@baseplate-dev/plugin-auth 3.0.1 → 3.0.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 (188) hide show
  1. package/dist/auth/core/components/auth-definition-editor.js +1 -1
  2. package/dist/auth/core/components/auth-definition-editor.js.map +1 -1
  3. package/dist/auth/core/node.d.ts.map +1 -1
  4. package/dist/auth/core/node.js +2 -1
  5. package/dist/auth/core/node.js.map +1 -1
  6. package/dist/auth/core/schema/plugin-definition.d.ts +6 -39
  7. package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -1
  8. package/dist/auth/core/schema/roles/schema.d.ts +7 -27
  9. package/dist/auth/core/schema/roles/schema.d.ts.map +1 -1
  10. package/dist/auth/core/schema/roles/schema.js +1 -1
  11. package/dist/auth/core/schema/roles/schema.js.map +1 -1
  12. package/dist/auth0/core/components/auth0-definition-editor.js +1 -1
  13. package/dist/auth0/core/components/auth0-definition-editor.js.map +1 -1
  14. package/dist/auth0/core/schema/plugin-definition.d.ts +1 -1
  15. package/dist/auth0/core/schema/plugin-definition.d.ts.map +1 -1
  16. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +1 -1
  17. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js +1 -1
  18. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js.map +1 -1
  19. package/dist/auth0/generators/react/auth0-apollo/templates/auth-link.ts +1 -1
  20. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +1 -1
  21. package/dist/auth0/generators/react/auth0-hooks/templates/src/hooks/use-current-user.ts +3 -2
  22. package/dist/auth0/generators/react/auth0-pages/auth0-pages.generator.d.ts +1 -1
  23. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts +1 -1
  24. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js +1 -1
  25. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.js.map +1 -1
  26. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js +1 -1
  27. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.js.map +1 -1
  28. package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/templates/routes/-components/role-manager-dialog.tsx +1 -1
  29. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js +1 -1
  30. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.js.map +1 -1
  31. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js +1 -1
  32. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.js.map +1 -1
  33. package/dist/local-auth/admin/generators/admin-crud-reset-password-action/templates/routes/-components/password-reset-dialog.tsx +1 -1
  34. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +1 -1
  35. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js +1 -1
  36. package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.js.map +1 -1
  37. package/dist/local-auth/admin/schema/manage-role-action.d.ts +5 -11
  38. package/dist/local-auth/admin/schema/manage-role-action.d.ts.map +1 -1
  39. package/dist/local-auth/admin/schema/reset-password-action.d.ts +5 -11
  40. package/dist/local-auth/admin/schema/reset-password-action.d.ts.map +1 -1
  41. package/dist/local-auth/admin/schema/roles-column.d.ts +1 -10
  42. package/dist/local-auth/admin/schema/roles-column.d.ts.map +1 -1
  43. package/dist/local-auth/core/components/local-auth-definition-editor.js +1 -1
  44. package/dist/local-auth/core/components/local-auth-definition-editor.js.map +1 -1
  45. package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts +2 -2
  46. package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts.map +1 -1
  47. package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.js +2 -1
  48. package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.js.map +1 -1
  49. package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.js +12 -7
  50. package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.js.map +1 -1
  51. package/dist/local-auth/core/generators/auth-apollo/templates/session-error-link.ts +11 -9
  52. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.d.ts.map +1 -1
  53. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js +0 -1
  54. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.js.map +1 -1
  55. package/dist/local-auth/core/generators/auth-email-password/templates/module/services/user-password.service.ts +0 -1
  56. package/dist/local-auth/core/generators/auth-hooks/auth-hooks.generator.d.ts +2 -2
  57. package/dist/local-auth/core/generators/auth-hooks/generated/index.d.ts +2 -2
  58. package/dist/local-auth/core/generators/auth-hooks/generated/template-renderers.d.ts +1 -1
  59. package/dist/local-auth/core/generators/auth-hooks/generated/typed-templates.d.ts +2 -2
  60. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.js +1 -1
  61. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.js.map +1 -1
  62. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-current-user.ts +1 -1
  63. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js +1 -1
  64. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.js.map +1 -1
  65. package/dist/local-auth/core/generators/auth-hooks/templates/src/hooks/use-log-out.ts +1 -1
  66. package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts.map +1 -1
  67. package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +4 -0
  68. package/dist/local-auth/core/generators/auth-module/auth-module.generator.js.map +1 -1
  69. package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js +1 -1
  70. package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.js.map +1 -1
  71. package/dist/local-auth/core/generators/auth-module/templates/module/services/user-session.service.ts +1 -1
  72. package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +2 -2
  73. package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +3 -3
  74. package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +1 -1
  75. package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +4 -4
  76. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts +3 -11
  77. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.d.ts.map +1 -1
  78. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +2 -5
  79. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js.map +1 -1
  80. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +2 -5
  81. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts +3 -11
  82. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.d.ts.map +1 -1
  83. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js +2 -5
  84. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.js.map +1 -1
  85. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/register.tsx +2 -5
  86. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts +1 -1
  87. package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/route.d.ts.map +1 -1
  88. package/dist/local-auth/core/generators/react-auth/react-auth.generator.d.ts +1 -1
  89. package/dist/local-auth/core/generators/react-session/generated/index.d.ts +1 -1
  90. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.d.ts +3 -3
  91. package/dist/local-auth/core/generators/react-session/generated/ts-import-providers.js +2 -2
  92. package/dist/local-auth/core/generators/react-session/generated/typed-templates.js +1 -1
  93. package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +2 -2
  94. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.d.ts.map +1 -1
  95. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js +17 -1
  96. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.js.map +1 -1
  97. package/dist/local-auth/core/generators/react-session/templates/src/app/user-session-provider.tsx +18 -1
  98. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.d.ts.map +1 -1
  99. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js +8 -2
  100. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.js.map +1 -1
  101. package/dist/local-auth/core/generators/react-session/templates/src/services/user-session-client.ts +8 -2
  102. package/dist/local-auth/core/schema/plugin-definition.d.ts +3 -9
  103. package/dist/local-auth/core/schema/plugin-definition.d.ts.map +1 -1
  104. package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js +1 -1
  105. package/dist/placeholder-auth/core/components/placeholder-auth-definition-editor.js.map +1 -1
  106. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/placeholder-auth-hooks.generator.d.ts +1 -1
  107. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.d.ts.map +1 -1
  108. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.js +2 -2
  109. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.js.map +1 -1
  110. package/dist/placeholder-auth/core/generators/placeholder-auth-hooks/templates/src/hooks/use-current-user.ts +3 -2
  111. package/dist/placeholder-auth/core/generators/placeholder-auth-module/auth-module.generator.d.ts +1 -1
  112. package/dist/placeholder-auth/core/generators/placeholder-react-auth/react-auth.generator.d.ts +1 -1
  113. package/dist/placeholder-auth/core/schema/plugin-definition.d.ts +1 -1
  114. package/dist/placeholder-auth/core/schema/plugin-definition.d.ts.map +1 -1
  115. package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js → __federation_expose_auth0CoreCommon-DxPG_Wc0.js} +3 -3
  116. package/dist/web/assets/{__federation_expose_auth0CoreCommon-xk1Gj1WU.js.map → __federation_expose_auth0CoreCommon-DxPG_Wc0.js.map} +1 -1
  117. package/dist/web/assets/{__federation_expose_auth0CoreWeb-CAiUkJwE.js → __federation_expose_auth0CoreWeb-B9jV1EyN.js} +7 -7
  118. package/dist/web/assets/__federation_expose_auth0CoreWeb-B9jV1EyN.js.map +1 -0
  119. package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js → __federation_expose_authCoreCommon-Cxa_7fkO.js} +3 -3
  120. package/dist/web/assets/{__federation_expose_authCoreCommon-K21saJbW.js.map → __federation_expose_authCoreCommon-Cxa_7fkO.js.map} +1 -1
  121. package/dist/web/assets/{__federation_expose_authCoreWeb-L7mv-Kl9.js → __federation_expose_authCoreWeb-CTQI1rXb.js} +9 -9
  122. package/dist/web/assets/__federation_expose_authCoreWeb-CTQI1rXb.js.map +1 -0
  123. package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js → __federation_expose_local-authAdminCommon-C0_ovnDb.js} +2 -2
  124. package/dist/web/assets/{__federation_expose_local-authAdminCommon-BcMGRCCu.js.map → __federation_expose_local-authAdminCommon-C0_ovnDb.js.map} +1 -1
  125. package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js → __federation_expose_local-authAdminWeb-GqHU6av7.js} +2 -2
  126. package/dist/web/assets/{__federation_expose_local-authAdminWeb-DUY1rKEt.js.map → __federation_expose_local-authAdminWeb-GqHU6av7.js.map} +1 -1
  127. package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js → __federation_expose_local-authCoreCommon-PHXPCKoj.js} +3 -3
  128. package/dist/web/assets/{__federation_expose_local-authCoreCommon-B1wtgXDT.js.map → __federation_expose_local-authCoreCommon-PHXPCKoj.js.map} +1 -1
  129. package/dist/web/assets/{__federation_expose_local-authCoreWeb-CSWj3XON.js → __federation_expose_local-authCoreWeb-Dz4oU0uP.js} +7 -7
  130. package/dist/web/assets/__federation_expose_local-authCoreWeb-Dz4oU0uP.js.map +1 -0
  131. package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js} +3 -3
  132. package/dist/web/assets/{__federation_expose_placeholder-authCoreCommon-BTZdABuy.js.map → __federation_expose_placeholder-authCoreCommon-CrB_sJO_.js.map} +1 -1
  133. package/dist/web/assets/{__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js → __federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js} +7 -7
  134. package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-KJ8YuuIQ.js.map +1 -0
  135. package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js → __federation_fn_import-CVjKjdRb.js} +2 -2
  136. package/dist/web/assets/{__federation_fn_import-BVpKhyMw.js.map → __federation_fn_import-CVjKjdRb.js.map} +1 -1
  137. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/{web-gdwlRH2l.js → web-BTmJxb08.js} +11 -6
  138. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-BTmJxb08.js.map +1 -0
  139. package/dist/web/assets/__federation_shared_@baseplate-dev/{project-builder-lib-BvJ1_iif.js → project-builder-lib-FK4Jv94w.js} +620 -644
  140. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-FK4Jv94w.js.map +1 -0
  141. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js → ui-components-jZLf5m_y.js} +5 -5
  142. package/dist/web/assets/__federation_shared_@baseplate-dev/{ui-components-E30UR3cY.js.map → ui-components-jZLf5m_y.js.map} +1 -1
  143. package/dist/web/assets/__federation_shared_@baseplate-dev/{utils-Ciu7eAT9.js → utils-CAgM5SRt.js} +47 -48
  144. package/dist/web/assets/__federation_shared_@baseplate-dev/utils-CAgM5SRt.js.map +1 -0
  145. package/dist/web/assets/__federation_shared_@tanstack/{react-router-AU7vpPwr.js → react-router-DynsSbJG.js} +2541 -2240
  146. package/dist/web/assets/__federation_shared_@tanstack/react-router-DynsSbJG.js.map +1 -0
  147. package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js +12007 -0
  148. package/dist/web/assets/__federation_shared_zod-B6wbpZ4f.js.map +1 -0
  149. package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js → get-auth-plugin-definition-DqZ2Eg7c.js} +2 -2
  150. package/dist/web/assets/{get-auth-plugin-definition-CHOjVGaq.js.map → get-auth-plugin-definition-DqZ2Eg7c.js.map} +1 -1
  151. package/dist/web/assets/{index-DqPqnxYC.js → index-Dccn3WBN.js} +2 -2
  152. package/dist/web/assets/{index-DqPqnxYC.js.map → index-Dccn3WBN.js.map} +1 -1
  153. package/dist/web/assets/{index.esm-DUunUtBj.js → index.esm-DeCjXqFv.js} +2 -2
  154. package/dist/web/assets/{index.esm-DUunUtBj.js.map → index.esm-DeCjXqFv.js.map} +1 -1
  155. package/dist/web/assets/{model-merger-CI1pu411.js → model-merger-kOQ_dmiE.js} +326 -170
  156. package/dist/web/assets/model-merger-kOQ_dmiE.js.map +1 -0
  157. package/dist/web/assets/{plugin-definition-CIiMl7Zf.js → plugin-definition-CxKhFkmJ.js} +3 -3
  158. package/dist/web/assets/plugin-definition-CxKhFkmJ.js.map +1 -0
  159. package/dist/web/assets/{plugin-definition--cfUfY5Z.js → plugin-definition-DKygiFuR.js} +2 -2
  160. package/dist/web/assets/{plugin-definition--cfUfY5Z.js.map → plugin-definition-DKygiFuR.js.map} +1 -1
  161. package/dist/web/assets/{plugin-definition-BzhiPIBh.js → plugin-definition-JFxKP18O.js} +2 -2
  162. package/dist/web/assets/{plugin-definition-BzhiPIBh.js.map → plugin-definition-JFxKP18O.js.map} +1 -1
  163. package/dist/web/assets/{plugin-definition-BYzEIUL9.js → plugin-definition-qkkt1X28.js} +2 -2
  164. package/dist/web/assets/{plugin-definition-BYzEIUL9.js.map → plugin-definition-qkkt1X28.js.map} +1 -1
  165. package/dist/web/assets/{react-DW8S9iUr.js → react-DA5A88WZ.js} +2 -2
  166. package/dist/web/assets/{react-DW8S9iUr.js.map → react-DA5A88WZ.js.map} +1 -1
  167. package/dist/web/assets/registries-19UehlAo.js +1081 -0
  168. package/dist/web/assets/registries-19UehlAo.js.map +1 -0
  169. package/dist/web/assets/remoteEntry.js +10 -10
  170. package/dist/web/assets/styles-CfTjrsB-.js +59 -0
  171. package/dist/web/assets/styles-CfTjrsB-.js.map +1 -0
  172. package/package.json +15 -15
  173. package/dist/index.js.map +0 -1
  174. package/dist/web/assets/__federation_expose_auth0CoreWeb-CAiUkJwE.js.map +0 -1
  175. package/dist/web/assets/__federation_expose_authCoreWeb-L7mv-Kl9.js.map +0 -1
  176. package/dist/web/assets/__federation_expose_local-authCoreWeb-CSWj3XON.js.map +0 -1
  177. package/dist/web/assets/__federation_expose_placeholder-authCoreWeb-DXc_X2aO.js.map +0 -1
  178. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-gdwlRH2l.js.map +0 -1
  179. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-BvJ1_iif.js.map +0 -1
  180. package/dist/web/assets/__federation_shared_@baseplate-dev/utils-Ciu7eAT9.js.map +0 -1
  181. package/dist/web/assets/__federation_shared_@tanstack/react-router-AU7vpPwr.js.map +0 -1
  182. package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js +0 -4291
  183. package/dist/web/assets/__federation_shared_zod-BGUJlEOa.js.map +0 -1
  184. package/dist/web/assets/model-merger-CI1pu411.js.map +0 -1
  185. package/dist/web/assets/plugin-definition-CIiMl7Zf.js.map +0 -1
  186. package/dist/web/assets/styles-N05E1ZaS.js +0 -58
  187. package/dist/web/assets/styles-N05E1ZaS.js.map +0 -1
  188. package/dist/web-export.js.map +0 -1
@@ -0,0 +1,1081 @@
1
+ /** A special constant with type `never` */
2
+ const NEVER = Object.freeze({
3
+ status: "aborted",
4
+ });
5
+ function $constructor(name, initializer, params) {
6
+ function init(inst, def) {
7
+ if (!inst._zod) {
8
+ Object.defineProperty(inst, "_zod", {
9
+ value: {
10
+ def,
11
+ constr: _,
12
+ traits: new Set(),
13
+ },
14
+ enumerable: false,
15
+ });
16
+ }
17
+ if (inst._zod.traits.has(name)) {
18
+ return;
19
+ }
20
+ inst._zod.traits.add(name);
21
+ initializer(inst, def);
22
+ // support prototype modifications
23
+ const proto = _.prototype;
24
+ const keys = Object.keys(proto);
25
+ for (let i = 0; i < keys.length; i++) {
26
+ const k = keys[i];
27
+ if (!(k in inst)) {
28
+ inst[k] = proto[k].bind(inst);
29
+ }
30
+ }
31
+ }
32
+ // doesn't work if Parent has a constructor with arguments
33
+ const Parent = params?.Parent ?? Object;
34
+ class Definition extends Parent {
35
+ }
36
+ Object.defineProperty(Definition, "name", { value: name });
37
+ function _(def) {
38
+ var _a;
39
+ const inst = params?.Parent ? new Definition() : this;
40
+ init(inst, def);
41
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
42
+ for (const fn of inst._zod.deferred) {
43
+ fn();
44
+ }
45
+ return inst;
46
+ }
47
+ Object.defineProperty(_, "init", { value: init });
48
+ Object.defineProperty(_, Symbol.hasInstance, {
49
+ value: (inst) => {
50
+ if (params?.Parent && inst instanceof params.Parent)
51
+ return true;
52
+ return inst?._zod?.traits?.has(name);
53
+ },
54
+ });
55
+ Object.defineProperty(_, "name", { value: name });
56
+ return _;
57
+ }
58
+ ////////////////////////////// UTILITIES ///////////////////////////////////////
59
+ const $brand = Symbol("zod_brand");
60
+ class $ZodAsyncError extends Error {
61
+ constructor() {
62
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
63
+ }
64
+ }
65
+ class $ZodEncodeError extends Error {
66
+ constructor(name) {
67
+ super(`Encountered unidirectional transform during encode: ${name}`);
68
+ this.name = "ZodEncodeError";
69
+ }
70
+ }
71
+ const globalConfig = {};
72
+ function config(newConfig) {
73
+ if (newConfig)
74
+ Object.assign(globalConfig, newConfig);
75
+ return globalConfig;
76
+ }
77
+
78
+ // functions
79
+ function assertEqual(val) {
80
+ return val;
81
+ }
82
+ function assertNotEqual(val) {
83
+ return val;
84
+ }
85
+ function assertIs(_arg) { }
86
+ function assertNever(_x) {
87
+ throw new Error();
88
+ }
89
+ function assert(_) { }
90
+ function getEnumValues(entries) {
91
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
92
+ const values = Object.entries(entries)
93
+ .filter(([k, _]) => numericValues.indexOf(+k) === -1)
94
+ .map(([_, v]) => v);
95
+ return values;
96
+ }
97
+ function joinValues(array, separator = "|") {
98
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
99
+ }
100
+ function jsonStringifyReplacer(_, value) {
101
+ if (typeof value === "bigint")
102
+ return value.toString();
103
+ return value;
104
+ }
105
+ function cached(getter) {
106
+ return {
107
+ get value() {
108
+ {
109
+ const value = getter();
110
+ Object.defineProperty(this, "value", { value });
111
+ return value;
112
+ }
113
+ },
114
+ };
115
+ }
116
+ function nullish(input) {
117
+ return input === null || input === undefined;
118
+ }
119
+ function cleanRegex(source) {
120
+ const start = source.startsWith("^") ? 1 : 0;
121
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
122
+ return source.slice(start, end);
123
+ }
124
+ function floatSafeRemainder(val, step) {
125
+ const valDecCount = (val.toString().split(".")[1] || "").length;
126
+ const stepString = step.toString();
127
+ let stepDecCount = (stepString.split(".")[1] || "").length;
128
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
129
+ const match = stepString.match(/\d?e-(\d?)/);
130
+ if (match?.[1]) {
131
+ stepDecCount = Number.parseInt(match[1]);
132
+ }
133
+ }
134
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
135
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
136
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
137
+ return (valInt % stepInt) / 10 ** decCount;
138
+ }
139
+ const EVALUATING = Symbol("evaluating");
140
+ function defineLazy(object, key, getter) {
141
+ let value = undefined;
142
+ Object.defineProperty(object, key, {
143
+ get() {
144
+ if (value === EVALUATING) {
145
+ // Circular reference detected, return undefined to break the cycle
146
+ return undefined;
147
+ }
148
+ if (value === undefined) {
149
+ value = EVALUATING;
150
+ value = getter();
151
+ }
152
+ return value;
153
+ },
154
+ set(v) {
155
+ Object.defineProperty(object, key, {
156
+ value: v,
157
+ // configurable: true,
158
+ });
159
+ // object[key] = v;
160
+ },
161
+ configurable: true,
162
+ });
163
+ }
164
+ function objectClone(obj) {
165
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
166
+ }
167
+ function assignProp(target, prop, value) {
168
+ Object.defineProperty(target, prop, {
169
+ value,
170
+ writable: true,
171
+ enumerable: true,
172
+ configurable: true,
173
+ });
174
+ }
175
+ function mergeDefs(...defs) {
176
+ const mergedDescriptors = {};
177
+ for (const def of defs) {
178
+ const descriptors = Object.getOwnPropertyDescriptors(def);
179
+ Object.assign(mergedDescriptors, descriptors);
180
+ }
181
+ return Object.defineProperties({}, mergedDescriptors);
182
+ }
183
+ function cloneDef(schema) {
184
+ return mergeDefs(schema._zod.def);
185
+ }
186
+ function getElementAtPath(obj, path) {
187
+ if (!path)
188
+ return obj;
189
+ return path.reduce((acc, key) => acc?.[key], obj);
190
+ }
191
+ function promiseAllObject(promisesObj) {
192
+ const keys = Object.keys(promisesObj);
193
+ const promises = keys.map((key) => promisesObj[key]);
194
+ return Promise.all(promises).then((results) => {
195
+ const resolvedObj = {};
196
+ for (let i = 0; i < keys.length; i++) {
197
+ resolvedObj[keys[i]] = results[i];
198
+ }
199
+ return resolvedObj;
200
+ });
201
+ }
202
+ function randomString(length = 10) {
203
+ const chars = "abcdefghijklmnopqrstuvwxyz";
204
+ let str = "";
205
+ for (let i = 0; i < length; i++) {
206
+ str += chars[Math.floor(Math.random() * chars.length)];
207
+ }
208
+ return str;
209
+ }
210
+ function esc(str) {
211
+ return JSON.stringify(str);
212
+ }
213
+ function slugify(input) {
214
+ return input
215
+ .toLowerCase()
216
+ .trim()
217
+ .replace(/[^\w\s-]/g, "")
218
+ .replace(/[\s_-]+/g, "-")
219
+ .replace(/^-+|-+$/g, "");
220
+ }
221
+ const captureStackTrace = ("captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => { });
222
+ function isObject(data) {
223
+ return typeof data === "object" && data !== null && !Array.isArray(data);
224
+ }
225
+ const allowsEval = cached(() => {
226
+ // @ts-ignore
227
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
228
+ return false;
229
+ }
230
+ try {
231
+ const F = Function;
232
+ new F("");
233
+ return true;
234
+ }
235
+ catch (_) {
236
+ return false;
237
+ }
238
+ });
239
+ function isPlainObject(o) {
240
+ if (isObject(o) === false)
241
+ return false;
242
+ // modified constructor
243
+ const ctor = o.constructor;
244
+ if (ctor === undefined)
245
+ return true;
246
+ if (typeof ctor !== "function")
247
+ return true;
248
+ // modified prototype
249
+ const prot = ctor.prototype;
250
+ if (isObject(prot) === false)
251
+ return false;
252
+ // ctor doesn't have static `isPrototypeOf`
253
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
254
+ return false;
255
+ }
256
+ return true;
257
+ }
258
+ function shallowClone(o) {
259
+ if (isPlainObject(o))
260
+ return { ...o };
261
+ if (Array.isArray(o))
262
+ return [...o];
263
+ return o;
264
+ }
265
+ function numKeys(data) {
266
+ let keyCount = 0;
267
+ for (const key in data) {
268
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
269
+ keyCount++;
270
+ }
271
+ }
272
+ return keyCount;
273
+ }
274
+ const getParsedType = (data) => {
275
+ const t = typeof data;
276
+ switch (t) {
277
+ case "undefined":
278
+ return "undefined";
279
+ case "string":
280
+ return "string";
281
+ case "number":
282
+ return Number.isNaN(data) ? "nan" : "number";
283
+ case "boolean":
284
+ return "boolean";
285
+ case "function":
286
+ return "function";
287
+ case "bigint":
288
+ return "bigint";
289
+ case "symbol":
290
+ return "symbol";
291
+ case "object":
292
+ if (Array.isArray(data)) {
293
+ return "array";
294
+ }
295
+ if (data === null) {
296
+ return "null";
297
+ }
298
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
299
+ return "promise";
300
+ }
301
+ if (typeof Map !== "undefined" && data instanceof Map) {
302
+ return "map";
303
+ }
304
+ if (typeof Set !== "undefined" && data instanceof Set) {
305
+ return "set";
306
+ }
307
+ if (typeof Date !== "undefined" && data instanceof Date) {
308
+ return "date";
309
+ }
310
+ // @ts-ignore
311
+ if (typeof File !== "undefined" && data instanceof File) {
312
+ return "file";
313
+ }
314
+ return "object";
315
+ default:
316
+ throw new Error(`Unknown data type: ${t}`);
317
+ }
318
+ };
319
+ const propertyKeyTypes = new Set(["string", "number", "symbol"]);
320
+ const primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
321
+ function escapeRegex(str) {
322
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
323
+ }
324
+ // zod-specific utils
325
+ function clone(inst, def, params) {
326
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
327
+ if (!def || params?.parent)
328
+ cl._zod.parent = inst;
329
+ return cl;
330
+ }
331
+ function normalizeParams(_params) {
332
+ const params = _params;
333
+ if (!params)
334
+ return {};
335
+ if (typeof params === "string")
336
+ return { error: () => params };
337
+ if (params?.message !== undefined) {
338
+ if (params?.error !== undefined)
339
+ throw new Error("Cannot specify both `message` and `error` params");
340
+ params.error = params.message;
341
+ }
342
+ delete params.message;
343
+ if (typeof params.error === "string")
344
+ return { ...params, error: () => params.error };
345
+ return params;
346
+ }
347
+ function createTransparentProxy(getter) {
348
+ let target;
349
+ return new Proxy({}, {
350
+ get(_, prop, receiver) {
351
+ target ?? (target = getter());
352
+ return Reflect.get(target, prop, receiver);
353
+ },
354
+ set(_, prop, value, receiver) {
355
+ target ?? (target = getter());
356
+ return Reflect.set(target, prop, value, receiver);
357
+ },
358
+ has(_, prop) {
359
+ target ?? (target = getter());
360
+ return Reflect.has(target, prop);
361
+ },
362
+ deleteProperty(_, prop) {
363
+ target ?? (target = getter());
364
+ return Reflect.deleteProperty(target, prop);
365
+ },
366
+ ownKeys(_) {
367
+ target ?? (target = getter());
368
+ return Reflect.ownKeys(target);
369
+ },
370
+ getOwnPropertyDescriptor(_, prop) {
371
+ target ?? (target = getter());
372
+ return Reflect.getOwnPropertyDescriptor(target, prop);
373
+ },
374
+ defineProperty(_, prop, descriptor) {
375
+ target ?? (target = getter());
376
+ return Reflect.defineProperty(target, prop, descriptor);
377
+ },
378
+ });
379
+ }
380
+ function stringifyPrimitive(value) {
381
+ if (typeof value === "bigint")
382
+ return value.toString() + "n";
383
+ if (typeof value === "string")
384
+ return `"${value}"`;
385
+ return `${value}`;
386
+ }
387
+ function optionalKeys(shape) {
388
+ return Object.keys(shape).filter((k) => {
389
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
390
+ });
391
+ }
392
+ const NUMBER_FORMAT_RANGES = {
393
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
394
+ int32: [-2147483648, 2147483647],
395
+ uint32: [0, 4294967295],
396
+ float32: [-34028234663852886e22, 3.4028234663852886e38],
397
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
398
+ };
399
+ const BIGINT_FORMAT_RANGES = {
400
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
401
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
402
+ };
403
+ function pick(schema, mask) {
404
+ const currDef = schema._zod.def;
405
+ const def = mergeDefs(schema._zod.def, {
406
+ get shape() {
407
+ const newShape = {};
408
+ for (const key in mask) {
409
+ if (!(key in currDef.shape)) {
410
+ throw new Error(`Unrecognized key: "${key}"`);
411
+ }
412
+ if (!mask[key])
413
+ continue;
414
+ newShape[key] = currDef.shape[key];
415
+ }
416
+ assignProp(this, "shape", newShape); // self-caching
417
+ return newShape;
418
+ },
419
+ checks: [],
420
+ });
421
+ return clone(schema, def);
422
+ }
423
+ function omit(schema, mask) {
424
+ const currDef = schema._zod.def;
425
+ const def = mergeDefs(schema._zod.def, {
426
+ get shape() {
427
+ const newShape = { ...schema._zod.def.shape };
428
+ for (const key in mask) {
429
+ if (!(key in currDef.shape)) {
430
+ throw new Error(`Unrecognized key: "${key}"`);
431
+ }
432
+ if (!mask[key])
433
+ continue;
434
+ delete newShape[key];
435
+ }
436
+ assignProp(this, "shape", newShape); // self-caching
437
+ return newShape;
438
+ },
439
+ checks: [],
440
+ });
441
+ return clone(schema, def);
442
+ }
443
+ function extend(schema, shape) {
444
+ if (!isPlainObject(shape)) {
445
+ throw new Error("Invalid input to extend: expected a plain object");
446
+ }
447
+ const checks = schema._zod.def.checks;
448
+ const hasChecks = checks && checks.length > 0;
449
+ if (hasChecks) {
450
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
451
+ }
452
+ const def = mergeDefs(schema._zod.def, {
453
+ get shape() {
454
+ const _shape = { ...schema._zod.def.shape, ...shape };
455
+ assignProp(this, "shape", _shape); // self-caching
456
+ return _shape;
457
+ },
458
+ checks: [],
459
+ });
460
+ return clone(schema, def);
461
+ }
462
+ function safeExtend(schema, shape) {
463
+ if (!isPlainObject(shape)) {
464
+ throw new Error("Invalid input to safeExtend: expected a plain object");
465
+ }
466
+ const def = {
467
+ ...schema._zod.def,
468
+ get shape() {
469
+ const _shape = { ...schema._zod.def.shape, ...shape };
470
+ assignProp(this, "shape", _shape); // self-caching
471
+ return _shape;
472
+ },
473
+ checks: schema._zod.def.checks,
474
+ };
475
+ return clone(schema, def);
476
+ }
477
+ function merge(a, b) {
478
+ const def = mergeDefs(a._zod.def, {
479
+ get shape() {
480
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
481
+ assignProp(this, "shape", _shape); // self-caching
482
+ return _shape;
483
+ },
484
+ get catchall() {
485
+ return b._zod.def.catchall;
486
+ },
487
+ checks: [], // delete existing checks
488
+ });
489
+ return clone(a, def);
490
+ }
491
+ function partial(Class, schema, mask) {
492
+ const def = mergeDefs(schema._zod.def, {
493
+ get shape() {
494
+ const oldShape = schema._zod.def.shape;
495
+ const shape = { ...oldShape };
496
+ if (mask) {
497
+ for (const key in mask) {
498
+ if (!(key in oldShape)) {
499
+ throw new Error(`Unrecognized key: "${key}"`);
500
+ }
501
+ if (!mask[key])
502
+ continue;
503
+ // if (oldShape[key]!._zod.optin === "optional") continue;
504
+ shape[key] = Class
505
+ ? new Class({
506
+ type: "optional",
507
+ innerType: oldShape[key],
508
+ })
509
+ : oldShape[key];
510
+ }
511
+ }
512
+ else {
513
+ for (const key in oldShape) {
514
+ // if (oldShape[key]!._zod.optin === "optional") continue;
515
+ shape[key] = Class
516
+ ? new Class({
517
+ type: "optional",
518
+ innerType: oldShape[key],
519
+ })
520
+ : oldShape[key];
521
+ }
522
+ }
523
+ assignProp(this, "shape", shape); // self-caching
524
+ return shape;
525
+ },
526
+ checks: [],
527
+ });
528
+ return clone(schema, def);
529
+ }
530
+ function required(Class, schema, mask) {
531
+ const def = mergeDefs(schema._zod.def, {
532
+ get shape() {
533
+ const oldShape = schema._zod.def.shape;
534
+ const shape = { ...oldShape };
535
+ if (mask) {
536
+ for (const key in mask) {
537
+ if (!(key in shape)) {
538
+ throw new Error(`Unrecognized key: "${key}"`);
539
+ }
540
+ if (!mask[key])
541
+ continue;
542
+ // overwrite with non-optional
543
+ shape[key] = new Class({
544
+ type: "nonoptional",
545
+ innerType: oldShape[key],
546
+ });
547
+ }
548
+ }
549
+ else {
550
+ for (const key in oldShape) {
551
+ // overwrite with non-optional
552
+ shape[key] = new Class({
553
+ type: "nonoptional",
554
+ innerType: oldShape[key],
555
+ });
556
+ }
557
+ }
558
+ assignProp(this, "shape", shape); // self-caching
559
+ return shape;
560
+ },
561
+ checks: [],
562
+ });
563
+ return clone(schema, def);
564
+ }
565
+ // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
566
+ function aborted(x, startIndex = 0) {
567
+ if (x.aborted === true)
568
+ return true;
569
+ for (let i = startIndex; i < x.issues.length; i++) {
570
+ if (x.issues[i]?.continue !== true) {
571
+ return true;
572
+ }
573
+ }
574
+ return false;
575
+ }
576
+ function prefixIssues(path, issues) {
577
+ return issues.map((iss) => {
578
+ var _a;
579
+ (_a = iss).path ?? (_a.path = []);
580
+ iss.path.unshift(path);
581
+ return iss;
582
+ });
583
+ }
584
+ function unwrapMessage(message) {
585
+ return typeof message === "string" ? message : message?.message;
586
+ }
587
+ function finalizeIssue(iss, ctx, config) {
588
+ const full = { ...iss, path: iss.path ?? [] };
589
+ // for backwards compatibility
590
+ if (!iss.message) {
591
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ??
592
+ unwrapMessage(ctx?.error?.(iss)) ??
593
+ unwrapMessage(config.customError?.(iss)) ??
594
+ unwrapMessage(config.localeError?.(iss)) ??
595
+ "Invalid input";
596
+ full.message = message;
597
+ }
598
+ // delete (full as any).def;
599
+ delete full.inst;
600
+ delete full.continue;
601
+ if (!ctx?.reportInput) {
602
+ delete full.input;
603
+ }
604
+ return full;
605
+ }
606
+ function getSizableOrigin(input) {
607
+ if (input instanceof Set)
608
+ return "set";
609
+ if (input instanceof Map)
610
+ return "map";
611
+ // @ts-ignore
612
+ if (input instanceof File)
613
+ return "file";
614
+ return "unknown";
615
+ }
616
+ function getLengthableOrigin(input) {
617
+ if (Array.isArray(input))
618
+ return "array";
619
+ if (typeof input === "string")
620
+ return "string";
621
+ return "unknown";
622
+ }
623
+ function issue(...args) {
624
+ const [iss, input, inst] = args;
625
+ if (typeof iss === "string") {
626
+ return {
627
+ message: iss,
628
+ code: "custom",
629
+ input,
630
+ inst,
631
+ };
632
+ }
633
+ return { ...iss };
634
+ }
635
+ function cleanEnum(obj) {
636
+ return Object.entries(obj)
637
+ .filter(([k, _]) => {
638
+ // return true if NaN, meaning it's not a number, thus a string key
639
+ return Number.isNaN(Number.parseInt(k, 10));
640
+ })
641
+ .map((el) => el[1]);
642
+ }
643
+ // Codec utility functions
644
+ function base64ToUint8Array(base64) {
645
+ const binaryString = atob(base64);
646
+ const bytes = new Uint8Array(binaryString.length);
647
+ for (let i = 0; i < binaryString.length; i++) {
648
+ bytes[i] = binaryString.charCodeAt(i);
649
+ }
650
+ return bytes;
651
+ }
652
+ function uint8ArrayToBase64(bytes) {
653
+ let binaryString = "";
654
+ for (let i = 0; i < bytes.length; i++) {
655
+ binaryString += String.fromCharCode(bytes[i]);
656
+ }
657
+ return btoa(binaryString);
658
+ }
659
+ function base64urlToUint8Array(base64url) {
660
+ const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
661
+ const padding = "=".repeat((4 - (base64.length % 4)) % 4);
662
+ return base64ToUint8Array(base64 + padding);
663
+ }
664
+ function uint8ArrayToBase64url(bytes) {
665
+ return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
666
+ }
667
+ function hexToUint8Array(hex) {
668
+ const cleanHex = hex.replace(/^0x/, "");
669
+ if (cleanHex.length % 2 !== 0) {
670
+ throw new Error("Invalid hex string length");
671
+ }
672
+ const bytes = new Uint8Array(cleanHex.length / 2);
673
+ for (let i = 0; i < cleanHex.length; i += 2) {
674
+ bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
675
+ }
676
+ return bytes;
677
+ }
678
+ function uint8ArrayToHex(bytes) {
679
+ return Array.from(bytes)
680
+ .map((b) => b.toString(16).padStart(2, "0"))
681
+ .join("");
682
+ }
683
+ // instanceof
684
+ class Class {
685
+ constructor(..._args) { }
686
+ }
687
+
688
+ const util = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
689
+ __proto__: null,
690
+ BIGINT_FORMAT_RANGES,
691
+ Class,
692
+ NUMBER_FORMAT_RANGES,
693
+ aborted,
694
+ allowsEval,
695
+ assert,
696
+ assertEqual,
697
+ assertIs,
698
+ assertNever,
699
+ assertNotEqual,
700
+ assignProp,
701
+ base64ToUint8Array,
702
+ base64urlToUint8Array,
703
+ cached,
704
+ captureStackTrace,
705
+ cleanEnum,
706
+ cleanRegex,
707
+ clone,
708
+ cloneDef,
709
+ createTransparentProxy,
710
+ defineLazy,
711
+ esc,
712
+ escapeRegex,
713
+ extend,
714
+ finalizeIssue,
715
+ floatSafeRemainder,
716
+ getElementAtPath,
717
+ getEnumValues,
718
+ getLengthableOrigin,
719
+ getParsedType,
720
+ getSizableOrigin,
721
+ hexToUint8Array,
722
+ isObject,
723
+ isPlainObject,
724
+ issue,
725
+ joinValues,
726
+ jsonStringifyReplacer,
727
+ merge,
728
+ mergeDefs,
729
+ normalizeParams,
730
+ nullish,
731
+ numKeys,
732
+ objectClone,
733
+ omit,
734
+ optionalKeys,
735
+ partial,
736
+ pick,
737
+ prefixIssues,
738
+ primitiveTypes,
739
+ promiseAllObject,
740
+ propertyKeyTypes,
741
+ randomString,
742
+ required,
743
+ safeExtend,
744
+ shallowClone,
745
+ slugify,
746
+ stringifyPrimitive,
747
+ uint8ArrayToBase64,
748
+ uint8ArrayToBase64url,
749
+ uint8ArrayToHex,
750
+ unwrapMessage
751
+ }, Symbol.toStringTag, { value: 'Module' }));
752
+
753
+ const initializer = (inst, def) => {
754
+ inst.name = "$ZodError";
755
+ Object.defineProperty(inst, "_zod", {
756
+ value: inst._zod,
757
+ enumerable: false,
758
+ });
759
+ Object.defineProperty(inst, "issues", {
760
+ value: def,
761
+ enumerable: false,
762
+ });
763
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
764
+ Object.defineProperty(inst, "toString", {
765
+ value: () => inst.message,
766
+ enumerable: false,
767
+ });
768
+ };
769
+ const $ZodError = $constructor("$ZodError", initializer);
770
+ const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
771
+ function flattenError(error, mapper = (issue) => issue.message) {
772
+ const fieldErrors = {};
773
+ const formErrors = [];
774
+ for (const sub of error.issues) {
775
+ if (sub.path.length > 0) {
776
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
777
+ fieldErrors[sub.path[0]].push(mapper(sub));
778
+ }
779
+ else {
780
+ formErrors.push(mapper(sub));
781
+ }
782
+ }
783
+ return { formErrors, fieldErrors };
784
+ }
785
+ function formatError(error, mapper = (issue) => issue.message) {
786
+ const fieldErrors = { _errors: [] };
787
+ const processError = (error) => {
788
+ for (const issue of error.issues) {
789
+ if (issue.code === "invalid_union" && issue.errors.length) {
790
+ issue.errors.map((issues) => processError({ issues }));
791
+ }
792
+ else if (issue.code === "invalid_key") {
793
+ processError({ issues: issue.issues });
794
+ }
795
+ else if (issue.code === "invalid_element") {
796
+ processError({ issues: issue.issues });
797
+ }
798
+ else if (issue.path.length === 0) {
799
+ fieldErrors._errors.push(mapper(issue));
800
+ }
801
+ else {
802
+ let curr = fieldErrors;
803
+ let i = 0;
804
+ while (i < issue.path.length) {
805
+ const el = issue.path[i];
806
+ const terminal = i === issue.path.length - 1;
807
+ if (!terminal) {
808
+ curr[el] = curr[el] || { _errors: [] };
809
+ }
810
+ else {
811
+ curr[el] = curr[el] || { _errors: [] };
812
+ curr[el]._errors.push(mapper(issue));
813
+ }
814
+ curr = curr[el];
815
+ i++;
816
+ }
817
+ }
818
+ }
819
+ };
820
+ processError(error);
821
+ return fieldErrors;
822
+ }
823
+ function treeifyError(error, mapper = (issue) => issue.message) {
824
+ const result = { errors: [] };
825
+ const processError = (error, path = []) => {
826
+ var _a, _b;
827
+ for (const issue of error.issues) {
828
+ if (issue.code === "invalid_union" && issue.errors.length) {
829
+ // regular union error
830
+ issue.errors.map((issues) => processError({ issues }, issue.path));
831
+ }
832
+ else if (issue.code === "invalid_key") {
833
+ processError({ issues: issue.issues }, issue.path);
834
+ }
835
+ else if (issue.code === "invalid_element") {
836
+ processError({ issues: issue.issues }, issue.path);
837
+ }
838
+ else {
839
+ const fullpath = [...path, ...issue.path];
840
+ if (fullpath.length === 0) {
841
+ result.errors.push(mapper(issue));
842
+ continue;
843
+ }
844
+ let curr = result;
845
+ let i = 0;
846
+ while (i < fullpath.length) {
847
+ const el = fullpath[i];
848
+ const terminal = i === fullpath.length - 1;
849
+ if (typeof el === "string") {
850
+ curr.properties ?? (curr.properties = {});
851
+ (_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
852
+ curr = curr.properties[el];
853
+ }
854
+ else {
855
+ curr.items ?? (curr.items = []);
856
+ (_b = curr.items)[el] ?? (_b[el] = { errors: [] });
857
+ curr = curr.items[el];
858
+ }
859
+ if (terminal) {
860
+ curr.errors.push(mapper(issue));
861
+ }
862
+ i++;
863
+ }
864
+ }
865
+ }
866
+ };
867
+ processError(error);
868
+ return result;
869
+ }
870
+ /** Format a ZodError as a human-readable string in the following form.
871
+ *
872
+ * From
873
+ *
874
+ * ```ts
875
+ * ZodError {
876
+ * issues: [
877
+ * {
878
+ * expected: 'string',
879
+ * code: 'invalid_type',
880
+ * path: [ 'username' ],
881
+ * message: 'Invalid input: expected string'
882
+ * },
883
+ * {
884
+ * expected: 'number',
885
+ * code: 'invalid_type',
886
+ * path: [ 'favoriteNumbers', 1 ],
887
+ * message: 'Invalid input: expected number'
888
+ * }
889
+ * ];
890
+ * }
891
+ * ```
892
+ *
893
+ * to
894
+ *
895
+ * ```
896
+ * username
897
+ * ✖ Expected number, received string at "username
898
+ * favoriteNumbers[0]
899
+ * ✖ Invalid input: expected number
900
+ * ```
901
+ */
902
+ function toDotPath(_path) {
903
+ const segs = [];
904
+ const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
905
+ for (const seg of path) {
906
+ if (typeof seg === "number")
907
+ segs.push(`[${seg}]`);
908
+ else if (typeof seg === "symbol")
909
+ segs.push(`[${JSON.stringify(String(seg))}]`);
910
+ else if (/[^\w$]/.test(seg))
911
+ segs.push(`[${JSON.stringify(seg)}]`);
912
+ else {
913
+ if (segs.length)
914
+ segs.push(".");
915
+ segs.push(seg);
916
+ }
917
+ }
918
+ return segs.join("");
919
+ }
920
+ function prettifyError(error) {
921
+ const lines = [];
922
+ // sort by path length
923
+ const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
924
+ // Process each issue
925
+ for (const issue of issues) {
926
+ lines.push(`✖ ${issue.message}`);
927
+ if (issue.path?.length)
928
+ lines.push(` → at ${toDotPath(issue.path)}`);
929
+ }
930
+ // Convert Map to formatted string
931
+ return lines.join("\n");
932
+ }
933
+
934
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
935
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
936
+ const result = schema._zod.run({ value, issues: [] }, ctx);
937
+ if (result instanceof Promise) {
938
+ throw new $ZodAsyncError();
939
+ }
940
+ if (result.issues.length) {
941
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
942
+ captureStackTrace(e, _params?.callee);
943
+ throw e;
944
+ }
945
+ return result.value;
946
+ };
947
+ const parse = /* @__PURE__*/ _parse($ZodRealError);
948
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
949
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
950
+ let result = schema._zod.run({ value, issues: [] }, ctx);
951
+ if (result instanceof Promise)
952
+ result = await result;
953
+ if (result.issues.length) {
954
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
955
+ captureStackTrace(e, params?.callee);
956
+ throw e;
957
+ }
958
+ return result.value;
959
+ };
960
+ const parseAsync = /* @__PURE__*/ _parseAsync($ZodRealError);
961
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
962
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
963
+ const result = schema._zod.run({ value, issues: [] }, ctx);
964
+ if (result instanceof Promise) {
965
+ throw new $ZodAsyncError();
966
+ }
967
+ return result.issues.length
968
+ ? {
969
+ success: false,
970
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
971
+ }
972
+ : { success: true, data: result.value };
973
+ };
974
+ const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
975
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
976
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
977
+ let result = schema._zod.run({ value, issues: [] }, ctx);
978
+ if (result instanceof Promise)
979
+ result = await result;
980
+ return result.issues.length
981
+ ? {
982
+ success: false,
983
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))),
984
+ }
985
+ : { success: true, data: result.value };
986
+ };
987
+ const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
988
+ const _encode = (_Err) => (schema, value, _ctx) => {
989
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
990
+ return _parse(_Err)(schema, value, ctx);
991
+ };
992
+ const encode = /* @__PURE__*/ _encode($ZodRealError);
993
+ const _decode = (_Err) => (schema, value, _ctx) => {
994
+ return _parse(_Err)(schema, value, _ctx);
995
+ };
996
+ const decode = /* @__PURE__*/ _decode($ZodRealError);
997
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
998
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
999
+ return _parseAsync(_Err)(schema, value, ctx);
1000
+ };
1001
+ const encodeAsync = /* @__PURE__*/ _encodeAsync($ZodRealError);
1002
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
1003
+ return _parseAsync(_Err)(schema, value, _ctx);
1004
+ };
1005
+ const decodeAsync = /* @__PURE__*/ _decodeAsync($ZodRealError);
1006
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
1007
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1008
+ return _safeParse(_Err)(schema, value, ctx);
1009
+ };
1010
+ const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
1011
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
1012
+ return _safeParse(_Err)(schema, value, _ctx);
1013
+ };
1014
+ const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
1015
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
1016
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
1017
+ return _safeParseAsync(_Err)(schema, value, ctx);
1018
+ };
1019
+ const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
1020
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
1021
+ return _safeParseAsync(_Err)(schema, value, _ctx);
1022
+ };
1023
+ const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
1024
+
1025
+ var _a;
1026
+ const $output = Symbol("ZodOutput");
1027
+ const $input = Symbol("ZodInput");
1028
+ class $ZodRegistry {
1029
+ constructor() {
1030
+ this._map = new WeakMap();
1031
+ this._idmap = new Map();
1032
+ }
1033
+ add(schema, ..._meta) {
1034
+ const meta = _meta[0];
1035
+ this._map.set(schema, meta);
1036
+ if (meta && typeof meta === "object" && "id" in meta) {
1037
+ if (this._idmap.has(meta.id)) {
1038
+ throw new Error(`ID ${meta.id} already exists in the registry`);
1039
+ }
1040
+ this._idmap.set(meta.id, schema);
1041
+ }
1042
+ return this;
1043
+ }
1044
+ clear() {
1045
+ this._map = new WeakMap();
1046
+ this._idmap = new Map();
1047
+ return this;
1048
+ }
1049
+ remove(schema) {
1050
+ const meta = this._map.get(schema);
1051
+ if (meta && typeof meta === "object" && "id" in meta) {
1052
+ this._idmap.delete(meta.id);
1053
+ }
1054
+ this._map.delete(schema);
1055
+ return this;
1056
+ }
1057
+ get(schema) {
1058
+ // return this._map.get(schema) as any;
1059
+ // inherit metadata
1060
+ const p = schema._zod.parent;
1061
+ if (p) {
1062
+ const pm = { ...(this.get(p) ?? {}) };
1063
+ delete pm.id; // do not inherit id
1064
+ const f = { ...pm, ...this._map.get(schema) };
1065
+ return Object.keys(f).length ? f : undefined;
1066
+ }
1067
+ return this._map.get(schema);
1068
+ }
1069
+ has(schema) {
1070
+ return this._map.has(schema);
1071
+ }
1072
+ }
1073
+ // registries
1074
+ function registry() {
1075
+ return new $ZodRegistry();
1076
+ }
1077
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
1078
+ const globalRegistry = globalThis.__zod_globalRegistry;
1079
+
1080
+ export { $constructor as $, optionalKeys as A, BIGINT_FORMAT_RANGES as B, issue as C, joinValues as D, stringifyPrimitive as E, normalizeParams as F, slugify as G, shallowClone as H, globalRegistry as I, $ZodRegistry as J, $ZodError as K, $ZodRealError as L, $brand as M, NUMBER_FORMAT_RANGES as N, $input as O, $output as P, NEVER as Q, _decodeAsync as R, _encode as S, _encodeAsync as T, _parse as U, _parseAsync as V, _safeDecode as W, _safeDecodeAsync as X, _safeEncode as Y, _safeEncodeAsync as Z, _decode as _, getLengthableOrigin as a, _safeParse as a0, _safeParseAsync as a1, clone as a2, decode as a3, decodeAsync as a4, encode as a5, encodeAsync as a6, flattenError as a7, formatError as a8, prettifyError as a9, registry as aa, safeDecode as ab, safeDecodeAsync as ac, safeEncode as ad, safeEncodeAsync as ae, toDotPath as af, treeifyError as ag, util as ah, jsonStringifyReplacer as ai, mergeDefs as aj, extend as ak, safeExtend as al, merge as am, pick as an, omit as ao, partial as ap, required as aq, $ZodAsyncError as b, safeParseAsync as c, aborted as d, escapeRegex as e, floatSafeRemainder as f, getSizableOrigin as g, defineLazy as h, cached as i, isObject as j, globalConfig as k, allowsEval as l, esc as m, nullish as n, cleanRegex as o, prefixIssues as p, isPlainObject as q, finalizeIssue as r, safeParse as s, config as t, getEnumValues as u, propertyKeyTypes as v, $ZodEncodeError as w, primitiveTypes as x, parse as y, parseAsync as z };
1081
+ //# sourceMappingURL=registries-19UehlAo.js.map