@iress-oss/ids-components 6.0.0-alpha.2 → 6.0.0-alpha.4

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.
@@ -0,0 +1,1080 @@
1
+ import V from "react";
2
+ var de = (e) => e.type === "checkbox", se = (e) => e instanceof Date, I = (e) => e == null;
3
+ const rt = (e) => typeof e == "object";
4
+ var E = (e) => !I(e) && !Array.isArray(e) && rt(e) && !se(e), st = (e) => E(e) && e.target ? de(e.target) ? e.target.checked : e.target.value : e, Dt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, it = (e, s) => e.has(Dt(s)), St = (e) => {
5
+ const s = e.constructor && e.constructor.prototype;
6
+ return E(s) && s.hasOwnProperty("isPrototypeOf");
7
+ }, Ee = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
8
+ function U(e) {
9
+ let s;
10
+ const t = Array.isArray(e), a = typeof FileList < "u" ? e instanceof FileList : !1;
11
+ if (e instanceof Date)
12
+ s = new Date(e);
13
+ else if (e instanceof Set)
14
+ s = new Set(e);
15
+ else if (!(Ee && (e instanceof Blob || a)) && (t || E(e)))
16
+ if (s = t ? [] : {}, !t && !St(e))
17
+ s = e;
18
+ else
19
+ for (const l in e)
20
+ e.hasOwnProperty(l) && (s[l] = U(e[l]));
21
+ else
22
+ return e;
23
+ return s;
24
+ }
25
+ var Ve = (e) => Array.isArray(e) ? e.filter(Boolean) : [], k = (e) => e === void 0, c = (e, s, t) => {
26
+ if (!s || !E(e))
27
+ return t;
28
+ const a = Ve(s.split(/[,[\].]+?/)).reduce((l, u) => I(l) ? l : l[u], e);
29
+ return k(a) || a === e ? k(e[s]) ? t : e[s] : a;
30
+ }, p = (e) => typeof e == "boolean", Ce = (e) => /^\w*$/.test(e), at = (e) => Ve(e.replace(/["|']|\]/g, "").split(/\.|\[/)), w = (e, s, t) => {
31
+ let a = -1;
32
+ const l = Ce(s) ? [s] : at(s), u = l.length, d = u - 1;
33
+ for (; ++a < u; ) {
34
+ const g = l[a];
35
+ let F = t;
36
+ if (a !== d) {
37
+ const T = e[g];
38
+ F = E(T) || Array.isArray(T) ? T : isNaN(+l[a + 1]) ? {} : [];
39
+ }
40
+ if (g === "__proto__" || g === "constructor" || g === "prototype")
41
+ return;
42
+ e[g] = F, e = e[g];
43
+ }
44
+ };
45
+ const he = {
46
+ BLUR: "blur",
47
+ FOCUS_OUT: "focusout",
48
+ CHANGE: "change"
49
+ }, j = {
50
+ onBlur: "onBlur",
51
+ onChange: "onChange",
52
+ onSubmit: "onSubmit",
53
+ onTouched: "onTouched",
54
+ all: "all"
55
+ }, X = {
56
+ max: "max",
57
+ min: "min",
58
+ maxLength: "maxLength",
59
+ minLength: "minLength",
60
+ pattern: "pattern",
61
+ required: "required",
62
+ validate: "validate"
63
+ }, lt = V.createContext(null), Te = () => V.useContext(lt), Kt = (e) => {
64
+ const { children: s, ...t } = e;
65
+ return V.createElement(lt.Provider, { value: t }, s);
66
+ };
67
+ var nt = (e, s, t, a = !0) => {
68
+ const l = {
69
+ defaultValues: s._defaultValues
70
+ };
71
+ for (const u in e)
72
+ Object.defineProperty(l, u, {
73
+ get: () => {
74
+ const d = u;
75
+ return s._proxyFormState[d] !== j.all && (s._proxyFormState[d] = !a || j.all), t && (t[d] = !0), e[d];
76
+ }
77
+ });
78
+ return l;
79
+ };
80
+ function kt(e) {
81
+ const s = Te(), { control: t = s.control, disabled: a, name: l, exact: u } = e || {}, [d, g] = V.useState(t._formState), F = V.useRef({
82
+ isDirty: !1,
83
+ isLoading: !1,
84
+ dirtyFields: !1,
85
+ touchedFields: !1,
86
+ validatingFields: !1,
87
+ isValidating: !1,
88
+ isValid: !1,
89
+ errors: !1
90
+ }), T = V.useRef(l);
91
+ return T.current = l, V.useEffect(() => t._subscribe({
92
+ name: T.current,
93
+ formState: F.current,
94
+ exact: u,
95
+ callback: (A) => {
96
+ !a && g({
97
+ ...t._formState,
98
+ ...A
99
+ });
100
+ }
101
+ }), [t, a, u]), V.useEffect(() => {
102
+ F.current.isValid && t._setValid(!0);
103
+ }, [t]), V.useMemo(() => nt(d, t, F.current, !1), [d, t]);
104
+ }
105
+ var J = (e) => typeof e == "string", ut = (e, s, t, a, l) => J(e) ? (a && s.watch.add(e), c(t, e, l)) : Array.isArray(e) ? e.map((u) => (a && s.watch.add(u), c(t, u))) : (a && (s.watchAll = !0), t);
106
+ function Et(e) {
107
+ const s = Te(), { control: t = s.control, name: a, defaultValue: l, disabled: u, exact: d } = e || {}, g = V.useRef(a), F = V.useRef(l);
108
+ g.current = a, V.useEffect(() => t._subscribe({
109
+ name: g.current,
110
+ formState: {
111
+ values: !0
112
+ },
113
+ exact: d,
114
+ callback: (D) => !u && A(ut(g.current, t._names, D.values || t._formValues, !1, F.current))
115
+ }), [t, u, d]);
116
+ const [T, A] = V.useState(t._getWatch(a, l));
117
+ return V.useEffect(() => t._removeUnmounted()), T;
118
+ }
119
+ function jt(e) {
120
+ const s = Te(), { name: t, disabled: a, control: l = s.control, shouldUnregister: u } = e, d = it(l._names.array, t), g = Et({
121
+ control: l,
122
+ name: t,
123
+ defaultValue: c(l._formValues, t, c(l._defaultValues, t, e.defaultValue)),
124
+ exact: !0
125
+ }), F = kt({
126
+ control: l,
127
+ name: t,
128
+ exact: !0
129
+ }), T = V.useRef(e), A = V.useRef(l.register(t, {
130
+ ...e.rules,
131
+ value: g,
132
+ ...p(e.disabled) ? { disabled: e.disabled } : {}
133
+ })), D = V.useMemo(() => Object.defineProperties({}, {
134
+ invalid: {
135
+ enumerable: !0,
136
+ get: () => !!c(F.errors, t)
137
+ },
138
+ isDirty: {
139
+ enumerable: !0,
140
+ get: () => !!c(F.dirtyFields, t)
141
+ },
142
+ isTouched: {
143
+ enumerable: !0,
144
+ get: () => !!c(F.touchedFields, t)
145
+ },
146
+ isValidating: {
147
+ enumerable: !0,
148
+ get: () => !!c(F.validatingFields, t)
149
+ },
150
+ error: {
151
+ enumerable: !0,
152
+ get: () => c(F.errors, t)
153
+ }
154
+ }), [F, t]), _ = V.useCallback((B) => A.current.onChange({
155
+ target: {
156
+ value: st(B),
157
+ name: t
158
+ },
159
+ type: he.CHANGE
160
+ }), [t]), te = V.useCallback(() => A.current.onBlur({
161
+ target: {
162
+ value: c(l._formValues, t),
163
+ name: t
164
+ },
165
+ type: he.BLUR
166
+ }), [t, l._formValues]), $ = V.useCallback((B) => {
167
+ const N = c(l._fields, t);
168
+ N && B && (N._f.ref = {
169
+ focus: () => B.focus(),
170
+ select: () => B.select(),
171
+ setCustomValidity: (v) => B.setCustomValidity(v),
172
+ reportValidity: () => B.reportValidity()
173
+ });
174
+ }, [l._fields, t]), R = V.useMemo(() => ({
175
+ name: t,
176
+ value: g,
177
+ ...p(a) || F.disabled ? { disabled: F.disabled || a } : {},
178
+ onChange: _,
179
+ onBlur: te,
180
+ ref: $
181
+ }), [t, a, F.disabled, _, te, $, g]);
182
+ return V.useEffect(() => {
183
+ const B = l._options.shouldUnregister || u;
184
+ l.register(t, {
185
+ ...T.current.rules,
186
+ ...p(T.current.disabled) ? { disabled: T.current.disabled } : {}
187
+ });
188
+ const N = (v, K) => {
189
+ const W = c(l._fields, v);
190
+ W && W._f && (W._f.mount = K);
191
+ };
192
+ if (N(t, !0), B) {
193
+ const v = U(c(l._options.defaultValues, t));
194
+ w(l._defaultValues, t, v), k(c(l._formValues, t)) && w(l._formValues, t, v);
195
+ }
196
+ return !d && l.register(t), () => {
197
+ (d ? B && !l._state.action : B) ? l.unregister(t) : N(t, !1);
198
+ };
199
+ }, [t, l, d, u]), V.useEffect(() => {
200
+ l._setDisabledField({
201
+ disabled: a,
202
+ name: t
203
+ });
204
+ }, [a, t, l]), V.useMemo(() => ({
205
+ field: R,
206
+ formState: F,
207
+ fieldState: D
208
+ }), [R, F, D]);
209
+ }
210
+ var Ct = (e, s, t, a, l) => s ? {
211
+ ...t[e],
212
+ types: {
213
+ ...t[e] && t[e].types ? t[e].types : {},
214
+ [a]: l || !0
215
+ }
216
+ } : {}, fe = (e) => Array.isArray(e) ? e : [e], Ke = () => {
217
+ let e = [];
218
+ return {
219
+ get observers() {
220
+ return e;
221
+ },
222
+ next: (l) => {
223
+ for (const u of e)
224
+ u.next && u.next(l);
225
+ },
226
+ subscribe: (l) => (e.push(l), {
227
+ unsubscribe: () => {
228
+ e = e.filter((u) => u !== l);
229
+ }
230
+ }),
231
+ unsubscribe: () => {
232
+ e = [];
233
+ }
234
+ };
235
+ }, ke = (e) => I(e) || !rt(e);
236
+ function ee(e, s) {
237
+ if (ke(e) || ke(s))
238
+ return e === s;
239
+ if (se(e) && se(s))
240
+ return e.getTime() === s.getTime();
241
+ const t = Object.keys(e), a = Object.keys(s);
242
+ if (t.length !== a.length)
243
+ return !1;
244
+ for (const l of t) {
245
+ const u = e[l];
246
+ if (!a.includes(l))
247
+ return !1;
248
+ if (l !== "ref") {
249
+ const d = s[l];
250
+ if (se(u) && se(d) || E(u) && E(d) || Array.isArray(u) && Array.isArray(d) ? !ee(u, d) : u !== d)
251
+ return !1;
252
+ }
253
+ }
254
+ return !0;
255
+ }
256
+ var P = (e) => E(e) && !Object.keys(e).length, Le = (e) => e.type === "file", z = (e) => typeof e == "function", ve = (e) => {
257
+ if (!Ee)
258
+ return !1;
259
+ const s = e ? e.ownerDocument : 0;
260
+ return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
261
+ }, ot = (e) => e.type === "select-multiple", Oe = (e) => e.type === "radio", Tt = (e) => Oe(e) || de(e), Se = (e) => ve(e) && e.isConnected;
262
+ function Lt(e, s) {
263
+ const t = s.slice(0, -1).length;
264
+ let a = 0;
265
+ for (; a < t; )
266
+ e = k(e) ? a++ : e[s[a++]];
267
+ return e;
268
+ }
269
+ function Ot(e) {
270
+ for (const s in e)
271
+ if (e.hasOwnProperty(s) && !k(e[s]))
272
+ return !1;
273
+ return !0;
274
+ }
275
+ function L(e, s) {
276
+ const t = Array.isArray(s) ? s : Ce(s) ? [s] : at(s), a = t.length === 1 ? e : Lt(e, t), l = t.length - 1, u = t[l];
277
+ return a && delete a[u], l !== 0 && (E(a) && P(a) || Array.isArray(a) && Ot(a)) && L(e, t.slice(0, -1)), e;
278
+ }
279
+ var ft = (e) => {
280
+ for (const s in e)
281
+ if (z(e[s]))
282
+ return !0;
283
+ return !1;
284
+ };
285
+ function _e(e, s = {}) {
286
+ const t = Array.isArray(e);
287
+ if (E(e) || t)
288
+ for (const a in e)
289
+ Array.isArray(e[a]) || E(e[a]) && !ft(e[a]) ? (s[a] = Array.isArray(e[a]) ? [] : {}, _e(e[a], s[a])) : I(e[a]) || (s[a] = !0);
290
+ return s;
291
+ }
292
+ function ct(e, s, t) {
293
+ const a = Array.isArray(e);
294
+ if (E(e) || a)
295
+ for (const l in e)
296
+ Array.isArray(e[l]) || E(e[l]) && !ft(e[l]) ? k(s) || ke(t[l]) ? t[l] = Array.isArray(e[l]) ? _e(e[l], []) : { ..._e(e[l]) } : ct(e[l], I(s) ? {} : s[l], t[l]) : t[l] = !ee(e[l], s[l]);
297
+ return t;
298
+ }
299
+ var ue = (e, s) => ct(e, s, _e(s));
300
+ const je = {
301
+ value: !1,
302
+ isValid: !1
303
+ }, ze = { value: !0, isValid: !0 };
304
+ var dt = (e) => {
305
+ if (Array.isArray(e)) {
306
+ if (e.length > 1) {
307
+ const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
308
+ return { value: s, isValid: !!s.length };
309
+ }
310
+ return e[0].checked && !e[0].disabled ? (
311
+ // @ts-expect-error expected to work in the browser
312
+ e[0].attributes && !k(e[0].attributes.value) ? k(e[0].value) || e[0].value === "" ? ze : { value: e[0].value, isValid: !0 } : ze
313
+ ) : je;
314
+ }
315
+ return je;
316
+ }, yt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: a }) => k(e) ? e : s ? e === "" ? NaN : e && +e : t && J(e) ? new Date(e) : a ? a(e) : e;
317
+ const Ge = {
318
+ isValid: !1,
319
+ value: null
320
+ };
321
+ var gt = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
322
+ isValid: !0,
323
+ value: t.value
324
+ } : s, Ge) : Ge;
325
+ function Ye(e) {
326
+ const s = e.ref;
327
+ return Le(s) ? s.files : Oe(s) ? gt(e.refs).value : ot(s) ? [...s.selectedOptions].map(({ value: t }) => t) : de(s) ? dt(e.refs).value : yt(k(s.value) ? e.ref.value : s.value, e);
328
+ }
329
+ var Rt = (e, s, t, a) => {
330
+ const l = {};
331
+ for (const u of e) {
332
+ const d = c(s, u);
333
+ d && w(l, u, d._f);
334
+ }
335
+ return {
336
+ criteriaMode: t,
337
+ names: [...e],
338
+ fields: l,
339
+ shouldUseNativeValidation: a
340
+ };
341
+ }, be = (e) => e instanceof RegExp, oe = (e) => k(e) ? e : be(e) ? e.source : E(e) ? be(e.value) ? e.value.source : e.value : e, Je = (e) => ({
342
+ isOnSubmit: !e || e === j.onSubmit,
343
+ isOnBlur: e === j.onBlur,
344
+ isOnChange: e === j.onChange,
345
+ isOnAll: e === j.all,
346
+ isOnTouch: e === j.onTouched
347
+ });
348
+ const Qe = "AsyncFunction";
349
+ var Ut = (e) => !!e && !!e.validate && !!(z(e.validate) && e.validate.constructor.name === Qe || E(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === Qe)), Mt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), Xe = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((a) => e.startsWith(a) && /^\.\w+/.test(e.slice(a.length))));
350
+ const ce = (e, s, t, a) => {
351
+ for (const l of t || Object.keys(e)) {
352
+ const u = c(e, l);
353
+ if (u) {
354
+ const { _f: d, ...g } = u;
355
+ if (d) {
356
+ if (d.refs && d.refs[0] && s(d.refs[0], l) && !a)
357
+ return !0;
358
+ if (d.ref && s(d.ref, d.name) && !a)
359
+ return !0;
360
+ if (ce(g, s))
361
+ break;
362
+ } else if (E(g) && ce(g, s))
363
+ break;
364
+ }
365
+ }
366
+ };
367
+ function Ze(e, s, t) {
368
+ const a = c(e, t);
369
+ if (a || Ce(t))
370
+ return {
371
+ error: a,
372
+ name: t
373
+ };
374
+ const l = t.split(".");
375
+ for (; l.length; ) {
376
+ const u = l.join("."), d = c(s, u), g = c(e, u);
377
+ if (d && !Array.isArray(d) && t !== u)
378
+ return { name: t };
379
+ if (g && g.type)
380
+ return {
381
+ name: u,
382
+ error: g
383
+ };
384
+ l.pop();
385
+ }
386
+ return {
387
+ name: t
388
+ };
389
+ }
390
+ var Bt = (e, s, t, a) => {
391
+ t(e);
392
+ const { name: l, ...u } = e;
393
+ return P(u) || Object.keys(u).length >= Object.keys(s).length || Object.keys(u).find((d) => s[d] === (!a || j.all));
394
+ }, Nt = (e, s, t) => !e || !s || e === s || fe(e).some((a) => a && (t ? a === s : a.startsWith(s) || s.startsWith(a))), Pt = (e, s, t, a, l) => l.isOnAll ? !1 : !t && l.isOnTouch ? !(s || e) : (t ? a.isOnBlur : l.isOnBlur) ? !e : (t ? a.isOnChange : l.isOnChange) ? e : !0, It = (e, s) => !Ve(c(e, s)).length && L(e, s), qt = (e, s, t) => {
395
+ const a = fe(c(e, t));
396
+ return w(a, "root", s[t]), w(e, t, a), e;
397
+ }, ge = (e) => J(e);
398
+ function et(e, s, t = "validate") {
399
+ if (ge(e) || Array.isArray(e) && e.every(ge) || p(e) && !e)
400
+ return {
401
+ type: t,
402
+ message: ge(e) ? e : "",
403
+ ref: s
404
+ };
405
+ }
406
+ var ie = (e) => E(e) && !be(e) ? e : {
407
+ value: e,
408
+ message: ""
409
+ }, tt = async (e, s, t, a, l, u) => {
410
+ const { ref: d, refs: g, required: F, maxLength: T, minLength: A, min: D, max: _, pattern: te, validate: $, name: R, valueAsNumber: B, mount: N } = e._f, v = c(t, R);
411
+ if (!N || s.has(R))
412
+ return {};
413
+ const K = g ? g[0] : d, W = (x) => {
414
+ l && K.reportValidity && (K.setCustomValidity(p(x) ? "" : x || ""), K.reportValidity());
415
+ }, O = {}, ae = Oe(d), le = de(d), Fe = ae || le, G = (B || Le(d)) && k(d.value) && k(v) || ve(d) && d.value === "" || v === "" || Array.isArray(v) && !v.length, re = Ct.bind(null, R, a, O), Q = (x, b, S, q = X.maxLength, H = X.minLength) => {
416
+ const Y = x ? b : S;
417
+ O[R] = {
418
+ type: x ? q : H,
419
+ message: Y,
420
+ ref: d,
421
+ ...re(x ? q : H, Y)
422
+ };
423
+ };
424
+ if (u ? !Array.isArray(v) || !v.length : F && (!Fe && (G || I(v)) || p(v) && !v || le && !dt(g).isValid || ae && !gt(g).isValid)) {
425
+ const { value: x, message: b } = ge(F) ? { value: !!F, message: F } : ie(F);
426
+ if (x && (O[R] = {
427
+ type: X.required,
428
+ message: b,
429
+ ref: K,
430
+ ...re(X.required, b)
431
+ }, !a))
432
+ return W(b), O;
433
+ }
434
+ if (!G && (!I(D) || !I(_))) {
435
+ let x, b;
436
+ const S = ie(_), q = ie(D);
437
+ if (!I(v) && !isNaN(v)) {
438
+ const H = d.valueAsNumber || v && +v;
439
+ I(S.value) || (x = H > S.value), I(q.value) || (b = H < q.value);
440
+ } else {
441
+ const H = d.valueAsDate || new Date(v), Y = (ye) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ye), Z = d.type == "time", ne = d.type == "week";
442
+ J(S.value) && v && (x = Z ? Y(v) > Y(S.value) : ne ? v > S.value : H > new Date(S.value)), J(q.value) && v && (b = Z ? Y(v) < Y(q.value) : ne ? v < q.value : H < new Date(q.value));
443
+ }
444
+ if ((x || b) && (Q(!!x, S.message, q.message, X.max, X.min), !a))
445
+ return W(O[R].message), O;
446
+ }
447
+ if ((T || A) && !G && (J(v) || u && Array.isArray(v))) {
448
+ const x = ie(T), b = ie(A), S = !I(x.value) && v.length > +x.value, q = !I(b.value) && v.length < +b.value;
449
+ if ((S || q) && (Q(S, x.message, b.message), !a))
450
+ return W(O[R].message), O;
451
+ }
452
+ if (te && !G && J(v)) {
453
+ const { value: x, message: b } = ie(te);
454
+ if (be(x) && !v.match(x) && (O[R] = {
455
+ type: X.pattern,
456
+ message: b,
457
+ ref: d,
458
+ ...re(X.pattern, b)
459
+ }, !a))
460
+ return W(b), O;
461
+ }
462
+ if ($) {
463
+ if (z($)) {
464
+ const x = await $(v, t), b = et(x, K);
465
+ if (b && (O[R] = {
466
+ ...b,
467
+ ...re(X.validate, b.message)
468
+ }, !a))
469
+ return W(b.message), O;
470
+ } else if (E($)) {
471
+ let x = {};
472
+ for (const b in $) {
473
+ if (!P(x) && !a)
474
+ break;
475
+ const S = et(await $[b](v, t), K, b);
476
+ S && (x = {
477
+ ...S,
478
+ ...re(b, S.message)
479
+ }, W(S.message), a && (O[R] = x));
480
+ }
481
+ if (!P(x) && (O[R] = {
482
+ ref: K,
483
+ ...x
484
+ }, !a))
485
+ return O;
486
+ }
487
+ }
488
+ return W(!0), O;
489
+ };
490
+ const Wt = {
491
+ mode: j.onSubmit,
492
+ reValidateMode: j.onChange,
493
+ shouldFocusError: !0
494
+ };
495
+ function pt(e = {}) {
496
+ let s = {
497
+ ...Wt,
498
+ ...e
499
+ }, t = {
500
+ submitCount: 0,
501
+ isDirty: !1,
502
+ isLoading: z(s.defaultValues),
503
+ isValidating: !1,
504
+ isSubmitted: !1,
505
+ isSubmitting: !1,
506
+ isSubmitSuccessful: !1,
507
+ isValid: !1,
508
+ touchedFields: {},
509
+ dirtyFields: {},
510
+ validatingFields: {},
511
+ errors: s.errors || {},
512
+ disabled: s.disabled || !1
513
+ };
514
+ const a = {};
515
+ let l = E(s.defaultValues) || E(s.values) ? U(s.values || s.defaultValues) || {} : {}, u = s.shouldUnregister ? {} : U(l), d = {
516
+ action: !1,
517
+ mount: !1,
518
+ watch: !1
519
+ }, g = {
520
+ mount: /* @__PURE__ */ new Set(),
521
+ disabled: /* @__PURE__ */ new Set(),
522
+ unMount: /* @__PURE__ */ new Set(),
523
+ array: /* @__PURE__ */ new Set(),
524
+ watch: /* @__PURE__ */ new Set()
525
+ }, F, T = 0;
526
+ const A = {
527
+ isDirty: !1,
528
+ dirtyFields: !1,
529
+ validatingFields: !1,
530
+ touchedFields: !1,
531
+ isValidating: !1,
532
+ isValid: !1,
533
+ errors: !1
534
+ };
535
+ let D = {
536
+ ...A
537
+ };
538
+ const _ = {
539
+ array: Ke(),
540
+ state: Ke()
541
+ }, te = Je(s.mode), $ = Je(s.reValidateMode), R = s.criteriaMode === j.all, B = (r) => (i) => {
542
+ clearTimeout(T), T = setTimeout(r, i);
543
+ }, N = async (r) => {
544
+ if (!s.disabled && (A.isValid || D.isValid || r)) {
545
+ const i = s.resolver ? P((await G()).errors) : await Q(a, !0);
546
+ i !== t.isValid && _.state.next({
547
+ isValid: i
548
+ });
549
+ }
550
+ }, v = (r, i) => {
551
+ !s.disabled && (A.isValidating || A.validatingFields || D.isValidating || D.validatingFields) && ((r || Array.from(g.mount)).forEach((n) => {
552
+ n && (i ? w(t.validatingFields, n, i) : L(t.validatingFields, n));
553
+ }), _.state.next({
554
+ validatingFields: t.validatingFields,
555
+ isValidating: !P(t.validatingFields)
556
+ }));
557
+ }, K = (r, i = [], n, y, f = !0, o = !0) => {
558
+ if (y && n && !s.disabled) {
559
+ if (d.action = !0, o && Array.isArray(c(a, r))) {
560
+ const h = n(c(a, r), y.argA, y.argB);
561
+ f && w(a, r, h);
562
+ }
563
+ if (o && Array.isArray(c(t.errors, r))) {
564
+ const h = n(c(t.errors, r), y.argA, y.argB);
565
+ f && w(t.errors, r, h), It(t.errors, r);
566
+ }
567
+ if ((A.touchedFields || D.touchedFields) && o && Array.isArray(c(t.touchedFields, r))) {
568
+ const h = n(c(t.touchedFields, r), y.argA, y.argB);
569
+ f && w(t.touchedFields, r, h);
570
+ }
571
+ (A.dirtyFields || D.dirtyFields) && (t.dirtyFields = ue(l, u)), _.state.next({
572
+ name: r,
573
+ isDirty: b(r, i),
574
+ dirtyFields: t.dirtyFields,
575
+ errors: t.errors,
576
+ isValid: t.isValid
577
+ });
578
+ } else
579
+ w(u, r, i);
580
+ }, W = (r, i) => {
581
+ w(t.errors, r, i), _.state.next({
582
+ errors: t.errors
583
+ });
584
+ }, O = (r) => {
585
+ t.errors = r, _.state.next({
586
+ errors: t.errors,
587
+ isValid: !1
588
+ });
589
+ }, ae = (r, i, n, y) => {
590
+ const f = c(a, r);
591
+ if (f) {
592
+ const o = c(u, r, k(n) ? c(l, r) : n);
593
+ k(o) || y && y.defaultChecked || i ? w(u, r, i ? o : Ye(f._f)) : H(r, o), d.mount && N();
594
+ }
595
+ }, le = (r, i, n, y, f) => {
596
+ let o = !1, h = !1;
597
+ const m = {
598
+ name: r
599
+ };
600
+ if (!s.disabled) {
601
+ if (!n || y) {
602
+ (A.isDirty || D.isDirty) && (h = t.isDirty, t.isDirty = m.isDirty = b(), o = h !== m.isDirty);
603
+ const C = ee(c(l, r), i);
604
+ h = !!c(t.dirtyFields, r), C ? L(t.dirtyFields, r) : w(t.dirtyFields, r, !0), m.dirtyFields = t.dirtyFields, o = o || (A.dirtyFields || D.dirtyFields) && h !== !C;
605
+ }
606
+ if (n) {
607
+ const C = c(t.touchedFields, r);
608
+ C || (w(t.touchedFields, r, n), m.touchedFields = t.touchedFields, o = o || (A.touchedFields || D.touchedFields) && C !== n);
609
+ }
610
+ o && f && _.state.next(m);
611
+ }
612
+ return o ? m : {};
613
+ }, Fe = (r, i, n, y) => {
614
+ const f = c(t.errors, r), o = (A.isValid || D.isValid) && p(i) && t.isValid !== i;
615
+ if (s.delayError && n ? (F = B(() => W(r, n)), F(s.delayError)) : (clearTimeout(T), F = null, n ? w(t.errors, r, n) : L(t.errors, r)), (n ? !ee(f, n) : f) || !P(y) || o) {
616
+ const h = {
617
+ ...y,
618
+ ...o && p(i) ? { isValid: i } : {},
619
+ errors: t.errors,
620
+ name: r
621
+ };
622
+ t = {
623
+ ...t,
624
+ ...h
625
+ }, _.state.next(h);
626
+ }
627
+ }, G = async (r) => {
628
+ v(r, !0);
629
+ const i = await s.resolver(u, s.context, Rt(r || g.mount, a, s.criteriaMode, s.shouldUseNativeValidation));
630
+ return v(r), i;
631
+ }, re = async (r) => {
632
+ const { errors: i } = await G(r);
633
+ if (r)
634
+ for (const n of r) {
635
+ const y = c(i, n);
636
+ y ? w(t.errors, n, y) : L(t.errors, n);
637
+ }
638
+ else
639
+ t.errors = i;
640
+ return i;
641
+ }, Q = async (r, i, n = {
642
+ valid: !0
643
+ }) => {
644
+ for (const y in r) {
645
+ const f = r[y];
646
+ if (f) {
647
+ const { _f: o, ...h } = f;
648
+ if (o) {
649
+ const m = g.array.has(o.name), C = f._f && Ut(f._f);
650
+ C && A.validatingFields && v([y], !0);
651
+ const M = await tt(f, g.disabled, u, R, s.shouldUseNativeValidation && !i, m);
652
+ if (C && A.validatingFields && v([y]), M[o.name] && (n.valid = !1, i))
653
+ break;
654
+ !i && (c(M, o.name) ? m ? qt(t.errors, M, o.name) : w(t.errors, o.name, M[o.name]) : L(t.errors, o.name));
655
+ }
656
+ !P(h) && await Q(h, i, n);
657
+ }
658
+ }
659
+ return n.valid;
660
+ }, x = () => {
661
+ for (const r of g.unMount) {
662
+ const i = c(a, r);
663
+ i && (i._f.refs ? i._f.refs.every((n) => !Se(n)) : !Se(i._f.ref)) && Ae(r);
664
+ }
665
+ g.unMount = /* @__PURE__ */ new Set();
666
+ }, b = (r, i) => !s.disabled && (r && i && w(u, r, i), !ee(Re(), l)), S = (r, i, n) => ut(r, g, {
667
+ ...d.mount ? u : k(i) ? l : J(r) ? { [r]: i } : i
668
+ }, n, i), q = (r) => Ve(c(d.mount ? u : l, r, s.shouldUnregister ? c(l, r, []) : [])), H = (r, i, n = {}) => {
669
+ const y = c(a, r);
670
+ let f = i;
671
+ if (y) {
672
+ const o = y._f;
673
+ o && (!o.disabled && w(u, r, yt(i, o)), f = ve(o.ref) && I(i) ? "" : i, ot(o.ref) ? [...o.ref.options].forEach((h) => h.selected = f.includes(h.value)) : o.refs ? de(o.ref) ? o.refs.length > 1 ? o.refs.forEach((h) => (!h.defaultChecked || !h.disabled) && (h.checked = Array.isArray(f) ? !!f.find((m) => m === h.value) : f === h.value)) : o.refs[0] && (o.refs[0].checked = !!f) : o.refs.forEach((h) => h.checked = h.value === f) : Le(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || _.state.next({
674
+ name: r,
675
+ values: U(u)
676
+ })));
677
+ }
678
+ (n.shouldDirty || n.shouldTouch) && le(r, f, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && me(r);
679
+ }, Y = (r, i, n) => {
680
+ for (const y in i) {
681
+ const f = i[y], o = `${r}.${y}`, h = c(a, o);
682
+ (g.array.has(r) || E(f) || h && !h._f) && !se(f) ? Y(o, f, n) : H(o, f, n);
683
+ }
684
+ }, Z = (r, i, n = {}) => {
685
+ const y = c(a, r), f = g.array.has(r), o = U(i);
686
+ w(u, r, o), f ? (_.array.next({
687
+ name: r,
688
+ values: U(u)
689
+ }), (A.isDirty || A.dirtyFields || D.isDirty || D.dirtyFields) && n.shouldDirty && _.state.next({
690
+ name: r,
691
+ dirtyFields: ue(l, u),
692
+ isDirty: b(r, o)
693
+ })) : y && !y._f && !I(o) ? Y(r, o, n) : H(r, o, n), Xe(r, g) && _.state.next({ ...t }), _.state.next({
694
+ name: d.mount ? r : void 0,
695
+ values: U(u)
696
+ });
697
+ }, ne = async (r) => {
698
+ d.mount = !0;
699
+ const i = r.target;
700
+ let n = i.name, y = !0;
701
+ const f = c(a, n), o = (h) => {
702
+ y = Number.isNaN(h) || se(h) && isNaN(h.getTime()) || ee(h, c(u, n, h));
703
+ };
704
+ if (f) {
705
+ let h, m;
706
+ const C = i.type ? Ye(f._f) : st(r), M = r.type === he.BLUR || r.type === he.FOCUS_OUT, At = !Mt(f._f) && !s.resolver && !c(t.errors, n) && !f._f.deps || Pt(M, c(t.touchedFields, n), t.isSubmitted, $, te), we = Xe(n, g, M);
707
+ w(u, n, C), M ? (f._f.onBlur && f._f.onBlur(r), F && F(0)) : f._f.onChange && f._f.onChange(r);
708
+ const De = le(n, C, M), xt = !P(De) || we;
709
+ if (!M && _.state.next({
710
+ name: n,
711
+ type: r.type,
712
+ values: U(u)
713
+ }), At)
714
+ return (A.isValid || D.isValid) && (s.mode === "onBlur" ? M && N() : M || N()), xt && _.state.next({ name: n, ...we ? {} : De });
715
+ if (!M && we && _.state.next({ ...t }), s.resolver) {
716
+ const { errors: He } = await G([n]);
717
+ if (o(C), y) {
718
+ const wt = Ze(t.errors, a, n), $e = Ze(He, a, wt.name || n);
719
+ h = $e.error, n = $e.name, m = P(He);
720
+ }
721
+ } else
722
+ v([n], !0), h = (await tt(f, g.disabled, u, R, s.shouldUseNativeValidation))[n], v([n]), o(C), y && (h ? m = !1 : (A.isValid || D.isValid) && (m = await Q(a, !0)));
723
+ y && (f._f.deps && me(f._f.deps), Fe(n, m, h, De));
724
+ }
725
+ }, ye = (r, i) => {
726
+ if (c(t.errors, i) && r.focus)
727
+ return r.focus(), 1;
728
+ }, me = async (r, i = {}) => {
729
+ let n, y;
730
+ const f = fe(r);
731
+ if (s.resolver) {
732
+ const o = await re(k(r) ? r : f);
733
+ n = P(o), y = r ? !f.some((h) => c(o, h)) : n;
734
+ } else r ? (y = (await Promise.all(f.map(async (o) => {
735
+ const h = c(a, o);
736
+ return await Q(h && h._f ? { [o]: h } : h);
737
+ }))).every(Boolean), !(!y && !t.isValid) && N()) : y = n = await Q(a);
738
+ return _.state.next({
739
+ ...!J(r) || (A.isValid || D.isValid) && n !== t.isValid ? {} : { name: r },
740
+ ...s.resolver || !r ? { isValid: n } : {},
741
+ errors: t.errors
742
+ }), i.shouldFocus && !y && ce(a, ye, r ? f : g.mount), y;
743
+ }, Re = (r) => {
744
+ const i = {
745
+ ...d.mount ? u : l
746
+ };
747
+ return k(r) ? i : J(r) ? c(i, r) : r.map((n) => c(i, n));
748
+ }, Ue = (r, i) => ({
749
+ invalid: !!c((i || t).errors, r),
750
+ isDirty: !!c((i || t).dirtyFields, r),
751
+ error: c((i || t).errors, r),
752
+ isValidating: !!c(t.validatingFields, r),
753
+ isTouched: !!c((i || t).touchedFields, r)
754
+ }), ht = (r) => {
755
+ r && fe(r).forEach((i) => L(t.errors, i)), _.state.next({
756
+ errors: r ? t.errors : {}
757
+ });
758
+ }, Me = (r, i, n) => {
759
+ const y = (c(a, r, { _f: {} })._f || {}).ref, f = c(t.errors, r) || {}, { ref: o, message: h, type: m, ...C } = f;
760
+ w(t.errors, r, {
761
+ ...C,
762
+ ...i,
763
+ ref: y
764
+ }), _.state.next({
765
+ name: r,
766
+ errors: t.errors,
767
+ isValid: !1
768
+ }), n && n.shouldFocus && y && y.focus && y.focus();
769
+ }, vt = (r, i) => z(r) ? _.state.subscribe({
770
+ next: (n) => r(S(void 0, i), n)
771
+ }) : S(r, i, !0), Be = (r) => _.state.subscribe({
772
+ next: (i) => {
773
+ Nt(r.name, i.name, r.exact) && Bt(i, r.formState || A, mt, r.reRenderRoot) && r.callback({
774
+ values: { ...u },
775
+ ...t,
776
+ ...i
777
+ });
778
+ }
779
+ }).unsubscribe, _t = (r) => (d.mount = !0, D = {
780
+ ...D,
781
+ ...r.formState
782
+ }, Be({
783
+ ...r,
784
+ formState: D
785
+ })), Ae = (r, i = {}) => {
786
+ for (const n of r ? fe(r) : g.mount)
787
+ g.mount.delete(n), g.array.delete(n), i.keepValue || (L(a, n), L(u, n)), !i.keepError && L(t.errors, n), !i.keepDirty && L(t.dirtyFields, n), !i.keepTouched && L(t.touchedFields, n), !i.keepIsValidating && L(t.validatingFields, n), !s.shouldUnregister && !i.keepDefaultValue && L(l, n);
788
+ _.state.next({
789
+ values: U(u)
790
+ }), _.state.next({
791
+ ...t,
792
+ ...i.keepDirty ? { isDirty: b() } : {}
793
+ }), !i.keepIsValid && N();
794
+ }, Ne = ({ disabled: r, name: i }) => {
795
+ (p(r) && d.mount || r || g.disabled.has(i)) && (r ? g.disabled.add(i) : g.disabled.delete(i));
796
+ }, xe = (r, i = {}) => {
797
+ let n = c(a, r);
798
+ const y = p(i.disabled) || p(s.disabled);
799
+ return w(a, r, {
800
+ ...n || {},
801
+ _f: {
802
+ ...n && n._f ? n._f : { ref: { name: r } },
803
+ name: r,
804
+ mount: !0,
805
+ ...i
806
+ }
807
+ }), g.mount.add(r), n ? Ne({
808
+ disabled: p(i.disabled) ? i.disabled : s.disabled,
809
+ name: r
810
+ }) : ae(r, !0, i.value), {
811
+ ...y ? { disabled: i.disabled || s.disabled } : {},
812
+ ...s.progressive ? {
813
+ required: !!i.required,
814
+ min: oe(i.min),
815
+ max: oe(i.max),
816
+ minLength: oe(i.minLength),
817
+ maxLength: oe(i.maxLength),
818
+ pattern: oe(i.pattern)
819
+ } : {},
820
+ name: r,
821
+ onChange: ne,
822
+ onBlur: ne,
823
+ ref: (f) => {
824
+ if (f) {
825
+ xe(r, i), n = c(a, r);
826
+ const o = k(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, h = Tt(o), m = n._f.refs || [];
827
+ if (h ? m.find((C) => C === o) : o === n._f.ref)
828
+ return;
829
+ w(a, r, {
830
+ _f: {
831
+ ...n._f,
832
+ ...h ? {
833
+ refs: [
834
+ ...m.filter(Se),
835
+ o,
836
+ ...Array.isArray(c(l, r)) ? [{}] : []
837
+ ],
838
+ ref: { type: o.type, name: r }
839
+ } : { ref: o }
840
+ }
841
+ }), ae(r, !1, void 0, o);
842
+ } else
843
+ n = c(a, r, {}), n._f && (n._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(it(g.array, r) && d.action) && g.unMount.add(r);
844
+ }
845
+ };
846
+ }, Pe = () => s.shouldFocusError && ce(a, ye, g.mount), bt = (r) => {
847
+ p(r) && (_.state.next({ disabled: r }), ce(a, (i, n) => {
848
+ const y = c(a, n);
849
+ y && (i.disabled = y._f.disabled || r, Array.isArray(y._f.refs) && y._f.refs.forEach((f) => {
850
+ f.disabled = y._f.disabled || r;
851
+ }));
852
+ }, 0, !1));
853
+ }, Ie = (r, i) => async (n) => {
854
+ let y;
855
+ n && (n.preventDefault && n.preventDefault(), n.persist && n.persist());
856
+ let f = U(u);
857
+ if (_.state.next({
858
+ isSubmitting: !0
859
+ }), s.resolver) {
860
+ const { errors: o, values: h } = await G();
861
+ t.errors = o, f = h;
862
+ } else
863
+ await Q(a);
864
+ if (g.disabled.size)
865
+ for (const o of g.disabled)
866
+ w(f, o, void 0);
867
+ if (L(t.errors, "root"), P(t.errors)) {
868
+ _.state.next({
869
+ errors: {}
870
+ });
871
+ try {
872
+ await r(f, n);
873
+ } catch (o) {
874
+ y = o;
875
+ }
876
+ } else
877
+ i && await i({ ...t.errors }, n), Pe(), setTimeout(Pe);
878
+ if (_.state.next({
879
+ isSubmitted: !0,
880
+ isSubmitting: !1,
881
+ isSubmitSuccessful: P(t.errors) && !y,
882
+ submitCount: t.submitCount + 1,
883
+ errors: t.errors
884
+ }), y)
885
+ throw y;
886
+ }, Vt = (r, i = {}) => {
887
+ c(a, r) && (k(i.defaultValue) ? Z(r, U(c(l, r))) : (Z(r, i.defaultValue), w(l, r, U(i.defaultValue))), i.keepTouched || L(t.touchedFields, r), i.keepDirty || (L(t.dirtyFields, r), t.isDirty = i.defaultValue ? b(r, U(c(l, r))) : b()), i.keepError || (L(t.errors, r), A.isValid && N()), _.state.next({ ...t }));
888
+ }, qe = (r, i = {}) => {
889
+ const n = r ? U(r) : l, y = U(n), f = P(r), o = f ? l : y;
890
+ if (i.keepDefaultValues || (l = n), !i.keepValues) {
891
+ if (i.keepDirtyValues) {
892
+ const h = /* @__PURE__ */ new Set([
893
+ ...g.mount,
894
+ ...Object.keys(ue(l, u))
895
+ ]);
896
+ for (const m of Array.from(h))
897
+ c(t.dirtyFields, m) ? w(o, m, c(u, m)) : Z(m, c(o, m));
898
+ } else {
899
+ if (Ee && k(r))
900
+ for (const h of g.mount) {
901
+ const m = c(a, h);
902
+ if (m && m._f) {
903
+ const C = Array.isArray(m._f.refs) ? m._f.refs[0] : m._f.ref;
904
+ if (ve(C)) {
905
+ const M = C.closest("form");
906
+ if (M) {
907
+ M.reset();
908
+ break;
909
+ }
910
+ }
911
+ }
912
+ }
913
+ for (const h of g.mount)
914
+ Z(h, c(o, h));
915
+ }
916
+ u = U(o), _.array.next({
917
+ values: { ...o }
918
+ }), _.state.next({
919
+ values: { ...o }
920
+ });
921
+ }
922
+ g = {
923
+ mount: i.keepDirtyValues ? g.mount : /* @__PURE__ */ new Set(),
924
+ unMount: /* @__PURE__ */ new Set(),
925
+ array: /* @__PURE__ */ new Set(),
926
+ disabled: /* @__PURE__ */ new Set(),
927
+ watch: /* @__PURE__ */ new Set(),
928
+ watchAll: !1,
929
+ focus: ""
930
+ }, d.mount = !A.isValid || !!i.keepIsValid || !!i.keepDirtyValues, d.watch = !!s.shouldUnregister, _.state.next({
931
+ submitCount: i.keepSubmitCount ? t.submitCount : 0,
932
+ isDirty: f ? !1 : i.keepDirty ? t.isDirty : !!(i.keepDefaultValues && !ee(r, l)),
933
+ isSubmitted: i.keepIsSubmitted ? t.isSubmitted : !1,
934
+ dirtyFields: f ? {} : i.keepDirtyValues ? i.keepDefaultValues && u ? ue(l, u) : t.dirtyFields : i.keepDefaultValues && r ? ue(l, r) : i.keepDirty ? t.dirtyFields : {},
935
+ touchedFields: i.keepTouched ? t.touchedFields : {},
936
+ errors: i.keepErrors ? t.errors : {},
937
+ isSubmitSuccessful: i.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
938
+ isSubmitting: !1
939
+ });
940
+ }, We = (r, i) => qe(z(r) ? r(u) : r, i), Ft = (r, i = {}) => {
941
+ const n = c(a, r), y = n && n._f;
942
+ if (y) {
943
+ const f = y.refs ? y.refs[0] : y.ref;
944
+ f.focus && (f.focus(), i.shouldSelect && z(f.select) && f.select());
945
+ }
946
+ }, mt = (r) => {
947
+ t = {
948
+ ...t,
949
+ ...r
950
+ };
951
+ }, pe = {
952
+ control: {
953
+ register: xe,
954
+ unregister: Ae,
955
+ getFieldState: Ue,
956
+ handleSubmit: Ie,
957
+ setError: Me,
958
+ _subscribe: Be,
959
+ _runSchema: G,
960
+ _getWatch: S,
961
+ _getDirty: b,
962
+ _setValid: N,
963
+ _setFieldArray: K,
964
+ _setDisabledField: Ne,
965
+ _setErrors: O,
966
+ _getFieldArray: q,
967
+ _reset: qe,
968
+ _resetDefaultValues: () => z(s.defaultValues) && s.defaultValues().then((r) => {
969
+ We(r, s.resetOptions), _.state.next({
970
+ isLoading: !1
971
+ });
972
+ }),
973
+ _removeUnmounted: x,
974
+ _disableForm: bt,
975
+ _subjects: _,
976
+ _proxyFormState: A,
977
+ get _fields() {
978
+ return a;
979
+ },
980
+ get _formValues() {
981
+ return u;
982
+ },
983
+ get _state() {
984
+ return d;
985
+ },
986
+ set _state(r) {
987
+ d = r;
988
+ },
989
+ get _defaultValues() {
990
+ return l;
991
+ },
992
+ get _names() {
993
+ return g;
994
+ },
995
+ set _names(r) {
996
+ g = r;
997
+ },
998
+ get _formState() {
999
+ return t;
1000
+ },
1001
+ get _options() {
1002
+ return s;
1003
+ },
1004
+ set _options(r) {
1005
+ s = {
1006
+ ...s,
1007
+ ...r
1008
+ };
1009
+ }
1010
+ },
1011
+ subscribe: _t,
1012
+ trigger: me,
1013
+ register: xe,
1014
+ handleSubmit: Ie,
1015
+ watch: vt,
1016
+ setValue: Z,
1017
+ getValues: Re,
1018
+ reset: We,
1019
+ resetField: Vt,
1020
+ clearErrors: ht,
1021
+ unregister: Ae,
1022
+ setError: Me,
1023
+ setFocus: Ft,
1024
+ getFieldState: Ue
1025
+ };
1026
+ return {
1027
+ ...pe,
1028
+ formControl: pe
1029
+ };
1030
+ }
1031
+ function zt(e = {}) {
1032
+ const s = V.useRef(void 0), t = V.useRef(void 0), [a, l] = V.useState({
1033
+ isDirty: !1,
1034
+ isValidating: !1,
1035
+ isLoading: z(e.defaultValues),
1036
+ isSubmitted: !1,
1037
+ isSubmitting: !1,
1038
+ isSubmitSuccessful: !1,
1039
+ isValid: !1,
1040
+ submitCount: 0,
1041
+ dirtyFields: {},
1042
+ touchedFields: {},
1043
+ validatingFields: {},
1044
+ errors: e.errors || {},
1045
+ disabled: e.disabled || !1,
1046
+ defaultValues: z(e.defaultValues) ? void 0 : e.defaultValues
1047
+ });
1048
+ s.current || (s.current = {
1049
+ ...e.formControl ? e.formControl : pt(e),
1050
+ formState: a
1051
+ }, e.formControl && e.defaultValues && !z(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions));
1052
+ const u = s.current.control;
1053
+ return u._options = e, V.useLayoutEffect(() => u._subscribe({
1054
+ formState: u._proxyFormState,
1055
+ callback: () => l({ ...u._formState }),
1056
+ reRenderRoot: !0
1057
+ }), [u]), V.useEffect(() => u._disableForm(e.disabled), [u, e.disabled]), V.useEffect(() => {
1058
+ if (u._proxyFormState.isDirty) {
1059
+ const d = u._getDirty();
1060
+ d !== a.isDirty && u._subjects.state.next({
1061
+ isDirty: d
1062
+ });
1063
+ }
1064
+ }, [u, a.isDirty]), V.useEffect(() => {
1065
+ e.values && !ee(e.values, t.current) ? (u._reset(e.values, u._options.resetOptions), t.current = e.values, l((d) => ({ ...d }))) : u._resetDefaultValues();
1066
+ }, [e.values, u]), V.useEffect(() => {
1067
+ e.errors && !P(e.errors) && u._setErrors(e.errors);
1068
+ }, [e.errors, u]), V.useEffect(() => {
1069
+ u._state.mount || (u._setValid(), u._state.mount = !0), u._state.watch && (u._state.watch = !1, u._subjects.state.next({ ...u._formState })), u._removeUnmounted();
1070
+ }), V.useEffect(() => {
1071
+ e.shouldUnregister && u._subjects.state.next({
1072
+ values: u._getWatch()
1073
+ });
1074
+ }, [e.shouldUnregister, u]), s.current.formState = nt(a, u), s.current;
1075
+ }
1076
+ export {
1077
+ Kt as F,
1078
+ jt as a,
1079
+ zt as u
1080
+ };