@rinzai/zen 0.1.11 → 0.2.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.
Files changed (59) hide show
  1. package/dist/index.d.ts +2 -17
  2. package/dist/{badge → packages/badge}/index.d.ts +1 -1
  3. package/dist/packages/badge/index.d.ts.map +1 -0
  4. package/dist/packages/button/index.d.ts.map +1 -0
  5. package/dist/packages/collapse/index.d.ts.map +1 -0
  6. package/dist/packages/dropdown/index.d.ts.map +1 -0
  7. package/dist/packages/icons/chevron-down.d.ts.map +1 -0
  8. package/dist/packages/icons/chevron-up.d.ts.map +1 -0
  9. package/dist/packages/icons/icon.types.d.ts.map +1 -0
  10. package/dist/packages/icons/index.d.ts.map +1 -0
  11. package/dist/packages/icons/search.d.ts.map +1 -0
  12. package/dist/packages/icons/x-mark.d.ts.map +1 -0
  13. package/dist/packages/index.d.ts +17 -0
  14. package/dist/packages/index.d.ts.map +1 -0
  15. package/dist/packages/input/index.d.ts.map +1 -0
  16. package/dist/{popover → packages/popover}/index.d.ts +2 -0
  17. package/dist/packages/popover/index.d.ts.map +1 -0
  18. package/dist/packages/textarea/index.d.ts +4 -0
  19. package/dist/packages/textarea/index.d.ts.map +1 -0
  20. package/dist/{toggle → packages/toggle}/index.d.ts +1 -1
  21. package/dist/packages/toggle/index.d.ts.map +1 -0
  22. package/dist/packages/utils/cva.d.ts.map +1 -0
  23. package/dist/packages/utils/cx.d.ts.map +1 -0
  24. package/dist/packages/utils/useClickOutside.d.ts.map +1 -0
  25. package/dist/zen.css +3 -1
  26. package/dist/zen.js +920 -2194
  27. package/package.json +77 -69
  28. package/dist/badge/index.d.ts.map +0 -1
  29. package/dist/button/index.d.ts.map +0 -1
  30. package/dist/collapse/index.d.ts.map +0 -1
  31. package/dist/dropdown/index.d.ts.map +0 -1
  32. package/dist/icons/chevron-down.d.ts.map +0 -1
  33. package/dist/icons/chevron-up.d.ts.map +0 -1
  34. package/dist/icons/icon.types.d.ts.map +0 -1
  35. package/dist/icons/index.d.ts.map +0 -1
  36. package/dist/icons/search.d.ts.map +0 -1
  37. package/dist/icons/x-mark.d.ts.map +0 -1
  38. package/dist/index.d.ts.map +0 -1
  39. package/dist/input/index.d.ts.map +0 -1
  40. package/dist/popover/index.d.ts.map +0 -1
  41. package/dist/textarea/index.d.ts +0 -4
  42. package/dist/textarea/index.d.ts.map +0 -1
  43. package/dist/toggle/index.d.ts.map +0 -1
  44. package/dist/utils/cva.d.ts.map +0 -1
  45. package/dist/utils/cx.d.ts.map +0 -1
  46. package/dist/utils/useClickOutside.d.ts.map +0 -1
  47. /package/dist/{button → packages/button}/index.d.ts +0 -0
  48. /package/dist/{collapse → packages/collapse}/index.d.ts +0 -0
  49. /package/dist/{dropdown → packages/dropdown}/index.d.ts +0 -0
  50. /package/dist/{icons → packages/icons}/chevron-down.d.ts +0 -0
  51. /package/dist/{icons → packages/icons}/chevron-up.d.ts +0 -0
  52. /package/dist/{icons → packages/icons}/icon.types.d.ts +0 -0
  53. /package/dist/{icons → packages/icons}/index.d.ts +0 -0
  54. /package/dist/{icons → packages/icons}/search.d.ts +0 -0
  55. /package/dist/{icons → packages/icons}/x-mark.d.ts +0 -0
  56. /package/dist/{input → packages/input}/index.d.ts +0 -0
  57. /package/dist/{utils → packages/utils}/cva.d.ts +0 -0
  58. /package/dist/{utils → packages/utils}/cx.d.ts +0 -0
  59. /package/dist/{utils → packages/utils}/useClickOutside.d.ts +0 -0
package/dist/zen.js CHANGED
@@ -1,2201 +1,927 @@
1
- import { jsx as y, jsxs as V, Fragment as je } from "react/jsx-runtime";
2
- import * as O from "react";
3
- import { useLayoutEffect as rt, useState as fe, useId as lt, useEffect as be, useMemo as ye, useRef as ve } from "react";
4
- import * as ct from "react-dom";
5
- import { createPortal as at, flushSync as ut } from "react-dom";
6
- const k = (...e) => e.reduce((o, t) => t == null || t === !1 ? o : typeof t == "string" || typeof t == "number" ? o + " " + t : Array.isArray(t) ? o + " " + k(...t) : typeof t == "object" ? o + " " + Object.entries(t).reduce((n, [s, i]) => i == null || i === !1 ? n : typeof i == "string" || typeof i == "number" ? n + " " + s + "-" + i : typeof i == "boolean" && i ? n + " " + s : n, "") : o, ""), Ae = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, $e = (e, o) => (t) => {
7
- if (o?.variants == null) return k(e, t?.class, t?.className);
8
- const { variants: n, defaultVariants: s } = o, i = Object.keys(n).map((c) => {
9
- const u = t?.[c], a = s?.[c];
10
- if (u === null) return null;
11
- const d = Ae(u) || Ae(a);
12
- return n[c][d];
13
- }), r = t && Object.entries(t).reduce(
14
- (c, [u, a]) => (a === void 0 || (c[u] = a), c),
15
- {}
16
- ), l = o?.compoundVariants?.reduce(
17
- (c, { class: u, className: a, ...d }) => Object.entries(d).every(
18
- ([h, f]) => Array.isArray(f) ? f.includes(
19
- {
20
- ...s,
21
- ...r
22
- }[h]
23
- ) : {
24
- ...s,
25
- ...r
26
- }[h] === f
27
- ) ? [...c, u, a] : c,
28
- []
29
- );
30
- return k(e, i, l, t?.class, t?.className);
1
+ import * as e from "react";
2
+ import { useEffect as t, useId as n, useMemo as r, useRef as i, useState as a } from "react";
3
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ import { flushSync as l } from "react-dom";
5
+ //#region packages/utils/cx.ts
6
+ var u = (...e) => e.reduce((e, t) => t == null || t === !1 ? e : typeof t == "string" || typeof t == "number" ? e + " " + t : Array.isArray(t) ? e + " " + u(...t) : typeof t == "object" ? e + " " + Object.entries(t).reduce((e, [t, n]) => n == null || n === !1 ? e : typeof n == "string" || typeof n == "number" ? e + " " + t + "-" + n : typeof n == "boolean" && n ? e + " " + t : e, "") : e, ""), d = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, f = (e, t) => (n) => {
7
+ if (t?.variants == null) return u(e, n?.class, n?.className);
8
+ let { variants: r, defaultVariants: i } = t, a = Object.keys(r).map((e) => {
9
+ let t = n?.[e], a = i?.[e];
10
+ if (t === null) return null;
11
+ let o = d(t) || d(a);
12
+ return r[e][o];
13
+ }), o = n && Object.entries(n).reduce((e, [t, n]) => (n === void 0 || (e[t] = n), e), {}), s = t?.compoundVariants?.reduce((e, { class: t, className: n, ...r }) => Object.entries(r).every(([e, t]) => Array.isArray(t) ? t.includes({
14
+ ...i,
15
+ ...o
16
+ }[e]) : {
17
+ ...i,
18
+ ...o
19
+ }[e] === t) ? [
20
+ ...e,
21
+ t,
22
+ n
23
+ ] : e, []);
24
+ return u(e, a, s, n?.class, n?.className);
31
25
  };
32
- function He({ variant: e, className: o, ...t }) {
33
- return /* @__PURE__ */ y("span", { ...t, className: ft({ variant: e, className: o }) });
34
- }
35
- const ft = $e(
36
- "zen__badge inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors whitespace-nowrap",
37
- {
38
- variants: {
39
- variant: {
40
- default: "border-transparent bg-primary text-primary-foreground shadow-sm",
41
- secondary: "border-transparent bg-secondary text-secondary-foreground",
42
- destructive: "border-transparent bg-destructive text-destructive-foreground shadow-sm",
43
- outline: "text-foreground"
44
- }
45
- },
46
- defaultVariants: {
47
- variant: "default"
48
- }
49
- }
50
- );
51
- function dt({ className: e, variant: o, size: t, ...n }) {
52
- return /* @__PURE__ */ y("button", { className: ht({ variant: o, size: t, className: e }), ...n });
53
- }
54
- const ht = $e(
55
- "zen__button inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
56
- {
57
- variants: {
58
- variant: {
59
- default: "bg-primary text-primary-foreground shadow-sm hover:bg-primary/90",
60
- destructive: "bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90",
61
- outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
62
- secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
63
- ghost: "hover:bg-accent hover:text-accent-foreground",
64
- link: "text-primary underline-offset-4 hover:underline",
65
- icon: ""
66
- },
67
- size: {
68
- default: "h-9 px-4 py-2",
69
- sm: "h-8 rounded-md px-3 text-xs",
70
- lg: "h-10 rounded-md px-8",
71
- icon: ""
72
- }
73
- },
74
- defaultVariants: {
75
- variant: "default",
76
- size: "default"
77
- }
78
- }
79
- ), re = Math.min, q = Math.max, le = Math.round, se = Math.floor, I = (e) => ({
80
- x: e,
81
- y: e
82
- }), mt = {
83
- left: "right",
84
- right: "left",
85
- bottom: "top",
86
- top: "bottom"
87
- }, gt = {
88
- start: "end",
89
- end: "start"
90
- };
91
- function Me(e, o, t) {
92
- return q(e, re(o, t));
93
- }
94
- function de(e, o) {
95
- return typeof e == "function" ? e(o) : e;
96
- }
97
- function U(e) {
98
- return e.split("-")[0];
99
- }
100
- function he(e) {
101
- return e.split("-")[1];
102
- }
103
- function qe(e) {
104
- return e === "x" ? "y" : "x";
105
- }
106
- function Ue(e) {
107
- return e === "y" ? "height" : "width";
108
- }
109
- const pt = /* @__PURE__ */ new Set(["top", "bottom"]);
110
- function $(e) {
111
- return pt.has(U(e)) ? "y" : "x";
112
- }
113
- function Ke(e) {
114
- return qe($(e));
115
- }
116
- function wt(e, o, t) {
117
- t === void 0 && (t = !1);
118
- const n = he(e), s = Ke(e), i = Ue(s);
119
- let r = s === "x" ? n === (t ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
120
- return o.reference[i] > o.floating[i] && (r = ce(r)), [r, ce(r)];
121
- }
122
- function xt(e) {
123
- const o = ce(e);
124
- return [Se(e), o, Se(o)];
125
- }
126
- function Se(e) {
127
- return e.replace(/start|end/g, (o) => gt[o]);
128
- }
129
- const ze = ["left", "right"], Ne = ["right", "left"], bt = ["top", "bottom"], yt = ["bottom", "top"];
130
- function vt(e, o, t) {
131
- switch (e) {
132
- case "top":
133
- case "bottom":
134
- return t ? o ? Ne : ze : o ? ze : Ne;
135
- case "left":
136
- case "right":
137
- return o ? bt : yt;
138
- default:
139
- return [];
140
- }
141
- }
142
- function St(e, o, t, n) {
143
- const s = he(e);
144
- let i = vt(U(e), t === "start", n);
145
- return s && (i = i.map((r) => r + "-" + s), o && (i = i.concat(i.map(Se)))), i;
146
- }
147
- function ce(e) {
148
- return e.replace(/left|right|bottom|top/g, (o) => mt[o]);
149
- }
150
- function Ct(e) {
151
- return {
152
- top: 0,
153
- right: 0,
154
- bottom: 0,
155
- left: 0,
156
- ...e
157
- };
158
- }
159
- function Ot(e) {
160
- return typeof e != "number" ? Ct(e) : {
161
- top: e,
162
- right: e,
163
- bottom: e,
164
- left: e
165
- };
166
- }
167
- function ae(e) {
168
- const {
169
- x: o,
170
- y: t,
171
- width: n,
172
- height: s
173
- } = e;
174
- return {
175
- width: n,
176
- height: s,
177
- top: t,
178
- left: o,
179
- right: o + n,
180
- bottom: t + s,
181
- x: o,
182
- y: t
183
- };
184
- }
185
- function Le(e, o, t) {
186
- let {
187
- reference: n,
188
- floating: s
189
- } = e;
190
- const i = $(o), r = Ke(o), l = Ue(r), c = U(o), u = i === "y", a = n.x + n.width / 2 - s.width / 2, d = n.y + n.height / 2 - s.height / 2, h = n[l] / 2 - s[l] / 2;
191
- let f;
192
- switch (c) {
193
- case "top":
194
- f = {
195
- x: a,
196
- y: n.y - s.height
197
- };
198
- break;
199
- case "bottom":
200
- f = {
201
- x: a,
202
- y: n.y + n.height
203
- };
204
- break;
205
- case "right":
206
- f = {
207
- x: n.x + n.width,
208
- y: d
209
- };
210
- break;
211
- case "left":
212
- f = {
213
- x: n.x - s.width,
214
- y: d
215
- };
216
- break;
217
- default:
218
- f = {
219
- x: n.x,
220
- y: n.y
221
- };
222
- }
223
- switch (he(o)) {
224
- case "start":
225
- f[r] -= h * (t && u ? -1 : 1);
226
- break;
227
- case "end":
228
- f[r] += h * (t && u ? -1 : 1);
229
- break;
230
- }
231
- return f;
232
- }
233
- const Et = async (e, o, t) => {
234
- const {
235
- placement: n = "bottom",
236
- strategy: s = "absolute",
237
- middleware: i = [],
238
- platform: r
239
- } = t, l = i.filter(Boolean), c = await (r.isRTL == null ? void 0 : r.isRTL(o));
240
- let u = await r.getElementRects({
241
- reference: e,
242
- floating: o,
243
- strategy: s
244
- }), {
245
- x: a,
246
- y: d
247
- } = Le(u, n, c), h = n, f = {}, g = 0;
248
- for (let m = 0; m < l.length; m++) {
249
- const {
250
- name: p,
251
- fn: w
252
- } = l[m], {
253
- x,
254
- y: v,
255
- data: S,
256
- reset: b
257
- } = await w({
258
- x: a,
259
- y: d,
260
- initialPlacement: n,
261
- placement: h,
262
- strategy: s,
263
- middlewareData: f,
264
- rects: u,
265
- platform: r,
266
- elements: {
267
- reference: e,
268
- floating: o
269
- }
270
- });
271
- a = x ?? a, d = v ?? d, f = {
272
- ...f,
273
- [p]: {
274
- ...f[p],
275
- ...S
276
- }
277
- }, b && g <= 50 && (g++, typeof b == "object" && (b.placement && (h = b.placement), b.rects && (u = b.rects === !0 ? await r.getElementRects({
278
- reference: e,
279
- floating: o,
280
- strategy: s
281
- }) : b.rects), {
282
- x: a,
283
- y: d
284
- } = Le(u, h, c)), m = -1);
285
- }
286
- return {
287
- x: a,
288
- y: d,
289
- placement: h,
290
- strategy: s,
291
- middlewareData: f
292
- };
293
- };
294
- async function Ye(e, o) {
295
- var t;
296
- o === void 0 && (o = {});
297
- const {
298
- x: n,
299
- y: s,
300
- platform: i,
301
- rects: r,
302
- elements: l,
303
- strategy: c
304
- } = e, {
305
- boundary: u = "clippingAncestors",
306
- rootBoundary: a = "viewport",
307
- elementContext: d = "floating",
308
- altBoundary: h = !1,
309
- padding: f = 0
310
- } = de(o, e), g = Ot(f), p = l[h ? d === "floating" ? "reference" : "floating" : d], w = ae(await i.getClippingRect({
311
- element: (t = await (i.isElement == null ? void 0 : i.isElement(p))) == null || t ? p : p.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(l.floating)),
312
- boundary: u,
313
- rootBoundary: a,
314
- strategy: c
315
- })), x = d === "floating" ? {
316
- x: n,
317
- y: s,
318
- width: r.floating.width,
319
- height: r.floating.height
320
- } : r.reference, v = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(l.floating)), S = await (i.isElement == null ? void 0 : i.isElement(v)) ? await (i.getScale == null ? void 0 : i.getScale(v)) || {
321
- x: 1,
322
- y: 1
323
- } : {
324
- x: 1,
325
- y: 1
326
- }, b = ae(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
327
- elements: l,
328
- rect: x,
329
- offsetParent: v,
330
- strategy: c
331
- }) : x);
332
- return {
333
- top: (w.top - b.top + g.top) / S.y,
334
- bottom: (b.bottom - w.bottom + g.bottom) / S.y,
335
- left: (w.left - b.left + g.left) / S.x,
336
- right: (b.right - w.right + g.right) / S.x
337
- };
338
- }
339
- const Rt = function(e) {
340
- return e === void 0 && (e = {}), {
341
- name: "flip",
342
- options: e,
343
- async fn(o) {
344
- var t, n;
345
- const {
346
- placement: s,
347
- middlewareData: i,
348
- rects: r,
349
- initialPlacement: l,
350
- platform: c,
351
- elements: u
352
- } = o, {
353
- mainAxis: a = !0,
354
- crossAxis: d = !0,
355
- fallbackPlacements: h,
356
- fallbackStrategy: f = "bestFit",
357
- fallbackAxisSideDirection: g = "none",
358
- flipAlignment: m = !0,
359
- ...p
360
- } = de(e, o);
361
- if ((t = i.arrow) != null && t.alignmentOffset)
362
- return {};
363
- const w = U(s), x = $(l), v = U(l) === l, S = await (c.isRTL == null ? void 0 : c.isRTL(u.floating)), b = h || (v || !m ? [ce(l)] : xt(l)), R = g !== "none";
364
- !h && R && b.push(...St(l, m, g, S));
365
- const E = [l, ...b], W = await Ye(o, p), Y = [];
366
- let _ = ((n = i.flip) == null ? void 0 : n.overflows) || [];
367
- if (a && Y.push(W[w]), d) {
368
- const N = wt(s, r, S);
369
- Y.push(W[N[0]], W[N[1]]);
370
- }
371
- if (_ = [..._, {
372
- placement: s,
373
- overflows: Y
374
- }], !Y.every((N) => N <= 0)) {
375
- var X, te;
376
- const N = (((X = i.flip) == null ? void 0 : X.index) || 0) + 1, Z = E[N];
377
- if (Z && (!(d === "alignment" ? x !== $(Z) : !1) || // We leave the current main axis only if every placement on that axis
378
- // overflows the main axis.
379
- _.every((C) => C.overflows[0] > 0 && $(C.placement) === x)))
380
- return {
381
- data: {
382
- index: N,
383
- overflows: _
384
- },
385
- reset: {
386
- placement: Z
387
- }
388
- };
389
- let A = (te = _.filter((D) => D.overflows[0] <= 0).sort((D, C) => D.overflows[1] - C.overflows[1])[0]) == null ? void 0 : te.placement;
390
- if (!A)
391
- switch (f) {
392
- case "bestFit": {
393
- var B;
394
- const D = (B = _.filter((C) => {
395
- if (R) {
396
- const M = $(C.placement);
397
- return M === x || // Create a bias to the `y` side axis due to horizontal
398
- // reading directions favoring greater width.
399
- M === "y";
400
- }
401
- return !0;
402
- }).map((C) => [C.placement, C.overflows.filter((M) => M > 0).reduce((M, j) => M + j, 0)]).sort((C, M) => C[1] - M[1])[0]) == null ? void 0 : B[0];
403
- D && (A = D);
404
- break;
405
- }
406
- case "initialPlacement":
407
- A = l;
408
- break;
409
- }
410
- if (s !== A)
411
- return {
412
- reset: {
413
- placement: A
414
- }
415
- };
416
- }
417
- return {};
418
- }
419
- };
420
- }, kt = /* @__PURE__ */ new Set(["left", "top"]);
421
- async function At(e, o) {
422
- const {
423
- placement: t,
424
- platform: n,
425
- elements: s
426
- } = e, i = await (n.isRTL == null ? void 0 : n.isRTL(s.floating)), r = U(t), l = he(t), c = $(t) === "y", u = kt.has(r) ? -1 : 1, a = i && c ? -1 : 1, d = de(o, e);
427
- let {
428
- mainAxis: h,
429
- crossAxis: f,
430
- alignmentAxis: g
431
- } = typeof d == "number" ? {
432
- mainAxis: d,
433
- crossAxis: 0,
434
- alignmentAxis: null
435
- } : {
436
- mainAxis: d.mainAxis || 0,
437
- crossAxis: d.crossAxis || 0,
438
- alignmentAxis: d.alignmentAxis
439
- };
440
- return l && typeof g == "number" && (f = l === "end" ? g * -1 : g), c ? {
441
- x: f * a,
442
- y: h * u
443
- } : {
444
- x: h * u,
445
- y: f * a
446
- };
447
- }
448
- const Mt = function(e) {
449
- return e === void 0 && (e = 0), {
450
- name: "offset",
451
- options: e,
452
- async fn(o) {
453
- var t, n;
454
- const {
455
- x: s,
456
- y: i,
457
- placement: r,
458
- middlewareData: l
459
- } = o, c = await At(o, e);
460
- return r === ((t = l.offset) == null ? void 0 : t.placement) && (n = l.arrow) != null && n.alignmentOffset ? {} : {
461
- x: s + c.x,
462
- y: i + c.y,
463
- data: {
464
- ...c,
465
- placement: r
466
- }
467
- };
468
- }
469
- };
470
- }, zt = function(e) {
471
- return e === void 0 && (e = {}), {
472
- name: "shift",
473
- options: e,
474
- async fn(o) {
475
- const {
476
- x: t,
477
- y: n,
478
- placement: s
479
- } = o, {
480
- mainAxis: i = !0,
481
- crossAxis: r = !1,
482
- limiter: l = {
483
- fn: (p) => {
484
- let {
485
- x: w,
486
- y: x
487
- } = p;
488
- return {
489
- x: w,
490
- y: x
491
- };
492
- }
493
- },
494
- ...c
495
- } = de(e, o), u = {
496
- x: t,
497
- y: n
498
- }, a = await Ye(o, c), d = $(U(s)), h = qe(d);
499
- let f = u[h], g = u[d];
500
- if (i) {
501
- const p = h === "y" ? "top" : "left", w = h === "y" ? "bottom" : "right", x = f + a[p], v = f - a[w];
502
- f = Me(x, f, v);
503
- }
504
- if (r) {
505
- const p = d === "y" ? "top" : "left", w = d === "y" ? "bottom" : "right", x = g + a[p], v = g - a[w];
506
- g = Me(x, g, v);
507
- }
508
- const m = l.fn({
509
- ...o,
510
- [h]: f,
511
- [d]: g
512
- });
513
- return {
514
- ...m,
515
- data: {
516
- x: m.x - t,
517
- y: m.y - n,
518
- enabled: {
519
- [h]: i,
520
- [d]: r
521
- }
522
- }
523
- };
524
- }
525
- };
526
- };
527
- function me() {
528
- return typeof window < "u";
529
- }
530
- function ee(e) {
531
- return Xe(e) ? (e.nodeName || "").toLowerCase() : "#document";
532
- }
533
- function z(e) {
534
- var o;
535
- return (e == null || (o = e.ownerDocument) == null ? void 0 : o.defaultView) || window;
536
- }
537
- function P(e) {
538
- var o;
539
- return (o = (Xe(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : o.documentElement;
540
- }
541
- function Xe(e) {
542
- return me() ? e instanceof Node || e instanceof z(e).Node : !1;
543
- }
544
- function L(e) {
545
- return me() ? e instanceof Element || e instanceof z(e).Element : !1;
546
- }
547
- function F(e) {
548
- return me() ? e instanceof HTMLElement || e instanceof z(e).HTMLElement : !1;
549
- }
550
- function Te(e) {
551
- return !me() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof z(e).ShadowRoot;
552
- }
553
- const Nt = /* @__PURE__ */ new Set(["inline", "contents"]);
554
- function oe(e) {
555
- const {
556
- overflow: o,
557
- overflowX: t,
558
- overflowY: n,
559
- display: s
560
- } = T(e);
561
- return /auto|scroll|overlay|hidden|clip/.test(o + n + t) && !Nt.has(s);
562
- }
563
- const Lt = /* @__PURE__ */ new Set(["table", "td", "th"]);
564
- function Tt(e) {
565
- return Lt.has(ee(e));
566
- }
567
- const _t = [":popover-open", ":modal"];
568
- function ge(e) {
569
- return _t.some((o) => {
570
- try {
571
- return e.matches(o);
572
- } catch {
573
- return !1;
574
- }
575
- });
576
- }
577
- const Dt = ["transform", "translate", "scale", "rotate", "perspective"], It = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Ft = ["paint", "layout", "strict", "content"];
578
- function Oe(e) {
579
- const o = Ee(), t = L(e) ? T(e) : e;
580
- return Dt.some((n) => t[n] ? t[n] !== "none" : !1) || (t.containerType ? t.containerType !== "normal" : !1) || !o && (t.backdropFilter ? t.backdropFilter !== "none" : !1) || !o && (t.filter ? t.filter !== "none" : !1) || It.some((n) => (t.willChange || "").includes(n)) || Ft.some((n) => (t.contain || "").includes(n));
581
- }
582
- function Pt(e) {
583
- let o = H(e);
584
- for (; F(o) && !Q(o); ) {
585
- if (Oe(o))
586
- return o;
587
- if (ge(o))
588
- return null;
589
- o = H(o);
590
- }
591
- return null;
592
- }
593
- function Ee() {
594
- return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
595
- }
596
- const Vt = /* @__PURE__ */ new Set(["html", "body", "#document"]);
597
- function Q(e) {
598
- return Vt.has(ee(e));
599
- }
600
- function T(e) {
601
- return z(e).getComputedStyle(e);
602
- }
603
- function pe(e) {
604
- return L(e) ? {
605
- scrollLeft: e.scrollLeft,
606
- scrollTop: e.scrollTop
607
- } : {
608
- scrollLeft: e.scrollX,
609
- scrollTop: e.scrollY
610
- };
611
- }
612
- function H(e) {
613
- if (ee(e) === "html")
614
- return e;
615
- const o = (
616
- // Step into the shadow DOM of the parent of a slotted node.
617
- e.assignedSlot || // DOM Element detected.
618
- e.parentNode || // ShadowRoot detected.
619
- Te(e) && e.host || // Fallback.
620
- P(e)
621
- );
622
- return Te(o) ? o.host : o;
623
- }
624
- function Ze(e) {
625
- const o = H(e);
626
- return Q(o) ? e.ownerDocument ? e.ownerDocument.body : e.body : F(o) && oe(o) ? o : Ze(o);
627
- }
628
- function ne(e, o, t) {
629
- var n;
630
- o === void 0 && (o = []), t === void 0 && (t = !0);
631
- const s = Ze(e), i = s === ((n = e.ownerDocument) == null ? void 0 : n.body), r = z(s);
632
- if (i) {
633
- const l = Ce(r);
634
- return o.concat(r, r.visualViewport || [], oe(s) ? s : [], l && t ? ne(l) : []);
635
- }
636
- return o.concat(s, ne(s, [], t));
637
- }
638
- function Ce(e) {
639
- return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
640
- }
641
- function Ge(e) {
642
- const o = T(e);
643
- let t = parseFloat(o.width) || 0, n = parseFloat(o.height) || 0;
644
- const s = F(e), i = s ? e.offsetWidth : t, r = s ? e.offsetHeight : n, l = le(t) !== i || le(n) !== r;
645
- return l && (t = i, n = r), {
646
- width: t,
647
- height: n,
648
- $: l
649
- };
650
- }
651
- function Re(e) {
652
- return L(e) ? e : e.contextElement;
653
- }
654
- function J(e) {
655
- const o = Re(e);
656
- if (!F(o))
657
- return I(1);
658
- const t = o.getBoundingClientRect(), {
659
- width: n,
660
- height: s,
661
- $: i
662
- } = Ge(o);
663
- let r = (i ? le(t.width) : t.width) / n, l = (i ? le(t.height) : t.height) / s;
664
- return (!r || !Number.isFinite(r)) && (r = 1), (!l || !Number.isFinite(l)) && (l = 1), {
665
- x: r,
666
- y: l
667
- };
668
- }
669
- const Wt = /* @__PURE__ */ I(0);
670
- function Je(e) {
671
- const o = z(e);
672
- return !Ee() || !o.visualViewport ? Wt : {
673
- x: o.visualViewport.offsetLeft,
674
- y: o.visualViewport.offsetTop
675
- };
676
- }
677
- function Bt(e, o, t) {
678
- return o === void 0 && (o = !1), !t || o && t !== z(e) ? !1 : o;
679
- }
680
- function K(e, o, t, n) {
681
- o === void 0 && (o = !1), t === void 0 && (t = !1);
682
- const s = e.getBoundingClientRect(), i = Re(e);
683
- let r = I(1);
684
- o && (n ? L(n) && (r = J(n)) : r = J(e));
685
- const l = Bt(i, t, n) ? Je(i) : I(0);
686
- let c = (s.left + l.x) / r.x, u = (s.top + l.y) / r.y, a = s.width / r.x, d = s.height / r.y;
687
- if (i) {
688
- const h = z(i), f = n && L(n) ? z(n) : n;
689
- let g = h, m = Ce(g);
690
- for (; m && n && f !== g; ) {
691
- const p = J(m), w = m.getBoundingClientRect(), x = T(m), v = w.left + (m.clientLeft + parseFloat(x.paddingLeft)) * p.x, S = w.top + (m.clientTop + parseFloat(x.paddingTop)) * p.y;
692
- c *= p.x, u *= p.y, a *= p.x, d *= p.y, c += v, u += S, g = z(m), m = Ce(g);
693
- }
694
- }
695
- return ae({
696
- width: a,
697
- height: d,
698
- x: c,
699
- y: u
700
- });
701
- }
702
- function ke(e, o) {
703
- const t = pe(e).scrollLeft;
704
- return o ? o.left + t : K(P(e)).left + t;
705
- }
706
- function Qe(e, o, t) {
707
- t === void 0 && (t = !1);
708
- const n = e.getBoundingClientRect(), s = n.left + o.scrollLeft - (t ? 0 : (
709
- // RTL <body> scrollbar.
710
- ke(e, n)
711
- )), i = n.top + o.scrollTop;
712
- return {
713
- x: s,
714
- y: i
715
- };
716
- }
717
- function jt(e) {
718
- let {
719
- elements: o,
720
- rect: t,
721
- offsetParent: n,
722
- strategy: s
723
- } = e;
724
- const i = s === "fixed", r = P(n), l = o ? ge(o.floating) : !1;
725
- if (n === r || l && i)
726
- return t;
727
- let c = {
728
- scrollLeft: 0,
729
- scrollTop: 0
730
- }, u = I(1);
731
- const a = I(0), d = F(n);
732
- if ((d || !d && !i) && ((ee(n) !== "body" || oe(r)) && (c = pe(n)), F(n))) {
733
- const f = K(n);
734
- u = J(n), a.x = f.x + n.clientLeft, a.y = f.y + n.clientTop;
735
- }
736
- const h = r && !d && !i ? Qe(r, c, !0) : I(0);
737
- return {
738
- width: t.width * u.x,
739
- height: t.height * u.y,
740
- x: t.x * u.x - c.scrollLeft * u.x + a.x + h.x,
741
- y: t.y * u.y - c.scrollTop * u.y + a.y + h.y
742
- };
743
- }
744
- function $t(e) {
745
- return Array.from(e.getClientRects());
746
- }
747
- function Ht(e) {
748
- const o = P(e), t = pe(e), n = e.ownerDocument.body, s = q(o.scrollWidth, o.clientWidth, n.scrollWidth, n.clientWidth), i = q(o.scrollHeight, o.clientHeight, n.scrollHeight, n.clientHeight);
749
- let r = -t.scrollLeft + ke(e);
750
- const l = -t.scrollTop;
751
- return T(n).direction === "rtl" && (r += q(o.clientWidth, n.clientWidth) - s), {
752
- width: s,
753
- height: i,
754
- x: r,
755
- y: l
756
- };
757
- }
758
- function qt(e, o) {
759
- const t = z(e), n = P(e), s = t.visualViewport;
760
- let i = n.clientWidth, r = n.clientHeight, l = 0, c = 0;
761
- if (s) {
762
- i = s.width, r = s.height;
763
- const u = Ee();
764
- (!u || u && o === "fixed") && (l = s.offsetLeft, c = s.offsetTop);
765
- }
766
- return {
767
- width: i,
768
- height: r,
769
- x: l,
770
- y: c
771
- };
772
- }
773
- const Ut = /* @__PURE__ */ new Set(["absolute", "fixed"]);
774
- function Kt(e, o) {
775
- const t = K(e, !0, o === "fixed"), n = t.top + e.clientTop, s = t.left + e.clientLeft, i = F(e) ? J(e) : I(1), r = e.clientWidth * i.x, l = e.clientHeight * i.y, c = s * i.x, u = n * i.y;
776
- return {
777
- width: r,
778
- height: l,
779
- x: c,
780
- y: u
781
- };
782
- }
783
- function _e(e, o, t) {
784
- let n;
785
- if (o === "viewport")
786
- n = qt(e, t);
787
- else if (o === "document")
788
- n = Ht(P(e));
789
- else if (L(o))
790
- n = Kt(o, t);
791
- else {
792
- const s = Je(e);
793
- n = {
794
- x: o.x - s.x,
795
- y: o.y - s.y,
796
- width: o.width,
797
- height: o.height
798
- };
799
- }
800
- return ae(n);
801
- }
802
- function et(e, o) {
803
- const t = H(e);
804
- return t === o || !L(t) || Q(t) ? !1 : T(t).position === "fixed" || et(t, o);
805
- }
806
- function Yt(e, o) {
807
- const t = o.get(e);
808
- if (t)
809
- return t;
810
- let n = ne(e, [], !1).filter((l) => L(l) && ee(l) !== "body"), s = null;
811
- const i = T(e).position === "fixed";
812
- let r = i ? H(e) : e;
813
- for (; L(r) && !Q(r); ) {
814
- const l = T(r), c = Oe(r);
815
- !c && l.position === "fixed" && (s = null), (i ? !c && !s : !c && l.position === "static" && !!s && Ut.has(s.position) || oe(r) && !c && et(e, r)) ? n = n.filter((a) => a !== r) : s = l, r = H(r);
816
- }
817
- return o.set(e, n), n;
818
- }
819
- function Xt(e) {
820
- let {
821
- element: o,
822
- boundary: t,
823
- rootBoundary: n,
824
- strategy: s
825
- } = e;
826
- const r = [...t === "clippingAncestors" ? ge(o) ? [] : Yt(o, this._c) : [].concat(t), n], l = r[0], c = r.reduce((u, a) => {
827
- const d = _e(o, a, s);
828
- return u.top = q(d.top, u.top), u.right = re(d.right, u.right), u.bottom = re(d.bottom, u.bottom), u.left = q(d.left, u.left), u;
829
- }, _e(o, l, s));
830
- return {
831
- width: c.right - c.left,
832
- height: c.bottom - c.top,
833
- x: c.left,
834
- y: c.top
835
- };
836
- }
837
- function Zt(e) {
838
- const {
839
- width: o,
840
- height: t
841
- } = Ge(e);
842
- return {
843
- width: o,
844
- height: t
845
- };
846
- }
847
- function Gt(e, o, t) {
848
- const n = F(o), s = P(o), i = t === "fixed", r = K(e, !0, i, o);
849
- let l = {
850
- scrollLeft: 0,
851
- scrollTop: 0
852
- };
853
- const c = I(0);
854
- function u() {
855
- c.x = ke(s);
856
- }
857
- if (n || !n && !i)
858
- if ((ee(o) !== "body" || oe(s)) && (l = pe(o)), n) {
859
- const f = K(o, !0, i, o);
860
- c.x = f.x + o.clientLeft, c.y = f.y + o.clientTop;
861
- } else s && u();
862
- i && !n && s && u();
863
- const a = s && !n && !i ? Qe(s, l) : I(0), d = r.left + l.scrollLeft - c.x - a.x, h = r.top + l.scrollTop - c.y - a.y;
864
- return {
865
- x: d,
866
- y: h,
867
- width: r.width,
868
- height: r.height
869
- };
870
- }
871
- function we(e) {
872
- return T(e).position === "static";
873
- }
874
- function De(e, o) {
875
- if (!F(e) || T(e).position === "fixed")
876
- return null;
877
- if (o)
878
- return o(e);
879
- let t = e.offsetParent;
880
- return P(e) === t && (t = t.ownerDocument.body), t;
881
- }
882
- function tt(e, o) {
883
- const t = z(e);
884
- if (ge(e))
885
- return t;
886
- if (!F(e)) {
887
- let s = H(e);
888
- for (; s && !Q(s); ) {
889
- if (L(s) && !we(s))
890
- return s;
891
- s = H(s);
892
- }
893
- return t;
894
- }
895
- let n = De(e, o);
896
- for (; n && Tt(n) && we(n); )
897
- n = De(n, o);
898
- return n && Q(n) && we(n) && !Oe(n) ? t : n || Pt(e) || t;
899
- }
900
- const Jt = async function(e) {
901
- const o = this.getOffsetParent || tt, t = this.getDimensions, n = await t(e.floating);
902
- return {
903
- reference: Gt(e.reference, await o(e.floating), e.strategy),
904
- floating: {
905
- x: 0,
906
- y: 0,
907
- width: n.width,
908
- height: n.height
909
- }
910
- };
911
- };
912
- function Qt(e) {
913
- return T(e).direction === "rtl";
914
- }
915
- const en = {
916
- convertOffsetParentRelativeRectToViewportRelativeRect: jt,
917
- getDocumentElement: P,
918
- getClippingRect: Xt,
919
- getOffsetParent: tt,
920
- getElementRects: Jt,
921
- getClientRects: $t,
922
- getDimensions: Zt,
923
- getScale: J,
924
- isElement: L,
925
- isRTL: Qt
926
- };
927
- function nt(e, o) {
928
- return e.x === o.x && e.y === o.y && e.width === o.width && e.height === o.height;
929
- }
930
- function tn(e, o) {
931
- let t = null, n;
932
- const s = P(e);
933
- function i() {
934
- var l;
935
- clearTimeout(n), (l = t) == null || l.disconnect(), t = null;
936
- }
937
- function r(l, c) {
938
- l === void 0 && (l = !1), c === void 0 && (c = 1), i();
939
- const u = e.getBoundingClientRect(), {
940
- left: a,
941
- top: d,
942
- width: h,
943
- height: f
944
- } = u;
945
- if (l || o(), !h || !f)
946
- return;
947
- const g = se(d), m = se(s.clientWidth - (a + h)), p = se(s.clientHeight - (d + f)), w = se(a), v = {
948
- rootMargin: -g + "px " + -m + "px " + -p + "px " + -w + "px",
949
- threshold: q(0, re(1, c)) || 1
950
- };
951
- let S = !0;
952
- function b(R) {
953
- const E = R[0].intersectionRatio;
954
- if (E !== c) {
955
- if (!S)
956
- return r();
957
- E ? r(!1, E) : n = setTimeout(() => {
958
- r(!1, 1e-7);
959
- }, 1e3);
960
- }
961
- E === 1 && !nt(u, e.getBoundingClientRect()) && r(), S = !1;
962
- }
963
- try {
964
- t = new IntersectionObserver(b, {
965
- ...v,
966
- // Handle <iframe>s
967
- root: s.ownerDocument
968
- });
969
- } catch {
970
- t = new IntersectionObserver(b, v);
971
- }
972
- t.observe(e);
973
- }
974
- return r(!0), i;
975
- }
976
- function nn(e, o, t, n) {
977
- n === void 0 && (n = {});
978
- const {
979
- ancestorScroll: s = !0,
980
- ancestorResize: i = !0,
981
- elementResize: r = typeof ResizeObserver == "function",
982
- layoutShift: l = typeof IntersectionObserver == "function",
983
- animationFrame: c = !1
984
- } = n, u = Re(e), a = s || i ? [...u ? ne(u) : [], ...ne(o)] : [];
985
- a.forEach((w) => {
986
- s && w.addEventListener("scroll", t, {
987
- passive: !0
988
- }), i && w.addEventListener("resize", t);
989
- });
990
- const d = u && l ? tn(u, t) : null;
991
- let h = -1, f = null;
992
- r && (f = new ResizeObserver((w) => {
993
- let [x] = w;
994
- x && x.target === u && f && (f.unobserve(o), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
995
- var v;
996
- (v = f) == null || v.observe(o);
997
- })), t();
998
- }), u && !c && f.observe(u), f.observe(o));
999
- let g, m = c ? K(e) : null;
1000
- c && p();
1001
- function p() {
1002
- const w = K(e);
1003
- m && !nt(m, w) && t(), m = w, g = requestAnimationFrame(p);
1004
- }
1005
- return t(), () => {
1006
- var w;
1007
- a.forEach((x) => {
1008
- s && x.removeEventListener("scroll", t), i && x.removeEventListener("resize", t);
1009
- }), d?.(), (w = f) == null || w.disconnect(), f = null, c && cancelAnimationFrame(g);
1010
- };
1011
- }
1012
- const on = Mt, sn = zt, rn = Rt, ln = (e, o, t) => {
1013
- const n = /* @__PURE__ */ new Map(), s = {
1014
- platform: en,
1015
- ...t
1016
- }, i = {
1017
- ...s.platform,
1018
- _c: n
1019
- };
1020
- return Et(e, o, {
1021
- ...s,
1022
- platform: i
1023
- });
1024
- };
1025
- var cn = typeof document < "u", an = function() {
1026
- }, ie = cn ? rt : an;
1027
- function ue(e, o) {
1028
- if (e === o)
1029
- return !0;
1030
- if (typeof e != typeof o)
1031
- return !1;
1032
- if (typeof e == "function" && e.toString() === o.toString())
1033
- return !0;
1034
- let t, n, s;
1035
- if (e && o && typeof e == "object") {
1036
- if (Array.isArray(e)) {
1037
- if (t = e.length, t !== o.length) return !1;
1038
- for (n = t; n-- !== 0; )
1039
- if (!ue(e[n], o[n]))
1040
- return !1;
1041
- return !0;
1042
- }
1043
- if (s = Object.keys(e), t = s.length, t !== Object.keys(o).length)
1044
- return !1;
1045
- for (n = t; n-- !== 0; )
1046
- if (!{}.hasOwnProperty.call(o, s[n]))
1047
- return !1;
1048
- for (n = t; n-- !== 0; ) {
1049
- const i = s[n];
1050
- if (!(i === "_owner" && e.$$typeof) && !ue(e[i], o[i]))
1051
- return !1;
1052
- }
1053
- return !0;
1054
- }
1055
- return e !== e && o !== o;
1056
- }
1057
- function ot(e) {
1058
- return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
1059
- }
1060
- function Ie(e, o) {
1061
- const t = ot(e);
1062
- return Math.round(o * t) / t;
1063
- }
1064
- function xe(e) {
1065
- const o = O.useRef(e);
1066
- return ie(() => {
1067
- o.current = e;
1068
- }), o;
1069
- }
1070
- function un(e) {
1071
- e === void 0 && (e = {});
1072
- const {
1073
- placement: o = "bottom",
1074
- strategy: t = "absolute",
1075
- middleware: n = [],
1076
- platform: s,
1077
- elements: {
1078
- reference: i,
1079
- floating: r
1080
- } = {},
1081
- transform: l = !0,
1082
- whileElementsMounted: c,
1083
- open: u
1084
- } = e, [a, d] = O.useState({
1085
- x: 0,
1086
- y: 0,
1087
- strategy: t,
1088
- placement: o,
1089
- middlewareData: {},
1090
- isPositioned: !1
1091
- }), [h, f] = O.useState(n);
1092
- ue(h, n) || f(n);
1093
- const [g, m] = O.useState(null), [p, w] = O.useState(null), x = O.useCallback((C) => {
1094
- C !== R.current && (R.current = C, m(C));
1095
- }, []), v = O.useCallback((C) => {
1096
- C !== E.current && (E.current = C, w(C));
1097
- }, []), S = i || g, b = r || p, R = O.useRef(null), E = O.useRef(null), W = O.useRef(a), Y = c != null, _ = xe(c), X = xe(s), te = xe(u), B = O.useCallback(() => {
1098
- if (!R.current || !E.current)
1099
- return;
1100
- const C = {
1101
- placement: o,
1102
- strategy: t,
1103
- middleware: h
1104
- };
1105
- X.current && (C.platform = X.current), ln(R.current, E.current, C).then((M) => {
1106
- const j = {
1107
- ...M,
1108
- // The floating element's position may be recomputed while it's closed
1109
- // but still mounted (such as when transitioning out). To ensure
1110
- // `isPositioned` will be `false` initially on the next open, avoid
1111
- // setting it to `true` when `open === false` (must be specified).
1112
- isPositioned: te.current !== !1
1113
- };
1114
- N.current && !ue(W.current, j) && (W.current = j, ct.flushSync(() => {
1115
- d(j);
1116
- }));
1117
- });
1118
- }, [h, o, t, X, te]);
1119
- ie(() => {
1120
- u === !1 && W.current.isPositioned && (W.current.isPositioned = !1, d((C) => ({
1121
- ...C,
1122
- isPositioned: !1
1123
- })));
1124
- }, [u]);
1125
- const N = O.useRef(!1);
1126
- ie(() => (N.current = !0, () => {
1127
- N.current = !1;
1128
- }), []), ie(() => {
1129
- if (S && (R.current = S), b && (E.current = b), S && b) {
1130
- if (_.current)
1131
- return _.current(S, b, B);
1132
- B();
1133
- }
1134
- }, [S, b, B, _, Y]);
1135
- const Z = O.useMemo(() => ({
1136
- reference: R,
1137
- floating: E,
1138
- setReference: x,
1139
- setFloating: v
1140
- }), [x, v]), A = O.useMemo(() => ({
1141
- reference: S,
1142
- floating: b
1143
- }), [S, b]), D = O.useMemo(() => {
1144
- const C = {
1145
- position: t,
1146
- left: 0,
1147
- top: 0
1148
- };
1149
- if (!A.floating)
1150
- return C;
1151
- const M = Ie(A.floating, a.x), j = Ie(A.floating, a.y);
1152
- return l ? {
1153
- ...C,
1154
- transform: "translate(" + M + "px, " + j + "px)",
1155
- ...ot(A.floating) >= 1.5 && {
1156
- willChange: "transform"
1157
- }
1158
- } : {
1159
- position: t,
1160
- left: M,
1161
- top: j
1162
- };
1163
- }, [t, l, A.floating, a.x, a.y]);
1164
- return O.useMemo(() => ({
1165
- ...a,
1166
- update: B,
1167
- refs: Z,
1168
- elements: A,
1169
- floatingStyles: D
1170
- }), [a, B, Z, A, D]);
1171
- }
1172
- const fn = (e, o) => ({
1173
- ...on(e),
1174
- options: [e, o]
1175
- }), dn = (e, o) => ({
1176
- ...sn(e),
1177
- options: [e, o]
1178
- }), hn = (e, o) => ({
1179
- ...rn(e),
1180
- options: [e, o]
26
+ //#endregion
27
+ //#region packages/badge/index.tsx
28
+ function p({ variant: e, className: t, ...n }) {
29
+ return /* @__PURE__ */ s("span", {
30
+ ...n,
31
+ className: m({
32
+ variant: e,
33
+ className: t
34
+ })
35
+ });
36
+ }
37
+ var m = f("zen__badge inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors whitespace-nowrap focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring", {
38
+ variants: { variant: {
39
+ default: "border-transparent bg-primary text-primary-foreground shadow-sm",
40
+ secondary: "border-transparent bg-secondary text-secondary-foreground shadow-sm",
41
+ destructive: "border-transparent bg-destructive text-destructive-foreground shadow-sm",
42
+ outline: "border-border text-foreground"
43
+ } },
44
+ defaultVariants: { variant: "default" }
1181
45
  });
1182
- function mn(e, o) {
1183
- return () => {
1184
- if (typeof document > "u")
1185
- return;
1186
- const t = (n) => {
1187
- !e.current || e.current.contains(n.target) || o(!0);
1188
- };
1189
- return document.addEventListener("mousedown", t), () => {
1190
- document.removeEventListener("mousedown", t);
1191
- };
1192
- };
1193
- }
1194
- function st(e) {
1195
- const {
1196
- className: o,
1197
- placement: t = "bottom-start",
1198
- trigger: n = "hover",
1199
- content: s,
1200
- children: i,
1201
- onClose: r,
1202
- onOpen: l,
1203
- disabled: c = !1,
1204
- show: u = !1,
1205
- setShow: a,
1206
- role: d = "tooltip",
1207
- style: h,
1208
- ...f
1209
- } = e, [g, m] = fe(u), p = () => a !== void 0 && u !== void 0 ? u : g, w = () => a !== void 0 && u !== void 0 ? a : m, { x, y: v, strategy: S, refs: b } = un({
1210
- open: p(),
1211
- middleware: [fn(4), hn(), dn()],
1212
- whileElementsMounted: nn,
1213
- placement: t
1214
- }), R = lt();
1215
- return be(
1216
- mn(b.floating, (E) => {
1217
- E && w()(!1);
1218
- }),
1219
- []
1220
- ), /* @__PURE__ */ V(je, { children: [
1221
- /* @__PURE__ */ y(
1222
- "div",
1223
- {
1224
- className: "z-auto min-w-fit max-w-fit",
1225
- id: `zen__popover-${R}`,
1226
- ref: b.setReference,
1227
- onClick: (E) => {
1228
- if (n === "click") {
1229
- if (c)
1230
- return;
1231
- p() ? (w()(!1), r?.()) : (w()(!0), l?.());
1232
- }
1233
- E.stopPropagation();
1234
- },
1235
- role: d,
1236
- children: i
1237
- }
1238
- ),
1239
- p() && at(
1240
- /* @__PURE__ */ y(
1241
- "div",
1242
- {
1243
- ...f,
1244
- onClick: (E) => E.stopPropagation(),
1245
- role: "tooltip",
1246
- className: k(
1247
- "zen__popover z-50 w-fit rounded border border-border bg-background shadow-secondary",
1248
- o
1249
- ),
1250
- ref: b.setFloating,
1251
- style: {
1252
- ...h,
1253
- position: S,
1254
- top: v ?? 0,
1255
- left: x ?? 0
1256
- },
1257
- children: s
1258
- }
1259
- ),
1260
- document.body
1261
- )
1262
- ] });
1263
- }
1264
- function gn(e) {
1265
- const {
1266
- items: o = [],
1267
- children: t,
1268
- moreItemsLabel: n = "",
1269
- parentRef: s,
1270
- data: i,
1271
- estimator: r = (m, p) => p + 30,
1272
- font: l = "12px Inter",
1273
- badgeVariant: c = "secondary",
1274
- badgeStyles: u
1275
- } = e, [a, d] = fe({
1276
- visible: o,
1277
- hidden: []
1278
- }), h = ye(() => {
1279
- if (typeof document > "u")
1280
- return null;
1281
- const p = document.createElement("canvas").getContext("2d");
1282
- return p && (p.font = l), p;
1283
- }, []), f = () => {
1284
- const m = s?.current;
1285
- if (!m)
1286
- return;
1287
- const p = m.offsetWidth, w = [], x = [], v = r(
1288
- n,
1289
- (h?.measureText(n).width ?? 0) + 10
1290
- );
1291
- g?.reduce((S, b, R) => (S + b + v > p - 20 ? x.push(o[R]) : w.push(o[R]), S + b), 0), d({
1292
- visible: w,
1293
- hidden: x
1294
- });
1295
- }, g = ye(
1296
- () => o?.map((m) => r(m, h?.measureText(m).width ?? 0)) ?? [],
1297
- [o]
1298
- );
1299
- return be(() => {
1300
- f();
1301
- }, [o]), be(() => {
1302
- if (!s?.current) return;
1303
- const m = new ResizeObserver(() => {
1304
- f();
1305
- });
1306
- return m.observe(s.current), () => {
1307
- m.disconnect();
1308
- };
1309
- }, [o]), /* @__PURE__ */ V(je, { children: [
1310
- a.visible?.map((m, p) => t(m, p, i?.[p])),
1311
- a.hidden?.length > 0 && /* @__PURE__ */ y(
1312
- st,
1313
- {
1314
- trigger: "click",
1315
- content: /* @__PURE__ */ y("div", { className: "grid max-h-60 grid-flow-row grid-cols-2 gap-3 overflow-auto p-2", children: a.hidden.map(
1316
- (m, p) => t(
1317
- m,
1318
- a.visible.length + p,
1319
- i?.[a.visible.length + p]
1320
- )
1321
- ) }),
1322
- children: /* @__PURE__ */ y(He, { className: u, variant: c, children: /* @__PURE__ */ y("p", { children: `+${a.hidden.length} ${n}` }) }, "more_items_button")
1323
- }
1324
- )
1325
- ] });
1326
- }
1327
- function G(e, o, t) {
1328
- let n = t.initialDeps ?? [], s;
1329
- function i() {
1330
- var r, l, c, u;
1331
- let a;
1332
- t.key && ((r = t.debug) != null && r.call(t)) && (a = Date.now());
1333
- const d = e();
1334
- if (!(d.length !== n.length || d.some((g, m) => n[m] !== g)))
1335
- return s;
1336
- n = d;
1337
- let f;
1338
- if (t.key && ((l = t.debug) != null && l.call(t)) && (f = Date.now()), s = o(...d), t.key && ((c = t.debug) != null && c.call(t))) {
1339
- const g = Math.round((Date.now() - a) * 100) / 100, m = Math.round((Date.now() - f) * 100) / 100, p = m / 16, w = (x, v) => {
1340
- for (x = String(x); x.length < v; )
1341
- x = " " + x;
1342
- return x;
1343
- };
1344
- console.info(
1345
- `%c⏱ ${w(m, 5)} /${w(g, 5)} ms`,
1346
- `
46
+ //#endregion
47
+ //#region packages/button/index.tsx
48
+ function h({ className: e, variant: t, size: n, ...r }) {
49
+ return /* @__PURE__ */ s("button", {
50
+ className: g({
51
+ variant: t,
52
+ size: n,
53
+ className: e
54
+ }),
55
+ ...r
56
+ });
57
+ }
58
+ var g = f("zen__button inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50", {
59
+ variants: {
60
+ variant: {
61
+ default: "bg-primary text-primary-foreground shadow-sm hover:bg-primary/70 active:bg-primary/90",
62
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/70 active:bg-destructive/90",
63
+ outline: "border border-input bg-background text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground active:bg-accent active:text-accent-foreground",
64
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/70 active:bg-secondary/90",
65
+ ghost: "text-foreground hover:bg-accent hover:text-accent-foreground active:bg-accent active:text-accent-foreground",
66
+ link: "text-primary underline-offset-4 hover:underline active:underline active:opacity-75",
67
+ icon: "text-foreground hover:bg-accent hover:text-accent-foreground active:bg-accent/80"
68
+ },
69
+ size: {
70
+ default: "h-9 px-4 py-2",
71
+ sm: "h-8 px-3 text-xs",
72
+ lg: "h-10 px-8",
73
+ icon: "p-0"
74
+ }
75
+ },
76
+ defaultVariants: {
77
+ variant: "default",
78
+ size: "default"
79
+ }
80
+ });
81
+ //#endregion
82
+ //#region packages/popover/index.tsx
83
+ function _(e) {
84
+ let { className: n, content: r, children: o, role: l = "tooltip", triggerType: d = "auto", trigger: f = "click", gap: p = "5px", show: m, setShow: h, style: g, ..._ } = e, v = i(null);
85
+ v.current === null && (v.current = crypto.randomUUID());
86
+ let y = v.current, [b, x] = a(!1), S = i(null);
87
+ return t(() => {
88
+ let t = S.current;
89
+ if (!t) return;
90
+ let n = () => {
91
+ x(!0), e.onOpen?.();
92
+ }, r = () => {
93
+ x(!1), e.onClose?.();
94
+ };
95
+ return t.addEventListener("popover:open", n), t.addEventListener("popover:close", r), () => {
96
+ t.removeEventListener("popover:open", n), t.removeEventListener("popover:close", r);
97
+ };
98
+ }, [e.onOpen, e.onClose]), t(() => {
99
+ d === "manual" && (m ? S.current?.showPopover?.() : S.current?.hidePopover?.());
100
+ }, [m, d]), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("div", {
101
+ "aria-expanded": b,
102
+ className: "max-w-fit min-w-fit",
103
+ style: { "anchor-name": `--zen-popover-anchor-${y}` },
104
+ popoverTarget: `zen__popover-${y}`,
105
+ popoverTargetAction: "toggle",
106
+ onClick: f === "click" ? (e) => {
107
+ switch (e.stopPropagation(), e.nativeEvent.stopImmediatePropagation(), d) {
108
+ case "auto":
109
+ S.current?.togglePopover?.();
110
+ break;
111
+ case "manual":
112
+ h?.(!m);
113
+ break;
114
+ }
115
+ } : void 0,
116
+ onMouseEnter: f === "hover" ? (e) => {
117
+ e.stopPropagation(), S.current?.showPopover?.();
118
+ } : void 0,
119
+ onMouseLeave: f === "hover" ? (e) => {
120
+ e.stopPropagation(), S.current?.hidePopover?.();
121
+ } : void 0,
122
+ children: o
123
+ }), /* @__PURE__ */ s("div", {
124
+ ..._,
125
+ ref: S,
126
+ role: l,
127
+ popover: d,
128
+ id: `zen__popover-${y}`,
129
+ className: u("zen__popover border-border bg-background fixed z-50 w-[anchor-size(width)] min-w-max [justify-self:anchor-center] rounded border shadow-md [position-area:block-end_center]", n),
130
+ style: {
131
+ ...g,
132
+ "--gap": p,
133
+ top: "calc(anchor(bottom) + var(--gap))",
134
+ "position-anchor": `--zen-popover-anchor-${y}`
135
+ },
136
+ children: r
137
+ })] });
138
+ }
139
+ //#endregion
140
+ //#region packages/collapse/index.tsx
141
+ function v(e) {
142
+ let { items: n = [], children: i, moreItemsLabel: l = "", parentRef: u, data: d, estimator: f = (e, t) => t + 30, font: m = "12px Inter", badgeVariant: h = "secondary", badgeStyles: g } = e, [v, y] = a({
143
+ visible: n,
144
+ hidden: []
145
+ }), b = r(() => {
146
+ if (typeof document > "u") return null;
147
+ let e = document.createElement("canvas").getContext("2d");
148
+ return e && (e.font = m), e;
149
+ }, []), x = () => {
150
+ let e = u?.current;
151
+ if (!e) return;
152
+ let t = e.offsetWidth, r = [], i = [], a = f(l, (b?.measureText(l).width ?? 0) + 10);
153
+ S?.reduce((e, o, s) => (e + o + a > t - 20 ? i.push(n[s]) : r.push(n[s]), e + o), 0), y({
154
+ visible: r,
155
+ hidden: i
156
+ });
157
+ }, S = r(() => n?.map((e) => f(e, b?.measureText(e).width ?? 0)) ?? [], [n]);
158
+ return t(() => {
159
+ x();
160
+ }, [n]), t(() => {
161
+ if (!u?.current) return;
162
+ let e = new ResizeObserver(() => {
163
+ x();
164
+ });
165
+ return e.observe(u.current), () => {
166
+ e.disconnect();
167
+ };
168
+ }, [n]), /* @__PURE__ */ c(o, { children: [v.visible?.map((e, t) => i(e, t, d?.[t])), v.hidden?.length > 0 && /* @__PURE__ */ s(_, {
169
+ trigger: "click",
170
+ content: /* @__PURE__ */ s("div", {
171
+ className: "grid max-h-60 grid-flow-row grid-cols-2 gap-3 overflow-auto p-2",
172
+ children: v.hidden.map((e, t) => i(e, v.visible.length + t, d?.[v.visible.length + t]))
173
+ }),
174
+ children: /* @__PURE__ */ s(p, {
175
+ className: g,
176
+ variant: h,
177
+ "aria-label": `Show ${v.hidden.length} more ${l}`,
178
+ children: /* @__PURE__ */ s("span", { children: `+${v.hidden.length} ${l}` })
179
+ }, "more_items_button")
180
+ })] });
181
+ }
182
+ //#endregion
183
+ //#region node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
184
+ function y(e, t, n) {
185
+ let r = n.initialDeps ?? [], i, a = !0;
186
+ function o() {
187
+ let o;
188
+ n.key && n.debug?.call(n) && (o = Date.now());
189
+ let s = e();
190
+ if (!(s.length !== r.length || s.some((e, t) => r[t] !== e))) return i;
191
+ r = s;
192
+ let c;
193
+ if (n.key && n.debug?.call(n) && (c = Date.now()), i = t(...s), n.key && n.debug?.call(n)) {
194
+ let e = Math.round((Date.now() - o) * 100) / 100, t = Math.round((Date.now() - c) * 100) / 100, r = t / 16, i = (e, t) => {
195
+ for (e = String(e); e.length < t;) e = " " + e;
196
+ return e;
197
+ };
198
+ console.info(`%c⏱ ${i(t, 5)} /${i(e, 5)} ms`, `
1347
199
  font-size: .6rem;
1348
200
  font-weight: bold;
1349
- color: hsl(${Math.max(
1350
- 0,
1351
- Math.min(120 - 120 * p, 120)
1352
- )}deg 100% 31%);`,
1353
- t?.key
1354
- );
1355
- }
1356
- return (u = t?.onChange) == null || u.call(t, s), s;
1357
- }
1358
- return i.updateDeps = (r) => {
1359
- n = r;
1360
- }, i;
1361
- }
1362
- function Fe(e, o) {
1363
- if (e === void 0)
1364
- throw new Error("Unexpected undefined");
1365
- return e;
1366
- }
1367
- const pn = (e, o) => Math.abs(e - o) < 1.01, wn = (e, o, t) => {
1368
- let n;
1369
- return function(...s) {
1370
- e.clearTimeout(n), n = e.setTimeout(() => o.apply(this, s), t);
1371
- };
1372
- }, Pe = (e) => {
1373
- const { offsetWidth: o, offsetHeight: t } = e;
1374
- return { width: o, height: t };
1375
- }, xn = (e) => e, bn = (e) => {
1376
- const o = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
1377
- for (let s = o; s <= t; s++)
1378
- n.push(s);
1379
- return n;
1380
- }, yn = (e, o) => {
1381
- const t = e.scrollElement;
1382
- if (!t)
1383
- return;
1384
- const n = e.targetWindow;
1385
- if (!n)
1386
- return;
1387
- const s = (r) => {
1388
- const { width: l, height: c } = r;
1389
- o({ width: Math.round(l), height: Math.round(c) });
1390
- };
1391
- if (s(Pe(t)), !n.ResizeObserver)
1392
- return () => {
1393
- };
1394
- const i = new n.ResizeObserver((r) => {
1395
- const l = () => {
1396
- const c = r[0];
1397
- if (c?.borderBoxSize) {
1398
- const u = c.borderBoxSize[0];
1399
- if (u) {
1400
- s({ width: u.inlineSize, height: u.blockSize });
1401
- return;
1402
- }
1403
- }
1404
- s(Pe(t));
1405
- };
1406
- e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
1407
- });
1408
- return i.observe(t, { box: "border-box" }), () => {
1409
- i.unobserve(t);
1410
- };
1411
- }, Ve = {
1412
- passive: !0
1413
- }, We = typeof window > "u" ? !0 : "onscrollend" in window, vn = (e, o) => {
1414
- const t = e.scrollElement;
1415
- if (!t)
1416
- return;
1417
- const n = e.targetWindow;
1418
- if (!n)
1419
- return;
1420
- let s = 0;
1421
- const i = e.options.useScrollendEvent && We ? () => {
1422
- } : wn(
1423
- n,
1424
- () => {
1425
- o(s, !1);
1426
- },
1427
- e.options.isScrollingResetDelay
1428
- ), r = (a) => () => {
1429
- const { horizontal: d, isRtl: h } = e.options;
1430
- s = d ? t.scrollLeft * (h && -1 || 1) : t.scrollTop, i(), o(s, a);
1431
- }, l = r(!0), c = r(!1);
1432
- c(), t.addEventListener("scroll", l, Ve);
1433
- const u = e.options.useScrollendEvent && We;
1434
- return u && t.addEventListener("scrollend", c, Ve), () => {
1435
- t.removeEventListener("scroll", l), u && t.removeEventListener("scrollend", c);
1436
- };
1437
- }, Sn = (e, o, t) => {
1438
- if (o?.borderBoxSize) {
1439
- const n = o.borderBoxSize[0];
1440
- if (n)
1441
- return Math.round(
1442
- n[t.options.horizontal ? "inlineSize" : "blockSize"]
1443
- );
1444
- }
1445
- return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
1446
- }, Cn = (e, {
1447
- adjustments: o = 0,
1448
- behavior: t
1449
- }, n) => {
1450
- var s, i;
1451
- const r = e + o;
1452
- (i = (s = n.scrollElement) == null ? void 0 : s.scrollTo) == null || i.call(s, {
1453
- [n.options.horizontal ? "left" : "top"]: r,
1454
- behavior: t
1455
- });
1456
- };
1457
- class On {
1458
- constructor(o) {
1459
- this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
1460
- let t = null;
1461
- const n = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((s) => {
1462
- s.forEach((i) => {
1463
- const r = () => {
1464
- this._measureElement(i.target, i);
1465
- };
1466
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
1467
- });
1468
- }));
1469
- return {
1470
- disconnect: () => {
1471
- var s;
1472
- (s = n()) == null || s.disconnect(), t = null;
1473
- },
1474
- observe: (s) => {
1475
- var i;
1476
- return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
1477
- },
1478
- unobserve: (s) => {
1479
- var i;
1480
- return (i = n()) == null ? void 0 : i.unobserve(s);
1481
- }
1482
- };
1483
- })(), this.range = null, this.setOptions = (t) => {
1484
- Object.entries(t).forEach(([n, s]) => {
1485
- typeof s > "u" && delete t[n];
1486
- }), this.options = {
1487
- debug: !1,
1488
- initialOffset: 0,
1489
- overscan: 1,
1490
- paddingStart: 0,
1491
- paddingEnd: 0,
1492
- scrollPaddingStart: 0,
1493
- scrollPaddingEnd: 0,
1494
- horizontal: !1,
1495
- getItemKey: xn,
1496
- rangeExtractor: bn,
1497
- onChange: () => {
1498
- },
1499
- measureElement: Sn,
1500
- initialRect: { width: 0, height: 0 },
1501
- scrollMargin: 0,
1502
- gap: 0,
1503
- indexAttribute: "data-index",
1504
- initialMeasurementsCache: [],
1505
- lanes: 1,
1506
- isScrollingResetDelay: 150,
1507
- enabled: !0,
1508
- isRtl: !1,
1509
- useScrollendEvent: !1,
1510
- useAnimationFrameWithResizeObserver: !1,
1511
- ...t
1512
- };
1513
- }, this.notify = (t) => {
1514
- var n, s;
1515
- (s = (n = this.options).onChange) == null || s.call(n, this, t);
1516
- }, this.maybeNotify = G(
1517
- () => (this.calculateRange(), [
1518
- this.isScrolling,
1519
- this.range ? this.range.startIndex : null,
1520
- this.range ? this.range.endIndex : null
1521
- ]),
1522
- (t) => {
1523
- this.notify(t);
1524
- },
1525
- {
1526
- key: process.env.NODE_ENV !== "production" && "maybeNotify",
1527
- debug: () => this.options.debug,
1528
- initialDeps: [
1529
- this.isScrolling,
1530
- this.range ? this.range.startIndex : null,
1531
- this.range ? this.range.endIndex : null
1532
- ]
1533
- }
1534
- ), this.cleanup = () => {
1535
- this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
1536
- }, this._didMount = () => () => {
1537
- this.cleanup();
1538
- }, this._willUpdate = () => {
1539
- var t;
1540
- const n = this.options.enabled ? this.options.getScrollElement() : null;
1541
- if (this.scrollElement !== n) {
1542
- if (this.cleanup(), !n) {
1543
- this.maybeNotify();
1544
- return;
1545
- }
1546
- this.scrollElement = n, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this.elementsCache.forEach((s) => {
1547
- this.observer.observe(s);
1548
- }), this._scrollToOffset(this.getScrollOffset(), {
1549
- adjustments: void 0,
1550
- behavior: void 0
1551
- }), this.unsubs.push(
1552
- this.options.observeElementRect(this, (s) => {
1553
- this.scrollRect = s, this.maybeNotify();
1554
- })
1555
- ), this.unsubs.push(
1556
- this.options.observeElementOffset(this, (s, i) => {
1557
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < s ? "forward" : "backward" : null, this.scrollOffset = s, this.isScrolling = i, this.maybeNotify();
1558
- })
1559
- );
1560
- }
1561
- }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (t, n) => {
1562
- const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1563
- for (let r = n - 1; r >= 0; r--) {
1564
- const l = t[r];
1565
- if (s.has(l.lane))
1566
- continue;
1567
- const c = i.get(
1568
- l.lane
1569
- );
1570
- if (c == null || l.end > c.end ? i.set(l.lane, l) : l.end < c.end && s.set(l.lane, !0), s.size === this.options.lanes)
1571
- break;
1572
- }
1573
- return i.size === this.options.lanes ? Array.from(i.values()).sort((r, l) => r.end === l.end ? r.index - l.index : r.end - l.end)[0] : void 0;
1574
- }, this.getMeasurementOptions = G(
1575
- () => [
1576
- this.options.count,
1577
- this.options.paddingStart,
1578
- this.options.scrollMargin,
1579
- this.options.getItemKey,
1580
- this.options.enabled
1581
- ],
1582
- (t, n, s, i, r) => (this.pendingMeasuredCacheIndexes = [], {
1583
- count: t,
1584
- paddingStart: n,
1585
- scrollMargin: s,
1586
- getItemKey: i,
1587
- enabled: r
1588
- }),
1589
- {
1590
- key: !1
1591
- }
1592
- ), this.getMeasurements = G(
1593
- () => [this.getMeasurementOptions(), this.itemSizeCache],
1594
- ({ count: t, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: r }, l) => {
1595
- if (!r)
1596
- return this.measurementsCache = [], this.itemSizeCache.clear(), [];
1597
- this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((a) => {
1598
- this.itemSizeCache.set(a.key, a.size);
1599
- }));
1600
- const c = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
1601
- this.pendingMeasuredCacheIndexes = [];
1602
- const u = this.measurementsCache.slice(0, c);
1603
- for (let a = c; a < t; a++) {
1604
- const d = i(a), h = this.options.lanes === 1 ? u[a - 1] : this.getFurthestMeasurement(u, a), f = h ? h.end + this.options.gap : n + s, g = l.get(d), m = typeof g == "number" ? g : this.options.estimateSize(a), p = f + m, w = h ? h.lane : a % this.options.lanes;
1605
- u[a] = {
1606
- index: a,
1607
- start: f,
1608
- size: m,
1609
- end: p,
1610
- key: d,
1611
- lane: w
1612
- };
1613
- }
1614
- return this.measurementsCache = u, u;
1615
- },
1616
- {
1617
- key: process.env.NODE_ENV !== "production" && "getMeasurements",
1618
- debug: () => this.options.debug
1619
- }
1620
- ), this.calculateRange = G(
1621
- () => [
1622
- this.getMeasurements(),
1623
- this.getSize(),
1624
- this.getScrollOffset(),
1625
- this.options.lanes
1626
- ],
1627
- (t, n, s, i) => this.range = t.length > 0 && n > 0 ? En({
1628
- measurements: t,
1629
- outerSize: n,
1630
- scrollOffset: s,
1631
- lanes: i
1632
- }) : null,
1633
- {
1634
- key: process.env.NODE_ENV !== "production" && "calculateRange",
1635
- debug: () => this.options.debug
1636
- }
1637
- ), this.getVirtualIndexes = G(
1638
- () => {
1639
- let t = null, n = null;
1640
- const s = this.calculateRange();
1641
- return s && (t = s.startIndex, n = s.endIndex), this.maybeNotify.updateDeps([this.isScrolling, t, n]), [
1642
- this.options.rangeExtractor,
1643
- this.options.overscan,
1644
- this.options.count,
1645
- t,
1646
- n
1647
- ];
1648
- },
1649
- (t, n, s, i, r) => i === null || r === null ? [] : t({
1650
- startIndex: i,
1651
- endIndex: r,
1652
- overscan: n,
1653
- count: s
1654
- }),
1655
- {
1656
- key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
1657
- debug: () => this.options.debug
1658
- }
1659
- ), this.indexFromElement = (t) => {
1660
- const n = this.options.indexAttribute, s = t.getAttribute(n);
1661
- return s ? parseInt(s, 10) : (console.warn(
1662
- `Missing attribute name '${n}={index}' on measured element.`
1663
- ), -1);
1664
- }, this._measureElement = (t, n) => {
1665
- const s = this.indexFromElement(t), i = this.measurementsCache[s];
1666
- if (!i)
1667
- return;
1668
- const r = i.key, l = this.elementsCache.get(r);
1669
- l !== t && (l && this.observer.unobserve(l), this.observer.observe(t), this.elementsCache.set(r, t)), t.isConnected && this.resizeItem(s, this.options.measureElement(t, n, this));
1670
- }, this.resizeItem = (t, n) => {
1671
- const s = this.measurementsCache[t];
1672
- if (!s)
1673
- return;
1674
- const i = this.itemSizeCache.get(s.key) ?? s.size, r = n - i;
1675
- r !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(s, r, this) : s.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", r), this._scrollToOffset(this.getScrollOffset(), {
1676
- adjustments: this.scrollAdjustments += r,
1677
- behavior: void 0
1678
- })), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
1679
- }, this.measureElement = (t) => {
1680
- if (!t) {
1681
- this.elementsCache.forEach((n, s) => {
1682
- n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
1683
- });
1684
- return;
1685
- }
1686
- this._measureElement(t, void 0);
1687
- }, this.getVirtualItems = G(
1688
- () => [this.getVirtualIndexes(), this.getMeasurements()],
1689
- (t, n) => {
1690
- const s = [];
1691
- for (let i = 0, r = t.length; i < r; i++) {
1692
- const l = t[i], c = n[l];
1693
- s.push(c);
1694
- }
1695
- return s;
1696
- },
1697
- {
1698
- key: process.env.NODE_ENV !== "production" && "getVirtualItems",
1699
- debug: () => this.options.debug
1700
- }
1701
- ), this.getVirtualItemForOffset = (t) => {
1702
- const n = this.getMeasurements();
1703
- if (n.length !== 0)
1704
- return Fe(
1705
- n[it(
1706
- 0,
1707
- n.length - 1,
1708
- (s) => Fe(n[s]).start,
1709
- t
1710
- )]
1711
- );
1712
- }, this.getOffsetForAlignment = (t, n, s = 0) => {
1713
- const i = this.getSize(), r = this.getScrollOffset();
1714
- n === "auto" && (n = t >= r + i ? "end" : "start"), n === "center" ? t += (s - i) / 2 : n === "end" && (t -= i);
1715
- const l = this.getTotalSize() + this.options.scrollMargin - i;
1716
- return Math.max(Math.min(l, t), 0);
1717
- }, this.getOffsetForIndex = (t, n = "auto") => {
1718
- t = Math.max(0, Math.min(t, this.options.count - 1));
1719
- const s = this.measurementsCache[t];
1720
- if (!s)
1721
- return;
1722
- const i = this.getSize(), r = this.getScrollOffset();
1723
- if (n === "auto")
1724
- if (s.end >= r + i - this.options.scrollPaddingEnd)
1725
- n = "end";
1726
- else if (s.start <= r + this.options.scrollPaddingStart)
1727
- n = "start";
1728
- else
1729
- return [r, n];
1730
- const l = n === "end" ? s.end + this.options.scrollPaddingEnd : s.start - this.options.scrollPaddingStart;
1731
- return [
1732
- this.getOffsetForAlignment(l, n, s.size),
1733
- n
1734
- ];
1735
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (t, { align: n = "start", behavior: s } = {}) => {
1736
- s === "smooth" && this.isDynamicMode() && console.warn(
1737
- "The `smooth` scroll behavior is not fully supported with dynamic size."
1738
- ), this._scrollToOffset(this.getOffsetForAlignment(t, n), {
1739
- adjustments: void 0,
1740
- behavior: s
1741
- });
1742
- }, this.scrollToIndex = (t, { align: n = "auto", behavior: s } = {}) => {
1743
- s === "smooth" && this.isDynamicMode() && console.warn(
1744
- "The `smooth` scroll behavior is not fully supported with dynamic size."
1745
- ), t = Math.max(0, Math.min(t, this.options.count - 1));
1746
- let i = 0;
1747
- const r = 10, l = (u) => {
1748
- if (!this.targetWindow) return;
1749
- const a = this.getOffsetForIndex(t, u);
1750
- if (!a) {
1751
- console.warn("Failed to get offset for index:", t);
1752
- return;
1753
- }
1754
- const [d, h] = a;
1755
- this._scrollToOffset(d, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
1756
- const f = this.getScrollOffset(), g = this.getOffsetForIndex(t, h);
1757
- if (!g) {
1758
- console.warn("Failed to get offset for index:", t);
1759
- return;
1760
- }
1761
- pn(g[0], f) || c(h);
1762
- });
1763
- }, c = (u) => {
1764
- this.targetWindow && (i++, i < r ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, r), this.targetWindow.requestAnimationFrame(() => l(u))) : console.warn(
1765
- `Failed to scroll to index ${t} after ${r} attempts.`
1766
- ));
1767
- };
1768
- l(n);
1769
- }, this.scrollBy = (t, { behavior: n } = {}) => {
1770
- n === "smooth" && this.isDynamicMode() && console.warn(
1771
- "The `smooth` scroll behavior is not fully supported with dynamic size."
1772
- ), this._scrollToOffset(this.getScrollOffset() + t, {
1773
- adjustments: void 0,
1774
- behavior: n
1775
- });
1776
- }, this.getTotalSize = () => {
1777
- var t;
1778
- const n = this.getMeasurements();
1779
- let s;
1780
- if (n.length === 0)
1781
- s = this.options.paddingStart;
1782
- else if (this.options.lanes === 1)
1783
- s = ((t = n[n.length - 1]) == null ? void 0 : t.end) ?? 0;
1784
- else {
1785
- const i = Array(this.options.lanes).fill(null);
1786
- let r = n.length - 1;
1787
- for (; r >= 0 && i.some((l) => l === null); ) {
1788
- const l = n[r];
1789
- i[l.lane] === null && (i[l.lane] = l.end), r--;
1790
- }
1791
- s = Math.max(...i.filter((l) => l !== null));
1792
- }
1793
- return Math.max(
1794
- s - this.options.scrollMargin + this.options.paddingEnd,
1795
- 0
1796
- );
1797
- }, this._scrollToOffset = (t, {
1798
- adjustments: n,
1799
- behavior: s
1800
- }) => {
1801
- this.options.scrollToFn(t, { behavior: s, adjustments: n }, this);
1802
- }, this.measure = () => {
1803
- this.itemSizeCache = /* @__PURE__ */ new Map(), this.notify(!1);
1804
- }, this.setOptions(o);
1805
- }
1806
- }
1807
- const it = (e, o, t, n) => {
1808
- for (; e <= o; ) {
1809
- const s = (e + o) / 2 | 0, i = t(s);
1810
- if (i < n)
1811
- e = s + 1;
1812
- else if (i > n)
1813
- o = s - 1;
1814
- else
1815
- return s;
1816
- }
1817
- return e > 0 ? e - 1 : 0;
201
+ color: hsl(${Math.max(0, Math.min(120 - 120 * r, 120))}deg 100% 31%);`, n?.key);
202
+ }
203
+ return n?.onChange && !(a && n.skipInitialOnChange) && n.onChange(i), a = !1, i;
204
+ }
205
+ return o.updateDeps = (e) => {
206
+ r = e;
207
+ }, o;
208
+ }
209
+ function b(e, t) {
210
+ if (e === void 0) throw Error(`Unexpected undefined${t ? `: ${t}` : ""}`);
211
+ return e;
212
+ }
213
+ var x = (e, t) => Math.abs(e - t) < 1.01, S = (e, t, n) => {
214
+ let r;
215
+ return function(...i) {
216
+ e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, i), n);
217
+ };
218
+ }, C = (e) => {
219
+ let { offsetWidth: t, offsetHeight: n } = e;
220
+ return {
221
+ width: t,
222
+ height: n
223
+ };
224
+ }, w = (e) => e, T = (e) => {
225
+ let t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
226
+ for (let e = t; e <= n; e++) r.push(e);
227
+ return r;
228
+ }, E = (e, t) => {
229
+ let n = e.scrollElement;
230
+ if (!n) return;
231
+ let r = e.targetWindow;
232
+ if (!r) return;
233
+ let i = (e) => {
234
+ let { width: n, height: r } = e;
235
+ t({
236
+ width: Math.round(n),
237
+ height: Math.round(r)
238
+ });
239
+ };
240
+ if (i(C(n)), !r.ResizeObserver) return () => {};
241
+ let a = new r.ResizeObserver((t) => {
242
+ let r = () => {
243
+ let e = t[0];
244
+ if (e?.borderBoxSize) {
245
+ let t = e.borderBoxSize[0];
246
+ if (t) {
247
+ i({
248
+ width: t.inlineSize,
249
+ height: t.blockSize
250
+ });
251
+ return;
252
+ }
253
+ }
254
+ i(C(n));
255
+ };
256
+ e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
257
+ });
258
+ return a.observe(n, { box: "border-box" }), () => {
259
+ a.unobserve(n);
260
+ };
261
+ }, D = { passive: !0 }, O = typeof window > "u" ? !0 : "onscrollend" in window, k = (e, t) => {
262
+ let n = e.scrollElement;
263
+ if (!n) return;
264
+ let r = e.targetWindow;
265
+ if (!r) return;
266
+ let i = 0, a = e.options.useScrollendEvent && O ? () => void 0 : S(r, () => {
267
+ t(i, !1);
268
+ }, e.options.isScrollingResetDelay), o = (r) => () => {
269
+ let { horizontal: o, isRtl: s } = e.options;
270
+ i = o ? n.scrollLeft * (s && -1 || 1) : n.scrollTop, a(), t(i, r);
271
+ }, s = o(!0), c = o(!1);
272
+ n.addEventListener("scroll", s, D);
273
+ let l = e.options.useScrollendEvent && O;
274
+ return l && n.addEventListener("scrollend", c, D), () => {
275
+ n.removeEventListener("scroll", s), l && n.removeEventListener("scrollend", c);
276
+ };
277
+ }, A = (e, t, n) => {
278
+ if (t?.borderBoxSize) {
279
+ let e = t.borderBoxSize[0];
280
+ if (e) return Math.round(e[n.options.horizontal ? "inlineSize" : "blockSize"]);
281
+ }
282
+ return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
283
+ }, j = (e, { adjustments: t = 0, behavior: n }, r) => {
284
+ var i, a;
285
+ let o = e + t;
286
+ (a = (i = r.scrollElement)?.scrollTo) == null || a.call(i, {
287
+ [r.options.horizontal ? "left" : "top"]: o,
288
+ behavior: n
289
+ });
290
+ }, M = class {
291
+ constructor(e) {
292
+ this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollState = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.now = () => {
293
+ var e;
294
+ return ((e = this.targetWindow?.performance)?.now)?.call(e) ?? Date.now();
295
+ }, this.observer = /* @__PURE__ */ (() => {
296
+ let e = null, t = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((e) => {
297
+ e.forEach((e) => {
298
+ let t = () => {
299
+ let t = e.target, n = this.indexFromElement(t);
300
+ if (!t.isConnected) {
301
+ this.observer.unobserve(t);
302
+ return;
303
+ }
304
+ this.shouldMeasureDuringScroll(n) && this.resizeItem(n, this.options.measureElement(t, e, this));
305
+ };
306
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(t) : t();
307
+ });
308
+ }));
309
+ return {
310
+ disconnect: () => {
311
+ var n;
312
+ (n = t()) == null || n.disconnect(), e = null;
313
+ },
314
+ observe: (e) => t()?.observe(e, { box: "border-box" }),
315
+ unobserve: (e) => t()?.unobserve(e)
316
+ };
317
+ })(), this.range = null, this.setOptions = (e) => {
318
+ Object.entries(e).forEach(([t, n]) => {
319
+ n === void 0 && delete e[t];
320
+ }), this.options = {
321
+ debug: !1,
322
+ initialOffset: 0,
323
+ overscan: 1,
324
+ paddingStart: 0,
325
+ paddingEnd: 0,
326
+ scrollPaddingStart: 0,
327
+ scrollPaddingEnd: 0,
328
+ horizontal: !1,
329
+ getItemKey: w,
330
+ rangeExtractor: T,
331
+ onChange: () => {},
332
+ measureElement: A,
333
+ initialRect: {
334
+ width: 0,
335
+ height: 0
336
+ },
337
+ scrollMargin: 0,
338
+ gap: 0,
339
+ indexAttribute: "data-index",
340
+ initialMeasurementsCache: [],
341
+ lanes: 1,
342
+ isScrollingResetDelay: 150,
343
+ enabled: !0,
344
+ isRtl: !1,
345
+ useScrollendEvent: !1,
346
+ useAnimationFrameWithResizeObserver: !1,
347
+ laneAssignmentMode: "estimate",
348
+ ...e
349
+ };
350
+ }, this.notify = (e) => {
351
+ var t, n;
352
+ (n = (t = this.options).onChange) == null || n.call(t, this, e);
353
+ }, this.maybeNotify = y(() => (this.calculateRange(), [
354
+ this.isScrolling,
355
+ this.range ? this.range.startIndex : null,
356
+ this.range ? this.range.endIndex : null
357
+ ]), (e) => {
358
+ this.notify(e);
359
+ }, {
360
+ key: process.env.NODE_ENV !== "production" && "maybeNotify",
361
+ debug: () => this.options.debug,
362
+ initialDeps: [
363
+ this.isScrolling,
364
+ this.range ? this.range.startIndex : null,
365
+ this.range ? this.range.endIndex : null
366
+ ]
367
+ }), this.cleanup = () => {
368
+ this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.rafId != null && this.targetWindow && (this.targetWindow.cancelAnimationFrame(this.rafId), this.rafId = null), this.scrollState = null, this.scrollElement = null, this.targetWindow = null;
369
+ }, this._didMount = () => () => {
370
+ this.cleanup();
371
+ }, this._willUpdate = () => {
372
+ let e = this.options.enabled ? this.options.getScrollElement() : null;
373
+ if (this.scrollElement !== e) {
374
+ if (this.cleanup(), !e) {
375
+ this.maybeNotify();
376
+ return;
377
+ }
378
+ this.scrollElement = e, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = this.scrollElement?.window ?? null, this.elementsCache.forEach((e) => {
379
+ this.observer.observe(e);
380
+ }), this.unsubs.push(this.options.observeElementRect(this, (e) => {
381
+ this.scrollRect = e, this.maybeNotify();
382
+ })), this.unsubs.push(this.options.observeElementOffset(this, (e, t) => {
383
+ this.scrollAdjustments = 0, this.scrollDirection = t ? this.getScrollOffset() < e ? "forward" : "backward" : null, this.scrollOffset = e, this.isScrolling = t, this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
384
+ })), this._scrollToOffset(this.getScrollOffset(), {
385
+ adjustments: void 0,
386
+ behavior: void 0
387
+ });
388
+ }
389
+ }, this.rafId = null, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (e, t) => {
390
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
391
+ for (let i = t - 1; i >= 0; i--) {
392
+ let t = e[i];
393
+ if (n.has(t.lane)) continue;
394
+ let a = r.get(t.lane);
395
+ if (a == null || t.end > a.end ? r.set(t.lane, t) : t.end < a.end && n.set(t.lane, !0), n.size === this.options.lanes) break;
396
+ }
397
+ return r.size === this.options.lanes ? Array.from(r.values()).sort((e, t) => e.end === t.end ? e.index - t.index : e.end - t.end)[0] : void 0;
398
+ }, this.getMeasurementOptions = y(() => [
399
+ this.options.count,
400
+ this.options.paddingStart,
401
+ this.options.scrollMargin,
402
+ this.options.getItemKey,
403
+ this.options.enabled,
404
+ this.options.lanes,
405
+ this.options.laneAssignmentMode
406
+ ], (e, t, n, r, i, a, o) => (this.prevLanes !== void 0 && this.prevLanes !== a && (this.lanesChangedFlag = !0), this.prevLanes = a, this.pendingMeasuredCacheIndexes = [], {
407
+ count: e,
408
+ paddingStart: t,
409
+ scrollMargin: n,
410
+ getItemKey: r,
411
+ enabled: i,
412
+ lanes: a,
413
+ laneAssignmentMode: o
414
+ }), { key: !1 }), this.getMeasurements = y(() => [this.getMeasurementOptions(), this.itemSizeCache], ({ count: e, paddingStart: t, scrollMargin: n, getItemKey: r, enabled: i, lanes: a, laneAssignmentMode: o }, s) => {
415
+ if (!i) return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
416
+ if (this.laneAssignments.size > e) for (let t of this.laneAssignments.keys()) t >= e && this.laneAssignments.delete(t);
417
+ this.lanesChangedFlag && (this.lanesChangedFlag = !1, this.lanesSettling = !0, this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), this.pendingMeasuredCacheIndexes = []), this.measurementsCache.length === 0 && !this.lanesSettling && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((e) => {
418
+ this.itemSizeCache.set(e.key, e.size);
419
+ }));
420
+ let c = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
421
+ this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
422
+ let l = this.measurementsCache.slice(0, c), u = Array(a).fill(void 0);
423
+ for (let e = 0; e < c; e++) {
424
+ let t = l[e];
425
+ t && (u[t.lane] = e);
426
+ }
427
+ for (let i = c; i < e; i++) {
428
+ let e = r(i), a = this.laneAssignments.get(i), c, d, f = o === "estimate" || s.has(e);
429
+ if (a !== void 0 && this.options.lanes > 1) {
430
+ c = a;
431
+ let e = u[c], r = e === void 0 ? void 0 : l[e];
432
+ d = r ? r.end + this.options.gap : t + n;
433
+ } else {
434
+ let e = this.options.lanes === 1 ? l[i - 1] : this.getFurthestMeasurement(l, i);
435
+ d = e ? e.end + this.options.gap : t + n, c = e ? e.lane : i % this.options.lanes, this.options.lanes > 1 && f && this.laneAssignments.set(i, c);
436
+ }
437
+ let p = s.get(e), m = typeof p == "number" ? p : this.options.estimateSize(i), h = d + m;
438
+ l[i] = {
439
+ index: i,
440
+ start: d,
441
+ size: m,
442
+ end: h,
443
+ key: e,
444
+ lane: c
445
+ }, u[c] = i;
446
+ }
447
+ return this.measurementsCache = l, l;
448
+ }, {
449
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
450
+ debug: () => this.options.debug
451
+ }), this.calculateRange = y(() => [
452
+ this.getMeasurements(),
453
+ this.getSize(),
454
+ this.getScrollOffset(),
455
+ this.options.lanes
456
+ ], (e, t, n, r) => this.range = e.length > 0 && t > 0 ? P({
457
+ measurements: e,
458
+ outerSize: t,
459
+ scrollOffset: n,
460
+ lanes: r
461
+ }) : null, {
462
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
463
+ debug: () => this.options.debug
464
+ }), this.getVirtualIndexes = y(() => {
465
+ let e = null, t = null, n = this.calculateRange();
466
+ return n && (e = n.startIndex, t = n.endIndex), this.maybeNotify.updateDeps([
467
+ this.isScrolling,
468
+ e,
469
+ t
470
+ ]), [
471
+ this.options.rangeExtractor,
472
+ this.options.overscan,
473
+ this.options.count,
474
+ e,
475
+ t
476
+ ];
477
+ }, (e, t, n, r, i) => r === null || i === null ? [] : e({
478
+ startIndex: r,
479
+ endIndex: i,
480
+ overscan: t,
481
+ count: n
482
+ }), {
483
+ key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
484
+ debug: () => this.options.debug
485
+ }), this.indexFromElement = (e) => {
486
+ let t = this.options.indexAttribute, n = e.getAttribute(t);
487
+ return n ? parseInt(n, 10) : (console.warn(`Missing attribute name '${t}={index}' on measured element.`), -1);
488
+ }, this.shouldMeasureDuringScroll = (e) => {
489
+ if (!this.scrollState || this.scrollState.behavior !== "smooth") return !0;
490
+ let t = this.scrollState.index ?? this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;
491
+ if (t !== void 0 && this.range) {
492
+ let n = Math.max(this.options.overscan, Math.ceil((this.range.endIndex - this.range.startIndex) / 2)), r = Math.max(0, t - n), i = Math.min(this.options.count - 1, t + n);
493
+ return e >= r && e <= i;
494
+ }
495
+ return !0;
496
+ }, this.measureElement = (e) => {
497
+ if (!e) {
498
+ this.elementsCache.forEach((e, t) => {
499
+ e.isConnected || (this.observer.unobserve(e), this.elementsCache.delete(t));
500
+ });
501
+ return;
502
+ }
503
+ let t = this.indexFromElement(e), n = this.options.getItemKey(t), r = this.elementsCache.get(n);
504
+ r !== e && (r && this.observer.unobserve(r), this.observer.observe(e), this.elementsCache.set(n, e)), (!this.isScrolling || this.scrollState) && this.shouldMeasureDuringScroll(t) && this.resizeItem(t, this.options.measureElement(e, void 0, this));
505
+ }, this.resizeItem = (e, t) => {
506
+ let n = this.measurementsCache[e];
507
+ if (!n) return;
508
+ let r = t - (this.itemSizeCache.get(n.key) ?? n.size);
509
+ r !== 0 && (this.scrollState?.behavior !== "smooth" && (this.shouldAdjustScrollPositionOnItemSizeChange === void 0 ? n.start < this.getScrollOffset() + this.scrollAdjustments : this.shouldAdjustScrollPositionOnItemSizeChange(n, r, this)) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", r), this._scrollToOffset(this.getScrollOffset(), {
510
+ adjustments: this.scrollAdjustments += r,
511
+ behavior: void 0
512
+ })), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, t)), this.notify(!1));
513
+ }, this.getVirtualItems = y(() => [this.getVirtualIndexes(), this.getMeasurements()], (e, t) => {
514
+ let n = [];
515
+ for (let r = 0, i = e.length; r < i; r++) {
516
+ let i = t[e[r]];
517
+ n.push(i);
518
+ }
519
+ return n;
520
+ }, {
521
+ key: process.env.NODE_ENV !== "production" && "getVirtualItems",
522
+ debug: () => this.options.debug
523
+ }), this.getVirtualItemForOffset = (e) => {
524
+ let t = this.getMeasurements();
525
+ if (t.length !== 0) return b(t[N(0, t.length - 1, (e) => b(t[e]).start, e)]);
526
+ }, this.getMaxScrollOffset = () => {
527
+ if (!this.scrollElement) return 0;
528
+ if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
529
+ {
530
+ let e = this.scrollElement.document.documentElement;
531
+ return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
532
+ }
533
+ }, this.getOffsetForAlignment = (e, t, n = 0) => {
534
+ if (!this.scrollElement) return 0;
535
+ let r = this.getSize(), i = this.getScrollOffset();
536
+ t === "auto" && (t = e >= i + r ? "end" : "start"), t === "center" ? e += (n - r) / 2 : t === "end" && (e -= r);
537
+ let a = this.getMaxScrollOffset();
538
+ return Math.max(Math.min(a, e), 0);
539
+ }, this.getOffsetForIndex = (e, t = "auto") => {
540
+ e = Math.max(0, Math.min(e, this.options.count - 1));
541
+ let n = this.getSize(), r = this.getScrollOffset(), i = this.measurementsCache[e];
542
+ if (!i) return;
543
+ if (t === "auto") if (i.end >= r + n - this.options.scrollPaddingEnd) t = "end";
544
+ else if (i.start <= r + this.options.scrollPaddingStart) t = "start";
545
+ else return [r, t];
546
+ if (t === "end" && e === this.options.count - 1) return [this.getMaxScrollOffset(), t];
547
+ let a = t === "end" ? i.end + this.options.scrollPaddingEnd : i.start - this.options.scrollPaddingStart;
548
+ return [this.getOffsetForAlignment(a, t, i.size), t];
549
+ }, this.scrollToOffset = (e, { align: t = "start", behavior: n = "auto" } = {}) => {
550
+ let r = this.getOffsetForAlignment(e, t), i = this.now();
551
+ this.scrollState = {
552
+ index: null,
553
+ align: t,
554
+ behavior: n,
555
+ startedAt: i,
556
+ lastTargetOffset: r,
557
+ stableFrames: 0
558
+ }, this._scrollToOffset(r, {
559
+ adjustments: void 0,
560
+ behavior: n
561
+ }), this.scheduleScrollReconcile();
562
+ }, this.scrollToIndex = (e, { align: t = "auto", behavior: n = "auto" } = {}) => {
563
+ e = Math.max(0, Math.min(e, this.options.count - 1));
564
+ let r = this.getOffsetForIndex(e, t);
565
+ if (!r) return;
566
+ let [i, a] = r, o = this.now();
567
+ this.scrollState = {
568
+ index: e,
569
+ align: a,
570
+ behavior: n,
571
+ startedAt: o,
572
+ lastTargetOffset: i,
573
+ stableFrames: 0
574
+ }, this._scrollToOffset(i, {
575
+ adjustments: void 0,
576
+ behavior: n
577
+ }), this.scheduleScrollReconcile();
578
+ }, this.scrollBy = (e, { behavior: t = "auto" } = {}) => {
579
+ let n = this.getScrollOffset() + e, r = this.now();
580
+ this.scrollState = {
581
+ index: null,
582
+ align: "start",
583
+ behavior: t,
584
+ startedAt: r,
585
+ lastTargetOffset: n,
586
+ stableFrames: 0
587
+ }, this._scrollToOffset(n, {
588
+ adjustments: void 0,
589
+ behavior: t
590
+ }), this.scheduleScrollReconcile();
591
+ }, this.getTotalSize = () => {
592
+ let e = this.getMeasurements(), t;
593
+ if (e.length === 0) t = this.options.paddingStart;
594
+ else if (this.options.lanes === 1) t = e[e.length - 1]?.end ?? 0;
595
+ else {
596
+ let n = Array(this.options.lanes).fill(null), r = e.length - 1;
597
+ for (; r >= 0 && n.some((e) => e === null);) {
598
+ let t = e[r];
599
+ n[t.lane] === null && (n[t.lane] = t.end), r--;
600
+ }
601
+ t = Math.max(...n.filter((e) => e !== null));
602
+ }
603
+ return Math.max(t - this.options.scrollMargin + this.options.paddingEnd, 0);
604
+ }, this._scrollToOffset = (e, { adjustments: t, behavior: n }) => {
605
+ this.options.scrollToFn(e, {
606
+ behavior: n,
607
+ adjustments: t
608
+ }, this);
609
+ }, this.measure = () => {
610
+ this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
611
+ }, this.setOptions(e);
612
+ }
613
+ scheduleScrollReconcile() {
614
+ if (!this.targetWindow) {
615
+ this.scrollState = null;
616
+ return;
617
+ }
618
+ this.rafId ??= this.targetWindow.requestAnimationFrame(() => {
619
+ this.rafId = null, this.reconcileScroll();
620
+ });
621
+ }
622
+ reconcileScroll() {
623
+ if (!this.scrollState || !this.scrollElement) return;
624
+ if (this.now() - this.scrollState.startedAt > 5e3) {
625
+ this.scrollState = null;
626
+ return;
627
+ }
628
+ let e = this.scrollState.index == null ? void 0 : this.getOffsetForIndex(this.scrollState.index, this.scrollState.align), t = e ? e[0] : this.scrollState.lastTargetOffset, n = t !== this.scrollState.lastTargetOffset;
629
+ if (!n && x(t, this.getScrollOffset())) {
630
+ if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= 1) {
631
+ this.scrollState = null;
632
+ return;
633
+ }
634
+ } else this.scrollState.stableFrames = 0, n && (this.scrollState.lastTargetOffset = t, this.scrollState.behavior = "auto", this._scrollToOffset(t, {
635
+ adjustments: void 0,
636
+ behavior: "auto"
637
+ }));
638
+ this.scheduleScrollReconcile();
639
+ }
640
+ }, N = (e, t, n, r) => {
641
+ for (; e <= t;) {
642
+ let i = (e + t) / 2 | 0, a = n(i);
643
+ if (a < r) e = i + 1;
644
+ else if (a > r) t = i - 1;
645
+ else return i;
646
+ }
647
+ return e > 0 ? e - 1 : 0;
1818
648
  };
1819
- function En({
1820
- measurements: e,
1821
- outerSize: o,
1822
- scrollOffset: t,
1823
- lanes: n
1824
- }) {
1825
- const s = e.length - 1, i = (c) => e[c].start;
1826
- if (e.length <= n)
1827
- return {
1828
- startIndex: 0,
1829
- endIndex: s
1830
- };
1831
- let r = it(
1832
- 0,
1833
- s,
1834
- i,
1835
- t
1836
- ), l = r;
1837
- if (n === 1)
1838
- for (; l < s && e[l].end < t + o; )
1839
- l++;
1840
- else if (n > 1) {
1841
- const c = Array(n).fill(0);
1842
- for (; l < s && c.some((a) => a < t + o); ) {
1843
- const a = e[l];
1844
- c[a.lane] = a.end, l++;
1845
- }
1846
- const u = Array(n).fill(t + o);
1847
- for (; r >= 0 && u.some((a) => a >= t); ) {
1848
- const a = e[r];
1849
- u[a.lane] = a.start, r--;
1850
- }
1851
- r = Math.max(0, r - r % n), l = Math.min(s, l + (n - 1 - l % n));
1852
- }
1853
- return { startIndex: r, endIndex: l };
1854
- }
1855
- const Be = typeof document < "u" ? O.useLayoutEffect : O.useEffect;
1856
- function Rn(e) {
1857
- const o = O.useReducer(() => ({}), {})[1], t = {
1858
- ...e,
1859
- onChange: (s, i) => {
1860
- var r;
1861
- i ? ut(o) : o(), (r = e.onChange) == null || r.call(e, s, i);
1862
- }
1863
- }, [n] = O.useState(
1864
- () => new On(t)
1865
- );
1866
- return n.setOptions(t), Be(() => n._didMount(), []), Be(() => n._willUpdate()), n;
1867
- }
1868
- function kn(e) {
1869
- return Rn({
1870
- observeElementRect: yn,
1871
- observeElementOffset: vn,
1872
- scrollToFn: Cn,
1873
- ...e
1874
- });
649
+ function P({ measurements: e, outerSize: t, scrollOffset: n, lanes: r }) {
650
+ let i = e.length - 1, a = (t) => e[t].start;
651
+ if (e.length <= r) return {
652
+ startIndex: 0,
653
+ endIndex: i
654
+ };
655
+ let o = N(0, i, a, n), s = o;
656
+ if (r === 1) for (; s < i && e[s].end < n + t;) s++;
657
+ else if (r > 1) {
658
+ let a = Array(r).fill(0);
659
+ for (; s < i && a.some((e) => e < n + t);) {
660
+ let t = e[s];
661
+ a[t.lane] = t.end, s++;
662
+ }
663
+ let c = Array(r).fill(n + t);
664
+ for (; o >= 0 && c.some((e) => e >= n);) {
665
+ let t = e[o];
666
+ c[t.lane] = t.start, o--;
667
+ }
668
+ o = Math.max(0, o - o % r), s = Math.min(i, s + (r - 1 - s % r));
669
+ }
670
+ return {
671
+ startIndex: o,
672
+ endIndex: s
673
+ };
674
+ }
675
+ //#endregion
676
+ //#region node_modules/.pnpm/@tanstack+react-virtual@3.13.24_react-dom@19.2.5_react@19.2.5__react@19.2.5/node_modules/@tanstack/react-virtual/dist/esm/index.js
677
+ var F = typeof document < "u" ? e.useLayoutEffect : e.useEffect;
678
+ function I({ useFlushSync: t = !0, ...n }) {
679
+ let r = e.useReducer(() => ({}), {})[1], i = {
680
+ ...n,
681
+ onChange: (e, i) => {
682
+ var a;
683
+ t && i ? l(r) : r(), (a = n.onChange) == null || a.call(n, e, i);
684
+ }
685
+ }, [a] = e.useState(() => new M(i));
686
+ return a.setOptions(i), F(() => a._didMount(), []), F(() => a._willUpdate()), a;
1875
687
  }
1876
- function An(e) {
1877
- return /* @__PURE__ */ y(
1878
- "svg",
1879
- {
1880
- xmlns: "http://www.w3.org/2000/svg",
1881
- fill: "none",
1882
- viewBox: "0 0 24 24",
1883
- strokeWidth: 1.5,
1884
- stroke: "currentColor",
1885
- className: "h-6 w-6",
1886
- ...e,
1887
- children: /* @__PURE__ */ y("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m19.5 8.25-7.5 7.5-7.5-7.5" })
1888
- }
1889
- );
1890
- }
1891
- function Mn(e) {
1892
- return /* @__PURE__ */ y(
1893
- "svg",
1894
- {
1895
- xmlns: "http://www.w3.org/2000/svg",
1896
- fill: "none",
1897
- viewBox: "0 0 24 24",
1898
- strokeWidth: 1.5,
1899
- stroke: "currentColor",
1900
- className: "h-6 w-6",
1901
- ...e,
1902
- children: /* @__PURE__ */ y(
1903
- "path",
1904
- {
1905
- strokeLinecap: "round",
1906
- strokeLinejoin: "round",
1907
- d: "m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"
1908
- }
1909
- )
1910
- }
1911
- );
1912
- }
1913
- function zn(e) {
1914
- return /* @__PURE__ */ y(
1915
- "svg",
1916
- {
1917
- xmlns: "http://www.w3.org/2000/svg",
1918
- fill: "none",
1919
- viewBox: "0 0 24 24",
1920
- strokeWidth: 1.5,
1921
- stroke: "currentColor",
1922
- className: "h-6 w-6",
1923
- ...e,
1924
- children: /* @__PURE__ */ y("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18 18 6M6 6l12 12" })
1925
- }
1926
- );
1927
- }
1928
- function Dn(e) {
1929
- const {
1930
- items: o,
1931
- selected: t,
1932
- className: n,
1933
- onChange: s,
1934
- disabled: i,
1935
- placeholder: r = "Select an Item",
1936
- multiple: l,
1937
- mutable: c,
1938
- onAdd: u
1939
- } = e, a = ve(null), [d, h] = fe(!1), f = ve(null);
1940
- return /* @__PURE__ */ y(
1941
- st,
1942
- {
1943
- placement: "bottom",
1944
- trigger: "click",
1945
- show: d,
1946
- setShow: h,
1947
- role: "combobox",
1948
- disabled: i,
1949
- style: {
1950
- "--input-width": `${f.current?.offsetWidth}px`
1951
- },
1952
- content: /* @__PURE__ */ y(
1953
- Nn,
1954
- {
1955
- ...c ? { mutable: c, onAdd: u } : { mutable: c },
1956
- ...l ? { multiple: l, items: o, onChange: s, selected: t } : { items: o, onChange: s, selected: t }
1957
- }
1958
- ),
1959
- children: /* @__PURE__ */ V(
1960
- "div",
1961
- {
1962
- className: k(
1963
- "inline-flex h-10 w-56 grow items-center justify-between rounded border-2 border-input bg-background p-2 transition",
1964
- i ? "cursor-not-allowed bg-muted text-muted" : "cursor-pointer",
1965
- d && "border-primary shadow-xs shadow-ring",
1966
- n
1967
- ),
1968
- ref: f,
1969
- children: [
1970
- /* @__PURE__ */ y(
1971
- "div",
1972
- {
1973
- className: k(
1974
- "flex max-w-[calc(100%-30px)] flex-none grow items-center gap-1 text-sm",
1975
- i ? "text-muted-foreground" : "text-foreground"
1976
- ),
1977
- ref: a,
1978
- children: l ? /* @__PURE__ */ y(
1979
- gn,
1980
- {
1981
- items: t.map((g) => g.text),
1982
- data: t,
1983
- parentRef: a,
1984
- estimator: (g, m) => m + 40,
1985
- badgeVariant: "secondary",
1986
- badgeStyles: "bg-input! h-6 min-w-min gap-2 bg-input!",
1987
- children: (g, m, p) => /* @__PURE__ */ V(
1988
- He,
1989
- {
1990
- className: "flex h-6 min-w-min gap-2 bg-input! pr-1",
1991
- variant: "secondary",
1992
- children: [
1993
- g,
1994
- /* @__PURE__ */ y(
1995
- dt,
1996
- {
1997
- onClick: () => {
1998
- s(t.filter((w) => w.key !== p?.key));
1999
- },
2000
- variant: "icon",
2001
- size: "icon",
2002
- className: "group bg-muted p-0.5 hover:bg-muted-foreground",
2003
- children: /* @__PURE__ */ y(zn, { className: "size-3 transition duration-300 group-hover:rotate-90 group-hover:text-muted" })
2004
- }
2005
- )
2006
- ]
2007
- },
2008
- `collapsed_item_${m}`
2009
- )
2010
- }
2011
- ) : t.text ?? r
2012
- }
2013
- ),
2014
- /* @__PURE__ */ y(
2015
- An,
2016
- {
2017
- className: k(
2018
- "size-4 rounded-full bg-input p-0.5 transition duration-300 ease-in-out",
2019
- d ? "rotate-180" : "rotate-0",
2020
- i ? "text-muted-foreground" : "text-foreground"
2021
- )
2022
- }
2023
- )
2024
- ]
2025
- }
2026
- )
2027
- }
2028
- );
2029
- }
2030
- function Nn(e) {
2031
- const { items: o, multiple: t, selected: n, onChange: s, mutable: i, onAdd: r } = e, [l, c] = fe(""), u = ve(null), a = ye(
2032
- () => o.reduce((f, g) => ((!l.length || g.text.toLowerCase().includes(l.toLowerCase())) && f.push(g), f), []),
2033
- [o, l]
2034
- ), d = kn({
2035
- count: a.length,
2036
- getScrollElement: () => u.current,
2037
- estimateSize: () => 35
2038
- }), h = n instanceof Array ? n.map((f) => f.key) : [n.key];
2039
- return /* @__PURE__ */ V("div", { className: "flex min-w-[var(--input-width)] flex-col divide-y-2 divide-border overflow-hidden rounded border border-input bg-background", children: [
2040
- /* @__PURE__ */ V("div", { className: k("inline-flex grow items-center rounded px-3 py-2"), children: [
2041
- /* @__PURE__ */ y(Mn, { className: "left-3 top-3 mr-2 size-4 text-muted-foreground" }),
2042
- /* @__PURE__ */ y(
2043
- "input",
2044
- {
2045
- className: "inline-flex grow bg-transparent text-sm text-foreground outline-hidden",
2046
- placeholder: "Search",
2047
- value: l,
2048
- onChange: (f) => c(f.target.value)
2049
- }
2050
- )
2051
- ] }),
2052
- /* @__PURE__ */ V(
2053
- "ul",
2054
- {
2055
- className: k("max-h-60 grow overflow-auto shadow-sm", "focus:outline-hidden focus:ring-0"),
2056
- ref: u,
2057
- children: [
2058
- /* @__PURE__ */ y(
2059
- "div",
2060
- {
2061
- style: {
2062
- height: `${d.getTotalSize()}px`,
2063
- width: "100%",
2064
- position: "relative"
2065
- },
2066
- children: d.getVirtualItems().map((f) => /* @__PURE__ */ y(
2067
- "li",
2068
- {
2069
- style: {
2070
- height: `${f.size}px`,
2071
- transform: `translateY(${f.start}px)`
2072
- },
2073
- className: k(
2074
- "absolute left-0 top-0 w-full cursor-pointer px-3 py-2 text-sm text-foreground",
2075
- h.includes(a[f.index].key) ? "bg-primary/90 text-primary-foreground" : "transition hover:bg-primary/60"
2076
- ),
2077
- onClick: () => {
2078
- t ? h.includes(a[f.index].key) ? s(
2079
- structuredClone(
2080
- n.filter(
2081
- (g) => g.key !== a[f.index].key
2082
- )
2083
- )
2084
- ) : s(structuredClone([...n, a[f.index]])) : s(a[f.index]);
2085
- },
2086
- children: a[f.index].text
2087
- },
2088
- f.key
2089
- ))
2090
- }
2091
- ),
2092
- l.length > 0 && a.length === 0 && (i ? /* @__PURE__ */ V(
2093
- "li",
2094
- {
2095
- className: k("px-3 py-2 text-sm text-foreground"),
2096
- onClick: () => {
2097
- r({ text: l, key: l }), c("");
2098
- },
2099
- children: [
2100
- "Add ",
2101
- l
2102
- ]
2103
- }
2104
- ) : /* @__PURE__ */ y("li", { className: k("cursor-not-allowed px-3 py-2 text-sm text-foreground"), children: "No results found" }))
2105
- ]
2106
- }
2107
- )
2108
- ] });
2109
- }
2110
- function In(e) {
2111
- return /* @__PURE__ */ y(
2112
- "svg",
2113
- {
2114
- xmlns: "http://www.w3.org/2000/svg",
2115
- fill: "none",
2116
- viewBox: "0 0 24 24",
2117
- strokeWidth: 1.5,
2118
- stroke: "currentColor",
2119
- className: "h-6 w-6",
2120
- ...e,
2121
- children: /* @__PURE__ */ y("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m4.5 15.75 7.5-7.5 7.5 7.5" })
2122
- }
2123
- );
2124
- }
2125
- function Fn(e) {
2126
- const { className: o, ...t } = e;
2127
- return /* @__PURE__ */ y(
2128
- "input",
2129
- {
2130
- className: k(
2131
- "h-10 w-full rounded border-2 border-input bg-background px-3 py-2 text-sm text-foreground transition",
2132
- "focus-visible:border-primary focus-visible:shadow-xs focus-visible:shadow-ring focus-visible:outline-hidden",
2133
- "read-only:cursor-pointer read-only:border-none! read-only:bg-transparent read-only:text-foreground read-only:shadow-none! read-only:outline-hidden!",
2134
- "disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted",
2135
- "file:border-0 file:bg-transparent file:text-sm file:font-medium",
2136
- o
2137
- ),
2138
- ...t
2139
- }
2140
- );
2141
- }
2142
- function Pn(e) {
2143
- const { className: o, checked: t, onChange: n, defaultChecked: s, ...i } = e;
2144
- return /* @__PURE__ */ V(
2145
- "div",
2146
- {
2147
- className: k(
2148
- "rounded-full",
2149
- "h-5 w-10",
2150
- "border-muted bg-secondary border",
2151
- "flex items-center",
2152
- o
2153
- ),
2154
- onClick: () => n?.(!t),
2155
- children: [
2156
- /* @__PURE__ */ y("input", { type: "hidden", readOnly: !0, ...i, defaultChecked: s, checked: t }),
2157
- /* @__PURE__ */ y(
2158
- "div",
2159
- {
2160
- className: k(
2161
- "[animation-timing-function:cubic-bezier(1, 0, 0, 1)] bg-primary size-4 rounded-full transition-all duration-250",
2162
- t ? "translate-x-5" : "translate-x-0"
2163
- )
2164
- }
2165
- )
2166
- ]
2167
- }
2168
- );
2169
- }
2170
- function Vn(e) {
2171
- const { className: o, ...t } = e;
2172
- return /* @__PURE__ */ y(
2173
- "textarea",
2174
- {
2175
- className: k(
2176
- "border-input bg-background text-foreground h-10 w-full rounded border-2 px-3 py-2 text-sm transition",
2177
- "focus-visible:border-primary focus-visible:shadow-ring focus-visible:shadow-xs focus-visible:outline-hidden",
2178
- "read-only:text-foreground read-only:cursor-pointer read-only:border-none! read-only:bg-transparent read-only:shadow-none! read-only:outline-hidden!",
2179
- "disabled:bg-muted disabled:text-muted disabled:cursor-not-allowed",
2180
- "file:border-0 file:bg-transparent file:text-sm file:font-medium",
2181
- o
2182
- ),
2183
- ...t
2184
- }
2185
- );
688
+ function L(e) {
689
+ return I({
690
+ observeElementRect: E,
691
+ observeElementOffset: k,
692
+ scrollToFn: j,
693
+ ...e
694
+ });
695
+ }
696
+ //#endregion
697
+ //#region packages/icons/chevron-up.tsx
698
+ function R(e) {
699
+ return /* @__PURE__ */ s("svg", {
700
+ xmlns: "http://www.w3.org/2000/svg",
701
+ fill: "none",
702
+ viewBox: "0 0 24 24",
703
+ strokeWidth: 1.5,
704
+ stroke: "currentColor",
705
+ className: "h-6 w-6",
706
+ ...e,
707
+ children: /* @__PURE__ */ s("path", {
708
+ strokeLinecap: "round",
709
+ strokeLinejoin: "round",
710
+ d: "m19.5 8.25-7.5 7.5-7.5-7.5"
711
+ })
712
+ });
713
+ }
714
+ //#endregion
715
+ //#region packages/icons/search.tsx
716
+ function z(e) {
717
+ return /* @__PURE__ */ s("svg", {
718
+ xmlns: "http://www.w3.org/2000/svg",
719
+ fill: "none",
720
+ viewBox: "0 0 24 24",
721
+ strokeWidth: 1.5,
722
+ stroke: "currentColor",
723
+ className: "h-6 w-6",
724
+ ...e,
725
+ children: /* @__PURE__ */ s("path", {
726
+ strokeLinecap: "round",
727
+ strokeLinejoin: "round",
728
+ d: "m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"
729
+ })
730
+ });
731
+ }
732
+ //#endregion
733
+ //#region packages/icons/x-mark.tsx
734
+ function B(e) {
735
+ return /* @__PURE__ */ s("svg", {
736
+ xmlns: "http://www.w3.org/2000/svg",
737
+ fill: "none",
738
+ viewBox: "0 0 24 24",
739
+ strokeWidth: 1.5,
740
+ stroke: "currentColor",
741
+ className: "h-6 w-6",
742
+ ...e,
743
+ children: /* @__PURE__ */ s("path", {
744
+ strokeLinecap: "round",
745
+ strokeLinejoin: "round",
746
+ d: "M6 18 18 6M6 6l12 12"
747
+ })
748
+ });
749
+ }
750
+ //#endregion
751
+ //#region packages/dropdown/index.tsx
752
+ function V(e) {
753
+ let { items: t, selected: n, className: r, onChange: o, disabled: l, placeholder: d = "Select an Item", multiple: f, mutable: m, onAdd: g } = e, y = i(null), [b, x] = a(!1);
754
+ return /* @__PURE__ */ s(_, {
755
+ content: /* @__PURE__ */ s(H, {
756
+ ...m ? {
757
+ mutable: m,
758
+ onAdd: g
759
+ } : { mutable: m },
760
+ ...f ? {
761
+ multiple: f,
762
+ items: t,
763
+ onChange: o,
764
+ selected: n
765
+ } : {
766
+ items: t,
767
+ onChange: o,
768
+ selected: n
769
+ }
770
+ }),
771
+ onOpen: () => x(!0),
772
+ onClose: () => x(!1),
773
+ children: /* @__PURE__ */ c("div", {
774
+ role: "combobox",
775
+ "aria-expanded": b,
776
+ "aria-haspopup": "listbox",
777
+ className: u("border-input bg-background inline-flex h-10 w-56 grow items-center justify-between rounded border-2 p-2 transition", l ? "bg-muted text-muted-foreground cursor-not-allowed" : "cursor-pointer", b && "border-primary", r),
778
+ children: [/* @__PURE__ */ s("div", {
779
+ className: u("flex max-w-[calc(100%-30px)] flex-none grow items-center gap-1 text-sm", l ? "text-muted-foreground" : "text-foreground"),
780
+ ref: y,
781
+ children: f ? /* @__PURE__ */ s(v, {
782
+ items: n.map((e) => e.text),
783
+ data: n,
784
+ parentRef: y,
785
+ estimator: (e, t) => t + 40,
786
+ badgeVariant: "secondary",
787
+ badgeStyles: "bg-input! h-6 min-w-min gap-2",
788
+ children: (e, t, r) => /* @__PURE__ */ c(p, {
789
+ className: "bg-input! flex h-6 min-w-min gap-2 pr-1",
790
+ variant: "secondary",
791
+ children: [e, /* @__PURE__ */ s(h, {
792
+ onClick: () => {
793
+ o(n.filter((e) => e.key !== r?.key));
794
+ },
795
+ variant: "icon",
796
+ size: "icon",
797
+ className: "group bg-muted hover:bg-muted-foreground p-0.5",
798
+ children: /* @__PURE__ */ s(B, { className: "group-hover:text-muted size-3 transition duration-300 group-hover:rotate-90" })
799
+ })]
800
+ }, `collapsed_item_${r?.key ?? t}`)
801
+ }) : n.text ?? d
802
+ }), /* @__PURE__ */ s(R, { className: u("bg-input size-4 rounded-full p-0.5 transition duration-300 ease-in-out", b ? "rotate-180" : "rotate-0", l ? "text-muted-foreground" : "text-foreground") })]
803
+ })
804
+ });
2186
805
  }
2187
- export {
2188
- He as Badge,
2189
- dt as Button,
2190
- In as ChevronDown,
2191
- An as ChevronUp,
2192
- gn as Collapse,
2193
- Dn as Dropdown,
2194
- Fn as Input,
2195
- st as Popover,
2196
- Mn as Search,
2197
- Vn as TextArea,
2198
- Pn as Toggle,
2199
- $e as cva,
2200
- k as cx
2201
- };
806
+ function H(e) {
807
+ let { items: t, multiple: n, selected: o, onChange: l, mutable: d, onAdd: f } = e, [p, m] = a(""), h = i(null), g = r(() => t.reduce((e, t) => ((!p.length || t.text.toLowerCase().includes(p.toLowerCase())) && e.push(t), e), []), [t, p]), _ = L({
808
+ count: g.length,
809
+ getScrollElement: () => h.current,
810
+ estimateSize: () => 35
811
+ }), v = o instanceof Array ? o.map((e) => e.key) : [o.key];
812
+ return /* @__PURE__ */ c("div", {
813
+ className: "divide-border border-input bg-background flex w-full flex-col divide-y overflow-hidden rounded border",
814
+ children: [/* @__PURE__ */ c("div", {
815
+ className: u("flex grow items-center rounded px-3 py-2"),
816
+ children: [/* @__PURE__ */ s(z, { className: "text-muted-foreground mr-2 size-4" }), /* @__PURE__ */ s("input", {
817
+ className: "text-foreground inline-flex grow bg-transparent text-sm outline-hidden",
818
+ placeholder: "Search",
819
+ value: p,
820
+ onChange: (e) => m(e.target.value)
821
+ })]
822
+ }), /* @__PURE__ */ c("ul", {
823
+ role: "listbox",
824
+ className: u("max-h-60 grow overflow-auto shadow-sm", "focus:ring-0 focus:outline-hidden"),
825
+ ref: h,
826
+ children: [/* @__PURE__ */ s("div", {
827
+ style: {
828
+ height: `${_.getTotalSize()}px`,
829
+ width: "100%",
830
+ position: "relative"
831
+ },
832
+ children: _.getVirtualItems().map((e) => /* @__PURE__ */ s("li", {
833
+ role: "option",
834
+ "aria-selected": v.includes(g[e.index].key),
835
+ style: {
836
+ height: `${e.size}px`,
837
+ transform: `translateY(${e.start}px)`
838
+ },
839
+ className: u("text-foreground absolute top-0 left-0 w-full cursor-pointer px-3 py-2 text-sm transition", v.includes(g[e.index].key) ? "bg-primary/90 text-primary-foreground dark:text-foreground" : "hover:bg-primary/60 hover:text-primary-foreground dark:hover:text-foreground"),
840
+ onClick: () => {
841
+ n ? v.includes(g[e.index].key) ? l(structuredClone(o.filter((t) => t.key !== g[e.index].key))) : l(structuredClone([...o, g[e.index]])) : l(g[e.index]);
842
+ },
843
+ children: g[e.index].text
844
+ }, e.key))
845
+ }), p.length > 0 && g.length === 0 && (d ? /* @__PURE__ */ c("li", {
846
+ role: "option",
847
+ "aria-selected": !1,
848
+ className: u("text-foreground cursor-pointer px-3 py-2 text-sm"),
849
+ onClick: () => {
850
+ f({
851
+ text: p,
852
+ key: p
853
+ }), m("");
854
+ },
855
+ children: ["Add ", p]
856
+ }) : /* @__PURE__ */ s("li", {
857
+ role: "option",
858
+ "aria-selected": !1,
859
+ className: u("text-foreground cursor-not-allowed px-3 py-2 text-sm"),
860
+ children: "No results found"
861
+ }))]
862
+ })]
863
+ });
864
+ }
865
+ //#endregion
866
+ //#region packages/icons/chevron-down.tsx
867
+ function U(e) {
868
+ return /* @__PURE__ */ s("svg", {
869
+ xmlns: "http://www.w3.org/2000/svg",
870
+ fill: "none",
871
+ viewBox: "0 0 24 24",
872
+ strokeWidth: 1.5,
873
+ stroke: "currentColor",
874
+ className: "h-6 w-6",
875
+ ...e,
876
+ children: /* @__PURE__ */ s("path", {
877
+ strokeLinecap: "round",
878
+ strokeLinejoin: "round",
879
+ d: "m4.5 15.75 7.5-7.5 7.5 7.5"
880
+ })
881
+ });
882
+ }
883
+ //#endregion
884
+ //#region packages/input/index.tsx
885
+ function W(e) {
886
+ let { className: t, ...n } = e;
887
+ return /* @__PURE__ */ s("input", {
888
+ className: u("border-input bg-background text-foreground h-10 w-full rounded border-2 px-3 py-2 text-sm transition", "placeholder:text-muted-foreground", "focus-visible:border-primary focus-visible:ring-ring/30 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-hidden", "read-only:text-foreground read-only:cursor-default read-only:border-none! read-only:bg-transparent read-only:shadow-none! read-only:outline-hidden!", "disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed", "file:border-0 file:bg-transparent file:text-sm file:font-medium", "[[type=\"checkbox\"]]:accent-primary [[type=\"checkbox\"]]:h-4 [[type=\"checkbox\"]]:w-4 [[type=\"checkbox\"]]:rounded-sm", "[[type=\"radio\"]]:accent-primary [[type=\"radio\"]]:h-4 [[type=\"radio\"]]:w-4", t),
889
+ ...n
890
+ });
891
+ }
892
+ //#endregion
893
+ //#region packages/textarea/index.tsx
894
+ function G(e) {
895
+ let { className: t, ...n } = e;
896
+ return /* @__PURE__ */ s("textarea", {
897
+ className: u("border-input bg-background text-foreground h-32 w-full resize-y rounded border-2 px-3 py-2 text-sm transition", "placeholder:text-muted-foreground", "focus-visible:border-primary focus-visible:ring-ring/30 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-hidden", "read-only:text-foreground read-only:cursor-default read-only:border-none! read-only:bg-transparent read-only:shadow-none! read-only:outline-hidden!", "disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed", t),
898
+ ...n
899
+ });
900
+ }
901
+ //#endregion
902
+ //#region packages/toggle/index.tsx
903
+ function K(e) {
904
+ let { className: t, checked: r, onChange: i, defaultChecked: a, id: o, ...l } = e, d = n(), f = o ?? d;
905
+ return /* @__PURE__ */ c("div", {
906
+ role: "switch",
907
+ "aria-checked": r ?? a ?? !1,
908
+ tabIndex: 0,
909
+ className: u("relative inline-flex h-5 w-10 shrink-0 cursor-pointer items-center rounded-full", "border-primary bg-secondary dark:bg-muted border", "focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", "transition-colors duration-300 ease-in-out", t),
910
+ onClick: () => i?.(!r),
911
+ onKeyDown: (e) => {
912
+ (e.key === " " || e.key === "Enter") && (e.preventDefault(), i?.(!r));
913
+ },
914
+ children: [/* @__PURE__ */ s("input", {
915
+ type: "checkbox",
916
+ id: f,
917
+ className: "sr-only",
918
+ checked: r,
919
+ defaultChecked: a,
920
+ onChange: (e) => i?.(e.target.checked),
921
+ tabIndex: -1,
922
+ ...l
923
+ }), /* @__PURE__ */ s("span", { className: u("bg-primary size-4 rounded-full transition-all duration-300 ease-in-out", r ? "translate-x-5" : "translate-x-0.5") })]
924
+ });
925
+ }
926
+ //#endregion
927
+ export { p as Badge, h as Button, U as ChevronDown, R as ChevronUp, v as Collapse, V as Dropdown, W as Input, _ as Popover, z as Search, G as TextArea, K as Toggle, f as cva, u as cx };