@ram_28/kf-ai-sdk 1.0.18 → 1.0.20

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.
Files changed (77) hide show
  1. package/README.md +45 -12
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api.cjs +1 -1
  4. package/dist/api.mjs +2 -2
  5. package/dist/auth.cjs +1 -1
  6. package/dist/auth.mjs +1 -1
  7. package/dist/{client-C15j4O5B.cjs → client-DgtkT50N.cjs} +1 -1
  8. package/dist/{client-CfvLiGfP.js → client-V-WzUb8H.js} +9 -5
  9. package/dist/components/hooks/useFilter/types.d.ts +14 -11
  10. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  11. package/dist/components/hooks/useFilter/useFilter.d.ts +1 -1
  12. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  14. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  15. package/dist/components/hooks/useKanban/context.d.ts +1 -1
  16. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  17. package/dist/components/hooks/useKanban/types.d.ts +5 -22
  18. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  19. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  20. package/dist/components/hooks/useTable/types.d.ts +19 -31
  21. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  22. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  23. package/dist/error-handling-CAoD0Kwb.cjs +1 -0
  24. package/dist/error-handling-CrhTtD88.js +14 -0
  25. package/dist/filter.cjs +1 -1
  26. package/dist/filter.mjs +1 -1
  27. package/dist/form.cjs +1 -1
  28. package/dist/form.mjs +825 -814
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/kanban.cjs +2 -2
  32. package/dist/kanban.mjs +335 -323
  33. package/dist/{metadata-2FLBsFcf.cjs → metadata-0lZAfuTP.cjs} +1 -1
  34. package/dist/{metadata-DBcoDth-.js → metadata-B88D_pVS.js} +1 -1
  35. package/dist/table.cjs +1 -1
  36. package/dist/table.mjs +113 -96
  37. package/dist/table.types.d.ts +1 -1
  38. package/dist/table.types.d.ts.map +1 -1
  39. package/dist/types/common.d.ts +26 -6
  40. package/dist/types/common.d.ts.map +1 -1
  41. package/dist/useFilter-DzpP_ag0.cjs +1 -0
  42. package/dist/useFilter-H5bgAZQF.js +120 -0
  43. package/dist/utils/api/buildListOptions.d.ts +43 -0
  44. package/dist/utils/api/buildListOptions.d.ts.map +1 -0
  45. package/dist/utils/api/index.d.ts +2 -0
  46. package/dist/utils/api/index.d.ts.map +1 -0
  47. package/dist/utils/error-handling.d.ts +41 -0
  48. package/dist/utils/error-handling.d.ts.map +1 -0
  49. package/dist/utils/index.d.ts +2 -0
  50. package/dist/utils/index.d.ts.map +1 -1
  51. package/docs/QUICK_REFERENCE.md +142 -420
  52. package/docs/useAuth.md +52 -340
  53. package/docs/useFilter.md +858 -162
  54. package/docs/useForm.md +712 -501
  55. package/docs/useKanban.md +534 -279
  56. package/docs/useTable.md +725 -214
  57. package/package.json +1 -1
  58. package/sdk/api/client.ts +7 -1
  59. package/sdk/components/hooks/useFilter/types.ts +14 -11
  60. package/sdk/components/hooks/useFilter/useFilter.ts +20 -18
  61. package/sdk/components/hooks/useForm/apiClient.ts +2 -1
  62. package/sdk/components/hooks/useForm/useForm.ts +47 -13
  63. package/sdk/components/hooks/useKanban/context.ts +5 -3
  64. package/sdk/components/hooks/useKanban/types.ts +7 -23
  65. package/sdk/components/hooks/useKanban/useKanban.ts +54 -18
  66. package/sdk/components/hooks/useTable/types.ts +26 -32
  67. package/sdk/components/hooks/useTable/useTable.llm.txt +8 -22
  68. package/sdk/components/hooks/useTable/useTable.ts +70 -25
  69. package/sdk/index.ts +154 -10
  70. package/sdk/table.types.ts +3 -0
  71. package/sdk/types/common.ts +31 -6
  72. package/sdk/utils/api/buildListOptions.ts +120 -0
  73. package/sdk/utils/api/index.ts +2 -0
  74. package/sdk/utils/error-handling.ts +150 -0
  75. package/sdk/utils/index.ts +6 -0
  76. package/dist/useFilter-Dofowpr_.cjs +0 -1
  77. package/dist/useFilter-Dv-mr9QW.js +0 -117
package/dist/form.mjs CHANGED
@@ -1,51 +1,52 @@
1
- var Bt = Object.defineProperty;
2
- var Pt = (e, t, r) => t in e ? Bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var we = (e, t, r) => Pt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import X, { useState as ye, useRef as qe, useEffect as $e, useMemo as Ne, useCallback as te } from "react";
5
- import { useQuery as ct } from "@tanstack/react-query";
6
- import { a as pe } from "./client-CfvLiGfP.js";
7
- import { g as qt } from "./metadata-DBcoDth-.js";
8
- var Le = (e) => e.type === "checkbox", ge = (e) => e instanceof Date, G = (e) => e == null;
9
- const St = (e) => typeof e == "object";
10
- var I = (e) => !G(e) && !Array.isArray(e) && St(e) && !ge(e), $t = (e) => I(e) && e.target ? Le(e.target) ? e.target.checked : e.target.value : e, jt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Wt = (e, t) => e.has(jt(t)), Ht = (e) => {
1
+ var Pt = Object.defineProperty;
2
+ var qt = (e, t, r) => t in e ? Pt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var ve = (e, t, r) => qt(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import X, { useState as ge, useRef as Ne, useEffect as He, useMemo as Oe, useCallback as te } from "react";
5
+ import { useQuery as ft } from "@tanstack/react-query";
6
+ import { a as be } from "./client-V-WzUb8H.js";
7
+ import { g as $t } from "./metadata-B88D_pVS.js";
8
+ import { t as Ve } from "./error-handling-CrhTtD88.js";
9
+ var Me = (e) => e.type === "checkbox", pe = (e) => e instanceof Date, J = (e) => e == null;
10
+ const Nt = (e) => typeof e == "object";
11
+ var U = (e) => !J(e) && !Array.isArray(e) && Nt(e) && !pe(e), jt = (e) => U(e) && e.target ? Me(e.target) ? e.target.checked : e.target.value : e, Wt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Ht = (e, t) => e.has(Wt(t)), Yt = (e) => {
11
12
  const t = e.constructor && e.constructor.prototype;
12
- return I(t) && t.hasOwnProperty("isPrototypeOf");
13
- }, rt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
14
- function k(e) {
13
+ return U(t) && t.hasOwnProperty("isPrototypeOf");
14
+ }, it = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
15
+ function P(e) {
15
16
  if (e instanceof Date)
16
17
  return new Date(e);
17
18
  const t = typeof FileList < "u" && e instanceof FileList;
18
- if (rt && (e instanceof Blob || t))
19
+ if (it && (e instanceof Blob || t))
19
20
  return e;
20
21
  const r = Array.isArray(e);
21
- if (!r && !(I(e) && Ht(e)))
22
+ if (!r && !(U(e) && Yt(e)))
22
23
  return e;
23
24
  const s = r ? [] : Object.create(Object.getPrototypeOf(e));
24
25
  for (const i in e)
25
- Object.prototype.hasOwnProperty.call(e, i) && (s[i] = k(e[i]));
26
+ Object.prototype.hasOwnProperty.call(e, i) && (s[i] = P(e[i]));
26
27
  return s;
27
28
  }
28
- var He = (e) => /^\w*$/.test(e), C = (e) => e === void 0, st = (e) => Array.isArray(e) ? e.filter(Boolean) : [], it = (e) => st(e.replace(/["|']|\]/g, "").split(/\.|\[/)), g = (e, t, r) => {
29
- if (!t || !I(e))
29
+ var ze = (e) => /^\w*$/.test(e), T = (e) => e === void 0, at = (e) => Array.isArray(e) ? e.filter(Boolean) : [], nt = (e) => at(e.replace(/["|']|\]/g, "").split(/\.|\[/)), g = (e, t, r) => {
30
+ if (!t || !U(e))
30
31
  return r;
31
- const s = (He(t) ? [t] : it(t)).reduce((i, n) => G(i) ? i : i[n], e);
32
- return C(s) || s === e ? C(e[t]) ? r : e[t] : s;
33
- }, ie = (e) => typeof e == "boolean", re = (e) => typeof e == "function", R = (e, t, r) => {
32
+ const s = (ze(t) ? [t] : nt(t)).reduce((i, n) => J(i) ? i : i[n], e);
33
+ return T(s) || s === e ? T(e[t]) ? r : e[t] : s;
34
+ }, ie = (e) => typeof e == "boolean", re = (e) => typeof e == "function", N = (e, t, r) => {
34
35
  let s = -1;
35
- const i = He(t) ? [t] : it(t), n = i.length, l = n - 1;
36
+ const i = ze(t) ? [t] : nt(t), n = i.length, l = n - 1;
36
37
  for (; ++s < n; ) {
37
- const d = i[s];
38
+ const f = i[s];
38
39
  let w = r;
39
40
  if (s !== l) {
40
- const p = e[d];
41
- w = I(p) || Array.isArray(p) ? p : isNaN(+i[s + 1]) ? {} : [];
41
+ const b = e[f];
42
+ w = U(b) || Array.isArray(b) ? b : isNaN(+i[s + 1]) ? {} : [];
42
43
  }
43
- if (d === "__proto__" || d === "constructor" || d === "prototype")
44
+ if (f === "__proto__" || f === "constructor" || f === "prototype")
44
45
  return;
45
- e[d] = w, e = e[d];
46
+ e[f] = w, e = e[f];
46
47
  }
47
48
  };
48
- const dt = {
49
+ const ht = {
49
50
  BLUR: "blur",
50
51
  FOCUS_OUT: "focusout"
51
52
  }, se = {
@@ -62,9 +63,9 @@ const dt = {
62
63
  pattern: "pattern",
63
64
  required: "required",
64
65
  validate: "validate"
65
- }, Yt = X.createContext(null);
66
- Yt.displayName = "HookFormContext";
67
- var Kt = (e, t, r, s = !0) => {
66
+ }, Kt = X.createContext(null);
67
+ Kt.displayName = "HookFormContext";
68
+ var zt = (e, t, r, s = !0) => {
68
69
  const i = {
69
70
  defaultValues: t._defaultValues
70
71
  };
@@ -77,12 +78,12 @@ var Kt = (e, t, r, s = !0) => {
77
78
  });
78
79
  return i;
79
80
  };
80
- const zt = typeof window < "u" ? X.useLayoutEffect : X.useEffect;
81
- var Q = (e) => typeof e == "string", Jt = (e, t, r, s, i) => Q(e) ? (s && t.watch.add(e), g(r, e, i)) : Array.isArray(e) ? e.map((n) => (s && t.watch.add(n), g(r, n))) : (s && (t.watchAll = !0), r), et = (e) => G(e) || !St(e);
82
- function de(e, t, r = /* @__PURE__ */ new WeakSet()) {
83
- if (et(e) || et(t))
81
+ const Jt = typeof window < "u" ? X.useLayoutEffect : X.useEffect;
82
+ var Q = (e) => typeof e == "string", Gt = (e, t, r, s, i) => Q(e) ? (s && t.watch.add(e), g(r, e, i)) : Array.isArray(e) ? e.map((n) => (s && t.watch.add(n), g(r, n))) : (s && (t.watchAll = !0), r), rt = (e) => J(e) || !Nt(e);
83
+ function he(e, t, r = /* @__PURE__ */ new WeakSet()) {
84
+ if (rt(e) || rt(t))
84
85
  return Object.is(e, t);
85
- if (ge(e) && ge(t))
86
+ if (pe(e) && pe(t))
86
87
  return Object.is(e.getTime(), t.getTime());
87
88
  const s = Object.keys(e), i = Object.keys(t);
88
89
  if (s.length !== i.length)
@@ -95,20 +96,20 @@ function de(e, t, r = /* @__PURE__ */ new WeakSet()) {
95
96
  if (!i.includes(n))
96
97
  return !1;
97
98
  if (n !== "ref") {
98
- const d = t[n];
99
- if (ge(l) && ge(d) || I(l) && I(d) || Array.isArray(l) && Array.isArray(d) ? !de(l, d, r) : !Object.is(l, d))
99
+ const f = t[n];
100
+ if (pe(l) && pe(f) || U(l) && U(f) || Array.isArray(l) && Array.isArray(f) ? !he(l, f, r) : !Object.is(l, f))
100
101
  return !1;
101
102
  }
102
103
  }
103
104
  return !0;
104
105
  }
105
- var Gt = (e, t, r, s, i) => t ? {
106
+ var Xt = (e, t, r, s, i) => t ? {
106
107
  ...r[e],
107
108
  types: {
108
109
  ...r[e] && r[e].types ? r[e].types : {},
109
110
  [s]: i || !0
110
111
  }
111
- } : {}, Ce = (e) => Array.isArray(e) ? e : [e], ft = () => {
112
+ } : {}, Te = (e) => Array.isArray(e) ? e : [e], mt = () => {
112
113
  let e = [];
113
114
  return {
114
115
  get observers() {
@@ -128,75 +129,75 @@ var Gt = (e, t, r, s, i) => t ? {
128
129
  }
129
130
  };
130
131
  };
131
- function Rt(e, t) {
132
+ function Ot(e, t) {
132
133
  const r = {};
133
134
  for (const s in e)
134
135
  if (e.hasOwnProperty(s)) {
135
136
  const i = e[s], n = t[s];
136
- if (i && I(i) && n) {
137
- const l = Rt(i, n);
138
- I(l) && (r[s] = l);
137
+ if (i && U(i) && n) {
138
+ const l = Ot(i, n);
139
+ U(l) && (r[s] = l);
139
140
  } else e[s] && (r[s] = n);
140
141
  }
141
142
  return r;
142
143
  }
143
- var Y = (e) => I(e) && !Object.keys(e).length, at = (e) => e.type === "file", je = (e) => {
144
- if (!rt)
144
+ var H = (e) => U(e) && !Object.keys(e).length, ut = (e) => e.type === "file", Ye = (e) => {
145
+ if (!it)
145
146
  return !1;
146
147
  const t = e ? e.ownerDocument : 0;
147
148
  return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
148
- }, Nt = (e) => e.type === "select-multiple", nt = (e) => e.type === "radio", Xt = (e) => nt(e) || Le(e), Qe = (e) => je(e) && e.isConnected;
149
- function Qt(e, t) {
149
+ }, Ct = (e) => e.type === "select-multiple", ot = (e) => e.type === "radio", Qt = (e) => ot(e) || Me(e), et = (e) => Ye(e) && e.isConnected;
150
+ function Zt(e, t) {
150
151
  const r = t.slice(0, -1).length;
151
152
  let s = 0;
152
153
  for (; s < r; )
153
- e = C(e) ? s++ : e[t[s++]];
154
+ e = T(e) ? s++ : e[t[s++]];
154
155
  return e;
155
156
  }
156
- function Zt(e) {
157
+ function er(e) {
157
158
  for (const t in e)
158
- if (e.hasOwnProperty(t) && !C(e[t]))
159
+ if (e.hasOwnProperty(t) && !T(e[t]))
159
160
  return !1;
160
161
  return !0;
161
162
  }
162
- function M(e, t) {
163
- const r = Array.isArray(t) ? t : He(t) ? [t] : it(t), s = r.length === 1 ? e : Qt(e, r), i = r.length - 1, n = r[i];
164
- return s && delete s[n], i !== 0 && (I(s) && Y(s) || Array.isArray(s) && Zt(s)) && M(e, r.slice(0, -1)), e;
163
+ function k(e, t) {
164
+ const r = Array.isArray(t) ? t : ze(t) ? [t] : nt(t), s = r.length === 1 ? e : Zt(e, r), i = r.length - 1, n = r[i];
165
+ return s && delete s[n], i !== 0 && (U(s) && H(s) || Array.isArray(s) && er(s)) && k(e, r.slice(0, -1)), e;
165
166
  }
166
- var er = (e) => {
167
+ var tr = (e) => {
167
168
  for (const t in e)
168
169
  if (re(e[t]))
169
170
  return !0;
170
171
  return !1;
171
172
  };
172
- function Ot(e) {
173
- return Array.isArray(e) || I(e) && !er(e);
173
+ function Tt(e) {
174
+ return Array.isArray(e) || U(e) && !tr(e);
174
175
  }
175
- function tt(e, t = {}) {
176
+ function st(e, t = {}) {
176
177
  for (const r in e) {
177
178
  const s = e[r];
178
- Ot(s) ? (t[r] = Array.isArray(s) ? [] : {}, tt(s, t[r])) : C(s) || (t[r] = !0);
179
+ Tt(s) ? (t[r] = Array.isArray(s) ? [] : {}, st(s, t[r])) : T(s) || (t[r] = !0);
179
180
  }
180
181
  return t;
181
182
  }
182
- function Fe(e, t, r) {
183
- r || (r = tt(t));
183
+ function Ee(e, t, r) {
184
+ r || (r = st(t));
184
185
  for (const s in e) {
185
186
  const i = e[s];
186
- if (Ot(i))
187
- C(t) || et(r[s]) ? r[s] = tt(i, Array.isArray(i) ? [] : {}) : Fe(i, G(t) ? {} : t[s], r[s]);
187
+ if (Tt(i))
188
+ T(t) || rt(r[s]) ? r[s] = st(i, Array.isArray(i) ? [] : {}) : Ee(i, J(t) ? {} : t[s], r[s]);
188
189
  else {
189
190
  const n = t[s];
190
- r[s] = !de(i, n);
191
+ r[s] = !he(i, n);
191
192
  }
192
193
  }
193
194
  return r;
194
195
  }
195
- const ht = {
196
+ const yt = {
196
197
  value: !1,
197
198
  isValid: !1
198
- }, mt = { value: !0, isValid: !0 };
199
- var Ct = (e) => {
199
+ }, gt = { value: !0, isValid: !0 };
200
+ var Lt = (e) => {
200
201
  if (Array.isArray(e)) {
201
202
  if (e.length > 1) {
202
203
  const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
@@ -204,28 +205,28 @@ var Ct = (e) => {
204
205
  }
205
206
  return e[0].checked && !e[0].disabled ? (
206
207
  // @ts-expect-error expected to work in the browser
207
- e[0].attributes && !C(e[0].attributes.value) ? C(e[0].value) || e[0].value === "" ? mt : { value: e[0].value, isValid: !0 } : mt
208
- ) : ht;
208
+ e[0].attributes && !T(e[0].attributes.value) ? T(e[0].value) || e[0].value === "" ? gt : { value: e[0].value, isValid: !0 } : gt
209
+ ) : yt;
209
210
  }
210
- return ht;
211
- }, Tt = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => C(e) ? e : t ? e === "" ? NaN : e && +e : r && Q(e) ? new Date(e) : s ? s(e) : e;
212
- const yt = {
211
+ return yt;
212
+ }, Mt = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => T(e) ? e : t ? e === "" ? NaN : e && +e : r && Q(e) ? new Date(e) : s ? s(e) : e;
213
+ const pt = {
213
214
  isValid: !1,
214
215
  value: null
215
216
  };
216
- var Lt = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
217
+ var It = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
217
218
  isValid: !0,
218
219
  value: r.value
219
- } : t, yt) : yt;
220
- function gt(e) {
220
+ } : t, pt) : pt;
221
+ function bt(e) {
221
222
  const t = e.ref;
222
- return at(t) ? t.files : nt(t) ? Lt(e.refs).value : Nt(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Le(t) ? Ct(e.refs).value : Tt(C(t.value) ? e.ref.value : t.value, e);
223
+ return ut(t) ? t.files : ot(t) ? It(e.refs).value : Ct(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Me(t) ? Lt(e.refs).value : Mt(T(t.value) ? e.ref.value : t.value, e);
223
224
  }
224
- var tr = (e, t, r, s) => {
225
+ var rr = (e, t, r, s) => {
225
226
  const i = {};
226
227
  for (const n of e) {
227
228
  const l = g(t, n);
228
- l && R(i, n, l._f);
229
+ l && N(i, n, l._f);
229
230
  }
230
231
  return {
231
232
  criteriaMode: r,
@@ -233,53 +234,53 @@ var tr = (e, t, r, s) => {
233
234
  fields: i,
234
235
  shouldUseNativeValidation: s
235
236
  };
236
- }, We = (e) => e instanceof RegExp, Oe = (e) => C(e) ? e : We(e) ? e.source : I(e) ? We(e.value) ? e.value.source : e.value : e, pt = (e) => ({
237
+ }, Ke = (e) => e instanceof RegExp, Ce = (e) => T(e) ? e : Ke(e) ? e.source : U(e) ? Ke(e.value) ? e.value.source : e.value : e, wt = (e) => ({
237
238
  isOnSubmit: !e || e === se.onSubmit,
238
239
  isOnBlur: e === se.onBlur,
239
240
  isOnChange: e === se.onChange,
240
241
  isOnAll: e === se.all,
241
242
  isOnTouch: e === se.onTouched
242
243
  });
243
- const bt = "AsyncFunction";
244
- var rr = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === bt || I(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === bt)), sr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), wt = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
245
- const Te = (e, t, r, s) => {
244
+ const vt = "AsyncFunction";
245
+ var sr = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === vt || U(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === vt)), ir = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Ft = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
246
+ const Le = (e, t, r, s) => {
246
247
  for (const i of r || Object.keys(e)) {
247
248
  const n = g(e, i);
248
249
  if (n) {
249
- const { _f: l, ...d } = n;
250
+ const { _f: l, ...f } = n;
250
251
  if (l) {
251
252
  if (l.refs && l.refs[0] && t(l.refs[0], i) && !s)
252
253
  return !0;
253
254
  if (l.ref && t(l.ref, l.name) && !s)
254
255
  return !0;
255
- if (Te(d, t))
256
+ if (Le(f, t))
256
257
  break;
257
- } else if (I(d) && Te(d, t))
258
+ } else if (U(f) && Le(f, t))
258
259
  break;
259
260
  }
260
261
  }
261
262
  };
262
- function vt(e, t, r) {
263
+ function Vt(e, t, r) {
263
264
  const s = g(e, r);
264
- if (s || He(r))
265
+ if (s || ze(r))
265
266
  return {
266
267
  error: s,
267
268
  name: r
268
269
  };
269
270
  const i = r.split(".");
270
271
  for (; i.length; ) {
271
- const n = i.join("."), l = g(t, n), d = g(e, n);
272
+ const n = i.join("."), l = g(t, n), f = g(e, n);
272
273
  if (l && !Array.isArray(l) && r !== n)
273
274
  return { name: r };
274
- if (d && d.type)
275
+ if (f && f.type)
275
276
  return {
276
277
  name: n,
277
- error: d
278
+ error: f
278
279
  };
279
- if (d && d.root && d.root.type)
280
+ if (f && f.root && f.root.type)
280
281
  return {
281
282
  name: `${n}.root`,
282
- error: d.root
283
+ error: f.root
283
284
  };
284
285
  i.pop();
285
286
  }
@@ -287,15 +288,15 @@ function vt(e, t, r) {
287
288
  name: r
288
289
  };
289
290
  }
290
- var ir = (e, t, r, s) => {
291
+ var ar = (e, t, r, s) => {
291
292
  r(e);
292
293
  const { name: i, ...n } = e;
293
- return Y(n) || Object.keys(n).length >= Object.keys(t).length || Object.keys(n).find((l) => t[l] === (!s || se.all));
294
- }, ar = (e, t, r) => !e || !t || e === t || Ce(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), nr = (e, t, r, s, i) => i.isOnAll ? !1 : !r && i.isOnTouch ? !(t || e) : (r ? s.isOnBlur : i.isOnBlur) ? !e : (r ? s.isOnChange : i.isOnChange) ? e : !0, or = (e, t) => !st(g(e, t)).length && M(e, t), ur = (e, t, r) => {
295
- const s = Ce(g(e, r));
296
- return R(s, "root", t[r]), R(e, r, s), e;
294
+ return H(n) || Object.keys(n).length >= Object.keys(t).length || Object.keys(n).find((l) => t[l] === (!s || se.all));
295
+ }, nr = (e, t, r) => !e || !t || e === t || Te(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), ur = (e, t, r, s, i) => i.isOnAll ? !1 : !r && i.isOnTouch ? !(t || e) : (r ? s.isOnBlur : i.isOnBlur) ? !e : (r ? s.isOnChange : i.isOnChange) ? e : !0, or = (e, t) => !at(g(e, t)).length && k(e, t), lr = (e, t, r) => {
296
+ const s = Te(g(e, r));
297
+ return N(s, "root", t[r]), N(e, r, s), e;
297
298
  };
298
- function Ft(e, t, r = "validate") {
299
+ function Et(e, t, r = "validate") {
299
300
  if (Q(e) || Array.isArray(e) && e.every(Q) || ie(e) && !e)
300
301
  return {
301
302
  type: r,
@@ -303,98 +304,98 @@ function Ft(e, t, r = "validate") {
303
304
  ref: t
304
305
  };
305
306
  }
306
- var ve = (e) => I(e) && !We(e) ? e : {
307
+ var Fe = (e) => U(e) && !Ke(e) ? e : {
307
308
  value: e,
308
309
  message: ""
309
- }, Vt = async (e, t, r, s, i, n) => {
310
- const { ref: l, refs: d, required: w, maxLength: p, minLength: N, min: D, max: v, pattern: m, validate: K, name: O, valueAsNumber: Z, mount: H } = e._f, x = g(r, O);
311
- if (!H || t.has(O))
310
+ }, At = async (e, t, r, s, i, n) => {
311
+ const { ref: l, refs: f, required: w, maxLength: b, minLength: O, min: D, max: v, pattern: m, validate: Y, name: C, valueAsNumber: Z, mount: W } = e._f, A = g(r, C);
312
+ if (!W || t.has(C))
312
313
  return {};
313
- const ee = d ? d[0] : l, L = (V) => {
314
+ const ee = f ? f[0] : l, M = (V) => {
314
315
  i && ee.reportValidity && (ee.setCustomValidity(ie(V) ? "" : V || ""), ee.reportValidity());
315
- }, T = {}, ue = nt(l), he = Le(l), ae = ue || he, ne = (Z || at(l)) && C(l.value) && C(x) || je(l) && l.value === "" || x === "" || Array.isArray(x) && !x.length, B = Gt.bind(null, O, s, T), le = (V, E, S, U = oe.maxLength, $ = oe.minLength) => {
316
- const j = V ? E : S;
317
- T[O] = {
318
- type: V ? U : $,
319
- message: j,
316
+ }, L = {}, le = ot(l), ye = Me(l), ae = le || ye, ne = (Z || ut(l)) && T(l.value) && T(A) || Ye(l) && l.value === "" || A === "" || Array.isArray(A) && !A.length, j = Xt.bind(null, C, s, L), ce = (V, x, S, I = oe.maxLength, G = oe.minLength) => {
317
+ const q = V ? x : S;
318
+ L[C] = {
319
+ type: V ? I : G,
320
+ message: q,
320
321
  ref: l,
321
- ...B(V ? U : $, j)
322
+ ...j(V ? I : G, q)
322
323
  };
323
324
  };
324
- if (n ? !Array.isArray(x) || !x.length : w && (!ae && (ne || G(x)) || ie(x) && !x || he && !Ct(d).isValid || ue && !Lt(d).isValid)) {
325
- const { value: V, message: E } = Q(w) ? { value: !!w, message: w } : ve(w);
326
- if (V && (T[O] = {
325
+ if (n ? !Array.isArray(A) || !A.length : w && (!ae && (ne || J(A)) || ie(A) && !A || ye && !Lt(f).isValid || le && !It(f).isValid)) {
326
+ const { value: V, message: x } = Q(w) ? { value: !!w, message: w } : Fe(w);
327
+ if (V && (L[C] = {
327
328
  type: oe.required,
328
- message: E,
329
+ message: x,
329
330
  ref: ee,
330
- ...B(oe.required, E)
331
+ ...j(oe.required, x)
331
332
  }, !s))
332
- return L(E), T;
333
+ return M(x), L;
333
334
  }
334
- if (!ne && (!G(D) || !G(v))) {
335
- let V, E;
336
- const S = ve(v), U = ve(D);
337
- if (!G(x) && !isNaN(x)) {
338
- const $ = l.valueAsNumber || x && +x;
339
- G(S.value) || (V = $ > S.value), G(U.value) || (E = $ < U.value);
335
+ if (!ne && (!J(D) || !J(v))) {
336
+ let V, x;
337
+ const S = Fe(v), I = Fe(D);
338
+ if (!J(A) && !isNaN(A)) {
339
+ const G = l.valueAsNumber || A && +A;
340
+ J(S.value) || (V = G > S.value), J(I.value) || (x = G < I.value);
340
341
  } else {
341
- const $ = l.valueAsDate || new Date(x), j = (me) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + me), z = l.type == "time", ce = l.type == "week";
342
- Q(S.value) && x && (V = z ? j(x) > j(S.value) : ce ? x > S.value : $ > new Date(S.value)), Q(U.value) && x && (E = z ? j(x) < j(U.value) : ce ? x < U.value : $ < new Date(U.value));
342
+ const G = l.valueAsDate || new Date(A), q = (fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + fe), de = l.type == "time", K = l.type == "week";
343
+ Q(S.value) && A && (V = de ? q(A) > q(S.value) : K ? A > S.value : G > new Date(S.value)), Q(I.value) && A && (x = de ? q(A) < q(I.value) : K ? A < I.value : G < new Date(I.value));
343
344
  }
344
- if ((V || E) && (le(!!V, S.message, U.message, oe.max, oe.min), !s))
345
- return L(T[O].message), T;
345
+ if ((V || x) && (ce(!!V, S.message, I.message, oe.max, oe.min), !s))
346
+ return M(L[C].message), L;
346
347
  }
347
- if ((p || N) && !ne && (Q(x) || n && Array.isArray(x))) {
348
- const V = ve(p), E = ve(N), S = !G(V.value) && x.length > +V.value, U = !G(E.value) && x.length < +E.value;
349
- if ((S || U) && (le(S, V.message, E.message), !s))
350
- return L(T[O].message), T;
348
+ if ((b || O) && !ne && (Q(A) || n && Array.isArray(A))) {
349
+ const V = Fe(b), x = Fe(O), S = !J(V.value) && A.length > +V.value, I = !J(x.value) && A.length < +x.value;
350
+ if ((S || I) && (ce(S, V.message, x.message), !s))
351
+ return M(L[C].message), L;
351
352
  }
352
- if (m && !ne && Q(x)) {
353
- const { value: V, message: E } = ve(m);
354
- if (We(V) && !x.match(V) && (T[O] = {
353
+ if (m && !ne && Q(A)) {
354
+ const { value: V, message: x } = Fe(m);
355
+ if (Ke(V) && !A.match(V) && (L[C] = {
355
356
  type: oe.pattern,
356
- message: E,
357
+ message: x,
357
358
  ref: l,
358
- ...B(oe.pattern, E)
359
+ ...j(oe.pattern, x)
359
360
  }, !s))
360
- return L(E), T;
361
+ return M(x), L;
361
362
  }
362
- if (K) {
363
- if (re(K)) {
364
- const V = await K(x, r), E = Ft(V, ee);
365
- if (E && (T[O] = {
366
- ...E,
367
- ...B(oe.validate, E.message)
363
+ if (Y) {
364
+ if (re(Y)) {
365
+ const V = await Y(A, r), x = Et(V, ee);
366
+ if (x && (L[C] = {
367
+ ...x,
368
+ ...j(oe.validate, x.message)
368
369
  }, !s))
369
- return L(E.message), T;
370
- } else if (I(K)) {
370
+ return M(x.message), L;
371
+ } else if (U(Y)) {
371
372
  let V = {};
372
- for (const E in K) {
373
- if (!Y(V) && !s)
373
+ for (const x in Y) {
374
+ if (!H(V) && !s)
374
375
  break;
375
- const S = Ft(await K[E](x, r), ee, E);
376
+ const S = Et(await Y[x](A, r), ee, x);
376
377
  S && (V = {
377
378
  ...S,
378
- ...B(E, S.message)
379
- }, L(S.message), s && (T[O] = V));
379
+ ...j(x, S.message)
380
+ }, M(S.message), s && (L[C] = V));
380
381
  }
381
- if (!Y(V) && (T[O] = {
382
+ if (!H(V) && (L[C] = {
382
383
  ref: ee,
383
384
  ...V
384
385
  }, !s))
385
- return T;
386
+ return L;
386
387
  }
387
388
  }
388
- return L(!0), T;
389
+ return M(!0), L;
389
390
  };
390
- const lr = {
391
+ const cr = {
391
392
  mode: se.onSubmit,
392
393
  reValidateMode: se.onChange,
393
394
  shouldFocusError: !0
394
395
  };
395
- function cr(e = {}) {
396
+ function dr(e = {}) {
396
397
  let t = {
397
- ...lr,
398
+ ...cr,
398
399
  ...e
399
400
  }, r = {
400
401
  submitCount: 0,
@@ -411,19 +412,19 @@ function cr(e = {}) {
411
412
  validatingFields: {},
412
413
  errors: t.errors || {},
413
414
  disabled: t.disabled || !1
414
- }, s = {}, i = I(t.defaultValues) || I(t.values) ? k(t.defaultValues || t.values) || {} : {}, n = t.shouldUnregister ? {} : k(i), l = {
415
+ }, s = {}, i = U(t.defaultValues) || U(t.values) ? P(t.defaultValues || t.values) || {} : {}, n = t.shouldUnregister ? {} : P(i), l = {
415
416
  action: !1,
416
417
  mount: !1,
417
418
  watch: !1,
418
419
  keepIsValid: !1
419
- }, d = {
420
+ }, f = {
420
421
  mount: /* @__PURE__ */ new Set(),
421
422
  disabled: /* @__PURE__ */ new Set(),
422
423
  unMount: /* @__PURE__ */ new Set(),
423
424
  array: /* @__PURE__ */ new Set(),
424
425
  watch: /* @__PURE__ */ new Set()
425
- }, w, p = 0;
426
- const N = {
426
+ }, w, b = 0;
427
+ const O = {
427
428
  isDirty: !1,
428
429
  dirtyFields: !1,
429
430
  validatingFields: !1,
@@ -432,45 +433,45 @@ function cr(e = {}) {
432
433
  isValid: !1,
433
434
  errors: !1
434
435
  }, D = {
435
- ...N
436
+ ...O
436
437
  };
437
438
  let v = {
438
439
  ...D
439
440
  };
440
441
  const m = {
441
- array: ft(),
442
- state: ft()
443
- }, K = t.criteriaMode === se.all, O = (a) => (o) => {
444
- clearTimeout(p), p = setTimeout(a, o);
442
+ array: mt(),
443
+ state: mt()
444
+ }, Y = t.criteriaMode === se.all, C = (a) => (o) => {
445
+ clearTimeout(b), b = setTimeout(a, o);
445
446
  }, Z = async (a) => {
446
447
  if (!l.keepIsValid && !t.disabled && (D.isValid || v.isValid || a)) {
447
448
  let o;
448
- t.resolver ? (o = Y((await ae()).errors), H()) : o = await B(s, !0), o !== r.isValid && m.state.next({
449
+ t.resolver ? (o = H((await ae()).errors), W()) : o = await j(s, !0), o !== r.isValid && m.state.next({
449
450
  isValid: o
450
451
  });
451
452
  }
452
- }, H = (a, o) => {
453
- !t.disabled && (D.isValidating || D.validatingFields || v.isValidating || v.validatingFields) && ((a || Array.from(d.mount)).forEach((u) => {
454
- u && (o ? R(r.validatingFields, u, o) : M(r.validatingFields, u));
453
+ }, W = (a, o) => {
454
+ !t.disabled && (D.isValidating || D.validatingFields || v.isValidating || v.validatingFields) && ((a || Array.from(f.mount)).forEach((u) => {
455
+ u && (o ? N(r.validatingFields, u, o) : k(r.validatingFields, u));
455
456
  }), m.state.next({
456
457
  validatingFields: r.validatingFields,
457
- isValidating: !Y(r.validatingFields)
458
+ isValidating: !H(r.validatingFields)
458
459
  }));
459
- }, x = (a, o = [], u, f, h = !0, c = !0) => {
460
- if (f && u && !t.disabled) {
461
- if (l.action = !0, c && Array.isArray(g(s, a))) {
462
- const y = u(g(s, a), f.argA, f.argB);
463
- h && R(s, a, y);
460
+ }, A = (a, o = [], u, h, c = !0, d = !0) => {
461
+ if (h && u && !t.disabled) {
462
+ if (l.action = !0, d && Array.isArray(g(s, a))) {
463
+ const y = u(g(s, a), h.argA, h.argB);
464
+ c && N(s, a, y);
464
465
  }
465
- if (c && Array.isArray(g(r.errors, a))) {
466
- const y = u(g(r.errors, a), f.argA, f.argB);
467
- h && R(r.errors, a, y), or(r.errors, a);
466
+ if (d && Array.isArray(g(r.errors, a))) {
467
+ const y = u(g(r.errors, a), h.argA, h.argB);
468
+ c && N(r.errors, a, y), or(r.errors, a);
468
469
  }
469
- if ((D.touchedFields || v.touchedFields) && c && Array.isArray(g(r.touchedFields, a))) {
470
- const y = u(g(r.touchedFields, a), f.argA, f.argB);
471
- h && R(r.touchedFields, a, y);
470
+ if ((D.touchedFields || v.touchedFields) && d && Array.isArray(g(r.touchedFields, a))) {
471
+ const y = u(g(r.touchedFields, a), h.argA, h.argB);
472
+ c && N(r.touchedFields, a, y);
472
473
  }
473
- (D.dirtyFields || v.dirtyFields) && (r.dirtyFields = Fe(i, n)), m.state.next({
474
+ (D.dirtyFields || v.dirtyFields) && (r.dirtyFields = Ee(i, n)), m.state.next({
474
475
  name: a,
475
476
  isDirty: V(a, o),
476
477
  dirtyFields: r.dirtyFields,
@@ -478,46 +479,46 @@ function cr(e = {}) {
478
479
  isValid: r.isValid
479
480
  });
480
481
  } else
481
- R(n, a, o);
482
+ N(n, a, o);
482
483
  }, ee = (a, o) => {
483
- R(r.errors, a, o), m.state.next({
484
+ N(r.errors, a, o), m.state.next({
484
485
  errors: r.errors
485
486
  });
486
- }, L = (a) => {
487
+ }, M = (a) => {
487
488
  r.errors = a, m.state.next({
488
489
  errors: r.errors,
489
490
  isValid: !1
490
491
  });
491
- }, T = (a, o, u, f) => {
492
- const h = g(s, a);
493
- if (h) {
494
- const c = g(n, a, C(u) ? g(i, a) : u);
495
- C(c) || f && f.defaultChecked || o ? R(n, a, o ? c : gt(h._f)) : U(a, c), l.mount && !l.action && Z();
492
+ }, L = (a, o, u, h) => {
493
+ const c = g(s, a);
494
+ if (c) {
495
+ const d = g(n, a, T(u) ? g(i, a) : u);
496
+ T(d) || h && h.defaultChecked || o ? N(n, a, o ? d : bt(c._f)) : I(a, d), l.mount && !l.action && Z();
496
497
  }
497
- }, ue = (a, o, u, f, h) => {
498
- let c = !1, y = !1;
499
- const F = {
498
+ }, le = (a, o, u, h, c) => {
499
+ let d = !1, y = !1;
500
+ const p = {
500
501
  name: a
501
502
  };
502
503
  if (!t.disabled) {
503
- if (!u || f) {
504
- (D.isDirty || v.isDirty) && (y = r.isDirty, r.isDirty = F.isDirty = V(), c = y !== F.isDirty);
505
- const b = de(g(i, a), o);
506
- y = !!g(r.dirtyFields, a), b ? M(r.dirtyFields, a) : R(r.dirtyFields, a, !0), F.dirtyFields = r.dirtyFields, c = c || (D.dirtyFields || v.dirtyFields) && y !== !b;
504
+ if (!u || h) {
505
+ (D.isDirty || v.isDirty) && (y = r.isDirty, r.isDirty = p.isDirty = V(), d = y !== p.isDirty);
506
+ const F = he(g(i, a), o);
507
+ y = !!g(r.dirtyFields, a), F ? k(r.dirtyFields, a) : N(r.dirtyFields, a, !0), p.dirtyFields = r.dirtyFields, d = d || (D.dirtyFields || v.dirtyFields) && y !== !F;
507
508
  }
508
509
  if (u) {
509
- const b = g(r.touchedFields, a);
510
- b || (R(r.touchedFields, a, u), F.touchedFields = r.touchedFields, c = c || (D.touchedFields || v.touchedFields) && b !== u);
510
+ const F = g(r.touchedFields, a);
511
+ F || (N(r.touchedFields, a, u), p.touchedFields = r.touchedFields, d = d || (D.touchedFields || v.touchedFields) && F !== u);
511
512
  }
512
- c && h && m.state.next(F);
513
+ d && c && m.state.next(p);
513
514
  }
514
- return c ? F : {};
515
- }, he = (a, o, u, f) => {
516
- const h = g(r.errors, a), c = (D.isValid || v.isValid) && ie(o) && r.isValid !== o;
517
- if (t.delayError && u ? (w = O(() => ee(a, u)), w(t.delayError)) : (clearTimeout(p), w = null, u ? R(r.errors, a, u) : M(r.errors, a)), (u ? !de(h, u) : h) || !Y(f) || c) {
515
+ return d ? p : {};
516
+ }, ye = (a, o, u, h) => {
517
+ const c = g(r.errors, a), d = (D.isValid || v.isValid) && ie(o) && r.isValid !== o;
518
+ if (t.delayError && u ? (w = C(() => ee(a, u)), w(t.delayError)) : (clearTimeout(b), w = null, u ? N(r.errors, a, u) : k(r.errors, a)), (u ? !he(c, u) : c) || !H(h) || d) {
518
519
  const y = {
519
- ...f,
520
- ...c && ie(o) ? { isValid: o } : {},
520
+ ...h,
521
+ ...d && ie(o) ? { isValid: o } : {},
521
522
  errors: r.errors,
522
523
  name: a
523
524
  };
@@ -526,187 +527,187 @@ function cr(e = {}) {
526
527
  ...y
527
528
  }, m.state.next(y);
528
529
  }
529
- }, ae = async (a) => (H(a, !0), await t.resolver(n, t.context, tr(a || d.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), ne = async (a) => {
530
+ }, ae = async (a) => (W(a, !0), await t.resolver(n, t.context, rr(a || f.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), ne = async (a) => {
530
531
  const { errors: o } = await ae(a);
531
- if (H(a), a)
532
+ if (W(a), a)
532
533
  for (const u of a) {
533
- const f = g(o, u);
534
- f ? R(r.errors, u, f) : M(r.errors, u);
534
+ const h = g(o, u);
535
+ h ? N(r.errors, u, h) : k(r.errors, u);
535
536
  }
536
537
  else
537
538
  r.errors = o;
538
539
  return o;
539
- }, B = async (a, o, u = {
540
+ }, j = async (a, o, u = {
540
541
  valid: !0
541
542
  }) => {
542
- for (const f in a) {
543
- const h = a[f];
544
- if (h) {
545
- const { _f: c, ...y } = h;
546
- if (c) {
547
- const F = d.array.has(c.name), b = h._f && rr(h._f);
548
- b && D.validatingFields && H([c.name], !0);
549
- const _ = await Vt(h, d.disabled, n, K, t.shouldUseNativeValidation && !o, F);
550
- if (b && D.validatingFields && H([c.name]), _[c.name] && (u.valid = !1, o || e.shouldUseNativeValidation))
543
+ for (const h in a) {
544
+ const c = a[h];
545
+ if (c) {
546
+ const { _f: d, ...y } = c;
547
+ if (d) {
548
+ const p = f.array.has(d.name), F = c._f && sr(c._f);
549
+ F && D.validatingFields && W([d.name], !0);
550
+ const _ = await At(c, f.disabled, n, Y, t.shouldUseNativeValidation && !o, p);
551
+ if (F && D.validatingFields && W([d.name]), _[d.name] && (u.valid = !1, o || e.shouldUseNativeValidation))
551
552
  break;
552
- !o && (g(_, c.name) ? F ? ur(r.errors, _, c.name) : R(r.errors, c.name, _[c.name]) : M(r.errors, c.name));
553
+ !o && (g(_, d.name) ? p ? lr(r.errors, _, d.name) : N(r.errors, d.name, _[d.name]) : k(r.errors, d.name));
553
554
  }
554
- !Y(y) && await B(y, o, u);
555
+ !H(y) && await j(y, o, u);
555
556
  }
556
557
  }
557
558
  return u.valid;
558
- }, le = () => {
559
- for (const a of d.unMount) {
559
+ }, ce = () => {
560
+ for (const a of f.unMount) {
560
561
  const o = g(s, a);
561
- o && (o._f.refs ? o._f.refs.every((u) => !Qe(u)) : !Qe(o._f.ref)) && xe(a);
562
+ o && (o._f.refs ? o._f.refs.every((u) => !et(u)) : !et(o._f.ref)) && xe(a);
562
563
  }
563
- d.unMount = /* @__PURE__ */ new Set();
564
- }, V = (a, o) => !t.disabled && (a && o && R(n, a, o), !de(Me(), i)), E = (a, o, u) => Jt(a, d, {
565
- ...l.mount ? n : C(o) ? i : Q(a) ? { [a]: o } : o
566
- }, u, o), S = (a) => st(g(l.mount ? n : i, a, t.shouldUnregister ? g(i, a, []) : [])), U = (a, o, u = {}) => {
567
- const f = g(s, a);
568
- let h = o;
569
- if (f) {
570
- const c = f._f;
571
- c && (!c.disabled && R(n, a, Tt(o, c)), h = je(c.ref) && G(o) ? "" : o, Nt(c.ref) ? [...c.ref.options].forEach((y) => y.selected = h.includes(y.value)) : c.refs ? Le(c.ref) ? c.refs.forEach((y) => {
572
- (!y.defaultChecked || !y.disabled) && (Array.isArray(h) ? y.checked = !!h.find((F) => F === y.value) : y.checked = h === y.value || !!h);
573
- }) : c.refs.forEach((y) => y.checked = y.value === h) : at(c.ref) ? c.ref.value = "" : (c.ref.value = h, c.ref.type || m.state.next({
564
+ f.unMount = /* @__PURE__ */ new Set();
565
+ }, V = (a, o) => !t.disabled && (a && o && N(n, a, o), !he(Ie(), i)), x = (a, o, u) => Gt(a, f, {
566
+ ...l.mount ? n : T(o) ? i : Q(a) ? { [a]: o } : o
567
+ }, u, o), S = (a) => at(g(l.mount ? n : i, a, t.shouldUnregister ? g(i, a, []) : [])), I = (a, o, u = {}) => {
568
+ const h = g(s, a);
569
+ let c = o;
570
+ if (h) {
571
+ const d = h._f;
572
+ d && (!d.disabled && N(n, a, Mt(o, d)), c = Ye(d.ref) && J(o) ? "" : o, Ct(d.ref) ? [...d.ref.options].forEach((y) => y.selected = c.includes(y.value)) : d.refs ? Me(d.ref) ? d.refs.forEach((y) => {
573
+ (!y.defaultChecked || !y.disabled) && (Array.isArray(c) ? y.checked = !!c.find((p) => p === y.value) : y.checked = c === y.value || !!c);
574
+ }) : d.refs.forEach((y) => y.checked = y.value === c) : ut(d.ref) ? d.ref.value = "" : (d.ref.value = c, d.ref.type || m.state.next({
574
575
  name: a,
575
- values: k(n)
576
+ values: P(n)
576
577
  })));
577
578
  }
578
- (u.shouldDirty || u.shouldTouch) && ue(a, h, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && me(a);
579
- }, $ = (a, o, u) => {
580
- for (const f in o) {
581
- if (!o.hasOwnProperty(f))
579
+ (u.shouldDirty || u.shouldTouch) && le(a, c, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && fe(a);
580
+ }, G = (a, o, u) => {
581
+ for (const h in o) {
582
+ if (!o.hasOwnProperty(h))
582
583
  return;
583
- const h = o[f], c = a + "." + f, y = g(s, c);
584
- (d.array.has(a) || I(h) || y && !y._f) && !ge(h) ? $(c, h, u) : U(c, h, u);
584
+ const c = o[h], d = a + "." + h, y = g(s, d);
585
+ (f.array.has(a) || U(c) || y && !y._f) && !pe(c) ? G(d, c, u) : I(d, c, u);
585
586
  }
586
- }, j = (a, o, u = {}) => {
587
- const f = g(s, a), h = d.array.has(a), c = k(o);
588
- R(n, a, c), h ? (m.array.next({
587
+ }, q = (a, o, u = {}) => {
588
+ const h = g(s, a), c = f.array.has(a), d = P(o);
589
+ N(n, a, d), c ? (m.array.next({
589
590
  name: a,
590
- values: k(n)
591
+ values: P(n)
591
592
  }), (D.isDirty || D.dirtyFields || v.isDirty || v.dirtyFields) && u.shouldDirty && m.state.next({
592
593
  name: a,
593
- dirtyFields: Fe(i, n),
594
- isDirty: V(a, c)
595
- })) : f && !f._f && !G(c) ? $(a, c, u) : U(a, c, u), wt(a, d) ? m.state.next({
594
+ dirtyFields: Ee(i, n),
595
+ isDirty: V(a, d)
596
+ })) : h && !h._f && !J(d) ? G(a, d, u) : I(a, d, u), Ft(a, f) ? m.state.next({
596
597
  ...r,
597
598
  name: a,
598
- values: k(n)
599
+ values: P(n)
599
600
  }) : m.state.next({
600
601
  name: l.mount ? a : void 0,
601
- values: k(n)
602
+ values: P(n)
602
603
  });
603
- }, z = async (a) => {
604
+ }, de = async (a) => {
604
605
  l.mount = !0;
605
606
  const o = a.target;
606
- let u = o.name, f = !0;
607
- const h = g(s, u), c = (b) => {
608
- f = Number.isNaN(b) || ge(b) && isNaN(b.getTime()) || de(b, g(n, u, b));
609
- }, y = pt(t.mode), F = pt(t.reValidateMode);
610
- if (h) {
611
- let b, _;
612
- const P = o.type ? gt(h._f) : $t(a), W = a.type === dt.BLUR || a.type === dt.FOCUS_OUT, q = !sr(h._f) && !t.resolver && !g(r.errors, u) && !h._f.deps || nr(W, g(r.touchedFields, u), r.isSubmitted, F, y), J = wt(u, d, W);
613
- R(n, u, P), W ? (!o || !o.readOnly) && (h._f.onBlur && h._f.onBlur(a), w && w(0)) : h._f.onChange && h._f.onChange(a);
614
- const be = ue(u, P, W), ut = !Y(be) || J;
615
- if (!W && m.state.next({
607
+ let u = o.name, h = !0;
608
+ const c = g(s, u), d = (F) => {
609
+ h = Number.isNaN(F) || pe(F) && isNaN(F.getTime()) || he(F, g(n, u, F));
610
+ }, y = wt(t.mode), p = wt(t.reValidateMode);
611
+ if (c) {
612
+ let F, _;
613
+ const R = o.type ? bt(c._f) : jt(a), $ = a.type === ht.BLUR || a.type === ht.FOCUS_OUT, ue = !ir(c._f) && !t.resolver && !g(r.errors, u) && !c._f.deps || ur($, g(r.touchedFields, u), r.isSubmitted, p, y), B = Ft(u, f, $);
614
+ N(n, u, R), $ ? (!o || !o.readOnly) && (c._f.onBlur && c._f.onBlur(a), w && w(0)) : c._f.onChange && c._f.onChange(a);
615
+ const z = le(u, R, $), We = !H(z) || B;
616
+ if (!$ && m.state.next({
616
617
  name: u,
617
618
  type: a.type,
618
- values: k(n)
619
- }), q)
620
- return (D.isValid || v.isValid) && (t.mode === "onBlur" ? W && Z() : W || Z()), ut && m.state.next({ name: u, ...J ? {} : be });
621
- if (!W && J && m.state.next({ ...r }), t.resolver) {
622
- const { errors: Xe } = await ae([u]);
623
- if (H([u]), c(P), f) {
624
- const Ut = vt(r.errors, s, u), lt = vt(Xe, s, Ut.name || u);
625
- b = lt.error, u = lt.name, _ = Y(Xe);
619
+ values: P(n)
620
+ }), ue)
621
+ return (D.isValid || v.isValid) && (t.mode === "onBlur" ? $ && Z() : $ || Z()), We && m.state.next({ name: u, ...B ? {} : z });
622
+ if (!$ && B && m.state.next({ ...r }), t.resolver) {
623
+ const { errors: Ze } = await ae([u]);
624
+ if (W([u]), d(R), h) {
625
+ const ct = Vt(r.errors, s, u), dt = Vt(Ze, s, ct.name || u);
626
+ F = dt.error, u = dt.name, _ = H(Ze);
626
627
  }
627
628
  } else
628
- H([u], !0), b = (await Vt(h, d.disabled, n, K, t.shouldUseNativeValidation))[u], H([u]), c(P), f && (b ? _ = !1 : (D.isValid || v.isValid) && (_ = await B(s, !0)));
629
- f && (h._f.deps && (!Array.isArray(h._f.deps) || h._f.deps.length > 0) && me(h._f.deps), he(u, _, b, be));
629
+ W([u], !0), F = (await At(c, f.disabled, n, Y, t.shouldUseNativeValidation))[u], W([u]), d(R), h && (F ? _ = !1 : (D.isValid || v.isValid) && (_ = await j(s, !0)));
630
+ h && (c._f.deps && (!Array.isArray(c._f.deps) || c._f.deps.length > 0) && fe(c._f.deps), ye(u, _, F, z));
630
631
  }
631
- }, ce = (a, o) => {
632
+ }, K = (a, o) => {
632
633
  if (g(r.errors, o) && a.focus)
633
634
  return a.focus(), 1;
634
- }, me = async (a, o = {}) => {
635
- let u, f;
636
- const h = Ce(a);
635
+ }, fe = async (a, o = {}) => {
636
+ let u, h;
637
+ const c = Te(a);
637
638
  if (t.resolver) {
638
- const c = await ne(C(a) ? a : h);
639
- u = Y(c), f = a ? !h.some((y) => g(c, y)) : u;
640
- } else a ? (f = (await Promise.all(h.map(async (c) => {
641
- const y = g(s, c);
642
- return await B(y && y._f ? { [c]: y } : y);
643
- }))).every(Boolean), !(!f && !r.isValid) && Z()) : f = u = await B(s);
639
+ const d = await ne(T(a) ? a : c);
640
+ u = H(d), h = a ? !c.some((y) => g(d, y)) : u;
641
+ } else a ? (h = (await Promise.all(c.map(async (d) => {
642
+ const y = g(s, d);
643
+ return await j(y && y._f ? { [d]: y } : y);
644
+ }))).every(Boolean), !(!h && !r.isValid) && Z()) : h = u = await j(s);
644
645
  return m.state.next({
645
646
  ...!Q(a) || (D.isValid || v.isValid) && u !== r.isValid ? {} : { name: a },
646
647
  ...t.resolver || !a ? { isValid: u } : {},
647
648
  errors: r.errors
648
- }), o.shouldFocus && !f && Te(s, ce, a ? h : d.mount), f;
649
- }, Me = (a, o) => {
649
+ }), o.shouldFocus && !h && Le(s, K, a ? c : f.mount), h;
650
+ }, Ie = (a, o) => {
650
651
  let u = {
651
652
  ...l.mount ? n : i
652
653
  };
653
- return o && (u = Rt(o.dirtyFields ? r.dirtyFields : r.touchedFields, u)), C(a) ? u : Q(a) ? g(u, a) : a.map((f) => g(u, f));
654
- }, A = (a, o) => ({
654
+ return o && (u = Ot(o.dirtyFields ? r.dirtyFields : r.touchedFields, u)), T(a) ? u : Q(a) ? g(u, a) : a.map((h) => g(u, h));
655
+ }, ke = (a, o) => ({
655
656
  invalid: !!g((o || r).errors, a),
656
657
  isDirty: !!g((o || r).dirtyFields, a),
657
658
  error: g((o || r).errors, a),
658
659
  isValidating: !!g(r.validatingFields, a),
659
660
  isTouched: !!g((o || r).touchedFields, a)
660
- }), Ee = (a) => {
661
- a && Ce(a).forEach((o) => M(r.errors, o)), m.state.next({
661
+ }), E = (a) => {
662
+ a && Te(a).forEach((o) => k(r.errors, o)), m.state.next({
662
663
  errors: a ? r.errors : {}
663
664
  });
664
- }, Ae = (a, o, u) => {
665
- const f = (g(s, a, { _f: {} })._f || {}).ref, h = g(r.errors, a) || {}, { ref: c, message: y, type: F, ...b } = h;
666
- R(r.errors, a, {
667
- ...b,
665
+ }, we = (a, o, u) => {
666
+ const h = (g(s, a, { _f: {} })._f || {}).ref, c = g(r.errors, a) || {}, { ref: d, message: y, type: p, ...F } = c;
667
+ N(r.errors, a, {
668
+ ...F,
668
669
  ...o,
669
- ref: f
670
+ ref: h
670
671
  }), m.state.next({
671
672
  name: a,
672
673
  errors: r.errors,
673
674
  isValid: !1
674
- }), u && u.shouldFocus && f && f.focus && f.focus();
675
- }, Ye = (a, o) => re(a) ? m.state.subscribe({
676
- next: (u) => "values" in u && a(E(void 0, o), u)
677
- }) : E(a, o, !0), Ie = (a) => m.state.subscribe({
675
+ }), u && u.shouldFocus && h && h.focus && h.focus();
676
+ }, Ue = (a, o) => re(a) ? m.state.subscribe({
677
+ next: (u) => "values" in u && a(x(void 0, o), u)
678
+ }) : x(a, o, !0), Be = (a) => m.state.subscribe({
678
679
  next: (o) => {
679
- ar(a.name, o.name, a.exact) && ir(o, a.formState || D, Ge, a.reRenderRoot) && a.callback({
680
+ nr(a.name, o.name, a.exact) && ar(o, a.formState || D, Qe, a.reRenderRoot) && a.callback({
680
681
  values: { ...n },
681
682
  ...r,
682
683
  ...o,
683
684
  defaultValues: i
684
685
  });
685
686
  }
686
- }).unsubscribe, Ke = (a) => (l.mount = !0, v = {
687
+ }).unsubscribe, Je = (a) => (l.mount = !0, v = {
687
688
  ...v,
688
689
  ...a.formState
689
- }, Ie({
690
+ }, Be({
690
691
  ...a,
691
692
  formState: {
692
- ...N,
693
+ ...O,
693
694
  ...a.formState
694
695
  }
695
696
  })), xe = (a, o = {}) => {
696
- for (const u of a ? Ce(a) : d.mount)
697
- d.mount.delete(u), d.array.delete(u), o.keepValue || (M(s, u), M(n, u)), !o.keepError && M(r.errors, u), !o.keepDirty && M(r.dirtyFields, u), !o.keepTouched && M(r.touchedFields, u), !o.keepIsValidating && M(r.validatingFields, u), !t.shouldUnregister && !o.keepDefaultValue && M(i, u);
697
+ for (const u of a ? Te(a) : f.mount)
698
+ f.mount.delete(u), f.array.delete(u), o.keepValue || (k(s, u), k(n, u)), !o.keepError && k(r.errors, u), !o.keepDirty && k(r.dirtyFields, u), !o.keepTouched && k(r.touchedFields, u), !o.keepIsValidating && k(r.validatingFields, u), !t.shouldUnregister && !o.keepDefaultValue && k(i, u);
698
699
  m.state.next({
699
- values: k(n)
700
+ values: P(n)
700
701
  }), m.state.next({
701
702
  ...r,
702
703
  ...o.keepDirty ? { isDirty: V() } : {}
703
704
  }), !o.keepIsValid && Z();
704
- }, ke = ({ disabled: a, name: o }) => {
705
- (ie(a) && l.mount || a || d.disabled.has(o)) && (a ? d.disabled.add(o) : d.disabled.delete(o));
705
+ }, Pe = ({ disabled: a, name: o }) => {
706
+ (ie(a) && l.mount || a || f.disabled.has(o)) && (a ? f.disabled.add(o) : f.disabled.delete(o));
706
707
  }, _e = (a, o = {}) => {
707
708
  let u = g(s, a);
708
- const f = ie(o.disabled) || ie(t.disabled);
709
- return R(s, a, {
709
+ const h = ie(o.disabled) || ie(t.disabled);
710
+ return N(s, a, {
710
711
  ...u || {},
711
712
  _f: {
712
713
  ...u && u._f ? u._f : { ref: { name: a } },
@@ -714,107 +715,107 @@ function cr(e = {}) {
714
715
  mount: !0,
715
716
  ...o
716
717
  }
717
- }), d.mount.add(a), u ? ke({
718
+ }), f.mount.add(a), u ? Pe({
718
719
  disabled: ie(o.disabled) ? o.disabled : t.disabled,
719
720
  name: a
720
- }) : T(a, !0, o.value), {
721
- ...f ? { disabled: o.disabled || t.disabled } : {},
721
+ }) : L(a, !0, o.value), {
722
+ ...h ? { disabled: o.disabled || t.disabled } : {},
722
723
  ...t.progressive ? {
723
724
  required: !!o.required,
724
- min: Oe(o.min),
725
- max: Oe(o.max),
726
- minLength: Oe(o.minLength),
727
- maxLength: Oe(o.maxLength),
728
- pattern: Oe(o.pattern)
725
+ min: Ce(o.min),
726
+ max: Ce(o.max),
727
+ minLength: Ce(o.minLength),
728
+ maxLength: Ce(o.maxLength),
729
+ pattern: Ce(o.pattern)
729
730
  } : {},
730
731
  name: a,
731
- onChange: z,
732
- onBlur: z,
733
- ref: (h) => {
734
- if (h) {
732
+ onChange: de,
733
+ onBlur: de,
734
+ ref: (c) => {
735
+ if (c) {
735
736
  _e(a, o), u = g(s, a);
736
- const c = C(h.value) && h.querySelectorAll && h.querySelectorAll("input,select,textarea")[0] || h, y = Xt(c), F = u._f.refs || [];
737
- if (y ? F.find((b) => b === c) : c === u._f.ref)
737
+ const d = T(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, y = Qt(d), p = u._f.refs || [];
738
+ if (y ? p.find((F) => F === d) : d === u._f.ref)
738
739
  return;
739
- R(s, a, {
740
+ N(s, a, {
740
741
  _f: {
741
742
  ...u._f,
742
743
  ...y ? {
743
744
  refs: [
744
- ...F.filter(Qe),
745
- c,
745
+ ...p.filter(et),
746
+ d,
746
747
  ...Array.isArray(g(i, a)) ? [{}] : []
747
748
  ],
748
- ref: { type: c.type, name: a }
749
- } : { ref: c }
749
+ ref: { type: d.type, name: a }
750
+ } : { ref: d }
750
751
  }
751
- }), T(a, !1, void 0, c);
752
+ }), L(a, !1, void 0, d);
752
753
  } else
753
- u = g(s, a, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || o.shouldUnregister) && !(Wt(d.array, a) && l.action) && d.unMount.add(a);
754
+ u = g(s, a, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || o.shouldUnregister) && !(Ht(f.array, a) && l.action) && f.unMount.add(a);
754
755
  }
755
756
  };
756
- }, De = () => t.shouldFocusError && Te(s, ce, d.mount), ze = (a) => {
757
- ie(a) && (m.state.next({ disabled: a }), Te(s, (o, u) => {
758
- const f = g(s, u);
759
- f && (o.disabled = f._f.disabled || a, Array.isArray(f._f.refs) && f._f.refs.forEach((h) => {
760
- h.disabled = f._f.disabled || a;
757
+ }, De = () => t.shouldFocusError && Le(s, K, f.mount), Ge = (a) => {
758
+ ie(a) && (m.state.next({ disabled: a }), Le(s, (o, u) => {
759
+ const h = g(s, u);
760
+ h && (o.disabled = h._f.disabled || a, Array.isArray(h._f.refs) && h._f.refs.forEach((c) => {
761
+ c.disabled = h._f.disabled || a;
761
762
  }));
762
763
  }, 0, !1));
763
- }, Ue = (a, o) => async (u) => {
764
- let f;
764
+ }, qe = (a, o) => async (u) => {
765
+ let h;
765
766
  u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
766
- let h = k(n);
767
+ let c = P(n);
767
768
  if (m.state.next({
768
769
  isSubmitting: !0
769
770
  }), t.resolver) {
770
- const { errors: c, values: y } = await ae();
771
- H(), r.errors = c, h = k(y);
771
+ const { errors: d, values: y } = await ae();
772
+ W(), r.errors = d, c = P(y);
772
773
  } else
773
- await B(s);
774
- if (d.disabled.size)
775
- for (const c of d.disabled)
776
- M(h, c);
777
- if (M(r.errors, "root"), Y(r.errors)) {
774
+ await j(s);
775
+ if (f.disabled.size)
776
+ for (const d of f.disabled)
777
+ k(c, d);
778
+ if (k(r.errors, "root"), H(r.errors)) {
778
779
  m.state.next({
779
780
  errors: {}
780
781
  });
781
782
  try {
782
- await a(h, u);
783
- } catch (c) {
784
- f = c;
783
+ await a(c, u);
784
+ } catch (d) {
785
+ h = d;
785
786
  }
786
787
  } else
787
788
  o && await o({ ...r.errors }, u), De(), setTimeout(De);
788
789
  if (m.state.next({
789
790
  isSubmitted: !0,
790
791
  isSubmitting: !1,
791
- isSubmitSuccessful: Y(r.errors) && !f,
792
+ isSubmitSuccessful: H(r.errors) && !h,
792
793
  submitCount: r.submitCount + 1,
793
794
  errors: r.errors
794
- }), f)
795
- throw f;
796
- }, Be = (a, o = {}) => {
797
- g(s, a) && (C(o.defaultValue) ? j(a, k(g(i, a))) : (j(a, o.defaultValue), R(i, a, k(o.defaultValue))), o.keepTouched || M(r.touchedFields, a), o.keepDirty || (M(r.dirtyFields, a), r.isDirty = o.defaultValue ? V(a, k(g(i, a))) : V()), o.keepError || (M(r.errors, a), D.isValid && Z()), m.state.next({ ...r }));
798
- }, Pe = (a, o = {}) => {
799
- const u = a ? k(a) : i, f = k(u), h = Y(a), c = h ? i : f;
795
+ }), h)
796
+ throw h;
797
+ }, Xe = (a, o = {}) => {
798
+ g(s, a) && (T(o.defaultValue) ? q(a, P(g(i, a))) : (q(a, o.defaultValue), N(i, a, P(o.defaultValue))), o.keepTouched || k(r.touchedFields, a), o.keepDirty || (k(r.dirtyFields, a), r.isDirty = o.defaultValue ? V(a, P(g(i, a))) : V()), o.keepError || (k(r.errors, a), D.isValid && Z()), m.state.next({ ...r }));
799
+ }, Se = (a, o = {}) => {
800
+ const u = a ? P(a) : i, h = P(u), c = H(a), d = c ? i : h;
800
801
  if (o.keepDefaultValues || (i = u), !o.keepValues) {
801
802
  if (o.keepDirtyValues) {
802
803
  const y = /* @__PURE__ */ new Set([
803
- ...d.mount,
804
- ...Object.keys(Fe(i, n))
804
+ ...f.mount,
805
+ ...Object.keys(Ee(i, n))
805
806
  ]);
806
- for (const F of Array.from(y)) {
807
- const b = g(r.dirtyFields, F), _ = g(n, F), P = g(c, F);
808
- b && !C(_) ? R(c, F, _) : !b && !C(P) && j(F, P);
807
+ for (const p of Array.from(y)) {
808
+ const F = g(r.dirtyFields, p), _ = g(n, p), R = g(d, p);
809
+ F && !T(_) ? N(d, p, _) : !F && !T(R) && q(p, R);
809
810
  }
810
811
  } else {
811
- if (rt && C(a))
812
- for (const y of d.mount) {
813
- const F = g(s, y);
814
- if (F && F._f) {
815
- const b = Array.isArray(F._f.refs) ? F._f.refs[0] : F._f.ref;
816
- if (je(b)) {
817
- const _ = b.closest("form");
812
+ if (it && T(a))
813
+ for (const y of f.mount) {
814
+ const p = g(s, y);
815
+ if (p && p._f) {
816
+ const F = Array.isArray(p._f.refs) ? p._f.refs[0] : p._f.ref;
817
+ if (Ye(F)) {
818
+ const _ = F.closest("form");
818
819
  if (_) {
819
820
  _.reset();
820
821
  break;
@@ -823,75 +824,75 @@ function cr(e = {}) {
823
824
  }
824
825
  }
825
826
  if (o.keepFieldsRef)
826
- for (const y of d.mount)
827
- j(y, g(c, y));
827
+ for (const y of f.mount)
828
+ q(y, g(d, y));
828
829
  else
829
830
  s = {};
830
831
  }
831
- n = t.shouldUnregister ? o.keepDefaultValues ? k(i) : {} : k(c), m.array.next({
832
- values: { ...c }
832
+ n = t.shouldUnregister ? o.keepDefaultValues ? P(i) : {} : P(d), m.array.next({
833
+ values: { ...d }
833
834
  }), m.state.next({
834
- values: { ...c }
835
+ values: { ...d }
835
836
  });
836
837
  }
837
- d = {
838
- mount: o.keepDirtyValues ? d.mount : /* @__PURE__ */ new Set(),
838
+ f = {
839
+ mount: o.keepDirtyValues ? f.mount : /* @__PURE__ */ new Set(),
839
840
  unMount: /* @__PURE__ */ new Set(),
840
841
  array: /* @__PURE__ */ new Set(),
841
842
  disabled: /* @__PURE__ */ new Set(),
842
843
  watch: /* @__PURE__ */ new Set(),
843
844
  watchAll: !1,
844
845
  focus: ""
845
- }, l.mount = !D.isValid || !!o.keepIsValid || !!o.keepDirtyValues || !t.shouldUnregister && !Y(c), l.watch = !!t.shouldUnregister, l.keepIsValid = !!o.keepIsValid, l.action = !1, o.keepErrors || (r.errors = {}), m.state.next({
846
+ }, l.mount = !D.isValid || !!o.keepIsValid || !!o.keepDirtyValues || !t.shouldUnregister && !H(d), l.watch = !!t.shouldUnregister, l.keepIsValid = !!o.keepIsValid, l.action = !1, o.keepErrors || (r.errors = {}), m.state.next({
846
847
  submitCount: o.keepSubmitCount ? r.submitCount : 0,
847
- isDirty: h ? !1 : o.keepDirty ? r.isDirty : !!(o.keepDefaultValues && !de(a, i)),
848
+ isDirty: c ? !1 : o.keepDirty ? r.isDirty : !!(o.keepDefaultValues && !he(a, i)),
848
849
  isSubmitted: o.keepIsSubmitted ? r.isSubmitted : !1,
849
- dirtyFields: h ? {} : o.keepDirtyValues ? o.keepDefaultValues && n ? Fe(i, n) : r.dirtyFields : o.keepDefaultValues && a ? Fe(i, a) : o.keepDirty ? r.dirtyFields : {},
850
+ dirtyFields: c ? {} : o.keepDirtyValues ? o.keepDefaultValues && n ? Ee(i, n) : r.dirtyFields : o.keepDefaultValues && a ? Ee(i, a) : o.keepDirty ? r.dirtyFields : {},
850
851
  touchedFields: o.keepTouched ? r.touchedFields : {},
851
852
  errors: o.keepErrors ? r.errors : {},
852
853
  isSubmitSuccessful: o.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
853
854
  isSubmitting: !1,
854
855
  defaultValues: i
855
856
  });
856
- }, Se = (a, o) => Pe(re(a) ? a(n) : a, { ...t.resetOptions, ...o }), Je = (a, o = {}) => {
857
- const u = g(s, a), f = u && u._f;
858
- if (f) {
859
- const h = f.refs ? f.refs[0] : f.ref;
860
- h.focus && setTimeout(() => {
861
- h.focus(), o.shouldSelect && re(h.select) && h.select();
857
+ }, $e = (a, o) => Se(re(a) ? a(n) : a, { ...t.resetOptions, ...o }), Re = (a, o = {}) => {
858
+ const u = g(s, a), h = u && u._f;
859
+ if (h) {
860
+ const c = h.refs ? h.refs[0] : h.ref;
861
+ c.focus && setTimeout(() => {
862
+ c.focus(), o.shouldSelect && re(c.select) && c.select();
862
863
  });
863
864
  }
864
- }, Ge = (a) => {
865
+ }, Qe = (a) => {
865
866
  r = {
866
867
  ...r,
867
868
  ...a
868
869
  };
869
- }, Re = {
870
+ }, je = {
870
871
  control: {
871
872
  register: _e,
872
873
  unregister: xe,
873
- getFieldState: A,
874
- handleSubmit: Ue,
875
- setError: Ae,
876
- _subscribe: Ie,
874
+ getFieldState: ke,
875
+ handleSubmit: qe,
876
+ setError: we,
877
+ _subscribe: Be,
877
878
  _runSchema: ae,
878
- _updateIsValidating: H,
879
+ _updateIsValidating: W,
879
880
  _focusError: De,
880
- _getWatch: E,
881
+ _getWatch: x,
881
882
  _getDirty: V,
882
883
  _setValid: Z,
883
- _setFieldArray: x,
884
- _setDisabledField: ke,
885
- _setErrors: L,
884
+ _setFieldArray: A,
885
+ _setDisabledField: Pe,
886
+ _setErrors: M,
886
887
  _getFieldArray: S,
887
- _reset: Pe,
888
+ _reset: Se,
888
889
  _resetDefaultValues: () => re(t.defaultValues) && t.defaultValues().then((a) => {
889
- Se(a, t.resetOptions), m.state.next({
890
+ $e(a, t.resetOptions), m.state.next({
890
891
  isLoading: !1
891
892
  });
892
893
  }),
893
- _removeUnmounted: le,
894
- _disableForm: ze,
894
+ _removeUnmounted: ce,
895
+ _disableForm: Ge,
895
896
  _subjects: m,
896
897
  _proxyFormState: D,
897
898
  get _fields() {
@@ -910,10 +911,10 @@ function cr(e = {}) {
910
911
  return i;
911
912
  },
912
913
  get _names() {
913
- return d;
914
+ return f;
914
915
  },
915
916
  set _names(a) {
916
- d = a;
917
+ f = a;
917
918
  },
918
919
  get _formState() {
919
920
  return r;
@@ -928,27 +929,27 @@ function cr(e = {}) {
928
929
  };
929
930
  }
930
931
  },
931
- subscribe: Ke,
932
- trigger: me,
932
+ subscribe: Je,
933
+ trigger: fe,
933
934
  register: _e,
934
- handleSubmit: Ue,
935
- watch: Ye,
936
- setValue: j,
937
- getValues: Me,
938
- reset: Se,
939
- resetField: Be,
940
- clearErrors: Ee,
935
+ handleSubmit: qe,
936
+ watch: Ue,
937
+ setValue: q,
938
+ getValues: Ie,
939
+ reset: $e,
940
+ resetField: Xe,
941
+ clearErrors: E,
941
942
  unregister: xe,
942
- setError: Ae,
943
- setFocus: Je,
944
- getFieldState: A
943
+ setError: we,
944
+ setFocus: Re,
945
+ getFieldState: ke
945
946
  };
946
947
  return {
947
- ...Re,
948
- formControl: Re
948
+ ...je,
949
+ formControl: je
949
950
  };
950
951
  }
951
- function dr(e = {}) {
952
+ function fr(e = {}) {
952
953
  const t = X.useRef(void 0), r = X.useRef(void 0), [s, i] = X.useState({
953
954
  isDirty: !1,
954
955
  isValidating: !1,
@@ -973,21 +974,21 @@ function dr(e = {}) {
973
974
  formState: s
974
975
  }, e.defaultValues && !re(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
975
976
  else {
976
- const { formControl: l, ...d } = cr(e);
977
+ const { formControl: l, ...f } = dr(e);
977
978
  t.current = {
978
- ...d,
979
+ ...f,
979
980
  formState: s
980
981
  };
981
982
  }
982
983
  const n = t.current.control;
983
- return n._options = e, zt(() => {
984
+ return n._options = e, Jt(() => {
984
985
  const l = n._subscribe({
985
986
  formState: n._proxyFormState,
986
987
  callback: () => i({ ...n._formState }),
987
988
  reRenderRoot: !0
988
989
  });
989
- return i((d) => ({
990
- ...d,
990
+ return i((f) => ({
991
+ ...f,
991
992
  isReady: !0
992
993
  })), n._formState.isReady = !0, l;
993
994
  }, [n]), X.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), X.useEffect(() => {
@@ -1007,15 +1008,15 @@ function dr(e = {}) {
1007
1008
  }
1008
1009
  }, [n, s.isDirty]), X.useEffect(() => {
1009
1010
  var l;
1010
- e.values && !de(e.values, r.current) ? (n._reset(e.values, {
1011
+ e.values && !he(e.values, r.current) ? (n._reset(e.values, {
1011
1012
  keepFieldsRef: !0,
1012
1013
  ...n._options.resetOptions
1013
- }), !((l = n._options.resetOptions) === null || l === void 0) && l.keepIsValid || n._setValid(), r.current = e.values, i((d) => ({ ...d }))) : n._resetDefaultValues();
1014
+ }), !((l = n._options.resetOptions) === null || l === void 0) && l.keepIsValid || n._setValid(), r.current = e.values, i((f) => ({ ...f }))) : n._resetDefaultValues();
1014
1015
  }, [n, e.values]), X.useEffect(() => {
1015
1016
  n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
1016
- }), t.current.formState = Kt(s, n), t.current;
1017
+ }), t.current.formState = zt(s, n), t.current;
1017
1018
  }
1018
- function fr() {
1019
+ function hr() {
1019
1020
  const e = /* @__PURE__ */ new Date();
1020
1021
  return {
1021
1022
  NOW: e,
@@ -1031,7 +1032,7 @@ function fr() {
1031
1032
  CURRENT_USER_ID: 1
1032
1033
  };
1033
1034
  }
1034
- const hr = {
1035
+ const mr = {
1035
1036
  // String functions
1036
1037
  CONCAT: (...e) => e.map((t) => String(t || "")).join(""),
1037
1038
  TRIM: (e) => String(e || "").trim(),
@@ -1094,56 +1095,56 @@ const hr = {
1094
1095
  ARRAY_CONTAINS: (e, t) => Array.isArray(e) ? e.includes(t) : !1,
1095
1096
  ARRAY_JOIN: (e, t = ",") => Array.isArray(e) ? e.join(t) : ""
1096
1097
  };
1097
- function fe(e, t) {
1098
+ function me(e, t) {
1098
1099
  var r;
1099
1100
  switch (e.Type) {
1100
1101
  case "Literal":
1101
1102
  return e.Value;
1102
1103
  case "SystemIdentifier":
1103
1104
  if (e.Property) {
1104
- const p = t.systemValues[e.Name];
1105
- return Ze(p, e.Property.Name);
1105
+ const b = t.systemValues[e.Name];
1106
+ return tt(b, e.Property.Name);
1106
1107
  }
1107
1108
  return t.systemValues[e.Name];
1108
1109
  case "Identifier":
1109
1110
  if (e.Property) {
1110
- const p = Et(e, t);
1111
- return Ze(p, e.Property.Name);
1111
+ const b = xt(e, t);
1112
+ return tt(b, e.Property.Name);
1112
1113
  }
1113
- return Et(e, t);
1114
+ return xt(e, t);
1114
1115
  case "MemberExpression":
1115
1116
  if (!e.Arguments || e.Arguments.length === 0)
1116
1117
  throw new Error("MemberExpression requires Arguments array");
1117
- const s = fe(e.Arguments[0], t), i = (r = e.Arguments[0].Property) == null ? void 0 : r.Name;
1118
- return i ? Ze(s, i) : s;
1118
+ const s = me(e.Arguments[0], t), i = (r = e.Arguments[0].Property) == null ? void 0 : r.Name;
1119
+ return i ? tt(s, i) : s;
1119
1120
  case "BinaryExpression":
1120
1121
  if (!e.Arguments || e.Arguments.length !== 2)
1121
1122
  throw new Error("BinaryExpression requires exactly 2 arguments");
1122
- const n = fe(e.Arguments[0], t), l = fe(e.Arguments[1], t);
1123
- return mr(e.Operator, n, l);
1123
+ const n = me(e.Arguments[0], t), l = me(e.Arguments[1], t);
1124
+ return yr(e.Operator, n, l);
1124
1125
  case "LogicalExpression":
1125
1126
  if (!e.Arguments || e.Arguments.length < 2)
1126
1127
  throw new Error("LogicalExpression requires at least 2 arguments");
1127
- return yr(e.Operator, e.Arguments, t);
1128
+ return gr(e.Operator, e.Arguments, t);
1128
1129
  case "CallExpression":
1129
1130
  if (!e.Callee)
1130
1131
  throw new Error("CallExpression requires Callee");
1131
- const d = hr[e.Callee];
1132
- if (!d)
1132
+ const f = mr[e.Callee];
1133
+ if (!f)
1133
1134
  throw new Error(`Unknown function: ${e.Callee}`);
1134
1135
  const w = (e.Arguments || []).map(
1135
- (p) => fe(p, t)
1136
+ (b) => me(b, t)
1136
1137
  );
1137
- return d(...w);
1138
+ return f(...w);
1138
1139
  case "AssignmentExpression":
1139
1140
  if (!e.Arguments || e.Arguments.length !== 1)
1140
1141
  throw new Error("AssignmentExpression requires exactly 1 argument");
1141
- return fe(e.Arguments[0], t);
1142
+ return me(e.Arguments[0], t);
1142
1143
  default:
1143
1144
  throw new Error(`Unknown expression type: ${e.Type}`);
1144
1145
  }
1145
1146
  }
1146
- function Et(e, t) {
1147
+ function xt(e, t) {
1147
1148
  const { Name: r, Source: s } = e;
1148
1149
  if (!r)
1149
1150
  throw new Error("Identifier requires Name");
@@ -1153,11 +1154,11 @@ function Et(e, t) {
1153
1154
  return t.formValues[r];
1154
1155
  }
1155
1156
  }
1156
- function Ze(e, t) {
1157
+ function tt(e, t) {
1157
1158
  if (!(!e || typeof e != "object"))
1158
1159
  return e[t];
1159
1160
  }
1160
- function mr(e, t, r) {
1161
+ function yr(e, t, r) {
1161
1162
  const s = (i) => i == null ? 0 : typeof i == "number" ? i : typeof i == "object" && i !== null && "value" in i ? Number(i.value) || 0 : Number(i) || 0;
1162
1163
  switch (e) {
1163
1164
  case "==":
@@ -1185,33 +1186,33 @@ function mr(e, t, r) {
1185
1186
  throw new Error(`Unknown binary operator: ${e}`);
1186
1187
  }
1187
1188
  }
1188
- function yr(e, t, r) {
1189
+ function gr(e, t, r) {
1189
1190
  switch (e) {
1190
1191
  case "AND":
1191
- return t.every((s) => !!fe(s, r));
1192
+ return t.every((s) => !!me(s, r));
1192
1193
  case "OR":
1193
- return t.some((s) => !!fe(s, r));
1194
+ return t.some((s) => !!me(s, r));
1194
1195
  default:
1195
1196
  throw new Error(`Unknown logical operator: ${e}`);
1196
1197
  }
1197
1198
  }
1198
- function Mt(e, t, r = {}) {
1199
+ function kt(e, t, r = {}) {
1199
1200
  const s = {
1200
1201
  formValues: t,
1201
- systemValues: fr(),
1202
+ systemValues: hr(),
1202
1203
  referenceData: r
1203
1204
  };
1204
1205
  try {
1205
- return fe(e, s);
1206
+ return me(e, s);
1206
1207
  } catch (i) {
1207
1208
  return console.warn("Expression evaluation failed:", i), !1;
1208
1209
  }
1209
1210
  }
1210
- function At(e, t, r = {}) {
1211
+ function _t(e, t, r = {}) {
1211
1212
  const s = [];
1212
1213
  for (const i of e)
1213
1214
  try {
1214
- Mt(
1215
+ kt(
1215
1216
  i.Condition.ExpressionTree,
1216
1217
  t,
1217
1218
  r
@@ -1225,25 +1226,25 @@ function At(e, t, r = {}) {
1225
1226
  }
1226
1227
  return s;
1227
1228
  }
1228
- function gr(e, t = {}, r = {}) {
1229
+ function pr(e, t = {}, r = {}) {
1229
1230
  try {
1230
- return Mt(e, t, r);
1231
+ return kt(e, t, r);
1231
1232
  } catch (s) {
1232
1233
  return console.warn("Default value calculation failed:", s), null;
1233
1234
  }
1234
1235
  }
1235
- function xt(e, t) {
1236
- var d, w, p;
1237
- const r = ((d = e.Expression) == null ? void 0 : d.toLowerCase()) || "", s = ((w = e.Name) == null ? void 0 : w.toLowerCase()) || "", i = ((p = e.Id) == null ? void 0 : p.toLowerCase()) || "", n = t.toLowerCase();
1236
+ function Dt(e, t) {
1237
+ var f, w, b;
1238
+ const r = ((f = e.Expression) == null ? void 0 : f.toLowerCase()) || "", s = ((w = e.Name) == null ? void 0 : w.toLowerCase()) || "", i = ((b = e.Id) == null ? void 0 : b.toLowerCase()) || "", n = t.toLowerCase();
1238
1239
  return s.includes("required") || i.includes("required") ? !0 : [
1239
1240
  `${n} != null`,
1240
1241
  `${n} != ''`,
1241
1242
  `trim(${n}) != ''`,
1242
1243
  `${n}!=null`,
1243
1244
  `${n}!=''`
1244
- ].some((N) => r.includes(N));
1245
+ ].some((O) => r.includes(O));
1245
1246
  }
1246
- function pr(e) {
1247
+ function br(e) {
1247
1248
  const t = { ...e };
1248
1249
  t.Rules || (t.Rules = {
1249
1250
  Validation: {},
@@ -1256,18 +1257,18 @@ function pr(e) {
1256
1257
  if (i.Validation && Array.isArray(i.Validation))
1257
1258
  if (i.Validation.length > 0 && typeof i.Validation[0] == "object") {
1258
1259
  const l = [];
1259
- i.Validation.forEach((d) => {
1260
- t.Rules.Validation[d.Id] = d, l.push(d.Id), xt(d, s) && (n = !0);
1260
+ i.Validation.forEach((f) => {
1261
+ t.Rules.Validation[f.Id] = f, l.push(f.Id), Dt(f, s) && (n = !0);
1261
1262
  }), r[s] = {
1262
1263
  ...i,
1263
1264
  Validation: l,
1264
1265
  Required: n
1265
1266
  };
1266
1267
  } else
1267
- i.Validation.forEach((d) => {
1268
- var p;
1269
- const w = (p = t.Rules.Validation) == null ? void 0 : p[d];
1270
- w && xt(w, s) && (n = !0);
1268
+ i.Validation.forEach((f) => {
1269
+ var b;
1270
+ const w = (b = t.Rules.Validation) == null ? void 0 : b[f];
1271
+ w && Dt(w, s) && (n = !0);
1271
1272
  }), n && !i.Required && (r[s] = {
1272
1273
  ...i,
1273
1274
  Required: !0
@@ -1285,7 +1286,7 @@ function pr(e) {
1285
1286
  }
1286
1287
  }), t.Fields = r, t;
1287
1288
  }
1288
- function br(e) {
1289
+ function wr(e) {
1289
1290
  var r, s, i;
1290
1291
  const t = {
1291
1292
  validation: {},
@@ -1294,7 +1295,7 @@ function br(e) {
1294
1295
  };
1295
1296
  return (r = e.Rules) != null && r.Validation && (t.validation = { ...e.Rules.Validation }), (s = e.Rules) != null && s.Computation && (t.computation = { ...e.Rules.Computation }), (i = e.Rules) != null && i.BusinessLogic && (t.businessLogic = { ...e.Rules.BusinessLogic }), t;
1296
1297
  }
1297
- function wr(e) {
1298
+ function vr(e) {
1298
1299
  var s;
1299
1300
  const t = {};
1300
1301
  if (!((s = e.Rules) != null && s.Computation)) return t;
@@ -1302,21 +1303,21 @@ function wr(e) {
1302
1303
  return r.sort((i, n) => n.length - i.length), Object.entries(e.Rules.Computation).forEach(([i, n]) => {
1303
1304
  const l = i.toUpperCase().replace(/[_-]/g, "");
1304
1305
  for (const w of r) {
1305
- const p = w.toUpperCase().replace(/[_-]/g, "");
1306
- if (l.includes(p)) {
1306
+ const b = w.toUpperCase().replace(/[_-]/g, "");
1307
+ if (l.includes(b)) {
1307
1308
  t[i] = w;
1308
1309
  return;
1309
1310
  }
1310
1311
  }
1311
- const d = `${n.Name || ""} ${n.Description || ""}`.toLowerCase();
1312
+ const f = `${n.Name || ""} ${n.Description || ""}`.toLowerCase();
1312
1313
  for (const w of r)
1313
- if (d.includes(w.toLowerCase())) {
1314
+ if (f.includes(w.toLowerCase())) {
1314
1315
  t[i] = w;
1315
1316
  return;
1316
1317
  }
1317
1318
  }), t;
1318
1319
  }
1319
- function vr(e, t) {
1320
+ function Fr(e, t) {
1320
1321
  const r = {};
1321
1322
  Object.keys(e.Fields).forEach((i) => {
1322
1323
  r[i] = {
@@ -1325,39 +1326,39 @@ function vr(e, t) {
1325
1326
  businessLogic: []
1326
1327
  };
1327
1328
  }), Object.entries(e.Fields).forEach(([i, n]) => {
1328
- n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((d) => {
1329
- t.validation[d] ? r[i].validation.push(d) : t.computation[d] ? r[i].computation.push(d) : t.businessLogic[d] && r[i].businessLogic.push(d);
1330
- }), n.Formula && Object.entries(t.computation).forEach(([l, d]) => {
1329
+ n.Validation && Array.isArray(n.Validation) && n.Validation.forEach((f) => {
1330
+ t.validation[f] ? r[i].validation.push(f) : t.computation[f] ? r[i].computation.push(f) : t.businessLogic[f] && r[i].businessLogic.push(f);
1331
+ }), n.Formula && Object.entries(t.computation).forEach(([l, f]) => {
1331
1332
  var w;
1332
- d.Expression === ((w = n.Formula) == null ? void 0 : w.Expression) && (r[i].computation.includes(l) || r[i].computation.push(l));
1333
+ f.Expression === ((w = n.Formula) == null ? void 0 : w.Expression) && (r[i].computation.includes(l) || r[i].computation.push(l));
1333
1334
  });
1334
1335
  });
1335
- const s = wr(e);
1336
+ const s = vr(e);
1336
1337
  return Object.entries(s).forEach(([i, n]) => {
1337
1338
  r[n] && !r[n].computation.includes(i) && r[n].computation.push(i);
1338
1339
  }), r;
1339
1340
  }
1340
- function Fr(e, t) {
1341
+ function Vr(e, t) {
1341
1342
  const r = {}, s = {
1342
1343
  editable: !0,
1343
1344
  readable: !0,
1344
1345
  hidden: !1
1345
1346
  };
1346
1347
  return Object.keys(e.Fields).forEach((i) => {
1347
- var w, p, N, D, v, m;
1348
+ var w, b, O, D, v, m;
1348
1349
  if (!t || !((w = e.RolePermission) != null && w[t])) {
1349
1350
  r[i] = s;
1350
1351
  return;
1351
1352
  }
1352
- const n = e.RolePermission[t], l = ((p = n.Editable) == null ? void 0 : p.includes(i)) || ((N = n.Editable) == null ? void 0 : N.includes("*")) || !1, d = ((D = n.ReadOnly) == null ? void 0 : D.includes(i)) || ((v = n.ReadOnly) == null ? void 0 : v.includes("*")) || l;
1353
+ const n = e.RolePermission[t], l = ((b = n.Editable) == null ? void 0 : b.includes(i)) || ((O = n.Editable) == null ? void 0 : O.includes("*")) || !1, f = ((D = n.ReadOnly) == null ? void 0 : D.includes(i)) || ((v = n.ReadOnly) == null ? void 0 : v.includes("*")) || l;
1353
1354
  r[i] = {
1354
1355
  editable: l && !((m = n.ReadOnly) != null && m.includes(i)),
1355
- readable: d,
1356
- hidden: !d
1356
+ readable: f,
1357
+ hidden: !f
1357
1358
  };
1358
1359
  }), r;
1359
1360
  }
1360
- function Vr(e, t) {
1361
+ function Er(e, t) {
1361
1362
  switch (e) {
1362
1363
  case "String":
1363
1364
  return t.toLowerCase().includes("email") ? "email" : t.toLowerCase().includes("password") ? "password" : "text";
@@ -1378,14 +1379,14 @@ function Vr(e, t) {
1378
1379
  return "text";
1379
1380
  }
1380
1381
  }
1381
- function It(e) {
1382
+ function Ut(e) {
1382
1383
  return e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).replace(/_/g, " ").trim();
1383
1384
  }
1384
- function Er(e, t, r) {
1385
+ function Ar(e, t, r) {
1385
1386
  const s = {};
1386
1387
  switch (t.Required && (s.required = {
1387
1388
  value: !0,
1388
- message: `${It(e)} is required`
1389
+ message: `${Ut(e)} is required`
1389
1390
  }), t.Type) {
1390
1391
  case "Number":
1391
1392
  s.valueAsNumber = !0;
@@ -1397,13 +1398,13 @@ function Er(e, t, r) {
1397
1398
  }
1398
1399
  return t.Validation && t.Validation.length > 0 && (s.validate = () => !0), s;
1399
1400
  }
1400
- function Ar(e) {
1401
+ function xr(e) {
1401
1402
  return e.Values ? e.Values.Mode === "Static" && e.Values.Items ? e.Values.Items.map((t) => ({
1402
1403
  value: t.Value,
1403
1404
  label: t.Label
1404
1405
  })) : e.Values.Mode === "Dynamic" && e.Values.Reference ? [] : [] : [];
1405
1406
  }
1406
- function xr(e, t = {}) {
1407
+ function _r(e, t = {}) {
1407
1408
  if (!e.DefaultValue)
1408
1409
  switch (e.Type) {
1409
1410
  case "Boolean":
@@ -1419,12 +1420,12 @@ function xr(e, t = {}) {
1419
1420
  default:
1420
1421
  return;
1421
1422
  }
1422
- return gr(
1423
+ return pr(
1423
1424
  e.DefaultValue.ExpressionTree,
1424
1425
  t
1425
1426
  );
1426
1427
  }
1427
- function _r(e, t, r, s = {}, i, n) {
1428
+ function Dr(e, t, r, s = {}, i, n) {
1428
1429
  const l = {
1429
1430
  editable: !0,
1430
1431
  readable: !0,
@@ -1433,58 +1434,58 @@ function _r(e, t, r, s = {}, i, n) {
1433
1434
  validation: [],
1434
1435
  computation: [],
1435
1436
  businessLogic: []
1436
- }, p = t.Computed || !!t.Formula || w.computation.length > 0, N = Er(e, t);
1437
- return p && (N.disabled = !0), {
1437
+ }, b = t.Computed || !!t.Formula || w.computation.length > 0, O = Ar(e, t);
1438
+ return b && (O.disabled = !0), {
1438
1439
  name: e,
1439
- type: Vr(t.Type, e),
1440
- label: t.Name || It(e),
1440
+ type: Er(t.Type, e),
1441
+ label: t.Name || Ut(e),
1441
1442
  required: t.Required || !1,
1442
- computed: p,
1443
- defaultValue: xr(t, s),
1444
- options: Ar(t),
1445
- validation: N,
1443
+ computed: b,
1444
+ defaultValue: _r(t, s),
1445
+ options: xr(t),
1446
+ validation: O,
1446
1447
  description: t.Description,
1447
1448
  _bdoField: t,
1448
1449
  permission: i || l,
1449
1450
  rules: w
1450
1451
  };
1451
1452
  }
1452
- function Dr(e, t = {}, r) {
1453
+ function Sr(e, t = {}, r) {
1453
1454
  let s = e;
1454
- s = pr(s);
1455
- const i = {}, n = [], l = [], d = [], w = [], p = br(s), N = vr(s, p), D = Fr(s, r);
1455
+ s = br(s);
1456
+ const i = {}, n = [], l = [], f = [], w = [], b = wr(s), O = Fr(s, b), D = Vr(s, r);
1456
1457
  for (const [v, m] of Object.entries(s.Fields)) {
1457
1458
  if (v.startsWith("_") && !["_id"].includes(v))
1458
1459
  continue;
1459
- const K = D[v];
1460
- if (K.hidden)
1460
+ const Y = D[v];
1461
+ if (Y.hidden)
1461
1462
  continue;
1462
- const O = _r(
1463
+ const C = Dr(
1463
1464
  v,
1464
1465
  m,
1465
1466
  s.Fields,
1466
1467
  t,
1467
- K,
1468
- N[v] || {
1468
+ Y,
1469
+ O[v] || {
1469
1470
  validation: [],
1470
1471
  computation: [],
1471
1472
  businessLogic: []
1472
1473
  }
1473
1474
  );
1474
- i[v] = O, n.push(v), O.computed && l.push(v), O.required && d.push(v);
1475
+ i[v] = C, n.push(v), C.computed && l.push(v), C.required && f.push(v);
1475
1476
  }
1476
1477
  return {
1477
1478
  fields: i,
1478
1479
  fieldOrder: n,
1479
1480
  computedFields: l,
1480
- requiredFields: d,
1481
+ requiredFields: f,
1481
1482
  crossFieldValidation: w,
1482
- rules: p,
1483
- fieldRules: N,
1483
+ rules: b,
1484
+ fieldRules: O,
1484
1485
  rolePermissions: s.RolePermission
1485
1486
  };
1486
1487
  }
1487
- function Sr(e) {
1488
+ function Rr(e) {
1488
1489
  var r;
1489
1490
  if (e.type !== "reference" || !((r = e._bdoField.Values) != null && r.Reference))
1490
1491
  return null;
@@ -1497,18 +1498,18 @@ function Sr(e) {
1497
1498
  sort: t.Sort
1498
1499
  };
1499
1500
  }
1500
- function Rr(e) {
1501
+ function Nr(e) {
1501
1502
  const t = {};
1502
1503
  for (const [r, s] of Object.entries(e.fields))
1503
1504
  if (s.type === "reference") {
1504
- const i = Sr(s);
1505
+ const i = Rr(s);
1505
1506
  i && (t[r] = i);
1506
1507
  }
1507
1508
  return t;
1508
1509
  }
1509
- async function Nr(e) {
1510
+ async function Or(e) {
1510
1511
  try {
1511
- const r = (await qt(e)).BOBlob;
1512
+ const r = (await $t(e)).BOBlob;
1512
1513
  if (!r || typeof r != "object" || !r.Fields)
1513
1514
  throw new Error(`Invalid BDO schema response for ${e}`);
1514
1515
  return r;
@@ -1518,13 +1519,13 @@ async function Nr(e) {
1518
1519
  );
1519
1520
  }
1520
1521
  }
1521
- async function Or(e, t = 3) {
1522
+ async function Cr(e, t = 3) {
1522
1523
  let r;
1523
1524
  for (let s = 1; s <= t; s++)
1524
1525
  try {
1525
- return await Nr(e);
1526
+ return await Or(e);
1526
1527
  } catch (i) {
1527
- if (r = i, s < t) {
1528
+ if (r = Ve(i), s < t) {
1528
1529
  const n = Math.min(1e3 * Math.pow(2, s - 1), 5e3);
1529
1530
  await new Promise((l) => setTimeout(l, n));
1530
1531
  continue;
@@ -1532,20 +1533,20 @@ async function Or(e, t = 3) {
1532
1533
  }
1533
1534
  throw r;
1534
1535
  }
1535
- async function Cr(e, t) {
1536
+ async function Tr(e, t) {
1536
1537
  try {
1537
- return await pe(e).get(t);
1538
+ return await be(e).get(t);
1538
1539
  } catch (r) {
1539
1540
  throw console.error(`Record fetch error for ${e}/${t}:`, r), new Error(
1540
1541
  `Failed to load record: ${r instanceof Error ? r.message : "Unknown error"}`
1541
1542
  );
1542
1543
  }
1543
1544
  }
1544
- async function Tr(e, t, r, s) {
1545
+ async function Lr(e, t, r, s) {
1545
1546
  try {
1546
1547
  let i;
1547
1548
  if (t === "create")
1548
- return i = await pe(e).create(r), {
1549
+ return i = await be(e).create(r), {
1549
1550
  success: !0,
1550
1551
  data: i,
1551
1552
  recordId: i._id || s
@@ -1553,7 +1554,7 @@ async function Tr(e, t, r, s) {
1553
1554
  if (t === "update") {
1554
1555
  if (!s)
1555
1556
  throw new Error("Record ID is required for update operations");
1556
- return i = await pe(e).update(s, r), {
1557
+ return i = await be(e).update(s, r), {
1557
1558
  success: !0,
1558
1559
  data: i,
1559
1560
  recordId: i._id || s
@@ -1569,19 +1570,19 @@ async function Tr(e, t, r, s) {
1569
1570
  };
1570
1571
  }
1571
1572
  }
1572
- async function Lr(e, t = ["_id"], r, s) {
1573
+ async function Mr(e, t = ["_id"], r, s) {
1573
1574
  try {
1574
1575
  const i = {};
1575
- return r && (i.Filter = r), s && (i.Sort = s), t.length > 0 && (i.Field = t), (await pe(e).list(i)).Data || [];
1576
+ return r && (i.Filter = r), s && (i.Sort = s), t.length > 0 && (i.Field = t), (await be(e).list(i)).Data || [];
1576
1577
  } catch (i) {
1577
1578
  return console.error(`Reference data fetch error for ${e}:`, i), [];
1578
1579
  }
1579
1580
  }
1580
- async function Mr(e) {
1581
+ async function Ir(e) {
1581
1582
  const t = {}, r = Object.entries(e).map(
1582
1583
  async ([i, n]) => {
1583
1584
  try {
1584
- const l = await Lr(
1585
+ const l = await Mr(
1585
1586
  n.businessObject,
1586
1587
  n.fields,
1587
1588
  n.filters,
@@ -1600,66 +1601,66 @@ async function Mr(e) {
1600
1601
  }
1601
1602
  }), t;
1602
1603
  }
1603
- function Ir(e, t, r = "create", s) {
1604
+ function kr(e, t, r = "create", s) {
1604
1605
  const i = {};
1605
1606
  return Object.keys(e).forEach((n) => {
1606
- const l = n, d = e[l];
1607
- if (!t.includes(n) && d !== void 0) {
1607
+ const l = n, f = e[l];
1608
+ if (!t.includes(n) && f !== void 0) {
1608
1609
  if (r === "create") {
1609
- i[l] = d;
1610
+ i[l] = f;
1610
1611
  return;
1611
1612
  }
1612
1613
  if (r === "update") {
1613
1614
  if (!s) {
1614
- i[l] = d;
1615
+ i[l] = f;
1615
1616
  return;
1616
1617
  }
1617
1618
  const w = s[l];
1618
- JSON.stringify(d) !== JSON.stringify(w) && (i[l] = d);
1619
+ JSON.stringify(f) !== JSON.stringify(w) && (i[l] = f);
1619
1620
  }
1620
1621
  }
1621
1622
  }), i;
1622
1623
  }
1623
- function zr(e) {
1624
+ function Gr(e) {
1624
1625
  var t, r, s, i;
1625
1626
  return typeof e == "string" ? e : e != null && e.message ? e.message : (r = (t = e == null ? void 0 : e.response) == null ? void 0 : t.data) != null && r.message ? e.response.data.message : (i = (s = e == null ? void 0 : e.response) == null ? void 0 : s.data) != null && i.error ? e.response.data.error : "An unexpected error occurred";
1626
1627
  }
1627
- function Jr(e) {
1628
+ function Xr(e) {
1628
1629
  var t, r;
1629
1630
  return !navigator.onLine || (e == null ? void 0 : e.code) === "NETWORK_ERROR" || ((t = e == null ? void 0 : e.message) == null ? void 0 : t.toLowerCase().includes("network")) || ((r = e == null ? void 0 : e.message) == null ? void 0 : r.toLowerCase().includes("fetch"));
1630
1631
  }
1631
- function Gr(e) {
1632
+ function Qr(e) {
1632
1633
  var t, r, s;
1633
1634
  return (e == null ? void 0 : e.status) === 400 || ((t = e == null ? void 0 : e.response) == null ? void 0 : t.status) === 400 || ((r = e == null ? void 0 : e.message) == null ? void 0 : r.toLowerCase().includes("validation")) || ((s = e == null ? void 0 : e.message) == null ? void 0 : s.toLowerCase().includes("invalid"));
1634
1635
  }
1635
- const Ve = /* @__PURE__ */ new Map();
1636
- function kr(e, t, r = 10) {
1637
- Ve.set(e, {
1636
+ const Ae = /* @__PURE__ */ new Map();
1637
+ function Ur(e, t, r = 10) {
1638
+ Ae.set(e, {
1638
1639
  data: t,
1639
1640
  timestamp: Date.now(),
1640
1641
  ttl: r * 60 * 1e3
1641
1642
  });
1642
1643
  }
1643
- function Ur(e) {
1644
- const t = Ve.get(e);
1645
- return t ? Date.now() - t.timestamp > t.ttl ? (Ve.delete(e), null) : t.data : null;
1644
+ function Br(e) {
1645
+ const t = Ae.get(e);
1646
+ return t ? Date.now() - t.timestamp > t.ttl ? (Ae.delete(e), null) : t.data : null;
1646
1647
  }
1647
- function Xr(e) {
1648
- e ? Array.from(Ve.keys()).filter(
1648
+ function Zr(e) {
1649
+ e ? Array.from(Ae.keys()).filter(
1649
1650
  (r) => r.startsWith(e)
1650
- ).forEach((r) => Ve.delete(r)) : Ve.clear();
1651
+ ).forEach((r) => Ae.delete(r)) : Ae.clear();
1651
1652
  }
1652
- async function Br(e) {
1653
- const t = `schema:${e}`, r = Ur(t);
1653
+ async function Pr(e) {
1654
+ const t = `schema:${e}`, r = Br(t);
1654
1655
  if (r)
1655
1656
  return r;
1656
- const s = await Or(e);
1657
- return kr(t, s, 30), s;
1657
+ const s = await Cr(e);
1658
+ return Ur(t, s, 30), s;
1658
1659
  }
1659
- class _t {
1660
+ class St {
1660
1661
  constructor(t = 1e3) {
1661
- we(this, "cache", /* @__PURE__ */ new Map());
1662
- we(this, "maxSize");
1662
+ ve(this, "cache", /* @__PURE__ */ new Map());
1663
+ ve(this, "maxSize");
1663
1664
  this.maxSize = t;
1664
1665
  }
1665
1666
  get(t) {
@@ -1679,7 +1680,7 @@ class _t {
1679
1680
  this.cache.clear();
1680
1681
  }
1681
1682
  }
1682
- function Pr(e) {
1683
+ function qr(e) {
1683
1684
  const t = /* @__PURE__ */ new Set();
1684
1685
  function r(s) {
1685
1686
  switch (s.Type) {
@@ -1698,11 +1699,11 @@ function Pr(e) {
1698
1699
  }
1699
1700
  return r(e), t;
1700
1701
  }
1701
- class qr {
1702
+ class $r {
1702
1703
  constructor() {
1703
- we(this, "resultCache", new _t(500));
1704
- we(this, "dependencyCache", new _t(200));
1705
- we(this, "compiledExpressions", /* @__PURE__ */ new Map());
1704
+ ve(this, "resultCache", new St(500));
1705
+ ve(this, "dependencyCache", new St(200));
1706
+ ve(this, "compiledExpressions", /* @__PURE__ */ new Map());
1706
1707
  }
1707
1708
  /**
1708
1709
  * Create cache key from expression and context
@@ -1717,7 +1718,7 @@ class qr {
1717
1718
  getDependencies(t) {
1718
1719
  const r = JSON.stringify(t);
1719
1720
  let s = this.dependencyCache.get(r);
1720
- return s || (s = Pr(t), this.dependencyCache.set(r, s)), s;
1721
+ return s || (s = qr(t), this.dependencyCache.set(r, s)), s;
1721
1722
  }
1722
1723
  /**
1723
1724
  * Check if expression result is cached and context hasn't changed
@@ -1848,7 +1849,7 @@ class qr {
1848
1849
  const s = ((i = t.Arguments) == null ? void 0 : i.map((n) => this.evaluateNode(n, r))) || [];
1849
1850
  switch (t.Callee) {
1850
1851
  case "CONCAT":
1851
- return s.map((p) => String(p || "")).join("");
1852
+ return s.map((b) => String(b || "")).join("");
1852
1853
  case "TRIM":
1853
1854
  return String(s[0] || "").trim();
1854
1855
  case "LENGTH":
@@ -1862,14 +1863,14 @@ class qr {
1862
1863
  case "MATCHES":
1863
1864
  return new RegExp(String(s[1])).test(String(s[0] || ""));
1864
1865
  case "SUM":
1865
- return s.reduce((p, N) => p + (Number(N) || 0), 0);
1866
+ return s.reduce((b, O) => b + (Number(O) || 0), 0);
1866
1867
  case "AVG":
1867
- const n = s.filter((p) => !isNaN(Number(p)));
1868
- return n.length > 0 ? n.reduce((p, N) => p + Number(N), 0) / n.length : 0;
1868
+ const n = s.filter((b) => !isNaN(Number(b)));
1869
+ return n.length > 0 ? n.reduce((b, O) => b + Number(O), 0) / n.length : 0;
1869
1870
  case "MIN":
1870
- return Math.min(...s.map((p) => Number(p) || 0));
1871
+ return Math.min(...s.map((b) => Number(b) || 0));
1871
1872
  case "MAX":
1872
- return Math.max(...s.map((p) => Number(p) || 0));
1873
+ return Math.max(...s.map((b) => Number(b) || 0));
1873
1874
  case "ROUND":
1874
1875
  return Math.round(Number(s[0]) || 0);
1875
1876
  case "FLOOR":
@@ -1885,7 +1886,7 @@ class qr {
1885
1886
  case "DAY":
1886
1887
  return new Date(s[0]).getDate();
1887
1888
  case "DATE_DIFF":
1888
- const l = new Date(s[0]), d = new Date(s[1]), w = Math.abs(l.getTime() - d.getTime());
1889
+ const l = new Date(s[0]), f = new Date(s[1]), w = Math.abs(l.getTime() - f.getTime());
1889
1890
  return Math.ceil(w / (1e3 * 60 * 60 * 24));
1890
1891
  case "IF":
1891
1892
  return s[0] ? s[1] : s[2];
@@ -1912,14 +1913,14 @@ class qr {
1912
1913
  this.resultCache.clear(), this.dependencyCache.clear(), this.compiledExpressions.clear();
1913
1914
  }
1914
1915
  }
1915
- const kt = new qr();
1916
- function $r(e, t, r, s, i) {
1916
+ const Bt = new $r();
1917
+ function jr(e, t, r, s, i) {
1917
1918
  if (!r || r.length === 0)
1918
1919
  return { isValid: !0 };
1919
1920
  const n = { ...s, [e]: t };
1920
1921
  for (const l of r)
1921
1922
  try {
1922
- if (!kt.evaluate(
1923
+ if (!Bt.evaluate(
1923
1924
  l.ExpressionTree,
1924
1925
  n,
1925
1926
  i
@@ -1929,15 +1930,15 @@ function $r(e, t, r, s, i) {
1929
1930
  message: l.Message || `Validation failed for ${l.Name}`,
1930
1931
  fieldName: e
1931
1932
  };
1932
- } catch (d) {
1933
- console.warn(`Validation rule ${l.Id} failed to evaluate:`, d);
1933
+ } catch (f) {
1934
+ console.warn(`Validation rule ${l.Id} failed to evaluate:`, f);
1934
1935
  }
1935
1936
  return { isValid: !0 };
1936
1937
  }
1937
- function Dt(e) {
1938
- return Array.from(kt.getDependencies(e));
1938
+ function Rt(e) {
1939
+ return Array.from(Bt.getDependencies(e));
1939
1940
  }
1940
- function Qr(e) {
1941
+ function es(e) {
1941
1942
  const {
1942
1943
  source: t,
1943
1944
  operation: r,
@@ -1946,24 +1947,24 @@ function Qr(e) {
1946
1947
  mode: n = "onBlur",
1947
1948
  // Validation mode - controls when errors are shown (see types.ts for details)
1948
1949
  enabled: l = !0,
1949
- userRole: d,
1950
+ userRole: f,
1950
1951
  onSchemaError: w,
1951
- skipSchemaFetch: p = !1,
1952
- schema: N,
1952
+ skipSchemaFetch: b = !1,
1953
+ schema: O,
1953
1954
  interactionMode: D = "interactive"
1954
- } = e, v = D === "interactive", [m, K] = ye(null), [O, Z] = ye({}), [H, x] = ye(!1), [ee] = ye({}), [L, T] = ye(null), [ue, he] = ye(!1), [ae, ne] = ye(null), B = qe(!1), le = qe(null), V = qe(null), E = qe(w);
1955
- $e(() => {
1956
- E.current = w;
1955
+ } = e, v = D === "interactive", [m, Y] = ge(null), [C, Z] = ge({}), [W, A] = ge(!1), [ee] = ge({}), [M, L] = ge(null), [le, ye] = ge(!1), [ae, ne] = ge(null), j = Ne(!1), ce = Ne(null), V = Ne(null), x = Ne(!1), S = Ne(w);
1956
+ He(() => {
1957
+ S.current = w;
1957
1958
  }, [w]);
1958
1959
  const {
1959
- data: S,
1960
- isLoading: U,
1961
- error: $,
1962
- refetch: j
1963
- } = ct({
1960
+ data: I,
1961
+ isLoading: G,
1962
+ error: q,
1963
+ refetch: de
1964
+ } = ft({
1964
1965
  queryKey: ["form-schema", t],
1965
- queryFn: () => p ? Promise.resolve(N || {}) : Br(t),
1966
- enabled: l && (!p || !!N),
1966
+ queryFn: () => b ? Promise.resolve(O || {}) : Pr(t),
1967
+ enabled: l && (!b || !!O),
1967
1968
  retry: 3,
1968
1969
  staleTime: 30 * 60 * 1e3,
1969
1970
  // 30 minutes - schemas don't change frequently
@@ -1971,12 +1972,12 @@ function Qr(e) {
1971
1972
  // 1 hour - keep schemas in cache longer
1972
1973
  throwOnError: !1
1973
1974
  }), {
1974
- data: z,
1975
- isLoading: ce,
1976
- error: me
1977
- } = ct({
1975
+ data: K,
1976
+ isLoading: fe,
1977
+ error: Ie
1978
+ } = ft({
1978
1979
  queryKey: ["form-record", t, s],
1979
- queryFn: () => Cr(t, s),
1980
+ queryFn: () => Tr(t, s),
1980
1981
  enabled: l && r === "update" && !!s,
1981
1982
  retry: 3,
1982
1983
  staleTime: 5 * 60 * 1e3,
@@ -1984,122 +1985,132 @@ function Qr(e) {
1984
1985
  gcTime: 15 * 60 * 1e3,
1985
1986
  // 15 minutes - keep records for a reasonable time
1986
1987
  throwOnError: !1
1987
- }), Me = Ne(() => {
1988
- const o = { ...i };
1989
- if (r === "update" && z && Object.assign(o, z), m)
1990
- for (const [u, f] of Object.entries(m.fields))
1991
- f.defaultValue !== void 0 && !(u in o) && (o[u] = f.defaultValue);
1992
- return o;
1993
- }, [i, z, r, m]), A = dr({
1988
+ }), ke = Oe(() => {
1989
+ const u = { ...i };
1990
+ if (r === "update" && K && Object.assign(u, K), m)
1991
+ for (const [h, c] of Object.entries(m.fields))
1992
+ c.defaultValue !== void 0 && !(h in u) && (u[h] = c.defaultValue);
1993
+ return u;
1994
+ }, [i, K, r, m]), E = fr({
1994
1995
  mode: n,
1995
1996
  defaultValues: i,
1996
- values: r === "update" && z ? Me : void 0
1997
+ values: r === "update" && K ? ke : void 0
1997
1998
  });
1998
- $e(() => {
1999
- var o;
2000
- if (S)
1999
+ He(() => {
2000
+ var u;
2001
+ if (I)
2001
2002
  try {
2002
- const u = Dr(
2003
- S,
2003
+ const h = Sr(
2004
+ I,
2004
2005
  {},
2005
2006
  // Pass empty object - validation functions get live values from react-hook-form
2006
- d
2007
+ f
2007
2008
  );
2008
- K(u);
2009
- const f = Rr(u);
2010
- Object.keys(f).length > 0 && Mr(f).then(Z).catch(console.warn);
2011
- } catch (u) {
2012
- console.error("Schema processing failed:", u), (o = E.current) == null || o.call(E, u);
2009
+ Y(h);
2010
+ const c = Nr(h);
2011
+ Object.keys(c).length > 0 && Ir(c).then(Z).catch((d) => {
2012
+ var p;
2013
+ const y = Ve(d);
2014
+ console.warn("Failed to fetch reference data:", y), (p = S.current) == null || p.call(S, y);
2015
+ });
2016
+ } catch (h) {
2017
+ console.error("Schema processing failed:", h), (u = S.current) == null || u.call(S, Ve(h));
2013
2018
  }
2014
- }, [S, d]), $e(() => {
2015
- var o;
2016
- $ && ((o = E.current) == null || o.call(E, $));
2017
- }, [$]), $e(() => {
2018
- if (!v || r !== "create" || !m || !l || L)
2019
+ }, [I, f]), He(() => {
2020
+ var u;
2021
+ q && ((u = S.current) == null || u.call(S, q));
2022
+ }, [q]), He(() => {
2023
+ if (!v || r !== "create" || !m || !l || M || x.current)
2019
2024
  return;
2020
- (async () => {
2021
- he(!0), ne(null);
2025
+ x.current = !0;
2026
+ let u = !0;
2027
+ return (async () => {
2028
+ ye(!0), ne(null);
2022
2029
  try {
2023
- const f = await pe(t).draftInteraction({});
2024
- T(f._id), f && typeof f == "object" && Object.entries(f).forEach(([h, c]) => {
2025
- if (h === "_id") return;
2026
- A.getValues(h) !== c && A.setValue(h, c, {
2030
+ const d = await be(t).draftInteraction({});
2031
+ if (!u) return;
2032
+ L(d._id), d && typeof d == "object" && Object.entries(d).forEach(([y, p]) => {
2033
+ if (y === "_id") return;
2034
+ E.getValues(y) !== p && E.setValue(y, p, {
2027
2035
  shouldDirty: !1,
2028
2036
  shouldValidate: !1
2029
2037
  });
2030
2038
  });
2031
- } catch (u) {
2032
- console.error("Failed to create initial draft:", u), ne(u);
2039
+ } catch (c) {
2040
+ if (!u) return;
2041
+ console.error("Failed to create initial draft:", c), ne(Ve(c)), x.current = !1;
2033
2042
  } finally {
2034
- he(!1);
2043
+ u && ye(!1);
2035
2044
  }
2036
- })();
2037
- }, [v, r, m, l, L, t, A]);
2038
- const Ee = Ne(() => {
2045
+ })(), () => {
2046
+ u = !1;
2047
+ };
2048
+ }, [v, r, m, l, M, t]);
2049
+ const we = Oe(() => {
2039
2050
  if (!m) return [];
2040
- const o = /* @__PURE__ */ new Set(), u = new Set(m.computedFields);
2041
- return Object.entries(m.fieldRules).forEach(([f, h]) => {
2042
- h.computation.forEach((c) => {
2043
- const y = m.rules.computation[c];
2044
- y != null && y.ExpressionTree && Dt(y.ExpressionTree).forEach((b) => {
2045
- m.fields[b] && b !== f && !u.has(b) && o.add(b);
2051
+ const u = /* @__PURE__ */ new Set(), h = new Set(m.computedFields);
2052
+ return Object.entries(m.fieldRules).forEach(([c, d]) => {
2053
+ d.computation.forEach((y) => {
2054
+ const p = m.rules.computation[y];
2055
+ p != null && p.ExpressionTree && Rt(p.ExpressionTree).forEach((_) => {
2056
+ m.fields[_] && _ !== c && !h.has(_) && u.add(_);
2046
2057
  });
2047
2058
  });
2048
- }), m.computedFields.forEach((f) => {
2049
- const h = m.fields[f];
2050
- h._bdoField.Formula && Dt(
2051
- h._bdoField.Formula.ExpressionTree
2052
- ).forEach((y) => {
2053
- m.fields[y] && y !== f && !u.has(y) && o.add(y);
2059
+ }), m.computedFields.forEach((c) => {
2060
+ const d = m.fields[c];
2061
+ d._bdoField.Formula && Rt(
2062
+ d._bdoField.Formula.ExpressionTree
2063
+ ).forEach((p) => {
2064
+ m.fields[p] && p !== c && !h.has(p) && u.add(p);
2054
2065
  });
2055
- }), Array.from(o);
2056
- }, [m]), Ae = te(
2057
- async (o) => {
2058
- if (!(!m || !(v || Ee.length > 0 && Ee.includes(o)))) {
2059
- if (v && r === "create" && !L) {
2066
+ }), Array.from(u);
2067
+ }, [m]), Ue = te(
2068
+ async (u) => {
2069
+ if (!(!m || !(v && r !== "update" || we.length > 0 && we.includes(u)))) {
2070
+ if (v && r === "create" && !M) {
2060
2071
  console.warn("Interactive create mode: waiting for draft ID");
2061
2072
  return;
2062
2073
  }
2063
- B.current || (le.current && clearTimeout(le.current), le.current = setTimeout(() => {
2064
- if (!m || B.current)
2074
+ j.current || (ce.current && clearTimeout(ce.current), ce.current = setTimeout(() => {
2075
+ if (!m || j.current)
2065
2076
  return;
2066
- const f = A.getValues();
2077
+ const c = E.getValues();
2067
2078
  (async () => {
2068
- B.current = !0;
2079
+ j.current = !0;
2069
2080
  try {
2070
- const c = pe(t), y = {};
2071
- r === "update" && s && "_id" in f && (y._id = f._id), v && r === "create" && L && (y._id = L);
2072
- const F = V.current ?? (r === "update" ? z : null) ?? {}, b = new Set(
2081
+ const y = be(t), p = {};
2082
+ r === "update" && s && "_id" in c && (p._id = c._id), v && r === "create" && M && (p._id = M);
2083
+ const F = V.current ?? (r === "update" ? K : null) ?? {}, _ = new Set(
2073
2084
  m.computedFields || []
2074
2085
  );
2075
- Object.keys(f).forEach((q) => {
2076
- if (q === "_id" || b.has(q)) return;
2077
- const J = f[q], be = F[q];
2078
- JSON.stringify(J) !== JSON.stringify(be) && (J !== "" && J !== null && J !== void 0) && (y[q] = J);
2086
+ Object.keys(c).forEach((B) => {
2087
+ if (B === "_id" || _.has(B)) return;
2088
+ const z = c[B], We = F[B];
2089
+ JSON.stringify(z) !== JSON.stringify(We) && (z !== "" && z !== null && z !== void 0) && (p[B] = z);
2079
2090
  });
2080
- const _ = y, P = {
2091
+ const R = p, $ = {
2081
2092
  ...V.current
2082
2093
  };
2083
- Object.keys(f).forEach((q) => {
2084
- b.has(q) || (P[q] = f[q]);
2085
- }), V.current = P;
2086
- let W;
2087
- r === "update" && s ? W = await c.draftPatch(s, _) : v && L ? W = await c.draftInteraction(_) : W = await c.draft(_), W && typeof W == "object" && (Object.entries(W).forEach(
2088
- ([q, J]) => {
2089
- f[q] !== J && A.setValue(q, J, {
2094
+ Object.keys(c).forEach((B) => {
2095
+ _.has(B) || ($[B] = c[B]);
2096
+ }), V.current = $;
2097
+ let ue;
2098
+ r === "update" && s ? ue = await y.draftPatch(s, R) : v && M ? ue = await y.draftInteraction(R) : ue = await y.draft(R), ue && typeof ue == "object" && (Object.entries(ue).forEach(
2099
+ ([B, z]) => {
2100
+ c[B] !== z && E.setValue(B, z, {
2090
2101
  shouldDirty: !1,
2091
2102
  shouldValidate: !1
2092
2103
  });
2093
2104
  }
2094
- ), Object.entries(W).forEach(
2095
- ([q, J]) => {
2096
- b.has(q) && (V.current[q] = J);
2105
+ ), Object.entries(ue).forEach(
2106
+ ([B, z]) => {
2107
+ _.has(B) && (V.current[B] = z);
2097
2108
  }
2098
2109
  ));
2099
- } catch (c) {
2100
- console.warn("Failed to compute fields via API:", c);
2110
+ } catch (y) {
2111
+ console.warn("Failed to compute fields via API:", y);
2101
2112
  } finally {
2102
- B.current = !1;
2113
+ j.current = !1;
2103
2114
  }
2104
2115
  })();
2105
2116
  }, 300));
@@ -2109,247 +2120,247 @@ function Qr(e) {
2109
2120
  m,
2110
2121
  r,
2111
2122
  s,
2112
- z,
2123
+ K,
2113
2124
  t,
2114
- A,
2115
- Ee,
2125
+ E,
2126
+ we,
2116
2127
  v,
2117
- L
2128
+ M
2118
2129
  ]
2119
- ), Ye = te(async () => {
2130
+ ), Be = te(async () => {
2120
2131
  if (!m)
2121
2132
  return !1;
2122
- const o = A.getValues();
2123
- if (!await A.trigger())
2133
+ const u = E.getValues();
2134
+ if (!await E.trigger())
2124
2135
  return !1;
2125
- const f = m.crossFieldValidation.map(
2126
- (c) => ({
2127
- Id: c.Id,
2128
- Condition: { ExpressionTree: c.ExpressionTree },
2129
- Message: c.Message || `Validation failed for ${c.Name}`
2136
+ const c = m.crossFieldValidation.map(
2137
+ (y) => ({
2138
+ Id: y.Id,
2139
+ Condition: { ExpressionTree: y.ExpressionTree },
2140
+ Message: y.Message || `Validation failed for ${y.Name}`
2130
2141
  })
2131
- ), h = At(
2132
- f,
2133
- o,
2134
- O
2142
+ ), d = _t(
2143
+ c,
2144
+ u,
2145
+ C
2135
2146
  );
2136
- return h.length > 0 ? (h.forEach((c, y) => {
2137
- A.setError(`root.crossField${y}`, {
2147
+ return d.length > 0 ? (d.forEach((y, p) => {
2148
+ E.setError(`root.crossField${p}`, {
2138
2149
  type: "validate",
2139
- message: c.message
2150
+ message: y.message
2140
2151
  });
2141
2152
  }), !1) : !0;
2142
2153
  }, [
2143
2154
  m,
2144
- A.getValues,
2145
- A.trigger,
2146
- A.setError,
2147
- O
2148
- ]), Ie = te(
2149
- (o, u) => A.handleSubmit(
2155
+ E.getValues,
2156
+ E.trigger,
2157
+ E.setError,
2158
+ C
2159
+ ]), Je = te(
2160
+ (u, h) => E.handleSubmit(
2150
2161
  // RHF onValid handler - validation passed, now do cross-field + API
2151
- async (f, h) => {
2162
+ async (c, d) => {
2152
2163
  if (!m) {
2153
- const c = new Error("Schema not loaded");
2154
- u == null || u(c, h);
2164
+ const y = new Error("Schema not loaded");
2165
+ h == null || h(y, d);
2155
2166
  return;
2156
2167
  }
2157
- x(!0);
2168
+ A(!0);
2158
2169
  try {
2159
- const c = m.crossFieldValidation.map(
2160
- (_) => ({
2161
- Id: _.Id,
2162
- Condition: { ExpressionTree: _.ExpressionTree },
2163
- Message: _.Message || `Validation failed for ${_.Name}`
2170
+ const y = m.crossFieldValidation.map(
2171
+ (R) => ({
2172
+ Id: R.Id,
2173
+ Condition: { ExpressionTree: R.ExpressionTree },
2174
+ Message: R.Message || `Validation failed for ${R.Name}`
2164
2175
  })
2165
- ), y = At(
2176
+ ), p = _t(
2177
+ y,
2166
2178
  c,
2167
- f,
2168
- O
2179
+ C
2169
2180
  );
2170
- if (y.length > 0) {
2171
- y.forEach((_, P) => {
2172
- A.setError(`root.crossField${P}`, {
2181
+ if (p.length > 0) {
2182
+ p.forEach((R, $) => {
2183
+ E.setError(`root.crossField${$}`, {
2173
2184
  type: "validate",
2174
- message: _.message
2185
+ message: R.message
2175
2186
  });
2176
- }), u == null || u(A.formState.errors, h);
2187
+ }), h == null || h(E.formState.errors, d);
2177
2188
  return;
2178
2189
  }
2179
- const F = Ir(
2180
- f,
2190
+ const F = kr(
2191
+ c,
2181
2192
  m.computedFields,
2182
2193
  r,
2183
- z
2194
+ K
2184
2195
  );
2185
- let b;
2196
+ let _;
2186
2197
  if (v) {
2187
- const _ = pe(t);
2198
+ const R = be(t);
2188
2199
  if (r === "create") {
2189
- if (!L)
2200
+ if (!M)
2190
2201
  throw new Error(
2191
2202
  "Interactive create mode requires a draft ID. Draft creation may have failed."
2192
2203
  );
2193
- b = { success: !0, data: await _.draft({
2204
+ _ = { success: !0, data: await R.draft({
2194
2205
  ...F,
2195
- _id: L
2206
+ _id: M
2196
2207
  }) };
2197
2208
  } else
2198
- b = { success: !0, data: await _.draftUpdate(s, F) };
2199
- } else if (b = await Tr(
2209
+ _ = { success: !0, data: await R.update(s, F) };
2210
+ } else if (_ = await Lr(
2200
2211
  t,
2201
2212
  r,
2202
2213
  F,
2203
2214
  s
2204
- ), !b.success)
2205
- throw b.error || new Error("Submission failed");
2206
- r === "create" && (A.reset(), v && T(null)), await (o == null ? void 0 : o(b.data || f, h));
2207
- } catch (c) {
2208
- u == null || u(c, h);
2215
+ ), !_.success)
2216
+ throw _.error || new Error("Submission failed");
2217
+ r === "create" && (E.reset(), v && L(null)), await (u == null ? void 0 : u(_.data || c, d));
2218
+ } catch (y) {
2219
+ h == null || h(Ve(y), d);
2209
2220
  } finally {
2210
- x(!1);
2221
+ A(!1);
2211
2222
  }
2212
2223
  },
2213
2224
  // RHF onInvalid handler - validation failed
2214
- (f, h) => {
2215
- u == null || u(f, h);
2225
+ (c, d) => {
2226
+ h == null || h(c, d);
2216
2227
  }
2217
2228
  ),
2218
2229
  [
2219
- A,
2230
+ E,
2220
2231
  m,
2221
- O,
2232
+ C,
2222
2233
  t,
2223
2234
  r,
2224
2235
  s,
2225
- z,
2236
+ K,
2226
2237
  v,
2227
- L
2238
+ M
2228
2239
  ]
2229
- ), Ke = te(
2230
- (o) => (m == null ? void 0 : m.fields[o]) || null,
2240
+ ), xe = te(
2241
+ (u) => (m == null ? void 0 : m.fields[u]) || null,
2231
2242
  [m]
2232
- ), xe = te(() => {
2243
+ ), Pe = te(() => {
2233
2244
  if (!m) return {};
2234
- const o = {};
2235
- return Object.entries(m.fields).forEach(([u, f]) => {
2236
- o[u] = f;
2237
- }), o;
2238
- }, [m]), ke = te(
2239
- (o) => !!(m != null && m.fields[o]),
2240
- [m]
2241
- ), _e = te(
2242
- (o) => (m == null ? void 0 : m.requiredFields.includes(o)) || !1,
2245
+ const u = {};
2246
+ return Object.entries(m.fields).forEach(([h, c]) => {
2247
+ u[h] = c;
2248
+ }), u;
2249
+ }, [m]), _e = te(
2250
+ (u) => !!(m != null && m.fields[u]),
2243
2251
  [m]
2244
2252
  ), De = te(
2245
- (o) => (m == null ? void 0 : m.computedFields.includes(o)) || !1,
2253
+ (u) => (m == null ? void 0 : m.requiredFields.includes(u)) || !1,
2254
+ [m]
2255
+ ), Ge = te(
2256
+ (u) => (m == null ? void 0 : m.computedFields.includes(u)) || !1,
2246
2257
  [m]
2247
- ), ze = te(async () => {
2248
- await j();
2249
- }, [j]), Ue = te(() => {
2250
- A.clearErrors();
2251
- }, [A]), Be = U || r === "update" && ce || v && r === "create" && ue, Pe = Be || H, Se = $ || me || ae, Je = !!Se, Ge = Ne(
2258
+ ), qe = te(async () => {
2259
+ await de();
2260
+ }, [de]), Xe = te(() => {
2261
+ E.clearErrors();
2262
+ }, [E]), Se = G || r === "update" && fe || v && r === "create" && le, $e = Se || W, Re = q || Ie || ae, Qe = !!Re, lt = Oe(
2252
2263
  () => (m == null ? void 0 : m.computedFields) || [],
2253
2264
  [m]
2254
- ), ot = Ne(
2265
+ ), je = Oe(
2255
2266
  () => (m == null ? void 0 : m.requiredFields) || [],
2256
2267
  [m]
2257
- ), Re = Ne(() => {
2268
+ ), a = Oe(() => {
2258
2269
  if (!m) return {};
2259
- const o = {};
2260
- return Object.entries(m.fields).forEach(([u, f]) => {
2261
- const h = {};
2262
- switch (f.required && (h.required = `${f.label} is required`), f.permission.editable || (h.disabled = !0), f.type) {
2270
+ const u = {};
2271
+ return Object.entries(m.fields).forEach(([h, c]) => {
2272
+ const d = {};
2273
+ switch (c.required && (d.required = `${c.label} is required`), c.permission.editable || (d.disabled = !0), c.type) {
2263
2274
  case "number":
2264
- h.valueAsNumber = !0;
2275
+ d.valueAsNumber = !0;
2265
2276
  break;
2266
2277
  case "date":
2267
2278
  case "datetime-local":
2268
- h.valueAsDate = !0;
2279
+ d.valueAsDate = !0;
2269
2280
  break;
2270
2281
  }
2271
- const c = f.rules.validation;
2272
- c.length > 0 && (h.validate = {
2273
- expressionValidation: (y) => {
2274
- const F = A.getValues();
2275
- for (const b of c) {
2276
- const _ = m.rules.validation[b];
2277
- if (_) {
2278
- const P = $r(
2279
- u,
2280
- y,
2281
- [_],
2282
+ const y = c.rules.validation;
2283
+ y.length > 0 && (d.validate = {
2284
+ expressionValidation: (p) => {
2285
+ const F = E.getValues();
2286
+ for (const _ of y) {
2287
+ const R = m.rules.validation[_];
2288
+ if (R) {
2289
+ const $ = jr(
2290
+ h,
2291
+ p,
2292
+ [R],
2282
2293
  F,
2283
2294
  ee
2284
2295
  );
2285
- if (!P.isValid)
2286
- return P.message || _.Message || "Invalid value";
2296
+ if (!$.isValid)
2297
+ return $.message || R.Message || "Invalid value";
2287
2298
  }
2288
2299
  }
2289
2300
  return !0;
2290
2301
  }
2291
- }), o[u] = h;
2292
- }), o;
2293
- }, [m, A, O]);
2302
+ }), u[h] = d;
2303
+ }), u;
2304
+ }, [m, E, C]);
2294
2305
  return {
2295
2306
  // Form methods with strict typing
2296
2307
  register: te(
2297
- (o, u) => {
2298
- const f = Re[o], h = u == null ? void 0 : u.onBlur, c = async (y) => {
2299
- h && await h(y);
2308
+ (u, h) => {
2309
+ const c = a[u], d = h == null ? void 0 : h.onBlur, y = async (p) => {
2310
+ d && await d(p);
2300
2311
  let F = !0;
2301
- n === "onBlur" || n === "onTouched" || n === "all" ? F = await A.trigger(o) : F = !A.getFieldState(o, A.formState).error, F && await Ae(o);
2312
+ n === "onBlur" || n === "onTouched" || n === "all" ? F = await E.trigger(u) : F = !E.getFieldState(u, E.formState).error, F && await Ue(u);
2302
2313
  };
2303
- return A.register(o, {
2304
- ...f,
2305
- ...u,
2306
- onBlur: c
2314
+ return E.register(u, {
2315
+ ...c,
2316
+ ...h,
2317
+ onBlur: y
2307
2318
  });
2308
2319
  },
2309
- [A, Re, Ae, n]
2320
+ [E, a, Ue, n]
2310
2321
  ),
2311
- handleSubmit: Ie,
2312
- watch: A.watch,
2322
+ handleSubmit: Je,
2323
+ watch: E.watch,
2313
2324
  // Type assertion for complex generic constraints
2314
- setValue: A.setValue,
2315
- reset: A.reset,
2325
+ setValue: E.setValue,
2326
+ reset: E.reset,
2316
2327
  // Flattened form state (NEW - direct access, no nested formState)
2317
- errors: A.formState.errors,
2318
- isValid: A.formState.isValid,
2319
- isDirty: A.formState.isDirty,
2320
- isSubmitting: A.formState.isSubmitting || H,
2321
- isSubmitSuccessful: A.formState.isSubmitSuccessful,
2328
+ errors: E.formState.errors,
2329
+ isValid: E.formState.isValid,
2330
+ isDirty: E.formState.isDirty,
2331
+ isSubmitting: E.formState.isSubmitting || W,
2332
+ isSubmitSuccessful: E.formState.isSubmitSuccessful,
2322
2333
  // Loading states
2323
- isLoadingInitialData: Be,
2324
- isLoadingRecord: ce,
2325
- isLoading: Pe,
2334
+ isLoadingInitialData: Se,
2335
+ isLoadingRecord: fe,
2336
+ isLoading: $e,
2326
2337
  // Interactive mode state
2327
- draftId: L,
2328
- isCreatingDraft: ue,
2338
+ draftId: M,
2339
+ isCreatingDraft: le,
2329
2340
  // Error handling
2330
- loadError: Se,
2331
- hasError: Je,
2341
+ loadError: Re ? Ve(Re) : null,
2342
+ hasError: Qe,
2332
2343
  // Schema information
2333
- schema: S,
2344
+ schema: I,
2334
2345
  schemaConfig: m,
2335
- computedFields: Ge,
2336
- requiredFields: ot,
2346
+ computedFields: lt,
2347
+ requiredFields: je,
2337
2348
  // Field helpers
2338
- getField: Ke,
2339
- getFields: xe,
2340
- hasField: ke,
2341
- isFieldRequired: _e,
2342
- isFieldComputed: De,
2349
+ getField: xe,
2350
+ getFields: Pe,
2351
+ hasField: _e,
2352
+ isFieldRequired: De,
2353
+ isFieldComputed: Ge,
2343
2354
  // Operations
2344
- refreshSchema: ze,
2345
- validateForm: Ye,
2346
- clearErrors: Ue
2355
+ refreshSchema: qe,
2356
+ validateForm: Be,
2357
+ clearErrors: Xe
2347
2358
  };
2348
2359
  }
2349
2360
  export {
2350
- Xr as clearFormCache,
2351
- Jr as isNetworkError,
2352
- Gr as isValidationError,
2353
- zr as parseApiError,
2354
- Qr as useForm
2361
+ Zr as clearFormCache,
2362
+ Xr as isNetworkError,
2363
+ Qr as isValidationError,
2364
+ Gr as parseApiError,
2365
+ es as useForm
2355
2366
  };