@xenosystem/agent-cli 0.5.180 → 0.5.181

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 (865) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +2455 -2453
  3. package/dist/metafile-esm.json +1 -1
  4. package/dist/sdk-build-identity.json +12 -12
  5. package/ownership/ownership-policy.json +99 -20
  6. package/package.json +94 -94
  7. package/node_modules/@xeno-corporation/account/LICENSE +0 -39
  8. package/node_modules/@xeno-corporation/account/README.md +0 -266
  9. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs +0 -60
  10. package/node_modules/@xeno-corporation/account/dist/chunk-FELZILY4.mjs.map +0 -1
  11. package/node_modules/@xeno-corporation/account/dist/client-CVtf6u7F.d.mts +0 -2346
  12. package/node_modules/@xeno-corporation/account/dist/client-CVtf6u7F.d.ts +0 -2346
  13. package/node_modules/@xeno-corporation/account/dist/index.d.mts +0 -110
  14. package/node_modules/@xeno-corporation/account/dist/index.d.ts +0 -110
  15. package/node_modules/@xeno-corporation/account/dist/index.js +0 -4115
  16. package/node_modules/@xeno-corporation/account/dist/index.js.map +0 -1
  17. package/node_modules/@xeno-corporation/account/dist/index.mjs +0 -3967
  18. package/node_modules/@xeno-corporation/account/dist/index.mjs.map +0 -1
  19. package/node_modules/@xeno-corporation/account/dist/node.d.mts +0 -109
  20. package/node_modules/@xeno-corporation/account/dist/node.d.ts +0 -109
  21. package/node_modules/@xeno-corporation/account/dist/node.js +0 -1448
  22. package/node_modules/@xeno-corporation/account/dist/node.js.map +0 -1
  23. package/node_modules/@xeno-corporation/account/dist/node.mjs +0 -1374
  24. package/node_modules/@xeno-corporation/account/dist/node.mjs.map +0 -1
  25. package/node_modules/@xeno-corporation/account/package.json +0 -62
  26. package/node_modules/zod/LICENSE +0 -21
  27. package/node_modules/zod/README.md +0 -218
  28. package/node_modules/zod/compile.cjs +0 -96
  29. package/node_modules/zod/compile.d.cts +0 -1
  30. package/node_modules/zod/compile.d.ts +0 -1
  31. package/node_modules/zod/compile.js +0 -52
  32. package/node_modules/zod/index.cjs +0 -52
  33. package/node_modules/zod/index.d.cts +0 -3
  34. package/node_modules/zod/index.d.ts +0 -3
  35. package/node_modules/zod/index.js +0 -7
  36. package/node_modules/zod/locales/index.cjs +0 -36
  37. package/node_modules/zod/locales/index.d.cts +0 -1
  38. package/node_modules/zod/locales/index.d.ts +0 -1
  39. package/node_modules/zod/locales/index.js +0 -1
  40. package/node_modules/zod/locales/package.json +0 -7
  41. package/node_modules/zod/mini/index.cjs +0 -51
  42. package/node_modules/zod/mini/index.d.cts +0 -3
  43. package/node_modules/zod/mini/index.d.ts +0 -3
  44. package/node_modules/zod/mini/index.js +0 -3
  45. package/node_modules/zod/mini/package.json +0 -7
  46. package/node_modules/zod/package.json +0 -147
  47. package/node_modules/zod/src/compile.ts +0 -56
  48. package/node_modules/zod/src/index.ts +0 -7
  49. package/node_modules/zod/src/locales/index.ts +0 -1
  50. package/node_modules/zod/src/mini/index.ts +0 -3
  51. package/node_modules/zod/src/v3/ZodError.ts +0 -340
  52. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  53. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  54. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  55. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  56. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  57. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  58. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  59. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  60. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  61. package/node_modules/zod/src/v3/errors.ts +0 -13
  62. package/node_modules/zod/src/v3/external.ts +0 -6
  63. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  64. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  65. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  66. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  67. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  68. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  69. package/node_modules/zod/src/v3/index.ts +0 -4
  70. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  71. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  72. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  73. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  74. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  75. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  76. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  77. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  78. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  79. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  80. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  81. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  82. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  83. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -70
  84. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  85. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  86. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  87. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  88. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  89. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  90. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  91. package/node_modules/zod/src/v3/tests/error.test.ts +0 -586
  92. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  93. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  94. package/node_modules/zod/src/v3/tests/function.test.ts +0 -261
  95. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  96. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  97. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -128
  98. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  99. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -206
  100. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  101. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  102. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  103. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  104. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -24
  105. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  106. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  107. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  108. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  109. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  110. package/node_modules/zod/src/v3/tests/object.test.ts +0 -431
  111. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  112. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  113. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  114. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  115. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  116. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  117. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  118. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  119. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  120. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -114
  121. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  122. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  123. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  124. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  125. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  126. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  127. package/node_modules/zod/src/v3/tests/string.test.ts +0 -922
  128. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  129. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  130. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  131. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  132. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  133. package/node_modules/zod/src/v3/types.ts +0 -5138
  134. package/node_modules/zod/src/v4/classic/checks.ts +0 -33
  135. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  136. package/node_modules/zod/src/v4/classic/compat.ts +0 -78
  137. package/node_modules/zod/src/v4/classic/deep-partial.ts +0 -76
  138. package/node_modules/zod/src/v4/classic/errors.ts +0 -97
  139. package/node_modules/zod/src/v4/classic/external.ts +0 -57
  140. package/node_modules/zod/src/v4/classic/from-json-schema.ts +0 -944
  141. package/node_modules/zod/src/v4/classic/in-out.ts +0 -45
  142. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  143. package/node_modules/zod/src/v4/classic/iso.ts +0 -20
  144. package/node_modules/zod/src/v4/classic/parse.ts +0 -88
  145. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2937
  146. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  147. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +0 -86
  148. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -291
  149. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -402
  150. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  151. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  152. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  153. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -89
  154. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -106
  155. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -604
  156. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  157. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -572
  158. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -704
  159. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  160. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -374
  161. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +0 -76
  162. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  163. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +0 -985
  164. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -92
  165. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -316
  166. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +0 -380
  167. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +0 -32
  168. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -455
  169. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +0 -27
  170. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  171. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +0 -221
  172. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -942
  173. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -305
  174. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -917
  175. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -1108
  176. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  177. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  178. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +0 -26
  179. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +0 -1467
  180. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -391
  181. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  182. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +0 -32
  183. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -67
  184. package/node_modules/zod/src/v4/classic/tests/iban.test.ts +0 -81
  185. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +0 -159
  186. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -958
  187. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +0 -319
  188. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -127
  189. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -334
  190. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +0 -215
  191. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +0 -39
  192. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -109
  193. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -262
  194. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -128
  195. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +0 -29
  196. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +0 -24
  197. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -349
  198. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  199. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  200. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  201. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  202. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -401
  203. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -1006
  204. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +0 -235
  205. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -366
  206. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -497
  207. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -211
  208. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  209. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -144
  210. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +0 -44
  211. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -351
  212. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  213. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  214. package/node_modules/zod/src/v4/classic/tests/properties.test.ts +0 -141
  215. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  216. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -184
  217. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -885
  218. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -707
  219. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +0 -68
  220. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -693
  221. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -243
  222. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -196
  223. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -153
  224. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  225. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1440
  226. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -124
  227. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -812
  228. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +0 -438
  229. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -4733
  230. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -378
  231. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -511
  232. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -310
  233. package/node_modules/zod/src/v4/classic/tests/url.test.ts +0 -13
  234. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +0 -645
  235. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  236. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  237. package/node_modules/zod/src/v4/core/api.ts +0 -1875
  238. package/node_modules/zod/src/v4/core/checks.ts +0 -1266
  239. package/node_modules/zod/src/v4/core/compile.ts +0 -2322
  240. package/node_modules/zod/src/v4/core/core.ts +0 -230
  241. package/node_modules/zod/src/v4/core/doc.ts +0 -52
  242. package/node_modules/zod/src/v4/core/errors.ts +0 -543
  243. package/node_modules/zod/src/v4/core/index.ts +0 -19
  244. package/node_modules/zod/src/v4/core/json-schema-generator.ts +0 -131
  245. package/node_modules/zod/src/v4/core/json-schema-processors.ts +0 -934
  246. package/node_modules/zod/src/v4/core/json-schema.ts +0 -148
  247. package/node_modules/zod/src/v4/core/memoizer.ts +0 -331
  248. package/node_modules/zod/src/v4/core/parse.ts +0 -309
  249. package/node_modules/zod/src/v4/core/regexes.ts +0 -217
  250. package/node_modules/zod/src/v4/core/registries.ts +0 -105
  251. package/node_modules/zod/src/v4/core/schemas.ts +0 -5226
  252. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -159
  253. package/node_modules/zod/src/v4/core/tests/cached.test.ts +0 -54
  254. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +0 -1004
  255. package/node_modules/zod/src/v4/core/tests/compile-generative.test.ts +0 -445
  256. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +0 -89
  257. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +0 -26
  258. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +0 -34
  259. package/node_modules/zod/src/v4/core/tests/compile.test.ts +0 -2036
  260. package/node_modules/zod/src/v4/core/tests/email-regex.test.ts +0 -140
  261. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -59
  262. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  263. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  264. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +0 -214
  265. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  266. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -180
  267. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +0 -72
  268. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +0 -379
  269. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +0 -163
  270. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +0 -46
  271. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +0 -42
  272. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  273. package/node_modules/zod/src/v4/core/tests/locales/tg.test.ts +0 -85
  274. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +0 -69
  275. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  276. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +0 -105
  277. package/node_modules/zod/src/v4/core/tests/polyfill-collision.test.ts +0 -46
  278. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +0 -125
  279. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +0 -45
  280. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +0 -51
  281. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +0 -133
  282. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -857
  283. package/node_modules/zod/src/v4/core/util.ts +0 -1293
  284. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  285. package/node_modules/zod/src/v4/core/visit.ts +0 -193
  286. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  287. package/node_modules/zod/src/v4/index.ts +0 -4
  288. package/node_modules/zod/src/v4/locales/ar.ts +0 -120
  289. package/node_modules/zod/src/v4/locales/az.ts +0 -116
  290. package/node_modules/zod/src/v4/locales/be.ts +0 -188
  291. package/node_modules/zod/src/v4/locales/bg.ts +0 -133
  292. package/node_modules/zod/src/v4/locales/bn.ts +0 -123
  293. package/node_modules/zod/src/v4/locales/ca.ts +0 -121
  294. package/node_modules/zod/src/v4/locales/ckb.ts +0 -140
  295. package/node_modules/zod/src/v4/locales/cs.ts +0 -123
  296. package/node_modules/zod/src/v4/locales/da.ts +0 -128
  297. package/node_modules/zod/src/v4/locales/de.ts +0 -121
  298. package/node_modules/zod/src/v4/locales/el.ts +0 -124
  299. package/node_modules/zod/src/v4/locales/en.ts +0 -136
  300. package/node_modules/zod/src/v4/locales/eo.ts +0 -123
  301. package/node_modules/zod/src/v4/locales/es.ts +0 -145
  302. package/node_modules/zod/src/v4/locales/fa.ts +0 -131
  303. package/node_modules/zod/src/v4/locales/fi.ts +0 -126
  304. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -121
  305. package/node_modules/zod/src/v4/locales/fr.ts +0 -139
  306. package/node_modules/zod/src/v4/locales/gu.ts +0 -123
  307. package/node_modules/zod/src/v4/locales/he.ts +0 -253
  308. package/node_modules/zod/src/v4/locales/hi.ts +0 -126
  309. package/node_modules/zod/src/v4/locales/hr.ts +0 -135
  310. package/node_modules/zod/src/v4/locales/hu.ts +0 -122
  311. package/node_modules/zod/src/v4/locales/hy.ts +0 -175
  312. package/node_modules/zod/src/v4/locales/id.ts +0 -120
  313. package/node_modules/zod/src/v4/locales/index.ts +0 -63
  314. package/node_modules/zod/src/v4/locales/is.ts +0 -124
  315. package/node_modules/zod/src/v4/locales/it.ts +0 -121
  316. package/node_modules/zod/src/v4/locales/ja.ts +0 -119
  317. package/node_modules/zod/src/v4/locales/ka.ts +0 -128
  318. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  319. package/node_modules/zod/src/v4/locales/km.ts +0 -124
  320. package/node_modules/zod/src/v4/locales/kn.ts +0 -126
  321. package/node_modules/zod/src/v4/locales/ko.ts +0 -126
  322. package/node_modules/zod/src/v4/locales/lt.ts +0 -243
  323. package/node_modules/zod/src/v4/locales/mk.ts +0 -123
  324. package/node_modules/zod/src/v4/locales/ms.ts +0 -120
  325. package/node_modules/zod/src/v4/locales/ne.ts +0 -128
  326. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  327. package/node_modules/zod/src/v4/locales/nn.ts +0 -121
  328. package/node_modules/zod/src/v4/locales/no.ts +0 -121
  329. package/node_modules/zod/src/v4/locales/ota.ts +0 -122
  330. package/node_modules/zod/src/v4/locales/pl.ts +0 -123
  331. package/node_modules/zod/src/v4/locales/ps.ts +0 -131
  332. package/node_modules/zod/src/v4/locales/pt-BR.ts +0 -161
  333. package/node_modules/zod/src/v4/locales/pt.ts +0 -159
  334. package/node_modules/zod/src/v4/locales/ro.ts +0 -132
  335. package/node_modules/zod/src/v4/locales/ru.ts +0 -188
  336. package/node_modules/zod/src/v4/locales/sk.ts +0 -123
  337. package/node_modules/zod/src/v4/locales/sl.ts +0 -123
  338. package/node_modules/zod/src/v4/locales/sv.ts +0 -124
  339. package/node_modules/zod/src/v4/locales/ta.ts +0 -123
  340. package/node_modules/zod/src/v4/locales/tg.ts +0 -135
  341. package/node_modules/zod/src/v4/locales/th.ts +0 -124
  342. package/node_modules/zod/src/v4/locales/tk.ts +0 -113
  343. package/node_modules/zod/src/v4/locales/tr.ts +0 -116
  344. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  345. package/node_modules/zod/src/v4/locales/uk.ts +0 -122
  346. package/node_modules/zod/src/v4/locales/ur.ts +0 -124
  347. package/node_modules/zod/src/v4/locales/uz.ts +0 -120
  348. package/node_modules/zod/src/v4/locales/vi.ts +0 -122
  349. package/node_modules/zod/src/v4/locales/yo.ts +0 -129
  350. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -121
  351. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -120
  352. package/node_modules/zod/src/v4/mini/checks.ts +0 -33
  353. package/node_modules/zod/src/v4/mini/coerce.ts +0 -27
  354. package/node_modules/zod/src/v4/mini/deep-partial.ts +0 -73
  355. package/node_modules/zod/src/v4/mini/external.ts +0 -52
  356. package/node_modules/zod/src/v4/mini/in-out.ts +0 -45
  357. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  358. package/node_modules/zod/src/v4/mini/iso.ts +0 -66
  359. package/node_modules/zod/src/v4/mini/parse.ts +0 -16
  360. package/node_modules/zod/src/v4/mini/schemas.ts +0 -2051
  361. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +0 -57
  362. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -190
  363. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -94
  364. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -158
  365. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -582
  366. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -30
  367. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +0 -84
  368. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +0 -54
  369. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -41
  370. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -14
  371. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -1146
  372. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -109
  373. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -292
  374. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  375. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -341
  376. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +0 -50
  377. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -396
  378. package/node_modules/zod/src/v4-mini/index.ts +0 -3
  379. package/node_modules/zod/v3/ZodError.cjs +0 -167
  380. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  381. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  382. package/node_modules/zod/v3/ZodError.js +0 -143
  383. package/node_modules/zod/v3/errors.cjs +0 -36
  384. package/node_modules/zod/v3/errors.d.cts +0 -5
  385. package/node_modules/zod/v3/errors.d.ts +0 -5
  386. package/node_modules/zod/v3/errors.js +0 -9
  387. package/node_modules/zod/v3/external.cjs +0 -41
  388. package/node_modules/zod/v3/external.d.cts +0 -6
  389. package/node_modules/zod/v3/external.d.ts +0 -6
  390. package/node_modules/zod/v3/external.js +0 -6
  391. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -21
  392. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  393. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  394. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  395. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -28
  396. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  397. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  398. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  399. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -143
  400. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  401. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  402. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  403. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -21
  404. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  405. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  406. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  407. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -21
  408. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  409. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  410. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  411. package/node_modules/zod/v3/helpers/util.cjs +0 -156
  412. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  413. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  414. package/node_modules/zod/v3/helpers/util.js +0 -133
  415. package/node_modules/zod/v3/index.cjs +0 -52
  416. package/node_modules/zod/v3/index.d.cts +0 -4
  417. package/node_modules/zod/v3/index.d.ts +0 -4
  418. package/node_modules/zod/v3/index.js +0 -4
  419. package/node_modules/zod/v3/locales/en.cjs +0 -112
  420. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  421. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  422. package/node_modules/zod/v3/locales/en.js +0 -109
  423. package/node_modules/zod/v3/package.json +0 -7
  424. package/node_modules/zod/v3/standard-schema.cjs +0 -21
  425. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  426. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  427. package/node_modules/zod/v3/standard-schema.js +0 -1
  428. package/node_modules/zod/v3/types.cjs +0 -3798
  429. package/node_modules/zod/v3/types.d.cts +0 -1034
  430. package/node_modules/zod/v3/types.d.ts +0 -1034
  431. package/node_modules/zod/v3/types.js +0 -3697
  432. package/node_modules/zod/v4/classic/checks.cjs +0 -53
  433. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  434. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  435. package/node_modules/zod/v4/classic/checks.js +0 -1
  436. package/node_modules/zod/v4/classic/coerce.cjs +0 -66
  437. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  438. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  439. package/node_modules/zod/v4/classic/coerce.js +0 -17
  440. package/node_modules/zod/v4/classic/compat.cjs +0 -80
  441. package/node_modules/zod/v4/classic/compat.d.cts +0 -48
  442. package/node_modules/zod/v4/classic/compat.d.ts +0 -48
  443. package/node_modules/zod/v4/classic/compat.js +0 -31
  444. package/node_modules/zod/v4/classic/deep-partial.cjs +0 -58
  445. package/node_modules/zod/v4/classic/deep-partial.d.cts +0 -14
  446. package/node_modules/zod/v4/classic/deep-partial.d.ts +0 -14
  447. package/node_modules/zod/v4/classic/deep-partial.js +0 -13
  448. package/node_modules/zod/v4/classic/errors.cjs +0 -102
  449. package/node_modules/zod/v4/classic/errors.d.cts +0 -29
  450. package/node_modules/zod/v4/classic/errors.d.ts +0 -29
  451. package/node_modules/zod/v4/classic/errors.js +0 -57
  452. package/node_modules/zod/v4/classic/external.cjs +0 -97
  453. package/node_modules/zod/v4/classic/external.d.cts +0 -19
  454. package/node_modules/zod/v4/classic/external.d.ts +0 -19
  455. package/node_modules/zod/v4/classic/external.js +0 -17
  456. package/node_modules/zod/v4/classic/from-json-schema.cjs +0 -926
  457. package/node_modules/zod/v4/classic/from-json-schema.d.cts +0 -12
  458. package/node_modules/zod/v4/classic/from-json-schema.d.ts +0 -12
  459. package/node_modules/zod/v4/classic/from-json-schema.js +0 -881
  460. package/node_modules/zod/v4/classic/in-out.cjs +0 -82
  461. package/node_modules/zod/v4/classic/in-out.d.cts +0 -8
  462. package/node_modules/zod/v4/classic/in-out.d.ts +0 -8
  463. package/node_modules/zod/v4/classic/in-out.js +0 -36
  464. package/node_modules/zod/v4/classic/index.cjs +0 -52
  465. package/node_modules/zod/v4/classic/index.d.cts +0 -3
  466. package/node_modules/zod/v4/classic/index.d.ts +0 -3
  467. package/node_modules/zod/v4/classic/index.js +0 -4
  468. package/node_modules/zod/v4/classic/iso.cjs +0 -68
  469. package/node_modules/zod/v4/classic/iso.d.cts +0 -7
  470. package/node_modules/zod/v4/classic/iso.d.ts +0 -7
  471. package/node_modules/zod/v4/classic/iso.js +0 -15
  472. package/node_modules/zod/v4/classic/package.json +0 -7
  473. package/node_modules/zod/v4/classic/parse.cjs +0 -63
  474. package/node_modules/zod/v4/classic/parse.d.cts +0 -44
  475. package/node_modules/zod/v4/classic/parse.d.ts +0 -44
  476. package/node_modules/zod/v4/classic/parse.js +0 -16
  477. package/node_modules/zod/v4/classic/schemas.cjs +0 -1676
  478. package/node_modules/zod/v4/classic/schemas.d.cts +0 -816
  479. package/node_modules/zod/v4/classic/schemas.d.ts +0 -816
  480. package/node_modules/zod/v4/classic/schemas.js +0 -1535
  481. package/node_modules/zod/v4/core/api.cjs +0 -1269
  482. package/node_modules/zod/v4/core/api.d.cts +0 -335
  483. package/node_modules/zod/v4/core/api.d.ts +0 -335
  484. package/node_modules/zod/v4/core/api.js +0 -1107
  485. package/node_modules/zod/v4/core/checks.cjs +0 -561
  486. package/node_modules/zod/v4/core/checks.d.cts +0 -294
  487. package/node_modules/zod/v4/core/checks.d.ts +0 -294
  488. package/node_modules/zod/v4/core/checks.js +0 -516
  489. package/node_modules/zod/v4/core/compile.cjs +0 -1916
  490. package/node_modules/zod/v4/core/compile.d.cts +0 -65
  491. package/node_modules/zod/v4/core/compile.d.ts +0 -65
  492. package/node_modules/zod/v4/core/compile.js +0 -1866
  493. package/node_modules/zod/v4/core/core.cjs +0 -167
  494. package/node_modules/zod/v4/core/core.d.cts +0 -82
  495. package/node_modules/zod/v4/core/core.d.ts +0 -82
  496. package/node_modules/zod/v4/core/core.js +0 -141
  497. package/node_modules/zod/v4/core/doc.cjs +0 -61
  498. package/node_modules/zod/v4/core/doc.d.cts +0 -16
  499. package/node_modules/zod/v4/core/doc.d.ts +0 -16
  500. package/node_modules/zod/v4/core/doc.js +0 -38
  501. package/node_modules/zod/v4/core/errors.cjs +0 -317
  502. package/node_modules/zod/v4/core/errors.d.cts +0 -225
  503. package/node_modules/zod/v4/core/errors.d.ts +0 -225
  504. package/node_modules/zod/v4/core/errors.js +0 -267
  505. package/node_modules/zod/v4/core/index.cjs +0 -70
  506. package/node_modules/zod/v4/core/index.d.cts +0 -19
  507. package/node_modules/zod/v4/core/index.d.ts +0 -19
  508. package/node_modules/zod/v4/core/index.js +0 -19
  509. package/node_modules/zod/v4/core/json-schema-generator.cjs +0 -122
  510. package/node_modules/zod/v4/core/json-schema-generator.d.cts +0 -65
  511. package/node_modules/zod/v4/core/json-schema-generator.d.ts +0 -65
  512. package/node_modules/zod/v4/core/json-schema-generator.js +0 -99
  513. package/node_modules/zod/v4/core/json-schema-processors.cjs +0 -929
  514. package/node_modules/zod/v4/core/json-schema-processors.d.cts +0 -65
  515. package/node_modules/zod/v4/core/json-schema-processors.d.ts +0 -65
  516. package/node_modules/zod/v4/core/json-schema-processors.js +0 -843
  517. package/node_modules/zod/v4/core/json-schema.cjs +0 -21
  518. package/node_modules/zod/v4/core/json-schema.d.cts +0 -89
  519. package/node_modules/zod/v4/core/json-schema.d.ts +0 -89
  520. package/node_modules/zod/v4/core/json-schema.js +0 -1
  521. package/node_modules/zod/v4/core/memoizer.cjs +0 -360
  522. package/node_modules/zod/v4/core/memoizer.d.cts +0 -15
  523. package/node_modules/zod/v4/core/memoizer.d.ts +0 -15
  524. package/node_modules/zod/v4/core/memoizer.js +0 -311
  525. package/node_modules/zod/v4/core/package.json +0 -7
  526. package/node_modules/zod/v4/core/parse.cjs +0 -233
  527. package/node_modules/zod/v4/core/parse.d.cts +0 -52
  528. package/node_modules/zod/v4/core/parse.d.ts +0 -52
  529. package/node_modules/zod/v4/core/parse.js +0 -175
  530. package/node_modules/zod/v4/core/regexes.cjs +0 -209
  531. package/node_modules/zod/v4/core/regexes.d.cts +0 -90
  532. package/node_modules/zod/v4/core/regexes.d.ts +0 -90
  533. package/node_modules/zod/v4/core/regexes.js +0 -156
  534. package/node_modules/zod/v4/core/registries.cjs +0 -75
  535. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  536. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  537. package/node_modules/zod/v4/core/registries.js +0 -51
  538. package/node_modules/zod/v4/core/schemas.cjs +0 -2699
  539. package/node_modules/zod/v4/core/schemas.d.cts +0 -1275
  540. package/node_modules/zod/v4/core/schemas.d.ts +0 -1275
  541. package/node_modules/zod/v4/core/schemas.js +0 -2636
  542. package/node_modules/zod/v4/core/standard-schema.cjs +0 -21
  543. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -126
  544. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -126
  545. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  546. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -681
  547. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -154
  548. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -154
  549. package/node_modules/zod/v4/core/to-json-schema.js +0 -651
  550. package/node_modules/zod/v4/core/util.cjs +0 -964
  551. package/node_modules/zod/v4/core/util.d.cts +0 -280
  552. package/node_modules/zod/v4/core/util.d.ts +0 -280
  553. package/node_modules/zod/v4/core/util.js +0 -873
  554. package/node_modules/zod/v4/core/versions.cjs +0 -27
  555. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  556. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  557. package/node_modules/zod/v4/core/versions.js +0 -5
  558. package/node_modules/zod/v4/core/visit.cjs +0 -214
  559. package/node_modules/zod/v4/core/visit.d.cts +0 -30
  560. package/node_modules/zod/v4/core/visit.d.ts +0 -30
  561. package/node_modules/zod/v4/core/visit.js +0 -169
  562. package/node_modules/zod/v4/index.cjs +0 -51
  563. package/node_modules/zod/v4/index.d.cts +0 -3
  564. package/node_modules/zod/v4/index.d.ts +0 -3
  565. package/node_modules/zod/v4/index.js +0 -4
  566. package/node_modules/zod/v4/locales/ar.cjs +0 -138
  567. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  568. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  569. package/node_modules/zod/v4/locales/ar.js +0 -111
  570. package/node_modules/zod/v4/locales/az.cjs +0 -137
  571. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  572. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  573. package/node_modules/zod/v4/locales/az.js +0 -110
  574. package/node_modules/zod/v4/locales/be.cjs +0 -195
  575. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  576. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  577. package/node_modules/zod/v4/locales/be.js +0 -168
  578. package/node_modules/zod/v4/locales/bg.cjs +0 -152
  579. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  580. package/node_modules/zod/v4/locales/bg.d.ts +0 -4
  581. package/node_modules/zod/v4/locales/bg.js +0 -125
  582. package/node_modules/zod/v4/locales/bn.cjs +0 -140
  583. package/node_modules/zod/v4/locales/bn.d.cts +0 -5
  584. package/node_modules/zod/v4/locales/bn.d.ts +0 -4
  585. package/node_modules/zod/v4/locales/bn.js +0 -113
  586. package/node_modules/zod/v4/locales/ca.cjs +0 -139
  587. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  588. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  589. package/node_modules/zod/v4/locales/ca.js +0 -112
  590. package/node_modules/zod/v4/locales/ckb.cjs +0 -160
  591. package/node_modules/zod/v4/locales/ckb.d.cts +0 -5
  592. package/node_modules/zod/v4/locales/ckb.d.ts +0 -4
  593. package/node_modules/zod/v4/locales/ckb.js +0 -133
  594. package/node_modules/zod/v4/locales/cs.cjs +0 -143
  595. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  596. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  597. package/node_modules/zod/v4/locales/cs.js +0 -116
  598. package/node_modules/zod/v4/locales/da.cjs +0 -147
  599. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  600. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  601. package/node_modules/zod/v4/locales/da.js +0 -120
  602. package/node_modules/zod/v4/locales/de.cjs +0 -140
  603. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  604. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  605. package/node_modules/zod/v4/locales/de.js +0 -113
  606. package/node_modules/zod/v4/locales/el.cjs +0 -139
  607. package/node_modules/zod/v4/locales/el.d.cts +0 -5
  608. package/node_modules/zod/v4/locales/el.d.ts +0 -4
  609. package/node_modules/zod/v4/locales/el.js +0 -112
  610. package/node_modules/zod/v4/locales/en.cjs +0 -152
  611. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  612. package/node_modules/zod/v4/locales/en.d.ts +0 -4
  613. package/node_modules/zod/v4/locales/en.js +0 -125
  614. package/node_modules/zod/v4/locales/eo.cjs +0 -141
  615. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  616. package/node_modules/zod/v4/locales/eo.d.ts +0 -4
  617. package/node_modules/zod/v4/locales/eo.js +0 -114
  618. package/node_modules/zod/v4/locales/es.cjs +0 -163
  619. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  620. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  621. package/node_modules/zod/v4/locales/es.js +0 -136
  622. package/node_modules/zod/v4/locales/fa.cjs +0 -146
  623. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  624. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  625. package/node_modules/zod/v4/locales/fa.js +0 -119
  626. package/node_modules/zod/v4/locales/fi.cjs +0 -144
  627. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  628. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  629. package/node_modules/zod/v4/locales/fi.js +0 -117
  630. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -139
  631. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  632. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  633. package/node_modules/zod/v4/locales/fr-CA.js +0 -112
  634. package/node_modules/zod/v4/locales/fr.cjs +0 -156
  635. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  636. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  637. package/node_modules/zod/v4/locales/fr.js +0 -129
  638. package/node_modules/zod/v4/locales/gu.cjs +0 -140
  639. package/node_modules/zod/v4/locales/gu.d.cts +0 -5
  640. package/node_modules/zod/v4/locales/gu.d.ts +0 -4
  641. package/node_modules/zod/v4/locales/gu.js +0 -113
  642. package/node_modules/zod/v4/locales/he.cjs +0 -248
  643. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  644. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  645. package/node_modules/zod/v4/locales/he.js +0 -221
  646. package/node_modules/zod/v4/locales/hi.cjs +0 -138
  647. package/node_modules/zod/v4/locales/hi.d.cts +0 -5
  648. package/node_modules/zod/v4/locales/hi.d.ts +0 -4
  649. package/node_modules/zod/v4/locales/hi.js +0 -111
  650. package/node_modules/zod/v4/locales/hr.cjs +0 -153
  651. package/node_modules/zod/v4/locales/hr.d.cts +0 -5
  652. package/node_modules/zod/v4/locales/hr.d.ts +0 -4
  653. package/node_modules/zod/v4/locales/hr.js +0 -126
  654. package/node_modules/zod/v4/locales/hu.cjs +0 -140
  655. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  656. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  657. package/node_modules/zod/v4/locales/hu.js +0 -113
  658. package/node_modules/zod/v4/locales/hy.cjs +0 -185
  659. package/node_modules/zod/v4/locales/hy.d.cts +0 -5
  660. package/node_modules/zod/v4/locales/hy.d.ts +0 -4
  661. package/node_modules/zod/v4/locales/hy.js +0 -158
  662. package/node_modules/zod/v4/locales/id.cjs +0 -138
  663. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  664. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  665. package/node_modules/zod/v4/locales/id.js +0 -111
  666. package/node_modules/zod/v4/locales/index.cjs +0 -152
  667. package/node_modules/zod/v4/locales/index.d.cts +0 -63
  668. package/node_modules/zod/v4/locales/index.d.ts +0 -63
  669. package/node_modules/zod/v4/locales/index.js +0 -63
  670. package/node_modules/zod/v4/locales/is.cjs +0 -141
  671. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  672. package/node_modules/zod/v4/locales/is.d.ts +0 -4
  673. package/node_modules/zod/v4/locales/is.js +0 -114
  674. package/node_modules/zod/v4/locales/it.cjs +0 -140
  675. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  676. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  677. package/node_modules/zod/v4/locales/it.js +0 -113
  678. package/node_modules/zod/v4/locales/ja.cjs +0 -139
  679. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  680. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  681. package/node_modules/zod/v4/locales/ja.js +0 -112
  682. package/node_modules/zod/v4/locales/ka.cjs +0 -144
  683. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  684. package/node_modules/zod/v4/locales/ka.d.ts +0 -4
  685. package/node_modules/zod/v4/locales/ka.js +0 -117
  686. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  687. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  688. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  689. package/node_modules/zod/v4/locales/kh.js +0 -5
  690. package/node_modules/zod/v4/locales/km.cjs +0 -142
  691. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  692. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  693. package/node_modules/zod/v4/locales/km.js +0 -115
  694. package/node_modules/zod/v4/locales/kn.cjs +0 -143
  695. package/node_modules/zod/v4/locales/kn.d.cts +0 -5
  696. package/node_modules/zod/v4/locales/kn.d.ts +0 -4
  697. package/node_modules/zod/v4/locales/kn.js +0 -116
  698. package/node_modules/zod/v4/locales/ko.cjs +0 -143
  699. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  700. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  701. package/node_modules/zod/v4/locales/ko.js +0 -116
  702. package/node_modules/zod/v4/locales/lt.cjs +0 -234
  703. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  704. package/node_modules/zod/v4/locales/lt.d.ts +0 -4
  705. package/node_modules/zod/v4/locales/lt.js +0 -207
  706. package/node_modules/zod/v4/locales/mk.cjs +0 -141
  707. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  708. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  709. package/node_modules/zod/v4/locales/mk.js +0 -114
  710. package/node_modules/zod/v4/locales/ms.cjs +0 -139
  711. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  712. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  713. package/node_modules/zod/v4/locales/ms.js +0 -112
  714. package/node_modules/zod/v4/locales/ne.cjs +0 -138
  715. package/node_modules/zod/v4/locales/ne.d.cts +0 -5
  716. package/node_modules/zod/v4/locales/ne.d.ts +0 -4
  717. package/node_modules/zod/v4/locales/ne.js +0 -111
  718. package/node_modules/zod/v4/locales/nl.cjs +0 -142
  719. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  720. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  721. package/node_modules/zod/v4/locales/nl.js +0 -115
  722. package/node_modules/zod/v4/locales/nn.cjs +0 -140
  723. package/node_modules/zod/v4/locales/nn.d.cts +0 -5
  724. package/node_modules/zod/v4/locales/nn.d.ts +0 -4
  725. package/node_modules/zod/v4/locales/nn.js +0 -113
  726. package/node_modules/zod/v4/locales/no.cjs +0 -140
  727. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  728. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  729. package/node_modules/zod/v4/locales/no.js +0 -113
  730. package/node_modules/zod/v4/locales/ota.cjs +0 -141
  731. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  732. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  733. package/node_modules/zod/v4/locales/ota.js +0 -114
  734. package/node_modules/zod/v4/locales/package.json +0 -7
  735. package/node_modules/zod/v4/locales/pl.cjs +0 -141
  736. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  737. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  738. package/node_modules/zod/v4/locales/pl.js +0 -114
  739. package/node_modules/zod/v4/locales/ps.cjs +0 -146
  740. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  741. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  742. package/node_modules/zod/v4/locales/ps.js +0 -119
  743. package/node_modules/zod/v4/locales/pt-BR.cjs +0 -170
  744. package/node_modules/zod/v4/locales/pt-BR.d.cts +0 -5
  745. package/node_modules/zod/v4/locales/pt-BR.d.ts +0 -4
  746. package/node_modules/zod/v4/locales/pt-BR.js +0 -143
  747. package/node_modules/zod/v4/locales/pt.cjs +0 -169
  748. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  749. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  750. package/node_modules/zod/v4/locales/pt.js +0 -142
  751. package/node_modules/zod/v4/locales/ro.cjs +0 -149
  752. package/node_modules/zod/v4/locales/ro.d.cts +0 -5
  753. package/node_modules/zod/v4/locales/ro.d.ts +0 -4
  754. package/node_modules/zod/v4/locales/ro.js +0 -122
  755. package/node_modules/zod/v4/locales/ru.cjs +0 -195
  756. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  757. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  758. package/node_modules/zod/v4/locales/ru.js +0 -168
  759. package/node_modules/zod/v4/locales/sk.cjs +0 -143
  760. package/node_modules/zod/v4/locales/sk.d.cts +0 -5
  761. package/node_modules/zod/v4/locales/sk.d.ts +0 -4
  762. package/node_modules/zod/v4/locales/sk.js +0 -116
  763. package/node_modules/zod/v4/locales/sl.cjs +0 -141
  764. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  765. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  766. package/node_modules/zod/v4/locales/sl.js +0 -114
  767. package/node_modules/zod/v4/locales/sv.cjs +0 -142
  768. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  769. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  770. package/node_modules/zod/v4/locales/sv.js +0 -115
  771. package/node_modules/zod/v4/locales/ta.cjs +0 -142
  772. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  773. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  774. package/node_modules/zod/v4/locales/ta.js +0 -115
  775. package/node_modules/zod/v4/locales/tg.cjs +0 -144
  776. package/node_modules/zod/v4/locales/tg.d.cts +0 -5
  777. package/node_modules/zod/v4/locales/tg.d.ts +0 -4
  778. package/node_modules/zod/v4/locales/tg.js +0 -117
  779. package/node_modules/zod/v4/locales/th.cjs +0 -142
  780. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  781. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  782. package/node_modules/zod/v4/locales/th.js +0 -115
  783. package/node_modules/zod/v4/locales/tk.cjs +0 -134
  784. package/node_modules/zod/v4/locales/tk.d.cts +0 -5
  785. package/node_modules/zod/v4/locales/tk.d.ts +0 -4
  786. package/node_modules/zod/v4/locales/tk.js +0 -107
  787. package/node_modules/zod/v4/locales/tr.cjs +0 -137
  788. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  789. package/node_modules/zod/v4/locales/tr.d.ts +0 -4
  790. package/node_modules/zod/v4/locales/tr.js +0 -110
  791. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  792. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  793. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  794. package/node_modules/zod/v4/locales/ua.js +0 -5
  795. package/node_modules/zod/v4/locales/uk.cjs +0 -140
  796. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  797. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  798. package/node_modules/zod/v4/locales/uk.js +0 -113
  799. package/node_modules/zod/v4/locales/ur.cjs +0 -142
  800. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  801. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  802. package/node_modules/zod/v4/locales/ur.js +0 -115
  803. package/node_modules/zod/v4/locales/uz.cjs +0 -140
  804. package/node_modules/zod/v4/locales/uz.d.cts +0 -5
  805. package/node_modules/zod/v4/locales/uz.d.ts +0 -4
  806. package/node_modules/zod/v4/locales/uz.js +0 -113
  807. package/node_modules/zod/v4/locales/vi.cjs +0 -140
  808. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  809. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  810. package/node_modules/zod/v4/locales/vi.js +0 -113
  811. package/node_modules/zod/v4/locales/yo.cjs +0 -139
  812. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  813. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  814. package/node_modules/zod/v4/locales/yo.js +0 -112
  815. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -141
  816. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  817. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  818. package/node_modules/zod/v4/locales/zh-CN.js +0 -114
  819. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -139
  820. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  821. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  822. package/node_modules/zod/v4/locales/zh-TW.js +0 -112
  823. package/node_modules/zod/v4/mini/checks.cjs +0 -54
  824. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  825. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  826. package/node_modules/zod/v4/mini/checks.js +0 -1
  827. package/node_modules/zod/v4/mini/coerce.cjs +0 -71
  828. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  829. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  830. package/node_modules/zod/v4/mini/coerce.js +0 -22
  831. package/node_modules/zod/v4/mini/deep-partial.cjs +0 -58
  832. package/node_modules/zod/v4/mini/deep-partial.d.cts +0 -14
  833. package/node_modules/zod/v4/mini/deep-partial.d.ts +0 -14
  834. package/node_modules/zod/v4/mini/deep-partial.js +0 -13
  835. package/node_modules/zod/v4/mini/external.cjs +0 -95
  836. package/node_modules/zod/v4/mini/external.d.cts +0 -16
  837. package/node_modules/zod/v4/mini/external.d.ts +0 -16
  838. package/node_modules/zod/v4/mini/external.js +0 -16
  839. package/node_modules/zod/v4/mini/in-out.cjs +0 -82
  840. package/node_modules/zod/v4/mini/in-out.d.cts +0 -8
  841. package/node_modules/zod/v4/mini/in-out.d.ts +0 -8
  842. package/node_modules/zod/v4/mini/in-out.js +0 -36
  843. package/node_modules/zod/v4/mini/index.cjs +0 -51
  844. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  845. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  846. package/node_modules/zod/v4/mini/index.js +0 -3
  847. package/node_modules/zod/v4/mini/iso.cjs +0 -83
  848. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  849. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  850. package/node_modules/zod/v4/mini/iso.js +0 -34
  851. package/node_modules/zod/v4/mini/package.json +0 -7
  852. package/node_modules/zod/v4/mini/parse.cjs +0 -37
  853. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  854. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  855. package/node_modules/zod/v4/mini/parse.js +0 -1
  856. package/node_modules/zod/v4/mini/schemas.cjs +0 -1147
  857. package/node_modules/zod/v4/mini/schemas.d.cts +0 -480
  858. package/node_modules/zod/v4/mini/schemas.d.ts +0 -480
  859. package/node_modules/zod/v4/mini/schemas.js +0 -1002
  860. package/node_modules/zod/v4/package.json +0 -7
  861. package/node_modules/zod/v4-mini/index.cjs +0 -51
  862. package/node_modules/zod/v4-mini/index.d.cts +0 -3
  863. package/node_modules/zod/v4-mini/index.d.ts +0 -3
  864. package/node_modules/zod/v4-mini/index.js +0 -3
  865. package/node_modules/zod/v4-mini/package.json +0 -7
@@ -1,2699 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.$ZodObject = exports.$ZodArray = exports.$ZodDate = exports.$ZodVoid = exports.$ZodNever = exports.$ZodUnknown = exports.$ZodAny = exports.$ZodNull = exports.$ZodUndefined = exports.$ZodSymbol = exports.$ZodBigIntFormat = exports.$ZodBigInt = exports.$ZodBoolean = exports.$ZodNumberFormat = exports.$ZodNumber = exports.$ZodCustomStringFormat = exports.$ZodJWT = exports.$ZodIBAN = exports.$ZodCreditCard = exports.$ZodE164 = exports.$ZodBase64URL = exports.base64urlCharset = exports.$ZodBase64 = exports.base64Charset = exports.$ZodCIDRv6 = exports.$ZodCIDRv4 = exports.$ZodMAC = exports.$ZodIPv6 = exports.$ZodIPv4 = exports.$ZodISODuration = exports.$ZodISOTime = exports.$ZodISODate = exports.$ZodISODateTime = exports.$ZodKSUID = exports.$ZodXID = exports.$ZodULID = exports.$ZodCUID2 = exports.$ZodCUID = exports.$ZodNanoID = exports.$ZodEmoji = exports.$ZodURL = exports.URL_UNPARSEABLE = exports.URL_BAD_FORMAT = exports.$ZodEmail = exports.$ZodUUID = exports.$ZodGUID = exports.$ZodStringFormat = exports.$ZodString = exports.clone = exports.$ZodType = void 0;
27
- exports.$ZodCustom = exports.$ZodLazy = exports.$ZodPromise = exports.$ZodFunction = exports.$ZodTemplateLiteral = exports.$ZodReadonly = exports.$ZodPreprocess = exports.$ZodCodec = exports.$ZodPipe = exports.$ZodNaN = exports.$ZodCatch = exports.$ZodSuccess = exports.$ZodNonOptional = exports.$ZodPrefault = exports.$ZodDefault = exports.$ZodNullable = exports.$ZodExactOptional = exports.$ZodOptional = exports.$ZodTransform = exports.$ZodFile = exports.$ZodLiteral = exports.$ZodEnum = exports.$ZodSet = exports.$ZodMap = exports.$ZodRecord = exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = void 0;
28
- exports.standardProps = standardProps;
29
- exports.canParseURL = canParseURL;
30
- exports.validateURL = validateURL;
31
- exports.parseURLObject = parseURLObject;
32
- exports.stripTabAndNewline = stripTabAndNewline;
33
- exports.urlHostnameOk = urlHostnameOk;
34
- exports.urlProtocolOk = urlProtocolOk;
35
- exports.isValidIPv6 = isValidIPv6;
36
- exports.isValidCIDRv6 = isValidCIDRv6;
37
- exports.isValidBase64 = isValidBase64;
38
- exports.isValidBase64URL = isValidBase64URL;
39
- exports.isValidCreditCard = isValidCreditCard;
40
- exports.isValidIBAN = isValidIBAN;
41
- exports.isValidJWT = isValidJWT;
42
- exports.getDiscriminatedOption = getDiscriminatedOption;
43
- exports.mergeValues = mergeValues;
44
- const checks = __importStar(require("./checks.cjs"));
45
- const core = __importStar(require("./core.cjs"));
46
- const doc_js_1 = require("./doc.cjs");
47
- const parse_js_1 = require("./parse.cjs");
48
- const regexes = __importStar(require("./regexes.cjs"));
49
- const util = __importStar(require("./util.cjs"));
50
- const versions_js_1 = require("./versions.cjs");
51
- exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
52
- var _a;
53
- inst ?? (inst = {});
54
- inst._zod.def = def; // set _def property
55
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
56
- inst._zod.version = versions_js_1.version;
57
- const defChecks = inst._zod.def.checks;
58
- // if inst is itself a checks.$ZodCheck, run it as a check
59
- const checks = inst._zod.traits.has("$ZodCheck")
60
- ? [inst, ...(defChecks ?? [])]
61
- : defChecks?.length
62
- ? [...defChecks]
63
- : [];
64
- for (const ch of checks) {
65
- for (const fn of ch._zod.onattach) {
66
- fn(inst);
67
- }
68
- }
69
- if (checks.length === 0) {
70
- // deferred initializer inst._zod.parse is not yet defined
71
- (_a = inst._zod).deferred ?? (_a.deferred = []);
72
- inst._zod.deferred?.push(() => {
73
- inst._zod.run = inst._zod.parse;
74
- });
75
- }
76
- else {
77
- const runChecks = (payload, checks, ctx) => {
78
- if (payload.memo)
79
- return payload;
80
- let isAborted = util.aborted(payload);
81
- let asyncResult;
82
- for (const ch of checks) {
83
- if (ch._zod.def.when) {
84
- if (util.explicitlyAborted(payload))
85
- continue;
86
- const shouldRun = ch._zod.def.when(payload);
87
- if (!shouldRun)
88
- continue;
89
- }
90
- else if (isAborted) {
91
- continue;
92
- }
93
- const currLen = payload.issues.length;
94
- const _ = ch._zod.check(payload);
95
- if (_ instanceof Promise && ctx?.async === false) {
96
- throw new core.$ZodAsyncError();
97
- }
98
- if (asyncResult || _ instanceof Promise) {
99
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
100
- await _;
101
- const nextLen = payload.issues.length;
102
- if (nextLen === currLen)
103
- return;
104
- util.attachSchema(payload.issues, currLen, inst);
105
- if (!isAborted)
106
- isAborted = util.aborted(payload, currLen);
107
- });
108
- }
109
- else {
110
- const nextLen = payload.issues.length;
111
- if (nextLen === currLen)
112
- continue;
113
- util.attachSchema(payload.issues, currLen, inst);
114
- if (!isAborted)
115
- isAborted = util.aborted(payload, currLen);
116
- }
117
- }
118
- if (asyncResult) {
119
- return asyncResult.then(() => {
120
- return payload;
121
- });
122
- }
123
- return payload;
124
- };
125
- const handleCanaryResult = (canary, payload, ctx) => {
126
- // abort if the canary is aborted
127
- if (util.aborted(canary)) {
128
- canary.aborted = true;
129
- return canary;
130
- }
131
- // run checks first, then
132
- const checkResult = runChecks(payload, checks, ctx);
133
- if (checkResult instanceof Promise) {
134
- if (ctx.async === false)
135
- throw new core.$ZodAsyncError();
136
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
137
- }
138
- return inst._zod.parse(checkResult, ctx);
139
- };
140
- inst._zod.run = (payload, ctx) => {
141
- if (ctx.skipChecks) {
142
- return inst._zod.parse(payload, ctx);
143
- }
144
- if (ctx.direction === "backward") {
145
- // run canary initial pass (no checks)
146
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
147
- if (canary instanceof Promise) {
148
- return canary.then((canary) => {
149
- return handleCanaryResult(canary, payload, ctx);
150
- });
151
- }
152
- return handleCanaryResult(canary, payload, ctx);
153
- }
154
- // forward
155
- const result = inst._zod.parse(payload, ctx);
156
- if (result instanceof Promise) {
157
- if (ctx.async === false)
158
- throw new core.$ZodAsyncError();
159
- return result.then((result) => runChecks(result, checks, ctx));
160
- }
161
- return runChecks(result, checks, ctx);
162
- };
163
- }
164
- }, {
165
- // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
166
- get "~standard"() {
167
- return util.hide(this, "~standard", standardProps(this));
168
- },
169
- set "~standard"(value) {
170
- util.own(this, "~standard", value);
171
- },
172
- });
173
- /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
174
- // a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
175
- const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())) } : { value: r.value };
176
- async function validateAsync(inst, value) {
177
- const ctx = { async: true };
178
- return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
179
- }
180
- function standardProps(inst) {
181
- return {
182
- validate: (value) => {
183
- const ctx = { async: false };
184
- try {
185
- const r = inst._zod.run({ value, issues: [] }, ctx);
186
- if (!(r instanceof Promise))
187
- return toStandardResult(r, ctx);
188
- }
189
- catch (_) { }
190
- // async function so a synchronously throwing check rejects instead of escaping validate
191
- return validateAsync(inst, value);
192
- },
193
- vendor: "zod",
194
- version: 1,
195
- };
196
- }
197
- var util_js_1 = require("./util.cjs");
198
- Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
199
- exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
200
- exports.$ZodType.init(inst, def);
201
- // a format's own pattern, else unbounded; a template literal derives the check-aware form itself
202
- inst._zod.pattern = def.pattern ?? regexes.anyString;
203
- inst._zod.parse = (payload, _) => {
204
- if (def.coerce)
205
- try {
206
- payload.value = String(payload.value);
207
- }
208
- catch (_) { }
209
- if (typeof payload.value === "string")
210
- return payload;
211
- payload.issues.push({
212
- expected: "string",
213
- code: "invalid_type",
214
- input: payload.value,
215
- inst,
216
- });
217
- return payload;
218
- };
219
- });
220
- exports.$ZodStringFormat = core.$constructor("$ZodStringFormat", (inst, def) => {
221
- // check initialization must come first
222
- checks.$ZodCheckStringFormat.init(inst, def);
223
- exports.$ZodString.init(inst, def);
224
- });
225
- exports.$ZodGUID = core.$constructor("$ZodGUID", (inst, def) => {
226
- def.pattern ?? (def.pattern = regexes.guid);
227
- exports.$ZodStringFormat.init(inst, def);
228
- });
229
- exports.$ZodUUID = core.$constructor("$ZodUUID", (inst, def) => {
230
- if (def.version) {
231
- const versionMap = {
232
- v1: 1,
233
- v2: 2,
234
- v3: 3,
235
- v4: 4,
236
- v5: 5,
237
- v6: 6,
238
- v7: 7,
239
- v8: 8,
240
- };
241
- const v = versionMap[def.version];
242
- if (v === undefined)
243
- throw new Error(`Invalid UUID version: "${def.version}"`);
244
- def.pattern ?? (def.pattern = regexes.uuid(v));
245
- }
246
- else
247
- def.pattern ?? (def.pattern = regexes.uuid());
248
- exports.$ZodStringFormat.init(inst, def);
249
- });
250
- exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
251
- def.pattern ?? (def.pattern = regexes.email);
252
- exports.$ZodStringFormat.init(inst, def);
253
- });
254
- /** The `://` guard rejected the input before the URL constructor saw it. */
255
- exports.URL_BAD_FORMAT = 1;
256
- /** The URL parser rejected the input. */
257
- exports.URL_UNPARSEABLE = 2;
258
- function canParseURL(input) {
259
- try {
260
- if (typeof URL !== "undefined" && typeof URL.canParse === "function")
261
- return URL.canParse(input);
262
- new URL(input);
263
- return true;
264
- }
265
- catch {
266
- return false;
267
- }
268
- }
269
- function validateURL(trimmed, def) {
270
- if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
271
- return canParseURL(trimmed) || exports.URL_UNPARSEABLE;
272
- }
273
- return parseURLObject(trimmed, def);
274
- }
275
- /** Parses a URL while preserving the non-normalizing HTTP guard. */
276
- function parseURLObject(trimmed, def) {
277
- // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
278
- if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
279
- return exports.URL_BAD_FORMAT;
280
- }
281
- try {
282
- if (typeof URL !== "undefined") {
283
- const URLStatic = URL;
284
- if (typeof URLStatic.parse === "function")
285
- return URLStatic.parse(trimmed) ?? exports.URL_UNPARSEABLE;
286
- }
287
- // @ts-ignore
288
- return new URL(trimmed);
289
- }
290
- catch {
291
- return exports.URL_UNPARSEABLE;
292
- }
293
- }
294
- const asciiTabOrNewline = /[\t\n\r]/g;
295
- /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
296
- function stripTabAndNewline(value) {
297
- return value.replace(asciiTabOrNewline, "");
298
- }
299
- function urlHostnameOk(url, hostname) {
300
- hostname.lastIndex = 0;
301
- return hostname.test(url.hostname);
302
- }
303
- function urlProtocolOk(url, protocol) {
304
- protocol.lastIndex = 0;
305
- return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
306
- }
307
- exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
308
- exports.$ZodStringFormat.init(inst, def);
309
- inst._zod.check = (payload) => {
310
- try {
311
- // Trim whitespace from input
312
- const trimmed = payload.value.trim();
313
- const url = validateURL(trimmed, def);
314
- if (url === exports.URL_BAD_FORMAT) {
315
- payload.issues.push({
316
- code: "invalid_format",
317
- format: "url",
318
- note: "Invalid URL format",
319
- input: payload.value,
320
- inst,
321
- continue: !def.abort,
322
- });
323
- return;
324
- }
325
- if (url === exports.URL_UNPARSEABLE) {
326
- payload.issues.push({
327
- code: "invalid_format",
328
- format: "url",
329
- input: payload.value,
330
- inst,
331
- continue: !def.abort,
332
- });
333
- return;
334
- }
335
- if (url === true) {
336
- payload.value = stripTabAndNewline(trimmed);
337
- return;
338
- }
339
- if (def.hostname && !urlHostnameOk(url, def.hostname)) {
340
- payload.issues.push({
341
- code: "invalid_format",
342
- format: "url",
343
- note: "Invalid hostname",
344
- pattern: def.hostname.source,
345
- input: payload.value,
346
- inst,
347
- continue: !def.abort,
348
- });
349
- }
350
- if (def.protocol && !urlProtocolOk(url, def.protocol)) {
351
- payload.issues.push({
352
- code: "invalid_format",
353
- format: "url",
354
- note: "Invalid protocol",
355
- pattern: def.protocol.source,
356
- input: payload.value,
357
- inst,
358
- continue: !def.abort,
359
- });
360
- }
361
- // Set the output value based on normalize flag
362
- payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
363
- return;
364
- }
365
- catch (_) {
366
- payload.issues.push({
367
- code: "invalid_format",
368
- format: "url",
369
- input: payload.value,
370
- inst,
371
- continue: !def.abort,
372
- });
373
- }
374
- };
375
- });
376
- exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
377
- def.pattern ?? (def.pattern = regexes.emoji());
378
- exports.$ZodStringFormat.init(inst, def);
379
- });
380
- exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
381
- if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
382
- throw new Error(`Invalid nanoid length: ${def.length}`);
383
- def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
384
- exports.$ZodStringFormat.init(inst, def);
385
- });
386
- /**
387
- * @deprecated CUID v1 is deprecated by its authors due to information leakage
388
- * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
389
- * See https://github.com/paralleldrive/cuid.
390
- */
391
- exports.$ZodCUID = core.$constructor("$ZodCUID", (inst, def) => {
392
- def.pattern ?? (def.pattern = regexes.cuid);
393
- exports.$ZodStringFormat.init(inst, def);
394
- });
395
- exports.$ZodCUID2 = core.$constructor("$ZodCUID2", (inst, def) => {
396
- def.pattern ?? (def.pattern = regexes.cuid2);
397
- exports.$ZodStringFormat.init(inst, def);
398
- });
399
- exports.$ZodULID = core.$constructor("$ZodULID", (inst, def) => {
400
- def.pattern ?? (def.pattern = regexes.ulid);
401
- exports.$ZodStringFormat.init(inst, def);
402
- });
403
- exports.$ZodXID = core.$constructor("$ZodXID", (inst, def) => {
404
- def.pattern ?? (def.pattern = regexes.xid);
405
- exports.$ZodStringFormat.init(inst, def);
406
- });
407
- exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
408
- def.pattern ?? (def.pattern = regexes.ksuid);
409
- exports.$ZodStringFormat.init(inst, def);
410
- });
411
- exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
412
- def.pattern ?? (def.pattern = regexes.datetime(def));
413
- exports.$ZodStringFormat.init(inst, def);
414
- });
415
- exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
416
- def.pattern ?? (def.pattern = regexes.date);
417
- exports.$ZodStringFormat.init(inst, def);
418
- });
419
- exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
420
- def.pattern ?? (def.pattern = regexes.time(def));
421
- exports.$ZodStringFormat.init(inst, def);
422
- });
423
- exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
424
- def.pattern ?? (def.pattern = regexes.duration);
425
- exports.$ZodStringFormat.init(inst, def);
426
- });
427
- exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
428
- def.pattern ?? (def.pattern = regexes.ipv4);
429
- exports.$ZodStringFormat.init(inst, def);
430
- });
431
- /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
432
- const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
433
- function isValidIPv6(value) {
434
- if (!ipv6Alphabet.test(value))
435
- return false;
436
- return canParseURL(`http://[${value}]`);
437
- }
438
- exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
439
- def.pattern ?? (def.pattern = regexes.ipv6);
440
- exports.$ZodStringFormat.init(inst, def);
441
- inst._zod.check = (payload) => {
442
- if (!isValidIPv6(payload.value)) {
443
- payload.issues.push({
444
- code: "invalid_format",
445
- format: "ipv6",
446
- input: payload.value,
447
- inst,
448
- continue: !def.abort,
449
- });
450
- }
451
- };
452
- });
453
- exports.$ZodMAC = core.$constructor("$ZodMAC", (inst, def) => {
454
- def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
455
- exports.$ZodStringFormat.init(inst, def);
456
- });
457
- exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
458
- def.pattern ?? (def.pattern = regexes.cidrv4);
459
- exports.$ZodStringFormat.init(inst, def);
460
- });
461
- function isValidCIDRv6(value) {
462
- const parts = value.split("/");
463
- if (parts.length !== 2)
464
- return false;
465
- const [address, prefix] = parts;
466
- if (!prefix)
467
- return false;
468
- const prefixNum = Number(prefix);
469
- if (`${prefixNum}` !== prefix)
470
- return false;
471
- if (prefixNum < 0 || prefixNum > 128)
472
- return false;
473
- return isValidIPv6(address);
474
- }
475
- exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
476
- def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
477
- exports.$ZodStringFormat.init(inst, def);
478
- inst._zod.check = (payload) => {
479
- if (!isValidCIDRv6(payload.value)) {
480
- payload.issues.push({
481
- code: "invalid_format",
482
- format: "cidrv6",
483
- input: payload.value,
484
- inst,
485
- continue: !def.abort,
486
- });
487
- }
488
- };
489
- });
490
- ////////////////////////////// ZodBase64 //////////////////////////////
491
- function isValidBase64(data) {
492
- if (data === "")
493
- return true;
494
- // atob ignores whitespace, so reject it up front.
495
- if (/\s/.test(data))
496
- return false;
497
- if (data.length % 4 !== 0)
498
- return false;
499
- try {
500
- // @ts-ignore
501
- atob(data);
502
- return true;
503
- }
504
- catch {
505
- return false;
506
- }
507
- }
508
- // lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
509
- exports.base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
510
- exports.$ZodBase64 = core.$constructor("$ZodBase64", (inst, def) => {
511
- def.pattern ?? (def.pattern = exports.base64Charset);
512
- exports.$ZodStringFormat.init(inst, def);
513
- inst._zod.check = (payload) => {
514
- if (isValidBase64(payload.value))
515
- return;
516
- payload.issues.push({
517
- code: "invalid_format",
518
- format: "base64",
519
- input: payload.value,
520
- inst,
521
- continue: !def.abort,
522
- });
523
- };
524
- });
525
- ////////////////////////////// ZodBase64URL //////////////////////////////
526
- // lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
527
- exports.base64urlCharset = /^[A-Za-z0-9_-]*$/;
528
- function isValidBase64URL(data) {
529
- if (!exports.base64urlCharset.test(data))
530
- return false;
531
- const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
532
- const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
533
- return isValidBase64(padded);
534
- }
535
- exports.$ZodBase64URL = core.$constructor("$ZodBase64URL", (inst, def) => {
536
- def.pattern ?? (def.pattern = exports.base64urlCharset);
537
- exports.$ZodStringFormat.init(inst, def);
538
- inst._zod.check = (payload) => {
539
- if (isValidBase64URL(payload.value))
540
- return;
541
- payload.issues.push({
542
- code: "invalid_format",
543
- format: "base64url",
544
- input: payload.value,
545
- inst,
546
- continue: !def.abort,
547
- });
548
- };
549
- });
550
- exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
551
- def.pattern ?? (def.pattern = regexes.e164);
552
- exports.$ZodStringFormat.init(inst, def);
553
- });
554
- ////////////////////////////// ZodCreditCard //////////////////////////////
555
- const CC_SANITIZE = /[- ]/g;
556
- /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
557
- function isLuhnAlgo(digits) {
558
- let length = digits.length;
559
- let bit = 1;
560
- let sum = 0;
561
- while (length) {
562
- const value = digits.charCodeAt(--length) - 48;
563
- bit ^= 1;
564
- sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
565
- }
566
- return sum % 10 === 0;
567
- }
568
- function isValidCreditCard(input) {
569
- if (!regexes.creditCard.test(input))
570
- return false;
571
- return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
572
- }
573
- exports.$ZodCreditCard = core.$constructor("$ZodCreditCard", (inst, def) => {
574
- // Shape only — the Luhn check below is not expressible as a pattern, so consumers of `pattern` (JSON Schema, template literals) get the length and separator rules alone.
575
- def.pattern ?? (def.pattern = regexes.creditCard);
576
- exports.$ZodStringFormat.init(inst, def);
577
- inst._zod.check = (payload) => {
578
- if (isValidCreditCard(payload.value))
579
- return;
580
- payload.issues.push({
581
- code: "invalid_format",
582
- format: "credit_card",
583
- input: payload.value,
584
- inst,
585
- continue: !def.abort,
586
- });
587
- };
588
- });
589
- ////////////////////////////// ZodIBAN //////////////////////////////
590
- // iso 7064 mod 97-10 checksum without BigInt
591
- function isIso7064Mod97(iban) {
592
- let remainder = 0;
593
- const len = iban.length;
594
- for (let i = 4; i < len; i++) {
595
- const code = iban.charCodeAt(i);
596
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
597
- }
598
- for (let i = 0; i < 4; i++) {
599
- const code = iban.charCodeAt(i);
600
- remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
601
- }
602
- return remainder === 1;
603
- }
604
- function isValidIBAN(input) {
605
- if (!regexes.iban.test(input))
606
- return false;
607
- return isIso7064Mod97(input);
608
- }
609
- exports.$ZodIBAN = core.$constructor("$ZodIBAN", (inst, def) => {
610
- // shape only — checksum is not expressible as a pattern
611
- def.pattern ?? (def.pattern = regexes.iban);
612
- exports.$ZodStringFormat.init(inst, def);
613
- inst._zod.check = (payload) => {
614
- if (isValidIBAN(payload.value))
615
- return;
616
- payload.issues.push({
617
- code: "invalid_format",
618
- format: "iban",
619
- input: payload.value,
620
- inst,
621
- continue: !def.abort,
622
- });
623
- };
624
- });
625
- ////////////////////////////// ZodJWT //////////////////////////////
626
- function isValidJWT(token, algorithm = null) {
627
- try {
628
- const tokensParts = token.split(".");
629
- if (tokensParts.length !== 3)
630
- return false;
631
- const [header] = tokensParts;
632
- if (!header)
633
- return false;
634
- // @ts-ignore
635
- const parsedHeader = JSON.parse(atob(header));
636
- if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
637
- return false;
638
- if (!parsedHeader.alg)
639
- return false;
640
- if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
641
- return false;
642
- return true;
643
- }
644
- catch {
645
- return false;
646
- }
647
- }
648
- exports.$ZodJWT = core.$constructor("$ZodJWT", (inst, def) => {
649
- exports.$ZodStringFormat.init(inst, def);
650
- inst._zod.check = (payload) => {
651
- if (isValidJWT(payload.value, def.alg))
652
- return;
653
- payload.issues.push({
654
- code: "invalid_format",
655
- format: "jwt",
656
- input: payload.value,
657
- inst,
658
- continue: !def.abort,
659
- });
660
- };
661
- });
662
- exports.$ZodCustomStringFormat = core.$constructor("$ZodCustomStringFormat", (inst, def) => {
663
- exports.$ZodStringFormat.init(inst, def);
664
- inst._zod.check = (payload) => {
665
- if (def.fn(payload.value))
666
- return;
667
- payload.issues.push({
668
- code: "invalid_format",
669
- format: def.format,
670
- input: payload.value,
671
- inst,
672
- continue: !def.abort,
673
- });
674
- };
675
- });
676
- exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
677
- exports.$ZodType.init(inst, def);
678
- inst._zod.pattern = regexes.number;
679
- inst._zod.parse = (payload, _ctx) => {
680
- if (def.coerce)
681
- try {
682
- payload.value = Number(payload.value);
683
- }
684
- catch (_) { }
685
- const input = payload.value;
686
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
687
- return payload;
688
- }
689
- const received = typeof input === "number"
690
- ? Number.isNaN(input)
691
- ? "NaN"
692
- : !Number.isFinite(input)
693
- ? String(input)
694
- : undefined
695
- : undefined;
696
- payload.issues.push({
697
- expected: "number",
698
- code: "invalid_type",
699
- input,
700
- inst,
701
- ...(received ? { received } : {}),
702
- });
703
- return payload;
704
- };
705
- });
706
- exports.$ZodNumberFormat = core.$constructor("$ZodNumberFormat", (inst, def) => {
707
- checks.$ZodCheckNumberFormat.init(inst, def);
708
- exports.$ZodNumber.init(inst, def); // no format checks
709
- });
710
- exports.$ZodBoolean = core.$constructor("$ZodBoolean", (inst, def) => {
711
- exports.$ZodType.init(inst, def);
712
- inst._zod.pattern = regexes.boolean;
713
- inst._zod.parse = (payload, _ctx) => {
714
- if (def.coerce)
715
- try {
716
- payload.value = Boolean(payload.value);
717
- }
718
- catch (_) { }
719
- const input = payload.value;
720
- if (typeof input === "boolean")
721
- return payload;
722
- payload.issues.push({
723
- expected: "boolean",
724
- code: "invalid_type",
725
- input,
726
- inst,
727
- });
728
- return payload;
729
- };
730
- });
731
- exports.$ZodBigInt = core.$constructor("$ZodBigInt", (inst, def) => {
732
- exports.$ZodType.init(inst, def);
733
- inst._zod.pattern = regexes.bigint;
734
- inst._zod.parse = (payload, _ctx) => {
735
- if (def.coerce)
736
- try {
737
- payload.value = BigInt(payload.value);
738
- }
739
- catch (_) { }
740
- if (typeof payload.value === "bigint")
741
- return payload;
742
- payload.issues.push({
743
- expected: "bigint",
744
- code: "invalid_type",
745
- input: payload.value,
746
- inst,
747
- });
748
- return payload;
749
- };
750
- });
751
- exports.$ZodBigIntFormat = core.$constructor("$ZodBigIntFormat", (inst, def) => {
752
- checks.$ZodCheckBigIntFormat.init(inst, def);
753
- exports.$ZodBigInt.init(inst, def); // no format checks
754
- });
755
- exports.$ZodSymbol = core.$constructor("$ZodSymbol", (inst, def) => {
756
- exports.$ZodType.init(inst, def);
757
- inst._zod.parse = (payload, _ctx) => {
758
- const input = payload.value;
759
- if (typeof input === "symbol")
760
- return payload;
761
- payload.issues.push({
762
- expected: "symbol",
763
- code: "invalid_type",
764
- input,
765
- inst,
766
- });
767
- return payload;
768
- };
769
- });
770
- exports.$ZodUndefined = core.$constructor("$ZodUndefined", (inst, def) => {
771
- exports.$ZodType.init(inst, def);
772
- inst._zod.pattern = regexes.undefined;
773
- inst._zod.values = new Set([undefined]);
774
- inst._zod.parse = (payload, _ctx) => {
775
- const input = payload.value;
776
- if (typeof input === "undefined")
777
- return payload;
778
- payload.issues.push({
779
- expected: "undefined",
780
- code: "invalid_type",
781
- input,
782
- inst,
783
- });
784
- return payload;
785
- };
786
- });
787
- exports.$ZodNull = core.$constructor("$ZodNull", (inst, def) => {
788
- exports.$ZodType.init(inst, def);
789
- inst._zod.pattern = regexes.null;
790
- inst._zod.values = new Set([null]);
791
- inst._zod.parse = (payload, _ctx) => {
792
- const input = payload.value;
793
- if (input === null)
794
- return payload;
795
- payload.issues.push({
796
- expected: "null",
797
- code: "invalid_type",
798
- input,
799
- inst,
800
- });
801
- return payload;
802
- };
803
- });
804
- exports.$ZodAny = core.$constructor("$ZodAny", (inst, def) => {
805
- exports.$ZodType.init(inst, def);
806
- inst._zod.parse = (payload) => payload;
807
- });
808
- exports.$ZodUnknown = core.$constructor("$ZodUnknown", (inst, def) => {
809
- exports.$ZodType.init(inst, def);
810
- inst._zod.parse = (payload) => payload;
811
- });
812
- exports.$ZodNever = core.$constructor("$ZodNever", (inst, def) => {
813
- exports.$ZodType.init(inst, def);
814
- inst._zod.parse = (payload, _ctx) => {
815
- payload.issues.push({
816
- expected: "never",
817
- code: "invalid_type",
818
- input: payload.value,
819
- inst,
820
- });
821
- return payload;
822
- };
823
- });
824
- exports.$ZodVoid = core.$constructor("$ZodVoid", (inst, def) => {
825
- exports.$ZodType.init(inst, def);
826
- inst._zod.parse = (payload, _ctx) => {
827
- const input = payload.value;
828
- if (typeof input === "undefined")
829
- return payload;
830
- payload.issues.push({
831
- expected: "void",
832
- code: "invalid_type",
833
- input,
834
- inst,
835
- });
836
- return payload;
837
- };
838
- });
839
- exports.$ZodDate = core.$constructor("$ZodDate", (inst, def) => {
840
- exports.$ZodType.init(inst, def);
841
- inst._zod.parse = (payload, _ctx) => {
842
- if (def.coerce) {
843
- try {
844
- payload.value = new Date(payload.value);
845
- }
846
- catch (_err) { }
847
- }
848
- const input = payload.value;
849
- const isDate = input instanceof Date;
850
- const isValidDate = isDate && !Number.isNaN(input.getTime());
851
- if (isValidDate)
852
- return payload;
853
- payload.issues.push({
854
- expected: "date",
855
- code: "invalid_type",
856
- input,
857
- ...(isDate ? { received: "Invalid Date" } : {}),
858
- inst,
859
- });
860
- return payload;
861
- };
862
- });
863
- // an oversized container fails its leading size checks before any element is parsed
864
- function capSize(inst, size) {
865
- const caps = util.sizeCaps(inst._zod.def.checks);
866
- if (!caps.length)
867
- return;
868
- const cap = Math.min(...caps.map((c) => c[0]));
869
- const parse = inst._zod.parse;
870
- inst._zod.parse = (payload, ctx) => {
871
- const n = size(payload.value);
872
- if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
873
- for (const [max, ch] of util.sizeCaps(inst._zod.def.checks)) {
874
- if (n > max && ch._zod.def.when(payload)) {
875
- const start = payload.issues.length;
876
- ch._zod.check(payload);
877
- // the value is still the raw input, so no later check may read it
878
- payload.issues[start].continue = false;
879
- util.attachSchema(payload.issues, start, inst);
880
- return payload;
881
- }
882
- }
883
- }
884
- return parse(payload, ctx);
885
- };
886
- }
887
- const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
888
- const mapSize = (input) => (input instanceof Map ? input.size : -1);
889
- const setSize = (input) => (input instanceof Set ? input.size : -1);
890
- function handleArrayResult(result, final, index) {
891
- if (result.issues.length) {
892
- final.issues.push(...util.prefixIssues(index, result.issues));
893
- }
894
- final.value[index] = result.value;
895
- }
896
- exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
897
- exports.$ZodType.init(inst, def);
898
- const memo = core.globalConfig.memoizer;
899
- memo?.attach(inst);
900
- inst._zod.parse = (payload, ctx) => {
901
- const input = payload.value;
902
- if (!Array.isArray(input)) {
903
- payload.issues.push({
904
- expected: "array",
905
- code: "invalid_type",
906
- input,
907
- inst,
908
- });
909
- return payload;
910
- }
911
- payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
912
- const proms = [];
913
- const abortEarly = ctx?.abortEarly;
914
- for (let i = 0; i < input.length; i++) {
915
- const item = input[i];
916
- const result = def.element._zod.run({
917
- value: item,
918
- issues: [],
919
- }, ctx);
920
- if (result instanceof Promise) {
921
- proms.push(result.then((result) => handleArrayResult(result, payload, i)));
922
- }
923
- else {
924
- handleArrayResult(result, payload, i);
925
- // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
926
- if (abortEarly && result.issues.length !== 0 && util.aborted(result))
927
- break;
928
- }
929
- }
930
- if (proms.length) {
931
- return Promise.all(proms).then(() => payload);
932
- }
933
- return payload; //handleArrayResultsAsync(parseResults, final);
934
- };
935
- capSize(inst, arraySize);
936
- });
937
- function handlePropertyResult(result, final, key, input, optin, optout) {
938
- const isPresent = key in input;
939
- const isOptionalOut = optout === "optional";
940
- // The middle rung means "absence permitted, nothing supplied in its place", so an absent key contributes nothing — whatever the schema made of `undefined` is invented, not substituted. Only `optional` reaches this with a value: `defaulted` substitutes, and a schema that isn't optional-out has to keep the key.
941
- if (!isPresent && isOptionalOut && optin === "optional") {
942
- return;
943
- }
944
- if (result.issues.length) {
945
- // For optional-in/out schemas, ignore errors on absent keys.
946
- if (optin !== undefined && isOptionalOut && !isPresent) {
947
- return;
948
- }
949
- final.issues.push(...util.prefixIssues(key, result.issues));
950
- }
951
- if (!isPresent && optin === undefined) {
952
- if (!result.issues.length) {
953
- final.issues.push({
954
- code: "invalid_type",
955
- expected: "nonoptional",
956
- input: undefined,
957
- path: [key],
958
- });
959
- }
960
- return;
961
- }
962
- if (result.value === undefined) {
963
- if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
964
- final.value[key] = undefined;
965
- }
966
- }
967
- else {
968
- final.value[key] = result.value;
969
- }
970
- }
971
- // one shared instance; a fresh [] per schema cost 56 bytes retained
972
- const NO_SYMBOL_KEYS = [];
973
- function normalizeDef(def) {
974
- const keys = Object.keys(def.shape);
975
- const ownSymbols = Object.getOwnPropertySymbols(def.shape);
976
- const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
977
- // aliases `keys` when there are no symbols, so a string-only shape keeps one array
978
- const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
979
- for (const k of allKeys) {
980
- if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
981
- throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
982
- }
983
- }
984
- const okeys = util.optionalKeys(def.shape);
985
- return {
986
- ...def,
987
- allKeys,
988
- symbolKeys,
989
- // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
990
- keySet: new Set(keys),
991
- numKeys: keys.length,
992
- optionalKeys: new Set(okeys),
993
- };
994
- }
995
- function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
996
- const unrecognized = [];
997
- const keySet = def.keySet;
998
- const _catchall = def.catchall._zod;
999
- const t = _catchall.def.type;
1000
- const optin = _catchall.optin;
1001
- const optout = _catchall.optout;
1002
- // starts at 0, not the current length: the shape phase already ran and may have aborted
1003
- let seen = 0;
1004
- for (const key in input) {
1005
- if (abortEarly && payload.issues.length !== seen) {
1006
- if (util.aborted(payload, seen))
1007
- break;
1008
- seen = payload.issues.length;
1009
- }
1010
- // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
1011
- if (keySet.has(key))
1012
- continue;
1013
- // Don't copy an undeclared __proto__ into the result; assignment to a plain {} would replace the result prototype. But in strict mode it is still an unknown key, so report it before skipping.
1014
- if (key === "__proto__") {
1015
- if (t === "never")
1016
- unrecognized.push(key);
1017
- continue;
1018
- }
1019
- if (t === "never") {
1020
- unrecognized.push(key);
1021
- continue;
1022
- }
1023
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1024
- if (r instanceof Promise) {
1025
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1026
- }
1027
- else {
1028
- handlePropertyResult(r, payload, key, input, optin, optout);
1029
- }
1030
- }
1031
- if (unrecognized.length) {
1032
- payload.issues.push({
1033
- code: "unrecognized_keys",
1034
- keys: unrecognized,
1035
- input,
1036
- inst,
1037
- // Describes the shape of the input, not the validity of the parsed value, so it never aborts. The parse still fails; the schema's own checks just get to run first, and an enclosing intersection can reconcile the key against a sibling operand.
1038
- continue: true,
1039
- });
1040
- }
1041
- if (!proms.length)
1042
- return payload;
1043
- return Promise.all(proms).then(() => {
1044
- return payload;
1045
- });
1046
- }
1047
- exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
1048
- // requires cast because technically $ZodObject doesn't extend
1049
- exports.$ZodType.init(inst, def);
1050
- const desc = Object.getOwnPropertyDescriptor(def, "shape");
1051
- // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
1052
- const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
1053
- if (sh) {
1054
- // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
1055
- const get = () => {
1056
- const newSh = { ...sh };
1057
- Object.defineProperty(def, "shape", { value: newSh });
1058
- get.raw = newSh;
1059
- return newSh;
1060
- };
1061
- get.raw = sh;
1062
- Object.defineProperty(def, "shape", { get });
1063
- }
1064
- const _normalized = util.cached(() => normalizeDef(def));
1065
- util.defineLazyInternal(inst, "propValues", (zod) => {
1066
- const shape = zod.def.shape;
1067
- const propValues = {};
1068
- for (const key in shape) {
1069
- const field = shape[key]._zod;
1070
- if (field.values) {
1071
- if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
1072
- util.assignProp(propValues, key, new Set());
1073
- }
1074
- for (const v of field.values)
1075
- propValues[key].add(v);
1076
- // An omittable slot reads back as undefined at a discriminator lookup, so it has to claim undefined: two options that can both omit the key are not discriminable on it.
1077
- if (field.optin !== undefined)
1078
- propValues[key].add(undefined);
1079
- }
1080
- }
1081
- return propValues;
1082
- });
1083
- const isObject = util.isObject;
1084
- const catchall = def.catchall;
1085
- let value;
1086
- const memo = core.globalConfig.memoizer;
1087
- memo?.attach(inst);
1088
- inst._zod.parse = (payload, ctx) => {
1089
- value ?? (value = _normalized.value);
1090
- const input = payload.value;
1091
- if (!isObject(input)) {
1092
- payload.issues.push({
1093
- expected: "object",
1094
- code: "invalid_type",
1095
- input,
1096
- inst,
1097
- });
1098
- return payload;
1099
- }
1100
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1101
- const proms = [];
1102
- const shape = value.shape;
1103
- const abortEarly = ctx?.abortEarly;
1104
- let seen = payload.issues.length;
1105
- for (const key of value.allKeys) {
1106
- if (abortEarly && payload.issues.length !== seen) {
1107
- if (util.aborted(payload, seen))
1108
- break;
1109
- seen = payload.issues.length;
1110
- }
1111
- if (key === "__proto__")
1112
- continue;
1113
- const el = shape[key];
1114
- const optin = el._zod.optin;
1115
- const optout = el._zod.optout;
1116
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1117
- if (r instanceof Promise) {
1118
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1119
- }
1120
- else {
1121
- handlePropertyResult(r, payload, key, input, optin, optout);
1122
- }
1123
- }
1124
- if (!catchall) {
1125
- return proms.length ? Promise.all(proms).then(() => payload) : payload;
1126
- }
1127
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1128
- };
1129
- });
1130
- exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
1131
- // requires cast because technically $ZodObject doesn't extend
1132
- exports.$ZodObject.init(inst, def);
1133
- const superParse = inst._zod.parse;
1134
- const _normalized = util.cached(() => normalizeDef(def));
1135
- const memo = core.globalConfig.memoizer;
1136
- const generateFastpass = (shape) => {
1137
- const normalized = _normalized.value;
1138
- const syms = normalized.symbolKeys;
1139
- // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
1140
- const doc = new doc_js_1.Doc(["payload", "ctx"], { shape, inst, memo, syms });
1141
- const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1142
- // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
1143
- const prefixStr = (id, k) => `
1144
- let ${id}_ab = false;
1145
- for (let i = 0; i < ${id}.issues.length; i++) {
1146
- const iss = ${id}.issues[i];
1147
- iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
1148
- payload.issues.push(iss);
1149
- if (iss.continue !== true) ${id}_ab = true;
1150
- }
1151
- if (${id}_ab && ctx && ctx.abortEarly) {
1152
- payload.value = newResult;
1153
- return payload;
1154
- }`;
1155
- doc.write(`const input = payload.value;`);
1156
- const ids = Object.create(null);
1157
- let counter = 0;
1158
- for (const key of normalized.allKeys) {
1159
- ids[key] = `key_${counter++}`;
1160
- }
1161
- // A: preserve key order {
1162
- doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
1163
- for (const key of normalized.allKeys) {
1164
- if (key === "__proto__")
1165
- continue;
1166
- const id = ids[key];
1167
- const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
1168
- const isPresent = `${k} in input`;
1169
- const schema = shape[key];
1170
- const optin = schema?._zod?.optin;
1171
- const isOptionalIn = optin !== undefined;
1172
- const isOptionalOut = schema?._zod?.optout === "optional";
1173
- doc.write(`const ${id} = ${parseStr(k)};`);
1174
- if (isOptionalIn && isOptionalOut) {
1175
- // For optional-in/out schemas, ignore errors on absent keys — and, like the interpreted path, drop the value produced alongside them. The middle rung goes further: it permits absence without supplying anything in its place, so an absent key contributes nothing at all.
1176
- const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
1177
- doc.write(`
1178
- const ${id}_present = ${isPresent};
1179
- if (!${id}.issues.length || ${id}_present) {
1180
- if (${id}.issues.length) {${prefixStr(id, k)}
1181
- }
1182
-
1183
- if (${assign}) {
1184
- newResult[${k}] = ${id}.value;
1185
- }
1186
- }
1187
-
1188
- `);
1189
- }
1190
- else if (!isOptionalIn) {
1191
- doc.write(`
1192
- const ${id}_present = ${isPresent};
1193
- if (${id}.issues.length) {${prefixStr(id, k)}
1194
- }
1195
- if (!${id}_present && !${id}.issues.length) {
1196
- payload.issues.push({
1197
- code: "invalid_type",
1198
- expected: "nonoptional",
1199
- input: undefined,
1200
- path: [${k}]
1201
- });
1202
- if (ctx && ctx.abortEarly) {
1203
- payload.value = newResult;
1204
- return payload;
1205
- }
1206
- }
1207
-
1208
- if (${id}_present) {
1209
- newResult[${k}] = ${id}.value;
1210
- }
1211
-
1212
- `);
1213
- }
1214
- else {
1215
- doc.write(`
1216
- if (${id}.issues.length) {${prefixStr(id, k)}
1217
- }
1218
- `);
1219
- if (optin === "defaulted") {
1220
- doc.write(`newResult[${k}] = ${id}.value;`);
1221
- }
1222
- else {
1223
- doc.write(`
1224
- if (${id}.value !== undefined || ${isPresent}) {
1225
- newResult[${k}] = ${id}.value;
1226
- }
1227
- `);
1228
- }
1229
- }
1230
- }
1231
- doc.write(`payload.value = newResult;`);
1232
- doc.write(`return payload;`);
1233
- // closing `shape` in is what pays: turbofan specializes the parser against that one shape object, so every `shape[k]._zod.run` folds to a known callee. as a parameter it stays a generic load and measures 13% slower even with the forwarding frame gone
1234
- return doc.compile();
1235
- };
1236
- let fastpass;
1237
- const isObject = util.isObject;
1238
- const jit = !core.globalConfig.jitless;
1239
- const allowsEval = util.allowsEval;
1240
- const fastEnabled = jit && allowsEval.value; // && !def.catchall;
1241
- const catchall = def.catchall;
1242
- let value;
1243
- inst._zod.parse = (payload, ctx) => {
1244
- value ?? (value = _normalized.value);
1245
- const input = payload.value;
1246
- if (!isObject(input)) {
1247
- payload.issues.push({
1248
- expected: "object",
1249
- code: "invalid_type",
1250
- input,
1251
- inst,
1252
- });
1253
- return payload;
1254
- }
1255
- if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1256
- // always synchronous
1257
- if (!fastpass)
1258
- fastpass = generateFastpass(def.shape);
1259
- payload = fastpass(payload, ctx);
1260
- if (!catchall)
1261
- return payload;
1262
- return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1263
- }
1264
- return superParse(payload, ctx);
1265
- };
1266
- });
1267
- function handleUnionResults(results, final, inst, ctx) {
1268
- for (const result of results) {
1269
- if (result.issues.length === 0) {
1270
- final.value = result.value;
1271
- return final;
1272
- }
1273
- }
1274
- const nonaborted = results.filter((r) => !util.aborted(r));
1275
- if (nonaborted.length === 1) {
1276
- final.value = nonaborted[0].value;
1277
- return nonaborted[0];
1278
- }
1279
- final.issues.push({
1280
- code: "invalid_union",
1281
- input: final.value,
1282
- inst,
1283
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1284
- });
1285
- return final;
1286
- }
1287
- exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
1288
- exports.$ZodType.init(inst, def);
1289
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
1290
- ? "defaulted"
1291
- : zod.def.options.some((o) => o._zod.optin !== undefined)
1292
- ? "optional"
1293
- : undefined);
1294
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1295
- util.defineLazyInternal(inst, "values", (zod) => {
1296
- if (zod.def.options.every((o) => o._zod.values)) {
1297
- return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1298
- }
1299
- return undefined;
1300
- });
1301
- util.defineLazyInternal(inst, "pattern", (zod) => {
1302
- if (zod.def.options.every((o) => o._zod.pattern)) {
1303
- const patterns = zod.def.options.map((o) => o._zod.pattern);
1304
- return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
1305
- }
1306
- return undefined;
1307
- });
1308
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1309
- inst._zod.parse = (payload, ctx) => {
1310
- if (first) {
1311
- return first(payload, ctx);
1312
- }
1313
- let async = false;
1314
- const results = [];
1315
- for (const option of def.options) {
1316
- const result = option._zod.run({
1317
- value: payload.value,
1318
- issues: [],
1319
- }, ctx);
1320
- if (result instanceof Promise) {
1321
- results.push(result);
1322
- async = true;
1323
- }
1324
- else {
1325
- if (result.issues.length === 0)
1326
- return result;
1327
- results.push(result);
1328
- }
1329
- }
1330
- if (!async)
1331
- return handleUnionResults(results, payload, inst, ctx);
1332
- return Promise.all(results).then((results) => {
1333
- return handleUnionResults(results, payload, inst, ctx);
1334
- });
1335
- };
1336
- });
1337
- function handleExclusiveUnionResults(results, final, inst, ctx) {
1338
- const matches = [];
1339
- for (let i = 0; i < results.length; i++) {
1340
- if (results[i].issues.length === 0)
1341
- matches.push(i);
1342
- }
1343
- if (matches.length === 1) {
1344
- final.value = results[matches[0]].value;
1345
- return final;
1346
- }
1347
- if (matches.length === 0) {
1348
- // No matches - same as regular union
1349
- final.issues.push({
1350
- code: "invalid_union",
1351
- input: final.value,
1352
- inst,
1353
- errors: results.map((result) => result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config()))),
1354
- });
1355
- }
1356
- else {
1357
- // Multiple matches - exclusive union failure
1358
- final.issues.push({
1359
- code: "invalid_union",
1360
- input: final.value,
1361
- inst,
1362
- errors: [],
1363
- inclusive: false,
1364
- matches,
1365
- });
1366
- }
1367
- return final;
1368
- }
1369
- exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
1370
- exports.$ZodUnion.init(inst, def);
1371
- def.inclusive = false;
1372
- const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1373
- inst._zod.parse = (payload, ctx) => {
1374
- if (first) {
1375
- return first(payload, ctx);
1376
- }
1377
- let async = false;
1378
- const results = [];
1379
- for (const option of def.options) {
1380
- const result = option._zod.run({
1381
- value: payload.value,
1382
- issues: [],
1383
- }, ctx);
1384
- if (result instanceof Promise) {
1385
- results.push(result);
1386
- async = true;
1387
- }
1388
- else {
1389
- results.push(result);
1390
- }
1391
- }
1392
- if (!async)
1393
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1394
- return Promise.all(results).then((results) => {
1395
- return handleExclusiveUnionResults(results, payload, inst, ctx);
1396
- });
1397
- };
1398
- });
1399
- /** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
1400
- function getDiscriminatedOption(union, value) {
1401
- const internals = union._zod;
1402
- let map = internals.bag.optionsMap;
1403
- if (!map) {
1404
- map = discriminatorMap(internals.def);
1405
- internals.bag.optionsMap = map;
1406
- }
1407
- const option = map.get(value);
1408
- if (option === null)
1409
- throw new Error(`Ambiguous discriminator value "${String(value)}"`);
1410
- return option;
1411
- }
1412
- function discriminatorMap(def) {
1413
- const map = new Map();
1414
- for (const option of def.options) {
1415
- const values = option._zod.propValues?.[def.discriminator];
1416
- if (!values || values.size === 0)
1417
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1418
- for (const value of values) {
1419
- if (map.has(value)) {
1420
- if (value !== undefined)
1421
- throw new Error(`Duplicate discriminator value "${String(value)}"`);
1422
- // keep the collision marked so a later member cannot reclaim it
1423
- map.set(value, null);
1424
- }
1425
- else {
1426
- map.set(value, option);
1427
- }
1428
- }
1429
- }
1430
- return map;
1431
- }
1432
- exports.$ZodDiscriminatedUnion =
1433
- /*@__PURE__*/
1434
- core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1435
- def.inclusive = false;
1436
- exports.$ZodUnion.init(inst, def);
1437
- const _super = inst._zod.parse;
1438
- util.defineLazyInternal(inst, "propValues", (zod) => {
1439
- const propValues = {};
1440
- let undefinedCount = 0;
1441
- for (const option of zod.def.options) {
1442
- const pv = option._zod.propValues;
1443
- if (!pv || Object.keys(pv).length === 0)
1444
- throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1445
- if (pv[zod.def.discriminator]?.has(undefined))
1446
- undefinedCount++;
1447
- for (const [k, v] of Object.entries(pv)) {
1448
- if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1449
- util.assignProp(propValues, k, new Set());
1450
- }
1451
- for (const val of v) {
1452
- propValues[k].add(val);
1453
- }
1454
- }
1455
- }
1456
- if (!zod.def.unionFallback && undefinedCount > 1)
1457
- propValues[zod.def.discriminator]?.delete(undefined);
1458
- return propValues;
1459
- });
1460
- // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
1461
- def.options.forEach((option, i) => {
1462
- const propShape = util.rawShape(option._zod.def);
1463
- if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1464
- throw new Error(`Invalid discriminated union option at index "${i}"`);
1465
- }
1466
- });
1467
- const disc = util.cached(() => discriminatorMap(def));
1468
- inst._zod.parse = (payload, ctx) => {
1469
- const input = payload.value;
1470
- if (!util.isObject(input)) {
1471
- payload.issues.push({
1472
- code: "invalid_type",
1473
- expected: "object",
1474
- input,
1475
- inst,
1476
- });
1477
- return payload;
1478
- }
1479
- const value = input?.[def.discriminator];
1480
- const opt = disc.value.get(value);
1481
- // forward metadata cannot choose an encoder for an absent tag
1482
- if (opt && (value !== undefined || ctx.direction !== "backward")) {
1483
- return opt._zod.run(payload, ctx);
1484
- }
1485
- // Fall back to union matching when the fast discriminator path fails:
1486
- // - explicitly enabled via unionFallback, or
1487
- // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
1488
- if (def.unionFallback || ctx.direction === "backward") {
1489
- return _super(payload, ctx);
1490
- }
1491
- // no matching discriminator
1492
- payload.issues.push({
1493
- code: "invalid_union",
1494
- errors: [],
1495
- note: "No matching discriminator",
1496
- discriminator: def.discriminator,
1497
- options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1498
- input,
1499
- path: [def.discriminator],
1500
- inst,
1501
- });
1502
- return payload;
1503
- };
1504
- });
1505
- exports.$ZodIntersection = core.$constructor("$ZodIntersection", (inst, def) => {
1506
- exports.$ZodType.init(inst, def);
1507
- inst._zod.parse = (payload, ctx) => {
1508
- const input = payload.value;
1509
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1510
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1511
- const async = left instanceof Promise || right instanceof Promise;
1512
- if (async) {
1513
- return Promise.all([left, right]).then(([left, right]) => {
1514
- return handleIntersectionResults(payload, left, right);
1515
- });
1516
- }
1517
- return handleIntersectionResults(payload, left, right);
1518
- };
1519
- });
1520
- function mergeValues(a, b) {
1521
- // const aType = parse.t(a);
1522
- // const bType = parse.t(b);
1523
- if (a === b) {
1524
- return { valid: true, data: a };
1525
- }
1526
- if (a instanceof Date && b instanceof Date && +a === +b) {
1527
- return { valid: true, data: a };
1528
- }
1529
- if (util.isPlainObject(a) && util.isPlainObject(b)) {
1530
- const bKeys = Object.keys(b);
1531
- const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1532
- const newObj = { ...a, ...b };
1533
- if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
1534
- delete newObj.__proto__;
1535
- for (const key of sharedKeys) {
1536
- if (key === "__proto__")
1537
- continue;
1538
- const sharedValue = mergeValues(a[key], b[key]);
1539
- if (!sharedValue.valid) {
1540
- return {
1541
- valid: false,
1542
- mergeErrorPath: [key, ...sharedValue.mergeErrorPath],
1543
- };
1544
- }
1545
- newObj[key] = sharedValue.data;
1546
- }
1547
- return { valid: true, data: newObj };
1548
- }
1549
- if (Array.isArray(a) && Array.isArray(b)) {
1550
- if (a.length !== b.length) {
1551
- return { valid: false, mergeErrorPath: [] };
1552
- }
1553
- const newArray = [];
1554
- for (let index = 0; index < a.length; index++) {
1555
- const itemA = a[index];
1556
- const itemB = b[index];
1557
- const sharedValue = mergeValues(itemA, itemB);
1558
- if (!sharedValue.valid) {
1559
- return {
1560
- valid: false,
1561
- mergeErrorPath: [index, ...sharedValue.mergeErrorPath],
1562
- };
1563
- }
1564
- newArray.push(sharedValue.data);
1565
- }
1566
- return { valid: true, data: newArray };
1567
- }
1568
- return { valid: false, mergeErrorPath: [] };
1569
- }
1570
- function handleIntersectionResults(result, left, right) {
1571
- // Track which side(s) reject each key. A key rejection is reported only when BOTH sides reject it, so a key owned by one branch survives the other's key schema. strictObject reports these as unrecognized_keys; a record with an open key schema reports one invalid_key per key.
1572
- const unrecKeys = new Map();
1573
- let unrecIssue;
1574
- const keyIssues = new Map();
1575
- const collect = (iss, side) => {
1576
- let keys;
1577
- if (iss.code === "unrecognized_keys" && !iss.path?.length) {
1578
- unrecIssue ?? (unrecIssue = iss);
1579
- keys = iss.keys;
1580
- }
1581
- else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
1582
- const k = String(iss.path[0]);
1583
- if (!keyIssues.has(k))
1584
- keyIssues.set(k, iss);
1585
- keys = [k];
1586
- }
1587
- else {
1588
- return false;
1589
- }
1590
- for (const k of keys) {
1591
- if (!unrecKeys.has(k))
1592
- unrecKeys.set(k, {});
1593
- unrecKeys.get(k)[side] = true;
1594
- }
1595
- return true;
1596
- };
1597
- for (const iss of left.issues) {
1598
- if (!collect(iss, "l"))
1599
- result.issues.push(iss);
1600
- }
1601
- for (const iss of right.issues) {
1602
- if (!collect(iss, "r"))
1603
- result.issues.push(iss);
1604
- }
1605
- // Report only keys rejected by BOTH sides
1606
- const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1607
- if (bothKeys.length) {
1608
- const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
1609
- if (aggregated.length)
1610
- result.issues.push({ ...unrecIssue, keys: aggregated });
1611
- for (const k of bothKeys) {
1612
- if (!aggregated.includes(k) && keyIssues.has(k))
1613
- result.issues.push(keyIssues.get(k));
1614
- }
1615
- }
1616
- const merged = mergeValues(left.value, right.value);
1617
- if (!merged.valid) {
1618
- if (util.aborted(result))
1619
- return result;
1620
- throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1621
- }
1622
- result.value = merged.data;
1623
- return result;
1624
- }
1625
- exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1626
- exports.$ZodType.init(inst, def);
1627
- const items = def.items;
1628
- const memo = core.globalConfig.memoizer;
1629
- memo?.attach(inst);
1630
- inst._zod.parse = (payload, ctx) => {
1631
- const input = payload.value;
1632
- if (!Array.isArray(input)) {
1633
- payload.issues.push({
1634
- input,
1635
- inst,
1636
- expected: "tuple",
1637
- code: "invalid_type",
1638
- });
1639
- return payload;
1640
- }
1641
- payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
1642
- const proms = [];
1643
- const optinStart = getTupleOptStart(items, "optin");
1644
- const optoutStart = getTupleOptStart(items, "optout");
1645
- if (!def.rest) {
1646
- if (input.length < optinStart) {
1647
- payload.issues.push({
1648
- code: "too_small",
1649
- minimum: optinStart,
1650
- inclusive: true,
1651
- input,
1652
- inst,
1653
- origin: "array",
1654
- });
1655
- return payload;
1656
- }
1657
- if (input.length > items.length) {
1658
- payload.issues.push({
1659
- code: "too_big",
1660
- maximum: items.length,
1661
- inclusive: true,
1662
- input,
1663
- inst,
1664
- origin: "array",
1665
- });
1666
- }
1667
- }
1668
- // Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
1669
- const itemResults = new Array(items.length);
1670
- // only tracked when there is a rest loop to skip
1671
- const abortEarly = def.rest ? ctx?.abortEarly : undefined;
1672
- let itemAborted = false;
1673
- for (let i = 0; i < items.length; i++) {
1674
- const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
1675
- if (r instanceof Promise) {
1676
- proms.push(r.then((rr) => {
1677
- itemResults[i] = rr;
1678
- }));
1679
- }
1680
- else {
1681
- itemResults[i] = r;
1682
- if (abortEarly && !itemAborted && r.issues.length)
1683
- itemAborted = util.aborted(r);
1684
- }
1685
- }
1686
- // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
1687
- if (def.rest && !itemAborted) {
1688
- let i = items.length - 1;
1689
- const rest = input.slice(items.length);
1690
- let seen = payload.issues.length;
1691
- for (const el of rest) {
1692
- if (abortEarly && payload.issues.length !== seen) {
1693
- if (util.aborted(payload, seen))
1694
- break;
1695
- seen = payload.issues.length;
1696
- }
1697
- i++;
1698
- const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
1699
- if (result instanceof Promise) {
1700
- proms.push(result.then((r) => handleTupleResult(r, payload, i)));
1701
- }
1702
- else {
1703
- handleTupleResult(result, payload, i);
1704
- }
1705
- }
1706
- }
1707
- if (proms.length) {
1708
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
1709
- }
1710
- return handleTupleResults(itemResults, payload, items, input, optoutStart);
1711
- };
1712
- });
1713
- function getTupleOptStart(items, key) {
1714
- for (let i = items.length - 1; i >= 0; i--) {
1715
- // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1716
- const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1717
- if (!omittable)
1718
- return i + 1;
1719
- }
1720
- return 0;
1721
- }
1722
- function handleTupleResult(result, final, index) {
1723
- if (result.issues.length) {
1724
- final.issues.push(...util.prefixIssues(index, result.issues));
1725
- }
1726
- final.value[index] = result.value;
1727
- }
1728
- function handleTupleResults(itemResults, final, items, input, optoutStart) {
1729
- // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional rule, but only after `optoutStart`: the first index where the output tuple tail can be absent.
1730
- for (let i = 0; i < items.length; i++) {
1731
- const r = itemResults[i];
1732
- const isPresent = i < input.length;
1733
- // The array analog of `handlePropertyResult`'s absent-key early return: the middle rung permits absence without supplying anything in its place, so the tail truncates here instead of materializing whatever the item made of `undefined`.
1734
- if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
1735
- final.value.length = i;
1736
- break;
1737
- }
1738
- if (r.issues.length) {
1739
- if (!isPresent && i >= optoutStart) {
1740
- final.value.length = i;
1741
- break;
1742
- }
1743
- final.issues.push(...util.prefixIssues(i, r.issues));
1744
- }
1745
- final.value[i] = r.value;
1746
- }
1747
- // Drop trailing slots that produced `undefined` for absent input
1748
- // (the array analog of an absent optional key on an object). The
1749
- // `i >= input.length` floor is critical: an explicit `undefined`
1750
- // *inside* the input must be preserved even when the schema is
1751
- // optional-out (e.g. `z.string().or(z.undefined())` accepting an
1752
- // explicit undefined value).
1753
- for (let i = final.value.length - 1; i >= input.length; i--) {
1754
- if (items[i]._zod.optout === "optional" && final.value[i] === undefined) {
1755
- final.value.length = i;
1756
- }
1757
- else {
1758
- break;
1759
- }
1760
- }
1761
- return final;
1762
- }
1763
- exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1764
- exports.$ZodType.init(inst, def);
1765
- const memo = core.globalConfig.memoizer;
1766
- memo?.attach(inst);
1767
- inst._zod.parse = (payload, ctx) => {
1768
- const input = payload.value;
1769
- if (!util.isPlainObject(input)) {
1770
- payload.issues.push({
1771
- expected: "record",
1772
- code: "invalid_type",
1773
- input,
1774
- inst,
1775
- });
1776
- return payload;
1777
- }
1778
- // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
1779
- const proms = [];
1780
- const values = def.keyType._zod.values;
1781
- if (values && !def.partial) {
1782
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1783
- const recordKeys = new Set();
1784
- for (const key of values) {
1785
- if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1786
- recordKeys.add(typeof key === "number" ? key.toString() : key);
1787
- // A declared __proto__ is stripped but is not an unrecognized key.
1788
- if (key === "__proto__")
1789
- continue;
1790
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1791
- if (keyResult instanceof Promise) {
1792
- throw new Error("Async schemas not supported in object keys currently");
1793
- }
1794
- if (keyResult.issues.length) {
1795
- payload.issues.push({
1796
- code: "invalid_key",
1797
- origin: "record",
1798
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1799
- input: key,
1800
- path: [key],
1801
- inst,
1802
- });
1803
- continue;
1804
- }
1805
- const outKey = keyResult.value;
1806
- if (outKey === "__proto__")
1807
- continue;
1808
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1809
- if (result instanceof Promise) {
1810
- proms.push(result.then((result) => {
1811
- if (result.issues.length) {
1812
- payload.issues.push(...util.prefixIssues(key, result.issues));
1813
- }
1814
- payload.value[outKey] = result.value;
1815
- }));
1816
- }
1817
- else {
1818
- if (result.issues.length) {
1819
- payload.issues.push(...util.prefixIssues(key, result.issues));
1820
- }
1821
- payload.value[outKey] = result.value;
1822
- }
1823
- }
1824
- }
1825
- let unrecognized;
1826
- for (const key in input) {
1827
- if (!recordKeys.has(key)) {
1828
- if (def.mode === "loose") {
1829
- // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
1830
- if (key === "__proto__")
1831
- continue;
1832
- payload.value[key] = input[key];
1833
- }
1834
- else {
1835
- unrecognized = unrecognized ?? [];
1836
- unrecognized.push(key);
1837
- }
1838
- }
1839
- }
1840
- if (unrecognized && unrecognized.length > 0) {
1841
- payload.issues.push({
1842
- code: "unrecognized_keys",
1843
- input,
1844
- inst,
1845
- keys: unrecognized,
1846
- continue: true,
1847
- });
1848
- }
1849
- }
1850
- else {
1851
- payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1852
- // An enumerable key schema declares which keys the record owns, so a key outside the set is unrecognized. A non-enumerable one (regex, refine) is a constraint every key must satisfy, so a failing key is invalid. Only the former is reconcilable against the other side of an intersection.
1853
- let unrecognized;
1854
- // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
1855
- for (const key of Reflect.ownKeys(input)) {
1856
- if (key === "__proto__")
1857
- continue;
1858
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
1859
- continue;
1860
- let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1861
- if (keyResult instanceof Promise) {
1862
- throw new Error("Async schemas not supported in object keys currently");
1863
- }
1864
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key). This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
1865
- const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
1866
- if (checkNumericKey) {
1867
- const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
1868
- if (retryResult instanceof Promise) {
1869
- throw new Error("Async schemas not supported in object keys currently");
1870
- }
1871
- if (retryResult.issues.length === 0) {
1872
- keyResult = retryResult;
1873
- }
1874
- }
1875
- if (keyResult.issues.length) {
1876
- if (def.mode === "loose") {
1877
- // Pass through unchanged
1878
- payload.value[key] = input[key];
1879
- }
1880
- else if (values) {
1881
- unrecognized = unrecognized ?? [];
1882
- unrecognized.push(key);
1883
- }
1884
- else {
1885
- // Default "strict" behavior: error on invalid key
1886
- payload.issues.push({
1887
- code: "invalid_key",
1888
- origin: "record",
1889
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1890
- input: key,
1891
- path: [key],
1892
- inst,
1893
- });
1894
- }
1895
- continue;
1896
- }
1897
- // the guard above tests the raw input key, but the key schema can normalize an ordinary key into __proto__; re-check the key we actually write under
1898
- const outKey = keyResult.value;
1899
- if (outKey === "__proto__")
1900
- continue;
1901
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1902
- if (result instanceof Promise) {
1903
- proms.push(result.then((result) => {
1904
- if (result.issues.length) {
1905
- payload.issues.push(...util.prefixIssues(key, result.issues));
1906
- }
1907
- payload.value[outKey] = result.value;
1908
- }));
1909
- }
1910
- else {
1911
- if (result.issues.length) {
1912
- payload.issues.push(...util.prefixIssues(key, result.issues));
1913
- }
1914
- payload.value[outKey] = result.value;
1915
- }
1916
- }
1917
- if (unrecognized && unrecognized.length > 0) {
1918
- payload.issues.push({
1919
- code: "unrecognized_keys",
1920
- input,
1921
- inst,
1922
- keys: unrecognized,
1923
- continue: true,
1924
- });
1925
- }
1926
- }
1927
- if (proms.length) {
1928
- return Promise.all(proms).then(() => payload);
1929
- }
1930
- return payload;
1931
- };
1932
- });
1933
- exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1934
- exports.$ZodType.init(inst, def);
1935
- const memo = core.globalConfig.memoizer;
1936
- memo?.attach(inst);
1937
- inst._zod.parse = (payload, ctx) => {
1938
- const input = payload.value;
1939
- if (!(input instanceof Map)) {
1940
- payload.issues.push({
1941
- expected: "map",
1942
- code: "invalid_type",
1943
- input,
1944
- inst,
1945
- });
1946
- return payload;
1947
- }
1948
- const proms = [];
1949
- payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
1950
- const abortEarly = ctx?.abortEarly;
1951
- let seen = payload.issues.length;
1952
- for (const [key, value] of input) {
1953
- if (abortEarly && payload.issues.length !== seen) {
1954
- if (util.aborted(payload, seen))
1955
- break;
1956
- seen = payload.issues.length;
1957
- }
1958
- const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1959
- const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
1960
- if (keyResult instanceof Promise || valueResult instanceof Promise) {
1961
- proms.push(Promise.all([keyResult, valueResult]).then(([keyResult, valueResult]) => {
1962
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1963
- }));
1964
- }
1965
- else {
1966
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
1967
- }
1968
- }
1969
- if (proms.length)
1970
- return Promise.all(proms).then(() => payload);
1971
- return payload;
1972
- };
1973
- capSize(inst, mapSize);
1974
- });
1975
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1976
- if (keyResult.issues.length) {
1977
- if (util.propertyKeyTypes.has(typeof key)) {
1978
- final.issues.push(...util.prefixIssues(key, keyResult.issues));
1979
- }
1980
- else {
1981
- final.issues.push({
1982
- code: "invalid_key",
1983
- origin: "map",
1984
- input,
1985
- inst,
1986
- issues: keyResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1987
- });
1988
- }
1989
- }
1990
- if (valueResult.issues.length) {
1991
- if (util.propertyKeyTypes.has(typeof key)) {
1992
- final.issues.push(...util.prefixIssues(key, valueResult.issues));
1993
- }
1994
- else {
1995
- final.issues.push({
1996
- origin: "map",
1997
- code: "invalid_element",
1998
- input,
1999
- inst,
2000
- key: key,
2001
- issues: valueResult.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2002
- });
2003
- }
2004
- }
2005
- final.value.set(keyResult.value, valueResult.value);
2006
- }
2007
- exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
2008
- exports.$ZodType.init(inst, def);
2009
- const memo = core.globalConfig.memoizer;
2010
- memo?.attach(inst);
2011
- inst._zod.parse = (payload, ctx) => {
2012
- const input = payload.value;
2013
- if (!(input instanceof Set)) {
2014
- payload.issues.push({
2015
- input,
2016
- inst,
2017
- expected: "set",
2018
- code: "invalid_type",
2019
- });
2020
- return payload;
2021
- }
2022
- const proms = [];
2023
- payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
2024
- const abortEarly = ctx?.abortEarly;
2025
- let seen = payload.issues.length;
2026
- for (const item of input) {
2027
- if (abortEarly && payload.issues.length !== seen) {
2028
- if (util.aborted(payload, seen))
2029
- break;
2030
- seen = payload.issues.length;
2031
- }
2032
- const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
2033
- if (result instanceof Promise) {
2034
- proms.push(result.then((result) => handleSetResult(result, payload)));
2035
- }
2036
- else
2037
- handleSetResult(result, payload);
2038
- }
2039
- if (proms.length)
2040
- return Promise.all(proms).then(() => payload);
2041
- return payload;
2042
- };
2043
- capSize(inst, setSize);
2044
- });
2045
- function handleSetResult(result, final) {
2046
- if (result.issues.length) {
2047
- final.issues.push(...result.issues);
2048
- }
2049
- final.value.add(result.value);
2050
- }
2051
- exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
2052
- exports.$ZodType.init(inst, def);
2053
- const values = util.getEnumValues(def.entries);
2054
- const valuesSet = new Set(values);
2055
- inst._zod.values = valuesSet;
2056
- util.defineLazyInternal(inst, "pattern", (zod) => {
2057
- const patternValues = util.getEnumValues(zod.def.entries).filter((k) => util.propertyKeyTypes.has(typeof k));
2058
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2059
- return new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2060
- });
2061
- inst._zod.parse = (payload, _ctx) => {
2062
- const input = payload.value;
2063
- if (valuesSet.has(input)) {
2064
- return payload;
2065
- }
2066
- payload.issues.push({
2067
- code: "invalid_value",
2068
- values,
2069
- input,
2070
- inst,
2071
- });
2072
- return payload;
2073
- };
2074
- });
2075
- exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
2076
- exports.$ZodType.init(inst, def);
2077
- const values = new Set(def.values);
2078
- inst._zod.values = values;
2079
- util.defineLazyInternal(inst, "pattern", (zod) => {
2080
- const vals = zod.def.values;
2081
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
2082
- return new RegExp(vals.length
2083
- ? `^(${vals
2084
- .map((o) => typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o))
2085
- .join("|")})$`
2086
- : "^[^\\s\\S]$");
2087
- });
2088
- inst._zod.parse = (payload, _ctx) => {
2089
- const input = payload.value;
2090
- if (values.has(input)) {
2091
- return payload;
2092
- }
2093
- payload.issues.push({
2094
- code: "invalid_value",
2095
- values: def.values,
2096
- input,
2097
- inst,
2098
- });
2099
- return payload;
2100
- };
2101
- });
2102
- exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
2103
- exports.$ZodType.init(inst, def);
2104
- inst._zod.parse = (payload, _ctx) => {
2105
- const input = payload.value;
2106
- // @ts-ignore
2107
- if (input instanceof File)
2108
- return payload;
2109
- payload.issues.push({
2110
- expected: "file",
2111
- code: "invalid_type",
2112
- input,
2113
- inst,
2114
- });
2115
- return payload;
2116
- };
2117
- });
2118
- exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
2119
- exports.$ZodType.init(inst, def);
2120
- inst._zod.optin = "optional";
2121
- core.globalConfig.memoizer?.guard(inst);
2122
- inst._zod.parse = (payload, ctx) => {
2123
- if (ctx.direction === "backward") {
2124
- throw new core.$ZodEncodeError(inst.constructor.name);
2125
- }
2126
- const _out = def.transform(payload.value, payload);
2127
- if (ctx.async) {
2128
- const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2129
- return output.then((output) => {
2130
- payload.value = output;
2131
- return payload;
2132
- });
2133
- }
2134
- if (_out instanceof Promise) {
2135
- throw new core.$ZodAsyncError();
2136
- }
2137
- payload.value = _out;
2138
- return payload;
2139
- };
2140
- });
2141
- function handleOptionalResult(payload, result) {
2142
- // A substituting schema that still failed has no usable answer; yield undefined. Its issues are simply dropped: it ran on a payload of its own, so there is no shared array to truncate and nothing of the caller's to lose with it.
2143
- payload.value = result.issues.length ? undefined : result.value;
2144
- return payload;
2145
- }
2146
- exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
2147
- exports.$ZodType.init(inst, def);
2148
- // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
2149
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2150
- inst._zod.optout = "optional";
2151
- util.defineLazyInternal(inst, "values", (zod) => {
2152
- const values = zod.def.innerType._zod.values;
2153
- return values ? new Set([...values, undefined]) : undefined;
2154
- });
2155
- util.defineLazyInternal(inst, "pattern", (zod) => {
2156
- const pattern = zod.def.innerType._zod.pattern;
2157
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
2158
- });
2159
- inst._zod.parse = (payload, ctx) => {
2160
- if (payload.value === undefined) {
2161
- // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
2162
- if (def.innerType._zod.optin !== "defaulted")
2163
- return payload;
2164
- // Its own payload, for the same reason $ZodCatch gets one: a pipe forwards an unrecognized key through the caller's issues array, and this must not read that as the substituting schema failing and drop it.
2165
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2166
- if (result instanceof Promise)
2167
- return result.then((result) => handleOptionalResult(payload, result));
2168
- return handleOptionalResult(payload, result);
2169
- }
2170
- return def.innerType._zod.run(payload, ctx);
2171
- };
2172
- });
2173
- exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) => {
2174
- // Call parent init - inherits optin/optout = "optional"
2175
- exports.$ZodOptional.init(inst, def);
2176
- // Override values/pattern to NOT add undefined
2177
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2178
- util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2179
- // Override parse to just delegate (no undefined handling)
2180
- inst._zod.parse = (payload, ctx) => {
2181
- return def.innerType._zod.run(payload, ctx);
2182
- };
2183
- });
2184
- exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
2185
- exports.$ZodType.init(inst, def);
2186
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2187
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2188
- util.defineLazyInternal(inst, "pattern", (zod) => {
2189
- const pattern = zod.def.innerType._zod.pattern;
2190
- return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
2191
- });
2192
- util.defineLazyInternal(inst, "values", (zod) => {
2193
- return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
2194
- });
2195
- inst._zod.parse = (payload, ctx) => {
2196
- // Forward direction (decode): allow null to pass through
2197
- if (payload.value === null)
2198
- return payload;
2199
- return def.innerType._zod.run(payload, ctx);
2200
- };
2201
- });
2202
- exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
2203
- exports.$ZodType.init(inst, def);
2204
- // inst._zod.qin = "true";
2205
- inst._zod.optin = "defaulted";
2206
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2207
- inst._zod.parse = (payload, ctx) => {
2208
- if (ctx.direction === "backward") {
2209
- return def.innerType._zod.run(payload, ctx);
2210
- }
2211
- // Forward direction (decode): apply defaults for undefined input
2212
- if (payload.value === undefined) {
2213
- payload.value = def.defaultValue;
2214
- /**
2215
- * $ZodDefault returns the default value immediately in forward direction.
2216
- * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2217
- return payload;
2218
- }
2219
- // Forward direction: continue with default handling
2220
- const result = def.innerType._zod.run(payload, ctx);
2221
- if (result instanceof Promise) {
2222
- return result.then((result) => handleDefaultResult(result, def));
2223
- }
2224
- return handleDefaultResult(result, def);
2225
- };
2226
- });
2227
- function handleDefaultResult(payload, def) {
2228
- if (payload.value === undefined) {
2229
- payload.value = def.defaultValue;
2230
- }
2231
- return payload;
2232
- }
2233
- exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
2234
- exports.$ZodType.init(inst, def);
2235
- inst._zod.optin = "defaulted";
2236
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2237
- inst._zod.parse = (payload, ctx) => {
2238
- if (ctx.direction === "backward") {
2239
- return def.innerType._zod.run(payload, ctx);
2240
- }
2241
- // Forward direction (decode): apply prefault for undefined input
2242
- if (payload.value === undefined) {
2243
- payload.value = def.defaultValue;
2244
- }
2245
- return def.innerType._zod.run(payload, ctx);
2246
- };
2247
- });
2248
- exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
2249
- exports.$ZodType.init(inst, def);
2250
- util.defineLazyInternal(inst, "values", (zod) => {
2251
- const v = zod.def.innerType._zod.values;
2252
- return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
2253
- });
2254
- inst._zod.parse = (payload, ctx) => {
2255
- const result = def.innerType._zod.run(payload, ctx);
2256
- if (result instanceof Promise) {
2257
- return result.then((result) => handleNonOptionalResult(result, inst));
2258
- }
2259
- return handleNonOptionalResult(result, inst);
2260
- };
2261
- });
2262
- function handleNonOptionalResult(payload, inst) {
2263
- if (!payload.issues.length && payload.value === undefined) {
2264
- payload.issues.push({
2265
- code: "invalid_type",
2266
- expected: "nonoptional",
2267
- input: payload.value,
2268
- inst,
2269
- });
2270
- }
2271
- return payload;
2272
- }
2273
- exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
2274
- exports.$ZodType.init(inst, def);
2275
- inst._zod.parse = (payload, ctx) => {
2276
- if (ctx.direction === "backward") {
2277
- throw new core.$ZodEncodeError("ZodSuccess");
2278
- }
2279
- const result = def.innerType._zod.run(payload, ctx);
2280
- if (result instanceof Promise) {
2281
- return result.then((result) => {
2282
- payload.value = result.issues.length === 0;
2283
- return payload;
2284
- });
2285
- }
2286
- payload.value = result.issues.length === 0;
2287
- return payload;
2288
- };
2289
- });
2290
- function handleCatchResult(payload, result, def, ctx) {
2291
- if (!result.issues.length) {
2292
- payload.value = result.value;
2293
- // The value carries up, so the flag describing it has to carry with it: a back-edge into a node still being parsed must not be frozen by an enclosing readonly, and its checks belong to the node itself. Guarded so the ordinary case adds no own property.
2294
- if (result.memo)
2295
- payload.memo = true;
2296
- return payload;
2297
- }
2298
- // Spread the inner's own payload, not ours: `value` has to stay the input the catch was handed, and the inner ran on a payload of its own so its issues are already private to this call.
2299
- payload.value = def.catchValue({
2300
- ...result,
2301
- value: payload.value,
2302
- error: {
2303
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2304
- },
2305
- input: payload.value,
2306
- });
2307
- return payload;
2308
- }
2309
- exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
2310
- exports.$ZodType.init(inst, def);
2311
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2312
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2313
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2314
- inst._zod.parse = (payload, ctx) => {
2315
- if (ctx.direction === "backward") {
2316
- return def.innerType._zod.run(payload, ctx);
2317
- }
2318
- // Forward direction (decode): apply catch logic
2319
- const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2320
- if (result instanceof Promise) {
2321
- return result.then((result) => handleCatchResult(payload, result, def, ctx));
2322
- }
2323
- return handleCatchResult(payload, result, def, ctx);
2324
- };
2325
- });
2326
- exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
2327
- exports.$ZodType.init(inst, def);
2328
- inst._zod.parse = (payload, _ctx) => {
2329
- if (typeof payload.value !== "number" || !Number.isNaN(payload.value)) {
2330
- payload.issues.push({
2331
- input: payload.value,
2332
- inst,
2333
- expected: "nan",
2334
- code: "invalid_type",
2335
- });
2336
- return payload;
2337
- }
2338
- return payload;
2339
- };
2340
- });
2341
- exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
2342
- exports.$ZodType.init(inst, def);
2343
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2344
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2345
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2346
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2347
- inst._zod.parse = (payload, ctx) => {
2348
- if (ctx.direction === "backward") {
2349
- const right = def.out._zod.run(payload, ctx);
2350
- if (right instanceof Promise) {
2351
- return right.then((right) => handlePipeResult(right, def.in, ctx));
2352
- }
2353
- return handlePipeResult(right, def.in, ctx);
2354
- }
2355
- const left = def.in._zod.run(payload, ctx);
2356
- if (left instanceof Promise) {
2357
- return left.then((left) => handlePipeResult(left, def.out, ctx));
2358
- }
2359
- return handlePipeResult(left, def.out, ctx);
2360
- };
2361
- });
2362
- function handlePipeResult(left, next, ctx) {
2363
- // Any issue stops the pipe, so a failing refinement never feeds its transform. An unrecognized key is the exception: it describes the input's extra properties, not the value being piped, and an enclosing intersection may yet reconcile it.
2364
- if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2365
- // prevent further checks
2366
- left.aborted = true;
2367
- return left;
2368
- }
2369
- return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2370
- }
2371
- exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
2372
- exports.$ZodType.init(inst, def);
2373
- util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2374
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2375
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2376
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2377
- inst._zod.parse = (payload, ctx) => {
2378
- const direction = ctx.direction || "forward";
2379
- if (direction === "forward") {
2380
- const left = def.in._zod.run(payload, ctx);
2381
- if (left instanceof Promise) {
2382
- return left.then((left) => handleCodecAResult(left, def, ctx));
2383
- }
2384
- return handleCodecAResult(left, def, ctx);
2385
- }
2386
- else {
2387
- const right = def.out._zod.run(payload, ctx);
2388
- if (right instanceof Promise) {
2389
- return right.then((right) => handleCodecAResult(right, def, ctx));
2390
- }
2391
- return handleCodecAResult(right, def, ctx);
2392
- }
2393
- };
2394
- });
2395
- function handleCodecAResult(result, def, ctx) {
2396
- if (result.issues.length) {
2397
- // prevent further checks
2398
- result.aborted = true;
2399
- return result;
2400
- }
2401
- const direction = ctx.direction || "forward";
2402
- if (direction === "forward") {
2403
- const transformed = def.transform(result.value, result);
2404
- if (transformed instanceof Promise) {
2405
- return transformed.then((value) => handleCodecTxResult(result, value, def.out, ctx));
2406
- }
2407
- return handleCodecTxResult(result, transformed, def.out, ctx);
2408
- }
2409
- else {
2410
- const transformed = def.reverseTransform(result.value, result);
2411
- if (transformed instanceof Promise) {
2412
- return transformed.then((value) => handleCodecTxResult(result, value, def.in, ctx));
2413
- }
2414
- return handleCodecTxResult(result, transformed, def.in, ctx);
2415
- }
2416
- }
2417
- function handleCodecTxResult(left, value, nextSchema, ctx) {
2418
- // Check if transform added any issues
2419
- if (left.issues.length) {
2420
- left.aborted = true;
2421
- return left;
2422
- }
2423
- return nextSchema._zod.run({ value, issues: left.issues }, ctx);
2424
- }
2425
- exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
2426
- exports.$ZodPipe.init(inst, def);
2427
- });
2428
- exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
2429
- exports.$ZodType.init(inst, def);
2430
- util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2431
- util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2432
- util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2433
- util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2434
- inst._zod.parse = (payload, ctx) => {
2435
- if (ctx.direction === "backward") {
2436
- return def.innerType._zod.run(payload, ctx);
2437
- }
2438
- const result = def.innerType._zod.run(payload, ctx);
2439
- if (result instanceof Promise) {
2440
- return result.then(handleReadonlyResult);
2441
- }
2442
- return handleReadonlyResult(result);
2443
- };
2444
- });
2445
- function handleReadonlyResult(payload) {
2446
- // A repeat visit hands back a node that is still being built; freezing it here would make the rest of its keys fail to assign.
2447
- if (!payload.memo)
2448
- payload.value = Object.freeze(payload.value);
2449
- return payload;
2450
- }
2451
- // a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
2452
- function leafPattern(schema) {
2453
- const def = schema._zod.def;
2454
- let pattern = def.pattern;
2455
- let isInt = !!def.format?.includes("int");
2456
- let minimum;
2457
- let maximum;
2458
- for (const ch of def.checks ?? []) {
2459
- const d = ch._zod.def;
2460
- if (d.pattern)
2461
- pattern = d.pattern;
2462
- isInt || (isInt = !!d.format?.includes("int"));
2463
- const lo = d.minimum ?? d.length;
2464
- const hi = d.maximum ?? d.length;
2465
- if (lo !== undefined && (minimum === undefined || lo > minimum))
2466
- minimum = lo;
2467
- if (hi !== undefined && (maximum === undefined || hi < maximum))
2468
- maximum = hi;
2469
- }
2470
- if (pattern)
2471
- return pattern.source;
2472
- // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
2473
- if (minimum !== undefined && maximum !== undefined && minimum > maximum)
2474
- return "(?!)";
2475
- if (minimum !== undefined || maximum !== undefined)
2476
- return regexes.string({ minimum, maximum }).source;
2477
- const own = schema._zod.pattern;
2478
- return (isInt && own === regexes.number ? regexes.integer : own)?.source;
2479
- }
2480
- // a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
2481
- function partPattern(schema) {
2482
- const def = schema._zod.def;
2483
- const own = schema._zod.pattern?.source;
2484
- // lazy resolves its inner on the internals, not the def
2485
- const inner = def.innerType ?? schema._zod.innerType;
2486
- if (inner) {
2487
- const before = inner._zod.pattern?.source;
2488
- const after = partPattern(inner);
2489
- if (own && before && after && after !== before) {
2490
- return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
2491
- }
2492
- return own;
2493
- }
2494
- if (def.options) {
2495
- const sources = def.options.map(partPattern);
2496
- if (sources.every(Boolean))
2497
- return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
2498
- }
2499
- return leafPattern(schema);
2500
- }
2501
- exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
2502
- exports.$ZodType.init(inst, def);
2503
- const regexParts = [];
2504
- for (const part of def.parts) {
2505
- if (typeof part === "object" && part !== null) {
2506
- // is Zod schema
2507
- const source = partPattern(part);
2508
- if (!source) {
2509
- throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
2510
- }
2511
- regexParts.push(util.cleanRegex(source));
2512
- }
2513
- else if (part === null || util.primitiveTypes.has(typeof part)) {
2514
- regexParts.push(util.escapeRegex(`${part}`));
2515
- }
2516
- else {
2517
- throw new Error(`Invalid template literal part: ${part}`);
2518
- }
2519
- }
2520
- inst._zod.pattern = new RegExp(`^${regexParts.join("")}$`);
2521
- inst._zod.parse = (payload, _ctx) => {
2522
- if (typeof payload.value !== "string") {
2523
- payload.issues.push({
2524
- input: payload.value,
2525
- inst,
2526
- expected: "string",
2527
- code: "invalid_type",
2528
- });
2529
- return payload;
2530
- }
2531
- inst._zod.pattern.lastIndex = 0;
2532
- if (!inst._zod.pattern.test(payload.value)) {
2533
- payload.issues.push({
2534
- input: payload.value,
2535
- inst,
2536
- code: "invalid_format",
2537
- format: def.format ?? "template_literal",
2538
- pattern: inst._zod.pattern.source,
2539
- });
2540
- return payload;
2541
- }
2542
- return payload;
2543
- };
2544
- });
2545
- exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
2546
- exports.$ZodType.init(inst, def);
2547
- // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
2548
- Object.defineProperty(inst, "_def", { value: def });
2549
- inst._zod.def = def;
2550
- inst.implement = (func) => {
2551
- if (typeof func !== "function") {
2552
- throw new Error("implement() must be called with a function");
2553
- }
2554
- // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
2555
- return Object.defineProperty(function (...args) {
2556
- const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
2557
- const result = Reflect.apply(func, this, parsedArgs);
2558
- if (inst._def.output) {
2559
- return (0, parse_js_1.parse)(inst._def.output, result);
2560
- }
2561
- return result;
2562
- }, "_zod", { value: inst._zod, enumerable: false });
2563
- };
2564
- inst.implementAsync = (func) => {
2565
- if (typeof func !== "function") {
2566
- throw new Error("implementAsync() must be called with a function");
2567
- }
2568
- return Object.defineProperty(async function (...args) {
2569
- const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
2570
- const result = await Reflect.apply(func, this, parsedArgs);
2571
- if (inst._def.output) {
2572
- return await (0, parse_js_1.parseAsync)(inst._def.output, result);
2573
- }
2574
- return result;
2575
- }, "_zod", { value: inst._zod, enumerable: false });
2576
- };
2577
- inst._zod.parse = (payload, _ctx) => {
2578
- if (typeof payload.value !== "function") {
2579
- payload.issues.push({
2580
- code: "invalid_type",
2581
- expected: "function",
2582
- input: payload.value,
2583
- inst,
2584
- });
2585
- return payload;
2586
- }
2587
- // Check if output is a promise type to determine if we should use async implementation
2588
- const hasPromiseOutput = inst._def.output && inst._def.output._zod.def.type === "promise";
2589
- if (hasPromiseOutput) {
2590
- payload.value = inst.implementAsync(payload.value);
2591
- }
2592
- else {
2593
- payload.value = inst.implement(payload.value);
2594
- }
2595
- return payload;
2596
- };
2597
- inst.input = (...args) => {
2598
- const F = inst.constructor;
2599
- if (Array.isArray(args[0])) {
2600
- return new F({
2601
- type: "function",
2602
- input: new exports.$ZodTuple({
2603
- type: "tuple",
2604
- items: args[0],
2605
- rest: args[1],
2606
- }),
2607
- output: inst._def.output,
2608
- });
2609
- }
2610
- return new F({
2611
- type: "function",
2612
- input: args[0],
2613
- output: inst._def.output,
2614
- });
2615
- };
2616
- inst.output = (output) => {
2617
- const F = inst.constructor;
2618
- return new F({
2619
- type: "function",
2620
- input: inst._def.input,
2621
- output,
2622
- });
2623
- };
2624
- return inst;
2625
- });
2626
- exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
2627
- exports.$ZodType.init(inst, def);
2628
- inst._zod.parse = (payload, ctx) => {
2629
- return Promise.resolve(payload.value).then((inner) => def.innerType._zod.run({ value: inner, issues: [] }, ctx));
2630
- };
2631
- });
2632
- exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
2633
- exports.$ZodType.init(inst, def);
2634
- // Cache the resolved inner type on the shared `def` so all clones of this lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance, preserving identity for cycle detection on recursive schemas.
2635
- util.defineLazy(inst._zod, "innerType", () => {
2636
- const d = def;
2637
- if (!d._cachedInner)
2638
- d._cachedInner = def.getter();
2639
- return d._cachedInner;
2640
- });
2641
- util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
2642
- util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
2643
- util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
2644
- util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
2645
- inst._zod.parse = (payload, ctx) => {
2646
- const inner = inst._zod.innerType;
2647
- return inner._zod.run(payload, ctx);
2648
- };
2649
- });
2650
- exports.$ZodCustom = core.$constructor("$ZodCustom", (inst, def) => {
2651
- checks.$ZodCheck.init(inst, def);
2652
- exports.$ZodType.init(inst, def);
2653
- inst._zod.parse = (payload, _) => {
2654
- return payload;
2655
- };
2656
- inst._zod.check = (payload) => {
2657
- const input = payload.value;
2658
- const r = def.fn(input);
2659
- if (r instanceof Promise) {
2660
- return r.then((r) => handleRefineResult(r, payload, input, inst));
2661
- }
2662
- handleRefineResult(r, payload, input, inst);
2663
- return;
2664
- };
2665
- });
2666
- function handleRefineResult(result, payload, input, inst) {
2667
- if (!result) {
2668
- const _iss = {
2669
- code: "custom",
2670
- input,
2671
- inst, // incorporates params.error into issue reporting
2672
- path: [...(inst._zod.def.path ?? [])], // incorporates params.error into issue reporting
2673
- continue: !inst._zod.def.abort,
2674
- // params: inst._zod.def.params,
2675
- };
2676
- if (inst._zod.def.params)
2677
- _iss.params = inst._zod.def.params;
2678
- payload.issues.push(util.issue(_iss));
2679
- }
2680
- }
2681
-
2682
- // seal-cjs-exports
2683
- (function () {
2684
- var keys = Object.getOwnPropertyNames(exports);
2685
- for (var i = 0; i < keys.length; i++) {
2686
- var desc = Object.getOwnPropertyDescriptor(exports, keys[i]);
2687
- if (!desc || !desc.get || !desc.configurable) continue;
2688
- var value;
2689
- try {
2690
- value = desc.get();
2691
- } catch (e) {
2692
- continue;
2693
- }
2694
- // a circular require may not have settled this one yet, so leave it live
2695
- if (value === undefined) continue;
2696
- Object.defineProperty(exports, keys[i], { value: value, writable: false, enumerable: desc.enumerable, configurable: false });
2697
- }
2698
- Object.freeze(exports);
2699
- })();