import"./js/vue2.RHmKp0B5.js";import{x as a,c as h,C as f,m as n,d,o as c,D as _,t as g,a as y,l as R,X as C}from"./js/vue.esm-bundler.CWQFYt9y.js";import{l as A}from"./js/index.ByT4ejSG.js";import{l as w}from"./js/index.BB7B6rSp.js";import{u as k,A as S,l as E}from"./js/links.DERf9LZO.js";/* empty css                */import{a as L}from"./js/addons.JFEbod-N.js";import{C as v}from"./js/Index.AHxBjomD.js";import{C as x}from"./js/Index.CU6y9mEJ.js";import{_ as H}from"./js/_plugin-vue_export-helper.BN1snXvA.js";import{i as b}from"./js/isEmpty.Ci-QAhhs.js";import"./js/translations.Buvln_cw.js";import"./js/default-i18n.Bd0Z306Z.js";import"./js/constants.B6ynd7gz.js";import"./js/Caret.iRBf3wcH.js";import"./js/helpers.D2xRWOvn.js";import"./js/upperFirst.CP4N4hLd.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.XwB3Xa5p.js";import"./js/JsonValues.D25FTfEu.js";import"./js/ProBadge.WwPkDor4.js";import"./js/External.Bfg4674G.js";import"./js/escapeRegExp.Cd2tL9wj.js";import"./js/Exclamation.DKtT8kuH.js";import"./js/Checkbox.D2dfpbIi.js";import"./js/Checkmark.pCOnqh_g.js";import"./js/Gear.aQH8e4fl.js";import"./js/Slide.CRIn0kdn.js";import"./js/Date.BWaxwlz2.js";import"./js/DatePicker.BcxlzFcx.js";import"./js/get.BT85ybc8.js";import"./js/isUndefined.CwgbffFV.js";import"./js/_getTag.CQI1SwGE.js";import"./js/debounce.DX0w6jjQ.js";import"./js/toNumber.LBtMnsWu.js";import"./js/_baseTrim.BYZhh0MR.js";import"./js/Tooltip.DiN2Zjvc.js";import"./js/Plus.DrDYrwHh.js";const $={setup(){return{rootStore:k()}},components:{CoreModal:v,CoreAddRedirection:x},data(){return{addons:L,urls:[],display:!1,target:null,loading:!1,strings:{modalHeader:this.$t.__("Add a Redirect",this.$td),redirectAdded:this.$t.sprintf(this.$t.__('%2$sYour redirect was added and you may edit it <a href="%1$s" target="_blank">here</a>.%3$s',this.$td),this.rootStore.aioseo.urls.aio.redirects,"<strong>","</strong>")},watchClasses:["aioseo-redirects-slug-changed","aioseo-redirects-trashed-post"]}},computed:{classSelectors(){return"."+this.watchClasses.join(", .")}},methods:{reload(){var e,o;this.display=!1;const t=(o=(e=this.target)==null?void 0:e.parentElement)==null?void 0:o.parentElement;if(t&&(t.classList.contains("components-notice__content")||t.classList.contains("notice"))){t.innerHTML="<p>"+this.strings.redirectAdded+"</p>";return}this.target.outerHTML=this.strings.redirectAdded},loadRedirect(t){this.loading=!0,S.get(this.$links.restUrl("redirects/manual-redirects/"+t)).then(e=>{this.urls=e.body.redirects,this.loading=!1}).catch(e=>console.error("Redirect modal failed to load the redirect data.",e))},preloadRedirect(){const t=document.querySelector(this.classSelectors);if(t){const e=this.getElementRedirectHash(t);if(!e)return;this.loadRedirect(e)}},watchClicks(){document.body.onclick=t=>{var o;if(!((o=t.target)!=null&&o.classList))return;let e=!1;this.watchClasses.forEach(i=>{t.target.classList.contains(i)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,b(this.url)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(t){return new URLSearchParams(t.href).get("aioseo-manual-urls")}},async created(){this.preloadRedirect(),this.watchClicks(),window.aioseoBus.$on("wp-core-notice-created",()=>{this.preloadRedirect()})}},B={key:0,class:"aioseo-redirects-add-redirect-standalone"},D={class:"bd"};function N(t,e,o,i,r,p){const m=a("core-add-redirection"),u=a("core-modal");return r.addons.isActive("aioseo-redirects")?(c(),h("div",B,[f(u,{show:r.display,classes:["aioseo-redirects"],onClose:e[0]||(e[0]=T=>r.display=!1)},{headerTitle:n(()=>[_(g(r.strings.modalHeader),1)]),body:n(()=>[y("div",D,[r.loading?d("",!0):(c(),R(m,{key:0,urls:r.urls,target:r.urls[0].target?r.urls[0].target:"/",disableSource:!0,onAddedRedirect:p.reload},null,8,["urls","target","onAddedRedirect"]))])]),_:1},8,["show"])])):d("",!0)}const P=H($,[["render",N]]),l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);let s=C({...P,name:"Standalone/Redirects/AddRedirect"});s=A(s);s=w(s);E(s);s.mount("#aioseo-redirects-add-redirect-standalone");
