import{b as a}from"./p-e680e7e4.js";import{j as o,r as t}from"./p-4f82c566.js";let e=0;const r=o=>{a.hasDocument&&c(document);const t=e++;o.overlayIndex=t,o.el.hasAttribute("id")||(o.el.id=`bal-overlay-${t}`)},s=(a,o)=>(void 0===o&&(o="bal-modal,bal-snackbar,bal-toast"),Array.from(a.querySelectorAll(o)).filter((a=>a.overlayIndex>0))),n=(a,o,t)=>{const e=s(a,o);return void 0===t?e[e.length-1]:e.find((a=>a.id===t))},c=a=>{0===e&&(e=1,a.addEventListener("keyup",(o=>{if("Escape"===o.key){const o=n(a);o&&o.dismiss(void 0,"backdrop")}})))},i=async(a,o,t,e)=>{if(!a.presented)return!1;try{a.el.style.setProperty("pointer-events","none"),a.willDismiss.emit({data:o,role:t}),await e(),a.presented=!1,a.didDismiss.emit({data:o,role:t})}catch(o){a.presented=!1,console.error(o)}return a.el.remove(),!0},l=(a,o)=>{let t;const e=new Promise((a=>t=a));return d(a,o,(a=>{t(a.detail)})),e},d=(a,e,r)=>{const s=o=>{t(a,e,s),r(o)};o(a,e,s)};export{n as a,i as d,l as e,s as g,r as p}