import{v as a,c as _,C as g,l as n,b as c,o as d,x as y,t as R,a as C,k as w,Y as k}from"./js/runtime-dom.esm-bundler.DKw-RQqs.js";import{l as A}from"./js/index.9ItM203B.js";import{l as S}from"./js/index.Olu2afa7.js";import{u as v,B as x,e as E,l as L}from"./js/index.ByF2aI-G.js";/* empty css                */import{a as b}from"./js/addons.C_QAj7aO.js";import{C as H}from"./js/Index.CzfUkh0l.js";import{C as B}from"./js/Index.D63mawWP.js";import"./js/translations.Ur07Kmot.js";import{_ as T}from"./js/_plugin-vue_export-helper.BN1snXvA.js";import{i as N}from"./js/isEmpty.CU5xp7vT.js";import{_ as l,a as P}from"./js/default-i18n.DvLqo3S3.js";import"./js/Caret.DMa7g0j7.js";import"./js/helpers.yjC6K_2A.js";import"./js/upperFirst.BjBqmCj-.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.Dc7QMRQR.js";import"./js/constants.DfsCWbZk.js";import"./js/JsonValues.CjR5TkFn.js";import"./js/ProBadge.BJ3spTo5.js";import"./js/External.DwsNMWba.js";import"./js/escapeRegExp.Cr4ECp1J.js";import"./js/Exclamation.QdVEhIVR.js";import"./js/Checkbox.BAIONgTE.js";import"./js/Checkmark.BedAg8BV.js";import"./js/Gear.CdOSWQ3A.js";import"./js/Slide.CdVEnD7S.js";import"./js/date.DgiqPou0.js";import"./js/DatePicker.Cf1_1YyU.js";import"./js/Calendar.DfOxy3oe.js";import"./js/pick.YiTG4DgQ.js";import"./js/_baseSet.Bbqt6CgN.js";import"./js/_getTag.KnvRqur7.js";import"./js/debounce.Dn172j5X.js";import"./js/toNumber.DaBXB5a2.js";import"./js/_baseTrim.BYZhh0MR.js";import"./js/isEqual.DPyFnjxk.js";import"./js/_baseIsEqual.BLPD4oRg.js";import"./js/Tooltip.B0brI66q.js";import"./js/Plus.CnHRD0g1.js";const p="all-in-one-seo-pack",U={setup(){return{rootStore:v()}},components:{CoreModal:H,CoreAddRedirection:B},data(){return{addons:b,urls:[],display:!1,target:null,loading:!1,strings:{modalHeader:l("Add a Redirect",p),redirectAdded:P(l('%2$sYour redirect was added and you may edit it <a href="%1$s" target="_blank">here</a>.%3$s',p),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 t,o;this.display=!1;const e=(o=(t=this.target)==null?void 0:t.parentElement)==null?void 0:o.parentElement;if(e&&(e.classList.contains("components-notice__content")||e.classList.contains("notice"))){e.innerHTML="<p>"+this.strings.redirectAdded+"</p>";return}this.target.outerHTML=this.strings.redirectAdded},loadRedirect(e){this.loading=!0,x.get(E.restUrl("redirects/manual-redirects/"+e)).then(t=>{this.urls=t.body.redirects,this.loading=!1}).catch(t=>console.error("Redirect modal failed to load the redirect data.",t))},preloadRedirect(){const e=document.querySelector(this.classSelectors);if(e){const t=this.getElementRedirectHash(e);if(!t)return;this.loadRedirect(t)}},watchClicks(){document.body.onclick=e=>{var o;if(!((o=e.target)!=null&&o.classList))return;let t=!1;this.watchClasses.forEach(i=>{e.target.classList.contains(i)&&(t=!0)}),t&&(e.preventDefault(),this.target=e.target,this.display=!0,N(this.urls)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(e){return new URLSearchParams(e.href).get("aioseo-manual-urls")}},async created(){this.preloadRedirect(),this.watchClicks(),window.aioseoBus.$on("wp-core-notice-created",()=>{this.$nextTick(()=>{this.preloadRedirect()})})}},V={key:0,class:"aioseo-redirects-add-redirect-standalone"},D={class:"bd"};function M(e,t,o,i,r,u){const h=a("core-add-redirection"),f=a("core-modal");return r.addons.isActive("aioseo-redirects")?(d(),_("div",V,[g(f,{show:r.display,classes:["aioseo-redirects"],onClose:t[0]||(t[0]=j=>r.display=!1),"allow-overflow":""},{headerTitle:n(()=>[y(R(r.strings.modalHeader),1)]),body:n(()=>[C("div",D,[r.loading?c("",!0):(d(),w(h,{key:0,urls:r.urls,target:r.urls[0].target?r.urls[0].target:"/",disableSource:!0,onAddedRedirect:u.reload},null,8,["urls","target","onAddedRedirect"]))])]),_:1},8,["show"])])):c("",!0)}const Y=T(U,[["render",M]]),m=document.createElement("div");m.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(m);let s=k({...Y,name:"Standalone/Redirects/AddRedirect"});s=A(s);s=S(s);L(s);s.mount("#aioseo-redirects-add-redirect-standalone");
