@spear-ai/spectral 1.4.13 → 1.4.15

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