@still-forest/canopy 0.24.0 → 0.25.1

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.
@@ -0,0 +1,2449 @@
1
+ import { j as o, c as $ } from "./utils.js";
2
+ import { c as ee, u as G, h as Ue, B as et, i as Pr, j as Ie, d as Mr } from "./calendar.js";
3
+ import * as a from "react";
4
+ import ue, { useState as tt, useEffect as Ar, useMemo as Dr } from "react";
5
+ import { F as oe, G as Or } from "./Layout2.js";
6
+ import { T as _e } from "./Heading.js";
7
+ import { c as ge, e as mt, P, b as Re, d as F, s as ht, u as te, t as vt, a as xt, R as Fr, A as Lr, q as ne, f as Br, V as $r, v as Vr, w as Gr, x as Hr, F as Kr, D as Ur, C as zr, g as Wr, i as gt, j as bt, k as wt, l as qr, p as Yr, O as Xr, m as Zr } from "./popover.js";
8
+ import * as yt from "react-dom";
9
+ /**
10
+ * @license lucide-react v0.525.0 - ISC
11
+ *
12
+ * This source code is licensed under the ISC license.
13
+ * See the LICENSE file in the root directory of this source tree.
14
+ */
15
+ const Jr = [
16
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
17
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
18
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
19
+ ["path", { d: "M3 10h18", key: "8toen8" }]
20
+ ], Qr = ee("calendar", Jr);
21
+ /**
22
+ * @license lucide-react v0.525.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */
27
+ const eo = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], rt = ee("check", eo);
28
+ /**
29
+ * @license lucide-react v0.525.0 - ISC
30
+ *
31
+ * This source code is licensed under the ISC license.
32
+ * See the LICENSE file in the root directory of this source tree.
33
+ */
34
+ const to = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], St = ee("chevron-down", to);
35
+ /**
36
+ * @license lucide-react v0.525.0 - ISC
37
+ *
38
+ * This source code is licensed under the ISC license.
39
+ * See the LICENSE file in the root directory of this source tree.
40
+ */
41
+ const ro = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], oo = ee("chevron-up", ro);
42
+ /**
43
+ * @license lucide-react v0.525.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */
48
+ const no = [
49
+ ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
50
+ ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
51
+ ], ao = ee("chevrons-up-down", no);
52
+ /**
53
+ * @license lucide-react v0.525.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */
58
+ const so = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]], lo = ee("circle", so);
59
+ /**
60
+ * @license lucide-react v0.525.0 - ISC
61
+ *
62
+ * This source code is licensed under the ISC license.
63
+ * See the LICENSE file in the root directory of this source tree.
64
+ */
65
+ const co = [
66
+ ["path", { d: "M12 2v4", key: "3427ic" }],
67
+ ["path", { d: "m16.2 7.8 2.9-2.9", key: "r700ao" }],
68
+ ["path", { d: "M18 12h4", key: "wj9ykh" }],
69
+ ["path", { d: "m16.2 16.2 2.9 2.9", key: "1bxg5t" }],
70
+ ["path", { d: "M12 18v4", key: "jadmvz" }],
71
+ ["path", { d: "m4.9 19.1 2.9-2.9", key: "bwix9q" }],
72
+ ["path", { d: "M2 12h4", key: "j09sii" }],
73
+ ["path", { d: "m4.9 4.9 2.9 2.9", key: "giyufr" }]
74
+ ], io = ee("loader", co);
75
+ /**
76
+ * @license lucide-react v0.525.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */
81
+ const uo = [
82
+ [
83
+ "path",
84
+ {
85
+ 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",
86
+ key: "1c8476"
87
+ }
88
+ ],
89
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
90
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
91
+ ], po = ee("save", uo);
92
+ /**
93
+ * @license lucide-react v0.525.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */
98
+ const fo = [
99
+ ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
100
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
101
+ ], mo = ee("search", fo);
102
+ /**
103
+ * @license lucide-react v0.525.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */
108
+ const ho = [
109
+ [
110
+ "path",
111
+ {
112
+ 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",
113
+ key: "1ffxy3"
114
+ }
115
+ ],
116
+ ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
117
+ ], $e = ee("send", ho);
118
+ /**
119
+ * @license lucide-react v0.525.0 - ISC
120
+ *
121
+ * This source code is licensed under the ISC license.
122
+ * See the LICENSE file in the root directory of this source tree.
123
+ */
124
+ const vo = [
125
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
126
+ ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
127
+ ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
128
+ ["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
129
+ ["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
130
+ ], xo = ee("trash-2", vo);
131
+ function Ct(e) {
132
+ const r = e + "CollectionProvider", [t, s] = ge(r), [n, l] = t(
133
+ r,
134
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
135
+ ), c = (h) => {
136
+ const { scope: m, children: w } = h, x = ue.useRef(null), C = ue.useRef(/* @__PURE__ */ new Map()).current;
137
+ return /* @__PURE__ */ o.jsx(n, { scope: m, itemMap: C, collectionRef: x, children: w });
138
+ };
139
+ c.displayName = r;
140
+ const i = e + "CollectionSlot", u = Ue(i), d = ue.forwardRef(
141
+ (h, m) => {
142
+ const { scope: w, children: x } = h, C = l(i, w), N = G(m, C.collectionRef);
143
+ return /* @__PURE__ */ o.jsx(u, { ref: N, children: x });
144
+ }
145
+ );
146
+ d.displayName = i;
147
+ const p = e + "CollectionItemSlot", v = "data-radix-collection-item", y = Ue(p), b = ue.forwardRef(
148
+ (h, m) => {
149
+ const { scope: w, children: x, ...C } = h, N = ue.useRef(null), M = G(m, N), j = l(p, w);
150
+ return ue.useEffect(() => (j.itemMap.set(N, { ref: N, ...C }), () => void j.itemMap.delete(N))), /* @__PURE__ */ o.jsx(y, { [v]: "", ref: M, children: x });
151
+ }
152
+ );
153
+ b.displayName = p;
154
+ function S(h) {
155
+ const m = l(e + "CollectionConsumer", h);
156
+ return ue.useCallback(() => {
157
+ const x = m.collectionRef.current;
158
+ if (!x) return [];
159
+ const C = Array.from(x.querySelectorAll(`[${v}]`));
160
+ return Array.from(m.itemMap.values()).sort(
161
+ (j, E) => C.indexOf(j.ref.current) - C.indexOf(E.ref.current)
162
+ );
163
+ }, [m.collectionRef, m.itemMap]);
164
+ }
165
+ return [
166
+ { Provider: c, Slot: d, ItemSlot: b },
167
+ S,
168
+ s
169
+ ];
170
+ }
171
+ var go = a.createContext(void 0);
172
+ function ot(e) {
173
+ const r = a.useContext(go);
174
+ return e || r || "ltr";
175
+ }
176
+ function nt(e) {
177
+ const r = a.useRef({ value: e, previous: e });
178
+ return a.useMemo(() => (r.current.value !== e && (r.current.previous = r.current.value, r.current.value = e), r.current.previous), [e]);
179
+ }
180
+ var Te = "Checkbox", [bo, ja] = ge(Te), [wo, at] = bo(Te);
181
+ function yo(e) {
182
+ const {
183
+ __scopeCheckbox: r,
184
+ checked: t,
185
+ children: s,
186
+ defaultChecked: n,
187
+ disabled: l,
188
+ form: c,
189
+ name: i,
190
+ onCheckedChange: u,
191
+ required: d,
192
+ value: p = "on",
193
+ // @ts-expect-error
194
+ internal_do_not_use_render: v
195
+ } = e, [y, b] = Re({
196
+ prop: t,
197
+ defaultProp: n ?? !1,
198
+ onChange: u,
199
+ caller: Te
200
+ }), [S, h] = a.useState(null), [m, w] = a.useState(null), x = a.useRef(!1), C = S ? !!c || !!S.closest("form") : (
201
+ // We set this to true by default so that events bubble to forms without JS (SSR)
202
+ !0
203
+ ), N = {
204
+ checked: y,
205
+ disabled: l,
206
+ setChecked: b,
207
+ control: S,
208
+ setControl: h,
209
+ name: i,
210
+ form: c,
211
+ value: p,
212
+ hasConsumerStoppedPropagationRef: x,
213
+ required: d,
214
+ defaultChecked: re(n) ? !1 : n,
215
+ isFormControl: C,
216
+ bubbleInput: m,
217
+ setBubbleInput: w
218
+ };
219
+ return /* @__PURE__ */ o.jsx(
220
+ wo,
221
+ {
222
+ scope: r,
223
+ ...N,
224
+ children: So(v) ? v(N) : s
225
+ }
226
+ );
227
+ }
228
+ var It = "CheckboxTrigger", Rt = a.forwardRef(
229
+ ({ __scopeCheckbox: e, onKeyDown: r, onClick: t, ...s }, n) => {
230
+ const {
231
+ control: l,
232
+ value: c,
233
+ disabled: i,
234
+ checked: u,
235
+ required: d,
236
+ setControl: p,
237
+ setChecked: v,
238
+ hasConsumerStoppedPropagationRef: y,
239
+ isFormControl: b,
240
+ bubbleInput: S
241
+ } = at(It, e), h = G(n, p), m = a.useRef(u);
242
+ return a.useEffect(() => {
243
+ const w = l?.form;
244
+ if (w) {
245
+ const x = () => v(m.current);
246
+ return w.addEventListener("reset", x), () => w.removeEventListener("reset", x);
247
+ }
248
+ }, [l, v]), /* @__PURE__ */ o.jsx(
249
+ P.button,
250
+ {
251
+ type: "button",
252
+ role: "checkbox",
253
+ "aria-checked": re(u) ? "mixed" : u,
254
+ "aria-required": d,
255
+ "data-state": Tt(u),
256
+ "data-disabled": i ? "" : void 0,
257
+ disabled: i,
258
+ value: c,
259
+ ...s,
260
+ ref: h,
261
+ onKeyDown: F(r, (w) => {
262
+ w.key === "Enter" && w.preventDefault();
263
+ }),
264
+ onClick: F(t, (w) => {
265
+ v((x) => re(x) ? !0 : !x), S && b && (y.current = w.isPropagationStopped(), y.current || w.stopPropagation());
266
+ })
267
+ }
268
+ );
269
+ }
270
+ );
271
+ Rt.displayName = It;
272
+ var kt = a.forwardRef(
273
+ (e, r) => {
274
+ const {
275
+ __scopeCheckbox: t,
276
+ name: s,
277
+ checked: n,
278
+ defaultChecked: l,
279
+ required: c,
280
+ disabled: i,
281
+ value: u,
282
+ onCheckedChange: d,
283
+ form: p,
284
+ ...v
285
+ } = e;
286
+ return /* @__PURE__ */ o.jsx(
287
+ yo,
288
+ {
289
+ __scopeCheckbox: t,
290
+ checked: n,
291
+ defaultChecked: l,
292
+ disabled: i,
293
+ required: c,
294
+ onCheckedChange: d,
295
+ name: s,
296
+ form: p,
297
+ value: u,
298
+ internal_do_not_use_render: ({ isFormControl: y }) => /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
299
+ /* @__PURE__ */ o.jsx(
300
+ Rt,
301
+ {
302
+ ...v,
303
+ ref: r,
304
+ __scopeCheckbox: t
305
+ }
306
+ ),
307
+ y && /* @__PURE__ */ o.jsx(
308
+ _t,
309
+ {
310
+ __scopeCheckbox: t
311
+ }
312
+ )
313
+ ] })
314
+ }
315
+ );
316
+ }
317
+ );
318
+ kt.displayName = Te;
319
+ var Et = "CheckboxIndicator", jt = a.forwardRef(
320
+ (e, r) => {
321
+ const { __scopeCheckbox: t, forceMount: s, ...n } = e, l = at(Et, t);
322
+ return /* @__PURE__ */ o.jsx(
323
+ mt,
324
+ {
325
+ present: s || re(l.checked) || l.checked === !0,
326
+ children: /* @__PURE__ */ o.jsx(
327
+ P.span,
328
+ {
329
+ "data-state": Tt(l.checked),
330
+ "data-disabled": l.disabled ? "" : void 0,
331
+ ...n,
332
+ ref: r,
333
+ style: { pointerEvents: "none", ...e.style }
334
+ }
335
+ )
336
+ }
337
+ );
338
+ }
339
+ );
340
+ jt.displayName = Et;
341
+ var Nt = "CheckboxBubbleInput", _t = a.forwardRef(
342
+ ({ __scopeCheckbox: e, ...r }, t) => {
343
+ const {
344
+ control: s,
345
+ hasConsumerStoppedPropagationRef: n,
346
+ checked: l,
347
+ defaultChecked: c,
348
+ required: i,
349
+ disabled: u,
350
+ name: d,
351
+ value: p,
352
+ form: v,
353
+ bubbleInput: y,
354
+ setBubbleInput: b
355
+ } = at(Nt, e), S = G(t, b), h = nt(l), m = ht(s);
356
+ a.useEffect(() => {
357
+ const x = y;
358
+ if (!x) return;
359
+ const C = window.HTMLInputElement.prototype, M = Object.getOwnPropertyDescriptor(
360
+ C,
361
+ "checked"
362
+ ).set, j = !n.current;
363
+ if (h !== l && M) {
364
+ const E = new Event("click", { bubbles: j });
365
+ x.indeterminate = re(l), M.call(x, re(l) ? !1 : l), x.dispatchEvent(E);
366
+ }
367
+ }, [y, h, l, n]);
368
+ const w = a.useRef(re(l) ? !1 : l);
369
+ return /* @__PURE__ */ o.jsx(
370
+ P.input,
371
+ {
372
+ type: "checkbox",
373
+ "aria-hidden": !0,
374
+ defaultChecked: c ?? w.current,
375
+ required: i,
376
+ disabled: u,
377
+ name: d,
378
+ value: p,
379
+ form: v,
380
+ ...r,
381
+ tabIndex: -1,
382
+ ref: S,
383
+ style: {
384
+ ...r.style,
385
+ ...m,
386
+ position: "absolute",
387
+ pointerEvents: "none",
388
+ opacity: 0,
389
+ margin: 0,
390
+ // We transform because the input is absolutely positioned but we have
391
+ // rendered it **after** the button. This pulls it back to sit on top
392
+ // of the button.
393
+ transform: "translateX(-100%)"
394
+ }
395
+ }
396
+ );
397
+ }
398
+ );
399
+ _t.displayName = Nt;
400
+ function So(e) {
401
+ return typeof e == "function";
402
+ }
403
+ function re(e) {
404
+ return e === "indeterminate";
405
+ }
406
+ function Tt(e) {
407
+ return re(e) ? "indeterminate" : e ? "checked" : "unchecked";
408
+ }
409
+ var Ve = "rovingFocusGroup.onEntryFocus", Co = { bubbles: !1, cancelable: !0 }, ke = "RovingFocusGroup", [ze, Pt, Io] = Ct(ke), [Ro, Mt] = ge(
410
+ ke,
411
+ [Io]
412
+ ), [ko, Eo] = Ro(ke), At = a.forwardRef(
413
+ (e, r) => /* @__PURE__ */ o.jsx(ze.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ o.jsx(ze.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ o.jsx(jo, { ...e, ref: r }) }) })
414
+ );
415
+ At.displayName = ke;
416
+ var jo = a.forwardRef((e, r) => {
417
+ const {
418
+ __scopeRovingFocusGroup: t,
419
+ orientation: s,
420
+ loop: n = !1,
421
+ dir: l,
422
+ currentTabStopId: c,
423
+ defaultCurrentTabStopId: i,
424
+ onCurrentTabStopIdChange: u,
425
+ onEntryFocus: d,
426
+ preventScrollOnEntryFocus: p = !1,
427
+ ...v
428
+ } = e, y = a.useRef(null), b = G(r, y), S = ot(l), [h, m] = Re({
429
+ prop: c,
430
+ defaultProp: i ?? null,
431
+ onChange: u,
432
+ caller: ke
433
+ }), [w, x] = a.useState(!1), C = vt(d), N = Pt(t), M = a.useRef(!1), [j, E] = a.useState(0);
434
+ return a.useEffect(() => {
435
+ const D = y.current;
436
+ if (D)
437
+ return D.addEventListener(Ve, C), () => D.removeEventListener(Ve, C);
438
+ }, [C]), /* @__PURE__ */ o.jsx(
439
+ ko,
440
+ {
441
+ scope: t,
442
+ orientation: s,
443
+ dir: S,
444
+ loop: n,
445
+ currentTabStopId: h,
446
+ onItemFocus: a.useCallback(
447
+ (D) => m(D),
448
+ [m]
449
+ ),
450
+ onItemShiftTab: a.useCallback(() => x(!0), []),
451
+ onFocusableItemAdd: a.useCallback(
452
+ () => E((D) => D + 1),
453
+ []
454
+ ),
455
+ onFocusableItemRemove: a.useCallback(
456
+ () => E((D) => D - 1),
457
+ []
458
+ ),
459
+ children: /* @__PURE__ */ o.jsx(
460
+ P.div,
461
+ {
462
+ tabIndex: w || j === 0 ? -1 : 0,
463
+ "data-orientation": s,
464
+ ...v,
465
+ ref: b,
466
+ style: { outline: "none", ...e.style },
467
+ onMouseDown: F(e.onMouseDown, () => {
468
+ M.current = !0;
469
+ }),
470
+ onFocus: F(e.onFocus, (D) => {
471
+ const Y = !M.current;
472
+ if (D.target === D.currentTarget && Y && !w) {
473
+ const W = new CustomEvent(Ve, Co);
474
+ if (D.currentTarget.dispatchEvent(W), !W.defaultPrevented) {
475
+ const H = N().filter((L) => L.focusable), z = H.find((L) => L.active), X = H.find((L) => L.id === h), U = [z, X, ...H].filter(
476
+ Boolean
477
+ ).map((L) => L.ref.current);
478
+ Ft(U, p);
479
+ }
480
+ }
481
+ M.current = !1;
482
+ }),
483
+ onBlur: F(e.onBlur, () => x(!1))
484
+ }
485
+ )
486
+ }
487
+ );
488
+ }), Dt = "RovingFocusGroupItem", Ot = a.forwardRef(
489
+ (e, r) => {
490
+ const {
491
+ __scopeRovingFocusGroup: t,
492
+ focusable: s = !0,
493
+ active: n = !1,
494
+ tabStopId: l,
495
+ children: c,
496
+ ...i
497
+ } = e, u = te(), d = l || u, p = Eo(Dt, t), v = p.currentTabStopId === d, y = Pt(t), { onFocusableItemAdd: b, onFocusableItemRemove: S, currentTabStopId: h } = p;
498
+ return a.useEffect(() => {
499
+ if (s)
500
+ return b(), () => S();
501
+ }, [s, b, S]), /* @__PURE__ */ o.jsx(
502
+ ze.ItemSlot,
503
+ {
504
+ scope: t,
505
+ id: d,
506
+ focusable: s,
507
+ active: n,
508
+ children: /* @__PURE__ */ o.jsx(
509
+ P.span,
510
+ {
511
+ tabIndex: v ? 0 : -1,
512
+ "data-orientation": p.orientation,
513
+ ...i,
514
+ ref: r,
515
+ onMouseDown: F(e.onMouseDown, (m) => {
516
+ s ? p.onItemFocus(d) : m.preventDefault();
517
+ }),
518
+ onFocus: F(e.onFocus, () => p.onItemFocus(d)),
519
+ onKeyDown: F(e.onKeyDown, (m) => {
520
+ if (m.key === "Tab" && m.shiftKey) {
521
+ p.onItemShiftTab();
522
+ return;
523
+ }
524
+ if (m.target !== m.currentTarget) return;
525
+ const w = To(m, p.orientation, p.dir);
526
+ if (w !== void 0) {
527
+ if (m.metaKey || m.ctrlKey || m.altKey || m.shiftKey) return;
528
+ m.preventDefault();
529
+ let C = y().filter((N) => N.focusable).map((N) => N.ref.current);
530
+ if (w === "last") C.reverse();
531
+ else if (w === "prev" || w === "next") {
532
+ w === "prev" && C.reverse();
533
+ const N = C.indexOf(m.currentTarget);
534
+ C = p.loop ? Po(C, N + 1) : C.slice(N + 1);
535
+ }
536
+ setTimeout(() => Ft(C));
537
+ }
538
+ }),
539
+ children: typeof c == "function" ? c({ isCurrentTabStop: v, hasTabStop: h != null }) : c
540
+ }
541
+ )
542
+ }
543
+ );
544
+ }
545
+ );
546
+ Ot.displayName = Dt;
547
+ var No = {
548
+ ArrowLeft: "prev",
549
+ ArrowUp: "prev",
550
+ ArrowRight: "next",
551
+ ArrowDown: "next",
552
+ PageUp: "first",
553
+ Home: "first",
554
+ PageDown: "last",
555
+ End: "last"
556
+ };
557
+ function _o(e, r) {
558
+ return r !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
559
+ }
560
+ function To(e, r, t) {
561
+ const s = _o(e.key, t);
562
+ if (!(r === "vertical" && ["ArrowLeft", "ArrowRight"].includes(s)) && !(r === "horizontal" && ["ArrowUp", "ArrowDown"].includes(s)))
563
+ return No[s];
564
+ }
565
+ function Ft(e, r = !1) {
566
+ const t = document.activeElement;
567
+ for (const s of e)
568
+ if (s === t || (s.focus({ preventScroll: r }), document.activeElement !== t)) return;
569
+ }
570
+ function Po(e, r) {
571
+ return e.map((t, s) => e[(r + s) % e.length]);
572
+ }
573
+ var Mo = At, Ao = Ot, Do = "Label", Lt = a.forwardRef((e, r) => /* @__PURE__ */ o.jsx(
574
+ P.label,
575
+ {
576
+ ...e,
577
+ ref: r,
578
+ onMouseDown: (t) => {
579
+ t.target.closest("button, input, select, textarea") || (e.onMouseDown?.(t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
580
+ }
581
+ }
582
+ ));
583
+ Lt.displayName = Do;
584
+ var Oo = Lt;
585
+ function it(e, [r, t]) {
586
+ return Math.min(t, Math.max(r, e));
587
+ }
588
+ var st = "Radio", [Fo, Bt] = ge(st), [Lo, Bo] = Fo(st), $t = a.forwardRef(
589
+ (e, r) => {
590
+ const {
591
+ __scopeRadio: t,
592
+ name: s,
593
+ checked: n = !1,
594
+ required: l,
595
+ disabled: c,
596
+ value: i = "on",
597
+ onCheck: u,
598
+ form: d,
599
+ ...p
600
+ } = e, [v, y] = a.useState(null), b = G(r, (m) => y(m)), S = a.useRef(!1), h = v ? d || !!v.closest("form") : !0;
601
+ return /* @__PURE__ */ o.jsxs(Lo, { scope: t, checked: n, disabled: c, children: [
602
+ /* @__PURE__ */ o.jsx(
603
+ P.button,
604
+ {
605
+ type: "button",
606
+ role: "radio",
607
+ "aria-checked": n,
608
+ "data-state": Kt(n),
609
+ "data-disabled": c ? "" : void 0,
610
+ disabled: c,
611
+ value: i,
612
+ ...p,
613
+ ref: b,
614
+ onClick: F(e.onClick, (m) => {
615
+ n || u?.(), h && (S.current = m.isPropagationStopped(), S.current || m.stopPropagation());
616
+ })
617
+ }
618
+ ),
619
+ h && /* @__PURE__ */ o.jsx(
620
+ Ht,
621
+ {
622
+ control: v,
623
+ bubbles: !S.current,
624
+ name: s,
625
+ value: i,
626
+ checked: n,
627
+ required: l,
628
+ disabled: c,
629
+ form: d,
630
+ style: { transform: "translateX(-100%)" }
631
+ }
632
+ )
633
+ ] });
634
+ }
635
+ );
636
+ $t.displayName = st;
637
+ var Vt = "RadioIndicator", Gt = a.forwardRef(
638
+ (e, r) => {
639
+ const { __scopeRadio: t, forceMount: s, ...n } = e, l = Bo(Vt, t);
640
+ return /* @__PURE__ */ o.jsx(mt, { present: s || l.checked, children: /* @__PURE__ */ o.jsx(
641
+ P.span,
642
+ {
643
+ "data-state": Kt(l.checked),
644
+ "data-disabled": l.disabled ? "" : void 0,
645
+ ...n,
646
+ ref: r
647
+ }
648
+ ) });
649
+ }
650
+ );
651
+ Gt.displayName = Vt;
652
+ var $o = "RadioBubbleInput", Ht = a.forwardRef(
653
+ ({
654
+ __scopeRadio: e,
655
+ control: r,
656
+ checked: t,
657
+ bubbles: s = !0,
658
+ ...n
659
+ }, l) => {
660
+ const c = a.useRef(null), i = G(c, l), u = nt(t), d = ht(r);
661
+ return a.useEffect(() => {
662
+ const p = c.current;
663
+ if (!p) return;
664
+ const v = window.HTMLInputElement.prototype, b = Object.getOwnPropertyDescriptor(
665
+ v,
666
+ "checked"
667
+ ).set;
668
+ if (u !== t && b) {
669
+ const S = new Event("click", { bubbles: s });
670
+ b.call(p, t), p.dispatchEvent(S);
671
+ }
672
+ }, [u, t, s]), /* @__PURE__ */ o.jsx(
673
+ P.input,
674
+ {
675
+ type: "radio",
676
+ "aria-hidden": !0,
677
+ defaultChecked: t,
678
+ ...n,
679
+ tabIndex: -1,
680
+ ref: i,
681
+ style: {
682
+ ...n.style,
683
+ ...d,
684
+ position: "absolute",
685
+ pointerEvents: "none",
686
+ opacity: 0,
687
+ margin: 0
688
+ }
689
+ }
690
+ );
691
+ }
692
+ );
693
+ Ht.displayName = $o;
694
+ function Kt(e) {
695
+ return e ? "checked" : "unchecked";
696
+ }
697
+ var Vo = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], Pe = "RadioGroup", [Go, Na] = ge(Pe, [
698
+ Mt,
699
+ Bt
700
+ ]), Ut = Mt(), zt = Bt(), [Ho, Ko] = Go(Pe), Wt = a.forwardRef(
701
+ (e, r) => {
702
+ const {
703
+ __scopeRadioGroup: t,
704
+ name: s,
705
+ defaultValue: n,
706
+ value: l,
707
+ required: c = !1,
708
+ disabled: i = !1,
709
+ orientation: u,
710
+ dir: d,
711
+ loop: p = !0,
712
+ onValueChange: v,
713
+ ...y
714
+ } = e, b = Ut(t), S = ot(d), [h, m] = Re({
715
+ prop: l,
716
+ defaultProp: n ?? null,
717
+ onChange: v,
718
+ caller: Pe
719
+ });
720
+ return /* @__PURE__ */ o.jsx(
721
+ Ho,
722
+ {
723
+ scope: t,
724
+ name: s,
725
+ required: c,
726
+ disabled: i,
727
+ value: h,
728
+ onValueChange: m,
729
+ children: /* @__PURE__ */ o.jsx(
730
+ Mo,
731
+ {
732
+ asChild: !0,
733
+ ...b,
734
+ orientation: u,
735
+ dir: S,
736
+ loop: p,
737
+ children: /* @__PURE__ */ o.jsx(
738
+ P.div,
739
+ {
740
+ role: "radiogroup",
741
+ "aria-required": c,
742
+ "aria-orientation": u,
743
+ "data-disabled": i ? "" : void 0,
744
+ dir: S,
745
+ ...y,
746
+ ref: r
747
+ }
748
+ )
749
+ }
750
+ )
751
+ }
752
+ );
753
+ }
754
+ );
755
+ Wt.displayName = Pe;
756
+ var qt = "RadioGroupItem", Yt = a.forwardRef(
757
+ (e, r) => {
758
+ const { __scopeRadioGroup: t, disabled: s, ...n } = e, l = Ko(qt, t), c = l.disabled || s, i = Ut(t), u = zt(t), d = a.useRef(null), p = G(r, d), v = l.value === n.value, y = a.useRef(!1);
759
+ return a.useEffect(() => {
760
+ const b = (h) => {
761
+ Vo.includes(h.key) && (y.current = !0);
762
+ }, S = () => y.current = !1;
763
+ return document.addEventListener("keydown", b), document.addEventListener("keyup", S), () => {
764
+ document.removeEventListener("keydown", b), document.removeEventListener("keyup", S);
765
+ };
766
+ }, []), /* @__PURE__ */ o.jsx(
767
+ Ao,
768
+ {
769
+ asChild: !0,
770
+ ...i,
771
+ focusable: !c,
772
+ active: v,
773
+ children: /* @__PURE__ */ o.jsx(
774
+ $t,
775
+ {
776
+ disabled: c,
777
+ required: l.required,
778
+ checked: v,
779
+ ...u,
780
+ ...n,
781
+ name: l.name,
782
+ ref: p,
783
+ onCheck: () => l.onValueChange(n.value),
784
+ onKeyDown: F((b) => {
785
+ b.key === "Enter" && b.preventDefault();
786
+ }),
787
+ onFocus: F(n.onFocus, () => {
788
+ y.current && d.current?.click();
789
+ })
790
+ }
791
+ )
792
+ }
793
+ );
794
+ }
795
+ );
796
+ Yt.displayName = qt;
797
+ var Uo = "RadioGroupIndicator", Xt = a.forwardRef(
798
+ (e, r) => {
799
+ const { __scopeRadioGroup: t, ...s } = e, n = zt(t);
800
+ return /* @__PURE__ */ o.jsx(Gt, { ...n, ...s, ref: r });
801
+ }
802
+ );
803
+ Xt.displayName = Uo;
804
+ var zo = Wt, Wo = Yt, qo = Xt, Yo = [" ", "Enter", "ArrowUp", "ArrowDown"], Xo = [" ", "Enter"], pe = "Select", [Me, Ae, Zo] = Ct(pe), [be, _a] = ge(pe, [
805
+ Zo,
806
+ xt
807
+ ]), De = xt(), [Jo, se] = be(pe), [Qo, en] = be(pe), Zt = (e) => {
808
+ const {
809
+ __scopeSelect: r,
810
+ children: t,
811
+ open: s,
812
+ defaultOpen: n,
813
+ onOpenChange: l,
814
+ value: c,
815
+ defaultValue: i,
816
+ onValueChange: u,
817
+ dir: d,
818
+ name: p,
819
+ autoComplete: v,
820
+ disabled: y,
821
+ required: b,
822
+ form: S
823
+ } = e, h = De(r), [m, w] = a.useState(null), [x, C] = a.useState(null), [N, M] = a.useState(!1), j = ot(d), [E, D] = Re({
824
+ prop: s,
825
+ defaultProp: n ?? !1,
826
+ onChange: l,
827
+ caller: pe
828
+ }), [Y, W] = Re({
829
+ prop: c,
830
+ defaultProp: i,
831
+ onChange: u,
832
+ caller: pe
833
+ }), H = a.useRef(null), z = m ? S || !!m.closest("form") : !0, [X, K] = a.useState(/* @__PURE__ */ new Set()), U = Array.from(X).map((L) => L.props.value).join(";");
834
+ return /* @__PURE__ */ o.jsx(Fr, { ...h, children: /* @__PURE__ */ o.jsxs(
835
+ Jo,
836
+ {
837
+ required: b,
838
+ scope: r,
839
+ trigger: m,
840
+ onTriggerChange: w,
841
+ valueNode: x,
842
+ onValueNodeChange: C,
843
+ valueNodeHasChildren: N,
844
+ onValueNodeHasChildrenChange: M,
845
+ contentId: te(),
846
+ value: Y,
847
+ onValueChange: W,
848
+ open: E,
849
+ onOpenChange: D,
850
+ dir: j,
851
+ triggerPointerDownPosRef: H,
852
+ disabled: y,
853
+ children: [
854
+ /* @__PURE__ */ o.jsx(Me.Provider, { scope: r, children: /* @__PURE__ */ o.jsx(
855
+ Qo,
856
+ {
857
+ scope: e.__scopeSelect,
858
+ onNativeOptionAdd: a.useCallback((L) => {
859
+ K((q) => new Set(q).add(L));
860
+ }, []),
861
+ onNativeOptionRemove: a.useCallback((L) => {
862
+ K((q) => {
863
+ const Z = new Set(q);
864
+ return Z.delete(L), Z;
865
+ });
866
+ }, []),
867
+ children: t
868
+ }
869
+ ) }),
870
+ z ? /* @__PURE__ */ o.jsxs(
871
+ br,
872
+ {
873
+ "aria-hidden": !0,
874
+ required: b,
875
+ tabIndex: -1,
876
+ name: p,
877
+ autoComplete: v,
878
+ value: Y,
879
+ onChange: (L) => W(L.target.value),
880
+ disabled: y,
881
+ form: S,
882
+ children: [
883
+ Y === void 0 ? /* @__PURE__ */ o.jsx("option", { value: "" }) : null,
884
+ Array.from(X)
885
+ ]
886
+ },
887
+ U
888
+ ) : null
889
+ ]
890
+ }
891
+ ) });
892
+ };
893
+ Zt.displayName = pe;
894
+ var Jt = "SelectTrigger", Qt = a.forwardRef(
895
+ (e, r) => {
896
+ const { __scopeSelect: t, disabled: s = !1, ...n } = e, l = De(t), c = se(Jt, t), i = c.disabled || s, u = G(r, c.onTriggerChange), d = Ae(t), p = a.useRef("touch"), [v, y, b] = yr((h) => {
897
+ const m = d().filter((C) => !C.disabled), w = m.find((C) => C.value === c.value), x = Sr(m, h, w);
898
+ x !== void 0 && c.onValueChange(x.value);
899
+ }), S = (h) => {
900
+ i || (c.onOpenChange(!0), b()), h && (c.triggerPointerDownPosRef.current = {
901
+ x: Math.round(h.pageX),
902
+ y: Math.round(h.pageY)
903
+ });
904
+ };
905
+ return /* @__PURE__ */ o.jsx(Lr, { asChild: !0, ...l, children: /* @__PURE__ */ o.jsx(
906
+ P.button,
907
+ {
908
+ type: "button",
909
+ role: "combobox",
910
+ "aria-controls": c.contentId,
911
+ "aria-expanded": c.open,
912
+ "aria-required": c.required,
913
+ "aria-autocomplete": "none",
914
+ dir: c.dir,
915
+ "data-state": c.open ? "open" : "closed",
916
+ disabled: i,
917
+ "data-disabled": i ? "" : void 0,
918
+ "data-placeholder": wr(c.value) ? "" : void 0,
919
+ ...n,
920
+ ref: u,
921
+ onClick: F(n.onClick, (h) => {
922
+ h.currentTarget.focus(), p.current !== "mouse" && S(h);
923
+ }),
924
+ onPointerDown: F(n.onPointerDown, (h) => {
925
+ p.current = h.pointerType;
926
+ const m = h.target;
927
+ m.hasPointerCapture(h.pointerId) && m.releasePointerCapture(h.pointerId), h.button === 0 && h.ctrlKey === !1 && h.pointerType === "mouse" && (S(h), h.preventDefault());
928
+ }),
929
+ onKeyDown: F(n.onKeyDown, (h) => {
930
+ const m = v.current !== "";
931
+ !(h.ctrlKey || h.altKey || h.metaKey) && h.key.length === 1 && y(h.key), !(m && h.key === " ") && Yo.includes(h.key) && (S(), h.preventDefault());
932
+ })
933
+ }
934
+ ) });
935
+ }
936
+ );
937
+ Qt.displayName = Jt;
938
+ var er = "SelectValue", tr = a.forwardRef(
939
+ (e, r) => {
940
+ const { __scopeSelect: t, className: s, style: n, children: l, placeholder: c = "", ...i } = e, u = se(er, t), { onValueNodeHasChildrenChange: d } = u, p = l !== void 0, v = G(r, u.onValueNodeChange);
941
+ return ne(() => {
942
+ d(p);
943
+ }, [d, p]), /* @__PURE__ */ o.jsx(
944
+ P.span,
945
+ {
946
+ ...i,
947
+ ref: v,
948
+ style: { pointerEvents: "none" },
949
+ children: wr(u.value) ? /* @__PURE__ */ o.jsx(o.Fragment, { children: c }) : l
950
+ }
951
+ );
952
+ }
953
+ );
954
+ tr.displayName = er;
955
+ var tn = "SelectIcon", rr = a.forwardRef(
956
+ (e, r) => {
957
+ const { __scopeSelect: t, children: s, ...n } = e;
958
+ return /* @__PURE__ */ o.jsx(P.span, { "aria-hidden": !0, ...n, ref: r, children: s || "▼" });
959
+ }
960
+ );
961
+ rr.displayName = tn;
962
+ var rn = "SelectPortal", or = (e) => /* @__PURE__ */ o.jsx(Br, { asChild: !0, ...e });
963
+ or.displayName = rn;
964
+ var fe = "SelectContent", nr = a.forwardRef(
965
+ (e, r) => {
966
+ const t = se(fe, e.__scopeSelect), [s, n] = a.useState();
967
+ if (ne(() => {
968
+ n(new DocumentFragment());
969
+ }, []), !t.open) {
970
+ const l = s;
971
+ return l ? yt.createPortal(
972
+ /* @__PURE__ */ o.jsx(ar, { scope: e.__scopeSelect, children: /* @__PURE__ */ o.jsx(Me.Slot, { scope: e.__scopeSelect, children: /* @__PURE__ */ o.jsx("div", { children: e.children }) }) }),
973
+ l
974
+ ) : null;
975
+ }
976
+ return /* @__PURE__ */ o.jsx(sr, { ...e, ref: r });
977
+ }
978
+ );
979
+ nr.displayName = fe;
980
+ var Q = 10, [ar, le] = be(fe), on = "SelectContentImpl", nn = Ue("SelectContent.RemoveScroll"), sr = a.forwardRef(
981
+ (e, r) => {
982
+ const {
983
+ __scopeSelect: t,
984
+ position: s = "item-aligned",
985
+ onCloseAutoFocus: n,
986
+ onEscapeKeyDown: l,
987
+ onPointerDownOutside: c,
988
+ //
989
+ // PopperContent props
990
+ side: i,
991
+ sideOffset: u,
992
+ align: d,
993
+ alignOffset: p,
994
+ arrowPadding: v,
995
+ collisionBoundary: y,
996
+ collisionPadding: b,
997
+ sticky: S,
998
+ hideWhenDetached: h,
999
+ avoidCollisions: m,
1000
+ //
1001
+ ...w
1002
+ } = e, x = se(fe, t), [C, N] = a.useState(null), [M, j] = a.useState(null), E = G(r, (g) => N(g)), [D, Y] = a.useState(null), [W, H] = a.useState(
1003
+ null
1004
+ ), z = Ae(t), [X, K] = a.useState(!1), U = a.useRef(!1);
1005
+ a.useEffect(() => {
1006
+ if (C) return Vr(C);
1007
+ }, [C]), Gr();
1008
+ const L = a.useCallback(
1009
+ (g) => {
1010
+ const [T, ...A] = z().map((V) => V.ref.current), [O] = A.slice(-1), B = document.activeElement;
1011
+ for (const V of g)
1012
+ if (V === B || (V?.scrollIntoView({ block: "nearest" }), V === T && M && (M.scrollTop = 0), V === O && M && (M.scrollTop = M.scrollHeight), V?.focus(), document.activeElement !== B)) return;
1013
+ },
1014
+ [z, M]
1015
+ ), q = a.useCallback(
1016
+ () => L([D, C]),
1017
+ [L, D, C]
1018
+ );
1019
+ a.useEffect(() => {
1020
+ X && q();
1021
+ }, [X, q]);
1022
+ const { onOpenChange: Z, triggerPointerDownPosRef: J } = x;
1023
+ a.useEffect(() => {
1024
+ if (C) {
1025
+ let g = { x: 0, y: 0 };
1026
+ const T = (O) => {
1027
+ g = {
1028
+ x: Math.abs(Math.round(O.pageX) - (J.current?.x ?? 0)),
1029
+ y: Math.abs(Math.round(O.pageY) - (J.current?.y ?? 0))
1030
+ };
1031
+ }, A = (O) => {
1032
+ g.x <= 10 && g.y <= 10 ? O.preventDefault() : C.contains(O.target) || Z(!1), document.removeEventListener("pointermove", T), J.current = null;
1033
+ };
1034
+ return J.current !== null && (document.addEventListener("pointermove", T), document.addEventListener("pointerup", A, { capture: !0, once: !0 })), () => {
1035
+ document.removeEventListener("pointermove", T), document.removeEventListener("pointerup", A, { capture: !0 });
1036
+ };
1037
+ }
1038
+ }, [C, Z, J]), a.useEffect(() => {
1039
+ const g = () => Z(!1);
1040
+ return window.addEventListener("blur", g), window.addEventListener("resize", g), () => {
1041
+ window.removeEventListener("blur", g), window.removeEventListener("resize", g);
1042
+ };
1043
+ }, [Z]);
1044
+ const [he, ce] = yr((g) => {
1045
+ const T = z().filter((B) => !B.disabled), A = T.find((B) => B.ref.current === document.activeElement), O = Sr(T, g, A);
1046
+ O && setTimeout(() => O.ref.current.focus());
1047
+ }), f = a.useCallback(
1048
+ (g, T, A) => {
1049
+ const O = !U.current && !A;
1050
+ (x.value !== void 0 && x.value === T || O) && (Y(g), O && (U.current = !0));
1051
+ },
1052
+ [x.value]
1053
+ ), R = a.useCallback(() => C?.focus(), [C]), k = a.useCallback(
1054
+ (g, T, A) => {
1055
+ const O = !U.current && !A;
1056
+ (x.value !== void 0 && x.value === T || O) && H(g);
1057
+ },
1058
+ [x.value]
1059
+ ), I = s === "popper" ? We : lr, _ = I === We ? {
1060
+ side: i,
1061
+ sideOffset: u,
1062
+ align: d,
1063
+ alignOffset: p,
1064
+ arrowPadding: v,
1065
+ collisionBoundary: y,
1066
+ collisionPadding: b,
1067
+ sticky: S,
1068
+ hideWhenDetached: h,
1069
+ avoidCollisions: m
1070
+ } : {};
1071
+ return /* @__PURE__ */ o.jsx(
1072
+ ar,
1073
+ {
1074
+ scope: t,
1075
+ content: C,
1076
+ viewport: M,
1077
+ onViewportChange: j,
1078
+ itemRefCallback: f,
1079
+ selectedItem: D,
1080
+ onItemLeave: R,
1081
+ itemTextRefCallback: k,
1082
+ focusSelectedItem: q,
1083
+ selectedItemText: W,
1084
+ position: s,
1085
+ isPositioned: X,
1086
+ searchRef: he,
1087
+ children: /* @__PURE__ */ o.jsx(Hr, { as: nn, allowPinchZoom: !0, children: /* @__PURE__ */ o.jsx(
1088
+ Kr,
1089
+ {
1090
+ asChild: !0,
1091
+ trapped: x.open,
1092
+ onMountAutoFocus: (g) => {
1093
+ g.preventDefault();
1094
+ },
1095
+ onUnmountAutoFocus: F(n, (g) => {
1096
+ x.trigger?.focus({ preventScroll: !0 }), g.preventDefault();
1097
+ }),
1098
+ children: /* @__PURE__ */ o.jsx(
1099
+ Ur,
1100
+ {
1101
+ asChild: !0,
1102
+ disableOutsidePointerEvents: !0,
1103
+ onEscapeKeyDown: l,
1104
+ onPointerDownOutside: c,
1105
+ onFocusOutside: (g) => g.preventDefault(),
1106
+ onDismiss: () => x.onOpenChange(!1),
1107
+ children: /* @__PURE__ */ o.jsx(
1108
+ I,
1109
+ {
1110
+ role: "listbox",
1111
+ id: x.contentId,
1112
+ "data-state": x.open ? "open" : "closed",
1113
+ dir: x.dir,
1114
+ onContextMenu: (g) => g.preventDefault(),
1115
+ ...w,
1116
+ ..._,
1117
+ onPlaced: () => K(!0),
1118
+ ref: E,
1119
+ style: {
1120
+ // flex layout so we can place the scroll buttons properly
1121
+ display: "flex",
1122
+ flexDirection: "column",
1123
+ // reset the outline by default as the content MAY get focused
1124
+ outline: "none",
1125
+ ...w.style
1126
+ },
1127
+ onKeyDown: F(w.onKeyDown, (g) => {
1128
+ const T = g.ctrlKey || g.altKey || g.metaKey;
1129
+ if (g.key === "Tab" && g.preventDefault(), !T && g.key.length === 1 && ce(g.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(g.key)) {
1130
+ let O = z().filter((B) => !B.disabled).map((B) => B.ref.current);
1131
+ if (["ArrowUp", "End"].includes(g.key) && (O = O.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(g.key)) {
1132
+ const B = g.target, V = O.indexOf(B);
1133
+ O = O.slice(V + 1);
1134
+ }
1135
+ setTimeout(() => L(O)), g.preventDefault();
1136
+ }
1137
+ })
1138
+ }
1139
+ )
1140
+ }
1141
+ )
1142
+ }
1143
+ ) })
1144
+ }
1145
+ );
1146
+ }
1147
+ );
1148
+ sr.displayName = on;
1149
+ var an = "SelectItemAlignedPosition", lr = a.forwardRef((e, r) => {
1150
+ const { __scopeSelect: t, onPlaced: s, ...n } = e, l = se(fe, t), c = le(fe, t), [i, u] = a.useState(null), [d, p] = a.useState(null), v = G(r, (E) => p(E)), y = Ae(t), b = a.useRef(!1), S = a.useRef(!0), { viewport: h, selectedItem: m, selectedItemText: w, focusSelectedItem: x } = c, C = a.useCallback(() => {
1151
+ if (l.trigger && l.valueNode && i && d && h && m && w) {
1152
+ const E = l.trigger.getBoundingClientRect(), D = d.getBoundingClientRect(), Y = l.valueNode.getBoundingClientRect(), W = w.getBoundingClientRect();
1153
+ if (l.dir !== "rtl") {
1154
+ const B = W.left - D.left, V = Y.left - B, ie = E.left - V, de = E.width + ie, Fe = Math.max(de, D.width), Le = window.innerWidth - Q, Be = it(V, [
1155
+ Q,
1156
+ // Prevents the content from going off the starting edge of the
1157
+ // viewport. It may still go off the ending edge, but this can be
1158
+ // controlled by the user since they may want to manage overflow in a
1159
+ // specific way.
1160
+ // https://github.com/radix-ui/primitives/issues/2049
1161
+ Math.max(Q, Le - Fe)
1162
+ ]);
1163
+ i.style.minWidth = de + "px", i.style.left = Be + "px";
1164
+ } else {
1165
+ const B = D.right - W.right, V = window.innerWidth - Y.right - B, ie = window.innerWidth - E.right - V, de = E.width + ie, Fe = Math.max(de, D.width), Le = window.innerWidth - Q, Be = it(V, [
1166
+ Q,
1167
+ Math.max(Q, Le - Fe)
1168
+ ]);
1169
+ i.style.minWidth = de + "px", i.style.right = Be + "px";
1170
+ }
1171
+ const H = y(), z = window.innerHeight - Q * 2, X = h.scrollHeight, K = window.getComputedStyle(d), U = parseInt(K.borderTopWidth, 10), L = parseInt(K.paddingTop, 10), q = parseInt(K.borderBottomWidth, 10), Z = parseInt(K.paddingBottom, 10), J = U + L + X + Z + q, he = Math.min(m.offsetHeight * 5, J), ce = window.getComputedStyle(h), f = parseInt(ce.paddingTop, 10), R = parseInt(ce.paddingBottom, 10), k = E.top + E.height / 2 - Q, I = z - k, _ = m.offsetHeight / 2, g = m.offsetTop + _, T = U + L + g, A = J - T;
1172
+ if (T <= k) {
1173
+ const B = H.length > 0 && m === H[H.length - 1].ref.current;
1174
+ i.style.bottom = "0px";
1175
+ const V = d.clientHeight - h.offsetTop - h.offsetHeight, ie = Math.max(
1176
+ I,
1177
+ _ + // viewport might have padding bottom, include it to avoid a scrollable viewport
1178
+ (B ? R : 0) + V + q
1179
+ ), de = T + ie;
1180
+ i.style.height = de + "px";
1181
+ } else {
1182
+ const B = H.length > 0 && m === H[0].ref.current;
1183
+ i.style.top = "0px";
1184
+ const ie = Math.max(
1185
+ k,
1186
+ U + h.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
1187
+ (B ? f : 0) + _
1188
+ ) + A;
1189
+ i.style.height = ie + "px", h.scrollTop = T - k + h.offsetTop;
1190
+ }
1191
+ i.style.margin = `${Q}px 0`, i.style.minHeight = he + "px", i.style.maxHeight = z + "px", s?.(), requestAnimationFrame(() => b.current = !0);
1192
+ }
1193
+ }, [
1194
+ y,
1195
+ l.trigger,
1196
+ l.valueNode,
1197
+ i,
1198
+ d,
1199
+ h,
1200
+ m,
1201
+ w,
1202
+ l.dir,
1203
+ s
1204
+ ]);
1205
+ ne(() => C(), [C]);
1206
+ const [N, M] = a.useState();
1207
+ ne(() => {
1208
+ d && M(window.getComputedStyle(d).zIndex);
1209
+ }, [d]);
1210
+ const j = a.useCallback(
1211
+ (E) => {
1212
+ E && S.current === !0 && (C(), x?.(), S.current = !1);
1213
+ },
1214
+ [C, x]
1215
+ );
1216
+ return /* @__PURE__ */ o.jsx(
1217
+ ln,
1218
+ {
1219
+ scope: t,
1220
+ contentWrapper: i,
1221
+ shouldExpandOnScrollRef: b,
1222
+ onScrollButtonChange: j,
1223
+ children: /* @__PURE__ */ o.jsx(
1224
+ "div",
1225
+ {
1226
+ ref: u,
1227
+ style: {
1228
+ display: "flex",
1229
+ flexDirection: "column",
1230
+ position: "fixed",
1231
+ zIndex: N
1232
+ },
1233
+ children: /* @__PURE__ */ o.jsx(
1234
+ P.div,
1235
+ {
1236
+ ...n,
1237
+ ref: v,
1238
+ style: {
1239
+ // When we get the height of the content, it includes borders. If we were to set
1240
+ // the height without having `boxSizing: 'border-box'` it would be too big.
1241
+ boxSizing: "border-box",
1242
+ // We need to ensure the content doesn't get taller than the wrapper
1243
+ maxHeight: "100%",
1244
+ ...n.style
1245
+ }
1246
+ }
1247
+ )
1248
+ }
1249
+ )
1250
+ }
1251
+ );
1252
+ });
1253
+ lr.displayName = an;
1254
+ var sn = "SelectPopperPosition", We = a.forwardRef((e, r) => {
1255
+ const {
1256
+ __scopeSelect: t,
1257
+ align: s = "start",
1258
+ collisionPadding: n = Q,
1259
+ ...l
1260
+ } = e, c = De(t);
1261
+ return /* @__PURE__ */ o.jsx(
1262
+ zr,
1263
+ {
1264
+ ...c,
1265
+ ...l,
1266
+ ref: r,
1267
+ align: s,
1268
+ collisionPadding: n,
1269
+ style: {
1270
+ // Ensure border-box for floating-ui calculations
1271
+ boxSizing: "border-box",
1272
+ ...l.style,
1273
+ "--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
1274
+ "--radix-select-content-available-width": "var(--radix-popper-available-width)",
1275
+ "--radix-select-content-available-height": "var(--radix-popper-available-height)",
1276
+ "--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
1277
+ "--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
1278
+ }
1279
+ }
1280
+ );
1281
+ });
1282
+ We.displayName = sn;
1283
+ var [ln, lt] = be(fe, {}), qe = "SelectViewport", cr = a.forwardRef(
1284
+ (e, r) => {
1285
+ const { __scopeSelect: t, nonce: s, ...n } = e, l = le(qe, t), c = lt(qe, t), i = G(r, l.onViewportChange), u = a.useRef(0);
1286
+ return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
1287
+ /* @__PURE__ */ o.jsx(
1288
+ "style",
1289
+ {
1290
+ dangerouslySetInnerHTML: {
1291
+ __html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
1292
+ },
1293
+ nonce: s
1294
+ }
1295
+ ),
1296
+ /* @__PURE__ */ o.jsx(Me.Slot, { scope: t, children: /* @__PURE__ */ o.jsx(
1297
+ P.div,
1298
+ {
1299
+ "data-radix-select-viewport": "",
1300
+ role: "presentation",
1301
+ ...n,
1302
+ ref: i,
1303
+ style: {
1304
+ // we use position: 'relative' here on the `viewport` so that when we call
1305
+ // `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
1306
+ // (independent of the scrollUpButton).
1307
+ position: "relative",
1308
+ flex: 1,
1309
+ // Viewport should only be scrollable in the vertical direction.
1310
+ // This won't work in vertical writing modes, so we'll need to
1311
+ // revisit this if/when that is supported
1312
+ // https://developer.chrome.com/blog/vertical-form-controls
1313
+ overflow: "hidden auto",
1314
+ ...n.style
1315
+ },
1316
+ onScroll: F(n.onScroll, (d) => {
1317
+ const p = d.currentTarget, { contentWrapper: v, shouldExpandOnScrollRef: y } = c;
1318
+ if (y?.current && v) {
1319
+ const b = Math.abs(u.current - p.scrollTop);
1320
+ if (b > 0) {
1321
+ const S = window.innerHeight - Q * 2, h = parseFloat(v.style.minHeight), m = parseFloat(v.style.height), w = Math.max(h, m);
1322
+ if (w < S) {
1323
+ const x = w + b, C = Math.min(S, x), N = x - C;
1324
+ v.style.height = C + "px", v.style.bottom === "0px" && (p.scrollTop = N > 0 ? N : 0, v.style.justifyContent = "flex-end");
1325
+ }
1326
+ }
1327
+ }
1328
+ u.current = p.scrollTop;
1329
+ })
1330
+ }
1331
+ ) })
1332
+ ] });
1333
+ }
1334
+ );
1335
+ cr.displayName = qe;
1336
+ var ir = "SelectGroup", [cn, dn] = be(ir), un = a.forwardRef(
1337
+ (e, r) => {
1338
+ const { __scopeSelect: t, ...s } = e, n = te();
1339
+ return /* @__PURE__ */ o.jsx(cn, { scope: t, id: n, children: /* @__PURE__ */ o.jsx(P.div, { role: "group", "aria-labelledby": n, ...s, ref: r }) });
1340
+ }
1341
+ );
1342
+ un.displayName = ir;
1343
+ var dr = "SelectLabel", pn = a.forwardRef(
1344
+ (e, r) => {
1345
+ const { __scopeSelect: t, ...s } = e, n = dn(dr, t);
1346
+ return /* @__PURE__ */ o.jsx(P.div, { id: n.id, ...s, ref: r });
1347
+ }
1348
+ );
1349
+ pn.displayName = dr;
1350
+ var Ne = "SelectItem", [fn, ur] = be(Ne), pr = a.forwardRef(
1351
+ (e, r) => {
1352
+ const {
1353
+ __scopeSelect: t,
1354
+ value: s,
1355
+ disabled: n = !1,
1356
+ textValue: l,
1357
+ ...c
1358
+ } = e, i = se(Ne, t), u = le(Ne, t), d = i.value === s, [p, v] = a.useState(l ?? ""), [y, b] = a.useState(!1), S = G(
1359
+ r,
1360
+ (x) => u.itemRefCallback?.(x, s, n)
1361
+ ), h = te(), m = a.useRef("touch"), w = () => {
1362
+ n || (i.onValueChange(s), i.onOpenChange(!1));
1363
+ };
1364
+ if (s === "")
1365
+ throw new Error(
1366
+ "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."
1367
+ );
1368
+ return /* @__PURE__ */ o.jsx(
1369
+ fn,
1370
+ {
1371
+ scope: t,
1372
+ value: s,
1373
+ disabled: n,
1374
+ textId: h,
1375
+ isSelected: d,
1376
+ onItemTextChange: a.useCallback((x) => {
1377
+ v((C) => C || (x?.textContent ?? "").trim());
1378
+ }, []),
1379
+ children: /* @__PURE__ */ o.jsx(
1380
+ Me.ItemSlot,
1381
+ {
1382
+ scope: t,
1383
+ value: s,
1384
+ disabled: n,
1385
+ textValue: p,
1386
+ children: /* @__PURE__ */ o.jsx(
1387
+ P.div,
1388
+ {
1389
+ role: "option",
1390
+ "aria-labelledby": h,
1391
+ "data-highlighted": y ? "" : void 0,
1392
+ "aria-selected": d && y,
1393
+ "data-state": d ? "checked" : "unchecked",
1394
+ "aria-disabled": n || void 0,
1395
+ "data-disabled": n ? "" : void 0,
1396
+ tabIndex: n ? void 0 : -1,
1397
+ ...c,
1398
+ ref: S,
1399
+ onFocus: F(c.onFocus, () => b(!0)),
1400
+ onBlur: F(c.onBlur, () => b(!1)),
1401
+ onClick: F(c.onClick, () => {
1402
+ m.current !== "mouse" && w();
1403
+ }),
1404
+ onPointerUp: F(c.onPointerUp, () => {
1405
+ m.current === "mouse" && w();
1406
+ }),
1407
+ onPointerDown: F(c.onPointerDown, (x) => {
1408
+ m.current = x.pointerType;
1409
+ }),
1410
+ onPointerMove: F(c.onPointerMove, (x) => {
1411
+ m.current = x.pointerType, n ? u.onItemLeave?.() : m.current === "mouse" && x.currentTarget.focus({ preventScroll: !0 });
1412
+ }),
1413
+ onPointerLeave: F(c.onPointerLeave, (x) => {
1414
+ x.currentTarget === document.activeElement && u.onItemLeave?.();
1415
+ }),
1416
+ onKeyDown: F(c.onKeyDown, (x) => {
1417
+ u.searchRef?.current !== "" && x.key === " " || (Xo.includes(x.key) && w(), x.key === " " && x.preventDefault());
1418
+ })
1419
+ }
1420
+ )
1421
+ }
1422
+ )
1423
+ }
1424
+ );
1425
+ }
1426
+ );
1427
+ pr.displayName = Ne;
1428
+ var Ce = "SelectItemText", fr = a.forwardRef(
1429
+ (e, r) => {
1430
+ const { __scopeSelect: t, className: s, style: n, ...l } = e, c = se(Ce, t), i = le(Ce, t), u = ur(Ce, t), d = en(Ce, t), [p, v] = a.useState(null), y = G(
1431
+ r,
1432
+ (w) => v(w),
1433
+ u.onItemTextChange,
1434
+ (w) => i.itemTextRefCallback?.(w, u.value, u.disabled)
1435
+ ), b = p?.textContent, S = a.useMemo(
1436
+ () => /* @__PURE__ */ o.jsx("option", { value: u.value, disabled: u.disabled, children: b }, u.value),
1437
+ [u.disabled, u.value, b]
1438
+ ), { onNativeOptionAdd: h, onNativeOptionRemove: m } = d;
1439
+ return ne(() => (h(S), () => m(S)), [h, m, S]), /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
1440
+ /* @__PURE__ */ o.jsx(P.span, { id: u.textId, ...l, ref: y }),
1441
+ u.isSelected && c.valueNode && !c.valueNodeHasChildren ? yt.createPortal(l.children, c.valueNode) : null
1442
+ ] });
1443
+ }
1444
+ );
1445
+ fr.displayName = Ce;
1446
+ var mr = "SelectItemIndicator", hr = a.forwardRef(
1447
+ (e, r) => {
1448
+ const { __scopeSelect: t, ...s } = e;
1449
+ return ur(mr, t).isSelected ? /* @__PURE__ */ o.jsx(P.span, { "aria-hidden": !0, ...s, ref: r }) : null;
1450
+ }
1451
+ );
1452
+ hr.displayName = mr;
1453
+ var Ye = "SelectScrollUpButton", vr = a.forwardRef((e, r) => {
1454
+ const t = le(Ye, e.__scopeSelect), s = lt(Ye, e.__scopeSelect), [n, l] = a.useState(!1), c = G(r, s.onScrollButtonChange);
1455
+ return ne(() => {
1456
+ if (t.viewport && t.isPositioned) {
1457
+ let i = function() {
1458
+ const d = u.scrollTop > 0;
1459
+ l(d);
1460
+ };
1461
+ const u = t.viewport;
1462
+ return i(), u.addEventListener("scroll", i), () => u.removeEventListener("scroll", i);
1463
+ }
1464
+ }, [t.viewport, t.isPositioned]), n ? /* @__PURE__ */ o.jsx(
1465
+ gr,
1466
+ {
1467
+ ...e,
1468
+ ref: c,
1469
+ onAutoScroll: () => {
1470
+ const { viewport: i, selectedItem: u } = t;
1471
+ i && u && (i.scrollTop = i.scrollTop - u.offsetHeight);
1472
+ }
1473
+ }
1474
+ ) : null;
1475
+ });
1476
+ vr.displayName = Ye;
1477
+ var Xe = "SelectScrollDownButton", xr = a.forwardRef((e, r) => {
1478
+ const t = le(Xe, e.__scopeSelect), s = lt(Xe, e.__scopeSelect), [n, l] = a.useState(!1), c = G(r, s.onScrollButtonChange);
1479
+ return ne(() => {
1480
+ if (t.viewport && t.isPositioned) {
1481
+ let i = function() {
1482
+ const d = u.scrollHeight - u.clientHeight, p = Math.ceil(u.scrollTop) < d;
1483
+ l(p);
1484
+ };
1485
+ const u = t.viewport;
1486
+ return i(), u.addEventListener("scroll", i), () => u.removeEventListener("scroll", i);
1487
+ }
1488
+ }, [t.viewport, t.isPositioned]), n ? /* @__PURE__ */ o.jsx(
1489
+ gr,
1490
+ {
1491
+ ...e,
1492
+ ref: c,
1493
+ onAutoScroll: () => {
1494
+ const { viewport: i, selectedItem: u } = t;
1495
+ i && u && (i.scrollTop = i.scrollTop + u.offsetHeight);
1496
+ }
1497
+ }
1498
+ ) : null;
1499
+ });
1500
+ xr.displayName = Xe;
1501
+ var gr = a.forwardRef((e, r) => {
1502
+ const { __scopeSelect: t, onAutoScroll: s, ...n } = e, l = le("SelectScrollButton", t), c = a.useRef(null), i = Ae(t), u = a.useCallback(() => {
1503
+ c.current !== null && (window.clearInterval(c.current), c.current = null);
1504
+ }, []);
1505
+ return a.useEffect(() => () => u(), [u]), ne(() => {
1506
+ i().find((p) => p.ref.current === document.activeElement)?.ref.current?.scrollIntoView({ block: "nearest" });
1507
+ }, [i]), /* @__PURE__ */ o.jsx(
1508
+ P.div,
1509
+ {
1510
+ "aria-hidden": !0,
1511
+ ...n,
1512
+ ref: r,
1513
+ style: { flexShrink: 0, ...n.style },
1514
+ onPointerDown: F(n.onPointerDown, () => {
1515
+ c.current === null && (c.current = window.setInterval(s, 50));
1516
+ }),
1517
+ onPointerMove: F(n.onPointerMove, () => {
1518
+ l.onItemLeave?.(), c.current === null && (c.current = window.setInterval(s, 50));
1519
+ }),
1520
+ onPointerLeave: F(n.onPointerLeave, () => {
1521
+ u();
1522
+ })
1523
+ }
1524
+ );
1525
+ }), mn = "SelectSeparator", hn = a.forwardRef(
1526
+ (e, r) => {
1527
+ const { __scopeSelect: t, ...s } = e;
1528
+ return /* @__PURE__ */ o.jsx(P.div, { "aria-hidden": !0, ...s, ref: r });
1529
+ }
1530
+ );
1531
+ hn.displayName = mn;
1532
+ var Ze = "SelectArrow", vn = a.forwardRef(
1533
+ (e, r) => {
1534
+ const { __scopeSelect: t, ...s } = e, n = De(t), l = se(Ze, t), c = le(Ze, t);
1535
+ return l.open && c.position === "popper" ? /* @__PURE__ */ o.jsx(Wr, { ...n, ...s, ref: r }) : null;
1536
+ }
1537
+ );
1538
+ vn.displayName = Ze;
1539
+ var xn = "SelectBubbleInput", br = a.forwardRef(
1540
+ ({ __scopeSelect: e, value: r, ...t }, s) => {
1541
+ const n = a.useRef(null), l = G(s, n), c = nt(r);
1542
+ return a.useEffect(() => {
1543
+ const i = n.current;
1544
+ if (!i) return;
1545
+ const u = window.HTMLSelectElement.prototype, p = Object.getOwnPropertyDescriptor(
1546
+ u,
1547
+ "value"
1548
+ ).set;
1549
+ if (c !== r && p) {
1550
+ const v = new Event("change", { bubbles: !0 });
1551
+ p.call(i, r), i.dispatchEvent(v);
1552
+ }
1553
+ }, [c, r]), /* @__PURE__ */ o.jsx(
1554
+ P.select,
1555
+ {
1556
+ ...t,
1557
+ style: { ...$r, ...t.style },
1558
+ ref: l,
1559
+ defaultValue: r
1560
+ }
1561
+ );
1562
+ }
1563
+ );
1564
+ br.displayName = xn;
1565
+ function wr(e) {
1566
+ return e === "" || e === void 0;
1567
+ }
1568
+ function yr(e) {
1569
+ const r = vt(e), t = a.useRef(""), s = a.useRef(0), n = a.useCallback(
1570
+ (c) => {
1571
+ const i = t.current + c;
1572
+ r(i), function u(d) {
1573
+ t.current = d, window.clearTimeout(s.current), d !== "" && (s.current = window.setTimeout(() => u(""), 1e3));
1574
+ }(i);
1575
+ },
1576
+ [r]
1577
+ ), l = a.useCallback(() => {
1578
+ t.current = "", window.clearTimeout(s.current);
1579
+ }, []);
1580
+ return a.useEffect(() => () => window.clearTimeout(s.current), []), [t, n, l];
1581
+ }
1582
+ function Sr(e, r, t) {
1583
+ const n = r.length > 1 && Array.from(r).every((d) => d === r[0]) ? r[0] : r, l = t ? e.indexOf(t) : -1;
1584
+ let c = gn(e, Math.max(l, 0));
1585
+ n.length === 1 && (c = c.filter((d) => d !== t));
1586
+ const u = c.find(
1587
+ (d) => d.textValue.toLowerCase().startsWith(n.toLowerCase())
1588
+ );
1589
+ return u !== t ? u : void 0;
1590
+ }
1591
+ function gn(e, r) {
1592
+ return e.map((t, s) => e[(r + s) % e.length]);
1593
+ }
1594
+ var bn = Zt, wn = Qt, yn = tr, Sn = rr, Cn = or, In = nr, Rn = cr, kn = pr, En = fr, jn = hr, Nn = vr, _n = xr;
1595
+ const Ta = ({ disabled: e = !1, handleDelete: r, ...t }) => /* @__PURE__ */ o.jsx(
1596
+ et,
1597
+ {
1598
+ disabled: e,
1599
+ icon: /* @__PURE__ */ o.jsx(xo, {}),
1600
+ onClick: r,
1601
+ variant: "outline",
1602
+ ...t,
1603
+ className: "border-destructive text-destructive hover:bg-destructive hover:text-white",
1604
+ children: "Delete"
1605
+ }
1606
+ ), dt = {
1607
+ default: { label: "Submit", submittingLabel: "Submitting", icon: /* @__PURE__ */ o.jsx($e, {}) },
1608
+ submit: { label: "Submit", submittingLabel: "Submitting", icon: /* @__PURE__ */ o.jsx($e, {}) },
1609
+ save: { label: "Save", submittingLabel: "Saving", icon: /* @__PURE__ */ o.jsx(po, {}) },
1610
+ send: { label: "Send", submittingLabel: "Sending", icon: /* @__PURE__ */ o.jsx($e, {}) }
1611
+ }, Pa = ({
1612
+ submitting: e = !1,
1613
+ disabled: r = !1,
1614
+ submittingIcon: t,
1615
+ action: s = "default",
1616
+ noIcon: n = !1,
1617
+ ...l
1618
+ }) => {
1619
+ const c = t || io;
1620
+ if (!dt[s])
1621
+ throw new Error(`Invalid action: ${s}`);
1622
+ const { label: i, submittingLabel: u, icon: d } = dt[s], p = e ? /* @__PURE__ */ o.jsx(c, { className: "animate-spin" }) : d;
1623
+ return /* @__PURE__ */ o.jsx(
1624
+ et,
1625
+ {
1626
+ disabled: r || e,
1627
+ icon: n ? void 0 : p,
1628
+ type: "submit",
1629
+ variant: "primary",
1630
+ ...l,
1631
+ children: e ? u : i
1632
+ }
1633
+ );
1634
+ };
1635
+ function Tn({ className: e, ...r }) {
1636
+ return /* @__PURE__ */ o.jsx(
1637
+ kt,
1638
+ {
1639
+ className: $(
1640
+ "peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs outline-none transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:ring-destructive/40",
1641
+ e
1642
+ ),
1643
+ "data-slot": "checkbox",
1644
+ ...r,
1645
+ children: /* @__PURE__ */ o.jsx(
1646
+ jt,
1647
+ {
1648
+ className: "flex items-center justify-center text-current transition-none",
1649
+ "data-slot": "checkbox-indicator",
1650
+ children: /* @__PURE__ */ o.jsx(rt, { className: "size-3.5" })
1651
+ }
1652
+ )
1653
+ }
1654
+ );
1655
+ }
1656
+ const Ma = ({ label: e, name: r, value: t, checked: s, onCheckedChange: n }) => {
1657
+ const [l, c] = tt(s);
1658
+ Ar(() => {
1659
+ c(s);
1660
+ }, [s]);
1661
+ let i = r;
1662
+ const u = t || r;
1663
+ t && (i += `[${t}]`);
1664
+ const d = (p) => {
1665
+ c(p), n?.(p);
1666
+ };
1667
+ return /* @__PURE__ */ o.jsxs(oe, { align: "center", gap: "2", children: [
1668
+ /* @__PURE__ */ o.jsx(
1669
+ Tn,
1670
+ {
1671
+ checked: l,
1672
+ id: i,
1673
+ name: r,
1674
+ onCheckedChange: d,
1675
+ value: u
1676
+ }
1677
+ ),
1678
+ /* @__PURE__ */ o.jsx(we, { className: "cursor-pointer", htmlFor: i, children: e })
1679
+ ] });
1680
+ }, Aa = ({ name: e, label: r, placeholder: t, note: s, className: n, ...l }) => /* @__PURE__ */ o.jsx(
1681
+ Cr,
1682
+ {
1683
+ className: $("max-w-[150px]", n),
1684
+ label: r,
1685
+ name: e,
1686
+ note: s,
1687
+ placeholder: t,
1688
+ type: "date",
1689
+ ...l
1690
+ }
1691
+ ), Da = ({ onDateSelection: e, initialValue: r, className: t, size: s = "default", error: n }) => {
1692
+ const [l, c] = tt(r), i = (u) => {
1693
+ c(u), u && e(u);
1694
+ };
1695
+ return /* @__PURE__ */ o.jsxs(oe, { direction: "col", gap: "2", children: [
1696
+ /* @__PURE__ */ o.jsxs(gt, { children: [
1697
+ /* @__PURE__ */ o.jsx(bt, { asChild: !0, children: /* @__PURE__ */ o.jsxs(
1698
+ et,
1699
+ {
1700
+ className: $("w-[280px] justify-start text-left font-normal", !l && "text-muted-foreground", t),
1701
+ size: s,
1702
+ variant: "outline",
1703
+ children: [
1704
+ /* @__PURE__ */ o.jsx(Qr, { className: "mr-2 h-4 w-4" }),
1705
+ l ? l.toISOString().split("T")[0] : /* @__PURE__ */ o.jsx("span", { children: "Select a date" })
1706
+ ]
1707
+ }
1708
+ ) }),
1709
+ /* @__PURE__ */ o.jsx(wt, { className: "w-auto p-0", children: /* @__PURE__ */ o.jsx(Pr, { autoFocus: !0, mode: "single", onSelect: i, selected: l }) })
1710
+ ] }),
1711
+ n && /* @__PURE__ */ o.jsx(Ee, { message: n })
1712
+ ] });
1713
+ }, Ee = ({ message: e }) => /* @__PURE__ */ o.jsx(_e, { size: "xs", variant: "destructive", children: e }), Pn = ({ label: e, labelFor: r, className: t = "", labelClassName: s = "", children: n }) => /* @__PURE__ */ o.jsxs(oe, { direction: "col", gap: "2", children: [
1714
+ e && /* @__PURE__ */ o.jsx(we, { className: s, htmlFor: r, children: e }),
1715
+ /* @__PURE__ */ o.jsx(oe, { className: `rounded-md border border-input bg-card p-2 shadow-xs ${t}`, gapY: "1", children: n })
1716
+ ] });
1717
+ function Mn({ className: e, ...r }) {
1718
+ return /* @__PURE__ */ o.jsx(
1719
+ Oo,
1720
+ {
1721
+ className: $(
1722
+ "flex select-none items-center gap-2 font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",
1723
+ e
1724
+ ),
1725
+ "data-slot": "label",
1726
+ ...r
1727
+ }
1728
+ );
1729
+ }
1730
+ const we = ({ htmlFor: e, value: r, children: t, className: s = "", ...n }) => /* @__PURE__ */ o.jsx(
1731
+ Mn,
1732
+ {
1733
+ className: $("font-display font-normal text-base text-foreground", s),
1734
+ htmlFor: e,
1735
+ ...n,
1736
+ children: r || t
1737
+ }
1738
+ );
1739
+ function An({ className: e, type: r, ...t }) {
1740
+ return /* @__PURE__ */ o.jsx(
1741
+ "input",
1742
+ {
1743
+ className: $(
1744
+ "flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs outline-none transition-[color,box-shadow] selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:font-medium file:text-foreground file:text-sm placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
1745
+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
1746
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
1747
+ e
1748
+ ),
1749
+ "data-slot": "input",
1750
+ type: r,
1751
+ ...t
1752
+ }
1753
+ );
1754
+ }
1755
+ const Cr = ({
1756
+ name: e,
1757
+ type: r = "text",
1758
+ placeholder: t,
1759
+ label: s,
1760
+ labelOrientation: n = "top",
1761
+ note: l,
1762
+ className: c,
1763
+ error: i,
1764
+ ...u
1765
+ }) => /* @__PURE__ */ o.jsxs(oe, { className: "w-full", direction: n === "left" ? "row" : "col", gap: "2", children: [
1766
+ s && /* @__PURE__ */ o.jsx(we, { className: n === "left" ? "text-nowrap" : "", htmlFor: e, children: s }),
1767
+ /* @__PURE__ */ o.jsx(
1768
+ An,
1769
+ {
1770
+ "aria-label": s || e,
1771
+ className: c,
1772
+ id: e,
1773
+ name: e,
1774
+ placeholder: t,
1775
+ type: r,
1776
+ ...u
1777
+ }
1778
+ ),
1779
+ l && /* @__PURE__ */ o.jsx(_e, { size: "sm", variant: "muted", children: l }),
1780
+ i && /* @__PURE__ */ o.jsx(Ee, { message: i })
1781
+ ] }), Oa = ({
1782
+ name: e,
1783
+ label: r,
1784
+ placeholder: t,
1785
+ note: s,
1786
+ // Default to two decimal places for currency and general decimal values
1787
+ step: n = ".01",
1788
+ className: l,
1789
+ ...c
1790
+ }) => /* @__PURE__ */ o.jsx(
1791
+ Cr,
1792
+ {
1793
+ className: l,
1794
+ label: r,
1795
+ name: e,
1796
+ note: s,
1797
+ placeholder: t,
1798
+ step: n,
1799
+ type: "number",
1800
+ ...c
1801
+ }
1802
+ );
1803
+ function Dn({ className: e, ...r }) {
1804
+ return /* @__PURE__ */ o.jsx(zo, { className: $("grid gap-3", e), "data-slot": "radio-group", ...r });
1805
+ }
1806
+ function On({ className: e, ...r }) {
1807
+ return /* @__PURE__ */ o.jsx(
1808
+ Wo,
1809
+ {
1810
+ className: $(
1811
+ "aspect-square size-4 shrink-0 rounded-full border border-input text-primary shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
1812
+ e
1813
+ ),
1814
+ "data-slot": "radio-group-item",
1815
+ ...r,
1816
+ children: /* @__PURE__ */ o.jsx(
1817
+ qo,
1818
+ {
1819
+ className: "relative flex items-center justify-center",
1820
+ "data-slot": "radio-group-indicator",
1821
+ children: /* @__PURE__ */ o.jsx(lo, { className: "-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2 size-2 fill-primary" })
1822
+ }
1823
+ )
1824
+ }
1825
+ );
1826
+ }
1827
+ const Fa = ({ label: e, name: r, options: t, value: s, onChange: n, error: l }) => /* @__PURE__ */ o.jsxs(Pn, { className: "flex flex-col gap-4 px-2 py-1", label: e, labelFor: r, children: [
1828
+ /* @__PURE__ */ o.jsx(Dn, { className: "w-full", name: r, onValueChange: n, value: s, children: /* @__PURE__ */ o.jsx(Or, { cols: "2", children: t.map((c, i) => /* @__PURE__ */ o.jsxs(oe, { align: "center", gap: "2", justify: "start", children: [
1829
+ /* @__PURE__ */ o.jsx(On, { id: c.value, value: c.value }),
1830
+ /* @__PURE__ */ o.jsx(we, { htmlFor: c.value, children: c.label })
1831
+ ] }, i)) }) }),
1832
+ l && /* @__PURE__ */ o.jsx(Ee, { message: l })
1833
+ ] });
1834
+ function Fn({ ...e }) {
1835
+ return /* @__PURE__ */ o.jsx(bn, { "data-slot": "select", ...e });
1836
+ }
1837
+ function Ln({ ...e }) {
1838
+ return /* @__PURE__ */ o.jsx(yn, { "data-slot": "select-value", ...e });
1839
+ }
1840
+ function Bn({
1841
+ className: e,
1842
+ size: r = "default",
1843
+ children: t,
1844
+ ...s
1845
+ }) {
1846
+ return /* @__PURE__ */ o.jsxs(
1847
+ wn,
1848
+ {
1849
+ className: $(
1850
+ "flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[size=default]:h-9 data-[size=sm]:h-8 data-[placeholder]:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:hover:bg-input/50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
1851
+ e
1852
+ ),
1853
+ "data-size": r,
1854
+ "data-slot": "select-trigger",
1855
+ ...s,
1856
+ children: [
1857
+ t,
1858
+ /* @__PURE__ */ o.jsx(Sn, { asChild: !0, children: /* @__PURE__ */ o.jsx(St, { className: "size-4 opacity-50" }) })
1859
+ ]
1860
+ }
1861
+ );
1862
+ }
1863
+ function $n({
1864
+ className: e,
1865
+ children: r,
1866
+ position: t = "popper",
1867
+ ...s
1868
+ }) {
1869
+ return /* @__PURE__ */ o.jsx(Cn, { children: /* @__PURE__ */ o.jsxs(
1870
+ In,
1871
+ {
1872
+ className: $(
1873
+ "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-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",
1874
+ t === "popper" && "data-[side=left]:-translate-x-1 data-[side=top]:-translate-y-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1",
1875
+ e
1876
+ ),
1877
+ "data-slot": "select-content",
1878
+ position: t,
1879
+ ...s,
1880
+ children: [
1881
+ /* @__PURE__ */ o.jsx(Gn, {}),
1882
+ /* @__PURE__ */ o.jsx(
1883
+ Rn,
1884
+ {
1885
+ className: $(
1886
+ "p-1",
1887
+ t === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
1888
+ ),
1889
+ children: r
1890
+ }
1891
+ ),
1892
+ /* @__PURE__ */ o.jsx(Hn, {})
1893
+ ]
1894
+ }
1895
+ ) });
1896
+ }
1897
+ function Vn({ className: e, children: r, ...t }) {
1898
+ return /* @__PURE__ */ o.jsxs(
1899
+ kn,
1900
+ {
1901
+ className: $(
1902
+ "relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
1903
+ e
1904
+ ),
1905
+ "data-slot": "select-item",
1906
+ ...t,
1907
+ children: [
1908
+ /* @__PURE__ */ o.jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ o.jsx(jn, { children: /* @__PURE__ */ o.jsx(rt, { className: "size-4" }) }) }),
1909
+ /* @__PURE__ */ o.jsx(En, { children: r })
1910
+ ]
1911
+ }
1912
+ );
1913
+ }
1914
+ function Gn({ className: e, ...r }) {
1915
+ return /* @__PURE__ */ o.jsx(
1916
+ Nn,
1917
+ {
1918
+ className: $("flex cursor-default items-center justify-center py-1", e),
1919
+ "data-slot": "select-scroll-up-button",
1920
+ ...r,
1921
+ children: /* @__PURE__ */ o.jsx(oo, { className: "size-4" })
1922
+ }
1923
+ );
1924
+ }
1925
+ function Hn({
1926
+ className: e,
1927
+ ...r
1928
+ }) {
1929
+ return /* @__PURE__ */ o.jsx(
1930
+ _n,
1931
+ {
1932
+ className: $("flex cursor-default items-center justify-center py-1", e),
1933
+ "data-slot": "select-scroll-down-button",
1934
+ ...r,
1935
+ children: /* @__PURE__ */ o.jsx(St, { className: "size-4" })
1936
+ }
1937
+ );
1938
+ }
1939
+ const La = ({
1940
+ name: e,
1941
+ defaultValue: r,
1942
+ options: t,
1943
+ label: s,
1944
+ placeholder: n,
1945
+ note: l,
1946
+ className: c,
1947
+ value: i,
1948
+ onValueChange: u,
1949
+ error: d,
1950
+ ...p
1951
+ }) => /* @__PURE__ */ o.jsxs(oe, { className: "w-full", direction: "col", gap: "2", children: [
1952
+ s && /* @__PURE__ */ o.jsx(we, { htmlFor: e, children: s }),
1953
+ /* @__PURE__ */ o.jsxs(
1954
+ Fn,
1955
+ {
1956
+ defaultValue: r,
1957
+ name: e,
1958
+ onValueChange: u,
1959
+ value: i,
1960
+ ...p,
1961
+ children: [
1962
+ /* @__PURE__ */ o.jsx(Bn, { className: $("min-w-[180px]", c), "data-testid": `select-input-${e}`, children: /* @__PURE__ */ o.jsx(Ln, { placeholder: n }) }),
1963
+ /* @__PURE__ */ o.jsx($n, { children: t.map(({ value: v, label: y }) => /* @__PURE__ */ o.jsx(Vn, { value: v, children: y }, `option-${v}`)) })
1964
+ ]
1965
+ }
1966
+ ),
1967
+ l && /* @__PURE__ */ o.jsx(_e, { size: "sm", variant: "muted", children: l }),
1968
+ d && /* @__PURE__ */ o.jsx(Ee, { message: d })
1969
+ ] });
1970
+ var ut = 1, Kn = 0.9, Un = 0.8, zn = 0.17, Ge = 0.1, He = 0.999, Wn = 0.9999, qn = 0.99, Yn = /[\\\/_+.#"@\[\(\{&]/, Xn = /[\\\/_+.#"@\[\(\{&]/g, Zn = /[\s-]/, Ir = /[\s-]/g;
1971
+ function Je(e, r, t, s, n, l, c) {
1972
+ if (l === r.length) return n === e.length ? ut : qn;
1973
+ var i = `${n},${l}`;
1974
+ if (c[i] !== void 0) return c[i];
1975
+ for (var u = s.charAt(l), d = t.indexOf(u, n), p = 0, v, y, b, S; d >= 0; ) v = Je(e, r, t, s, d + 1, l + 1, c), v > p && (d === n ? v *= ut : Yn.test(e.charAt(d - 1)) ? (v *= Un, b = e.slice(n, d - 1).match(Xn), b && n > 0 && (v *= Math.pow(He, b.length))) : Zn.test(e.charAt(d - 1)) ? (v *= Kn, S = e.slice(n, d - 1).match(Ir), S && n > 0 && (v *= Math.pow(He, S.length))) : (v *= zn, n > 0 && (v *= Math.pow(He, d - n))), e.charAt(d) !== r.charAt(l) && (v *= Wn)), (v < Ge && t.charAt(d - 1) === s.charAt(l + 1) || s.charAt(l + 1) === s.charAt(l) && t.charAt(d - 1) !== s.charAt(l)) && (y = Je(e, r, t, s, d + 1, l + 2, c), y * Ge > v && (v = y * Ge)), v > p && (p = v), d = t.indexOf(u, d + 1);
1976
+ return c[i] = p, p;
1977
+ }
1978
+ function pt(e) {
1979
+ return e.toLowerCase().replace(Ir, " ");
1980
+ }
1981
+ function Jn(e, r, t) {
1982
+ return e = t && t.length > 0 ? `${e + " " + t.join(" ")}` : e, Je(e, r, pt(e), pt(r), 0, 0, {});
1983
+ }
1984
+ var Se = '[cmdk-group=""]', Ke = '[cmdk-group-items=""]', Qn = '[cmdk-group-heading=""]', Rr = '[cmdk-item=""]', ft = `${Rr}:not([aria-disabled="true"])`, Qe = "cmdk-item-select", ve = "data-value", ea = (e, r, t) => Jn(e, r, t), kr = a.createContext(void 0), je = () => a.useContext(kr), Er = a.createContext(void 0), ct = () => a.useContext(Er), jr = a.createContext(void 0), Nr = a.forwardRef((e, r) => {
1985
+ let t = xe(() => {
1986
+ var f, R;
1987
+ return { search: "", value: (R = (f = e.value) != null ? f : e.defaultValue) != null ? R : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
1988
+ }), s = xe(() => /* @__PURE__ */ new Set()), n = xe(() => /* @__PURE__ */ new Map()), l = xe(() => /* @__PURE__ */ new Map()), c = xe(() => /* @__PURE__ */ new Set()), i = _r(e), { label: u, children: d, value: p, onValueChange: v, filter: y, shouldFilter: b, loop: S, disablePointerSelection: h = !1, vimBindings: m = !0, ...w } = e, x = te(), C = te(), N = te(), M = a.useRef(null), j = ua();
1989
+ me(() => {
1990
+ if (p !== void 0) {
1991
+ let f = p.trim();
1992
+ t.current.value = f, E.emit();
1993
+ }
1994
+ }, [p]), me(() => {
1995
+ j(6, X);
1996
+ }, []);
1997
+ let E = a.useMemo(() => ({ subscribe: (f) => (c.current.add(f), () => c.current.delete(f)), snapshot: () => t.current, setState: (f, R, k) => {
1998
+ var I, _, g, T;
1999
+ if (!Object.is(t.current[f], R)) {
2000
+ if (t.current[f] = R, f === "search") z(), W(), j(1, H);
2001
+ else if (f === "value") {
2002
+ if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
2003
+ let A = document.getElementById(N);
2004
+ A ? A.focus() : (I = document.getElementById(x)) == null || I.focus();
2005
+ }
2006
+ if (j(7, () => {
2007
+ var A;
2008
+ t.current.selectedItemId = (A = K()) == null ? void 0 : A.id, E.emit();
2009
+ }), k || j(5, X), ((_ = i.current) == null ? void 0 : _.value) !== void 0) {
2010
+ let A = R ?? "";
2011
+ (T = (g = i.current).onValueChange) == null || T.call(g, A);
2012
+ return;
2013
+ }
2014
+ }
2015
+ E.emit();
2016
+ }
2017
+ }, emit: () => {
2018
+ c.current.forEach((f) => f());
2019
+ } }), []), D = a.useMemo(() => ({ value: (f, R, k) => {
2020
+ var I;
2021
+ R !== ((I = l.current.get(f)) == null ? void 0 : I.value) && (l.current.set(f, { value: R, keywords: k }), t.current.filtered.items.set(f, Y(R, k)), j(2, () => {
2022
+ W(), E.emit();
2023
+ }));
2024
+ }, item: (f, R) => (s.current.add(f), R && (n.current.has(R) ? n.current.get(R).add(f) : n.current.set(R, /* @__PURE__ */ new Set([f]))), j(3, () => {
2025
+ z(), W(), t.current.value || H(), E.emit();
2026
+ }), () => {
2027
+ l.current.delete(f), s.current.delete(f), t.current.filtered.items.delete(f);
2028
+ let k = K();
2029
+ j(4, () => {
2030
+ z(), k?.getAttribute("id") === f && H(), E.emit();
2031
+ });
2032
+ }), group: (f) => (n.current.has(f) || n.current.set(f, /* @__PURE__ */ new Set()), () => {
2033
+ l.current.delete(f), n.current.delete(f);
2034
+ }), filter: () => i.current.shouldFilter, label: u || e["aria-label"], getDisablePointerSelection: () => i.current.disablePointerSelection, listId: x, inputId: N, labelId: C, listInnerRef: M }), []);
2035
+ function Y(f, R) {
2036
+ var k, I;
2037
+ let _ = (I = (k = i.current) == null ? void 0 : k.filter) != null ? I : ea;
2038
+ return f ? _(f, t.current.search, R) : 0;
2039
+ }
2040
+ function W() {
2041
+ if (!t.current.search || i.current.shouldFilter === !1) return;
2042
+ let f = t.current.filtered.items, R = [];
2043
+ t.current.filtered.groups.forEach((I) => {
2044
+ let _ = n.current.get(I), g = 0;
2045
+ _.forEach((T) => {
2046
+ let A = f.get(T);
2047
+ g = Math.max(A, g);
2048
+ }), R.push([I, g]);
2049
+ });
2050
+ let k = M.current;
2051
+ U().sort((I, _) => {
2052
+ var g, T;
2053
+ let A = I.getAttribute("id"), O = _.getAttribute("id");
2054
+ return ((g = f.get(O)) != null ? g : 0) - ((T = f.get(A)) != null ? T : 0);
2055
+ }).forEach((I) => {
2056
+ let _ = I.closest(Ke);
2057
+ _ ? _.appendChild(I.parentElement === _ ? I : I.closest(`${Ke} > *`)) : k.appendChild(I.parentElement === k ? I : I.closest(`${Ke} > *`));
2058
+ }), R.sort((I, _) => _[1] - I[1]).forEach((I) => {
2059
+ var _;
2060
+ let g = (_ = M.current) == null ? void 0 : _.querySelector(`${Se}[${ve}="${encodeURIComponent(I[0])}"]`);
2061
+ g?.parentElement.appendChild(g);
2062
+ });
2063
+ }
2064
+ function H() {
2065
+ let f = U().find((k) => k.getAttribute("aria-disabled") !== "true"), R = f?.getAttribute(ve);
2066
+ E.setState("value", R || void 0);
2067
+ }
2068
+ function z() {
2069
+ var f, R, k, I;
2070
+ if (!t.current.search || i.current.shouldFilter === !1) {
2071
+ t.current.filtered.count = s.current.size;
2072
+ return;
2073
+ }
2074
+ t.current.filtered.groups = /* @__PURE__ */ new Set();
2075
+ let _ = 0;
2076
+ for (let g of s.current) {
2077
+ let T = (R = (f = l.current.get(g)) == null ? void 0 : f.value) != null ? R : "", A = (I = (k = l.current.get(g)) == null ? void 0 : k.keywords) != null ? I : [], O = Y(T, A);
2078
+ t.current.filtered.items.set(g, O), O > 0 && _++;
2079
+ }
2080
+ for (let [g, T] of n.current) for (let A of T) if (t.current.filtered.items.get(A) > 0) {
2081
+ t.current.filtered.groups.add(g);
2082
+ break;
2083
+ }
2084
+ t.current.filtered.count = _;
2085
+ }
2086
+ function X() {
2087
+ var f, R, k;
2088
+ let I = K();
2089
+ I && (((f = I.parentElement) == null ? void 0 : f.firstChild) === I && ((k = (R = I.closest(Se)) == null ? void 0 : R.querySelector(Qn)) == null || k.scrollIntoView({ block: "nearest" })), I.scrollIntoView({ block: "nearest" }));
2090
+ }
2091
+ function K() {
2092
+ var f;
2093
+ return (f = M.current) == null ? void 0 : f.querySelector(`${Rr}[aria-selected="true"]`);
2094
+ }
2095
+ function U() {
2096
+ var f;
2097
+ return Array.from(((f = M.current) == null ? void 0 : f.querySelectorAll(ft)) || []);
2098
+ }
2099
+ function L(f) {
2100
+ let R = U()[f];
2101
+ R && E.setState("value", R.getAttribute(ve));
2102
+ }
2103
+ function q(f) {
2104
+ var R;
2105
+ let k = K(), I = U(), _ = I.findIndex((T) => T === k), g = I[_ + f];
2106
+ (R = i.current) != null && R.loop && (g = _ + f < 0 ? I[I.length - 1] : _ + f === I.length ? I[0] : I[_ + f]), g && E.setState("value", g.getAttribute(ve));
2107
+ }
2108
+ function Z(f) {
2109
+ let R = K(), k = R?.closest(Se), I;
2110
+ for (; k && !I; ) k = f > 0 ? ia(k, Se) : da(k, Se), I = k?.querySelector(ft);
2111
+ I ? E.setState("value", I.getAttribute(ve)) : q(f);
2112
+ }
2113
+ let J = () => L(U().length - 1), he = (f) => {
2114
+ f.preventDefault(), f.metaKey ? J() : f.altKey ? Z(1) : q(1);
2115
+ }, ce = (f) => {
2116
+ f.preventDefault(), f.metaKey ? L(0) : f.altKey ? Z(-1) : q(-1);
2117
+ };
2118
+ return a.createElement(P.div, { ref: r, tabIndex: -1, ...w, "cmdk-root": "", onKeyDown: (f) => {
2119
+ var R;
2120
+ (R = w.onKeyDown) == null || R.call(w, f);
2121
+ let k = f.nativeEvent.isComposing || f.keyCode === 229;
2122
+ if (!(f.defaultPrevented || k)) switch (f.key) {
2123
+ case "n":
2124
+ case "j": {
2125
+ m && f.ctrlKey && he(f);
2126
+ break;
2127
+ }
2128
+ case "ArrowDown": {
2129
+ he(f);
2130
+ break;
2131
+ }
2132
+ case "p":
2133
+ case "k": {
2134
+ m && f.ctrlKey && ce(f);
2135
+ break;
2136
+ }
2137
+ case "ArrowUp": {
2138
+ ce(f);
2139
+ break;
2140
+ }
2141
+ case "Home": {
2142
+ f.preventDefault(), L(0);
2143
+ break;
2144
+ }
2145
+ case "End": {
2146
+ f.preventDefault(), J();
2147
+ break;
2148
+ }
2149
+ case "Enter": {
2150
+ f.preventDefault();
2151
+ let I = K();
2152
+ if (I) {
2153
+ let _ = new Event(Qe);
2154
+ I.dispatchEvent(_);
2155
+ }
2156
+ }
2157
+ }
2158
+ } }, a.createElement("label", { "cmdk-label": "", htmlFor: D.inputId, id: D.labelId, style: fa }, u), Oe(e, (f) => a.createElement(Er.Provider, { value: E }, a.createElement(kr.Provider, { value: D }, f))));
2159
+ }), ta = a.forwardRef((e, r) => {
2160
+ var t, s;
2161
+ let n = te(), l = a.useRef(null), c = a.useContext(jr), i = je(), u = _r(e), d = (s = (t = u.current) == null ? void 0 : t.forceMount) != null ? s : c?.forceMount;
2162
+ me(() => {
2163
+ if (!d) return i.item(n, c?.id);
2164
+ }, [d]);
2165
+ let p = Tr(n, l, [e.value, e.children, l], e.keywords), v = ct(), y = ae((j) => j.value && j.value === p.current), b = ae((j) => d || i.filter() === !1 ? !0 : j.search ? j.filtered.items.get(n) > 0 : !0);
2166
+ a.useEffect(() => {
2167
+ let j = l.current;
2168
+ if (!(!j || e.disabled)) return j.addEventListener(Qe, S), () => j.removeEventListener(Qe, S);
2169
+ }, [b, e.onSelect, e.disabled]);
2170
+ function S() {
2171
+ var j, E;
2172
+ h(), (E = (j = u.current).onSelect) == null || E.call(j, p.current);
2173
+ }
2174
+ function h() {
2175
+ v.setState("value", p.current, !0);
2176
+ }
2177
+ if (!b) return null;
2178
+ let { disabled: m, value: w, onSelect: x, forceMount: C, keywords: N, ...M } = e;
2179
+ return a.createElement(P.div, { ref: Ie(l, r), ...M, id: n, "cmdk-item": "", role: "option", "aria-disabled": !!m, "aria-selected": !!y, "data-disabled": !!m, "data-selected": !!y, onPointerMove: m || i.getDisablePointerSelection() ? void 0 : h, onClick: m ? void 0 : S }, e.children);
2180
+ }), ra = a.forwardRef((e, r) => {
2181
+ let { heading: t, children: s, forceMount: n, ...l } = e, c = te(), i = a.useRef(null), u = a.useRef(null), d = te(), p = je(), v = ae((b) => n || p.filter() === !1 ? !0 : b.search ? b.filtered.groups.has(c) : !0);
2182
+ me(() => p.group(c), []), Tr(c, i, [e.value, e.heading, u]);
2183
+ let y = a.useMemo(() => ({ id: c, forceMount: n }), [n]);
2184
+ return a.createElement(P.div, { ref: Ie(i, r), ...l, "cmdk-group": "", role: "presentation", hidden: v ? void 0 : !0 }, t && a.createElement("div", { ref: u, "cmdk-group-heading": "", "aria-hidden": !0, id: d }, t), Oe(e, (b) => a.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? d : void 0 }, a.createElement(jr.Provider, { value: y }, b))));
2185
+ }), oa = a.forwardRef((e, r) => {
2186
+ let { alwaysRender: t, ...s } = e, n = a.useRef(null), l = ae((c) => !c.search);
2187
+ return !t && !l ? null : a.createElement(P.div, { ref: Ie(n, r), ...s, "cmdk-separator": "", role: "separator" });
2188
+ }), na = a.forwardRef((e, r) => {
2189
+ let { onValueChange: t, ...s } = e, n = e.value != null, l = ct(), c = ae((d) => d.search), i = ae((d) => d.selectedItemId), u = je();
2190
+ return a.useEffect(() => {
2191
+ e.value != null && l.setState("search", e.value);
2192
+ }, [e.value]), a.createElement(P.input, { ref: r, ...s, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": u.listId, "aria-labelledby": u.labelId, "aria-activedescendant": i, id: u.inputId, type: "text", value: n ? e.value : c, onChange: (d) => {
2193
+ n || l.setState("search", d.target.value), t?.(d.target.value);
2194
+ } });
2195
+ }), aa = a.forwardRef((e, r) => {
2196
+ let { children: t, label: s = "Suggestions", ...n } = e, l = a.useRef(null), c = a.useRef(null), i = ae((d) => d.selectedItemId), u = je();
2197
+ return a.useEffect(() => {
2198
+ if (c.current && l.current) {
2199
+ let d = c.current, p = l.current, v, y = new ResizeObserver(() => {
2200
+ v = requestAnimationFrame(() => {
2201
+ let b = d.offsetHeight;
2202
+ p.style.setProperty("--cmdk-list-height", b.toFixed(1) + "px");
2203
+ });
2204
+ });
2205
+ return y.observe(d), () => {
2206
+ cancelAnimationFrame(v), y.unobserve(d);
2207
+ };
2208
+ }
2209
+ }, []), a.createElement(P.div, { ref: Ie(l, r), ...n, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": i, "aria-label": s, id: u.listId }, Oe(e, (d) => a.createElement("div", { ref: Ie(c, u.listInnerRef), "cmdk-list-sizer": "" }, d)));
2210
+ }), sa = a.forwardRef((e, r) => {
2211
+ let { open: t, onOpenChange: s, overlayClassName: n, contentClassName: l, container: c, ...i } = e;
2212
+ return a.createElement(qr, { open: t, onOpenChange: s }, a.createElement(Yr, { container: c }, a.createElement(Xr, { "cmdk-overlay": "", className: n }), a.createElement(Zr, { "aria-label": e.label, "cmdk-dialog": "", className: l }, a.createElement(Nr, { ref: r, ...i }))));
2213
+ }), la = a.forwardRef((e, r) => ae((t) => t.filtered.count === 0) ? a.createElement(P.div, { ref: r, ...e, "cmdk-empty": "", role: "presentation" }) : null), ca = a.forwardRef((e, r) => {
2214
+ let { progress: t, children: s, label: n = "Loading...", ...l } = e;
2215
+ return a.createElement(P.div, { ref: r, ...l, "cmdk-loading": "", role: "progressbar", "aria-valuenow": t, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": n }, Oe(e, (c) => a.createElement("div", { "aria-hidden": !0 }, c)));
2216
+ }), ye = Object.assign(Nr, { List: aa, Item: ta, Input: na, Group: ra, Separator: oa, Dialog: sa, Empty: la, Loading: ca });
2217
+ function ia(e, r) {
2218
+ let t = e.nextElementSibling;
2219
+ for (; t; ) {
2220
+ if (t.matches(r)) return t;
2221
+ t = t.nextElementSibling;
2222
+ }
2223
+ }
2224
+ function da(e, r) {
2225
+ let t = e.previousElementSibling;
2226
+ for (; t; ) {
2227
+ if (t.matches(r)) return t;
2228
+ t = t.previousElementSibling;
2229
+ }
2230
+ }
2231
+ function _r(e) {
2232
+ let r = a.useRef(e);
2233
+ return me(() => {
2234
+ r.current = e;
2235
+ }), r;
2236
+ }
2237
+ var me = typeof window > "u" ? a.useEffect : a.useLayoutEffect;
2238
+ function xe(e) {
2239
+ let r = a.useRef();
2240
+ return r.current === void 0 && (r.current = e()), r;
2241
+ }
2242
+ function ae(e) {
2243
+ let r = ct(), t = () => e(r.snapshot());
2244
+ return a.useSyncExternalStore(r.subscribe, t, t);
2245
+ }
2246
+ function Tr(e, r, t, s = []) {
2247
+ let n = a.useRef(), l = je();
2248
+ return me(() => {
2249
+ var c;
2250
+ let i = (() => {
2251
+ var d;
2252
+ for (let p of t) {
2253
+ if (typeof p == "string") return p.trim();
2254
+ if (typeof p == "object" && "current" in p) return p.current ? (d = p.current.textContent) == null ? void 0 : d.trim() : n.current;
2255
+ }
2256
+ })(), u = s.map((d) => d.trim());
2257
+ l.value(e, i, u), (c = r.current) == null || c.setAttribute(ve, i), n.current = i;
2258
+ }), n;
2259
+ }
2260
+ var ua = () => {
2261
+ let [e, r] = a.useState(), t = xe(() => /* @__PURE__ */ new Map());
2262
+ return me(() => {
2263
+ t.current.forEach((s) => s()), t.current = /* @__PURE__ */ new Map();
2264
+ }, [e]), (s, n) => {
2265
+ t.current.set(s, n), r({});
2266
+ };
2267
+ };
2268
+ function pa(e) {
2269
+ let r = e.type;
2270
+ return typeof r == "function" ? r(e.props) : "render" in r ? r.render(e.props) : e;
2271
+ }
2272
+ function Oe({ asChild: e, children: r }, t) {
2273
+ return e && a.isValidElement(r) ? a.cloneElement(pa(r), { ref: r.ref }, t(r.props.children)) : t(r);
2274
+ }
2275
+ var fa = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
2276
+ function ma({ className: e, ...r }) {
2277
+ return /* @__PURE__ */ o.jsx(
2278
+ ye,
2279
+ {
2280
+ className: $(
2281
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
2282
+ e
2283
+ ),
2284
+ "data-slot": "command",
2285
+ ...r
2286
+ }
2287
+ );
2288
+ }
2289
+ function ha({ className: e, ...r }) {
2290
+ return /* @__PURE__ */ o.jsxs("div", { className: "flex h-9 items-center gap-2 border-b px-3", "data-slot": "command-input-wrapper", children: [
2291
+ /* @__PURE__ */ o.jsx(mo, { className: "size-4 shrink-0 opacity-50" }),
2292
+ /* @__PURE__ */ o.jsx(
2293
+ ye.Input,
2294
+ {
2295
+ className: $(
2296
+ "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",
2297
+ e
2298
+ ),
2299
+ "data-slot": "command-input",
2300
+ ...r
2301
+ }
2302
+ )
2303
+ ] });
2304
+ }
2305
+ function va({ className: e, ...r }) {
2306
+ return /* @__PURE__ */ o.jsx(
2307
+ ye.List,
2308
+ {
2309
+ className: $("max-h-[300px] scroll-py-1 overflow-y-auto overflow-x-hidden", e),
2310
+ "data-slot": "command-list",
2311
+ ...r
2312
+ }
2313
+ );
2314
+ }
2315
+ function xa({ ...e }) {
2316
+ return /* @__PURE__ */ o.jsx(ye.Empty, { className: "py-6 text-center text-sm", "data-slot": "command-empty", ...e });
2317
+ }
2318
+ function ga({ className: e, ...r }) {
2319
+ return /* @__PURE__ */ o.jsx(
2320
+ ye.Group,
2321
+ {
2322
+ className: $(
2323
+ "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",
2324
+ e
2325
+ ),
2326
+ "data-slot": "command-group",
2327
+ ...r
2328
+ }
2329
+ );
2330
+ }
2331
+ function ba({ className: e, ...r }) {
2332
+ return /* @__PURE__ */ o.jsx(
2333
+ ye.Item,
2334
+ {
2335
+ className: $(
2336
+ "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",
2337
+ e
2338
+ ),
2339
+ "data-slot": "command-item",
2340
+ ...r
2341
+ }
2342
+ );
2343
+ }
2344
+ const wa = ({
2345
+ placeholder: e,
2346
+ selected: r,
2347
+ className: t,
2348
+ open: s,
2349
+ renderSelected: n = (l) => l.label
2350
+ }) => /* @__PURE__ */ o.jsx(bt, { asChild: !0, children: /* @__PURE__ */ o.jsxs(Mr, { "aria-expanded": s, className: `justify-between ${t}`, role: "combobox", variant: "outline", children: [
2351
+ n(r || { label: e, value: "" }),
2352
+ /* @__PURE__ */ o.jsx(ao, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
2353
+ ] }) }), Ba = ({
2354
+ options: e,
2355
+ value: r = "",
2356
+ placeholder: t = "Select a value...",
2357
+ className: s = "",
2358
+ onSelect: n = () => {
2359
+ },
2360
+ renderSelected: l = (c) => c.label
2361
+ }) => {
2362
+ const [c, i] = tt(!1), u = Dr(() => e.find((d) => d.value === r), [e, r]);
2363
+ return /* @__PURE__ */ o.jsxs(gt, { onOpenChange: i, open: c, children: [
2364
+ /* @__PURE__ */ o.jsx(
2365
+ wa,
2366
+ {
2367
+ className: `w-full ${s}`,
2368
+ open: c,
2369
+ placeholder: t,
2370
+ renderSelected: l,
2371
+ selected: u
2372
+ }
2373
+ ),
2374
+ /* @__PURE__ */ o.jsx(wt, { className: "w-full p-0", children: /* @__PURE__ */ o.jsxs(ma, { value: r, children: [
2375
+ /* @__PURE__ */ o.jsx(ha, { "aria-label": "Search options", className: "h-9", placeholder: "Search" }),
2376
+ /* @__PURE__ */ o.jsxs(va, { children: [
2377
+ /* @__PURE__ */ o.jsx(xa, { children: "No results found" }),
2378
+ /* @__PURE__ */ o.jsx(ga, { children: e.map((d) => /* @__PURE__ */ o.jsxs(
2379
+ ba,
2380
+ {
2381
+ onSelect: () => {
2382
+ i(!1), n(d.value);
2383
+ },
2384
+ value: d.value,
2385
+ children: [
2386
+ d.icon ? /* @__PURE__ */ o.jsx("span", { className: "mr-2", children: d.icon }) : "",
2387
+ d.label,
2388
+ /* @__PURE__ */ o.jsx(rt, { className: $("ml-auto", d.value === r ? "opacity-100" : "opacity-0") })
2389
+ ]
2390
+ },
2391
+ d.value
2392
+ )) })
2393
+ ] })
2394
+ ] }) })
2395
+ ] });
2396
+ };
2397
+ function ya({ className: e, ...r }) {
2398
+ return /* @__PURE__ */ o.jsx(
2399
+ "textarea",
2400
+ {
2401
+ className: $(
2402
+ "field-sizing-content flex min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs outline-none transition-[color,box-shadow] placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:aria-invalid:ring-destructive/40",
2403
+ e
2404
+ ),
2405
+ "data-slot": "textarea",
2406
+ ...r
2407
+ }
2408
+ );
2409
+ }
2410
+ function $a({ label: e, name: r, note: t, placeholder: s, className: n, error: l, ...c }) {
2411
+ return /* @__PURE__ */ o.jsxs(oe, { className: "w-full", direction: "col", gap: "2", children: [
2412
+ e && /* @__PURE__ */ o.jsx(we, { htmlFor: r, children: e }),
2413
+ /* @__PURE__ */ o.jsx(
2414
+ ya,
2415
+ {
2416
+ "aria-label": e || r,
2417
+ className: n,
2418
+ id: r,
2419
+ name: r,
2420
+ placeholder: s,
2421
+ ...c
2422
+ }
2423
+ ),
2424
+ t && /* @__PURE__ */ o.jsx(_e, { size: "sm", variant: "muted", children: t }),
2425
+ l && /* @__PURE__ */ o.jsx(Ee, { message: l })
2426
+ ] });
2427
+ }
2428
+ export {
2429
+ Ma as C,
2430
+ Ta as D,
2431
+ Ee as I,
2432
+ we as L,
2433
+ Oa as N,
2434
+ Fa as R,
2435
+ Pa as S,
2436
+ $a as T,
2437
+ Aa as a,
2438
+ Da as b,
2439
+ Pn as c,
2440
+ La as d,
2441
+ Ba as e,
2442
+ Cr as f,
2443
+ Ct as g,
2444
+ Mt as h,
2445
+ Mo as i,
2446
+ Ao as j,
2447
+ St as k,
2448
+ ot as u
2449
+ };