zudoku 0.25.2 → 0.26.0

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