import{u as _}from"./links.C2upUfsO.js";import{S as f}from"./Caret.iRBf3wcH.js";import{x as y,o as t,l as w,a as l,C as d,m,c as r,d as n,T as u,q as i,G as h,H as C,J as g}from"./vue.esm-bundler.CWQFYt9y.js";import{_ as v}from"./_plugin-vue_export-helper.BN1snXvA.js";const k={setup(){return{rootStore:_()}},emits:["close"],components:{SvgClose:f},props:{classes:{type:Array,default(){return[]}},allowBgClose:{type:Boolean,default:!0},noHeader:Boolean,allowOverflow:Boolean,show:Boolean,modalName:String,teleportTo:{type:String,default(){return"#aioseo-modal-portal"}}},watch:{show(e){if(e){this.startListening(),this.scrollToElement(),this.rootStore.setActiveModal(this.modalName||this._uid);return}this.closeModal(),this.stopListening()}},computed:{cssClasses(){const e=Array.isArray(this.classes)?this.classes:[];return this.allowOverflow&&e.push("allow-overflow"),Array.isArray(this.classes)?this.classes:[]}},methods:{scrollToElement(){const e=this.$el.getElementsByClassName?this.$el.getElementsByClassName("component-wrapper")[0]:null;setTimeout(()=>{e&&(e.firstChild.scrollTop=0)},10)},escapeListener(e){e.key==="Escape"&&(this.modalName||this._uid)===this.rootStore.modals.active&&(e.stopPropagation(),this.closeModal())},maybeCloseModal(e){this.allowBgClose&&e.target.classList.contains("modal-wrapper")&&(this.modalName||this._uid)===this.rootStore.modals.active&&this.closeModal()},startListening(){document.addEventListener("keydown",this.escapeListener,!0)},stopListening(){document.removeEventListener("keydown",this.escapeListener)},closeModal(){this.$emit("close"),this.rootStore.unsetActiveModal(this.modalName||this._uid)}}},M=["show"],B={key:0,class:"modal-mask"},L={class:"modal-container"},S={key:0,class:"modal-header"},A={class:"modal-body"},N={key:1,class:"modal-container__footer"};function T(e,a,s,b,E,o){const p=y("svg-close");return t(),w(g,{to:s.teleportTo},[l("div",{show:s.show,class:C(["aioseo-app aioseo-modal",[...o.cssClasses]])},[d(u,{name:"modal-background"},{default:m(()=>[s.show?(t(),r("div",B)):n("",!0)]),_:1}),d(u,{name:"modal-content"},{default:m(()=>[s.show?(t(),r("div",{key:0,class:"modal-wrapper",onClick:a[1]||(a[1]=h((...c)=>o.maybeCloseModal&&o.maybeCloseModal(...c),["stop"]))},[l("div",L,[s.noHeader?n("",!0):(t(),r("div",S,[i(e.$slots,"header",{},()=>[i(e.$slots,"headerTitle"),l("button",{class:"close",type:"button",onClick:a[0]||(a[0]=h((...c)=>o.closeModal&&o.closeModal(...c),["stop"]))},[d(p,{onClick:o.closeModal},null,8,["onClick"])])])])),l("div",A,[i(e.$slots,"body")]),e.$slots.footer?(t(),r("div",N,[i(e.$slots,"footer")])):n("",!0)])])):n("",!0)]),_:3})],10,M)],8,["to"])}const P=v(k,[["render",T]]);export{P as C};
