text: import{r as t,e as i,h as s,H as e,g as h}from"./p-8dfd188c.js";import{k as n,l as o,h as a}from"./p-5ea482c8.js";import"./p-030c6588.js";import{g as r}from"./p-bac8255f.js";import{G as d}from"./p-0d9cab2d.js";import{createGesture as l}from"./p-4b074146.js";import{m as c}from"./p-5bd037f7.js";const m=class{constructor(s){t(this,s),this.bkkrWillOpen=i(this,"bkkrWillOpen",7),this.bkkrWillClose=i(this,"bkkrWillClose",7),this.bkkrDidOpen=i(this,"bkkrDidOpen",7),this.bkkrDidClose=i(this,"bkkrDidClose",7),this.bkkrMenuChange=i(this,"bkkrMenuChange",7),this.lastOnEnd=0,this.blocker=d.createBlocker({disableScroll:!0}),this.isAnimating=!1,this._isOpen=!1,this.isPaneVisible=!1,this.isEndSide=!1,this.disabled=!1,this.side="start",this.swipeGesture=!0,this.maxEdgeStart=50}typeChanged(t,i){const s=this.contentEl;s&&(void 0!==i&&s.classList.remove(`menu-content-${i}`),s.classList.add(`menu-content-${t}`),s.removeAttribute("style")),this.menuInnerEl&&this.menuInnerEl.removeAttribute("style"),this.animation=void 0}disabledChanged(){this.updateState(),this.bkkrMenuChange.emit({disabled:this.disabled,open:this._isOpen})}sideChanged(){this.isEndSide=n(this.side)}swipeGestureChanged(){this.updateState()}async connectedCallback(){void 0===this.type&&(this.type="overlay");const t=this.el.parentNode,i=void 0!==this.contentId?document.getElementById(this.contentId):t&&t.querySelector&&t.querySelector("[main]");i&&i.tagName?(this.contentEl=i,i.classList.add("menu-content"),this.typeChanged(this.type,void 0),this.sideChanged(),c._register(this),this.gesture=l({el:document,gestureName:"menu-swipe",gesturePriority:30,threshold:10,blurOnStart:!0,canStart:async t=>this.canStart(t),onWillStart:()=>this.onWillStart(),onStart:()=>this.onStart(),onMove:t=>this.onMove(t),onEnd:t=>this.onEnd(t)}),this.updateState()):console.error('Menu: must have a "content" element to listen for drag events on.')}async componentDidLoad(){this.bkkrMenuChange.emit({disabled:this.disabled,open:this._isOpen}),this.updateState()}disconnectedCallback(){this.blocker.destroy(),c._unregister(this),this.animation&&this.animation.destroy(),this.gesture&&(this.gesture.destroy(),this.gesture=void 0),this.animation=void 0,this.contentEl=this.backdropEl=this.menuInnerEl=void 0}onSplitPaneChanged(t){this.isPaneVisible=t.detail.isPane(this.el),this.updateState()}onBackdropClick(t){this._isOpen&&this.lastOnEnd<t.timeStamp-100&&t.composedPath&&!t.composedPath().includes(this.menuInnerEl)&&(t.preventDefault(),t.stopPropagation(),this.close())}isOpen(){return Promise.resolve(this._isOpen)}isActive(){return Promise.resolve(this._isActive())}open(t=!0){return this.setOpen(!0,t)}close(t=!0){return this.setOpen(!1,t)}toggle(t=!0){return this.setOpen(!this._isOpen,t)}setOpen(t,i=!0){return c._setOpen(this,t,i)}async _setOpen(t,i=!0){return!(!this._isActive()||this.isAnimating||t===this._isOpen||(this.beforeAnimation(t),await this.loadAnimation(),await this.startAnimation(t,i),this.afterAnimation(t),0))}async loadAnimation(){const t=this.menuInnerEl.offsetWidth;t===this.width&&void 0!==this.animation||(this.width=t,this.animation&&(this.animation.destroy(),this.animation=void 0),this.animation=await c._createAnimation(this.type,this),this.animation.fill("both"))}async startAnimation(t,i){const s=!t,e=this.animation.direction(s?"reverse":"normal").easing(s?"cubic-bezier(1, 0, 0.68, 0.28)":"cubic-bezier(0.32,0.72,0,1)").onFinish((()=>{"reverse"===e.getDirection()&&e.direction("normal")}));i?await e.play():e.play({sync:!0})}_isActive(){return!this.disabled&&!this.isPaneVisible}canSwipe(){return this.swipeGesture&&!this.isAnimating&&this._isActive()}canStart(t){return!(document.querySelector("bkkr-modal.show-modal")||!this.canSwipe())&&(!!this._isOpen||!c._getOpenSync()&&b(window,t.currentX,this.isEndSide,this.maxEdgeStart))}onWillStart(){return this.beforeAnimation(!this._isOpen),this.loadAnimation()}onStart(){this.isAnimating&&this.animation?this.animation.progressStart(!0,this._isOpen?1:0):o(!1,"isAnimating has to be true")}onMove(t){if(!this.isAnimating||!this.animation)return void o(!1,"isAnimating has to be true");const i=p(t.deltaX,this._isOpen,this.isEndSide)/this.width;this.animation.progressStep(this._isOpen?1-i:i)}onEnd(t){if(!this.isAnimating||!this.animation)return void o(!1,"isAnimating has to be true");const i=this._isOpen,s=this.isEndSide,e=p(t.deltaX,i,s),h=this.width,n=e/h,d=t.velocityX,l=h/2,c=d>=0&&(d>.2||t.deltaX>l),m=d<=0&&(d<-.2||t.deltaX<-l),b=i?s?c:m:s?m:c;let u=!i&&b;i&&!b&&(u=!0),this.lastOnEnd=t.currentTime;let k=b?.001:-.001;k+=r([0,0],[.4,0],[.6,1],[1,1],a(0,n<0?.01:n,.9999))[0]||0;const w=this._isOpen?!b:b;this.animation.easing("cubic-bezier(0.4, 0.0, 0.6, 1)").onFinish((()=>this.afterAnimation(u)),{oneTimeCallback:!0}).progressEnd(w?1:0,this._isOpen?1-k:k,300)}beforeAnimation(t){o(!this.isAnimating,"_before() should not be called while animating"),this.el.classList.add(u),this.backdropEl&&this.backdropEl.classList.add(k),this.blocker.block(),this.isAnimating=!0,t?this.bkkrWillOpen.emit():this.bkkrWillClose.emit()}afterAnimation(t){o(this.isAnimating,"_before() should be called while animating"),this._isOpen=t,this.isAnimating=!1,this._isOpen||this.blocker.unblock(),t?(this.contentEl&&this.contentEl.classList.add(w),this.bkkrDidOpen.emit()):(this.el.classList.remove(u),this.contentEl&&this.contentEl.classList.remove(w),this.backdropEl&&this.backdropEl.classList.remove(k),this.animation&&this.animation.stop(),this.bkkrDidClose.emit())}updateState(){const t=this._isActive();this.gesture&&this.gesture.enable(t&&this.swipeGesture),!t&&this._isOpen&&this.forceClosing(),this.disabled||c._setActiveMenu(this),o(!this.isAnimating,"can not be animating")}forceClosing(){o(this._isOpen,"menu cannot be closed"),this.isAnimating=!0,this.animation.direction("reverse").play({sync:!0}),this.afterAnimation(!1)}render(){const{isEndSide:t,type:i,disabled:h,isPaneVisible:n}=this;return s(e,{role:"navigation",class:{[`menu-type-${i}`]:!0,"menu-enabled":!h,"menu-side-end":t,"menu-side-start":!t,"menu-pane-visible":n}},s("div",{class:"menu-inner",part:"container",ref:t=>this.menuInnerEl=t},s("slot",null)),s("bkkr-backdrop",{ref:t=>this.backdropEl=t,class:"menu-backdrop",tappable:!1,stopPropagation:!1,part:"backdrop"}))}get el(){return h(this)}},p=(t,i,s)=>Math.max(0,i!==s?-t:t),b=(t,i,s,e)=>s?i>=t.innerWidth-e:i<=e,u="show-menu",k="show-backdrop",w="menu-content-open";m.style=":host{--width:264px;--min-width:auto;--max-width:auto;--height:100%;--background:var(--bkkr-background-color, #fff);--box-shadow:0 15px 25px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.1), 0 6px 20px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.12), 0 13.2px 40px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.08);--backdrop-opacity:var(--bkkr-backdrop-opacity, .3);top:0;right:0;bottom:0;left:0;display:none;position:absolute;contain:size style}:host(.show-menu){display:block}.menu-inner{top:0;right:auto;bottom:0;left:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:justify;justify-content:space-between;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);-webkit-transform:translate3d(-9999px, 0, 0);transform:translate3d(-9999px, 0, 0);background:var(--background);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow);contain:size style;z-index:1000}:host(.menu-side-start) .menu-inner{--safe-area-right:0px;right:auto;left:0}:host(.menu-side-end) .menu-inner{--safe-area-left:0px;right:0;left:auto}bkkr-backdrop{display:none;z-index:-1}:host(.menu-type-reveal){z-index:0}:host(.menu-type-reveal.show-menu) .menu-inner{-webkit-transform:translate3d(0, 0, 0);transform:translate3d(0, 0, 0)}:host(.menu-type-overlay){z-index:100}:host(.menu-type-overlay) .show-backdrop{display:block;cursor:pointer}:host(.menu-pane-visible){width:var(--width);min-width:var(--min-width);max-width:var(--max-width)}:host(.menu-pane-visible) .menu-inner{top:0;bottom:0;width:100%;-webkit-transform:none !important;transform:none !important;-webkit-box-shadow:none !important;box-shadow:none !important}:host(.menu-pane-visible) ion-backdrop{display:hidden !important;}";export{m as bkkr_menu}