@middag-io/react 0.31.2 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { C as e, D as t, E as n, F as r, G as i, H as a, J as o, K as s, L as c, St as l, T as u, V as d, W as f, Y as p, _ as m, a as h, bt as g, c as _, d as v, dt as y, f as b, ft as x, g as S, gt as C, h as w, ht as T, i as E, k as D, l as O, m as k, mt as A, n as j, o as ee, p as te, pt as ne, q as re, r as ie, s as ae, t as M, u as oe, v as se, vt as N, w as ce, xt as le, y as ue, z as de } from "./resolve-field-error-dbUy6DeX.js";
2
- import { t as fe } from "./button-Bm0X9WO5.js";
3
- import { t as pe } from "./useTranslation-BuyMWJ9T.js";
4
- import { t as me } from "./utils-CpaZ5_iF.js";
5
- import { t as he } from "./skeleton-xL_Hzxj-.js";
6
- import P, { Suspense as ge, lazy as _e, useCallback as ve, useEffect as ye, useId as be, useMemo as F, useRef as xe, useState as Se } from "react";
1
+ import { $ as e, A as t, D as n, Dt as r, E as i, Et as a, Ft as o, J as s, K as c, Nt as l, O as u, Ot as d, Pt as f, T as p, Tt as m, U as h, V as g, Y as _, Z as v, _ as y, a as b, at as x, b as S, c as C, d as ee, et as w, f as T, g as E, h as D, i as O, jt as k, kt as A, l as te, m as ne, n as re, nt as ie, o as ae, p as oe, r as se, t as j, tt as ce, u as le, v as ue, w as de, wt as fe, y as pe } from "./resolve-field-error-DLX1h_6J.js";
2
+ import { t as me } from "./button-Bm0X9WO5.js";
3
+ import { t as he } from "./useTranslation-BuyMWJ9T.js";
4
+ import { t as ge } from "./utils-CpaZ5_iF.js";
5
+ import { t as _e } from "./skeleton-xL_Hzxj-.js";
6
+ import M, { Suspense as N, lazy as P, useCallback as ve, useEffect as ye, useId as be, useMemo as F, useRef as xe, useState as Se } from "react";
7
7
  import { router as Ce } from "@inertiajs/core";
8
8
  import { Fragment as we, jsx as I, jsxs as L } from "react/jsx-runtime";
9
9
  //#region node_modules/react-hook-form/dist/index.esm.mjs
@@ -57,16 +57,16 @@ var je = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Me = (e) => Array.isAr
57
57
  pattern: "pattern",
58
58
  required: "required",
59
59
  validate: "validate"
60
- }, Fe = "form", Ie = "root", Le = P.createContext(null);
60
+ }, Fe = "form", Ie = "root", Le = M.createContext(null);
61
61
  Le.displayName = "HookFormControlContext";
62
- var Re = () => P.useContext(Le), ze = (e, t, n, r = !0) => {
62
+ var Re = () => M.useContext(Le), ze = (e, t, n, r = !0) => {
63
63
  let i = {};
64
64
  for (let a in e) Object.defineProperty(i, a, { get: () => {
65
65
  let i = a;
66
66
  return t._proxyFormState[i] !== q.all && (t._proxyFormState[i] = !r || q.all), n && (n[i] = !0), e[i];
67
67
  } });
68
68
  return i;
69
- }, Be = typeof window < "u" ? P.useLayoutEffect : P.useEffect, Y = (e) => typeof e == "string", Ve = (e, t, n, r, i) => Y(e) ? (r && t.watch.add(e), U(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), U(n, e))) : (r && (t.watchAll = !0), n), He = (e) => z(e) || !Ee(e);
69
+ }, Be = typeof window < "u" ? M.useLayoutEffect : M.useEffect, Y = (e) => typeof e == "string", Ve = (e, t, n, r, i) => Y(e) ? (r && t.watch.add(e), U(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), U(n, e))) : (r && (t.watchAll = !0), n), He = (e) => z(e) || !Ee(e);
70
70
  function X(e, t, n = /* @__PURE__ */ new WeakSet()) {
71
71
  if (e === t) return !0;
72
72
  if (He(e) || He(t)) return Object.is(e, t);
@@ -86,19 +86,19 @@ function X(e, t, n = /* @__PURE__ */ new WeakSet()) {
86
86
  return !0;
87
87
  }
88
88
  function Ue(e) {
89
- let t = Re(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = P.useRef(i), l = P.useRef(s), u = P.useRef(void 0), d = P.useRef(n), f = P.useRef(r);
89
+ let t = Re(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = M.useRef(i), l = M.useRef(s), u = M.useRef(void 0), d = M.useRef(n), f = M.useRef(r);
90
90
  l.current = s;
91
- let [p, m] = P.useState(() => {
91
+ let [p, m] = M.useState(() => {
92
92
  let e = n._getWatch(r, c.current);
93
93
  return l.current ? l.current(e) : e;
94
- }), h = P.useCallback((e) => {
94
+ }), h = M.useCallback((e) => {
95
95
  let t = Ve(r, n._names, e || n._formValues, !1, c.current);
96
96
  return l.current ? l.current(t) : t;
97
97
  }, [
98
98
  n._formValues,
99
99
  n._names,
100
100
  r
101
- ]), g = P.useCallback((e) => {
101
+ ]), g = M.useCallback((e) => {
102
102
  if (!a) {
103
103
  let t = Ve(r, n._names, e || n._formValues, !1, c.current);
104
104
  if (l.current) {
@@ -124,8 +124,8 @@ function Ue(e) {
124
124
  o,
125
125
  r,
126
126
  g
127
- ]), P.useEffect(() => n._removeUnmounted());
128
- let _ = d.current !== n, v = f.current, y = P.useMemo(() => {
127
+ ]), M.useEffect(() => n._removeUnmounted());
128
+ let _ = d.current !== n, v = f.current, y = M.useMemo(() => {
129
129
  if (a) return null;
130
130
  let e = !_ && !X(v, r);
131
131
  return _ || e ? h() : null;
@@ -138,7 +138,7 @@ function Ue(e) {
138
138
  ]);
139
139
  return y === null ? p : y;
140
140
  }
141
- var We = P.createContext(null);
141
+ var We = M.createContext(null);
142
142
  We.displayName = "HookFormContext";
143
143
  var Ge = (e, t, n, r, i) => t ? {
144
144
  ...n[e],
@@ -349,16 +349,16 @@ var $ = (e) => B(e) && !gt(e) ? e : {
349
349
  if (!_ || t.has(h)) return {};
350
350
  let y = s ? s[0] : o, b = (e) => {
351
351
  i && y.reportValidity && (y.setCustomValidity(W(e) ? "" : e || ""), y.reportValidity());
352
- }, x = {}, S = Qe(o), C = Te(o), w = S || C, T = (g || Ye(o)) && H(o.value) && H(v) || Xe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), E = Ge.bind(null, h, r, x), D = (e, t, n, r = J.maxLength, i = J.minLength) => {
352
+ }, x = {}, S = Qe(o), C = Te(o), ee = S || C, w = (g || Ye(o)) && H(o.value) && H(v) || Xe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), T = Ge.bind(null, h, r, x), E = (e, t, n, r = J.maxLength, i = J.minLength) => {
353
353
  let a = e ? t : n;
354
354
  x[h] = {
355
355
  type: e ? r : i,
356
356
  message: a,
357
357
  ref: o,
358
- ...E(e ? r : i, a)
358
+ ...T(e ? r : i, a)
359
359
  };
360
360
  };
361
- if (a ? !Array.isArray(v) || !v.length : c && (!w && (T || z(v)) || W(v) && !v || C && !ut(s).isValid || S && !pt(s).isValid)) {
361
+ if (a ? !Array.isArray(v) || !v.length : c && (!ee && (w || z(v)) || W(v) && !v || C && !ut(s).isValid || S && !pt(s).isValid)) {
362
362
  let { value: e, message: t } = Y(c) ? {
363
363
  value: !!c,
364
364
  message: c
@@ -367,10 +367,10 @@ var $ = (e) => B(e) && !gt(e) ? e : {
367
367
  type: J.required,
368
368
  message: t,
369
369
  ref: y,
370
- ...E(J.required, t)
370
+ ...T(J.required, t)
371
371
  }, !r)) return b(t), x;
372
372
  }
373
- if (!T && (!z(d) || !z(f))) {
373
+ if (!w && (!z(d) || !z(f))) {
374
374
  let e, t, n = $(f), i = $(d);
375
375
  if (!z(v) && !isNaN(v)) {
376
376
  let r = o.valueAsNumber || v && +v;
@@ -379,19 +379,19 @@ var $ = (e) => B(e) && !gt(e) ? e : {
379
379
  let r = o.valueAsDate || new Date(v), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
380
380
  Y(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), Y(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
381
381
  }
382
- if ((e || t) && (D(!!e, n.message, i.message, J.max, J.min), !r)) return b(x[h].message), x;
382
+ if ((e || t) && (E(!!e, n.message, i.message, J.max, J.min), !r)) return b(x[h].message), x;
383
383
  }
384
- if ((l || u) && !T && (Y(v) || a && Array.isArray(v))) {
384
+ if ((l || u) && !w && (Y(v) || a && Array.isArray(v))) {
385
385
  let e = $(l), t = $(u), n = !z(e.value) && v.length > +e.value, i = !z(t.value) && v.length < +t.value;
386
- if ((n || i) && (D(n, e.message, t.message), !r)) return b(x[h].message), x;
386
+ if ((n || i) && (E(n, e.message, t.message), !r)) return b(x[h].message), x;
387
387
  }
388
- if (p && !T && Y(v)) {
388
+ if (p && !w && Y(v)) {
389
389
  let { value: e, message: t } = $(p);
390
390
  if (gt(e) && !v.match(e) && (x[h] = {
391
391
  type: J.pattern,
392
392
  message: t,
393
393
  ref: o,
394
- ...E(J.pattern, t)
394
+ ...T(J.pattern, t)
395
395
  }, !r)) return b(t), x;
396
396
  }
397
397
  if (m) {
@@ -399,7 +399,7 @@ var $ = (e) => B(e) && !gt(e) ? e : {
399
399
  let e = At(await m(v, n), y);
400
400
  if (e && (x[h] = {
401
401
  ...e,
402
- ...E(J.validate, e.message)
402
+ ...T(J.validate, e.message)
403
403
  }, !r)) return b(e.message), x;
404
404
  } else if (B(m)) {
405
405
  let e = {};
@@ -408,7 +408,7 @@ var $ = (e) => B(e) && !gt(e) ? e : {
408
408
  let i = At(await m[t](v, n), y, t);
409
409
  i && (e = {
410
410
  ...i,
411
- ...E(t, i.message)
411
+ ...T(t, i.message)
412
412
  }, b(i.message), r && (x[h] = e));
413
413
  }
414
414
  if (!Z(e) && (x[h] = {
@@ -472,7 +472,7 @@ function Pt(e = {}) {
472
472
  }, g = async (e) => {
473
473
  if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
474
474
  let e;
475
- t.resolver ? (e = Z((await T()).errors), _()) : e = await O({
475
+ t.resolver ? (e = Z((await w()).errors), _()) : e = await D({
476
476
  fields: r,
477
477
  onlyCheckValid: !0,
478
478
  eventType: Pe.VALID
@@ -503,7 +503,7 @@ function Pt(e = {}) {
503
503
  }
504
504
  (d.dirtyFields || f.dirtyFields) && v(), p.state.next({
505
505
  name: e,
506
- isDirty: A(e, i),
506
+ isDirty: k(e, i),
507
507
  dirtyFields: n.dirtyFields,
508
508
  errors: n.errors,
509
509
  isValid: n.isValid
@@ -520,13 +520,13 @@ function Pt(e = {}) {
520
520
  let l = U(r, e);
521
521
  if (l) {
522
522
  let r = H(U(a, e)), u = U(a, e, H(s) ? U(i, e) : s);
523
- H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : mt(l._f)) : te(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (A() || (n.isDirty = !1, p.state.next({ ...n }))));
523
+ H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : mt(l._f)) : ne(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (k() || (n.isDirty = !1, p.state.next({ ...n }))));
524
524
  }
525
525
  }, C = (e, r, a, o, s) => {
526
526
  let c = !1, l = !1, u = { name: e };
527
527
  if (!t.disabled) {
528
528
  if (!a || o) {
529
- (d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = A(), c = l !== u.isDirty);
529
+ (d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = k(), c = l !== u.isDirty);
530
530
  let t = X(U(i, e), r);
531
531
  l = !!U(n.dirtyFields, e), t ? Q(n.dirtyFields, e) : K(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
532
532
  }
@@ -537,7 +537,7 @@ function Pt(e = {}) {
537
537
  c && s && p.state.next(u);
538
538
  }
539
539
  return c ? u : {};
540
- }, w = (e, r, i, a) => {
540
+ }, ee = (e, r, i, a) => {
541
541
  let o = U(n.errors, e), s = (d.isValid || f.isValid) && W(r) && n.isValid !== r;
542
542
  if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) : Q(n.errors, e)), (i ? !X(o, i) : o) || !Z(a) || s) {
543
543
  let t = {
@@ -551,15 +551,15 @@ function Pt(e = {}) {
551
551
  ...t
552
552
  }, p.state.next(t);
553
553
  }
554
- }, T = async (e) => (_(e, !0), await t.resolver(a, t.context, ht(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), E = async (e) => {
555
- let { errors: t } = await T(e);
554
+ }, w = async (e) => (_(e, !0), await t.resolver(a, t.context, ht(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), T = async (e) => {
555
+ let { errors: t } = await w(e);
556
556
  if (_(e), e) for (let r of e) {
557
557
  let e = U(t, r);
558
558
  e ? K(n.errors, r, e) : Q(n.errors, r);
559
559
  }
560
560
  else n.errors = t;
561
561
  return t;
562
- }, D = async ({ name: t, eventType: r }) => {
562
+ }, E = async ({ name: t, eventType: r }) => {
563
563
  if (e.validate) {
564
564
  let i = await e.validate({
565
565
  formValues: a,
@@ -567,22 +567,22 @@ function Pt(e = {}) {
567
567
  name: t,
568
568
  eventType: r
569
569
  });
570
- if (B(i)) for (let e in i) i[e] && le(`${Fe}.${e}`, {
570
+ if (B(i)) for (let e in i) i[e] && de(`${Fe}.${e}`, {
571
571
  message: Y(i.message) ? i.message : "",
572
572
  type: J.validate
573
573
  });
574
- else Y(i) || !i ? le(Fe, {
574
+ else Y(i) || !i ? de(Fe, {
575
575
  message: i || "",
576
576
  type: J.validate
577
- }) : ce(Fe);
577
+ }) : ue(Fe);
578
578
  return i;
579
579
  }
580
580
  return !0;
581
- }, O = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
581
+ }, D = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
582
582
  valid: !0,
583
583
  runRootValidation: !1
584
584
  } }) => {
585
- if (e.validate && (l.runRootValidation = !0, !await D({
585
+ if (e.validate && (l.runRootValidation = !0, !await E({
586
586
  name: o,
587
587
  eventType: c
588
588
  }) && (l.valid = !1, i))) return l.valid;
@@ -596,7 +596,7 @@ function Pt(e = {}) {
596
596
  let f = await jt(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
597
597
  if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ? kt(n.errors, f, r.name) : K(n.errors, r.name, f[r.name]) : Q(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
598
598
  }
599
- !Z(f) && await O({
599
+ !Z(f) && await D({
600
600
  context: l,
601
601
  onlyCheckValid: i,
602
602
  fields: f,
@@ -606,13 +606,13 @@ function Pt(e = {}) {
606
606
  }
607
607
  }
608
608
  return l.valid;
609
- }, k = () => {
609
+ }, O = () => {
610
610
  for (let e of s.unMount) {
611
611
  let t = U(r, e);
612
- t && (t._f.refs ? t._f.refs.every((e) => !et(e)) : !et(t._f.ref)) && pe(e);
612
+ t && (t._f.refs ? t._f.refs.every((e) => !et(e)) : !et(t._f.ref)) && he(e);
613
613
  }
614
614
  s.unMount = /* @__PURE__ */ new Set();
615
- }, A = (e, n) => !t.disabled && (e && n && K(a, e, n), !X(se(), i)), j = (e, t, n) => Ve(e, s, { ...o.mount ? a : H(t) ? i : Y(e) ? { [e]: t } : t }, n, t), ee = (e) => Me(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), te = (e, t, n = {}) => {
615
+ }, k = (e, n) => !t.disabled && (e && n && K(a, e, n), !X(ce(), i)), A = (e, t, n) => Ve(e, s, { ...o.mount ? a : H(t) ? i : Y(e) ? { [e]: t } : t }, n, t), te = (e) => Me(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), ne = (e, t, n = {}) => {
616
616
  let i = U(r, e), o = t;
617
617
  if (i) {
618
618
  let n = i._f;
@@ -623,14 +623,14 @@ function Pt(e = {}) {
623
623
  values: V(a)
624
624
  })));
625
625
  }
626
- (n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && oe(e);
627
- }, ne = (e, t, n) => {
626
+ (n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && j(e);
627
+ }, re = (e, t, n) => {
628
628
  for (let i in t) {
629
629
  if (!t.hasOwnProperty(i)) return;
630
630
  let a = t[i], o = e + "." + i, c = U(r, o);
631
- (s.array.has(e) || B(a) || c && !c._f) && !R(a) ? ne(o, a, n) : te(o, a, n);
631
+ (s.array.has(e) || B(a) || c && !c._f) && !R(a) ? re(o, a, n) : ne(o, a, n);
632
632
  }
633
- }, re = (e, t, i = {}) => {
633
+ }, ie = (e, t, i = {}) => {
634
634
  let c = U(r, e), l = s.array.has(e), u = V(t), m = X(U(a, e), u);
635
635
  if (K(a, e, u), l) p.array.next({
636
636
  name: e,
@@ -638,11 +638,11 @@ function Pt(e = {}) {
638
638
  }), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
639
639
  name: e,
640
640
  dirtyFields: n.dirtyFields,
641
- isDirty: A(e, u)
641
+ isDirty: k(e, u)
642
642
  }));
643
643
  else {
644
644
  let t = Array.isArray(u) && !u.length || Z(u);
645
- !c || c._f || z(u) || t ? te(e, u, i) : ne(e, u, i);
645
+ !c || c._f || z(u) || t ? ne(e, u, i) : re(e, u, i);
646
646
  }
647
647
  if (!m) {
648
648
  let t = St(e, s);
@@ -652,7 +652,7 @@ function Pt(e = {}) {
652
652
  values: V(a)
653
653
  });
654
654
  }
655
- }, ie = (e) => {
655
+ }, ae = (e) => {
656
656
  let t = G(e) ? e(a) : e;
657
657
  X(a, t) || (a = {
658
658
  ...a,
@@ -661,54 +661,54 @@ function Pt(e = {}) {
661
661
  ...n,
662
662
  values: a
663
663
  }));
664
- }, ae = async (i) => {
664
+ }, oe = async (i) => {
665
665
  o.mount = !0;
666
666
  let l = i.target, u = l.name, h = !0, v = U(r, u), y = (e) => {
667
667
  h = Number.isNaN(e) || R(e) && isNaN(e.getTime()) || X(e, U(a, u, e));
668
668
  }, b = vt(t.mode), x = vt(t.reValidateMode);
669
669
  if (v) {
670
- let o, S, E = l.type ? mt(v._f) : De(i), k = i.type === Pe.BLUR || i.type === Pe.FOCUS_OUT, A = !xt(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || Dt(k, U(n.touchedFields, u), n.isSubmitted, x, b), j = St(u, s, k);
671
- K(a, u, E), k ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
672
- let ee = C(u, E, k), te = !Z(ee) || j;
673
- if (!k && p.state.next({
670
+ let o, S, T = l.type ? mt(v._f) : De(i), O = i.type === Pe.BLUR || i.type === Pe.FOCUS_OUT, k = !xt(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || Dt(O, U(n.touchedFields, u), n.isSubmitted, x, b), A = St(u, s, O);
671
+ K(a, u, T), O ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
672
+ let te = C(u, T, O), ne = !Z(te) || A;
673
+ if (!O && p.state.next({
674
674
  name: u,
675
675
  type: i.type,
676
676
  values: V(a)
677
- }), A) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? k && g() : k || g()), te && p.state.next({
677
+ }), k) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? O && g() : O || g()), ne && p.state.next({
678
678
  name: u,
679
- ...j ? {} : ee
679
+ ...A ? {} : te
680
680
  });
681
- if (!t.resolver && e.validate && await D({
681
+ if (!t.resolver && e.validate && await E({
682
682
  name: u,
683
683
  eventType: i.type
684
- }), !k && j && p.state.next({ ...n }), t.resolver) {
685
- let { errors: e } = await T([u]);
686
- if (_([u]), y(E), h) {
684
+ }), !O && A && p.state.next({ ...n }), t.resolver) {
685
+ let { errors: e } = await w([u]);
686
+ if (_([u]), y(T), h) {
687
687
  let t = wt(n.errors, r, u), i = wt(e, r, t.name || u);
688
688
  o = i.error, u = i.name, S = Z(e);
689
689
  }
690
- } else _([u], !0), o = (await jt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(E), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await O({
690
+ } else _([u], !0), o = (await jt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(T), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await D({
691
691
  fields: r,
692
692
  onlyCheckValid: !0,
693
693
  name: u,
694
694
  eventType: i.type
695
695
  })));
696
- h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && oe(v._f.deps), w(u, S, o, ee));
696
+ h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && j(v._f.deps), ee(u, S, o, te));
697
697
  }
698
- }, M = (e, t) => {
698
+ }, se = (e, t) => {
699
699
  if (U(n.errors, t) && e.focus) return e.focus(), 1;
700
- }, oe = async (e, i = {}) => {
700
+ }, j = async (e, i = {}) => {
701
701
  let a, o, c = Ke(e);
702
702
  if (t.resolver) {
703
- let t = await E(H(e) ? e : c);
703
+ let t = await T(H(e) ? e : c);
704
704
  a = Z(t), o = e ? !c.some((e) => U(t, e)) : a;
705
705
  } else e ? (o = (await Promise.all(c.map(async (e) => {
706
706
  let t = U(r, e);
707
- return await O({
707
+ return await D({
708
708
  fields: t && t._f ? { [e]: t } : t,
709
709
  eventType: Pe.TRIGGER
710
710
  });
711
- }))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await O({
711
+ }))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await D({
712
712
  fields: r,
713
713
  name: e,
714
714
  eventType: Pe.TRIGGER
@@ -717,17 +717,17 @@ function Pt(e = {}) {
717
717
  ...!Y(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
718
718
  ...t.resolver || !e ? { isValid: a } : {},
719
719
  errors: n.errors
720
- }), i.shouldFocus && !o && Ct(r, M, e ? c : s.mount), o;
721
- }, se = (e, t) => {
720
+ }), i.shouldFocus && !o && Ct(r, se, e ? c : s.mount), o;
721
+ }, ce = (e, t) => {
722
722
  let r = { ...o.mount ? a : i };
723
723
  return t && (r = Je(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), H(e) ? r : Y(e) ? U(r, e) : e.map((e) => U(r, e));
724
- }, N = (e, t) => ({
724
+ }, le = (e, t) => ({
725
725
  invalid: !!U((t || n).errors, e),
726
726
  isDirty: !!U((t || n).dirtyFields, e),
727
727
  error: U((t || n).errors, e),
728
728
  isValidating: !!U(n.validatingFields, e),
729
729
  isTouched: !!U((t || n).touchedFields, e)
730
- }), ce = (e) => {
730
+ }), ue = (e) => {
731
731
  let t = e ? Ke(e) : void 0;
732
732
  t?.forEach((e) => Q(n.errors, e)), t ? t.forEach((e) => {
733
733
  p.state.next({
@@ -735,7 +735,7 @@ function Pt(e = {}) {
735
735
  errors: n.errors
736
736
  });
737
737
  }) : p.state.next({ errors: {} });
738
- }, le = (e, t, i) => {
738
+ }, de = (e, t, i) => {
739
739
  let a = (U(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = U(n.errors, e) || {};
740
740
  K(n.errors, e, {
741
741
  ...l,
@@ -746,7 +746,7 @@ function Pt(e = {}) {
746
746
  errors: n.errors,
747
747
  isValid: !1
748
748
  }), i && i.shouldFocus && a && a.focus && a.focus();
749
- }, ue = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || j(void 0, t), n) }) : j(e, t, !0), de = (e) => p.state.subscribe({ next: (t) => {
749
+ }, fe = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || A(void 0, t), n) }) : A(e, t, !0), pe = (e) => p.state.subscribe({ next: (t) => {
750
750
  if (Et(e.name, t.name, e.exact) && Tt(t, e.formState || d, xe, e.reRenderRoot)) {
751
751
  let r = { ...a };
752
752
  e.callback({
@@ -756,27 +756,27 @@ function Pt(e = {}) {
756
756
  defaultValues: i
757
757
  });
758
758
  }
759
- } }).unsubscribe, fe = (e) => (o.mount = !0, f = {
759
+ } }).unsubscribe, me = (e) => (o.mount = !0, f = {
760
760
  ...f,
761
761
  ...e.formState
762
- }, de({
762
+ }, pe({
763
763
  ...e,
764
764
  formState: {
765
765
  ...u,
766
766
  ...e.formState
767
767
  }
768
- })), pe = (e, o = {}) => {
768
+ })), he = (e, o = {}) => {
769
769
  for (let c of e ? Ke(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || (Q(r, c), Q(a, c)), !o.keepError && Q(n.errors, c), !o.keepDirty && Q(n.dirtyFields, c), !o.keepTouched && Q(n.touchedFields, c), !o.keepIsValidating && Q(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && Q(i, c);
770
770
  p.state.next({ values: V(a) }), p.state.next({
771
771
  ...n,
772
- ...o.keepDirty ? { isDirty: A() } : {}
772
+ ...o.keepDirty ? { isDirty: k() } : {}
773
773
  }), !o.keepIsValid && g();
774
- }, me = ({ disabled: e, name: t }) => {
774
+ }, ge = ({ disabled: e, name: t }) => {
775
775
  if (W(e) && o.mount || e || s.disabled.has(t)) {
776
776
  let n = s.disabled.has(t) !== !!e;
777
777
  e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
778
778
  }
779
- }, he = (e, n = {}) => {
779
+ }, _e = (e, n = {}) => {
780
780
  let a = U(r, e), c = W(n.disabled) || W(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
781
781
  return K(r, e, {
782
782
  ...a || {},
@@ -786,7 +786,7 @@ function Pt(e = {}) {
786
786
  mount: !0,
787
787
  ...n
788
788
  }
789
- }), s.mount.add(e), a && !l ? me({
789
+ }), s.mount.add(e), a && !l ? ge({
790
790
  disabled: W(n.disabled) ? n.disabled : t.disabled,
791
791
  name: e
792
792
  }) : S(e, !0, n.value), {
@@ -800,11 +800,11 @@ function Pt(e = {}) {
800
800
  pattern: _t(n.pattern)
801
801
  } : {},
802
802
  name: e,
803
- onChange: ae,
804
- onBlur: ae,
803
+ onChange: oe,
804
+ onBlur: oe,
805
805
  ref: (c) => {
806
806
  if (c) {
807
- s.registerName.add(e), he(e, n), s.registerName.delete(e), a = U(r, e);
807
+ s.registerName.add(e), _e(e, n), s.registerName.delete(e), a = U(r, e);
808
808
  let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = $e(t), l = a._f.refs || [];
809
809
  if (o ? l.find((e) => e === t) : t === a._f.ref) return;
810
810
  K(r, e, { _f: {
@@ -824,21 +824,21 @@ function Pt(e = {}) {
824
824
  } else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(Oe(s.array, e) && o.action) && s.unMount.add(e);
825
825
  }
826
826
  };
827
- }, P = () => t.shouldFocusError && Ct(r, M, s.mount), ge = (e) => {
827
+ }, M = () => t.shouldFocusError && Ct(r, se, s.mount), N = (e) => {
828
828
  W(e) && (p.state.next({ disabled: e }), Ct(r, (t, n) => {
829
829
  let i = U(r, n);
830
830
  i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
831
831
  t.disabled = i._f.disabled || e;
832
832
  }));
833
833
  }, 0, !1));
834
- }, _e = (e, i) => async (o) => {
834
+ }, P = (e, i) => async (o) => {
835
835
  let c;
836
836
  o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
837
837
  let l = V(a);
838
838
  if (p.state.next({ isSubmitting: !0 }), t.resolver) {
839
- let { errors: e, values: t } = await T();
839
+ let { errors: e, values: t } = await w();
840
840
  _(), n.errors = e, l = V(t);
841
- } else await O({
841
+ } else await D({
842
842
  fields: r,
843
843
  eventType: Pe.SUBMIT
844
844
  });
@@ -850,7 +850,7 @@ function Pt(e = {}) {
850
850
  } catch (e) {
851
851
  c = e;
852
852
  }
853
- } else i && await i({ ...n.errors }, o), P(), setTimeout(P);
853
+ } else i && await i({ ...n.errors }, o), M(), setTimeout(M);
854
854
  if (p.state.next({
855
855
  isSubmitted: !0,
856
856
  isSubmitting: !1,
@@ -859,7 +859,7 @@ function Pt(e = {}) {
859
859
  errors: n.errors
860
860
  }), c) throw c;
861
861
  }, ve = (e, t = {}) => {
862
- U(r, e) && (H(t.defaultValue) ? re(e, V(U(i, e))) : (re(e, t.defaultValue), K(i, e, V(t.defaultValue))), t.keepTouched || Q(n.touchedFields, e), t.keepDirty || (Q(n.dirtyFields, e), n.isDirty = t.defaultValue ? A(e, V(U(i, e))) : A()), t.keepError || (Q(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
862
+ U(r, e) && (H(t.defaultValue) ? ie(e, V(U(i, e))) : (ie(e, t.defaultValue), K(i, e, V(t.defaultValue))), t.keepTouched || Q(n.touchedFields, e), t.keepDirty || (Q(n.dirtyFields, e), n.isDirty = t.defaultValue ? k(e, V(U(i, e))) : k()), t.keepError || (Q(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
863
863
  }, ye = (e, c = {}) => {
864
864
  let l = e ? V(e) : i, u = V(l), f = Z(e), m = f ? i : u;
865
865
  if (c.keepDefaultValues || (i = l), !c.keepValues) {
@@ -867,7 +867,7 @@ function Pt(e = {}) {
867
867
  let e = new Set([...s.mount, ...Object.keys(st(i, a))]);
868
868
  for (let t of Array.from(e)) {
869
869
  let e = U(n.dirtyFields, t), r = U(a, t), i = U(m, t);
870
- e && !H(r) ? K(m, t, r) : !e && !H(i) && re(t, i);
870
+ e && !H(r) ? K(m, t, r) : !e && !H(i) && ie(t, i);
871
871
  }
872
872
  } else {
873
873
  if (Ae && H(e)) for (let e of s.mount) {
@@ -883,7 +883,7 @@ function Pt(e = {}) {
883
883
  }
884
884
  }
885
885
  }
886
- if (c.keepFieldsRef) for (let e of s.mount) re(e, U(m, e));
886
+ if (c.keepFieldsRef) for (let e of s.mount) ie(e, U(m, e));
887
887
  else r = {};
888
888
  }
889
889
  a = t.shouldUnregister ? c.keepDefaultValues ? V(i) : {} : V(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
@@ -926,28 +926,28 @@ function Pt(e = {}) {
926
926
  };
927
927
  }, Se = {
928
928
  control: {
929
- register: he,
930
- unregister: pe,
931
- getFieldState: N,
932
- handleSubmit: _e,
933
- setError: le,
934
- _subscribe: de,
935
- _runSchema: T,
929
+ register: _e,
930
+ unregister: he,
931
+ getFieldState: le,
932
+ handleSubmit: P,
933
+ setError: de,
934
+ _subscribe: pe,
935
+ _runSchema: w,
936
936
  _updateIsValidating: _,
937
- _focusError: P,
938
- _getWatch: j,
939
- _getDirty: A,
937
+ _focusError: M,
938
+ _getWatch: A,
939
+ _getDirty: k,
940
940
  _setValid: g,
941
941
  _setFieldArray: y,
942
- _setDisabledField: me,
942
+ _setDisabledField: ge,
943
943
  _setErrors: x,
944
- _getFieldArray: ee,
944
+ _getFieldArray: te,
945
945
  _reset: ye,
946
946
  _resetDefaultValues: () => G(t.defaultValues) && t.defaultValues().then((e) => {
947
947
  be(e, t.resetOptions), p.state.next({ isLoading: !1 });
948
948
  }),
949
- _removeUnmounted: k,
950
- _disableForm: ge,
949
+ _removeUnmounted: O,
950
+ _disableForm: N,
951
951
  _subjects: p,
952
952
  _proxyFormState: d,
953
953
  get _fields() {
@@ -984,21 +984,21 @@ function Pt(e = {}) {
984
984
  };
985
985
  }
986
986
  },
987
- subscribe: fe,
988
- trigger: oe,
989
- register: he,
990
- handleSubmit: _e,
991
- watch: ue,
992
- setValue: re,
993
- setValues: ie,
994
- getValues: se,
987
+ subscribe: me,
988
+ trigger: j,
989
+ register: _e,
990
+ handleSubmit: P,
991
+ watch: fe,
992
+ setValue: ie,
993
+ setValues: ae,
994
+ getValues: ce,
995
995
  reset: be,
996
996
  resetField: ve,
997
- clearErrors: ce,
998
- unregister: pe,
999
- setError: le,
997
+ clearErrors: ue,
998
+ unregister: he,
999
+ setError: de,
1000
1000
  setFocus: F,
1001
- getFieldState: N
1001
+ getFieldState: le
1002
1002
  };
1003
1003
  return {
1004
1004
  ...Se,
@@ -1006,7 +1006,7 @@ function Pt(e = {}) {
1006
1006
  };
1007
1007
  }
1008
1008
  function Ft(e = {}) {
1009
- let t = P.useRef(void 0), n = P.useRef(void 0), [r, i] = P.useState(() => ({
1009
+ let t = M.useRef(void 0), n = M.useRef(void 0), [r, i] = M.useState(() => ({
1010
1010
  ...V(Nt),
1011
1011
  isLoading: G(e.defaultValues),
1012
1012
  errors: e.errors || {},
@@ -1035,29 +1035,29 @@ function Ft(e = {}) {
1035
1035
  ...e,
1036
1036
  isReady: !0
1037
1037
  })), a._formState.isReady = !0, e;
1038
- }, [a]), P.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), P.useEffect(() => {
1038
+ }, [a]), M.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), M.useEffect(() => {
1039
1039
  e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
1040
1040
  }, [
1041
1041
  a,
1042
1042
  e.mode,
1043
1043
  e.reValidateMode
1044
- ]), P.useEffect(() => {
1044
+ ]), M.useEffect(() => {
1045
1045
  e.errors && (a._setErrors(e.errors), a._focusError());
1046
- }, [a, e.errors]), P.useEffect(() => {
1046
+ }, [a, e.errors]), M.useEffect(() => {
1047
1047
  e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
1048
- }, [a, e.shouldUnregister]), P.useEffect(() => {
1048
+ }, [a, e.shouldUnregister]), M.useEffect(() => {
1049
1049
  if (a._proxyFormState.isDirty) {
1050
1050
  let e = a._getDirty();
1051
1051
  e !== r.isDirty && a._subjects.state.next({ isDirty: e });
1052
1052
  }
1053
- }, [a, r.isDirty]), P.useEffect(() => {
1053
+ }, [a, r.isDirty]), M.useEffect(() => {
1054
1054
  e.values && !X(e.values, n.current) ? (a._reset(e.values, {
1055
1055
  keepFieldsRef: !0,
1056
1056
  ...a._options.resetOptions
1057
1057
  }), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
1058
- }, [a, e.values]), P.useEffect(() => {
1058
+ }, [a, e.values]), M.useEffect(() => {
1059
1059
  a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
1060
- }), t.current.formState = P.useMemo(() => ze(r, a), [a, r]), t.current;
1060
+ }), t.current.formState = M.useMemo(() => ze(r, a), [a, r]), t.current;
1061
1061
  }
1062
1062
  //#endregion
1063
1063
  //#region node_modules/@hookform/resolvers/dist/resolvers.mjs
@@ -1179,7 +1179,7 @@ function Wt(e, t, n) {
1179
1179
  }(e)) return function(r, i, a) {
1180
1180
  try {
1181
1181
  return Promise.resolve(Vt(function() {
1182
- return Promise.resolve((n.mode === "sync" ? g : le)(e, r, t)).then(function(e) {
1182
+ return Promise.resolve((n.mode === "sync" ? l : f)(e, r, t)).then(function(e) {
1183
1183
  return a.shouldUseNativeValidation && Lt({}, a), {
1184
1184
  errors: {},
1185
1185
  values: n.raw ? Object.assign({}, r) : e
@@ -1187,7 +1187,7 @@ function Wt(e, t, n) {
1187
1187
  });
1188
1188
  }, function(e) {
1189
1189
  if (function(e) {
1190
- return e instanceof l;
1190
+ return e instanceof o;
1191
1191
  }(e)) return {
1192
1192
  values: {},
1193
1193
  errors: Rt(Ut(e.issues, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
@@ -1207,100 +1207,100 @@ function Gt(e) {
1207
1207
  for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...Gt(n.children));
1208
1208
  return t;
1209
1209
  }
1210
- function Kt(e, n) {
1210
+ function Kt(e, t) {
1211
1211
  if (e.component === "header") return !0;
1212
- let { props: r } = e;
1213
- return !(r.hidden_when && t(r.hidden_when, n) || r.visible_when && !t(r.visible_when, n));
1212
+ let { props: n } = e;
1213
+ return !(n.hidden_when && u(n.hidden_when, t) || n.visible_when && !u(n.visible_when, t));
1214
1214
  }
1215
- function qt(e, n) {
1215
+ function qt(e, t) {
1216
1216
  if (e.component === "header") return !1;
1217
- let { props: r } = e;
1218
- return !!(r.disabled || r.disabled_when && t(r.disabled_when, n));
1217
+ let { props: n } = e;
1218
+ return !!(n.disabled || n.disabled_when && u(n.disabled_when, t));
1219
1219
  }
1220
- function Jt(e, n) {
1221
- if (e.component === "header" || qt(e, n)) return !1;
1222
- let { props: r } = e;
1223
- return !!(r.required || r.required_when && t(r.required_when, n));
1220
+ function Jt(e, t) {
1221
+ if (e.component === "header" || qt(e, t)) return !1;
1222
+ let { props: n } = e;
1223
+ return !!(n.required || n.required_when && u(n.required_when, t));
1224
1224
  }
1225
1225
  //#endregion
1226
1226
  //#region src/base/form/form-schema-builder.ts
1227
1227
  function Yt(e, t, n) {
1228
- let { component: r, props: i } = e, a = i.validation, o = n;
1229
- switch (r) {
1228
+ let { component: i, props: o } = e, s = o.validation, c = n;
1229
+ switch (i) {
1230
1230
  case "text":
1231
1231
  case "textarea":
1232
1232
  case "password":
1233
1233
  case "slug":
1234
1234
  case "color": {
1235
- let e = N();
1236
- return o && (e = e.min(1, t("middag.ui.validation.required"))), a?.minLength && (e = e.min(a.minLength, t("middag.ui.validation.min_length", { min: a.minLength }))), a?.maxLength && (e = e.max(a.maxLength, t("middag.ui.validation.max_length", { max: a.maxLength }))), a?.pattern && (e = e.regex(new RegExp(a.pattern), a.patternMessage ?? t("middag.ui.validation.pattern"))), o ? e : e.or(A(""));
1235
+ let e = k();
1236
+ return c && (e = e.min(1, t("middag.ui.validation.required"))), s?.minLength && (e = e.min(s.minLength, t("middag.ui.validation.min_length", { min: s.minLength }))), s?.maxLength && (e = e.max(s.maxLength, t("middag.ui.validation.max_length", { max: s.maxLength }))), s?.pattern && (e = e.regex(new RegExp(s.pattern), s.patternMessage ?? t("middag.ui.validation.pattern"))), c ? e : e.or(r(""));
1237
1237
  }
1238
1238
  case "email": {
1239
- let e = N();
1240
- if (o) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
1241
- else return e.email(t("middag.ui.validation.email")).or(A(""));
1239
+ let e = k();
1240
+ if (c) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
1241
+ else return e.email(t("middag.ui.validation.email")).or(r(""));
1242
1242
  return e;
1243
1243
  }
1244
1244
  case "url": {
1245
- let e = N();
1246
- if (o) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
1247
- else return e.url(t("middag.ui.validation.url")).or(A(""));
1245
+ let e = k();
1246
+ if (c) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
1247
+ else return e.url(t("middag.ui.validation.url")).or(r(""));
1248
1248
  return e;
1249
1249
  }
1250
1250
  case "int": {
1251
- let e = T({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
1252
- return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
1251
+ let e = d({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
1252
+ return o.min != null && (e = e.min(o.min, t("middag.ui.validation.min_value", { min: o.min }))), o.max != null && (e = e.max(o.max, t("middag.ui.validation.max_value", { max: o.max }))), c ? e : e.nullable();
1253
1253
  }
1254
1254
  case "float": {
1255
- let e = T();
1256
- return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
1255
+ let e = d();
1256
+ return o.min != null && (e = e.min(o.min, t("middag.ui.validation.min_value", { min: o.min }))), o.max != null && (e = e.max(o.max, t("middag.ui.validation.max_value", { max: o.max }))), c ? e : e.nullable();
1257
1257
  }
1258
1258
  case "currency": {
1259
- let e = T();
1260
- return o ? e : e.nullable();
1259
+ let e = d();
1260
+ return c ? e : e.nullable();
1261
1261
  }
1262
1262
  case "select":
1263
1263
  case "radio":
1264
1264
  case "entity_picker": {
1265
- let e = N();
1266
- return o ? e.min(1, t("middag.ui.validation.required")) : e;
1265
+ let e = k();
1266
+ return c ? e.min(1, t("middag.ui.validation.required")) : e;
1267
1267
  }
1268
1268
  case "multiselect":
1269
1269
  case "tags": {
1270
- let e = x(N());
1271
- return o ? e.min(1, t("middag.ui.validation.required")) : e;
1270
+ let e = m(k());
1271
+ return c ? e.min(1, t("middag.ui.validation.required")) : e;
1272
1272
  }
1273
1273
  case "checkbox":
1274
- case "switch": return ne();
1274
+ case "switch": return a();
1275
1275
  case "date":
1276
1276
  case "datetime": {
1277
- let e = N();
1278
- return o ? e.min(1, t("middag.ui.validation.required")) : e;
1277
+ let e = k();
1278
+ return c ? e.min(1, t("middag.ui.validation.required")) : e;
1279
1279
  }
1280
1280
  case "phone": {
1281
- let e = N();
1282
- return o ? e.min(1, t("middag.ui.validation.required")) : e;
1281
+ let e = k();
1282
+ return c ? e.min(1, t("middag.ui.validation.required")) : e;
1283
1283
  }
1284
1284
  case "document": {
1285
- let e = i.documentType ?? "generic", n = i.documentScope ?? "any", r = N(), a = async (t) => {
1285
+ let e = o.documentType ?? "generic", n = o.documentScope ?? "any", r = k(), i = async (t) => {
1286
1286
  let { isValidDocument: r } = await import("./document-validation-DX0fB9cu.js");
1287
1287
  return r(t, e, n);
1288
1288
  };
1289
- return o ? r.min(1, t("middag.ui.validation.required")).refine(a, t("middag.ui.validation.document_invalid")) : r.refine(async (e) => e === "" || await a(e), t("middag.ui.validation.document_invalid"));
1289
+ return c ? r.min(1, t("middag.ui.validation.required")).refine(i, t("middag.ui.validation.document_invalid")) : r.refine(async (e) => e === "" || await i(e), t("middag.ui.validation.document_invalid"));
1290
1290
  }
1291
- default: return y();
1291
+ default: return fe();
1292
1292
  }
1293
1293
  }
1294
1294
  function Xt(e, t, n) {
1295
1295
  let r = Gt(e), i = {};
1296
1296
  for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || Kt(e, t) && (i[e.key] = Yt(e, n, Jt(e, t)));
1297
- return C(i);
1297
+ return A(i);
1298
1298
  }
1299
1299
  //#endregion
1300
1300
  //#region src/base/form/FormField.tsx
1301
- var Zt = _e(() => import("./PhoneField-D_djeYhK.js").then((e) => ({ default: e.PhoneField }))), Qt = _e(() => import("./DateField-CcRD2r-Z.js").then((e) => ({ default: e.DateField }))), $t = _e(() => import("./DocumentField-DjnK9T7o.js").then((e) => ({ default: e.DocumentField }))), en = _e(() => import("./DateRangeField-DKZMfKB2.js").then((e) => ({ default: e.DateRangeField })));
1301
+ var Zt = P(() => import("./PhoneField-BF70G_PS.js").then((e) => ({ default: e.PhoneField }))), Qt = P(() => import("./DateField-CcRD2r-Z.js").then((e) => ({ default: e.DateField }))), $t = P(() => import("./DocumentField-DjnK9T7o.js").then((e) => ({ default: e.DocumentField }))), en = P(() => import("./DateRangeField-DKZMfKB2.js").then((e) => ({ default: e.DateRangeField })));
1302
1302
  function tn() {
1303
- return /* @__PURE__ */ I(he, { className: "h-9 w-full rounded-md" });
1303
+ return /* @__PURE__ */ I(_e, { className: "h-9 w-full rounded-md" });
1304
1304
  }
1305
1305
  function nn({ label: e }) {
1306
1306
  return /* @__PURE__ */ I("div", {
@@ -1319,7 +1319,7 @@ function rn({ id: e, value: t }) {
1319
1319
  });
1320
1320
  }
1321
1321
  function an({ field: e, value: t, onChange: r, error: i, sourceValues: a = {} }) {
1322
- let { t: o } = pe(), s = be(), c = `field-${e.key}-${s}`, l = `${c}-help`, u = `${c}-error`, { component: d, props: f } = e;
1322
+ let { t: o } = he(), s = be(), c = `field-${e.key}-${s}`, l = `${c}-help`, u = `${c}-error`, { component: d, props: f } = e;
1323
1323
  if (d === "header") return /* @__PURE__ */ I(nn, { label: f.label });
1324
1324
  if (d === "hidden") return /* @__PURE__ */ I(rn, {
1325
1325
  id: c,
@@ -1351,159 +1351,159 @@ function an({ field: e, value: t, onChange: r, error: i, sourceValues: a = {} })
1351
1351
  ]
1352
1352
  });
1353
1353
  }
1354
- function on(t, n, r, i, a, o, s, c, l, d, f, p) {
1355
- let g = {
1356
- id: n,
1354
+ function on(e, t, n, r, a, o, s, c, l, u, d, f) {
1355
+ let m = {
1356
+ id: t,
1357
1357
  error: o,
1358
1358
  helpTextId: s,
1359
1359
  errorId: c,
1360
- disabled: f,
1361
- required: p
1360
+ disabled: d,
1361
+ required: f
1362
1362
  };
1363
- switch (t) {
1364
- case "text": return /* @__PURE__ */ I(ie, {
1365
- ...g,
1363
+ switch (e) {
1364
+ case "text": return /* @__PURE__ */ I(se, {
1365
+ ...m,
1366
1366
  type: "text",
1367
- value: r,
1368
- onChange: i,
1367
+ value: n,
1368
+ onChange: r,
1369
1369
  placeholder: a.placeholder,
1370
1370
  readOnly: a.readOnly
1371
1371
  });
1372
- case "email": return /* @__PURE__ */ I(ie, {
1373
- ...g,
1372
+ case "email": return /* @__PURE__ */ I(se, {
1373
+ ...m,
1374
1374
  type: "email",
1375
- value: r,
1376
- onChange: i,
1375
+ value: n,
1376
+ onChange: r,
1377
1377
  placeholder: a.placeholder,
1378
1378
  readOnly: a.readOnly
1379
1379
  });
1380
- case "url": return /* @__PURE__ */ I(ie, {
1381
- ...g,
1380
+ case "url": return /* @__PURE__ */ I(se, {
1381
+ ...m,
1382
1382
  type: "url",
1383
- value: r,
1384
- onChange: i,
1383
+ value: n,
1384
+ onChange: r,
1385
1385
  placeholder: a.placeholder,
1386
1386
  readOnly: a.readOnly
1387
1387
  });
1388
- case "textarea": return /* @__PURE__ */ I(E, {
1389
- ...g,
1390
- value: r,
1391
- onChange: i,
1388
+ case "textarea": return /* @__PURE__ */ I(O, {
1389
+ ...m,
1390
+ value: n,
1391
+ onChange: r,
1392
1392
  placeholder: a.placeholder,
1393
1393
  rows: a.rows,
1394
1394
  readOnly: a.readOnly
1395
1395
  });
1396
- case "password": return /* @__PURE__ */ I(te, {
1397
- ...g,
1398
- value: r,
1399
- onChange: i,
1396
+ case "password": return /* @__PURE__ */ I(ne, {
1397
+ ...m,
1398
+ value: n,
1399
+ onChange: r,
1400
1400
  placeholder: a.placeholder
1401
1401
  });
1402
- case "otp": return /* @__PURE__ */ I(k, {
1403
- ...g,
1404
- value: r,
1405
- onChange: i,
1402
+ case "otp": return /* @__PURE__ */ I(D, {
1403
+ ...m,
1404
+ value: n,
1405
+ onChange: r,
1406
1406
  maxLength: a.maxLength,
1407
1407
  pattern: a.pattern,
1408
1408
  groupSize: a.groupSize
1409
1409
  });
1410
- case "select": return /* @__PURE__ */ I(oe, {
1411
- ...g,
1412
- value: r,
1413
- onChange: i,
1410
+ case "select": return /* @__PURE__ */ I(ee, {
1411
+ ...m,
1412
+ value: n,
1413
+ onChange: r,
1414
1414
  options: a.options ?? [],
1415
1415
  placeholder: a.placeholder
1416
1416
  });
1417
- case "native_select": return /* @__PURE__ */ I(S, {
1418
- ...g,
1419
- value: r,
1420
- onChange: i,
1417
+ case "native_select": return /* @__PURE__ */ I(y, {
1418
+ ...m,
1419
+ value: n,
1420
+ onChange: r,
1421
1421
  options: a.options ?? [],
1422
1422
  placeholder: a.placeholder
1423
1423
  });
1424
- case "multiselect": return /* @__PURE__ */ I(m, {
1425
- ...g,
1426
- value: r,
1427
- onChange: i,
1424
+ case "multiselect": return /* @__PURE__ */ I(ue, {
1425
+ ...m,
1426
+ value: n,
1427
+ onChange: r,
1428
1428
  options: a.options ?? [],
1429
1429
  placeholder: a.placeholder
1430
1430
  });
1431
- case "radio": return /* @__PURE__ */ I(b, {
1432
- ...g,
1433
- value: r,
1434
- onChange: i,
1431
+ case "radio": return /* @__PURE__ */ I(oe, {
1432
+ ...m,
1433
+ value: n,
1434
+ onChange: r,
1435
1435
  options: a.options ?? []
1436
1436
  });
1437
- case "int": return /* @__PURE__ */ I(w, {
1438
- ...g,
1439
- value: r,
1440
- onChange: i,
1437
+ case "int": return /* @__PURE__ */ I(E, {
1438
+ ...m,
1439
+ value: n,
1440
+ onChange: r,
1441
1441
  min: a.min,
1442
1442
  max: a.max,
1443
1443
  step: 1
1444
1444
  });
1445
- case "float": return /* @__PURE__ */ I(w, {
1446
- ...g,
1447
- value: r,
1448
- onChange: i,
1445
+ case "float": return /* @__PURE__ */ I(E, {
1446
+ ...m,
1447
+ value: n,
1448
+ onChange: r,
1449
1449
  min: a.min,
1450
1450
  max: a.max,
1451
1451
  step: a.step ?? .1
1452
1452
  });
1453
- case "slider": return /* @__PURE__ */ I(O, {
1454
- ...g,
1455
- value: r,
1456
- onChange: i,
1453
+ case "slider": return /* @__PURE__ */ I(le, {
1454
+ ...m,
1455
+ value: n,
1456
+ onChange: r,
1457
1457
  min: a.min,
1458
1458
  max: a.max,
1459
1459
  step: a.step,
1460
1460
  multiple: a.multiple
1461
1461
  });
1462
- case "checkbox": return /* @__PURE__ */ I(u, {
1463
- ...g,
1464
- value: r,
1465
- onChange: i,
1462
+ case "checkbox": return /* @__PURE__ */ I(i, {
1463
+ ...m,
1464
+ value: n,
1465
+ onChange: r,
1466
1466
  label: a.label
1467
1467
  });
1468
- case "switch": return /* @__PURE__ */ I(ee, {
1469
- ...g,
1470
- value: r,
1471
- onChange: i,
1468
+ case "switch": return /* @__PURE__ */ I(ae, {
1469
+ ...m,
1470
+ value: n,
1471
+ onChange: r,
1472
1472
  label: a.label
1473
1473
  });
1474
- case "date": return /* @__PURE__ */ I(ge, {
1474
+ case "date": return /* @__PURE__ */ I(N, {
1475
1475
  fallback: /* @__PURE__ */ I(tn, {}),
1476
1476
  children: /* @__PURE__ */ I(Qt, {
1477
- ...g,
1477
+ ...m,
1478
1478
  mode: "date",
1479
- value: r,
1480
- onChange: i,
1479
+ value: n,
1480
+ onChange: r,
1481
1481
  placeholder: a.placeholder
1482
1482
  })
1483
1483
  });
1484
- case "datetime": return /* @__PURE__ */ I(ge, {
1484
+ case "datetime": return /* @__PURE__ */ I(N, {
1485
1485
  fallback: /* @__PURE__ */ I(tn, {}),
1486
1486
  children: /* @__PURE__ */ I(Qt, {
1487
- ...g,
1487
+ ...m,
1488
1488
  mode: "datetime",
1489
- value: r,
1490
- onChange: i,
1489
+ value: n,
1490
+ onChange: r,
1491
1491
  placeholder: a.placeholder
1492
1492
  })
1493
1493
  });
1494
- case "file": return /* @__PURE__ */ I(se, {
1495
- ...g,
1496
- value: r,
1497
- onChange: i,
1494
+ case "file": return /* @__PURE__ */ I(pe, {
1495
+ ...m,
1496
+ value: n,
1497
+ onChange: r,
1498
1498
  accept: a.accept,
1499
1499
  multiple: a.multiple,
1500
1500
  maxFiles: a.maxFiles,
1501
1501
  maxSize: a.maxSize
1502
1502
  });
1503
- case "entity_picker": return /* @__PURE__ */ I(ue, {
1504
- ...g,
1505
- value: r,
1506
- onChange: i,
1503
+ case "entity_picker": return /* @__PURE__ */ I(S, {
1504
+ ...m,
1505
+ value: n,
1506
+ onChange: r,
1507
1507
  options: a.options,
1508
1508
  autocompleteHref: a.autocompleteHref,
1509
1509
  autocompleteMinChars: a.autocompleteMinChars,
@@ -1512,81 +1512,81 @@ function on(t, n, r, i, a, o, s, c, l, d, f, p) {
1512
1512
  entitySubtitleField: a.entitySubtitleField,
1513
1513
  placeholder: a.placeholder
1514
1514
  });
1515
- case "static": return /* @__PURE__ */ I(ae, {
1516
- id: n,
1517
- value: r
1515
+ case "static": return /* @__PURE__ */ I(C, {
1516
+ id: t,
1517
+ value: n
1518
1518
  });
1519
- case "phone": return /* @__PURE__ */ I(ge, {
1519
+ case "phone": return /* @__PURE__ */ I(N, {
1520
1520
  fallback: /* @__PURE__ */ I(tn, {}),
1521
1521
  children: /* @__PURE__ */ I(Zt, {
1522
- ...g,
1523
- value: r,
1524
- onChange: i,
1522
+ ...m,
1523
+ value: n,
1524
+ onChange: r,
1525
1525
  placeholder: a.placeholder,
1526
1526
  defaultCountry: a.defaultCountry,
1527
1527
  fixedCountry: a.fixedCountry
1528
1528
  })
1529
1529
  });
1530
- case "document": return /* @__PURE__ */ I(ge, {
1530
+ case "document": return /* @__PURE__ */ I(N, {
1531
1531
  fallback: /* @__PURE__ */ I(tn, {}),
1532
1532
  children: /* @__PURE__ */ I($t, {
1533
- ...g,
1534
- value: r,
1535
- onChange: i,
1533
+ ...m,
1534
+ value: n,
1535
+ onChange: r,
1536
1536
  documentType: a.documentType,
1537
1537
  documentScope: a.documentScope,
1538
1538
  documentMasks: a.documentMasks,
1539
1539
  placeholder: a.placeholder
1540
1540
  })
1541
1541
  });
1542
- case "currency": return /* @__PURE__ */ I(e, {
1543
- ...g,
1544
- value: r,
1545
- onChange: i,
1542
+ case "currency": return /* @__PURE__ */ I(de, {
1543
+ ...m,
1544
+ value: n,
1545
+ onChange: r,
1546
1546
  currency: a.currency,
1547
1547
  placeholder: a.placeholder,
1548
1548
  min: a.min,
1549
1549
  max: a.max
1550
1550
  });
1551
- case "color": return /* @__PURE__ */ I(ce, {
1552
- ...g,
1553
- value: r,
1554
- onChange: i,
1551
+ case "color": return /* @__PURE__ */ I(p, {
1552
+ ...m,
1553
+ value: n,
1554
+ onChange: r,
1555
1555
  placeholder: a.placeholder
1556
1556
  });
1557
- case "slug": return /* @__PURE__ */ I(_, {
1558
- ...g,
1559
- value: r,
1560
- onChange: i,
1561
- sourceValue: a.sourceField === void 0 ? void 0 : String(d[a.sourceField] ?? ""),
1557
+ case "slug": return /* @__PURE__ */ I(te, {
1558
+ ...m,
1559
+ value: n,
1560
+ onChange: r,
1561
+ sourceValue: a.sourceField === void 0 ? void 0 : String(u[a.sourceField] ?? ""),
1562
1562
  prefix: a.prefix,
1563
1563
  placeholder: a.placeholder
1564
1564
  });
1565
- case "tags": return /* @__PURE__ */ I(h, {
1566
- ...g,
1567
- value: r,
1568
- onChange: i,
1565
+ case "tags": return /* @__PURE__ */ I(b, {
1566
+ ...m,
1567
+ value: n,
1568
+ onChange: r,
1569
1569
  placeholder: a.placeholder,
1570
1570
  maxTags: a.maxTags
1571
1571
  });
1572
- case "date_range": return /* @__PURE__ */ I(ge, {
1572
+ case "date_range": return /* @__PURE__ */ I(N, {
1573
1573
  fallback: /* @__PURE__ */ I(tn, {}),
1574
1574
  children: /* @__PURE__ */ I(en, {
1575
- ...g,
1576
- value: r,
1577
- onChange: i,
1575
+ ...m,
1576
+ value: n,
1577
+ onChange: r,
1578
1578
  operator: a.operator
1579
1579
  })
1580
1580
  });
1581
- case "rating": return /* @__PURE__ */ I(v, {
1582
- ...g,
1583
- value: r,
1584
- onChange: i,
1581
+ case "rating": return /* @__PURE__ */ I(T, {
1582
+ ...m,
1583
+ value: n,
1584
+ onChange: r,
1585
1585
  maxRating: a.maxRating
1586
1586
  });
1587
1587
  default: return /* @__PURE__ */ L("p", {
1588
1588
  className: "text-destructive text-xs",
1589
- children: ["Unknown field component: ", t]
1589
+ children: ["Unknown field component: ", e]
1590
1590
  });
1591
1591
  }
1592
1592
  }
@@ -1611,204 +1611,204 @@ function sn(e, t) {
1611
1611
  function cn(e, t) {
1612
1612
  return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : sn(e, t);
1613
1613
  }
1614
- function ln({ nodes: e, values: t, errors: n, onChange: r, sourceValues: i }) {
1615
- return /* @__PURE__ */ I(we, { children: e.map((e, a) => {
1614
+ function ln({ nodes: e, values: n, errors: r, onChange: i, sourceValues: a }) {
1615
+ return /* @__PURE__ */ I(we, { children: e.map((e, o) => {
1616
1616
  switch (e.kind) {
1617
- case "field": return Kt(e, t) ? /* @__PURE__ */ I(an, {
1617
+ case "field": return Kt(e, n) ? /* @__PURE__ */ I(an, {
1618
1618
  field: e,
1619
- value: cn(e, t),
1620
- onChange: (t) => r(e.key, t),
1621
- error: n[e.key],
1622
- sourceValues: i
1619
+ value: cn(e, n),
1620
+ onChange: (t) => i(e.key, t),
1621
+ error: r[e.key],
1622
+ sourceValues: a
1623
1623
  }, e.key) : null;
1624
- case "section": return /* @__PURE__ */ I(j, {
1624
+ case "section": return /* @__PURE__ */ I(re, {
1625
1625
  id: e.id,
1626
1626
  title: e.label,
1627
1627
  defaultCollapsed: e.defaultCollapsed,
1628
- hasErrors: e.children.some((e) => e.kind === "field" && !!n[e.key]),
1629
- errorCount: e.children.filter((e) => e.kind === "field" && !!n[e.key]).length,
1628
+ hasErrors: e.children.some((e) => e.kind === "field" && !!r[e.key]),
1629
+ errorCount: e.children.filter((e) => e.kind === "field" && !!r[e.key]).length,
1630
1630
  children: /* @__PURE__ */ I(ln, {
1631
1631
  nodes: e.children,
1632
- values: t,
1633
- errors: n,
1634
- onChange: r,
1635
- sourceValues: i
1632
+ values: n,
1633
+ errors: r,
1634
+ onChange: i,
1635
+ sourceValues: a
1636
1636
  })
1637
1637
  }, e.id);
1638
1638
  case "group": return /* @__PURE__ */ I("div", {
1639
- className: me("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
1639
+ className: ge("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
1640
1640
  children: /* @__PURE__ */ I(ln, {
1641
1641
  nodes: e.children,
1642
- values: t,
1643
- errors: n,
1644
- onChange: r,
1645
- sourceValues: i
1642
+ values: n,
1643
+ errors: r,
1644
+ onChange: i,
1645
+ sourceValues: a
1646
1646
  })
1647
1647
  }, e.id);
1648
1648
  case "header": return /* @__PURE__ */ L("div", {
1649
1649
  className: "space-y-2",
1650
- children: [/* @__PURE__ */ I(D, {}), /* @__PURE__ */ I("h4", {
1650
+ children: [/* @__PURE__ */ I(t, {}), /* @__PURE__ */ I("h4", {
1651
1651
  className: "text-foreground text-base font-semibold",
1652
1652
  children: e.label
1653
1653
  })]
1654
- }, `header-${a}`);
1654
+ }, `header-${o}`);
1655
1655
  default: return null;
1656
1656
  }
1657
1657
  }) });
1658
1658
  }
1659
- function un({ block: e }) {
1660
- let { t } = pe(), { data: n } = e, l = F(() => Gt(n.schema), [n.schema]), u = F(() => new Set(l.map((e) => e.key)), [l]), m = (n.meta.validation ?? "both") !== "server", h = F(() => Object.fromEntries(l.map((e) => [e.key, sn(e, n.values)])), [l, n.values]), g = xe(m ? Xt(n.schema, h, t) : null), _ = Ft({
1661
- defaultValues: h,
1659
+ function un({ block: t }) {
1660
+ let { t: n } = he(), { data: r } = t, i = F(() => Gt(r.schema), [r.schema]), a = F(() => new Set(i.map((e) => e.key)), [i]), o = (r.meta.validation ?? "both") !== "server", l = F(() => Object.fromEntries(i.map((e) => [e.key, sn(e, r.values)])), [i, r.values]), u = xe(o ? Xt(r.schema, l, n) : null), d = Ft({
1661
+ defaultValues: l,
1662
1662
  mode: "onTouched",
1663
1663
  resolver: F(() => {
1664
- if (m) return async (e, t, n) => g.current ? Wt(g.current)(e, t, n) : {
1664
+ if (o) return async (e, t, n) => u.current ? Wt(u.current)(e, t, n) : {
1665
1665
  values: e,
1666
1666
  errors: {}
1667
1667
  };
1668
- }, [m])
1669
- }), v = Ue({ control: _.control }) ?? h, y = l.map((e) => `${Kt(e, v) ? "1" : "0"}${Jt(e, v) ? "1" : "0"}`).join("");
1668
+ }, [o])
1669
+ }), f = Ue({ control: d.control }) ?? l, p = i.map((e) => `${Kt(e, f) ? "1" : "0"}${Jt(e, f) ? "1" : "0"}`).join("");
1670
1670
  ye(() => {
1671
- m && (g.current = Xt(n.schema, v, t));
1671
+ o && (u.current = Xt(r.schema, f, n));
1672
1672
  }, [
1673
- m,
1674
- n.schema,
1675
- t,
1676
- y
1673
+ o,
1674
+ r.schema,
1675
+ n,
1676
+ p
1677
1677
  ]);
1678
- let [b, x] = Se(!1), [S, C] = Se(null), [w, T] = Se({}), E = JSON.stringify(n.values), D = xe(!0);
1678
+ let [m, y] = Se(!1), [b, S] = Se(null), [C, ee] = Se({}), T = JSON.stringify(r.values), E = xe(!0);
1679
1679
  ye(() => {
1680
- if (D.current) {
1681
- D.current = !1;
1680
+ if (E.current) {
1681
+ E.current = !1;
1682
1682
  return;
1683
1683
  }
1684
- _.reset(h);
1685
- for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
1684
+ d.reset(l);
1685
+ for (let [e, t] of Object.entries(r.errors)) a.has(e) && d.setError(e, {
1686
1686
  type: "server",
1687
- message: M(r, t)
1687
+ message: j(t, n)
1688
1688
  });
1689
- }, [E]), ye(() => {
1690
- if (Object.keys(n.errors).length > 0) for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
1689
+ }, [T]), ye(() => {
1690
+ if (Object.keys(r.errors).length > 0) for (let [e, t] of Object.entries(r.errors)) a.has(e) && d.setError(e, {
1691
1691
  type: "server",
1692
- message: M(r, t)
1692
+ message: j(t, n)
1693
1693
  });
1694
- }, [JSON.stringify(n.errors)]);
1695
- let { isDirty: O, isSubmitting: k } = _.formState;
1694
+ }, [JSON.stringify(r.errors)]);
1695
+ let { isDirty: D, isSubmitting: O } = d.formState;
1696
1696
  ye(() => {
1697
- if (!O) return;
1697
+ if (!D) return;
1698
1698
  let e = (e) => {
1699
1699
  e.preventDefault();
1700
1700
  };
1701
1701
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
1702
- }, [O]);
1703
- let A = ve((e, t) => {
1704
- _.setValue(e, t, {
1702
+ }, [D]);
1703
+ let k = ve((e, t) => {
1704
+ d.setValue(e, t, {
1705
1705
  shouldDirty: !0,
1706
- shouldValidate: _.formState.isSubmitted
1707
- }), _.clearErrors(e);
1708
- }, [_]), j = ve((e) => {
1709
- T({});
1710
- let r = l.filter((t) => Kt(t, e)), i = Object.fromEntries(r.map((t) => [t.key, e[t.key]])), a = Object.values(i).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
1711
- Ce[n.method === "put" ? "put" : n.method === "patch" ? "patch" : "post"](n.action, i, {
1712
- forceFormData: a,
1706
+ shouldValidate: d.formState.isSubmitted
1707
+ }), d.clearErrors(e);
1708
+ }, [d]), A = ve((e) => {
1709
+ ee({});
1710
+ let t = i.filter((t) => Kt(t, e)), o = Object.fromEntries(t.map((t) => [t.key, e[t.key]])), s = Object.values(o).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
1711
+ Ce[r.method === "put" ? "put" : r.method === "patch" ? "patch" : "post"](r.action, o, {
1712
+ forceFormData: s,
1713
1713
  onProgress: (e) => {
1714
- e && typeof e.percentage == "number" && C(Math.round(e.percentage));
1714
+ e && typeof e.percentage == "number" && S(Math.round(e.percentage));
1715
1715
  },
1716
1716
  onError: (e) => {
1717
- let n = {};
1718
- for (let [r, i] of Object.entries(e)) u.has(r) ? _.setError(r, {
1717
+ let t = {};
1718
+ for (let [r, i] of Object.entries(e)) a.has(r) ? d.setError(r, {
1719
1719
  type: "server",
1720
- message: M(i, t)
1721
- }) : n[r] = i;
1722
- Object.keys(n).length > 0 && T((e) => ({
1720
+ message: j(i, n)
1721
+ }) : t[r] = i;
1722
+ Object.keys(t).length > 0 && ee((e) => ({
1723
1723
  ...e,
1724
- ...n
1724
+ ...t
1725
1725
  }));
1726
1726
  },
1727
- onFinish: () => C(null)
1727
+ onFinish: () => S(null)
1728
1728
  });
1729
1729
  }, [
1730
- l,
1730
+ i,
1731
+ r,
1732
+ d,
1731
1733
  n,
1732
- _,
1733
- t,
1734
- u
1735
- ]), ee = ve(() => {
1736
- O ? x(!0) : n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
1737
- }, [O, n.meta.cancelHref]), te = F(() => {
1734
+ a
1735
+ ]), te = ve(() => {
1736
+ D ? y(!0) : r.meta.cancelHref ? Ce.visit(r.meta.cancelHref) : window.history.back();
1737
+ }, [D, r.meta.cancelHref]), ne = F(() => {
1738
1738
  let e = {};
1739
- for (let [t, n] of Object.entries(_.formState.errors)) n?.message && (e[t] = n.message);
1739
+ for (let [t, n] of Object.entries(d.formState.errors)) n?.message && (e[t] = n.message);
1740
1740
  return e;
1741
- }, [_.formState.errors]), ne = F(() => {
1742
- let e = /* @__PURE__ */ new Map(), r = (n) => {
1743
- for (let [r, i] of Object.entries(n)) {
1744
- if (u.has(r)) continue;
1745
- let n = M(i, t);
1746
- n && e.set(r, n);
1741
+ }, [d.formState.errors]), re = F(() => {
1742
+ let e = /* @__PURE__ */ new Map(), t = (t) => {
1743
+ for (let [r, i] of Object.entries(t)) {
1744
+ if (a.has(r)) continue;
1745
+ let t = j(i, n);
1746
+ t && e.set(r, t);
1747
1747
  }
1748
1748
  };
1749
- return r(n.errors), r(w), Array.from(e, ([e, t]) => ({
1749
+ return t(r.errors), t(C), Array.from(e, ([e, t]) => ({
1750
1750
  key: e,
1751
1751
  message: t
1752
1752
  }));
1753
1753
  }, [
1754
- n.errors,
1755
- w,
1756
- u,
1757
- t
1754
+ r.errors,
1755
+ C,
1756
+ a,
1757
+ n
1758
1758
  ]);
1759
- return l.filter((e) => Kt(e, v)).length === 0 && n.schema.length === 0 ? /* @__PURE__ */ I(r, {
1759
+ return i.filter((e) => Kt(e, f)).length === 0 && r.schema.length === 0 ? /* @__PURE__ */ I(g, {
1760
1760
  variant: "inline",
1761
- title: t("middag.ui.form.no_fields")
1761
+ title: n("middag.ui.form.no_fields")
1762
1762
  }) : /* @__PURE__ */ L(we, { children: [/* @__PURE__ */ L("form", {
1763
- onSubmit: _.handleSubmit(j),
1763
+ onSubmit: d.handleSubmit(A),
1764
1764
  className: "mx-auto max-w-[720px] space-y-6",
1765
1765
  noValidate: !0,
1766
1766
  role: "form",
1767
- "aria-label": c(e.title, t) || t("middag.ui.form.default_title"),
1767
+ "aria-label": h(t.title, n) || n("middag.ui.form.default_title"),
1768
1768
  children: [
1769
- ne.length > 0 && /* @__PURE__ */ L(de, {
1769
+ re.length > 0 && /* @__PURE__ */ L(c, {
1770
1770
  variant: "destructive",
1771
- children: [/* @__PURE__ */ I(a, { children: t("middag.ui.form.errors_title") }), /* @__PURE__ */ I(d, { children: /* @__PURE__ */ I("ul", {
1771
+ children: [/* @__PURE__ */ I(_, { children: n("middag.ui.form.errors_title") }), /* @__PURE__ */ I(s, { children: /* @__PURE__ */ I("ul", {
1772
1772
  className: "list-disc ps-4",
1773
- children: ne.map((e) => /* @__PURE__ */ I("li", { children: e.message }, e.key))
1773
+ children: re.map((e) => /* @__PURE__ */ I("li", { children: e.message }, e.key))
1774
1774
  }) })]
1775
1775
  }),
1776
1776
  /* @__PURE__ */ I(ln, {
1777
- nodes: n.schema,
1778
- values: v,
1779
- errors: te,
1780
- onChange: A,
1781
- sourceValues: v
1777
+ nodes: r.schema,
1778
+ values: f,
1779
+ errors: ne,
1780
+ onChange: k,
1781
+ sourceValues: f
1782
1782
  }),
1783
1783
  /* @__PURE__ */ L("div", {
1784
1784
  className: "flex gap-3 pt-4",
1785
- children: [/* @__PURE__ */ I(fe, {
1785
+ children: [/* @__PURE__ */ I(me, {
1786
1786
  type: "submit",
1787
- disabled: k,
1788
- "aria-disabled": k,
1789
- "aria-busy": k,
1790
- children: k ? S === null ? t("middag.ui.form.saving") : `${t("middag.ui.form.saving")} ${S}%` : n.meta.submitLabel ?? t("middag.ui.form.save")
1791
- }), /* @__PURE__ */ I(fe, {
1787
+ disabled: O,
1788
+ "aria-disabled": O,
1789
+ "aria-busy": O,
1790
+ children: O ? b === null ? n("middag.ui.form.saving") : `${n("middag.ui.form.saving")} ${b}%` : r.meta.submitLabel ?? n("middag.ui.form.save")
1791
+ }), /* @__PURE__ */ I(me, {
1792
1792
  type: "button",
1793
1793
  variant: "outline",
1794
- onClick: ee,
1795
- children: n.meta.cancelLabel ?? t("middag.ui.cancel")
1794
+ onClick: te,
1795
+ children: r.meta.cancelLabel ?? n("middag.ui.cancel")
1796
1796
  })]
1797
1797
  })
1798
1798
  ]
1799
- }), /* @__PURE__ */ I(f, {
1800
- open: b,
1801
- onOpenChange: x,
1802
- children: /* @__PURE__ */ L(i, { children: [/* @__PURE__ */ L(o, { children: [/* @__PURE__ */ I(p, { children: t("middag.ui.form.dirty_title") }), /* @__PURE__ */ I(s, { children: t("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ L(re, { children: [/* @__PURE__ */ I(fe, {
1799
+ }), /* @__PURE__ */ I(v, {
1800
+ open: m,
1801
+ onOpenChange: y,
1802
+ children: /* @__PURE__ */ L(e, { children: [/* @__PURE__ */ L(ie, { children: [/* @__PURE__ */ I(x, { children: n("middag.ui.form.dirty_title") }), /* @__PURE__ */ I(w, { children: n("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ L(ce, { children: [/* @__PURE__ */ I(me, {
1803
1803
  variant: "outline",
1804
- onClick: () => x(!1),
1805
- children: t("middag.ui.cancel")
1806
- }), /* @__PURE__ */ I(fe, {
1804
+ onClick: () => y(!1),
1805
+ children: n("middag.ui.cancel")
1806
+ }), /* @__PURE__ */ I(me, {
1807
1807
  variant: "destructive",
1808
1808
  onClick: () => {
1809
- x(!1), n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
1809
+ y(!1), r.meta.cancelHref ? Ce.visit(r.meta.cancelHref) : window.history.back();
1810
1810
  },
1811
- children: t("middag.ui.form.dirty_leave")
1811
+ children: n("middag.ui.form.dirty_leave")
1812
1812
  })] })] })
1813
1813
  })] });
1814
1814
  }