@overmap-ai/forms 1.0.4-conditional-arrows.3 → 1.0.4-conditional-arrows.5

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.
package/dist/forms.js CHANGED
@@ -1,19 +1,19 @@
1
- var Ut = Object.defineProperty;
2
- var Gt = (s, i, e) => i in s ? Ut(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
- var m = (s, i, e) => (Gt(s, typeof i != "symbol" ? i + "" : i, e), e);
4
- import { jsx as o, jsxs as b, Fragment as wt } from "react/jsx-runtime";
5
- import { Flex as y, Text as D, useSeverityColor as me, Checkbox as Kt, CheckCircledIcon as Yt, TextField as ae, FontFamilyIcon as Qt, CalendarIcon as Xt, InputIcon as Jt, TextArea as Zt, RowsIcon as ei, Select as vt, Box as ge, IconButton as ce, PlusIcon as Oe, Badge as Ue, Cross1Icon as It, ListBulletIcon as ti, DropdownMenuIcon as ii, MultiSelect as ni, CheckboxIcon as ri, Card as xe, Heading as Re, Button as K, UploadIcon as Ct, ButtonList as Ne, divButtonProps as oi, StarFilledIcon as si, StarIcon as li, QuestionMarkCircledIcon as ai, PersonIcon as ci, Tooltip as di, Avatar as ui, Separator as fi, Dialog as mi, Pencil1Icon as pi, TrashIcon as hi, CopyIcon as gi, DragHandleDots2Icon as bi, DropdownMenu as yi, DotsVerticalIcon as xi, useAlertDialog as wi, Em as vi, Strong as mt, useToast as Ii, Tabs as J } from "@overmap-ai/blocks";
6
- import { useField as Ze, useFormikContext as pe, useFormik as et, FormikProvider as tt } from "formik";
7
- import Ci, { useMemo as I, memo as z, useCallback as T, useState as de, useEffect as we, useRef as it, forwardRef as ve, useReducer as Fi } from "react";
8
- import { DragDropContext as Ft, Droppable as nt, Draggable as rt } from "@hello-pangea/dnd";
9
- import { slugify as Ti, useAppSelector as M, selectFormRevision as Tt, useSDK as St, selectSubmissionAttachments as Si, selectFilteredUserForms as zi, selectUserFormMapping as Ei, selectOrganization as zt, selectUser as ot, selectNumberOfUserForms as Ai, selectCurrentUser as Et, classNames as At, isToday as Li, getLocalDateString as Pi, selectLatestFormRevision as ki, useFileSrc as Vi, selectSubmissionsForForm as Di } from "@overmap-ai/core";
10
- import ue from "lodash.get";
11
- import st from "lodash.set";
12
- class Lt {
1
+ var qt = Object.defineProperty;
2
+ var Wt = (s, i, e) => i in s ? qt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var p = (s, i, e) => (Wt(s, typeof i != "symbol" ? i + "" : i, e), e);
4
+ import { jsx as r, jsxs as b, Fragment as Xe } from "react/jsx-runtime";
5
+ import { Flex as y, Text as D, useSeverityColor as pe, Checkbox as jt, CheckCircledIcon as Ht, TextField as ce, FontFamilyIcon as Ut, CalendarIcon as Gt, InputIcon as Kt, TextArea as Yt, RowsIcon as Xt, Select as gt, Box as be, IconButton as de, PlusIcon as De, Badge as We, Cross1Icon as bt, ListBulletIcon as Qt, DropdownMenuIcon as Jt, MultiSelect as Zt, CheckboxIcon as ei, Card as xe, Heading as $e, Button as K, UploadIcon as yt, ButtonList as _e, divButtonProps as ti, StarFilledIcon as ii, StarIcon as ni, QuestionMarkCircledIcon as ri, PersonIcon as oi, Tooltip as si, Avatar as li, Separator as ai, Dialog as ci, Pencil1Icon as di, TrashIcon as ui, CopyIcon as fi, DragHandleDots2Icon as mi, DropdownMenu as pi, DotsVerticalIcon as hi, useAlertDialog as gi, Em as bi, Strong as ct, useToast as yi, Tabs as Z } from "@overmap-ai/blocks";
6
+ import { useField as Qe, useFormikContext as he, useFormik as Je, FormikProvider as Ze } from "formik";
7
+ import wi, { useMemo as F, memo as z, useCallback as T, useState as X, useEffect as ue, useRef as wt, forwardRef as ve, useReducer as xi } from "react";
8
+ import { DragDropContext as xt, Droppable as et, Draggable as tt } from "@hello-pangea/dnd";
9
+ import { slugify as vi, useAppSelector as N, selectFormRevision as vt, useSDK as It, selectSubmissionAttachments as Ii, selectFilteredUserForms as Fi, selectUserFormMapping as Ci, selectOrganization as Ft, selectUser as it, selectNumberOfUserForms as Ti, selectCurrentUser as Ct, classNames as Tt, isToday as Si, getLocalDateString as zi, selectLatestFormRevision as Ei, useFileSrc as Ai, selectSubmissionsForForm as Li } from "@overmap-ai/core";
10
+ import fe from "lodash.get";
11
+ import nt from "lodash.set";
12
+ class St {
13
13
  constructor(i) {
14
- m(this, "type");
15
- m(this, "identifier");
16
- m(this, "description");
14
+ p(this, "type");
15
+ p(this, "identifier");
16
+ p(this, "description");
17
17
  const { description: e = null, identifier: t, type: n } = i;
18
18
  this.identifier = t, this.description = e, this.type = n;
19
19
  }
@@ -33,22 +33,22 @@ class Lt {
33
33
  };
34
34
  }
35
35
  }
36
- class O extends Lt {
36
+ class R extends St {
37
37
  constructor(e) {
38
- const { label: t, required: n, fieldValidators: r = [], formValidators: a = [], ...c } = e;
38
+ const { label: t, required: n, fieldValidators: o = [], formValidators: a = [], ...c } = e;
39
39
  super(c);
40
- m(this, "required");
41
- m(this, "formValidators");
42
- m(this, "fieldValidators");
43
- m(this, "label");
40
+ p(this, "required");
41
+ p(this, "formValidators");
42
+ p(this, "fieldValidators");
43
+ p(this, "label");
44
44
  /**
45
45
  * By default, validation doesn't execute on `onChange` events when editing fields
46
46
  * until the field has been `touched`. This can be overridden by setting this to `false`
47
47
  * if you want to validate on every `onChange` event. This is important for fields like booleans
48
48
  * which don't have a `onBlur` event (which is used to set the `touched` state).
49
49
  */
50
- m(this, "onlyValidateAfterTouched", !0);
51
- this.label = t, this.required = n, this.fieldValidators = r, this.formValidators = a;
50
+ p(this, "onlyValidateAfterTouched", !0);
51
+ this.label = t, this.required = n, this.fieldValidators = o, this.formValidators = a;
52
52
  }
53
53
  static getFieldCreationSchema() {
54
54
  return [];
@@ -63,15 +63,15 @@ class O extends Lt {
63
63
  if (this.required && this.isBlank(e))
64
64
  return "This field is required.";
65
65
  for (const n of this.getFieldValidators()) {
66
- const r = n(e);
67
- if (r)
68
- return r;
66
+ const o = n(e);
67
+ if (o)
68
+ return o;
69
69
  }
70
70
  if (t)
71
71
  for (const n of this.getFormValidators()) {
72
- const r = n(e, t);
73
- if (r)
74
- return r;
72
+ const o = n(e, t);
73
+ if (o)
74
+ return o;
75
75
  }
76
76
  }
77
77
  // TODO: We can probably combine _serialize and serialize.
@@ -89,65 +89,64 @@ class O extends Lt {
89
89
  return [...this.formValidators];
90
90
  }
91
91
  }
92
- m(O, "fieldTypeName"), m(O, "fieldTypeDescription");
93
- const _i = "_description_9dewt_1", $i = "_fieldsContainer_9dewt_5", Ie = {
94
- description: _i,
95
- fieldsContainer: $i
96
- }, q = (s) => {
97
- const { label: i, children: e, severity: t, inputId: n, labelId: r, flexProps: a } = s;
98
- return /* @__PURE__ */ o(y, { direction: "column", gap: "1", asChild: !0, ...a, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
99
- /* @__PURE__ */ o(D, { severity: t, id: r, children: i }),
92
+ p(R, "fieldTypeName"), p(R, "fieldTypeDescription");
93
+ const Pi = "_description_17zed_1", Me = {
94
+ description: Pi
95
+ }, H = (s) => {
96
+ const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: a } = s;
97
+ return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...a, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
98
+ /* @__PURE__ */ r(D, { severity: t, id: o, children: i }),
100
99
  e
101
100
  ] }) });
102
- }, W = (s) => {
101
+ }, U = (s) => {
103
102
  const { helpText: i, children: e, severity: t } = s;
104
103
  return /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
105
104
  e,
106
- /* @__PURE__ */ o(y, { direction: "column", children: /* @__PURE__ */ o(D, { size: "1", severity: t, className: Ie.description, children: i }) })
105
+ /* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(D, { size: "1", severity: t, className: Me.description, children: i }) })
107
106
  ] });
108
- }, j = (s) => {
109
- const { id: i, field: e, formId: t, ...n } = s, [r, a, c] = Ze(e.getId()), { touched: l } = a, d = a.error ?? e.description, f = a.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, g = I(() => ({
110
- ...r,
111
- onChange: (v) => {
112
- const x = e.getValueFromChangeEvent(v);
113
- c.setValue(x, !1).then(), (l || !e.onlyValidateAfterTouched) && c.setError(e.getError(x));
107
+ }, G = (s) => {
108
+ const { id: i, field: e, formId: t, ...n } = s, [o, a, c] = Qe(e.getId()), { touched: l } = a, f = a.error ?? e.description, d = a.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, h = `${u}-label`, g = e.required ? `${e.label} *` : e.label, m = F(() => ({
109
+ ...o,
110
+ onChange: (I) => {
111
+ const v = e.getValueFromChangeEvent(I);
112
+ c.setValue(v, !1).then(), (l || !e.onlyValidateAfterTouched) && c.setError(e.getError(v));
114
113
  },
115
- onBlur: (v) => {
116
- c.setTouched(!0, !1).then(), c.setError(e.getError(e.getValueFromChangeEvent(v)));
114
+ onBlur: (I) => {
115
+ c.setTouched(!0, !1).then(), c.setError(e.getError(e.getValueFromChangeEvent(I)));
117
116
  }
118
- }), [e, r, c, l]);
117
+ }), [e, o, c, l]);
119
118
  return [
120
119
  {
121
- helpText: d,
122
- severity: f,
120
+ helpText: f,
121
+ severity: d,
123
122
  inputId: u,
124
- labelId: p,
125
- label: h,
126
- fieldProps: g,
123
+ labelId: h,
124
+ label: g,
125
+ fieldProps: m,
127
126
  helpers: c,
128
127
  field: e
129
128
  },
130
- { ...n, "aria-labelledby": p }
129
+ { ...n, "aria-labelledby": h }
131
130
  ];
132
- }, Mi = [!0, "true"], Oi = z(function(i) {
133
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c }, l] = j(i), d = me(n), f = Mi.includes(c.value);
134
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(
135
- q,
131
+ }, ki = [!0, "true"], Vi = z(function(i) {
132
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = G(i), f = pe(n), d = ki.includes(c.value);
133
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(
134
+ H,
136
135
  {
137
136
  severity: n,
138
137
  inputId: e,
139
138
  labelId: t,
140
139
  label: a,
141
140
  flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
142
- children: /* @__PURE__ */ o(
143
- Kt,
141
+ children: /* @__PURE__ */ r(
142
+ jt,
144
143
  {
145
144
  ...l,
146
145
  ...c,
147
146
  id: e,
148
- color: d,
149
- value: f.toString(),
150
- checked: f,
147
+ color: f,
148
+ value: d.toString(),
149
+ checked: d,
151
150
  onCheckedChange: c.onChange,
152
151
  onChange: void 0,
153
152
  onBlur: void 0
@@ -155,10 +154,10 @@ const _i = "_description_9dewt_1", $i = "_fieldsContainer_9dewt_5", Ie = {
155
154
  )
156
155
  }
157
156
  ) });
158
- }), Z = class Z extends O {
157
+ }), ee = class ee extends R {
159
158
  constructor(e) {
160
159
  super({ ...e, type: "boolean" });
161
- m(this, "onlyValidateAfterTouched", !1);
160
+ p(this, "onlyValidateAfterTouched", !1);
162
161
  }
163
162
  // if a BooleanField is required, `false` is considered blank
164
163
  isBlank(e) {
@@ -173,42 +172,42 @@ const _i = "_description_9dewt_1", $i = "_fieldsContainer_9dewt_5", Ie = {
173
172
  static deserialize(e) {
174
173
  if (e.type !== "boolean")
175
174
  throw new Error("Type mismatch.");
176
- return new Z(e);
175
+ return new ee(e);
177
176
  }
178
177
  getInput(e) {
179
- return /* @__PURE__ */ o(Oi, { ...e, field: this });
178
+ return /* @__PURE__ */ r(Vi, { ...e, field: this });
180
179
  }
181
180
  };
182
- m(Z, "fieldTypeName", "Checkbox"), m(Z, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(Z, "Icon", Yt);
183
- let fe = Z;
184
- const Ri = z(function(i) {
185
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c, field: l }, d] = j(i), f = me(n);
186
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(
187
- ae.Input,
181
+ p(ee, "fieldTypeName", "Checkbox"), p(ee, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), p(ee, "Icon", Ht);
182
+ let me = ee;
183
+ const Di = z(function(i) {
184
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = G(i), d = pe(n);
185
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
186
+ ce.Input,
188
187
  {
189
- ...d,
188
+ ...f,
190
189
  ...c,
191
190
  type: "number",
192
191
  id: e,
193
192
  min: l.minimum,
194
193
  max: l.maximum,
195
194
  step: l.integers ? 1 : 0.1,
196
- color: f
195
+ color: d
197
196
  }
198
197
  ) }) });
199
- }), B = class B extends O {
198
+ }), j = class j extends R {
200
199
  constructor(e) {
201
200
  const {
202
201
  minimum: t = Number.MIN_SAFE_INTEGER,
203
202
  maximum: n = Number.MAX_SAFE_INTEGER,
204
- integers: r = !1,
203
+ integers: o = !1,
205
204
  ...a
206
205
  } = e;
207
206
  super({ ...a, type: "number" });
208
- m(this, "minimum");
209
- m(this, "maximum");
210
- m(this, "integers");
211
- this.minimum = t, this.maximum = n, this.integers = r;
207
+ p(this, "minimum");
208
+ p(this, "maximum");
209
+ p(this, "integers");
210
+ this.minimum = t, this.maximum = n, this.integers = o;
212
211
  }
213
212
  getValueFromChangeEvent(e) {
214
213
  const t = Number.parseFloat(e.target.value);
@@ -216,7 +215,7 @@ const Ri = z(function(i) {
216
215
  }
217
216
  static getFieldCreationSchema() {
218
217
  return [
219
- new B({
218
+ new j({
220
219
  label: "Minimum",
221
220
  description: "Minimum value",
222
221
  integers: !0,
@@ -224,7 +223,7 @@ const Ri = z(function(i) {
224
223
  identifier: "minimum",
225
224
  formValidators: [this._validateMin]
226
225
  }),
227
- new B({
226
+ new j({
228
227
  label: "Maximum",
229
228
  description: "Maximum value",
230
229
  integers: !0,
@@ -232,7 +231,7 @@ const Ri = z(function(i) {
232
231
  identifier: "maximum",
233
232
  formValidators: [this._validateMax]
234
233
  }),
235
- new fe({
234
+ new me({
236
235
  label: "Integers",
237
236
  description: "Whole numbers only",
238
237
  required: !1,
@@ -242,14 +241,14 @@ const Ri = z(function(i) {
242
241
  }
243
242
  getFieldValidators() {
244
243
  const e = super.getFieldValidators(), t = this.minimum, n = this.maximum;
245
- return typeof t == "number" && e.push((r) => {
246
- if (typeof r == "number" && r < t)
244
+ return typeof t == "number" && e.push((o) => {
245
+ if (typeof o == "number" && o < t)
247
246
  return `Must be at least ${this.minimum}.`;
248
- }), typeof n == "number" && e.push((r) => {
249
- if (typeof r == "number" && r > n)
247
+ }), typeof n == "number" && e.push((o) => {
248
+ if (typeof o == "number" && o > n)
250
249
  return `Must be at most ${this.maximum}.`;
251
- }), this.integers && e.push((r) => {
252
- if (typeof r == "number" && !Number.isInteger(r))
250
+ }), this.integers && e.push((o) => {
251
+ if (typeof o == "number" && !Number.isInteger(o))
253
252
  return "Must be a whole number.";
254
253
  }), e;
255
254
  }
@@ -264,21 +263,21 @@ const Ri = z(function(i) {
264
263
  static deserialize(e) {
265
264
  if (e.type !== "number")
266
265
  throw new Error("Type mismatch.");
267
- return new B(e);
266
+ return new j(e);
268
267
  }
269
268
  getInput(e) {
270
- return /* @__PURE__ */ o(Ri, { field: this, ...e });
269
+ return /* @__PURE__ */ r(Di, { field: this, ...e });
271
270
  }
272
271
  };
273
- m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", Qt), m(B, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(B, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
274
- let Q = B;
275
- const Ni = z(function(i) {
276
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c }, l] = j(i), d = me(n), f = c.value ? c.value.split("T")[0] : "";
277
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(ae.Input, { ...l, ...c, type: "date", id: e, color: d, value: f }) }) });
278
- }), ee = class ee extends O {
272
+ p(j, "fieldTypeName", "Number"), p(j, "fieldTypeDescription", "Allows specifying a number within a given range."), p(j, "Icon", Ut), p(j, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), p(j, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
273
+ let Q = j;
274
+ const $i = z(function(i) {
275
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = G(i), f = pe(n), d = c.value ? c.value.split("T")[0] : "";
276
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ce.Input, { ...l, ...c, type: "date", id: e, color: f, value: d }) }) });
277
+ }), te = class te extends R {
279
278
  constructor(e) {
280
279
  super({ ...e, type: "date" });
281
- m(this, "onlyValidateAfterTouched", !1);
280
+ p(this, "onlyValidateAfterTouched", !1);
282
281
  }
283
282
  serialize() {
284
283
  return super._serialize();
@@ -289,20 +288,20 @@ const Ni = z(function(i) {
289
288
  static deserialize(e) {
290
289
  if (e.type !== "date")
291
290
  throw new Error("Type mismatch.");
292
- return new ee(e);
291
+ return new te(e);
293
292
  }
294
293
  getInput(e) {
295
- return /* @__PURE__ */ o(Ni, { field: this, ...e });
294
+ return /* @__PURE__ */ r($i, { field: this, ...e });
296
295
  }
297
296
  };
298
- m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon", Xt);
299
- let Ge = ee;
300
- class Ae extends O {
297
+ p(te, "fieldTypeName", "Date"), p(te, "fieldTypeDescription", "Allows specifying a date."), p(te, "Icon", Gt);
298
+ let je = te;
299
+ class Te extends R {
301
300
  constructor(e) {
302
- const { minLength: t, maxLength: n = 5e3, ...r } = e;
303
- super(r);
304
- m(this, "minLength");
305
- m(this, "maxLength");
301
+ const { minLength: t, maxLength: n = 5e3, ...o } = e;
302
+ super(o);
303
+ p(this, "minLength");
304
+ p(this, "maxLength");
306
305
  this.minLength = t ? Math.max(t, 0) : void 0, this.maxLength = n ? Math.max(n, 0) : 5e3;
307
306
  }
308
307
  static getFieldCreationSchema() {
@@ -356,24 +355,24 @@ class Ae extends O {
356
355
  * This function validates that the value given for "minimum length" (when creating a new field) is less than or
357
356
  * equal to the value given for "maximum length".
358
357
  */
359
- m(Ae, "_validateMin", (e, t) => typeof t.maximum_length == "number" && typeof e == "number" && t.maximum_length < e ? "Minimum cannot be greater than maximum." : null), /**
358
+ p(Te, "_validateMin", (e, t) => typeof t.maximum_length == "number" && typeof e == "number" && t.maximum_length < e ? "Minimum cannot be greater than maximum." : null), /**
360
359
  * This function validates that the value given for "maximum length" (when creating a new field) is greater than or
361
360
  * equal to the value given for "minimum length".
362
361
  */
363
- m(Ae, "_validateMax", (e, t) => {
362
+ p(Te, "_validateMax", (e, t) => {
364
363
  if (typeof e != "number")
365
364
  return null;
366
365
  const { minimum_length: n } = t;
367
366
  return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
368
367
  });
369
- const Bi = z(function(i) {
370
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c, field: l }, d] = j(i), f = me(n);
371
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(ae.Input, { ...d, ...c, type: l.inputType, id: e, color: f }) }) });
372
- }), te = class te extends Ae {
368
+ const _i = z(function(i) {
369
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = G(i), d = pe(n);
370
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ce.Input, { ...f, ...c, type: l.inputType, id: e, color: d }) }) });
371
+ }), ie = class ie extends Te {
373
372
  constructor(e) {
374
- const { inputType: t = "text", ...n } = e, r = e.maxLength ? Math.min(500, e.maxLength) : 500, a = e.minLength ? Math.min(e.minLength, r) : void 0;
375
- super({ ...n, maxLength: r, minLength: a, type: "string" });
376
- m(this, "inputType");
373
+ const { inputType: t = "text", ...n } = e, o = e.maxLength ? Math.min(500, e.maxLength) : 500, a = e.minLength ? Math.min(e.minLength, o) : void 0;
374
+ super({ ...n, maxLength: o, minLength: a, type: "string" });
375
+ p(this, "inputType");
377
376
  this.inputType = t;
378
377
  }
379
378
  serialize() {
@@ -382,19 +381,19 @@ const Bi = z(function(i) {
382
381
  static deserialize(e) {
383
382
  if (e.type !== "string")
384
383
  throw new Error("Type mismatch.");
385
- const { maximum_length: t, minimum_length: n, input_type: r, ...a } = e;
386
- return new te({ ...a, maxLength: t, minLength: n, inputType: r });
384
+ const { maximum_length: t, minimum_length: n, input_type: o, ...a } = e;
385
+ return new ie({ ...a, maxLength: t, minLength: n, inputType: o });
387
386
  }
388
387
  getInput(e) {
389
- return /* @__PURE__ */ o(Bi, { field: this, ...e });
388
+ return /* @__PURE__ */ r(_i, { field: this, ...e });
390
389
  }
391
390
  };
392
- m(te, "fieldTypeName", "Short Text"), m(te, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(te, "Icon", Jt);
393
- let be = te;
394
- const qi = z(function(i) {
395
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c }, l] = j(i);
396
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(Zt, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
397
- }), ie = class ie extends Ae {
391
+ p(ie, "fieldTypeName", "Short Text"), p(ie, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), p(ie, "Icon", Kt);
392
+ let ye = ie;
393
+ const Mi = z(function(i) {
394
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = G(i);
395
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(Yt, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
396
+ }), ne = class ne extends Te {
398
397
  constructor(i) {
399
398
  const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
400
399
  super({ ...i, maxLength: e, minLength: t, type: "text" });
@@ -406,207 +405,207 @@ const qi = z(function(i) {
406
405
  if (i.type !== "text")
407
406
  throw new Error("Type mismatch.");
408
407
  const { maximum_length: e, minimum_length: t, ...n } = i;
409
- return new ie({ ...n, maxLength: e, minLength: t });
408
+ return new ne({ ...n, maxLength: e, minLength: t });
410
409
  }
411
410
  getInput(i) {
412
- return /* @__PURE__ */ o(qi, { field: this, ...i });
411
+ return /* @__PURE__ */ r(Mi, { field: this, ...i });
413
412
  }
414
413
  };
415
- m(ie, "fieldTypeName", "Paragraph"), m(ie, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ie, "Icon", ei);
416
- let ye = ie;
417
- const Wi = z(function(i) {
418
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c, field: l }, d] = j(i), { onChange: f, onBlur: u } = c, p = I(
419
- () => l.options.map((g) => ({ value: g.value, itemContent: g.label })),
414
+ p(ne, "fieldTypeName", "Paragraph"), p(ne, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), p(ne, "Icon", Xt);
415
+ let we = ne;
416
+ const Oi = z(function(i) {
417
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = G(i), { onChange: d, onBlur: u } = c, h = F(
418
+ () => l.options.map((m) => ({ value: m.value, itemContent: m.label })),
420
419
  [l.options]
421
- ), h = T(
422
- (g) => {
423
- f(g), u(g);
420
+ ), g = T(
421
+ (m) => {
422
+ d(m), u(m);
424
423
  },
425
- [f, u]
424
+ [d, u]
426
425
  );
427
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(
428
- vt,
426
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
427
+ gt,
429
428
  {
430
- items: p,
429
+ items: h,
431
430
  ...c,
432
- onValueChange: h,
431
+ onValueChange: g,
433
432
  placeholder: "Select one...",
434
433
  id: e,
435
434
  severity: n,
436
- ...d
435
+ ...f
437
436
  }
438
437
  ) }) });
439
- }), Le = (s = "", i = []) => ({
438
+ }), Se = (s = "", i = []) => ({
440
439
  type: "section",
441
440
  fields: i,
442
441
  identifier: s,
443
442
  label: null,
444
443
  condition: null,
445
444
  conditional: !1
446
- }), ji = (s) => {
445
+ }), Ni = (s) => {
447
446
  if (!s)
448
447
  return;
449
448
  const i = s.fields;
450
449
  let e = [];
451
450
  const t = [];
452
451
  for (const n of i)
453
- n.type === "section" ? (e.length > 0 && (t.push(Le(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
454
- return e.length > 0 && t.push(Le("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
452
+ n.type === "section" ? (e.length > 0 && (t.push(Se(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
453
+ return e.length > 0 && t.push(Se("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
455
454
  };
456
- function Ke(s, i, e) {
455
+ function He(s, i, e) {
457
456
  const t = Array.from(s), [n] = t.splice(i, 1);
458
457
  if (!n)
459
458
  throw new Error("Could not find field to reorder.");
460
459
  return t.splice(e, 0, n), t;
461
460
  }
462
- function Hi(s, i, e) {
461
+ function Ri(s, i, e) {
463
462
  const t = Array.from(s);
464
463
  return t[i] = e, t;
465
464
  }
466
- function Pt(s, i, e) {
465
+ function zt(s, i, e) {
467
466
  const t = Array.from(s ?? []);
468
467
  return t.splice(i, 0, e), t;
469
468
  }
470
- function Pe(s, i) {
469
+ function ze(s, i) {
471
470
  const e = Array.from(s);
472
471
  return e.splice(i, 1), e;
473
472
  }
474
- const kt = (s, i) => {
473
+ const Et = (s, i) => {
475
474
  if (typeof s == "string" && s.length > 0)
476
475
  return s;
477
476
  const e = /* @__PURE__ */ new Date();
478
- return `${Ti(i)}-${e.getTime()}`;
479
- }, Vt = (s, i) => {
477
+ return `${vi(i)}-${e.getTime()}`;
478
+ }, At = (s, i) => {
480
479
  if (!i)
481
480
  return null;
482
481
  for (const e of s)
483
482
  if (e.type === "section") {
484
- const t = Vt(e.fields, i);
483
+ const t = At(e.fields, i);
485
484
  if (t)
486
485
  return t;
487
486
  } else if (e.identifier === i)
488
487
  return e;
489
488
  return null;
490
- }, Ee = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Dt = (s) => s.flatMap(
489
+ }, Ce = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Lt = (s) => s.flatMap(
491
490
  (i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
492
- ).filter((i) => i !== null), Ye = (s, i) => {
491
+ ).filter((i) => i !== null), Ue = (s, i) => {
493
492
  let e = 1, t = `${s} (${e})`;
494
493
  for (; i.includes(t); )
495
494
  t = `${s} (${++e})`;
496
495
  return t;
497
- }, Ui = z(function(i) {
498
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c }, l] = j(i), d = me(n), f = I(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: g } = l, [F, S] = de(""), [v, x] = de(""), P = v || r, _ = v ? "red" : d, w = T(
496
+ }, Bi = z(function(i) {
497
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = G(i), f = pe(n), d = F(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: h } = c, g = `${e}-droppable`, { disabled: m } = l, [w, x] = X(""), [I, v] = X(""), k = I || o, L = I ? "red" : f, C = T(
499
498
  (A) => {
500
- u(A), p(A);
499
+ u(A), h(A);
501
500
  },
502
- [u, p]
503
- ), L = T(
501
+ [u, h]
502
+ ), P = T(
504
503
  (A) => {
505
- f.findIndex((N) => N.value === A.target.value.trim()) >= 0 ? x("All options must be unique") : A.target.value ? x("") : x("Option cannot be empty"), S(A.target.value);
504
+ d.findIndex((q) => q.value === A.target.value.trim()) >= 0 ? v("All options must be unique") : A.target.value ? v("") : v("Option cannot be empty"), x(A.target.value);
506
505
  },
507
- [S, f]
508
- ), $ = T(() => {
509
- if (v)
506
+ [x, d]
507
+ ), O = T(() => {
508
+ if (I)
510
509
  return;
511
- if (!F.trim())
512
- return x("Option cannot be empty");
513
- const A = F.trim();
514
- w([...f, { value: A, label: A }]), S("");
515
- }, [F, v, w, f]), H = T(
510
+ if (!w.trim())
511
+ return v("Option cannot be empty");
512
+ const A = w.trim();
513
+ C([...d, { value: A, label: A }]), x("");
514
+ }, [w, I, C, d]), _ = T(
516
515
  (A) => {
517
- A.key === "Enter" && (A.preventDefault(), $());
516
+ A.key === "Enter" && (A.preventDefault(), O());
518
517
  },
519
- [$]
520
- ), U = T(
518
+ [O]
519
+ ), M = T(
521
520
  (A) => {
522
- w(Pe(f, A));
521
+ C(ze(d, A));
523
522
  },
524
- [f, w]
525
- ), G = T(
523
+ [d, C]
524
+ ), B = T(
526
525
  (A) => {
527
526
  if (!A.destination)
528
527
  return;
529
- const N = A.source.index, Y = A.destination.index;
530
- w(Ke(f, N, Y));
528
+ const q = A.source.index, Y = A.destination.index;
529
+ C(He(d, q, Y));
531
530
  },
532
- [w, f]
531
+ [C, d]
533
532
  );
534
- return /* @__PURE__ */ o(Ft, { onDragEnd: G, children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
535
- /* @__PURE__ */ o(W, { helpText: P, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: (!g || f.length === 0) && /* @__PURE__ */ b(y, { gap: "2", children: [
536
- /* @__PURE__ */ o(ge, { grow: "1", children: /* @__PURE__ */ o(
537
- ae.Input,
533
+ return /* @__PURE__ */ r(xt, { onDragEnd: B, children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
534
+ /* @__PURE__ */ r(U, { helpText: k, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: (!m || d.length === 0) && /* @__PURE__ */ b(y, { gap: "2", children: [
535
+ /* @__PURE__ */ r(be, { grow: "1", children: /* @__PURE__ */ r(
536
+ ce.Input,
538
537
  {
539
538
  placeholder: "Press enter to add a new option",
540
539
  ...l,
541
540
  ...c,
542
- value: F,
543
- onChange: L,
544
- onKeyDown: H,
541
+ value: w,
542
+ onChange: P,
543
+ onKeyDown: _,
545
544
  id: e,
546
- color: _,
545
+ color: L,
547
546
  onBlur: void 0
548
547
  }
549
548
  ) }),
550
- /* @__PURE__ */ o(
551
- ce,
549
+ /* @__PURE__ */ r(
550
+ de,
552
551
  {
553
552
  type: "button",
554
553
  "aria-label": "Add option",
555
- disabled: !!v || g,
556
- onClick: $,
557
- children: /* @__PURE__ */ o(Oe, {})
554
+ disabled: !!I || m,
555
+ onClick: O,
556
+ children: /* @__PURE__ */ r(De, {})
558
557
  }
559
558
  )
560
559
  ] }) }) }),
561
- /* @__PURE__ */ o(nt, { droppableId: h, children: (A) => /* @__PURE__ */ b(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
562
- f.map((N, Y) => /* @__PURE__ */ o(
563
- rt,
560
+ /* @__PURE__ */ r(et, { droppableId: g, children: (A) => /* @__PURE__ */ b(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
561
+ d.map((q, Y) => /* @__PURE__ */ r(
562
+ tt,
564
563
  {
565
- draggableId: `${N.value}-draggable`,
564
+ draggableId: `${q.value}-draggable`,
566
565
  index: Y,
567
- isDragDisabled: g,
568
- children: ({ draggableProps: Ce, dragHandleProps: Fe, innerRef: Te }) => /* @__PURE__ */ o(
566
+ isDragDisabled: m,
567
+ children: ({ draggableProps: E, dragHandleProps: S, innerRef: V }) => /* @__PURE__ */ r(
569
568
  y,
570
569
  {
571
- ...Fe,
572
- ...Ce,
573
- ref: Te,
570
+ ...S,
571
+ ...E,
572
+ ref: V,
574
573
  gap: "2",
575
574
  align: "center",
576
575
  justify: "between",
577
576
  mb: "1",
578
577
  asChild: !0,
579
- children: /* @__PURE__ */ b(Ue, { color: "gray", size: "2", children: [
580
- /* @__PURE__ */ o("span", { children: N.label }),
581
- /* @__PURE__ */ o(
582
- ce,
578
+ children: /* @__PURE__ */ b(We, { color: "gray", size: "2", children: [
579
+ /* @__PURE__ */ r("span", { children: q.label }),
580
+ /* @__PURE__ */ r(
581
+ de,
583
582
  {
584
583
  size: "small",
585
584
  variant: "ghost",
586
585
  type: "button",
587
586
  "aria-label": "Delete option",
588
587
  severity: "info",
589
- disabled: g,
590
- onClick: () => U(Y),
591
- children: /* @__PURE__ */ o(It, {})
588
+ disabled: m,
589
+ onClick: () => M(Y),
590
+ children: /* @__PURE__ */ r(bt, {})
592
591
  }
593
592
  )
594
593
  ] })
595
594
  }
596
595
  )
597
596
  },
598
- N.value
597
+ q.value
599
598
  )),
600
599
  A.placeholder
601
600
  ] }) })
602
601
  ] }) });
603
- }), ne = class ne extends O {
602
+ }), re = class re extends R {
604
603
  constructor(e) {
605
- const { minimum_length: t, maximum_length: n, ...r } = e;
606
- super({ ...r, type: "multi-string" });
607
- m(this, "minLength");
608
- m(this, "maxLength");
609
- m(this, "onlyValidateAfterTouched", !1);
604
+ const { minimum_length: t, maximum_length: n, ...o } = e;
605
+ super({ ...o, type: "multi-string" });
606
+ p(this, "minLength");
607
+ p(this, "maxLength");
608
+ p(this, "onlyValidateAfterTouched", !1);
610
609
  this.minLength = t ?? 0, this.maxLength = n ?? 1 / 0;
611
610
  }
612
611
  getValueFromChangeEvent(e) {
@@ -615,7 +614,7 @@ const kt = (s, i) => {
615
614
  throw new Error("Expected an array.");
616
615
  }
617
616
  getInput(e) {
618
- return /* @__PURE__ */ o(Ui, { field: this, ...e });
617
+ return /* @__PURE__ */ r(Bi, { field: this, ...e });
619
618
  }
620
619
  serialize() {
621
620
  return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
@@ -636,16 +635,16 @@ const kt = (s, i) => {
636
635
  static deserialize(e) {
637
636
  if (e.type !== "multi-string")
638
637
  throw new Error("Type mismatch.");
639
- return new ne(e);
638
+ return new re(e);
640
639
  }
641
640
  };
642
- m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon", ti);
643
- let ke = ne;
644
- class _t extends O {
641
+ p(re, "fieldTypeName", "Multi-string"), p(re, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), p(re, "Icon", Qt);
642
+ let Ee = re;
643
+ class Pt extends R {
645
644
  constructor(e) {
646
645
  super(e);
647
- m(this, "options");
648
- m(this, "onlyValidateAfterTouched", !1);
646
+ p(this, "options");
647
+ p(this, "onlyValidateAfterTouched", !1);
649
648
  const t = /* @__PURE__ */ new Set();
650
649
  this.options = e.options.map((n) => (typeof n == "string" && (n = { label: n, value: n }), t.add(n.label), n)), t.size !== e.options.length && console.error(
651
650
  `${e.options.length - t.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,
@@ -660,7 +659,7 @@ class _t extends O {
660
659
  }
661
660
  static getFieldCreationSchema() {
662
661
  return [
663
- new ke({
662
+ new Ee({
664
663
  label: "Options",
665
664
  description: "List possible options for the user to select from.",
666
665
  required: !0,
@@ -671,7 +670,7 @@ class _t extends O {
671
670
  ];
672
671
  }
673
672
  }
674
- const re = class re extends _t {
673
+ const oe = class oe extends Pt {
675
674
  constructor(i) {
676
675
  super({ ...i, type: "select" });
677
676
  }
@@ -684,35 +683,35 @@ const re = class re extends _t {
684
683
  static deserialize(i) {
685
684
  if (i.type !== "select")
686
685
  throw new Error("Type mismatch.");
687
- return new re(i);
686
+ return new oe(i);
688
687
  }
689
688
  getInput(i) {
690
- return /* @__PURE__ */ o(Wi, { field: this, ...i });
689
+ return /* @__PURE__ */ r(Oi, { field: this, ...i });
691
690
  }
692
691
  };
693
- m(re, "fieldTypeName", "Dropdown"), m(re, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(re, "Icon", ii);
694
- let Ve = re;
695
- const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = z(function(i) {
696
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c, field: l }, d] = j(i), { onChange: f, onBlur: u } = c, p = I(() => Gi(c.value), [c.value]), h = T(
697
- (g) => {
698
- f(g), u(g);
692
+ p(oe, "fieldTypeName", "Dropdown"), p(oe, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), p(oe, "Icon", Jt);
693
+ let Ae = oe;
694
+ const qi = (s) => s ? Array.isArray(s) ? s : [s] : [], Wi = z(function(i) {
695
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = G(i), { onChange: d, onBlur: u } = c, h = F(() => qi(c.value), [c.value]), g = T(
696
+ (m) => {
697
+ d(m), u(m);
699
698
  },
700
- [f, u]
699
+ [d, u]
701
700
  );
702
- return /* @__PURE__ */ o(W, { helpText: r, severity: n, children: /* @__PURE__ */ o(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ o(
703
- ni,
701
+ return /* @__PURE__ */ r(U, { helpText: o, severity: n, children: /* @__PURE__ */ r(H, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
702
+ Zt,
704
703
  {
705
- value: p,
706
- onValueChange: h,
704
+ value: h,
705
+ onValueChange: g,
707
706
  options: l.options,
708
707
  name: c.name,
709
708
  placeholder: "Select one or more...",
710
709
  id: e,
711
710
  severity: n,
712
- ...d
711
+ ...f
713
712
  }
714
713
  ) }) });
715
- }), oe = class oe extends _t {
714
+ }), se = class se extends Pt {
716
715
  constructor(i) {
717
716
  super({ ...i, type: "multi-select" });
718
717
  }
@@ -730,27 +729,27 @@ const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = z(function(i) {
730
729
  static deserialize(i) {
731
730
  if (i.type !== "multi-select")
732
731
  throw new Error("Type mismatch.");
733
- return new oe(i);
732
+ return new se(i);
734
733
  }
735
734
  getInput(i) {
736
- return /* @__PURE__ */ o(Ki, { field: this, ...i });
735
+ return /* @__PURE__ */ r(Wi, { field: this, ...i });
737
736
  }
738
737
  };
739
- m(oe, "fieldTypeName", "Multi-select"), m(oe, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(oe, "Icon", ri);
740
- let De = oe;
741
- const Yi = z(function({ field: i, ...e }) {
742
- const [{ value: t }] = Ze(i.options.clonedFieldIdentifier), n = I(() => {
743
- const r = i.options.getFieldToClone(t);
744
- return r ? Be(r) : null;
738
+ p(se, "fieldTypeName", "Multi-select"), p(se, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), p(se, "Icon", ei);
739
+ let Le = se;
740
+ const ji = z(function({ field: i, ...e }) {
741
+ const [{ value: t }] = Qe(i.options.clonedFieldIdentifier), n = F(() => {
742
+ const o = i.options.getFieldToClone(t);
743
+ return o ? Oe(o) : null;
745
744
  }, [i.options, t]);
746
- return $e(n, e);
745
+ return ke(n, e);
747
746
  });
748
- class _e extends O {
747
+ class Pe extends R {
749
748
  constructor(e, t) {
750
749
  super({ ...e, type: "custom" });
751
- m(this, "Component");
750
+ p(this, "Component");
752
751
  // identifier of the field whose value is the label of the field to re-render
753
- m(this, "options");
752
+ p(this, "options");
754
753
  this.options = e, this.Component = t;
755
754
  }
756
755
  serialize() {
@@ -758,49 +757,49 @@ class _e extends O {
758
757
  }
759
758
  getInput(e) {
760
759
  const t = this.Component;
761
- return /* @__PURE__ */ o(t, { field: this, ...e });
760
+ return /* @__PURE__ */ r(t, { field: this, ...e });
762
761
  }
763
762
  }
764
- m(_e, "fieldTypeName", "Custom"), m(_e, "fieldTypeDescription", "Allows re-rendering of field already in the form");
765
- class Qi extends _e {
763
+ p(Pe, "fieldTypeName", "Custom"), p(Pe, "fieldTypeDescription", "Allows re-rendering of field already in the form");
764
+ class Hi extends Pe {
766
765
  constructor(i) {
767
- super(i, Yi);
766
+ super(i, ji);
768
767
  }
769
768
  }
770
- const Xi = z(function(i) {
771
- const { field: e, ...t } = i, { label: n, description: r, fields: a, condition: c } = e, { values: l, setFieldValue: d } = pe(), f = c != null && c.identifier ? ue(l, c.identifier) : void 0, u = I(() => Ot(c, f), [c, f]);
772
- we(() => {
769
+ const Ui = z(function(i) {
770
+ const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } = he(), d = c != null && c.identifier ? fe(l, c.identifier) : void 0, u = F(() => Dt(c, d), [c, d]);
771
+ ue(() => {
773
772
  if (!u)
774
- for (const h of a)
775
- d(h.getId(), "").then();
776
- }, [u, a, d]);
777
- const p = Rt(a, t);
778
- return u ? n ? /* @__PURE__ */ o(xe, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
773
+ for (const g of a)
774
+ f(g.getId(), "").then();
775
+ }, [u, a, f]);
776
+ const h = $t(a, t);
777
+ return u ? n ? /* @__PURE__ */ r(xe, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
779
778
  /* @__PURE__ */ b(y, { direction: "column", children: [
780
- /* @__PURE__ */ o(Re, { as: "h3", size: "3", children: n }),
781
- /* @__PURE__ */ o(D, { className: Ie.description, children: r })
779
+ /* @__PURE__ */ r($e, { as: "h3", size: "3", children: n }),
780
+ /* @__PURE__ */ r(D, { className: Me.description, children: o })
782
781
  ] }),
783
- p
784
- ] }) }) : p : null;
785
- }), se = class se extends Lt {
782
+ h
783
+ ] }) }) : h : null;
784
+ }), le = class le extends St {
786
785
  constructor(e) {
787
- const { label: t = null, fields: n, condition: r = null, conditional: a, ...c } = e;
786
+ const { label: t = null, fields: n, condition: o = null, conditional: a, ...c } = e;
788
787
  super({ ...c, type: "section" });
789
- m(this, "label");
790
- m(this, "fields");
791
- m(this, "condition");
792
- this.fields = n, this.condition = r, this.label = t, a === !1 && (this.condition = null);
788
+ p(this, "label");
789
+ p(this, "fields");
790
+ p(this, "condition");
791
+ this.fields = n, this.condition = o, this.label = t, a === !1 && (this.condition = null);
793
792
  }
794
793
  static getFieldCreationSchema(e) {
795
794
  return e.length === 0 ? [] : [
796
- new fe({
795
+ new me({
797
796
  label: "Conditional",
798
797
  description: "Conditionally show or hide this section.",
799
798
  identifier: "conditional",
800
799
  required: !1
801
800
  }),
802
801
  // Declare a section that will hold options for the condition (if any).
803
- new se({
802
+ new le({
804
803
  label: "Conditional settings",
805
804
  identifier: "conditional-settings",
806
805
  // This section will only be rendered if the above "Conditional" field is checked.
@@ -812,7 +811,7 @@ const Xi = z(function(i) {
812
811
  fields: [
813
812
  // Declare a select field that will be used to select the field against which we will check the
814
813
  // condition. This must be selected before the next field is rendered.
815
- new Ve({
814
+ new Ae({
816
815
  label: "Field",
817
816
  description: "The field to use for the condition.",
818
817
  // The options (for the field against which we will check the condition) are all the labels of
@@ -829,7 +828,7 @@ const Xi = z(function(i) {
829
828
  // Declare a custom field that will be used to input a value for the condition. The value of the
830
829
  // conditional field selected in the previous step must be equal to the value the user inputs into
831
830
  // this field for the section to be rendered.
832
- new Qi({
831
+ new Hi({
833
832
  label: "Value",
834
833
  identifier: "condition.value",
835
834
  required: !0,
@@ -837,7 +836,7 @@ const Xi = z(function(i) {
837
836
  getFieldToClone(t) {
838
837
  if (!t)
839
838
  return null;
840
- const n = e.find((r) => r.identifier === t);
839
+ const n = e.find((o) => o.identifier === t);
841
840
  return n ? {
842
841
  ...n,
843
842
  // Override some options to make it make sense in the context and to make it work with the framework.
@@ -856,8 +855,8 @@ const Xi = z(function(i) {
856
855
  var n;
857
856
  if (e.type !== "section")
858
857
  throw new Error("Invalid type");
859
- const t = ((n = e.fields) == null ? void 0 : n.map($t)) ?? [];
860
- return new se({ ...e, fields: t });
858
+ const t = ((n = e.fields) == null ? void 0 : n.map(kt)) ?? [];
859
+ return new le({ ...e, fields: t });
861
860
  }
862
861
  conditional() {
863
862
  return this.condition !== null;
@@ -874,52 +873,52 @@ const Xi = z(function(i) {
874
873
  getErrors(e) {
875
874
  const t = {};
876
875
  for (const n of this.fields) {
877
- const r = n.getId(), a = n.getError(ue(e, r), e);
878
- a && st(t, n.getId(), a);
876
+ const o = n.getId(), a = n.getError(fe(e, o), e);
877
+ a && nt(t, n.getId(), a);
879
878
  }
880
879
  return t;
881
880
  }
882
881
  getInput(e) {
883
- return /* @__PURE__ */ o(Xi, { field: this, ...e });
882
+ return /* @__PURE__ */ r(Ui, { field: this, ...e });
884
883
  }
885
884
  };
886
- m(se, "fieldTypeName", "Section"), m(se, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
887
- let X = se;
888
- const Ji = "_previewImage_1ig84_1", Zi = {
889
- previewImage: Ji
890
- }, lt = (s) => {
885
+ p(le, "fieldTypeName", "Section"), p(le, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
886
+ let J = le;
887
+ const Gi = "_previewImage_1ig84_1", Ki = {
888
+ previewImage: Gi
889
+ }, rt = (s) => {
891
890
  const i = ["byte", "kilobyte", "megabyte"];
892
891
  let e = s, t = 0;
893
892
  for (; e > 1024 && t < i.length - 1; )
894
893
  e /= 1024, t++;
895
894
  return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
896
- }, en = z(function(i) {
897
- var _;
898
- const [{ inputId: e, labelId: t, severity: n, helpText: r, label: a, fieldProps: c, field: l }, d] = j(i), { onChange: f } = c, u = me(n), p = it(null), { value: h } = c, g = I(() => r || (l.maxFileSize ? `Maximum file size: ${lt(l.maxFileSize)}` : null), [l.maxFileSize, r]), F = T(() => {
899
- var w;
900
- (w = p.current) == null || w.click();
901
- }, []), S = T(
902
- (w) => {
903
- const L = [...h];
904
- L.splice(w, 1), f({ target: { files: L } });
895
+ }, Yi = z(function(i) {
896
+ var L;
897
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = G(i), { onChange: d } = c, u = pe(n), h = wt(null), { value: g } = c, m = F(() => o || (l.maxFileSize ? `Maximum file size: ${rt(l.maxFileSize)}` : null), [l.maxFileSize, o]), w = T(() => {
898
+ var C;
899
+ (C = h.current) == null || C.click();
900
+ }, []), x = T(
901
+ (C) => {
902
+ const P = [...g];
903
+ P.splice(C, 1), d({ target: { files: P } });
905
904
  },
906
- [h, f]
907
- ), v = h ? "Select new files" : "Select files", x = h ? "Select new file" : "Select a file", P = l.maxFiles > 1 ? v : x;
905
+ [g, d]
906
+ ), I = g ? "Select new files" : "Select files", v = g ? "Select new file" : "Select a file", k = l.maxFiles > 1 ? I : v;
908
907
  return /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
909
- /* @__PURE__ */ o(W, { helpText: g, severity: n, children: /* @__PURE__ */ b(q, { severity: n, inputId: e, labelId: t, label: a, children: [
910
- /* @__PURE__ */ o(y, { direction: "row", gap: "2", children: /* @__PURE__ */ o(ge, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(K, { ...d, onClick: F, children: [
911
- /* @__PURE__ */ o(Ct, {}),
908
+ /* @__PURE__ */ r(U, { helpText: m, severity: n, children: /* @__PURE__ */ b(H, { severity: n, inputId: e, labelId: t, label: a, children: [
909
+ /* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(be, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(K, { ...f, onClick: w, children: [
910
+ /* @__PURE__ */ r(yt, {}),
912
911
  " ",
913
- P
912
+ k
914
913
  ] }) }) }),
915
- /* @__PURE__ */ o(
914
+ /* @__PURE__ */ r(
916
915
  "input",
917
916
  {
918
- ...d,
917
+ ...f,
919
918
  type: "file",
920
- ref: p,
919
+ ref: h,
921
920
  id: e,
922
- accept: (_ = l.extensions) == null ? void 0 : _.join(","),
921
+ accept: (L = l.extensions) == null ? void 0 : L.join(","),
923
922
  multiple: l.maxFiles > 1,
924
923
  color: u,
925
924
  style: { display: "none" },
@@ -928,54 +927,54 @@ const Ji = "_previewImage_1ig84_1", Zi = {
928
927
  }
929
928
  )
930
929
  ] }) }),
931
- Array.isArray(h) && h.length > 0 && /* @__PURE__ */ o(y, { direction: "column", gap: "2", children: h.map((w, L) => /* @__PURE__ */ o(
932
- tn,
930
+ Array.isArray(g) && g.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: g.map((C, P) => /* @__PURE__ */ r(
931
+ Xi,
933
932
  {
934
933
  field: l,
935
- file: w,
936
- onRemove: () => S(L),
937
- disabled: d.disabled
934
+ file: C,
935
+ onRemove: () => x(P),
936
+ disabled: f.disabled
938
937
  },
939
- L
938
+ P
940
939
  )) })
941
940
  ] });
942
- }), tn = z(function({ file: i, field: e, onRemove: t, disabled: n }) {
943
- const [r, a] = de(null), c = I(() => r && e.getError([r]), [e, r]), { url: l, name: d, size: f } = I(() => {
944
- let u = null, p, h;
945
- return r != null && r.type.startsWith("image/") && (u = URL.createObjectURL(r)), r ? (p = r.name, h = lt(r.size)) : (p = "Downloading...", h = "..."), { url: u, name: p, size: h };
946
- }, [r]);
947
- return we(() => {
941
+ }), Xi = z(function({ file: i, field: e, onRemove: t, disabled: n }) {
942
+ const [o, a] = X(null), c = F(() => o && e.getError([o]), [e, o]), { url: l, name: f, size: d } = F(() => {
943
+ let u = null, h, g;
944
+ return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (h = o.name, g = rt(o.size)) : (h = "Downloading...", g = "..."), { url: u, name: h, size: g };
945
+ }, [o]);
946
+ return ue(() => {
948
947
  i instanceof Promise ? i.then(a) : a(i);
949
- }, [i]), /* @__PURE__ */ o(xe, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
948
+ }, [i]), /* @__PURE__ */ r(xe, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
950
949
  /* @__PURE__ */ b(y, { direction: "row", gap: "3", align: "center", grow: "1", shrink: "0", children: [
951
- /* @__PURE__ */ o(
952
- ce,
950
+ /* @__PURE__ */ r(
951
+ de,
953
952
  {
954
953
  severity: "info",
955
954
  variant: "outline",
956
- "aria-label": `Remove ${d}`,
955
+ "aria-label": `Remove ${f}`,
957
956
  disabled: n,
958
957
  onClick: t,
959
- children: /* @__PURE__ */ o(It, {})
958
+ children: /* @__PURE__ */ r(bt, {})
960
959
  }
961
960
  ),
962
961
  /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
963
- /* @__PURE__ */ o(D, { children: d }),
964
- /* @__PURE__ */ o(D, { size: "1", children: f }),
965
- c && /* @__PURE__ */ o(D, { size: "1", severity: "danger", children: c })
962
+ /* @__PURE__ */ r(D, { children: f }),
963
+ /* @__PURE__ */ r(D, { size: "1", children: d }),
964
+ c && /* @__PURE__ */ r(D, { size: "1", severity: "danger", children: c })
966
965
  ] })
967
966
  ] }),
968
- l && /* @__PURE__ */ o("img", { className: Zi.previewImage, src: l, alt: d })
967
+ l && /* @__PURE__ */ r("img", { className: Ki.previewImage, src: l, alt: f })
969
968
  ] }) });
970
- }), pt = 50 * 1024 * 1024, le = class le extends O {
969
+ }), dt = 50 * 1024 * 1024, ae = class ae extends R {
971
970
  constructor(e) {
972
- const { extensions: t, maximum_files: n, maximum_size: r, ...a } = e;
971
+ const { extensions: t, maximum_files: n, maximum_size: o, ...a } = e;
973
972
  super({ ...a, type: "upload" });
974
- m(this, "extensions");
975
- m(this, "maxFileSize");
976
- m(this, "maxFiles");
977
- m(this, "onlyValidateAfterTouched", !1);
978
- this.maxFileSize = typeof r == "number" ? r : void 0, this.maxFiles = Math.max(typeof n == "number" ? n : 1, 1), this.extensions = t;
973
+ p(this, "extensions");
974
+ p(this, "maxFileSize");
975
+ p(this, "maxFiles");
976
+ p(this, "onlyValidateAfterTouched", !1);
977
+ this.maxFileSize = typeof o == "number" ? o : void 0, this.maxFiles = Math.max(typeof n == "number" ? n : 1, 1), this.extensions = t;
979
978
  }
980
979
  getValueFromChangeEvent(e) {
981
980
  return Array.from(e.target.files || []);
@@ -999,10 +998,10 @@ const Ji = "_previewImage_1ig84_1", Zi = {
999
998
  required: !1,
1000
999
  identifier: "maximum_size",
1001
1000
  minimum: 1,
1002
- maximum: pt,
1001
+ maximum: dt,
1003
1002
  integers: !0
1004
1003
  }),
1005
- new De({
1004
+ new Le({
1006
1005
  label: "Accepted file types",
1007
1006
  description: "Types of allowed files to upload. If left blank, all files will be accepted.",
1008
1007
  required: !1,
@@ -1033,12 +1032,12 @@ const Ji = "_previewImage_1ig84_1", Zi = {
1033
1032
  ];
1034
1033
  }
1035
1034
  getFieldValidators() {
1036
- const e = super.getFieldValidators(), t = this.maxFileSize ?? pt, n = this.maxFiles ?? 1;
1037
- return e.push((r) => {
1038
- if (r && r.some((a) => a.size > t))
1039
- return `Files must be at most ${lt(t)}.`;
1040
- }), e.push((r) => {
1041
- if (r && r.length > n)
1035
+ const e = super.getFieldValidators(), t = this.maxFileSize ?? dt, n = this.maxFiles ?? 1;
1036
+ return e.push((o) => {
1037
+ if (o && o.some((a) => a.size > t))
1038
+ return `Files must be at most ${rt(t)}.`;
1039
+ }), e.push((o) => {
1040
+ if (o && o.length > n)
1042
1041
  return `You can only upload ${n} files.`;
1043
1042
  }), e;
1044
1043
  }
@@ -1053,46 +1052,46 @@ const Ji = "_previewImage_1ig84_1", Zi = {
1053
1052
  static deserialize(e) {
1054
1053
  if (e.type !== "upload")
1055
1054
  throw new Error("Type mismatch.");
1056
- return new le(e);
1055
+ return new ae(e);
1057
1056
  }
1058
1057
  getInput(e) {
1059
- return /* @__PURE__ */ o(en, { field: this, ...e });
1058
+ return /* @__PURE__ */ r(Yi, { field: this, ...e });
1060
1059
  }
1061
1060
  };
1062
- m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon", Ct);
1063
- let Qe = le;
1064
- const at = {
1065
- date: Ge,
1061
+ p(ae, "fieldTypeName", "Upload"), p(ae, "fieldTypeDescription", "Allows a file to be uploaded."), p(ae, "Icon", yt);
1062
+ let Ge = ae;
1063
+ const ot = {
1064
+ date: je,
1066
1065
  number: Q,
1067
- boolean: fe,
1068
- select: Ve,
1069
- string: be,
1070
- text: ye,
1071
- custom: _e,
1072
- upload: Qe,
1066
+ boolean: me,
1067
+ select: Ae,
1068
+ string: ye,
1069
+ text: we,
1070
+ custom: Pe,
1071
+ upload: Ge,
1073
1072
  // TODO: Underscore
1074
- "multi-string": ke,
1075
- "multi-select": De
1076
- }, $t = (s) => {
1073
+ "multi-string": Ee,
1074
+ "multi-select": Le
1075
+ }, kt = (s) => {
1077
1076
  const i = s.type;
1078
- return at[i].deserialize(s);
1079
- }, Be = (s) => s.type === "section" ? X.deserialize(s) : $t(s);
1080
- function Mt(s, i = {}) {
1077
+ return ot[i].deserialize(s);
1078
+ }, Oe = (s) => s.type === "section" ? J.deserialize(s) : kt(s);
1079
+ function Vt(s, i = {}) {
1081
1080
  const { readonly: e = !1 } = i;
1082
1081
  return {
1083
1082
  title: s.title,
1084
1083
  description: s.description,
1085
- fields: s.fields.map((t) => Be(t)),
1084
+ fields: s.fields.map((t) => Oe(t)),
1086
1085
  meta: { readonly: e }
1087
1086
  };
1088
1087
  }
1089
- function Xe(s) {
1088
+ function Ke(s) {
1090
1089
  return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
1091
1090
  }
1092
- function Ot(s, i) {
1091
+ function Dt(s, i) {
1093
1092
  if (!s)
1094
1093
  return !0;
1095
- if (Xe(i) || Xe(s.value))
1094
+ if (Ke(i) || Ke(s.value))
1096
1095
  throw new Error("Conditions do not support file uploads");
1097
1096
  const e = Array.isArray(i) ? i.map((n) => typeof n == "string" ? n : n.value) : i, t = Array.isArray(s.value) ? s.value.map((n) => typeof n == "string" ? n : n.value) : s.value;
1098
1097
  if (Array.isArray(t) && Array.isArray(e)) {
@@ -1103,92 +1102,92 @@ function Ot(s, i) {
1103
1102
  }
1104
1103
  return t === i;
1105
1104
  }
1106
- const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s, i) => {
1107
- const e = I(() => s.map((t) => /* @__PURE__ */ o("div", { children: t.getInput(i) }, t.getId())), [s, i]);
1108
- return /* @__PURE__ */ o(y, { direction: "column", gap: "2", children: e });
1109
- }, Me = (s) => Object.keys(s).length > 0, Nt = async (s, i) => {
1105
+ const ke = (s, i) => F(() => !i || !s ? null : s.getInput(i), [s, i]), $t = (s, i) => {
1106
+ const e = F(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
1107
+ return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
1108
+ }, Ve = (s) => Object.keys(s).length > 0, _t = async (s, i) => {
1110
1109
  const e = {};
1111
1110
  for (const t of s.fields)
1112
- if (t instanceof X) {
1111
+ if (t instanceof J) {
1113
1112
  if (t.condition) {
1114
1113
  const { identifier: n } = t.condition;
1115
- if (!Ot(t.condition, ue(i, n)))
1114
+ if (!Dt(t.condition, fe(i, n)))
1116
1115
  continue;
1117
1116
  }
1118
1117
  Object.assign(e, t.getErrors(i));
1119
1118
  } else {
1120
- if (!(t instanceof O))
1119
+ if (!(t instanceof R))
1121
1120
  throw new Error("Invalid field type");
1122
- const n = t.getId(), r = t.getError(ue(i, n), i);
1123
- r && st(e, n, r);
1121
+ const n = t.getId(), o = t.getError(fe(i, n), i);
1122
+ o && nt(e, n, o);
1124
1123
  }
1125
- if (Me(e))
1124
+ if (Ve(e))
1126
1125
  return e;
1127
- }, nn = [null, void 0], ct = (s, i) => s.reduce((e, t) => t instanceof X ? { ...e, ...ct(t.fields, i) } : (nn.includes(ue(e, t.getId())) && st(e, t.getId(), ""), e), i), rn = () => {
1126
+ }, Qi = [null, void 0], st = (s, i) => s.reduce((e, t) => t instanceof J ? { ...e, ...st(t.fields, i) } : (Qi.includes(fe(e, t.getId())) && nt(e, t.getId(), ""), e), i), Ji = () => {
1128
1127
  throw new Error("onSubmit must be provided if form is not readonly.");
1129
- }, dt = z(
1128
+ }, lt = z(
1130
1129
  ve((s, i) => {
1131
1130
  const {
1132
1131
  schema: e,
1133
1132
  values: t = {},
1134
- onSubmit: n = rn,
1135
- submitText: r = "Submit",
1133
+ onSubmit: n = Ji,
1134
+ submitText: o = "Submit",
1136
1135
  cancelText: a,
1137
1136
  onCancel: c,
1138
1137
  onDirty: l,
1139
1138
  // if the title isn't provided, hide it by default
1140
- hideTitle: d = !e.title,
1141
- hideDescription: f,
1139
+ hideTitle: f = !e.title,
1140
+ hideDescription: d,
1142
1141
  className: u
1143
- } = s, { readonly: p } = e.meta, h = I(() => crypto.randomUUID(), []), g = et({
1144
- initialValues: ct(e.fields, t),
1142
+ } = s, { readonly: h } = e.meta, g = F(() => crypto.randomUUID(), []), m = Je({
1143
+ initialValues: st(e.fields, t),
1145
1144
  onSubmit: n,
1146
- validate: (P) => Nt(e, P),
1145
+ validate: (k) => _t(e, k),
1147
1146
  // only validate the entire form on submit
1148
1147
  validateOnBlur: !1,
1149
1148
  validateOnChange: !1
1150
- }), { dirty: F } = g, S = I(
1151
- () => typeof e.title == "string" ? /* @__PURE__ */ o(Re, { children: e.title }) : e.title,
1149
+ }), { dirty: w } = m, x = F(
1150
+ () => typeof e.title == "string" ? /* @__PURE__ */ r($e, { children: e.title }) : e.title,
1152
1151
  [e.title]
1153
- ), v = I(
1154
- () => typeof e.description == "string" ? /* @__PURE__ */ o(D, { className: Ie.description, children: e.description }) : e.description,
1152
+ ), I = F(
1153
+ () => typeof e.description == "string" ? /* @__PURE__ */ r(D, { className: Me.description, children: e.description }) : e.description,
1155
1154
  [e.description]
1156
- ), x = Rt(e.fields, { formId: h, disabled: p });
1157
- return we(() => {
1158
- F && l && l();
1159
- }, [F, l]), /* @__PURE__ */ o(tt, { value: g, children: /* @__PURE__ */ o(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: h, onSubmit: g.handleSubmit, children: [
1160
- !d && /* @__PURE__ */ o(xe, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
1161
- S,
1162
- !f && v
1155
+ ), v = $t(e.fields, { formId: g, disabled: h });
1156
+ return ue(() => {
1157
+ w && l && l();
1158
+ }, [w, l]), /* @__PURE__ */ r(Ze, { value: m, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: g, onSubmit: m.handleSubmit, children: [
1159
+ !f && /* @__PURE__ */ r(xe, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
1160
+ x,
1161
+ !d && I
1163
1162
  ] }) }),
1164
- x,
1165
- !p && /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
1166
- a && /* @__PURE__ */ o(K, { type: "button", variant: "soft", onClick: c, children: a }),
1167
- /* @__PURE__ */ o(K, { type: "submit", disabled: !g.isValid, children: r })
1163
+ v,
1164
+ !h && /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
1165
+ a && /* @__PURE__ */ r(K, { type: "button", variant: "soft", onClick: c, children: a }),
1166
+ /* @__PURE__ */ r(K, { type: "submit", disabled: !m.isValid, children: o })
1168
1167
  ] })
1169
1168
  ] }) }) });
1170
1169
  })
1171
- ), On = z(
1170
+ ), Vn = z(
1172
1171
  ve((s, i) => {
1173
- const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, r = M(Tt(e.form_revision)), { sdk: a } = St();
1174
- if (!r)
1172
+ const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = N(vt(e.form_revision)), { sdk: a } = It();
1173
+ if (!o)
1175
1174
  throw new Error(
1176
1175
  `Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
1177
1176
  );
1178
- const c = I(() => Mt(r, { readonly: !0 }), [r]), l = I(() => {
1179
- const d = Si(e.offline_id)(a.store.getState()) ?? [], f = {};
1180
- for (const u of d) {
1181
- const p = a.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((g) => {
1182
- if (!g.success)
1177
+ const c = F(() => Vt(o, { readonly: !0 }), [o]), l = F(() => {
1178
+ const f = Ii(e.offline_id)(a.store.getState()) ?? [], d = {};
1179
+ for (const u of f) {
1180
+ const h = a.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((m) => {
1181
+ if (!m.success)
1183
1182
  throw new Error(`Failed to download attachment ${u.file_name}.`);
1184
- return g.body;
1185
- }), h = f[u.field_identifier];
1186
- h ? h.push(p) : f[u.field_identifier] = [p];
1183
+ return m.body;
1184
+ }), g = d[u.field_identifier];
1185
+ g ? g.push(h) : d[u.field_identifier] = [h];
1187
1186
  }
1188
- return { ...e.values, ...f };
1187
+ return { ...e.values, ...d };
1189
1188
  }, [a.files, a.store, e.offline_id, e.values]);
1190
- return /* @__PURE__ */ o(
1191
- dt,
1189
+ return /* @__PURE__ */ r(
1190
+ lt,
1192
1191
  {
1193
1192
  ref: i,
1194
1193
  schema: c,
@@ -1198,38 +1197,38 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1198
1197
  }
1199
1198
  );
1200
1199
  })
1201
- ), on = "_favoriteIcon_1bixi_1", sn = "_regularIcon_1bixi_9", ht = {
1202
- favoriteIcon: on,
1203
- regularIcon: sn
1204
- }, je = "organization:", He = "user:", Rn = z(
1200
+ ), Zi = "_favoriteIcon_1bixi_1", en = "_regularIcon_1bixi_9", ut = {
1201
+ favoriteIcon: Zi,
1202
+ regularIcon: en
1203
+ }, Be = "organization:", qe = "user:", Dn = z(
1205
1204
  ve((s, i) => {
1206
- const { maxResults: e = 20, ...t } = s, [n, r] = de(""), [a, c] = de(""), { sdk: l } = St(), d = I(() => {
1207
- const x = { maxResults: e, searchTerm: n };
1208
- return a && (a.startsWith(je) ? x.owner_organization = parseInt(a.slice(je.length)) : a.startsWith(He) && (x.owner_user = parseInt(a.slice(He.length)))), x;
1209
- }, [n, e, a]), f = M(zi(d)) ?? [], u = M(Ei), p = T(
1210
- (x) => {
1211
- x.favorite ? l.userForms.unfavorite(x.offline_id).then() : l.userForms.favorite(x.offline_id).then();
1205
+ const { maxResults: e = 20, ...t } = s, [n, o] = X(""), [a, c] = X(""), { sdk: l } = It(), f = F(() => {
1206
+ const v = { maxResults: e, searchTerm: n };
1207
+ return a && (a.startsWith(Be) ? v.owner_organization = parseInt(a.slice(Be.length)) : a.startsWith(qe) && (v.owner_user = parseInt(a.slice(qe.length)))), v;
1208
+ }, [n, e, a]), d = N(Fi(f)) ?? [], u = N(Ci), h = T(
1209
+ (v) => {
1210
+ v.favorite ? l.userForms.unfavorite(v.offline_id).then() : l.userForms.favorite(v.offline_id).then();
1212
1211
  },
1213
1212
  [l]
1214
- ), h = I(() => {
1215
- const x = l.store.getState(), P = {};
1216
- for (const _ of Object.values(u)) {
1217
- const w = zt(_.owner_organization || -1)(x);
1218
- w && (P[`${je}${w.id}`] = w.name);
1219
- const L = ot(_.owner_user || -1)(x);
1220
- L && (P[`${He}${L.id}`] = L.username);
1213
+ ), g = F(() => {
1214
+ const v = l.store.getState(), k = {};
1215
+ for (const L of Object.values(u)) {
1216
+ const C = Ft(L.owner_organization || -1)(v);
1217
+ C && (k[`${Be}${C.id}`] = C.name);
1218
+ const P = it(L.owner_user || -1)(v);
1219
+ P && (k[`${qe}${P.id}`] = P.username);
1221
1220
  }
1222
- return Object.entries(P).map(([_, w]) => ({ itemContent: w, value: _ }));
1223
- }, [u, l.store]), g = T((x) => {
1224
- r(x.currentTarget.value);
1225
- }, []), S = (M(Ai) || 0) - f.length, v = f.length == e && S > 0 ? `Only the first ${e} results are shown (${S} hidden)` : S > 0 && `${S} hidden forms`;
1221
+ return Object.entries(k).map(([L, C]) => ({ itemContent: C, value: L }));
1222
+ }, [u, l.store]), m = T((v) => {
1223
+ o(v.currentTarget.value);
1224
+ }, []), x = (N(Ti) || 0) - d.length, I = d.length == e && x > 0 ? `Only the first ${e} results are shown (${x} hidden)` : x > 0 && `${x} hidden forms`;
1226
1225
  return /* @__PURE__ */ b(y, { ref: i, direction: "column", gap: "2", children: [
1227
1226
  /* @__PURE__ */ b(y, { gap: "2", grow: "1", children: [
1228
- /* @__PURE__ */ o(ge, { grow: "1", asChild: !0, children: /* @__PURE__ */ o(ae.Root, { size: "3", children: /* @__PURE__ */ o(ae.Input, { placeholder: "Filter", value: n, onChange: g }) }) }),
1229
- /* @__PURE__ */ o(
1230
- vt,
1227
+ /* @__PURE__ */ r(be, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(ce.Root, { size: "3", children: /* @__PURE__ */ r(ce.Input, { placeholder: "Filter", value: n, onChange: m }) }) }),
1228
+ /* @__PURE__ */ r(
1229
+ gt,
1231
1230
  {
1232
- items: h,
1231
+ items: g,
1233
1232
  value: a,
1234
1233
  onValueChange: c,
1235
1234
  placeholder: "Owner",
@@ -1237,201 +1236,201 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1237
1236
  }
1238
1237
  )
1239
1238
  ] }),
1240
- f.length > 0 && /* @__PURE__ */ o(Ne.Root, { children: f.map((x) => /* @__PURE__ */ o(
1241
- ln,
1239
+ d.length > 0 && /* @__PURE__ */ r(_e.Root, { children: d.map((v) => /* @__PURE__ */ r(
1240
+ tn,
1242
1241
  {
1243
1242
  ...t,
1244
- form: x,
1245
- handleToggleFavorite: () => p(x)
1243
+ form: v,
1244
+ handleToggleFavorite: () => h(v)
1246
1245
  },
1247
- x.offline_id
1246
+ v.offline_id
1248
1247
  )) }),
1249
- /* @__PURE__ */ o(ge, { px: "3", children: /* @__PURE__ */ o(D, { size: "2", severity: "info", children: v }) })
1248
+ /* @__PURE__ */ r(be, { px: "3", children: /* @__PURE__ */ r(D, { size: "2", severity: "info", children: I }) })
1250
1249
  ] });
1251
1250
  })
1252
- ), ln = (s) => {
1253
- var p;
1254
- const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, r = (p = M(zt(i.owner_organization || -1))) == null ? void 0 : p.name, a = M(ot(i.owner_user || -1)), c = M(Et).id, l = !!a && a.id === c, d = r ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", f = T(
1255
- (h) => {
1256
- h.stopPropagation(), n();
1251
+ ), tn = (s) => {
1252
+ var h;
1253
+ const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (h = N(Ft(i.owner_organization || -1))) == null ? void 0 : h.name, a = N(it(i.owner_user || -1)), c = N(Ct).id, l = !!a && a.id === c, f = o ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", d = T(
1254
+ (g) => {
1255
+ g.stopPropagation(), n();
1257
1256
  },
1258
1257
  [n]
1259
- ), u = /* @__PURE__ */ o(Ne.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...oi, children: [
1258
+ ), u = /* @__PURE__ */ r(_e.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...ti, children: [
1260
1259
  /* @__PURE__ */ b(y, { grow: "1", align: "center", gap: "2", children: [
1261
- /* @__PURE__ */ o(
1262
- ce,
1260
+ /* @__PURE__ */ r(
1261
+ de,
1263
1262
  {
1264
- className: At(i.favorite ? ht.favoriteIcon : ht.regularIcon),
1263
+ className: Tt(i.favorite ? ut.favoriteIcon : ut.regularIcon),
1265
1264
  variant: "ghost",
1266
- onClick: f,
1265
+ onClick: d,
1267
1266
  "aria-label": i.favorite ? "Favorite form" : "Standard form",
1268
1267
  disabled: !t,
1269
- children: i.favorite ? /* @__PURE__ */ o(si, {}) : /* @__PURE__ */ o(li, {})
1268
+ children: i.favorite ? /* @__PURE__ */ r(ii, {}) : /* @__PURE__ */ r(ni, {})
1270
1269
  }
1271
1270
  ),
1272
- /* @__PURE__ */ o(D, { noWrap: !0, children: i.latestRevision.title }),
1273
- i.latestRevision.description && /* @__PURE__ */ o(ai, {})
1271
+ /* @__PURE__ */ r(D, { noWrap: !0, children: i.latestRevision.title }),
1272
+ i.latestRevision.description && /* @__PURE__ */ r(ri, {})
1274
1273
  ] }),
1275
- d && /* @__PURE__ */ b(y, { align: "center", gap: "2", children: [
1276
- /* @__PURE__ */ o(ci, {}),
1274
+ f && /* @__PURE__ */ b(y, { align: "center", gap: "2", children: [
1275
+ /* @__PURE__ */ r(oi, {}),
1277
1276
  " ",
1278
- d
1277
+ f
1279
1278
  ] })
1280
1279
  ] }) });
1281
- return i.latestRevision.description ? /* @__PURE__ */ o(di, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1282
- }, an = "_submissionsContainer_9iirt_1", cn = "_stopHorizontalOverflow_9iirt_6", Bt = {
1283
- submissionsContainer: an,
1284
- stopHorizontalOverflow: cn
1285
- }, dn = z(function(i) {
1286
- var x;
1287
- const { submission: e, onSubmissionClick: t, compact: n, labelType: r, rowDecorator: a } = i, c = M(Et), l = M(ot("created_by" in e ? e.created_by : c.id)), d = Je(e), f = Li(d) ? d.toLocaleTimeString([], {
1280
+ return i.latestRevision.description ? /* @__PURE__ */ r(si, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1281
+ }, nn = "_submissionsContainer_9iirt_1", rn = "_stopHorizontalOverflow_9iirt_6", Mt = {
1282
+ submissionsContainer: nn,
1283
+ stopHorizontalOverflow: rn
1284
+ }, on = z(function(i) {
1285
+ var v;
1286
+ const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c = N(Ct), l = N(it("created_by" in e ? e.created_by : c.id)), f = Ye(e), d = Si(f) ? f.toLocaleTimeString([], {
1288
1287
  hour: "2-digit",
1289
1288
  minute: "2-digit"
1290
- }) : Pi(d), u = M(Tt(e.form_revision));
1289
+ }) : zi(f), u = N(vt(e.form_revision));
1291
1290
  if (!u)
1292
1291
  throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
1293
- const p = (x = M(ki(u.form))) == null ? void 0 : x.revision, h = Vi({
1292
+ const h = (v = N(Ei(u.form))) == null ? void 0 : v.revision, g = Ai({
1294
1293
  file: (l == null ? void 0 : l.profile.file) ?? null,
1295
1294
  fileSha1: (l == null ? void 0 : l.profile.file_sha1) ?? null
1296
- }), g = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", F = u.revision === p, S = Ci.useCallback(() => {
1295
+ }), m = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", w = u.revision === h, x = wi.useCallback(() => {
1297
1296
  t && t({ submission: e });
1298
- }, [e, t]), v = /* @__PURE__ */ o(Ne.Item, { onClick: S, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
1299
- /* @__PURE__ */ b(y, { gap: "2", align: "center", className: Bt.stopHorizontalOverflow, children: [
1300
- /* @__PURE__ */ o(ui, { src: h, size: "1", fallback: g }),
1301
- /* @__PURE__ */ o(D, { size: "2", noWrap: !0, children: r === "creator" ? (l || c).username : u.title })
1297
+ }, [e, t]), I = /* @__PURE__ */ r(_e.Item, { onClick: x, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
1298
+ /* @__PURE__ */ b(y, { gap: "2", align: "center", className: Mt.stopHorizontalOverflow, children: [
1299
+ /* @__PURE__ */ r(li, { src: g, size: "1", fallback: m }),
1300
+ /* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: o === "creator" ? (l || c).username : u.title })
1302
1301
  ] }),
1303
1302
  /* @__PURE__ */ b(y, { gap: "2", align: "center", children: [
1304
- !n && (u.revision ? /* @__PURE__ */ o(Ue, { variant: "soft", severity: F ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!p && /* @__PURE__ */ o(Ue, { children: "Original" })),
1305
- /* @__PURE__ */ o(D, { size: "2", noWrap: !0, children: f })
1303
+ !n && (u.revision ? /* @__PURE__ */ r(We, { variant: "soft", severity: w ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!h && /* @__PURE__ */ r(We, { children: "Original" })),
1304
+ /* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: d })
1306
1305
  ] })
1307
1306
  ] }) });
1308
- return a ? a(e, v) : v;
1309
- }), Je = (s) => {
1307
+ return a ? a(e, I) : I;
1308
+ }), Ye = (s) => {
1310
1309
  const i = "created_at" in s ? s.created_at : s.submitted_at;
1311
1310
  return new Date(i);
1312
- }, Nn = z(function(i) {
1311
+ }, $n = z(function(i) {
1313
1312
  const {
1314
1313
  formId: e,
1315
1314
  submissions: t,
1316
1315
  compact: n = !1,
1317
- className: r,
1316
+ className: o,
1318
1317
  after: a,
1319
1318
  variant: c = "outline",
1320
1319
  ...l
1321
1320
  } = i;
1322
1321
  if (!!e == !!t)
1323
1322
  throw new Error("Either formId or submissions must be provided, but not both.");
1324
- const d = M(
1325
- t ? () => t : Di(e)
1326
- ), f = I(
1327
- () => d == null ? void 0 : d.sort((u, p) => Je(p).getTime() - Je(u).getTime()),
1328
- [d]
1323
+ const f = N(
1324
+ t ? () => t : Li(e)
1325
+ ), d = F(
1326
+ () => f == null ? void 0 : f.sort((u, h) => Ye(h).getTime() - Ye(u).getTime()),
1327
+ [f]
1329
1328
  );
1330
- return /* @__PURE__ */ o(
1331
- Ne.Root,
1329
+ return /* @__PURE__ */ r(
1330
+ _e.Root,
1332
1331
  {
1333
- className: At(Bt.submissionsContainer, r),
1332
+ className: Tt(Mt.submissionsContainer, o),
1334
1333
  size: "small",
1335
1334
  variant: c,
1336
1335
  before: !n && /* @__PURE__ */ b(D, { severity: "info", children: [
1337
1336
  "There are ",
1338
- ((d == null ? void 0 : d.length) || 0).toString(),
1337
+ ((f == null ? void 0 : f.length) || 0).toString(),
1339
1338
  " submissions of this form."
1340
1339
  ] }),
1341
1340
  after: a,
1342
- children: f == null ? void 0 : f.map((u, p) => /* @__PURE__ */ o(
1343
- dn,
1341
+ children: d == null ? void 0 : d.map((u, h) => /* @__PURE__ */ r(
1342
+ on,
1344
1343
  {
1345
1344
  submission: u,
1346
1345
  compact: n,
1347
1346
  ...l
1348
1347
  },
1349
- p
1348
+ h
1350
1349
  ))
1351
1350
  }
1352
1351
  );
1353
- }), Bn = z(function(i) {
1354
- const { name: e, render: t } = i, { submitForm: n } = pe(), [r, a, c] = Ze(e);
1355
- return I(() => {
1356
- const l = (d) => c.setValue(d, !1);
1352
+ }), _n = z(function(i) {
1353
+ const { name: e, render: t } = i, { submitForm: n } = he(), [o, a, c] = Qe(e);
1354
+ return F(() => {
1355
+ const l = (f) => c.setValue(f, !1);
1357
1356
  return t({
1358
- value: r.value,
1357
+ value: o.value,
1359
1358
  setValue: l,
1360
1359
  patchValue: n
1361
1360
  });
1362
- }, [n, c, r.value, t]);
1363
- }), qn = z(
1361
+ }, [n, c, o.value, t]);
1362
+ }), Mn = z(
1364
1363
  ve((s, i) => {
1365
- const { children: e, schema: t, values: n, onPatch: r, onError: a, ...c } = s, l = I(() => ct(t.fields, n), [t.fields, n]), d = T(
1366
- (g) => {
1367
- const F = {};
1368
- for (const S in g) {
1369
- const v = g[S];
1370
- v !== l[S] && v !== void 0 && (F[S] = v);
1364
+ const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = F(() => st(t.fields, n), [t.fields, n]), f = T(
1365
+ (m) => {
1366
+ const w = {};
1367
+ for (const x in m) {
1368
+ const I = m[x];
1369
+ I !== l[x] && I !== void 0 && (w[x] = I);
1371
1370
  }
1372
- Me(F) && r(F);
1371
+ Ve(w) && o(w);
1373
1372
  },
1374
- [l, r]
1375
- ), f = T(
1376
- async (g) => {
1377
- const F = await Nt(t, g);
1378
- return F && a(F), F;
1373
+ [l, o]
1374
+ ), d = T(
1375
+ async (m) => {
1376
+ const w = await _t(t, m);
1377
+ return w && a(w), w;
1379
1378
  },
1380
1379
  [t, a]
1381
- ), u = et({
1380
+ ), u = Je({
1382
1381
  initialValues: l,
1383
- onSubmit: d,
1384
- validate: f,
1382
+ onSubmit: f,
1383
+ validate: d,
1385
1384
  // only validate the entire form on submit
1386
1385
  validateOnBlur: !1,
1387
1386
  validateOnChange: !1
1388
- }), { errors: p, resetForm: h } = u;
1389
- return we(() => {
1390
- Me(p) && h({ values: l, errors: {} });
1391
- }, [p, l, h]), /* @__PURE__ */ o(tt, { value: u, children: /* @__PURE__ */ o("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1387
+ }), { errors: h, resetForm: g } = u;
1388
+ return ue(() => {
1389
+ Ve(h) && g({ values: l, errors: {} });
1390
+ }, [h, l, g]), /* @__PURE__ */ r(Ze, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1392
1391
  })
1393
- ), qt = {
1394
- ...at,
1395
- section: X
1396
- }, un = z(function(i) {
1397
- const { field: e, setFieldType: t } = i, n = e.fieldTypeName, r = e.fieldTypeDescription, a = e.Icon;
1392
+ ), Ot = {
1393
+ ...ot,
1394
+ section: J
1395
+ }, sn = z(function(i) {
1396
+ const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, a = e.Icon;
1398
1397
  return /* @__PURE__ */ b(y, { gap: "4", align: "center", children: [
1399
- /* @__PURE__ */ o(K, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
1400
- /* @__PURE__ */ o(a, {}),
1398
+ /* @__PURE__ */ r(K, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
1399
+ /* @__PURE__ */ r(a, {}),
1401
1400
  n
1402
1401
  ] }) }),
1403
- /* @__PURE__ */ o(D, { children: r })
1402
+ /* @__PURE__ */ r(D, { children: o })
1404
1403
  ] });
1405
- }), Wt = [
1404
+ }), Nt = [
1406
1405
  ["string", "text"],
1407
1406
  ["select", "multi-select", "upload"],
1408
1407
  ["boolean", "date", "number", "multi-string"]
1409
- ], fn = Wt.length - 1, mn = z(function(i) {
1408
+ ], ln = Nt.length - 1, an = z(function(i) {
1410
1409
  const { setFieldType: e } = i;
1411
- return /* @__PURE__ */ o(y, { direction: "column", gap: "3", children: Wt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
1412
- /* @__PURE__ */ o(y, { direction: "column", gap: "2", children: t.map((r) => /* @__PURE__ */ o(
1413
- un,
1410
+ return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Nt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
1411
+ /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
1412
+ sn,
1414
1413
  {
1415
- field: at[r],
1416
- setFieldType: () => e(r)
1414
+ field: ot[o],
1415
+ setFieldType: () => e(o)
1417
1416
  },
1418
- r
1417
+ o
1419
1418
  )) }),
1420
- n < fn && /* @__PURE__ */ o(fi, { size: "4" })
1419
+ n < ln && /* @__PURE__ */ r(ai, { size: "4" })
1421
1420
  ] }, n)) });
1422
- }), pn = (s) => (i) => {
1421
+ }), cn = (s) => (i) => {
1423
1422
  if (!(!i || typeof i != "string") && s.includes(i.trim()))
1424
1423
  return "This name is already taken.";
1425
- }, hn = (s, i) => {
1424
+ }, dn = (s, i) => {
1426
1425
  const e = [
1427
- new be({
1426
+ new ye({
1428
1427
  label: "Label",
1429
1428
  required: !0,
1430
1429
  maxLength: 200,
1431
1430
  identifier: "label",
1432
- fieldValidators: [pn(s)]
1431
+ fieldValidators: [cn(s)]
1433
1432
  }),
1434
- new ye({
1433
+ new we({
1435
1434
  label: "Description",
1436
1435
  required: !1,
1437
1436
  maxLength: 1e3,
@@ -1440,18 +1439,18 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1440
1439
  ];
1441
1440
  return i === "section" ? e : [
1442
1441
  ...e,
1443
- new fe({ label: "Required", description: null, required: !1, identifier: "required" })
1442
+ new me({ label: "Required", description: null, required: !1, identifier: "required" })
1444
1443
  ];
1445
- }, gn = z(function(i) {
1446
- const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: r, conditionalSourceFields: a } = i, c = qt[e], l = pe(), d = I(() => {
1447
- const f = Dt(l.values.fields).filter((p) => p !== (r == null ? void 0 : r.label));
1448
- let u = hn(f, e);
1449
- if (c === X) {
1444
+ }, un = z(function(i) {
1445
+ const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c = Ot[e], l = he(), f = F(() => {
1446
+ const d = Lt(l.values.fields).filter((h) => h !== (o == null ? void 0 : o.label));
1447
+ let u = dn(d, e);
1448
+ if (c === J) {
1450
1449
  if (a === void 0)
1451
1450
  throw new Error("Conditional source fields must be provided when changing sections.");
1452
1451
  u = u.concat(c.getFieldCreationSchema(a));
1453
1452
  } else {
1454
- if (!(c.prototype instanceof O))
1453
+ if (!(c.prototype instanceof R))
1455
1454
  throw new Error(`Field must be an instance of BaseField. Got ${c}.`);
1456
1455
  u = [...u, ...c.getFieldCreationSchema()];
1457
1456
  }
@@ -1461,120 +1460,120 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1461
1460
  // using the dialog title as the form title
1462
1461
  title: null
1463
1462
  };
1464
- }, [l.values.fields, e, c, r == null ? void 0 : r.label, a]);
1465
- return /* @__PURE__ */ o(
1466
- dt,
1463
+ }, [l.values.fields, e, c, o == null ? void 0 : o.label, a]);
1464
+ return /* @__PURE__ */ r(
1465
+ lt,
1467
1466
  {
1468
- schema: d,
1469
- values: r,
1467
+ schema: f,
1468
+ values: o,
1470
1469
  onSubmit: n,
1471
- cancelText: r ? void 0 : "Back",
1470
+ cancelText: o ? void 0 : "Back",
1472
1471
  onCancel: t
1473
1472
  }
1474
1473
  );
1475
- }), he = z(function(i) {
1476
- const { parentPath: e, index: t, children: n, initial: r, editing: a, conditionalSourceFields: c } = i, [l, d] = de(), f = (r == null ? void 0 : r.type) ?? l, u = f ? qt[f].fieldTypeName : void 0, { setFieldValue: p, values: h } = pe();
1477
- if (a && !r)
1474
+ }), ge = z(function(i) {
1475
+ const { parentPath: e, index: t, children: n, initial: o, editing: a, conditionalSourceFields: c } = i, [l, f] = X(), d = (o == null ? void 0 : o.type) ?? l, u = d ? Ot[d].fieldTypeName : void 0, { setFieldValue: h, values: g } = he();
1476
+ if (a && !o)
1478
1477
  throw new Error("Initial field must be provided if editing is true.");
1479
- const g = !f && !a && !r, F = g ? "Choose a field type" : `${u} settings`, S = g ? "Select a field type to add to this section." : (u == null ? void 0 : u.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${u == null ? void 0 : u.toLowerCase()} field.`, v = T(() => d(void 0), []), x = T((w) => {
1480
- d(void 0), w();
1481
- }, []), P = T(
1482
- (w, L) => {
1483
- const { label: $ } = w;
1484
- if (!f)
1478
+ const m = !d && !a && !o, w = m ? "Choose a field type" : `${u} settings`, x = m ? "Select a field type to add to this section." : (u == null ? void 0 : u.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${u == null ? void 0 : u.toLowerCase()} field.`, I = T(() => f(void 0), []), v = T((C) => {
1479
+ f(void 0), C();
1480
+ }, []), k = T(
1481
+ (C, P) => {
1482
+ const { label: O } = C;
1483
+ if (!d)
1485
1484
  throw new Error("Field type must be selected before creating a field.");
1486
- if (!$ || typeof $ != "string")
1485
+ if (!O || typeof O != "string")
1487
1486
  throw new Error("Label must be provided before creating a field.");
1488
- const H = Be({
1489
- type: f,
1490
- ...w,
1491
- identifier: kt(w.identifier, $)
1492
- }).serialize(), U = ue(h, e);
1493
- if (U === void 0)
1487
+ const _ = Oe({
1488
+ type: d,
1489
+ ...C,
1490
+ identifier: Et(C.identifier, O)
1491
+ }).serialize(), M = fe(g, e);
1492
+ if (M === void 0)
1494
1493
  throw new Error("Parent path must point to an existing field.");
1495
- let G;
1496
- if (!Array.isArray(U))
1494
+ let B;
1495
+ if (!Array.isArray(M))
1497
1496
  throw new Error("Parent path must point to an array.");
1498
- a ? G = Hi(U, t, H) : G = Pt(U, t, H), p(e, G).then(), L();
1497
+ a ? B = Ri(M, t, _) : B = zt(M, t, _), h(e, B).then(), P();
1499
1498
  },
1500
- [a, f, h, e, p, t]
1501
- ), _ = T(
1502
- (w) => g ? /* @__PURE__ */ o(mn, { setFieldType: d }) : /* @__PURE__ */ o(
1503
- gn,
1499
+ [a, d, g, e, h, t]
1500
+ ), L = T(
1501
+ (C) => m ? /* @__PURE__ */ r(an, { setFieldType: f }) : /* @__PURE__ */ r(
1502
+ un,
1504
1503
  {
1505
1504
  conditionalSourceFields: c,
1506
- handleCancel: v,
1507
- handleCreateField: (L) => P(L, w),
1508
- fieldType: f,
1509
- defaultField: r
1505
+ handleCancel: I,
1506
+ handleCreateField: (P) => k(P, C),
1507
+ fieldType: d,
1508
+ defaultField: o
1510
1509
  }
1511
1510
  ),
1512
- [c, v, P, r, g, f]
1511
+ [c, I, k, o, m, d]
1513
1512
  );
1514
- return /* @__PURE__ */ o(mi, { onCloseInterrupt: x, title: F, description: S, content: _, children: n });
1515
- }), gt = ({ children: s }) => /* @__PURE__ */ o(wt, { children: s }), bt = (s, i) => ({
1513
+ return /* @__PURE__ */ r(ci, { onCloseInterrupt: v, title: w, description: x, content: L, children: n });
1514
+ }), ft = ({ children: s }) => /* @__PURE__ */ r(Xe, { children: s }), mt = (s, i) => ({
1516
1515
  initial: s ? i : "none",
1517
1516
  sm: s ? "none" : i
1518
- }), jt = z(function(i) {
1519
- const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: r, duplicateProps: a } = i, c = I(
1517
+ }), Rt = z(function(i) {
1518
+ const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: a } = i, c = F(
1520
1519
  () => [
1521
1520
  {
1522
- Wrapper: he,
1521
+ Wrapper: ge,
1523
1522
  wrapperProps: n,
1524
- Icon: pi,
1523
+ Icon: di,
1525
1524
  text: "Edit"
1526
1525
  },
1527
1526
  {
1528
- Icon: hi,
1527
+ Icon: ui,
1529
1528
  buttonProps: {
1530
1529
  onClick: e
1531
1530
  },
1532
1531
  text: "Delete"
1533
1532
  },
1534
1533
  {
1535
- Wrapper: he,
1534
+ Wrapper: ge,
1536
1535
  wrapperProps: a,
1537
- Icon: gi,
1536
+ Icon: fi,
1538
1537
  text: "Duplicate"
1539
1538
  },
1540
1539
  {
1541
- Wrapper: he,
1542
- wrapperProps: r,
1543
- Icon: Oe,
1540
+ Wrapper: ge,
1541
+ wrapperProps: o,
1542
+ Icon: De,
1544
1543
  text: "Add after"
1545
1544
  },
1546
1545
  {
1547
1546
  // Wrapping icon in a div so that the asChild turns the button into a div
1548
1547
  // so that the drag handle props are not applied to the icon
1549
1548
  // Note: b/c the <button> does not handle the space-press event correctly
1550
- Icon: (l) => /* @__PURE__ */ o("div", { ...l, children: /* @__PURE__ */ o(bi, {}) }),
1549
+ Icon: (l) => /* @__PURE__ */ r("div", { ...l, children: /* @__PURE__ */ r(mi, {}) }),
1551
1550
  text: "Reorder",
1552
1551
  disableOnMobile: !0,
1553
1552
  buttonProps: { ...t, asChild: !0 }
1554
1553
  }
1555
1554
  ],
1556
- [t, a, n, r, e]
1555
+ [t, a, n, o, e]
1557
1556
  );
1558
- return /* @__PURE__ */ b(wt, { children: [
1559
- /* @__PURE__ */ o(y, { gap: "4", display: bt(!1, "flex"), children: c.map((l) => {
1560
- const d = l.Wrapper ?? gt;
1561
- return /* @__PURE__ */ o(d, { ...l.wrapperProps, children: /* @__PURE__ */ o(ce, { type: "button", variant: "ghost", "aria-label": l.text, ...l.buttonProps, children: /* @__PURE__ */ o(l.Icon, {}) }) }, l.text);
1557
+ return /* @__PURE__ */ b(Xe, { children: [
1558
+ /* @__PURE__ */ r(y, { gap: "4", display: mt(!1, "flex"), children: c.map((l) => {
1559
+ const f = l.Wrapper ?? ft;
1560
+ return /* @__PURE__ */ r(f, { ...l.wrapperProps, children: /* @__PURE__ */ r(de, { type: "button", variant: "ghost", "aria-label": l.text, ...l.buttonProps, children: /* @__PURE__ */ r(l.Icon, {}) }) }, l.text);
1562
1561
  }) }),
1563
- /* @__PURE__ */ o(ge, { display: bt(!0, "block"), children: /* @__PURE__ */ o(
1564
- yi,
1562
+ /* @__PURE__ */ r(be, { display: mt(!0, "block"), children: /* @__PURE__ */ r(
1563
+ pi,
1565
1564
  {
1566
- trigger: /* @__PURE__ */ o(ce, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ o(xi, {}) }),
1565
+ trigger: /* @__PURE__ */ r(de, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(hi, {}) }),
1567
1566
  closeOnSelect: !1,
1568
1567
  items: c.map((l) => {
1569
- var f;
1568
+ var d;
1570
1569
  if (l.disableOnMobile)
1571
1570
  return null;
1572
- const d = l.Wrapper ?? gt;
1571
+ const f = l.Wrapper ?? ft;
1573
1572
  return {
1574
1573
  ...l.buttonProps,
1575
- onSelect: (f = l.buttonProps) == null ? void 0 : f.onClick,
1576
- content: /* @__PURE__ */ o(d, { ...l.wrapperProps, children: /* @__PURE__ */ b(y, { gap: "2", align: "center", children: [
1577
- /* @__PURE__ */ o(l.Icon, {}),
1574
+ onSelect: (d = l.buttonProps) == null ? void 0 : d.onClick,
1575
+ content: /* @__PURE__ */ r(f, { ...l.wrapperProps, children: /* @__PURE__ */ b(y, { gap: "2", align: "center", children: [
1576
+ /* @__PURE__ */ r(l.Icon, {}),
1578
1577
  l.text
1579
1578
  ] }) })
1580
1579
  };
@@ -1582,15 +1581,15 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1582
1581
  }
1583
1582
  ) })
1584
1583
  ] });
1585
- }), qe = "form-builder", bn = z(function(i) {
1586
- const { field: e, index: t, sectionIndex: n, takenLabels: r, remove: a, getFieldNodeMap: c } = i, l = I(() => Be(e), [e]), d = $e(l, { formId: qe, disabled: !0 }), f = T(
1587
- (g) => {
1588
- if (g.label === null)
1589
- throw new Error(`Expected a label for field ${g.identifier}`);
1590
- return { ...g, label: Ye(g.label, r), identifier: "" };
1584
+ }), Ne = "form-builder", fn = z(function(i) {
1585
+ const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a, getFieldNodeMap: c } = i, l = F(() => Oe(e), [e]), f = ke(l, { formId: Ne, disabled: !0 }), d = T(
1586
+ (m) => {
1587
+ if (m.label === null)
1588
+ throw new Error(`Expected a label for field ${m.identifier}`);
1589
+ return { ...m, label: Ue(m.label, o), identifier: "" };
1591
1590
  },
1592
- [r]
1593
- ), u = I(
1591
+ [o]
1592
+ ), u = F(
1594
1593
  () => ({
1595
1594
  index: t,
1596
1595
  parentPath: `fields.${n}.fields`,
@@ -1598,14 +1597,14 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1598
1597
  editing: !0
1599
1598
  }),
1600
1599
  [e, t, n]
1601
- ), p = I(
1600
+ ), h = F(
1602
1601
  () => ({
1603
1602
  parentPath: `fields.${n}.fields`,
1604
1603
  index: t + 1,
1605
- initial: f(e)
1604
+ initial: d(e)
1606
1605
  }),
1607
- [f, e, t, n]
1608
- ), h = I(
1606
+ [d, e, t, n]
1607
+ ), g = F(
1609
1608
  () => ({
1610
1609
  parentPath: `fields.${n}.fields`,
1611
1610
  index: t + 1,
@@ -1613,33 +1612,33 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1613
1612
  }),
1614
1613
  [t, n]
1615
1614
  );
1616
- return /* @__PURE__ */ o(rt, { draggableId: e.identifier, index: t, children: (g) => /* @__PURE__ */ o(
1615
+ return /* @__PURE__ */ r(tt, { draggableId: e.identifier, index: t, children: (m) => /* @__PURE__ */ r(
1617
1616
  xe,
1618
1617
  {
1619
- ref: g.innerRef,
1620
- ...g.draggableProps,
1621
- ...g.dragHandleProps,
1618
+ ref: m.innerRef,
1619
+ ...m.draggableProps,
1620
+ ...m.dragHandleProps,
1622
1621
  mb: "4",
1623
1622
  children: /* @__PURE__ */ b(
1624
1623
  y,
1625
1624
  {
1626
- ref: (F) => {
1627
- const S = c();
1628
- F ? S.set(e.identifier, F) : S.delete(e.identifier);
1625
+ ref: (w) => {
1626
+ const x = c();
1627
+ w ? x.set(e.identifier, w) : x.delete(e.identifier);
1629
1628
  },
1630
1629
  gap: "4",
1631
1630
  justify: "between",
1632
1631
  align: "center",
1633
1632
  children: [
1634
- d,
1635
- /* @__PURE__ */ o(
1636
- jt,
1633
+ f,
1634
+ /* @__PURE__ */ r(
1635
+ Rt,
1637
1636
  {
1638
1637
  remove: a,
1639
1638
  editProps: u,
1640
- duplicateProps: p,
1641
- insertAfterProps: h,
1642
- dragHandleProps: g.dragHandleProps
1639
+ duplicateProps: h,
1640
+ insertAfterProps: g,
1641
+ dragHandleProps: m.dragHandleProps
1643
1642
  }
1644
1643
  )
1645
1644
  ]
@@ -1647,270 +1646,206 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1647
1646
  )
1648
1647
  }
1649
1648
  ) });
1650
- }), yn = z(function(i) {
1651
- const { start: e, end: t } = i;
1652
- if (e === void 0 || t === void 0)
1653
- return null;
1654
- const n = 20, r = {
1655
- x: Math.min(e.x, t.x),
1656
- y: Math.min(e.y, t.y)
1657
- }, a = Math.abs(t.x - e.x) + n * 2, c = Math.abs(t.y - e.y);
1658
- return /* @__PURE__ */ b(
1659
- "svg",
1660
- {
1661
- width: a,
1662
- height: c,
1663
- style: {
1664
- backgroundColor: "#eee",
1665
- transform: `translate(${r.x}px, ${r.y}px)`
1666
- },
1667
- children: [
1668
- /* @__PURE__ */ o(
1669
- "line",
1670
- {
1671
- stroke: "black",
1672
- strokeWidth: 2,
1673
- x1: e.x - r.x - n,
1674
- y1: t.y - r.y,
1675
- x2: t.x - r.x,
1676
- y2: t.y - r.y
1677
- }
1678
- ),
1679
- /* @__PURE__ */ o(
1680
- "line",
1681
- {
1682
- stroke: "black",
1683
- strokeWidth: 2,
1684
- x1: e.x - r.x - n,
1685
- y1: e.y - r.y,
1686
- x2: e.x - r.x - n,
1687
- y2: t.y - r.y
1688
- }
1689
- ),
1690
- /* @__PURE__ */ o(
1691
- "line",
1692
- {
1693
- stroke: "black",
1694
- strokeWidth: 2,
1695
- x1: e.x - r.x,
1696
- y1: e.y - r.y,
1697
- x2: t.x - r.x - n,
1698
- y2: e.y - r.y
1699
- }
1700
- )
1701
- ]
1702
- }
1703
- );
1704
- }), xn = z(function(i) {
1705
- var G, A, N, Y, Ce, Fe, Te, ut;
1706
- const { field: e, index: t, dropState: n, getFieldNodeMap: r } = i, a = it(null), c = (G = n[e.identifier]) == null ? void 0 : G.disabled, { setFieldValue: l, values: d } = pe(), f = wi(), u = Dt(d.fields), p = T(
1707
- (C, E) => {
1708
- for (const V of C) {
1709
- const k = E.indexOf(V);
1710
- l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
1649
+ }), mn = z(function(i) {
1650
+ var O, _, M, B, A, q, Y;
1651
+ const { field: e, index: t, dropState: n, getFieldNodeMap: o } = i, a = (O = n[e.identifier]) == null ? void 0 : O.disabled, { setFieldValue: c, values: l } = he(), f = gi(), d = Lt(l.fields), u = T(
1652
+ (E, S) => {
1653
+ for (const V of E) {
1654
+ const $ = S.indexOf(V);
1655
+ c(`fields.${$}.condition`, null).then(), c(`fields.${$}.conditional`, !1).then();
1711
1656
  }
1712
1657
  },
1713
- [l]
1658
+ [c]
1714
1659
  ), h = T(
1715
- (C) => {
1716
- var k;
1717
- const E = e.fields[C];
1718
- if (!E)
1660
+ (E) => {
1661
+ var $;
1662
+ const S = e.fields[E];
1663
+ if (!S)
1719
1664
  throw new Error("Could not find field to remove.");
1720
1665
  const V = [];
1721
- for (const R of d.fields)
1722
- ((k = R.condition) == null ? void 0 : k.identifier) === E.identifier && V.push(R);
1666
+ for (const W of l.fields)
1667
+ (($ = W.condition) == null ? void 0 : $.identifier) === S.identifier && V.push(W);
1723
1668
  return {
1724
- removing: E,
1669
+ removing: S,
1725
1670
  affectedSections: V,
1726
- action: () => l(`fields.${t}.fields`, Pe(e.fields, C))
1671
+ action: () => c(`fields.${t}.fields`, ze(e.fields, E))
1727
1672
  };
1728
1673
  },
1729
- [e.fields, d.fields, l, t]
1674
+ [e.fields, l.fields, c, t]
1730
1675
  ), g = T(
1731
- (C) => {
1732
- const { affectedSections: E, action: V, removing: k } = h(C), R = () => {
1733
- V().then(), p(E, d.fields);
1676
+ (E) => {
1677
+ const { affectedSections: S, action: V, removing: $ } = h(E), W = () => {
1678
+ V().then(), u(S, l.fields);
1734
1679
  };
1735
- if (E.length > 0) {
1736
- const We = E.map((Se) => Se.label).join(", ");
1680
+ if (S.length > 0) {
1681
+ const Re = S.map((Ie) => Ie.label).join(", ");
1737
1682
  return f({
1738
1683
  title: "Remove condition?",
1739
- description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${We} section(s).`,
1684
+ description: `${$.label} is being used as a condition, deleting it will remove the condition from the ${Re} section(s).`,
1740
1685
  severity: "danger",
1741
1686
  actionText: "Remove",
1742
- onAction: R
1687
+ onAction: W
1743
1688
  });
1744
1689
  }
1745
- R();
1690
+ W();
1746
1691
  },
1747
- [h, p, d.fields, f]
1748
- ), F = T(() => {
1749
- const E = e.fields.map((ze, Ht) => h(Ht)).flatMap((ze) => ze.affectedSections), V = E.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, R = E.map((ze) => ze.label).join(", "), We = E.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${R}` : `Deleting this section will remove the ${k} field(s) it contains.`, Se = Pe(d.fields, t), ft = () => l("fields", Se);
1750
- if (E.length > 0)
1692
+ [h, u, l.fields, f]
1693
+ ), m = T(() => {
1694
+ const S = e.fields.map((Fe, Bt) => h(Bt)).flatMap((Fe) => Fe.affectedSections), V = S.length ? "Remove fields and conditions?" : "Remove fields?", $ = e.fields.length, W = S.map((Fe) => Fe.label).join(", "), Re = S.length ? `Deleting this section will remove the ${$} field(s) it contains and will remove the conditions from following sections: ${W}` : `Deleting this section will remove the ${$} field(s) it contains.`, Ie = ze(l.fields, t), at = () => c("fields", Ie);
1695
+ if (S.length > 0)
1751
1696
  return f({
1752
1697
  title: V,
1753
- description: We,
1698
+ description: Re,
1754
1699
  severity: "danger",
1755
1700
  actionText: "Remove",
1756
1701
  onAction: () => {
1757
- ft().then(() => {
1758
- p(E, Se);
1702
+ at().then(() => {
1703
+ u(S, Ie);
1759
1704
  });
1760
1705
  }
1761
1706
  });
1762
- ft().then();
1707
+ at().then();
1763
1708
  }, [
1764
1709
  e.fields,
1765
- d.fields,
1710
+ l.fields,
1766
1711
  t,
1767
1712
  h,
1768
- l,
1713
+ c,
1769
1714
  f,
1770
- p
1771
- ]), S = T(
1772
- (C) => {
1773
- if (C.label === null)
1774
- throw new Error(`Expected a label for field ${C.identifier}`);
1775
- const E = Ye(C.label, u), V = C.fields.map((k) => {
1776
- const R = Ye(k.label, u);
1715
+ u
1716
+ ]), w = T(
1717
+ (E) => {
1718
+ if (E.label === null)
1719
+ throw new Error(`Expected a label for field ${E.identifier}`);
1720
+ const S = Ue(E.label, d), V = E.fields.map(($) => {
1721
+ const W = Ue($.label, d);
1777
1722
  return {
1778
- ...k,
1779
- label: R,
1780
- identifier: kt(void 0, R)
1723
+ ...$,
1724
+ label: W,
1725
+ identifier: Et(void 0, W)
1781
1726
  };
1782
1727
  });
1783
- return { ...C, label: E, fields: V, identifier: "" };
1728
+ return { ...E, label: S, fields: V, identifier: "" };
1784
1729
  },
1785
- [u]
1786
- ), v = I(
1730
+ [d]
1731
+ ), x = F(
1787
1732
  () => ({
1788
1733
  index: t,
1789
1734
  parentPath: "fields",
1790
1735
  initial: e,
1791
1736
  editing: !0,
1792
- conditionalSourceFields: Ee(d.fields, t)
1737
+ conditionalSourceFields: Ce(l.fields, t)
1793
1738
  }),
1794
- [e, t, d.fields]
1795
- ), x = I(
1739
+ [e, t, l.fields]
1740
+ ), I = F(
1796
1741
  () => ({
1797
1742
  index: t + 1,
1798
1743
  parentPath: "fields",
1799
- initial: Le(),
1800
- conditionalSourceFields: Ee(d.fields, t + 1)
1744
+ initial: Se(),
1745
+ conditionalSourceFields: Ce(l.fields, t + 1)
1801
1746
  }),
1802
- [t, d.fields]
1803
- ), P = I(
1747
+ [t, l.fields]
1748
+ ), v = F(
1804
1749
  () => ({
1805
1750
  parentPath: `fields.${t}.fields`,
1806
1751
  index: e.fields.length,
1807
1752
  initial: void 0
1808
1753
  }),
1809
1754
  [e.fields.length, t]
1810
- ), _ = I(
1755
+ ), k = F(
1811
1756
  () => ({
1812
1757
  index: t + 1,
1813
1758
  parentPath: "fields",
1814
- initial: S(e),
1815
- conditionalSourceFields: Ee(d.fields, t + 1)
1759
+ initial: w(e),
1760
+ conditionalSourceFields: Ce(l.fields, t + 1)
1816
1761
  }),
1817
- [S, e, t, d.fields]
1818
- ), w = I(
1762
+ [w, e, t, l.fields]
1763
+ ), L = F(
1819
1764
  () => {
1820
- var C, E;
1821
- return (E = Vt(d.fields, (C = e.condition) == null ? void 0 : C.identifier)) == null ? void 0 : E.label;
1765
+ var E, S;
1766
+ return (S = At(l.fields, (E = e.condition) == null ? void 0 : E.identifier)) == null ? void 0 : S.label;
1822
1767
  },
1823
- [(A = e.condition) == null ? void 0 : A.identifier, d.fields]
1824
- ), L = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? "contains all of" : "equals";
1825
- if (Xe((Y = e.condition) == null ? void 0 : Y.value))
1768
+ [(_ = e.condition) == null ? void 0 : _.identifier, l.fields]
1769
+ ), C = Array.isArray((M = e.condition) == null ? void 0 : M.value) ? "contains all of" : "equals";
1770
+ if (Ke((B = e.condition) == null ? void 0 : B.value))
1826
1771
  throw new Error("File values are not supported for conditions.");
1827
- const $ = Array.isArray((Ce = e.condition) == null ? void 0 : Ce.value) ? (Fe = e.condition) == null ? void 0 : Fe.value.map((C) => typeof C == "string" ? C : C.label).join(", ") : (Te = e.condition) == null ? void 0 : Te.value.toString();
1828
- console.log(e), console.log(a.current, (ut = a.current) == null ? void 0 : ut.getBoundingClientRect());
1829
- const H = T((C) => {
1830
- if (console.log("in callback", C), C) {
1831
- const { top: E, bottom: V, left: k } = C.getBoundingClientRect();
1832
- return { x: k, y: (V - E) / 2 };
1833
- }
1834
- }, []), U = T(
1835
- (C) => {
1836
- const V = r().get(C);
1837
- return H(V);
1838
- },
1839
- [r, H]
1840
- );
1841
- return /* @__PURE__ */ o(rt, { draggableId: e.identifier, index: t, children: (C) => /* @__PURE__ */ b(
1772
+ const P = Array.isArray((A = e.condition) == null ? void 0 : A.value) ? (q = e.condition) == null ? void 0 : q.value.map((E) => typeof E == "string" ? E : E.label).join(", ") : (Y = e.condition) == null ? void 0 : Y.value.toString();
1773
+ return console.log("field", e), /* @__PURE__ */ r(tt, { draggableId: e.identifier, index: t, children: (E) => /* @__PURE__ */ r(
1842
1774
  xe,
1843
1775
  {
1844
- ref: C.innerRef,
1845
- ...C.draggableProps,
1846
- ...C.dragHandleProps,
1776
+ ref: E.innerRef,
1777
+ ...E.draggableProps,
1778
+ ...E.dragHandleProps,
1847
1779
  mb: "4",
1848
- children: [
1849
- e.condition && /* @__PURE__ */ o(
1850
- yn,
1851
- {
1852
- start: H(a.current),
1853
- end: U(e.condition.identifier)
1854
- }
1855
- ),
1856
- /* @__PURE__ */ b(y, { ref: a, gap: "3", justify: "between", align: "center", children: [
1857
- /* @__PURE__ */ b(y, { direction: "column", gap: "2", grow: "1", children: [
1858
- /* @__PURE__ */ b(y, { direction: "column", children: [
1859
- /* @__PURE__ */ o(Re, { as: "h3", size: "3", children: e.label }),
1860
- /* @__PURE__ */ o(D, { className: Ie.description, children: e.description })
1780
+ children: /* @__PURE__ */ b(
1781
+ y,
1782
+ {
1783
+ ref: (S) => {
1784
+ const V = o();
1785
+ S ? V.set(e.identifier, S) : V.delete(e.identifier);
1786
+ },
1787
+ gap: "3",
1788
+ justify: "between",
1789
+ align: "center",
1790
+ children: [
1791
+ /* @__PURE__ */ b(y, { direction: "column", gap: "2", grow: "1", children: [
1792
+ /* @__PURE__ */ b(y, { direction: "column", children: [
1793
+ /* @__PURE__ */ r($e, { as: "h3", size: "3", children: e.label }),
1794
+ /* @__PURE__ */ r(D, { className: Me.description, children: e.description })
1795
+ ] }),
1796
+ e.condition && /* @__PURE__ */ r(D, { size: "1", children: /* @__PURE__ */ b(bi, { children: [
1797
+ "Display only if ",
1798
+ /* @__PURE__ */ r(ct, { children: L }),
1799
+ " ",
1800
+ C,
1801
+ " ",
1802
+ /* @__PURE__ */ r(ct, { children: P })
1803
+ ] }) }),
1804
+ /* @__PURE__ */ r(et, { droppableId: e.identifier, type: "SECTION", isDropDisabled: a, children: (S) => /* @__PURE__ */ b(
1805
+ y,
1806
+ {
1807
+ ref: S.innerRef,
1808
+ ...S.droppableProps,
1809
+ direction: "column",
1810
+ gap: "0",
1811
+ children: [
1812
+ e.fields.map((V, $) => /* @__PURE__ */ r(
1813
+ fn,
1814
+ {
1815
+ field: V,
1816
+ index: $,
1817
+ sectionIndex: t,
1818
+ remove: () => g($),
1819
+ takenLabels: d,
1820
+ getFieldNodeMap: o
1821
+ },
1822
+ V.identifier
1823
+ )),
1824
+ S.placeholder,
1825
+ /* @__PURE__ */ r(ge, { ...v, children: /* @__PURE__ */ b(K, { type: "button", variant: "outline", children: [
1826
+ /* @__PURE__ */ r(De, {}),
1827
+ " Add a field"
1828
+ ] }) })
1829
+ ]
1830
+ }
1831
+ ) })
1861
1832
  ] }),
1862
- e.condition && /* @__PURE__ */ o(D, { size: "1", children: /* @__PURE__ */ b(vi, { children: [
1863
- "Display only if ",
1864
- /* @__PURE__ */ o(mt, { children: w }),
1865
- " ",
1866
- L,
1867
- " ",
1868
- /* @__PURE__ */ o(mt, { children: $ })
1869
- ] }) }),
1870
- /* @__PURE__ */ o(nt, { droppableId: e.identifier, type: "SECTION", isDropDisabled: c, children: (E) => /* @__PURE__ */ b(
1871
- y,
1833
+ /* @__PURE__ */ r(
1834
+ Rt,
1872
1835
  {
1873
- ref: E.innerRef,
1874
- ...E.droppableProps,
1875
- direction: "column",
1876
- gap: "0",
1877
- children: [
1878
- e.fields.map((V, k) => /* @__PURE__ */ o(
1879
- bn,
1880
- {
1881
- field: V,
1882
- index: k,
1883
- sectionIndex: t,
1884
- remove: () => g(k),
1885
- takenLabels: u,
1886
- getFieldNodeMap: r
1887
- },
1888
- V.identifier
1889
- )),
1890
- E.placeholder,
1891
- /* @__PURE__ */ o(he, { ...P, children: /* @__PURE__ */ b(K, { type: "button", variant: "outline", children: [
1892
- /* @__PURE__ */ o(Oe, {}),
1893
- " Add a field"
1894
- ] }) })
1895
- ]
1836
+ remove: m,
1837
+ insertAfterProps: I,
1838
+ dragHandleProps: E.dragHandleProps,
1839
+ editProps: x,
1840
+ duplicateProps: k
1896
1841
  }
1897
- ) })
1898
- ] }),
1899
- /* @__PURE__ */ o(
1900
- jt,
1901
- {
1902
- remove: F,
1903
- insertAfterProps: x,
1904
- dragHandleProps: C.dragHandleProps,
1905
- editProps: v,
1906
- duplicateProps: _
1907
- }
1908
- )
1909
- ] })
1910
- ]
1842
+ )
1843
+ ]
1844
+ }
1845
+ )
1911
1846
  }
1912
1847
  ) });
1913
- }), wn = (s, i) => {
1848
+ }), pn = (s, i) => {
1914
1849
  var t;
1915
1850
  const e = { ...s };
1916
1851
  switch (i.type) {
@@ -1925,7 +1860,7 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1925
1860
  case "update":
1926
1861
  return i.state;
1927
1862
  }
1928
- }, vn = (s, i) => {
1863
+ }, hn = (s, i) => {
1929
1864
  if (i)
1930
1865
  for (let e = 0; e < s.length; e++) {
1931
1866
  const t = s[e];
@@ -1935,208 +1870,260 @@ const $e = (s, i) => I(() => !i || !s ? null : s.getInput(i), [s, i]), Rt = (s,
1935
1870
  return e;
1936
1871
  }
1937
1872
  }
1938
- }, yt = (s) => {
1873
+ }, pt = (s) => {
1939
1874
  var e, t, n;
1940
1875
  const i = {};
1941
- for (let r = 0; r < s.length; r++) {
1942
- const a = s[r];
1876
+ for (let o = 0; o < s.length; o++) {
1877
+ const a = s[o];
1943
1878
  if (!a)
1944
1879
  throw new Error("Field is undefined.");
1945
- const c = r > 0 ? (e = i[s[r - 1].identifier]) == null ? void 0 : e.conditionFields : void 0, l = new Set(c);
1880
+ const c = o > 0 ? (e = i[s[o - 1].identifier]) == null ? void 0 : e.conditionFields : void 0, l = new Set(c);
1946
1881
  (t = a.condition) != null && t.identifier && l.add(a.condition.identifier), i[a.identifier] = {
1947
1882
  disabled: !1,
1948
1883
  conditionFields: l,
1949
- conditionIndex: vn(s, (n = a.condition) == null ? void 0 : n.identifier),
1950
- index: r,
1884
+ conditionIndex: hn(s, (n = a.condition) == null ? void 0 : n.identifier),
1885
+ index: o,
1951
1886
  label: a.label
1952
1887
  };
1953
1888
  }
1954
1889
  return i;
1955
- }, xt = (s, i) => {
1890
+ }, gn = z(function(i) {
1891
+ const { start: e, end: t } = i, n = 20;
1892
+ return /* @__PURE__ */ b(Xe, { children: [
1893
+ /* @__PURE__ */ r("line", { stroke: "black", strokeWidth: 2, x1: e.x - n, y1: t.y, x2: t.x, y2: t.y }),
1894
+ /* @__PURE__ */ r(
1895
+ "line",
1896
+ {
1897
+ stroke: "black",
1898
+ strokeWidth: 2,
1899
+ x1: e.x - n,
1900
+ y1: e.y,
1901
+ x2: e.x - n,
1902
+ y2: t.y
1903
+ }
1904
+ ),
1905
+ /* @__PURE__ */ r(
1906
+ "line",
1907
+ {
1908
+ stroke: "black",
1909
+ strokeWidth: 2,
1910
+ x1: e.x,
1911
+ y1: e.y,
1912
+ x2: t.x - n,
1913
+ y2: e.y
1914
+ }
1915
+ )
1916
+ ] });
1917
+ }), ht = (s, i) => {
1956
1918
  for (const [e, t] of Object.entries(s))
1957
1919
  if (t.identifier === i)
1958
1920
  return [t, e];
1959
- }, In = z(function() {
1960
- const { values: i, setFieldValue: e } = pe(), t = it(null), [n, r] = Fi(wn, i.fields, yt), { showInfo: a } = Ii();
1961
- we(() => {
1962
- r({ type: "update", state: yt(i.fields) });
1963
- }, [r, i.fields]);
1964
- const c = T((u) => {
1965
- u.type === "SECTION" && r({ type: "hold", fieldId: u.draggableId });
1966
- }, []), l = T(
1967
- (u) => {
1968
- const { source: p, destination: h, type: g, reason: F, draggableId: S } = u;
1969
- if (r({ type: "release" }), !h || F === "CANCEL")
1921
+ }, bn = z(function() {
1922
+ const { values: i, setFieldValue: e } = he(), t = wt(null), [n, o] = X([]), [a, c] = xi(pn, i.fields, pt), { showInfo: l } = yi();
1923
+ ue(() => {
1924
+ c({ type: "update", state: pt(i.fields) });
1925
+ }, [c, i.fields]);
1926
+ const f = T((m) => {
1927
+ m.type === "SECTION" && c({ type: "hold", fieldId: m.draggableId });
1928
+ }, []), d = T(
1929
+ (m) => {
1930
+ const { source: w, destination: x, type: I, reason: v, draggableId: k } = m;
1931
+ if (c({ type: "release" }), !x || v === "CANCEL")
1970
1932
  return;
1971
- if (g === "ROOT") {
1972
- const w = n[S];
1973
- if (!w)
1933
+ if (I === "ROOT") {
1934
+ const _ = a[k];
1935
+ if (!_)
1974
1936
  throw new Error("Could not find section context.");
1975
- let L = typeof w.conditionIndex < "u" ? (
1937
+ let M = typeof _.conditionIndex < "u" ? (
1976
1938
  // cannot move a section with a condition before the condition's field
1977
- Math.max(w.conditionIndex + 1, h.index)
1978
- ) : h.index;
1979
- for (const $ of Object.values(n))
1980
- $.conditionIndex === p.index && (L = Math.min(L, $.index - 1));
1981
- return L != h.index && a({
1939
+ Math.max(_.conditionIndex + 1, x.index)
1940
+ ) : x.index;
1941
+ for (const B of Object.values(a))
1942
+ B.conditionIndex === w.index && (M = Math.min(M, B.index - 1));
1943
+ return M != x.index && l({
1982
1944
  title: "Reordered sections",
1983
1945
  description: "Sections with conditions must be below the fields they reference."
1984
- }), e("fields", Ke(i.fields, p.index, L));
1946
+ }), e("fields", He(i.fields, w.index, M));
1985
1947
  }
1986
- if (g !== "SECTION")
1948
+ if (I !== "SECTION")
1987
1949
  throw new Error("Unexpected droppable type.");
1988
- const [v, x] = xt(i.fields, p.droppableId) ?? [], [P, _] = xt(i.fields, h.droppableId) ?? [];
1989
- if (!(v != null && v.fields) || !P)
1950
+ const [L, C] = ht(i.fields, w.droppableId) ?? [], [P, O] = ht(i.fields, x.droppableId) ?? [];
1951
+ if (!(L != null && L.fields) || !P)
1990
1952
  throw new Error("Could not find section with fields.");
1991
- if (v.identifier === P.identifier)
1953
+ if (L.identifier === P.identifier)
1992
1954
  e(
1993
- `fields.${x}.fields`,
1994
- Ke(v.fields, p.index, h.index)
1955
+ `fields.${C}.fields`,
1956
+ He(L.fields, w.index, x.index)
1995
1957
  ).then();
1996
1958
  else {
1997
- const w = v.fields[p.index];
1998
- if (!w)
1959
+ const _ = L.fields[w.index];
1960
+ if (!_)
1999
1961
  throw new Error("Could not find field to reorder.");
2000
- e(`fields.${x}.fields`, Pe(v.fields, p.index)).then(), e(
2001
- `fields.${_}.fields`,
2002
- Pt(P.fields, h.index, w)
1962
+ e(`fields.${C}.fields`, ze(L.fields, w.index)).then(), e(
1963
+ `fields.${O}.fields`,
1964
+ zt(P.fields, x.index, _)
2003
1965
  ).then();
2004
1966
  }
2005
1967
  },
2006
- [i.fields, e, n, a]
2007
- ), d = I(
1968
+ [i.fields, e, a, l]
1969
+ ), u = F(
2008
1970
  () => ({
2009
1971
  index: i.fields.length,
2010
1972
  parentPath: "fields",
2011
- initial: Le(),
2012
- conditionalSourceFields: Ee(i.fields, i.fields.length)
1973
+ initial: Se(),
1974
+ conditionalSourceFields: Ce(i.fields, i.fields.length)
2013
1975
  }),
2014
1976
  [i.fields]
2015
- ), f = () => (t.current === null && (t.current = /* @__PURE__ */ new Map()), t.current);
2016
- return /* @__PURE__ */ o(Ft, { onDragStart: c, onDragEnd: l, children: /* @__PURE__ */ o(nt, { droppableId: "droppable", type: "ROOT", children: (u) => /* @__PURE__ */ b(
2017
- y,
2018
- {
2019
- ref: u.innerRef,
2020
- ...u.droppableProps,
2021
- className: Ie.fieldsContainer,
2022
- direction: "column",
2023
- gap: "0",
2024
- children: [
2025
- i.fields.map((p, h) => /* @__PURE__ */ o(
2026
- xn,
1977
+ ), h = T(() => (t.current === null && (t.current = /* @__PURE__ */ new Map()), t.current), []), g = T((m) => {
1978
+ console.log("in callback", m, m.getBoundingClientRect());
1979
+ const { top: w, bottom: x, left: I } = m.getBoundingClientRect();
1980
+ return { x: I + window.scrollX, y: (x - w) / 2 + window.scrollY };
1981
+ }, []);
1982
+ return ue(() => {
1983
+ const m = () => {
1984
+ console.log("generatearrows ran", i.fields);
1985
+ const w = i.fields.filter((I) => I.conditional), x = h();
1986
+ return w.map((I) => {
1987
+ var L;
1988
+ const v = x.get(I.identifier), k = ((L = I.condition) == null ? void 0 : L.identifier) && x.get(I.condition.identifier);
1989
+ return !v || !k ? null : /* @__PURE__ */ r(
1990
+ gn,
2027
1991
  {
2028
- field: p,
2029
- index: h,
2030
- dropState: n,
2031
- getFieldNodeMap: f
1992
+ start: g(v),
1993
+ end: g(k)
2032
1994
  },
2033
- p.label
2034
- )),
2035
- u.placeholder,
2036
- /* @__PURE__ */ o(he, { ...d, children: /* @__PURE__ */ b(K, { type: "button", variant: "outline", children: [
2037
- /* @__PURE__ */ o(Oe, {}),
2038
- " Add a section"
2039
- ] }) })
2040
- ]
2041
- }
2042
- ) }) });
2043
- }), Cn = {
1995
+ I.identifier
1996
+ );
1997
+ });
1998
+ };
1999
+ console.log("useeffect ran"), o(m());
2000
+ }, [h, g, i.fields]), /* @__PURE__ */ r(xt, { onDragStart: f, onDragEnd: d, children: /* @__PURE__ */ r(et, { droppableId: "droppable", type: "ROOT", children: (m) => /* @__PURE__ */ b(y, { direction: "row", children: [
2001
+ /* @__PURE__ */ r("svg", { width: "10%", height: "100%", children: n }),
2002
+ /* @__PURE__ */ b(
2003
+ y,
2004
+ {
2005
+ ref: m.innerRef,
2006
+ ...m.droppableProps,
2007
+ direction: "column",
2008
+ gap: "0",
2009
+ grow: "1",
2010
+ children: [
2011
+ i.fields.map((w, x) => /* @__PURE__ */ r(
2012
+ mn,
2013
+ {
2014
+ field: w,
2015
+ index: x,
2016
+ dropState: a,
2017
+ getFieldNodeMap: h
2018
+ },
2019
+ w.label
2020
+ )),
2021
+ m.placeholder,
2022
+ /* @__PURE__ */ r(ge, { ...u, children: /* @__PURE__ */ b(K, { type: "button", variant: "outline", children: [
2023
+ /* @__PURE__ */ r(De, {}),
2024
+ " Add a section"
2025
+ ] }) })
2026
+ ]
2027
+ }
2028
+ )
2029
+ ] }) }) });
2030
+ }), yn = {
2044
2031
  title: "",
2045
2032
  description: "",
2046
2033
  fields: []
2047
- }, Fn = new be({
2034
+ }, wn = new ye({
2048
2035
  label: "Title",
2049
2036
  minLength: 0,
2050
2037
  maxLength: 100,
2051
2038
  required: !0,
2052
2039
  identifier: "title"
2053
- }), Tn = { formId: qe, placeholder: "Give your form a title." }, Sn = new ye({
2040
+ }), xn = { formId: Ne, placeholder: "Give your form a title." }, vn = new we({
2054
2041
  label: "Description",
2055
2042
  minLength: 0,
2056
2043
  maxLength: 1e3,
2057
2044
  required: !1,
2058
2045
  identifier: "description"
2059
- }), zn = { formId: qe, placeholder: "Explain the purpose of this form." }, En = () => {
2046
+ }), In = { formId: Ne, placeholder: "Explain the purpose of this form." }, Fn = () => {
2060
2047
  alert("This is a form preview, your data will not be saved.");
2061
- }, Wn = z(
2048
+ }, On = z(
2062
2049
  ve((s, i) => {
2063
- const { onCancel: e, onSave: t, revision: n } = s, r = n ? "Edit form" : "Create a new form", { heading: a = r } = s, c = T((h) => {
2064
- const g = {};
2065
- if (h.title || (g.title = "Title is required."), (!h.fields || h.fields.length === 0) && (g.fields = "At least one field is required."), Me(g))
2066
- return g;
2067
- }, []), l = et({
2068
- initialValues: ji(n) ?? Cn,
2050
+ const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = T((g) => {
2051
+ const m = {};
2052
+ if (g.title || (m.title = "Title is required."), (!g.fields || g.fields.length === 0) && (m.fields = "At least one field is required."), Ve(m))
2053
+ return m;
2054
+ }, []), l = Je({
2055
+ initialValues: Ni(n) ?? yn,
2069
2056
  validate: c,
2070
- onSubmit: (h) => t(h),
2057
+ onSubmit: (g) => t(g),
2071
2058
  // only validate the entire for on submit
2072
2059
  validateOnChange: !1,
2073
2060
  validateOnBlur: !1
2074
- }), d = I(() => Mt(l.values), [l.values]), f = $e(Fn, Tn), u = $e(Sn, zn), p = I(
2075
- () => typeof a == "object" ? a : /* @__PURE__ */ o(Re, { children: a }),
2061
+ }), f = F(() => Vt(l.values), [l.values]), d = ke(wn, xn), u = ke(vn, In), h = F(
2062
+ () => typeof a == "object" ? a : /* @__PURE__ */ r($e, { children: a }),
2076
2063
  [a]
2077
2064
  );
2078
- return /* @__PURE__ */ o(J.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
2079
- /* @__PURE__ */ b(J.List, { children: [
2080
- /* @__PURE__ */ o(J.Trigger, { value: "edit", children: "Edit" }),
2081
- /* @__PURE__ */ o(J.Trigger, { value: "preview", children: "Preview" })
2065
+ return /* @__PURE__ */ r(Z.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
2066
+ /* @__PURE__ */ b(Z.List, { children: [
2067
+ /* @__PURE__ */ r(Z.Trigger, { value: "edit", children: "Edit" }),
2068
+ /* @__PURE__ */ r(Z.Trigger, { value: "preview", children: "Preview" })
2082
2069
  ] }),
2083
- /* @__PURE__ */ b(J.Content, { value: "edit", children: [
2084
- p,
2070
+ /* @__PURE__ */ b(Z.Content, { value: "edit", children: [
2071
+ h,
2085
2072
  /* @__PURE__ */ b(D, { children: [
2086
2073
  "Add a new form field by clicking a + button. Specify options for each field, then drag and drop to rearrange them. You can see what a submitted form might look like in the",
2087
2074
  " ",
2088
- /* @__PURE__ */ o("em", { children: "Preview" }),
2075
+ /* @__PURE__ */ r("em", { children: "Preview" }),
2089
2076
  " tab, but",
2090
2077
  " ",
2091
- /* @__PURE__ */ o("strong", { children: "field values entered on this page will not be saved." })
2078
+ /* @__PURE__ */ r("strong", { children: "field values entered on this page will not be saved." })
2092
2079
  ] }),
2093
- /* @__PURE__ */ o(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ b("form", { id: qe, onSubmit: l.handleSubmit, children: [
2094
- /* @__PURE__ */ b(tt, { value: l, children: [
2095
- f,
2080
+ /* @__PURE__ */ r(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ b("form", { id: Ne, onSubmit: l.handleSubmit, children: [
2081
+ /* @__PURE__ */ b(Ze, { value: l, children: [
2082
+ d,
2096
2083
  u,
2097
- /* @__PURE__ */ o(In, {}),
2098
- /* @__PURE__ */ o(D, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
2084
+ /* @__PURE__ */ r(bn, {}),
2085
+ /* @__PURE__ */ r(D, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
2099
2086
  ] }),
2100
2087
  /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
2101
- /* @__PURE__ */ o(K, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
2102
- /* @__PURE__ */ o(K, { type: "submit", disabled: !l.isValid, children: "Save" })
2088
+ /* @__PURE__ */ r(K, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
2089
+ /* @__PURE__ */ r(K, { type: "submit", disabled: !l.isValid, children: "Save" })
2103
2090
  ] })
2104
2091
  ] }) })
2105
2092
  ] }),
2106
- /* @__PURE__ */ o(J.Content, { value: "preview", children: /* @__PURE__ */ o(dt, { schema: d, onSubmit: En }) })
2093
+ /* @__PURE__ */ r(Z.Content, { value: "preview", children: /* @__PURE__ */ r(lt, { schema: f, onSubmit: Fn }) })
2107
2094
  ] }) });
2108
2095
  })
2109
2096
  );
2110
2097
  export {
2111
- fe as BooleanField,
2112
- Oi as BooleanInput,
2113
- Ge as DateField,
2114
- Ni as DateInput,
2115
- X as FieldSection,
2116
- Rn as FormBrowser,
2117
- Wn as FormBuilder,
2118
- dt as FormRenderer,
2119
- Nn as FormSubmissionBrowser,
2120
- On as FormSubmissionViewer,
2121
- De as MultiSelectField,
2122
- Ki as MultiSelectInput,
2123
- ke as MultiStringField,
2124
- Ui as MultiStringInput,
2098
+ me as BooleanField,
2099
+ Vi as BooleanInput,
2100
+ je as DateField,
2101
+ $i as DateInput,
2102
+ J as FieldSection,
2103
+ Dn as FormBrowser,
2104
+ On as FormBuilder,
2105
+ lt as FormRenderer,
2106
+ $n as FormSubmissionBrowser,
2107
+ Vn as FormSubmissionViewer,
2108
+ Le as MultiSelectField,
2109
+ Wi as MultiSelectInput,
2110
+ Ee as MultiStringField,
2111
+ Bi as MultiStringInput,
2125
2112
  Q as NumberField,
2126
- Ri as NumberInput,
2127
- Bn as PatchField,
2128
- qn as PatchFormProvider,
2129
- Ve as SelectField,
2130
- Wi as SelectInput,
2131
- be as StringField,
2132
- Bi as StringInput,
2133
- ye as TextField,
2134
- qi as TextInput,
2135
- Be as deserialize,
2136
- $t as deserializeField,
2137
- Mt as formRevisionToSchema,
2138
- Ot as isConditionMet,
2139
- $e as useFieldInput,
2140
- Rt as useFieldInputs,
2141
- Xe as valueIsFile
2113
+ Di as NumberInput,
2114
+ _n as PatchField,
2115
+ Mn as PatchFormProvider,
2116
+ Ae as SelectField,
2117
+ Oi as SelectInput,
2118
+ ye as StringField,
2119
+ _i as StringInput,
2120
+ we as TextField,
2121
+ Mi as TextInput,
2122
+ Oe as deserialize,
2123
+ kt as deserializeField,
2124
+ Vt as formRevisionToSchema,
2125
+ Dt as isConditionMet,
2126
+ ke as useFieldInput,
2127
+ $t as useFieldInputs,
2128
+ Ke as valueIsFile
2142
2129
  };