@opennsw/jsonforms-renderers 0.3.1 → 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,182 +1,195 @@
1
- import { jsx as e, jsxs as z, Fragment as ge } from "react/jsx-runtime";
2
- import { createContext as xe, useContext as ze, useEffect as q, useState as fe, useRef as ye, useCallback as Te } from "react";
3
- import { rankWith as N, isStringControl as ke, or as me, isNumberControl as Oe, isIntegerControl as Le, isBooleanControl as Fe, isEnumControl as we, isOneOfControl as Ce, isDateControl as Re, isDateTimeControl as Ae, isTimeControl as Ue, uiTypeIs as ie, and as _e, schemaMatches as Ie, createDefaultValue as je, isObjectArrayControl as Ve, isPrimitiveArrayControl as We } from "@jsonforms/core";
4
- import { withJsonFormsControlProps as Q, JsonFormsDispatch as se, withJsonFormsArrayControlProps as Ye } from "@jsonforms/react";
5
- import { Box as U, Flex as R, Text as D, TextField as oe, Checkbox as Ne, RadioGroup as ve, Select as ce, Tabs as ae, Heading as Se, Card as De, Button as pe, IconButton as Ee } from "@radix-ui/themes";
6
- import { FileTextIcon as He, CheckCircledIcon as Pe, Cross2Icon as Be, ExclamationTriangleIcon as Je, UploadIcon as Ge, TrashIcon as qe, PlusIcon as Ke } from "@radix-ui/react-icons";
7
- const Me = xe(null);
8
- function Bt({
9
- children: o,
10
- onUpload: r,
11
- getDownloadUrl: t
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
12
17
  }) {
13
- const y = { onUpload: r, getDownloadUrl: t };
14
- return /* @__PURE__ */ e(Me.Provider, { value: y, children: o });
18
+ const d = { onUpload: t, getDownloadUrl: r };
19
+ return /* @__PURE__ */ n(je.Provider, { value: d, children: e });
15
20
  }
16
- function Ze() {
17
- return ze(Me);
21
+ function Sr() {
22
+ return He(je);
18
23
  }
19
- const X = (o, r) => o ? o.split(`
20
- `).map((t) => t.trim() === "is a required property" ? `${r || "This field"} is required` : t).join(`
21
- `) : "", Qe = ({
22
- data: o,
23
- handleChange: r,
24
- path: t,
25
- label: y,
26
- required: x,
27
- errors: S,
28
- uischema: a,
29
- schema: M,
30
- enabled: h,
31
- visible: f = !0
24
+ const er = We(null);
25
+ function Qt({
26
+ children: e,
27
+ services: t
28
+ }) {
29
+ const r = lr(() => t, [t]);
30
+ return /* @__PURE__ */ n(er.Provider, { value: r, children: e });
31
+ }
32
+ function Nr(e) {
33
+ const t = He(er);
34
+ return !t || !e ? null : t[e] ?? null;
35
+ }
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
32
53
  }) => {
33
- var T;
34
- if (q(() => {
35
- f === !1 && r(t, void 0);
36
- }, [f, t, r]), f === !1)
54
+ var y;
55
+ if (fe(i, r, t), i === !1)
37
56
  return null;
38
- const d = S.length === 0;
39
- return /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ z(R, { direction: "column", gap: "1", children: [
40
- /* @__PURE__ */ z(D, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
41
- y,
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,
42
61
  " ",
43
- x && /* @__PURE__ */ e(D, { color: "red", children: "*" })
62
+ m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
44
63
  ] }),
45
- /* @__PURE__ */ e(
46
- oe.Root,
64
+ /* @__PURE__ */ n(
65
+ ye.Root,
47
66
  {
48
- value: o || "",
49
- onChange: (w) => r(t, w.target.value),
50
- disabled: !h,
51
- placeholder: (T = a.options) == null ? void 0 : T.placeholder,
52
- color: d ? void 0 : "red",
53
- id: t
67
+ value: e || "",
68
+ onChange: (p) => t(r, p.target.value),
69
+ disabled: !o,
70
+ placeholder: (y = c.options) == null ? void 0 : y.placeholder,
71
+ color: l ? void 0 : "red",
72
+ id: r
54
73
  }
55
74
  ),
56
- !d && /* @__PURE__ */ e(D, { color: "red", size: "1", children: X(S, y) }),
57
- M.description && /* @__PURE__ */ e(D, { size: "1", color: "gray", children: M.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 })
58
77
  ] }) });
59
- }, Xe = N(1, ke), et = Q(Qe), tt = ({
60
- data: o,
61
- handleChange: r,
62
- path: t,
63
- label: y,
64
- required: x,
65
- errors: S,
66
- uischema: a,
67
- schema: M,
68
- enabled: h,
69
- visible: f = !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
70
89
  }) => {
71
- var w;
72
- if (q(() => {
73
- f === !1 && r(t, void 0);
74
- }, [f, t, r]), f === !1)
90
+ var p;
91
+ if (fe(i, r, t), i === !1)
75
92
  return null;
76
- const d = S.length === 0, T = ($) => {
77
- if ($ === "") {
78
- r(t, void 0);
93
+ const l = a.length === 0, y = (f) => {
94
+ if (f === "") {
95
+ t(r, void 0);
79
96
  return;
80
97
  }
81
- const m = Number($);
82
- isNaN(m) || r(t, m);
98
+ const v = Number(f);
99
+ isNaN(v) || t(r, v);
83
100
  };
84
- return /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ z(R, { direction: "column", gap: "1", children: [
85
- /* @__PURE__ */ z(D, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
86
- y,
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,
87
104
  " ",
88
- x && /* @__PURE__ */ e(D, { color: "red", children: "*" })
105
+ m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
89
106
  ] }),
90
- /* @__PURE__ */ e(
91
- oe.Root,
107
+ /* @__PURE__ */ n(
108
+ ye.Root,
92
109
  {
93
110
  type: "number",
94
- value: o ?? "",
95
- onChange: ($) => T($.target.value),
96
- disabled: !h,
97
- placeholder: (w = a.options) == null ? void 0 : w.placeholder,
98
- color: d ? void 0 : "red",
99
- id: t
111
+ value: e ?? "",
112
+ onChange: (f) => y(f.target.value),
113
+ disabled: !o,
114
+ placeholder: (p = c.options) == null ? void 0 : p.placeholder,
115
+ color: l ? void 0 : "red",
116
+ id: r
100
117
  }
101
118
  ),
102
- !d && /* @__PURE__ */ e(D, { color: "red", size: "1", children: X(S, y) }),
103
- M.description && /* @__PURE__ */ e(D, { size: "1", color: "gray", children: M.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 })
104
121
  ] }) });
105
- }, rt = N(2, me(Oe, Le)), nt = Q(tt), ot = ({
106
- data: o,
107
- handleChange: r,
108
- path: t,
109
- label: y,
110
- required: x,
111
- errors: S,
112
- schema: a,
113
- enabled: M,
114
- visible: h = !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
115
132
  }) => {
116
- if (q(() => {
117
- h === !1 && r(t, void 0);
118
- }, [h, t, r]), h === !1)
133
+ if (fe(o, r, t), o === !1)
119
134
  return null;
120
- const f = S.length === 0;
121
- return /* @__PURE__ */ z(U, { mb: "4", children: [
122
- /* @__PURE__ */ z(R, { gap: "2", align: "center", children: [
123
- /* @__PURE__ */ e(
124
- Ne,
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,
125
140
  {
126
- checked: !!o,
127
- onCheckedChange: (d) => r(t, d === !0),
128
- disabled: !M,
129
- id: t
141
+ checked: !!e,
142
+ onCheckedChange: (l) => t(r, l === !0),
143
+ disabled: !s,
144
+ id: r
130
145
  }
131
146
  ),
132
- /* @__PURE__ */ z(D, { as: "label", size: "2", htmlFor: t, children: [
133
- y,
147
+ /* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
148
+ d,
134
149
  " ",
135
- x && "*"
150
+ m && "*"
136
151
  ] })
137
152
  ] }),
138
- !f && /* @__PURE__ */ e(D, { color: "red", size: "1", className: "block mt-1", children: X(S, y) }),
139
- a.description && /* @__PURE__ */ e(D, { size: "1", color: "gray", className: "block mt-1", children: a.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 })
140
155
  ] });
141
- }, it = N(2, Fe), st = Q(ot), lt = ({
142
- data: o,
143
- handleChange: r,
144
- path: t,
145
- label: y,
146
- required: x,
147
- errors: S,
148
- schema: a,
149
- enabled: M,
150
- visible: h = !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
151
166
  }) => {
152
- if (q(() => {
153
- h === !1 && r(t, void 0);
154
- }, [h, t, r]), h === !1)
167
+ if (fe(o, r, t), o === !1)
155
168
  return null;
156
- const f = S.length === 0;
157
- let d = [];
158
- a.enum ? d = a.enum.map((w) => ({ value: w, label: String(w) })) : a.oneOf && (d = a.oneOf.map((w) => ({
159
- value: w.const,
160
- label: w.title || String(w.const)
169
+ const i = a.length === 0;
170
+ let l = [];
171
+ c.enum ? l = c.enum.map((p) => ({ value: p, label: String(p) })) : c.oneOf && (l = c.oneOf.map((p) => ({
172
+ value: p.const,
173
+ label: p.title || String(p.const)
161
174
  })));
162
- const T = o;
163
- return /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ z(R, { direction: "column", gap: "1", children: [
164
- /* @__PURE__ */ z(D, { as: "div", size: "2", weight: "bold", children: [
165
- y,
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,
166
179
  " ",
167
- x && /* @__PURE__ */ e(D, { color: "red", children: "*" })
180
+ m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
168
181
  ] }),
169
- /* @__PURE__ */ e(
170
- ve.Root,
182
+ /* @__PURE__ */ n(
183
+ ke.Root,
171
184
  {
172
- value: T !== void 0 ? String(T) : "",
173
- onValueChange: (w) => {
174
- const $ = d.find((m) => String(m.value) === w);
175
- $ && r(t, $.value);
185
+ value: y !== void 0 ? String(y) : "",
186
+ onValueChange: (p) => {
187
+ const f = l.find((v) => String(v.value) === p);
188
+ f && t(r, f.value);
176
189
  },
177
- disabled: !M,
178
- children: /* @__PURE__ */ e(
179
- R,
190
+ disabled: !s,
191
+ children: /* @__PURE__ */ n(
192
+ T,
180
193
  {
181
194
  direction: "row",
182
195
  style: {
@@ -184,636 +197,551 @@ const X = (o, r) => o ? o.split(`
184
197
  columnGap: "clamp(14px, 3vw, 36px)",
185
198
  rowGap: "clamp(8px, 1.6vw, 14px)"
186
199
  },
187
- children: d.map((w) => /* @__PURE__ */ z(R, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
188
- /* @__PURE__ */ e(ve.Item, { value: String(w.value) }),
189
- /* @__PURE__ */ e(D, { size: "2", color: M ? void 0 : "gray", children: w.label })
190
- ] }, String(w.value)))
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 })
203
+ ] }, String(p.value)))
191
204
  }
192
205
  )
193
206
  }
194
207
  ),
195
- !f && /* @__PURE__ */ e(D, { color: "red", size: "1", children: X(S, y) }),
196
- a.description && /* @__PURE__ */ e(D, { size: "1", color: "gray", children: a.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 })
197
210
  ] }) });
198
- }, ct = (o, r, t) => {
199
- var x;
200
- return me(we, Ce)(o, r, t) && ((x = o == null ? void 0 : o.options) == null ? void 0 : x.format) === "radio" ? 3 : -1;
201
- }, at = Q(lt), ut = ({
202
- data: o,
203
- handleChange: r,
204
- path: t,
205
- label: y,
206
- required: x,
207
- errors: S,
208
- schema: a,
209
- uischema: M,
210
- enabled: h,
211
- visible: f = !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
212
225
  }) => {
213
- var $;
214
- if (q(() => {
215
- f === !1 && r(t, void 0);
216
- }, [f, t, r]), f === !1)
226
+ var f;
227
+ if (fe(i, r, t), i === !1)
217
228
  return null;
218
- const d = S.length === 0;
219
- let T = [];
220
- a.enum ? T = a.enum.map((m) => ({ value: String(m), label: String(m) })) : a.oneOf && (T = a.oneOf.map((m) => ({
221
- value: String(m.const),
222
- label: m.title || String(m.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)
223
234
  })));
224
- const w = o !== void 0 ? String(o) : "";
225
- return /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ z(R, { direction: "column", gap: "1", children: [
226
- /* @__PURE__ */ z(D, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
227
- y,
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,
228
239
  " ",
229
- x && /* @__PURE__ */ e(D, { color: "red", children: "*" })
240
+ m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
230
241
  ] }),
231
- /* @__PURE__ */ z(ce.Root, { value: w, onValueChange: (m) => r(t, m), disabled: !h, children: [
232
- /* @__PURE__ */ e(
233
- ce.Trigger,
242
+ /* @__PURE__ */ g(Ce.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
243
+ /* @__PURE__ */ n(
244
+ Ce.Trigger,
234
245
  {
235
- placeholder: (($ = M.options) == null ? void 0 : $.placeholder) || "Select an option",
236
- color: d ? void 0 : "red",
237
- id: t
246
+ placeholder: ((f = s.options) == null ? void 0 : f.placeholder) || "Select an option",
247
+ color: l ? void 0 : "red",
248
+ id: r
238
249
  }
239
250
  ),
240
- /* @__PURE__ */ e(ce.Content, { children: T.map((m) => /* @__PURE__ */ e(ce.Item, { value: m.value, children: m.label }, m.value)) })
251
+ /* @__PURE__ */ n(Ce.Content, { children: y.map((v) => /* @__PURE__ */ n(Ce.Item, { value: v.value, children: v.label }, v.value)) })
241
252
  ] }),
242
- !d && /* @__PURE__ */ e(D, { color: "red", size: "1", children: X(S, y) }),
243
- a.description && /* @__PURE__ */ e(D, { size: "1", color: "gray", children: a.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 })
244
255
  ] }) });
245
- }, dt = N(2, me(we, Ce)), ft = Q(ut);
246
- function ht(o) {
247
- return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
248
- }
249
- var he = { exports: {} }, mt = he.exports, $e;
250
- function pt() {
251
- return $e || ($e = 1, (function(o, r) {
252
- (function(t, y) {
253
- o.exports = y();
254
- })(mt, (function() {
255
- var t = 1e3, y = 6e4, x = 36e5, S = "millisecond", a = "second", M = "minute", h = "hour", f = "day", d = "week", T = "month", w = "quarter", $ = "year", m = "date", _ = "Invalid Date", I = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, O = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, A = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(u) {
256
- var l = ["th", "st", "nd", "rd"], n = u % 100;
257
- return "[" + u + (l[(n - 20) % 10] || l[n] || l[0]) + "]";
258
- } }, J = function(u, l, n) {
259
- var c = String(u);
260
- return !c || c.length >= l ? u : "" + Array(l + 1 - c.length).join(n) + u;
261
- }, K = { s: J, z: function(u) {
262
- var l = -u.utcOffset(), n = Math.abs(l), c = Math.floor(n / 60), i = n % 60;
263
- return (l <= 0 ? "+" : "-") + J(c, 2, "0") + ":" + J(i, 2, "0");
264
- }, m: function u(l, n) {
265
- if (l.date() < n.date()) return -u(n, l);
266
- var c = 12 * (n.year() - l.year()) + (n.month() - l.month()), i = l.clone().add(c, T), p = n - i < 0, g = l.clone().add(c + (p ? -1 : 1), T);
267
- return +(-(c + (n - i) / (p ? i - g : g - i)) || 0);
268
- }, a: function(u) {
269
- return u < 0 ? Math.ceil(u) || 0 : Math.floor(u);
270
- }, p: function(u) {
271
- return { M: T, y: $, w: d, d: f, D: m, h, m: M, s: a, ms: S, Q: w }[u] || String(u || "").toLowerCase().replace(/s$/, "");
272
- }, u: function(u) {
273
- return u === void 0;
274
- } }, H = "en", j = {};
275
- j[H] = A;
276
- var te = "$isDayjsObject", ee = function(u) {
277
- return u instanceof B || !(!u || !u[te]);
278
- }, P = function u(l, n, c) {
279
- var i;
280
- if (!l) return H;
281
- if (typeof l == "string") {
282
- var p = l.toLowerCase();
283
- j[p] && (i = p), n && (j[p] = n, i = p);
284
- var g = l.split("-");
285
- if (!i && g.length > 1) return u(g[0]);
286
- } else {
287
- var s = l.name;
288
- j[s] = l, i = s;
289
- }
290
- return !c && i && (H = i), i || !c && H;
291
- }, L = function(u, l) {
292
- if (ee(u)) return u.clone();
293
- var n = typeof l == "object" ? l : {};
294
- return n.date = u, n.args = arguments, new B(n);
295
- }, C = K;
296
- C.l = P, C.i = ee, C.w = function(u, l) {
297
- return L(u, { locale: l.$L, utc: l.$u, x: l.$x, $offset: l.$offset });
298
- };
299
- var B = (function() {
300
- function u(n) {
301
- this.$L = P(n.locale, null, !0), this.parse(n), this.$x = this.$x || n.x || {}, this[te] = !0;
302
- }
303
- var l = u.prototype;
304
- return l.parse = function(n) {
305
- this.$d = (function(c) {
306
- var i = c.date, p = c.utc;
307
- if (i === null) return /* @__PURE__ */ new Date(NaN);
308
- if (C.u(i)) return /* @__PURE__ */ new Date();
309
- if (i instanceof Date) return new Date(i);
310
- if (typeof i == "string" && !/Z$/i.test(i)) {
311
- var g = i.match(I);
312
- if (g) {
313
- var s = g[2] - 1 || 0, v = (g[7] || "0").substring(0, 3);
314
- return p ? new Date(Date.UTC(g[1], s, g[3] || 1, g[4] || 0, g[5] || 0, g[6] || 0, v)) : new Date(g[1], s, g[3] || 1, g[4] || 0, g[5] || 0, g[6] || 0, v);
256
+ }, Vr = W(2, Ne(Be, Ke)), Hr = le(Pr), Wr = {
257
+ "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
258
+ "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
259
+ "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
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
271
+ }) => {
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;
277
+ return;
278
+ }
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);
283
+ }).catch(() => {
284
+ }), () => {
285
+ u = !0;
286
+ };
287
+ }, [e, S]);
288
+ const E = De(
289
+ async (u, w = !1) => {
290
+ var j;
291
+ if (!S) {
292
+ G("Search service not configured.");
293
+ return;
294
+ }
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));
298
+ try {
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);
305
+ } catch {
306
+ if (de.signal.aborted) return;
307
+ G("Failed to load results. Please try again.");
308
+ } finally {
309
+ de.signal.aborted || (w ? D(!1) : X(!1));
310
+ }
311
+ },
312
+ [S, f == null ? void 0 : f.paginated]
313
+ );
314
+ if (pe(() => {
315
+ if (!L) return;
316
+ const u = (w) => {
317
+ N.current && !N.current.contains(w.target) && O(!1);
318
+ };
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;
327
+ return;
328
+ }
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);
335
+ };
336
+ }, [F, L, v, E]), fe(s, r, t, null), s === !1)
337
+ return null;
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,
350
+ " ",
351
+ m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
352
+ ] }),
353
+ /* @__PURE__ */ g("div", { ref: N, style: { position: "relative" }, children: [
354
+ /* @__PURE__ */ n(
355
+ ye.Root,
356
+ {
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());
365
+ },
366
+ onFocus: () => {
367
+ C && !L && V();
368
+ },
369
+ onKeyDown: (u) => {
370
+ u.key === "Escape" && O(!1);
371
+ },
372
+ children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(T, { align: "center", gap: "1", children: [
373
+ e && C && /* @__PURE__ */ n(
374
+ "span",
375
+ {
376
+ role: "button",
377
+ tabIndex: 0,
378
+ onMouseDown: (u) => u.preventDefault(),
379
+ onClick: Z,
380
+ onKeyDown: Q,
381
+ style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
382
+ "aria-label": "Clear selection",
383
+ children: "×"
315
384
  }
316
- }
317
- return new Date(i);
318
- })(n), this.init();
319
- }, l.init = function() {
320
- var n = this.$d;
321
- this.$y = n.getFullYear(), this.$M = n.getMonth(), this.$D = n.getDate(), this.$W = n.getDay(), this.$H = n.getHours(), this.$m = n.getMinutes(), this.$s = n.getSeconds(), this.$ms = n.getMilliseconds();
322
- }, l.$utils = function() {
323
- return C;
324
- }, l.isValid = function() {
325
- return this.$d.toString() !== _;
326
- }, l.isSame = function(n, c) {
327
- var i = L(n);
328
- return this.startOf(c) <= i && i <= this.endOf(c);
329
- }, l.isAfter = function(n, c) {
330
- return L(n) < this.startOf(c);
331
- }, l.isBefore = function(n, c) {
332
- return this.endOf(c) < L(n);
333
- }, l.$g = function(n, c, i) {
334
- return C.u(n) ? this[c] : this.set(i, n);
335
- }, l.unix = function() {
336
- return Math.floor(this.valueOf() / 1e3);
337
- }, l.valueOf = function() {
338
- return this.$d.getTime();
339
- }, l.startOf = function(n, c) {
340
- var i = this, p = !!C.u(c) || c, g = C.p(n), s = function(Z, W) {
341
- var G = C.w(i.$u ? Date.UTC(i.$y, W, Z) : new Date(i.$y, W, Z), i);
342
- return p ? G : G.endOf(f);
343
- }, v = function(Z, W) {
344
- return C.w(i.toDate()[Z].apply(i.toDate("s"), (p ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(W)), i);
345
- }, k = this.$W, b = this.$M, F = this.$D, V = "set" + (this.$u ? "UTC" : "");
346
- switch (g) {
347
- case $:
348
- return p ? s(1, 0) : s(31, 11);
349
- case T:
350
- return p ? s(1, b) : s(0, b + 1);
351
- case d:
352
- var Y = this.$locale().weekStart || 0, E = (k < Y ? k + 7 : k) - Y;
353
- return s(p ? F - E : F + (6 - E), b);
354
- case f:
355
- case m:
356
- return v(V + "Hours", 0);
357
- case h:
358
- return v(V + "Minutes", 1);
359
- case M:
360
- return v(V + "Seconds", 2);
361
- case a:
362
- return v(V + "Milliseconds", 3);
363
- default:
364
- return this.clone();
365
- }
366
- }, l.endOf = function(n) {
367
- return this.startOf(n, !1);
368
- }, l.$set = function(n, c) {
369
- var i, p = C.p(n), g = "set" + (this.$u ? "UTC" : ""), s = (i = {}, i[f] = g + "Date", i[m] = g + "Date", i[T] = g + "Month", i[$] = g + "FullYear", i[h] = g + "Hours", i[M] = g + "Minutes", i[a] = g + "Seconds", i[S] = g + "Milliseconds", i)[p], v = p === f ? this.$D + (c - this.$W) : c;
370
- if (p === T || p === $) {
371
- var k = this.clone().set(m, 1);
372
- k.$d[s](v), k.init(), this.$d = k.set(m, Math.min(this.$D, k.daysInMonth())).$d;
373
- } else s && this.$d[s](v);
374
- return this.init(), this;
375
- }, l.set = function(n, c) {
376
- return this.clone().$set(n, c);
377
- }, l.get = function(n) {
378
- return this[C.p(n)]();
379
- }, l.add = function(n, c) {
380
- var i, p = this;
381
- n = Number(n);
382
- var g = C.p(c), s = function(b) {
383
- var F = L(p);
384
- return C.w(F.date(F.date() + Math.round(b * n)), p);
385
- };
386
- if (g === T) return this.set(T, this.$M + n);
387
- if (g === $) return this.set($, this.$y + n);
388
- if (g === f) return s(1);
389
- if (g === d) return s(7);
390
- var v = (i = {}, i[M] = y, i[h] = x, i[a] = t, i)[g] || 1, k = this.$d.getTime() + n * v;
391
- return C.w(k, this);
392
- }, l.subtract = function(n, c) {
393
- return this.add(-1 * n, c);
394
- }, l.format = function(n) {
395
- var c = this, i = this.$locale();
396
- if (!this.isValid()) return i.invalidDate || _;
397
- var p = n || "YYYY-MM-DDTHH:mm:ssZ", g = C.z(this), s = this.$H, v = this.$m, k = this.$M, b = i.weekdays, F = i.months, V = i.meridiem, Y = function(W, G, ne, le) {
398
- return W && (W[G] || W(c, p)) || ne[G].slice(0, le);
399
- }, E = function(W) {
400
- return C.s(s % 12 || 12, W, "0");
401
- }, Z = V || function(W, G, ne) {
402
- var le = W < 12 ? "AM" : "PM";
403
- return ne ? le.toLowerCase() : le;
404
- };
405
- return p.replace(O, (function(W, G) {
406
- return G || (function(ne) {
407
- switch (ne) {
408
- case "YY":
409
- return String(c.$y).slice(-2);
410
- case "YYYY":
411
- return C.s(c.$y, 4, "0");
412
- case "M":
413
- return k + 1;
414
- case "MM":
415
- return C.s(k + 1, 2, "0");
416
- case "MMM":
417
- return Y(i.monthsShort, k, F, 3);
418
- case "MMMM":
419
- return Y(F, k);
420
- case "D":
421
- return c.$D;
422
- case "DD":
423
- return C.s(c.$D, 2, "0");
424
- case "d":
425
- return String(c.$W);
426
- case "dd":
427
- return Y(i.weekdaysMin, c.$W, b, 2);
428
- case "ddd":
429
- return Y(i.weekdaysShort, c.$W, b, 3);
430
- case "dddd":
431
- return b[c.$W];
432
- case "H":
433
- return String(s);
434
- case "HH":
435
- return C.s(s, 2, "0");
436
- case "h":
437
- return E(1);
438
- case "hh":
439
- return E(2);
440
- case "a":
441
- return Z(s, v, !0);
442
- case "A":
443
- return Z(s, v, !1);
444
- case "m":
445
- return String(v);
446
- case "mm":
447
- return C.s(v, 2, "0");
448
- case "s":
449
- return String(c.$s);
450
- case "ss":
451
- return C.s(c.$s, 2, "0");
452
- case "SSS":
453
- return C.s(c.$ms, 3, "0");
454
- case "Z":
455
- return g;
385
+ ),
386
+ /* @__PURE__ */ n(
387
+ Er,
388
+ {
389
+ style: { transform: L ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
456
390
  }
457
- return null;
458
- })(W) || g.replace(":", "");
459
- }));
460
- }, l.utcOffset = function() {
461
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
462
- }, l.diff = function(n, c, i) {
463
- var p, g = this, s = C.p(c), v = L(n), k = (v.utcOffset() - this.utcOffset()) * y, b = this - v, F = function() {
464
- return C.m(g, v);
465
- };
466
- switch (s) {
467
- case $:
468
- p = F() / 12;
469
- break;
470
- case T:
471
- p = F();
472
- break;
473
- case w:
474
- p = F() / 3;
475
- break;
476
- case d:
477
- p = (b - k) / 6048e5;
478
- break;
479
- case f:
480
- p = (b - k) / 864e5;
481
- break;
482
- case h:
483
- p = b / x;
484
- break;
485
- case M:
486
- p = b / y;
487
- break;
488
- case a:
489
- p = b / t;
490
- break;
491
- default:
492
- p = b;
493
- }
494
- return i ? p : C.a(p);
495
- }, l.daysInMonth = function() {
496
- return this.endOf(T).$D;
497
- }, l.$locale = function() {
498
- return j[this.$L];
499
- }, l.locale = function(n, c) {
500
- if (!n) return this.$L;
501
- var i = this.clone(), p = P(n, c, !0);
502
- return p && (i.$L = p), i;
503
- }, l.clone = function() {
504
- return C.w(this.$d, this);
505
- }, l.toDate = function() {
506
- return new Date(this.valueOf());
507
- }, l.toJSON = function() {
508
- return this.isValid() ? this.toISOString() : null;
509
- }, l.toISOString = function() {
510
- return this.$d.toISOString();
511
- }, l.toString = function() {
512
- return this.$d.toUTCString();
513
- }, u;
514
- })(), re = B.prototype;
515
- return L.prototype = re, [["$ms", S], ["$s", a], ["$m", M], ["$H", h], ["$W", f], ["$M", T], ["$y", $], ["$D", m]].forEach((function(u) {
516
- re[u[1]] = function(l) {
517
- return this.$g(l, u[0], u[1]);
518
- };
519
- })), L.extend = function(u, l) {
520
- return u.$i || (u(l, B, L), u.$i = !0), L;
521
- }, L.locale = P, L.isDayjs = ee, L.unix = function(u) {
522
- return L(1e3 * u);
523
- }, L.en = j[H], L.Ls = j, L.p = {}, L;
524
- }));
525
- })(he)), he.exports;
526
- }
527
- var gt = pt();
528
- const yt = /* @__PURE__ */ ht(gt), vt = (o, r) => yt(`${o}T${r}`).format(), $t = ({ path: o, label: r, required: t, errors: y, description: x, children: S }) => {
529
- const a = y.length === 0;
530
- return /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ z(R, { direction: "column", gap: "1", children: [
531
- /* @__PURE__ */ z(D, { as: "label", size: "2", weight: "bold", htmlFor: o, children: [
532
- r,
391
+ )
392
+ ] }) })
393
+ }
394
+ ),
395
+ L && /* @__PURE__ */ n(
396
+ R,
397
+ {
398
+ style: {
399
+ position: "absolute",
400
+ top: "calc(100% + 4px)",
401
+ left: 0,
402
+ right: 0,
403
+ zIndex: 50,
404
+ background: "var(--color-panel-solid)",
405
+ borderRadius: "var(--radius-3)",
406
+ boxShadow: "var(--shadow-5)",
407
+ border: "1px solid var(--gray-a6)",
408
+ overflow: "hidden"
409
+ },
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,
416
+ {
417
+ px: "3",
418
+ py: "2",
419
+ onMouseDown: (w) => w.preventDefault(),
420
+ onClick: () => J(u),
421
+ style: {
422
+ cursor: "pointer",
423
+ borderRadius: "var(--radius-2)",
424
+ backgroundColor: u.id === e ? "var(--accent-3)" : void 0
425
+ },
426
+ className: "hover:bg-(--gray-3)",
427
+ children: /* @__PURE__ */ n(h, { size: "2", children: u.name })
428
+ },
429
+ u.id
430
+ )),
431
+ (f == null ? void 0 : f.paginated) && se && !te && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(
432
+ Se,
433
+ {
434
+ variant: "ghost",
435
+ size: "1",
436
+ style: { width: "100%" },
437
+ onMouseDown: (u) => u.preventDefault(),
438
+ onClick: () => void E(F, !0),
439
+ children: "Load more"
440
+ }
441
+ ) }),
442
+ te && /* @__PURE__ */ n(T, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
443
+ ] }) })
444
+ }
445
+ )
446
+ ] }),
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 })
449
+ ] }) });
450
+ }, Kr = le(Br), Gr = W(
451
+ 3,
452
+ Me((e) => {
453
+ const t = e["x-search"];
454
+ return e.type === "string" && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
455
+ })
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,
533
461
  " ",
534
- t && /* @__PURE__ */ e(D, { color: "red", children: "*" })
462
+ r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
535
463
  ] }),
536
- S,
537
- !a && /* @__PURE__ */ e(D, { color: "red", size: "1", children: X(y, r) }),
538
- x && /* @__PURE__ */ e(D, { size: "1", color: "gray", children: x })
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 })
539
467
  ] }) });
540
- }, bt = ({
541
- data: o,
542
- handleChange: r,
543
- path: t,
544
- label: y,
545
- required: x,
546
- errors: S,
547
- schema: a,
548
- enabled: M,
549
- visible: h = !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
550
478
  }) => {
551
- if (q(() => {
552
- h === !1 && r(t, void 0);
553
- }, [h, t, r]), h === !1)
479
+ if (pe(() => {
480
+ o === !1 && t(r, void 0);
481
+ }, [o, r, t]), o === !1)
554
482
  return null;
555
- const f = S.length === 0, d = typeof o == "string" ? o : "", T = (O) => /* @__PURE__ */ e($t, { path: t, label: y, required: x, errors: S, description: a.description, children: O });
556
- if (a.format === "time")
557
- return T(
558
- /* @__PURE__ */ e(
559
- oe.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,
560
488
  {
561
489
  type: "time",
562
- value: d,
563
- onChange: (O) => r(t, O.target.value),
564
- disabled: !M,
565
- color: f ? void 0 : "red",
566
- id: t
490
+ value: l,
491
+ onChange: (C) => t(r, C.target.value),
492
+ disabled: !s,
493
+ color: i ? void 0 : "red",
494
+ id: r
567
495
  }
568
496
  )
569
497
  );
570
- const w = a.format === "date-time", [$ = "", m = ""] = d.split("T"), _ = m.slice(0, 5), I = (O, A) => {
571
- if (!O) {
572
- r(t, 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);
573
501
  return;
574
502
  }
575
- r(t, w ? vt(O, A || "00:00") : O);
503
+ t(r, p ? Xr(C, I || "00:00") : C);
576
504
  };
577
- return T(
578
- /* @__PURE__ */ z(R, { gap: "2", align: "center", children: [
579
- /* @__PURE__ */ e(
580
- oe.Root,
505
+ return y(
506
+ /* @__PURE__ */ g(T, { gap: "2", align: "center", children: [
507
+ /* @__PURE__ */ n(
508
+ ye.Root,
581
509
  {
582
510
  type: "date",
583
- value: $,
584
- disabled: !M,
585
- color: f ? void 0 : "red",
586
- onChange: (O) => I(O.target.value, _),
587
- id: t,
511
+ value: f,
512
+ disabled: !s,
513
+ color: i ? void 0 : "red",
514
+ onChange: (C) => x(C.target.value, S),
515
+ id: r,
588
516
  style: { flex: 1 }
589
517
  }
590
518
  ),
591
- w && /* @__PURE__ */ e(
592
- oe.Root,
519
+ p && /* @__PURE__ */ n(
520
+ ye.Root,
593
521
  {
594
522
  type: "time",
595
- value: _,
596
- disabled: !M || !$,
597
- color: f ? void 0 : "red",
598
- onChange: (O) => I($, O.target.value),
523
+ value: S,
524
+ disabled: !s || !f,
525
+ color: i ? void 0 : "red",
526
+ onChange: (C) => x(f, C.target.value),
599
527
  style: { flex: 1 }
600
528
  }
601
529
  )
602
530
  ] })
603
531
  );
604
- }, wt = N(2, me(Re, Ae, Ue)), Ct = Q(bt), St = ({
605
- uischema: o,
606
- schema: r,
607
- path: t,
608
- renderers: y,
609
- cells: x,
610
- enabled: S,
611
- visible: a = !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
612
540
  }) => {
613
- const h = o.elements;
614
- return a === !1 ? null : /* @__PURE__ */ e(R, { direction: "column", gap: "4", children: h.map((f, d) => /* @__PURE__ */ e(
615
- se,
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,
616
544
  {
617
- uischema: f,
618
- schema: r,
619
- path: t,
620
- renderers: y,
621
- cells: x,
622
- enabled: S
545
+ uischema: i,
546
+ schema: t,
547
+ path: r,
548
+ renderers: d,
549
+ cells: m,
550
+ enabled: a
623
551
  },
624
- `${t}-${d}`
552
+ `${r}-${l}`
625
553
  )) });
626
- }, Dt = N(1, ie("VerticalLayout")), Mt = ({
627
- uischema: o,
628
- schema: r,
629
- path: t,
630
- renderers: y,
631
- cells: x,
632
- enabled: S,
633
- visible: a = !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
634
562
  }) => {
635
- const h = o.elements;
636
- return a === !1 ? null : /* @__PURE__ */ e(R, { direction: "row", gap: "4", children: h.map((f, d) => /* @__PURE__ */ e(U, { style: { flex: 1 }, children: /* @__PURE__ */ e(
637
- se,
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,
638
566
  {
639
- uischema: f,
640
- schema: r,
641
- path: t,
642
- renderers: y,
643
- cells: x,
644
- enabled: S
567
+ uischema: i,
568
+ schema: t,
569
+ path: r,
570
+ renderers: d,
571
+ cells: m,
572
+ enabled: a
645
573
  }
646
- ) }, `${t}-${d}`)) });
647
- }, xt = N(1, ie("HorizontalLayout")), zt = ({
648
- uischema: o,
649
- schema: r,
650
- path: t,
651
- renderers: y,
652
- cells: x,
653
- enabled: S,
654
- visible: a = !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
655
583
  }) => {
656
- const M = o, h = M.elements;
657
- return a === !1 ? null : /* @__PURE__ */ z(U, { mb: "6", children: [
658
- M.label && /* @__PURE__ */ e(Se, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: M.label }),
659
- /* @__PURE__ */ e(R, { direction: "column", gap: "4", children: h.map((f, d) => /* @__PURE__ */ e(
660
- se,
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,
661
589
  {
662
- uischema: f,
663
- schema: r,
664
- path: t,
665
- renderers: y,
666
- cells: x,
667
- enabled: S
590
+ uischema: i,
591
+ schema: t,
592
+ path: r,
593
+ renderers: d,
594
+ cells: m,
595
+ enabled: a
668
596
  },
669
- `${t}-${d}`
597
+ `${r}-${l}`
670
598
  )) })
671
599
  ] });
672
- }, Tt = N(1, ie("Group")), kt = ({
673
- uischema: o,
674
- schema: r,
675
- path: t,
676
- renderers: y,
677
- cells: x,
678
- enabled: S,
679
- visible: a = !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
680
608
  }) => {
681
- var w;
682
- const h = o.elements.filter(($) => $.type === "Category"), [f, d] = fe(((w = h[0]) == null ? void 0 : w.label) || "");
683
- if (a === !1 || !h.length) return null;
684
- const T = h.find(($) => $.label === f) ? f : h[0].label;
685
- return /* @__PURE__ */ z(ae.Root, { value: T, onValueChange: d, children: [
686
- /* @__PURE__ */ e(ae.List, { children: h.map(($, m) => /* @__PURE__ */ e(ae.Trigger, { value: $.label, children: $.label }, `${t}-${m}`)) }),
687
- /* @__PURE__ */ e(U, { pt: "3", children: h.map(($, m) => /* @__PURE__ */ e(ae.Content, { value: $.label, children: /* @__PURE__ */ e(R, { direction: "column", gap: "4", children: $.elements.map((_, I) => /* @__PURE__ */ e(
688
- se,
609
+ var p;
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,
689
617
  {
690
- uischema: _,
691
- schema: r,
692
- path: t,
693
- renderers: y,
694
- cells: x,
695
- enabled: S
618
+ uischema: S,
619
+ schema: t,
620
+ path: r,
621
+ renderers: d,
622
+ cells: m,
623
+ enabled: a
696
624
  },
697
- `${t}-${m}-${I}`
698
- )) }) }, `${t}-${m}`)) })
625
+ `${r}-${v}-${x}`
626
+ )) }) }, `${r}-${v}`)) })
699
627
  ] });
700
- }, Ot = N(1, ie("Categorization"));
701
- function Lt(o) {
702
- return o ? Array.isArray(o) ? o : [o] : [];
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`;
703
631
  }
704
- function ue(o) {
705
- return o >= 1024 * 1024 ? `${(o / (1024 * 1024)).toFixed(0)} MB` : o >= 1024 ? `${(o / 1024).toFixed(0)} KB` : `${o} B`;
706
- }
707
- function de(o) {
708
- return o.split(",").map((r) => {
709
- if (r = r.trim(), r.endsWith("/*"))
710
- return r.split("/")[0].toUpperCase() + "S";
711
- if (r.startsWith("."))
712
- return r.slice(1).toUpperCase();
713
- const t = r.split("/")[1];
714
- return t ? t.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;
715
640
  }).join(", ");
716
641
  }
717
- const Ft = ({
718
- data: o,
719
- handleChange: r,
720
- path: t,
721
- label: y,
722
- required: x,
723
- uischema: S,
724
- schema: a,
725
- enabled: M,
726
- errors: h,
727
- visible: f = !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
728
656
  }) => {
729
- const d = Ze();
730
- if (q(() => {
731
- f === !1 && r(t, null);
732
- }, [f, t, r]), f === !1)
733
- return null;
734
- const T = !h || h.length === 0, w = (a == null ? void 0 : a["x-file"]) ?? {}, $ = (S == null ? void 0 : S.options) ?? {}, m = w.maxFiles ?? $.maxFiles ?? 1, _ = w.maxSize ?? $.maxSize ?? 5 * 1024 * 1024, I = w.accept ?? $.accept ?? "image/*,application/pdf", O = m > 1, A = M !== !1, [J, K] = fe(!1), [H, j] = fe(null), [te, ee] = fe({}), P = ye(/* @__PURE__ */ new Set()), L = ye(null), C = Lt(o), B = C.length >= m;
735
- q(() => () => {
736
- P.current.forEach((s) => URL.revokeObjectURL(s)), P.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();
737
662
  }, []);
738
- const re = Te(
739
- async (s) => {
740
- if (j(null), C.length >= m) {
741
- j(`Maximum ${m} file${m > 1 ? "s" : ""} allowed.`);
663
+ const te = De(
664
+ async (b) => {
665
+ if ($(null), P.length >= v) {
666
+ $(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
742
667
  return;
743
668
  }
744
- if (s.size > _) {
745
- j(`File exceeds the ${ue(_)} limit.`);
669
+ if (b.size > S) {
670
+ $(`File exceeds the ${ge(S)} limit.`);
746
671
  return;
747
672
  }
748
- if (!I.split(",").map((b) => b.trim()).some((b) => b === "*" || b === "*/*" ? !0 : b.endsWith("/*") ? s.type.startsWith(b.slice(0, -1)) : b.startsWith(".") ? s.name.toLowerCase().endsWith(b.toLowerCase()) : s.type === b)) {
749
- j(`Invalid type. Accepted: ${de(I)}`);
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)}`);
750
675
  return;
751
676
  }
752
- if (!(d != null && d.onUpload)) {
753
- j("Upload service not configured.");
677
+ if (!(l != null && l.onUpload)) {
678
+ $("Upload service not configured.");
754
679
  return;
755
680
  }
756
681
  try {
757
- const b = await d.onUpload(s), F = URL.createObjectURL(s);
758
- P.current.add(F);
759
- const V = { key: b.key, name: b.name ?? s.name, blobUrl: F };
760
- ee((E) => ({ ...E, [b.key]: V }));
761
- const Y = [...C, b.key];
762
- r(t, O ? Y : Y[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]);
763
688
  } catch {
764
- j("Upload failed. Please try again."), L.current && (L.current.value = "");
689
+ $("Upload failed. Please try again."), B.current && (B.current.value = "");
765
690
  }
766
691
  },
767
- [C, m, _, I, d, t, r, O]
768
- ), u = (s) => {
769
- s.preventDefault(), s.stopPropagation(), !(!A || B) && K(s.type === "dragenter" || s.type === "dragover");
770
- }, l = (s) => {
771
- var v;
772
- s.preventDefault(), s.stopPropagation(), K(!1), !(!A || B) && (v = s.dataTransfer.files) != null && v[0] && re(s.dataTransfer.files[0]);
773
- }, n = (s) => {
774
- var v;
775
- (v = s.target.files) != null && v[0] && (re(s.target.files[0]), s.target.value = "");
776
- }, c = (s) => {
777
- if (!A) return;
778
- ee((k) => {
779
- var V;
780
- const b = { ...k }, F = (V = b[s]) == null ? void 0 : V.blobUrl;
781
- return F && (URL.revokeObjectURL(F), P.current.delete(F)), delete b[s], b;
692
+ [P, v, S, x, l, r, t, C]
693
+ );
694
+ if (i === !1)
695
+ return null;
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;
782
710
  });
783
- const v = C.filter((k) => k !== s);
784
- r(t, O ? v.length > 0 ? v : null : v[0] ?? null);
785
- }, i = async (s, v) => {
786
- var F, V, Y;
787
- s.preventDefault();
788
- const k = (F = te[v]) == null ? void 0 : F.blobUrl;
789
- if (k) {
790
- (V = window.open(k, "_blank", "noopener,noreferrer")) == null || V.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();
791
719
  return;
792
720
  }
793
- const b = window.open("", "_blank");
794
- if (b)
721
+ const E = window.open("", "_blank");
722
+ if (E)
795
723
  try {
796
- const E = await ((Y = d == null ? void 0 : d.getDownloadUrl) == null ? void 0 : Y.call(d, v));
797
- E != null && E.url ? b.location.href = E.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();
798
726
  } catch {
799
- b.close();
727
+ E.close();
800
728
  }
801
729
  };
802
- if (!A && C.length === 0) return null;
803
- const p = m - C.length, g = A && !B;
804
- return /* @__PURE__ */ z(U, { mb: "4", children: [
805
- /* @__PURE__ */ z(R, { align: "center", justify: "between", mb: "2", children: [
806
- /* @__PURE__ */ z(D, { as: "label", size: "2", weight: "bold", children: [
807
- y,
808
- x && /* @__PURE__ */ e(D, { 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: " *" })
809
737
  ] }),
810
- /* @__PURE__ */ e(D, { size: "1", color: "gray", children: O ? `Up to ${m} files · ${ue(_)} each · ${de(I)}` : `${ue(_)} · ${de(I)}` })
738
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: C ? `Up to ${v} files · ${ge(S)} each · ${me(x)}` : `${ge(S)} · ${me(x)}` })
811
739
  ] }),
812
- C.map((s) => {
813
- var v;
814
- return /* @__PURE__ */ e(De, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ z(R, { align: "center", gap: "3", children: [
815
- /* @__PURE__ */ e(
816
- U,
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,
817
745
  {
818
746
  style: {
819
747
  background: "var(--blue-3)",
@@ -822,11 +750,11 @@ const Ft = ({
822
750
  color: "var(--blue-9)",
823
751
  flexShrink: 0
824
752
  },
825
- children: /* @__PURE__ */ e(He, { width: "20", height: "20" })
753
+ children: /* @__PURE__ */ n(Ye, { width: "20", height: "20" })
826
754
  }
827
755
  ),
828
- /* @__PURE__ */ e(U, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ e(
829
- D,
756
+ /* @__PURE__ */ n(R, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
757
+ h,
830
758
  {
831
759
  size: "2",
832
760
  weight: "bold",
@@ -836,204 +764,807 @@ const Ft = ({
836
764
  textOverflow: "ellipsis",
837
765
  whiteSpace: "nowrap"
838
766
  },
839
- children: ((v = te[s]) == null ? void 0 : v.name) ?? "Uploaded File"
767
+ children: ((N = re[b]) == null ? void 0 : N.name) ?? "Uploaded File"
840
768
  }
841
769
  ) }),
842
- /* @__PURE__ */ z(R, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
843
- /* @__PURE__ */ e(pe, { variant: "soft", color: "blue", size: "1", onClick: (k) => i(k, s), children: "View" }),
844
- /* @__PURE__ */ e(Pe, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
845
- A && /* @__PURE__ */ e(Ee, { variant: "ghost", color: "gray", onClick: () => c(s), children: /* @__PURE__ */ e(Be, {}) })
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, {}) })
846
774
  ] })
847
- ] }) }, s);
775
+ ] }) }, b);
848
776
  }),
849
- g && /* @__PURE__ */ z(
777
+ ne && /* @__PURE__ */ g(
850
778
  "div",
851
779
  {
852
780
  role: "button",
853
781
  tabIndex: 0,
854
782
  onClick: () => {
855
- var s;
856
- return (s = L.current) == null ? void 0 : s.click();
783
+ var b;
784
+ return (b = B.current) == null ? void 0 : b.click();
857
785
  },
858
- onKeyDown: (s) => {
859
- var v;
860
- (s.key === "Enter" || s.key === " ") && (s.preventDefault(), (v = L.current) == null || v.click());
786
+ onKeyDown: (b) => {
787
+ var N;
788
+ (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (N = B.current) == null || N.click());
861
789
  },
862
- onDragEnter: u,
863
- onDragLeave: u,
864
- onDragOver: u,
865
- onDrop: l,
790
+ onDragEnter: D,
791
+ onDragLeave: D,
792
+ onDragOver: D,
793
+ onDrop: ce,
866
794
  style: { cursor: "pointer" },
867
795
  className: [
868
796
  "border-2 border-dashed rounded-lg p-6 text-center",
869
797
  "transition-all duration-200 ease-in-out",
870
- J ? "border-blue-500 bg-blue-50" : H ? "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"
871
799
  ].join(" "),
872
800
  children: [
873
- /* @__PURE__ */ e("input", { ref: L, type: "file", style: { display: "none" }, accept: I, onChange: n }),
874
- /* @__PURE__ */ e(R, { direction: "column", align: "center", gap: "2", children: H ? /* @__PURE__ */ z(ge, { children: [
875
- /* @__PURE__ */ e(Je, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
876
- /* @__PURE__ */ e(D, { size: "2", color: "red", weight: "medium", children: H }),
877
- /* @__PURE__ */ e(D, { size: "1", color: "gray", children: "Click to try again" })
878
- ] }) : /* @__PURE__ */ z(ge, { children: [
879
- /* @__PURE__ */ e(Ge, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
880
- /* @__PURE__ */ e(D, { size: "2", weight: "medium", children: C.length > 0 ? `Add another file (${p} remaining)` : "Click to upload or drag and drop" }),
881
- /* @__PURE__ */ z(D, { size: "1", color: "gray", children: [
882
- ue(_),
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),
883
811
  " max · ",
884
- de(I)
812
+ me(x)
885
813
  ] })
886
814
  ] }) })
887
815
  ]
888
816
  }
889
817
  ),
890
- A && B && O && /* @__PURE__ */ z(D, { 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: [
891
819
  "Maximum ",
892
- m,
820
+ v,
893
821
  " files uploaded. Remove one to replace it."
894
822
  ] }),
895
- !T && /* @__PURE__ */ e(D, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: X(h, y) })
823
+ !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ie(o, d) })
896
824
  ] });
897
- }, Rt = Q(Ft), At = N(
825
+ }, ct = le(st), at = W(
898
826
  10,
899
827
  // high rank to beat default array renderer
900
- _e(
828
+ hr(
901
829
  // Match both single-file (type: string) and multi-file (type: array)
902
- Ie((o) => {
903
- if (o.type === "string" && o.format === "file") return !0;
904
- if (o.type === "array") {
905
- const r = o.items;
906
- 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";
907
835
  }
908
836
  return !1;
909
837
  })
910
838
  )
911
- ), Ut = ({
912
- data: o,
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,
913
1252
  path: r,
914
- schema: t,
915
- uischema: y,
916
- enabled: x,
917
- visible: S,
918
- addItem: a,
919
- removeItems: M,
920
- rootSchema: h,
921
- arraySchema: f
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
922
1446
  }) => {
923
- const d = f ? t : t.items, T = f || t;
924
- if (S === !1 || !d || typeof d != "object" || Array.isArray(d))
1447
+ const l = i ? r : r.items, y = i || r;
1448
+ if (a === !1 || !l || typeof l != "object" || Array.isArray(l))
925
1449
  return null;
926
- const w = d, $ = Array.isArray(o) ? o : [], m = T.title || "Array Items", _ = () => {
927
- const O = je(w, h);
928
- a && a(r, O)();
929
- }, I = (O) => {
930
- if (M) {
931
- const A = M(r, [O]);
932
- A && A();
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();
933
1457
  }
934
1458
  };
935
- return /* @__PURE__ */ e(U, { mb: "6", children: /* @__PURE__ */ z(R, { direction: "column", gap: "4", children: [
936
- /* @__PURE__ */ e(D, { as: "div", size: "4", weight: "bold", children: m }),
937
- $.length === 0 && /* @__PURE__ */ e(U, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ e(D, { size: "2", color: "gray", children: "No items have been added yet." }) }),
938
- $.map((O, A) => {
939
- var K;
940
- const J = `${r}.${A}`;
941
- return /* @__PURE__ */ e(De, { size: "3", variant: "surface", children: /* @__PURE__ */ z(R, { direction: "column", gap: "4", children: [
942
- /* @__PURE__ */ z(R, { justify: "between", align: "center", children: [
943
- /* @__PURE__ */ z(D, { 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: [
944
1468
  "Item ",
945
- A + 1
1469
+ I + 1
946
1470
  ] }),
947
- x && /* @__PURE__ */ z(
948
- pe,
1471
+ m && /* @__PURE__ */ g(
1472
+ Se,
949
1473
  {
950
1474
  type: "button",
951
1475
  color: "red",
952
1476
  variant: "soft",
953
- onClick: () => I(A),
1477
+ onClick: () => x(I),
954
1478
  title: "Remove item",
955
1479
  children: [
956
- /* @__PURE__ */ e(qe, {}),
1480
+ /* @__PURE__ */ n(wr, {}),
957
1481
  "Remove"
958
1482
  ]
959
1483
  }
960
1484
  )
961
1485
  ] }),
962
- /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e(
963
- se,
1486
+ /* @__PURE__ */ n(R, { children: /* @__PURE__ */ n(
1487
+ Re,
964
1488
  {
965
- schema: w,
966
- uischema: ((K = y.options) == null ? void 0 : K.detail) || (w.type === "object" || w.properties ? {
1489
+ schema: p,
1490
+ uischema: ((O = d.options) == null ? void 0 : O.detail) || (p.type === "object" || p.properties ? {
967
1491
  type: "VerticalLayout",
968
- elements: Object.keys(w.properties || {}).map((H) => ({
1492
+ elements: Object.keys(p.properties || {}).map((F) => ({
969
1493
  type: "Control",
970
- scope: `#/properties/${H}`
1494
+ scope: `#/properties/${F}`
971
1495
  }))
972
1496
  } : {
973
1497
  type: "Control",
974
1498
  scope: "#"
975
1499
  }),
976
- path: J,
977
- enabled: x,
1500
+ path: L,
1501
+ enabled: m,
978
1502
  renderers: void 0,
979
1503
  cells: void 0
980
1504
  }
981
1505
  ) })
982
- ] }) }, J);
1506
+ ] }) }, L);
983
1507
  }),
984
- x && /* @__PURE__ */ e(U, { mt: "2", children: /* @__PURE__ */ z(pe, { type: "button", variant: "surface", onClick: _, children: [
985
- /* @__PURE__ */ e(Ke, {}),
1508
+ m && /* @__PURE__ */ n(R, { mt: "2", children: /* @__PURE__ */ g(Se, { type: "button", variant: "surface", onClick: S, children: [
1509
+ /* @__PURE__ */ n(Rr, {}),
986
1510
  "Add Item"
987
1511
  ] }) })
988
1512
  ] }) });
989
- }, be = Ye(Ut), _t = N(3, Ve), It = ({ uischema: o, visible: r }) => {
990
- const t = o;
991
- return r === !1 ? null : /* @__PURE__ */ e(U, { mb: "4", children: /* @__PURE__ */ e(Se, { size: "4", children: t.text }) });
992
- }, jt = N(1, ie("Label")), Vt = N(3, We), Jt = [
993
- { tester: Xe, renderer: et },
994
- { tester: rt, renderer: nt },
995
- { tester: it, renderer: st },
996
- { tester: ct, renderer: at },
997
- { tester: dt, renderer: ft },
998
- { tester: wt, renderer: Ct },
999
- { tester: Dt, renderer: St },
1000
- { tester: xt, renderer: Mt },
1001
- { tester: Tt, renderer: zt },
1002
- { tester: Ot, renderer: kt },
1003
- { tester: At, renderer: Rt },
1004
- { tester: _t, renderer: be },
1005
- { tester: Vt, renderer: be },
1006
- { tester: jt, renderer: It }
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 }
1007
1533
  ];
1008
1534
  export {
1009
- be as ArrayControl,
1010
- _t as ArrayControlTester,
1011
- ot as BooleanControl,
1012
- it as BooleanControlTester,
1013
- kt as CategorizationLayoutRenderer,
1014
- Ot as CategorizationLayoutTester,
1015
- bt as DateControl,
1016
- wt as DateControlTester,
1017
- Rt as FileControl,
1018
- At as FileControlTester,
1019
- zt as GroupLayoutRenderer,
1020
- Tt as GroupLayoutTester,
1021
- Mt as HorizontalLayoutRenderer,
1022
- xt as HorizontalLayoutTester,
1023
- It as LabelRenderer,
1024
- jt as LabelTester,
1025
- tt as NumberControl,
1026
- rt as NumberControlTester,
1027
- lt as RadioControl,
1028
- ct as RadioControlTester,
1029
- ut as SelectControl,
1030
- dt as SelectControlTester,
1031
- Qe as TextControl,
1032
- Xe as TextControlTester,
1033
- Bt as UploadProvider,
1034
- St as VerticalLayoutRenderer,
1035
- Dt as VerticalLayoutTester,
1036
- X as getErrorMessage,
1037
- Jt as radixRenderers,
1038
- Ze 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
1039
1570
  };