import{a as _}from"./index.e0fdfdc6.js";import{S as y}from"./Close.ccd53ef3.js";import{T as m,a as u}from"./runtime-dom.esm-bundler.dc49ee3e.js";import{_ as w}from"./_plugin-vue_export-helper.eefbdd86.js";import{a6 as g,o as s,a1 as C,c as a,l as d,a2 as h,a4 as l,_ as c,a3 as n,ae as v,ag as k}from"./runtime-core.esm-bundler.ce5add0b.js";const M={emits:["close"],setup(){return{rootStore:_()}},components:{SvgClose:y},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"}}},data(){return{shouldRender:!0}},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)}},beforeMount(){this.modalName&&(this.shouldRender=!this.rootStore.modals.rendered.has(this.modalName),this.rootStore.modals.rendered.add(this.modalName))},beforeUnmount(){this.modalName&&this.rootStore.modals.rendered.delete(this.modalName)}},N=["show"],S={key:0,class:"modal-mask"},B={class:"modal-container"},L={key:0,class:"modal-header"},b={class:"modal-body"},A={key:1,class:"modal-container__footer"};function T(e,r,t,E,p,o){const f=g("svg-close");return s(),C(k,{to:t.teleportTo},[p.shouldRender?(s(),a("div",{key:0,show:t.show,class:v(["aioseo-app aioseo-modal",[...o.cssClasses]])},[d(m,{name:"modal-background"},{default:h(()=>[t.show?(s(),a("div",S)):l("",!0)]),_:1}),d(m,{name:"modal-content"},{default:h(()=>[t.show?(s(),a("div",{key:0,class:"modal-wrapper",onClick:r[1]||(r[1]=u((...i)=>o.maybeCloseModal&&o.maybeCloseModal(...i),["stop"]))},[c("div",B,[t.noHeader?l("",!0):(s(),a("div",L,[n(e.$slots,"header",{},()=>[n(e.$slots,"headerTitle"),c("button",{class:"close",type:"button",onClick:r[0]||(r[0]=u((...i)=>o.closeModal&&o.closeModal(...i),["stop"]))},[d(f,{onClick:o.closeModal},null,8,["onClick"])])])])),c("div",b,[n(e.$slots,"body")]),e.$slots.footer?(s(),a("div",A,[n(e.$slots,"footer")])):l("",!0)])])):l("",!0)]),_:3})],10,N)):l("",!0)],8,["to"])}const O=w(M,[["render",T]]);export{O as C};
