import{a as _}from"./index.317ad629.js";import{S as y}from"./Close.ccd53ef3.js";import{T as u,a as d}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 l,l as c,a2 as h,a4 as r,_ as m,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,HTMLElement],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"),e}},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"},L={class:"modal-container"},B={key:0,class:"modal-header"},T={class:"modal-body"},b={key:1,class:"modal-container__footer"};function E(e,o,a,A,p,t){const f=g("svg-close");return s(),C(k,{to:a.teleportTo},[p.shouldRender?(s(),l("div",{key:0,show:a.show,class:v(["aioseo-app aioseo-modal",[...t.cssClasses]])},[c(u,{name:"modal-background"},{default:h(()=>[a.show?(s(),l("div",S)):r("",!0)]),_:1}),c(u,{name:"modal-content"},{default:h(()=>[a.show?(s(),l("div",{key:0,class:"modal-wrapper",onClick:o[1]||(o[1]=d((...i)=>t.maybeCloseModal&&t.maybeCloseModal(...i),["stop"])),onContextmenu:o[2]||(o[2]=d(()=>{},["stop"]))},[m("div",L,[a.noHeader?r("",!0):(s(),l("div",B,[n(e.$slots,"header",{},()=>[n(e.$slots,"headerTitle"),m("button",{class:"close",type:"button",onClick:o[0]||(o[0]=d((...i)=>t.closeModal&&t.closeModal(...i),["stop"]))},[c(f,{width:"14",height:"14",onClick:t.closeModal},null,8,["onClick"])])])])),m("div",T,[n(e.$slots,"body")]),e.$slots.footer?(s(),l("div",b,[n(e.$slots,"footer")])):r("",!0)])],32)):r("",!0)]),_:3})],10,N)):r("",!0)],8,["to"])}const O=w(M,[["render",E]]);export{O as C};
