@openclaw/feishu 2026.9.3 → 2026.9.5

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 (743) hide show
  1. package/assets/activity.svg +3 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/{accounts-cCMNFBKg.js → .setup/accounts-DmU0xYPx.mjs} +1 -1
  4. package/dist/{app-registration-BI99e_JI.js → .setup/app-registration-Bv4mvauR.mjs} +1 -1
  5. package/dist/{channel-DrAqd5ED.js → .setup/channel-C1KrXXJa.mjs} +100 -99
  6. package/dist/{channel.runtime-BZzuDlOS.js → .setup/channel.runtime-Bizuv7WZ.mjs} +32 -18
  7. package/dist/{chat-BZSnEtgb.js → .setup/chat-dWJYS63b.mjs} +89 -88
  8. package/dist/{client-DMbIL3UH.js → .setup/client-DCwNVFZg.mjs} +128 -11
  9. package/dist/{conversation-id-VYgGQ-GX.js → .setup/conversation-id-H-lUayji.mjs} +49 -14
  10. package/dist/{monitor-DSGtOPio.js → .setup/monitor-C69OLzgO.mjs} +4 -4
  11. package/dist/{monitor.account-BRDUsS_q.js → .setup/monitor.account-zwHb3HKM.mjs} +76 -52
  12. package/dist/{probe-D_SatdZl.js → .setup/probe-bdidyhAn.mjs} +2 -2
  13. package/dist/{reply-delivery-result-BXEmtKpf.js → .setup/reply-delivery-result-DFjxGLgX.mjs} +162 -163
  14. package/dist/.setup/runtime-setter-api-CG-RC4_r.mjs +3 -0
  15. package/dist/.setup/secret-contract-api-jmCkqVLc.mjs +3 -0
  16. package/dist/{security-audit-DKfR4Cv3.js → .setup/security-audit-CmiKKfU-.mjs} +1 -1
  17. package/dist/{session-conversation-DFCIvQK-.js → .setup/session-conversation-ZC6TC1zk.mjs} +1 -1
  18. package/dist/.setup/setup-api-CTRwX09n.mjs +3 -0
  19. package/dist/{subagent-hooks-Buadpie_.js → .setup/subagent-hooks-BBfF1hZk.mjs} +3 -19
  20. package/dist/api.js +125 -121
  21. package/dist/channel-plugin-api.js +1 -1
  22. package/dist/contract-api.js +3 -3
  23. package/dist/doctor-contract-api.js +1 -1
  24. package/dist/runtime-api.js +1 -1
  25. package/dist/runtime-setter-api.js +1 -1
  26. package/dist/secret-contract-api.js +1 -1
  27. package/dist/security-contract-api.js +1 -1
  28. package/dist/session-binding-contract-api.js +1 -1
  29. package/dist/session-key-api.js +1 -1
  30. package/dist/setup-api.js +1 -1
  31. package/dist/setup-entry.js +4 -3
  32. package/dist/subagent-hooks-api.js +1 -1
  33. package/node_modules/@larksuiteoapi/node-sdk/es/index.js +199 -35
  34. package/node_modules/@larksuiteoapi/node-sdk/lib/index.js +199 -35
  35. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/CHANGELOG.md +62 -0
  36. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/README.md +233 -5
  37. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.js +387 -89
  38. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js +3 -3
  39. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js.map +1 -1
  40. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/browser/axios.cjs +458 -98
  41. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.js +458 -98
  42. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js +2 -2
  43. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  44. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/node/axios.cjs +568 -116
  45. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.cts +4 -0
  46. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.ts +4 -0
  47. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/fetch.js +64 -11
  48. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/http.js +134 -50
  49. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/xhr.js +52 -3
  50. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/Axios.js +19 -14
  51. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/InterceptorManager.js +107 -8
  52. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/buildFullPath.js +1 -13
  53. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/dispatchRequest.js +8 -2
  54. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/mergeConfig.js +1 -1
  55. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/methodList.js +17 -0
  56. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/defaults/index.js +2 -1
  57. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/env/data.js +1 -1
  58. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
  59. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
  60. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
  61. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  62. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
  63. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
  64. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
  65. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/throttle.js +3 -2
  66. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/toFormData.js +14 -21
  67. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/utils.js +134 -13
  68. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/package.json +1 -1
  69. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/README.md +24 -17
  70. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js +124 -14
  71. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  72. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  73. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  74. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js +63 -9
  75. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  76. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  77. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  78. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js +133 -18
  79. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  80. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  81. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  82. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.generated.d.ts +7 -0
  83. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/descriptor.js +24 -0
  84. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/protojson.js +14 -4
  85. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/ext/textformat.js +8 -4
  86. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.json +20 -1
  87. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/google/protobuf/descriptor.proto +14 -1
  88. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/index.d.ts +12 -0
  89. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/package.json +1 -1
  90. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/decoder.js +31 -2
  91. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/enum.js +10 -0
  92. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/object.js +5 -2
  93. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/parse.js +9 -4
  94. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/reader.js +61 -7
  95. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/type.js +10 -0
  96. package/node_modules/@larksuiteoapi/node-sdk/node_modules/protobufjs/src/wrappers.js +5 -1
  97. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  98. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/CHANGELOG.md +15 -0
  99. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/README.md +19 -1
  100. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/dist/qs.js +21 -21
  101. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/eslint.config.mjs +1 -1
  102. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/parse.js +3 -4
  103. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/stringify.js +23 -8
  104. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/utils.js +10 -3
  105. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/package.json +4 -4
  106. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/parse.js +192 -3
  107. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/stringify.js +317 -0
  108. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/utils.js +12 -0
  109. package/node_modules/@larksuiteoapi/node-sdk/package.json +1 -1
  110. package/node_modules/@larksuiteoapi/node-sdk/types/index.d.ts +35 -0
  111. package/node_modules/typebox/build/compile/validator.d.mts +1 -1
  112. package/node_modules/typebox/build/compile/validator.mjs +1 -1
  113. package/node_modules/typebox/build/format/idna/idn-hostname.mjs +7 -5
  114. package/node_modules/typebox/build/format/iri.mjs +5 -1
  115. package/node_modules/typebox/build/guard/emit.mjs +2 -4
  116. package/node_modules/typebox/build/guard/guard.mjs +6 -18
  117. package/node_modules/typebox/build/guard/string.mjs +16 -24
  118. package/node_modules/typebox/build/schema/build.mjs +2 -2
  119. package/node_modules/typebox/build/schema/check.mjs +1 -1
  120. package/node_modules/typebox/build/schema/compile.d.mts +3 -2
  121. package/node_modules/typebox/build/schema/compile.mjs +8 -8
  122. package/node_modules/typebox/build/schema/engine/_context.d.mts +6 -7
  123. package/node_modules/typebox/build/schema/engine/_context.mjs +23 -15
  124. package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
  125. package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
  126. package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
  127. package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
  128. package/node_modules/typebox/build/schema/engine/_refine.mjs +4 -7
  129. package/node_modules/typebox/build/schema/engine/_stack.d.mts +34 -16
  130. package/node_modules/typebox/build/schema/engine/_stack.mjs +148 -104
  131. package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
  132. package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -8
  133. package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +26 -18
  134. package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
  135. package/node_modules/typebox/build/schema/engine/allOf.mjs +3 -3
  136. package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
  137. package/node_modules/typebox/build/schema/engine/anyOf.mjs +5 -10
  138. package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
  139. package/node_modules/typebox/build/schema/engine/boolean.mjs +2 -6
  140. package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
  141. package/node_modules/typebox/build/schema/engine/const.mjs +2 -6
  142. package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
  143. package/node_modules/typebox/build/schema/engine/contains.mjs +2 -6
  144. package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
  145. package/node_modules/typebox/build/schema/engine/dependencies.mjs +3 -6
  146. package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
  147. package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +2 -6
  148. package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
  149. package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
  150. package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +11 -7
  151. package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
  152. package/node_modules/typebox/build/schema/engine/enum.mjs +2 -6
  153. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
  154. package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +2 -6
  155. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
  156. package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +2 -6
  157. package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
  158. package/node_modules/typebox/build/schema/engine/format.mjs +2 -6
  159. package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
  160. package/node_modules/typebox/build/schema/engine/if.mjs +7 -15
  161. package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
  162. package/node_modules/typebox/build/schema/engine/items.mjs +1 -1
  163. package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
  164. package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -6
  165. package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
  166. package/node_modules/typebox/build/schema/engine/maxItems.mjs +2 -6
  167. package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
  168. package/node_modules/typebox/build/schema/engine/maxLength.mjs +2 -6
  169. package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
  170. package/node_modules/typebox/build/schema/engine/maxProperties.mjs +2 -6
  171. package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
  172. package/node_modules/typebox/build/schema/engine/maximum.mjs +2 -6
  173. package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
  174. package/node_modules/typebox/build/schema/engine/minContains.mjs +2 -6
  175. package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
  176. package/node_modules/typebox/build/schema/engine/minItems.mjs +2 -6
  177. package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
  178. package/node_modules/typebox/build/schema/engine/minLength.mjs +2 -6
  179. package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
  180. package/node_modules/typebox/build/schema/engine/minProperties.mjs +2 -6
  181. package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
  182. package/node_modules/typebox/build/schema/engine/minimum.mjs +2 -6
  183. package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
  184. package/node_modules/typebox/build/schema/engine/multipleOf.mjs +2 -6
  185. package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
  186. package/node_modules/typebox/build/schema/engine/not.mjs +4 -8
  187. package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
  188. package/node_modules/typebox/build/schema/engine/oneOf.mjs +6 -11
  189. package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
  190. package/node_modules/typebox/build/schema/engine/pattern.mjs +3 -7
  191. package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
  192. package/node_modules/typebox/build/schema/engine/patternProperties.mjs +1 -1
  193. package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
  194. package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
  195. package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
  196. package/node_modules/typebox/build/schema/engine/properties.mjs +1 -1
  197. package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
  198. package/node_modules/typebox/build/schema/engine/propertyNames.mjs +4 -10
  199. package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
  200. package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +11 -7
  201. package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
  202. package/node_modules/typebox/build/schema/engine/ref.mjs +19 -15
  203. package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
  204. package/node_modules/typebox/build/schema/engine/required.mjs +2 -6
  205. package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
  206. package/node_modules/typebox/build/schema/engine/schema.mjs +137 -133
  207. package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
  208. package/node_modules/typebox/build/schema/engine/type.mjs +2 -6
  209. package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
  210. package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +5 -9
  211. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
  212. package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +5 -9
  213. package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
  214. package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +2 -6
  215. package/node_modules/typebox/build/schema/errors.d.mts +2 -2
  216. package/node_modules/typebox/build/schema/errors.mjs +8 -14
  217. package/node_modules/typebox/build/schema/intern/index.d.mts +1 -0
  218. package/node_modules/typebox/build/schema/intern/index.mjs +1 -0
  219. package/node_modules/typebox/build/schema/intern/intern.d.mts +11 -0
  220. package/node_modules/typebox/build/schema/intern/intern.mjs +293 -0
  221. package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +2 -0
  222. package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +288 -0
  223. package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +2 -0
  224. package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +300 -0
  225. package/node_modules/typebox/build/schema/meta/draft_3.d.mts +2 -0
  226. package/node_modules/typebox/build/schema/meta/draft_3.mjs +143 -0
  227. package/node_modules/typebox/build/schema/meta/draft_4.d.mts +2 -0
  228. package/node_modules/typebox/build/schema/meta/draft_4.mjs +149 -0
  229. package/node_modules/typebox/build/schema/meta/draft_6.d.mts +2 -0
  230. package/node_modules/typebox/build/schema/meta/draft_6.mjs +155 -0
  231. package/node_modules/typebox/build/schema/meta/draft_7.d.mts +2 -0
  232. package/node_modules/typebox/build/schema/meta/draft_7.mjs +172 -0
  233. package/node_modules/typebox/build/schema/meta/index.d.mts +2 -0
  234. package/node_modules/typebox/build/schema/meta/index.mjs +2 -0
  235. package/node_modules/typebox/build/schema/meta/meta.d.mts +9 -0
  236. package/node_modules/typebox/build/schema/meta/meta.mjs +15 -0
  237. package/node_modules/typebox/build/schema/meta/schema.d.mts +6 -0
  238. package/node_modules/typebox/build/schema/meta/schema.mjs +1 -0
  239. package/node_modules/typebox/build/schema/parse.d.mts +1 -0
  240. package/node_modules/typebox/build/schema/parse.mjs +10 -5
  241. package/node_modules/typebox/build/schema/resolve/resolve.d.mts +8 -3
  242. package/node_modules/typebox/build/schema/resolve/resolve.mjs +268 -139
  243. package/node_modules/typebox/build/schema/schema.d.mts +2 -0
  244. package/node_modules/typebox/build/schema/schema.mjs +2 -0
  245. package/node_modules/typebox/build/value/errors/errors.d.mts +2 -12
  246. package/node_modules/typebox/build/value/errors/errors.mjs +2 -7
  247. package/node_modules/typebox/package.json +1 -1
  248. package/node_modules/typebox/readme.md +59 -89
  249. package/node_modules/zod/README.md +27 -0
  250. package/node_modules/zod/compile.cjs +77 -0
  251. package/node_modules/zod/compile.d.cts +1 -0
  252. package/node_modules/zod/compile.d.ts +1 -0
  253. package/node_modules/zod/compile.js +52 -0
  254. package/node_modules/zod/index.cjs +2 -2
  255. package/node_modules/zod/index.d.cts +1 -2
  256. package/node_modules/zod/index.d.ts +1 -2
  257. package/node_modules/zod/index.js +5 -2
  258. package/node_modules/zod/package.json +13 -2
  259. package/node_modules/zod/src/compile.ts +56 -0
  260. package/node_modules/zod/src/index.ts +5 -2
  261. package/node_modules/zod/src/v3/ZodError.ts +22 -12
  262. package/node_modules/zod/src/v3/tests/error.test.ts +35 -0
  263. package/node_modules/zod/src/v3/tests/intersection.test.ts +18 -0
  264. package/node_modules/zod/src/v3/tests/language-server.test.ts +1 -2
  265. package/node_modules/zod/src/v3/tests/object.test.ts +3 -6
  266. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -80
  267. package/node_modules/zod/src/v3/tests/string.test.ts +6 -0
  268. package/node_modules/zod/src/v3/types.ts +5 -5
  269. package/node_modules/zod/src/v4/classic/checks.ts +1 -0
  270. package/node_modules/zod/src/v4/classic/compat.ts +26 -18
  271. package/node_modules/zod/src/v4/classic/deep-partial.ts +76 -0
  272. package/node_modules/zod/src/v4/classic/errors.ts +59 -44
  273. package/node_modules/zod/src/v4/classic/external.ts +12 -9
  274. package/node_modules/zod/src/v4/classic/from-json-schema.ts +140 -78
  275. package/node_modules/zod/src/v4/classic/in-out.ts +45 -0
  276. package/node_modules/zod/src/v4/classic/index.ts +2 -2
  277. package/node_modules/zod/src/v4/classic/iso.ts +2 -72
  278. package/node_modules/zod/src/v4/classic/parse.ts +10 -4
  279. package/node_modules/zod/src/v4/classic/schemas.ts +452 -262
  280. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +27 -0
  281. package/node_modules/zod/src/v4/classic/tests/array.test.ts +2 -2
  282. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +135 -0
  283. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +30 -1
  284. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +278 -0
  285. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +1 -2
  286. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +2 -1
  287. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +2 -2
  288. package/node_modules/zod/src/v4/classic/tests/credit-card.test.ts +76 -0
  289. package/node_modules/zod/src/v4/classic/tests/cyclic-data.test.ts +720 -0
  290. package/node_modules/zod/src/v4/classic/tests/date.test.ts +30 -0
  291. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +32 -18
  292. package/node_modules/zod/src/v4/classic/tests/deep-partial.test.ts +380 -0
  293. package/node_modules/zod/src/v4/classic/tests/default-locale.test.ts +32 -0
  294. package/node_modules/zod/src/v4/classic/tests/default.test.ts +46 -0
  295. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +31 -7
  296. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +155 -13
  297. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +11 -0
  298. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +112 -2
  299. package/node_modules/zod/src/v4/classic/tests/error.test.ts +274 -6
  300. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +425 -10
  301. package/node_modules/zod/src/v4/classic/tests/function.test.ts +31 -0
  302. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +2 -9
  303. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +1 -2
  304. package/node_modules/zod/src/v4/classic/tests/in-out.test.ts +159 -0
  305. package/node_modules/zod/src/v4/classic/tests/index.test.ts +21 -2
  306. package/node_modules/zod/src/v4/classic/tests/instance-footprint.test.ts +281 -0
  307. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +47 -0
  308. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +136 -0
  309. package/node_modules/zod/src/v4/classic/tests/issue-schema.test.ts +183 -0
  310. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +3 -10
  311. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +36 -1
  312. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +12 -1
  313. package/node_modules/zod/src/v4/classic/tests/map.test.ts +12 -0
  314. package/node_modules/zod/src/v4/classic/tests/number.test.ts +46 -9
  315. package/node_modules/zod/src/v4/classic/tests/object.test.ts +245 -12
  316. package/node_modules/zod/src/v4/classic/tests/optin-ladder.test.ts +234 -0
  317. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +49 -16
  318. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +51 -4
  319. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +20 -2
  320. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -68
  321. package/node_modules/zod/src/v4/classic/tests/record.test.ts +186 -18
  322. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +33 -2
  323. package/node_modules/zod/src/v4/classic/tests/redos.test.ts +68 -0
  324. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +60 -0
  325. package/node_modules/zod/src/v4/classic/tests/set.test.ts +9 -0
  326. package/node_modules/zod/src/v4/classic/tests/string.test.ts +127 -5
  327. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +18 -0
  328. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +11 -2
  329. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +1585 -173
  330. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +45 -30
  331. package/node_modules/zod/src/v4/classic/tests/union.test.ts +39 -2
  332. package/node_modules/zod/src/v4/classic/tests/validate.test.ts +76 -0
  333. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +2 -2
  334. package/node_modules/zod/src/v4/core/api.ts +48 -12
  335. package/node_modules/zod/src/v4/core/checks.ts +57 -44
  336. package/node_modules/zod/src/v4/core/compile.ts +2188 -0
  337. package/node_modules/zod/src/v4/core/core.ts +98 -19
  338. package/node_modules/zod/src/v4/core/doc.ts +11 -7
  339. package/node_modules/zod/src/v4/core/errors.ts +115 -24
  340. package/node_modules/zod/src/v4/core/index.ts +3 -0
  341. package/node_modules/zod/src/v4/core/json-schema-generator.ts +6 -1
  342. package/node_modules/zod/src/v4/core/json-schema-processors.ts +257 -93
  343. package/node_modules/zod/src/v4/core/json-schema.ts +2 -1
  344. package/node_modules/zod/src/v4/core/memoizer.ts +284 -0
  345. package/node_modules/zod/src/v4/core/parse.ts +131 -38
  346. package/node_modules/zod/src/v4/core/regexes.ts +30 -13
  347. package/node_modules/zod/src/v4/core/registries.ts +2 -2
  348. package/node_modules/zod/src/v4/core/schemas.ts +759 -461
  349. package/node_modules/zod/src/v4/core/tests/compile-differential.test.ts +969 -0
  350. package/node_modules/zod/src/v4/core/tests/compile-global.test.ts +89 -0
  351. package/node_modules/zod/src/v4/core/tests/compile-off-by-default.test.ts +26 -0
  352. package/node_modules/zod/src/v4/core/tests/compile-stats.test.ts +34 -0
  353. package/node_modules/zod/src/v4/core/tests/compile.test.ts +1639 -0
  354. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +1 -2
  355. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +1 -2
  356. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +3 -3
  357. package/node_modules/zod/src/v4/core/tests/locales/parity.test.ts +42 -0
  358. package/node_modules/zod/src/v4/core/tests/locales/tk.test.ts +69 -0
  359. package/node_modules/zod/src/v4/core/tests/treeshake.test.ts +51 -0
  360. package/node_modules/zod/src/v4/core/tests/url-no-canparse.test.ts +31 -0
  361. package/node_modules/zod/src/v4/core/to-json-schema.ts +275 -42
  362. package/node_modules/zod/src/v4/core/util.ts +268 -42
  363. package/node_modules/zod/src/v4/core/versions.ts +2 -2
  364. package/node_modules/zod/src/v4/core/visit.ts +193 -0
  365. package/node_modules/zod/src/v4/index.ts +3 -3
  366. package/node_modules/zod/src/v4/locales/ar.ts +3 -0
  367. package/node_modules/zod/src/v4/locales/az.ts +3 -0
  368. package/node_modules/zod/src/v4/locales/be.ts +10 -0
  369. package/node_modules/zod/src/v4/locales/bg.ts +3 -0
  370. package/node_modules/zod/src/v4/locales/bn.ts +121 -0
  371. package/node_modules/zod/src/v4/locales/ca.ts +3 -0
  372. package/node_modules/zod/src/v4/locales/ckb.ts +138 -0
  373. package/node_modules/zod/src/v4/locales/cs.ts +3 -0
  374. package/node_modules/zod/src/v4/locales/da.ts +5 -2
  375. package/node_modules/zod/src/v4/locales/de.ts +3 -0
  376. package/node_modules/zod/src/v4/locales/el.ts +1 -0
  377. package/node_modules/zod/src/v4/locales/en.ts +15 -4
  378. package/node_modules/zod/src/v4/locales/eo.ts +3 -0
  379. package/node_modules/zod/src/v4/locales/es.ts +2 -0
  380. package/node_modules/zod/src/v4/locales/fa.ts +3 -0
  381. package/node_modules/zod/src/v4/locales/fi.ts +3 -0
  382. package/node_modules/zod/src/v4/locales/fr-CA.ts +3 -0
  383. package/node_modules/zod/src/v4/locales/fr.ts +19 -14
  384. package/node_modules/zod/src/v4/locales/gu.ts +121 -0
  385. package/node_modules/zod/src/v4/locales/he.ts +6 -1
  386. package/node_modules/zod/src/v4/locales/hi.ts +124 -0
  387. package/node_modules/zod/src/v4/locales/hr.ts +2 -0
  388. package/node_modules/zod/src/v4/locales/hu.ts +3 -0
  389. package/node_modules/zod/src/v4/locales/hy.ts +9 -0
  390. package/node_modules/zod/src/v4/locales/id.ts +3 -0
  391. package/node_modules/zod/src/v4/locales/index.ts +10 -0
  392. package/node_modules/zod/src/v4/locales/is.ts +3 -0
  393. package/node_modules/zod/src/v4/locales/it.ts +3 -0
  394. package/node_modules/zod/src/v4/locales/ja.ts +3 -0
  395. package/node_modules/zod/src/v4/locales/ka.ts +3 -0
  396. package/node_modules/zod/src/v4/locales/km.ts +3 -0
  397. package/node_modules/zod/src/v4/locales/kn.ts +124 -0
  398. package/node_modules/zod/src/v4/locales/ko.ts +3 -0
  399. package/node_modules/zod/src/v4/locales/lt.ts +2 -0
  400. package/node_modules/zod/src/v4/locales/mk.ts +3 -0
  401. package/node_modules/zod/src/v4/locales/ms.ts +3 -0
  402. package/node_modules/zod/src/v4/locales/ne.ts +126 -0
  403. package/node_modules/zod/src/v4/locales/nl.ts +3 -0
  404. package/node_modules/zod/src/v4/locales/nn.ts +119 -0
  405. package/node_modules/zod/src/v4/locales/no.ts +5 -2
  406. package/node_modules/zod/src/v4/locales/ota.ts +3 -0
  407. package/node_modules/zod/src/v4/locales/pl.ts +3 -0
  408. package/node_modules/zod/src/v4/locales/ps.ts +3 -0
  409. package/node_modules/zod/src/v4/locales/pt-BR.ts +159 -0
  410. package/node_modules/zod/src/v4/locales/pt.ts +99 -58
  411. package/node_modules/zod/src/v4/locales/ro.ts +1 -0
  412. package/node_modules/zod/src/v4/locales/ru.ts +10 -0
  413. package/node_modules/zod/src/v4/locales/sk.ts +121 -0
  414. package/node_modules/zod/src/v4/locales/sl.ts +3 -0
  415. package/node_modules/zod/src/v4/locales/sv.ts +5 -2
  416. package/node_modules/zod/src/v4/locales/ta.ts +3 -0
  417. package/node_modules/zod/src/v4/locales/th.ts +3 -0
  418. package/node_modules/zod/src/v4/locales/tk.ts +111 -0
  419. package/node_modules/zod/src/v4/locales/tr.ts +3 -0
  420. package/node_modules/zod/src/v4/locales/uk.ts +3 -0
  421. package/node_modules/zod/src/v4/locales/ur.ts +3 -0
  422. package/node_modules/zod/src/v4/locales/uz.ts +1 -0
  423. package/node_modules/zod/src/v4/locales/vi.ts +3 -0
  424. package/node_modules/zod/src/v4/locales/yo.ts +3 -0
  425. package/node_modules/zod/src/v4/locales/zh-CN.ts +3 -0
  426. package/node_modules/zod/src/v4/locales/zh-TW.ts +3 -0
  427. package/node_modules/zod/src/v4/mini/checks.ts +1 -0
  428. package/node_modules/zod/src/v4/mini/deep-partial.ts +73 -0
  429. package/node_modules/zod/src/v4/mini/external.ts +10 -1
  430. package/node_modules/zod/src/v4/mini/in-out.ts +45 -0
  431. package/node_modules/zod/src/v4/mini/parse.ts +2 -0
  432. package/node_modules/zod/src/v4/mini/schemas.ts +135 -56
  433. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +33 -0
  434. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +62 -1
  435. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +14 -0
  436. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +35 -1
  437. package/node_modules/zod/src/v4/mini/tests/cyclic-data.test.ts +84 -0
  438. package/node_modules/zod/src/v4/mini/tests/deep-partial.test.ts +54 -0
  439. package/node_modules/zod/src/v4/mini/tests/error.test.ts +23 -4
  440. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +9 -0
  441. package/node_modules/zod/src/v4/mini/tests/index.test.ts +72 -5
  442. package/node_modules/zod/src/v4/mini/tests/number.test.ts +14 -0
  443. package/node_modules/zod/src/v4/mini/tests/object.test.ts +65 -0
  444. package/node_modules/zod/src/v4/mini/tests/string.test.ts +21 -0
  445. package/node_modules/zod/v3/ZodError.cjs +22 -12
  446. package/node_modules/zod/v3/ZodError.d.cts +1 -1
  447. package/node_modules/zod/v3/ZodError.d.ts +1 -1
  448. package/node_modules/zod/v3/ZodError.js +22 -12
  449. package/node_modules/zod/v3/types.cjs +7 -5
  450. package/node_modules/zod/v3/types.js +7 -5
  451. package/node_modules/zod/v4/classic/checks.cjs +2 -1
  452. package/node_modules/zod/v4/classic/checks.d.cts +1 -1
  453. package/node_modules/zod/v4/classic/checks.d.ts +1 -1
  454. package/node_modules/zod/v4/classic/checks.js +1 -1
  455. package/node_modules/zod/v4/classic/compat.d.cts +9 -11
  456. package/node_modules/zod/v4/classic/compat.d.ts +9 -11
  457. package/node_modules/zod/v4/classic/deep-partial.cjs +39 -0
  458. package/node_modules/zod/v4/classic/deep-partial.d.cts +14 -0
  459. package/node_modules/zod/v4/classic/deep-partial.d.ts +14 -0
  460. package/node_modules/zod/v4/classic/deep-partial.js +13 -0
  461. package/node_modules/zod/v4/classic/errors.cjs +43 -34
  462. package/node_modules/zod/v4/classic/errors.d.cts +3 -4
  463. package/node_modules/zod/v4/classic/errors.d.ts +3 -4
  464. package/node_modules/zod/v4/classic/errors.js +43 -34
  465. package/node_modules/zod/v4/classic/external.cjs +30 -27
  466. package/node_modules/zod/v4/classic/external.d.cts +5 -2
  467. package/node_modules/zod/v4/classic/external.d.ts +5 -2
  468. package/node_modules/zod/v4/classic/external.js +5 -8
  469. package/node_modules/zod/v4/classic/from-json-schema.cjs +136 -75
  470. package/node_modules/zod/v4/classic/from-json-schema.js +136 -75
  471. package/node_modules/zod/v4/classic/in-out.cjs +63 -0
  472. package/node_modules/zod/v4/classic/in-out.d.cts +8 -0
  473. package/node_modules/zod/v4/classic/in-out.d.ts +8 -0
  474. package/node_modules/zod/v4/classic/in-out.js +36 -0
  475. package/node_modules/zod/v4/classic/index.cjs +2 -2
  476. package/node_modules/zod/v4/classic/index.d.cts +1 -2
  477. package/node_modules/zod/v4/classic/index.d.ts +1 -2
  478. package/node_modules/zod/v4/classic/index.js +2 -2
  479. package/node_modules/zod/v4/classic/iso.cjs +11 -22
  480. package/node_modules/zod/v4/classic/iso.d.cts +2 -17
  481. package/node_modules/zod/v4/classic/iso.d.ts +2 -17
  482. package/node_modules/zod/v4/classic/iso.js +2 -17
  483. package/node_modules/zod/v4/classic/parse.cjs +4 -1
  484. package/node_modules/zod/v4/classic/parse.d.cts +17 -4
  485. package/node_modules/zod/v4/classic/parse.d.ts +17 -4
  486. package/node_modules/zod/v4/classic/parse.js +1 -0
  487. package/node_modules/zod/v4/classic/schemas.cjs +498 -398
  488. package/node_modules/zod/v4/classic/schemas.d.cts +53 -18
  489. package/node_modules/zod/v4/classic/schemas.d.ts +53 -18
  490. package/node_modules/zod/v4/classic/schemas.js +492 -396
  491. package/node_modules/zod/v4/core/api.cjs +23 -4
  492. package/node_modules/zod/v4/core/api.d.cts +13 -9
  493. package/node_modules/zod/v4/core/api.d.ts +13 -9
  494. package/node_modules/zod/v4/core/api.js +21 -4
  495. package/node_modules/zod/v4/core/checks.cjs +37 -31
  496. package/node_modules/zod/v4/core/checks.d.cts +13 -13
  497. package/node_modules/zod/v4/core/checks.d.ts +13 -13
  498. package/node_modules/zod/v4/core/checks.js +37 -31
  499. package/node_modules/zod/v4/core/compile.cjs +1813 -0
  500. package/node_modules/zod/v4/core/compile.d.cts +51 -0
  501. package/node_modules/zod/v4/core/compile.d.ts +51 -0
  502. package/node_modules/zod/v4/core/compile.js +1783 -0
  503. package/node_modules/zod/v4/core/core.cjs +81 -18
  504. package/node_modules/zod/v4/core/core.d.cts +16 -4
  505. package/node_modules/zod/v4/core/core.d.ts +16 -4
  506. package/node_modules/zod/v4/core/core.js +82 -19
  507. package/node_modules/zod/v4/core/doc.cjs +5 -7
  508. package/node_modules/zod/v4/core/doc.d.cts +3 -1
  509. package/node_modules/zod/v4/core/doc.d.ts +3 -1
  510. package/node_modules/zod/v4/core/doc.js +5 -7
  511. package/node_modules/zod/v4/core/errors.cjs +110 -25
  512. package/node_modules/zod/v4/core/errors.d.cts +4 -0
  513. package/node_modules/zod/v4/core/errors.d.ts +4 -0
  514. package/node_modules/zod/v4/core/errors.js +110 -25
  515. package/node_modules/zod/v4/core/index.cjs +5 -1
  516. package/node_modules/zod/v4/core/index.d.cts +3 -0
  517. package/node_modules/zod/v4/core/index.d.ts +3 -0
  518. package/node_modules/zod/v4/core/index.js +3 -0
  519. package/node_modules/zod/v4/core/json-schema-generator.cjs +4 -0
  520. package/node_modules/zod/v4/core/json-schema-generator.d.cts +2 -2
  521. package/node_modules/zod/v4/core/json-schema-generator.d.ts +2 -2
  522. package/node_modules/zod/v4/core/json-schema-generator.js +4 -0
  523. package/node_modules/zod/v4/core/json-schema-processors.cjs +264 -95
  524. package/node_modules/zod/v4/core/json-schema-processors.js +243 -97
  525. package/node_modules/zod/v4/core/json-schema.d.cts +2 -1
  526. package/node_modules/zod/v4/core/json-schema.d.ts +2 -1
  527. package/node_modules/zod/v4/core/memoizer.cjs +272 -0
  528. package/node_modules/zod/v4/core/memoizer.d.cts +15 -0
  529. package/node_modules/zod/v4/core/memoizer.d.ts +15 -0
  530. package/node_modules/zod/v4/core/memoizer.js +265 -0
  531. package/node_modules/zod/v4/core/parse.cjs +96 -34
  532. package/node_modules/zod/v4/core/parse.d.cts +14 -11
  533. package/node_modules/zod/v4/core/parse.d.ts +14 -11
  534. package/node_modules/zod/v4/core/parse.js +94 -33
  535. package/node_modules/zod/v4/core/regexes.cjs +27 -15
  536. package/node_modules/zod/v4/core/regexes.d.cts +2 -0
  537. package/node_modules/zod/v4/core/regexes.d.ts +2 -0
  538. package/node_modules/zod/v4/core/regexes.js +24 -13
  539. package/node_modules/zod/v4/core/registries.js +2 -2
  540. package/node_modules/zod/v4/core/schemas.cjs +537 -326
  541. package/node_modules/zod/v4/core/schemas.d.cts +100 -31
  542. package/node_modules/zod/v4/core/schemas.d.ts +100 -31
  543. package/node_modules/zod/v4/core/schemas.js +526 -325
  544. package/node_modules/zod/v4/core/to-json-schema.cjs +242 -39
  545. package/node_modules/zod/v4/core/to-json-schema.d.cts +42 -3
  546. package/node_modules/zod/v4/core/to-json-schema.d.ts +42 -3
  547. package/node_modules/zod/v4/core/to-json-schema.js +241 -39
  548. package/node_modules/zod/v4/core/util.cjs +212 -31
  549. package/node_modules/zod/v4/core/util.d.cts +58 -1
  550. package/node_modules/zod/v4/core/util.d.ts +58 -1
  551. package/node_modules/zod/v4/core/util.js +202 -30
  552. package/node_modules/zod/v4/core/versions.cjs +2 -2
  553. package/node_modules/zod/v4/core/versions.d.cts +1 -1
  554. package/node_modules/zod/v4/core/versions.d.ts +1 -1
  555. package/node_modules/zod/v4/core/versions.js +2 -2
  556. package/node_modules/zod/v4/core/visit.cjs +195 -0
  557. package/node_modules/zod/v4/core/visit.d.cts +30 -0
  558. package/node_modules/zod/v4/core/visit.d.ts +30 -0
  559. package/node_modules/zod/v4/core/visit.js +169 -0
  560. package/node_modules/zod/v4/index.cjs +15 -5
  561. package/node_modules/zod/v4/index.d.cts +2 -2
  562. package/node_modules/zod/v4/index.d.ts +2 -2
  563. package/node_modules/zod/v4/index.js +3 -2
  564. package/node_modules/zod/v4/locales/ar.cjs +3 -0
  565. package/node_modules/zod/v4/locales/ar.js +3 -0
  566. package/node_modules/zod/v4/locales/az.cjs +3 -0
  567. package/node_modules/zod/v4/locales/az.js +3 -0
  568. package/node_modules/zod/v4/locales/be.cjs +10 -0
  569. package/node_modules/zod/v4/locales/be.js +10 -0
  570. package/node_modules/zod/v4/locales/bg.cjs +3 -0
  571. package/node_modules/zod/v4/locales/bg.js +3 -0
  572. package/node_modules/zod/v4/locales/bn.cjs +138 -0
  573. package/node_modules/zod/v4/locales/bn.d.cts +5 -0
  574. package/node_modules/zod/v4/locales/bn.d.ts +4 -0
  575. package/node_modules/zod/v4/locales/bn.js +111 -0
  576. package/node_modules/zod/v4/locales/ca.cjs +3 -0
  577. package/node_modules/zod/v4/locales/ca.js +3 -0
  578. package/node_modules/zod/v4/locales/ckb.cjs +158 -0
  579. package/node_modules/zod/v4/locales/ckb.d.cts +5 -0
  580. package/node_modules/zod/v4/locales/ckb.d.ts +4 -0
  581. package/node_modules/zod/v4/locales/ckb.js +131 -0
  582. package/node_modules/zod/v4/locales/cs.cjs +3 -0
  583. package/node_modules/zod/v4/locales/cs.js +3 -0
  584. package/node_modules/zod/v4/locales/da.cjs +5 -2
  585. package/node_modules/zod/v4/locales/da.js +5 -2
  586. package/node_modules/zod/v4/locales/de.cjs +3 -0
  587. package/node_modules/zod/v4/locales/de.js +3 -0
  588. package/node_modules/zod/v4/locales/el.cjs +1 -0
  589. package/node_modules/zod/v4/locales/el.js +1 -0
  590. package/node_modules/zod/v4/locales/en.cjs +14 -4
  591. package/node_modules/zod/v4/locales/en.js +14 -4
  592. package/node_modules/zod/v4/locales/eo.cjs +3 -0
  593. package/node_modules/zod/v4/locales/eo.js +3 -0
  594. package/node_modules/zod/v4/locales/es.cjs +2 -0
  595. package/node_modules/zod/v4/locales/es.js +2 -0
  596. package/node_modules/zod/v4/locales/fa.cjs +3 -0
  597. package/node_modules/zod/v4/locales/fa.js +3 -0
  598. package/node_modules/zod/v4/locales/fi.cjs +3 -0
  599. package/node_modules/zod/v4/locales/fi.js +3 -0
  600. package/node_modules/zod/v4/locales/fr-CA.cjs +3 -0
  601. package/node_modules/zod/v4/locales/fr-CA.js +3 -0
  602. package/node_modules/zod/v4/locales/fr.cjs +16 -14
  603. package/node_modules/zod/v4/locales/fr.js +16 -14
  604. package/node_modules/zod/v4/locales/gu.cjs +138 -0
  605. package/node_modules/zod/v4/locales/gu.d.cts +5 -0
  606. package/node_modules/zod/v4/locales/gu.d.ts +4 -0
  607. package/node_modules/zod/v4/locales/gu.js +111 -0
  608. package/node_modules/zod/v4/locales/he.cjs +5 -0
  609. package/node_modules/zod/v4/locales/he.js +5 -0
  610. package/node_modules/zod/v4/locales/hi.cjs +136 -0
  611. package/node_modules/zod/v4/locales/hi.d.cts +5 -0
  612. package/node_modules/zod/v4/locales/hi.d.ts +4 -0
  613. package/node_modules/zod/v4/locales/hi.js +109 -0
  614. package/node_modules/zod/v4/locales/hr.cjs +2 -0
  615. package/node_modules/zod/v4/locales/hr.js +2 -0
  616. package/node_modules/zod/v4/locales/hu.cjs +3 -0
  617. package/node_modules/zod/v4/locales/hu.js +3 -0
  618. package/node_modules/zod/v4/locales/hy.cjs +9 -0
  619. package/node_modules/zod/v4/locales/hy.js +9 -0
  620. package/node_modules/zod/v4/locales/id.cjs +3 -0
  621. package/node_modules/zod/v4/locales/id.js +3 -0
  622. package/node_modules/zod/v4/locales/index.cjs +22 -2
  623. package/node_modules/zod/v4/locales/index.d.cts +10 -0
  624. package/node_modules/zod/v4/locales/index.d.ts +10 -0
  625. package/node_modules/zod/v4/locales/index.js +10 -0
  626. package/node_modules/zod/v4/locales/is.cjs +3 -0
  627. package/node_modules/zod/v4/locales/is.js +3 -0
  628. package/node_modules/zod/v4/locales/it.cjs +3 -0
  629. package/node_modules/zod/v4/locales/it.js +3 -0
  630. package/node_modules/zod/v4/locales/ja.cjs +3 -0
  631. package/node_modules/zod/v4/locales/ja.js +3 -0
  632. package/node_modules/zod/v4/locales/ka.cjs +3 -0
  633. package/node_modules/zod/v4/locales/ka.js +3 -0
  634. package/node_modules/zod/v4/locales/km.cjs +3 -0
  635. package/node_modules/zod/v4/locales/km.js +3 -0
  636. package/node_modules/zod/v4/locales/kn.cjs +141 -0
  637. package/node_modules/zod/v4/locales/kn.d.cts +5 -0
  638. package/node_modules/zod/v4/locales/kn.d.ts +4 -0
  639. package/node_modules/zod/v4/locales/kn.js +114 -0
  640. package/node_modules/zod/v4/locales/ko.cjs +3 -0
  641. package/node_modules/zod/v4/locales/ko.js +3 -0
  642. package/node_modules/zod/v4/locales/lt.cjs +2 -0
  643. package/node_modules/zod/v4/locales/lt.js +2 -0
  644. package/node_modules/zod/v4/locales/mk.cjs +3 -0
  645. package/node_modules/zod/v4/locales/mk.js +3 -0
  646. package/node_modules/zod/v4/locales/ms.cjs +3 -0
  647. package/node_modules/zod/v4/locales/ms.js +3 -0
  648. package/node_modules/zod/v4/locales/ne.cjs +136 -0
  649. package/node_modules/zod/v4/locales/ne.d.cts +5 -0
  650. package/node_modules/zod/v4/locales/ne.d.ts +4 -0
  651. package/node_modules/zod/v4/locales/ne.js +109 -0
  652. package/node_modules/zod/v4/locales/nl.cjs +3 -0
  653. package/node_modules/zod/v4/locales/nl.js +3 -0
  654. package/node_modules/zod/v4/locales/nn.cjs +138 -0
  655. package/node_modules/zod/v4/locales/nn.d.cts +5 -0
  656. package/node_modules/zod/v4/locales/nn.d.ts +4 -0
  657. package/node_modules/zod/v4/locales/nn.js +111 -0
  658. package/node_modules/zod/v4/locales/no.cjs +5 -2
  659. package/node_modules/zod/v4/locales/no.js +5 -2
  660. package/node_modules/zod/v4/locales/ota.cjs +3 -0
  661. package/node_modules/zod/v4/locales/ota.js +3 -0
  662. package/node_modules/zod/v4/locales/pl.cjs +3 -0
  663. package/node_modules/zod/v4/locales/pl.js +3 -0
  664. package/node_modules/zod/v4/locales/ps.cjs +3 -0
  665. package/node_modules/zod/v4/locales/ps.js +3 -0
  666. package/node_modules/zod/v4/locales/pt-BR.cjs +168 -0
  667. package/node_modules/zod/v4/locales/pt-BR.d.cts +5 -0
  668. package/node_modules/zod/v4/locales/pt-BR.d.ts +4 -0
  669. package/node_modules/zod/v4/locales/pt-BR.js +141 -0
  670. package/node_modules/zod/v4/locales/pt.cjs +87 -55
  671. package/node_modules/zod/v4/locales/pt.js +87 -55
  672. package/node_modules/zod/v4/locales/ro.cjs +1 -0
  673. package/node_modules/zod/v4/locales/ro.js +1 -0
  674. package/node_modules/zod/v4/locales/ru.cjs +10 -0
  675. package/node_modules/zod/v4/locales/ru.js +10 -0
  676. package/node_modules/zod/v4/locales/sk.cjs +141 -0
  677. package/node_modules/zod/v4/locales/sk.d.cts +5 -0
  678. package/node_modules/zod/v4/locales/sk.d.ts +4 -0
  679. package/node_modules/zod/v4/locales/sk.js +114 -0
  680. package/node_modules/zod/v4/locales/sl.cjs +3 -0
  681. package/node_modules/zod/v4/locales/sl.js +3 -0
  682. package/node_modules/zod/v4/locales/sv.cjs +5 -2
  683. package/node_modules/zod/v4/locales/sv.js +5 -2
  684. package/node_modules/zod/v4/locales/ta.cjs +3 -0
  685. package/node_modules/zod/v4/locales/ta.js +3 -0
  686. package/node_modules/zod/v4/locales/th.cjs +3 -0
  687. package/node_modules/zod/v4/locales/th.js +3 -0
  688. package/node_modules/zod/v4/locales/tk.cjs +132 -0
  689. package/node_modules/zod/v4/locales/tk.d.cts +5 -0
  690. package/node_modules/zod/v4/locales/tk.d.ts +4 -0
  691. package/node_modules/zod/v4/locales/tk.js +105 -0
  692. package/node_modules/zod/v4/locales/tr.cjs +3 -0
  693. package/node_modules/zod/v4/locales/tr.js +3 -0
  694. package/node_modules/zod/v4/locales/uk.cjs +3 -0
  695. package/node_modules/zod/v4/locales/uk.js +3 -0
  696. package/node_modules/zod/v4/locales/ur.cjs +3 -0
  697. package/node_modules/zod/v4/locales/ur.js +3 -0
  698. package/node_modules/zod/v4/locales/uz.cjs +1 -0
  699. package/node_modules/zod/v4/locales/uz.js +1 -0
  700. package/node_modules/zod/v4/locales/vi.cjs +3 -0
  701. package/node_modules/zod/v4/locales/vi.js +3 -0
  702. package/node_modules/zod/v4/locales/yo.cjs +3 -0
  703. package/node_modules/zod/v4/locales/yo.js +3 -0
  704. package/node_modules/zod/v4/locales/zh-CN.cjs +3 -0
  705. package/node_modules/zod/v4/locales/zh-CN.js +3 -0
  706. package/node_modules/zod/v4/locales/zh-TW.cjs +3 -0
  707. package/node_modules/zod/v4/locales/zh-TW.js +3 -0
  708. package/node_modules/zod/v4/mini/checks.cjs +2 -1
  709. package/node_modules/zod/v4/mini/checks.d.cts +1 -1
  710. package/node_modules/zod/v4/mini/checks.d.ts +1 -1
  711. package/node_modules/zod/v4/mini/checks.js +1 -1
  712. package/node_modules/zod/v4/mini/deep-partial.cjs +39 -0
  713. package/node_modules/zod/v4/mini/deep-partial.d.cts +14 -0
  714. package/node_modules/zod/v4/mini/deep-partial.d.ts +14 -0
  715. package/node_modules/zod/v4/mini/deep-partial.js +13 -0
  716. package/node_modules/zod/v4/mini/external.cjs +12 -1
  717. package/node_modules/zod/v4/mini/external.d.cts +5 -2
  718. package/node_modules/zod/v4/mini/external.d.ts +5 -2
  719. package/node_modules/zod/v4/mini/external.js +3 -1
  720. package/node_modules/zod/v4/mini/in-out.cjs +63 -0
  721. package/node_modules/zod/v4/mini/in-out.d.cts +8 -0
  722. package/node_modules/zod/v4/mini/in-out.d.ts +8 -0
  723. package/node_modules/zod/v4/mini/in-out.js +36 -0
  724. package/node_modules/zod/v4/mini/parse.cjs +3 -1
  725. package/node_modules/zod/v4/mini/parse.d.cts +1 -1
  726. package/node_modules/zod/v4/mini/parse.d.ts +1 -1
  727. package/node_modules/zod/v4/mini/parse.js +1 -1
  728. package/node_modules/zod/v4/mini/schemas.cjs +75 -47
  729. package/node_modules/zod/v4/mini/schemas.d.cts +43 -13
  730. package/node_modules/zod/v4/mini/schemas.d.ts +43 -13
  731. package/node_modules/zod/v4/mini/schemas.js +71 -45
  732. package/openclaw.plugin.json +27 -56
  733. package/package.json +10 -7
  734. package/dist/targets-BTQCYRZQ.js +0 -48
  735. package/node_modules/zod/src/v4/core/config.ts +0 -15
  736. /package/dist/{audio-preflight.runtime-BBfC9elv.js → .setup/audio-preflight.runtime-BBfC9elv.mjs} +0 -0
  737. /package/dist/{doctor-contract-w6FpMypv.js → .setup/doctor-contract-w6FpMypv.mjs} +0 -0
  738. /package/dist/{json-response-DXajw_FU.js → .setup/json-response-DXajw_FU.mjs} +0 -0
  739. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  740. /package/dist/{runtime-C5JxBWZp.js → .setup/runtime-C5JxBWZp.mjs} +0 -0
  741. /package/dist/{secret-contract-BCpDLdg9.js → .setup/secret-contract-BCpDLdg9.mjs} +0 -0
  742. /package/dist/{security-audit-shared-CK5rVR-1.js → .setup/security-audit-shared-CK5rVR-1.mjs} +0 -0
  743. /package/dist/{thread-bindings-BiL1wGqK.js → .setup/thread-bindings-BiL1wGqK.mjs} +0 -0
@@ -23,11 +23,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.$ZodTuple = exports.$ZodIntersection = exports.$ZodDiscriminatedUnion = exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = 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.$ZodE164 = exports.$ZodBase64URL = exports.$ZodBase64 = 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.$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 = void 0;
26
+ exports.$ZodXor = exports.$ZodUnion = exports.$ZodObjectJIT = 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.$ZodCreditCard = exports.$ZodE164 = exports.$ZodBase64URL = exports.$ZodBase64 = 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 = void 0;
28
+ exports.standardProps = standardProps;
29
+ exports.parseURLObject = parseURLObject;
30
+ exports.stripTabAndNewline = stripTabAndNewline;
31
+ exports.urlHostnameOk = urlHostnameOk;
32
+ exports.urlProtocolOk = urlProtocolOk;
33
+ exports.isValidIPv6 = isValidIPv6;
34
+ exports.isValidCIDRv6 = isValidCIDRv6;
28
35
  exports.isValidBase64 = isValidBase64;
29
36
  exports.isValidBase64URL = isValidBase64URL;
37
+ exports.isValidCreditCard = isValidCreditCard;
30
38
  exports.isValidJWT = isValidJWT;
39
+ exports.getDiscriminatedOption = getDiscriminatedOption;
40
+ exports.mergeValues = mergeValues;
31
41
  const checks = __importStar(require("./checks.cjs"));
32
42
  const core = __importStar(require("./core.cjs"));
33
43
  const doc_js_1 = require("./doc.cjs");
@@ -41,19 +51,20 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
41
51
  inst._zod.def = def; // set _def property
42
52
  inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
43
53
  inst._zod.version = versions_js_1.version;
44
- const checks = [...(inst._zod.def.checks ?? [])];
54
+ const defChecks = inst._zod.def.checks;
45
55
  // if inst is itself a checks.$ZodCheck, run it as a check
46
- if (inst._zod.traits.has("$ZodCheck")) {
47
- checks.unshift(inst);
48
- }
56
+ const checks = inst._zod.traits.has("$ZodCheck")
57
+ ? [inst, ...(defChecks ?? [])]
58
+ : defChecks?.length
59
+ ? [...defChecks]
60
+ : [];
49
61
  for (const ch of checks) {
50
62
  for (const fn of ch._zod.onattach) {
51
63
  fn(inst);
52
64
  }
53
65
  }
54
66
  if (checks.length === 0) {
55
- // deferred initializer
56
- // inst._zod.parse is not yet defined
67
+ // deferred initializer inst._zod.parse is not yet defined
57
68
  (_a = inst._zod).deferred ?? (_a.deferred = []);
58
69
  inst._zod.deferred?.push(() => {
59
70
  inst._zod.run = inst._zod.parse;
@@ -61,6 +72,8 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
61
72
  }
62
73
  else {
63
74
  const runChecks = (payload, checks, ctx) => {
75
+ if (payload.memo)
76
+ return payload;
64
77
  let isAborted = util.aborted(payload);
65
78
  let asyncResult;
66
79
  for (const ch of checks) {
@@ -85,6 +98,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
85
98
  const nextLen = payload.issues.length;
86
99
  if (nextLen === currLen)
87
100
  return;
101
+ util.attachSchema(payload.issues, currLen, inst);
88
102
  if (!isAborted)
89
103
  isAborted = util.aborted(payload, currLen);
90
104
  });
@@ -93,6 +107,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
93
107
  const nextLen = payload.issues.length;
94
108
  if (nextLen === currLen)
95
109
  continue;
110
+ util.attachSchema(payload.issues, currLen, inst);
96
111
  if (!isAborted)
97
112
  isAborted = util.aborted(payload, currLen);
98
113
  }
@@ -124,8 +139,7 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
124
139
  return inst._zod.parse(payload, ctx);
125
140
  }
126
141
  if (ctx.direction === "backward") {
127
- // run canary
128
- // initial pass (no checks)
142
+ // run canary initial pass (no checks)
129
143
  const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
130
144
  if (canary instanceof Promise) {
131
145
  return canary.then((canary) => {
@@ -144,21 +158,31 @@ exports.$ZodType = core.$constructor("$ZodType", (inst, def) => {
144
158
  return runChecks(result, checks, ctx);
145
159
  };
146
160
  }
147
- // Lazy initialize ~standard to avoid creating objects for every schema
148
- util.defineLazy(inst, "~standard", () => ({
161
+ }, {
162
+ // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
163
+ get "~standard"() {
164
+ return util.hide(this, "~standard", standardProps(this));
165
+ },
166
+ set "~standard"(value) {
167
+ util.own(this, "~standard", value);
168
+ },
169
+ });
170
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
171
+ const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
172
+ function standardProps(inst) {
173
+ return {
149
174
  validate: (value) => {
150
175
  try {
151
- const r = (0, parse_js_1.safeParse)(inst, value);
152
- return r.success ? { value: r.data } : { issues: r.error?.issues };
176
+ return toStandardResult((0, parse_js_1.safeParse)(inst, value));
153
177
  }
154
178
  catch (_) {
155
- return (0, parse_js_1.safeParseAsync)(inst, value).then((r) => (r.success ? { value: r.data } : { issues: r.error?.issues }));
179
+ return (0, parse_js_1.safeParseAsync)(inst, value).then(toStandardResult);
156
180
  }
157
181
  },
158
182
  vendor: "zod",
159
183
  version: 1,
160
- }));
161
- });
184
+ };
185
+ }
162
186
  var util_js_1 = require("./util.cjs");
163
187
  Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return util_js_1.clone; } });
164
188
  exports.$ZodString = core.$constructor("$ZodString", (inst, def) => {
@@ -215,66 +239,89 @@ exports.$ZodEmail = core.$constructor("$ZodEmail", (inst, def) => {
215
239
  def.pattern ?? (def.pattern = regexes.email);
216
240
  exports.$ZodStringFormat.init(inst, def);
217
241
  });
242
+ /** The `://` guard rejected the input before the URL constructor saw it. */
243
+ exports.URL_BAD_FORMAT = 1;
244
+ /** The URL constructor rejected the input. */
245
+ exports.URL_UNPARSEABLE = 2;
246
+ /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
247
+ function parseURLObject(trimmed, def) {
248
+ // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
249
+ if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
250
+ return exports.URL_BAD_FORMAT;
251
+ }
252
+ try {
253
+ // @ts-ignore
254
+ return new URL(trimmed);
255
+ }
256
+ catch {
257
+ return exports.URL_UNPARSEABLE;
258
+ }
259
+ }
260
+ const asciiTabOrNewline = /[\t\n\r]/g;
261
+ /** 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. */
262
+ function stripTabAndNewline(value) {
263
+ return value.replace(asciiTabOrNewline, "");
264
+ }
265
+ function urlHostnameOk(url, hostname) {
266
+ hostname.lastIndex = 0;
267
+ return hostname.test(url.hostname);
268
+ }
269
+ function urlProtocolOk(url, protocol) {
270
+ protocol.lastIndex = 0;
271
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
272
+ }
218
273
  exports.$ZodURL = core.$constructor("$ZodURL", (inst, def) => {
219
274
  exports.$ZodStringFormat.init(inst, def);
220
275
  inst._zod.check = (payload) => {
221
276
  try {
222
277
  // Trim whitespace from input
223
278
  const trimmed = payload.value.trim();
224
- // When normalize is off, require :// for http/https URLs
225
- // This prevents strings like "http:example.com" or "https:/path" from being silently accepted
226
- if (!def.normalize && def.protocol?.source === regexes.httpProtocol.source) {
227
- if (!/^https?:\/\//i.test(trimmed)) {
228
- payload.issues.push({
229
- code: "invalid_format",
230
- format: "url",
231
- note: "Invalid URL format",
232
- input: payload.value,
233
- inst,
234
- continue: !def.abort,
235
- });
236
- return;
237
- }
238
- }
239
- // @ts-ignore
240
- const url = new URL(trimmed);
241
- if (def.hostname) {
242
- def.hostname.lastIndex = 0;
243
- if (!def.hostname.test(url.hostname)) {
244
- payload.issues.push({
245
- code: "invalid_format",
246
- format: "url",
247
- note: "Invalid hostname",
248
- pattern: def.hostname.source,
249
- input: payload.value,
250
- inst,
251
- continue: !def.abort,
252
- });
253
- }
279
+ const url = parseURLObject(trimmed, def);
280
+ if (url === exports.URL_BAD_FORMAT) {
281
+ payload.issues.push({
282
+ code: "invalid_format",
283
+ format: "url",
284
+ note: "Invalid URL format",
285
+ input: payload.value,
286
+ inst,
287
+ continue: !def.abort,
288
+ });
289
+ return;
254
290
  }
255
- if (def.protocol) {
256
- def.protocol.lastIndex = 0;
257
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
258
- payload.issues.push({
259
- code: "invalid_format",
260
- format: "url",
261
- note: "Invalid protocol",
262
- pattern: def.protocol.source,
263
- input: payload.value,
264
- inst,
265
- continue: !def.abort,
266
- });
267
- }
291
+ if (url === exports.URL_UNPARSEABLE) {
292
+ payload.issues.push({
293
+ code: "invalid_format",
294
+ format: "url",
295
+ input: payload.value,
296
+ inst,
297
+ continue: !def.abort,
298
+ });
299
+ return;
268
300
  }
269
- // Set the output value based on normalize flag
270
- if (def.normalize) {
271
- // Use normalized URL
272
- payload.value = url.href;
301
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) {
302
+ payload.issues.push({
303
+ code: "invalid_format",
304
+ format: "url",
305
+ note: "Invalid hostname",
306
+ pattern: def.hostname.source,
307
+ input: payload.value,
308
+ inst,
309
+ continue: !def.abort,
310
+ });
273
311
  }
274
- else {
275
- // Preserve the original input (trimmed)
276
- payload.value = trimmed;
312
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) {
313
+ payload.issues.push({
314
+ code: "invalid_format",
315
+ format: "url",
316
+ note: "Invalid protocol",
317
+ pattern: def.protocol.source,
318
+ input: payload.value,
319
+ inst,
320
+ continue: !def.abort,
321
+ });
277
322
  }
323
+ // Set the output value based on normalize flag
324
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
278
325
  return;
279
326
  }
280
327
  catch (_) {
@@ -293,7 +340,9 @@ exports.$ZodEmoji = core.$constructor("$ZodEmoji", (inst, def) => {
293
340
  exports.$ZodStringFormat.init(inst, def);
294
341
  });
295
342
  exports.$ZodNanoID = core.$constructor("$ZodNanoID", (inst, def) => {
296
- def.pattern ?? (def.pattern = regexes.nanoid);
343
+ if (def.length !== undefined && (!Number.isInteger(def.length) || def.length < 1))
344
+ throw new Error(`Invalid nanoid length: ${def.length}`);
345
+ def.pattern ?? (def.pattern = def.length === undefined ? regexes.nanoid : regexes.nanoidOfLength(def.length));
297
346
  exports.$ZodStringFormat.init(inst, def);
298
347
  });
299
348
  /**
@@ -324,6 +373,13 @@ exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
324
373
  exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
325
374
  def.pattern ?? (def.pattern = regexes.datetime(def));
326
375
  exports.$ZodStringFormat.init(inst, def);
376
+ // these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
377
+ if (def.local || def.precision === -1) {
378
+ inst._zod.bag.laxFormat = true;
379
+ inst._zod.onattach.push((s) => {
380
+ s._zod.bag.laxFormat = true;
381
+ });
382
+ }
327
383
  });
328
384
  exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
329
385
  def.pattern ?? (def.pattern = regexes.date);
@@ -342,17 +398,26 @@ exports.$ZodIPv4 = core.$constructor("$ZodIPv4", (inst, def) => {
342
398
  exports.$ZodStringFormat.init(inst, def);
343
399
  inst._zod.bag.format = `ipv4`;
344
400
  });
401
+ /** 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`. */
402
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
403
+ function isValidIPv6(value) {
404
+ if (!ipv6Alphabet.test(value))
405
+ return false;
406
+ try {
407
+ // @ts-ignore
408
+ new URL(`http://[${value}]`);
409
+ return true;
410
+ }
411
+ catch {
412
+ return false;
413
+ }
414
+ }
345
415
  exports.$ZodIPv6 = core.$constructor("$ZodIPv6", (inst, def) => {
346
416
  def.pattern ?? (def.pattern = regexes.ipv6);
347
417
  exports.$ZodStringFormat.init(inst, def);
348
418
  inst._zod.bag.format = `ipv6`;
349
419
  inst._zod.check = (payload) => {
350
- try {
351
- // @ts-ignore
352
- new URL(`http://[${payload.value}]`);
353
- // return;
354
- }
355
- catch {
420
+ if (!isValidIPv6(payload.value)) {
356
421
  payload.issues.push({
357
422
  code: "invalid_format",
358
423
  format: "ipv6",
@@ -372,26 +437,25 @@ exports.$ZodCIDRv4 = core.$constructor("$ZodCIDRv4", (inst, def) => {
372
437
  def.pattern ?? (def.pattern = regexes.cidrv4);
373
438
  exports.$ZodStringFormat.init(inst, def);
374
439
  });
440
+ function isValidCIDRv6(value) {
441
+ const parts = value.split("/");
442
+ if (parts.length !== 2)
443
+ return false;
444
+ const [address, prefix] = parts;
445
+ if (!prefix)
446
+ return false;
447
+ const prefixNum = Number(prefix);
448
+ if (`${prefixNum}` !== prefix)
449
+ return false;
450
+ if (prefixNum < 0 || prefixNum > 128)
451
+ return false;
452
+ return isValidIPv6(address);
453
+ }
375
454
  exports.$ZodCIDRv6 = core.$constructor("$ZodCIDRv6", (inst, def) => {
376
455
  def.pattern ?? (def.pattern = regexes.cidrv6); // not used for validation
377
456
  exports.$ZodStringFormat.init(inst, def);
378
457
  inst._zod.check = (payload) => {
379
- const parts = payload.value.split("/");
380
- try {
381
- if (parts.length !== 2)
382
- throw new Error();
383
- const [address, prefix] = parts;
384
- if (!prefix)
385
- throw new Error();
386
- const prefixNum = Number(prefix);
387
- if (`${prefixNum}` !== prefix)
388
- throw new Error();
389
- if (prefixNum < 0 || prefixNum > 128)
390
- throw new Error();
391
- // @ts-ignore
392
- new URL(`http://[${address}]`);
393
- }
394
- catch {
458
+ if (!isValidCIDRv6(payload.value)) {
395
459
  payload.issues.push({
396
460
  code: "invalid_format",
397
461
  format: "cidrv6",
@@ -464,6 +528,41 @@ exports.$ZodE164 = core.$constructor("$ZodE164", (inst, def) => {
464
528
  def.pattern ?? (def.pattern = regexes.e164);
465
529
  exports.$ZodStringFormat.init(inst, def);
466
530
  });
531
+ ////////////////////////////// ZodCreditCard //////////////////////////////
532
+ const CC_SANITIZE = /[- ]/g;
533
+ /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
534
+ function isLuhnAlgo(digits) {
535
+ let length = digits.length;
536
+ let bit = 1;
537
+ let sum = 0;
538
+ while (length) {
539
+ const value = +digits[--length];
540
+ bit ^= 1;
541
+ sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
542
+ }
543
+ return sum % 10 === 0;
544
+ }
545
+ function isValidCreditCard(input) {
546
+ if (!regexes.creditCard.test(input))
547
+ return false;
548
+ return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
549
+ }
550
+ exports.$ZodCreditCard = core.$constructor("$ZodCreditCard", (inst, def) => {
551
+ // 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.
552
+ def.pattern ?? (def.pattern = regexes.creditCard);
553
+ exports.$ZodStringFormat.init(inst, def);
554
+ inst._zod.check = (payload) => {
555
+ if (isValidCreditCard(payload.value))
556
+ return;
557
+ payload.issues.push({
558
+ code: "invalid_format",
559
+ format: "credit_card",
560
+ input: payload.value,
561
+ inst,
562
+ continue: !def.abort,
563
+ });
564
+ };
565
+ });
467
566
  ////////////////////////////// ZodJWT //////////////////////////////
468
567
  function isValidJWT(token, algorithm = null) {
469
568
  try {
@@ -532,7 +631,7 @@ exports.$ZodNumber = core.$constructor("$ZodNumber", (inst, def) => {
532
631
  ? Number.isNaN(input)
533
632
  ? "NaN"
534
633
  : !Number.isFinite(input)
535
- ? "Infinity"
634
+ ? String(input)
536
635
  : undefined
537
636
  : undefined;
538
637
  payload.issues.push({
@@ -710,6 +809,8 @@ function handleArrayResult(result, final, index) {
710
809
  }
711
810
  exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
712
811
  exports.$ZodType.init(inst, def);
812
+ const memo = core.globalConfig.memoizer;
813
+ memo?.attach(inst);
713
814
  inst._zod.parse = (payload, ctx) => {
714
815
  const input = payload.value;
715
816
  if (!Array.isArray(input)) {
@@ -721,7 +822,7 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
721
822
  });
722
823
  return payload;
723
824
  }
724
- payload.value = Array(input.length);
825
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
725
826
  const proms = [];
726
827
  for (let i = 0; i < input.length; i++) {
727
828
  const item = input[i];
@@ -742,16 +843,21 @@ exports.$ZodArray = core.$constructor("$ZodArray", (inst, def) => {
742
843
  return payload; //handleArrayResultsAsync(parseResults, final);
743
844
  };
744
845
  });
745
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
846
+ function handlePropertyResult(result, final, key, input, optin, optout) {
746
847
  const isPresent = key in input;
848
+ const isOptionalOut = optout === "optional";
849
+ // 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.
850
+ if (!isPresent && isOptionalOut && optin === "optional") {
851
+ return;
852
+ }
747
853
  if (result.issues.length) {
748
854
  // For optional-in/out schemas, ignore errors on absent keys.
749
- if (isOptionalIn && isOptionalOut && !isPresent) {
855
+ if (optin !== undefined && isOptionalOut && !isPresent) {
750
856
  return;
751
857
  }
752
858
  final.issues.push(...util.prefixIssues(key, result.issues));
753
859
  }
754
- if (!isPresent && !isOptionalIn) {
860
+ if (!isPresent && optin === undefined) {
755
861
  if (!result.issues.length) {
756
862
  final.issues.push({
757
863
  code: "invalid_type",
@@ -771,17 +877,25 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
771
877
  final.value[key] = result.value;
772
878
  }
773
879
  }
880
+ // one shared instance; a fresh [] per schema cost 56 bytes retained
881
+ const NO_SYMBOL_KEYS = [];
774
882
  function normalizeDef(def) {
775
883
  const keys = Object.keys(def.shape);
776
- for (const k of keys) {
884
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
885
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
886
+ // aliases `keys` when there are no symbols, so a string-only shape keeps one array
887
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
888
+ for (const k of allKeys) {
777
889
  if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
778
- throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
890
+ throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
779
891
  }
780
892
  }
781
893
  const okeys = util.optionalKeys(def.shape);
782
894
  return {
783
895
  ...def,
784
- keys,
896
+ allKeys,
897
+ symbolKeys,
898
+ // string-only: handleCatchall matches it against `for...in`, which never yields a symbol
785
899
  keySet: new Set(keys),
786
900
  numKeys: keys.length,
787
901
  optionalKeys: new Set(okeys),
@@ -792,25 +906,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
792
906
  const keySet = def.keySet;
793
907
  const _catchall = def.catchall._zod;
794
908
  const t = _catchall.def.type;
795
- const isOptionalIn = _catchall.optin === "optional";
796
- const isOptionalOut = _catchall.optout === "optional";
909
+ const optin = _catchall.optin;
910
+ const optout = _catchall.optout;
797
911
  for (const key in input) {
798
- // skip __proto__ so it can't replace the result prototype via the
799
- // assignment setter on the plain {} we build into
800
- if (key === "__proto__")
801
- continue;
912
+ // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
802
913
  if (keySet.has(key))
803
914
  continue;
915
+ // 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.
916
+ if (key === "__proto__") {
917
+ if (t === "never")
918
+ unrecognized.push(key);
919
+ continue;
920
+ }
804
921
  if (t === "never") {
805
922
  unrecognized.push(key);
806
923
  continue;
807
924
  }
808
925
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
809
926
  if (r instanceof Promise) {
810
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
927
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
811
928
  }
812
929
  else {
813
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
930
+ handlePropertyResult(r, payload, key, input, optin, optout);
814
931
  }
815
932
  }
816
933
  if (unrecognized.length) {
@@ -819,6 +936,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
819
936
  keys: unrecognized,
820
937
  input,
821
938
  inst,
939
+ // 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.
940
+ continue: true,
822
941
  });
823
942
  }
824
943
  if (!proms.length)
@@ -827,6 +946,8 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
827
946
  return payload;
828
947
  });
829
948
  }
949
+ // Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
950
+ const propShapes = new WeakMap();
830
951
  exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
831
952
  // requires cast because technically $ZodObject doesn't extend
832
953
  exports.$ZodType.init(inst, def);
@@ -834,26 +955,33 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
834
955
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
835
956
  if (!desc?.get) {
836
957
  const sh = def.shape;
958
+ propShapes.set(def, sh);
837
959
  Object.defineProperty(def, "shape", {
838
960
  get: () => {
839
961
  const newSh = { ...sh };
840
962
  Object.defineProperty(def, "shape", {
841
963
  value: newSh,
842
964
  });
965
+ propShapes.set(def, newSh);
843
966
  return newSh;
844
967
  },
845
968
  });
846
969
  }
847
970
  const _normalized = util.cached(() => normalizeDef(def));
848
- util.defineLazy(inst._zod, "propValues", () => {
849
- const shape = def.shape;
971
+ util.defineLazyInternal(inst, "propValues", (zod) => {
972
+ const shape = zod.def.shape;
850
973
  const propValues = {};
851
974
  for (const key in shape) {
852
975
  const field = shape[key]._zod;
853
976
  if (field.values) {
854
- propValues[key] ?? (propValues[key] = new Set());
977
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) {
978
+ util.assignProp(propValues, key, new Set());
979
+ }
855
980
  for (const v of field.values)
856
981
  propValues[key].add(v);
982
+ // 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.
983
+ if (field.optin !== undefined)
984
+ propValues[key].add(undefined);
857
985
  }
858
986
  }
859
987
  return propValues;
@@ -861,6 +989,8 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
861
989
  const isObject = util.isObject;
862
990
  const catchall = def.catchall;
863
991
  let value;
992
+ const memo = core.globalConfig.memoizer;
993
+ memo?.attach(inst);
864
994
  inst._zod.parse = (payload, ctx) => {
865
995
  value ?? (value = _normalized.value);
866
996
  const input = payload.value;
@@ -873,19 +1003,21 @@ exports.$ZodObject = core.$constructor("$ZodObject", (inst, def) => {
873
1003
  });
874
1004
  return payload;
875
1005
  }
876
- payload.value = {};
1006
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
877
1007
  const proms = [];
878
1008
  const shape = value.shape;
879
- for (const key of value.keys) {
1009
+ for (const key of value.allKeys) {
1010
+ if (key === "__proto__")
1011
+ continue;
880
1012
  const el = shape[key];
881
- const isOptionalIn = el._zod.optin === "optional";
882
- const isOptionalOut = el._zod.optout === "optional";
1013
+ const optin = el._zod.optin;
1014
+ const optout = el._zod.optout;
883
1015
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
884
1016
  if (r instanceof Promise) {
885
- proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1017
+ proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
886
1018
  }
887
1019
  else {
888
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1020
+ handlePropertyResult(r, payload, key, input, optin, optout);
889
1021
  }
890
1022
  }
891
1023
  if (!catchall) {
@@ -899,58 +1031,59 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
899
1031
  exports.$ZodObject.init(inst, def);
900
1032
  const superParse = inst._zod.parse;
901
1033
  const _normalized = util.cached(() => normalizeDef(def));
1034
+ const memo = core.globalConfig.memoizer;
902
1035
  const generateFastpass = (shape) => {
903
- const doc = new doc_js_1.Doc(["shape", "payload", "ctx"]);
904
1036
  const normalized = _normalized.value;
905
- const parseStr = (key) => {
906
- const k = util.esc(key);
907
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
908
- };
1037
+ const syms = normalized.symbolKeys;
1038
+ // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
1039
+ const doc = new doc_js_1.Doc(["payload", "ctx"], { shape, inst, memo, syms });
1040
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1041
+ // Prefixes in place, like util.prefixIssues does for every interpreted path.
1042
+ const prefixStr = (id, k) => `
1043
+ for (let i = 0; i < ${id}.issues.length; i++) {
1044
+ const iss = ${id}.issues[i];
1045
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
1046
+ payload.issues.push(iss);
1047
+ }`;
909
1048
  doc.write(`const input = payload.value;`);
910
1049
  const ids = Object.create(null);
911
1050
  let counter = 0;
912
- for (const key of normalized.keys) {
1051
+ for (const key of normalized.allKeys) {
913
1052
  ids[key] = `key_${counter++}`;
914
1053
  }
915
1054
  // A: preserve key order {
916
- doc.write(`const newResult = {};`);
917
- for (const key of normalized.keys) {
1055
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
1056
+ for (const key of normalized.allKeys) {
1057
+ if (key === "__proto__")
1058
+ continue;
918
1059
  const id = ids[key];
919
- const k = util.esc(key);
1060
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : util.esc(key);
1061
+ const isPresent = `${k} in input`;
920
1062
  const schema = shape[key];
921
- const isOptionalIn = schema?._zod?.optin === "optional";
1063
+ const optin = schema?._zod?.optin;
1064
+ const isOptionalIn = optin !== undefined;
922
1065
  const isOptionalOut = schema?._zod?.optout === "optional";
923
- doc.write(`const ${id} = ${parseStr(key)};`);
1066
+ doc.write(`const ${id} = ${parseStr(k)};`);
924
1067
  if (isOptionalIn && isOptionalOut) {
925
- // For optional-in/out schemas, ignore errors on absent keys
1068
+ // 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.
1069
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
926
1070
  doc.write(`
927
- if (${id}.issues.length) {
928
- if (${k} in input) {
929
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
930
- ...iss,
931
- path: iss.path ? [${k}, ...iss.path] : [${k}]
932
- })));
1071
+ const ${id}_present = ${isPresent};
1072
+ if (!${id}.issues.length || ${id}_present) {
1073
+ if (${id}.issues.length) {${prefixStr(id, k)}
933
1074
  }
934
- }
935
-
936
- if (${id}.value === undefined) {
937
- if (${k} in input) {
938
- newResult[${k}] = undefined;
1075
+
1076
+ if (${assign}) {
1077
+ newResult[${k}] = ${id}.value;
939
1078
  }
940
- } else {
941
- newResult[${k}] = ${id}.value;
942
1079
  }
943
-
1080
+
944
1081
  `);
945
1082
  }
946
1083
  else if (!isOptionalIn) {
947
1084
  doc.write(`
948
- const ${id}_present = ${k} in input;
949
- if (${id}.issues.length) {
950
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
951
- ...iss,
952
- path: iss.path ? [${k}, ...iss.path] : [${k}]
953
- })));
1085
+ const ${id}_present = ${isPresent};
1086
+ if (${id}.issues.length) {${prefixStr(id, k)}
954
1087
  }
955
1088
  if (!${id}_present && !${id}.issues.length) {
956
1089
  payload.issues.push({
@@ -962,39 +1095,31 @@ exports.$ZodObjectJIT = core.$constructor("$ZodObjectJIT", (inst, def) => {
962
1095
  }
963
1096
 
964
1097
  if (${id}_present) {
965
- if (${id}.value === undefined) {
966
- newResult[${k}] = undefined;
967
- } else {
968
- newResult[${k}] = ${id}.value;
969
- }
1098
+ newResult[${k}] = ${id}.value;
970
1099
  }
971
1100
 
972
1101
  `);
973
1102
  }
974
1103
  else {
975
1104
  doc.write(`
976
- if (${id}.issues.length) {
977
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
978
- ...iss,
979
- path: iss.path ? [${k}, ...iss.path] : [${k}]
980
- })));
1105
+ if (${id}.issues.length) {${prefixStr(id, k)}
981
1106
  }
982
1107
 
983
1108
  if (${id}.value === undefined) {
984
- if (${k} in input) {
1109
+ if (${isPresent}) {
985
1110
  newResult[${k}] = undefined;
986
1111
  }
987
1112
  } else {
988
1113
  newResult[${k}] = ${id}.value;
989
1114
  }
990
-
1115
+
991
1116
  `);
992
1117
  }
993
1118
  }
994
1119
  doc.write(`payload.value = newResult;`);
995
1120
  doc.write(`return payload;`);
996
- const fn = doc.compile();
997
- return (payload, ctx) => fn(shape, payload, ctx);
1121
+ // 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
1122
+ return doc.compile();
998
1123
  };
999
1124
  let fastpass;
1000
1125
  const isObject = util.isObject;
@@ -1049,17 +1174,21 @@ function handleUnionResults(results, final, inst, ctx) {
1049
1174
  }
1050
1175
  exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
1051
1176
  exports.$ZodType.init(inst, def);
1052
- util.defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : undefined);
1053
- util.defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1054
- util.defineLazy(inst._zod, "values", () => {
1055
- if (def.options.every((o) => o._zod.values)) {
1056
- return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1177
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted")
1178
+ ? "defaulted"
1179
+ : zod.def.options.some((o) => o._zod.optin !== undefined)
1180
+ ? "optional"
1181
+ : undefined);
1182
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : undefined);
1183
+ util.defineLazyInternal(inst, "values", (zod) => {
1184
+ if (zod.def.options.every((o) => o._zod.values)) {
1185
+ return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1057
1186
  }
1058
1187
  return undefined;
1059
1188
  });
1060
- util.defineLazy(inst._zod, "pattern", () => {
1061
- if (def.options.every((o) => o._zod.pattern)) {
1062
- const patterns = def.options.map((o) => o._zod.pattern);
1189
+ util.defineLazyInternal(inst, "pattern", (zod) => {
1190
+ if (zod.def.options.every((o) => o._zod.pattern)) {
1191
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1063
1192
  return new RegExp(`^(${patterns.map((p) => util.cleanRegex(p.source)).join("|")})$`);
1064
1193
  }
1065
1194
  return undefined;
@@ -1094,12 +1223,16 @@ exports.$ZodUnion = core.$constructor("$ZodUnion", (inst, def) => {
1094
1223
  };
1095
1224
  });
1096
1225
  function handleExclusiveUnionResults(results, final, inst, ctx) {
1097
- const successes = results.filter((r) => r.issues.length === 0);
1098
- if (successes.length === 1) {
1099
- final.value = successes[0].value;
1226
+ const matches = [];
1227
+ for (let i = 0; i < results.length; i++) {
1228
+ if (results[i].issues.length === 0)
1229
+ matches.push(i);
1230
+ }
1231
+ if (matches.length === 1) {
1232
+ final.value = results[matches[0]].value;
1100
1233
  return final;
1101
1234
  }
1102
- if (successes.length === 0) {
1235
+ if (matches.length === 0) {
1103
1236
  // No matches - same as regular union
1104
1237
  final.issues.push({
1105
1238
  code: "invalid_union",
@@ -1116,6 +1249,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
1116
1249
  inst,
1117
1250
  errors: [],
1118
1251
  inclusive: false,
1252
+ matches,
1119
1253
  });
1120
1254
  }
1121
1255
  return final;
@@ -1150,21 +1284,39 @@ exports.$ZodXor = core.$constructor("$ZodXor", (inst, def) => {
1150
1284
  });
1151
1285
  };
1152
1286
  });
1287
+ /** Returns the option of `union` whose discriminator claims `value`. */
1288
+ function getDiscriminatedOption(union, value) {
1289
+ const internals = union._zod;
1290
+ let map = internals.bag.optionsMap;
1291
+ if (!map) {
1292
+ map = new Map();
1293
+ const { options, discriminator } = internals.def;
1294
+ for (const option of options) {
1295
+ // First declaration wins, matching the order the parse path resolves a duplicate in.
1296
+ for (const v of option._zod.propValues?.[discriminator] ?? [])
1297
+ if (!map.has(v))
1298
+ map.set(v, option);
1299
+ }
1300
+ internals.bag.optionsMap = map;
1301
+ }
1302
+ return map.get(value);
1303
+ }
1153
1304
  exports.$ZodDiscriminatedUnion =
1154
1305
  /*@__PURE__*/
1155
1306
  core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1156
1307
  def.inclusive = false;
1157
1308
  exports.$ZodUnion.init(inst, def);
1158
1309
  const _super = inst._zod.parse;
1159
- util.defineLazy(inst._zod, "propValues", () => {
1310
+ util.defineLazyInternal(inst, "propValues", (zod) => {
1160
1311
  const propValues = {};
1161
- for (const option of def.options) {
1312
+ for (const option of zod.def.options) {
1162
1313
  const pv = option._zod.propValues;
1163
1314
  if (!pv || Object.keys(pv).length === 0)
1164
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1315
+ throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
1165
1316
  for (const [k, v] of Object.entries(pv)) {
1166
- if (!propValues[k])
1167
- propValues[k] = new Set();
1317
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
1318
+ util.assignProp(propValues, k, new Set());
1319
+ }
1168
1320
  for (const val of v) {
1169
1321
  propValues[k].add(val);
1170
1322
  }
@@ -1172,6 +1324,13 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1172
1324
  }
1173
1325
  return propValues;
1174
1326
  });
1327
+ // 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, lazies, and objects rebuilt by a builder such as `.extend()` — are left to the map.
1328
+ def.options.forEach((option, i) => {
1329
+ const propShape = propShapes.get(option._zod.def);
1330
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
1331
+ throw new Error(`Invalid discriminated union option at index "${i}"`);
1332
+ }
1333
+ });
1175
1334
  const disc = util.cached(() => {
1176
1335
  const opts = def.options;
1177
1336
  const map = new Map();
@@ -1205,8 +1364,7 @@ core.$constructor("$ZodDiscriminatedUnion", (inst, def) => {
1205
1364
  }
1206
1365
  // Fall back to union matching when the fast discriminator path fails:
1207
1366
  // - explicitly enabled via unionFallback, or
1208
- // - during backward direction (encode), since codec-based discriminators
1209
- // have different values in forward vs backward directions
1367
+ // - during backward direction (encode), since codec-based discriminators have different values in forward vs backward directions
1210
1368
  if (def.unionFallback || ctx.direction === "backward") {
1211
1369
  return _super(payload, ctx);
1212
1370
  }
@@ -1252,7 +1410,11 @@ function mergeValues(a, b) {
1252
1410
  const bKeys = Object.keys(b);
1253
1411
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1254
1412
  const newObj = { ...a, ...b };
1413
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__"))
1414
+ delete newObj.__proto__;
1255
1415
  for (const key of sharedKeys) {
1416
+ if (key === "__proto__")
1417
+ continue;
1256
1418
  const sharedValue = mergeValues(a[key], b[key]);
1257
1419
  if (!sharedValue.valid) {
1258
1420
  return {
@@ -1286,43 +1448,55 @@ function mergeValues(a, b) {
1286
1448
  return { valid: false, mergeErrorPath: [] };
1287
1449
  }
1288
1450
  function handleIntersectionResults(result, left, right) {
1289
- // Track which side(s) report each key as unrecognized
1451
+ // 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.
1290
1452
  const unrecKeys = new Map();
1291
1453
  let unrecIssue;
1292
- for (const iss of left.issues) {
1293
- if (iss.code === "unrecognized_keys") {
1454
+ const keyIssues = new Map();
1455
+ const collect = (iss, side) => {
1456
+ let keys;
1457
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
1294
1458
  unrecIssue ?? (unrecIssue = iss);
1295
- for (const k of iss.keys) {
1296
- if (!unrecKeys.has(k))
1297
- unrecKeys.set(k, {});
1298
- unrecKeys.get(k).l = true;
1299
- }
1459
+ keys = iss.keys;
1460
+ }
1461
+ else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
1462
+ const k = String(iss.path[0]);
1463
+ if (!keyIssues.has(k))
1464
+ keyIssues.set(k, iss);
1465
+ keys = [k];
1300
1466
  }
1301
1467
  else {
1302
- result.issues.push(iss);
1468
+ return false;
1469
+ }
1470
+ for (const k of keys) {
1471
+ if (!unrecKeys.has(k))
1472
+ unrecKeys.set(k, {});
1473
+ unrecKeys.get(k)[side] = true;
1303
1474
  }
1475
+ return true;
1476
+ };
1477
+ for (const iss of left.issues) {
1478
+ if (!collect(iss, "l"))
1479
+ result.issues.push(iss);
1304
1480
  }
1305
1481
  for (const iss of right.issues) {
1306
- if (iss.code === "unrecognized_keys") {
1307
- for (const k of iss.keys) {
1308
- if (!unrecKeys.has(k))
1309
- unrecKeys.set(k, {});
1310
- unrecKeys.get(k).r = true;
1311
- }
1312
- }
1313
- else {
1482
+ if (!collect(iss, "r"))
1314
1483
  result.issues.push(iss);
1315
- }
1316
1484
  }
1317
- // Report only keys unrecognized by BOTH sides
1485
+ // Report only keys rejected by BOTH sides
1318
1486
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1319
- if (bothKeys.length && unrecIssue) {
1320
- result.issues.push({ ...unrecIssue, keys: bothKeys });
1487
+ if (bothKeys.length) {
1488
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
1489
+ if (aggregated.length)
1490
+ result.issues.push({ ...unrecIssue, keys: aggregated });
1491
+ for (const k of bothKeys) {
1492
+ if (!aggregated.includes(k) && keyIssues.has(k))
1493
+ result.issues.push(keyIssues.get(k));
1494
+ }
1321
1495
  }
1322
- if (util.aborted(result))
1323
- return result;
1324
1496
  const merged = mergeValues(left.value, right.value);
1325
1497
  if (!merged.valid) {
1498
+ if (util.aborted(result))
1499
+ return result;
1326
1500
  throw new Error(`Unmergable intersection. Error path: ` + `${JSON.stringify(merged.mergeErrorPath)}`);
1327
1501
  }
1328
1502
  result.value = merged.data;
@@ -1331,6 +1505,8 @@ function handleIntersectionResults(result, left, right) {
1331
1505
  exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1332
1506
  exports.$ZodType.init(inst, def);
1333
1507
  const items = def.items;
1508
+ const memo = core.globalConfig.memoizer;
1509
+ memo?.attach(inst);
1334
1510
  inst._zod.parse = (payload, ctx) => {
1335
1511
  const input = payload.value;
1336
1512
  if (!Array.isArray(input)) {
@@ -1342,7 +1518,7 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1342
1518
  });
1343
1519
  return payload;
1344
1520
  }
1345
- payload.value = [];
1521
+ payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
1346
1522
  const proms = [];
1347
1523
  const optinStart = getTupleOptStart(items, "optin");
1348
1524
  const optoutStart = getTupleOptStart(items, "optout");
@@ -1369,10 +1545,7 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1369
1545
  });
1370
1546
  }
1371
1547
  }
1372
- // Run every item in parallel, collecting results into an indexed
1373
- // array. The post-processing in `handleTupleResults` walks them in
1374
- // order so it can decide whether an absent optional-output error can
1375
- // truncate the tail or must be reported to preserve required output.
1548
+ // 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.
1376
1549
  const itemResults = new Array(items.length);
1377
1550
  for (let i = 0; i < items.length; i++) {
1378
1551
  const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
@@ -1407,7 +1580,9 @@ exports.$ZodTuple = core.$constructor("$ZodTuple", (inst, def) => {
1407
1580
  });
1408
1581
  function getTupleOptStart(items, key) {
1409
1582
  for (let i = items.length - 1; i >= 0; i--) {
1410
- if (items[i]._zod[key] !== "optional")
1583
+ // optin is a three-rung ladder so any rung above `undefined` permits an absent slot; optout stays two-valued.
1584
+ const omittable = key === "optin" ? items[i]._zod.optin !== undefined : items[i]._zod.optout === "optional";
1585
+ if (!omittable)
1411
1586
  return i + 1;
1412
1587
  }
1413
1588
  return 0;
@@ -1419,12 +1594,15 @@ function handleTupleResult(result, final, index) {
1419
1594
  final.value[index] = result.value;
1420
1595
  }
1421
1596
  function handleTupleResults(itemResults, final, items, input, optoutStart) {
1422
- // Walk results in order. Mirror $ZodObject's swallow-on-absent-optional
1423
- // rule, but only after `optoutStart`: the first index where the output
1424
- // tuple tail can be absent.
1597
+ // 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.
1425
1598
  for (let i = 0; i < items.length; i++) {
1426
1599
  const r = itemResults[i];
1427
1600
  const isPresent = i < input.length;
1601
+ // 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`.
1602
+ if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
1603
+ final.value.length = i;
1604
+ break;
1605
+ }
1428
1606
  if (r.issues.length) {
1429
1607
  if (!isPresent && i >= optoutStart) {
1430
1608
  final.value.length = i;
@@ -1452,6 +1630,8 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
1452
1630
  }
1453
1631
  exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1454
1632
  exports.$ZodType.init(inst, def);
1633
+ const memo = core.globalConfig.memoizer;
1634
+ memo?.attach(inst);
1455
1635
  inst._zod.parse = (payload, ctx) => {
1456
1636
  const input = payload.value;
1457
1637
  if (!util.isPlainObject(input)) {
@@ -1465,12 +1645,15 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1465
1645
  }
1466
1646
  const proms = [];
1467
1647
  const values = def.keyType._zod.values;
1468
- if (values) {
1469
- payload.value = {};
1648
+ if (values && !def.partial) {
1649
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1470
1650
  const recordKeys = new Set();
1471
1651
  for (const key of values) {
1472
1652
  if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
1473
1653
  recordKeys.add(typeof key === "number" ? key.toString() : key);
1654
+ // A declared __proto__ is stripped but is not an unrecognized key.
1655
+ if (key === "__proto__")
1656
+ continue;
1474
1657
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1475
1658
  if (keyResult instanceof Promise) {
1476
1659
  throw new Error("Async schemas not supported in object keys currently");
@@ -1487,6 +1670,8 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1487
1670
  continue;
1488
1671
  }
1489
1672
  const outKey = keyResult.value;
1673
+ if (outKey === "__proto__")
1674
+ continue;
1490
1675
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1491
1676
  if (result instanceof Promise) {
1492
1677
  proms.push(result.then((result) => {
@@ -1507,8 +1692,16 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1507
1692
  let unrecognized;
1508
1693
  for (const key in input) {
1509
1694
  if (!recordKeys.has(key)) {
1510
- unrecognized = unrecognized ?? [];
1511
- unrecognized.push(key);
1695
+ if (def.mode === "loose") {
1696
+ // skip __proto__ so it can't replace the result prototype via the assignment setter on the plain {} we build into
1697
+ if (key === "__proto__")
1698
+ continue;
1699
+ payload.value[key] = input[key];
1700
+ }
1701
+ else {
1702
+ unrecognized = unrecognized ?? [];
1703
+ unrecognized.push(key);
1704
+ }
1512
1705
  }
1513
1706
  }
1514
1707
  if (unrecognized && unrecognized.length > 0) {
@@ -1517,11 +1710,14 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1517
1710
  input,
1518
1711
  inst,
1519
1712
  keys: unrecognized,
1713
+ continue: true,
1520
1714
  });
1521
1715
  }
1522
1716
  }
1523
1717
  else {
1524
- payload.value = {};
1718
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1719
+ // 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.
1720
+ let unrecognized;
1525
1721
  // Reflect.ownKeys for Symbol-key support; filter non-enumerable to match z.object()
1526
1722
  for (const key of Reflect.ownKeys(input)) {
1527
1723
  if (key === "__proto__")
@@ -1532,8 +1728,7 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1532
1728
  if (keyResult instanceof Promise) {
1533
1729
  throw new Error("Async schemas not supported in object keys currently");
1534
1730
  }
1535
- // Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
1536
- // This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
1731
+ // 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
1537
1732
  const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
1538
1733
  if (checkNumericKey) {
1539
1734
  const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
@@ -1549,6 +1744,10 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1549
1744
  // Pass through unchanged
1550
1745
  payload.value[key] = input[key];
1551
1746
  }
1747
+ else if (values) {
1748
+ unrecognized = unrecognized ?? [];
1749
+ unrecognized.push(key);
1750
+ }
1552
1751
  else {
1553
1752
  // Default "strict" behavior: error on invalid key
1554
1753
  payload.issues.push({
@@ -1562,22 +1761,35 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1562
1761
  }
1563
1762
  continue;
1564
1763
  }
1764
+ // 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
1765
+ const outKey = keyResult.value;
1766
+ if (outKey === "__proto__")
1767
+ continue;
1565
1768
  const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
1566
1769
  if (result instanceof Promise) {
1567
1770
  proms.push(result.then((result) => {
1568
1771
  if (result.issues.length) {
1569
1772
  payload.issues.push(...util.prefixIssues(key, result.issues));
1570
1773
  }
1571
- payload.value[keyResult.value] = result.value;
1774
+ payload.value[outKey] = result.value;
1572
1775
  }));
1573
1776
  }
1574
1777
  else {
1575
1778
  if (result.issues.length) {
1576
1779
  payload.issues.push(...util.prefixIssues(key, result.issues));
1577
1780
  }
1578
- payload.value[keyResult.value] = result.value;
1781
+ payload.value[outKey] = result.value;
1579
1782
  }
1580
1783
  }
1784
+ if (unrecognized && unrecognized.length > 0) {
1785
+ payload.issues.push({
1786
+ code: "unrecognized_keys",
1787
+ input,
1788
+ inst,
1789
+ keys: unrecognized,
1790
+ continue: true,
1791
+ });
1792
+ }
1581
1793
  }
1582
1794
  if (proms.length) {
1583
1795
  return Promise.all(proms).then(() => payload);
@@ -1587,6 +1799,8 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
1587
1799
  });
1588
1800
  exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1589
1801
  exports.$ZodType.init(inst, def);
1802
+ const memo = core.globalConfig.memoizer;
1803
+ memo?.attach(inst);
1590
1804
  inst._zod.parse = (payload, ctx) => {
1591
1805
  const input = payload.value;
1592
1806
  if (!(input instanceof Map)) {
@@ -1599,7 +1813,7 @@ exports.$ZodMap = core.$constructor("$ZodMap", (inst, def) => {
1599
1813
  return payload;
1600
1814
  }
1601
1815
  const proms = [];
1602
- payload.value = new Map();
1816
+ payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
1603
1817
  for (const [key, value] of input) {
1604
1818
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
1605
1819
  const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
@@ -1651,6 +1865,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
1651
1865
  }
1652
1866
  exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
1653
1867
  exports.$ZodType.init(inst, def);
1868
+ const memo = core.globalConfig.memoizer;
1869
+ memo?.attach(inst);
1654
1870
  inst._zod.parse = (payload, ctx) => {
1655
1871
  const input = payload.value;
1656
1872
  if (!(input instanceof Set)) {
@@ -1663,7 +1879,7 @@ exports.$ZodSet = core.$constructor("$ZodSet", (inst, def) => {
1663
1879
  return payload;
1664
1880
  }
1665
1881
  const proms = [];
1666
- payload.value = new Set();
1882
+ payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
1667
1883
  for (const item of input) {
1668
1884
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
1669
1885
  if (result instanceof Promise) {
@@ -1688,10 +1904,9 @@ exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
1688
1904
  const values = util.getEnumValues(def.entries);
1689
1905
  const valuesSet = new Set(values);
1690
1906
  inst._zod.values = valuesSet;
1691
- inst._zod.pattern = new RegExp(`^(${values
1692
- .filter((k) => util.propertyKeyTypes.has(typeof k))
1693
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o.toString()))
1694
- .join("|")})$`);
1907
+ const patternValues = values.filter((k) => util.propertyKeyTypes.has(typeof k));
1908
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
1909
+ inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => util.escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
1695
1910
  inst._zod.parse = (payload, _ctx) => {
1696
1911
  const input = payload.value;
1697
1912
  if (valuesSet.has(input)) {
@@ -1708,14 +1923,14 @@ exports.$ZodEnum = core.$constructor("$ZodEnum", (inst, def) => {
1708
1923
  });
1709
1924
  exports.$ZodLiteral = core.$constructor("$ZodLiteral", (inst, def) => {
1710
1925
  exports.$ZodType.init(inst, def);
1711
- if (def.values.length === 0) {
1712
- throw new Error("Cannot create literal schema with no valid values");
1713
- }
1714
1926
  const values = new Set(def.values);
1715
1927
  inst._zod.values = values;
1716
- inst._zod.pattern = new RegExp(`^(${def.values
1717
- .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
1718
- .join("|")})$`);
1928
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
1929
+ inst._zod.pattern = new RegExp(def.values.length
1930
+ ? `^(${def.values
1931
+ .map((o) => (typeof o === "string" ? util.escapeRegex(o) : o ? util.escapeRegex(o.toString()) : String(o)))
1932
+ .join("|")})$`
1933
+ : "^[^\\s\\S]$");
1719
1934
  inst._zod.parse = (payload, _ctx) => {
1720
1935
  const input = payload.value;
1721
1936
  if (values.has(input)) {
@@ -1749,6 +1964,7 @@ exports.$ZodFile = core.$constructor("$ZodFile", (inst, def) => {
1749
1964
  exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
1750
1965
  exports.$ZodType.init(inst, def);
1751
1966
  inst._zod.optin = "optional";
1967
+ core.globalConfig.memoizer?.guard(inst);
1752
1968
  inst._zod.parse = (payload, ctx) => {
1753
1969
  if (ctx.direction === "backward") {
1754
1970
  throw new core.$ZodEncodeError(inst.constructor.name);
@@ -1758,7 +1974,6 @@ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
1758
1974
  const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1759
1975
  return output.then((output) => {
1760
1976
  payload.value = output;
1761
- payload.fallback = true;
1762
1977
  return payload;
1763
1978
  });
1764
1979
  }
@@ -1766,37 +1981,37 @@ exports.$ZodTransform = core.$constructor("$ZodTransform", (inst, def) => {
1766
1981
  throw new core.$ZodAsyncError();
1767
1982
  }
1768
1983
  payload.value = _out;
1769
- payload.fallback = true;
1770
1984
  return payload;
1771
1985
  };
1772
1986
  });
1773
- function handleOptionalResult(result, input) {
1774
- if (input === undefined && (result.issues.length || result.fallback)) {
1775
- return { issues: [], value: undefined };
1776
- }
1777
- return result;
1987
+ function handleOptionalResult(payload, result) {
1988
+ // 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.
1989
+ payload.value = result.issues.length ? undefined : result.value;
1990
+ return payload;
1778
1991
  }
1779
1992
  exports.$ZodOptional = core.$constructor("$ZodOptional", (inst, def) => {
1780
1993
  exports.$ZodType.init(inst, def);
1781
- inst._zod.optin = "optional";
1994
+ // .optional() propagates absence rather than substituting for it, so a defaulted inner keeps its rung.
1995
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
1782
1996
  inst._zod.optout = "optional";
1783
- util.defineLazy(inst._zod, "values", () => {
1784
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, undefined]) : undefined;
1997
+ util.defineLazyInternal(inst, "values", (zod) => {
1998
+ const values = zod.def.innerType._zod.values;
1999
+ return values ? new Set([...values, undefined]) : undefined;
1785
2000
  });
1786
- util.defineLazy(inst._zod, "pattern", () => {
1787
- const pattern = def.innerType._zod.pattern;
2001
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2002
+ const pattern = zod.def.innerType._zod.pattern;
1788
2003
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)})?$`) : undefined;
1789
2004
  });
1790
2005
  inst._zod.parse = (payload, ctx) => {
1791
- if (def.innerType._zod.optin === "optional") {
1792
- const input = payload.value;
1793
- const result = def.innerType._zod.run(payload, ctx);
1794
- if (result instanceof Promise)
1795
- return result.then((r) => handleOptionalResult(r, input));
1796
- return handleOptionalResult(result, input);
1797
- }
1798
2006
  if (payload.value === undefined) {
1799
- return payload;
2007
+ // Only the top rung substitutes a value for absence; everything else leaves it intact, which is what .optional() means.
2008
+ if (def.innerType._zod.optin !== "defaulted")
2009
+ return payload;
2010
+ // 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.
2011
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
2012
+ if (result instanceof Promise)
2013
+ return result.then((result) => handleOptionalResult(payload, result));
2014
+ return handleOptionalResult(payload, result);
1800
2015
  }
1801
2016
  return def.innerType._zod.run(payload, ctx);
1802
2017
  };
@@ -1805,8 +2020,8 @@ exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) =
1805
2020
  // Call parent init - inherits optin/optout = "optional"
1806
2021
  exports.$ZodOptional.init(inst, def);
1807
2022
  // Override values/pattern to NOT add undefined
1808
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1809
- util.defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2023
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2024
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
1810
2025
  // Override parse to just delegate (no undefined handling)
1811
2026
  inst._zod.parse = (payload, ctx) => {
1812
2027
  return def.innerType._zod.run(payload, ctx);
@@ -1814,14 +2029,14 @@ exports.$ZodExactOptional = core.$constructor("$ZodExactOptional", (inst, def) =
1814
2029
  });
1815
2030
  exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
1816
2031
  exports.$ZodType.init(inst, def);
1817
- util.defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1818
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1819
- util.defineLazy(inst._zod, "pattern", () => {
1820
- const pattern = def.innerType._zod.pattern;
2032
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2033
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2034
+ util.defineLazyInternal(inst, "pattern", (zod) => {
2035
+ const pattern = zod.def.innerType._zod.pattern;
1821
2036
  return pattern ? new RegExp(`^(${util.cleanRegex(pattern.source)}|null)$`) : undefined;
1822
2037
  });
1823
- util.defineLazy(inst._zod, "values", () => {
1824
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : undefined;
2038
+ util.defineLazyInternal(inst, "values", (zod) => {
2039
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : undefined;
1825
2040
  });
1826
2041
  inst._zod.parse = (payload, ctx) => {
1827
2042
  // Forward direction (decode): allow null to pass through
@@ -1833,8 +2048,8 @@ exports.$ZodNullable = core.$constructor("$ZodNullable", (inst, def) => {
1833
2048
  exports.$ZodDefault = core.$constructor("$ZodDefault", (inst, def) => {
1834
2049
  exports.$ZodType.init(inst, def);
1835
2050
  // inst._zod.qin = "true";
1836
- inst._zod.optin = "optional";
1837
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2051
+ inst._zod.optin = "defaulted";
2052
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1838
2053
  inst._zod.parse = (payload, ctx) => {
1839
2054
  if (ctx.direction === "backward") {
1840
2055
  return def.innerType._zod.run(payload, ctx);
@@ -1863,8 +2078,8 @@ function handleDefaultResult(payload, def) {
1863
2078
  }
1864
2079
  exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
1865
2080
  exports.$ZodType.init(inst, def);
1866
- inst._zod.optin = "optional";
1867
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2081
+ inst._zod.optin = "defaulted";
2082
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1868
2083
  inst._zod.parse = (payload, ctx) => {
1869
2084
  if (ctx.direction === "backward") {
1870
2085
  return def.innerType._zod.run(payload, ctx);
@@ -1878,8 +2093,8 @@ exports.$ZodPrefault = core.$constructor("$ZodPrefault", (inst, def) => {
1878
2093
  });
1879
2094
  exports.$ZodNonOptional = core.$constructor("$ZodNonOptional", (inst, def) => {
1880
2095
  exports.$ZodType.init(inst, def);
1881
- util.defineLazy(inst._zod, "values", () => {
1882
- const v = def.innerType._zod.values;
2096
+ util.defineLazyInternal(inst, "values", (zod) => {
2097
+ const v = zod.def.innerType._zod.values;
1883
2098
  return v ? new Set([...v].filter((x) => x !== undefined)) : undefined;
1884
2099
  });
1885
2100
  inst._zod.parse = (payload, ctx) => {
@@ -1918,47 +2133,40 @@ exports.$ZodSuccess = core.$constructor("$ZodSuccess", (inst, def) => {
1918
2133
  return payload;
1919
2134
  };
1920
2135
  });
2136
+ function handleCatchResult(payload, result, def, ctx) {
2137
+ if (!result.issues.length) {
2138
+ payload.value = result.value;
2139
+ // 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.
2140
+ if (result.memo)
2141
+ payload.memo = true;
2142
+ return payload;
2143
+ }
2144
+ // 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.
2145
+ payload.value = def.catchValue({
2146
+ ...result,
2147
+ value: payload.value,
2148
+ error: {
2149
+ issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
2150
+ },
2151
+ input: payload.value,
2152
+ });
2153
+ return payload;
2154
+ }
1921
2155
  exports.$ZodCatch = core.$constructor("$ZodCatch", (inst, def) => {
1922
2156
  exports.$ZodType.init(inst, def);
1923
- inst._zod.optin = "optional";
1924
- util.defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1925
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2157
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2158
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2159
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1926
2160
  inst._zod.parse = (payload, ctx) => {
1927
2161
  if (ctx.direction === "backward") {
1928
2162
  return def.innerType._zod.run(payload, ctx);
1929
2163
  }
1930
2164
  // Forward direction (decode): apply catch logic
1931
- const result = def.innerType._zod.run(payload, ctx);
2165
+ const result = def.innerType._zod.run({ value: payload.value, issues: [] }, ctx);
1932
2166
  if (result instanceof Promise) {
1933
- return result.then((result) => {
1934
- payload.value = result.value;
1935
- if (result.issues.length) {
1936
- payload.value = def.catchValue({
1937
- ...payload,
1938
- error: {
1939
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1940
- },
1941
- input: payload.value,
1942
- });
1943
- payload.issues = [];
1944
- payload.fallback = true;
1945
- }
1946
- return payload;
1947
- });
1948
- }
1949
- payload.value = result.value;
1950
- if (result.issues.length) {
1951
- payload.value = def.catchValue({
1952
- ...payload,
1953
- error: {
1954
- issues: result.issues.map((iss) => util.finalizeIssue(iss, ctx, core.config())),
1955
- },
1956
- input: payload.value,
1957
- });
1958
- payload.issues = [];
1959
- payload.fallback = true;
2167
+ return result.then((result) => handleCatchResult(payload, result, def, ctx));
1960
2168
  }
1961
- return payload;
2169
+ return handleCatchResult(payload, result, def, ctx);
1962
2170
  };
1963
2171
  });
1964
2172
  exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
@@ -1978,10 +2186,10 @@ exports.$ZodNaN = core.$constructor("$ZodNaN", (inst, def) => {
1978
2186
  });
1979
2187
  exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
1980
2188
  exports.$ZodType.init(inst, def);
1981
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
1982
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1983
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1984
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2189
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2190
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2191
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2192
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
1985
2193
  inst._zod.parse = (payload, ctx) => {
1986
2194
  if (ctx.direction === "backward") {
1987
2195
  const right = def.out._zod.run(payload, ctx);
@@ -1998,19 +2206,20 @@ exports.$ZodPipe = core.$constructor("$ZodPipe", (inst, def) => {
1998
2206
  };
1999
2207
  });
2000
2208
  function handlePipeResult(left, next, ctx) {
2001
- if (left.issues.length) {
2209
+ // 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.
2210
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2002
2211
  // prevent further checks
2003
2212
  left.aborted = true;
2004
2213
  return left;
2005
2214
  }
2006
- return next._zod.run({ value: left.value, issues: left.issues, fallback: left.fallback }, ctx);
2215
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2007
2216
  }
2008
2217
  exports.$ZodCodec = core.$constructor("$ZodCodec", (inst, def) => {
2009
2218
  exports.$ZodType.init(inst, def);
2010
- util.defineLazy(inst._zod, "values", () => def.in._zod.values);
2011
- util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2012
- util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2013
- util.defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2219
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2220
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2221
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2222
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2014
2223
  inst._zod.parse = (payload, ctx) => {
2015
2224
  const direction = ctx.direction || "forward";
2016
2225
  if (direction === "forward") {
@@ -2064,10 +2273,10 @@ exports.$ZodPreprocess = core.$constructor("$ZodPreprocess", (inst, def) => {
2064
2273
  });
2065
2274
  exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
2066
2275
  exports.$ZodType.init(inst, def);
2067
- util.defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2068
- util.defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2069
- util.defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2070
- util.defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2276
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2277
+ util.defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2278
+ util.defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2279
+ util.defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2071
2280
  inst._zod.parse = (payload, ctx) => {
2072
2281
  if (ctx.direction === "backward") {
2073
2282
  return def.innerType._zod.run(payload, ctx);
@@ -2080,7 +2289,9 @@ exports.$ZodReadonly = core.$constructor("$ZodReadonly", (inst, def) => {
2080
2289
  };
2081
2290
  });
2082
2291
  function handleReadonlyResult(payload) {
2083
- payload.value = Object.freeze(payload.value);
2292
+ // 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.
2293
+ if (!payload.memo)
2294
+ payload.value = Object.freeze(payload.value);
2084
2295
  return payload;
2085
2296
  }
2086
2297
  exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, def) => {
@@ -2134,33 +2345,35 @@ exports.$ZodTemplateLiteral = core.$constructor("$ZodTemplateLiteral", (inst, de
2134
2345
  });
2135
2346
  exports.$ZodFunction = core.$constructor("$ZodFunction", (inst, def) => {
2136
2347
  exports.$ZodType.init(inst, def);
2137
- inst._def = def;
2348
+ // Defined, not assigned: the classic prototype exposes `_def` as a getter with no setter.
2349
+ Object.defineProperty(inst, "_def", { value: def });
2138
2350
  inst._zod.def = def;
2139
2351
  inst.implement = (func) => {
2140
2352
  if (typeof func !== "function") {
2141
2353
  throw new Error("implement() must be called with a function");
2142
2354
  }
2143
- return function (...args) {
2355
+ // Defined inline so the closure stays anonymous: binding it to a `const` first names it, which costs 256 bytes per implemented function.
2356
+ return Object.defineProperty(function (...args) {
2144
2357
  const parsedArgs = inst._def.input ? (0, parse_js_1.parse)(inst._def.input, args) : args;
2145
2358
  const result = Reflect.apply(func, this, parsedArgs);
2146
2359
  if (inst._def.output) {
2147
2360
  return (0, parse_js_1.parse)(inst._def.output, result);
2148
2361
  }
2149
2362
  return result;
2150
- };
2363
+ }, "_zod", { value: inst._zod, enumerable: false });
2151
2364
  };
2152
2365
  inst.implementAsync = (func) => {
2153
2366
  if (typeof func !== "function") {
2154
2367
  throw new Error("implementAsync() must be called with a function");
2155
2368
  }
2156
- return async function (...args) {
2369
+ return Object.defineProperty(async function (...args) {
2157
2370
  const parsedArgs = inst._def.input ? await (0, parse_js_1.parseAsync)(inst._def.input, args) : args;
2158
2371
  const result = await Reflect.apply(func, this, parsedArgs);
2159
2372
  if (inst._def.output) {
2160
2373
  return await (0, parse_js_1.parseAsync)(inst._def.output, result);
2161
2374
  }
2162
2375
  return result;
2163
- };
2376
+ }, "_zod", { value: inst._zod, enumerable: false });
2164
2377
  };
2165
2378
  inst._zod.parse = (payload, _ctx) => {
2166
2379
  if (typeof payload.value !== "function") {
@@ -2219,19 +2432,17 @@ exports.$ZodPromise = core.$constructor("$ZodPromise", (inst, def) => {
2219
2432
  });
2220
2433
  exports.$ZodLazy = core.$constructor("$ZodLazy", (inst, def) => {
2221
2434
  exports.$ZodType.init(inst, def);
2222
- // Cache the resolved inner type on the shared `def` so all clones of this
2223
- // lazy (e.g. via `.describe()`/`.meta()`) share the same inner instance,
2224
- // preserving identity for cycle detection on recursive schemas.
2435
+ // 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.
2225
2436
  util.defineLazy(inst._zod, "innerType", () => {
2226
2437
  const d = def;
2227
2438
  if (!d._cachedInner)
2228
2439
  d._cachedInner = def.getter();
2229
2440
  return d._cachedInner;
2230
2441
  });
2231
- util.defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2232
- util.defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2233
- util.defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? undefined);
2234
- util.defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? undefined);
2442
+ util.defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
2443
+ util.defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
2444
+ util.defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? undefined);
2445
+ util.defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? undefined);
2235
2446
  inst._zod.parse = (payload, ctx) => {
2236
2447
  const inner = inst._zod.innerType;
2237
2448
  return inner._zod.run(payload, ctx);