@still-forest/canopy 0.41.1 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3099 +0,0 @@
1
- import { j as a } from "./jsx-runtime-B0GD0xBr.js";
2
- import { e as Q, J as ve, aa as dt, K as te, M as j, U as P, ab as V, G as Me, H as de, ac as yt, B as Ae, Q as Ct, ad as De, L as ue, ae as It, af as Rt, ag as kt, ah as or, b as Oe, c as Pe, ai as Et, aj as ar, ak as sr, al as re, am as ir, an as cr, ao as lr, ap as dr, aq as ur, ar as pr, as as fr, at as mr, au as hr, av as vr, aw as _t, R as gr, P as xr, O as br, w as Sr, ax as Re, ay as wr } from "./sidebar-5TOTH-eb.js";
3
- import * as c from "react";
4
- import { useState as ke, useEffect as jt, useRef as yr, useMemo as Cr, useId as Ir } from "react";
5
- import { F as pe, G as Rr } from "./Layout-CvVv48kM.js";
6
- import { T as Pt } from "./Heading-DjVutKs1.js";
7
- import { L as kr } from "./Loader-DW_x9PM7.js";
8
- import { c as B } from "./index-CRiPKpXj.js";
9
- import * as Nt from "react-dom";
10
- /**
11
- * @license lucide-react v0.544.0 - ISC
12
- *
13
- * This source code is licensed under the ISC license.
14
- * See the LICENSE file in the root directory of this source tree.
15
- */
16
- const Er = [
17
- ["path", { d: "M8 2v4", key: "1cmpym" }],
18
- ["path", { d: "M16 2v4", key: "4m81vk" }],
19
- ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
20
- ["path", { d: "M3 10h18", key: "8toen8" }]
21
- ], _r = Q("calendar", Er);
22
- /**
23
- * @license lucide-react v0.544.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */
28
- const jr = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], ut = Q("check", jr);
29
- /**
30
- * @license lucide-react v0.544.0 - ISC
31
- *
32
- * This source code is licensed under the ISC license.
33
- * See the LICENSE file in the root directory of this source tree.
34
- */
35
- const Pr = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], Nr = Q("chevron-up", Pr);
36
- /**
37
- * @license lucide-react v0.544.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */
42
- const Tr = [
43
- ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
44
- ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
45
- ], Mr = Q("chevrons-up-down", Tr);
46
- /**
47
- * @license lucide-react v0.544.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */
52
- const Ar = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]], Dr = Q("circle", Ar);
53
- /**
54
- * @license lucide-react v0.544.0 - ISC
55
- *
56
- * This source code is licensed under the ISC license.
57
- * See the LICENSE file in the root directory of this source tree.
58
- */
59
- const Or = [
60
- ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
61
- [
62
- "path",
63
- {
64
- d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
65
- key: "116196"
66
- }
67
- ],
68
- ["path", { d: "m9 14 2 2 4-4", key: "df797q" }]
69
- ], Lr = Q("clipboard-check", Or);
70
- /**
71
- * @license lucide-react v0.544.0 - ISC
72
- *
73
- * This source code is licensed under the ISC license.
74
- * See the LICENSE file in the root directory of this source tree.
75
- */
76
- const Br = [
77
- ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
78
- [
79
- "path",
80
- {
81
- d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
82
- key: "116196"
83
- }
84
- ]
85
- ], Fr = Q("clipboard", Br);
86
- /**
87
- * @license lucide-react v0.544.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */
92
- const $r = [
93
- [
94
- "path",
95
- {
96
- d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
97
- key: "ct8e1f"
98
- }
99
- ],
100
- ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
101
- [
102
- "path",
103
- {
104
- d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
105
- key: "13bj9a"
106
- }
107
- ],
108
- ["path", { d: "m2 2 20 20", key: "1ooewy" }]
109
- ], Vr = Q("eye-off", $r);
110
- /**
111
- * @license lucide-react v0.544.0 - ISC
112
- *
113
- * This source code is licensed under the ISC license.
114
- * See the LICENSE file in the root directory of this source tree.
115
- */
116
- const Kr = [
117
- [
118
- "path",
119
- {
120
- d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
121
- key: "1nclc0"
122
- }
123
- ],
124
- ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
125
- ], Hr = Q("eye", Kr);
126
- /**
127
- * @license lucide-react v0.544.0 - ISC
128
- *
129
- * This source code is licensed under the ISC license.
130
- * See the LICENSE file in the root directory of this source tree.
131
- */
132
- const Ur = [
133
- [
134
- "path",
135
- {
136
- d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
137
- key: "1c8476"
138
- }
139
- ],
140
- ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
141
- ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
142
- ], Gr = Q("save", Ur);
143
- /**
144
- * @license lucide-react v0.544.0 - ISC
145
- *
146
- * This source code is licensed under the ISC license.
147
- * See the LICENSE file in the root directory of this source tree.
148
- */
149
- const zr = [
150
- ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
151
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
152
- ], Wr = Q("search", zr);
153
- /**
154
- * @license lucide-react v0.544.0 - ISC
155
- *
156
- * This source code is licensed under the ISC license.
157
- * See the LICENSE file in the root directory of this source tree.
158
- */
159
- const qr = [
160
- [
161
- "path",
162
- {
163
- d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
164
- key: "1ffxy3"
165
- }
166
- ],
167
- ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
168
- ], qe = Q("send", qr);
169
- /**
170
- * @license lucide-react v0.544.0 - ISC
171
- *
172
- * This source code is licensed under the ISC license.
173
- * See the LICENSE file in the root directory of this source tree.
174
- */
175
- const Yr = [
176
- ["path", { d: "M10 11v6", key: "nco0om" }],
177
- ["path", { d: "M14 11v6", key: "outv1u" }],
178
- ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
179
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
180
- ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
181
- ], Xr = Q("trash-2", Yr);
182
- var Ye = "rovingFocusGroup.onEntryFocus", Zr = { bubbles: !1, cancelable: !0 }, Ee = "RovingFocusGroup", [Qe, Tt, Jr] = dt(Ee), [Qr, Mt] = ve(
183
- Ee,
184
- [Jr]
185
- ), [eo, to] = Qr(Ee), At = c.forwardRef(
186
- (e, n) => /* @__PURE__ */ a.jsx(Qe.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a.jsx(Qe.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ a.jsx(no, { ...e, ref: n }) }) })
187
- );
188
- At.displayName = Ee;
189
- var no = c.forwardRef((e, n) => {
190
- const {
191
- __scopeRovingFocusGroup: t,
192
- orientation: o,
193
- loop: r = !1,
194
- dir: i,
195
- currentTabStopId: s,
196
- defaultCurrentTabStopId: l,
197
- onCurrentTabStopIdChange: d,
198
- onEntryFocus: u,
199
- preventScrollOnEntryFocus: p = !1,
200
- ...f
201
- } = e, g = c.useRef(null), x = V(n, g), S = Me(i), [h, m] = de({
202
- prop: s,
203
- defaultProp: l ?? null,
204
- onChange: d,
205
- caller: Ee
206
- }), [b, w] = c.useState(!1), y = yt(u), R = Tt(t), A = c.useRef(!1), [N, _] = c.useState(0);
207
- return c.useEffect(() => {
208
- const L = g.current;
209
- if (L)
210
- return L.addEventListener(Ye, y), () => L.removeEventListener(Ye, y);
211
- }, [y]), /* @__PURE__ */ a.jsx(
212
- eo,
213
- {
214
- scope: t,
215
- orientation: o,
216
- dir: S,
217
- loop: r,
218
- currentTabStopId: h,
219
- onItemFocus: c.useCallback(
220
- (L) => m(L),
221
- [m]
222
- ),
223
- onItemShiftTab: c.useCallback(() => w(!0), []),
224
- onFocusableItemAdd: c.useCallback(
225
- () => _((L) => L + 1),
226
- []
227
- ),
228
- onFocusableItemRemove: c.useCallback(
229
- () => _((L) => L - 1),
230
- []
231
- ),
232
- children: /* @__PURE__ */ a.jsx(
233
- j.div,
234
- {
235
- tabIndex: b || N === 0 ? -1 : 0,
236
- "data-orientation": o,
237
- ...f,
238
- ref: x,
239
- style: { outline: "none", ...e.style },
240
- onMouseDown: P(e.onMouseDown, () => {
241
- A.current = !0;
242
- }),
243
- onFocus: P(e.onFocus, (L) => {
244
- const Z = !A.current;
245
- if (L.target === L.currentTarget && Z && !b) {
246
- const z = new CustomEvent(Ye, Zr);
247
- if (L.currentTarget.dispatchEvent(z), !z.defaultPrevented) {
248
- const D = R().filter((O) => O.focusable), K = D.find((O) => O.active), X = D.find((O) => O.id === h), U = [K, X, ...D].filter(
249
- Boolean
250
- ).map((O) => O.ref.current);
251
- Lt(U, p);
252
- }
253
- }
254
- A.current = !1;
255
- }),
256
- onBlur: P(e.onBlur, () => w(!1))
257
- }
258
- )
259
- }
260
- );
261
- }), Dt = "RovingFocusGroupItem", Ot = c.forwardRef(
262
- (e, n) => {
263
- const {
264
- __scopeRovingFocusGroup: t,
265
- focusable: o = !0,
266
- active: r = !1,
267
- tabStopId: i,
268
- children: s,
269
- ...l
270
- } = e, d = te(), u = i || d, p = to(Dt, t), f = p.currentTabStopId === u, g = Tt(t), { onFocusableItemAdd: x, onFocusableItemRemove: S, currentTabStopId: h } = p;
271
- return c.useEffect(() => {
272
- if (o)
273
- return x(), () => S();
274
- }, [o, x, S]), /* @__PURE__ */ a.jsx(
275
- Qe.ItemSlot,
276
- {
277
- scope: t,
278
- id: u,
279
- focusable: o,
280
- active: r,
281
- children: /* @__PURE__ */ a.jsx(
282
- j.span,
283
- {
284
- tabIndex: f ? 0 : -1,
285
- "data-orientation": p.orientation,
286
- ...l,
287
- ref: n,
288
- onMouseDown: P(e.onMouseDown, (m) => {
289
- o ? p.onItemFocus(u) : m.preventDefault();
290
- }),
291
- onFocus: P(e.onFocus, () => p.onItemFocus(u)),
292
- onKeyDown: P(e.onKeyDown, (m) => {
293
- if (m.key === "Tab" && m.shiftKey) {
294
- p.onItemShiftTab();
295
- return;
296
- }
297
- if (m.target !== m.currentTarget) return;
298
- const b = ao(m, p.orientation, p.dir);
299
- if (b !== void 0) {
300
- if (m.metaKey || m.ctrlKey || m.altKey || m.shiftKey) return;
301
- m.preventDefault();
302
- let y = g().filter((R) => R.focusable).map((R) => R.ref.current);
303
- if (b === "last") y.reverse();
304
- else if (b === "prev" || b === "next") {
305
- b === "prev" && y.reverse();
306
- const R = y.indexOf(m.currentTarget);
307
- y = p.loop ? so(y, R + 1) : y.slice(R + 1);
308
- }
309
- setTimeout(() => Lt(y));
310
- }
311
- }),
312
- children: typeof s == "function" ? s({ isCurrentTabStop: f, hasTabStop: h != null }) : s
313
- }
314
- )
315
- }
316
- );
317
- }
318
- );
319
- Ot.displayName = Dt;
320
- var ro = {
321
- ArrowLeft: "prev",
322
- ArrowUp: "prev",
323
- ArrowRight: "next",
324
- ArrowDown: "next",
325
- PageUp: "first",
326
- Home: "first",
327
- PageDown: "last",
328
- End: "last"
329
- };
330
- function oo(e, n) {
331
- return n !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
332
- }
333
- function ao(e, n, t) {
334
- const o = oo(e.key, t);
335
- if (!(n === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(n === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
336
- return ro[o];
337
- }
338
- function Lt(e, n = !1) {
339
- const t = document.activeElement;
340
- for (const o of e)
341
- if (o === t || (o.focus({ preventScroll: n }), document.activeElement !== t)) return;
342
- }
343
- function so(e, n) {
344
- return e.map((t, o) => e[(n + o) % e.length]);
345
- }
346
- var io = At, co = Ot;
347
- const _s = ({ disabled: e = !1, handleDelete: n, ...t }) => /* @__PURE__ */ a.jsx(
348
- Ae,
349
- {
350
- disabled: e,
351
- icon: /* @__PURE__ */ a.jsx(Xr, {}),
352
- onClick: n,
353
- variant: "outline",
354
- ...t,
355
- className: "border-destructive text-destructive hover:bg-destructive hover:text-white",
356
- children: "Delete"
357
- }
358
- ), gt = {
359
- default: { label: "Submit", submittingLabel: "Submitting", IconComponent: qe },
360
- submit: { label: "Submit", submittingLabel: "Submitting", IconComponent: qe },
361
- save: { label: "Save", submittingLabel: "Saving", IconComponent: Gr },
362
- send: { label: "Send", submittingLabel: "Sending", IconComponent: qe }
363
- }, js = ({
364
- submitting: e = !1,
365
- disabled: n = !1,
366
- submittingIcon: t,
367
- action: o = "default",
368
- label: r,
369
- submittingLabel: i,
370
- icon: s,
371
- noIcon: l = !1,
372
- ...d
373
- }) => {
374
- if (!gt[o])
375
- throw new Error(`Invalid action: ${o}`);
376
- const u = gt[o], p = r || u.label, f = i || u.submittingLabel, g = s || u.IconComponent, x = e ? /* @__PURE__ */ a.jsx(kr, { icon: t }) : /* @__PURE__ */ a.jsx(g, {});
377
- return /* @__PURE__ */ a.jsx(
378
- Ae,
379
- {
380
- disabled: n || e,
381
- icon: l ? void 0 : x,
382
- type: "submit",
383
- variant: "primary",
384
- ...d,
385
- children: e ? f : p
386
- }
387
- );
388
- };
389
- function _e(e) {
390
- const n = c.useRef({ value: e, previous: e });
391
- return c.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
392
- }
393
- var Le = "Checkbox", [lo, Ps] = ve(Le), [uo, pt] = lo(Le);
394
- function po(e) {
395
- const {
396
- __scopeCheckbox: n,
397
- checked: t,
398
- children: o,
399
- defaultChecked: r,
400
- disabled: i,
401
- form: s,
402
- name: l,
403
- onCheckedChange: d,
404
- required: u,
405
- value: p = "on",
406
- // @ts-expect-error
407
- internal_do_not_use_render: f
408
- } = e, [g, x] = de({
409
- prop: t,
410
- defaultProp: r ?? !1,
411
- onChange: d,
412
- caller: Le
413
- }), [S, h] = c.useState(null), [m, b] = c.useState(null), w = c.useRef(!1), y = S ? !!s || !!S.closest("form") : (
414
- // We set this to true by default so that events bubble to forms without JS (SSR)
415
- !0
416
- ), R = {
417
- checked: g,
418
- disabled: i,
419
- setChecked: x,
420
- control: S,
421
- setControl: h,
422
- name: l,
423
- form: s,
424
- value: p,
425
- hasConsumerStoppedPropagationRef: w,
426
- required: u,
427
- defaultChecked: ne(r) ? !1 : r,
428
- isFormControl: y,
429
- bubbleInput: m,
430
- setBubbleInput: b
431
- };
432
- return /* @__PURE__ */ a.jsx(
433
- uo,
434
- {
435
- scope: n,
436
- ...R,
437
- children: fo(f) ? f(R) : o
438
- }
439
- );
440
- }
441
- var Bt = "CheckboxTrigger", Ft = c.forwardRef(
442
- ({ __scopeCheckbox: e, onKeyDown: n, onClick: t, ...o }, r) => {
443
- const {
444
- control: i,
445
- value: s,
446
- disabled: l,
447
- checked: d,
448
- required: u,
449
- setControl: p,
450
- setChecked: f,
451
- hasConsumerStoppedPropagationRef: g,
452
- isFormControl: x,
453
- bubbleInput: S
454
- } = pt(Bt, e), h = V(r, p), m = c.useRef(d);
455
- return c.useEffect(() => {
456
- const b = i?.form;
457
- if (b) {
458
- const w = () => f(m.current);
459
- return b.addEventListener("reset", w), () => b.removeEventListener("reset", w);
460
- }
461
- }, [i, f]), /* @__PURE__ */ a.jsx(
462
- j.button,
463
- {
464
- type: "button",
465
- role: "checkbox",
466
- "aria-checked": ne(d) ? "mixed" : d,
467
- "aria-required": u,
468
- "data-state": Gt(d),
469
- "data-disabled": l ? "" : void 0,
470
- disabled: l,
471
- value: s,
472
- ...o,
473
- ref: h,
474
- onKeyDown: P(n, (b) => {
475
- b.key === "Enter" && b.preventDefault();
476
- }),
477
- onClick: P(t, (b) => {
478
- f((w) => ne(w) ? !0 : !w), S && x && (g.current = b.isPropagationStopped(), g.current || b.stopPropagation());
479
- })
480
- }
481
- );
482
- }
483
- );
484
- Ft.displayName = Bt;
485
- var $t = c.forwardRef(
486
- (e, n) => {
487
- const {
488
- __scopeCheckbox: t,
489
- name: o,
490
- checked: r,
491
- defaultChecked: i,
492
- required: s,
493
- disabled: l,
494
- value: d,
495
- onCheckedChange: u,
496
- form: p,
497
- ...f
498
- } = e;
499
- return /* @__PURE__ */ a.jsx(
500
- po,
501
- {
502
- __scopeCheckbox: t,
503
- checked: r,
504
- defaultChecked: i,
505
- disabled: l,
506
- required: s,
507
- onCheckedChange: u,
508
- name: o,
509
- form: p,
510
- value: d,
511
- internal_do_not_use_render: ({ isFormControl: g }) => /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
512
- /* @__PURE__ */ a.jsx(
513
- Ft,
514
- {
515
- ...f,
516
- ref: n,
517
- __scopeCheckbox: t
518
- }
519
- ),
520
- g && /* @__PURE__ */ a.jsx(
521
- Ut,
522
- {
523
- __scopeCheckbox: t
524
- }
525
- )
526
- ] })
527
- }
528
- );
529
- }
530
- );
531
- $t.displayName = Le;
532
- var Vt = "CheckboxIndicator", Kt = c.forwardRef(
533
- (e, n) => {
534
- const { __scopeCheckbox: t, forceMount: o, ...r } = e, i = pt(Vt, t);
535
- return /* @__PURE__ */ a.jsx(
536
- Ct,
537
- {
538
- present: o || ne(i.checked) || i.checked === !0,
539
- children: /* @__PURE__ */ a.jsx(
540
- j.span,
541
- {
542
- "data-state": Gt(i.checked),
543
- "data-disabled": i.disabled ? "" : void 0,
544
- ...r,
545
- ref: n,
546
- style: { pointerEvents: "none", ...e.style }
547
- }
548
- )
549
- }
550
- );
551
- }
552
- );
553
- Kt.displayName = Vt;
554
- var Ht = "CheckboxBubbleInput", Ut = c.forwardRef(
555
- ({ __scopeCheckbox: e, ...n }, t) => {
556
- const {
557
- control: o,
558
- hasConsumerStoppedPropagationRef: r,
559
- checked: i,
560
- defaultChecked: s,
561
- required: l,
562
- disabled: d,
563
- name: u,
564
- value: p,
565
- form: f,
566
- bubbleInput: g,
567
- setBubbleInput: x
568
- } = pt(Ht, e), S = V(t, x), h = _e(i), m = De(o);
569
- c.useEffect(() => {
570
- const w = g;
571
- if (!w) return;
572
- const y = window.HTMLInputElement.prototype, A = Object.getOwnPropertyDescriptor(
573
- y,
574
- "checked"
575
- ).set, N = !r.current;
576
- if (h !== i && A) {
577
- const _ = new Event("click", { bubbles: N });
578
- w.indeterminate = ne(i), A.call(w, ne(i) ? !1 : i), w.dispatchEvent(_);
579
- }
580
- }, [g, h, i, r]);
581
- const b = c.useRef(ne(i) ? !1 : i);
582
- return /* @__PURE__ */ a.jsx(
583
- j.input,
584
- {
585
- type: "checkbox",
586
- "aria-hidden": !0,
587
- defaultChecked: s ?? b.current,
588
- required: l,
589
- disabled: d,
590
- name: u,
591
- value: p,
592
- form: f,
593
- ...n,
594
- tabIndex: -1,
595
- ref: S,
596
- style: {
597
- ...n.style,
598
- ...m,
599
- position: "absolute",
600
- pointerEvents: "none",
601
- opacity: 0,
602
- margin: 0,
603
- // We transform because the input is absolutely positioned but we have
604
- // rendered it **after** the button. This pulls it back to sit on top
605
- // of the button.
606
- transform: "translateX(-100%)"
607
- }
608
- }
609
- );
610
- }
611
- );
612
- Ut.displayName = Ht;
613
- function fo(e) {
614
- return typeof e == "function";
615
- }
616
- function ne(e) {
617
- return e === "indeterminate";
618
- }
619
- function Gt(e) {
620
- return ne(e) ? "indeterminate" : e ? "checked" : "unchecked";
621
- }
622
- function mo({ className: e, ...n }) {
623
- return /* @__PURE__ */ a.jsx(
624
- $t,
625
- {
626
- className: B(
627
- "peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
628
- e
629
- ),
630
- "data-slot": "checkbox",
631
- ...n,
632
- children: /* @__PURE__ */ a.jsx(
633
- Kt,
634
- {
635
- className: "flex items-center justify-center text-current transition-none",
636
- "data-slot": "checkbox-indicator",
637
- children: /* @__PURE__ */ a.jsx(ut, { className: "size-3.5" })
638
- }
639
- )
640
- }
641
- );
642
- }
643
- const Ns = ({ label: e, name: n, value: t, checked: o, onCheckedChange: r }) => {
644
- const [i, s] = ke(o);
645
- jt(() => {
646
- s(o);
647
- }, [o]);
648
- let l = n;
649
- const d = t || n;
650
- t && (l += `[${t}]`);
651
- const u = (p) => {
652
- s(p), r?.(p);
653
- };
654
- return /* @__PURE__ */ a.jsxs(pe, { align: "center", gap: "2", children: [
655
- /* @__PURE__ */ a.jsx(
656
- mo,
657
- {
658
- checked: i,
659
- id: l,
660
- name: n,
661
- onCheckedChange: u,
662
- value: d
663
- }
664
- ),
665
- /* @__PURE__ */ a.jsx(ue, { className: "cursor-pointer", htmlFor: l, children: e })
666
- ] });
667
- }, Ts = ({ content: e, className: n, size: t = "md", ...o }) => {
668
- const [r, i] = ke(!1), s = yr(null);
669
- jt(() => () => {
670
- s.current && clearTimeout(s.current);
671
- }, []);
672
- const l = () => {
673
- const d = navigator.clipboard?.writeText;
674
- d && (i(!0), d.call(navigator.clipboard, e).then(() => {
675
- s.current && clearTimeout(s.current), s.current = setTimeout(() => {
676
- i(!1), s.current = null;
677
- }, 2e3);
678
- }).catch(() => {
679
- i(!1);
680
- }));
681
- };
682
- return /* @__PURE__ */ a.jsx(
683
- Ae,
684
- {
685
- className: B(
686
- {
687
- "w-[88px]": t === "xs",
688
- "w-[96px]": t === "sm",
689
- "w-[100px]": t === "md",
690
- "w-[125px]": t === "lg",
691
- "w-[144px]": t === "xl"
692
- },
693
- "justify-start",
694
- n
695
- ),
696
- disabled: r,
697
- icon: r ? /* @__PURE__ */ a.jsx(Lr, {}) : /* @__PURE__ */ a.jsx(Fr, {}),
698
- label: r ? "Copied" : "Copy",
699
- onClick: l,
700
- size: t,
701
- ...o
702
- }
703
- );
704
- }, Ms = ({ onDateSelection: e, initialValue: n, className: t, size: o = "default", error: r }) => {
705
- const [i, s] = ke(n), l = (d) => {
706
- s(d), d && e(d);
707
- };
708
- return /* @__PURE__ */ a.jsxs(pe, { direction: "col", gap: "2", children: [
709
- /* @__PURE__ */ a.jsxs(It, { children: [
710
- /* @__PURE__ */ a.jsx(Rt, { asChild: !0, children: /* @__PURE__ */ a.jsxs(
711
- Ae,
712
- {
713
- className: B("w-[280px] justify-start text-left font-normal", !i && "text-muted-foreground", t),
714
- size: o,
715
- variant: "outline",
716
- children: [
717
- /* @__PURE__ */ a.jsx(_r, { className: "mr-2 h-4 w-4" }),
718
- i ? i.toISOString().split("T")[0] : /* @__PURE__ */ a.jsx("span", { children: "Select a date" })
719
- ]
720
- }
721
- ) }),
722
- /* @__PURE__ */ a.jsx(kt, { className: "w-auto p-0", children: /* @__PURE__ */ a.jsx(or, { autoFocus: !0, mode: "single", onSelect: l, selected: i }) })
723
- ] }),
724
- r && /* @__PURE__ */ a.jsx(Oe, { message: r })
725
- ] });
726
- }, ho = ({
727
- label: e,
728
- labelFor: n,
729
- className: t = "",
730
- labelClassName: o = "",
731
- children: r
732
- }) => /* @__PURE__ */ a.jsxs(pe, { direction: "col", gap: "2", children: [
733
- e && /* @__PURE__ */ a.jsx(ue, { className: o, htmlFor: n, children: e }),
734
- /* @__PURE__ */ a.jsx(pe, { className: `rounded-md border border-input bg-card p-2 shadow-xs ${t}`, gapY: "1", children: r })
735
- ] }), As = ({
736
- name: e,
737
- size: n = "md",
738
- label: t,
739
- labelOrientation: o = "top",
740
- note: r,
741
- error: i,
742
- ...s
743
- }) => {
744
- const [l, d] = ke(!1), u = () => {
745
- d(!l);
746
- };
747
- return /* @__PURE__ */ a.jsxs(pe, { className: "w-full", direction: o === "left" ? "row" : "col", gap: "2", children: [
748
- t && /* @__PURE__ */ a.jsx(ue, { className: o === "left" ? "text-nowrap" : "", htmlFor: e, size: n, children: t }),
749
- /* @__PURE__ */ a.jsxs(Pe, { children: [
750
- /* @__PURE__ */ a.jsx(Pe.Input, { type: l ? "text" : "password", ...s, name: e, size: n }),
751
- /* @__PURE__ */ a.jsx(Pe.Addon, { right: !0, children: /* @__PURE__ */ a.jsx(
752
- Pe.Button,
753
- {
754
- "aria-label": l ? "Hide password" : "Show password",
755
- asIcon: !0,
756
- onClick: u,
757
- size: "xs",
758
- variant: "ghost",
759
- children: l ? /* @__PURE__ */ a.jsx(Hr, {}) : /* @__PURE__ */ a.jsx(Vr, {})
760
- }
761
- ) })
762
- ] }),
763
- r && /* @__PURE__ */ a.jsx(Pt, { size: "sm", variant: "muted", children: r }),
764
- i && /* @__PURE__ */ a.jsx(Oe, { message: i })
765
- ] });
766
- };
767
- var ft = "Radio", [vo, zt] = ve(ft), [go, xo] = vo(ft), Wt = c.forwardRef(
768
- (e, n) => {
769
- const {
770
- __scopeRadio: t,
771
- name: o,
772
- checked: r = !1,
773
- required: i,
774
- disabled: s,
775
- value: l = "on",
776
- onCheck: d,
777
- form: u,
778
- ...p
779
- } = e, [f, g] = c.useState(null), x = V(n, (m) => g(m)), S = c.useRef(!1), h = f ? u || !!f.closest("form") : !0;
780
- return /* @__PURE__ */ a.jsxs(go, { scope: t, checked: r, disabled: s, children: [
781
- /* @__PURE__ */ a.jsx(
782
- j.button,
783
- {
784
- type: "button",
785
- role: "radio",
786
- "aria-checked": r,
787
- "data-state": Zt(r),
788
- "data-disabled": s ? "" : void 0,
789
- disabled: s,
790
- value: l,
791
- ...p,
792
- ref: x,
793
- onClick: P(e.onClick, (m) => {
794
- r || d?.(), h && (S.current = m.isPropagationStopped(), S.current || m.stopPropagation());
795
- })
796
- }
797
- ),
798
- h && /* @__PURE__ */ a.jsx(
799
- Xt,
800
- {
801
- control: f,
802
- bubbles: !S.current,
803
- name: o,
804
- value: l,
805
- checked: r,
806
- required: i,
807
- disabled: s,
808
- form: u,
809
- style: { transform: "translateX(-100%)" }
810
- }
811
- )
812
- ] });
813
- }
814
- );
815
- Wt.displayName = ft;
816
- var qt = "RadioIndicator", Yt = c.forwardRef(
817
- (e, n) => {
818
- const { __scopeRadio: t, forceMount: o, ...r } = e, i = xo(qt, t);
819
- return /* @__PURE__ */ a.jsx(Ct, { present: o || i.checked, children: /* @__PURE__ */ a.jsx(
820
- j.span,
821
- {
822
- "data-state": Zt(i.checked),
823
- "data-disabled": i.disabled ? "" : void 0,
824
- ...r,
825
- ref: n
826
- }
827
- ) });
828
- }
829
- );
830
- Yt.displayName = qt;
831
- var bo = "RadioBubbleInput", Xt = c.forwardRef(
832
- ({
833
- __scopeRadio: e,
834
- control: n,
835
- checked: t,
836
- bubbles: o = !0,
837
- ...r
838
- }, i) => {
839
- const s = c.useRef(null), l = V(s, i), d = _e(t), u = De(n);
840
- return c.useEffect(() => {
841
- const p = s.current;
842
- if (!p) return;
843
- const f = window.HTMLInputElement.prototype, x = Object.getOwnPropertyDescriptor(
844
- f,
845
- "checked"
846
- ).set;
847
- if (d !== t && x) {
848
- const S = new Event("click", { bubbles: o });
849
- x.call(p, t), p.dispatchEvent(S);
850
- }
851
- }, [d, t, o]), /* @__PURE__ */ a.jsx(
852
- j.input,
853
- {
854
- type: "radio",
855
- "aria-hidden": !0,
856
- defaultChecked: t,
857
- ...r,
858
- tabIndex: -1,
859
- ref: l,
860
- style: {
861
- ...r.style,
862
- ...u,
863
- position: "absolute",
864
- pointerEvents: "none",
865
- opacity: 0,
866
- margin: 0
867
- }
868
- }
869
- );
870
- }
871
- );
872
- Xt.displayName = bo;
873
- function Zt(e) {
874
- return e ? "checked" : "unchecked";
875
- }
876
- var So = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], Be = "RadioGroup", [wo, Ds] = ve(Be, [
877
- Mt,
878
- zt
879
- ]), Jt = Mt(), Qt = zt(), [yo, Co] = wo(Be), en = c.forwardRef(
880
- (e, n) => {
881
- const {
882
- __scopeRadioGroup: t,
883
- name: o,
884
- defaultValue: r,
885
- value: i,
886
- required: s = !1,
887
- disabled: l = !1,
888
- orientation: d,
889
- dir: u,
890
- loop: p = !0,
891
- onValueChange: f,
892
- ...g
893
- } = e, x = Jt(t), S = Me(u), [h, m] = de({
894
- prop: i,
895
- defaultProp: r ?? null,
896
- onChange: f,
897
- caller: Be
898
- });
899
- return /* @__PURE__ */ a.jsx(
900
- yo,
901
- {
902
- scope: t,
903
- name: o,
904
- required: s,
905
- disabled: l,
906
- value: h,
907
- onValueChange: m,
908
- children: /* @__PURE__ */ a.jsx(
909
- io,
910
- {
911
- asChild: !0,
912
- ...x,
913
- orientation: d,
914
- dir: S,
915
- loop: p,
916
- children: /* @__PURE__ */ a.jsx(
917
- j.div,
918
- {
919
- role: "radiogroup",
920
- "aria-required": s,
921
- "aria-orientation": d,
922
- "data-disabled": l ? "" : void 0,
923
- dir: S,
924
- ...g,
925
- ref: n
926
- }
927
- )
928
- }
929
- )
930
- }
931
- );
932
- }
933
- );
934
- en.displayName = Be;
935
- var tn = "RadioGroupItem", nn = c.forwardRef(
936
- (e, n) => {
937
- const { __scopeRadioGroup: t, disabled: o, ...r } = e, i = Co(tn, t), s = i.disabled || o, l = Jt(t), d = Qt(t), u = c.useRef(null), p = V(n, u), f = i.value === r.value, g = c.useRef(!1);
938
- return c.useEffect(() => {
939
- const x = (h) => {
940
- So.includes(h.key) && (g.current = !0);
941
- }, S = () => g.current = !1;
942
- return document.addEventListener("keydown", x), document.addEventListener("keyup", S), () => {
943
- document.removeEventListener("keydown", x), document.removeEventListener("keyup", S);
944
- };
945
- }, []), /* @__PURE__ */ a.jsx(
946
- co,
947
- {
948
- asChild: !0,
949
- ...l,
950
- focusable: !s,
951
- active: f,
952
- children: /* @__PURE__ */ a.jsx(
953
- Wt,
954
- {
955
- disabled: s,
956
- required: i.required,
957
- checked: f,
958
- ...d,
959
- ...r,
960
- name: i.name,
961
- ref: p,
962
- onCheck: () => i.onValueChange(r.value),
963
- onKeyDown: P((x) => {
964
- x.key === "Enter" && x.preventDefault();
965
- }),
966
- onFocus: P(r.onFocus, () => {
967
- g.current && u.current?.click();
968
- })
969
- }
970
- )
971
- }
972
- );
973
- }
974
- );
975
- nn.displayName = tn;
976
- var Io = "RadioGroupIndicator", rn = c.forwardRef(
977
- (e, n) => {
978
- const { __scopeRadioGroup: t, ...o } = e, r = Qt(t);
979
- return /* @__PURE__ */ a.jsx(Yt, { ...r, ...o, ref: n });
980
- }
981
- );
982
- rn.displayName = Io;
983
- var Ro = en, ko = nn, Eo = rn;
984
- function _o({ className: e, ...n }) {
985
- return /* @__PURE__ */ a.jsx(Ro, { className: B("grid gap-3", e), "data-slot": "radio-group", ...n });
986
- }
987
- function jo({ className: e, ...n }) {
988
- return /* @__PURE__ */ a.jsx(
989
- ko,
990
- {
991
- className: B(
992
- "border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
993
- e
994
- ),
995
- "data-slot": "radio-group-item",
996
- ...n,
997
- children: /* @__PURE__ */ a.jsx(
998
- Eo,
999
- {
1000
- className: "relative flex items-center justify-center",
1001
- "data-slot": "radio-group-indicator",
1002
- children: /* @__PURE__ */ a.jsx(Dr, { className: "fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" })
1003
- }
1004
- )
1005
- }
1006
- );
1007
- }
1008
- const Os = ({ label: e, name: n, options: t, value: o, onChange: r, error: i }) => /* @__PURE__ */ a.jsxs(ho, { className: "flex flex-col gap-4 px-2 py-1", label: e, labelFor: n, children: [
1009
- /* @__PURE__ */ a.jsx(_o, { className: "w-full", name: n, onValueChange: r, value: o, children: /* @__PURE__ */ a.jsx(Rr, { cols: "2", children: t.map((s, l) => /* @__PURE__ */ a.jsxs(pe, { align: "center", gap: "2", justify: "start", children: [
1010
- /* @__PURE__ */ a.jsx(jo, { id: s.value, value: s.value }),
1011
- /* @__PURE__ */ a.jsx(ue, { htmlFor: s.value, children: s.label })
1012
- ] }, l)) }) }),
1013
- i && /* @__PURE__ */ a.jsx(Oe, { message: i })
1014
- ] });
1015
- function Ne(e, [n, t]) {
1016
- return Math.min(t, Math.max(n, e));
1017
- }
1018
- var Po = [" ", "Enter", "ArrowUp", "ArrowDown"], No = [" ", "Enter"], fe = "Select", [Fe, $e, To] = dt(fe), [Se, Ls] = ve(fe, [
1019
- To,
1020
- Et
1021
- ]), Ve = Et(), [Mo, ae] = Se(fe), [Ao, Do] = Se(fe), on = (e) => {
1022
- const {
1023
- __scopeSelect: n,
1024
- children: t,
1025
- open: o,
1026
- defaultOpen: r,
1027
- onOpenChange: i,
1028
- value: s,
1029
- defaultValue: l,
1030
- onValueChange: d,
1031
- dir: u,
1032
- name: p,
1033
- autoComplete: f,
1034
- disabled: g,
1035
- required: x,
1036
- form: S
1037
- } = e, h = Ve(n), [m, b] = c.useState(null), [w, y] = c.useState(null), [R, A] = c.useState(!1), N = Me(u), [_, L] = de({
1038
- prop: o,
1039
- defaultProp: r ?? !1,
1040
- onChange: i,
1041
- caller: fe
1042
- }), [Z, z] = de({
1043
- prop: s,
1044
- defaultProp: l,
1045
- onChange: d,
1046
- caller: fe
1047
- }), D = c.useRef(null), K = m ? S || !!m.closest("form") : !0, [X, W] = c.useState(/* @__PURE__ */ new Set()), U = Array.from(X).map((O) => O.props.value).join(";");
1048
- return /* @__PURE__ */ a.jsx(ar, { ...h, children: /* @__PURE__ */ a.jsxs(
1049
- Mo,
1050
- {
1051
- required: x,
1052
- scope: n,
1053
- trigger: m,
1054
- onTriggerChange: b,
1055
- valueNode: w,
1056
- onValueNodeChange: y,
1057
- valueNodeHasChildren: R,
1058
- onValueNodeHasChildrenChange: A,
1059
- contentId: te(),
1060
- value: Z,
1061
- onValueChange: z,
1062
- open: _,
1063
- onOpenChange: L,
1064
- dir: N,
1065
- triggerPointerDownPosRef: D,
1066
- disabled: g,
1067
- children: [
1068
- /* @__PURE__ */ a.jsx(Fe.Provider, { scope: n, children: /* @__PURE__ */ a.jsx(
1069
- Ao,
1070
- {
1071
- scope: e.__scopeSelect,
1072
- onNativeOptionAdd: c.useCallback((O) => {
1073
- W((G) => new Set(G).add(O));
1074
- }, []),
1075
- onNativeOptionRemove: c.useCallback((O) => {
1076
- W((G) => {
1077
- const q = new Set(G);
1078
- return q.delete(O), q;
1079
- });
1080
- }, []),
1081
- children: t
1082
- }
1083
- ) }),
1084
- K ? /* @__PURE__ */ a.jsxs(
1085
- En,
1086
- {
1087
- "aria-hidden": !0,
1088
- required: x,
1089
- tabIndex: -1,
1090
- name: p,
1091
- autoComplete: f,
1092
- value: Z,
1093
- onChange: (O) => z(O.target.value),
1094
- disabled: g,
1095
- form: S,
1096
- children: [
1097
- Z === void 0 ? /* @__PURE__ */ a.jsx("option", { value: "" }) : null,
1098
- Array.from(X)
1099
- ]
1100
- },
1101
- U
1102
- ) : null
1103
- ]
1104
- }
1105
- ) });
1106
- };
1107
- on.displayName = fe;
1108
- var an = "SelectTrigger", sn = c.forwardRef(
1109
- (e, n) => {
1110
- const { __scopeSelect: t, disabled: o = !1, ...r } = e, i = Ve(t), s = ae(an, t), l = s.disabled || o, d = V(n, s.onTriggerChange), u = $e(t), p = c.useRef("touch"), [f, g, x] = jn((h) => {
1111
- const m = u().filter((y) => !y.disabled), b = m.find((y) => y.value === s.value), w = Pn(m, h, b);
1112
- w !== void 0 && s.onValueChange(w.value);
1113
- }), S = (h) => {
1114
- l || (s.onOpenChange(!0), x()), h && (s.triggerPointerDownPosRef.current = {
1115
- x: Math.round(h.pageX),
1116
- y: Math.round(h.pageY)
1117
- });
1118
- };
1119
- return /* @__PURE__ */ a.jsx(sr, { asChild: !0, ...i, children: /* @__PURE__ */ a.jsx(
1120
- j.button,
1121
- {
1122
- type: "button",
1123
- role: "combobox",
1124
- "aria-controls": s.contentId,
1125
- "aria-expanded": s.open,
1126
- "aria-required": s.required,
1127
- "aria-autocomplete": "none",
1128
- dir: s.dir,
1129
- "data-state": s.open ? "open" : "closed",
1130
- disabled: l,
1131
- "data-disabled": l ? "" : void 0,
1132
- "data-placeholder": _n(s.value) ? "" : void 0,
1133
- ...r,
1134
- ref: d,
1135
- onClick: P(r.onClick, (h) => {
1136
- h.currentTarget.focus(), p.current !== "mouse" && S(h);
1137
- }),
1138
- onPointerDown: P(r.onPointerDown, (h) => {
1139
- p.current = h.pointerType;
1140
- const m = h.target;
1141
- m.hasPointerCapture(h.pointerId) && m.releasePointerCapture(h.pointerId), h.button === 0 && h.ctrlKey === !1 && h.pointerType === "mouse" && (S(h), h.preventDefault());
1142
- }),
1143
- onKeyDown: P(r.onKeyDown, (h) => {
1144
- const m = f.current !== "";
1145
- !(h.ctrlKey || h.altKey || h.metaKey) && h.key.length === 1 && g(h.key), !(m && h.key === " ") && Po.includes(h.key) && (S(), h.preventDefault());
1146
- })
1147
- }
1148
- ) });
1149
- }
1150
- );
1151
- sn.displayName = an;
1152
- var cn = "SelectValue", ln = c.forwardRef(
1153
- (e, n) => {
1154
- const { __scopeSelect: t, className: o, style: r, children: i, placeholder: s = "", ...l } = e, d = ae(cn, t), { onValueNodeHasChildrenChange: u } = d, p = i !== void 0, f = V(n, d.onValueNodeChange);
1155
- return re(() => {
1156
- u(p);
1157
- }, [u, p]), /* @__PURE__ */ a.jsx(
1158
- j.span,
1159
- {
1160
- ...l,
1161
- ref: f,
1162
- style: { pointerEvents: "none" },
1163
- children: _n(d.value) ? /* @__PURE__ */ a.jsx(a.Fragment, { children: s }) : i
1164
- }
1165
- );
1166
- }
1167
- );
1168
- ln.displayName = cn;
1169
- var Oo = "SelectIcon", dn = c.forwardRef(
1170
- (e, n) => {
1171
- const { __scopeSelect: t, children: o, ...r } = e;
1172
- return /* @__PURE__ */ a.jsx(j.span, { "aria-hidden": !0, ...r, ref: n, children: o || "▼" });
1173
- }
1174
- );
1175
- dn.displayName = Oo;
1176
- var Lo = "SelectPortal", un = (e) => /* @__PURE__ */ a.jsx(ir, { asChild: !0, ...e });
1177
- un.displayName = Lo;
1178
- var me = "SelectContent", pn = c.forwardRef(
1179
- (e, n) => {
1180
- const t = ae(me, e.__scopeSelect), [o, r] = c.useState();
1181
- if (re(() => {
1182
- r(new DocumentFragment());
1183
- }, []), !t.open) {
1184
- const i = o;
1185
- return i ? Nt.createPortal(
1186
- /* @__PURE__ */ a.jsx(fn, { scope: e.__scopeSelect, children: /* @__PURE__ */ a.jsx(Fe.Slot, { scope: e.__scopeSelect, children: /* @__PURE__ */ a.jsx("div", { children: e.children }) }) }),
1187
- i
1188
- ) : null;
1189
- }
1190
- return /* @__PURE__ */ a.jsx(mn, { ...e, ref: n });
1191
- }
1192
- );
1193
- pn.displayName = me;
1194
- var ee = 10, [fn, se] = Se(me), Bo = "SelectContentImpl", Fo = pr("SelectContent.RemoveScroll"), mn = c.forwardRef(
1195
- (e, n) => {
1196
- const {
1197
- __scopeSelect: t,
1198
- position: o = "item-aligned",
1199
- onCloseAutoFocus: r,
1200
- onEscapeKeyDown: i,
1201
- onPointerDownOutside: s,
1202
- //
1203
- // PopperContent props
1204
- side: l,
1205
- sideOffset: d,
1206
- align: u,
1207
- alignOffset: p,
1208
- arrowPadding: f,
1209
- collisionBoundary: g,
1210
- collisionPadding: x,
1211
- sticky: S,
1212
- hideWhenDetached: h,
1213
- avoidCollisions: m,
1214
- //
1215
- ...b
1216
- } = e, w = ae(me, t), [y, R] = c.useState(null), [A, N] = c.useState(null), _ = V(n, (C) => R(C)), [L, Z] = c.useState(null), [z, D] = c.useState(
1217
- null
1218
- ), K = $e(t), [X, W] = c.useState(!1), U = c.useRef(!1);
1219
- c.useEffect(() => {
1220
- if (y) return lr(y);
1221
- }, [y]), dr();
1222
- const O = c.useCallback(
1223
- (C) => {
1224
- const [M, ...F] = K().map((Y) => Y.ref.current), [$] = F.slice(-1), H = document.activeElement;
1225
- for (const Y of C)
1226
- if (Y === H || (Y?.scrollIntoView({ block: "nearest" }), Y === M && A && (A.scrollTop = 0), Y === $ && A && (A.scrollTop = A.scrollHeight), Y?.focus(), document.activeElement !== H)) return;
1227
- },
1228
- [K, A]
1229
- ), G = c.useCallback(
1230
- () => O([L, y]),
1231
- [O, L, y]
1232
- );
1233
- c.useEffect(() => {
1234
- X && G();
1235
- }, [X, G]);
1236
- const { onOpenChange: q, triggerPointerDownPosRef: J } = w;
1237
- c.useEffect(() => {
1238
- if (y) {
1239
- let C = { x: 0, y: 0 };
1240
- const M = ($) => {
1241
- C = {
1242
- x: Math.abs(Math.round($.pageX) - (J.current?.x ?? 0)),
1243
- y: Math.abs(Math.round($.pageY) - (J.current?.y ?? 0))
1244
- };
1245
- }, F = ($) => {
1246
- C.x <= 10 && C.y <= 10 ? $.preventDefault() : y.contains($.target) || q(!1), document.removeEventListener("pointermove", M), J.current = null;
1247
- };
1248
- return J.current !== null && (document.addEventListener("pointermove", M), document.addEventListener("pointerup", F, { capture: !0, once: !0 })), () => {
1249
- document.removeEventListener("pointermove", M), document.removeEventListener("pointerup", F, { capture: !0 });
1250
- };
1251
- }
1252
- }, [y, q, J]), c.useEffect(() => {
1253
- const C = () => q(!1);
1254
- return window.addEventListener("blur", C), window.addEventListener("resize", C), () => {
1255
- window.removeEventListener("blur", C), window.removeEventListener("resize", C);
1256
- };
1257
- }, [q]);
1258
- const [ge, ie] = jn((C) => {
1259
- const M = K().filter((H) => !H.disabled), F = M.find((H) => H.ref.current === document.activeElement), $ = Pn(M, C, F);
1260
- $ && setTimeout(() => $.ref.current.focus());
1261
- }), v = c.useCallback(
1262
- (C, M, F) => {
1263
- const $ = !U.current && !F;
1264
- (w.value !== void 0 && w.value === M || $) && (Z(C), $ && (U.current = !0));
1265
- },
1266
- [w.value]
1267
- ), k = c.useCallback(() => y?.focus(), [y]), E = c.useCallback(
1268
- (C, M, F) => {
1269
- const $ = !U.current && !F;
1270
- (w.value !== void 0 && w.value === M || $) && D(C);
1271
- },
1272
- [w.value]
1273
- ), I = o === "popper" ? et : hn, T = I === et ? {
1274
- side: l,
1275
- sideOffset: d,
1276
- align: u,
1277
- alignOffset: p,
1278
- arrowPadding: f,
1279
- collisionBoundary: g,
1280
- collisionPadding: x,
1281
- sticky: S,
1282
- hideWhenDetached: h,
1283
- avoidCollisions: m
1284
- } : {};
1285
- return /* @__PURE__ */ a.jsx(
1286
- fn,
1287
- {
1288
- scope: t,
1289
- content: y,
1290
- viewport: A,
1291
- onViewportChange: N,
1292
- itemRefCallback: v,
1293
- selectedItem: L,
1294
- onItemLeave: k,
1295
- itemTextRefCallback: E,
1296
- focusSelectedItem: G,
1297
- selectedItemText: z,
1298
- position: o,
1299
- isPositioned: X,
1300
- searchRef: ge,
1301
- children: /* @__PURE__ */ a.jsx(ur, { as: Fo, allowPinchZoom: !0, children: /* @__PURE__ */ a.jsx(
1302
- fr,
1303
- {
1304
- asChild: !0,
1305
- trapped: w.open,
1306
- onMountAutoFocus: (C) => {
1307
- C.preventDefault();
1308
- },
1309
- onUnmountAutoFocus: P(r, (C) => {
1310
- w.trigger?.focus({ preventScroll: !0 }), C.preventDefault();
1311
- }),
1312
- children: /* @__PURE__ */ a.jsx(
1313
- mr,
1314
- {
1315
- asChild: !0,
1316
- disableOutsidePointerEvents: !0,
1317
- onEscapeKeyDown: i,
1318
- onPointerDownOutside: s,
1319
- onFocusOutside: (C) => C.preventDefault(),
1320
- onDismiss: () => w.onOpenChange(!1),
1321
- children: /* @__PURE__ */ a.jsx(
1322
- I,
1323
- {
1324
- role: "listbox",
1325
- id: w.contentId,
1326
- "data-state": w.open ? "open" : "closed",
1327
- dir: w.dir,
1328
- onContextMenu: (C) => C.preventDefault(),
1329
- ...b,
1330
- ...T,
1331
- onPlaced: () => W(!0),
1332
- ref: _,
1333
- style: {
1334
- // flex layout so we can place the scroll buttons properly
1335
- display: "flex",
1336
- flexDirection: "column",
1337
- // reset the outline by default as the content MAY get focused
1338
- outline: "none",
1339
- ...b.style
1340
- },
1341
- onKeyDown: P(b.onKeyDown, (C) => {
1342
- const M = C.ctrlKey || C.altKey || C.metaKey;
1343
- if (C.key === "Tab" && C.preventDefault(), !M && C.key.length === 1 && ie(C.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(C.key)) {
1344
- let $ = K().filter((H) => !H.disabled).map((H) => H.ref.current);
1345
- if (["ArrowUp", "End"].includes(C.key) && ($ = $.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(C.key)) {
1346
- const H = C.target, Y = $.indexOf(H);
1347
- $ = $.slice(Y + 1);
1348
- }
1349
- setTimeout(() => O($)), C.preventDefault();
1350
- }
1351
- })
1352
- }
1353
- )
1354
- }
1355
- )
1356
- }
1357
- ) })
1358
- }
1359
- );
1360
- }
1361
- );
1362
- mn.displayName = Bo;
1363
- var $o = "SelectItemAlignedPosition", hn = c.forwardRef((e, n) => {
1364
- const { __scopeSelect: t, onPlaced: o, ...r } = e, i = ae(me, t), s = se(me, t), [l, d] = c.useState(null), [u, p] = c.useState(null), f = V(n, (_) => p(_)), g = $e(t), x = c.useRef(!1), S = c.useRef(!0), { viewport: h, selectedItem: m, selectedItemText: b, focusSelectedItem: w } = s, y = c.useCallback(() => {
1365
- if (i.trigger && i.valueNode && l && u && h && m && b) {
1366
- const _ = i.trigger.getBoundingClientRect(), L = u.getBoundingClientRect(), Z = i.valueNode.getBoundingClientRect(), z = b.getBoundingClientRect();
1367
- if (i.dir !== "rtl") {
1368
- const H = z.left - L.left, Y = Z.left - H, ce = _.left - Y, le = _.width + ce, Ge = Math.max(le, L.width), ze = window.innerWidth - ee, We = Ne(Y, [
1369
- ee,
1370
- // Prevents the content from going off the starting edge of the
1371
- // viewport. It may still go off the ending edge, but this can be
1372
- // controlled by the user since they may want to manage overflow in a
1373
- // specific way.
1374
- // https://github.com/radix-ui/primitives/issues/2049
1375
- Math.max(ee, ze - Ge)
1376
- ]);
1377
- l.style.minWidth = le + "px", l.style.left = We + "px";
1378
- } else {
1379
- const H = L.right - z.right, Y = window.innerWidth - Z.right - H, ce = window.innerWidth - _.right - Y, le = _.width + ce, Ge = Math.max(le, L.width), ze = window.innerWidth - ee, We = Ne(Y, [
1380
- ee,
1381
- Math.max(ee, ze - Ge)
1382
- ]);
1383
- l.style.minWidth = le + "px", l.style.right = We + "px";
1384
- }
1385
- const D = g(), K = window.innerHeight - ee * 2, X = h.scrollHeight, W = window.getComputedStyle(u), U = parseInt(W.borderTopWidth, 10), O = parseInt(W.paddingTop, 10), G = parseInt(W.borderBottomWidth, 10), q = parseInt(W.paddingBottom, 10), J = U + O + X + q + G, ge = Math.min(m.offsetHeight * 5, J), ie = window.getComputedStyle(h), v = parseInt(ie.paddingTop, 10), k = parseInt(ie.paddingBottom, 10), E = _.top + _.height / 2 - ee, I = K - E, T = m.offsetHeight / 2, C = m.offsetTop + T, M = U + O + C, F = J - M;
1386
- if (M <= E) {
1387
- const H = D.length > 0 && m === D[D.length - 1].ref.current;
1388
- l.style.bottom = "0px";
1389
- const Y = u.clientHeight - h.offsetTop - h.offsetHeight, ce = Math.max(
1390
- I,
1391
- T + // viewport might have padding bottom, include it to avoid a scrollable viewport
1392
- (H ? k : 0) + Y + G
1393
- ), le = M + ce;
1394
- l.style.height = le + "px";
1395
- } else {
1396
- const H = D.length > 0 && m === D[0].ref.current;
1397
- l.style.top = "0px";
1398
- const ce = Math.max(
1399
- E,
1400
- U + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
1401
- (H ? v : 0) + T
1402
- ) + F;
1403
- l.style.height = ce + "px", h.scrollTop = M - E + h.offsetTop;
1404
- }
1405
- l.style.margin = `${ee}px 0`, l.style.minHeight = ge + "px", l.style.maxHeight = K + "px", o?.(), requestAnimationFrame(() => x.current = !0);
1406
- }
1407
- }, [
1408
- g,
1409
- i.trigger,
1410
- i.valueNode,
1411
- l,
1412
- u,
1413
- h,
1414
- m,
1415
- b,
1416
- i.dir,
1417
- o
1418
- ]);
1419
- re(() => y(), [y]);
1420
- const [R, A] = c.useState();
1421
- re(() => {
1422
- u && A(window.getComputedStyle(u).zIndex);
1423
- }, [u]);
1424
- const N = c.useCallback(
1425
- (_) => {
1426
- _ && S.current === !0 && (y(), w?.(), S.current = !1);
1427
- },
1428
- [y, w]
1429
- );
1430
- return /* @__PURE__ */ a.jsx(
1431
- Ko,
1432
- {
1433
- scope: t,
1434
- contentWrapper: l,
1435
- shouldExpandOnScrollRef: x,
1436
- onScrollButtonChange: N,
1437
- children: /* @__PURE__ */ a.jsx(
1438
- "div",
1439
- {
1440
- ref: d,
1441
- style: {
1442
- display: "flex",
1443
- flexDirection: "column",
1444
- position: "fixed",
1445
- zIndex: R
1446
- },
1447
- children: /* @__PURE__ */ a.jsx(
1448
- j.div,
1449
- {
1450
- ...r,
1451
- ref: f,
1452
- style: {
1453
- // When we get the height of the content, it includes borders. If we were to set
1454
- // the height without having `boxSizing: 'border-box'` it would be too big.
1455
- boxSizing: "border-box",
1456
- // We need to ensure the content doesn't get taller than the wrapper
1457
- maxHeight: "100%",
1458
- ...r.style
1459
- }
1460
- }
1461
- )
1462
- }
1463
- )
1464
- }
1465
- );
1466
- });
1467
- hn.displayName = $o;
1468
- var Vo = "SelectPopperPosition", et = c.forwardRef((e, n) => {
1469
- const {
1470
- __scopeSelect: t,
1471
- align: o = "start",
1472
- collisionPadding: r = ee,
1473
- ...i
1474
- } = e, s = Ve(t);
1475
- return /* @__PURE__ */ a.jsx(
1476
- hr,
1477
- {
1478
- ...s,
1479
- ...i,
1480
- ref: n,
1481
- align: o,
1482
- collisionPadding: r,
1483
- style: {
1484
- // Ensure border-box for floating-ui calculations
1485
- boxSizing: "border-box",
1486
- ...i.style,
1487
- "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
1488
- "--radix-select-content-available-width": "var(--radix-popper-available-width)",
1489
- "--radix-select-content-available-height": "var(--radix-popper-available-height)",
1490
- "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
1491
- "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
1492
- }
1493
- }
1494
- );
1495
- });
1496
- et.displayName = Vo;
1497
- var [Ko, mt] = Se(me, {}), tt = "SelectViewport", vn = c.forwardRef(
1498
- (e, n) => {
1499
- const { __scopeSelect: t, nonce: o, ...r } = e, i = se(tt, t), s = mt(tt, t), l = V(n, i.onViewportChange), d = c.useRef(0);
1500
- return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
1501
- /* @__PURE__ */ a.jsx(
1502
- "style",
1503
- {
1504
- dangerouslySetInnerHTML: {
1505
- __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
1506
- },
1507
- nonce: o
1508
- }
1509
- ),
1510
- /* @__PURE__ */ a.jsx(Fe.Slot, { scope: t, children: /* @__PURE__ */ a.jsx(
1511
- j.div,
1512
- {
1513
- "data-radix-select-viewport": "",
1514
- role: "presentation",
1515
- ...r,
1516
- ref: l,
1517
- style: {
1518
- // we use position: 'relative' here on the `viewport` so that when we call
1519
- // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
1520
- // (independent of the scrollUpButton).
1521
- position: "relative",
1522
- flex: 1,
1523
- // Viewport should only be scrollable in the vertical direction.
1524
- // This won't work in vertical writing modes, so we'll need to
1525
- // revisit this if/when that is supported
1526
- // https://developer.chrome.com/blog/vertical-form-controls
1527
- overflow: "hidden auto",
1528
- ...r.style
1529
- },
1530
- onScroll: P(r.onScroll, (u) => {
1531
- const p = u.currentTarget, { contentWrapper: f, shouldExpandOnScrollRef: g } = s;
1532
- if (g?.current && f) {
1533
- const x = Math.abs(d.current - p.scrollTop);
1534
- if (x > 0) {
1535
- const S = window.innerHeight - ee * 2, h = parseFloat(f.style.minHeight), m = parseFloat(f.style.height), b = Math.max(h, m);
1536
- if (b < S) {
1537
- const w = b + x, y = Math.min(S, w), R = w - y;
1538
- f.style.height = y + "px", f.style.bottom === "0px" && (p.scrollTop = R > 0 ? R : 0, f.style.justifyContent = "flex-end");
1539
- }
1540
- }
1541
- }
1542
- d.current = p.scrollTop;
1543
- })
1544
- }
1545
- ) })
1546
- ] });
1547
- }
1548
- );
1549
- vn.displayName = tt;
1550
- var gn = "SelectGroup", [Ho, Uo] = Se(gn), Go = c.forwardRef(
1551
- (e, n) => {
1552
- const { __scopeSelect: t, ...o } = e, r = te();
1553
- return /* @__PURE__ */ a.jsx(Ho, { scope: t, id: r, children: /* @__PURE__ */ a.jsx(j.div, { role: "group", "aria-labelledby": r, ...o, ref: n }) });
1554
- }
1555
- );
1556
- Go.displayName = gn;
1557
- var xn = "SelectLabel", zo = c.forwardRef(
1558
- (e, n) => {
1559
- const { __scopeSelect: t, ...o } = e, r = Uo(xn, t);
1560
- return /* @__PURE__ */ a.jsx(j.div, { id: r.id, ...o, ref: n });
1561
- }
1562
- );
1563
- zo.displayName = xn;
1564
- var Te = "SelectItem", [Wo, bn] = Se(Te), Sn = c.forwardRef(
1565
- (e, n) => {
1566
- const {
1567
- __scopeSelect: t,
1568
- value: o,
1569
- disabled: r = !1,
1570
- textValue: i,
1571
- ...s
1572
- } = e, l = ae(Te, t), d = se(Te, t), u = l.value === o, [p, f] = c.useState(i ?? ""), [g, x] = c.useState(!1), S = V(
1573
- n,
1574
- (w) => d.itemRefCallback?.(w, o, r)
1575
- ), h = te(), m = c.useRef("touch"), b = () => {
1576
- r || (l.onValueChange(o), l.onOpenChange(!1));
1577
- };
1578
- if (o === "")
1579
- throw new Error(
1580
- "A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
1581
- );
1582
- return /* @__PURE__ */ a.jsx(
1583
- Wo,
1584
- {
1585
- scope: t,
1586
- value: o,
1587
- disabled: r,
1588
- textId: h,
1589
- isSelected: u,
1590
- onItemTextChange: c.useCallback((w) => {
1591
- f((y) => y || (w?.textContent ?? "").trim());
1592
- }, []),
1593
- children: /* @__PURE__ */ a.jsx(
1594
- Fe.ItemSlot,
1595
- {
1596
- scope: t,
1597
- value: o,
1598
- disabled: r,
1599
- textValue: p,
1600
- children: /* @__PURE__ */ a.jsx(
1601
- j.div,
1602
- {
1603
- role: "option",
1604
- "aria-labelledby": h,
1605
- "data-highlighted": g ? "" : void 0,
1606
- "aria-selected": u && g,
1607
- "data-state": u ? "checked" : "unchecked",
1608
- "aria-disabled": r || void 0,
1609
- "data-disabled": r ? "" : void 0,
1610
- tabIndex: r ? void 0 : -1,
1611
- ...s,
1612
- ref: S,
1613
- onFocus: P(s.onFocus, () => x(!0)),
1614
- onBlur: P(s.onBlur, () => x(!1)),
1615
- onClick: P(s.onClick, () => {
1616
- m.current !== "mouse" && b();
1617
- }),
1618
- onPointerUp: P(s.onPointerUp, () => {
1619
- m.current === "mouse" && b();
1620
- }),
1621
- onPointerDown: P(s.onPointerDown, (w) => {
1622
- m.current = w.pointerType;
1623
- }),
1624
- onPointerMove: P(s.onPointerMove, (w) => {
1625
- m.current = w.pointerType, r ? d.onItemLeave?.() : m.current === "mouse" && w.currentTarget.focus({ preventScroll: !0 });
1626
- }),
1627
- onPointerLeave: P(s.onPointerLeave, (w) => {
1628
- w.currentTarget === document.activeElement && d.onItemLeave?.();
1629
- }),
1630
- onKeyDown: P(s.onKeyDown, (w) => {
1631
- d.searchRef?.current !== "" && w.key === " " || (No.includes(w.key) && b(), w.key === " " && w.preventDefault());
1632
- })
1633
- }
1634
- )
1635
- }
1636
- )
1637
- }
1638
- );
1639
- }
1640
- );
1641
- Sn.displayName = Te;
1642
- var Ie = "SelectItemText", wn = c.forwardRef(
1643
- (e, n) => {
1644
- const { __scopeSelect: t, className: o, style: r, ...i } = e, s = ae(Ie, t), l = se(Ie, t), d = bn(Ie, t), u = Do(Ie, t), [p, f] = c.useState(null), g = V(
1645
- n,
1646
- (b) => f(b),
1647
- d.onItemTextChange,
1648
- (b) => l.itemTextRefCallback?.(b, d.value, d.disabled)
1649
- ), x = p?.textContent, S = c.useMemo(
1650
- () => /* @__PURE__ */ a.jsx("option", { value: d.value, disabled: d.disabled, children: x }, d.value),
1651
- [d.disabled, d.value, x]
1652
- ), { onNativeOptionAdd: h, onNativeOptionRemove: m } = u;
1653
- return re(() => (h(S), () => m(S)), [h, m, S]), /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
1654
- /* @__PURE__ */ a.jsx(j.span, { id: d.textId, ...i, ref: g }),
1655
- d.isSelected && s.valueNode && !s.valueNodeHasChildren ? Nt.createPortal(i.children, s.valueNode) : null
1656
- ] });
1657
- }
1658
- );
1659
- wn.displayName = Ie;
1660
- var yn = "SelectItemIndicator", Cn = c.forwardRef(
1661
- (e, n) => {
1662
- const { __scopeSelect: t, ...o } = e;
1663
- return bn(yn, t).isSelected ? /* @__PURE__ */ a.jsx(j.span, { "aria-hidden": !0, ...o, ref: n }) : null;
1664
- }
1665
- );
1666
- Cn.displayName = yn;
1667
- var nt = "SelectScrollUpButton", In = c.forwardRef((e, n) => {
1668
- const t = se(nt, e.__scopeSelect), o = mt(nt, e.__scopeSelect), [r, i] = c.useState(!1), s = V(n, o.onScrollButtonChange);
1669
- return re(() => {
1670
- if (t.viewport && t.isPositioned) {
1671
- let l = function() {
1672
- const u = d.scrollTop > 0;
1673
- i(u);
1674
- };
1675
- const d = t.viewport;
1676
- return l(), d.addEventListener("scroll", l), () => d.removeEventListener("scroll", l);
1677
- }
1678
- }, [t.viewport, t.isPositioned]), r ? /* @__PURE__ */ a.jsx(
1679
- kn,
1680
- {
1681
- ...e,
1682
- ref: s,
1683
- onAutoScroll: () => {
1684
- const { viewport: l, selectedItem: d } = t;
1685
- l && d && (l.scrollTop = l.scrollTop - d.offsetHeight);
1686
- }
1687
- }
1688
- ) : null;
1689
- });
1690
- In.displayName = nt;
1691
- var rt = "SelectScrollDownButton", Rn = c.forwardRef((e, n) => {
1692
- const t = se(rt, e.__scopeSelect), o = mt(rt, e.__scopeSelect), [r, i] = c.useState(!1), s = V(n, o.onScrollButtonChange);
1693
- return re(() => {
1694
- if (t.viewport && t.isPositioned) {
1695
- let l = function() {
1696
- const u = d.scrollHeight - d.clientHeight, p = Math.ceil(d.scrollTop) < u;
1697
- i(p);
1698
- };
1699
- const d = t.viewport;
1700
- return l(), d.addEventListener("scroll", l), () => d.removeEventListener("scroll", l);
1701
- }
1702
- }, [t.viewport, t.isPositioned]), r ? /* @__PURE__ */ a.jsx(
1703
- kn,
1704
- {
1705
- ...e,
1706
- ref: s,
1707
- onAutoScroll: () => {
1708
- const { viewport: l, selectedItem: d } = t;
1709
- l && d && (l.scrollTop = l.scrollTop + d.offsetHeight);
1710
- }
1711
- }
1712
- ) : null;
1713
- });
1714
- Rn.displayName = rt;
1715
- var kn = c.forwardRef((e, n) => {
1716
- const { __scopeSelect: t, onAutoScroll: o, ...r } = e, i = se("SelectScrollButton", t), s = c.useRef(null), l = $e(t), d = c.useCallback(() => {
1717
- s.current !== null && (window.clearInterval(s.current), s.current = null);
1718
- }, []);
1719
- return c.useEffect(() => () => d(), [d]), re(() => {
1720
- l().find((p) => p.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
1721
- }, [l]), /* @__PURE__ */ a.jsx(
1722
- j.div,
1723
- {
1724
- "aria-hidden": !0,
1725
- ...r,
1726
- ref: n,
1727
- style: { flexShrink: 0, ...r.style },
1728
- onPointerDown: P(r.onPointerDown, () => {
1729
- s.current === null && (s.current = window.setInterval(o, 50));
1730
- }),
1731
- onPointerMove: P(r.onPointerMove, () => {
1732
- i.onItemLeave?.(), s.current === null && (s.current = window.setInterval(o, 50));
1733
- }),
1734
- onPointerLeave: P(r.onPointerLeave, () => {
1735
- d();
1736
- })
1737
- }
1738
- );
1739
- }), qo = "SelectSeparator", Yo = c.forwardRef(
1740
- (e, n) => {
1741
- const { __scopeSelect: t, ...o } = e;
1742
- return /* @__PURE__ */ a.jsx(j.div, { "aria-hidden": !0, ...o, ref: n });
1743
- }
1744
- );
1745
- Yo.displayName = qo;
1746
- var ot = "SelectArrow", Xo = c.forwardRef(
1747
- (e, n) => {
1748
- const { __scopeSelect: t, ...o } = e, r = Ve(t), i = ae(ot, t), s = se(ot, t);
1749
- return i.open && s.position === "popper" ? /* @__PURE__ */ a.jsx(vr, { ...r, ...o, ref: n }) : null;
1750
- }
1751
- );
1752
- Xo.displayName = ot;
1753
- var Zo = "SelectBubbleInput", En = c.forwardRef(
1754
- ({ __scopeSelect: e, value: n, ...t }, o) => {
1755
- const r = c.useRef(null), i = V(o, r), s = _e(n);
1756
- return c.useEffect(() => {
1757
- const l = r.current;
1758
- if (!l) return;
1759
- const d = window.HTMLSelectElement.prototype, p = Object.getOwnPropertyDescriptor(
1760
- d,
1761
- "value"
1762
- ).set;
1763
- if (s !== n && p) {
1764
- const f = new Event("change", { bubbles: !0 });
1765
- p.call(l, n), l.dispatchEvent(f);
1766
- }
1767
- }, [s, n]), /* @__PURE__ */ a.jsx(
1768
- j.select,
1769
- {
1770
- ...t,
1771
- style: { ...cr, ...t.style },
1772
- ref: i,
1773
- defaultValue: n
1774
- }
1775
- );
1776
- }
1777
- );
1778
- En.displayName = Zo;
1779
- function _n(e) {
1780
- return e === "" || e === void 0;
1781
- }
1782
- function jn(e) {
1783
- const n = yt(e), t = c.useRef(""), o = c.useRef(0), r = c.useCallback(
1784
- (s) => {
1785
- const l = t.current + s;
1786
- n(l), function d(u) {
1787
- t.current = u, window.clearTimeout(o.current), u !== "" && (o.current = window.setTimeout(() => d(""), 1e3));
1788
- }(l);
1789
- },
1790
- [n]
1791
- ), i = c.useCallback(() => {
1792
- t.current = "", window.clearTimeout(o.current);
1793
- }, []);
1794
- return c.useEffect(() => () => window.clearTimeout(o.current), []), [t, r, i];
1795
- }
1796
- function Pn(e, n, t) {
1797
- const r = n.length > 1 && Array.from(n).every((u) => u === n[0]) ? n[0] : n, i = t ? e.indexOf(t) : -1;
1798
- let s = Jo(e, Math.max(i, 0));
1799
- r.length === 1 && (s = s.filter((u) => u !== t));
1800
- const d = s.find(
1801
- (u) => u.textValue.toLowerCase().startsWith(r.toLowerCase())
1802
- );
1803
- return d !== t ? d : void 0;
1804
- }
1805
- function Jo(e, n) {
1806
- return e.map((t, o) => e[(n + o) % e.length]);
1807
- }
1808
- var Qo = on, ea = sn, ta = ln, na = dn, ra = un, oa = pn, aa = vn, sa = Sn, ia = wn, ca = Cn, la = In, da = Rn;
1809
- function ua({ ...e }) {
1810
- return /* @__PURE__ */ a.jsx(Qo, { "data-slot": "select", ...e });
1811
- }
1812
- function pa({ ...e }) {
1813
- return /* @__PURE__ */ a.jsx(ta, { "data-slot": "select-value", ...e });
1814
- }
1815
- function fa({
1816
- className: e,
1817
- size: n = "default",
1818
- children: t,
1819
- ...o
1820
- }) {
1821
- return /* @__PURE__ */ a.jsxs(
1822
- ea,
1823
- {
1824
- className: B(
1825
- "border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
1826
- e
1827
- ),
1828
- "data-size": n,
1829
- "data-slot": "select-trigger",
1830
- ...o,
1831
- children: [
1832
- t,
1833
- /* @__PURE__ */ a.jsx(na, { asChild: !0, children: /* @__PURE__ */ a.jsx(_t, { className: "size-4 opacity-50" }) })
1834
- ]
1835
- }
1836
- );
1837
- }
1838
- function ma({
1839
- className: e,
1840
- children: n,
1841
- position: t = "popper",
1842
- align: o = "center",
1843
- ...r
1844
- }) {
1845
- return /* @__PURE__ */ a.jsx(ra, { children: /* @__PURE__ */ a.jsxs(
1846
- oa,
1847
- {
1848
- align: o,
1849
- className: B(
1850
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
1851
- t === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
1852
- e
1853
- ),
1854
- "data-slot": "select-content",
1855
- position: t,
1856
- ...r,
1857
- children: [
1858
- /* @__PURE__ */ a.jsx(ha, {}),
1859
- /* @__PURE__ */ a.jsx(
1860
- aa,
1861
- {
1862
- className: B(
1863
- "p-1",
1864
- t === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
1865
- ),
1866
- children: n
1867
- }
1868
- ),
1869
- /* @__PURE__ */ a.jsx(va, {})
1870
- ]
1871
- }
1872
- ) });
1873
- }
1874
- function xt({ className: e, children: n, ...t }) {
1875
- return /* @__PURE__ */ a.jsxs(
1876
- sa,
1877
- {
1878
- className: B(
1879
- "focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
1880
- e
1881
- ),
1882
- "data-slot": "select-item",
1883
- ...t,
1884
- children: [
1885
- /* @__PURE__ */ a.jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ a.jsx(ca, { children: /* @__PURE__ */ a.jsx(ut, { className: "size-4" }) }) }),
1886
- /* @__PURE__ */ a.jsx(ia, { children: n })
1887
- ]
1888
- }
1889
- );
1890
- }
1891
- function ha({ className: e, ...n }) {
1892
- return /* @__PURE__ */ a.jsx(
1893
- la,
1894
- {
1895
- className: B("flex cursor-default items-center justify-center py-1", e),
1896
- "data-slot": "select-scroll-up-button",
1897
- ...n,
1898
- children: /* @__PURE__ */ a.jsx(Nr, { className: "size-4" })
1899
- }
1900
- );
1901
- }
1902
- function va({
1903
- className: e,
1904
- ...n
1905
- }) {
1906
- return /* @__PURE__ */ a.jsx(
1907
- da,
1908
- {
1909
- className: B("flex cursor-default items-center justify-center py-1", e),
1910
- "data-slot": "select-scroll-down-button",
1911
- ...n,
1912
- children: /* @__PURE__ */ a.jsx(_t, { className: "size-4" })
1913
- }
1914
- );
1915
- }
1916
- const Bs = ({
1917
- name: e,
1918
- defaultValue: n,
1919
- options: t,
1920
- label: o,
1921
- placeholder: r,
1922
- note: i,
1923
- className: s,
1924
- value: l,
1925
- onValueChange: d,
1926
- error: u,
1927
- size: p = "md",
1928
- ...f
1929
- }) => {
1930
- const g = B(
1931
- "min-w-[180px]",
1932
- p === "xs" && "h-7 text-xs md:text-xs",
1933
- p === "sm" && "h-8 text-sm md:text-xs",
1934
- p === "md" && "h-9 text-base md:text-sm",
1935
- p === "lg" && "h-10 text-lg md:text-base",
1936
- p === "xl" && "h-11 text-xl md:text-lg",
1937
- s
1938
- ), x = p === "xs" || p === "sm" ? "sm" : "default", S = "__none__", h = (m) => {
1939
- d(m === S ? "" : m);
1940
- };
1941
- return /* @__PURE__ */ a.jsxs(pe, { className: "w-full", direction: "col", gap: "2", children: [
1942
- o && /* @__PURE__ */ a.jsx(ue, { htmlFor: e, children: o }),
1943
- /* @__PURE__ */ a.jsxs(
1944
- ua,
1945
- {
1946
- defaultValue: n,
1947
- name: e,
1948
- onValueChange: h,
1949
- value: l,
1950
- ...f,
1951
- children: [
1952
- /* @__PURE__ */ a.jsx(fa, { className: g, "data-testid": `select-input-${e}`, size: x, children: /* @__PURE__ */ a.jsx(pa, { placeholder: r }) }),
1953
- /* @__PURE__ */ a.jsxs(ma, { children: [
1954
- /* @__PURE__ */ a.jsx(xt, { className: "border-b border-b-border", value: S, children: " " }, "empty-option"),
1955
- t.map(({ value: m, label: b }) => /* @__PURE__ */ a.jsx(xt, { value: m, children: b }, `option-${m}`))
1956
- ] })
1957
- ]
1958
- }
1959
- ),
1960
- i && /* @__PURE__ */ a.jsx(Pt, { size: "sm", variant: "muted", children: i }),
1961
- u && /* @__PURE__ */ a.jsx(Oe, { message: u })
1962
- ] });
1963
- };
1964
- var bt = 1, ga = 0.9, xa = 0.8, ba = 0.17, Xe = 0.1, Ze = 0.999, Sa = 0.9999, wa = 0.99, ya = /[\\\/_+.#"@\[\(\{&]/, Ca = /[\\\/_+.#"@\[\(\{&]/g, Ia = /[\s-]/, Nn = /[\s-]/g;
1965
- function at(e, n, t, o, r, i, s) {
1966
- if (i === n.length) return r === e.length ? bt : wa;
1967
- var l = `${r},${i}`;
1968
- if (s[l] !== void 0) return s[l];
1969
- for (var d = o.charAt(i), u = t.indexOf(d, r), p = 0, f, g, x, S; u >= 0; ) f = at(e, n, t, o, u + 1, i + 1, s), f > p && (u === r ? f *= bt : ya.test(e.charAt(u - 1)) ? (f *= xa, x = e.slice(r, u - 1).match(Ca), x && r > 0 && (f *= Math.pow(Ze, x.length))) : Ia.test(e.charAt(u - 1)) ? (f *= ga, S = e.slice(r, u - 1).match(Nn), S && r > 0 && (f *= Math.pow(Ze, S.length))) : (f *= ba, r > 0 && (f *= Math.pow(Ze, u - r))), e.charAt(u) !== n.charAt(i) && (f *= Sa)), (f < Xe && t.charAt(u - 1) === o.charAt(i + 1) || o.charAt(i + 1) === o.charAt(i) && t.charAt(u - 1) !== o.charAt(i)) && (g = at(e, n, t, o, u + 1, i + 2, s), g * Xe > f && (f = g * Xe)), f > p && (p = f), u = t.indexOf(d, u + 1);
1970
- return s[l] = p, p;
1971
- }
1972
- function St(e) {
1973
- return e.toLowerCase().replace(Nn, " ");
1974
- }
1975
- function Ra(e, n, t) {
1976
- return e = t && t.length > 0 ? `${e + " " + t.join(" ")}` : e, at(e, n, St(e), St(n), 0, 0, {});
1977
- }
1978
- var Ce = '[cmdk-group=""]', Je = '[cmdk-group-items=""]', ka = '[cmdk-group-heading=""]', Tn = '[cmdk-item=""]', wt = `${Tn}:not([aria-disabled="true"])`, st = "cmdk-item-select", xe = "data-value", Ea = (e, n, t) => Ra(e, n, t), Mn = c.createContext(void 0), je = () => c.useContext(Mn), An = c.createContext(void 0), ht = () => c.useContext(An), Dn = c.createContext(void 0), On = c.forwardRef((e, n) => {
1979
- let t = be(() => {
1980
- var v, k;
1981
- return { search: "", value: (k = (v = e.value) != null ? v : e.defaultValue) != null ? k : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
1982
- }), o = be(() => /* @__PURE__ */ new Set()), r = be(() => /* @__PURE__ */ new Map()), i = be(() => /* @__PURE__ */ new Map()), s = be(() => /* @__PURE__ */ new Set()), l = Ln(e), { label: d, children: u, value: p, onValueChange: f, filter: g, shouldFilter: x, loop: S, disablePointerSelection: h = !1, vimBindings: m = !0, ...b } = e, w = te(), y = te(), R = te(), A = c.useRef(null), N = Ba();
1983
- he(() => {
1984
- if (p !== void 0) {
1985
- let v = p.trim();
1986
- t.current.value = v, _.emit();
1987
- }
1988
- }, [p]), he(() => {
1989
- N(6, X);
1990
- }, []);
1991
- let _ = c.useMemo(() => ({ subscribe: (v) => (s.current.add(v), () => s.current.delete(v)), snapshot: () => t.current, setState: (v, k, E) => {
1992
- var I, T, C, M;
1993
- if (!Object.is(t.current[v], k)) {
1994
- if (t.current[v] = k, v === "search") K(), z(), N(1, D);
1995
- else if (v === "value") {
1996
- if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
1997
- let F = document.getElementById(R);
1998
- F ? F.focus() : (I = document.getElementById(w)) == null || I.focus();
1999
- }
2000
- if (N(7, () => {
2001
- var F;
2002
- t.current.selectedItemId = (F = W()) == null ? void 0 : F.id, _.emit();
2003
- }), E || N(5, X), ((T = l.current) == null ? void 0 : T.value) !== void 0) {
2004
- let F = k ?? "";
2005
- (M = (C = l.current).onValueChange) == null || M.call(C, F);
2006
- return;
2007
- }
2008
- }
2009
- _.emit();
2010
- }
2011
- }, emit: () => {
2012
- s.current.forEach((v) => v());
2013
- } }), []), L = c.useMemo(() => ({ value: (v, k, E) => {
2014
- var I;
2015
- k !== ((I = i.current.get(v)) == null ? void 0 : I.value) && (i.current.set(v, { value: k, keywords: E }), t.current.filtered.items.set(v, Z(k, E)), N(2, () => {
2016
- z(), _.emit();
2017
- }));
2018
- }, item: (v, k) => (o.current.add(v), k && (r.current.has(k) ? r.current.get(k).add(v) : r.current.set(k, /* @__PURE__ */ new Set([v]))), N(3, () => {
2019
- K(), z(), t.current.value || D(), _.emit();
2020
- }), () => {
2021
- i.current.delete(v), o.current.delete(v), t.current.filtered.items.delete(v);
2022
- let E = W();
2023
- N(4, () => {
2024
- K(), E?.getAttribute("id") === v && D(), _.emit();
2025
- });
2026
- }), group: (v) => (r.current.has(v) || r.current.set(v, /* @__PURE__ */ new Set()), () => {
2027
- i.current.delete(v), r.current.delete(v);
2028
- }), filter: () => l.current.shouldFilter, label: d || e["aria-label"], getDisablePointerSelection: () => l.current.disablePointerSelection, listId: w, inputId: R, labelId: y, listInnerRef: A }), []);
2029
- function Z(v, k) {
2030
- var E, I;
2031
- let T = (I = (E = l.current) == null ? void 0 : E.filter) != null ? I : Ea;
2032
- return v ? T(v, t.current.search, k) : 0;
2033
- }
2034
- function z() {
2035
- if (!t.current.search || l.current.shouldFilter === !1) return;
2036
- let v = t.current.filtered.items, k = [];
2037
- t.current.filtered.groups.forEach((I) => {
2038
- let T = r.current.get(I), C = 0;
2039
- T.forEach((M) => {
2040
- let F = v.get(M);
2041
- C = Math.max(F, C);
2042
- }), k.push([I, C]);
2043
- });
2044
- let E = A.current;
2045
- U().sort((I, T) => {
2046
- var C, M;
2047
- let F = I.getAttribute("id"), $ = T.getAttribute("id");
2048
- return ((C = v.get($)) != null ? C : 0) - ((M = v.get(F)) != null ? M : 0);
2049
- }).forEach((I) => {
2050
- let T = I.closest(Je);
2051
- T ? T.appendChild(I.parentElement === T ? I : I.closest(`${Je} > *`)) : E.appendChild(I.parentElement === E ? I : I.closest(`${Je} > *`));
2052
- }), k.sort((I, T) => T[1] - I[1]).forEach((I) => {
2053
- var T;
2054
- let C = (T = A.current) == null ? void 0 : T.querySelector(`${Ce}[${xe}="${encodeURIComponent(I[0])}"]`);
2055
- C?.parentElement.appendChild(C);
2056
- });
2057
- }
2058
- function D() {
2059
- let v = U().find((E) => E.getAttribute("aria-disabled") !== "true"), k = v?.getAttribute(xe);
2060
- _.setState("value", k || void 0);
2061
- }
2062
- function K() {
2063
- var v, k, E, I;
2064
- if (!t.current.search || l.current.shouldFilter === !1) {
2065
- t.current.filtered.count = o.current.size;
2066
- return;
2067
- }
2068
- t.current.filtered.groups = /* @__PURE__ */ new Set();
2069
- let T = 0;
2070
- for (let C of o.current) {
2071
- let M = (k = (v = i.current.get(C)) == null ? void 0 : v.value) != null ? k : "", F = (I = (E = i.current.get(C)) == null ? void 0 : E.keywords) != null ? I : [], $ = Z(M, F);
2072
- t.current.filtered.items.set(C, $), $ > 0 && T++;
2073
- }
2074
- for (let [C, M] of r.current) for (let F of M) if (t.current.filtered.items.get(F) > 0) {
2075
- t.current.filtered.groups.add(C);
2076
- break;
2077
- }
2078
- t.current.filtered.count = T;
2079
- }
2080
- function X() {
2081
- var v, k, E;
2082
- let I = W();
2083
- I && (((v = I.parentElement) == null ? void 0 : v.firstChild) === I && ((E = (k = I.closest(Ce)) == null ? void 0 : k.querySelector(ka)) == null || E.scrollIntoView({ block: "nearest" })), I.scrollIntoView({ block: "nearest" }));
2084
- }
2085
- function W() {
2086
- var v;
2087
- return (v = A.current) == null ? void 0 : v.querySelector(`${Tn}[aria-selected="true"]`);
2088
- }
2089
- function U() {
2090
- var v;
2091
- return Array.from(((v = A.current) == null ? void 0 : v.querySelectorAll(wt)) || []);
2092
- }
2093
- function O(v) {
2094
- let k = U()[v];
2095
- k && _.setState("value", k.getAttribute(xe));
2096
- }
2097
- function G(v) {
2098
- var k;
2099
- let E = W(), I = U(), T = I.findIndex((M) => M === E), C = I[T + v];
2100
- (k = l.current) != null && k.loop && (C = T + v < 0 ? I[I.length - 1] : T + v === I.length ? I[0] : I[T + v]), C && _.setState("value", C.getAttribute(xe));
2101
- }
2102
- function q(v) {
2103
- let k = W(), E = k?.closest(Ce), I;
2104
- for (; E && !I; ) E = v > 0 ? Oa(E, Ce) : La(E, Ce), I = E?.querySelector(wt);
2105
- I ? _.setState("value", I.getAttribute(xe)) : G(v);
2106
- }
2107
- let J = () => O(U().length - 1), ge = (v) => {
2108
- v.preventDefault(), v.metaKey ? J() : v.altKey ? q(1) : G(1);
2109
- }, ie = (v) => {
2110
- v.preventDefault(), v.metaKey ? O(0) : v.altKey ? q(-1) : G(-1);
2111
- };
2112
- return c.createElement(j.div, { ref: n, tabIndex: -1, ...b, "cmdk-root": "", onKeyDown: (v) => {
2113
- var k;
2114
- (k = b.onKeyDown) == null || k.call(b, v);
2115
- let E = v.nativeEvent.isComposing || v.keyCode === 229;
2116
- if (!(v.defaultPrevented || E)) switch (v.key) {
2117
- case "n":
2118
- case "j": {
2119
- m && v.ctrlKey && ge(v);
2120
- break;
2121
- }
2122
- case "ArrowDown": {
2123
- ge(v);
2124
- break;
2125
- }
2126
- case "p":
2127
- case "k": {
2128
- m && v.ctrlKey && ie(v);
2129
- break;
2130
- }
2131
- case "ArrowUp": {
2132
- ie(v);
2133
- break;
2134
- }
2135
- case "Home": {
2136
- v.preventDefault(), O(0);
2137
- break;
2138
- }
2139
- case "End": {
2140
- v.preventDefault(), J();
2141
- break;
2142
- }
2143
- case "Enter": {
2144
- v.preventDefault();
2145
- let I = W();
2146
- if (I) {
2147
- let T = new Event(st);
2148
- I.dispatchEvent(T);
2149
- }
2150
- }
2151
- }
2152
- } }, c.createElement("label", { "cmdk-label": "", htmlFor: L.inputId, id: L.labelId, style: $a }, d), Ke(e, (v) => c.createElement(An.Provider, { value: _ }, c.createElement(Mn.Provider, { value: L }, v))));
2153
- }), _a = c.forwardRef((e, n) => {
2154
- var t, o;
2155
- let r = te(), i = c.useRef(null), s = c.useContext(Dn), l = je(), d = Ln(e), u = (o = (t = d.current) == null ? void 0 : t.forceMount) != null ? o : s?.forceMount;
2156
- he(() => {
2157
- if (!u) return l.item(r, s?.id);
2158
- }, [u]);
2159
- let p = Bn(r, i, [e.value, e.children, i], e.keywords), f = ht(), g = oe((N) => N.value && N.value === p.current), x = oe((N) => u || l.filter() === !1 ? !0 : N.search ? N.filtered.items.get(r) > 0 : !0);
2160
- c.useEffect(() => {
2161
- let N = i.current;
2162
- if (!(!N || e.disabled)) return N.addEventListener(st, S), () => N.removeEventListener(st, S);
2163
- }, [x, e.onSelect, e.disabled]);
2164
- function S() {
2165
- var N, _;
2166
- h(), (_ = (N = d.current).onSelect) == null || _.call(N, p.current);
2167
- }
2168
- function h() {
2169
- f.setState("value", p.current, !0);
2170
- }
2171
- if (!x) return null;
2172
- let { disabled: m, value: b, onSelect: w, forceMount: y, keywords: R, ...A } = e;
2173
- return c.createElement(j.div, { ref: Re(i, n), ...A, id: r, "cmdk-item": "", role: "option", "aria-disabled": !!m, "aria-selected": !!g, "data-disabled": !!m, "data-selected": !!g, onPointerMove: m || l.getDisablePointerSelection() ? void 0 : h, onClick: m ? void 0 : S }, e.children);
2174
- }), ja = c.forwardRef((e, n) => {
2175
- let { heading: t, children: o, forceMount: r, ...i } = e, s = te(), l = c.useRef(null), d = c.useRef(null), u = te(), p = je(), f = oe((x) => r || p.filter() === !1 ? !0 : x.search ? x.filtered.groups.has(s) : !0);
2176
- he(() => p.group(s), []), Bn(s, l, [e.value, e.heading, d]);
2177
- let g = c.useMemo(() => ({ id: s, forceMount: r }), [r]);
2178
- return c.createElement(j.div, { ref: Re(l, n), ...i, "cmdk-group": "", role: "presentation", hidden: f ? void 0 : !0 }, t && c.createElement("div", { ref: d, "cmdk-group-heading": "", "aria-hidden": !0, id: u }, t), Ke(e, (x) => c.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? u : void 0 }, c.createElement(Dn.Provider, { value: g }, x))));
2179
- }), Pa = c.forwardRef((e, n) => {
2180
- let { alwaysRender: t, ...o } = e, r = c.useRef(null), i = oe((s) => !s.search);
2181
- return !t && !i ? null : c.createElement(j.div, { ref: Re(r, n), ...o, "cmdk-separator": "", role: "separator" });
2182
- }), Na = c.forwardRef((e, n) => {
2183
- let { onValueChange: t, ...o } = e, r = e.value != null, i = ht(), s = oe((u) => u.search), l = oe((u) => u.selectedItemId), d = je();
2184
- return c.useEffect(() => {
2185
- e.value != null && i.setState("search", e.value);
2186
- }, [e.value]), c.createElement(j.input, { ref: n, ...o, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": d.listId, "aria-labelledby": d.labelId, "aria-activedescendant": l, id: d.inputId, type: "text", value: r ? e.value : s, onChange: (u) => {
2187
- r || i.setState("search", u.target.value), t?.(u.target.value);
2188
- } });
2189
- }), Ta = c.forwardRef((e, n) => {
2190
- let { children: t, label: o = "Suggestions", ...r } = e, i = c.useRef(null), s = c.useRef(null), l = oe((u) => u.selectedItemId), d = je();
2191
- return c.useEffect(() => {
2192
- if (s.current && i.current) {
2193
- let u = s.current, p = i.current, f, g = new ResizeObserver(() => {
2194
- f = requestAnimationFrame(() => {
2195
- let x = u.offsetHeight;
2196
- p.style.setProperty("--cmdk-list-height", x.toFixed(1) + "px");
2197
- });
2198
- });
2199
- return g.observe(u), () => {
2200
- cancelAnimationFrame(f), g.unobserve(u);
2201
- };
2202
- }
2203
- }, []), c.createElement(j.div, { ref: Re(i, n), ...r, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": l, "aria-label": o, id: d.listId }, Ke(e, (u) => c.createElement("div", { ref: Re(s, d.listInnerRef), "cmdk-list-sizer": "" }, u)));
2204
- }), Ma = c.forwardRef((e, n) => {
2205
- let { open: t, onOpenChange: o, overlayClassName: r, contentClassName: i, container: s, ...l } = e;
2206
- return c.createElement(gr, { open: t, onOpenChange: o }, c.createElement(xr, { container: s }, c.createElement(br, { "cmdk-overlay": "", className: r }), c.createElement(Sr, { "aria-label": e.label, "cmdk-dialog": "", className: i }, c.createElement(On, { ref: n, ...l }))));
2207
- }), Aa = c.forwardRef((e, n) => oe((t) => t.filtered.count === 0) ? c.createElement(j.div, { ref: n, ...e, "cmdk-empty": "", role: "presentation" }) : null), Da = c.forwardRef((e, n) => {
2208
- let { progress: t, children: o, label: r = "Loading...", ...i } = e;
2209
- return c.createElement(j.div, { ref: n, ...i, "cmdk-loading": "", role: "progressbar", "aria-valuenow": t, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": r }, Ke(e, (s) => c.createElement("div", { "aria-hidden": !0 }, s)));
2210
- }), we = Object.assign(On, { List: Ta, Item: _a, Input: Na, Group: ja, Separator: Pa, Dialog: Ma, Empty: Aa, Loading: Da });
2211
- function Oa(e, n) {
2212
- let t = e.nextElementSibling;
2213
- for (; t; ) {
2214
- if (t.matches(n)) return t;
2215
- t = t.nextElementSibling;
2216
- }
2217
- }
2218
- function La(e, n) {
2219
- let t = e.previousElementSibling;
2220
- for (; t; ) {
2221
- if (t.matches(n)) return t;
2222
- t = t.previousElementSibling;
2223
- }
2224
- }
2225
- function Ln(e) {
2226
- let n = c.useRef(e);
2227
- return he(() => {
2228
- n.current = e;
2229
- }), n;
2230
- }
2231
- var he = typeof window > "u" ? c.useEffect : c.useLayoutEffect;
2232
- function be(e) {
2233
- let n = c.useRef();
2234
- return n.current === void 0 && (n.current = e()), n;
2235
- }
2236
- function oe(e) {
2237
- let n = ht(), t = () => e(n.snapshot());
2238
- return c.useSyncExternalStore(n.subscribe, t, t);
2239
- }
2240
- function Bn(e, n, t, o = []) {
2241
- let r = c.useRef(), i = je();
2242
- return he(() => {
2243
- var s;
2244
- let l = (() => {
2245
- var u;
2246
- for (let p of t) {
2247
- if (typeof p == "string") return p.trim();
2248
- if (typeof p == "object" && "current" in p) return p.current ? (u = p.current.textContent) == null ? void 0 : u.trim() : r.current;
2249
- }
2250
- })(), d = o.map((u) => u.trim());
2251
- i.value(e, l, d), (s = n.current) == null || s.setAttribute(xe, l), r.current = l;
2252
- }), r;
2253
- }
2254
- var Ba = () => {
2255
- let [e, n] = c.useState(), t = be(() => /* @__PURE__ */ new Map());
2256
- return he(() => {
2257
- t.current.forEach((o) => o()), t.current = /* @__PURE__ */ new Map();
2258
- }, [e]), (o, r) => {
2259
- t.current.set(o, r), n({});
2260
- };
2261
- };
2262
- function Fa(e) {
2263
- let n = e.type;
2264
- return typeof n == "function" ? n(e.props) : "render" in n ? n.render(e.props) : e;
2265
- }
2266
- function Ke({ asChild: e, children: n }, t) {
2267
- return e && c.isValidElement(n) ? c.cloneElement(Fa(n), { ref: n.ref }, t(n.props.children)) : t(n);
2268
- }
2269
- var $a = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
2270
- function Va({ className: e, ...n }) {
2271
- return /* @__PURE__ */ a.jsx(
2272
- we,
2273
- {
2274
- className: B(
2275
- "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
2276
- e
2277
- ),
2278
- "data-slot": "command",
2279
- ...n
2280
- }
2281
- );
2282
- }
2283
- function Ka({ className: e, ...n }) {
2284
- return /* @__PURE__ */ a.jsxs("div", { className: "flex h-9 items-center gap-2 border-b px-3", "data-slot": "command-input-wrapper", children: [
2285
- /* @__PURE__ */ a.jsx(Wr, { className: "size-4 shrink-0 opacity-50" }),
2286
- /* @__PURE__ */ a.jsx(
2287
- we.Input,
2288
- {
2289
- className: B(
2290
- "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
2291
- e
2292
- ),
2293
- "data-slot": "command-input",
2294
- ...n
2295
- }
2296
- )
2297
- ] });
2298
- }
2299
- function Ha({ className: e, ...n }) {
2300
- return /* @__PURE__ */ a.jsx(
2301
- we.List,
2302
- {
2303
- className: B("max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden", e),
2304
- "data-slot": "command-list",
2305
- ...n
2306
- }
2307
- );
2308
- }
2309
- function Ua({ ...e }) {
2310
- return /* @__PURE__ */ a.jsx(we.Empty, { className: "py-6 text-center text-sm", "data-slot": "command-empty", ...e });
2311
- }
2312
- function Ga({ className: e, ...n }) {
2313
- return /* @__PURE__ */ a.jsx(
2314
- we.Group,
2315
- {
2316
- className: B(
2317
- "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs",
2318
- e
2319
- ),
2320
- "data-slot": "command-group",
2321
- ...n
2322
- }
2323
- );
2324
- }
2325
- function za({ className: e, ...n }) {
2326
- return /* @__PURE__ */ a.jsx(
2327
- we.Item,
2328
- {
2329
- className: B(
2330
- "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
2331
- e
2332
- ),
2333
- "data-slot": "command-item",
2334
- ...n
2335
- }
2336
- );
2337
- }
2338
- const Wa = ({
2339
- placeholder: e,
2340
- selected: n,
2341
- className: t,
2342
- open: o,
2343
- renderSelected: r = (i) => i.label
2344
- }) => /* @__PURE__ */ a.jsx(Rt, { asChild: !0, children: /* @__PURE__ */ a.jsxs(wr, { "aria-expanded": o, className: `justify-between ${t}`, role: "combobox", variant: "outline", children: [
2345
- r(n || { label: e, value: "" }),
2346
- /* @__PURE__ */ a.jsx(Mr, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
2347
- ] }) }), Fs = ({
2348
- options: e,
2349
- value: n = "",
2350
- placeholder: t = "Select a value...",
2351
- className: o = "",
2352
- onSelect: r = () => {
2353
- },
2354
- renderSelected: i = (s) => s.label
2355
- }) => {
2356
- const [s, l] = ke(!1), d = Cr(() => e.find((u) => u.value === n), [e, n]);
2357
- return /* @__PURE__ */ a.jsxs(It, { onOpenChange: l, open: s, children: [
2358
- /* @__PURE__ */ a.jsx(
2359
- Wa,
2360
- {
2361
- className: `w-full ${o}`,
2362
- open: s,
2363
- placeholder: t,
2364
- renderSelected: i,
2365
- selected: d
2366
- }
2367
- ),
2368
- /* @__PURE__ */ a.jsx(kt, { className: "w-full p-0", children: /* @__PURE__ */ a.jsxs(Va, { value: n, children: [
2369
- /* @__PURE__ */ a.jsx(Ka, { "aria-label": "Search options", className: "h-9", placeholder: "Search" }),
2370
- /* @__PURE__ */ a.jsxs(Ha, { children: [
2371
- /* @__PURE__ */ a.jsx(Ua, { children: "No results found" }),
2372
- /* @__PURE__ */ a.jsx(Ga, { children: e.map((u) => /* @__PURE__ */ a.jsxs(
2373
- za,
2374
- {
2375
- onSelect: () => {
2376
- l(!1), r(u.value);
2377
- },
2378
- value: u.value,
2379
- children: [
2380
- u.icon ? /* @__PURE__ */ a.jsx("span", { className: "mr-2", children: u.icon }) : "",
2381
- u.label,
2382
- /* @__PURE__ */ a.jsx(ut, { className: B("ml-auto", u.value === n ? "opacity-100" : "opacity-0") })
2383
- ]
2384
- },
2385
- u.value
2386
- )) })
2387
- ] })
2388
- ] }) })
2389
- ] });
2390
- };
2391
- var Fn = ["PageUp", "PageDown"], $n = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], Vn = {
2392
- "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
2393
- "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
2394
- "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
2395
- "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
2396
- }, ye = "Slider", [it, qa, Ya] = dt(ye), [Kn, $s] = ve(ye, [
2397
- Ya
2398
- ]), [Xa, He] = Kn(ye), Hn = c.forwardRef(
2399
- (e, n) => {
2400
- const {
2401
- name: t,
2402
- min: o = 0,
2403
- max: r = 100,
2404
- step: i = 1,
2405
- orientation: s = "horizontal",
2406
- disabled: l = !1,
2407
- minStepsBetweenThumbs: d = 0,
2408
- defaultValue: u = [o],
2409
- value: p,
2410
- onValueChange: f = () => {
2411
- },
2412
- onValueCommit: g = () => {
2413
- },
2414
- inverted: x = !1,
2415
- form: S,
2416
- ...h
2417
- } = e, m = c.useRef(/* @__PURE__ */ new Set()), b = c.useRef(0), y = s === "horizontal" ? Za : Ja, [R = [], A] = de({
2418
- prop: p,
2419
- defaultProp: u,
2420
- onChange: (D) => {
2421
- [...m.current][b.current]?.focus(), f(D);
2422
- }
2423
- }), N = c.useRef(R);
2424
- function _(D) {
2425
- const K = rs(R, D);
2426
- z(D, K);
2427
- }
2428
- function L(D) {
2429
- z(D, b.current);
2430
- }
2431
- function Z() {
2432
- const D = N.current[b.current];
2433
- R[b.current] !== D && g(R);
2434
- }
2435
- function z(D, K, { commit: X } = { commit: !1 }) {
2436
- const W = is(i), U = cs(Math.round((D - o) / i) * i + o, W), O = Ne(U, [o, r]);
2437
- A((G = []) => {
2438
- const q = ts(G, O, K);
2439
- if (ss(q, d * i)) {
2440
- b.current = q.indexOf(O);
2441
- const J = String(q) !== String(G);
2442
- return J && X && g(q), J ? q : G;
2443
- } else
2444
- return G;
2445
- });
2446
- }
2447
- return /* @__PURE__ */ a.jsx(
2448
- Xa,
2449
- {
2450
- scope: e.__scopeSlider,
2451
- name: t,
2452
- disabled: l,
2453
- min: o,
2454
- max: r,
2455
- valueIndexToChangeRef: b,
2456
- thumbs: m.current,
2457
- values: R,
2458
- orientation: s,
2459
- form: S,
2460
- children: /* @__PURE__ */ a.jsx(it.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ a.jsx(it.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ a.jsx(
2461
- y,
2462
- {
2463
- "aria-disabled": l,
2464
- "data-disabled": l ? "" : void 0,
2465
- ...h,
2466
- ref: n,
2467
- onPointerDown: P(h.onPointerDown, () => {
2468
- l || (N.current = R);
2469
- }),
2470
- min: o,
2471
- max: r,
2472
- inverted: x,
2473
- onSlideStart: l ? void 0 : _,
2474
- onSlideMove: l ? void 0 : L,
2475
- onSlideEnd: l ? void 0 : Z,
2476
- onHomeKeyDown: () => !l && z(o, 0, { commit: !0 }),
2477
- onEndKeyDown: () => !l && z(r, R.length - 1, { commit: !0 }),
2478
- onStepKeyDown: ({ event: D, direction: K }) => {
2479
- if (!l) {
2480
- const U = Fn.includes(D.key) || D.shiftKey && $n.includes(D.key) ? 10 : 1, O = b.current, G = R[O], q = i * U * K;
2481
- z(G + q, O, { commit: !0 });
2482
- }
2483
- }
2484
- }
2485
- ) }) })
2486
- }
2487
- );
2488
- }
2489
- );
2490
- Hn.displayName = ye;
2491
- var [Un, Gn] = Kn(ye, {
2492
- startEdge: "left",
2493
- endEdge: "right",
2494
- size: "width",
2495
- direction: 1
2496
- }), Za = c.forwardRef(
2497
- (e, n) => {
2498
- const {
2499
- min: t,
2500
- max: o,
2501
- dir: r,
2502
- inverted: i,
2503
- onSlideStart: s,
2504
- onSlideMove: l,
2505
- onSlideEnd: d,
2506
- onStepKeyDown: u,
2507
- ...p
2508
- } = e, [f, g] = c.useState(null), x = V(n, (y) => g(y)), S = c.useRef(void 0), h = Me(r), m = h === "ltr", b = m && !i || !m && i;
2509
- function w(y) {
2510
- const R = S.current || f.getBoundingClientRect(), A = [0, R.width], _ = vt(A, b ? [t, o] : [o, t]);
2511
- return S.current = R, _(y - R.left);
2512
- }
2513
- return /* @__PURE__ */ a.jsx(
2514
- Un,
2515
- {
2516
- scope: e.__scopeSlider,
2517
- startEdge: b ? "left" : "right",
2518
- endEdge: b ? "right" : "left",
2519
- direction: b ? 1 : -1,
2520
- size: "width",
2521
- children: /* @__PURE__ */ a.jsx(
2522
- zn,
2523
- {
2524
- dir: h,
2525
- "data-orientation": "horizontal",
2526
- ...p,
2527
- ref: x,
2528
- style: {
2529
- ...p.style,
2530
- "--radix-slider-thumb-transform": "translateX(-50%)"
2531
- },
2532
- onSlideStart: (y) => {
2533
- const R = w(y.clientX);
2534
- s?.(R);
2535
- },
2536
- onSlideMove: (y) => {
2537
- const R = w(y.clientX);
2538
- l?.(R);
2539
- },
2540
- onSlideEnd: () => {
2541
- S.current = void 0, d?.();
2542
- },
2543
- onStepKeyDown: (y) => {
2544
- const A = Vn[b ? "from-left" : "from-right"].includes(y.key);
2545
- u?.({ event: y, direction: A ? -1 : 1 });
2546
- }
2547
- }
2548
- )
2549
- }
2550
- );
2551
- }
2552
- ), Ja = c.forwardRef(
2553
- (e, n) => {
2554
- const {
2555
- min: t,
2556
- max: o,
2557
- inverted: r,
2558
- onSlideStart: i,
2559
- onSlideMove: s,
2560
- onSlideEnd: l,
2561
- onStepKeyDown: d,
2562
- ...u
2563
- } = e, p = c.useRef(null), f = V(n, p), g = c.useRef(void 0), x = !r;
2564
- function S(h) {
2565
- const m = g.current || p.current.getBoundingClientRect(), b = [0, m.height], y = vt(b, x ? [o, t] : [t, o]);
2566
- return g.current = m, y(h - m.top);
2567
- }
2568
- return /* @__PURE__ */ a.jsx(
2569
- Un,
2570
- {
2571
- scope: e.__scopeSlider,
2572
- startEdge: x ? "bottom" : "top",
2573
- endEdge: x ? "top" : "bottom",
2574
- size: "height",
2575
- direction: x ? 1 : -1,
2576
- children: /* @__PURE__ */ a.jsx(
2577
- zn,
2578
- {
2579
- "data-orientation": "vertical",
2580
- ...u,
2581
- ref: f,
2582
- style: {
2583
- ...u.style,
2584
- "--radix-slider-thumb-transform": "translateY(50%)"
2585
- },
2586
- onSlideStart: (h) => {
2587
- const m = S(h.clientY);
2588
- i?.(m);
2589
- },
2590
- onSlideMove: (h) => {
2591
- const m = S(h.clientY);
2592
- s?.(m);
2593
- },
2594
- onSlideEnd: () => {
2595
- g.current = void 0, l?.();
2596
- },
2597
- onStepKeyDown: (h) => {
2598
- const b = Vn[x ? "from-bottom" : "from-top"].includes(h.key);
2599
- d?.({ event: h, direction: b ? -1 : 1 });
2600
- }
2601
- }
2602
- )
2603
- }
2604
- );
2605
- }
2606
- ), zn = c.forwardRef(
2607
- (e, n) => {
2608
- const {
2609
- __scopeSlider: t,
2610
- onSlideStart: o,
2611
- onSlideMove: r,
2612
- onSlideEnd: i,
2613
- onHomeKeyDown: s,
2614
- onEndKeyDown: l,
2615
- onStepKeyDown: d,
2616
- ...u
2617
- } = e, p = He(ye, t);
2618
- return /* @__PURE__ */ a.jsx(
2619
- j.span,
2620
- {
2621
- ...u,
2622
- ref: n,
2623
- onKeyDown: P(e.onKeyDown, (f) => {
2624
- f.key === "Home" ? (s(f), f.preventDefault()) : f.key === "End" ? (l(f), f.preventDefault()) : Fn.concat($n).includes(f.key) && (d(f), f.preventDefault());
2625
- }),
2626
- onPointerDown: P(e.onPointerDown, (f) => {
2627
- const g = f.target;
2628
- g.setPointerCapture(f.pointerId), f.preventDefault(), p.thumbs.has(g) ? g.focus() : o(f);
2629
- }),
2630
- onPointerMove: P(e.onPointerMove, (f) => {
2631
- f.target.hasPointerCapture(f.pointerId) && r(f);
2632
- }),
2633
- onPointerUp: P(e.onPointerUp, (f) => {
2634
- const g = f.target;
2635
- g.hasPointerCapture(f.pointerId) && (g.releasePointerCapture(f.pointerId), i(f));
2636
- })
2637
- }
2638
- );
2639
- }
2640
- ), Wn = "SliderTrack", qn = c.forwardRef(
2641
- (e, n) => {
2642
- const { __scopeSlider: t, ...o } = e, r = He(Wn, t);
2643
- return /* @__PURE__ */ a.jsx(
2644
- j.span,
2645
- {
2646
- "data-disabled": r.disabled ? "" : void 0,
2647
- "data-orientation": r.orientation,
2648
- ...o,
2649
- ref: n
2650
- }
2651
- );
2652
- }
2653
- );
2654
- qn.displayName = Wn;
2655
- var ct = "SliderRange", Yn = c.forwardRef(
2656
- (e, n) => {
2657
- const { __scopeSlider: t, ...o } = e, r = He(ct, t), i = Gn(ct, t), s = c.useRef(null), l = V(n, s), d = r.values.length, u = r.values.map(
2658
- (g) => Jn(g, r.min, r.max)
2659
- ), p = d > 1 ? Math.min(...u) : 0, f = 100 - Math.max(...u);
2660
- return /* @__PURE__ */ a.jsx(
2661
- j.span,
2662
- {
2663
- "data-orientation": r.orientation,
2664
- "data-disabled": r.disabled ? "" : void 0,
2665
- ...o,
2666
- ref: l,
2667
- style: {
2668
- ...e.style,
2669
- [i.startEdge]: p + "%",
2670
- [i.endEdge]: f + "%"
2671
- }
2672
- }
2673
- );
2674
- }
2675
- );
2676
- Yn.displayName = ct;
2677
- var lt = "SliderThumb", Xn = c.forwardRef(
2678
- (e, n) => {
2679
- const t = qa(e.__scopeSlider), [o, r] = c.useState(null), i = V(n, (l) => r(l)), s = c.useMemo(
2680
- () => o ? t().findIndex((l) => l.ref.current === o) : -1,
2681
- [t, o]
2682
- );
2683
- return /* @__PURE__ */ a.jsx(Qa, { ...e, ref: i, index: s });
2684
- }
2685
- ), Qa = c.forwardRef(
2686
- (e, n) => {
2687
- const { __scopeSlider: t, index: o, name: r, ...i } = e, s = He(lt, t), l = Gn(lt, t), [d, u] = c.useState(null), p = V(n, (w) => u(w)), f = d ? s.form || !!d.closest("form") : !0, g = De(d), x = s.values[o], S = x === void 0 ? 0 : Jn(x, s.min, s.max), h = ns(o, s.values.length), m = g?.[l.size], b = m ? os(m, S, l.direction) : 0;
2688
- return c.useEffect(() => {
2689
- if (d)
2690
- return s.thumbs.add(d), () => {
2691
- s.thumbs.delete(d);
2692
- };
2693
- }, [d, s.thumbs]), /* @__PURE__ */ a.jsxs(
2694
- "span",
2695
- {
2696
- style: {
2697
- transform: "var(--radix-slider-thumb-transform)",
2698
- position: "absolute",
2699
- [l.startEdge]: `calc(${S}% + ${b}px)`
2700
- },
2701
- children: [
2702
- /* @__PURE__ */ a.jsx(it.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ a.jsx(
2703
- j.span,
2704
- {
2705
- role: "slider",
2706
- "aria-label": e["aria-label"] || h,
2707
- "aria-valuemin": s.min,
2708
- "aria-valuenow": x,
2709
- "aria-valuemax": s.max,
2710
- "aria-orientation": s.orientation,
2711
- "data-orientation": s.orientation,
2712
- "data-disabled": s.disabled ? "" : void 0,
2713
- tabIndex: s.disabled ? void 0 : 0,
2714
- ...i,
2715
- ref: p,
2716
- style: x === void 0 ? { display: "none" } : e.style,
2717
- onFocus: P(e.onFocus, () => {
2718
- s.valueIndexToChangeRef.current = o;
2719
- })
2720
- }
2721
- ) }),
2722
- f && /* @__PURE__ */ a.jsx(
2723
- Zn,
2724
- {
2725
- name: r ?? (s.name ? s.name + (s.values.length > 1 ? "[]" : "") : void 0),
2726
- form: s.form,
2727
- value: x
2728
- },
2729
- o
2730
- )
2731
- ]
2732
- }
2733
- );
2734
- }
2735
- );
2736
- Xn.displayName = lt;
2737
- var es = "RadioBubbleInput", Zn = c.forwardRef(
2738
- ({ __scopeSlider: e, value: n, ...t }, o) => {
2739
- const r = c.useRef(null), i = V(r, o), s = _e(n);
2740
- return c.useEffect(() => {
2741
- const l = r.current;
2742
- if (!l) return;
2743
- const d = window.HTMLInputElement.prototype, p = Object.getOwnPropertyDescriptor(d, "value").set;
2744
- if (s !== n && p) {
2745
- const f = new Event("input", { bubbles: !0 });
2746
- p.call(l, n), l.dispatchEvent(f);
2747
- }
2748
- }, [s, n]), /* @__PURE__ */ a.jsx(
2749
- j.input,
2750
- {
2751
- style: { display: "none" },
2752
- ...t,
2753
- ref: i,
2754
- defaultValue: n
2755
- }
2756
- );
2757
- }
2758
- );
2759
- Zn.displayName = es;
2760
- function ts(e = [], n, t) {
2761
- const o = [...e];
2762
- return o[t] = n, o.sort((r, i) => r - i);
2763
- }
2764
- function Jn(e, n, t) {
2765
- const i = 100 / (t - n) * (e - n);
2766
- return Ne(i, [0, 100]);
2767
- }
2768
- function ns(e, n) {
2769
- return n > 2 ? `Value ${e + 1} of ${n}` : n === 2 ? ["Minimum", "Maximum"][e] : void 0;
2770
- }
2771
- function rs(e, n) {
2772
- if (e.length === 1) return 0;
2773
- const t = e.map((r) => Math.abs(r - n)), o = Math.min(...t);
2774
- return t.indexOf(o);
2775
- }
2776
- function os(e, n, t) {
2777
- const o = e / 2, i = vt([0, 50], [0, o]);
2778
- return (o - i(n) * t) * t;
2779
- }
2780
- function as(e) {
2781
- return e.slice(0, -1).map((n, t) => e[t + 1] - n);
2782
- }
2783
- function ss(e, n) {
2784
- if (n > 0) {
2785
- const t = as(e);
2786
- return Math.min(...t) >= n;
2787
- }
2788
- return !0;
2789
- }
2790
- function vt(e, n) {
2791
- return (t) => {
2792
- if (e[0] === e[1] || n[0] === n[1]) return n[0];
2793
- const o = (n[1] - n[0]) / (e[1] - e[0]);
2794
- return n[0] + o * (t - e[0]);
2795
- };
2796
- }
2797
- function is(e) {
2798
- return (String(e).split(".")[1] || "").length;
2799
- }
2800
- function cs(e, n) {
2801
- const t = Math.pow(10, n);
2802
- return Math.round(e * t) / t;
2803
- }
2804
- var ls = Hn, ds = qn, us = Yn, ps = Xn;
2805
- function fs({
2806
- className: e,
2807
- trackClassName: n,
2808
- thumbClassName: t,
2809
- defaultValue: o,
2810
- value: r,
2811
- min: i = 0,
2812
- max: s = 100,
2813
- ...l
2814
- }) {
2815
- const d = c.useMemo(
2816
- () => Array.isArray(r) ? r : Array.isArray(o) ? o : [i, s],
2817
- [r, o, i, s]
2818
- );
2819
- return /* @__PURE__ */ a.jsxs(
2820
- ls,
2821
- {
2822
- className: B(
2823
- "relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
2824
- e
2825
- ),
2826
- "data-slot": "slider",
2827
- defaultValue: o,
2828
- max: s,
2829
- min: i,
2830
- value: r,
2831
- ...l,
2832
- children: [
2833
- /* @__PURE__ */ a.jsx(
2834
- ds,
2835
- {
2836
- className: B(
2837
- "bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",
2838
- n
2839
- ),
2840
- "data-slot": "slider-track",
2841
- children: /* @__PURE__ */ a.jsx(
2842
- us,
2843
- {
2844
- className: B("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"),
2845
- "data-slot": "slider-range"
2846
- }
2847
- )
2848
- }
2849
- ),
2850
- Array.from({ length: d.length }, (u, p) => /* @__PURE__ */ a.jsx(
2851
- ps,
2852
- {
2853
- className: B(
2854
- "border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50",
2855
- t
2856
- ),
2857
- "data-slot": "slider-thumb"
2858
- },
2859
- p
2860
- ))
2861
- ]
2862
- }
2863
- );
2864
- }
2865
- const Vs = ({ size: e = "md", thumbClassName: n, trackClassName: t, value: o, defaultValue: r, ...i }) => {
2866
- const s = r !== void 0 ? Array.isArray(r) ? r : [r] : void 0, l = o !== void 0 ? Array.isArray(o) ? o : [o] : void 0;
2867
- return /* @__PURE__ */ a.jsx(
2868
- fs,
2869
- {
2870
- defaultValue: s,
2871
- thumbClassName: B(
2872
- {
2873
- "size-2": e === "xs",
2874
- "size-3": e === "sm",
2875
- "size-4": e === "md",
2876
- "size-5": e === "lg",
2877
- "size-6": e === "xl"
2878
- },
2879
- "bg-primary",
2880
- n
2881
- ),
2882
- trackClassName: B(
2883
- {
2884
- "data-[orientation=horizontal]:h-1 data-[orientation=vertical]:w-1": e === "xs",
2885
- "data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5": e === "sm",
2886
- "data-[orientation=horizontal]:h-2 data-[orientation=vertical]:w-2": e === "md",
2887
- "data-[orientation=horizontal]:h-3 data-[orientation=vertical]:w-3": e === "lg",
2888
- "data-[orientation=horizontal]:h-4 data-[orientation=vertical]:w-4": e === "xl"
2889
- },
2890
- t
2891
- ),
2892
- value: l,
2893
- ...i
2894
- }
2895
- );
2896
- };
2897
- var Ue = "Switch", [ms, Ks] = ve(Ue), [hs, vs] = ms(Ue), Qn = c.forwardRef(
2898
- (e, n) => {
2899
- const {
2900
- __scopeSwitch: t,
2901
- name: o,
2902
- checked: r,
2903
- defaultChecked: i,
2904
- required: s,
2905
- disabled: l,
2906
- value: d = "on",
2907
- onCheckedChange: u,
2908
- form: p,
2909
- ...f
2910
- } = e, [g, x] = c.useState(null), S = V(n, (y) => x(y)), h = c.useRef(!1), m = g ? p || !!g.closest("form") : !0, [b, w] = de({
2911
- prop: r,
2912
- defaultProp: i ?? !1,
2913
- onChange: u,
2914
- caller: Ue
2915
- });
2916
- return /* @__PURE__ */ a.jsxs(hs, { scope: t, checked: b, disabled: l, children: [
2917
- /* @__PURE__ */ a.jsx(
2918
- j.button,
2919
- {
2920
- type: "button",
2921
- role: "switch",
2922
- "aria-checked": b,
2923
- "aria-required": s,
2924
- "data-state": rr(b),
2925
- "data-disabled": l ? "" : void 0,
2926
- disabled: l,
2927
- value: d,
2928
- ...f,
2929
- ref: S,
2930
- onClick: P(e.onClick, (y) => {
2931
- w((R) => !R), m && (h.current = y.isPropagationStopped(), h.current || y.stopPropagation());
2932
- })
2933
- }
2934
- ),
2935
- m && /* @__PURE__ */ a.jsx(
2936
- nr,
2937
- {
2938
- control: g,
2939
- bubbles: !h.current,
2940
- name: o,
2941
- value: d,
2942
- checked: b,
2943
- required: s,
2944
- disabled: l,
2945
- form: p,
2946
- style: { transform: "translateX(-100%)" }
2947
- }
2948
- )
2949
- ] });
2950
- }
2951
- );
2952
- Qn.displayName = Ue;
2953
- var er = "SwitchThumb", tr = c.forwardRef(
2954
- (e, n) => {
2955
- const { __scopeSwitch: t, ...o } = e, r = vs(er, t);
2956
- return /* @__PURE__ */ a.jsx(
2957
- j.span,
2958
- {
2959
- "data-state": rr(r.checked),
2960
- "data-disabled": r.disabled ? "" : void 0,
2961
- ...o,
2962
- ref: n
2963
- }
2964
- );
2965
- }
2966
- );
2967
- tr.displayName = er;
2968
- var gs = "SwitchBubbleInput", nr = c.forwardRef(
2969
- ({
2970
- __scopeSwitch: e,
2971
- control: n,
2972
- checked: t,
2973
- bubbles: o = !0,
2974
- ...r
2975
- }, i) => {
2976
- const s = c.useRef(null), l = V(s, i), d = _e(t), u = De(n);
2977
- return c.useEffect(() => {
2978
- const p = s.current;
2979
- if (!p) return;
2980
- const f = window.HTMLInputElement.prototype, x = Object.getOwnPropertyDescriptor(
2981
- f,
2982
- "checked"
2983
- ).set;
2984
- if (d !== t && x) {
2985
- const S = new Event("click", { bubbles: o });
2986
- x.call(p, t), p.dispatchEvent(S);
2987
- }
2988
- }, [d, t, o]), /* @__PURE__ */ a.jsx(
2989
- "input",
2990
- {
2991
- type: "checkbox",
2992
- "aria-hidden": !0,
2993
- defaultChecked: t,
2994
- ...r,
2995
- tabIndex: -1,
2996
- ref: l,
2997
- style: {
2998
- ...r.style,
2999
- ...u,
3000
- position: "absolute",
3001
- pointerEvents: "none",
3002
- opacity: 0,
3003
- margin: 0
3004
- }
3005
- }
3006
- );
3007
- }
3008
- );
3009
- nr.displayName = gs;
3010
- function rr(e) {
3011
- return e ? "checked" : "unchecked";
3012
- }
3013
- var xs = Qn, bs = tr;
3014
- function Ss({
3015
- className: e,
3016
- thumbClassName: n,
3017
- ...t
3018
- }) {
3019
- return /* @__PURE__ */ a.jsx(
3020
- xs,
3021
- {
3022
- className: B(
3023
- "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
3024
- e
3025
- ),
3026
- "data-slot": "switch",
3027
- ...t,
3028
- children: /* @__PURE__ */ a.jsx(
3029
- bs,
3030
- {
3031
- className: B(
3032
- "bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0",
3033
- n
3034
- ),
3035
- "data-slot": "switch-thumb"
3036
- }
3037
- )
3038
- }
3039
- );
3040
- }
3041
- const Hs = ({
3042
- id: e,
3043
- label: n,
3044
- className: t,
3045
- thumbClassName: o,
3046
- labelClassName: r,
3047
- size: i = "md",
3048
- ...s
3049
- }) => {
3050
- const l = Ir(), d = e || l, [u, p] = Array.isArray(n) ? n : [null, n], f = "cursor-pointer", g = r && Array.isArray(r) ? r[0] : r, x = r && Array.isArray(r) ? r[1] : r;
3051
- return /* @__PURE__ */ a.jsxs("div", { className: "flex items-center space-x-2", children: [
3052
- u && /* @__PURE__ */ a.jsx(ue, { className: B(f, g), htmlFor: d, size: i, children: u }),
3053
- /* @__PURE__ */ a.jsx(
3054
- Ss,
3055
- {
3056
- className: B(
3057
- {
3058
- "h-[10px] w-4": i === "xs",
3059
- "h-[14px] w-6": i === "sm",
3060
- "h-[18px] w-8": i === "md",
3061
- "h-[22px] w-10": i === "lg",
3062
- "h-[26px] w-12": i === "xl"
3063
- },
3064
- t
3065
- ),
3066
- id: d,
3067
- thumbClassName: B(
3068
- {
3069
- "size-2": i === "xs",
3070
- "size-3": i === "sm",
3071
- "size-4": i === "md",
3072
- "size-5": i === "lg",
3073
- "size-6": i === "xl"
3074
- },
3075
- o
3076
- ),
3077
- ...s
3078
- }
3079
- ),
3080
- /* @__PURE__ */ a.jsx(ue, { className: B(f, x), htmlFor: d, size: i, children: p })
3081
- ] });
3082
- };
3083
- export {
3084
- Ns as C,
3085
- _s as D,
3086
- co as I,
3087
- ho as L,
3088
- As as P,
3089
- Os as R,
3090
- js as S,
3091
- Ts as a,
3092
- Ms as b,
3093
- Bs as c,
3094
- Fs as d,
3095
- Vs as e,
3096
- Hs as f,
3097
- Mt as g,
3098
- io as h
3099
- };