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