@opennsw/jsonforms-renderers 0.8.0 → 0.10.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.
@@ -1,195 +1,194 @@
1
- var mr = Object.defineProperty;
2
- var gr = (e, t, r) => t in e ? mr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Pe = (e, t, r) => gr(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { jsx as n, jsxs as g, Fragment as be } from "react/jsx-runtime";
5
- import { useContext as Ze, createContext as Qe, useMemo as yr, useEffect as fe, useState as U, useRef as de, useCallback as _e } from "react";
6
- import { rankWith as K, isStringControl as vr, or as Le, isNumberControl as br, isIntegerControl as wr, isBooleanControl as Er, isEnumControl as er, isOneOfControl as rr, schemaMatches as ze, isDateControl as Rr, isDateTimeControl as Cr, isTimeControl as Tr, uiTypeIs as Te, and as Ar, Resolve as Sr, createDefaultValue as Or, isObjectArrayControl as Nr, isPrimitiveArrayControl as Ir } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as se, JsonFormsDispatch as Ae, useJsonForms as xr, withJsonFormsArrayControlProps as Mr } from "@jsonforms/react";
8
- import { Box as R, Flex as S, Text as h, TextField as ye, Checkbox as kr, RadioGroup as Ve, Select as Ne, ScrollArea as Lr, Spinner as Me, Button as ke, Tabs as Ie, Heading as tr, Card as nr, IconButton as Ue, Tooltip as We, Table as P } from "@radix-ui/themes";
9
- import { ChevronDownIcon as zr, FileTextIcon as Dr, CheckCircledIcon as Fr, Cross2Icon as or, ExclamationTriangleIcon as lr, UploadIcon as He, TrashIcon as Ur, PlusIcon as Hr } from "@radix-ui/react-icons";
10
- import $r from "dayjs";
11
- import { read as _r, utils as Pr } from "@e965/xlsx";
12
- const ir = Qe(null);
13
- function Nn({
1
+ var Dr = Object.defineProperty;
2
+ var Mr = (e, t, r) => t in e ? Dr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var tr = (e, t, r) => Mr(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as n, jsxs as m, Fragment as ae } from "react/jsx-runtime";
5
+ import { useContext as mr, createContext as gr, useMemo as Xe, useEffect as ue, useState as H, useRef as le, useCallback as Ne } from "react";
6
+ import { rankWith as te, isStringControl as zr, or as _e, isNumberControl as Lr, isIntegerControl as Fr, isBooleanControl as Ur, isEnumControl as yr, isOneOfControl as vr, schemaMatches as De, isDateControl as Pr, isDateTimeControl as $r, isTimeControl as _r, uiTypeIs as Me, and as Vr, Resolve as Ke, update as Hr, createDefaultValue as Wr, isObjectArrayControl as jr, isPrimitiveArrayControl as Br } from "@jsonforms/core";
7
+ import { withJsonFormsControlProps as fe, JsonFormsDispatch as ze, useJsonForms as br, withJsonFormsArrayControlProps as Xr } from "@jsonforms/react";
8
+ import { Box as I, Flex as k, Text as p, TextField as be, Checkbox as Kr, RadioGroup as nr, ScrollArea as wr, Select as Fe, Spinner as xe, Button as Ie, Tabs as Ue, Heading as Er, Card as Rr, IconButton as ke, Table as ve, Tooltip as $e } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as Ar, FileTextIcon as Gr, CheckCircledIcon as Yr, Cross2Icon as Je, ExclamationTriangleIcon as Ze, UploadIcon as Oe, TrashIcon as Jr, PlusIcon as Zr } from "@radix-ui/react-icons";
10
+ import qr from "dayjs";
11
+ const Cr = gr(null);
12
+ function io({
14
13
  children: e,
15
14
  onUpload: t,
16
15
  getDownloadUrl: r
17
16
  }) {
18
- const i = { onUpload: t, getDownloadUrl: r };
19
- return /* @__PURE__ */ n(ir.Provider, { value: i, children: e });
17
+ const o = { onUpload: t, getDownloadUrl: r };
18
+ return /* @__PURE__ */ n(Cr.Provider, { value: o, children: e });
20
19
  }
21
- function Vr() {
22
- return Ze(ir);
20
+ function Qr() {
21
+ return mr(Cr);
23
22
  }
24
- const sr = Qe(null);
25
- function In({
23
+ const Tr = gr(null);
24
+ function lo({
26
25
  children: e,
27
26
  services: t
28
27
  }) {
29
- const r = yr(() => t, [t]);
30
- return /* @__PURE__ */ n(sr.Provider, { value: r, children: e });
28
+ const r = Xe(() => t, [t]);
29
+ return /* @__PURE__ */ n(Tr.Provider, { value: r, children: e });
31
30
  }
32
- function Wr(e) {
33
- const t = Ze(sr);
31
+ function et(e) {
32
+ const t = mr(Tr);
34
33
  return !t || !e ? null : t[e] ?? null;
35
34
  }
36
- const ce = (e, t, r, i = void 0) => {
37
- fe(() => {
38
- e === !1 && r(t, i);
39
- }, [e, t, r, i]);
40
- }, ae = (e, t) => e ? e.split(`
35
+ const ge = (e, t, r, o = void 0) => {
36
+ ue(() => {
37
+ e === !1 && r(t, o);
38
+ }, [e, t, r, o]);
39
+ }, de = (e, t) => e ? e.split(`
41
40
  `).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
42
- `) : "", Br = ({
41
+ `) : "", rt = ({
43
42
  data: e,
44
43
  handleChange: t,
45
44
  path: r,
46
- label: i,
47
- required: f,
48
- errors: s,
45
+ label: o,
46
+ required: u,
47
+ errors: i,
49
48
  uischema: l,
50
- schema: a,
51
- enabled: o,
52
- visible: c = !0
49
+ schema: c,
50
+ enabled: s,
51
+ visible: d = !0
53
52
  }) => {
54
- var y;
55
- if (ce(c, r, t), c === !1)
53
+ var g;
54
+ if (ge(d, r, t), d === !1)
56
55
  return null;
57
- const u = s.length === 0;
58
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
59
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
60
- i,
56
+ const a = i.length === 0;
57
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
58
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
59
+ o,
61
60
  " ",
62
- f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
61
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
63
62
  ] }),
64
63
  /* @__PURE__ */ n(
65
- ye.Root,
64
+ be.Root,
66
65
  {
67
66
  value: e || "",
68
- onChange: (p) => t(r, p.target.value),
69
- disabled: !o,
70
- placeholder: (y = l.options) == null ? void 0 : y.placeholder,
71
- color: u ? void 0 : "red",
67
+ onChange: (f) => t(r, f.target.value),
68
+ disabled: !s,
69
+ placeholder: (g = l.options) == null ? void 0 : g.placeholder,
70
+ color: a ? void 0 : "red",
72
71
  id: r
73
72
  }
74
73
  ),
75
- !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
76
- a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
74
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
75
+ c.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: c.description })
77
76
  ] }) });
78
- }, Kr = K(1, vr), Gr = se(Br), Xr = ({
77
+ }, tt = te(1, zr), nt = fe(rt), ot = ({
79
78
  data: e,
80
79
  handleChange: t,
81
80
  path: r,
82
- label: i,
83
- required: f,
84
- errors: s,
81
+ label: o,
82
+ required: u,
83
+ errors: i,
85
84
  uischema: l,
86
- schema: a,
87
- enabled: o,
88
- visible: c = !0
85
+ schema: c,
86
+ enabled: s,
87
+ visible: d = !0
89
88
  }) => {
90
- var p;
91
- if (ce(c, r, t), c === !1)
89
+ var f;
90
+ if (ge(d, r, t), d === !1)
92
91
  return null;
93
- const u = s.length === 0, y = (m) => {
94
- if (m === "") {
92
+ const a = i.length === 0, g = (y) => {
93
+ if (y === "") {
95
94
  t(r, void 0);
96
95
  return;
97
96
  }
98
- const v = Number(m);
99
- isNaN(v) || t(r, v);
97
+ const w = Number(y);
98
+ isNaN(w) || t(r, w);
100
99
  };
101
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
102
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
- i,
100
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
101
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
102
+ o,
104
103
  " ",
105
- f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
104
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
106
105
  ] }),
107
106
  /* @__PURE__ */ n(
108
- ye.Root,
107
+ be.Root,
109
108
  {
110
109
  type: "number",
111
110
  value: e ?? "",
112
- onChange: (m) => y(m.target.value),
113
- disabled: !o,
114
- placeholder: (p = l.options) == null ? void 0 : p.placeholder,
115
- color: u ? void 0 : "red",
111
+ onChange: (y) => g(y.target.value),
112
+ disabled: !s,
113
+ placeholder: (f = l.options) == null ? void 0 : f.placeholder,
114
+ color: a ? void 0 : "red",
116
115
  id: r
117
116
  }
118
117
  ),
119
- !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
120
- a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
118
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
119
+ c.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: c.description })
121
120
  ] }) });
122
- }, jr = K(2, Le(br, wr)), Yr = se(Xr), Jr = ({
121
+ }, it = te(2, _e(Lr, Fr)), lt = fe(ot), st = ({
123
122
  data: e,
124
123
  handleChange: t,
125
124
  path: r,
126
- label: i,
127
- required: f,
128
- errors: s,
125
+ label: o,
126
+ required: u,
127
+ errors: i,
129
128
  schema: l,
130
- enabled: a,
131
- visible: o = !0
129
+ enabled: c,
130
+ visible: s = !0
132
131
  }) => {
133
- if (ce(o, r, t), o === !1)
132
+ if (ge(s, r, t), s === !1)
134
133
  return null;
135
- const c = s.length === 0;
136
- return /* @__PURE__ */ g(R, { mb: "4", children: [
137
- /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
134
+ const d = i.length === 0;
135
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
136
+ /* @__PURE__ */ m(k, { gap: "2", align: "center", children: [
138
137
  /* @__PURE__ */ n(
139
- kr,
138
+ Kr,
140
139
  {
141
140
  checked: !!e,
142
- onCheckedChange: (u) => t(r, u === !0),
143
- disabled: !a,
141
+ onCheckedChange: (a) => t(r, a === !0),
142
+ disabled: !c,
144
143
  id: r
145
144
  }
146
145
  ),
147
- /* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
148
- i,
146
+ /* @__PURE__ */ m(p, { as: "label", size: "2", htmlFor: r, children: [
147
+ o,
149
148
  " ",
150
- f && "*"
149
+ u && "*"
151
150
  ] })
152
151
  ] }),
153
- !c && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: ae(s, i) }),
154
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: l.description })
152
+ !d && /* @__PURE__ */ n(p, { color: "red", size: "1", className: "block mt-1", children: de(i, o) }),
153
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", className: "block mt-1", children: l.description })
155
154
  ] });
156
- }, qr = K(2, Er), Zr = se(Jr), Qr = ({
155
+ }, ct = te(2, Ur), at = fe(st), ut = ({
157
156
  data: e,
158
157
  handleChange: t,
159
158
  path: r,
160
- label: i,
161
- required: f,
162
- errors: s,
159
+ label: o,
160
+ required: u,
161
+ errors: i,
163
162
  schema: l,
164
- enabled: a,
165
- visible: o = !0
163
+ enabled: c,
164
+ visible: s = !0
166
165
  }) => {
167
- if (ce(o, r, t), o === !1)
166
+ if (ge(s, r, t), s === !1)
168
167
  return null;
169
- const c = s.length === 0;
170
- let u = [];
171
- l.enum ? u = l.enum.map((p) => ({ value: p, label: String(p) })) : l.oneOf && (u = l.oneOf.map((p) => ({
172
- value: p.const,
173
- label: p.title || String(p.const)
168
+ const d = i.length === 0;
169
+ let a = [];
170
+ l.enum ? a = l.enum.map((f) => ({ value: f, label: String(f) })) : l.oneOf && (a = l.oneOf.map((f) => ({
171
+ value: f.const,
172
+ label: f.title || String(f.const)
174
173
  })));
175
- const y = e;
176
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
177
- /* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
178
- i,
174
+ const g = e;
175
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
176
+ /* @__PURE__ */ m(p, { as: "div", size: "2", weight: "bold", children: [
177
+ o,
179
178
  " ",
180
- f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
179
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
181
180
  ] }),
182
181
  /* @__PURE__ */ n(
183
- Ve.Root,
182
+ nr.Root,
184
183
  {
185
- value: y !== void 0 ? String(y) : "",
186
- onValueChange: (p) => {
187
- const m = u.find((v) => String(v.value) === p);
188
- m && t(r, m.value);
184
+ value: g !== void 0 ? String(g) : "",
185
+ onValueChange: (f) => {
186
+ const y = a.find((w) => String(w.value) === f);
187
+ y && t(r, y.value);
189
188
  },
190
- disabled: !a,
189
+ disabled: !c,
191
190
  children: /* @__PURE__ */ n(
192
- S,
191
+ k,
193
192
  {
194
193
  direction: "row",
195
194
  style: {
@@ -197,210 +196,308 @@ const ce = (e, t, r, i = void 0) => {
197
196
  columnGap: "clamp(14px, 3vw, 36px)",
198
197
  rowGap: "clamp(8px, 1.6vw, 14px)"
199
198
  },
200
- children: u.map((p) => /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
- /* @__PURE__ */ n(Ve.Item, { value: String(p.value) }),
202
- /* @__PURE__ */ n(h, { size: "2", color: a ? void 0 : "gray", children: p.label })
203
- ] }, String(p.value)))
199
+ children: a.map((f) => /* @__PURE__ */ m(k, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
200
+ /* @__PURE__ */ n(nr.Item, { value: String(f.value) }),
201
+ /* @__PURE__ */ n(p, { size: "2", color: c ? void 0 : "gray", children: f.label })
202
+ ] }, String(f.value)))
204
203
  }
205
204
  )
206
205
  }
207
206
  ),
208
- !c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
209
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
207
+ !d && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
208
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
210
209
  ] }) });
211
- }, et = (e, t, r) => {
212
- var f;
213
- return Le(er, rr)(e, t, r) && ((f = e == null ? void 0 : e.options) == null ? void 0 : f.format) === "radio" ? 3 : -1;
214
- }, rt = se(Qr), tt = ({
210
+ }, dt = (e, t, r) => {
211
+ var u;
212
+ return _e(yr, vr)(e, t, r) && ((u = e == null ? void 0 : e.options) == null ? void 0 : u.format) === "radio" ? 3 : -1;
213
+ }, ft = fe(ut), ht = ({
215
214
  data: e,
216
215
  handleChange: t,
217
216
  path: r,
218
- label: i,
219
- required: f,
220
- errors: s,
217
+ label: o,
218
+ required: u,
219
+ errors: i,
221
220
  schema: l,
222
- uischema: a,
223
- enabled: o,
224
- visible: c = !0
221
+ uischema: c,
222
+ enabled: s,
223
+ visible: d = !0
225
224
  }) => {
226
- var m;
227
- if (ce(c, r, t), c === !1)
225
+ var $, W, z;
226
+ ge(d, r, t);
227
+ const a = (($ = c.options) == null ? void 0 : $.autocomplete) === !0, [g, f] = H(!1), [y, w] = H(""), [L, O] = H(0), R = le(null);
228
+ if (ue(() => {
229
+ if (!a || !g) return;
230
+ const E = (b) => {
231
+ R.current && !R.current.contains(b.target) && f(!1);
232
+ };
233
+ return document.addEventListener("mousedown", E), () => document.removeEventListener("mousedown", E);
234
+ }, [a, g]), d === !1)
228
235
  return null;
229
- const u = s.length === 0;
230
- let y = [];
231
- l.enum ? y = l.enum.map((v) => ({ value: String(v), label: String(v) })) : l.oneOf && (y = l.oneOf.map((v) => ({
232
- value: String(v.const),
233
- label: v.title || String(v.const)
236
+ const T = i.length === 0;
237
+ let S = [];
238
+ l.enum ? S = l.enum.map((E) => ({ value: String(E), label: String(E) })) : l.oneOf && (S = l.oneOf.map((E) => ({
239
+ value: String(E.const),
240
+ label: E.title || String(E.const)
234
241
  })));
235
- const p = e !== void 0 ? String(e) : "";
236
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
237
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
238
- i,
242
+ const N = e !== void 0 ? String(e) : "", D = ((W = c.options) == null ? void 0 : W.placeholder) || "Select an option";
243
+ if (a) {
244
+ const E = ((z = S.find((C) => C.value === N)) == null ? void 0 : z.label) ?? "", b = g ? S.filter((C) => C.label.toLowerCase().includes(y.toLowerCase())) : S, K = Math.min(L, b.length - 1), G = (C) => {
245
+ t(r, C.value), f(!1);
246
+ }, j = (C) => {
247
+ C.stopPropagation(), t(r, void 0), w("");
248
+ }, Y = (C) => {
249
+ (C.key === "Enter" || C.key === " ") && j(C);
250
+ };
251
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
252
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
253
+ o,
254
+ " ",
255
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
256
+ ] }),
257
+ /* @__PURE__ */ m("div", { ref: R, style: { position: "relative" }, children: [
258
+ /* @__PURE__ */ n(
259
+ be.Root,
260
+ {
261
+ id: r,
262
+ value: g ? y : E,
263
+ placeholder: D,
264
+ disabled: !s,
265
+ style: T ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
266
+ onChange: (C) => {
267
+ w(C.target.value), O(0), g || f(!0);
268
+ },
269
+ onFocus: () => {
270
+ s && !g && (w(""), O(0), f(!0));
271
+ },
272
+ onKeyDown: (C) => {
273
+ C.key === "Escape" ? f(!1) : C.key === "ArrowDown" ? (C.preventDefault(), g ? O((Z) => Math.min(Z + 1, b.length - 1)) : (w(""), f(!0))) : C.key === "ArrowUp" ? (C.preventDefault(), g && O((Z) => Math.max(Z - 1, 0))) : C.key === "Enter" && g && b[K] && (C.preventDefault(), G(b[K]));
274
+ },
275
+ children: /* @__PURE__ */ n(be.Slot, { side: "right", children: /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
276
+ N && s && /* @__PURE__ */ n(
277
+ "span",
278
+ {
279
+ role: "button",
280
+ tabIndex: 0,
281
+ onMouseDown: (C) => C.preventDefault(),
282
+ onClick: j,
283
+ onKeyDown: Y,
284
+ style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
285
+ "aria-label": "Clear selection",
286
+ children: "×"
287
+ }
288
+ ),
289
+ /* @__PURE__ */ n(
290
+ Ar,
291
+ {
292
+ style: { transform: g ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
293
+ }
294
+ )
295
+ ] }) })
296
+ }
297
+ ),
298
+ g && /* @__PURE__ */ n(
299
+ I,
300
+ {
301
+ style: {
302
+ position: "absolute",
303
+ top: "calc(100% + 4px)",
304
+ left: 0,
305
+ right: 0,
306
+ zIndex: 50,
307
+ background: "var(--color-panel-solid)",
308
+ borderRadius: "var(--radius-3)",
309
+ boxShadow: "var(--shadow-5)",
310
+ border: "1px solid var(--gray-a6)",
311
+ overflow: "hidden"
312
+ },
313
+ children: /* @__PURE__ */ n(wr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ m(I, { p: "1", children: [
314
+ b.length === 0 && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "No results found." }) }),
315
+ b.map((C, Z) => /* @__PURE__ */ n(
316
+ I,
317
+ {
318
+ px: "3",
319
+ py: "2",
320
+ onMouseDown: (J) => J.preventDefault(),
321
+ onClick: () => G(C),
322
+ onMouseEnter: () => O(Z),
323
+ style: {
324
+ cursor: "pointer",
325
+ borderRadius: "var(--radius-2)",
326
+ backgroundColor: Z === K ? "var(--accent-4)" : C.value === N ? "var(--accent-3)" : void 0
327
+ },
328
+ children: /* @__PURE__ */ n(p, { size: "2", children: C.label })
329
+ },
330
+ C.value
331
+ ))
332
+ ] }) })
333
+ }
334
+ )
335
+ ] }),
336
+ !T && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
337
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
338
+ ] }) });
339
+ }
340
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
341
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
342
+ o,
239
343
  " ",
240
- f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
344
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
241
345
  ] }),
242
- /* @__PURE__ */ g(Ne.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
243
- /* @__PURE__ */ n(
244
- Ne.Trigger,
245
- {
246
- placeholder: ((m = a.options) == null ? void 0 : m.placeholder) || "Select an option",
247
- color: u ? void 0 : "red",
248
- id: r
249
- }
250
- ),
251
- /* @__PURE__ */ n(Ne.Content, { children: y.map((v) => /* @__PURE__ */ n(Ne.Item, { value: v.value, children: v.label }, v.value)) })
346
+ /* @__PURE__ */ m(Fe.Root, { value: N, onValueChange: (E) => t(r, E), disabled: !s, children: [
347
+ /* @__PURE__ */ n(Fe.Trigger, { placeholder: D, color: T ? void 0 : "red", id: r }),
348
+ /* @__PURE__ */ n(Fe.Content, { children: S.map((E) => /* @__PURE__ */ n(Fe.Item, { value: E.value, children: E.label }, E.value)) })
252
349
  ] }),
253
- !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
254
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
350
+ !T && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
351
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
255
352
  ] }) });
256
- }, nt = K(2, Le(er, rr)), ot = se(tt), lt = {
353
+ }, pt = te(2, _e(yr, vr)), mt = fe(ht), gt = {
257
354
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
258
355
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
259
356
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
260
- }, it = ({
357
+ }, yt = ({
261
358
  data: e,
262
359
  handleChange: t,
263
360
  path: r,
264
- label: i,
265
- required: f,
266
- errors: s,
361
+ label: o,
362
+ required: u,
363
+ errors: i,
267
364
  enabled: l,
268
- visible: a = !0,
269
- schema: o,
270
- uischema: c
365
+ visible: c = !0,
366
+ schema: s,
367
+ uischema: d
271
368
  }) => {
272
- var Re;
273
- const u = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = u.service ?? "", p = u.mode ?? "large-paginated-list", m = lt[p], v = (m == null ? void 0 : m.fetchOnOpen) ?? !1, N = u.params, A = Wr(y), w = o.type === "object", I = w ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, L = w ? I == null ? void 0 : I.value : e, D = I == null ? void 0 : I.label, C = y ? A ? m ? null : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", H = l !== !1, W = !s || s.length === 0, [x, O] = U(!1), [F, B] = U(""), [oe, ee] = U([]), [le, Y] = U(!1), [Z, re] = U(!1), [he, ne] = U(!1), [ue, b] = U(null), [k, $] = U(void 0), T = de(void 0), _ = de(null), J = de(null), Q = de(null), G = de(void 0);
274
- fe(() => {
275
- var E, q;
276
- if (!L) {
277
- $(void 0), G.current = void 0;
369
+ var A;
370
+ const a = (s == null ? void 0 : s["x-search"]) ?? { service: "" }, g = a.service ?? "", f = a.mode ?? "large-paginated-list", y = gt[f], w = (y == null ? void 0 : y.fetchOnOpen) ?? !1, L = a.params, O = et(g), R = s.type === "object", T = R ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, S = R ? T == null ? void 0 : T.value : e, N = T == null ? void 0 : T.label, D = g ? O ? y ? null : `Invalid x-search.mode "${f}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${g}" is not registered.` : "Search not configured.", $ = l !== !1, W = !i || i.length === 0, [z, E] = H(!1), [b, K] = H(""), [G, j] = H([]), [Y, C] = H(!1), [Z, J] = H(!1), [he, ie] = H(!1), [ye, h] = H(null), [x, B] = H(void 0), M = le(void 0), P = le(null), Q = le(null), ee = le(null), re = le(void 0);
371
+ ue(() => {
372
+ var X, F;
373
+ if (!S) {
374
+ B(void 0), re.current = void 0;
278
375
  return;
279
376
  }
280
- if (((E = G.current) == null ? void 0 : E.value) === L && ((q = G.current) == null ? void 0 : q.label) === D) return;
281
- if (G.current = { value: L, label: D }, w && D) {
282
- $({ id: L, name: D });
377
+ if (((X = re.current) == null ? void 0 : X.value) === S && ((F = re.current) == null ? void 0 : F.label) === N) return;
378
+ if (re.current = { value: S, label: N }, R && N) {
379
+ B({ id: S, name: N });
283
380
  return;
284
381
  }
285
- if ($({ id: L, name: D ?? L }), !(A != null && A.resolve)) return;
286
- let d = !1;
287
- return A.resolve(L, N).then((te) => {
288
- !d && te && $(te);
382
+ if (B({ id: S, name: N ?? S }), !(O != null && O.resolve)) return;
383
+ let v = !1;
384
+ return O.resolve(S, L).then((U) => {
385
+ !v && U && B(U);
289
386
  }).catch(() => {
290
387
  }), () => {
291
- d = !0;
388
+ v = !0;
292
389
  };
293
- }, [L, D, w, A, N]);
294
- const we = _e(
295
- async (d, E = !1) => {
296
- var te;
297
- if (!A) {
298
- b("Search service not configured.");
390
+ }, [S, N, R, O, L]);
391
+ const _ = Ne(
392
+ async (v, X = !1) => {
393
+ var U;
394
+ if (!O) {
395
+ h("Search service not configured.");
299
396
  return;
300
397
  }
301
- (te = J.current) == null || te.abort();
302
- const q = new AbortController();
303
- J.current = q, E ? ne(!0) : (re(!0), ne(!1), b(null));
398
+ (U = Q.current) == null || U.abort();
399
+ const F = new AbortController();
400
+ Q.current = F, X ? ie(!0) : (J(!0), ie(!1), h(null));
304
401
  try {
305
- const ie = await A.search({
306
- query: d,
307
- cursor: E ? T.current : void 0,
308
- signal: q.signal,
309
- params: N
310
- }), z = ie.options ?? [];
311
- ee(E ? (pr) => [...pr, ...z] : z), T.current = ie.nextCursor, Y(((m == null ? void 0 : m.paginated) ?? !1) && ie.nextCursor != null);
402
+ const se = await O.search({
403
+ query: v,
404
+ cursor: X ? M.current : void 0,
405
+ signal: F.signal,
406
+ params: L
407
+ }), Re = se.options ?? [];
408
+ j(X ? (je) => [...je, ...Re] : Re), M.current = se.nextCursor, C(((y == null ? void 0 : y.paginated) ?? !1) && se.nextCursor != null);
312
409
  } catch {
313
- if (q.signal.aborted) return;
314
- b("Failed to load results. Please try again.");
410
+ if (F.signal.aborted) return;
411
+ h("Failed to load results. Please try again.");
315
412
  } finally {
316
- q.signal.aborted || (E ? ne(!1) : re(!1));
413
+ F.signal.aborted || (X ? ie(!1) : J(!1));
317
414
  }
318
415
  },
319
- [A, m == null ? void 0 : m.paginated, N]
416
+ [O, y == null ? void 0 : y.paginated, L]
320
417
  );
321
- if (fe(() => {
322
- if (!x) return;
323
- const d = (E) => {
324
- Q.current && !Q.current.contains(E.target) && O(!1);
418
+ if (ue(() => {
419
+ if (!z) return;
420
+ const v = (X) => {
421
+ ee.current && !ee.current.contains(X.target) && E(!1);
325
422
  };
326
- return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
327
- }, [x]), fe(() => {
328
- var d;
329
- x || ((d = J.current) == null || d.abort(), B(""), ee([]), Y(!1), b(null), re(!1), ne(!1), T.current = void 0);
330
- }, [x]), fe(() => {
331
- if (!x) return;
332
- if (!F && !v) {
333
- ee([]), Y(!1), b(null), T.current = void 0;
423
+ return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
424
+ }, [z]), ue(() => {
425
+ var v;
426
+ z || ((v = Q.current) == null || v.abort(), K(""), j([]), C(!1), h(null), J(!1), ie(!1), M.current = void 0);
427
+ }, [z]), ue(() => {
428
+ if (!z) return;
429
+ if (!b && !w) {
430
+ j([]), C(!1), h(null), M.current = void 0;
334
431
  return;
335
432
  }
336
- _.current && clearTimeout(_.current);
337
- const d = F ? 300 : 0;
338
- return _.current = setTimeout(() => {
339
- ee([]), Y(!1), T.current = void 0, we(F);
340
- }, d), () => {
341
- _.current && clearTimeout(_.current);
433
+ P.current && clearTimeout(P.current);
434
+ const v = b ? 300 : 0;
435
+ return P.current = setTimeout(() => {
436
+ j([]), C(!1), M.current = void 0, _(b);
437
+ }, v), () => {
438
+ P.current && clearTimeout(P.current);
342
439
  };
343
- }, [F, x, v, we]), ce(a, r, t, w ? void 0 : null), a === !1)
440
+ }, [b, z, w, _]), ge(c, r, t), c === !1)
344
441
  return null;
345
- const Ee = () => {
346
- B(""), ee([]), Y(!1), b(null), T.current = void 0, O(!0);
347
- }, De = (d) => {
348
- t(r, w ? { value: d.id, label: d.name } : d.id), $(d), G.current = { value: d.id, label: w ? d.name : void 0 }, O(!1);
349
- }, Se = (d) => {
350
- d.stopPropagation(), t(r, w ? void 0 : null), $(void 0);
351
- }, Fe = (d) => {
352
- (d.key === "Enter" || d.key === " ") && Se(d);
353
- }, Oe = ((Re = c == null ? void 0 : c.options) == null ? void 0 : Re.placeholder) ?? "Select an option";
354
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
355
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
356
- i,
442
+ const Se = () => {
443
+ K(""), j([]), C(!1), h(null), M.current = void 0, E(!0);
444
+ }, Ve = (v) => {
445
+ t(r, R ? { value: v.id, label: v.name } : v.id), B(v), re.current = { value: v.id, label: R ? v.name : void 0 }, E(!1);
446
+ }, Le = (v) => {
447
+ v.stopPropagation(), t(r, void 0), B(void 0);
448
+ }, He = (v) => {
449
+ (v.key === "Enter" || v.key === " ") && Le(v);
450
+ }, We = ((A = d == null ? void 0 : d.options) == null ? void 0 : A.placeholder) ?? "Select an option";
451
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
452
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
453
+ o,
357
454
  " ",
358
- f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
455
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
359
456
  ] }),
360
- /* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
457
+ /* @__PURE__ */ m("div", { ref: ee, style: { position: "relative" }, children: [
361
458
  /* @__PURE__ */ n(
362
- ye.Root,
459
+ be.Root,
363
460
  {
364
461
  id: r,
365
- value: x ? F : (k == null ? void 0 : k.name) ?? "",
366
- placeholder: x && (m != null && m.searchable) ? "Search..." : Oe,
367
- disabled: !H,
368
- readOnly: x && !(m != null && m.searchable),
462
+ value: z ? b : (x == null ? void 0 : x.name) ?? "",
463
+ placeholder: z && (y != null && y.searchable) ? "Search..." : We,
464
+ disabled: !$,
465
+ readOnly: z && !(y != null && y.searchable),
369
466
  style: W ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
370
- onChange: (d) => {
371
- m != null && m.searchable && (B(d.target.value), x || Ee());
467
+ onChange: (v) => {
468
+ y != null && y.searchable && (K(v.target.value), z || Se());
372
469
  },
373
470
  onFocus: () => {
374
- H && !x && Ee();
471
+ $ && !z && Se();
375
472
  },
376
- onKeyDown: (d) => {
377
- d.key === "Escape" && O(!1);
473
+ onKeyDown: (v) => {
474
+ v.key === "Escape" && E(!1);
378
475
  },
379
- children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
380
- L && H && /* @__PURE__ */ n(
476
+ children: /* @__PURE__ */ n(be.Slot, { side: "right", children: /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
477
+ S && $ && /* @__PURE__ */ n(
381
478
  "span",
382
479
  {
383
480
  role: "button",
384
481
  tabIndex: 0,
385
- onMouseDown: (d) => d.preventDefault(),
386
- onClick: Se,
387
- onKeyDown: Fe,
482
+ onMouseDown: (v) => v.preventDefault(),
483
+ onClick: Le,
484
+ onKeyDown: He,
388
485
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
389
486
  "aria-label": "Clear selection",
390
487
  children: "×"
391
488
  }
392
489
  ),
393
490
  /* @__PURE__ */ n(
394
- zr,
491
+ Ar,
395
492
  {
396
- style: { transform: x ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
493
+ style: { transform: z ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
397
494
  }
398
495
  )
399
496
  ] }) })
400
497
  }
401
498
  ),
402
- x && /* @__PURE__ */ n(
403
- R,
499
+ z && /* @__PURE__ */ n(
500
+ I,
404
501
  {
405
502
  style: {
406
503
  position: "absolute",
@@ -414,341 +511,340 @@ const ce = (e, t, r, i = void 0) => {
414
511
  border: "1px solid var(--gray-a6)",
415
512
  overflow: "hidden"
416
513
  },
417
- children: C ? /* @__PURE__ */ n(R, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: C }) }) : /* @__PURE__ */ n(Lr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(R, { p: "1", children: [
418
- Z && /* @__PURE__ */ n(S, { justify: "center", p: "4", children: /* @__PURE__ */ n(Me, {}) }),
419
- !Z && ue && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: ue }) }),
420
- !Z && !ue && oe.length === 0 && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: F || v ? "No results found." : "Type to search…" }) }),
421
- oe.map((d) => /* @__PURE__ */ n(
422
- R,
514
+ children: D ? /* @__PURE__ */ n(I, { p: "3", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: D }) }) : /* @__PURE__ */ n(wr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ m(I, { p: "1", children: [
515
+ Z && /* @__PURE__ */ n(k, { justify: "center", p: "4", children: /* @__PURE__ */ n(xe, {}) }),
516
+ !Z && ye && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "red", children: ye }) }),
517
+ !Z && !ye && G.length === 0 && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: b || w ? "No results found." : "Type to search…" }) }),
518
+ G.map((v) => /* @__PURE__ */ n(
519
+ I,
423
520
  {
424
521
  px: "3",
425
522
  py: "2",
426
- onMouseDown: (E) => E.preventDefault(),
427
- onClick: () => De(d),
523
+ onMouseDown: (X) => X.preventDefault(),
524
+ onClick: () => Ve(v),
428
525
  style: {
429
526
  cursor: "pointer",
430
527
  borderRadius: "var(--radius-2)",
431
- backgroundColor: d.id === L ? "var(--accent-3)" : void 0
528
+ backgroundColor: v.id === S ? "var(--accent-3)" : void 0
432
529
  },
433
530
  className: "hover:bg-(--gray-3)",
434
- children: /* @__PURE__ */ n(h, { size: "2", children: d.name })
531
+ children: /* @__PURE__ */ n(p, { size: "2", children: v.name })
435
532
  },
436
- d.id
533
+ v.id
437
534
  )),
438
- (m == null ? void 0 : m.paginated) && le && !he && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
- ke,
535
+ (y == null ? void 0 : y.paginated) && Y && !he && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(
536
+ Ie,
440
537
  {
441
538
  variant: "ghost",
442
539
  size: "1",
443
540
  style: { width: "100%" },
444
- onMouseDown: (d) => d.preventDefault(),
445
- onClick: () => void we(F, !0),
541
+ onMouseDown: (v) => v.preventDefault(),
542
+ onClick: () => void _(b, !0),
446
543
  children: "Load more"
447
544
  }
448
545
  ) }),
449
- he && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(Me, {}) })
546
+ he && /* @__PURE__ */ n(k, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
450
547
  ] }) })
451
548
  }
452
549
  )
453
550
  ] }),
454
- !W && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
455
- o.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: o.description })
551
+ !W && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
552
+ s.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: s.description })
456
553
  ] }) });
457
- }, st = se(it), ct = K(
554
+ }, vt = fe(yt), bt = te(
458
555
  3,
459
- ze((e) => {
556
+ De((e) => {
460
557
  const t = e["x-search"];
461
558
  return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
462
559
  })
463
- ), at = (e, t) => $r(`${e}T${t}`).format(), ut = ({ path: e, label: t, required: r, errors: i, description: f, children: s }) => {
464
- const l = i.length === 0;
465
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
466
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
560
+ ), wt = (e, t) => qr(`${e}T${t}`).format(), Et = ({ path: e, label: t, required: r, errors: o, description: u, children: i }) => {
561
+ const l = o.length === 0;
562
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
563
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
467
564
  t,
468
565
  " ",
469
- r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
566
+ r && /* @__PURE__ */ n(p, { color: "red", children: "*" })
470
567
  ] }),
471
- s,
472
- !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(i, t) }),
473
- f && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f })
568
+ i,
569
+ !l && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(o, t) }),
570
+ u && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: u })
474
571
  ] }) });
475
- }, dt = ({
572
+ }, Rt = ({
476
573
  data: e,
477
574
  handleChange: t,
478
575
  path: r,
479
- label: i,
480
- required: f,
481
- errors: s,
576
+ label: o,
577
+ required: u,
578
+ errors: i,
482
579
  schema: l,
483
- enabled: a,
484
- visible: o = !0
580
+ enabled: c,
581
+ visible: s = !0
485
582
  }) => {
486
- if (fe(() => {
487
- o === !1 && t(r, void 0);
488
- }, [o, r, t]), o === !1)
583
+ if (ue(() => {
584
+ s === !1 && t(r, void 0);
585
+ }, [s, r, t]), s === !1)
489
586
  return null;
490
- const c = s.length === 0, u = typeof e == "string" ? e : "", y = (w) => /* @__PURE__ */ n(ut, { path: r, label: i, required: f, errors: s, description: l.description, children: w });
587
+ const d = i.length === 0, a = typeof e == "string" ? e : "", g = (R) => /* @__PURE__ */ n(Et, { path: r, label: o, required: u, errors: i, description: l.description, children: R });
491
588
  if (l.format === "time")
492
- return y(
589
+ return g(
493
590
  /* @__PURE__ */ n(
494
- ye.Root,
591
+ be.Root,
495
592
  {
496
593
  type: "time",
497
- value: u,
498
- onChange: (w) => t(r, w.target.value),
499
- disabled: !a,
500
- color: c ? void 0 : "red",
594
+ value: a,
595
+ onChange: (R) => t(r, R.target.value),
596
+ disabled: !c,
597
+ color: d ? void 0 : "red",
501
598
  id: r
502
599
  }
503
600
  )
504
601
  );
505
- const p = l.format === "date-time", [m = "", v = ""] = u.split("T"), N = v.slice(0, 5), A = (w, I) => {
506
- if (!w) {
602
+ const f = l.format === "date-time", [y = "", w = ""] = a.split("T"), L = w.slice(0, 5), O = (R, T) => {
603
+ if (!R) {
507
604
  t(r, void 0);
508
605
  return;
509
606
  }
510
- t(r, p ? at(w, I || "00:00") : w);
607
+ t(r, f ? wt(R, T || "00:00") : R);
511
608
  };
512
- return y(
513
- /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
609
+ return g(
610
+ /* @__PURE__ */ m(k, { gap: "2", align: "center", children: [
514
611
  /* @__PURE__ */ n(
515
- ye.Root,
612
+ be.Root,
516
613
  {
517
614
  type: "date",
518
- value: m,
519
- disabled: !a,
520
- color: c ? void 0 : "red",
521
- onChange: (w) => A(w.target.value, N),
615
+ value: y,
616
+ disabled: !c,
617
+ color: d ? void 0 : "red",
618
+ onChange: (R) => O(R.target.value, L),
522
619
  id: r,
523
620
  style: { flex: 1 }
524
621
  }
525
622
  ),
526
- p && /* @__PURE__ */ n(
527
- ye.Root,
623
+ f && /* @__PURE__ */ n(
624
+ be.Root,
528
625
  {
529
626
  type: "time",
530
- value: N,
531
- disabled: !a || !m,
532
- color: c ? void 0 : "red",
533
- onChange: (w) => A(m, w.target.value),
627
+ value: L,
628
+ disabled: !c || !y,
629
+ color: d ? void 0 : "red",
630
+ onChange: (R) => O(y, R.target.value),
534
631
  style: { flex: 1 }
535
632
  }
536
633
  )
537
634
  ] })
538
635
  );
539
- }, ft = K(2, Le(Rr, Cr, Tr)), ht = se(dt), pt = ({
636
+ }, At = te(2, _e(Pr, $r, _r)), Ct = fe(Rt), Tt = ({
540
637
  uischema: e,
541
638
  schema: t,
542
639
  path: r,
543
- renderers: i,
544
- cells: f,
545
- enabled: s,
640
+ renderers: o,
641
+ cells: u,
642
+ enabled: i,
546
643
  visible: l = !0
547
644
  }) => {
548
- const o = e.elements;
549
- return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
550
- Ae,
645
+ const s = e.elements;
646
+ return l === !1 ? null : /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(
647
+ ze,
551
648
  {
552
- uischema: c,
649
+ uischema: d,
553
650
  schema: t,
554
651
  path: r,
555
- renderers: i,
556
- cells: f,
557
- enabled: s
652
+ renderers: o,
653
+ cells: u,
654
+ enabled: i
558
655
  },
559
- `${r}-${u}`
656
+ `${r}-${a}`
560
657
  )) });
561
- }, mt = K(1, Te("VerticalLayout")), gt = ({
658
+ }, St = te(1, Me("VerticalLayout")), Ot = ({
562
659
  uischema: e,
563
660
  schema: t,
564
661
  path: r,
565
- renderers: i,
566
- cells: f,
567
- enabled: s,
662
+ renderers: o,
663
+ cells: u,
664
+ enabled: i,
568
665
  visible: l = !0
569
666
  }) => {
570
- const o = e.elements;
571
- return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "row", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(R, { style: { flex: 1 }, children: /* @__PURE__ */ n(
572
- Ae,
667
+ const s = e.elements;
668
+ return l === !1 ? null : /* @__PURE__ */ n(k, { direction: "row", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(I, { style: { flex: 1 }, children: /* @__PURE__ */ n(
669
+ ze,
573
670
  {
574
- uischema: c,
671
+ uischema: d,
575
672
  schema: t,
576
673
  path: r,
577
- renderers: i,
578
- cells: f,
579
- enabled: s
674
+ renderers: o,
675
+ cells: u,
676
+ enabled: i
580
677
  }
581
- ) }, `${r}-${u}`)) });
582
- }, yt = K(1, Te("HorizontalLayout")), vt = ({
678
+ ) }, `${r}-${a}`)) });
679
+ }, xt = te(1, Me("HorizontalLayout")), Nt = ({
583
680
  uischema: e,
584
681
  schema: t,
585
682
  path: r,
586
- renderers: i,
587
- cells: f,
588
- enabled: s,
683
+ renderers: o,
684
+ cells: u,
685
+ enabled: i,
589
686
  visible: l = !0
590
687
  }) => {
591
- const a = e, o = a.elements;
592
- return l === !1 ? null : /* @__PURE__ */ g(R, { mb: "6", children: [
593
- a.label && /* @__PURE__ */ n(tr, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: a.label }),
594
- /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
595
- Ae,
688
+ const c = e, s = c.elements;
689
+ return l === !1 ? null : /* @__PURE__ */ m(I, { mb: "6", children: [
690
+ c.label && /* @__PURE__ */ n(Er, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: c.label }),
691
+ /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(
692
+ ze,
596
693
  {
597
- uischema: c,
694
+ uischema: d,
598
695
  schema: t,
599
696
  path: r,
600
- renderers: i,
601
- cells: f,
602
- enabled: s
697
+ renderers: o,
698
+ cells: u,
699
+ enabled: i
603
700
  },
604
- `${r}-${u}`
701
+ `${r}-${a}`
605
702
  )) })
606
703
  ] });
607
- }, bt = K(1, Te("Group")), wt = ({
704
+ }, It = te(1, Me("Group")), kt = ({
608
705
  uischema: e,
609
706
  schema: t,
610
707
  path: r,
611
- renderers: i,
612
- cells: f,
613
- enabled: s,
708
+ renderers: o,
709
+ cells: u,
710
+ enabled: i,
614
711
  visible: l = !0
615
712
  }) => {
616
- var p;
617
- const o = e.elements.filter((m) => m.type === "Category"), [c, u] = U(((p = o[0]) == null ? void 0 : p.label) || "");
618
- if (l === !1 || !o.length) return null;
619
- const y = o.find((m) => m.label === c) ? c : o[0].label;
620
- return /* @__PURE__ */ g(Ie.Root, { value: y, onValueChange: u, children: [
621
- /* @__PURE__ */ n(Ie.List, { children: o.map((m, v) => /* @__PURE__ */ n(Ie.Trigger, { value: m.label, children: m.label }, `${r}-${v}`)) }),
622
- /* @__PURE__ */ n(R, { pt: "3", children: o.map((m, v) => /* @__PURE__ */ n(Ie.Content, { value: m.label, children: /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: m.elements.map((N, A) => /* @__PURE__ */ n(
623
- Ae,
713
+ var f;
714
+ const s = e.elements.filter((y) => y.type === "Category"), [d, a] = H(((f = s[0]) == null ? void 0 : f.label) || "");
715
+ if (l === !1 || !s.length) return null;
716
+ const g = s.find((y) => y.label === d) ? d : s[0].label;
717
+ return /* @__PURE__ */ m(Ue.Root, { value: g, onValueChange: a, children: [
718
+ /* @__PURE__ */ n(Ue.List, { children: s.map((y, w) => /* @__PURE__ */ n(Ue.Trigger, { value: y.label, children: y.label }, `${r}-${w}`)) }),
719
+ /* @__PURE__ */ n(I, { pt: "3", children: s.map((y, w) => /* @__PURE__ */ n(Ue.Content, { value: y.label, children: /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: y.elements.map((L, O) => /* @__PURE__ */ n(
720
+ ze,
624
721
  {
625
- uischema: N,
722
+ uischema: L,
626
723
  schema: t,
627
724
  path: r,
628
- renderers: i,
629
- cells: f,
630
- enabled: s
725
+ renderers: o,
726
+ cells: u,
727
+ enabled: i
631
728
  },
632
- `${r}-${v}-${A}`
633
- )) }) }, `${r}-${v}`)) })
729
+ `${r}-${w}-${O}`
730
+ )) }) }, `${r}-${w}`)) })
634
731
  ] });
635
- }, Et = K(1, Te("Categorization"));
636
- function me(e) {
732
+ }, Dt = te(1, Me("Categorization"));
733
+ function pe(e) {
637
734
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
638
735
  }
639
- function ge(e) {
640
- return e.split(",").map((t) => {
641
- if (t = t.trim(), t.endsWith("/*"))
642
- return t.split("/")[0].toUpperCase() + "S";
643
- if (t.startsWith("."))
644
- return t.slice(1).toUpperCase();
645
- const r = t.split("/")[1];
646
- return r ? r.toUpperCase() : t;
647
- }).join(", ");
736
+ function me(e) {
737
+ const t = e.split(",").map((i) => i.trim()).filter(Boolean), r = t.filter((i) => i.startsWith(".")), u = (r.length > 0 ? r : t).map((i) => {
738
+ if (i.endsWith("/*")) return i.split("/")[0].toUpperCase() + "S";
739
+ if (i.startsWith(".")) return i.slice(1).toUpperCase();
740
+ const l = i.split("/")[1];
741
+ return l ? l.toUpperCase() : i;
742
+ });
743
+ return [...new Set(u)].join(", ");
648
744
  }
649
- function Rt(e) {
745
+ function Mt(e) {
650
746
  return e ? Array.isArray(e) ? e : [e] : [];
651
747
  }
652
- const Ct = ({
748
+ const zt = ({
653
749
  data: e,
654
750
  handleChange: t,
655
751
  path: r,
656
- label: i,
657
- required: f,
658
- uischema: s,
752
+ label: o,
753
+ required: u,
754
+ uischema: i,
659
755
  schema: l,
660
- enabled: a,
661
- errors: o,
662
- visible: c = !0
756
+ enabled: c,
757
+ errors: s,
758
+ visible: d = !0
663
759
  }) => {
664
- const u = Vr();
665
- ce(c, r, t, null);
666
- const y = !o || o.length === 0, p = (l == null ? void 0 : l["x-file"]) ?? {}, m = (s == null ? void 0 : s.options) ?? {}, v = p.maxFiles ?? m.maxFiles ?? 1, N = p.maxSize ?? m.maxSize ?? 5 * 1024 * 1024, A = p.accept ?? m.accept ?? "image/*,application/pdf", w = v > 1, I = a !== !1, [L, D] = U(!1), [C, H] = U(null), [W, x] = U({}), O = de(/* @__PURE__ */ new Set()), F = de(null), B = Rt(e), oe = B.length >= v;
667
- fe(() => () => {
668
- O.current.forEach((b) => URL.revokeObjectURL(b)), O.current.clear();
760
+ const a = Qr();
761
+ ge(d, r, t);
762
+ const g = !s || s.length === 0, f = (l == null ? void 0 : l["x-file"]) ?? {}, y = (i == null ? void 0 : i.options) ?? {}, w = f.maxFiles ?? y.maxFiles ?? 1, L = f.maxSize ?? y.maxSize ?? 5 * 1024 * 1024, O = f.accept ?? y.accept ?? "image/*,application/pdf", R = w > 1, T = c !== !1, [S, N] = H(!1), [D, $] = H(null), [W, z] = H({}), E = le(/* @__PURE__ */ new Set()), b = le(null), K = Mt(e), G = K.length >= w;
763
+ ue(() => () => {
764
+ E.current.forEach((h) => URL.revokeObjectURL(h)), E.current.clear();
669
765
  }, []);
670
- const ee = _e(
671
- async (b) => {
672
- if (H(null), B.length >= v) {
673
- H(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
766
+ const j = Ne(
767
+ async (h) => {
768
+ if ($(null), K.length >= w) {
769
+ $(`Maximum ${w} file${w > 1 ? "s" : ""} allowed.`);
674
770
  return;
675
771
  }
676
- if (b.size > N) {
677
- H(`File exceeds the ${me(N)} limit.`);
772
+ if (h.size > L) {
773
+ $(`File exceeds the ${pe(L)} limit.`);
678
774
  return;
679
775
  }
680
- if (!A.split(",").map((T) => T.trim()).some((T) => T === "*" || T === "*/*" ? !0 : T.endsWith("/*") ? b.type.startsWith(T.slice(0, -1)) : T.startsWith(".") ? b.name.toLowerCase().endsWith(T.toLowerCase()) : b.type === T)) {
681
- H(`Invalid type. Accepted: ${ge(A)}`);
776
+ if (!O.split(",").map((M) => M.trim()).some((M) => M === "*" || M === "*/*" ? !0 : M.endsWith("/*") ? h.type.startsWith(M.slice(0, -1)) : M.startsWith(".") ? h.name.toLowerCase().endsWith(M.toLowerCase()) : h.type === M)) {
777
+ $(`Invalid type. Accepted: ${me(O)}`);
682
778
  return;
683
779
  }
684
- if (!(u != null && u.onUpload)) {
685
- H("Upload service not configured.");
780
+ if (!(a != null && a.onUpload)) {
781
+ $("Upload service not configured.");
686
782
  return;
687
783
  }
688
784
  try {
689
- const T = await u.onUpload(b), _ = URL.createObjectURL(b);
690
- O.current.add(_);
691
- const J = { key: T.key, name: T.name ?? b.name, blobUrl: _ };
692
- x((G) => ({ ...G, [T.key]: J }));
693
- const Q = [...B, T.key];
694
- t(r, w ? Q : Q[0]);
785
+ const M = await a.onUpload(h), P = URL.createObjectURL(h);
786
+ E.current.add(P);
787
+ const Q = { key: M.key, name: M.name ?? h.name, blobUrl: P };
788
+ z((re) => ({ ...re, [M.key]: Q }));
789
+ const ee = [...K, M.key];
790
+ t(r, R ? ee : ee[0]);
695
791
  } catch {
696
- H("Upload failed. Please try again."), F.current && (F.current.value = "");
792
+ $("Upload failed. Please try again."), b.current && (b.current.value = "");
697
793
  }
698
794
  },
699
- [B, v, N, A, u, r, t, w]
795
+ [K, w, L, O, a, r, t, R]
700
796
  );
701
- if (c === !1)
797
+ if (d === !1)
702
798
  return null;
703
- const le = (b) => {
704
- b.preventDefault(), b.stopPropagation(), !(!I || oe) && D(b.type === "dragenter" || b.type === "dragover");
705
- }, Y = (b) => {
706
- var k;
707
- b.preventDefault(), b.stopPropagation(), D(!1), !(!I || oe) && (k = b.dataTransfer.files) != null && k[0] && ee(b.dataTransfer.files[0]);
708
- }, Z = (b) => {
709
- var k;
710
- (k = b.target.files) != null && k[0] && (ee(b.target.files[0]), b.target.value = "");
711
- }, re = (b) => {
712
- if (!I) return;
713
- x(($) => {
714
- var J;
715
- const T = { ...$ }, _ = (J = T[b]) == null ? void 0 : J.blobUrl;
716
- return _ && (URL.revokeObjectURL(_), O.current.delete(_)), delete T[b], T;
799
+ const Y = (h) => {
800
+ h.preventDefault(), h.stopPropagation(), !(!T || G) && N(h.type === "dragenter" || h.type === "dragover");
801
+ }, C = (h) => {
802
+ var x;
803
+ h.preventDefault(), h.stopPropagation(), N(!1), !(!T || G) && (x = h.dataTransfer.files) != null && x[0] && j(h.dataTransfer.files[0]);
804
+ }, Z = (h) => {
805
+ var x;
806
+ (x = h.target.files) != null && x[0] && (j(h.target.files[0]), h.target.value = "");
807
+ }, J = (h) => {
808
+ if (!T) return;
809
+ z((B) => {
810
+ var Q;
811
+ const M = { ...B }, P = (Q = M[h]) == null ? void 0 : Q.blobUrl;
812
+ return P && (URL.revokeObjectURL(P), E.current.delete(P)), delete M[h], M;
717
813
  });
718
- const k = B.filter(($) => $ !== b);
719
- t(r, w ? k.length > 0 ? k : null : k[0] ?? null);
720
- }, he = async (b, k) => {
721
- var _, J, Q;
722
- b.preventDefault();
723
- const $ = (_ = W[k]) == null ? void 0 : _.blobUrl;
724
- if ($) {
725
- (J = window.open($, "_blank", "noopener,noreferrer")) == null || J.focus();
814
+ const x = K.filter((B) => B !== h);
815
+ t(r, R ? x.length > 0 ? x : void 0 : x[0]);
816
+ }, he = async (h, x) => {
817
+ var P, Q, ee;
818
+ h.preventDefault();
819
+ const B = (P = W[x]) == null ? void 0 : P.blobUrl;
820
+ if (B) {
821
+ (Q = window.open(B, "_blank", "noopener,noreferrer")) == null || Q.focus();
726
822
  return;
727
823
  }
728
- const T = window.open("", "_blank");
729
- if (T)
824
+ const M = window.open("", "_blank");
825
+ if (M)
730
826
  try {
731
- const G = await ((Q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : Q.call(u, k));
732
- G != null && G.url ? T.location.href = G.url : T.close();
827
+ const re = await ((ee = a == null ? void 0 : a.getDownloadUrl) == null ? void 0 : ee.call(a, x));
828
+ re != null && re.url ? M.location.href = re.url : M.close();
733
829
  } catch {
734
- T.close();
830
+ M.close();
735
831
  }
736
832
  };
737
- if (!I && B.length === 0) return null;
738
- const ne = v - B.length, ue = I && !oe;
739
- return /* @__PURE__ */ g(R, { mb: "4", children: [
740
- /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
741
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
742
- i,
743
- f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
833
+ if (!T && K.length === 0) return null;
834
+ const ie = w - K.length, ye = T && !G;
835
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
836
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
837
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
838
+ o,
839
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
744
840
  ] }),
745
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(N)} each · ${ge(A)}` : `${me(N)} · ${ge(A)}` })
841
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: R ? `Up to ${w} files · ${pe(L)} each · ${me(O)}` : `${pe(L)} · ${me(O)}` })
746
842
  ] }),
747
- B.map((b) => {
748
- var k;
749
- return /* @__PURE__ */ n(nr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
843
+ K.map((h) => {
844
+ var x;
845
+ return /* @__PURE__ */ n(Rr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ m(k, { align: "center", gap: "3", children: [
750
846
  /* @__PURE__ */ n(
751
- R,
847
+ I,
752
848
  {
753
849
  style: {
754
850
  background: "var(--blue-3)",
@@ -757,11 +853,11 @@ const Ct = ({
757
853
  color: "var(--blue-9)",
758
854
  flexShrink: 0
759
855
  },
760
- children: /* @__PURE__ */ n(Dr, { width: "20", height: "20" })
856
+ children: /* @__PURE__ */ n(Gr, { width: "20", height: "20" })
761
857
  }
762
858
  ),
763
- /* @__PURE__ */ n(R, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
764
- h,
859
+ /* @__PURE__ */ n(I, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
860
+ p,
765
861
  {
766
862
  size: "2",
767
863
  weight: "bold",
@@ -771,70 +867,70 @@ const Ct = ({
771
867
  textOverflow: "ellipsis",
772
868
  whiteSpace: "nowrap"
773
869
  },
774
- children: ((k = W[b]) == null ? void 0 : k.name) ?? "Uploaded File"
870
+ children: ((x = W[h]) == null ? void 0 : x.name) ?? "Uploaded File"
775
871
  }
776
872
  ) }),
777
- /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
778
- /* @__PURE__ */ n(ke, { variant: "soft", color: "blue", size: "1", onClick: ($) => he($, b), children: "View" }),
779
- /* @__PURE__ */ n(Fr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
780
- I && /* @__PURE__ */ n(Ue, { variant: "ghost", color: "gray", onClick: () => re(b), children: /* @__PURE__ */ n(or, {}) })
873
+ /* @__PURE__ */ m(k, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
874
+ /* @__PURE__ */ n(Ie, { variant: "soft", color: "blue", size: "1", onClick: (B) => he(B, h), children: "View" }),
875
+ /* @__PURE__ */ n(Yr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
876
+ T && /* @__PURE__ */ n(ke, { variant: "ghost", color: "gray", onClick: () => J(h), children: /* @__PURE__ */ n(Je, {}) })
781
877
  ] })
782
- ] }) }, b);
878
+ ] }) }, h);
783
879
  }),
784
- ue && /* @__PURE__ */ g(
880
+ ye && /* @__PURE__ */ m(
785
881
  "div",
786
882
  {
787
883
  role: "button",
788
884
  tabIndex: 0,
789
885
  onClick: () => {
790
- var b;
791
- return (b = F.current) == null ? void 0 : b.click();
886
+ var h;
887
+ return (h = b.current) == null ? void 0 : h.click();
792
888
  },
793
- onKeyDown: (b) => {
794
- var k;
795
- (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (k = F.current) == null || k.click());
889
+ onKeyDown: (h) => {
890
+ var x;
891
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = b.current) == null || x.click());
796
892
  },
797
- onDragEnter: le,
798
- onDragLeave: le,
799
- onDragOver: le,
800
- onDrop: Y,
893
+ onDragEnter: Y,
894
+ onDragLeave: Y,
895
+ onDragOver: Y,
896
+ onDrop: C,
801
897
  style: { cursor: "pointer" },
802
898
  className: [
803
899
  "border-2 border-dashed rounded-lg p-6 text-center",
804
900
  "transition-all duration-200 ease-in-out",
805
- L ? "border-blue-500 bg-blue-50" : C ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
901
+ S ? "border-blue-500 bg-blue-50" : D ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
806
902
  ].join(" "),
807
903
  children: [
808
- /* @__PURE__ */ n("input", { ref: F, type: "file", style: { display: "none" }, accept: A, onChange: Z }),
809
- /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: C ? /* @__PURE__ */ g(be, { children: [
810
- /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
811
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: C }),
812
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
813
- ] }) : /* @__PURE__ */ g(be, { children: [
814
- /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
815
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: B.length > 0 ? `Add another file (${ne} remaining)` : "Click to upload or drag and drop" }),
816
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
817
- me(N),
904
+ /* @__PURE__ */ n("input", { ref: b, type: "file", style: { display: "none" }, accept: O, onChange: Z }),
905
+ /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: D ? /* @__PURE__ */ m(ae, { children: [
906
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
907
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: D }),
908
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
909
+ ] }) : /* @__PURE__ */ m(ae, { children: [
910
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
911
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: K.length > 0 ? `Add another file (${ie} remaining)` : "Click to upload or drag and drop" }),
912
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
913
+ pe(L),
818
914
  " max · ",
819
- ge(A)
915
+ me(O)
820
916
  ] })
821
917
  ] }) })
822
918
  ]
823
919
  }
824
920
  ),
825
- I && oe && w && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
921
+ T && G && R && /* @__PURE__ */ m(p, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
826
922
  "Maximum ",
827
- v,
923
+ w,
828
924
  " files uploaded. Remove one to replace it."
829
925
  ] }),
830
- !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
926
+ !g && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
831
927
  ] });
832
- }, Tt = se(Ct), At = K(
928
+ }, Lt = fe(zt), Ft = te(
833
929
  10,
834
930
  // high rank to beat default array renderer
835
- Ar(
931
+ Vr(
836
932
  // Match both single-file (type: string) and multi-file (type: array)
837
- ze((e) => {
933
+ De((e) => {
838
934
  if (e.type === "string" && e.format === "file") return !0;
839
935
  if (e.type === "array") {
840
936
  const t = e.items;
@@ -844,42 +940,42 @@ const Ct = ({
844
940
  })
845
941
  )
846
942
  );
847
- function St(e, t) {
943
+ function Sr(e, t) {
848
944
  return e !== !1 && t !== !0;
849
945
  }
850
- class $e extends Error {
946
+ class Ge extends Error {
851
947
  }
852
- function Ot(e, t) {
853
- const r = _r(e, { type: "array", cellDates: !0 });
854
- if (r.SheetNames.length === 0)
855
- throw new $e("This file has no sheets.");
856
- const i = t ?? r.SheetNames[0], f = r.Sheets[i];
857
- if (!f)
858
- throw new $e(`This file doesn't have a sheet named "${i}".`);
859
- const s = Pr.sheet_to_json(f, { header: 1, raw: !0, defval: null });
948
+ async function Ut(e, t) {
949
+ const { read: r, utils: o } = await import("@e965/xlsx"), u = r(e, { type: "array", cellDates: !0 });
950
+ if (u.SheetNames.length === 0)
951
+ throw new Ge("This file has no sheets.");
952
+ const i = t ?? u.SheetNames[0], l = u.Sheets[i];
953
+ if (!l)
954
+ throw new Ge(`This file doesn't have a sheet named "${i}".`);
955
+ const c = o.sheet_to_json(l, { header: 1, raw: !0, defval: null });
860
956
  return {
861
957
  sheetName: i,
862
- matrix: s,
863
- rowCount: s.length,
864
- colCount: Math.max(0, ...s.map((l) => l.length))
958
+ matrix: c,
959
+ rowCount: c.length,
960
+ colCount: Math.max(0, ...c.map((s) => s.length))
865
961
  };
866
962
  }
867
- function Nt(e) {
963
+ function Pt(e) {
868
964
  let t = e + 1, r = "";
869
965
  for (; t > 0; ) {
870
- const i = (t - 1) % 26;
871
- r = String.fromCharCode(65 + i) + r, t = Math.floor((t - 1) / 26);
966
+ const o = (t - 1) % 26;
967
+ r = String.fromCharCode(65 + o) + r, t = Math.floor((t - 1) / 26);
872
968
  }
873
969
  return r;
874
970
  }
875
- class j extends Error {
876
- constructor(r, i) {
877
- super(i ?? r);
878
- Pe(this, "code");
971
+ class oe extends Error {
972
+ constructor(r, o) {
973
+ super(o ?? r);
974
+ tr(this, "code");
879
975
  this.code = r, this.name = "FormulaError";
880
976
  }
881
977
  }
882
- const It = [
978
+ const $t = [
883
979
  // Logical
884
980
  // IF is excluded here even though its native body is real, non-stub code —
885
981
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -905,7 +1001,7 @@ const It = [
905
1001
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
906
1002
  "DATE",
907
1003
  "TODAY"
908
- ], xt = [
1004
+ ], _t = [
909
1005
  "MAX",
910
1006
  "MIN",
911
1007
  "MAXA",
@@ -924,7 +1020,7 @@ const It = [
924
1020
  "COUNTA",
925
1021
  // not present in fast-formula-parser's function table at all.
926
1022
  "UPPER"
927
- ], Mt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], kt = ["IF"], Lt = [
1023
+ ], Vt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Ht = ["IF"], Wt = [
928
1024
  "CONCATENATE",
929
1025
  "CONCAT",
930
1026
  "LEN",
@@ -935,115 +1031,115 @@ const It = [
935
1031
  "MID",
936
1032
  "FIND",
937
1033
  "SEARCH"
938
- ], zt = /* @__PURE__ */ new Set([
939
- ...It,
940
- ...xt,
941
- ...Mt,
942
- ...Lt,
943
- ...kt
944
- ]), Dt = /"(?:[^"]|"")*"/g, Be = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
945
- function Ft(e) {
946
- const t = e.replace(Dt, (i) => " ".repeat(i.length));
947
- Be.lastIndex = 0;
1034
+ ], jt = /* @__PURE__ */ new Set([
1035
+ ...$t,
1036
+ ..._t,
1037
+ ...Vt,
1038
+ ...Wt,
1039
+ ...Ht
1040
+ ]), Bt = /"(?:[^"]|"")*"/g, or = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1041
+ function Xt(e) {
1042
+ const t = e.replace(Bt, (o) => " ".repeat(o.length));
1043
+ or.lastIndex = 0;
948
1044
  let r;
949
- for (; (r = Be.exec(t)) !== null; ) {
950
- const i = r[1].toUpperCase();
951
- if (!zt.has(i))
952
- throw new j("NAME", `Function ${i} is not allowed.`);
1045
+ for (; (r = or.exec(t)) !== null; ) {
1046
+ const o = r[1].toUpperCase();
1047
+ if (!jt.has(o))
1048
+ throw new oe("NAME", `Function ${o} is not allowed.`);
953
1049
  }
954
1050
  }
955
- function Ut(e, t, r) {
956
- let i = e;
957
- if (i == null) throw r.NA;
958
- if (typeof i == "object" && !(i instanceof r) && (i = t.retrieveRef(i)), i instanceof r) throw i;
959
- if (typeof i == "boolean") return i;
960
- if (typeof i == "number") return i !== 0;
1051
+ function Kt(e, t, r) {
1052
+ let o = e;
1053
+ if (o == null) throw r.NA;
1054
+ if (typeof o == "object" && !(o instanceof r) && (o = t.retrieveRef(o)), o instanceof r) throw o;
1055
+ if (typeof o == "boolean") return o;
1056
+ if (typeof o == "number") return o !== 0;
961
1057
  throw r.VALUE;
962
1058
  }
963
- function cr(e) {
1059
+ function Or(e) {
964
1060
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
965
1061
  }
966
- function pe(e) {
967
- const t = cr(e);
1062
+ function Ce(e) {
1063
+ const t = Or(e);
968
1064
  return Array.isArray(t) ? t.flat(1 / 0) : [t];
969
1065
  }
970
- function M(e) {
971
- const t = cr(e);
1066
+ function V(e) {
1067
+ const t = Or(e);
972
1068
  return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
973
1069
  }
974
- function xe(e) {
975
- return e === void 0 ? void 0 : M(e);
1070
+ function Pe(e) {
1071
+ return e === void 0 ? void 0 : V(e);
976
1072
  }
977
- function X(e) {
1073
+ function ne(e) {
978
1074
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
979
1075
  }
980
- function Ht(e, t) {
1076
+ function Gt(e, t) {
981
1077
  return e instanceof t ? e : new t(e.message || "#ERROR!");
982
1078
  }
983
- function V(e) {
1079
+ function q(e) {
984
1080
  return e.find((t) => t instanceof Error);
985
1081
  }
986
- function $t(e, t) {
987
- const r = (s) => {
988
- throw Ht(s, t);
989
- }, i = (s, { checkArgsForErrors: l = !0 } = {}) => (...a) => {
990
- const o = a.flatMap(pe);
1082
+ function Yt(e, t) {
1083
+ const r = (i) => {
1084
+ throw Gt(i, t);
1085
+ }, o = (i, { checkArgsForErrors: l = !0 } = {}) => (...c) => {
1086
+ const s = c.flatMap(Ce);
991
1087
  if (l) {
992
- const u = V(o);
993
- u && r(u);
1088
+ const a = q(s);
1089
+ a && r(a);
994
1090
  }
995
- const c = s(...o);
996
- return c instanceof Error ? r(c) : c;
997
- }, f = (s, { toText: l = !1 } = {}) => (a) => {
998
- const o = M(a), c = V([o]);
999
- c && r(c);
1000
- const u = s(l ? X(o) : o);
1001
- return u instanceof Error ? r(u) : u;
1091
+ const d = i(...s);
1092
+ return d instanceof Error ? r(d) : d;
1093
+ }, u = (i, { toText: l = !1 } = {}) => (c) => {
1094
+ const s = V(c), d = q([s]);
1095
+ d && r(d);
1096
+ const a = i(l ? ne(s) : s);
1097
+ return a instanceof Error ? r(a) : a;
1002
1098
  };
1003
1099
  return {
1004
1100
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
1005
1101
  // dereferenced or type-checked here) — that's what makes
1006
1102
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
1007
- IF: (s, l, a, o) => {
1008
- const c = Ut(l, s, t);
1009
- if (a == null) throw t.NA;
1010
- return c ? a : o ?? !1;
1103
+ IF: (i, l, c, s) => {
1104
+ const d = Kt(l, i, t);
1105
+ if (c == null) throw t.NA;
1106
+ return d ? c : s ?? !1;
1011
1107
  },
1012
1108
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1013
1109
  // and formulajs's own convention for MAX/MIN.
1014
- MAX: i(e.MAX),
1015
- MIN: i(e.MIN),
1016
- MAXA: i(e.MAXA),
1017
- MINA: i(e.MINA),
1018
- MEDIAN: i(e.MEDIAN),
1110
+ MAX: o(e.MAX),
1111
+ MIN: o(e.MIN),
1112
+ MAXA: o(e.MAXA),
1113
+ MINA: o(e.MINA),
1114
+ MEDIAN: o(e.MEDIAN),
1019
1115
  // COUNTA counts non-blank entries; an error value among the args is
1020
1116
  // itself non-blank and gets counted (matching formulajs's own COUNTA,
1021
1117
  // which never checks for errors), so this skips the error propagation
1022
1118
  // the other aggregates use.
1023
- COUNTA: i(e.COUNTA, { checkArgsForErrors: !1 }),
1024
- LARGE: (s, l) => {
1025
- const a = pe(s), o = M(l), c = V([...a, o]);
1026
- c && r(c);
1027
- const u = e.LARGE(a, o);
1028
- return u instanceof Error ? r(u) : u;
1119
+ COUNTA: o(e.COUNTA, { checkArgsForErrors: !1 }),
1120
+ LARGE: (i, l) => {
1121
+ const c = Ce(i), s = V(l), d = q([...c, s]);
1122
+ d && r(d);
1123
+ const a = e.LARGE(c, s);
1124
+ return a instanceof Error ? r(a) : a;
1029
1125
  },
1030
- SMALL: (s, l) => {
1031
- const a = pe(s), o = M(l), c = V([...a, o]);
1032
- c && r(c);
1033
- const u = e.SMALL(a, o);
1034
- return u instanceof Error ? r(u) : u;
1126
+ SMALL: (i, l) => {
1127
+ const c = Ce(i), s = V(l), d = q([...c, s]);
1128
+ d && r(d);
1129
+ const a = e.SMALL(c, s);
1130
+ return a instanceof Error ? r(a) : a;
1035
1131
  },
1036
- PERMUT: (s, l) => {
1037
- const a = [M(s), M(l)], o = V(a);
1038
- o && r(o);
1039
- const c = e.PERMUT(a[0], a[1]);
1040
- return c instanceof Error ? r(c) : c;
1132
+ PERMUT: (i, l) => {
1133
+ const c = [V(i), V(l)], s = q(c);
1134
+ s && r(s);
1135
+ const d = e.PERMUT(c[0], c[1]);
1136
+ return d instanceof Error ? r(d) : d;
1041
1137
  },
1042
- PERMUTATIONA: (s, l) => {
1043
- const a = [M(s), M(l)], o = V(a);
1044
- o && r(o);
1045
- const c = e.PERMUTATIONA(a[0], a[1]);
1046
- return c instanceof Error ? r(c) : c;
1138
+ PERMUTATIONA: (i, l) => {
1139
+ const c = [V(i), V(l)], s = q(c);
1140
+ s && r(s);
1141
+ const d = e.PERMUTATIONA(c[0], c[1]);
1142
+ return d instanceof Error ? r(d) : d;
1047
1143
  },
1048
1144
  // match_type is intentionally ignored and forced to 0 (exact match)
1049
1145
  // regardless of what the formula author supplied — approximate/sorted
@@ -1051,43 +1147,43 @@ function $t(e, t) {
1051
1147
  // Excel's own default too) risks silently mis-ranking unsorted
1052
1148
  // real-world data. Same scope decision as the hand-rolled engine this
1053
1149
  // replaces, carried forward deliberately rather than dropped.
1054
- MATCH: (s, l) => {
1055
- const a = M(s), o = pe(l), c = V([a, ...o]);
1150
+ MATCH: (i, l) => {
1151
+ const c = V(i), s = Ce(l), d = q([c, ...s]);
1152
+ d && r(d);
1153
+ const a = e.MATCH(c, s, 0);
1154
+ return a instanceof Error ? r(a) : a;
1155
+ },
1156
+ SWITCH: (...i) => {
1157
+ const l = i.map(V), c = q(l);
1056
1158
  c && r(c);
1057
- const u = e.MATCH(a, o, 0);
1058
- return u instanceof Error ? r(u) : u;
1159
+ const s = e.SWITCH(...l);
1160
+ return s instanceof Error ? r(s) : s;
1059
1161
  },
1060
- SWITCH: (...s) => {
1061
- const l = s.map(M), a = V(l);
1162
+ SUBSTITUTE: (i, l, c, s) => {
1163
+ const d = [ne(V(i)), ne(V(l)), ne(V(c))];
1164
+ s !== void 0 && d.push(V(s));
1165
+ const a = q(d);
1062
1166
  a && r(a);
1063
- const o = e.SWITCH(...l);
1064
- return o instanceof Error ? r(o) : o;
1167
+ const g = e.SUBSTITUTE(...d);
1168
+ return g instanceof Error ? r(g) : g;
1065
1169
  },
1066
- SUBSTITUTE: (s, l, a, o) => {
1067
- const c = [X(M(s)), X(M(l)), X(M(a))];
1068
- o !== void 0 && c.push(M(o));
1069
- const u = V(c);
1070
- u && r(u);
1071
- const y = e.SUBSTITUTE(...c);
1072
- return y instanceof Error ? r(y) : y;
1170
+ TEXTJOIN: (i, l, ...c) => {
1171
+ const s = ne(V(i)), d = V(l), a = c.flatMap(Ce).map(ne), g = q([s, d]);
1172
+ g && r(g);
1173
+ const f = e.TEXTJOIN(s, d, a);
1174
+ return f instanceof Error ? r(f) : f;
1073
1175
  },
1074
- TEXTJOIN: (s, l, ...a) => {
1075
- const o = X(M(s)), c = M(l), u = a.flatMap(pe).map(X), y = V([o, c]);
1076
- y && r(y);
1077
- const p = e.TEXTJOIN(o, c, u);
1078
- return p instanceof Error ? r(p) : p;
1079
- },
1080
- UPPER: f(e.UPPER),
1176
+ UPPER: u(e.UPPER),
1081
1177
  // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
1082
1178
  // fast-formula-parser's own (real, but broken-for-Date-cells) versions.
1083
- YEAR: f(e.YEAR),
1084
- MONTH: f(e.MONTH),
1085
- DAY: f(e.DAY),
1086
- WEEKDAY: (s, l) => {
1087
- const a = M(s), o = M(l), c = V([a]);
1088
- c && r(c);
1089
- const u = e.WEEKDAY(a, o);
1090
- return u instanceof Error ? r(u) : u;
1179
+ YEAR: u(e.YEAR),
1180
+ MONTH: u(e.MONTH),
1181
+ DAY: u(e.DAY),
1182
+ WEEKDAY: (i, l) => {
1183
+ const c = V(i), s = V(l), d = q([c]);
1184
+ d && r(d);
1185
+ const a = e.WEEKDAY(c, s);
1186
+ return a instanceof Error ? r(a) : a;
1091
1187
  },
1092
1188
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1093
1189
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1098,54 +1194,54 @@ function $t(e, t) {
1098
1194
  // Flattens every argument (a whole range included) and joins with no
1099
1195
  // separator, matching Excel's own range-argument behavior — the native
1100
1196
  // implementation instead inserts stray commas for a whole-range argument.
1101
- CONCATENATE: (...s) => {
1102
- const l = s.flatMap(pe), a = V(l);
1103
- a && r(a);
1104
- const o = e.CONCATENATE(...l.map(X));
1105
- return o instanceof Error ? r(o) : o;
1106
- },
1107
- CONCAT: (...s) => {
1108
- const l = s.flatMap(pe), a = V(l);
1109
- a && r(a);
1110
- const o = e.CONCAT(...l.map(X));
1111
- return o instanceof Error ? r(o) : o;
1112
- },
1113
- LEN: f(e.LEN, { toText: !0 }),
1114
- TRIM: f(e.TRIM, { toText: !0 }),
1115
- LOWER: f(e.LOWER, { toText: !0 }),
1116
- LEFT: (s, l) => {
1117
- const a = M(s), o = xe(l), c = V([a]);
1197
+ CONCATENATE: (...i) => {
1198
+ const l = i.flatMap(Ce), c = q(l);
1118
1199
  c && r(c);
1119
- const u = e.LEFT(X(a), o);
1120
- return u instanceof Error ? r(u) : u;
1200
+ const s = e.CONCATENATE(...l.map(ne));
1201
+ return s instanceof Error ? r(s) : s;
1121
1202
  },
1122
- RIGHT: (s, l) => {
1123
- const a = M(s), o = xe(l), c = V([a]);
1203
+ CONCAT: (...i) => {
1204
+ const l = i.flatMap(Ce), c = q(l);
1124
1205
  c && r(c);
1125
- const u = e.RIGHT(X(a), o);
1126
- return u instanceof Error ? r(u) : u;
1206
+ const s = e.CONCAT(...l.map(ne));
1207
+ return s instanceof Error ? r(s) : s;
1208
+ },
1209
+ LEN: u(e.LEN, { toText: !0 }),
1210
+ TRIM: u(e.TRIM, { toText: !0 }),
1211
+ LOWER: u(e.LOWER, { toText: !0 }),
1212
+ LEFT: (i, l) => {
1213
+ const c = V(i), s = Pe(l), d = q([c]);
1214
+ d && r(d);
1215
+ const a = e.LEFT(ne(c), s);
1216
+ return a instanceof Error ? r(a) : a;
1217
+ },
1218
+ RIGHT: (i, l) => {
1219
+ const c = V(i), s = Pe(l), d = q([c]);
1220
+ d && r(d);
1221
+ const a = e.RIGHT(ne(c), s);
1222
+ return a instanceof Error ? r(a) : a;
1127
1223
  },
1128
- MID: (s, l, a) => {
1129
- const o = M(s), c = M(l), u = M(a), y = V([o, c, u]);
1130
- y && r(y);
1131
- const p = e.MID(X(o), c, u);
1132
- return p instanceof Error ? r(p) : p;
1224
+ MID: (i, l, c) => {
1225
+ const s = V(i), d = V(l), a = V(c), g = q([s, d, a]);
1226
+ g && r(g);
1227
+ const f = e.MID(ne(s), d, a);
1228
+ return f instanceof Error ? r(f) : f;
1133
1229
  },
1134
- FIND: (s, l, a) => {
1135
- const o = M(s), c = M(l), u = xe(a), y = V([o, c]);
1136
- y && r(y);
1137
- const p = e.FIND(X(o), X(c), u);
1138
- return p instanceof Error ? r(p) : p;
1230
+ FIND: (i, l, c) => {
1231
+ const s = V(i), d = V(l), a = Pe(c), g = q([s, d]);
1232
+ g && r(g);
1233
+ const f = e.FIND(ne(s), ne(d), a);
1234
+ return f instanceof Error ? r(f) : f;
1139
1235
  },
1140
- SEARCH: (s, l, a) => {
1141
- const o = M(s), c = M(l), u = xe(a), y = V([o, c]);
1142
- y && r(y);
1143
- const p = e.SEARCH(X(o), X(c), u);
1144
- return p instanceof Error ? r(p) : p;
1236
+ SEARCH: (i, l, c) => {
1237
+ const s = V(i), d = V(l), a = Pe(c), g = q([s, d]);
1238
+ g && r(g);
1239
+ const f = e.SEARCH(ne(s), ne(d), a);
1240
+ return f instanceof Error ? r(f) : f;
1145
1241
  }
1146
1242
  };
1147
1243
  }
1148
- const _t = {
1244
+ const Jt = {
1149
1245
  "#REF!": "REF",
1150
1246
  "#VALUE!": "VALUE",
1151
1247
  "#DIV/0!": "DIV0",
@@ -1154,100 +1250,100 @@ const _t = {
1154
1250
  "#NUM!": "NUM",
1155
1251
  "#NULL!": "NULL"
1156
1252
  };
1157
- function Ke(e) {
1158
- return _t[e.error] ?? "ERROR";
1253
+ function ir(e) {
1254
+ return Jt[e.error] ?? "ERROR";
1159
1255
  }
1160
- function Ge(e, t) {
1161
- if (e instanceof j) return e;
1256
+ function lr(e, t) {
1257
+ if (e instanceof oe) return e;
1162
1258
  if (e instanceof t) {
1163
1259
  const r = e.details;
1164
- return r instanceof j ? r : r instanceof t ? new j(Ke(r), r.message) : new j(Ke(e), e.message);
1260
+ return r instanceof oe ? r : r instanceof t ? new oe(ir(r), r.message) : new oe(ir(e), e.message);
1165
1261
  }
1166
- return new j("ERROR", e instanceof Error ? e.message : void 0);
1262
+ return new oe("ERROR", e instanceof Error ? e.message : void 0);
1167
1263
  }
1168
- function Pt(e) {
1264
+ function Zt(e) {
1169
1265
  return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
1170
1266
  }
1171
- function Vt(e) {
1267
+ function qt(e) {
1172
1268
  return (t) => {
1173
1269
  const r = e[t.row - 1];
1174
1270
  if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
1175
- throw new j("REF");
1176
- const i = r[t.col - 1];
1177
- return i == null || i === "" ? null : i;
1271
+ throw new oe("REF");
1272
+ const o = r[t.col - 1];
1273
+ return o == null || o === "" ? null : o;
1178
1274
  };
1179
1275
  }
1180
- function Wt(e) {
1276
+ function Qt(e) {
1181
1277
  return (t) => {
1182
- const r = Math.min(t.from.row, t.to.row), i = Math.min(t.from.col, t.to.col), f = Math.max(t.from.row, t.to.row), s = Math.max(t.from.col, t.to.col), l = Pt(e);
1183
- if (r > e.length || i > l)
1184
- throw new j("REF");
1185
- const a = Math.min(f, e.length), o = [];
1186
- for (let c = r; c <= a; c++) {
1187
- const u = e[c - 1], y = [];
1188
- if (u != null) {
1189
- const p = Math.min(s, u.length);
1190
- for (let m = i; m <= p; m++) {
1191
- const v = u[m - 1];
1192
- y.push(v == null || v === "" ? null : v);
1278
+ const r = Math.min(t.from.row, t.to.row), o = Math.min(t.from.col, t.to.col), u = Math.max(t.from.row, t.to.row), i = Math.max(t.from.col, t.to.col), l = Zt(e);
1279
+ if (r > e.length || o > l)
1280
+ throw new oe("REF");
1281
+ const c = Math.min(u, e.length), s = [];
1282
+ for (let d = r; d <= c; d++) {
1283
+ const a = e[d - 1], g = [];
1284
+ if (a != null) {
1285
+ const f = Math.min(i, a.length);
1286
+ for (let y = o; y <= f; y++) {
1287
+ const w = a[y - 1];
1288
+ g.push(w == null || w === "" ? null : w);
1193
1289
  }
1194
1290
  }
1195
- o.push(y);
1291
+ s.push(g);
1196
1292
  }
1197
- return o;
1293
+ return s;
1198
1294
  };
1199
1295
  }
1200
- function Bt(e) {
1296
+ function en(e) {
1201
1297
  if (e == null || e === "") return null;
1202
1298
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1203
1299
  return e;
1204
- throw new j("VALUE");
1300
+ throw new oe("VALUE");
1205
1301
  }
1206
- async function ar(e, t) {
1207
- if (typeof e != "string") throw new j("ERROR");
1302
+ async function xr(e, t) {
1303
+ if (typeof e != "string") throw new oe("ERROR");
1208
1304
  const r = e.trim();
1209
- if (r === "") throw new j("ERROR");
1210
- const i = r.startsWith("=") ? r.slice(1) : r;
1211
- Ft(i);
1212
- const [f, s] = await Promise.all([
1305
+ if (r === "") throw new oe("ERROR");
1306
+ const o = r.startsWith("=") ? r.slice(1) : r;
1307
+ Xt(o);
1308
+ const [u, i] = await Promise.all([
1213
1309
  import("fast-formula-parser"),
1214
1310
  import("@formulajs/formulajs")
1215
- ]), l = f.default ?? f, a = l.FormulaError, o = new l({
1311
+ ]), l = u.default ?? u, c = l.FormulaError, s = new l({
1216
1312
  ...t,
1217
1313
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- formulajs's own types are all `any`-typed; formulaFunctions.ts narrows the surface it actually calls.
1218
- functions: $t(s, a)
1314
+ functions: Yt(i, c)
1219
1315
  });
1220
- let c;
1316
+ let d;
1221
1317
  try {
1222
- c = o.parse(i, { row: 1, col: 1, sheet: "Sheet1" });
1223
- } catch (u) {
1224
- throw Ge(u, a);
1318
+ d = s.parse(o, { row: 1, col: 1, sheet: "Sheet1" });
1319
+ } catch (a) {
1320
+ throw lr(a, c);
1225
1321
  }
1226
- if (c instanceof a)
1227
- throw Ge(c, a);
1228
- return Bt(c);
1322
+ if (d instanceof c)
1323
+ throw lr(d, c);
1324
+ return en(d);
1229
1325
  }
1230
- async function Kt(e, t) {
1231
- return ar(t, { onCell: Vt(e), onRange: Wt(e) });
1326
+ async function rn(e, t) {
1327
+ return xr(t, { onCell: qt(e), onRange: Qt(e) });
1232
1328
  }
1233
- const Xe = -1;
1234
- async function Gt(e, t) {
1329
+ const sr = -1;
1330
+ async function Nr(e, t) {
1235
1331
  const r = Object.keys(e);
1236
- return ar(t, {
1237
- onVariable: (i) => {
1238
- const f = r.indexOf(i);
1239
- return f === -1 ? null : { row: Xe, col: f + 1 };
1332
+ return xr(t, {
1333
+ onVariable: (o) => {
1334
+ const u = r.indexOf(o);
1335
+ return u === -1 ? null : { row: sr, col: u + 1 };
1240
1336
  },
1241
- onCell: (i) => {
1242
- if (i.row === Xe) return e[r[i.col - 1]] ?? null;
1243
- throw new j("REF");
1337
+ onCell: (o) => {
1338
+ if (o.row === sr) return e[r[o.col - 1]] ?? null;
1339
+ throw new oe("REF");
1244
1340
  },
1245
1341
  onRange: () => {
1246
- throw new j("REF");
1342
+ throw new oe("REF");
1247
1343
  }
1248
1344
  });
1249
1345
  }
1250
- const ur = {
1346
+ const Ir = {
1251
1347
  REF: "#REF!",
1252
1348
  VALUE: "#VALUE!",
1253
1349
  DIV0: "#DIV/0!",
@@ -1257,525 +1353,943 @@ const ur = {
1257
1353
  NUM: "#NUM!",
1258
1354
  NULL: "#NULL!"
1259
1355
  };
1260
- function dr(e) {
1261
- const t = e instanceof j ? e.code : "ERROR";
1262
- return ur[t];
1356
+ function qe(e) {
1357
+ const t = e instanceof oe ? e.code : "ERROR";
1358
+ return Ir[t];
1263
1359
  }
1264
- async function Xt(e, t) {
1360
+ async function tn(e, t) {
1265
1361
  return e.length === 0 ? t.map((r) => ({
1266
1362
  id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1267
1363
  label: (r == null ? void 0 : r.label) ?? "(unknown)",
1268
1364
  value: null,
1269
- error: ur.ERROR
1365
+ error: Ir.ERROR
1270
1366
  })) : Promise.all(
1271
1367
  t.map(async (r) => {
1272
1368
  try {
1273
1369
  if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
1274
- throw new j("ERROR");
1275
- return { id: r.id, label: r.label, value: await Kt(e, r.expression) };
1276
- } catch (i) {
1370
+ throw new oe("ERROR");
1371
+ return { id: r.id, label: r.label, value: await rn(e, r.expression) };
1372
+ } catch (o) {
1277
1373
  return {
1278
1374
  id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1279
1375
  label: (r == null ? void 0 : r.label) ?? "(unknown)",
1280
1376
  value: null,
1281
- error: dr(i)
1377
+ error: qe(o)
1282
1378
  };
1283
1379
  }
1284
1380
  })
1285
1381
  );
1286
1382
  }
1287
- function jt(e, t = {}) {
1288
- if (t.columnHeader && t.rowHeader)
1289
- throw new Error(
1290
- "x-spreadsheet: columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape."
1291
- );
1292
- return t.columnHeader ? Yt(e) : t.rowHeader ? Jt(e) : e;
1383
+ function cr(e) {
1384
+ const t = /* @__PURE__ */ new Set();
1385
+ for (const { id: r } of e) {
1386
+ if (t.has(r)) return r;
1387
+ t.add(r);
1388
+ }
1389
+ return null;
1293
1390
  }
1294
- function fr(e) {
1295
- return e == null || e === "" ? null : e instanceof Date ? e.toISOString() : String(e);
1391
+ function kr(e) {
1392
+ const { columnHeader: t, rowHeader: r, columns: o, rows: u } = e;
1393
+ if (o !== void 0 && !Array.isArray(o))
1394
+ return "columns must be an array of { id, label } objects.";
1395
+ if (u !== void 0 && !Array.isArray(u))
1396
+ return "rows must be an array of { id, label } objects.";
1397
+ if (o !== void 0 && o.length === 0)
1398
+ return "columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1399
+ if (u !== void 0 && u.length === 0)
1400
+ return "rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1401
+ const i = (a) => !!a && typeof a.id == "string" && a.id !== "" && typeof a.label == "string" && a.label !== "", l = o == null ? void 0 : o.findIndex((a) => !i(a));
1402
+ if (l != null && l !== -1)
1403
+ return `columns[${l}] must be a { id, label } object with non-empty string fields.`;
1404
+ const c = u == null ? void 0 : u.findIndex((a) => !i(a));
1405
+ if (c != null && c !== -1)
1406
+ return `rows[${c}] must be a { id, label } object with non-empty string fields.`;
1407
+ const s = !!o && o.length > 0, d = !!u && u.length > 0;
1408
+ if (s) {
1409
+ const a = cr(o);
1410
+ if (a) return `duplicate column id "${a}" — every declared column id must be unique.`;
1411
+ }
1412
+ if (d) {
1413
+ const a = cr(u);
1414
+ if (a) return `duplicate row id "${a}" — every declared row id must be unique.`;
1415
+ }
1416
+ return t && r ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : s && d ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : t && !s ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : r && !d ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1296
1417
  }
1297
- function hr(e, t) {
1298
- const r = /* @__PURE__ */ new Set();
1299
- for (const i of e)
1300
- if (i != null) {
1301
- if (r.has(i))
1302
- throw new Error(
1303
- `x-spreadsheet: duplicate ${t} value "${i}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
1304
- );
1305
- r.add(i);
1306
- }
1418
+ function ar(e, t = {}) {
1419
+ const r = kr(t);
1420
+ if (r) throw new Error(`x-spreadsheet: ${r}`);
1421
+ const { columnHeader: o, rowHeader: u, columns: i, rows: l } = t;
1422
+ return i && i.length > 0 ? nn(e, i, o === !0) : l && l.length > 0 ? on(e, l, u === !0) : e;
1307
1423
  }
1308
- function Yt(e) {
1309
- const [t, ...r] = e;
1310
- if (!t) return [];
1311
- const i = t.map(fr);
1312
- return hr(i, "columnHeader"), r.map((f) => {
1313
- const s = /* @__PURE__ */ Object.create(null);
1314
- return i.forEach((l, a) => {
1315
- l != null && (s[l] = f[a] ?? null);
1316
- }), s;
1424
+ function nn(e, t, r) {
1425
+ return (r ? e.slice(1) : e).map((u) => {
1426
+ const i = /* @__PURE__ */ Object.create(null);
1427
+ return t.forEach((l, c) => {
1428
+ i[l.id] = u[c] ?? null;
1429
+ }), i;
1317
1430
  });
1318
1431
  }
1319
- function Jt(e) {
1320
- const t = e.map((f) => fr(f[0]));
1321
- hr(t, "rowHeader");
1322
- const r = Math.max(0, ...e.map((f) => f.length)), i = Math.max(0, r - 1);
1323
- return Array.from({ length: i }, (f, s) => {
1324
- const l = s + 1, a = /* @__PURE__ */ Object.create(null);
1325
- return t.forEach((o, c) => {
1326
- o != null && (a[o] = e[c][l] ?? null);
1327
- }), a;
1432
+ function on(e, t, r) {
1433
+ const o = r ? 1 : 0, u = Math.max(0, ...e.map((l) => l.length)), i = Math.max(0, u - o);
1434
+ return Array.from({ length: i }, (l, c) => {
1435
+ const s = o + c, d = /* @__PURE__ */ Object.create(null);
1436
+ return t.forEach((a, g) => {
1437
+ var f;
1438
+ d[a.id] = ((f = e[g]) == null ? void 0 : f[s]) ?? null;
1439
+ }), d;
1328
1440
  });
1329
1441
  }
1330
- function je(e) {
1442
+ function ln(e) {
1331
1443
  return !Array.isArray(e[0]);
1332
1444
  }
1333
- async function qt(e, t, r = {}) {
1334
- const i = await Xt(e, t), f = /* @__PURE__ */ Object.create(null);
1335
- for (const { id: s, label: l, value: a, error: o } of i)
1336
- f[s] = o === void 0 ? { label: l, value: a } : { label: l, value: a, error: o };
1337
- return r.persistSheet === !1 ? { derivations: f } : { sheet: jt(e, r), derivations: f };
1445
+ function sn(e) {
1446
+ const t = /* @__PURE__ */ Object.create(null);
1447
+ for (const { id: r, label: o, value: u, error: i } of e)
1448
+ t[r] = i === void 0 ? { label: o, value: u } : { label: o, value: u, error: i };
1449
+ return t;
1338
1450
  }
1339
- const Zt = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Qt = 10 * 1024 * 1024, ve = 200, Ye = 50, en = [];
1340
- function Ce(e) {
1451
+ function Ye(e, t) {
1452
+ const r = (o) => o instanceof Date ? o.toISOString() : o ?? null;
1453
+ return r(e) === r(t);
1454
+ }
1455
+ function cn(e, t) {
1456
+ const r = e ?? {}, o = t ?? {}, u = Object.keys(r);
1457
+ return u.length !== Object.keys(o).length ? !1 : u.every((i) => {
1458
+ if (!Object.prototype.hasOwnProperty.call(o, i)) return !1;
1459
+ const l = r[i], c = o[i];
1460
+ return l.label === c.label && l.error === c.error && Ye(l.value, c.value);
1461
+ });
1462
+ }
1463
+ function an(e, t) {
1464
+ if (e == null || t == null) return e === t;
1465
+ const r = Array.isArray(e);
1466
+ if (r !== Array.isArray(t)) return !1;
1467
+ if (r) {
1468
+ const l = e, c = t;
1469
+ return l.length === c.length && l.every((s, d) => Ye(s, c[d]));
1470
+ }
1471
+ const o = e, u = t, i = Object.keys(o);
1472
+ return i.length !== Object.keys(u).length ? !1 : i.every((l) => Object.prototype.hasOwnProperty.call(u, l) && Ye(o[l], u[l]));
1473
+ }
1474
+ function un(e, t) {
1475
+ if (e === t) return !0;
1476
+ if (e == null || t == null) return !1;
1477
+ const r = e, o = t;
1478
+ return r.length !== o.length ? !1 : r.every((u, i) => an(u, o[i]));
1479
+ }
1480
+ function dn(e) {
1481
+ return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
1482
+ }
1483
+ function fn(e, t) {
1484
+ if (e.length === 0) return [];
1485
+ const r = [], o = /* @__PURE__ */ new Set();
1486
+ for (const i of t ?? [])
1487
+ o.has(i) || (o.add(i), r.push(i));
1488
+ for (const i of e)
1489
+ for (const l of Object.keys(i))
1490
+ o.has(l) || (o.add(l), r.push(l));
1491
+ if (r.length === 0) return [];
1492
+ const u = e.map(
1493
+ (i) => r.map((l) => {
1494
+ if (!Object.prototype.hasOwnProperty.call(i, l)) return null;
1495
+ const c = i[l];
1496
+ return dn(c) ? c : null;
1497
+ })
1498
+ );
1499
+ return [r, ...u];
1500
+ }
1501
+ function hn(e) {
1502
+ const t = Math.max(0, ...e.map((r) => r.length));
1503
+ return Array.from({ length: t }, (r, o) => e.map((u) => u[o] ?? null));
1504
+ }
1505
+ const pn = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", mn = 10 * 1024 * 1024, Be = 200, gn = 50, yn = [];
1506
+ function ur(e) {
1341
1507
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1342
1508
  }
1343
- const rn = ({
1509
+ const vn = ({
1344
1510
  data: e,
1345
1511
  handleChange: t,
1346
1512
  path: r,
1347
- label: i,
1348
- required: f,
1349
- schema: s,
1513
+ label: o,
1514
+ required: u,
1515
+ schema: i,
1350
1516
  enabled: l,
1351
- readonly: a,
1352
- errors: o,
1353
- visible: c = !0
1517
+ readonly: c,
1518
+ errors: s,
1519
+ visible: d = !0
1354
1520
  }) => {
1355
- ce(c, r, t, null);
1356
- const u = !o || o.length === 0, y = St(l, a), p = (s == null ? void 0 : s["x-spreadsheet"]) ?? {}, m = (s == null ? void 0 : s["x-evaluate"]) ?? en, v = p.accept ?? Zt, N = p.maxSize ?? Qt, A = p.persistSheet !== !1, w = p.columnHeader === !0, I = p.rowHeader === !0, L = p.showSheet !== !1, D = p.sheetName, C = e ?? null, [H, W] = U(
1357
- () => C != null && C.sheet || Object.keys((C == null ? void 0 : C.derivations) ?? {}).length > 0 ? "ready" : "empty"
1358
- ), [x, O] = U(null), [F, B] = U(!1), [oe, ee] = U(null), le = de(null), Y = (C == null ? void 0 : C.sheet) ?? null, Z = oe ?? (Y && !je(Y) ? Y : null), re = oe == null && Y && je(Y) ? Y : null, he = (C == null ? void 0 : C.derivations) ?? {}, ne = Z != null || C != null, ue = _e(
1359
- async (d) => {
1360
- if (O(null), d.size > N) {
1361
- O(`File exceeds the ${me(N)} limit.`);
1521
+ ge(d, r, t);
1522
+ const a = !s || s.length === 0, g = Sr(l, c), f = (i == null ? void 0 : i["x-spreadsheet"]) ?? {}, y = (i == null ? void 0 : i["x-evaluate"]) ?? yn, w = f.accept ?? pn, L = f.maxSize ?? mn, O = f.columnHeader === !0, R = f.rowHeader === !0, T = f.columns, S = f.rows, N = Array.isArray(T) && T.length > 0, D = Array.isArray(S) && S.length > 0, $ = kr({ columnHeader: O, rowHeader: R, columns: T, rows: S }), W = f.showSheet !== !1, z = f.sheetName, E = f.persistSheet !== !1, b = e ?? null, [K, G] = H(
1523
+ () => b != null && b.sheet || Object.keys((b == null ? void 0 : b.derivations) ?? {}).length > 0 ? "ready" : "empty"
1524
+ ), [j, Y] = H(null), [C, Z] = H(!1), [J, he] = H(null), [ie, ye] = H(null), h = le(null), x = le(null), B = (b == null ? void 0 : b.sheet) ?? null, M = Ne(
1525
+ (A) => {
1526
+ if (!ln(A)) return A;
1527
+ const v = D ? S : N ? T : void 0, X = fn(
1528
+ A,
1529
+ v == null ? void 0 : v.map((F) => F.id)
1530
+ );
1531
+ return D ? hn(X) : X;
1532
+ },
1533
+ [N, D, T, S]
1534
+ ), P = Xe(() => J ?? (B ? M(B) : null), [J, B, M]), Q = ((ie == null ? void 0 : ie.matrix) === P ? ie.derivations : null) ?? (b == null ? void 0 : b.derivations) ?? {}, ee = P != null || b != null, re = Xe(() => {
1535
+ const A = N ? 1 : 0, v = D ? 1 : 0, X = P ? P.slice(A) : [], F = X.slice(0, Be), U = Math.min(
1536
+ gn,
1537
+ Math.max(0, ...F.map((we) => Math.max(0, we.length - v)))
1538
+ ), se = Array.from({ length: U }, (we, Ae) => Ae + v), Re = "", je = D && !N;
1539
+ return /* @__PURE__ */ n(ae, { children: P && W && /* @__PURE__ */ m(I, { mt: "3", children: [
1540
+ /* @__PURE__ */ n(I, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ m(ve.Root, { variant: "surface", size: "1", children: [
1541
+ !je && /* @__PURE__ */ n(ve.Header, { children: /* @__PURE__ */ m(ve.Row, { children: [
1542
+ /* @__PURE__ */ n(ve.ColumnHeaderCell, { children: Re }),
1543
+ se.map((we) => {
1544
+ var Ae;
1545
+ return (
1546
+ // This row only renders when hasRows isn't the sole
1547
+ // flag set (see suppressColumnHeaderRow) — so reaching
1548
+ // here, either hasColumns is true (declared labels,
1549
+ // looked up positionally — never read from the matrix
1550
+ // cell itself, which only ever holds the id) or both
1551
+ // are false (columnLetter fallback).
1552
+ /* @__PURE__ */ n(ve.ColumnHeaderCell, { children: N ? ((Ae = T == null ? void 0 : T[we]) == null ? void 0 : Ae.label) ?? "" : Pt(we) }, we)
1553
+ );
1554
+ })
1555
+ ] }) }),
1556
+ /* @__PURE__ */ n(ve.Body, { children: F.map((we, Ae) => {
1557
+ var er;
1558
+ const Qe = A + Ae;
1559
+ return /* @__PURE__ */ m(ve.Row, { children: [
1560
+ /* @__PURE__ */ n(
1561
+ ve.RowHeaderCell,
1562
+ {
1563
+ style: D ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1564
+ children: D ? ((er = S == null ? void 0 : S[Qe]) == null ? void 0 : er.label) ?? "" : N ? "" : Qe + 1
1565
+ }
1566
+ ),
1567
+ se.map((rr) => /* @__PURE__ */ n(ve.Cell, { children: ur(we[rr]) }, rr))
1568
+ ] }, Ae);
1569
+ }) })
1570
+ ] }) }),
1571
+ X.length > Be && /* @__PURE__ */ m(p, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1572
+ "Showing first ",
1573
+ Be,
1574
+ " of ",
1575
+ X.length,
1576
+ " rows"
1577
+ ] })
1578
+ ] }) });
1579
+ }, [P, W, N, D, T, S]), _ = Ne(
1580
+ async (A) => {
1581
+ if (Y(null), A.size > L) {
1582
+ Y(`File exceeds the ${pe(L)} limit.`);
1362
1583
  return;
1363
1584
  }
1364
- if (!v.split(",").map((z) => z.trim()).some((z) => z === "*" || z === "*/*" ? !0 : z.endsWith("/*") ? d.type.startsWith(z.slice(0, -1)) : z.startsWith(".") ? d.name.toLowerCase().endsWith(z.toLowerCase()) : d.type === z)) {
1365
- O(`Invalid type. Accepted: ${ge(v)}`);
1585
+ if (!w.split(",").map((U) => U.trim()).some((U) => U === "*" || U === "*/*" ? !0 : U.endsWith("/*") ? A.type.startsWith(U.slice(0, -1)) : U.startsWith(".") ? A.name.toLowerCase().endsWith(U.toLowerCase()) : A.type === U)) {
1586
+ Y(`Invalid type. Accepted: ${me(w)}`);
1366
1587
  return;
1367
1588
  }
1368
- W("parsing");
1369
- let te;
1589
+ G("parsing");
1590
+ let F;
1370
1591
  try {
1371
- const z = await d.arrayBuffer();
1372
- te = Ot(z, D).matrix;
1373
- } catch (z) {
1374
- W("error"), O(
1375
- z instanceof $e ? z.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1592
+ const U = await A.arrayBuffer();
1593
+ F = (await Ut(U, z)).matrix;
1594
+ } catch (U) {
1595
+ G("error"), Y(
1596
+ U instanceof Ge ? U.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1376
1597
  );
1377
1598
  return;
1378
1599
  }
1379
- ee(te);
1380
- let ie;
1381
- try {
1382
- ie = await qt(te, m, { persistSheet: A, columnHeader: w, rowHeader: I });
1383
- } catch (z) {
1384
- W("error"), O(z instanceof Error ? z.message : "Failed to process the uploaded spreadsheet.");
1385
- return;
1386
- }
1387
- t(r, ie), W("ready");
1600
+ if (N || D)
1601
+ try {
1602
+ F = M(ar(F, { columnHeader: O, rowHeader: R, columns: T, rows: S }));
1603
+ } catch (U) {
1604
+ G("error"), Y(U instanceof Error ? U.message : "Failed to process this sheet.");
1605
+ return;
1606
+ }
1607
+ x.current = (e == null ? void 0 : e.sheet) ?? null, he(F), G("ready");
1388
1608
  },
1389
- [v, N, A, w, I, D, m, r, t]
1609
+ [w, L, z, e, O, R, T, S, N, D, M]
1390
1610
  );
1391
- if (c === !1)
1611
+ if (ue(() => {
1612
+ J != null && B != null && B !== x.current && he(null);
1613
+ }, [J, B]), ue(() => {
1614
+ if ($ || y.length === 0 && !E) return;
1615
+ let A = !1;
1616
+ const v = (F) => {
1617
+ g && (cn(b == null ? void 0 : b.derivations, F == null ? void 0 : F.derivations) && un(b == null ? void 0 : b.sheet, F == null ? void 0 : F.sheet) || (x.current = (F == null ? void 0 : F.sheet) ?? null, t(r, F)));
1618
+ }, X = P ?? [];
1619
+ if (X.length === 0) {
1620
+ b != null && v(void 0);
1621
+ return;
1622
+ }
1623
+ return tn(X, y).then((F) => {
1624
+ if (A) return;
1625
+ let U;
1626
+ if (J != null) {
1627
+ if (E)
1628
+ try {
1629
+ U = ar(X, { columnHeader: N, rowHeader: D, columns: T, rows: S });
1630
+ } catch (Re) {
1631
+ Y(Re instanceof Error ? Re.message : "Failed to process this sheet.");
1632
+ return;
1633
+ }
1634
+ } else
1635
+ U = b == null ? void 0 : b.sheet;
1636
+ Y(null);
1637
+ const se = sn(F);
1638
+ ye({ matrix: X, derivations: se }), v(U === void 0 ? { derivations: se } : { sheet: U, derivations: se });
1639
+ }), () => {
1640
+ A = !0;
1641
+ };
1642
+ }, [P, J, y, g, E, N, D, T, S, $]), d === !1)
1392
1643
  return null;
1393
- if (w && I)
1394
- return /* @__PURE__ */ g(R, { mb: "4", children: [
1395
- /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1396
- /* @__PURE__ */ n(h, { size: "2", color: "red", style: { display: "block" }, children: "Invalid x-spreadsheet config: columnHeader and rowHeader cannot both be true — pick one orientation." })
1644
+ if ($)
1645
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1646
+ /* @__PURE__ */ n(p, { as: "label", size: "2", weight: "bold", children: o }),
1647
+ /* @__PURE__ */ m(p, { size: "2", color: "red", style: { display: "block" }, children: [
1648
+ "Invalid x-spreadsheet config: ",
1649
+ $
1650
+ ] })
1397
1651
  ] });
1398
- if (!y && !ne) return null;
1399
- const b = (d) => {
1400
- d.preventDefault(), d.stopPropagation(), y && B(d.type === "dragenter" || d.type === "dragover");
1401
- }, k = (d) => {
1402
- var E;
1403
- d.preventDefault(), d.stopPropagation(), B(!1), y && (E = d.dataTransfer.files) != null && E[0] && ue(d.dataTransfer.files[0]);
1404
- }, $ = (d) => {
1405
- var E;
1406
- (E = d.target.files) != null && E[0] && (ue(d.target.files[0]), d.target.value = "");
1407
- }, T = () => {
1408
- y && (ee(null), O(null), W("empty"), t(r, null));
1409
- }, _ = w ? 1 : 0, J = I ? 1 : 0, Q = Z ? Z.slice(_) : [], G = Q.slice(0, ve), we = Math.min(
1410
- Ye,
1411
- Math.max(0, ...G.map((d) => Math.max(0, d.length - J)))
1412
- ), Ee = Array.from({ length: we }, (d, E) => E + J), De = L && Z == null && re == null && C != null, Se = "", Fe = I && !w, Oe = re ? re.slice(0, ve) : [], Re = Array.from(new Set(Oe.flatMap((d) => Object.keys(d)))).slice(0, Ye);
1413
- return /* @__PURE__ */ g(R, { mb: "4", children: [
1414
- /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
1415
- /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
1416
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1417
- i,
1418
- f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1652
+ if (!g && !ee) return null;
1653
+ const Se = (A) => {
1654
+ A.preventDefault(), A.stopPropagation(), g && Z(A.type === "dragenter" || A.type === "dragover");
1655
+ }, Ve = (A) => {
1656
+ var v;
1657
+ A.preventDefault(), A.stopPropagation(), Z(!1), g && (v = A.dataTransfer.files) != null && v[0] && _(A.dataTransfer.files[0]);
1658
+ }, Le = (A) => {
1659
+ var v;
1660
+ (v = A.target.files) != null && v[0] && (_(A.target.files[0]), A.target.value = "");
1661
+ }, He = () => {
1662
+ g && (he(null), ye(null), x.current = null, Y(null), G("empty"), t(r, void 0));
1663
+ }, We = W && P == null && b != null;
1664
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1665
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
1666
+ /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
1667
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
1668
+ o,
1669
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
1419
1670
  ] }),
1420
- ne && y && /* @__PURE__ */ g(be, { children: [
1421
- /* @__PURE__ */ n(We, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1422
- Ue,
1671
+ ee && g && /* @__PURE__ */ m(ae, { children: [
1672
+ /* @__PURE__ */ n($e, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1673
+ ke,
1423
1674
  {
1424
1675
  variant: "ghost",
1425
1676
  size: "1",
1426
1677
  onClick: () => {
1427
- var d;
1428
- return (d = le.current) == null ? void 0 : d.click();
1678
+ var A;
1679
+ return (A = h.current) == null ? void 0 : A.click();
1429
1680
  },
1430
1681
  "aria-label": "Replace spreadsheet",
1431
- children: /* @__PURE__ */ n(He, {})
1682
+ children: /* @__PURE__ */ n(Oe, {})
1432
1683
  }
1433
1684
  ) }),
1434
- /* @__PURE__ */ n(We, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1435
- Ue,
1685
+ /* @__PURE__ */ n($e, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1686
+ ke,
1436
1687
  {
1437
1688
  variant: "ghost",
1438
1689
  size: "1",
1439
1690
  color: "gray",
1440
- onClick: T,
1691
+ onClick: He,
1441
1692
  "aria-label": "Remove spreadsheet",
1442
- children: /* @__PURE__ */ n(or, {})
1693
+ children: /* @__PURE__ */ n(Je, {})
1443
1694
  }
1444
1695
  ) })
1445
1696
  ] })
1446
1697
  ] }),
1447
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1448
- me(N),
1698
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
1699
+ pe(L),
1449
1700
  " max · ",
1450
- ge(v)
1701
+ me(w)
1451
1702
  ] })
1452
1703
  ] }),
1453
- ne && x && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: x }),
1454
- /* @__PURE__ */ n("input", { ref: le, type: "file", style: { display: "none" }, accept: v, onChange: $ }),
1455
- y && !ne && /* @__PURE__ */ n(
1704
+ ee && j && /* @__PURE__ */ n(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: j }),
1705
+ /* @__PURE__ */ n("input", { ref: h, type: "file", style: { display: "none" }, accept: w, onChange: Le }),
1706
+ g && !ee && /* @__PURE__ */ n(
1456
1707
  "div",
1457
1708
  {
1458
1709
  role: "button",
1459
1710
  tabIndex: 0,
1460
1711
  onClick: () => {
1461
- var d;
1462
- return (d = le.current) == null ? void 0 : d.click();
1712
+ var A;
1713
+ return (A = h.current) == null ? void 0 : A.click();
1463
1714
  },
1464
- onKeyDown: (d) => {
1465
- var E;
1466
- (d.key === "Enter" || d.key === " ") && (d.preventDefault(), (E = le.current) == null || E.click());
1715
+ onKeyDown: (A) => {
1716
+ var v;
1717
+ (A.key === "Enter" || A.key === " ") && (A.preventDefault(), (v = h.current) == null || v.click());
1467
1718
  },
1468
- onDragEnter: b,
1469
- onDragLeave: b,
1470
- onDragOver: b,
1471
- onDrop: k,
1719
+ onDragEnter: Se,
1720
+ onDragLeave: Se,
1721
+ onDragOver: Se,
1722
+ onDrop: Ve,
1472
1723
  style: { cursor: "pointer" },
1473
1724
  className: [
1474
1725
  "border-2 border-dashed rounded-lg p-6 text-center",
1475
1726
  "transition-all duration-200 ease-in-out",
1476
- F ? "border-blue-500 bg-blue-50" : x ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1727
+ C ? "border-blue-500 bg-blue-50" : j ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1477
1728
  ].join(" "),
1478
- children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: H === "parsing" ? /* @__PURE__ */ g(be, { children: [
1479
- /* @__PURE__ */ n(Me, { size: "3" }),
1480
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1481
- ] }) : x ? /* @__PURE__ */ g(be, { children: [
1482
- /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1483
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: x }),
1484
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1485
- ] }) : /* @__PURE__ */ g(be, { children: [
1486
- /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1487
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1488
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1489
- me(N),
1729
+ children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: K === "parsing" ? /* @__PURE__ */ m(ae, { children: [
1730
+ /* @__PURE__ */ n(xe, { size: "3" }),
1731
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1732
+ ] }) : j ? /* @__PURE__ */ m(ae, { children: [
1733
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1734
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: j }),
1735
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
1736
+ ] }) : /* @__PURE__ */ m(ae, { children: [
1737
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1738
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1739
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
1740
+ pe(L),
1490
1741
  " max · ",
1491
- ge(v)
1742
+ me(w)
1492
1743
  ] })
1493
1744
  ] }) })
1494
1745
  }
1495
1746
  ),
1496
- Z && L && /* @__PURE__ */ g(R, { mt: "3", children: [
1497
- /* @__PURE__ */ n(R, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(P.Root, { variant: "surface", size: "1", children: [
1498
- !Fe && /* @__PURE__ */ n(P.Header, { children: /* @__PURE__ */ g(P.Row, { children: [
1499
- /* @__PURE__ */ n(P.ColumnHeaderCell, { children: Se }),
1500
- Ee.map((d) => {
1501
- var E;
1502
- return (
1503
- // This row only renders when rowHeader isn't the sole
1504
- // flag set (see suppressColumnHeaderRow) — so reaching
1505
- // here, either columnHeader is true (real labels) or
1506
- // both are false (columnLetter fallback).
1507
- /* @__PURE__ */ n(P.ColumnHeaderCell, { children: w ? Ce((E = Z[0]) == null ? void 0 : E[d]) : Nt(d) }, d)
1508
- );
1509
- })
1510
- ] }) }),
1511
- /* @__PURE__ */ n(P.Body, { children: G.map((d, E) => {
1512
- var te;
1513
- const q = _ + E;
1514
- return /* @__PURE__ */ g(P.Row, { children: [
1515
- /* @__PURE__ */ n(
1516
- P.RowHeaderCell,
1517
- {
1518
- style: I ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1519
- children: I ? Ce((te = Z[q]) == null ? void 0 : te[0]) : w ? "" : q + 1
1520
- }
1521
- ),
1522
- Ee.map((ie) => /* @__PURE__ */ n(P.Cell, { children: Ce(d[ie]) }, ie))
1523
- ] }, E);
1524
- }) })
1525
- ] }) }),
1526
- Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1527
- "Showing first ",
1528
- ve,
1529
- " of ",
1530
- Q.length,
1531
- " rows"
1532
- ] })
1533
- ] }),
1534
- re && L && /* @__PURE__ */ g(R, { mt: "3", children: [
1535
- /* @__PURE__ */ n(R, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(P.Root, { variant: "surface", size: "1", children: [
1536
- /* @__PURE__ */ n(P.Header, { children: /* @__PURE__ */ g(P.Row, { children: [
1537
- /* @__PURE__ */ n(P.ColumnHeaderCell, {}),
1538
- Re.map((d) => /* @__PURE__ */ n(P.ColumnHeaderCell, { children: d }, d))
1539
- ] }) }),
1540
- /* @__PURE__ */ n(P.Body, { children: Oe.map((d, E) => /* @__PURE__ */ g(P.Row, { children: [
1541
- /* @__PURE__ */ n(P.RowHeaderCell, { children: E + 1 }),
1542
- Re.map((q) => /* @__PURE__ */ n(P.Cell, { children: Ce(d[q]) }, q))
1543
- ] }, E)) })
1544
- ] }) }),
1545
- re.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1546
- "Showing first ",
1547
- ve,
1548
- " of ",
1549
- re.length,
1550
- " rows"
1551
- ] })
1552
- ] }),
1553
- De && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1554
- Object.keys(he).length > 0 && /* @__PURE__ */ g(R, { mt: "3", children: [
1555
- /* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1556
- /* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(he).map(([d, E]) => /* @__PURE__ */ g(S, { justify: "between", children: [
1557
- /* @__PURE__ */ n(h, { size: "2", children: E.label }),
1558
- E.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: E.error }) : (
1747
+ re,
1748
+ We && /* @__PURE__ */ n(p, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1749
+ Object.keys(Q).length > 0 && /* @__PURE__ */ m(I, { mt: "3", children: [
1750
+ /* @__PURE__ */ n(p, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1751
+ /* @__PURE__ */ n(k, { direction: "column", gap: "1", children: Object.entries(Q).map(([A, v]) => /* @__PURE__ */ m(k, { justify: "between", children: [
1752
+ /* @__PURE__ */ n(p, { size: "2", children: v.label }),
1753
+ v.error ? /* @__PURE__ */ n(p, { size: "2", color: "red", children: v.error }) : (
1559
1754
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1560
1755
  // possible results anymore — INDEX/CONCATENATE can return a
1561
1756
  // string, a bare comparison can return a boolean, etc.), so
1562
1757
  // `.toLocaleString()` would throw for e.g. a boolean result.
1563
1758
  // Reuse the same formatCell used for the sheet-preview grid.
1564
- /* @__PURE__ */ n(h, { size: "2", children: Ce(E.value) })
1759
+ /* @__PURE__ */ n(p, { size: "2", children: ur(v.value) })
1565
1760
  )
1566
- ] }, d)) })
1761
+ ] }, A)) })
1567
1762
  ] }),
1568
- !u && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
1763
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
1569
1764
  ] });
1570
- }, tn = se(rn), nn = K(
1765
+ }, bn = fe(vn), wn = te(
1571
1766
  10,
1572
1767
  // matches FileControlTester's rank — beats the default object/Group renderer
1573
- ze(
1768
+ De(
1574
1769
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1575
1770
  )
1576
1771
  );
1577
- function on(e, t, r) {
1578
- const i = {};
1579
- for (const [f, s] of Object.entries(r)) {
1580
- const { path: l, default: a } = typeof s == "string" ? { path: s, default: void 0 } : s, o = t ? `${t}.${l}` : l, c = Sr.data(e, o);
1581
- if (c == null) {
1582
- if (a === void 0) return;
1583
- i[f] = a;
1772
+ class Ee extends Error {
1773
+ }
1774
+ const dr = 5e6, En = 1024, Rn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, An = {
1775
+ // Default is true, which would silently drop what in many formats is most of
1776
+ // the payload.
1777
+ ignoreAttributes: !1,
1778
+ // Non-empty, so `@_id` and a sibling <id> element can coexist on one node.
1779
+ attributeNamePrefix: "@_",
1780
+ textNodeName: "#text",
1781
+ parseTagValue: !0,
1782
+ // Default is false, which would make <line qty="10"/> a string while
1783
+ // <line><qty>10</qty></line> is a number.
1784
+ parseAttributeValue: !0,
1785
+ // Defaults are hex: true, leadingZeros: true, which turn "00742" into 742 and
1786
+ // "0x1A" into 26 — silent, irreversible corruption of the zero-padded SKUs,
1787
+ // postcodes and invoice refs that fill real XML.
1788
+ numberParseOptions: { hex: !1, leadingZeros: !1, eNotation: !0 },
1789
+ trimValues: !0,
1790
+ // CDATA merges into the node's ordinary text value: whether an author wrapped
1791
+ // a value in CDATA is an encoding detail, not content.
1792
+ cdataPropName: !1,
1793
+ commentPropName: !1,
1794
+ // Enabled so `&amp;` and DOCTYPE-declared entities resolve. Verified against
1795
+ // 5.11.1 and pinned in parse.test.ts: the library refuses external and
1796
+ // parameter entities, caps declarations, and leaves a nested entity reference
1797
+ // literal rather than expanding it — so no XXE or amplification guard of our
1798
+ // own is needed.
1799
+ processEntities: !0,
1800
+ // Default is false. Despite the name, this is what decodes NUMERIC character
1801
+ // references (`&#233;`), which are core XML — left off they persist as
1802
+ // literal text. The HTML named set comes along as a harmless superset.
1803
+ htmlEntities: !0,
1804
+ // Defaults are both false, which injects a `?xml` key of transport metadata
1805
+ // into the document root.
1806
+ ignoreDeclaration: !0,
1807
+ ignorePiTags: !0,
1808
+ // A leaf with no attributes collapses to its bare value, so <qty>10</qty> is
1809
+ // `10`. Only genuinely mixed nodes get a '#text' key.
1810
+ alwaysCreateTextNode: !1,
1811
+ preserveOrder: !1,
1812
+ // Prefixes are kept so <a:Name> and <b:Name> stay distinguishable;
1813
+ // x-xml.removeNamespaces opts out per field, lossily — see docs.
1814
+ removeNSPrefix: !1,
1815
+ // Library defaults, restated because they are load-bearing: the depth bound
1816
+ // is what stops a deeply-nested document overflowing the stack here and in
1817
+ // every recursive consumer downstream.
1818
+ maxNestedTags: 100,
1819
+ strictReservedNames: !0
1820
+ };
1821
+ function Cn(e) {
1822
+ const t = new Set(e);
1823
+ return t.size === 0 ? () => !1 : (r, o) => (
1824
+ // A string while the library's own `jPath` option is true (the default) and
1825
+ // a matcher object otherwise; both stringify to the same dotted path.
1826
+ t.has(typeof o == "string" ? o : o.toString()) || t.has(r)
1827
+ );
1828
+ }
1829
+ function Tn(e) {
1830
+ const t = e instanceof Error ? e.message : "";
1831
+ return t.startsWith("[SECURITY] Invalid name:") ? "This document uses a reserved JavaScript name (__proto__, constructor or prototype) as an element or attribute name, which cannot be represented safely." : t === "External entities are not supported" || t === "Parameter entities are not supported" ? `${t}. Please remove the DOCTYPE entity declarations and try again.` : t.startsWith("Maximum nested tags exceeded") ? "This document is nested too deeply to parse." : t.startsWith("Entity count") || t.includes("exceeds maximum allowed") ? "This document declares too many or too large entity definitions to expand safely." : "This doesn't look like a valid XML document. Please check the file and try again.";
1832
+ }
1833
+ async function Sn(e, t = {}) {
1834
+ var d;
1835
+ if (typeof e != "string") throw new Ee("This file could not be read as text.");
1836
+ const r = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
1837
+ if (r.trim() === "") throw new Ee("This file is empty.");
1838
+ if (r.length > dr)
1839
+ throw new Ee(
1840
+ `This document is too large to parse (over ${dr / 1e6} million characters).`
1841
+ );
1842
+ const o = (d = Rn.exec(r.slice(0, En))) == null ? void 0 : d[1];
1843
+ if (o && !/^utf-?8$/i.test(o))
1844
+ throw new Ee(
1845
+ `This document declares the unsupported encoding "${o}". Only UTF-8 is supported.`
1846
+ );
1847
+ const { XMLParser: u, XMLValidator: i } = await import("fast-xml-parser"), l = i.validate(r, { allowBooleanAttributes: !1 });
1848
+ if (l !== !0) {
1849
+ const { msg: a, line: g, col: f } = l.err;
1850
+ throw new Ee(`Invalid XML at line ${g}, column ${f}: ${a}`);
1851
+ }
1852
+ const c = new u({
1853
+ ...An,
1854
+ removeNSPrefix: t.removeNamespaces === !0,
1855
+ isArray: Cn(t.arrayPaths ?? [])
1856
+ });
1857
+ let s;
1858
+ try {
1859
+ s = c.parse(r);
1860
+ } catch (a) {
1861
+ throw new Ee(Tn(a));
1862
+ }
1863
+ if (s == null || typeof s != "object" || Array.isArray(s))
1864
+ throw new Ee("This document has no root element.");
1865
+ return s;
1866
+ }
1867
+ const Te = { found: !1 }, ce = (e) => ({ found: !0, value: e });
1868
+ function fr(e) {
1869
+ return e == null || e === "" ? Te : Array.isArray(e) || e instanceof Date ? ce(e) : typeof e == "object" ? Te : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? ce(e) : Te;
1870
+ }
1871
+ const On = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), xn = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
1872
+ async function Nn(e, t) {
1873
+ switch (t.as) {
1874
+ case void 0:
1875
+ return ce(e);
1876
+ case "string":
1877
+ return ce(e instanceof Date ? e.toISOString() : String(e));
1878
+ case "number": {
1879
+ const r = e instanceof Date ? e.getTime() : Number(e);
1880
+ return Number.isFinite(r) ? ce(r) : Te;
1881
+ }
1882
+ case "boolean": {
1883
+ const r = String(e).trim().toLowerCase();
1884
+ return On.has(r) ? ce(!0) : xn.has(r) ? ce(!1) : Te;
1885
+ }
1886
+ case "date": {
1887
+ const { default: r } = await import("dayjs"), { default: o } = await import("./customParseFormat-D14EWdSX.js").then((l) => l.c);
1888
+ r.extend(o);
1889
+ const u = e instanceof Date ? e.toISOString() : String(e), i = t.format ? r(u, t.format, !0) : r(u);
1890
+ return i.isValid() ? ce(i.format("YYYY-MM-DD")) : Te;
1891
+ }
1892
+ }
1893
+ }
1894
+ async function In(e, t) {
1895
+ if (t.formula !== void 0) {
1896
+ const r = {};
1897
+ for (const [o, u] of Object.entries(t.inputs ?? {})) {
1898
+ const i = fr(Ke.data(e, u));
1899
+ if (!i.found || Array.isArray(i.value)) return Te;
1900
+ r[o] = i.value;
1901
+ }
1902
+ try {
1903
+ return ce(await Nr(r, t.formula));
1904
+ } catch (o) {
1905
+ throw new Error(`x-xml.writeTo "${t.to}": ${qe(o)}`);
1906
+ }
1907
+ }
1908
+ if (t.from === void 0) throw new Error(`x-xml.writeTo "${t.to}" needs either "from" or "formula".`);
1909
+ return fr(Ke.data(e, t.from));
1910
+ }
1911
+ async function kn(e, t) {
1912
+ const r = [];
1913
+ for (const o of t) {
1914
+ let u = await In(e, o);
1915
+ const i = u.found && Array.isArray(u.value);
1916
+ if (u.found && !i && o.map) {
1917
+ const l = u.value instanceof Date ? u.value.toISOString() : String(u.value);
1918
+ Object.prototype.hasOwnProperty.call(o.map, l) && (u = ce(o.map[l]));
1919
+ }
1920
+ if (u.found && !i && (u = await Nn(u.value, o)), !u.found) {
1921
+ if (o.default === void 0) continue;
1922
+ r.push({ to: o.to, value: o.default });
1923
+ continue;
1924
+ }
1925
+ r.push({ to: o.to, value: u.value });
1926
+ }
1927
+ return r;
1928
+ }
1929
+ const Dn = ".xml,text/xml,application/xml", Mn = 5 * 1024 * 1024, zn = ({
1930
+ data: e,
1931
+ handleChange: t,
1932
+ path: r,
1933
+ label: o,
1934
+ required: u,
1935
+ schema: i,
1936
+ enabled: l,
1937
+ readonly: c,
1938
+ errors: s,
1939
+ visible: d = !0
1940
+ }) => {
1941
+ ge(d, r, t);
1942
+ const a = !s || s.length === 0, g = Sr(l, c), f = (i == null ? void 0 : i["x-xml"]) ?? {}, y = f.accept ?? Dn, w = f.maxSize ?? Mn, L = f.arrayPaths, O = f.removeNamespaces === !0, R = f.writeTo, T = f.writeBase ?? "root", S = f.persistDocument !== !1, N = br(), D = e ?? null, [$, W] = H(() => D ? "ready" : "empty"), [z, E] = H(null), [b, K] = H(!1), G = le(null), j = le(0), Y = D != null, C = R !== void 0 && R.length > 0, Z = Ne(
1943
+ async (h) => {
1944
+ var re;
1945
+ const x = ++j.current;
1946
+ if (E(null), h.size > w) {
1947
+ E(`File exceeds the ${pe(w)} limit.`);
1948
+ return;
1949
+ }
1950
+ if (!y.split(",").map((_) => _.trim()).some((_) => _ === "*" || _ === "*/*" ? !0 : _.endsWith("/*") ? h.type.startsWith(_.slice(0, -1)) : _.startsWith(".") ? h.name.toLowerCase().endsWith(_.toLowerCase()) : h.type === _)) {
1951
+ E(`Invalid type. Accepted: ${me(y)}`);
1952
+ return;
1953
+ }
1954
+ W("parsing");
1955
+ let P;
1956
+ try {
1957
+ const _ = await h.text();
1958
+ P = await Sn(_, { arrayPaths: L, removeNamespaces: O });
1959
+ } catch (_) {
1960
+ if (x !== j.current) return;
1961
+ W("error"), E(
1962
+ _ instanceof Ee ? _.message : "This doesn't look like a valid XML document. Please check the file and try again."
1963
+ );
1964
+ return;
1965
+ }
1966
+ let Q = [];
1967
+ if (R && R.length > 0)
1968
+ try {
1969
+ Q = await kn(P, R);
1970
+ } catch (_) {
1971
+ if (x !== j.current) return;
1972
+ W("error"), E(_ instanceof Error ? _.message : "This document could not be mapped onto the form.");
1973
+ return;
1974
+ }
1975
+ if (x !== j.current) return;
1976
+ S && t(r, P);
1977
+ const ee = T === "parent" ? r.split(".").slice(0, -1).join(".") : "";
1978
+ for (const _ of Q) (re = N.dispatch) == null || re.call(N, Hr(ee ? `${ee}.${_.to}` : _.to, () => _.value));
1979
+ W("ready");
1980
+ },
1981
+ [y, w, L, O, R, T, S, r, t, N]
1982
+ );
1983
+ if (d === !1 || !g && !Y) return null;
1984
+ const J = (h) => {
1985
+ h.preventDefault(), h.stopPropagation(), g && K(h.type === "dragenter" || h.type === "dragover");
1986
+ }, he = (h) => {
1987
+ var x;
1988
+ h.preventDefault(), h.stopPropagation(), K(!1), g && (x = h.dataTransfer.files) != null && x[0] && Z(h.dataTransfer.files[0]);
1989
+ }, ie = (h) => {
1990
+ var x;
1991
+ (x = h.target.files) != null && x[0] && (Z(h.target.files[0]), h.target.value = "");
1992
+ };
1993
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1994
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
1995
+ /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
1996
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
1997
+ o,
1998
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
1999
+ ] }),
2000
+ !C && Y && g && /* @__PURE__ */ m(ae, { children: [
2001
+ /* @__PURE__ */ n($e, { content: "Replace document", children: /* @__PURE__ */ n(
2002
+ ke,
2003
+ {
2004
+ variant: "ghost",
2005
+ size: "1",
2006
+ onClick: () => {
2007
+ var h;
2008
+ return (h = G.current) == null ? void 0 : h.click();
2009
+ },
2010
+ "aria-label": "Replace document",
2011
+ children: /* @__PURE__ */ n(Oe, {})
2012
+ }
2013
+ ) }),
2014
+ /* @__PURE__ */ n($e, { content: "Remove document", children: /* @__PURE__ */ n(ke, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2015
+ g && (++j.current, E(null), W("empty"), t(r, void 0));
2016
+ }, "aria-label": "Remove document", children: /* @__PURE__ */ n(Je, {}) }) })
2017
+ ] })
2018
+ ] }),
2019
+ /* @__PURE__ */ m(k, { align: "center", gap: "2", children: [
2020
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
2021
+ pe(w),
2022
+ " max · ",
2023
+ me(y)
2024
+ ] }),
2025
+ C && g && /* @__PURE__ */ m(Ie, { size: "1", variant: "soft", onClick: () => {
2026
+ var h;
2027
+ return (h = G.current) == null ? void 0 : h.click();
2028
+ }, disabled: $ === "parsing", children: [
2029
+ $ === "parsing" ? /* @__PURE__ */ n(xe, { size: "1" }) : /* @__PURE__ */ n(Oe, {}),
2030
+ "Upload"
2031
+ ] })
2032
+ ] })
2033
+ ] }),
2034
+ (C || Y) && z && /* @__PURE__ */ n(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: z }),
2035
+ /* @__PURE__ */ n("input", { ref: G, type: "file", style: { display: "none" }, accept: y, onChange: ie }),
2036
+ !C && g && !Y && /* @__PURE__ */ n(
2037
+ "div",
2038
+ {
2039
+ role: "button",
2040
+ tabIndex: 0,
2041
+ onClick: () => {
2042
+ var h;
2043
+ return (h = G.current) == null ? void 0 : h.click();
2044
+ },
2045
+ onKeyDown: (h) => {
2046
+ var x;
2047
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = G.current) == null || x.click());
2048
+ },
2049
+ onDragEnter: J,
2050
+ onDragLeave: J,
2051
+ onDragOver: J,
2052
+ onDrop: he,
2053
+ style: { cursor: "pointer" },
2054
+ className: [
2055
+ "border-2 border-dashed rounded-lg p-6 text-center",
2056
+ "transition-all duration-200 ease-in-out",
2057
+ b ? "border-blue-500 bg-blue-50" : z ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2058
+ ].join(" "),
2059
+ children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: $ === "parsing" ? /* @__PURE__ */ m(ae, { children: [
2060
+ /* @__PURE__ */ n(xe, { size: "3" }),
2061
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Parsing document…" })
2062
+ ] }) : z ? /* @__PURE__ */ m(ae, { children: [
2063
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2064
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: z }),
2065
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
2066
+ ] }) : /* @__PURE__ */ m(ae, { children: [
2067
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2068
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2069
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
2070
+ pe(w),
2071
+ " max · ",
2072
+ me(y)
2073
+ ] })
2074
+ ] }) })
2075
+ }
2076
+ ),
2077
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
2078
+ ] });
2079
+ }, Ln = fe(zn), Fn = te(
2080
+ 10,
2081
+ De((e) => {
2082
+ const t = e["x-xml"];
2083
+ return e.type === "object" && typeof t == "object" && t !== null;
2084
+ })
2085
+ );
2086
+ function Un(e, t, r) {
2087
+ const o = {};
2088
+ for (const [u, i] of Object.entries(r)) {
2089
+ const { path: l, default: c } = typeof i == "string" ? { path: i, default: void 0 } : i, s = t ? `${t}.${l}` : l, d = Ke.data(e, s);
2090
+ if (d == null) {
2091
+ if (c === void 0) return;
2092
+ o[u] = c;
1584
2093
  } else
1585
- i[f] = c;
2094
+ o[u] = d;
1586
2095
  }
1587
- return i;
2096
+ return o;
1588
2097
  }
1589
- async function ln(e, t) {
2098
+ async function Pn(e, t) {
1590
2099
  try {
1591
- return { status: "ok", value: await Gt(e, t) };
2100
+ return { status: "ok", value: await Nr(e, t) };
1592
2101
  } catch (r) {
1593
- return { status: "error", error: dr(r) };
2102
+ return { status: "error", error: qe(r) };
1594
2103
  }
1595
2104
  }
1596
- function sn(e, t) {
1597
- return e == null ? "" : typeof e == "number" ? e.toFixed(cn(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2105
+ function $n(e, t) {
2106
+ return e == null ? "" : typeof e == "number" ? e.toFixed(_n(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
1598
2107
  }
1599
- function cn(e) {
2108
+ function _n(e) {
1600
2109
  return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
1601
2110
  }
1602
- const Je = "{value}", an = 2, un = {}, dn = ({ data: e, handleChange: t, path: r, label: i, schema: f, visible: s = !0 }) => {
1603
- var H;
1604
- ce(s, r, t, null);
1605
- const l = f == null ? void 0 : f["x-computed"], a = (l == null ? void 0 : l.inputs) ?? un, o = (l == null ? void 0 : l.formula) ?? "", c = (l == null ? void 0 : l.format) ?? Je, u = (l == null ? void 0 : l.decimals) ?? an, y = xr(), p = r.split(".").slice(0, -1).join("."), m = on((H = y.core) == null ? void 0 : H.data, p, a), v = m ? JSON.stringify(m) : null, N = y.readonly === !0, [A, w] = U(() => typeof e == "number" ? "ok" : "unavailable"), [I, L] = U(() => typeof e == "number" ? e : null), [D, C] = U(null);
1606
- return fe(() => {
1607
- if (!s) return;
2111
+ const hr = "{value}", Vn = 2, Hn = {}, Wn = ({ data: e, handleChange: t, path: r, label: o, schema: u, visible: i = !0 }) => {
2112
+ var $;
2113
+ ge(i, r, t);
2114
+ const l = u == null ? void 0 : u["x-computed"], c = (l == null ? void 0 : l.inputs) ?? Hn, s = (l == null ? void 0 : l.formula) ?? "", d = (l == null ? void 0 : l.format) ?? hr, a = (l == null ? void 0 : l.decimals) ?? Vn, g = br(), f = r.split(".").slice(0, -1).join("."), y = Un(($ = g.core) == null ? void 0 : $.data, f, c), w = y ? JSON.stringify(y) : null, L = g.readonly === !0, [O, R] = H(() => typeof e == "number" ? "ok" : "unavailable"), [T, S] = H(() => typeof e == "number" ? e : null), [N, D] = H(null);
2115
+ return ue(() => {
2116
+ if (!i) return;
1608
2117
  let W = !1;
1609
- const x = (O) => {
1610
- N || O !== (e ?? null) && t(r, O);
2118
+ const z = (E) => {
2119
+ L || E !== e && t(r, E);
1611
2120
  };
1612
- if (m === void 0) {
1613
- w("unavailable"), C(null), L(null), x(null);
2121
+ if (y === void 0) {
2122
+ R("unavailable"), D(null), S(null), z(void 0);
1614
2123
  return;
1615
2124
  }
1616
- return w((O) => O === "ok" ? O : "loading"), ln(m, o).then((O) => {
2125
+ return R((E) => E === "ok" ? E : "loading"), Pn(y, s).then((E) => {
1617
2126
  if (W) return;
1618
- const F = O.status === "ok" && typeof O.value == "number" && Number.isFinite(O.value) ? O.value : null;
1619
- if (F === null) {
1620
- w("error"), C(
1621
- O.status === "error" ? O.error ?? "Unable to compute value." : "Computed value must be a number."
1622
- ), L(null), x(null);
2127
+ const b = E.status === "ok" && typeof E.value == "number" && Number.isFinite(E.value) ? E.value : null;
2128
+ if (b === null) {
2129
+ R("error"), D(
2130
+ E.status === "error" ? E.error ?? "Unable to compute value." : "Computed value must be a number."
2131
+ ), S(null), z(void 0);
1623
2132
  return;
1624
2133
  }
1625
- w("ok"), C(null), L(F), x(F);
2134
+ R("ok"), D(null), S(b), z(b);
1626
2135
  }), () => {
1627
2136
  W = !0;
1628
2137
  };
1629
- }, [v, o, s, N]), s === !1 ? null : /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
1630
- /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1631
- A === "unavailable" ? /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Not yet available." }) : A === "loading" ? /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
1632
- /* @__PURE__ */ n(Me, { size: "1" }),
1633
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Computing…" })
1634
- ] }) : A === "error" ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: D }) : /* @__PURE__ */ n(h, { size: "2", children: c.split(Je).join(sn(I, u)) }),
1635
- f.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f.description })
2138
+ }, [w, s, i, L]), i === !1 ? null : /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
2139
+ /* @__PURE__ */ n(p, { as: "label", size: "2", weight: "bold", children: o }),
2140
+ O === "unavailable" ? /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Not yet available." }) : O === "loading" ? /* @__PURE__ */ m(k, { align: "center", gap: "2", children: [
2141
+ /* @__PURE__ */ n(xe, { size: "1" }),
2142
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Computing…" })
2143
+ ] }) : O === "error" ? /* @__PURE__ */ n(p, { size: "2", color: "red", children: N }) : /* @__PURE__ */ n(p, { size: "2", children: d.split(hr).join($n(T, a)) }),
2144
+ u.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: u.description })
1636
2145
  ] }) });
1637
- }, fn = se(dn), hn = K(
2146
+ }, jn = fe(Wn), Bn = te(
1638
2147
  5,
1639
- ze((e) => {
2148
+ De((e) => {
1640
2149
  const t = e["x-computed"];
1641
2150
  return e.type === "number" && typeof t == "object" && t !== null;
1642
2151
  })
1643
- ), pn = ({
2152
+ ), Xn = ({
1644
2153
  data: e,
1645
2154
  path: t,
1646
2155
  schema: r,
1647
- uischema: i,
1648
- enabled: f,
1649
- visible: s,
2156
+ uischema: o,
2157
+ enabled: u,
2158
+ visible: i,
1650
2159
  addItem: l,
1651
- removeItems: a,
1652
- rootSchema: o,
1653
- arraySchema: c
2160
+ removeItems: c,
2161
+ rootSchema: s,
2162
+ arraySchema: d
1654
2163
  }) => {
1655
- const u = c ? r : r.items, y = c || r;
1656
- if (s === !1 || !u || typeof u != "object" || Array.isArray(u))
2164
+ const a = d ? r : r.items, g = d || r;
2165
+ if (i === !1 || !a || typeof a != "object" || Array.isArray(a))
1657
2166
  return null;
1658
- const p = u, m = Array.isArray(e) ? e : [], v = y.title || "Array Items", N = i.options ?? {}, A = f && N.addable !== !1, w = f && N.removable !== !1, I = () => {
1659
- const D = Or(p, o);
1660
- l && l(t, D)();
1661
- }, L = (D) => {
1662
- if (a) {
1663
- const C = a(t, [D]);
1664
- C && C();
2167
+ const f = a, y = Array.isArray(e) ? e : [], w = g.title || "Array Items", L = o.options ?? {}, O = u && L.addable !== !1, R = u && L.removable !== !1, T = () => {
2168
+ const N = Wr(f, s);
2169
+ l && l(t, N)();
2170
+ }, S = (N) => {
2171
+ if (c) {
2172
+ const D = c(t, [N]);
2173
+ D && D();
1665
2174
  }
1666
2175
  };
1667
- return /* @__PURE__ */ n(R, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1668
- /* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
1669
- m.length === 0 && /* @__PURE__ */ n(R, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
1670
- m.map((D, C) => {
2176
+ return /* @__PURE__ */ n(I, { mb: "6", children: /* @__PURE__ */ m(k, { direction: "column", gap: "4", children: [
2177
+ /* @__PURE__ */ n(p, { as: "div", size: "4", weight: "bold", children: w }),
2178
+ y.length === 0 && /* @__PURE__ */ n(I, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2179
+ y.map((N, D) => {
1671
2180
  var W;
1672
- const H = `${t}.${C}`;
1673
- return /* @__PURE__ */ n(nr, { size: "3", variant: "surface", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1674
- /* @__PURE__ */ g(S, { justify: "between", align: "center", children: [
1675
- /* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
2181
+ const $ = `${t}.${D}`;
2182
+ return /* @__PURE__ */ n(Rr, { size: "3", variant: "surface", children: /* @__PURE__ */ m(k, { direction: "column", gap: "4", children: [
2183
+ /* @__PURE__ */ m(k, { justify: "between", align: "center", children: [
2184
+ /* @__PURE__ */ m(p, { size: "3", weight: "bold", children: [
1676
2185
  "Item ",
1677
- C + 1
2186
+ D + 1
1678
2187
  ] }),
1679
- w && /* @__PURE__ */ g(
1680
- ke,
2188
+ R && /* @__PURE__ */ m(
2189
+ Ie,
1681
2190
  {
1682
2191
  type: "button",
1683
2192
  color: "red",
1684
2193
  variant: "soft",
1685
- onClick: () => L(C),
2194
+ onClick: () => S(D),
1686
2195
  title: "Remove item",
1687
2196
  children: [
1688
- /* @__PURE__ */ n(Ur, {}),
2197
+ /* @__PURE__ */ n(Jr, {}),
1689
2198
  "Remove"
1690
2199
  ]
1691
2200
  }
1692
2201
  )
1693
2202
  ] }),
1694
- /* @__PURE__ */ n(R, { children: /* @__PURE__ */ n(
1695
- Ae,
2203
+ /* @__PURE__ */ n(I, { children: /* @__PURE__ */ n(
2204
+ ze,
1696
2205
  {
1697
- schema: p,
1698
- uischema: ((W = i.options) == null ? void 0 : W.detail) || (p.type === "object" || p.properties ? {
2206
+ schema: f,
2207
+ uischema: ((W = o.options) == null ? void 0 : W.detail) || (f.type === "object" || f.properties ? {
1699
2208
  type: "VerticalLayout",
1700
- elements: Object.keys(p.properties || {}).map((x) => ({
2209
+ elements: Object.keys(f.properties || {}).map((z) => ({
1701
2210
  type: "Control",
1702
- scope: `#/properties/${x}`
2211
+ scope: `#/properties/${z}`
1703
2212
  }))
1704
2213
  } : {
1705
2214
  type: "Control",
1706
2215
  scope: "#"
1707
2216
  }),
1708
- path: H,
1709
- enabled: f,
2217
+ path: $,
2218
+ enabled: u,
1710
2219
  renderers: void 0,
1711
2220
  cells: void 0
1712
2221
  }
1713
2222
  ) })
1714
- ] }) }, H);
2223
+ ] }) }, $);
1715
2224
  }),
1716
- A && /* @__PURE__ */ n(R, { mt: "2", children: /* @__PURE__ */ g(ke, { type: "button", variant: "surface", onClick: I, children: [
1717
- /* @__PURE__ */ n(Hr, {}),
2225
+ O && /* @__PURE__ */ n(I, { mt: "2", children: /* @__PURE__ */ m(Ie, { type: "button", variant: "surface", onClick: T, children: [
2226
+ /* @__PURE__ */ n(Zr, {}),
1718
2227
  "Add Item"
1719
2228
  ] }) })
1720
2229
  ] }) });
1721
- }, qe = Mr(pn), mn = K(3, Nr), gn = ({ uischema: e, visible: t }) => {
2230
+ }, pr = Xr(Xn), Kn = te(3, jr), Gn = ({ uischema: e, visible: t }) => {
1722
2231
  const r = e;
1723
- return t === !1 ? null : /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ n(tr, { size: "4", children: r.text }) });
1724
- }, yn = K(1, Te("Label")), vn = K(3, Ir), xn = [
1725
- { tester: Kr, renderer: Gr },
1726
- { tester: jr, renderer: Yr },
1727
- { tester: qr, renderer: Zr },
1728
- { tester: et, renderer: rt },
1729
- { tester: ct, renderer: st },
1730
- { tester: nt, renderer: ot },
1731
- { tester: ft, renderer: ht },
1732
- { tester: mt, renderer: pt },
1733
- { tester: yt, renderer: gt },
2232
+ return t === !1 ? null : /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ n(Er, { size: "4", children: r.text }) });
2233
+ }, Yn = te(1, Me("Label")), Jn = te(3, Br), so = [
2234
+ { tester: tt, renderer: nt },
2235
+ { tester: it, renderer: lt },
2236
+ { tester: ct, renderer: at },
2237
+ { tester: dt, renderer: ft },
1734
2238
  { tester: bt, renderer: vt },
1735
- { tester: Et, renderer: wt },
1736
- { tester: At, renderer: Tt },
1737
- { tester: nn, renderer: tn },
1738
- { tester: hn, renderer: fn },
1739
- { tester: mn, renderer: qe },
1740
- { tester: vn, renderer: qe },
1741
- { tester: yn, renderer: gn }
2239
+ { tester: pt, renderer: mt },
2240
+ { tester: At, renderer: Ct },
2241
+ { tester: St, renderer: Tt },
2242
+ { tester: xt, renderer: Ot },
2243
+ { tester: It, renderer: Nt },
2244
+ { tester: Dt, renderer: kt },
2245
+ { tester: Ft, renderer: Lt },
2246
+ { tester: wn, renderer: bn },
2247
+ // After SpreadsheetControl on purpose: both testers rank 10, and a tie is
2248
+ // resolved by registration order (see XmlControlTester's comment).
2249
+ { tester: Fn, renderer: Ln },
2250
+ { tester: Bn, renderer: jn },
2251
+ { tester: Kn, renderer: pr },
2252
+ { tester: Jn, renderer: pr },
2253
+ { tester: Yn, renderer: Gn }
1742
2254
  ];
1743
2255
  export {
1744
- qe as ArrayControl,
1745
- mn as ArrayControlTester,
1746
- Jr as BooleanControl,
1747
- qr as BooleanControlTester,
1748
- wt as CategorizationLayoutRenderer,
1749
- Et as CategorizationLayoutTester,
1750
- fn as ComputedControl,
1751
- hn as ComputedControlTester,
1752
- dt as DateControl,
1753
- ft as DateControlTester,
1754
- Tt as FileControl,
1755
- At as FileControlTester,
1756
- vt as GroupLayoutRenderer,
1757
- bt as GroupLayoutTester,
1758
- gt as HorizontalLayoutRenderer,
1759
- yt as HorizontalLayoutTester,
1760
- gn as LabelRenderer,
1761
- yn as LabelTester,
1762
- Xr as NumberControl,
1763
- jr as NumberControlTester,
1764
- Qr as RadioControl,
1765
- et as RadioControlTester,
1766
- st as SearchSelectControl,
1767
- ct as SearchSelectControlTester,
1768
- In as SearchServiceProvider,
1769
- tt as SelectControl,
1770
- nt as SelectControlTester,
1771
- tn as SpreadsheetControl,
1772
- nn as SpreadsheetControlTester,
1773
- Br as TextControl,
1774
- Kr as TextControlTester,
1775
- Nn as UploadProvider,
1776
- pt as VerticalLayoutRenderer,
1777
- mt as VerticalLayoutTester,
1778
- xn as radixRenderers,
1779
- Wr as useSearchService,
1780
- Vr as useUpload
2256
+ pr as ArrayControl,
2257
+ Kn as ArrayControlTester,
2258
+ st as BooleanControl,
2259
+ ct as BooleanControlTester,
2260
+ kt as CategorizationLayoutRenderer,
2261
+ Dt as CategorizationLayoutTester,
2262
+ jn as ComputedControl,
2263
+ Bn as ComputedControlTester,
2264
+ Rt as DateControl,
2265
+ At as DateControlTester,
2266
+ Lt as FileControl,
2267
+ Ft as FileControlTester,
2268
+ Nt as GroupLayoutRenderer,
2269
+ It as GroupLayoutTester,
2270
+ Ot as HorizontalLayoutRenderer,
2271
+ xt as HorizontalLayoutTester,
2272
+ Gn as LabelRenderer,
2273
+ Yn as LabelTester,
2274
+ ot as NumberControl,
2275
+ it as NumberControlTester,
2276
+ ut as RadioControl,
2277
+ dt as RadioControlTester,
2278
+ vt as SearchSelectControl,
2279
+ bt as SearchSelectControlTester,
2280
+ lo as SearchServiceProvider,
2281
+ ht as SelectControl,
2282
+ pt as SelectControlTester,
2283
+ bn as SpreadsheetControl,
2284
+ wn as SpreadsheetControlTester,
2285
+ rt as TextControl,
2286
+ tt as TextControlTester,
2287
+ io as UploadProvider,
2288
+ Tt as VerticalLayoutRenderer,
2289
+ St as VerticalLayoutTester,
2290
+ Ln as XmlControl,
2291
+ Fn as XmlControlTester,
2292
+ so as radixRenderers,
2293
+ et as useSearchService,
2294
+ Qr as useUpload
1781
2295
  };