@plainsheet/core 0.7.5 → 0.7.8

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.
package/README.md CHANGED
@@ -18,9 +18,7 @@
18
18
 
19
19
  The **minimalistic**, **configurable** bottom sheet for any web project.
20
20
 
21
- ### [Check out our website](https://www.plainsheet.org//), for a quick start guide, APIs, examples, and more!
22
-
23
- ## Why?
21
+ ### [Check out our website](https://www.plainsheet.org//), for a quick start guide, API, examples, and more!
24
22
 
25
23
  ### 🧩 Framework-agnostic
26
24
 
@@ -1 +1 @@
1
- {"version":3,"file":"dragging-handler.d.ts","sourceRoot":"","sources":["../../src/event-handlers/dragging-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AASjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7E,eAAO,MAAM,sBAAsB,kBAClB,aAAa,gBACd,WAAW,GAAG,IAAI,kBAChB,WAAW,KAC1B,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,uBAEJ,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,aAEtB,QAAQ,SAKf,CAAC;AAEJ,eAAO,MAAM,cAAc,uBAEH,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,aAExB,QAAQ,SAUf,CAAC;AA+EJ,eAAO,MAAM,aAAa,kBAEP,gBAAgB,wBACT,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,WACrB,MAAM,IAAI,oBACD,gBAAgB,aAE5B,QAAQ,SAqGf,CAAC"}
1
+ {"version":3,"file":"dragging-handler.d.ts","sourceRoot":"","sources":["../../src/event-handlers/dragging-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AASjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,OAAO,KAAK,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAI7E,eAAO,MAAM,sBAAsB,kBAClB,aAAa,gBACd,WAAW,GAAG,IAAI,kBAChB,WAAW,KAC1B,IAYF,CAAC;AAEF,eAAO,MAAM,eAAe,uBAEJ,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,aAEtB,QAAQ,SAKf,CAAC;AAEJ,eAAO,MAAM,cAAc,uBAEH,gBAAgB,wBACd,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,aAExB,QAAQ,SAUf,CAAC;AAyFJ,eAAO,MAAM,aAAa,kBAEP,gBAAgB,wBACT,WAAW,oBACf,QAAQ,CAAC,oBAAoB,CAAC,iBACjC,aAAa,kBACZ,cAAc,WACrB,MAAM,IAAI,oBACD,gBAAgB,aAE5B,QAAQ,SAsHf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet-defaults.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-defaults.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGjF,MAAM,MAAM,0BAA0B,GAAG,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,0BAA0B,EAAE,wBA+BxC,CAAC"}
1
+ {"version":3,"file":"bottom-sheet-defaults.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-defaults.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAGjF,MAAM,MAAM,0BAA0B,GAAG,MAAM,wBAAwB,CAAC;AAExE,eAAO,MAAM,0BAA0B,EAAE,wBAqCxC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAejE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,uCAAuC;IAC/C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,aAAa,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACrC,OAAO,EAAE,kBAAkB,GAC1B,uCAAuC,CAsBzC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,WAAW,CAAC;IAC7B,mBAAmB,EAAE,WAAW,CAAC;IACjC,oBAAoB,EAAE,WAAW,CAAC;IAClC,iBAAiB,EAAE,WAAW,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,yBAAyB,EAAE,WAAW,CAAC;IACvC,6BAA6B,EAAE,WAAW,CAAC;CAC5C;AA4GD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,CACpB,YAAY,CAAC,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KACtD,IAAI,CAAC;IACV,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,2BAA2B,EAAE,MAAM,IAAI,CAAC;IACxC,yBAAyB,EAAE,MAAM,IAAI,CAAC;CACvC"}
1
+ {"version":3,"file":"bottom-sheet-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAejE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAOzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,uCAAuC;IAC/C,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,aAAa,EAAE,0BAA0B,CAAC;CAC3C;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACrC,OAAO,EAAE,kBAAkB,GAC1B,uCAAuC,CA2CzC;AAED,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,WAAW,CAAC;IAC7B,mBAAmB,EAAE,WAAW,CAAC;IACjC,oBAAoB,EAAE,WAAW,CAAC;IAClC,iBAAiB,EAAE,WAAW,CAAC;IAC/B,oBAAoB,EAAE,WAAW,CAAC;IAClC,yBAAyB,EAAE,WAAW,CAAC;IACvC,6BAA6B,EAAE,WAAW,CAAC;CAC5C;AA4GD,MAAM,WAAW,sBAAsB;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,gBAAgB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACjD,OAAO,EAAE,kBAAkB,CAAC;CAC7B;AAED,MAAM,WAAW,0BAA0B;IACzC,oBAAoB,EAAE,CACpB,YAAY,CAAC,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KACtD,IAAI,CAAC;IACV,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,2BAA2B,EAAE,MAAM,IAAI,CAAC;IACxC,yBAAyB,EAAE,MAAM,IAAI,CAAC;CACvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet-props-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-props-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAezD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAGpC,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,GAC1B,wBAAwB,CAuB1B;AAED,wBAAgB,6BAA6B,CAC3C,wBAAwB,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,GACzE,uBAAuB,CAWzB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,aAAa,EAAE,0BAA0B,GACxC,kBAAkB,CAgIpB"}
1
+ {"version":3,"file":"bottom-sheet-props-initializer.d.ts","sourceRoot":"","sources":["../../src/initializer/bottom-sheet-props-initializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAezD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,EACV,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,4BAA4B,CAAC;AAGpC,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,oBAAoB,GAC1B,wBAAwB,CAuB1B;AAED,wBAAgB,6BAA6B,CAC3C,wBAAwB,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,GACzE,uBAAuB,CAWzB;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,gBAAgB,EAAE,gBAAgB,EAClC,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,EACjD,aAAa,EAAE,0BAA0B,GACxC,kBAAkB,CA4KpB"}
@@ -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%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.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 kt=Object.defineProperty;var Bt=(t,n,e)=>n in t?kt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>Bt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function H(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(tt(n))}function X(t,n){t.classList.add(tt(n))}function ot(t,n){t.classList.remove(tt(n))}function G(t,n,e){H(e)&&(H(n)&&ot(t,n),X(t,e))}function tt(t){return H(t)?t.trim().replace(/\./g,""):""}function R(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function Pt(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const dt="open",ft="hidden";function rt(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?(X(t,dt),ot(t,ft)):(X(t,ft),ot(t,dt))}function Et(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function It(t){Et(t)&&t.focus()}function Nt(t){if(!Et(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),s=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||s||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||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function I(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{X(r,i)}),H(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:Pt([b.Root,b.ContentWrapper])};function gt(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 vt(t,n){return n<t?-(t-n):n-t}function J(t,n){return t>n?t-n:n-t}function xt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function ht(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function wt(t,n,e){return-(t-n)+e}function mt(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function yt(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(s=>s.trim());e.push({type:o,values:i})}return e}function Ft(t){const n=t.style.transform,e=yt(n);return{transform:n,transformValues:e}}function Ht(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function P(t){const n=t.style.transform,e=yt(n),r=Ht(e,it);return Ot(r??{type:it,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:o}=Ft(t),i=Ht(o,it);if(i){const s=Ot(i);t.style.transform=`translate(${n??s.x??0}px,${e??s.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 Ot(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:mt(n)??0,y:mt(e)??0}}function st(t){return t!=null}function pt(t,{min:n,max:e}){return st(e)&&t>=e?e:st(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,b.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Rt=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=P(n),e.onDragStart()},Ut=(t,n,e,r,o)=>i=>{Wt(i,t,e,r,o,n,e.marginTop)};function Wt(t,n,e,r,o,i,s){if(!r.isDragging||!Y(r.startY))return;const l=n.getCoordinates(t).y,a=vt(r.startY,l),p=window.innerHeight,f=i.clientHeight,d=f-(r.containerStartTranslate.y+a);if(d>=p)return;const T=Ct(r.startY,l);if(T.isUp&&!e.expandable&&d>=f)return;o.start(()=>{Z(i,{y:r.containerStartTranslate.y+a})},0);const D=p-s,c=f-r.containerStartTranslate.y;if(T.isUp){const C=D-c,O=D-d,L=pt(1-Q(O/C,2),{min:0,max:1});e.onDragMove(T,L)}else if(T.isDown){const C=pt(Q(1-d/c,2),{min:0,max:1});e.onDragMove(T,C)}}const Gt=(t,n,e,r,o,i,s)=>l=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const a=r.startY,p=t.getCoordinates(l).y,f=P(n).y,d=Ct(a,p),T=window.innerHeight,D=n.clientHeight;if(d.isUp){const c=[...e.snapPoints].sort((L,k)=>L-k),C=D+-f;if(!e.expandable&&C>=D)return;for(const L of c){const k=L*window.innerHeight;if(C<=k){const A=J(C,k);s.translateContainer({startY:f,endY:f-A,animationFrame:o,bottomSheetContainer:n});return}}const O=wt(T,D,e.marginTop);s.translateContainer({startY:f,endY:O,animationFrame:o,bottomSheetContainer:n})}else if(d.isDown){const c=[...e.snapPoints].sort((C,O)=>O-C);for(const C of c){const O=C*window.innerHeight,L=D+-f;if(L>=O){const k=J(L,O);s.translateContainer({startY:f,endY:f+k,animationFrame:o,bottomSheetContainer:n});return}}i()}};var x=(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))(x||{});function at(t){switch(t){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return 3;default:return-1}}const $t={eventPhase:x.All};class ${constructor(n){W(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=$t,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===x.All){n(i);return}at(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===x.All){n(i);return}at(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}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 Lt(t){const n=t;return`${n} ${n} 0px 0px`}function Vt(t,n){const e=Xt(t);jt(e),e.bottomSheetContainer.style.width=t.width;const r=document.createElement("div");r.innerHTML=t.content??"";const o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Kt({bottomSheetElements:e,bottomSheetProps:t,options:n});return{elements:e,eventHandlers:i}}function Xt(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=Lt(t.containerBorderRadius));const r=I("div",b.GapFiller,b.GapFiller),o=I("button",R([b.Handle,q.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),b.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=I("span",R([b.HandleBar,t.shouldShowHandle?null:V.Hidden]),b.HandleBar),s=I("article",R([b.ContentWrapper,t.contentWrapperClass]),b.ContentWrapper),l=I("div",R([b.Backdrop,t.backdropClass,V.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:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:s,bottomSheetContainerGapFiller:r}}function jt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Kt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:s,bottomSheetContentWrapper:l,bottomSheetBackdrop:a}=t,{animationFrame:p}=e,f=new $(i),d=new $(l),T=new $(s),D=n.dragTriggers.reduce((v,y)=>{const E=r.querySelectorAll(y);if(!E.length)return v;const _=Array.from(E).map(u=>u instanceof HTMLElement?new $(u):null).filter(u=>!!u);return[...v,..._]},[]),c=new $(window),C=Rt(c,o,n,e.draggingState),O=Ut(c,o,n,e.draggingState,p),L=Gt(c,o,n,e.draggingState,p,e.onClose,e.bottomSheetState);function k(v){v.target instanceof Element&&!r.contains(v.target)&&e.onClose()}function A(v){_t(e.draggingState,v.target,t.bottomSheetContentWrapper)}function F(v){const y=v??n;y.draggable&&(f.addEventListeners({onStart:A}),D.forEach(E=>{E.addEventListeners({onStart:A,onStartOptions:{eventPhase:x.Target}})})),y.draggable&&y.backgroundDraggable&&(d.addEventListeners({onStart:A,onStartOptions:{eventPhase:x.Target}}),T.addEventListeners({onStart:A})),y.draggable&&c.addEventListeners({onStart:C,onMove:O,onEnd:L}),y.draggable&&window.document.addEventListener("keyup",E=>{E.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",E=>{if(E.key==="ArrowUp"){e.moveUp();return}if(E.key==="ArrowDown"){e.moveDown();return}if(E.shiftKey&&E.key==="Tab"){const _=et(t.bottomSheetContentWrapper);It(_)}})}function j(){n.shouldCloseOnOutsideClick?a.addEventListener("click",k):a.style.pointerEvents="none"}function nt(){a.removeEventListener("click",k)}function et(v){let y=[...Array.from(v.childNodes).reverse()];for(;y.length;){const E=y.shift();if(Nt(E))return E;E&&(y=[...y,...Array.from(E.childNodes).reverse()])}return null}function K(){f.removeEventListeners({onStart:A}),d.removeEventListeners({onStart:A}),T.removeEventListeners({onStart:A}),D.forEach(v=>{v.removeEventListeners({onStart:A})}),c.removeEventListeners({onStart:C,onMove:O,onEnd:L})}return{attachEventListeners:F,clearEventListeners:K,attacheOnOpenEventListeners:j,clearOnOpenEventListeners:nt}}class zt{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 o=i=>{this.startedAt||(this.startedAt=i);const s=i-this.startedAt,a=e===0?1:Q(s/e,2),p=a>=1&&!r;n(a),p?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:s,animationDuration:l}=t,a=vt(n,e);o.stop();let p=!1;o.start(f=>{Z(r,{y:n+a*s(f)}),!p&&f>=1&&(i==null||i(),p=!0)},l)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},M={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,s){return n(o,i),Reflect.set(r,o,i,s)}};return new Proxy(t,e)}function Zt(...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 At(t){for(const n of Object.values(N))if(n===t)return!0;return!1}function ut(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function U(t,n,e,r){return function(a){return l(i(a))};function i(a){let p=0,f=1,d=a,T;if(a===0||a===1)return a;for(;p<f;){if(T=s(d),Math.abs(T-a)<.001)return d;a>T?p=d:f=d,d=(f+p)/2}return d}function s(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*r*Math.pow(a,2)*(1-a)+Math.pow(a,3)}}const Tt=U(.25,.1,.25,1),tn=U(.42,0,1,1),St=U(.42,0,.58,1),nn=U(.4,.1,.6,1),en=U(.45,1.5,.55,1);function rn(t){switch(t){case N.EASE:return Tt;case N.EASE_IN:return tn;case N.EASE_OUT:return St;case N.EASE_IN_OUT:return nn;case N.SPRING:return en;default:return Tt}}function bt(t){return typeof t=="boolean"}const Dt={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 on(t){const n={...Dt},e=Object.entries(t).reduce((o,i)=>{const[s,l]=i;return st(l)&&(o[s]=l),o},{});return{...n,...e}}function lt(t){if(ut(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return U(n,e,r,o)}return At(t)?rn(t):St}function sn(t,n,e,r){function o(i,s){switch(i){case"content":H(s)&&(t.bottomSheetContentWrapper.innerHTML=s);break;case"width":H(s)&&(t.bottomSheetContainer.style.width=s);break;case"shouldShowHandle":bt(s)||z(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":bt(s)||z(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":H(s)&&(t.bottomSheetContainer.style.borderRadius=Lt(s));break;case"backdropColor":H(s)&&(t.bottomSheetBackdrop.style.backgroundColor=s);break;case"backDropTransition":H(s)&&(t.bottomSheetBackdrop.style.transition=s);break;case"rootClass":if(!H(s))return;G(t.bottomSheetRoot,e.rootClass,s);break;case"containerClass":if(!H(s))return;G(t.bottomSheetContainer,e.containerClass,s);break;case"handleClass":if(!H(s))return;G(t.bottomSheetHandle,e.handleClass,s);break;case"contentWrapperClass":if(!H(s))return;G(t.bottomSheetContentWrapper,e.contentWrapperClass,s);break;case"backdropClass":if(!H(s))return;G(t.bottomSheetBackdrop,e.backdropClass,s);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(ut(s)){const l=lt(s),a=ct(l,e.draggingAnimationDuration);n.translateContainer=a}break;case"draggingAnimationDuration":if(Y(s)){const l=lt(e.draggingAnimationTimings),a=ct(l,s);n.translateContainer=a}break}}return o}function an(t){const n=on(t),e=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function s(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const l=new zt,a={animationFrame:l,onClose:k,bottomSheetState:o,draggingState:i,snapTo:_,moveUp:y,moveDown:E},{elements:p,eventHandlers:f}=Vt(n,a),d=Qt(n,sn(p,o,n,f)),{bottomSheetBackdrop:T,bottomSheetRoot:D,bottomSheetContainer:c}=p,C=u=>{const g=u??window.document.body;g.appendChild(D),g.appendChild(T);const h=window.innerHeight;Z(c,{y:h}),f.attachEventListeners(),o.isMounted=!0},O=()=>{f.clearEventListeners(),Object.values(p).forEach(u=>{u.remove()}),s(),o.isMounted=!1},L=()=>{var B;if(A()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(B=t.beforeOpen)==null||B.call(t),F())return;rt(T,!0),d.shouldShowBackdrop||X(T,"transparent"),rt([c],!0),Z(c,{y:c.clientHeight});const g=window.innerHeight,h=gt(g,c.clientHeight,d.marginTop,d.defaultPosition),m=P(c).y;o.translateContainer({startY:m,endY:h,animationFrame:l,bottomSheetContainer:c,onEnd:t.afterOpen});const w=document.body.style.overflowY;i.originalDocumentOverflowY=w||"initial";const S=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=S||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",p.bottomSheetHandle.focus(),f.attacheOnOpenEventListeners()};function k(){var h;if(j())return;(h=t.beforeClose)==null||h.call(t);const u=P(c).y,g=c.clientHeight;o.translateContainer({startY:u,endY:g,animationFrame:l,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),rt([T,c],!1),f.clearOnOpenEventListeners()}}),s()}function A(){return o.isMounted}function F(){const u=P(c).y,g=window.innerHeight,h=c.clientHeight>=g?g:c.clientHeight;return u<=h}function j(){return!F()}function nt(){const u=P(c).y,g=c.clientHeight,h=window.innerHeight;if(u<=5&&u>=-5)return M.CONTENT_HEIGHT;const m=g-u;if(m===h/2)return M.MIDDLE;const w=h-d.marginTop,S=10;return m<=w+S&&m>=w-S?M.TOP:M.CLOSED}function et(){return c.clientHeight}function K(u){if(!F())return;const g=P(c).y,m=c.clientHeight-g,w=window.innerHeight-u,S=xt(m,w),B=J(m,w);o.translateContainer({startY:g,endY:g+(S.isUp?-B:B),animationFrame:l,bottomSheetContainer:c})}function v(u,{viewportHeight:g,visibleHeight:h}){let m=null;for(const w of u){const S=w*g,B=J(h,S);(m===null||B<m)&&(m=B)}return{minOffset:m}}function y(){const u=[...d.snapPoints].reverse(),g=P(c).y,h=c.clientHeight,m=h-g;if(!d.expandable&&m>=h)return;const w=window.innerHeight,S=ht("above",{visibleHeight:m,viewportHeight:w},u),{minOffset:B}=v(S,{visibleHeight:m,viewportHeight:w});if(B===null&&m<w-d.marginTop){o.translateContainer({startY:g,endY:gt(w,h,d.marginTop,"top"),animationFrame:l,bottomSheetContainer:c});return}Y(B)&&o.translateContainer({startY:g,endY:g-B,animationFrame:l,bottomSheetContainer:c})}function E(){const u=P(c).y,h=c.clientHeight-u;if(h<1)return;const m=window.innerHeight,w=ht("below",{visibleHeight:h,viewportHeight:m},d.snapPoints),{minOffset:S}=v(w,{visibleHeight:h,viewportHeight:m});Y(S)&&o.translateContainer({startY:u,endY:u+S,animationFrame:l,bottomSheetContainer:c})}function _(u){const g=window.innerHeight;if(!Jt(u))return;const h=Q(g*u,2);K(h)}return{props:d,elements:p,mount:C,unmount:O,open:L,close:k,getIsMounted:A,getIsOpen:F,getIsClosed:j,getPosition:nt,getHeight:et,moveTo:K,snapTo:_}}function cn(){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=Dt;exports.BOTTOM_SHEET_POSITION=M;exports.BOTTOM_SHEET_SELECTORS=Mt;exports.COMMON_ANIMATION_KEYS=N;exports.ClassNames=b;exports.EventPhase=x;exports.ResetClassNames=q;exports.UtilClassNames=V;exports.createBottomSheet=an;exports.createPlaceholderBottomSheet=cn;exports.eventPhaseToEnum=at;exports.isAnimationTimingPoints=ut;exports.isCommonAnimationTimingsKey=At;
2
+ "use strict";var Bt=Object.defineProperty;var Dt=(t,n,e)=>n in t?Bt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var j=(t,n,e)=>Dt(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function H(t){return typeof t=="string"}function Yt(t,n){return t.classList.contains(tt(n))}function X(t,n){t.classList.add(tt(n))}function ot(t,n){t.classList.remove(tt(n))}function W(t,n,e){H(e)&&(H(n)&&ot(t,n),X(t,e))}function tt(t){return H(t)?t.trim().replace(/\./g,""):""}function F(t){return t.map(n=>tt(n)).filter(Boolean).join(" ")}function It(t){return t.map(n=>n==null?void 0:n.trim()).filter(Boolean).map(n=>`.${n}`).join(" ")}const dt="open",ft="hidden";function rt(t,n){const e=n;if(Array.isArray(t)){t.forEach(r=>{q(r,e),r.setAttribute("aria-modal",e?"true":"false")});return}q(t,e),t.setAttribute("aria-modal",e?"true":"false")}function q(t,n){n?(X(t,dt),ot(t,ft)):(X(t,ft),ot(t,dt))}function yt(t){return t instanceof HTMLElement}function Y(t){return typeof t=="number"&&!Number.isNaN(t)}function Nt(t){yt(t)&&t.focus()}function Pt(t){if(!yt(t)||t.offsetParent===null||"disabled"in t&&t.disabled)return!1;const e=t.getAttribute("tabindex"),r=Y(e)?parseInt(e,10):-1,i=["INPUT","BUTTON","SELECT","TEXTAREA","A","AREA","IFRAME"].includes(t.tagName),a=t instanceof HTMLAnchorElement&&t.href!==""||t instanceof HTMLAreaElement&&t.href!=="";return i||a||r>-1}var y=(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))(y||{}),J=(t=>(t.Button="pbs-button-reset",t.Dialog="pbs-dialog-reset",t))(J||{}),V=(t=>(t.Hidden="hidden",t))(V||{});function N(t,n,e){const r=document.createElement(t);return n.split(" ").forEach(i=>{X(r,i)}),H(e)&&r.setAttribute("data-testid",e),r}const Mt={CONTENTS_WRAPPER:It([y.Root,y.ContentWrapper])};function gt(t,n,e,r){switch(r){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 Et(t,n){const e=n<t,r=n>t;return{isUp:e,isDown:r,stayedSame:n===t}}function Ct(t,n){return n<t?-(t-n):n-t}function $(t,n){return t>n?t-n:n-t}function xt(t,n){const e=t<n,r=t>n;return{isUp:e,isDown:r,stayedSame:t===n}}function ht(t,n,e){const r=t==="above";return e.filter(o=>{const i=o*n.viewportHeight;return r?n.visibleHeight<i:n.visibleHeight>i})}function vt(t,n,e){return-(t-n)+e}function mt(t){return Number(t.replace("px",""))}function Q(t,...n){return Number(t.toFixed(...n))}function St(t){const n=/(?<type>\w+)\((?<values>[^)]+)\)/g,e=[];let r;for(;(r=n.exec(t))!==null;){const o=r[1],i=r[2].split(",").map(a=>a.trim());e.push({type:o,values:i})}return e}function Rt(t){const n=t.style.transform,e=St(n);return{transform:n,transformValues:e}}function Ot(t,n){const e=t.find(r=>r.type.startsWith(n));return e||null}const it="translate";function I(t){const n=t.style.transform,e=St(n),r=Ot(e,it);return wt(r??{type:it,values:[]})}function Z(t,{x:n,y:e}){const{transform:r,transformValues:o}=Rt(t),i=Ot(o,it);if(i){const a=wt(i);t.style.transform=`translate(${n??a.x??0}px,${e??a.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 wt(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:mt(n)??0,y:mt(e)??0}}function at(t){return t!=null}function bt(t,{min:n,max:e}){return at(e)&&t>=e?e:at(n)&&t<=n?n:t}const _t=(t,n,e)=>{n instanceof HTMLElement&&!Yt(n,y.Handle)&&e.scrollTop>=1||(t.isDragging=!0)},Ft=(t,n,e,r)=>o=>{r.startY=t.getCoordinates(o).y,r.containerStartTranslate=I(n),e.onDragStart()},Ut=(t,n,e,r,o)=>i=>{jt(i,t,e,r,o,n,e.marginTop)};function jt(t,n,e,r,o,i,a){if(!r.isDragging||!Y(r.startY))return;const u=n.getCoordinates(t).y,s=Ct(r.startY,u),b=window.innerHeight,l=i.clientHeight,f=l-(r.containerStartTranslate.y+s);if(f>=b)return;const p=Et(r.startY,u);if(p.isUp&&!e.expandable&&f>=l||e.preventClosing&&f<=l)return;o.start(()=>{Z(i,{y:r.containerStartTranslate.y+s})},0);const S=b-a,c=l-r.containerStartTranslate.y;if(p.isUp){const T=S-c,O=S-f,L=bt(1-Q(O/T,2),{min:0,max:1});e.onDragMove(p,L)}else if(p.isDown){const T=bt(Q(1-f/c,2),{min:0,max:1});e.onDragMove(p,T)}}const Wt=(t,n,e,r,o,i,a)=>u=>{if(!r.isDragging||(r.isDragging=!1,!Y(r.startY)))return;e.onDragEnd();const s=r.startY,b=t.getCoordinates(u).y,l=I(n).y,f=Et(s,b),p=window.innerHeight,S=n.clientHeight;if(f.isUp){const c=[...e.snapPoints].sort((L,B)=>L-B),T=S+-l;if(!e.expandable&&T>=S)return;for(const L of c){const B=L*window.innerHeight;if(T<=B){const A=$(T,B);a.translateContainer({startY:l,endY:l-A,animationFrame:o,bottomSheetContainer:n});return}}const O=vt(p,S,e.marginTop);a.translateContainer({startY:l,endY:O,animationFrame:o,bottomSheetContainer:n})}else if(f.isDown){const c=[...e.snapPoints].sort((T,O)=>O-T);for(const T of c){const O=T*window.innerHeight,L=S+-l;if(L>=O){const B=$(L,O);a.translateContainer({startY:l,endY:l+B,animationFrame:o,bottomSheetContainer:n});return}}if(e.preventClosing){const T=S+-l;if(T>=S){const O=$(T,S);a.translateContainer({startY:l,endY:l+O,animationFrame:o,bottomSheetContainer:n})}return}i()}};var x=(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))(x||{});function st(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:x.All};class G{constructor(n){j(this,"currentTarget");this.currentTarget=n}addEventListeners({onStart:n,onStartOptions:e=Gt,onMove:r,onEnd:o}){this.addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}),this.addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o})}addTouchEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("touchstart",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("touchmove",r),o&&this.currentTarget.addEventListener("touchend",o)}addMouseEventListeners({onStart:n,onStartOptions:e,onMove:r,onEnd:o}){n&&this.currentTarget.addEventListener("mousedown",i=>{if(e.eventPhase===x.All){n(i);return}st(i.eventPhase)===e.eventPhase&&n(i)},{passive:!0}),r&&this.currentTarget.addEventListener("mousemove",r),o&&this.currentTarget.addEventListener("mouseup",i=>{o(i)})}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 Ht(t){const n=t;return`${n} ${n} 0px 0px`}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 o=window.innerHeight;e.bottomSheetContainer.style.maxHeight=`${o}px`,e.bottomSheetContentWrapper.appendChild(r);const i=Kt({bottomSheetElements:e,bottomSheetProps:t,options:n});return t.rootStyle&&Object.assign(e.bottomSheetRoot.style,t.rootStyle),t.backdropStyle&&Object.assign(e.bottomSheetBackdrop.style,t.backdropStyle),t.containerStyle&&Object.assign(e.bottomSheetContainer.style,t.containerStyle),t.handleStyle&&Object.assign(e.bottomSheetHandleBar.style,t.handleStyle),t.contentWrapperStyle&&Object.assign(e.bottomSheetContentWrapper.style,t.contentWrapperStyle),{elements:e,eventHandlers:i}}function $t(t){const n=N("dialog",F([y.Root,J.Dialog,t.rootClass]),y.Root);n.ariaLabel=t.ariaLabel;const e=N("section",F([y.Container,t.containerClass]),y.Container);t.containerBorderRadius&&(e.style.borderRadius=Ht(t.containerBorderRadius));const r=N("div",y.GapFiller,y.GapFiller),o=N("button",F([y.Handle,J.Button,t.shouldShowHandle?null:V.Hidden,t.handleClass]),y.Handle);o.setAttribute("type","button"),o.ariaLabel="bottom sheet close button";const i=N("span",F([y.HandleBar,t.shouldShowHandle?null:V.Hidden]),y.HandleBar),a=N("article",F([y.ContentWrapper,t.contentWrapperClass]),y.ContentWrapper),u=N("div",F([y.Backdrop,t.backdropClass,V.Hidden]),y.Backdrop);return t.backdropColor&&(u.style.backgroundColor=t.backdropColor),t.backDropTransition&&(u.style.transition=t.backDropTransition),{bottomSheetRoot:n,bottomSheetBackdrop:u,bottomSheetContainer:e,bottomSheetHandle:o,bottomSheetHandleBar:i,bottomSheetContentWrapper:a,bottomSheetContainerGapFiller:r}}function Xt({bottomSheetRoot:t,bottomSheetContainer:n,bottomSheetHandle:e,bottomSheetHandleBar:r,bottomSheetContentWrapper:o,bottomSheetContainerGapFiller:i}){t.appendChild(n),e.appendChild(r),n.appendChild(e),n.appendChild(o),n.appendChild(i)}function Kt({bottomSheetElements:t,bottomSheetProps:n,options:e}){const{bottomSheetRoot:r,bottomSheetContainer:o,bottomSheetHandle:i,bottomSheetContainerGapFiller:a,bottomSheetContentWrapper:u,bottomSheetBackdrop:s}=t,{animationFrame:b}=e,l=new G(i),f=new G(u),p=new G(a),S=n.dragTriggers.reduce((C,w)=>{const E=r.querySelectorAll(w);if(!E.length)return C;const _=Array.from(E).map(d=>d instanceof HTMLElement?new G(d):null).filter(d=>!!d);return[...C,..._]},[]),c=new G(window),T=Ft(c,o,n,e.draggingState),O=Ut(c,o,n,e.draggingState,b),L=Wt(c,o,n,e.draggingState,b,e.onClose,e.bottomSheetState);function B(C){C.target instanceof Element&&!r.contains(C.target)&&e.onClose()}function A(C){_t(e.draggingState,C.target,t.bottomSheetContentWrapper)}function R(C){const w=C??n;w.draggable&&(l.addEventListeners({onStart:A}),S.forEach(E=>{E.addEventListeners({onStart:A,onStartOptions:{eventPhase:x.Target}})})),w.draggable&&w.backgroundDraggable&&(f.addEventListeners({onStart:A,onStartOptions:{eventPhase:x.Target}}),p.addEventListeners({onStart:A})),w.draggable&&c.addEventListeners({onStart:T,onMove:O,onEnd:L}),w.draggable&&window.document.addEventListener("keyup",E=>{E.key==="Escape"&&e.onClose()}),i.addEventListener("keyup",E=>{if(E.key==="ArrowUp"){e.moveUp();return}if(E.key==="ArrowDown"){e.moveDown();return}if(E.shiftKey&&E.key==="Tab"){const _=et(t.bottomSheetContentWrapper);Nt(_)}})}function K(){n.shouldCloseOnOutsideClick?s.addEventListener("click",B):s.style.pointerEvents="none"}function nt(){s.removeEventListener("click",B)}function et(C){let w=[...Array.from(C.childNodes).reverse()];for(;w.length;){const E=w.shift();if(Pt(E))return E;E&&(w=[...w,...Array.from(E.childNodes).reverse()])}return null}function z(){l.removeEventListeners({onStart:A}),f.removeEventListeners({onStart:A}),p.removeEventListeners({onStart:A}),S.forEach(C=>{C.removeEventListeners({onStart:A})}),c.removeEventListeners({onStart:T,onMove:O,onEnd:L})}return{attachEventListeners:R,clearEventListeners:z,attacheOnOpenEventListeners:K,clearOnOpenEventListeners:nt}}class zt{constructor(){j(this,"animationId");j(this,"isInProgress");j(this,"startedAt");this.animationId=null,this.isInProgress=!1,this.startedAt=null}start(n,e,r=!1){this.isInProgress=!0;const o=i=>{this.startedAt||(this.startedAt=i);const a=i-this.startedAt,s=e===0?1:Q(a/e,2),b=s>=1&&!r;n(s),b?this.stop():this.animationId=requestAnimationFrame(o)};this.animationId=requestAnimationFrame(o)}stop(){this.isInProgress=!1,this.startedAt=null,Y(this.animationId)&&cancelAnimationFrame(this.animationId)}}function qt(t){const{startY:n,endY:e,bottomSheetContainer:r,animationFrame:o,onEnd:i,animationTimingFunction:a,animationDuration:u}=t,s=Ct(n,e);o.stop();let b=!1;o.start(l=>{Z(r,{y:n+s*a(l)}),!b&&l>=1&&(i==null||i(),b=!0)},u)}const ct=(t,n)=>e=>{qt({...e,animationTimingFunction:t,animationDuration:n})},M={TOP:"top",MIDDLE:"middle",CONTENT_HEIGHT:"content-height",CLOSED:"closed"};function Jt(t){return!(!Y(t)||t>1||t<0)}function Qt(t,n){const e={set(r,o,i,a){return n(o,i),Reflect.set(r,o,i,a)}};return new Proxy(t,e)}function Zt(...t){console.error(t)}const P={EASE:"ease",EASE_IN:"ease-in",EASE_OUT:"ease-out",EASE_IN_OUT:"ease-in-out",SPRING:"spring"};function Lt(t){for(const n of Object.values(P))if(n===t)return!0;return!1}function ut(t){return!!(t instanceof Object&&"p1x"in t&&"p1y"in t&&"p2x"in t&&"p2y"in t&&Y(t.p1x)&&Y(t.p1y)&&Y(t.p2x)&&Y(t.p2y))}function U(t,n,e,r){return function(s){return u(i(s))};function i(s){let b=0,l=1,f=s,p;if(s===0||s===1)return s;for(;b<l;){if(p=a(f),Math.abs(p-s)<.001)return f;s>p?b=f:l=f,f=(l+b)/2}return f}function a(s){return 3*t*s*Math.pow(1-s,2)+3*e*Math.pow(s,2)*(1-s)+Math.pow(s,3)}function u(s){return 3*n*s*Math.pow(1-s,2)+3*r*Math.pow(s,2)*(1-s)+Math.pow(s,3)}}const pt=U(.25,.1,.25,1),tn=U(.42,0,1,1),At=U(.42,0,.58,1),nn=U(.4,.1,.6,1),en=U(.45,1.5,.55,1);function rn(t){switch(t){case P.EASE:return pt;case P.EASE_IN:return tn;case P.EASE_OUT:return At;case P.EASE_IN_OUT:return nn;case P.SPRING:return en;default:return pt}}function Tt(t){return typeof t=="boolean"}const kt={ariaLabel:"Bottom sheet",content:"",defaultPosition:M.CONTENT_HEIGHT,marginTop:20,snapPoints:[],width:"92%",dragTriggers:[],beforeOpen:()=>{},afterOpen:()=>{},beforeClose:()=>{},afterClose:()=>{},onDragStart:()=>{},onDragMove:()=>{},onDragEnd:()=>{},expandable:!0,preventClosing:!1,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,rootStyle:{},containerStyle:{},handleStyle:{},contentWrapperStyle:{},backdropStyle:{}};function on(t){const n={...kt},e=Object.entries(t).reduce((o,i)=>{const[a,u]=i;return at(u)&&(o[a]=u),o},{});return{...n,...e}}function lt(t){if(ut(t)){const{p1x:n,p1y:e,p2x:r,p2y:o}=t;return U(n,e,r,o)}return Lt(t)?rn(t):At}function an(t,n,e,r){function o(i,a){switch(i){case"content":H(a)&&(t.bottomSheetContentWrapper.innerHTML=a);break;case"width":H(a)&&(t.bottomSheetContainer.style.width=a);break;case"shouldShowHandle":Tt(a)||q(t.bottomSheetHandle,!1);break;case"shouldShowBackdrop":Tt(a)||q(t.bottomSheetBackdrop,!1);break;case"containerBorderRadius":H(a)&&(t.bottomSheetContainer.style.borderRadius=Ht(a));break;case"backdropColor":H(a)&&(t.bottomSheetBackdrop.style.backgroundColor=a);break;case"backDropTransition":H(a)&&(t.bottomSheetBackdrop.style.transition=a);break;case"rootClass":if(!H(a))return;W(t.bottomSheetRoot,e.rootClass,a);break;case"containerClass":if(!H(a))return;W(t.bottomSheetContainer,e.containerClass,a);break;case"handleClass":if(!H(a))return;W(t.bottomSheetHandle,e.handleClass,a);break;case"contentWrapperClass":if(!H(a))return;W(t.bottomSheetContentWrapper,e.contentWrapperClass,a);break;case"backdropClass":if(!H(a))return;W(t.bottomSheetBackdrop,e.backdropClass,a);break;case"expandable":r.clearEventListeners(),r.attachEventListeners(e);break;case"preventClosing":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggable":r.clearEventListeners(),r.attachEventListeners(e);break;case"draggingAnimationTimings":if(ut(a)){const u=lt(a),s=ct(u,e.draggingAnimationDuration);n.translateContainer=s}break;case"draggingAnimationDuration":if(Y(a)){const u=lt(e.draggingAnimationTimings),s=ct(u,a);n.translateContainer=s}break;case"rootStyle":e.rootStyle&&Object.assign(t.bottomSheetRoot.style,e.rootStyle);break;case"backdropStyle":e.backdropStyle&&Object.assign(t.bottomSheetBackdrop.style,e.backdropStyle);break;case"containerStyle":e.containerStyle&&Object.assign(t.bottomSheetContainer.style,e.containerStyle);break;case"handleStyle":e.handleStyle&&Object.assign(t.bottomSheetHandleBar.style,e.handleStyle);break;case"contentWrapperStyle":e.contentWrapperStyle&&Object.assign(t.bottomSheetContentWrapper.style,e.contentWrapperStyle);break}}return o}function sn(t){const n=on(t),e=lt(t.draggingAnimationTimings),o={isMounted:!1,translateContainer:ct(e,n.draggingAnimationDuration)},i={startY:null,containerStartTranslate:{x:0,y:0},isDragging:!1,originalDocumentOverflowY:null,originalDocumentOverscrollBehavior:null};function a(){i.originalDocumentOverflowY&&i.originalDocumentOverflowY!=="hidden"&&(document.body.style.overflowY=i.originalDocumentOverflowY),i.originalDocumentOverscrollBehavior&&(document.body.style.position=i.originalDocumentOverscrollBehavior)}const u=new zt,s={animationFrame:u,onClose:B,bottomSheetState:o,draggingState:i,snapTo:_,moveUp:w,moveDown:E},{elements:b,eventHandlers:l}=Vt(n,s),f=Qt(n,an(b,o,n,l)),{bottomSheetBackdrop:p,bottomSheetRoot:S,bottomSheetContainer:c}=b,T=d=>{const g=d??window.document.body;g.appendChild(S),g.appendChild(p);const h=window.innerHeight;Z(c,{y:h}),l.attachEventListeners(),o.isMounted=!0},O=()=>{l.clearEventListeners(),Object.values(b).forEach(d=>{d.remove()}),a(),o.isMounted=!1},L=()=>{var D;if(A()||Zt('Bottom Sheet is not mounted yet. call the "mount" method first.'),(D=t.beforeOpen)==null||D.call(t),R())return;rt(p,!0),f.shouldShowBackdrop||X(p,"transparent"),rt([c],!0),Z(c,{y:c.clientHeight});const g=window.innerHeight,h=gt(g,c.clientHeight,f.marginTop,f.defaultPosition),m=I(c).y;o.translateContainer({startY:m,endY:h,animationFrame:u,bottomSheetContainer:c,onEnd:t.afterOpen});const v=document.body.style.overflowY;i.originalDocumentOverflowY=v||"initial";const k=document.body.style.overscrollBehavior;i.originalDocumentOverscrollBehavior=k||"initial",document.body.style.overflow="hidden",document.body.style.overscrollBehavior="contain",b.bottomSheetHandle.focus(),l.attacheOnOpenEventListeners()};function B(){var h;if(K())return;(h=t.beforeClose)==null||h.call(t);const d=I(c).y,g=c.clientHeight;o.translateContainer({startY:d,endY:g,animationFrame:u,bottomSheetContainer:c,onEnd:()=>{var m;(m=t.afterClose)==null||m.call(t),rt([p,c],!1),l.clearOnOpenEventListeners()}}),a()}function A(){return o.isMounted}function R(){const d=I(c).y,g=window.innerHeight,h=c.clientHeight>=g?g:c.clientHeight;return d<=h}function K(){return!R()}function nt(){const d=I(c).y,g=c.clientHeight,h=window.innerHeight;if(d<=5&&d>=-5)return M.CONTENT_HEIGHT;const m=g-d;if(m===h/2)return M.MIDDLE;const v=h-f.marginTop,k=10;return m<=v+k&&m>=v-k?M.TOP:M.CLOSED}function et(){return c.clientHeight}function z(d){if(!R())return;const g=I(c).y,m=c.clientHeight-g,v=window.innerHeight-d,k=xt(m,v),D=$(m,v);o.translateContainer({startY:g,endY:g+(k.isUp?-D:D),animationFrame:u,bottomSheetContainer:c})}function C(d,{viewportHeight:g,visibleHeight:h}){let m=null;for(const v of d){const k=v*g,D=$(h,k);(m===null||D<m)&&(m=D)}return{minOffset:m}}function w(){const d=[...f.snapPoints].reverse(),g=I(c).y,h=c.clientHeight,m=h-g;if(!f.expandable&&m>=h)return;const v=window.innerHeight,k=ht("above",{visibleHeight:m,viewportHeight:v},d),{minOffset:D}=C(k,{visibleHeight:m,viewportHeight:v});if(D===null&&m<v-f.marginTop){o.translateContainer({startY:g,endY:gt(v,h,f.marginTop,"top"),animationFrame:u,bottomSheetContainer:c});return}Y(D)&&o.translateContainer({startY:g,endY:g-D,animationFrame:u,bottomSheetContainer:c})}function E(){const d=I(c).y,h=c.clientHeight-d;if(h<1)return;const m=window.innerHeight,v=ht("below",{visibleHeight:h,viewportHeight:m},f.snapPoints),{minOffset:k}=C(v,{visibleHeight:h,viewportHeight:m});Y(k)&&o.translateContainer({startY:d,endY:d+k,animationFrame:u,bottomSheetContainer:c})}function _(d){const g=window.innerHeight;if(!Jt(d))return;const h=Q(g*d,2);z(h)}return{props:f,elements:b,mount:T,unmount:O,open:L,close:B,getIsMounted:A,getIsOpen:R,getIsClosed:K,getPosition:nt,getHeight:et,moveTo:z,snapTo:_}}function cn(){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=kt;exports.BOTTOM_SHEET_POSITION=M;exports.BOTTOM_SHEET_SELECTORS=Mt;exports.COMMON_ANIMATION_KEYS=P;exports.ClassNames=y;exports.EventPhase=x;exports.ResetClassNames=J;exports.UtilClassNames=V;exports.createBottomSheet=sn;exports.createPlaceholderBottomSheet=cn;exports.eventPhaseToEnum=st;exports.isAnimationTimingPoints=ut;exports.isCommonAnimationTimingsKey=Lt;