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