import{_,r as d,o as i,c as y,h as c,w as l,e as C,t as $,f as R,a,b as w}from"./js/_plugin-vue_export-helper.2d9794a3.js";import{l as A}from"./js/index.c8cd2612.js";import{l as k}from"./js/index.fd0fcee8.js";import{g as b,m as p,s as m}from"./js/index.02a5ed9a.js";import{C as v}from"./js/Portal.c64d3c93.js";import{C as E}from"./js/Index.bff498e4.js";import{i as L}from"./js/isEmpty.bf352345.js";import"./js/client.e7a26247.js";import"./js/_commonjsHelpers.f84db168.js";import"./js/vuex.esm-bundler.8589b2dd.js";import"./js/default-i18n.ab92175e.js";import"./js/helpers.de7566d0.js";import"./js/constants.e9426d11.js";import"./js/isArrayLikeObject.c492f682.js";import"./js/Caret.42a820e0.js";import"./js/Index.1fd8fc42.js";import"./js/WpTable.8adff4c1.js";import"./js/RequiresUpdate.52f5acf2.js";import"./js/postContent.741ce73c.js";import"./js/cleanForSlug.1898a430.js";import"./js/html.14f2a8b9.js";import"./js/JsonValues.870a4901.js";import"./js/SaveChanges.bc66cd69.js";import"./js/strings.225838ed.js";import"./js/isString.d3a213af.js";import"./js/ProBadge.bcf74c08.js";import"./js/External.e98f124d.js";import"./js/Exclamation.9b2c9d16.js";import"./js/Checkbox.b4e8b6fc.js";import"./js/Checkmark.c5326878.js";import"./js/Row.5e452de4.js";import"./js/Gear.b05c5b07.js";import"./js/Slide.cd756e61.js";import"./js/Tooltip.ae0bcccb.js";import"./js/Plus.303de95b.js";import"./js/_getTag.af0e2981.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=w(B);r=A(r);r=k(r);r.use(m);m._vm=r;r.config.globalProperties.$aioseo=window.aioseo;r.mount("#aioseo-redirects-add-redirect-standalone");
