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