suprform 1.1.4 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,39 @@
1
- import { jsx as ee, jsxs as dt, Fragment as Qt } from "react/jsx-runtime";
2
- import b, { createContext as Gt, useContext as zt, useMemo as he, cloneElement as Ae, useImperativeHandle as bt, Children as Kt, isValidElement as Yt, useEffect as Jt } from "react";
3
- var ve = (t) => t.type === "checkbox", le = (t) => t instanceof Date, G = (t) => t == null;
4
- const At = (t) => typeof t == "object";
5
- var P = (t) => !G(t) && !Array.isArray(t) && At(t) && !le(t), pt = (t) => P(t) && t.target ? ve(t.target) ? t.target.checked : t.target.value : t, Xt = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, xt = (t, r) => t.has(Xt(r)), Zt = (t) => {
1
+ import { jsx as te, jsxs as Le, Fragment as Qt } from "react/jsx-runtime";
2
+ import F, { createContext as zt, useContext as Kt, useMemo as ye, cloneElement as Ae, useImperativeHandle as At, Children as Yt, isValidElement as Jt, useEffect as Xt } from "react";
3
+ var ve = (t) => t.type === "checkbox", oe = (t) => t instanceof Date, Q = (t) => t == null;
4
+ const pt = (t) => typeof t == "object";
5
+ var H = (t) => !Q(t) && !Array.isArray(t) && pt(t) && !oe(t), xt = (t) => H(t) && t.target ? ve(t.target) ? t.target.checked : t.target.value : t, Zt = (t) => t.substring(0, t.search(/\.\d+(\.|$)/)) || t, St = (t, r) => t.has(Zt(r)), er = (t) => {
6
6
  const r = t.constructor && t.constructor.prototype;
7
- return P(r) && r.hasOwnProperty("isPrototypeOf");
8
- }, ze = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
9
- function U(t) {
10
- let r;
11
- const e = Array.isArray(t), s = typeof FileList < "u" ? t instanceof FileList : !1;
7
+ return H(r) && r.hasOwnProperty("isPrototypeOf");
8
+ }, Ke = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
9
+ function M(t) {
12
10
  if (t instanceof Date)
13
- r = new Date(t);
14
- else if (!(ze && (t instanceof Blob || s)) && (e || P(t)))
15
- if (r = e ? [] : Object.create(Object.getPrototypeOf(t)), !e && !Zt(t))
16
- r = t;
17
- else
18
- for (const u in t)
19
- t.hasOwnProperty(u) && (r[u] = U(t[u]));
20
- else
11
+ return new Date(t);
12
+ const r = typeof FileList < "u" && t instanceof FileList;
13
+ if (Ke && (t instanceof Blob || r))
21
14
  return t;
22
- return r;
15
+ const e = Array.isArray(t);
16
+ if (!e && !(H(t) && er(t)))
17
+ return t;
18
+ const s = e ? [] : Object.create(Object.getPrototypeOf(t));
19
+ for (const u in t)
20
+ Object.prototype.hasOwnProperty.call(t, u) && (s[u] = M(t[u]));
21
+ return s;
23
22
  }
24
- var Ee = (t) => /^\w*$/.test(t), O = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ke = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
25
- if (!r || !P(t))
23
+ var Ee = (t) => /^\w*$/.test(t), N = (t) => t === void 0, we = (t) => Array.isArray(t) ? t.filter(Boolean) : [], Ye = (t) => we(t.replace(/["|']|\]/g, "").split(/\.|\[/)), m = (t, r, e) => {
24
+ if (!r || !H(t))
26
25
  return e;
27
- const s = (Ee(r) ? [r] : Ke(r)).reduce((u, i) => G(u) ? u : u[i], t);
28
- return O(s) || s === t ? O(t[r]) ? e : t[r] : s;
29
- }, K = (t) => typeof t == "boolean", R = (t, r, e) => {
26
+ const s = (Ee(r) ? [r] : Ye(r)).reduce((u, i) => Q(u) ? u : u[i], t);
27
+ return N(s) || s === t ? N(t[r]) ? e : t[r] : s;
28
+ }, J = (t) => typeof t == "boolean", G = (t) => typeof t == "function", O = (t, r, e) => {
30
29
  let s = -1;
31
- const u = Ee(r) ? [r] : Ke(r), i = u.length, c = i - 1;
30
+ const u = Ee(r) ? [r] : Ye(r), i = u.length, c = i - 1;
32
31
  for (; ++s < i; ) {
33
32
  const l = u[s];
34
33
  let V = e;
35
34
  if (s !== c) {
36
- const v = t[l];
37
- V = P(v) || Array.isArray(v) ? v : isNaN(+u[s + 1]) ? {} : [];
35
+ const h = t[l];
36
+ V = H(h) || Array.isArray(h) ? h : isNaN(+u[s + 1]) ? {} : [];
38
37
  }
39
38
  if (l === "__proto__" || l === "constructor" || l === "prototype")
40
39
  return;
@@ -45,7 +44,7 @@ const pe = {
45
44
  BLUR: "blur",
46
45
  FOCUS_OUT: "focusout",
47
46
  CHANGE: "change"
48
- }, X = {
47
+ }, re = {
49
48
  onBlur: "onBlur",
50
49
  onChange: "onChange",
51
50
  onSubmit: "onSubmit",
@@ -59,13 +58,13 @@ const pe = {
59
58
  pattern: "pattern",
60
59
  required: "required",
61
60
  validate: "validate"
62
- }, Ye = b.createContext(null);
63
- Ye.displayName = "HookFormContext";
64
- const Ve = () => b.useContext(Ye), er = (t) => {
61
+ }, Je = F.createContext(null);
62
+ Je.displayName = "HookFormContext";
63
+ const Ve = () => F.useContext(Je), tr = (t) => {
65
64
  const { children: r, ...e } = t;
66
- return b.createElement(Ye.Provider, { value: e }, r);
65
+ return F.createElement(Je.Provider, { value: e }, r);
67
66
  };
68
- var St = (t, r, e, s = !0) => {
67
+ var Et = (t, r, e, s = !0) => {
69
68
  const u = {
70
69
  defaultValues: r._defaultValues
71
70
  };
@@ -73,14 +72,14 @@ var St = (t, r, e, s = !0) => {
73
72
  Object.defineProperty(u, i, {
74
73
  get: () => {
75
74
  const c = i;
76
- return r._proxyFormState[c] !== X.all && (r._proxyFormState[c] = !s || X.all), e && (e[c] = !0), t[c];
75
+ return r._proxyFormState[c] !== re.all && (r._proxyFormState[c] = !s || re.all), e && (e[c] = !0), t[c];
77
76
  }
78
77
  });
79
78
  return u;
80
79
  };
81
- const ke = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
82
- function tr(t) {
83
- const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = b.useState(e._formState), V = b.useRef({
80
+ const ke = typeof window < "u" ? F.useLayoutEffect : F.useEffect;
81
+ function rr(t) {
82
+ const r = Ve(), { control: e = r.control, disabled: s, name: u, exact: i } = t || {}, [c, l] = F.useState(e._formState), V = F.useRef({
84
83
  isDirty: !1,
85
84
  isLoading: !1,
86
85
  dirtyFields: !1,
@@ -94,21 +93,21 @@ function tr(t) {
94
93
  name: u,
95
94
  formState: V.current,
96
95
  exact: i,
97
- callback: (v) => {
96
+ callback: (h) => {
98
97
  !s && l({
99
98
  ...e._formState,
100
- ...v
99
+ ...h
101
100
  });
102
101
  }
103
- }), [u, s, i]), b.useEffect(() => {
102
+ }), [u, s, i]), F.useEffect(() => {
104
103
  V.current.isValid && e._setValid(!0);
105
- }, [e]), b.useMemo(() => St(c, e, V.current, !1), [c, e]);
104
+ }, [e]), F.useMemo(() => Et(c, e, V.current, !1), [c, e]);
106
105
  }
107
- var Y = (t) => typeof t == "string", He = (t, r, e, s, u) => Y(t) ? (s && r.watch.add(t), m(e, t, u)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), m(e, i))) : (s && (r.watchAll = !0), e), qe = (t) => G(t) || !At(t);
108
- function te(t, r, e = /* @__PURE__ */ new WeakSet()) {
109
- if (qe(t) || qe(r))
106
+ var X = (t) => typeof t == "string", qe = (t, r, e, s, u) => X(t) ? (s && r.watch.add(t), m(e, t, u)) : Array.isArray(t) ? t.map((i) => (s && r.watch.add(i), m(e, i))) : (s && (r.watchAll = !0), e), je = (t) => Q(t) || !pt(t);
107
+ function ae(t, r, e = /* @__PURE__ */ new WeakSet()) {
108
+ if (je(t) || je(r))
110
109
  return Object.is(t, r);
111
- if (le(t) && le(r))
110
+ if (oe(t) && oe(r))
112
111
  return t.getTime() === r.getTime();
113
112
  const s = Object.keys(t), u = Object.keys(r);
114
113
  if (s.length !== u.length)
@@ -122,66 +121,66 @@ function te(t, r, e = /* @__PURE__ */ new WeakSet()) {
122
121
  return !1;
123
122
  if (i !== "ref") {
124
123
  const l = r[i];
125
- if (le(c) && le(l) || P(c) && P(l) || Array.isArray(c) && Array.isArray(l) ? !te(c, l, e) : !Object.is(c, l))
124
+ if (oe(c) && oe(l) || H(c) && H(l) || Array.isArray(c) && Array.isArray(l) ? !ae(c, l, e) : !Object.is(c, l))
126
125
  return !1;
127
126
  }
128
127
  }
129
128
  return !0;
130
129
  }
131
- function Je(t) {
132
- const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = b.useRef(u), v = b.useRef(l), x = b.useRef(void 0), g = b.useRef(e), F = b.useRef(s);
133
- v.current = l;
134
- const [$, L] = b.useState(() => {
130
+ function Xe(t) {
131
+ const r = Ve(), { control: e = r.control, name: s, defaultValue: u, disabled: i, exact: c, compute: l } = t || {}, V = F.useRef(u), h = F.useRef(l), k = F.useRef(void 0), g = F.useRef(e), S = F.useRef(s);
132
+ h.current = l;
133
+ const [p, I] = F.useState(() => {
135
134
  const f = e._getWatch(s, V.current);
136
- return v.current ? v.current(f) : f;
137
- }), w = b.useCallback((f) => {
138
- const d = He(s, e._names, f || e._formValues, !1, V.current);
139
- return v.current ? v.current(d) : d;
140
- }, [e._formValues, e._names, s]), N = b.useCallback((f) => {
135
+ return h.current ? h.current(f) : f;
136
+ }), R = F.useCallback((f) => {
137
+ const d = qe(s, e._names, f || e._formValues, !1, V.current);
138
+ return h.current ? h.current(d) : d;
139
+ }, [e._formValues, e._names, s]), T = F.useCallback((f) => {
141
140
  if (!i) {
142
- const d = He(s, e._names, f || e._formValues, !1, V.current);
143
- if (v.current) {
144
- const p = v.current(d);
145
- te(p, x.current) || (L(p), x.current = p);
141
+ const d = qe(s, e._names, f || e._formValues, !1, V.current);
142
+ if (h.current) {
143
+ const A = h.current(d);
144
+ ae(A, k.current) || (I(A), k.current = A);
146
145
  } else
147
- L(d);
146
+ I(d);
148
147
  }
149
148
  }, [e._formValues, e._names, i, s]);
150
- ke(() => ((g.current !== e || !te(F.current, s)) && (g.current = e, F.current = s, N()), e._subscribe({
149
+ ke(() => ((g.current !== e || !ae(S.current, s)) && (g.current = e, S.current = s, T()), e._subscribe({
151
150
  name: s,
152
151
  formState: {
153
152
  values: !0
154
153
  },
155
154
  exact: c,
156
155
  callback: (f) => {
157
- N(f.values);
156
+ T(f.values);
158
157
  }
159
- })), [e, c, s, N]), b.useEffect(() => e._removeUnmounted());
160
- const H = g.current !== e, S = F.current, M = b.useMemo(() => {
158
+ })), [e, c, s, T]), F.useEffect(() => e._removeUnmounted());
159
+ const U = g.current !== e, x = S.current, B = F.useMemo(() => {
161
160
  if (i)
162
161
  return null;
163
- const f = !H && !te(S, s);
164
- return H || f ? w() : null;
165
- }, [i, H, s, S, w]);
166
- return M !== null ? M : $;
162
+ const f = !U && !ae(x, s);
163
+ return U || f ? R() : null;
164
+ }, [i, U, s, x, R]);
165
+ return B !== null ? B : p;
167
166
  }
168
- function rr(t) {
169
- const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = xt(u._names.array, e), v = b.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), x = Je({
167
+ function sr(t) {
168
+ const r = Ve(), { name: e, disabled: s, control: u = r.control, shouldUnregister: i, defaultValue: c, exact: l = !0 } = t, V = St(u._names.array, e), h = F.useMemo(() => m(u._formValues, e, m(u._defaultValues, e, c)), [u, e, c]), k = Xe({
170
169
  control: u,
171
170
  name: e,
172
- defaultValue: v,
171
+ defaultValue: h,
173
172
  exact: l
174
- }), g = tr({
173
+ }), g = rr({
175
174
  control: u,
176
175
  name: e,
177
176
  exact: l
178
- }), F = b.useRef(t), $ = b.useRef(void 0), L = b.useRef(u.register(e, {
177
+ }), S = F.useRef(t), p = F.useRef(void 0), I = F.useRef(u.register(e, {
179
178
  ...t.rules,
180
- value: x,
181
- ...K(t.disabled) ? { disabled: t.disabled } : {}
179
+ value: k,
180
+ ...J(t.disabled) ? { disabled: t.disabled } : {}
182
181
  }));
183
- F.current = t;
184
- const w = b.useMemo(() => Object.defineProperties({}, {
182
+ S.current = t;
183
+ const R = F.useMemo(() => Object.defineProperties({}, {
185
184
  invalid: {
186
185
  enumerable: !0,
187
186
  get: () => !!m(g.errors, e)
@@ -202,70 +201,70 @@ function rr(t) {
202
201
  enumerable: !0,
203
202
  get: () => m(g.errors, e)
204
203
  }
205
- }), [g, e]), N = b.useCallback((f) => L.current.onChange({
204
+ }), [g, e]), T = F.useCallback((f) => I.current.onChange({
206
205
  target: {
207
- value: pt(f),
206
+ value: xt(f),
208
207
  name: e
209
208
  },
210
209
  type: pe.CHANGE
211
- }), [e]), H = b.useCallback(() => L.current.onBlur({
210
+ }), [e]), U = F.useCallback(() => I.current.onBlur({
212
211
  target: {
213
212
  value: m(u._formValues, e),
214
213
  name: e
215
214
  },
216
215
  type: pe.BLUR
217
- }), [e, u._formValues]), S = b.useCallback((f) => {
216
+ }), [e, u._formValues]), x = F.useCallback((f) => {
218
217
  const d = m(u._fields, e);
219
- d && f && (d._f.ref = {
220
- focus: () => f.focus && f.focus(),
221
- select: () => f.select && f.select(),
222
- setCustomValidity: (p) => f.setCustomValidity(p),
223
- reportValidity: () => f.reportValidity()
218
+ d && d._f && f && (d._f.ref = {
219
+ focus: () => G(f.focus) && f.focus(),
220
+ select: () => G(f.select) && f.select(),
221
+ setCustomValidity: (A) => G(f.setCustomValidity) && f.setCustomValidity(A),
222
+ reportValidity: () => G(f.reportValidity) && f.reportValidity()
224
223
  });
225
- }, [u._fields, e]), M = b.useMemo(() => ({
224
+ }, [u._fields, e]), B = F.useMemo(() => ({
226
225
  name: e,
227
- value: x,
228
- ...K(s) || g.disabled ? { disabled: g.disabled || s } : {},
229
- onChange: N,
230
- onBlur: H,
231
- ref: S
232
- }), [e, s, g.disabled, N, H, S, x]);
233
- return b.useEffect(() => {
234
- const f = u._options.shouldUnregister || i, d = $.current;
226
+ value: k,
227
+ ...J(s) || g.disabled ? { disabled: g.disabled || s } : {},
228
+ onChange: T,
229
+ onBlur: U,
230
+ ref: x
231
+ }), [e, s, g.disabled, T, U, x, k]);
232
+ return F.useEffect(() => {
233
+ const f = u._options.shouldUnregister || i, d = p.current;
235
234
  d && d !== e && !V && u.unregister(d), u.register(e, {
236
- ...F.current.rules,
237
- ...K(F.current.disabled) ? { disabled: F.current.disabled } : {}
235
+ ...S.current.rules,
236
+ ...J(S.current.disabled) ? { disabled: S.current.disabled } : {}
238
237
  });
239
- const p = (E, Z) => {
240
- const W = m(u._fields, E);
241
- W && W._f && (W._f.mount = Z);
238
+ const A = (w, W) => {
239
+ const K = m(u._fields, w);
240
+ K && K._f && (K._f.mount = W);
242
241
  };
243
- if (p(e, !0), f) {
244
- const E = U(m(u._options.defaultValues, e, F.current.defaultValue));
245
- R(u._defaultValues, e, E), O(m(u._formValues, e)) && R(u._formValues, e, E);
242
+ if (A(e, !0), f) {
243
+ const w = M(m(u._options.defaultValues, e, S.current.defaultValue));
244
+ O(u._defaultValues, e, w), N(m(u._formValues, e)) && O(u._formValues, e, w);
246
245
  }
247
- return !V && u.register(e), $.current = e, () => {
248
- (V ? f && !u._state.action : f) ? u.unregister(e) : p(e, !1);
246
+ return !V && u.register(e), p.current = e, () => {
247
+ (V ? f && !u._state.action : f) ? u.unregister(e) : A(e, !1);
249
248
  };
250
- }, [e, u, V, i]), b.useEffect(() => {
249
+ }, [e, u, V, i]), F.useEffect(() => {
251
250
  u._setDisabledField({
252
251
  disabled: s,
253
252
  name: e
254
253
  });
255
- }, [s, e, u]), b.useMemo(() => ({
256
- field: M,
254
+ }, [s, e, u]), F.useMemo(() => ({
255
+ field: B,
257
256
  formState: g,
258
- fieldState: w
259
- }), [M, g, w]);
257
+ fieldState: R
258
+ }), [B, g, R]);
260
259
  }
261
- const sr = (t) => t.render(rr(t));
262
- var ar = (t, r, e, s, u) => r ? {
260
+ const ar = (t) => t.render(sr(t));
261
+ var nr = (t, r, e, s, u) => r ? {
263
262
  ...e[t],
264
263
  types: {
265
264
  ...e[t] && e[t].types ? e[t].types : {},
266
265
  [s]: u || !0
267
266
  }
268
- } : {}, z = (t) => Array.isArray(t) ? t : [t], ft = () => {
267
+ } : {}, z = (t) => Array.isArray(t) ? t : [t], yt = () => {
269
268
  let t = [];
270
269
  return {
271
270
  get observers() {
@@ -285,75 +284,75 @@ var ar = (t, r, e, s, u) => r ? {
285
284
  }
286
285
  };
287
286
  };
288
- function Et(t, r) {
287
+ function wt(t, r) {
289
288
  const e = {};
290
289
  for (const s in t)
291
290
  if (t.hasOwnProperty(s)) {
292
291
  const u = t[s], i = r[s];
293
- if (u && P(u) && i) {
294
- const c = Et(u, i);
295
- P(c) && (e[s] = c);
292
+ if (u && H(u) && i) {
293
+ const c = wt(u, i);
294
+ H(c) && (e[s] = c);
296
295
  } else t[s] && (e[s] = i);
297
296
  }
298
297
  return e;
299
298
  }
300
- var q = (t) => P(t) && !Object.keys(t).length, Xe = (t) => t.type === "file", re = (t) => typeof t == "function", xe = (t) => {
301
- if (!ze)
299
+ var j = (t) => H(t) && !Object.keys(t).length, Ze = (t) => t.type === "file", xe = (t) => {
300
+ if (!Ke)
302
301
  return !1;
303
302
  const r = t ? t.ownerDocument : 0;
304
303
  return t instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
305
- }, wt = (t) => t.type === "select-multiple", Ze = (t) => t.type === "radio", nr = (t) => Ze(t) || ve(t), Ue = (t) => xe(t) && t.isConnected;
306
- function ir(t, r) {
304
+ }, kt = (t) => t.type === "select-multiple", et = (t) => t.type === "radio", ir = (t) => et(t) || ve(t), Ne = (t) => xe(t) && t.isConnected;
305
+ function ur(t, r) {
307
306
  const e = r.slice(0, -1).length;
308
307
  let s = 0;
309
308
  for (; s < e; )
310
- t = O(t) ? s++ : t[r[s++]];
309
+ t = N(t) ? s++ : t[r[s++]];
311
310
  return t;
312
311
  }
313
- function ur(t) {
312
+ function or(t) {
314
313
  for (const r in t)
315
- if (t.hasOwnProperty(r) && !O(t[r]))
314
+ if (t.hasOwnProperty(r) && !N(t[r]))
316
315
  return !1;
317
316
  return !0;
318
317
  }
319
- function B(t, r) {
320
- const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ke(r), s = e.length === 1 ? t : ir(t, e), u = e.length - 1, i = e[u];
321
- return s && delete s[i], u !== 0 && (P(s) && q(s) || Array.isArray(s) && ur(s)) && B(t, e.slice(0, -1)), t;
318
+ function P(t, r) {
319
+ const e = Array.isArray(r) ? r : Ee(r) ? [r] : Ye(r), s = e.length === 1 ? t : ur(t, e), u = e.length - 1, i = e[u];
320
+ return s && delete s[i], u !== 0 && (H(s) && j(s) || Array.isArray(s) && or(s)) && P(t, e.slice(0, -1)), t;
322
321
  }
323
- var or = (t) => {
322
+ var lr = (t) => {
324
323
  for (const r in t)
325
- if (re(t[r]))
324
+ if (G(t[r]))
326
325
  return !0;
327
326
  return !1;
328
327
  };
329
- function kt(t) {
330
- return Array.isArray(t) || P(t) && !or(t);
328
+ function Ct(t) {
329
+ return Array.isArray(t) || H(t) && !lr(t);
331
330
  }
332
- function je(t, r = {}) {
331
+ function Ge(t, r = {}) {
333
332
  for (const e in t) {
334
333
  const s = t[e];
335
- kt(s) ? (r[e] = Array.isArray(s) ? [] : {}, je(s, r[e])) : O(s) || (r[e] = !0);
334
+ Ct(s) ? (r[e] = Array.isArray(s) ? [] : {}, Ge(s, r[e])) : N(s) || (r[e] = !0);
336
335
  }
337
336
  return r;
338
337
  }
339
- function fe(t, r, e) {
340
- e || (e = je(r));
338
+ function ce(t, r, e) {
339
+ e || (e = Ge(r));
341
340
  for (const s in t) {
342
341
  const u = t[s];
343
- if (kt(u))
344
- O(r) || qe(e[s]) ? e[s] = je(u, Array.isArray(u) ? [] : {}) : fe(u, G(r) ? {} : r[s], e[s]);
342
+ if (Ct(u))
343
+ N(r) || je(e[s]) ? e[s] = Ge(u, Array.isArray(u) ? [] : {}) : ce(u, Q(r) ? {} : r[s], e[s]);
345
344
  else {
346
345
  const i = r[s];
347
- e[s] = !te(u, i);
346
+ e[s] = !ae(u, i);
348
347
  }
349
348
  }
350
349
  return e;
351
350
  }
352
- const yt = {
351
+ const mt = {
353
352
  value: !1,
354
353
  isValid: !1
355
- }, mt = { value: !0, isValid: !0 };
356
- var Ct = (t) => {
354
+ }, _t = { value: !0, isValid: !0 };
355
+ var Dt = (t) => {
357
356
  if (Array.isArray(t)) {
358
357
  if (t.length > 1) {
359
358
  const r = t.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
@@ -361,28 +360,28 @@ var Ct = (t) => {
361
360
  }
362
361
  return t[0].checked && !t[0].disabled ? (
363
362
  // @ts-expect-error expected to work in the browser
364
- t[0].attributes && !O(t[0].attributes.value) ? O(t[0].value) || t[0].value === "" ? mt : { value: t[0].value, isValid: !0 } : mt
365
- ) : yt;
363
+ t[0].attributes && !N(t[0].attributes.value) ? N(t[0].value) || t[0].value === "" ? _t : { value: t[0].value, isValid: !0 } : _t
364
+ ) : mt;
366
365
  }
367
- return yt;
368
- }, Dt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => O(t) ? t : r ? t === "" ? NaN : t && +t : e && Y(t) ? new Date(t) : s ? s(t) : t;
369
- const _t = {
366
+ return mt;
367
+ }, Tt = (t, { valueAsNumber: r, valueAsDate: e, setValueAs: s }) => N(t) ? t : r ? t === "" ? NaN : t && +t : e && X(t) ? new Date(t) : s ? s(t) : t;
368
+ const gt = {
370
369
  isValid: !1,
371
370
  value: null
372
371
  };
373
- var Rt = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disabled ? {
372
+ var Ot = (t) => Array.isArray(t) ? t.reduce((r, e) => e && e.checked && !e.disabled ? {
374
373
  isValid: !0,
375
374
  value: e.value
376
- } : r, _t) : _t;
377
- function gt(t) {
375
+ } : r, gt) : gt;
376
+ function ht(t) {
378
377
  const r = t.ref;
379
- return Xe(r) ? r.files : Ze(r) ? Rt(t.refs).value : wt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Ct(t.refs).value : Dt(O(r.value) ? t.ref.value : r.value, t);
378
+ return Ze(r) ? r.files : et(r) ? Ot(t.refs).value : kt(r) ? [...r.selectedOptions].map(({ value: e }) => e) : ve(r) ? Dt(t.refs).value : Tt(N(r.value) ? t.ref.value : r.value, t);
380
379
  }
381
- var lr = (t, r, e, s) => {
380
+ var cr = (t, r, e, s) => {
382
381
  const u = {};
383
382
  for (const i of t) {
384
383
  const c = m(r, i);
385
- c && R(u, i, c._f);
384
+ c && O(u, i, c._f);
386
385
  }
387
386
  return {
388
387
  criteriaMode: e,
@@ -390,16 +389,16 @@ var lr = (t, r, e, s) => {
390
389
  fields: u,
391
390
  shouldUseNativeValidation: s
392
391
  };
393
- }, Se = (t) => t instanceof RegExp, ge = (t) => O(t) ? t : Se(t) ? t.source : P(t) ? Se(t.value) ? t.value.source : t.value : t, ye = (t) => ({
394
- isOnSubmit: !t || t === X.onSubmit,
395
- isOnBlur: t === X.onBlur,
396
- isOnChange: t === X.onChange,
397
- isOnAll: t === X.all,
398
- isOnTouch: t === X.onTouched
392
+ }, Se = (t) => t instanceof RegExp, he = (t) => N(t) ? t : Se(t) ? t.source : H(t) ? Se(t.value) ? t.value.source : t.value : t, de = (t) => ({
393
+ isOnSubmit: !t || t === re.onSubmit,
394
+ isOnBlur: t === re.onBlur,
395
+ isOnChange: t === re.onChange,
396
+ isOnAll: t === re.all,
397
+ isOnTouch: t === re.onTouched
399
398
  });
400
- const ht = "AsyncFunction";
401
- var cr = (t) => !!t && !!t.validate && !!(re(t.validate) && t.validate.constructor.name === ht || P(t.validate) && Object.values(t.validate).find((r) => r.constructor.name === ht)), dr = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate), Qe = (t, r, e) => !e && (r.watchAll || r.watch.has(t) || [...r.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
402
- const me = (t, r, e, s) => {
399
+ const vt = "AsyncFunction";
400
+ var dr = (t) => !!t && !!t.validate && !!(G(t.validate) && t.validate.constructor.name === vt || H(t.validate) && Object.values(t.validate).find((r) => r.constructor.name === vt)), fr = (t) => t.mount && (t.required || t.min || t.max || t.maxLength || t.minLength || t.pattern || t.validate), Qe = (t, r, e) => !e && (r.watchAll || r.watch.has(t) || [...r.watch].some((s) => t.startsWith(s) && /^\.\w+/.test(t.slice(s.length))));
401
+ const fe = (t, r, e, s) => {
403
402
  for (const u of e || Object.keys(t)) {
404
403
  const i = m(t, u);
405
404
  if (i) {
@@ -409,14 +408,14 @@ const me = (t, r, e, s) => {
409
408
  return !0;
410
409
  if (c.ref && r(c.ref, c.name) && !s)
411
410
  return !0;
412
- if (me(l, r))
411
+ if (fe(l, r))
413
412
  break;
414
- } else if (P(l) && me(l, r))
413
+ } else if (H(l) && fe(l, r))
415
414
  break;
416
415
  }
417
416
  }
418
417
  };
419
- function vt(t, r, e) {
418
+ function Vt(t, r, e) {
420
419
  const s = m(t, e);
421
420
  if (s || Ee(e))
422
421
  return {
@@ -444,120 +443,120 @@ function vt(t, r, e) {
444
443
  name: e
445
444
  };
446
445
  }
447
- var fr = (t, r, e, s) => {
446
+ var yr = (t, r, e, s) => {
448
447
  e(t);
449
448
  const { name: u, ...i } = t;
450
- return q(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || X.all));
451
- }, yr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), mr = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, _r = (t, r) => !we(m(t, r)).length && B(t, r), Tt = (t, r, e) => {
449
+ return j(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((c) => r[c] === (!s || re.all));
450
+ }, mr = (t, r, e) => !t || !r || t === r || z(t).some((s) => s && (e ? s === r : s.startsWith(r) || r.startsWith(s))), _r = (t, r, e, s, u) => u.isOnAll ? !1 : !e && u.isOnTouch ? !(r || t) : (e ? s.isOnBlur : u.isOnBlur) ? !t : (e ? s.isOnChange : u.isOnChange) ? t : !0, gr = (t, r) => !we(m(t, r)).length && P(t, r), Rt = (t, r, e) => {
452
451
  const s = z(m(t, e));
453
- return R(s, "root", r[e]), R(t, e, s), t;
452
+ return O(s, "root", r[e]), O(t, e, s), t;
454
453
  };
455
- function Vt(t, r, e = "validate") {
456
- if (Y(t) || Array.isArray(t) && t.every(Y) || K(t) && !t)
454
+ function Ft(t, r, e = "validate") {
455
+ if (X(t) || Array.isArray(t) && t.every(X) || J(t) && !t)
457
456
  return {
458
457
  type: e,
459
- message: Y(t) ? t : "",
458
+ message: X(t) ? t : "",
460
459
  ref: r
461
460
  };
462
461
  }
463
- var de = (t) => P(t) && !Se(t) ? t : {
462
+ var le = (t) => H(t) && !Se(t) ? t : {
464
463
  value: t,
465
464
  message: ""
466
- }, Ge = async (t, r, e, s, u, i) => {
467
- const { ref: c, refs: l, required: V, maxLength: v, minLength: x, min: g, max: F, pattern: $, validate: L, name: w, valueAsNumber: N, mount: H } = t._f, S = m(e, w);
468
- if (!H || r.has(w))
465
+ }, ze = async (t, r, e, s, u, i) => {
466
+ const { ref: c, refs: l, required: V, maxLength: h, minLength: k, min: g, max: S, pattern: p, validate: I, name: R, valueAsNumber: T, mount: U } = t._f, x = m(e, R);
467
+ if (!U || r.has(R))
469
468
  return {};
470
- const M = l ? l[0] : c, f = (k) => {
471
- u && M.reportValidity && (M.setCustomValidity(K(k) ? "" : k || ""), M.reportValidity());
472
- }, d = {}, p = Ze(c), E = ve(c), Z = p || E, W = (N || Xe(c)) && O(c.value) && O(S) || xe(c) && c.value === "" || S === "" || Array.isArray(S) && !S.length, oe = ar.bind(null, w, s, d), se = (k, D, I, j = ne.maxLength, Q = ne.minLength) => {
473
- const ae = k ? D : I;
474
- d[w] = {
475
- type: k ? j : Q,
476
- message: ae,
469
+ const B = l ? l[0] : c, f = (E) => {
470
+ u && B.reportValidity && (B.setCustomValidity(J(E) ? "" : E || ""), B.reportValidity());
471
+ }, d = {}, A = et(c), w = ve(c), W = A || w, K = (T || Ze(c)) && N(c.value) && N(x) || xe(c) && c.value === "" || x === "" || Array.isArray(x) && !x.length, Z = nr.bind(null, R, s, d), Fe = (E, C, $, q = ne.maxLength, se = ne.minLength) => {
472
+ const Y = E ? C : $;
473
+ d[R] = {
474
+ type: E ? q : se,
475
+ message: Y,
477
476
  ref: c,
478
- ...oe(k ? j : Q, ae)
477
+ ...Z(E ? q : se, Y)
479
478
  };
480
479
  };
481
- if (i ? !Array.isArray(S) || !S.length : V && (!Z && (W || G(S)) || K(S) && !S || E && !Ct(l).isValid || p && !Rt(l).isValid)) {
482
- const { value: k, message: D } = Y(V) ? { value: !!V, message: V } : de(V);
483
- if (k && (d[w] = {
480
+ if (i ? !Array.isArray(x) || !x.length : V && (!W && (K || Q(x)) || J(x) && !x || w && !Dt(l).isValid || A && !Ot(l).isValid)) {
481
+ const { value: E, message: C } = X(V) ? { value: !!V, message: V } : le(V);
482
+ if (E && (d[R] = {
484
483
  type: ne.required,
485
- message: D,
486
- ref: M,
487
- ...oe(ne.required, D)
484
+ message: C,
485
+ ref: B,
486
+ ...Z(ne.required, C)
488
487
  }, !s))
489
- return f(D), d;
488
+ return f(C), d;
490
489
  }
491
- if (!W && (!G(g) || !G(F))) {
492
- let k, D;
493
- const I = de(F), j = de(g);
494
- if (!G(S) && !isNaN(S)) {
495
- const Q = c.valueAsNumber || S && +S;
496
- G(I.value) || (k = Q > I.value), G(j.value) || (D = Q < j.value);
490
+ if (!K && (!Q(g) || !Q(S))) {
491
+ let E, C;
492
+ const $ = le(S), q = le(g);
493
+ if (!Q(x) && !isNaN(x)) {
494
+ const se = c.valueAsNumber || x && +x;
495
+ Q($.value) || (E = se > $.value), Q(q.value) || (C = se < q.value);
497
496
  } else {
498
- const Q = c.valueAsDate || new Date(S), ae = (Fe) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + Fe), _e = c.type == "time", ce = c.type == "week";
499
- Y(I.value) && S && (k = _e ? ae(S) > ae(I.value) : ce ? S > I.value : Q > new Date(I.value)), Y(j.value) && S && (D = _e ? ae(S) < ae(j.value) : ce ? S < j.value : Q < new Date(j.value));
497
+ const se = c.valueAsDate || new Date(x), Y = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), me = c.type == "time", _e = c.type == "week";
498
+ X($.value) && x && (E = me ? Y(x) > Y($.value) : _e ? x > $.value : se > new Date($.value)), X(q.value) && x && (C = me ? Y(x) < Y(q.value) : _e ? x < q.value : se < new Date(q.value));
500
499
  }
501
- if ((k || D) && (se(!!k, I.message, j.message, ne.max, ne.min), !s))
502
- return f(d[w].message), d;
500
+ if ((E || C) && (Fe(!!E, $.message, q.message, ne.max, ne.min), !s))
501
+ return f(d[R].message), d;
503
502
  }
504
- if ((v || x) && !W && (Y(S) || i && Array.isArray(S))) {
505
- const k = de(v), D = de(x), I = !G(k.value) && S.length > +k.value, j = !G(D.value) && S.length < +D.value;
506
- if ((I || j) && (se(I, k.message, D.message), !s))
507
- return f(d[w].message), d;
503
+ if ((h || k) && !K && (X(x) || i && Array.isArray(x))) {
504
+ const E = le(h), C = le(k), $ = !Q(E.value) && x.length > +E.value, q = !Q(C.value) && x.length < +C.value;
505
+ if (($ || q) && (Fe($, E.message, C.message), !s))
506
+ return f(d[R].message), d;
508
507
  }
509
- if ($ && !W && Y(S)) {
510
- const { value: k, message: D } = de($);
511
- if (Se(k) && !S.match(k) && (d[w] = {
508
+ if (p && !K && X(x)) {
509
+ const { value: E, message: C } = le(p);
510
+ if (Se(E) && !x.match(E) && (d[R] = {
512
511
  type: ne.pattern,
513
- message: D,
512
+ message: C,
514
513
  ref: c,
515
- ...oe(ne.pattern, D)
514
+ ...Z(ne.pattern, C)
516
515
  }, !s))
517
- return f(D), d;
516
+ return f(C), d;
518
517
  }
519
- if (L) {
520
- if (re(L)) {
521
- const k = await L(S, e), D = Vt(k, M);
522
- if (D && (d[w] = {
523
- ...D,
524
- ...oe(ne.validate, D.message)
518
+ if (I) {
519
+ if (G(I)) {
520
+ const E = await I(x, e), C = Ft(E, B);
521
+ if (C && (d[R] = {
522
+ ...C,
523
+ ...Z(ne.validate, C.message)
525
524
  }, !s))
526
- return f(D.message), d;
527
- } else if (P(L)) {
528
- let k = {};
529
- for (const D in L) {
530
- if (!q(k) && !s)
525
+ return f(C.message), d;
526
+ } else if (H(I)) {
527
+ let E = {};
528
+ for (const C in I) {
529
+ if (!j(E) && !s)
531
530
  break;
532
- const I = Vt(await L[D](S, e), M, D);
533
- I && (k = {
534
- ...I,
535
- ...oe(D, I.message)
536
- }, f(I.message), s && (d[w] = k));
531
+ const $ = Ft(await I[C](x, e), B, C);
532
+ $ && (E = {
533
+ ...$,
534
+ ...Z(C, $.message)
535
+ }, f($.message), s && (d[R] = E));
537
536
  }
538
- if (!q(k) && (d[w] = {
539
- ref: M,
540
- ...k
537
+ if (!j(E) && (d[R] = {
538
+ ref: B,
539
+ ...E
541
540
  }, !s))
542
541
  return d;
543
542
  }
544
543
  }
545
544
  return f(!0), d;
546
545
  };
547
- const gr = {
548
- mode: X.onSubmit,
549
- reValidateMode: X.onChange,
546
+ const hr = {
547
+ mode: re.onSubmit,
548
+ reValidateMode: re.onChange,
550
549
  shouldFocusError: !0
551
550
  };
552
- function hr(t = {}) {
551
+ function vr(t = {}) {
553
552
  let r = {
554
- ...gr,
553
+ ...hr,
555
554
  ...t
556
555
  }, e = {
557
556
  submitCount: 0,
558
557
  isDirty: !1,
559
558
  isReady: !1,
560
- isLoading: re(r.defaultValues),
559
+ isLoading: G(r.defaultValues),
561
560
  isValidating: !1,
562
561
  isSubmitted: !1,
563
562
  isSubmitting: !1,
@@ -568,18 +567,19 @@ function hr(t = {}) {
568
567
  validatingFields: {},
569
568
  errors: r.errors || {},
570
569
  disabled: r.disabled || !1
571
- }, s = {}, u = P(r.defaultValues) || P(r.values) ? U(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : U(u), c = {
570
+ }, s = {}, u = H(r.defaultValues) || H(r.values) ? M(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : M(u), c = {
572
571
  action: !1,
573
572
  mount: !1,
574
- watch: !1
573
+ watch: !1,
574
+ keepIsValid: !1
575
575
  }, l = {
576
576
  mount: /* @__PURE__ */ new Set(),
577
577
  disabled: /* @__PURE__ */ new Set(),
578
578
  unMount: /* @__PURE__ */ new Set(),
579
579
  array: /* @__PURE__ */ new Set(),
580
580
  watch: /* @__PURE__ */ new Set()
581
- }, V, v = 0;
582
- const x = {
581
+ }, V, h = 0;
582
+ const k = {
583
583
  isDirty: !1,
584
584
  dirtyFields: !1,
585
585
  validatingFields: !1,
@@ -587,277 +587,278 @@ function hr(t = {}) {
587
587
  isValidating: !1,
588
588
  isValid: !1,
589
589
  errors: !1
590
+ }, g = {
591
+ ...k
590
592
  };
591
- let g = {
592
- ...x
593
+ let S = {
594
+ ...g
593
595
  };
594
- const F = {
595
- array: ft(),
596
- state: ft()
597
- }, $ = r.criteriaMode === X.all, L = (a) => (n) => {
598
- clearTimeout(v), v = setTimeout(a, n);
599
- }, w = async (a) => {
600
- if (!r.disabled && (x.isValid || g.isValid || a)) {
601
- const n = r.resolver ? q((await E()).errors) : await W(s, !0);
602
- n !== e.isValid && F.state.next({
596
+ const p = {
597
+ array: yt(),
598
+ state: yt()
599
+ }, I = r.criteriaMode === re.all, R = (a) => (n) => {
600
+ clearTimeout(h), h = setTimeout(a, n);
601
+ }, T = async (a) => {
602
+ if (!c.keepIsValid && !r.disabled && (g.isValid || S.isValid || a)) {
603
+ let n;
604
+ r.resolver ? (n = j((await W()).errors), U()) : n = await Z(s, !0), n !== e.isValid && p.state.next({
603
605
  isValid: n
604
606
  });
605
607
  }
606
- }, N = (a, n) => {
607
- !r.disabled && (x.isValidating || x.validatingFields || g.isValidating || g.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
608
- o && (n ? R(e.validatingFields, o, n) : B(e.validatingFields, o));
609
- }), F.state.next({
608
+ }, U = (a, n) => {
609
+ !r.disabled && (g.isValidating || g.validatingFields || S.isValidating || S.validatingFields) && ((a || Array.from(l.mount)).forEach((o) => {
610
+ o && (n ? O(e.validatingFields, o, n) : P(e.validatingFields, o));
611
+ }), p.state.next({
610
612
  validatingFields: e.validatingFields,
611
- isValidating: !q(e.validatingFields)
613
+ isValidating: !j(e.validatingFields)
612
614
  }));
613
- }, H = (a, n = [], o, h, _ = !0, y = !0) => {
614
- if (h && o && !r.disabled) {
615
+ }, x = (a, n = [], o, v, _ = !0, y = !0) => {
616
+ if (v && o && !r.disabled) {
615
617
  if (c.action = !0, y && Array.isArray(m(s, a))) {
616
- const A = o(m(s, a), h.argA, h.argB);
617
- _ && R(s, a, A);
618
+ const b = o(m(s, a), v.argA, v.argB);
619
+ _ && O(s, a, b);
618
620
  }
619
621
  if (y && Array.isArray(m(e.errors, a))) {
620
- const A = o(m(e.errors, a), h.argA, h.argB);
621
- _ && R(e.errors, a, A), _r(e.errors, a);
622
+ const b = o(m(e.errors, a), v.argA, v.argB);
623
+ _ && O(e.errors, a, b), gr(e.errors, a);
622
624
  }
623
- if ((x.touchedFields || g.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
624
- const A = o(m(e.touchedFields, a), h.argA, h.argB);
625
- _ && R(e.touchedFields, a, A);
625
+ if ((g.touchedFields || S.touchedFields) && y && Array.isArray(m(e.touchedFields, a))) {
626
+ const b = o(m(e.touchedFields, a), v.argA, v.argB);
627
+ _ && O(e.touchedFields, a, b);
626
628
  }
627
- (x.dirtyFields || g.dirtyFields) && (e.dirtyFields = fe(u, i)), F.state.next({
629
+ (g.dirtyFields || S.dirtyFields) && (e.dirtyFields = ce(u, i)), p.state.next({
628
630
  name: a,
629
- isDirty: se(a, n),
631
+ isDirty: E(a, n),
630
632
  dirtyFields: e.dirtyFields,
631
633
  errors: e.errors,
632
634
  isValid: e.isValid
633
635
  });
634
636
  } else
635
- R(i, a, n);
636
- }, S = (a, n) => {
637
- R(e.errors, a, n), F.state.next({
637
+ O(i, a, n);
638
+ }, B = (a, n) => {
639
+ O(e.errors, a, n), p.state.next({
638
640
  errors: e.errors
639
641
  });
640
- }, M = (a) => {
641
- e.errors = a, F.state.next({
642
+ }, f = (a) => {
643
+ e.errors = a, p.state.next({
642
644
  errors: e.errors,
643
645
  isValid: !1
644
646
  });
645
- }, f = (a, n, o, h) => {
647
+ }, d = (a, n, o, v) => {
646
648
  const _ = m(s, a);
647
649
  if (_) {
648
- const y = m(i, a, O(o) ? m(u, a) : o);
649
- O(y) || h && h.defaultChecked || n ? R(i, a, n ? y : gt(_._f)) : I(a, y), c.mount && !c.action && w();
650
+ const y = m(i, a, N(o) ? m(u, a) : o);
651
+ N(y) || v && v.defaultChecked || n ? O(i, a, n ? y : ht(_._f)) : q(a, y), c.mount && !c.action && T();
650
652
  }
651
- }, d = (a, n, o, h, _) => {
652
- let y = !1, A = !1;
653
- const C = {
653
+ }, A = (a, n, o, v, _) => {
654
+ let y = !1, b = !1;
655
+ const D = {
654
656
  name: a
655
657
  };
656
658
  if (!r.disabled) {
657
- if (!o || h) {
658
- (x.isDirty || g.isDirty) && (A = e.isDirty, e.isDirty = C.isDirty = se(), y = A !== C.isDirty);
659
- const T = te(m(u, a), n);
660
- A = !!m(e.dirtyFields, a), T ? B(e.dirtyFields, a) : R(e.dirtyFields, a, !0), C.dirtyFields = e.dirtyFields, y = y || (x.dirtyFields || g.dirtyFields) && A !== !T;
659
+ if (!o || v) {
660
+ (g.isDirty || S.isDirty) && (b = e.isDirty, e.isDirty = D.isDirty = E(), y = b !== D.isDirty);
661
+ const L = ae(m(u, a), n);
662
+ b = !!m(e.dirtyFields, a), L ? P(e.dirtyFields, a) : O(e.dirtyFields, a, !0), D.dirtyFields = e.dirtyFields, y = y || (g.dirtyFields || S.dirtyFields) && b !== !L;
661
663
  }
662
664
  if (o) {
663
- const T = m(e.touchedFields, a);
664
- T || (R(e.touchedFields, a, o), C.touchedFields = e.touchedFields, y = y || (x.touchedFields || g.touchedFields) && T !== o);
665
+ const L = m(e.touchedFields, a);
666
+ L || (O(e.touchedFields, a, o), D.touchedFields = e.touchedFields, y = y || (g.touchedFields || S.touchedFields) && L !== o);
665
667
  }
666
- y && _ && F.state.next(C);
668
+ y && _ && p.state.next(D);
667
669
  }
668
- return y ? C : {};
669
- }, p = (a, n, o, h) => {
670
- const _ = m(e.errors, a), y = (x.isValid || g.isValid) && K(n) && e.isValid !== n;
671
- if (r.delayError && o ? (V = L(() => S(a, o)), V(r.delayError)) : (clearTimeout(v), V = null, o ? R(e.errors, a, o) : B(e.errors, a)), (o ? !te(_, o) : _) || !q(h) || y) {
672
- const A = {
673
- ...h,
674
- ...y && K(n) ? { isValid: n } : {},
670
+ return y ? D : {};
671
+ }, w = (a, n, o, v) => {
672
+ const _ = m(e.errors, a), y = (g.isValid || S.isValid) && J(n) && e.isValid !== n;
673
+ if (r.delayError && o ? (V = R(() => B(a, o)), V(r.delayError)) : (clearTimeout(h), V = null, o ? O(e.errors, a, o) : P(e.errors, a)), (o ? !ae(_, o) : _) || !j(v) || y) {
674
+ const b = {
675
+ ...v,
676
+ ...y && J(n) ? { isValid: n } : {},
675
677
  errors: e.errors,
676
678
  name: a
677
679
  };
678
680
  e = {
679
681
  ...e,
680
- ...A
681
- }, F.state.next(A);
682
+ ...b
683
+ }, p.state.next(b);
682
684
  }
683
- }, E = async (a) => {
684
- N(a, !0);
685
- const n = await r.resolver(i, r.context, lr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation));
686
- return N(a), n;
687
- }, Z = async (a) => {
688
- const { errors: n } = await E(a);
689
- if (a)
685
+ }, W = async (a) => (U(a, !0), await r.resolver(i, r.context, cr(a || l.mount, s, r.criteriaMode, r.shouldUseNativeValidation))), K = async (a) => {
686
+ const { errors: n } = await W(a);
687
+ if (U(a), a)
690
688
  for (const o of a) {
691
- const h = m(n, o);
692
- h ? R(e.errors, o, h) : B(e.errors, o);
689
+ const v = m(n, o);
690
+ v ? O(e.errors, o, v) : P(e.errors, o);
693
691
  }
694
692
  else
695
693
  e.errors = n;
696
694
  return n;
697
- }, W = async (a, n, o = {
695
+ }, Z = async (a, n, o = {
698
696
  valid: !0
699
697
  }) => {
700
- for (const h in a) {
701
- const _ = a[h];
698
+ for (const v in a) {
699
+ const _ = a[v];
702
700
  if (_) {
703
- const { _f: y, ...A } = _;
701
+ const { _f: y, ...b } = _;
704
702
  if (y) {
705
- const C = l.array.has(y.name), T = _._f && cr(_._f);
706
- T && x.validatingFields && N([y.name], !0);
707
- const J = await Ge(_, l.disabled, i, $, r.shouldUseNativeValidation && !n, C);
708
- if (T && x.validatingFields && N([y.name]), J[y.name] && (o.valid = !1, n))
703
+ const D = l.array.has(y.name), L = _._f && dr(_._f);
704
+ L && g.validatingFields && U([y.name], !0);
705
+ const ee = await ze(_, l.disabled, i, I, r.shouldUseNativeValidation && !n, D);
706
+ if (L && g.validatingFields && U([y.name]), ee[y.name] && (o.valid = !1, n))
709
707
  break;
710
- !n && (m(J, y.name) ? C ? Tt(e.errors, J, y.name) : R(e.errors, y.name, J[y.name]) : B(e.errors, y.name));
708
+ !n && (m(ee, y.name) ? D ? Rt(e.errors, ee, y.name) : O(e.errors, y.name, ee[y.name]) : P(e.errors, y.name));
711
709
  }
712
- !q(A) && await W(A, n, o);
710
+ !j(b) && await Z(b, n, o);
713
711
  }
714
712
  }
715
713
  return o.valid;
716
- }, oe = () => {
714
+ }, Fe = () => {
717
715
  for (const a of l.unMount) {
718
716
  const n = m(s, a);
719
- n && (n._f.refs ? n._f.refs.every((o) => !Ue(o)) : !Ue(n._f.ref)) && Ce(a);
717
+ n && (n._f.refs ? n._f.refs.every((o) => !Ne(o)) : !Ne(n._f.ref)) && Ce(a);
720
718
  }
721
719
  l.unMount = /* @__PURE__ */ new Set();
722
- }, se = (a, n) => !r.disabled && (a && n && R(i, a, n), !te(Fe(), u)), k = (a, n, o) => He(a, l, {
723
- ...c.mount ? i : O(n) ? u : Y(a) ? { [a]: n } : n
724
- }, o, n), D = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), I = (a, n, o = {}) => {
725
- const h = m(s, a);
720
+ }, E = (a, n) => !r.disabled && (a && n && O(i, a, n), !ae(rt(), u)), C = (a, n, o) => qe(a, l, {
721
+ ...c.mount ? i : N(n) ? u : X(a) ? { [a]: n } : n
722
+ }, o, n), $ = (a) => we(m(c.mount ? i : u, a, r.shouldUnregister ? m(u, a, []) : [])), q = (a, n, o = {}) => {
723
+ const v = m(s, a);
726
724
  let _ = n;
727
- if (h) {
728
- const y = h._f;
729
- y && (!y.disabled && R(i, a, Dt(n, y)), _ = xe(y.ref) && G(n) ? "" : n, wt(y.ref) ? [...y.ref.options].forEach((A) => A.selected = _.includes(A.value)) : y.refs ? ve(y.ref) ? y.refs.forEach((A) => {
730
- (!A.defaultChecked || !A.disabled) && (Array.isArray(_) ? A.checked = !!_.find((C) => C === A.value) : A.checked = _ === A.value || !!_);
731
- }) : y.refs.forEach((A) => A.checked = A.value === _) : Xe(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || F.state.next({
725
+ if (v) {
726
+ const y = v._f;
727
+ y && (!y.disabled && O(i, a, Tt(n, y)), _ = xe(y.ref) && Q(n) ? "" : n, kt(y.ref) ? [...y.ref.options].forEach((b) => b.selected = _.includes(b.value)) : y.refs ? ve(y.ref) ? y.refs.forEach((b) => {
728
+ (!b.defaultChecked || !b.disabled) && (Array.isArray(_) ? b.checked = !!_.find((D) => D === b.value) : b.checked = _ === b.value || !!_);
729
+ }) : y.refs.forEach((b) => b.checked = b.value === _) : Ze(y.ref) ? y.ref.value = "" : (y.ref.value = _, y.ref.type || p.state.next({
732
730
  name: a,
733
- values: U(i)
731
+ values: M(i)
734
732
  })));
735
733
  }
736
- (o.shouldDirty || o.shouldTouch) && d(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ce(a);
737
- }, j = (a, n, o) => {
738
- for (const h in n) {
739
- if (!n.hasOwnProperty(h))
734
+ (o.shouldDirty || o.shouldTouch) && A(a, _, o.shouldTouch, o.shouldDirty, !0), o.shouldValidate && ge(a);
735
+ }, se = (a, n, o) => {
736
+ for (const v in n) {
737
+ if (!n.hasOwnProperty(v))
740
738
  return;
741
- const _ = n[h], y = a + "." + h, A = m(s, y);
742
- (l.array.has(a) || P(_) || A && !A._f) && !le(_) ? j(y, _, o) : I(y, _, o);
739
+ const _ = n[v], y = a + "." + v, b = m(s, y);
740
+ (l.array.has(a) || H(_) || b && !b._f) && !oe(_) ? se(y, _, o) : q(y, _, o);
743
741
  }
744
- }, Q = (a, n, o = {}) => {
745
- const h = m(s, a), _ = l.array.has(a), y = U(n);
746
- R(i, a, y), _ ? (F.array.next({
742
+ }, Y = (a, n, o = {}) => {
743
+ const v = m(s, a), _ = l.array.has(a), y = M(n);
744
+ O(i, a, y), _ ? (p.array.next({
747
745
  name: a,
748
- values: U(i)
749
- }), (x.isDirty || x.dirtyFields || g.isDirty || g.dirtyFields) && o.shouldDirty && F.state.next({
746
+ values: M(i)
747
+ }), (g.isDirty || g.dirtyFields || S.isDirty || S.dirtyFields) && o.shouldDirty && p.state.next({
750
748
  name: a,
751
- dirtyFields: fe(u, i),
752
- isDirty: se(a, y)
753
- })) : h && !h._f && !G(y) ? j(a, y, o) : I(a, y, o), Qe(a, l) && F.state.next({ ...e, name: a }), F.state.next({
749
+ dirtyFields: ce(u, i),
750
+ isDirty: E(a, y)
751
+ })) : v && !v._f && !Q(y) ? se(a, y, o) : q(a, y, o), Qe(a, l) && p.state.next({ ...e, name: a }), p.state.next({
754
752
  name: c.mount ? a : void 0,
755
- values: U(i)
753
+ values: M(i)
756
754
  });
757
- }, ae = async (a) => {
755
+ }, me = async (a) => {
758
756
  c.mount = !0;
759
757
  const n = a.target;
760
- let o = n.name, h = !0;
761
- const _ = m(s, o), y = (T) => {
762
- h = Number.isNaN(T) || le(T) && isNaN(T.getTime()) || te(T, m(i, o, T));
763
- }, A = ye(r.mode), C = ye(r.reValidateMode);
758
+ let o = n.name, v = !0;
759
+ const _ = m(s, o), y = (L) => {
760
+ v = Number.isNaN(L) || oe(L) && isNaN(L.getTime()) || ae(L, m(i, o, L));
761
+ }, b = de(r.mode), D = de(r.reValidateMode);
764
762
  if (_) {
765
- let T, J;
766
- const be = n.type ? gt(_._f) : pt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, Ht = !dr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || mr(ie, m(e.touchedFields, o), e.isSubmitted, C, A), Te = Qe(o, l, ie);
767
- R(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
768
- const Oe = d(o, be, ie), qt = !q(Oe) || Te;
769
- if (!ie && F.state.next({
763
+ let L, ee;
764
+ const be = n.type ? ht(_._f) : xt(a), ie = a.type === pe.BLUR || a.type === pe.FOCUS_OUT, qt = !fr(_._f) && !r.resolver && !m(e.errors, o) && !_._f.deps || _r(ie, m(e.touchedFields, o), e.isSubmitted, D, b), Oe = Qe(o, l, ie);
765
+ O(i, o, be), ie ? (!n || !n.readOnly) && (_._f.onBlur && _._f.onBlur(a), V && V(0)) : _._f.onChange && _._f.onChange(a);
766
+ const Re = A(o, be, ie), jt = !j(Re) || Oe;
767
+ if (!ie && p.state.next({
770
768
  name: o,
771
769
  type: a.type,
772
- values: U(i)
773
- }), Ht)
774
- return (x.isValid || g.isValid) && (r.mode === "onBlur" ? ie && w() : ie || w()), qt && F.state.next({ name: o, ...Te ? {} : Oe });
775
- if (!ie && Te && F.state.next({ ...e }), r.resolver) {
776
- const { errors: lt } = await E([o]);
777
- if (y(be), h) {
778
- const jt = vt(e.errors, s, o), ct = vt(lt, s, jt.name || o);
779
- T = ct.error, o = ct.name, J = q(lt);
770
+ values: M(i)
771
+ }), qt)
772
+ return (g.isValid || S.isValid) && (r.mode === "onBlur" ? ie && T() : ie || T()), jt && p.state.next({ name: o, ...Oe ? {} : Re });
773
+ if (!ie && Oe && p.state.next({ ...e }), r.resolver) {
774
+ const { errors: dt } = await W([o]);
775
+ if (U([o]), y(be), v) {
776
+ const Gt = Vt(e.errors, s, o), ft = Vt(dt, s, Gt.name || o);
777
+ L = ft.error, o = ft.name, ee = j(dt);
780
778
  }
781
779
  } else
782
- N([o], !0), T = (await Ge(_, l.disabled, i, $, r.shouldUseNativeValidation))[o], N([o]), y(be), h && (T ? J = !1 : (x.isValid || g.isValid) && (J = await W(s, !0)));
783
- h && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ce(_._f.deps), p(o, J, T, Oe));
780
+ U([o], !0), L = (await ze(_, l.disabled, i, I, r.shouldUseNativeValidation))[o], U([o]), y(be), v && (L ? ee = !1 : (g.isValid || S.isValid) && (ee = await Z(s, !0)));
781
+ v && (_._f.deps && (!Array.isArray(_._f.deps) || _._f.deps.length > 0) && ge(_._f.deps), w(o, ee, L, Re));
784
782
  }
785
783
  }, _e = (a, n) => {
786
784
  if (m(e.errors, n) && a.focus)
787
785
  return a.focus(), 1;
788
- }, ce = async (a, n = {}) => {
789
- let o, h;
786
+ }, ge = async (a, n = {}) => {
787
+ let o, v;
790
788
  const _ = z(a);
791
789
  if (r.resolver) {
792
- const y = await Z(O(a) ? a : _);
793
- o = q(y), h = a ? !_.some((A) => m(y, A)) : o;
794
- } else a ? (h = (await Promise.all(_.map(async (y) => {
795
- const A = m(s, y);
796
- return await W(A && A._f ? { [y]: A } : A);
797
- }))).every(Boolean), !(!h && !e.isValid) && w()) : h = o = await W(s);
798
- return F.state.next({
799
- ...!Y(a) || (x.isValid || g.isValid) && o !== e.isValid ? {} : { name: a },
790
+ const y = await K(N(a) ? a : _);
791
+ o = j(y), v = a ? !_.some((b) => m(y, b)) : o;
792
+ } else a ? (v = (await Promise.all(_.map(async (y) => {
793
+ const b = m(s, y);
794
+ return await Z(b && b._f ? { [y]: b } : b);
795
+ }))).every(Boolean), !(!v && !e.isValid) && T()) : v = o = await Z(s);
796
+ return p.state.next({
797
+ ...!X(a) || (g.isValid || S.isValid) && o !== e.isValid ? {} : { name: a },
800
798
  ...r.resolver || !a ? { isValid: o } : {},
801
799
  errors: e.errors
802
- }), n.shouldFocus && !h && me(s, _e, a ? _ : l.mount), h;
803
- }, Fe = (a, n) => {
800
+ }), n.shouldFocus && !v && fe(s, _e, a ? _ : l.mount), v;
801
+ }, rt = (a, n) => {
804
802
  let o = {
805
803
  ...c.mount ? i : u
806
804
  };
807
- return n && (o = Et(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), O(a) ? o : Y(a) ? m(o, a) : a.map((h) => m(o, h));
808
- }, tt = (a, n) => ({
805
+ return n && (o = wt(n.dirtyFields ? e.dirtyFields : e.touchedFields, o)), N(a) ? o : X(a) ? m(o, a) : a.map((v) => m(o, v));
806
+ }, st = (a, n) => ({
809
807
  invalid: !!m((n || e).errors, a),
810
808
  isDirty: !!m((n || e).dirtyFields, a),
811
809
  error: m((n || e).errors, a),
812
810
  isValidating: !!m(e.validatingFields, a),
813
811
  isTouched: !!m((n || e).touchedFields, a)
814
- }), Lt = (a) => {
815
- a && z(a).forEach((n) => B(e.errors, n)), F.state.next({
812
+ }), Mt = (a) => {
813
+ a && z(a).forEach((n) => P(e.errors, n)), p.state.next({
816
814
  errors: a ? e.errors : {}
817
815
  });
818
- }, rt = (a, n, o) => {
819
- const h = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: A, type: C, ...T } = _;
820
- R(e.errors, a, {
821
- ...T,
816
+ }, at = (a, n, o) => {
817
+ const v = (m(s, a, { _f: {} })._f || {}).ref, _ = m(e.errors, a) || {}, { ref: y, message: b, type: D, ...L } = _;
818
+ O(e.errors, a, {
819
+ ...L,
822
820
  ...n,
823
- ref: h
824
- }), F.state.next({
821
+ ref: v
822
+ }), p.state.next({
825
823
  name: a,
826
824
  errors: e.errors,
827
825
  isValid: !1
828
- }), o && o.shouldFocus && h && h.focus && h.focus();
829
- }, Mt = (a, n) => re(a) ? F.state.subscribe({
830
- next: (o) => "values" in o && a(k(void 0, n), o)
831
- }) : k(a, n, !0), st = (a) => F.state.subscribe({
826
+ }), o && o.shouldFocus && v && v.focus && v.focus();
827
+ }, It = (a, n) => G(a) ? p.state.subscribe({
828
+ next: (o) => "values" in o && a(C(void 0, n), o)
829
+ }) : C(a, n, !0), nt = (a) => p.state.subscribe({
832
830
  next: (n) => {
833
- yr(a.name, n.name, a.exact) && fr(n, a.formState || x, $t, a.reRenderRoot) && a.callback({
831
+ mr(a.name, n.name, a.exact) && yr(n, a.formState || g, $t, a.reRenderRoot) && a.callback({
834
832
  values: { ...i },
835
833
  ...e,
836
834
  ...n,
837
835
  defaultValues: u
838
836
  });
839
837
  }
840
- }).unsubscribe, It = (a) => (c.mount = !0, g = {
841
- ...g,
838
+ }).unsubscribe, Bt = (a) => (c.mount = !0, S = {
839
+ ...S,
842
840
  ...a.formState
843
- }, st({
841
+ }, nt({
844
842
  ...a,
845
- formState: g
843
+ formState: {
844
+ ...k,
845
+ ...a.formState
846
+ }
846
847
  })), Ce = (a, n = {}) => {
847
848
  for (const o of a ? z(a) : l.mount)
848
- l.mount.delete(o), l.array.delete(o), n.keepValue || (B(s, o), B(i, o)), !n.keepError && B(e.errors, o), !n.keepDirty && B(e.dirtyFields, o), !n.keepTouched && B(e.touchedFields, o), !n.keepIsValidating && B(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && B(u, o);
849
- F.state.next({
850
- values: U(i)
851
- }), F.state.next({
849
+ l.mount.delete(o), l.array.delete(o), n.keepValue || (P(s, o), P(i, o)), !n.keepError && P(e.errors, o), !n.keepDirty && P(e.dirtyFields, o), !n.keepTouched && P(e.touchedFields, o), !n.keepIsValidating && P(e.validatingFields, o), !r.shouldUnregister && !n.keepDefaultValue && P(u, o);
850
+ p.state.next({
851
+ values: M(i)
852
+ }), p.state.next({
852
853
  ...e,
853
- ...n.keepDirty ? { isDirty: se() } : {}
854
- }), !n.keepIsValid && w();
855
- }, at = ({ disabled: a, name: n }) => {
856
- (K(a) && c.mount || a || l.disabled.has(n)) && (a ? l.disabled.add(n) : l.disabled.delete(n));
854
+ ...n.keepDirty ? { isDirty: E() } : {}
855
+ }), !n.keepIsValid && T();
856
+ }, it = ({ disabled: a, name: n }) => {
857
+ (J(a) && c.mount || a || l.disabled.has(n)) && (a ? l.disabled.add(n) : l.disabled.delete(n));
857
858
  }, De = (a, n = {}) => {
858
859
  let o = m(s, a);
859
- const h = K(n.disabled) || K(r.disabled);
860
- return R(s, a, {
860
+ const v = J(n.disabled) || J(r.disabled);
861
+ return O(s, a, {
861
862
  ...o || {},
862
863
  _f: {
863
864
  ...o && o._f ? o._f : { ref: { name: a } },
@@ -865,121 +866,121 @@ function hr(t = {}) {
865
866
  mount: !0,
866
867
  ...n
867
868
  }
868
- }), l.mount.add(a), o ? at({
869
- disabled: K(n.disabled) ? n.disabled : r.disabled,
869
+ }), l.mount.add(a), o ? it({
870
+ disabled: J(n.disabled) ? n.disabled : r.disabled,
870
871
  name: a
871
- }) : f(a, !0, n.value), {
872
- ...h ? { disabled: n.disabled || r.disabled } : {},
872
+ }) : d(a, !0, n.value), {
873
+ ...v ? { disabled: n.disabled || r.disabled } : {},
873
874
  ...r.progressive ? {
874
875
  required: !!n.required,
875
- min: ge(n.min),
876
- max: ge(n.max),
877
- minLength: ge(n.minLength),
878
- maxLength: ge(n.maxLength),
879
- pattern: ge(n.pattern)
876
+ min: he(n.min),
877
+ max: he(n.max),
878
+ minLength: he(n.minLength),
879
+ maxLength: he(n.maxLength),
880
+ pattern: he(n.pattern)
880
881
  } : {},
881
882
  name: a,
882
- onChange: ae,
883
- onBlur: ae,
883
+ onChange: me,
884
+ onBlur: me,
884
885
  ref: (_) => {
885
886
  if (_) {
886
887
  De(a, n), o = m(s, a);
887
- const y = O(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, A = nr(y), C = o._f.refs || [];
888
- if (A ? C.find((T) => T === y) : y === o._f.ref)
888
+ const y = N(_.value) && _.querySelectorAll && _.querySelectorAll("input,select,textarea")[0] || _, b = ir(y), D = o._f.refs || [];
889
+ if (b ? D.find((L) => L === y) : y === o._f.ref)
889
890
  return;
890
- R(s, a, {
891
+ O(s, a, {
891
892
  _f: {
892
893
  ...o._f,
893
- ...A ? {
894
+ ...b ? {
894
895
  refs: [
895
- ...C.filter(Ue),
896
+ ...D.filter(Ne),
896
897
  y,
897
898
  ...Array.isArray(m(u, a)) ? [{}] : []
898
899
  ],
899
900
  ref: { type: y.type, name: a }
900
901
  } : { ref: y }
901
902
  }
902
- }), f(a, !1, void 0, y);
903
+ }), d(a, !1, void 0, y);
903
904
  } else
904
- o = m(s, a, {}), o._f && (o._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(xt(l.array, a) && c.action) && l.unMount.add(a);
905
+ o = m(s, a, {}), o._f && (o._f.mount = !1), (r.shouldUnregister || n.shouldUnregister) && !(St(l.array, a) && c.action) && l.unMount.add(a);
905
906
  }
906
907
  };
907
- }, Re = () => r.shouldFocusError && me(s, _e, l.mount), Bt = (a) => {
908
- K(a) && (F.state.next({ disabled: a }), me(s, (n, o) => {
909
- const h = m(s, o);
910
- h && (n.disabled = h._f.disabled || a, Array.isArray(h._f.refs) && h._f.refs.forEach((_) => {
911
- _.disabled = h._f.disabled || a;
908
+ }, Te = () => r.shouldFocusError && fe(s, _e, l.mount), Pt = (a) => {
909
+ J(a) && (p.state.next({ disabled: a }), fe(s, (n, o) => {
910
+ const v = m(s, o);
911
+ v && (n.disabled = v._f.disabled || a, Array.isArray(v._f.refs) && v._f.refs.forEach((_) => {
912
+ _.disabled = v._f.disabled || a;
912
913
  }));
913
914
  }, 0, !1));
914
- }, nt = (a, n) => async (o) => {
915
- let h;
915
+ }, ut = (a, n) => async (o) => {
916
+ let v;
916
917
  o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
917
- let _ = U(i);
918
- if (F.state.next({
918
+ let _ = M(i);
919
+ if (p.state.next({
919
920
  isSubmitting: !0
920
921
  }), r.resolver) {
921
- const { errors: y, values: A } = await E();
922
- e.errors = y, _ = U(A);
922
+ const { errors: y, values: b } = await W();
923
+ U(), e.errors = y, _ = M(b);
923
924
  } else
924
- await W(s);
925
+ await Z(s);
925
926
  if (l.disabled.size)
926
927
  for (const y of l.disabled)
927
- B(_, y);
928
- if (B(e.errors, "root"), q(e.errors)) {
929
- F.state.next({
928
+ P(_, y);
929
+ if (P(e.errors, "root"), j(e.errors)) {
930
+ p.state.next({
930
931
  errors: {}
931
932
  });
932
933
  try {
933
934
  await a(_, o);
934
935
  } catch (y) {
935
- h = y;
936
+ v = y;
936
937
  }
937
938
  } else
938
- n && await n({ ...e.errors }, o), Re(), setTimeout(Re);
939
- if (F.state.next({
939
+ n && await n({ ...e.errors }, o), Te(), setTimeout(Te);
940
+ if (p.state.next({
940
941
  isSubmitted: !0,
941
942
  isSubmitting: !1,
942
- isSubmitSuccessful: q(e.errors) && !h,
943
+ isSubmitSuccessful: j(e.errors) && !v,
943
944
  submitCount: e.submitCount + 1,
944
945
  errors: e.errors
945
- }), h)
946
- throw h;
947
- }, Pt = (a, n = {}) => {
948
- m(s, a) && (O(n.defaultValue) ? Q(a, U(m(u, a))) : (Q(a, n.defaultValue), R(u, a, U(n.defaultValue))), n.keepTouched || B(e.touchedFields, a), n.keepDirty || (B(e.dirtyFields, a), e.isDirty = n.defaultValue ? se(a, U(m(u, a))) : se()), n.keepError || (B(e.errors, a), x.isValid && w()), F.state.next({ ...e }));
949
- }, it = (a, n = {}) => {
950
- const o = a ? U(a) : u, h = U(o), _ = q(a), y = _ ? u : h;
946
+ }), v)
947
+ throw v;
948
+ }, Wt = (a, n = {}) => {
949
+ m(s, a) && (N(n.defaultValue) ? Y(a, M(m(u, a))) : (Y(a, n.defaultValue), O(u, a, M(n.defaultValue))), n.keepTouched || P(e.touchedFields, a), n.keepDirty || (P(e.dirtyFields, a), e.isDirty = n.defaultValue ? E(a, M(m(u, a))) : E()), n.keepError || (P(e.errors, a), g.isValid && T()), p.state.next({ ...e }));
950
+ }, ot = (a, n = {}) => {
951
+ const o = a ? M(a) : u, v = M(o), _ = j(a), y = _ ? u : v;
951
952
  if (n.keepDefaultValues || (u = o), !n.keepValues) {
952
953
  if (n.keepDirtyValues) {
953
- const A = /* @__PURE__ */ new Set([
954
+ const b = /* @__PURE__ */ new Set([
954
955
  ...l.mount,
955
- ...Object.keys(fe(u, i))
956
+ ...Object.keys(ce(u, i))
956
957
  ]);
957
- for (const C of Array.from(A))
958
- m(e.dirtyFields, C) ? R(y, C, m(i, C)) : Q(C, m(y, C));
958
+ for (const D of Array.from(b))
959
+ m(e.dirtyFields, D) ? O(y, D, m(i, D)) : Y(D, m(y, D));
959
960
  } else {
960
- if (ze && O(a))
961
- for (const A of l.mount) {
962
- const C = m(s, A);
963
- if (C && C._f) {
964
- const T = Array.isArray(C._f.refs) ? C._f.refs[0] : C._f.ref;
965
- if (xe(T)) {
966
- const J = T.closest("form");
967
- if (J) {
968
- J.reset();
961
+ if (Ke && N(a))
962
+ for (const b of l.mount) {
963
+ const D = m(s, b);
964
+ if (D && D._f) {
965
+ const L = Array.isArray(D._f.refs) ? D._f.refs[0] : D._f.ref;
966
+ if (xe(L)) {
967
+ const ee = L.closest("form");
968
+ if (ee) {
969
+ ee.reset();
969
970
  break;
970
971
  }
971
972
  }
972
973
  }
973
974
  }
974
975
  if (n.keepFieldsRef)
975
- for (const A of l.mount)
976
- Q(A, m(y, A));
976
+ for (const b of l.mount)
977
+ Y(b, m(y, b));
977
978
  else
978
979
  s = {};
979
980
  }
980
- i = r.shouldUnregister ? n.keepDefaultValues ? U(u) : {} : U(y), F.array.next({
981
+ i = r.shouldUnregister ? n.keepDefaultValues ? M(u) : {} : M(y), p.array.next({
981
982
  values: { ...y }
982
- }), F.state.next({
983
+ }), p.state.next({
983
984
  values: { ...y }
984
985
  });
985
986
  }
@@ -991,55 +992,58 @@ function hr(t = {}) {
991
992
  watch: /* @__PURE__ */ new Set(),
992
993
  watchAll: !1,
993
994
  focus: ""
994
- }, c.mount = !x.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !q(y), c.watch = !!r.shouldUnregister, c.action = !1, n.keepErrors || (e.errors = {}), F.state.next({
995
+ }, c.mount = !g.isValid || !!n.keepIsValid || !!n.keepDirtyValues || !r.shouldUnregister && !j(y), c.watch = !!r.shouldUnregister, c.keepIsValid = !!n.keepIsValid, c.action = !1, n.keepErrors || (e.errors = {}), p.state.next({
995
996
  submitCount: n.keepSubmitCount ? e.submitCount : 0,
996
- isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !te(a, u)),
997
+ isDirty: _ ? !1 : n.keepDirty ? e.isDirty : !!(n.keepDefaultValues && !ae(a, u)),
997
998
  isSubmitted: n.keepIsSubmitted ? e.isSubmitted : !1,
998
- dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ? fe(u, i) : e.dirtyFields : n.keepDefaultValues && a ? fe(u, a) : n.keepDirty ? e.dirtyFields : {},
999
+ dirtyFields: _ ? {} : n.keepDirtyValues ? n.keepDefaultValues && i ? ce(u, i) : e.dirtyFields : n.keepDefaultValues && a ? ce(u, a) : n.keepDirty ? e.dirtyFields : {},
999
1000
  touchedFields: n.keepTouched ? e.touchedFields : {},
1000
1001
  errors: n.keepErrors ? e.errors : {},
1001
1002
  isSubmitSuccessful: n.keepIsSubmitSuccessful ? e.isSubmitSuccessful : !1,
1002
1003
  isSubmitting: !1,
1003
1004
  defaultValues: u
1004
1005
  });
1005
- }, ut = (a, n) => it(re(a) ? a(i) : a, n), Wt = (a, n = {}) => {
1006
- const o = m(s, a), h = o && o._f;
1007
- if (h) {
1008
- const _ = h.refs ? h.refs[0] : h.ref;
1009
- _.focus && (_.focus(), n.shouldSelect && re(_.select) && _.select());
1006
+ }, lt = (a, n) => ot(G(a) ? a(i) : a, { ...r.resetOptions, ...n }), Ht = (a, n = {}) => {
1007
+ const o = m(s, a), v = o && o._f;
1008
+ if (v) {
1009
+ const _ = v.refs ? v.refs[0] : v.ref;
1010
+ _.focus && setTimeout(() => {
1011
+ _.focus(), n.shouldSelect && G(_.select) && _.select();
1012
+ });
1010
1013
  }
1011
1014
  }, $t = (a) => {
1012
1015
  e = {
1013
1016
  ...e,
1014
1017
  ...a
1015
1018
  };
1016
- }, ot = {
1019
+ }, ct = {
1017
1020
  control: {
1018
1021
  register: De,
1019
1022
  unregister: Ce,
1020
- getFieldState: tt,
1021
- handleSubmit: nt,
1022
- setError: rt,
1023
- _subscribe: st,
1024
- _runSchema: E,
1025
- _focusError: Re,
1026
- _getWatch: k,
1027
- _getDirty: se,
1028
- _setValid: w,
1029
- _setFieldArray: H,
1030
- _setDisabledField: at,
1031
- _setErrors: M,
1032
- _getFieldArray: D,
1033
- _reset: it,
1034
- _resetDefaultValues: () => re(r.defaultValues) && r.defaultValues().then((a) => {
1035
- ut(a, r.resetOptions), F.state.next({
1023
+ getFieldState: st,
1024
+ handleSubmit: ut,
1025
+ setError: at,
1026
+ _subscribe: nt,
1027
+ _runSchema: W,
1028
+ _updateIsValidating: U,
1029
+ _focusError: Te,
1030
+ _getWatch: C,
1031
+ _getDirty: E,
1032
+ _setValid: T,
1033
+ _setFieldArray: x,
1034
+ _setDisabledField: it,
1035
+ _setErrors: f,
1036
+ _getFieldArray: $,
1037
+ _reset: ot,
1038
+ _resetDefaultValues: () => G(r.defaultValues) && r.defaultValues().then((a) => {
1039
+ lt(a, r.resetOptions), p.state.next({
1036
1040
  isLoading: !1
1037
1041
  });
1038
1042
  }),
1039
- _removeUnmounted: oe,
1040
- _disableForm: Bt,
1041
- _subjects: F,
1042
- _proxyFormState: x,
1043
+ _removeUnmounted: Fe,
1044
+ _disableForm: Pt,
1045
+ _subjects: p,
1046
+ _proxyFormState: g,
1043
1047
  get _fields() {
1044
1048
  return s;
1045
1049
  },
@@ -1074,24 +1078,24 @@ function hr(t = {}) {
1074
1078
  };
1075
1079
  }
1076
1080
  },
1077
- subscribe: It,
1078
- trigger: ce,
1081
+ subscribe: Bt,
1082
+ trigger: ge,
1079
1083
  register: De,
1080
- handleSubmit: nt,
1081
- watch: Mt,
1082
- setValue: Q,
1083
- getValues: Fe,
1084
- reset: ut,
1085
- resetField: Pt,
1086
- clearErrors: Lt,
1084
+ handleSubmit: ut,
1085
+ watch: It,
1086
+ setValue: Y,
1087
+ getValues: rt,
1088
+ reset: lt,
1089
+ resetField: Wt,
1090
+ clearErrors: Mt,
1087
1091
  unregister: Ce,
1088
- setError: rt,
1089
- setFocus: Wt,
1090
- getFieldState: tt
1092
+ setError: at,
1093
+ setFocus: Ht,
1094
+ getFieldState: st
1091
1095
  };
1092
1096
  return {
1093
- ...ot,
1094
- formControl: ot
1097
+ ...ct,
1098
+ formControl: ct
1095
1099
  };
1096
1100
  }
1097
1101
  var ue = () => {
@@ -1102,137 +1106,138 @@ var ue = () => {
1102
1106
  const e = (Math.random() * 16 + t) % 16 | 0;
1103
1107
  return (r == "x" ? e : e & 3 | 8).toString(16);
1104
1108
  });
1105
- }, Ne = (t, r, e = {}) => e.shouldFocus || O(e.shouldFocus) ? e.focusName || `${t}.${O(e.focusIndex) ? r : e.focusIndex}.` : "", Le = (t, r) => [
1109
+ }, Ue = (t, r, e = {}) => e.shouldFocus || N(e.shouldFocus) ? e.focusName || `${t}.${N(e.focusIndex) ? r : e.focusIndex}.` : "", Me = (t, r) => [
1106
1110
  ...t,
1107
1111
  ...z(r)
1108
- ], Me = (t) => Array.isArray(t) ? t.map(() => {
1112
+ ], Ie = (t) => Array.isArray(t) ? t.map(() => {
1109
1113
  }) : void 0;
1110
- function Ie(t, r, e) {
1114
+ function Be(t, r, e) {
1111
1115
  return [
1112
1116
  ...t.slice(0, r),
1113
1117
  ...z(e),
1114
1118
  ...t.slice(r)
1115
1119
  ];
1116
1120
  }
1117
- var Be = (t, r, e) => Array.isArray(t) ? (O(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], Pe = (t, r) => [
1121
+ var Pe = (t, r, e) => Array.isArray(t) ? (N(t[e]) && (t[e] = void 0), t.splice(e, 0, t.splice(r, 1)[0]), t) : [], We = (t, r) => [
1118
1122
  ...z(r),
1119
1123
  ...z(t)
1120
1124
  ];
1121
- function vr(t, r) {
1125
+ function Vr(t, r) {
1122
1126
  let e = 0;
1123
1127
  const s = [...t];
1124
1128
  for (const u of r)
1125
1129
  s.splice(u - e, 1), e++;
1126
1130
  return we(s).length ? s : [];
1127
1131
  }
1128
- var We = (t, r) => O(r) ? [] : vr(t, z(r).sort((e, s) => e - s)), $e = (t, r, e) => {
1132
+ var He = (t, r) => N(r) ? [] : Vr(t, z(r).sort((e, s) => e - s)), $e = (t, r, e) => {
1129
1133
  [t[r], t[e]] = [t[e], t[r]];
1130
- }, Ft = (t, r, e) => (t[r] = e, t);
1131
- function Vr(t) {
1132
- const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = b.useState(e._getFieldArray(s)), v = b.useRef(e._getFieldArray(s).map(ue)), x = b.useRef(!1);
1133
- e._names.array.add(s), b.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), ke(() => e._subjects.array.subscribe({
1134
+ }, bt = (t, r, e) => (t[r] = e, t);
1135
+ function Fr(t) {
1136
+ const r = Ve(), { control: e = r.control, name: s, keyName: u = "id", shouldUnregister: i, rules: c } = t, [l, V] = F.useState(e._getFieldArray(s)), h = F.useRef(e._getFieldArray(s).map(ue)), k = F.useRef(!1);
1137
+ e._names.array.add(s), F.useMemo(() => c && l.length >= 0 && e.register(s, c), [e, s, l.length, c]), ke(() => e._subjects.array.subscribe({
1134
1138
  next: ({ values: f, name: d }) => {
1135
1139
  if (d === s || !d) {
1136
- const p = m(f, s);
1137
- Array.isArray(p) && (V(p), v.current = p.map(ue));
1140
+ const A = m(f, s);
1141
+ Array.isArray(A) && (V(A), h.current = A.map(ue));
1138
1142
  }
1139
1143
  }
1140
1144
  }).unsubscribe, [e, s]);
1141
- const g = b.useCallback((f) => {
1142
- x.current = !0, e._setFieldArray(s, f);
1143
- }, [e, s]), F = (f, d) => {
1144
- const p = z(U(f)), E = Le(e._getFieldArray(s), p);
1145
- e._names.focus = Ne(s, E.length - 1, d), v.current = Le(v.current, p.map(ue)), g(E), V(E), e._setFieldArray(s, E, Le, {
1146
- argA: Me(f)
1145
+ const g = F.useCallback((f) => {
1146
+ k.current = !0, e._setFieldArray(s, f);
1147
+ }, [e, s]), S = (f, d) => {
1148
+ const A = z(M(f)), w = Me(e._getFieldArray(s), A);
1149
+ e._names.focus = Ue(s, w.length - 1, d), h.current = Me(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, Me, {
1150
+ argA: Ie(f)
1147
1151
  });
1148
- }, $ = (f, d) => {
1149
- const p = z(U(f)), E = Pe(e._getFieldArray(s), p);
1150
- e._names.focus = Ne(s, 0, d), v.current = Pe(v.current, p.map(ue)), g(E), V(E), e._setFieldArray(s, E, Pe, {
1151
- argA: Me(f)
1152
+ }, p = (f, d) => {
1153
+ const A = z(M(f)), w = We(e._getFieldArray(s), A);
1154
+ e._names.focus = Ue(s, 0, d), h.current = We(h.current, A.map(ue)), g(w), V(w), e._setFieldArray(s, w, We, {
1155
+ argA: Ie(f)
1152
1156
  });
1153
- }, L = (f) => {
1154
- const d = We(e._getFieldArray(s), f);
1155
- v.current = We(v.current, f), g(d), V(d), !Array.isArray(m(e._fields, s)) && R(e._fields, s, void 0), e._setFieldArray(s, d, We, {
1157
+ }, I = (f) => {
1158
+ const d = He(e._getFieldArray(s), f);
1159
+ h.current = He(h.current, f), g(d), V(d), !Array.isArray(m(e._fields, s)) && O(e._fields, s, void 0), e._setFieldArray(s, d, He, {
1156
1160
  argA: f
1157
1161
  });
1158
- }, w = (f, d, p) => {
1159
- const E = z(U(d)), Z = Ie(e._getFieldArray(s), f, E);
1160
- e._names.focus = Ne(s, f, p), v.current = Ie(v.current, f, E.map(ue)), g(Z), V(Z), e._setFieldArray(s, Z, Ie, {
1162
+ }, R = (f, d, A) => {
1163
+ const w = z(M(d)), W = Be(e._getFieldArray(s), f, w);
1164
+ e._names.focus = Ue(s, f, A), h.current = Be(h.current, f, w.map(ue)), g(W), V(W), e._setFieldArray(s, W, Be, {
1161
1165
  argA: f,
1162
- argB: Me(d)
1166
+ argB: Ie(d)
1163
1167
  });
1164
- }, N = (f, d) => {
1165
- const p = e._getFieldArray(s);
1166
- $e(p, f, d), $e(v.current, f, d), g(p), V(p), e._setFieldArray(s, p, $e, {
1168
+ }, T = (f, d) => {
1169
+ const A = e._getFieldArray(s);
1170
+ $e(A, f, d), $e(h.current, f, d), g(A), V(A), e._setFieldArray(s, A, $e, {
1167
1171
  argA: f,
1168
1172
  argB: d
1169
1173
  }, !1);
1170
- }, H = (f, d) => {
1171
- const p = e._getFieldArray(s);
1172
- Be(p, f, d), Be(v.current, f, d), g(p), V(p), e._setFieldArray(s, p, Be, {
1174
+ }, U = (f, d) => {
1175
+ const A = e._getFieldArray(s);
1176
+ Pe(A, f, d), Pe(h.current, f, d), g(A), V(A), e._setFieldArray(s, A, Pe, {
1173
1177
  argA: f,
1174
1178
  argB: d
1175
1179
  }, !1);
1176
- }, S = (f, d) => {
1177
- const p = U(d), E = Ft(e._getFieldArray(s), f, p);
1178
- v.current = [...E].map((Z, W) => !Z || W === f ? ue() : v.current[W]), g(E), V([...E]), e._setFieldArray(s, E, Ft, {
1180
+ }, x = (f, d) => {
1181
+ const A = M(d), w = bt(e._getFieldArray(s), f, A);
1182
+ h.current = [...w].map((W, K) => !W || K === f ? ue() : h.current[K]), g(w), V([...w]), e._setFieldArray(s, w, bt, {
1179
1183
  argA: f,
1180
- argB: p
1184
+ argB: A
1181
1185
  }, !0, !1);
1182
- }, M = (f) => {
1183
- const d = z(U(f));
1184
- v.current = d.map(ue), g([...d]), V([...d]), e._setFieldArray(s, [...d], (p) => p, {}, !0, !1);
1186
+ }, B = (f) => {
1187
+ const d = z(M(f));
1188
+ h.current = d.map(ue), g([...d]), V([...d]), e._setFieldArray(s, [...d], (A) => A, {}, !0, !1);
1185
1189
  };
1186
- return b.useEffect(() => {
1190
+ return F.useEffect(() => {
1187
1191
  if (e._state.action = !1, Qe(s, e._names) && e._subjects.state.next({
1188
1192
  ...e._formState
1189
- }), x.current && (!ye(e._options.mode).isOnSubmit || e._formState.isSubmitted) && !ye(e._options.reValidateMode).isOnSubmit)
1193
+ }), k.current && (!de(e._options.mode).isOnSubmit || e._formState.isSubmitted) && !de(e._options.reValidateMode).isOnSubmit)
1190
1194
  if (e._options.resolver)
1191
1195
  e._runSchema([s]).then((f) => {
1192
- const d = m(f.errors, s), p = m(e._formState.errors, s);
1193
- (p ? !d && p.type || d && (p.type !== d.type || p.message !== d.message) : d && d.type) && (d ? R(e._formState.errors, s, d) : B(e._formState.errors, s), e._subjects.state.next({
1196
+ e._updateIsValidating([s]);
1197
+ const d = m(f.errors, s), A = m(e._formState.errors, s);
1198
+ (A ? !d && A.type || d && (A.type !== d.type || A.message !== d.message) : d && d.type) && (d ? O(e._formState.errors, s, d) : P(e._formState.errors, s), e._subjects.state.next({
1194
1199
  errors: e._formState.errors
1195
1200
  }));
1196
1201
  });
1197
1202
  else {
1198
1203
  const f = m(e._fields, s);
1199
- f && f._f && !(ye(e._options.reValidateMode).isOnSubmit && ye(e._options.mode).isOnSubmit) && Ge(f, e._names.disabled, e._formValues, e._options.criteriaMode === X.all, e._options.shouldUseNativeValidation, !0).then((d) => !q(d) && e._subjects.state.next({
1200
- errors: Tt(e._formState.errors, d, s)
1204
+ f && f._f && !(de(e._options.reValidateMode).isOnSubmit && de(e._options.mode).isOnSubmit) && ze(f, e._names.disabled, e._formValues, e._options.criteriaMode === re.all, e._options.shouldUseNativeValidation, !0).then((d) => !j(d) && e._subjects.state.next({
1205
+ errors: Rt(e._formState.errors, d, s)
1201
1206
  }));
1202
1207
  }
1203
1208
  e._subjects.state.next({
1204
1209
  name: s,
1205
- values: U(e._formValues)
1206
- }), e._names.focus && me(e._fields, (f, d) => {
1210
+ values: M(e._formValues)
1211
+ }), e._names.focus && fe(e._fields, (f, d) => {
1207
1212
  if (e._names.focus && d.startsWith(e._names.focus) && f.focus)
1208
1213
  return f.focus(), 1;
1209
- }), e._names.focus = "", e._setValid(), x.current = !1;
1210
- }, [l, s, e]), b.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
1211
- const f = (d, p) => {
1212
- const E = m(e._fields, d);
1213
- E && E._f && (E._f.mount = p);
1214
+ }), e._names.focus = "", e._setValid(), k.current = !1;
1215
+ }, [l, s, e]), F.useEffect(() => (!m(e._formValues, s) && e._setFieldArray(s), () => {
1216
+ const f = (d, A) => {
1217
+ const w = m(e._fields, d);
1218
+ w && w._f && (w._f.mount = A);
1214
1219
  };
1215
1220
  e._options.shouldUnregister || i ? e.unregister(s) : f(s, !1);
1216
1221
  }), [s, e, u, i]), {
1217
- swap: b.useCallback(N, [g, s, e]),
1218
- move: b.useCallback(H, [g, s, e]),
1219
- prepend: b.useCallback($, [g, s, e]),
1220
- append: b.useCallback(F, [g, s, e]),
1221
- remove: b.useCallback(L, [g, s, e]),
1222
- insert: b.useCallback(w, [g, s, e]),
1223
- update: b.useCallback(S, [g, s, e]),
1224
- replace: b.useCallback(M, [g, s, e]),
1225
- fields: b.useMemo(() => l.map((f, d) => ({
1222
+ swap: F.useCallback(T, [g, s, e]),
1223
+ move: F.useCallback(U, [g, s, e]),
1224
+ prepend: F.useCallback(p, [g, s, e]),
1225
+ append: F.useCallback(S, [g, s, e]),
1226
+ remove: F.useCallback(I, [g, s, e]),
1227
+ insert: F.useCallback(R, [g, s, e]),
1228
+ update: F.useCallback(x, [g, s, e]),
1229
+ replace: F.useCallback(B, [g, s, e]),
1230
+ fields: F.useMemo(() => l.map((f, d) => ({
1226
1231
  ...f,
1227
- [u]: v.current[d] || ue()
1232
+ [u]: h.current[d] || ue()
1228
1233
  })), [l, u])
1229
1234
  };
1230
1235
  }
1231
- function Fr(t = {}) {
1232
- const r = b.useRef(void 0), e = b.useRef(void 0), [s, u] = b.useState({
1236
+ function br(t = {}) {
1237
+ const r = F.useRef(void 0), e = F.useRef(void 0), [s, u] = F.useState({
1233
1238
  isDirty: !1,
1234
1239
  isValidating: !1,
1235
- isLoading: re(t.defaultValues),
1240
+ isLoading: G(t.defaultValues),
1236
1241
  isSubmitted: !1,
1237
1242
  isSubmitting: !1,
1238
1243
  isSubmitSuccessful: !1,
@@ -1244,16 +1249,16 @@ function Fr(t = {}) {
1244
1249
  errors: t.errors || {},
1245
1250
  disabled: t.disabled || !1,
1246
1251
  isReady: !1,
1247
- defaultValues: re(t.defaultValues) ? void 0 : t.defaultValues
1252
+ defaultValues: G(t.defaultValues) ? void 0 : t.defaultValues
1248
1253
  });
1249
1254
  if (!r.current)
1250
1255
  if (t.formControl)
1251
1256
  r.current = {
1252
1257
  ...t.formControl,
1253
1258
  formState: s
1254
- }, t.defaultValues && !re(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
1259
+ }, t.defaultValues && !G(t.defaultValues) && t.formControl.reset(t.defaultValues, t.resetOptions);
1255
1260
  else {
1256
- const { formControl: c, ...l } = hr(t);
1261
+ const { formControl: c, ...l } = vr(t);
1257
1262
  r.current = {
1258
1263
  ...l,
1259
1264
  formState: s
@@ -1270,39 +1275,39 @@ function Fr(t = {}) {
1270
1275
  ...l,
1271
1276
  isReady: !0
1272
1277
  })), i._formState.isReady = !0, c;
1273
- }, [i]), b.useEffect(() => i._disableForm(t.disabled), [i, t.disabled]), b.useEffect(() => {
1278
+ }, [i]), F.useEffect(() => i._disableForm(t.disabled), [i, t.disabled]), F.useEffect(() => {
1274
1279
  t.mode && (i._options.mode = t.mode), t.reValidateMode && (i._options.reValidateMode = t.reValidateMode);
1275
- }, [i, t.mode, t.reValidateMode]), b.useEffect(() => {
1280
+ }, [i, t.mode, t.reValidateMode]), F.useEffect(() => {
1276
1281
  t.errors && (i._setErrors(t.errors), i._focusError());
1277
- }, [i, t.errors]), b.useEffect(() => {
1282
+ }, [i, t.errors]), F.useEffect(() => {
1278
1283
  t.shouldUnregister && i._subjects.state.next({
1279
1284
  values: i._getWatch()
1280
1285
  });
1281
- }, [i, t.shouldUnregister]), b.useEffect(() => {
1286
+ }, [i, t.shouldUnregister]), F.useEffect(() => {
1282
1287
  if (i._proxyFormState.isDirty) {
1283
1288
  const c = i._getDirty();
1284
1289
  c !== s.isDirty && i._subjects.state.next({
1285
1290
  isDirty: c
1286
1291
  });
1287
1292
  }
1288
- }, [i, s.isDirty]), b.useEffect(() => {
1293
+ }, [i, s.isDirty]), F.useEffect(() => {
1289
1294
  var c;
1290
- t.values && !te(t.values, e.current) ? (i._reset(t.values, {
1295
+ t.values && !ae(t.values, e.current) ? (i._reset(t.values, {
1291
1296
  keepFieldsRef: !0,
1292
1297
  ...i._options.resetOptions
1293
1298
  }), !((c = i._options.resetOptions) === null || c === void 0) && c.keepIsValid || i._setValid(), e.current = t.values, u((l) => ({ ...l }))) : i._resetDefaultValues();
1294
- }, [i, t.values]), b.useEffect(() => {
1299
+ }, [i, t.values]), F.useEffect(() => {
1295
1300
  i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
1296
- }), r.current.formState = St(s, i), r.current;
1301
+ }), r.current.formState = Et(s, i), r.current;
1297
1302
  }
1298
- const Ot = Gt(void 0), br = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ ee(Ot.Provider, { value: { showAsterisk: t }, children: r }), Ar = () => {
1299
- const t = zt(Ot);
1303
+ const Lt = zt(void 0), Ar = ({ showAsterisk: t, children: r }) => /* @__PURE__ */ te(Lt.Provider, { value: { showAsterisk: t }, children: r }), pr = () => {
1304
+ const t = Kt(Lt);
1300
1305
  if (!t)
1301
1306
  throw new Error("useSuprFormContext must be used within a SuprFormProvider");
1302
1307
  return t;
1303
1308
  };
1304
- function Ut(t, r, e) {
1305
- const { conditions: s, operator: u } = e, i = t.reduce((l, V, v) => (l[V] = r[v], l), {}), c = s.map((l) => {
1309
+ function Nt(t, r, e) {
1310
+ const { conditions: s, operator: u } = e, i = t.reduce((l, V, h) => (l[V] = r[h], l), {}), c = s.map((l) => {
1306
1311
  const V = i[l.name];
1307
1312
  switch (l.operator) {
1308
1313
  case "EQUALS":
@@ -1331,19 +1336,19 @@ function Ut(t, r, e) {
1331
1336
  });
1332
1337
  return u === "AND" ? c.every(Boolean) : c.some(Boolean);
1333
1338
  }
1334
- const pr = ({
1339
+ const xr = ({
1335
1340
  children: t,
1336
1341
  visibility: r
1337
1342
  }) => {
1338
- const e = he(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Je({ name: e });
1339
- return he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 : Ut(e, s, r), [r, e, s]) ? t : null;
1340
- }, xr = ({
1343
+ const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e });
1344
+ return ye(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !0 : Nt(e, s, r), [r, e, s]) ? t : null;
1345
+ }, Sr = ({
1341
1346
  children: t,
1342
1347
  disabled: r
1343
1348
  }) => {
1344
- const e = he(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Je({ name: e }), u = he(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 : Ut(e, s, r), [r, e, s]);
1349
+ const e = ye(() => typeof r == "boolean" ? [] : (r == null ? void 0 : r.conditions.map((i) => i.name)) || [], [r]), s = Xe({ name: e }), u = ye(() => typeof r == "boolean" ? r : !r || (r == null ? void 0 : r.conditions.length) === 0 ? !1 : Nt(e, s, r), [r, e, s]);
1345
1350
  return Ae(t, { ...t.props, disabled: u });
1346
- }, et = ({
1351
+ }, tt = ({
1347
1352
  children: t,
1348
1353
  name: r,
1349
1354
  rules: e,
@@ -1352,53 +1357,74 @@ const pr = ({
1352
1357
  id: i,
1353
1358
  disabled: c,
1354
1359
  shouldUnregister: l,
1355
- visibility: V
1360
+ visibility: V,
1361
+ description: h
1356
1362
  }) => {
1357
- const { control: v } = Ve(), x = t.props.value ?? "", { showAsterisk: g } = Ar(), F = t.props.onChange, $ = t.props.onBlur, L = he(() => i || crypto.randomUUID(), []);
1358
- return /* @__PURE__ */ ee(pr, { visibility: V, children: /* @__PURE__ */ ee(xr, { disabled: c, children: /* @__PURE__ */ ee(
1359
- sr,
1363
+ const { control: k } = Ve(), g = t.props.value ?? "", { showAsterisk: S } = pr(), p = t.props.onChange, I = t.props.onBlur, R = ye(() => i || crypto.randomUUID(), []), T = ye(() => {
1364
+ if (h)
1365
+ return typeof h == "string" ? { position: "LABEL_BOTTOM", text: h } : h;
1366
+ }, [h]);
1367
+ return /* @__PURE__ */ te(xr, { visibility: V, children: /* @__PURE__ */ te(Sr, { disabled: c, children: /* @__PURE__ */ te(
1368
+ ar,
1360
1369
  {
1361
- control: v,
1370
+ control: k,
1362
1371
  name: r,
1363
1372
  rules: e,
1364
- defaultValue: x,
1373
+ defaultValue: g,
1365
1374
  shouldUnregister: l,
1366
1375
  render: ({
1367
- field: { name: w, onBlur: N, value: H, onChange: S, ref: M, disabled: f },
1368
- fieldState: { error: d }
1369
- }) => /* @__PURE__ */ dt(
1376
+ field: { name: U, onBlur: x, value: B, onChange: f, ref: d, disabled: A },
1377
+ fieldState: { error: w }
1378
+ }) => /* @__PURE__ */ Le(
1370
1379
  "div",
1371
1380
  {
1372
1381
  className: `controlled-field ${s}`,
1373
1382
  style: { display: "flex", flexDirection: "column", gap: "5px" },
1374
1383
  children: [
1375
- u && /* @__PURE__ */ dt("label", { htmlFor: L, className: "controlled-field-label", children: [
1376
- u,
1377
- g && !!e && /* @__PURE__ */ ee("span", { style: { color: "red" }, children: " *" })
1378
- ] }),
1384
+ /* @__PURE__ */ Le(
1385
+ "div",
1386
+ {
1387
+ className: "controlled-field-description",
1388
+ style: {
1389
+ display: "inline-flex",
1390
+ ...T && {
1391
+ gap: "2px",
1392
+ alignItems: "center",
1393
+ flexDirection: T.position === "LABEL_RIGHT" ? "row" : "column"
1394
+ }
1395
+ },
1396
+ children: [
1397
+ u && /* @__PURE__ */ Le("label", { htmlFor: R, className: "controlled-field-label", children: [
1398
+ u,
1399
+ S && !!e && /* @__PURE__ */ te("span", { style: { color: "red" }, children: " *" })
1400
+ ] }),
1401
+ T && T.position !== "CONTROL_BOTTOM" && /* @__PURE__ */ te("span", { style: { color: "#a1a1a1", fontSize: 12 }, children: T.text })
1402
+ ]
1403
+ }
1404
+ ),
1379
1405
  Ae(t, {
1380
1406
  ...t.props,
1381
- id: L,
1382
- name: w,
1383
- disabled: f,
1384
- onChange: (...p) => {
1385
- S(...p), F == null || F(...p);
1407
+ id: R,
1408
+ name: U,
1409
+ disabled: A,
1410
+ onChange: (...W) => {
1411
+ f(...W), p == null || p(...W);
1386
1412
  },
1387
- value: H,
1388
- onBlur: (...p) => {
1389
- N(), $ == null || $(...p);
1413
+ value: B,
1414
+ onBlur: (...W) => {
1415
+ x(), I == null || I(...W);
1390
1416
  },
1391
- ref: M
1417
+ ref: d
1392
1418
  }),
1393
- d && /* @__PURE__ */ ee("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: d.message })
1419
+ w && /* @__PURE__ */ te("div", { style: { color: "red", fontSize: 13 }, className: "controlled-field-error", children: w.message })
1394
1420
  ]
1395
1421
  }
1396
1422
  )
1397
1423
  }
1398
1424
  ) }) });
1399
1425
  };
1400
- et.displayName = "SuprFormControl";
1401
- const Sr = ({
1426
+ tt.displayName = "SuprFormControl";
1427
+ const Er = ({
1402
1428
  name: t,
1403
1429
  rules: r,
1404
1430
  ref: e,
@@ -1406,56 +1432,56 @@ const Sr = ({
1406
1432
  visibility: u,
1407
1433
  disabled: i
1408
1434
  }) => {
1409
- const c = Vr({
1435
+ const c = Fr({
1410
1436
  name: t,
1411
1437
  rules: r
1412
1438
  });
1413
- bt(e, () => c, [c]);
1414
- const l = (V, v) => Kt.map(V, (x) => {
1415
- var L, w;
1416
- if (!Yt(x))
1417
- return x;
1418
- const g = x.props, F = x.type;
1419
- if (((F == null ? void 0 : F.displayName) === "SuprFormControl" || F === et || g.name !== void 0 && typeof F != "string") && g.name !== void 0) {
1420
- const N = u ? u[g.name] : void 0, H = N ? {
1421
- ...N,
1422
- conditions: ((L = N.conditions) == null ? void 0 : L.map((d) => ({
1439
+ At(e, () => c, [c]);
1440
+ const l = (V, h) => Yt.map(V, (k) => {
1441
+ var I, R;
1442
+ if (!Jt(k))
1443
+ return k;
1444
+ const g = k.props, S = k.type;
1445
+ if (((S == null ? void 0 : S.displayName) === "SuprFormControl" || S === tt || g.name !== void 0 && typeof S != "string") && g.name !== void 0) {
1446
+ const T = u ? u[g.name] : void 0, U = T ? {
1447
+ ...T,
1448
+ conditions: ((I = T.conditions) == null ? void 0 : I.map((d) => ({
1423
1449
  ...d,
1424
- name: `${v}${d.name}`
1450
+ name: `${h}${d.name}`
1425
1451
  }))) || []
1426
- } : void 0, S = i ? i[g.name] : void 0, M = S ? {
1427
- ...S,
1428
- conditions: ((w = S.conditions) == null ? void 0 : w.map((d) => ({
1452
+ } : void 0, x = i ? i[g.name] : void 0, B = x ? {
1453
+ ...x,
1454
+ conditions: ((R = x.conditions) == null ? void 0 : R.map((d) => ({
1429
1455
  ...d,
1430
- name: `${v}${d.name}`
1456
+ name: `${h}${d.name}`
1431
1457
  }))) || []
1432
1458
  } : void 0, f = {
1433
1459
  ...g,
1434
- name: `${v}${g.name}`,
1435
- visibility: H,
1436
- disabled: M
1460
+ name: `${h}${g.name}`,
1461
+ visibility: U,
1462
+ disabled: B
1437
1463
  };
1438
- return g.id !== void 0 && (f.id = `${v}${g.id}`), Ae(x, f);
1464
+ return g.id !== void 0 && (f.id = `${h}${g.id}`), Ae(k, f);
1439
1465
  }
1440
- return g.children ? Ae(x, {
1466
+ return g.children ? Ae(k, {
1441
1467
  ...g,
1442
- children: l(g.children, v)
1443
- }) : x;
1468
+ children: l(g.children, h)
1469
+ }) : k;
1444
1470
  });
1445
- return /* @__PURE__ */ ee(Qt, { children: c.fields.map((V, v) => {
1446
- const x = `${t}.${v}.`;
1447
- return /* @__PURE__ */ ee(
1471
+ return /* @__PURE__ */ te(Qt, { children: c.fields.map((V, h) => {
1472
+ const k = `${t}.${h}.`;
1473
+ return /* @__PURE__ */ te(
1448
1474
  "div",
1449
1475
  {
1450
- "data-index": v,
1476
+ "data-index": h,
1451
1477
  style: { display: "contents" },
1452
1478
  id: "field-array-item",
1453
- children: l(s, x)
1479
+ children: l(s, k)
1454
1480
  },
1455
- x
1481
+ k
1456
1482
  );
1457
1483
  }) });
1458
- }, Nt = ({
1484
+ }, Ut = ({
1459
1485
  children: t,
1460
1486
  onSubmit: r = () => {
1461
1487
  },
@@ -1468,47 +1494,47 @@ const Sr = ({
1468
1494
  ref: l,
1469
1495
  onChange: V
1470
1496
  }) => {
1471
- const v = Fr({
1497
+ const h = br({
1472
1498
  mode: "onSubmit",
1473
1499
  reValidateMode: "onChange",
1474
1500
  shouldFocusError: !0,
1475
1501
  ...i
1476
1502
  });
1477
- return bt(
1503
+ return At(
1478
1504
  l,
1479
1505
  () => ({
1480
- setValue: v.setValue,
1481
- setError: v.setError,
1482
- clearErrors: v.clearErrors,
1483
- getValues: v.getValues,
1484
- reset: v.reset,
1485
- setFocus: v.setFocus,
1486
- resetField: v.resetField,
1487
- trigger: v.trigger,
1488
- unregister: v.unregister,
1489
- watch: v.watch,
1490
- handleSubmit: v.handleSubmit
1506
+ setValue: h.setValue,
1507
+ setError: h.setError,
1508
+ clearErrors: h.clearErrors,
1509
+ getValues: h.getValues,
1510
+ reset: h.reset,
1511
+ setFocus: h.setFocus,
1512
+ resetField: h.resetField,
1513
+ trigger: h.trigger,
1514
+ unregister: h.unregister,
1515
+ watch: h.watch,
1516
+ handleSubmit: h.handleSubmit
1491
1517
  }),
1492
- [v]
1493
- ), Jt(() => {
1494
- const x = v.watch((g) => {
1518
+ [h]
1519
+ ), Xt(() => {
1520
+ const k = h.watch((g) => {
1495
1521
  V == null || V(g);
1496
1522
  });
1497
- return () => x.unsubscribe();
1498
- }, [v.watch]), /* @__PURE__ */ ee(br, { showAsterisk: c, children: /* @__PURE__ */ ee(er, { ...v, children: /* @__PURE__ */ ee(
1523
+ return () => k.unsubscribe();
1524
+ }, [h.watch]), /* @__PURE__ */ te(Ar, { showAsterisk: c, children: /* @__PURE__ */ te(tr, { ...h, children: /* @__PURE__ */ te(
1499
1525
  "form",
1500
1526
  {
1501
1527
  noValidate: !0,
1502
- onSubmit: v.handleSubmit(r, e),
1528
+ onSubmit: h.handleSubmit(r, e),
1503
1529
  style: s,
1504
1530
  className: u,
1505
1531
  children: t
1506
1532
  }
1507
1533
  ) }) });
1508
1534
  };
1509
- Nt.Control = et;
1510
- Nt.ControlArray = Sr;
1535
+ Ut.Control = tt;
1536
+ Ut.ControlArray = Er;
1511
1537
  export {
1512
- Nt as SuprForm
1538
+ Ut as SuprForm
1513
1539
  };
1514
1540
  //# sourceMappingURL=suprform.es.js.map