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