suprform 1.0.6 → 1.0.8

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