import{_,r as d,o as i,c as y,b as c,w as l,y as C,t as $,a as R,f as a,A}from"./js/_plugin-vue_export-helper.a81c6319.js";import{l as w}from"./js/index.251e7289.js";import{l as k}from"./js/index.fae5bbc8.js";import{g as b,s as m}from"./js/index.4dbecc01.js";import{C as v}from"./js/Portal.76dcdd17.js";import{C as E}from"./js/Index.2cc2f3a4.js";import{i as L}from"./js/isEmpty.e7515279.js";import{a as p}from"./js/vuex.esm-bundler.55d3d5b3.js";import"./js/client.e7a26247.js";import"./js/_commonjsHelpers.f84db168.js";import"./js/default-i18n.0e8bc810.js";import"./js/helpers.51e5fd9c.js";import"./js/constants.e56e1512.js";import"./js/Caret.19bf2275.js";import"./js/Index.048705a6.js";import"./js/WpTable.3e09f0c1.js";import"./js/Index.3662e61b.js";import"./js/Row.d42459be.js";import"./js/RequiresUpdate.52f5acf2.js";import"./js/postContent.f08c6962.js";import"./js/cleanForSlug.d16f1e3a.js";import"./js/html.a669733f.js";import"./js/JsonValues.870a4901.js";import"./js/SaveChanges.c85e9ba4.js";import"./js/strings.ab2d1a4c.js";import"./js/isString.a41bd70d.js";import"./js/ProBadge.c7f4f378.js";import"./js/External.bfa99ff9.js";import"./js/Exclamation.09d9f31b.js";import"./js/Checkbox.ec732dfe.js";import"./js/Checkmark.36fbf255.js";import"./js/Gear.7e79093b.js";import"./js/Slide.4392623f.js";import"./js/Tooltip.c4cc47a2.js";import"./js/Plus.3cb7669b.js";import"./js/_getTag.4d7a4b86.js";const H={components:{CoreModalPortal:v,CoreAddRedirection:E},data(){return{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.$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,this.$http.get(this.$links.restUrl("redirects/manual-redirects/"+t)).then(e=>{this.urls=e.body.redirects,this.loading=!1}).catch(e=>console.log("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(n=>{t.target.classList.contains(n)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,L(this.url)&&this.loadRedirect(this.getElementRedirectHash(this.target)))}},getElementRedirectHash(t){return new URLSearchParams(t.href).get("aioseo-manual-urls")}},async created(){const{addons:t,redirects:e}=await b(this.$.appContext.app);this.$store.state.addons=p([...this.$store.state.addons],[...t]),this.$store.state.redirects=p({...this.$store.state.redirects},{...e}),this.preloadRedirect(),this.watchClicks(),this.$bus.$on("wp-core-notice-created",()=>{this.preloadRedirect()})}},x={key:0,class:"aioseo-redirects-add-redirect-standalone"},S={class:"bd"};function P(t,e,o,n,s,h){const g=d("core-add-redirection"),f=d("core-modal-portal");return t.$addons.isActive("aioseo-redirects")?(i(),y("div",x,[s.display?(i(),c(f,{key:0,classes:["aioseo-redirects","modal"],onClose:e[0]||(e[0]=T=>s.display=!1)},{headerTitle:l(()=>[C($(s.strings.modalHeader),1)]),body:l(()=>[R("div",S,[s.loading?a("",!0):(i(),c(g,{key:0,urls:s.urls,target:s.urls[0].target?s.urls[0].target:"/",disableSource:!0,onAddedRedirect:h.reload},null,8,["urls","target","onAddedRedirect"]))])]),_:1})):a("",!0)])):a("",!0)}const B=_(H,[["render",P]]),u=document.createElement("div");u.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(u);let r=A(B);r=w(r);r=k(r);r.use(m);m._vm=r;r.config.globalProperties.$aioseo=window.aioseo;r.mount("#aioseo-redirects-add-redirect-standalone");
