import{k as o}from"./p-8e32a29b.js";let t=0;const n=o=>({create:t=>c(o,t),dismiss:(t,n,e)=>u(document,t,n,o,e),getTop:async()=>p(document,o)}),e=n("ion-alert"),a=n("ion-action-sheet"),i=n("ion-picker"),s=n("ion-popover"),r=o=>{const n=document;d(n);const e=t++;o.overlayIndex=e,o.hasAttribute("id")||(o.id=`ion-overlay-${e}`)},c=(o,t)=>customElements.whenDefined(o).then(()=>{const n=document,e=n.createElement(o);return e.classList.add("overlay-hidden"),Object.assign(e,t),f(n).appendChild(e),e.componentOnReady()}),d=o=>{0===t&&(t=1,o.addEventListener("focusin",t=>{const n=p(o);if(n&&n.backdropDismiss&&!k(n,t.target)){const o=n.querySelector("input,button");o&&o.focus()}}),o.addEventListener("ionBackButton",t=>{const n=p(o);n&&n.backdropDismiss&&t.detail.register(100,()=>n.dismiss(void 0,j))}),o.addEventListener("keyup",t=>{if("Escape"===t.key){const t=p(o);t&&t.backdropDismiss&&t.dismiss(void 0,j)}}))},u=(o,t,n,e,a)=>{const i=p(o,e,a);return i?i.dismiss(t,n):Promise.reject("overlay does not exist")},p=(o,t,n)=>{const e=((o,t)=>(void 0===t&&(t="ion-alert,ion-action-sheet,ion-loading,ion-modal,ion-picker,ion-popover,ion-toast"),Array.from(o.querySelectorAll(t)).filter(o=>o.overlayIndex>0)))(o,t);return void 0===n?e[e.length-1]:e.find(o=>o.id===n)},l=async(t,n,e,a,i)=>{if(t.presented)return;t.presented=!0,t.willPresent.emit();const s=t.enterAnimation?t.enterAnimation:o.get(n,"ios"===t.mode?e:a);await m(t,s,t.el,i)&&t.didPresent.emit()},y=async(t,n,e,a,i,s,r)=>{if(!t.presented)return!1;t.presented=!1;try{t.willDismiss.emit({data:n,role:e});const c=t.leaveAnimation?t.leaveAnimation:o.get(a,"ios"===t.mode?i:s);await m(t,c,t.el,r),t.didDismiss.emit({data:n,role:e})}catch(o){console.error(o)}return t.el.remove(),!0},f=o=>o.querySelector("ion-app")||o.body,m=async(t,n,e,a)=>{if(t.animation)return t.animation.destroy(),t.animation=void 0,!1;e.classList.remove("overlay-hidden");const i=e.shadowRoot||t.el;let s,r=!0;try{const o=await __sc_import_dos_wc_library("./p-559f1738.js");s=await o.create(n,i,a)}catch(o){(s=n(i,a)).fill("both"),r=!1}t.animation=s,t.animated&&o.getBoolean("animated",!0)||s.duration(0),t.keyboardClose&&s.beforeAddWrite(()=>{const o=e.ownerDocument.activeElement;o&&o.matches("input, ion-input, ion-textarea")&&o.blur()});const c=void 0===await s.playAsync()||s.hasCompleted;return r&&s.destroy(),t.animation=void 0,c},v=(o,t)=>{let n;const e=new Promise(o=>n=o);return h(o,t,o=>{n(o.detail)}),e},h=(o,t,n)=>{const e=a=>{o.removeEventListener(t,e),n(a)};o.addEventListener(t,e)},b=o=>"cancel"===o||o===j,k=(o,t)=>{for(;t;){if(t===o)return!0;t=t.parentElement}return!1},w=o=>o(),_=(t,n)=>{if("function"==typeof t)return o.get("_zoneGate",w)(()=>{try{return t(n)}catch(o){console.error(o)}})},j="backdrop";export{j as B,l as a,u as b,c,y as d,v as e,i as f,p as g,s as h,b as i,a as j,e as k,r as p,_ as s};