@openfeed-ink/widget 0.1.3

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