@opennsw/jsonforms-renderers 0.11.0 → 0.12.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,44 +1,44 @@
1
- var Jt = Object.defineProperty;
2
- var Zt = (e, r, t) => r in e ? Jt(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var ut = (e, r, t) => Zt(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { jsx as i, jsxs as y, Fragment as ge } from "react/jsx-runtime";
5
- import { useContext as Rt, createContext as Ct, useMemo as _e, useEffect as de, useState as j, useRef as ae, useCallback as Fe } from "react";
6
- import { rankWith as ee, isStringControl as Qt, or as Je, isNumberControl as er, isIntegerControl as tr, isBooleanControl as rr, isEnumControl as St, isOneOfControl as Ot, Resolve as Ve, schemaMatches as Ie, isDateControl as nr, isDateTimeControl as or, isTimeControl as ir, uiTypeIs as He, and as Nt, not as sr, optionIs as lr, update as cr, createDefaultValue as ar, isObjectArrayControl as ur, isPrimitiveArrayControl as dr } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as ue, useJsonForms as We, JsonFormsDispatch as Be, withJsonFormsArrayControlProps as fr } from "@jsonforms/react";
8
- import { Box as S, Flex as D, Text as f, TextField as Ae, Checkbox as pr, RadioGroup as dt, ScrollArea as kt, Select as Ke, Spinner as Ue, Button as De, Tabs as Ye, Heading as It, Card as Dt, IconButton as je, Table as Te, Tooltip as qe } from "@radix-ui/themes";
9
- import { ChevronDownIcon as Lt, FileTextIcon as hr, CheckCircledIcon as mr, Cross2Icon as rt, ExclamationTriangleIcon as nt, UploadIcon as ze, DownloadIcon as Mt, TrashIcon as gr, PlusIcon as yr } from "@radix-ui/react-icons";
10
- import zt from "dayjs";
11
- const Ft = Ct(null);
12
- function ei({
1
+ var fr = Object.defineProperty;
2
+ var pr = (e, r, t) => r in e ? fr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var gt = (e, r, t) => pr(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { jsx as i, jsxs as y, Fragment as ve } from "react/jsx-runtime";
5
+ import { useContext as Mt, createContext as zt, useMemo as We, useEffect as me, useState as j, useRef as ue, useCallback as $e } from "react";
6
+ import { rankWith as te, isStringControl as hr, or as tt, isNumberControl as mr, isIntegerControl as gr, isBooleanControl as yr, isEnumControl as Ft, isOneOfControl as Ut, Resolve as Pe, schemaMatches as Me, isDateControl as br, isDateTimeControl as vr, isTimeControl as wr, uiTypeIs as Xe, and as $t, not as Er, optionIs as Tr, update as xr, createDefaultValue as Ar, isObjectArrayControl as Rr, isPrimitiveArrayControl as Cr } from "@jsonforms/core";
7
+ import { withJsonFormsControlProps as pe, useJsonForms as Ve, JsonFormsDispatch as Ye, withJsonFormsArrayControlProps as Sr, withJsonFormsLayoutProps as Ge } from "@jsonforms/react";
8
+ import { Box as k, Flex as F, Text as h, TextField as Oe, Checkbox as Or, RadioGroup as yt, ScrollArea as Pt, Select as qe, Spinner as _e, Button as ze, Tabs as Je, Heading as _t, Card as jt, Tooltip as Be, IconButton as je, Table as Se } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as Vt, FileTextIcon as Nr, DownloadIcon as at, CheckCircledIcon as Dr, Cross2Icon as ct, ExclamationTriangleIcon as ut, UploadIcon as Ue, TrashIcon as Ir, PlusIcon as kr } from "@radix-ui/react-icons";
10
+ import Ht from "dayjs";
11
+ const Wt = zt(null);
12
+ function Ci({
13
13
  children: e,
14
14
  onUpload: r,
15
15
  getDownloadUrl: t
16
16
  }) {
17
17
  const n = { onUpload: r, getDownloadUrl: t };
18
- return /* @__PURE__ */ i(Ft.Provider, { value: n, children: e });
18
+ return /* @__PURE__ */ i(Wt.Provider, { value: n, children: e });
19
19
  }
20
- function br() {
21
- return Rt(Ft);
20
+ function Lr() {
21
+ return Mt(Wt);
22
22
  }
23
- const Ut = Ct(null);
24
- function ti({
23
+ const Bt = zt(null);
24
+ function Si({
25
25
  children: e,
26
26
  services: r
27
27
  }) {
28
- const t = _e(() => r, [r]);
29
- return /* @__PURE__ */ i(Ut.Provider, { value: t, children: e });
28
+ const t = We(() => r, [r]);
29
+ return /* @__PURE__ */ i(Bt.Provider, { value: t, children: e });
30
30
  }
31
- function vr(e) {
32
- const r = Rt(Ut);
31
+ function Mr(e) {
32
+ const r = Mt(Bt);
33
33
  return !r || !e ? null : r[e] ?? null;
34
34
  }
35
- const Ee = (e, r, t, n = void 0) => {
36
- de(() => {
35
+ const Re = (e, r, t, n = void 0) => {
36
+ me(() => {
37
37
  e === !1 && t(r, n);
38
38
  }, [e, r, t, n]);
39
- }, ye = (e, r) => e ? e.split(`
39
+ }, we = (e, r) => e ? e.split(`
40
40
  `).map((t) => t.trim() === "is a required property" ? `${r || "This field"} is required` : t).join(`
41
- `) : "", wr = ({
41
+ `) : "", zr = ({
42
42
  data: e,
43
43
  handleChange: r,
44
44
  path: t,
@@ -46,35 +46,35 @@ const Ee = (e, r, t, n = void 0) => {
46
46
  required: l,
47
47
  errors: o,
48
48
  uischema: s,
49
- schema: c,
49
+ schema: u,
50
50
  enabled: a,
51
- visible: d = !0
51
+ visible: c = !0
52
52
  }) => {
53
- var h;
54
- if (Ee(d, t, r), d === !1)
53
+ var f;
54
+ if (Re(c, t, r), c === !1)
55
55
  return null;
56
- const u = o.length === 0;
57
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
58
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
56
+ const d = o.length === 0;
57
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
58
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
59
59
  n,
60
60
  " ",
61
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
61
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
62
62
  ] }),
63
63
  /* @__PURE__ */ i(
64
- Ae.Root,
64
+ Oe.Root,
65
65
  {
66
66
  value: e || "",
67
67
  onChange: (p) => r(t, p.target.value),
68
68
  disabled: !a,
69
- placeholder: (h = s.options) == null ? void 0 : h.placeholder,
70
- color: u ? void 0 : "red",
69
+ placeholder: (f = s.options) == null ? void 0 : f.placeholder,
70
+ color: d ? void 0 : "red",
71
71
  id: t
72
72
  }
73
73
  ),
74
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
75
- c.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: c.description })
74
+ !d && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
75
+ u.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: u.description })
76
76
  ] }) });
77
- }, Er = ee(1, Qt), Tr = ue(wr), Ar = ({
77
+ }, Fr = te(1, hr), Ur = pe(zr), $r = ({
78
78
  data: e,
79
79
  handleChange: r,
80
80
  path: t,
@@ -82,14 +82,14 @@ const Ee = (e, r, t, n = void 0) => {
82
82
  required: l,
83
83
  errors: o,
84
84
  uischema: s,
85
- schema: c,
85
+ schema: u,
86
86
  enabled: a,
87
- visible: d = !0
87
+ visible: c = !0
88
88
  }) => {
89
89
  var p;
90
- if (Ee(d, t, r), d === !1)
90
+ if (Re(c, t, r), c === !1)
91
91
  return null;
92
- const u = o.length === 0, h = (g) => {
92
+ const d = o.length === 0, f = (g) => {
93
93
  if (g === "") {
94
94
  r(t, void 0);
95
95
  return;
@@ -97,28 +97,28 @@ const Ee = (e, r, t, n = void 0) => {
97
97
  const b = Number(g);
98
98
  isNaN(b) || r(t, b);
99
99
  };
100
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
101
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
100
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
101
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
102
102
  n,
103
103
  " ",
104
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
104
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
105
105
  ] }),
106
106
  /* @__PURE__ */ i(
107
- Ae.Root,
107
+ Oe.Root,
108
108
  {
109
109
  type: "number",
110
110
  value: e ?? "",
111
- onChange: (g) => h(g.target.value),
111
+ onChange: (g) => f(g.target.value),
112
112
  disabled: !a,
113
113
  placeholder: (p = s.options) == null ? void 0 : p.placeholder,
114
- color: u ? void 0 : "red",
114
+ color: d ? void 0 : "red",
115
115
  id: t
116
116
  }
117
117
  ),
118
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
119
- c.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: c.description })
118
+ !d && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
119
+ u.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: u.description })
120
120
  ] }) });
121
- }, xr = ee(2, Je(er, tr)), Rr = ue(Ar), Cr = ({
121
+ }, Pr = te(2, tt(mr, gr)), _r = pe($r), jr = ({
122
122
  data: e,
123
123
  handleChange: r,
124
124
  path: t,
@@ -126,33 +126,33 @@ const Ee = (e, r, t, n = void 0) => {
126
126
  required: l,
127
127
  errors: o,
128
128
  schema: s,
129
- enabled: c,
129
+ enabled: u,
130
130
  visible: a = !0
131
131
  }) => {
132
- if (Ee(a, t, r), a === !1)
132
+ if (Re(a, t, r), a === !1)
133
133
  return null;
134
- const d = o.length === 0;
135
- return /* @__PURE__ */ y(S, { mb: "4", children: [
136
- /* @__PURE__ */ y(D, { gap: "2", align: "center", children: [
134
+ const c = o.length === 0;
135
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
136
+ /* @__PURE__ */ y(F, { gap: "2", align: "center", children: [
137
137
  /* @__PURE__ */ i(
138
- pr,
138
+ Or,
139
139
  {
140
140
  checked: !!e,
141
- onCheckedChange: (u) => r(t, u === !0),
142
- disabled: !c,
141
+ onCheckedChange: (d) => r(t, d === !0),
142
+ disabled: !u,
143
143
  id: t
144
144
  }
145
145
  ),
146
- /* @__PURE__ */ y(f, { as: "label", size: "2", htmlFor: t, children: [
146
+ /* @__PURE__ */ y(h, { as: "label", size: "2", htmlFor: t, children: [
147
147
  n,
148
148
  " ",
149
149
  l && "*"
150
150
  ] })
151
151
  ] }),
152
- !d && /* @__PURE__ */ i(f, { color: "red", size: "1", className: "block mt-1", children: ye(o, n) }),
153
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", className: "block mt-1", children: s.description })
152
+ !c && /* @__PURE__ */ i(h, { color: "red", size: "1", className: "block mt-1", children: we(o, n) }),
153
+ s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", className: "block mt-1", children: s.description })
154
154
  ] });
155
- }, Sr = ee(2, rr), Or = ue(Cr), Nr = ({
155
+ }, Vr = te(2, yr), Hr = pe(jr), Wr = ({
156
156
  data: e,
157
157
  handleChange: r,
158
158
  path: t,
@@ -160,35 +160,35 @@ const Ee = (e, r, t, n = void 0) => {
160
160
  required: l,
161
161
  errors: o,
162
162
  schema: s,
163
- enabled: c,
163
+ enabled: u,
164
164
  visible: a = !0
165
165
  }) => {
166
- if (Ee(a, t, r), a === !1)
166
+ if (Re(a, t, r), a === !1)
167
167
  return null;
168
- const d = o.length === 0;
169
- let u = [];
170
- s.enum ? u = s.enum.map((p) => ({ value: p, label: String(p) })) : s.oneOf && (u = s.oneOf.map((p) => ({
168
+ const c = o.length === 0;
169
+ let d = [];
170
+ s.enum ? d = s.enum.map((p) => ({ value: p, label: String(p) })) : s.oneOf && (d = s.oneOf.map((p) => ({
171
171
  value: p.const,
172
172
  label: p.title || String(p.const)
173
173
  })));
174
- const h = e;
175
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
176
- /* @__PURE__ */ y(f, { as: "div", size: "2", weight: "bold", children: [
174
+ const f = e;
175
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
176
+ /* @__PURE__ */ y(h, { as: "div", size: "2", weight: "bold", children: [
177
177
  n,
178
178
  " ",
179
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
179
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
180
180
  ] }),
181
181
  /* @__PURE__ */ i(
182
- dt.Root,
182
+ yt.Root,
183
183
  {
184
- value: h !== void 0 ? String(h) : "",
184
+ value: f !== void 0 ? String(f) : "",
185
185
  onValueChange: (p) => {
186
- const g = u.find((b) => String(b.value) === p);
186
+ const g = d.find((b) => String(b.value) === p);
187
187
  g && r(t, g.value);
188
188
  },
189
- disabled: !c,
189
+ disabled: !u,
190
190
  children: /* @__PURE__ */ i(
191
- D,
191
+ F,
192
192
  {
193
193
  direction: "row",
194
194
  style: {
@@ -196,21 +196,21 @@ const Ee = (e, r, t, n = void 0) => {
196
196
  columnGap: "clamp(14px, 3vw, 36px)",
197
197
  rowGap: "clamp(8px, 1.6vw, 14px)"
198
198
  },
199
- children: u.map((p) => /* @__PURE__ */ y(D, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
200
- /* @__PURE__ */ i(dt.Item, { value: String(p.value) }),
201
- /* @__PURE__ */ i(f, { size: "2", color: c ? void 0 : "gray", children: p.label })
199
+ children: d.map((p) => /* @__PURE__ */ y(F, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
200
+ /* @__PURE__ */ i(yt.Item, { value: String(p.value) }),
201
+ /* @__PURE__ */ i(h, { size: "2", color: u ? void 0 : "gray", children: p.label })
202
202
  ] }, String(p.value)))
203
203
  }
204
204
  )
205
205
  }
206
206
  ),
207
- !d && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
208
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
207
+ !c && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
208
+ s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
209
209
  ] }) });
210
- }, kr = (e, r, t) => {
210
+ }, Br = (e, r, t) => {
211
211
  var l;
212
- return Je(St, Ot)(e, r, t) && ((l = e == null ? void 0 : e.options) == null ? void 0 : l.format) === "radio" ? 3 : -1;
213
- }, Ir = ue(Nr), Dr = ({
212
+ return tt(Ft, Ut)(e, r, t) && ((l = e == null ? void 0 : e.options) == null ? void 0 : l.format) === "radio" ? 3 : -1;
213
+ }, Xr = pe(Wr), Yr = ({
214
214
  data: e,
215
215
  handleChange: r,
216
216
  path: t,
@@ -218,85 +218,85 @@ const Ee = (e, r, t, n = void 0) => {
218
218
  required: l,
219
219
  errors: o,
220
220
  schema: s,
221
- uischema: c,
221
+ uischema: u,
222
222
  enabled: a,
223
- visible: d = !0
223
+ visible: c = !0
224
224
  }) => {
225
- var N, U, z;
226
- Ee(d, t, r);
227
- const u = ((N = c.options) == null ? void 0 : N.autocomplete) === !0, [h, p] = j(!1), [g, b] = j(""), [I, O] = j(0), T = ae(null);
228
- if (de(() => {
229
- if (!u || !h) return;
230
- const v = (E) => {
231
- T.current && !T.current.contains(E.target) && p(!1);
225
+ var D, z, V;
226
+ Re(c, t, r);
227
+ const d = ((D = u.options) == null ? void 0 : D.autocomplete) === !0, [f, p] = j(!1), [g, b] = j(""), [M, N] = j(0), U = ue(null);
228
+ if (me(() => {
229
+ if (!d || !f) return;
230
+ const v = (x) => {
231
+ U.current && !U.current.contains(x.target) && p(!1);
232
232
  };
233
233
  return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
234
- }, [u, h]), d === !1)
234
+ }, [d, f]), c === !1)
235
235
  return null;
236
- const A = o.length === 0;
237
- let k = [];
238
- s.enum ? k = s.enum.map((v) => ({ value: String(v), label: String(v) })) : s.oneOf && (k = s.oneOf.map((v) => ({
236
+ const T = o.length === 0;
237
+ let R = [];
238
+ s.enum ? R = s.enum.map((v) => ({ value: String(v), label: String(v) })) : s.oneOf && (R = s.oneOf.map((v) => ({
239
239
  value: String(v.const),
240
240
  label: v.title || String(v.const)
241
241
  })));
242
- const M = e !== void 0 ? String(e) : "", L = ((U = c.options) == null ? void 0 : U.placeholder) || "Select an option";
243
- if (u) {
244
- const v = ((z = k.find((R) => R.value === M)) == null ? void 0 : z.label) ?? "", E = h ? k.filter((R) => R.label.toLowerCase().includes(g.toLowerCase())) : k, B = Math.min(I, E.length - 1), K = (R) => {
245
- r(t, R.value), p(!1);
246
- }, J = (R) => {
247
- R.stopPropagation(), r(t, void 0), b("");
248
- }, F = (R) => {
249
- (R.key === "Enter" || R.key === " ") && J(R);
242
+ const I = e !== void 0 ? String(e) : "", A = ((z = u.options) == null ? void 0 : z.placeholder) || "Select an option";
243
+ if (d) {
244
+ const v = ((V = R.find((O) => O.value === I)) == null ? void 0 : V.label) ?? "", x = f ? R.filter((O) => O.label.toLowerCase().includes(g.toLowerCase())) : R, re = Math.min(M, x.length - 1), X = (O) => {
245
+ r(t, O.value), p(!1);
246
+ }, Y = (O) => {
247
+ O.stopPropagation(), r(t, void 0), b("");
248
+ }, L = (O) => {
249
+ (O.key === "Enter" || O.key === " ") && Y(O);
250
250
  };
251
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
252
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
251
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
252
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
253
253
  n,
254
254
  " ",
255
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
255
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
256
256
  ] }),
257
- /* @__PURE__ */ y("div", { ref: T, style: { position: "relative" }, children: [
257
+ /* @__PURE__ */ y("div", { ref: U, style: { position: "relative" }, children: [
258
258
  /* @__PURE__ */ i(
259
- Ae.Root,
259
+ Oe.Root,
260
260
  {
261
261
  id: t,
262
- value: h ? g : v,
263
- placeholder: L,
262
+ value: f ? g : v,
263
+ placeholder: A,
264
264
  disabled: !a,
265
- style: A ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
266
- onChange: (R) => {
267
- b(R.target.value), O(0), h || p(!0);
265
+ style: T ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
266
+ onChange: (O) => {
267
+ b(O.target.value), N(0), f || p(!0);
268
268
  },
269
269
  onFocus: () => {
270
- a && !h && (b(""), O(0), p(!0));
270
+ a && !f && (b(""), N(0), p(!0));
271
271
  },
272
- onKeyDown: (R) => {
273
- R.key === "Escape" ? p(!1) : R.key === "ArrowDown" ? (R.preventDefault(), h ? O((Y) => Math.min(Y + 1, E.length - 1)) : (b(""), p(!0))) : R.key === "ArrowUp" ? (R.preventDefault(), h && O((Y) => Math.max(Y - 1, 0))) : R.key === "Enter" && h && E[B] && (R.preventDefault(), K(E[B]));
272
+ onKeyDown: (O) => {
273
+ O.key === "Escape" ? p(!1) : O.key === "ArrowDown" ? (O.preventDefault(), f ? N((G) => Math.min(G + 1, x.length - 1)) : (b(""), p(!0))) : O.key === "ArrowUp" ? (O.preventDefault(), f && N((G) => Math.max(G - 1, 0))) : O.key === "Enter" && f && x[re] && (O.preventDefault(), X(x[re]));
274
274
  },
275
- children: /* @__PURE__ */ i(Ae.Slot, { side: "right", children: /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
276
- M && a && /* @__PURE__ */ i(
275
+ children: /* @__PURE__ */ i(Oe.Slot, { side: "right", children: /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
276
+ I && a && /* @__PURE__ */ i(
277
277
  "span",
278
278
  {
279
279
  role: "button",
280
280
  tabIndex: 0,
281
- onMouseDown: (R) => R.preventDefault(),
282
- onClick: J,
283
- onKeyDown: F,
281
+ onMouseDown: (O) => O.preventDefault(),
282
+ onClick: Y,
283
+ onKeyDown: L,
284
284
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
285
285
  "aria-label": "Clear selection",
286
286
  children: "×"
287
287
  }
288
288
  ),
289
289
  /* @__PURE__ */ i(
290
- Lt,
290
+ Vt,
291
291
  {
292
- style: { transform: h ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
292
+ style: { transform: f ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
293
293
  }
294
294
  )
295
295
  ] }) })
296
296
  }
297
297
  ),
298
- h && /* @__PURE__ */ i(
299
- S,
298
+ f && /* @__PURE__ */ i(
299
+ k,
300
300
  {
301
301
  style: {
302
302
  position: "absolute",
@@ -310,82 +310,82 @@ const Ee = (e, r, t, n = void 0) => {
310
310
  border: "1px solid var(--gray-a6)",
311
311
  overflow: "hidden"
312
312
  },
313
- children: /* @__PURE__ */ i(kt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(S, { p: "1", children: [
314
- E.length === 0 && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "No results found." }) }),
315
- E.map((R, Y) => /* @__PURE__ */ i(
316
- S,
313
+ children: /* @__PURE__ */ i(Pt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(k, { p: "1", children: [
314
+ x.length === 0 && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "No results found." }) }),
315
+ x.map((O, G) => /* @__PURE__ */ i(
316
+ k,
317
317
  {
318
318
  px: "3",
319
319
  py: "2",
320
320
  onMouseDown: (Q) => Q.preventDefault(),
321
- onClick: () => K(R),
322
- onMouseEnter: () => O(Y),
321
+ onClick: () => X(O),
322
+ onMouseEnter: () => N(G),
323
323
  style: {
324
324
  cursor: "pointer",
325
325
  borderRadius: "var(--radius-2)",
326
- backgroundColor: Y === B ? "var(--accent-4)" : R.value === M ? "var(--accent-3)" : void 0
326
+ backgroundColor: G === re ? "var(--accent-4)" : O.value === I ? "var(--accent-3)" : void 0
327
327
  },
328
- children: /* @__PURE__ */ i(f, { size: "2", children: R.label })
328
+ children: /* @__PURE__ */ i(h, { size: "2", children: O.label })
329
329
  },
330
- R.value
330
+ O.value
331
331
  ))
332
332
  ] }) })
333
333
  }
334
334
  )
335
335
  ] }),
336
- !A && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
337
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
336
+ !T && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
337
+ s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
338
338
  ] }) });
339
339
  }
340
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
341
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
340
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
341
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
342
342
  n,
343
343
  " ",
344
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
344
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
345
345
  ] }),
346
- /* @__PURE__ */ y(Ke.Root, { value: M, onValueChange: (v) => r(t, v), disabled: !a, children: [
347
- /* @__PURE__ */ i(Ke.Trigger, { placeholder: L, color: A ? void 0 : "red", id: t }),
348
- /* @__PURE__ */ i(Ke.Content, { children: k.map((v) => /* @__PURE__ */ i(Ke.Item, { value: v.value, children: v.label }, v.value)) })
346
+ /* @__PURE__ */ y(qe.Root, { value: I, onValueChange: (v) => r(t, v), disabled: !a, children: [
347
+ /* @__PURE__ */ i(qe.Trigger, { placeholder: A, color: T ? void 0 : "red", id: t }),
348
+ /* @__PURE__ */ i(qe.Content, { children: R.map((v) => /* @__PURE__ */ i(qe.Item, { value: v.value, children: v.label }, v.value)) })
349
349
  ] }),
350
- !A && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
351
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
350
+ !T && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
351
+ s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
352
352
  ] }) });
353
- }, Lr = ee(2, Je(St, Ot)), Mr = ue(Dr), Pt = /\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g, zr = {
354
- today: (e) => zt().format(e || "YYYY-MM-DD")
355
- }, Fr = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint", ft = (e, r) => Object.prototype.hasOwnProperty.call(e, r);
356
- function ot(e, r, t = {}) {
357
- const n = { ...zr, ...t };
358
- return e.replace(Pt, (l, o, s) => {
359
- let c;
353
+ }, Kr = te(2, tt(Ft, Ut)), Gr = pe(Yr), Xt = /\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g, qr = {
354
+ today: (e) => Ht().format(e || "YYYY-MM-DD")
355
+ }, Jr = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint", bt = (e, r) => Object.prototype.hasOwnProperty.call(e, r);
356
+ function rt(e, r, t = {}) {
357
+ const n = { ...qr, ...t };
358
+ return e.replace(Xt, (l, o, s) => {
359
+ let u;
360
360
  if (s === void 0) {
361
- if (!ft(r, o)) return l;
362
- c = r[o];
361
+ if (!bt(r, o)) return l;
362
+ u = r[o];
363
363
  } else {
364
- if (!ft(n, o)) return l;
364
+ if (!bt(n, o)) return l;
365
365
  try {
366
- c = n[o](s);
366
+ u = n[o](s);
367
367
  } catch {
368
368
  return l;
369
369
  }
370
370
  }
371
- return c == null ? "" : Fr(c) ? String(c) : l;
371
+ return u == null ? "" : Jr(u) ? String(u) : l;
372
372
  });
373
373
  }
374
- function it(e) {
374
+ function dt(e) {
375
375
  const r = [];
376
376
  let t = 0;
377
- for (const n of e.matchAll(Pt))
377
+ for (const n of e.matchAll(Xt))
378
378
  n.index > t && r.push(e.slice(t, n.index)), r.push(n[2] === void 0 ? { name: n[1] } : { name: n[1], arg: n[2] }), t = n.index + n[0].length;
379
379
  return t < e.length && r.push(e.slice(t)), r;
380
380
  }
381
- function Ur(e) {
381
+ function Zr(e) {
382
382
  if (typeof e == "string" && e.length > 0) return e;
383
383
  if (e && typeof e == "object" && typeof e.value == "string") {
384
384
  const r = e.value;
385
385
  return r.length > 0 ? r : void 0;
386
386
  }
387
387
  }
388
- function Pr(e) {
388
+ function Qr(e) {
389
389
  if (typeof e == "string") return e.length > 0 ? { parent: e } : void 0;
390
390
  if (!e || typeof e != "object") return;
391
391
  const r = Object.entries(e);
@@ -395,20 +395,20 @@ function Pr(e) {
395
395
  typeof o == "string" && o.length > 0 ? t[l] = o : n.push(l);
396
396
  return n.length > 0 && console.warn(`x-search.dependsOn: ignoring invalid entries [${n.join(", ")}]`), Object.keys(t).length === 0 ? (console.warn("x-search.dependsOn: map has no valid entries; search will not fetch until fixed"), {}) : t;
397
397
  }
398
- function $r(e, r, t) {
398
+ function en(e, r, t) {
399
399
  const n = {};
400
400
  for (const [l, o] of Object.entries(e))
401
- n[l] = Ur(Ve.data(r, t ? `${t}.${o}` : o));
401
+ n[l] = Zr(Pe.data(r, t ? `${t}.${o}` : o));
402
402
  return n;
403
403
  }
404
- function pt(e, r) {
405
- return r ? { ...e, name: ot(r, e) } : e;
404
+ function vt(e, r) {
405
+ return r ? { ...e, name: rt(r, e) } : e;
406
406
  }
407
- const _r = {
407
+ const tn = {
408
408
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
409
409
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
410
410
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
411
- }, Vr = ({
411
+ }, rn = ({
412
412
  data: e,
413
413
  handleChange: r,
414
414
  path: t,
@@ -416,167 +416,172 @@ const _r = {
416
416
  required: l,
417
417
  errors: o,
418
418
  enabled: s,
419
- visible: c = !0,
419
+ visible: u = !0,
420
420
  schema: a,
421
- uischema: d
421
+ uischema: c
422
422
  }) => {
423
- var Xe, pe;
424
- const u = (a == null ? void 0 : a["x-search"]) ?? {
423
+ var Ke, ye;
424
+ const d = (a == null ? void 0 : a["x-search"]) ?? {
425
425
  service: "",
426
426
  displayTemplate: ""
427
- }, h = u.service ?? "", p = u.mode ?? "large-paginated-list", g = _r[p], b = (g == null ? void 0 : g.fetchOnOpen) ?? !1, I = typeof u.displayTemplate == "string" ? u.displayTemplate : "", O = We(), T = t.split(".").slice(0, -1).join("."), { parentValues: A, parentValuesKey: k, missingParent: M } = _e(() => {
428
- var he;
429
- const w = Pr(u.dependsOn);
430
- if (!w) return { parentValues: void 0, parentValuesKey: "", missingParent: !1 };
431
- const Z = $r(w, (he = O.core) == null ? void 0 : he.data, T), ne = Object.keys(Z).length === 0 || Object.values(Z).some((Me) => !Me);
432
- return { parentValues: Z, parentValuesKey: JSON.stringify(Z), missingParent: ne };
433
- }, [u.dependsOn, (Xe = O.core) == null ? void 0 : Xe.data, T]), L = _e(() => A ? { ...u.params, ...A } : u.params, [A, k, u.params]), N = vr(h), U = a.type === "object", z = U ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, v = U ? z == null ? void 0 : z.value : e, E = z == null ? void 0 : z.label, B = h ? N ? g ? I ? null : "x-search.displayTemplate is required." : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${h}" is not registered.` : "Search not configured.", K = s !== !1, J = !o || o.length === 0, [F, R] = j(!1), [Y, Q] = j(""), [be, oe] = j([]), [Se, m] = j(!1), [C, G] = j(!1), [P, _] = j(!1), [re, q] = j(null), [ie, $] = j(void 0), fe = ae(void 0), Oe = ae(null), Pe = ae(null), $e = ae(null), xe = ae(void 0), x = ae(void 0);
434
- de(() => {
435
- if (!A) return;
436
- const w = x.current;
437
- if (x.current = A, !w || !v) return;
438
- Object.keys(A).some((ne) => w[ne] !== void 0 && w[ne] !== A[ne]) && r(t, U ? void 0 : null);
439
- }, [k, v, r, t, U]), de(() => {
440
- var Z, ne;
441
- if (B) {
442
- $(void 0), xe.current = void 0;
427
+ }, f = d.service ?? "", p = d.mode ?? "large-paginated-list", g = tn[p], b = (g == null ? void 0 : g.fetchOnOpen) ?? !1, M = typeof d.displayTemplate == "string" ? d.displayTemplate : "", N = Ve(), U = t.split(".").slice(0, -1).join("."), { parentValues: T, parentValuesKey: R, missingParent: I } = We(() => {
428
+ var be;
429
+ const E = Qr(d.dependsOn);
430
+ if (!E) return { parentValues: void 0, parentValuesKey: "", missingParent: !1 };
431
+ const Z = en(E, (be = N.core) == null ? void 0 : be.data, U), le = Object.keys(Z).length === 0 || Object.values(Z).some((Ce) => !Ce);
432
+ return { parentValues: Z, parentValuesKey: JSON.stringify(Z), missingParent: le };
433
+ }, [d.dependsOn, (Ke = N.core) == null ? void 0 : Ke.data, U]), A = We(() => T ? { ...d.params, ...T } : d.params, [T, R, d.params]), D = Mr(f), z = a.type === "object", V = z ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, v = z ? V == null ? void 0 : V.value : e, x = V == null ? void 0 : V.label, re = f ? D ? g ? M ? null : "x-search.displayTemplate is required." : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${f}" is not registered.` : "Search not configured.", X = s !== !1, Y = !o || o.length === 0, [L, O] = j(!1), [G, Q] = j(""), [de, ne] = j([]), [Ne, S] = j(!1), [K, fe] = j(!1), [Ee, ee] = j(!1), [ge, ie] = j(null), [Te, m] = j(void 0), w = ue(void 0), $ = ue(null), B = ue(null), q = ue(null), J = ue(void 0), C = ue(void 0);
434
+ me(() => {
435
+ if (!T) return;
436
+ const E = C.current;
437
+ if (C.current = T, !E || !v) return;
438
+ Object.keys(T).some((le) => E[le] !== void 0 && E[le] !== T[le]) && r(t, z ? void 0 : null);
439
+ }, [R, v, r, t, z]), me(() => {
440
+ var be, Ce;
441
+ if (re) {
442
+ m(void 0), J.current = void 0;
443
443
  return;
444
444
  }
445
445
  if (!v) {
446
- $(void 0), xe.current = void 0;
446
+ m(void 0), J.current = void 0;
447
447
  return;
448
448
  }
449
- if (((Z = xe.current) == null ? void 0 : Z.value) === v && ((ne = xe.current) == null ? void 0 : ne.label) === E) return;
450
- if (xe.current = { value: v, label: E }, U && E) {
451
- $({ id: v, name: E });
449
+ if (((be = J.current) == null ? void 0 : be.value) === v && ((Ce = J.current) == null ? void 0 : Ce.label) === x) return;
450
+ if (z && x) {
451
+ m({ id: v, name: x }), J.current = { value: v, label: x };
452
452
  return;
453
453
  }
454
- if ($({ id: v, name: E ?? v }), !(N != null && N.resolve)) return;
455
- let w = !1;
456
- return N.resolve(v, L).then((he) => {
457
- !w && he && $(pt(he, I));
454
+ if (m({ id: v, name: x ?? v }), !(D != null && D.resolve)) {
455
+ J.current = { value: v, label: x };
456
+ return;
457
+ }
458
+ let E = !1;
459
+ const Z = v, le = x;
460
+ return D.resolve(Z, A).then((He) => {
461
+ E || (He && m(vt(He, M)), J.current = { value: Z, label: le });
458
462
  }).catch(() => {
463
+ E || (J.current = { value: Z, label: le });
459
464
  }), () => {
460
- w = !0;
465
+ E = !0;
461
466
  };
462
- }, [B, v, E, U, N, L, I]);
463
- const V = Fe(
464
- async (w, Z = !1) => {
465
- var he;
466
- if (B) return;
467
- if (!N) {
468
- q("Search service not configured.");
467
+ }, [re, v, x, z, D, A, M]);
468
+ const P = $e(
469
+ async (E, Z = !1) => {
470
+ var be;
471
+ if (re) return;
472
+ if (!D) {
473
+ ie("Search service not configured.");
469
474
  return;
470
475
  }
471
- (he = Pe.current) == null || he.abort();
472
- const ne = new AbortController();
473
- Pe.current = ne, Z ? _(!0) : (G(!0), _(!1), q(null));
476
+ (be = B.current) == null || be.abort();
477
+ const le = new AbortController();
478
+ B.current = le, Z ? ee(!0) : (fe(!0), ee(!1), ie(null));
474
479
  try {
475
- const Me = await N.search({
476
- query: w,
477
- cursor: Z ? fe.current : void 0,
478
- signal: ne.signal,
479
- params: L
480
+ const Ce = await D.search({
481
+ query: E,
482
+ cursor: Z ? w.current : void 0,
483
+ signal: le.signal,
484
+ params: A
480
485
  });
481
- if (ne.signal.aborted) return;
482
- const at = (Me.options ?? []).map((Ze) => pt(Ze, I));
483
- oe(Z ? (Ze) => [...Ze, ...at] : at), fe.current = Me.nextCursor, m(((g == null ? void 0 : g.paginated) ?? !1) && Me.nextCursor != null);
486
+ if (le.signal.aborted) return;
487
+ const He = (Ce.options ?? []).map((nt) => vt(nt, M));
488
+ ne(Z ? (nt) => [...nt, ...He] : He), w.current = Ce.nextCursor, S(((g == null ? void 0 : g.paginated) ?? !1) && Ce.nextCursor != null);
484
489
  } catch {
485
- if (ne.signal.aborted) return;
486
- q("Failed to load results. Please try again.");
490
+ if (le.signal.aborted) return;
491
+ ie("Failed to load results. Please try again.");
487
492
  } finally {
488
- ne.signal.aborted || (Z ? _(!1) : G(!1));
493
+ le.signal.aborted || (Z ? ee(!1) : fe(!1));
489
494
  }
490
495
  },
491
- [B, N, g == null ? void 0 : g.paginated, L, I]
496
+ [re, D, g == null ? void 0 : g.paginated, A, M]
492
497
  );
493
- if (de(() => {
494
- if (!F) return;
495
- const w = (Z) => {
496
- $e.current && !$e.current.contains(Z.target) && R(!1);
498
+ if (me(() => {
499
+ if (!L) return;
500
+ const E = (Z) => {
501
+ q.current && !q.current.contains(Z.target) && O(!1);
497
502
  };
498
- return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
499
- }, [F]), de(() => {
500
- var w;
501
- F || ((w = Pe.current) == null || w.abort(), Q(""), oe([]), m(!1), q(null), G(!1), _(!1), fe.current = void 0);
502
- }, [F]), de(() => {
503
- if (!F) return;
504
- if (M) {
505
- oe([]), m(!1), q(null), fe.current = void 0;
503
+ return document.addEventListener("mousedown", E), () => document.removeEventListener("mousedown", E);
504
+ }, [L]), me(() => {
505
+ var E;
506
+ L || ((E = B.current) == null || E.abort(), Q(""), ne([]), S(!1), ie(null), fe(!1), ee(!1), w.current = void 0);
507
+ }, [L]), me(() => {
508
+ if (!L) return;
509
+ if (I) {
510
+ ne([]), S(!1), ie(null), w.current = void 0;
506
511
  return;
507
512
  }
508
- if (!Y && !b) {
509
- oe([]), m(!1), q(null), fe.current = void 0;
513
+ if (!G && !b) {
514
+ ne([]), S(!1), ie(null), w.current = void 0;
510
515
  return;
511
516
  }
512
- Oe.current && clearTimeout(Oe.current);
513
- const w = Y ? 300 : 0;
514
- return Oe.current = setTimeout(() => {
515
- oe([]), m(!1), fe.current = void 0, V(Y);
516
- }, w), () => {
517
- Oe.current && clearTimeout(Oe.current);
517
+ $.current && clearTimeout($.current);
518
+ const E = G ? 300 : 0;
519
+ return $.current = setTimeout(() => {
520
+ ne([]), S(!1), w.current = void 0, P(G);
521
+ }, E), () => {
522
+ $.current && clearTimeout($.current);
518
523
  };
519
- }, [Y, F, b, V, M, k]), Ee(c, t, r), c === !1)
524
+ }, [G, L, b, P, I, R]), Re(u, t, r), u === !1)
520
525
  return null;
521
526
  const se = () => {
522
- Q(""), oe([]), m(!1), q(null), fe.current = void 0, R(!0);
523
- }, X = (w) => {
524
- r(t, U ? { value: w.id, label: w.name } : w.id), $(w), xe.current = { value: w.id, label: U ? w.name : void 0 }, R(!1);
525
- }, H = (w) => {
526
- w.stopPropagation(), r(t, void 0), $(void 0);
527
- }, Re = (w) => {
528
- (w.key === "Enter" || w.key === " ") && H(w);
529
- }, Le = ((pe = d == null ? void 0 : d.options) == null ? void 0 : pe.placeholder) ?? "Select an option";
530
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
531
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
527
+ Q(""), ne([]), S(!1), ie(null), w.current = void 0, O(!0);
528
+ }, H = (E) => {
529
+ r(t, z ? { value: E.id, label: E.name } : E.id), m(E), J.current = { value: E.id, label: z ? E.name : void 0 }, O(!1);
530
+ }, _ = (E) => {
531
+ E.stopPropagation(), r(t, void 0), m(void 0);
532
+ }, De = (E) => {
533
+ (E.key === "Enter" || E.key === " ") && _(E);
534
+ }, Fe = ((ye = c == null ? void 0 : c.options) == null ? void 0 : ye.placeholder) ?? "Select an option";
535
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
536
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
532
537
  n,
533
538
  " ",
534
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
539
+ l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
535
540
  ] }),
536
- /* @__PURE__ */ y("div", { ref: $e, style: { position: "relative" }, children: [
541
+ /* @__PURE__ */ y("div", { ref: q, style: { position: "relative" }, children: [
537
542
  /* @__PURE__ */ i(
538
- Ae.Root,
543
+ Oe.Root,
539
544
  {
540
545
  id: t,
541
- value: F ? Y : (ie == null ? void 0 : ie.name) ?? "",
542
- placeholder: F && (g != null && g.searchable) ? "Search..." : Le,
543
- disabled: !K,
544
- readOnly: F && !(g != null && g.searchable),
545
- style: J ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
546
- onChange: (w) => {
547
- g != null && g.searchable && (Q(w.target.value), F || se());
546
+ value: L ? G : (Te == null ? void 0 : Te.name) ?? "",
547
+ placeholder: L && (g != null && g.searchable) ? "Search..." : Fe,
548
+ disabled: !X,
549
+ readOnly: L && !(g != null && g.searchable),
550
+ style: Y ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
551
+ onChange: (E) => {
552
+ g != null && g.searchable && (Q(E.target.value), L || se());
548
553
  },
549
554
  onFocus: () => {
550
- K && !F && se();
555
+ X && !L && se();
551
556
  },
552
- onKeyDown: (w) => {
553
- w.key === "Escape" && R(!1);
557
+ onKeyDown: (E) => {
558
+ E.key === "Escape" && O(!1);
554
559
  },
555
- children: /* @__PURE__ */ i(Ae.Slot, { side: "right", children: /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
556
- v && K && /* @__PURE__ */ i(
560
+ children: /* @__PURE__ */ i(Oe.Slot, { side: "right", children: /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
561
+ v && X && /* @__PURE__ */ i(
557
562
  "span",
558
563
  {
559
564
  role: "button",
560
565
  tabIndex: 0,
561
- onMouseDown: (w) => w.preventDefault(),
562
- onClick: H,
563
- onKeyDown: Re,
566
+ onMouseDown: (E) => E.preventDefault(),
567
+ onClick: _,
568
+ onKeyDown: De,
564
569
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
565
570
  "aria-label": "Clear selection",
566
571
  children: "×"
567
572
  }
568
573
  ),
569
574
  /* @__PURE__ */ i(
570
- Lt,
575
+ Vt,
571
576
  {
572
- style: { transform: F ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
577
+ style: { transform: L ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
573
578
  }
574
579
  )
575
580
  ] }) })
576
581
  }
577
582
  ),
578
- F && /* @__PURE__ */ i(
579
- S,
583
+ L && /* @__PURE__ */ i(
584
+ k,
580
585
  {
581
586
  style: {
582
587
  position: "absolute",
@@ -590,65 +595,72 @@ const _r = {
590
595
  border: "1px solid var(--gray-a6)",
591
596
  overflow: "hidden"
592
597
  },
593
- children: B ? /* @__PURE__ */ i(S, { p: "3", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: B }) }) : /* @__PURE__ */ i(kt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(S, { p: "1", children: [
594
- C && /* @__PURE__ */ i(D, { justify: "center", p: "4", children: /* @__PURE__ */ i(Ue, {}) }),
595
- !C && re && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "red", children: re }) }),
596
- !C && !re && be.length === 0 && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: M ? "Select the related field first." : Y || b ? "No results found." : "Type to search…" }) }),
597
- be.map((w) => /* @__PURE__ */ i(
598
- S,
598
+ children: re ? /* @__PURE__ */ i(k, { p: "3", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: re }) }) : /* @__PURE__ */ i(Pt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(k, { p: "1", children: [
599
+ K && /* @__PURE__ */ i(F, { justify: "center", p: "4", children: /* @__PURE__ */ i(_e, {}) }),
600
+ !K && ge && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "red", children: ge }) }),
601
+ !K && !ge && de.length === 0 && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: I ? "Select the related field first." : G || b ? "No results found." : "Type to search…" }) }),
602
+ de.map((E) => /* @__PURE__ */ i(
603
+ k,
599
604
  {
600
605
  px: "3",
601
606
  py: "2",
602
607
  onMouseDown: (Z) => Z.preventDefault(),
603
- onClick: () => X(w),
608
+ onClick: () => H(E),
604
609
  style: {
605
610
  cursor: "pointer",
606
611
  borderRadius: "var(--radius-2)",
607
- backgroundColor: w.id === v ? "var(--accent-3)" : void 0
612
+ backgroundColor: E.id === v ? "var(--accent-3)" : void 0
608
613
  },
609
614
  className: "hover:bg-(--gray-3)",
610
- children: /* @__PURE__ */ i(f, { size: "2", children: w.name })
615
+ children: /* @__PURE__ */ i(h, { size: "2", children: E.name })
611
616
  },
612
- w.id
617
+ E.id
613
618
  )),
614
- (g == null ? void 0 : g.paginated) && Se && !P && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(
615
- De,
619
+ (g == null ? void 0 : g.paginated) && Ne && !Ee && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(
620
+ ze,
616
621
  {
617
622
  variant: "ghost",
618
623
  size: "1",
619
624
  style: { width: "100%" },
620
- onMouseDown: (w) => w.preventDefault(),
621
- onClick: () => void V(Y, !0),
625
+ onMouseDown: (E) => E.preventDefault(),
626
+ onClick: () => void P(G, !0),
622
627
  children: "Load more"
623
628
  }
624
629
  ) }),
625
- P && /* @__PURE__ */ i(D, { justify: "center", p: "2", children: /* @__PURE__ */ i(Ue, {}) })
630
+ Ee && /* @__PURE__ */ i(F, { justify: "center", p: "2", children: /* @__PURE__ */ i(_e, {}) })
626
631
  ] }) })
627
632
  }
628
633
  )
629
634
  ] }),
630
- !J && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
631
- a.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: a.description })
635
+ !Y && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
636
+ a.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: a.description })
632
637
  ] }) });
633
- }, jr = ue(Vr), Hr = ee(
638
+ }, nn = pe(rn), on = te(
634
639
  3,
635
- Ie((e) => {
640
+ Me((e) => {
636
641
  const r = e["x-search"];
637
642
  return (e.type === "string" || e.type === "object") && typeof (r == null ? void 0 : r.service) == "string" && r.service !== "";
638
643
  })
639
- ), Wr = (e, r) => zt(`${e}T${r}`).format(), Br = ({ path: e, label: r, required: t, errors: n, description: l, children: o }) => {
644
+ ), sn = (e) => {
645
+ if (e)
646
+ return /^\d{2}:\d{2}$/.test(e) ? `${e}:00` : e;
647
+ }, wt = (e, r) => {
648
+ if (!e) return "";
649
+ const t = e.match(/^(\d{2}:\d{2})(:\d{2})?/);
650
+ return t ? r ? `${t[1]}${t[2] ?? ":00"}` : t[1] : e;
651
+ }, ln = (e, r) => Ht(`${e}T${r}`).format(), an = ({ path: e, label: r, required: t, errors: n, description: l, children: o }) => {
640
652
  const s = n.length === 0;
641
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
642
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
653
+ return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
654
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
643
655
  r,
644
656
  " ",
645
- t && /* @__PURE__ */ i(f, { color: "red", children: "*" })
657
+ t && /* @__PURE__ */ i(h, { color: "red", children: "*" })
646
658
  ] }),
647
659
  o,
648
- !s && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(n, r) }),
649
- l && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: l })
660
+ !s && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(n, r) }),
661
+ l && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: l })
650
662
  ] }) });
651
- }, Xr = ({
663
+ }, cn = ({
652
664
  data: e,
653
665
  handleChange: r,
654
666
  path: t,
@@ -656,63 +668,67 @@ const _r = {
656
668
  required: l,
657
669
  errors: o,
658
670
  schema: s,
659
- enabled: c,
660
- visible: a = !0
671
+ uischema: u,
672
+ enabled: a,
673
+ visible: c = !0
661
674
  }) => {
662
- if (de(() => {
663
- a === !1 && r(t, void 0);
664
- }, [a, t, r]), a === !1)
675
+ var I;
676
+ if (me(() => {
677
+ c === !1 && r(t, void 0);
678
+ }, [c, t, r]), c === !1)
665
679
  return null;
666
- const d = o.length === 0, u = typeof e == "string" ? e : "", h = (T) => /* @__PURE__ */ i(Br, { path: t, label: n, required: l, errors: o, description: s.description, children: T });
680
+ const d = o.length === 0, f = typeof e == "string" ? e : "", p = ((I = u == null ? void 0 : u.options) == null ? void 0 : I.showSeconds) === !0, g = p ? 1 : 60, b = (A) => /* @__PURE__ */ i(an, { path: t, label: n, required: l, errors: o, description: s.description, children: A });
667
681
  if (s.format === "time")
668
- return h(
682
+ return b(
669
683
  /* @__PURE__ */ i(
670
- Ae.Root,
684
+ Oe.Root,
671
685
  {
672
686
  type: "time",
673
- value: u,
674
- onChange: (T) => r(t, T.target.value),
675
- disabled: !c,
687
+ step: g,
688
+ value: wt(f, p),
689
+ onChange: (A) => r(t, sn(A.target.value)),
690
+ disabled: !a,
676
691
  color: d ? void 0 : "red",
677
692
  id: t
678
693
  }
679
694
  )
680
695
  );
681
- const p = s.format === "date-time", [g = "", b = ""] = u.split("T"), I = b.slice(0, 5), O = (T, A) => {
682
- if (!T) {
696
+ const M = s.format === "date-time", [N = "", U = ""] = f.split("T"), T = wt(U, p), R = (A, D) => {
697
+ if (!A) {
683
698
  r(t, void 0);
684
699
  return;
685
700
  }
686
- r(t, p ? Wr(T, A || "00:00") : T);
701
+ r(t, M ? ln(A, D || "00:00") : A);
687
702
  };
688
- return h(
689
- /* @__PURE__ */ y(D, { gap: "2", align: "center", children: [
703
+ return b(
704
+ /* @__PURE__ */ y(F, { gap: "2", align: "center", children: [
690
705
  /* @__PURE__ */ i(
691
- Ae.Root,
706
+ Oe.Root,
692
707
  {
693
708
  type: "date",
694
- value: g,
695
- disabled: !c,
709
+ value: N,
710
+ disabled: !a,
696
711
  color: d ? void 0 : "red",
697
- onChange: (T) => O(T.target.value, I),
712
+ onChange: (A) => R(A.target.value, T),
698
713
  id: t,
699
714
  style: { flex: 1 }
700
715
  }
701
716
  ),
702
- p && /* @__PURE__ */ i(
703
- Ae.Root,
717
+ M && /* @__PURE__ */ i(
718
+ Oe.Root,
704
719
  {
705
720
  type: "time",
706
- value: I,
707
- disabled: !c || !g,
721
+ step: g,
722
+ value: T,
723
+ disabled: !a || !N,
708
724
  color: d ? void 0 : "red",
709
- onChange: (T) => O(g, T.target.value),
725
+ onChange: (A) => R(N, A.target.value),
710
726
  style: { flex: 1 }
711
727
  }
712
728
  )
713
729
  ] })
714
730
  );
715
- }, Kr = ee(2, Je(nr, or, ir)), Yr = ue(Xr), Gr = ({
731
+ }, un = te(2, tt(br, vr, wr)), dn = pe(cn), fn = ({
716
732
  uischema: e,
717
733
  schema: r,
718
734
  path: t,
@@ -722,19 +738,19 @@ const _r = {
722
738
  visible: s = !0
723
739
  }) => {
724
740
  const a = e.elements;
725
- return s === !1 ? null : /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(
726
- Be,
741
+ return s === !1 ? null : /* @__PURE__ */ i(F, { direction: "column", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(
742
+ Ye,
727
743
  {
728
- uischema: d,
744
+ uischema: c,
729
745
  schema: r,
730
746
  path: t,
731
747
  renderers: n,
732
748
  cells: l,
733
749
  enabled: o
734
750
  },
735
- `${t}-${u}`
751
+ `${t}-${d}`
736
752
  )) });
737
- }, qr = ee(1, He("VerticalLayout")), Jr = ({
753
+ }, pn = te(1, Xe("VerticalLayout")), hn = ({
738
754
  uischema: e,
739
755
  schema: r,
740
756
  path: t,
@@ -744,18 +760,18 @@ const _r = {
744
760
  visible: s = !0
745
761
  }) => {
746
762
  const a = e.elements;
747
- return s === !1 ? null : /* @__PURE__ */ i(D, { direction: "row", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(S, { style: { flex: 1 }, children: /* @__PURE__ */ i(
748
- Be,
763
+ return s === !1 ? null : /* @__PURE__ */ i(F, { direction: "row", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(k, { style: { flex: 1 }, children: /* @__PURE__ */ i(
764
+ Ye,
749
765
  {
750
- uischema: d,
766
+ uischema: c,
751
767
  schema: r,
752
768
  path: t,
753
769
  renderers: n,
754
770
  cells: l,
755
771
  enabled: o
756
772
  }
757
- ) }, `${t}-${u}`)) });
758
- }, Zr = ee(1, He("HorizontalLayout")), Qr = ({
773
+ ) }, `${t}-${d}`)) });
774
+ }, mn = te(1, Xe("HorizontalLayout")), gn = ({
759
775
  uischema: e,
760
776
  schema: r,
761
777
  path: t,
@@ -764,23 +780,23 @@ const _r = {
764
780
  enabled: o,
765
781
  visible: s = !0
766
782
  }) => {
767
- const c = e, a = c.elements;
768
- return s === !1 ? null : /* @__PURE__ */ y(S, { mb: "6", children: [
769
- c.label && /* @__PURE__ */ i(It, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: c.label }),
770
- /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(
771
- Be,
783
+ const u = e, a = u.elements;
784
+ return s === !1 ? null : /* @__PURE__ */ y(k, { mb: "6", children: [
785
+ u.label && /* @__PURE__ */ i(_t, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: u.label }),
786
+ /* @__PURE__ */ i(F, { direction: "column", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(
787
+ Ye,
772
788
  {
773
- uischema: d,
789
+ uischema: c,
774
790
  schema: r,
775
791
  path: t,
776
792
  renderers: n,
777
793
  cells: l,
778
794
  enabled: o
779
795
  },
780
- `${t}-${u}`
796
+ `${t}-${d}`
781
797
  )) })
782
798
  ] });
783
- }, en = ee(1, He("Group")), tn = ({
799
+ }, yn = te(1, Xe("Group")), bn = ({
784
800
  uischema: e,
785
801
  schema: r,
786
802
  path: t,
@@ -790,29 +806,29 @@ const _r = {
790
806
  visible: s = !0
791
807
  }) => {
792
808
  var p;
793
- const a = e.elements.filter((g) => g.type === "Category"), [d, u] = j(((p = a[0]) == null ? void 0 : p.label) || "");
809
+ const a = e.elements.filter((g) => g.type === "Category"), [c, d] = j(((p = a[0]) == null ? void 0 : p.label) || "");
794
810
  if (s === !1 || !a.length) return null;
795
- const h = a.find((g) => g.label === d) ? d : a[0].label;
796
- return /* @__PURE__ */ y(Ye.Root, { value: h, onValueChange: u, children: [
797
- /* @__PURE__ */ i(Ye.List, { children: a.map((g, b) => /* @__PURE__ */ i(Ye.Trigger, { value: g.label, children: g.label }, `${t}-${b}`)) }),
798
- /* @__PURE__ */ i(S, { pt: "3", children: a.map((g, b) => /* @__PURE__ */ i(Ye.Content, { value: g.label, children: /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: g.elements.map((I, O) => /* @__PURE__ */ i(
799
- Be,
811
+ const f = a.find((g) => g.label === c) ? c : a[0].label;
812
+ return /* @__PURE__ */ y(Je.Root, { value: f, onValueChange: d, children: [
813
+ /* @__PURE__ */ i(Je.List, { children: a.map((g, b) => /* @__PURE__ */ i(Je.Trigger, { value: g.label, children: g.label }, `${t}-${b}`)) }),
814
+ /* @__PURE__ */ i(k, { pt: "3", children: a.map((g, b) => /* @__PURE__ */ i(Je.Content, { value: g.label, children: /* @__PURE__ */ i(F, { direction: "column", gap: "4", children: g.elements.map((M, N) => /* @__PURE__ */ i(
815
+ Ye,
800
816
  {
801
- uischema: I,
817
+ uischema: M,
802
818
  schema: r,
803
819
  path: t,
804
820
  renderers: n,
805
821
  cells: l,
806
822
  enabled: o
807
823
  },
808
- `${t}-${b}-${O}`
824
+ `${t}-${b}-${N}`
809
825
  )) }) }, `${t}-${b}`)) })
810
826
  ] });
811
- }, rn = ee(1, He("Categorization"));
812
- function ve(e) {
827
+ }, vn = te(1, Xe("Categorization"));
828
+ function xe(e) {
813
829
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
814
830
  }
815
- function we(e) {
831
+ function Ae(e) {
816
832
  const r = e.split(",").map((o) => o.trim()).filter(Boolean), t = r.filter((o) => o.startsWith(".")), l = (t.length > 0 ? t : r).map((o) => {
817
833
  if (o.endsWith("/*")) return o.split("/")[0].toUpperCase() + "S";
818
834
  if (o.startsWith(".")) return o.slice(1).toUpperCase();
@@ -821,10 +837,50 @@ function we(e) {
821
837
  });
822
838
  return [...new Set(l)].join(", ");
823
839
  }
824
- function nn(e) {
840
+ const wn = "image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";
841
+ function Yt(e, r) {
842
+ return r.split(",").map((n) => n.trim()).filter(Boolean).some((n) => n === "*" || n === "*/*" ? !0 : n.endsWith("/*") ? (e.type ?? "").startsWith(n.slice(0, -1)) : n.startsWith(".") ? e.name.toLowerCase().endsWith(n.toLowerCase()) : e.type === n);
843
+ }
844
+ function En(e) {
845
+ const r = !!e.type, t = it(e.name) !== void 0;
846
+ return !r && !t ? !0 : Yt(e, wn);
847
+ }
848
+ function it(e) {
849
+ const r = e.split(/[/\\]/).pop() ?? e, t = r.lastIndexOf(".");
850
+ if (!(t <= 0 || t === r.length - 1))
851
+ return r.slice(t);
852
+ }
853
+ function Tn(e, r, t) {
854
+ Kt(new Blob([e], { type: t }), r);
855
+ }
856
+ function Kt(e, r) {
857
+ const t = URL.createObjectURL(e), n = document.createElement("a");
858
+ n.href = t, n.download = r, n.click(), setTimeout(() => URL.revokeObjectURL(t), 0);
859
+ }
860
+ async function xn(e, r) {
861
+ const t = await fetch(e);
862
+ if (!t.ok) throw new Error(`Download failed (${t.status})`);
863
+ Kt(await t.blob(), r);
864
+ }
865
+ function An(e, r, t) {
866
+ const n = t.name || t.key;
867
+ if (!e) return n;
868
+ const l = ft(e, r, n), o = it(t.name ?? "") ?? it(t.key);
869
+ return !o || l.toLowerCase().endsWith(o.toLowerCase()) ? l : `${l}${o}`;
870
+ }
871
+ const Rn = /* @__PURE__ */ new Set(["/", "\\", "<", ">", ":", '"', "|", "?", "*"]), Cn = (e) => Rn.has(e) || e.charCodeAt(0) < 32 || e.charCodeAt(0) === 127;
872
+ function Sn(e, r) {
873
+ const t = Array.from(e, (n) => Cn(n) ? "_" : n).join("").trim();
874
+ return t === "" || t.startsWith(".") ? r : t;
875
+ }
876
+ function ft(e, r, t) {
877
+ const n = r !== null && typeof r == "object" && !Array.isArray(r) ? r : {};
878
+ return Sn(rt(e, n), t);
879
+ }
880
+ function On(e) {
825
881
  return e ? Array.isArray(e) ? e : [e] : [];
826
882
  }
827
- const on = ({
883
+ const Nn = ({
828
884
  data: e,
829
885
  handleChange: r,
830
886
  path: t,
@@ -832,184 +888,248 @@ const on = ({
832
888
  required: l,
833
889
  uischema: o,
834
890
  schema: s,
835
- enabled: c,
891
+ enabled: u,
836
892
  errors: a,
837
- visible: d = !0
893
+ visible: c = !0
838
894
  }) => {
839
- const u = br();
840
- Ee(d, t, r);
841
- const h = !a || a.length === 0, p = (s == null ? void 0 : s["x-file"]) ?? {}, g = (o == null ? void 0 : o.options) ?? {}, b = p.maxFiles ?? g.maxFiles ?? 1, I = p.maxSize ?? g.maxSize ?? 5 * 1024 * 1024, O = p.accept ?? g.accept ?? "image/*,application/pdf", T = b > 1, A = c !== !1, [k, M] = j(!1), [L, N] = j(null), [U, z] = j({}), v = ae(/* @__PURE__ */ new Set()), E = ae(null), B = nn(e), K = B.length >= b;
842
- de(() => () => {
843
- v.current.forEach((m) => URL.revokeObjectURL(m)), v.current.clear();
895
+ const d = Lr();
896
+ Re(c, t, r);
897
+ const f = !a || a.length === 0, p = (s == null ? void 0 : s["x-file"]) ?? {}, g = (o == null ? void 0 : o.options) ?? {}, b = p.maxFiles ?? g.maxFiles ?? 1, M = p.maxSize ?? g.maxSize ?? 5 * 1024 * 1024, N = p.accept ?? g.accept ?? "image/*,application/pdf", U = typeof p.fileName == "string" ? p.fileName : void 0, T = b > 1, R = u !== !1, [I, A] = j(!1), [D, z] = j(null), [V, v] = j({}), [x, re] = j({}), X = ue(/* @__PURE__ */ new Set()), Y = ue(null), L = On(e), O = L.length >= b, G = (m) => {
898
+ const w = x[m];
899
+ return { name: (w == null ? void 0 : w.name) ?? m, type: w == null ? void 0 : w.type };
900
+ }, Q = async (m) => {
901
+ var B, q;
902
+ const w = (B = x[m]) == null ? void 0 : B.blobUrl;
903
+ if (w) return w;
904
+ const $ = await ((q = d == null ? void 0 : d.getDownloadUrl) == null ? void 0 : q.call(d, m));
905
+ return $ == null ? void 0 : $.url;
906
+ }, de = (m, w) => {
907
+ v(($) => ({ ...$, [m]: w }));
908
+ }, ne = (m) => {
909
+ v((w) => {
910
+ if (!w[m]) return w;
911
+ const $ = { ...w };
912
+ return delete $[m], $;
913
+ });
914
+ };
915
+ me(() => () => {
916
+ X.current.forEach((m) => URL.revokeObjectURL(m)), X.current.clear();
844
917
  }, []);
845
- const J = Fe(
918
+ const Ne = $e(
846
919
  async (m) => {
847
- if (N(null), B.length >= b) {
848
- N(`Maximum ${b} file${b > 1 ? "s" : ""} allowed.`);
920
+ if (z(null), L.length >= b) {
921
+ z(`Maximum ${b} file${b > 1 ? "s" : ""} allowed.`);
849
922
  return;
850
923
  }
851
- if (m.size > I) {
852
- N(`File exceeds the ${ve(I)} limit.`);
924
+ if (m.size > M) {
925
+ z(`File exceeds the ${xe(M)} limit.`);
853
926
  return;
854
927
  }
855
- if (!O.split(",").map((P) => P.trim()).some((P) => P === "*" || P === "*/*" ? !0 : P.endsWith("/*") ? m.type.startsWith(P.slice(0, -1)) : P.startsWith(".") ? m.name.toLowerCase().endsWith(P.toLowerCase()) : m.type === P)) {
856
- N(`Invalid type. Accepted: ${we(O)}`);
928
+ if (!Yt(m, N)) {
929
+ z(`Invalid type. Accepted: ${Ae(N)}`);
857
930
  return;
858
931
  }
859
- if (!(u != null && u.onUpload)) {
860
- N("Upload service not configured.");
932
+ if (!(d != null && d.onUpload)) {
933
+ z("Upload service not configured.");
861
934
  return;
862
935
  }
863
936
  try {
864
- const P = await u.onUpload(m), _ = URL.createObjectURL(m);
865
- v.current.add(_);
866
- const re = { key: P.key, name: P.name ?? m.name, blobUrl: _ };
867
- z((ie) => ({ ...ie, [P.key]: re }));
868
- const q = [...B, P.key];
937
+ const w = await d.onUpload(m), $ = URL.createObjectURL(m);
938
+ X.current.add($);
939
+ const B = {
940
+ key: w.key,
941
+ name: w.name ?? m.name,
942
+ type: m.type || void 0,
943
+ blobUrl: $
944
+ };
945
+ re((J) => ({ ...J, [w.key]: B }));
946
+ const q = [...L, w.key];
869
947
  r(t, T ? q : q[0]);
870
948
  } catch {
871
- N("Upload failed. Please try again."), E.current && (E.current.value = "");
949
+ z("Upload failed. Please try again."), Y.current && (Y.current.value = "");
872
950
  }
873
951
  },
874
- [B, b, I, O, u, t, r, T]
952
+ [L, b, M, N, d, t, r, T]
875
953
  );
876
- if (d === !1)
954
+ if (c === !1)
877
955
  return null;
878
- const F = (m) => {
879
- m.preventDefault(), m.stopPropagation(), !(!A || K) && M(m.type === "dragenter" || m.type === "dragover");
880
- }, R = (m) => {
881
- var C;
882
- m.preventDefault(), m.stopPropagation(), M(!1), !(!A || K) && (C = m.dataTransfer.files) != null && C[0] && J(m.dataTransfer.files[0]);
883
- }, Y = (m) => {
884
- var C;
885
- (C = m.target.files) != null && C[0] && (J(m.target.files[0]), m.target.value = "");
886
- }, Q = (m) => {
887
- if (!A) return;
888
- z((G) => {
889
- var re;
890
- const P = { ...G }, _ = (re = P[m]) == null ? void 0 : re.blobUrl;
891
- return _ && (URL.revokeObjectURL(_), v.current.delete(_)), delete P[m], P;
892
- });
893
- const C = B.filter((G) => G !== m);
894
- r(t, T ? C.length > 0 ? C : void 0 : C[0]);
895
- }, be = async (m, C) => {
896
- var _, re, q;
897
- m.preventDefault();
898
- const G = (_ = U[C]) == null ? void 0 : _.blobUrl;
899
- if (G) {
900
- (re = window.open(G, "_blank", "noopener,noreferrer")) == null || re.focus();
956
+ const S = (m) => {
957
+ m.preventDefault(), m.stopPropagation(), !(!R || O) && A(m.type === "dragenter" || m.type === "dragover");
958
+ }, K = (m) => {
959
+ var w;
960
+ m.preventDefault(), m.stopPropagation(), A(!1), !(!R || O) && (w = m.dataTransfer.files) != null && w[0] && Ne(m.dataTransfer.files[0]);
961
+ }, fe = (m) => {
962
+ var w;
963
+ (w = m.target.files) != null && w[0] && (Ne(m.target.files[0]), m.target.value = "");
964
+ }, Ee = (m) => {
965
+ if (!R) return;
966
+ re(($) => {
967
+ var J;
968
+ const B = { ...$ }, q = (J = B[m]) == null ? void 0 : J.blobUrl;
969
+ return q && (URL.revokeObjectURL(q), X.current.delete(q)), delete B[m], B;
970
+ }), ne(m);
971
+ const w = L.filter(($) => $ !== m);
972
+ r(t, T ? w.length > 0 ? w : void 0 : w[0]);
973
+ }, ee = async (m, w) => {
974
+ var q, J;
975
+ m.preventDefault(), ne(w);
976
+ const $ = (q = x[w]) == null ? void 0 : q.blobUrl;
977
+ if ($) {
978
+ (J = window.open($, "_blank", "noopener,noreferrer")) == null || J.focus();
901
979
  return;
902
980
  }
903
- const P = window.open("", "_blank");
904
- if (P)
981
+ const B = window.open("", "_blank");
982
+ if (B)
905
983
  try {
906
- const ie = await ((q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : q.call(u, C));
907
- ie != null && ie.url ? P.location.href = ie.url : P.close();
984
+ const C = await Q(w);
985
+ C ? B.location.href = C : (B.close(), de(w, "Unable to open file."));
908
986
  } catch {
909
- P.close();
987
+ B.close(), de(w, "Unable to open file.");
988
+ }
989
+ }, ge = async (m, w) => {
990
+ ne(m);
991
+ try {
992
+ const $ = await Q(m);
993
+ if (!$) {
994
+ de(m, "Unable to download file.");
995
+ return;
910
996
  }
997
+ await xn($, w);
998
+ } catch {
999
+ de(m, "Unable to download file.");
1000
+ }
911
1001
  };
912
- if (!A && B.length === 0) return null;
913
- const oe = b - B.length, Se = A && !K;
914
- return /* @__PURE__ */ y(S, { mb: "4", children: [
915
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
916
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
1002
+ if (!R && L.length === 0) return null;
1003
+ const ie = b - L.length, Te = R && !O;
1004
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
1005
+ /* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
1006
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
917
1007
  n,
918
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
1008
+ l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
919
1009
  ] }),
920
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: T ? `Up to ${b} files · ${ve(I)} each · ${we(O)}` : `${ve(I)} · ${we(O)}` })
1010
+ /* @__PURE__ */ i(h, { size: "1", color: "gray", children: T ? `Up to ${b} files · ${xe(M)} each · ${Ae(N)}` : `${xe(M)} · ${Ae(N)}` })
921
1011
  ] }),
922
- B.map((m) => {
923
- var C;
924
- return /* @__PURE__ */ i(Dt, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ y(D, { align: "center", gap: "3", children: [
925
- /* @__PURE__ */ i(
926
- S,
927
- {
928
- style: {
929
- background: "var(--blue-3)",
930
- padding: 8,
931
- borderRadius: 6,
932
- color: "var(--blue-9)",
933
- flexShrink: 0
934
- },
935
- children: /* @__PURE__ */ i(hr, { width: "20", height: "20" })
936
- }
937
- ),
938
- /* @__PURE__ */ i(S, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ i(
939
- f,
940
- {
941
- size: "2",
942
- weight: "bold",
943
- style: {
944
- display: "block",
945
- overflow: "hidden",
946
- textOverflow: "ellipsis",
947
- whiteSpace: "nowrap"
948
- },
949
- children: ((C = U[m]) == null ? void 0 : C.name) ?? "Uploaded File"
950
- }
951
- ) }),
952
- /* @__PURE__ */ y(D, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
953
- /* @__PURE__ */ i(De, { variant: "soft", color: "blue", size: "1", onClick: (G) => be(G, m), children: "View" }),
954
- /* @__PURE__ */ i(mr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
955
- A && /* @__PURE__ */ i(je, { variant: "ghost", color: "gray", onClick: () => Q(m), children: /* @__PURE__ */ i(rt, {}) })
956
- ] })
957
- ] }) }, m);
1012
+ L.map((m, w) => {
1013
+ var H;
1014
+ const $ = w + 1, B = (H = x[m]) == null ? void 0 : H.name, q = An(U, { index: $ }, { name: B, key: m }), J = U ? q : B ?? "Uploaded File", C = !!(U && B), P = V[m], se = En(G(m));
1015
+ return /* @__PURE__ */ y(jt, { size: "2", variant: "surface", mb: "2", children: [
1016
+ /* @__PURE__ */ y(F, { align: "center", gap: "3", children: [
1017
+ /* @__PURE__ */ i(
1018
+ k,
1019
+ {
1020
+ style: {
1021
+ background: "var(--blue-3)",
1022
+ padding: 8,
1023
+ borderRadius: 6,
1024
+ color: "var(--blue-9)",
1025
+ flexShrink: 0
1026
+ },
1027
+ children: /* @__PURE__ */ i(Nr, { width: "20", height: "20" })
1028
+ }
1029
+ ),
1030
+ /* @__PURE__ */ y(k, { style: { flex: 1, overflow: "hidden" }, children: [
1031
+ /* @__PURE__ */ i(
1032
+ h,
1033
+ {
1034
+ size: "2",
1035
+ weight: "bold",
1036
+ style: {
1037
+ display: "block",
1038
+ overflow: "hidden",
1039
+ textOverflow: "ellipsis",
1040
+ whiteSpace: "nowrap"
1041
+ },
1042
+ children: J
1043
+ }
1044
+ ),
1045
+ C && /* @__PURE__ */ i(
1046
+ h,
1047
+ {
1048
+ size: "1",
1049
+ color: "gray",
1050
+ style: {
1051
+ display: "block",
1052
+ overflow: "hidden",
1053
+ textOverflow: "ellipsis",
1054
+ whiteSpace: "nowrap"
1055
+ },
1056
+ children: B
1057
+ }
1058
+ )
1059
+ ] }),
1060
+ /* @__PURE__ */ y(F, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
1061
+ se && /* @__PURE__ */ i(ze, { variant: "soft", color: "blue", size: "1", onClick: (_) => void ee(_, m), children: "View" }),
1062
+ /* @__PURE__ */ i(Be, { content: "Download", children: /* @__PURE__ */ i(
1063
+ je,
1064
+ {
1065
+ variant: "ghost",
1066
+ color: "gray",
1067
+ "aria-label": "Download",
1068
+ onClick: () => void ge(m, q),
1069
+ children: /* @__PURE__ */ i(at, {})
1070
+ }
1071
+ ) }),
1072
+ /* @__PURE__ */ i(Dr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
1073
+ R && /* @__PURE__ */ i(je, { variant: "ghost", color: "gray", onClick: () => Ee(m), children: /* @__PURE__ */ i(ct, {}) })
1074
+ ] })
1075
+ ] }),
1076
+ P && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: P })
1077
+ ] }, m);
958
1078
  }),
959
- Se && /* @__PURE__ */ y(
1079
+ Te && /* @__PURE__ */ y(
960
1080
  "div",
961
1081
  {
962
1082
  role: "button",
963
1083
  tabIndex: 0,
964
1084
  onClick: () => {
965
1085
  var m;
966
- return (m = E.current) == null ? void 0 : m.click();
1086
+ return (m = Y.current) == null ? void 0 : m.click();
967
1087
  },
968
1088
  onKeyDown: (m) => {
969
- var C;
970
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), (C = E.current) == null || C.click());
1089
+ var w;
1090
+ (m.key === "Enter" || m.key === " ") && (m.preventDefault(), (w = Y.current) == null || w.click());
971
1091
  },
972
- onDragEnter: F,
973
- onDragLeave: F,
974
- onDragOver: F,
975
- onDrop: R,
1092
+ onDragEnter: S,
1093
+ onDragLeave: S,
1094
+ onDragOver: S,
1095
+ onDrop: K,
976
1096
  style: { cursor: "pointer" },
977
1097
  className: [
978
1098
  "border-2 border-dashed rounded-lg p-6 text-center",
979
1099
  "transition-all duration-200 ease-in-out",
980
- k ? "border-blue-500 bg-blue-50" : L ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1100
+ I ? "border-blue-500 bg-blue-50" : D ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
981
1101
  ].join(" "),
982
1102
  children: [
983
- /* @__PURE__ */ i("input", { ref: E, type: "file", style: { display: "none" }, accept: O, onChange: Y }),
984
- /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: L ? /* @__PURE__ */ y(ge, { children: [
985
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
986
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: L }),
987
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
988
- ] }) : /* @__PURE__ */ y(ge, { children: [
989
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
990
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: B.length > 0 ? `Add another file (${oe} remaining)` : "Click to upload or drag and drop" }),
991
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
992
- ve(I),
1103
+ /* @__PURE__ */ i("input", { ref: Y, type: "file", style: { display: "none" }, accept: N, onChange: fe }),
1104
+ /* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: D ? /* @__PURE__ */ y(ve, { children: [
1105
+ /* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1106
+ /* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: D }),
1107
+ /* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
1108
+ ] }) : /* @__PURE__ */ y(ve, { children: [
1109
+ /* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1110
+ /* @__PURE__ */ i(h, { size: "2", weight: "medium", children: L.length > 0 ? `Add another file (${ie} remaining)` : "Click to upload or drag and drop" }),
1111
+ /* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
1112
+ xe(M),
993
1113
  " max · ",
994
- we(O)
1114
+ Ae(N)
995
1115
  ] })
996
1116
  ] }) })
997
1117
  ]
998
1118
  }
999
1119
  ),
1000
- A && K && T && /* @__PURE__ */ y(f, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
1120
+ R && O && T && /* @__PURE__ */ y(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
1001
1121
  "Maximum ",
1002
1122
  b,
1003
1123
  " files uploaded. Remove one to replace it."
1004
1124
  ] }),
1005
- !h && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
1125
+ !f && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
1006
1126
  ] });
1007
- }, sn = ue(on), ln = ee(
1127
+ }, Dn = pe(Nn), In = te(
1008
1128
  10,
1009
1129
  // high rank to beat default array renderer
1010
- Nt(
1130
+ $t(
1011
1131
  // Match both single-file (type: string) and multi-file (type: array)
1012
- Ie((e) => {
1132
+ Me((e) => {
1013
1133
  if (e.type === "string" && e.format === "file") return !0;
1014
1134
  if (e.type === "array") {
1015
1135
  const r = e.items;
@@ -1019,27 +1139,27 @@ const on = ({
1019
1139
  })
1020
1140
  )
1021
1141
  );
1022
- function $t(e, r) {
1142
+ function Gt(e, r) {
1023
1143
  return e !== !1 && r !== !0;
1024
1144
  }
1025
- class et extends Error {
1145
+ class st extends Error {
1026
1146
  }
1027
- async function cn(e, r) {
1147
+ async function kn(e, r) {
1028
1148
  const { read: t, utils: n } = await import("@e965/xlsx"), l = t(e, { type: "array", cellDates: !0 });
1029
1149
  if (l.SheetNames.length === 0)
1030
- throw new et("This file has no sheets.");
1150
+ throw new st("This file has no sheets.");
1031
1151
  const o = r ?? l.SheetNames[0], s = l.Sheets[o];
1032
1152
  if (!s)
1033
- throw new et(`This file doesn't have a sheet named "${o}".`);
1034
- const c = n.sheet_to_json(s, { header: 1, raw: !0, defval: null });
1153
+ throw new st(`This file doesn't have a sheet named "${o}".`);
1154
+ const u = n.sheet_to_json(s, { header: 1, raw: !0, defval: null });
1035
1155
  return {
1036
1156
  sheetName: o,
1037
- matrix: c,
1038
- rowCount: c.length,
1039
- colCount: Math.max(0, ...c.map((a) => a.length))
1157
+ matrix: u,
1158
+ rowCount: u.length,
1159
+ colCount: Math.max(0, ...u.map((a) => a.length))
1040
1160
  };
1041
1161
  }
1042
- function an(e) {
1162
+ function Ln(e) {
1043
1163
  let r = e + 1, t = "";
1044
1164
  for (; r > 0; ) {
1045
1165
  const n = (r - 1) % 26;
@@ -1050,11 +1170,11 @@ function an(e) {
1050
1170
  class ce extends Error {
1051
1171
  constructor(t, n) {
1052
1172
  super(n ?? t);
1053
- ut(this, "code");
1173
+ gt(this, "code");
1054
1174
  this.code = t, this.name = "FormulaError";
1055
1175
  }
1056
1176
  }
1057
- const un = [
1177
+ const Mn = [
1058
1178
  // Logical
1059
1179
  // IF is excluded here even though its native body is real, non-stub code —
1060
1180
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -1080,7 +1200,7 @@ const un = [
1080
1200
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
1081
1201
  "DATE",
1082
1202
  "TODAY"
1083
- ], dn = [
1203
+ ], zn = [
1084
1204
  "MAX",
1085
1205
  "MIN",
1086
1206
  "MAXA",
@@ -1099,7 +1219,7 @@ const un = [
1099
1219
  "COUNTA",
1100
1220
  // not present in fast-formula-parser's function table at all.
1101
1221
  "UPPER"
1102
- ], fn = ["YEAR", "MONTH", "DAY", "WEEKDAY"], pn = ["IF"], hn = [
1222
+ ], Fn = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Un = ["IF"], $n = [
1103
1223
  "CONCATENATE",
1104
1224
  "CONCAT",
1105
1225
  "LEN",
@@ -1110,24 +1230,24 @@ const un = [
1110
1230
  "MID",
1111
1231
  "FIND",
1112
1232
  "SEARCH"
1113
- ], mn = /* @__PURE__ */ new Set([
1114
- ...un,
1115
- ...dn,
1116
- ...fn,
1117
- ...hn,
1118
- ...pn
1119
- ]), gn = /"(?:[^"]|"")*"/g, ht = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1120
- function yn(e) {
1121
- const r = e.replace(gn, (n) => " ".repeat(n.length));
1122
- ht.lastIndex = 0;
1233
+ ], Pn = /* @__PURE__ */ new Set([
1234
+ ...Mn,
1235
+ ...zn,
1236
+ ...Fn,
1237
+ ...$n,
1238
+ ...Un
1239
+ ]), _n = /"(?:[^"]|"")*"/g, Et = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1240
+ function jn(e) {
1241
+ const r = e.replace(_n, (n) => " ".repeat(n.length));
1242
+ Et.lastIndex = 0;
1123
1243
  let t;
1124
- for (; (t = ht.exec(r)) !== null; ) {
1244
+ for (; (t = Et.exec(r)) !== null; ) {
1125
1245
  const n = t[1].toUpperCase();
1126
- if (!mn.has(n))
1246
+ if (!Pn.has(n))
1127
1247
  throw new ce("NAME", `Function ${n} is not allowed.`);
1128
1248
  }
1129
1249
  }
1130
- function bn(e, r, t) {
1250
+ function Vn(e, r, t) {
1131
1251
  let n = e;
1132
1252
  if (n == null) throw t.NA;
1133
1253
  if (typeof n == "object" && !(n instanceof t) && (n = r.retrieveRef(n)), n instanceof t) throw n;
@@ -1135,54 +1255,54 @@ function bn(e, r, t) {
1135
1255
  if (typeof n == "number") return n !== 0;
1136
1256
  throw t.VALUE;
1137
1257
  }
1138
- function _t(e) {
1258
+ function qt(e) {
1139
1259
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
1140
1260
  }
1141
- function Ne(e) {
1142
- const r = _t(e);
1261
+ function Le(e) {
1262
+ const r = qt(e);
1143
1263
  return Array.isArray(r) ? r.flat(1 / 0) : [r];
1144
1264
  }
1145
1265
  function W(e) {
1146
- const r = _t(e);
1266
+ const r = qt(e);
1147
1267
  return Array.isArray(r) ? r.flat(1 / 0)[0] : r;
1148
1268
  }
1149
- function Ge(e) {
1269
+ function Ze(e) {
1150
1270
  return e === void 0 ? void 0 : W(e);
1151
1271
  }
1152
- function le(e) {
1272
+ function ae(e) {
1153
1273
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
1154
1274
  }
1155
- function vn(e, r) {
1275
+ function Hn(e, r) {
1156
1276
  return e instanceof r ? e : new r(e.message || "#ERROR!");
1157
1277
  }
1158
- function te(e) {
1278
+ function oe(e) {
1159
1279
  return e.find((r) => r instanceof Error);
1160
1280
  }
1161
- function wn(e, r) {
1281
+ function Wn(e, r) {
1162
1282
  const t = (o) => {
1163
- throw vn(o, r);
1164
- }, n = (o, { checkArgsForErrors: s = !0 } = {}) => (...c) => {
1165
- const a = c.flatMap(Ne);
1283
+ throw Hn(o, r);
1284
+ }, n = (o, { checkArgsForErrors: s = !0 } = {}) => (...u) => {
1285
+ const a = u.flatMap(Le);
1166
1286
  if (s) {
1167
- const u = te(a);
1168
- u && t(u);
1287
+ const d = oe(a);
1288
+ d && t(d);
1169
1289
  }
1170
- const d = o(...a);
1290
+ const c = o(...a);
1291
+ return c instanceof Error ? t(c) : c;
1292
+ }, l = (o, { toText: s = !1 } = {}) => (u) => {
1293
+ const a = W(u), c = oe([a]);
1294
+ c && t(c);
1295
+ const d = o(s ? ae(a) : a);
1171
1296
  return d instanceof Error ? t(d) : d;
1172
- }, l = (o, { toText: s = !1 } = {}) => (c) => {
1173
- const a = W(c), d = te([a]);
1174
- d && t(d);
1175
- const u = o(s ? le(a) : a);
1176
- return u instanceof Error ? t(u) : u;
1177
1297
  };
1178
1298
  return {
1179
1299
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
1180
1300
  // dereferenced or type-checked here) — that's what makes
1181
1301
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
1182
- IF: (o, s, c, a) => {
1183
- const d = bn(s, o, r);
1184
- if (c == null) throw r.NA;
1185
- return d ? c : a ?? !1;
1302
+ IF: (o, s, u, a) => {
1303
+ const c = Vn(s, o, r);
1304
+ if (u == null) throw r.NA;
1305
+ return c ? u : a ?? !1;
1186
1306
  },
1187
1307
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1188
1308
  // and formulajs's own convention for MAX/MIN.
@@ -1197,28 +1317,28 @@ function wn(e, r) {
1197
1317
  // the other aggregates use.
1198
1318
  COUNTA: n(e.COUNTA, { checkArgsForErrors: !1 }),
1199
1319
  LARGE: (o, s) => {
1200
- const c = Ne(o), a = W(s), d = te([...c, a]);
1201
- d && t(d);
1202
- const u = e.LARGE(c, a);
1203
- return u instanceof Error ? t(u) : u;
1320
+ const u = Le(o), a = W(s), c = oe([...u, a]);
1321
+ c && t(c);
1322
+ const d = e.LARGE(u, a);
1323
+ return d instanceof Error ? t(d) : d;
1204
1324
  },
1205
1325
  SMALL: (o, s) => {
1206
- const c = Ne(o), a = W(s), d = te([...c, a]);
1207
- d && t(d);
1208
- const u = e.SMALL(c, a);
1209
- return u instanceof Error ? t(u) : u;
1326
+ const u = Le(o), a = W(s), c = oe([...u, a]);
1327
+ c && t(c);
1328
+ const d = e.SMALL(u, a);
1329
+ return d instanceof Error ? t(d) : d;
1210
1330
  },
1211
1331
  PERMUT: (o, s) => {
1212
- const c = [W(o), W(s)], a = te(c);
1332
+ const u = [W(o), W(s)], a = oe(u);
1213
1333
  a && t(a);
1214
- const d = e.PERMUT(c[0], c[1]);
1215
- return d instanceof Error ? t(d) : d;
1334
+ const c = e.PERMUT(u[0], u[1]);
1335
+ return c instanceof Error ? t(c) : c;
1216
1336
  },
1217
1337
  PERMUTATIONA: (o, s) => {
1218
- const c = [W(o), W(s)], a = te(c);
1338
+ const u = [W(o), W(s)], a = oe(u);
1219
1339
  a && t(a);
1220
- const d = e.PERMUTATIONA(c[0], c[1]);
1221
- return d instanceof Error ? t(d) : d;
1340
+ const c = e.PERMUTATIONA(u[0], u[1]);
1341
+ return c instanceof Error ? t(c) : c;
1222
1342
  },
1223
1343
  // match_type is intentionally ignored and forced to 0 (exact match)
1224
1344
  // regardless of what the formula author supplied — approximate/sorted
@@ -1227,29 +1347,29 @@ function wn(e, r) {
1227
1347
  // real-world data. Same scope decision as the hand-rolled engine this
1228
1348
  // replaces, carried forward deliberately rather than dropped.
1229
1349
  MATCH: (o, s) => {
1230
- const c = W(o), a = Ne(s), d = te([c, ...a]);
1231
- d && t(d);
1232
- const u = e.MATCH(c, a, 0);
1233
- return u instanceof Error ? t(u) : u;
1350
+ const u = W(o), a = Le(s), c = oe([u, ...a]);
1351
+ c && t(c);
1352
+ const d = e.MATCH(u, a, 0);
1353
+ return d instanceof Error ? t(d) : d;
1234
1354
  },
1235
1355
  SWITCH: (...o) => {
1236
- const s = o.map(W), c = te(s);
1237
- c && t(c);
1356
+ const s = o.map(W), u = oe(s);
1357
+ u && t(u);
1238
1358
  const a = e.SWITCH(...s);
1239
1359
  return a instanceof Error ? t(a) : a;
1240
1360
  },
1241
- SUBSTITUTE: (o, s, c, a) => {
1242
- const d = [le(W(o)), le(W(s)), le(W(c))];
1243
- a !== void 0 && d.push(W(a));
1244
- const u = te(d);
1245
- u && t(u);
1246
- const h = e.SUBSTITUTE(...d);
1247
- return h instanceof Error ? t(h) : h;
1361
+ SUBSTITUTE: (o, s, u, a) => {
1362
+ const c = [ae(W(o)), ae(W(s)), ae(W(u))];
1363
+ a !== void 0 && c.push(W(a));
1364
+ const d = oe(c);
1365
+ d && t(d);
1366
+ const f = e.SUBSTITUTE(...c);
1367
+ return f instanceof Error ? t(f) : f;
1248
1368
  },
1249
- TEXTJOIN: (o, s, ...c) => {
1250
- const a = le(W(o)), d = W(s), u = c.flatMap(Ne).map(le), h = te([a, d]);
1251
- h && t(h);
1252
- const p = e.TEXTJOIN(a, d, u);
1369
+ TEXTJOIN: (o, s, ...u) => {
1370
+ const a = ae(W(o)), c = W(s), d = u.flatMap(Le).map(ae), f = oe([a, c]);
1371
+ f && t(f);
1372
+ const p = e.TEXTJOIN(a, c, d);
1253
1373
  return p instanceof Error ? t(p) : p;
1254
1374
  },
1255
1375
  UPPER: l(e.UPPER),
@@ -1259,10 +1379,10 @@ function wn(e, r) {
1259
1379
  MONTH: l(e.MONTH),
1260
1380
  DAY: l(e.DAY),
1261
1381
  WEEKDAY: (o, s) => {
1262
- const c = W(o), a = W(s), d = te([c]);
1263
- d && t(d);
1264
- const u = e.WEEKDAY(c, a);
1265
- return u instanceof Error ? t(u) : u;
1382
+ const u = W(o), a = W(s), c = oe([u]);
1383
+ c && t(c);
1384
+ const d = e.WEEKDAY(u, a);
1385
+ return d instanceof Error ? t(d) : d;
1266
1386
  },
1267
1387
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1268
1388
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1274,53 +1394,53 @@ function wn(e, r) {
1274
1394
  // separator, matching Excel's own range-argument behavior — the native
1275
1395
  // implementation instead inserts stray commas for a whole-range argument.
1276
1396
  CONCATENATE: (...o) => {
1277
- const s = o.flatMap(Ne), c = te(s);
1278
- c && t(c);
1279
- const a = e.CONCATENATE(...s.map(le));
1397
+ const s = o.flatMap(Le), u = oe(s);
1398
+ u && t(u);
1399
+ const a = e.CONCATENATE(...s.map(ae));
1280
1400
  return a instanceof Error ? t(a) : a;
1281
1401
  },
1282
1402
  CONCAT: (...o) => {
1283
- const s = o.flatMap(Ne), c = te(s);
1284
- c && t(c);
1285
- const a = e.CONCAT(...s.map(le));
1403
+ const s = o.flatMap(Le), u = oe(s);
1404
+ u && t(u);
1405
+ const a = e.CONCAT(...s.map(ae));
1286
1406
  return a instanceof Error ? t(a) : a;
1287
1407
  },
1288
1408
  LEN: l(e.LEN, { toText: !0 }),
1289
1409
  TRIM: l(e.TRIM, { toText: !0 }),
1290
1410
  LOWER: l(e.LOWER, { toText: !0 }),
1291
1411
  LEFT: (o, s) => {
1292
- const c = W(o), a = Ge(s), d = te([c]);
1293
- d && t(d);
1294
- const u = e.LEFT(le(c), a);
1295
- return u instanceof Error ? t(u) : u;
1412
+ const u = W(o), a = Ze(s), c = oe([u]);
1413
+ c && t(c);
1414
+ const d = e.LEFT(ae(u), a);
1415
+ return d instanceof Error ? t(d) : d;
1296
1416
  },
1297
1417
  RIGHT: (o, s) => {
1298
- const c = W(o), a = Ge(s), d = te([c]);
1299
- d && t(d);
1300
- const u = e.RIGHT(le(c), a);
1301
- return u instanceof Error ? t(u) : u;
1418
+ const u = W(o), a = Ze(s), c = oe([u]);
1419
+ c && t(c);
1420
+ const d = e.RIGHT(ae(u), a);
1421
+ return d instanceof Error ? t(d) : d;
1302
1422
  },
1303
- MID: (o, s, c) => {
1304
- const a = W(o), d = W(s), u = W(c), h = te([a, d, u]);
1305
- h && t(h);
1306
- const p = e.MID(le(a), d, u);
1423
+ MID: (o, s, u) => {
1424
+ const a = W(o), c = W(s), d = W(u), f = oe([a, c, d]);
1425
+ f && t(f);
1426
+ const p = e.MID(ae(a), c, d);
1307
1427
  return p instanceof Error ? t(p) : p;
1308
1428
  },
1309
- FIND: (o, s, c) => {
1310
- const a = W(o), d = W(s), u = Ge(c), h = te([a, d]);
1311
- h && t(h);
1312
- const p = e.FIND(le(a), le(d), u);
1429
+ FIND: (o, s, u) => {
1430
+ const a = W(o), c = W(s), d = Ze(u), f = oe([a, c]);
1431
+ f && t(f);
1432
+ const p = e.FIND(ae(a), ae(c), d);
1313
1433
  return p instanceof Error ? t(p) : p;
1314
1434
  },
1315
- SEARCH: (o, s, c) => {
1316
- const a = W(o), d = W(s), u = Ge(c), h = te([a, d]);
1317
- h && t(h);
1318
- const p = e.SEARCH(le(a), le(d), u);
1435
+ SEARCH: (o, s, u) => {
1436
+ const a = W(o), c = W(s), d = Ze(u), f = oe([a, c]);
1437
+ f && t(f);
1438
+ const p = e.SEARCH(ae(a), ae(c), d);
1319
1439
  return p instanceof Error ? t(p) : p;
1320
1440
  }
1321
1441
  };
1322
1442
  }
1323
- const En = {
1443
+ const Bn = {
1324
1444
  "#REF!": "REF",
1325
1445
  "#VALUE!": "VALUE",
1326
1446
  "#DIV/0!": "DIV0",
@@ -1329,21 +1449,21 @@ const En = {
1329
1449
  "#NUM!": "NUM",
1330
1450
  "#NULL!": "NULL"
1331
1451
  };
1332
- function mt(e) {
1333
- return En[e.error] ?? "ERROR";
1452
+ function Tt(e) {
1453
+ return Bn[e.error] ?? "ERROR";
1334
1454
  }
1335
- function gt(e, r) {
1455
+ function xt(e, r) {
1336
1456
  if (e instanceof ce) return e;
1337
1457
  if (e instanceof r) {
1338
1458
  const t = e.details;
1339
- return t instanceof ce ? t : t instanceof r ? new ce(mt(t), t.message) : new ce(mt(e), e.message);
1459
+ return t instanceof ce ? t : t instanceof r ? new ce(Tt(t), t.message) : new ce(Tt(e), e.message);
1340
1460
  }
1341
1461
  return new ce("ERROR", e instanceof Error ? e.message : void 0);
1342
1462
  }
1343
- function Tn(e) {
1463
+ function Xn(e) {
1344
1464
  return Math.max(0, ...e.map((r) => (r == null ? void 0 : r.length) ?? 0));
1345
1465
  }
1346
- function An(e) {
1466
+ function Yn(e) {
1347
1467
  return (r) => {
1348
1468
  const t = e[r.row - 1];
1349
1469
  if (r.row < 1 || r.col < 1 || t == null || r.col - 1 >= t.length)
@@ -1352,69 +1472,69 @@ function An(e) {
1352
1472
  return n == null || n === "" ? null : n;
1353
1473
  };
1354
1474
  }
1355
- function xn(e) {
1475
+ function Kn(e) {
1356
1476
  return (r) => {
1357
- const t = Math.min(r.from.row, r.to.row), n = Math.min(r.from.col, r.to.col), l = Math.max(r.from.row, r.to.row), o = Math.max(r.from.col, r.to.col), s = Tn(e);
1477
+ const t = Math.min(r.from.row, r.to.row), n = Math.min(r.from.col, r.to.col), l = Math.max(r.from.row, r.to.row), o = Math.max(r.from.col, r.to.col), s = Xn(e);
1358
1478
  if (t > e.length || n > s)
1359
1479
  throw new ce("REF");
1360
- const c = Math.min(l, e.length), a = [];
1361
- for (let d = t; d <= c; d++) {
1362
- const u = e[d - 1], h = [];
1363
- if (u != null) {
1364
- const p = Math.min(o, u.length);
1480
+ const u = Math.min(l, e.length), a = [];
1481
+ for (let c = t; c <= u; c++) {
1482
+ const d = e[c - 1], f = [];
1483
+ if (d != null) {
1484
+ const p = Math.min(o, d.length);
1365
1485
  for (let g = n; g <= p; g++) {
1366
- const b = u[g - 1];
1367
- h.push(b == null || b === "" ? null : b);
1486
+ const b = d[g - 1];
1487
+ f.push(b == null || b === "" ? null : b);
1368
1488
  }
1369
1489
  }
1370
- a.push(h);
1490
+ a.push(f);
1371
1491
  }
1372
1492
  return a;
1373
1493
  };
1374
1494
  }
1375
- function Rn(e) {
1495
+ function Gn(e) {
1376
1496
  if (e == null || e === "") return null;
1377
1497
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1378
1498
  return e;
1379
1499
  throw new ce("VALUE");
1380
1500
  }
1381
- async function Vt(e, r) {
1501
+ async function Jt(e, r) {
1382
1502
  if (typeof e != "string") throw new ce("ERROR");
1383
1503
  const t = e.trim();
1384
1504
  if (t === "") throw new ce("ERROR");
1385
1505
  const n = t.startsWith("=") ? t.slice(1) : t;
1386
- yn(n);
1506
+ jn(n);
1387
1507
  const [l, o] = await Promise.all([
1388
1508
  import("fast-formula-parser"),
1389
1509
  import("@formulajs/formulajs")
1390
- ]), s = l.default ?? l, c = s.FormulaError, a = new s({
1510
+ ]), s = l.default ?? l, u = s.FormulaError, a = new s({
1391
1511
  ...r,
1392
1512
  // 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.
1393
- functions: wn(o, c)
1513
+ functions: Wn(o, u)
1394
1514
  });
1395
- let d;
1515
+ let c;
1396
1516
  try {
1397
- d = a.parse(n, { row: 1, col: 1, sheet: "Sheet1" });
1398
- } catch (u) {
1399
- throw gt(u, c);
1517
+ c = a.parse(n, { row: 1, col: 1, sheet: "Sheet1" });
1518
+ } catch (d) {
1519
+ throw xt(d, u);
1400
1520
  }
1401
- if (d instanceof c)
1402
- throw gt(d, c);
1403
- return Rn(d);
1521
+ if (c instanceof u)
1522
+ throw xt(c, u);
1523
+ return Gn(c);
1404
1524
  }
1405
- async function Cn(e, r) {
1406
- return Vt(r, { onCell: An(e), onRange: xn(e) });
1525
+ async function qn(e, r) {
1526
+ return Jt(r, { onCell: Yn(e), onRange: Kn(e) });
1407
1527
  }
1408
- const yt = -1;
1409
- async function jt(e, r) {
1528
+ const At = -1;
1529
+ async function Zt(e, r) {
1410
1530
  const t = Object.keys(e);
1411
- return Vt(r, {
1531
+ return Jt(r, {
1412
1532
  onVariable: (n) => {
1413
1533
  const l = t.indexOf(n);
1414
- return l === -1 ? null : { row: yt, col: l + 1 };
1534
+ return l === -1 ? null : { row: At, col: l + 1 };
1415
1535
  },
1416
1536
  onCell: (n) => {
1417
- if (n.row === yt) return e[t[n.col - 1]] ?? null;
1537
+ if (n.row === At) return e[t[n.col - 1]] ?? null;
1418
1538
  throw new ce("REF");
1419
1539
  },
1420
1540
  onRange: () => {
@@ -1422,7 +1542,7 @@ async function jt(e, r) {
1422
1542
  }
1423
1543
  });
1424
1544
  }
1425
- const Ht = {
1545
+ const Qt = {
1426
1546
  REF: "#REF!",
1427
1547
  VALUE: "#VALUE!",
1428
1548
  DIV0: "#DIV/0!",
@@ -1432,34 +1552,34 @@ const Ht = {
1432
1552
  NUM: "#NUM!",
1433
1553
  NULL: "#NULL!"
1434
1554
  };
1435
- function st(e) {
1555
+ function pt(e) {
1436
1556
  const r = e instanceof ce ? e.code : "ERROR";
1437
- return Ht[r];
1557
+ return Qt[r];
1438
1558
  }
1439
- async function Sn(e, r) {
1559
+ async function Jn(e, r) {
1440
1560
  return e.length === 0 ? r.map((t) => ({
1441
1561
  id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
1442
1562
  label: (t == null ? void 0 : t.label) ?? "(unknown)",
1443
1563
  value: null,
1444
- error: Ht.ERROR
1564
+ error: Qt.ERROR
1445
1565
  })) : Promise.all(
1446
1566
  r.map(async (t) => {
1447
1567
  try {
1448
1568
  if (!t || typeof t.label != "string" || typeof t.expression != "string" || typeof t.id != "string")
1449
1569
  throw new ce("ERROR");
1450
- return { id: t.id, label: t.label, value: await Cn(e, t.expression) };
1570
+ return { id: t.id, label: t.label, value: await qn(e, t.expression) };
1451
1571
  } catch (n) {
1452
1572
  return {
1453
1573
  id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
1454
1574
  label: (t == null ? void 0 : t.label) ?? "(unknown)",
1455
1575
  value: null,
1456
- error: st(n)
1576
+ error: pt(n)
1457
1577
  };
1458
1578
  }
1459
1579
  })
1460
1580
  );
1461
1581
  }
1462
- function bt(e) {
1582
+ function Rt(e) {
1463
1583
  const r = /* @__PURE__ */ new Set();
1464
1584
  for (const { id: t } of e) {
1465
1585
  if (r.has(t)) return t;
@@ -1467,7 +1587,7 @@ function bt(e) {
1467
1587
  }
1468
1588
  return null;
1469
1589
  }
1470
- function Wt(e) {
1590
+ function er(e) {
1471
1591
  const { columnHeader: r, rowHeader: t, columns: n, rows: l } = e;
1472
1592
  if (n !== void 0 && !Array.isArray(n))
1473
1593
  return "columns must be an array of { id, label } objects.";
@@ -1477,89 +1597,89 @@ function Wt(e) {
1477
1597
  return "columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1478
1598
  if (l !== void 0 && l.length === 0)
1479
1599
  return "rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1480
- const o = (u) => !!u && typeof u.id == "string" && u.id !== "" && typeof u.label == "string" && u.label !== "", s = n == null ? void 0 : n.findIndex((u) => !o(u));
1600
+ const o = (d) => !!d && typeof d.id == "string" && d.id !== "" && typeof d.label == "string" && d.label !== "", s = n == null ? void 0 : n.findIndex((d) => !o(d));
1481
1601
  if (s != null && s !== -1)
1482
1602
  return `columns[${s}] must be a { id, label } object with non-empty string fields.`;
1483
- const c = l == null ? void 0 : l.findIndex((u) => !o(u));
1484
- if (c != null && c !== -1)
1485
- return `rows[${c}] must be a { id, label } object with non-empty string fields.`;
1486
- const a = !!n && n.length > 0, d = !!l && l.length > 0;
1603
+ const u = l == null ? void 0 : l.findIndex((d) => !o(d));
1604
+ if (u != null && u !== -1)
1605
+ return `rows[${u}] must be a { id, label } object with non-empty string fields.`;
1606
+ const a = !!n && n.length > 0, c = !!l && l.length > 0;
1487
1607
  if (a) {
1488
- const u = bt(n);
1489
- if (u) return `duplicate column id "${u}" — every declared column id must be unique.`;
1608
+ const d = Rt(n);
1609
+ if (d) return `duplicate column id "${d}" — every declared column id must be unique.`;
1490
1610
  }
1491
- if (d) {
1492
- const u = bt(l);
1493
- if (u) return `duplicate row id "${u}" — every declared row id must be unique.`;
1611
+ if (c) {
1612
+ const d = Rt(l);
1613
+ if (d) return `duplicate row id "${d}" — every declared row id must be unique.`;
1494
1614
  }
1495
- return r && t ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : a && d ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : r && !a ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : t && !d ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1615
+ return r && t ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : a && c ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : r && !a ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : t && !c ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1496
1616
  }
1497
- function vt(e, r = {}) {
1498
- const t = Wt(r);
1617
+ function Ct(e, r = {}) {
1618
+ const t = er(r);
1499
1619
  if (t) throw new Error(`x-spreadsheet: ${t}`);
1500
1620
  const { columnHeader: n, rowHeader: l, columns: o, rows: s } = r;
1501
- return o && o.length > 0 ? On(e, o, n === !0) : s && s.length > 0 ? Nn(e, s, l === !0) : e;
1621
+ return o && o.length > 0 ? Zn(e, o, n === !0) : s && s.length > 0 ? Qn(e, s, l === !0) : e;
1502
1622
  }
1503
- function On(e, r, t) {
1623
+ function Zn(e, r, t) {
1504
1624
  return (t ? e.slice(1) : e).map((l) => {
1505
1625
  const o = /* @__PURE__ */ Object.create(null);
1506
- return r.forEach((s, c) => {
1507
- o[s.id] = l[c] ?? null;
1626
+ return r.forEach((s, u) => {
1627
+ o[s.id] = l[u] ?? null;
1508
1628
  }), o;
1509
1629
  });
1510
1630
  }
1511
- function Nn(e, r, t) {
1631
+ function Qn(e, r, t) {
1512
1632
  const n = t ? 1 : 0, l = Math.max(0, ...e.map((s) => s.length)), o = Math.max(0, l - n);
1513
- return Array.from({ length: o }, (s, c) => {
1514
- const a = n + c, d = /* @__PURE__ */ Object.create(null);
1515
- return r.forEach((u, h) => {
1633
+ return Array.from({ length: o }, (s, u) => {
1634
+ const a = n + u, c = /* @__PURE__ */ Object.create(null);
1635
+ return r.forEach((d, f) => {
1516
1636
  var p;
1517
- d[u.id] = ((p = e[h]) == null ? void 0 : p[a]) ?? null;
1518
- }), d;
1637
+ c[d.id] = ((p = e[f]) == null ? void 0 : p[a]) ?? null;
1638
+ }), c;
1519
1639
  });
1520
1640
  }
1521
- function Bt(e) {
1641
+ function tr(e) {
1522
1642
  return !Array.isArray(e[0]);
1523
1643
  }
1524
- function kn(e) {
1644
+ function eo(e) {
1525
1645
  const r = /* @__PURE__ */ Object.create(null);
1526
1646
  for (const { id: t, label: n, value: l, error: o } of e)
1527
1647
  r[t] = o === void 0 ? { label: n, value: l } : { label: n, value: l, error: o };
1528
1648
  return r;
1529
1649
  }
1530
- function tt(e, r) {
1650
+ function lt(e, r) {
1531
1651
  const t = (n) => n instanceof Date ? n.toISOString() : n ?? null;
1532
1652
  return t(e) === t(r);
1533
1653
  }
1534
- function In(e, r) {
1654
+ function to(e, r) {
1535
1655
  const t = e ?? {}, n = r ?? {}, l = Object.keys(t);
1536
1656
  return l.length !== Object.keys(n).length ? !1 : l.every((o) => {
1537
1657
  if (!Object.prototype.hasOwnProperty.call(n, o)) return !1;
1538
- const s = t[o], c = n[o];
1539
- return s.label === c.label && s.error === c.error && tt(s.value, c.value);
1658
+ const s = t[o], u = n[o];
1659
+ return s.label === u.label && s.error === u.error && lt(s.value, u.value);
1540
1660
  });
1541
1661
  }
1542
- function Dn(e, r) {
1662
+ function ro(e, r) {
1543
1663
  if (e == null || r == null) return e === r;
1544
1664
  const t = Array.isArray(e);
1545
1665
  if (t !== Array.isArray(r)) return !1;
1546
1666
  if (t) {
1547
- const s = e, c = r;
1548
- return s.length === c.length && s.every((a, d) => tt(a, c[d]));
1667
+ const s = e, u = r;
1668
+ return s.length === u.length && s.every((a, c) => lt(a, u[c]));
1549
1669
  }
1550
1670
  const n = e, l = r, o = Object.keys(n);
1551
- return o.length !== Object.keys(l).length ? !1 : o.every((s) => Object.prototype.hasOwnProperty.call(l, s) && tt(n[s], l[s]));
1671
+ return o.length !== Object.keys(l).length ? !1 : o.every((s) => Object.prototype.hasOwnProperty.call(l, s) && lt(n[s], l[s]));
1552
1672
  }
1553
- function Ln(e, r) {
1673
+ function no(e, r) {
1554
1674
  if (e === r) return !0;
1555
1675
  if (e == null || r == null) return !1;
1556
1676
  const t = e, n = r;
1557
- return t.length !== n.length ? !1 : t.every((l, o) => Dn(l, n[o]));
1677
+ return t.length !== n.length ? !1 : t.every((l, o) => ro(l, n[o]));
1558
1678
  }
1559
- function Mn(e) {
1679
+ function oo(e) {
1560
1680
  return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
1561
1681
  }
1562
- function Xt(e, r) {
1682
+ function rr(e, r) {
1563
1683
  if (e.length === 0) return [];
1564
1684
  const t = [], n = /* @__PURE__ */ new Set();
1565
1685
  for (const o of r ?? [])
@@ -1571,21 +1691,21 @@ function Xt(e, r) {
1571
1691
  const l = e.map(
1572
1692
  (o) => t.map((s) => {
1573
1693
  if (!Object.prototype.hasOwnProperty.call(o, s)) return null;
1574
- const c = o[s];
1575
- return Mn(c) ? c : null;
1694
+ const u = o[s];
1695
+ return oo(u) ? u : null;
1576
1696
  })
1577
1697
  );
1578
1698
  return [t, ...l];
1579
1699
  }
1580
- function zn(e) {
1700
+ function io(e) {
1581
1701
  const r = Math.max(0, ...e.map((t) => t.length));
1582
1702
  return Array.from({ length: r }, (t, n) => e.map((l) => l[n] ?? null));
1583
1703
  }
1584
- const Fn = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Un = 10 * 1024 * 1024, Qe = 200, Pn = 50, $n = [];
1585
- function wt(e) {
1704
+ const so = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", lo = 10 * 1024 * 1024, ot = 200, ao = 50, co = [];
1705
+ function St(e) {
1586
1706
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1587
1707
  }
1588
- const _n = ({
1708
+ const uo = ({
1589
1709
  data: e,
1590
1710
  handleChange: r,
1591
1711
  path: t,
@@ -1593,34 +1713,34 @@ const _n = ({
1593
1713
  required: l,
1594
1714
  schema: o,
1595
1715
  enabled: s,
1596
- readonly: c,
1716
+ readonly: u,
1597
1717
  errors: a,
1598
- visible: d = !0
1718
+ visible: c = !0
1599
1719
  }) => {
1600
- Ee(d, t, r);
1601
- const u = !a || a.length === 0, h = $t(s, c), p = (o == null ? void 0 : o["x-spreadsheet"]) ?? {}, g = (o == null ? void 0 : o["x-evaluate"]) ?? $n, b = p.accept ?? Fn, I = p.maxSize ?? Un, O = p.columnHeader === !0, T = p.rowHeader === !0, A = p.columns, k = p.rows, M = Array.isArray(A) && A.length > 0, L = Array.isArray(k) && k.length > 0, N = Wt({ columnHeader: O, rowHeader: T, columns: A, rows: k }), U = p.showSheet !== !1, z = p.sheetName, v = p.persistSheet !== !1, E = e ?? null, [B, K] = j(
1602
- () => E != null && E.sheet || Object.keys((E == null ? void 0 : E.derivations) ?? {}).length > 0 ? "ready" : "empty"
1603
- ), [J, F] = j(null), [R, Y] = j(!1), [Q, be] = j(null), [oe, Se] = j(null), m = ae(null), C = ae(null), G = (E == null ? void 0 : E.sheet) ?? null, P = Fe(
1604
- (x) => {
1605
- if (!Bt(x)) return x;
1606
- const V = L ? k : M ? A : void 0, se = Xt(
1607
- x,
1608
- V == null ? void 0 : V.map((X) => X.id)
1720
+ Re(c, t, r);
1721
+ const d = !a || a.length === 0, f = Gt(s, u), p = (o == null ? void 0 : o["x-spreadsheet"]) ?? {}, g = (o == null ? void 0 : o["x-evaluate"]) ?? co, b = p.accept ?? so, M = p.maxSize ?? lo, N = p.columnHeader === !0, U = p.rowHeader === !0, T = p.columns, R = p.rows, I = Array.isArray(T) && T.length > 0, A = Array.isArray(R) && R.length > 0, D = er({ columnHeader: N, rowHeader: U, columns: T, rows: R }), z = p.showSheet !== !1, V = p.sheetName, v = p.persistSheet !== !1, x = e ?? null, [re, X] = j(
1722
+ () => x != null && x.sheet || Object.keys((x == null ? void 0 : x.derivations) ?? {}).length > 0 ? "ready" : "empty"
1723
+ ), [Y, L] = j(null), [O, G] = j(!1), [Q, de] = j(null), [ne, Ne] = j(null), S = ue(null), K = ue(null), fe = (x == null ? void 0 : x.sheet) ?? null, Ee = $e(
1724
+ (C) => {
1725
+ if (!tr(C)) return C;
1726
+ const P = A ? R : I ? T : void 0, se = rr(
1727
+ C,
1728
+ P == null ? void 0 : P.map((H) => H.id)
1609
1729
  );
1610
- return L ? zn(se) : se;
1730
+ return A ? io(se) : se;
1611
1731
  },
1612
- [M, L, A, k]
1613
- ), _ = _e(() => Q ?? (G ? P(G) : null), [Q, G, P]), re = ((oe == null ? void 0 : oe.matrix) === _ ? oe.derivations : null) ?? (E == null ? void 0 : E.derivations) ?? {}, q = _ != null || E != null, ie = _e(() => {
1614
- const x = M ? 1 : 0, V = L ? 1 : 0, se = _ ? _.slice(x) : [], X = se.slice(0, Qe), H = Math.min(
1615
- Pn,
1616
- Math.max(0, ...X.map((pe) => Math.max(0, pe.length - V)))
1617
- ), Re = Array.from({ length: H }, (pe, w) => w + V), Le = "", Xe = L && !M;
1618
- return /* @__PURE__ */ i(ge, { children: _ && U && /* @__PURE__ */ y(S, { mt: "3", children: [
1619
- /* @__PURE__ */ i(S, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ y(Te.Root, { variant: "surface", size: "1", children: [
1620
- !Xe && /* @__PURE__ */ i(Te.Header, { children: /* @__PURE__ */ y(Te.Row, { children: [
1621
- /* @__PURE__ */ i(Te.ColumnHeaderCell, { children: Le }),
1622
- Re.map((pe) => {
1623
- var w;
1732
+ [I, A, T, R]
1733
+ ), ee = We(() => Q ?? (fe ? Ee(fe) : null), [Q, fe, Ee]), ge = ((ne == null ? void 0 : ne.matrix) === ee ? ne.derivations : null) ?? (x == null ? void 0 : x.derivations) ?? {}, ie = ee != null || x != null, Te = We(() => {
1734
+ const C = I ? 1 : 0, P = A ? 1 : 0, se = ee ? ee.slice(C) : [], H = se.slice(0, ot), _ = Math.min(
1735
+ ao,
1736
+ Math.max(0, ...H.map((ye) => Math.max(0, ye.length - P)))
1737
+ ), De = Array.from({ length: _ }, (ye, E) => E + P), Fe = "", Ke = A && !I;
1738
+ return /* @__PURE__ */ i(ve, { children: ee && z && /* @__PURE__ */ y(k, { mt: "3", children: [
1739
+ /* @__PURE__ */ i(k, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ y(Se.Root, { variant: "surface", size: "1", children: [
1740
+ !Ke && /* @__PURE__ */ i(Se.Header, { children: /* @__PURE__ */ y(Se.Row, { children: [
1741
+ /* @__PURE__ */ i(Se.ColumnHeaderCell, { children: Fe }),
1742
+ De.map((ye) => {
1743
+ var E;
1624
1744
  return (
1625
1745
  // This row only renders when hasRows isn't the sole
1626
1746
  // flag set (see suppressColumnHeaderRow) — so reaching
@@ -1628,227 +1748,227 @@ const _n = ({
1628
1748
  // looked up positionally — never read from the matrix
1629
1749
  // cell itself, which only ever holds the id) or both
1630
1750
  // are false (columnLetter fallback).
1631
- /* @__PURE__ */ i(Te.ColumnHeaderCell, { children: M ? ((w = A == null ? void 0 : A[pe]) == null ? void 0 : w.label) ?? "" : an(pe) }, pe)
1751
+ /* @__PURE__ */ i(Se.ColumnHeaderCell, { children: I ? ((E = T == null ? void 0 : T[ye]) == null ? void 0 : E.label) ?? "" : Ln(ye) }, ye)
1632
1752
  );
1633
1753
  })
1634
1754
  ] }) }),
1635
- /* @__PURE__ */ i(Te.Body, { children: X.map((pe, w) => {
1636
- var ne;
1637
- const Z = x + w;
1638
- return /* @__PURE__ */ y(Te.Row, { children: [
1755
+ /* @__PURE__ */ i(Se.Body, { children: H.map((ye, E) => {
1756
+ var le;
1757
+ const Z = C + E;
1758
+ return /* @__PURE__ */ y(Se.Row, { children: [
1639
1759
  /* @__PURE__ */ i(
1640
- Te.RowHeaderCell,
1760
+ Se.RowHeaderCell,
1641
1761
  {
1642
- style: L ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1643
- children: L ? ((ne = k == null ? void 0 : k[Z]) == null ? void 0 : ne.label) ?? "" : M ? "" : Z + 1
1762
+ style: A ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1763
+ children: A ? ((le = R == null ? void 0 : R[Z]) == null ? void 0 : le.label) ?? "" : I ? "" : Z + 1
1644
1764
  }
1645
1765
  ),
1646
- Re.map((he) => /* @__PURE__ */ i(Te.Cell, { children: wt(pe[he]) }, he))
1647
- ] }, w);
1766
+ De.map((be) => /* @__PURE__ */ i(Se.Cell, { children: St(ye[be]) }, be))
1767
+ ] }, E);
1648
1768
  }) })
1649
1769
  ] }) }),
1650
- se.length > Qe && /* @__PURE__ */ y(f, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1770
+ se.length > ot && /* @__PURE__ */ y(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1651
1771
  "Showing first ",
1652
- Qe,
1772
+ ot,
1653
1773
  " of ",
1654
1774
  se.length,
1655
1775
  " rows"
1656
1776
  ] })
1657
1777
  ] }) });
1658
- }, [_, U, M, L, A, k]), $ = Fe(
1659
- async (x) => {
1660
- if (F(null), x.size > I) {
1661
- F(`File exceeds the ${ve(I)} limit.`);
1778
+ }, [ee, z, I, A, T, R]), m = $e(
1779
+ async (C) => {
1780
+ if (L(null), C.size > M) {
1781
+ L(`File exceeds the ${xe(M)} limit.`);
1662
1782
  return;
1663
1783
  }
1664
- if (!b.split(",").map((H) => H.trim()).some((H) => H === "*" || H === "*/*" ? !0 : H.endsWith("/*") ? x.type.startsWith(H.slice(0, -1)) : H.startsWith(".") ? x.name.toLowerCase().endsWith(H.toLowerCase()) : x.type === H)) {
1665
- F(`Invalid type. Accepted: ${we(b)}`);
1784
+ if (!b.split(",").map((_) => _.trim()).some((_) => _ === "*" || _ === "*/*" ? !0 : _.endsWith("/*") ? C.type.startsWith(_.slice(0, -1)) : _.startsWith(".") ? C.name.toLowerCase().endsWith(_.toLowerCase()) : C.type === _)) {
1785
+ L(`Invalid type. Accepted: ${Ae(b)}`);
1666
1786
  return;
1667
1787
  }
1668
- K("parsing");
1669
- let X;
1788
+ X("parsing");
1789
+ let H;
1670
1790
  try {
1671
- const H = await x.arrayBuffer();
1672
- X = (await cn(H, z)).matrix;
1673
- } catch (H) {
1674
- K("error"), F(
1675
- H instanceof et ? H.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1791
+ const _ = await C.arrayBuffer();
1792
+ H = (await kn(_, V)).matrix;
1793
+ } catch (_) {
1794
+ X("error"), L(
1795
+ _ instanceof st ? _.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1676
1796
  );
1677
1797
  return;
1678
1798
  }
1679
- if (M || L)
1799
+ if (I || A)
1680
1800
  try {
1681
- X = P(vt(X, { columnHeader: O, rowHeader: T, columns: A, rows: k }));
1682
- } catch (H) {
1683
- K("error"), F(H instanceof Error ? H.message : "Failed to process this sheet.");
1801
+ H = Ee(Ct(H, { columnHeader: N, rowHeader: U, columns: T, rows: R }));
1802
+ } catch (_) {
1803
+ X("error"), L(_ instanceof Error ? _.message : "Failed to process this sheet.");
1684
1804
  return;
1685
1805
  }
1686
- C.current = (e == null ? void 0 : e.sheet) ?? null, be(X), K("ready");
1806
+ K.current = (e == null ? void 0 : e.sheet) ?? null, de(H), X("ready");
1687
1807
  },
1688
- [b, I, z, e, O, T, A, k, M, L, P]
1808
+ [b, M, V, e, N, U, T, R, I, A, Ee]
1689
1809
  );
1690
- if (de(() => {
1691
- Q != null && G != null && G !== C.current && be(null);
1692
- }, [Q, G]), de(() => {
1693
- if (N || g.length === 0 && !v) return;
1694
- let x = !1;
1695
- const V = (X) => {
1696
- h && (In(E == null ? void 0 : E.derivations, X == null ? void 0 : X.derivations) && Ln(E == null ? void 0 : E.sheet, X == null ? void 0 : X.sheet) || (C.current = (X == null ? void 0 : X.sheet) ?? null, r(t, X)));
1697
- }, se = _ ?? [];
1810
+ if (me(() => {
1811
+ Q != null && fe != null && fe !== K.current && de(null);
1812
+ }, [Q, fe]), me(() => {
1813
+ if (D || g.length === 0 && !v) return;
1814
+ let C = !1;
1815
+ const P = (H) => {
1816
+ f && (to(x == null ? void 0 : x.derivations, H == null ? void 0 : H.derivations) && no(x == null ? void 0 : x.sheet, H == null ? void 0 : H.sheet) || (K.current = (H == null ? void 0 : H.sheet) ?? null, r(t, H)));
1817
+ }, se = ee ?? [];
1698
1818
  if (se.length === 0) {
1699
- E != null && V(void 0);
1819
+ x != null && P(void 0);
1700
1820
  return;
1701
1821
  }
1702
- return Sn(se, g).then((X) => {
1703
- if (x) return;
1704
- let H;
1822
+ return Jn(se, g).then((H) => {
1823
+ if (C) return;
1824
+ let _;
1705
1825
  if (Q != null) {
1706
1826
  if (v)
1707
1827
  try {
1708
- H = vt(se, { columnHeader: M, rowHeader: L, columns: A, rows: k });
1709
- } catch (Le) {
1710
- F(Le instanceof Error ? Le.message : "Failed to process this sheet.");
1828
+ _ = Ct(se, { columnHeader: I, rowHeader: A, columns: T, rows: R });
1829
+ } catch (Fe) {
1830
+ L(Fe instanceof Error ? Fe.message : "Failed to process this sheet.");
1711
1831
  return;
1712
1832
  }
1713
1833
  } else
1714
- H = E == null ? void 0 : E.sheet;
1715
- F(null);
1716
- const Re = kn(X);
1717
- Se({ matrix: se, derivations: Re }), V(H === void 0 ? { derivations: Re } : { sheet: H, derivations: Re });
1834
+ _ = x == null ? void 0 : x.sheet;
1835
+ L(null);
1836
+ const De = eo(H);
1837
+ Ne({ matrix: se, derivations: De }), P(_ === void 0 ? { derivations: De } : { sheet: _, derivations: De });
1718
1838
  }), () => {
1719
- x = !0;
1839
+ C = !0;
1720
1840
  };
1721
- }, [_, Q, g, h, v, M, L, A, k, N]), d === !1)
1841
+ }, [ee, Q, g, f, v, I, A, T, R, D]), c === !1)
1722
1842
  return null;
1723
- if (N)
1724
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1725
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: n }),
1726
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
1843
+ if (D)
1844
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
1845
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: n }),
1846
+ /* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
1727
1847
  "Invalid x-spreadsheet config: ",
1728
- N
1848
+ D
1729
1849
  ] })
1730
1850
  ] });
1731
- if (!h && !q) return null;
1732
- const fe = (x) => {
1733
- x.preventDefault(), x.stopPropagation(), h && Y(x.type === "dragenter" || x.type === "dragover");
1734
- }, Oe = (x) => {
1735
- var V;
1736
- x.preventDefault(), x.stopPropagation(), Y(!1), h && (V = x.dataTransfer.files) != null && V[0] && $(x.dataTransfer.files[0]);
1737
- }, Pe = (x) => {
1738
- var V;
1739
- (V = x.target.files) != null && V[0] && ($(x.target.files[0]), x.target.value = "");
1740
- }, $e = () => {
1741
- h && (be(null), Se(null), C.current = null, F(null), K("empty"), r(t, void 0));
1742
- }, xe = U && _ == null && E != null;
1743
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1744
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
1745
- /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
1746
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
1851
+ if (!f && !ie) return null;
1852
+ const w = (C) => {
1853
+ C.preventDefault(), C.stopPropagation(), f && G(C.type === "dragenter" || C.type === "dragover");
1854
+ }, $ = (C) => {
1855
+ var P;
1856
+ C.preventDefault(), C.stopPropagation(), G(!1), f && (P = C.dataTransfer.files) != null && P[0] && m(C.dataTransfer.files[0]);
1857
+ }, B = (C) => {
1858
+ var P;
1859
+ (P = C.target.files) != null && P[0] && (m(C.target.files[0]), C.target.value = "");
1860
+ }, q = () => {
1861
+ f && (de(null), Ne(null), K.current = null, L(null), X("empty"), r(t, void 0));
1862
+ }, J = z && ee == null && x != null;
1863
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
1864
+ /* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
1865
+ /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
1866
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
1747
1867
  n,
1748
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
1868
+ l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
1749
1869
  ] }),
1750
- q && h && /* @__PURE__ */ y(ge, { children: [
1751
- /* @__PURE__ */ i(qe, { content: "Replace spreadsheet", children: /* @__PURE__ */ i(
1870
+ ie && f && /* @__PURE__ */ y(ve, { children: [
1871
+ /* @__PURE__ */ i(Be, { content: "Replace spreadsheet", children: /* @__PURE__ */ i(
1752
1872
  je,
1753
1873
  {
1754
1874
  variant: "ghost",
1755
1875
  size: "1",
1756
1876
  onClick: () => {
1757
- var x;
1758
- return (x = m.current) == null ? void 0 : x.click();
1877
+ var C;
1878
+ return (C = S.current) == null ? void 0 : C.click();
1759
1879
  },
1760
1880
  "aria-label": "Replace spreadsheet",
1761
- children: /* @__PURE__ */ i(ze, {})
1881
+ children: /* @__PURE__ */ i(Ue, {})
1762
1882
  }
1763
1883
  ) }),
1764
- /* @__PURE__ */ i(qe, { content: "Remove spreadsheet", children: /* @__PURE__ */ i(
1884
+ /* @__PURE__ */ i(Be, { content: "Remove spreadsheet", children: /* @__PURE__ */ i(
1765
1885
  je,
1766
1886
  {
1767
1887
  variant: "ghost",
1768
1888
  size: "1",
1769
1889
  color: "gray",
1770
- onClick: $e,
1890
+ onClick: q,
1771
1891
  "aria-label": "Remove spreadsheet",
1772
- children: /* @__PURE__ */ i(rt, {})
1892
+ children: /* @__PURE__ */ i(ct, {})
1773
1893
  }
1774
1894
  ) })
1775
1895
  ] })
1776
1896
  ] }),
1777
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
1778
- ve(I),
1897
+ /* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
1898
+ xe(M),
1779
1899
  " max · ",
1780
- we(b)
1900
+ Ae(b)
1781
1901
  ] })
1782
1902
  ] }),
1783
- q && J && /* @__PURE__ */ i(f, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: J }),
1784
- /* @__PURE__ */ i("input", { ref: m, type: "file", style: { display: "none" }, accept: b, onChange: Pe }),
1785
- h && !q && /* @__PURE__ */ i(
1903
+ ie && Y && /* @__PURE__ */ i(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: Y }),
1904
+ /* @__PURE__ */ i("input", { ref: S, type: "file", style: { display: "none" }, accept: b, onChange: B }),
1905
+ f && !ie && /* @__PURE__ */ i(
1786
1906
  "div",
1787
1907
  {
1788
1908
  role: "button",
1789
1909
  tabIndex: 0,
1790
1910
  onClick: () => {
1791
- var x;
1792
- return (x = m.current) == null ? void 0 : x.click();
1911
+ var C;
1912
+ return (C = S.current) == null ? void 0 : C.click();
1793
1913
  },
1794
- onKeyDown: (x) => {
1795
- var V;
1796
- (x.key === "Enter" || x.key === " ") && (x.preventDefault(), (V = m.current) == null || V.click());
1914
+ onKeyDown: (C) => {
1915
+ var P;
1916
+ (C.key === "Enter" || C.key === " ") && (C.preventDefault(), (P = S.current) == null || P.click());
1797
1917
  },
1798
- onDragEnter: fe,
1799
- onDragLeave: fe,
1800
- onDragOver: fe,
1801
- onDrop: Oe,
1918
+ onDragEnter: w,
1919
+ onDragLeave: w,
1920
+ onDragOver: w,
1921
+ onDrop: $,
1802
1922
  style: { cursor: "pointer" },
1803
1923
  className: [
1804
1924
  "border-2 border-dashed rounded-lg p-6 text-center",
1805
1925
  "transition-all duration-200 ease-in-out",
1806
- R ? "border-blue-500 bg-blue-50" : J ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1926
+ O ? "border-blue-500 bg-blue-50" : Y ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1807
1927
  ].join(" "),
1808
- children: /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: B === "parsing" ? /* @__PURE__ */ y(ge, { children: [
1809
- /* @__PURE__ */ i(Ue, { size: "3" }),
1810
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1811
- ] }) : J ? /* @__PURE__ */ y(ge, { children: [
1812
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1813
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: J }),
1814
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
1815
- ] }) : /* @__PURE__ */ y(ge, { children: [
1816
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1817
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1818
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
1819
- ve(I),
1928
+ children: /* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: re === "parsing" ? /* @__PURE__ */ y(ve, { children: [
1929
+ /* @__PURE__ */ i(_e, { size: "3" }),
1930
+ /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1931
+ ] }) : Y ? /* @__PURE__ */ y(ve, { children: [
1932
+ /* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1933
+ /* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: Y }),
1934
+ /* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
1935
+ ] }) : /* @__PURE__ */ y(ve, { children: [
1936
+ /* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1937
+ /* @__PURE__ */ i(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1938
+ /* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
1939
+ xe(M),
1820
1940
  " max · ",
1821
- we(b)
1941
+ Ae(b)
1822
1942
  ] })
1823
1943
  ] }) })
1824
1944
  }
1825
1945
  ),
1826
- ie,
1827
- xe && /* @__PURE__ */ i(f, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1828
- Object.keys(re).length > 0 && /* @__PURE__ */ y(S, { mt: "3", children: [
1829
- /* @__PURE__ */ i(f, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1830
- /* @__PURE__ */ i(D, { direction: "column", gap: "1", children: Object.entries(re).map(([x, V]) => /* @__PURE__ */ y(D, { justify: "between", children: [
1831
- /* @__PURE__ */ i(f, { size: "2", children: V.label }),
1832
- V.error ? /* @__PURE__ */ i(f, { size: "2", color: "red", children: V.error }) : (
1946
+ Te,
1947
+ J && /* @__PURE__ */ i(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1948
+ Object.keys(ge).length > 0 && /* @__PURE__ */ y(k, { mt: "3", children: [
1949
+ /* @__PURE__ */ i(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1950
+ /* @__PURE__ */ i(F, { direction: "column", gap: "1", children: Object.entries(ge).map(([C, P]) => /* @__PURE__ */ y(F, { justify: "between", children: [
1951
+ /* @__PURE__ */ i(h, { size: "2", children: P.label }),
1952
+ P.error ? /* @__PURE__ */ i(h, { size: "2", color: "red", children: P.error }) : (
1833
1953
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1834
1954
  // possible results anymore — INDEX/CONCATENATE can return a
1835
1955
  // string, a bare comparison can return a boolean, etc.), so
1836
1956
  // `.toLocaleString()` would throw for e.g. a boolean result.
1837
1957
  // Reuse the same formatCell used for the sheet-preview grid.
1838
- /* @__PURE__ */ i(f, { size: "2", children: wt(V.value) })
1958
+ /* @__PURE__ */ i(h, { size: "2", children: St(P.value) })
1839
1959
  )
1840
- ] }, x)) })
1960
+ ] }, C)) })
1841
1961
  ] }),
1842
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
1962
+ !d && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
1843
1963
  ] });
1844
- }, Vn = ue(_n), jn = ee(
1964
+ }, fo = pe(uo), po = te(
1845
1965
  10,
1846
1966
  // matches FileControlTester's rank — beats the default object/Group renderer
1847
- Ie(
1967
+ Me(
1848
1968
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1849
1969
  )
1850
- ), Hn = "Sheet1", Wn = "xlsx";
1851
- function Bn(e) {
1970
+ ), ho = "Sheet1", mo = "xlsx";
1971
+ function go(e) {
1852
1972
  if (e === void 0) return null;
1853
1973
  if (!Array.isArray(e)) return "columns must be an array of { id, label } objects.";
1854
1974
  if (e.length === 0)
@@ -1858,9 +1978,9 @@ function Bn(e) {
1858
1978
  );
1859
1979
  return r !== -1 ? `columns[${r}] must be a { id, label } object with non-empty string fields.` : null;
1860
1980
  }
1861
- function Xn(e, r) {
1862
- if (!Bt(e)) return e;
1863
- const t = Xt(
1981
+ function yo(e, r) {
1982
+ if (!tr(e)) return e;
1983
+ const t = rr(
1864
1984
  e,
1865
1985
  r == null ? void 0 : r.map((s) => s.id)
1866
1986
  );
@@ -1868,51 +1988,54 @@ function Xn(e, r) {
1868
1988
  const n = new Map(r.map((s) => [s.id, s.label])), [l, ...o] = t;
1869
1989
  return [l.map((s) => n.get(String(s)) ?? s), ...o];
1870
1990
  }
1871
- const Kn = ({ data: e, label: r, schema: t, visible: n = !0 }) => {
1872
- const [l, o] = j(null);
1873
- if (n === !1)
1991
+ const bo = ({ data: e, path: r, label: t, schema: n, visible: l = !0 }) => {
1992
+ const [o, s] = j(null), u = Ve();
1993
+ if (l === !1)
1874
1994
  return null;
1875
- const s = (t == null ? void 0 : t["x-spreadsheet-export"]) ?? {}, c = s.columns, a = s.sheetName ?? Hn, d = s.fileType ?? Wn, u = s.fileName ?? `export.${d}`, h = Bn(c);
1876
- if (h)
1877
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1878
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: r }),
1879
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
1995
+ const a = (n == null ? void 0 : n["x-spreadsheet-export"]) ?? {}, c = a.columns, d = a.sheetName ?? ho, f = a.fileType ?? mo, p = a.fileName ?? `export.${f}`, g = go(c);
1996
+ if (g)
1997
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
1998
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: t }),
1999
+ /* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
1880
2000
  "Invalid x-spreadsheet-export config: ",
1881
- h
2001
+ g
1882
2002
  ] })
1883
2003
  ] });
1884
- const p = Array.isArray(e) && e.length > 0, g = async () => {
1885
- if (p) {
1886
- o(null);
2004
+ const b = Array.isArray(e) && e.length > 0, M = async () => {
2005
+ var N, U;
2006
+ if (b) {
2007
+ s(null);
1887
2008
  try {
1888
- const b = await import("@e965/xlsx"), I = Xn(e, c), O = b.utils.aoa_to_sheet(I), T = b.utils.book_new();
1889
- b.utils.book_append_sheet(T, O, a), b.writeFile(T, u, { bookType: d });
1890
- } catch (b) {
1891
- o(b instanceof Error ? b.message : "Failed to build the workbook.");
2009
+ const T = await import("@e965/xlsx"), R = yo(e, c), I = T.utils.aoa_to_sheet(R), A = T.utils.book_new();
2010
+ T.utils.book_append_sheet(A, I, d);
2011
+ const D = r.split(".").slice(0, -1).join("."), z = D ? Pe.data((N = u.core) == null ? void 0 : N.data, D) : (U = u.core) == null ? void 0 : U.data;
2012
+ T.writeFile(A, ft(p, z, `export.${f}`), { bookType: f });
2013
+ } catch (T) {
2014
+ s(T instanceof Error ? T.message : "Failed to build the workbook.");
1892
2015
  }
1893
2016
  }
1894
2017
  };
1895
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1896
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
1897
- /* @__PURE__ */ y(De, { type: "button", variant: "soft", disabled: !p, onClick: () => void g(), children: [
1898
- /* @__PURE__ */ i(Mt, {}),
2018
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
2019
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: t }),
2020
+ /* @__PURE__ */ y(ze, { type: "button", variant: "soft", disabled: !b, onClick: () => void M(), children: [
2021
+ /* @__PURE__ */ i(at, {}),
1899
2022
  " Download Spreadsheet"
1900
2023
  ] }),
1901
- l && /* @__PURE__ */ i(f, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: l })
2024
+ o && /* @__PURE__ */ i(h, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: o })
1902
2025
  ] });
1903
- }, Yn = ue(Kn), Gn = ee(
2026
+ }, vo = pe(bo), wo = te(
1904
2027
  10,
1905
- Nt(
1906
- Ie((e) => {
2028
+ $t(
2029
+ Me((e) => {
1907
2030
  const r = e["x-spreadsheet-export"];
1908
2031
  return e.type === "array" && typeof r == "object" && r !== null;
1909
2032
  }),
1910
- sr(lr("editable", !0))
2033
+ Er(Tr("editable", !0))
1911
2034
  )
1912
2035
  );
1913
- class Ce extends Error {
2036
+ class Ie extends Error {
1914
2037
  }
1915
- const Et = 5e6, qn = 1024, Jn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, Zn = {
2038
+ const Ot = 5e6, Eo = 1024, To = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, xo = {
1916
2039
  // Default is true, which would silently drop what in many formats is most of
1917
2040
  // the payload.
1918
2041
  ignoreAttributes: !1,
@@ -1959,7 +2082,7 @@ const Et = 5e6, qn = 1024, Jn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["'
1959
2082
  maxNestedTags: 100,
1960
2083
  strictReservedNames: !0
1961
2084
  };
1962
- function Qn(e) {
2085
+ function Ao(e) {
1963
2086
  const r = new Set(e);
1964
2087
  return r.size === 0 ? () => !1 : (t, n) => (
1965
2088
  // A string while the library's own `jPath` option is true (the default) and
@@ -1967,137 +2090,212 @@ function Qn(e) {
1967
2090
  r.has(typeof n == "string" ? n : n.toString()) || r.has(t)
1968
2091
  );
1969
2092
  }
1970
- function eo(e) {
2093
+ function Ro(e) {
1971
2094
  const r = e instanceof Error ? e.message : "";
1972
2095
  return r.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." : r === "External entities are not supported" || r === "Parameter entities are not supported" ? `${r}. Please remove the DOCTYPE entity declarations and try again.` : r.startsWith("Maximum nested tags exceeded") ? "This document is nested too deeply to parse." : r.startsWith("Entity count") || r.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.";
1973
2096
  }
1974
- async function to(e, r = {}) {
1975
- var d;
1976
- if (typeof e != "string") throw new Ce("This file could not be read as text.");
2097
+ async function Co(e, r = {}) {
2098
+ var c;
2099
+ if (typeof e != "string") throw new Ie("This file could not be read as text.");
1977
2100
  const t = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
1978
- if (t.trim() === "") throw new Ce("This file is empty.");
1979
- if (t.length > Et)
1980
- throw new Ce(
1981
- `This document is too large to parse (over ${Et / 1e6} million characters).`
2101
+ if (t.trim() === "") throw new Ie("This file is empty.");
2102
+ if (t.length > Ot)
2103
+ throw new Ie(
2104
+ `This document is too large to parse (over ${Ot / 1e6} million characters).`
1982
2105
  );
1983
- const n = (d = Jn.exec(t.slice(0, qn))) == null ? void 0 : d[1];
2106
+ const n = (c = To.exec(t.slice(0, Eo))) == null ? void 0 : c[1];
1984
2107
  if (n && !/^utf-?8$/i.test(n))
1985
- throw new Ce(
2108
+ throw new Ie(
1986
2109
  `This document declares the unsupported encoding "${n}". Only UTF-8 is supported.`
1987
2110
  );
1988
2111
  const { XMLParser: l, XMLValidator: o } = await import("fast-xml-parser"), s = o.validate(t, { allowBooleanAttributes: !1 });
1989
2112
  if (s !== !0) {
1990
- const { msg: u, line: h, col: p } = s.err;
1991
- throw new Ce(`Invalid XML at line ${h}, column ${p}: ${u}`);
2113
+ const { msg: d, line: f, col: p } = s.err;
2114
+ throw new Ie(`Invalid XML at line ${f}, column ${p}: ${d}`);
1992
2115
  }
1993
- const c = new l({
1994
- ...Zn,
2116
+ const u = new l({
2117
+ ...xo,
1995
2118
  removeNSPrefix: r.removeNamespaces === !0,
1996
- isArray: Qn(r.arrayPaths ?? [])
2119
+ isArray: Ao(r.arrayPaths ?? [])
1997
2120
  });
1998
2121
  let a;
1999
2122
  try {
2000
- a = c.parse(t);
2001
- } catch (u) {
2002
- throw new Ce(eo(u));
2123
+ a = u.parse(t);
2124
+ } catch (d) {
2125
+ throw new Ie(Ro(d));
2003
2126
  }
2004
2127
  if (a == null || typeof a != "object" || Array.isArray(a))
2005
- throw new Ce("This document has no root element.");
2128
+ throw new Ie("This document has no root element.");
2006
2129
  return a;
2007
2130
  }
2008
- const ke = { found: !1 }, me = (e) => ({ found: !0, value: e });
2009
- function Tt(e) {
2010
- return e == null || e === "" ? ke : Array.isArray(e) || e instanceof Date ? me(e) : typeof e == "object" ? ke : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? me(e) : ke;
2131
+ function nr(e, r, t) {
2132
+ const { path: n, default: l } = typeof t == "string" ? { path: t, default: void 0 } : t, o = Pe.data(e, r ? `${r}.${n}` : n);
2133
+ return o ?? l;
2134
+ }
2135
+ function So(e, r, t) {
2136
+ const n = {};
2137
+ for (const [l, o] of Object.entries(t)) {
2138
+ const s = nr(e, r, o);
2139
+ if (s === void 0) return;
2140
+ n[l] = s;
2141
+ }
2142
+ return n;
2143
+ }
2144
+ async function Oo(e, r) {
2145
+ try {
2146
+ return { status: "ok", value: await Zt(e, r) };
2147
+ } catch (t) {
2148
+ return { status: "error", error: pt(t) };
2149
+ }
2011
2150
  }
2012
- const ro = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), no = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
2013
- async function oo(e, r) {
2151
+ function or(e, r) {
2152
+ return e == null ? "" : typeof e == "number" ? e.toFixed(No(r)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2153
+ }
2154
+ function No(e) {
2155
+ return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
2156
+ }
2157
+ const ke = { found: !1 }, he = (e) => ({ found: !0, value: e });
2158
+ function Nt(e) {
2159
+ return e == null || e === "" ? ke : Array.isArray(e) || e instanceof Date ? he(e) : typeof e == "object" ? ke : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? he(e) : ke;
2160
+ }
2161
+ const Do = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), Io = /* @__PURE__ */ new Set(["false", "0", "no", "n"]), ko = /^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;
2162
+ async function Lo(e, r, t) {
2014
2163
  switch (r.as) {
2015
2164
  case void 0:
2016
- return me(e);
2165
+ return he(e);
2017
2166
  case "string":
2018
- return me(e instanceof Date ? e.toISOString() : String(e));
2167
+ return he(e instanceof Date ? e.toISOString() : String(e));
2019
2168
  case "number": {
2020
- const t = e instanceof Date ? e.getTime() : Number(e);
2021
- return Number.isFinite(t) ? me(t) : ke;
2169
+ const n = e instanceof Date ? e.getTime() : Number(e);
2170
+ return Number.isFinite(n) ? he(r.decimals === void 0 ? n : or(n, r.decimals)) : ke;
2022
2171
  }
2023
2172
  case "boolean": {
2024
- const t = String(e).trim().toLowerCase();
2025
- return ro.has(t) ? me(!0) : no.has(t) ? me(!1) : ke;
2173
+ const n = String(e).trim().toLowerCase();
2174
+ return Do.has(n) ? he(!0) : Io.has(n) ? he(!1) : ke;
2026
2175
  }
2027
2176
  case "date": {
2028
- const { default: t } = await import("dayjs"), { default: n } = await import("./customParseFormat-D14EWdSX.js").then((s) => s.c);
2029
- t.extend(n);
2030
- const l = e instanceof Date ? e.toISOString() : String(e), o = r.format ? t(l, r.format, !0) : t(l);
2031
- return o.isValid() ? me(o.format("YYYY-MM-DD")) : ke;
2177
+ const { default: n } = await import("dayjs"), { default: l } = await import("./customParseFormat-D14EWdSX.js").then((u) => u.c);
2178
+ if (n.extend(l), t === "export") {
2179
+ const u = typeof e == "string" ? ko.exec(e) : null, a = e instanceof Date ? n(e) : u ? n(u[1], "YYYY-MM-DD", !0) : null;
2180
+ return a != null && a.isValid() ? he(a.format(r.format ?? "YYYY-MM-DD")) : ke;
2181
+ }
2182
+ const o = e instanceof Date ? e.toISOString() : String(e), s = r.format ? n(o, r.format, !0) : n(o);
2183
+ return s.isValid() ? he(s.format("YYYY-MM-DD")) : ke;
2032
2184
  }
2033
2185
  }
2034
2186
  }
2035
- async function io(e, r) {
2187
+ async function Mo(e, r) {
2036
2188
  if (r.formula !== void 0) {
2037
2189
  const t = {};
2038
2190
  for (const [n, l] of Object.entries(r.inputs ?? {})) {
2039
- const o = Tt(Ve.data(e, l));
2191
+ const o = Nt(Pe.data(e, l));
2040
2192
  if (!o.found || Array.isArray(o.value)) return ke;
2041
2193
  t[n] = o.value;
2042
2194
  }
2043
2195
  try {
2044
- return me(await jt(t, r.formula));
2196
+ return he(await Zt(t, r.formula));
2045
2197
  } catch (n) {
2046
- throw new Error(`writeTo "${r.to}": ${st(n)}`);
2198
+ throw new Error(`writeTo "${r.to}": ${pt(n)}`);
2047
2199
  }
2048
2200
  }
2049
2201
  if (r.from === void 0) throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);
2050
- return Tt(Ve.data(e, r.from));
2051
- }
2052
- function Kt(e) {
2053
- const r = {};
2054
- for (const { to: t, value: n } of e) {
2055
- const l = t.split(".").filter(Boolean);
2056
- if (l.length === 0) continue;
2057
- let o = r;
2058
- for (const s of l.slice(0, -1)) {
2059
- const c = o[s];
2060
- if (c && typeof c == "object" && !Array.isArray(c))
2061
- o = c;
2062
- else {
2063
- const a = {};
2064
- o[s] = a, o = a;
2065
- }
2202
+ return Nt(Pe.data(e, r.from));
2203
+ }
2204
+ const Qe = "@_", ir = "#text", et = (e) => e.split(".").filter(Boolean), sr = (e) => e.startsWith(Qe) || e === ir;
2205
+ function lr(e, r) {
2206
+ if (typeof e.to != "string" || et(e.to).length === 0) return '"to" must be a non-empty path.';
2207
+ if (e.format !== void 0 && e.as !== "date") return '"format" needs "as": "date".';
2208
+ if (e.decimals !== void 0) {
2209
+ if (r === "import")
2210
+ return '"decimals" only applies on export — on import it would put text in a number field.';
2211
+ if (e.as !== "number") return '"decimals" needs "as": "number".';
2212
+ const { decimals: t } = e;
2213
+ if (!Number.isInteger(t) || t < 0 || t > 100)
2214
+ return '"decimals" must be a whole number from 0 to 100.';
2215
+ }
2216
+ if (r === "export") {
2217
+ const t = et(e.to);
2218
+ for (const [n, l] of t.entries()) {
2219
+ if (l === Qe) return '"@_" needs an attribute name after it, e.g. "@_id".';
2220
+ if (sr(l) && n < t.length - 1)
2221
+ return `"${l}" must be the last segment — it belongs to the element before it.`;
2222
+ }
2223
+ }
2224
+ return null;
2225
+ }
2226
+ function Dt(e, r, t) {
2227
+ const n = t ? ` To give "${r}" both text and attributes, write its text to "${r}.${ir}".` : "";
2228
+ return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${n}`);
2229
+ }
2230
+ function ar(e) {
2231
+ const r = {}, t = /* @__PURE__ */ new Set([r]);
2232
+ for (const { to: n, value: l } of e) {
2233
+ const o = et(n);
2234
+ if (o.length === 0) continue;
2235
+ let s = r;
2236
+ for (const [c, d] of o.slice(0, -1).entries()) {
2237
+ const f = s[d];
2238
+ if (f === void 0) {
2239
+ const p = {};
2240
+ t.add(p), s[d] = p, s = p;
2241
+ } else if (t.has(f))
2242
+ s = f;
2243
+ else
2244
+ throw Dt(n, o.slice(0, c + 1).join("."), o[c + 1].startsWith(Qe));
2245
+ }
2246
+ const u = o[o.length - 1], a = s[u];
2247
+ if (t.has(a)) {
2248
+ const c = Object.keys(a).some((d) => d.startsWith(Qe));
2249
+ throw Dt(n, o.join("."), c);
2066
2250
  }
2067
- o[l[l.length - 1]] = n;
2251
+ s[u] = l;
2068
2252
  }
2069
2253
  return r;
2070
2254
  }
2071
- async function lt(e, r) {
2072
- const t = [];
2073
- for (const n of r) {
2074
- let l = await io(e, n);
2075
- const o = l.found && Array.isArray(l.value);
2076
- if (l.found && o && n.writeTo) {
2077
- const s = await Promise.all(
2078
- l.value.map(
2079
- async (c) => Kt(await lt(c, n.writeTo))
2255
+ const zo = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean";
2256
+ async function ht(e, r, t) {
2257
+ const n = [];
2258
+ for (const l of r) {
2259
+ const o = lr(l, t);
2260
+ if (o) throw new Error(`writeTo "${l.to}": ${o}`);
2261
+ const s = et(l.to), u = t === "export" && sr(s[s.length - 1]), a = (f) => {
2262
+ if (!(u && f == null)) {
2263
+ if (u && !zo(f)) {
2264
+ const p = f instanceof Date ? ' Add "as": "date" to write a date.' : "";
2265
+ throw new Error(
2266
+ `writeTo "${l.to}": an attribute or #text value must be text, a number or a boolean.${p}`
2267
+ );
2268
+ }
2269
+ n.push({ to: l.to, value: f });
2270
+ }
2271
+ };
2272
+ let c = await Mo(e, l);
2273
+ const d = c.found && Array.isArray(c.value);
2274
+ if (c.found && d && l.writeTo) {
2275
+ const f = await Promise.all(
2276
+ c.value.map(
2277
+ async (p) => ar(await ht(p, l.writeTo, t))
2080
2278
  )
2081
2279
  );
2082
- t.push({ to: n.to, value: s });
2280
+ a(f);
2083
2281
  continue;
2084
2282
  }
2085
- if (l.found && !o && n.writeTo)
2086
- throw new Error(`writeTo "${n.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);
2087
- if (l.found && !o && n.map) {
2088
- const s = l.value instanceof Date ? l.value.toISOString() : String(l.value);
2089
- Object.prototype.hasOwnProperty.call(n.map, s) && (l = me(n.map[s]));
2283
+ if (c.found && !d && l.writeTo)
2284
+ throw new Error(`writeTo "${l.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);
2285
+ if (c.found && !d && l.map) {
2286
+ const f = c.value instanceof Date ? c.value.toISOString() : String(c.value);
2287
+ Object.prototype.hasOwnProperty.call(l.map, f) && (c = he(l.map[f]));
2090
2288
  }
2091
- if (l.found && !o && (l = await oo(l.value, n)), !l.found) {
2092
- if (n.default === void 0) continue;
2093
- t.push({ to: n.to, value: n.default });
2289
+ if (c.found && !d && (c = await Lo(c.value, l, t)), !c.found) {
2290
+ if (l.default === void 0) continue;
2291
+ a(l.default);
2094
2292
  continue;
2095
2293
  }
2096
- t.push({ to: n.to, value: l.value });
2294
+ a(c.value);
2097
2295
  }
2098
- return t;
2296
+ return n;
2099
2297
  }
2100
- const so = ".xml,text/xml,application/xml", lo = 5 * 1024 * 1024, co = ({
2298
+ const Fo = ".xml,text/xml,application/xml", Uo = 5 * 1024 * 1024, $o = ({
2101
2299
  data: e,
2102
2300
  handleChange: r,
2103
2301
  path: t,
@@ -2105,347 +2303,346 @@ const so = ".xml,text/xml,application/xml", lo = 5 * 1024 * 1024, co = ({
2105
2303
  required: l,
2106
2304
  schema: o,
2107
2305
  enabled: s,
2108
- readonly: c,
2306
+ readonly: u,
2109
2307
  errors: a,
2110
- visible: d = !0
2308
+ visible: c = !0
2111
2309
  }) => {
2112
- Ee(d, t, r);
2113
- const u = !a || a.length === 0, h = $t(s, c), p = (o == null ? void 0 : o["x-xml"]) ?? {}, g = p.accept ?? so, b = p.maxSize ?? lo, I = p.arrayPaths, O = p.removeNamespaces === !0, T = p.writeTo, A = p.writeBase ?? "root", k = p.persistDocument !== !1, M = We(), L = e ?? null, [N, U] = j(() => L ? "ready" : "empty"), [z, v] = j(null), [E, B] = j(!1), K = ae(null), J = ae(0), F = L != null, R = T !== void 0 && T.length > 0, Y = Fe(
2114
- async (m) => {
2115
- var ie;
2116
- const C = ++J.current;
2117
- if (v(null), m.size > b) {
2118
- v(`File exceeds the ${ve(b)} limit.`);
2310
+ Re(c, t, r);
2311
+ const d = !a || a.length === 0, f = Gt(s, u), p = (o == null ? void 0 : o["x-xml"]) ?? {}, g = p.accept ?? Fo, b = p.maxSize ?? Uo, M = p.arrayPaths, N = p.removeNamespaces === !0, U = p.writeTo, T = p.writeBase ?? "root", R = p.persistDocument !== !1, I = Ve(), A = e ?? null, [D, z] = j(() => A ? "ready" : "empty"), [V, v] = j(null), [x, re] = j(!1), X = ue(null), Y = ue(0), L = A != null, O = U !== void 0 && U.length > 0, G = $e(
2312
+ async (S) => {
2313
+ var Te;
2314
+ const K = ++Y.current;
2315
+ if (v(null), S.size > b) {
2316
+ v(`File exceeds the ${xe(b)} limit.`);
2119
2317
  return;
2120
2318
  }
2121
- if (!g.split(",").map(($) => $.trim()).some(($) => $ === "*" || $ === "*/*" ? !0 : $.endsWith("/*") ? m.type.startsWith($.slice(0, -1)) : $.startsWith(".") ? m.name.toLowerCase().endsWith($.toLowerCase()) : m.type === $)) {
2122
- v(`Invalid type. Accepted: ${we(g)}`);
2319
+ if (!g.split(",").map((m) => m.trim()).some((m) => m === "*" || m === "*/*" ? !0 : m.endsWith("/*") ? S.type.startsWith(m.slice(0, -1)) : m.startsWith(".") ? S.name.toLowerCase().endsWith(m.toLowerCase()) : S.type === m)) {
2320
+ v(`Invalid type. Accepted: ${Ae(g)}`);
2123
2321
  return;
2124
2322
  }
2125
- U("parsing");
2126
- let _;
2323
+ z("parsing");
2324
+ let ee;
2127
2325
  try {
2128
- const $ = await m.text();
2129
- _ = await to($, { arrayPaths: I, removeNamespaces: O });
2130
- } catch ($) {
2131
- if (C !== J.current) return;
2132
- U("error"), v(
2133
- $ instanceof Ce ? $.message : "This doesn't look like a valid XML document. Please check the file and try again."
2326
+ const m = await S.text();
2327
+ ee = await Co(m, { arrayPaths: M, removeNamespaces: N });
2328
+ } catch (m) {
2329
+ if (K !== Y.current) return;
2330
+ z("error"), v(
2331
+ m instanceof Ie ? m.message : "This doesn't look like a valid XML document. Please check the file and try again."
2134
2332
  );
2135
2333
  return;
2136
2334
  }
2137
- let re = [];
2138
- if (T && T.length > 0)
2335
+ let ge = [];
2336
+ if (U && U.length > 0)
2139
2337
  try {
2140
- re = await lt(_, T);
2141
- } catch ($) {
2142
- if (C !== J.current) return;
2143
- U("error"), v($ instanceof Error ? $.message : "This document could not be mapped onto the form.");
2338
+ ge = await ht(ee, U, "import");
2339
+ } catch (m) {
2340
+ if (K !== Y.current) return;
2341
+ z("error"), v(m instanceof Error ? m.message : "This document could not be mapped onto the form.");
2144
2342
  return;
2145
2343
  }
2146
- if (C !== J.current) return;
2147
- k && r(t, _);
2148
- const q = A === "parent" ? t.split(".").slice(0, -1).join(".") : "";
2149
- for (const $ of re) (ie = M.dispatch) == null || ie.call(M, cr(q ? `${q}.${$.to}` : $.to, () => $.value));
2150
- U("ready");
2344
+ if (K !== Y.current) return;
2345
+ R && r(t, ee);
2346
+ const ie = T === "parent" ? t.split(".").slice(0, -1).join(".") : "";
2347
+ for (const m of ge) (Te = I.dispatch) == null || Te.call(I, xr(ie ? `${ie}.${m.to}` : m.to, () => m.value));
2348
+ z("ready");
2151
2349
  },
2152
- [g, b, I, O, T, A, k, t, r, M]
2350
+ [g, b, M, N, U, T, R, t, r, I]
2153
2351
  );
2154
- if (d === !1 || !h && !F) return null;
2155
- const Q = (m) => {
2156
- m.preventDefault(), m.stopPropagation(), h && B(m.type === "dragenter" || m.type === "dragover");
2157
- }, be = (m) => {
2158
- var C;
2159
- m.preventDefault(), m.stopPropagation(), B(!1), h && (C = m.dataTransfer.files) != null && C[0] && Y(m.dataTransfer.files[0]);
2160
- }, oe = (m) => {
2161
- var C;
2162
- (C = m.target.files) != null && C[0] && (Y(m.target.files[0]), m.target.value = "");
2352
+ if (c === !1 || !f && !L) return null;
2353
+ const Q = (S) => {
2354
+ S.preventDefault(), S.stopPropagation(), f && re(S.type === "dragenter" || S.type === "dragover");
2355
+ }, de = (S) => {
2356
+ var K;
2357
+ S.preventDefault(), S.stopPropagation(), re(!1), f && (K = S.dataTransfer.files) != null && K[0] && G(S.dataTransfer.files[0]);
2358
+ }, ne = (S) => {
2359
+ var K;
2360
+ (K = S.target.files) != null && K[0] && (G(S.target.files[0]), S.target.value = "");
2163
2361
  };
2164
- return /* @__PURE__ */ y(S, { mb: "4", children: [
2165
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
2166
- /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
2167
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
2362
+ return /* @__PURE__ */ y(k, { mb: "4", children: [
2363
+ /* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
2364
+ /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
2365
+ /* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
2168
2366
  n,
2169
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
2367
+ l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
2170
2368
  ] }),
2171
- !R && F && h && /* @__PURE__ */ y(ge, { children: [
2172
- /* @__PURE__ */ i(qe, { content: "Replace document", children: /* @__PURE__ */ i(
2369
+ !O && L && f && /* @__PURE__ */ y(ve, { children: [
2370
+ /* @__PURE__ */ i(Be, { content: "Replace document", children: /* @__PURE__ */ i(
2173
2371
  je,
2174
2372
  {
2175
2373
  variant: "ghost",
2176
2374
  size: "1",
2177
2375
  onClick: () => {
2178
- var m;
2179
- return (m = K.current) == null ? void 0 : m.click();
2376
+ var S;
2377
+ return (S = X.current) == null ? void 0 : S.click();
2180
2378
  },
2181
2379
  "aria-label": "Replace document",
2182
- children: /* @__PURE__ */ i(ze, {})
2380
+ children: /* @__PURE__ */ i(Ue, {})
2183
2381
  }
2184
2382
  ) }),
2185
- /* @__PURE__ */ i(qe, { content: "Remove document", children: /* @__PURE__ */ i(je, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2186
- h && (++J.current, v(null), U("empty"), r(t, void 0));
2187
- }, "aria-label": "Remove document", children: /* @__PURE__ */ i(rt, {}) }) })
2383
+ /* @__PURE__ */ i(Be, { content: "Remove document", children: /* @__PURE__ */ i(je, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2384
+ f && (++Y.current, v(null), z("empty"), r(t, void 0));
2385
+ }, "aria-label": "Remove document", children: /* @__PURE__ */ i(ct, {}) }) })
2188
2386
  ] })
2189
2387
  ] }),
2190
- /* @__PURE__ */ y(D, { align: "center", gap: "2", children: [
2191
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
2192
- ve(b),
2388
+ /* @__PURE__ */ y(F, { align: "center", gap: "2", children: [
2389
+ /* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
2390
+ xe(b),
2193
2391
  " max · ",
2194
- we(g)
2392
+ Ae(g)
2195
2393
  ] }),
2196
- R && h && /* @__PURE__ */ y(De, { size: "1", variant: "soft", onClick: () => {
2197
- var m;
2198
- return (m = K.current) == null ? void 0 : m.click();
2199
- }, disabled: N === "parsing", children: [
2200
- N === "parsing" ? /* @__PURE__ */ i(Ue, { size: "1" }) : /* @__PURE__ */ i(ze, {}),
2394
+ O && f && /* @__PURE__ */ y(ze, { size: "1", variant: "soft", onClick: () => {
2395
+ var S;
2396
+ return (S = X.current) == null ? void 0 : S.click();
2397
+ }, disabled: D === "parsing", children: [
2398
+ D === "parsing" ? /* @__PURE__ */ i(_e, { size: "1" }) : /* @__PURE__ */ i(Ue, {}),
2201
2399
  "Upload"
2202
2400
  ] })
2203
2401
  ] })
2204
2402
  ] }),
2205
- (R || F) && z && /* @__PURE__ */ i(f, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: z }),
2206
- /* @__PURE__ */ i("input", { ref: K, type: "file", style: { display: "none" }, accept: g, onChange: oe }),
2207
- !R && h && !F && /* @__PURE__ */ i(
2403
+ (O || L) && V && /* @__PURE__ */ i(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: V }),
2404
+ /* @__PURE__ */ i("input", { ref: X, type: "file", style: { display: "none" }, accept: g, onChange: ne }),
2405
+ !O && f && !L && /* @__PURE__ */ i(
2208
2406
  "div",
2209
2407
  {
2210
2408
  role: "button",
2211
2409
  tabIndex: 0,
2212
2410
  onClick: () => {
2213
- var m;
2214
- return (m = K.current) == null ? void 0 : m.click();
2411
+ var S;
2412
+ return (S = X.current) == null ? void 0 : S.click();
2215
2413
  },
2216
- onKeyDown: (m) => {
2217
- var C;
2218
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), (C = K.current) == null || C.click());
2414
+ onKeyDown: (S) => {
2415
+ var K;
2416
+ (S.key === "Enter" || S.key === " ") && (S.preventDefault(), (K = X.current) == null || K.click());
2219
2417
  },
2220
2418
  onDragEnter: Q,
2221
2419
  onDragLeave: Q,
2222
2420
  onDragOver: Q,
2223
- onDrop: be,
2421
+ onDrop: de,
2224
2422
  style: { cursor: "pointer" },
2225
2423
  className: [
2226
2424
  "border-2 border-dashed rounded-lg p-6 text-center",
2227
2425
  "transition-all duration-200 ease-in-out",
2228
- E ? "border-blue-500 bg-blue-50" : z ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2426
+ x ? "border-blue-500 bg-blue-50" : V ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2229
2427
  ].join(" "),
2230
- children: /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: N === "parsing" ? /* @__PURE__ */ y(ge, { children: [
2231
- /* @__PURE__ */ i(Ue, { size: "3" }),
2232
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Parsing document…" })
2233
- ] }) : z ? /* @__PURE__ */ y(ge, { children: [
2234
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2235
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: z }),
2236
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
2237
- ] }) : /* @__PURE__ */ y(ge, { children: [
2238
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2239
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2240
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
2241
- ve(b),
2428
+ children: /* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: D === "parsing" ? /* @__PURE__ */ y(ve, { children: [
2429
+ /* @__PURE__ */ i(_e, { size: "3" }),
2430
+ /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Parsing document…" })
2431
+ ] }) : V ? /* @__PURE__ */ y(ve, { children: [
2432
+ /* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2433
+ /* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: V }),
2434
+ /* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
2435
+ ] }) : /* @__PURE__ */ y(ve, { children: [
2436
+ /* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2437
+ /* @__PURE__ */ i(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2438
+ /* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
2439
+ xe(b),
2242
2440
  " max · ",
2243
- we(g)
2441
+ Ae(g)
2244
2442
  ] })
2245
2443
  ] }) })
2246
2444
  }
2247
2445
  ),
2248
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
2446
+ !d && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
2249
2447
  ] });
2250
- }, ao = ue(co), uo = ee(
2448
+ }, Po = pe($o), _o = te(
2251
2449
  10,
2252
- Ie((e) => {
2450
+ Me((e) => {
2253
2451
  const r = e["x-xml"];
2254
2452
  return e.type === "object" && typeof r == "object" && r !== null;
2255
2453
  })
2256
- );
2257
- function fo(e, r, t) {
2258
- const n = new Blob([e], { type: t }), l = URL.createObjectURL(n), o = document.createElement("a");
2259
- o.href = l, o.download = r, o.click(), URL.revokeObjectURL(l);
2454
+ ), jo = "root", It = "export.xml", Vo = {
2455
+ format: !0,
2456
+ indentBy: " ",
2457
+ ignoreAttributes: !1,
2458
+ attributeNamePrefix: "@_",
2459
+ textNodeName: "#text",
2460
+ suppressBooleanAttributes: !1,
2461
+ processEntities: !0
2462
+ };
2463
+ function Ho(e) {
2464
+ if (e === null || typeof e != "object" || Array.isArray(e))
2465
+ return 'declaration must be an object, e.g. { "standalone": "no" }, or {} for the defaults.';
2466
+ const { version: r, encoding: t, standalone: n, ...l } = e, [o] = Object.keys(l);
2467
+ return o ? `declaration has an unknown key "${o}" — only version, encoding and standalone.` : r !== void 0 && r !== "1.0" && r !== "1.1" ? 'declaration.version must be "1.0" or "1.1".' : t !== void 0 && t !== "UTF-8" ? 'declaration.encoding can only be "UTF-8" — the file is always written as UTF-8.' : n !== void 0 && n !== "yes" && n !== "no" ? 'declaration.standalone must be "yes" or "no".' : null;
2468
+ }
2469
+ function cr(e) {
2470
+ for (const r of e) {
2471
+ if (r === null || typeof r != "object" || Array.isArray(r))
2472
+ return "every writeTo entry must be an object.";
2473
+ const { to: t, writeTo: n } = r, l = lr(r, "export");
2474
+ if (l) return `writeTo "${t}": ${l}`;
2475
+ if (n !== void 0) {
2476
+ if (!Array.isArray(n)) return `writeTo "${t}": its nested writeTo must be an array.`;
2477
+ const o = cr(n);
2478
+ if (o) return o;
2479
+ }
2480
+ }
2481
+ return null;
2260
2482
  }
2261
- const po = "root", ho = "export.xml";
2262
- function mo(e) {
2263
- return e === void 0 ? "writeTo is required — see docs/xml-export-control.md." : Array.isArray(e) ? e.length === 0 ? "writeTo is declared but empty — declare at least one entry." : null : "writeTo must be an array of { from | formula, to } entries.";
2483
+ function Wo({ writeTo: e, declaration: r }) {
2484
+ return e === void 0 ? "writeTo is required — see docs/xml-export-control.md." : Array.isArray(e) ? e.length === 0 ? "writeTo is declared but empty — declare at least one entry." : cr(e) ?? (r === void 0 ? null : Ho(r)) : "writeTo must be an array of { from | formula, to } entries.";
2264
2485
  }
2265
- function go(e) {
2486
+ function Bo({ version: e = "1.0", standalone: r }) {
2487
+ return { "@_version": e, "@_encoding": "UTF-8", ...r && { "@_standalone": r } };
2488
+ }
2489
+ function Xo(e) {
2266
2490
  return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1;
2267
2491
  }
2268
- const yo = ({ path: e, label: r, schema: t, visible: n = !0 }) => {
2269
- var T, A;
2270
- const l = (t == null ? void 0 : t["x-xml-export"]) ?? {}, o = l.rootElement ?? po, s = l.fileName ?? ho, c = l.writeTo, a = l.writeBase ?? "root", d = mo(c), u = We(), h = a === "parent" ? e.split(".").slice(0, -1).join(".") : "", p = h ? Ve.data((T = u.core) == null ? void 0 : T.data, h) : (A = u.core) == null ? void 0 : A.data, [g, b] = j(null), I = go(p), O = Fe(async () => {
2271
- if (!c) return;
2272
- b(null);
2273
- let k;
2274
- try {
2275
- const z = await lt(p, c);
2276
- k = Kt(z);
2277
- } catch (z) {
2278
- b(z instanceof Error ? z.message : "This mapping could not be resolved.");
2279
- return;
2492
+ const Yo = ({ path: e, label: r, schema: t, visible: n = !0 }) => {
2493
+ var T, R;
2494
+ const l = (t == null ? void 0 : t["x-xml-export"]) ?? {}, o = l.rootElement ?? jo, s = l.fileName ?? It, u = l.writeTo, a = l.writeBase ?? "root", c = l.declaration, d = Wo(l), f = Ve(), p = a === "parent" ? e.split(".").slice(0, -1).join(".") : "", g = p ? Pe.data((T = f.core) == null ? void 0 : T.data, p) : (R = f.core) == null ? void 0 : R.data, [b, M] = j(null), N = Xo(g), U = $e(async () => {
2495
+ if (u) {
2496
+ M(null);
2497
+ try {
2498
+ const I = ar(await ht(g, u, "export")), { XMLBuilder: A } = await import("fast-xml-parser"), D = {
2499
+ ...c && { "?xml": Bo(c) },
2500
+ [o]: I
2501
+ }, z = new A(Vo).build(D);
2502
+ Tn(z, ft(s, g, It), "application/xml");
2503
+ } catch (I) {
2504
+ M(I instanceof Error ? I.message : "This export could not be built.");
2505
+ }
2280
2506
  }
2281
- const { XMLBuilder: M } = await import("fast-xml-parser"), L = { [o]: k }, U = new M({ format: !0, indentBy: " ", ignoreAttributes: !0 }).build(L);
2282
- fo(U, s, "application/xml");
2283
- }, [c, p, o, s]);
2284
- return n === !1 ? null : d ? /* @__PURE__ */ y(S, { mb: "4", children: [
2285
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: r }),
2286
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
2507
+ }, [u, g, c, o, s]);
2508
+ return n === !1 ? null : d ? /* @__PURE__ */ y(k, { mb: "4", children: [
2509
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: r }),
2510
+ /* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
2287
2511
  "Invalid x-xml-export config: ",
2288
2512
  d
2289
2513
  ] })
2290
- ] }) : /* @__PURE__ */ y(S, { mb: "4", children: [
2291
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
2292
- /* @__PURE__ */ y(De, { size: "1", variant: "soft", disabled: I, onClick: () => void O(), children: [
2293
- /* @__PURE__ */ i(Mt, {}),
2514
+ ] }) : /* @__PURE__ */ y(k, { mb: "4", children: [
2515
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
2516
+ /* @__PURE__ */ y(ze, { size: "1", variant: "soft", disabled: N, onClick: () => void U(), children: [
2517
+ /* @__PURE__ */ i(at, {}),
2294
2518
  "Download XML"
2295
2519
  ] }),
2296
- g && /* @__PURE__ */ i(f, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: g })
2520
+ b && /* @__PURE__ */ i(h, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: b })
2297
2521
  ] });
2298
- }, bo = ue(yo), vo = ee(
2522
+ }, Ko = pe(Yo), Go = te(
2299
2523
  10,
2300
- Ie((e) => {
2524
+ Me((e) => {
2301
2525
  const r = e["x-xml-export"];
2302
2526
  return e.type === "object" && typeof r == "object" && r !== null;
2303
2527
  })
2304
- );
2305
- function Yt(e, r, t) {
2306
- const { path: n, default: l } = typeof t == "string" ? { path: t, default: void 0 } : t, o = Ve.data(e, r ? `${r}.${n}` : n);
2307
- return o ?? l;
2308
- }
2309
- function wo(e, r, t) {
2310
- const n = {};
2311
- for (const [l, o] of Object.entries(t)) {
2312
- const s = Yt(e, r, o);
2313
- if (s === void 0) return;
2314
- n[l] = s;
2315
- }
2316
- return n;
2317
- }
2318
- async function Eo(e, r) {
2319
- try {
2320
- return { status: "ok", value: await jt(e, r) };
2321
- } catch (t) {
2322
- return { status: "error", error: st(t) };
2323
- }
2324
- }
2325
- function To(e, r) {
2326
- return e == null ? "" : typeof e == "number" ? e.toFixed(Ao(r)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2327
- }
2328
- function Ao(e) {
2329
- return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
2330
- }
2331
- const xo = "{value}", Ro = 2, Co = {}, So = ({ data: e, handleChange: r, path: t, label: n, schema: l, visible: o = !0 }) => {
2332
- var N;
2333
- Ee(o, t, r);
2334
- const s = l == null ? void 0 : l["x-computed"], c = (s == null ? void 0 : s.inputs) ?? Co, a = (s == null ? void 0 : s.formula) ?? "", d = (s == null ? void 0 : s.format) ?? xo, u = (s == null ? void 0 : s.decimals) ?? Ro, h = We(), p = t.split(".").slice(0, -1).join("."), g = wo((N = h.core) == null ? void 0 : N.data, p, c), b = g ? JSON.stringify(g) : null, I = h.readonly === !0, [O, T] = j(() => typeof e == "number" ? "ok" : "unavailable"), [A, k] = j(() => typeof e == "number" ? e : null), [M, L] = j(null);
2335
- return de(() => {
2528
+ ), qo = "{value}", Jo = 2, Zo = {}, Qo = ({ data: e, handleChange: r, path: t, label: n, schema: l, visible: o = !0 }) => {
2529
+ var D;
2530
+ Re(o, t, r);
2531
+ const s = l == null ? void 0 : l["x-computed"], u = (s == null ? void 0 : s.inputs) ?? Zo, a = (s == null ? void 0 : s.formula) ?? "", c = (s == null ? void 0 : s.format) ?? qo, d = (s == null ? void 0 : s.decimals) ?? Jo, f = Ve(), p = t.split(".").slice(0, -1).join("."), g = So((D = f.core) == null ? void 0 : D.data, p, u), b = g ? JSON.stringify(g) : null, M = f.readonly === !0, [N, U] = j(() => typeof e == "number" ? "ok" : "unavailable"), [T, R] = j(() => typeof e == "number" ? e : null), [I, A] = j(null);
2532
+ return me(() => {
2336
2533
  if (!o) return;
2337
- let U = !1;
2338
- const z = (v) => {
2339
- I || v !== e && r(t, v);
2534
+ let z = !1;
2535
+ const V = (v) => {
2536
+ M || v !== e && r(t, v);
2340
2537
  };
2341
2538
  if (g === void 0) {
2342
- T("unavailable"), L(null), k(null), z(void 0);
2539
+ U("unavailable"), A(null), R(null), V(void 0);
2343
2540
  return;
2344
2541
  }
2345
- return T((v) => v === "ok" ? v : "loading"), Eo(g, a).then((v) => {
2346
- if (U) return;
2347
- const E = v.status === "ok" && typeof v.value == "number" && Number.isFinite(v.value) ? v.value : null;
2348
- if (E === null) {
2349
- T("error"), L(
2542
+ return U((v) => v === "ok" ? v : "loading"), Oo(g, a).then((v) => {
2543
+ if (z) return;
2544
+ const x = v.status === "ok" && typeof v.value == "number" && Number.isFinite(v.value) ? v.value : null;
2545
+ if (x === null) {
2546
+ U("error"), A(
2350
2547
  v.status === "error" ? v.error ?? "Unable to compute value." : "Computed value must be a number."
2351
- ), k(null), z(void 0);
2548
+ ), R(null), V(void 0);
2352
2549
  return;
2353
2550
  }
2354
- T("ok"), L(null), k(E), z(E);
2551
+ U("ok"), A(null), R(x), V(x);
2355
2552
  }), () => {
2356
- U = !0;
2553
+ z = !0;
2357
2554
  };
2358
- }, [b, a, o, I]), o === !1 ? null : /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
2359
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: n }),
2360
- O === "unavailable" ? /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Not yet available." }) : O === "loading" ? /* @__PURE__ */ y(D, { align: "center", gap: "2", children: [
2361
- /* @__PURE__ */ i(Ue, { size: "1" }),
2362
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Computing…" })
2363
- ] }) : O === "error" ? /* @__PURE__ */ i(f, { size: "2", color: "red", children: M }) : /* @__PURE__ */ i(f, { size: "2", children: ot(d, { value: To(A, u) }) }),
2364
- l.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: l.description })
2555
+ }, [b, a, o, M]), o === !1 ? null : /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
2556
+ /* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: n }),
2557
+ N === "unavailable" ? /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Not yet available." }) : N === "loading" ? /* @__PURE__ */ y(F, { align: "center", gap: "2", children: [
2558
+ /* @__PURE__ */ i(_e, { size: "1" }),
2559
+ /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Computing…" })
2560
+ ] }) : N === "error" ? /* @__PURE__ */ i(h, { size: "2", color: "red", children: I }) : /* @__PURE__ */ i(h, { size: "2", children: rt(c, { value: or(T, d) }) }),
2561
+ l.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: l.description })
2365
2562
  ] }) });
2366
- }, Oo = ue(So), No = ee(
2563
+ }, ei = pe(Qo), ti = te(
2367
2564
  5,
2368
- Ie((e) => {
2565
+ Me((e) => {
2369
2566
  const r = e["x-computed"];
2370
2567
  return e.type === "number" && typeof r == "object" && r !== null;
2371
2568
  })
2372
- ), Gt = "seq", At = 2, ko = (e) => e == null || e === "", qt = (e) => typeof e == "object" && e !== null && !Array.isArray(e) ? e : void 0, Io = (e) => {
2569
+ ), ur = "seq", kt = 2, ri = (e) => e == null || e === "", dr = (e) => typeof e == "object" && e !== null && !Array.isArray(e) ? e : void 0, ni = (e) => {
2373
2570
  const r = e == null ? void 0 : e["x-template"];
2374
2571
  if (typeof r != "object" || r === null) return;
2375
2572
  const { template: t, inputs: n } = r;
2376
2573
  if (!(typeof t != "string" || t === ""))
2377
2574
  return { template: t, inputs: n };
2378
- }, ct = (e) => typeof e == "object" && e.name === Gt && e.arg !== void 0, Do = (e) => e.every((r, t) => !ct(r) || typeof e[t - 1] != "object" && typeof e[t + 1] != "object"), Lo = (e) => {
2575
+ }, mt = (e) => typeof e == "object" && e.name === ur && e.arg !== void 0, oi = (e) => e.every((r, t) => !mt(r) || typeof e[t - 1] != "object" && typeof e[t + 1] != "object"), ii = (e) => {
2379
2576
  const r = /* @__PURE__ */ new Set();
2380
- for (const t of it(e))
2577
+ for (const t of dt(e))
2381
2578
  typeof t == "object" && t.arg === void 0 && r.add(t.name);
2382
2579
  return [...r];
2383
- }, Mo = (e) => {
2580
+ }, si = (e) => {
2384
2581
  const r = [];
2385
2582
  for (const [t, n] of Object.entries((e == null ? void 0 : e.properties) ?? {})) {
2386
- const l = Io(n);
2583
+ const l = ni(n);
2387
2584
  l && r.push([t, l]);
2388
2585
  }
2389
2586
  return r;
2390
- }, zo = (e, r, t) => {
2587
+ }, li = (e, r, t) => {
2391
2588
  var l;
2392
2589
  const n = {};
2393
- for (const o of Lo(t.template)) {
2394
- const s = Yt(e, r, ((l = t.inputs) == null ? void 0 : l[o]) ?? o);
2590
+ for (const o of ii(t.template)) {
2591
+ const s = nr(e, r, ((l = t.inputs) == null ? void 0 : l[o]) ?? o);
2395
2592
  n[o] = typeof s == "string" || typeof s == "number" || typeof s == "boolean" ? String(s) : "";
2396
2593
  }
2397
2594
  return n;
2398
- }, Fo = (e) => (r) => {
2399
- const t = r.trim() === "" ? At : Number(r);
2400
- return `${e}`.padStart(Number.isInteger(t) && t >= 0 ? t : At, "0");
2401
- }, Uo = (e) => {
2595
+ }, ai = (e) => (r) => {
2596
+ const t = r.trim() === "" ? kt : Number(r);
2597
+ return `${e}`.padStart(Number.isInteger(t) && t >= 0 ? t : kt, "0");
2598
+ }, ci = (e) => {
2402
2599
  const r = (n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2403
2600
  let t = "";
2404
- for (const n of it(e))
2405
- typeof n == "string" ? t += r(n) : t += ct(n) ? "(\\d+)" : ".*?";
2601
+ for (const n of dt(e))
2602
+ typeof n == "string" ? t += r(n) : t += mt(n) ? "(\\d+)" : ".*?";
2406
2603
  return new RegExp(`^${t}$`);
2407
- }, Po = (e, r, t) => {
2604
+ }, ui = (e, r, t) => {
2408
2605
  var o, s;
2409
- const n = Uo(t.template);
2606
+ const n = ci(t.template);
2410
2607
  let l = 0;
2411
- for (const c of e) {
2412
- const a = (o = qt(c)) == null ? void 0 : o[r];
2608
+ for (const u of e) {
2609
+ const a = (o = dr(u)) == null ? void 0 : o[r];
2413
2610
  if (typeof a != "string") continue;
2414
- const d = Number((s = n.exec(a)) == null ? void 0 : s[1]);
2415
- Number.isFinite(d) && d > l && (l = d);
2611
+ const c = Number((s = n.exec(a)) == null ? void 0 : s[1]);
2612
+ Number.isFinite(c) && c > l && (l = c);
2416
2613
  }
2417
2614
  return l;
2418
- }, $o = (e, r, t, n, l, o) => {
2419
- const s = Mo(e);
2615
+ }, di = (e, r, t, n, l, o) => {
2616
+ const s = si(e);
2420
2617
  if (s.length === 0) return r;
2421
- const c = qt(r);
2422
- if (!c) return r;
2423
- const a = { ...c };
2424
- for (const [d, u] of s) {
2425
- if (!ko(a[d])) continue;
2426
- const h = it(u.template), p = {};
2427
- if (h.some(ct)) {
2428
- if (!Do(h)) {
2618
+ const u = dr(r);
2619
+ if (!u) return r;
2620
+ const a = { ...u };
2621
+ for (const [c, d] of s) {
2622
+ if (!ri(a[c])) continue;
2623
+ const f = dt(d.template), p = {};
2624
+ if (f.some(mt)) {
2625
+ if (!oi(f)) {
2429
2626
  console.warn(
2430
- `x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${u.template}"`
2627
+ `x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${d.template}"`
2431
2628
  );
2432
2629
  continue;
2433
2630
  }
2434
- const g = Math.max(o[d] ?? 0, Po(t, d, u)) + 1;
2435
- o[d] = g, p[Gt] = Fo(g);
2631
+ const g = Math.max(o[c] ?? 0, ui(t, c, d)) + 1;
2632
+ o[c] = g, p[ur] = ai(g);
2436
2633
  }
2437
- a[d] = ot(u.template, zo(n, l, u), p);
2634
+ a[c] = rt(d.template, li(n, l, d), p);
2438
2635
  }
2439
2636
  return a;
2440
- }, _o = ({ path: e, items: r, itemsSchema: t, rootSchema: n, addItem: l, sequences: o }) => {
2441
- const s = We();
2442
- return /* @__PURE__ */ i(S, { mt: "2", children: /* @__PURE__ */ y(De, { type: "button", variant: "surface", onClick: () => {
2443
- var d;
2444
- const a = $o(
2637
+ }, fi = ({ path: e, items: r, itemsSchema: t, rootSchema: n, addItem: l, sequences: o }) => {
2638
+ const s = Ve();
2639
+ return /* @__PURE__ */ i(k, { mt: "2", children: /* @__PURE__ */ y(ze, { type: "button", variant: "surface", onClick: () => {
2640
+ var c;
2641
+ const a = di(
2445
2642
  t,
2446
- ar(t, n),
2643
+ Ar(t, n),
2447
2644
  r,
2448
- (d = s.core) == null ? void 0 : d.data,
2645
+ (c = s.core) == null ? void 0 : c.data,
2449
2646
  // The object CONTAINING the array, not the row: a row being filled is
2450
2647
  // empty, so what a template reaches for sits alongside the array.
2451
2648
  e.split(".").slice(0, -1).join("."),
@@ -2453,10 +2650,10 @@ const xo = "{value}", Ro = 2, Co = {}, So = ({ data: e, handleChange: r, path: t
2453
2650
  );
2454
2651
  l && l(e, a)();
2455
2652
  }, children: [
2456
- /* @__PURE__ */ i(yr, {}),
2653
+ /* @__PURE__ */ i(kr, {}),
2457
2654
  "Add Item"
2458
2655
  ] }) });
2459
- }, Vo = ({
2656
+ }, pi = ({
2460
2657
  data: e,
2461
2658
  path: r,
2462
2659
  schema: t,
@@ -2464,52 +2661,52 @@ const xo = "{value}", Ro = 2, Co = {}, So = ({ data: e, handleChange: r, path: t
2464
2661
  enabled: l,
2465
2662
  visible: o,
2466
2663
  addItem: s,
2467
- removeItems: c,
2664
+ removeItems: u,
2468
2665
  rootSchema: a,
2469
- arraySchema: d
2666
+ arraySchema: c
2470
2667
  }) => {
2471
- const u = ae({}), h = d ? t : t.items, p = d || t;
2472
- if (o === !1 || !h || typeof h != "object" || Array.isArray(h))
2668
+ const d = ue({}), f = c ? t : t.items, p = c || t;
2669
+ if (o === !1 || !f || typeof f != "object" || Array.isArray(f))
2473
2670
  return null;
2474
- const g = h, b = Array.isArray(e) ? e : [], I = p.title || "Array Items", O = n.options ?? {}, T = l && O.addable !== !1, A = l && O.removable !== !1, k = O.itemLabel || "Item", M = (L) => {
2475
- if (c) {
2476
- const N = c(r, [L]);
2477
- N && N();
2671
+ const g = f, b = Array.isArray(e) ? e : [], M = p.title || "Array Items", N = n.options ?? {}, U = l && N.addable !== !1, T = l && N.removable !== !1, R = N.itemLabel || "Item", I = (A) => {
2672
+ if (u) {
2673
+ const D = u(r, [A]);
2674
+ D && D();
2478
2675
  }
2479
2676
  };
2480
- return /* @__PURE__ */ i(S, { mb: "6", children: /* @__PURE__ */ y(D, { direction: "column", gap: "4", children: [
2481
- /* @__PURE__ */ i(f, { as: "div", size: "4", weight: "bold", children: I }),
2482
- b.length === 0 && /* @__PURE__ */ i(S, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2483
- b.map((L, N) => {
2484
- var z;
2485
- const U = `${r}.${N}`;
2486
- return /* @__PURE__ */ i(Dt, { size: "3", variant: "surface", children: /* @__PURE__ */ y(D, { direction: "column", gap: "4", children: [
2487
- /* @__PURE__ */ y(D, { justify: "between", align: "center", children: [
2488
- /* @__PURE__ */ y(f, { size: "3", weight: "bold", children: [
2489
- k,
2677
+ return /* @__PURE__ */ i(k, { mb: "6", children: /* @__PURE__ */ y(F, { direction: "column", gap: "4", children: [
2678
+ /* @__PURE__ */ i(h, { as: "div", size: "4", weight: "bold", children: M }),
2679
+ b.length === 0 && /* @__PURE__ */ i(k, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2680
+ b.map((A, D) => {
2681
+ var V;
2682
+ const z = `${r}.${D}`;
2683
+ return /* @__PURE__ */ i(jt, { size: "3", variant: "surface", children: /* @__PURE__ */ y(F, { direction: "column", gap: "4", children: [
2684
+ /* @__PURE__ */ y(F, { justify: "between", align: "center", children: [
2685
+ /* @__PURE__ */ y(h, { size: "3", weight: "bold", children: [
2686
+ R,
2490
2687
  " ",
2491
- N + 1
2688
+ D + 1
2492
2689
  ] }),
2493
- A && /* @__PURE__ */ y(
2494
- De,
2690
+ T && /* @__PURE__ */ y(
2691
+ ze,
2495
2692
  {
2496
2693
  type: "button",
2497
2694
  color: "red",
2498
2695
  variant: "soft",
2499
- onClick: () => M(N),
2696
+ onClick: () => I(D),
2500
2697
  title: "Remove item",
2501
2698
  children: [
2502
- /* @__PURE__ */ i(gr, {}),
2699
+ /* @__PURE__ */ i(Ir, {}),
2503
2700
  "Remove"
2504
2701
  ]
2505
2702
  }
2506
2703
  )
2507
2704
  ] }),
2508
- /* @__PURE__ */ i(S, { children: /* @__PURE__ */ i(
2509
- Be,
2705
+ /* @__PURE__ */ i(k, { children: /* @__PURE__ */ i(
2706
+ Ye,
2510
2707
  {
2511
2708
  schema: g,
2512
- uischema: ((z = n.options) == null ? void 0 : z.detail) || (g.type === "object" || g.properties ? {
2709
+ uischema: ((V = n.options) == null ? void 0 : V.detail) || (g.type === "object" || g.properties ? {
2513
2710
  type: "VerticalLayout",
2514
2711
  elements: Object.keys(g.properties || {}).map((v) => ({
2515
2712
  type: "Control",
@@ -2519,98 +2716,101 @@ const xo = "{value}", Ro = 2, Co = {}, So = ({ data: e, handleChange: r, path: t
2519
2716
  type: "Control",
2520
2717
  scope: "#"
2521
2718
  }),
2522
- path: U,
2719
+ path: z,
2523
2720
  enabled: l,
2524
2721
  renderers: void 0,
2525
2722
  cells: void 0
2526
2723
  }
2527
2724
  ) })
2528
- ] }) }, U);
2725
+ ] }) }, z);
2529
2726
  }),
2530
- T && /* @__PURE__ */ i(
2531
- _o,
2727
+ U && /* @__PURE__ */ i(
2728
+ fi,
2532
2729
  {
2533
2730
  path: r,
2534
2731
  items: b,
2535
2732
  itemsSchema: g,
2536
2733
  rootSchema: a,
2537
2734
  addItem: s,
2538
- sequences: u
2735
+ sequences: d
2539
2736
  }
2540
2737
  )
2541
2738
  ] }) });
2542
- }, xt = fr(Vo), jo = ee(3, ur), Ho = ({ uischema: e, visible: r }) => {
2739
+ }, Lt = Sr(pi), hi = te(3, Rr), mi = ({ uischema: e, visible: r }) => {
2543
2740
  const t = e;
2544
- return r === !1 ? null : /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ i(It, { size: "4", children: t.text }) });
2545
- }, Wo = ee(1, He("Label")), Bo = ee(3, dr), ri = [
2546
- { tester: Er, renderer: Tr },
2547
- { tester: xr, renderer: Rr },
2548
- { tester: Sr, renderer: Or },
2549
- { tester: kr, renderer: Ir },
2550
- { tester: Hr, renderer: jr },
2551
- { tester: Lr, renderer: Mr },
2552
- { tester: Kr, renderer: Yr },
2553
- { tester: qr, renderer: Gr },
2554
- { tester: Zr, renderer: Jr },
2555
- { tester: en, renderer: Qr },
2556
- { tester: rn, renderer: tn },
2557
- { tester: ln, renderer: sn },
2558
- { tester: jn, renderer: Vn },
2559
- { tester: Gn, renderer: Yn },
2741
+ return r === !1 ? null : /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ i(_t, { size: "4", children: t.text }) });
2742
+ }, gi = te(1, Xe("Label")), yi = te(3, Cr), Oi = [
2743
+ { tester: Fr, renderer: Ur },
2744
+ { tester: Pr, renderer: _r },
2745
+ { tester: Vr, renderer: Hr },
2746
+ { tester: Br, renderer: Xr },
2747
+ { tester: on, renderer: nn },
2748
+ { tester: Kr, renderer: Gr },
2749
+ { tester: un, renderer: dn },
2750
+ // The layout renderers take their props from withJsonFormsLayoutProps, which
2751
+ // evaluates the layout's rule into `visible` and `enabled`, as
2752
+ // withJsonFormsControlProps does for the controls.
2753
+ { tester: pn, renderer: Ge(fn) },
2754
+ { tester: mn, renderer: Ge(hn) },
2755
+ { tester: yn, renderer: Ge(gn) },
2756
+ { tester: vn, renderer: Ge(bn) },
2757
+ { tester: In, renderer: Dn },
2758
+ { tester: po, renderer: fo },
2759
+ { tester: wo, renderer: vo },
2560
2760
  // After SpreadsheetControl on purpose: both testers rank 10, and a tie is
2561
2761
  // resolved by registration order (see XmlControlTester's comment).
2562
- { tester: uo, renderer: ao },
2762
+ { tester: _o, renderer: Po },
2563
2763
  // Also rank 10, but matches the distinct `x-xml-export` keyword rather
2564
2764
  // than `x-xml`, so it never ties with XmlControlTester on the same schema
2565
2765
  // node (see XmlExportControlTester's own comment).
2566
- { tester: vo, renderer: bo },
2567
- { tester: No, renderer: Oo },
2568
- { tester: jo, renderer: xt },
2569
- { tester: Bo, renderer: xt },
2570
- { tester: Wo, renderer: Ho }
2766
+ { tester: Go, renderer: Ko },
2767
+ { tester: ti, renderer: ei },
2768
+ { tester: hi, renderer: Lt },
2769
+ { tester: yi, renderer: Lt },
2770
+ { tester: gi, renderer: mi }
2571
2771
  ];
2572
2772
  export {
2573
- xt as ArrayControl,
2574
- jo as ArrayControlTester,
2575
- Cr as BooleanControl,
2576
- Sr as BooleanControlTester,
2577
- tn as CategorizationLayoutRenderer,
2578
- rn as CategorizationLayoutTester,
2579
- Oo as ComputedControl,
2580
- No as ComputedControlTester,
2581
- Xr as DateControl,
2582
- Kr as DateControlTester,
2583
- sn as FileControl,
2584
- ln as FileControlTester,
2585
- Qr as GroupLayoutRenderer,
2586
- en as GroupLayoutTester,
2587
- Jr as HorizontalLayoutRenderer,
2588
- Zr as HorizontalLayoutTester,
2589
- Ho as LabelRenderer,
2590
- Wo as LabelTester,
2591
- Ar as NumberControl,
2592
- xr as NumberControlTester,
2593
- Nr as RadioControl,
2594
- kr as RadioControlTester,
2595
- jr as SearchSelectControl,
2596
- Hr as SearchSelectControlTester,
2597
- ti as SearchServiceProvider,
2598
- Dr as SelectControl,
2599
- Lr as SelectControlTester,
2600
- Vn as SpreadsheetControl,
2601
- jn as SpreadsheetControlTester,
2602
- Yn as SpreadsheetExportControl,
2603
- Gn as SpreadsheetExportControlTester,
2604
- wr as TextControl,
2605
- Er as TextControlTester,
2606
- ei as UploadProvider,
2607
- Gr as VerticalLayoutRenderer,
2608
- qr as VerticalLayoutTester,
2609
- ao as XmlControl,
2610
- uo as XmlControlTester,
2611
- bo as XmlExportControl,
2612
- vo as XmlExportControlTester,
2613
- ri as radixRenderers,
2614
- vr as useSearchService,
2615
- br as useUpload
2773
+ Lt as ArrayControl,
2774
+ hi as ArrayControlTester,
2775
+ jr as BooleanControl,
2776
+ Vr as BooleanControlTester,
2777
+ bn as CategorizationLayoutRenderer,
2778
+ vn as CategorizationLayoutTester,
2779
+ ei as ComputedControl,
2780
+ ti as ComputedControlTester,
2781
+ cn as DateControl,
2782
+ un as DateControlTester,
2783
+ Dn as FileControl,
2784
+ In as FileControlTester,
2785
+ gn as GroupLayoutRenderer,
2786
+ yn as GroupLayoutTester,
2787
+ hn as HorizontalLayoutRenderer,
2788
+ mn as HorizontalLayoutTester,
2789
+ mi as LabelRenderer,
2790
+ gi as LabelTester,
2791
+ $r as NumberControl,
2792
+ Pr as NumberControlTester,
2793
+ Wr as RadioControl,
2794
+ Br as RadioControlTester,
2795
+ nn as SearchSelectControl,
2796
+ on as SearchSelectControlTester,
2797
+ Si as SearchServiceProvider,
2798
+ Yr as SelectControl,
2799
+ Kr as SelectControlTester,
2800
+ fo as SpreadsheetControl,
2801
+ po as SpreadsheetControlTester,
2802
+ vo as SpreadsheetExportControl,
2803
+ wo as SpreadsheetExportControlTester,
2804
+ zr as TextControl,
2805
+ Fr as TextControlTester,
2806
+ Ci as UploadProvider,
2807
+ fn as VerticalLayoutRenderer,
2808
+ pn as VerticalLayoutTester,
2809
+ Po as XmlControl,
2810
+ _o as XmlControlTester,
2811
+ Ko as XmlExportControl,
2812
+ Go as XmlExportControlTester,
2813
+ Oi as radixRenderers,
2814
+ Mr as useSearchService,
2815
+ Lr as useUpload
2616
2816
  };