@ram_28/kf-ai-sdk 1.0.19 → 1.0.21

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