import{g as o,c as n}from"./p-871106e0.js";import{OVERLAY_BACK_BUTTON_PRIORITY as t}from"./p-add30d46.js";import{c as e,f as i,a,r,g as s}from"./p-d68092b7.js";
/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */let d=0;const c=new WeakMap,l=o=>({create:n=>b(o,n),dismiss:(n,t,e)=>j(document,n,t,o,e),getTop:async()=>k(document,o)}),u=l("ion-alert"),p=l("ion-action-sheet"),v=l("ion-modal"),m=l("ion-popover"),f=l("ion-toast"),y=o=>{"undefined"!=typeof document&&g(document);const n=d++;o.overlayIndex=n,o.hasAttribute("id")||(o.id=`ion-overlay-${n}`)},b=(o,n)=>"undefined"!=typeof window&&void 0!==window.customElements?window.customElements.whenDefined(o).then((()=>{const t=document.createElement(o);return t.classList.add("overlay-hidden"),Object.assign(t,Object.assign(Object.assign({},n),{hasController:!0})),T(document).appendChild(t),new Promise((o=>e(t,o)))})):Promise.resolve(),w='[tabindex]:not([tabindex^="-"]), input:not([type=hidden]):not([tabindex^="-"]), textarea:not([tabindex^="-"]), button:not([tabindex^="-"]), select:not([tabindex^="-"]), .ion-focusable:not([tabindex^="-"])',h=(o,n)=>{let t=o.querySelector(w);const e=null==t?void 0:t.shadowRoot;e&&(t=e.querySelector(w)||t),t?i(t):n.focus()},x=(o,n)=>{const t=Array.from(o.querySelectorAll(w));let e=t.length>0?t[t.length-1]:null;const i=null==e?void 0:e.shadowRoot;i&&(e=i.querySelector(w)||e),e?e.focus():n.focus()},g=o=>{0===d&&(d=1,o.addEventListener("focus",(n=>{((o,n)=>{const t=k(n,"ion-alert,ion-action-sheet,ion-loading,ion-modal,ion-picker,ion-popover"),e=o.target;t&&e&&(t.classList.contains("ion-disable-focus-trap")||(t.shadowRoot?(()=>{if(t.contains(e))t.lastFocus=e;else{const o=t.lastFocus;h(t,t),o===n.activeElement&&x(t,t),t.lastFocus=n.activeElement}})():(()=>{if(t===e)t.lastFocus=void 0;else{const o=s(t);if(!o.contains(e))return;const i=o.querySelector(".ion-overlay-wrapper");if(!i)return;if(i.contains(e))t.lastFocus=e;else{const o=t.lastFocus;h(i,t),o===n.activeElement&&x(i,t),t.lastFocus=n.activeElement}}})()))})(n,o)}),!0),o.addEventListener("ionBackButton",(n=>{const e=k(o);(null==e?void 0:e.backdropDismiss)&&n.detail.register(t,(()=>e.dismiss(void 0,N)))})),o.addEventListener("keyup",(n=>{if("Escape"===n.key){const n=k(o);(null==n?void 0:n.backdropDismiss)&&n.dismiss(void 0,N)}})))},j=(o,n,t,e,i)=>{const a=k(o,e,i);return a?a.dismiss(n,t):Promise.reject("overlay does not exist")},k=(o,n,t)=>{const e=((o,n)=>(void 0===n&&(n="ion-alert,ion-action-sheet,ion-loading,ion-modal,ion-picker,ion-popover,ion-toast"),Array.from(o.querySelectorAll(n)).filter((o=>o.overlayIndex>0))))(o,n).filter((o=>!o.classList.contains("overlay-hidden")));return void 0===t?e[e.length-1]:e.find((o=>o.id===t))},O=(o=!1)=>{const n=T(document).querySelector("ion-router-outlet, ion-nav, #ion-view-container-root");n&&(o?n.setAttribute("aria-hidden","true"):n.removeAttribute("aria-hidden"))},P=async(t,e,i,a,r)=>{var s,d;if(t.presented)return;O(!0),t.presented=!0,t.willPresent.emit(),null===(s=t.willPresentShorthand)||void 0===s||s.emit();const c=o(t),l=t.enterAnimation?t.enterAnimation:n.get(e,"ios"===c?i:a);await z(t,l,t.el,r)&&(t.didPresent.emit(),null===(d=t.didPresentShorthand)||void 0===d||d.emit()),"ION-TOAST"!==t.el.tagName&&A(t.el),!t.keyboardClose||null!==document.activeElement&&t.el.contains(document.activeElement)||t.el.focus()},A=async o=>{let n=document.activeElement;if(!n)return;const t=null==n?void 0:n.shadowRoot;t&&(n=t.querySelector(w)||n),await o.onDidDismiss(),n.focus()},B=async(t,e,i,a,r,s,d)=>{var l,u;if(!t.presented)return!1;O(!1),t.presented=!1;try{t.el.style.setProperty("pointer-events","none"),t.willDismiss.emit({data:e,role:i}),null===(l=t.willDismissShorthand)||void 0===l||l.emit({data:e,role:i});const p=o(t),v=t.leaveAnimation?t.leaveAnimation:n.get(a,"ios"===p?r:s);"gesture"!==i&&await z(t,v,t.el,d),t.didDismiss.emit({data:e,role:i}),null===(u=t.didDismissShorthand)||void 0===u||u.emit({data:e,role:i}),c.delete(t),t.el.classList.add("overlay-hidden"),t.el.style.removeProperty("pointer-events")}catch(o){console.error(o)}return t.el.remove(),!0},T=o=>o.querySelector("ion-app")||o.body,z=async(o,t,e,i)=>{e.classList.remove("overlay-hidden");const a=t(o.el,i);o.animated&&n.getBoolean("animated",!0)||a.duration(0),o.keyboardClose&&a.beforeAddWrite((()=>{const o=e.ownerDocument.activeElement;(null==o?void 0:o.matches("input,ion-input, ion-textarea"))&&o.blur()}));const r=c.get(o)||[];return c.set(o,[...r,a]),await a.play(),!0},C=(o,n)=>{let t;const e=new Promise((o=>t=o));return E(o,n,(o=>{t(o.detail)})),e},E=(o,n,t)=>{const e=i=>{r(o,n,e),t(i)};a(o,n,e)},G=o=>"cancel"===o||o===N,I=o=>o(),M=(o,t)=>{if("function"==typeof o)return n.get("_zoneGate",I)((()=>{try{return o(t)}catch(o){throw o}}))},N="backdrop";export{N as B,u as a,P as b,c,B as d,C as e,m as f,k as g,p as h,G as i,h as j,v as m,y as p,M as s,f as t}