/*!
 * (C) Ionic http://ionicframework.com - MIT License
 */
import{b as t,d as e,M as n}from"./p-COLHV2ym.js";import{f as r}from"./p-C8IsBmNU.js";import{c as s}from"./p-BiTKUjko.js";import{c as a}from"./p-ByhhQryg.js";const o=t=>a().duration(t?400:300),i=e=>{let n,r;const s=e.width+8,i=a(),u=a();e.isEndSide?(n=s+"px",r="0px"):(n=-s+"px",r="0px"),i.addElement(e.menuInnerEl).fromTo("transform",`translateX(${n})`,`translateX(${r})`);const c="ios"===t(e),m=c?.2:.25;return u.addElement(e.backdropEl).fromTo("opacity",.01,m),o(c).addAnimation([i,u])},u=e=>{let n,r;const s=t(e),i=e.width,u="ios"===s;e.isEndSide?(n=-i+"px",r=i+"px"):(n=i+"px",r=-i+"px");const c=a().addElement(e.menuInnerEl).fromTo("transform",`translateX(${r})`,"translateX(0px)"),m=a().addElement(e.contentEl).fromTo("transform","translateX(0px)",`translateX(${n})`),p=a().addElement(e.backdropEl).fromTo("opacity",.01,.32);return o(u).addAnimation([c,m,p])},c=e=>{const n="ios"===t(e),r=e.width*(e.isEndSide?-1:1)+"px",s=a().addElement(e.contentEl).fromTo("transform","translateX(0px)",`translateX(${r})`);return o(n).addAnimation(s)},m=(()=>{const t=new Map,a=[],o=async(t,e=!1)=>{if(await d(),"start"===t||"end"===t){const n=a.filter((e=>e.side===t&&!e.disabled));if(n.length>=1)return n.length>1&&e&&r(`menuController queried for a menu on the "${t}" side, but ${n.length} menus were found. The first menu reference will be used. If this is not the behavior you want then pass the ID of the menu instead of its side.`,n.map((t=>t.el))),n[0].el;const s=a.filter((e=>e.side===t));if(s.length>=1)return s.length>1&&e&&r(`menuController queried for a menu on the "${t}" side, but ${s.length} menus were found. The first menu reference will be used. If this is not the behavior you want then pass the ID of the menu instead of its side.`,s.map((t=>t.el))),s[0].el}else if(null!=t)return w((e=>e.menuId===t));return w((t=>!t.disabled))||(a.length>0?a[0].el:void 0)},m=async()=>(await d(),f()),p=(e,n)=>{t.set(e,n)},f=()=>w((t=>t._isOpen)),l=()=>a.some((t=>t.isAnimating)),w=t=>{const e=a.find(t);if(void 0!==e)return e.el},d=()=>Promise.all(Array.from(document.querySelectorAll("ion-menu")).map((t=>new Promise((e=>s(t,e))))));return p("reveal",c),p("push",u),p("overlay",i),null==e||e.addEventListener("ionBackButton",(t=>{const e=f();e&&t.detail.register(n,(()=>e.close()))})),{registerAnimation:p,get:o,getMenus:async()=>(await d(),a.map((t=>t.el))),getOpen:m,isEnabled:async t=>{const e=await o(t);return!!e&&!e.disabled},swipeGesture:async(t,e)=>{const n=await o(e);return n&&(n.swipeGesture=t),n},isAnimating:async()=>(await d(),l()),isOpen:async t=>{if(null!=t){const e=await o(t);return void 0!==e&&e.isOpen()}return void 0!==await m()},enable:async(t,e)=>{const n=await o(e);return n&&(n.disabled=!t),n},toggle:async t=>{const e=await o(t,!0);return!!e&&e.toggle()},close:async t=>{const e=await(void 0!==t?o(t,!0):m());return void 0!==e&&e.close()},open:async t=>{const e=await o(t,!0);return!!e&&e.open()},_getOpenSync:f,_createAnimation:(e,n)=>{const r=t.get(e);if(!r)throw new Error("animation not registered");return r(n)},_register:t=>{a.indexOf(t)<0&&a.push(t)},_unregister:t=>{const e=a.indexOf(t);e>-1&&a.splice(e,1)},_setOpen:async(t,e,n,r)=>{if(l())return!1;if(e){const e=await m();e&&t.el!==e&&await e.setOpen(!1,!1)}return t._setOpen(e,n,r)}}})();export{m}