import"./js/vue2.Bk-dUoBE.js";import{x as a,c as h,C as f,m as n,d as c,o as d,D as _,t as g,a as y,l as R,X as C}from"./js/vue.esm-bundler.DqIKZLqK.js";import{l as w}from"./js/index.Bl99HVqA.js";import{l as A}from"./js/index.sD-vStxq.js";import{c as k,B as S,l as v}from"./js/links.DYfvsp_u.js";/* empty css                */import{a as x}from"./js/addons.qvyITi11.js";import{C as E}from"./js/Index.Dq2Y3sD9.js";import{C as L}from"./js/Index.Di8wjR57.js";import{_ as H}from"./js/_plugin-vue_export-helper.BN1snXvA.js";import{i as b}from"./js/isEmpty.DBp8qITK.js";import"./js/translations.Buvln_cw.js";import"./js/default-i18n.Bd0Z306Z.js";import"./js/constants.B6ynd7gz.js";import"./js/Caret.CE8P-qnG.js";import"./js/helpers.Ccl21t4W.js";import"./js/upperFirst.BADaHsnX.js";import"./js/_stringToArray.DnK4tKcY.js";import"./js/toString.C7L0MmPq.js";import"./js/JsonValues.D25FTfEu.js";import"./js/ProBadge.CjKJMApR.js";import"./js/External.BpSjuEvK.js";import"./js/escapeRegExp.v3ainh1g.js";import"./js/Exclamation.BWU5OCVZ.js";import"./js/Checkbox.DUOJ_PLM.js";import"./js/Checkmark.CUxYD2Fh.js";import"./js/Gear.CG2jqT3t.js";import"./js/Slide.Qz9BWVTI.js";import"./js/Date.DpLFUdAk.js";import"./js/DatePicker.C34BvyoW.js";import"./js/Calendar.q2eLUa1q.js";import"./js/get.25styALf.js";import"./js/isUndefined.Bn7yhabI.js";import"./js/_getTag.C8a9uvOi.js";import"./js/debounce.BpUWE6mp.js";import"./js/toNumber.zVV478Sd.js";import"./js/_baseTrim.BYZhh0MR.js";import"./js/isEqual.B1WeH0aP.js";import"./js/_baseIsEqual.Ipwc5MlE.js";import"./js/Tooltip.zaM0rDUW.js";import"./js/Plus.D1ndwb34.js";const $={setup(){return{rootStore:k()}},components:{CoreModal:E,CoreAddRedirection:L},data(){return{addons:x,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.urls)&&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.$nextTick(()=>{this.preloadRedirect()})})}},B={key:0,class:"aioseo-redirects-add-redirect-standalone"},T={class:"bd"};function D(t,e,o,i,r,p){const m=a("core-add-redirection"),u=a("core-modal");return r.addons.isActive("aioseo-redirects")?(d(),h("div",B,[f(u,{show:r.display,classes:["aioseo-redirects"],onClose:e[0]||(e[0]=P=>r.display=!1),"allow-overflow":""},{headerTitle:n(()=>[_(g(r.strings.modalHeader),1)]),body:n(()=>[y("div",T,[r.loading?c("",!0):(d(),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"])])):c("",!0)}const N=H($,[["render",D]]),l=document.createElement("div");l.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(l);let s=C({...N,name:"Standalone/Redirects/AddRedirect"});s=w(s);s=A(s);v(s);s.mount("#aioseo-redirects-add-redirect-standalone");
