import{u as f}from"./links.C572zDFG.js";import{S as _}from"./Caret.CGwYaMo_.js";import{_ as y,T as m,w as u}from"./_plugin-vue_export-helper.BLXtEB-G.js";import{v as w,o as t,k as v,a as l,B as d,l as h,c as r,b as n,m as i,aa as C,ab as g}from"./runtime-core.esm-bundler.DMBo7TXk.js";const k={setup(){return{rootStore:f()}},emits:["close"],components:{SvgClose:_},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"},b={class:"modal-body"},A={key:1,class:"modal-container__footer"};function N(e,a,s,T,E,o){const p=w("svg-close");return t(),v(g,{to:s.teleportTo},[l("div",{show:s.show,class:C(["aioseo-app aioseo-modal",[...o.cssClasses]])},[d(m,{name:"modal-background"},{default:h(()=>[s.show?(t(),r("div",B)):n("",!0)]),_:1}),d(m,{name:"modal-content"},{default:h(()=>[s.show?(t(),r("div",{key:0,class:"modal-wrapper",onClick:a[1]||(a[1]=u((...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]=u((...c)=>o.closeModal&&o.closeModal(...c),["stop"]))},[d(p,{onClick:o.closeModal},null,8,["onClick"])])])])),l("div",b,[i(e.$slots,"body")]),e.$slots.footer?(t(),r("div",A,[i(e.$slots,"footer")])):n("",!0)])])):n("",!0)]),_:3})],10,M)],8,["to"])}const O=y(k,[["render",N]]);export{O as C};
