@rinzai/zen 0.1.11 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/index.d.ts +2 -17
  2. package/dist/packages/badge/index.d.ts.map +1 -0
  3. package/dist/packages/button/index.d.ts.map +1 -0
  4. package/dist/packages/collapse/index.d.ts.map +1 -0
  5. package/dist/packages/dropdown/index.d.ts.map +1 -0
  6. package/dist/packages/icons/chevron-down.d.ts.map +1 -0
  7. package/dist/packages/icons/chevron-up.d.ts.map +1 -0
  8. package/dist/packages/icons/icon.types.d.ts.map +1 -0
  9. package/dist/packages/icons/index.d.ts.map +1 -0
  10. package/dist/packages/icons/search.d.ts.map +1 -0
  11. package/dist/packages/icons/x-mark.d.ts.map +1 -0
  12. package/dist/packages/index.d.ts +17 -0
  13. package/dist/packages/index.d.ts.map +1 -0
  14. package/dist/packages/input/index.d.ts.map +1 -0
  15. package/dist/{popover → packages/popover}/index.d.ts +2 -0
  16. package/dist/packages/popover/index.d.ts.map +1 -0
  17. package/dist/packages/textarea/index.d.ts.map +1 -0
  18. package/dist/packages/toggle/index.d.ts.map +1 -0
  19. package/dist/packages/utils/cva.d.ts.map +1 -0
  20. package/dist/packages/utils/cx.d.ts.map +1 -0
  21. package/dist/packages/utils/useClickOutside.d.ts.map +1 -0
  22. package/dist/zen.css +3 -1
  23. package/dist/zen.js +892 -2194
  24. package/package.json +78 -69
  25. package/dist/badge/index.d.ts.map +0 -1
  26. package/dist/button/index.d.ts.map +0 -1
  27. package/dist/collapse/index.d.ts.map +0 -1
  28. package/dist/dropdown/index.d.ts.map +0 -1
  29. package/dist/icons/chevron-down.d.ts.map +0 -1
  30. package/dist/icons/chevron-up.d.ts.map +0 -1
  31. package/dist/icons/icon.types.d.ts.map +0 -1
  32. package/dist/icons/index.d.ts.map +0 -1
  33. package/dist/icons/search.d.ts.map +0 -1
  34. package/dist/icons/x-mark.d.ts.map +0 -1
  35. package/dist/index.d.ts.map +0 -1
  36. package/dist/input/index.d.ts.map +0 -1
  37. package/dist/popover/index.d.ts.map +0 -1
  38. package/dist/textarea/index.d.ts.map +0 -1
  39. package/dist/toggle/index.d.ts.map +0 -1
  40. package/dist/utils/cva.d.ts.map +0 -1
  41. package/dist/utils/cx.d.ts.map +0 -1
  42. package/dist/utils/useClickOutside.d.ts.map +0 -1
  43. /package/dist/{badge → packages/badge}/index.d.ts +0 -0
  44. /package/dist/{button → packages/button}/index.d.ts +0 -0
  45. /package/dist/{collapse → packages/collapse}/index.d.ts +0 -0
  46. /package/dist/{dropdown → packages/dropdown}/index.d.ts +0 -0
  47. /package/dist/{icons → packages/icons}/chevron-down.d.ts +0 -0
  48. /package/dist/{icons → packages/icons}/chevron-up.d.ts +0 -0
  49. /package/dist/{icons → packages/icons}/icon.types.d.ts +0 -0
  50. /package/dist/{icons → packages/icons}/index.d.ts +0 -0
  51. /package/dist/{icons → packages/icons}/search.d.ts +0 -0
  52. /package/dist/{icons → packages/icons}/x-mark.d.ts +0 -0
  53. /package/dist/{input → packages/input}/index.d.ts +0 -0
  54. /package/dist/{textarea → packages/textarea}/index.d.ts +0 -0
  55. /package/dist/{toggle → packages/toggle}/index.d.ts +0 -0
  56. /package/dist/{utils → packages/utils}/cva.d.ts +0 -0
  57. /package/dist/{utils → packages/utils}/cx.d.ts +0 -0
  58. /package/dist/{utils → packages/utils}/useClickOutside.d.ts +0 -0
package/dist/zen.js CHANGED
@@ -1,2201 +1,899 @@
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", {
38
+ variants: { variant: {
39
+ default: "border-transparent bg-primary text-primary-foreground shadow-sm",
40
+ secondary: "border-transparent bg-secondary text-secondary-foreground",
41
+ destructive: "border-transparent bg-destructive text-destructive-foreground shadow-sm",
42
+ outline: "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-xs hover:bg-destructive/70 active:bg-destructive",
63
+ outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground active:bg-accent",
64
+ secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/70 active:bg-secondary/90",
65
+ ghost: "hover:bg-accent hover:text-accent-foreground active:bg-accent",
66
+ link: "text-primary underline-offset-4 hover:underline active:underline",
67
+ icon: ""
68
+ },
69
+ size: {
70
+ default: "h-9 px-4 py-2",
71
+ sm: "h-8 rounded-md px-3 text-xs",
72
+ lg: "h-10 rounded-md px-8",
73
+ icon: ""
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: a, role: o = "tooltip", triggerType: l = "auto", trigger: d = "click", gap: f = "5px", show: p, setShow: m, style: h, ...g } = e, _ = crypto.randomUUID(), v = i(null);
85
+ return t(() => {
86
+ let t = v.current;
87
+ if (!t) return;
88
+ let n = () => e.onOpen?.(), r = () => e.onClose?.();
89
+ return t.addEventListener("popover:open", n), t.addEventListener("popover:close", r), () => {
90
+ t.removeEventListener("popover:open", n), t.removeEventListener("popover:close", r);
91
+ };
92
+ }, [e.onOpen, e.onClose]), t(() => {
93
+ l === "manual" && (p ? v.current?.showPopover?.() : v.current?.hidePopover?.());
94
+ }, [p, l]), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("div", {
95
+ className: "z-auto max-w-fit min-w-fit",
96
+ style: { "anchor-name": `--zen-popover-anchor-${_}` },
97
+ popoverTarget: `zen__popover-${_}`,
98
+ popoverTargetAction: "toggle",
99
+ onClick: d === "click" ? (e) => {
100
+ switch (e.stopPropagation(), e.nativeEvent.stopImmediatePropagation(), l) {
101
+ case "auto":
102
+ v.current?.togglePopover?.();
103
+ break;
104
+ case "manual":
105
+ m?.(!p);
106
+ break;
107
+ }
108
+ } : void 0,
109
+ onMouseEnter: d === "hover" ? (e) => {
110
+ e.stopPropagation(), v.current?.showPopover?.();
111
+ } : void 0,
112
+ onMouseLeave: d === "hover" ? (e) => {
113
+ e.stopPropagation(), v.current?.hidePopover?.();
114
+ } : void 0,
115
+ children: a
116
+ }), /* @__PURE__ */ s("div", {
117
+ ...g,
118
+ ref: v,
119
+ role: "tooltip",
120
+ popover: l,
121
+ id: `zen__popover-${_}`,
122
+ className: u("zen__popover border-border bg-background shadow-secondary fixed z-50 w-[anchor-size(width)] min-w-max [justify-self:anchor-center] rounded border [position-area:block-end_center]", n),
123
+ style: {
124
+ ...h,
125
+ "--gap": f,
126
+ top: "calc(anchor(bottom) + var(--gap))",
127
+ "position-anchor": `--zen-popover-anchor-${_}`
128
+ },
129
+ children: r
130
+ })] });
131
+ }
132
+ //#endregion
133
+ //#region packages/collapse/index.tsx
134
+ function v(e) {
135
+ 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({
136
+ visible: n,
137
+ hidden: []
138
+ }), b = r(() => {
139
+ if (typeof document > "u") return null;
140
+ let e = document.createElement("canvas").getContext("2d");
141
+ return e && (e.font = m), e;
142
+ }, []), x = () => {
143
+ let e = u?.current;
144
+ if (!e) return;
145
+ let t = e.offsetWidth, r = [], i = [], a = f(l, (b?.measureText(l).width ?? 0) + 10);
146
+ S?.reduce((e, o, s) => (e + o + a > t - 20 ? i.push(n[s]) : r.push(n[s]), e + o), 0), y({
147
+ visible: r,
148
+ hidden: i
149
+ });
150
+ }, S = r(() => n?.map((e) => f(e, b?.measureText(e).width ?? 0)) ?? [], [n]);
151
+ return t(() => {
152
+ x();
153
+ }, [n]), t(() => {
154
+ if (!u?.current) return;
155
+ let e = new ResizeObserver(() => {
156
+ x();
157
+ });
158
+ return e.observe(u.current), () => {
159
+ e.disconnect();
160
+ };
161
+ }, [n]), /* @__PURE__ */ c(o, { children: [v.visible?.map((e, t) => i(e, t, d?.[t])), v.hidden?.length > 0 && /* @__PURE__ */ s(_, {
162
+ trigger: "click",
163
+ content: /* @__PURE__ */ s("div", {
164
+ className: "grid max-h-60 grid-flow-row grid-cols-2 gap-3 overflow-auto p-2",
165
+ children: v.hidden.map((e, t) => i(e, v.visible.length + t, d?.[v.visible.length + t]))
166
+ }),
167
+ children: /* @__PURE__ */ s(p, {
168
+ className: g,
169
+ variant: h,
170
+ children: /* @__PURE__ */ s("p", { children: `+${v.hidden.length} ${l}` })
171
+ }, "more_items_button")
172
+ })] });
173
+ }
174
+ //#endregion
175
+ //#region node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
176
+ function y(e, t, n) {
177
+ let r = n.initialDeps ?? [], i, a = !0;
178
+ function o() {
179
+ let o;
180
+ n.key && n.debug?.call(n) && (o = Date.now());
181
+ let s = e();
182
+ if (!(s.length !== r.length || s.some((e, t) => r[t] !== e))) return i;
183
+ r = s;
184
+ let c;
185
+ if (n.key && n.debug?.call(n) && (c = Date.now()), i = t(...s), n.key && n.debug?.call(n)) {
186
+ let e = Math.round((Date.now() - o) * 100) / 100, t = Math.round((Date.now() - c) * 100) / 100, r = t / 16, i = (e, t) => {
187
+ for (e = String(e); e.length < t;) e = " " + e;
188
+ return e;
189
+ };
190
+ console.info(`%c⏱ ${i(t, 5)} /${i(e, 5)} ms`, `
1347
191
  font-size: .6rem;
1348
192
  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;
193
+ color: hsl(${Math.max(0, Math.min(120 - 120 * r, 120))}deg 100% 31%);`, n?.key);
194
+ }
195
+ return n?.onChange && !(a && n.skipInitialOnChange) && n.onChange(i), a = !1, i;
196
+ }
197
+ return o.updateDeps = (e) => {
198
+ r = e;
199
+ }, o;
200
+ }
201
+ function b(e, t) {
202
+ if (e === void 0) throw Error(`Unexpected undefined${t ? `: ${t}` : ""}`);
203
+ return e;
204
+ }
205
+ var x = (e, t) => Math.abs(e - t) < 1.01, S = (e, t, n) => {
206
+ let r;
207
+ return function(...i) {
208
+ e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, i), n);
209
+ };
210
+ }, C = (e) => {
211
+ let { offsetWidth: t, offsetHeight: n } = e;
212
+ return {
213
+ width: t,
214
+ height: n
215
+ };
216
+ }, w = (e) => e, T = (e) => {
217
+ let t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
218
+ for (let e = t; e <= n; e++) r.push(e);
219
+ return r;
220
+ }, E = (e, t) => {
221
+ let n = e.scrollElement;
222
+ if (!n) return;
223
+ let r = e.targetWindow;
224
+ if (!r) return;
225
+ let i = (e) => {
226
+ let { width: n, height: r } = e;
227
+ t({
228
+ width: Math.round(n),
229
+ height: Math.round(r)
230
+ });
231
+ };
232
+ if (i(C(n)), !r.ResizeObserver) return () => {};
233
+ let a = new r.ResizeObserver((t) => {
234
+ let r = () => {
235
+ let e = t[0];
236
+ if (e?.borderBoxSize) {
237
+ let t = e.borderBoxSize[0];
238
+ if (t) {
239
+ i({
240
+ width: t.inlineSize,
241
+ height: t.blockSize
242
+ });
243
+ return;
244
+ }
245
+ }
246
+ i(C(n));
247
+ };
248
+ e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
249
+ });
250
+ return a.observe(n, { box: "border-box" }), () => {
251
+ a.unobserve(n);
252
+ };
253
+ }, D = { passive: !0 }, O = typeof window > "u" ? !0 : "onscrollend" in window, k = (e, t) => {
254
+ let n = e.scrollElement;
255
+ if (!n) return;
256
+ let r = e.targetWindow;
257
+ if (!r) return;
258
+ let i = 0, a = e.options.useScrollendEvent && O ? () => void 0 : S(r, () => {
259
+ t(i, !1);
260
+ }, e.options.isScrollingResetDelay), o = (r) => () => {
261
+ let { horizontal: o, isRtl: s } = e.options;
262
+ i = o ? n.scrollLeft * (s && -1 || 1) : n.scrollTop, a(), t(i, r);
263
+ }, s = o(!0), c = o(!1);
264
+ n.addEventListener("scroll", s, D);
265
+ let l = e.options.useScrollendEvent && O;
266
+ return l && n.addEventListener("scrollend", c, D), () => {
267
+ n.removeEventListener("scroll", s), l && n.removeEventListener("scrollend", c);
268
+ };
269
+ }, A = (e, t, n) => {
270
+ if (t?.borderBoxSize) {
271
+ let e = t.borderBoxSize[0];
272
+ if (e) return Math.round(e[n.options.horizontal ? "inlineSize" : "blockSize"]);
273
+ }
274
+ return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
275
+ }, j = (e, { adjustments: t = 0, behavior: n }, r) => {
276
+ var i, a;
277
+ let o = e + t;
278
+ (a = (i = r.scrollElement)?.scrollTo) == null || a.call(i, {
279
+ [r.options.horizontal ? "left" : "top"]: o,
280
+ behavior: n
281
+ });
282
+ }, M = class {
283
+ constructor(e) {
284
+ 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 = () => {
285
+ var e;
286
+ return ((e = this.targetWindow?.performance)?.now)?.call(e) ?? Date.now();
287
+ }, this.observer = /* @__PURE__ */ (() => {
288
+ let e = null, t = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((e) => {
289
+ e.forEach((e) => {
290
+ let t = () => {
291
+ let t = e.target, n = this.indexFromElement(t);
292
+ if (!t.isConnected) {
293
+ this.observer.unobserve(t);
294
+ return;
295
+ }
296
+ this.shouldMeasureDuringScroll(n) && this.resizeItem(n, this.options.measureElement(t, e, this));
297
+ };
298
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(t) : t();
299
+ });
300
+ }));
301
+ return {
302
+ disconnect: () => {
303
+ var n;
304
+ (n = t()) == null || n.disconnect(), e = null;
305
+ },
306
+ observe: (e) => t()?.observe(e, { box: "border-box" }),
307
+ unobserve: (e) => t()?.unobserve(e)
308
+ };
309
+ })(), this.range = null, this.setOptions = (e) => {
310
+ Object.entries(e).forEach(([t, n]) => {
311
+ n === void 0 && delete e[t];
312
+ }), this.options = {
313
+ debug: !1,
314
+ initialOffset: 0,
315
+ overscan: 1,
316
+ paddingStart: 0,
317
+ paddingEnd: 0,
318
+ scrollPaddingStart: 0,
319
+ scrollPaddingEnd: 0,
320
+ horizontal: !1,
321
+ getItemKey: w,
322
+ rangeExtractor: T,
323
+ onChange: () => {},
324
+ measureElement: A,
325
+ initialRect: {
326
+ width: 0,
327
+ height: 0
328
+ },
329
+ scrollMargin: 0,
330
+ gap: 0,
331
+ indexAttribute: "data-index",
332
+ initialMeasurementsCache: [],
333
+ lanes: 1,
334
+ isScrollingResetDelay: 150,
335
+ enabled: !0,
336
+ isRtl: !1,
337
+ useScrollendEvent: !1,
338
+ useAnimationFrameWithResizeObserver: !1,
339
+ laneAssignmentMode: "estimate",
340
+ ...e
341
+ };
342
+ }, this.notify = (e) => {
343
+ var t, n;
344
+ (n = (t = this.options).onChange) == null || n.call(t, this, e);
345
+ }, this.maybeNotify = y(() => (this.calculateRange(), [
346
+ this.isScrolling,
347
+ this.range ? this.range.startIndex : null,
348
+ this.range ? this.range.endIndex : null
349
+ ]), (e) => {
350
+ this.notify(e);
351
+ }, {
352
+ key: process.env.NODE_ENV !== "production" && "maybeNotify",
353
+ debug: () => this.options.debug,
354
+ initialDeps: [
355
+ this.isScrolling,
356
+ this.range ? this.range.startIndex : null,
357
+ this.range ? this.range.endIndex : null
358
+ ]
359
+ }), this.cleanup = () => {
360
+ 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;
361
+ }, this._didMount = () => () => {
362
+ this.cleanup();
363
+ }, this._willUpdate = () => {
364
+ let e = this.options.enabled ? this.options.getScrollElement() : null;
365
+ if (this.scrollElement !== e) {
366
+ if (this.cleanup(), !e) {
367
+ this.maybeNotify();
368
+ return;
369
+ }
370
+ 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) => {
371
+ this.observer.observe(e);
372
+ }), this.unsubs.push(this.options.observeElementRect(this, (e) => {
373
+ this.scrollRect = e, this.maybeNotify();
374
+ })), this.unsubs.push(this.options.observeElementOffset(this, (e, t) => {
375
+ this.scrollAdjustments = 0, this.scrollDirection = t ? this.getScrollOffset() < e ? "forward" : "backward" : null, this.scrollOffset = e, this.isScrolling = t, this.scrollState && this.scheduleScrollReconcile(), this.maybeNotify();
376
+ })), this._scrollToOffset(this.getScrollOffset(), {
377
+ adjustments: void 0,
378
+ behavior: void 0
379
+ });
380
+ }
381
+ }, 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) => {
382
+ let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
383
+ for (let i = t - 1; i >= 0; i--) {
384
+ let t = e[i];
385
+ if (n.has(t.lane)) continue;
386
+ let a = r.get(t.lane);
387
+ 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;
388
+ }
389
+ 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;
390
+ }, this.getMeasurementOptions = y(() => [
391
+ this.options.count,
392
+ this.options.paddingStart,
393
+ this.options.scrollMargin,
394
+ this.options.getItemKey,
395
+ this.options.enabled,
396
+ this.options.lanes,
397
+ this.options.laneAssignmentMode
398
+ ], (e, t, n, r, i, a, o) => (this.prevLanes !== void 0 && this.prevLanes !== a && (this.lanesChangedFlag = !0), this.prevLanes = a, this.pendingMeasuredCacheIndexes = [], {
399
+ count: e,
400
+ paddingStart: t,
401
+ scrollMargin: n,
402
+ getItemKey: r,
403
+ enabled: i,
404
+ lanes: a,
405
+ laneAssignmentMode: o
406
+ }), { key: !1 }), this.getMeasurements = y(() => [this.getMeasurementOptions(), this.itemSizeCache], ({ count: e, paddingStart: t, scrollMargin: n, getItemKey: r, enabled: i, lanes: a, laneAssignmentMode: o }, s) => {
407
+ if (!i) return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
408
+ if (this.laneAssignments.size > e) for (let t of this.laneAssignments.keys()) t >= e && this.laneAssignments.delete(t);
409
+ 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) => {
410
+ this.itemSizeCache.set(e.key, e.size);
411
+ }));
412
+ let c = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
413
+ this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
414
+ let l = this.measurementsCache.slice(0, c), u = Array(a).fill(void 0);
415
+ for (let e = 0; e < c; e++) {
416
+ let t = l[e];
417
+ t && (u[t.lane] = e);
418
+ }
419
+ for (let i = c; i < e; i++) {
420
+ let e = r(i), a = this.laneAssignments.get(i), c, d, f = o === "estimate" || s.has(e);
421
+ if (a !== void 0 && this.options.lanes > 1) {
422
+ c = a;
423
+ let e = u[c], r = e === void 0 ? void 0 : l[e];
424
+ d = r ? r.end + this.options.gap : t + n;
425
+ } else {
426
+ let e = this.options.lanes === 1 ? l[i - 1] : this.getFurthestMeasurement(l, i);
427
+ 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);
428
+ }
429
+ let p = s.get(e), m = typeof p == "number" ? p : this.options.estimateSize(i), h = d + m;
430
+ l[i] = {
431
+ index: i,
432
+ start: d,
433
+ size: m,
434
+ end: h,
435
+ key: e,
436
+ lane: c
437
+ }, u[c] = i;
438
+ }
439
+ return this.measurementsCache = l, l;
440
+ }, {
441
+ key: process.env.NODE_ENV !== "production" && "getMeasurements",
442
+ debug: () => this.options.debug
443
+ }), this.calculateRange = y(() => [
444
+ this.getMeasurements(),
445
+ this.getSize(),
446
+ this.getScrollOffset(),
447
+ this.options.lanes
448
+ ], (e, t, n, r) => this.range = e.length > 0 && t > 0 ? P({
449
+ measurements: e,
450
+ outerSize: t,
451
+ scrollOffset: n,
452
+ lanes: r
453
+ }) : null, {
454
+ key: process.env.NODE_ENV !== "production" && "calculateRange",
455
+ debug: () => this.options.debug
456
+ }), this.getVirtualIndexes = y(() => {
457
+ let e = null, t = null, n = this.calculateRange();
458
+ return n && (e = n.startIndex, t = n.endIndex), this.maybeNotify.updateDeps([
459
+ this.isScrolling,
460
+ e,
461
+ t
462
+ ]), [
463
+ this.options.rangeExtractor,
464
+ this.options.overscan,
465
+ this.options.count,
466
+ e,
467
+ t
468
+ ];
469
+ }, (e, t, n, r, i) => r === null || i === null ? [] : e({
470
+ startIndex: r,
471
+ endIndex: i,
472
+ overscan: t,
473
+ count: n
474
+ }), {
475
+ key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
476
+ debug: () => this.options.debug
477
+ }), this.indexFromElement = (e) => {
478
+ let t = this.options.indexAttribute, n = e.getAttribute(t);
479
+ return n ? parseInt(n, 10) : (console.warn(`Missing attribute name '${t}={index}' on measured element.`), -1);
480
+ }, this.shouldMeasureDuringScroll = (e) => {
481
+ if (!this.scrollState || this.scrollState.behavior !== "smooth") return !0;
482
+ let t = this.scrollState.index ?? this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;
483
+ if (t !== void 0 && this.range) {
484
+ 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);
485
+ return e >= r && e <= i;
486
+ }
487
+ return !0;
488
+ }, this.measureElement = (e) => {
489
+ if (!e) {
490
+ this.elementsCache.forEach((e, t) => {
491
+ e.isConnected || (this.observer.unobserve(e), this.elementsCache.delete(t));
492
+ });
493
+ return;
494
+ }
495
+ let t = this.indexFromElement(e), n = this.options.getItemKey(t), r = this.elementsCache.get(n);
496
+ 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));
497
+ }, this.resizeItem = (e, t) => {
498
+ let n = this.measurementsCache[e];
499
+ if (!n) return;
500
+ let r = t - (this.itemSizeCache.get(n.key) ?? n.size);
501
+ 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(), {
502
+ adjustments: this.scrollAdjustments += r,
503
+ behavior: void 0
504
+ })), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, t)), this.notify(!1));
505
+ }, this.getVirtualItems = y(() => [this.getVirtualIndexes(), this.getMeasurements()], (e, t) => {
506
+ let n = [];
507
+ for (let r = 0, i = e.length; r < i; r++) {
508
+ let i = t[e[r]];
509
+ n.push(i);
510
+ }
511
+ return n;
512
+ }, {
513
+ key: process.env.NODE_ENV !== "production" && "getVirtualItems",
514
+ debug: () => this.options.debug
515
+ }), this.getVirtualItemForOffset = (e) => {
516
+ let t = this.getMeasurements();
517
+ if (t.length !== 0) return b(t[N(0, t.length - 1, (e) => b(t[e]).start, e)]);
518
+ }, this.getMaxScrollOffset = () => {
519
+ if (!this.scrollElement) return 0;
520
+ if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
521
+ {
522
+ let e = this.scrollElement.document.documentElement;
523
+ return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
524
+ }
525
+ }, this.getOffsetForAlignment = (e, t, n = 0) => {
526
+ if (!this.scrollElement) return 0;
527
+ let r = this.getSize(), i = this.getScrollOffset();
528
+ t === "auto" && (t = e >= i + r ? "end" : "start"), t === "center" ? e += (n - r) / 2 : t === "end" && (e -= r);
529
+ let a = this.getMaxScrollOffset();
530
+ return Math.max(Math.min(a, e), 0);
531
+ }, this.getOffsetForIndex = (e, t = "auto") => {
532
+ e = Math.max(0, Math.min(e, this.options.count - 1));
533
+ let n = this.getSize(), r = this.getScrollOffset(), i = this.measurementsCache[e];
534
+ if (!i) return;
535
+ if (t === "auto") if (i.end >= r + n - this.options.scrollPaddingEnd) t = "end";
536
+ else if (i.start <= r + this.options.scrollPaddingStart) t = "start";
537
+ else return [r, t];
538
+ if (t === "end" && e === this.options.count - 1) return [this.getMaxScrollOffset(), t];
539
+ let a = t === "end" ? i.end + this.options.scrollPaddingEnd : i.start - this.options.scrollPaddingStart;
540
+ return [this.getOffsetForAlignment(a, t, i.size), t];
541
+ }, this.scrollToOffset = (e, { align: t = "start", behavior: n = "auto" } = {}) => {
542
+ let r = this.getOffsetForAlignment(e, t), i = this.now();
543
+ this.scrollState = {
544
+ index: null,
545
+ align: t,
546
+ behavior: n,
547
+ startedAt: i,
548
+ lastTargetOffset: r,
549
+ stableFrames: 0
550
+ }, this._scrollToOffset(r, {
551
+ adjustments: void 0,
552
+ behavior: n
553
+ }), this.scheduleScrollReconcile();
554
+ }, this.scrollToIndex = (e, { align: t = "auto", behavior: n = "auto" } = {}) => {
555
+ e = Math.max(0, Math.min(e, this.options.count - 1));
556
+ let r = this.getOffsetForIndex(e, t);
557
+ if (!r) return;
558
+ let [i, a] = r, o = this.now();
559
+ this.scrollState = {
560
+ index: e,
561
+ align: a,
562
+ behavior: n,
563
+ startedAt: o,
564
+ lastTargetOffset: i,
565
+ stableFrames: 0
566
+ }, this._scrollToOffset(i, {
567
+ adjustments: void 0,
568
+ behavior: n
569
+ }), this.scheduleScrollReconcile();
570
+ }, this.scrollBy = (e, { behavior: t = "auto" } = {}) => {
571
+ let n = this.getScrollOffset() + e, r = this.now();
572
+ this.scrollState = {
573
+ index: null,
574
+ align: "start",
575
+ behavior: t,
576
+ startedAt: r,
577
+ lastTargetOffset: n,
578
+ stableFrames: 0
579
+ }, this._scrollToOffset(n, {
580
+ adjustments: void 0,
581
+ behavior: t
582
+ }), this.scheduleScrollReconcile();
583
+ }, this.getTotalSize = () => {
584
+ let e = this.getMeasurements(), t;
585
+ if (e.length === 0) t = this.options.paddingStart;
586
+ else if (this.options.lanes === 1) t = e[e.length - 1]?.end ?? 0;
587
+ else {
588
+ let n = Array(this.options.lanes).fill(null), r = e.length - 1;
589
+ for (; r >= 0 && n.some((e) => e === null);) {
590
+ let t = e[r];
591
+ n[t.lane] === null && (n[t.lane] = t.end), r--;
592
+ }
593
+ t = Math.max(...n.filter((e) => e !== null));
594
+ }
595
+ return Math.max(t - this.options.scrollMargin + this.options.paddingEnd, 0);
596
+ }, this._scrollToOffset = (e, { adjustments: t, behavior: n }) => {
597
+ this.options.scrollToFn(e, {
598
+ behavior: n,
599
+ adjustments: t
600
+ }, this);
601
+ }, this.measure = () => {
602
+ this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
603
+ }, this.setOptions(e);
604
+ }
605
+ scheduleScrollReconcile() {
606
+ if (!this.targetWindow) {
607
+ this.scrollState = null;
608
+ return;
609
+ }
610
+ this.rafId ??= this.targetWindow.requestAnimationFrame(() => {
611
+ this.rafId = null, this.reconcileScroll();
612
+ });
613
+ }
614
+ reconcileScroll() {
615
+ if (!this.scrollState || !this.scrollElement) return;
616
+ if (this.now() - this.scrollState.startedAt > 5e3) {
617
+ this.scrollState = null;
618
+ return;
619
+ }
620
+ 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;
621
+ if (!n && x(t, this.getScrollOffset())) {
622
+ if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= 1) {
623
+ this.scrollState = null;
624
+ return;
625
+ }
626
+ } else this.scrollState.stableFrames = 0, n && (this.scrollState.lastTargetOffset = t, this.scrollState.behavior = "auto", this._scrollToOffset(t, {
627
+ adjustments: void 0,
628
+ behavior: "auto"
629
+ }));
630
+ this.scheduleScrollReconcile();
631
+ }
632
+ }, N = (e, t, n, r) => {
633
+ for (; e <= t;) {
634
+ let i = (e + t) / 2 | 0, a = n(i);
635
+ if (a < r) e = i + 1;
636
+ else if (a > r) t = i - 1;
637
+ else return i;
638
+ }
639
+ return e > 0 ? e - 1 : 0;
1818
640
  };
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
- });
641
+ function P({ measurements: e, outerSize: t, scrollOffset: n, lanes: r }) {
642
+ let i = e.length - 1, a = (t) => e[t].start;
643
+ if (e.length <= r) return {
644
+ startIndex: 0,
645
+ endIndex: i
646
+ };
647
+ let o = N(0, i, a, n), s = o;
648
+ if (r === 1) for (; s < i && e[s].end < n + t;) s++;
649
+ else if (r > 1) {
650
+ let a = Array(r).fill(0);
651
+ for (; s < i && a.some((e) => e < n + t);) {
652
+ let t = e[s];
653
+ a[t.lane] = t.end, s++;
654
+ }
655
+ let c = Array(r).fill(n + t);
656
+ for (; o >= 0 && c.some((e) => e >= n);) {
657
+ let t = e[o];
658
+ c[t.lane] = t.start, o--;
659
+ }
660
+ o = Math.max(0, o - o % r), s = Math.min(i, s + (r - 1 - s % r));
661
+ }
662
+ return {
663
+ startIndex: o,
664
+ endIndex: s
665
+ };
666
+ }
667
+ //#endregion
668
+ //#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
669
+ var F = typeof document < "u" ? e.useLayoutEffect : e.useEffect;
670
+ function I({ useFlushSync: t = !0, ...n }) {
671
+ let r = e.useReducer(() => ({}), {})[1], i = {
672
+ ...n,
673
+ onChange: (e, i) => {
674
+ var a;
675
+ t && i ? l(r) : r(), (a = n.onChange) == null || a.call(n, e, i);
676
+ }
677
+ }, [a] = e.useState(() => new M(i));
678
+ return a.setOptions(i), F(() => a._didMount(), []), F(() => a._willUpdate()), a;
1875
679
  }
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
- );
680
+ function L(e) {
681
+ return I({
682
+ observeElementRect: E,
683
+ observeElementOffset: k,
684
+ scrollToFn: j,
685
+ ...e
686
+ });
687
+ }
688
+ //#endregion
689
+ //#region packages/icons/chevron-up.tsx
690
+ function R(e) {
691
+ return /* @__PURE__ */ s("svg", {
692
+ xmlns: "http://www.w3.org/2000/svg",
693
+ fill: "none",
694
+ viewBox: "0 0 24 24",
695
+ strokeWidth: 1.5,
696
+ stroke: "currentColor",
697
+ className: "h-6 w-6",
698
+ ...e,
699
+ children: /* @__PURE__ */ s("path", {
700
+ strokeLinecap: "round",
701
+ strokeLinejoin: "round",
702
+ d: "m19.5 8.25-7.5 7.5-7.5-7.5"
703
+ })
704
+ });
705
+ }
706
+ //#endregion
707
+ //#region packages/icons/search.tsx
708
+ function z(e) {
709
+ return /* @__PURE__ */ s("svg", {
710
+ xmlns: "http://www.w3.org/2000/svg",
711
+ fill: "none",
712
+ viewBox: "0 0 24 24",
713
+ strokeWidth: 1.5,
714
+ stroke: "currentColor",
715
+ className: "h-6 w-6",
716
+ ...e,
717
+ children: /* @__PURE__ */ s("path", {
718
+ strokeLinecap: "round",
719
+ strokeLinejoin: "round",
720
+ 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"
721
+ })
722
+ });
723
+ }
724
+ //#endregion
725
+ //#region packages/icons/x-mark.tsx
726
+ function B(e) {
727
+ return /* @__PURE__ */ s("svg", {
728
+ xmlns: "http://www.w3.org/2000/svg",
729
+ fill: "none",
730
+ viewBox: "0 0 24 24",
731
+ strokeWidth: 1.5,
732
+ stroke: "currentColor",
733
+ className: "h-6 w-6",
734
+ ...e,
735
+ children: /* @__PURE__ */ s("path", {
736
+ strokeLinecap: "round",
737
+ strokeLinejoin: "round",
738
+ d: "M6 18 18 6M6 6l12 12"
739
+ })
740
+ });
741
+ }
742
+ //#endregion
743
+ //#region packages/dropdown/index.tsx
744
+ function V(e) {
745
+ let { items: t, selected: r, className: o, onChange: l, disabled: d, placeholder: f = "Select an Item", multiple: m, mutable: g, onAdd: y } = e, b = i(null), [x, S] = a(!1);
746
+ return i(null), n(), /* @__PURE__ */ s(_, {
747
+ content: /* @__PURE__ */ s(H, {
748
+ ...g ? {
749
+ mutable: g,
750
+ onAdd: y
751
+ } : { mutable: g },
752
+ ...m ? {
753
+ multiple: m,
754
+ items: t,
755
+ onChange: l,
756
+ selected: r
757
+ } : {
758
+ items: t,
759
+ onChange: l,
760
+ selected: r
761
+ }
762
+ }),
763
+ children: /* @__PURE__ */ c("div", {
764
+ className: u("border-input bg-background inline-flex h-10 w-56 grow items-center justify-between rounded border-2 p-2 transition", d ? "bg-muted text-muted cursor-not-allowed" : "cursor-pointer", x && "border-primary", o),
765
+ children: [/* @__PURE__ */ s("div", {
766
+ className: u("flex max-w-[calc(100%-30px)] flex-none grow items-center gap-1 text-sm", d ? "text-muted-foreground" : "text-foreground"),
767
+ ref: b,
768
+ children: m ? /* @__PURE__ */ s(v, {
769
+ items: r.map((e) => e.text),
770
+ data: r,
771
+ parentRef: b,
772
+ estimator: (e, t) => t + 40,
773
+ badgeVariant: "secondary",
774
+ badgeStyles: "bg-input! h-6 min-w-min gap-2 bg-input!",
775
+ children: (e, t, n) => /* @__PURE__ */ c(p, {
776
+ className: "bg-input! flex h-6 min-w-min gap-2 pr-1",
777
+ variant: "secondary",
778
+ children: [e, /* @__PURE__ */ s(h, {
779
+ onClick: () => {
780
+ l(r.filter((e) => e.key !== n?.key));
781
+ },
782
+ variant: "icon",
783
+ size: "icon",
784
+ className: "group bg-muted hover:bg-muted-foreground p-0.5",
785
+ children: /* @__PURE__ */ s(B, { className: "group-hover:text-muted size-3 transition duration-300 group-hover:rotate-90" })
786
+ })]
787
+ }, `collapsed_item_${n?.key ?? t}`)
788
+ }) : r.text ?? f
789
+ }), /* @__PURE__ */ s(R, { className: u("bg-input size-4 rounded-full p-0.5 transition duration-300 ease-in-out", x ? "rotate-180" : "rotate-0", d ? "text-muted-foreground" : "text-foreground") })]
790
+ })
791
+ });
2186
792
  }
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
- };
793
+ function H(e) {
794
+ 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({
795
+ count: g.length,
796
+ getScrollElement: () => h.current,
797
+ estimateSize: () => 35
798
+ }), v = o instanceof Array ? o.map((e) => e.key) : [o.key];
799
+ return /* @__PURE__ */ c("div", {
800
+ className: "divide-border border-input bg-background w-full flex-col divide-y-2 overflow-hidden rounded border",
801
+ children: [/* @__PURE__ */ c("div", {
802
+ className: u("flex grow items-center rounded px-3 py-2"),
803
+ children: [/* @__PURE__ */ s(z, { className: "text-muted-foreground top-3 left-3 mr-2 size-4" }), /* @__PURE__ */ s("input", {
804
+ className: "text-foreground inline-flex grow bg-transparent text-sm outline-hidden",
805
+ placeholder: "Search",
806
+ value: p,
807
+ onChange: (e) => m(e.target.value)
808
+ })]
809
+ }), /* @__PURE__ */ c("ul", {
810
+ className: u("max-h-60 grow overflow-auto shadow-sm", "focus:ring-0 focus:outline-hidden"),
811
+ ref: h,
812
+ children: [/* @__PURE__ */ s("div", {
813
+ style: {
814
+ height: `${_.getTotalSize()}px`,
815
+ width: "100%",
816
+ position: "relative"
817
+ },
818
+ children: _.getVirtualItems().map((e) => /* @__PURE__ */ s("li", {
819
+ style: {
820
+ height: `${e.size}px`,
821
+ transform: `translateY(${e.start}px)`
822
+ },
823
+ 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"),
824
+ onClick: () => {
825
+ 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]);
826
+ },
827
+ children: g[e.index].text
828
+ }, e.key))
829
+ }), p.length > 0 && g.length === 0 && (d ? /* @__PURE__ */ c("li", {
830
+ className: u("text-foreground px-3 py-2 text-sm"),
831
+ onClick: () => {
832
+ f({
833
+ text: p,
834
+ key: p
835
+ }), m("");
836
+ },
837
+ children: ["Add ", p]
838
+ }) : /* @__PURE__ */ s("li", {
839
+ className: u("text-foreground cursor-not-allowed px-3 py-2 text-sm"),
840
+ children: "No results found"
841
+ }))]
842
+ })]
843
+ });
844
+ }
845
+ //#endregion
846
+ //#region packages/icons/chevron-down.tsx
847
+ function U(e) {
848
+ return /* @__PURE__ */ s("svg", {
849
+ xmlns: "http://www.w3.org/2000/svg",
850
+ fill: "none",
851
+ viewBox: "0 0 24 24",
852
+ strokeWidth: 1.5,
853
+ stroke: "currentColor",
854
+ className: "h-6 w-6",
855
+ ...e,
856
+ children: /* @__PURE__ */ s("path", {
857
+ strokeLinecap: "round",
858
+ strokeLinejoin: "round",
859
+ d: "m4.5 15.75 7.5-7.5 7.5 7.5"
860
+ })
861
+ });
862
+ }
863
+ //#endregion
864
+ //#region packages/input/index.tsx
865
+ function W(e) {
866
+ let { className: t, ...n } = e;
867
+ return /* @__PURE__ */ s("input", {
868
+ className: u("border-input bg-background text-foreground h-10 w-full rounded border-2 px-3 py-2 text-sm transition", "focus-visible:border-primary focus-visible:shadow-ring focus-visible:outline-hidden", "active:border-primary active:shadow-ring active:outline-hidden", "read-only:text-foreground read-only:cursor-pointer read-only:border-none! read-only:bg-transparent read-only:shadow-none! read-only:outline-hidden!", "disabled:bg-muted disabled:text-muted 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),
869
+ ...n
870
+ });
871
+ }
872
+ //#endregion
873
+ //#region packages/textarea/index.tsx
874
+ function G(e) {
875
+ let { className: t, ...n } = e;
876
+ return /* @__PURE__ */ s("textarea", {
877
+ className: u("border-input bg-background text-foreground h-30 w-full rounded border-2 px-3 py-2 text-sm transition", "focus-visible:border-primary focus-visible:shadow-ring focus-visible:shadow-xs focus-visible:outline-hidden", "read-only:text-foreground read-only:cursor-pointer read-only:border-none! read-only:bg-transparent read-only:shadow-none! read-only:outline-hidden!", "disabled:bg-muted disabled:text-muted disabled:cursor-not-allowed", "file:border-0 file:bg-transparent file:text-sm file:font-medium", t),
878
+ ...n
879
+ });
880
+ }
881
+ //#endregion
882
+ //#region packages/toggle/index.tsx
883
+ function K(e) {
884
+ let { className: t, checked: n, onChange: r, defaultChecked: i, ...a } = e;
885
+ return /* @__PURE__ */ c("div", {
886
+ className: u("rounded-full", "h-5 w-10", "border-primary dark:bg-primary-foreground bg-secondary border", "flex items-center", t),
887
+ onClick: () => r?.(!n),
888
+ children: [/* @__PURE__ */ s("input", {
889
+ type: "hidden",
890
+ ...a,
891
+ readOnly: !0,
892
+ className: "peer/toggle",
893
+ defaultChecked: i,
894
+ checked: n
895
+ }), /* @__PURE__ */ s("div", { className: u("[animation-timing-function:cubic-bezier(1, 0, 0, 1)] bg-primary size-4 rounded-full transition-all duration-250", n ? "translate-x-5" : "translate-x-0.5") })]
896
+ });
897
+ }
898
+ //#endregion
899
+ 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 };