@overmap-ai/forms 1.0.17-file-viewer-updates.0 → 1.0.17-file-viewer-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
@@ -1,8 +1,8 @@
1
- var nr = Object.defineProperty;
2
- var ir = (t, n, e) => n in t ? nr(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
- var x = (t, n, e) => ir(t, typeof n != "symbol" ? n + "" : n, e);
1
+ var ir = Object.defineProperty;
2
+ var rr = (t, n, e) => n in t ? ir(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var x = (t, n, e) => rr(t, typeof n != "symbol" ? n + "" : n, e);
4
4
  import { jsxs as v, jsx as a, Fragment as Q } from "react/jsx-runtime";
5
- import { Popover as Oe, IconButton as _, RiIcon as T, Badge as Ut, Spinner as gt, Text as $e, Checkbox as rt, Input as oe, useToast as Wt, Button as K, Card as Ve, Menu as z, TextArea as Vn, useSize as jn, ButtonGroup as qt, Tooltip as we, Separator as Ht, Dialog as rr, Heading as Un, useAlertDialog as or, Tabs as xe, IconToggleButton as ar } from "@overmap-ai/blocks";
5
+ import { Popover as Oe, IconButton as _, RiIcon as T, Badge as Ut, Spinner as gt, Text as $e, Checkbox as rt, Input as oe, useToast as Wt, Button as K, Card as Ve, Menu as z, TextArea as Vn, useSize as jn, ButtonGroup as qt, Tooltip as we, Separator as Ht, Heading as Un, useAlertDialog as or, Tabs as xe, IconToggleButton as ar } from "@overmap-ai/blocks";
6
6
  import * as p from "react";
7
7
  import { memo as A, useCallback as R, useMemo as P, forwardRef as We, useState as W, useEffect as X, useRef as re, useLayoutEffect as sr, createContext as lr, useContext as cr, useReducer as dr, Fragment as ur } from "react";
8
8
  import { truncate as Gt, slugify as fr, downloadFile as Wn, Colors as qn, fileToBlob as Hn, hashFile as Cn, DeferredPromise as mr } from "@overmap-ai/core";
@@ -2202,8 +2202,8 @@ var Ca = p.forwardRef(
2202
2202
  }
2203
2203
  ),
2204
2204
  /* @__PURE__ */ v(Q, { children: [
2205
- /* @__PURE__ */ a(Ra, { titleId: l.titleId }),
2206
- /* @__PURE__ */ a(La, { contentRef: f, descriptionId: l.descriptionId })
2205
+ /* @__PURE__ */ a(Na, { titleId: l.titleId }),
2206
+ /* @__PURE__ */ a(Ta, { contentRef: f, descriptionId: l.descriptionId })
2207
2207
  ] })
2208
2208
  ] });
2209
2209
  }
@@ -2221,7 +2221,7 @@ var Pi = "DialogDescription", Sa = p.forwardRef(
2221
2221
  }
2222
2222
  );
2223
2223
  Sa.displayName = Pi;
2224
- var ki = "DialogClose", Na = p.forwardRef(
2224
+ var ki = "DialogClose", Oi = p.forwardRef(
2225
2225
  (t, n) => {
2226
2226
  const { __scopeDialog: e, ...i } = t, r = ee(ki, e);
2227
2227
  return /* @__PURE__ */ a(
@@ -2235,16 +2235,16 @@ var ki = "DialogClose", Na = p.forwardRef(
2235
2235
  );
2236
2236
  }
2237
2237
  );
2238
- Na.displayName = ki;
2238
+ Oi.displayName = ki;
2239
2239
  function ln(t) {
2240
2240
  return t ? "open" : "closed";
2241
2241
  }
2242
- var Oi = "DialogTitleWarning", [vs, Mi] = Jr(Oi, {
2242
+ var Mi = "DialogTitleWarning", [vs, _i] = Jr(Mi, {
2243
2243
  contentName: ve,
2244
2244
  titleName: sn,
2245
2245
  docsSlug: "dialog"
2246
- }), Ra = ({ titleId: t }) => {
2247
- const n = Mi(Oi), e = `\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
2246
+ }), Na = ({ titleId: t }) => {
2247
+ const n = _i(Mi), e = `\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
2248
2248
 
2249
2249
  If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
2250
2250
 
@@ -2252,15 +2252,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do
2252
2252
  return p.useEffect(() => {
2253
2253
  t && (document.getElementById(t) || console.error(e));
2254
2254
  }, [e, t]), null;
2255
- }, Ta = "DialogDescriptionWarning", La = ({ contentRef: t, descriptionId: n }) => {
2256
- const i = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Mi(Ta).contentName}}.`;
2255
+ }, Ra = "DialogDescriptionWarning", Ta = ({ contentRef: t, descriptionId: n }) => {
2256
+ const i = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${_i(Ra).contentName}}.`;
2257
2257
  return p.useEffect(() => {
2258
2258
  var o;
2259
2259
  const r = (o = t.current) == null ? void 0 : o.getAttribute("aria-describedby");
2260
2260
  n && r && (document.getElementById(n) || console.warn(i));
2261
2261
  }, [i, t, n]), null;
2262
- }, cn = Ni, dn = Li, un = Fi, fn = Di;
2263
- const _i = A((t) => {
2262
+ }, cn = Ni, dn = Li, un = Fi, fn = Di, La = Oi;
2263
+ const zi = A((t) => {
2264
2264
  const [{ inputId: n, labelId: e, label: i, helpText: r, size: o, severity: s, showInputOnly: l, field: f, fieldProps: c }, d] = j(t), [u, h] = W(!1), g = c.value, b = R(
2265
2265
  (w) => {
2266
2266
  c.onChange({ target: { value: w } }), h(!1);
@@ -2286,7 +2286,7 @@ const _i = A((t) => {
2286
2286
  children: [
2287
2287
  /* @__PURE__ */ a(cn, { open: u, onOpenChange: h, children: /* @__PURE__ */ v(dn, { children: [
2288
2288
  /* @__PURE__ */ a(un, { className: "light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)" }),
2289
- /* @__PURE__ */ a(fn, { className: "fixed inset-0", children: /* @__PURE__ */ a(zi, { onQrScan: b, onClose: C }) })
2289
+ /* @__PURE__ */ a(fn, { className: "fixed inset-0", children: /* @__PURE__ */ a($i, { onQrScan: b, onClose: C }) })
2290
2290
  ] }) }),
2291
2291
  /* @__PURE__ */ v("div", { className: "flex w-max items-center gap-1", children: [
2292
2292
  /* @__PURE__ */ v(K, { ...d, variant: "soft", onClick: y, type: "button", children: [
@@ -2313,8 +2313,8 @@ const _i = A((t) => {
2313
2313
  }
2314
2314
  ) });
2315
2315
  });
2316
- _i.displayName = "QrInput";
2317
- const zi = A((t) => {
2316
+ zi.displayName = "QrInput";
2317
+ const $i = A((t) => {
2318
2318
  const { onQrScan: n, onClose: e } = t, i = re(null), [r, o] = W(!1);
2319
2319
  return X(() => {
2320
2320
  if (!i.current) return;
@@ -2341,7 +2341,7 @@ const zi = A((t) => {
2341
2341
  ] })
2342
2342
  ] });
2343
2343
  });
2344
- zi.displayName = "QrScanner";
2344
+ $i.displayName = "QrScanner";
2345
2345
  const Fa = {
2346
2346
  ...Z,
2347
2347
  type: "qr"
@@ -2358,12 +2358,12 @@ const Fa = {
2358
2358
  return new Te(e);
2359
2359
  }
2360
2360
  getInput(e) {
2361
- return /* @__PURE__ */ a(_i, { ...e, field: this });
2361
+ return /* @__PURE__ */ a(zi, { ...e, field: this });
2362
2362
  }
2363
2363
  };
2364
2364
  x(Te, "fieldTypeName", "QR"), x(Te, "fieldTypeDescription", "Used for scanning/reading QR codes."), x(Te, "Icon", yr);
2365
2365
  let Mt = Te;
2366
- class $i extends G {
2366
+ class Bi extends G {
2367
2367
  constructor(e) {
2368
2368
  const { placeholder: i = "", ...r } = e;
2369
2369
  super(r);
@@ -2400,7 +2400,7 @@ class $i extends G {
2400
2400
  ];
2401
2401
  }
2402
2402
  }
2403
- const Da = (t) => t ? Array.isArray(t) ? t : [t] : [], Bi = A((t) => {
2403
+ const Da = (t) => t ? Array.isArray(t) ? t : [t] : [], Vi = A((t) => {
2404
2404
  const [{ inputId: n, labelId: e, size: i, severity: r, showInputOnly: o, field: s, fieldProps: l }, f] = j(t), { onChange: c, onBlur: d } = l;
2405
2405
  let [{ helpText: u, label: h }] = j(t);
2406
2406
  u = o ? null : u, h = o ? "" : h;
@@ -2450,12 +2450,12 @@ const Da = (t) => t ? Array.isArray(t) ? t : [t] : [], Bi = A((t) => {
2450
2450
  }
2451
2451
  ) });
2452
2452
  });
2453
- Bi.displayName = "MultiSelectInput";
2453
+ Vi.displayName = "MultiSelectInput";
2454
2454
  const Aa = {
2455
2455
  ...Z,
2456
2456
  type: "multi-select",
2457
2457
  options: []
2458
- }, Le = class Le extends $i {
2458
+ }, Le = class Le extends Bi {
2459
2459
  constructor(n) {
2460
2460
  const { placeholder: e = "Select one or more...", ...i } = n;
2461
2461
  super({ ...i, placeholder: e, type: "multi-select" });
@@ -2475,12 +2475,12 @@ const Aa = {
2475
2475
  return new Le(n);
2476
2476
  }
2477
2477
  getInput(n) {
2478
- return /* @__PURE__ */ a(Bi, { field: this, ...n });
2478
+ return /* @__PURE__ */ a(Vi, { field: this, ...n });
2479
2479
  }
2480
2480
  };
2481
2481
  x(Le, "fieldTypeName", "Multi-select"), x(Le, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), x(Le, "Icon", br);
2482
2482
  let mt = Le;
2483
- const Vi = A((t) => {
2483
+ const ji = A((t) => {
2484
2484
  const [{ inputId: n, labelId: e, size: i, severity: r, showInputOnly: o, field: s, fieldProps: l }, f] = j(t), { onChange: c, onBlur: d } = l;
2485
2485
  let [{ helpText: u, label: h }] = j(t);
2486
2486
  u = o ? null : u, h = o ? "" : h;
@@ -2525,12 +2525,12 @@ const Vi = A((t) => {
2525
2525
  }
2526
2526
  ) });
2527
2527
  });
2528
- Vi.displayName = "SelectInput";
2528
+ ji.displayName = "SelectInput";
2529
2529
  const Pa = {
2530
2530
  ...Z,
2531
2531
  type: "select",
2532
2532
  options: []
2533
- }, Fe = class Fe extends $i {
2533
+ }, Fe = class Fe extends Bi {
2534
2534
  constructor(n) {
2535
2535
  const { placeholder: e = "Select one...", ...i } = n;
2536
2536
  super({ ...i, placeholder: e, type: "select" });
@@ -2546,7 +2546,7 @@ const Pa = {
2546
2546
  return new Fe(n);
2547
2547
  }
2548
2548
  getInput(n) {
2549
- return /* @__PURE__ */ a(Vi, { field: this, ...n });
2549
+ return /* @__PURE__ */ a(ji, { field: this, ...n });
2550
2550
  }
2551
2551
  };
2552
2552
  x(Fe, "fieldTypeName", "Dropdown"), x(Fe, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), x(Fe, "Icon", wr);
@@ -2634,7 +2634,7 @@ x(pt, "_validateMax", (e) => (i, r) => {
2634
2634
  const { minimum_length: o } = zn(r) ? J(r, e) : r;
2635
2635
  return typeof o != "number" ? null : o > i ? "Maximum cannot be less than minimum." : null;
2636
2636
  });
2637
- const ji = A((t) => {
2637
+ const Ui = A((t) => {
2638
2638
  const [{ inputId: n, labelId: e, size: i, severity: r, showInputOnly: o, field: s, fieldProps: l }, f] = j(t);
2639
2639
  let [{ helpText: c, label: d }] = j(t);
2640
2640
  return c = o ? null : c, d = o ? "" : d, /* @__PURE__ */ a(se, { helpText: c, severity: r, children: /* @__PURE__ */ a(
@@ -2659,7 +2659,7 @@ const ji = A((t) => {
2659
2659
  }
2660
2660
  ) });
2661
2661
  });
2662
- ji.displayName = "StringInput";
2662
+ Ui.displayName = "StringInput";
2663
2663
  const ka = {
2664
2664
  ...Z,
2665
2665
  type: "string",
@@ -2687,12 +2687,12 @@ const ka = {
2687
2687
  });
2688
2688
  }
2689
2689
  getInput(e) {
2690
- return /* @__PURE__ */ a(ji, { field: this, ...e });
2690
+ return /* @__PURE__ */ a(Ui, { field: this, ...e });
2691
2691
  }
2692
2692
  };
2693
2693
  x(De, "fieldTypeName", "Short Text"), x(De, "fieldTypeDescription", `Short text fields can hold up to ${Je} characters on a single line.`), x(De, "Icon", xr);
2694
2694
  let _t = De;
2695
- const Ui = A((t) => {
2695
+ const Wi = A((t) => {
2696
2696
  const [{ inputId: n, labelId: e, size: i, severity: r, showInputOnly: o, field: s, fieldProps: l }, f] = j(t);
2697
2697
  let [{ helpText: c, label: d }] = j(t);
2698
2698
  return c = o ? null : c, d = o ? "" : d, /* @__PURE__ */ a(se, { helpText: c, severity: r, children: /* @__PURE__ */ a(
@@ -2720,7 +2720,7 @@ const Ui = A((t) => {
2720
2720
  }
2721
2721
  ) });
2722
2722
  });
2723
- Ui.displayName = "TextInput";
2723
+ Wi.displayName = "TextInput";
2724
2724
  const Oa = {
2725
2725
  ...Z,
2726
2726
  type: "text",
@@ -2744,7 +2744,7 @@ const Oa = {
2744
2744
  });
2745
2745
  }
2746
2746
  getInput(n) {
2747
- return /* @__PURE__ */ a(Ui, { field: this, ...n });
2747
+ return /* @__PURE__ */ a(Wi, { field: this, ...n });
2748
2748
  }
2749
2749
  };
2750
2750
  x(Ae, "fieldTypeName", "Paragraph"), x(Ae, "fieldTypeDescription", `Paragraph fields can hold up to ${Me} characters and can have multiple lines.`), x(Ae, "Icon", Cr);
@@ -2803,9 +2803,9 @@ const Ma = A(
2803
2803
  }
2804
2804
  );
2805
2805
  })
2806
- ), Wi = lr(() => {
2806
+ ), qi = lr(() => {
2807
2807
  throw new Error("No ImageViewerProvider found");
2808
- }), _a = () => cr(Wi), qi = A((t) => {
2808
+ }), _a = () => cr(qi), Hi = A((t) => {
2809
2809
  const { file: n, onClose: e } = t, i = re(null), r = R(() => {
2810
2810
  var l;
2811
2811
  if (!i.current) return;
@@ -2844,7 +2844,7 @@ const Ma = A(
2844
2844
  /* @__PURE__ */ a(we.Content, { size: "sm", children: "Download" })
2845
2845
  ] }),
2846
2846
  /* @__PURE__ */ a(Ht, { orientation: "vertical", size: "sm" }),
2847
- /* @__PURE__ */ a(rr.Close, { asChild: !0, children: /* @__PURE__ */ a(_, { onClick: e, "aria-label": "close", children: /* @__PURE__ */ a(T, { icon: "RiCloseLine" }) }) })
2847
+ /* @__PURE__ */ a(La, { asChild: !0, children: /* @__PURE__ */ a(_, { onClick: e, "aria-label": "close", children: /* @__PURE__ */ a(T, { icon: "RiCloseLine" }) }) })
2848
2848
  ]
2849
2849
  }
2850
2850
  ),
@@ -2863,7 +2863,7 @@ const Ma = A(
2863
2863
  }
2864
2864
  ) }) });
2865
2865
  });
2866
- qi.displayName = "ImageViewer";
2866
+ Hi.displayName = "ImageViewer";
2867
2867
  const za = A((t) => {
2868
2868
  const { children: n } = t, [e, i] = W(null), r = R(() => {
2869
2869
  i(null);
@@ -2875,9 +2875,9 @@ const za = A((t) => {
2875
2875
  ), s = R(() => {
2876
2876
  e && (e.onClose && e.onClose(), r());
2877
2877
  }, [r, e]), l = P(() => o, [o]);
2878
- return /* @__PURE__ */ v(Wi.Provider, { value: l, children: [
2878
+ return /* @__PURE__ */ v(qi.Provider, { value: l, children: [
2879
2879
  n,
2880
- e && /* @__PURE__ */ a(qi, { file: e.file, onClose: s })
2880
+ e && /* @__PURE__ */ a(Hi, { file: e.file, onClose: s })
2881
2881
  ] });
2882
2882
  });
2883
2883
  za.displayName = "FileViewerProvider";
@@ -2892,7 +2892,7 @@ const $a = (t) => {
2892
2892
  style: "unit",
2893
2893
  unit: n[i]
2894
2894
  }).format(e);
2895
- }, Hi = A((t) => {
2895
+ }, Gi = A((t) => {
2896
2896
  var I;
2897
2897
  const [{ inputId: n, labelId: e, size: i, severity: r, helpText: o, showInputOnly: s, field: l, fieldProps: f }, c] = j(t), { onChange: d } = f;
2898
2898
  let [{ label: u }] = j(t);
@@ -2953,7 +2953,7 @@ const $a = (t) => {
2953
2953
  }
2954
2954
  ) }),
2955
2955
  Array.isArray(b) && b.length > 0 && /* @__PURE__ */ a("div", { className: "flex h-max flex-col gap-2", children: b.map((L, N) => /* @__PURE__ */ a(
2956
- Gi,
2956
+ Xi,
2957
2957
  {
2958
2958
  field: l,
2959
2959
  file: L,
@@ -2966,8 +2966,8 @@ const $a = (t) => {
2966
2966
  )) })
2967
2967
  ] });
2968
2968
  });
2969
- Hi.displayName = "UploadInput";
2970
- const Gi = A((t) => {
2969
+ Gi.displayName = "UploadInput";
2970
+ const Xi = A((t) => {
2971
2971
  const { file: n, field: e, onRemove: i, disabled: r } = t, [o, s] = W(null), l = _a(), f = P(() => o && e.getError([o]), [e, o]), { url: c, name: d } = P(() => {
2972
2972
  let m = null, y, C;
2973
2973
  return o != null && o.type.startsWith("image/") && (m = URL.createObjectURL(o)), o ? (y = o.name, C = $a(o.size)) : (y = "Downloading...", C = "..."), { url: m, name: y, size: C };
@@ -3013,7 +3013,7 @@ const Gi = A((t) => {
3013
3013
  }
3014
3014
  ) : /* @__PURE__ */ a(Yn, { file: o, error: f ?? void 0, rightSlot: b });
3015
3015
  });
3016
- Gi.displayName = "DisplayFile";
3016
+ Xi.displayName = "DisplayFile";
3017
3017
  const Ba = {
3018
3018
  ...Z,
3019
3019
  type: "upload",
@@ -3120,7 +3120,7 @@ const Ba = {
3120
3120
  return new Pe(e);
3121
3121
  }
3122
3122
  getInput(e) {
3123
- return /* @__PURE__ */ a(Hi, { field: this, ...e });
3123
+ return /* @__PURE__ */ a(Gi, { field: this, ...e });
3124
3124
  }
3125
3125
  };
3126
3126
  x(Pe, "fieldTypeName", "Upload"), x(Pe, "fieldTypeDescription", "Allows a file to be uploaded."), x(Pe, "Icon", Er);
@@ -3151,10 +3151,10 @@ const mn = {
3151
3151
  // TODO: Underscore
3152
3152
  "multi-string": Yr,
3153
3153
  "multi-select": Aa
3154
- }, nt = 50, ja = nt * 1e3, Ua = ja * 1e3, Xi = (t) => {
3154
+ }, nt = 50, ja = nt * 1e3, Ua = ja * 1e3, Ki = (t) => {
3155
3155
  const n = t.type;
3156
3156
  return mn[n].deserialize(t);
3157
- }, hn = (t) => t.type === "section" ? H.deserialize(t) : Xi(t);
3157
+ }, hn = (t) => t.type === "section" ? H.deserialize(t) : Ki(t);
3158
3158
  function Wa(t, n = {}) {
3159
3159
  const { readonly: e = !1 } = n;
3160
3160
  return {
@@ -3164,7 +3164,7 @@ function Wa(t, n = {}) {
3164
3164
  meta: { readonly: e }
3165
3165
  };
3166
3166
  }
3167
- function Ki(t) {
3167
+ function Yi(t) {
3168
3168
  const n = [];
3169
3169
  for (const e of t.fields)
3170
3170
  if (e instanceof H)
@@ -3178,7 +3178,7 @@ function Ki(t) {
3178
3178
  return n;
3179
3179
  }
3180
3180
  function ys(t, n) {
3181
- const e = Ki(t), i = {};
3181
+ const e = Yi(t), i = {};
3182
3182
  for (const r of e) {
3183
3183
  const o = n[r.identifier] ?? null;
3184
3184
  o !== null ? i[r.identifier] = r.decodeJsonToValue(o) : i[r.identifier] = o;
@@ -3186,7 +3186,7 @@ function ys(t, n) {
3186
3186
  return i;
3187
3187
  }
3188
3188
  function bs(t, n) {
3189
- const e = Ki(t), i = {};
3189
+ const e = Yi(t), i = {};
3190
3190
  for (const r of e) {
3191
3191
  const o = n[r.identifier];
3192
3192
  i[r.identifier] = r.encodeValueToJson(o);
@@ -3196,7 +3196,7 @@ function bs(t, n) {
3196
3196
  function Bt(t) {
3197
3197
  return Array.isArray(t) && t.some((n) => n instanceof File || n instanceof Promise);
3198
3198
  }
3199
- function Yi(t, n) {
3199
+ function Qi(t, n) {
3200
3200
  if (!t) return !0;
3201
3201
  if (Bt(n) || Bt(t.value)) throw new Error("Conditions do not support file uploads");
3202
3202
  const e = Array.isArray(n) ? n.map((r) => typeof r == "string" ? r : r.value) : n, i = Array.isArray(t.value) ? t.value.map((r) => typeof r == "string" ? r : r.value) : t.value;
@@ -3207,9 +3207,9 @@ function Yi(t, n) {
3207
3207
  }
3208
3208
  return i === n;
3209
3209
  }
3210
- const Qi = A((t) => {
3210
+ const Ji = A((t) => {
3211
3211
  const { field: n, ...e } = t, { label: i, description: r, fields: o, condition: s } = n, { values: l, setFieldValue: f } = ye(), c = s != null && s.identifier ? J(l, s.identifier) : void 0, d = P(
3212
- () => c === void 0 || Yi(s, c),
3212
+ () => c === void 0 || Qi(s, c),
3213
3213
  [s, c]
3214
3214
  );
3215
3215
  X(() => {
@@ -3226,7 +3226,7 @@ const Qi = A((t) => {
3226
3226
  u
3227
3227
  ] }) }) : null;
3228
3228
  });
3229
- Qi.displayName = "FieldSectionLayout";
3229
+ Ji.displayName = "FieldSectionLayout";
3230
3230
  const ke = class ke extends Qn {
3231
3231
  constructor(e) {
3232
3232
  const { label: i = null, fields: r, condition: o = null, conditional: s, ...l } = e;
@@ -3307,7 +3307,7 @@ const ke = class ke extends Qn {
3307
3307
  static deserialize(e) {
3308
3308
  if (e.type !== "section") throw new Error("Invalid type");
3309
3309
  if (!Array.isArray(e.fields)) throw new Error(`Invalid fields: ${e.fields} (not an array)`);
3310
- const i = e.fields.map(Xi);
3310
+ const i = e.fields.map(Ki);
3311
3311
  return new ke({ ...e, fields: i });
3312
3312
  }
3313
3313
  conditional() {
@@ -3331,7 +3331,7 @@ const ke = class ke extends Qn {
3331
3331
  return i;
3332
3332
  }
3333
3333
  getInput(e) {
3334
- return /* @__PURE__ */ a(Qi, { field: this, ...e });
3334
+ return /* @__PURE__ */ a(Ji, { field: this, ...e });
3335
3335
  }
3336
3336
  };
3337
3337
  x(ke, "fieldTypeName", "Section"), x(ke, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
@@ -3342,7 +3342,7 @@ const he = (t) => Object.keys(t).length > 0, pn = (t, n) => {
3342
3342
  if (i instanceof H) {
3343
3343
  if (i.condition) {
3344
3344
  const { identifier: r } = i.condition;
3345
- if (!Yi(i.condition, J(n, r)))
3345
+ if (!Qi(i.condition, J(n, r)))
3346
3346
  continue;
3347
3347
  }
3348
3348
  Object.assign(e, i.getErrors(n));
@@ -3615,7 +3615,7 @@ const ws = A(
3615
3615
  ] });
3616
3616
  });
3617
3617
  vn.displayName = "FieldActions";
3618
- const Ji = (t = () => null) => P(() => Xa.map((n) => n.map((e) => {
3618
+ const Zi = (t = () => null) => P(() => Xa.map((n) => n.map((e) => {
3619
3619
  const i = mn[e], r = i.Icon;
3620
3620
  return {
3621
3621
  children: i.fieldTypeName,
@@ -3648,7 +3648,7 @@ const Ji = (t = () => null) => P(() => Xa.map((n) => n.map((e) => {
3648
3648
  jt.displayName = "FieldSettingsPopover";
3649
3649
  const yn = A((t) => {
3650
3650
  var qe, Ct, bn, wn, xn;
3651
- const { parentPath: n, index: e, initial: i, conditionalSourceFields: r } = t, { values: o, setFieldValue: s, errors: l } = ye(), f = Ji(), c = re(null), d = 576, [u, h] = W(
3651
+ const { parentPath: n, index: e, initial: i, conditionalSourceFields: r } = t, { values: o, setFieldValue: s, errors: l } = ye(), f = Zi(), c = re(null), d = 576, [u, h] = W(
3652
3652
  c.current && c.current.getBoundingClientRect().width >= d
3653
3653
  );
3654
3654
  X(() => {
@@ -3856,7 +3856,7 @@ const yn = A((t) => {
3856
3856
  ] }) });
3857
3857
  });
3858
3858
  yn.displayName = "FieldBuilder";
3859
- const Zi = A((t) => {
3859
+ const er = A((t) => {
3860
3860
  const { field: n, index: e, sectionIndex: i, remove: r } = t, { setFieldValue: o, values: s } = ye(), { reorderField: l } = nn(), { showError: f } = Wt(), c = `fields.${i}.fields`, d = P(
3861
3861
  () => ({
3862
3862
  index: e,
@@ -3933,8 +3933,8 @@ const Zi = A((t) => {
3933
3933
  }
3934
3934
  ) });
3935
3935
  });
3936
- Zi.displayName = "FieldWithActions";
3937
- const er = A((t) => {
3936
+ er.displayName = "FieldWithActions";
3937
+ const tr = A((t) => {
3938
3938
  var S;
3939
3939
  const { field: n, index: e, dropState: i, fieldsOnly: r } = t, o = (S = i[n.identifier]) == null ? void 0 : S.disabled, { setFieldValue: s, values: l } = ye(), f = or(), { reorderSection: c } = nn(), d = R(
3940
3940
  (E, I) => {
@@ -4032,7 +4032,7 @@ const er = A((t) => {
4032
4032
  );
4033
4033
  },
4034
4034
  [e, n.fields.length, l, s]
4035
- ), w = Ji(C);
4035
+ ), w = Zi(C);
4036
4036
  return /* @__PURE__ */ a(Zt, { draggableId: n.identifier, index: e, children: (E) => /* @__PURE__ */ a(
4037
4037
  Ve,
4038
4038
  {
@@ -4058,7 +4058,7 @@ const er = A((t) => {
4058
4058
  ...I.droppableProps,
4059
4059
  children: [
4060
4060
  n.fields.map((L, N) => /* @__PURE__ */ a(
4061
- Zi,
4061
+ er,
4062
4062
  {
4063
4063
  field: L,
4064
4064
  index: N,
@@ -4100,11 +4100,11 @@ const er = A((t) => {
4100
4100
  }
4101
4101
  ) });
4102
4102
  });
4103
- er.displayName = "FieldSectionWithActions";
4103
+ tr.displayName = "FieldSectionWithActions";
4104
4104
  const Bn = (t, n) => {
4105
4105
  for (const [e, i] of Object.entries(t))
4106
4106
  if (i.identifier === n) return [i, e];
4107
- }, tr = A((t) => {
4107
+ }, nr = A((t) => {
4108
4108
  const { fieldsOnly: n } = t, { values: e, setFieldValue: i } = ye(), [r, o] = dr(Ka, e.fields, $n), { reorderSection: s, reorderField: l } = nn();
4109
4109
  X(() => {
4110
4110
  o({ type: "update", state: $n(e.fields) });
@@ -4147,7 +4147,7 @@ const Bn = (t, n) => {
4147
4147
  children: [
4148
4148
  e.fields.map((h, g) => /* @__PURE__ */ v(ur, { children: [
4149
4149
  /* @__PURE__ */ a(
4150
- er,
4150
+ tr,
4151
4151
  {
4152
4152
  field: h,
4153
4153
  index: g,
@@ -4193,7 +4193,7 @@ const Bn = (t, n) => {
4193
4193
  }
4194
4194
  ) }) });
4195
4195
  });
4196
- tr.displayName = "FieldsEditor";
4196
+ nr.displayName = "FieldsEditor";
4197
4197
  const Qa = () => {
4198
4198
  alert("This is a form preview, your data will not be saved.");
4199
4199
  }, xs = A(
@@ -4326,7 +4326,7 @@ const Qa = () => {
4326
4326
  }
4327
4327
  )
4328
4328
  ] }),
4329
- /* @__PURE__ */ a(tr, { fieldsOnly: f }),
4329
+ /* @__PURE__ */ a(nr, { fieldsOnly: f }),
4330
4330
  /* @__PURE__ */ a(
4331
4331
  "span",
4332
4332
  {
@@ -4517,13 +4517,13 @@ export {
4517
4517
  Ga as FormRenderer,
4518
4518
  Ma as ImageCard,
4519
4519
  ts as ImageMarkup,
4520
- qi as ImageViewer,
4520
+ Hi as ImageViewer,
4521
4521
  za as ImageViewerProvider,
4522
4522
  Zn as InputWithHelpText,
4523
4523
  ae as InputWithLabel,
4524
4524
  se as InputWithLabelAndHelpText,
4525
4525
  mt as MultiSelectField,
4526
- Bi as MultiSelectInput,
4526
+ Vi as MultiSelectInput,
4527
4527
  dt as MultiStringField,
4528
4528
  si as MultiStringInput,
4529
4529
  pe as NumberField,
@@ -4531,20 +4531,20 @@ export {
4531
4531
  ze as PatchField,
4532
4532
  ws as PatchFormProvider,
4533
4533
  Mt as QrField,
4534
- _i as QrInput,
4535
- zi as QrScanner,
4534
+ zi as QrInput,
4535
+ $i as QrScanner,
4536
4536
  kr as SUPPORTED_IMAGE_FILE_TYPES,
4537
4537
  Mr as SUPPORTED_PDF_FILE_TYPES,
4538
4538
  Or as SUPPORTED_SPREADSHEET_FILE_EXTENSIONS,
4539
4539
  ht as SelectField,
4540
- Vi as SelectInput,
4540
+ ji as SelectInput,
4541
4541
  _t as StringField,
4542
- ji as StringInput,
4542
+ Ui as StringInput,
4543
4543
  zt as TextField,
4544
- Ui as TextInput,
4544
+ Wi as TextInput,
4545
4545
  ys as decodeFormValues,
4546
4546
  hn as deserialize,
4547
- Xi as deserializeField,
4547
+ Ki as deserializeField,
4548
4548
  Z as emptyBaseField,
4549
4549
  Wr as emptyBooleanField,
4550
4550
  qr as emptyDateField,
@@ -4556,10 +4556,10 @@ export {
4556
4556
  ka as emptyStringField,
4557
4557
  Oa as emptyTextField,
4558
4558
  bs as encodeFormValues,
4559
- Ki as flattenFields,
4559
+ Yi as flattenFields,
4560
4560
  Wa as formRevisionToSchema,
4561
4561
  gn as initialFormValues,
4562
- Yi as isConditionMet,
4562
+ Qi as isConditionMet,
4563
4563
  ii as useFieldInput,
4564
4564
  at as useFieldInputs,
4565
4565
  j as useFormikInput,
@@ -1,5 +1,5 @@
1
- (function(w,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("@overmap-ai/core"),require("formik"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("react-dom"),require("qr-scanner"),require("lodash.clonedeep"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","@overmap-ai/core","formik","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","react-dom","qr-scanner","lodash.clonedeep","react-sketch-canvas"],i):(w=typeof globalThis<"u"?globalThis:w||self,i(w.forms={},w.jsxRuntime,w.blocks,w.React,w.core,w.formik,w.ri,w.get,w.set,w.dnd,w.ReactDOM,w.QrScannerAPI,w.cloneDeep,w.reactSketchCanvas))})(this,function(w,i,d,f,H,k,U,X,ht,re,hn,qr,Hr,Gr){"use strict";var ea=Object.defineProperty;var ta=(w,i,d)=>i in w?ea(w,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):w[i]=d;var x=(w,i,d)=>ta(w,typeof i!="symbol"?i+"":i,d);function pn(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 g=pn(f),Xr=pn(hn),pt=f.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=f.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{children:o}),i.jsx(d.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(d.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(d.RiIcon,{icon:"RiCheckLine"})},s))})})]})});pt.displayName="ColorPicker";const mn=["image/jpeg","image/png","image/svg+xml"],gn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],vn=["application/pdf"],Me=f.memo(t=>{const{fileType:n}=t,e=f.useMemo(()=>gn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFileExcelLine"}):vn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFilePdfLine"}):mn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFileImageLine"}):i.jsx(d.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});Me.displayName="FileIcon";const yn=f.memo(t=>{const{file:n,truncateLength:e,hideName:r=!1,...o}=t,a=f.useMemo(()=>e!==void 0?H.truncate(n.name,e):n.name,[n.name,e]);return i.jsxs(d.Badge,{...o,children:[i.jsx(Me,{fileType:n.type}),!r&&a]})});yn.displayName="FileBadge";function bn(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=bn(t[n]))&&(r&&(r+=" "),r+=e)}else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}function Kr(){for(var t,n,e=0,r="",o=arguments.length;e<o;e++)(t=arguments[e])&&(n=bn(t))&&(r&&(r+=" "),r+=n);return r}const pe=Kr,mt=f.memo(f.forwardRef((t,n)=>{const{file:e,className:r,error:o,truncateLength:a,rightSlot:s,...l}=t,p=f.useMemo(()=>{if(e)return a!==void 0?H.truncate(e.name,a):e.name},[e,a]);return i.jsxs("div",{className:pe(r,"flex h-5 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,...l,children:[o?i.jsx(d.RiIcon,{icon:"RiFileWarningLine"}):i.jsx(Me,{fileType:(e==null?void 0:e.type)??""}),o||(e?p:i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(d.Spinner,{})})),s]})}));mt.displayName="FileCard";const ze=500,me=1e4,te={danger:"danger",warning:"warning",info:"base",success:"success"};class gt{constructor(n){x(this,"type");x(this,"identifier");x(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 G={label:"",description:"",required:!1};class j extends gt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...p}=e;super(p);x(this,"required");x(this,"formValidators");x(this,"fieldValidators");x(this,"label");x(this,"image");x(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)}}x(j,"fieldTypeName"),x(j,"fieldTypeDescription");const z=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,internal:s,...l}=t,[p,c,u]=k.useField(e.getId()),{touched:h}=c,v=c.error??e.description,y=c.error?"danger":void 0,C=n??`${r}-${e.getId()}-input`,m=`${C}-label`,b=e.required?`${e.label} *`:e.label,E=f.useMemo(()=>({...p,onChange:S=>{const F=e.getValueFromChangeEvent(S);u.setValue(F,!1).then(),(h||!e.onlyValidateAfterTouched)&&u.setError(e.getError(F))},onBlur:S=>{u.setTouched(!0,!1).then(),u.setError(e.getError(e.getValueFromChangeEvent(S)))}}),[e,p,u,h]);return console.debug("severity",y),[{helpText:v,size:o,severity:y,inputId:C,labelId:m,label:b,showInputOnly:a,internal:s,fieldProps:E,helpers:u,field:e},{...l,"aria-labelledby":m}]};var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ve={exports:{}},Yr=Ve.exports,wn;function Jr(){return wn||(wn=1,function(t,n){(function(e,r){r()})(Yr,function(){function e(c,u){return typeof u>"u"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,u,h){var v=new XMLHttpRequest;v.open("GET",c),v.responseType="blob",v.onload=function(){p(v.response,u,h)},v.onerror=function(){console.error("could not download file")},v.send()}function o(c){var u=new XMLHttpRequest;u.open("HEAD",c,!1);try{u.send()}catch{}return 200<=u.status&&299>=u.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(u)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof $e=="object"&&$e.global===$e?$e:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(c,u,h){var v=s.URL||s.webkitURL,y=document.createElement("a");u=u||c.name||"download",y.download=u,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,u,h):a(y,y.target="_blank")):(y.href=v.createObjectURL(c),setTimeout(function(){v.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,u,h){if(u=u||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),u);else if(o(c))r(c,u,h);else{var v=document.createElement("a");v.href=c,v.target="_blank",setTimeout(function(){a(v)})}}:function(c,u,h,v){if(v=v||open("","_blank"),v&&(v.document.title=v.document.body.innerText="downloading..."),typeof c=="string")return r(c,u,h);var y=c.type==="application/octet-stream",C=/constructor/i.test(s.HTMLElement)||s.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||y&&C||l)&&typeof FileReader<"u"){var b=new FileReader;b.onloadend=function(){var N=b.result;N=m?N:N.replace(/^data:[^;]*;/,"data:attachment/file;"),v?v.location.href=N:location=N,v=null},b.readAsDataURL(c)}else{var E=s.URL||s.webkitURL,I=E.createObjectURL(c);v?v.location=I:location.href=I,v=null,setTimeout(function(){E.revokeObjectURL(I)},4e4)}});s.saveAs=p.saveAs=p,t.exports=p})}(Ve)),Ve.exports}var Cn=Jr();const Zr=Qr(Cn),vt=f.memo(t=>{const{file:n,url:e,name:r,setShowPreview:o}=t,a=f.useCallback(s=>{s.stopPropagation();const l=new Blob([n]);Zr(l,r)},[r,n]);return i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"fixed top-0 left-0 z-[5000] h-full w-full bg-[rgba(0,0,0,0.85)] bg-black",type:"button",onClick:()=>{o(!1)},children:i.jsx("img",{className:"absolute top-[50%] left-[50%] z-[5001] max-h-[calc(100%-120px)] max-w-svw translate-x-[-50%] translate-y-[50%] object-contain",src:e,alt:r,onClick:s=>{s.stopPropagation()}})}),i.jsxs("div",{className:"fixed top-0 left-0 z-[5001] flex w-full items-center bg-(--color-background)",children:[i.jsx(d.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":"Exit preview",onClick:()=>{o(!1)},children:i.jsx(d.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx("span",{className:"grow text-center",children:r}),i.jsx(d.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":`Download ${r}`,onClick:a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]})]})});vt.displayName="FullScreenImagePreview";const K=t=>{const{className:n,label:e,children:r,size:o,severity:a,inputId:s,labelId:l,image:p}=t,[c,u]=f.useState(void 0),[h,v]=f.useState(!1),y=a?te[a]:"base";console.debug(a,y),f.useEffect(()=>{p instanceof Promise?p.then(u).catch(console.error):u(p)},[p]);const C=c?URL.createObjectURL(c):void 0;return i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(i.Fragment,{children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:C,alt:c.name,onClick:()=>{v(!0)}}),h&&i.jsx(vt,{file:c,url:C,name:c.name,setShowPreview:v})]}),i.jsxs("label",{className:pe(n,"flex flex-col gap-1"),htmlFor:s,children:[i.jsx(d.Text,{accentColor:y,size:o,id:l,weight:"medium",children:e}),r]})]})},yt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?te[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(d.Text,{accentColor:o,size:"xs",children:n})})]})},Q=t=>{const{children:n,...e}=t;return i.jsx(yt,{...e,children:n})},Rr=[!0,"true"],bt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=Rr.includes(l.value);return i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,className:"align-center flex-row-reverse justify-end gap-2",children:i.jsx(d.Checkbox.Root,{...p,...l,id:n,accentColor:"base",value:h.toString(),checked:h,onCheckedChange:l.onChange,onChange:void 0,onBlur:void 0,variant:"surface",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})})})})});bt.displayName="BooleanInput";const In={...G,type:"boolean"},Ce=class Ce extends j{constructor(e){super({...e,type:"boolean"});x(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 Ce(e)}getInput(e){return i.jsx(bt,{...e,field:this})}};x(Ce,"fieldTypeName","Checkbox"),x(Ce,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),x(Ce,"Icon",U.RiCheckboxCircleLine);let ge=Ce;const wt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=l.value?l.value.split("T")[0]:"";return i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,type:"date",id:n,value:h})})})})});wt.displayName="DateInput";const xn={...G,type:"date"},Ie=class Ie extends j{constructor(e){super({...e,type:"date"});x(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return new Date(e.target.value).toISOString()}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Ie(e)}getInput(e){return i.jsx(wt,{field:this,...e})}};x(Ie,"fieldTypeName","Date"),x(Ie,"fieldTypeDescription","Allows specifying a date."),x(Ie,"Icon",U.RiCalendarLine);let ke=Ie;const En=f.memo(t=>{const{field:n,...e}=t,[{value:r}]=k.useField(n.options.clonedFieldIdentifier),o=f.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?st(a):null},[n.options,r]);return Ct(o,e)});En.displayName="FieldInputCloner";const ei={...G,type:"custom"};class Ue extends j{constructor(e,r){super({...e,type:"custom"});x(this,"Component");x(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})}}x(Ue,"fieldTypeName","Custom"),x(Ue,"fieldTypeDescription","Allows re-rendering of field already in the form");class ti extends Ue{constructor(n){super(n,En)}}const Ct=(t,n)=>f.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Pe=(t,n)=>{const e=f.useMemo(()=>t.map(r=>i.jsx("div",{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-2",children:e})},je=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),ni=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(je(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(je("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function It(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 Sn(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function We(t,n){const e=Array.from(t);return e.splice(n,1),e}const xt=(t,n)=>{const e=new Date;return`${H.slugify(n)}-${e.getTime()}`},Fn=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Fn(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},Nn=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),qe=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:xt(null,a)},l=X(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 p=Sn(l,n,s);o(t,p).then()},ri=(t,n,e)=>{const r={...je(),label:""};qe("fields",t,r,n,e)},Et=()=>{const{showError:t}=d.useToast(),n=f.useCallback((r,o,a,s,l,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let u=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(u=Math.min(u,h.index-1));if(u!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",It(l.fields,a,u))},[t]),e=f.useCallback((r,o,a,s,l,p,c)=>{var u;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)c(`fields.${o}.fields`,It(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((u=s.condition)==null?void 0:u.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}c(`fields.${o}.fields`,We(r.fields,a)).then(),c(`fields.${l}.fields`,Sn(s.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},St=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=f.useMemo(()=>Array.isArray(l.value)?l.value:[],[l.value]),{onChange:v,onBlur:y}=l,C=`${n}-droppable`,{disabled:m}=p,[b,E]=f.useState(""),[I,N]=f.useState(""),S=I||c,F=f.useCallback(M=>{v(M),y(M)},[v,y]),L=f.useCallback(M=>{h.findIndex(B=>B===M.target.value.trim())>=0?N("All options must be unique"):M.target.value?N(""):N("Option cannot be empty"),E(M.target.value)},[E,h]),T=f.useCallback(()=>{if(I)return;if(!b.trim()){N("Option cannot be empty");return}const M=b.trim();F([...h,M]),E("")},[b,I,F,h]),P=f.useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),T())},[T]),A=f.useCallback(M=>{F(We(h,M))},[h,F]),$=f.useCallback(M=>{if(!M.destination)return;const B=M.source.index,_=M.destination.index;F(It(h,B,_))},[F,h]);return i.jsx(re.DragDropContext,{onDragEnd:$,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Q,{helpText:S,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:(!m||h.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,value:b,onChange:L,onKeyDown:P,id:n,placeholder:s.placeholder,onBlur:void 0})})}),i.jsx(d.IconButton,{type:"button","aria-label":"Add option",disabled:!!I||m,onClick:T,children:i.jsx(d.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(re.Droppable,{droppableId:C,children:M=>i.jsxs("div",{className:"flex flex-col",...M.droppableProps,ref:M.innerRef,children:[h.map((B,_)=>i.jsx(re.Draggable,{draggableId:`${B}-draggable`,index:_,isDragDisabled:m,children:({draggableProps:ee,dragHandleProps:se,innerRef:_e})=>i.jsxs(d.Badge,{...se,...ee,ref:_e,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"md",variant:"soft",children:[i.jsx("span",{children:typeof B=="object"&&"label"in B?B.label:B}),i.jsx(d.IconButton,{size:"sm",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:m,onClick:()=>{A(_)},children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]})},B)),M.placeholder]})})]})})});St.displayName="MultiStringInput";const Tn={...G,type:"multi-string",minimum_length:0,maximum_length:null},xe=class xe extends j{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});x(this,"minLength");x(this,"maxLength");x(this,"onlyValidateAfterTouched",!1);x(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(St,{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 xe(e)}};x(xe,"fieldTypeName","Multi-string"),x(xe,"fieldTypeDescription","Allows the user to provide multiple unique strings."),x(xe,"Icon",U.RiListCheck);let Ae=xe;const Ft=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,type:"number",id:n,placeholder:s.placeholder,min:s.minimum,max:s.maximum,step:s.integers?1:.1})})})})});Ft.displayName="NumberInput";const Ln={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Dn=t=>"fields"in t,R=class R extends j{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"});x(this,"minimum");x(this,"maximum");x(this,"integers");x(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 ge({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(Ft,{field:this,...e})}};x(R,"fieldTypeName","Number"),x(R,"fieldTypeDescription","Allows specifying a number within a given range."),x(R,"Icon",U.RiHashtag),x(R,"_validateMin",e=>(r,o)=>{const a=Dn(o)?X(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),x(R,"_validateMax",e=>(r,o)=>{const a=Dn(o)?X(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let ie=R;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 Mn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function Pn(...t){return n=>{let e=!1;const r=t.map(o=>{const a=Mn(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():Mn(t[o],null)}}}}function le(...t){return g.useCallback(Pn(...t),t)}function ii(t,n){const e=g.createContext(n),r=a=>{const{children:s,...l}=a,p=g.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:p,children:s})};r.displayName=t+"Provider";function o(a){const s=g.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 oi(t,n=[]){let e=[];function r(a,s){const l=g.createContext(s),p=e.length;e=[...e,s];const c=h=>{var E;const{scope:v,children:y,...C}=h,m=((E=v==null?void 0:v[t])==null?void 0:E[p])||l,b=g.useMemo(()=>C,Object.values(C));return i.jsx(m.Provider,{value:b,children:y})};c.displayName=a+"Provider";function u(h,v){var m;const y=((m=v==null?void 0:v[t])==null?void 0:m[p])||l,C=g.useContext(y);if(C)return C;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[c,u]}const o=()=>{const a=e.map(s=>g.createContext(s));return function(l){const p=(l==null?void 0:l[t])||a;return g.useMemo(()=>({[`__scope${t}`]:{...l,[t]:p}}),[l,p])}};return o.scopeName=t,[r,ai(o,...n)]}function ai(...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:p,scopeName:c})=>{const h=p(a)[`__scope${c}`];return{...l,...h}},{});return g.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var He=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},si=g.useId||(()=>{}),li=0;function Nt(t){const[n,e]=g.useState(si());return He(()=>{e(r=>r??String(li++))},[t]),t||(n?`radix-${n}`:"")}function ce(t){const n=g.useRef(t);return g.useEffect(()=>{n.current=t}),g.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function ci({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=di({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=ce(e),p=g.useCallback(c=>{if(a){const h=typeof c=="function"?c(t):c;h!==t&&l(h)}else o(c)},[a,t,o,l]);return[s,p]}function di({defaultProp:t,onChange:n}){const e=g.useState(t),[r]=e,o=g.useRef(r),a=ce(n);return g.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var Tt=g.forwardRef((t,n)=>{const{children:e,...r}=t,o=g.Children.toArray(e),a=o.find(fi);if(a){const s=a.props.children,l=o.map(p=>p===a?g.Children.count(s)>1?g.Children.only(null):g.isValidElement(s)?s.props.children:null:p);return i.jsx(Lt,{...r,ref:n,children:g.isValidElement(s)?g.cloneElement(s,void 0,l):null})}return i.jsx(Lt,{...r,ref:n,children:e})});Tt.displayName="Slot";var Lt=g.forwardRef((t,n)=>{const{children:e,...r}=t;if(g.isValidElement(e)){const o=pi(e);return g.cloneElement(e,{...hi(r,e.props),ref:n?Pn(n,o):o})}return g.Children.count(e)>1?g.Children.only(null):null});Lt.displayName="SlotClone";var ui=({children:t})=>i.jsx(i.Fragment,{children:t});function fi(t){return g.isValidElement(t)&&t.type===ui}function hi(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 pi(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 mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ne=mi.reduce((t,n)=>{const e=g.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?Tt: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 gi(t,n){t&&Xr.flushSync(()=>t.dispatchEvent(n))}function vi(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t);g.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 yi="DismissableLayer",Dt="dismissableLayer.update",bi="dismissableLayer.pointerDownOutside",wi="dismissableLayer.focusOutside",An,On=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bn=g.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...p}=t,c=g.useContext(On),[u,h]=g.useState(null),v=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=g.useState({}),C=le(n,T=>h(T)),m=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),E=m.indexOf(b),I=u?m.indexOf(u):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,S=I>=E,F=xi(T=>{const P=T.target,A=[...c.branches].some($=>$.contains(P));!S||A||(o==null||o(T),s==null||s(T),T.defaultPrevented||l==null||l())},v),L=Ei(T=>{const P=T.target;[...c.branches].some($=>$.contains(P))||(a==null||a(T),s==null||s(T),T.defaultPrevented||l==null||l())},v);return vi(T=>{I===c.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&l&&(T.preventDefault(),l()))},v),g.useEffect(()=>{if(u)return e&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(An=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),_n(),()=>{e&&c.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=An)}},[u,v,e,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),_n())},[u,c]),g.useEffect(()=>{const T=()=>y({});return document.addEventListener(Dt,T),()=>document.removeEventListener(Dt,T)},[]),i.jsx(ne.div,{...p,ref:C,style:{pointerEvents:N?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,L.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,L.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,F.onPointerDownCapture)})});Bn.displayName=yi;var Ci="DismissableLayerBranch",Ii=g.forwardRef((t,n)=>{const e=g.useContext(On),r=g.useRef(null),o=le(n,r);return g.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})});Ii.displayName=Ci;function xi(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t),r=g.useRef(!1),o=g.useRef(()=>{});return g.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let p=function(){zn(bi,e,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=p,n.addEventListener("click",o.current,{once:!0})):p()}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 Ei(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t),r=g.useRef(!1);return g.useEffect(()=>{const o=a=>{a.target&&!r.current&&zn(wi,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 _n(){const t=new CustomEvent(Dt);document.dispatchEvent(t)}function zn(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?gi(o,a):o.dispatchEvent(a)}var Mt="focusScope.autoFocusOnMount",Pt="focusScope.autoFocusOnUnmount",$n={bubbles:!1,cancelable:!0},Si="FocusScope",Vn=g.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,p]=g.useState(null),c=ce(o),u=ce(a),h=g.useRef(null),v=le(n,m=>p(m)),y=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let m=function(N){if(y.paused||!l)return;const S=N.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},b=function(N){if(y.paused||!l)return;const S=N.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},E=function(N){if(document.activeElement===document.body)for(const F of N)F.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",m),document.addEventListener("focusout",b);const I=new MutationObserver(E);return l&&I.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",b),I.disconnect()}}},[r,l,y.paused]),g.useEffect(()=>{if(l){jn.add(y);const m=document.activeElement;if(!l.contains(m)){const E=new CustomEvent(Mt,$n);l.addEventListener(Mt,c),l.dispatchEvent(E),E.defaultPrevented||(Fi(Mi(kn(l)),{select:!0}),document.activeElement===m&&ae(l))}return()=>{l.removeEventListener(Mt,c),setTimeout(()=>{const E=new CustomEvent(Pt,$n);l.addEventListener(Pt,u),l.dispatchEvent(E),E.defaultPrevented||ae(m??document.body,{select:!0}),l.removeEventListener(Pt,u),jn.remove(y)},0)}}},[l,c,u,y]);const C=g.useCallback(m=>{if(!e&&!r||y.paused)return;const b=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,E=document.activeElement;if(b&&E){const I=m.currentTarget,[N,S]=Ni(I);N&&S?!m.shiftKey&&E===S?(m.preventDefault(),e&&ae(N,{select:!0})):m.shiftKey&&E===N&&(m.preventDefault(),e&&ae(S,{select:!0})):E===I&&m.preventDefault()}},[e,r,y.paused]);return i.jsx(ne.div,{tabIndex:-1,...s,ref:v,onKeyDown:C})});Vn.displayName=Si;function Fi(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function Ni(t){const n=kn(t),e=Un(n,t),r=Un(n.reverse(),t);return[e,r]}function kn(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 Un(t,n){for(const e of t)if(!Ti(e,{upTo:n}))return e}function Ti(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 Li(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&&Li(t)&&n&&t.select()}}var jn=Di();function Di(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Wn(t,n),t.unshift(n)},remove(n){var e;t=Wn(t,n),(e=t[0])==null||e.resume()}}}function Wn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Mi(t){return t.filter(n=>n.tagName!=="A")}var Pi="Portal",qn=g.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=g.useState(!1);He(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?hn.createPortal(i.jsx(ne.div,{...r,ref:n}),s):null});qn.displayName=Pi;function Ai(t,n){return g.useReducer((e,r)=>n[e][r]??e,t)}var Ge=t=>{const{present:n,children:e}=t,r=Oi(n),o=typeof e=="function"?e({present:r.isPresent}):g.Children.only(e),a=le(r.ref,Bi(o));return typeof e=="function"||r.isPresent?g.cloneElement(o,{ref:a}):null};Ge.displayName="Presence";function Oi(t){const[n,e]=g.useState(),r=g.useRef({}),o=g.useRef(t),a=g.useRef("none"),s=t?"mounted":"unmounted",[l,p]=Ai(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=Xe(r.current);a.current=l==="mounted"?c:"none"},[l]),He(()=>{const c=r.current,u=o.current;if(u!==t){const v=a.current,y=Xe(c);t?p("MOUNT"):y==="none"||(c==null?void 0:c.display)==="none"?p("UNMOUNT"):p(u&&v!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,p]),He(()=>{if(n){let c;const u=n.ownerDocument.defaultView??window,h=y=>{const m=Xe(r.current).includes(y.animationName);if(y.target===n&&m&&(p("ANIMATION_END"),!o.current)){const b=n.style.animationFillMode;n.style.animationFillMode="forwards",c=u.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=b)})}},v=y=>{y.target===n&&(a.current=Xe(r.current))};return n.addEventListener("animationstart",v),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{u.clearTimeout(c),n.removeEventListener("animationstart",v),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else p("ANIMATION_END")},[n,p]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:g.useCallback(c=>{c&&(r.current=getComputedStyle(c)),e(c)},[])}}function Xe(t){return(t==null?void 0:t.animationName)||"none"}function Bi(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 At=0;function _i(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Hn()),document.body.insertAdjacentElement("beforeend",t[1]??Hn()),At++,()=>{At===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),At--}},[])}function Hn(){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 Gn(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 zi(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 Ke="right-scroll-bar-position",Qe="width-before-scroll-bar",$i="with-scroll-bars-hidden",Vi="--removed-body-scroll-bar-size";function Ot(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function ki(t,n){var e=f.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 Ui=typeof window<"u"?g.useLayoutEffect:g.useEffect,Xn=new WeakMap;function ji(t,n){var e=ki(null,function(r){return t.forEach(function(o){return Ot(o,r)})});return Ui(function(){var r=Xn.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Ot(l,null)}),a.forEach(function(l){o.has(l)||Ot(l,s)})}Xn.set(e,t)},[t]),e}function Wi(t){return t}function qi(t,n){n===void 0&&(n=Wi);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 p=function(){var u=s;s=[],u.forEach(a)},c=function(){return Promise.resolve().then(p)};c(),e={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),e}}}};return o}function Hi(t){t===void 0&&(t={});var n=qi(null);return n.options=Z({async:!0,ssr:!1},t),n}var Kn=function(t){var n=t.sideCar,e=Gn(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 g.createElement(r,Z({},e))};Kn.isSideCarExport=!0;function Gi(t,n){return t.useMedium(n),Kn}var Qn=Hi(),Bt=function(){},Ye=g.forwardRef(function(t,n){var e=g.useRef(null),r=g.useState({onScrollCapture:Bt,onWheelCapture:Bt,onTouchMoveCapture:Bt}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,p=t.className,c=t.removeScrollBar,u=t.enabled,h=t.shards,v=t.sideCar,y=t.noIsolation,C=t.inert,m=t.allowPinchZoom,b=t.as,E=b===void 0?"div":b,I=t.gapMode,N=Gn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=v,F=ji([e,n]),L=Z(Z({},N),o);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:Qn,removeScrollBar:c,shards:h,noIsolation:y,inert:C,setCallbacks:a,allowPinchZoom:!!m,lockRef:e,gapMode:I}),s?g.cloneElement(g.Children.only(l),Z(Z({},L),{ref:F})):g.createElement(E,Z({},L,{className:p,ref:F}),l))});Ye.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ye.classNames={fullWidth:Qe,zeroRight:Ke};var Xi=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ki(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=Xi();return n&&t.setAttribute("nonce",n),t}function Qi(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Yi(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var Ji=function(){var t=0,n=null;return{add:function(e){t==0&&(n=Ki())&&(Qi(n,e),Yi(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Zi=function(){var t=Ji();return function(n,e){g.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},Yn=function(){var t=Zi(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},Ri={left:0,top:0,right:0,gap:0},_t=function(t){return parseInt(t||"",10)||0},eo=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[_t(e),_t(r),_t(o)]},to=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return Ri;var n=eo(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])}},no=Yn(),ve="data-scroll-locked",ro=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
- .`.concat($i,` {
1
+ (function(w,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("@overmap-ai/blocks"),require("react"),require("@overmap-ai/core"),require("formik"),require("react-icons/ri"),require("lodash.get"),require("lodash.set"),require("@hello-pangea/dnd"),require("react-dom"),require("qr-scanner"),require("lodash.clonedeep"),require("react-sketch-canvas")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@overmap-ai/blocks","react","@overmap-ai/core","formik","react-icons/ri","lodash.get","lodash.set","@hello-pangea/dnd","react-dom","qr-scanner","lodash.clonedeep","react-sketch-canvas"],i):(w=typeof globalThis<"u"?globalThis:w||self,i(w.forms={},w.jsxRuntime,w.blocks,w.React,w.core,w.formik,w.ri,w.get,w.set,w.dnd,w.ReactDOM,w.QrScannerAPI,w.cloneDeep,w.reactSketchCanvas))})(this,function(w,i,d,f,H,k,U,X,ht,re,hn,Hr,Gr,Xr){"use strict";var ta=Object.defineProperty;var na=(w,i,d)=>i in w?ta(w,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):w[i]=d;var x=(w,i,d)=>na(w,typeof i!="symbol"?i+"":i,d);function pn(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 g=pn(f),Kr=pn(hn),pt=f.memo(t=>{const{selectedColor:n,allColors:e,onFinish:r,trigger:o}=t,a=f.useCallback(s=>()=>{r(s)},[r]);return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{children:o}),i.jsx(d.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(d.IconButton,{onClick:a(s),style:{backgroundColor:s},type:"button",variant:"solid","aria-label":s,children:n===s&&i.jsx(d.RiIcon,{icon:"RiCheckLine"})},s))})})]})});pt.displayName="ColorPicker";const mn=["image/jpeg","image/png","image/svg+xml"],gn=["text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel"],vn=["application/pdf"],Me=f.memo(t=>{const{fileType:n}=t,e=f.useMemo(()=>gn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFileExcelLine"}):vn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFilePdfLine"}):mn.includes(n)?i.jsx(d.RiIcon,{icon:"RiFileImageLine"}):i.jsx(d.RiIcon,{icon:"RiFileLine"}),[n]);return i.jsx("div",{className:"h-max w-max",children:e})});Me.displayName="FileIcon";const yn=f.memo(t=>{const{file:n,truncateLength:e,hideName:r=!1,...o}=t,a=f.useMemo(()=>e!==void 0?H.truncate(n.name,e):n.name,[n.name,e]);return i.jsxs(d.Badge,{...o,children:[i.jsx(Me,{fileType:n.type}),!r&&a]})});yn.displayName="FileBadge";function bn(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=bn(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=bn(t))&&(r&&(r+=" "),r+=n);return r}const pe=Qr,mt=f.memo(f.forwardRef((t,n)=>{const{file:e,className:r,error:o,truncateLength:a,rightSlot:s,...l}=t,p=f.useMemo(()=>{if(e)return a!==void 0?H.truncate(e.name,a):e.name},[e,a]);return i.jsxs("div",{className:pe(r,"flex h-5 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,...l,children:[o?i.jsx(d.RiIcon,{icon:"RiFileWarningLine"}):i.jsx(Me,{fileType:(e==null?void 0:e.type)??""}),o||(e?p:i.jsx("div",{className:"flex w-full justify-center",children:i.jsx(d.Spinner,{})})),s]})}));mt.displayName="FileCard";const ze=500,me=1e4,te={danger:"danger",warning:"warning",info:"base",success:"success"};class gt{constructor(n){x(this,"type");x(this,"identifier");x(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 G={label:"",description:"",required:!1};class j extends gt{constructor(e){const{label:r,required:o,image:a,fieldValidators:s=[],formValidators:l=[],...p}=e;super(p);x(this,"required");x(this,"formValidators");x(this,"fieldValidators");x(this,"label");x(this,"image");x(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)}}x(j,"fieldTypeName"),x(j,"fieldTypeDescription");const z=t=>{const{id:n,field:e,formId:r,size:o,showInputOnly:a,internal:s,...l}=t,[p,c,u]=k.useField(e.getId()),{touched:h}=c,v=c.error??e.description,y=c.error?"danger":void 0,C=n??`${r}-${e.getId()}-input`,m=`${C}-label`,b=e.required?`${e.label} *`:e.label,E=f.useMemo(()=>({...p,onChange:S=>{const F=e.getValueFromChangeEvent(S);u.setValue(F,!1).then(),(h||!e.onlyValidateAfterTouched)&&u.setError(e.getError(F))},onBlur:S=>{u.setTouched(!0,!1).then(),u.setError(e.getError(e.getValueFromChangeEvent(S)))}}),[e,p,u,h]);return console.debug("severity",y),[{helpText:v,size:o,severity:y,inputId:C,labelId:m,label:b,showInputOnly:a,internal:s,fieldProps:E,helpers:u,field:e},{...l,"aria-labelledby":m}]};var $e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ve={exports:{}},Jr=Ve.exports,wn;function Zr(){return wn||(wn=1,function(t,n){(function(e,r){r()})(Jr,function(){function e(c,u){return typeof u>"u"?u={autoBom:!1}:typeof u!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,u,h){var v=new XMLHttpRequest;v.open("GET",c),v.responseType="blob",v.onload=function(){p(v.response,u,h)},v.onerror=function(){console.error("could not download file")},v.send()}function o(c){var u=new XMLHttpRequest;u.open("HEAD",c,!1);try{u.send()}catch{}return 200<=u.status&&299>=u.status}function a(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var u=document.createEvent("MouseEvents");u.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(u)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof $e=="object"&&$e.global===$e?$e:void 0,l=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),p=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!l?function(c,u,h){var v=s.URL||s.webkitURL,y=document.createElement("a");u=u||c.name||"download",y.download=u,y.rel="noopener",typeof c=="string"?(y.href=c,y.origin===location.origin?a(y):o(y.href)?r(c,u,h):a(y,y.target="_blank")):(y.href=v.createObjectURL(c),setTimeout(function(){v.revokeObjectURL(y.href)},4e4),setTimeout(function(){a(y)},0))}:"msSaveOrOpenBlob"in navigator?function(c,u,h){if(u=u||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(e(c,h),u);else if(o(c))r(c,u,h);else{var v=document.createElement("a");v.href=c,v.target="_blank",setTimeout(function(){a(v)})}}:function(c,u,h,v){if(v=v||open("","_blank"),v&&(v.document.title=v.document.body.innerText="downloading..."),typeof c=="string")return r(c,u,h);var y=c.type==="application/octet-stream",C=/constructor/i.test(s.HTMLElement)||s.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||y&&C||l)&&typeof FileReader<"u"){var b=new FileReader;b.onloadend=function(){var N=b.result;N=m?N:N.replace(/^data:[^;]*;/,"data:attachment/file;"),v?v.location.href=N:location=N,v=null},b.readAsDataURL(c)}else{var E=s.URL||s.webkitURL,I=E.createObjectURL(c);v?v.location=I:location.href=I,v=null,setTimeout(function(){E.revokeObjectURL(I)},4e4)}});s.saveAs=p.saveAs=p,t.exports=p})}(Ve)),Ve.exports}var Cn=Zr();const Rr=Yr(Cn),vt=f.memo(t=>{const{file:n,url:e,name:r,setShowPreview:o}=t,a=f.useCallback(s=>{s.stopPropagation();const l=new Blob([n]);Rr(l,r)},[r,n]);return i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"fixed top-0 left-0 z-[5000] h-full w-full bg-[rgba(0,0,0,0.85)] bg-black",type:"button",onClick:()=>{o(!1)},children:i.jsx("img",{className:"absolute top-[50%] left-[50%] z-[5001] max-h-[calc(100%-120px)] max-w-svw translate-x-[-50%] translate-y-[50%] object-contain",src:e,alt:r,onClick:s=>{s.stopPropagation()}})}),i.jsxs("div",{className:"fixed top-0 left-0 z-[5001] flex w-full items-center bg-(--color-background)",children:[i.jsx(d.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":"Exit preview",onClick:()=>{o(!1)},children:i.jsx(d.RiIcon,{icon:"RiArrowLeftLine"})}),i.jsx("span",{className:"grow text-center",children:r}),i.jsx(d.IconButton,{className:"min-w-[50px]",variant:"soft","aria-label":`Download ${r}`,onClick:a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]})]})});vt.displayName="FullScreenImagePreview";const K=t=>{const{className:n,label:e,children:r,size:o,severity:a,inputId:s,labelId:l,image:p}=t,[c,u]=f.useState(void 0),[h,v]=f.useState(!1),y=a?te[a]:"base";console.debug(a,y),f.useEffect(()=>{p instanceof Promise?p.then(u).catch(console.error):u(p)},[p]);const C=c?URL.createObjectURL(c):void 0;return i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(i.Fragment,{children:[i.jsx("img",{className:"h-[100px] w-full min-w-[300px] cursor-pointer rounded-md object-cover",src:C,alt:c.name,onClick:()=>{v(!0)}}),h&&i.jsx(vt,{file:c,url:C,name:c.name,setShowPreview:v})]}),i.jsxs("label",{className:pe(n,"flex flex-col gap-1"),htmlFor:s,children:[i.jsx(d.Text,{accentColor:y,size:o,id:l,weight:"medium",children:e}),r]})]})},yt=t=>{const{helpText:n,children:e,severity:r}=t,o=r?te[r]:"base";return i.jsxs("div",{className:"flex flex-col gap-1",children:[e,i.jsx("div",{className:"flex flex-col w-full",children:i.jsx(d.Text,{accentColor:o,size:"xs",children:n})})]})},Q=t=>{const{children:n,...e}=t;return i.jsx(yt,{...e,children:n})},ei=[!0,"true"],bt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=ei.includes(l.value);return i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,className:"align-center flex-row-reverse justify-end gap-2",children:i.jsx(d.Checkbox.Root,{...p,...l,id:n,accentColor:"base",value:h.toString(),checked:h,onCheckedChange:l.onChange,onChange:void 0,onBlur:void 0,variant:"surface",children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})})})})});bt.displayName="BooleanInput";const In={...G,type:"boolean"},Ce=class Ce extends j{constructor(e){super({...e,type:"boolean"});x(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 Ce(e)}getInput(e){return i.jsx(bt,{...e,field:this})}};x(Ce,"fieldTypeName","Checkbox"),x(Ce,"fieldTypeDescription","Perfect for both optional and required yes/no questions."),x(Ce,"Icon",U.RiCheckboxCircleLine);let ge=Ce;const wt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=l.value?l.value.split("T")[0]:"";return i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,type:"date",id:n,value:h})})})})});wt.displayName="DateInput";const xn={...G,type:"date"},Ie=class Ie extends j{constructor(e){super({...e,type:"date"});x(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}getValueFromChangeEvent(e){return new Date(e.target.value).toISOString()}static deserialize(e){if(e.type!=="date")throw new Error("Type mismatch.");return new Ie(e)}getInput(e){return i.jsx(wt,{field:this,...e})}};x(Ie,"fieldTypeName","Date"),x(Ie,"fieldTypeDescription","Allows specifying a date."),x(Ie,"Icon",U.RiCalendarLine);let ke=Ie;const En=f.memo(t=>{const{field:n,...e}=t,[{value:r}]=k.useField(n.options.clonedFieldIdentifier),o=f.useMemo(()=>{const a=n.options.getFieldToClone(r);return a?st(a):null},[n.options,r]);return Ct(o,e)});En.displayName="FieldInputCloner";const ti={...G,type:"custom"};class Ue extends j{constructor(e,r){super({...e,type:"custom"});x(this,"Component");x(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})}}x(Ue,"fieldTypeName","Custom"),x(Ue,"fieldTypeDescription","Allows re-rendering of field already in the form");class ni extends Ue{constructor(n){super(n,En)}}const Ct=(t,n)=>f.useMemo(()=>!n||!t?null:t.getInput(n),[t,n]),Pe=(t,n)=>{const e=f.useMemo(()=>t.map(r=>i.jsx("div",{children:r.getInput(n)},r.getId())),[t,n]);return i.jsx("div",{className:"flex flex-col gap-2",children:e})},je=(t="",n=[])=>({type:"section",fields:n,identifier:t,label:null,condition:null,conditional:!1}),ri=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(je(`AUTO_section-${n.indexOf(o)}`,e)),e=[]),r.push(o)):e.push(o);return e.length>0&&r.push(je("AUTO_section-last",e)),{...t,fields:r,description:t.description??""}};function It(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 Sn(t,n,e){const r=Array.from(t??[]);return r.splice(n,0,e),r}function We(t,n){const e=Array.from(t);return e.splice(n,1),e}const xt=(t,n)=>{const e=new Date;return`${H.slugify(n)}-${e.getTime()}`},Fn=(t,n)=>{if(!n)return null;for(const e of t)if(e.type==="section"){const r=Fn(e.fields,n);if(r)return r}else if(e.identifier===n)return e;return null},Nn=(t,n)=>t.filter((e,r)=>r<n).flatMap(e=>e.fields),qe=(t,n,e,r,o)=>{const{label:a}=e,s={...e,identifier:xt(null,a)},l=X(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 p=Sn(l,n,s);o(t,p).then()},ii=(t,n,e)=>{const r={...je(),label:""};qe("fields",t,r,n,e)},Et=()=>{const{showError:t}=d.useToast(),n=f.useCallback((r,o,a,s,l,p)=>{const c=r[o];if(!c)throw new Error("Could not find section context.");let u=typeof c.conditionIndex<"u"?Math.max(c.conditionIndex+1,s):s;for(const h of Object.values(r))h.conditionIndex===a&&(u=Math.min(u,h.index-1));if(u!==s){t({title:"Could not reorder sections",description:"Sections with conditions must be below the fields they reference."});return}p("fields",It(l.fields,a,u))},[t]),e=f.useCallback((r,o,a,s,l,p,c)=>{var u;if(!(r!=null&&r.fields)||!s)throw new Error("Could not find section with fields.");if(r.identifier===s.identifier)c(`fields.${o}.fields`,It(r.fields,a,p)).then();else{const h=r.fields[a];if(!h)throw new Error("Could not find field to reorder.");if(((u=s.condition)==null?void 0:u.identifier)===h.identifier){t({title:"Could not reorder field",description:"Field must be above the section whose condition references it."});return}c(`fields.${o}.fields`,We(r.fields,a)).then(),c(`fields.${l}.fields`,Sn(s.fields,p,h)).then()}},[t]);return{reorderSection:n,reorderField:e}},St=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);c=a?null:c,u=a?"":u;const h=f.useMemo(()=>Array.isArray(l.value)?l.value:[],[l.value]),{onChange:v,onBlur:y}=l,C=`${n}-droppable`,{disabled:m}=p,[b,E]=f.useState(""),[I,N]=f.useState(""),S=I||c,F=f.useCallback(M=>{v(M),y(M)},[v,y]),L=f.useCallback(M=>{h.findIndex(B=>B===M.target.value.trim())>=0?N("All options must be unique"):M.target.value?N(""):N("Option cannot be empty"),E(M.target.value)},[E,h]),T=f.useCallback(()=>{if(I)return;if(!b.trim()){N("Option cannot be empty");return}const M=b.trim();F([...h,M]),E("")},[b,I,F,h]),P=f.useCallback(M=>{M.key==="Enter"&&(M.preventDefault(),T())},[T]),A=f.useCallback(M=>{F(We(h,M))},[h,F]),$=f.useCallback(M=>{if(!M.destination)return;const B=M.source.index,_=M.destination.index;F(It(h,B,_))},[F,h]);return i.jsx(re.DragDropContext,{onDragEnd:$,children:i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Q,{helpText:S,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:(!m||h.length===0)&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("div",{className:"grow",children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,value:b,onChange:L,onKeyDown:P,id:n,placeholder:s.placeholder,onBlur:void 0})})}),i.jsx(d.IconButton,{type:"button","aria-label":"Add option",disabled:!!I||m,onClick:T,children:i.jsx(d.RiIcon,{icon:"RiAddLine"})})]})})}),i.jsx(re.Droppable,{droppableId:C,children:M=>i.jsxs("div",{className:"flex flex-col",...M.droppableProps,ref:M.innerRef,children:[h.map((B,_)=>i.jsx(re.Draggable,{draggableId:`${B}-draggable`,index:_,isDragDisabled:m,children:({draggableProps:ee,dragHandleProps:se,innerRef:_e})=>i.jsxs(d.Badge,{...se,...ee,ref:_e,className:"mb-1 flex items-center justify-between gap-2",accentColor:"base",size:"md",variant:"soft",children:[i.jsx("span",{children:typeof B=="object"&&"label"in B?B.label:B}),i.jsx(d.IconButton,{size:"sm",variant:"ghost",type:"button","aria-label":"Delete option",accentColor:"base",disabled:m,onClick:()=>{A(_)},children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]})},B)),M.placeholder]})})]})})});St.displayName="MultiStringInput";const Tn={...G,type:"multi-string",minimum_length:0,maximum_length:null},xe=class xe extends j{constructor(e){const{minimum_length:r,maximum_length:o,placeholder:a,...s}=e;super({...s,type:"multi-string"});x(this,"minLength");x(this,"maxLength");x(this,"onlyValidateAfterTouched",!1);x(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(St,{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 xe(e)}};x(xe,"fieldTypeName","Multi-string"),x(xe,"fieldTypeDescription","Allows the user to provide multiple unique strings."),x(xe,"Icon",U.RiListCheck);let Ae=xe;const Ft=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,type:"number",id:n,placeholder:s.placeholder,min:s.minimum,max:s.maximum,step:s.integers?1:.1})})})})});Ft.displayName="NumberInput";const Ln={...G,type:"number",minimum:Number.MIN_SAFE_INTEGER,maximum:Number.MAX_SAFE_INTEGER,integers:!1},Dn=t=>"fields"in t,R=class R extends j{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"});x(this,"minimum");x(this,"maximum");x(this,"integers");x(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 ge({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(Ft,{field:this,...e})}};x(R,"fieldTypeName","Number"),x(R,"fieldTypeDescription","Allows specifying a number within a given range."),x(R,"Icon",U.RiHashtag),x(R,"_validateMin",e=>(r,o)=>{const a=Dn(o)?X(o,e):o;return typeof a.maximum=="number"&&typeof r=="number"&&a.maximum<r?"Minimum cannot be greater than minimum.":null}),x(R,"_validateMax",e=>(r,o)=>{const a=Dn(o)?X(o,e):o;return typeof a.minimum=="number"&&typeof r=="number"&&a.minimum>r?"Maximum cannot be less than minimum.":null});let ie=R;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 Mn(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function Pn(...t){return n=>{let e=!1;const r=t.map(o=>{const a=Mn(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():Mn(t[o],null)}}}}function le(...t){return g.useCallback(Pn(...t),t)}function oi(t,n){const e=g.createContext(n),r=a=>{const{children:s,...l}=a,p=g.useMemo(()=>l,Object.values(l));return i.jsx(e.Provider,{value:p,children:s})};r.displayName=t+"Provider";function o(a){const s=g.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 ai(t,n=[]){let e=[];function r(a,s){const l=g.createContext(s),p=e.length;e=[...e,s];const c=h=>{var E;const{scope:v,children:y,...C}=h,m=((E=v==null?void 0:v[t])==null?void 0:E[p])||l,b=g.useMemo(()=>C,Object.values(C));return i.jsx(m.Provider,{value:b,children:y})};c.displayName=a+"Provider";function u(h,v){var m;const y=((m=v==null?void 0:v[t])==null?void 0:m[p])||l,C=g.useContext(y);if(C)return C;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${a}\``)}return[c,u]}const o=()=>{const a=e.map(s=>g.createContext(s));return function(l){const p=(l==null?void 0:l[t])||a;return g.useMemo(()=>({[`__scope${t}`]:{...l,[t]:p}}),[l,p])}};return o.scopeName=t,[r,si(o,...n)]}function si(...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:p,scopeName:c})=>{const h=p(a)[`__scope${c}`];return{...l,...h}},{});return g.useMemo(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return e.scopeName=n.scopeName,e}var He=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},li=g.useId||(()=>{}),ci=0;function Nt(t){const[n,e]=g.useState(li());return He(()=>{e(r=>r??String(ci++))},[t]),t||(n?`radix-${n}`:"")}function ce(t){const n=g.useRef(t);return g.useEffect(()=>{n.current=t}),g.useMemo(()=>(...e)=>{var r;return(r=n.current)==null?void 0:r.call(n,...e)},[])}function di({prop:t,defaultProp:n,onChange:e=()=>{}}){const[r,o]=ui({defaultProp:n,onChange:e}),a=t!==void 0,s=a?t:r,l=ce(e),p=g.useCallback(c=>{if(a){const h=typeof c=="function"?c(t):c;h!==t&&l(h)}else o(c)},[a,t,o,l]);return[s,p]}function ui({defaultProp:t,onChange:n}){const e=g.useState(t),[r]=e,o=g.useRef(r),a=ce(n);return g.useEffect(()=>{o.current!==r&&(a(r),o.current=r)},[r,o,a]),e}var Tt=g.forwardRef((t,n)=>{const{children:e,...r}=t,o=g.Children.toArray(e),a=o.find(hi);if(a){const s=a.props.children,l=o.map(p=>p===a?g.Children.count(s)>1?g.Children.only(null):g.isValidElement(s)?s.props.children:null:p);return i.jsx(Lt,{...r,ref:n,children:g.isValidElement(s)?g.cloneElement(s,void 0,l):null})}return i.jsx(Lt,{...r,ref:n,children:e})});Tt.displayName="Slot";var Lt=g.forwardRef((t,n)=>{const{children:e,...r}=t;if(g.isValidElement(e)){const o=mi(e);return g.cloneElement(e,{...pi(r,e.props),ref:n?Pn(n,o):o})}return g.Children.count(e)>1?g.Children.only(null):null});Lt.displayName="SlotClone";var fi=({children:t})=>i.jsx(i.Fragment,{children:t});function hi(t){return g.isValidElement(t)&&t.type===fi}function pi(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 mi(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 gi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ne=gi.reduce((t,n)=>{const e=g.forwardRef((r,o)=>{const{asChild:a,...s}=r,l=a?Tt: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 vi(t,n){t&&Kr.flushSync(()=>t.dispatchEvent(n))}function yi(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t);g.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 bi="DismissableLayer",Dt="dismissableLayer.update",wi="dismissableLayer.pointerDownOutside",Ci="dismissableLayer.focusOutside",An,On=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Bn=g.forwardRef((t,n)=>{const{disableOutsidePointerEvents:e=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:s,onDismiss:l,...p}=t,c=g.useContext(On),[u,h]=g.useState(null),v=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=g.useState({}),C=le(n,T=>h(T)),m=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),E=m.indexOf(b),I=u?m.indexOf(u):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,S=I>=E,F=Ei(T=>{const P=T.target,A=[...c.branches].some($=>$.contains(P));!S||A||(o==null||o(T),s==null||s(T),T.defaultPrevented||l==null||l())},v),L=Si(T=>{const P=T.target;[...c.branches].some($=>$.contains(P))||(a==null||a(T),s==null||s(T),T.defaultPrevented||l==null||l())},v);return yi(T=>{I===c.layers.size-1&&(r==null||r(T),!T.defaultPrevented&&l&&(T.preventDefault(),l()))},v),g.useEffect(()=>{if(u)return e&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(An=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),_n(),()=>{e&&c.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=An)}},[u,v,e,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),_n())},[u,c]),g.useEffect(()=>{const T=()=>y({});return document.addEventListener(Dt,T),()=>document.removeEventListener(Dt,T)},[]),i.jsx(ne.div,{...p,ref:C,style:{pointerEvents:N?S?"auto":"none":void 0,...t.style},onFocusCapture:oe(t.onFocusCapture,L.onFocusCapture),onBlurCapture:oe(t.onBlurCapture,L.onBlurCapture),onPointerDownCapture:oe(t.onPointerDownCapture,F.onPointerDownCapture)})});Bn.displayName=bi;var Ii="DismissableLayerBranch",xi=g.forwardRef((t,n)=>{const e=g.useContext(On),r=g.useRef(null),o=le(n,r);return g.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})});xi.displayName=Ii;function Ei(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t),r=g.useRef(!1),o=g.useRef(()=>{});return g.useEffect(()=>{const a=l=>{if(l.target&&!r.current){let p=function(){zn(wi,e,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=p,n.addEventListener("click",o.current,{once:!0})):p()}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 Si(t,n=globalThis==null?void 0:globalThis.document){const e=ce(t),r=g.useRef(!1);return g.useEffect(()=>{const o=a=>{a.target&&!r.current&&zn(Ci,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 _n(){const t=new CustomEvent(Dt);document.dispatchEvent(t)}function zn(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?vi(o,a):o.dispatchEvent(a)}var Mt="focusScope.autoFocusOnMount",Pt="focusScope.autoFocusOnUnmount",$n={bubbles:!1,cancelable:!0},Fi="FocusScope",Vn=g.forwardRef((t,n)=>{const{loop:e=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=t,[l,p]=g.useState(null),c=ce(o),u=ce(a),h=g.useRef(null),v=le(n,m=>p(m)),y=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let m=function(N){if(y.paused||!l)return;const S=N.target;l.contains(S)?h.current=S:ae(h.current,{select:!0})},b=function(N){if(y.paused||!l)return;const S=N.relatedTarget;S!==null&&(l.contains(S)||ae(h.current,{select:!0}))},E=function(N){if(document.activeElement===document.body)for(const F of N)F.removedNodes.length>0&&ae(l)};document.addEventListener("focusin",m),document.addEventListener("focusout",b);const I=new MutationObserver(E);return l&&I.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",b),I.disconnect()}}},[r,l,y.paused]),g.useEffect(()=>{if(l){jn.add(y);const m=document.activeElement;if(!l.contains(m)){const E=new CustomEvent(Mt,$n);l.addEventListener(Mt,c),l.dispatchEvent(E),E.defaultPrevented||(Ni(Pi(kn(l)),{select:!0}),document.activeElement===m&&ae(l))}return()=>{l.removeEventListener(Mt,c),setTimeout(()=>{const E=new CustomEvent(Pt,$n);l.addEventListener(Pt,u),l.dispatchEvent(E),E.defaultPrevented||ae(m??document.body,{select:!0}),l.removeEventListener(Pt,u),jn.remove(y)},0)}}},[l,c,u,y]);const C=g.useCallback(m=>{if(!e&&!r||y.paused)return;const b=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,E=document.activeElement;if(b&&E){const I=m.currentTarget,[N,S]=Ti(I);N&&S?!m.shiftKey&&E===S?(m.preventDefault(),e&&ae(N,{select:!0})):m.shiftKey&&E===N&&(m.preventDefault(),e&&ae(S,{select:!0})):E===I&&m.preventDefault()}},[e,r,y.paused]);return i.jsx(ne.div,{tabIndex:-1,...s,ref:v,onKeyDown:C})});Vn.displayName=Fi;function Ni(t,{select:n=!1}={}){const e=document.activeElement;for(const r of t)if(ae(r,{select:n}),document.activeElement!==e)return}function Ti(t){const n=kn(t),e=Un(n,t),r=Un(n.reverse(),t);return[e,r]}function kn(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 Un(t,n){for(const e of t)if(!Li(e,{upTo:n}))return e}function Li(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 Di(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&&Di(t)&&n&&t.select()}}var jn=Mi();function Mi(){let t=[];return{add(n){const e=t[0];n!==e&&(e==null||e.pause()),t=Wn(t,n),t.unshift(n)},remove(n){var e;t=Wn(t,n),(e=t[0])==null||e.resume()}}}function Wn(t,n){const e=[...t],r=e.indexOf(n);return r!==-1&&e.splice(r,1),e}function Pi(t){return t.filter(n=>n.tagName!=="A")}var Ai="Portal",qn=g.forwardRef((t,n)=>{var l;const{container:e,...r}=t,[o,a]=g.useState(!1);He(()=>a(!0),[]);const s=e||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?hn.createPortal(i.jsx(ne.div,{...r,ref:n}),s):null});qn.displayName=Ai;function Oi(t,n){return g.useReducer((e,r)=>n[e][r]??e,t)}var Ge=t=>{const{present:n,children:e}=t,r=Bi(n),o=typeof e=="function"?e({present:r.isPresent}):g.Children.only(e),a=le(r.ref,_i(o));return typeof e=="function"||r.isPresent?g.cloneElement(o,{ref:a}):null};Ge.displayName="Presence";function Bi(t){const[n,e]=g.useState(),r=g.useRef({}),o=g.useRef(t),a=g.useRef("none"),s=t?"mounted":"unmounted",[l,p]=Oi(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=Xe(r.current);a.current=l==="mounted"?c:"none"},[l]),He(()=>{const c=r.current,u=o.current;if(u!==t){const v=a.current,y=Xe(c);t?p("MOUNT"):y==="none"||(c==null?void 0:c.display)==="none"?p("UNMOUNT"):p(u&&v!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,p]),He(()=>{if(n){let c;const u=n.ownerDocument.defaultView??window,h=y=>{const m=Xe(r.current).includes(y.animationName);if(y.target===n&&m&&(p("ANIMATION_END"),!o.current)){const b=n.style.animationFillMode;n.style.animationFillMode="forwards",c=u.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=b)})}},v=y=>{y.target===n&&(a.current=Xe(r.current))};return n.addEventListener("animationstart",v),n.addEventListener("animationcancel",h),n.addEventListener("animationend",h),()=>{u.clearTimeout(c),n.removeEventListener("animationstart",v),n.removeEventListener("animationcancel",h),n.removeEventListener("animationend",h)}}else p("ANIMATION_END")},[n,p]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:g.useCallback(c=>{c&&(r.current=getComputedStyle(c)),e(c)},[])}}function Xe(t){return(t==null?void 0:t.animationName)||"none"}function _i(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 At=0;function zi(){g.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Hn()),document.body.insertAdjacentElement("beforeend",t[1]??Hn()),At++,()=>{At===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(n=>n.remove()),At--}},[])}function Hn(){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 Gn(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 $i(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 Ke="right-scroll-bar-position",Qe="width-before-scroll-bar",Vi="with-scroll-bars-hidden",ki="--removed-body-scroll-bar-size";function Ot(t,n){return typeof t=="function"?t(n):t&&(t.current=n),t}function Ui(t,n){var e=f.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 ji=typeof window<"u"?g.useLayoutEffect:g.useEffect,Xn=new WeakMap;function Wi(t,n){var e=Ui(null,function(r){return t.forEach(function(o){return Ot(o,r)})});return ji(function(){var r=Xn.get(e);if(r){var o=new Set(r),a=new Set(t),s=e.current;o.forEach(function(l){a.has(l)||Ot(l,null)}),a.forEach(function(l){o.has(l)||Ot(l,s)})}Xn.set(e,t)},[t]),e}function qi(t){return t}function Hi(t,n){n===void 0&&(n=qi);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 p=function(){var u=s;s=[],u.forEach(a)},c=function(){return Promise.resolve().then(p)};c(),e={push:function(u){s.push(u),c()},filter:function(u){return s=s.filter(u),e}}}};return o}function Gi(t){t===void 0&&(t={});var n=Hi(null);return n.options=Z({async:!0,ssr:!1},t),n}var Kn=function(t){var n=t.sideCar,e=Gn(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 g.createElement(r,Z({},e))};Kn.isSideCarExport=!0;function Xi(t,n){return t.useMedium(n),Kn}var Qn=Gi(),Bt=function(){},Ye=g.forwardRef(function(t,n){var e=g.useRef(null),r=g.useState({onScrollCapture:Bt,onWheelCapture:Bt,onTouchMoveCapture:Bt}),o=r[0],a=r[1],s=t.forwardProps,l=t.children,p=t.className,c=t.removeScrollBar,u=t.enabled,h=t.shards,v=t.sideCar,y=t.noIsolation,C=t.inert,m=t.allowPinchZoom,b=t.as,E=b===void 0?"div":b,I=t.gapMode,N=Gn(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=v,F=Wi([e,n]),L=Z(Z({},N),o);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:Qn,removeScrollBar:c,shards:h,noIsolation:y,inert:C,setCallbacks:a,allowPinchZoom:!!m,lockRef:e,gapMode:I}),s?g.cloneElement(g.Children.only(l),Z(Z({},L),{ref:F})):g.createElement(E,Z({},L,{className:p,ref:F}),l))});Ye.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ye.classNames={fullWidth:Qe,zeroRight:Ke};var Ki=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Qi(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var n=Ki();return n&&t.setAttribute("nonce",n),t}function Yi(t,n){t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}function Ji(t){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(t)}var Zi=function(){var t=0,n=null;return{add:function(e){t==0&&(n=Qi())&&(Yi(n,e),Ji(n)),t++},remove:function(){t--,!t&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},Ri=function(){var t=Zi();return function(n,e){g.useEffect(function(){return t.add(n),function(){t.remove()}},[n&&e])}},Yn=function(){var t=Ri(),n=function(e){var r=e.styles,o=e.dynamic;return t(r,o),null};return n},eo={left:0,top:0,right:0,gap:0},_t=function(t){return parseInt(t||"",10)||0},to=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[_t(e),_t(r),_t(o)]},no=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return eo;var n=to(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])}},ro=Yn(),ve="data-scroll-locked",io=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
+ .`.concat(Vi,` {
3
3
  overflow: hidden `).concat(r,`;
4
4
  padding-right: `).concat(l,"px ").concat(r,`;
5
5
  }
@@ -33,13 +33,13 @@
33
33
  }
34
34
 
35
35
  body[`).concat(ve,`] {
36
- `).concat(Vi,": ").concat(l,`px;
36
+ `).concat(ki,": ").concat(l,`px;
37
37
  }
38
- `)},Jn=function(){var t=parseInt(document.body.getAttribute(ve)||"0",10);return isFinite(t)?t:0},io=function(){g.useEffect(function(){return document.body.setAttribute(ve,(Jn()+1).toString()),function(){var t=Jn()-1;t<=0?document.body.removeAttribute(ve):document.body.setAttribute(ve,t.toString())}},[])},oo=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;io();var a=g.useMemo(function(){return to(o)},[o]);return g.createElement(no,{styles:ro(a,!n,o,e?"":"!important")})},zt=!1;if(typeof window<"u")try{var Je=Object.defineProperty({},"passive",{get:function(){return zt=!0,!0}});window.addEventListener("test",Je,Je),window.removeEventListener("test",Je,Je)}catch{zt=!1}var ye=zt?{passive:!1}:!1,ao=function(t){return t.tagName==="TEXTAREA"},Zn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!ao(t)&&e[n]==="visible")},so=function(t){return Zn(t,"overflowY")},lo=function(t){return Zn(t,"overflowX")},Rn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=er(t,r);if(o){var a=tr(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},co=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},uo=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},er=function(t,n){return t==="v"?so(n):lo(n)},tr=function(t,n){return t==="v"?co(n):uo(n)},fo=function(t,n){return t==="h"&&n==="rtl"?-1:1},ho=function(t,n,e,r,o){var a=fo(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,p=n.contains(l),c=!1,u=s>0,h=0,v=0;do{var y=tr(t,l),C=y[0],m=y[1],b=y[2],E=m-b-a*C;(C||E)&&er(t,l)&&(h+=E,v+=C),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!p&&l!==document.body||p&&(n.contains(l)||n===l));return(u&&Math.abs(h)<1||!u&&Math.abs(v)<1)&&(c=!0),c},Ze=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},nr=function(t){return[t.deltaX,t.deltaY]},rr=function(t){return t&&"current"in t?t.current:t},po=function(t,n){return t[0]===n[0]&&t[1]===n[1]},mo=function(t){return`
38
+ `)},Jn=function(){var t=parseInt(document.body.getAttribute(ve)||"0",10);return isFinite(t)?t:0},oo=function(){g.useEffect(function(){return document.body.setAttribute(ve,(Jn()+1).toString()),function(){var t=Jn()-1;t<=0?document.body.removeAttribute(ve):document.body.setAttribute(ve,t.toString())}},[])},ao=function(t){var n=t.noRelative,e=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;oo();var a=g.useMemo(function(){return no(o)},[o]);return g.createElement(ro,{styles:io(a,!n,o,e?"":"!important")})},zt=!1;if(typeof window<"u")try{var Je=Object.defineProperty({},"passive",{get:function(){return zt=!0,!0}});window.addEventListener("test",Je,Je),window.removeEventListener("test",Je,Je)}catch{zt=!1}var ye=zt?{passive:!1}:!1,so=function(t){return t.tagName==="TEXTAREA"},Zn=function(t,n){if(!(t instanceof Element))return!1;var e=window.getComputedStyle(t);return e[n]!=="hidden"&&!(e.overflowY===e.overflowX&&!so(t)&&e[n]==="visible")},lo=function(t){return Zn(t,"overflowY")},co=function(t){return Zn(t,"overflowX")},Rn=function(t,n){var e=n.ownerDocument,r=n;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=er(t,r);if(o){var a=tr(t,r),s=a[1],l=a[2];if(s>l)return!0}r=r.parentNode}while(r&&r!==e.body);return!1},uo=function(t){var n=t.scrollTop,e=t.scrollHeight,r=t.clientHeight;return[n,e,r]},fo=function(t){var n=t.scrollLeft,e=t.scrollWidth,r=t.clientWidth;return[n,e,r]},er=function(t,n){return t==="v"?lo(n):co(n)},tr=function(t,n){return t==="v"?uo(n):fo(n)},ho=function(t,n){return t==="h"&&n==="rtl"?-1:1},po=function(t,n,e,r,o){var a=ho(t,window.getComputedStyle(n).direction),s=a*r,l=e.target,p=n.contains(l),c=!1,u=s>0,h=0,v=0;do{var y=tr(t,l),C=y[0],m=y[1],b=y[2],E=m-b-a*C;(C||E)&&er(t,l)&&(h+=E,v+=C),l instanceof ShadowRoot?l=l.host:l=l.parentNode}while(!p&&l!==document.body||p&&(n.contains(l)||n===l));return(u&&Math.abs(h)<1||!u&&Math.abs(v)<1)&&(c=!0),c},Ze=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},nr=function(t){return[t.deltaX,t.deltaY]},rr=function(t){return t&&"current"in t?t.current:t},mo=function(t,n){return t[0]===n[0]&&t[1]===n[1]},go=function(t){return`
39
39
  .block-interactivity-`.concat(t,` {pointer-events: none;}
40
40
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
41
- `)},go=0,be=[];function vo(t){var n=g.useRef([]),e=g.useRef([0,0]),r=g.useRef(),o=g.useState(go++)[0],a=g.useState(Yn)[0],s=g.useRef(t);g.useEffect(function(){s.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=zi([t.lockRef.current],(t.shards||[]).map(rr),!0).filter(Boolean);return m.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=g.useCallback(function(m,b){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var E=Ze(m),I=e.current,N="deltaX"in m?m.deltaX:I[0]-E[0],S="deltaY"in m?m.deltaY:I[1]-E[1],F,L=m.target,T=Math.abs(N)>Math.abs(S)?"h":"v";if("touches"in m&&T==="h"&&L.type==="range")return!1;var P=Rn(T,L);if(!P)return!0;if(P?F=T:(F=T==="v"?"h":"v",P=Rn(T,L)),!P)return!1;if(!r.current&&"changedTouches"in m&&(N||S)&&(r.current=F),!F)return!0;var A=r.current||F;return ho(A,b,m,A==="h"?N:S)},[]),p=g.useCallback(function(m){var b=m;if(!(!be.length||be[be.length-1]!==a)){var E="deltaY"in b?nr(b):Ze(b),I=n.current.filter(function(F){return F.name===b.type&&(F.target===b.target||b.target===F.shadowParent)&&po(F.delta,E)})[0];if(I&&I.should){b.cancelable&&b.preventDefault();return}if(!I){var N=(s.current.shards||[]).map(rr).filter(Boolean).filter(function(F){return F.contains(b.target)}),S=N.length>0?l(b,N[0]):!s.current.noIsolation;S&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(m,b,E,I){var N={name:m,delta:b,target:E,should:I,shadowParent:yo(E)};n.current.push(N),setTimeout(function(){n.current=n.current.filter(function(S){return S!==N})},1)},[]),u=g.useCallback(function(m){e.current=Ze(m),r.current=void 0},[]),h=g.useCallback(function(m){c(m.type,nr(m),m.target,l(m,t.lockRef.current))},[]),v=g.useCallback(function(m){c(m.type,Ze(m),m.target,l(m,t.lockRef.current))},[]);g.useEffect(function(){return be.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:v}),document.addEventListener("wheel",p,ye),document.addEventListener("touchmove",p,ye),document.addEventListener("touchstart",u,ye),function(){be=be.filter(function(m){return m!==a}),document.removeEventListener("wheel",p,ye),document.removeEventListener("touchmove",p,ye),document.removeEventListener("touchstart",u,ye)}},[]);var y=t.removeScrollBar,C=t.inert;return g.createElement(g.Fragment,null,C?g.createElement(a,{styles:mo(o)}):null,y?g.createElement(oo,{gapMode:t.gapMode}):null)}function yo(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const bo=Gi(Qn,vo);var ir=g.forwardRef(function(t,n){return g.createElement(Ye,Z({},t,{ref:n,sideCar:bo}))});ir.classNames=Ye.classNames;var wo=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},we=new WeakMap,Re=new WeakMap,et={},$t=0,or=function(t){return t&&(t.host||or(t.parentNode))},Co=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=or(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})},Io=function(t,n,e,r){var o=Co(n,Array.isArray(t)?t:[t]);et[e]||(et[e]=new WeakMap);var a=et[e],s=[],l=new Set,p=new Set(o),c=function(h){!h||l.has(h)||(l.add(h),c(h.parentNode))};o.forEach(c);var u=function(h){!h||p.has(h)||Array.prototype.forEach.call(h.children,function(v){if(l.has(v))u(v);else try{var y=v.getAttribute(r),C=y!==null&&y!=="false",m=(we.get(v)||0)+1,b=(a.get(v)||0)+1;we.set(v,m),a.set(v,b),s.push(v),m===1&&C&&Re.set(v,!0),b===1&&v.setAttribute(e,"true"),C||v.setAttribute(r,"true")}catch(E){console.error("aria-hidden: cannot operate on ",v,E)}})};return u(n),l.clear(),$t++,function(){s.forEach(function(h){var v=we.get(h)-1,y=a.get(h)-1;we.set(h,v),a.set(h,y),v||(Re.has(h)||h.removeAttribute(r),Re.delete(h)),y||h.removeAttribute(e)}),$t--,$t||(we=new WeakMap,we=new WeakMap,Re=new WeakMap,et={})}},xo=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=wo(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),Io(r,o,e,"aria-hidden")):function(){return null}},Vt="Dialog",[ar,na]=oi(Vt),[Eo,Y]=ar(Vt),sr=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=g.useRef(null),p=g.useRef(null),[c=!1,u]=ci({prop:r,defaultProp:o,onChange:a});return i.jsx(Eo,{scope:n,triggerRef:l,contentRef:p,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(h=>!h),[u]),modal:s,children:e})};sr.displayName=Vt;var lr="DialogTrigger",So=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(lr,e),a=le(n,o.triggerRef);return i.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":jt(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});So.displayName=lr;var kt="DialogPortal",[Fo,cr]=ar(kt,{forceMount:void 0}),dr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Y(kt,n);return i.jsx(Fo,{scope:n,forceMount:e,children:g.Children.map(r,s=>i.jsx(Ge,{present:e||a.open,children:i.jsx(qn,{asChild:!0,container:o,children:s})}))})};dr.displayName=kt;var tt="DialogOverlay",ur=g.forwardRef((t,n)=>{const e=cr(tt,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(tt,t.__scopeDialog);return a.modal?i.jsx(Ge,{present:r||a.open,children:i.jsx(No,{...o,ref:n})}):null});ur.displayName=tt;var No=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(tt,e);return i.jsx(ir,{as:Tt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(ne.div,{"data-state":jt(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),de="DialogContent",fr=g.forwardRef((t,n)=>{const e=cr(de,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(de,t.__scopeDialog);return i.jsx(Ge,{present:r||a.open,children:a.modal?i.jsx(To,{...o,ref:n}):i.jsx(Lo,{...o,ref:n})})});fr.displayName=de;var To=g.forwardRef((t,n)=>{const e=Y(de,t.__scopeDialog),r=g.useRef(null),o=le(n,e.contentRef,r);return g.useEffect(()=>{const a=r.current;if(a)return xo(a)},[]),i.jsx(hr,{...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())})}),Lo=g.forwardRef((t,n)=>{const e=Y(de,t.__scopeDialog),r=g.useRef(!1),o=g.useRef(!1);return i.jsx(hr,{...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 p,c;(p=t.onInteractOutside)==null||p.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((c=e.triggerRef.current)==null?void 0:c.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),hr=g.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Y(de,e),p=g.useRef(null),c=le(n,p);return _i(),i.jsxs(i.Fragment,{children:[i.jsx(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Bn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":jt(l.open),...s,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Ao,{titleId:l.titleId}),i.jsx(Bo,{contentRef:p,descriptionId:l.descriptionId})]})]})}),Ut="DialogTitle",Do=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(Ut,e);return i.jsx(ne.h2,{id:o.titleId,...r,ref:n})});Do.displayName=Ut;var pr="DialogDescription",Mo=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(pr,e);return i.jsx(ne.p,{id:o.descriptionId,...r,ref:n})});Mo.displayName=pr;var mr="DialogClose",Po=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(mr,e);return i.jsx(ne.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});Po.displayName=mr;function jt(t){return t?"open":"closed"}var gr="DialogTitleWarning",[ra,vr]=ii(gr,{contentName:de,titleName:Ut,docsSlug:"dialog"}),Ao=({titleId:t})=>{const n=vr(gr),e=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
41
+ `)},vo=0,be=[];function yo(t){var n=g.useRef([]),e=g.useRef([0,0]),r=g.useRef(),o=g.useState(vo++)[0],a=g.useState(Yn)[0],s=g.useRef(t);g.useEffect(function(){s.current=t},[t]),g.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=$i([t.lockRef.current],(t.shards||[]).map(rr),!0).filter(Boolean);return m.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var l=g.useCallback(function(m,b){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var E=Ze(m),I=e.current,N="deltaX"in m?m.deltaX:I[0]-E[0],S="deltaY"in m?m.deltaY:I[1]-E[1],F,L=m.target,T=Math.abs(N)>Math.abs(S)?"h":"v";if("touches"in m&&T==="h"&&L.type==="range")return!1;var P=Rn(T,L);if(!P)return!0;if(P?F=T:(F=T==="v"?"h":"v",P=Rn(T,L)),!P)return!1;if(!r.current&&"changedTouches"in m&&(N||S)&&(r.current=F),!F)return!0;var A=r.current||F;return po(A,b,m,A==="h"?N:S)},[]),p=g.useCallback(function(m){var b=m;if(!(!be.length||be[be.length-1]!==a)){var E="deltaY"in b?nr(b):Ze(b),I=n.current.filter(function(F){return F.name===b.type&&(F.target===b.target||b.target===F.shadowParent)&&mo(F.delta,E)})[0];if(I&&I.should){b.cancelable&&b.preventDefault();return}if(!I){var N=(s.current.shards||[]).map(rr).filter(Boolean).filter(function(F){return F.contains(b.target)}),S=N.length>0?l(b,N[0]):!s.current.noIsolation;S&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(m,b,E,I){var N={name:m,delta:b,target:E,should:I,shadowParent:bo(E)};n.current.push(N),setTimeout(function(){n.current=n.current.filter(function(S){return S!==N})},1)},[]),u=g.useCallback(function(m){e.current=Ze(m),r.current=void 0},[]),h=g.useCallback(function(m){c(m.type,nr(m),m.target,l(m,t.lockRef.current))},[]),v=g.useCallback(function(m){c(m.type,Ze(m),m.target,l(m,t.lockRef.current))},[]);g.useEffect(function(){return be.push(a),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:v}),document.addEventListener("wheel",p,ye),document.addEventListener("touchmove",p,ye),document.addEventListener("touchstart",u,ye),function(){be=be.filter(function(m){return m!==a}),document.removeEventListener("wheel",p,ye),document.removeEventListener("touchmove",p,ye),document.removeEventListener("touchstart",u,ye)}},[]);var y=t.removeScrollBar,C=t.inert;return g.createElement(g.Fragment,null,C?g.createElement(a,{styles:go(o)}):null,y?g.createElement(ao,{gapMode:t.gapMode}):null)}function bo(t){for(var n=null;t!==null;)t instanceof ShadowRoot&&(n=t.host,t=t.host),t=t.parentNode;return n}const wo=Xi(Qn,yo);var ir=g.forwardRef(function(t,n){return g.createElement(Ye,Z({},t,{ref:n,sideCar:wo}))});ir.classNames=Ye.classNames;var Co=function(t){if(typeof document>"u")return null;var n=Array.isArray(t)?t[0]:t;return n.ownerDocument.body},we=new WeakMap,Re=new WeakMap,et={},$t=0,or=function(t){return t&&(t.host||or(t.parentNode))},Io=function(t,n){return n.map(function(e){if(t.contains(e))return e;var r=or(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})},xo=function(t,n,e,r){var o=Io(n,Array.isArray(t)?t:[t]);et[e]||(et[e]=new WeakMap);var a=et[e],s=[],l=new Set,p=new Set(o),c=function(h){!h||l.has(h)||(l.add(h),c(h.parentNode))};o.forEach(c);var u=function(h){!h||p.has(h)||Array.prototype.forEach.call(h.children,function(v){if(l.has(v))u(v);else try{var y=v.getAttribute(r),C=y!==null&&y!=="false",m=(we.get(v)||0)+1,b=(a.get(v)||0)+1;we.set(v,m),a.set(v,b),s.push(v),m===1&&C&&Re.set(v,!0),b===1&&v.setAttribute(e,"true"),C||v.setAttribute(r,"true")}catch(E){console.error("aria-hidden: cannot operate on ",v,E)}})};return u(n),l.clear(),$t++,function(){s.forEach(function(h){var v=we.get(h)-1,y=a.get(h)-1;we.set(h,v),a.set(h,y),v||(Re.has(h)||h.removeAttribute(r),Re.delete(h)),y||h.removeAttribute(e)}),$t--,$t||(we=new WeakMap,we=new WeakMap,Re=new WeakMap,et={})}},Eo=function(t,n,e){e===void 0&&(e="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=Co(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live]"))),xo(r,o,e,"aria-hidden")):function(){return null}},Vt="Dialog",[ar,ra]=ai(Vt),[So,Y]=ar(Vt),sr=t=>{const{__scopeDialog:n,children:e,open:r,defaultOpen:o,onOpenChange:a,modal:s=!0}=t,l=g.useRef(null),p=g.useRef(null),[c=!1,u]=di({prop:r,defaultProp:o,onChange:a});return i.jsx(So,{scope:n,triggerRef:l,contentRef:p,contentId:Nt(),titleId:Nt(),descriptionId:Nt(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(h=>!h),[u]),modal:s,children:e})};sr.displayName=Vt;var lr="DialogTrigger",Fo=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(lr,e),a=le(n,o.triggerRef);return i.jsx(ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":jt(o.open),...r,ref:a,onClick:oe(t.onClick,o.onOpenToggle)})});Fo.displayName=lr;var kt="DialogPortal",[No,cr]=ar(kt,{forceMount:void 0}),dr=t=>{const{__scopeDialog:n,forceMount:e,children:r,container:o}=t,a=Y(kt,n);return i.jsx(No,{scope:n,forceMount:e,children:g.Children.map(r,s=>i.jsx(Ge,{present:e||a.open,children:i.jsx(qn,{asChild:!0,container:o,children:s})}))})};dr.displayName=kt;var tt="DialogOverlay",ur=g.forwardRef((t,n)=>{const e=cr(tt,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(tt,t.__scopeDialog);return a.modal?i.jsx(Ge,{present:r||a.open,children:i.jsx(To,{...o,ref:n})}):null});ur.displayName=tt;var To=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(tt,e);return i.jsx(ir,{as:Tt,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(ne.div,{"data-state":jt(o.open),...r,ref:n,style:{pointerEvents:"auto",...r.style}})})}),de="DialogContent",fr=g.forwardRef((t,n)=>{const e=cr(de,t.__scopeDialog),{forceMount:r=e.forceMount,...o}=t,a=Y(de,t.__scopeDialog);return i.jsx(Ge,{present:r||a.open,children:a.modal?i.jsx(Lo,{...o,ref:n}):i.jsx(Do,{...o,ref:n})})});fr.displayName=de;var Lo=g.forwardRef((t,n)=>{const e=Y(de,t.__scopeDialog),r=g.useRef(null),o=le(n,e.contentRef,r);return g.useEffect(()=>{const a=r.current;if(a)return Eo(a)},[]),i.jsx(hr,{...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())})}),Do=g.forwardRef((t,n)=>{const e=Y(de,t.__scopeDialog),r=g.useRef(!1),o=g.useRef(!1);return i.jsx(hr,{...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 p,c;(p=t.onInteractOutside)==null||p.call(t,a),a.defaultPrevented||(r.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=a.target;((c=e.triggerRef.current)==null?void 0:c.contains(s))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),hr=g.forwardRef((t,n)=>{const{__scopeDialog:e,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:a,...s}=t,l=Y(de,e),p=g.useRef(null),c=le(n,p);return zi(),i.jsxs(i.Fragment,{children:[i.jsx(Vn,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:a,children:i.jsx(Bn,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":jt(l.open),...s,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),i.jsxs(i.Fragment,{children:[i.jsx(Ao,{titleId:l.titleId}),i.jsx(Bo,{contentRef:p,descriptionId:l.descriptionId})]})]})}),Ut="DialogTitle",Mo=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(Ut,e);return i.jsx(ne.h2,{id:o.titleId,...r,ref:n})});Mo.displayName=Ut;var pr="DialogDescription",Po=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(pr,e);return i.jsx(ne.p,{id:o.descriptionId,...r,ref:n})});Po.displayName=pr;var mr="DialogClose",gr=g.forwardRef((t,n)=>{const{__scopeDialog:e,...r}=t,o=Y(mr,e);return i.jsx(ne.button,{type:"button",...r,ref:n,onClick:oe(t.onClick,()=>o.onOpenChange(!1))})});gr.displayName=mr;function jt(t){return t?"open":"closed"}var vr="DialogTitleWarning",[ia,yr]=oi(vr,{contentName:de,titleName:Ut,docsSlug:"dialog"}),Ao=({titleId:t})=>{const n=yr(vr),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 g.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Oo="DialogDescriptionWarning",Bo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${vr(Oo).contentName}}.`;return g.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},Wt=sr,qt=dr,Ht=ur,Gt=fr;const Xt=f.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:p,fieldProps:c},u]=z(t),[h,v]=f.useState(!1),y=c.value,C=f.useCallback(I=>{c.onChange({target:{value:I}}),v(!1)},[c]),m=f.useCallback(()=>{c.onChange({target:{value:""}})},[c]),b=f.useCallback(()=>{v(!0)},[]),E=f.useCallback(()=>{v(!1)},[]);return i.jsx(Q,{helpText:o,severity:s,children:i.jsxs(K,{size:a,severity:s,inputId:n,labelId:e,label:r,image:l?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(Wt,{open:h,onOpenChange:v,children:i.jsxs(qt,{children:[i.jsx(Ht,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Gt,{className:"fixed inset-0",children:i.jsx(Kt,{onQrScan:C,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(d.Button,{...u,variant:"soft",onClick:b,type:"button",children:[i.jsx(d.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(d.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(d.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(d.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:m,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Xt.displayName="QrInput";const Kt=f.memo(t=>{const{onQrScan:n,onClose:e}=t,r=f.useRef(null),[o,a]=f.useState(!1);return f.useEffect(()=>{if(!r.current)return;const s=new qr(r.current,l=>{const p=l.data;n(p),s.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),s.start().finally(()=>{a(!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(d.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{ref:r,style:{width:"100%",height:"100%"}}),o&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(d.Spinner,{})})]})]})});Kt.displayName="QrScanner";const yr={...G,type:"qr"},Ee=class Ee extends j{constructor(e){super({...e,type:"qr"});x(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Ee(e)}getInput(e){return i.jsx(Xt,{...e,field:this})}};x(Ee,"fieldTypeName","QR"),x(Ee,"fieldTypeDescription","Used for scanning/reading QR codes."),x(Ee,"Icon",U.RiQrCodeLine);let nt=Ee;class br extends j{constructor(e){const{placeholder:r="",...o}=e;super(o);x(this,"options");x(this,"onlyValidateAfterTouched",!1);x(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 Ae({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const _o=t=>t?Array.isArray(t)?t:[t]:[],Qt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:v}]=z(t);h=a?null:h,v=a?"":v;const y=f.useMemo(()=>_o(l.value),[l.value]),C=f.useCallback(m=>{c(m),u(m)},[c,u]);return i.jsx(Q,{helpText:h,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:v,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{id:n,className:"!justify-between",name:l.name,variant:"surface",type:"button",accentColor:"base",...p,children:[y.length>0?y.join(", "):s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsxs(d.Menu.MultiSelectGroup,{values:y,onValuesChange:C,children:[i.jsxs(d.Menu.SelectAllItem,{allValues:s.options.map(({value:m})=>m),children:[i.jsx(d.Menu.SelectAllIndicator,{children:m=>m?i.jsx(d.RiIcon,{icon:"RiSubtractLine"}):i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(m=>i.jsxs(d.Menu.MultiSelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))]})})]})})})});Qt.displayName="MultiSelectInput";const wr={...G,type:"multi-select",options:[]},Se=class Se extends br{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 Se(n)}getInput(n){return i.jsx(Qt,{field:this,...n})}};x(Se,"fieldTypeName","Multi-select"),x(Se,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),x(Se,"Icon",U.RiCheckboxLine);let Oe=Se;const Yt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:v}]=z(t);h=a?null:h,v=a?"":v;const y=f.useCallback(m=>{c(m),u(m)},[c,u]),C=f.useMemo(()=>s.options.find(m=>m.value===l.value),[s.options,l.value]);return i.jsx(Q,{helpText:h,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:v,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{...l,className:"!justify-between",id:n,name:l.name,accentColor:"base",variant:"surface",type:"button",...p,children:[C?C.label:s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.SelectGroup,{value:l.value,onValueChange:y,children:s.options.map(m=>i.jsxs(d.Menu.SelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))})})]})})})});Yt.displayName="SelectInput";const Cr={...G,type:"select",options:[]},Fe=class Fe extends br{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 Fe(n)}getInput(n){return i.jsx(Yt,{field:this,...n})}};x(Fe,"fieldTypeName","Dropdown"),x(Fe,"fieldTypeDescription","Allows the user to select a single option from a list of options."),x(Fe,"Icon",U.RiMenuFoldLine);let Be=Fe;const Ir=t=>"fields"in t;class rt extends j{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);x(this,"minLength");x(this,"maxLength");x(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):me,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ie({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 ie({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:me,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}}}x(rt,"_validateMin",e=>(r,o)=>{const a=Ir(o)?X(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),x(rt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=Ir(o)?X(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const Jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,type:s.inputType,id:n,placeholder:s.placeholder})})})})});Jt.displayName="StringInput";const xr={...G,type:"string",maximum_length:ze,input_type:"text"},Ne=class Ne extends rt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ze,e.maxLength):ze,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});x(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 Ne({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(Jt,{field:this,...e})}};x(Ne,"fieldTypeName","Short Text"),x(Ne,"fieldTypeDescription",`Short text fields can hold up to ${ze} characters on a single line.`),x(Ne,"Icon",U.RiInputField);let it=Ne;const Zt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.TextArea,{...p,...l,className:"field-sizing-content",resize:"vertical",id:n,placeholder:s.placeholder,accentColor:"base",variant:"surface"})})})});Zt.displayName="TextInput";const Er={...G,type:"text",maximum_length:me},Te=class Te extends rt{constructor(n){const e=n.maxLength?Math.min(me,n.maxLength):me,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 Te({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(Zt,{field:this,...n})}};x(Te,"fieldTypeName","Paragraph"),x(Te,"fieldTypeDescription",`Paragraph fields can hold up to ${me} characters and can have multiple lines.`),x(Te,"Icon",U.RiAlignJustify);let ot=Te;const Sr=f.memo(f.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,truncateLength:l,...p}=t,c=f.useRef(null),u=f.useRef(null),h=d.useSize(c);f.useLayoutEffect(()=>{!u.current||!h||(u.current.style.height=`${h.height*4}px`)},[h]);const v=f.useMemo(()=>{if(e)return l!==void 0?H.truncate(e.name,l):e.name},[e,l]);return i.jsxs("div",{className:pe(s,"relative flex h-max w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...p,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(d.Spinner,{})}),i.jsx("div",{ref:u,className:"-m-4 flex max-w-full 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:pe("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),ref:c,children:[o?i.jsx(d.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(Me,{fileType:e.type}),o??v,a]})]})})),Fr=f.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Nr=()=>f.useContext(Fr),Rt=f.memo(t=>{const{file:n,onClose:e}=t,r=f.useRef(null),o=f.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(p=>{p&&navigator.clipboard.write([new ClipboardItem({"image/png":p})])},"image/png")},[]),a=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(Wt,{open:!0,onOpenChange:e,children:i.jsx(qt,{children:i.jsx(Ht,{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(Gt,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(d.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(d.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(d.Separator,{orientation:"vertical",size:"sm"}),i.jsx(d.Dialog.Close,{asChild:!0,children:i.jsx(d.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(d.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})})]})})})})});Rt.displayName="ImageViewer";const Tr=f.memo(t=>{const{children:n}=t,[e,r]=f.useState(null),o=f.useCallback(()=>{r(null)},[]),a=f.useCallback(p=>{r(p(o))},[o]),s=f.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=f.useMemo(()=>a,[a]);return i.jsxs(Fr.Provider,{value:l,children:[n,e&&i.jsx(Rt,{file:e.file,onClose:s})]})});Tr.displayName="FileViewerProvider";const 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)},Lr=f.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:p},c]=z(t),{onChange:u}=p;let[{label:h}]=z(t);h=s?"":h;const v=o?te[o]:void 0,y=f.useRef(null),{value:C}=p,m=f.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),b=f.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=f.useCallback(L=>{const T=[...C];T.splice(L,1),u({target:{files:T}})},[C,u]),I=C?"Select new files":"Select files",N=C?"Select new file":"Select a file",S=l.maxFiles>1?I:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Q,{helpText:m,severity:o,children:i.jsxs(K,{size:r,severity:o,inputId:n,labelId:e,label:h,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(d.Button,{...c,className:"w-max",variant:"soft",onClick:b,id:"upload-input-upload-button",type:"button",children:[i.jsx(d.RiIcon,{icon:"RiUpload2Line"})," ",S]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,color:v,style:{display:"none"},...p,value:""})]})}),Array.isArray(C)&&C.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:C.map((L,T)=>i.jsx(Dr,{field:l,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});Lr.displayName="UploadInput";const Dr=f.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=f.useState(null),l=Nr(),p=f.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:u}=f.useMemo(()=>{let m=null,b,E;return a!=null&&a.type.startsWith("image/")&&(m=URL.createObjectURL(a)),a?(b=a.name,E=zo(a.size)):(b="Downloading...",E="..."),{url:m,name:b,size:E}},[a]);f.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=f.useCallback(m=>{if(m.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const b=new Blob([a]);Cn.saveAs(b,u)},[u,a]),v=f.useCallback(m=>{m.stopPropagation(),r()},[r]),y=f.useCallback(()=>{a&&l(m=>({file:a,onDelete:o?void 0:()=>{r(),m()}}))},[o,r,l,a]),C=f.useMemo(()=>i.jsxs(d.ButtonGroup,{className:"flex w-full justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(d.IconButton,{"aria-label":`Download ${u}`,onClick:h,disabled:!a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(d.IconButton,{"aria-label":`Remove ${u}`,disabled:o,onClick:v,children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]}),[o,v,h,u,a]);return c?i.jsx(Sr,{className:"cursor-pointer",onClick:y,file:a,error:p??void 0,rightSlot:C}):i.jsx(mt,{file:a,error:p??void 0,rightSlot:C})});Dr.displayName="DisplayFile";const $o={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Le=class Le extends j{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});x(this,"extensions");x(this,"maxFileSize");x(this,"maxFiles");x(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 ie({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 ie({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${at}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:at,integers:!0}),showDirectly:!1},{field:new Oe({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??at,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 Le(e)}getInput(e){return i.jsx(Lr,{field:this,...e})}};x(Le,"fieldTypeName","Upload"),x(Le,"fieldTypeDescription","Allows a file to be uploaded."),x(Le,"Icon",U.RiUpload2Line);let en=Le;const tn={date:ke,number:ie,boolean:ge,select:Be,string:it,text:ot,custom:Ue,upload:en,qr:nt,"multi-string":Ae,"multi-select":Oe},Vo={date:xn,number:Ln,boolean:In,select:Cr,string:xr,text:Er,custom:ei,upload:$o,qr:yr,"multi-string":Tn,"multi-select":wr},at=50,ko=at*1e3*1e3,nn=t=>{const n=t.type;return tn[n].deserialize(t)},st=t=>t.type==="section"?W.deserialize(t):nn(t);function Mr(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>st(r)),meta:{readonly:e}}}function rn(t){const n=[];for(const e of t.fields)if(e instanceof W)for(const r of e.fields)n.push(r);else{if(!(e instanceof j))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function Uo(t,n){const e=rn(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 jo(t,n){const e=rn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function lt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function on(t,n){if(!t)return!0;if(lt(n)||lt(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=f.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:p}=k.useFormikContext(),c=s!=null&&s.identifier?X(l,s.identifier):void 0,u=f.useMemo(()=>c===void 0||on(s,c),[s,c]);f.useEffect(()=>{if(!u)for(const v of a)p(v.getId(),"").then()},[u,a,p]);const h=Pe(a,e);return u?i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(d.Heading,{size:"lg",children:r}),i.jsx(d.Text,{accentColor:"base",children:o})]}),h]})}):null});Pr.displayName="FieldSectionLayout";const De=class De extends gt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});x(this,"label");x(this,"fields");x(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 ge({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new De({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Be({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 ti({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(nn);return new De({...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(X(e,a),e);s&&ht(r,o.getId(),s)}return r}getInput(e){return i.jsx(Pr,{field:this,...e})}};x(De,"fieldTypeName","Section"),x(De,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let W=De;const ue=t=>Object.keys(t).length>0,ct=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof W){if(r.condition){const{identifier:o}=r.condition;if(!on(r.condition,X(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof j))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(X(n,o),n);a&&ht(e,o,a)}if(ue(e))return e},Wo=[null,void 0],dt=(t,n)=>t.reduce((e,r)=>r instanceof W?{...e,...dt(r.fields,n)}:(Wo.includes(X(e,r.getId()))&&ht(e,r.getId(),""),e),Hr(n)),qo=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Ar=f.memo(f.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=qo,submitText:a="Submit",cancelText:s,onCancel:l,onDirty:p,onDirtyChange:c,hideTitle:u=!e.title,hideDescription:h,className:v,buttonProps:y}=t,{readonly:C}=e.meta,m=f.useMemo(()=>crypto.randomUUID(),[]),b=k.useFormik({initialValues:dt(e.fields,r),onSubmit:o,validate:F=>ct(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=b,I=f.useMemo(()=>typeof e.title=="string"?i.jsx(d.Heading,{size:"lg",children:e.title}):e.title,[e.title]),N=f.useMemo(()=>typeof e.description=="string"?i.jsx(d.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),S=Pe(e.fields,{formId:m,disabled:C});return f.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(k.FormikProvider,{value:b,children:i.jsxs("form",{id:m,ref:n,className:pe(v,"flex flex-col gap-2"),onSubmit:b.handleSubmit,children:[!u&&i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[I,!h&&N]})}),S,!C&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s&&i.jsxs(d.Button,{accentColor:te.danger,...y,type:"button",onClick:l,children:[i.jsx(d.RiIcon,{icon:"RiCloseLine"}),s]}),i.jsxs(d.Button,{...y,type:"submit",disabled:!b.isValid,accentColor:"success",children:[i.jsx(d.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),fe=f.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=k.useFormikContext(),[o,a,s]=k.useField(n),l=f.useMemo(()=>{const p=c=>{s.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});fe.displayName="PatchField";const Ho=f.memo(f.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:p,...c}=t,u=f.useMemo(()=>dt(r.fields,o),[r.fields,o]),h=f.useCallback(I=>{const N={};for(const S in I){const F=I[S];F!==u[S]&&F!==void 0&&(N[S]=F)}return N},[u]),v=f.useCallback(I=>{const N=h(I);l&&!ue(N)||a(N)},[h,a,l]),y=f.useCallback(I=>{const N=ct(r,I);if(N&&s(N),p){const S=h(I);p(ue(S))}return N},[r,p,s,h]),C=k.useFormik({initialValues:u,onSubmit:v,validate:y,validateOnBlur:!1,validateOnChange:!1}),m=f.useCallback(()=>{if(p){const I=h(C.values);ue(I)&&p(!0)}},[C.values,h,p]),{errors:b,resetForm:E}=C;return f.useEffect(()=>{ue(b)&&E({values:u,errors:{}})},[b,u,E]),i.jsx(k.FormikProvider,{value:C,children:i.jsx("form",{...c,ref:n,onSubmit:C.handleSubmit,onChange:m,children:e})})})),ut="form-builder",Go=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],an={...tn,section:W},Xo=(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}},Ko=(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}}},Or=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,p=new Set(l);(r=s.condition)!=null&&r.identifier&&p.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:p,conditionIndex:Ko(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},sn=f.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:p}=k.useFormikContext(),c=f.useRef(null),u=f.useMemo(()=>{const h=[{Icon:U.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:U.RiDeleteBin2Line,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:U.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var v;(v=c.current)==null||v.click()}}}),(r===void 0&&n!==p.fields.length-1||r!==void 0&&(r<p.fields.length-1||n!==p.fields[r].fields.length-1))&&h.unshift({Icon:U.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:U.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-2 hidden flex-col gap-5 sm:flex",children:u.map(h=>i.jsx(d.IconButton,{type:"button",variant:"ghost",accentColor:h.key.startsWith("move")?"base":void 0,"aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsx(d.IconButton,{variant:"ghost","aria-label":"Actions menu",children:i.jsx(d.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(d.Menu.Content,{children:u.map(h=>{var v;return i.jsxs(d.Menu.Item,{onClick:(v=h.buttonProps)==null?void 0:v.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:l})]})});sn.displayName="FieldActions";const Br=(t=()=>null)=>f.useMemo(()=>Go.map(n=>n.map(e=>{const r=tn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),he=t=>t.type==="section",ln=f.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{children:i.jsxs(d.Button,{variant:"soft",size:"sm","aria-label":"settings",...e&&{color:te.danger},children:[i.jsx(d.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(d.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});ln.displayName="FieldSettingsPopover";const cn=f.memo(t=>{var ft,fn,Ur,jr,Wr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=k.useFormikContext(),p=Br(),c=f.useRef(null),u=576,[h,v]=f.useState(c.current&&c.current.getBoundingClientRect().width>=u);f.useEffect(()=>{const D=c.current;if(D){const O=new ResizeObserver(q=>{q[0]&&v(q[0].contentRect.width>=u)});return O.observe(D),()=>{O.disconnect()}}},[]);const[y,C]=f.useState(void 0),[m,b]=f.useState(!1);f.useEffect(()=>{he(r)?C(void 0):r.image instanceof Promise?r.image.then(C).catch(console.error):C(r.image)},[r]);const E=y?URL.createObjectURL(y):void 0,I=f.useCallback(D=>{D.stopPropagation();const{image:O,...q}=r;s(`${n}.${e}`,q).then()},[e,r,n,s]);f.useEffect(()=>{he(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const N=f.useMemo(()=>{var D,O;return he(r)?(O=Fn(a.fields,(D=r.condition)==null?void 0:D.identifier))==null?void 0:O.label:void 0},[r,a.fields]),S=he(r)?Array.isArray((ft=r.condition)==null?void 0:ft.value)?"contains all of":"equals":void 0;let F;if(he(r)){if(lt((fn=r.condition)==null?void 0:fn.value))throw new Error("File values are not supported for conditions.");F=Array.isArray((Ur=r.condition)==null?void 0:Ur.value)?r.condition.value.map(D=>typeof D=="string"?D:D.label).join(", "):(Wr=(jr=r.condition)==null?void 0:jr.value)==null?void 0:Wr.toString()}const L=f.useCallback(D=>{D.target.parentNode instanceof HTMLElement&&(D.target.parentNode.dataset.replicatedValue=D.target.value)},[]),T=f.useCallback(D=>{D.target.parentNode instanceof HTMLElement&&(D.target.parentNode.dataset.replicatedValue=D.target.value)},[]),P=r.type,A=an[P],[$,M]=f.useMemo(()=>{let D=[],O=[];if(A===W){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const q=A.getFieldCreationSchema(o,`${n}.${e}`);D=D.concat(q.filter(V=>V.showDirectly).map(V=>V.field)),O=O.concat(q.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(A.prototype instanceof j))throw new Error(`Field must be an instance of BaseField. Got ${A.toString()}.`);const q=A.getFieldCreationSchema(`${n}.${e}`);h?(D=[...D,...q.filter(V=>V.showDirectly).map(V=>V.field)],O=[...O,...q.filter(V=>!V.showDirectly).map(V=>V.field)]):O=[...O,...q.map(V=>V.field)]}return[D,O]},[A,o,n,e,h]),B=Pe($,{formId:ut,disabled:!1,internal:!0,...A===W&&{size:"sm"}}),_=Pe(M,{formId:ut,disabled:!1});let ee=M.length>0;he(r)&&M.length>0&&(ee=r.conditional);const se=M.some(D=>{const O=X(l,A===W?`${n}.${e}.condition`:D.getId());return O&&(typeof O!="object"||ue(O))}),_e=se?te.danger:void 0,dn=f.useMemo(()=>st(r),[r]),un=Ct(dn,{formId:ut,showInputOnly:!1}),J=f.useMemo(()=>p.flat().find(D=>D.value===P),[p,P]);return i.jsx("div",{className:"flex grow items-center w-full",ref:c,children:i.jsxs("div",{className:"flex w-full flex-col gap-4",children:[A===W&&i.jsxs("div",{className:"flex flex-col gap-2",children:[$.length>0&&B,i.jsxs("div",{className:"flex items-center gap-4",children:[ee&&i.jsx(ln,{popoverInputs:_,hasError:se}),he(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":_e,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:N})," ",S," ",i.jsx("strong",{children:F})]})})]})]}),A!==W&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(d.Badge,{accentColor:"base",variant:"soft",children:[J==null?void 0:J.icon,J==null?void 0:J.children]}),i.jsx(fe,{name:`${n}.${e}.required`,render:({setValue:D,value:O})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Checkbox.Root,{checked:O,onCheckedChange:D,children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(d.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),ee&&i.jsx(ln,{popoverInputs:_,hasError:se})]}),y&&i.jsxs(i.Fragment,{children:[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:E,alt:y.name,onClick:()=>{b(!0)}}),i.jsx(d.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:te.danger,"aria-label":"delete",onClick:I,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]}),m&&i.jsx(vt,{file:y,url:E,name:y.name,setShowPreview:b})]}),i.jsx(fe,{name:`${n}.${e}.label`,render:({setValue:D,value:O})=>i.jsx("input",{className:"bg-transparent outline-none text-base",placeholder:P==="section"?"Enter a section label (optional)":"Enter your question",value:O,onChange:q=>{D(q.target.value)},onInput:L,maxLength:200})}),i.jsx(fe,{name:`${n}.${e}.description`,render:({setValue:D,value:O})=>i.jsx("textarea",{className:"bg-transparent outline-none text-base field-sizing-content grow",placeholder:`Enter a ${P==="section"?"section":"field"} description (optional)`,value:O,onChange:q=>{D(q.target.value)},onInput:T,maxLength:1e3})}),A!==W&&$.length>0&&i.jsx("div",{className:"w-full",children:B}),A!==W&&i.jsxs(i.Fragment,{children:[i.jsx(d.Separator,{size:"full"}),i.jsxs(d.Card,{className:"flex flex-col gap-2 bg-(--accent-a2)",children:[i.jsx(d.Text,{accentColor:"base",children:"Field preview"}),i.jsx("div",{children:un})]})]})]})})});cn.displayName="FieldBuilder";const _r=f.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=k.useFormikContext(),{reorderField:l}=Et(),{showError:p}=d.useToast(),c=`fields.${r}.fields`,u=f.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=f.useCallback(()=>{const C=n.label??"Unlabelled field",m={...n,label:C};qe(c,e+1,m,s,a)},[n,c,e,s,a]),v=f.useCallback(C=>{const m=r,b=s.fields[m];let E=r,I=C==="up"?e-1:e+1;C==="up"&&e===0?(E=r-1,I=s.fields[E].fields.length):C==="down"&&e===b.fields.length-1&&(E=r+1,I=0);const N=s.fields[E];l(b,m,e,N,E,I,a)},[r,s.fields,e,l,a]),y=f.useCallback(C=>{const{files:m}=C.target;if(!m||m.length!==1)return;const b=m.item(0);if(b){if(b.size>ko){p({title:"File upload error",description:`The file ${b.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:b}).then()}},[n,e,c,a,p]);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:C=>i.jsx(d.Card,{ref:C.innerRef,...C.draggableProps,...C.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(cn,{...u}),i.jsx(sn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:v,upload:y})]})})})});_r.displayName="FieldWithActions";const zr=f.memo(t=>{var N;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(N=r[n.identifier])==null?void 0:N.disabled,{setFieldValue:s,values:l}=k.useFormikContext(),p=d.useAlertDialog(),{reorderSection:c}=Et(),u=f.useCallback((S,F)=>{for(const L of S){const T=F.indexOf(L);s(`fields.${T}.condition`,null).then(),s(`fields.${T}.conditional`,!1).then()}},[s]),h=f.useCallback(S=>{var T;const F=n.fields[S];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const P of l.fields)((T=P.condition)==null?void 0:T.identifier)===F.identifier&&L.push(P);return{removing:F,affectedSections:L,action:()=>s(`fields.${e}.fields`,We(n.fields,S))}},[n.fields,l.fields,s,e]),v=f.useCallback(S=>{const{affectedSections:F,action:L,removing:T}=h(S),P=()=>{L().then(),u(F,l.fields)};if(F.length>0){const A=F.map($=>$.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${A} section(s).`,action:"Remove",onAction:P});return}P()},[h,u,l.fields,p]),y=f.useCallback(()=>{const F=n.fields.map((B,_)=>h(_)).flatMap(B=>B.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,P=F.map(B=>B.label).join(", "),A=F.length?`Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${P}`:`Deleting this section will remove the ${T} field(s) it contains.`,$=We(l.fields,e),M=()=>s("fields",$);if(F.length>0){p({title:L,description:A,action:"Remove",onAction:()=>{M().then(()=>{u(F,$)})}});return}M().then()},[n.fields,l.fields,e,h,s,p,u]),C=f.useCallback(S=>{const F=S==="up"?e-1:e+1;c(r,n.identifier,e,F,l,s)},[e,c,r,n.identifier,l,s]),m=f.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:Nn(l.fields,e)}),[n,e,l.fields]),b=f.useCallback(()=>{const S=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:xt(null,T.label)})),L={...n,label:S,fields:F};qe("fields",e+1,L,l,s)},[n,e,l,s]),E=f.useCallback(S=>{qe(`fields.${e}.fields`,n.fields.length,Vo[S],l,s)},[e,n.fields.length,l,s]),I=Br(E);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:S=>i.jsx(d.Card,{ref:S.innerRef,...S.draggableProps,...S.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(cn,{...m}),i.jsx(re.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:F=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:F.innerRef,...F.droppableProps,children:[n.fields.map((L,T)=>i.jsx(_r,{field:L,index:T,sectionIndex:e,remove:()=>{v(T)}},L.identifier)),F.placeholder,i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{type:"button",variant:"solid",children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(d.Menu.Content,{children:I.flat().map(L=>i.jsxs(d.Menu.Item,{onSelect:L.onSelect,children:[L.icon,L.children]},L.value))})]})]})})]}),!o&&i.jsx(sn,{index:e,type:n.type,remove:y,duplicate:b,move:C})]})})})});zr.displayName="FieldSectionWithActions";const $r=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},Vr=f.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=k.useFormikContext(),[o,a]=f.useReducer(Xo,e.fields,Or),{reorderSection:s,reorderField:l}=Et();f.useEffect(()=>{a({type:"update",state:Or(e.fields)})},[a,e.fields]);const p=f.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=f.useCallback(h=>{const{source:v,destination:y,type:C,reason:m,draggableId:b}=h;if(a({type:"release"}),!y||m==="CANCEL")return;if(C==="ROOT"){s(o,b,v.index,y.index,e,r);return}if(C!=="SECTION")throw new Error("Unexpected droppable type.");const[E,I]=$r(e.fields,v.droppableId)??[],[N,S]=$r(e.fields,y.droppableId)??[];l(E,I,v.index,N,S,y.index,r)},[e,l,r,s,o]),u=f.useCallback(h=>{ri(h+1,e,r)},[e,r]);return i.jsx(re.DragDropContext,{onDragStart:p,onDragEnd:c,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((v,y)=>i.jsxs(f.Fragment,{children:[i.jsx(zr,{field:v,index:y,dropState:o,fieldsOnly:n}),!n&&y!==e.fields.length-1&&i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(y)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]})]},v.identifier)),i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(e.fields.length)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});Vr.displayName="FieldsEditor";const Qo=()=>{alert("This is a form preview, your data will not be saved.")},Yo=f.memo(f.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:u,hydrateRevisionWithImages:h}=t,{showError:v}=d.useToast(),y=f.useCallback(I=>{const N={};I.title||(N.title="Title is required."),(!I.fields||I.fields.length===0)&&(N.fields="At least one field is required.");let S=[];for(const[L,T]of I.fields.entries()){const A=an.section.getFieldCreationSchema(Nn(I.fields,L),`fields.${L}`).map($=>$.field);S=[...S,...A];for(const[$,M]of T.fields.entries()){const _=an[M.type].getFieldCreationSchema(`fields.${L}.fields.${$}`).map(ee=>ee.field);S=[...S,..._]}}const F=ct({fields:S},I);if(F&&(N.fields=F.fields),ue(N))return v({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),N},[v]),C=f.useMemo(()=>({title:a??"",description:"",fields:[{...je(xt(null,"")),label:""}]}),[a]),m=o?h(o):void 0,b=k.useFormik({initialValues:ni(m)??C,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=f.useMemo(()=>Mr(b.values),[b.values]);return i.jsx(d.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(d.Tabs.List,{className:pe("sticky top-0 z-[2000] flex bg-(--color-background)",u),children:[i.jsx(d.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(d.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(d.Tabs.Content,{value:"edit",children:[s&&i.jsxs("span",{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:ut,onSubmit:b.handleSubmit,children:[i.jsxs(k.FormikProvider,{value:b,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(fe,{name:"title",render:({setValue:I,value:N,meta:S})=>i.jsx(yt,{severity:"danger",helpText:S.error??null,children:i.jsx(d.Input.Root,{variant:"outline",size:"lg",accentColor:S.error?te.danger:"primary",children:i.jsx(d.Input.Field,{placeholder:"Form title",value:N,onChange:F=>{I(F.target.value)},maxLength:100})})})}),i.jsx(fe,{name:"description",render:({setValue:I,value:N})=>i.jsx(d.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:N,onChange:S=>{I(S.target.value)},resize:"vertical",maxLength:1e3})})]}),i.jsx(Vr,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":te.danger,className:"text-xs text-(--accent-a11)",children:typeof b.errors.fields=="string"&&b.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(d.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(d.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(d.Tabs.Content,{value:"preview",children:i.jsx(Ar,{schema:E,onSubmit:Qo,hideTitle:!l})})]})})})),Jo=Object.values(H.Colors),Zo=1;async function Ro(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 H.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 p=t.toDataURL("image/jpeg",Zo),c=await H.fileToBlob(p),u=new File([c],n.name,{type:"image/jpeg"});l.resolve(u)}},a.src=URL.createObjectURL(n),l}const kr=f.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=f.useRef(null),p=f.useRef(null),[c,u]=f.useState(H.Colors.red),[h,v]=f.useState(null),[y,C]=f.useState(!1),[m,b]=f.useState(!1),E=f.useRef(null),I=d.useSize(E);f.useEffect(()=>{const _=new Image;_.onload=function(){v({width:_.naturalWidth,height:_.naturalHeight})},_.src=URL.createObjectURL(n)},[n]),f.useEffect(()=>{!m&&(I!=null&&I.width)&&I.height&&b(!0)},[I,m]);const N=f.useCallback(async()=>{a||e();const _=l.current;if(!_)return;if(!h)throw new Error("Original image size not loaded yet");const ee=await _.exportImage("png"),se=new Image(h.width,h.height);se.onload=async function(){const _e=await H.fileToBlob(ee),dn=new File([_e],n.name,{type:n.type}),un=p.current,J=await Ro(un,n,dn,h);J.objectURL=URL.createObjectURL(J);const ft=await H.hashFile(n);await H.hashFile(J)!==ft&&r(J),C(!1),e()},C(!0),se.src=ee},[a,n,e,r,h]),S=f.useCallback(()=>{o(n)},[n,o]),F=f.useCallback(()=>{e()},[e]),L=f.useCallback(()=>{s(!0)},[s]),T=f.useCallback(()=>{l.current&&l.current.redo()},[]),P=f.useCallback(()=>{l.current&&l.current.undo()},[]),A=f.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),$=f.useCallback(_=>{l.current&&l.current.eraseMode(_)},[]),M=f.useCallback(()=>{N()},[N]),B=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(Wt,{open:!0,onOpenChange:e,children:i.jsxs(qt,{children:[i.jsx(Ht,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Gt,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs(i.Fragment,{children:[h&&i.jsx("canvas",{style:{display:"none"},id:"attachment-markup-canvas",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-8 w-full items-center bg-(--color-background) px-2",children:i.jsx(d.ButtonGroup,{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(d.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})}),i.jsx(d.IconButton,{"aria-label":`Download ${n.name}`,onClick:B,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(pt,{selectedColor:c,allColors:Jo,onFinish:u,trigger:i.jsx(d.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(d.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:$,children:i.jsx(d.RiIcon,{icon:"RiEraserFill"})}),i.jsx(d.Separator,{orientation:"vertical",size:"full"}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:P,children:i.jsx(d.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(d.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(d.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(d.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(d.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:M,children:i.jsx(d.RiIcon,{icon:"RiSaveLine"})}),i.jsx(d.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})})}),i.jsxs("div",{className:"relative flex w-full grow items-center justify-center p-4",children:[i.jsx("img",{className:"translate-xmax-h-[calc(100%-130px)] pointer-events-none invisible absolute top-[50%] left-[50%] max-w-svw translate-x-[-50%] translate-y-[-50%] object-contain",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(d.Spinner,{}):i.jsx(Gr.ReactSketchCanvas,{backgroundImage:n.objectURL,ref:l,width:`${(I==null?void 0:I.width)||0}px`,height:`${(I==null?void 0:I.height)||0}px`,onStroke:L,strokeColor:c},m?"1":"0")]})]})]})})]})})});kr.displayName="AttachmentEditor",w.BaseField=j,w.BaseFormElement=gt,w.BooleanField=ge,w.BooleanInput=bt,w.ColorPicker=pt,w.DateField=ke,w.DateInput=wt,w.FieldSection=W,w.FileBadge=yn,w.FileCard=mt,w.FileIcon=Me,w.FormBuilder=Yo,w.FormRenderer=Ar,w.ImageCard=Sr,w.ImageMarkup=kr,w.ImageViewer=Rt,w.ImageViewerProvider=Tr,w.InputWithHelpText=yt,w.InputWithLabel=K,w.InputWithLabelAndHelpText=Q,w.MultiSelectField=Oe,w.MultiSelectInput=Qt,w.MultiStringField=Ae,w.MultiStringInput=St,w.NumberField=ie,w.NumberInput=Ft,w.PatchField=fe,w.PatchFormProvider=Ho,w.QrField=nt,w.QrInput=Xt,w.QrScanner=Kt,w.SUPPORTED_IMAGE_FILE_TYPES=mn,w.SUPPORTED_PDF_FILE_TYPES=vn,w.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=gn,w.SelectField=Be,w.SelectInput=Yt,w.StringField=it,w.StringInput=Jt,w.TextField=ot,w.TextInput=Zt,w.decodeFormValues=Uo,w.deserialize=st,w.deserializeField=nn,w.emptyBaseField=G,w.emptyBooleanField=In,w.emptyDateField=xn,w.emptyMultiSelectField=wr,w.emptyMultiStringField=Tn,w.emptyNumberField=Ln,w.emptyQrField=yr,w.emptySelectField=Cr,w.emptyStringField=xr,w.emptyTextField=Er,w.encodeFormValues=jo,w.flattenFields=rn,w.formRevisionToSchema=Mr,w.initialFormValues=dt,w.isConditionMet=on,w.useFieldInput=Ct,w.useFieldInputs=Pe,w.useFormikInput=z,w.useImageViewer=Nr,w.validateForm=ct,w.valueIsFile=lt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
45
+ For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return g.useEffect(()=>{t&&(document.getElementById(t)||console.error(e))},[e,t]),null},Oo="DialogDescriptionWarning",Bo=({contentRef:t,descriptionId:n})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${yr(Oo).contentName}}.`;return g.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},Wt=sr,qt=dr,Ht=ur,Gt=fr,_o=gr;const Xt=f.memo(t=>{const[{inputId:n,labelId:e,label:r,helpText:o,size:a,severity:s,showInputOnly:l,field:p,fieldProps:c},u]=z(t),[h,v]=f.useState(!1),y=c.value,C=f.useCallback(I=>{c.onChange({target:{value:I}}),v(!1)},[c]),m=f.useCallback(()=>{c.onChange({target:{value:""}})},[c]),b=f.useCallback(()=>{v(!0)},[]),E=f.useCallback(()=>{v(!1)},[]);return i.jsx(Q,{helpText:o,severity:s,children:i.jsxs(K,{size:a,severity:s,inputId:n,labelId:e,label:r,image:l?void 0:p.image,className:"flex-col items-start justify-start gap-1",children:[i.jsx(Wt,{open:h,onOpenChange:v,children:i.jsxs(qt,{children:[i.jsx(Ht,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)"}),i.jsx(Gt,{className:"fixed inset-0",children:i.jsx(Kt,{onQrScan:C,onClose:E})})]})}),i.jsxs("div",{className:"flex w-max items-center gap-1",children:[i.jsxs(d.Button,{...u,variant:"soft",onClick:b,type:"button",children:[i.jsx(d.RiIcon,{icon:"RiQrCodeLine"}),"Scan"]}),y&&i.jsx("span",{className:"text-xs text-(--accent-a11)","data-accent-color":"primary",children:i.jsx(d.RiIcon,{icon:"RiCheckLine",style:{verticalAlign:"bottom"}})})]}),!!y&&i.jsx(d.Card,{children:i.jsxs("div",{className:"w-max items-center gap-2",children:[i.jsx("code",{className:"bg-(--base-a3)",children:y}),i.jsx(d.IconButton,{accentColor:"base",variant:"ghost","aria-label":"delete",size:"sm",onClick:m,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})]})})]})})});Xt.displayName="QrInput";const Kt=f.memo(t=>{const{onQrScan:n,onClose:e}=t,r=f.useRef(null),[o,a]=f.useState(!1);return f.useEffect(()=>{if(!r.current)return;const s=new Hr(r.current,l=>{const p=l.data;n(p),s.destroy()},{highlightCodeOutline:!0,highlightScanRegion:!0,maxScansPerSecond:1});a(!0),s.start().finally(()=>{a(!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(d.IconButton,{"aria-label":"close",variant:"soft",accentColor:"base",onClick:e,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})})}),i.jsxs("div",{className:"relative max-h-full max-w-full",children:[i.jsx("video",{ref:r,style:{width:"100%",height:"100%"}}),o&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-(--color-background)",children:i.jsx(d.Spinner,{})})]})]})});Kt.displayName="QrScanner";const br={...G,type:"qr"},Ee=class Ee extends j{constructor(e){super({...e,type:"qr"});x(this,"onlyValidateAfterTouched",!1)}serialize(){return super._serialize()}static deserialize(e){if(e.type!=="qr")throw new Error("Type mismatch.");return new Ee(e)}getInput(e){return i.jsx(Xt,{...e,field:this})}};x(Ee,"fieldTypeName","QR"),x(Ee,"fieldTypeDescription","Used for scanning/reading QR codes."),x(Ee,"Icon",U.RiQrCodeLine);let nt=Ee;class wr extends j{constructor(e){const{placeholder:r="",...o}=e;super(o);x(this,"options");x(this,"onlyValidateAfterTouched",!1);x(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 Ae({label:"Options",description:"List possible options for the user to select from.",required:!0,identifier:`${r}options`,minimum_length:2}),showDirectly:!0}]}}const zo=t=>t?Array.isArray(t)?t:[t]:[],Qt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:v}]=z(t);h=a?null:h,v=a?"":v;const y=f.useMemo(()=>zo(l.value),[l.value]),C=f.useCallback(m=>{c(m),u(m)},[c,u]);return i.jsx(Q,{helpText:h,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:v,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{id:n,className:"!justify-between",name:l.name,variant:"surface",type:"button",accentColor:"base",...p,children:[y.length>0?y.join(", "):s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsxs(d.Menu.MultiSelectGroup,{values:y,onValuesChange:C,children:[i.jsxs(d.Menu.SelectAllItem,{allValues:s.options.map(({value:m})=>m),children:[i.jsx(d.Menu.SelectAllIndicator,{children:m=>m?i.jsx(d.RiIcon,{icon:"RiSubtractLine"}):i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),"Select all"]}),s.options.map(m=>i.jsxs(d.Menu.MultiSelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))]})})]})})})});Qt.displayName="MultiSelectInput";const Cr={...G,type:"multi-select",options:[]},Se=class Se extends wr{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 Se(n)}getInput(n){return i.jsx(Qt,{field:this,...n})}};x(Se,"fieldTypeName","Multi-select"),x(Se,"fieldTypeDescription","Allows the user to select a multiple options from a list of options."),x(Se,"Icon",U.RiCheckboxLine);let Oe=Se;const Yt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t),{onChange:c,onBlur:u}=l;let[{helpText:h,label:v}]=z(t);h=a?null:h,v=a?"":v;const y=f.useCallback(m=>{c(m),u(m)},[c,u]),C=f.useMemo(()=>s.options.find(m=>m.value===l.value),[s.options,l.value]);return i.jsx(Q,{helpText:h,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:v,image:a?void 0:s.image,children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{...l,className:"!justify-between",id:n,name:l.name,accentColor:"base",variant:"surface",type:"button",...p,children:[C?C.label:s.placeholder,i.jsx(d.RiIcon,{icon:"RiArrowDownSLine"})]})}),i.jsx(d.Menu.Content,{children:i.jsx(d.Menu.SelectGroup,{value:l.value,onValueChange:y,children:s.options.map(m=>i.jsxs(d.Menu.SelectItem,{value:m.value,children:[i.jsx(d.Menu.SelectedIndicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})}),m.label]},m.value))})})]})})})});Yt.displayName="SelectInput";const Ir={...G,type:"select",options:[]},Fe=class Fe extends wr{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 Fe(n)}getInput(n){return i.jsx(Yt,{field:this,...n})}};x(Fe,"fieldTypeName","Dropdown"),x(Fe,"fieldTypeDescription","Allows the user to select a single option from a list of options."),x(Fe,"Icon",U.RiMenuFoldLine);let Be=Fe;const xr=t=>"fields"in t;class rt extends j{constructor(e){const{minLength:r,maxLength:o,placeholder:a="",...s}=e;super(s);x(this,"minLength");x(this,"maxLength");x(this,"placeholder");this.minLength=r?Math.max(r,0):void 0,this.maxLength=o?Math.max(o,0):me,this.placeholder=a}static getFieldCreationSchema(e=""){const r=e&&`${e}.`;return[{field:new ie({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 ie({label:"Maximum length",description:"Maximum number of characters",required:!1,identifier:`${r}maximum_length`,minimum:1,maximum:me,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}}}x(rt,"_validateMin",e=>(r,o)=>{const a=xr(o)?X(o,e):o;return typeof a.maximum_length=="number"&&typeof r=="number"&&a.maximum_length<r?"Minimum cannot be greater than maximum.":null}),x(rt,"_validateMax",e=>(r,o)=>{if(typeof r!="number")return null;const{minimum_length:a}=xr(o)?X(o,e):o;return typeof a!="number"?null:a>r?"Maximum cannot be less than minimum.":null});const Jt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.Input.Root,{accentColor:"base",variant:"surface",children:i.jsx(d.Input.Field,{...p,...l,type:s.inputType,id:n,placeholder:s.placeholder})})})})});Jt.displayName="StringInput";const Er={...G,type:"string",maximum_length:ze,input_type:"text"},Ne=class Ne extends rt{constructor(e){const{inputType:r="text",...o}=e,a=e.maxLength?Math.min(ze,e.maxLength):ze,s=e.minLength?Math.min(e.minLength,a):void 0;super({...o,maxLength:a,minLength:s,type:"string"});x(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 Ne({...s,maxLength:r,minLength:o,inputType:a,placeholder:"Enter a short description"})}getInput(e){return i.jsx(Jt,{field:this,...e})}};x(Ne,"fieldTypeName","Short Text"),x(Ne,"fieldTypeDescription",`Short text fields can hold up to ${ze} characters on a single line.`),x(Ne,"Icon",U.RiInputField);let it=Ne;const Zt=f.memo(t=>{const[{inputId:n,labelId:e,size:r,severity:o,showInputOnly:a,field:s,fieldProps:l},p]=z(t);let[{helpText:c,label:u}]=z(t);return c=a?null:c,u=a?"":u,i.jsx(Q,{helpText:c,severity:o,children:i.jsx(K,{size:r,severity:o,inputId:n,labelId:e,label:u,image:a?void 0:s.image,children:i.jsx(d.TextArea,{...p,...l,className:"field-sizing-content",resize:"vertical",id:n,placeholder:s.placeholder,accentColor:"base",variant:"surface"})})})});Zt.displayName="TextInput";const Sr={...G,type:"text",maximum_length:me},Te=class Te extends rt{constructor(n){const e=n.maxLength?Math.min(me,n.maxLength):me,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 Te({...o,maxLength:e,minLength:r,placeholder:"Enter a description"})}getInput(n){return i.jsx(Zt,{field:this,...n})}};x(Te,"fieldTypeName","Paragraph"),x(Te,"fieldTypeDescription",`Paragraph fields can hold up to ${me} characters and can have multiple lines.`),x(Te,"Icon",U.RiAlignJustify);let ot=Te;const Fr=f.memo(f.forwardRef((t,n)=>{const{file:e,alt:r,error:o,rightSlot:a,className:s,truncateLength:l,...p}=t,c=f.useRef(null),u=f.useRef(null),h=d.useSize(c);f.useLayoutEffect(()=>{!u.current||!h||(u.current.style.height=`${h.height*4}px`)},[h]);const v=f.useMemo(()=>{if(e)return l!==void 0?H.truncate(e.name,l):e.name},[e,l]);return i.jsxs("div",{className:pe(s,"relative flex h-max w-full flex-col gap-0 overflow-hidden rounded-md border items-center border-(--base-a6)"),ref:n,...p,children:[!e&&!o&&i.jsx("div",{className:"absolute flex h-full w-full flex-col items-center justify-center",children:i.jsx(d.Spinner,{})}),i.jsx("div",{ref:u,className:"-m-4 flex max-w-full 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:pe("flex h-max w-full items-center gap-1 bg-(--base-2) px-2 py-1",{"bg-transparent":!e}),ref:c,children:[o?i.jsx(d.RiIcon,{icon:"RiFileWarningLine"}):e&&i.jsx(Me,{fileType:e.type}),o??v,a]})]})})),Nr=f.createContext(()=>{throw new Error("No ImageViewerProvider found")}),Tr=()=>f.useContext(Nr),Rt=f.memo(t=>{const{file:n,onClose:e}=t,r=f.useRef(null),o=f.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(p=>{p&&navigator.clipboard.write([new ClipboardItem({"image/png":p})])},"image/png")},[]),a=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(Wt,{open:!0,onOpenChange:e,children:i.jsx(qt,{children:i.jsx(Ht,{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(Gt,{className:"absolute inset-0 py-12","data-floating-content":"",onOpenAutoFocus:s=>s.preventDefault(),children:[i.jsxs(d.ButtonGroup,{className:"flex gap-2 items-center top-0 absolute right-0 p-2",accentColor:"base",variant:"ghost",children:[i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:o,"aria-label":"copy to clipboard",children:i.jsx(d.RiIcon,{icon:"RiFileCopyLine"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Copy"})]}),i.jsxs(d.Tooltip.Root,{children:[i.jsx(d.Tooltip.Trigger,{children:i.jsx(d.IconButton,{onClick:a,"aria-label":"download",children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})}),i.jsx(d.Tooltip.Content,{size:"sm",children:"Download"})]}),i.jsx(d.Separator,{orientation:"vertical",size:"sm"}),i.jsx(_o,{asChild:!0,children:i.jsx(d.IconButton,{onClick:e,"aria-label":"close",children:i.jsx(d.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})})]})})})})});Rt.displayName="ImageViewer";const Lr=f.memo(t=>{const{children:n}=t,[e,r]=f.useState(null),o=f.useCallback(()=>{r(null)},[]),a=f.useCallback(p=>{r(p(o))},[o]),s=f.useCallback(()=>{e&&(e.onClose&&e.onClose(),o())},[o,e]),l=f.useMemo(()=>a,[a]);return i.jsxs(Nr.Provider,{value:l,children:[n,e&&i.jsx(Rt,{file:e.file,onClose:s})]})});Lr.displayName="FileViewerProvider";const $o=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=f.memo(t=>{var F;const[{inputId:n,labelId:e,size:r,severity:o,helpText:a,showInputOnly:s,field:l,fieldProps:p},c]=z(t),{onChange:u}=p;let[{label:h}]=z(t);h=s?"":h;const v=o?te[o]:void 0,y=f.useRef(null),{value:C}=p,m=f.useMemo(()=>s?null:a||(l.maxFileSize?`Maximum file size: ${l.maxFileSize}MB`:null),[l.maxFileSize,a,s]),b=f.useCallback(()=>{var L;(L=y.current)==null||L.click()},[]),E=f.useCallback(L=>{const T=[...C];T.splice(L,1),u({target:{files:T}})},[C,u]),I=C?"Select new files":"Select files",N=C?"Select new file":"Select a file",S=l.maxFiles>1?I:N;return i.jsxs("div",{className:"flex flex-col gap-2",children:[i.jsx(Q,{helpText:m,severity:o,children:i.jsxs(K,{size:r,severity:o,inputId:n,labelId:e,label:h,image:s?void 0:l.image,children:[i.jsx("div",{className:"flex gap-2",children:i.jsxs(d.Button,{...c,className:"w-max",variant:"soft",onClick:b,id:"upload-input-upload-button",type:"button",children:[i.jsx(d.RiIcon,{icon:"RiUpload2Line"})," ",S]})}),i.jsx("input",{...c,type:"file",ref:y,id:n,accept:(F=l.extensions)==null?void 0:F.join(","),multiple:l.maxFiles>1,color:v,style:{display:"none"},...p,value:""})]})}),Array.isArray(C)&&C.length>0&&i.jsx("div",{className:"flex h-max flex-col gap-2",children:C.map((L,T)=>i.jsx(Mr,{field:l,file:L,onRemove:()=>{E(T)},disabled:c.disabled},T))})]})});Dr.displayName="UploadInput";const Mr=f.memo(t=>{const{file:n,field:e,onRemove:r,disabled:o}=t,[a,s]=f.useState(null),l=Tr(),p=f.useMemo(()=>a&&e.getError([a]),[e,a]),{url:c,name:u}=f.useMemo(()=>{let m=null,b,E;return a!=null&&a.type.startsWith("image/")&&(m=URL.createObjectURL(a)),a?(b=a.name,E=$o(a.size)):(b="Downloading...",E="..."),{url:m,name:b,size:E}},[a]);f.useEffect(()=>{n instanceof Promise?n.then(s).catch(console.error):s(n)},[n]);const h=f.useCallback(m=>{if(m.stopPropagation(),!a)throw new Error("Cannot download a file that is not resolved.");const b=new Blob([a]);Cn.saveAs(b,u)},[u,a]),v=f.useCallback(m=>{m.stopPropagation(),r()},[r]),y=f.useCallback(()=>{a&&l(m=>({file:a,onDelete:o?void 0:()=>{r(),m()}}))},[o,r,l,a]),C=f.useMemo(()=>i.jsxs(d.ButtonGroup,{className:"flex w-full justify-end",variant:"ghost",accentColor:"base",size:"sm",children:[i.jsx(d.IconButton,{"aria-label":`Download ${u}`,onClick:h,disabled:!a,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})}),!o&&i.jsx(d.IconButton,{"aria-label":`Remove ${u}`,disabled:o,onClick:v,children:i.jsx(d.RiIcon,{icon:"RiCloseLargeLine"})})]}),[o,v,h,u,a]);return c?i.jsx(Fr,{className:"cursor-pointer",onClick:y,file:a,error:p??void 0,rightSlot:C}):i.jsx(mt,{file:a,error:p??void 0,rightSlot:C})});Mr.displayName="DisplayFile";const Vo={...G,type:"upload",extensions:[],maximum_size:void 0,maximum_files:1},Le=class Le extends j{constructor(e){const{extensions:r,maximum_files:o,maximum_size:a,...s}=e;super({...s,type:"upload"});x(this,"extensions");x(this,"maxFileSize");x(this,"maxFiles");x(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 ie({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 ie({label:"What is the maximum size of each file?",description:`Maximum file size in megabytes (between 1MB–${at}MB).`,required:!1,identifier:`${r}maximum_size`,minimum:1,maximum:at,integers:!0}),showDirectly:!1},{field:new Oe({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??at,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 Le(e)}getInput(e){return i.jsx(Dr,{field:this,...e})}};x(Le,"fieldTypeName","Upload"),x(Le,"fieldTypeDescription","Allows a file to be uploaded."),x(Le,"Icon",U.RiUpload2Line);let en=Le;const tn={date:ke,number:ie,boolean:ge,select:Be,string:it,text:ot,custom:Ue,upload:en,qr:nt,"multi-string":Ae,"multi-select":Oe},ko={date:xn,number:Ln,boolean:In,select:Ir,string:Er,text:Sr,custom:ti,upload:Vo,qr:br,"multi-string":Tn,"multi-select":Cr},at=50,Uo=at*1e3*1e3,nn=t=>{const n=t.type;return tn[n].deserialize(t)},st=t=>t.type==="section"?W.deserialize(t):nn(t);function Pr(t,n={}){const{readonly:e=!1}=n;return{title:t.title,description:t.description,fields:t.fields.map(r=>st(r)),meta:{readonly:e}}}function rn(t){const n=[];for(const e of t.fields)if(e instanceof W)for(const r of e.fields)n.push(r);else{if(!(e instanceof j))throw new Error(`Invalid field type: ${e.type}`);n.push(e)}return n}function jo(t,n){const e=rn(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 Wo(t,n){const e=rn(t),r={};for(const o of e){const a=n[o.identifier];r[o.identifier]=o.encodeValueToJson(a)}return r}function lt(t){return Array.isArray(t)&&t.some(n=>n instanceof File||n instanceof Promise)}function on(t,n){if(!t)return!0;if(lt(n)||lt(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 Ar=f.memo(t=>{const{field:n,...e}=t,{label:r,description:o,fields:a,condition:s}=n,{values:l,setFieldValue:p}=k.useFormikContext(),c=s!=null&&s.identifier?X(l,s.identifier):void 0,u=f.useMemo(()=>c===void 0||on(s,c),[s,c]);f.useEffect(()=>{if(!u)for(const v of a)p(v.getId(),"").then()},[u,a,p]);const h=Pe(a,e);return u?i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-6",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx(d.Heading,{size:"lg",children:r}),i.jsx(d.Text,{accentColor:"base",children:o})]}),h]})}):null});Ar.displayName="FieldSectionLayout";const De=class De extends gt{constructor(e){const{label:r=null,fields:o,condition:a=null,conditional:s,...l}=e;super({...l,type:"section"});x(this,"label");x(this,"fields");x(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 ge({label:"Conditionally render section",identifier:`${o}conditional`,required:!1}),showDirectly:!0},{field:new De({label:"Conditional settings",identifier:`${o}conditional-settings`,condition:{identifier:`${o}conditional`,value:!0},fields:[new Be({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 ni({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(nn);return new De({...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(X(e,a),e);s&&ht(r,o.getId(),s)}return r}getInput(e){return i.jsx(Ar,{field:this,...e})}};x(De,"fieldTypeName","Section"),x(De,"fieldTypeDescription","Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");let W=De;const ue=t=>Object.keys(t).length>0,ct=(t,n)=>{const e={};for(const r of t.fields)if(r instanceof W){if(r.condition){const{identifier:o}=r.condition;if(!on(r.condition,X(n,o)))continue}Object.assign(e,r.getErrors(n))}else{if(!(r instanceof j))throw new Error("Invalid field type");const o=r.getId(),a=r.getError(X(n,o),n);a&&ht(e,o,a)}if(ue(e))return e},qo=[null,void 0],dt=(t,n)=>t.reduce((e,r)=>r instanceof W?{...e,...dt(r.fields,n)}:(qo.includes(X(e,r.getId()))&&ht(e,r.getId(),""),e),Gr(n)),Ho=()=>{throw new Error("onSubmit must be provided if form is not readonly.")},Or=f.memo(f.forwardRef((t,n)=>{const{schema:e,values:r={},onSubmit:o=Ho,submitText:a="Submit",cancelText:s,onCancel:l,onDirty:p,onDirtyChange:c,hideTitle:u=!e.title,hideDescription:h,className:v,buttonProps:y}=t,{readonly:C}=e.meta,m=f.useMemo(()=>crypto.randomUUID(),[]),b=k.useFormik({initialValues:dt(e.fields,r),onSubmit:o,validate:F=>ct(e,F),validateOnBlur:!1,validateOnChange:!1}),{dirty:E}=b,I=f.useMemo(()=>typeof e.title=="string"?i.jsx(d.Heading,{size:"lg",children:e.title}):e.title,[e.title]),N=f.useMemo(()=>typeof e.description=="string"?i.jsx(d.Text,{accentColor:"base",children:e.description}):e.description,[e.description]),S=Pe(e.fields,{formId:m,disabled:C});return f.useEffect(()=>{E&&p&&p(),c&&c(E)},[E,p,c]),i.jsx(k.FormikProvider,{value:b,children:i.jsxs("form",{id:m,ref:n,className:pe(v,"flex flex-col gap-2"),onSubmit:b.handleSubmit,children:[!u&&i.jsx(d.Card,{children:i.jsxs("div",{className:"flex flex-col gap-1",children:[I,!h&&N]})}),S,!C&&i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s&&i.jsxs(d.Button,{accentColor:te.danger,...y,type:"button",onClick:l,children:[i.jsx(d.RiIcon,{icon:"RiCloseLine"}),s]}),i.jsxs(d.Button,{...y,type:"submit",disabled:!b.isValid,accentColor:"success",children:[i.jsx(d.RiIcon,{icon:"RiCheckLine"}),a]})]})]})})})),fe=f.memo(t=>{const{name:n,render:e}=t,{submitForm:r}=k.useFormikContext(),[o,a,s]=k.useField(n),l=f.useMemo(()=>{const p=c=>{s.setValue(c,!1)};return e({value:o.value,meta:a,setValue:p,patchValue:()=>{r()}})},[e,o.value,a,r,s]);return i.jsx(i.Fragment,{children:l})});fe.displayName="PatchField";const Go=f.memo(f.forwardRef((t,n)=>{const{children:e,schema:r,values:o,onPatch:a,onError:s,requiresDiff:l=!0,onDirtyChange:p,...c}=t,u=f.useMemo(()=>dt(r.fields,o),[r.fields,o]),h=f.useCallback(I=>{const N={};for(const S in I){const F=I[S];F!==u[S]&&F!==void 0&&(N[S]=F)}return N},[u]),v=f.useCallback(I=>{const N=h(I);l&&!ue(N)||a(N)},[h,a,l]),y=f.useCallback(I=>{const N=ct(r,I);if(N&&s(N),p){const S=h(I);p(ue(S))}return N},[r,p,s,h]),C=k.useFormik({initialValues:u,onSubmit:v,validate:y,validateOnBlur:!1,validateOnChange:!1}),m=f.useCallback(()=>{if(p){const I=h(C.values);ue(I)&&p(!0)}},[C.values,h,p]),{errors:b,resetForm:E}=C;return f.useEffect(()=>{ue(b)&&E({values:u,errors:{}})},[b,u,E]),i.jsx(k.FormikProvider,{value:C,children:i.jsx("form",{...c,ref:n,onSubmit:C.handleSubmit,onChange:m,children:e})})})),ut="form-builder",Xo=[["string","text"],["select","multi-select","upload","qr"],["boolean","date","number","multi-string"]],an={...tn,section:W},Ko=(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}},Qo=(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,p=new Set(l);(r=s.condition)!=null&&r.identifier&&p.add(s.condition.identifier),n[s.identifier]={disabled:!1,conditionFields:p,conditionIndex:Qo(t,(o=s.condition)==null?void 0:o.identifier),index:a,label:s.label}}return n},sn=f.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:p}=k.useFormikContext(),c=f.useRef(null),u=f.useMemo(()=>{const h=[{Icon:U.RiFileCopyLine,key:"duplicate",text:"Duplicate",buttonProps:{onClick:a}}];return h.push({Icon:U.RiDeleteBin2Line,key:"delete",text:"Delete",buttonProps:{onClick:o}}),e!=="section"&&h.unshift({Icon:U.RiImageLine,key:"upload",text:"Upload image",buttonProps:{onClick:()=>{var v;(v=c.current)==null||v.click()}}}),(r===void 0&&n!==p.fields.length-1||r!==void 0&&(r<p.fields.length-1||n!==p.fields[r].fields.length-1))&&h.unshift({Icon:U.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:U.RiArrowUpLine,key:"moveUp",text:"Move up",buttonProps:{onClick:()=>{s("up")}}}),h},[a,n,s,o,r,e,p.fields]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-2 hidden flex-col gap-5 sm:flex",children:u.map(h=>i.jsx(d.IconButton,{type:"button",variant:"ghost",accentColor:h.key.startsWith("move")?"base":void 0,"aria-label":h.text,...h.buttonProps,children:i.jsx(h.Icon,{})},h.key))}),i.jsx("div",{className:"sm:hidden",children:i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsx(d.IconButton,{variant:"ghost","aria-label":"Actions menu",children:i.jsx(d.RiIcon,{icon:"RiMore2Line"})})}),i.jsx(d.Menu.Content,{children:u.map(h=>{var v;return i.jsxs(d.Menu.Item,{onClick:(v=h.buttonProps)==null?void 0:v.onClick,children:[i.jsx(h.Icon,{}),h.text]},h.key)})})]})}),e!=="section"&&i.jsx("input",{style:{display:"none"},ref:c,type:"file",accept:"image/*",onChange:l})]})});sn.displayName="FieldActions";const _r=(t=()=>null)=>f.useMemo(()=>Xo.map(n=>n.map(e=>{const r=tn[e],o=r.Icon;return{children:r.fieldTypeName,icon:i.jsx(o,{}),value:e,onSelect:()=>{t(e)}}})),[t]),he=t=>t.type==="section",ln=f.memo(t=>{const{popoverInputs:n,hasError:e}=t;return i.jsxs(d.Popover.Root,{children:[i.jsx(d.Popover.Trigger,{children:i.jsxs(d.Button,{variant:"soft",size:"sm","aria-label":"settings",...e&&{color:te.danger},children:[i.jsx(d.RiIcon,{icon:"RiSettings2Line"}),i.jsx("span",{children:"Settings"})]},"settings")}),i.jsx(d.Popover.Content,{size:"sm",children:i.jsx("div",{className:"flex max-w-[240px] flex-col",children:n})})]})});ln.displayName="FieldSettingsPopover";const cn=f.memo(t=>{var ft,fn,jr,Wr,qr;const{parentPath:n,index:e,initial:r,conditionalSourceFields:o}=t,{values:a,setFieldValue:s,errors:l}=k.useFormikContext(),p=_r(),c=f.useRef(null),u=576,[h,v]=f.useState(c.current&&c.current.getBoundingClientRect().width>=u);f.useEffect(()=>{const D=c.current;if(D){const O=new ResizeObserver(q=>{q[0]&&v(q[0].contentRect.width>=u)});return O.observe(D),()=>{O.disconnect()}}},[]);const[y,C]=f.useState(void 0),[m,b]=f.useState(!1);f.useEffect(()=>{he(r)?C(void 0):r.image instanceof Promise?r.image.then(C).catch(console.error):C(r.image)},[r]);const E=y?URL.createObjectURL(y):void 0,I=f.useCallback(D=>{D.stopPropagation();const{image:O,...q}=r;s(`${n}.${e}`,q).then()},[e,r,n,s]);f.useEffect(()=>{he(r)&&!r.conditional&&s(`${n}.${e}.condition`,null).then()},[e,r,n,s]);const N=f.useMemo(()=>{var D,O;return he(r)?(O=Fn(a.fields,(D=r.condition)==null?void 0:D.identifier))==null?void 0:O.label:void 0},[r,a.fields]),S=he(r)?Array.isArray((ft=r.condition)==null?void 0:ft.value)?"contains all of":"equals":void 0;let F;if(he(r)){if(lt((fn=r.condition)==null?void 0:fn.value))throw new Error("File values are not supported for conditions.");F=Array.isArray((jr=r.condition)==null?void 0:jr.value)?r.condition.value.map(D=>typeof D=="string"?D:D.label).join(", "):(qr=(Wr=r.condition)==null?void 0:Wr.value)==null?void 0:qr.toString()}const L=f.useCallback(D=>{D.target.parentNode instanceof HTMLElement&&(D.target.parentNode.dataset.replicatedValue=D.target.value)},[]),T=f.useCallback(D=>{D.target.parentNode instanceof HTMLElement&&(D.target.parentNode.dataset.replicatedValue=D.target.value)},[]),P=r.type,A=an[P],[$,M]=f.useMemo(()=>{let D=[],O=[];if(A===W){if(o===void 0)throw new Error("Conditional source fields must be provided when changing sections.");const q=A.getFieldCreationSchema(o,`${n}.${e}`);D=D.concat(q.filter(V=>V.showDirectly).map(V=>V.field)),O=O.concat(q.filter(V=>!V.showDirectly).map(V=>V.field))}else{if(!(A.prototype instanceof j))throw new Error(`Field must be an instance of BaseField. Got ${A.toString()}.`);const q=A.getFieldCreationSchema(`${n}.${e}`);h?(D=[...D,...q.filter(V=>V.showDirectly).map(V=>V.field)],O=[...O,...q.filter(V=>!V.showDirectly).map(V=>V.field)]):O=[...O,...q.map(V=>V.field)]}return[D,O]},[A,o,n,e,h]),B=Pe($,{formId:ut,disabled:!1,internal:!0,...A===W&&{size:"sm"}}),_=Pe(M,{formId:ut,disabled:!1});let ee=M.length>0;he(r)&&M.length>0&&(ee=r.conditional);const se=M.some(D=>{const O=X(l,A===W?`${n}.${e}.condition`:D.getId());return O&&(typeof O!="object"||ue(O))}),_e=se?te.danger:void 0,dn=f.useMemo(()=>st(r),[r]),un=Ct(dn,{formId:ut,showInputOnly:!1}),J=f.useMemo(()=>p.flat().find(D=>D.value===P),[p,P]);return i.jsx("div",{className:"flex grow items-center w-full",ref:c,children:i.jsxs("div",{className:"flex w-full flex-col gap-4",children:[A===W&&i.jsxs("div",{className:"flex flex-col gap-2",children:[$.length>0&&B,i.jsxs("div",{className:"flex items-center gap-4",children:[ee&&i.jsx(ln,{popoverInputs:_,hasError:se}),he(r)&&r.conditional&&i.jsx("span",{className:"text-sm text-(--accent-a11)","data-accent-color":_e,children:i.jsxs("em",{children:["Display only if ",i.jsx("strong",{children:N})," ",S," ",i.jsx("strong",{children:F})]})})]})]}),A!==W&&i.jsxs("div",{className:"flex gap-2 w-full justify-between",children:[i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsxs(d.Badge,{accentColor:"base",variant:"soft",children:[J==null?void 0:J.icon,J==null?void 0:J.children]}),i.jsx(fe,{name:`${n}.${e}.required`,render:({setValue:D,value:O})=>i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.Checkbox.Root,{checked:O,onCheckedChange:D,children:i.jsx(d.Checkbox.Indicator,{children:i.jsx(d.RiIcon,{icon:"RiCheckLine"})})}),i.jsx(d.Text,{size:"sm",accentColor:"base",children:"Required"})]})})]}),ee&&i.jsx(ln,{popoverInputs:_,hasError:se})]}),y&&i.jsxs(i.Fragment,{children:[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:E,alt:y.name,onClick:()=>{b(!0)}}),i.jsx(d.IconButton,{className:"absolute top-2 right-2 hidden group-hover:not-disabled:flex",variant:"solid",accentColor:te.danger,"aria-label":"delete",onClick:I,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]}),m&&i.jsx(vt,{file:y,url:E,name:y.name,setShowPreview:b})]}),i.jsx(fe,{name:`${n}.${e}.label`,render:({setValue:D,value:O})=>i.jsx("input",{className:"bg-transparent outline-none text-base",placeholder:P==="section"?"Enter a section label (optional)":"Enter your question",value:O,onChange:q=>{D(q.target.value)},onInput:L,maxLength:200})}),i.jsx(fe,{name:`${n}.${e}.description`,render:({setValue:D,value:O})=>i.jsx("textarea",{className:"bg-transparent outline-none text-base field-sizing-content grow",placeholder:`Enter a ${P==="section"?"section":"field"} description (optional)`,value:O,onChange:q=>{D(q.target.value)},onInput:T,maxLength:1e3})}),A!==W&&$.length>0&&i.jsx("div",{className:"w-full",children:B}),A!==W&&i.jsxs(i.Fragment,{children:[i.jsx(d.Separator,{size:"full"}),i.jsxs(d.Card,{className:"flex flex-col gap-2 bg-(--accent-a2)",children:[i.jsx(d.Text,{accentColor:"base",children:"Field preview"}),i.jsx("div",{children:un})]})]})]})})});cn.displayName="FieldBuilder";const zr=f.memo(t=>{const{field:n,index:e,sectionIndex:r,remove:o}=t,{setFieldValue:a,values:s}=k.useFormikContext(),{reorderField:l}=Et(),{showError:p}=d.useToast(),c=`fields.${r}.fields`,u=f.useMemo(()=>({index:e,parentPath:c,initial:n}),[n,e,c]),h=f.useCallback(()=>{const C=n.label??"Unlabelled field",m={...n,label:C};qe(c,e+1,m,s,a)},[n,c,e,s,a]),v=f.useCallback(C=>{const m=r,b=s.fields[m];let E=r,I=C==="up"?e-1:e+1;C==="up"&&e===0?(E=r-1,I=s.fields[E].fields.length):C==="down"&&e===b.fields.length-1&&(E=r+1,I=0);const N=s.fields[E];l(b,m,e,N,E,I,a)},[r,s.fields,e,l,a]),y=f.useCallback(C=>{const{files:m}=C.target;if(!m||m.length!==1)return;const b=m.item(0);if(b){if(b.size>Uo){p({title:"File upload error",description:`The file ${b.name} exceeded the maximum file size`});return}a(`${c}.${e}`,{...n,image:b}).then()}},[n,e,c,a,p]);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:C=>i.jsx(d.Card,{ref:C.innerRef,...C.draggableProps,...C.dragHandleProps,className:"mb-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-4 w-full",children:[i.jsx(cn,{...u}),i.jsx(sn,{index:e,type:n.type,sectionIndex:r,remove:o,duplicate:h,move:v,upload:y})]})})})});zr.displayName="FieldWithActions";const $r=f.memo(t=>{var N;const{field:n,index:e,dropState:r,fieldsOnly:o}=t,a=(N=r[n.identifier])==null?void 0:N.disabled,{setFieldValue:s,values:l}=k.useFormikContext(),p=d.useAlertDialog(),{reorderSection:c}=Et(),u=f.useCallback((S,F)=>{for(const L of S){const T=F.indexOf(L);s(`fields.${T}.condition`,null).then(),s(`fields.${T}.conditional`,!1).then()}},[s]),h=f.useCallback(S=>{var T;const F=n.fields[S];if(!F)throw new Error("Could not find field to remove.");const L=[];for(const P of l.fields)((T=P.condition)==null?void 0:T.identifier)===F.identifier&&L.push(P);return{removing:F,affectedSections:L,action:()=>s(`fields.${e}.fields`,We(n.fields,S))}},[n.fields,l.fields,s,e]),v=f.useCallback(S=>{const{affectedSections:F,action:L,removing:T}=h(S),P=()=>{L().then(),u(F,l.fields)};if(F.length>0){const A=F.map($=>$.label).join(", ");p({title:"Remove condition?",description:`${T.label} is being used as a condition, deleting it will remove the condition from the ${A} section(s).`,action:"Remove",onAction:P});return}P()},[h,u,l.fields,p]),y=f.useCallback(()=>{const F=n.fields.map((B,_)=>h(_)).flatMap(B=>B.affectedSections),L=F.length?"Remove fields and conditions?":"Remove fields?",T=n.fields.length,P=F.map(B=>B.label).join(", "),A=F.length?`Deleting this section will remove the ${T} field(s) it contains and will remove the conditions from following sections: ${P}`:`Deleting this section will remove the ${T} field(s) it contains.`,$=We(l.fields,e),M=()=>s("fields",$);if(F.length>0){p({title:L,description:A,action:"Remove",onAction:()=>{M().then(()=>{u(F,$)})}});return}M().then()},[n.fields,l.fields,e,h,s,p,u]),C=f.useCallback(S=>{const F=S==="up"?e-1:e+1;c(r,n.identifier,e,F,l,s)},[e,c,r,n.identifier,l,s]),m=f.useMemo(()=>({index:e,parentPath:"fields",initial:n,conditionalSourceFields:Nn(l.fields,e)}),[n,e,l.fields]),b=f.useCallback(()=>{const S=n.label??"Untitled section",F=n.fields.map(T=>({...T,identifier:xt(null,T.label)})),L={...n,label:S,fields:F};qe("fields",e+1,L,l,s)},[n,e,l,s]),E=f.useCallback(S=>{qe(`fields.${e}.fields`,n.fields.length,ko[S],l,s)},[e,n.fields.length,l,s]),I=_r(E);return i.jsx(re.Draggable,{draggableId:n.identifier,index:e,children:S=>i.jsx(d.Card,{ref:S.innerRef,...S.draggableProps,...S.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(cn,{...m}),i.jsx(re.Droppable,{droppableId:n.identifier,type:"SECTION",isDropDisabled:a,children:F=>i.jsxs("div",{className:"flex flex-col gap-0 w-full",ref:F.innerRef,...F.droppableProps,children:[n.fields.map((L,T)=>i.jsx(zr,{field:L,index:T,sectionIndex:e,remove:()=>{v(T)}},L.identifier)),F.placeholder,i.jsxs(d.Menu.Root,{children:[i.jsx(d.Menu.ClickTrigger,{children:i.jsxs(d.Button,{type:"button",variant:"solid",children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add field"]})}),i.jsx(d.Menu.Content,{children:I.flat().map(L=>i.jsxs(d.Menu.Item,{onSelect:L.onSelect,children:[L.icon,L.children]},L.value))})]})]})})]}),!o&&i.jsx(sn,{index:e,type:n.type,remove:y,duplicate:b,move:C})]})})})});$r.displayName="FieldSectionWithActions";const Vr=(t,n)=>{for(const[e,r]of Object.entries(t))if(r.identifier===n)return[r,e]},kr=f.memo(t=>{const{fieldsOnly:n}=t,{values:e,setFieldValue:r}=k.useFormikContext(),[o,a]=f.useReducer(Ko,e.fields,Br),{reorderSection:s,reorderField:l}=Et();f.useEffect(()=>{a({type:"update",state:Br(e.fields)})},[a,e.fields]);const p=f.useCallback(h=>{h.type==="SECTION"&&a({type:"hold",fieldId:h.draggableId})},[]),c=f.useCallback(h=>{const{source:v,destination:y,type:C,reason:m,draggableId:b}=h;if(a({type:"release"}),!y||m==="CANCEL")return;if(C==="ROOT"){s(o,b,v.index,y.index,e,r);return}if(C!=="SECTION")throw new Error("Unexpected droppable type.");const[E,I]=Vr(e.fields,v.droppableId)??[],[N,S]=Vr(e.fields,y.droppableId)??[];l(E,I,v.index,N,S,y.index,r)},[e,l,r,s,o]),u=f.useCallback(h=>{ii(h+1,e,r)},[e,r]);return i.jsx(re.DragDropContext,{onDragStart:p,onDragEnd:c,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((v,y)=>i.jsxs(f.Fragment,{children:[i.jsx($r,{field:v,index:y,dropState:o,fieldsOnly:n}),!n&&y!==e.fields.length-1&&i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(y)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]})]},v.identifier)),i.jsxs(d.Button,{className:"mb-4",type:"button",variant:"soft",accentColor:"base",onClick:()=>{u(e.fields.length)},children:[i.jsx(d.RiIcon,{icon:"RiAddLine"})," Add section"]}),h.placeholder]})})})});kr.displayName="FieldsEditor";const Yo=()=>{alert("This is a form preview, your data will not be saved.")},Jo=f.memo(f.forwardRef((t,n)=>{const{onCancel:e,onSave:r,revision:o,initialTitle:a,showExplainerText:s=!0,showFormTitle:l=!0,fieldsOnly:p=!1,showTabs:c=!0,tabsListClassName:u,hydrateRevisionWithImages:h}=t,{showError:v}=d.useToast(),y=f.useCallback(I=>{const N={};I.title||(N.title="Title is required."),(!I.fields||I.fields.length===0)&&(N.fields="At least one field is required.");let S=[];for(const[L,T]of I.fields.entries()){const A=an.section.getFieldCreationSchema(Nn(I.fields,L),`fields.${L}`).map($=>$.field);S=[...S,...A];for(const[$,M]of T.fields.entries()){const _=an[M.type].getFieldCreationSchema(`fields.${L}.fields.${$}`).map(ee=>ee.field);S=[...S,..._]}}const F=ct({fields:S},I);if(F&&(N.fields=F.fields),ue(N))return v({title:"Some form settings are invalid",description:"Please check settings highlighted in red."}),N},[v]),C=f.useMemo(()=>({title:a??"",description:"",fields:[{...je(xt(null,"")),label:""}]}),[a]),m=o?h(o):void 0,b=k.useFormik({initialValues:ri(m)??C,validate:y,onSubmit:r,validateOnChange:!1,validateOnBlur:!1}),E=f.useMemo(()=>Pr(b.values),[b.values]);return i.jsx(d.Tabs.Root,{ref:n,defaultValue:"edit",children:i.jsxs("div",{className:"flex flex-col gap-2",children:[c&&i.jsxs(d.Tabs.List,{className:pe("sticky top-0 z-[2000] flex bg-(--color-background)",u),children:[i.jsx(d.Tabs.Trigger,{className:"grow",value:"edit",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiPencilLine"}),"Edit form"]})}),i.jsx(d.Tabs.Trigger,{className:"grow",value:"preview",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(d.RiIcon,{icon:"RiEyeLine"}),"Preview form"]})})]}),i.jsxs(d.Tabs.Content,{value:"edit",children:[s&&i.jsxs("span",{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:ut,onSubmit:b.handleSubmit,children:[i.jsxs(k.FormikProvider,{value:b,children:[l&&i.jsxs(i.Fragment,{children:[i.jsx(fe,{name:"title",render:({setValue:I,value:N,meta:S})=>i.jsx(yt,{severity:"danger",helpText:S.error??null,children:i.jsx(d.Input.Root,{variant:"outline",size:"lg",accentColor:S.error?te.danger:"primary",children:i.jsx(d.Input.Field,{placeholder:"Form title",value:N,onChange:F=>{I(F.target.value)},maxLength:100})})})}),i.jsx(fe,{name:"description",render:({setValue:I,value:N})=>i.jsx(d.TextArea,{className:"field-sizing-content",placeholder:"Explain the purpose of this form",value:N,onChange:S=>{I(S.target.value)},resize:"vertical",maxLength:1e3})})]}),i.jsx(kr,{fieldsOnly:p}),i.jsx("span",{"data-accent-color":te.danger,className:"text-xs text-(--accent-a11)",children:typeof b.errors.fields=="string"&&b.errors.fields})]}),i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e&&i.jsx(d.Button,{type:"button",variant:"solid",accentColor:"base",onClick:e,children:"Cancel"}),i.jsx(d.Button,{type:"submit",children:"Save form"})]})]})]}),i.jsx(d.Tabs.Content,{value:"preview",children:i.jsx(Or,{schema:E,onSubmit:Yo,hideTitle:!l})})]})})})),Zo=Object.values(H.Colors),Ro=1;async function ea(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 H.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 p=t.toDataURL("image/jpeg",Ro),c=await H.fileToBlob(p),u=new File([c],n.name,{type:"image/jpeg"});l.resolve(u)}},a.src=URL.createObjectURL(n),l}const Ur=f.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=f.useRef(null),p=f.useRef(null),[c,u]=f.useState(H.Colors.red),[h,v]=f.useState(null),[y,C]=f.useState(!1),[m,b]=f.useState(!1),E=f.useRef(null),I=d.useSize(E);f.useEffect(()=>{const _=new Image;_.onload=function(){v({width:_.naturalWidth,height:_.naturalHeight})},_.src=URL.createObjectURL(n)},[n]),f.useEffect(()=>{!m&&(I!=null&&I.width)&&I.height&&b(!0)},[I,m]);const N=f.useCallback(async()=>{a||e();const _=l.current;if(!_)return;if(!h)throw new Error("Original image size not loaded yet");const ee=await _.exportImage("png"),se=new Image(h.width,h.height);se.onload=async function(){const _e=await H.fileToBlob(ee),dn=new File([_e],n.name,{type:n.type}),un=p.current,J=await ea(un,n,dn,h);J.objectURL=URL.createObjectURL(J);const ft=await H.hashFile(n);await H.hashFile(J)!==ft&&r(J),C(!1),e()},C(!0),se.src=ee},[a,n,e,r,h]),S=f.useCallback(()=>{o(n)},[n,o]),F=f.useCallback(()=>{e()},[e]),L=f.useCallback(()=>{s(!0)},[s]),T=f.useCallback(()=>{l.current&&l.current.redo()},[]),P=f.useCallback(()=>{l.current&&l.current.undo()},[]),A=f.useCallback(()=>{l.current&&(s(!1),l.current.clearCanvas())},[s]),$=f.useCallback(_=>{l.current&&l.current.eraseMode(_)},[]),M=f.useCallback(()=>{N()},[N]),B=f.useCallback(()=>{H.downloadFile(n)},[n]);return i.jsx(Wt,{open:!0,onOpenChange:e,children:i.jsxs(qt,{children:[i.jsx(Ht,{className:"light:bg-(--black-a6) fixed inset-0 dark:bg-(--black-a8)","data-floating-content":""}),i.jsx(Gt,{className:"fixed inset-0","data-floating-content":"",children:i.jsxs(i.Fragment,{children:[h&&i.jsx("canvas",{style:{display:"none"},id:"attachment-markup-canvas",ref:p,width:h.width,height:h.height}),i.jsxs("div",{className:"relative flex h-full w-full flex-col",children:[i.jsx("div",{className:"flex h-8 w-full items-center bg-(--color-background) px-2",children:i.jsx(d.ButtonGroup,{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(d.IconButton,{"aria-label":"close",onClick:F,children:i.jsx(d.RiIcon,{icon:"RiCloseLine"})}),i.jsx(d.IconButton,{"aria-label":`Download ${n.name}`,onClick:B,children:i.jsx(d.RiIcon,{icon:"RiDownload2Line"})})]}),i.jsxs("div",{className:"flex items-center justify-center gap-2",children:[i.jsx(pt,{selectedColor:c,allColors:Zo,onFinish:u,trigger:i.jsx(d.IconButton,{"aria-label":"Markup color picker",type:"button",variant:"solid",style:{backgroundColor:c},children:" "})}),i.jsx(d.IconToggleButton,{defaultPressed:!1,"aria-label":"erase",onPressedChange:$,children:i.jsx(d.RiIcon,{icon:"RiEraserFill"})}),i.jsx(d.Separator,{orientation:"vertical",size:"full"}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:P,children:i.jsx(d.RiIcon,{icon:"RiArrowGoBackLine"})}),i.jsx(d.IconButton,{"aria-label":"undo",onClick:T,children:i.jsx(d.RiIcon,{icon:"RiArrowGoForwardLine"})}),i.jsx(d.IconButton,{"aria-label":"undo all",onClick:A,children:i.jsx(d.RiIcon,{icon:"RiLoopLeftLine"})})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(d.IconButton,{"aria-label":"Save markup",accentColor:"primary",onClick:M,children:i.jsx(d.RiIcon,{icon:"RiSaveLine"})}),i.jsx(d.IconButton,{"aria-label":"Delete attachment",onClick:S,children:i.jsx(d.RiIcon,{icon:"RiDeleteBin2Line"})})]})]})})}),i.jsxs("div",{className:"relative flex w-full grow items-center justify-center p-4",children:[i.jsx("img",{className:"translate-xmax-h-[calc(100%-130px)] pointer-events-none invisible absolute top-[50%] left-[50%] max-w-svw translate-x-[-50%] translate-y-[-50%] object-contain",alt:"Photo attachment",ref:E,src:n.objectURL}),y?i.jsx(d.Spinner,{}):i.jsx(Xr.ReactSketchCanvas,{backgroundImage:n.objectURL,ref:l,width:`${(I==null?void 0:I.width)||0}px`,height:`${(I==null?void 0:I.height)||0}px`,onStroke:L,strokeColor:c},m?"1":"0")]})]})]})})]})})});Ur.displayName="AttachmentEditor",w.BaseField=j,w.BaseFormElement=gt,w.BooleanField=ge,w.BooleanInput=bt,w.ColorPicker=pt,w.DateField=ke,w.DateInput=wt,w.FieldSection=W,w.FileBadge=yn,w.FileCard=mt,w.FileIcon=Me,w.FormBuilder=Jo,w.FormRenderer=Or,w.ImageCard=Fr,w.ImageMarkup=Ur,w.ImageViewer=Rt,w.ImageViewerProvider=Lr,w.InputWithHelpText=yt,w.InputWithLabel=K,w.InputWithLabelAndHelpText=Q,w.MultiSelectField=Oe,w.MultiSelectInput=Qt,w.MultiStringField=Ae,w.MultiStringInput=St,w.NumberField=ie,w.NumberInput=Ft,w.PatchField=fe,w.PatchFormProvider=Go,w.QrField=nt,w.QrInput=Xt,w.QrScanner=Kt,w.SUPPORTED_IMAGE_FILE_TYPES=mn,w.SUPPORTED_PDF_FILE_TYPES=vn,w.SUPPORTED_SPREADSHEET_FILE_EXTENSIONS=gn,w.SelectField=Be,w.SelectInput=Yt,w.StringField=it,w.StringInput=Jt,w.TextField=ot,w.TextInput=Zt,w.decodeFormValues=jo,w.deserialize=st,w.deserializeField=nn,w.emptyBaseField=G,w.emptyBooleanField=In,w.emptyDateField=xn,w.emptyMultiSelectField=Cr,w.emptyMultiStringField=Tn,w.emptyNumberField=Ln,w.emptyQrField=br,w.emptySelectField=Ir,w.emptyStringField=Er,w.emptyTextField=Sr,w.encodeFormValues=Wo,w.flattenFields=rn,w.formRevisionToSchema=Pr,w.initialFormValues=dt,w.isConditionMet=on,w.useFieldInput=Ct,w.useFieldInputs=Pe,w.useFormikInput=z,w.useImageViewer=Tr,w.validateForm=ct,w.valueIsFile=lt,Object.defineProperty(w,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-file-viewer-updates.0",
4
+ "version": "1.0.17-file-viewer-updates.1",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/forms.umd.cjs",
7
7
  "module": "dist/forms.js",