@szum-tech/design-system 3.12.3 → 3.14.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 (94) hide show
  1. package/dist/chunk-4IGU5SVP.js +54 -0
  2. package/dist/{chunk-XJZOANXX.cjs → chunk-6HX7ETL3.cjs} +1 -1
  3. package/dist/chunk-7OD2NBSV.cjs +50 -0
  4. package/dist/chunk-B4M7Q5KX.cjs +25 -0
  5. package/dist/{chunk-S2BCU6WG.cjs → chunk-CAIAZGSW.cjs} +5 -4
  6. package/dist/chunk-EOTQVIA5.js +993 -0
  7. package/dist/chunk-EZCWHR56.cjs +2355 -0
  8. package/dist/chunk-G24PWQKG.js +20 -0
  9. package/dist/chunk-GEDBA3JU.cjs +49 -0
  10. package/dist/chunk-IZU3KULT.js +41 -0
  11. package/dist/{chunk-KQ6QE7BT.cjs → chunk-MNDQXDV4.cjs} +4 -4
  12. package/dist/chunk-N4TYSZSU.cjs +44 -0
  13. package/dist/chunk-OZSNSRLV.cjs +1027 -0
  14. package/dist/{chunk-DL54DIMD.js → chunk-Q2MJKFIE.js} +2 -1
  15. package/dist/chunk-S3ZUFD6U.js +23 -0
  16. package/dist/{chunk-WXZE35FK.js → chunk-VK2FJ65F.js} +1 -1
  17. package/dist/chunk-VL3TPVSB.js +2299 -0
  18. package/dist/chunk-X5O7GP4S.js +48 -0
  19. package/dist/{chunk-E5TYGWGE.js → chunk-XKCLVPUC.js} +1 -1
  20. package/dist/{chunk-XIQUR62A.cjs → chunk-XY3ZNUWR.cjs} +32 -20
  21. package/dist/color-picker.types-GI7dq2Ig.d.cts +42 -0
  22. package/dist/color-picker.types-GI7dq2Ig.d.ts +42 -0
  23. package/dist/components/badge-overflow/index.cjs +3 -2
  24. package/dist/components/badge-overflow/index.js +2 -1
  25. package/dist/components/button/index.cjs +16 -12
  26. package/dist/components/button/index.d.cts +1 -0
  27. package/dist/components/button/index.d.ts +1 -0
  28. package/dist/components/button/index.js +15 -11
  29. package/dist/components/carousel/index.cjs +17 -13
  30. package/dist/components/carousel/index.d.cts +1 -0
  31. package/dist/components/carousel/index.d.ts +1 -0
  32. package/dist/components/carousel/index.js +15 -11
  33. package/dist/components/color-picker/index.cjs +88 -0
  34. package/dist/components/color-picker/index.d.cts +71 -0
  35. package/dist/components/color-picker/index.d.ts +71 -0
  36. package/dist/components/color-picker/index.js +39 -0
  37. package/dist/components/dialog/index.d.cts +1 -0
  38. package/dist/components/dialog/index.d.ts +1 -0
  39. package/dist/components/file-upload/index.cjs +60 -0
  40. package/dist/components/file-upload/index.d.cts +131 -0
  41. package/dist/components/file-upload/index.d.ts +131 -0
  42. package/dist/components/file-upload/index.js +3 -0
  43. package/dist/components/index.cjs +216 -84
  44. package/dist/components/index.d.cts +8 -1
  45. package/dist/components/index.d.ts +8 -1
  46. package/dist/components/index.js +15 -11
  47. package/dist/components/input/index.cjs +2 -2
  48. package/dist/components/input/index.js +1 -1
  49. package/dist/components/item/index.d.cts +1 -0
  50. package/dist/components/item/index.d.ts +1 -0
  51. package/dist/components/masonry/index.cjs +5 -4
  52. package/dist/components/masonry/index.js +3 -2
  53. package/dist/components/popover/index.cjs +35 -0
  54. package/dist/components/popover/index.d.cts +18 -0
  55. package/dist/components/popover/index.d.ts +18 -0
  56. package/dist/components/popover/index.js +2 -0
  57. package/dist/components/select/index.cjs +7 -7
  58. package/dist/components/select/index.d.cts +8 -14
  59. package/dist/components/select/index.d.ts +8 -14
  60. package/dist/components/select/index.js +1 -1
  61. package/dist/components/sheet/index.d.cts +2 -1
  62. package/dist/components/sheet/index.d.ts +2 -1
  63. package/dist/components/stepper/index.cjs +34 -30
  64. package/dist/components/stepper/index.d.cts +1 -0
  65. package/dist/components/stepper/index.d.ts +1 -0
  66. package/dist/components/stepper/index.js +15 -11
  67. package/dist/components/switch/index.cjs +11 -0
  68. package/dist/components/switch/index.d.cts +19 -0
  69. package/dist/components/switch/index.d.ts +19 -0
  70. package/dist/components/switch/index.js +2 -0
  71. package/dist/components/timeline/index.cjs +12 -11
  72. package/dist/components/timeline/index.d.cts +1 -0
  73. package/dist/components/timeline/index.d.ts +1 -0
  74. package/dist/components/timeline/index.js +3 -2
  75. package/dist/components/toaster/index.cjs +17 -13
  76. package/dist/components/toaster/index.js +15 -11
  77. package/dist/components/typing-text/index.d.cts +1 -0
  78. package/dist/components/typing-text/index.d.ts +1 -0
  79. package/dist/components/word-rotate/index.d.cts +1 -0
  80. package/dist/components/word-rotate/index.d.ts +1 -0
  81. package/dist/hooks/index.cjs +17 -8
  82. package/dist/hooks/index.d.cts +15 -4
  83. package/dist/hooks/index.d.ts +15 -4
  84. package/dist/hooks/index.js +2 -1
  85. package/dist/popover-trigger-Cf4PPj0z.d.cts +14 -0
  86. package/dist/popover-trigger-Cf4PPj0z.d.ts +14 -0
  87. package/dist/select-Bf6XQtt-.d.cts +12 -0
  88. package/dist/select-Bf6XQtt-.d.ts +12 -0
  89. package/package.json +1 -1
  90. package/dist/chunk-5AA4IE2T.cjs +0 -27
  91. package/dist/chunk-CP43WJCN.cjs +0 -1065
  92. package/dist/chunk-QTYNFISP.js +0 -1020
  93. package/dist/chunk-SB5UG7OC.js +0 -41
  94. package/dist/chunk-UGSNASZM.js +0 -25
@@ -0,0 +1,2355 @@
1
+ 'use strict';
2
+
3
+ var chunkB4M7Q5KX_cjs = require('./chunk-B4M7Q5KX.cjs');
4
+ var chunk3WSQRFUY_cjs = require('./chunk-3WSQRFUY.cjs');
5
+ var chunkMNDQXDV4_cjs = require('./chunk-MNDQXDV4.cjs');
6
+ var chunkGEDBA3JU_cjs = require('./chunk-GEDBA3JU.cjs');
7
+ var chunk6HX7ETL3_cjs = require('./chunk-6HX7ETL3.cjs');
8
+ var chunkXY3ZNUWR_cjs = require('./chunk-XY3ZNUWR.cjs');
9
+ var chunkN4TYSZSU_cjs = require('./chunk-N4TYSZSU.cjs');
10
+ var chunkH2BWO3SI_cjs = require('./chunk-H2BWO3SI.cjs');
11
+ var React16 = require('react');
12
+ var reactSlot = require('@radix-ui/react-slot');
13
+ var radixUi = require('radix-ui');
14
+ var jsxRuntime = require('react/jsx-runtime');
15
+ var lucideReact = require('lucide-react');
16
+ var classVarianceAuthority = require('class-variance-authority');
17
+ var sonner = require('sonner');
18
+
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n.default = e;
34
+ return Object.freeze(n);
35
+ }
36
+
37
+ var React16__namespace = /*#__PURE__*/_interopNamespace(React16);
38
+
39
+ function VisuallyHiddenInput(props) {
40
+ const { control, value, checked, bubbles = true, type = "hidden", style, ...inputProps } = props;
41
+ const isCheckInput = React16__namespace.useMemo(() => type === "checkbox" || type === "radio" || type === "switch", [type]);
42
+ const inputRef = React16__namespace.useRef(null);
43
+ const prevValueRef = React16__namespace.useRef({
44
+ value: isCheckInput ? checked : value,
45
+ previous: isCheckInput ? checked : value
46
+ });
47
+ const prevValue = React16__namespace.useMemo(() => {
48
+ const currentValue = isCheckInput ? checked : value;
49
+ if (prevValueRef.current.value !== currentValue) {
50
+ prevValueRef.current.previous = prevValueRef.current.value;
51
+ prevValueRef.current.value = currentValue;
52
+ }
53
+ return prevValueRef.current.previous;
54
+ }, [isCheckInput, value, checked]);
55
+ const [controlSize, setControlSize] = React16__namespace.useState({});
56
+ React16__namespace.useLayoutEffect(() => {
57
+ if (!control) {
58
+ setControlSize({});
59
+ return;
60
+ }
61
+ setControlSize({
62
+ width: control.offsetWidth,
63
+ height: control.offsetHeight
64
+ });
65
+ if (typeof window === "undefined") return;
66
+ const resizeObserver = new ResizeObserver((entries) => {
67
+ if (!Array.isArray(entries) || !entries.length) return;
68
+ const entry = entries[0];
69
+ if (!entry) return;
70
+ let width;
71
+ let height;
72
+ if ("borderBoxSize" in entry) {
73
+ const borderSizeEntry = entry.borderBoxSize;
74
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
75
+ width = borderSize.inlineSize;
76
+ height = borderSize.blockSize;
77
+ } else {
78
+ width = control.offsetWidth;
79
+ height = control.offsetHeight;
80
+ }
81
+ setControlSize({ width, height });
82
+ });
83
+ resizeObserver.observe(control, { box: "border-box" });
84
+ return () => {
85
+ resizeObserver.disconnect();
86
+ };
87
+ }, [control]);
88
+ React16__namespace.useEffect(() => {
89
+ const input = inputRef.current;
90
+ if (!input) return;
91
+ const inputProto = window.HTMLInputElement.prototype;
92
+ const propertyKey = isCheckInput ? "checked" : "value";
93
+ const eventType = isCheckInput ? "click" : "input";
94
+ const currentValue = isCheckInput ? checked : value;
95
+ const serializedCurrentValue = isCheckInput ? checked : typeof value === "object" && value !== null ? JSON.stringify(value) : value;
96
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, propertyKey);
97
+ const setter = descriptor?.set;
98
+ if (prevValue !== currentValue && setter) {
99
+ const event = new Event(eventType, { bubbles });
100
+ setter.call(input, serializedCurrentValue);
101
+ input.dispatchEvent(event);
102
+ }
103
+ }, [prevValue, value, checked, bubbles, isCheckInput]);
104
+ const composedStyle = React16__namespace.useMemo(() => {
105
+ return {
106
+ ...style,
107
+ ...controlSize.width !== void 0 && controlSize.height !== void 0 ? controlSize : {},
108
+ border: 0,
109
+ clip: "rect(0 0 0 0)",
110
+ clipPath: "inset(50%)",
111
+ height: "1px",
112
+ margin: "-1px",
113
+ overflow: "hidden",
114
+ padding: 0,
115
+ position: "absolute",
116
+ whiteSpace: "nowrap",
117
+ width: "1px"
118
+ };
119
+ }, [style, controlSize]);
120
+ return /* @__PURE__ */ jsxRuntime.jsx(
121
+ "input",
122
+ {
123
+ type,
124
+ ...inputProps,
125
+ ref: inputRef,
126
+ "aria-hidden": isCheckInput,
127
+ tabIndex: -1,
128
+ defaultChecked: isCheckInput ? checked : void 0,
129
+ style: composedStyle
130
+ }
131
+ );
132
+ }
133
+
134
+ // src/components/color-picker/color-picker.constants.ts
135
+ var COLOR_PICKER_ROOT_NAME = "ColorPicker";
136
+ var COLOR_PICKER_IMPL_NAME = "ColorPickerImpl";
137
+ var COLOR_PICKER_TRIGGER_NAME = "ColorPickerTrigger";
138
+ var COLOR_PICKER_CONTENT_NAME = "ColorPickerContent";
139
+ var COLOR_PICKER_AREA_NAME = "ColorPickerArea";
140
+ var COLOR_PICKER_HUE_SLIDER_NAME = "ColorPickerHueSlider";
141
+ var COLOR_PICKER_ALPHA_SLIDER_NAME = "ColorPickerAlphaSlider";
142
+ var COLOR_PICKER_SWATCH_NAME = "ColorPickerSwatch";
143
+ var COLOR_PICKER_EYE_DROPPER_NAME = "ColorPickerEyeDropper";
144
+ var COLOR_PICKER_FORMAT_SELECT_NAME = "ColorPickerFormatSelect";
145
+ var COLOR_PICKER_INPUT_NAME = "ColorPickerInput";
146
+ var COLOR_FORMATS = ["hex", "rgb", "hsl", "hsb"];
147
+ var ColorPickerContext = React16__namespace.createContext(null);
148
+ function useColorPickerContext(consumerName) {
149
+ const context = React16__namespace.useContext(ColorPickerContext);
150
+ if (!context) {
151
+ throw new Error(`\`${consumerName}\` must be used within \`${COLOR_PICKER_ROOT_NAME}\``);
152
+ }
153
+ return context;
154
+ }
155
+
156
+ // src/components/color-picker/color-picker.utils.ts
157
+ function hexToRgb(hex, alpha) {
158
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
159
+ return result ? {
160
+ r: Number.parseInt(result[1] ?? "0", 16),
161
+ g: Number.parseInt(result[2] ?? "0", 16),
162
+ b: Number.parseInt(result[3] ?? "0", 16),
163
+ a: alpha ?? 1
164
+ } : { r: 0, g: 0, b: 0, a: alpha ?? 1 };
165
+ }
166
+ function rgbToHex(color) {
167
+ const toHex = (n) => {
168
+ const hex = Math.round(n).toString(16);
169
+ return hex.length === 1 ? `0${hex}` : hex;
170
+ };
171
+ return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`;
172
+ }
173
+ function rgbToHsv(color) {
174
+ const r = color.r / 255;
175
+ const g = color.g / 255;
176
+ const b = color.b / 255;
177
+ const max = Math.max(r, g, b);
178
+ const min = Math.min(r, g, b);
179
+ const diff = max - min;
180
+ let h = 0;
181
+ if (diff !== 0) {
182
+ switch (max) {
183
+ case r:
184
+ h = (g - b) / diff % 6;
185
+ break;
186
+ case g:
187
+ h = (b - r) / diff + 2;
188
+ break;
189
+ case b:
190
+ h = (r - g) / diff + 4;
191
+ break;
192
+ }
193
+ }
194
+ h = Math.round(h * 60);
195
+ if (h < 0) h += 360;
196
+ const s = max === 0 ? 0 : diff / max;
197
+ return {
198
+ h,
199
+ s: Math.round(s * 100),
200
+ v: Math.round(max * 100),
201
+ a: color.a
202
+ };
203
+ }
204
+ function hsvToRgb(hsv) {
205
+ const h = hsv.h / 360;
206
+ const s = hsv.s / 100;
207
+ const v = hsv.v / 100;
208
+ const i = Math.floor(h * 6);
209
+ const f = h * 6 - i;
210
+ const p = v * (1 - s);
211
+ const q = v * (1 - f * s);
212
+ const t = v * (1 - (1 - f) * s);
213
+ let r;
214
+ let g;
215
+ let b;
216
+ switch (i % 6) {
217
+ case 0: {
218
+ r = v;
219
+ g = t;
220
+ b = p;
221
+ break;
222
+ }
223
+ case 1: {
224
+ r = q;
225
+ g = v;
226
+ b = p;
227
+ break;
228
+ }
229
+ case 2: {
230
+ r = p;
231
+ g = v;
232
+ b = t;
233
+ break;
234
+ }
235
+ case 3: {
236
+ r = p;
237
+ g = q;
238
+ b = v;
239
+ break;
240
+ }
241
+ case 4: {
242
+ r = t;
243
+ g = p;
244
+ b = v;
245
+ break;
246
+ }
247
+ case 5: {
248
+ r = v;
249
+ g = p;
250
+ b = q;
251
+ break;
252
+ }
253
+ default: {
254
+ r = 0;
255
+ g = 0;
256
+ b = 0;
257
+ }
258
+ }
259
+ return {
260
+ r: Math.round(r * 255),
261
+ g: Math.round(g * 255),
262
+ b: Math.round(b * 255),
263
+ a: hsv.a
264
+ };
265
+ }
266
+ function rgbToHsl(color) {
267
+ const r = color.r / 255;
268
+ const g = color.g / 255;
269
+ const b = color.b / 255;
270
+ const max = Math.max(r, g, b);
271
+ const min = Math.min(r, g, b);
272
+ const diff = max - min;
273
+ const sum = max + min;
274
+ const l = sum / 2;
275
+ let h = 0;
276
+ let s = 0;
277
+ if (diff !== 0) {
278
+ s = l > 0.5 ? diff / (2 - sum) : diff / sum;
279
+ if (max === r) {
280
+ h = (g - b) / diff + (g < b ? 6 : 0);
281
+ } else if (max === g) {
282
+ h = (b - r) / diff + 2;
283
+ } else if (max === b) {
284
+ h = (r - g) / diff + 4;
285
+ }
286
+ h /= 6;
287
+ }
288
+ return {
289
+ h: Math.round(h * 360),
290
+ s: Math.round(s * 100),
291
+ l: Math.round(l * 100)
292
+ };
293
+ }
294
+ function hslToRgb(hsl, alpha = 1) {
295
+ const h = hsl.h / 360;
296
+ const s = hsl.s / 100;
297
+ const l = hsl.l / 100;
298
+ const c = (1 - Math.abs(2 * l - 1)) * s;
299
+ const x = c * (1 - Math.abs(h * 6 % 2 - 1));
300
+ const m = l - c / 2;
301
+ let r = 0;
302
+ let g = 0;
303
+ let b = 0;
304
+ if (h >= 0 && h < 1 / 6) {
305
+ r = c;
306
+ g = x;
307
+ b = 0;
308
+ } else if (h >= 1 / 6 && h < 2 / 6) {
309
+ r = x;
310
+ g = c;
311
+ b = 0;
312
+ } else if (h >= 2 / 6 && h < 3 / 6) {
313
+ r = 0;
314
+ g = c;
315
+ b = x;
316
+ } else if (h >= 3 / 6 && h < 4 / 6) {
317
+ r = 0;
318
+ g = x;
319
+ b = c;
320
+ } else if (h >= 4 / 6 && h < 5 / 6) {
321
+ r = x;
322
+ g = 0;
323
+ b = c;
324
+ } else if (h >= 5 / 6 && h < 1) {
325
+ r = c;
326
+ g = 0;
327
+ b = x;
328
+ }
329
+ return {
330
+ r: Math.round((r + m) * 255),
331
+ g: Math.round((g + m) * 255),
332
+ b: Math.round((b + m) * 255),
333
+ a: alpha
334
+ };
335
+ }
336
+ function colorToString(color, format = "hex") {
337
+ switch (format) {
338
+ case "hex":
339
+ return rgbToHex(color);
340
+ case "rgb":
341
+ return color.a < 1 ? `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a})` : `rgb(${color.r}, ${color.g}, ${color.b})`;
342
+ case "hsl": {
343
+ const hsl = rgbToHsl(color);
344
+ return color.a < 1 ? `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${color.a})` : `hsl(${hsl.h}, ${hsl.s}%, ${hsl.l}%)`;
345
+ }
346
+ case "hsb": {
347
+ const hsv = rgbToHsv(color);
348
+ return color.a < 1 ? `hsba(${hsv.h}, ${hsv.s}%, ${hsv.v}%, ${color.a})` : `hsb(${hsv.h}, ${hsv.s}%, ${hsv.v}%)`;
349
+ }
350
+ default:
351
+ return rgbToHex(color);
352
+ }
353
+ }
354
+ function parseColorString(value) {
355
+ const trimmed = value.trim();
356
+ if (trimmed.startsWith("#")) {
357
+ const hexMatch = trimmed.match(/^#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})$/);
358
+ if (hexMatch) return hexToRgb(trimmed);
359
+ }
360
+ const rgbMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);
361
+ if (rgbMatch) {
362
+ return {
363
+ r: Number.parseInt(rgbMatch[1] ?? "0", 10),
364
+ g: Number.parseInt(rgbMatch[2] ?? "0", 10),
365
+ b: Number.parseInt(rgbMatch[3] ?? "0", 10),
366
+ a: rgbMatch[4] ? Number.parseFloat(rgbMatch[4]) : 1
367
+ };
368
+ }
369
+ const hslMatch = trimmed.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+))?\s*\)$/);
370
+ if (hslMatch) {
371
+ const h = Number.parseInt(hslMatch[1] ?? "0", 10);
372
+ const s = Number.parseInt(hslMatch[2] ?? "0", 10) / 100;
373
+ const l = Number.parseInt(hslMatch[3] ?? "0", 10) / 100;
374
+ const a = hslMatch[4] ? Number.parseFloat(hslMatch[4]) : 1;
375
+ const c = (1 - Math.abs(2 * l - 1)) * s;
376
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
377
+ const m = l - c / 2;
378
+ let r = 0;
379
+ let g = 0;
380
+ let b = 0;
381
+ if (h >= 0 && h < 60) {
382
+ r = c;
383
+ g = x;
384
+ } else if (h >= 60 && h < 120) {
385
+ r = x;
386
+ g = c;
387
+ } else if (h >= 120 && h < 180) {
388
+ g = c;
389
+ b = x;
390
+ } else if (h >= 180 && h < 240) {
391
+ g = x;
392
+ b = c;
393
+ } else if (h >= 240 && h < 300) {
394
+ r = x;
395
+ b = c;
396
+ } else if (h >= 300 && h < 360) {
397
+ r = c;
398
+ b = x;
399
+ }
400
+ return {
401
+ r: Math.round((r + m) * 255),
402
+ g: Math.round((g + m) * 255),
403
+ b: Math.round((b + m) * 255),
404
+ a
405
+ };
406
+ }
407
+ const hsbMatch = trimmed.match(/^hsba?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+))?\s*\)$/);
408
+ if (hsbMatch) {
409
+ const h = Number.parseInt(hsbMatch[1] ?? "0", 10);
410
+ const s = Number.parseInt(hsbMatch[2] ?? "0", 10);
411
+ const v = Number.parseInt(hsbMatch[3] ?? "0", 10);
412
+ const a = hsbMatch[4] ? Number.parseFloat(hsbMatch[4]) : 1;
413
+ return hsvToRgb({ h, s, v, a });
414
+ }
415
+ return null;
416
+ }
417
+
418
+ // src/components/color-picker/color-picker.store.tsx
419
+ var ColorPickerStoreContext = React16__namespace.createContext(null);
420
+ function useColorPickerStoreContext(consumerName) {
421
+ const context = React16__namespace.useContext(ColorPickerStoreContext);
422
+ if (!context) {
423
+ throw new Error(`\`${consumerName}\` must be used within \`ColorPicker\``);
424
+ }
425
+ return context;
426
+ }
427
+ function useColorPickerStore(selector) {
428
+ const store = useColorPickerStoreContext("useColorPickerStore");
429
+ const getSnapshot = React16__namespace.useCallback(() => selector(store.getState()), [store, selector]);
430
+ return React16__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
431
+ }
432
+ function createColorPickerStore(listenersRef, stateRef, propsRef) {
433
+ const store = {
434
+ subscribe: (cb) => {
435
+ listenersRef.current.add(cb);
436
+ return () => listenersRef.current.delete(cb);
437
+ },
438
+ getState: () => stateRef.current,
439
+ setColor: (value) => {
440
+ if (Object.is(stateRef.current.color, value)) return;
441
+ const prevState = { ...stateRef.current };
442
+ stateRef.current.color = value;
443
+ if (propsRef.current.onValueChange) {
444
+ propsRef.current.onValueChange(colorToString(value, prevState.format));
445
+ }
446
+ store.notify();
447
+ },
448
+ setHsv: (value) => {
449
+ if (Object.is(stateRef.current.hsv, value)) return;
450
+ const prevState = { ...stateRef.current };
451
+ stateRef.current.hsv = value;
452
+ if (propsRef.current.onValueChange) {
453
+ propsRef.current.onValueChange(colorToString(hsvToRgb(value), prevState.format));
454
+ }
455
+ store.notify();
456
+ },
457
+ setOpen: (value) => {
458
+ if (Object.is(stateRef.current.open, value)) return;
459
+ stateRef.current.open = value;
460
+ propsRef.current.onOpenChange?.(value);
461
+ store.notify();
462
+ },
463
+ setFormat: (value) => {
464
+ if (Object.is(stateRef.current.format, value)) return;
465
+ stateRef.current.format = value;
466
+ propsRef.current.onFormatChange?.(value);
467
+ store.notify();
468
+ },
469
+ notify: () => {
470
+ for (const cb of listenersRef.current) cb();
471
+ }
472
+ };
473
+ return store;
474
+ }
475
+ function ColorPicker(props) {
476
+ const {
477
+ value: valueProp,
478
+ defaultValue = "#000000",
479
+ onValueChange,
480
+ format: formatProp,
481
+ defaultFormat = "hex",
482
+ onFormatChange,
483
+ defaultOpen,
484
+ open: openProp,
485
+ onOpenChange,
486
+ modal,
487
+ name,
488
+ disabled,
489
+ inline,
490
+ readOnly,
491
+ required,
492
+ ...rootProps
493
+ } = props;
494
+ const listenersRef = chunkN4TYSZSU_cjs.useLazyRef(() => /* @__PURE__ */ new Set());
495
+ const stateRef = chunkN4TYSZSU_cjs.useLazyRef(() => {
496
+ const colorString = valueProp ?? defaultValue;
497
+ const color = hexToRgb(colorString);
498
+ return {
499
+ color,
500
+ hsv: rgbToHsv(color),
501
+ open: openProp ?? defaultOpen ?? false,
502
+ format: formatProp ?? defaultFormat
503
+ };
504
+ });
505
+ const propsRef = chunkN4TYSZSU_cjs.useAsRef({ onValueChange, onOpenChange, onFormatChange });
506
+ const store = React16__namespace.useMemo(
507
+ () => createColorPickerStore(listenersRef, stateRef, propsRef),
508
+ [listenersRef, stateRef, propsRef]
509
+ );
510
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorPickerStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxRuntime.jsx(
511
+ ColorPickerImpl,
512
+ {
513
+ ...rootProps,
514
+ value: valueProp,
515
+ defaultOpen,
516
+ open: openProp,
517
+ modal,
518
+ name,
519
+ disabled,
520
+ inline,
521
+ readOnly,
522
+ required
523
+ }
524
+ ) });
525
+ }
526
+ function ColorPickerImpl(props) {
527
+ const {
528
+ value: valueProp,
529
+ dir: dirProp,
530
+ defaultOpen,
531
+ open: openProp,
532
+ modal,
533
+ name,
534
+ ref,
535
+ asChild,
536
+ disabled,
537
+ inline,
538
+ readOnly,
539
+ required,
540
+ ...rootProps
541
+ } = props;
542
+ const store = useColorPickerStoreContext(COLOR_PICKER_IMPL_NAME);
543
+ const dir = radixUi.Direction.useDirection(dirProp);
544
+ const [formTrigger, setFormTrigger] = React16__namespace.useState(null);
545
+ const composedRef = chunkXY3ZNUWR_cjs.useComposedRefs(ref, (node) => setFormTrigger(node));
546
+ const isFormControl = formTrigger ? !!formTrigger.closest("form") : true;
547
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
548
+ if (valueProp !== void 0) {
549
+ const currentState = store.getState();
550
+ const color = hexToRgb(valueProp, currentState.color.a);
551
+ store.setColor(color);
552
+ store.setHsv(rgbToHsv(color));
553
+ }
554
+ }, [valueProp]);
555
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
556
+ if (openProp !== void 0) {
557
+ store.setOpen(openProp);
558
+ }
559
+ }, [openProp]);
560
+ const contextValue = React16__namespace.useMemo(
561
+ () => ({ dir, disabled, inline, readOnly, required }),
562
+ [dir, disabled, inline, readOnly, required]
563
+ );
564
+ const value = useColorPickerStore((state) => rgbToHex(state.color));
565
+ const open = useColorPickerStore((state) => state.open);
566
+ const RootPrimitive = asChild ? radixUi.Slot.Slot : "div";
567
+ if (inline) {
568
+ return /* @__PURE__ */ jsxRuntime.jsxs(ColorPickerContext.Provider, { value: contextValue, children: [
569
+ /* @__PURE__ */ jsxRuntime.jsx(RootPrimitive, { "data-slot": "color-picker", ...rootProps, ref: composedRef }),
570
+ isFormControl && /* @__PURE__ */ jsxRuntime.jsx(
571
+ VisuallyHiddenInput,
572
+ {
573
+ type: "hidden",
574
+ control: formTrigger,
575
+ name,
576
+ value,
577
+ disabled,
578
+ readOnly,
579
+ required
580
+ }
581
+ )
582
+ ] });
583
+ }
584
+ return /* @__PURE__ */ jsxRuntime.jsx(ColorPickerContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(chunkGEDBA3JU_cjs.Popover, { defaultOpen, open, onOpenChange: store.setOpen, modal, children: [
585
+ /* @__PURE__ */ jsxRuntime.jsx(RootPrimitive, { "data-slot": "color-picker", ...rootProps, ref: composedRef }),
586
+ isFormControl && /* @__PURE__ */ jsxRuntime.jsx(
587
+ VisuallyHiddenInput,
588
+ {
589
+ type: "hidden",
590
+ control: formTrigger,
591
+ name,
592
+ value,
593
+ disabled,
594
+ readOnly,
595
+ required
596
+ }
597
+ )
598
+ ] }) });
599
+ }
600
+ function ColorPickerTrigger(props) {
601
+ const { asChild, disabled, ...triggerProps } = props;
602
+ const context = useColorPickerContext(COLOR_PICKER_TRIGGER_NAME);
603
+ const isDisabled = disabled || context.disabled;
604
+ const TriggerPrimitive = asChild ? radixUi.Slot.Slot : Button;
605
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkGEDBA3JU_cjs.PopoverTrigger, { asChild: true, disabled: isDisabled, children: /* @__PURE__ */ jsxRuntime.jsx(TriggerPrimitive, { "data-slot": "color-picker-trigger", ...triggerProps }) });
606
+ }
607
+ function ColorPickerContent(props) {
608
+ const { asChild, className, children, ...popoverContentProps } = props;
609
+ const context = useColorPickerContext(COLOR_PICKER_CONTENT_NAME);
610
+ if (context.inline) {
611
+ const ContentPrimitive = asChild ? radixUi.Slot.Slot : "div";
612
+ return /* @__PURE__ */ jsxRuntime.jsx(
613
+ ContentPrimitive,
614
+ {
615
+ "data-slot": "color-picker-content",
616
+ ...popoverContentProps,
617
+ className: chunkH2BWO3SI_cjs.cn("flex w-[340px] flex-col gap-4 p-4", className),
618
+ children
619
+ }
620
+ );
621
+ }
622
+ return /* @__PURE__ */ jsxRuntime.jsx(
623
+ chunkGEDBA3JU_cjs.PopoverContent,
624
+ {
625
+ "data-slot": "color-picker-content",
626
+ asChild,
627
+ ...popoverContentProps,
628
+ className: chunkH2BWO3SI_cjs.cn("flex w-[340px] flex-col gap-4 p-4", className),
629
+ children
630
+ }
631
+ );
632
+ }
633
+ function ColorPickerArea(props) {
634
+ const {
635
+ asChild,
636
+ onPointerDown: onPointerDownProp,
637
+ onPointerMove: onPointerMoveProp,
638
+ onPointerUp: onPointerUpProp,
639
+ className,
640
+ ref,
641
+ ...areaProps
642
+ } = props;
643
+ const propsRef = chunkN4TYSZSU_cjs.useAsRef({
644
+ onPointerDown: onPointerDownProp,
645
+ onPointerMove: onPointerMoveProp,
646
+ onPointerUp: onPointerUpProp
647
+ });
648
+ const context = useColorPickerContext(COLOR_PICKER_AREA_NAME);
649
+ const store = useColorPickerStoreContext(COLOR_PICKER_AREA_NAME);
650
+ const hsv = useColorPickerStore((state) => state.hsv);
651
+ const isDraggingRef = React16__namespace.useRef(false);
652
+ const areaRef = React16__namespace.useRef(null);
653
+ const composedRef = chunkXY3ZNUWR_cjs.useComposedRefs(ref, areaRef);
654
+ const updateColorFromPosition = React16__namespace.useCallback(
655
+ (clientX, clientY) => {
656
+ if (!areaRef.current) return;
657
+ const rect = areaRef.current.getBoundingClientRect();
658
+ const x = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
659
+ const y = Math.max(0, Math.min(1, 1 - (clientY - rect.top) / rect.height));
660
+ const newHsv = {
661
+ h: hsv?.h ?? 0,
662
+ s: Math.round(x * 100),
663
+ v: Math.round(y * 100),
664
+ a: hsv?.a ?? 1
665
+ };
666
+ store.setHsv(newHsv);
667
+ store.setColor(hsvToRgb(newHsv));
668
+ },
669
+ [hsv, store]
670
+ );
671
+ const onPointerDown = React16__namespace.useCallback(
672
+ (event) => {
673
+ if (context.disabled) return;
674
+ propsRef.current.onPointerDown?.(event);
675
+ if (event.defaultPrevented) return;
676
+ isDraggingRef.current = true;
677
+ areaRef.current?.setPointerCapture(event.pointerId);
678
+ updateColorFromPosition(event.clientX, event.clientY);
679
+ },
680
+ [context.disabled, updateColorFromPosition, propsRef]
681
+ );
682
+ const onPointerMove = React16__namespace.useCallback(
683
+ (event) => {
684
+ propsRef.current.onPointerMove?.(event);
685
+ if (event.defaultPrevented) return;
686
+ if (isDraggingRef.current) updateColorFromPosition(event.clientX, event.clientY);
687
+ },
688
+ [updateColorFromPosition, propsRef]
689
+ );
690
+ const onPointerUp = React16__namespace.useCallback(
691
+ (event) => {
692
+ propsRef.current.onPointerUp?.(event);
693
+ if (event.defaultPrevented) return;
694
+ isDraggingRef.current = false;
695
+ areaRef.current?.releasePointerCapture(event.pointerId);
696
+ },
697
+ [propsRef]
698
+ );
699
+ const hue = hsv?.h ?? 0;
700
+ const backgroundHue = hsvToRgb({ h: hue, s: 100, v: 100, a: 1 });
701
+ const AreaPrimitive = asChild ? radixUi.Slot.Slot : "div";
702
+ return /* @__PURE__ */ jsxRuntime.jsxs(
703
+ AreaPrimitive,
704
+ {
705
+ "data-slot": "color-picker-area",
706
+ ...areaProps,
707
+ className: chunkH2BWO3SI_cjs.cn(
708
+ "relative h-40 w-full cursor-crosshair touch-none rounded-sm border",
709
+ context.disabled && "pointer-events-none opacity-50",
710
+ className
711
+ ),
712
+ ref: composedRef,
713
+ onPointerDown,
714
+ onPointerMove,
715
+ onPointerUp,
716
+ children: [
717
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-0 overflow-hidden rounded-sm", children: [
718
+ /* @__PURE__ */ jsxRuntime.jsx(
719
+ "div",
720
+ {
721
+ className: "absolute inset-0",
722
+ style: { backgroundColor: `rgb(${backgroundHue.r}, ${backgroundHue.g}, ${backgroundHue.b})` }
723
+ }
724
+ ),
725
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0", style: { background: "linear-gradient(to right, #fff, transparent)" } }),
726
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0", style: { background: "linear-gradient(to bottom, transparent, #000)" } })
727
+ ] }),
728
+ /* @__PURE__ */ jsxRuntime.jsx(
729
+ "div",
730
+ {
731
+ className: "absolute size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-sm",
732
+ style: { left: `${hsv?.s ?? 0}%`, top: `${100 - (hsv?.v ?? 0)}%` }
733
+ }
734
+ )
735
+ ]
736
+ }
737
+ );
738
+ }
739
+ function ColorPickerHueSlider(props) {
740
+ const { className, ...sliderProps } = props;
741
+ const context = useColorPickerContext(COLOR_PICKER_HUE_SLIDER_NAME);
742
+ const store = useColorPickerStoreContext(COLOR_PICKER_HUE_SLIDER_NAME);
743
+ const hsv = useColorPickerStore((state) => state.hsv);
744
+ const onValueChange = React16__namespace.useCallback(
745
+ (values) => {
746
+ const newHsv = { h: values[0] ?? 0, s: hsv?.s ?? 0, v: hsv?.v ?? 0, a: hsv?.a ?? 1 };
747
+ store.setHsv(newHsv);
748
+ store.setColor(hsvToRgb(newHsv));
749
+ },
750
+ [hsv, store]
751
+ );
752
+ return /* @__PURE__ */ jsxRuntime.jsxs(
753
+ radixUi.Slider.Root,
754
+ {
755
+ "data-slot": "color-picker-hue-slider",
756
+ ...sliderProps,
757
+ max: 360,
758
+ step: 1,
759
+ className: chunkH2BWO3SI_cjs.cn("relative flex w-full touch-none items-center select-none", className),
760
+ value: [hsv?.h ?? 0],
761
+ onValueChange,
762
+ disabled: context.disabled,
763
+ children: [
764
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Track, { className: "relative h-3 w-full grow overflow-hidden rounded-full bg-[linear-gradient(to_right,#ff0000_0%,#ffff00_16.66%,#00ff00_33.33%,#00ffff_50%,#0000ff_66.66%,#ff00ff_83.33%,#ff0000_100%)]", children: /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Range, { className: "absolute h-full" }) }),
765
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Thumb, { className: "border-primary/50 bg-background focus-visible:ring-ring block size-4 rounded-full border shadow transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50" })
766
+ ]
767
+ }
768
+ );
769
+ }
770
+ function ColorPickerAlphaSlider(props) {
771
+ const { className, ...sliderProps } = props;
772
+ const context = useColorPickerContext(COLOR_PICKER_ALPHA_SLIDER_NAME);
773
+ const store = useColorPickerStoreContext(COLOR_PICKER_ALPHA_SLIDER_NAME);
774
+ const color = useColorPickerStore((state) => state.color);
775
+ const hsv = useColorPickerStore((state) => state.hsv);
776
+ const onValueChange = React16__namespace.useCallback(
777
+ (values) => {
778
+ const alpha = (values[0] ?? 0) / 100;
779
+ store.setColor({ ...color, a: alpha });
780
+ store.setHsv({ ...hsv, a: alpha });
781
+ },
782
+ [color, hsv, store]
783
+ );
784
+ const gradientColor = `rgb(${color?.r ?? 0}, ${color?.g ?? 0}, ${color?.b ?? 0})`;
785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
786
+ radixUi.Slider.Root,
787
+ {
788
+ "data-slot": "color-picker-alpha-slider",
789
+ ...sliderProps,
790
+ max: 100,
791
+ step: 1,
792
+ disabled: context.disabled,
793
+ className: chunkH2BWO3SI_cjs.cn("relative flex w-full touch-none items-center select-none", className),
794
+ value: [Math.round((color?.a ?? 1) * 100)],
795
+ onValueChange,
796
+ children: [
797
+ /* @__PURE__ */ jsxRuntime.jsxs(
798
+ radixUi.Slider.Track,
799
+ {
800
+ className: "relative h-3 w-full grow overflow-hidden rounded-full",
801
+ style: {
802
+ background: "linear-gradient(45deg, #ccc 25%, transparent 25%), linear-gradient(-45deg, #ccc 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ccc 75%), linear-gradient(-45deg, transparent 75%, #ccc 75%)",
803
+ backgroundSize: "8px 8px",
804
+ backgroundPosition: "0 0, 0 4px, 4px -4px, -4px 0px"
805
+ },
806
+ children: [
807
+ /* @__PURE__ */ jsxRuntime.jsx(
808
+ "div",
809
+ {
810
+ className: "absolute inset-0 rounded-full",
811
+ style: { background: `linear-gradient(to right, transparent, ${gradientColor})` }
812
+ }
813
+ ),
814
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Range, { className: "absolute h-full" })
815
+ ]
816
+ }
817
+ ),
818
+ /* @__PURE__ */ jsxRuntime.jsx(radixUi.Slider.Thumb, { className: "border-primary/50 bg-background focus-visible:ring-ring block size-4 rounded-full border shadow transition-colors focus-visible:ring-1 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50" })
819
+ ]
820
+ }
821
+ );
822
+ }
823
+ function ColorPickerSwatch(props) {
824
+ const { asChild, className, ...swatchProps } = props;
825
+ const context = useColorPickerContext(COLOR_PICKER_SWATCH_NAME);
826
+ const color = useColorPickerStore((state) => state.color);
827
+ const format = useColorPickerStore((state) => state.format);
828
+ const backgroundStyle = React16__namespace.useMemo(() => {
829
+ if (!color) {
830
+ return {
831
+ background: "linear-gradient(to bottom right, transparent calc(50% - 1px), hsl(var(--destructive)) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) no-repeat"
832
+ };
833
+ }
834
+ const colorString = `rgba(${color.r}, ${color.g}, ${color.b}, ${color.a})`;
835
+ if (color.a < 1) {
836
+ return {
837
+ background: `linear-gradient(${colorString}, ${colorString}), repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0% 50% / 8px 8px`
838
+ };
839
+ }
840
+ return { backgroundColor: colorString };
841
+ }, [color]);
842
+ const ariaLabel = !color ? "No color selected" : `Current color: ${colorToString(color, format)}`;
843
+ const SwatchPrimitive = asChild ? radixUi.Slot.Slot : "div";
844
+ return /* @__PURE__ */ jsxRuntime.jsx(
845
+ SwatchPrimitive,
846
+ {
847
+ role: "img",
848
+ "aria-label": ariaLabel,
849
+ "data-slot": "color-picker-swatch",
850
+ ...swatchProps,
851
+ className: chunkH2BWO3SI_cjs.cn("box-border size-8 rounded-sm border shadow-sm", context.disabled && "opacity-50", className),
852
+ style: { ...backgroundStyle, forcedColorAdjust: "none" }
853
+ }
854
+ );
855
+ }
856
+ function ColorPickerEyeDropper(props) {
857
+ const { size: sizeProp, children, disabled, ...buttonProps } = props;
858
+ const context = useColorPickerContext(COLOR_PICKER_EYE_DROPPER_NAME);
859
+ const store = useColorPickerStoreContext(COLOR_PICKER_EYE_DROPPER_NAME);
860
+ const color = useColorPickerStore((state) => state.color);
861
+ const isDisabled = disabled || context.disabled;
862
+ const onEyeDropper = React16__namespace.useCallback(async () => {
863
+ if (!window.EyeDropper) return;
864
+ try {
865
+ const eyeDropper = new window.EyeDropper();
866
+ const result = await eyeDropper.open();
867
+ if (result.sRGBHex) {
868
+ const newColor = hexToRgb(result.sRGBHex, color?.a ?? 1);
869
+ store.setColor(newColor);
870
+ store.setHsv(rgbToHsv(newColor));
871
+ }
872
+ } catch (error) {
873
+ console.warn("EyeDropper error:", error);
874
+ }
875
+ }, [color, store]);
876
+ const hasEyeDropper = typeof window !== "undefined" && !!window.EyeDropper;
877
+ if (!hasEyeDropper) return null;
878
+ const size = sizeProp ?? (children ? "default" : "icon");
879
+ return /* @__PURE__ */ jsxRuntime.jsx(
880
+ Button,
881
+ {
882
+ "data-slot": "color-picker-eye-dropper",
883
+ ...buttonProps,
884
+ variant: "outline",
885
+ size,
886
+ onClick: onEyeDropper,
887
+ disabled: isDisabled,
888
+ children: children ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PipetteIcon, {})
889
+ }
890
+ );
891
+ }
892
+ function ColorPickerFormatSelect(props) {
893
+ const { size, disabled, className, ...selectProps } = props;
894
+ const context = useColorPickerContext(COLOR_PICKER_FORMAT_SELECT_NAME);
895
+ const store = useColorPickerStoreContext(COLOR_PICKER_FORMAT_SELECT_NAME);
896
+ const isDisabled = disabled || context.disabled;
897
+ const format = useColorPickerStore((state) => state.format);
898
+ const onFormatChange = React16__namespace.useCallback(
899
+ (value) => {
900
+ store.setFormat(value);
901
+ },
902
+ [store]
903
+ );
904
+ return /* @__PURE__ */ jsxRuntime.jsx(
905
+ chunk6HX7ETL3_cjs.Select,
906
+ {
907
+ "data-slot": "color-picker-format-select",
908
+ ...selectProps,
909
+ value: format,
910
+ onValueChange: onFormatChange,
911
+ disabled: isDisabled,
912
+ size: size ?? "sm",
913
+ className: chunkH2BWO3SI_cjs.cn(className),
914
+ children: /* @__PURE__ */ jsxRuntime.jsx(chunk6HX7ETL3_cjs.SelectContent, { children: COLOR_FORMATS.map((f) => /* @__PURE__ */ jsxRuntime.jsx(chunk6HX7ETL3_cjs.SelectItem, { value: f, children: f.toUpperCase() }, f)) })
915
+ }
916
+ );
917
+ }
918
+ var inputGroupItemVariants = classVarianceAuthority.cva(
919
+ "h-8 [-moz-appearance:textfield] focus-visible:z-10 focus-visible:ring-1 [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none",
920
+ {
921
+ variants: {
922
+ position: {
923
+ first: "rounded-e-none",
924
+ middle: "-ms-px rounded-none border-l-0",
925
+ last: "-ms-px rounded-s-none border-l-0",
926
+ isolated: ""
927
+ }
928
+ },
929
+ defaultVariants: {
930
+ position: "isolated"
931
+ }
932
+ }
933
+ );
934
+ function ColorPickerInput(props) {
935
+ const store = useColorPickerStoreContext(COLOR_PICKER_INPUT_NAME);
936
+ const context = useColorPickerContext(COLOR_PICKER_INPUT_NAME);
937
+ const color = useColorPickerStore((state) => state.color);
938
+ const format = useColorPickerStore((state) => state.format);
939
+ const hsv = useColorPickerStore((state) => state.hsv);
940
+ const onColorChange = React16__namespace.useCallback(
941
+ (newColor) => {
942
+ const newHsv = rgbToHsv(newColor);
943
+ store.setColor(newColor);
944
+ store.setHsv(newHsv);
945
+ },
946
+ [store]
947
+ );
948
+ if (format === "hex") {
949
+ return /* @__PURE__ */ jsxRuntime.jsx(HexInput, { color, onColorChange, context, ...props });
950
+ }
951
+ if (format === "rgb") {
952
+ return /* @__PURE__ */ jsxRuntime.jsx(RgbInput, { color, onColorChange, context, ...props });
953
+ }
954
+ if (format === "hsl") {
955
+ return /* @__PURE__ */ jsxRuntime.jsx(HslInput, { color, onColorChange, context, ...props });
956
+ }
957
+ if (format === "hsb") {
958
+ return /* @__PURE__ */ jsxRuntime.jsx(HsbInput, { hsv, onColorChange, context, ...props });
959
+ }
960
+ }
961
+ function InputGroupItem({ className, position, ...props }) {
962
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkB4M7Q5KX_cjs.Input, { "data-slot": "color-picker-input", className: chunkH2BWO3SI_cjs.cn(inputGroupItemVariants({ position, className })), ...props });
963
+ }
964
+ function HexInput(props) {
965
+ const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
966
+ const hexValue = rgbToHex(color);
967
+ const alphaValue = Math.round((color?.a ?? 1) * 100);
968
+ const onHexChange = React16__namespace.useCallback(
969
+ (event) => {
970
+ const value = event.target.value;
971
+ const parsedColor = parseColorString(value);
972
+ if (parsedColor) {
973
+ onColorChange({ ...parsedColor, a: color?.a ?? 1 });
974
+ }
975
+ },
976
+ [color, onColorChange]
977
+ );
978
+ const onAlphaChange = React16__namespace.useCallback(
979
+ (event) => {
980
+ const value = Number.parseInt(event.target.value, 10);
981
+ if (!Number.isNaN(value) && value >= 0 && value <= 100) {
982
+ onColorChange({ ...color, a: value / 100 });
983
+ }
984
+ },
985
+ [color, onColorChange]
986
+ );
987
+ if (withoutAlpha) {
988
+ return /* @__PURE__ */ jsxRuntime.jsx(
989
+ InputGroupItem,
990
+ {
991
+ "aria-label": "Hex color value",
992
+ position: "isolated",
993
+ ...inputProps,
994
+ placeholder: "#000000",
995
+ className: chunkH2BWO3SI_cjs.cn("font-code", className),
996
+ value: hexValue,
997
+ onChange: onHexChange,
998
+ disabled: context.disabled
999
+ }
1000
+ );
1001
+ }
1002
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "color-picker-input-wrapper", className: chunkH2BWO3SI_cjs.cn("flex flex-1 items-center", className), children: [
1003
+ /* @__PURE__ */ jsxRuntime.jsx(
1004
+ InputGroupItem,
1005
+ {
1006
+ "aria-label": "Hex color value",
1007
+ position: "first",
1008
+ ...inputProps,
1009
+ placeholder: "#000000",
1010
+ className: "font-code flex-1",
1011
+ value: hexValue,
1012
+ onChange: onHexChange,
1013
+ disabled: context.disabled
1014
+ }
1015
+ ),
1016
+ /* @__PURE__ */ jsxRuntime.jsx(
1017
+ InputGroupItem,
1018
+ {
1019
+ "aria-label": "Alpha transparency percentage",
1020
+ position: "last",
1021
+ ...inputProps,
1022
+ placeholder: "100",
1023
+ inputMode: "numeric",
1024
+ pattern: "[0-9]*",
1025
+ min: "0",
1026
+ max: "100",
1027
+ className: "w-14",
1028
+ value: alphaValue,
1029
+ onChange: onAlphaChange,
1030
+ disabled: context.disabled
1031
+ }
1032
+ )
1033
+ ] });
1034
+ }
1035
+ function RgbInput(props) {
1036
+ const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1037
+ const rValue = Math.round(color?.r ?? 0);
1038
+ const gValue = Math.round(color?.g ?? 0);
1039
+ const bValue = Math.round(color?.b ?? 0);
1040
+ const alphaValue = Math.round((color?.a ?? 1) * 100);
1041
+ const onChannelChange = React16__namespace.useCallback(
1042
+ (channel, max, isAlpha = false) => (event) => {
1043
+ const value = Number.parseInt(event.target.value, 10);
1044
+ if (!Number.isNaN(value) && value >= 0 && value <= max) {
1045
+ const newValue = isAlpha ? value / 100 : value;
1046
+ onColorChange({ ...color, [channel]: newValue });
1047
+ }
1048
+ },
1049
+ [color, onColorChange]
1050
+ );
1051
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "color-picker-input-wrapper", className: chunkH2BWO3SI_cjs.cn("flex flex-1 items-center", className), children: [
1052
+ /* @__PURE__ */ jsxRuntime.jsx(
1053
+ InputGroupItem,
1054
+ {
1055
+ "aria-label": "Red color component (0-255)",
1056
+ position: "first",
1057
+ ...inputProps,
1058
+ placeholder: "0",
1059
+ inputMode: "numeric",
1060
+ pattern: "[0-9]*",
1061
+ min: "0",
1062
+ max: "255",
1063
+ className: "w-14",
1064
+ value: rValue,
1065
+ onChange: onChannelChange("r", 255),
1066
+ disabled: context.disabled
1067
+ }
1068
+ ),
1069
+ /* @__PURE__ */ jsxRuntime.jsx(
1070
+ InputGroupItem,
1071
+ {
1072
+ "aria-label": "Green color component (0-255)",
1073
+ position: "middle",
1074
+ ...inputProps,
1075
+ placeholder: "0",
1076
+ inputMode: "numeric",
1077
+ pattern: "[0-9]*",
1078
+ min: "0",
1079
+ max: "255",
1080
+ className: "w-14",
1081
+ value: gValue,
1082
+ onChange: onChannelChange("g", 255),
1083
+ disabled: context.disabled
1084
+ }
1085
+ ),
1086
+ /* @__PURE__ */ jsxRuntime.jsx(
1087
+ InputGroupItem,
1088
+ {
1089
+ "aria-label": "Blue color component (0-255)",
1090
+ position: withoutAlpha ? "last" : "middle",
1091
+ ...inputProps,
1092
+ placeholder: "0",
1093
+ inputMode: "numeric",
1094
+ pattern: "[0-9]*",
1095
+ min: "0",
1096
+ max: "255",
1097
+ className: "w-14",
1098
+ value: bValue,
1099
+ onChange: onChannelChange("b", 255),
1100
+ disabled: context.disabled
1101
+ }
1102
+ ),
1103
+ !withoutAlpha && /* @__PURE__ */ jsxRuntime.jsx(
1104
+ InputGroupItem,
1105
+ {
1106
+ "aria-label": "Alpha transparency percentage",
1107
+ position: "last",
1108
+ ...inputProps,
1109
+ placeholder: "100",
1110
+ inputMode: "numeric",
1111
+ pattern: "[0-9]*",
1112
+ min: "0",
1113
+ max: "100",
1114
+ className: "w-14",
1115
+ value: alphaValue,
1116
+ onChange: onChannelChange("a", 100, true),
1117
+ disabled: context.disabled
1118
+ }
1119
+ )
1120
+ ] });
1121
+ }
1122
+ function HslInput(props) {
1123
+ const { color, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1124
+ const hsl = React16__namespace.useMemo(() => rgbToHsl(color), [color]);
1125
+ const alphaValue = Math.round((color?.a ?? 1) * 100);
1126
+ const onHslChannelChange = React16__namespace.useCallback(
1127
+ (channel, max) => (event) => {
1128
+ const value = Number.parseInt(event.target.value, 10);
1129
+ if (!Number.isNaN(value) && value >= 0 && value <= max) {
1130
+ const newHsl = { ...hsl, [channel]: value };
1131
+ const newColor = hslToRgb(newHsl, color?.a ?? 1);
1132
+ onColorChange(newColor);
1133
+ }
1134
+ },
1135
+ [hsl, color, onColorChange]
1136
+ );
1137
+ const onAlphaChange = React16__namespace.useCallback(
1138
+ (event) => {
1139
+ const value = Number.parseInt(event.target.value, 10);
1140
+ if (!Number.isNaN(value) && value >= 0 && value <= 100) {
1141
+ onColorChange({ ...color, a: value / 100 });
1142
+ }
1143
+ },
1144
+ [color, onColorChange]
1145
+ );
1146
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "color-picker-input-wrapper", className: chunkH2BWO3SI_cjs.cn("flex items-center", className), children: [
1147
+ /* @__PURE__ */ jsxRuntime.jsx(
1148
+ InputGroupItem,
1149
+ {
1150
+ "aria-label": "Hue degree (0-360)",
1151
+ position: "first",
1152
+ ...inputProps,
1153
+ placeholder: "0",
1154
+ inputMode: "numeric",
1155
+ pattern: "[0-9]*",
1156
+ min: "0",
1157
+ max: "360",
1158
+ className: "w-14",
1159
+ value: hsl.h,
1160
+ onChange: onHslChannelChange("h", 360),
1161
+ disabled: context.disabled
1162
+ }
1163
+ ),
1164
+ /* @__PURE__ */ jsxRuntime.jsx(
1165
+ InputGroupItem,
1166
+ {
1167
+ "aria-label": "Saturation percentage (0-100)",
1168
+ position: "middle",
1169
+ ...inputProps,
1170
+ placeholder: "0",
1171
+ inputMode: "numeric",
1172
+ pattern: "[0-9]*",
1173
+ min: "0",
1174
+ max: "100",
1175
+ className: "w-14",
1176
+ value: hsl.s,
1177
+ onChange: onHslChannelChange("s", 100),
1178
+ disabled: context.disabled
1179
+ }
1180
+ ),
1181
+ /* @__PURE__ */ jsxRuntime.jsx(
1182
+ InputGroupItem,
1183
+ {
1184
+ "aria-label": "Lightness percentage (0-100)",
1185
+ position: withoutAlpha ? "last" : "middle",
1186
+ ...inputProps,
1187
+ placeholder: "0",
1188
+ inputMode: "numeric",
1189
+ pattern: "[0-9]*",
1190
+ min: "0",
1191
+ max: "100",
1192
+ className: "w-14",
1193
+ value: hsl.l,
1194
+ onChange: onHslChannelChange("l", 100),
1195
+ disabled: context.disabled
1196
+ }
1197
+ ),
1198
+ !withoutAlpha && /* @__PURE__ */ jsxRuntime.jsx(
1199
+ InputGroupItem,
1200
+ {
1201
+ "aria-label": "Alpha transparency percentage",
1202
+ position: "last",
1203
+ ...inputProps,
1204
+ placeholder: "100",
1205
+ inputMode: "numeric",
1206
+ pattern: "[0-9]*",
1207
+ min: "0",
1208
+ max: "100",
1209
+ className: "w-14",
1210
+ value: alphaValue,
1211
+ onChange: onAlphaChange,
1212
+ disabled: context.disabled
1213
+ }
1214
+ )
1215
+ ] });
1216
+ }
1217
+ function HsbInput(props) {
1218
+ const { hsv, onColorChange, context, withoutAlpha, className, ...inputProps } = props;
1219
+ const alphaValue = Math.round((hsv?.a ?? 1) * 100);
1220
+ const onHsvChannelChange = React16__namespace.useCallback(
1221
+ (channel, max) => (event) => {
1222
+ const value = Number.parseInt(event.target.value, 10);
1223
+ if (!Number.isNaN(value) && value >= 0 && value <= max) {
1224
+ const newHsv = { ...hsv, [channel]: value };
1225
+ const newColor = hsvToRgb(newHsv);
1226
+ onColorChange(newColor);
1227
+ }
1228
+ },
1229
+ [hsv, onColorChange]
1230
+ );
1231
+ const onAlphaChange = React16__namespace.useCallback(
1232
+ (event) => {
1233
+ const value = Number.parseInt(event.target.value, 10);
1234
+ if (!Number.isNaN(value) && value >= 0 && value <= 100) {
1235
+ const currentColor = hsvToRgb(hsv);
1236
+ onColorChange({ ...currentColor, a: value / 100 });
1237
+ }
1238
+ },
1239
+ [hsv, onColorChange]
1240
+ );
1241
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "color-picker-input-wrapper", className: chunkH2BWO3SI_cjs.cn("flex items-center", className), children: [
1242
+ /* @__PURE__ */ jsxRuntime.jsx(
1243
+ InputGroupItem,
1244
+ {
1245
+ "aria-label": "Hue degree (0-360)",
1246
+ position: "first",
1247
+ ...inputProps,
1248
+ placeholder: "0",
1249
+ inputMode: "numeric",
1250
+ pattern: "[0-9]*",
1251
+ min: "0",
1252
+ max: "360",
1253
+ className: "w-14",
1254
+ value: hsv?.h ?? 0,
1255
+ onChange: onHsvChannelChange("h", 360),
1256
+ disabled: context.disabled
1257
+ }
1258
+ ),
1259
+ /* @__PURE__ */ jsxRuntime.jsx(
1260
+ InputGroupItem,
1261
+ {
1262
+ "aria-label": "Saturation percentage (0-100)",
1263
+ position: "middle",
1264
+ ...inputProps,
1265
+ placeholder: "0",
1266
+ inputMode: "numeric",
1267
+ pattern: "[0-9]*",
1268
+ min: "0",
1269
+ max: "100",
1270
+ className: "w-14",
1271
+ value: hsv?.s ?? 0,
1272
+ onChange: onHsvChannelChange("s", 100),
1273
+ disabled: context.disabled
1274
+ }
1275
+ ),
1276
+ /* @__PURE__ */ jsxRuntime.jsx(
1277
+ InputGroupItem,
1278
+ {
1279
+ "aria-label": "Brightness percentage (0-100)",
1280
+ position: withoutAlpha ? "last" : "middle",
1281
+ ...inputProps,
1282
+ placeholder: "0",
1283
+ inputMode: "numeric",
1284
+ pattern: "[0-9]*",
1285
+ min: "0",
1286
+ max: "100",
1287
+ className: "w-14",
1288
+ value: hsv?.v ?? 0,
1289
+ onChange: onHsvChannelChange("v", 100),
1290
+ disabled: context.disabled
1291
+ }
1292
+ ),
1293
+ !withoutAlpha && /* @__PURE__ */ jsxRuntime.jsx(
1294
+ InputGroupItem,
1295
+ {
1296
+ "aria-label": "Alpha transparency percentage",
1297
+ position: "last",
1298
+ ...inputProps,
1299
+ placeholder: "100",
1300
+ inputMode: "numeric",
1301
+ pattern: "[0-9]*",
1302
+ min: "0",
1303
+ max: "100",
1304
+ className: "w-14",
1305
+ value: alphaValue,
1306
+ onChange: onAlphaChange,
1307
+ disabled: context.disabled
1308
+ }
1309
+ )
1310
+ ] });
1311
+ }
1312
+
1313
+ // src/components/stepper/stepper.constants.ts
1314
+ var STEPPER_ROOT_NAME = "Stepper";
1315
+ var STEPPER_NAV_NAME = "StepperNav";
1316
+ var STEPPER_ITEM_NAME = "StepperItem";
1317
+ var STEPPER_TRIGGER_NAME = "StepperTrigger";
1318
+ var STEPPER_INDICATOR_NAME = "StepperIndicator";
1319
+ var STEPPER_TITLE_NAME = "StepperTitle";
1320
+ var STEPPER_DESCRIPTION_NAME = "StepperDescription";
1321
+ var STEPPER_CONTENT_NAME = "StepperContent";
1322
+ var STEPPER_PREV_TRIGGER_NAME = "StepperPrevTrigger";
1323
+ var STEPPER_NEXT_TRIGGER_NAME = "StepperNextTrigger";
1324
+ var STEPPER_ENTRY_FOCUS = "stepperFocusGroup.onEntryFocus";
1325
+ var STEPPER_EVENT_OPTIONS = { bubbles: false, cancelable: true };
1326
+ var STEPPER_ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
1327
+ var STEPPER_MAP_KEY_TO_FOCUS_INTENT = {
1328
+ ArrowLeft: "prev",
1329
+ ArrowUp: "prev",
1330
+ ArrowRight: "next",
1331
+ ArrowDown: "next",
1332
+ PageUp: "first",
1333
+ Home: "first",
1334
+ PageDown: "last",
1335
+ End: "last"
1336
+ };
1337
+
1338
+ // src/components/stepper/stepper.context.tsx
1339
+ var StepperContext = React16__namespace.createContext(null);
1340
+ function useStepperContext(consumerName) {
1341
+ const context = React16__namespace.useContext(StepperContext);
1342
+ if (!context) {
1343
+ throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ROOT_NAME}\``);
1344
+ }
1345
+ return context;
1346
+ }
1347
+ function createStepperStore(listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate) {
1348
+ const store = {
1349
+ subscribe: (cb) => {
1350
+ if (listenersRef.current) {
1351
+ listenersRef.current.add(cb);
1352
+ return () => listenersRef.current?.delete(cb);
1353
+ }
1354
+ return () => {
1355
+ };
1356
+ },
1357
+ getState: () => stateRef.current ?? {
1358
+ steps: /* @__PURE__ */ new Map(),
1359
+ value: void 0
1360
+ },
1361
+ setState: (key, value) => {
1362
+ const state = stateRef.current;
1363
+ if (!state || Object.is(state[key], value)) return;
1364
+ if (key === "value" && typeof value === "string") {
1365
+ state.value = value;
1366
+ onValueChange?.(value);
1367
+ } else {
1368
+ state[key] = value;
1369
+ }
1370
+ store.notify();
1371
+ },
1372
+ setStateWithValidation: async (value, direction) => {
1373
+ if (!onValidate) {
1374
+ store.setState("value", value);
1375
+ return true;
1376
+ }
1377
+ try {
1378
+ const isValid = await onValidate(value, direction);
1379
+ if (isValid) {
1380
+ store.setState("value", value);
1381
+ }
1382
+ return isValid;
1383
+ } catch {
1384
+ return false;
1385
+ }
1386
+ },
1387
+ hasValidation: () => !!onValidate,
1388
+ addStep: (newStep) => {
1389
+ const state = stateRef.current;
1390
+ if (state) {
1391
+ state.steps = new Map(state.steps);
1392
+ state.steps.set(newStep.value, newStep);
1393
+ onValueAdd?.(newStep.value);
1394
+ store.notify();
1395
+ }
1396
+ },
1397
+ removeStep: (value) => {
1398
+ const state = stateRef.current;
1399
+ if (state) {
1400
+ state.steps = new Map(state.steps);
1401
+ state.steps.delete(value);
1402
+ onValueRemove?.(value);
1403
+ store.notify();
1404
+ }
1405
+ },
1406
+ setStep: ({ value, disabled, loading, completed }) => {
1407
+ const state = stateRef.current;
1408
+ if (state) {
1409
+ const step = state.steps.get(value);
1410
+ if (step) {
1411
+ const updatedStep = { ...step, completed, disabled, loading };
1412
+ state.steps = new Map(state.steps);
1413
+ state.steps.set(value, updatedStep);
1414
+ if (completed !== step.completed) {
1415
+ onValueComplete?.(value, completed);
1416
+ }
1417
+ store.notify();
1418
+ }
1419
+ }
1420
+ },
1421
+ notify: () => {
1422
+ if (listenersRef.current) {
1423
+ for (const cb of listenersRef.current) {
1424
+ cb();
1425
+ }
1426
+ }
1427
+ }
1428
+ };
1429
+ return store;
1430
+ }
1431
+ var StepperStoreContext = React16__namespace.createContext(null);
1432
+ function useStepperStoreContext(consumerName) {
1433
+ const context = React16__namespace.useContext(StepperStoreContext);
1434
+ if (!context) {
1435
+ throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ROOT_NAME}\``);
1436
+ }
1437
+ return context;
1438
+ }
1439
+ function useStepperStore(selector) {
1440
+ const store = useStepperStoreContext("useStore");
1441
+ const getSnapshot = React16__namespace.useCallback(() => selector(store.getState()), [selector, store]);
1442
+ return React16__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
1443
+ }
1444
+ function Stepper({
1445
+ value,
1446
+ defaultValue,
1447
+ onValueChange,
1448
+ onValueComplete,
1449
+ onValueAdd,
1450
+ onValueRemove,
1451
+ onValidate,
1452
+ id: idProp,
1453
+ dir: dirProp,
1454
+ orientation = "horizontal",
1455
+ activationMode = "automatic",
1456
+ asChild,
1457
+ disabled = false,
1458
+ nonInteractive = false,
1459
+ loop = false,
1460
+ className,
1461
+ indicators = {},
1462
+ ...rootProps
1463
+ }) {
1464
+ const id = React16__namespace.useId();
1465
+ const rootId = idProp ?? id;
1466
+ const listenersRef = chunkN4TYSZSU_cjs.useLazyRef(() => /* @__PURE__ */ new Set());
1467
+ const stateRef = chunkN4TYSZSU_cjs.useLazyRef(() => ({
1468
+ steps: /* @__PURE__ */ new Map(),
1469
+ value: value ?? defaultValue
1470
+ }));
1471
+ const store = React16__namespace.useMemo(
1472
+ () => createStepperStore(listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate),
1473
+ [listenersRef, stateRef, onValueChange, onValueComplete, onValueAdd, onValueRemove, onValidate]
1474
+ );
1475
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
1476
+ if (value !== void 0) {
1477
+ store.setState("value", value);
1478
+ }
1479
+ }, [value]);
1480
+ const dir = chunkMNDQXDV4_cjs.useDirection(dirProp);
1481
+ const contextValue = React16__namespace.useMemo(
1482
+ () => ({
1483
+ id: rootId,
1484
+ dir,
1485
+ orientation,
1486
+ activationMode,
1487
+ disabled,
1488
+ nonInteractive,
1489
+ loop,
1490
+ indicators
1491
+ }),
1492
+ [rootId, dir, orientation, activationMode, disabled, nonInteractive, loop, indicators]
1493
+ );
1494
+ const RootPrimitive = asChild ? reactSlot.Slot : "div";
1495
+ return /* @__PURE__ */ jsxRuntime.jsx(StepperStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxRuntime.jsx(StepperContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
1496
+ RootPrimitive,
1497
+ {
1498
+ id: rootId,
1499
+ "data-disabled": disabled ? "" : void 0,
1500
+ "data-orientation": orientation,
1501
+ "data-slot": "stepper",
1502
+ dir,
1503
+ ...rootProps,
1504
+ className: chunkH2BWO3SI_cjs.cn("flex w-full flex-col gap-4 data-[orientation=vertical]:flex-row", className)
1505
+ }
1506
+ ) }) });
1507
+ }
1508
+
1509
+ // src/components/stepper/stepper.types.ts
1510
+ var StepperFocusIntent = {
1511
+ FIRST: "first",
1512
+ LAST: "last",
1513
+ PREV: "prev",
1514
+ NEXT: "next"
1515
+ };
1516
+ var StepperOrientation = {
1517
+ HORIZONTAL: "horizontal",
1518
+ VERTICAL: "vertical"
1519
+ };
1520
+ var StepperNavigationDirection = {
1521
+ NEXT: "next",
1522
+ PREV: "prev"
1523
+ };
1524
+ var StepperActivationMode = {
1525
+ AUTOMATIC: "automatic",
1526
+ MANUAL: "manual"
1527
+ };
1528
+ var StepperDataState = {
1529
+ INACTIVE: "inactive",
1530
+ ACTIVE: "active",
1531
+ COMPLETED: "completed"
1532
+ };
1533
+ var StepperFocusContext = React16__namespace.createContext(null);
1534
+ function useStepperFocusContext(consumerName) {
1535
+ const context = React16__namespace.useContext(StepperFocusContext);
1536
+ if (!context) {
1537
+ throw new Error(`\`${consumerName}\` must be used within \`FocusProvider\``);
1538
+ }
1539
+ return context;
1540
+ }
1541
+
1542
+ // src/components/stepper/stepper.utils.tsx
1543
+ function focusFirst(candidates, preventScroll = false) {
1544
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
1545
+ for (const candidateRef of candidates) {
1546
+ const candidate = candidateRef.current;
1547
+ if (!candidate) continue;
1548
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
1549
+ candidate.focus({ preventScroll });
1550
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
1551
+ }
1552
+ }
1553
+ function getDataState(value, itemValue, stepState, steps, variant = "item") {
1554
+ const stepKeys = Array.from(steps.keys());
1555
+ const currentIndex = stepKeys.indexOf(itemValue);
1556
+ if (stepState?.completed) {
1557
+ return StepperDataState.COMPLETED;
1558
+ }
1559
+ if (value === itemValue) {
1560
+ return variant === "separator" ? StepperDataState.INACTIVE : StepperDataState.ACTIVE;
1561
+ }
1562
+ if (value) {
1563
+ const activeIndex = stepKeys.indexOf(value);
1564
+ if (activeIndex > currentIndex) {
1565
+ return StepperDataState.COMPLETED;
1566
+ }
1567
+ }
1568
+ return StepperDataState.INACTIVE;
1569
+ }
1570
+ function getId(id, variant, value) {
1571
+ return `${id}-${variant}-${value}`;
1572
+ }
1573
+ function wrapArray(array, startIndex) {
1574
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
1575
+ }
1576
+ function getDirectionAwareKey(key, dir) {
1577
+ if (dir !== "rtl") return key;
1578
+ return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
1579
+ }
1580
+ function getFocusIntent(event, dir, orientation) {
1581
+ const key = getDirectionAwareKey(event.key, dir);
1582
+ if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
1583
+ if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
1584
+ return STEPPER_MAP_KEY_TO_FOCUS_INTENT[key];
1585
+ }
1586
+ function StepperNav({ className, children, asChild, ref, ...listProps }) {
1587
+ const context = useStepperContext(STEPPER_NAV_NAME);
1588
+ const orientation = context.orientation;
1589
+ const currentValue = useStepperStore((state) => state.value);
1590
+ const [tabStopId, setTabStopId] = React16__namespace.useState(null);
1591
+ const [isTabbingBackOut, setIsTabbingBackOut] = React16__namespace.useState(false);
1592
+ const [focusableItemCount, setFocusableItemCount] = React16__namespace.useState(0);
1593
+ const isClickFocusRef = React16__namespace.useRef(false);
1594
+ const itemsRef = React16__namespace.useRef(/* @__PURE__ */ new Map());
1595
+ const listRef = React16__namespace.useRef(null);
1596
+ const composedRef = chunkMNDQXDV4_cjs.useComposedRefs(ref, listRef);
1597
+ const onItemFocus = React16__namespace.useCallback((tabStopId2) => {
1598
+ setTabStopId(tabStopId2);
1599
+ }, []);
1600
+ const onItemShiftTab = React16__namespace.useCallback(() => {
1601
+ setIsTabbingBackOut(true);
1602
+ }, []);
1603
+ const onFocusableItemAdd = React16__namespace.useCallback(() => {
1604
+ setFocusableItemCount((prevCount) => prevCount + 1);
1605
+ }, []);
1606
+ const onFocusableItemRemove = React16__namespace.useCallback(() => {
1607
+ setFocusableItemCount((prevCount) => prevCount - 1);
1608
+ }, []);
1609
+ const onItemRegister = React16__namespace.useCallback((item) => {
1610
+ itemsRef.current.set(item.id, item);
1611
+ }, []);
1612
+ const onItemUnregister = React16__namespace.useCallback((id) => {
1613
+ itemsRef.current.delete(id);
1614
+ }, []);
1615
+ const getItems = React16__namespace.useCallback(() => {
1616
+ return Array.from(itemsRef.current.values()).filter((item) => item.ref.current).sort((a, b) => {
1617
+ const elementA = a.ref.current;
1618
+ const elementB = b.ref.current;
1619
+ if (!elementA || !elementB) return 0;
1620
+ const position = elementA.compareDocumentPosition(elementB);
1621
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
1622
+ return -1;
1623
+ }
1624
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) {
1625
+ return 1;
1626
+ }
1627
+ return 0;
1628
+ });
1629
+ }, []);
1630
+ const onBlur = React16__namespace.useCallback(
1631
+ (event) => {
1632
+ listProps.onBlur?.(event);
1633
+ if (event.defaultPrevented) return;
1634
+ setIsTabbingBackOut(false);
1635
+ },
1636
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1637
+ [listProps.onBlur]
1638
+ );
1639
+ const onFocus = React16__namespace.useCallback(
1640
+ (event) => {
1641
+ listProps.onFocus?.(event);
1642
+ if (event.defaultPrevented) return;
1643
+ const isKeyboardFocus = !isClickFocusRef.current;
1644
+ if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
1645
+ const entryFocusEvent = new CustomEvent(STEPPER_ENTRY_FOCUS, STEPPER_EVENT_OPTIONS);
1646
+ event.currentTarget.dispatchEvent(entryFocusEvent);
1647
+ if (!entryFocusEvent.defaultPrevented) {
1648
+ const items = Array.from(itemsRef.current.values()).filter((item) => !item.disabled);
1649
+ const selectedItem = currentValue ? items.find((item) => item.value === currentValue) : void 0;
1650
+ const activeItem = items.find((item) => item.active);
1651
+ const currentItem = items.find((item) => item.id === tabStopId);
1652
+ const candidateItems = [selectedItem, activeItem, currentItem, ...items].filter(
1653
+ Boolean
1654
+ );
1655
+ const candidateRefs = candidateItems.map((item) => item.ref);
1656
+ focusFirst(candidateRefs, false);
1657
+ }
1658
+ }
1659
+ isClickFocusRef.current = false;
1660
+ },
1661
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1662
+ [listProps.onFocus, isTabbingBackOut, currentValue, tabStopId]
1663
+ );
1664
+ const onMouseDown = React16__namespace.useCallback(
1665
+ (event) => {
1666
+ listProps.onMouseDown?.(event);
1667
+ if (event.defaultPrevented) return;
1668
+ isClickFocusRef.current = true;
1669
+ },
1670
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1671
+ [listProps.onMouseDown]
1672
+ );
1673
+ const focusContextValue = React16__namespace.useMemo(
1674
+ () => ({
1675
+ tabStopId,
1676
+ onItemFocus,
1677
+ onItemShiftTab,
1678
+ onFocusableItemAdd,
1679
+ onFocusableItemRemove,
1680
+ onItemRegister,
1681
+ onItemUnregister,
1682
+ getItems
1683
+ }),
1684
+ [
1685
+ tabStopId,
1686
+ onItemFocus,
1687
+ onItemShiftTab,
1688
+ onFocusableItemAdd,
1689
+ onFocusableItemRemove,
1690
+ onItemRegister,
1691
+ onItemUnregister,
1692
+ getItems
1693
+ ]
1694
+ );
1695
+ const StepperNavPrimitive = asChild ? reactSlot.Slot : "nav";
1696
+ return /* @__PURE__ */ jsxRuntime.jsx(StepperFocusContext.Provider, { value: focusContextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
1697
+ StepperNavPrimitive,
1698
+ {
1699
+ role: "tablist",
1700
+ "data-slot": "stepper-nav",
1701
+ "aria-orientation": orientation,
1702
+ "data-orientation": orientation,
1703
+ dir: context.dir,
1704
+ tabIndex: isTabbingBackOut || focusableItemCount === 0 ? -1 : 0,
1705
+ ref: composedRef,
1706
+ onBlur,
1707
+ onFocus,
1708
+ onMouseDown,
1709
+ className: chunkH2BWO3SI_cjs.cn(
1710
+ "group/stepper-nav inline-flex gap-4",
1711
+ "data-[orientation=horizontal]:w-full data-[orientation=horizontal]:flex-row data-[orientation=vertical]:flex-col",
1712
+ className
1713
+ ),
1714
+ ...listProps,
1715
+ children
1716
+ }
1717
+ ) });
1718
+ }
1719
+ var StepperItemContext = React16__namespace.createContext(null);
1720
+ function useStepperItemContext(consumerName) {
1721
+ const context = React16__namespace.useContext(StepperItemContext);
1722
+ if (!context) {
1723
+ throw new Error(`\`${consumerName}\` must be used within \`${STEPPER_ITEM_NAME}\``);
1724
+ }
1725
+ return context;
1726
+ }
1727
+ function StepperItem({
1728
+ value: itemValue,
1729
+ completed = false,
1730
+ disabled = false,
1731
+ loading = false,
1732
+ asChild,
1733
+ className,
1734
+ children,
1735
+ ...props
1736
+ }) {
1737
+ const { orientation, dir } = useStepperContext(STEPPER_ITEM_NAME);
1738
+ const store = useStepperStoreContext(STEPPER_ITEM_NAME);
1739
+ const value = useStepperStore((state) => state.value);
1740
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
1741
+ store.addStep({ value: itemValue, completed, disabled, loading });
1742
+ return () => {
1743
+ store.removeStep(itemValue);
1744
+ };
1745
+ }, [itemValue, completed, disabled, loading]);
1746
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
1747
+ store.setStep({ value: itemValue, completed, disabled, loading });
1748
+ }, [itemValue, completed, disabled, loading]);
1749
+ const stepState = useStepperStore((state) => state.steps.get(itemValue));
1750
+ const steps = useStepperStore((state) => state.steps);
1751
+ const dataState = getDataState(value, itemValue, stepState, steps);
1752
+ const itemContextValue = React16__namespace.useMemo(
1753
+ () => ({
1754
+ value: itemValue,
1755
+ stepState
1756
+ }),
1757
+ [itemValue, stepState]
1758
+ );
1759
+ const StepperItemPrimitive = asChild ? reactSlot.Slot : "div";
1760
+ return /* @__PURE__ */ jsxRuntime.jsx(StepperItemContext.Provider, { value: itemContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
1761
+ StepperItemPrimitive,
1762
+ {
1763
+ "data-disabled": stepState?.disabled ? "" : void 0,
1764
+ "data-orientation": orientation,
1765
+ "data-state": dataState,
1766
+ "data-slot": "stepper-item",
1767
+ dir,
1768
+ className: chunkH2BWO3SI_cjs.cn(
1769
+ "group/step flex flex-1 flex-col justify-end data-[disabled]:opacity-50",
1770
+ "",
1771
+ // "group-data-[orientation=horizontal]/stepper-nav:flex-row group-data-[orientation=vertical]/stepper-nav:flex-col",
1772
+ className
1773
+ ),
1774
+ ...props,
1775
+ children: [
1776
+ children,
1777
+ /* @__PURE__ */ jsxRuntime.jsx(
1778
+ "div",
1779
+ {
1780
+ "data-state": dataState,
1781
+ className: chunkH2BWO3SI_cjs.cn(
1782
+ "bg-border h-1 w-full transition-colors duration-500",
1783
+ "data-[state=active]:bg-primary data-[state=completed]:bg-success"
1784
+ )
1785
+ }
1786
+ )
1787
+ ]
1788
+ }
1789
+ ) });
1790
+ }
1791
+ function StepperTrigger({ asChild, disabled, className, ref, ...triggerProps }) {
1792
+ const context = useStepperContext(STEPPER_TRIGGER_NAME);
1793
+ const itemContext = useStepperItemContext(STEPPER_TRIGGER_NAME);
1794
+ const store = useStepperStoreContext(STEPPER_TRIGGER_NAME);
1795
+ const focusContext = useStepperFocusContext(STEPPER_TRIGGER_NAME);
1796
+ const value = useStepperStore((state) => state.value);
1797
+ const itemValue = itemContext.value;
1798
+ const stepState = useStepperStore((state) => state.steps.get(itemValue));
1799
+ const activationMode = context.activationMode;
1800
+ const orientation = context.orientation;
1801
+ const loop = context.loop;
1802
+ const steps = useStepperStore((state) => state.steps);
1803
+ const stepIndex = Array.from(steps.keys()).indexOf(itemValue);
1804
+ const stepPosition = stepIndex + 1;
1805
+ const stepCount = steps.size;
1806
+ const triggerId = getId(context.id, "trigger", itemValue);
1807
+ const contentId = getId(context.id, "content", itemValue);
1808
+ const titleId = getId(context.id, "title", itemValue);
1809
+ const descriptionId = getId(context.id, "description", itemValue);
1810
+ const isDisabled = context.disabled || stepState?.disabled || disabled;
1811
+ const isActive = value === itemValue;
1812
+ const isTabStop = focusContext.tabStopId === triggerId;
1813
+ const dataState = getDataState(value, itemValue, stepState, steps);
1814
+ const triggerRef = React16__namespace.useRef(null);
1815
+ const composedRef = chunkMNDQXDV4_cjs.useComposedRefs(ref, triggerRef);
1816
+ const isArrowKeyPressedRef = React16__namespace.useRef(false);
1817
+ const isMouseClickRef = React16__namespace.useRef(false);
1818
+ React16__namespace.useEffect(() => {
1819
+ function onKeyDown2(event) {
1820
+ if (STEPPER_ARROW_KEYS.includes(event.key)) {
1821
+ isArrowKeyPressedRef.current = true;
1822
+ }
1823
+ }
1824
+ function onKeyUp() {
1825
+ isArrowKeyPressedRef.current = false;
1826
+ }
1827
+ document.addEventListener("keydown", onKeyDown2);
1828
+ document.addEventListener("keyup", onKeyUp);
1829
+ return () => {
1830
+ document.removeEventListener("keydown", onKeyDown2);
1831
+ document.removeEventListener("keyup", onKeyUp);
1832
+ };
1833
+ }, []);
1834
+ chunkN4TYSZSU_cjs.useIsomorphicLayoutEffect(() => {
1835
+ focusContext.onItemRegister({
1836
+ id: triggerId,
1837
+ ref: triggerRef,
1838
+ value: itemValue,
1839
+ active: isTabStop,
1840
+ disabled: !!isDisabled
1841
+ });
1842
+ if (!isDisabled) {
1843
+ focusContext.onFocusableItemAdd();
1844
+ }
1845
+ return () => {
1846
+ focusContext.onItemUnregister(triggerId);
1847
+ if (!isDisabled) {
1848
+ focusContext.onFocusableItemRemove();
1849
+ }
1850
+ };
1851
+ }, [focusContext, triggerId, itemValue, isTabStop, isDisabled]);
1852
+ const onClick = React16__namespace.useCallback(
1853
+ async (event) => {
1854
+ triggerProps.onClick?.(event);
1855
+ if (event.defaultPrevented) return;
1856
+ if (!isDisabled && !context.nonInteractive) {
1857
+ const currentStepIndex = Array.from(steps.keys()).indexOf(value ?? "");
1858
+ const targetStepIndex = Array.from(steps.keys()).indexOf(itemValue);
1859
+ const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1860
+ await store.setStateWithValidation(itemValue, direction);
1861
+ }
1862
+ },
1863
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1864
+ [isDisabled, context.nonInteractive, store, itemValue, value, steps, triggerProps.onClick]
1865
+ );
1866
+ const onFocus = React16__namespace.useCallback(
1867
+ async (event) => {
1868
+ triggerProps.onFocus?.(event);
1869
+ if (event.defaultPrevented) return;
1870
+ focusContext.onItemFocus(triggerId);
1871
+ const isKeyboardFocus = !isMouseClickRef.current;
1872
+ if (!isActive && !isDisabled && activationMode !== "manual" && !context.nonInteractive && isKeyboardFocus) {
1873
+ const currentStepIndex = Array.from(steps.keys()).indexOf(value || "");
1874
+ const targetStepIndex = Array.from(steps.keys()).indexOf(itemValue);
1875
+ const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1876
+ await store.setStateWithValidation(itemValue, direction);
1877
+ }
1878
+ isMouseClickRef.current = false;
1879
+ },
1880
+ [
1881
+ triggerProps,
1882
+ focusContext,
1883
+ triggerId,
1884
+ isActive,
1885
+ isDisabled,
1886
+ activationMode,
1887
+ context.nonInteractive,
1888
+ steps,
1889
+ value,
1890
+ itemValue,
1891
+ store
1892
+ ]
1893
+ );
1894
+ const onKeyDown = React16__namespace.useCallback(
1895
+ async (event) => {
1896
+ triggerProps.onKeyDown?.(event);
1897
+ if (event.defaultPrevented) return;
1898
+ if (event.key === "Enter" && context.nonInteractive) {
1899
+ event.preventDefault();
1900
+ return;
1901
+ }
1902
+ if ((event.key === "Enter" || event.key === " ") && activationMode === "manual" && !context.nonInteractive) {
1903
+ event.preventDefault();
1904
+ if (!isDisabled && triggerRef.current) {
1905
+ triggerRef.current.click();
1906
+ }
1907
+ return;
1908
+ }
1909
+ if (event.key === "Tab" && event.shiftKey) {
1910
+ focusContext.onItemShiftTab();
1911
+ return;
1912
+ }
1913
+ if (event.target !== event.currentTarget) return;
1914
+ const focusIntent = getFocusIntent(event, context.dir, orientation);
1915
+ if (focusIntent !== void 0) {
1916
+ if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
1917
+ event.preventDefault();
1918
+ const items = focusContext.getItems().filter((item) => !item.disabled);
1919
+ let candidateRefs = items.map((item) => item.ref);
1920
+ if (focusIntent === "last") {
1921
+ candidateRefs.reverse();
1922
+ } else if (focusIntent === "prev" || focusIntent === "next") {
1923
+ if (focusIntent === "prev") candidateRefs.reverse();
1924
+ const currentIndex = candidateRefs.findIndex((ref2) => ref2.current === event.currentTarget);
1925
+ candidateRefs = loop ? wrapArray(candidateRefs, currentIndex + 1) : candidateRefs.slice(currentIndex + 1);
1926
+ }
1927
+ if (store.hasValidation() && candidateRefs.length > 0) {
1928
+ const nextRef = candidateRefs[0];
1929
+ const nextElement = nextRef?.current;
1930
+ const nextItem = items.find((item) => item.ref.current === nextElement);
1931
+ if (nextItem && nextItem.value !== itemValue) {
1932
+ const currentStepIndex = Array.from(steps.keys()).indexOf(value || "");
1933
+ const targetStepIndex = Array.from(steps.keys()).indexOf(nextItem.value);
1934
+ const direction = targetStepIndex > currentStepIndex ? "next" : "prev";
1935
+ if (direction === "next") {
1936
+ const isValid = await store.setStateWithValidation(nextItem.value, direction);
1937
+ if (!isValid) return;
1938
+ } else {
1939
+ store.setState("value", nextItem.value);
1940
+ }
1941
+ queueMicrotask(() => nextElement?.focus());
1942
+ return;
1943
+ }
1944
+ }
1945
+ queueMicrotask(() => focusFirst(candidateRefs));
1946
+ }
1947
+ },
1948
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1949
+ [
1950
+ focusContext,
1951
+ context.nonInteractive,
1952
+ context.dir,
1953
+ activationMode,
1954
+ orientation,
1955
+ loop,
1956
+ isDisabled,
1957
+ triggerProps.onKeyDown,
1958
+ store,
1959
+ itemValue,
1960
+ value,
1961
+ steps
1962
+ ]
1963
+ );
1964
+ const onMouseDown = React16__namespace.useCallback(
1965
+ (event) => {
1966
+ triggerProps.onMouseDown?.(event);
1967
+ if (event.defaultPrevented) {
1968
+ return;
1969
+ }
1970
+ isMouseClickRef.current = true;
1971
+ if (isDisabled) {
1972
+ event.preventDefault();
1973
+ } else {
1974
+ focusContext.onItemFocus(triggerId);
1975
+ }
1976
+ },
1977
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1978
+ [focusContext, triggerId, isDisabled, triggerProps.onMouseDown]
1979
+ );
1980
+ const TriggerPrimitive = asChild ? reactSlot.Slot : "button";
1981
+ return /* @__PURE__ */ jsxRuntime.jsx(
1982
+ TriggerPrimitive,
1983
+ {
1984
+ id: triggerId,
1985
+ role: "tab",
1986
+ type: "button",
1987
+ disabled: isDisabled,
1988
+ tabIndex: isTabStop ? 0 : -1,
1989
+ ref: composedRef,
1990
+ "data-slot": "stepper-trigger",
1991
+ "data-disabled": isDisabled ? "" : void 0,
1992
+ "data-state": dataState,
1993
+ "aria-controls": contentId,
1994
+ "aria-current": isActive ? "step" : void 0,
1995
+ "aria-describedby": `${titleId} ${descriptionId}`,
1996
+ "aria-posinset": stepPosition,
1997
+ "aria-selected": isActive,
1998
+ "aria-setsize": stepCount,
1999
+ className: chunkH2BWO3SI_cjs.cn(
2000
+ "inline-flex w-full cursor-pointer items-center gap-3 rounded text-left transition-colors duration-500 outline-none",
2001
+ "disabled:pointer-events-none",
2002
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
2003
+ className
2004
+ ),
2005
+ onClick,
2006
+ onFocus,
2007
+ onKeyDown,
2008
+ onMouseDown,
2009
+ ...triggerProps
2010
+ }
2011
+ );
2012
+ }
2013
+ function StepperIndicator({ className, children, asChild, ref, ...props }) {
2014
+ const { indicators, dir } = useStepperContext(STEPPER_INDICATOR_NAME);
2015
+ const itemContext = useStepperItemContext(STEPPER_INDICATOR_NAME);
2016
+ const value = useStepperStore((state) => state.value);
2017
+ const itemValue = itemContext.value;
2018
+ const stepState = useStepperStore((state) => state.steps.get(itemValue));
2019
+ const steps = useStepperStore((state) => state.steps);
2020
+ const stepPosition = Array.from(steps.keys()).indexOf(itemValue) + 1;
2021
+ const dataState = getDataState(value, itemValue, stepState, steps);
2022
+ const StepperIndicatorPrimitive = asChild ? reactSlot.Slot : "div";
2023
+ return /* @__PURE__ */ jsxRuntime.jsx(
2024
+ StepperIndicatorPrimitive,
2025
+ {
2026
+ "data-slot": "stepper-indicator",
2027
+ "data-state": dataState,
2028
+ dir,
2029
+ ref,
2030
+ className: chunkH2BWO3SI_cjs.cn(
2031
+ "bg-muted border-border text-muted-foreground relative flex size-6 shrink-0 items-center justify-center self-end overflow-hidden rounded-t border-x border-t text-xs transition-colors duration-500",
2032
+ "data-[state=completed]:bg-success/50 data-[state=completed]:border-success data-[state=completed]:text-success-foreground",
2033
+ "data-[state=active]:bg-primary/50 data-[state=active]:border-primary data-[state=active]:text-primary-foreground",
2034
+ className
2035
+ ),
2036
+ ...props,
2037
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute", children: typeof children === "function" ? children(dataState) : indicators && (itemContext.stepState?.loading && indicators.loading || dataState === "completed" && indicators.completed || dataState === "active" && indicators.active || dataState === "inactive" && indicators.inactive) ? itemContext.stepState?.loading && indicators.loading || dataState === "completed" && indicators.completed || dataState === "active" && indicators.active || dataState === "inactive" && indicators.inactive : children ? children : stepPosition })
2038
+ }
2039
+ );
2040
+ }
2041
+ function StepperTitle({ className, asChild = false, ...props }) {
2042
+ const context = useStepperContext(STEPPER_TITLE_NAME);
2043
+ const itemContext = useStepperItemContext(STEPPER_TITLE_NAME);
2044
+ const titleId = getId(context.id, "title", itemContext.value);
2045
+ const TitlePrimitive = asChild ? reactSlot.Slot : "h3";
2046
+ return /* @__PURE__ */ jsxRuntime.jsx(
2047
+ TitlePrimitive,
2048
+ {
2049
+ id: titleId,
2050
+ "data-slot": "stepper-title",
2051
+ dir: context.dir,
2052
+ className: chunkH2BWO3SI_cjs.cn("text-sm leading-none font-medium", className),
2053
+ ...props
2054
+ }
2055
+ );
2056
+ }
2057
+ function StepperDescription({ className, asChild, ...props }) {
2058
+ const context = useStepperContext(STEPPER_DESCRIPTION_NAME);
2059
+ const itemContext = useStepperItemContext(STEPPER_DESCRIPTION_NAME);
2060
+ const descriptionId = getId(context.id, "description", itemContext.value);
2061
+ const StepperDescriptionPrimitive = asChild ? reactSlot.Slot : "span";
2062
+ return /* @__PURE__ */ jsxRuntime.jsx(
2063
+ StepperDescriptionPrimitive,
2064
+ {
2065
+ id: descriptionId,
2066
+ "data-slot": "stepper-description",
2067
+ dir: context.dir,
2068
+ className: chunkH2BWO3SI_cjs.cn("text-muted-foreground text-sm", className),
2069
+ ...props
2070
+ }
2071
+ );
2072
+ }
2073
+ function StepperPanel({ children, asChild = false, className, ...props }) {
2074
+ const currentValue = useStepperStore((state) => state.value);
2075
+ const StepperPanelPrimitive = asChild ? reactSlot.Slot : "div";
2076
+ return /* @__PURE__ */ jsxRuntime.jsx(
2077
+ StepperPanelPrimitive,
2078
+ {
2079
+ "data-slot": "stepper-panel",
2080
+ "data-state": currentValue,
2081
+ className: chunkH2BWO3SI_cjs.cn("w-full", className),
2082
+ ...props,
2083
+ children
2084
+ }
2085
+ );
2086
+ }
2087
+ function StepperContent({
2088
+ value: valueProp,
2089
+ asChild = false,
2090
+ forceMount = false,
2091
+ className,
2092
+ ...props
2093
+ }) {
2094
+ const context = useStepperContext(STEPPER_CONTENT_NAME);
2095
+ const value = useStepperStore((state) => state.value);
2096
+ const contentId = getId(context.id, "content", valueProp);
2097
+ const triggerId = getId(context.id, "trigger", valueProp);
2098
+ const isActive = value === valueProp;
2099
+ if (!isActive && !forceMount) {
2100
+ return null;
2101
+ }
2102
+ const ContentPrimitive = asChild ? reactSlot.Slot : "div";
2103
+ return /* @__PURE__ */ jsxRuntime.jsx(
2104
+ ContentPrimitive,
2105
+ {
2106
+ id: contentId,
2107
+ role: "tabpanel",
2108
+ "data-state": value,
2109
+ "aria-labelledby": triggerId,
2110
+ "data-slot": "stepper-content",
2111
+ dir: context.dir,
2112
+ className: chunkH2BWO3SI_cjs.cn("w-full", className, !isActive && forceMount && "hidden"),
2113
+ hidden: !isActive && forceMount,
2114
+ ...props
2115
+ }
2116
+ );
2117
+ }
2118
+ function StepperNextTrigger({ asChild = false, onClick, disabled, ...props }) {
2119
+ const store = useStepperStoreContext(STEPPER_NEXT_TRIGGER_NAME);
2120
+ const value = useStepperStore((state) => state.value);
2121
+ const steps = useStepperStore((state) => state.steps);
2122
+ const stepKeys = Array.from(steps.keys());
2123
+ const currentIndex = value ? stepKeys.indexOf(value) : -1;
2124
+ const isDisabled = disabled || currentIndex >= stepKeys.length - 1;
2125
+ const handleClick = React16__namespace.useCallback(
2126
+ async (event) => {
2127
+ onClick?.(event);
2128
+ if (event.defaultPrevented || isDisabled) {
2129
+ return;
2130
+ }
2131
+ const nextIndex = Math.min(currentIndex + 1, stepKeys.length - 1);
2132
+ const nextStepValue = stepKeys[nextIndex];
2133
+ if (nextStepValue) {
2134
+ await store.setStateWithValidation(nextStepValue, "next");
2135
+ }
2136
+ },
2137
+ [onClick, isDisabled, currentIndex, stepKeys, store]
2138
+ );
2139
+ const StepperNextTriggerPrimitive = asChild ? reactSlot.Slot : "button";
2140
+ return /* @__PURE__ */ jsxRuntime.jsx(
2141
+ StepperNextTriggerPrimitive,
2142
+ {
2143
+ type: "button",
2144
+ "data-slot": "stepper-next-trigger",
2145
+ disabled: isDisabled,
2146
+ onClick: handleClick,
2147
+ ...props
2148
+ }
2149
+ );
2150
+ }
2151
+ function StepperPrevTrigger({ asChild = false, disabled, onClick, ...props }) {
2152
+ const store = useStepperStoreContext(STEPPER_PREV_TRIGGER_NAME);
2153
+ const value = useStepperStore((state) => state.value);
2154
+ const steps = useStepperStore((state) => state.steps);
2155
+ const stepKeys = Array.from(steps.keys());
2156
+ const currentIndex = value ? stepKeys.indexOf(value) : -1;
2157
+ const isDisabled = disabled || currentIndex <= 0;
2158
+ const handleClick = React16__namespace.useCallback(
2159
+ async (event) => {
2160
+ onClick?.(event);
2161
+ if (event.defaultPrevented || isDisabled) {
2162
+ return;
2163
+ }
2164
+ const prevIndex = Math.max(currentIndex - 1, 0);
2165
+ const prevStepValue = stepKeys[prevIndex];
2166
+ if (prevStepValue) {
2167
+ store.setState("value", prevStepValue);
2168
+ }
2169
+ },
2170
+ [currentIndex, isDisabled, onClick, stepKeys, store]
2171
+ );
2172
+ const StepperPrevTriggerPrimitive = asChild ? reactSlot.Slot : "button";
2173
+ return /* @__PURE__ */ jsxRuntime.jsx(
2174
+ StepperPrevTriggerPrimitive,
2175
+ {
2176
+ type: "button",
2177
+ "data-slot": "stepper-prev-trigger",
2178
+ disabled: isDisabled,
2179
+ onClick: handleClick,
2180
+ ...props
2181
+ }
2182
+ );
2183
+ }
2184
+ var Toaster = ({ theme = "system", ...props }) => {
2185
+ return /* @__PURE__ */ jsxRuntime.jsx(
2186
+ sonner.Toaster,
2187
+ {
2188
+ className: "group",
2189
+ icons: {
2190
+ success: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheckIcon, { className: "size-4" }),
2191
+ info: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, { className: "size-4" }),
2192
+ warning: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TriangleAlertIcon, { className: "size-4" }),
2193
+ error: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.OctagonXIcon, { className: "size-4" }),
2194
+ loading: /* @__PURE__ */ jsxRuntime.jsx(chunk3WSQRFUY_cjs.Spinner, {})
2195
+ },
2196
+ toastOptions: {
2197
+ classNames: {
2198
+ toast: "!bg-popover !text-popover-foreground !border !border-border !rounded",
2199
+ description: "!text-muted-foreground"
2200
+ }
2201
+ },
2202
+ theme,
2203
+ ...props
2204
+ }
2205
+ );
2206
+ };
2207
+ var buttonVariants = classVarianceAuthority.cva(
2208
+ [
2209
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded text-sm font-medium whitespace-nowrap transition-all outline-none",
2210
+ "disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50",
2211
+ "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
2212
+ "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring",
2213
+ "aria-invalid:ring-error/20 dark:aria-invalid:ring-error/40 aria-invalid:border-error"
2214
+ ],
2215
+ {
2216
+ variants: {
2217
+ variant: {
2218
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
2219
+ error: "bg-error hover:bg-error/90 focus-visible:ring-error/20 dark:focus-visible:ring-error/40 dark:bg-error/60 text-white",
2220
+ outline: "bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs",
2221
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
2222
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
2223
+ link: "text-primary underline-offset-4 hover:underline"
2224
+ },
2225
+ size: {
2226
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
2227
+ sm: "h-8 gap-1.5 rounded px-3 has-[>svg]:px-2.5",
2228
+ lg: "h-10 rounded px-6 has-[>svg]:px-4",
2229
+ icon: "size-9",
2230
+ "icon-sm": "size-8",
2231
+ "icon-lg": "size-10"
2232
+ },
2233
+ fullWidth: {
2234
+ true: "w-full"
2235
+ }
2236
+ },
2237
+ defaultVariants: {
2238
+ variant: "default",
2239
+ size: "default",
2240
+ fullWidth: false
2241
+ }
2242
+ }
2243
+ );
2244
+ function Button({
2245
+ asChild = false,
2246
+ variant = "default",
2247
+ disabled = false,
2248
+ fullWidth = false,
2249
+ loadingPosition: loadingPositionProp = "start",
2250
+ children,
2251
+ type = "button",
2252
+ loading = false,
2253
+ size = "default",
2254
+ endIcon,
2255
+ startIcon,
2256
+ className,
2257
+ ...props
2258
+ }) {
2259
+ const Comp = asChild ? reactSlot.Slot : "button";
2260
+ const isDisabled = disabled || loading;
2261
+ const loadingPosition = size?.startsWith("icon") ? "center" : loadingPositionProp;
2262
+ return /* @__PURE__ */ jsxRuntime.jsx(
2263
+ Comp,
2264
+ {
2265
+ "data-slot": "button",
2266
+ "aria-disabled": isDisabled || void 0,
2267
+ className: chunkH2BWO3SI_cjs.cn(buttonVariants({ fullWidth, size, variant }), className),
2268
+ "data-state": loading ? "loading" : void 0,
2269
+ disabled: isDisabled,
2270
+ role: Comp !== "button" ? "button" : void 0,
2271
+ tabIndex: isDisabled ? -1 : 0,
2272
+ type: Comp === "button" ? type : void 0,
2273
+ "data-size": size,
2274
+ "data-variant": variant,
2275
+ ...props,
2276
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2277
+ ButtonContent,
2278
+ {
2279
+ loading,
2280
+ size,
2281
+ loadingPosition,
2282
+ startIcon,
2283
+ endIcon,
2284
+ asChild,
2285
+ children
2286
+ }
2287
+ )
2288
+ }
2289
+ );
2290
+ }
2291
+ function ButtonContent({
2292
+ children,
2293
+ loading = false,
2294
+ loadingPosition = "start",
2295
+ startIcon,
2296
+ asChild,
2297
+ endIcon,
2298
+ ...props
2299
+ }) {
2300
+ const isStartLoading = loading && loadingPosition === "start";
2301
+ const StartIcon = isStartLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk3WSQRFUY_cjs.Spinner, { "aria-label": "Loading" }) : startIcon || null;
2302
+ const isEndLoading = loading && loadingPosition === "end";
2303
+ const EndIcon = isEndLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk3WSQRFUY_cjs.Spinner, { "aria-label": "Loading" }) : endIcon || null;
2304
+ const isCenterLoading = loading && loadingPosition === "center";
2305
+ return asChild && React16__namespace.isValidElement(children) ? React16__namespace.cloneElement(
2306
+ children,
2307
+ props,
2308
+ /* @__PURE__ */ jsxRuntime.jsxs(React16__namespace.Fragment, { children: [
2309
+ StartIcon,
2310
+ isCenterLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk3WSQRFUY_cjs.Spinner, { "aria-label": "Loading" }) : React16__namespace.isValidElement(children) ? children.props?.children : null,
2311
+ EndIcon
2312
+ ] })
2313
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(React16__namespace.Fragment, { children: [
2314
+ StartIcon,
2315
+ isCenterLoading ? /* @__PURE__ */ jsxRuntime.jsx(chunk3WSQRFUY_cjs.Spinner, { "aria-label": "Loading" }) : children,
2316
+ EndIcon
2317
+ ] });
2318
+ }
2319
+
2320
+ Object.defineProperty(exports, "toast", {
2321
+ enumerable: true,
2322
+ get: function () { return sonner.toast; }
2323
+ });
2324
+ exports.Button = Button;
2325
+ exports.ColorPicker = ColorPicker;
2326
+ exports.ColorPickerAlphaSlider = ColorPickerAlphaSlider;
2327
+ exports.ColorPickerArea = ColorPickerArea;
2328
+ exports.ColorPickerContent = ColorPickerContent;
2329
+ exports.ColorPickerEyeDropper = ColorPickerEyeDropper;
2330
+ exports.ColorPickerFormatSelect = ColorPickerFormatSelect;
2331
+ exports.ColorPickerHueSlider = ColorPickerHueSlider;
2332
+ exports.ColorPickerInput = ColorPickerInput;
2333
+ exports.ColorPickerSwatch = ColorPickerSwatch;
2334
+ exports.ColorPickerTrigger = ColorPickerTrigger;
2335
+ exports.Stepper = Stepper;
2336
+ exports.StepperActivationMode = StepperActivationMode;
2337
+ exports.StepperContent = StepperContent;
2338
+ exports.StepperDataState = StepperDataState;
2339
+ exports.StepperDescription = StepperDescription;
2340
+ exports.StepperFocusIntent = StepperFocusIntent;
2341
+ exports.StepperIndicator = StepperIndicator;
2342
+ exports.StepperItem = StepperItem;
2343
+ exports.StepperNav = StepperNav;
2344
+ exports.StepperNavigationDirection = StepperNavigationDirection;
2345
+ exports.StepperNextTrigger = StepperNextTrigger;
2346
+ exports.StepperOrientation = StepperOrientation;
2347
+ exports.StepperPanel = StepperPanel;
2348
+ exports.StepperPrevTrigger = StepperPrevTrigger;
2349
+ exports.StepperTitle = StepperTitle;
2350
+ exports.StepperTrigger = StepperTrigger;
2351
+ exports.Toaster = Toaster;
2352
+ exports.useColorPickerStore = useColorPickerStore;
2353
+ exports.useStepperContext = useStepperContext;
2354
+ exports.useStepperFocusContext = useStepperFocusContext;
2355
+ exports.useStepperItemContext = useStepperItemContext;