import{n as d,V as a}from"./js/vueComponentNormalizer.67c9b86e.js";import"./js/index.81e35b24.js";import{h as c,m as i,s as l}from"./js/index.7b63dad7.js";import{C as p}from"./js/Portal.6fcb130a.js";import{C as m}from"./js/Index.dca1e202.js";import{i as u}from"./js/isEmpty.a9afd21a.js";import"./js/client.90beecd8.js";import"./js/_commonjsHelpers.10c44588.js";import"./js/translations.3bc9d58c.js";import"./js/default-i18n.0e73c33c.js";import"./js/Caret.eeb84d06.js";import"./js/helpers.a2b0759e.js";import"./js/constants.8bff9f56.js";import"./js/isArrayLikeObject.5268a676.js";import"./js/portal-vue.esm.18ed59c3.js";import"./js/vuex.esm.19624049.js";import"./js/Index.cb09fd7a.js";import"./js/WpTable.36ecda37.js";import"./js/attachments.e5102eba.js";import"./js/cleanForSlug.7a45fb51.js";import"./js/html.bcbe747e.js";import"./js/JsonValues.08065e69.js";import"./js/SaveChanges.68e73792.js";import"./js/ProBadge.3e5c17e9.js";import"./js/External.98cc7a29.js";import"./js/Exclamation.9f3b358f.js";import"./js/Checkbox.1903802a.js";import"./js/Checkmark.cdcd77fe.js";import"./js/Row.2d17f2cd.js";import"./js/Gear.7c17fabe.js";import"./js/Slide.9538a421.js";import"./js/Tooltip.d723c3c3.js";import"./js/Plus.92a90910.js";import"./js/_getTag.e79f4b6e.js";var h=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.$addons.isActive("aioseo-redirects")?r("div",{staticClass:"aioseo-redirects-add-redirect-standalone"},[t.display?r("core-modal-portal",{attrs:{classes:["aioseo-redirects","modal"]},on:{close:function(s){t.display=!1}}},[r("div",{attrs:{slot:"headerTitle"},slot:"headerTitle"},[t._v(" "+t._s(t.strings.modalHeader)+" ")]),r("div",{attrs:{slot:"body"},slot:"body"},[t.loading?t._e():r("core-add-redirection",{attrs:{urls:t.urls,target:t.urls[0].target?t.urls[0].target:"/",disableSource:!0},on:{"added-redirect":t.reload}})],1)]):t._e()],1):t._e()},_=[];const f={components:{CoreModalPortal:p,CoreAddRedirection:m},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,r;this.display=!1;const t=(r=(e=this.target)==null?void 0:e.parentElement)==null?void 0:r.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 r;if(!((r=t.target)!=null&&r.classList))return;let e=!1;this.watchClasses.forEach(s=>{t.target.classList.contains(s)&&(e=!0)}),e&&(t.preventDefault(),this.target=t.target,this.display=!0,u(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 c(this.$http);this.$set(this.$store.state,"addons",i([...this.$store.state.addons],[...t])),this.$set(this.$store.state,"redirects",i({...this.$store.state.redirects},{...e})),this.preloadRedirect(),this.watchClicks(),this.$bus.$on("wp-core-notice-created",()=>{this.preloadRedirect()})}},o={};var g=d(f,h,_,!1,y,null,null,null);function y(t){for(let e in o)this[e]=o[e]}const $=function(){return g.exports}(),n=document.createElement("div");n.id="aioseo-redirects-add-redirect-standalone";document.body.appendChild(n);a.prototype.$aioseo=window.aioseo;new a({store:l,render:t=>t($)}).$mount("#aioseo-redirects-add-redirect-standalone");
