@brightlocal/ui-components 3.4.0 → 3.5.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 (196) hide show
  1. package/AI_USAGE.md +22 -3
  2. package/README.md +177 -109
  3. package/component-meta.json +1061 -102
  4. package/dist/alert-dialog.cjs +1 -1
  5. package/dist/alert-dialog.d.ts +13 -2
  6. package/dist/alert-dialog.d.ts.map +1 -1
  7. package/dist/alert-dialog.js +4 -3
  8. package/dist/banner.cjs +1 -1
  9. package/dist/banner.d.ts +47 -11
  10. package/dist/banner.d.ts.map +1 -1
  11. package/dist/banner.js +156 -79
  12. package/dist/blocks/empty-state.cjs +1 -1
  13. package/dist/blocks/empty-state.d.ts +40 -5
  14. package/dist/blocks/empty-state.d.ts.map +1 -1
  15. package/dist/blocks/empty-state.js +59 -52
  16. package/dist/blocks/input-list.d.ts +1 -0
  17. package/dist/blocks/input-list.d.ts.map +1 -1
  18. package/dist/blocks/sidebar.cjs +1 -1
  19. package/dist/blocks/sidebar.d.ts +12 -6
  20. package/dist/blocks/sidebar.d.ts.map +1 -1
  21. package/dist/blocks/sidebar.js +64 -63
  22. package/dist/button.cjs +1 -1
  23. package/dist/button.d.ts.map +1 -1
  24. package/dist/button.js +47 -43
  25. package/dist/card.cjs +1 -1
  26. package/dist/card.d.ts +12 -0
  27. package/dist/card.d.ts.map +1 -1
  28. package/dist/card.js +115 -97
  29. package/dist/chart.cjs +6 -6
  30. package/dist/chart.d.ts +6 -10
  31. package/dist/chart.d.ts.map +1 -1
  32. package/dist/chart.js +281 -296
  33. package/dist/combobox.cjs +3 -3
  34. package/dist/combobox.d.ts.map +1 -1
  35. package/dist/combobox.js +430 -343
  36. package/dist/command.cjs +1 -1
  37. package/dist/command.d.ts +23 -2
  38. package/dist/command.d.ts.map +1 -1
  39. package/dist/command.js +212 -207
  40. package/dist/count-indicator.cjs +1 -0
  41. package/dist/count-indicator.d.ts +85 -0
  42. package/dist/count-indicator.d.ts.map +1 -0
  43. package/dist/count-indicator.js +72 -0
  44. package/dist/data-table.cjs +1 -1
  45. package/dist/data-table.d.ts +101 -11
  46. package/dist/data-table.d.ts.map +1 -1
  47. package/dist/data-table.js +593 -523
  48. package/dist/dialog.cjs +1 -1
  49. package/dist/dialog.d.ts +26 -3
  50. package/dist/dialog.d.ts.map +1 -1
  51. package/dist/dialog.js +62 -47
  52. package/dist/drawer.cjs +1 -1
  53. package/dist/drawer.d.ts +8 -4
  54. package/dist/drawer.d.ts.map +1 -1
  55. package/dist/drawer.js +37 -38
  56. package/dist/file-upload.cjs +1 -0
  57. package/dist/file-upload.d.ts +546 -0
  58. package/dist/file-upload.d.ts.map +1 -0
  59. package/dist/file-upload.js +1103 -0
  60. package/dist/global-layout.cjs +1 -1
  61. package/dist/global-layout.d.ts +7 -2
  62. package/dist/global-layout.d.ts.map +1 -1
  63. package/dist/global-layout.js +52 -52
  64. package/dist/hooks/use-file-dropzone.cjs +1 -0
  65. package/dist/hooks/use-file-dropzone.d.ts +75 -0
  66. package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
  67. package/dist/hooks/use-file-dropzone.js +133 -0
  68. package/dist/hover-card.cjs +1 -1
  69. package/dist/hover-card.d.ts +29 -16
  70. package/dist/hover-card.d.ts.map +1 -1
  71. package/dist/hover-card.js +153 -36
  72. package/dist/index.cjs +1 -1
  73. package/dist/index.d.ts +3 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +676 -640
  76. package/dist/input-chip.cjs +1 -1
  77. package/dist/input-chip.d.ts +30 -1
  78. package/dist/input-chip.d.ts.map +1 -1
  79. package/dist/input-chip.js +131 -115
  80. package/dist/input-group.cjs +1 -1
  81. package/dist/input-group.d.ts +37 -2
  82. package/dist/input-group.d.ts.map +1 -1
  83. package/dist/input-group.js +131 -114
  84. package/dist/input-password.cjs +1 -1
  85. package/dist/input-password.js +6 -6
  86. package/dist/lib/empty-canvas.cjs +1 -1
  87. package/dist/lib/empty-canvas.d.ts +27 -1
  88. package/dist/lib/empty-canvas.d.ts.map +1 -1
  89. package/dist/lib/empty-canvas.js +27 -23
  90. package/dist/lib/empty-chip.cjs +1 -1
  91. package/dist/lib/empty-chip.d.ts +19 -2
  92. package/dist/lib/empty-chip.d.ts.map +1 -1
  93. package/dist/lib/empty-chip.js +14 -9
  94. package/dist/lib/field-aria.cjs +1 -1
  95. package/dist/lib/field-aria.d.ts +4 -4
  96. package/dist/lib/field-aria.d.ts.map +1 -1
  97. package/dist/lib/field-aria.js +7 -5
  98. package/dist/lib/media-viewer-content.cjs +1 -1
  99. package/dist/lib/media-viewer-content.js +1 -1
  100. package/dist/lib/table-internal.cjs +1 -1
  101. package/dist/lib/table-internal.d.ts +19 -0
  102. package/dist/lib/table-internal.d.ts.map +1 -1
  103. package/dist/lib/table-internal.js +22 -7
  104. package/dist/list.cjs +1 -1
  105. package/dist/list.d.ts +13 -0
  106. package/dist/list.d.ts.map +1 -1
  107. package/dist/list.js +103 -82
  108. package/dist/logo-mark.cjs +1 -1
  109. package/dist/logo-mark.d.ts +18 -2
  110. package/dist/logo-mark.d.ts.map +1 -1
  111. package/dist/logo-mark.js +159 -79
  112. package/dist/media-empty.cjs +1 -1
  113. package/dist/media-empty.d.ts +50 -7
  114. package/dist/media-empty.d.ts.map +1 -1
  115. package/dist/media-empty.js +14 -13
  116. package/dist/media-viewer.cjs +1 -1
  117. package/dist/media-viewer.js +6 -6
  118. package/dist/multi-select-filter.cjs +1 -1
  119. package/dist/multi-select-filter.d.ts.map +1 -1
  120. package/dist/multi-select-filter.js +92 -101
  121. package/dist/pagination.cjs +1 -1
  122. package/dist/pagination.d.ts +11 -0
  123. package/dist/pagination.d.ts.map +1 -1
  124. package/dist/pagination.js +17 -17
  125. package/dist/relative-date.d.ts +6 -0
  126. package/dist/relative-date.d.ts.map +1 -1
  127. package/dist/resizable.d.ts +1 -1
  128. package/dist/result-count.cjs +1 -1
  129. package/dist/result-count.d.ts +13 -16
  130. package/dist/result-count.d.ts.map +1 -1
  131. package/dist/result-count.js +24 -33
  132. package/dist/sheet.cjs +1 -1
  133. package/dist/sheet.d.ts +22 -3
  134. package/dist/sheet.d.ts.map +1 -1
  135. package/dist/sheet.js +152 -125
  136. package/dist/single-select-filter.cjs +1 -1
  137. package/dist/single-select-filter.d.ts.map +1 -1
  138. package/dist/single-select-filter.js +67 -76
  139. package/dist/table.cjs +1 -1
  140. package/dist/table.d.ts.map +1 -1
  141. package/dist/table.js +77 -76
  142. package/dist/tabs.cjs +1 -1
  143. package/dist/tabs.d.ts +39 -3
  144. package/dist/tabs.d.ts.map +1 -1
  145. package/dist/tabs.js +127 -76
  146. package/dist/textarea.cjs +1 -1
  147. package/dist/textarea.d.ts +34 -0
  148. package/dist/textarea.d.ts.map +1 -1
  149. package/dist/textarea.js +115 -19
  150. package/dist/tooltip.cjs +1 -1
  151. package/dist/tooltip.d.ts.map +1 -1
  152. package/dist/tooltip.js +137 -131
  153. package/dist/typography-text.cjs +1 -1
  154. package/dist/typography-text.d.ts +6 -2
  155. package/dist/typography-text.d.ts.map +1 -1
  156. package/dist/typography-text.js +14 -13
  157. package/package.json +3 -4
  158. package/src/blocks/empty-state.tsx +108 -48
  159. package/src/blocks/input-list.tsx +1 -0
  160. package/src/blocks/sidebar.tsx +39 -16
  161. package/src/components/alert-dialog.tsx +18 -2
  162. package/src/components/banner.tsx +247 -68
  163. package/src/components/button.tsx +27 -10
  164. package/src/components/card.tsx +89 -7
  165. package/src/components/chart.tsx +47 -67
  166. package/src/components/combobox.tsx +221 -12
  167. package/src/components/command.tsx +83 -37
  168. package/src/components/count-indicator.tsx +188 -0
  169. package/src/components/data-table.tsx +506 -159
  170. package/src/components/dialog.tsx +74 -5
  171. package/src/components/drawer.tsx +52 -32
  172. package/src/components/file-upload.tsx +2574 -0
  173. package/src/components/global-layout.tsx +18 -5
  174. package/src/components/hover-card.tsx +395 -65
  175. package/src/components/input-chip.tsx +67 -2
  176. package/src/components/input-group.tsx +89 -6
  177. package/src/components/list.tsx +40 -3
  178. package/src/components/logo-mark.tsx +109 -25
  179. package/src/components/media-empty.tsx +62 -7
  180. package/src/components/multi-select-filter.tsx +9 -16
  181. package/src/components/pagination.tsx +15 -2
  182. package/src/components/relative-date.tsx +6 -0
  183. package/src/components/result-count.tsx +27 -54
  184. package/src/components/sheet.tsx +86 -8
  185. package/src/components/single-select-filter.tsx +9 -16
  186. package/src/components/table.tsx +16 -1
  187. package/src/components/tabs.tsx +223 -41
  188. package/src/components/textarea.tsx +271 -4
  189. package/src/components/tooltip.tsx +29 -2
  190. package/src/components/typography-text.tsx +7 -2
  191. package/src/hooks/use-file-dropzone.ts +325 -0
  192. package/src/index.ts +3 -0
  193. package/src/lib/empty-canvas.tsx +47 -20
  194. package/src/lib/empty-chip.tsx +38 -3
  195. package/src/lib/field-aria.tsx +11 -6
  196. package/src/lib/table-internal.ts +38 -0
@@ -0,0 +1,1103 @@
1
+ "use client";
2
+ import { composeEventHandlers as X } from "./lib/compose-event-handlers.js";
3
+ import * as o from "react";
4
+ import { Check as Qe, CircleX as Ze, File as et, FileCode as tt, FileImage as at, FileJson as rt, FileSpreadsheet as st, FileText as ot, TriangleAlert as he, X as je } from "@brightlocal/icons";
5
+ import { cn as z } from "@brightlocal/ui-components/lib/utils";
6
+ import { Fragment as xe, jsx as s, jsxs as f } from "react/jsx-runtime";
7
+ import { Slot as nt } from "@radix-ui/react-slot";
8
+ import { cva as $e } from "class-variance-authority";
9
+ import { Button as ve } from "@brightlocal/ui-components/button";
10
+ import { Spinner as it } from "@brightlocal/ui-components/spinner";
11
+ import { Alert as lt, AlertTitle as ct } from "@brightlocal/ui-components/alert";
12
+ import { MediaEmpty as dt } from "@brightlocal/ui-components/media-empty";
13
+ import { LogoMark as Ne } from "@brightlocal/ui-components/logo-mark";
14
+ import { CountIndicator as ut } from "@brightlocal/ui-components/count-indicator";
15
+ import { Progress as pt } from "@brightlocal/ui-components/progress";
16
+ import { TypographyText as C } from "@brightlocal/ui-components/typography-text";
17
+ import { dragItemsMatchAccept as ft, useFileDropzone as mt, validateFile as gt } from "@brightlocal/ui-components/hooks/use-file-dropzone";
18
+ function le(t) {
19
+ if (t < 1024) return `${t} B`;
20
+ const e = [
21
+ "KB",
22
+ "MB",
23
+ "GB"
24
+ ];
25
+ let a = t / 1024, r = 0;
26
+ for (; a >= 1024 && r < e.length - 1; )
27
+ a /= 1024, r++;
28
+ return `${a >= 10 ? String(Math.round(a)) : a.toFixed(1).replace(/\.0$/, "")} ${e[r]}`;
29
+ }
30
+ async function ht(t) {
31
+ if (typeof window > "u") return null;
32
+ if (typeof createImageBitmap == "function") try {
33
+ const e = await createImageBitmap(t), a = {
34
+ width: e.width,
35
+ height: e.height
36
+ };
37
+ return e.close(), a;
38
+ } catch {
39
+ return null;
40
+ }
41
+ return new Promise((e) => {
42
+ const a = URL.createObjectURL(t), r = new window.Image();
43
+ r.onload = () => {
44
+ e({
45
+ width: r.naturalWidth,
46
+ height: r.naturalHeight
47
+ }), URL.revokeObjectURL(a);
48
+ }, r.onerror = () => {
49
+ e(null), URL.revokeObjectURL(a);
50
+ }, r.src = a;
51
+ });
52
+ }
53
+ function vt(t) {
54
+ if (!t) return "";
55
+ const e = [];
56
+ for (const [r, n] of Object.entries(t)) {
57
+ for (const i of n) e.push(i.replace(/^\./, "").toUpperCase());
58
+ if (n.length === 0 && r.includes("/")) {
59
+ const i = r.split("/").pop();
60
+ i && i !== "*" && e.push(i.toUpperCase());
61
+ }
62
+ }
63
+ const a = [...new Set(e)];
64
+ return a.length <= 1 ? a[0] ?? "" : `${a.slice(0, -1).join(", ")} or ${a[a.length - 1]}`;
65
+ }
66
+ function _(t, e) {
67
+ return t.replace(/\{(\w+)\}/g, (a, r) => r in e ? String(e[r]) : a);
68
+ }
69
+ function We(t) {
70
+ return Math.round(Math.min(100, Math.max(0, t)));
71
+ }
72
+ var bt = {
73
+ invalidType: "This type of file isn't supported.",
74
+ invalidTypeWithLabel: "This type of file isn't supported. Use {label}.",
75
+ tooLarge: "This file is {size}. Files need to be {maxSize} or smaller.",
76
+ tooSmall: "This file is {size}. Files need to be at least {minSize}.",
77
+ tooManyFilesOne: "You can add one file. Remove it to add a different one.",
78
+ tooManyFiles: "You've reached the limit of {maxFiles} files. Remove one to add another.",
79
+ imageUnreadable: "We couldn't read this image.",
80
+ imageTooSmall: "This image is {width} × {height} px. Images need to be at least {minWidth} × {minHeight} px.",
81
+ uploadFailed: "Upload failed.",
82
+ fileRemoved: "{name} removed.",
83
+ uploadedOne: "1 file uploaded.",
84
+ uploadedMany: "{n} files uploaded.",
85
+ uploadFailedOne: "1 file failed to upload.",
86
+ uploadFailedMany: "{n} files failed to upload."
87
+ };
88
+ function _e(t) {
89
+ return o.useMemo(() => ({
90
+ ...bt,
91
+ ...t
92
+ }), [t]);
93
+ }
94
+ function ze(t, e, a) {
95
+ const { messages: r } = a;
96
+ switch (e) {
97
+ case "file-invalid-type": {
98
+ const n = a.acceptLabel ?? vt(a.accept);
99
+ return n ? _(r.invalidTypeWithLabel, { label: n }) : r.invalidType;
100
+ }
101
+ case "file-too-large":
102
+ return _(r.tooLarge, {
103
+ size: le(t.size),
104
+ maxSize: le(a.maxSize ?? 0)
105
+ });
106
+ case "file-too-small":
107
+ return _(r.tooSmall, {
108
+ size: le(t.size),
109
+ minSize: le(a.minSize ?? 0)
110
+ });
111
+ case "too-many-files":
112
+ return a.maxFiles === 1 ? r.tooManyFilesOne : _(r.tooManyFiles, { maxFiles: a.maxFiles ?? 0 });
113
+ }
114
+ }
115
+ async function Be(t, e) {
116
+ const a = t.type.startsWith("image/") || !t.type && /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico|tiff?)$/i.test(t.name);
117
+ if (e.minImageSize && a) {
118
+ const r = await ht(t);
119
+ if (!r) return e.messages.imageUnreadable;
120
+ if (r.width < e.minImageSize.width || r.height < e.minImageSize.height) return _(e.messages.imageTooSmall, {
121
+ width: r.width,
122
+ height: r.height,
123
+ minWidth: e.minImageSize.width,
124
+ minHeight: e.minImageSize.height
125
+ });
126
+ }
127
+ if (e.onFileValidate) {
128
+ const r = await e.onFileValidate(t);
129
+ if (r) return r;
130
+ }
131
+ return null;
132
+ }
133
+ var xt = [
134
+ {
135
+ test: (t) => t.startsWith("image/"),
136
+ icon: at
137
+ },
138
+ {
139
+ test: (t, e) => t === "text/csv" || t === "application/vnd.ms-excel" || t === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || e === "csv" || e === "xlsx" || e === "xls",
140
+ icon: st
141
+ },
142
+ {
143
+ test: (t, e) => t === "application/json" || e === "json",
144
+ icon: rt
145
+ },
146
+ {
147
+ test: (t, e) => t === "application/xml" || t === "text/xml" || e === "xml" || e === "html" || e === "htm" || e === "svg",
148
+ icon: tt
149
+ },
150
+ {
151
+ test: (t, e) => t === "application/pdf" || t.startsWith("text/") || e === "pdf" || e === "txt" || e === "md" || e === "doc" || e === "docx" || e === "rtf",
152
+ icon: ot
153
+ }
154
+ ];
155
+ function yt(t) {
156
+ const e = t.type.toLowerCase(), a = t.name.split(".").pop()?.toLowerCase() ?? "";
157
+ for (const r of xt) if (r.test(e, a)) return r.icon;
158
+ return et;
159
+ }
160
+ var Ae = 0;
161
+ function qe() {
162
+ const [t, e] = o.useState(""), a = o.useRef(0);
163
+ return [t, o.useCallback((r) => {
164
+ a.current += 1, e(r + (a.current % 2 === 0 ? "" : " "));
165
+ }, [])];
166
+ }
167
+ var ce = /* @__PURE__ */ new Map();
168
+ function Se(t) {
169
+ const e = ce.get(t);
170
+ if (e) return e.url;
171
+ const a = URL.createObjectURL(t);
172
+ return ce.set(t, {
173
+ url: a,
174
+ refs: 0
175
+ }), a;
176
+ }
177
+ function Ge(t) {
178
+ const e = t && typeof window < "u" ? Se(t) : void 0;
179
+ return o.useEffect(() => {
180
+ if (!t) return;
181
+ Se(t);
182
+ const a = ce.get(t);
183
+ return a.refs++, () => {
184
+ a.refs--, setTimeout(() => {
185
+ a.refs <= 0 && ce.get(t) === a && (URL.revokeObjectURL(a.url), ce.delete(t));
186
+ }, 0);
187
+ };
188
+ }, [t]), e;
189
+ }
190
+ var be = {
191
+ status: "idle",
192
+ progress: 0
193
+ }, Jt = {
194
+ accept: {
195
+ "image/jpeg": [".jpg", ".jpeg"],
196
+ "image/png": [".png"]
197
+ },
198
+ acceptLabel: "JPG or PNG",
199
+ minSize: 10240,
200
+ maxSize: 5242880,
201
+ minImageSize: {
202
+ width: 250,
203
+ height: 250
204
+ }
205
+ }, He = o.createContext(null);
206
+ function O() {
207
+ const t = o.useContext(He);
208
+ if (!t) throw new Error("FileUpload components must be used within a <FileUpload>");
209
+ return t;
210
+ }
211
+ var Ft = o.forwardRef(({ className: t, dataHook: e, accept: a, acceptLabel: r, maxSize: n, minSize: i, maxFiles: l, multiple: d, minImageSize: m, disabled: u = !1, validate: g, onFileValidate: R, value: $, onValueChange: S, onFileReject: M, onFilesChange: P, onUpload: B, messages: Q, trackingEl: F, trackingLabel: Z, children: ye, ...Fe }, q) => {
212
+ const [ke, we] = o.useState([]), Y = $ !== void 0, T = Y ? $ : ke, G = _e(Q), ee = o.useRef(null), [te, ae] = o.useState([]), [Ue, H] = qe(), V = o.useCallback((p) => {
213
+ ae((v) => v.filter((h) => h.id !== p));
214
+ }, []), de = o.useCallback(() => {
215
+ ae([]);
216
+ }, []), [re, ue] = o.useState(() => /* @__PURE__ */ new Map()), I = o.useCallback((p, v) => {
217
+ ue((h) => {
218
+ const k = new Map(h), x = k.get(p) ?? { ...be };
219
+ return k.set(p, {
220
+ ...x,
221
+ ...v
222
+ }), k;
223
+ });
224
+ }, []), K = o.useCallback((p) => re.get(p) ?? be, [re]), J = o.useRef(T);
225
+ o.useEffect(() => {
226
+ const p = J.current.filter((v) => !T.includes(v));
227
+ J.current = T, p.length !== 0 && ue((v) => {
228
+ const h = new Map(v);
229
+ for (const k of p) h.delete(k);
230
+ return h;
231
+ });
232
+ }, [T]);
233
+ const L = o.useRef({
234
+ files: T,
235
+ maxFiles: l,
236
+ minImageSize: m,
237
+ acceptLabel: r,
238
+ accept: a,
239
+ maxSize: n,
240
+ minSize: i,
241
+ messages: G,
242
+ onFileValidate: R,
243
+ onValueChange: S,
244
+ onFileReject: M,
245
+ onFilesChange: P,
246
+ onUpload: B
247
+ });
248
+ o.useEffect(() => {
249
+ L.current = {
250
+ files: T,
251
+ maxFiles: l,
252
+ minImageSize: m,
253
+ acceptLabel: r,
254
+ accept: a,
255
+ maxSize: n,
256
+ minSize: i,
257
+ messages: G,
258
+ onFileValidate: R,
259
+ onValueChange: S,
260
+ onFileReject: M,
261
+ onFilesChange: P,
262
+ onUpload: B
263
+ };
264
+ });
265
+ const A = o.useCallback(async (p) => {
266
+ const v = L.current.onUpload;
267
+ if (!v || p.length === 0) return;
268
+ const { messages: h } = L.current, k = /* @__PURE__ */ new Map();
269
+ for (const w of p) I(w, {
270
+ status: "uploading",
271
+ progress: 0,
272
+ error: void 0
273
+ });
274
+ try {
275
+ await v(p, {
276
+ onProgress: (w, y) => {
277
+ I(w, { progress: We(y) });
278
+ },
279
+ onSuccess: (w) => {
280
+ k.set(w, "success"), I(w, {
281
+ status: "success",
282
+ progress: 100
283
+ });
284
+ },
285
+ onError: (w, y) => {
286
+ k.set(w, "error");
287
+ const b = typeof y == "string" ? y : y?.message;
288
+ I(w, {
289
+ status: "error",
290
+ error: b || h.uploadFailed
291
+ });
292
+ }
293
+ });
294
+ } catch {
295
+ }
296
+ let x = 0;
297
+ for (const w of p) {
298
+ const y = k.get(w);
299
+ y === "error" ? x++ : y === void 0 && (x++, I(w, {
300
+ status: "error",
301
+ error: h.uploadFailed
302
+ }));
303
+ }
304
+ const j = p.length - x, W = [];
305
+ x > 0 && W.push(x === 1 ? h.uploadFailedOne : _(h.uploadFailedMany, { n: x })), j > 0 && W.push(j === 1 ? h.uploadedOne : _(h.uploadedMany, { n: j })), H(W.join(" "));
306
+ }, [I, H]), se = o.useCallback((p) => {
307
+ (async () => {
308
+ const v = L.current, h = [], k = (b, E) => {
309
+ v.onFileReject?.(b, E), Ae += 1, h.push({
310
+ id: String(Ae),
311
+ name: b.name,
312
+ message: E
313
+ });
314
+ };
315
+ for (const { file: b, errors: E } of p.rejectedFiles) {
316
+ const pe = E[0];
317
+ pe && k(b, ze(b, pe, v));
318
+ }
319
+ const x = [];
320
+ for (const b of p.acceptedFiles) {
321
+ const E = await Be(b, v);
322
+ if (E) {
323
+ k(b, E);
324
+ continue;
325
+ }
326
+ x.push(b);
327
+ }
328
+ const j = L.current, W = j.files, w = j.maxFiles !== void 0 ? Math.max(0, j.maxFiles - W.length) : 1 / 0, y = x.slice(0, w);
329
+ for (const b of x.slice(y.length)) k(b, ze(b, "too-many-files", j));
330
+ h.length > 0 && ae((b) => [...b, ...h]), y.length > 0 && (Y || we((b) => [...b, ...y]), j.onValueChange?.([...W, ...y])), j.onFilesChange?.({
331
+ acceptedFiles: y,
332
+ rejectedFiles: p.rejectedFiles
333
+ }), y.length > 0 && j.onUpload && A(y);
334
+ })();
335
+ }, [Y, A]), N = mt({
336
+ accept: a,
337
+ maxSize: n,
338
+ minSize: i,
339
+ maxFiles: void 0,
340
+ multiple: d ?? l !== 1,
341
+ disabled: u,
342
+ validate: g,
343
+ onFilesChange: se
344
+ }), Re = o.useMemo(() => ({
345
+ state: N.state,
346
+ dragActive: N.dragActive,
347
+ disabled: u,
348
+ files: T,
349
+ maxFiles: l,
350
+ openFilePicker: N.openFilePicker,
351
+ dropzoneProps: N.dropzoneProps,
352
+ inputProps: N.inputProps,
353
+ inputRef: N.inputRef,
354
+ rootRef: ee,
355
+ rejections: te,
356
+ dismissRejection: V,
357
+ clearRejections: de,
358
+ announce: H,
359
+ getFileStatus: K,
360
+ messages: G
361
+ }), [
362
+ N,
363
+ u,
364
+ T,
365
+ l,
366
+ te,
367
+ V,
368
+ de,
369
+ H,
370
+ K,
371
+ G
372
+ ]), oe = o.useCallback((p) => {
373
+ ee.current = p, typeof q == "function" ? q(p) : q && (q.current = p);
374
+ }, [q]);
375
+ return /* @__PURE__ */ s(He.Provider, {
376
+ value: Re,
377
+ children: /* @__PURE__ */ f("div", {
378
+ ref: oe,
379
+ className: z("relative flex flex-col gap-3", t),
380
+ "data-hook": e,
381
+ "data-slot": "file-upload",
382
+ "data-tracking-el": F ?? "file-upload",
383
+ "data-tracking-label": Z,
384
+ ...Fe,
385
+ children: [ye, /* @__PURE__ */ s("div", {
386
+ "aria-live": "polite",
387
+ className: "sr-only",
388
+ "data-slot": "file-upload-announcer",
389
+ role: "status",
390
+ children: Ue
391
+ })]
392
+ })
393
+ });
394
+ });
395
+ Ft.displayName = "FileUpload";
396
+ var kt = $e([
397
+ "relative flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6",
398
+ "transition-[border-color,background-color] duration-fast ease-out",
399
+ "outline-none has-[:focus-visible]:shadow-default has-[:focus-visible]:border-transparent",
400
+ "cursor-pointer"
401
+ ], {
402
+ variants: {
403
+ state: {
404
+ idle: "border-input bg-background hover:bg-accent",
405
+ accept: "border-success-mark bg-success-mark/5 dark:bg-success-mark/10",
406
+ reject: "border-destructive bg-destructive/5 dark:bg-destructive/10"
407
+ },
408
+ disabled: { true: "pointer-events-none cursor-not-allowed opacity-50" }
409
+ },
410
+ defaultVariants: {
411
+ state: "idle",
412
+ disabled: !1
413
+ }
414
+ }), wt = o.forwardRef(({ className: t, dataHook: e, ariaLabel: a, children: r, onClick: n, onDragEnter: i, onDragOver: l, onDragLeave: d, onDrop: m, onPaste: u, ...g }, R) => {
415
+ const { state: $, disabled: S, openFilePicker: M, dropzoneProps: P, inputProps: B, inputRef: Q } = O(), F = o.useCallback((Z) => {
416
+ Z.target.closest("button, a, input") || M();
417
+ }, [M]);
418
+ return /* @__PURE__ */ f("div", {
419
+ ref: R,
420
+ "aria-disabled": S ? "true" : void 0,
421
+ className: z(kt({
422
+ state: $,
423
+ disabled: S
424
+ }), t),
425
+ "data-hook": e,
426
+ "data-slot": "file-upload-dropzone",
427
+ "data-state": $,
428
+ onClick: X(n, F),
429
+ onDragEnter: X(i, P.onDragEnter),
430
+ onDragLeave: X(d, P.onDragLeave),
431
+ onDragOver: X(l, P.onDragOver),
432
+ onDrop: X(m, P.onDrop),
433
+ onPaste: X(u, P.onPaste),
434
+ ...g,
435
+ children: [/* @__PURE__ */ s("input", {
436
+ ref: Q,
437
+ ...B,
438
+ "aria-label": a ?? "Upload file",
439
+ "data-hook": e ? `${e}-input` : void 0,
440
+ disabled: S,
441
+ tabIndex: S ? -1 : 0
442
+ }), r]
443
+ });
444
+ });
445
+ wt.displayName = "FileUploadDropzone";
446
+ var Ve = o.forwardRef(({ asChild: t = !1, dataHook: e, onClick: a, children: r, ...n }, i) => {
447
+ const { disabled: l, openFilePicker: d } = O();
448
+ return /* @__PURE__ */ s(t ? nt : "button", {
449
+ ref: i,
450
+ "data-file-upload-trigger": "",
451
+ "data-hook": e,
452
+ "data-slot": "file-upload-trigger",
453
+ disabled: l,
454
+ type: t ? void 0 : "button",
455
+ onClick: X(a, d),
456
+ ...n,
457
+ children: r
458
+ });
459
+ });
460
+ Ve.displayName = "FileUploadTrigger";
461
+ function Je({ children: t }) {
462
+ const { state: e } = O();
463
+ return e !== "idle" ? null : /* @__PURE__ */ s(xe, { children: t });
464
+ }
465
+ Je.displayName = "FileUploadIdle";
466
+ function Xe({ children: t }) {
467
+ const { state: e } = O();
468
+ return e !== "accept" ? null : /* @__PURE__ */ s(xe, { children: t });
469
+ }
470
+ Xe.displayName = "FileUploadAccept";
471
+ function Ye({ children: t }) {
472
+ const { state: e } = O();
473
+ return e !== "reject" ? null : /* @__PURE__ */ s(xe, { children: t });
474
+ }
475
+ Ye.displayName = "FileUploadReject";
476
+ var Ut = o.forwardRef(({ className: t, dataHook: e, icon: a, title: r, description: n, triggerLabel: i, acceptMessage: l, rejectMessage: d, trackingEl: m, trackingLabel: u, ...g }, R) => /* @__PURE__ */ f("div", {
477
+ ref: R,
478
+ className: z("flex flex-col items-center gap-2 text-center", t),
479
+ "data-slot": "file-upload-dropzone-content",
480
+ ...g,
481
+ children: [
482
+ /* @__PURE__ */ f(Je, { children: [
483
+ /* @__PURE__ */ s(Ne, {
484
+ "data-slot": "file-upload-dropzone-icon",
485
+ "data-state": "idle",
486
+ dataHook: `${e}-icon`,
487
+ name: /* @__PURE__ */ s(a, { className: "text-muted-foreground" }),
488
+ shape: "circle",
489
+ size: "lg"
490
+ }),
491
+ /* @__PURE__ */ s(C, {
492
+ dataHook: `${e}-title`,
493
+ children: r
494
+ }),
495
+ /* @__PURE__ */ s(C, {
496
+ color: "muted",
497
+ dataHook: `${e}-description`,
498
+ variant: "body-sm",
499
+ children: n
500
+ }),
501
+ i && /* @__PURE__ */ s(Ve, {
502
+ asChild: !0,
503
+ dataHook: `${e}-trigger`,
504
+ children: /* @__PURE__ */ s(ve, {
505
+ className: "mt-1",
506
+ "data-tracking-el": m,
507
+ "data-tracking-label": u,
508
+ dataHook: `${e}-trigger-btn`,
509
+ size: "sm",
510
+ variant: "outline",
511
+ children: i
512
+ })
513
+ })
514
+ ] }),
515
+ /* @__PURE__ */ f(Xe, { children: [/* @__PURE__ */ s(Ne, {
516
+ "data-slot": "file-upload-dropzone-icon",
517
+ "data-state": "accept",
518
+ dataHook: `${e}-icon`,
519
+ name: /* @__PURE__ */ s(a, {}),
520
+ shape: "circle",
521
+ size: "lg",
522
+ variant: "success"
523
+ }), /* @__PURE__ */ s(C, {
524
+ className: "text-score-strong-ink",
525
+ dataHook: `${e}-accept-message`,
526
+ children: l ?? "Release to upload"
527
+ })] }),
528
+ /* @__PURE__ */ f(Ye, { children: [/* @__PURE__ */ s(Ne, {
529
+ "data-slot": "file-upload-dropzone-icon",
530
+ "data-state": "reject",
531
+ dataHook: `${e}-icon`,
532
+ name: /* @__PURE__ */ s(Ze, {}),
533
+ shape: "circle",
534
+ size: "lg",
535
+ variant: "destructive"
536
+ }), /* @__PURE__ */ s(C, {
537
+ className: "text-score-poor-ink",
538
+ dataHook: `${e}-reject-message`,
539
+ children: d ?? "File not accepted"
540
+ })] })
541
+ ]
542
+ }));
543
+ Ut.displayName = "FileUploadDropzoneContent";
544
+ var Rt = $e("", {
545
+ variants: { variant: {
546
+ list: "flex flex-col gap-2",
547
+ grid: "grid grid-cols-3 gap-2 sm:grid-cols-4 sm:gap-3 xl:grid-cols-5 2xl:grid-cols-6"
548
+ } },
549
+ defaultVariants: { variant: "list" }
550
+ }), Ct = o.forwardRef(({ className: t, dataHook: e, ariaLabel: a, variant: r = "list", children: n, ...i }, l) => /* @__PURE__ */ s("ul", {
551
+ ref: l,
552
+ "aria-label": a ?? "Uploaded files",
553
+ className: z(Rt({ variant: r }), t),
554
+ "data-hook": e,
555
+ "data-slot": "file-upload-list",
556
+ "data-variant": r,
557
+ ...i,
558
+ children: n
559
+ }));
560
+ Ct.displayName = "FileUploadList";
561
+ var Ie = o.forwardRef(({ className: t, dataHook: e, children: a, ...r }, n) => /* @__PURE__ */ s("li", {
562
+ ref: n,
563
+ className: z("flex items-center gap-2", t),
564
+ "data-hook": e,
565
+ "data-slot": "file-upload-item",
566
+ ...r,
567
+ children: a
568
+ }));
569
+ Ie.displayName = "FileUploadItem";
570
+ var Nt = $e("bg-muted text-muted-foreground relative flex items-center justify-center overflow-hidden rounded-md", {
571
+ variants: { size: {
572
+ sm: "size-10 shrink-0",
573
+ lg: "aspect-square w-full"
574
+ } },
575
+ defaultVariants: { size: "sm" }
576
+ }), Me = o.forwardRef(({ className: t, dataHook: e, file: a, size: r = "sm", children: n, ...i }, l) => {
577
+ const d = Ge(a), m = a.type.startsWith("image/");
578
+ return /* @__PURE__ */ f("div", {
579
+ ref: l,
580
+ className: z(Nt({ size: r }), t),
581
+ "data-hook": e,
582
+ "data-size": r,
583
+ "data-slot": "file-upload-item-preview",
584
+ ...i,
585
+ children: [m && d ? /* @__PURE__ */ s("img", {
586
+ alt: a.name,
587
+ className: "size-full object-cover",
588
+ src: d
589
+ }) : o.createElement(yt(a), {
590
+ "aria-hidden": !0,
591
+ size: r === "lg" ? 32 : 20,
592
+ strokeWidth: 1.5
593
+ }), n]
594
+ });
595
+ });
596
+ Me.displayName = "FileUploadItemPreview";
597
+ var Pe = o.forwardRef(({ file: t, dataHook: e, removeAriaLabel: a, onClick: r, children: n, className: i, ...l }, d) => {
598
+ const { rootRef: m, announce: u, messages: g } = O(), R = o.useCallback(($) => {
599
+ if (r?.($), $.defaultPrevented) return;
600
+ u(_(g.fileRemoved, { name: t.name }));
601
+ const S = $.currentTarget.closest("li"), M = S?.nextElementSibling ?? S?.previousElementSibling;
602
+ setTimeout(() => {
603
+ ((M?.isConnected ? M.querySelector("[data-file-upload-remove]") : null) ?? m.current?.querySelector("[data-file-upload-trigger]"))?.focus();
604
+ }, 0);
605
+ }, [
606
+ r,
607
+ t.name,
608
+ m,
609
+ u,
610
+ g.fileRemoved
611
+ ]);
612
+ return /* @__PURE__ */ s("button", {
613
+ ref: d,
614
+ "aria-label": a ?? `Remove ${t.name}`,
615
+ className: z("text-muted-foreground hover:text-foreground duration-fast cursor-pointer rounded-sm transition-colors ease-out", "focus-visible:shadow-default outline-none", "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", i),
616
+ "data-file-upload-remove": "",
617
+ "data-hook": e,
618
+ "data-slot": "file-upload-item-remove",
619
+ type: "button",
620
+ onClick: R,
621
+ ...l,
622
+ children: n
623
+ });
624
+ });
625
+ Pe.displayName = "FileUploadItemRemove";
626
+ var Te = o.forwardRef(({ className: t, dataHook: e, file: a, uploadingLabel: r, successLabel: n, errorLabel: i, ...l }, d) => {
627
+ const { getFileStatus: m } = O(), u = m(a), g = e ?? "file-upload-item-progress";
628
+ return u.status === "idle" ? null : u.status === "uploading" ? /* @__PURE__ */ f("div", {
629
+ ref: d,
630
+ className: z("flex items-center gap-2", t),
631
+ "data-hook": g,
632
+ "data-slot": "file-upload-item-progress",
633
+ "data-status": "uploading",
634
+ ...l,
635
+ children: [/* @__PURE__ */ s(pt, {
636
+ ariaLabel: r ?? "Uploading…",
637
+ className: "flex-1",
638
+ dataHook: `${g}-bar`,
639
+ size: "sm",
640
+ value: u.progress
641
+ }), /* @__PURE__ */ s(C, {
642
+ asChild: !0,
643
+ color: "muted",
644
+ dataHook: `${g}-text`,
645
+ variant: "body-xs",
646
+ children: /* @__PURE__ */ s("span", {
647
+ className: "shrink-0",
648
+ children: r ?? "Uploading…"
649
+ })
650
+ })]
651
+ }) : u.status === "success" ? /* @__PURE__ */ f("div", {
652
+ ref: d,
653
+ className: z("text-label-sm text-success-foreground flex items-center gap-1", t),
654
+ "data-hook": g,
655
+ "data-slot": "file-upload-item-progress",
656
+ "data-status": "success",
657
+ ...l,
658
+ children: [/* @__PURE__ */ s(Qe, {
659
+ "aria-hidden": !0,
660
+ size: 14
661
+ }), n ?? "Uploaded"]
662
+ }) : /* @__PURE__ */ f("div", {
663
+ ref: d,
664
+ className: z("text-label-sm text-destructive-foreground flex items-center gap-1", t),
665
+ "data-hook": g,
666
+ "data-slot": "file-upload-item-progress",
667
+ "data-status": "error",
668
+ ...l,
669
+ children: [/* @__PURE__ */ s(he, {
670
+ "aria-hidden": !0,
671
+ size: 14
672
+ }), i ?? u.error ?? "Upload failed"]
673
+ });
674
+ });
675
+ Te.displayName = "FileUploadItemProgress";
676
+ var zt = o.forwardRef(({ className: t, dataHook: e, file: a, onRemove: r, removeAriaLabel: n, trackingEl: i, trackingLabel: l, ...d }, m) => /* @__PURE__ */ s(Ie, {
677
+ ref: m,
678
+ className: t,
679
+ dataHook: e,
680
+ ...d,
681
+ children: /* @__PURE__ */ f("div", {
682
+ className: "flex w-full flex-col gap-2 rounded-lg border p-3",
683
+ children: [/* @__PURE__ */ f("div", {
684
+ className: "flex items-center gap-3",
685
+ children: [
686
+ /* @__PURE__ */ s(Me, { file: a }),
687
+ /* @__PURE__ */ f("div", {
688
+ className: "min-w-0 flex-1",
689
+ children: [/* @__PURE__ */ s(C, {
690
+ truncate: !0,
691
+ "data-slot": "file-upload-file-name",
692
+ dataHook: `${e}-name`,
693
+ children: a.name
694
+ }), /* @__PURE__ */ s(C, {
695
+ color: "muted",
696
+ "data-slot": "file-upload-file-description",
697
+ dataHook: `${e}-size`,
698
+ variant: "body-sm",
699
+ children: le(a.size)
700
+ })]
701
+ }),
702
+ r && /* @__PURE__ */ s(Pe, {
703
+ "data-tracking-el": i,
704
+ "data-tracking-label": l,
705
+ dataHook: `${e}-remove`,
706
+ file: a,
707
+ removeAriaLabel: n,
708
+ onClick: r,
709
+ children: /* @__PURE__ */ s(je, { size: 16 })
710
+ })
711
+ ]
712
+ }), /* @__PURE__ */ s(Te, { file: a })]
713
+ })
714
+ }));
715
+ zt.displayName = "FileUploadCardItem";
716
+ var St = o.forwardRef(({ className: t, dataHook: e, file: a, onRemove: r, removeAriaLabel: n, showName: i = !1, trackingEl: l, trackingLabel: d, ...m }, u) => /* @__PURE__ */ f(Ie, {
717
+ ref: u,
718
+ className: z("flex min-w-0 flex-col gap-1.5", t),
719
+ dataHook: e,
720
+ ...m,
721
+ children: [
722
+ /* @__PURE__ */ s(Me, {
723
+ className: "group/thumb",
724
+ file: a,
725
+ size: "lg",
726
+ children: r && /* @__PURE__ */ s("div", {
727
+ className: "bg-background/80 hover:bg-background duration-fast absolute top-1.5 right-1.5 rounded-full p-0.5 opacity-0 transition-opacity ease-out group-focus-within/thumb:opacity-100 group-hover/thumb:opacity-100",
728
+ children: /* @__PURE__ */ s(Pe, {
729
+ className: "flex",
730
+ "data-tracking-el": l,
731
+ "data-tracking-label": d,
732
+ dataHook: `${e}-remove`,
733
+ file: a,
734
+ removeAriaLabel: n,
735
+ onClick: r,
736
+ children: /* @__PURE__ */ s(je, { size: 16 })
737
+ })
738
+ })
739
+ }),
740
+ i && /* @__PURE__ */ s(C, {
741
+ asChild: !0,
742
+ truncate: !0,
743
+ color: "muted",
744
+ dataHook: `${e}-name`,
745
+ variant: "body-xs",
746
+ children: /* @__PURE__ */ s("span", {
747
+ "data-slot": "file-upload-file-name",
748
+ children: a.name
749
+ })
750
+ }),
751
+ /* @__PURE__ */ s(Te, { file: a })
752
+ ]
753
+ }));
754
+ St.displayName = "FileUploadGridItem";
755
+ var jt = o.forwardRef(({ className: t, dataHook: e, title: a, dismissLabel: r, ...n }, i) => {
756
+ const { rejections: l, clearRejections: d } = O(), m = e ?? "file-upload-rejections";
757
+ if (l.length === 0) return null;
758
+ const u = l.length, g = a ? a.replace("{n}", String(u)) : u === 1 ? "1 file wasn't added" : `${u} files weren't added`;
759
+ return /* @__PURE__ */ f(lt, {
760
+ ref: i,
761
+ className: t,
762
+ "data-hook": m,
763
+ "data-slot": "file-upload-rejections",
764
+ role: "status",
765
+ variant: "warning",
766
+ ...n,
767
+ children: [/* @__PURE__ */ s(he, {
768
+ "aria-hidden": !0,
769
+ className: "shrink-0 translate-y-0.5"
770
+ }), /* @__PURE__ */ f("div", {
771
+ className: "flex min-w-0 flex-1 flex-col gap-1",
772
+ children: [/* @__PURE__ */ f("div", {
773
+ className: "flex items-start justify-between gap-2",
774
+ children: [/* @__PURE__ */ s(ct, { children: g }), /* @__PURE__ */ s(ve, {
775
+ "aria-label": r ?? "Dismiss",
776
+ className: "-my-1.5 -mr-2 shrink-0",
777
+ dataHook: `${m}-dismiss`,
778
+ size: "sm",
779
+ variant: "ghost",
780
+ onClick: d,
781
+ children: /* @__PURE__ */ s(je, { "aria-hidden": !0 })
782
+ })]
783
+ }), /* @__PURE__ */ s(C, {
784
+ asChild: !0,
785
+ dataHook: `${m}-list`,
786
+ variant: "body-sm",
787
+ children: /* @__PURE__ */ s("ul", {
788
+ className: "flex flex-col gap-1",
789
+ children: l.map((R) => /* @__PURE__ */ f("li", {
790
+ className: "min-w-0 break-words",
791
+ "data-slot": "file-upload-rejection",
792
+ children: [
793
+ /* @__PURE__ */ s("strong", { children: R.name }),
794
+ " — ",
795
+ R.message
796
+ ]
797
+ }, R.id))
798
+ })
799
+ })]
800
+ })]
801
+ });
802
+ });
803
+ jt.displayName = "FileUploadRejections";
804
+ var $t = o.forwardRef(({ className: t, dataHook: e, layout: a = "vertical", shape: r = "square", label: n, description: i, emptyMessage: l, src: d, onChange: m, onRemove: u, accept: g, acceptLabel: R, maxSize: $, minSize: S, minImageSize: M, onFileValidate: P, onUpload: B, messages: Q, disabled: F = !1, uploadLabel: Z, removeLabel: ye, uploadingLabel: Fe, actions: q, trackingEl: ke, trackingLabel: we, onDragEnter: Y, onDragOver: T, onDragLeave: G, onDrop: ee, onPaste: te, ...ae }, Ue) => {
805
+ const H = o.useRef(null), V = o.useRef(!1), [de, re] = o.useState(null), ue = Ge(de), I = d !== void 0 ? d : ue ?? null, K = _e(Q), [J, L] = o.useState("idle"), A = o.useRef(0), [se, N] = o.useState(be), [Re, oe] = o.useState(null), [p, v] = qe(), h = o.useCallback((c) => {
806
+ oe(c), v(c);
807
+ }, [v]), k = o.useRef({
808
+ accept: g,
809
+ acceptLabel: R,
810
+ maxSize: $,
811
+ minSize: S,
812
+ minImageSize: M,
813
+ messages: K,
814
+ onFileValidate: P,
815
+ onChange: m,
816
+ onUpload: B
817
+ });
818
+ o.useEffect(() => {
819
+ k.current = {
820
+ accept: g,
821
+ acceptLabel: R,
822
+ maxSize: $,
823
+ minSize: S,
824
+ minImageSize: M,
825
+ messages: K,
826
+ onFileValidate: P,
827
+ onChange: m,
828
+ onUpload: B
829
+ };
830
+ });
831
+ const x = o.useCallback((c) => {
832
+ const U = c[0];
833
+ F || V.current || !U || (async () => {
834
+ const D = k.current, Ee = gt(U, {
835
+ accept: D.accept,
836
+ maxSize: D.maxSize,
837
+ minSize: D.minSize
838
+ })[0];
839
+ if (Ee) {
840
+ h(ze(U, Ee, {
841
+ ...D,
842
+ maxFiles: 1
843
+ }));
844
+ return;
845
+ }
846
+ const Oe = await Be(U, D);
847
+ if (Oe) {
848
+ h(Oe);
849
+ return;
850
+ }
851
+ if (oe(null), re(U), D.onChange?.(U, Se(U)), !D.onUpload) return;
852
+ let Ce;
853
+ V.current = !0, N({
854
+ status: "uploading",
855
+ progress: 0
856
+ });
857
+ try {
858
+ await D.onUpload([U], {
859
+ onProgress: (me, ie) => {
860
+ N((ge) => ({
861
+ ...ge,
862
+ progress: We(ie)
863
+ }));
864
+ },
865
+ onSuccess: () => {
866
+ Ce = "success", N({
867
+ status: "success",
868
+ progress: 100
869
+ });
870
+ },
871
+ onError: (me, ie) => {
872
+ Ce = "error";
873
+ const ge = (typeof ie == "string" ? ie : ie?.message) || D.messages.uploadFailed;
874
+ N({
875
+ status: "error",
876
+ progress: 0,
877
+ error: ge
878
+ }), v(ge);
879
+ }
880
+ });
881
+ } catch {
882
+ }
883
+ if (Ce === void 0) {
884
+ const me = D.messages.uploadFailed;
885
+ N({
886
+ status: "error",
887
+ progress: 0,
888
+ error: me
889
+ }), v(me);
890
+ }
891
+ V.current = !1;
892
+ })();
893
+ }, [
894
+ F,
895
+ h,
896
+ v
897
+ ]), j = o.useCallback((c) => {
898
+ if (Y?.(c), c.preventDefault(), !F && (A.current += 1, A.current === 1)) {
899
+ const U = ft(c.dataTransfer.items, g);
900
+ L(U ? "accept" : "reject");
901
+ }
902
+ }, [
903
+ Y,
904
+ F,
905
+ g
906
+ ]), W = o.useCallback((c) => {
907
+ T?.(c), c.preventDefault(), F || (c.dataTransfer.dropEffect = "copy");
908
+ }, [T, F]), w = o.useCallback((c) => {
909
+ G?.(c), c.preventDefault(), !F && (A.current -= 1, A.current === 0 && L("idle"));
910
+ }, [G, F]), y = o.useCallback((c) => {
911
+ ee?.(c), !c.defaultPrevented && (c.preventDefault(), A.current = 0, L("idle"), x(Array.from(c.dataTransfer.files)));
912
+ }, [ee, x]), b = o.useCallback((c) => {
913
+ if (te?.(c), c.defaultPrevented) return;
914
+ const U = Array.from(c.clipboardData.files);
915
+ U.length > 0 && (c.preventDefault(), x(U));
916
+ }, [te, x]), E = o.useCallback((c) => {
917
+ x(Array.from(c.target.files ?? [])), c.target.value = "";
918
+ }, [x]), pe = o.useCallback(() => {
919
+ V.current = !1, re(null), N(be), oe(null), u?.();
920
+ }, [u]), Ke = g ? Object.entries(g).flatMap(([c, U]) => U.length > 0 ? U : [c]).join(",") : void 0, ne = se.status === "uploading", fe = Re ?? (se.status === "error" ? se.error ?? K.uploadFailed : null), De = a === "horizontal", Le = /* @__PURE__ */ f("div", {
921
+ className: "flex flex-wrap gap-2",
922
+ children: [
923
+ /* @__PURE__ */ s("input", {
924
+ ref: H,
925
+ accept: Ke,
926
+ "aria-label": n ? `Upload ${n}` : "Upload file",
927
+ className: "sr-only",
928
+ disabled: F || ne,
929
+ tabIndex: -1,
930
+ type: "file",
931
+ onChange: E
932
+ }),
933
+ /* @__PURE__ */ s(ve, {
934
+ dataHook: `${e}-upload`,
935
+ disabled: F || ne,
936
+ size: "sm",
937
+ variant: "outline",
938
+ onClick: () => H.current?.click(),
939
+ children: Z ?? (I ? "Replace" : "Upload")
940
+ }),
941
+ I && !ne && q,
942
+ I && !ne && /* @__PURE__ */ s(ve, {
943
+ dataHook: `${e}-remove`,
944
+ disabled: F,
945
+ size: "sm",
946
+ variant: "ghost",
947
+ onClick: pe,
948
+ children: ye ?? "Remove"
949
+ })
950
+ ]
951
+ });
952
+ return /* @__PURE__ */ f("div", {
953
+ ref: Ue,
954
+ className: z("relative flex", De ? "flex-wrap items-start gap-4" : "flex-col items-center gap-2", t),
955
+ "data-hook": e,
956
+ "data-slot": "file-upload-slot",
957
+ "data-tracking-el": ke ?? "file-upload-slot",
958
+ "data-tracking-label": we,
959
+ onDragEnter: j,
960
+ onDragLeave: w,
961
+ onDragOver: W,
962
+ onDrop: y,
963
+ onPaste: b,
964
+ ...ae,
965
+ children: [
966
+ /* @__PURE__ */ f("div", {
967
+ className: z("bg-muted text-muted-foreground relative flex shrink-0 items-center justify-center overflow-hidden rounded-lg", "duration-fast transition-shadow ease-out", r === "square" ? "size-24" : "h-24 w-40", F && "opacity-50", J === "accept" && "ring-success-mark ring-2", J === "reject" && "ring-destructive ring-2"),
968
+ "data-drag-state": J !== "idle" ? J : void 0,
969
+ "data-hook": `${e}-frame`,
970
+ "data-slot": "file-upload-slot-frame",
971
+ children: [I ? /* @__PURE__ */ s("img", {
972
+ alt: n ?? "",
973
+ className: "size-full object-cover",
974
+ src: I
975
+ }) : /* @__PURE__ */ s(dt, {
976
+ dataHook: `${e}-empty`,
977
+ message: l
978
+ }), ne && /* @__PURE__ */ s("div", {
979
+ className: "bg-background/70 absolute inset-0 flex items-center justify-center",
980
+ children: /* @__PURE__ */ s(it, {
981
+ className: "text-primary",
982
+ dataHook: `${e}-spinner`,
983
+ loadingLabel: Fe ?? "Uploading…",
984
+ size: "lg"
985
+ })
986
+ })]
987
+ }),
988
+ De ? /* @__PURE__ */ f("div", {
989
+ className: "flex min-w-0 flex-1 flex-col gap-2",
990
+ children: [
991
+ n && /* @__PURE__ */ s(C, {
992
+ asChild: !0,
993
+ dataHook: `${e}-label`,
994
+ variant: "body-sm",
995
+ children: /* @__PURE__ */ s("span", { children: n })
996
+ }),
997
+ i && /* @__PURE__ */ s(C, {
998
+ color: "muted",
999
+ dataHook: `${e}-description`,
1000
+ variant: "body-xs",
1001
+ children: i
1002
+ }),
1003
+ fe && /* @__PURE__ */ s(C, {
1004
+ asChild: !0,
1005
+ color: "destructive",
1006
+ dataHook: `${e}-status-text`,
1007
+ variant: "body-xs",
1008
+ children: /* @__PURE__ */ f("p", {
1009
+ "aria-hidden": !0,
1010
+ className: "flex items-start gap-1",
1011
+ "data-hook": `${e}-status`,
1012
+ "data-slot": "file-upload-slot-status",
1013
+ children: [/* @__PURE__ */ s(he, {
1014
+ className: "mt-0.5 shrink-0",
1015
+ size: 14
1016
+ }), /* @__PURE__ */ s("span", { children: fe })]
1017
+ })
1018
+ }),
1019
+ Le
1020
+ ]
1021
+ }) : /* @__PURE__ */ f(xe, { children: [
1022
+ n && /* @__PURE__ */ s(C, {
1023
+ asChild: !0,
1024
+ color: "muted",
1025
+ dataHook: `${e}-label`,
1026
+ variant: "body-xs",
1027
+ children: /* @__PURE__ */ s("span", { children: n })
1028
+ }),
1029
+ i && /* @__PURE__ */ s(C, {
1030
+ align: "center",
1031
+ className: "max-w-60",
1032
+ color: "muted",
1033
+ dataHook: `${e}-description`,
1034
+ variant: "body-xs",
1035
+ children: i
1036
+ }),
1037
+ fe && /* @__PURE__ */ s(C, {
1038
+ asChild: !0,
1039
+ color: "destructive",
1040
+ dataHook: `${e}-status-text`,
1041
+ variant: "body-xs",
1042
+ children: /* @__PURE__ */ f("p", {
1043
+ "aria-hidden": !0,
1044
+ className: "flex max-w-60 items-start gap-1 text-center",
1045
+ "data-hook": `${e}-status`,
1046
+ "data-slot": "file-upload-slot-status",
1047
+ children: [/* @__PURE__ */ s(he, {
1048
+ className: "mt-0.5 shrink-0",
1049
+ size: 14
1050
+ }), /* @__PURE__ */ s("span", { children: fe })]
1051
+ })
1052
+ }),
1053
+ Le
1054
+ ] }),
1055
+ /* @__PURE__ */ s("div", {
1056
+ "aria-live": "polite",
1057
+ className: "sr-only",
1058
+ "data-slot": "file-upload-announcer",
1059
+ role: "status",
1060
+ children: p
1061
+ })
1062
+ ]
1063
+ });
1064
+ });
1065
+ $t.displayName = "FileUploadSlot";
1066
+ var It = o.forwardRef(({ className: t, count: e, dataHook: a, ...r }, n) => {
1067
+ const { files: i, maxFiles: l } = O();
1068
+ return l === void 0 ? null : /* @__PURE__ */ s(ut, {
1069
+ ref: n,
1070
+ className: z("order-last ml-auto pl-3", t),
1071
+ count: e ?? i.length,
1072
+ "data-slot": "file-upload-count",
1073
+ dataHook: a ?? "file-upload-count",
1074
+ limit: l,
1075
+ ...r
1076
+ });
1077
+ });
1078
+ It.displayName = "FileUploadCount";
1079
+ export {
1080
+ bt as FILE_UPLOAD_MESSAGES,
1081
+ Ft as FileUpload,
1082
+ Xe as FileUploadAccept,
1083
+ zt as FileUploadCardItem,
1084
+ It as FileUploadCount,
1085
+ wt as FileUploadDropzone,
1086
+ Ut as FileUploadDropzoneContent,
1087
+ St as FileUploadGridItem,
1088
+ Je as FileUploadIdle,
1089
+ Ie as FileUploadItem,
1090
+ Me as FileUploadItemPreview,
1091
+ Te as FileUploadItemProgress,
1092
+ Pe as FileUploadItemRemove,
1093
+ Ct as FileUploadList,
1094
+ Ye as FileUploadReject,
1095
+ jt as FileUploadRejections,
1096
+ $t as FileUploadSlot,
1097
+ Ve as FileUploadTrigger,
1098
+ Jt as PHOTO_UPLOAD_RULES,
1099
+ le as formatBytes,
1100
+ yt as getFileTypeIcon,
1101
+ ht as getImageDimensions,
1102
+ Ge as useObjectUrl
1103
+ };