@plainsheet/core 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../src/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AAiBjC,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAYjE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,oBAAoB,GAC1B,eAAe,CAqXjB"}
1
+ {"version":3,"file":"bottom-sheet.d.ts","sourceRoot":"","sources":["../src/bottom-sheet.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,0BAA0B,CAAC;AAClC,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AAiBjC,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAYjE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,oBAAoB,GAC1B,eAAe,CA+XjB"}
@@ -1,2 +1,2 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{display:none}.pbs-backdrop.open{background-color:#454545b3}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
- "use strict";var Dt=Object.defineProperty;var kt=(t,n,e)=>n in t?Dt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>kt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function O(t){return typeof t=="string"}function Bt(t,n){return t.classList.contains(tt(n))}function K(t,n){t.classList.add(tt(n))}function et(t,n){t.classList.remove(tt(n))}function G(t,n,e){O(e)&&(O(n)&&et(t,n),K(t,e))}function tt(t){return O(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function Yt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const lt="open",dt="hidden";function nt(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{z(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}z(t,e),t.setAttribute("aria-modal",e?"true":"false")}function z(t,n){n?(K(t,lt),et(t,dt)):(K(t,dt),et(t,lt))}function bt(t){return t instanceof HTMLElement}function S(t){return typeof t=="number"&&!Number.isNaN(t)}function It(t){bt(t)&&t.focus()}function Nt(t){if(!bt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=S(e)?parseInt(e,10):-1,o=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),c=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return o||c||r>-1}var b=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(b||{}),q=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(q||{}),$=(t=>(t.Hidden="hidden",t))($||{});function I(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(o=>{K(r,o)}),O(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:Yt([b.Root,b.ContentWrapper])};function ft(t,n,e,r){switch(r){case"content-height":return n>=t?wt(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function Ct(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Et(t,n){return n<t?-(t-n):n-t}function J(t,n){return t>n?t-n:n-t}function Pt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function gt(t,n,e){const r=t==="above";return e.filter(i=>{const o=i*n.viewportHeight;return r?n.visibleHeight<o:n.visibleHeight>o})}function wt(t,n,e){return-(t-n)+e}function ht(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function Ht(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const i=r[1],o=r[2].split(",").map(c=>c.trim());e.push({type:i,values:o})}return e}function xt(t){const n=t.style.transform,e=Ht(n);return{transform:n,transformValues:e}}function vt(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const rt="translate";function Y(t){const n=t.style.transform,e=Ht(n),r=vt(e,rt);return yt(r??{type:rt,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:i}=xt(t),o=vt(i,rt);if(o){const c=yt(o);t.style.transform=`translate(${n??c.x??0}px,${e??c.y??0}px)`;return}if(r){t.style.transform=`${r}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function yt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:ht(n)??0,y:ht(e)??0}}function ot(t){return t!=null}function mt(t,{min:n,max:e}){return ot(e)&&t>=e?e:ot(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Bt(n,b.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Ft=(t,n,e,r)=>i=>{r.startY=t.getCoordinates(i).y,r.containerStartTranslate=Y(n),e.onDragStart()},Rt=(t,n,e,r,i)=>o=>{Ut(o,t,e,r,i,n,e.marginTop)};function Ut(t,n,e,r,i,o,c){if(!r.isDragging||!S(r.startY))return;const u=n.getCoordinates(t).y,a=Et(r.startY,u),p=window.innerHeight,g=o.clientHeight,l=g-(r.containerStartTranslate.y+a);if(l>=p)return;const C=Ct(r.startY,u);if(C.isUp&&!e.expandable&&l>=g)return;i.start(()=>{Z(o,{y:r.containerStartTranslate.y+a})},0);const v=p-c,s=g-r.containerStartTranslate.y;if(C.isUp){const w=v-s,A=v-l,L=mt(1-Q(A/w,2),{min:0,max:1});e.onDragMove(C,L)}else if(C.isDown){const w=mt(Q(1-l/s,2),{min:0,max:1});e.onDragMove(C,w)}}const Wt=(t,n,e,r,i,o,c)=>u=>{if(!r.isDragging||(r.isDragging=!1,!S(r.startY)))return;e.onDragEnd();const a=r.startY,p=t.getCoordinates(u).y,g=Y(n).y,l=Ct(a,p),C=window.innerHeight,v=n.clientHeight;if(l.isUp){const s=[...e.snapPoints].sort((L,E)=>L-E),w=v+-g;if(!e.expandable&&w>=v)return;for(const L of s){const E=L*window.innerHeight;if(w<=E){const x=J(w,E);c.translateContainer({startY:g,endY:g-x,animationFrame:i,bottomSheetContainer:n});return}}const A=wt(C,v,e.marginTop);c.translateContainer({startY:g,endY:A,animationFrame:i,bottomSheetContainer:n})}else if(l.isDown){const s=[...e.snapPoints].sort((w,A)=>A-w);for(const w of s){const A=w*window.innerHeight,L=v+-g;if(L>=A){const E=J(L,A);c.translateContainer({startY:g,endY:g+E,animationFrame:i,bottomSheetContainer:n});return}}o()}};var P=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(P||{});function it(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gt={eventPhase:P.All};class V{constructor(n){W(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Gt,onMove:r,onEnd:i}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("touchstart",o=>{if(e.eventPhase===P.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:i}){n&&this.currentTarget.addEventListener("mousedown",o=>{if(e.eventPhase===P.All){n(o);return}it(o.eventPhase)===e.eventPhase&&n(o)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),i&&this.currentTarget.addEventListener("mouseup",o=>{i(o)})}removeEventListeners({onStart:n,onMove:e,onEnd:r}){n&&this.currentTarget.removeEventListener("touchstart",n),r&&this.currentTarget.removeEventListener("touchend",r),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),r&&this.currentTarget.removeEventListener("mouseup",r)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Vt(t,n){const e=$t(t);Xt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(r);const o=jt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:o}}function $t(t){const n=I("dialog",R([b.Root,q.Dialog,t.rootClass]),b.Root);n.ariaLabel=t.ariaLabel;const e=I("section",R([b.Container,t.containerClass]),b.Container);t.containerBorderRadius&&(e.style.borderRadius=t.containerBorderRadius);const r=I("div",b.GapFiller,b.GapFiller),i=I("button",R([b.Handle,q.Button,t.shouldShowHandle?null:$.Hidden,t.handleClass]),b.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const o=I("span",R([b.HandleBar,t.shouldShowHandle?null:$.Hidden]),b.HandleBar),c=I("article",R([b.ContentWrapper,t.contentWrapperClass]),b.ContentWrapper),u=I("div",R([b.Backdrop,t.backdropClass,$.Hidden]),b.Backdrop);return t.backdropColor&&(u.style.backgroundColor=t.backdropColor),t.backDropTransition&&(u.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:u,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:o,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:r}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:o}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(i),n.appendChild(o)}function jt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:i,bottomSheetHandle:o,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:u}=t,{animationFrame:a}=e,p=new V(o),g=new V(u),l=new V(c),C=n.dragTriggers.reduce((T,D)=>{const k=r.querySelectorAll(D);if(!k.length)return T;const j=Array.from(k).map(F=>F instanceof HTMLElement?new V(F):null).filter(F=>!!F);return[...T,...j]},[]),v=new V(window),s=Ft(v,i,n,e.draggingState),w=Rt(v,i,n,e.draggingState,a),A=Wt(v,i,n,e.draggingState,a,e.onClose,e.bottomSheetState);function L(T){T.target instanceof Element&&!r.contains(T.target)&&e.onClose()}function E(T){_t(e.draggingState,T.target,t.bottomSheetContentWrapper)}function x(){n.draggable&&(p.addEventListeners({onStart:E}),C.forEach(T=>{T.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}})})),n.draggable&&n.backgroundDraggable&&(g.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}}),l.addEventListeners({onStart:E})),n.draggable&&v.addEventListeners({onStart:s,onMove:w,onEnd:A}),n.draggable&&window.document.addEventListener("keyup",T=>{T.key==="Escape"&&e.onClose()}),n.shouldCloseOnOutsideClick&&window.document.addEventListener("click",L),o.addEventListener("keyup",T=>{if(T.key==="ArrowUp"){e.moveUp();return}if(T.key==="ArrowDown"){e.moveDown();return}if(T.shiftKey&&T.key==="Tab"){const D=_(t.bottomSheetContentWrapper);It(D)}})}function _(T){let D=[...Array.from(T.childNodes).reverse()];for(;D.length;){const k=D.shift();if(Nt(k))return k;k&&(D=[...D,...Array.from(k.childNodes).reverse()])}return null}function X(){p.removeEventListeners({onStart:E}),g.removeEventListeners({onStart:E}),l.removeEventListeners({onStart:E}),C.forEach(T=>{T.removeEventListeners({onStart:E})}),v.removeEventListeners({onStart:s,onMove:w,onEnd:A}),window.removeEventListener("click",L)}return{attachEventListeners:x,clearEventListeners:X}}class Kt{constructor(){W(this,"animationId");W(this,"isInProgress");W(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const i=o=>{this.startedAt||(this.startedAt=o);const c=o-this.startedAt,a=e===0?1:Q(c/e,2),p=a>=1&&!r;n(a),p?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,S(this.animationId)&&cancelAnimationFrame(this.animationId)}}function zt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:i,onEnd:o,animationTimingFunction:c,animationDuration:u}=t,a=Et(n,e);i.stop();let p=!1;i.start(g=>{Z(r,{y:n+a*c(g)}),!p&&g>=1&&(o==null||o(),p=!0)},u)}const st=(t,n)=>e=>{zt({...e,animationTimingFunction:t,animationDuration:n})},M={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function qt(t){return!(!S(t)||t>1||t<0)}function Jt(t,n){const e={set(r,i,o,c){return n(i,o),Reflect.set(r,i,o,c)}};return new Proxy(t,e)}function Qt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ot(t){for(const n of Object.values(N))if(n===t)return!0;return!1}function ct(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&S(t.p1x)&&S(t.p1y)&&S(t.p2x)&&S(t.p2y))}function U(t,n,e,r){return function(a){return u(o(a))};function o(a){let p=0,g=1,l=a,C;if(a===0||a===1)return a;for(;p<g;){if(C=c(l),Math.abs(C-a)<.001)return l;a>C?p=l:g=l,l=(g+p)/2}return l}function c(a){return 3*t*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function u(a){return 3*n*a*Math.pow(1-a,2)+3*r*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const Zt=U(.25,.1,.25,1),tn=U(.42,0,1,1),At=U(.42,0,.58,1),pt=U(.4,.1,.6,1),nn=U(.45,1.5,.55,1);function en(t){switch(t){case N.EASE:return Zt;case N.EASE_IN:return tn;case N.EASE_OUT:return At;case N.EASE_IN_OUT:return pt;case N.SPRING:return nn;default:return pt}}function Tt(t){return typeof t=="boolean"}const Lt={ariaLabel:"Bottom sheet",content:"",defaultPosition:M.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180};function rn(t){const n={...Lt},e=Object.entries(t).reduce((i,o)=>{const[c,u]=o;return ot(u)&&(i[c]=u),i},{});return{...n,...e}}function at(t){if(ct(t)){const{p1x:n,p1y:e,p2x:r,p2y:i}=t;return U(n,e,r,i)}return Ot(t)?en(t):At}function on(t,n,e){function r(i,o){switch(i){case"content":O(o)&&(t.bottomSheetContentWrapper.innerHTML=o);break;case"width":O(o)&&(t.bottomSheetContainer.style.width=o);break;case"shouldShowHandle":Tt(o)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(o)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":O(o)&&(t.bottomSheetContainer.style.borderRadius=o);break;case"backdropColor":O(o)&&(t.bottomSheetBackdrop.style.backgroundColor=o);break;case"backDropTransition":O(o)&&(t.bottomSheetBackdrop.style.transition=o);break;case"rootClass":if(!O(o))return;G(t.bottomSheetRoot,e.rootClass,o);break;case"containerClass":if(!O(o))return;G(t.bottomSheetContainer,e.containerClass,o);break;case"handleClass":if(!O(o))return;G(t.bottomSheetHandle,e.handleClass,o);break;case"contentWrapperClass":if(!O(o))return;G(t.bottomSheetContentWrapper,e.contentWrapperClass,o);break;case"backdropClass":if(!O(o))return;G(t.bottomSheetBackdrop,e.backdropClass,o);break;case"draggingAnimationTimings":if(ct(o)){const c=at(o),u=st(c,e.draggingAnimationDuration);n.translateContainer=u}break;case"draggingAnimationDuration":if(S(o)){const c=at(e.draggingAnimationTimings),u=st(c,o);n.translateContainer=u}break}}return r}function sn(t){const n=rn(t),e=at(t.draggingAnimationTimings),i={isMounted:!1,translateContainer:st(e,n.draggingAnimationDuration)},o={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null};function c(){o.originalDocumentOverflowY&&o.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=o.originalDocumentOverflowY)}const u=new Kt,a={animationFrame:u,onClose:E,bottomSheetState:i,draggingState:o,snapTo:ut,moveUp:F,moveDown:St},{elements:p,eventHandlers:g}=Vt(n,a),l=Jt(n,on(p,i,n)),{bottomSheetBackdrop:C,bottomSheetRoot:v,bottomSheetContainer:s}=p,w=d=>{const f=d??window.document.body;f.appendChild(v),f.appendChild(C);const h=window.innerHeight;Z(s,{y:h}),g.attachEventListeners(),i.isMounted=!0},A=()=>{g.clearEventListeners(),Object.values(p).forEach(d=>{d.remove()}),c(),i.isMounted=!1},L=()=>{var y;if(x()||Qt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(y=t.beforeOpen)==null||y.call(t),_())return;l.shouldShowBackdrop&&nt(C,!0),nt([s],!0),Z(s,{y:s.clientHeight});const f=window.innerHeight,h=ft(f,s.clientHeight,l.marginTop,l.defaultPosition),m=Y(s).y;i.translateContainer({startY:m,endY:h,animationFrame:u,bottomSheetContainer:s,onEnd:t.afterOpen}),p.bottomSheetHandle.focus();const H=document.body.style.overflowY;o.originalDocumentOverflowY=H||"initial",document.body.style.overflowY="hidden"};function E(){var h;if(X())return;(h=t.beforeClose)==null||h.call(t);const d=Y(s).y,f=s.clientHeight;i.translateContainer({startY:d,endY:f,animationFrame:u,bottomSheetContainer:s,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),nt([C,s],!1)}}),c()}function x(){return i.isMounted}function _(){const d=Y(s).y,f=window.innerHeight,h=s.clientHeight>=f?f:s.clientHeight;return d<h}function X(){return!_()}function T(){const d=Y(s).y,f=s.clientHeight,h=window.innerHeight;if(d<=5&&d>=-5)return M.CONTENT_HEIGHT;const m=f-d;if(m===h/2)return M.MIDDLE;const H=h-l.marginTop,y=10;return m<=H+y&&m>=H-y?M.TOP:M.CLOSED}function D(){return s.clientHeight}function k(d){if(!_())return;const f=Y(s).y,m=s.clientHeight-f,H=window.innerHeight-d,y=Pt(m,H),B=J(m,H);i.translateContainer({startY:f,endY:f+(y.isUp?-B:B),animationFrame:u,bottomSheetContainer:s})}function j(d,{viewportHeight:f,visibleHeight:h}){let m=null;for(const H of d){const y=H*f,B=J(h,y);(m===null||B<m)&&(m=B)}return{minOffset:m}}function F(){const d=[...l.snapPoints].reverse(),f=Y(s).y,h=s.clientHeight,m=h-f;if(!l.expandable&&m>=h)return;const H=window.innerHeight,y=gt("above",{visibleHeight:m,viewportHeight:H},d),{minOffset:B}=j(y,{visibleHeight:m,viewportHeight:H});if(B===null&&m<H-l.marginTop){i.translateContainer({startY:f,endY:ft(H,h,l.marginTop,"top"),animationFrame:u,bottomSheetContainer:s});return}S(B)&&i.translateContainer({startY:f,endY:f-B,animationFrame:u,bottomSheetContainer:s})}function St(){const d=Y(s).y,h=s.clientHeight-d;if(h<1)return;const m=window.innerHeight,H=gt("below",{visibleHeight:h,viewportHeight:m},l.snapPoints),{minOffset:y}=j(H,{visibleHeight:h,viewportHeight:m});S(y)&&i.translateContainer({startY:d,endY:d+y,animationFrame:u,bottomSheetContainer:s})}function ut(d){const f=window.innerHeight;if(!qt(d))return;const h=Q(f*d,2);k(h)}return{props:l,elements:p,mount:w,unmount:A,open:L,close:E,getIsMounted:x,getIsOpen:_,getIsClosed:X,getPosition:T,getHeight:D,moveTo:k,snapTo:ut}}function an(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>M.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}exports.BOTTOM_SHEET_DEFAULT_PROPS=Lt;exports.BOTTOM_SHEET_POSITION=M;exports.BOTTOM_SHEET_SELECTORS=Mt;exports.COMMON_ANIMATION_KEYS=N;exports.ClassNames=b;exports.EventPhase=P;exports.ResetClassNames=q;exports.UtilClassNames=$;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=an;exports.eventPhaseToEnum=it;exports.isAnimationTimingPoints=ct;exports.isCommonAnimationTimingsKey=Ot;
2
+ "use strict";var St=Object.defineProperty;var kt=(t,n,e)=>n in t?St(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>kt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(t){return typeof t=="string"}function Bt(t,n){return t.classList.contains(tt(n))}function K(t,n){t.classList.add(tt(n))}function et(t,n){t.classList.remove(tt(n))}function G(t,n,e){y(e)&&(y(n)&&et(t,n),K(t,e))}function tt(t){return y(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function Yt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const ut="open",dt="hidden";function nt(t,n){const e=n;if(Array.isArray(t)){t.forEach(o=>{z(o,e),o.setAttribute("aria-modal",e?"true":"false")});return}z(t,e),t.setAttribute("aria-modal",e?"true":"false")}function z(t,n){n?(K(t,ut),et(t,dt)):(K(t,dt),et(t,ut))}function bt(t){return t instanceof HTMLElement}function S(t){return typeof t=="number"&&!Number.isNaN(t)}function It(t){bt(t)&&t.focus()}function Nt(t){if(!bt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),o=S(e)?parseInt(e,10):-1,r=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),c=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return r||c||o>-1}var b=(t=>(t.Backdrop="pbs-backdrop",t.Root="pbs-root",t.Container="pbs-container",t.GapFiller="pbs-gap-filler",t.Handle="pbs-handle",t.HandleBar="pbs-handle-bar",t.ContentWrapper="pbs-content-wrapper",t))(b||{}),q=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(q||{}),$=(t=>(t.Hidden="hidden",t))($||{});function I(t,n,e){const o=document.createElement(t);return n.split(" ").forEach(r=>{K(o,r)}),y(e)&&o.setAttribute("data-testid",e),o}const Mt={CONTENTS_WRAPPER:Yt([b.Root,b.ContentWrapper])};function ft(t,n,e,o){switch(o){case"content-height":return n>=t?vt(t,n,e):0;case"middle":return-(t/2-n);case"top":return-(t-n)+e;default:return 0}}function Ct(t,n){const e=n<t,o=n>t;return{isUp:e,isDown:o,stayedSame:n===t}}function Et(t,n){return n<t?-(t-n):n-t}function J(t,n){return t>n?t-n:n-t}function Pt(t,n){const e=t<n,o=t>n;return{isUp:e,isDown:o,stayedSame:t===n}}function gt(t,n,e){const o=t==="above";return e.filter(i=>{const r=i*n.viewportHeight;return o?n.visibleHeight<r:n.visibleHeight>r})}function vt(t,n,e){return-(t-n)+e}function ht(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function wt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let o;for(;(o=n.exec(t))!==null;){const i=o[1],r=o[2].split(",").map(c=>c.trim());e.push({type:i,values:r})}return e}function xt(t){const n=t.style.transform,e=wt(n);return{transform:n,transformValues:e}}function Ht(t,n){const e=t.find(o=>o.type.startsWith(n));return e||null}const rt="translate";function Y(t){const n=t.style.transform,e=wt(n),o=Ht(e,rt);return yt(o??{type:rt,values:[]})}function Z(t,{x:n,y:e}){const{transform:o,transformValues:i}=xt(t),r=Ht(i,rt);if(r){const c=yt(r);t.style.transform=`translate(${n??c.x??0}px,${e??c.y??0}px)`;return}if(o){t.style.transform=`${o}, translate(${n??0}px,${e??0}px)`;return}t.style.transform=`translate(${n??0}px,${e??0}px)`}function yt(t){if(t.type!=="translate")throw new Error(`Could not get coordinates from ${t.type}, since is not translate.`);const n=t.values[0],e=t.values[1];return{x:ht(n)??0,y:ht(e)??0}}function ot(t){return t!=null}function mt(t,{min:n,max:e}){return ot(e)&&t>=e?e:ot(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Bt(n,b.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Ft=(t,n,e,o)=>i=>{o.startY=t.getCoordinates(i).y,o.containerStartTranslate=Y(n),e.onDragStart()},Rt=(t,n,e,o,i)=>r=>{Ut(r,t,e,o,i,n,e.marginTop)};function Ut(t,n,e,o,i,r,c){if(!o.isDragging||!S(o.startY))return;const l=n.getCoordinates(t).y,a=Et(o.startY,l),p=window.innerHeight,g=r.clientHeight,u=g-(o.containerStartTranslate.y+a);if(u>=p)return;const C=Ct(o.startY,l);if(C.isUp&&!e.expandable&&u>=g)return;i.start(()=>{Z(r,{y:o.containerStartTranslate.y+a})},0);const H=p-c,s=g-o.containerStartTranslate.y;if(C.isUp){const v=H-s,O=H-u,A=mt(1-Q(O/v,2),{min:0,max:1});e.onDragMove(C,A)}else if(C.isDown){const v=mt(Q(1-u/s,2),{min:0,max:1});e.onDragMove(C,v)}}const Wt=(t,n,e,o,i,r,c)=>l=>{if(!o.isDragging||(o.isDragging=!1,!S(o.startY)))return;e.onDragEnd();const a=o.startY,p=t.getCoordinates(l).y,g=Y(n).y,u=Ct(a,p),C=window.innerHeight,H=n.clientHeight;if(u.isUp){const s=[...e.snapPoints].sort((A,E)=>A-E),v=H+-g;if(!e.expandable&&v>=H)return;for(const A of s){const E=A*window.innerHeight;if(v<=E){const x=J(v,E);c.translateContainer({startY:g,endY:g-x,animationFrame:i,bottomSheetContainer:n});return}}const O=vt(C,H,e.marginTop);c.translateContainer({startY:g,endY:O,animationFrame:i,bottomSheetContainer:n})}else if(u.isDown){const s=[...e.snapPoints].sort((v,O)=>O-v);for(const v of s){const O=v*window.innerHeight,A=H+-g;if(A>=O){const E=J(A,O);c.translateContainer({startY:g,endY:g+E,animationFrame:i,bottomSheetContainer:n});return}}r()}};var P=(t=>(t[t.All=-1]="All",t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Target=2]="Target",t[t.Bubble=3]="Bubble",t))(P||{});function it(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const Gt={eventPhase:P.All};class V{constructor(n){W(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Gt,onMove:o,onEnd:i}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:o,onEnd:i}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:o,onEnd:i})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:o,onEnd:i}){n&&this.currentTarget.addEventListener("touchstart",r=>{if(e.eventPhase===P.All){n(r);return}it(r.eventPhase)===e.eventPhase&&n(r)},{passive:!0}),o&&this.currentTarget.addEventListener("touchmove",o),i&&this.currentTarget.addEventListener("touchend",i)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:o,onEnd:i}){n&&this.currentTarget.addEventListener("mousedown",r=>{if(e.eventPhase===P.All){n(r);return}it(r.eventPhase)===e.eventPhase&&n(r)},{passive:!0}),o&&this.currentTarget.addEventListener("mousemove",o),i&&this.currentTarget.addEventListener("mouseup",r=>{i(r)})}removeEventListeners({onStart:n,onMove:e,onEnd:o}){n&&this.currentTarget.removeEventListener("touchstart",n),o&&this.currentTarget.removeEventListener("touchend",o),e&&this.currentTarget.removeEventListener("touchmove",e),n&&this.currentTarget.removeEventListener("mousedown",n),e&&this.currentTarget.removeEventListener("mousemove",e),o&&this.currentTarget.removeEventListener("mouseup",o)}getCoordinates(n){if(n.type==="touchstart"||n.type==="mousedown"){if("touches"in n)return{x:n.touches[0].clientX,y:n.touches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}if(n.type==="touchend"||n.type==="mouseup"||n.type==="mousemove"||n.type==="touchmove"){if("touches"in n)return{x:n.changedTouches[0].clientX,y:n.changedTouches[0].clientY};if(n instanceof MouseEvent)return{x:n.clientX,y:n.clientY}}return{x:0,y:0}}}function Vt(t,n){const e=$t(t);Xt(e),e.bottomSheetContainer.style.width=t.width;const o=document.createElement("div");o.innerHTML=t.content??"";const i=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${i}px`,e.bottomSheetContentWrapper.appendChild(o);const r=jt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:r}}function $t(t){const n=I("dialog",R([b.Root,q.Dialog,t.rootClass]),b.Root);n.ariaLabel=t.ariaLabel;const e=I("section",R([b.Container,t.containerClass]),b.Container);t.containerBorderRadius&&(e.style.borderRadius=t.containerBorderRadius);const o=I("div",b.GapFiller,b.GapFiller),i=I("button",R([b.Handle,q.Button,t.shouldShowHandle?null:$.Hidden,t.handleClass]),b.Handle);i.setAttribute("type","button"),i.ariaLabel="bottom sheet close button";const r=I("span",R([b.HandleBar,t.shouldShowHandle?null:$.Hidden]),b.HandleBar),c=I("article",R([b.ContentWrapper,t.contentWrapperClass]),b.ContentWrapper),l=I("div",R([b.Backdrop,t.backdropClass,$.Hidden]),b.Backdrop);return t.backdropColor&&(l.style.backgroundColor=t.backdropColor),t.backDropTransition&&(l.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:l,bottomSheetContainer:e,bottomSheetHandle:i,bottomSheetHandleBar:r,bottomSheetContentWrapper:c,bottomSheetContainerGapFiller:o}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:o,bottomSheetContentWrapper:i,bottomSheetContainerGapFiller:r}){t.appendChild(n),e.appendChild(o),n.appendChild(e),n.appendChild(i),n.appendChild(r)}function jt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:o,bottomSheetContainer:i,bottomSheetHandle:r,bottomSheetContainerGapFiller:c,bottomSheetContentWrapper:l}=t,{animationFrame:a}=e,p=new V(r),g=new V(l),u=new V(c),C=n.dragTriggers.reduce((T,k)=>{const B=o.querySelectorAll(k);if(!B.length)return T;const j=Array.from(B).map(F=>F instanceof HTMLElement?new V(F):null).filter(F=>!!F);return[...T,...j]},[]),H=new V(window),s=Ft(H,i,n,e.draggingState),v=Rt(H,i,n,e.draggingState,a),O=Wt(H,i,n,e.draggingState,a,e.onClose,e.bottomSheetState);function A(T){T.target instanceof Element&&!o.contains(T.target)&&e.onClose()}function E(T){_t(e.draggingState,T.target,t.bottomSheetContentWrapper)}function x(){n.draggable&&(p.addEventListeners({onStart:E}),C.forEach(T=>{T.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}})})),n.draggable&&n.backgroundDraggable&&(g.addEventListeners({onStart:E,onStartOptions:{eventPhase:P.Target}}),u.addEventListeners({onStart:E})),n.draggable&&H.addEventListeners({onStart:s,onMove:v,onEnd:O}),n.draggable&&window.document.addEventListener("keyup",T=>{T.key==="Escape"&&e.onClose()}),n.shouldCloseOnOutsideClick&&window.document.addEventListener("click",A),r.addEventListener("keyup",T=>{if(T.key==="ArrowUp"){e.moveUp();return}if(T.key==="ArrowDown"){e.moveDown();return}if(T.shiftKey&&T.key==="Tab"){const k=_(t.bottomSheetContentWrapper);It(k)}})}function _(T){let k=[...Array.from(T.childNodes).reverse()];for(;k.length;){const B=k.shift();if(Nt(B))return B;B&&(k=[...k,...Array.from(B.childNodes).reverse()])}return null}function X(){p.removeEventListeners({onStart:E}),g.removeEventListeners({onStart:E}),u.removeEventListeners({onStart:E}),C.forEach(T=>{T.removeEventListeners({onStart:E})}),H.removeEventListeners({onStart:s,onMove:v,onEnd:O}),window.removeEventListener("click",A)}return{attachEventListeners:x,clearEventListeners:X}}class Kt{constructor(){W(this,"animationId");W(this,"isInProgress");W(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,o=!1){this.isInProgress=!0;const i=r=>{this.startedAt||(this.startedAt=r);const c=r-this.startedAt,a=e===0?1:Q(c/e,2),p=a>=1&&!o;n(a),p?this.stop():this.animationId=requestAnimationFrame(i)};this.animationId=requestAnimationFrame(i)}stop(){this.isInProgress=!1,this.startedAt=null,S(this.animationId)&&cancelAnimationFrame(this.animationId)}}function zt(t){const{startY:n,endY:e,bottomSheetContainer:o,animationFrame:i,onEnd:r,animationTimingFunction:c,animationDuration:l}=t,a=Et(n,e);i.stop();let p=!1;i.start(g=>{Z(o,{y:n+a*c(g)}),!p&&g>=1&&(r==null||r(),p=!0)},l)}const st=(t,n)=>e=>{zt({...e,animationTimingFunction:t,animationDuration:n})},M={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function qt(t){return!(!S(t)||t>1||t<0)}function Jt(t,n){const e={set(o,i,r,c){return n(i,r),Reflect.set(o,i,r,c)}};return new Proxy(t,e)}function Qt(...t){console.error(t)}const N={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Ot(t){for(const n of Object.values(N))if(n===t)return!0;return!1}function ct(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&S(t.p1x)&&S(t.p1y)&&S(t.p2x)&&S(t.p2y))}function U(t,n,e,o){return function(a){return l(r(a))};function r(a){let p=0,g=1,u=a,C;if(a===0||a===1)return a;for(;p<g;){if(C=c(u),Math.abs(C-a)<.001)return u;a>C?p=u:g=u,u=(g+p)/2}return u}function c(a){return 3*t*a*Math.pow(1-a,2)+3*e*Math.pow(a,2)*(1-a)+Math.pow(a,3)}function l(a){return 3*n*a*Math.pow(1-a,2)+3*o*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const pt=U(.25,.1,.25,1),Zt=U(.42,0,1,1),At=U(.42,0,.58,1),tn=U(.4,.1,.6,1),nn=U(.45,1.5,.55,1);function en(t){switch(t){case N.EASE:return pt;case N.EASE_IN:return Zt;case N.EASE_OUT:return At;case N.EASE_IN_OUT:return tn;case N.SPRING:return nn;default:return pt}}function Tt(t){return typeof t=="boolean"}const Lt={ariaLabel:"Bottom sheet",content:"",defaultPosition:M.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,draggable:!0,backgroundDraggable:!0,shouldCloseOnOutsideClick:!0,shouldShowBackdrop:!0,shouldShowHandle:!0,backDropTransition:null,backdropColor:null,containerBorderRadius:null,rootClass:null,containerClass:null,handleClass:null,contentWrapperClass:null,backdropClass:null,draggingAnimationTimings:"ease-in-out",draggingAnimationDuration:180};function rn(t){const n={...Lt},e=Object.entries(t).reduce((i,r)=>{const[c,l]=r;return ot(l)&&(i[c]=l),i},{});return{...n,...e}}function at(t){if(ct(t)){const{p1x:n,p1y:e,p2x:o,p2y:i}=t;return U(n,e,o,i)}return Ot(t)?en(t):At}function on(t,n,e){function o(i,r){switch(i){case"content":y(r)&&(t.bottomSheetContentWrapper.innerHTML=r);break;case"width":y(r)&&(t.bottomSheetContainer.style.width=r);break;case"shouldShowHandle":Tt(r)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(r)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":y(r)&&(t.bottomSheetContainer.style.borderRadius=r);break;case"backdropColor":y(r)&&(t.bottomSheetBackdrop.style.backgroundColor=r);break;case"backDropTransition":y(r)&&(t.bottomSheetBackdrop.style.transition=r);break;case"rootClass":if(!y(r))return;G(t.bottomSheetRoot,e.rootClass,r);break;case"containerClass":if(!y(r))return;G(t.bottomSheetContainer,e.containerClass,r);break;case"handleClass":if(!y(r))return;G(t.bottomSheetHandle,e.handleClass,r);break;case"contentWrapperClass":if(!y(r))return;G(t.bottomSheetContentWrapper,e.contentWrapperClass,r);break;case"backdropClass":if(!y(r))return;G(t.bottomSheetBackdrop,e.backdropClass,r);break;case"draggingAnimationTimings":if(ct(r)){const c=at(r),l=st(c,e.draggingAnimationDuration);n.translateContainer=l}break;case"draggingAnimationDuration":if(S(r)){const c=at(e.draggingAnimationTimings),l=st(c,r);n.translateContainer=l}break}}return o}function sn(t){const n=rn(t),e=at(t.draggingAnimationTimings),i={isMounted:!1,translateContainer:st(e,n.draggingAnimationDuration)},r={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function c(){r.originalDocumentOverflowY&&r.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=r.originalDocumentOverflowY),r.originalDocumentOverscrollBehavior&&(document.body.style.position=r.originalDocumentOverscrollBehavior)}const l=new Kt,a={animationFrame:l,onClose:E,bottomSheetState:i,draggingState:r,snapTo:lt,moveUp:F,moveDown:Dt},{elements:p,eventHandlers:g}=Vt(n,a),u=Jt(n,on(p,i,n)),{bottomSheetBackdrop:C,bottomSheetRoot:H,bottomSheetContainer:s}=p,v=d=>{const f=d??window.document.body;f.appendChild(H),f.appendChild(C);const h=window.innerHeight;Z(s,{y:h}),g.attachEventListeners(),i.isMounted=!0},O=()=>{g.clearEventListeners(),Object.values(p).forEach(d=>{d.remove()}),c(),i.isMounted=!1},A=()=>{var D;if(x()||Qt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(D=t.beforeOpen)==null||D.call(t),_())return;u.shouldShowBackdrop&&nt(C,!0),nt([s],!0),Z(s,{y:s.clientHeight});const f=window.innerHeight,h=ft(f,s.clientHeight,u.marginTop,u.defaultPosition),m=Y(s).y;i.translateContainer({startY:m,endY:h,animationFrame:l,bottomSheetContainer:s,onEnd:t.afterOpen}),p.bottomSheetHandle.focus();const w=document.body.style.overflowY;r.originalDocumentOverflowY=w||"initial";const L=document.body.style.overscrollBehavior;r.originalDocumentOverscrollBehavior=L||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain"};function E(){var h;if(X())return;(h=t.beforeClose)==null||h.call(t);const d=Y(s).y,f=s.clientHeight;i.translateContainer({startY:d,endY:f,animationFrame:l,bottomSheetContainer:s,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),nt([C,s],!1)}}),c()}function x(){return i.isMounted}function _(){const d=Y(s).y,f=window.innerHeight,h=s.clientHeight>=f?f:s.clientHeight;return d<h}function X(){return!_()}function T(){const d=Y(s).y,f=s.clientHeight,h=window.innerHeight;if(d<=5&&d>=-5)return M.CONTENT_HEIGHT;const m=f-d;if(m===h/2)return M.MIDDLE;const w=h-u.marginTop,L=10;return m<=w+L&&m>=w-L?M.TOP:M.CLOSED}function k(){return s.clientHeight}function B(d){if(!_())return;const f=Y(s).y,m=s.clientHeight-f,w=window.innerHeight-d,L=Pt(m,w),D=J(m,w);i.translateContainer({startY:f,endY:f+(L.isUp?-D:D),animationFrame:l,bottomSheetContainer:s})}function j(d,{viewportHeight:f,visibleHeight:h}){let m=null;for(const w of d){const L=w*f,D=J(h,L);(m===null||D<m)&&(m=D)}return{minOffset:m}}function F(){const d=[...u.snapPoints].reverse(),f=Y(s).y,h=s.clientHeight,m=h-f;if(!u.expandable&&m>=h)return;const w=window.innerHeight,L=gt("above",{visibleHeight:m,viewportHeight:w},d),{minOffset:D}=j(L,{visibleHeight:m,viewportHeight:w});if(D===null&&m<w-u.marginTop){i.translateContainer({startY:f,endY:ft(w,h,u.marginTop,"top"),animationFrame:l,bottomSheetContainer:s});return}S(D)&&i.translateContainer({startY:f,endY:f-D,animationFrame:l,bottomSheetContainer:s})}function Dt(){const d=Y(s).y,h=s.clientHeight-d;if(h<1)return;const m=window.innerHeight,w=gt("below",{visibleHeight:h,viewportHeight:m},u.snapPoints),{minOffset:L}=j(w,{visibleHeight:h,viewportHeight:m});S(L)&&i.translateContainer({startY:d,endY:d+L,animationFrame:l,bottomSheetContainer:s})}function lt(d){const f=window.innerHeight;if(!qt(d))return;const h=Q(f*d,2);B(h)}return{props:u,elements:p,mount:v,unmount:O,open:A,close:E,getIsMounted:x,getIsOpen:_,getIsClosed:X,getPosition:T,getHeight:k,moveTo:B,snapTo:lt}}function an(){return{elements:{bottomSheetRoot:void 0,bottomSheetBackdrop:void 0,bottomSheetContainer:void 0,bottomSheetHandle:void 0,bottomSheetHandleBar:void 0,bottomSheetContentWrapper:void 0,bottomSheetContainerGapFiller:void 0},mount:()=>{},unmount:()=>{},open:()=>{},close:()=>{},getIsMounted:()=>!1,getHeight:()=>0,getIsOpen:()=>!1,getIsClosed:()=>!0,getPosition:()=>M.CLOSED,moveTo:()=>{},snapTo:()=>{},props:{content:""}}}exports.BOTTOM_SHEET_DEFAULT_PROPS=Lt;exports.BOTTOM_SHEET_POSITION=M;exports.BOTTOM_SHEET_SELECTORS=Mt;exports.COMMON_ANIMATION_KEYS=N;exports.ClassNames=b;exports.EventPhase=P;exports.ResetClassNames=q;exports.UtilClassNames=$;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=an;exports.eventPhaseToEnum=it;exports.isAnimationTimingPoints=ct;exports.isCommonAnimationTimingsKey=Ot;