@enya-learning/nova 0.4.3 → 0.6.0

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.
Files changed (146) hide show
  1. package/README.md +8 -19
  2. package/dist/chunks/dist-fahbq1psobj0ox6s.js +1327 -0
  3. package/dist/chunks/dist-fahbq1psobj0ox6s.js.map +1 -0
  4. package/dist/chunks/dist-o8x0ip0z71xkr2oh.js +37 -0
  5. package/dist/chunks/dist-o8x0ip0z71xkr2oh.js.map +1 -0
  6. package/dist/components/accordion.js +62 -0
  7. package/dist/components/accordion.js.map +1 -0
  8. package/dist/components/alert-dialog.js +108 -0
  9. package/dist/components/alert-dialog.js.map +1 -0
  10. package/dist/components/alert.js +49 -0
  11. package/dist/components/alert.js.map +1 -0
  12. package/dist/components/aspect-ratio.js +16 -0
  13. package/dist/components/aspect-ratio.js.map +1 -0
  14. package/dist/components/avatar.js +58 -0
  15. package/dist/components/avatar.js.map +1 -0
  16. package/dist/components/badge.js +33 -0
  17. package/dist/components/badge.js.map +1 -0
  18. package/dist/components/box.js +16 -0
  19. package/dist/components/box.js.map +1 -0
  20. package/dist/components/breadcrumb.js +85 -0
  21. package/dist/components/breadcrumb.js.map +1 -0
  22. package/dist/components/button-group.js +47 -0
  23. package/dist/components/button-group.js.map +1 -0
  24. package/dist/components/button.js +48 -3
  25. package/dist/components/button.js.map +1 -0
  26. package/dist/components/calendar.js +3004 -0
  27. package/dist/components/calendar.js.map +1 -0
  28. package/dist/components/card.js +65 -0
  29. package/dist/components/card.js.map +1 -0
  30. package/dist/components/carousel.js +1198 -0
  31. package/dist/components/carousel.js.map +1 -0
  32. package/dist/components/chart.js +10596 -0
  33. package/dist/components/chart.js.map +1 -0
  34. package/dist/components/checkbox.js +23 -0
  35. package/dist/components/checkbox.js.map +1 -0
  36. package/dist/components/collapsible.js +28 -0
  37. package/dist/components/collapsible.js.map +1 -0
  38. package/dist/components/combobox.js +192 -0
  39. package/dist/components/combobox.js.map +1 -0
  40. package/dist/components/command.js +663 -0
  41. package/dist/components/command.js.map +1 -0
  42. package/dist/components/context-menu.js +153 -0
  43. package/dist/components/context-menu.js.map +1 -0
  44. package/dist/components/dialog.js +104 -0
  45. package/dist/components/dialog.js.map +1 -0
  46. package/dist/components/direction.js +6 -0
  47. package/dist/components/drawer.js +1042 -0
  48. package/dist/components/drawer.js.map +1 -0
  49. package/dist/components/dropdown-menu.js +157 -0
  50. package/dist/components/dropdown-menu.js.map +1 -0
  51. package/dist/components/empty.js +67 -0
  52. package/dist/components/empty.js.map +1 -0
  53. package/dist/components/enya-logo.js +42 -42
  54. package/dist/components/enya-logo.js.map +1 -1
  55. package/dist/components/field.js +119 -0
  56. package/dist/components/field.js.map +1 -0
  57. package/dist/components/heading.js +39 -0
  58. package/dist/components/heading.js.map +1 -0
  59. package/dist/components/hover-card.js +40 -0
  60. package/dist/components/hover-card.js.map +1 -0
  61. package/dist/components/input-group.js +85 -0
  62. package/dist/components/input-group.js.map +1 -0
  63. package/dist/components/input-otp.js +417 -0
  64. package/dist/components/input-otp.js.map +1 -0
  65. package/dist/components/input.js +18 -0
  66. package/dist/components/input.js.map +1 -0
  67. package/dist/components/item.js +133 -0
  68. package/dist/components/item.js.map +1 -0
  69. package/dist/components/kbd.js +23 -0
  70. package/dist/components/kbd.js.map +1 -0
  71. package/dist/components/label.js +16 -0
  72. package/dist/components/label.js.map +1 -0
  73. package/dist/components/menubar.js +154 -0
  74. package/dist/components/menubar.js.map +1 -0
  75. package/dist/components/native-select.js +45 -0
  76. package/dist/components/native-select.js.map +1 -0
  77. package/dist/components/navigation-menu.js +95 -0
  78. package/dist/components/navigation-menu.js.map +1 -0
  79. package/dist/components/pagination.js +98 -0
  80. package/dist/components/pagination.js.map +1 -0
  81. package/dist/components/popover.js +62 -0
  82. package/dist/components/popover.js.map +1 -0
  83. package/dist/components/progress.js +50 -0
  84. package/dist/components/progress.js.map +1 -0
  85. package/dist/components/radio-group.js +30 -0
  86. package/dist/components/radio-group.js.map +1 -0
  87. package/dist/components/resizable.js +1562 -0
  88. package/dist/components/resizable.js.map +1 -0
  89. package/dist/components/scroll-area.js +40 -0
  90. package/dist/components/scroll-area.js.map +1 -0
  91. package/dist/components/select.js +116 -0
  92. package/dist/components/select.js.map +1 -0
  93. package/dist/components/separator.js +17 -0
  94. package/dist/components/separator.js.map +1 -0
  95. package/dist/components/sheet.js +99 -0
  96. package/dist/components/sheet.js.map +1 -0
  97. package/dist/components/sidebar.js +399 -0
  98. package/dist/components/sidebar.js.map +1 -0
  99. package/dist/components/skeleton.js +15 -0
  100. package/dist/components/skeleton.js.map +1 -0
  101. package/dist/components/slider.js +36 -0
  102. package/dist/components/slider.js.map +1 -0
  103. package/dist/components/sonner.js +738 -0
  104. package/dist/components/sonner.js.map +1 -0
  105. package/dist/components/spinner.js +19 -0
  106. package/dist/components/spinner.js.map +1 -0
  107. package/dist/components/switch.js +21 -0
  108. package/dist/components/switch.js.map +1 -0
  109. package/dist/components/table.js +76 -0
  110. package/dist/components/table.js.map +1 -0
  111. package/dist/components/tabs.js +51 -0
  112. package/dist/components/tabs.js.map +1 -0
  113. package/dist/components/text.js +47 -0
  114. package/dist/components/text.js.map +1 -0
  115. package/dist/components/textarea.js +16 -0
  116. package/dist/components/textarea.js.map +1 -0
  117. package/dist/components/toggle-group.js +55 -0
  118. package/dist/components/toggle-group.js.map +1 -0
  119. package/dist/components/toggle.js +39 -0
  120. package/dist/components/toggle.js.map +1 -0
  121. package/dist/components/tooltip.js +46 -0
  122. package/dist/components/tooltip.js.map +1 -0
  123. package/dist/index.js +25 -23241
  124. package/dist/src/components/badge/badge.d.ts +1 -1
  125. package/dist/src/components/box/box.d.ts +7 -0
  126. package/dist/src/components/box/index.d.ts +1 -0
  127. package/dist/src/components/button/button.d.ts +1 -1
  128. package/dist/src/components/heading/heading.d.ts +15 -0
  129. package/dist/src/components/heading/index.d.ts +1 -0
  130. package/dist/src/components/item/item.d.ts +1 -1
  131. package/dist/src/components/spinner/spinner.d.ts +2 -1
  132. package/dist/src/components/tabs/tabs.d.ts +1 -1
  133. package/dist/src/components/text/index.d.ts +1 -0
  134. package/dist/src/components/text/text.d.ts +13 -0
  135. package/dist/src/index.d.ts +4 -53
  136. package/dist/styles/nova-binding.css +355 -255
  137. package/dist/styles/nova.css +205 -38
  138. package/dist/styles/typography.css +22 -130
  139. package/package.json +31 -10
  140. package/src/eslint/no-primitive-colors.js +2 -2
  141. package/src/eslint/no-primitive-colors.test.ts +97 -0
  142. package/dist/chunks/button-kvgr8g13fe959ju0.js +0 -81
  143. package/dist/chunks/button-kvgr8g13fe959ju0.js.map +0 -1
  144. package/dist/index.js.map +0 -1
  145. package/dist/styles/globals.css +0 -77
  146. package/dist/styles/theme-nova.css +0 -201
@@ -0,0 +1,1042 @@
1
+ "use client";
2
+ import { t as rt } from "../chunks/utils-kyb5nny4y41y7hd8.js";
3
+ import { a as ge, c as ve, i as be, n as ye, o as Re, r as Se, s as Te, t as Ee } from "../chunks/dist-fahbq1psobj0ox6s.js";
4
+ import { jsx as Y, jsxs as Bt } from "react/jsx-runtime";
5
+ import * as De from "react";
6
+ import r, { useEffect as xe, useLayoutEffect as Ce, useMemo as Oe } from "react";
7
+ function $e(t) {
8
+ if (!t || typeof document > "u") return;
9
+ let n = document.head || document.getElementsByTagName("head")[0], e = document.createElement("style");
10
+ e.type = "text/css", n.appendChild(e), e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
11
+ }
12
+ var jt = r.createContext({
13
+ drawerRef: { current: null },
14
+ overlayRef: { current: null },
15
+ onPress: () => {
16
+ },
17
+ onRelease: () => {
18
+ },
19
+ onDrag: () => {
20
+ },
21
+ onNestedDrag: () => {
22
+ },
23
+ onNestedOpenChange: () => {
24
+ },
25
+ onNestedRelease: () => {
26
+ },
27
+ openProp: void 0,
28
+ dismissible: !1,
29
+ isOpen: !1,
30
+ isDragging: !1,
31
+ keyboardIsOpen: { current: !1 },
32
+ snapPointsOffset: null,
33
+ snapPoints: null,
34
+ handleOnly: !1,
35
+ modal: !1,
36
+ shouldFade: !1,
37
+ activeSnapPoint: null,
38
+ onOpenChange: () => {
39
+ },
40
+ setActiveSnapPoint: () => {
41
+ },
42
+ closeDrawer: () => {
43
+ },
44
+ direction: "bottom",
45
+ shouldAnimate: { current: !0 },
46
+ shouldScaleBackground: !1,
47
+ setBackgroundColorOnScale: !0,
48
+ noBodyStyles: !1,
49
+ container: null,
50
+ autoFocus: !1
51
+ }), at = () => {
52
+ const t = r.useContext(jt);
53
+ if (!t) throw new Error("useDrawerContext must be used within a Drawer.Root");
54
+ return t;
55
+ };
56
+ $e(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
57
+ [data-state=closed]
58
+ ){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);
59
+ function Ae() {
60
+ const t = navigator.userAgent;
61
+ return typeof window < "u" && (/Firefox/.test(t) && /Mobile/.test(t) || /FxiOS/.test(t));
62
+ }
63
+ function Pe() {
64
+ return Ot(/^Mac/);
65
+ }
66
+ function Me() {
67
+ return Ot(/^iPhone/);
68
+ }
69
+ function Ft() {
70
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
71
+ }
72
+ function Ne() {
73
+ return Ot(/^iPad/) || Pe() && navigator.maxTouchPoints > 1;
74
+ }
75
+ function Yt() {
76
+ return Me() || Ne();
77
+ }
78
+ function Ot(t) {
79
+ return typeof window < "u" && window.navigator != null ? t.test(window.navigator.platform) : void 0;
80
+ }
81
+ var Ie = 24, _e = typeof window < "u" ? Ce : xe;
82
+ function Ut(...t) {
83
+ return (...n) => {
84
+ for (let e of t) typeof e == "function" && e(...n);
85
+ };
86
+ }
87
+ var Tt = typeof document < "u" && window.visualViewport;
88
+ function Wt(t) {
89
+ let n = window.getComputedStyle(t);
90
+ return /(auto|scroll)/.test(n.overflow + n.overflowX + n.overflowY);
91
+ }
92
+ function qt(t) {
93
+ for (Wt(t) && (t = t.parentElement); t && !Wt(t); ) t = t.parentElement;
94
+ return t || document.scrollingElement || document.documentElement;
95
+ }
96
+ var ke = /* @__PURE__ */ new Set([
97
+ "checkbox",
98
+ "radio",
99
+ "range",
100
+ "color",
101
+ "file",
102
+ "image",
103
+ "button",
104
+ "submit",
105
+ "reset"
106
+ ]), pt = 0, zt;
107
+ function He(t = {}) {
108
+ let { isDisabled: n } = t;
109
+ _e(() => {
110
+ if (!n)
111
+ return pt++, pt === 1 && Yt() && (zt = Le()), () => {
112
+ pt--, pt === 0 && zt?.();
113
+ };
114
+ }, [n]);
115
+ }
116
+ function Le() {
117
+ let t, n = 0, e = (g) => {
118
+ t = qt(g.target), !(t === document.documentElement && t === document.body) && (n = g.changedTouches[0].pageY);
119
+ }, o = (g) => {
120
+ if (!t || t === document.documentElement || t === document.body) {
121
+ g.preventDefault();
122
+ return;
123
+ }
124
+ let m = g.changedTouches[0].pageY, B = t.scrollTop, k = t.scrollHeight - t.clientHeight;
125
+ k !== 0 && ((B <= 0 && m > n || B >= k && m < n) && g.preventDefault(), n = m);
126
+ }, i = (g) => {
127
+ let m = g.target;
128
+ xt(m) && m !== document.activeElement && (g.preventDefault(), m.style.transform = "translateY(-2000px)", m.focus(), requestAnimationFrame(() => {
129
+ m.style.transform = "";
130
+ }));
131
+ }, a = (g) => {
132
+ let m = g.target;
133
+ xt(m) && (m.style.transform = "translateY(-2000px)", requestAnimationFrame(() => {
134
+ m.style.transform = "", Tt && (Tt.height < window.innerHeight ? requestAnimationFrame(() => {
135
+ Vt(m);
136
+ }) : Tt.addEventListener("resize", () => Vt(m), { once: !0 }));
137
+ }));
138
+ }, b = () => {
139
+ window.scrollTo(0, 0);
140
+ }, c = window.pageXOffset, h = window.pageYOffset, x = Ut(Be(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
141
+ window.scrollTo(0, 0);
142
+ let w = Ut(st(document, "touchstart", e, {
143
+ passive: !1,
144
+ capture: !0
145
+ }), st(document, "touchmove", o, {
146
+ passive: !1,
147
+ capture: !0
148
+ }), st(document, "touchend", i, {
149
+ passive: !1,
150
+ capture: !0
151
+ }), st(document, "focus", a, !0), st(window, "scroll", b));
152
+ return () => {
153
+ x(), w(), window.scrollTo(c, h);
154
+ };
155
+ }
156
+ function Be(t, n, e) {
157
+ let o = t.style[n];
158
+ return t.style[n] = e, () => {
159
+ t.style[n] = o;
160
+ };
161
+ }
162
+ function st(t, n, e, o) {
163
+ return t.addEventListener(n, e, o), () => {
164
+ t.removeEventListener(n, e, o);
165
+ };
166
+ }
167
+ function Vt(t) {
168
+ let n = document.scrollingElement || document.documentElement;
169
+ for (; t && t !== n; ) {
170
+ let e = qt(t);
171
+ if (e !== document.documentElement && e !== document.body && e !== t) {
172
+ let o = e.getBoundingClientRect().top, i = t.getBoundingClientRect().top;
173
+ t.getBoundingClientRect().bottom > e.getBoundingClientRect().bottom + Ie && (e.scrollTop += i - o);
174
+ }
175
+ t = e.parentElement;
176
+ }
177
+ }
178
+ function xt(t) {
179
+ return t instanceof HTMLInputElement && !ke.has(t.type) || t instanceof HTMLTextAreaElement || t instanceof HTMLElement && t.isContentEditable;
180
+ }
181
+ function Fe(t, n) {
182
+ typeof t == "function" ? t(n) : t != null && (t.current = n);
183
+ }
184
+ function Ue(...t) {
185
+ return (n) => t.forEach((e) => Fe(e, n));
186
+ }
187
+ function Xt(...t) {
188
+ return De.useCallback(Ue(...t), t);
189
+ }
190
+ var Kt = /* @__PURE__ */ new WeakMap();
191
+ function $(t, n, e = !1) {
192
+ if (!t || !(t instanceof HTMLElement)) return;
193
+ let o = {};
194
+ Object.entries(n).forEach(([i, a]) => {
195
+ if (i.startsWith("--")) {
196
+ t.style.setProperty(i, a);
197
+ return;
198
+ }
199
+ o[i] = t.style[i], t.style[i] = a;
200
+ }), !e && Kt.set(t, o);
201
+ }
202
+ function We(t, n) {
203
+ if (!t || !(t instanceof HTMLElement)) return;
204
+ let e = Kt.get(t);
205
+ e && (t.style[n] = e[n]);
206
+ }
207
+ var O = (t) => {
208
+ switch (t) {
209
+ case "top":
210
+ case "bottom":
211
+ return !0;
212
+ case "left":
213
+ case "right":
214
+ return !1;
215
+ default:
216
+ return t;
217
+ }
218
+ };
219
+ function wt(t, n) {
220
+ if (!t) return null;
221
+ const e = window.getComputedStyle(t), o = e.transform || e.webkitTransform || e.mozTransform;
222
+ let i = o.match(/^matrix3d\((.+)\)$/);
223
+ return i ? parseFloat(i[1].split(", ")[O(n) ? 13 : 12]) : (i = o.match(/^matrix\((.+)\)$/), i ? parseFloat(i[1].split(", ")[O(n) ? 5 : 4]) : null);
224
+ }
225
+ function ze(t) {
226
+ return 8 * (Math.log(t + 1) - 2);
227
+ }
228
+ function Et(t, n) {
229
+ if (!t) return () => {
230
+ };
231
+ const e = t.style.cssText;
232
+ return Object.assign(t.style, n), () => {
233
+ t.style.cssText = e;
234
+ };
235
+ }
236
+ var D = {
237
+ DURATION: 0.5,
238
+ EASE: [
239
+ 0.32,
240
+ 0.72,
241
+ 0,
242
+ 1
243
+ ]
244
+ }, Gt = 0.4, Ve = 0.25, je = 100, Jt = 8, ht = 16, Ct = 26, Dt = "vaul-dragging";
245
+ function Qt(t) {
246
+ const n = r.useRef(t);
247
+ return r.useEffect(() => {
248
+ n.current = t;
249
+ }), r.useMemo(() => (...e) => n.current == null ? void 0 : n.current.call(n, ...e), []);
250
+ }
251
+ function Ye({ defaultProp: t, onChange: n }) {
252
+ const e = r.useState(t), [o] = e, i = r.useRef(o), a = Qt(n);
253
+ return r.useEffect(() => {
254
+ i.current !== o && (a(o), i.current = o);
255
+ }, [
256
+ o,
257
+ i,
258
+ a
259
+ ]), e;
260
+ }
261
+ function Zt({ prop: t, defaultProp: n, onChange: e = () => {
262
+ } }) {
263
+ const [o, i] = Ye({
264
+ defaultProp: n,
265
+ onChange: e
266
+ }), a = t !== void 0, b = a ? t : o, c = Qt(e);
267
+ return [b, r.useCallback((h) => {
268
+ if (a) {
269
+ const x = typeof h == "function" ? h(t) : h;
270
+ x !== t && c(x);
271
+ } else i(h);
272
+ }, [
273
+ a,
274
+ t,
275
+ i,
276
+ c
277
+ ])];
278
+ }
279
+ function qe({ activeSnapPointProp: t, setActiveSnapPointProp: n, snapPoints: e, drawerRef: o, overlayRef: i, fadeFromIndex: a, onSnapPointChange: b, direction: c = "bottom", container: h, snapToSequentialPoint: x }) {
280
+ const [w, g] = Zt({
281
+ prop: t,
282
+ defaultProp: e?.[0],
283
+ onChange: n
284
+ }), [m, B] = r.useState(typeof window < "u" ? {
285
+ innerWidth: window.innerWidth,
286
+ innerHeight: window.innerHeight
287
+ } : void 0);
288
+ r.useEffect(() => {
289
+ function f() {
290
+ B({
291
+ innerWidth: window.innerWidth,
292
+ innerHeight: window.innerHeight
293
+ });
294
+ }
295
+ return window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
296
+ }, []);
297
+ const k = r.useMemo(() => w === e?.[e.length - 1] || null, [e, w]), E = r.useMemo(() => {
298
+ var f;
299
+ return (f = e?.findIndex((R) => R === w)) != null ? f : null;
300
+ }, [e, w]), F = e && e.length > 0 && (a || a === 0) && !Number.isNaN(a) && e[a] === w || !e, p = r.useMemo(() => {
301
+ const f = h ? {
302
+ width: h.getBoundingClientRect().width,
303
+ height: h.getBoundingClientRect().height
304
+ } : typeof window < "u" ? {
305
+ width: window.innerWidth,
306
+ height: window.innerHeight
307
+ } : {
308
+ width: 0,
309
+ height: 0
310
+ };
311
+ var R;
312
+ return (R = e?.map((y) => {
313
+ const A = typeof y == "string";
314
+ let U = 0;
315
+ if (A && (U = parseInt(y, 10)), O(c)) {
316
+ const u = A ? U : m ? y * f.height : 0;
317
+ return m ? c === "bottom" ? f.height - u : -f.height + u : u;
318
+ }
319
+ const W = A ? U : m ? y * f.width : 0;
320
+ return m ? c === "right" ? f.width - W : -f.width + W : W;
321
+ })) != null ? R : [];
322
+ }, [
323
+ e,
324
+ m,
325
+ h
326
+ ]), M = r.useMemo(() => E !== null ? p?.[E] : null, [p, E]), P = r.useCallback((f) => {
327
+ var R;
328
+ const y = (R = p?.findIndex((A) => A === f)) != null ? R : null;
329
+ b(y), $(o.current, {
330
+ transition: `transform ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
331
+ transform: O(c) ? `translate3d(0, ${f}px, 0)` : `translate3d(${f}px, 0, 0)`
332
+ }), p && y !== p.length - 1 && a !== void 0 && y !== a && y < a ? $(i.current, {
333
+ transition: `opacity ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
334
+ opacity: "0"
335
+ }) : $(i.current, {
336
+ transition: `opacity ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
337
+ opacity: "1"
338
+ }), g(e?.[Math.max(y, 0)]);
339
+ }, [
340
+ o.current,
341
+ e,
342
+ p,
343
+ a,
344
+ i,
345
+ g
346
+ ]);
347
+ r.useEffect(() => {
348
+ if (w || t) {
349
+ var f;
350
+ const R = (f = e?.findIndex((y) => y === t || y === w)) != null ? f : -1;
351
+ p && R !== -1 && typeof p[R] == "number" && P(p[R]);
352
+ }
353
+ }, [
354
+ w,
355
+ t,
356
+ e,
357
+ p,
358
+ P
359
+ ]);
360
+ function s({ draggedDistance: f, closeDrawer: R, velocity: y, dismissible: A }) {
361
+ if (a === void 0) return;
362
+ const U = c === "bottom" || c === "right" ? (M ?? 0) - f : (M ?? 0) + f, W = E === a - 1, u = E === 0, z = f > 0;
363
+ if (W && $(i.current, { transition: `opacity ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})` }), !x && y > 2 && !z) {
364
+ A ? R() : P(p[0]);
365
+ return;
366
+ }
367
+ if (!x && y > 2 && z && p && e) {
368
+ P(p[e.length - 1]);
369
+ return;
370
+ }
371
+ const N = p?.reduce((I, X) => typeof I != "number" || typeof X != "number" ? I : Math.abs(X - U) < Math.abs(I - U) ? X : I), j = O(c) ? window.innerHeight : window.innerWidth;
372
+ if (y > Gt && Math.abs(f) < j * 0.4) {
373
+ const I = z ? 1 : -1;
374
+ if (I > 0 && k && e) {
375
+ P(p[e.length - 1]);
376
+ return;
377
+ }
378
+ if (u && I < 0 && A && R(), E === null) return;
379
+ P(p[E + I]);
380
+ return;
381
+ }
382
+ P(N);
383
+ }
384
+ function q({ draggedDistance: f }) {
385
+ if (M === null) return;
386
+ const R = c === "bottom" || c === "right" ? M - f : M + f;
387
+ (c === "bottom" || c === "right") && R < p[p.length - 1] || (c === "top" || c === "left") && R > p[p.length - 1] || $(o.current, { transform: O(c) ? `translate3d(0, ${R}px, 0)` : `translate3d(${R}px, 0, 0)` });
388
+ }
389
+ function J(f, R) {
390
+ if (!e || typeof E != "number" || !p || a === void 0) return null;
391
+ const y = E === a - 1;
392
+ if (E >= a && R) return 0;
393
+ if (y && !R) return 1;
394
+ if (!F && !y) return null;
395
+ const A = y ? E + 1 : E - 1, U = y ? p[A] - p[A - 1] : p[A + 1] - p[A], W = f / Math.abs(U);
396
+ return y ? 1 - W : W;
397
+ }
398
+ return {
399
+ isLastSnapPoint: k,
400
+ activeSnapPoint: w,
401
+ shouldFade: F,
402
+ getPercentageDragged: J,
403
+ setActiveSnapPoint: g,
404
+ activeSnapPointIndex: E,
405
+ onRelease: s,
406
+ onDrag: q,
407
+ snapPointsOffset: p
408
+ };
409
+ }
410
+ function Xe() {
411
+ const { direction: t, isOpen: n, shouldScaleBackground: e, setBackgroundColorOnScale: o, noBodyStyles: i } = at(), a = r.useRef(null), b = Oe(() => document.body.style.backgroundColor, []);
412
+ function c() {
413
+ return (window.innerWidth - Ct) / window.innerWidth;
414
+ }
415
+ r.useEffect(() => {
416
+ if (n && e) {
417
+ a.current && clearTimeout(a.current);
418
+ const h = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[vaul-drawer-wrapper]");
419
+ if (!h) return;
420
+ o && !i && Et(document.body, { background: "black" }), Et(h, {
421
+ transformOrigin: O(t) ? "top" : "left",
422
+ transitionProperty: "transform, border-radius",
423
+ transitionDuration: `${D.DURATION}s`,
424
+ transitionTimingFunction: `cubic-bezier(${D.EASE.join(",")})`
425
+ });
426
+ const x = Et(h, {
427
+ borderRadius: `${Jt}px`,
428
+ overflow: "hidden",
429
+ ...O(t) ? { transform: `scale(${c()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)` } : { transform: `scale(${c()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)` }
430
+ });
431
+ return () => {
432
+ x(), a.current = window.setTimeout(() => {
433
+ b ? document.body.style.background = b : document.body.style.removeProperty("background");
434
+ }, D.DURATION * 1e3);
435
+ };
436
+ }
437
+ }, [
438
+ n,
439
+ e,
440
+ b
441
+ ]);
442
+ }
443
+ var ct = null;
444
+ function Ke({ isOpen: t, modal: n, nested: e, hasBeenOpened: o, preventScrollRestoration: i, noBodyStyles: a }) {
445
+ const [b, c] = r.useState(() => typeof window < "u" ? window.location.href : ""), h = r.useRef(0), x = r.useCallback(() => {
446
+ if (Ft() && ct === null && t && !a) {
447
+ ct = {
448
+ position: document.body.style.position,
449
+ top: document.body.style.top,
450
+ left: document.body.style.left,
451
+ height: document.body.style.height,
452
+ right: "unset"
453
+ };
454
+ const { scrollX: g, innerHeight: m } = window;
455
+ document.body.style.setProperty("position", "fixed", "important"), Object.assign(document.body.style, {
456
+ top: `${-h.current}px`,
457
+ left: `${-g}px`,
458
+ right: "0px",
459
+ height: "auto"
460
+ }), window.setTimeout(() => window.requestAnimationFrame(() => {
461
+ const B = m - window.innerHeight;
462
+ B && h.current >= m && (document.body.style.top = `${-(h.current + B)}px`);
463
+ }), 300);
464
+ }
465
+ }, [t]), w = r.useCallback(() => {
466
+ if (Ft() && ct !== null && !a) {
467
+ const g = -parseInt(document.body.style.top, 10), m = -parseInt(document.body.style.left, 10);
468
+ Object.assign(document.body.style, ct), window.requestAnimationFrame(() => {
469
+ if (i && b !== window.location.href) {
470
+ c(window.location.href);
471
+ return;
472
+ }
473
+ window.scrollTo(m, g);
474
+ }), ct = null;
475
+ }
476
+ }, [b]);
477
+ return r.useEffect(() => {
478
+ function g() {
479
+ h.current = window.scrollY;
480
+ }
481
+ return g(), window.addEventListener("scroll", g), () => {
482
+ window.removeEventListener("scroll", g);
483
+ };
484
+ }, []), r.useEffect(() => {
485
+ if (n)
486
+ return () => {
487
+ typeof document > "u" || document.querySelector("[data-vaul-drawer]") || w();
488
+ };
489
+ }, [n, w]), r.useEffect(() => {
490
+ e || !o || (t ? (!window.matchMedia("(display-mode: standalone)").matches && x(), n || window.setTimeout(() => {
491
+ w();
492
+ }, 500)) : w());
493
+ }, [
494
+ t,
495
+ o,
496
+ b,
497
+ n,
498
+ e,
499
+ x,
500
+ w
501
+ ]), { restorePositionSetting: w };
502
+ }
503
+ function te({ open: t, onOpenChange: n, children: e, onDrag: o, onRelease: i, snapPoints: a, shouldScaleBackground: b = !1, setBackgroundColorOnScale: c = !0, closeThreshold: h = Ve, scrollLockTimeout: x = je, dismissible: w = !0, handleOnly: g = !1, fadeFromIndex: m = a && a.length - 1, activeSnapPoint: B, setActiveSnapPoint: k, fixed: E, modal: F = !0, onClose: p, nested: M, noBodyStyles: P = !1, direction: s = "bottom", defaultOpen: q = !1, disablePreventScroll: J = !0, snapToSequentialPoint: f = !1, preventScrollRestoration: R = !1, repositionInputs: y = !0, onAnimationEnd: A, container: U, autoFocus: W = !1 }) {
504
+ var u, z;
505
+ const [N = !1, j] = Zt({
506
+ defaultProp: q,
507
+ prop: t,
508
+ onChange: (l) => {
509
+ n?.(l), !l && !M && se(), setTimeout(() => {
510
+ A?.(l);
511
+ }, D.DURATION * 1e3), l && !F && typeof window < "u" && window.requestAnimationFrame(() => {
512
+ document.body.style.pointerEvents = "auto";
513
+ }), l || (document.body.style.pointerEvents = "auto");
514
+ }
515
+ }), [I, X] = r.useState(!1), [K, gt] = r.useState(!1), [ae, $t] = r.useState(!1), Z = r.useRef(null), dt = r.useRef(null), vt = r.useRef(null), bt = r.useRef(null), ot = r.useRef(null), it = r.useRef(!1), yt = r.useRef(null), Rt = r.useRef(0), tt = r.useRef(!1), At = r.useRef(!q), Pt = r.useRef(0), d = r.useRef(null), Mt = r.useRef(((u = d.current) == null ? void 0 : u.getBoundingClientRect().height) || 0), Nt = r.useRef(((z = d.current) == null ? void 0 : z.getBoundingClientRect().width) || 0), St = r.useRef(0), { activeSnapPoint: oe, activeSnapPointIndex: et, setActiveSnapPoint: It, onRelease: ie, snapPointsOffset: lt, onDrag: le, shouldFade: _t, getPercentageDragged: ue } = qe({
516
+ snapPoints: a,
517
+ activeSnapPointProp: B,
518
+ setActiveSnapPointProp: k,
519
+ drawerRef: d,
520
+ fadeFromIndex: m,
521
+ overlayRef: Z,
522
+ onSnapPointChange: r.useCallback((l) => {
523
+ a && l === lt.length - 1 && (dt.current = /* @__PURE__ */ new Date());
524
+ }, []),
525
+ direction: s,
526
+ container: U,
527
+ snapToSequentialPoint: f
528
+ });
529
+ He({ isDisabled: !N || K || !F || ae || !I || !y || !J });
530
+ const { restorePositionSetting: se } = Ke({
531
+ isOpen: N,
532
+ modal: F,
533
+ nested: M ?? !1,
534
+ hasBeenOpened: I,
535
+ preventScrollRestoration: R,
536
+ noBodyStyles: P
537
+ });
538
+ function ft() {
539
+ return (window.innerWidth - Ct) / window.innerWidth;
540
+ }
541
+ function ce(l) {
542
+ var S, T;
543
+ !w && !a || d.current && !d.current.contains(l.target) || (Mt.current = ((S = d.current) == null ? void 0 : S.getBoundingClientRect().height) || 0, Nt.current = ((T = d.current) == null ? void 0 : T.getBoundingClientRect().width) || 0, gt(!0), vt.current = /* @__PURE__ */ new Date(), Yt() && window.addEventListener("touchend", () => it.current = !1, { once: !0 }), l.target.setPointerCapture(l.pointerId), Rt.current = O(s) ? l.pageY : l.pageX);
544
+ }
545
+ function kt(l, S) {
546
+ var T;
547
+ let v = l;
548
+ const C = (T = window.getSelection()) == null ? void 0 : T.toString(), H = d.current ? wt(d.current, s) : null, _ = /* @__PURE__ */ new Date();
549
+ if (v.tagName === "SELECT" || v.hasAttribute("data-vaul-no-drag") || v.closest("[data-vaul-no-drag]")) return !1;
550
+ if (s === "right" || s === "left") return !0;
551
+ if (dt.current && _.getTime() - dt.current.getTime() < 500) return !1;
552
+ if (H !== null && (s === "bottom" ? H > 0 : H < 0))
553
+ return !0;
554
+ if (C && C.length > 0) return !1;
555
+ if (ot.current && _.getTime() - ot.current.getTime() < x && H === 0 || S)
556
+ return ot.current = _, !1;
557
+ for (; v; ) {
558
+ if (v.scrollHeight > v.clientHeight) {
559
+ if (v.scrollTop !== 0)
560
+ return ot.current = /* @__PURE__ */ new Date(), !1;
561
+ if (v.getAttribute("role") === "dialog") return !0;
562
+ }
563
+ v = v.parentNode;
564
+ }
565
+ return !0;
566
+ }
567
+ function de(l) {
568
+ if (d.current && K) {
569
+ const S = s === "bottom" || s === "right" ? 1 : -1, T = (Rt.current - (O(s) ? l.pageY : l.pageX)) * S, v = T > 0, C = a && !w && !v;
570
+ if (C && et === 0) return;
571
+ const H = Math.abs(T), _ = document.querySelector("[data-vaul-drawer-wrapper]");
572
+ let L = H / (s === "bottom" || s === "top" ? Mt.current : Nt.current);
573
+ const nt = ue(H, v);
574
+ if (nt !== null && (L = nt), C && L >= 1 || !it.current && !kt(l.target, v)) return;
575
+ if (d.current.classList.add(Dt), it.current = !0, $(d.current, { transition: "none" }), $(Z.current, { transition: "none" }), a && le({ draggedDistance: T }), v && !a) {
576
+ const V = ze(T), Q = Math.min(V * -1, 0) * S;
577
+ $(d.current, { transform: O(s) ? `translate3d(0, ${Q}px, 0)` : `translate3d(${Q}px, 0, 0)` });
578
+ return;
579
+ }
580
+ const mt = 1 - L;
581
+ if ((_t || m && et === m - 1) && (o?.(l, L), $(Z.current, {
582
+ opacity: `${mt}`,
583
+ transition: "none"
584
+ }, !0)), _ && Z.current && b) {
585
+ const V = Math.min(ft() + L * (1 - ft()), 1), Q = 8 - L * 8, Lt = Math.max(0, 14 - L * 14);
586
+ $(_, {
587
+ borderRadius: `${Q}px`,
588
+ transform: O(s) ? `scale(${V}) translate3d(0, ${Lt}px, 0)` : `scale(${V}) translate3d(${Lt}px, 0, 0)`,
589
+ transition: "none"
590
+ }, !0);
591
+ }
592
+ if (!a) {
593
+ const V = H * S;
594
+ $(d.current, { transform: O(s) ? `translate3d(0, ${V}px, 0)` : `translate3d(${V}px, 0, 0)` });
595
+ }
596
+ }
597
+ }
598
+ r.useEffect(() => {
599
+ window.requestAnimationFrame(() => {
600
+ At.current = !0;
601
+ });
602
+ }, []), r.useEffect(() => {
603
+ var l;
604
+ function S() {
605
+ if (!d.current || !y) return;
606
+ const T = document.activeElement;
607
+ if (xt(T) || tt.current) {
608
+ var v;
609
+ const C = ((v = window.visualViewport) == null ? void 0 : v.height) || 0, H = window.innerHeight;
610
+ let _ = H - C;
611
+ const L = d.current.getBoundingClientRect().height || 0, nt = L > H * 0.8;
612
+ St.current || (St.current = L);
613
+ const mt = d.current.getBoundingClientRect().top;
614
+ if (Math.abs(Pt.current - _) > 60 && (tt.current = !tt.current), a && a.length > 0 && lt && et) {
615
+ const V = lt[et] || 0;
616
+ _ += V;
617
+ }
618
+ if (Pt.current = _, L > C || tt.current) {
619
+ const V = d.current.getBoundingClientRect().height;
620
+ let Q = V;
621
+ V > C && (Q = C - (nt ? mt : Ct)), E ? d.current.style.height = `${V - Math.max(_, 0)}px` : d.current.style.height = `${Math.max(Q, C - mt)}px`;
622
+ } else Ae() || (d.current.style.height = `${St.current}px`);
623
+ a && a.length > 0 && !tt.current ? d.current.style.bottom = "0px" : d.current.style.bottom = `${Math.max(_, 0)}px`;
624
+ }
625
+ }
626
+ return (l = window.visualViewport) == null || l.addEventListener("resize", S), () => {
627
+ var T;
628
+ return (T = window.visualViewport) == null ? void 0 : T.removeEventListener("resize", S);
629
+ };
630
+ }, [
631
+ et,
632
+ a,
633
+ lt
634
+ ]);
635
+ function ut(l) {
636
+ fe(), p?.(), l || j(!1), setTimeout(() => {
637
+ a && It(a[0]);
638
+ }, D.DURATION * 1e3);
639
+ }
640
+ function Ht() {
641
+ if (!d.current) return;
642
+ const l = document.querySelector("[data-vaul-drawer-wrapper]"), S = wt(d.current, s);
643
+ $(d.current, {
644
+ transform: "translate3d(0, 0, 0)",
645
+ transition: `transform ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`
646
+ }), $(Z.current, {
647
+ transition: `opacity ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
648
+ opacity: "1"
649
+ }), b && S && S > 0 && N && $(l, {
650
+ borderRadius: `${Jt}px`,
651
+ overflow: "hidden",
652
+ ...O(s) ? {
653
+ transform: `scale(${ft()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
654
+ transformOrigin: "top"
655
+ } : {
656
+ transform: `scale(${ft()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
657
+ transformOrigin: "left"
658
+ },
659
+ transitionProperty: "transform, border-radius",
660
+ transitionDuration: `${D.DURATION}s`,
661
+ transitionTimingFunction: `cubic-bezier(${D.EASE.join(",")})`
662
+ }, !0);
663
+ }
664
+ function fe() {
665
+ !K || !d.current || (d.current.classList.remove(Dt), it.current = !1, gt(!1), bt.current = /* @__PURE__ */ new Date());
666
+ }
667
+ function me(l) {
668
+ if (!K || !d.current) return;
669
+ d.current.classList.remove(Dt), it.current = !1, gt(!1), bt.current = /* @__PURE__ */ new Date();
670
+ const S = wt(d.current, s);
671
+ if (!l || !kt(l.target, !1) || !S || Number.isNaN(S) || vt.current === null) return;
672
+ const T = bt.current.getTime() - vt.current.getTime(), v = Rt.current - (O(s) ? l.pageY : l.pageX), C = Math.abs(v) / T;
673
+ if (C > 0.05 && ($t(!0), setTimeout(() => {
674
+ $t(!1);
675
+ }, 200)), a) {
676
+ ie({
677
+ draggedDistance: v * (s === "bottom" || s === "right" ? 1 : -1),
678
+ closeDrawer: ut,
679
+ velocity: C,
680
+ dismissible: w
681
+ }), i?.(l, !0);
682
+ return;
683
+ }
684
+ if (s === "bottom" || s === "right" ? v > 0 : v < 0) {
685
+ Ht(), i?.(l, !0);
686
+ return;
687
+ }
688
+ if (C > Gt) {
689
+ ut(), i?.(l, !1);
690
+ return;
691
+ }
692
+ var H;
693
+ const _ = Math.min((H = d.current.getBoundingClientRect().height) != null ? H : 0, window.innerHeight);
694
+ var L;
695
+ const nt = Math.min((L = d.current.getBoundingClientRect().width) != null ? L : 0, window.innerWidth);
696
+ if (Math.abs(S) >= (s === "left" || s === "right" ? nt : _) * h) {
697
+ ut(), i?.(l, !1);
698
+ return;
699
+ }
700
+ i?.(l, !0), Ht();
701
+ }
702
+ r.useEffect(() => (N && ($(document.documentElement, { scrollBehavior: "auto" }), dt.current = /* @__PURE__ */ new Date()), () => {
703
+ We(document.documentElement, "scrollBehavior");
704
+ }), [N]);
705
+ function pe(l) {
706
+ const S = l ? (window.innerWidth - ht) / window.innerWidth : 1, T = l ? -16 : 0;
707
+ yt.current && window.clearTimeout(yt.current), $(d.current, {
708
+ transition: `transform ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
709
+ transform: O(s) ? `scale(${S}) translate3d(0, ${T}px, 0)` : `scale(${S}) translate3d(${T}px, 0, 0)`
710
+ }), !l && d.current && (yt.current = setTimeout(() => {
711
+ const v = wt(d.current, s);
712
+ $(d.current, {
713
+ transition: "none",
714
+ transform: O(s) ? `translate3d(0, ${v}px, 0)` : `translate3d(${v}px, 0, 0)`
715
+ });
716
+ }, 500));
717
+ }
718
+ function we(l, S) {
719
+ if (S < 0) return;
720
+ const T = (window.innerWidth - ht) / window.innerWidth, v = T + S * (1 - T), C = -16 + S * ht;
721
+ $(d.current, {
722
+ transform: O(s) ? `scale(${v}) translate3d(0, ${C}px, 0)` : `scale(${v}) translate3d(${C}px, 0, 0)`,
723
+ transition: "none"
724
+ });
725
+ }
726
+ function he(l, S) {
727
+ const T = O(s) ? window.innerHeight : window.innerWidth, v = S ? (T - ht) / T : 1, C = S ? -16 : 0;
728
+ S && $(d.current, {
729
+ transition: `transform ${D.DURATION}s cubic-bezier(${D.EASE.join(",")})`,
730
+ transform: O(s) ? `scale(${v}) translate3d(0, ${C}px, 0)` : `scale(${v}) translate3d(${C}px, 0, 0)`
731
+ });
732
+ }
733
+ return r.useEffect(() => {
734
+ F || window.requestAnimationFrame(() => {
735
+ document.body.style.pointerEvents = "auto";
736
+ });
737
+ }, [F]), /* @__PURE__ */ r.createElement(Re, {
738
+ defaultOpen: q,
739
+ onOpenChange: (l) => {
740
+ !w && !l || (l ? X(!0) : ut(!0), j(l));
741
+ },
742
+ open: N
743
+ }, /* @__PURE__ */ r.createElement(jt.Provider, { value: {
744
+ activeSnapPoint: oe,
745
+ snapPoints: a,
746
+ setActiveSnapPoint: It,
747
+ drawerRef: d,
748
+ overlayRef: Z,
749
+ onOpenChange: n,
750
+ onPress: ce,
751
+ onRelease: me,
752
+ onDrag: de,
753
+ dismissible: w,
754
+ shouldAnimate: At,
755
+ handleOnly: g,
756
+ isOpen: N,
757
+ isDragging: K,
758
+ shouldFade: _t,
759
+ closeDrawer: ut,
760
+ onNestedDrag: we,
761
+ onNestedOpenChange: pe,
762
+ onNestedRelease: he,
763
+ keyboardIsOpen: tt,
764
+ modal: F,
765
+ snapPointsOffset: lt,
766
+ activeSnapPointIndex: et,
767
+ direction: s,
768
+ shouldScaleBackground: b,
769
+ setBackgroundColorOnScale: c,
770
+ noBodyStyles: P,
771
+ container: U,
772
+ autoFocus: W
773
+ } }, e));
774
+ }
775
+ var ee = /* @__PURE__ */ r.forwardRef(function({ ...t }, n) {
776
+ const { overlayRef: e, snapPoints: o, onRelease: i, shouldFade: a, isOpen: b, modal: c, shouldAnimate: h } = at(), x = Xt(n, e), w = o && o.length > 0;
777
+ if (!c) return null;
778
+ const g = r.useCallback((m) => i(m), [i]);
779
+ return /* @__PURE__ */ r.createElement(be, {
780
+ onMouseUp: g,
781
+ ref: x,
782
+ "data-vaul-overlay": "",
783
+ "data-vaul-snap-points": b && w ? "true" : "false",
784
+ "data-vaul-snap-points-overlay": b && a ? "true" : "false",
785
+ "data-vaul-animate": h?.current ? "true" : "false",
786
+ ...t
787
+ });
788
+ });
789
+ ee.displayName = "Drawer.Overlay";
790
+ var ne = /* @__PURE__ */ r.forwardRef(function({ onPointerDownOutside: t, style: n, onOpenAutoFocus: e, ...o }, i) {
791
+ const { drawerRef: a, onPress: b, onRelease: c, onDrag: h, keyboardIsOpen: x, snapPointsOffset: w, activeSnapPointIndex: g, modal: m, isOpen: B, direction: k, snapPoints: E, container: F, handleOnly: p, shouldAnimate: M, autoFocus: P } = at(), [s, q] = r.useState(!1), J = Xt(i, a), f = r.useRef(null), R = r.useRef(null), y = r.useRef(!1), A = E && E.length > 0;
792
+ Xe();
793
+ const U = (u, z, N = 0) => {
794
+ if (y.current) return !0;
795
+ const j = Math.abs(u.y), I = Math.abs(u.x), X = I > j, K = ["bottom", "right"].includes(z) ? 1 : -1;
796
+ if (z === "left" || z === "right") {
797
+ if (!(u.x * K < 0) && I >= 0 && I <= N) return X;
798
+ } else if (!(u.y * K < 0) && j >= 0 && j <= N) return !X;
799
+ return y.current = !0, !0;
800
+ };
801
+ r.useEffect(() => {
802
+ A && window.requestAnimationFrame(() => {
803
+ q(!0);
804
+ });
805
+ }, []);
806
+ function W(u) {
807
+ f.current = null, y.current = !1, c(u);
808
+ }
809
+ return /* @__PURE__ */ r.createElement(ye, {
810
+ "data-vaul-drawer-direction": k,
811
+ "data-vaul-drawer": "",
812
+ "data-vaul-delayed-snap-points": s ? "true" : "false",
813
+ "data-vaul-snap-points": B && A ? "true" : "false",
814
+ "data-vaul-custom-container": F ? "true" : "false",
815
+ "data-vaul-animate": M?.current ? "true" : "false",
816
+ ...o,
817
+ ref: J,
818
+ style: w && w.length > 0 ? {
819
+ "--snap-point-height": `${w[g ?? 0]}px`,
820
+ ...n
821
+ } : n,
822
+ onPointerDown: (u) => {
823
+ p || (o.onPointerDown == null || o.onPointerDown.call(o, u), f.current = {
824
+ x: u.pageX,
825
+ y: u.pageY
826
+ }, b(u));
827
+ },
828
+ onOpenAutoFocus: (u) => {
829
+ e?.(u), P || u.preventDefault();
830
+ },
831
+ onPointerDownOutside: (u) => {
832
+ if (t?.(u), !m || u.defaultPrevented) {
833
+ u.preventDefault();
834
+ return;
835
+ }
836
+ x.current && (x.current = !1);
837
+ },
838
+ onFocusOutside: (u) => {
839
+ if (!m) {
840
+ u.preventDefault();
841
+ return;
842
+ }
843
+ },
844
+ onPointerMove: (u) => {
845
+ if (R.current = u, p || (o.onPointerMove == null || o.onPointerMove.call(o, u), !f.current)) return;
846
+ const z = u.pageY - f.current.y, N = u.pageX - f.current.x, j = u.pointerType === "touch" ? 10 : 2;
847
+ U({
848
+ x: N,
849
+ y: z
850
+ }, k, j) ? h(u) : (Math.abs(N) > j || Math.abs(z) > j) && (f.current = null);
851
+ },
852
+ onPointerUp: (u) => {
853
+ o.onPointerUp == null || o.onPointerUp.call(o, u), f.current = null, y.current = !1, c(u);
854
+ },
855
+ onPointerOut: (u) => {
856
+ o.onPointerOut == null || o.onPointerOut.call(o, u), W(R.current);
857
+ },
858
+ onContextMenu: (u) => {
859
+ o.onContextMenu == null || o.onContextMenu.call(o, u), R.current && W(R.current);
860
+ }
861
+ });
862
+ });
863
+ ne.displayName = "Drawer.Content";
864
+ var Ge = 250, Je = 120, re = /* @__PURE__ */ r.forwardRef(function({ preventCycle: t = !1, children: n, ...e }, o) {
865
+ const { closeDrawer: i, isDragging: a, snapPoints: b, activeSnapPoint: c, setActiveSnapPoint: h, dismissible: x, handleOnly: w, isOpen: g, onPress: m, onDrag: B } = at(), k = r.useRef(null), E = r.useRef(!1);
866
+ function F() {
867
+ if (E.current) {
868
+ P();
869
+ return;
870
+ }
871
+ window.setTimeout(() => {
872
+ p();
873
+ }, Je);
874
+ }
875
+ function p() {
876
+ if (a || t || E.current) {
877
+ P();
878
+ return;
879
+ }
880
+ if (P(), !b || b.length === 0) {
881
+ x || i();
882
+ return;
883
+ }
884
+ if (c === b[b.length - 1] && x) {
885
+ i();
886
+ return;
887
+ }
888
+ const s = b.findIndex((J) => J === c);
889
+ if (s === -1) return;
890
+ const q = b[s + 1];
891
+ h(q);
892
+ }
893
+ function M() {
894
+ k.current = window.setTimeout(() => {
895
+ E.current = !0;
896
+ }, Ge);
897
+ }
898
+ function P() {
899
+ k.current && window.clearTimeout(k.current), E.current = !1;
900
+ }
901
+ return /* @__PURE__ */ r.createElement("div", {
902
+ onClick: F,
903
+ onPointerCancel: P,
904
+ onPointerDown: (s) => {
905
+ w && m(s), M();
906
+ },
907
+ onPointerMove: (s) => {
908
+ w && B(s);
909
+ },
910
+ ref: o,
911
+ "data-vaul-drawer-visible": g ? "true" : "false",
912
+ "data-vaul-handle": "",
913
+ "aria-hidden": "true",
914
+ ...e
915
+ }, /* @__PURE__ */ r.createElement("span", {
916
+ "data-vaul-handle-hitarea": "",
917
+ "aria-hidden": "true"
918
+ }, n));
919
+ });
920
+ re.displayName = "Drawer.Handle";
921
+ function Qe({ onDrag: t, onOpenChange: n, open: e, ...o }) {
922
+ const { onNestedDrag: i, onNestedOpenChange: a, onNestedRelease: b } = at();
923
+ if (!i) throw new Error("Drawer.NestedRoot must be placed in another drawer");
924
+ return /* @__PURE__ */ r.createElement(te, {
925
+ nested: !0,
926
+ open: e,
927
+ onClose: () => {
928
+ a(!1);
929
+ },
930
+ onDrag: (c, h) => {
931
+ i(c, h), t?.(c, h);
932
+ },
933
+ onOpenChange: (c) => {
934
+ c && a(c), n?.(c);
935
+ },
936
+ onRelease: b,
937
+ ...o
938
+ });
939
+ }
940
+ function Ze(t) {
941
+ const n = at(), { container: e = n.container, ...o } = t;
942
+ return /* @__PURE__ */ r.createElement(ge, {
943
+ container: e,
944
+ ...o
945
+ });
946
+ }
947
+ var G = {
948
+ Root: te,
949
+ NestedRoot: Qe,
950
+ Content: ne,
951
+ Overlay: ee,
952
+ Trigger: ve,
953
+ Portal: Ze,
954
+ Handle: re,
955
+ Close: Ee,
956
+ Title: Te,
957
+ Description: Se
958
+ };
959
+ function ln({ ...t }) {
960
+ return /* @__PURE__ */ Y(G.Root, {
961
+ "data-slot": "drawer",
962
+ ...t
963
+ });
964
+ }
965
+ function un({ ...t }) {
966
+ return /* @__PURE__ */ Y(G.Trigger, {
967
+ "data-slot": "drawer-trigger",
968
+ ...t
969
+ });
970
+ }
971
+ function tn({ ...t }) {
972
+ return /* @__PURE__ */ Y(G.Portal, {
973
+ "data-slot": "drawer-portal",
974
+ ...t
975
+ });
976
+ }
977
+ function sn({ ...t }) {
978
+ return /* @__PURE__ */ Y(G.Close, {
979
+ "data-slot": "drawer-close",
980
+ ...t
981
+ });
982
+ }
983
+ function en({ className: t, ...n }) {
984
+ return /* @__PURE__ */ Y(G.Overlay, {
985
+ "data-slot": "drawer-overlay",
986
+ className: rt("fixed inset-0 z-50 bg-black/80 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", t),
987
+ ...n
988
+ });
989
+ }
990
+ function cn({ className: t, children: n, ...e }) {
991
+ return /* @__PURE__ */ Bt(tn, {
992
+ "data-slot": "drawer-portal",
993
+ children: [/* @__PURE__ */ Y(en, {}), /* @__PURE__ */ Bt(G.Content, {
994
+ "data-slot": "drawer-content",
995
+ className: rt("group/drawer-content fixed z-50 flex h-auto flex-col bg-transparent p-4 text-sm text-popover-foreground before:absolute before:inset-2 before:-z-10 before:rounded-4xl before:border before:border-border before:bg-popover data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:start-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:end-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm", t),
996
+ ...e,
997
+ children: [/* @__PURE__ */ Y("div", { className: "mx-auto mt-4 hidden h-1.5 w-[100px] shrink-0 rounded-full bg-surface-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block" }), n]
998
+ })]
999
+ });
1000
+ }
1001
+ function dn({ className: t, ...n }) {
1002
+ return /* @__PURE__ */ Y("div", {
1003
+ "data-slot": "drawer-header",
1004
+ className: rt("flex flex-col gap-0.5 p-4 group-data-[vaul-drawer-direction=bottom]/drawer-content:text-center group-data-[vaul-drawer-direction=top]/drawer-content:text-center md:gap-1.5 md:text-start", t),
1005
+ ...n
1006
+ });
1007
+ }
1008
+ function fn({ className: t, ...n }) {
1009
+ return /* @__PURE__ */ Y("div", {
1010
+ "data-slot": "drawer-footer",
1011
+ className: rt("mt-auto flex flex-col gap-2 p-4", t),
1012
+ ...n
1013
+ });
1014
+ }
1015
+ function mn({ className: t, ...n }) {
1016
+ return /* @__PURE__ */ Y(G.Title, {
1017
+ "data-slot": "drawer-title",
1018
+ className: rt("font-heading text-base font-medium text-foreground", t),
1019
+ ...n
1020
+ });
1021
+ }
1022
+ function pn({ className: t, ...n }) {
1023
+ return /* @__PURE__ */ Y(G.Description, {
1024
+ "data-slot": "drawer-description",
1025
+ className: rt("text-sm text-muted-foreground", t),
1026
+ ...n
1027
+ });
1028
+ }
1029
+ export {
1030
+ ln as Drawer,
1031
+ sn as DrawerClose,
1032
+ cn as DrawerContent,
1033
+ pn as DrawerDescription,
1034
+ fn as DrawerFooter,
1035
+ dn as DrawerHeader,
1036
+ en as DrawerOverlay,
1037
+ tn as DrawerPortal,
1038
+ mn as DrawerTitle,
1039
+ un as DrawerTrigger
1040
+ };
1041
+
1042
+ //# sourceMappingURL=drawer.js.map