@scbt-ecom/ui 0.23.0 → 0.24.1

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