@spear-ai/spectral 1.4.12 → 1.4.14

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