@tonyclaw/agent-inspector 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/.output/cli.js +1611 -0
  2. package/.output/nitro.json +17 -0
  3. package/.output/public/assets/CompareDrawer-CU5ZrWcL.js +1 -0
  4. package/.output/public/assets/ProxyViewerContainer-pEBqVp1d.js +101 -0
  5. package/.output/public/assets/ReplayDialog-F58yNg5j.js +1 -0
  6. package/.output/public/assets/RequestAnatomy-C9lT0qE_.js +1 -0
  7. package/.output/public/assets/ResponseView-DHJq6bnz.js +1 -0
  8. package/.output/public/assets/StreamingChunkSequence-BTgfpFUT.js +1 -0
  9. package/.output/public/assets/_sessionId-DsNRbnNm.js +1 -0
  10. package/.output/public/assets/alibaba-TTwafVwX.svg +1 -0
  11. package/.output/public/assets/index-CpWG2hFn.css +1 -0
  12. package/.output/public/assets/index-DmBV8Gve.js +1 -0
  13. package/.output/public/assets/json-viewer-CZVYLR8j.js +14 -0
  14. package/.output/public/assets/main-DHs7FBK3.js +18 -0
  15. package/.output/public/assets/minimax-BPMzvuL-.jpeg +0 -0
  16. package/.output/public/assets/qwen-CONDcHqt.png +0 -0
  17. package/.output/public/assets/zhipuai-BPNAnxo-.svg +219 -0
  18. package/.output/server/_chunks/ssr-renderer.mjs +22 -0
  19. package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -0
  20. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
  21. package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +2 -0
  22. package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +2 -0
  23. package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +2 -0
  24. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
  25. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
  26. package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
  27. package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
  28. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -0
  29. package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
  30. package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +34 -0
  31. package/.output/server/_libs/ajv-formats.mjs +330 -0
  32. package/.output/server/_libs/ajv.mjs +11444 -0
  33. package/.output/server/_libs/aria-hidden.mjs +122 -0
  34. package/.output/server/_libs/atomically.mjs +152 -0
  35. package/.output/server/_libs/bail.mjs +8 -0
  36. package/.output/server/_libs/cfworker__json-schema.mjs +1 -0
  37. package/.output/server/_libs/character-entities.mjs +2130 -0
  38. package/.output/server/_libs/class-variance-authority.mjs +44 -0
  39. package/.output/server/_libs/clsx.mjs +16 -0
  40. package/.output/server/_libs/comma-separated-tokens.mjs +10 -0
  41. package/.output/server/_libs/conf.mjs +635 -0
  42. package/.output/server/_libs/cookie-es.mjs +58 -0
  43. package/.output/server/_libs/core-util-is.mjs +75 -0
  44. package/.output/server/_libs/croner.mjs +1 -0
  45. package/.output/server/_libs/crossws.mjs +1 -0
  46. package/.output/server/_libs/debounce-fn.mjs +69 -0
  47. package/.output/server/_libs/decode-named-character-reference+[...].mjs +8 -0
  48. package/.output/server/_libs/dequal.mjs +27 -0
  49. package/.output/server/_libs/detect-node-es.mjs +1 -0
  50. package/.output/server/_libs/devlop.mjs +8 -0
  51. package/.output/server/_libs/diff.mjs +320 -0
  52. package/.output/server/_libs/dot-prop.mjs +265 -0
  53. package/.output/server/_libs/env-paths.mjs +57 -0
  54. package/.output/server/_libs/estree-util-is-identifier-name.mjs +11 -0
  55. package/.output/server/_libs/extend.mjs +97 -0
  56. package/.output/server/_libs/fast-deep-equal.mjs +38 -0
  57. package/.output/server/_libs/fast-uri.mjs +812 -0
  58. package/.output/server/_libs/floating-ui__core.mjs +725 -0
  59. package/.output/server/_libs/floating-ui__dom.mjs +622 -0
  60. package/.output/server/_libs/floating-ui__react-dom.mjs +292 -0
  61. package/.output/server/_libs/floating-ui__utils.mjs +320 -0
  62. package/.output/server/_libs/get-nonce.mjs +9 -0
  63. package/.output/server/_libs/h3-v2.mjs +276 -0
  64. package/.output/server/_libs/h3.mjs +408 -0
  65. package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
  66. package/.output/server/_libs/hast-util-whitespace.mjs +10 -0
  67. package/.output/server/_libs/hookable.mjs +1 -0
  68. package/.output/server/_libs/html-url-attributes.mjs +26 -0
  69. package/.output/server/_libs/immediate.mjs +74 -0
  70. package/.output/server/_libs/inherits.mjs +50 -0
  71. package/.output/server/_libs/inline-style-parser.mjs +142 -0
  72. package/.output/server/_libs/is-plain-obj.mjs +10 -0
  73. package/.output/server/_libs/isarray.mjs +14 -0
  74. package/.output/server/_libs/isbot.mjs +20 -0
  75. package/.output/server/_libs/json-schema-traverse.mjs +180 -0
  76. package/.output/server/_libs/jszip.mjs +3051 -0
  77. package/.output/server/_libs/lie.mjs +273 -0
  78. package/.output/server/_libs/lucide-react.mjs +492 -0
  79. package/.output/server/_libs/mdast-util-from-markdown.mjs +717 -0
  80. package/.output/server/_libs/mdast-util-to-hast.mjs +710 -0
  81. package/.output/server/_libs/mdast-util-to-string.mjs +38 -0
  82. package/.output/server/_libs/micromark-core-commonmark.mjs +2259 -0
  83. package/.output/server/_libs/micromark-factory-destination.mjs +94 -0
  84. package/.output/server/_libs/micromark-factory-label.mjs +63 -0
  85. package/.output/server/_libs/micromark-factory-space.mjs +24 -0
  86. package/.output/server/_libs/micromark-factory-title.mjs +65 -0
  87. package/.output/server/_libs/micromark-factory-whitespace.mjs +22 -0
  88. package/.output/server/_libs/micromark-util-character.mjs +44 -0
  89. package/.output/server/_libs/micromark-util-chunked.mjs +36 -0
  90. package/.output/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
  91. package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
  92. package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
  93. package/.output/server/_libs/micromark-util-decode-string.mjs +21 -0
  94. package/.output/server/_libs/micromark-util-encode.mjs +1 -0
  95. package/.output/server/_libs/micromark-util-html-tag-name.mjs +69 -0
  96. package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
  97. package/.output/server/_libs/micromark-util-resolve-all.mjs +15 -0
  98. package/.output/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
  99. package/.output/server/_libs/micromark-util-subtokenize.mjs +346 -0
  100. package/.output/server/_libs/micromark.mjs +906 -0
  101. package/.output/server/_libs/mimic-function.mjs +47 -0
  102. package/.output/server/_libs/modelcontextprotocol__server.mjs +9738 -0
  103. package/.output/server/_libs/ocache.mjs +1 -0
  104. package/.output/server/_libs/ohash.mjs +1 -0
  105. package/.output/server/_libs/pako.mjs +4223 -0
  106. package/.output/server/_libs/process-nextick-args.mjs +48 -0
  107. package/.output/server/_libs/property-information.mjs +1209 -0
  108. package/.output/server/_libs/radix-ui.mjs +1 -0
  109. package/.output/server/_libs/radix-ui__number.mjs +6 -0
  110. package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
  111. package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -0
  112. package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -0
  113. package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
  114. package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -0
  115. package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -0
  116. package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -0
  117. package/.output/server/_libs/radix-ui__react-collapsible.mjs +144 -0
  118. package/.output/server/_libs/radix-ui__react-collection.mjs +69 -0
  119. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
  120. package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -0
  121. package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
  122. package/.output/server/_libs/radix-ui__react-dialog.mjs +325 -0
  123. package/.output/server/_libs/radix-ui__react-direction.mjs +9 -0
  124. package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -0
  125. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
  126. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
  127. package/.output/server/_libs/radix-ui__react-form.mjs +1 -0
  128. package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -0
  129. package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
  130. package/.output/server/_libs/radix-ui__react-label.mjs +1 -0
  131. package/.output/server/_libs/radix-ui__react-menu.mjs +1 -0
  132. package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -0
  133. package/.output/server/_libs/radix-ui__react-popover.mjs +1 -0
  134. package/.output/server/_libs/radix-ui__react-popper.mjs +286 -0
  135. package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
  136. package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
  137. package/.output/server/_libs/radix-ui__react-primitive.mjs +42 -0
  138. package/.output/server/_libs/radix-ui__react-progress.mjs +1 -0
  139. package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -0
  140. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +224 -0
  141. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +721 -0
  142. package/.output/server/_libs/radix-ui__react-select.mjs +1163 -0
  143. package/.output/server/_libs/radix-ui__react-separator.mjs +28 -0
  144. package/.output/server/_libs/radix-ui__react-slider.mjs +1 -0
  145. package/.output/server/_libs/radix-ui__react-slot.mjs +99 -0
  146. package/.output/server/_libs/radix-ui__react-switch.mjs +1 -0
  147. package/.output/server/_libs/radix-ui__react-tabs.mjs +189 -0
  148. package/.output/server/_libs/radix-ui__react-toast.mjs +2 -0
  149. package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -0
  150. package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -0
  151. package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -0
  152. package/.output/server/_libs/radix-ui__react-tooltip.mjs +495 -0
  153. package/.output/server/_libs/radix-ui__react-use-previous.mjs +14 -0
  154. package/.output/server/_libs/radix-ui__react-use-size.mjs +39 -0
  155. package/.output/server/_libs/react-dom.mjs +10781 -0
  156. package/.output/server/_libs/react-markdown.mjs +147 -0
  157. package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
  158. package/.output/server/_libs/react-remove-scroll.mjs +328 -0
  159. package/.output/server/_libs/react-style-singleton.mjs +69 -0
  160. package/.output/server/_libs/react.mjs +515 -0
  161. package/.output/server/_libs/readable-stream.mjs +1518 -0
  162. package/.output/server/_libs/remark-parse.mjs +19 -0
  163. package/.output/server/_libs/remark-rehype.mjs +21 -0
  164. package/.output/server/_libs/rou3.mjs +14 -0
  165. package/.output/server/_libs/safe-buffer.mjs +64 -0
  166. package/.output/server/_libs/semver.mjs +1938 -0
  167. package/.output/server/_libs/seroval-plugins.mjs +58 -0
  168. package/.output/server/_libs/seroval.mjs +1765 -0
  169. package/.output/server/_libs/setimmediate.mjs +152 -0
  170. package/.output/server/_libs/space-separated-tokens.mjs +6 -0
  171. package/.output/server/_libs/srvx.mjs +1029 -0
  172. package/.output/server/_libs/stubborn-fs.mjs +91 -0
  173. package/.output/server/_libs/stubborn-utils.mjs +66 -0
  174. package/.output/server/_libs/style-to-js.mjs +72 -0
  175. package/.output/server/_libs/style-to-object.mjs +38 -0
  176. package/.output/server/_libs/swr.mjs +939 -0
  177. package/.output/server/_libs/tailwind-merge.mjs +3010 -0
  178. package/.output/server/_libs/tanstack__history.mjs +217 -0
  179. package/.output/server/_libs/tanstack__react-router.mjs +1480 -0
  180. package/.output/server/_libs/tanstack__react-store.mjs +1 -0
  181. package/.output/server/_libs/tanstack__react-virtual.mjs +44 -0
  182. package/.output/server/_libs/tanstack__router-core.mjs +4827 -0
  183. package/.output/server/_libs/tanstack__store.mjs +1 -0
  184. package/.output/server/_libs/tanstack__virtual-core.mjs +1225 -0
  185. package/.output/server/_libs/tiny-invariant.mjs +12 -0
  186. package/.output/server/_libs/tiny-warning.mjs +5 -0
  187. package/.output/server/_libs/trim-lines.mjs +41 -0
  188. package/.output/server/_libs/trough.mjs +85 -0
  189. package/.output/server/_libs/tslib.mjs +1 -0
  190. package/.output/server/_libs/ufo.mjs +54 -0
  191. package/.output/server/_libs/uint8array-extras.mjs +69 -0
  192. package/.output/server/_libs/ungap__structured-clone.mjs +212 -0
  193. package/.output/server/_libs/unified.mjs +661 -0
  194. package/.output/server/_libs/unist-util-is.mjs +100 -0
  195. package/.output/server/_libs/unist-util-position.mjs +27 -0
  196. package/.output/server/_libs/unist-util-stringify-position.mjs +27 -0
  197. package/.output/server/_libs/unist-util-visit-parents.mjs +82 -0
  198. package/.output/server/_libs/unist-util-visit.mjs +24 -0
  199. package/.output/server/_libs/unstorage.mjs +1 -0
  200. package/.output/server/_libs/use-callback-ref.mjs +66 -0
  201. package/.output/server/_libs/use-sidecar.mjs +106 -0
  202. package/.output/server/_libs/use-sync-external-store.mjs +64 -0
  203. package/.output/server/_libs/util-deprecate.mjs +12 -0
  204. package/.output/server/_libs/vfile-message.mjs +138 -0
  205. package/.output/server/_libs/vfile.mjs +467 -0
  206. package/.output/server/_libs/when-exit.mjs +53 -0
  207. package/.output/server/_libs/zod.mjs +4524 -0
  208. package/.output/server/_sessionId-wMLPvC5g.mjs +123 -0
  209. package/.output/server/_ssr/CompareDrawer-BU4V0uVf.mjs +1041 -0
  210. package/.output/server/_ssr/ProxyViewerContainer-BnRwFEnn.mjs +5972 -0
  211. package/.output/server/_ssr/ReplayDialog-C7dn9pd_.mjs +322 -0
  212. package/.output/server/_ssr/RequestAnatomy-C1rWpe9-.mjs +353 -0
  213. package/.output/server/_ssr/ResponseView-hGpPaYsf.mjs +602 -0
  214. package/.output/server/_ssr/StreamingChunkSequence-BRWI1r_G.mjs +302 -0
  215. package/.output/server/_ssr/index-BKURLVPz.mjs +118 -0
  216. package/.output/server/_ssr/index.mjs +1184 -0
  217. package/.output/server/_ssr/json-viewer-BBd2DtQP.mjs +515 -0
  218. package/.output/server/_ssr/router-BcZ0D6AB.mjs +6317 -0
  219. package/.output/server/_ssr/start-HYkvq4Ni.mjs +4 -0
  220. package/.output/server/_tanstack-start-manifest_v-1y8ZVxRI.mjs +4 -0
  221. package/.output/server/index.mjs +436 -0
  222. package/.output/server/node_modules/tslib/modules/index.js +70 -0
  223. package/.output/server/node_modules/tslib/modules/package.json +3 -0
  224. package/.output/server/node_modules/tslib/package.json +47 -0
  225. package/.output/server/node_modules/tslib/tslib.js +484 -0
  226. package/.output/server/package.json +9 -0
  227. package/LICENSE +21 -0
  228. package/README.md +52 -0
  229. package/package.json +110 -0
  230. package/src/assets/favicon.svg +31 -0
  231. package/src/assets/logos/alibaba.svg +1 -0
  232. package/src/assets/logos/anthropic.svg +1 -0
  233. package/src/assets/logos/claude-code.svg +4 -0
  234. package/src/assets/logos/deepseek.svg +1 -0
  235. package/src/assets/logos/mcp.png +0 -0
  236. package/src/assets/logos/minimax.jpeg +0 -0
  237. package/src/assets/logos/openai.svg +1 -0
  238. package/src/assets/logos/opencode.svg +4 -0
  239. package/src/assets/logos/qwen.png +0 -0
  240. package/src/assets/logos/zhipuai.svg +219 -0
  241. package/src/cli/detect-tools.ts +147 -0
  242. package/src/cli/doctor.ts +521 -0
  243. package/src/cli/onboard.ts +224 -0
  244. package/src/cli/templates/command-onboard.ts +17 -0
  245. package/src/cli/templates/skill-onboard.ts +547 -0
  246. package/src/cli.ts +345 -0
  247. package/src/components/OnboardingBanner.tsx +67 -0
  248. package/src/components/ProxyViewer.tsx +545 -0
  249. package/src/components/ProxyViewerContainer.tsx +363 -0
  250. package/src/components/providers/ImportWizardDialog.tsx +349 -0
  251. package/src/components/providers/ProviderCard.tsx +474 -0
  252. package/src/components/providers/ProviderForm.tsx +494 -0
  253. package/src/components/providers/ProviderLogo.tsx +117 -0
  254. package/src/components/providers/ProvidersPanel.tsx +619 -0
  255. package/src/components/providers/SettingsDialog.tsx +202 -0
  256. package/src/components/proxy-viewer/CompareDrawer.tsx +893 -0
  257. package/src/components/proxy-viewer/ConversationGroup.tsx +107 -0
  258. package/src/components/proxy-viewer/ConversationHeader.tsx +300 -0
  259. package/src/components/proxy-viewer/LogEntry.tsx +543 -0
  260. package/src/components/proxy-viewer/LogEntryHeader.tsx +501 -0
  261. package/src/components/proxy-viewer/ReplayDialog.tsx +218 -0
  262. package/src/components/proxy-viewer/ResponseView.tsx +171 -0
  263. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +188 -0
  264. package/src/components/proxy-viewer/ThreadConnector.tsx +136 -0
  265. package/src/components/proxy-viewer/TurnGroup.tsx +337 -0
  266. package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +98 -0
  267. package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +196 -0
  268. package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +53 -0
  269. package/src/components/proxy-viewer/anatomy/types.ts +39 -0
  270. package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +114 -0
  271. package/src/components/proxy-viewer/cacheTrend.ts +50 -0
  272. package/src/components/proxy-viewer/diff/DiffView.tsx +321 -0
  273. package/src/components/proxy-viewer/diff/computeDiff.ts +178 -0
  274. package/src/components/proxy-viewer/diff/index.ts +3 -0
  275. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +157 -0
  276. package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +66 -0
  277. package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +21 -0
  278. package/src/components/proxy-viewer/formats/index.tsx +33 -0
  279. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +170 -0
  280. package/src/components/proxy-viewer/index.ts +9 -0
  281. package/src/components/proxy-viewer/lazy.ts +37 -0
  282. package/src/components/proxy-viewer/log-formats/anthropic.ts +194 -0
  283. package/src/components/proxy-viewer/log-formats/index.ts +23 -0
  284. package/src/components/proxy-viewer/log-formats/openai.ts +167 -0
  285. package/src/components/proxy-viewer/log-formats/types.ts +40 -0
  286. package/src/components/proxy-viewer/log-formats/unknown.ts +18 -0
  287. package/src/components/proxy-viewer/logEntryVisibility.ts +39 -0
  288. package/src/components/proxy-viewer/requestDiff.ts +277 -0
  289. package/src/components/proxy-viewer/useCopyFeedback.ts +36 -0
  290. package/src/components/proxy-viewer/useKeyboardNavigation.ts +190 -0
  291. package/src/components/proxy-viewer/viewerState.ts +66 -0
  292. package/src/components/ui/badge.tsx +47 -0
  293. package/src/components/ui/button.tsx +47 -0
  294. package/src/components/ui/collapsible.tsx +21 -0
  295. package/src/components/ui/confirm-dialog.tsx +51 -0
  296. package/src/components/ui/crab-logo.tsx +95 -0
  297. package/src/components/ui/crab-variants.tsx +467 -0
  298. package/src/components/ui/dialog.tsx +129 -0
  299. package/src/components/ui/json-expansion-button.tsx +56 -0
  300. package/src/components/ui/json-viewer-bulk.ts +97 -0
  301. package/src/components/ui/json-viewer.tsx +494 -0
  302. package/src/components/ui/mcp-logo.tsx +20 -0
  303. package/src/components/ui/scroll-area.tsx +54 -0
  304. package/src/components/ui/select.tsx +178 -0
  305. package/src/components/ui/separator.tsx +28 -0
  306. package/src/components/ui/tabs.tsx +88 -0
  307. package/src/components/ui/tooltip.tsx +51 -0
  308. package/src/index.css +11 -0
  309. package/src/knowledge/candidateStore.ts +63 -0
  310. package/src/knowledge/distiller.ts +98 -0
  311. package/src/knowledge/openclawClient.ts +118 -0
  312. package/src/knowledge/redactor.ts +80 -0
  313. package/src/knowledge/types.ts +84 -0
  314. package/src/lib/apiClient.ts +49 -0
  315. package/src/lib/export-logs.ts +51 -0
  316. package/src/lib/mask.ts +4 -0
  317. package/src/lib/objectUtils.ts +22 -0
  318. package/src/lib/providerContract.ts +26 -0
  319. package/src/lib/providerTestContract.ts +107 -0
  320. package/src/lib/runtimeConfig.ts +25 -0
  321. package/src/lib/serverPort.ts +41 -0
  322. package/src/lib/sessionUrl.ts +44 -0
  323. package/src/lib/stopReason.ts +58 -0
  324. package/src/lib/useOnboarding.ts +80 -0
  325. package/src/lib/useProviders.ts +30 -0
  326. package/src/lib/useStripConfig.ts +108 -0
  327. package/src/lib/utils.ts +21 -0
  328. package/src/mcp/loopback.ts +76 -0
  329. package/src/mcp/previewExtractor.ts +166 -0
  330. package/src/mcp/server.ts +396 -0
  331. package/src/mcp/toolHandlers.ts +341 -0
  332. package/src/proxy/chunkStorage.ts +112 -0
  333. package/src/proxy/claudeCodeStrip.ts +99 -0
  334. package/src/proxy/config.ts +172 -0
  335. package/src/proxy/constants.ts +47 -0
  336. package/src/proxy/dataDir.ts +86 -0
  337. package/src/proxy/formats/anthropic/anthropicProvider.ts +75 -0
  338. package/src/proxy/formats/anthropic/handler.ts +71 -0
  339. package/src/proxy/formats/anthropic/index.ts +14 -0
  340. package/src/proxy/formats/anthropic/register.ts +4 -0
  341. package/src/proxy/formats/anthropic/schemas.ts +237 -0
  342. package/src/proxy/formats/anthropic/stream.ts +205 -0
  343. package/src/proxy/formats/handler.ts +46 -0
  344. package/src/proxy/formats/index.ts +12 -0
  345. package/src/proxy/formats/jsonSchema.ts +36 -0
  346. package/src/proxy/formats/openai/alibabaProvider.ts +38 -0
  347. package/src/proxy/formats/openai/handler.ts +96 -0
  348. package/src/proxy/formats/openai/index.ts +25 -0
  349. package/src/proxy/formats/openai/provider.ts +50 -0
  350. package/src/proxy/formats/openai/register.ts +4 -0
  351. package/src/proxy/formats/openai/schemas.ts +187 -0
  352. package/src/proxy/formats/openai/stream.ts +206 -0
  353. package/src/proxy/formats/protocol.ts +50 -0
  354. package/src/proxy/formats/providerRegistry.ts +51 -0
  355. package/src/proxy/formats/providers/index.ts +3 -0
  356. package/src/proxy/formats/registry.ts +66 -0
  357. package/src/proxy/handler.ts +334 -0
  358. package/src/proxy/logFinalizer.ts +305 -0
  359. package/src/proxy/logFinalizer.worker.ts +24 -0
  360. package/src/proxy/logIndex.ts +268 -0
  361. package/src/proxy/logger.ts +179 -0
  362. package/src/proxy/openaiOrphanToolStrip.ts +142 -0
  363. package/src/proxy/providerImporters.ts +491 -0
  364. package/src/proxy/providers.ts +613 -0
  365. package/src/proxy/schemas.ts +209 -0
  366. package/src/proxy/sessionProcess.ts +140 -0
  367. package/src/proxy/sessionRuntime.ts +85 -0
  368. package/src/proxy/sessionSupervisor.ts +283 -0
  369. package/src/proxy/sessionWorkerEntry.ts +26 -0
  370. package/src/proxy/socketTracker.ts +255 -0
  371. package/src/proxy/store.ts +412 -0
  372. package/src/proxy/upstream.ts +90 -0
  373. package/src/router.tsx +16 -0
  374. package/src/routes/__root.tsx +45 -0
  375. package/src/routes/api/config.paths.ts +14 -0
  376. package/src/routes/api/config.ts +53 -0
  377. package/src/routes/api/health.ts +15 -0
  378. package/src/routes/api/knowledge.candidates.$candidateId.promote.ts +32 -0
  379. package/src/routes/api/knowledge.candidates.ts +10 -0
  380. package/src/routes/api/knowledge.project-context.ts +18 -0
  381. package/src/routes/api/knowledge.search.ts +31 -0
  382. package/src/routes/api/knowledge.sessions.$sessionId.candidates.ts +16 -0
  383. package/src/routes/api/logs.$id.chunks.ts +36 -0
  384. package/src/routes/api/logs.$id.replay.ts +191 -0
  385. package/src/routes/api/logs.$id.ts +22 -0
  386. package/src/routes/api/logs.stream.ts +74 -0
  387. package/src/routes/api/logs.ts +59 -0
  388. package/src/routes/api/mcp.ts +25 -0
  389. package/src/routes/api/models.ts +10 -0
  390. package/src/routes/api/providers.$providerId.test.log.ts +293 -0
  391. package/src/routes/api/providers.$providerId.ts +50 -0
  392. package/src/routes/api/providers.export.ts +26 -0
  393. package/src/routes/api/providers.import.ts +47 -0
  394. package/src/routes/api/providers.scan.ts +23 -0
  395. package/src/routes/api/providers.ts +45 -0
  396. package/src/routes/api/sessions.ts +17 -0
  397. package/src/routes/index.tsx +6 -0
  398. package/src/routes/proxy/$.ts +15 -0
  399. package/src/routes/session/$sessionId.tsx +23 -0
  400. package/styles/globals.css +188 -0
@@ -0,0 +1,4524 @@
1
+ const NEVER = Object.freeze({
2
+ status: "aborted"
3
+ });
4
+ function $constructor(name, initializer2, params) {
5
+ function init(inst, def) {
6
+ if (!inst._zod) {
7
+ Object.defineProperty(inst, "_zod", {
8
+ value: {
9
+ def,
10
+ constr: _,
11
+ traits: /* @__PURE__ */ new Set()
12
+ },
13
+ enumerable: false
14
+ });
15
+ }
16
+ if (inst._zod.traits.has(name)) {
17
+ return;
18
+ }
19
+ inst._zod.traits.add(name);
20
+ initializer2(inst, def);
21
+ const proto = _.prototype;
22
+ const keys = Object.keys(proto);
23
+ for (let i = 0; i < keys.length; i++) {
24
+ const k = keys[i];
25
+ if (!(k in inst)) {
26
+ inst[k] = proto[k].bind(inst);
27
+ }
28
+ }
29
+ }
30
+ const Parent = params?.Parent ?? Object;
31
+ class Definition extends Parent {
32
+ }
33
+ Object.defineProperty(Definition, "name", { value: name });
34
+ function _(def) {
35
+ var _a2;
36
+ const inst = params?.Parent ? new Definition() : this;
37
+ init(inst, def);
38
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
39
+ for (const fn of inst._zod.deferred) {
40
+ fn();
41
+ }
42
+ return inst;
43
+ }
44
+ Object.defineProperty(_, "init", { value: init });
45
+ Object.defineProperty(_, Symbol.hasInstance, {
46
+ value: (inst) => {
47
+ if (params?.Parent && inst instanceof params.Parent)
48
+ return true;
49
+ return inst?._zod?.traits?.has(name);
50
+ }
51
+ });
52
+ Object.defineProperty(_, "name", { value: name });
53
+ return _;
54
+ }
55
+ class $ZodAsyncError extends Error {
56
+ constructor() {
57
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
58
+ }
59
+ }
60
+ class $ZodEncodeError extends Error {
61
+ constructor(name) {
62
+ super(`Encountered unidirectional transform during encode: ${name}`);
63
+ this.name = "ZodEncodeError";
64
+ }
65
+ }
66
+ const globalConfig = {};
67
+ function config(newConfig) {
68
+ return globalConfig;
69
+ }
70
+ function getEnumValues(entries) {
71
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
72
+ const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
73
+ return values;
74
+ }
75
+ function jsonStringifyReplacer(_, value) {
76
+ if (typeof value === "bigint")
77
+ return value.toString();
78
+ return value;
79
+ }
80
+ function cached(getter) {
81
+ return {
82
+ get value() {
83
+ {
84
+ const value = getter();
85
+ Object.defineProperty(this, "value", { value });
86
+ return value;
87
+ }
88
+ }
89
+ };
90
+ }
91
+ function nullish(input) {
92
+ return input === null || input === void 0;
93
+ }
94
+ function cleanRegex(source) {
95
+ const start = source.startsWith("^") ? 1 : 0;
96
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
97
+ return source.slice(start, end);
98
+ }
99
+ function floatSafeRemainder(val, step) {
100
+ const valDecCount = (val.toString().split(".")[1] || "").length;
101
+ const stepString = step.toString();
102
+ let stepDecCount = (stepString.split(".")[1] || "").length;
103
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
104
+ const match = stepString.match(/\d?e-(\d?)/);
105
+ if (match?.[1]) {
106
+ stepDecCount = Number.parseInt(match[1]);
107
+ }
108
+ }
109
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
110
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
111
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
112
+ return valInt % stepInt / 10 ** decCount;
113
+ }
114
+ const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
115
+ function defineLazy(object2, key, getter) {
116
+ let value = void 0;
117
+ Object.defineProperty(object2, key, {
118
+ get() {
119
+ if (value === EVALUATING) {
120
+ return void 0;
121
+ }
122
+ if (value === void 0) {
123
+ value = EVALUATING;
124
+ value = getter();
125
+ }
126
+ return value;
127
+ },
128
+ set(v) {
129
+ Object.defineProperty(object2, key, {
130
+ value: v
131
+ // configurable: true,
132
+ });
133
+ },
134
+ configurable: true
135
+ });
136
+ }
137
+ function assignProp(target, prop, value) {
138
+ Object.defineProperty(target, prop, {
139
+ value,
140
+ writable: true,
141
+ enumerable: true,
142
+ configurable: true
143
+ });
144
+ }
145
+ function mergeDefs(...defs) {
146
+ const mergedDescriptors = {};
147
+ for (const def of defs) {
148
+ const descriptors = Object.getOwnPropertyDescriptors(def);
149
+ Object.assign(mergedDescriptors, descriptors);
150
+ }
151
+ return Object.defineProperties({}, mergedDescriptors);
152
+ }
153
+ function esc(str) {
154
+ return JSON.stringify(str);
155
+ }
156
+ function slugify(input) {
157
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
158
+ }
159
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
160
+ };
161
+ function isObject(data) {
162
+ return typeof data === "object" && data !== null && !Array.isArray(data);
163
+ }
164
+ const allowsEval = cached(() => {
165
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
166
+ return false;
167
+ }
168
+ try {
169
+ const F = Function;
170
+ new F("");
171
+ return true;
172
+ } catch (_) {
173
+ return false;
174
+ }
175
+ });
176
+ function isPlainObject(o) {
177
+ if (isObject(o) === false)
178
+ return false;
179
+ const ctor = o.constructor;
180
+ if (ctor === void 0)
181
+ return true;
182
+ if (typeof ctor !== "function")
183
+ return true;
184
+ const prot = ctor.prototype;
185
+ if (isObject(prot) === false)
186
+ return false;
187
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
188
+ return false;
189
+ }
190
+ return true;
191
+ }
192
+ function shallowClone(o) {
193
+ if (isPlainObject(o))
194
+ return { ...o };
195
+ if (Array.isArray(o))
196
+ return [...o];
197
+ return o;
198
+ }
199
+ const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
200
+ function escapeRegex(str) {
201
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
202
+ }
203
+ function clone(inst, def, params) {
204
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
205
+ if (!def || params?.parent)
206
+ cl._zod.parent = inst;
207
+ return cl;
208
+ }
209
+ function normalizeParams(_params) {
210
+ const params = _params;
211
+ if (!params)
212
+ return {};
213
+ if (typeof params === "string")
214
+ return { error: () => params };
215
+ if (params?.message !== void 0) {
216
+ if (params?.error !== void 0)
217
+ throw new Error("Cannot specify both `message` and `error` params");
218
+ params.error = params.message;
219
+ }
220
+ delete params.message;
221
+ if (typeof params.error === "string")
222
+ return { ...params, error: () => params.error };
223
+ return params;
224
+ }
225
+ function optionalKeys(shape) {
226
+ return Object.keys(shape).filter((k) => {
227
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
228
+ });
229
+ }
230
+ const NUMBER_FORMAT_RANGES = {
231
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
232
+ int32: [-2147483648, 2147483647],
233
+ uint32: [0, 4294967295],
234
+ float32: [-34028234663852886e22, 34028234663852886e22],
235
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
236
+ };
237
+ function pick(schema, mask) {
238
+ const currDef = schema._zod.def;
239
+ const checks = currDef.checks;
240
+ const hasChecks = checks && checks.length > 0;
241
+ if (hasChecks) {
242
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
243
+ }
244
+ const def = mergeDefs(schema._zod.def, {
245
+ get shape() {
246
+ const newShape = {};
247
+ for (const key in mask) {
248
+ if (!(key in currDef.shape)) {
249
+ throw new Error(`Unrecognized key: "${key}"`);
250
+ }
251
+ if (!mask[key])
252
+ continue;
253
+ newShape[key] = currDef.shape[key];
254
+ }
255
+ assignProp(this, "shape", newShape);
256
+ return newShape;
257
+ },
258
+ checks: []
259
+ });
260
+ return clone(schema, def);
261
+ }
262
+ function omit(schema, mask) {
263
+ const currDef = schema._zod.def;
264
+ const checks = currDef.checks;
265
+ const hasChecks = checks && checks.length > 0;
266
+ if (hasChecks) {
267
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
268
+ }
269
+ const def = mergeDefs(schema._zod.def, {
270
+ get shape() {
271
+ const newShape = { ...schema._zod.def.shape };
272
+ for (const key in mask) {
273
+ if (!(key in currDef.shape)) {
274
+ throw new Error(`Unrecognized key: "${key}"`);
275
+ }
276
+ if (!mask[key])
277
+ continue;
278
+ delete newShape[key];
279
+ }
280
+ assignProp(this, "shape", newShape);
281
+ return newShape;
282
+ },
283
+ checks: []
284
+ });
285
+ return clone(schema, def);
286
+ }
287
+ function extend(schema, shape) {
288
+ if (!isPlainObject(shape)) {
289
+ throw new Error("Invalid input to extend: expected a plain object");
290
+ }
291
+ const checks = schema._zod.def.checks;
292
+ const hasChecks = checks && checks.length > 0;
293
+ if (hasChecks) {
294
+ const existingShape = schema._zod.def.shape;
295
+ for (const key in shape) {
296
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
297
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
298
+ }
299
+ }
300
+ }
301
+ const def = mergeDefs(schema._zod.def, {
302
+ get shape() {
303
+ const _shape = { ...schema._zod.def.shape, ...shape };
304
+ assignProp(this, "shape", _shape);
305
+ return _shape;
306
+ }
307
+ });
308
+ return clone(schema, def);
309
+ }
310
+ function safeExtend(schema, shape) {
311
+ if (!isPlainObject(shape)) {
312
+ throw new Error("Invalid input to safeExtend: expected a plain object");
313
+ }
314
+ const def = mergeDefs(schema._zod.def, {
315
+ get shape() {
316
+ const _shape = { ...schema._zod.def.shape, ...shape };
317
+ assignProp(this, "shape", _shape);
318
+ return _shape;
319
+ }
320
+ });
321
+ return clone(schema, def);
322
+ }
323
+ function merge(a, b) {
324
+ const def = mergeDefs(a._zod.def, {
325
+ get shape() {
326
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
327
+ assignProp(this, "shape", _shape);
328
+ return _shape;
329
+ },
330
+ get catchall() {
331
+ return b._zod.def.catchall;
332
+ },
333
+ checks: []
334
+ // delete existing checks
335
+ });
336
+ return clone(a, def);
337
+ }
338
+ function partial(Class, schema, mask) {
339
+ const currDef = schema._zod.def;
340
+ const checks = currDef.checks;
341
+ const hasChecks = checks && checks.length > 0;
342
+ if (hasChecks) {
343
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
344
+ }
345
+ const def = mergeDefs(schema._zod.def, {
346
+ get shape() {
347
+ const oldShape = schema._zod.def.shape;
348
+ const shape = { ...oldShape };
349
+ if (mask) {
350
+ for (const key in mask) {
351
+ if (!(key in oldShape)) {
352
+ throw new Error(`Unrecognized key: "${key}"`);
353
+ }
354
+ if (!mask[key])
355
+ continue;
356
+ shape[key] = Class ? new Class({
357
+ type: "optional",
358
+ innerType: oldShape[key]
359
+ }) : oldShape[key];
360
+ }
361
+ } else {
362
+ for (const key in oldShape) {
363
+ shape[key] = Class ? new Class({
364
+ type: "optional",
365
+ innerType: oldShape[key]
366
+ }) : oldShape[key];
367
+ }
368
+ }
369
+ assignProp(this, "shape", shape);
370
+ return shape;
371
+ },
372
+ checks: []
373
+ });
374
+ return clone(schema, def);
375
+ }
376
+ function required(Class, schema, mask) {
377
+ const def = mergeDefs(schema._zod.def, {
378
+ get shape() {
379
+ const oldShape = schema._zod.def.shape;
380
+ const shape = { ...oldShape };
381
+ if (mask) {
382
+ for (const key in mask) {
383
+ if (!(key in shape)) {
384
+ throw new Error(`Unrecognized key: "${key}"`);
385
+ }
386
+ if (!mask[key])
387
+ continue;
388
+ shape[key] = new Class({
389
+ type: "nonoptional",
390
+ innerType: oldShape[key]
391
+ });
392
+ }
393
+ } else {
394
+ for (const key in oldShape) {
395
+ shape[key] = new Class({
396
+ type: "nonoptional",
397
+ innerType: oldShape[key]
398
+ });
399
+ }
400
+ }
401
+ assignProp(this, "shape", shape);
402
+ return shape;
403
+ }
404
+ });
405
+ return clone(schema, def);
406
+ }
407
+ function aborted(x, startIndex = 0) {
408
+ if (x.aborted === true)
409
+ return true;
410
+ for (let i = startIndex; i < x.issues.length; i++) {
411
+ if (x.issues[i]?.continue !== true) {
412
+ return true;
413
+ }
414
+ }
415
+ return false;
416
+ }
417
+ function prefixIssues(path, issues) {
418
+ return issues.map((iss) => {
419
+ var _a2;
420
+ (_a2 = iss).path ?? (_a2.path = []);
421
+ iss.path.unshift(path);
422
+ return iss;
423
+ });
424
+ }
425
+ function unwrapMessage(message) {
426
+ return typeof message === "string" ? message : message?.message;
427
+ }
428
+ function finalizeIssue(iss, ctx, config2) {
429
+ const full = { ...iss, path: iss.path ?? [] };
430
+ if (!iss.message) {
431
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
432
+ full.message = message;
433
+ }
434
+ delete full.inst;
435
+ delete full.continue;
436
+ if (!ctx?.reportInput) {
437
+ delete full.input;
438
+ }
439
+ return full;
440
+ }
441
+ function getLengthableOrigin(input) {
442
+ if (Array.isArray(input))
443
+ return "array";
444
+ if (typeof input === "string")
445
+ return "string";
446
+ return "unknown";
447
+ }
448
+ function issue(...args) {
449
+ const [iss, input, inst] = args;
450
+ if (typeof iss === "string") {
451
+ return {
452
+ message: iss,
453
+ code: "custom",
454
+ input,
455
+ inst
456
+ };
457
+ }
458
+ return { ...iss };
459
+ }
460
+ const initializer$1 = (inst, def) => {
461
+ inst.name = "$ZodError";
462
+ Object.defineProperty(inst, "_zod", {
463
+ value: inst._zod,
464
+ enumerable: false
465
+ });
466
+ Object.defineProperty(inst, "issues", {
467
+ value: def,
468
+ enumerable: false
469
+ });
470
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
471
+ Object.defineProperty(inst, "toString", {
472
+ value: () => inst.message,
473
+ enumerable: false
474
+ });
475
+ };
476
+ const $ZodError = $constructor("$ZodError", initializer$1);
477
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
478
+ function flattenError(error, mapper = (issue2) => issue2.message) {
479
+ const fieldErrors = {};
480
+ const formErrors = [];
481
+ for (const sub of error.issues) {
482
+ if (sub.path.length > 0) {
483
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
484
+ fieldErrors[sub.path[0]].push(mapper(sub));
485
+ } else {
486
+ formErrors.push(mapper(sub));
487
+ }
488
+ }
489
+ return { formErrors, fieldErrors };
490
+ }
491
+ function formatError(error, mapper = (issue2) => issue2.message) {
492
+ const fieldErrors = { _errors: [] };
493
+ const processError = (error2) => {
494
+ for (const issue2 of error2.issues) {
495
+ if (issue2.code === "invalid_union" && issue2.errors.length) {
496
+ issue2.errors.map((issues) => processError({ issues }));
497
+ } else if (issue2.code === "invalid_key") {
498
+ processError({ issues: issue2.issues });
499
+ } else if (issue2.code === "invalid_element") {
500
+ processError({ issues: issue2.issues });
501
+ } else if (issue2.path.length === 0) {
502
+ fieldErrors._errors.push(mapper(issue2));
503
+ } else {
504
+ let curr = fieldErrors;
505
+ let i = 0;
506
+ while (i < issue2.path.length) {
507
+ const el = issue2.path[i];
508
+ const terminal = i === issue2.path.length - 1;
509
+ if (!terminal) {
510
+ curr[el] = curr[el] || { _errors: [] };
511
+ } else {
512
+ curr[el] = curr[el] || { _errors: [] };
513
+ curr[el]._errors.push(mapper(issue2));
514
+ }
515
+ curr = curr[el];
516
+ i++;
517
+ }
518
+ }
519
+ }
520
+ };
521
+ processError(error);
522
+ return fieldErrors;
523
+ }
524
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
525
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
526
+ const result = schema._zod.run({ value, issues: [] }, ctx);
527
+ if (result instanceof Promise) {
528
+ throw new $ZodAsyncError();
529
+ }
530
+ if (result.issues.length) {
531
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
532
+ captureStackTrace(e, _params?.callee);
533
+ throw e;
534
+ }
535
+ return result.value;
536
+ };
537
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
538
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
539
+ let result = schema._zod.run({ value, issues: [] }, ctx);
540
+ if (result instanceof Promise)
541
+ result = await result;
542
+ if (result.issues.length) {
543
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
544
+ captureStackTrace(e, params?.callee);
545
+ throw e;
546
+ }
547
+ return result.value;
548
+ };
549
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
550
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
551
+ const result = schema._zod.run({ value, issues: [] }, ctx);
552
+ if (result instanceof Promise) {
553
+ throw new $ZodAsyncError();
554
+ }
555
+ return result.issues.length ? {
556
+ success: false,
557
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
558
+ } : { success: true, data: result.value };
559
+ };
560
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
561
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
562
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
563
+ let result = schema._zod.run({ value, issues: [] }, ctx);
564
+ if (result instanceof Promise)
565
+ result = await result;
566
+ return result.issues.length ? {
567
+ success: false,
568
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
569
+ } : { success: true, data: result.value };
570
+ };
571
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
572
+ const _encode = (_Err) => (schema, value, _ctx) => {
573
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
574
+ return _parse(_Err)(schema, value, ctx);
575
+ };
576
+ const _decode = (_Err) => (schema, value, _ctx) => {
577
+ return _parse(_Err)(schema, value, _ctx);
578
+ };
579
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
580
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
581
+ return _parseAsync(_Err)(schema, value, ctx);
582
+ };
583
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
584
+ return _parseAsync(_Err)(schema, value, _ctx);
585
+ };
586
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
587
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
588
+ return _safeParse(_Err)(schema, value, ctx);
589
+ };
590
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
591
+ return _safeParse(_Err)(schema, value, _ctx);
592
+ };
593
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
594
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
595
+ return _safeParseAsync(_Err)(schema, value, ctx);
596
+ };
597
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
598
+ return _safeParseAsync(_Err)(schema, value, _ctx);
599
+ };
600
+ const cuid = /^[cC][^\s-]{8,}$/;
601
+ const cuid2 = /^[0-9a-z]+$/;
602
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
603
+ const xid = /^[0-9a-vA-V]{20}$/;
604
+ const ksuid = /^[A-Za-z0-9]{27}$/;
605
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
606
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
607
+ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
608
+ const uuid = (version2) => {
609
+ if (!version2)
610
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
611
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
612
+ };
613
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
614
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
615
+ function emoji() {
616
+ return new RegExp(_emoji$1, "u");
617
+ }
618
+ const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
619
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
620
+ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
621
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
622
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
623
+ const base64url = /^[A-Za-z0-9_-]*$/;
624
+ const e164 = /^\+[1-9]\d{6,14}$/;
625
+ const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
626
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
627
+ function timeSource(args) {
628
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
629
+ const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
630
+ return regex;
631
+ }
632
+ function time$1(args) {
633
+ return new RegExp(`^${timeSource(args)}$`);
634
+ }
635
+ function datetime$1(args) {
636
+ const time2 = timeSource({ precision: args.precision });
637
+ const opts = ["Z"];
638
+ if (args.local)
639
+ opts.push("");
640
+ if (args.offset)
641
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
642
+ const timeRegex = `${time2}(?:${opts.join("|")})`;
643
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
644
+ }
645
+ const string$1 = (params) => {
646
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
647
+ return new RegExp(`^${regex}$`);
648
+ };
649
+ const integer = /^-?\d+$/;
650
+ const number$2 = /^-?\d+(?:\.\d+)?$/;
651
+ const boolean$1 = /^(?:true|false)$/i;
652
+ const _null$2 = /^null$/i;
653
+ const lowercase = /^[^A-Z]*$/;
654
+ const uppercase = /^[^a-z]*$/;
655
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
656
+ var _a2;
657
+ inst._zod ?? (inst._zod = {});
658
+ inst._zod.def = def;
659
+ (_a2 = inst._zod).onattach ?? (_a2.onattach = []);
660
+ });
661
+ const numericOriginMap = {
662
+ number: "number",
663
+ bigint: "bigint",
664
+ object: "date"
665
+ };
666
+ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
667
+ $ZodCheck.init(inst, def);
668
+ const origin = numericOriginMap[typeof def.value];
669
+ inst._zod.onattach.push((inst2) => {
670
+ const bag = inst2._zod.bag;
671
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
672
+ if (def.value < curr) {
673
+ if (def.inclusive)
674
+ bag.maximum = def.value;
675
+ else
676
+ bag.exclusiveMaximum = def.value;
677
+ }
678
+ });
679
+ inst._zod.check = (payload) => {
680
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
681
+ return;
682
+ }
683
+ payload.issues.push({
684
+ origin,
685
+ code: "too_big",
686
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
687
+ input: payload.value,
688
+ inclusive: def.inclusive,
689
+ inst,
690
+ continue: !def.abort
691
+ });
692
+ };
693
+ });
694
+ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
695
+ $ZodCheck.init(inst, def);
696
+ const origin = numericOriginMap[typeof def.value];
697
+ inst._zod.onattach.push((inst2) => {
698
+ const bag = inst2._zod.bag;
699
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
700
+ if (def.value > curr) {
701
+ if (def.inclusive)
702
+ bag.minimum = def.value;
703
+ else
704
+ bag.exclusiveMinimum = def.value;
705
+ }
706
+ });
707
+ inst._zod.check = (payload) => {
708
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
709
+ return;
710
+ }
711
+ payload.issues.push({
712
+ origin,
713
+ code: "too_small",
714
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
715
+ input: payload.value,
716
+ inclusive: def.inclusive,
717
+ inst,
718
+ continue: !def.abort
719
+ });
720
+ };
721
+ });
722
+ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
723
+ $ZodCheck.init(inst, def);
724
+ inst._zod.onattach.push((inst2) => {
725
+ var _a2;
726
+ (_a2 = inst2._zod.bag).multipleOf ?? (_a2.multipleOf = def.value);
727
+ });
728
+ inst._zod.check = (payload) => {
729
+ if (typeof payload.value !== typeof def.value)
730
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
731
+ const isMultiple = typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0;
732
+ if (isMultiple)
733
+ return;
734
+ payload.issues.push({
735
+ origin: typeof payload.value,
736
+ code: "not_multiple_of",
737
+ divisor: def.value,
738
+ input: payload.value,
739
+ inst,
740
+ continue: !def.abort
741
+ });
742
+ };
743
+ });
744
+ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
745
+ $ZodCheck.init(inst, def);
746
+ def.format = def.format || "float64";
747
+ const isInt = def.format?.includes("int");
748
+ const origin = isInt ? "int" : "number";
749
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
750
+ inst._zod.onattach.push((inst2) => {
751
+ const bag = inst2._zod.bag;
752
+ bag.format = def.format;
753
+ bag.minimum = minimum;
754
+ bag.maximum = maximum;
755
+ if (isInt)
756
+ bag.pattern = integer;
757
+ });
758
+ inst._zod.check = (payload) => {
759
+ const input = payload.value;
760
+ if (isInt) {
761
+ if (!Number.isInteger(input)) {
762
+ payload.issues.push({
763
+ expected: origin,
764
+ format: def.format,
765
+ code: "invalid_type",
766
+ continue: false,
767
+ input,
768
+ inst
769
+ });
770
+ return;
771
+ }
772
+ if (!Number.isSafeInteger(input)) {
773
+ if (input > 0) {
774
+ payload.issues.push({
775
+ input,
776
+ code: "too_big",
777
+ maximum: Number.MAX_SAFE_INTEGER,
778
+ note: "Integers must be within the safe integer range.",
779
+ inst,
780
+ origin,
781
+ inclusive: true,
782
+ continue: !def.abort
783
+ });
784
+ } else {
785
+ payload.issues.push({
786
+ input,
787
+ code: "too_small",
788
+ minimum: Number.MIN_SAFE_INTEGER,
789
+ note: "Integers must be within the safe integer range.",
790
+ inst,
791
+ origin,
792
+ inclusive: true,
793
+ continue: !def.abort
794
+ });
795
+ }
796
+ return;
797
+ }
798
+ }
799
+ if (input < minimum) {
800
+ payload.issues.push({
801
+ origin: "number",
802
+ input,
803
+ code: "too_small",
804
+ minimum,
805
+ inclusive: true,
806
+ inst,
807
+ continue: !def.abort
808
+ });
809
+ }
810
+ if (input > maximum) {
811
+ payload.issues.push({
812
+ origin: "number",
813
+ input,
814
+ code: "too_big",
815
+ maximum,
816
+ inclusive: true,
817
+ inst,
818
+ continue: !def.abort
819
+ });
820
+ }
821
+ };
822
+ });
823
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
824
+ var _a2;
825
+ $ZodCheck.init(inst, def);
826
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
827
+ const val = payload.value;
828
+ return !nullish(val) && val.length !== void 0;
829
+ });
830
+ inst._zod.onattach.push((inst2) => {
831
+ const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
832
+ if (def.maximum < curr)
833
+ inst2._zod.bag.maximum = def.maximum;
834
+ });
835
+ inst._zod.check = (payload) => {
836
+ const input = payload.value;
837
+ const length = input.length;
838
+ if (length <= def.maximum)
839
+ return;
840
+ const origin = getLengthableOrigin(input);
841
+ payload.issues.push({
842
+ origin,
843
+ code: "too_big",
844
+ maximum: def.maximum,
845
+ inclusive: true,
846
+ input,
847
+ inst,
848
+ continue: !def.abort
849
+ });
850
+ };
851
+ });
852
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
853
+ var _a2;
854
+ $ZodCheck.init(inst, def);
855
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
856
+ const val = payload.value;
857
+ return !nullish(val) && val.length !== void 0;
858
+ });
859
+ inst._zod.onattach.push((inst2) => {
860
+ const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
861
+ if (def.minimum > curr)
862
+ inst2._zod.bag.minimum = def.minimum;
863
+ });
864
+ inst._zod.check = (payload) => {
865
+ const input = payload.value;
866
+ const length = input.length;
867
+ if (length >= def.minimum)
868
+ return;
869
+ const origin = getLengthableOrigin(input);
870
+ payload.issues.push({
871
+ origin,
872
+ code: "too_small",
873
+ minimum: def.minimum,
874
+ inclusive: true,
875
+ input,
876
+ inst,
877
+ continue: !def.abort
878
+ });
879
+ };
880
+ });
881
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
882
+ var _a2;
883
+ $ZodCheck.init(inst, def);
884
+ (_a2 = inst._zod.def).when ?? (_a2.when = (payload) => {
885
+ const val = payload.value;
886
+ return !nullish(val) && val.length !== void 0;
887
+ });
888
+ inst._zod.onattach.push((inst2) => {
889
+ const bag = inst2._zod.bag;
890
+ bag.minimum = def.length;
891
+ bag.maximum = def.length;
892
+ bag.length = def.length;
893
+ });
894
+ inst._zod.check = (payload) => {
895
+ const input = payload.value;
896
+ const length = input.length;
897
+ if (length === def.length)
898
+ return;
899
+ const origin = getLengthableOrigin(input);
900
+ const tooBig = length > def.length;
901
+ payload.issues.push({
902
+ origin,
903
+ ...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
904
+ inclusive: true,
905
+ exact: true,
906
+ input: payload.value,
907
+ inst,
908
+ continue: !def.abort
909
+ });
910
+ };
911
+ });
912
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
913
+ var _a2, _b;
914
+ $ZodCheck.init(inst, def);
915
+ inst._zod.onattach.push((inst2) => {
916
+ const bag = inst2._zod.bag;
917
+ bag.format = def.format;
918
+ if (def.pattern) {
919
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
920
+ bag.patterns.add(def.pattern);
921
+ }
922
+ });
923
+ if (def.pattern)
924
+ (_a2 = inst._zod).check ?? (_a2.check = (payload) => {
925
+ def.pattern.lastIndex = 0;
926
+ if (def.pattern.test(payload.value))
927
+ return;
928
+ payload.issues.push({
929
+ origin: "string",
930
+ code: "invalid_format",
931
+ format: def.format,
932
+ input: payload.value,
933
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
934
+ inst,
935
+ continue: !def.abort
936
+ });
937
+ });
938
+ else
939
+ (_b = inst._zod).check ?? (_b.check = () => {
940
+ });
941
+ });
942
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
943
+ $ZodCheckStringFormat.init(inst, def);
944
+ inst._zod.check = (payload) => {
945
+ def.pattern.lastIndex = 0;
946
+ if (def.pattern.test(payload.value))
947
+ return;
948
+ payload.issues.push({
949
+ origin: "string",
950
+ code: "invalid_format",
951
+ format: "regex",
952
+ input: payload.value,
953
+ pattern: def.pattern.toString(),
954
+ inst,
955
+ continue: !def.abort
956
+ });
957
+ };
958
+ });
959
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
960
+ def.pattern ?? (def.pattern = lowercase);
961
+ $ZodCheckStringFormat.init(inst, def);
962
+ });
963
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
964
+ def.pattern ?? (def.pattern = uppercase);
965
+ $ZodCheckStringFormat.init(inst, def);
966
+ });
967
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
968
+ $ZodCheck.init(inst, def);
969
+ const escapedRegex = escapeRegex(def.includes);
970
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
971
+ def.pattern = pattern;
972
+ inst._zod.onattach.push((inst2) => {
973
+ const bag = inst2._zod.bag;
974
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
975
+ bag.patterns.add(pattern);
976
+ });
977
+ inst._zod.check = (payload) => {
978
+ if (payload.value.includes(def.includes, def.position))
979
+ return;
980
+ payload.issues.push({
981
+ origin: "string",
982
+ code: "invalid_format",
983
+ format: "includes",
984
+ includes: def.includes,
985
+ input: payload.value,
986
+ inst,
987
+ continue: !def.abort
988
+ });
989
+ };
990
+ });
991
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
992
+ $ZodCheck.init(inst, def);
993
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
994
+ def.pattern ?? (def.pattern = pattern);
995
+ inst._zod.onattach.push((inst2) => {
996
+ const bag = inst2._zod.bag;
997
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
998
+ bag.patterns.add(pattern);
999
+ });
1000
+ inst._zod.check = (payload) => {
1001
+ if (payload.value.startsWith(def.prefix))
1002
+ return;
1003
+ payload.issues.push({
1004
+ origin: "string",
1005
+ code: "invalid_format",
1006
+ format: "starts_with",
1007
+ prefix: def.prefix,
1008
+ input: payload.value,
1009
+ inst,
1010
+ continue: !def.abort
1011
+ });
1012
+ };
1013
+ });
1014
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
1015
+ $ZodCheck.init(inst, def);
1016
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1017
+ def.pattern ?? (def.pattern = pattern);
1018
+ inst._zod.onattach.push((inst2) => {
1019
+ const bag = inst2._zod.bag;
1020
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1021
+ bag.patterns.add(pattern);
1022
+ });
1023
+ inst._zod.check = (payload) => {
1024
+ if (payload.value.endsWith(def.suffix))
1025
+ return;
1026
+ payload.issues.push({
1027
+ origin: "string",
1028
+ code: "invalid_format",
1029
+ format: "ends_with",
1030
+ suffix: def.suffix,
1031
+ input: payload.value,
1032
+ inst,
1033
+ continue: !def.abort
1034
+ });
1035
+ };
1036
+ });
1037
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
1038
+ $ZodCheck.init(inst, def);
1039
+ inst._zod.check = (payload) => {
1040
+ payload.value = def.tx(payload.value);
1041
+ };
1042
+ });
1043
+ class Doc {
1044
+ constructor(args = []) {
1045
+ this.content = [];
1046
+ this.indent = 0;
1047
+ if (this)
1048
+ this.args = args;
1049
+ }
1050
+ indented(fn) {
1051
+ this.indent += 1;
1052
+ fn(this);
1053
+ this.indent -= 1;
1054
+ }
1055
+ write(arg) {
1056
+ if (typeof arg === "function") {
1057
+ arg(this, { execution: "sync" });
1058
+ arg(this, { execution: "async" });
1059
+ return;
1060
+ }
1061
+ const content = arg;
1062
+ const lines = content.split("\n").filter((x) => x);
1063
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1064
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1065
+ for (const line of dedented) {
1066
+ this.content.push(line);
1067
+ }
1068
+ }
1069
+ compile() {
1070
+ const F = Function;
1071
+ const args = this?.args;
1072
+ const content = this?.content ?? [``];
1073
+ const lines = [...content.map((x) => ` ${x}`)];
1074
+ return new F(...args, lines.join("\n"));
1075
+ }
1076
+ }
1077
+ const version = {
1078
+ major: 4,
1079
+ minor: 3,
1080
+ patch: 6
1081
+ };
1082
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1083
+ var _a2;
1084
+ inst ?? (inst = {});
1085
+ inst._zod.def = def;
1086
+ inst._zod.bag = inst._zod.bag || {};
1087
+ inst._zod.version = version;
1088
+ const checks = [...inst._zod.def.checks ?? []];
1089
+ if (inst._zod.traits.has("$ZodCheck")) {
1090
+ checks.unshift(inst);
1091
+ }
1092
+ for (const ch of checks) {
1093
+ for (const fn of ch._zod.onattach) {
1094
+ fn(inst);
1095
+ }
1096
+ }
1097
+ if (checks.length === 0) {
1098
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
1099
+ inst._zod.deferred?.push(() => {
1100
+ inst._zod.run = inst._zod.parse;
1101
+ });
1102
+ } else {
1103
+ const runChecks = (payload, checks2, ctx) => {
1104
+ let isAborted = aborted(payload);
1105
+ let asyncResult;
1106
+ for (const ch of checks2) {
1107
+ if (ch._zod.def.when) {
1108
+ const shouldRun = ch._zod.def.when(payload);
1109
+ if (!shouldRun)
1110
+ continue;
1111
+ } else if (isAborted) {
1112
+ continue;
1113
+ }
1114
+ const currLen = payload.issues.length;
1115
+ const _ = ch._zod.check(payload);
1116
+ if (_ instanceof Promise && ctx?.async === false) {
1117
+ throw new $ZodAsyncError();
1118
+ }
1119
+ if (asyncResult || _ instanceof Promise) {
1120
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1121
+ await _;
1122
+ const nextLen = payload.issues.length;
1123
+ if (nextLen === currLen)
1124
+ return;
1125
+ if (!isAborted)
1126
+ isAborted = aborted(payload, currLen);
1127
+ });
1128
+ } else {
1129
+ const nextLen = payload.issues.length;
1130
+ if (nextLen === currLen)
1131
+ continue;
1132
+ if (!isAborted)
1133
+ isAborted = aborted(payload, currLen);
1134
+ }
1135
+ }
1136
+ if (asyncResult) {
1137
+ return asyncResult.then(() => {
1138
+ return payload;
1139
+ });
1140
+ }
1141
+ return payload;
1142
+ };
1143
+ const handleCanaryResult = (canary, payload, ctx) => {
1144
+ if (aborted(canary)) {
1145
+ canary.aborted = true;
1146
+ return canary;
1147
+ }
1148
+ const checkResult = runChecks(payload, checks, ctx);
1149
+ if (checkResult instanceof Promise) {
1150
+ if (ctx.async === false)
1151
+ throw new $ZodAsyncError();
1152
+ return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
1153
+ }
1154
+ return inst._zod.parse(checkResult, ctx);
1155
+ };
1156
+ inst._zod.run = (payload, ctx) => {
1157
+ if (ctx.skipChecks) {
1158
+ return inst._zod.parse(payload, ctx);
1159
+ }
1160
+ if (ctx.direction === "backward") {
1161
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
1162
+ if (canary instanceof Promise) {
1163
+ return canary.then((canary2) => {
1164
+ return handleCanaryResult(canary2, payload, ctx);
1165
+ });
1166
+ }
1167
+ return handleCanaryResult(canary, payload, ctx);
1168
+ }
1169
+ const result = inst._zod.parse(payload, ctx);
1170
+ if (result instanceof Promise) {
1171
+ if (ctx.async === false)
1172
+ throw new $ZodAsyncError();
1173
+ return result.then((result2) => runChecks(result2, checks, ctx));
1174
+ }
1175
+ return runChecks(result, checks, ctx);
1176
+ };
1177
+ }
1178
+ defineLazy(inst, "~standard", () => ({
1179
+ validate: (value) => {
1180
+ try {
1181
+ const r = safeParse$1(inst, value);
1182
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1183
+ } catch (_) {
1184
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1185
+ }
1186
+ },
1187
+ vendor: "zod",
1188
+ version: 1
1189
+ }));
1190
+ });
1191
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1192
+ $ZodType.init(inst, def);
1193
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1194
+ inst._zod.parse = (payload, _) => {
1195
+ if (def.coerce)
1196
+ try {
1197
+ payload.value = String(payload.value);
1198
+ } catch (_2) {
1199
+ }
1200
+ if (typeof payload.value === "string")
1201
+ return payload;
1202
+ payload.issues.push({
1203
+ expected: "string",
1204
+ code: "invalid_type",
1205
+ input: payload.value,
1206
+ inst
1207
+ });
1208
+ return payload;
1209
+ };
1210
+ });
1211
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1212
+ $ZodCheckStringFormat.init(inst, def);
1213
+ $ZodString.init(inst, def);
1214
+ });
1215
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1216
+ def.pattern ?? (def.pattern = guid);
1217
+ $ZodStringFormat.init(inst, def);
1218
+ });
1219
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1220
+ if (def.version) {
1221
+ const versionMap = {
1222
+ v1: 1,
1223
+ v2: 2,
1224
+ v3: 3,
1225
+ v4: 4,
1226
+ v5: 5,
1227
+ v6: 6,
1228
+ v7: 7,
1229
+ v8: 8
1230
+ };
1231
+ const v = versionMap[def.version];
1232
+ if (v === void 0)
1233
+ throw new Error(`Invalid UUID version: "${def.version}"`);
1234
+ def.pattern ?? (def.pattern = uuid(v));
1235
+ } else
1236
+ def.pattern ?? (def.pattern = uuid());
1237
+ $ZodStringFormat.init(inst, def);
1238
+ });
1239
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1240
+ def.pattern ?? (def.pattern = email);
1241
+ $ZodStringFormat.init(inst, def);
1242
+ });
1243
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1244
+ $ZodStringFormat.init(inst, def);
1245
+ inst._zod.check = (payload) => {
1246
+ try {
1247
+ const trimmed = payload.value.trim();
1248
+ const url2 = new URL(trimmed);
1249
+ if (def.hostname) {
1250
+ def.hostname.lastIndex = 0;
1251
+ if (!def.hostname.test(url2.hostname)) {
1252
+ payload.issues.push({
1253
+ code: "invalid_format",
1254
+ format: "url",
1255
+ note: "Invalid hostname",
1256
+ pattern: def.hostname.source,
1257
+ input: payload.value,
1258
+ inst,
1259
+ continue: !def.abort
1260
+ });
1261
+ }
1262
+ }
1263
+ if (def.protocol) {
1264
+ def.protocol.lastIndex = 0;
1265
+ if (!def.protocol.test(url2.protocol.endsWith(":") ? url2.protocol.slice(0, -1) : url2.protocol)) {
1266
+ payload.issues.push({
1267
+ code: "invalid_format",
1268
+ format: "url",
1269
+ note: "Invalid protocol",
1270
+ pattern: def.protocol.source,
1271
+ input: payload.value,
1272
+ inst,
1273
+ continue: !def.abort
1274
+ });
1275
+ }
1276
+ }
1277
+ if (def.normalize) {
1278
+ payload.value = url2.href;
1279
+ } else {
1280
+ payload.value = trimmed;
1281
+ }
1282
+ return;
1283
+ } catch (_) {
1284
+ payload.issues.push({
1285
+ code: "invalid_format",
1286
+ format: "url",
1287
+ input: payload.value,
1288
+ inst,
1289
+ continue: !def.abort
1290
+ });
1291
+ }
1292
+ };
1293
+ });
1294
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1295
+ def.pattern ?? (def.pattern = emoji());
1296
+ $ZodStringFormat.init(inst, def);
1297
+ });
1298
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1299
+ def.pattern ?? (def.pattern = nanoid);
1300
+ $ZodStringFormat.init(inst, def);
1301
+ });
1302
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1303
+ def.pattern ?? (def.pattern = cuid);
1304
+ $ZodStringFormat.init(inst, def);
1305
+ });
1306
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1307
+ def.pattern ?? (def.pattern = cuid2);
1308
+ $ZodStringFormat.init(inst, def);
1309
+ });
1310
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1311
+ def.pattern ?? (def.pattern = ulid);
1312
+ $ZodStringFormat.init(inst, def);
1313
+ });
1314
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1315
+ def.pattern ?? (def.pattern = xid);
1316
+ $ZodStringFormat.init(inst, def);
1317
+ });
1318
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1319
+ def.pattern ?? (def.pattern = ksuid);
1320
+ $ZodStringFormat.init(inst, def);
1321
+ });
1322
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1323
+ def.pattern ?? (def.pattern = datetime$1(def));
1324
+ $ZodStringFormat.init(inst, def);
1325
+ });
1326
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1327
+ def.pattern ?? (def.pattern = date$1);
1328
+ $ZodStringFormat.init(inst, def);
1329
+ });
1330
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1331
+ def.pattern ?? (def.pattern = time$1(def));
1332
+ $ZodStringFormat.init(inst, def);
1333
+ });
1334
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1335
+ def.pattern ?? (def.pattern = duration$1);
1336
+ $ZodStringFormat.init(inst, def);
1337
+ });
1338
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1339
+ def.pattern ?? (def.pattern = ipv4);
1340
+ $ZodStringFormat.init(inst, def);
1341
+ inst._zod.bag.format = `ipv4`;
1342
+ });
1343
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1344
+ def.pattern ?? (def.pattern = ipv6);
1345
+ $ZodStringFormat.init(inst, def);
1346
+ inst._zod.bag.format = `ipv6`;
1347
+ inst._zod.check = (payload) => {
1348
+ try {
1349
+ new URL(`http://[${payload.value}]`);
1350
+ } catch {
1351
+ payload.issues.push({
1352
+ code: "invalid_format",
1353
+ format: "ipv6",
1354
+ input: payload.value,
1355
+ inst,
1356
+ continue: !def.abort
1357
+ });
1358
+ }
1359
+ };
1360
+ });
1361
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1362
+ def.pattern ?? (def.pattern = cidrv4);
1363
+ $ZodStringFormat.init(inst, def);
1364
+ });
1365
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1366
+ def.pattern ?? (def.pattern = cidrv6);
1367
+ $ZodStringFormat.init(inst, def);
1368
+ inst._zod.check = (payload) => {
1369
+ const parts = payload.value.split("/");
1370
+ try {
1371
+ if (parts.length !== 2)
1372
+ throw new Error();
1373
+ const [address, prefix] = parts;
1374
+ if (!prefix)
1375
+ throw new Error();
1376
+ const prefixNum = Number(prefix);
1377
+ if (`${prefixNum}` !== prefix)
1378
+ throw new Error();
1379
+ if (prefixNum < 0 || prefixNum > 128)
1380
+ throw new Error();
1381
+ new URL(`http://[${address}]`);
1382
+ } catch {
1383
+ payload.issues.push({
1384
+ code: "invalid_format",
1385
+ format: "cidrv6",
1386
+ input: payload.value,
1387
+ inst,
1388
+ continue: !def.abort
1389
+ });
1390
+ }
1391
+ };
1392
+ });
1393
+ function isValidBase64(data) {
1394
+ if (data === "")
1395
+ return true;
1396
+ if (data.length % 4 !== 0)
1397
+ return false;
1398
+ try {
1399
+ atob(data);
1400
+ return true;
1401
+ } catch {
1402
+ return false;
1403
+ }
1404
+ }
1405
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1406
+ def.pattern ?? (def.pattern = base64);
1407
+ $ZodStringFormat.init(inst, def);
1408
+ inst._zod.bag.contentEncoding = "base64";
1409
+ inst._zod.check = (payload) => {
1410
+ if (isValidBase64(payload.value))
1411
+ return;
1412
+ payload.issues.push({
1413
+ code: "invalid_format",
1414
+ format: "base64",
1415
+ input: payload.value,
1416
+ inst,
1417
+ continue: !def.abort
1418
+ });
1419
+ };
1420
+ });
1421
+ function isValidBase64URL(data) {
1422
+ if (!base64url.test(data))
1423
+ return false;
1424
+ const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1425
+ const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
1426
+ return isValidBase64(padded);
1427
+ }
1428
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1429
+ def.pattern ?? (def.pattern = base64url);
1430
+ $ZodStringFormat.init(inst, def);
1431
+ inst._zod.bag.contentEncoding = "base64url";
1432
+ inst._zod.check = (payload) => {
1433
+ if (isValidBase64URL(payload.value))
1434
+ return;
1435
+ payload.issues.push({
1436
+ code: "invalid_format",
1437
+ format: "base64url",
1438
+ input: payload.value,
1439
+ inst,
1440
+ continue: !def.abort
1441
+ });
1442
+ };
1443
+ });
1444
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1445
+ def.pattern ?? (def.pattern = e164);
1446
+ $ZodStringFormat.init(inst, def);
1447
+ });
1448
+ function isValidJWT(token, algorithm = null) {
1449
+ try {
1450
+ const tokensParts = token.split(".");
1451
+ if (tokensParts.length !== 3)
1452
+ return false;
1453
+ const [header] = tokensParts;
1454
+ if (!header)
1455
+ return false;
1456
+ const parsedHeader = JSON.parse(atob(header));
1457
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
1458
+ return false;
1459
+ if (!parsedHeader.alg)
1460
+ return false;
1461
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
1462
+ return false;
1463
+ return true;
1464
+ } catch {
1465
+ return false;
1466
+ }
1467
+ }
1468
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1469
+ $ZodStringFormat.init(inst, def);
1470
+ inst._zod.check = (payload) => {
1471
+ if (isValidJWT(payload.value, def.alg))
1472
+ return;
1473
+ payload.issues.push({
1474
+ code: "invalid_format",
1475
+ format: "jwt",
1476
+ input: payload.value,
1477
+ inst,
1478
+ continue: !def.abort
1479
+ });
1480
+ };
1481
+ });
1482
+ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1483
+ $ZodType.init(inst, def);
1484
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
1485
+ inst._zod.parse = (payload, _ctx) => {
1486
+ if (def.coerce)
1487
+ try {
1488
+ payload.value = Number(payload.value);
1489
+ } catch (_) {
1490
+ }
1491
+ const input = payload.value;
1492
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
1493
+ return payload;
1494
+ }
1495
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1496
+ payload.issues.push({
1497
+ expected: "number",
1498
+ code: "invalid_type",
1499
+ input,
1500
+ inst,
1501
+ ...received ? { received } : {}
1502
+ });
1503
+ return payload;
1504
+ };
1505
+ });
1506
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1507
+ $ZodCheckNumberFormat.init(inst, def);
1508
+ $ZodNumber.init(inst, def);
1509
+ });
1510
+ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1511
+ $ZodType.init(inst, def);
1512
+ inst._zod.pattern = boolean$1;
1513
+ inst._zod.parse = (payload, _ctx) => {
1514
+ if (def.coerce)
1515
+ try {
1516
+ payload.value = Boolean(payload.value);
1517
+ } catch (_) {
1518
+ }
1519
+ const input = payload.value;
1520
+ if (typeof input === "boolean")
1521
+ return payload;
1522
+ payload.issues.push({
1523
+ expected: "boolean",
1524
+ code: "invalid_type",
1525
+ input,
1526
+ inst
1527
+ });
1528
+ return payload;
1529
+ };
1530
+ });
1531
+ const $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
1532
+ $ZodType.init(inst, def);
1533
+ inst._zod.pattern = _null$2;
1534
+ inst._zod.values = /* @__PURE__ */ new Set([null]);
1535
+ inst._zod.parse = (payload, _ctx) => {
1536
+ const input = payload.value;
1537
+ if (input === null)
1538
+ return payload;
1539
+ payload.issues.push({
1540
+ expected: "null",
1541
+ code: "invalid_type",
1542
+ input,
1543
+ inst
1544
+ });
1545
+ return payload;
1546
+ };
1547
+ });
1548
+ const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
1549
+ $ZodType.init(inst, def);
1550
+ inst._zod.parse = (payload) => payload;
1551
+ });
1552
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1553
+ $ZodType.init(inst, def);
1554
+ inst._zod.parse = (payload) => payload;
1555
+ });
1556
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1557
+ $ZodType.init(inst, def);
1558
+ inst._zod.parse = (payload, _ctx) => {
1559
+ payload.issues.push({
1560
+ expected: "never",
1561
+ code: "invalid_type",
1562
+ input: payload.value,
1563
+ inst
1564
+ });
1565
+ return payload;
1566
+ };
1567
+ });
1568
+ function handleArrayResult(result, final, index) {
1569
+ if (result.issues.length) {
1570
+ final.issues.push(...prefixIssues(index, result.issues));
1571
+ }
1572
+ final.value[index] = result.value;
1573
+ }
1574
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1575
+ $ZodType.init(inst, def);
1576
+ inst._zod.parse = (payload, ctx) => {
1577
+ const input = payload.value;
1578
+ if (!Array.isArray(input)) {
1579
+ payload.issues.push({
1580
+ expected: "array",
1581
+ code: "invalid_type",
1582
+ input,
1583
+ inst
1584
+ });
1585
+ return payload;
1586
+ }
1587
+ payload.value = Array(input.length);
1588
+ const proms = [];
1589
+ for (let i = 0; i < input.length; i++) {
1590
+ const item = input[i];
1591
+ const result = def.element._zod.run({
1592
+ value: item,
1593
+ issues: []
1594
+ }, ctx);
1595
+ if (result instanceof Promise) {
1596
+ proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
1597
+ } else {
1598
+ handleArrayResult(result, payload, i);
1599
+ }
1600
+ }
1601
+ if (proms.length) {
1602
+ return Promise.all(proms).then(() => payload);
1603
+ }
1604
+ return payload;
1605
+ };
1606
+ });
1607
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1608
+ if (result.issues.length) {
1609
+ if (isOptionalOut && !(key in input)) {
1610
+ return;
1611
+ }
1612
+ final.issues.push(...prefixIssues(key, result.issues));
1613
+ }
1614
+ if (result.value === void 0) {
1615
+ if (key in input) {
1616
+ final.value[key] = void 0;
1617
+ }
1618
+ } else {
1619
+ final.value[key] = result.value;
1620
+ }
1621
+ }
1622
+ function normalizeDef(def) {
1623
+ const keys = Object.keys(def.shape);
1624
+ for (const k of keys) {
1625
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1626
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1627
+ }
1628
+ }
1629
+ const okeys = optionalKeys(def.shape);
1630
+ return {
1631
+ ...def,
1632
+ keys,
1633
+ keySet: new Set(keys),
1634
+ numKeys: keys.length,
1635
+ optionalKeys: new Set(okeys)
1636
+ };
1637
+ }
1638
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1639
+ const unrecognized = [];
1640
+ const keySet = def.keySet;
1641
+ const _catchall = def.catchall._zod;
1642
+ const t = _catchall.def.type;
1643
+ const isOptionalOut = _catchall.optout === "optional";
1644
+ for (const key in input) {
1645
+ if (keySet.has(key))
1646
+ continue;
1647
+ if (t === "never") {
1648
+ unrecognized.push(key);
1649
+ continue;
1650
+ }
1651
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1652
+ if (r instanceof Promise) {
1653
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1654
+ } else {
1655
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1656
+ }
1657
+ }
1658
+ if (unrecognized.length) {
1659
+ payload.issues.push({
1660
+ code: "unrecognized_keys",
1661
+ keys: unrecognized,
1662
+ input,
1663
+ inst
1664
+ });
1665
+ }
1666
+ if (!proms.length)
1667
+ return payload;
1668
+ return Promise.all(proms).then(() => {
1669
+ return payload;
1670
+ });
1671
+ }
1672
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1673
+ $ZodType.init(inst, def);
1674
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1675
+ if (!desc?.get) {
1676
+ const sh = def.shape;
1677
+ Object.defineProperty(def, "shape", {
1678
+ get: () => {
1679
+ const newSh = { ...sh };
1680
+ Object.defineProperty(def, "shape", {
1681
+ value: newSh
1682
+ });
1683
+ return newSh;
1684
+ }
1685
+ });
1686
+ }
1687
+ const _normalized = cached(() => normalizeDef(def));
1688
+ defineLazy(inst._zod, "propValues", () => {
1689
+ const shape = def.shape;
1690
+ const propValues = {};
1691
+ for (const key in shape) {
1692
+ const field = shape[key]._zod;
1693
+ if (field.values) {
1694
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1695
+ for (const v of field.values)
1696
+ propValues[key].add(v);
1697
+ }
1698
+ }
1699
+ return propValues;
1700
+ });
1701
+ const isObject$1 = isObject;
1702
+ const catchall = def.catchall;
1703
+ let value;
1704
+ inst._zod.parse = (payload, ctx) => {
1705
+ value ?? (value = _normalized.value);
1706
+ const input = payload.value;
1707
+ if (!isObject$1(input)) {
1708
+ payload.issues.push({
1709
+ expected: "object",
1710
+ code: "invalid_type",
1711
+ input,
1712
+ inst
1713
+ });
1714
+ return payload;
1715
+ }
1716
+ payload.value = {};
1717
+ const proms = [];
1718
+ const shape = value.shape;
1719
+ for (const key of value.keys) {
1720
+ const el = shape[key];
1721
+ const isOptionalOut = el._zod.optout === "optional";
1722
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1723
+ if (r instanceof Promise) {
1724
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1725
+ } else {
1726
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1727
+ }
1728
+ }
1729
+ if (!catchall) {
1730
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
1731
+ }
1732
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1733
+ };
1734
+ });
1735
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1736
+ $ZodObject.init(inst, def);
1737
+ const superParse = inst._zod.parse;
1738
+ const _normalized = cached(() => normalizeDef(def));
1739
+ const generateFastpass = (shape) => {
1740
+ const doc = new Doc(["shape", "payload", "ctx"]);
1741
+ const normalized = _normalized.value;
1742
+ const parseStr = (key) => {
1743
+ const k = esc(key);
1744
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1745
+ };
1746
+ doc.write(`const input = payload.value;`);
1747
+ const ids = /* @__PURE__ */ Object.create(null);
1748
+ let counter = 0;
1749
+ for (const key of normalized.keys) {
1750
+ ids[key] = `key_${counter++}`;
1751
+ }
1752
+ doc.write(`const newResult = {};`);
1753
+ for (const key of normalized.keys) {
1754
+ const id = ids[key];
1755
+ const k = esc(key);
1756
+ const schema = shape[key];
1757
+ const isOptionalOut = schema?._zod?.optout === "optional";
1758
+ doc.write(`const ${id} = ${parseStr(key)};`);
1759
+ if (isOptionalOut) {
1760
+ doc.write(`
1761
+ if (${id}.issues.length) {
1762
+ if (${k} in input) {
1763
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1764
+ ...iss,
1765
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1766
+ })));
1767
+ }
1768
+ }
1769
+
1770
+ if (${id}.value === undefined) {
1771
+ if (${k} in input) {
1772
+ newResult[${k}] = undefined;
1773
+ }
1774
+ } else {
1775
+ newResult[${k}] = ${id}.value;
1776
+ }
1777
+
1778
+ `);
1779
+ } else {
1780
+ doc.write(`
1781
+ if (${id}.issues.length) {
1782
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1783
+ ...iss,
1784
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1785
+ })));
1786
+ }
1787
+
1788
+ if (${id}.value === undefined) {
1789
+ if (${k} in input) {
1790
+ newResult[${k}] = undefined;
1791
+ }
1792
+ } else {
1793
+ newResult[${k}] = ${id}.value;
1794
+ }
1795
+
1796
+ `);
1797
+ }
1798
+ }
1799
+ doc.write(`payload.value = newResult;`);
1800
+ doc.write(`return payload;`);
1801
+ const fn = doc.compile();
1802
+ return (payload, ctx) => fn(shape, payload, ctx);
1803
+ };
1804
+ let fastpass;
1805
+ const isObject$1 = isObject;
1806
+ const jit = !globalConfig.jitless;
1807
+ const allowsEval$1 = allowsEval;
1808
+ const fastEnabled = jit && allowsEval$1.value;
1809
+ const catchall = def.catchall;
1810
+ let value;
1811
+ inst._zod.parse = (payload, ctx) => {
1812
+ value ?? (value = _normalized.value);
1813
+ const input = payload.value;
1814
+ if (!isObject$1(input)) {
1815
+ payload.issues.push({
1816
+ expected: "object",
1817
+ code: "invalid_type",
1818
+ input,
1819
+ inst
1820
+ });
1821
+ return payload;
1822
+ }
1823
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1824
+ if (!fastpass)
1825
+ fastpass = generateFastpass(def.shape);
1826
+ payload = fastpass(payload, ctx);
1827
+ if (!catchall)
1828
+ return payload;
1829
+ return handleCatchall([], input, payload, ctx, value, inst);
1830
+ }
1831
+ return superParse(payload, ctx);
1832
+ };
1833
+ });
1834
+ function handleUnionResults(results, final, inst, ctx) {
1835
+ for (const result of results) {
1836
+ if (result.issues.length === 0) {
1837
+ final.value = result.value;
1838
+ return final;
1839
+ }
1840
+ }
1841
+ const nonaborted = results.filter((r) => !aborted(r));
1842
+ if (nonaborted.length === 1) {
1843
+ final.value = nonaborted[0].value;
1844
+ return nonaborted[0];
1845
+ }
1846
+ final.issues.push({
1847
+ code: "invalid_union",
1848
+ input: final.value,
1849
+ inst,
1850
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1851
+ });
1852
+ return final;
1853
+ }
1854
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1855
+ $ZodType.init(inst, def);
1856
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1857
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1858
+ defineLazy(inst._zod, "values", () => {
1859
+ if (def.options.every((o) => o._zod.values)) {
1860
+ return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1861
+ }
1862
+ return void 0;
1863
+ });
1864
+ defineLazy(inst._zod, "pattern", () => {
1865
+ if (def.options.every((o) => o._zod.pattern)) {
1866
+ const patterns = def.options.map((o) => o._zod.pattern);
1867
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1868
+ }
1869
+ return void 0;
1870
+ });
1871
+ const single = def.options.length === 1;
1872
+ const first = def.options[0]._zod.run;
1873
+ inst._zod.parse = (payload, ctx) => {
1874
+ if (single) {
1875
+ return first(payload, ctx);
1876
+ }
1877
+ let async = false;
1878
+ const results = [];
1879
+ for (const option of def.options) {
1880
+ const result = option._zod.run({
1881
+ value: payload.value,
1882
+ issues: []
1883
+ }, ctx);
1884
+ if (result instanceof Promise) {
1885
+ results.push(result);
1886
+ async = true;
1887
+ } else {
1888
+ if (result.issues.length === 0)
1889
+ return result;
1890
+ results.push(result);
1891
+ }
1892
+ }
1893
+ if (!async)
1894
+ return handleUnionResults(results, payload, inst, ctx);
1895
+ return Promise.all(results).then((results2) => {
1896
+ return handleUnionResults(results2, payload, inst, ctx);
1897
+ });
1898
+ };
1899
+ });
1900
+ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1901
+ def.inclusive = false;
1902
+ $ZodUnion.init(inst, def);
1903
+ const _super = inst._zod.parse;
1904
+ defineLazy(inst._zod, "propValues", () => {
1905
+ const propValues = {};
1906
+ for (const option of def.options) {
1907
+ const pv = option._zod.propValues;
1908
+ if (!pv || Object.keys(pv).length === 0)
1909
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1910
+ for (const [k, v] of Object.entries(pv)) {
1911
+ if (!propValues[k])
1912
+ propValues[k] = /* @__PURE__ */ new Set();
1913
+ for (const val of v) {
1914
+ propValues[k].add(val);
1915
+ }
1916
+ }
1917
+ }
1918
+ return propValues;
1919
+ });
1920
+ const disc = cached(() => {
1921
+ const opts = def.options;
1922
+ const map = /* @__PURE__ */ new Map();
1923
+ for (const o of opts) {
1924
+ const values = o._zod.propValues?.[def.discriminator];
1925
+ if (!values || values.size === 0)
1926
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1927
+ for (const v of values) {
1928
+ if (map.has(v)) {
1929
+ throw new Error(`Duplicate discriminator value "${String(v)}"`);
1930
+ }
1931
+ map.set(v, o);
1932
+ }
1933
+ }
1934
+ return map;
1935
+ });
1936
+ inst._zod.parse = (payload, ctx) => {
1937
+ const input = payload.value;
1938
+ if (!isObject(input)) {
1939
+ payload.issues.push({
1940
+ code: "invalid_type",
1941
+ expected: "object",
1942
+ input,
1943
+ inst
1944
+ });
1945
+ return payload;
1946
+ }
1947
+ const opt = disc.value.get(input?.[def.discriminator]);
1948
+ if (opt) {
1949
+ return opt._zod.run(payload, ctx);
1950
+ }
1951
+ if (def.unionFallback) {
1952
+ return _super(payload, ctx);
1953
+ }
1954
+ payload.issues.push({
1955
+ code: "invalid_union",
1956
+ errors: [],
1957
+ note: "No matching discriminator",
1958
+ discriminator: def.discriminator,
1959
+ input,
1960
+ path: [def.discriminator],
1961
+ inst
1962
+ });
1963
+ return payload;
1964
+ };
1965
+ });
1966
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1967
+ $ZodType.init(inst, def);
1968
+ inst._zod.parse = (payload, ctx) => {
1969
+ const input = payload.value;
1970
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1971
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1972
+ const async = left instanceof Promise || right instanceof Promise;
1973
+ if (async) {
1974
+ return Promise.all([left, right]).then(([left2, right2]) => {
1975
+ return handleIntersectionResults(payload, left2, right2);
1976
+ });
1977
+ }
1978
+ return handleIntersectionResults(payload, left, right);
1979
+ };
1980
+ });
1981
+ function mergeValues(a, b) {
1982
+ if (a === b) {
1983
+ return { valid: true, data: a };
1984
+ }
1985
+ if (a instanceof Date && b instanceof Date && +a === +b) {
1986
+ return { valid: true, data: a };
1987
+ }
1988
+ if (isPlainObject(a) && isPlainObject(b)) {
1989
+ const bKeys = Object.keys(b);
1990
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1991
+ const newObj = { ...a, ...b };
1992
+ for (const key of sharedKeys) {
1993
+ const sharedValue = mergeValues(a[key], b[key]);
1994
+ if (!sharedValue.valid) {
1995
+ return {
1996
+ valid: false,
1997
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1998
+ };
1999
+ }
2000
+ newObj[key] = sharedValue.data;
2001
+ }
2002
+ return { valid: true, data: newObj };
2003
+ }
2004
+ if (Array.isArray(a) && Array.isArray(b)) {
2005
+ if (a.length !== b.length) {
2006
+ return { valid: false, mergeErrorPath: [] };
2007
+ }
2008
+ const newArray = [];
2009
+ for (let index = 0; index < a.length; index++) {
2010
+ const itemA = a[index];
2011
+ const itemB = b[index];
2012
+ const sharedValue = mergeValues(itemA, itemB);
2013
+ if (!sharedValue.valid) {
2014
+ return {
2015
+ valid: false,
2016
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2017
+ };
2018
+ }
2019
+ newArray.push(sharedValue.data);
2020
+ }
2021
+ return { valid: true, data: newArray };
2022
+ }
2023
+ return { valid: false, mergeErrorPath: [] };
2024
+ }
2025
+ function handleIntersectionResults(result, left, right) {
2026
+ const unrecKeys = /* @__PURE__ */ new Map();
2027
+ let unrecIssue;
2028
+ for (const iss of left.issues) {
2029
+ if (iss.code === "unrecognized_keys") {
2030
+ unrecIssue ?? (unrecIssue = iss);
2031
+ for (const k of iss.keys) {
2032
+ if (!unrecKeys.has(k))
2033
+ unrecKeys.set(k, {});
2034
+ unrecKeys.get(k).l = true;
2035
+ }
2036
+ } else {
2037
+ result.issues.push(iss);
2038
+ }
2039
+ }
2040
+ for (const iss of right.issues) {
2041
+ if (iss.code === "unrecognized_keys") {
2042
+ for (const k of iss.keys) {
2043
+ if (!unrecKeys.has(k))
2044
+ unrecKeys.set(k, {});
2045
+ unrecKeys.get(k).r = true;
2046
+ }
2047
+ } else {
2048
+ result.issues.push(iss);
2049
+ }
2050
+ }
2051
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2052
+ if (bothKeys.length && unrecIssue) {
2053
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
2054
+ }
2055
+ if (aborted(result))
2056
+ return result;
2057
+ const merged = mergeValues(left.value, right.value);
2058
+ if (!merged.valid) {
2059
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2060
+ }
2061
+ result.value = merged.data;
2062
+ return result;
2063
+ }
2064
+ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2065
+ $ZodType.init(inst, def);
2066
+ inst._zod.parse = (payload, ctx) => {
2067
+ const input = payload.value;
2068
+ if (!isPlainObject(input)) {
2069
+ payload.issues.push({
2070
+ expected: "record",
2071
+ code: "invalid_type",
2072
+ input,
2073
+ inst
2074
+ });
2075
+ return payload;
2076
+ }
2077
+ const proms = [];
2078
+ const values = def.keyType._zod.values;
2079
+ if (values) {
2080
+ payload.value = {};
2081
+ const recordKeys = /* @__PURE__ */ new Set();
2082
+ for (const key of values) {
2083
+ if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2084
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
2085
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2086
+ if (result instanceof Promise) {
2087
+ proms.push(result.then((result2) => {
2088
+ if (result2.issues.length) {
2089
+ payload.issues.push(...prefixIssues(key, result2.issues));
2090
+ }
2091
+ payload.value[key] = result2.value;
2092
+ }));
2093
+ } else {
2094
+ if (result.issues.length) {
2095
+ payload.issues.push(...prefixIssues(key, result.issues));
2096
+ }
2097
+ payload.value[key] = result.value;
2098
+ }
2099
+ }
2100
+ }
2101
+ let unrecognized;
2102
+ for (const key in input) {
2103
+ if (!recordKeys.has(key)) {
2104
+ unrecognized = unrecognized ?? [];
2105
+ unrecognized.push(key);
2106
+ }
2107
+ }
2108
+ if (unrecognized && unrecognized.length > 0) {
2109
+ payload.issues.push({
2110
+ code: "unrecognized_keys",
2111
+ input,
2112
+ inst,
2113
+ keys: unrecognized
2114
+ });
2115
+ }
2116
+ } else {
2117
+ payload.value = {};
2118
+ for (const key of Reflect.ownKeys(input)) {
2119
+ if (key === "__proto__")
2120
+ continue;
2121
+ let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2122
+ if (keyResult instanceof Promise) {
2123
+ throw new Error("Async schemas not supported in object keys currently");
2124
+ }
2125
+ const checkNumericKey = typeof key === "string" && number$2.test(key) && keyResult.issues.length;
2126
+ if (checkNumericKey) {
2127
+ const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2128
+ if (retryResult instanceof Promise) {
2129
+ throw new Error("Async schemas not supported in object keys currently");
2130
+ }
2131
+ if (retryResult.issues.length === 0) {
2132
+ keyResult = retryResult;
2133
+ }
2134
+ }
2135
+ if (keyResult.issues.length) {
2136
+ if (def.mode === "loose") {
2137
+ payload.value[key] = input[key];
2138
+ } else {
2139
+ payload.issues.push({
2140
+ code: "invalid_key",
2141
+ origin: "record",
2142
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2143
+ input: key,
2144
+ path: [key],
2145
+ inst
2146
+ });
2147
+ }
2148
+ continue;
2149
+ }
2150
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2151
+ if (result instanceof Promise) {
2152
+ proms.push(result.then((result2) => {
2153
+ if (result2.issues.length) {
2154
+ payload.issues.push(...prefixIssues(key, result2.issues));
2155
+ }
2156
+ payload.value[keyResult.value] = result2.value;
2157
+ }));
2158
+ } else {
2159
+ if (result.issues.length) {
2160
+ payload.issues.push(...prefixIssues(key, result.issues));
2161
+ }
2162
+ payload.value[keyResult.value] = result.value;
2163
+ }
2164
+ }
2165
+ }
2166
+ if (proms.length) {
2167
+ return Promise.all(proms).then(() => payload);
2168
+ }
2169
+ return payload;
2170
+ };
2171
+ });
2172
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2173
+ $ZodType.init(inst, def);
2174
+ const values = getEnumValues(def.entries);
2175
+ const valuesSet = new Set(values);
2176
+ inst._zod.values = valuesSet;
2177
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2178
+ inst._zod.parse = (payload, _ctx) => {
2179
+ const input = payload.value;
2180
+ if (valuesSet.has(input)) {
2181
+ return payload;
2182
+ }
2183
+ payload.issues.push({
2184
+ code: "invalid_value",
2185
+ values,
2186
+ input,
2187
+ inst
2188
+ });
2189
+ return payload;
2190
+ };
2191
+ });
2192
+ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2193
+ $ZodType.init(inst, def);
2194
+ if (def.values.length === 0) {
2195
+ throw new Error("Cannot create literal schema with no valid values");
2196
+ }
2197
+ const values = new Set(def.values);
2198
+ inst._zod.values = values;
2199
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2200
+ inst._zod.parse = (payload, _ctx) => {
2201
+ const input = payload.value;
2202
+ if (values.has(input)) {
2203
+ return payload;
2204
+ }
2205
+ payload.issues.push({
2206
+ code: "invalid_value",
2207
+ values: def.values,
2208
+ input,
2209
+ inst
2210
+ });
2211
+ return payload;
2212
+ };
2213
+ });
2214
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2215
+ $ZodType.init(inst, def);
2216
+ inst._zod.parse = (payload, ctx) => {
2217
+ if (ctx.direction === "backward") {
2218
+ throw new $ZodEncodeError(inst.constructor.name);
2219
+ }
2220
+ const _out = def.transform(payload.value, payload);
2221
+ if (ctx.async) {
2222
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
2223
+ return output.then((output2) => {
2224
+ payload.value = output2;
2225
+ return payload;
2226
+ });
2227
+ }
2228
+ if (_out instanceof Promise) {
2229
+ throw new $ZodAsyncError();
2230
+ }
2231
+ payload.value = _out;
2232
+ return payload;
2233
+ };
2234
+ });
2235
+ function handleOptionalResult(result, input) {
2236
+ if (result.issues.length && input === void 0) {
2237
+ return { issues: [], value: void 0 };
2238
+ }
2239
+ return result;
2240
+ }
2241
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2242
+ $ZodType.init(inst, def);
2243
+ inst._zod.optin = "optional";
2244
+ inst._zod.optout = "optional";
2245
+ defineLazy(inst._zod, "values", () => {
2246
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
2247
+ });
2248
+ defineLazy(inst._zod, "pattern", () => {
2249
+ const pattern = def.innerType._zod.pattern;
2250
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2251
+ });
2252
+ inst._zod.parse = (payload, ctx) => {
2253
+ if (def.innerType._zod.optin === "optional") {
2254
+ const result = def.innerType._zod.run(payload, ctx);
2255
+ if (result instanceof Promise)
2256
+ return result.then((r) => handleOptionalResult(r, payload.value));
2257
+ return handleOptionalResult(result, payload.value);
2258
+ }
2259
+ if (payload.value === void 0) {
2260
+ return payload;
2261
+ }
2262
+ return def.innerType._zod.run(payload, ctx);
2263
+ };
2264
+ });
2265
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2266
+ $ZodOptional.init(inst, def);
2267
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2268
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2269
+ inst._zod.parse = (payload, ctx) => {
2270
+ return def.innerType._zod.run(payload, ctx);
2271
+ };
2272
+ });
2273
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2274
+ $ZodType.init(inst, def);
2275
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2276
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2277
+ defineLazy(inst._zod, "pattern", () => {
2278
+ const pattern = def.innerType._zod.pattern;
2279
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2280
+ });
2281
+ defineLazy(inst._zod, "values", () => {
2282
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
2283
+ });
2284
+ inst._zod.parse = (payload, ctx) => {
2285
+ if (payload.value === null)
2286
+ return payload;
2287
+ return def.innerType._zod.run(payload, ctx);
2288
+ };
2289
+ });
2290
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2291
+ $ZodType.init(inst, def);
2292
+ inst._zod.optin = "optional";
2293
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2294
+ inst._zod.parse = (payload, ctx) => {
2295
+ if (ctx.direction === "backward") {
2296
+ return def.innerType._zod.run(payload, ctx);
2297
+ }
2298
+ if (payload.value === void 0) {
2299
+ payload.value = def.defaultValue;
2300
+ return payload;
2301
+ }
2302
+ const result = def.innerType._zod.run(payload, ctx);
2303
+ if (result instanceof Promise) {
2304
+ return result.then((result2) => handleDefaultResult(result2, def));
2305
+ }
2306
+ return handleDefaultResult(result, def);
2307
+ };
2308
+ });
2309
+ function handleDefaultResult(payload, def) {
2310
+ if (payload.value === void 0) {
2311
+ payload.value = def.defaultValue;
2312
+ }
2313
+ return payload;
2314
+ }
2315
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2316
+ $ZodType.init(inst, def);
2317
+ inst._zod.optin = "optional";
2318
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2319
+ inst._zod.parse = (payload, ctx) => {
2320
+ if (ctx.direction === "backward") {
2321
+ return def.innerType._zod.run(payload, ctx);
2322
+ }
2323
+ if (payload.value === void 0) {
2324
+ payload.value = def.defaultValue;
2325
+ }
2326
+ return def.innerType._zod.run(payload, ctx);
2327
+ };
2328
+ });
2329
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2330
+ $ZodType.init(inst, def);
2331
+ defineLazy(inst._zod, "values", () => {
2332
+ const v = def.innerType._zod.values;
2333
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2334
+ });
2335
+ inst._zod.parse = (payload, ctx) => {
2336
+ const result = def.innerType._zod.run(payload, ctx);
2337
+ if (result instanceof Promise) {
2338
+ return result.then((result2) => handleNonOptionalResult(result2, inst));
2339
+ }
2340
+ return handleNonOptionalResult(result, inst);
2341
+ };
2342
+ });
2343
+ function handleNonOptionalResult(payload, inst) {
2344
+ if (!payload.issues.length && payload.value === void 0) {
2345
+ payload.issues.push({
2346
+ code: "invalid_type",
2347
+ expected: "nonoptional",
2348
+ input: payload.value,
2349
+ inst
2350
+ });
2351
+ }
2352
+ return payload;
2353
+ }
2354
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2355
+ $ZodType.init(inst, def);
2356
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2357
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2358
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2359
+ inst._zod.parse = (payload, ctx) => {
2360
+ if (ctx.direction === "backward") {
2361
+ return def.innerType._zod.run(payload, ctx);
2362
+ }
2363
+ const result = def.innerType._zod.run(payload, ctx);
2364
+ if (result instanceof Promise) {
2365
+ return result.then((result2) => {
2366
+ payload.value = result2.value;
2367
+ if (result2.issues.length) {
2368
+ payload.value = def.catchValue({
2369
+ ...payload,
2370
+ error: {
2371
+ issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
2372
+ },
2373
+ input: payload.value
2374
+ });
2375
+ payload.issues = [];
2376
+ }
2377
+ return payload;
2378
+ });
2379
+ }
2380
+ payload.value = result.value;
2381
+ if (result.issues.length) {
2382
+ payload.value = def.catchValue({
2383
+ ...payload,
2384
+ error: {
2385
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
2386
+ },
2387
+ input: payload.value
2388
+ });
2389
+ payload.issues = [];
2390
+ }
2391
+ return payload;
2392
+ };
2393
+ });
2394
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2395
+ $ZodType.init(inst, def);
2396
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2397
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2398
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2399
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2400
+ inst._zod.parse = (payload, ctx) => {
2401
+ if (ctx.direction === "backward") {
2402
+ const right = def.out._zod.run(payload, ctx);
2403
+ if (right instanceof Promise) {
2404
+ return right.then((right2) => handlePipeResult(right2, def.in, ctx));
2405
+ }
2406
+ return handlePipeResult(right, def.in, ctx);
2407
+ }
2408
+ const left = def.in._zod.run(payload, ctx);
2409
+ if (left instanceof Promise) {
2410
+ return left.then((left2) => handlePipeResult(left2, def.out, ctx));
2411
+ }
2412
+ return handlePipeResult(left, def.out, ctx);
2413
+ };
2414
+ });
2415
+ function handlePipeResult(left, next, ctx) {
2416
+ if (left.issues.length) {
2417
+ left.aborted = true;
2418
+ return left;
2419
+ }
2420
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
2421
+ }
2422
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2423
+ $ZodType.init(inst, def);
2424
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2425
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2426
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2427
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2428
+ inst._zod.parse = (payload, ctx) => {
2429
+ if (ctx.direction === "backward") {
2430
+ return def.innerType._zod.run(payload, ctx);
2431
+ }
2432
+ const result = def.innerType._zod.run(payload, ctx);
2433
+ if (result instanceof Promise) {
2434
+ return result.then(handleReadonlyResult);
2435
+ }
2436
+ return handleReadonlyResult(result);
2437
+ };
2438
+ });
2439
+ function handleReadonlyResult(payload) {
2440
+ payload.value = Object.freeze(payload.value);
2441
+ return payload;
2442
+ }
2443
+ const $ZodLazy = /* @__PURE__ */ $constructor("$ZodLazy", (inst, def) => {
2444
+ $ZodType.init(inst, def);
2445
+ defineLazy(inst._zod, "innerType", () => def.getter());
2446
+ defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
2447
+ defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
2448
+ defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
2449
+ defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
2450
+ inst._zod.parse = (payload, ctx) => {
2451
+ const inner = inst._zod.innerType;
2452
+ return inner._zod.run(payload, ctx);
2453
+ };
2454
+ });
2455
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2456
+ $ZodCheck.init(inst, def);
2457
+ $ZodType.init(inst, def);
2458
+ inst._zod.parse = (payload, _) => {
2459
+ return payload;
2460
+ };
2461
+ inst._zod.check = (payload) => {
2462
+ const input = payload.value;
2463
+ const r = def.fn(input);
2464
+ if (r instanceof Promise) {
2465
+ return r.then((r2) => handleRefineResult(r2, payload, input, inst));
2466
+ }
2467
+ handleRefineResult(r, payload, input, inst);
2468
+ return;
2469
+ };
2470
+ });
2471
+ function handleRefineResult(result, payload, input, inst) {
2472
+ if (!result) {
2473
+ const _iss = {
2474
+ code: "custom",
2475
+ input,
2476
+ inst,
2477
+ // incorporates params.error into issue reporting
2478
+ path: [...inst._zod.def.path ?? []],
2479
+ // incorporates params.error into issue reporting
2480
+ continue: !inst._zod.def.abort
2481
+ // params: inst._zod.def.params,
2482
+ };
2483
+ if (inst._zod.def.params)
2484
+ _iss.params = inst._zod.def.params;
2485
+ payload.issues.push(issue(_iss));
2486
+ }
2487
+ }
2488
+ var _a;
2489
+ class $ZodRegistry {
2490
+ constructor() {
2491
+ this._map = /* @__PURE__ */ new WeakMap();
2492
+ this._idmap = /* @__PURE__ */ new Map();
2493
+ }
2494
+ add(schema, ..._meta) {
2495
+ const meta = _meta[0];
2496
+ this._map.set(schema, meta);
2497
+ if (meta && typeof meta === "object" && "id" in meta) {
2498
+ this._idmap.set(meta.id, schema);
2499
+ }
2500
+ return this;
2501
+ }
2502
+ clear() {
2503
+ this._map = /* @__PURE__ */ new WeakMap();
2504
+ this._idmap = /* @__PURE__ */ new Map();
2505
+ return this;
2506
+ }
2507
+ remove(schema) {
2508
+ const meta = this._map.get(schema);
2509
+ if (meta && typeof meta === "object" && "id" in meta) {
2510
+ this._idmap.delete(meta.id);
2511
+ }
2512
+ this._map.delete(schema);
2513
+ return this;
2514
+ }
2515
+ get(schema) {
2516
+ const p = schema._zod.parent;
2517
+ if (p) {
2518
+ const pm = { ...this.get(p) ?? {} };
2519
+ delete pm.id;
2520
+ const f = { ...pm, ...this._map.get(schema) };
2521
+ return Object.keys(f).length ? f : void 0;
2522
+ }
2523
+ return this._map.get(schema);
2524
+ }
2525
+ has(schema) {
2526
+ return this._map.has(schema);
2527
+ }
2528
+ }
2529
+ function registry() {
2530
+ return new $ZodRegistry();
2531
+ }
2532
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2533
+ const globalRegistry = globalThis.__zod_globalRegistry;
2534
+ // @__NO_SIDE_EFFECTS__
2535
+ function _string(Class, params) {
2536
+ return new Class({
2537
+ type: "string",
2538
+ ...normalizeParams(params)
2539
+ });
2540
+ }
2541
+ // @__NO_SIDE_EFFECTS__
2542
+ function _email(Class, params) {
2543
+ return new Class({
2544
+ type: "string",
2545
+ format: "email",
2546
+ check: "string_format",
2547
+ abort: false,
2548
+ ...normalizeParams(params)
2549
+ });
2550
+ }
2551
+ // @__NO_SIDE_EFFECTS__
2552
+ function _guid(Class, params) {
2553
+ return new Class({
2554
+ type: "string",
2555
+ format: "guid",
2556
+ check: "string_format",
2557
+ abort: false,
2558
+ ...normalizeParams(params)
2559
+ });
2560
+ }
2561
+ // @__NO_SIDE_EFFECTS__
2562
+ function _uuid(Class, params) {
2563
+ return new Class({
2564
+ type: "string",
2565
+ format: "uuid",
2566
+ check: "string_format",
2567
+ abort: false,
2568
+ ...normalizeParams(params)
2569
+ });
2570
+ }
2571
+ // @__NO_SIDE_EFFECTS__
2572
+ function _uuidv4(Class, params) {
2573
+ return new Class({
2574
+ type: "string",
2575
+ format: "uuid",
2576
+ check: "string_format",
2577
+ abort: false,
2578
+ version: "v4",
2579
+ ...normalizeParams(params)
2580
+ });
2581
+ }
2582
+ // @__NO_SIDE_EFFECTS__
2583
+ function _uuidv6(Class, params) {
2584
+ return new Class({
2585
+ type: "string",
2586
+ format: "uuid",
2587
+ check: "string_format",
2588
+ abort: false,
2589
+ version: "v6",
2590
+ ...normalizeParams(params)
2591
+ });
2592
+ }
2593
+ // @__NO_SIDE_EFFECTS__
2594
+ function _uuidv7(Class, params) {
2595
+ return new Class({
2596
+ type: "string",
2597
+ format: "uuid",
2598
+ check: "string_format",
2599
+ abort: false,
2600
+ version: "v7",
2601
+ ...normalizeParams(params)
2602
+ });
2603
+ }
2604
+ // @__NO_SIDE_EFFECTS__
2605
+ function _url(Class, params) {
2606
+ return new Class({
2607
+ type: "string",
2608
+ format: "url",
2609
+ check: "string_format",
2610
+ abort: false,
2611
+ ...normalizeParams(params)
2612
+ });
2613
+ }
2614
+ // @__NO_SIDE_EFFECTS__
2615
+ function _emoji(Class, params) {
2616
+ return new Class({
2617
+ type: "string",
2618
+ format: "emoji",
2619
+ check: "string_format",
2620
+ abort: false,
2621
+ ...normalizeParams(params)
2622
+ });
2623
+ }
2624
+ // @__NO_SIDE_EFFECTS__
2625
+ function _nanoid(Class, params) {
2626
+ return new Class({
2627
+ type: "string",
2628
+ format: "nanoid",
2629
+ check: "string_format",
2630
+ abort: false,
2631
+ ...normalizeParams(params)
2632
+ });
2633
+ }
2634
+ // @__NO_SIDE_EFFECTS__
2635
+ function _cuid(Class, params) {
2636
+ return new Class({
2637
+ type: "string",
2638
+ format: "cuid",
2639
+ check: "string_format",
2640
+ abort: false,
2641
+ ...normalizeParams(params)
2642
+ });
2643
+ }
2644
+ // @__NO_SIDE_EFFECTS__
2645
+ function _cuid2(Class, params) {
2646
+ return new Class({
2647
+ type: "string",
2648
+ format: "cuid2",
2649
+ check: "string_format",
2650
+ abort: false,
2651
+ ...normalizeParams(params)
2652
+ });
2653
+ }
2654
+ // @__NO_SIDE_EFFECTS__
2655
+ function _ulid(Class, params) {
2656
+ return new Class({
2657
+ type: "string",
2658
+ format: "ulid",
2659
+ check: "string_format",
2660
+ abort: false,
2661
+ ...normalizeParams(params)
2662
+ });
2663
+ }
2664
+ // @__NO_SIDE_EFFECTS__
2665
+ function _xid(Class, params) {
2666
+ return new Class({
2667
+ type: "string",
2668
+ format: "xid",
2669
+ check: "string_format",
2670
+ abort: false,
2671
+ ...normalizeParams(params)
2672
+ });
2673
+ }
2674
+ // @__NO_SIDE_EFFECTS__
2675
+ function _ksuid(Class, params) {
2676
+ return new Class({
2677
+ type: "string",
2678
+ format: "ksuid",
2679
+ check: "string_format",
2680
+ abort: false,
2681
+ ...normalizeParams(params)
2682
+ });
2683
+ }
2684
+ // @__NO_SIDE_EFFECTS__
2685
+ function _ipv4(Class, params) {
2686
+ return new Class({
2687
+ type: "string",
2688
+ format: "ipv4",
2689
+ check: "string_format",
2690
+ abort: false,
2691
+ ...normalizeParams(params)
2692
+ });
2693
+ }
2694
+ // @__NO_SIDE_EFFECTS__
2695
+ function _ipv6(Class, params) {
2696
+ return new Class({
2697
+ type: "string",
2698
+ format: "ipv6",
2699
+ check: "string_format",
2700
+ abort: false,
2701
+ ...normalizeParams(params)
2702
+ });
2703
+ }
2704
+ // @__NO_SIDE_EFFECTS__
2705
+ function _cidrv4(Class, params) {
2706
+ return new Class({
2707
+ type: "string",
2708
+ format: "cidrv4",
2709
+ check: "string_format",
2710
+ abort: false,
2711
+ ...normalizeParams(params)
2712
+ });
2713
+ }
2714
+ // @__NO_SIDE_EFFECTS__
2715
+ function _cidrv6(Class, params) {
2716
+ return new Class({
2717
+ type: "string",
2718
+ format: "cidrv6",
2719
+ check: "string_format",
2720
+ abort: false,
2721
+ ...normalizeParams(params)
2722
+ });
2723
+ }
2724
+ // @__NO_SIDE_EFFECTS__
2725
+ function _base64(Class, params) {
2726
+ return new Class({
2727
+ type: "string",
2728
+ format: "base64",
2729
+ check: "string_format",
2730
+ abort: false,
2731
+ ...normalizeParams(params)
2732
+ });
2733
+ }
2734
+ // @__NO_SIDE_EFFECTS__
2735
+ function _base64url(Class, params) {
2736
+ return new Class({
2737
+ type: "string",
2738
+ format: "base64url",
2739
+ check: "string_format",
2740
+ abort: false,
2741
+ ...normalizeParams(params)
2742
+ });
2743
+ }
2744
+ // @__NO_SIDE_EFFECTS__
2745
+ function _e164(Class, params) {
2746
+ return new Class({
2747
+ type: "string",
2748
+ format: "e164",
2749
+ check: "string_format",
2750
+ abort: false,
2751
+ ...normalizeParams(params)
2752
+ });
2753
+ }
2754
+ // @__NO_SIDE_EFFECTS__
2755
+ function _jwt(Class, params) {
2756
+ return new Class({
2757
+ type: "string",
2758
+ format: "jwt",
2759
+ check: "string_format",
2760
+ abort: false,
2761
+ ...normalizeParams(params)
2762
+ });
2763
+ }
2764
+ // @__NO_SIDE_EFFECTS__
2765
+ function _isoDateTime(Class, params) {
2766
+ return new Class({
2767
+ type: "string",
2768
+ format: "datetime",
2769
+ check: "string_format",
2770
+ offset: false,
2771
+ local: false,
2772
+ precision: null,
2773
+ ...normalizeParams(params)
2774
+ });
2775
+ }
2776
+ // @__NO_SIDE_EFFECTS__
2777
+ function _isoDate(Class, params) {
2778
+ return new Class({
2779
+ type: "string",
2780
+ format: "date",
2781
+ check: "string_format",
2782
+ ...normalizeParams(params)
2783
+ });
2784
+ }
2785
+ // @__NO_SIDE_EFFECTS__
2786
+ function _isoTime(Class, params) {
2787
+ return new Class({
2788
+ type: "string",
2789
+ format: "time",
2790
+ check: "string_format",
2791
+ precision: null,
2792
+ ...normalizeParams(params)
2793
+ });
2794
+ }
2795
+ // @__NO_SIDE_EFFECTS__
2796
+ function _isoDuration(Class, params) {
2797
+ return new Class({
2798
+ type: "string",
2799
+ format: "duration",
2800
+ check: "string_format",
2801
+ ...normalizeParams(params)
2802
+ });
2803
+ }
2804
+ // @__NO_SIDE_EFFECTS__
2805
+ function _number(Class, params) {
2806
+ return new Class({
2807
+ type: "number",
2808
+ checks: [],
2809
+ ...normalizeParams(params)
2810
+ });
2811
+ }
2812
+ // @__NO_SIDE_EFFECTS__
2813
+ function _coercedNumber(Class, params) {
2814
+ return new Class({
2815
+ type: "number",
2816
+ coerce: true,
2817
+ checks: [],
2818
+ ...normalizeParams(params)
2819
+ });
2820
+ }
2821
+ // @__NO_SIDE_EFFECTS__
2822
+ function _int(Class, params) {
2823
+ return new Class({
2824
+ type: "number",
2825
+ check: "number_format",
2826
+ abort: false,
2827
+ format: "safeint",
2828
+ ...normalizeParams(params)
2829
+ });
2830
+ }
2831
+ // @__NO_SIDE_EFFECTS__
2832
+ function _boolean(Class, params) {
2833
+ return new Class({
2834
+ type: "boolean",
2835
+ ...normalizeParams(params)
2836
+ });
2837
+ }
2838
+ // @__NO_SIDE_EFFECTS__
2839
+ function _null$1(Class, params) {
2840
+ return new Class({
2841
+ type: "null",
2842
+ ...normalizeParams(params)
2843
+ });
2844
+ }
2845
+ // @__NO_SIDE_EFFECTS__
2846
+ function _any(Class) {
2847
+ return new Class({
2848
+ type: "any"
2849
+ });
2850
+ }
2851
+ // @__NO_SIDE_EFFECTS__
2852
+ function _unknown(Class) {
2853
+ return new Class({
2854
+ type: "unknown"
2855
+ });
2856
+ }
2857
+ // @__NO_SIDE_EFFECTS__
2858
+ function _never(Class, params) {
2859
+ return new Class({
2860
+ type: "never",
2861
+ ...normalizeParams(params)
2862
+ });
2863
+ }
2864
+ // @__NO_SIDE_EFFECTS__
2865
+ function _lt(value, params) {
2866
+ return new $ZodCheckLessThan({
2867
+ check: "less_than",
2868
+ ...normalizeParams(params),
2869
+ value,
2870
+ inclusive: false
2871
+ });
2872
+ }
2873
+ // @__NO_SIDE_EFFECTS__
2874
+ function _lte(value, params) {
2875
+ return new $ZodCheckLessThan({
2876
+ check: "less_than",
2877
+ ...normalizeParams(params),
2878
+ value,
2879
+ inclusive: true
2880
+ });
2881
+ }
2882
+ // @__NO_SIDE_EFFECTS__
2883
+ function _gt(value, params) {
2884
+ return new $ZodCheckGreaterThan({
2885
+ check: "greater_than",
2886
+ ...normalizeParams(params),
2887
+ value,
2888
+ inclusive: false
2889
+ });
2890
+ }
2891
+ // @__NO_SIDE_EFFECTS__
2892
+ function _gte(value, params) {
2893
+ return new $ZodCheckGreaterThan({
2894
+ check: "greater_than",
2895
+ ...normalizeParams(params),
2896
+ value,
2897
+ inclusive: true
2898
+ });
2899
+ }
2900
+ // @__NO_SIDE_EFFECTS__
2901
+ function _multipleOf(value, params) {
2902
+ return new $ZodCheckMultipleOf({
2903
+ check: "multiple_of",
2904
+ ...normalizeParams(params),
2905
+ value
2906
+ });
2907
+ }
2908
+ // @__NO_SIDE_EFFECTS__
2909
+ function _maxLength(maximum, params) {
2910
+ const ch = new $ZodCheckMaxLength({
2911
+ check: "max_length",
2912
+ ...normalizeParams(params),
2913
+ maximum
2914
+ });
2915
+ return ch;
2916
+ }
2917
+ // @__NO_SIDE_EFFECTS__
2918
+ function _minLength(minimum, params) {
2919
+ return new $ZodCheckMinLength({
2920
+ check: "min_length",
2921
+ ...normalizeParams(params),
2922
+ minimum
2923
+ });
2924
+ }
2925
+ // @__NO_SIDE_EFFECTS__
2926
+ function _length(length, params) {
2927
+ return new $ZodCheckLengthEquals({
2928
+ check: "length_equals",
2929
+ ...normalizeParams(params),
2930
+ length
2931
+ });
2932
+ }
2933
+ // @__NO_SIDE_EFFECTS__
2934
+ function _regex(pattern, params) {
2935
+ return new $ZodCheckRegex({
2936
+ check: "string_format",
2937
+ format: "regex",
2938
+ ...normalizeParams(params),
2939
+ pattern
2940
+ });
2941
+ }
2942
+ // @__NO_SIDE_EFFECTS__
2943
+ function _lowercase(params) {
2944
+ return new $ZodCheckLowerCase({
2945
+ check: "string_format",
2946
+ format: "lowercase",
2947
+ ...normalizeParams(params)
2948
+ });
2949
+ }
2950
+ // @__NO_SIDE_EFFECTS__
2951
+ function _uppercase(params) {
2952
+ return new $ZodCheckUpperCase({
2953
+ check: "string_format",
2954
+ format: "uppercase",
2955
+ ...normalizeParams(params)
2956
+ });
2957
+ }
2958
+ // @__NO_SIDE_EFFECTS__
2959
+ function _includes(includes, params) {
2960
+ return new $ZodCheckIncludes({
2961
+ check: "string_format",
2962
+ format: "includes",
2963
+ ...normalizeParams(params),
2964
+ includes
2965
+ });
2966
+ }
2967
+ // @__NO_SIDE_EFFECTS__
2968
+ function _startsWith(prefix, params) {
2969
+ return new $ZodCheckStartsWith({
2970
+ check: "string_format",
2971
+ format: "starts_with",
2972
+ ...normalizeParams(params),
2973
+ prefix
2974
+ });
2975
+ }
2976
+ // @__NO_SIDE_EFFECTS__
2977
+ function _endsWith(suffix, params) {
2978
+ return new $ZodCheckEndsWith({
2979
+ check: "string_format",
2980
+ format: "ends_with",
2981
+ ...normalizeParams(params),
2982
+ suffix
2983
+ });
2984
+ }
2985
+ // @__NO_SIDE_EFFECTS__
2986
+ function _overwrite(tx) {
2987
+ return new $ZodCheckOverwrite({
2988
+ check: "overwrite",
2989
+ tx
2990
+ });
2991
+ }
2992
+ // @__NO_SIDE_EFFECTS__
2993
+ function _normalize(form) {
2994
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2995
+ }
2996
+ // @__NO_SIDE_EFFECTS__
2997
+ function _trim() {
2998
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
2999
+ }
3000
+ // @__NO_SIDE_EFFECTS__
3001
+ function _toLowerCase() {
3002
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
3003
+ }
3004
+ // @__NO_SIDE_EFFECTS__
3005
+ function _toUpperCase() {
3006
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
3007
+ }
3008
+ // @__NO_SIDE_EFFECTS__
3009
+ function _slugify() {
3010
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
3011
+ }
3012
+ // @__NO_SIDE_EFFECTS__
3013
+ function _array(Class, element, params) {
3014
+ return new Class({
3015
+ type: "array",
3016
+ element,
3017
+ // get element() {
3018
+ // return element;
3019
+ // },
3020
+ ...normalizeParams(params)
3021
+ });
3022
+ }
3023
+ // @__NO_SIDE_EFFECTS__
3024
+ function _refine(Class, fn, _params) {
3025
+ const schema = new Class({
3026
+ type: "custom",
3027
+ check: "custom",
3028
+ fn,
3029
+ ...normalizeParams(_params)
3030
+ });
3031
+ return schema;
3032
+ }
3033
+ // @__NO_SIDE_EFFECTS__
3034
+ function _superRefine(fn) {
3035
+ const ch = /* @__PURE__ */ _check((payload) => {
3036
+ payload.addIssue = (issue$1) => {
3037
+ if (typeof issue$1 === "string") {
3038
+ payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
3039
+ } else {
3040
+ const _issue = issue$1;
3041
+ if (_issue.fatal)
3042
+ _issue.continue = false;
3043
+ _issue.code ?? (_issue.code = "custom");
3044
+ _issue.input ?? (_issue.input = payload.value);
3045
+ _issue.inst ?? (_issue.inst = ch);
3046
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
3047
+ payload.issues.push(issue(_issue));
3048
+ }
3049
+ };
3050
+ return fn(payload.value, payload);
3051
+ });
3052
+ return ch;
3053
+ }
3054
+ // @__NO_SIDE_EFFECTS__
3055
+ function _check(fn, params) {
3056
+ const ch = new $ZodCheck({
3057
+ check: "custom",
3058
+ ...normalizeParams(params)
3059
+ });
3060
+ ch._zod.check = fn;
3061
+ return ch;
3062
+ }
3063
+ function initializeContext(params) {
3064
+ let target = params?.target ?? "draft-2020-12";
3065
+ if (target === "draft-4")
3066
+ target = "draft-04";
3067
+ if (target === "draft-7")
3068
+ target = "draft-07";
3069
+ return {
3070
+ processors: params.processors ?? {},
3071
+ metadataRegistry: params?.metadata ?? globalRegistry,
3072
+ target,
3073
+ unrepresentable: params?.unrepresentable ?? "throw",
3074
+ override: params?.override ?? (() => {
3075
+ }),
3076
+ io: params?.io ?? "output",
3077
+ counter: 0,
3078
+ seen: /* @__PURE__ */ new Map(),
3079
+ cycles: params?.cycles ?? "ref",
3080
+ reused: params?.reused ?? "inline",
3081
+ external: params?.external ?? void 0
3082
+ };
3083
+ }
3084
+ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
3085
+ var _a2;
3086
+ const def = schema._zod.def;
3087
+ const seen = ctx.seen.get(schema);
3088
+ if (seen) {
3089
+ seen.count++;
3090
+ const isCycle = _params.schemaPath.includes(schema);
3091
+ if (isCycle) {
3092
+ seen.cycle = _params.path;
3093
+ }
3094
+ return seen.schema;
3095
+ }
3096
+ const result = { schema: {}, count: 1, cycle: void 0, path: _params.path };
3097
+ ctx.seen.set(schema, result);
3098
+ const overrideSchema = schema._zod.toJSONSchema?.();
3099
+ if (overrideSchema) {
3100
+ result.schema = overrideSchema;
3101
+ } else {
3102
+ const params = {
3103
+ ..._params,
3104
+ schemaPath: [..._params.schemaPath, schema],
3105
+ path: _params.path
3106
+ };
3107
+ if (schema._zod.processJSONSchema) {
3108
+ schema._zod.processJSONSchema(ctx, result.schema, params);
3109
+ } else {
3110
+ const _json = result.schema;
3111
+ const processor = ctx.processors[def.type];
3112
+ if (!processor) {
3113
+ throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3114
+ }
3115
+ processor(schema, ctx, _json, params);
3116
+ }
3117
+ const parent = schema._zod.parent;
3118
+ if (parent) {
3119
+ if (!result.ref)
3120
+ result.ref = parent;
3121
+ process(parent, ctx, params);
3122
+ ctx.seen.get(parent).isParent = true;
3123
+ }
3124
+ }
3125
+ const meta = ctx.metadataRegistry.get(schema);
3126
+ if (meta)
3127
+ Object.assign(result.schema, meta);
3128
+ if (ctx.io === "input" && isTransforming(schema)) {
3129
+ delete result.schema.examples;
3130
+ delete result.schema.default;
3131
+ }
3132
+ if (ctx.io === "input" && result.schema._prefault)
3133
+ (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
3134
+ delete result.schema._prefault;
3135
+ const _result = ctx.seen.get(schema);
3136
+ return _result.schema;
3137
+ }
3138
+ function extractDefs(ctx, schema) {
3139
+ const root = ctx.seen.get(schema);
3140
+ if (!root)
3141
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3142
+ const idToSchema = /* @__PURE__ */ new Map();
3143
+ for (const entry of ctx.seen.entries()) {
3144
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3145
+ if (id) {
3146
+ const existing = idToSchema.get(id);
3147
+ if (existing && existing !== entry[0]) {
3148
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3149
+ }
3150
+ idToSchema.set(id, entry[0]);
3151
+ }
3152
+ }
3153
+ const makeURI = (entry) => {
3154
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3155
+ if (ctx.external) {
3156
+ const externalId = ctx.external.registry.get(entry[0])?.id;
3157
+ const uriGenerator = ctx.external.uri ?? ((id2) => id2);
3158
+ if (externalId) {
3159
+ return { ref: uriGenerator(externalId) };
3160
+ }
3161
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3162
+ entry[1].defId = id;
3163
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3164
+ }
3165
+ if (entry[1] === root) {
3166
+ return { ref: "#" };
3167
+ }
3168
+ const uriPrefix = `#`;
3169
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3170
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3171
+ return { defId, ref: defUriPrefix + defId };
3172
+ };
3173
+ const extractToDef = (entry) => {
3174
+ if (entry[1].schema.$ref) {
3175
+ return;
3176
+ }
3177
+ const seen = entry[1];
3178
+ const { ref, defId } = makeURI(entry);
3179
+ seen.def = { ...seen.schema };
3180
+ if (defId)
3181
+ seen.defId = defId;
3182
+ const schema2 = seen.schema;
3183
+ for (const key in schema2) {
3184
+ delete schema2[key];
3185
+ }
3186
+ schema2.$ref = ref;
3187
+ };
3188
+ if (ctx.cycles === "throw") {
3189
+ for (const entry of ctx.seen.entries()) {
3190
+ const seen = entry[1];
3191
+ if (seen.cycle) {
3192
+ throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
3193
+
3194
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
3195
+ }
3196
+ }
3197
+ }
3198
+ for (const entry of ctx.seen.entries()) {
3199
+ const seen = entry[1];
3200
+ if (schema === entry[0]) {
3201
+ extractToDef(entry);
3202
+ continue;
3203
+ }
3204
+ if (ctx.external) {
3205
+ const ext = ctx.external.registry.get(entry[0])?.id;
3206
+ if (schema !== entry[0] && ext) {
3207
+ extractToDef(entry);
3208
+ continue;
3209
+ }
3210
+ }
3211
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3212
+ if (id) {
3213
+ extractToDef(entry);
3214
+ continue;
3215
+ }
3216
+ if (seen.cycle) {
3217
+ extractToDef(entry);
3218
+ continue;
3219
+ }
3220
+ if (seen.count > 1) {
3221
+ if (ctx.reused === "ref") {
3222
+ extractToDef(entry);
3223
+ continue;
3224
+ }
3225
+ }
3226
+ }
3227
+ }
3228
+ function finalize(ctx, schema) {
3229
+ const root = ctx.seen.get(schema);
3230
+ if (!root)
3231
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3232
+ const flattenRef = (zodSchema) => {
3233
+ const seen = ctx.seen.get(zodSchema);
3234
+ if (seen.ref === null)
3235
+ return;
3236
+ const schema2 = seen.def ?? seen.schema;
3237
+ const _cached = { ...schema2 };
3238
+ const ref = seen.ref;
3239
+ seen.ref = null;
3240
+ if (ref) {
3241
+ flattenRef(ref);
3242
+ const refSeen = ctx.seen.get(ref);
3243
+ const refSchema = refSeen.schema;
3244
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3245
+ schema2.allOf = schema2.allOf ?? [];
3246
+ schema2.allOf.push(refSchema);
3247
+ } else {
3248
+ Object.assign(schema2, refSchema);
3249
+ }
3250
+ Object.assign(schema2, _cached);
3251
+ const isParentRef = zodSchema._zod.parent === ref;
3252
+ if (isParentRef) {
3253
+ for (const key in schema2) {
3254
+ if (key === "$ref" || key === "allOf")
3255
+ continue;
3256
+ if (!(key in _cached)) {
3257
+ delete schema2[key];
3258
+ }
3259
+ }
3260
+ }
3261
+ if (refSchema.$ref && refSeen.def) {
3262
+ for (const key in schema2) {
3263
+ if (key === "$ref" || key === "allOf")
3264
+ continue;
3265
+ if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
3266
+ delete schema2[key];
3267
+ }
3268
+ }
3269
+ }
3270
+ }
3271
+ const parent = zodSchema._zod.parent;
3272
+ if (parent && parent !== ref) {
3273
+ flattenRef(parent);
3274
+ const parentSeen = ctx.seen.get(parent);
3275
+ if (parentSeen?.schema.$ref) {
3276
+ schema2.$ref = parentSeen.schema.$ref;
3277
+ if (parentSeen.def) {
3278
+ for (const key in schema2) {
3279
+ if (key === "$ref" || key === "allOf")
3280
+ continue;
3281
+ if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
3282
+ delete schema2[key];
3283
+ }
3284
+ }
3285
+ }
3286
+ }
3287
+ }
3288
+ ctx.override({
3289
+ zodSchema,
3290
+ jsonSchema: schema2,
3291
+ path: seen.path ?? []
3292
+ });
3293
+ };
3294
+ for (const entry of [...ctx.seen.entries()].reverse()) {
3295
+ flattenRef(entry[0]);
3296
+ }
3297
+ const result = {};
3298
+ if (ctx.target === "draft-2020-12") {
3299
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
3300
+ } else if (ctx.target === "draft-07") {
3301
+ result.$schema = "http://json-schema.org/draft-07/schema#";
3302
+ } else if (ctx.target === "draft-04") {
3303
+ result.$schema = "http://json-schema.org/draft-04/schema#";
3304
+ } else if (ctx.target === "openapi-3.0") ;
3305
+ else ;
3306
+ if (ctx.external?.uri) {
3307
+ const id = ctx.external.registry.get(schema)?.id;
3308
+ if (!id)
3309
+ throw new Error("Schema is missing an `id` property");
3310
+ result.$id = ctx.external.uri(id);
3311
+ }
3312
+ Object.assign(result, root.def ?? root.schema);
3313
+ const defs = ctx.external?.defs ?? {};
3314
+ for (const entry of ctx.seen.entries()) {
3315
+ const seen = entry[1];
3316
+ if (seen.def && seen.defId) {
3317
+ defs[seen.defId] = seen.def;
3318
+ }
3319
+ }
3320
+ if (ctx.external) ;
3321
+ else {
3322
+ if (Object.keys(defs).length > 0) {
3323
+ if (ctx.target === "draft-2020-12") {
3324
+ result.$defs = defs;
3325
+ } else {
3326
+ result.definitions = defs;
3327
+ }
3328
+ }
3329
+ }
3330
+ try {
3331
+ const finalized = JSON.parse(JSON.stringify(result));
3332
+ Object.defineProperty(finalized, "~standard", {
3333
+ value: {
3334
+ ...schema["~standard"],
3335
+ jsonSchema: {
3336
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3337
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3338
+ }
3339
+ },
3340
+ enumerable: false,
3341
+ writable: false
3342
+ });
3343
+ return finalized;
3344
+ } catch (_err) {
3345
+ throw new Error("Error converting schema to JSON.");
3346
+ }
3347
+ }
3348
+ function isTransforming(_schema, _ctx) {
3349
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3350
+ if (ctx.seen.has(_schema))
3351
+ return false;
3352
+ ctx.seen.add(_schema);
3353
+ const def = _schema._zod.def;
3354
+ if (def.type === "transform")
3355
+ return true;
3356
+ if (def.type === "array")
3357
+ return isTransforming(def.element, ctx);
3358
+ if (def.type === "set")
3359
+ return isTransforming(def.valueType, ctx);
3360
+ if (def.type === "lazy")
3361
+ return isTransforming(def.getter(), ctx);
3362
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") {
3363
+ return isTransforming(def.innerType, ctx);
3364
+ }
3365
+ if (def.type === "intersection") {
3366
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3367
+ }
3368
+ if (def.type === "record" || def.type === "map") {
3369
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3370
+ }
3371
+ if (def.type === "pipe") {
3372
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3373
+ }
3374
+ if (def.type === "object") {
3375
+ for (const key in def.shape) {
3376
+ if (isTransforming(def.shape[key], ctx))
3377
+ return true;
3378
+ }
3379
+ return false;
3380
+ }
3381
+ if (def.type === "union") {
3382
+ for (const option of def.options) {
3383
+ if (isTransforming(option, ctx))
3384
+ return true;
3385
+ }
3386
+ return false;
3387
+ }
3388
+ if (def.type === "tuple") {
3389
+ for (const item of def.items) {
3390
+ if (isTransforming(item, ctx))
3391
+ return true;
3392
+ }
3393
+ if (def.rest && isTransforming(def.rest, ctx))
3394
+ return true;
3395
+ return false;
3396
+ }
3397
+ return false;
3398
+ }
3399
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3400
+ const ctx = initializeContext({ ...params, processors });
3401
+ process(schema, ctx);
3402
+ extractDefs(ctx, schema);
3403
+ return finalize(ctx, schema);
3404
+ };
3405
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3406
+ const { libraryOptions, target } = params ?? {};
3407
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
3408
+ process(schema, ctx);
3409
+ extractDefs(ctx, schema);
3410
+ return finalize(ctx, schema);
3411
+ };
3412
+ const formatMap = {
3413
+ guid: "uuid",
3414
+ url: "uri",
3415
+ datetime: "date-time",
3416
+ json_string: "json-string",
3417
+ regex: ""
3418
+ // do not set
3419
+ };
3420
+ const stringProcessor = (schema, ctx, _json, _params) => {
3421
+ const json = _json;
3422
+ json.type = "string";
3423
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3424
+ if (typeof minimum === "number")
3425
+ json.minLength = minimum;
3426
+ if (typeof maximum === "number")
3427
+ json.maxLength = maximum;
3428
+ if (format) {
3429
+ json.format = formatMap[format] ?? format;
3430
+ if (json.format === "")
3431
+ delete json.format;
3432
+ if (format === "time") {
3433
+ delete json.format;
3434
+ }
3435
+ }
3436
+ if (contentEncoding)
3437
+ json.contentEncoding = contentEncoding;
3438
+ if (patterns && patterns.size > 0) {
3439
+ const regexes = [...patterns];
3440
+ if (regexes.length === 1)
3441
+ json.pattern = regexes[0].source;
3442
+ else if (regexes.length > 1) {
3443
+ json.allOf = [
3444
+ ...regexes.map((regex) => ({
3445
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3446
+ pattern: regex.source
3447
+ }))
3448
+ ];
3449
+ }
3450
+ }
3451
+ };
3452
+ const numberProcessor = (schema, ctx, _json, _params) => {
3453
+ const json = _json;
3454
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3455
+ if (typeof format === "string" && format.includes("int"))
3456
+ json.type = "integer";
3457
+ else
3458
+ json.type = "number";
3459
+ if (typeof exclusiveMinimum === "number") {
3460
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3461
+ json.minimum = exclusiveMinimum;
3462
+ json.exclusiveMinimum = true;
3463
+ } else {
3464
+ json.exclusiveMinimum = exclusiveMinimum;
3465
+ }
3466
+ }
3467
+ if (typeof minimum === "number") {
3468
+ json.minimum = minimum;
3469
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
3470
+ if (exclusiveMinimum >= minimum)
3471
+ delete json.minimum;
3472
+ else
3473
+ delete json.exclusiveMinimum;
3474
+ }
3475
+ }
3476
+ if (typeof exclusiveMaximum === "number") {
3477
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3478
+ json.maximum = exclusiveMaximum;
3479
+ json.exclusiveMaximum = true;
3480
+ } else {
3481
+ json.exclusiveMaximum = exclusiveMaximum;
3482
+ }
3483
+ }
3484
+ if (typeof maximum === "number") {
3485
+ json.maximum = maximum;
3486
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
3487
+ if (exclusiveMaximum <= maximum)
3488
+ delete json.maximum;
3489
+ else
3490
+ delete json.exclusiveMaximum;
3491
+ }
3492
+ }
3493
+ if (typeof multipleOf === "number")
3494
+ json.multipleOf = multipleOf;
3495
+ };
3496
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
3497
+ json.type = "boolean";
3498
+ };
3499
+ const nullProcessor = (_schema, ctx, json, _params) => {
3500
+ if (ctx.target === "openapi-3.0") {
3501
+ json.type = "string";
3502
+ json.nullable = true;
3503
+ json.enum = [null];
3504
+ } else {
3505
+ json.type = "null";
3506
+ }
3507
+ };
3508
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3509
+ json.not = {};
3510
+ };
3511
+ const anyProcessor = (_schema, _ctx, _json, _params) => {
3512
+ };
3513
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {
3514
+ };
3515
+ const enumProcessor = (schema, _ctx, json, _params) => {
3516
+ const def = schema._zod.def;
3517
+ const values = getEnumValues(def.entries);
3518
+ if (values.every((v) => typeof v === "number"))
3519
+ json.type = "number";
3520
+ if (values.every((v) => typeof v === "string"))
3521
+ json.type = "string";
3522
+ json.enum = values;
3523
+ };
3524
+ const literalProcessor = (schema, ctx, json, _params) => {
3525
+ const def = schema._zod.def;
3526
+ const vals = [];
3527
+ for (const val of def.values) {
3528
+ if (val === void 0) {
3529
+ if (ctx.unrepresentable === "throw") {
3530
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3531
+ }
3532
+ } else if (typeof val === "bigint") {
3533
+ if (ctx.unrepresentable === "throw") {
3534
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
3535
+ } else {
3536
+ vals.push(Number(val));
3537
+ }
3538
+ } else {
3539
+ vals.push(val);
3540
+ }
3541
+ }
3542
+ if (vals.length === 0) ;
3543
+ else if (vals.length === 1) {
3544
+ const val = vals[0];
3545
+ json.type = val === null ? "null" : typeof val;
3546
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3547
+ json.enum = [val];
3548
+ } else {
3549
+ json.const = val;
3550
+ }
3551
+ } else {
3552
+ if (vals.every((v) => typeof v === "number"))
3553
+ json.type = "number";
3554
+ if (vals.every((v) => typeof v === "string"))
3555
+ json.type = "string";
3556
+ if (vals.every((v) => typeof v === "boolean"))
3557
+ json.type = "boolean";
3558
+ if (vals.every((v) => v === null))
3559
+ json.type = "null";
3560
+ json.enum = vals;
3561
+ }
3562
+ };
3563
+ const customProcessor = (_schema, ctx, _json, _params) => {
3564
+ if (ctx.unrepresentable === "throw") {
3565
+ throw new Error("Custom types cannot be represented in JSON Schema");
3566
+ }
3567
+ };
3568
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3569
+ if (ctx.unrepresentable === "throw") {
3570
+ throw new Error("Transforms cannot be represented in JSON Schema");
3571
+ }
3572
+ };
3573
+ const arrayProcessor = (schema, ctx, _json, params) => {
3574
+ const json = _json;
3575
+ const def = schema._zod.def;
3576
+ const { minimum, maximum } = schema._zod.bag;
3577
+ if (typeof minimum === "number")
3578
+ json.minItems = minimum;
3579
+ if (typeof maximum === "number")
3580
+ json.maxItems = maximum;
3581
+ json.type = "array";
3582
+ json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
3583
+ };
3584
+ const objectProcessor = (schema, ctx, _json, params) => {
3585
+ const json = _json;
3586
+ const def = schema._zod.def;
3587
+ json.type = "object";
3588
+ json.properties = {};
3589
+ const shape = def.shape;
3590
+ for (const key in shape) {
3591
+ json.properties[key] = process(shape[key], ctx, {
3592
+ ...params,
3593
+ path: [...params.path, "properties", key]
3594
+ });
3595
+ }
3596
+ const allKeys = new Set(Object.keys(shape));
3597
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3598
+ const v = def.shape[key]._zod;
3599
+ if (ctx.io === "input") {
3600
+ return v.optin === void 0;
3601
+ } else {
3602
+ return v.optout === void 0;
3603
+ }
3604
+ }));
3605
+ if (requiredKeys.size > 0) {
3606
+ json.required = Array.from(requiredKeys);
3607
+ }
3608
+ if (def.catchall?._zod.def.type === "never") {
3609
+ json.additionalProperties = false;
3610
+ } else if (!def.catchall) {
3611
+ if (ctx.io === "output")
3612
+ json.additionalProperties = false;
3613
+ } else if (def.catchall) {
3614
+ json.additionalProperties = process(def.catchall, ctx, {
3615
+ ...params,
3616
+ path: [...params.path, "additionalProperties"]
3617
+ });
3618
+ }
3619
+ };
3620
+ const unionProcessor = (schema, ctx, json, params) => {
3621
+ const def = schema._zod.def;
3622
+ const isExclusive = def.inclusive === false;
3623
+ const options = def.options.map((x, i) => process(x, ctx, {
3624
+ ...params,
3625
+ path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
3626
+ }));
3627
+ if (isExclusive) {
3628
+ json.oneOf = options;
3629
+ } else {
3630
+ json.anyOf = options;
3631
+ }
3632
+ };
3633
+ const intersectionProcessor = (schema, ctx, json, params) => {
3634
+ const def = schema._zod.def;
3635
+ const a = process(def.left, ctx, {
3636
+ ...params,
3637
+ path: [...params.path, "allOf", 0]
3638
+ });
3639
+ const b = process(def.right, ctx, {
3640
+ ...params,
3641
+ path: [...params.path, "allOf", 1]
3642
+ });
3643
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3644
+ const allOf = [
3645
+ ...isSimpleIntersection(a) ? a.allOf : [a],
3646
+ ...isSimpleIntersection(b) ? b.allOf : [b]
3647
+ ];
3648
+ json.allOf = allOf;
3649
+ };
3650
+ const recordProcessor = (schema, ctx, _json, params) => {
3651
+ const json = _json;
3652
+ const def = schema._zod.def;
3653
+ json.type = "object";
3654
+ const keyType = def.keyType;
3655
+ const keyBag = keyType._zod.bag;
3656
+ const patterns = keyBag?.patterns;
3657
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
3658
+ const valueSchema = process(def.valueType, ctx, {
3659
+ ...params,
3660
+ path: [...params.path, "patternProperties", "*"]
3661
+ });
3662
+ json.patternProperties = {};
3663
+ for (const pattern of patterns) {
3664
+ json.patternProperties[pattern.source] = valueSchema;
3665
+ }
3666
+ } else {
3667
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
3668
+ json.propertyNames = process(def.keyType, ctx, {
3669
+ ...params,
3670
+ path: [...params.path, "propertyNames"]
3671
+ });
3672
+ }
3673
+ json.additionalProperties = process(def.valueType, ctx, {
3674
+ ...params,
3675
+ path: [...params.path, "additionalProperties"]
3676
+ });
3677
+ }
3678
+ const keyValues = keyType._zod.values;
3679
+ if (keyValues) {
3680
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3681
+ if (validKeyValues.length > 0) {
3682
+ json.required = validKeyValues;
3683
+ }
3684
+ }
3685
+ };
3686
+ const nullableProcessor = (schema, ctx, json, params) => {
3687
+ const def = schema._zod.def;
3688
+ const inner = process(def.innerType, ctx, params);
3689
+ const seen = ctx.seen.get(schema);
3690
+ if (ctx.target === "openapi-3.0") {
3691
+ seen.ref = def.innerType;
3692
+ json.nullable = true;
3693
+ } else {
3694
+ json.anyOf = [inner, { type: "null" }];
3695
+ }
3696
+ };
3697
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3698
+ const def = schema._zod.def;
3699
+ process(def.innerType, ctx, params);
3700
+ const seen = ctx.seen.get(schema);
3701
+ seen.ref = def.innerType;
3702
+ };
3703
+ const defaultProcessor = (schema, ctx, json, params) => {
3704
+ const def = schema._zod.def;
3705
+ process(def.innerType, ctx, params);
3706
+ const seen = ctx.seen.get(schema);
3707
+ seen.ref = def.innerType;
3708
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3709
+ };
3710
+ const prefaultProcessor = (schema, ctx, json, params) => {
3711
+ const def = schema._zod.def;
3712
+ process(def.innerType, ctx, params);
3713
+ const seen = ctx.seen.get(schema);
3714
+ seen.ref = def.innerType;
3715
+ if (ctx.io === "input")
3716
+ json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3717
+ };
3718
+ const catchProcessor = (schema, ctx, json, params) => {
3719
+ const def = schema._zod.def;
3720
+ process(def.innerType, ctx, params);
3721
+ const seen = ctx.seen.get(schema);
3722
+ seen.ref = def.innerType;
3723
+ let catchValue;
3724
+ try {
3725
+ catchValue = def.catchValue(void 0);
3726
+ } catch {
3727
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3728
+ }
3729
+ json.default = catchValue;
3730
+ };
3731
+ const pipeProcessor = (schema, ctx, _json, params) => {
3732
+ const def = schema._zod.def;
3733
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3734
+ process(innerType, ctx, params);
3735
+ const seen = ctx.seen.get(schema);
3736
+ seen.ref = innerType;
3737
+ };
3738
+ const readonlyProcessor = (schema, ctx, json, params) => {
3739
+ const def = schema._zod.def;
3740
+ process(def.innerType, ctx, params);
3741
+ const seen = ctx.seen.get(schema);
3742
+ seen.ref = def.innerType;
3743
+ json.readOnly = true;
3744
+ };
3745
+ const optionalProcessor = (schema, ctx, _json, params) => {
3746
+ const def = schema._zod.def;
3747
+ process(def.innerType, ctx, params);
3748
+ const seen = ctx.seen.get(schema);
3749
+ seen.ref = def.innerType;
3750
+ };
3751
+ const lazyProcessor = (schema, ctx, _json, params) => {
3752
+ const innerType = schema._zod.innerType;
3753
+ process(innerType, ctx, params);
3754
+ const seen = ctx.seen.get(schema);
3755
+ seen.ref = innerType;
3756
+ };
3757
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3758
+ $ZodISODateTime.init(inst, def);
3759
+ ZodStringFormat.init(inst, def);
3760
+ });
3761
+ function datetime(params) {
3762
+ return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3763
+ }
3764
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
3765
+ $ZodISODate.init(inst, def);
3766
+ ZodStringFormat.init(inst, def);
3767
+ });
3768
+ function date(params) {
3769
+ return /* @__PURE__ */ _isoDate(ZodISODate, params);
3770
+ }
3771
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
3772
+ $ZodISOTime.init(inst, def);
3773
+ ZodStringFormat.init(inst, def);
3774
+ });
3775
+ function time(params) {
3776
+ return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3777
+ }
3778
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
3779
+ $ZodISODuration.init(inst, def);
3780
+ ZodStringFormat.init(inst, def);
3781
+ });
3782
+ function duration(params) {
3783
+ return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3784
+ }
3785
+ const initializer = (inst, issues) => {
3786
+ $ZodError.init(inst, issues);
3787
+ inst.name = "ZodError";
3788
+ Object.defineProperties(inst, {
3789
+ format: {
3790
+ value: (mapper) => formatError(inst, mapper)
3791
+ // enumerable: false,
3792
+ },
3793
+ flatten: {
3794
+ value: (mapper) => flattenError(inst, mapper)
3795
+ // enumerable: false,
3796
+ },
3797
+ addIssue: {
3798
+ value: (issue2) => {
3799
+ inst.issues.push(issue2);
3800
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3801
+ }
3802
+ // enumerable: false,
3803
+ },
3804
+ addIssues: {
3805
+ value: (issues2) => {
3806
+ inst.issues.push(...issues2);
3807
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3808
+ }
3809
+ // enumerable: false,
3810
+ },
3811
+ isEmpty: {
3812
+ get() {
3813
+ return inst.issues.length === 0;
3814
+ }
3815
+ // enumerable: false,
3816
+ }
3817
+ });
3818
+ };
3819
+ const ZodRealError = $constructor("ZodError", initializer, {
3820
+ Parent: Error
3821
+ });
3822
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3823
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3824
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3825
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3826
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3827
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3828
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3829
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3830
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3831
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3832
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3833
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3834
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3835
+ $ZodType.init(inst, def);
3836
+ Object.assign(inst["~standard"], {
3837
+ jsonSchema: {
3838
+ input: createStandardJSONSchemaMethod(inst, "input"),
3839
+ output: createStandardJSONSchemaMethod(inst, "output")
3840
+ }
3841
+ });
3842
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3843
+ inst.def = def;
3844
+ inst.type = def.type;
3845
+ Object.defineProperty(inst, "_def", { value: def });
3846
+ inst.check = (...checks) => {
3847
+ return inst.clone(mergeDefs(def, {
3848
+ checks: [
3849
+ ...def.checks ?? [],
3850
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3851
+ ]
3852
+ }), {
3853
+ parent: true
3854
+ });
3855
+ };
3856
+ inst.with = inst.check;
3857
+ inst.clone = (def2, params) => clone(inst, def2, params);
3858
+ inst.brand = () => inst;
3859
+ inst.register = ((reg, meta) => {
3860
+ reg.add(inst, meta);
3861
+ return inst;
3862
+ });
3863
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3864
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3865
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3866
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3867
+ inst.spa = inst.safeParseAsync;
3868
+ inst.encode = (data, params) => encode(inst, data, params);
3869
+ inst.decode = (data, params) => decode(inst, data, params);
3870
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3871
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3872
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3873
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3874
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3875
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3876
+ inst.refine = (check, params) => inst.check(refine(check, params));
3877
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3878
+ inst.overwrite = (fn) => inst.check(/* @__PURE__ */ _overwrite(fn));
3879
+ inst.optional = () => optional(inst);
3880
+ inst.exactOptional = () => exactOptional(inst);
3881
+ inst.nullable = () => nullable(inst);
3882
+ inst.nullish = () => optional(nullable(inst));
3883
+ inst.nonoptional = (params) => nonoptional(inst, params);
3884
+ inst.array = () => array(inst);
3885
+ inst.or = (arg) => union([inst, arg]);
3886
+ inst.and = (arg) => intersection(inst, arg);
3887
+ inst.transform = (tx) => pipe(inst, transform(tx));
3888
+ inst.default = (def2) => _default(inst, def2);
3889
+ inst.prefault = (def2) => prefault(inst, def2);
3890
+ inst.catch = (params) => _catch(inst, params);
3891
+ inst.pipe = (target) => pipe(inst, target);
3892
+ inst.readonly = () => readonly(inst);
3893
+ inst.describe = (description) => {
3894
+ const cl = inst.clone();
3895
+ globalRegistry.add(cl, { description });
3896
+ return cl;
3897
+ };
3898
+ Object.defineProperty(inst, "description", {
3899
+ get() {
3900
+ return globalRegistry.get(inst)?.description;
3901
+ },
3902
+ configurable: true
3903
+ });
3904
+ inst.meta = (...args) => {
3905
+ if (args.length === 0) {
3906
+ return globalRegistry.get(inst);
3907
+ }
3908
+ const cl = inst.clone();
3909
+ globalRegistry.add(cl, args[0]);
3910
+ return cl;
3911
+ };
3912
+ inst.isOptional = () => inst.safeParse(void 0).success;
3913
+ inst.isNullable = () => inst.safeParse(null).success;
3914
+ inst.apply = (fn) => fn(inst);
3915
+ return inst;
3916
+ });
3917
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3918
+ $ZodString.init(inst, def);
3919
+ ZodType.init(inst, def);
3920
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
3921
+ const bag = inst._zod.bag;
3922
+ inst.format = bag.format ?? null;
3923
+ inst.minLength = bag.minimum ?? null;
3924
+ inst.maxLength = bag.maximum ?? null;
3925
+ inst.regex = (...args) => inst.check(/* @__PURE__ */ _regex(...args));
3926
+ inst.includes = (...args) => inst.check(/* @__PURE__ */ _includes(...args));
3927
+ inst.startsWith = (...args) => inst.check(/* @__PURE__ */ _startsWith(...args));
3928
+ inst.endsWith = (...args) => inst.check(/* @__PURE__ */ _endsWith(...args));
3929
+ inst.min = (...args) => inst.check(/* @__PURE__ */ _minLength(...args));
3930
+ inst.max = (...args) => inst.check(/* @__PURE__ */ _maxLength(...args));
3931
+ inst.length = (...args) => inst.check(/* @__PURE__ */ _length(...args));
3932
+ inst.nonempty = (...args) => inst.check(/* @__PURE__ */ _minLength(1, ...args));
3933
+ inst.lowercase = (params) => inst.check(/* @__PURE__ */ _lowercase(params));
3934
+ inst.uppercase = (params) => inst.check(/* @__PURE__ */ _uppercase(params));
3935
+ inst.trim = () => inst.check(/* @__PURE__ */ _trim());
3936
+ inst.normalize = (...args) => inst.check(/* @__PURE__ */ _normalize(...args));
3937
+ inst.toLowerCase = () => inst.check(/* @__PURE__ */ _toLowerCase());
3938
+ inst.toUpperCase = () => inst.check(/* @__PURE__ */ _toUpperCase());
3939
+ inst.slugify = () => inst.check(/* @__PURE__ */ _slugify());
3940
+ });
3941
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3942
+ $ZodString.init(inst, def);
3943
+ _ZodString.init(inst, def);
3944
+ inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3945
+ inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3946
+ inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3947
+ inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3948
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3949
+ inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3950
+ inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3951
+ inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3952
+ inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3953
+ inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3954
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3955
+ inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3956
+ inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3957
+ inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3958
+ inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3959
+ inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3960
+ inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3961
+ inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3962
+ inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3963
+ inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3964
+ inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3965
+ inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3966
+ inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3967
+ inst.datetime = (params) => inst.check(datetime(params));
3968
+ inst.date = (params) => inst.check(date(params));
3969
+ inst.time = (params) => inst.check(time(params));
3970
+ inst.duration = (params) => inst.check(duration(params));
3971
+ });
3972
+ function string(params) {
3973
+ return /* @__PURE__ */ _string(ZodString, params);
3974
+ }
3975
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
3976
+ $ZodStringFormat.init(inst, def);
3977
+ _ZodString.init(inst, def);
3978
+ });
3979
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
3980
+ $ZodEmail.init(inst, def);
3981
+ ZodStringFormat.init(inst, def);
3982
+ });
3983
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
3984
+ $ZodGUID.init(inst, def);
3985
+ ZodStringFormat.init(inst, def);
3986
+ });
3987
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
3988
+ $ZodUUID.init(inst, def);
3989
+ ZodStringFormat.init(inst, def);
3990
+ });
3991
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
3992
+ $ZodURL.init(inst, def);
3993
+ ZodStringFormat.init(inst, def);
3994
+ });
3995
+ function url(params) {
3996
+ return /* @__PURE__ */ _url(ZodURL, params);
3997
+ }
3998
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
3999
+ $ZodEmoji.init(inst, def);
4000
+ ZodStringFormat.init(inst, def);
4001
+ });
4002
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
4003
+ $ZodNanoID.init(inst, def);
4004
+ ZodStringFormat.init(inst, def);
4005
+ });
4006
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
4007
+ $ZodCUID.init(inst, def);
4008
+ ZodStringFormat.init(inst, def);
4009
+ });
4010
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
4011
+ $ZodCUID2.init(inst, def);
4012
+ ZodStringFormat.init(inst, def);
4013
+ });
4014
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
4015
+ $ZodULID.init(inst, def);
4016
+ ZodStringFormat.init(inst, def);
4017
+ });
4018
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
4019
+ $ZodXID.init(inst, def);
4020
+ ZodStringFormat.init(inst, def);
4021
+ });
4022
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
4023
+ $ZodKSUID.init(inst, def);
4024
+ ZodStringFormat.init(inst, def);
4025
+ });
4026
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
4027
+ $ZodIPv4.init(inst, def);
4028
+ ZodStringFormat.init(inst, def);
4029
+ });
4030
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
4031
+ $ZodIPv6.init(inst, def);
4032
+ ZodStringFormat.init(inst, def);
4033
+ });
4034
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
4035
+ $ZodCIDRv4.init(inst, def);
4036
+ ZodStringFormat.init(inst, def);
4037
+ });
4038
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
4039
+ $ZodCIDRv6.init(inst, def);
4040
+ ZodStringFormat.init(inst, def);
4041
+ });
4042
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
4043
+ $ZodBase64.init(inst, def);
4044
+ ZodStringFormat.init(inst, def);
4045
+ });
4046
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
4047
+ $ZodBase64URL.init(inst, def);
4048
+ ZodStringFormat.init(inst, def);
4049
+ });
4050
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
4051
+ $ZodE164.init(inst, def);
4052
+ ZodStringFormat.init(inst, def);
4053
+ });
4054
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
4055
+ $ZodJWT.init(inst, def);
4056
+ ZodStringFormat.init(inst, def);
4057
+ });
4058
+ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
4059
+ $ZodNumber.init(inst, def);
4060
+ ZodType.init(inst, def);
4061
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
4062
+ inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
4063
+ inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
4064
+ inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
4065
+ inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
4066
+ inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
4067
+ inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
4068
+ inst.int = (params) => inst.check(int(params));
4069
+ inst.safe = (params) => inst.check(int(params));
4070
+ inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(0, params));
4071
+ inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(0, params));
4072
+ inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(0, params));
4073
+ inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(0, params));
4074
+ inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
4075
+ inst.step = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
4076
+ inst.finite = () => inst;
4077
+ const bag = inst._zod.bag;
4078
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
4079
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
4080
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
4081
+ inst.isFinite = true;
4082
+ inst.format = bag.format ?? null;
4083
+ });
4084
+ function number$1(params) {
4085
+ return /* @__PURE__ */ _number(ZodNumber, params);
4086
+ }
4087
+ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
4088
+ $ZodNumberFormat.init(inst, def);
4089
+ ZodNumber.init(inst, def);
4090
+ });
4091
+ function int(params) {
4092
+ return /* @__PURE__ */ _int(ZodNumberFormat, params);
4093
+ }
4094
+ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
4095
+ $ZodBoolean.init(inst, def);
4096
+ ZodType.init(inst, def);
4097
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
4098
+ });
4099
+ function boolean(params) {
4100
+ return /* @__PURE__ */ _boolean(ZodBoolean, params);
4101
+ }
4102
+ const ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
4103
+ $ZodNull.init(inst, def);
4104
+ ZodType.init(inst, def);
4105
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json);
4106
+ });
4107
+ function _null(params) {
4108
+ return /* @__PURE__ */ _null$1(ZodNull, params);
4109
+ }
4110
+ const ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
4111
+ $ZodAny.init(inst, def);
4112
+ ZodType.init(inst, def);
4113
+ inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor();
4114
+ });
4115
+ function any() {
4116
+ return /* @__PURE__ */ _any(ZodAny);
4117
+ }
4118
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
4119
+ $ZodUnknown.init(inst, def);
4120
+ ZodType.init(inst, def);
4121
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
4122
+ });
4123
+ function unknown() {
4124
+ return /* @__PURE__ */ _unknown(ZodUnknown);
4125
+ }
4126
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
4127
+ $ZodNever.init(inst, def);
4128
+ ZodType.init(inst, def);
4129
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
4130
+ });
4131
+ function never(params) {
4132
+ return /* @__PURE__ */ _never(ZodNever, params);
4133
+ }
4134
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
4135
+ $ZodArray.init(inst, def);
4136
+ ZodType.init(inst, def);
4137
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4138
+ inst.element = def.element;
4139
+ inst.min = (minLength, params) => inst.check(/* @__PURE__ */ _minLength(minLength, params));
4140
+ inst.nonempty = (params) => inst.check(/* @__PURE__ */ _minLength(1, params));
4141
+ inst.max = (maxLength, params) => inst.check(/* @__PURE__ */ _maxLength(maxLength, params));
4142
+ inst.length = (len, params) => inst.check(/* @__PURE__ */ _length(len, params));
4143
+ inst.unwrap = () => inst.element;
4144
+ });
4145
+ function array(element, params) {
4146
+ return /* @__PURE__ */ _array(ZodArray, element, params);
4147
+ }
4148
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4149
+ $ZodObjectJIT.init(inst, def);
4150
+ ZodType.init(inst, def);
4151
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4152
+ defineLazy(inst, "shape", () => {
4153
+ return def.shape;
4154
+ });
4155
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4156
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
4157
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4158
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
4159
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
4160
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
4161
+ inst.extend = (incoming) => {
4162
+ return extend(inst, incoming);
4163
+ };
4164
+ inst.safeExtend = (incoming) => {
4165
+ return safeExtend(inst, incoming);
4166
+ };
4167
+ inst.merge = (other) => merge(inst, other);
4168
+ inst.pick = (mask) => pick(inst, mask);
4169
+ inst.omit = (mask) => omit(inst, mask);
4170
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4171
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4172
+ });
4173
+ function object(shape, params) {
4174
+ const def = {
4175
+ type: "object",
4176
+ shape: shape ?? {},
4177
+ ...normalizeParams(params)
4178
+ };
4179
+ return new ZodObject(def);
4180
+ }
4181
+ function looseObject(shape, params) {
4182
+ return new ZodObject({
4183
+ type: "object",
4184
+ shape,
4185
+ catchall: unknown(),
4186
+ ...normalizeParams(params)
4187
+ });
4188
+ }
4189
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
4190
+ $ZodUnion.init(inst, def);
4191
+ ZodType.init(inst, def);
4192
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4193
+ inst.options = def.options;
4194
+ });
4195
+ function union(options, params) {
4196
+ return new ZodUnion({
4197
+ type: "union",
4198
+ options,
4199
+ ...normalizeParams(params)
4200
+ });
4201
+ }
4202
+ const ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
4203
+ ZodUnion.init(inst, def);
4204
+ $ZodDiscriminatedUnion.init(inst, def);
4205
+ });
4206
+ function discriminatedUnion(discriminator, options, params) {
4207
+ return new ZodDiscriminatedUnion({
4208
+ type: "union",
4209
+ options,
4210
+ discriminator,
4211
+ ...normalizeParams(params)
4212
+ });
4213
+ }
4214
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
4215
+ $ZodIntersection.init(inst, def);
4216
+ ZodType.init(inst, def);
4217
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4218
+ });
4219
+ function intersection(left, right) {
4220
+ return new ZodIntersection({
4221
+ type: "intersection",
4222
+ left,
4223
+ right
4224
+ });
4225
+ }
4226
+ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4227
+ $ZodRecord.init(inst, def);
4228
+ ZodType.init(inst, def);
4229
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4230
+ inst.keyType = def.keyType;
4231
+ inst.valueType = def.valueType;
4232
+ });
4233
+ function record(keyType, valueType, params) {
4234
+ return new ZodRecord({
4235
+ type: "record",
4236
+ keyType,
4237
+ valueType,
4238
+ ...normalizeParams(params)
4239
+ });
4240
+ }
4241
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4242
+ $ZodEnum.init(inst, def);
4243
+ ZodType.init(inst, def);
4244
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
4245
+ inst.enum = def.entries;
4246
+ inst.options = Object.values(def.entries);
4247
+ const keys = new Set(Object.keys(def.entries));
4248
+ inst.extract = (values, params) => {
4249
+ const newEntries = {};
4250
+ for (const value of values) {
4251
+ if (keys.has(value)) {
4252
+ newEntries[value] = def.entries[value];
4253
+ } else
4254
+ throw new Error(`Key ${value} not found in enum`);
4255
+ }
4256
+ return new ZodEnum({
4257
+ ...def,
4258
+ checks: [],
4259
+ ...normalizeParams(params),
4260
+ entries: newEntries
4261
+ });
4262
+ };
4263
+ inst.exclude = (values, params) => {
4264
+ const newEntries = { ...def.entries };
4265
+ for (const value of values) {
4266
+ if (keys.has(value)) {
4267
+ delete newEntries[value];
4268
+ } else
4269
+ throw new Error(`Key ${value} not found in enum`);
4270
+ }
4271
+ return new ZodEnum({
4272
+ ...def,
4273
+ checks: [],
4274
+ ...normalizeParams(params),
4275
+ entries: newEntries
4276
+ });
4277
+ };
4278
+ });
4279
+ function _enum(values, params) {
4280
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
4281
+ return new ZodEnum({
4282
+ type: "enum",
4283
+ entries,
4284
+ ...normalizeParams(params)
4285
+ });
4286
+ }
4287
+ const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4288
+ $ZodLiteral.init(inst, def);
4289
+ ZodType.init(inst, def);
4290
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json);
4291
+ inst.values = new Set(def.values);
4292
+ Object.defineProperty(inst, "value", {
4293
+ get() {
4294
+ if (def.values.length > 1) {
4295
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4296
+ }
4297
+ return def.values[0];
4298
+ }
4299
+ });
4300
+ });
4301
+ function literal(value, params) {
4302
+ return new ZodLiteral({
4303
+ type: "literal",
4304
+ values: Array.isArray(value) ? value : [value],
4305
+ ...normalizeParams(params)
4306
+ });
4307
+ }
4308
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4309
+ $ZodTransform.init(inst, def);
4310
+ ZodType.init(inst, def);
4311
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
4312
+ inst._zod.parse = (payload, _ctx) => {
4313
+ if (_ctx.direction === "backward") {
4314
+ throw new $ZodEncodeError(inst.constructor.name);
4315
+ }
4316
+ payload.addIssue = (issue$1) => {
4317
+ if (typeof issue$1 === "string") {
4318
+ payload.issues.push(issue(issue$1, payload.value, def));
4319
+ } else {
4320
+ const _issue = issue$1;
4321
+ if (_issue.fatal)
4322
+ _issue.continue = false;
4323
+ _issue.code ?? (_issue.code = "custom");
4324
+ _issue.input ?? (_issue.input = payload.value);
4325
+ _issue.inst ?? (_issue.inst = inst);
4326
+ payload.issues.push(issue(_issue));
4327
+ }
4328
+ };
4329
+ const output = def.transform(payload.value, payload);
4330
+ if (output instanceof Promise) {
4331
+ return output.then((output2) => {
4332
+ payload.value = output2;
4333
+ return payload;
4334
+ });
4335
+ }
4336
+ payload.value = output;
4337
+ return payload;
4338
+ };
4339
+ });
4340
+ function transform(fn) {
4341
+ return new ZodTransform({
4342
+ type: "transform",
4343
+ transform: fn
4344
+ });
4345
+ }
4346
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
4347
+ $ZodOptional.init(inst, def);
4348
+ ZodType.init(inst, def);
4349
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4350
+ inst.unwrap = () => inst._zod.def.innerType;
4351
+ });
4352
+ function optional(innerType) {
4353
+ return new ZodOptional({
4354
+ type: "optional",
4355
+ innerType
4356
+ });
4357
+ }
4358
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4359
+ $ZodExactOptional.init(inst, def);
4360
+ ZodType.init(inst, def);
4361
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4362
+ inst.unwrap = () => inst._zod.def.innerType;
4363
+ });
4364
+ function exactOptional(innerType) {
4365
+ return new ZodExactOptional({
4366
+ type: "optional",
4367
+ innerType
4368
+ });
4369
+ }
4370
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4371
+ $ZodNullable.init(inst, def);
4372
+ ZodType.init(inst, def);
4373
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4374
+ inst.unwrap = () => inst._zod.def.innerType;
4375
+ });
4376
+ function nullable(innerType) {
4377
+ return new ZodNullable({
4378
+ type: "nullable",
4379
+ innerType
4380
+ });
4381
+ }
4382
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
4383
+ $ZodDefault.init(inst, def);
4384
+ ZodType.init(inst, def);
4385
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4386
+ inst.unwrap = () => inst._zod.def.innerType;
4387
+ inst.removeDefault = inst.unwrap;
4388
+ });
4389
+ function _default(innerType, defaultValue) {
4390
+ return new ZodDefault({
4391
+ type: "default",
4392
+ innerType,
4393
+ get defaultValue() {
4394
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4395
+ }
4396
+ });
4397
+ }
4398
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
4399
+ $ZodPrefault.init(inst, def);
4400
+ ZodType.init(inst, def);
4401
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4402
+ inst.unwrap = () => inst._zod.def.innerType;
4403
+ });
4404
+ function prefault(innerType, defaultValue) {
4405
+ return new ZodPrefault({
4406
+ type: "prefault",
4407
+ innerType,
4408
+ get defaultValue() {
4409
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4410
+ }
4411
+ });
4412
+ }
4413
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
4414
+ $ZodNonOptional.init(inst, def);
4415
+ ZodType.init(inst, def);
4416
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4417
+ inst.unwrap = () => inst._zod.def.innerType;
4418
+ });
4419
+ function nonoptional(innerType, params) {
4420
+ return new ZodNonOptional({
4421
+ type: "nonoptional",
4422
+ innerType,
4423
+ ...normalizeParams(params)
4424
+ });
4425
+ }
4426
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
4427
+ $ZodCatch.init(inst, def);
4428
+ ZodType.init(inst, def);
4429
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4430
+ inst.unwrap = () => inst._zod.def.innerType;
4431
+ inst.removeCatch = inst.unwrap;
4432
+ });
4433
+ function _catch(innerType, catchValue) {
4434
+ return new ZodCatch({
4435
+ type: "catch",
4436
+ innerType,
4437
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4438
+ });
4439
+ }
4440
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
4441
+ $ZodPipe.init(inst, def);
4442
+ ZodType.init(inst, def);
4443
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4444
+ inst.in = def.in;
4445
+ inst.out = def.out;
4446
+ });
4447
+ function pipe(in_, out) {
4448
+ return new ZodPipe({
4449
+ type: "pipe",
4450
+ in: in_,
4451
+ out
4452
+ // ...util.normalizeParams(params),
4453
+ });
4454
+ }
4455
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4456
+ $ZodReadonly.init(inst, def);
4457
+ ZodType.init(inst, def);
4458
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4459
+ inst.unwrap = () => inst._zod.def.innerType;
4460
+ });
4461
+ function readonly(innerType) {
4462
+ return new ZodReadonly({
4463
+ type: "readonly",
4464
+ innerType
4465
+ });
4466
+ }
4467
+ const ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
4468
+ $ZodLazy.init(inst, def);
4469
+ ZodType.init(inst, def);
4470
+ inst._zod.processJSONSchema = (ctx, json, params) => lazyProcessor(inst, ctx, json, params);
4471
+ inst.unwrap = () => inst._zod.def.getter();
4472
+ });
4473
+ function lazy(getter) {
4474
+ return new ZodLazy({
4475
+ type: "lazy",
4476
+ getter
4477
+ });
4478
+ }
4479
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4480
+ $ZodCustom.init(inst, def);
4481
+ ZodType.init(inst, def);
4482
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
4483
+ });
4484
+ function refine(fn, _params = {}) {
4485
+ return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4486
+ }
4487
+ function superRefine(fn) {
4488
+ return /* @__PURE__ */ _superRefine(fn);
4489
+ }
4490
+ function preprocess(fn, schema) {
4491
+ return pipe(transform(fn), schema);
4492
+ }
4493
+ const ZodIssueCode = {
4494
+ custom: "custom"
4495
+ };
4496
+ function number(params) {
4497
+ return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
4498
+ }
4499
+ export {
4500
+ NEVER as N,
4501
+ ZodIssueCode as Z,
4502
+ _enum as _,
4503
+ array as a,
4504
+ string as b,
4505
+ boolean as c,
4506
+ object as d,
4507
+ unknown as e,
4508
+ looseObject as f,
4509
+ discriminatedUnion as g,
4510
+ _null as h,
4511
+ datetime as i,
4512
+ intersection as j,
4513
+ lazy as k,
4514
+ literal as l,
4515
+ url as m,
4516
+ number$1 as n,
4517
+ optional as o,
4518
+ preprocess as p,
4519
+ number as q,
4520
+ record as r,
4521
+ safeParse as s,
4522
+ any as t,
4523
+ union as u
4524
+ };