@overmap-ai/forms 1.0.17-blur-updates.0 → 1.0.17-blur-updates.1

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
@@ -2,7 +2,7 @@ var or = Object.defineProperty;
2
2
  var ar = (t, n, e) => n in t ? or(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
3
  var I = (t, n, e) => ar(t, typeof n != "symbol" ? n + "" : n, e);
4
4
  import { jsxs as x, jsx as s, Fragment as ye } from "react/jsx-runtime";
5
- import { Popover as se, IconButton as $, RiIcon as F, Text as pe, Spinner as yt, ButtonGroup as bt, Tooltip as Re, Separator as Ht, Checkbox as at, Button as K, DayPicker as sr, useToast as wt, Input as he, Badge as Ot, Card as qe, Menu as z, TextArea as jn, Heading as Wn, HoverCard as It, useAlertDialog as lr, Tabs as Ne, useSize as cr, IconToggleButton as dr } from "@overmap-ai/blocks";
5
+ import { Popover as se, IconButton as $, RiIcon as F, Text as pe, Spinner as yt, ButtonGroup as bt, Tooltip as Re, Separator as Ht, Checkbox as at, Button as K, DayPicker as sr, useToast as wt, Input as he, Badge as Ot, Card as qe, Menu as _, TextArea as jn, Heading as Wn, HoverCard as It, useAlertDialog as lr, Tabs as Ne, useSize as cr, IconToggleButton as dr } from "@overmap-ai/blocks";
6
6
  import * as p from "react";
7
7
  import { memo as O, useCallback as N, useMemo as P, forwardRef as Ge, createContext as ur, useContext as fr, useState as V, useRef as fe, useEffect as X, Fragment as qn, useLayoutEffect as Gt, useReducer as mr } from "react";
8
8
  import { useField as Xt, useFormikContext as Ee, useFormik as Kt, FormikProvider as Qt } from "formik";
@@ -465,11 +465,11 @@ var eo = "DismissableLayer", kt = "dismissableLayer.update", to = "dismissableLa
465
465
  onDismiss: l,
466
466
  ...m
467
467
  } = t, c = p.useContext(ti), [d, u] = p.useState(null), h = (d == null ? void 0 : d.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, y] = p.useState({}), b = Ie(n, (R) => u(R)), f = Array.from(c.layers), [g] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), C = f.indexOf(g), w = d ? f.indexOf(d) : -1, v = c.layersWithOutsidePointerEventsDisabled.size > 0, E = w >= C, S = oo((R) => {
468
- const T = R.target, A = [...c.branches].some((B) => B.contains(T));
469
- !E || A || (r == null || r(R), a == null || a(R), R.defaultPrevented || l == null || l());
468
+ const T = R.target, D = [...c.branches].some((M) => M.contains(T));
469
+ !E || D || (r == null || r(R), a == null || a(R), R.defaultPrevented || l == null || l());
470
470
  }, h), L = ao((R) => {
471
471
  const T = R.target;
472
- [...c.branches].some((B) => B.contains(T)) || (o == null || o(R), a == null || a(R), R.defaultPrevented || l == null || l());
472
+ [...c.branches].some((M) => M.contains(T)) || (o == null || o(R), a == null || a(R), R.defaultPrevented || l == null || l());
473
473
  }, h);
474
474
  return Zr((R) => {
475
475
  w === c.layers.size - 1 && (i == null || i(R), !R.defaultPrevented && l && (R.preventDefault(), l()));
@@ -1187,8 +1187,8 @@ function Zo(t) {
1187
1187
  return !1;
1188
1188
  if (!i.current && "changedTouches" in f && (v || E) && (i.current = S), !S)
1189
1189
  return !0;
1190
- var A = i.current || S;
1191
- return Ko(A, g, f, A === "h" ? v : E);
1190
+ var D = i.current || S;
1191
+ return Ko(D, g, f, D === "h" ? v : E);
1192
1192
  }, []), m = p.useCallback(function(f) {
1193
1193
  var g = f;
1194
1194
  if (!(!Le.length || Le[Le.length - 1] !== o)) {
@@ -1995,12 +1995,12 @@ const mn = (t, n) => {
1995
1995
  b(k), f(k);
1996
1996
  },
1997
1997
  [b, f]
1998
- ), A = N(
1998
+ ), D = N(
1999
1999
  (k) => {
2000
2000
  g.findIndex((W) => W === k.target.value.trim()) >= 0 ? L("All options must be unique") : k.target.value ? L("") : L("Option cannot be empty"), E(k.target.value);
2001
2001
  },
2002
2002
  [E, g]
2003
- ), B = N(() => {
2003
+ ), M = N(() => {
2004
2004
  if (S) return;
2005
2005
  if (!v.trim()) {
2006
2006
  L("Option cannot be empty");
@@ -2010,15 +2010,15 @@ const mn = (t, n) => {
2010
2010
  T([...g, k]), E("");
2011
2011
  }, [v, S, T, g]), G = N(
2012
2012
  (k) => {
2013
- k.key === "Enter" && (k.preventDefault(), B());
2013
+ k.key === "Enter" && (k.preventDefault(), M());
2014
2014
  },
2015
- [B]
2015
+ [M]
2016
2016
  ), te = N(
2017
2017
  (k) => {
2018
2018
  T(ft(g, k));
2019
2019
  },
2020
2020
  [g, T]
2021
- ), _ = N(
2021
+ ), B = N(
2022
2022
  (k) => {
2023
2023
  if (!k.destination) return;
2024
2024
  const W = k.source.index, ce = k.destination.index;
@@ -2028,7 +2028,7 @@ const mn = (t, n) => {
2028
2028
  ), Q = N(() => {
2029
2029
  f(g);
2030
2030
  }, [f, g]);
2031
- return /* @__PURE__ */ s(Hn, { onDragEnd: _, children: /* @__PURE__ */ x("div", { className: "flex flex-col gap-2", children: [
2031
+ return /* @__PURE__ */ s(Hn, { onDragEnd: B, children: /* @__PURE__ */ x("div", { className: "flex flex-col gap-2", children: [
2032
2032
  /* @__PURE__ */ s(ae, { helpText: R, severity: r, children: /* @__PURE__ */ s(
2033
2033
  oe,
2034
2034
  {
@@ -2043,7 +2043,7 @@ const mn = (t, n) => {
2043
2043
  he.Field,
2044
2044
  {
2045
2045
  value: v,
2046
- onChange: A,
2046
+ onChange: D,
2047
2047
  onKeyDown: G,
2048
2048
  id: n,
2049
2049
  placeholder: a.placeholder,
@@ -2061,7 +2061,7 @@ const mn = (t, n) => {
2061
2061
  type: "button",
2062
2062
  "aria-label": "Add option",
2063
2063
  disabled: !!S || w,
2064
- onClick: B,
2064
+ onClick: M,
2065
2065
  children: /* @__PURE__ */ s(F, { icon: "RiAddLine" })
2066
2066
  }
2067
2067
  )
@@ -2184,8 +2184,8 @@ const Vi = O((t) => {
2184
2184
  }, [g]);
2185
2185
  const S = N(
2186
2186
  (R) => {
2187
- const T = Number.parseFloat(R.target.value), A = Number.isNaN(T) ? "" : T;
2188
- E(A), (d || !a.onlyValidateAfterTouched) && u.setError(a.getError(A));
2187
+ const T = Number.parseFloat(R.target.value), D = Number.isNaN(T) ? "" : T;
2188
+ E(D), (d || !a.onlyValidateAfterTouched) && u.setError(a.getError(D));
2189
2189
  },
2190
2190
  [a, u, d]
2191
2191
  ), L = N(() => {
@@ -2496,8 +2496,8 @@ const Fa = (t) => t ? Array.isArray(t) ? t : [t] : [], qi = O((t) => {
2496
2496
  labelId: e,
2497
2497
  label: f,
2498
2498
  image: o ? void 0 : a.image,
2499
- children: /* @__PURE__ */ x(z.Root, { onOpenChange: w, align: "start", children: [
2500
- /* @__PURE__ */ s(z.ClickTrigger, { children: /* @__PURE__ */ x(
2499
+ children: /* @__PURE__ */ x(_.Root, { onOpenChange: w, align: "start", children: [
2500
+ /* @__PURE__ */ s(_.ClickTrigger, { children: /* @__PURE__ */ x(
2501
2501
  K,
2502
2502
  {
2503
2503
  id: n,
@@ -2514,13 +2514,13 @@ const Fa = (t) => t ? Array.isArray(t) ? t : [t] : [], qi = O((t) => {
2514
2514
  ]
2515
2515
  }
2516
2516
  ) }),
2517
- /* @__PURE__ */ s(z.Content, { children: /* @__PURE__ */ s(z.Scroll, { children: /* @__PURE__ */ x(z.MultiSelectGroup, { values: g, onValuesChange: C, children: [
2518
- /* @__PURE__ */ x(z.SelectAllItem, { children: [
2519
- /* @__PURE__ */ s(z.CheckboxItemIndicator, { children: (v) => v ? /* @__PURE__ */ s(F, { icon: "RiSubtractLine" }) : /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2517
+ /* @__PURE__ */ s(_.Content, { children: /* @__PURE__ */ s(_.Scroll, { children: /* @__PURE__ */ x(_.MultiSelectGroup, { values: g, onValuesChange: C, children: [
2518
+ /* @__PURE__ */ x(_.SelectAllItem, { children: [
2519
+ /* @__PURE__ */ s(_.CheckboxItemIndicator, { children: (v) => v ? /* @__PURE__ */ s(F, { icon: "RiSubtractLine" }) : /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2520
2520
  "Select all"
2521
2521
  ] }),
2522
- a.options.map((v) => /* @__PURE__ */ x(z.MultiSelectItem, { value: v.value, children: [
2523
- /* @__PURE__ */ s(z.SelectedIndicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2522
+ a.options.map((v) => /* @__PURE__ */ x(_.MultiSelectItem, { value: v.value, children: [
2523
+ /* @__PURE__ */ s(_.SelectedIndicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2524
2524
  v.label
2525
2525
  ] }, v.value))
2526
2526
  ] }) }) })
@@ -2574,8 +2574,8 @@ const Hi = O((t) => {
2574
2574
  labelId: e,
2575
2575
  label: g,
2576
2576
  image: o ? void 0 : a.image,
2577
- children: /* @__PURE__ */ x(z.Root, { align: "start", children: [
2578
- /* @__PURE__ */ s(z.ClickTrigger, { children: /* @__PURE__ */ x(
2577
+ children: /* @__PURE__ */ x(_.Root, { align: "start", children: [
2578
+ /* @__PURE__ */ s(_.ClickTrigger, { children: /* @__PURE__ */ x(
2579
2579
  K,
2580
2580
  {
2581
2581
  id: n,
@@ -2592,8 +2592,8 @@ const Hi = O((t) => {
2592
2592
  ]
2593
2593
  }
2594
2594
  ) }),
2595
- /* @__PURE__ */ s(z.Content, { children: /* @__PURE__ */ s(z.Scroll, { children: /* @__PURE__ */ s(z.SelectGroup, { required: !0, value: b, onValueChange: C, children: a.options.map((v) => /* @__PURE__ */ x(z.SelectItem, { value: v.value, children: [
2596
- /* @__PURE__ */ s(z.SelectedIndicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2595
+ /* @__PURE__ */ s(_.Content, { children: /* @__PURE__ */ s(_.Scroll, { children: /* @__PURE__ */ s(_.SelectGroup, { required: !0, value: b, onValueChange: C, children: a.options.map((v) => /* @__PURE__ */ x(_.SelectItem, { value: v.value, children: [
2596
+ /* @__PURE__ */ s(_.SelectedIndicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }),
2597
2597
  v.label
2598
2598
  ] }, v.value)) }) }) })
2599
2599
  ] })
@@ -2922,12 +2922,12 @@ const ka = O(
2922
2922
  y([]);
2923
2923
  return;
2924
2924
  }
2925
- const A = Array.from(T);
2926
- h(A), y(A);
2927
- }, [y, h]), v = N(
2925
+ const D = Array.from(T), M = [...u, ...D];
2926
+ h(M), y(M);
2927
+ }, [y, h, u]), v = N(
2928
2928
  (T) => {
2929
- const A = [...u];
2930
- A.splice(T, 1), h(A);
2929
+ const D = [...u];
2930
+ D.splice(T, 1), h(D);
2931
2931
  },
2932
2932
  [u, h]
2933
2933
  );
@@ -2937,7 +2937,7 @@ const ka = O(
2937
2937
  return f.current.addEventListener(
2938
2938
  "cancel",
2939
2939
  () => {
2940
- y([]), console.debug("UploadInput: onBlur", u);
2940
+ y([]);
2941
2941
  },
2942
2942
  {
2943
2943
  signal: T.signal
@@ -2993,17 +2993,17 @@ const ka = O(
2993
2993
  ]
2994
2994
  }
2995
2995
  ) }),
2996
- Array.isArray(u) && u.length > 0 && /* @__PURE__ */ s("div", { className: "flex h-max flex-col gap-2", children: u.map((T, A) => /* @__PURE__ */ s(
2996
+ Array.isArray(u) && u.length > 0 && /* @__PURE__ */ s("div", { className: "flex h-max flex-col gap-2", children: u.map((T, D) => /* @__PURE__ */ s(
2997
2997
  Qi,
2998
2998
  {
2999
2999
  field: l,
3000
3000
  file: T,
3001
3001
  onRemove: () => {
3002
- v(A);
3002
+ v(D);
3003
3003
  },
3004
3004
  disabled: c.disabled
3005
3005
  },
3006
- A
3006
+ D
3007
3007
  )) })
3008
3008
  ] });
3009
3009
  });
@@ -3448,9 +3448,9 @@ const ve = (t) => Object.keys(t).length > 0, vn = (t, n) => {
3448
3448
  [e.description]
3449
3449
  ), S = N(
3450
3450
  (R, T) => {
3451
- r == null || r({ ...C.values, [R]: T });
3451
+ r == null || r({ [R]: T });
3452
3452
  },
3453
- [C.values, r]
3453
+ [r]
3454
3454
  ), L = dt(e.fields, { formId: g, disabled: f, onValuesChange: S });
3455
3455
  return X(() => {
3456
3456
  w && c && c(), d && d(w);
@@ -3658,8 +3658,8 @@ const ys = O(
3658
3658
  },
3659
3659
  u.key
3660
3660
  )) }),
3661
- /* @__PURE__ */ s("div", { className: "sm:hidden", children: /* @__PURE__ */ x(z.Root, { children: [
3662
- /* @__PURE__ */ s(z.ClickTrigger, { children: /* @__PURE__ */ s(
3661
+ /* @__PURE__ */ s("div", { className: "sm:hidden", children: /* @__PURE__ */ x(_.Root, { children: [
3662
+ /* @__PURE__ */ s(_.ClickTrigger, { children: /* @__PURE__ */ s(
3663
3663
  $,
3664
3664
  {
3665
3665
  variant: "ghost",
@@ -3670,9 +3670,9 @@ const ys = O(
3670
3670
  children: /* @__PURE__ */ s(F, { icon: "RiMore2Line" })
3671
3671
  }
3672
3672
  ) }),
3673
- /* @__PURE__ */ s(z.Content, { children: d.map((u) => {
3673
+ /* @__PURE__ */ s(_.Content, { children: d.map((u) => {
3674
3674
  var h;
3675
- return /* @__PURE__ */ x(z.Item, { onClick: (h = u.buttonProps) == null ? void 0 : h.onClick, children: [
3675
+ return /* @__PURE__ */ x(_.Item, { onClick: (h = u.buttonProps) == null ? void 0 : h.onClick, children: [
3676
3676
  /* @__PURE__ */ s(u.Icon, {}),
3677
3677
  u.text
3678
3678
  ] }, u.key);
@@ -3721,13 +3721,13 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3721
3721
  d.current && d.current.getBoundingClientRect().width >= u
3722
3722
  );
3723
3723
  X(() => {
3724
- const D = d.current;
3725
- if (D) {
3726
- const M = new ResizeObserver((j) => {
3724
+ const A = d.current;
3725
+ if (A) {
3726
+ const z = new ResizeObserver((j) => {
3727
3727
  j[0] && y(j[0].contentRect.width >= u);
3728
3728
  });
3729
- return M.observe(D), () => {
3730
- M.disconnect();
3729
+ return z.observe(A), () => {
3730
+ z.disconnect();
3731
3731
  };
3732
3732
  }
3733
3733
  }, []);
@@ -3736,9 +3736,9 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3736
3736
  ge(i) ? f(void 0) : i.image instanceof Promise ? i.image.then(f).catch(console.error) : f(i.image);
3737
3737
  }, [i]);
3738
3738
  const g = b ? URL.createObjectURL(b) : void 0, C = N(
3739
- (D) => {
3740
- D.stopPropagation();
3741
- const { image: M, ...j } = i;
3739
+ (A) => {
3740
+ A.stopPropagation();
3741
+ const { image: z, ...j } = i;
3742
3742
  a(`${n}.${e}`, j).then();
3743
3743
  },
3744
3744
  [e, i, n, a]
@@ -3748,8 +3748,8 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3748
3748
  }, [e, i, n, a]);
3749
3749
  const w = P(
3750
3750
  () => {
3751
- var D, M;
3752
- return ge(i) ? (M = _i(o.fields, (D = i.condition) == null ? void 0 : D.identifier)) == null ? void 0 : M.label : void 0;
3751
+ var A, z;
3752
+ return ge(i) ? (z = _i(o.fields, (A = i.condition) == null ? void 0 : A.identifier)) == null ? void 0 : z.label : void 0;
3753
3753
  },
3754
3754
  [i, o.fields]
3755
3755
  ), v = ge(i) ? Array.isArray((Se = i.condition) == null ? void 0 : Se.value) ? "contains all of" : "equals" : void 0;
@@ -3757,21 +3757,21 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3757
3757
  if (ge(i)) {
3758
3758
  if (jt((Et = i.condition) == null ? void 0 : Et.value))
3759
3759
  throw new Error("File values are not supported for conditions.");
3760
- E = Array.isArray((xn = i.condition) == null ? void 0 : xn.value) ? i.condition.value.map((D) => typeof D == "string" ? D : D.label).join(", ") : (En = (Cn = i.condition) == null ? void 0 : Cn.value) == null ? void 0 : En.toString();
3760
+ E = Array.isArray((xn = i.condition) == null ? void 0 : xn.value) ? i.condition.value.map((A) => typeof A == "string" ? A : A.label).join(", ") : (En = (Cn = i.condition) == null ? void 0 : Cn.value) == null ? void 0 : En.toString();
3761
3761
  }
3762
- const S = N((D) => {
3763
- D.target.parentNode instanceof HTMLElement && (D.target.parentNode.dataset.replicatedValue = D.target.value);
3764
- }, []), L = N((D) => {
3765
- D.target.parentNode instanceof HTMLElement && (D.target.parentNode.dataset.replicatedValue = D.target.value);
3766
- }, []), R = i.type, T = Wt[R], [A, B] = P(() => {
3767
- let D = [], M = [];
3762
+ const S = N((A) => {
3763
+ A.target.parentNode instanceof HTMLElement && (A.target.parentNode.dataset.replicatedValue = A.target.value);
3764
+ }, []), L = N((A) => {
3765
+ A.target.parentNode instanceof HTMLElement && (A.target.parentNode.dataset.replicatedValue = A.target.value);
3766
+ }, []), R = i.type, T = Wt[R], [D, M] = P(() => {
3767
+ let A = [], z = [];
3768
3768
  if (T === q) {
3769
3769
  if (r === void 0)
3770
3770
  throw new Error("Conditional source fields must be provided when changing sections.");
3771
3771
  const j = T.getFieldCreationSchema(r, `${n}.${e}`);
3772
- D = D.concat(
3772
+ A = A.concat(
3773
3773
  j.filter((U) => U.showDirectly).map((U) => U.field)
3774
- ), M = M.concat(
3774
+ ), z = z.concat(
3775
3775
  j.filter((U) => !U.showDirectly).map((U) => U.field)
3776
3776
  );
3777
3777
  } else {
@@ -3780,30 +3780,30 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3780
3780
  const j = T.getFieldCreationSchema(
3781
3781
  `${n}.${e}`
3782
3782
  );
3783
- h ? (D = [
3784
- ...D,
3783
+ h ? (A = [
3784
+ ...A,
3785
3785
  ...j.filter((U) => U.showDirectly).map((U) => U.field)
3786
- ], M = [
3787
- ...M,
3786
+ ], z = [
3787
+ ...z,
3788
3788
  ...j.filter((U) => !U.showDirectly).map((U) => U.field)
3789
- ]) : M = [...M, ...j.map((U) => U.field)];
3789
+ ]) : z = [...z, ...j.map((U) => U.field)];
3790
3790
  }
3791
- return [D, M];
3792
- }, [T, r, n, e, h]), G = dt(A, {
3791
+ return [A, z];
3792
+ }, [T, r, n, e, h]), G = dt(D, {
3793
3793
  formId: ot,
3794
3794
  disabled: !1,
3795
3795
  ...T === q && { size: "sm" }
3796
- }), te = dt(B, {
3796
+ }), te = dt(M, {
3797
3797
  formId: ot,
3798
3798
  disabled: !1
3799
3799
  });
3800
- let _ = B.length > 0;
3801
- ge(i) && B.length > 0 && (_ = i.conditional);
3802
- const Q = B.some((D) => {
3803
- const M = Y(l, T === q ? `${n}.${e}.condition` : D.getId());
3804
- return M && (typeof M != "object" || ve(M));
3800
+ let B = M.length > 0;
3801
+ ge(i) && M.length > 0 && (B = i.conditional);
3802
+ const Q = M.some((A) => {
3803
+ const z = Y(l, T === q ? `${n}.${e}.condition` : A.getId());
3804
+ return z && (typeof z != "object" || ve(z));
3805
3805
  }), k = Q ? be.danger : void 0, W = P(() => gn(i), [i]), ce = Mi(W, { formId: ot, showInputOnly: !1 }), ne = P(
3806
- () => m.flat().find((D) => D.value === R),
3806
+ () => m.flat().find((A) => A.value === R),
3807
3807
  [m, R]
3808
3808
  ), de = N(() => {
3809
3809
  b && c(() => ({
@@ -3811,9 +3811,9 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3811
3811
  }));
3812
3812
  }, [c, b]);
3813
3813
  return /* @__PURE__ */ s("div", { className: "flex grow items-center w-full", ref: d, children: /* @__PURE__ */ x("div", { className: "flex w-full flex-col gap-2", children: [
3814
- T === q && (A.length > 0 || _) && /* @__PURE__ */ x("div", { className: "flex flex-col gap-2", children: [
3814
+ T === q && (D.length > 0 || B) && /* @__PURE__ */ x("div", { className: "flex flex-col gap-2", children: [
3815
3815
  G,
3816
- _ && /* @__PURE__ */ x("div", { className: "flex items-center gap-4", children: [
3816
+ B && /* @__PURE__ */ x("div", { className: "flex items-center gap-4", children: [
3817
3817
  /* @__PURE__ */ s(
3818
3818
  qt,
3819
3819
  {
@@ -3842,14 +3842,14 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3842
3842
  je,
3843
3843
  {
3844
3844
  name: `${n}.${e}.required`,
3845
- render: ({ setValue: D, value: M }) => /* @__PURE__ */ x("div", { className: "flex items-center gap-2", children: [
3846
- /* @__PURE__ */ s(at.Root, { checked: M, onCheckedChange: D, size: "sm", children: /* @__PURE__ */ s(at.Indicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }) }),
3845
+ render: ({ setValue: A, value: z }) => /* @__PURE__ */ x("div", { className: "flex items-center gap-2", children: [
3846
+ /* @__PURE__ */ s(at.Root, { checked: z, onCheckedChange: A, size: "sm", children: /* @__PURE__ */ s(at.Indicator, { children: /* @__PURE__ */ s(F, { icon: "RiCheckLine" }) }) }),
3847
3847
  /* @__PURE__ */ s(pe, { size: "sm", accentColor: "base", children: "Required" })
3848
3848
  ] })
3849
3849
  }
3850
3850
  )
3851
3851
  ] }),
3852
- _ && /* @__PURE__ */ s(
3852
+ B && /* @__PURE__ */ s(
3853
3853
  qt,
3854
3854
  {
3855
3855
  popoverInputs: te,
@@ -3885,14 +3885,14 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3885
3885
  je,
3886
3886
  {
3887
3887
  name: `${n}.${e}.label`,
3888
- render: ({ setValue: D, value: M }) => /* @__PURE__ */ s(
3888
+ render: ({ setValue: A, value: z }) => /* @__PURE__ */ s(
3889
3889
  "input",
3890
3890
  {
3891
3891
  className: "bg-transparent outline-none text-sm placeholder-(--base-a9)",
3892
3892
  placeholder: R === "section" ? "Enter a section label (optional)" : "Enter your question",
3893
- value: M,
3893
+ value: z,
3894
3894
  onChange: (j) => {
3895
- D(j.target.value);
3895
+ A(j.target.value);
3896
3896
  },
3897
3897
  onInput: S,
3898
3898
  maxLength: 200
@@ -3904,14 +3904,14 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3904
3904
  je,
3905
3905
  {
3906
3906
  name: `${n}.${e}.description`,
3907
- render: ({ setValue: D, value: M }) => /* @__PURE__ */ s(
3907
+ render: ({ setValue: A, value: z }) => /* @__PURE__ */ s(
3908
3908
  "textarea",
3909
3909
  {
3910
3910
  className: "bg-transparent outline-none text-sm field-sizing-content grow placeholder-(--base-a9)",
3911
3911
  placeholder: `Enter a ${R === "section" ? "section" : "field"} description (optional)`,
3912
- value: M,
3912
+ value: z,
3913
3913
  onChange: (j) => {
3914
- D(j.target.value);
3914
+ A(j.target.value);
3915
3915
  },
3916
3916
  onInput: L,
3917
3917
  maxLength: 1e3
@@ -3919,7 +3919,7 @@ const tr = (t = () => null) => P(() => qa.map((n) => n.map((e) => {
3919
3919
  )
3920
3920
  }
3921
3921
  ),
3922
- T !== q && A.length > 0 && /* @__PURE__ */ s("div", { className: "w-full", children: G }),
3922
+ T !== q && D.length > 0 && /* @__PURE__ */ s("div", { className: "w-full", children: G }),
3923
3923
  T !== q && /* @__PURE__ */ x(qe, { className: "flex gap-4 bg-(--accent-a2) items-center", children: [
3924
3924
  /* @__PURE__ */ x(It.Root, { children: [
3925
3925
  /* @__PURE__ */ s(It.Trigger, { asChild: !0, children: /* @__PURE__ */ s(Ot, { icon: !0, size: "sm", variant: "soft", accentColor: "base", children: /* @__PURE__ */ s(F, { icon: "RiEyeLine" }) }) }),
@@ -4027,8 +4027,8 @@ const ir = O((t) => {
4027
4027
  const L = n.fields[S];
4028
4028
  if (!L) throw new Error("Could not find field to remove.");
4029
4029
  const R = [];
4030
- for (const A of l.fields)
4031
- ((T = A.condition) == null ? void 0 : T.identifier) === L.identifier && R.push(A);
4030
+ for (const D of l.fields)
4031
+ ((T = D.condition) == null ? void 0 : T.identifier) === L.identifier && R.push(D);
4032
4032
  return {
4033
4033
  removing: L,
4034
4034
  affectedSections: R,
@@ -4038,28 +4038,28 @@ const ir = O((t) => {
4038
4038
  [n.fields, l.fields, a, e]
4039
4039
  ), y = N(
4040
4040
  (S) => {
4041
- const { affectedSections: L, action: R, removing: T } = h(S), A = () => {
4041
+ const { affectedSections: L, action: R, removing: T } = h(S), D = () => {
4042
4042
  R().then(), u(L, l.fields);
4043
4043
  };
4044
4044
  if (L.length > 0) {
4045
- const B = L.map((G) => G.label).join(", ");
4045
+ const M = L.map((G) => G.label).join(", ");
4046
4046
  m({
4047
4047
  title: "Remove condition?",
4048
- description: `${T.label} is being used as a condition, deleting it will remove the condition from the ${B} section(s).`,
4048
+ description: `${T.label} is being used as a condition, deleting it will remove the condition from the ${M} section(s).`,
4049
4049
  action: "Remove",
4050
- onAction: A
4050
+ onAction: D
4051
4051
  });
4052
4052
  return;
4053
4053
  }
4054
- A();
4054
+ D();
4055
4055
  },
4056
4056
  [h, u, l.fields, m]
4057
4057
  ), b = N(() => {
4058
- const L = n.fields.map((_, Q) => h(Q)).flatMap((_) => _.affectedSections), R = L.length ? "Remove fields and conditions?" : "Remove fields?", T = n.fields.length, A = L.map((_) => _.label).join(", "), B = L.length ? `Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${A}` : `Deleting this section will remove the ${T} field(s) it contains.`, G = ft(l.fields, e), te = () => a("fields", G);
4058
+ const L = n.fields.map((B, Q) => h(Q)).flatMap((B) => B.affectedSections), R = L.length ? "Remove fields and conditions?" : "Remove fields?", T = n.fields.length, D = L.map((B) => B.label).join(", "), M = L.length ? `Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${D}` : `Deleting this section will remove the ${T} field(s) it contains.`, G = ft(l.fields, e), te = () => a("fields", G);
4059
4059
  if (L.length > 0) {
4060
4060
  m({
4061
4061
  title: R,
4062
- description: B,
4062
+ description: M,
4063
4063
  action: "Remove",
4064
4064
  onAction: () => {
4065
4065
  te().then(() => {
@@ -4150,12 +4150,12 @@ const ir = O((t) => {
4150
4150
  R.identifier
4151
4151
  )),
4152
4152
  L.placeholder,
4153
- /* @__PURE__ */ x(z.Root, { children: [
4154
- /* @__PURE__ */ s(z.ClickTrigger, { children: /* @__PURE__ */ x(K, { type: "button", variant: "soft", size: "sm", children: [
4153
+ /* @__PURE__ */ x(_.Root, { children: [
4154
+ /* @__PURE__ */ s(_.ClickTrigger, { children: /* @__PURE__ */ x(K, { type: "button", variant: "soft", size: "sm", children: [
4155
4155
  /* @__PURE__ */ s(F, { icon: "RiAddLine" }),
4156
4156
  " Add field"
4157
4157
  ] }) }),
4158
- /* @__PURE__ */ s(z.Content, { children: v.flat().map((R) => /* @__PURE__ */ x(z.Item, { onSelect: R.onSelect, children: [
4158
+ /* @__PURE__ */ s(_.Content, { children: v.flat().map((R) => /* @__PURE__ */ x(_.Item, { onSelect: R.onSelect, children: [
4159
4159
  R.icon,
4160
4160
  R.children
4161
4161
  ] }, R.value)) })
@@ -4297,14 +4297,14 @@ const Xa = () => {
4297
4297
  w.title || (v.title = "Title is required."), (!w.fields || w.fields.length === 0) && (v.fields = "At least one field is required.");
4298
4298
  let E = [];
4299
4299
  for (const [L, R] of w.fields.entries()) {
4300
- const A = Wt.section.getFieldCreationSchema(
4300
+ const D = Wt.section.getFieldCreationSchema(
4301
4301
  Bi(w.fields, L),
4302
4302
  `fields.${L}`
4303
- ).map((B) => B.field);
4304
- E = [...E, ...A];
4305
- for (const [B, G] of R.fields.entries()) {
4306
- const _ = Wt[G.type].getFieldCreationSchema(`fields.${L}.fields.${B}`).map((Q) => Q.field);
4307
- E = [...E, ..._];
4303
+ ).map((M) => M.field);
4304
+ E = [...E, ...D];
4305
+ for (const [M, G] of R.fields.entries()) {
4306
+ const B = Wt[G.type].getFieldCreationSchema(`fields.${L}.fields.${M}`).map((Q) => Q.field);
4307
+ E = [...E, ...B];
4308
4308
  }
4309
4309
  }
4310
4310
  const S = vn(
@@ -4444,20 +4444,20 @@ const Ja = O((t) => {
4444
4444
  n.objectURL || (n.objectURL = URL.createObjectURL(n));
4445
4445
  const l = fe(null), m = fe(null), [c, d] = V(Gn.red), [u, h] = V(null), [y, b] = V(!1), [f, g] = V(!1), C = fe(null), w = cr(C);
4446
4446
  X(() => {
4447
- const _ = new Image();
4448
- _.onload = function() {
4449
- h({ width: _.naturalWidth, height: _.naturalHeight });
4450
- }, _.src = URL.createObjectURL(n);
4447
+ const B = new Image();
4448
+ B.onload = function() {
4449
+ h({ width: B.naturalWidth, height: B.naturalHeight });
4450
+ }, B.src = URL.createObjectURL(n);
4451
4451
  }, [n]), X(() => {
4452
4452
  !f && (w != null && w.width) && w.height && g(!0);
4453
4453
  }, [w, f]);
4454
4454
  const v = N(async () => {
4455
4455
  o || e();
4456
- const _ = l.current;
4457
- if (!_) return;
4456
+ const B = l.current;
4457
+ if (!B) return;
4458
4458
  if (!u)
4459
4459
  throw new Error("Original image size not loaded yet");
4460
- const Q = await _.exportImage("png"), k = new Image(u.width, u.height);
4460
+ const Q = await B.exportImage("png"), k = new Image(u.width, u.height);
4461
4461
  k.onload = async function() {
4462
4462
  const W = await Xn(Q), ce = new File([W], n.name, { type: n.type }), ne = m.current, de = await Ya(ne, n, ce, u);
4463
4463
  de.objectURL = URL.createObjectURL(de);
@@ -4474,10 +4474,10 @@ const Ja = O((t) => {
4474
4474
  l.current && l.current.redo();
4475
4475
  }, []), T = N(() => {
4476
4476
  l.current && l.current.undo();
4477
- }, []), A = N(() => {
4477
+ }, []), D = N(() => {
4478
4478
  l.current && (a(!1), l.current.clearCanvas());
4479
- }, [a]), B = N((_) => {
4480
- l.current && l.current.eraseMode(_);
4479
+ }, [a]), M = N((B) => {
4480
+ l.current && l.current.eraseMode(B);
4481
4481
  }, []), G = N(() => {
4482
4482
  v();
4483
4483
  }, [v]), te = N(() => {
@@ -4530,14 +4530,14 @@ const Ja = O((t) => {
4530
4530
  {
4531
4531
  defaultPressed: !1,
4532
4532
  "aria-label": "erase",
4533
- onPressedChange: B,
4533
+ onPressedChange: M,
4534
4534
  children: /* @__PURE__ */ s(F, { icon: "RiEraserFill" })
4535
4535
  }
4536
4536
  ),
4537
4537
  /* @__PURE__ */ s(Ht, { orientation: "vertical", size: "full" }),
4538
4538
  /* @__PURE__ */ s($, { "aria-label": "undo", onClick: T, children: /* @__PURE__ */ s(F, { icon: "RiArrowGoBackLine" }) }),
4539
4539
  /* @__PURE__ */ s($, { "aria-label": "undo", onClick: R, children: /* @__PURE__ */ s(F, { icon: "RiArrowGoForwardLine" }) }),
4540
- /* @__PURE__ */ s($, { "aria-label": "undo all", onClick: A, children: /* @__PURE__ */ s(F, { icon: "RiLoopLeftLine" }) })
4540
+ /* @__PURE__ */ s($, { "aria-label": "undo all", onClick: D, children: /* @__PURE__ */ s(F, { icon: "RiLoopLeftLine" }) })
4541
4541
  ] }),
4542
4542
  /* @__PURE__ */ x("div", { className: "flex justify-end gap-2", children: [
4543
4543
  /* @__PURE__ */ s($, { "aria-label": "Save markup", accentColor: "primary", onClick: G, children: /* @__PURE__ */ s(F, { icon: "RiSaveLine" }) }),
@@ -1,4 +1,4 @@
1
- (function(E,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("formik"),require("react-dom"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("@overmap-ai/core"),require("qr-scanner"),require("lodash.clonedeep"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","formik","react-dom","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","@overmap-ai/core","qr-scanner","lodash.clonedeep","react-sketch-canvas"],i):(E=typeof globalThis<"u"?globalThis:E||self,i(E.forms={},E.jsxRuntime,E.blocks,E.React,E.formik,E.ReactDOM,E.ri,E.get,E.set,E.dnd,E.core,E.QrScannerAPI,E.cloneDeep,E.reactSketchCanvas))})(this,function(E,i,c,d,V,pn,$,K,gt,re,ie,Hr,Gr,Xr){"use strict";var Ro=Object.defineProperty;var ea=(E,i,c)=>i in E?Ro(E,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):E[i]=c;var T=(E,i,c)=>ea(E,typeof i!="symbol"?i+"":i,c);function mn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const v=mn(d),Kr=mn(pn),vt=d.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=d.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{children:o}),i.jsx(c.Popover.Content,{size:"sm",children:i.jsx("div",{className:"grid w-max grid-cols-7 gap-x-1 gap-y-1",children:e.map(s=>i.jsx(c.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(c.RiIcon,{icon:"RiCheckLine"})},s))})})]})});vt.displayName="ColorPicker";function gn(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=gn(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Qr(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=gn(t))&&(r&&(r+=" "),r+=n);return r}const ve=Qr,vn=["image/jpeg","image/png","image/svg+xml"],yn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],bn=["application/pdf"],$e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>yn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileExcelLine"}):bn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFilePdfLine"}):vn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileImageLine"}):i.jsx(c.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});$e.displayName="FileIcon";const yt=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,rightSlot:a,...s}=t;return i.jsxs("div",{className:ve(r,"flex h-8 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):i.jsx($e,{fileType:(e==null?void 0:e.type)??""}),o||(e?i.jsx(c.Text,{className:"truncate",children:e.name}):i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(c.Spinner,{})})),a]})}));yt.displayName="FileCard";const ke=500,ye=1e4,de={danger:"danger",warning:"warning",info:"base",success:"success"},Yr={boolean:"RiCheckboxCircleLine",date:"RiCalendarLine","multi-string":"RiListCheck",number:"RiHashtag",qr:"RiQrCodeLine","multi-select":"RiCheckboxLine",select:"RiMenuFoldLine",string:"RiInputField",text:"RiAlignJustify",upload:"RiUpload2Line",custom:"RiCodeSSlashLine",section:"RiFolderLine"};class bt{constructor(n){T(this,"type");T(this,"identifier");T(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const H={label:"",description:"",required:!1};class k extends bt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...m}=e;super(m);T(this,"required");T(this,"formValidators");T(this,"fieldValidators");T(this,"label");T(this,"image");T(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=s,this.formValidators=l}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}T(k,"fieldTypeName"),T(k,"fieldTypeDescription");const G=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,onValuesChange:s,...l}=t,[m,u,f]=V.useField(e.getId()),{touched:h}=u,g=u.error??e.description,C=u.error?"danger":void 0,w=n??`${r}-${e.getId()}-input`,p=`${w}-label`,y=e.required?`${e.label} *`:e.label,x=d.useMemo(()=>({...m,onChange:S=>{f.setValue(S,!1).then(),s==null||s(e.getId(),S),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(S))},onBlur:S=>{f.setTouched(!0,!1).then(),f.setError(e.getError(S))}}),[e,m,f,s,h]);return[{helpText:g,size:o,severity:C,inputId:w,labelId:p,label:y,showInputOnly:a,fieldProps:x,helpers:f,field:e,touched:h},{...l,"aria-labelledby":p}]},Cn=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Ue=()=>d.useContext(Cn);function oe(t,n,{checkForDefaultPrevented:e=!0}={}){return function(o){if(t==null||t(o),e===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function wn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function In(...t){return n=>{let e=!1;const r=t.map(o=>{const a=wn(o,n);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():wn(t[o],null)}}}}function ue(...t){return v.useCallback(In(...t),t)}function Jr(t,n){const e=v.createContext(n),r=a=>{const{children:s,...l}=a,m=v.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:m,children:s})};r.displayName=t+"Provider";function o(a){const s=v.useContext(e);if(s)return s;if(n!==void 0)return n;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,o]}function Zr(t,n=[]){let e=[];function r(a,s){const l=v.createContext(s),m=e.length;e=[...e,s];const u=h=>{var x;const{scope:g,children:C,...w}=h,p=((x=g==null?void 0:g[t])==null?void 0:x[m])||l,y=v.useMemo(()=>w,Object.values(w));return i.jsx(p.Provider,{value:y,children:C})};u.displayName=a+"Provider";function f(h,g){var p;const C=((p=g==null?void 0:g[t])==null?void 0:p[m])||l,w=v.useContext(C);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=e.map(s=>v.createContext(s));return function(l){const m=(l==null?void 0:l[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...l,[t]:m}}),[l,m])}};return o.scopeName=t,[r,Rr(o,...n)]}function Rr(...t){const n=t[0];if(t.length===1)return n;const e=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const s=r.reduce((l,{useScope:m,scopeName:u})=>{const h=m(a)[`__scope${u}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var je=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},ei=v.useId||(()=>{}),ti=0;function Ct(t){const[n,e]=v.useState(ei());return je(()=>{e(r=>r??String(ti++))},[t]),t||(n?`radix-${n}`:"")}function fe(t){const n=v.useRef(t);return v.useEffect(()=>{n.current=t}),v.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function ni({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=ri({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=fe(e),m=v.useCallback(u=>{if(a){const h=typeof u=="function"?u(t):u;h!==t&&l(h)}else o(u)},[a,t,o,l]);return[s,m]}function ri({defaultProp:t,onChange:n}){const e=v.useState(t),[r]=e,o=v.useRef(r),a=fe(n);return v.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var wt=v.forwardRef((t,n)=>{const{children:e,...r}=t,o=v.Children.toArray(e),a=o.find(oi);if(a){const s=a.props.children,l=o.map(m=>m===a?v.Children.count(s)>1?v.Children.only(null):v.isValidElement(s)?s.props.children:null:m);return i.jsx(It,{...r,ref:n,children:v.isValidElement(s)?v.cloneElement(s,void 0,l):null})}return i.jsx(It,{...r,ref:n,children:e})});wt.displayName="Slot";var It=v.forwardRef((t,n)=>{const{children:e,...r}=t;if(v.isValidElement(e)){const o=si(e);return v.cloneElement(e,{...ai(r,e.props),ref:n?In(n,o):o})}return v.Children.count(e)>1?v.Children.only(null):null});It.displayName="SlotClone";var ii=({children:t})=>i.jsx(i.Fragment,{children:t});function oi(t){return v.isValidElement(t)&&t.type===ii}function ai(t,n){const e={...n};for(const r in n){const o=t[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...l)=>{a(...l),o(...l)}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...t,...e}}function si(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var li=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ne=li.reduce((t,n)=>{const e=v.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?wt:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(l,{...s,ref:o})});return e.displayName=`Primitive.${n}`,{...t,[n]:e}},{});function ci(t,n){t&&Kr.flushSync(()=>t.dispatchEvent(n))}function di(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return n.addEventListener("keydown",r,{capture:!0}),()=>n.removeEventListener("keydown",r,{capture:!0})},[e,n])}var ui="DismissableLayer",xt="dismissableLayer.update",fi="dismissableLayer.pointerDownOutside",hi="dismissableLayer.focusOutside",xn,En=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sn=v.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...m}=t,u=v.useContext(En),[f,h]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,C]=v.useState({}),w=ue(n,F=>h(F)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=p.indexOf(y),I=f?p.indexOf(f):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,S=I>=x,N=gi(F=>{const L=F.target,M=[...u.branches].some(z=>z.contains(L));!S||M||(o==null||o(F),s==null||s(F),F.defaultPrevented||l==null||l())},g),D=vi(F=>{const L=F.target;[...u.branches].some(z=>z.contains(L))||(a==null||a(F),s==null||s(F),F.defaultPrevented||l==null||l())},g);return di(F=>{I===u.layers.size-1&&(r==null||r(F),!F.defaultPrevented&&l&&(F.preventDefault(),l()))},g),v.useEffect(()=>{if(f)return e&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Tn(),()=>{e&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=xn)}},[f,g,e,u]),v.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Tn())},[f,u]),v.useEffect(()=>{const F=()=>C({});return document.addEventListener(xt,F),()=>document.removeEventListener(xt,F)},[]),i.jsx(ne.div,{...m,ref:w,style:{pointerEvents:b?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,D.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,N.onPointerDownCapture)})});Sn.displayName=ui;var pi="DismissableLayerBranch",mi=v.forwardRef((t,n)=>{const e=v.useContext(En),r=v.useRef(null),o=ue(n,r);return v.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),i.jsx(ne.div,{...t,ref:o})});mi.displayName=pi;function gi(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let m=function(){Nn(fi,e,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=m,n.addEventListener("click",o.current,{once:!0})):m()}else n.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(s),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,e]),{onPointerDownCapture:()=>r.current=!0}}function vi(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t),r=v.useRef(!1);return v.useEffect(()=>{const o=a=>{a.target&&!r.current&&Nn(hi,e,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Tn(){const t=new CustomEvent(xt);document.dispatchEvent(t)}function Nn(t,n,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:e});n&&o.addEventListener(t,n,{once:!0}),r?ci(o,a):o.dispatchEvent(a)}var Et="focusScope.autoFocusOnMount",St="focusScope.autoFocusOnUnmount",Fn={bubbles:!1,cancelable:!0},yi="FocusScope",Ln=v.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,m]=v.useState(null),u=fe(o),f=fe(a),h=v.useRef(null),g=ue(n,p=>m(p)),C=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let p=function(b){if(C.paused||!l)return;const S=b.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},y=function(b){if(C.paused||!l)return;const S=b.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const N of b)N.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const I=new MutationObserver(x);return l&&I.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),I.disconnect()}}},[r,l,C.paused]),v.useEffect(()=>{if(l){An.add(C);const p=document.activeElement;if(!l.contains(p)){const x=new CustomEvent(Et,Fn);l.addEventListener(Et,u),l.dispatchEvent(x),x.defaultPrevented||(bi(Ei(Dn(l)),{select:!0}),document.activeElement===p&&ae(l))}return()=>{l.removeEventListener(Et,u),setTimeout(()=>{const x=new CustomEvent(St,Fn);l.addEventListener(St,f),l.dispatchEvent(x),x.defaultPrevented||ae(p??document.body,{select:!0}),l.removeEventListener(St,f),An.remove(C)},0)}}},[l,u,f,C]);const w=v.useCallback(p=>{if(!e&&!r||C.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,x=document.activeElement;if(y&&x){const I=p.currentTarget,[b,S]=Ci(I);b&&S?!p.shiftKey&&x===S?(p.preventDefault(),e&&ae(b,{select:!0})):p.shiftKey&&x===b&&(p.preventDefault(),e&&ae(S,{select:!0})):x===I&&p.preventDefault()}},[e,r,C.paused]);return i.jsx(ne.div,{tabIndex:-1,...s,ref:g,onKeyDown:w})});Ln.displayName=yi;function bi(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function Ci(t){const n=Dn(t),e=Mn(n,t),r=Mn(n.reverse(),t);return[e,r]}function Dn(t){const n=[],e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)n.push(e.currentNode);return n}function Mn(t,n){for(const e of t)if(!wi(e,{upTo:n}))return e}function wi(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Ii(t){return t instanceof HTMLInputElement&&"select"in t}function ae(t,{select:n=!1}={}){if(t&&t.focus){const e=document.activeElement;t.focus({preventScroll:!0}),t!==e&&Ii(t)&&n&&t.select()}}var An=xi();function xi(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Pn(t,n),t.unshift(n)},remove(n){var e;t=Pn(t,n),(e=t[0])==null||e.resume()}}}function Pn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Ei(t){return t.filter(n=>n.tagName!=="A")}var Si="Portal",On=v.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=v.useState(!1);je(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?pn.createPortal(i.jsx(ne.div,{...r,ref:n}),s):null});On.displayName=Si;function Ti(t,n){return v.useReducer((e,r)=>n[e][r]??e,t)}var We=t=>{const{present:n,children:e}=t,r=Ni(n),o=typeof e=="function"?e({present:r.isPresent}):v.Children.only(e),a=ue(r.ref,Fi(o));return typeof e=="function"||r.isPresent?v.cloneElement(o,{ref:a}):null};We.displayName="Presence";function Ni(t){const[n,e]=v.useState(),r=v.useRef({}),o=v.useRef(t),a=v.useRef("none"),s=t?"mounted":"unmounted",[l,m]=Ti(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=qe(r.current);a.current=l==="mounted"?u:"none"},[l]),je(()=>{const u=r.current,f=o.current;if(f!==t){const g=a.current,C=qe(u);t?m("MOUNT"):C==="none"||(u==null?void 0:u.display)==="none"?m("UNMOUNT"):m(f&&g!==C?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,m]),je(()=>{if(n){let u;const f=n.ownerDocument.defaultView??window,h=C=>{const p=qe(r.current).includes(C.animationName);if(C.target===n&&p&&(m("ANIMATION_END"),!o.current)){const y=n.style.animationFillMode;n.style.animationFillMode="forwards",u=f.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=y)})}},g=C=>{C.target===n&&(a.current=qe(r.current))};return n.addEventListener("animationstart",g),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{f.clearTimeout(u),n.removeEventListener("animationstart",g),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:v.useCallback(u=>{u&&(r.current=getComputedStyle(u)),e(u)},[])}}function qe(t){return(t==null?void 0:t.animationName)||"none"}function Fi(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Tt=0;function Li(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Bn()),document.body.insertAdjacentElement("beforeend",t[1]??Bn()),Tt++,()=>{Tt===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),Tt--}},[])}function Bn(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Z=function(){return Z=Object.assign||function(n){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},Z.apply(this,arguments)};function zn(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]]);return e}function Di(t,n,e){if(e||arguments.length===2)for(var r=0,o=n.length,a;r<o;r++)(a||!(r in n))&&(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return t.concat(a||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;var He="right-scroll-bar-position",Ge="width-before-scroll-bar",Mi="with-scroll-bars-hidden",Ai="--removed-body-scroll-bar-size";function Nt(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function Pi(t,n){var e=d.useState(function(){return{value:t,callback:n,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=n,e.facade}var Oi=typeof window<"u"?v.useLayoutEffect:v.useEffect,_n=new WeakMap;function Bi(t,n){var e=Pi(null,function(r){return t.forEach(function(o){return Nt(o,r)})});return Oi(function(){var r=_n.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Nt(l,null)}),a.forEach(function(l){o.has(l)||Nt(l,s)})}_n.set(e,t)},[t]),e}function zi(t){return t}function _i(t,n){n===void 0&&(n=zi);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:t},useMedium:function(a){var s=n(a,r);return e.push(s),function(){e=e.filter(function(l){return l!==s})}},assignSyncMedium:function(a){for(r=!0;e.length;){var s=e;e=[],s.forEach(a)}e={push:function(l){return a(l)},filter:function(){return e}}},assignMedium:function(a){r=!0;var s=[];if(e.length){var l=e;e=[],l.forEach(a),s=e}var m=function(){var f=s;s=[],f.forEach(a)},u=function(){return Promise.resolve().then(m)};u(),e={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),e}}}};return o}function Vi(t){t===void 0&&(t={});var n=_i(null);return n.options=Z({async:!0,ssr:!1},t),n}var Vn=function(t){var n=t.sideCar,e=zn(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,Z({},e))};Vn.isSideCarExport=!0;function $i(t,n){return t.useMedium(n),Vn}var $n=Vi(),Ft=function(){},Xe=v.forwardRef(function(t,n){var e=v.useRef(null),r=v.useState({onScrollCapture:Ft,onWheelCapture:Ft,onTouchMoveCapture:Ft}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,m=t.className,u=t.removeScrollBar,f=t.enabled,h=t.shards,g=t.sideCar,C=t.noIsolation,w=t.inert,p=t.allowPinchZoom,y=t.as,x=y===void 0?"div":y,I=t.gapMode,b=zn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=g,N=Bi([e,n]),D=Z(Z({},b),o);return v.createElement(v.Fragment,null,f&&v.createElement(S,{sideCar:$n,removeScrollBar:u,shards:h,noIsolation:C,inert:w,setCallbacks:a,allowPinchZoom:!!p,lockRef:e,gapMode:I}),s?v.cloneElement(v.Children.only(l),Z(Z({},D),{ref:N})):v.createElement(x,Z({},D,{className:m,ref:N}),l))});Xe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Xe.classNames={fullWidth:Ge,zeroRight:He};var ki=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ui(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=ki();return n&&t.setAttribute("nonce",n),t}function ji(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Wi(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var qi=function(){var t=0,n=null;return{add:function(e){t==0&&(n=Ui())&&(ji(n,e),Wi(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Hi=function(){var t=qi();return function(n,e){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},kn=function(){var t=Hi(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},Gi={left:0,top:0,right:0,gap:0},Lt=function(t){return parseInt(t||"",10)||0},Xi=function(t){var n=window.getComputedStyle(document.body),e=n[t==="padding"?"paddingLeft":"marginLeft"],r=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[Lt(e),Lt(r),Lt(o)]},Ki=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Gi;var n=Xi(t),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-e+n[2]-n[0])}},Qi=kn(),be="data-scroll-locked",Yi=function(t,n,e,r){var o=t.left,a=t.top,s=t.right,l=t.gap;return e===void 0&&(e="margin"),`
1
+ (function(x,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("formik"),require("react-dom"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("@overmap-ai/core"),require("qr-scanner"),require("lodash.clonedeep"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","formik","react-dom","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","@overmap-ai/core","qr-scanner","lodash.clonedeep","react-sketch-canvas"],i):(x=typeof globalThis<"u"?globalThis:x||self,i(x.forms={},x.jsxRuntime,x.blocks,x.React,x.formik,x.ReactDOM,x.ri,x.get,x.set,x.dnd,x.core,x.QrScannerAPI,x.cloneDeep,x.reactSketchCanvas))})(this,function(x,i,c,d,V,pn,$,K,gt,re,ie,Hr,Gr,Xr){"use strict";var Ro=Object.defineProperty;var ea=(x,i,c)=>i in x?Ro(x,i,{enumerable:!0,configurable:!0,writable:!0,value:c}):x[i]=c;var T=(x,i,c)=>ea(x,typeof i!="symbol"?i+"":i,c);function mn(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const v=mn(d),Kr=mn(pn),vt=d.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=d.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{children:o}),i.jsx(c.Popover.Content,{size:"sm",children:i.jsx("div",{className:"grid w-max grid-cols-7 gap-x-1 gap-y-1",children:e.map(s=>i.jsx(c.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(c.RiIcon,{icon:"RiCheckLine"})},s))})})]})});vt.displayName="ColorPicker";function gn(t){var n,e,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(n=0;n<o;n++)t[n]&&(e=gn(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Qr(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=gn(t))&&(r&&(r+=" "),r+=n);return r}const ve=Qr,vn=["image/jpeg","image/png","image/svg+xml"],yn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],bn=["application/pdf"],$e=d.memo(t=>{const{fileType:n}=t,e=d.useMemo(()=>yn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileExcelLine"}):bn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFilePdfLine"}):vn.includes(n)?i.jsx(c.RiIcon,{icon:"RiFileImageLine"}):i.jsx(c.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});$e.displayName="FileIcon";const yt=d.memo(d.forwardRef((t,n)=>{const{file:e,className:r,error:o,rightSlot:a,...s}=t;return i.jsxs("div",{className:ve(r,"flex h-8 w-full items-center gap-2 rounded-md border border-(--base-a6) bg-(--base-2) text-sm py-1 px-2 h-max",{"text-(--gray-11)":o}),ref:n,...s,children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):i.jsx($e,{fileType:(e==null?void 0:e.type)??""}),o||(e?i.jsx(c.Text,{className:"truncate",children:e.name}):i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(c.Spinner,{})})),a]})}));yt.displayName="FileCard";const ke=500,ye=1e4,de={danger:"danger",warning:"warning",info:"base",success:"success"},Yr={boolean:"RiCheckboxCircleLine",date:"RiCalendarLine","multi-string":"RiListCheck",number:"RiHashtag",qr:"RiQrCodeLine","multi-select":"RiCheckboxLine",select:"RiMenuFoldLine",string:"RiInputField",text:"RiAlignJustify",upload:"RiUpload2Line",custom:"RiCodeSSlashLine",section:"RiFolderLine"};class bt{constructor(n){T(this,"type");T(this,"identifier");T(this,"description");const{description:e=null,identifier:r,type:o}=n;this.identifier=r,this.description=e,this.type=o}getId(){return this.identifier}static deserialize(n){throw new Error(`${this.name} must implement deserialize.`)}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{type:this.type,identifier:this.identifier,description:this.description}}}const H={label:"",description:"",required:!1};class k extends bt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...m}=e;super(m);T(this,"required");T(this,"formValidators");T(this,"fieldValidators");T(this,"label");T(this,"image");T(this,"onlyValidateAfterTouched",!0);this.label=r,this.required=o,this.image=a,this.fieldValidators=s,this.formValidators=l}static getFieldCreationSchema(){return[]}isBlank(e){return e==null||e===""}getValueFromChangeEvent(e){return e.target.value}getError(e,r){if(this.required&&this.isBlank(e))return"This field is required.";for(const o of this.getFieldValidators()){const a=o(e);if(a)return a}if(r)for(const o of this.getFormValidators()){const a=o(e,r);if(a)return a}}_serialize(){return{...super._serialize(),label:this.label,required:this.required,image:this.image}}getFieldValidators(){return[...this.fieldValidators]}getFormValidators(){return[...this.formValidators]}encodeValueToJson(e){return JSON.stringify(e)}decodeJsonToValue(e){return JSON.parse(e)}}T(k,"fieldTypeName"),T(k,"fieldTypeDescription");const G=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,onValuesChange:s,...l}=t,[m,u,f]=V.useField(e.getId()),{touched:h}=u,g=u.error??e.description,C=u.error?"danger":void 0,w=n??`${r}-${e.getId()}-input`,p=`${w}-label`,y=e.required?`${e.label} *`:e.label,E=d.useMemo(()=>({...m,onChange:S=>{f.setValue(S,!1).then(),s==null||s(e.getId(),S),(h||!e.onlyValidateAfterTouched)&&f.setError(e.getError(S))},onBlur:S=>{f.setTouched(!0,!1).then(),f.setError(e.getError(S))}}),[e,m,f,s,h]);return[{helpText:g,size:o,severity:C,inputId:w,labelId:p,label:y,showInputOnly:a,fieldProps:E,helpers:f,field:e,touched:h},{...l,"aria-labelledby":p}]},Cn=d.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Ue=()=>d.useContext(Cn);function oe(t,n,{checkForDefaultPrevented:e=!0}={}){return function(o){if(t==null||t(o),e===!1||!o.defaultPrevented)return n==null?void 0:n(o)}}function wn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function In(...t){return n=>{let e=!1;const r=t.map(o=>{const a=wn(o,n);return!e&&typeof a=="function"&&(e=!0),a});if(e)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():wn(t[o],null)}}}}function ue(...t){return v.useCallback(In(...t),t)}function Jr(t,n){const e=v.createContext(n),r=a=>{const{children:s,...l}=a,m=v.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:m,children:s})};r.displayName=t+"Provider";function o(a){const s=v.useContext(e);if(s)return s;if(n!==void 0)return n;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,o]}function Zr(t,n=[]){let e=[];function r(a,s){const l=v.createContext(s),m=e.length;e=[...e,s];const u=h=>{var E;const{scope:g,children:C,...w}=h,p=((E=g==null?void 0:g[t])==null?void 0:E[m])||l,y=v.useMemo(()=>w,Object.values(w));return i.jsx(p.Provider,{value:y,children:C})};u.displayName=a+"Provider";function f(h,g){var p;const C=((p=g==null?void 0:g[t])==null?void 0:p[m])||l,w=v.useContext(C);if(w)return w;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=e.map(s=>v.createContext(s));return function(l){const m=(l==null?void 0:l[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...l,[t]:m}}),[l,m])}};return o.scopeName=t,[r,Rr(o,...n)]}function Rr(...t){const n=t[0];if(t.length===1)return n;const e=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const s=r.reduce((l,{useScope:m,scopeName:u})=>{const h=m(a)[`__scope${u}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var je=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},ei=v.useId||(()=>{}),ti=0;function Ct(t){const[n,e]=v.useState(ei());return je(()=>{e(r=>r??String(ti++))},[t]),t||(n?`radix-${n}`:"")}function fe(t){const n=v.useRef(t);return v.useEffect(()=>{n.current=t}),v.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function ni({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=ri({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=fe(e),m=v.useCallback(u=>{if(a){const h=typeof u=="function"?u(t):u;h!==t&&l(h)}else o(u)},[a,t,o,l]);return[s,m]}function ri({defaultProp:t,onChange:n}){const e=v.useState(t),[r]=e,o=v.useRef(r),a=fe(n);return v.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var wt=v.forwardRef((t,n)=>{const{children:e,...r}=t,o=v.Children.toArray(e),a=o.find(oi);if(a){const s=a.props.children,l=o.map(m=>m===a?v.Children.count(s)>1?v.Children.only(null):v.isValidElement(s)?s.props.children:null:m);return i.jsx(It,{...r,ref:n,children:v.isValidElement(s)?v.cloneElement(s,void 0,l):null})}return i.jsx(It,{...r,ref:n,children:e})});wt.displayName="Slot";var It=v.forwardRef((t,n)=>{const{children:e,...r}=t;if(v.isValidElement(e)){const o=si(e);return v.cloneElement(e,{...ai(r,e.props),ref:n?In(n,o):o})}return v.Children.count(e)>1?v.Children.only(null):null});It.displayName="SlotClone";var ii=({children:t})=>i.jsx(i.Fragment,{children:t});function oi(t){return v.isValidElement(t)&&t.type===ii}function ai(t,n){const e={...n};for(const r in n){const o=t[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?e[r]=(...l)=>{a(...l),o(...l)}:o&&(e[r]=o):r==="style"?e[r]={...o,...a}:r==="className"&&(e[r]=[o,a].filter(Boolean).join(" "))}return{...t,...e}}function si(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var li=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ne=li.reduce((t,n)=>{const e=v.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?wt:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(l,{...s,ref:o})});return e.displayName=`Primitive.${n}`,{...t,[n]:e}},{});function ci(t,n){t&&Kr.flushSync(()=>t.dispatchEvent(n))}function di(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t);v.useEffect(()=>{const r=o=>{o.key==="Escape"&&e(o)};return n.addEventListener("keydown",r,{capture:!0}),()=>n.removeEventListener("keydown",r,{capture:!0})},[e,n])}var ui="DismissableLayer",xt="dismissableLayer.update",fi="dismissableLayer.pointerDownOutside",hi="dismissableLayer.focusOutside",xn,En=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Sn=v.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...m}=t,u=v.useContext(En),[f,h]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,C]=v.useState({}),w=ue(n,F=>h(F)),p=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),E=p.indexOf(y),I=f?p.indexOf(f):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,S=I>=E,N=gi(F=>{const L=F.target,A=[...u.branches].some(O=>O.contains(L));!S||A||(o==null||o(F),s==null||s(F),F.defaultPrevented||l==null||l())},g),D=vi(F=>{const L=F.target;[...u.branches].some(O=>O.contains(L))||(a==null||a(F),s==null||s(F),F.defaultPrevented||l==null||l())},g);return di(F=>{I===u.layers.size-1&&(r==null||r(F),!F.defaultPrevented&&l&&(F.preventDefault(),l()))},g),v.useEffect(()=>{if(f)return e&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(xn=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Tn(),()=>{e&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=xn)}},[f,g,e,u]),v.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Tn())},[f,u]),v.useEffect(()=>{const F=()=>C({});return document.addEventListener(xt,F),()=>document.removeEventListener(xt,F)},[]),i.jsx(ne.div,{...m,ref:w,style:{pointerEvents:b?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,D.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,N.onPointerDownCapture)})});Sn.displayName=ui;var pi="DismissableLayerBranch",mi=v.forwardRef((t,n)=>{const e=v.useContext(En),r=v.useRef(null),o=ue(n,r);return v.useEffect(()=>{const a=r.current;if(a)return e.branches.add(a),()=>{e.branches.delete(a)}},[e.branches]),i.jsx(ne.div,{...t,ref:o})});mi.displayName=pi;function gi(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t),r=v.useRef(!1),o=v.useRef(()=>{});return v.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let m=function(){Nn(fi,e,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=m,n.addEventListener("click",o.current,{once:!0})):m()}else n.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(s),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,e]),{onPointerDownCapture:()=>r.current=!0}}function vi(t,n=globalThis==null?void 0:globalThis.document){const e=fe(t),r=v.useRef(!1);return v.useEffect(()=>{const o=a=>{a.target&&!r.current&&Nn(hi,e,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,e]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Tn(){const t=new CustomEvent(xt);document.dispatchEvent(t)}function Nn(t,n,e,{discrete:r}){const o=e.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:e});n&&o.addEventListener(t,n,{once:!0}),r?ci(o,a):o.dispatchEvent(a)}var Et="focusScope.autoFocusOnMount",St="focusScope.autoFocusOnUnmount",Fn={bubbles:!1,cancelable:!0},yi="FocusScope",Ln=v.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,m]=v.useState(null),u=fe(o),f=fe(a),h=v.useRef(null),g=ue(n,p=>m(p)),C=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let p=function(b){if(C.paused||!l)return;const S=b.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},y=function(b){if(C.paused||!l)return;const S=b.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},E=function(b){if(document.activeElement===document.body)for(const N of b)N.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const I=new MutationObserver(E);return l&&I.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),I.disconnect()}}},[r,l,C.paused]),v.useEffect(()=>{if(l){An.add(C);const p=document.activeElement;if(!l.contains(p)){const E=new CustomEvent(Et,Fn);l.addEventListener(Et,u),l.dispatchEvent(E),E.defaultPrevented||(bi(Ei(Dn(l)),{select:!0}),document.activeElement===p&&ae(l))}return()=>{l.removeEventListener(Et,u),setTimeout(()=>{const E=new CustomEvent(St,Fn);l.addEventListener(St,f),l.dispatchEvent(E),E.defaultPrevented||ae(p??document.body,{select:!0}),l.removeEventListener(St,f),An.remove(C)},0)}}},[l,u,f,C]);const w=v.useCallback(p=>{if(!e&&!r||C.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,E=document.activeElement;if(y&&E){const I=p.currentTarget,[b,S]=Ci(I);b&&S?!p.shiftKey&&E===S?(p.preventDefault(),e&&ae(b,{select:!0})):p.shiftKey&&E===b&&(p.preventDefault(),e&&ae(S,{select:!0})):E===I&&p.preventDefault()}},[e,r,C.paused]);return i.jsx(ne.div,{tabIndex:-1,...s,ref:g,onKeyDown:w})});Ln.displayName=yi;function bi(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function Ci(t){const n=Dn(t),e=Mn(n,t),r=Mn(n.reverse(),t);return[e,r]}function Dn(t){const n=[],e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;e.nextNode();)n.push(e.currentNode);return n}function Mn(t,n){for(const e of t)if(!wi(e,{upTo:n}))return e}function wi(t,{upTo:n}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(n!==void 0&&t===n)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Ii(t){return t instanceof HTMLInputElement&&"select"in t}function ae(t,{select:n=!1}={}){if(t&&t.focus){const e=document.activeElement;t.focus({preventScroll:!0}),t!==e&&Ii(t)&&n&&t.select()}}var An=xi();function xi(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Pn(t,n),t.unshift(n)},remove(n){var e;t=Pn(t,n),(e=t[0])==null||e.resume()}}}function Pn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Ei(t){return t.filter(n=>n.tagName!=="A")}var Si="Portal",On=v.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=v.useState(!1);je(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?pn.createPortal(i.jsx(ne.div,{...r,ref:n}),s):null});On.displayName=Si;function Ti(t,n){return v.useReducer((e,r)=>n[e][r]??e,t)}var We=t=>{const{present:n,children:e}=t,r=Ni(n),o=typeof e=="function"?e({present:r.isPresent}):v.Children.only(e),a=ue(r.ref,Fi(o));return typeof e=="function"||r.isPresent?v.cloneElement(o,{ref:a}):null};We.displayName="Presence";function Ni(t){const[n,e]=v.useState(),r=v.useRef({}),o=v.useRef(t),a=v.useRef("none"),s=t?"mounted":"unmounted",[l,m]=Ti(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const u=qe(r.current);a.current=l==="mounted"?u:"none"},[l]),je(()=>{const u=r.current,f=o.current;if(f!==t){const g=a.current,C=qe(u);t?m("MOUNT"):C==="none"||(u==null?void 0:u.display)==="none"?m("UNMOUNT"):m(f&&g!==C?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,m]),je(()=>{if(n){let u;const f=n.ownerDocument.defaultView??window,h=C=>{const p=qe(r.current).includes(C.animationName);if(C.target===n&&p&&(m("ANIMATION_END"),!o.current)){const y=n.style.animationFillMode;n.style.animationFillMode="forwards",u=f.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=y)})}},g=C=>{C.target===n&&(a.current=qe(r.current))};return n.addEventListener("animationstart",g),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{f.clearTimeout(u),n.removeEventListener("animationstart",g),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:v.useCallback(u=>{u&&(r.current=getComputedStyle(u)),e(u)},[])}}function qe(t){return(t==null?void 0:t.animationName)||"none"}function Fi(t){var r,o;let n=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var Tt=0;function Li(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Bn()),document.body.insertAdjacentElement("beforeend",t[1]??Bn()),Tt++,()=>{Tt===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),Tt--}},[])}function Bn(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Z=function(){return Z=Object.assign||function(n){for(var e,r=1,o=arguments.length;r<o;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a])}return n},Z.apply(this,arguments)};function zn(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]]);return e}function Di(t,n,e){if(e||arguments.length===2)for(var r=0,o=n.length,a;r<o;r++)(a||!(r in n))&&(a||(a=Array.prototype.slice.call(n,0,r)),a[r]=n[r]);return t.concat(a||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;var He="right-scroll-bar-position",Ge="width-before-scroll-bar",Mi="with-scroll-bars-hidden",Ai="--removed-body-scroll-bar-size";function Nt(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function Pi(t,n){var e=d.useState(function(){return{value:t,callback:n,facade:{get current(){return e.value},set current(r){var o=e.value;o!==r&&(e.value=r,e.callback(r,o))}}}})[0];return e.callback=n,e.facade}var Oi=typeof window<"u"?v.useLayoutEffect:v.useEffect,_n=new WeakMap;function Bi(t,n){var e=Pi(null,function(r){return t.forEach(function(o){return Nt(o,r)})});return Oi(function(){var r=_n.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Nt(l,null)}),a.forEach(function(l){o.has(l)||Nt(l,s)})}_n.set(e,t)},[t]),e}function zi(t){return t}function _i(t,n){n===void 0&&(n=zi);var e=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return e.length?e[e.length-1]:t},useMedium:function(a){var s=n(a,r);return e.push(s),function(){e=e.filter(function(l){return l!==s})}},assignSyncMedium:function(a){for(r=!0;e.length;){var s=e;e=[],s.forEach(a)}e={push:function(l){return a(l)},filter:function(){return e}}},assignMedium:function(a){r=!0;var s=[];if(e.length){var l=e;e=[],l.forEach(a),s=e}var m=function(){var f=s;s=[],f.forEach(a)},u=function(){return Promise.resolve().then(m)};u(),e={push:function(f){s.push(f),u()},filter:function(f){return s=s.filter(f),e}}}};return o}function Vi(t){t===void 0&&(t={});var n=_i(null);return n.options=Z({async:!0,ssr:!1},t),n}var Vn=function(t){var n=t.sideCar,e=zn(t,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=n.read();if(!r)throw new Error("Sidecar medium not found");return v.createElement(r,Z({},e))};Vn.isSideCarExport=!0;function $i(t,n){return t.useMedium(n),Vn}var $n=Vi(),Ft=function(){},Xe=v.forwardRef(function(t,n){var e=v.useRef(null),r=v.useState({onScrollCapture:Ft,onWheelCapture:Ft,onTouchMoveCapture:Ft}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,m=t.className,u=t.removeScrollBar,f=t.enabled,h=t.shards,g=t.sideCar,C=t.noIsolation,w=t.inert,p=t.allowPinchZoom,y=t.as,E=y===void 0?"div":y,I=t.gapMode,b=zn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=g,N=Bi([e,n]),D=Z(Z({},b),o);return v.createElement(v.Fragment,null,f&&v.createElement(S,{sideCar:$n,removeScrollBar:u,shards:h,noIsolation:C,inert:w,setCallbacks:a,allowPinchZoom:!!p,lockRef:e,gapMode:I}),s?v.cloneElement(v.Children.only(l),Z(Z({},D),{ref:N})):v.createElement(E,Z({},D,{className:m,ref:N}),l))});Xe.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Xe.classNames={fullWidth:Ge,zeroRight:He};var ki=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ui(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=ki();return n&&t.setAttribute("nonce",n),t}function ji(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Wi(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var qi=function(){var t=0,n=null;return{add:function(e){t==0&&(n=Ui())&&(ji(n,e),Wi(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Hi=function(){var t=qi();return function(n,e){v.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},kn=function(){var t=Hi(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},Gi={left:0,top:0,right:0,gap:0},Lt=function(t){return parseInt(t||"",10)||0},Xi=function(t){var n=window.getComputedStyle(document.body),e=n[t==="padding"?"paddingLeft":"marginLeft"],r=n[t==="padding"?"paddingTop":"marginTop"],o=n[t==="padding"?"paddingRight":"marginRight"];return[Lt(e),Lt(r),Lt(o)]},Ki=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Gi;var n=Xi(t),e=document.documentElement.clientWidth,r=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,r-e+n[2]-n[0])}},Qi=kn(),be="data-scroll-locked",Yi=function(t,n,e,r){var o=t.left,a=t.top,s=t.right,l=t.gap;return e===void 0&&(e="margin"),`
2
2
  .`.concat(Mi,` {
3
3
  overflow: hidden `).concat(r,`;
4
4
  padding-right: `).concat(l,"px ").concat(r,`;
@@ -35,11 +35,11 @@
35
35
  body[`).concat(be,`] {
36
36
  `).concat(Ai,": ").concat(l,`px;
37
37
  }
38
- `)},Un=function(){var t=parseInt(document.body.getAttribute(be)||"0",10);return isFinite(t)?t:0},Ji=function(){v.useEffect(function(){return document.body.setAttribute(be,(Un()+1).toString()),function(){var t=Un()-1;t<=0?document.body.removeAttribute(be):document.body.setAttribute(be,t.toString())}},[])},Zi=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;Ji();var a=v.useMemo(function(){return Ki(o)},[o]);return v.createElement(Qi,{styles:Yi(a,!n,o,e?"":"!important")})},Dt=!1;if(typeof window<"u")try{var Ke=Object.defineProperty({},"passive",{get:function(){return Dt=!0,!0}});window.addEventListener("test",Ke,Ke),window.removeEventListener("test",Ke,Ke)}catch{Dt=!1}var Ce=Dt?{passive:!1}:!1,Ri=function(t){return t.tagName==="TEXTAREA"},jn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!Ri(t)&&e[n]==="visible")},eo=function(t){return jn(t,"overflowY")},to=function(t){return jn(t,"overflowX")},Wn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=qn(t,r);if(o){var a=Hn(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},no=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},ro=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},qn=function(t,n){return t==="v"?eo(n):to(n)},Hn=function(t,n){return t==="v"?no(n):ro(n)},io=function(t,n){return t==="h"&&n==="rtl"?-1:1},oo=function(t,n,e,r,o){var a=io(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,m=n.contains(l),u=!1,f=s>0,h=0,g=0;do{var C=Hn(t,l),w=C[0],p=C[1],y=C[2],x=p-y-a*w;(w||x)&&qn(t,l)&&(h+=x,g+=w),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!m&&l!==document.body||m&&(n.contains(l)||n===l));return(f&&Math.abs(h)<1||!f&&Math.abs(g)<1)&&(u=!0),u},Qe=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Gn=function(t){return[t.deltaX,t.deltaY]},Xn=function(t){return t&&"current"in t?t.current:t},ao=function(t,n){return t[0]===n[0]&&t[1]===n[1]},so=function(t){return`
38
+ `)},Un=function(){var t=parseInt(document.body.getAttribute(be)||"0",10);return isFinite(t)?t:0},Ji=function(){v.useEffect(function(){return document.body.setAttribute(be,(Un()+1).toString()),function(){var t=Un()-1;t<=0?document.body.removeAttribute(be):document.body.setAttribute(be,t.toString())}},[])},Zi=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;Ji();var a=v.useMemo(function(){return Ki(o)},[o]);return v.createElement(Qi,{styles:Yi(a,!n,o,e?"":"!important")})},Dt=!1;if(typeof window<"u")try{var Ke=Object.defineProperty({},"passive",{get:function(){return Dt=!0,!0}});window.addEventListener("test",Ke,Ke),window.removeEventListener("test",Ke,Ke)}catch{Dt=!1}var Ce=Dt?{passive:!1}:!1,Ri=function(t){return t.tagName==="TEXTAREA"},jn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!Ri(t)&&e[n]==="visible")},eo=function(t){return jn(t,"overflowY")},to=function(t){return jn(t,"overflowX")},Wn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=qn(t,r);if(o){var a=Hn(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},no=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},ro=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},qn=function(t,n){return t==="v"?eo(n):to(n)},Hn=function(t,n){return t==="v"?no(n):ro(n)},io=function(t,n){return t==="h"&&n==="rtl"?-1:1},oo=function(t,n,e,r,o){var a=io(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,m=n.contains(l),u=!1,f=s>0,h=0,g=0;do{var C=Hn(t,l),w=C[0],p=C[1],y=C[2],E=p-y-a*w;(w||E)&&qn(t,l)&&(h+=E,g+=w),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!m&&l!==document.body||m&&(n.contains(l)||n===l));return(f&&Math.abs(h)<1||!f&&Math.abs(g)<1)&&(u=!0),u},Qe=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},Gn=function(t){return[t.deltaX,t.deltaY]},Xn=function(t){return t&&"current"in t?t.current:t},ao=function(t,n){return t[0]===n[0]&&t[1]===n[1]},so=function(t){return`
39
39
  .block-interactivity-`.concat(t,` {pointer-events: none;}
40
40
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
41
- `)},lo=0,we=[];function co(t){var n=v.useRef([]),e=v.useRef([0,0]),r=v.useRef(),o=v.useState(lo++)[0],a=v.useState(kn)[0],s=v.useRef(t);v.useEffect(function(){s.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Di([t.lockRef.current],(t.shards||[]).map(Xn),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=v.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!s.current.allowPinchZoom;var x=Qe(p),I=e.current,b="deltaX"in p?p.deltaX:I[0]-x[0],S="deltaY"in p?p.deltaY:I[1]-x[1],N,D=p.target,F=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in p&&F==="h"&&D.type==="range")return!1;var L=Wn(F,D);if(!L)return!0;if(L?N=F:(N=F==="v"?"h":"v",L=Wn(F,D)),!L)return!1;if(!r.current&&"changedTouches"in p&&(b||S)&&(r.current=N),!N)return!0;var M=r.current||N;return oo(M,y,p,M==="h"?b:S)},[]),m=v.useCallback(function(p){var y=p;if(!(!we.length||we[we.length-1]!==a)){var x="deltaY"in y?Gn(y):Qe(y),I=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&ao(N.delta,x)})[0];if(I&&I.should){y.cancelable&&y.preventDefault();return}if(!I){var b=(s.current.shards||[]).map(Xn).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=b.length>0?l(y,b[0]):!s.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),u=v.useCallback(function(p,y,x,I){var b={name:p,delta:y,target:x,should:I,shadowParent:uo(x)};n.current.push(b),setTimeout(function(){n.current=n.current.filter(function(S){return S!==b})},1)},[]),f=v.useCallback(function(p){e.current=Qe(p),r.current=void 0},[]),h=v.useCallback(function(p){u(p.type,Gn(p),p.target,l(p,t.lockRef.current))},[]),g=v.useCallback(function(p){u(p.type,Qe(p),p.target,l(p,t.lockRef.current))},[]);v.useEffect(function(){return we.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",m,Ce),document.addEventListener("touchmove",m,Ce),document.addEventListener("touchstart",f,Ce),function(){we=we.filter(function(p){return p!==a}),document.removeEventListener("wheel",m,Ce),document.removeEventListener("touchmove",m,Ce),document.removeEventListener("touchstart",f,Ce)}},[]);var C=t.removeScrollBar,w=t.inert;return v.createElement(v.Fragment,null,w?v.createElement(a,{styles:so(o)}):null,C?v.createElement(Zi,{gapMode:t.gapMode}):null)}function uo(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const fo=$i($n,co);var Kn=v.forwardRef(function(t,n){return v.createElement(Xe,Z({},t,{ref:n,sideCar:fo}))});Kn.classNames=Xe.classNames;var ho=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},Ie=new WeakMap,Ye=new WeakMap,Je={},Mt=0,Qn=function(t){return t&&(t.host||Qn(t.parentNode))},po=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=Qn(e);return r&&t.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e})},mo=function(t,n,e,r){var o=po(n,Array.isArray(t)?t:[t]);Je[e]||(Je[e]=new WeakMap);var a=Je[e],s=[],l=new Set,m=new Set(o),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};o.forEach(u);var f=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))f(g);else try{var C=g.getAttribute(r),w=C!==null&&C!=="false",p=(Ie.get(g)||0)+1,y=(a.get(g)||0)+1;Ie.set(g,p),a.set(g,y),s.push(g),p===1&&w&&Ye.set(g,!0),y===1&&g.setAttribute(e,"true"),w||g.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",g,x)}})};return f(n),l.clear(),Mt++,function(){s.forEach(function(h){var g=Ie.get(h)-1,C=a.get(h)-1;Ie.set(h,g),a.set(h,C),g||(Ye.has(h)||h.removeAttribute(r),Ye.delete(h)),C||h.removeAttribute(e)}),Mt--,Mt||(Ie=new WeakMap,Ie=new WeakMap,Ye=new WeakMap,Je={})}},go=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=ho(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),mo(r,o,e,"aria-hidden")):function(){return null}},At="Dialog",[Yn,ta]=Zr(At),[vo,Q]=Yn(At),Jn=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=v.useRef(null),m=v.useRef(null),[u=!1,f]=ni({prop:r,defaultProp:o,onChange:a});return i.jsx(vo,{scope:n,triggerRef:l,contentRef:m,contentId:Ct(),titleId:Ct(),descriptionId:Ct(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:s,children:e})};Jn.displayName=At;var Zn="DialogTrigger",Rn=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Zn,e),a=ue(n,o.triggerRef);return i.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bt(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});Rn.displayName=Zn;var Pt="DialogPortal",[yo,er]=Yn(Pt,{forceMount:void 0}),tr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Q(Pt,n);return i.jsx(yo,{scope:n,forceMount:e,children:v.Children.map(r,s=>i.jsx(We,{present:e||a.open,children:i.jsx(On,{asChild:!0,container:o,children:s})}))})};tr.displayName=Pt;var Ze="DialogOverlay",nr=v.forwardRef((t,n)=>{const e=er(Ze,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Q(Ze,t.__scopeDialog);return a.modal?i.jsx(We,{present:r||a.open,children:i.jsx(bo,{...o,ref:n})}):null});nr.displayName=Ze;var bo=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Ze,e);return i.jsx(Kn,{as:wt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(ne.div,{"data-state":Bt(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),he="DialogContent",rr=v.forwardRef((t,n)=>{const e=er(he,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Q(he,t.__scopeDialog);return i.jsx(We,{present:r||a.open,children:a.modal?i.jsx(Co,{...o,ref:n}):i.jsx(wo,{...o,ref:n})})});rr.displayName=he;var Co=v.forwardRef((t,n)=>{const e=Q(he,t.__scopeDialog),r=v.useRef(null),o=ue(n,e.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return go(a)},[]),i.jsx(ir,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(t.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=e.triggerRef.current)==null||s.focus()}),onPointerDownOutside:oe(t.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:oe(t.onFocusOutside,a=>a.preventDefault())})}),wo=v.forwardRef((t,n)=>{const e=Q(he,t.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return i.jsx(ir,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=t.onCloseAutoFocus)==null||s.call(t,a),a.defaultPrevented||(r.current||(l=e.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var m,u;(m=t.onInteractOutside)==null||m.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((u=e.triggerRef.current)==null?void 0:u.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ir=v.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Q(he,e),m=v.useRef(null),u=ue(n,m);return Li(),i.jsxs(i.Fragment,{children:[i.jsx(Ln,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Sn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Bt(l.open),...s,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Eo,{titleId:l.titleId}),i.jsx(To,{contentRef:m,descriptionId:l.descriptionId})]})]})}),Ot="DialogTitle",Io=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Ot,e);return i.jsx(ne.h2,{id:o.titleId,...r,ref:n})});Io.displayName=Ot;var or="DialogDescription",xo=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(or,e);return i.jsx(ne.p,{id:o.descriptionId,...r,ref:n})});xo.displayName=or;var ar="DialogClose",sr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(ar,e);return i.jsx(ne.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});sr.displayName=ar;function Bt(t){return t?"open":"closed"}var lr="DialogTitleWarning",[na,cr]=Jr(lr,{contentName:he,titleName:Ot,docsSlug:"dialog"}),Eo=({titleId:t})=>{const n=cr(lr),e=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
41
+ `)},lo=0,we=[];function co(t){var n=v.useRef([]),e=v.useRef([0,0]),r=v.useRef(),o=v.useState(lo++)[0],a=v.useState(kn)[0],s=v.useRef(t);v.useEffect(function(){s.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var p=Di([t.lockRef.current],(t.shards||[]).map(Xn),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=v.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!s.current.allowPinchZoom;var E=Qe(p),I=e.current,b="deltaX"in p?p.deltaX:I[0]-E[0],S="deltaY"in p?p.deltaY:I[1]-E[1],N,D=p.target,F=Math.abs(b)>Math.abs(S)?"h":"v";if("touches"in p&&F==="h"&&D.type==="range")return!1;var L=Wn(F,D);if(!L)return!0;if(L?N=F:(N=F==="v"?"h":"v",L=Wn(F,D)),!L)return!1;if(!r.current&&"changedTouches"in p&&(b||S)&&(r.current=N),!N)return!0;var A=r.current||N;return oo(A,y,p,A==="h"?b:S)},[]),m=v.useCallback(function(p){var y=p;if(!(!we.length||we[we.length-1]!==a)){var E="deltaY"in y?Gn(y):Qe(y),I=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&ao(N.delta,E)})[0];if(I&&I.should){y.cancelable&&y.preventDefault();return}if(!I){var b=(s.current.shards||[]).map(Xn).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=b.length>0?l(y,b[0]):!s.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),u=v.useCallback(function(p,y,E,I){var b={name:p,delta:y,target:E,should:I,shadowParent:uo(E)};n.current.push(b),setTimeout(function(){n.current=n.current.filter(function(S){return S!==b})},1)},[]),f=v.useCallback(function(p){e.current=Qe(p),r.current=void 0},[]),h=v.useCallback(function(p){u(p.type,Gn(p),p.target,l(p,t.lockRef.current))},[]),g=v.useCallback(function(p){u(p.type,Qe(p),p.target,l(p,t.lockRef.current))},[]);v.useEffect(function(){return we.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",m,Ce),document.addEventListener("touchmove",m,Ce),document.addEventListener("touchstart",f,Ce),function(){we=we.filter(function(p){return p!==a}),document.removeEventListener("wheel",m,Ce),document.removeEventListener("touchmove",m,Ce),document.removeEventListener("touchstart",f,Ce)}},[]);var C=t.removeScrollBar,w=t.inert;return v.createElement(v.Fragment,null,w?v.createElement(a,{styles:so(o)}):null,C?v.createElement(Zi,{gapMode:t.gapMode}):null)}function uo(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const fo=$i($n,co);var Kn=v.forwardRef(function(t,n){return v.createElement(Xe,Z({},t,{ref:n,sideCar:fo}))});Kn.classNames=Xe.classNames;var ho=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},Ie=new WeakMap,Ye=new WeakMap,Je={},Mt=0,Qn=function(t){return t&&(t.host||Qn(t.parentNode))},po=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=Qn(e);return r&&t.contains(r)?r:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e})},mo=function(t,n,e,r){var o=po(n,Array.isArray(t)?t:[t]);Je[e]||(Je[e]=new WeakMap);var a=Je[e],s=[],l=new Set,m=new Set(o),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};o.forEach(u);var f=function(h){!h||m.has(h)||Array.prototype.forEach.call(h.children,function(g){if(l.has(g))f(g);else try{var C=g.getAttribute(r),w=C!==null&&C!=="false",p=(Ie.get(g)||0)+1,y=(a.get(g)||0)+1;Ie.set(g,p),a.set(g,y),s.push(g),p===1&&w&&Ye.set(g,!0),y===1&&g.setAttribute(e,"true"),w||g.setAttribute(r,"true")}catch(E){console.error("aria-hidden: cannot operate on ",g,E)}})};return f(n),l.clear(),Mt++,function(){s.forEach(function(h){var g=Ie.get(h)-1,C=a.get(h)-1;Ie.set(h,g),a.set(h,C),g||(Ye.has(h)||h.removeAttribute(r),Ye.delete(h)),C||h.removeAttribute(e)}),Mt--,Mt||(Ie=new WeakMap,Ie=new WeakMap,Ye=new WeakMap,Je={})}},go=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=ho(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),mo(r,o,e,"aria-hidden")):function(){return null}},At="Dialog",[Yn,ta]=Zr(At),[vo,Q]=Yn(At),Jn=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=v.useRef(null),m=v.useRef(null),[u=!1,f]=ni({prop:r,defaultProp:o,onChange:a});return i.jsx(vo,{scope:n,triggerRef:l,contentRef:m,contentId:Ct(),titleId:Ct(),descriptionId:Ct(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:s,children:e})};Jn.displayName=At;var Zn="DialogTrigger",Rn=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Zn,e),a=ue(n,o.triggerRef);return i.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Bt(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});Rn.displayName=Zn;var Pt="DialogPortal",[yo,er]=Yn(Pt,{forceMount:void 0}),tr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Q(Pt,n);return i.jsx(yo,{scope:n,forceMount:e,children:v.Children.map(r,s=>i.jsx(We,{present:e||a.open,children:i.jsx(On,{asChild:!0,container:o,children:s})}))})};tr.displayName=Pt;var Ze="DialogOverlay",nr=v.forwardRef((t,n)=>{const e=er(Ze,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Q(Ze,t.__scopeDialog);return a.modal?i.jsx(We,{present:r||a.open,children:i.jsx(bo,{...o,ref:n})}):null});nr.displayName=Ze;var bo=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Ze,e);return i.jsx(Kn,{as:wt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(ne.div,{"data-state":Bt(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),he="DialogContent",rr=v.forwardRef((t,n)=>{const e=er(he,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Q(he,t.__scopeDialog);return i.jsx(We,{present:r||a.open,children:a.modal?i.jsx(Co,{...o,ref:n}):i.jsx(wo,{...o,ref:n})})});rr.displayName=he;var Co=v.forwardRef((t,n)=>{const e=Q(he,t.__scopeDialog),r=v.useRef(null),o=ue(n,e.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return go(a)},[]),i.jsx(ir,{...t,ref:o,trapFocus:e.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:oe(t.onCloseAutoFocus,a=>{var s;a.preventDefault(),(s=e.triggerRef.current)==null||s.focus()}),onPointerDownOutside:oe(t.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&a.preventDefault()}),onFocusOutside:oe(t.onFocusOutside,a=>a.preventDefault())})}),wo=v.forwardRef((t,n)=>{const e=Q(he,t.__scopeDialog),r=v.useRef(!1),o=v.useRef(!1);return i.jsx(ir,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var s,l;(s=t.onCloseAutoFocus)==null||s.call(t,a),a.defaultPrevented||(r.current||(l=e.triggerRef.current)==null||l.focus(),a.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:a=>{var m,u;(m=t.onInteractOutside)==null||m.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((u=e.triggerRef.current)==null?void 0:u.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),ir=v.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Q(he,e),m=v.useRef(null),u=ue(n,m);return Li(),i.jsxs(i.Fragment,{children:[i.jsx(Ln,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Sn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Bt(l.open),...s,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Eo,{titleId:l.titleId}),i.jsx(To,{contentRef:m,descriptionId:l.descriptionId})]})]})}),Ot="DialogTitle",Io=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(Ot,e);return i.jsx(ne.h2,{id:o.titleId,...r,ref:n})});Io.displayName=Ot;var or="DialogDescription",xo=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(or,e);return i.jsx(ne.p,{id:o.descriptionId,...r,ref:n})});xo.displayName=or;var ar="DialogClose",sr=v.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Q(ar,e);return i.jsx(ne.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});sr.displayName=ar;function Bt(t){return t?"open":"closed"}var lr="DialogTitleWarning",[na,cr]=Jr(lr,{contentName:he,titleName:Ot,docsSlug:"dialog"}),Eo=({titleId:t})=>{const n=cr(lr),e=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
42
42
 
43
43
  If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
44
44
 
45
- For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},So="DialogDescriptionWarning",To=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${cr(So).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},zt=Jn,No=Rn,_t=tr,Vt=nr,$t=rr,dr=sr,Re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},et={exports:{}},Fo=et.exports,ur;function Lo(){return ur||(ur=1,function(t,n){(function(e,r){r()})(Fo,function(){function e(u,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function r(u,f,h){var g=new XMLHttpRequest;g.open("GET",u),g.responseType="blob",g.onload=function(){m(g.response,f,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(u){var f=new XMLHttpRequest;f.open("HEAD",u,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(f)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Re=="object"&&Re.global===Re?Re:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),m=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,f,h){var g=s.URL||s.webkitURL,C=document.createElement("a");f=f||u.name||"download",C.download=f,C.rel="noopener",typeof u=="string"?(C.href=u,C.origin===location.origin?a(C):o(C.href)?r(u,f,h):a(C,C.target="_blank")):(C.href=g.createObjectURL(u),setTimeout(function(){g.revokeObjectURL(C.href)},4e4),setTimeout(function(){a(C)},0))}:"msSaveOrOpenBlob"in navigator?function(u,f,h){if(f=f||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(e(u,h),f);else if(o(u))r(u,f,h);else{var g=document.createElement("a");g.href=u,g.target="_blank",setTimeout(function(){a(g)})}}:function(u,f,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof u=="string")return r(u,f,h);var C=u.type==="application/octet-stream",w=/constructor/i.test(s.HTMLElement)||s.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||C&&w||l)&&typeof FileReader<"u"){var y=new FileReader;y.onloadend=function(){var b=y.result;b=p?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=b:location=b,g=null},y.readAsDataURL(u)}else{var x=s.URL||s.webkitURL,I=x.createObjectURL(u);g?g.location=I:location.href=I,g=null,setTimeout(function(){x.revokeObjectURL(I)},4e4)}});s.saveAs=m.saveAs=m,t.exports=m})}(et)),et.exports}var kt=Lo();const Ut=d.memo(t=>{const{file:n,onClose:e}=t,r=d.useRef(null),o=d.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(m=>{m&&navigator.clipboard.write([new ClipboardItem({"image/png":m})])},"image/png")},[]),a=d.useCallback(()=>{kt.saveAs(n,n.name)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsx(_t,{children:i.jsx(Vt,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(c.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{children:i.jsx(c.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(c.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{children:i.jsx(c.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(c.Separator,{orientation:"vertical",size:"sm"}),i.jsx(dr,{asChild:!0,children:i.jsx(c.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Ut.displayName="ImageViewer";const fr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),a=d.useCallback(m=>{r(m(o))},[o]),s=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=d.useMemo(()=>a,[a]);return i.jsxs(Cn.Provider,{value:l,children:[n,e&&i.jsx(Ut,{file:e.file,onClose:s})]})});fr.displayName="FileViewerProvider";const Y=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[m,u]=d.useState(void 0),f=Ue(),h=o?de[o]:"base";d.useEffect(()=>{l instanceof Promise?l.then(u).catch(console.error):u(l)},[l]);const g=m?URL.createObjectURL(m):void 0,C=d.useCallback(()=>{m&&f(()=>({file:m}))},[f,m]);return i.jsxs("div",{className:"flex flex-col gap-1",children:[m&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:m.name,onClick:C}),i.jsx("label",{className:ve(n,"flex flex-col gap-1 w-max"),htmlFor:a,children:i.jsx(c.Text,{accentColor:h,size:"sm",id:s,weight:"medium",children:e})}),r]})},jt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?de[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,!!n&&i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(c.Text,{accentColor:o,size:"xs",children:n})})]})},J=t=>{const{children:n,...e}=t;return i.jsx(jt,{...e,children:n})},Do=[!0,"true"],Wt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onBlur:g,onChange:C}=u,w=a?null:l,p=a?"":m,y=Do.includes(u.value),x=d.useCallback(()=>{g(y)},[g,y]);return i.jsx(J,{helpText:w,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(c.Checkbox.Root,{id:n,name:h,value:y.toString(),checked:y,onCheckedChange:C,onBlur:x,size:"sm",accentColor:"primary",variant:"surface",...f,children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})})})})});Wt.displayName="BooleanInput";const hr={...H,type:"boolean"},Ee=class Ee extends k{constructor(e){super({...e,type:"boolean"});T(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new Ee(e)}getInput(e){return i.jsx(Wt,{...e,field:this})}};T(Ee,"fieldTypeName","Checkbox"),T(Ee,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),T(Ee,"Icon",$.RiCheckboxCircleLine);let xe=Ee;const qt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C}=u,[w,p]=d.useState(!1),y=a?null:l,x=a?"":m,I=u.value?new Date(u.value):void 0,b=d.useCallback(N=>{N&&g(N.toISOString()),p(!1)},[g]),S=d.useCallback(N=>{p(N),N||C(u.value)},[u.value,C]);return i.jsx(J,{helpText:y,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:x,image:a?void 0:s.image,children:i.jsxs(c.Popover.Root,{open:w,onOpenChange:S,children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:"sm",...f,children:[I?I.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(c.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(c.Popover.Content,{align:"start",children:i.jsx(c.DayPicker,{required:!1,mode:"single",variant:"solid",selected:I,onSelect:b})})]})})})});qt.displayName="DateInput";const pr={...H,type:"date"},Se=class Se extends k{constructor(e){super({...e,type:"date"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(qt,{field:this,...e})}};T(Se,"fieldTypeName","Date"),T(Se,"fieldTypeDescription","Allows specifying a date."),T(Se,"Icon",$.RiCalendarLine);let tt=Se;const mr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=V.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ut(a):null},[n.options,r]);return Ht(o,e)});mr.displayName="FieldInputCloner";const Mo={...H,type:"custom"};class nt extends k{constructor(e,r){super({...e,type:"custom"});T(this,"Component");T(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}T(nt,"fieldTypeName","Custom"),T(nt,"fieldTypeDescription","Allows re-rendering of field already in the form");class Ao extends nt{constructor(n){super(n,mr)}}const Ht=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Be=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx(d.Fragment,{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-4",children:e})},pe=t=>t.type==="section",rt=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Po=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(rt(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(rt("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function Gt(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function gr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function it(t,n){const e=Array.from(t);return e.splice(n,1),e}const Xt=(t,n)=>{const e=new Date;return`${ie.slugify(n)}-${e.getTime()}`},vr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=vr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},yr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),ot=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:Xt(null,a)},l=K(r,t);if(l===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(l))throw new Error("Parent path must point to an array.");const m=gr(l,n,s);o(t,m).then()},Oo=(t,n,e)=>{const r={...rt(),label:""};ot("fields",t,r,n,e)},Kt=()=>{const{showError:t}=c.useToast(),n=d.useCallback((r,o,a,s,l,m)=>{const u=r[o];if(!u)throw new Error("Could not find section context.");let f=typeof u.conditionIndex<"u"?Math.max(u.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}m("fields",Gt(l.fields,a,f))},[t]),e=d.useCallback((r,o,a,s,l,m,u)=>{var f;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)u(`fields.${o}.fields`,Gt(r.fields,a,m)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=s.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}u(`fields.${o}.fields`,it(r.fields,a)).then(),u(`fields.${l}.fields`,gr(s.fields,m,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Qt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),h=a?null:l,g=a?"":m,{name:C,onChange:w,onBlur:p}=u,y=d.useMemo(()=>Array.isArray(u.value)?u.value:[],[u.value]),x=`${n}-droppable`,{disabled:I}=f,[b,S]=d.useState(""),[N,D]=d.useState(""),F=N||h,L=d.useCallback(P=>{w(P),p(P)},[w,p]),M=d.useCallback(P=>{y.findIndex(W=>W===P.target.value.trim())>=0?D("All options must be unique"):P.target.value?D(""):D("Option cannot be empty"),S(P.target.value)},[S,y]),z=d.useCallback(()=>{if(N)return;if(!b.trim()){D("Option cannot be empty");return}const P=b.trim();L([...y,P]),S("")},[b,N,L,y]),q=d.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),z())},[z]),ee=d.useCallback(P=>{L(it(y,P))},[y,L]),B=d.useCallback(P=>{if(!P.destination)return;const W=P.source.index,le=P.destination.index;L(Gt(y,W,le))},[L,y]),X=d.useCallback(()=>{p(y)},[p,y]);return i.jsx(re.DragDropContext,{onDragEnd:B,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(J,{helpText:F,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:(!I||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{value:b,onChange:M,onKeyDown:q,id:n,placeholder:s.placeholder,onBlur:X,name:C,...f})}),i.jsx(c.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!N||I,onClick:z,children:i.jsx(c.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(re.Droppable,{droppableId:x,children:P=>i.jsxs("div",{className:"flex flex-col",...P.droppableProps,ref:P.innerRef,children:[y.map((W,le)=>i.jsx(re.Draggable,{draggableId:`${W}-draggable`,index:le,isDragDisabled:I,children:({draggableProps:te,dragHandleProps:ce,innerRef:Oe})=>i.jsxs(c.Badge,{...ce,...te,ref:Oe,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof W=="object"&&"label"in W?W.label:W}),i.jsx(c.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:I,onClick:()=>{ee(le)},children:i.jsx(c.RiIcon,{icon:"RiCloseLargeLine"})})]})},W)),P.placeholder]})})]})})});Qt.displayName="MultiStringInput";const br={...H,type:"multi-string",minimum_length:0,maximum_length:null},Te=class Te extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});T(this,"minLength");T(this,"maxLength");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(Qt,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Te(e)}};T(Te,"fieldTypeName","Multi-string"),T(Te,"fieldTypeDescription","Allows the user to provide multiple unique strings."),T(Te,"Icon",$.RiListCheck);let ze=Te;const Yt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{const L=Number.parseFloat(F.target.value),M=Number.isNaN(L)?"":L;S(M),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(M))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:x,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,onChange:N,onBlur:D,value:b,type:"number",min:s.minimum,max:s.maximum,step:s.integers?1:.1,placeholder:s.placeholder,...g})})})})});Yt.displayName="NumberInput";const Cr={...H,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},wr=t=>"fields"in t,R=class R extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});T(this,"minimum");T(this,"maximum");T(this,"integers");T(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new R({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new R({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new xe({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new R(e)}getInput(e){return i.jsx(Yt,{field:this,...e})}};T(R,"fieldTypeName","Number"),T(R,"fieldTypeDescription","Allows specifying a number within a given range."),T(R,"Icon",$.RiHashtag),T(R,"_validateMin",e=>(r,o)=>{const a=wr(o)?K(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),T(R,"_validateMax",e=>(r,o)=>{const a=wr(o)?K(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let se=R;const Jt=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:m,fieldProps:u},f]=G(t),{name:h,onBlur:g,onChange:C,value:w}=u,[p,y]=d.useState(!1),x=l?null:o,I=l?"":r,b=d.useCallback(D=>{C(D),y(!1)},[C]),S=d.useCallback(()=>{C("")},[C]),N=d.useCallback(D=>{y(D),D||g(w)},[g,w]);return i.jsx(J,{helpText:x,severity:s,children:i.jsxs(Y,{size:a,severity:s,inputId:n,labelId:e,label:I,image:l?void 0:m.image,className:"flex-col items-start justify-start gap-2",children:[i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(zt,{open:p,onOpenChange:N,children:[i.jsx(No,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",variant:"soft",size:"sm",accentColor:"base",...f,children:[i.jsx(c.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]})}),i.jsxs(_t,{children:[i.jsx(Vt,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx($t,{className:"fixed inset-0",children:i.jsx(Zt,{onQrScan:b})})]})]}),w&&i.jsx(c.RiIcon,{icon:"RiCheckLine",className:"align-bottom text-(--primary-a11)"})]}),!!w&&i.jsx(c.Card,{className:"max-w-full w-max",size:"sm",children:i.jsxs("div",{className:"max-w-full w-max flex justify-between gap-2",children:[i.jsx("code",{className:"bg-(--base-a3) truncate text-sm",children:w}),i.jsx(c.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Jt.displayName="QrInput";const Zt=d.memo(t=>{const{onQrScan:n}=t,e=d.useRef(null),[r,o]=d.useState(!1);return d.useEffect(()=>{if(!e.current)return;const a=new Hr(e.current,s=>{const l=s.data;n(l),a.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});o(!0),a.start().finally(()=>{o(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(dr,{asChild:!0,children:i.jsx(c.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{className:"size-full",ref:e}),r&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(c.Spinner,{})})]})]})});Zt.displayName="QrScanner";const Ir={...H,type:"qr"},Ne=class Ne extends k{constructor(e){super({...e,type:"qr"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Ne(e)}getInput(e){return i.jsx(Jt,{...e,field:this})}};T(Ne,"fieldTypeName","QR"),T(Ne,"fieldTypeDescription","Used for scanning/reading QR codes."),T(Ne,"Icon",$.RiQrCodeLine);let at=Ne;class xr extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);T(this,"options");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ze({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const Bo=t=>t?Array.isArray(t)?t:[t]:[],Rt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C}=u,w=a?null:l,p=a?"":m,y=d.useMemo(()=>Bo(u.value),[u.value]),x=d.useCallback(b=>{g(b),C(b)},[C,g]),I=d.useCallback(b=>{b||C(y)},[y,C]);return i.jsx(J,{helpText:w,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{onOpenChange:I,align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",variant:"surface",type:"button",size:"sm",accentColor:"base",...f,children:[i.jsx("span",{className:"truncate",children:y.length>0?y.join(", "):s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsxs(c.Menu.MultiSelectGroup,{values:y,onValuesChange:x,children:[i.jsxs(c.Menu.SelectAllItem,{children:[i.jsx(c.Menu.CheckboxItemIndicator,{children:b=>b?i.jsx(c.RiIcon,{icon:"RiSubtractLine"}):i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(b=>i.jsxs(c.Menu.MultiSelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))]})})})]})})})});Rt.displayName="MultiSelectInput";const Er={...H,type:"multi-select",options:[]},Fe=class Fe extends xr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Fe(n)}getInput(n){return i.jsx(Rt,{field:this,...n})}};T(Fe,"fieldTypeName","Multi-select"),T(Fe,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),T(Fe,"Icon",$.RiCheckboxLine);let _e=Fe;const en=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C,value:w}=u,p=a?null:l,y=a?"":m,x=d.useCallback(b=>{b&&(g(b),C(b))},[C,g]),I=d.useMemo(()=>s.options.find(b=>b.value===w),[s.options,w]);return i.jsx(J,{helpText:p,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:y,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:"sm",...f,children:[i.jsx("span",{className:"truncate",children:I?I.label:s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsx(c.Menu.SelectGroup,{required:!0,value:w,onValueChange:x,children:s.options.map(b=>i.jsxs(c.Menu.SelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))})})})]})})})});en.displayName="SelectInput";const Sr={...H,type:"select",options:[]},Le=class Le extends xr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new Le(n)}getInput(n){return i.jsx(en,{field:this,...n})}};T(Le,"fieldTypeName","Dropdown"),T(Le,"fieldTypeDescription","Allows the user to select a single option from a list of options."),T(Le,"Icon",$.RiMenuFoldLine);let Ve=Le;const Tr=t=>"fields"in t;class st extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);T(this,"minLength");T(this,"maxLength");T(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):ye,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new se({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:ye,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}T(st,"_validateMin",e=>(r,o)=>{const a=Tr(o)?K(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),T(st,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Tr(o)?K(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const tn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:x,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,value:b,type:s.inputType,placeholder:s.placeholder,onChange:N,onBlur:D,...g})})})})});tn.displayName="StringInput";const Nr={...H,type:"string",maximum_length:ke,input_type:"text"},De=class De extends st{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ke,e.maxLength):ke,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});T(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...s}=e;return new De({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(tn,{field:this,...e})}};T(De,"fieldTypeName","Short Text"),T(De,"fieldTypeDescription",`Short text fields can hold up to ${ke} characters on a single line.`),T(De,"Icon",$.RiInputField);let lt=De;const nn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,x=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:x,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.TextArea,{id:n,value:b,name:C,onChange:N,onBlur:D,className:"field-sizing-content min-h-12",placeholder:s.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:"sm",...g})})})});nn.displayName="TextInput";const Fr={...H,type:"text",maximum_length:ye},Me=class Me extends st{constructor(n){const e=n.maxLength?Math.min(ye,n.maxLength):ye,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Me({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(nn,{field:this,...n})}};T(Me,"fieldTypeName","Paragraph"),T(Me,"fieldTypeDescription",`Paragraph fields can hold up to ${ye} characters and can have multiple lines.`),T(Me,"Icon",$.RiAlignJustify);let ct=Me;const Lr=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,...l}=t;return i.jsxs("div",{className:ve(s,"relative flex h-[200px] w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...l,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(c.Spinner,{})}),i.jsx("div",{className:"-m-4 flex max-w-full grow items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:ve("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx($e,{fileType:e.type}),i.jsx(c.Text,{className:"truncate",size:"sm",children:o??(e==null?void 0:e.name)}),a]})]})})),zo=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},Dr=d.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:m},u]=G(t),{name:f,value:h,onChange:g,onBlur:C}=m;let[{label:w}]=G(t);w=s?"":w;const p=d.useRef(null),y=d.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),x=d.useCallback(()=>{var L;(L=p.current)==null||L.click()},[]),I=d.useCallback(()=>{if(!p.current)return;const L=p.current.files;if(!L){C([]);return}const M=Array.from(L);g(M),C(M)},[C,g]),b=d.useCallback(L=>{const M=[...h];M.splice(L,1),g(M)},[h,g]);d.useEffect(()=>{if(!p.current)return;const L=new AbortController;return p.current.addEventListener("cancel",()=>{C([]),console.debug("UploadInput: onBlur",h)},{signal:L.signal}),()=>{L.abort()}},[C,h]);const S=h?"Select new files":"Select files",N=h?"Select new file":"Select a file",D=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(J,{helpText:y,severity:o,children:i.jsxs(Y,{size:r,severity:o,inputId:n,labelId:e,label:w,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(c.Button,{className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:x,id:"upload-input-upload-button",type:"button",...u,children:[i.jsx(c.RiIcon,{icon:"RiUpload2Line"})," ",D]})}),i.jsx("input",{id:n,name:f,type:"file",ref:p,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:I,value:""})]})}),Array.isArray(h)&&h.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:h.map((L,M)=>i.jsx(Mr,{field:l,file:L,onRemove:()=>{b(M)},disabled:u.disabled},M))})]})});Dr.displayName="UploadInput";const Mr=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=d.useState(null),l=Ue(),m=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:u,name:f}=d.useMemo(()=>{let p=null,y,x;return a!=null&&a.type.startsWith("image/")&&(p=URL.createObjectURL(a)),a?(y=a.name,x=zo(a.size)):(y="Downloading...",x="..."),{url:p,name:y,size:x}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=d.useCallback(p=>{if(p.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const y=new Blob([a]);kt.saveAs(y,f)},[f,a]),g=d.useCallback(p=>{p.stopPropagation(),r()},[r]),C=d.useCallback(()=>{a&&l(p=>({file:a,onDelete:o?void 0:()=>{r(),p()}}))},[o,r,l,a]),w=d.useMemo(()=>i.jsxs(c.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(c.IconButton,{"aria-label":`Download ${f}`,type:"button",onClick:h,disabled:!a,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(c.IconButton,{type:"button","aria-label":`Remove ${f}`,disabled:o,onClick:g,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,f,a]);return u?i.jsx(Lr,{className:"cursor-pointer",onClick:C,file:a,error:m??void 0,rightSlot:w}):i.jsx(yt,{file:a,error:m??void 0,rightSlot:w})});Mr.displayName="DisplayFile";const _o={...H,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Ae=class Ae extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});T(this,"extensions");T(this,"maxFileSize");T(this,"maxFiles");T(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new se({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${dt}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:dt,integers:!0}),showDirectly:!1},{field:new _e({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??dt,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new Ae(e)}getInput(e){return i.jsx(Dr,{field:this,...e})}};T(Ae,"fieldTypeName","Upload"),T(Ae,"fieldTypeDescription","Allows a file to be uploaded."),T(Ae,"Icon",$.RiUpload2Line);let rn=Ae;const on={date:tt,number:se,boolean:xe,select:Ve,string:lt,text:ct,custom:nt,upload:rn,qr:at,"multi-string":ze,"multi-select":_e},Vo={date:pr,number:Cr,boolean:hr,select:Sr,string:Nr,text:Fr,custom:Mo,upload:_o,qr:Ir,"multi-string":br,"multi-select":Er},dt=50,$o=dt*1e3*1e3,an=t=>{const n=t.type;return on[n].deserialize(t)},ut=t=>t.type==="section"?U.deserialize(t):an(t);function Ar(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ut(r)),meta:{readonly:e}}}function sn(t){const n=[];for(const e of t.fields)if(e instanceof U)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function ko(t,n){const e=sn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Uo(t,n){const e=sn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function ft(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function ln(t,n){if(!t)return!0;if(ft(n)||ft(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const Pr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:m}=V.useFormikContext(),u=s!=null&&s.identifier?K(l,s.identifier):void 0,f=d.useMemo(()=>u===void 0||ln(s,u),[s,u]);d.useEffect(()=>{if(!f)for(const g of a)m(g.getId(),"").then()},[f,a,m]);const h=Be(a,e);return f?i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(c.Heading,{size:"md",children:r}),i.jsx(c.Text,{accentColor:"base",children:o})]}),i.jsx(c.Separator,{size:"full"})]}),h]})}):null});Pr.displayName="FieldSectionLayout";const Pe=class Pe extends bt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});T(this,"label");T(this,"fields");T(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new xe({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Pe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Ve({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new Ao({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(an);return new Pe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),s=o.getError(K(e,a),e);s&&gt(r,o.getId(),s)}return r}getInput(e){return i.jsx(Pr,{field:this,...e})}};T(Pe,"fieldTypeName","Section"),T(Pe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let U=Pe;const me=t=>Object.keys(t).length>0,ht=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof U){if(r.condition){const{identifier:o}=r.condition;if(!ln(r.condition,K(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(K(n,o),n);a&&gt(e,o,a)}if(me(e))return e},jo=[null,void 0],pt=(t,n)=>t.reduce((e,r)=>r instanceof U?{...e,...pt(r.fields,n)}:(jo.includes(K(e,r.getId()))&&gt(e,r.getId(),""),e),Gr(n)),Wo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Or=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onValuesChange:o,onSubmit:a=Wo,submitText:s="Submit",cancelText:l,onCancel:m,onDirty:u,onDirtyChange:f,hideTitle:h=!e.title,hideDescription:g,className:C,buttonProps:w}=t,{readonly:p}=e.meta,y=d.useMemo(()=>crypto.randomUUID(),[]),x=V.useFormik({initialValues:pt(e.fields,r),onSubmit:a,validate:F=>ht(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:I}=x,b=d.useMemo(()=>typeof e.title=="string"?i.jsx(c.Heading,{size:"md",children:e.title}):e.title,[e.title]),S=d.useMemo(()=>typeof e.description=="string"?i.jsx(c.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),N=d.useCallback((F,L)=>{o==null||o({...x.values,[F]:L})},[x.values,o]),D=Be(e.fields,{formId:y,disabled:p,onValuesChange:N});return d.useEffect(()=>{I&&u&&u(),f&&f(I)},[I,u,f]),i.jsx(V.FormikProvider,{value:x,children:i.jsxs("form",{id:y,ref:n,className:ve(C,"flex flex-col gap-2"),onSubmit:x.handleSubmit,children:[!h&&i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-1",children:[b,!g&&S]})}),D,!p&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(c.Button,{accentColor:de.danger,...w,type:"button",onClick:m,children:[i.jsx(c.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(c.Button,{...w,type:"submit",disabled:!x.isValid,accentColor:"success",children:[i.jsx(c.RiIcon,{icon:"RiCheckLine"}),s]})]})]})})})),ge=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=V.useFormikContext(),[o,a,s]=V.useField(n),l=d.useMemo(()=>{const m=u=>{s.setValue(u,!1)};return e({value:o.value,meta:a,setValue:m,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ge.displayName="PatchField";const qo=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:m,...u}=t,f=d.useMemo(()=>pt(r.fields,o),[r.fields,o]),h=d.useCallback(I=>{const b={};for(const S in I){const N=I[S];N!==f[S]&&N!==void 0&&(b[S]=N)}return b},[f]),g=d.useCallback(I=>{const b=h(I);l&&!me(b)||a(b)},[h,a,l]),C=d.useCallback(I=>{const b=ht(r,I);if(b&&s(b),m){const S=h(I);m(me(S))}return b},[r,m,s,h]),w=V.useFormik({initialValues:f,onSubmit:g,validate:C,validateOnBlur:!1,validateOnChange:!1}),p=d.useCallback(()=>{if(m){const I=h(w.values);me(I)&&m(!0)}},[w.values,h,m]),{errors:y,resetForm:x}=w;return d.useEffect(()=>{me(y)&&x({values:f,errors:{}})},[y,f,x]),i.jsx(V.FormikProvider,{value:w,children:i.jsx("form",{...u,ref:n,onSubmit:w.handleSubmit,onChange:p,children:e})})})),mt="form-builder",Ho=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],cn={...on,section:U},Go=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},Xo=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},Br=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,m=new Set(l);(r=s.condition)!=null&&r.identifier&&m.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:m,conditionIndex:Xo(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},dn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:m}=V.useFormikContext(),u=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:$.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:$.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:$.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=u.current)==null||g.click()}}}),(r===void 0&&n!==m.fields.length-1||r!==void 0&&(r<m.fields.length-1||n!==m.fields[r].fields.length-1))&&h.unshift({Icon:$.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:$.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,m.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(c.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:f.map(h=>i.jsx(c.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsx(c.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",type:"button",children:i.jsx(c.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(c.Menu.Content,{children:f.map(h=>{var g;return i.jsxs(c.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:u,type:"file",accept:"image/*",onChange:l})]})});dn.displayName="FieldActions";const un=d.memo(t=>{const{popoverInputs:n,hasError:e,...r}=t;return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:de.danger},children:[i.jsx(c.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(c.Popover.Content,{size:"sm",...r,children:i.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:n})})]})});un.displayName="FieldSettingsPopover";const zr=(t=()=>null)=>d.useMemo(()=>Ho.map(n=>n.map(e=>{const r=on[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),fn=d.memo(t=>{var Oe,hn,jr,Wr,qr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=V.useFormikContext(),m=zr(),u=Ue(),f=d.useRef(null),h=576,[g,C]=d.useState(f.current&&f.current.getBoundingClientRect().width>=h);d.useEffect(()=>{const A=f.current;if(A){const O=new ResizeObserver(j=>{j[0]&&C(j[0].contentRect.width>=h)});return O.observe(A),()=>{O.disconnect()}}},[]);const[w,p]=d.useState(void 0);d.useEffect(()=>{pe(r)?p(void 0):r.image instanceof Promise?r.image.then(p).catch(console.error):p(r.image)},[r]);const y=w?URL.createObjectURL(w):void 0,x=d.useCallback(A=>{A.stopPropagation();const{image:O,...j}=r;s(`${n}.${e}`,j).then()},[e,r,n,s]);d.useEffect(()=>{pe(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const I=d.useMemo(()=>{var A,O;return pe(r)?(O=vr(a.fields,(A=r.condition)==null?void 0:A.identifier))==null?void 0:O.label:void 0},[r,a.fields]),b=pe(r)?Array.isArray((Oe=r.condition)==null?void 0:Oe.value)?"contains all of":"equals":void 0;let S;if(pe(r)){if(ft((hn=r.condition)==null?void 0:hn.value))throw new Error("File values are not supported for conditions.");S=Array.isArray((jr=r.condition)==null?void 0:jr.value)?r.condition.value.map(A=>typeof A=="string"?A:A.label).join(", "):(qr=(Wr=r.condition)==null?void 0:Wr.value)==null?void 0:qr.toString()}const N=d.useCallback(A=>{A.target.parentNode instanceof HTMLElement&&(A.target.parentNode.dataset.replicatedValue=A.target.value)},[]),D=d.useCallback(A=>{A.target.parentNode instanceof HTMLElement&&(A.target.parentNode.dataset.replicatedValue=A.target.value)},[]),F=r.type,L=cn[F],[M,z]=d.useMemo(()=>{let A=[],O=[];if(L===U){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const j=L.getFieldCreationSchema(o,`${n}.${e}`);A=A.concat(j.filter(_=>_.showDirectly).map(_=>_.field)),O=O.concat(j.filter(_=>!_.showDirectly).map(_=>_.field))}else{if(!(L.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${L.toString()}.`);const j=L.getFieldCreationSchema(`${n}.${e}`);g?(A=[...A,...j.filter(_=>_.showDirectly).map(_=>_.field)],O=[...O,...j.filter(_=>!_.showDirectly).map(_=>_.field)]):O=[...O,...j.map(_=>_.field)]}return[A,O]},[L,o,n,e,g]),q=Be(M,{formId:mt,disabled:!1,...L===U&&{size:"sm"}}),ee=Be(z,{formId:mt,disabled:!1});let B=z.length>0;pe(r)&&z.length>0&&(B=r.conditional);const X=z.some(A=>{const O=K(l,L===U?`${n}.${e}.condition`:A.getId());return O&&(typeof O!="object"||me(O))}),P=X?de.danger:void 0,W=d.useMemo(()=>ut(r),[r]),le=Ht(W,{formId:mt,showInputOnly:!1}),te=d.useMemo(()=>m.flat().find(A=>A.value===F),[m,F]),ce=d.useCallback(()=>{w&&u(()=>({file:w}))},[u,w]);return i.jsx("div",{className:"flex grow items-center w-full",ref:f,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[L===U&&(M.length>0||B)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[q,B&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(un,{popoverInputs:ee,hasError:X,align:"start"}),pe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":P,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:I})," ",b," ",i.jsx("strong",{children:S})]})})]})]}),L!==U&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(c.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[te==null?void 0:te.icon,te==null?void 0:te.children]}),i.jsx(ge,{name:`${n}.${e}.required`,render:({setValue:A,value:O})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.Checkbox.Root,{checked:O,onCheckedChange:A,size:"sm",children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(c.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),B&&i.jsx(un,{popoverInputs:ee,hasError:X,align:"end"})]}),w&&i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:y,alt:w.name,onClick:ce}),i.jsx(c.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:x,size:"sm",children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ge,{name:`${n}.${e}.label`,render:({setValue:A,value:O})=>i.jsx("input",{className:"bg-transparent outline-none text-sm placeholder-(--base-a9)",placeholder:F==="section"?"Enter a section label (optional)":"Enter your question",value:O,onChange:j=>{A(j.target.value)},onInput:N,maxLength:200})}),i.jsx(ge,{name:`${n}.${e}.description`,render:({setValue:A,value:O})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow placeholder-(--base-a9)",placeholder:`Enter a ${F==="section"?"section":"field"} description (optional)`,value:O,onChange:j=>{A(j.target.value)},onInput:D,maxLength:1e3})}),L!==U&&M.length>0&&i.jsx("div",{className:"w-full",children:q}),L!==U&&i.jsxs(c.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(c.HoverCard.Root,{children:[i.jsx(c.HoverCard.Trigger,{asChild:!0,children:i.jsx(c.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(c.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow h-max",children:le})]})]})})});fn.displayName="FieldBuilder";const _r=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=V.useFormikContext(),{reorderField:l}=Kt(),{showInfo:m,showError:u}=c.useToast(),f=`fields.${r}.fields`,h=d.useMemo(()=>({index:e,parentPath:f,initial:n}),[n,e,f]),g=d.useCallback(()=>{const p=n.label||"Unlabelled field",y={...n,label:p};ot(f,e+1,y,s,a),m({title:"Field duplicated",description:`The field "${p}" has been duplicated`})},[n,f,e,s,a,m]),C=d.useCallback(p=>{const y=r,x=s.fields[y];let I=r,b=p==="up"?e-1:e+1;p==="up"&&e===0?(I=r-1,b=s.fields[I].fields.length):p==="down"&&e===x.fields.length-1&&(I=r+1,b=0);const S=s.fields[I];l(x,y,e,S,I,b,a)},[r,s.fields,e,l,a]),w=d.useCallback(p=>{const{files:y}=p.target;if(!y||y.length!==1)return;const x=y.item(0);if(x){if(x.size>$o){u({title:"File upload error",description:`The file ${x.name} exceeded the maximum file size`});return}a(`${f}.${e}`,{...n,image:x}).then()}},[n,e,f,a,u]);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:p=>i.jsx(c.Card,{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(fn,{...h}),i.jsx(dn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:g,move:C,upload:w})]})})})});_r.displayName="FieldWithActions";const Vr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:s,values:l}=V.useFormikContext(),m=c.useAlertDialog(),{reorderSection:u}=Kt(),{showInfo:f}=c.useToast(),h=d.useCallback((N,D)=>{for(const F of N){const L=D.indexOf(F);s(`fields.${L}.condition`,null).then(),s(`fields.${L}.conditional`,!1).then()}},[s]),g=d.useCallback(N=>{var L;const D=n.fields[N];if(!D)throw new Error("Could not find field to remove.");const F=[];for(const M of l.fields)((L=M.condition)==null?void 0:L.identifier)===D.identifier&&F.push(M);return{removing:D,affectedSections:F,action:()=>s(`fields.${e}.fields`,it(n.fields,N))}},[n.fields,l.fields,s,e]),C=d.useCallback(N=>{const{affectedSections:D,action:F,removing:L}=g(N),M=()=>{F().then(),h(D,l.fields)};if(D.length>0){const z=D.map(q=>q.label).join(", ");m({title:"Remove condition?",description:`${L.label} is being used as a condition, deleting it will remove the condition from the ${z} section(s).`,action:"Remove",onAction:M});return}M()},[g,h,l.fields,m]),w=d.useCallback(()=>{const D=n.fields.map((B,X)=>g(X)).flatMap(B=>B.affectedSections),F=D.length?"Remove fields and conditions?":"Remove fields?",L=n.fields.length,M=D.map(B=>B.label).join(", "),z=D.length?`Deleting this section will remove the ${L} field(s) it contains and will remove the conditions from following sections: ${M}`:`Deleting this section will remove the ${L} field(s) it contains.`,q=it(l.fields,e),ee=()=>s("fields",q);if(D.length>0){m({title:F,description:z,action:"Remove",onAction:()=>{ee().then(()=>{h(D,q)})}});return}ee().then()},[n.fields,l.fields,e,g,s,m,h]),p=d.useCallback(N=>{const D=N==="up"?e-1:e+1;u(r,n.identifier,e,D,l,s)},[e,u,r,n.identifier,l,s]),y=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:yr(l.fields,e)}),[n,e,l.fields]),x=d.useCallback(()=>{const N=n.label||"Untitled section",D=n.fields.map(L=>({...L,identifier:Xt(null,L.label)})),F={...n,label:N,fields:D};ot("fields",e+1,F,l,s),f({title:"Section duplicated",description:`The section "${N}" has been duplicated.`})},[n,e,l,s,f]),I=d.useCallback(N=>{ot(`fields.${e}.fields`,n.fields.length,Vo[N],l,s)},[e,n.fields.length,l,s]),b=zr(I);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:N=>i.jsx(c.Card,{ref:N.innerRef,...N.draggableProps,...N.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(fn,{...y}),i.jsx(re.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:D=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:D.innerRef,...D.droppableProps,children:[n.fields.map((F,L)=>i.jsx(_r,{field:F,index:L,sectionIndex:e,remove:()=>{C(L)}},F.identifier)),D.placeholder,i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(c.Menu.Content,{children:b.flat().map(F=>i.jsxs(c.Menu.Item,{onSelect:F.onSelect,children:[F.icon,F.children]},F.value))})]})]})})]}),!o&&i.jsx(dn,{index:e,type:n.type,remove:w,duplicate:x,move:p})]})})})});Vr.displayName="FieldSectionWithActions";const $r=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},kr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=V.useFormikContext(),[o,a]=d.useReducer(Go,e.fields,Br),{reorderSection:s,reorderField:l}=Kt();d.useEffect(()=>{a({type:"update",state:Br(e.fields)})},[a,e.fields]);const m=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),u=d.useCallback(h=>{const{source:g,destination:C,type:w,reason:p,draggableId:y}=h;if(a({type:"release"}),!C||p==="CANCEL")return;if(w==="ROOT"){s(o,y,g.index,C.index,e,r);return}if(w!=="SECTION")throw new Error("Unexpected droppable type.");const[x,I]=$r(e.fields,g.droppableId)??[],[b,S]=$r(e.fields,C.droppableId)??[];l(x,I,g.index,b,S,C.index,r)},[e,l,r,s,o]),f=d.useCallback(h=>{Oo(h+1,e,r)},[e,r]);return i.jsx(re.DragDropContext,{onDragStart:m,onDragEnd:u,children:i.jsx(re.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((g,C)=>i.jsxs(d.Fragment,{children:[i.jsx(Vr,{field:g,index:C,dropState:o,fieldsOnly:n}),!n&&C!==e.fields.length-1&&i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",size:"sm",accentColor:"base",onClick:()=>{f(C)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:()=>{f(e.fields.length)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});kr.displayName="FieldsEditor";const Ko=()=>{alert("This is a form preview, your data will not be saved.")},Qo=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:m=!1,showTabs:u=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:g}=c.useToast(),C=d.useCallback(I=>{const b={};I.title||(b.title="Title is required."),(!I.fields||I.fields.length===0)&&(b.fields="At least one field is required.");let S=[];for(const[D,F]of I.fields.entries()){const M=cn.section.getFieldCreationSchema(yr(I.fields,D),`fields.${D}`).map(z=>z.field);S=[...S,...M];for(const[z,q]of F.fields.entries()){const B=cn[q.type].getFieldCreationSchema(`fields.${D}.fields.${z}`).map(X=>X.field);S=[...S,...B]}}const N=ht({fields:S},I);if(N&&(b.fields=N.fields),me(b))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),b},[g]),w=d.useMemo(()=>({title:a??"",description:"",fields:[{...rt(Xt(null,"")),label:""}]}),[a]),p=o?h(o):void 0,y=V.useFormik({initialValues:Po(p)??w,validate:C,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),x=d.useMemo(()=>Ar(y.values),[y.values]);return i.jsx(c.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[u&&i.jsxs(c.Tabs.List,{className:ve("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(c.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(c.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(c.Tabs.Content,{value:"edit",children:[s&&i.jsxs(c.Text,{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:mt,onSubmit:y.handleSubmit,children:[i.jsxs(V.FormikProvider,{value:y,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ge,{name:"title",render:({setValue:I,value:b,meta:S})=>i.jsx(jt,{severity:"danger",helpText:S.error??null,children:i.jsx(c.Input.Root,{variant:"outline",size:"md",accentColor:S.error?de.danger:"primary",children:i.jsx(c.Input.Field,{placeholder:"Form title",value:b,onChange:N=>{I(N.target.value)},maxLength:100})})})}),i.jsx(ge,{name:"description",render:({setValue:I,value:b})=>i.jsx(c.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:b,onChange:S=>{I(S.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx(kr,{fieldsOnly:m}),i.jsx("span",{"data-accent-color":de.danger,className:"text-xs text-(--accent-a11)",children:typeof y.errors.fields=="string"&&y.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(c.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(c.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(c.Tabs.Content,{value:"preview",children:i.jsx(Or,{schema:x,onSubmit:Ko,hideTitle:!l})})]})})})),Yo=Object.values(ie.Colors),Jo=1;async function Zo(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new ie.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const m=t.toDataURL("image/jpeg",Jo),u=await ie.fileToBlob(m),f=new File([u],n.name,{type:"image/jpeg"});l.resolve(f)}},a.src=URL.createObjectURL(n),l}const Ur=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=d.useRef(null),m=d.useRef(null),[u,f]=d.useState(ie.Colors.red),[h,g]=d.useState(null),[C,w]=d.useState(!1),[p,y]=d.useState(!1),x=d.useRef(null),I=c.useSize(x);d.useEffect(()=>{const B=new Image;B.onload=function(){g({width:B.naturalWidth,height:B.naturalHeight})},B.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!p&&(I!=null&&I.width)&&I.height&&y(!0)},[I,p]);const b=d.useCallback(async()=>{a||e();const B=l.current;if(!B)return;if(!h)throw new Error("Original image size not loaded yet");const X=await B.exportImage("png"),P=new Image(h.width,h.height);P.onload=async function(){const W=await ie.fileToBlob(X),le=new File([W],n.name,{type:n.type}),te=m.current,ce=await Zo(te,n,le,h);ce.objectURL=URL.createObjectURL(ce);const Oe=await ie.hashFile(n);await ie.hashFile(ce)!==Oe&&r(ce),w(!1),e()},w(!0),P.src=X},[a,n,e,r,h]),S=d.useCallback(()=>{o(n)},[n,o]),N=d.useCallback(()=>{e()},[e]),D=d.useCallback(()=>{s(!0)},[s]),F=d.useCallback(()=>{l.current&&l.current.redo()},[]),L=d.useCallback(()=>{l.current&&l.current.undo()},[]),M=d.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),z=d.useCallback(B=>{l.current&&l.current.eraseMode(B)},[]),q=d.useCallback(()=>{b()},[b]),ee=d.useCallback(()=>{kt.saveAs(n,n.name)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsxs(_t,{children:[i.jsx(Vt,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(c.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.IconButton,{"aria-label":"close",onClick:N,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})}),i.jsx(c.IconButton,{"aria-label":`Download ${n.name}`,onClick:ee,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(vt,{selectedColor:u,allColors:Yo,onFinish:f,trigger:i.jsx(c.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:u},children:" "})}),i.jsx(c.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:z,children:i.jsx(c.RiIcon,{icon:"RiEraserFill"})}),i.jsx(c.Separator,{orientation:"vertical",size:"full"}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:L,children:i.jsx(c.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:F,children:i.jsx(c.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(c.IconButton,{"aria-label":"undo all",onClick:M,children:i.jsx(c.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(c.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:q,children:i.jsx(c.RiIcon,{icon:"RiSaveLine"})}),i.jsx(c.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:m,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:x,src:n.objectURL}),C?i.jsx(c.Spinner,{}):i.jsx(Xr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:D,strokeColor:u},p?"1":"0")]})]})]})})});Ur.displayName="AttachmentEditor",E.BaseField=k,E.BaseFormElement=bt,E.BooleanField=xe,E.BooleanInput=Wt,E.ColorPicker=vt,E.DateField=tt,E.DateInput=qt,E.FieldSection=U,E.FileCard=yt,E.FileIcon=$e,E.FormBuilder=Qo,E.FormRenderer=Or,E.ImageCard=Lr,E.ImageMarkup=Ur,E.ImageViewer=Ut,E.ImageViewerProvider=fr,E.InputWithHelpText=jt,E.InputWithLabel=Y,E.InputWithLabelAndHelpText=J,E.MultiSelectField=_e,E.MultiSelectInput=Rt,E.MultiStringField=ze,E.MultiStringInput=Qt,E.NumberField=se,E.NumberInput=Yt,E.PatchField=ge,E.PatchFormProvider=qo,E.QrField=at,E.QrInput=Jt,E.QrScanner=Zt,E.SUPPORTED_IMAGE_FILE_TYPES=vn,E.SUPPORTED_PDF_FILE_TYPES=bn,E.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=yn,E.SelectField=Ve,E.SelectInput=en,E.StringField=lt,E.StringInput=tn,E.TextField=ct,E.TextInput=nn,E.decodeFormValues=ko,E.deserialize=ut,E.deserializeField=an,E.emptyBaseField=H,E.emptyBooleanField=hr,E.emptyDateField=pr,E.emptyMultiSelectField=Er,E.emptyMultiStringField=br,E.emptyNumberField=Cr,E.emptyQrField=Ir,E.emptySelectField=Sr,E.emptyStringField=Nr,E.emptyTextField=Fr,E.encodeFormValues=Uo,E.fieldIcons=Yr,E.flattenFields=sn,E.formRevisionToSchema=Ar,E.initialFormValues=pt,E.isConditionMet=ln,E.useFieldInput=Ht,E.useFieldInputs=Be,E.useFormikInput=G,E.useImageViewer=Ue,E.validateForm=ht,E.valueIsFile=ft,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return v.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},So="DialogDescriptionWarning",To=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${cr(So).contentName}}.`;return v.useEffect(()=>{var a;const o=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null},zt=Jn,No=Rn,_t=tr,Vt=nr,$t=rr,dr=sr,Re=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},et={exports:{}},Fo=et.exports,ur;function Lo(){return ur||(ur=1,function(t,n){(function(e,r){r()})(Fo,function(){function e(u,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(u.type)?new Blob(["\uFEFF",u],{type:u.type}):u}function r(u,f,h){var g=new XMLHttpRequest;g.open("GET",u),g.responseType="blob",g.onload=function(){m(g.response,f,h)},g.onerror=function(){console.error("could not download file")},g.send()}function o(u){var f=new XMLHttpRequest;f.open("HEAD",u,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function a(u){try{u.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),u.dispatchEvent(f)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Re=="object"&&Re.global===Re?Re:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),m=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(u,f,h){var g=s.URL||s.webkitURL,C=document.createElement("a");f=f||u.name||"download",C.download=f,C.rel="noopener",typeof u=="string"?(C.href=u,C.origin===location.origin?a(C):o(C.href)?r(u,f,h):a(C,C.target="_blank")):(C.href=g.createObjectURL(u),setTimeout(function(){g.revokeObjectURL(C.href)},4e4),setTimeout(function(){a(C)},0))}:"msSaveOrOpenBlob"in navigator?function(u,f,h){if(f=f||u.name||"download",typeof u!="string")navigator.msSaveOrOpenBlob(e(u,h),f);else if(o(u))r(u,f,h);else{var g=document.createElement("a");g.href=u,g.target="_blank",setTimeout(function(){a(g)})}}:function(u,f,h,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),typeof u=="string")return r(u,f,h);var C=u.type==="application/octet-stream",w=/constructor/i.test(s.HTMLElement)||s.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||C&&w||l)&&typeof FileReader<"u"){var y=new FileReader;y.onloadend=function(){var b=y.result;b=p?b:b.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=b:location=b,g=null},y.readAsDataURL(u)}else{var E=s.URL||s.webkitURL,I=E.createObjectURL(u);g?g.location=I:location.href=I,g=null,setTimeout(function(){E.revokeObjectURL(I)},4e4)}});s.saveAs=m.saveAs=m,t.exports=m})}(et)),et.exports}var kt=Lo();const Ut=d.memo(t=>{const{file:n,onClose:e}=t,r=d.useRef(null),o=d.useCallback(()=>{var l;if(!r.current)return;const s=document.createElement("canvas");s.width=r.current.width,s.height=r.current.height,(l=s.getContext("2d"))==null||l.drawImage(r.current,0,0,r.current.width,r.current.height),s.toBlob(m=>{m&&navigator.clipboard.write([new ClipboardItem({"image/png":m})])},"image/png")},[]),a=d.useCallback(()=>{kt.saveAs(n,n.name)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsx(_t,{children:i.jsx(Vt,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":"",children:i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(c.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{children:i.jsx(c.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(c.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(c.Tooltip.Root,{children:[i.jsx(c.Tooltip.Trigger,{children:i.jsx(c.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(c.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(c.Separator,{orientation:"vertical",size:"sm"}),i.jsx(dr,{asChild:!0,children:i.jsx(c.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})]}),i.jsx("figure",{className:"size-full overflow-hidden p-4 flex justify-center items-center",children:i.jsx("img",{ref:r,className:"max-w-full max-h-full",src:URL.createObjectURL(n),alt:n.name})})]})})})})});Ut.displayName="ImageViewer";const fr=d.memo(t=>{const{children:n}=t,[e,r]=d.useState(null),o=d.useCallback(()=>{r(null)},[]),a=d.useCallback(m=>{r(m(o))},[o]),s=d.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=d.useMemo(()=>a,[a]);return i.jsxs(Cn.Provider,{value:l,children:[n,e&&i.jsx(Ut,{file:e.file,onClose:s})]})});fr.displayName="FileViewerProvider";const Y=t=>{const{className:n,label:e,children:r,severity:o,inputId:a,labelId:s,image:l}=t,[m,u]=d.useState(void 0),f=Ue(),h=o?de[o]:"base";d.useEffect(()=>{l instanceof Promise?l.then(u).catch(console.error):u(l)},[l]);const g=m?URL.createObjectURL(m):void 0,C=d.useCallback(()=>{m&&f(()=>({file:m}))},[f,m]);return i.jsxs("div",{className:"flex flex-col gap-1",children:[m&&i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:g,alt:m.name,onClick:C}),i.jsx("label",{className:ve(n,"flex flex-col gap-1 w-max"),htmlFor:a,children:i.jsx(c.Text,{accentColor:h,size:"sm",id:s,weight:"medium",children:e})}),r]})},jt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?de[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,!!n&&i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(c.Text,{accentColor:o,size:"xs",children:n})})]})},J=t=>{const{children:n,...e}=t;return i.jsx(jt,{...e,children:n})},Do=[!0,"true"],Wt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onBlur:g,onChange:C}=u,w=a?null:l,p=a?"":m,y=Do.includes(u.value),E=d.useCallback(()=>{g(y)},[g,y]);return i.jsx(J,{helpText:w,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,className:"items-center flex-row-reverse justify-end gap-2",children:i.jsx(c.Checkbox.Root,{id:n,name:h,value:y.toString(),checked:y,onCheckedChange:C,onBlur:E,size:"sm",accentColor:"primary",variant:"surface",...f,children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})})})})});Wt.displayName="BooleanInput";const hr={...H,type:"boolean"},Ee=class Ee extends k{constructor(e){super({...e,type:"boolean"});T(this,"onlyValidateAfterTouched",!1)}isBlank(e){return this.required&&!e}getValueFromChangeEvent(e){return typeof e=="boolean"?e:e.target.checked}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="boolean")throw new Error("Type mismatch.");return new Ee(e)}getInput(e){return i.jsx(Wt,{...e,field:this})}};T(Ee,"fieldTypeName","Checkbox"),T(Ee,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),T(Ee,"Icon",$.RiCheckboxCircleLine);let xe=Ee;const qt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C}=u,[w,p]=d.useState(!1),y=a?null:l,E=a?"":m,I=u.value?new Date(u.value):void 0,b=d.useCallback(N=>{N&&g(N.toISOString()),p(!1)},[g]),S=d.useCallback(N=>{p(N),N||C(u.value)},[u.value,C]);return i.jsx(J,{helpText:y,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:E,image:a?void 0:s.image,children:i.jsxs(c.Popover.Root,{open:w,onOpenChange:S,children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",className:"!justify-between",accentColor:"base",variant:"surface",size:"sm",...f,children:[I?I.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}):"yyyy-mm-dd",i.jsx(c.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(c.Popover.Content,{align:"start",children:i.jsx(c.DayPicker,{required:!1,mode:"single",variant:"solid",selected:I,onSelect:b})})]})})})});qt.displayName="DateInput";const pr={...H,type:"date"},Se=class Se extends k{constructor(e){super({...e,type:"date"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return e.target.value}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Se(e)}getInput(e){return i.jsx(qt,{field:this,...e})}};T(Se,"fieldTypeName","Date"),T(Se,"fieldTypeDescription","Allows specifying a date."),T(Se,"Icon",$.RiCalendarLine);let tt=Se;const mr=d.memo(t=>{const{field:n,...e}=t,[{value:r}]=V.useField(n.options.clonedFieldIdentifier),o=d.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?ut(a):null},[n.options,r]);return Ht(o,e)});mr.displayName="FieldInputCloner";const Mo={...H,type:"custom"};class nt extends k{constructor(e,r){super({...e,type:"custom"});T(this,"Component");T(this,"options");this.options=e,this.Component=r}serialize(){throw new Error("Serializing only supported for public input types.")}getInput(e){const r=this.Component;return i.jsx(r,{field:this,...e})}}T(nt,"fieldTypeName","Custom"),T(nt,"fieldTypeDescription","Allows re-rendering of field already in the form");class Ao extends nt{constructor(n){super(n,mr)}}const Ht=(t,n)=>d.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Be=(t,n)=>{const e=d.useMemo(()=>t.map(r=>i.jsx(d.Fragment,{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-4",children:e})},pe=t=>t.type==="section",rt=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),Po=t=>{if(!t)return;const n=t.fields;let e=[];const r=[];for(const o of n)o.type==="section"?(e.length>0&&(r.push(rt(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(rt("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function Gt(t,n,e){const r=Array.from(t),[o]=r.splice(n,1);if(!o)throw new Error("Could not find field to reorder.");return r.splice(e,0,o),r}function gr(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function it(t,n){const e=Array.from(t);return e.splice(n,1),e}const Xt=(t,n)=>{const e=new Date;return`${ie.slugify(n)}-${e.getTime()}`},vr=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=vr(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},yr=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),ot=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:Xt(null,a)},l=K(r,t);if(l===void 0)throw new Error("Parent path must point to an existing field.");if(!Array.isArray(l))throw new Error("Parent path must point to an array.");const m=gr(l,n,s);o(t,m).then()},Oo=(t,n,e)=>{const r={...rt(),label:""};ot("fields",t,r,n,e)},Kt=()=>{const{showError:t}=c.useToast(),n=d.useCallback((r,o,a,s,l,m)=>{const u=r[o];if(!u)throw new Error("Could not find section context.");let f=typeof u.conditionIndex<"u"?Math.max(u.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(f=Math.min(f,h.index-1));if(f!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}m("fields",Gt(l.fields,a,f))},[t]),e=d.useCallback((r,o,a,s,l,m,u)=>{var f;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)u(`fields.${o}.fields`,Gt(r.fields,a,m)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((f=s.condition)==null?void 0:f.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}u(`fields.${o}.fields`,it(r.fields,a)).then(),u(`fields.${l}.fields`,gr(s.fields,m,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},Qt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),h=a?null:l,g=a?"":m,{name:C,onChange:w,onBlur:p}=u,y=d.useMemo(()=>Array.isArray(u.value)?u.value:[],[u.value]),E=`${n}-droppable`,{disabled:I}=f,[b,S]=d.useState(""),[N,D]=d.useState(""),F=N||h,L=d.useCallback(P=>{w(P),p(P)},[w,p]),A=d.useCallback(P=>{y.findIndex(W=>W===P.target.value.trim())>=0?D("All options must be unique"):P.target.value?D(""):D("Option cannot be empty"),S(P.target.value)},[S,y]),O=d.useCallback(()=>{if(N)return;if(!b.trim()){D("Option cannot be empty");return}const P=b.trim();L([...y,P]),S("")},[b,N,L,y]),q=d.useCallback(P=>{P.key==="Enter"&&(P.preventDefault(),O())},[O]),ee=d.useCallback(P=>{L(it(y,P))},[y,L]),z=d.useCallback(P=>{if(!P.destination)return;const W=P.source.index,le=P.destination.index;L(Gt(y,W,le))},[L,y]),X=d.useCallback(()=>{p(y)},[p,y]);return i.jsx(re.DragDropContext,{onDragEnd:z,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(J,{helpText:F,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:g,image:a?void 0:s.image,children:(!I||y.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.Input.Root,{className:"grow",accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{value:b,onChange:A,onKeyDown:q,id:n,placeholder:s.placeholder,onBlur:X,name:C,...f})}),i.jsx(c.IconButton,{size:"sm",accentColor:"base",variant:"soft",type:"button","aria-label":"Add option",disabled:!!N||I,onClick:O,children:i.jsx(c.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(re.Droppable,{droppableId:E,children:P=>i.jsxs("div",{className:"flex flex-col",...P.droppableProps,ref:P.innerRef,children:[y.map((W,le)=>i.jsx(re.Draggable,{draggableId:`${W}-draggable`,index:le,isDragDisabled:I,children:({draggableProps:te,dragHandleProps:ce,innerRef:Oe})=>i.jsxs(c.Badge,{...ce,...te,ref:Oe,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"sm",variant:"soft",children:[i.jsx("span",{children:typeof W=="object"&&"label"in W?W.label:W}),i.jsx(c.IconButton,{size:"xs",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:I,onClick:()=>{ee(le)},children:i.jsx(c.RiIcon,{icon:"RiCloseLargeLine"})})]})},W)),P.placeholder]})})]})})});Qt.displayName="MultiStringInput";const br={...H,type:"multi-string",minimum_length:0,maximum_length:null},Te=class Te extends k{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});T(this,"minLength");T(this,"maxLength");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.minLength=r??0,this.maxLength=o??1/0,this.placeholder=a??"Press enter to add a new option"}getValueFromChangeEvent(e){if(Array.isArray(e))return e;throw new Error("Expected an array.")}getInput(e){return i.jsx(Qt,{field:this,...e})}serialize(){return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}isBlank(e){return super.isBlank(e)||e.length===0}getFieldValidators(){const e=super.getFieldValidators();return e.push(r=>{if(Array.isArray(r)&&r.length<this.minLength)return`Must have at least ${this.minLength} options.`}),e.push(r=>{if(Array.isArray(r)&&r.length>this.maxLength)return`Must have at most ${this.maxLength} options.`}),e}static deserialize(e){if(e.type!=="multi-string")throw new Error("Type mismatch.");return new Te(e)}};T(Te,"fieldTypeName","Multi-string"),T(Te,"fieldTypeDescription","Allows the user to provide multiple unique strings."),T(Te,"Icon",$.RiListCheck);let ze=Te;const Yt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,E=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{const L=Number.parseFloat(F.target.value),A=Number.isNaN(L)?"":L;S(A),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(A))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:E,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,onChange:N,onBlur:D,value:b,type:"number",min:s.minimum,max:s.maximum,step:s.integers?1:.1,placeholder:s.placeholder,...g})})})})});Yt.displayName="NumberInput";const Cr={...H,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},wr=t=>"fields"in t,R=class R extends k{constructor(e){const{minimum:r=Number.MIN_SAFE_INTEGER,maximum:o=Number.MAX_SAFE_INTEGER,integers:a=!1,placeholder:s="Enter a number",...l}=e;super({...l,type:"number"});T(this,"minimum");T(this,"maximum");T(this,"integers");T(this,"placeholder");this.minimum=r,this.maximum=o,this.integers=a,this.placeholder=s}getValueFromChangeEvent(e){const r=Number.parseFloat(e.target.value);return Number.isNaN(r)?"":r}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new R({label:"Minimum",description:"Minimum value",integers:!0,required:!1,identifier:`${r}minimum`,formValidators:[this._validateMin(e)]}),showDirectly:!1},{field:new R({label:"Maximum",description:"Maximum value",integers:!0,required:!1,identifier:`${r}maximum`,formValidators:[this._validateMax(e)]}),showDirectly:!1},{field:new xe({label:"Integers",description:"Whole numbers only",required:!1,identifier:`${r}integers`}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.minimum,o=this.maximum;return typeof r=="number"&&e.push(a=>{if(typeof a=="number"&&a<r)return`Must be at least ${this.minimum}.`}),typeof o=="number"&&e.push(a=>{if(typeof a=="number"&&a>o)return`Must be at most ${this.maximum}.`}),this.integers&&e.push(a=>{if(typeof a=="number"&&!Number.isInteger(a))return"Must be a whole number."}),e}serialize(){return{...super._serialize(),minimum:this.minimum,maximum:this.maximum,integers:this.integers,placeholder:this.placeholder}}static deserialize(e){if(e.type!=="number")throw new Error("Type mismatch.");return new R(e)}getInput(e){return i.jsx(Yt,{field:this,...e})}};T(R,"fieldTypeName","Number"),T(R,"fieldTypeDescription","Allows specifying a number within a given range."),T(R,"Icon",$.RiHashtag),T(R,"_validateMin",e=>(r,o)=>{const a=wr(o)?K(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),T(R,"_validateMax",e=>(r,o)=>{const a=wr(o)?K(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let se=R;const Jt=d.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:m,fieldProps:u},f]=G(t),{name:h,onBlur:g,onChange:C,value:w}=u,[p,y]=d.useState(!1),E=l?null:o,I=l?"":r,b=d.useCallback(D=>{C(D),y(!1)},[C]),S=d.useCallback(()=>{C("")},[C]),N=d.useCallback(D=>{y(D),D||g(w)},[g,w]);return i.jsx(J,{helpText:E,severity:s,children:i.jsxs(Y,{size:a,severity:s,inputId:n,labelId:e,label:I,image:l?void 0:m.image,className:"flex-col items-start justify-start gap-2",children:[i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(zt,{open:p,onOpenChange:N,children:[i.jsx(No,{asChild:!0,children:i.jsxs(c.Button,{id:n,name:h,type:"button",variant:"soft",size:"sm",accentColor:"base",...f,children:[i.jsx(c.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]})}),i.jsxs(_t,{children:[i.jsx(Vt,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx($t,{className:"fixed inset-0",children:i.jsx(Zt,{onQrScan:b})})]})]}),w&&i.jsx(c.RiIcon,{icon:"RiCheckLine",className:"align-bottom text-(--primary-a11)"})]}),!!w&&i.jsx(c.Card,{className:"max-w-full w-max",size:"sm",children:i.jsxs("div",{className:"max-w-full w-max flex justify-between gap-2",children:[i.jsx("code",{className:"bg-(--base-a3) truncate text-sm",children:w}),i.jsx(c.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Jt.displayName="QrInput";const Zt=d.memo(t=>{const{onQrScan:n}=t,e=d.useRef(null),[r,o]=d.useState(!1);return d.useEffect(()=>{if(!e.current)return;const a=new Hr(e.current,s=>{const l=s.data;n(l),a.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});o(!0),a.start().finally(()=>{o(!1)})},[n]),i.jsxs("div",{className:"relative flex h-full w-full flex-col justify-center gap-2 bg-(--color-background)",children:[i.jsx("div",{className:"absolute top-0 flex w-full p-2",children:i.jsx(dr,{asChild:!0,children:i.jsx(c.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{className:"size-full",ref:e}),r&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(c.Spinner,{})})]})]})});Zt.displayName="QrScanner";const Ir={...H,type:"qr"},Ne=class Ne extends k{constructor(e){super({...e,type:"qr"});T(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Ne(e)}getInput(e){return i.jsx(Jt,{...e,field:this})}};T(Ne,"fieldTypeName","QR"),T(Ne,"fieldTypeDescription","Used for scanning/reading QR codes."),T(Ne,"Icon",$.RiQrCodeLine);let at=Ne;class xr extends k{constructor(e){const{placeholder:r="",...o}=e;super(o);T(this,"options");T(this,"onlyValidateAfterTouched",!1);T(this,"placeholder");this.placeholder=r;const a=new Set;this.options=e.options.map(s=>(typeof s=="string"&&(s={label:s,value:s}),a.add(s.label),s)),a.size!==e.options.length&&console.error(`${e.options.length-a.size} duplicate identifiers found in options. This may cause unexpected behavior. Options:`,e.options)}_serialize(){return{...super._serialize(),options:this.options,placeholder:this.placeholder}}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ze({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const Bo=t=>t?Array.isArray(t)?t:[t]:[],Rt=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C}=u,w=a?null:l,p=a?"":m,y=d.useMemo(()=>Bo(u.value),[u.value]),E=d.useCallback(b=>{g(b),C(b)},[C,g]),I=d.useCallback(b=>{b||C(y)},[y,C]);return i.jsx(J,{helpText:w,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:p,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{onOpenChange:I,align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",variant:"surface",type:"button",size:"sm",accentColor:"base",...f,children:[i.jsx("span",{className:"truncate",children:y.length>0?y.join(", "):s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsxs(c.Menu.MultiSelectGroup,{values:y,onValuesChange:E,children:[i.jsxs(c.Menu.SelectAllItem,{children:[i.jsx(c.Menu.CheckboxItemIndicator,{children:b=>b?i.jsx(c.RiIcon,{icon:"RiSubtractLine"}):i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(b=>i.jsxs(c.Menu.MultiSelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))]})})})]})})})});Rt.displayName="MultiSelectInput";const Er={...H,type:"multi-select",options:[]},Fe=class Fe extends xr{constructor(n){const{placeholder:e="Select one or more...",...r}=n;super({...r,placeholder:e,type:"multi-select"})}getValueFromChangeEvent(n){if(Array.isArray(n))return n;throw new Error("Expected an array.")}isBlank(n){return super.isBlank(n)||n.length===0}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="multi-select")throw new Error("Type mismatch.");return new Fe(n)}getInput(n){return i.jsx(Rt,{field:this,...n})}};T(Fe,"fieldTypeName","Multi-select"),T(Fe,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),T(Fe,"Icon",$.RiCheckboxLine);let _e=Fe;const en=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u},f]=G(t),{name:h,onChange:g,onBlur:C,value:w}=u,p=a?null:l,y=a?"":m,E=d.useCallback(b=>{b&&(g(b),C(b))},[C,g]),I=d.useMemo(()=>s.options.find(b=>b.value===w),[s.options,w]);return i.jsx(J,{helpText:p,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:y,image:a?void 0:s.image,children:i.jsxs(c.Menu.Root,{align:"start",children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{id:n,name:h,className:"!justify-between",accentColor:"base",variant:"surface",type:"button",size:"sm",...f,children:[i.jsx("span",{className:"truncate",children:I?I.label:s.placeholder}),i.jsx(c.RiIcon,{className:"shrink-0",icon:"RiArrowDownSLine"})]})}),i.jsx(c.Menu.Content,{children:i.jsx(c.Menu.Scroll,{children:i.jsx(c.Menu.SelectGroup,{required:!0,value:w,onValueChange:E,children:s.options.map(b=>i.jsxs(c.Menu.SelectItem,{value:b.value,children:[i.jsx(c.Menu.SelectedIndicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})}),b.label]},b.value))})})})]})})})});en.displayName="SelectInput";const Sr={...H,type:"select",options:[]},Le=class Le extends xr{constructor(n){const{placeholder:e="Select one...",...r}=n;super({...r,placeholder:e,type:"select"})}getValueFromChangeEvent(n){return typeof n=="string"?n:n.target.value}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="select")throw new Error("Type mismatch.");return new Le(n)}getInput(n){return i.jsx(en,{field:this,...n})}};T(Le,"fieldTypeName","Dropdown"),T(Le,"fieldTypeDescription","Allows the user to select a single option from a list of options."),T(Le,"Icon",$.RiMenuFoldLine);let Ve=Le;const Tr=t=>"fields"in t;class st extends k{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);T(this,"minLength");T(this,"maxLength");T(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):ye,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"Minimum length",description:"Minimum number of characters",required:!1,identifier:`${r}minimum_length`,minimum:0,maximum:100,formValidators:[this._validateMin(e)],integers:!0}),showDirectly:!1},{field:new se({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:ye,formValidators:[this._validateMax(e)],integers:!0}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators();return this.minLength&&e.push(r=>{if(this.minLength&&(!r||r.length<this.minLength))return!this.required&&!r?null:`Minimum ${this.minLength} character(s).`}),this.maxLength&&e.push(r=>{if(typeof r=="string"&&this.maxLength&&r.length>this.maxLength)return`Maximum ${this.maxLength} character(s).`}),e}_serialize(){if(!this.identifier)throw new Error("Field identifier must be set before serializing.");return{...super._serialize(),minimum_length:this.minLength,maximum_length:this.maxLength,placeholder:this.placeholder}}}T(st,"_validateMin",e=>(r,o)=>{const a=Tr(o)?K(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),T(st,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Tr(o)?K(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const tn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,E=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:E,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.Input.Root,{accentColor:"base",variant:"surface",size:"sm",children:i.jsx(c.Input.Field,{id:n,name:C,value:b,type:s.inputType,placeholder:s.placeholder,onChange:N,onBlur:D,...g})})})})});tn.displayName="StringInput";const Nr={...H,type:"string",maximum_length:ke,input_type:"text"},De=class De extends st{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ke,e.maxLength):ke,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});T(this,"inputType");this.inputType=r}serialize(){return{...super._serialize(),input_type:this.inputType}}static deserialize(e){if(e.type!=="string")throw new Error("Type mismatch.");const{maximum_length:r,minimum_length:o,input_type:a,...s}=e;return new De({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(tn,{field:this,...e})}};T(De,"fieldTypeName","Short Text"),T(De,"fieldTypeDescription",`Short text fields can hold up to ${ke} characters on a single line.`),T(De,"Icon",$.RiInputField);let lt=De;const nn=d.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,helpText:l,label:m,fieldProps:u,touched:f,helpers:h},g]=G(t),{name:C,onBlur:w,onChange:p,value:y}=u,E=a?null:l,I=a?"":m,[b,S]=d.useState("");d.useLayoutEffect(()=>{S(y)},[y]);const N=d.useCallback(F=>{S(F.target.value),(f||!s.onlyValidateAfterTouched)&&h.setError(s.getError(F.target.value))},[s,h,f]),D=d.useCallback(()=>{p(b),w(b)},[b,w,p]);return i.jsx(J,{helpText:E,severity:o,children:i.jsx(Y,{size:r,severity:o,inputId:n,labelId:e,label:I,image:a?void 0:s.image,children:i.jsx(c.TextArea,{id:n,value:b,name:C,onChange:N,onBlur:D,className:"field-sizing-content min-h-12",placeholder:s.placeholder,resize:"vertical",accentColor:"base",variant:"surface",size:"sm",...g})})})});nn.displayName="TextInput";const Fr={...H,type:"text",maximum_length:ye},Me=class Me extends st{constructor(n){const e=n.maxLength?Math.min(ye,n.maxLength):ye,r=n.minLength?Math.min(n.minLength,e):void 0;super({...n,maxLength:e,minLength:r,type:"text"})}serialize(){return super._serialize()}static deserialize(n){if(n.type!=="text")throw new Error("Type mismatch.");const{maximum_length:e,minimum_length:r,...o}=n;return new Me({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(nn,{field:this,...n})}};T(Me,"fieldTypeName","Paragraph"),T(Me,"fieldTypeDescription",`Paragraph fields can hold up to ${ye} characters and can have multiple lines.`),T(Me,"Icon",$.RiAlignJustify);let ct=Me;const Lr=d.memo(d.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,...l}=t;return i.jsxs("div",{className:ve(s,"relative flex h-[200px] w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...l,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(c.Spinner,{})}),i.jsx("div",{className:"-m-4 flex max-w-full grow items-center justify-center overflow-hidden bg-clip-padding",children:e&&!o&&i.jsx("img",{className:"max-w-full object-cover",src:URL.createObjectURL(e),alt:r??e.name})}),i.jsxs("div",{className:ve("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),children:[o?i.jsx(c.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx($e,{fileType:e.type}),i.jsx(c.Text,{className:"truncate",size:"sm",children:o??(e==null?void 0:e.name)}),a]})]})})),zo=t=>{const n=["byte","kilobyte","megabyte"];let e=t,r=0;for(;e>1e3&&r<n.length-1;)e/=1e3,r++;return new Intl.NumberFormat([],{maximumFractionDigits:Math.max(0,r-1),style:"unit",unit:n[r]}).format(e)},Dr=d.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:m},u]=G(t),{name:f,value:h,onChange:g,onBlur:C}=m;let[{label:w}]=G(t);w=s?"":w;const p=d.useRef(null),y=d.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),E=d.useCallback(()=>{var L;(L=p.current)==null||L.click()},[]),I=d.useCallback(()=>{if(!p.current)return;const L=p.current.files;if(!L){C([]);return}const A=Array.from(L),O=[...h,...A];g(O),C(O)},[C,g,h]),b=d.useCallback(L=>{const A=[...h];A.splice(L,1),g(A)},[h,g]);d.useEffect(()=>{if(!p.current)return;const L=new AbortController;return p.current.addEventListener("cancel",()=>{C([])},{signal:L.signal}),()=>{L.abort()}},[C,h]);const S=h?"Select new files":"Select files",N=h?"Select new file":"Select a file",D=l.maxFiles>1?S:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(J,{helpText:y,severity:o,children:i.jsxs(Y,{size:r,severity:o,inputId:n,labelId:e,label:w,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(c.Button,{className:"w-max",size:"sm",variant:"soft",accentColor:"base",onClick:E,id:"upload-input-upload-button",type:"button",...u,children:[i.jsx(c.RiIcon,{icon:"RiUpload2Line"})," ",D]})}),i.jsx("input",{id:n,name:f,type:"file",ref:p,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,className:"hidden",onChange:I,value:""})]})}),Array.isArray(h)&&h.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:h.map((L,A)=>i.jsx(Mr,{field:l,file:L,onRemove:()=>{b(A)},disabled:u.disabled},A))})]})});Dr.displayName="UploadInput";const Mr=d.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=d.useState(null),l=Ue(),m=d.useMemo(()=>a&&e.getError([a]),[e,a]),{url:u,name:f}=d.useMemo(()=>{let p=null,y,E;return a!=null&&a.type.startsWith("image/")&&(p=URL.createObjectURL(a)),a?(y=a.name,E=zo(a.size)):(y="Downloading...",E="..."),{url:p,name:y,size:E}},[a]);d.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=d.useCallback(p=>{if(p.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const y=new Blob([a]);kt.saveAs(y,f)},[f,a]),g=d.useCallback(p=>{p.stopPropagation(),r()},[r]),C=d.useCallback(()=>{a&&l(p=>({file:a,onDelete:o?void 0:()=>{r(),p()}}))},[o,r,l,a]),w=d.useMemo(()=>i.jsxs(c.ButtonGroup,{className:"flex grow justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(c.IconButton,{"aria-label":`Download ${f}`,type:"button",onClick:h,disabled:!a,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(c.IconButton,{type:"button","aria-label":`Remove ${f}`,disabled:o,onClick:g,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),[o,g,h,f,a]);return u?i.jsx(Lr,{className:"cursor-pointer",onClick:C,file:a,error:m??void 0,rightSlot:w}):i.jsx(yt,{file:a,error:m??void 0,rightSlot:w})});Mr.displayName="DisplayFile";const _o={...H,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Ae=class Ae extends k{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});T(this,"extensions");T(this,"maxFileSize");T(this,"maxFiles");T(this,"onlyValidateAfterTouched",!1);this.maxFileSize=typeof a=="number"?a:void 0,this.maxFiles=Math.max(typeof o=="number"?o:1,1),this.extensions=r}getValueFromChangeEvent(e){return Array.from(e.target.files||[])}isBlank(e){return super.isBlank(e)||e.length===0}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new se({label:"How many files can be uploaded?",description:"By default, only one file can be uploaded.",required:!1,minimum:1,maximum:10,identifier:`${r}maximum_files`,integers:!0}),showDirectly:!1},{field:new se({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${dt}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:dt,integers:!0}),showDirectly:!1},{field:new _e({label:"Accepted file types",description:"Types of allowed files to upload. If left blank, all files will be accepted.",required:!1,identifier:`${r}extensions`,options:[{value:"image/*",label:"Images"},{value:"audio/*",label:"Audio files"},{value:"video/*",label:"Videos"},{value:"text/*",label:"Text files"},{value:"application/*",label:"Application files (includes PDFs and Word documents)"}]}),showDirectly:!1}]}getFieldValidators(){const e=super.getFieldValidators(),r=this.maxFileSize??dt,o=r*1e3*1e3,a=this.maxFiles||1;return e.push(s=>{if(s&&s.some(l=>l.size>o))return`Files must be at most ${r}MB.`}),e.push(s=>{if(s&&s.length>a)return`You can only upload ${a} files.`}),e}serialize(){return{...super._serialize(),extensions:this.extensions,maximum_size:this.maxFileSize,maximum_files:this.maxFiles}}static deserialize(e){if(e.type!=="upload")throw new Error("Type mismatch.");return new Ae(e)}getInput(e){return i.jsx(Dr,{field:this,...e})}};T(Ae,"fieldTypeName","Upload"),T(Ae,"fieldTypeDescription","Allows a file to be uploaded."),T(Ae,"Icon",$.RiUpload2Line);let rn=Ae;const on={date:tt,number:se,boolean:xe,select:Ve,string:lt,text:ct,custom:nt,upload:rn,qr:at,"multi-string":ze,"multi-select":_e},Vo={date:pr,number:Cr,boolean:hr,select:Sr,string:Nr,text:Fr,custom:Mo,upload:_o,qr:Ir,"multi-string":br,"multi-select":Er},dt=50,$o=dt*1e3*1e3,an=t=>{const n=t.type;return on[n].deserialize(t)},ut=t=>t.type==="section"?U.deserialize(t):an(t);function Ar(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>ut(r)),meta:{readonly:e}}}function sn(t){const n=[];for(const e of t.fields)if(e instanceof U)for(const r of e.fields)n.push(r);else{if(!(e instanceof k))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function ko(t,n){const e=sn(t),r={};for(const o of e){const a=n[o.identifier]??null;a!==null?r[o.identifier]=o.decodeJsonToValue(a):r[o.identifier]=a}return r}function Uo(t,n){const e=sn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function ft(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function ln(t,n){if(!t)return!0;if(ft(n)||ft(t.value))throw new Error("Conditions do not support file uploads");const e=Array.isArray(n)?n.map(o=>typeof o=="string"?o:o.value):n,r=Array.isArray(t.value)?t.value.map(o=>typeof o=="string"?o:o.value):t.value;if(Array.isArray(r)&&Array.isArray(e)){for(const o of r)if(!e.includes(o))return!1;return!0}return r===n}const Pr=d.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:m}=V.useFormikContext(),u=s!=null&&s.identifier?K(l,s.identifier):void 0,f=d.useMemo(()=>u===void 0||ln(s,u),[s,u]);d.useEffect(()=>{if(!f)for(const g of a)m(g.getId(),"").then()},[f,a,m]);const h=Be(a,e);return f?i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-4",children:[(r||o)&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(c.Heading,{size:"md",children:r}),i.jsx(c.Text,{accentColor:"base",children:o})]}),i.jsx(c.Separator,{size:"full"})]}),h]})}):null});Pr.displayName="FieldSectionLayout";const Pe=class Pe extends bt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});T(this,"label");T(this,"fields");T(this,"condition");this.fields=o,this.condition=a,this.label=r,s===!1&&(this.condition=null)}static getFieldCreationSchema(e,r=""){if(e.length===0)return[];const o=r&&`${r}.`;return[{field:new xe({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new Pe({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Ve({label:"Field",description:"The field to use for the condition.",options:e.map(a=>!a.label||a.type==="upload"?null:{label:a.label,value:a.identifier}).filter(a=>!!a),identifier:`${o}condition.identifier`,required:!0}),new Ao({label:"Value",identifier:`${o}condition.value`,required:!0,clonedFieldIdentifier:`${o}condition.identifier`,getFieldToClone(a){if(!a)return null;const s=e.find(l=>l.identifier===a);return s?{...s,label:"Value",identifier:`${o}condition.value`,description:"The value to compare against.",required:s.type!=="boolean"}:(console.error("Could not find field with identifier",a),null)}})]}),showDirectly:!1}]}static deserialize(e){if(e.type!=="section")throw new Error("Invalid type");if(!Array.isArray(e.fields))throw new Error(`Invalid fields: ${e.fields} (not an array)`);const r=e.fields.map(an);return new Pe({...e,fields:r})}conditional(){return this.condition!==null}serialize(){return{...super._serialize(),label:this.label,condition:this.condition,conditional:this.conditional(),fields:this.fields.map(e=>e.serialize())}}getErrors(e){const r={};for(const o of this.fields){const a=o.getId(),s=o.getError(K(e,a),e);s&&gt(r,o.getId(),s)}return r}getInput(e){return i.jsx(Pr,{field:this,...e})}};T(Pe,"fieldTypeName","Section"),T(Pe,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let U=Pe;const me=t=>Object.keys(t).length>0,ht=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof U){if(r.condition){const{identifier:o}=r.condition;if(!ln(r.condition,K(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof k))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(K(n,o),n);a&&gt(e,o,a)}if(me(e))return e},jo=[null,void 0],pt=(t,n)=>t.reduce((e,r)=>r instanceof U?{...e,...pt(r.fields,n)}:(jo.includes(K(e,r.getId()))&&gt(e,r.getId(),""),e),Gr(n)),Wo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Or=d.memo(d.forwardRef((t,n)=>{const{schema:e,values:r={},onValuesChange:o,onSubmit:a=Wo,submitText:s="Submit",cancelText:l,onCancel:m,onDirty:u,onDirtyChange:f,hideTitle:h=!e.title,hideDescription:g,className:C,buttonProps:w}=t,{readonly:p}=e.meta,y=d.useMemo(()=>crypto.randomUUID(),[]),E=V.useFormik({initialValues:pt(e.fields,r),onSubmit:a,validate:F=>ht(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:I}=E,b=d.useMemo(()=>typeof e.title=="string"?i.jsx(c.Heading,{size:"md",children:e.title}):e.title,[e.title]),S=d.useMemo(()=>typeof e.description=="string"?i.jsx(c.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),N=d.useCallback((F,L)=>{o==null||o({[F]:L})},[o]),D=Be(e.fields,{formId:y,disabled:p,onValuesChange:N});return d.useEffect(()=>{I&&u&&u(),f&&f(I)},[I,u,f]),i.jsx(V.FormikProvider,{value:E,children:i.jsxs("form",{id:y,ref:n,className:ve(C,"flex flex-col gap-2"),onSubmit:E.handleSubmit,children:[!h&&i.jsx(c.Card,{variant:"soft",children:i.jsxs("div",{className:"flex flex-col gap-1",children:[b,!g&&S]})}),D,!p&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[l&&i.jsxs(c.Button,{accentColor:de.danger,...w,type:"button",onClick:m,children:[i.jsx(c.RiIcon,{icon:"RiCloseLine"}),l]}),i.jsxs(c.Button,{...w,type:"submit",disabled:!E.isValid,accentColor:"success",children:[i.jsx(c.RiIcon,{icon:"RiCheckLine"}),s]})]})]})})})),ge=d.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=V.useFormikContext(),[o,a,s]=V.useField(n),l=d.useMemo(()=>{const m=u=>{s.setValue(u,!1)};return e({value:o.value,meta:a,setValue:m,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});ge.displayName="PatchField";const qo=d.memo(d.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:m,...u}=t,f=d.useMemo(()=>pt(r.fields,o),[r.fields,o]),h=d.useCallback(I=>{const b={};for(const S in I){const N=I[S];N!==f[S]&&N!==void 0&&(b[S]=N)}return b},[f]),g=d.useCallback(I=>{const b=h(I);l&&!me(b)||a(b)},[h,a,l]),C=d.useCallback(I=>{const b=ht(r,I);if(b&&s(b),m){const S=h(I);m(me(S))}return b},[r,m,s,h]),w=V.useFormik({initialValues:f,onSubmit:g,validate:C,validateOnBlur:!1,validateOnChange:!1}),p=d.useCallback(()=>{if(m){const I=h(w.values);me(I)&&m(!0)}},[w.values,h,m]),{errors:y,resetForm:E}=w;return d.useEffect(()=>{me(y)&&E({values:f,errors:{}})},[y,f,E]),i.jsx(V.FormikProvider,{value:w,children:i.jsx("form",{...u,ref:n,onSubmit:w.handleSubmit,onChange:p,children:e})})})),mt="form-builder",Ho=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],cn={...on,section:U},Go=(t,n)=>{var r;const e={...t};switch(n.type){case"release":for(const o in e)e[o].disabled=!1;return e;case"hold":for(const o in e)(r=e[o])!=null&&r.conditionFields.has(n.fieldId)&&(e[o].disabled=!0);return e;case"update":return n.state}},Xo=(t,n)=>{if(n)for(let e=0;e<t.length;e++){const r=t[e];if(r){for(const o of r.fields)if(o.identifier===n)return e}}},Br=t=>{var e,r,o;const n={};for(let a=0;a<t.length;a++){const s=t[a];if(!s)throw new Error("Field is undefined.");const l=a>0?(e=n[t[a-1].identifier])==null?void 0:e.conditionFields:void 0,m=new Set(l);(r=s.condition)!=null&&r.identifier&&m.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:m,conditionIndex:Xo(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},dn=d.memo(t=>{const{index:n,type:e,sectionIndex:r,remove:o,duplicate:a,move:s,upload:l}=t;if(e!=="section"&&!l)throw new Error("Upload function prop must be defined for non-section fields.");const{values:m}=V.useFormikContext(),u=d.useRef(null),f=d.useMemo(()=>{const h=[{Icon:$.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:$.RiDeleteBin7Fill,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:$.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var g;(g=u.current)==null||g.click()}}}),(r===void 0&&n!==m.fields.length-1||r!==void 0&&(r<m.fields.length-1||n!==m.fields[r].fields.length-1))&&h.unshift({Icon:$.RiArrowDownLine,key:"moveDown",text:"Move down",buttonProps:{onClick:()=>{s("down")}}}),(r===void 0&&n!==0||r!==void 0&&(r!==0||n!==0))&&h.unshift({Icon:$.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,m.fields]);return i.jsxs(i.Fragment,{children:[i.jsx(c.ButtonGroup,{className:"mx-2 hidden flex-col gap-0.5 sm:flex",variant:"ghost",accentColor:"base",size:"sm",children:f.map(h=>i.jsx(c.IconButton,{type:"button","aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsx(c.IconButton,{variant:"ghost",accentColor:"base","aria-label":"Actions menu",size:"sm",type:"button",children:i.jsx(c.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(c.Menu.Content,{children:f.map(h=>{var g;return i.jsxs(c.Menu.Item,{onClick:(g=h.buttonProps)==null?void 0:g.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:u,type:"file",accept:"image/*",onChange:l})]})});dn.displayName="FieldActions";const un=d.memo(t=>{const{popoverInputs:n,hasError:e,...r}=t;return i.jsxs(c.Popover.Root,{children:[i.jsx(c.Popover.Trigger,{asChild:!0,children:i.jsxs(c.Button,{variant:"soft",type:"button",size:"sm","aria-label":"settings",accentColor:"base",...e&&{color:de.danger},children:[i.jsx(c.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(c.Popover.Content,{size:"sm",...r,children:i.jsx("div",{className:"flex w-full max-w-[350px] flex-col",children:n})})]})});un.displayName="FieldSettingsPopover";const zr=(t=()=>null)=>d.useMemo(()=>Ho.map(n=>n.map(e=>{const r=on[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),fn=d.memo(t=>{var Oe,hn,jr,Wr,qr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=V.useFormikContext(),m=zr(),u=Ue(),f=d.useRef(null),h=576,[g,C]=d.useState(f.current&&f.current.getBoundingClientRect().width>=h);d.useEffect(()=>{const M=f.current;if(M){const B=new ResizeObserver(j=>{j[0]&&C(j[0].contentRect.width>=h)});return B.observe(M),()=>{B.disconnect()}}},[]);const[w,p]=d.useState(void 0);d.useEffect(()=>{pe(r)?p(void 0):r.image instanceof Promise?r.image.then(p).catch(console.error):p(r.image)},[r]);const y=w?URL.createObjectURL(w):void 0,E=d.useCallback(M=>{M.stopPropagation();const{image:B,...j}=r;s(`${n}.${e}`,j).then()},[e,r,n,s]);d.useEffect(()=>{pe(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const I=d.useMemo(()=>{var M,B;return pe(r)?(B=vr(a.fields,(M=r.condition)==null?void 0:M.identifier))==null?void 0:B.label:void 0},[r,a.fields]),b=pe(r)?Array.isArray((Oe=r.condition)==null?void 0:Oe.value)?"contains all of":"equals":void 0;let S;if(pe(r)){if(ft((hn=r.condition)==null?void 0:hn.value))throw new Error("File values are not supported for conditions.");S=Array.isArray((jr=r.condition)==null?void 0:jr.value)?r.condition.value.map(M=>typeof M=="string"?M:M.label).join(", "):(qr=(Wr=r.condition)==null?void 0:Wr.value)==null?void 0:qr.toString()}const N=d.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),D=d.useCallback(M=>{M.target.parentNode instanceof HTMLElement&&(M.target.parentNode.dataset.replicatedValue=M.target.value)},[]),F=r.type,L=cn[F],[A,O]=d.useMemo(()=>{let M=[],B=[];if(L===U){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const j=L.getFieldCreationSchema(o,`${n}.${e}`);M=M.concat(j.filter(_=>_.showDirectly).map(_=>_.field)),B=B.concat(j.filter(_=>!_.showDirectly).map(_=>_.field))}else{if(!(L.prototype instanceof k))throw new Error(`Field must be an instance of BaseField. Got ${L.toString()}.`);const j=L.getFieldCreationSchema(`${n}.${e}`);g?(M=[...M,...j.filter(_=>_.showDirectly).map(_=>_.field)],B=[...B,...j.filter(_=>!_.showDirectly).map(_=>_.field)]):B=[...B,...j.map(_=>_.field)]}return[M,B]},[L,o,n,e,g]),q=Be(A,{formId:mt,disabled:!1,...L===U&&{size:"sm"}}),ee=Be(O,{formId:mt,disabled:!1});let z=O.length>0;pe(r)&&O.length>0&&(z=r.conditional);const X=O.some(M=>{const B=K(l,L===U?`${n}.${e}.condition`:M.getId());return B&&(typeof B!="object"||me(B))}),P=X?de.danger:void 0,W=d.useMemo(()=>ut(r),[r]),le=Ht(W,{formId:mt,showInputOnly:!1}),te=d.useMemo(()=>m.flat().find(M=>M.value===F),[m,F]),ce=d.useCallback(()=>{w&&u(()=>({file:w}))},[u,w]);return i.jsx("div",{className:"flex grow items-center w-full",ref:f,children:i.jsxs("div",{className:"flex w-full flex-col gap-2",children:[L===U&&(A.length>0||z)&&i.jsxs("div",{className:"flex flex-col gap-2",children:[q,z&&i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(un,{popoverInputs:ee,hasError:X,align:"start"}),pe(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":P,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:I})," ",b," ",i.jsx("strong",{children:S})]})})]})]}),L!==U&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(c.Badge,{accentColor:"base",variant:"soft",size:"sm",children:[te==null?void 0:te.icon,te==null?void 0:te.children]}),i.jsx(ge,{name:`${n}.${e}.required`,render:({setValue:M,value:B})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.Checkbox.Root,{checked:B,onCheckedChange:M,size:"sm",children:i.jsx(c.Checkbox.Indicator,{children:i.jsx(c.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(c.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),z&&i.jsx(un,{popoverInputs:ee,hasError:X,align:"end"})]}),w&&i.jsxs("div",{className:"group relative inline-block w-full min-w-[300px]",children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:y,alt:w.name,onClick:ce}),i.jsx(c.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:"base","aria-label":"delete",onClick:E,size:"sm",children:i.jsx(c.RiIcon,{icon:"RiDeleteBin7Fill"})})]}),i.jsx(ge,{name:`${n}.${e}.label`,render:({setValue:M,value:B})=>i.jsx("input",{className:"bg-transparent outline-none text-sm placeholder-(--base-a9)",placeholder:F==="section"?"Enter a section label (optional)":"Enter your question",value:B,onChange:j=>{M(j.target.value)},onInput:N,maxLength:200})}),i.jsx(ge,{name:`${n}.${e}.description`,render:({setValue:M,value:B})=>i.jsx("textarea",{className:"bg-transparent outline-none text-sm field-sizing-content grow placeholder-(--base-a9)",placeholder:`Enter a ${F==="section"?"section":"field"} description (optional)`,value:B,onChange:j=>{M(j.target.value)},onInput:D,maxLength:1e3})}),L!==U&&A.length>0&&i.jsx("div",{className:"w-full",children:q}),L!==U&&i.jsxs(c.Card,{className:"flex gap-4 bg-(--accent-a2) items-center",children:[i.jsxs(c.HoverCard.Root,{children:[i.jsx(c.HoverCard.Trigger,{asChild:!0,children:i.jsx(c.Badge,{icon:!0,size:"sm",variant:"soft",accentColor:"base",children:i.jsx(c.RiIcon,{icon:"RiEyeLine"})})}),i.jsx(c.HoverCard.Content,{className:"w-[225px]",size:"sm",align:"start",children:"This is a preview of the field as it will be rendered in the form."})]}),i.jsx("div",{className:"grow h-max",children:le})]})]})})});fn.displayName="FieldBuilder";const _r=d.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=V.useFormikContext(),{reorderField:l}=Kt(),{showInfo:m,showError:u}=c.useToast(),f=`fields.${r}.fields`,h=d.useMemo(()=>({index:e,parentPath:f,initial:n}),[n,e,f]),g=d.useCallback(()=>{const p=n.label||"Unlabelled field",y={...n,label:p};ot(f,e+1,y,s,a),m({title:"Field duplicated",description:`The field "${p}" has been duplicated`})},[n,f,e,s,a,m]),C=d.useCallback(p=>{const y=r,E=s.fields[y];let I=r,b=p==="up"?e-1:e+1;p==="up"&&e===0?(I=r-1,b=s.fields[I].fields.length):p==="down"&&e===E.fields.length-1&&(I=r+1,b=0);const S=s.fields[I];l(E,y,e,S,I,b,a)},[r,s.fields,e,l,a]),w=d.useCallback(p=>{const{files:y}=p.target;if(!y||y.length!==1)return;const E=y.item(0);if(E){if(E.size>$o){u({title:"File upload error",description:`The file ${E.name} exceeded the maximum file size`});return}a(`${f}.${e}`,{...n,image:E}).then()}},[n,e,f,a,u]);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:p=>i.jsx(c.Card,{ref:p.innerRef,...p.draggableProps,...p.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(fn,{...h}),i.jsx(dn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:g,move:C,upload:w})]})})})});_r.displayName="FieldWithActions";const Vr=d.memo(t=>{var S;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(S=r[n.identifier])==null?void 0:S.disabled,{setFieldValue:s,values:l}=V.useFormikContext(),m=c.useAlertDialog(),{reorderSection:u}=Kt(),{showInfo:f}=c.useToast(),h=d.useCallback((N,D)=>{for(const F of N){const L=D.indexOf(F);s(`fields.${L}.condition`,null).then(),s(`fields.${L}.conditional`,!1).then()}},[s]),g=d.useCallback(N=>{var L;const D=n.fields[N];if(!D)throw new Error("Could not find field to remove.");const F=[];for(const A of l.fields)((L=A.condition)==null?void 0:L.identifier)===D.identifier&&F.push(A);return{removing:D,affectedSections:F,action:()=>s(`fields.${e}.fields`,it(n.fields,N))}},[n.fields,l.fields,s,e]),C=d.useCallback(N=>{const{affectedSections:D,action:F,removing:L}=g(N),A=()=>{F().then(),h(D,l.fields)};if(D.length>0){const O=D.map(q=>q.label).join(", ");m({title:"Remove condition?",description:`${L.label} is being used as a condition, deleting it will remove the condition from the ${O} section(s).`,action:"Remove",onAction:A});return}A()},[g,h,l.fields,m]),w=d.useCallback(()=>{const D=n.fields.map((z,X)=>g(X)).flatMap(z=>z.affectedSections),F=D.length?"Remove fields and conditions?":"Remove fields?",L=n.fields.length,A=D.map(z=>z.label).join(", "),O=D.length?`Deleting this section will remove the ${L} field(s) it contains and will remove the conditions from following sections: ${A}`:`Deleting this section will remove the ${L} field(s) it contains.`,q=it(l.fields,e),ee=()=>s("fields",q);if(D.length>0){m({title:F,description:O,action:"Remove",onAction:()=>{ee().then(()=>{h(D,q)})}});return}ee().then()},[n.fields,l.fields,e,g,s,m,h]),p=d.useCallback(N=>{const D=N==="up"?e-1:e+1;u(r,n.identifier,e,D,l,s)},[e,u,r,n.identifier,l,s]),y=d.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:yr(l.fields,e)}),[n,e,l.fields]),E=d.useCallback(()=>{const N=n.label||"Untitled section",D=n.fields.map(L=>({...L,identifier:Xt(null,L.label)})),F={...n,label:N,fields:D};ot("fields",e+1,F,l,s),f({title:"Section duplicated",description:`The section "${N}" has been duplicated.`})},[n,e,l,s,f]),I=d.useCallback(N=>{ot(`fields.${e}.fields`,n.fields.length,Vo[N],l,s)},[e,n.fields.length,l,s]),b=zr(I);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:N=>i.jsx(c.Card,{ref:N.innerRef,...N.draggableProps,...N.dragHandleProps,variant:"outline",className:"mb-4 w-full",children:i.jsxs("div",{className:"flex items-center justify-between gap-3 w-full",children:[i.jsxs("div",{className:"flex grow flex-col gap-2 w-full",children:[!o&&i.jsx(fn,{...y}),i.jsx(re.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:D=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:D.innerRef,...D.droppableProps,children:[n.fields.map((F,L)=>i.jsx(_r,{field:F,index:L,sectionIndex:e,remove:()=>{C(L)}},F.identifier)),D.placeholder,i.jsxs(c.Menu.Root,{children:[i.jsx(c.Menu.ClickTrigger,{children:i.jsxs(c.Button,{type:"button",variant:"soft",size:"sm",children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(c.Menu.Content,{children:b.flat().map(F=>i.jsxs(c.Menu.Item,{onSelect:F.onSelect,children:[F.icon,F.children]},F.value))})]})]})})]}),!o&&i.jsx(dn,{index:e,type:n.type,remove:w,duplicate:E,move:p})]})})})});Vr.displayName="FieldSectionWithActions";const $r=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},kr=d.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=V.useFormikContext(),[o,a]=d.useReducer(Go,e.fields,Br),{reorderSection:s,reorderField:l}=Kt();d.useEffect(()=>{a({type:"update",state:Br(e.fields)})},[a,e.fields]);const m=d.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),u=d.useCallback(h=>{const{source:g,destination:C,type:w,reason:p,draggableId:y}=h;if(a({type:"release"}),!C||p==="CANCEL")return;if(w==="ROOT"){s(o,y,g.index,C.index,e,r);return}if(w!=="SECTION")throw new Error("Unexpected droppable type.");const[E,I]=$r(e.fields,g.droppableId)??[],[b,S]=$r(e.fields,C.droppableId)??[];l(E,I,g.index,b,S,C.index,r)},[e,l,r,s,o]),f=d.useCallback(h=>{Oo(h+1,e,r)},[e,r]);return i.jsx(re.DragDropContext,{onDragStart:m,onDragEnd:u,children:i.jsx(re.Droppable,{droppableId:"droppable",type:"ROOT",children:h=>i.jsxs("div",{className:"flex flex-col gap-0",ref:h.innerRef,...h.droppableProps,children:[e.fields.map((g,C)=>i.jsxs(d.Fragment,{children:[i.jsx(Vr,{field:g,index:C,dropState:o,fieldsOnly:n}),!n&&C!==e.fields.length-1&&i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",size:"sm",accentColor:"base",onClick:()=>{f(C)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]})]},g.identifier)),i.jsxs(c.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",size:"sm",onClick:()=>{f(e.fields.length)},children:[i.jsx(c.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});kr.displayName="FieldsEditor";const Ko=()=>{alert("This is a form preview, your data will not be saved.")},Qo=d.memo(d.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:m=!1,showTabs:u=!0,tabsListClassName:f,hydrateRevisionWithImages:h}=t,{showError:g}=c.useToast(),C=d.useCallback(I=>{const b={};I.title||(b.title="Title is required."),(!I.fields||I.fields.length===0)&&(b.fields="At least one field is required.");let S=[];for(const[D,F]of I.fields.entries()){const A=cn.section.getFieldCreationSchema(yr(I.fields,D),`fields.${D}`).map(O=>O.field);S=[...S,...A];for(const[O,q]of F.fields.entries()){const z=cn[q.type].getFieldCreationSchema(`fields.${D}.fields.${O}`).map(X=>X.field);S=[...S,...z]}}const N=ht({fields:S},I);if(N&&(b.fields=N.fields),me(b))return g({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),b},[g]),w=d.useMemo(()=>({title:a??"",description:"",fields:[{...rt(Xt(null,"")),label:""}]}),[a]),p=o?h(o):void 0,y=V.useFormik({initialValues:Po(p)??w,validate:C,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=d.useMemo(()=>Ar(y.values),[y.values]);return i.jsx(c.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[u&&i.jsxs(c.Tabs.List,{className:ve("sticky top-0 z-[2000] flex bg-(--color-background)",f),children:[i.jsx(c.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(c.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(c.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(c.Tabs.Content,{value:"edit",children:[s&&i.jsxs(c.Text,{children:["Create your form using various field types. Sections can be"," ",i.jsx("strong",{children:"conditionally rendered"})," based on"," ",i.jsx("strong",{children:"answers to fields in preceding sections. "})]}),i.jsxs("form",{className:"mt-3 flex flex-col gap-2",id:mt,onSubmit:y.handleSubmit,children:[i.jsxs(V.FormikProvider,{value:y,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(ge,{name:"title",render:({setValue:I,value:b,meta:S})=>i.jsx(jt,{severity:"danger",helpText:S.error??null,children:i.jsx(c.Input.Root,{variant:"outline",size:"md",accentColor:S.error?de.danger:"primary",children:i.jsx(c.Input.Field,{placeholder:"Form title",value:b,onChange:N=>{I(N.target.value)},maxLength:100})})})}),i.jsx(ge,{name:"description",render:({setValue:I,value:b})=>i.jsx(c.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:b,onChange:S=>{I(S.target.value)},resize:"vertical",maxLength:1e3,size:"md"})})]}),i.jsx(kr,{fieldsOnly:m}),i.jsx("span",{"data-accent-color":de.danger,className:"text-xs text-(--accent-a11)",children:typeof y.errors.fields=="string"&&y.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(c.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(c.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(c.Tabs.Content,{value:"preview",children:i.jsx(Or,{schema:E,onSubmit:Ko,hideTitle:!l})})]})})})),Yo=Object.values(ie.Colors),Jo=1;async function Zo(t,n,e,r){const o=t.getContext("2d",{}),a=new Image(r.width,r.height),s=new Image(r.width,r.height),l=new ie.DeferredPromise;return a.onload=function(){o.drawImage(a,0,0,r.width,r.height),s.src=URL.createObjectURL(e),s.onload=async function(){o.drawImage(s,0,0,r.width,r.height);const m=t.toDataURL("image/jpeg",Jo),u=await ie.fileToBlob(m),f=new File([u],n.name,{type:"image/jpeg"});l.resolve(f)}},a.src=URL.createObjectURL(n),l}const Ur=d.memo(t=>{const{file:n,onClose:e,onSave:r,onDelete:o,dirty:a,onDirty:s}=t;n.objectURL||(n.objectURL=URL.createObjectURL(n));const l=d.useRef(null),m=d.useRef(null),[u,f]=d.useState(ie.Colors.red),[h,g]=d.useState(null),[C,w]=d.useState(!1),[p,y]=d.useState(!1),E=d.useRef(null),I=c.useSize(E);d.useEffect(()=>{const z=new Image;z.onload=function(){g({width:z.naturalWidth,height:z.naturalHeight})},z.src=URL.createObjectURL(n)},[n]),d.useEffect(()=>{!p&&(I!=null&&I.width)&&I.height&&y(!0)},[I,p]);const b=d.useCallback(async()=>{a||e();const z=l.current;if(!z)return;if(!h)throw new Error("Original image size not loaded yet");const X=await z.exportImage("png"),P=new Image(h.width,h.height);P.onload=async function(){const W=await ie.fileToBlob(X),le=new File([W],n.name,{type:n.type}),te=m.current,ce=await Zo(te,n,le,h);ce.objectURL=URL.createObjectURL(ce);const Oe=await ie.hashFile(n);await ie.hashFile(ce)!==Oe&&r(ce),w(!1),e()},w(!0),P.src=X},[a,n,e,r,h]),S=d.useCallback(()=>{o(n)},[n,o]),N=d.useCallback(()=>{e()},[e]),D=d.useCallback(()=>{s(!0)},[s]),F=d.useCallback(()=>{l.current&&l.current.redo()},[]),L=d.useCallback(()=>{l.current&&l.current.undo()},[]),A=d.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),O=d.useCallback(z=>{l.current&&l.current.eraseMode(z)},[]),q=d.useCallback(()=>{b()},[b]),ee=d.useCallback(()=>{kt.saveAs(n,n.name)},[n]);return i.jsx(zt,{open:!0,onOpenChange:e,children:i.jsxs(_t,{children:[i.jsx(Vt,{className:"bg-(--color-background) fixed inset-0 data-[state='open']:fade-in-0 data-[state='open']:zoom-in-95 data-[state='closed']:animate-out data-[state='closed']:fade-out-0 data-[state='closed']:zoom-out-95 data-[state='open']:animate-in","data-floating-content":""}),i.jsxs($t,{className:"absolute inset-0 py-12","data-floating-content":"",children:[i.jsx(c.ButtonGroup,{className:"flex w-full gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",size:"md",variant:"soft",children:i.jsxs("div",{className:"grid w-full grid-cols-3",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(c.IconButton,{"aria-label":"close",onClick:N,children:i.jsx(c.RiIcon,{icon:"RiCloseLine"})}),i.jsx(c.IconButton,{"aria-label":`Download ${n.name}`,onClick:ee,children:i.jsx(c.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(vt,{selectedColor:u,allColors:Yo,onFinish:f,trigger:i.jsx(c.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:u},children:" "})}),i.jsx(c.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:O,children:i.jsx(c.RiIcon,{icon:"RiEraserFill"})}),i.jsx(c.Separator,{orientation:"vertical",size:"full"}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:L,children:i.jsx(c.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(c.IconButton,{"aria-label":"undo",onClick:F,children:i.jsx(c.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(c.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(c.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(c.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:q,children:i.jsx(c.RiIcon,{icon:"RiSaveLine"})}),i.jsx(c.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(c.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})}),h&&i.jsx("canvas",{id:"attachment-markup-canvas",className:"hidden",ref:m,width:h.width,height:h.height}),i.jsxs("div",{className:"relative size-full flex items-center justify-center p-4 overflow-hidden",children:[i.jsx("img",{className:"max-w-full max-h-full invisible absolute",alt:"Photo attachment",ref:E,src:n.objectURL}),C?i.jsx(c.Spinner,{}):i.jsx(Xr.ReactSketchCanvas,{className:"max-w-full max-h-full aspect-square",backgroundImage:n.objectURL,ref:l,onStroke:D,strokeColor:u},p?"1":"0")]})]})]})})});Ur.displayName="AttachmentEditor",x.BaseField=k,x.BaseFormElement=bt,x.BooleanField=xe,x.BooleanInput=Wt,x.ColorPicker=vt,x.DateField=tt,x.DateInput=qt,x.FieldSection=U,x.FileCard=yt,x.FileIcon=$e,x.FormBuilder=Qo,x.FormRenderer=Or,x.ImageCard=Lr,x.ImageMarkup=Ur,x.ImageViewer=Ut,x.ImageViewerProvider=fr,x.InputWithHelpText=jt,x.InputWithLabel=Y,x.InputWithLabelAndHelpText=J,x.MultiSelectField=_e,x.MultiSelectInput=Rt,x.MultiStringField=ze,x.MultiStringInput=Qt,x.NumberField=se,x.NumberInput=Yt,x.PatchField=ge,x.PatchFormProvider=qo,x.QrField=at,x.QrInput=Jt,x.QrScanner=Zt,x.SUPPORTED_IMAGE_FILE_TYPES=vn,x.SUPPORTED_PDF_FILE_TYPES=bn,x.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=yn,x.SelectField=Ve,x.SelectInput=en,x.StringField=lt,x.StringInput=tn,x.TextField=ct,x.TextInput=nn,x.decodeFormValues=ko,x.deserialize=ut,x.deserializeField=an,x.emptyBaseField=H,x.emptyBooleanField=hr,x.emptyDateField=pr,x.emptyMultiSelectField=Er,x.emptyMultiStringField=br,x.emptyNumberField=Cr,x.emptyQrField=Ir,x.emptySelectField=Sr,x.emptyStringField=Nr,x.emptyTextField=Fr,x.encodeFormValues=Uo,x.fieldIcons=Yr,x.flattenFields=sn,x.formRevisionToSchema=Ar,x.initialFormValues=pt,x.isConditionMet=ln,x.useFieldInput=Ht,x.useFieldInputs=Be,x.useFormikInput=G,x.useImageViewer=Ue,x.validateForm=ht,x.valueIsFile=ft,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@overmap-ai/forms",
3
3
  "private": false,
4
- "version": "1.0.17-blur-updates.0",
4
+ "version": "1.0.17-blur-updates.1",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/forms.umd.cjs",
7
7
  "module": "dist/forms.js",