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