@opennsw/jsonforms-renderers 0.4.0 → 0.6.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,191 +1,195 @@
1
- import { jsx as e, jsxs as f, Fragment as be } from "react/jsx-runtime";
2
- import { useContext as ze, createContext as Se, useMemo as Ue, useEffect as X, useState as A, useRef as Q, useCallback as Te } from "react";
3
- import { rankWith as D, isStringControl as Ee, or as ge, isNumberControl as Ve, isIntegerControl as je, isBooleanControl as Ne, isEnumControl as Re, isOneOfControl as ke, schemaMatches as $e, isDateControl as Pe, isDateTimeControl as Be, isTimeControl as Me, uiTypeIs as ie, and as We, createDefaultValue as He, isObjectArrayControl as Ke, isPrimitiveArrayControl as Ge } from "@jsonforms/core";
4
- import { withJsonFormsControlProps as J, JsonFormsDispatch as ce, withJsonFormsArrayControlProps as Je } from "@jsonforms/react";
5
- import { Box as C, Flex as z, Text as c, TextField as Y, Checkbox as _e, RadioGroup as we, Select as de, ScrollArea as qe, Spinner as Ce, Button as he, Tabs as ue, Heading as Fe, Card as De, IconButton as Ze } from "@radix-ui/themes";
6
- import { ChevronDownIcon as Qe, FileTextIcon as Xe, CheckCircledIcon as Ye, Cross2Icon as er, ExclamationTriangleIcon as rr, UploadIcon as tr, TrashIcon as nr, PlusIcon as or } from "@radix-ui/react-icons";
7
- import lr from "dayjs";
8
- const Oe = Se(null);
9
- function tt({
10
- children: t,
11
- onUpload: r,
12
- getDownloadUrl: n
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({
14
+ children: e,
15
+ onUpload: t,
16
+ getDownloadUrl: r
13
17
  }) {
14
- const a = { onUpload: r, getDownloadUrl: n };
15
- return /* @__PURE__ */ e(Oe.Provider, { value: a, children: t });
18
+ const d = { onUpload: t, getDownloadUrl: r };
19
+ return /* @__PURE__ */ n(or.Provider, { value: d, children: e });
16
20
  }
17
- function ir() {
18
- return ze(Oe);
21
+ function Lr() {
22
+ return Xe(or);
19
23
  }
20
- const Ie = Se(null);
21
- function nt({
22
- children: t,
23
- services: r
24
+ const lr = Ye(null);
25
+ function nn({
26
+ children: e,
27
+ services: t
24
28
  }) {
25
- const n = Ue(() => r, [r]);
26
- return /* @__PURE__ */ e(Ie.Provider, { value: n, children: t });
29
+ const r = dr(() => t, [t]);
30
+ return /* @__PURE__ */ n(lr.Provider, { value: r, children: e });
27
31
  }
28
- function cr(t) {
29
- const r = ze(Ie);
30
- return !r || !t ? null : r[t] ?? null;
32
+ function Mr(e) {
33
+ const t = Xe(lr);
34
+ return !t || !e ? null : t[e] ?? null;
31
35
  }
32
- const ee = (t, r, n, a = void 0) => {
33
- X(() => {
34
- t === !1 && n(r, a);
35
- }, [t, r, n, a]);
36
- }, _ = (t, r) => t ? t.split(`
37
- `).map((n) => n.trim() === "is a required property" ? `${r || "This field"} is required` : n).join(`
38
- `) : "", sr = ({
39
- data: t,
40
- handleChange: r,
41
- path: n,
42
- label: a,
43
- required: y,
44
- errors: h,
45
- uischema: s,
46
- schema: v,
47
- enabled: d,
48
- visible: g = !0
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(`
41
+ `).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
42
+ `) : "", Dr = ({
43
+ data: e,
44
+ handleChange: t,
45
+ path: r,
46
+ label: d,
47
+ required: g,
48
+ errors: a,
49
+ uischema: c,
50
+ schema: s,
51
+ enabled: o,
52
+ visible: i = !0
49
53
  }) => {
50
- var x;
51
- if (ee(g, n, r), g === !1)
54
+ var y;
55
+ if (ue(i, r, t), i === !1)
52
56
  return null;
53
- const l = h.length === 0;
54
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
55
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", htmlFor: n, children: [
56
- a,
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
61
  " ",
58
- y && /* @__PURE__ */ e(c, { color: "red", children: "*" })
62
+ g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
59
63
  ] }),
60
- /* @__PURE__ */ e(
61
- Y.Root,
64
+ /* @__PURE__ */ n(
65
+ ve.Root,
62
66
  {
63
- value: t || "",
64
- onChange: (p) => r(n, p.target.value),
65
- disabled: !d,
66
- placeholder: (x = s.options) == null ? void 0 : x.placeholder,
67
+ value: e || "",
68
+ onChange: (h) => t(r, h.target.value),
69
+ disabled: !o,
70
+ placeholder: (y = c.options) == null ? void 0 : y.placeholder,
67
71
  color: l ? void 0 : "red",
68
- id: n
72
+ id: r
69
73
  }
70
74
  ),
71
- !l && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(h, a) }),
72
- v.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: v.description })
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 })
73
77
  ] }) });
74
- }, ar = D(1, Ee), dr = J(sr), ur = ({
75
- data: t,
76
- handleChange: r,
77
- path: n,
78
- label: a,
79
- required: y,
80
- errors: h,
81
- uischema: s,
82
- schema: v,
83
- enabled: d,
84
- visible: g = !0
78
+ }, zr = W(1, ur), Ur = oe(Dr), kr = ({
79
+ data: e,
80
+ handleChange: t,
81
+ path: r,
82
+ label: d,
83
+ required: g,
84
+ errors: a,
85
+ uischema: c,
86
+ schema: s,
87
+ enabled: o,
88
+ visible: i = !0
85
89
  }) => {
86
- var p;
87
- if (ee(g, n, r), g === !1)
90
+ var h;
91
+ if (ue(i, r, t), i === !1)
88
92
  return null;
89
- const l = h.length === 0, x = (o) => {
90
- if (o === "") {
91
- r(n, void 0);
93
+ const l = a.length === 0, y = (u) => {
94
+ if (u === "") {
95
+ t(r, void 0);
92
96
  return;
93
97
  }
94
- const u = Number(o);
95
- isNaN(u) || r(n, u);
98
+ const v = Number(u);
99
+ isNaN(v) || t(r, v);
96
100
  };
97
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
98
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", htmlFor: n, children: [
99
- a,
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,
100
104
  " ",
101
- y && /* @__PURE__ */ e(c, { color: "red", children: "*" })
105
+ g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
102
106
  ] }),
103
- /* @__PURE__ */ e(
104
- Y.Root,
107
+ /* @__PURE__ */ n(
108
+ ve.Root,
105
109
  {
106
110
  type: "number",
107
- value: t ?? "",
108
- onChange: (o) => x(o.target.value),
109
- disabled: !d,
110
- placeholder: (p = s.options) == null ? void 0 : p.placeholder,
111
+ value: e ?? "",
112
+ onChange: (u) => y(u.target.value),
113
+ disabled: !o,
114
+ placeholder: (h = c.options) == null ? void 0 : h.placeholder,
111
115
  color: l ? void 0 : "red",
112
- id: n
116
+ id: r
113
117
  }
114
118
  ),
115
- !l && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(h, a) }),
116
- v.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: v.description })
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 })
117
121
  ] }) });
118
- }, fr = D(2, ge(Ve, je)), pr = J(ur), hr = ({
119
- data: t,
120
- handleChange: r,
121
- path: n,
122
- label: a,
123
- required: y,
124
- errors: h,
125
- schema: s,
126
- enabled: v,
127
- visible: d = !0
122
+ }, Fr = W(2, Me(fr, hr)), $r = oe(kr), _r = ({
123
+ data: e,
124
+ handleChange: t,
125
+ path: r,
126
+ label: d,
127
+ required: g,
128
+ errors: a,
129
+ schema: c,
130
+ enabled: s,
131
+ visible: o = !0
128
132
  }) => {
129
- if (ee(d, n, r), d === !1)
133
+ if (ue(o, r, t), o === !1)
130
134
  return null;
131
- const g = h.length === 0;
132
- return /* @__PURE__ */ f(C, { mb: "4", children: [
133
- /* @__PURE__ */ f(z, { gap: "2", align: "center", children: [
134
- /* @__PURE__ */ e(
135
- _e,
135
+ const i = a.length === 0;
136
+ return /* @__PURE__ */ p(C, { mb: "4", children: [
137
+ /* @__PURE__ */ p(T, { gap: "2", align: "center", children: [
138
+ /* @__PURE__ */ n(
139
+ Cr,
136
140
  {
137
- checked: !!t,
138
- onCheckedChange: (l) => r(n, l === !0),
139
- disabled: !v,
140
- id: n
141
+ checked: !!e,
142
+ onCheckedChange: (l) => t(r, l === !0),
143
+ disabled: !s,
144
+ id: r
141
145
  }
142
146
  ),
143
- /* @__PURE__ */ f(c, { as: "label", size: "2", htmlFor: n, children: [
144
- a,
147
+ /* @__PURE__ */ p(f, { as: "label", size: "2", htmlFor: r, children: [
148
+ d,
145
149
  " ",
146
- y && "*"
150
+ g && "*"
147
151
  ] })
148
152
  ] }),
149
- !g && /* @__PURE__ */ e(c, { color: "red", size: "1", className: "block mt-1", children: _(h, a) }),
150
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", className: "block mt-1", children: s.description })
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 })
151
155
  ] });
152
- }, gr = D(2, Ne), mr = J(hr), yr = ({
153
- data: t,
154
- handleChange: r,
155
- path: n,
156
- label: a,
157
- required: y,
158
- errors: h,
159
- schema: s,
160
- enabled: v,
161
- visible: d = !0
156
+ }, Pr = W(2, pr), Vr = oe(_r), Hr = ({
157
+ data: e,
158
+ handleChange: t,
159
+ path: r,
160
+ label: d,
161
+ required: g,
162
+ errors: a,
163
+ schema: c,
164
+ enabled: s,
165
+ visible: o = !0
162
166
  }) => {
163
- if (ee(d, n, r), d === !1)
167
+ if (ue(o, r, t), o === !1)
164
168
  return null;
165
- const g = h.length === 0;
169
+ const i = a.length === 0;
166
170
  let l = [];
167
- s.enum ? l = s.enum.map((p) => ({ value: p, label: String(p) })) : s.oneOf && (l = s.oneOf.map((p) => ({
168
- value: p.const,
169
- label: p.title || String(p.const)
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)
170
174
  })));
171
- const x = t;
172
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
173
- /* @__PURE__ */ f(c, { as: "div", size: "2", weight: "bold", children: [
174
- a,
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,
175
179
  " ",
176
- y && /* @__PURE__ */ e(c, { color: "red", children: "*" })
180
+ g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
177
181
  ] }),
178
- /* @__PURE__ */ e(
179
- we.Root,
182
+ /* @__PURE__ */ n(
183
+ Ve.Root,
180
184
  {
181
- value: x !== void 0 ? String(x) : "",
182
- onValueChange: (p) => {
183
- const o = l.find((u) => String(u.value) === p);
184
- o && r(n, o.value);
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);
185
189
  },
186
- disabled: !v,
187
- children: /* @__PURE__ */ e(
188
- z,
190
+ disabled: !s,
191
+ children: /* @__PURE__ */ n(
192
+ T,
189
193
  {
190
194
  direction: "row",
191
195
  style: {
@@ -193,202 +197,209 @@ const ee = (t, r, n, a = void 0) => {
193
197
  columnGap: "clamp(14px, 3vw, 36px)",
194
198
  rowGap: "clamp(8px, 1.6vw, 14px)"
195
199
  },
196
- children: l.map((p) => /* @__PURE__ */ f(z, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
197
- /* @__PURE__ */ e(we.Item, { value: String(p.value) }),
198
- /* @__PURE__ */ e(c, { size: "2", color: v ? void 0 : "gray", children: p.label })
199
- ] }, String(p.value)))
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
204
  }
201
205
  )
202
206
  }
203
207
  ),
204
- !g && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(h, a) }),
205
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: s.description })
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 })
206
210
  ] }) });
207
- }, vr = (t, r, n) => {
208
- var y;
209
- return ge(Re, ke)(t, r, n) && ((y = t == null ? void 0 : t.options) == null ? void 0 : y.format) === "radio" ? 3 : -1;
210
- }, br = J(yr), wr = ({
211
- data: t,
212
- handleChange: r,
213
- path: n,
214
- label: a,
215
- required: y,
216
- errors: h,
217
- schema: s,
218
- uischema: v,
219
- enabled: d,
220
- visible: g = !0
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 = ({
215
+ data: e,
216
+ handleChange: t,
217
+ path: r,
218
+ label: d,
219
+ required: g,
220
+ errors: a,
221
+ schema: c,
222
+ uischema: s,
223
+ enabled: o,
224
+ visible: i = !0
221
225
  }) => {
222
- var o;
223
- if (ee(g, n, r), g === !1)
226
+ var u;
227
+ if (ue(i, r, t), i === !1)
224
228
  return null;
225
- const l = h.length === 0;
226
- let x = [];
227
- s.enum ? x = s.enum.map((u) => ({ value: String(u), label: String(u) })) : s.oneOf && (x = s.oneOf.map((u) => ({
228
- value: String(u.const),
229
- label: u.title || String(u.const)
229
+ const l = a.length === 0;
230
+ let y = [];
231
+ c.enum ? y = c.enum.map((v) => ({ value: String(v), label: String(v) })) : c.oneOf && (y = c.oneOf.map((v) => ({
232
+ value: String(v.const),
233
+ label: v.title || String(v.const)
230
234
  })));
231
- const p = t !== void 0 ? String(t) : "";
232
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
233
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", htmlFor: n, children: [
234
- a,
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
239
  " ",
236
- y && /* @__PURE__ */ e(c, { color: "red", children: "*" })
240
+ g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
237
241
  ] }),
238
- /* @__PURE__ */ f(de.Root, { value: p, onValueChange: (u) => r(n, u), disabled: !d, children: [
239
- /* @__PURE__ */ e(
240
- de.Trigger,
242
+ /* @__PURE__ */ p(Oe.Root, { value: h, onValueChange: (v) => t(r, v), disabled: !o, children: [
243
+ /* @__PURE__ */ n(
244
+ Oe.Trigger,
241
245
  {
242
- placeholder: ((o = v.options) == null ? void 0 : o.placeholder) || "Select an option",
246
+ placeholder: ((u = s.options) == null ? void 0 : u.placeholder) || "Select an option",
243
247
  color: l ? void 0 : "red",
244
- id: n
248
+ id: r
245
249
  }
246
250
  ),
247
- /* @__PURE__ */ e(de.Content, { children: x.map((u) => /* @__PURE__ */ e(de.Item, { value: u.value, children: u.label }, u.value)) })
251
+ /* @__PURE__ */ n(Oe.Content, { children: y.map((v) => /* @__PURE__ */ n(Oe.Item, { value: v.value, children: v.label }, v.value)) })
248
252
  ] }),
249
- !l && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(h, a) }),
250
- s.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: s.description })
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 })
251
255
  ] }) });
252
- }, Cr = D(2, ge(Re, ke)), xr = J(wr), zr = {
256
+ }, Gr = W(2, Me(Je, Ze)), Xr = oe(Kr), Yr = {
253
257
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
254
258
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
255
259
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
256
- }, Sr = ({
257
- data: t,
258
- handleChange: r,
259
- path: n,
260
- label: a,
261
- required: y,
262
- errors: h,
263
- enabled: s,
264
- visible: v = !0,
265
- schema: d,
266
- uischema: g
260
+ }, Jr = ({
261
+ data: e,
262
+ handleChange: t,
263
+ path: r,
264
+ label: d,
265
+ required: g,
266
+ errors: a,
267
+ enabled: c,
268
+ visible: s = !0,
269
+ schema: o,
270
+ uischema: i
267
271
  }) => {
268
- var me;
269
- const l = (d == null ? void 0 : d["x-search"]) ?? { service: "" }, x = l.service ?? "", p = l.mode ?? "large-paginated-list", o = zr[p], u = (o == null ? void 0 : o.fetchOnOpen) ?? !1, S = cr(x), $ = x ? S ? o ? null : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${x}" is not registered.` : "Search not configured.", w = s !== !1, R = !h || h.length === 0, [k, V] = A(!1), [O, j] = A(""), [te, N] = A([]), [re, U] = A(!1), [I, B] = A(!1), [ne, M] = A(!1), [oe, W] = A(null), [le, q] = A(void 0), H = Q(void 0), Z = Q(null), i = Q(null), T = Q(null), F = Q(void 0);
270
- X(() => {
271
- if (!t) {
272
- q(void 0), F.current = void 0;
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;
278
+ return;
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 });
273
283
  return;
274
284
  }
275
- if (F.current === t || (F.current = t, q({ id: t, name: t }), !(S != null && S.resolve))) return;
285
+ if (D({ id: z, name: S ?? z }), !(A != null && A.resolve)) return;
276
286
  let m = !1;
277
- return S.resolve(t).then((E) => {
278
- !m && E && q(E);
287
+ return A.resolve(z, M).then((Re) => {
288
+ !m && Re && D(Re);
279
289
  }).catch(() => {
280
290
  }), () => {
281
291
  m = !0;
282
292
  };
283
- }, [t, S]);
284
- const b = Te(
285
- async (m, E = !1) => {
286
- var ye;
287
- if (!S) {
288
- W("Search service not configured.");
293
+ }, [z, S, w, A, M]);
294
+ const be = ke(
295
+ async (m, Z = !1) => {
296
+ var Re;
297
+ if (!A) {
298
+ b("Search service not configured.");
289
299
  return;
290
300
  }
291
- (ye = i.current) == null || ye.abort();
292
- const se = new AbortController();
293
- i.current = se, E ? M(!0) : (B(!0), M(!1), W(null));
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));
294
304
  try {
295
- const ae = await S.search({
305
+ const Ne = await A.search({
296
306
  query: m,
297
- cursor: E ? H.current : void 0,
298
- signal: se.signal
299
- }), ve = ae.options ?? [];
300
- N(E ? (Ae) => [...Ae, ...ve] : ve), H.current = ae.nextCursor, U(((o == null ? void 0 : o.paginated) ?? !1) && ae.nextCursor != null);
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);
301
312
  } catch {
302
- if (se.signal.aborted) return;
303
- W("Failed to load results. Please try again.");
313
+ if (he.signal.aborted) return;
314
+ b("Failed to load results. Please try again.");
304
315
  } finally {
305
- se.signal.aborted || (E ? M(!1) : B(!1));
316
+ he.signal.aborted || (Z ? ce(!1) : ie(!1));
306
317
  }
307
318
  },
308
- [S, o == null ? void 0 : o.paginated]
319
+ [A, u == null ? void 0 : u.paginated, M]
309
320
  );
310
- if (X(() => {
311
- if (!k) return;
312
- const m = (E) => {
313
- T.current && !T.current.contains(E.target) && V(!1);
321
+ if (ge(() => {
322
+ if (!x) return;
323
+ const m = (Z) => {
324
+ Y.current && !Y.current.contains(Z.target) && J(!1);
314
325
  };
315
326
  return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
316
- }, [k]), X(() => {
327
+ }, [x]), ge(() => {
317
328
  var m;
318
- k || ((m = i.current) == null || m.abort(), j(""), N([]), U(!1), W(null), B(!1), M(!1), H.current = void 0);
319
- }, [k]), X(() => {
320
- if (!k) return;
321
- if (!O && !u) {
322
- N([]), U(!1), W(null), H.current = void 0;
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;
323
334
  return;
324
335
  }
325
- Z.current && clearTimeout(Z.current);
326
- const m = O ? 300 : 0;
327
- return Z.current = setTimeout(() => {
328
- N([]), U(!1), H.current = void 0, b(O);
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);
329
340
  }, m), () => {
330
- Z.current && clearTimeout(Z.current);
341
+ U.current && clearTimeout(U.current);
331
342
  };
332
- }, [O, k, u, b]), ee(v, n, r, null), v === !1)
343
+ }, [F, x, v, be]), ue(s, r, t, w ? void 0 : null), s === !1)
333
344
  return null;
334
- const L = () => {
335
- j(""), N([]), U(!1), W(null), H.current = void 0, V(!0);
336
- }, P = (m) => {
337
- r(n, m.id), q(m), F.current = m.id, V(!1);
338
- }, K = (m) => {
339
- m.stopPropagation(), r(n, null), q(void 0);
340
- }, G = (m) => {
341
- (m.key === "Enter" || m.key === " ") && K(m);
342
- }, Le = ((me = g == null ? void 0 : g.options) == null ? void 0 : me.placeholder) ?? "Select an option";
343
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
344
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", htmlFor: n, children: [
345
- a,
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
357
  " ",
347
- y && /* @__PURE__ */ e(c, { color: "red", children: "*" })
358
+ g && /* @__PURE__ */ n(f, { color: "red", children: "*" })
348
359
  ] }),
349
- /* @__PURE__ */ f("div", { ref: T, style: { position: "relative" }, children: [
350
- /* @__PURE__ */ e(
351
- Y.Root,
360
+ /* @__PURE__ */ p("div", { ref: Y, style: { position: "relative" }, children: [
361
+ /* @__PURE__ */ n(
362
+ ve.Root,
352
363
  {
353
- id: n,
354
- value: k ? O : (le == null ? void 0 : le.name) ?? "",
355
- placeholder: k && (o != null && o.searchable) ? "Search..." : Le,
356
- disabled: !w,
357
- readOnly: k && !(o != null && o.searchable),
358
- style: R ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
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" },
359
370
  onChange: (m) => {
360
- o != null && o.searchable && (j(m.target.value), k || L());
371
+ u != null && u.searchable && (V(m.target.value), x || Ee());
361
372
  },
362
373
  onFocus: () => {
363
- w && !k && L();
374
+ P && !x && Ee();
364
375
  },
365
376
  onKeyDown: (m) => {
366
- m.key === "Escape" && V(!1);
377
+ m.key === "Escape" && J(!1);
367
378
  },
368
- children: /* @__PURE__ */ e(Y.Slot, { side: "right", children: /* @__PURE__ */ f(z, { align: "center", gap: "1", children: [
369
- t && w && /* @__PURE__ */ e(
379
+ children: /* @__PURE__ */ n(ve.Slot, { side: "right", children: /* @__PURE__ */ p(T, { align: "center", gap: "1", children: [
380
+ z && P && /* @__PURE__ */ n(
370
381
  "span",
371
382
  {
372
383
  role: "button",
373
384
  tabIndex: 0,
374
385
  onMouseDown: (m) => m.preventDefault(),
375
- onClick: K,
376
- onKeyDown: G,
386
+ onClick: L,
387
+ onKeyDown: we,
377
388
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
378
389
  "aria-label": "Clear selection",
379
390
  children: "×"
380
391
  }
381
392
  ),
382
- /* @__PURE__ */ e(
383
- Qe,
393
+ /* @__PURE__ */ n(
394
+ Ar,
384
395
  {
385
- style: { transform: k ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
396
+ style: { transform: x ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
386
397
  }
387
398
  )
388
399
  ] }) })
389
400
  }
390
401
  ),
391
- k && /* @__PURE__ */ e(
402
+ x && /* @__PURE__ */ n(
392
403
  C,
393
404
  {
394
405
  style: {
@@ -403,340 +414,340 @@ const ee = (t, r, n, a = void 0) => {
403
414
  border: "1px solid var(--gray-a6)",
404
415
  overflow: "hidden"
405
416
  },
406
- children: $ ? /* @__PURE__ */ e(C, { p: "3", children: /* @__PURE__ */ e(c, { size: "2", color: "gray", children: $ }) }) : /* @__PURE__ */ e(qe, { style: { maxHeight: 240 }, children: /* @__PURE__ */ f(C, { p: "1", children: [
407
- I && /* @__PURE__ */ e(z, { justify: "center", p: "4", children: /* @__PURE__ */ e(Ce, {}) }),
408
- !I && oe && /* @__PURE__ */ e(C, { px: "3", py: "2", children: /* @__PURE__ */ e(c, { size: "2", color: "red", children: oe }) }),
409
- !I && !oe && te.length === 0 && /* @__PURE__ */ e(C, { px: "3", py: "2", children: /* @__PURE__ */ e(c, { size: "2", color: "gray", children: O || u ? "No results found." : "Type to search…" }) }),
410
- te.map((m) => /* @__PURE__ */ e(
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(
411
422
  C,
412
423
  {
413
424
  px: "3",
414
425
  py: "2",
415
- onMouseDown: (E) => E.preventDefault(),
416
- onClick: () => P(m),
426
+ onMouseDown: (Z) => Z.preventDefault(),
427
+ onClick: () => E(m),
417
428
  style: {
418
429
  cursor: "pointer",
419
430
  borderRadius: "var(--radius-2)",
420
- backgroundColor: m.id === t ? "var(--accent-3)" : void 0
431
+ backgroundColor: m.id === z ? "var(--accent-3)" : void 0
421
432
  },
422
433
  className: "hover:bg-(--gray-3)",
423
- children: /* @__PURE__ */ e(c, { size: "2", children: m.name })
434
+ children: /* @__PURE__ */ n(f, { size: "2", children: m.name })
424
435
  },
425
436
  m.id
426
437
  )),
427
- (o == null ? void 0 : o.paginated) && re && !ne && /* @__PURE__ */ e(C, { px: "3", py: "2", children: /* @__PURE__ */ e(
428
- he,
438
+ (u == null ? void 0 : u.paginated) && $ && !se && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
+ Le,
429
440
  {
430
441
  variant: "ghost",
431
442
  size: "1",
432
443
  style: { width: "100%" },
433
444
  onMouseDown: (m) => m.preventDefault(),
434
- onClick: () => void b(O, !0),
445
+ onClick: () => void be(F, !0),
435
446
  children: "Load more"
436
447
  }
437
448
  ) }),
438
- ne && /* @__PURE__ */ e(z, { justify: "center", p: "2", children: /* @__PURE__ */ e(Ce, {}) })
449
+ se && /* @__PURE__ */ n(T, { justify: "center", p: "2", children: /* @__PURE__ */ n(ze, {}) })
439
450
  ] }) })
440
451
  }
441
452
  )
442
453
  ] }),
443
- !R && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(h, a) }),
444
- d.description && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: d.description })
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 })
445
456
  ] }) });
446
- }, Tr = J(Sr), Rr = D(
457
+ }, Zr = oe(Jr), qr = W(
447
458
  3,
448
- $e((t) => {
449
- const r = t["x-search"];
450
- return t.type === "string" && typeof (r == null ? void 0 : r.service) == "string" && r.service !== "";
459
+ Fe((e) => {
460
+ const t = e["x-search"];
461
+ return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
451
462
  })
452
- ), kr = (t, r) => lr(`${t}T${r}`).format(), $r = ({ path: t, label: r, required: n, errors: a, description: y, children: h }) => {
453
- const s = a.length === 0;
454
- return /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ f(z, { direction: "column", gap: "1", children: [
455
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
456
- r,
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: [
467
+ t,
457
468
  " ",
458
- n && /* @__PURE__ */ e(c, { color: "red", children: "*" })
469
+ r && /* @__PURE__ */ n(f, { color: "red", children: "*" })
459
470
  ] }),
460
- h,
461
- !s && /* @__PURE__ */ e(c, { color: "red", size: "1", children: _(a, r) }),
462
- y && /* @__PURE__ */ e(c, { size: "1", color: "gray", children: y })
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 })
463
474
  ] }) });
464
- }, Fr = ({
465
- data: t,
466
- handleChange: r,
467
- path: n,
468
- label: a,
469
- required: y,
470
- errors: h,
471
- schema: s,
472
- enabled: v,
473
- visible: d = !0
475
+ }, et = ({
476
+ data: e,
477
+ handleChange: t,
478
+ path: r,
479
+ label: d,
480
+ required: g,
481
+ errors: a,
482
+ schema: c,
483
+ enabled: s,
484
+ visible: o = !0
474
485
  }) => {
475
- if (X(() => {
476
- d === !1 && r(n, void 0);
477
- }, [d, n, r]), d === !1)
486
+ if (ge(() => {
487
+ o === !1 && t(r, void 0);
488
+ }, [o, r, t]), o === !1)
478
489
  return null;
479
- const g = h.length === 0, l = typeof t == "string" ? t : "", x = (w) => /* @__PURE__ */ e($r, { path: n, label: a, required: y, errors: h, description: s.description, children: w });
480
- if (s.format === "time")
481
- return x(
482
- /* @__PURE__ */ e(
483
- Y.Root,
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")
492
+ return y(
493
+ /* @__PURE__ */ n(
494
+ ve.Root,
484
495
  {
485
496
  type: "time",
486
497
  value: l,
487
- onChange: (w) => r(n, w.target.value),
488
- disabled: !v,
489
- color: g ? void 0 : "red",
490
- id: n
498
+ onChange: (w) => t(r, w.target.value),
499
+ disabled: !s,
500
+ color: i ? void 0 : "red",
501
+ id: r
491
502
  }
492
503
  )
493
504
  );
494
- const p = s.format === "date-time", [o = "", u = ""] = l.split("T"), S = u.slice(0, 5), $ = (w, R) => {
505
+ const h = c.format === "date-time", [u = "", v = ""] = l.split("T"), M = v.slice(0, 5), A = (w, O) => {
495
506
  if (!w) {
496
- r(n, void 0);
507
+ t(r, void 0);
497
508
  return;
498
509
  }
499
- r(n, p ? kr(w, R || "00:00") : w);
510
+ t(r, h ? jr(w, O || "00:00") : w);
500
511
  };
501
- return x(
502
- /* @__PURE__ */ f(z, { gap: "2", align: "center", children: [
503
- /* @__PURE__ */ e(
504
- Y.Root,
512
+ return y(
513
+ /* @__PURE__ */ p(T, { gap: "2", align: "center", children: [
514
+ /* @__PURE__ */ n(
515
+ ve.Root,
505
516
  {
506
517
  type: "date",
507
- value: o,
508
- disabled: !v,
509
- color: g ? void 0 : "red",
510
- onChange: (w) => $(w.target.value, S),
511
- id: n,
518
+ value: u,
519
+ disabled: !s,
520
+ color: i ? void 0 : "red",
521
+ onChange: (w) => A(w.target.value, M),
522
+ id: r,
512
523
  style: { flex: 1 }
513
524
  }
514
525
  ),
515
- p && /* @__PURE__ */ e(
516
- Y.Root,
526
+ h && /* @__PURE__ */ n(
527
+ ve.Root,
517
528
  {
518
529
  type: "time",
519
- value: S,
520
- disabled: !v || !o,
521
- color: g ? void 0 : "red",
522
- onChange: (w) => $(o, w.target.value),
530
+ value: M,
531
+ disabled: !s || !u,
532
+ color: i ? void 0 : "red",
533
+ onChange: (w) => A(u, w.target.value),
523
534
  style: { flex: 1 }
524
535
  }
525
536
  )
526
537
  ] })
527
538
  );
528
- }, Dr = D(2, ge(Pe, Be, Me)), Or = J(Fr), Ir = ({
529
- uischema: t,
530
- schema: r,
531
- path: n,
532
- renderers: a,
533
- cells: y,
534
- enabled: h,
535
- visible: s = !0
539
+ }, rt = W(2, Me(gr, mr, yr)), tt = oe(et), nt = ({
540
+ uischema: e,
541
+ schema: t,
542
+ path: r,
543
+ renderers: d,
544
+ cells: g,
545
+ enabled: a,
546
+ visible: c = !0
536
547
  }) => {
537
- const d = t.elements;
538
- return s === !1 ? null : /* @__PURE__ */ e(z, { direction: "column", gap: "4", children: d.map((g, l) => /* @__PURE__ */ e(
539
- ce,
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,
540
551
  {
541
- uischema: g,
542
- schema: r,
543
- path: n,
544
- renderers: a,
545
- cells: y,
546
- enabled: h
552
+ uischema: i,
553
+ schema: t,
554
+ path: r,
555
+ renderers: d,
556
+ cells: g,
557
+ enabled: a
547
558
  },
548
- `${n}-${l}`
559
+ `${r}-${l}`
549
560
  )) });
550
- }, Lr = D(1, ie("VerticalLayout")), Ar = ({
551
- uischema: t,
552
- schema: r,
553
- path: n,
554
- renderers: a,
555
- cells: y,
556
- enabled: h,
557
- visible: s = !0
561
+ }, ot = W(1, Ae("VerticalLayout")), lt = ({
562
+ uischema: e,
563
+ schema: t,
564
+ path: r,
565
+ renderers: d,
566
+ cells: g,
567
+ enabled: a,
568
+ visible: c = !0
558
569
  }) => {
559
- const d = t.elements;
560
- return s === !1 ? null : /* @__PURE__ */ e(z, { direction: "row", gap: "4", children: d.map((g, l) => /* @__PURE__ */ e(C, { style: { flex: 1 }, children: /* @__PURE__ */ e(
561
- ce,
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,
562
573
  {
563
- uischema: g,
564
- schema: r,
565
- path: n,
566
- renderers: a,
567
- cells: y,
568
- enabled: h
574
+ uischema: i,
575
+ schema: t,
576
+ path: r,
577
+ renderers: d,
578
+ cells: g,
579
+ enabled: a
569
580
  }
570
- ) }, `${n}-${l}`)) });
571
- }, Ur = D(1, ie("HorizontalLayout")), Er = ({
572
- uischema: t,
573
- schema: r,
574
- path: n,
575
- renderers: a,
576
- cells: y,
577
- enabled: h,
578
- visible: s = !0
581
+ ) }, `${r}-${l}`)) });
582
+ }, it = W(1, Ae("HorizontalLayout")), st = ({
583
+ uischema: e,
584
+ schema: t,
585
+ path: r,
586
+ renderers: d,
587
+ cells: g,
588
+ enabled: a,
589
+ visible: c = !0
579
590
  }) => {
580
- const v = t, d = v.elements;
581
- return s === !1 ? null : /* @__PURE__ */ f(C, { mb: "6", children: [
582
- v.label && /* @__PURE__ */ e(Fe, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: v.label }),
583
- /* @__PURE__ */ e(z, { direction: "column", gap: "4", children: d.map((g, l) => /* @__PURE__ */ e(
584
- ce,
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,
585
596
  {
586
- uischema: g,
587
- schema: r,
588
- path: n,
589
- renderers: a,
590
- cells: y,
591
- enabled: h
597
+ uischema: i,
598
+ schema: t,
599
+ path: r,
600
+ renderers: d,
601
+ cells: g,
602
+ enabled: a
592
603
  },
593
- `${n}-${l}`
604
+ `${r}-${l}`
594
605
  )) })
595
606
  ] });
596
- }, Vr = D(1, ie("Group")), jr = ({
597
- uischema: t,
598
- schema: r,
599
- path: n,
600
- renderers: a,
601
- cells: y,
602
- enabled: h,
603
- visible: s = !0
607
+ }, ct = W(1, Ae("Group")), at = ({
608
+ uischema: e,
609
+ schema: t,
610
+ path: r,
611
+ renderers: d,
612
+ cells: g,
613
+ enabled: a,
614
+ visible: c = !0
604
615
  }) => {
605
- var p;
606
- const d = t.elements.filter((o) => o.type === "Category"), [g, l] = A(((p = d[0]) == null ? void 0 : p.label) || "");
607
- if (s === !1 || !d.length) return null;
608
- const x = d.find((o) => o.label === g) ? g : d[0].label;
609
- return /* @__PURE__ */ f(ue.Root, { value: x, onValueChange: l, children: [
610
- /* @__PURE__ */ e(ue.List, { children: d.map((o, u) => /* @__PURE__ */ e(ue.Trigger, { value: o.label, children: o.label }, `${n}-${u}`)) }),
611
- /* @__PURE__ */ e(C, { pt: "3", children: d.map((o, u) => /* @__PURE__ */ e(ue.Content, { value: o.label, children: /* @__PURE__ */ e(z, { direction: "column", gap: "4", children: o.elements.map((S, $) => /* @__PURE__ */ e(
612
- ce,
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,
613
624
  {
614
- uischema: S,
615
- schema: r,
616
- path: n,
617
- renderers: a,
618
- cells: y,
619
- enabled: h
625
+ uischema: M,
626
+ schema: t,
627
+ path: r,
628
+ renderers: d,
629
+ cells: g,
630
+ enabled: a
620
631
  },
621
- `${n}-${u}-${$}`
622
- )) }) }, `${n}-${u}`)) })
632
+ `${r}-${v}-${A}`
633
+ )) }) }, `${r}-${v}`)) })
623
634
  ] });
624
- }, Nr = D(1, ie("Categorization"));
625
- function Pr(t) {
626
- return t ? Array.isArray(t) ? t : [t] : [];
635
+ }, dt = W(1, Ae("Categorization"));
636
+ function me(e) {
637
+ return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
627
638
  }
628
- function fe(t) {
629
- return t >= 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(0)} MB` : t >= 1024 ? `${(t / 1024).toFixed(0)} KB` : `${t} B`;
630
- }
631
- function pe(t) {
632
- return t.split(",").map((r) => {
633
- if (r = r.trim(), r.endsWith("/*"))
634
- return r.split("/")[0].toUpperCase() + "S";
635
- if (r.startsWith("."))
636
- return r.slice(1).toUpperCase();
637
- const n = r.split("/")[1];
638
- return n ? n.toUpperCase() : r;
639
+ function ye(e) {
640
+ return e.split(",").map((t) => {
641
+ if (t = t.trim(), t.endsWith("/*"))
642
+ return t.split("/")[0].toUpperCase() + "S";
643
+ if (t.startsWith("."))
644
+ return t.slice(1).toUpperCase();
645
+ const r = t.split("/")[1];
646
+ return r ? r.toUpperCase() : t;
639
647
  }).join(", ");
640
648
  }
641
- const Br = ({
642
- data: t,
643
- handleChange: r,
644
- path: n,
645
- label: a,
646
- required: y,
647
- uischema: h,
648
- schema: s,
649
- enabled: v,
650
- errors: d,
651
- visible: g = !0
649
+ function ut(e) {
650
+ return e ? Array.isArray(e) ? e : [e] : [];
651
+ }
652
+ const ft = ({
653
+ data: e,
654
+ handleChange: t,
655
+ path: r,
656
+ label: d,
657
+ required: g,
658
+ uischema: a,
659
+ schema: c,
660
+ enabled: s,
661
+ errors: o,
662
+ visible: i = !0
652
663
  }) => {
653
- const l = ir();
654
- ee(g, n, r, null);
655
- const x = !d || d.length === 0, p = (s == null ? void 0 : s["x-file"]) ?? {}, o = (h == null ? void 0 : h.options) ?? {}, u = p.maxFiles ?? o.maxFiles ?? 1, S = p.maxSize ?? o.maxSize ?? 5 * 1024 * 1024, $ = p.accept ?? o.accept ?? "image/*,application/pdf", w = u > 1, R = v !== !1, [k, V] = A(!1), [O, j] = A(null), [te, N] = A({}), re = Q(/* @__PURE__ */ new Set()), U = Q(null), I = Pr(t), B = I.length >= u;
656
- X(() => () => {
657
- re.current.forEach((i) => URL.revokeObjectURL(i)), re.current.clear();
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();
658
669
  }, []);
659
- const ne = Te(
660
- async (i) => {
661
- if (j(null), I.length >= u) {
662
- j(`Maximum ${u} file${u > 1 ? "s" : ""} allowed.`);
670
+ const K = ke(
671
+ async (b) => {
672
+ if (P(null), V.length >= v) {
673
+ P(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
663
674
  return;
664
675
  }
665
- if (i.size > S) {
666
- j(`File exceeds the ${fe(S)} limit.`);
676
+ if (b.size > M) {
677
+ P(`File exceeds the ${me(M)} limit.`);
667
678
  return;
668
679
  }
669
- if (!$.split(",").map((b) => b.trim()).some((b) => b === "*" || b === "*/*" ? !0 : b.endsWith("/*") ? i.type.startsWith(b.slice(0, -1)) : b.startsWith(".") ? i.name.toLowerCase().endsWith(b.toLowerCase()) : i.type === b)) {
670
- j(`Invalid type. Accepted: ${pe($)}`);
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)}`);
671
682
  return;
672
683
  }
673
684
  if (!(l != null && l.onUpload)) {
674
- j("Upload service not configured.");
685
+ P("Upload service not configured.");
675
686
  return;
676
687
  }
677
688
  try {
678
- const b = await l.onUpload(i), L = URL.createObjectURL(i);
679
- re.current.add(L);
680
- const P = { key: b.key, name: b.name ?? i.name, blobUrl: L };
681
- N((G) => ({ ...G, [b.key]: P }));
682
- const K = [...I, b.key];
683
- r(n, w ? K : K[0]);
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]);
684
695
  } catch {
685
- j("Upload failed. Please try again."), U.current && (U.current.value = "");
696
+ P("Upload failed. Please try again."), F.current && (F.current.value = "");
686
697
  }
687
698
  },
688
- [I, u, S, $, l, n, r, w]
699
+ [V, v, M, A, l, r, t, w]
689
700
  );
690
- if (g === !1)
701
+ if (i === !1)
691
702
  return null;
692
- const M = (i) => {
693
- i.preventDefault(), i.stopPropagation(), !(!R || B) && V(i.type === "dragenter" || i.type === "dragover");
694
- }, oe = (i) => {
695
- var T;
696
- i.preventDefault(), i.stopPropagation(), V(!1), !(!R || B) && (T = i.dataTransfer.files) != null && T[0] && ne(i.dataTransfer.files[0]);
697
- }, W = (i) => {
698
- var T;
699
- (T = i.target.files) != null && T[0] && (ne(i.target.files[0]), i.target.value = "");
700
- }, le = (i) => {
701
- if (!R) return;
702
- N((F) => {
703
- var P;
704
- const b = { ...F }, L = (P = b[i]) == null ? void 0 : P.blobUrl;
705
- return L && (URL.revokeObjectURL(L), re.current.delete(L)), delete b[i], b;
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]);
708
+ }, 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;
706
717
  });
707
- const T = I.filter((F) => F !== i);
708
- r(n, w ? T.length > 0 ? T : null : T[0] ?? null);
709
- }, q = async (i, T) => {
710
- var L, P, K;
711
- i.preventDefault();
712
- const F = (L = te[T]) == null ? void 0 : L.blobUrl;
713
- if (F) {
714
- (P = window.open(F, "_blank", "noopener,noreferrer")) == null || P.focus();
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;
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();
715
726
  return;
716
727
  }
717
- const b = window.open("", "_blank");
718
- if (b)
728
+ const R = window.open("", "_blank");
729
+ if (R)
719
730
  try {
720
- const G = await ((K = l == null ? void 0 : l.getDownloadUrl) == null ? void 0 : K.call(l, T));
721
- G != null && G.url ? b.location.href = G.url : b.close();
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();
722
733
  } catch {
723
- b.close();
734
+ R.close();
724
735
  }
725
736
  };
726
- if (!R && I.length === 0) return null;
727
- const H = u - I.length, Z = R && !B;
728
- return /* @__PURE__ */ f(C, { mb: "4", children: [
729
- /* @__PURE__ */ f(z, { align: "center", justify: "between", mb: "2", children: [
730
- /* @__PURE__ */ f(c, { as: "label", size: "2", weight: "bold", children: [
731
- a,
732
- y && /* @__PURE__ */ e(c, { color: "red", children: " *" })
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: " *" })
733
744
  ] }),
734
- /* @__PURE__ */ e(c, { size: "1", color: "gray", children: w ? `Up to ${u} files · ${fe(S)} each · ${pe($)}` : `${fe(S)} · ${pe($)}` })
745
+ /* @__PURE__ */ n(f, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(M)} each · ${ye(A)}` : `${me(M)} · ${ye(A)}` })
735
746
  ] }),
736
- I.map((i) => {
737
- var T;
738
- return /* @__PURE__ */ e(De, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ f(z, { align: "center", gap: "3", children: [
739
- /* @__PURE__ */ e(
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: [
750
+ /* @__PURE__ */ n(
740
751
  C,
741
752
  {
742
753
  style: {
@@ -746,11 +757,11 @@ const Br = ({
746
757
  color: "var(--blue-9)",
747
758
  flexShrink: 0
748
759
  },
749
- children: /* @__PURE__ */ e(Xe, { width: "20", height: "20" })
760
+ children: /* @__PURE__ */ n(Qe, { width: "20", height: "20" })
750
761
  }
751
762
  ),
752
- /* @__PURE__ */ e(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(
753
- c,
763
+ /* @__PURE__ */ n(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
764
+ f,
754
765
  {
755
766
  size: "2",
756
767
  weight: "bold",
@@ -760,208 +771,807 @@ const Br = ({
760
771
  textOverflow: "ellipsis",
761
772
  whiteSpace: "nowrap"
762
773
  },
763
- children: ((T = te[i]) == null ? void 0 : T.name) ?? "Uploaded File"
774
+ children: ((I = ee[b]) == null ? void 0 : I.name) ?? "Uploaded File"
764
775
  }
765
776
  ) }),
766
- /* @__PURE__ */ f(z, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
767
- /* @__PURE__ */ e(he, { variant: "soft", color: "blue", size: "1", onClick: (F) => q(F, i), children: "View" }),
768
- /* @__PURE__ */ e(Ye, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
769
- R && /* @__PURE__ */ e(Ze, { variant: "ghost", color: "gray", onClick: () => le(i), children: /* @__PURE__ */ e(er, {}) })
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, {}) })
770
781
  ] })
771
- ] }) }, i);
782
+ ] }) }, b);
772
783
  }),
773
- Z && /* @__PURE__ */ f(
784
+ fe && /* @__PURE__ */ p(
774
785
  "div",
775
786
  {
776
787
  role: "button",
777
788
  tabIndex: 0,
778
789
  onClick: () => {
779
- var i;
780
- return (i = U.current) == null ? void 0 : i.click();
790
+ var b;
791
+ return (b = F.current) == null ? void 0 : b.click();
781
792
  },
782
- onKeyDown: (i) => {
783
- var T;
784
- (i.key === "Enter" || i.key === " ") && (i.preventDefault(), (T = U.current) == null || T.click());
793
+ onKeyDown: (b) => {
794
+ var I;
795
+ (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (I = F.current) == null || I.click());
785
796
  },
786
- onDragEnter: M,
787
- onDragLeave: M,
788
- onDragOver: M,
789
- onDrop: oe,
797
+ onDragEnter: $,
798
+ onDragLeave: $,
799
+ onDragOver: $,
800
+ onDrop: Q,
790
801
  style: { cursor: "pointer" },
791
802
  className: [
792
803
  "border-2 border-dashed rounded-lg p-6 text-center",
793
804
  "transition-all duration-200 ease-in-out",
794
- k ? "border-blue-500 bg-blue-50" : O ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
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"
795
806
  ].join(" "),
796
807
  children: [
797
- /* @__PURE__ */ e("input", { ref: U, type: "file", style: { display: "none" }, accept: $, onChange: W }),
798
- /* @__PURE__ */ e(z, { direction: "column", align: "center", gap: "2", children: O ? /* @__PURE__ */ f(be, { children: [
799
- /* @__PURE__ */ e(rr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
800
- /* @__PURE__ */ e(c, { size: "2", color: "red", weight: "medium", children: O }),
801
- /* @__PURE__ */ e(c, { size: "1", color: "gray", children: "Click to try again" })
802
- ] }) : /* @__PURE__ */ f(be, { children: [
803
- /* @__PURE__ */ e(tr, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
804
- /* @__PURE__ */ e(c, { size: "2", weight: "medium", children: I.length > 0 ? `Add another file (${H} remaining)` : "Click to upload or drag and drop" }),
805
- /* @__PURE__ */ f(c, { size: "1", color: "gray", children: [
806
- fe(S),
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),
807
818
  " max · ",
808
- pe($)
819
+ ye(A)
809
820
  ] })
810
821
  ] }) })
811
822
  ]
812
823
  }
813
824
  ),
814
- R && B && w && /* @__PURE__ */ f(c, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
825
+ O && j && w && /* @__PURE__ */ p(f, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
815
826
  "Maximum ",
816
- u,
827
+ v,
817
828
  " files uploaded. Remove one to replace it."
818
829
  ] }),
819
- !x && /* @__PURE__ */ e(c, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: _(d, a) })
830
+ !y && /* @__PURE__ */ n(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: le(o, d) })
820
831
  ] });
821
- }, Mr = J(Br), Wr = D(
832
+ }, ht = oe(ft), pt = W(
822
833
  10,
823
834
  // high rank to beat default array renderer
824
- We(
835
+ vr(
825
836
  // Match both single-file (type: string) and multi-file (type: array)
826
- $e((t) => {
827
- if (t.type === "string" && t.format === "file") return !0;
828
- if (t.type === "array") {
829
- const r = t.items;
830
- return (r == null ? void 0 : r.type) === "string" && (r == null ? void 0 : r.format) === "file";
837
+ Fe((e) => {
838
+ if (e.type === "string" && e.format === "file") return !0;
839
+ if (e.type === "array") {
840
+ const t = e.items;
841
+ return (t == null ? void 0 : t.type) === "string" && (t == null ? void 0 : t.format) === "file";
831
842
  }
832
843
  return !1;
833
844
  })
834
845
  )
835
- ), Hr = ({
836
- data: t,
846
+ );
847
+ class Ue extends Error {
848
+ }
849
+ function gt(e, t) {
850
+ const r = Ir(e, { type: "array", cellDates: !0 });
851
+ 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 });
857
+ return {
858
+ sheetName: d,
859
+ matrix: a,
860
+ rowCount: a.length,
861
+ colCount: Math.max(0, ...a.map((c) => c.length))
862
+ };
863
+ }
864
+ function mt(e) {
865
+ let t = e + 1, r = "";
866
+ for (; t > 0; ) {
867
+ const d = (t - 1) % 26;
868
+ r = String.fromCharCode(65 + d) + r, t = Math.floor((t - 1) / 26);
869
+ }
870
+ return r;
871
+ }
872
+ class X extends Error {
873
+ constructor(r, d) {
874
+ super(d ?? r);
875
+ Pe(this, "code");
876
+ this.code = r, this.name = "FormulaError";
877
+ }
878
+ }
879
+ const yt = [
880
+ // Logical
881
+ // IF is excluded here even though its native body is real, non-stub code —
882
+ // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
883
+ // backfilled instead.
884
+ "IFS",
885
+ "IFERROR",
886
+ "AND",
887
+ "OR",
888
+ "NOT",
889
+ // Math
890
+ "ROUND",
891
+ "ROUNDUP",
892
+ "ROUNDDOWN",
893
+ // Lookup and reference
894
+ "INDEX",
895
+ "VLOOKUP",
896
+ "HLOOKUP",
897
+ // Statistical
898
+ "SUM",
899
+ "AVERAGE",
900
+ "COUNT",
901
+ // Date — DATE/TODAY only; YEAR/MONTH/DAY/WEEKDAY are backfilled below, see
902
+ // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
903
+ "DATE",
904
+ "TODAY"
905
+ ], vt = [
906
+ "MAX",
907
+ "MIN",
908
+ "MAXA",
909
+ "MINA",
910
+ "MEDIAN",
911
+ "LARGE",
912
+ "SMALL",
913
+ "PERMUT",
914
+ "PERMUTATIONA",
915
+ "MATCH",
916
+ // forced to exact-match only — see the MATCH wrapper below.
917
+ "SWITCH",
918
+ // a stub too, despite being implemented elsewhere in Excel's own function set.
919
+ "SUBSTITUTE",
920
+ "TEXTJOIN",
921
+ "COUNTA",
922
+ // not present in fast-formula-parser's function table at all.
923
+ "UPPER"
924
+ ], bt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Et = ["IF"], wt = [
925
+ "CONCATENATE",
926
+ "CONCAT",
927
+ "LEN",
928
+ "TRIM",
929
+ "LOWER",
930
+ "LEFT",
931
+ "RIGHT",
932
+ "MID",
933
+ "FIND",
934
+ "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;
945
+ 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.`);
950
+ }
951
+ }
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;
958
+ throw r.VALUE;
959
+ }
960
+ function ir(e) {
961
+ return e !== null && typeof e == "object" && "value" in e ? e.value : e;
962
+ }
963
+ function pe(e) {
964
+ const t = ir(e);
965
+ return Array.isArray(t) ? t.flat(1 / 0) : [t];
966
+ }
967
+ function N(e) {
968
+ const t = ir(e);
969
+ return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
970
+ }
971
+ function xe(e) {
972
+ return e === void 0 ? void 0 : N(e);
973
+ }
974
+ function H(e) {
975
+ return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
976
+ }
977
+ function St(e, t) {
978
+ return e instanceof t ? e : new t(e.message || "#ERROR!");
979
+ }
980
+ function k(e) {
981
+ return e.find((t) => t instanceof Error);
982
+ }
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);
991
+ }
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;
999
+ };
1000
+ return {
1001
+ // valueIfTrue/valueIfFalse are passed through unretrieved (not
1002
+ // dereferenced or type-checked here) — that's what makes
1003
+ // `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;
1008
+ },
1009
+ // Empty input -> 0, matching both the hand-rolled engine this replaces
1010
+ // 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),
1016
+ // COUNTA counts non-blank entries; an error value among the args is
1017
+ // itself non-blank and gets counted (matching formulajs's own COUNTA,
1018
+ // which never checks for errors), so this skips the error propagation
1019
+ // 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;
1026
+ },
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;
1032
+ },
1033
+ PERMUT: (a, c) => {
1034
+ const s = [N(a), N(c)], o = k(s);
1035
+ o && r(o);
1036
+ const i = e.PERMUT(s[0], s[1]);
1037
+ return i instanceof Error ? r(i) : i;
1038
+ },
1039
+ PERMUTATIONA: (a, c) => {
1040
+ const s = [N(a), N(c)], o = k(s);
1041
+ o && r(o);
1042
+ const i = e.PERMUTATIONA(s[0], s[1]);
1043
+ return i instanceof Error ? r(i) : i;
1044
+ },
1045
+ // match_type is intentionally ignored and forced to 0 (exact match)
1046
+ // regardless of what the formula author supplied — approximate/sorted
1047
+ // matching (formulajs's own default when the argument is omitted, and
1048
+ // Excel's own default too) risks silently mis-ranking unsorted
1049
+ // real-world data. Same scope decision as the hand-rolled engine this
1050
+ // 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;
1056
+ },
1057
+ SWITCH: (...a) => {
1058
+ const c = a.map(N), s = k(c);
1059
+ s && r(s);
1060
+ const o = e.SWITCH(...c);
1061
+ return o instanceof Error ? r(o) : o;
1062
+ },
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);
1069
+ return y instanceof Error ? r(y) : y;
1070
+ },
1071
+ TEXTJOIN: (a, c, ...s) => {
1072
+ const o = H(N(a)), i = N(c), l = s.flatMap(pe).map(H), y = k([o, i]);
1073
+ y && r(y);
1074
+ const h = e.TEXTJOIN(o, i, l);
1075
+ return h instanceof Error ? r(h) : h;
1076
+ },
1077
+ UPPER: g(e.UPPER),
1078
+ // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
1079
+ // 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;
1088
+ },
1089
+ // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1090
+ // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
1091
+ // Every text argument goes through this file's own null-safe toText()
1092
+ // rather than the library's own buggy coercer, so a blank cell reads as
1093
+ // empty text here the same way it always has for SUM/AVERAGE/COUNT.
1094
+ //
1095
+ // Flattens every argument (a whole range included) and joins with no
1096
+ // separator, matching Excel's own range-argument behavior — the native
1097
+ // 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));
1102
+ return o instanceof Error ? r(o) : o;
1103
+ },
1104
+ CONCAT: (...a) => {
1105
+ const c = a.flatMap(pe), s = k(c);
1106
+ s && r(s);
1107
+ const o = e.CONCAT(...c.map(H));
1108
+ return o instanceof Error ? r(o) : o;
1109
+ },
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;
1118
+ },
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;
1124
+ },
1125
+ MID: (a, c, s) => {
1126
+ const o = N(a), i = N(c), l = N(s), y = k([o, i, l]);
1127
+ y && r(y);
1128
+ const h = e.MID(H(o), i, l);
1129
+ return h instanceof Error ? r(h) : h;
1130
+ },
1131
+ FIND: (a, c, s) => {
1132
+ const o = N(a), i = N(c), l = xe(s), y = k([o, i]);
1133
+ y && r(y);
1134
+ const h = e.FIND(H(o), H(i), l);
1135
+ return h instanceof Error ? r(h) : h;
1136
+ },
1137
+ SEARCH: (a, c, s) => {
1138
+ const o = N(a), i = N(c), l = xe(s), y = k([o, i]);
1139
+ y && r(y);
1140
+ const h = e.SEARCH(H(o), H(i), l);
1141
+ return h instanceof Error ? r(h) : h;
1142
+ }
1143
+ };
1144
+ }
1145
+ const Ot = {
1146
+ "#REF!": "REF",
1147
+ "#VALUE!": "VALUE",
1148
+ "#DIV/0!": "DIV0",
1149
+ "#NAME?": "NAME",
1150
+ "#N/A": "NA",
1151
+ "#NUM!": "NUM",
1152
+ "#NULL!": "NULL"
1153
+ };
1154
+ function We(e) {
1155
+ return Ot[e.error] ?? "ERROR";
1156
+ }
1157
+ function Be(e, t) {
1158
+ if (e instanceof X) return e;
1159
+ if (e instanceof t) {
1160
+ 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);
1162
+ }
1163
+ return new X("ERROR", e instanceof Error ? e.message : void 0);
1164
+ }
1165
+ function It(e) {
1166
+ return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
1167
+ }
1168
+ function xt(e) {
1169
+ return (t) => {
1170
+ const r = e[t.row - 1];
1171
+ if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
1172
+ throw new X("REF");
1173
+ const d = r[t.col - 1];
1174
+ return d == null || d === "" ? null : d;
1175
+ };
1176
+ }
1177
+ function Lt(e) {
1178
+ 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)
1181
+ 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];
1189
+ y.push(v == null || v === "" ? null : v);
1190
+ }
1191
+ }
1192
+ o.push(y);
1193
+ }
1194
+ return o;
1195
+ };
1196
+ }
1197
+ function Mt(e) {
1198
+ if (e == null || e === "") return null;
1199
+ if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1200
+ return e;
1201
+ throw new X("VALUE");
1202
+ }
1203
+ async function Dt(e, t) {
1204
+ if (typeof t != "string") throw new X("ERROR");
1205
+ const r = t.trim();
1206
+ 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
+ import("fast-formula-parser"),
1211
+ import("@formulajs/formulajs")
1212
+ ]), c = g.default ?? g, s = c.FormulaError, o = new c({
1213
+ onCell: xt(e),
1214
+ onRange: Lt(e),
1215
+ // 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)
1217
+ });
1218
+ let i;
1219
+ try {
1220
+ i = o.parse(d, { row: 1, col: 1, sheet: "Sheet1" });
1221
+ } catch (l) {
1222
+ throw Be(l, s);
1223
+ }
1224
+ if (i instanceof s)
1225
+ throw Be(i, s);
1226
+ return Mt(i);
1227
+ }
1228
+ const Ke = {
1229
+ REF: "#REF!",
1230
+ VALUE: "#VALUE!",
1231
+ DIV0: "#DIV/0!",
1232
+ NAME: "#NAME?",
1233
+ ERROR: "#ERROR!",
1234
+ NA: "#N/A",
1235
+ NUM: "#NUM!",
1236
+ NULL: "#NULL!"
1237
+ };
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(
1240
+ t.map(async (r) => {
1241
+ try {
1242
+ if (!r || typeof r.label != "string" || typeof r.expression != "string")
1243
+ 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] };
1248
+ }
1249
+ })
1250
+ );
1251
+ }
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 = [];
1253
+ function Ce(e) {
1254
+ return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1255
+ }
1256
+ const _t = ({
1257
+ data: e,
1258
+ handleChange: t,
837
1259
  path: r,
838
- schema: n,
839
- uischema: a,
840
- enabled: y,
841
- visible: h,
842
- addItem: s,
843
- removeItems: v,
844
- rootSchema: d,
845
- arraySchema: g
1260
+ label: d,
1261
+ required: g,
1262
+ schema: a,
1263
+ enabled: c,
1264
+ errors: s,
1265
+ visible: o = !0
1266
+ }) => {
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.`);
1278
+ return;
1279
+ }
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)}`);
1282
+ return;
1283
+ }
1284
+ P("parsing");
1285
+ let te;
1286
+ 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."
1292
+ );
1293
+ return;
1294
+ }
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");
1301
+ },
1302
+ [u, v, M, z, h, r, t]
1303
+ );
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: " *" })
1324
+ ] }),
1325
+ /* @__PURE__ */ p(f, { size: "1", color: "gray", children: [
1326
+ me(v),
1327
+ " max · ",
1328
+ ye(u)
1329
+ ] })
1330
+ ] }),
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(
1350
+ "div",
1351
+ {
1352
+ role: "button",
1353
+ tabIndex: 0,
1354
+ onClick: () => {
1355
+ var E;
1356
+ return (E = K.current) == null ? void 0 : E.click();
1357
+ },
1358
+ onKeyDown: (E) => {
1359
+ var L;
1360
+ (E.key === "Enter" || E.key === " ") && (E.preventDefault(), (L = K.current) == null || L.click());
1361
+ },
1362
+ onDragEnter: se,
1363
+ onDragLeave: se,
1364
+ onDragOver: se,
1365
+ onDrop: ce,
1366
+ style: { cursor: "pointer" },
1367
+ className: [
1368
+ "border-2 border-dashed rounded-lg p-6 text-center",
1369
+ "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"
1371
+ ].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
+ ]
1391
+ }
1392
+ ),
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);
1400
+ })
1401
+ ] }) }),
1402
+ /* @__PURE__ */ n(ne.Body, { children: U.map((E, L) => {
1403
+ 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);
1409
+ }) })
1410
+ ] }) }),
1411
+ R.length > De && /* @__PURE__ */ p(f, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1412
+ "Showing first ",
1413
+ De,
1414
+ " of ",
1415
+ R.length,
1416
+ " rows"
1417
+ ] })
1418
+ ] }),
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 }) : (
1425
+ // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1426
+ // possible results anymore — INDEX/CONCATENATE can return a
1427
+ // string, a bare comparison can return a boolean, etc.), so
1428
+ // `.toLocaleString()` would throw for e.g. a boolean result.
1429
+ // Reuse the same formatCell used for the sheet-preview grid.
1430
+ /* @__PURE__ */ n(f, { size: "2", children: Ce(E.value) })
1431
+ )
1432
+ ] }, L)) })
1433
+ ] }),
1434
+ !i && /* @__PURE__ */ n(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: le(s, d) })
1435
+ ] });
1436
+ }, Pt = oe(_t), Vt = W(
1437
+ 10,
1438
+ // matches FileControlTester's rank — beats the default object/Group renderer
1439
+ Fe(
1440
+ (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1441
+ )
1442
+ ), Ht = ({
1443
+ data: e,
1444
+ path: t,
1445
+ schema: r,
1446
+ uischema: d,
1447
+ enabled: g,
1448
+ visible: a,
1449
+ addItem: c,
1450
+ removeItems: s,
1451
+ rootSchema: o,
1452
+ arraySchema: i
846
1453
  }) => {
847
- const l = g ? n : n.items, x = g || n;
848
- if (h === !1 || !l || typeof l != "object" || Array.isArray(l))
1454
+ const l = i ? r : r.items, y = i || r;
1455
+ if (a === !1 || !l || typeof l != "object" || Array.isArray(l))
849
1456
  return null;
850
- const p = l, o = Array.isArray(t) ? t : [], u = x.title || "Array Items", S = () => {
851
- const w = He(p, d);
852
- s && s(r, w)();
853
- }, $ = (w) => {
854
- if (v) {
855
- const R = v(r, [w]);
856
- R && R();
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)();
1460
+ }, A = (w) => {
1461
+ if (s) {
1462
+ const O = s(t, [w]);
1463
+ O && O();
857
1464
  }
858
1465
  };
859
- return /* @__PURE__ */ e(C, { mb: "6", children: /* @__PURE__ */ f(z, { direction: "column", gap: "4", children: [
860
- /* @__PURE__ */ e(c, { as: "div", size: "4", weight: "bold", children: u }),
861
- o.length === 0 && /* @__PURE__ */ e(C, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ e(c, { size: "2", color: "gray", children: "No items have been added yet." }) }),
862
- o.map((w, R) => {
863
- var V;
864
- const k = `${r}.${R}`;
865
- return /* @__PURE__ */ e(De, { size: "3", variant: "surface", children: /* @__PURE__ */ f(z, { direction: "column", gap: "4", children: [
866
- /* @__PURE__ */ f(z, { justify: "between", align: "center", children: [
867
- /* @__PURE__ */ f(c, { size: "3", weight: "bold", children: [
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: [
868
1475
  "Item ",
869
- R + 1
1476
+ O + 1
870
1477
  ] }),
871
- y && /* @__PURE__ */ f(
872
- he,
1478
+ g && /* @__PURE__ */ p(
1479
+ Le,
873
1480
  {
874
1481
  type: "button",
875
1482
  color: "red",
876
1483
  variant: "soft",
877
- onClick: () => $(R),
1484
+ onClick: () => A(O),
878
1485
  title: "Remove item",
879
1486
  children: [
880
- /* @__PURE__ */ e(nr, {}),
1487
+ /* @__PURE__ */ n(Sr, {}),
881
1488
  "Remove"
882
1489
  ]
883
1490
  }
884
1491
  )
885
1492
  ] }),
886
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(
887
- ce,
1493
+ /* @__PURE__ */ n(C, { children: /* @__PURE__ */ n(
1494
+ Se,
888
1495
  {
889
- schema: p,
890
- uischema: ((V = a.options) == null ? void 0 : V.detail) || (p.type === "object" || p.properties ? {
1496
+ schema: h,
1497
+ uischema: ((S = d.options) == null ? void 0 : S.detail) || (h.type === "object" || h.properties ? {
891
1498
  type: "VerticalLayout",
892
- elements: Object.keys(p.properties || {}).map((O) => ({
1499
+ elements: Object.keys(h.properties || {}).map((q) => ({
893
1500
  type: "Control",
894
- scope: `#/properties/${O}`
1501
+ scope: `#/properties/${q}`
895
1502
  }))
896
1503
  } : {
897
1504
  type: "Control",
898
1505
  scope: "#"
899
1506
  }),
900
- path: k,
901
- enabled: y,
1507
+ path: z,
1508
+ enabled: g,
902
1509
  renderers: void 0,
903
1510
  cells: void 0
904
1511
  }
905
1512
  ) })
906
- ] }) }, k);
1513
+ ] }) }, z);
907
1514
  }),
908
- y && /* @__PURE__ */ e(C, { mt: "2", children: /* @__PURE__ */ f(he, { type: "button", variant: "surface", onClick: S, children: [
909
- /* @__PURE__ */ e(or, {}),
1515
+ g && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ p(Le, { type: "button", variant: "surface", onClick: M, children: [
1516
+ /* @__PURE__ */ n(Nr, {}),
910
1517
  "Add Item"
911
1518
  ] }) })
912
1519
  ] }) });
913
- }, xe = Je(Hr), Kr = D(3, Ke), Gr = ({ uischema: t, visible: r }) => {
914
- const n = t;
915
- return r === !1 ? null : /* @__PURE__ */ e(C, { mb: "4", children: /* @__PURE__ */ e(Fe, { size: "4", children: n.text }) });
916
- }, Jr = D(1, ie("Label")), _r = D(3, Ge), ot = [
917
- { tester: ar, renderer: dr },
918
- { tester: fr, renderer: pr },
919
- { tester: gr, renderer: mr },
920
- { tester: vr, renderer: br },
921
- { tester: Rr, renderer: Tr },
922
- { tester: Cr, renderer: xr },
923
- { tester: Dr, renderer: Or },
924
- { tester: Lr, renderer: Ir },
925
- { tester: Ur, renderer: Ar },
926
- { tester: Vr, renderer: Er },
927
- { tester: Nr, renderer: jr },
928
- { tester: Wr, renderer: Mr },
929
- { tester: Kr, renderer: xe },
930
- { tester: _r, renderer: xe },
931
- { tester: Jr, renderer: Gr }
1520
+ }, Ge = Rr(Ht), Wt = W(3, Er), Bt = ({ uischema: e, visible: t }) => {
1521
+ 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 },
1528
+ { tester: qr, renderer: Zr },
1529
+ { tester: Gr, renderer: Xr },
1530
+ { tester: rt, renderer: tt },
1531
+ { tester: ot, renderer: nt },
1532
+ { tester: it, renderer: lt },
1533
+ { 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 }
932
1540
  ];
933
1541
  export {
934
- xe as ArrayControl,
935
- Kr as ArrayControlTester,
936
- hr as BooleanControl,
937
- gr as BooleanControlTester,
938
- jr as CategorizationLayoutRenderer,
939
- Nr as CategorizationLayoutTester,
940
- Fr as DateControl,
941
- Dr as DateControlTester,
942
- Mr as FileControl,
943
- Wr as FileControlTester,
944
- Er as GroupLayoutRenderer,
945
- Vr as GroupLayoutTester,
946
- Ar as HorizontalLayoutRenderer,
947
- Ur as HorizontalLayoutTester,
948
- Gr as LabelRenderer,
949
- Jr as LabelTester,
950
- ur as NumberControl,
951
- fr as NumberControlTester,
952
- yr as RadioControl,
953
- vr as RadioControlTester,
954
- Tr as SearchSelectControl,
955
- Rr as SearchSelectControlTester,
956
- nt as SearchServiceProvider,
957
- wr as SelectControl,
958
- Cr as SelectControlTester,
959
- sr as TextControl,
960
- ar as TextControlTester,
961
- tt as UploadProvider,
962
- Ir as VerticalLayoutRenderer,
963
- Lr as VerticalLayoutTester,
964
- ot as radixRenderers,
965
- cr as useSearchService,
966
- ir as useUpload
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
967
1577
  };