import{u as _}from"./links.7c59a081.js";import{S as f}from"./Caret.02d7c74a.js";import{x as y,o,k as w,a as l,C as d,l as m,c as n,b as r,T as u,m as i,H as h,I as v,K as C}from"./vue.runtime.esm-bundler.4a881941.js";import{_ as g}from"./_plugin-vue_export-helper.abeb2ae0.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},watch:{show(s){if(s){this.startListening(),this.scrollToElement(),this.rootStore.setActiveModal(this.modalName||this._uid);return}this.closeModal(),this.stopListening()}},computed:{cssClasses(){const s=Array.isArray(this.classes)?this.classes:[];return this.allowOverflow&&s.push("allow-overflow"),Array.isArray(this.classes)?this.classes:[]}},methods:{scrollToElement(){const s=this.$el.getElementsByClassName?this.$el.getElementsByClassName("component-wrapper")[0]:null;setTimeout(()=>{s&&(s.firstChild.scrollTop=0)},10)},escapeListener(s){s.key==="Escape"&&(this.modalName||this._uid)===this.rootStore.modals.active&&(s.stopPropagation(),this.closeModal())},maybeCloseModal(s){this.allowBgClose&&s.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"},A={key:0,class:"modal-header"},N={class:"modal-body"},S={key:1,class:"modal-container__footer"};function b(s,t,a,E,T,e){const p=y("svg-close");return o(),w(C,{to:"#aioseo-modal-portal"},[l("div",{show:a.show,class:v(["aioseo-app aioseo-modal",[...e.cssClasses]])},[d(u,{name:"modal-background"},{default:m(()=>[a.show?(o(),n("div",B)):r("",!0)]),_:1}),d(u,{name:"modal-content"},{default:m(()=>[a.show?(o(),n("div",{key:0,class:"modal-wrapper",onClick:t[1]||(t[1]=h((...c)=>e.maybeCloseModal&&e.maybeCloseModal(...c),["stop"]))},[l("div",L,[a.noHeader?r("",!0):(o(),n("div",A,[i(s.$slots,"header",{},()=>[i(s.$slots,"headerTitle"),l("button",{class:"close",type:"button",onClick:t[0]||(t[0]=h((...c)=>e.closeModal&&e.closeModal(...c),["stop"]))},[d(p,{onClick:e.closeModal},null,8,["onClick"])])])])),l("div",N,[i(s.$slots,"body")]),s.$slots.footer?(o(),n("div",S,[i(s.$slots,"footer")])):r("",!0)])])):r("",!0)]),_:3})],10,M)])}const O=g(k,[["render",b]]);export{O as C};
