@opennsw/jsonforms-renderers 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,195 +1,195 @@
1
- var cr = Object.defineProperty;
2
- var ar = (e, t, r) => t in e ? cr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Pe = (e, t, r) => ar(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { jsx as n, jsxs as p, Fragment as Te } from "react/jsx-runtime";
5
- import { useContext as Xe, createContext as Ye, useMemo as dr, useEffect as ge, useState as _, useRef as de, useCallback as ke } from "react";
6
- import { rankWith as W, isStringControl as ur, or as Me, isNumberControl as fr, isIntegerControl as hr, isBooleanControl as pr, isEnumControl as Je, isOneOfControl as Ze, schemaMatches as Fe, isDateControl as gr, isDateTimeControl as mr, isTimeControl as yr, uiTypeIs as Ae, and as vr, createDefaultValue as br, isObjectArrayControl as Er, isPrimitiveArrayControl as wr } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as oe, JsonFormsDispatch as Se, withJsonFormsArrayControlProps as Rr } from "@jsonforms/react";
8
- import { Box as C, Flex as T, Text as f, TextField as ve, Checkbox as Cr, RadioGroup as Ve, Select as Oe, ScrollArea as Tr, Spinner as ze, Button as Le, Tabs as Ie, Heading as qe, Card as $e, IconButton as je, Table as ne } from "@radix-ui/themes";
9
- import { ChevronDownIcon as Ar, FileTextIcon as Qe, CheckCircledIcon as er, Cross2Icon as rr, ExclamationTriangleIcon as tr, UploadIcon as nr, TrashIcon as Sr, PlusIcon as Nr } from "@radix-ui/react-icons";
10
- import Or from "dayjs";
11
- import { read as Ir, utils as xr } from "@e965/xlsx";
12
- const or = Ye(null);
13
- function tn({
1
+ var mr = Object.defineProperty;
2
+ var gr = (e, t, r) => t in e ? mr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var Pe = (e, t, r) => gr(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as n, jsxs as g, Fragment as be } from "react/jsx-runtime";
5
+ import { useContext as Ze, createContext as Qe, useMemo as yr, useEffect as fe, useState as F, useRef as de, useCallback as _e } from "react";
6
+ import { rankWith as W, isStringControl as vr, or as Le, isNumberControl as br, isIntegerControl as wr, isBooleanControl as Er, isEnumControl as er, isOneOfControl as rr, schemaMatches as ze, isDateControl as Rr, isDateTimeControl as Cr, isTimeControl as Tr, uiTypeIs as Te, and as Ar, Resolve as Sr, createDefaultValue as Or, isObjectArrayControl as Nr, isPrimitiveArrayControl as Ir } from "@jsonforms/core";
7
+ import { withJsonFormsControlProps as se, JsonFormsDispatch as Ae, useJsonForms as xr, withJsonFormsArrayControlProps as Mr } from "@jsonforms/react";
8
+ import { Box as C, Flex as S, Text as h, TextField as ye, Checkbox as kr, RadioGroup as Ve, Select as Ne, ScrollArea as Lr, Spinner as Me, Button as ke, Tabs as Ie, Heading as tr, Card as nr, IconButton as Ue, Tooltip as We, Table as $ } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as zr, FileTextIcon as Dr, CheckCircledIcon as Fr, Cross2Icon as or, ExclamationTriangleIcon as lr, UploadIcon as He, TrashIcon as Ur, PlusIcon as Hr } from "@radix-ui/react-icons";
10
+ import $r from "dayjs";
11
+ import { read as _r, utils as Pr } from "@e965/xlsx";
12
+ const ir = Qe(null);
13
+ function Nn({
14
14
  children: e,
15
15
  onUpload: t,
16
16
  getDownloadUrl: r
17
17
  }) {
18
- const d = { onUpload: t, getDownloadUrl: r };
19
- return /* @__PURE__ */ n(or.Provider, { value: d, children: e });
18
+ const i = { onUpload: t, getDownloadUrl: r };
19
+ return /* @__PURE__ */ n(ir.Provider, { value: i, children: e });
20
20
  }
21
- function Lr() {
22
- return Xe(or);
21
+ function Vr() {
22
+ return Ze(ir);
23
23
  }
24
- const lr = Ye(null);
25
- function nn({
24
+ const sr = Qe(null);
25
+ function In({
26
26
  children: e,
27
27
  services: t
28
28
  }) {
29
- const r = dr(() => t, [t]);
30
- return /* @__PURE__ */ n(lr.Provider, { value: r, children: e });
29
+ const r = yr(() => t, [t]);
30
+ return /* @__PURE__ */ n(sr.Provider, { value: r, children: e });
31
31
  }
32
- function Mr(e) {
33
- const t = Xe(lr);
32
+ function Wr(e) {
33
+ const t = Ze(sr);
34
34
  return !t || !e ? null : t[e] ?? null;
35
35
  }
36
- const ue = (e, t, r, d = void 0) => {
37
- ge(() => {
38
- e === !1 && r(t, d);
39
- }, [e, t, r, d]);
40
- }, le = (e, t) => e ? e.split(`
36
+ const ce = (e, t, r, i = void 0) => {
37
+ fe(() => {
38
+ e === !1 && r(t, i);
39
+ }, [e, t, r, i]);
40
+ }, ae = (e, t) => e ? e.split(`
41
41
  `).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
42
- `) : "", Dr = ({
42
+ `) : "", Br = ({
43
43
  data: e,
44
44
  handleChange: t,
45
45
  path: r,
46
- label: d,
47
- required: g,
48
- errors: a,
49
- uischema: c,
50
- schema: s,
46
+ label: i,
47
+ required: f,
48
+ errors: s,
49
+ uischema: l,
50
+ schema: a,
51
51
  enabled: o,
52
- visible: i = !0
52
+ visible: c = !0
53
53
  }) => {
54
54
  var y;
55
- if (ue(i, r, t), i === !1)
55
+ if (ce(c, r, t), c === !1)
56
56
  return null;
57
- const l = a.length === 0;
58
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
59
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
60
- d,
57
+ const u = s.length === 0;
58
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
59
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
60
+ i,
61
61
  " ",
62
- g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
62
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
63
63
  ] }),
64
64
  /* @__PURE__ */ n(
65
- ve.Root,
65
+ ye.Root,
66
66
  {
67
67
  value: e || "",
68
- onChange: (h) => t(r, h.target.value),
68
+ onChange: (p) => t(r, p.target.value),
69
69
  disabled: !o,
70
- placeholder: (y = c.options) == null ? void 0 : y.placeholder,
71
- color: l ? void 0 : "red",
70
+ placeholder: (y = l.options) == null ? void 0 : y.placeholder,
71
+ color: u ? void 0 : "red",
72
72
  id: r
73
73
  }
74
74
  ),
75
- !l && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(a, d) }),
76
- s.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: s.description })
75
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
76
+ a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
77
77
  ] }) });
78
- }, zr = W(1, ur), Ur = oe(Dr), kr = ({
78
+ }, Kr = W(1, vr), Gr = se(Br), Xr = ({
79
79
  data: e,
80
80
  handleChange: t,
81
81
  path: r,
82
- label: d,
83
- required: g,
84
- errors: a,
85
- uischema: c,
86
- schema: s,
82
+ label: i,
83
+ required: f,
84
+ errors: s,
85
+ uischema: l,
86
+ schema: a,
87
87
  enabled: o,
88
- visible: i = !0
88
+ visible: c = !0
89
89
  }) => {
90
- var h;
91
- if (ue(i, r, t), i === !1)
90
+ var p;
91
+ if (ce(c, r, t), c === !1)
92
92
  return null;
93
- const l = a.length === 0, y = (u) => {
94
- if (u === "") {
93
+ const u = s.length === 0, y = (m) => {
94
+ if (m === "") {
95
95
  t(r, void 0);
96
96
  return;
97
97
  }
98
- const v = Number(u);
98
+ const v = Number(m);
99
99
  isNaN(v) || t(r, v);
100
100
  };
101
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
102
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
- d,
101
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
102
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
+ i,
104
104
  " ",
105
- g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
105
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
106
106
  ] }),
107
107
  /* @__PURE__ */ n(
108
- ve.Root,
108
+ ye.Root,
109
109
  {
110
110
  type: "number",
111
111
  value: e ?? "",
112
- onChange: (u) => y(u.target.value),
112
+ onChange: (m) => y(m.target.value),
113
113
  disabled: !o,
114
- placeholder: (h = c.options) == null ? void 0 : h.placeholder,
115
- color: l ? void 0 : "red",
114
+ placeholder: (p = l.options) == null ? void 0 : p.placeholder,
115
+ color: u ? void 0 : "red",
116
116
  id: r
117
117
  }
118
118
  ),
119
- !l && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(a, d) }),
120
- s.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: s.description })
119
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
120
+ a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
121
121
  ] }) });
122
- }, Fr = W(2, Me(fr, hr)), $r = oe(kr), _r = ({
122
+ }, jr = W(2, Le(br, wr)), Yr = se(Xr), Jr = ({
123
123
  data: e,
124
124
  handleChange: t,
125
125
  path: r,
126
- label: d,
127
- required: g,
128
- errors: a,
129
- schema: c,
130
- enabled: s,
126
+ label: i,
127
+ required: f,
128
+ errors: s,
129
+ schema: l,
130
+ enabled: a,
131
131
  visible: o = !0
132
132
  }) => {
133
- if (ue(o, r, t), o === !1)
133
+ if (ce(o, r, t), o === !1)
134
134
  return null;
135
- const i = a.length === 0;
136
- return /* @__PURE__ */ p(C, { mb: "4", children: [
137
- /* @__PURE__ */ p(T, { gap: "2", align: "center", children: [
135
+ const c = s.length === 0;
136
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
137
+ /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
138
138
  /* @__PURE__ */ n(
139
- Cr,
139
+ kr,
140
140
  {
141
141
  checked: !!e,
142
- onCheckedChange: (l) => t(r, l === !0),
143
- disabled: !s,
142
+ onCheckedChange: (u) => t(r, u === !0),
143
+ disabled: !a,
144
144
  id: r
145
145
  }
146
146
  ),
147
- /* @__PURE__ */ p(f, { as: "label", size: "2", htmlFor: r, children: [
148
- d,
147
+ /* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
148
+ i,
149
149
  " ",
150
- g && "*"
150
+ f && "*"
151
151
  ] })
152
152
  ] }),
153
- !i && /* @__PURE__ */ n(f, { color: "red", size: "1", className: "block mt-1", children: le(a, d) }),
154
- c.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", className: "block mt-1", children: c.description })
153
+ !c && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: ae(s, i) }),
154
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: l.description })
155
155
  ] });
156
- }, Pr = W(2, pr), Vr = oe(_r), Hr = ({
156
+ }, qr = W(2, Er), Zr = se(Jr), Qr = ({
157
157
  data: e,
158
158
  handleChange: t,
159
159
  path: r,
160
- label: d,
161
- required: g,
162
- errors: a,
163
- schema: c,
164
- enabled: s,
160
+ label: i,
161
+ required: f,
162
+ errors: s,
163
+ schema: l,
164
+ enabled: a,
165
165
  visible: o = !0
166
166
  }) => {
167
- if (ue(o, r, t), o === !1)
167
+ if (ce(o, r, t), o === !1)
168
168
  return null;
169
- const i = a.length === 0;
170
- let l = [];
171
- c.enum ? l = c.enum.map((h) => ({ value: h, label: String(h) })) : c.oneOf && (l = c.oneOf.map((h) => ({
172
- value: h.const,
173
- label: h.title || String(h.const)
169
+ const c = s.length === 0;
170
+ let u = [];
171
+ l.enum ? u = l.enum.map((p) => ({ value: p, label: String(p) })) : l.oneOf && (u = l.oneOf.map((p) => ({
172
+ value: p.const,
173
+ label: p.title || String(p.const)
174
174
  })));
175
175
  const y = e;
176
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
177
- /* @__PURE__ */ p(f, { as: "div", size: "2", weight: "bold", children: [
178
- d,
176
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
177
+ /* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
178
+ i,
179
179
  " ",
180
- g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
180
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
181
181
  ] }),
182
182
  /* @__PURE__ */ n(
183
183
  Ve.Root,
184
184
  {
185
185
  value: y !== void 0 ? String(y) : "",
186
- onValueChange: (h) => {
187
- const u = l.find((v) => String(v.value) === h);
188
- u && t(r, u.value);
186
+ onValueChange: (p) => {
187
+ const m = u.find((v) => String(v.value) === p);
188
+ m && t(r, m.value);
189
189
  },
190
- disabled: !s,
190
+ disabled: !a,
191
191
  children: /* @__PURE__ */ n(
192
- T,
192
+ S,
193
193
  {
194
194
  direction: "row",
195
195
  style: {
@@ -197,209 +197,209 @@ const ue = (e, t, r, d = void 0) => {
197
197
  columnGap: "clamp(14px, 3vw, 36px)",
198
198
  rowGap: "clamp(8px, 1.6vw, 14px)"
199
199
  },
200
- children: l.map((h) => /* @__PURE__ */ p(T, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
- /* @__PURE__ */ n(Ve.Item, { value: String(h.value) }),
202
- /* @__PURE__ */ n(f, { size: "2", color: s ? void 0 : "gray", children: h.label })
203
- ] }, String(h.value)))
200
+ children: u.map((p) => /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
+ /* @__PURE__ */ n(Ve.Item, { value: String(p.value) }),
202
+ /* @__PURE__ */ n(h, { size: "2", color: a ? void 0 : "gray", children: p.label })
203
+ ] }, String(p.value)))
204
204
  }
205
205
  )
206
206
  }
207
207
  ),
208
- !i && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(a, d) }),
209
- c.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: c.description })
208
+ !c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
209
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
210
210
  ] }) });
211
- }, Wr = (e, t, r) => {
212
- var g;
213
- return Me(Je, Ze)(e, t, r) && ((g = e == null ? void 0 : e.options) == null ? void 0 : g.format) === "radio" ? 3 : -1;
214
- }, Br = oe(Hr), Kr = ({
211
+ }, et = (e, t, r) => {
212
+ var f;
213
+ return Le(er, rr)(e, t, r) && ((f = e == null ? void 0 : e.options) == null ? void 0 : f.format) === "radio" ? 3 : -1;
214
+ }, rt = se(Qr), tt = ({
215
215
  data: e,
216
216
  handleChange: t,
217
217
  path: r,
218
- label: d,
219
- required: g,
220
- errors: a,
221
- schema: c,
222
- uischema: s,
218
+ label: i,
219
+ required: f,
220
+ errors: s,
221
+ schema: l,
222
+ uischema: a,
223
223
  enabled: o,
224
- visible: i = !0
224
+ visible: c = !0
225
225
  }) => {
226
- var u;
227
- if (ue(i, r, t), i === !1)
226
+ var m;
227
+ if (ce(c, r, t), c === !1)
228
228
  return null;
229
- const l = a.length === 0;
229
+ const u = s.length === 0;
230
230
  let y = [];
231
- c.enum ? y = c.enum.map((v) => ({ value: String(v), label: String(v) })) : c.oneOf && (y = c.oneOf.map((v) => ({
231
+ l.enum ? y = l.enum.map((v) => ({ value: String(v), label: String(v) })) : l.oneOf && (y = l.oneOf.map((v) => ({
232
232
  value: String(v.const),
233
233
  label: v.title || String(v.const)
234
234
  })));
235
- const h = e !== void 0 ? String(e) : "";
236
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
237
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
238
- d,
235
+ const p = e !== void 0 ? String(e) : "";
236
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
237
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
238
+ i,
239
239
  " ",
240
- g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
240
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
241
241
  ] }),
242
- /* @__PURE__ */ p(Oe.Root, { value: h, onValueChange: (v) => t(r, v), disabled: !o, children: [
242
+ /* @__PURE__ */ g(Ne.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
243
243
  /* @__PURE__ */ n(
244
- Oe.Trigger,
244
+ Ne.Trigger,
245
245
  {
246
- placeholder: ((u = s.options) == null ? void 0 : u.placeholder) || "Select an option",
247
- color: l ? void 0 : "red",
246
+ placeholder: ((m = a.options) == null ? void 0 : m.placeholder) || "Select an option",
247
+ color: u ? void 0 : "red",
248
248
  id: r
249
249
  }
250
250
  ),
251
- /* @__PURE__ */ n(Oe.Content, { children: y.map((v) => /* @__PURE__ */ n(Oe.Item, { value: v.value, children: v.label }, v.value)) })
251
+ /* @__PURE__ */ n(Ne.Content, { children: y.map((v) => /* @__PURE__ */ n(Ne.Item, { value: v.value, children: v.label }, v.value)) })
252
252
  ] }),
253
- !l && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(a, d) }),
254
- c.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: c.description })
253
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
254
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
255
255
  ] }) });
256
- }, Gr = W(2, Me(Je, Ze)), Xr = oe(Kr), Yr = {
256
+ }, nt = W(2, Le(er, rr)), ot = se(tt), lt = {
257
257
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
258
258
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
259
259
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
260
- }, Jr = ({
260
+ }, it = ({
261
261
  data: e,
262
262
  handleChange: t,
263
263
  path: r,
264
- label: d,
265
- required: g,
266
- errors: a,
267
- enabled: c,
268
- visible: s = !0,
264
+ label: i,
265
+ required: f,
266
+ errors: s,
267
+ enabled: l,
268
+ visible: a = !0,
269
269
  schema: o,
270
- uischema: i
270
+ uischema: c
271
271
  }) => {
272
- var ae;
273
- const l = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = l.service ?? "", h = l.mode ?? "large-paginated-list", u = Yr[h], v = (u == null ? void 0 : u.fetchOnOpen) ?? !1, M = l.params, A = Mr(y), w = o.type === "object", O = w ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, z = w ? O == null ? void 0 : O.value : e, S = O == null ? void 0 : O.label, q = y ? A ? u ? null : `Invalid x-search.mode "${h}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", P = c !== !1, ee = !a || a.length === 0, [x, J] = _(!1), [F, V] = _(""), [j, K] = _([]), [$, Q] = _(!1), [re, ie] = _(!1), [se, ce] = _(!1), [fe, b] = _(null), [I, D] = _(void 0), R = de(void 0), U = de(null), G = de(null), Y = de(null), B = de(void 0);
274
- ge(() => {
275
- var Z, he;
276
- if (!z) {
277
- D(void 0), B.current = void 0;
272
+ var Re;
273
+ const u = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = u.service ?? "", p = u.mode ?? "large-paginated-list", m = lt[p], v = (m == null ? void 0 : m.fetchOnOpen) ?? !1, N = u.params, A = Wr(y), w = o.type === "object", R = w ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, L = w ? R == null ? void 0 : R.value : e, P = R == null ? void 0 : R.label, I = y ? A ? m ? null : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", B = l !== !1, j = !s || s.length === 0, [M, O] = F(!1), [D, V] = F(""), [oe, ee] = F([]), [le, Y] = F(!1), [Z, re] = F(!1), [he, ne] = F(!1), [ue, b] = F(null), [k, U] = F(void 0), T = de(void 0), H = de(null), J = de(null), Q = de(null), K = de(void 0);
274
+ fe(() => {
275
+ var E, q;
276
+ if (!L) {
277
+ U(void 0), K.current = void 0;
278
278
  return;
279
279
  }
280
- if (((Z = B.current) == null ? void 0 : Z.value) === z && ((he = B.current) == null ? void 0 : he.label) === S) return;
281
- if (B.current = { value: z, label: S }, w && S) {
282
- D({ id: z, name: S });
280
+ if (((E = K.current) == null ? void 0 : E.value) === L && ((q = K.current) == null ? void 0 : q.label) === P) return;
281
+ if (K.current = { value: L, label: P }, w && P) {
282
+ U({ id: L, name: P });
283
283
  return;
284
284
  }
285
- if (D({ id: z, name: S ?? z }), !(A != null && A.resolve)) return;
286
- let m = !1;
287
- return A.resolve(z, M).then((Re) => {
288
- !m && Re && D(Re);
285
+ if (U({ id: L, name: P ?? L }), !(A != null && A.resolve)) return;
286
+ let d = !1;
287
+ return A.resolve(L, N).then((te) => {
288
+ !d && te && U(te);
289
289
  }).catch(() => {
290
290
  }), () => {
291
- m = !0;
291
+ d = !0;
292
292
  };
293
- }, [z, S, w, A, M]);
294
- const be = ke(
295
- async (m, Z = !1) => {
296
- var Re;
293
+ }, [L, P, w, A, N]);
294
+ const we = _e(
295
+ async (d, E = !1) => {
296
+ var te;
297
297
  if (!A) {
298
298
  b("Search service not configured.");
299
299
  return;
300
300
  }
301
- (Re = G.current) == null || Re.abort();
302
- const he = new AbortController();
303
- G.current = he, Z ? ce(!0) : (ie(!0), ce(!1), b(null));
301
+ (te = J.current) == null || te.abort();
302
+ const q = new AbortController();
303
+ J.current = q, E ? ne(!0) : (re(!0), ne(!1), b(null));
304
304
  try {
305
- const Ne = await A.search({
306
- query: m,
307
- cursor: Z ? R.current : void 0,
308
- signal: he.signal,
309
- params: M
310
- }), _e = Ne.options ?? [];
311
- K(Z ? (sr) => [...sr, ..._e] : _e), R.current = Ne.nextCursor, Q(((u == null ? void 0 : u.paginated) ?? !1) && Ne.nextCursor != null);
305
+ const ie = await A.search({
306
+ query: d,
307
+ cursor: E ? T.current : void 0,
308
+ signal: q.signal,
309
+ params: N
310
+ }), z = ie.options ?? [];
311
+ ee(E ? (pr) => [...pr, ...z] : z), T.current = ie.nextCursor, Y(((m == null ? void 0 : m.paginated) ?? !1) && ie.nextCursor != null);
312
312
  } catch {
313
- if (he.signal.aborted) return;
313
+ if (q.signal.aborted) return;
314
314
  b("Failed to load results. Please try again.");
315
315
  } finally {
316
- he.signal.aborted || (Z ? ce(!1) : ie(!1));
316
+ q.signal.aborted || (E ? ne(!1) : re(!1));
317
317
  }
318
318
  },
319
- [A, u == null ? void 0 : u.paginated, M]
319
+ [A, m == null ? void 0 : m.paginated, N]
320
320
  );
321
- if (ge(() => {
322
- if (!x) return;
323
- const m = (Z) => {
324
- Y.current && !Y.current.contains(Z.target) && J(!1);
321
+ if (fe(() => {
322
+ if (!M) return;
323
+ const d = (E) => {
324
+ Q.current && !Q.current.contains(E.target) && O(!1);
325
325
  };
326
- return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
327
- }, [x]), ge(() => {
328
- var m;
329
- x || ((m = G.current) == null || m.abort(), V(""), K([]), Q(!1), b(null), ie(!1), ce(!1), R.current = void 0);
330
- }, [x]), ge(() => {
331
- if (!x) return;
332
- if (!F && !v) {
333
- K([]), Q(!1), b(null), R.current = void 0;
326
+ return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
327
+ }, [M]), fe(() => {
328
+ var d;
329
+ M || ((d = J.current) == null || d.abort(), V(""), ee([]), Y(!1), b(null), re(!1), ne(!1), T.current = void 0);
330
+ }, [M]), fe(() => {
331
+ if (!M) return;
332
+ if (!D && !v) {
333
+ ee([]), Y(!1), b(null), T.current = void 0;
334
334
  return;
335
335
  }
336
- U.current && clearTimeout(U.current);
337
- const m = F ? 300 : 0;
338
- return U.current = setTimeout(() => {
339
- K([]), Q(!1), R.current = void 0, be(F);
340
- }, m), () => {
341
- U.current && clearTimeout(U.current);
336
+ H.current && clearTimeout(H.current);
337
+ const d = D ? 300 : 0;
338
+ return H.current = setTimeout(() => {
339
+ ee([]), Y(!1), T.current = void 0, we(D);
340
+ }, d), () => {
341
+ H.current && clearTimeout(H.current);
342
342
  };
343
- }, [F, x, v, be]), ue(s, r, t, w ? void 0 : null), s === !1)
343
+ }, [D, M, v, we]), ce(a, r, t, w ? void 0 : null), a === !1)
344
344
  return null;
345
345
  const Ee = () => {
346
- V(""), K([]), Q(!1), b(null), R.current = void 0, J(!0);
347
- }, E = (m) => {
348
- t(r, w ? { value: m.id, label: m.name } : m.id), D(m), B.current = { value: m.id, label: w ? m.name : void 0 }, J(!1);
349
- }, L = (m) => {
350
- m.stopPropagation(), t(r, w ? void 0 : null), D(void 0);
351
- }, we = (m) => {
352
- (m.key === "Enter" || m.key === " ") && L(m);
353
- }, te = ((ae = i == null ? void 0 : i.options) == null ? void 0 : ae.placeholder) ?? "Select an option";
354
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
355
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
356
- d,
346
+ V(""), ee([]), Y(!1), b(null), T.current = void 0, O(!0);
347
+ }, De = (d) => {
348
+ t(r, w ? { value: d.id, label: d.name } : d.id), U(d), K.current = { value: d.id, label: w ? d.name : void 0 }, O(!1);
349
+ }, Se = (d) => {
350
+ d.stopPropagation(), t(r, w ? void 0 : null), U(void 0);
351
+ }, Fe = (d) => {
352
+ (d.key === "Enter" || d.key === " ") && Se(d);
353
+ }, Oe = ((Re = c == null ? void 0 : c.options) == null ? void 0 : Re.placeholder) ?? "Select an option";
354
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
355
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
356
+ i,
357
357
  " ",
358
- g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
358
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
359
359
  ] }),
360
- /* @__PURE__ */ p("div", { ref: Y, style: { position: "relative" }, children: [
360
+ /* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
361
361
  /* @__PURE__ */ n(
362
- ve.Root,
362
+ ye.Root,
363
363
  {
364
364
  id: r,
365
- value: x ? F : (I == null ? void 0 : I.name) ?? "",
366
- placeholder: x && (u != null && u.searchable) ? "Search..." : te,
367
- disabled: !P,
368
- readOnly: x && !(u != null && u.searchable),
369
- style: ee ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
370
- onChange: (m) => {
371
- u != null && u.searchable && (V(m.target.value), x || Ee());
365
+ value: M ? D : (k == null ? void 0 : k.name) ?? "",
366
+ placeholder: M && (m != null && m.searchable) ? "Search..." : Oe,
367
+ disabled: !B,
368
+ readOnly: M && !(m != null && m.searchable),
369
+ style: j ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
370
+ onChange: (d) => {
371
+ m != null && m.searchable && (V(d.target.value), M || Ee());
372
372
  },
373
373
  onFocus: () => {
374
- P && !x && Ee();
374
+ B && !M && Ee();
375
375
  },
376
- onKeyDown: (m) => {
377
- m.key === "Escape" && J(!1);
376
+ onKeyDown: (d) => {
377
+ d.key === "Escape" && O(!1);
378
378
  },
379
- children: /* @__PURE__ */ n(ve.Slot, { side: "right", children: /* @__PURE__ */ p(T, { align: "center", gap: "1", children: [
380
- z && P && /* @__PURE__ */ n(
379
+ children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
380
+ L && B && /* @__PURE__ */ n(
381
381
  "span",
382
382
  {
383
383
  role: "button",
384
384
  tabIndex: 0,
385
- onMouseDown: (m) => m.preventDefault(),
386
- onClick: L,
387
- onKeyDown: we,
385
+ onMouseDown: (d) => d.preventDefault(),
386
+ onClick: Se,
387
+ onKeyDown: Fe,
388
388
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
389
389
  "aria-label": "Clear selection",
390
390
  children: "×"
391
391
  }
392
392
  ),
393
393
  /* @__PURE__ */ n(
394
- Ar,
394
+ zr,
395
395
  {
396
- style: { transform: x ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
396
+ style: { transform: M ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
397
397
  }
398
398
  )
399
399
  ] }) })
400
400
  }
401
401
  ),
402
- x && /* @__PURE__ */ n(
402
+ M && /* @__PURE__ */ n(
403
403
  C,
404
404
  {
405
405
  style: {
@@ -414,229 +414,229 @@ const ue = (e, t, r, d = void 0) => {
414
414
  border: "1px solid var(--gray-a6)",
415
415
  overflow: "hidden"
416
416
  },
417
- children: q ? /* @__PURE__ */ n(C, { p: "3", children: /* @__PURE__ */ n(f, { size: "2", color: "gray", children: q }) }) : /* @__PURE__ */ n(Tr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ p(C, { p: "1", children: [
418
- re && /* @__PURE__ */ n(T, { justify: "center", p: "4", children: /* @__PURE__ */ n(ze, {}) }),
419
- !re && fe && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(f, { size: "2", color: "red", children: fe }) }),
420
- !re && !fe && j.length === 0 && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(f, { size: "2", color: "gray", children: F || v ? "No results found." : "Type to search…" }) }),
421
- j.map((m) => /* @__PURE__ */ n(
417
+ children: I ? /* @__PURE__ */ n(C, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: I }) }) : /* @__PURE__ */ n(Lr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(C, { p: "1", children: [
418
+ Z && /* @__PURE__ */ n(S, { justify: "center", p: "4", children: /* @__PURE__ */ n(Me, {}) }),
419
+ !Z && ue && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: ue }) }),
420
+ !Z && !ue && oe.length === 0 && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: D || v ? "No results found." : "Type to search…" }) }),
421
+ oe.map((d) => /* @__PURE__ */ n(
422
422
  C,
423
423
  {
424
424
  px: "3",
425
425
  py: "2",
426
- onMouseDown: (Z) => Z.preventDefault(),
427
- onClick: () => E(m),
426
+ onMouseDown: (E) => E.preventDefault(),
427
+ onClick: () => De(d),
428
428
  style: {
429
429
  cursor: "pointer",
430
430
  borderRadius: "var(--radius-2)",
431
- backgroundColor: m.id === z ? "var(--accent-3)" : void 0
431
+ backgroundColor: d.id === L ? "var(--accent-3)" : void 0
432
432
  },
433
433
  className: "hover:bg-(--gray-3)",
434
- children: /* @__PURE__ */ n(f, { size: "2", children: m.name })
434
+ children: /* @__PURE__ */ n(h, { size: "2", children: d.name })
435
435
  },
436
- m.id
436
+ d.id
437
437
  )),
438
- (u == null ? void 0 : u.paginated) && $ && !se && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
- Le,
438
+ (m == null ? void 0 : m.paginated) && le && !he && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
+ ke,
440
440
  {
441
441
  variant: "ghost",
442
442
  size: "1",
443
443
  style: { width: "100%" },
444
- onMouseDown: (m) => m.preventDefault(),
445
- onClick: () => void be(F, !0),
444
+ onMouseDown: (d) => d.preventDefault(),
445
+ onClick: () => void we(D, !0),
446
446
  children: "Load more"
447
447
  }
448
448
  ) }),
449
- se && /* @__PURE__ */ n(T, { justify: "center", p: "2", children: /* @__PURE__ */ n(ze, {}) })
449
+ he && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(Me, {}) })
450
450
  ] }) })
451
451
  }
452
452
  )
453
453
  ] }),
454
- !ee && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(a, d) }),
455
- o.description && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: o.description })
454
+ !j && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
455
+ o.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: o.description })
456
456
  ] }) });
457
- }, Zr = oe(Jr), qr = W(
457
+ }, st = se(it), ct = W(
458
458
  3,
459
- Fe((e) => {
459
+ ze((e) => {
460
460
  const t = e["x-search"];
461
461
  return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
462
462
  })
463
- ), jr = (e, t) => Or(`${e}T${t}`).format(), Qr = ({ path: e, label: t, required: r, errors: d, description: g, children: a }) => {
464
- const c = d.length === 0;
465
- return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ p(T, { direction: "column", gap: "1", children: [
466
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
463
+ ), at = (e, t) => $r(`${e}T${t}`).format(), ut = ({ path: e, label: t, required: r, errors: i, description: f, children: s }) => {
464
+ const l = i.length === 0;
465
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
466
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
467
467
  t,
468
468
  " ",
469
- r && /* @__PURE__ */ n(f, { color: "red", children: "*" })
469
+ r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
470
470
  ] }),
471
- a,
472
- !c && /* @__PURE__ */ n(f, { color: "red", size: "1", children: le(d, t) }),
473
- g && /* @__PURE__ */ n(f, { size: "1", color: "gray", children: g })
471
+ s,
472
+ !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(i, t) }),
473
+ f && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f })
474
474
  ] }) });
475
- }, et = ({
475
+ }, dt = ({
476
476
  data: e,
477
477
  handleChange: t,
478
478
  path: r,
479
- label: d,
480
- required: g,
481
- errors: a,
482
- schema: c,
483
- enabled: s,
479
+ label: i,
480
+ required: f,
481
+ errors: s,
482
+ schema: l,
483
+ enabled: a,
484
484
  visible: o = !0
485
485
  }) => {
486
- if (ge(() => {
486
+ if (fe(() => {
487
487
  o === !1 && t(r, void 0);
488
488
  }, [o, r, t]), o === !1)
489
489
  return null;
490
- const i = a.length === 0, l = typeof e == "string" ? e : "", y = (w) => /* @__PURE__ */ n(Qr, { path: r, label: d, required: g, errors: a, description: c.description, children: w });
491
- if (c.format === "time")
490
+ const c = s.length === 0, u = typeof e == "string" ? e : "", y = (w) => /* @__PURE__ */ n(ut, { path: r, label: i, required: f, errors: s, description: l.description, children: w });
491
+ if (l.format === "time")
492
492
  return y(
493
493
  /* @__PURE__ */ n(
494
- ve.Root,
494
+ ye.Root,
495
495
  {
496
496
  type: "time",
497
- value: l,
497
+ value: u,
498
498
  onChange: (w) => t(r, w.target.value),
499
- disabled: !s,
500
- color: i ? void 0 : "red",
499
+ disabled: !a,
500
+ color: c ? void 0 : "red",
501
501
  id: r
502
502
  }
503
503
  )
504
504
  );
505
- const h = c.format === "date-time", [u = "", v = ""] = l.split("T"), M = v.slice(0, 5), A = (w, O) => {
505
+ const p = l.format === "date-time", [m = "", v = ""] = u.split("T"), N = v.slice(0, 5), A = (w, R) => {
506
506
  if (!w) {
507
507
  t(r, void 0);
508
508
  return;
509
509
  }
510
- t(r, h ? jr(w, O || "00:00") : w);
510
+ t(r, p ? at(w, R || "00:00") : w);
511
511
  };
512
512
  return y(
513
- /* @__PURE__ */ p(T, { gap: "2", align: "center", children: [
513
+ /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
514
514
  /* @__PURE__ */ n(
515
- ve.Root,
515
+ ye.Root,
516
516
  {
517
517
  type: "date",
518
- value: u,
519
- disabled: !s,
520
- color: i ? void 0 : "red",
521
- onChange: (w) => A(w.target.value, M),
518
+ value: m,
519
+ disabled: !a,
520
+ color: c ? void 0 : "red",
521
+ onChange: (w) => A(w.target.value, N),
522
522
  id: r,
523
523
  style: { flex: 1 }
524
524
  }
525
525
  ),
526
- h && /* @__PURE__ */ n(
527
- ve.Root,
526
+ p && /* @__PURE__ */ n(
527
+ ye.Root,
528
528
  {
529
529
  type: "time",
530
- value: M,
531
- disabled: !s || !u,
532
- color: i ? void 0 : "red",
533
- onChange: (w) => A(u, w.target.value),
530
+ value: N,
531
+ disabled: !a || !m,
532
+ color: c ? void 0 : "red",
533
+ onChange: (w) => A(m, w.target.value),
534
534
  style: { flex: 1 }
535
535
  }
536
536
  )
537
537
  ] })
538
538
  );
539
- }, rt = W(2, Me(gr, mr, yr)), tt = oe(et), nt = ({
539
+ }, ft = W(2, Le(Rr, Cr, Tr)), ht = se(dt), pt = ({
540
540
  uischema: e,
541
541
  schema: t,
542
542
  path: r,
543
- renderers: d,
544
- cells: g,
545
- enabled: a,
546
- visible: c = !0
543
+ renderers: i,
544
+ cells: f,
545
+ enabled: s,
546
+ visible: l = !0
547
547
  }) => {
548
548
  const o = e.elements;
549
- return c === !1 ? null : /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(
550
- Se,
549
+ return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
550
+ Ae,
551
551
  {
552
- uischema: i,
552
+ uischema: c,
553
553
  schema: t,
554
554
  path: r,
555
- renderers: d,
556
- cells: g,
557
- enabled: a
555
+ renderers: i,
556
+ cells: f,
557
+ enabled: s
558
558
  },
559
- `${r}-${l}`
559
+ `${r}-${u}`
560
560
  )) });
561
- }, ot = W(1, Ae("VerticalLayout")), lt = ({
561
+ }, mt = W(1, Te("VerticalLayout")), gt = ({
562
562
  uischema: e,
563
563
  schema: t,
564
564
  path: r,
565
- renderers: d,
566
- cells: g,
567
- enabled: a,
568
- visible: c = !0
565
+ renderers: i,
566
+ cells: f,
567
+ enabled: s,
568
+ visible: l = !0
569
569
  }) => {
570
570
  const o = e.elements;
571
- return c === !1 ? null : /* @__PURE__ */ n(T, { direction: "row", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(
572
- Se,
571
+ return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "row", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(
572
+ Ae,
573
573
  {
574
- uischema: i,
574
+ uischema: c,
575
575
  schema: t,
576
576
  path: r,
577
- renderers: d,
578
- cells: g,
579
- enabled: a
577
+ renderers: i,
578
+ cells: f,
579
+ enabled: s
580
580
  }
581
- ) }, `${r}-${l}`)) });
582
- }, it = W(1, Ae("HorizontalLayout")), st = ({
581
+ ) }, `${r}-${u}`)) });
582
+ }, yt = W(1, Te("HorizontalLayout")), vt = ({
583
583
  uischema: e,
584
584
  schema: t,
585
585
  path: r,
586
- renderers: d,
587
- cells: g,
588
- enabled: a,
589
- visible: c = !0
586
+ renderers: i,
587
+ cells: f,
588
+ enabled: s,
589
+ visible: l = !0
590
590
  }) => {
591
- const s = e, o = s.elements;
592
- return c === !1 ? null : /* @__PURE__ */ p(C, { mb: "6", children: [
593
- s.label && /* @__PURE__ */ n(qe, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: s.label }),
594
- /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(
595
- Se,
591
+ const a = e, o = a.elements;
592
+ return l === !1 ? null : /* @__PURE__ */ g(C, { mb: "6", children: [
593
+ a.label && /* @__PURE__ */ n(tr, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: a.label }),
594
+ /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
595
+ Ae,
596
596
  {
597
- uischema: i,
597
+ uischema: c,
598
598
  schema: t,
599
599
  path: r,
600
- renderers: d,
601
- cells: g,
602
- enabled: a
600
+ renderers: i,
601
+ cells: f,
602
+ enabled: s
603
603
  },
604
- `${r}-${l}`
604
+ `${r}-${u}`
605
605
  )) })
606
606
  ] });
607
- }, ct = W(1, Ae("Group")), at = ({
607
+ }, bt = W(1, Te("Group")), wt = ({
608
608
  uischema: e,
609
609
  schema: t,
610
610
  path: r,
611
- renderers: d,
612
- cells: g,
613
- enabled: a,
614
- visible: c = !0
611
+ renderers: i,
612
+ cells: f,
613
+ enabled: s,
614
+ visible: l = !0
615
615
  }) => {
616
- var h;
617
- const o = e.elements.filter((u) => u.type === "Category"), [i, l] = _(((h = o[0]) == null ? void 0 : h.label) || "");
618
- if (c === !1 || !o.length) return null;
619
- const y = o.find((u) => u.label === i) ? i : o[0].label;
620
- return /* @__PURE__ */ p(Ie.Root, { value: y, onValueChange: l, children: [
621
- /* @__PURE__ */ n(Ie.List, { children: o.map((u, v) => /* @__PURE__ */ n(Ie.Trigger, { value: u.label, children: u.label }, `${r}-${v}`)) }),
622
- /* @__PURE__ */ n(C, { pt: "3", children: o.map((u, v) => /* @__PURE__ */ n(Ie.Content, { value: u.label, children: /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: u.elements.map((M, A) => /* @__PURE__ */ n(
623
- Se,
616
+ var p;
617
+ const o = e.elements.filter((m) => m.type === "Category"), [c, u] = F(((p = o[0]) == null ? void 0 : p.label) || "");
618
+ if (l === !1 || !o.length) return null;
619
+ const y = o.find((m) => m.label === c) ? c : o[0].label;
620
+ return /* @__PURE__ */ g(Ie.Root, { value: y, onValueChange: u, children: [
621
+ /* @__PURE__ */ n(Ie.List, { children: o.map((m, v) => /* @__PURE__ */ n(Ie.Trigger, { value: m.label, children: m.label }, `${r}-${v}`)) }),
622
+ /* @__PURE__ */ n(C, { pt: "3", children: o.map((m, v) => /* @__PURE__ */ n(Ie.Content, { value: m.label, children: /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: m.elements.map((N, A) => /* @__PURE__ */ n(
623
+ Ae,
624
624
  {
625
- uischema: M,
625
+ uischema: N,
626
626
  schema: t,
627
627
  path: r,
628
- renderers: d,
629
- cells: g,
630
- enabled: a
628
+ renderers: i,
629
+ cells: f,
630
+ enabled: s
631
631
  },
632
632
  `${r}-${v}-${A}`
633
633
  )) }) }, `${r}-${v}`)) })
634
634
  ] });
635
- }, dt = W(1, Ae("Categorization"));
635
+ }, Et = W(1, Te("Categorization"));
636
636
  function me(e) {
637
637
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
638
638
  }
639
- function ye(e) {
639
+ function ge(e) {
640
640
  return e.split(",").map((t) => {
641
641
  if (t = t.trim(), t.endsWith("/*"))
642
642
  return t.split("/")[0].toUpperCase() + "S";
@@ -646,107 +646,107 @@ function ye(e) {
646
646
  return r ? r.toUpperCase() : t;
647
647
  }).join(", ");
648
648
  }
649
- function ut(e) {
649
+ function Rt(e) {
650
650
  return e ? Array.isArray(e) ? e : [e] : [];
651
651
  }
652
- const ft = ({
652
+ const Ct = ({
653
653
  data: e,
654
654
  handleChange: t,
655
655
  path: r,
656
- label: d,
657
- required: g,
658
- uischema: a,
659
- schema: c,
660
- enabled: s,
656
+ label: i,
657
+ required: f,
658
+ uischema: s,
659
+ schema: l,
660
+ enabled: a,
661
661
  errors: o,
662
- visible: i = !0
662
+ visible: c = !0
663
663
  }) => {
664
- const l = Lr();
665
- ue(i, r, t, null);
666
- const y = !o || o.length === 0, h = (c == null ? void 0 : c["x-file"]) ?? {}, u = (a == null ? void 0 : a.options) ?? {}, v = h.maxFiles ?? u.maxFiles ?? 1, M = h.maxSize ?? u.maxSize ?? 5 * 1024 * 1024, A = h.accept ?? u.accept ?? "image/*,application/pdf", w = v > 1, O = s !== !1, [z, S] = _(!1), [q, P] = _(null), [ee, x] = _({}), J = de(/* @__PURE__ */ new Set()), F = de(null), V = ut(e), j = V.length >= v;
667
- ge(() => () => {
668
- J.current.forEach((b) => URL.revokeObjectURL(b)), J.current.clear();
664
+ const u = Vr();
665
+ ce(c, r, t, null);
666
+ const y = !o || o.length === 0, p = (l == null ? void 0 : l["x-file"]) ?? {}, m = (s == null ? void 0 : s.options) ?? {}, v = p.maxFiles ?? m.maxFiles ?? 1, N = p.maxSize ?? m.maxSize ?? 5 * 1024 * 1024, A = p.accept ?? m.accept ?? "image/*,application/pdf", w = v > 1, R = a !== !1, [L, P] = F(!1), [I, B] = F(null), [j, M] = F({}), O = de(/* @__PURE__ */ new Set()), D = de(null), V = Rt(e), oe = V.length >= v;
667
+ fe(() => () => {
668
+ O.current.forEach((b) => URL.revokeObjectURL(b)), O.current.clear();
669
669
  }, []);
670
- const K = ke(
670
+ const ee = _e(
671
671
  async (b) => {
672
- if (P(null), V.length >= v) {
673
- P(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
672
+ if (B(null), V.length >= v) {
673
+ B(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
674
674
  return;
675
675
  }
676
- if (b.size > M) {
677
- P(`File exceeds the ${me(M)} limit.`);
676
+ if (b.size > N) {
677
+ B(`File exceeds the ${me(N)} limit.`);
678
678
  return;
679
679
  }
680
- if (!A.split(",").map((R) => R.trim()).some((R) => R === "*" || R === "*/*" ? !0 : R.endsWith("/*") ? b.type.startsWith(R.slice(0, -1)) : R.startsWith(".") ? b.name.toLowerCase().endsWith(R.toLowerCase()) : b.type === R)) {
681
- P(`Invalid type. Accepted: ${ye(A)}`);
680
+ if (!A.split(",").map((T) => T.trim()).some((T) => T === "*" || T === "*/*" ? !0 : T.endsWith("/*") ? b.type.startsWith(T.slice(0, -1)) : T.startsWith(".") ? b.name.toLowerCase().endsWith(T.toLowerCase()) : b.type === T)) {
681
+ B(`Invalid type. Accepted: ${ge(A)}`);
682
682
  return;
683
683
  }
684
- if (!(l != null && l.onUpload)) {
685
- P("Upload service not configured.");
684
+ if (!(u != null && u.onUpload)) {
685
+ B("Upload service not configured.");
686
686
  return;
687
687
  }
688
688
  try {
689
- const R = await l.onUpload(b), U = URL.createObjectURL(b);
690
- J.current.add(U);
691
- const G = { key: R.key, name: R.name ?? b.name, blobUrl: U };
692
- x((B) => ({ ...B, [R.key]: G }));
693
- const Y = [...V, R.key];
694
- t(r, w ? Y : Y[0]);
689
+ const T = await u.onUpload(b), H = URL.createObjectURL(b);
690
+ O.current.add(H);
691
+ const J = { key: T.key, name: T.name ?? b.name, blobUrl: H };
692
+ M((K) => ({ ...K, [T.key]: J }));
693
+ const Q = [...V, T.key];
694
+ t(r, w ? Q : Q[0]);
695
695
  } catch {
696
- P("Upload failed. Please try again."), F.current && (F.current.value = "");
696
+ B("Upload failed. Please try again."), D.current && (D.current.value = "");
697
697
  }
698
698
  },
699
- [V, v, M, A, l, r, t, w]
699
+ [V, v, N, A, u, r, t, w]
700
700
  );
701
- if (i === !1)
701
+ if (c === !1)
702
702
  return null;
703
- const $ = (b) => {
704
- b.preventDefault(), b.stopPropagation(), !(!O || j) && S(b.type === "dragenter" || b.type === "dragover");
705
- }, Q = (b) => {
706
- var I;
707
- b.preventDefault(), b.stopPropagation(), S(!1), !(!O || j) && (I = b.dataTransfer.files) != null && I[0] && K(b.dataTransfer.files[0]);
703
+ const le = (b) => {
704
+ b.preventDefault(), b.stopPropagation(), !(!R || oe) && P(b.type === "dragenter" || b.type === "dragover");
705
+ }, Y = (b) => {
706
+ var k;
707
+ b.preventDefault(), b.stopPropagation(), P(!1), !(!R || oe) && (k = b.dataTransfer.files) != null && k[0] && ee(b.dataTransfer.files[0]);
708
+ }, Z = (b) => {
709
+ var k;
710
+ (k = b.target.files) != null && k[0] && (ee(b.target.files[0]), b.target.value = "");
708
711
  }, re = (b) => {
709
- var I;
710
- (I = b.target.files) != null && I[0] && (K(b.target.files[0]), b.target.value = "");
711
- }, ie = (b) => {
712
- if (!O) return;
713
- x((D) => {
714
- var G;
715
- const R = { ...D }, U = (G = R[b]) == null ? void 0 : G.blobUrl;
716
- return U && (URL.revokeObjectURL(U), J.current.delete(U)), delete R[b], R;
712
+ if (!R) return;
713
+ M((U) => {
714
+ var J;
715
+ const T = { ...U }, H = (J = T[b]) == null ? void 0 : J.blobUrl;
716
+ return H && (URL.revokeObjectURL(H), O.current.delete(H)), delete T[b], T;
717
717
  });
718
- const I = V.filter((D) => D !== b);
719
- t(r, w ? I.length > 0 ? I : null : I[0] ?? null);
720
- }, se = async (b, I) => {
721
- var U, G, Y;
718
+ const k = V.filter((U) => U !== b);
719
+ t(r, w ? k.length > 0 ? k : null : k[0] ?? null);
720
+ }, he = async (b, k) => {
721
+ var H, J, Q;
722
722
  b.preventDefault();
723
- const D = (U = ee[I]) == null ? void 0 : U.blobUrl;
724
- if (D) {
725
- (G = window.open(D, "_blank", "noopener,noreferrer")) == null || G.focus();
723
+ const U = (H = j[k]) == null ? void 0 : H.blobUrl;
724
+ if (U) {
725
+ (J = window.open(U, "_blank", "noopener,noreferrer")) == null || J.focus();
726
726
  return;
727
727
  }
728
- const R = window.open("", "_blank");
729
- if (R)
728
+ const T = window.open("", "_blank");
729
+ if (T)
730
730
  try {
731
- const B = await ((Y = l == null ? void 0 : l.getDownloadUrl) == null ? void 0 : Y.call(l, I));
732
- B != null && B.url ? R.location.href = B.url : R.close();
731
+ const K = await ((Q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : Q.call(u, k));
732
+ K != null && K.url ? T.location.href = K.url : T.close();
733
733
  } catch {
734
- R.close();
734
+ T.close();
735
735
  }
736
736
  };
737
- if (!O && V.length === 0) return null;
738
- const ce = v - V.length, fe = O && !j;
739
- return /* @__PURE__ */ p(C, { mb: "4", children: [
740
- /* @__PURE__ */ p(T, { align: "center", justify: "between", mb: "2", children: [
741
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", children: [
742
- d,
743
- g && /* @__PURE__ */ n(f, { color: "red", children: " *" })
737
+ if (!R && V.length === 0) return null;
738
+ const ne = v - V.length, ue = R && !oe;
739
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
740
+ /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
741
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
742
+ i,
743
+ f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
744
744
  ] }),
745
- /* @__PURE__ */ n(f, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(M)} each · ${ye(A)}` : `${me(M)} · ${ye(A)}` })
745
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(N)} each · ${ge(A)}` : `${me(N)} · ${ge(A)}` })
746
746
  ] }),
747
747
  V.map((b) => {
748
- var I;
749
- return /* @__PURE__ */ n($e, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ p(T, { align: "center", gap: "3", children: [
748
+ var k;
749
+ return /* @__PURE__ */ n(nr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
750
750
  /* @__PURE__ */ n(
751
751
  C,
752
752
  {
@@ -757,11 +757,11 @@ const ft = ({
757
757
  color: "var(--blue-9)",
758
758
  flexShrink: 0
759
759
  },
760
- children: /* @__PURE__ */ n(Qe, { width: "20", height: "20" })
760
+ children: /* @__PURE__ */ n(Dr, { width: "20", height: "20" })
761
761
  }
762
762
  ),
763
763
  /* @__PURE__ */ n(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
764
- f,
764
+ h,
765
765
  {
766
766
  size: "2",
767
767
  weight: "bold",
@@ -771,70 +771,70 @@ const ft = ({
771
771
  textOverflow: "ellipsis",
772
772
  whiteSpace: "nowrap"
773
773
  },
774
- children: ((I = ee[b]) == null ? void 0 : I.name) ?? "Uploaded File"
774
+ children: ((k = j[b]) == null ? void 0 : k.name) ?? "Uploaded File"
775
775
  }
776
776
  ) }),
777
- /* @__PURE__ */ p(T, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
778
- /* @__PURE__ */ n(Le, { variant: "soft", color: "blue", size: "1", onClick: (D) => se(D, b), children: "View" }),
779
- /* @__PURE__ */ n(er, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
780
- O && /* @__PURE__ */ n(je, { variant: "ghost", color: "gray", onClick: () => ie(b), children: /* @__PURE__ */ n(rr, {}) })
777
+ /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
778
+ /* @__PURE__ */ n(ke, { variant: "soft", color: "blue", size: "1", onClick: (U) => he(U, b), children: "View" }),
779
+ /* @__PURE__ */ n(Fr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
780
+ R && /* @__PURE__ */ n(Ue, { variant: "ghost", color: "gray", onClick: () => re(b), children: /* @__PURE__ */ n(or, {}) })
781
781
  ] })
782
782
  ] }) }, b);
783
783
  }),
784
- fe && /* @__PURE__ */ p(
784
+ ue && /* @__PURE__ */ g(
785
785
  "div",
786
786
  {
787
787
  role: "button",
788
788
  tabIndex: 0,
789
789
  onClick: () => {
790
790
  var b;
791
- return (b = F.current) == null ? void 0 : b.click();
791
+ return (b = D.current) == null ? void 0 : b.click();
792
792
  },
793
793
  onKeyDown: (b) => {
794
- var I;
795
- (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (I = F.current) == null || I.click());
794
+ var k;
795
+ (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (k = D.current) == null || k.click());
796
796
  },
797
- onDragEnter: $,
798
- onDragLeave: $,
799
- onDragOver: $,
800
- onDrop: Q,
797
+ onDragEnter: le,
798
+ onDragLeave: le,
799
+ onDragOver: le,
800
+ onDrop: Y,
801
801
  style: { cursor: "pointer" },
802
802
  className: [
803
803
  "border-2 border-dashed rounded-lg p-6 text-center",
804
804
  "transition-all duration-200 ease-in-out",
805
- z ? "border-blue-500 bg-blue-50" : q ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
805
+ L ? "border-blue-500 bg-blue-50" : I ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
806
806
  ].join(" "),
807
807
  children: [
808
- /* @__PURE__ */ n("input", { ref: F, type: "file", style: { display: "none" }, accept: A, onChange: re }),
809
- /* @__PURE__ */ n(T, { direction: "column", align: "center", gap: "2", children: q ? /* @__PURE__ */ p(Te, { children: [
810
- /* @__PURE__ */ n(tr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
811
- /* @__PURE__ */ n(f, { size: "2", color: "red", weight: "medium", children: q }),
812
- /* @__PURE__ */ n(f, { size: "1", color: "gray", children: "Click to try again" })
813
- ] }) : /* @__PURE__ */ p(Te, { children: [
814
- /* @__PURE__ */ n(nr, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
815
- /* @__PURE__ */ n(f, { size: "2", weight: "medium", children: V.length > 0 ? `Add another file (${ce} remaining)` : "Click to upload or drag and drop" }),
816
- /* @__PURE__ */ p(f, { size: "1", color: "gray", children: [
817
- me(M),
808
+ /* @__PURE__ */ n("input", { ref: D, type: "file", style: { display: "none" }, accept: A, onChange: Z }),
809
+ /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: I ? /* @__PURE__ */ g(be, { children: [
810
+ /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
811
+ /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: I }),
812
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
813
+ ] }) : /* @__PURE__ */ g(be, { children: [
814
+ /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
815
+ /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: V.length > 0 ? `Add another file (${ne} remaining)` : "Click to upload or drag and drop" }),
816
+ /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
817
+ me(N),
818
818
  " max · ",
819
- ye(A)
819
+ ge(A)
820
820
  ] })
821
821
  ] }) })
822
822
  ]
823
823
  }
824
824
  ),
825
- O && j && w && /* @__PURE__ */ p(f, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
825
+ R && oe && w && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
826
826
  "Maximum ",
827
827
  v,
828
828
  " files uploaded. Remove one to replace it."
829
829
  ] }),
830
- !y && /* @__PURE__ */ n(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: le(o, d) })
830
+ !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
831
831
  ] });
832
- }, ht = oe(ft), pt = W(
832
+ }, Tt = se(Ct), At = W(
833
833
  10,
834
834
  // high rank to beat default array renderer
835
- vr(
835
+ Ar(
836
836
  // Match both single-file (type: string) and multi-file (type: array)
837
- Fe((e) => {
837
+ ze((e) => {
838
838
  if (e.type === "string" && e.format === "file") return !0;
839
839
  if (e.type === "array") {
840
840
  const t = e.items;
@@ -844,39 +844,42 @@ const ft = ({
844
844
  })
845
845
  )
846
846
  );
847
- class Ue extends Error {
847
+ function St(e, t) {
848
+ return e !== !1 && t !== !0;
848
849
  }
849
- function gt(e, t) {
850
- const r = Ir(e, { type: "array", cellDates: !0 });
850
+ class $e extends Error {
851
+ }
852
+ function Ot(e, t) {
853
+ const r = _r(e, { type: "array", cellDates: !0 });
851
854
  if (r.SheetNames.length === 0)
852
- throw new Ue("This file has no sheets.");
853
- const d = t ?? r.SheetNames[0], g = r.Sheets[d];
854
- if (!g)
855
- throw new Ue(`This file doesn't have a sheet named "${d}".`);
856
- const a = xr.sheet_to_json(g, { header: 1, raw: !0, defval: null });
855
+ throw new $e("This file has no sheets.");
856
+ const i = t ?? r.SheetNames[0], f = r.Sheets[i];
857
+ if (!f)
858
+ throw new $e(`This file doesn't have a sheet named "${i}".`);
859
+ const s = Pr.sheet_to_json(f, { header: 1, raw: !0, defval: null });
857
860
  return {
858
- sheetName: d,
859
- matrix: a,
860
- rowCount: a.length,
861
- colCount: Math.max(0, ...a.map((c) => c.length))
861
+ sheetName: i,
862
+ matrix: s,
863
+ rowCount: s.length,
864
+ colCount: Math.max(0, ...s.map((l) => l.length))
862
865
  };
863
866
  }
864
- function mt(e) {
867
+ function Nt(e) {
865
868
  let t = e + 1, r = "";
866
869
  for (; t > 0; ) {
867
- const d = (t - 1) % 26;
868
- r = String.fromCharCode(65 + d) + r, t = Math.floor((t - 1) / 26);
870
+ const i = (t - 1) % 26;
871
+ r = String.fromCharCode(65 + i) + r, t = Math.floor((t - 1) / 26);
869
872
  }
870
873
  return r;
871
874
  }
872
875
  class X extends Error {
873
- constructor(r, d) {
874
- super(d ?? r);
876
+ constructor(r, i) {
877
+ super(i ?? r);
875
878
  Pe(this, "code");
876
879
  this.code = r, this.name = "FormulaError";
877
880
  }
878
881
  }
879
- const yt = [
882
+ const It = [
880
883
  // Logical
881
884
  // IF is excluded here even though its native body is real, non-stub code —
882
885
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -902,7 +905,7 @@ const yt = [
902
905
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
903
906
  "DATE",
904
907
  "TODAY"
905
- ], vt = [
908
+ ], xt = [
906
909
  "MAX",
907
910
  "MIN",
908
911
  "MAXA",
@@ -921,7 +924,7 @@ const yt = [
921
924
  "COUNTA",
922
925
  // not present in fast-formula-parser's function table at all.
923
926
  "UPPER"
924
- ], bt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Et = ["IF"], wt = [
927
+ ], Mt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], kt = ["IF"], Lt = [
925
928
  "CONCATENATE",
926
929
  "CONCAT",
927
930
  "LEN",
@@ -932,115 +935,115 @@ const yt = [
932
935
  "MID",
933
936
  "FIND",
934
937
  "SEARCH"
935
- ], Rt = /* @__PURE__ */ new Set([
936
- ...yt,
937
- ...vt,
938
- ...bt,
939
- ...wt,
940
- ...Et
941
- ]), Ct = /"(?:[^"]|"")*"/g, He = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
942
- function Tt(e) {
943
- const t = e.replace(Ct, (d) => " ".repeat(d.length));
944
- He.lastIndex = 0;
938
+ ], zt = /* @__PURE__ */ new Set([
939
+ ...It,
940
+ ...xt,
941
+ ...Mt,
942
+ ...Lt,
943
+ ...kt
944
+ ]), Dt = /"(?:[^"]|"")*"/g, Be = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
945
+ function Ft(e) {
946
+ const t = e.replace(Dt, (i) => " ".repeat(i.length));
947
+ Be.lastIndex = 0;
945
948
  let r;
946
- for (; (r = He.exec(t)) !== null; ) {
947
- const d = r[1].toUpperCase();
948
- if (!Rt.has(d))
949
- throw new X("NAME", `Function ${d} is not allowed.`);
949
+ for (; (r = Be.exec(t)) !== null; ) {
950
+ const i = r[1].toUpperCase();
951
+ if (!zt.has(i))
952
+ throw new X("NAME", `Function ${i} is not allowed.`);
950
953
  }
951
954
  }
952
- function At(e, t, r) {
953
- let d = e;
954
- if (d == null) throw r.NA;
955
- if (typeof d == "object" && !(d instanceof r) && (d = t.retrieveRef(d)), d instanceof r) throw d;
956
- if (typeof d == "boolean") return d;
957
- if (typeof d == "number") return d !== 0;
955
+ function Ut(e, t, r) {
956
+ let i = e;
957
+ if (i == null) throw r.NA;
958
+ if (typeof i == "object" && !(i instanceof r) && (i = t.retrieveRef(i)), i instanceof r) throw i;
959
+ if (typeof i == "boolean") return i;
960
+ if (typeof i == "number") return i !== 0;
958
961
  throw r.VALUE;
959
962
  }
960
- function ir(e) {
963
+ function cr(e) {
961
964
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
962
965
  }
963
966
  function pe(e) {
964
- const t = ir(e);
967
+ const t = cr(e);
965
968
  return Array.isArray(t) ? t.flat(1 / 0) : [t];
966
969
  }
967
- function N(e) {
968
- const t = ir(e);
970
+ function x(e) {
971
+ const t = cr(e);
969
972
  return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
970
973
  }
971
974
  function xe(e) {
972
- return e === void 0 ? void 0 : N(e);
975
+ return e === void 0 ? void 0 : x(e);
973
976
  }
974
- function H(e) {
977
+ function G(e) {
975
978
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
976
979
  }
977
- function St(e, t) {
980
+ function Ht(e, t) {
978
981
  return e instanceof t ? e : new t(e.message || "#ERROR!");
979
982
  }
980
- function k(e) {
983
+ function _(e) {
981
984
  return e.find((t) => t instanceof Error);
982
985
  }
983
- function Nt(e, t) {
984
- const r = (a) => {
985
- throw St(a, t);
986
- }, d = (a, { checkArgsForErrors: c = !0 } = {}) => (...s) => {
987
- const o = s.flatMap(pe);
988
- if (c) {
989
- const l = k(o);
990
- l && r(l);
986
+ function $t(e, t) {
987
+ const r = (s) => {
988
+ throw Ht(s, t);
989
+ }, i = (s, { checkArgsForErrors: l = !0 } = {}) => (...a) => {
990
+ const o = a.flatMap(pe);
991
+ if (l) {
992
+ const u = _(o);
993
+ u && r(u);
991
994
  }
992
- const i = a(...o);
993
- return i instanceof Error ? r(i) : i;
994
- }, g = (a, { toText: c = !1 } = {}) => (s) => {
995
- const o = N(s), i = k([o]);
996
- i && r(i);
997
- const l = a(c ? H(o) : o);
998
- return l instanceof Error ? r(l) : l;
995
+ const c = s(...o);
996
+ return c instanceof Error ? r(c) : c;
997
+ }, f = (s, { toText: l = !1 } = {}) => (a) => {
998
+ const o = x(a), c = _([o]);
999
+ c && r(c);
1000
+ const u = s(l ? G(o) : o);
1001
+ return u instanceof Error ? r(u) : u;
999
1002
  };
1000
1003
  return {
1001
1004
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
1002
1005
  // dereferenced or type-checked here) — that's what makes
1003
1006
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
1004
- IF: (a, c, s, o) => {
1005
- const i = At(c, a, t);
1006
- if (s == null) throw t.NA;
1007
- return i ? s : o ?? !1;
1007
+ IF: (s, l, a, o) => {
1008
+ const c = Ut(l, s, t);
1009
+ if (a == null) throw t.NA;
1010
+ return c ? a : o ?? !1;
1008
1011
  },
1009
1012
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1010
1013
  // and formulajs's own convention for MAX/MIN.
1011
- MAX: d(e.MAX),
1012
- MIN: d(e.MIN),
1013
- MAXA: d(e.MAXA),
1014
- MINA: d(e.MINA),
1015
- MEDIAN: d(e.MEDIAN),
1014
+ MAX: i(e.MAX),
1015
+ MIN: i(e.MIN),
1016
+ MAXA: i(e.MAXA),
1017
+ MINA: i(e.MINA),
1018
+ MEDIAN: i(e.MEDIAN),
1016
1019
  // COUNTA counts non-blank entries; an error value among the args is
1017
1020
  // itself non-blank and gets counted (matching formulajs's own COUNTA,
1018
1021
  // which never checks for errors), so this skips the error propagation
1019
1022
  // the other aggregates use.
1020
- COUNTA: d(e.COUNTA, { checkArgsForErrors: !1 }),
1021
- LARGE: (a, c) => {
1022
- const s = pe(a), o = N(c), i = k([...s, o]);
1023
- i && r(i);
1024
- const l = e.LARGE(s, o);
1025
- return l instanceof Error ? r(l) : l;
1023
+ COUNTA: i(e.COUNTA, { checkArgsForErrors: !1 }),
1024
+ LARGE: (s, l) => {
1025
+ const a = pe(s), o = x(l), c = _([...a, o]);
1026
+ c && r(c);
1027
+ const u = e.LARGE(a, o);
1028
+ return u instanceof Error ? r(u) : u;
1026
1029
  },
1027
- SMALL: (a, c) => {
1028
- const s = pe(a), o = N(c), i = k([...s, o]);
1029
- i && r(i);
1030
- const l = e.SMALL(s, o);
1031
- return l instanceof Error ? r(l) : l;
1030
+ SMALL: (s, l) => {
1031
+ const a = pe(s), o = x(l), c = _([...a, o]);
1032
+ c && r(c);
1033
+ const u = e.SMALL(a, o);
1034
+ return u instanceof Error ? r(u) : u;
1032
1035
  },
1033
- PERMUT: (a, c) => {
1034
- const s = [N(a), N(c)], o = k(s);
1036
+ PERMUT: (s, l) => {
1037
+ const a = [x(s), x(l)], o = _(a);
1035
1038
  o && r(o);
1036
- const i = e.PERMUT(s[0], s[1]);
1037
- return i instanceof Error ? r(i) : i;
1039
+ const c = e.PERMUT(a[0], a[1]);
1040
+ return c instanceof Error ? r(c) : c;
1038
1041
  },
1039
- PERMUTATIONA: (a, c) => {
1040
- const s = [N(a), N(c)], o = k(s);
1042
+ PERMUTATIONA: (s, l) => {
1043
+ const a = [x(s), x(l)], o = _(a);
1041
1044
  o && r(o);
1042
- const i = e.PERMUTATIONA(s[0], s[1]);
1043
- return i instanceof Error ? r(i) : i;
1045
+ const c = e.PERMUTATIONA(a[0], a[1]);
1046
+ return c instanceof Error ? r(c) : c;
1044
1047
  },
1045
1048
  // match_type is intentionally ignored and forced to 0 (exact match)
1046
1049
  // regardless of what the formula author supplied — approximate/sorted
@@ -1048,43 +1051,43 @@ function Nt(e, t) {
1048
1051
  // Excel's own default too) risks silently mis-ranking unsorted
1049
1052
  // real-world data. Same scope decision as the hand-rolled engine this
1050
1053
  // replaces, carried forward deliberately rather than dropped.
1051
- MATCH: (a, c) => {
1052
- const s = N(a), o = pe(c), i = k([s, ...o]);
1053
- i && r(i);
1054
- const l = e.MATCH(s, o, 0);
1055
- return l instanceof Error ? r(l) : l;
1054
+ MATCH: (s, l) => {
1055
+ const a = x(s), o = pe(l), c = _([a, ...o]);
1056
+ c && r(c);
1057
+ const u = e.MATCH(a, o, 0);
1058
+ return u instanceof Error ? r(u) : u;
1056
1059
  },
1057
- SWITCH: (...a) => {
1058
- const c = a.map(N), s = k(c);
1059
- s && r(s);
1060
- const o = e.SWITCH(...c);
1060
+ SWITCH: (...s) => {
1061
+ const l = s.map(x), a = _(l);
1062
+ a && r(a);
1063
+ const o = e.SWITCH(...l);
1061
1064
  return o instanceof Error ? r(o) : o;
1062
1065
  },
1063
- SUBSTITUTE: (a, c, s, o) => {
1064
- const i = [H(N(a)), H(N(c)), H(N(s))];
1065
- o !== void 0 && i.push(N(o));
1066
- const l = k(i);
1067
- l && r(l);
1068
- const y = e.SUBSTITUTE(...i);
1066
+ SUBSTITUTE: (s, l, a, o) => {
1067
+ const c = [G(x(s)), G(x(l)), G(x(a))];
1068
+ o !== void 0 && c.push(x(o));
1069
+ const u = _(c);
1070
+ u && r(u);
1071
+ const y = e.SUBSTITUTE(...c);
1069
1072
  return y instanceof Error ? r(y) : y;
1070
1073
  },
1071
- TEXTJOIN: (a, c, ...s) => {
1072
- const o = H(N(a)), i = N(c), l = s.flatMap(pe).map(H), y = k([o, i]);
1074
+ TEXTJOIN: (s, l, ...a) => {
1075
+ const o = G(x(s)), c = x(l), u = a.flatMap(pe).map(G), y = _([o, c]);
1073
1076
  y && r(y);
1074
- const h = e.TEXTJOIN(o, i, l);
1075
- return h instanceof Error ? r(h) : h;
1077
+ const p = e.TEXTJOIN(o, c, u);
1078
+ return p instanceof Error ? r(p) : p;
1076
1079
  },
1077
- UPPER: g(e.UPPER),
1080
+ UPPER: f(e.UPPER),
1078
1081
  // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
1079
1082
  // fast-formula-parser's own (real, but broken-for-Date-cells) versions.
1080
- YEAR: g(e.YEAR),
1081
- MONTH: g(e.MONTH),
1082
- DAY: g(e.DAY),
1083
- WEEKDAY: (a, c) => {
1084
- const s = N(a), o = N(c), i = k([s]);
1085
- i && r(i);
1086
- const l = e.WEEKDAY(s, o);
1087
- return l instanceof Error ? r(l) : l;
1083
+ YEAR: f(e.YEAR),
1084
+ MONTH: f(e.MONTH),
1085
+ DAY: f(e.DAY),
1086
+ WEEKDAY: (s, l) => {
1087
+ const a = x(s), o = x(l), c = _([a]);
1088
+ c && r(c);
1089
+ const u = e.WEEKDAY(a, o);
1090
+ return u instanceof Error ? r(u) : u;
1088
1091
  },
1089
1092
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1090
1093
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1095,54 +1098,54 @@ function Nt(e, t) {
1095
1098
  // Flattens every argument (a whole range included) and joins with no
1096
1099
  // separator, matching Excel's own range-argument behavior — the native
1097
1100
  // implementation instead inserts stray commas for a whole-range argument.
1098
- CONCATENATE: (...a) => {
1099
- const c = a.flatMap(pe), s = k(c);
1100
- s && r(s);
1101
- const o = e.CONCATENATE(...c.map(H));
1101
+ CONCATENATE: (...s) => {
1102
+ const l = s.flatMap(pe), a = _(l);
1103
+ a && r(a);
1104
+ const o = e.CONCATENATE(...l.map(G));
1102
1105
  return o instanceof Error ? r(o) : o;
1103
1106
  },
1104
- CONCAT: (...a) => {
1105
- const c = a.flatMap(pe), s = k(c);
1106
- s && r(s);
1107
- const o = e.CONCAT(...c.map(H));
1107
+ CONCAT: (...s) => {
1108
+ const l = s.flatMap(pe), a = _(l);
1109
+ a && r(a);
1110
+ const o = e.CONCAT(...l.map(G));
1108
1111
  return o instanceof Error ? r(o) : o;
1109
1112
  },
1110
- LEN: g(e.LEN, { toText: !0 }),
1111
- TRIM: g(e.TRIM, { toText: !0 }),
1112
- LOWER: g(e.LOWER, { toText: !0 }),
1113
- LEFT: (a, c) => {
1114
- const s = N(a), o = xe(c), i = k([s]);
1115
- i && r(i);
1116
- const l = e.LEFT(H(s), o);
1117
- return l instanceof Error ? r(l) : l;
1113
+ LEN: f(e.LEN, { toText: !0 }),
1114
+ TRIM: f(e.TRIM, { toText: !0 }),
1115
+ LOWER: f(e.LOWER, { toText: !0 }),
1116
+ LEFT: (s, l) => {
1117
+ const a = x(s), o = xe(l), c = _([a]);
1118
+ c && r(c);
1119
+ const u = e.LEFT(G(a), o);
1120
+ return u instanceof Error ? r(u) : u;
1118
1121
  },
1119
- RIGHT: (a, c) => {
1120
- const s = N(a), o = xe(c), i = k([s]);
1121
- i && r(i);
1122
- const l = e.RIGHT(H(s), o);
1123
- return l instanceof Error ? r(l) : l;
1122
+ RIGHT: (s, l) => {
1123
+ const a = x(s), o = xe(l), c = _([a]);
1124
+ c && r(c);
1125
+ const u = e.RIGHT(G(a), o);
1126
+ return u instanceof Error ? r(u) : u;
1124
1127
  },
1125
- MID: (a, c, s) => {
1126
- const o = N(a), i = N(c), l = N(s), y = k([o, i, l]);
1128
+ MID: (s, l, a) => {
1129
+ const o = x(s), c = x(l), u = x(a), y = _([o, c, u]);
1127
1130
  y && r(y);
1128
- const h = e.MID(H(o), i, l);
1129
- return h instanceof Error ? r(h) : h;
1131
+ const p = e.MID(G(o), c, u);
1132
+ return p instanceof Error ? r(p) : p;
1130
1133
  },
1131
- FIND: (a, c, s) => {
1132
- const o = N(a), i = N(c), l = xe(s), y = k([o, i]);
1134
+ FIND: (s, l, a) => {
1135
+ const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
1133
1136
  y && r(y);
1134
- const h = e.FIND(H(o), H(i), l);
1135
- return h instanceof Error ? r(h) : h;
1137
+ const p = e.FIND(G(o), G(c), u);
1138
+ return p instanceof Error ? r(p) : p;
1136
1139
  },
1137
- SEARCH: (a, c, s) => {
1138
- const o = N(a), i = N(c), l = xe(s), y = k([o, i]);
1140
+ SEARCH: (s, l, a) => {
1141
+ const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
1139
1142
  y && r(y);
1140
- const h = e.SEARCH(H(o), H(i), l);
1141
- return h instanceof Error ? r(h) : h;
1143
+ const p = e.SEARCH(G(o), G(c), u);
1144
+ return p instanceof Error ? r(p) : p;
1142
1145
  }
1143
1146
  };
1144
1147
  }
1145
- const Ot = {
1148
+ const _t = {
1146
1149
  "#REF!": "REF",
1147
1150
  "#VALUE!": "VALUE",
1148
1151
  "#DIV/0!": "DIV0",
@@ -1151,41 +1154,41 @@ const Ot = {
1151
1154
  "#NUM!": "NUM",
1152
1155
  "#NULL!": "NULL"
1153
1156
  };
1154
- function We(e) {
1155
- return Ot[e.error] ?? "ERROR";
1157
+ function Ke(e) {
1158
+ return _t[e.error] ?? "ERROR";
1156
1159
  }
1157
- function Be(e, t) {
1160
+ function Ge(e, t) {
1158
1161
  if (e instanceof X) return e;
1159
1162
  if (e instanceof t) {
1160
1163
  const r = e.details;
1161
- return r instanceof X ? r : r instanceof t ? new X(We(r), r.message) : new X(We(e), e.message);
1164
+ return r instanceof X ? r : r instanceof t ? new X(Ke(r), r.message) : new X(Ke(e), e.message);
1162
1165
  }
1163
1166
  return new X("ERROR", e instanceof Error ? e.message : void 0);
1164
1167
  }
1165
- function It(e) {
1168
+ function Pt(e) {
1166
1169
  return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
1167
1170
  }
1168
- function xt(e) {
1171
+ function Vt(e) {
1169
1172
  return (t) => {
1170
1173
  const r = e[t.row - 1];
1171
1174
  if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
1172
1175
  throw new X("REF");
1173
- const d = r[t.col - 1];
1174
- return d == null || d === "" ? null : d;
1176
+ const i = r[t.col - 1];
1177
+ return i == null || i === "" ? null : i;
1175
1178
  };
1176
1179
  }
1177
- function Lt(e) {
1180
+ function Wt(e) {
1178
1181
  return (t) => {
1179
- const r = Math.min(t.from.row, t.to.row), d = Math.min(t.from.col, t.to.col), g = Math.max(t.from.row, t.to.row), a = Math.max(t.from.col, t.to.col), c = It(e);
1180
- if (r > e.length || d > c)
1182
+ const r = Math.min(t.from.row, t.to.row), i = Math.min(t.from.col, t.to.col), f = Math.max(t.from.row, t.to.row), s = Math.max(t.from.col, t.to.col), l = Pt(e);
1183
+ if (r > e.length || i > l)
1181
1184
  throw new X("REF");
1182
- const s = Math.min(g, e.length), o = [];
1183
- for (let i = r; i <= s; i++) {
1184
- const l = e[i - 1], y = [];
1185
- if (l != null) {
1186
- const h = Math.min(a, l.length);
1187
- for (let u = d; u <= h; u++) {
1188
- const v = l[u - 1];
1185
+ const a = Math.min(f, e.length), o = [];
1186
+ for (let c = r; c <= a; c++) {
1187
+ const u = e[c - 1], y = [];
1188
+ if (u != null) {
1189
+ const p = Math.min(s, u.length);
1190
+ for (let m = i; m <= p; m++) {
1191
+ const v = u[m - 1];
1189
1192
  y.push(v == null || v === "" ? null : v);
1190
1193
  }
1191
1194
  }
@@ -1194,38 +1197,57 @@ function Lt(e) {
1194
1197
  return o;
1195
1198
  };
1196
1199
  }
1197
- function Mt(e) {
1200
+ function Bt(e) {
1198
1201
  if (e == null || e === "") return null;
1199
1202
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1200
1203
  return e;
1201
1204
  throw new X("VALUE");
1202
1205
  }
1203
- async function Dt(e, t) {
1204
- if (typeof t != "string") throw new X("ERROR");
1205
- const r = t.trim();
1206
+ async function ar(e, t) {
1207
+ if (typeof e != "string") throw new X("ERROR");
1208
+ const r = e.trim();
1206
1209
  if (r === "") throw new X("ERROR");
1207
- const d = r.startsWith("=") ? r.slice(1) : r;
1208
- Tt(d);
1209
- const [g, a] = await Promise.all([
1210
+ const i = r.startsWith("=") ? r.slice(1) : r;
1211
+ Ft(i);
1212
+ const [f, s] = await Promise.all([
1210
1213
  import("fast-formula-parser"),
1211
1214
  import("@formulajs/formulajs")
1212
- ]), c = g.default ?? g, s = c.FormulaError, o = new c({
1213
- onCell: xt(e),
1214
- onRange: Lt(e),
1215
+ ]), l = f.default ?? f, a = l.FormulaError, o = new l({
1216
+ ...t,
1215
1217
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- formulajs's own types are all `any`-typed; formulaFunctions.ts narrows the surface it actually calls.
1216
- functions: Nt(a, s)
1218
+ functions: $t(s, a)
1217
1219
  });
1218
- let i;
1220
+ let c;
1219
1221
  try {
1220
- i = o.parse(d, { row: 1, col: 1, sheet: "Sheet1" });
1221
- } catch (l) {
1222
- throw Be(l, s);
1222
+ c = o.parse(i, { row: 1, col: 1, sheet: "Sheet1" });
1223
+ } catch (u) {
1224
+ throw Ge(u, a);
1223
1225
  }
1224
- if (i instanceof s)
1225
- throw Be(i, s);
1226
- return Mt(i);
1226
+ if (c instanceof a)
1227
+ throw Ge(c, a);
1228
+ return Bt(c);
1227
1229
  }
1228
- const Ke = {
1230
+ async function Kt(e, t) {
1231
+ return ar(t, { onCell: Vt(e), onRange: Wt(e) });
1232
+ }
1233
+ const Xe = -1;
1234
+ async function Gt(e, t) {
1235
+ const r = Object.keys(e);
1236
+ return ar(t, {
1237
+ onVariable: (i) => {
1238
+ const f = r.indexOf(i);
1239
+ return f === -1 ? null : { row: Xe, col: f + 1 };
1240
+ },
1241
+ onCell: (i) => {
1242
+ if (i.row === Xe) return e[r[i.col - 1]] ?? null;
1243
+ throw new X("REF");
1244
+ },
1245
+ onRange: () => {
1246
+ throw new X("REF");
1247
+ }
1248
+ });
1249
+ }
1250
+ const ur = {
1229
1251
  REF: "#REF!",
1230
1252
  VALUE: "#VALUE!",
1231
1253
  DIV0: "#DIV/0!",
@@ -1235,343 +1257,525 @@ const Ke = {
1235
1257
  NUM: "#NUM!",
1236
1258
  NULL: "#NULL!"
1237
1259
  };
1238
- async function zt(e, t) {
1239
- return e.length === 0 ? t.map((r) => ({ label: (r == null ? void 0 : r.label) ?? "(unknown)", value: null, error: Ke.ERROR })) : Promise.all(
1260
+ function dr(e) {
1261
+ const t = e instanceof X ? e.code : "ERROR";
1262
+ return ur[t];
1263
+ }
1264
+ async function Xt(e, t) {
1265
+ return e.length === 0 ? t.map((r) => ({
1266
+ id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1267
+ label: (r == null ? void 0 : r.label) ?? "(unknown)",
1268
+ value: null,
1269
+ error: ur.ERROR
1270
+ })) : Promise.all(
1240
1271
  t.map(async (r) => {
1241
1272
  try {
1242
- if (!r || typeof r.label != "string" || typeof r.expression != "string")
1273
+ if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
1243
1274
  throw new X("ERROR");
1244
- return { label: r.label, value: await Dt(e, r.expression) };
1245
- } catch (d) {
1246
- const g = d instanceof X ? d.code : "ERROR";
1247
- return { label: (r == null ? void 0 : r.label) ?? "(unknown)", value: null, error: Ke[g] };
1275
+ return { id: r.id, label: r.label, value: await Kt(e, r.expression) };
1276
+ } catch (i) {
1277
+ return {
1278
+ id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1279
+ label: (r == null ? void 0 : r.label) ?? "(unknown)",
1280
+ value: null,
1281
+ error: dr(i)
1282
+ };
1248
1283
  }
1249
1284
  })
1250
1285
  );
1251
1286
  }
1252
- const Ut = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", kt = 10 * 1024 * 1024, De = 200, Ft = 50, $t = [];
1287
+ function jt(e, t = {}) {
1288
+ if (t.columnHeader && t.rowHeader)
1289
+ throw new Error(
1290
+ "x-spreadsheet: columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape."
1291
+ );
1292
+ return t.columnHeader ? Yt(e) : t.rowHeader ? Jt(e) : e;
1293
+ }
1294
+ function fr(e) {
1295
+ return e == null || e === "" ? null : e instanceof Date ? e.toISOString() : String(e);
1296
+ }
1297
+ function hr(e, t) {
1298
+ const r = /* @__PURE__ */ new Set();
1299
+ for (const i of e)
1300
+ if (i != null) {
1301
+ if (r.has(i))
1302
+ throw new Error(
1303
+ `x-spreadsheet: duplicate ${t} value "${i}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
1304
+ );
1305
+ r.add(i);
1306
+ }
1307
+ }
1308
+ function Yt(e) {
1309
+ const [t, ...r] = e;
1310
+ if (!t) return [];
1311
+ const i = t.map(fr);
1312
+ return hr(i, "columnHeader"), r.map((f) => {
1313
+ const s = /* @__PURE__ */ Object.create(null);
1314
+ return i.forEach((l, a) => {
1315
+ l != null && (s[l] = f[a] ?? null);
1316
+ }), s;
1317
+ });
1318
+ }
1319
+ function Jt(e) {
1320
+ const t = e.map((f) => fr(f[0]));
1321
+ hr(t, "rowHeader");
1322
+ const r = Math.max(0, ...e.map((f) => f.length)), i = Math.max(0, r - 1);
1323
+ return Array.from({ length: i }, (f, s) => {
1324
+ const l = s + 1, a = /* @__PURE__ */ Object.create(null);
1325
+ return t.forEach((o, c) => {
1326
+ o != null && (a[o] = e[c][l] ?? null);
1327
+ }), a;
1328
+ });
1329
+ }
1330
+ function je(e) {
1331
+ return !Array.isArray(e[0]);
1332
+ }
1333
+ async function qt(e, t, r = {}) {
1334
+ const i = await Xt(e, t), f = /* @__PURE__ */ Object.create(null);
1335
+ for (const { id: s, label: l, value: a, error: o } of i)
1336
+ f[s] = o === void 0 ? { label: l, value: a } : { label: l, value: a, error: o };
1337
+ return r.persistSheet === !1 ? { derivations: f } : { sheet: jt(e, r), derivations: f };
1338
+ }
1339
+ const Zt = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Qt = 10 * 1024 * 1024, ve = 200, Ye = 50, en = [];
1253
1340
  function Ce(e) {
1254
1341
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1255
1342
  }
1256
- const _t = ({
1343
+ const rn = ({
1257
1344
  data: e,
1258
1345
  handleChange: t,
1259
1346
  path: r,
1260
- label: d,
1261
- required: g,
1262
- schema: a,
1263
- enabled: c,
1264
- errors: s,
1265
- visible: o = !0
1347
+ label: i,
1348
+ required: f,
1349
+ schema: s,
1350
+ enabled: l,
1351
+ readonly: a,
1352
+ errors: o,
1353
+ visible: c = !0
1266
1354
  }) => {
1267
- var Ee;
1268
- ue(o, r, t, null);
1269
- const i = !s || s.length === 0, l = c !== !1, y = (a == null ? void 0 : a["x-spreadsheet"]) ?? {}, h = (a == null ? void 0 : a["x-evaluate"]) ?? $t, u = y.accept ?? Ut, v = y.maxSize ?? kt, M = y.persistSheet !== !1, A = y.columnHeader === !0, w = y.rowHeader === !0, O = y.showSheet !== !1, z = y.sheetName, S = e ?? null, [q, P] = _(
1270
- () => {
1271
- var E;
1272
- return S != null && S.sheet || (((E = S == null ? void 0 : S.derivations) == null ? void 0 : E.length) ?? 0) > 0 ? "ready" : "empty";
1273
- }
1274
- ), [ee, x] = _(null), [J, F] = _(!1), [V, j] = _(null), K = de(null), $ = V ?? (S == null ? void 0 : S.sheet) ?? null, Q = (S == null ? void 0 : S.derivations) ?? [], re = $ != null || S != null, ie = ke(
1275
- async (E) => {
1276
- if (x(null), E.size > v) {
1277
- x(`File exceeds the ${me(v)} limit.`);
1355
+ ce(c, r, t, null);
1356
+ const u = !o || o.length === 0, y = St(l, a), p = (s == null ? void 0 : s["x-spreadsheet"]) ?? {}, m = (s == null ? void 0 : s["x-evaluate"]) ?? en, v = p.accept ?? Zt, N = p.maxSize ?? Qt, A = p.persistSheet !== !1, w = p.columnHeader === !0, R = p.rowHeader === !0, L = p.showSheet !== !1, P = p.sheetName, I = e ?? null, [B, j] = F(
1357
+ () => I != null && I.sheet || Object.keys((I == null ? void 0 : I.derivations) ?? {}).length > 0 ? "ready" : "empty"
1358
+ ), [M, O] = F(null), [D, V] = F(!1), [oe, ee] = F(null), le = de(null), Y = (I == null ? void 0 : I.sheet) ?? null, Z = oe ?? (Y && !je(Y) ? Y : null), re = oe == null && Y && je(Y) ? Y : null, he = (I == null ? void 0 : I.derivations) ?? {}, ne = Z != null || I != null, ue = _e(
1359
+ async (d) => {
1360
+ if (O(null), d.size > N) {
1361
+ O(`File exceeds the ${me(N)} limit.`);
1278
1362
  return;
1279
1363
  }
1280
- if (!u.split(",").map((m) => m.trim()).some((m) => m === "*" || m === "*/*" ? !0 : m.endsWith("/*") ? E.type.startsWith(m.slice(0, -1)) : m.startsWith(".") ? E.name.toLowerCase().endsWith(m.toLowerCase()) : E.type === m)) {
1281
- x(`Invalid type. Accepted: ${ye(u)}`);
1364
+ if (!v.split(",").map((z) => z.trim()).some((z) => z === "*" || z === "*/*" ? !0 : z.endsWith("/*") ? d.type.startsWith(z.slice(0, -1)) : z.startsWith(".") ? d.name.toLowerCase().endsWith(z.toLowerCase()) : d.type === z)) {
1365
+ O(`Invalid type. Accepted: ${ge(v)}`);
1282
1366
  return;
1283
1367
  }
1284
- P("parsing");
1368
+ j("parsing");
1285
1369
  let te;
1286
1370
  try {
1287
- const m = await E.arrayBuffer();
1288
- te = gt(m, z).matrix;
1289
- } catch (m) {
1290
- P("error"), x(
1291
- m instanceof Ue ? m.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1371
+ const z = await d.arrayBuffer();
1372
+ te = Ot(z, P).matrix;
1373
+ } catch (z) {
1374
+ j("error"), O(
1375
+ z instanceof $e ? z.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1292
1376
  );
1293
1377
  return;
1294
1378
  }
1295
- j(te);
1296
- const ae = await zt(te, h);
1297
- t(
1298
- r,
1299
- M ? { sheet: te, derivations: ae } : { derivations: ae }
1300
- ), P("ready");
1379
+ ee(te);
1380
+ let ie;
1381
+ try {
1382
+ ie = await qt(te, m, { persistSheet: A, columnHeader: w, rowHeader: R });
1383
+ } catch (z) {
1384
+ j("error"), O(z instanceof Error ? z.message : "Failed to process the uploaded spreadsheet.");
1385
+ return;
1386
+ }
1387
+ t(r, ie), j("ready");
1301
1388
  },
1302
- [u, v, M, z, h, r, t]
1389
+ [v, N, A, w, R, P, m, r, t]
1303
1390
  );
1304
- if (o === !1 || !l && !re) return null;
1305
- const se = (E) => {
1306
- E.preventDefault(), E.stopPropagation(), l && F(E.type === "dragenter" || E.type === "dragover");
1307
- }, ce = (E) => {
1308
- var L;
1309
- E.preventDefault(), E.stopPropagation(), F(!1), l && (L = E.dataTransfer.files) != null && L[0] && ie(E.dataTransfer.files[0]);
1310
- }, fe = (E) => {
1311
- var L;
1312
- (L = E.target.files) != null && L[0] && (ie(E.target.files[0]), E.target.value = "");
1313
- }, b = () => {
1314
- l && (j(null), x(null), P("empty"), t(r, null));
1315
- }, I = A ? 1 : 0, D = w ? 1 : 0, R = $ ? $.slice(I) : [], U = R.slice(0, De), G = Math.min(
1316
- Ft,
1317
- Math.max(0, ...U.map((E) => Math.max(0, E.length - D)))
1318
- ), Y = Array.from({ length: G }, (E, L) => L + D), B = O && $ == null && S != null, be = A && w ? Ce((Ee = $ == null ? void 0 : $[0]) == null ? void 0 : Ee[0]) : "";
1319
- return /* @__PURE__ */ p(C, { mb: "4", children: [
1320
- /* @__PURE__ */ p(T, { align: "center", justify: "between", mb: "2", children: [
1321
- /* @__PURE__ */ p(f, { as: "label", size: "2", weight: "bold", children: [
1322
- d,
1323
- g && /* @__PURE__ */ n(f, { color: "red", children: " *" })
1391
+ if (c === !1)
1392
+ return null;
1393
+ if (w && R)
1394
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
1395
+ /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1396
+ /* @__PURE__ */ n(h, { size: "2", color: "red", style: { display: "block" }, children: "Invalid x-spreadsheet config: columnHeader and rowHeader cannot both be true — pick one orientation." })
1397
+ ] });
1398
+ if (!y && !ne) return null;
1399
+ const b = (d) => {
1400
+ d.preventDefault(), d.stopPropagation(), y && V(d.type === "dragenter" || d.type === "dragover");
1401
+ }, k = (d) => {
1402
+ var E;
1403
+ d.preventDefault(), d.stopPropagation(), V(!1), y && (E = d.dataTransfer.files) != null && E[0] && ue(d.dataTransfer.files[0]);
1404
+ }, U = (d) => {
1405
+ var E;
1406
+ (E = d.target.files) != null && E[0] && (ue(d.target.files[0]), d.target.value = "");
1407
+ }, T = () => {
1408
+ y && (ee(null), O(null), j("empty"), t(r, null));
1409
+ }, H = w ? 1 : 0, J = R ? 1 : 0, Q = Z ? Z.slice(H) : [], K = Q.slice(0, ve), we = Math.min(
1410
+ Ye,
1411
+ Math.max(0, ...K.map((d) => Math.max(0, d.length - J)))
1412
+ ), Ee = Array.from({ length: we }, (d, E) => E + J), De = L && Z == null && re == null && I != null, Se = "", Fe = R && !w, Oe = re ? re.slice(0, ve) : [], Re = Array.from(new Set(Oe.flatMap((d) => Object.keys(d)))).slice(0, Ye);
1413
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
1414
+ /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
1415
+ /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
1416
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1417
+ i,
1418
+ f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1419
+ ] }),
1420
+ ne && y && /* @__PURE__ */ g(be, { children: [
1421
+ /* @__PURE__ */ n(We, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1422
+ Ue,
1423
+ {
1424
+ variant: "ghost",
1425
+ size: "1",
1426
+ onClick: () => {
1427
+ var d;
1428
+ return (d = le.current) == null ? void 0 : d.click();
1429
+ },
1430
+ "aria-label": "Replace spreadsheet",
1431
+ children: /* @__PURE__ */ n(He, {})
1432
+ }
1433
+ ) }),
1434
+ /* @__PURE__ */ n(We, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1435
+ Ue,
1436
+ {
1437
+ variant: "ghost",
1438
+ size: "1",
1439
+ color: "gray",
1440
+ onClick: T,
1441
+ "aria-label": "Remove spreadsheet",
1442
+ children: /* @__PURE__ */ n(or, {})
1443
+ }
1444
+ ) })
1445
+ ] })
1324
1446
  ] }),
1325
- /* @__PURE__ */ p(f, { size: "1", color: "gray", children: [
1326
- me(v),
1447
+ /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1448
+ me(N),
1327
1449
  " max · ",
1328
- ye(u)
1450
+ ge(v)
1329
1451
  ] })
1330
1452
  ] }),
1331
- re && /* @__PURE__ */ n($e, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ p(T, { align: "center", gap: "3", children: [
1332
- /* @__PURE__ */ n(
1333
- C,
1334
- {
1335
- style: {
1336
- background: "var(--blue-3)",
1337
- padding: 8,
1338
- borderRadius: 6,
1339
- color: "var(--blue-9)",
1340
- flexShrink: 0
1341
- },
1342
- children: /* @__PURE__ */ n(Qe, { width: "20", height: "20" })
1343
- }
1344
- ),
1345
- /* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(f, { size: "2", weight: "bold", children: "Spreadsheet uploaded" }) }),
1346
- /* @__PURE__ */ n(er, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
1347
- l && /* @__PURE__ */ n(je, { variant: "ghost", color: "gray", onClick: b, "aria-label": "Remove spreadsheet", children: /* @__PURE__ */ n(rr, {}) })
1348
- ] }) }),
1349
- l && /* @__PURE__ */ p(
1453
+ ne && M && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: M }),
1454
+ /* @__PURE__ */ n("input", { ref: le, type: "file", style: { display: "none" }, accept: v, onChange: U }),
1455
+ y && !ne && /* @__PURE__ */ n(
1350
1456
  "div",
1351
1457
  {
1352
1458
  role: "button",
1353
1459
  tabIndex: 0,
1354
1460
  onClick: () => {
1355
- var E;
1356
- return (E = K.current) == null ? void 0 : E.click();
1461
+ var d;
1462
+ return (d = le.current) == null ? void 0 : d.click();
1357
1463
  },
1358
- onKeyDown: (E) => {
1359
- var L;
1360
- (E.key === "Enter" || E.key === " ") && (E.preventDefault(), (L = K.current) == null || L.click());
1464
+ onKeyDown: (d) => {
1465
+ var E;
1466
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), (E = le.current) == null || E.click());
1361
1467
  },
1362
- onDragEnter: se,
1363
- onDragLeave: se,
1364
- onDragOver: se,
1365
- onDrop: ce,
1468
+ onDragEnter: b,
1469
+ onDragLeave: b,
1470
+ onDragOver: b,
1471
+ onDrop: k,
1366
1472
  style: { cursor: "pointer" },
1367
1473
  className: [
1368
1474
  "border-2 border-dashed rounded-lg p-6 text-center",
1369
1475
  "transition-all duration-200 ease-in-out",
1370
- J ? "border-blue-500 bg-blue-50" : ee ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1476
+ D ? "border-blue-500 bg-blue-50" : M ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1371
1477
  ].join(" "),
1372
- children: [
1373
- /* @__PURE__ */ n("input", { ref: K, type: "file", style: { display: "none" }, accept: u, onChange: fe }),
1374
- /* @__PURE__ */ n(T, { direction: "column", align: "center", gap: "2", children: q === "parsing" ? /* @__PURE__ */ p(Te, { children: [
1375
- /* @__PURE__ */ n(ze, { size: "3" }),
1376
- /* @__PURE__ */ n(f, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1377
- ] }) : ee ? /* @__PURE__ */ p(Te, { children: [
1378
- /* @__PURE__ */ n(tr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1379
- /* @__PURE__ */ n(f, { size: "2", color: "red", weight: "medium", children: ee }),
1380
- /* @__PURE__ */ n(f, { size: "1", color: "gray", children: "Click to try again" })
1381
- ] }) : /* @__PURE__ */ p(Te, { children: [
1382
- /* @__PURE__ */ n(nr, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1383
- /* @__PURE__ */ n(f, { size: "2", weight: "medium", children: re ? "Click to upload a replacement" : "Click to upload or drag and drop" }),
1384
- /* @__PURE__ */ p(f, { size: "1", color: "gray", children: [
1385
- me(v),
1386
- " max · ",
1387
- ye(u)
1388
- ] })
1389
- ] }) })
1390
- ]
1478
+ children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: B === "parsing" ? /* @__PURE__ */ g(be, { children: [
1479
+ /* @__PURE__ */ n(Me, { size: "3" }),
1480
+ /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1481
+ ] }) : M ? /* @__PURE__ */ g(be, { children: [
1482
+ /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1483
+ /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: M }),
1484
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1485
+ ] }) : /* @__PURE__ */ g(be, { children: [
1486
+ /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1487
+ /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1488
+ /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1489
+ me(N),
1490
+ " max · ",
1491
+ ge(v)
1492
+ ] })
1493
+ ] }) })
1391
1494
  }
1392
1495
  ),
1393
- $ && O && /* @__PURE__ */ p(C, { mt: "3", children: [
1394
- /* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ p(ne.Root, { variant: "surface", size: "1", children: [
1395
- /* @__PURE__ */ n(ne.Header, { children: /* @__PURE__ */ p(ne.Row, { children: [
1396
- /* @__PURE__ */ n(ne.ColumnHeaderCell, { children: be }),
1397
- Y.map((E) => {
1398
- var L;
1399
- return /* @__PURE__ */ n(ne.ColumnHeaderCell, { children: A ? Ce((L = $[0]) == null ? void 0 : L[E]) : mt(E) }, E);
1496
+ Z && L && /* @__PURE__ */ g(C, { mt: "3", children: [
1497
+ /* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
1498
+ !Fe && /* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
1499
+ /* @__PURE__ */ n($.ColumnHeaderCell, { children: Se }),
1500
+ Ee.map((d) => {
1501
+ var E;
1502
+ return (
1503
+ // This row only renders when rowHeader isn't the sole
1504
+ // flag set (see suppressColumnHeaderRow) — so reaching
1505
+ // here, either columnHeader is true (real labels) or
1506
+ // both are false (columnLetter fallback).
1507
+ /* @__PURE__ */ n($.ColumnHeaderCell, { children: w ? Ce((E = Z[0]) == null ? void 0 : E[d]) : Nt(d) }, d)
1508
+ );
1400
1509
  })
1401
1510
  ] }) }),
1402
- /* @__PURE__ */ n(ne.Body, { children: U.map((E, L) => {
1511
+ /* @__PURE__ */ n($.Body, { children: K.map((d, E) => {
1403
1512
  var te;
1404
- const we = I + L;
1405
- return /* @__PURE__ */ p(ne.Row, { children: [
1406
- /* @__PURE__ */ n(ne.RowHeaderCell, { children: w ? Ce((te = $[we]) == null ? void 0 : te[0]) : we + 1 }),
1407
- Y.map((ae) => /* @__PURE__ */ n(ne.Cell, { children: Ce(E[ae]) }, ae))
1408
- ] }, L);
1513
+ const q = H + E;
1514
+ return /* @__PURE__ */ g($.Row, { children: [
1515
+ /* @__PURE__ */ n(
1516
+ $.RowHeaderCell,
1517
+ {
1518
+ style: R ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1519
+ children: R ? Ce((te = Z[q]) == null ? void 0 : te[0]) : w ? "" : q + 1
1520
+ }
1521
+ ),
1522
+ Ee.map((ie) => /* @__PURE__ */ n($.Cell, { children: Ce(d[ie]) }, ie))
1523
+ ] }, E);
1409
1524
  }) })
1410
1525
  ] }) }),
1411
- R.length > De && /* @__PURE__ */ p(f, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1526
+ Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1527
+ "Showing first ",
1528
+ ve,
1529
+ " of ",
1530
+ Q.length,
1531
+ " rows"
1532
+ ] })
1533
+ ] }),
1534
+ re && L && /* @__PURE__ */ g(C, { mt: "3", children: [
1535
+ /* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
1536
+ /* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
1537
+ /* @__PURE__ */ n($.ColumnHeaderCell, {}),
1538
+ Re.map((d) => /* @__PURE__ */ n($.ColumnHeaderCell, { children: d }, d))
1539
+ ] }) }),
1540
+ /* @__PURE__ */ n($.Body, { children: Oe.map((d, E) => /* @__PURE__ */ g($.Row, { children: [
1541
+ /* @__PURE__ */ n($.RowHeaderCell, { children: E + 1 }),
1542
+ Re.map((q) => /* @__PURE__ */ n($.Cell, { children: Ce(d[q]) }, q))
1543
+ ] }, E)) })
1544
+ ] }) }),
1545
+ re.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1412
1546
  "Showing first ",
1413
- De,
1547
+ ve,
1414
1548
  " of ",
1415
- R.length,
1549
+ re.length,
1416
1550
  " rows"
1417
1551
  ] })
1418
1552
  ] }),
1419
- B && /* @__PURE__ */ n(f, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1420
- Q.length > 0 && /* @__PURE__ */ p(C, { mt: "3", children: [
1421
- /* @__PURE__ */ n(f, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1422
- /* @__PURE__ */ n(T, { direction: "column", gap: "1", children: Q.map((E, L) => /* @__PURE__ */ p(T, { justify: "between", children: [
1423
- /* @__PURE__ */ n(f, { size: "2", children: E.label }),
1424
- E.error ? /* @__PURE__ */ n(f, { size: "2", color: "red", children: E.error }) : (
1553
+ De && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1554
+ Object.keys(he).length > 0 && /* @__PURE__ */ g(C, { mt: "3", children: [
1555
+ /* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1556
+ /* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(he).map(([d, E]) => /* @__PURE__ */ g(S, { justify: "between", children: [
1557
+ /* @__PURE__ */ n(h, { size: "2", children: E.label }),
1558
+ E.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: E.error }) : (
1425
1559
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1426
1560
  // possible results anymore — INDEX/CONCATENATE can return a
1427
1561
  // string, a bare comparison can return a boolean, etc.), so
1428
1562
  // `.toLocaleString()` would throw for e.g. a boolean result.
1429
1563
  // Reuse the same formatCell used for the sheet-preview grid.
1430
- /* @__PURE__ */ n(f, { size: "2", children: Ce(E.value) })
1564
+ /* @__PURE__ */ n(h, { size: "2", children: Ce(E.value) })
1431
1565
  )
1432
- ] }, L)) })
1566
+ ] }, d)) })
1433
1567
  ] }),
1434
- !i && /* @__PURE__ */ n(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: le(s, d) })
1568
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
1435
1569
  ] });
1436
- }, Pt = oe(_t), Vt = W(
1570
+ }, tn = se(rn), nn = W(
1437
1571
  10,
1438
1572
  // matches FileControlTester's rank — beats the default object/Group renderer
1439
- Fe(
1573
+ ze(
1440
1574
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1441
1575
  )
1442
- ), Ht = ({
1576
+ );
1577
+ function on(e, t, r) {
1578
+ const i = {};
1579
+ for (const [f, s] of Object.entries(r)) {
1580
+ const { path: l, default: a } = typeof s == "string" ? { path: s, default: void 0 } : s, o = t ? `${t}.${l}` : l, c = Sr.data(e, o);
1581
+ if (c == null) {
1582
+ if (a === void 0) return;
1583
+ i[f] = a;
1584
+ } else
1585
+ i[f] = c;
1586
+ }
1587
+ return i;
1588
+ }
1589
+ async function ln(e, t) {
1590
+ try {
1591
+ return { status: "ok", value: await Gt(e, t) };
1592
+ } catch (r) {
1593
+ return { status: "error", error: dr(r) };
1594
+ }
1595
+ }
1596
+ function sn(e, t) {
1597
+ return e == null ? "" : typeof e == "number" ? e.toFixed(cn(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
1598
+ }
1599
+ function cn(e) {
1600
+ return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
1601
+ }
1602
+ const Je = "{value}", an = 2, un = {}, dn = ({ data: e, handleChange: t, path: r, label: i, schema: f, visible: s = !0 }) => {
1603
+ var B;
1604
+ ce(s, r, t, null);
1605
+ const l = f == null ? void 0 : f["x-computed"], a = (l == null ? void 0 : l.inputs) ?? un, o = (l == null ? void 0 : l.formula) ?? "", c = (l == null ? void 0 : l.format) ?? Je, u = (l == null ? void 0 : l.decimals) ?? an, y = xr(), p = r.split(".").slice(0, -1).join("."), m = on((B = y.core) == null ? void 0 : B.data, p, a), v = m ? JSON.stringify(m) : null, N = y.readonly === !0, [A, w] = F(() => typeof e == "number" ? "ok" : "unavailable"), [R, L] = F(() => typeof e == "number" ? e : null), [P, I] = F(null);
1606
+ return fe(() => {
1607
+ if (!s) return;
1608
+ let j = !1;
1609
+ const M = (O) => {
1610
+ N || O !== (e ?? null) && t(r, O);
1611
+ };
1612
+ if (m === void 0) {
1613
+ w("unavailable"), I(null), L(null), M(null);
1614
+ return;
1615
+ }
1616
+ return w((O) => O === "ok" ? O : "loading"), ln(m, o).then((O) => {
1617
+ if (j) return;
1618
+ const D = O.status === "ok" && typeof O.value == "number" && Number.isFinite(O.value) ? O.value : null;
1619
+ if (D === null) {
1620
+ w("error"), I(
1621
+ O.status === "error" ? O.error ?? "Unable to compute value." : "Computed value must be a number."
1622
+ ), L(null), M(null);
1623
+ return;
1624
+ }
1625
+ w("ok"), I(null), L(D), M(D);
1626
+ }), () => {
1627
+ j = !0;
1628
+ };
1629
+ }, [v, o, s, N]), s === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
1630
+ /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1631
+ A === "unavailable" ? /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Not yet available." }) : A === "loading" ? /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
1632
+ /* @__PURE__ */ n(Me, { size: "1" }),
1633
+ /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Computing…" })
1634
+ ] }) : A === "error" ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: P }) : /* @__PURE__ */ n(h, { size: "2", children: c.split(Je).join(sn(R, u)) }),
1635
+ f.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f.description })
1636
+ ] }) });
1637
+ }, fn = se(dn), hn = W(
1638
+ 5,
1639
+ ze((e) => {
1640
+ const t = e["x-computed"];
1641
+ return e.type === "number" && typeof t == "object" && t !== null;
1642
+ })
1643
+ ), pn = ({
1443
1644
  data: e,
1444
1645
  path: t,
1445
1646
  schema: r,
1446
- uischema: d,
1447
- enabled: g,
1448
- visible: a,
1449
- addItem: c,
1450
- removeItems: s,
1647
+ uischema: i,
1648
+ enabled: f,
1649
+ visible: s,
1650
+ addItem: l,
1651
+ removeItems: a,
1451
1652
  rootSchema: o,
1452
- arraySchema: i
1653
+ arraySchema: c
1453
1654
  }) => {
1454
- const l = i ? r : r.items, y = i || r;
1455
- if (a === !1 || !l || typeof l != "object" || Array.isArray(l))
1655
+ const u = c ? r : r.items, y = c || r;
1656
+ if (s === !1 || !u || typeof u != "object" || Array.isArray(u))
1456
1657
  return null;
1457
- const h = l, u = Array.isArray(e) ? e : [], v = y.title || "Array Items", M = () => {
1458
- const w = br(h, o);
1459
- c && c(t, w)();
1658
+ const p = u, m = Array.isArray(e) ? e : [], v = y.title || "Array Items", N = () => {
1659
+ const w = Or(p, o);
1660
+ l && l(t, w)();
1460
1661
  }, A = (w) => {
1461
- if (s) {
1462
- const O = s(t, [w]);
1463
- O && O();
1662
+ if (a) {
1663
+ const R = a(t, [w]);
1664
+ R && R();
1464
1665
  }
1465
1666
  };
1466
- return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */ p(T, { direction: "column", gap: "4", children: [
1467
- /* @__PURE__ */ n(f, { as: "div", size: "4", weight: "bold", children: v }),
1468
- u.length === 0 && /* @__PURE__ */ n(C, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(f, { size: "2", color: "gray", children: "No items have been added yet." }) }),
1469
- u.map((w, O) => {
1470
- var S;
1471
- const z = `${t}.${O}`;
1472
- return /* @__PURE__ */ n($e, { size: "3", variant: "surface", children: /* @__PURE__ */ p(T, { direction: "column", gap: "4", children: [
1473
- /* @__PURE__ */ p(T, { justify: "between", align: "center", children: [
1474
- /* @__PURE__ */ p(f, { size: "3", weight: "bold", children: [
1667
+ return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1668
+ /* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
1669
+ m.length === 0 && /* @__PURE__ */ n(C, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
1670
+ m.map((w, R) => {
1671
+ var P;
1672
+ const L = `${t}.${R}`;
1673
+ return /* @__PURE__ */ n(nr, { size: "3", variant: "surface", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1674
+ /* @__PURE__ */ g(S, { justify: "between", align: "center", children: [
1675
+ /* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
1475
1676
  "Item ",
1476
- O + 1
1677
+ R + 1
1477
1678
  ] }),
1478
- g && /* @__PURE__ */ p(
1479
- Le,
1679
+ f && /* @__PURE__ */ g(
1680
+ ke,
1480
1681
  {
1481
1682
  type: "button",
1482
1683
  color: "red",
1483
1684
  variant: "soft",
1484
- onClick: () => A(O),
1685
+ onClick: () => A(R),
1485
1686
  title: "Remove item",
1486
1687
  children: [
1487
- /* @__PURE__ */ n(Sr, {}),
1688
+ /* @__PURE__ */ n(Ur, {}),
1488
1689
  "Remove"
1489
1690
  ]
1490
1691
  }
1491
1692
  )
1492
1693
  ] }),
1493
1694
  /* @__PURE__ */ n(C, { children: /* @__PURE__ */ n(
1494
- Se,
1695
+ Ae,
1495
1696
  {
1496
- schema: h,
1497
- uischema: ((S = d.options) == null ? void 0 : S.detail) || (h.type === "object" || h.properties ? {
1697
+ schema: p,
1698
+ uischema: ((P = i.options) == null ? void 0 : P.detail) || (p.type === "object" || p.properties ? {
1498
1699
  type: "VerticalLayout",
1499
- elements: Object.keys(h.properties || {}).map((q) => ({
1700
+ elements: Object.keys(p.properties || {}).map((I) => ({
1500
1701
  type: "Control",
1501
- scope: `#/properties/${q}`
1702
+ scope: `#/properties/${I}`
1502
1703
  }))
1503
1704
  } : {
1504
1705
  type: "Control",
1505
1706
  scope: "#"
1506
1707
  }),
1507
- path: z,
1508
- enabled: g,
1708
+ path: L,
1709
+ enabled: f,
1509
1710
  renderers: void 0,
1510
1711
  cells: void 0
1511
1712
  }
1512
1713
  ) })
1513
- ] }) }, z);
1714
+ ] }) }, L);
1514
1715
  }),
1515
- g && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ p(Le, { type: "button", variant: "surface", onClick: M, children: [
1516
- /* @__PURE__ */ n(Nr, {}),
1716
+ f && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ g(ke, { type: "button", variant: "surface", onClick: N, children: [
1717
+ /* @__PURE__ */ n(Hr, {}),
1517
1718
  "Add Item"
1518
1719
  ] }) })
1519
1720
  ] }) });
1520
- }, Ge = Rr(Ht), Wt = W(3, Er), Bt = ({ uischema: e, visible: t }) => {
1721
+ }, qe = Mr(pn), mn = W(3, Nr), gn = ({ uischema: e, visible: t }) => {
1521
1722
  const r = e;
1522
- return t === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ n(qe, { size: "4", children: r.text }) });
1523
- }, Kt = W(1, Ae("Label")), Gt = W(3, wr), on = [
1524
- { tester: zr, renderer: Ur },
1525
- { tester: Fr, renderer: $r },
1526
- { tester: Pr, renderer: Vr },
1527
- { tester: Wr, renderer: Br },
1723
+ return t === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ n(tr, { size: "4", children: r.text }) });
1724
+ }, yn = W(1, Te("Label")), vn = W(3, Ir), xn = [
1725
+ { tester: Kr, renderer: Gr },
1726
+ { tester: jr, renderer: Yr },
1528
1727
  { tester: qr, renderer: Zr },
1529
- { tester: Gr, renderer: Xr },
1530
- { tester: rt, renderer: tt },
1531
- { tester: ot, renderer: nt },
1532
- { tester: it, renderer: lt },
1728
+ { tester: et, renderer: rt },
1533
1729
  { tester: ct, renderer: st },
1534
- { tester: dt, renderer: at },
1535
- { tester: pt, renderer: ht },
1536
- { tester: Vt, renderer: Pt },
1537
- { tester: Wt, renderer: Ge },
1538
- { tester: Gt, renderer: Ge },
1539
- { tester: Kt, renderer: Bt }
1730
+ { tester: nt, renderer: ot },
1731
+ { tester: ft, renderer: ht },
1732
+ { tester: mt, renderer: pt },
1733
+ { tester: yt, renderer: gt },
1734
+ { tester: bt, renderer: vt },
1735
+ { tester: Et, renderer: wt },
1736
+ { tester: At, renderer: Tt },
1737
+ { tester: nn, renderer: tn },
1738
+ { tester: hn, renderer: fn },
1739
+ { tester: mn, renderer: qe },
1740
+ { tester: vn, renderer: qe },
1741
+ { tester: yn, renderer: gn }
1540
1742
  ];
1541
1743
  export {
1542
- Ge as ArrayControl,
1543
- Wt as ArrayControlTester,
1544
- _r as BooleanControl,
1545
- Pr as BooleanControlTester,
1546
- at as CategorizationLayoutRenderer,
1547
- dt as CategorizationLayoutTester,
1548
- et as DateControl,
1549
- rt as DateControlTester,
1550
- ht as FileControl,
1551
- pt as FileControlTester,
1552
- st as GroupLayoutRenderer,
1553
- ct as GroupLayoutTester,
1554
- lt as HorizontalLayoutRenderer,
1555
- it as HorizontalLayoutTester,
1556
- Bt as LabelRenderer,
1557
- Kt as LabelTester,
1558
- kr as NumberControl,
1559
- Fr as NumberControlTester,
1560
- Hr as RadioControl,
1561
- Wr as RadioControlTester,
1562
- Zr as SearchSelectControl,
1563
- qr as SearchSelectControlTester,
1564
- nn as SearchServiceProvider,
1565
- Kr as SelectControl,
1566
- Gr as SelectControlTester,
1567
- Pt as SpreadsheetControl,
1568
- Vt as SpreadsheetControlTester,
1569
- Dr as TextControl,
1570
- zr as TextControlTester,
1571
- tn as UploadProvider,
1572
- nt as VerticalLayoutRenderer,
1573
- ot as VerticalLayoutTester,
1574
- on as radixRenderers,
1575
- Mr as useSearchService,
1576
- Lr as useUpload
1744
+ qe as ArrayControl,
1745
+ mn as ArrayControlTester,
1746
+ Jr as BooleanControl,
1747
+ qr as BooleanControlTester,
1748
+ wt as CategorizationLayoutRenderer,
1749
+ Et as CategorizationLayoutTester,
1750
+ fn as ComputedControl,
1751
+ hn as ComputedControlTester,
1752
+ dt as DateControl,
1753
+ ft as DateControlTester,
1754
+ Tt as FileControl,
1755
+ At as FileControlTester,
1756
+ vt as GroupLayoutRenderer,
1757
+ bt as GroupLayoutTester,
1758
+ gt as HorizontalLayoutRenderer,
1759
+ yt as HorizontalLayoutTester,
1760
+ gn as LabelRenderer,
1761
+ yn as LabelTester,
1762
+ Xr as NumberControl,
1763
+ jr as NumberControlTester,
1764
+ Qr as RadioControl,
1765
+ et as RadioControlTester,
1766
+ st as SearchSelectControl,
1767
+ ct as SearchSelectControlTester,
1768
+ In as SearchServiceProvider,
1769
+ tt as SelectControl,
1770
+ nt as SelectControlTester,
1771
+ tn as SpreadsheetControl,
1772
+ nn as SpreadsheetControlTester,
1773
+ Br as TextControl,
1774
+ Kr as TextControlTester,
1775
+ Nn as UploadProvider,
1776
+ pt as VerticalLayoutRenderer,
1777
+ mt as VerticalLayoutTester,
1778
+ xn as radixRenderers,
1779
+ Wr as useSearchService,
1780
+ Vr as useUpload
1577
1781
  };