zudoku 0.46.1 → 0.46.3

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