kiki-agent 0.4.2 → 0.5.1

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 (238) hide show
  1. package/README.md +3 -3
  2. package/dist/cpu-worker.mjs +52744 -0
  3. package/dist/docs/en/configuration/config-files.md +121 -46
  4. package/dist/docs/en/configuration/data-locations.md +34 -7
  5. package/dist/docs/en/configuration/env-vars.md +37 -9
  6. package/dist/docs/en/configuration/overrides.md +20 -9
  7. package/dist/docs/en/configuration/providers.md +114 -9
  8. package/dist/docs/en/customization/agent-profiles.md +1 -1
  9. package/dist/docs/en/customization/agents-and-subagents.md +55 -12
  10. package/dist/docs/en/customization/hooks.md +3 -3
  11. package/dist/docs/en/customization/personas.md +36 -2
  12. package/dist/docs/en/customization/plugins.md +56 -3
  13. package/dist/docs/en/customization/prompt-fields.md +65 -5
  14. package/dist/docs/en/customization/recipes.md +77 -0
  15. package/dist/docs/en/customization/skins.md +2 -2
  16. package/dist/docs/en/customization/themes.md +1 -1
  17. package/dist/docs/en/features/agent-workflows.md +8 -8
  18. package/dist/docs/en/features/browser-and-computer.md +40 -0
  19. package/dist/docs/en/features/daily.md +13 -13
  20. package/dist/docs/en/features/ecosystem.md +6 -6
  21. package/dist/docs/en/features/extend.md +11 -10
  22. package/dist/docs/en/features/freedom.md +9 -9
  23. package/dist/docs/en/features/index.md +58 -28
  24. package/dist/docs/en/features/long-work.md +18 -14
  25. package/dist/docs/en/features/look.md +6 -6
  26. package/dist/docs/en/features/people.md +6 -6
  27. package/dist/docs/en/features/phone.md +13 -3
  28. package/dist/docs/en/features/spaces.md +12 -12
  29. package/dist/docs/en/features/workbench.md +8 -8
  30. package/dist/docs/en/getting-started/desktop-app.md +4 -8
  31. package/dist/docs/en/getting-started/first-launch.md +1 -1
  32. package/dist/docs/en/guides/goals.md +4 -2
  33. package/dist/docs/en/guides/interface.md +32 -10
  34. package/dist/docs/en/guides/memory.md +64 -10
  35. package/dist/docs/en/guides/sessions.md +21 -9
  36. package/dist/docs/en/guides/settings.md +64 -40
  37. package/dist/docs/en/index.md +3 -1
  38. package/dist/docs/en/reference/command.md +90 -31
  39. package/dist/docs/en/reference/model-vocabulary.md +2 -2
  40. package/dist/docs/en/reference/slash-commands.md +1 -1
  41. package/dist/docs/en/reference/tools.md +65 -20
  42. package/dist/docs/en/server/acp.md +9 -3
  43. package/dist/docs/en/server/local-server.md +19 -27
  44. package/dist/docs/en/server/mcp.md +9 -5
  45. package/dist/docs/en/server/rest-api.md +350 -22
  46. package/dist/docs/en/server/script-tools.md +268 -0
  47. package/dist/docs/zh/configuration/config-files.md +121 -46
  48. package/dist/docs/zh/configuration/data-locations.md +34 -7
  49. package/dist/docs/zh/configuration/env-vars.md +37 -9
  50. package/dist/docs/zh/configuration/overrides.md +20 -9
  51. package/dist/docs/zh/configuration/providers.md +114 -9
  52. package/dist/docs/zh/customization/agent-profiles.md +1 -1
  53. package/dist/docs/zh/customization/agents-and-subagents.md +55 -12
  54. package/dist/docs/zh/customization/hooks.md +3 -3
  55. package/dist/docs/zh/customization/personas.md +36 -2
  56. package/dist/docs/zh/customization/plugins.md +56 -3
  57. package/dist/docs/zh/customization/prompt-fields.md +65 -5
  58. package/dist/docs/zh/customization/recipes.md +77 -0
  59. package/dist/docs/zh/customization/skins.md +2 -2
  60. package/dist/docs/zh/customization/themes.md +1 -1
  61. package/dist/docs/zh/features/agent-workflows.md +10 -10
  62. package/dist/docs/zh/features/browser-and-computer.md +40 -0
  63. package/dist/docs/zh/features/daily.md +13 -13
  64. package/dist/docs/zh/features/ecosystem.md +6 -6
  65. package/dist/docs/zh/features/extend.md +10 -9
  66. package/dist/docs/zh/features/freedom.md +9 -9
  67. package/dist/docs/zh/features/index.md +58 -28
  68. package/dist/docs/zh/features/long-work.md +17 -13
  69. package/dist/docs/zh/features/look.md +6 -6
  70. package/dist/docs/zh/features/people.md +5 -5
  71. package/dist/docs/zh/features/phone.md +13 -3
  72. package/dist/docs/zh/features/spaces.md +12 -12
  73. package/dist/docs/zh/features/workbench.md +8 -8
  74. package/dist/docs/zh/getting-started/desktop-app.md +4 -8
  75. package/dist/docs/zh/getting-started/first-launch.md +1 -1
  76. package/dist/docs/zh/guides/goals.md +4 -2
  77. package/dist/docs/zh/guides/interface.md +32 -10
  78. package/dist/docs/zh/guides/memory.md +64 -10
  79. package/dist/docs/zh/guides/sessions.md +21 -9
  80. package/dist/docs/zh/guides/settings.md +64 -40
  81. package/dist/docs/zh/index.md +4 -2
  82. package/dist/docs/zh/reference/command.md +90 -31
  83. package/dist/docs/zh/reference/model-vocabulary.md +2 -2
  84. package/dist/docs/zh/reference/slash-commands.md +1 -1
  85. package/dist/docs/zh/reference/tools.md +65 -20
  86. package/dist/docs/zh/server/acp.md +9 -3
  87. package/dist/docs/zh/server/local-server.md +19 -27
  88. package/dist/docs/zh/server/mcp.md +9 -5
  89. package/dist/docs/zh/server/rest-api.md +338 -21
  90. package/dist/docs/zh/server/script-tools.md +268 -0
  91. package/dist/external-harness/agy-cli-acp.mjs +168 -162
  92. package/dist/external-harness/agy-hook-registration.mjs +69 -30
  93. package/dist/external-harness/agy-mcp-plugin.mjs +19 -0
  94. package/dist/external-harness/agy-permission-hook.mjs +29 -2
  95. package/dist/hostRunner.mjs +112 -3
  96. package/dist/mailbox-worker.mjs +403 -0
  97. package/dist/main.mjs +2 -2
  98. package/dist/memory-worker.mjs +1008 -0
  99. package/dist/native/windows-process-helper.exe +0 -0
  100. package/dist/query-store-worker.mjs +487 -0
  101. package/dist/sqlite-indexer.mjs +255 -403
  102. package/dist/sqlite-query-worker.mjs +261 -249
  103. package/dist/usage-parser-worker.mjs +3977 -9
  104. package/dist/usage-read-model-worker.mjs +761 -0
  105. package/dist/web/assets/AppErrorBoundary-B5Fc4f6-.js +1 -0
  106. package/dist/web/assets/NavScopeBoundary-C7MnGQio.js +1 -0
  107. package/dist/web/assets/{arc-DYDCMlOS.js → arc-DGB9OVgQ.js} +1 -1
  108. package/dist/web/assets/{architectureDiagram-3BPJPVTR-C9Y7T0O2.js → architectureDiagram-3BPJPVTR-glnQCMub.js} +1 -1
  109. package/dist/web/assets/{blockDiagram-GPEHLZMM-CdUrp-tD.js → blockDiagram-GPEHLZMM-bM0tnGby.js} +1 -1
  110. package/dist/web/assets/{c4Diagram-AAUBKEIU-PrwvB9IJ.js → c4Diagram-AAUBKEIU-DMf_rTtt.js} +1 -1
  111. package/dist/web/assets/channel-Cj8SKJ38.js +1 -0
  112. package/dist/web/assets/{chunk-2J33WTMH-BL56g_Es.js → chunk-2J33WTMH-mTccJ3tW.js} +1 -1
  113. package/dist/web/assets/{chunk-4BX2VUAB-DvJD5M9M.js → chunk-4BX2VUAB-DhqPYMjY.js} +1 -1
  114. package/dist/web/assets/{chunk-55IACEB6-C8f-nzvx.js → chunk-55IACEB6-BujrYRoO.js} +1 -1
  115. package/dist/web/assets/{chunk-727SXJPM-DOGkWKkV.js → chunk-727SXJPM-ciMmSI4G.js} +1 -1
  116. package/dist/web/assets/{chunk-AQP2D5EJ-fFOuz7g6.js → chunk-AQP2D5EJ-CZW9pKTc.js} +1 -1
  117. package/dist/web/assets/{chunk-FMBD7UC4-BpeXZ9LM.js → chunk-FMBD7UC4-hdALNnnU.js} +1 -1
  118. package/dist/web/assets/{chunk-ND2GUHAM-CRUh76fb.js → chunk-ND2GUHAM-CgKyqUdb.js} +1 -1
  119. package/dist/web/assets/{chunk-QZHKN3VN-uNfxaPk0.js → chunk-QZHKN3VN-B2mmUz_E.js} +1 -1
  120. package/dist/web/assets/classDiagram-4FO5ZUOK-f8V9p-dD.js +1 -0
  121. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-f8V9p-dD.js +1 -0
  122. package/dist/web/assets/client-ClWQBErG.js +3 -0
  123. package/dist/web/assets/connection-C0J3BPgk.js +1 -0
  124. package/dist/web/assets/{cose-bilkent-S5V4N54A-BNkxG-qX.js → cose-bilkent-S5V4N54A-UV3uPjkK.js} +1 -1
  125. package/dist/web/assets/{dagre-BM42HDAG-BerioUei.js → dagre-BM42HDAG-Zjy-gQ6C.js} +1 -1
  126. package/dist/web/assets/{diagram-2AECGRRQ-Czv2SR07.js → diagram-2AECGRRQ-DL-kilIf.js} +1 -1
  127. package/dist/web/assets/{diagram-5GNKFQAL-Uzi1weGK.js → diagram-5GNKFQAL-CjB_xR5B.js} +1 -1
  128. package/dist/web/assets/{diagram-KO2AKTUF-W36h_ff3.js → diagram-KO2AKTUF-CjN4i3b9.js} +1 -1
  129. package/dist/web/assets/{diagram-LMA3HP47-FG4dDk52.js → diagram-LMA3HP47-CPCAMndo.js} +1 -1
  130. package/dist/web/assets/{diagram-OG6HWLK6-CQoEjIAY.js → diagram-OG6HWLK6-DVeBWBKd.js} +1 -1
  131. package/dist/web/assets/{erDiagram-TEJ5UH35-Ck06KVyZ.js → erDiagram-TEJ5UH35-CHKzBHrr.js} +1 -1
  132. package/dist/web/assets/export-CXoWon32.js +2 -0
  133. package/dist/web/assets/{flowDiagram-I6XJVG4X-C5hgxdFZ.js → flowDiagram-I6XJVG4X-C5rQa2pq.js} +1 -1
  134. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BS52Pw5_.js → ganttDiagram-6RSMTGT7-BrLjEsNJ.js} +1 -1
  135. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLlQKZHs.js → gitGraphDiagram-PVQCEYII-3DRR5VZj.js} +1 -1
  136. package/dist/web/assets/highlighted-body-OFNGDK62-Bdj5SJfv.js +1 -0
  137. package/dist/web/assets/index-2Vx5mHRn.js +1 -0
  138. package/dist/web/assets/index-B1UXw2C9.js +1 -0
  139. package/dist/web/assets/{index-CM-nNfuV.js → index-BJxtlf4P.js} +4 -4
  140. package/dist/web/assets/{index-DKIysLbI.js → index-BY7jPurv.js} +1 -1
  141. package/dist/web/assets/index-Bq79v-Sa.js +1 -0
  142. package/dist/web/assets/index-BqD3iTIl.js +1 -0
  143. package/dist/web/assets/index-Br3AlBrQ.js +1 -0
  144. package/dist/web/assets/{index-Ca607_hK.js → index-BvRBCpc6.js} +2 -2
  145. package/dist/web/assets/index-BxYCSNg_.js +3 -0
  146. package/dist/web/assets/{index-B2Pu0Iuu.js → index-C62wjCF_.js} +1 -1
  147. package/dist/web/assets/index-CBvwNH_H.js +1 -0
  148. package/dist/web/assets/{index-BNch_a4L.js → index-CG9e6lgq.js} +1 -1
  149. package/dist/web/assets/{index-ByiwExpV.js → index-CPSWYh_R.js} +2 -2
  150. package/dist/web/assets/index-CS4xJLZV.js +1 -0
  151. package/dist/web/assets/index-CjvqtF2I.js +1 -0
  152. package/dist/web/assets/index-CprdjRRk.js +13 -0
  153. package/dist/web/assets/{index-Bg99yVX_.js → index-CypTtrCB.js} +1 -1
  154. package/dist/web/assets/{index-BwcG86o3.js → index-DDJQGcUL.js} +1 -1
  155. package/dist/web/assets/index-DLWzxUOO.js +1 -0
  156. package/dist/web/assets/index-DQxkxZmn.js +7 -0
  157. package/dist/web/assets/index-DRo5Y_9p.js +1 -0
  158. package/dist/web/assets/index-De_LkTZx.js +1 -0
  159. package/dist/web/assets/{index-CZX3qUe2.js → index-DfUpwUTM.js} +2 -2
  160. package/dist/web/assets/{index-BLU8_Um7.js → index-Dkbz748K.js} +2 -2
  161. package/dist/web/assets/index-DmwFFSkV.js +1 -0
  162. package/dist/web/assets/index-DpcWEDhW.js +1 -0
  163. package/dist/web/assets/index-Dqq1RDP4.js +1 -0
  164. package/dist/web/assets/index-H1uMvIoa.css +1 -0
  165. package/dist/web/assets/index-ICHWJ2SM.js +1 -0
  166. package/dist/web/assets/index-O5fSd569.js +229 -0
  167. package/dist/web/assets/index-odjtqLLS.js +1 -0
  168. package/dist/web/assets/index-v_yAQ0Am.js +1 -0
  169. package/dist/web/assets/{infoDiagram-5YYISTIA-CD4XJGFm.js → infoDiagram-5YYISTIA-CCwV4Z0v.js} +1 -1
  170. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-fu5E3_CT.js → ishikawaDiagram-YF4QCWOH-BwwZcGyZ.js} +1 -1
  171. package/dist/web/assets/{journeyDiagram-JHISSGLW-CXcnKBfJ.js → journeyDiagram-JHISSGLW-Dc6WqniQ.js} +1 -1
  172. package/dist/web/assets/{kanban-definition-UN3LZRKU-BawKH6Pl.js → kanban-definition-UN3LZRKU-DVUqULOS.js} +1 -1
  173. package/dist/web/assets/{linear-BplJuXph.js → linear-d6rWsNOU.js} +1 -1
  174. package/dist/web/assets/memoryAdvisor-DBQXJB1o.js +1 -0
  175. package/dist/web/assets/mermaid-GHXKKRXX-Ik6SkVDT.js +642 -0
  176. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DA1SE2uy.js → mindmap-definition-RKZ34NQL-_JHAkhHL.js} +1 -1
  177. package/dist/web/assets/navViewState-DaCMIYWA.js +1 -0
  178. package/dist/web/assets/{pieDiagram-4H26LBE5-6i021QeX.js → pieDiagram-4H26LBE5-BlhlygGy.js} +1 -1
  179. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CcKSZDMT.js → quadrantDiagram-W4KKPZXB-jn6R_C0S.js} +1 -1
  180. package/dist/web/assets/{requirementDiagram-4Y6WPE33-lYVuWRuD.js → requirementDiagram-4Y6WPE33-B9fXCHBr.js} +1 -1
  181. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-4Zfb4_h4.js → sankeyDiagram-5OEKKPKP-fPJwIxkl.js} +1 -1
  182. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DqltKmlY.js → sequenceDiagram-3UESZ5HK-1v1DTNGt.js} +1 -1
  183. package/dist/web/assets/{spaces-CjuXbmxF.js → spaces-CvL2DRZM.js} +1 -1
  184. package/dist/web/assets/{stateDiagram-AJRCARHV-HFdhqxzx.js → stateDiagram-AJRCARHV-CEc_PLov.js} +1 -1
  185. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-iAMctzaT.js +1 -0
  186. package/dist/web/assets/theme-LRSmy8mD.js +1 -0
  187. package/dist/web/assets/{timeline-definition-PNZ67QCA-HNRxaB3t.js → timeline-definition-PNZ67QCA-CEjhuitj.js} +1 -1
  188. package/dist/web/assets/{vennDiagram-CIIHVFJN-DwsCTyaD.js → vennDiagram-CIIHVFJN-CActt9h9.js} +1 -1
  189. package/dist/web/assets/{wardley-L42UT6IY-BWW2wtVO.js → wardley-L42UT6IY-Bp3q2izt.js} +1 -1
  190. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-C-ktKm7v.js → wardleyDiagram-YWT4CUSO-C_zutiQ2.js} +1 -1
  191. package/dist/web/assets/{xychartDiagram-2RQKCTM6-48AxNW9k.js → xychartDiagram-2RQKCTM6-CRafvv33.js} +1 -1
  192. package/dist/web/icons/apple-touch-icon.png +0 -0
  193. package/dist/web/icons/icon-192.png +0 -0
  194. package/dist/web/icons/icon-512.png +0 -0
  195. package/dist/web/icons/maskable-512.png +0 -0
  196. package/dist/web/index.html +12 -2
  197. package/dist/web/manifest.webmanifest +16 -0
  198. package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
  199. package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
  200. package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
  201. package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
  202. package/package.json +23 -4
  203. package/dist/search-worker.mjs +0 -14177
  204. package/dist/web/assets/AppErrorBoundary-DiGMUg4r.js +0 -1
  205. package/dist/web/assets/LifeMark-CL6-HWDu.js +0 -1
  206. package/dist/web/assets/NavScopeBoundary-CFCnvZR0.js +0 -1
  207. package/dist/web/assets/channel-Bj_gZ_Lv.js +0 -1
  208. package/dist/web/assets/classDiagram-4FO5ZUOK-ssCwe2R4.js +0 -1
  209. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ssCwe2R4.js +0 -1
  210. package/dist/web/assets/client-DGj93bGT.js +0 -3
  211. package/dist/web/assets/connection-Bpf-EjrL.js +0 -1
  212. package/dist/web/assets/export-T_izwEkQ.js +0 -2
  213. package/dist/web/assets/highlighted-body-OFNGDK62-Btm6MuZ4.js +0 -1
  214. package/dist/web/assets/index-5_yzg61S.js +0 -1
  215. package/dist/web/assets/index-B-6LiYTY.js +0 -1
  216. package/dist/web/assets/index-B4iu4SJW.js +0 -1
  217. package/dist/web/assets/index-B9MlqF7J.js +0 -1
  218. package/dist/web/assets/index-BECSk4If.js +0 -1
  219. package/dist/web/assets/index-BFcyN2Zw.js +0 -1
  220. package/dist/web/assets/index-BIebkSEI.css +0 -1
  221. package/dist/web/assets/index-BMWid2q9.js +0 -1
  222. package/dist/web/assets/index-BeMvPEXs.js +0 -1
  223. package/dist/web/assets/index-Bezli3SF.js +0 -1
  224. package/dist/web/assets/index-BkPV0psm.js +0 -1
  225. package/dist/web/assets/index-CG8uIlD7.js +0 -1
  226. package/dist/web/assets/index-CJ92kLtO.js +0 -1
  227. package/dist/web/assets/index-CRDDqofN.js +0 -1
  228. package/dist/web/assets/index-Cd62y0wD.js +0 -1
  229. package/dist/web/assets/index-CgcJPsK6.js +0 -3
  230. package/dist/web/assets/index-Cy8C_eFR.js +0 -7
  231. package/dist/web/assets/index-D8z7lcQn.js +0 -166
  232. package/dist/web/assets/index-D_oPSlBL.js +0 -1
  233. package/dist/web/assets/index-Dceu0bqY.js +0 -1
  234. package/dist/web/assets/index-eUyF-8Sq.js +0 -1
  235. package/dist/web/assets/index-hG2s2Spn.js +0 -13
  236. package/dist/web/assets/mermaid-GHXKKRXX-BO9hkP3Z.js +0 -621
  237. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Dx28QuZF.js +0 -1
  238. package/dist/web/assets/theme-beWE_6f8.js +0 -1
@@ -1,4 +1,6 @@
1
1
  import { parentPort } from "node:worker_threads";
2
+ import { availableParallelism, totalmem } from "node:os";
3
+ import { getHeapStatistics } from "node:v8";
2
4
 
3
5
  //#region ../../packages/agent-core-v2/src/agent/usage/usageJson.ts
4
6
  const stringRun = /(?:[^"\\\u0000-\u001f]+|\\(?:["\\/bfnrt]|u[0-9a-fA-F]{4})){1,256}/y;
@@ -185,11 +187,11 @@ var UsageJsonStream = class UsageJsonStream {
185
187
  this.batchObserver = batchObserver;
186
188
  }
187
189
  snapshot() {
188
- if (this.batchObserver !== void 0) throw new TypeError("Fact observers cannot be transferred");
189
- return structuredClone(this);
190
+ const { batchObserver: _observer, ...state } = this;
191
+ return structuredClone(state);
190
192
  }
191
- static resume(state) {
192
- return Object.assign(new UsageJsonStream(), state);
193
+ static resume(state, observer) {
194
+ return Object.assign(new UsageJsonStream(observer), structuredClone(state));
193
195
  }
194
196
  write(text) {
195
197
  let position = 0;
@@ -455,6 +457,3903 @@ var UsageJsonStream = class UsageJsonStream {
455
457
  }
456
458
  };
457
459
 
460
+ //#endregion
461
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
462
+ /** A special constant with type `never` */
463
+ const NEVER = Object.freeze({ status: "aborted" });
464
+ function $constructor(name, initializer, params) {
465
+ function init(inst, def) {
466
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
467
+ value: {
468
+ def,
469
+ constr: _,
470
+ traits: /* @__PURE__ */ new Set()
471
+ },
472
+ enumerable: false
473
+ });
474
+ if (inst._zod.traits.has(name)) return;
475
+ inst._zod.traits.add(name);
476
+ initializer(inst, def);
477
+ const proto = _.prototype;
478
+ const keys = Object.keys(proto);
479
+ for (let i = 0; i < keys.length; i++) {
480
+ const k = keys[i];
481
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
482
+ }
483
+ }
484
+ const Parent = params?.Parent ?? Object;
485
+ class Definition extends Parent {}
486
+ Object.defineProperty(Definition, "name", { value: name });
487
+ function _(def) {
488
+ var _a;
489
+ const inst = params?.Parent ? new Definition() : this;
490
+ init(inst, def);
491
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
492
+ for (const fn of inst._zod.deferred) fn();
493
+ return inst;
494
+ }
495
+ Object.defineProperty(_, "init", { value: init });
496
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
497
+ if (params?.Parent && inst instanceof params.Parent) return true;
498
+ return inst?._zod?.traits?.has(name);
499
+ } });
500
+ Object.defineProperty(_, "name", { value: name });
501
+ return _;
502
+ }
503
+ var $ZodAsyncError = class extends Error {
504
+ constructor() {
505
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
506
+ }
507
+ };
508
+ var $ZodEncodeError = class extends Error {
509
+ constructor(name) {
510
+ super(`Encountered unidirectional transform during encode: ${name}`);
511
+ this.name = "ZodEncodeError";
512
+ }
513
+ };
514
+ const globalConfig = {};
515
+ function config(newConfig) {
516
+ if (newConfig) Object.assign(globalConfig, newConfig);
517
+ return globalConfig;
518
+ }
519
+
520
+ //#endregion
521
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
522
+ function getEnumValues(entries) {
523
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
524
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
525
+ }
526
+ function jsonStringifyReplacer(_, value) {
527
+ if (typeof value === "bigint") return value.toString();
528
+ return value;
529
+ }
530
+ function cached(getter) {
531
+ return { get value() {
532
+ {
533
+ const value = getter();
534
+ Object.defineProperty(this, "value", { value });
535
+ return value;
536
+ }
537
+ throw new Error("cached value already set");
538
+ } };
539
+ }
540
+ function nullish(input) {
541
+ return input === null || input === void 0;
542
+ }
543
+ function cleanRegex(source) {
544
+ const start = source.startsWith("^") ? 1 : 0;
545
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
546
+ return source.slice(start, end);
547
+ }
548
+ function floatSafeRemainder(val, step) {
549
+ const valDecCount = (val.toString().split(".")[1] || "").length;
550
+ const stepString = step.toString();
551
+ let stepDecCount = (stepString.split(".")[1] || "").length;
552
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
553
+ const match = stepString.match(/\d?e-(\d?)/);
554
+ if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
555
+ }
556
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
557
+ return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
558
+ }
559
+ const EVALUATING = Symbol("evaluating");
560
+ function defineLazy(object, key, getter) {
561
+ let value = void 0;
562
+ Object.defineProperty(object, key, {
563
+ get() {
564
+ if (value === EVALUATING) return;
565
+ if (value === void 0) {
566
+ value = EVALUATING;
567
+ value = getter();
568
+ }
569
+ return value;
570
+ },
571
+ set(v) {
572
+ Object.defineProperty(object, key, { value: v });
573
+ },
574
+ configurable: true
575
+ });
576
+ }
577
+ function assignProp(target, prop, value) {
578
+ Object.defineProperty(target, prop, {
579
+ value,
580
+ writable: true,
581
+ enumerable: true,
582
+ configurable: true
583
+ });
584
+ }
585
+ function mergeDefs(...defs) {
586
+ const mergedDescriptors = {};
587
+ for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
588
+ return Object.defineProperties({}, mergedDescriptors);
589
+ }
590
+ function esc(str) {
591
+ return JSON.stringify(str);
592
+ }
593
+ function slugify(input) {
594
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
595
+ }
596
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
597
+ function isObject(data) {
598
+ return typeof data === "object" && data !== null && !Array.isArray(data);
599
+ }
600
+ const allowsEval = cached(() => {
601
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
602
+ try {
603
+ new Function("");
604
+ return true;
605
+ } catch (_) {
606
+ return false;
607
+ }
608
+ });
609
+ function isPlainObject(o) {
610
+ if (isObject(o) === false) return false;
611
+ const ctor = o.constructor;
612
+ if (ctor === void 0) return true;
613
+ if (typeof ctor !== "function") return true;
614
+ const prot = ctor.prototype;
615
+ if (isObject(prot) === false) return false;
616
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
617
+ return true;
618
+ }
619
+ function shallowClone(o) {
620
+ if (isPlainObject(o)) return { ...o };
621
+ if (Array.isArray(o)) return [...o];
622
+ return o;
623
+ }
624
+ const propertyKeyTypes = new Set([
625
+ "string",
626
+ "number",
627
+ "symbol"
628
+ ]);
629
+ function escapeRegex(str) {
630
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
631
+ }
632
+ function clone(inst, def, params) {
633
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
634
+ if (!def || params?.parent) cl._zod.parent = inst;
635
+ return cl;
636
+ }
637
+ function normalizeParams(_params) {
638
+ const params = _params;
639
+ if (!params) return {};
640
+ if (typeof params === "string") return { error: () => params };
641
+ if (params?.message !== void 0) {
642
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
643
+ params.error = params.message;
644
+ }
645
+ delete params.message;
646
+ if (typeof params.error === "string") return {
647
+ ...params,
648
+ error: () => params.error
649
+ };
650
+ return params;
651
+ }
652
+ function optionalKeys(shape) {
653
+ return Object.keys(shape).filter((k) => {
654
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
655
+ });
656
+ }
657
+ const NUMBER_FORMAT_RANGES = {
658
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
659
+ int32: [-2147483648, 2147483647],
660
+ uint32: [0, 4294967295],
661
+ float32: [-34028234663852886e22, 34028234663852886e22],
662
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
663
+ };
664
+ function pick(schema, mask) {
665
+ const currDef = schema._zod.def;
666
+ const checks = currDef.checks;
667
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
668
+ return clone(schema, mergeDefs(schema._zod.def, {
669
+ get shape() {
670
+ const newShape = {};
671
+ for (const key in mask) {
672
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
673
+ if (!mask[key]) continue;
674
+ newShape[key] = currDef.shape[key];
675
+ }
676
+ assignProp(this, "shape", newShape);
677
+ return newShape;
678
+ },
679
+ checks: []
680
+ }));
681
+ }
682
+ function omit(schema, mask) {
683
+ const currDef = schema._zod.def;
684
+ const checks = currDef.checks;
685
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
686
+ return clone(schema, mergeDefs(schema._zod.def, {
687
+ get shape() {
688
+ const newShape = { ...schema._zod.def.shape };
689
+ for (const key in mask) {
690
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
691
+ if (!mask[key]) continue;
692
+ delete newShape[key];
693
+ }
694
+ assignProp(this, "shape", newShape);
695
+ return newShape;
696
+ },
697
+ checks: []
698
+ }));
699
+ }
700
+ function extend(schema, shape) {
701
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
702
+ const checks = schema._zod.def.checks;
703
+ if (checks && checks.length > 0) {
704
+ const existingShape = schema._zod.def.shape;
705
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
706
+ }
707
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
708
+ const _shape = {
709
+ ...schema._zod.def.shape,
710
+ ...shape
711
+ };
712
+ assignProp(this, "shape", _shape);
713
+ return _shape;
714
+ } }));
715
+ }
716
+ function safeExtend(schema, shape) {
717
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
718
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
719
+ const _shape = {
720
+ ...schema._zod.def.shape,
721
+ ...shape
722
+ };
723
+ assignProp(this, "shape", _shape);
724
+ return _shape;
725
+ } }));
726
+ }
727
+ function merge(a, b) {
728
+ return clone(a, mergeDefs(a._zod.def, {
729
+ get shape() {
730
+ const _shape = {
731
+ ...a._zod.def.shape,
732
+ ...b._zod.def.shape
733
+ };
734
+ assignProp(this, "shape", _shape);
735
+ return _shape;
736
+ },
737
+ get catchall() {
738
+ return b._zod.def.catchall;
739
+ },
740
+ checks: []
741
+ }));
742
+ }
743
+ function partial(Class, schema, mask) {
744
+ const checks = schema._zod.def.checks;
745
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
746
+ return clone(schema, mergeDefs(schema._zod.def, {
747
+ get shape() {
748
+ const oldShape = schema._zod.def.shape;
749
+ const shape = { ...oldShape };
750
+ if (mask) for (const key in mask) {
751
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
752
+ if (!mask[key]) continue;
753
+ shape[key] = Class ? new Class({
754
+ type: "optional",
755
+ innerType: oldShape[key]
756
+ }) : oldShape[key];
757
+ }
758
+ else for (const key in oldShape) shape[key] = Class ? new Class({
759
+ type: "optional",
760
+ innerType: oldShape[key]
761
+ }) : oldShape[key];
762
+ assignProp(this, "shape", shape);
763
+ return shape;
764
+ },
765
+ checks: []
766
+ }));
767
+ }
768
+ function required(Class, schema, mask) {
769
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
770
+ const oldShape = schema._zod.def.shape;
771
+ const shape = { ...oldShape };
772
+ if (mask) for (const key in mask) {
773
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
774
+ if (!mask[key]) continue;
775
+ shape[key] = new Class({
776
+ type: "nonoptional",
777
+ innerType: oldShape[key]
778
+ });
779
+ }
780
+ else for (const key in oldShape) shape[key] = new Class({
781
+ type: "nonoptional",
782
+ innerType: oldShape[key]
783
+ });
784
+ assignProp(this, "shape", shape);
785
+ return shape;
786
+ } }));
787
+ }
788
+ function aborted(x, startIndex = 0) {
789
+ if (x.aborted === true) return true;
790
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
791
+ return false;
792
+ }
793
+ function prefixIssues(path, issues) {
794
+ return issues.map((iss) => {
795
+ var _a;
796
+ (_a = iss).path ?? (_a.path = []);
797
+ iss.path.unshift(path);
798
+ return iss;
799
+ });
800
+ }
801
+ function unwrapMessage(message) {
802
+ return typeof message === "string" ? message : message?.message;
803
+ }
804
+ function finalizeIssue(iss, ctx, config) {
805
+ const full = {
806
+ ...iss,
807
+ path: iss.path ?? []
808
+ };
809
+ if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
810
+ delete full.inst;
811
+ delete full.continue;
812
+ if (!ctx?.reportInput) delete full.input;
813
+ return full;
814
+ }
815
+ function getLengthableOrigin(input) {
816
+ if (Array.isArray(input)) return "array";
817
+ if (typeof input === "string") return "string";
818
+ return "unknown";
819
+ }
820
+ function issue(...args) {
821
+ const [iss, input, inst] = args;
822
+ if (typeof iss === "string") return {
823
+ message: iss,
824
+ code: "custom",
825
+ input,
826
+ inst
827
+ };
828
+ return { ...iss };
829
+ }
830
+
831
+ //#endregion
832
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
833
+ const initializer$1 = (inst, def) => {
834
+ inst.name = "$ZodError";
835
+ Object.defineProperty(inst, "_zod", {
836
+ value: inst._zod,
837
+ enumerable: false
838
+ });
839
+ Object.defineProperty(inst, "issues", {
840
+ value: def,
841
+ enumerable: false
842
+ });
843
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
844
+ Object.defineProperty(inst, "toString", {
845
+ value: () => inst.message,
846
+ enumerable: false
847
+ });
848
+ };
849
+ const $ZodError = $constructor("$ZodError", initializer$1);
850
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
851
+ function flattenError(error, mapper = (issue) => issue.message) {
852
+ const fieldErrors = {};
853
+ const formErrors = [];
854
+ for (const sub of error.issues) if (sub.path.length > 0) {
855
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
856
+ fieldErrors[sub.path[0]].push(mapper(sub));
857
+ } else formErrors.push(mapper(sub));
858
+ return {
859
+ formErrors,
860
+ fieldErrors
861
+ };
862
+ }
863
+ function formatError(error, mapper = (issue) => issue.message) {
864
+ const fieldErrors = { _errors: [] };
865
+ const processError = (error) => {
866
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
867
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues });
868
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues });
869
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
870
+ else {
871
+ let curr = fieldErrors;
872
+ let i = 0;
873
+ while (i < issue.path.length) {
874
+ const el = issue.path[i];
875
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
876
+ else {
877
+ curr[el] = curr[el] || { _errors: [] };
878
+ curr[el]._errors.push(mapper(issue));
879
+ }
880
+ curr = curr[el];
881
+ i++;
882
+ }
883
+ }
884
+ };
885
+ processError(error);
886
+ return fieldErrors;
887
+ }
888
+
889
+ //#endregion
890
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js
891
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
892
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
893
+ const result = schema._zod.run({
894
+ value,
895
+ issues: []
896
+ }, ctx);
897
+ if (result instanceof Promise) throw new $ZodAsyncError();
898
+ if (result.issues.length) {
899
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
900
+ captureStackTrace(e, _params?.callee);
901
+ throw e;
902
+ }
903
+ return result.value;
904
+ };
905
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
906
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
907
+ let result = schema._zod.run({
908
+ value,
909
+ issues: []
910
+ }, ctx);
911
+ if (result instanceof Promise) result = await result;
912
+ if (result.issues.length) {
913
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
914
+ captureStackTrace(e, params?.callee);
915
+ throw e;
916
+ }
917
+ return result.value;
918
+ };
919
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
920
+ const ctx = _ctx ? {
921
+ ..._ctx,
922
+ async: false
923
+ } : { async: false };
924
+ const result = schema._zod.run({
925
+ value,
926
+ issues: []
927
+ }, ctx);
928
+ if (result instanceof Promise) throw new $ZodAsyncError();
929
+ return result.issues.length ? {
930
+ success: false,
931
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
932
+ } : {
933
+ success: true,
934
+ data: result.value
935
+ };
936
+ };
937
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
938
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
939
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
940
+ let result = schema._zod.run({
941
+ value,
942
+ issues: []
943
+ }, ctx);
944
+ if (result instanceof Promise) result = await result;
945
+ return result.issues.length ? {
946
+ success: false,
947
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
948
+ } : {
949
+ success: true,
950
+ data: result.value
951
+ };
952
+ };
953
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
954
+ const _encode = (_Err) => (schema, value, _ctx) => {
955
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
956
+ return _parse(_Err)(schema, value, ctx);
957
+ };
958
+ const _decode = (_Err) => (schema, value, _ctx) => {
959
+ return _parse(_Err)(schema, value, _ctx);
960
+ };
961
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
962
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
963
+ return _parseAsync(_Err)(schema, value, ctx);
964
+ };
965
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
966
+ return _parseAsync(_Err)(schema, value, _ctx);
967
+ };
968
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
969
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
970
+ return _safeParse(_Err)(schema, value, ctx);
971
+ };
972
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
973
+ return _safeParse(_Err)(schema, value, _ctx);
974
+ };
975
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
976
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
977
+ return _safeParseAsync(_Err)(schema, value, ctx);
978
+ };
979
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
980
+ return _safeParseAsync(_Err)(schema, value, _ctx);
981
+ };
982
+
983
+ //#endregion
984
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/regexes.js
985
+ const cuid = /^[cC][^\s-]{8,}$/;
986
+ const cuid2 = /^[0-9a-z]+$/;
987
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
988
+ const xid = /^[0-9a-vA-V]{20}$/;
989
+ const ksuid = /^[A-Za-z0-9]{27}$/;
990
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
991
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
992
+ 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)?)?)$/;
993
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
994
+ 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})$/;
995
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
996
+ *
997
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
998
+ const uuid = (version) => {
999
+ if (!version) 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)$/;
1000
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1001
+ };
1002
+ /** Practical email validation */
1003
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1004
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1005
+ function emoji() {
1006
+ return new RegExp(_emoji$1, "u");
1007
+ }
1008
+ 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])$/;
1009
+ 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}|:))$/;
1010
+ 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])$/;
1011
+ 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])$/;
1012
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
1013
+ const base64url = /^[A-Za-z0-9_-]*$/;
1014
+ const e164 = /^\+[1-9]\d{6,14}$/;
1015
+ 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])))`;
1016
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
1017
+ function timeSource(args) {
1018
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
1019
+ return 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+)?)?`;
1020
+ }
1021
+ function time$1(args) {
1022
+ return new RegExp(`^${timeSource(args)}$`);
1023
+ }
1024
+ function datetime$1(args) {
1025
+ const time = timeSource({ precision: args.precision });
1026
+ const opts = ["Z"];
1027
+ if (args.local) opts.push("");
1028
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
1029
+ const timeRegex = `${time}(?:${opts.join("|")})`;
1030
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1031
+ }
1032
+ const string$1 = (params) => {
1033
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1034
+ return new RegExp(`^${regex}$`);
1035
+ };
1036
+ const integer = /^-?\d+$/;
1037
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
1038
+ const boolean$1 = /^(?:true|false)$/i;
1039
+ const lowercase = /^[^A-Z]*$/;
1040
+ const uppercase = /^[^a-z]*$/;
1041
+
1042
+ //#endregion
1043
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
1044
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
1045
+ var _a;
1046
+ inst._zod ?? (inst._zod = {});
1047
+ inst._zod.def = def;
1048
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
1049
+ });
1050
+ const numericOriginMap = {
1051
+ number: "number",
1052
+ bigint: "bigint",
1053
+ object: "date"
1054
+ };
1055
+ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst, def) => {
1056
+ $ZodCheck.init(inst, def);
1057
+ const origin = numericOriginMap[typeof def.value];
1058
+ inst._zod.onattach.push((inst) => {
1059
+ const bag = inst._zod.bag;
1060
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
1061
+ if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
1062
+ else bag.exclusiveMaximum = def.value;
1063
+ });
1064
+ inst._zod.check = (payload) => {
1065
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
1066
+ payload.issues.push({
1067
+ origin,
1068
+ code: "too_big",
1069
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
1070
+ input: payload.value,
1071
+ inclusive: def.inclusive,
1072
+ inst,
1073
+ continue: !def.abort
1074
+ });
1075
+ };
1076
+ });
1077
+ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan", (inst, def) => {
1078
+ $ZodCheck.init(inst, def);
1079
+ const origin = numericOriginMap[typeof def.value];
1080
+ inst._zod.onattach.push((inst) => {
1081
+ const bag = inst._zod.bag;
1082
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
1083
+ if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
1084
+ else bag.exclusiveMinimum = def.value;
1085
+ });
1086
+ inst._zod.check = (payload) => {
1087
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
1088
+ payload.issues.push({
1089
+ origin,
1090
+ code: "too_small",
1091
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
1092
+ input: payload.value,
1093
+ inclusive: def.inclusive,
1094
+ inst,
1095
+ continue: !def.abort
1096
+ });
1097
+ };
1098
+ });
1099
+ const $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
1100
+ $ZodCheck.init(inst, def);
1101
+ inst._zod.onattach.push((inst) => {
1102
+ var _a;
1103
+ (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
1104
+ });
1105
+ inst._zod.check = (payload) => {
1106
+ if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
1107
+ if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1108
+ payload.issues.push({
1109
+ origin: typeof payload.value,
1110
+ code: "not_multiple_of",
1111
+ divisor: def.value,
1112
+ input: payload.value,
1113
+ inst,
1114
+ continue: !def.abort
1115
+ });
1116
+ };
1117
+ });
1118
+ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat", (inst, def) => {
1119
+ $ZodCheck.init(inst, def);
1120
+ def.format = def.format || "float64";
1121
+ const isInt = def.format?.includes("int");
1122
+ const origin = isInt ? "int" : "number";
1123
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
1124
+ inst._zod.onattach.push((inst) => {
1125
+ const bag = inst._zod.bag;
1126
+ bag.format = def.format;
1127
+ bag.minimum = minimum;
1128
+ bag.maximum = maximum;
1129
+ if (isInt) bag.pattern = integer;
1130
+ });
1131
+ inst._zod.check = (payload) => {
1132
+ const input = payload.value;
1133
+ if (isInt) {
1134
+ if (!Number.isInteger(input)) {
1135
+ payload.issues.push({
1136
+ expected: origin,
1137
+ format: def.format,
1138
+ code: "invalid_type",
1139
+ continue: false,
1140
+ input,
1141
+ inst
1142
+ });
1143
+ return;
1144
+ }
1145
+ if (!Number.isSafeInteger(input)) {
1146
+ if (input > 0) payload.issues.push({
1147
+ input,
1148
+ code: "too_big",
1149
+ maximum: Number.MAX_SAFE_INTEGER,
1150
+ note: "Integers must be within the safe integer range.",
1151
+ inst,
1152
+ origin,
1153
+ inclusive: true,
1154
+ continue: !def.abort
1155
+ });
1156
+ else payload.issues.push({
1157
+ input,
1158
+ code: "too_small",
1159
+ minimum: Number.MIN_SAFE_INTEGER,
1160
+ note: "Integers must be within the safe integer range.",
1161
+ inst,
1162
+ origin,
1163
+ inclusive: true,
1164
+ continue: !def.abort
1165
+ });
1166
+ return;
1167
+ }
1168
+ }
1169
+ if (input < minimum) payload.issues.push({
1170
+ origin: "number",
1171
+ input,
1172
+ code: "too_small",
1173
+ minimum,
1174
+ inclusive: true,
1175
+ inst,
1176
+ continue: !def.abort
1177
+ });
1178
+ if (input > maximum) payload.issues.push({
1179
+ origin: "number",
1180
+ input,
1181
+ code: "too_big",
1182
+ maximum,
1183
+ inclusive: true,
1184
+ inst,
1185
+ continue: !def.abort
1186
+ });
1187
+ };
1188
+ });
1189
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
1190
+ var _a;
1191
+ $ZodCheck.init(inst, def);
1192
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1193
+ const val = payload.value;
1194
+ return !nullish(val) && val.length !== void 0;
1195
+ });
1196
+ inst._zod.onattach.push((inst) => {
1197
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1198
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
1199
+ });
1200
+ inst._zod.check = (payload) => {
1201
+ const input = payload.value;
1202
+ if (input.length <= def.maximum) return;
1203
+ const origin = getLengthableOrigin(input);
1204
+ payload.issues.push({
1205
+ origin,
1206
+ code: "too_big",
1207
+ maximum: def.maximum,
1208
+ inclusive: true,
1209
+ input,
1210
+ inst,
1211
+ continue: !def.abort
1212
+ });
1213
+ };
1214
+ });
1215
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
1216
+ var _a;
1217
+ $ZodCheck.init(inst, def);
1218
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1219
+ const val = payload.value;
1220
+ return !nullish(val) && val.length !== void 0;
1221
+ });
1222
+ inst._zod.onattach.push((inst) => {
1223
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
1224
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
1225
+ });
1226
+ inst._zod.check = (payload) => {
1227
+ const input = payload.value;
1228
+ if (input.length >= def.minimum) return;
1229
+ const origin = getLengthableOrigin(input);
1230
+ payload.issues.push({
1231
+ origin,
1232
+ code: "too_small",
1233
+ minimum: def.minimum,
1234
+ inclusive: true,
1235
+ input,
1236
+ inst,
1237
+ continue: !def.abort
1238
+ });
1239
+ };
1240
+ });
1241
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1242
+ var _a;
1243
+ $ZodCheck.init(inst, def);
1244
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1245
+ const val = payload.value;
1246
+ return !nullish(val) && val.length !== void 0;
1247
+ });
1248
+ inst._zod.onattach.push((inst) => {
1249
+ const bag = inst._zod.bag;
1250
+ bag.minimum = def.length;
1251
+ bag.maximum = def.length;
1252
+ bag.length = def.length;
1253
+ });
1254
+ inst._zod.check = (payload) => {
1255
+ const input = payload.value;
1256
+ const length = input.length;
1257
+ if (length === def.length) return;
1258
+ const origin = getLengthableOrigin(input);
1259
+ const tooBig = length > def.length;
1260
+ payload.issues.push({
1261
+ origin,
1262
+ ...tooBig ? {
1263
+ code: "too_big",
1264
+ maximum: def.length
1265
+ } : {
1266
+ code: "too_small",
1267
+ minimum: def.length
1268
+ },
1269
+ inclusive: true,
1270
+ exact: true,
1271
+ input: payload.value,
1272
+ inst,
1273
+ continue: !def.abort
1274
+ });
1275
+ };
1276
+ });
1277
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
1278
+ var _a, _b;
1279
+ $ZodCheck.init(inst, def);
1280
+ inst._zod.onattach.push((inst) => {
1281
+ const bag = inst._zod.bag;
1282
+ bag.format = def.format;
1283
+ if (def.pattern) {
1284
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1285
+ bag.patterns.add(def.pattern);
1286
+ }
1287
+ });
1288
+ if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
1289
+ def.pattern.lastIndex = 0;
1290
+ if (def.pattern.test(payload.value)) return;
1291
+ payload.issues.push({
1292
+ origin: "string",
1293
+ code: "invalid_format",
1294
+ format: def.format,
1295
+ input: payload.value,
1296
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
1297
+ inst,
1298
+ continue: !def.abort
1299
+ });
1300
+ });
1301
+ else (_b = inst._zod).check ?? (_b.check = () => {});
1302
+ });
1303
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
1304
+ $ZodCheckStringFormat.init(inst, def);
1305
+ inst._zod.check = (payload) => {
1306
+ def.pattern.lastIndex = 0;
1307
+ if (def.pattern.test(payload.value)) return;
1308
+ payload.issues.push({
1309
+ origin: "string",
1310
+ code: "invalid_format",
1311
+ format: "regex",
1312
+ input: payload.value,
1313
+ pattern: def.pattern.toString(),
1314
+ inst,
1315
+ continue: !def.abort
1316
+ });
1317
+ };
1318
+ });
1319
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
1320
+ def.pattern ?? (def.pattern = lowercase);
1321
+ $ZodCheckStringFormat.init(inst, def);
1322
+ });
1323
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
1324
+ def.pattern ?? (def.pattern = uppercase);
1325
+ $ZodCheckStringFormat.init(inst, def);
1326
+ });
1327
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
1328
+ $ZodCheck.init(inst, def);
1329
+ const escapedRegex = escapeRegex(def.includes);
1330
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1331
+ def.pattern = pattern;
1332
+ inst._zod.onattach.push((inst) => {
1333
+ const bag = inst._zod.bag;
1334
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1335
+ bag.patterns.add(pattern);
1336
+ });
1337
+ inst._zod.check = (payload) => {
1338
+ if (payload.value.includes(def.includes, def.position)) return;
1339
+ payload.issues.push({
1340
+ origin: "string",
1341
+ code: "invalid_format",
1342
+ format: "includes",
1343
+ includes: def.includes,
1344
+ input: payload.value,
1345
+ inst,
1346
+ continue: !def.abort
1347
+ });
1348
+ };
1349
+ });
1350
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
1351
+ $ZodCheck.init(inst, def);
1352
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1353
+ def.pattern ?? (def.pattern = pattern);
1354
+ inst._zod.onattach.push((inst) => {
1355
+ const bag = inst._zod.bag;
1356
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1357
+ bag.patterns.add(pattern);
1358
+ });
1359
+ inst._zod.check = (payload) => {
1360
+ if (payload.value.startsWith(def.prefix)) return;
1361
+ payload.issues.push({
1362
+ origin: "string",
1363
+ code: "invalid_format",
1364
+ format: "starts_with",
1365
+ prefix: def.prefix,
1366
+ input: payload.value,
1367
+ inst,
1368
+ continue: !def.abort
1369
+ });
1370
+ };
1371
+ });
1372
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
1373
+ $ZodCheck.init(inst, def);
1374
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1375
+ def.pattern ?? (def.pattern = pattern);
1376
+ inst._zod.onattach.push((inst) => {
1377
+ const bag = inst._zod.bag;
1378
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1379
+ bag.patterns.add(pattern);
1380
+ });
1381
+ inst._zod.check = (payload) => {
1382
+ if (payload.value.endsWith(def.suffix)) return;
1383
+ payload.issues.push({
1384
+ origin: "string",
1385
+ code: "invalid_format",
1386
+ format: "ends_with",
1387
+ suffix: def.suffix,
1388
+ input: payload.value,
1389
+ inst,
1390
+ continue: !def.abort
1391
+ });
1392
+ };
1393
+ });
1394
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
1395
+ $ZodCheck.init(inst, def);
1396
+ inst._zod.check = (payload) => {
1397
+ payload.value = def.tx(payload.value);
1398
+ };
1399
+ });
1400
+
1401
+ //#endregion
1402
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/doc.js
1403
+ var Doc = class {
1404
+ constructor(args = []) {
1405
+ this.content = [];
1406
+ this.indent = 0;
1407
+ if (this) this.args = args;
1408
+ }
1409
+ indented(fn) {
1410
+ this.indent += 1;
1411
+ fn(this);
1412
+ this.indent -= 1;
1413
+ }
1414
+ write(arg) {
1415
+ if (typeof arg === "function") {
1416
+ arg(this, { execution: "sync" });
1417
+ arg(this, { execution: "async" });
1418
+ return;
1419
+ }
1420
+ const lines = arg.split("\n").filter((x) => x);
1421
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
1422
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
1423
+ for (const line of dedented) this.content.push(line);
1424
+ }
1425
+ compile() {
1426
+ const F = Function;
1427
+ const args = this?.args;
1428
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1429
+ return new F(...args, lines.join("\n"));
1430
+ }
1431
+ };
1432
+
1433
+ //#endregion
1434
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.js
1435
+ const version = {
1436
+ major: 4,
1437
+ minor: 3,
1438
+ patch: 6
1439
+ };
1440
+
1441
+ //#endregion
1442
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
1443
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1444
+ var _a;
1445
+ inst ?? (inst = {});
1446
+ inst._zod.def = def;
1447
+ inst._zod.bag = inst._zod.bag || {};
1448
+ inst._zod.version = version;
1449
+ const checks = [...inst._zod.def.checks ?? []];
1450
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1451
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1452
+ if (checks.length === 0) {
1453
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1454
+ inst._zod.deferred?.push(() => {
1455
+ inst._zod.run = inst._zod.parse;
1456
+ });
1457
+ } else {
1458
+ const runChecks = (payload, checks, ctx) => {
1459
+ let isAborted = aborted(payload);
1460
+ let asyncResult;
1461
+ for (const ch of checks) {
1462
+ if (ch._zod.def.when) {
1463
+ if (!ch._zod.def.when(payload)) continue;
1464
+ } else if (isAborted) continue;
1465
+ const currLen = payload.issues.length;
1466
+ const _ = ch._zod.check(payload);
1467
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1468
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1469
+ await _;
1470
+ if (payload.issues.length === currLen) return;
1471
+ if (!isAborted) isAborted = aborted(payload, currLen);
1472
+ });
1473
+ else {
1474
+ if (payload.issues.length === currLen) continue;
1475
+ if (!isAborted) isAborted = aborted(payload, currLen);
1476
+ }
1477
+ }
1478
+ if (asyncResult) return asyncResult.then(() => {
1479
+ return payload;
1480
+ });
1481
+ return payload;
1482
+ };
1483
+ const handleCanaryResult = (canary, payload, ctx) => {
1484
+ if (aborted(canary)) {
1485
+ canary.aborted = true;
1486
+ return canary;
1487
+ }
1488
+ const checkResult = runChecks(payload, checks, ctx);
1489
+ if (checkResult instanceof Promise) {
1490
+ if (ctx.async === false) throw new $ZodAsyncError();
1491
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1492
+ }
1493
+ return inst._zod.parse(checkResult, ctx);
1494
+ };
1495
+ inst._zod.run = (payload, ctx) => {
1496
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1497
+ if (ctx.direction === "backward") {
1498
+ const canary = inst._zod.parse({
1499
+ value: payload.value,
1500
+ issues: []
1501
+ }, {
1502
+ ...ctx,
1503
+ skipChecks: true
1504
+ });
1505
+ if (canary instanceof Promise) return canary.then((canary) => {
1506
+ return handleCanaryResult(canary, payload, ctx);
1507
+ });
1508
+ return handleCanaryResult(canary, payload, ctx);
1509
+ }
1510
+ const result = inst._zod.parse(payload, ctx);
1511
+ if (result instanceof Promise) {
1512
+ if (ctx.async === false) throw new $ZodAsyncError();
1513
+ return result.then((result) => runChecks(result, checks, ctx));
1514
+ }
1515
+ return runChecks(result, checks, ctx);
1516
+ };
1517
+ }
1518
+ defineLazy(inst, "~standard", () => ({
1519
+ validate: (value) => {
1520
+ try {
1521
+ const r = safeParse$1(inst, value);
1522
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1523
+ } catch (_) {
1524
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1525
+ }
1526
+ },
1527
+ vendor: "zod",
1528
+ version: 1
1529
+ }));
1530
+ });
1531
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1532
+ $ZodType.init(inst, def);
1533
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1534
+ inst._zod.parse = (payload, _) => {
1535
+ if (def.coerce) try {
1536
+ payload.value = String(payload.value);
1537
+ } catch (_) {}
1538
+ if (typeof payload.value === "string") return payload;
1539
+ payload.issues.push({
1540
+ expected: "string",
1541
+ code: "invalid_type",
1542
+ input: payload.value,
1543
+ inst
1544
+ });
1545
+ return payload;
1546
+ };
1547
+ });
1548
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
1549
+ $ZodCheckStringFormat.init(inst, def);
1550
+ $ZodString.init(inst, def);
1551
+ });
1552
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
1553
+ def.pattern ?? (def.pattern = guid);
1554
+ $ZodStringFormat.init(inst, def);
1555
+ });
1556
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1557
+ if (def.version) {
1558
+ const v = {
1559
+ v1: 1,
1560
+ v2: 2,
1561
+ v3: 3,
1562
+ v4: 4,
1563
+ v5: 5,
1564
+ v6: 6,
1565
+ v7: 7,
1566
+ v8: 8
1567
+ }[def.version];
1568
+ if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1569
+ def.pattern ?? (def.pattern = uuid(v));
1570
+ } else def.pattern ?? (def.pattern = uuid());
1571
+ $ZodStringFormat.init(inst, def);
1572
+ });
1573
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1574
+ def.pattern ?? (def.pattern = email);
1575
+ $ZodStringFormat.init(inst, def);
1576
+ });
1577
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1578
+ $ZodStringFormat.init(inst, def);
1579
+ inst._zod.check = (payload) => {
1580
+ try {
1581
+ const trimmed = payload.value.trim();
1582
+ const url = new URL(trimmed);
1583
+ if (def.hostname) {
1584
+ def.hostname.lastIndex = 0;
1585
+ if (!def.hostname.test(url.hostname)) payload.issues.push({
1586
+ code: "invalid_format",
1587
+ format: "url",
1588
+ note: "Invalid hostname",
1589
+ pattern: def.hostname.source,
1590
+ input: payload.value,
1591
+ inst,
1592
+ continue: !def.abort
1593
+ });
1594
+ }
1595
+ if (def.protocol) {
1596
+ def.protocol.lastIndex = 0;
1597
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1598
+ code: "invalid_format",
1599
+ format: "url",
1600
+ note: "Invalid protocol",
1601
+ pattern: def.protocol.source,
1602
+ input: payload.value,
1603
+ inst,
1604
+ continue: !def.abort
1605
+ });
1606
+ }
1607
+ if (def.normalize) payload.value = url.href;
1608
+ else payload.value = trimmed;
1609
+ return;
1610
+ } catch (_) {
1611
+ payload.issues.push({
1612
+ code: "invalid_format",
1613
+ format: "url",
1614
+ input: payload.value,
1615
+ inst,
1616
+ continue: !def.abort
1617
+ });
1618
+ }
1619
+ };
1620
+ });
1621
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1622
+ def.pattern ?? (def.pattern = emoji());
1623
+ $ZodStringFormat.init(inst, def);
1624
+ });
1625
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1626
+ def.pattern ?? (def.pattern = nanoid);
1627
+ $ZodStringFormat.init(inst, def);
1628
+ });
1629
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1630
+ def.pattern ?? (def.pattern = cuid);
1631
+ $ZodStringFormat.init(inst, def);
1632
+ });
1633
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1634
+ def.pattern ?? (def.pattern = cuid2);
1635
+ $ZodStringFormat.init(inst, def);
1636
+ });
1637
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1638
+ def.pattern ?? (def.pattern = ulid);
1639
+ $ZodStringFormat.init(inst, def);
1640
+ });
1641
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1642
+ def.pattern ?? (def.pattern = xid);
1643
+ $ZodStringFormat.init(inst, def);
1644
+ });
1645
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1646
+ def.pattern ?? (def.pattern = ksuid);
1647
+ $ZodStringFormat.init(inst, def);
1648
+ });
1649
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1650
+ def.pattern ?? (def.pattern = datetime$1(def));
1651
+ $ZodStringFormat.init(inst, def);
1652
+ });
1653
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1654
+ def.pattern ?? (def.pattern = date$1);
1655
+ $ZodStringFormat.init(inst, def);
1656
+ });
1657
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1658
+ def.pattern ?? (def.pattern = time$1(def));
1659
+ $ZodStringFormat.init(inst, def);
1660
+ });
1661
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1662
+ def.pattern ?? (def.pattern = duration$1);
1663
+ $ZodStringFormat.init(inst, def);
1664
+ });
1665
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1666
+ def.pattern ?? (def.pattern = ipv4);
1667
+ $ZodStringFormat.init(inst, def);
1668
+ inst._zod.bag.format = `ipv4`;
1669
+ });
1670
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1671
+ def.pattern ?? (def.pattern = ipv6);
1672
+ $ZodStringFormat.init(inst, def);
1673
+ inst._zod.bag.format = `ipv6`;
1674
+ inst._zod.check = (payload) => {
1675
+ try {
1676
+ new URL(`http://[${payload.value}]`);
1677
+ } catch {
1678
+ payload.issues.push({
1679
+ code: "invalid_format",
1680
+ format: "ipv6",
1681
+ input: payload.value,
1682
+ inst,
1683
+ continue: !def.abort
1684
+ });
1685
+ }
1686
+ };
1687
+ });
1688
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1689
+ def.pattern ?? (def.pattern = cidrv4);
1690
+ $ZodStringFormat.init(inst, def);
1691
+ });
1692
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1693
+ def.pattern ?? (def.pattern = cidrv6);
1694
+ $ZodStringFormat.init(inst, def);
1695
+ inst._zod.check = (payload) => {
1696
+ const parts = payload.value.split("/");
1697
+ try {
1698
+ if (parts.length !== 2) throw new Error();
1699
+ const [address, prefix] = parts;
1700
+ if (!prefix) throw new Error();
1701
+ const prefixNum = Number(prefix);
1702
+ if (`${prefixNum}` !== prefix) throw new Error();
1703
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
1704
+ new URL(`http://[${address}]`);
1705
+ } catch {
1706
+ payload.issues.push({
1707
+ code: "invalid_format",
1708
+ format: "cidrv6",
1709
+ input: payload.value,
1710
+ inst,
1711
+ continue: !def.abort
1712
+ });
1713
+ }
1714
+ };
1715
+ });
1716
+ function isValidBase64(data) {
1717
+ if (data === "") return true;
1718
+ if (data.length % 4 !== 0) return false;
1719
+ try {
1720
+ atob(data);
1721
+ return true;
1722
+ } catch {
1723
+ return false;
1724
+ }
1725
+ }
1726
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1727
+ def.pattern ?? (def.pattern = base64);
1728
+ $ZodStringFormat.init(inst, def);
1729
+ inst._zod.bag.contentEncoding = "base64";
1730
+ inst._zod.check = (payload) => {
1731
+ if (isValidBase64(payload.value)) return;
1732
+ payload.issues.push({
1733
+ code: "invalid_format",
1734
+ format: "base64",
1735
+ input: payload.value,
1736
+ inst,
1737
+ continue: !def.abort
1738
+ });
1739
+ };
1740
+ });
1741
+ function isValidBase64URL(data) {
1742
+ if (!base64url.test(data)) return false;
1743
+ const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1744
+ return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1745
+ }
1746
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1747
+ def.pattern ?? (def.pattern = base64url);
1748
+ $ZodStringFormat.init(inst, def);
1749
+ inst._zod.bag.contentEncoding = "base64url";
1750
+ inst._zod.check = (payload) => {
1751
+ if (isValidBase64URL(payload.value)) return;
1752
+ payload.issues.push({
1753
+ code: "invalid_format",
1754
+ format: "base64url",
1755
+ input: payload.value,
1756
+ inst,
1757
+ continue: !def.abort
1758
+ });
1759
+ };
1760
+ });
1761
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1762
+ def.pattern ?? (def.pattern = e164);
1763
+ $ZodStringFormat.init(inst, def);
1764
+ });
1765
+ function isValidJWT(token, algorithm = null) {
1766
+ try {
1767
+ const tokensParts = token.split(".");
1768
+ if (tokensParts.length !== 3) return false;
1769
+ const [header] = tokensParts;
1770
+ if (!header) return false;
1771
+ const parsedHeader = JSON.parse(atob(header));
1772
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1773
+ if (!parsedHeader.alg) return false;
1774
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1775
+ return true;
1776
+ } catch {
1777
+ return false;
1778
+ }
1779
+ }
1780
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1781
+ $ZodStringFormat.init(inst, def);
1782
+ inst._zod.check = (payload) => {
1783
+ if (isValidJWT(payload.value, def.alg)) return;
1784
+ payload.issues.push({
1785
+ code: "invalid_format",
1786
+ format: "jwt",
1787
+ input: payload.value,
1788
+ inst,
1789
+ continue: !def.abort
1790
+ });
1791
+ };
1792
+ });
1793
+ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
1794
+ $ZodType.init(inst, def);
1795
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1796
+ inst._zod.parse = (payload, _ctx) => {
1797
+ if (def.coerce) try {
1798
+ payload.value = Number(payload.value);
1799
+ } catch (_) {}
1800
+ const input = payload.value;
1801
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1802
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1803
+ payload.issues.push({
1804
+ expected: "number",
1805
+ code: "invalid_type",
1806
+ input,
1807
+ inst,
1808
+ ...received ? { received } : {}
1809
+ });
1810
+ return payload;
1811
+ };
1812
+ });
1813
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
1814
+ $ZodCheckNumberFormat.init(inst, def);
1815
+ $ZodNumber.init(inst, def);
1816
+ });
1817
+ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1818
+ $ZodType.init(inst, def);
1819
+ inst._zod.pattern = boolean$1;
1820
+ inst._zod.parse = (payload, _ctx) => {
1821
+ if (def.coerce) try {
1822
+ payload.value = Boolean(payload.value);
1823
+ } catch (_) {}
1824
+ const input = payload.value;
1825
+ if (typeof input === "boolean") return payload;
1826
+ payload.issues.push({
1827
+ expected: "boolean",
1828
+ code: "invalid_type",
1829
+ input,
1830
+ inst
1831
+ });
1832
+ return payload;
1833
+ };
1834
+ });
1835
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1836
+ $ZodType.init(inst, def);
1837
+ inst._zod.parse = (payload) => payload;
1838
+ });
1839
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1840
+ $ZodType.init(inst, def);
1841
+ inst._zod.parse = (payload, _ctx) => {
1842
+ payload.issues.push({
1843
+ expected: "never",
1844
+ code: "invalid_type",
1845
+ input: payload.value,
1846
+ inst
1847
+ });
1848
+ return payload;
1849
+ };
1850
+ });
1851
+ function handleArrayResult(result, final, index) {
1852
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1853
+ final.value[index] = result.value;
1854
+ }
1855
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1856
+ $ZodType.init(inst, def);
1857
+ inst._zod.parse = (payload, ctx) => {
1858
+ const input = payload.value;
1859
+ if (!Array.isArray(input)) {
1860
+ payload.issues.push({
1861
+ expected: "array",
1862
+ code: "invalid_type",
1863
+ input,
1864
+ inst
1865
+ });
1866
+ return payload;
1867
+ }
1868
+ payload.value = Array(input.length);
1869
+ const proms = [];
1870
+ for (let i = 0; i < input.length; i++) {
1871
+ const item = input[i];
1872
+ const result = def.element._zod.run({
1873
+ value: item,
1874
+ issues: []
1875
+ }, ctx);
1876
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1877
+ else handleArrayResult(result, payload, i);
1878
+ }
1879
+ if (proms.length) return Promise.all(proms).then(() => payload);
1880
+ return payload;
1881
+ };
1882
+ });
1883
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1884
+ if (result.issues.length) {
1885
+ if (isOptionalOut && !(key in input)) return;
1886
+ final.issues.push(...prefixIssues(key, result.issues));
1887
+ }
1888
+ if (result.value === void 0) {
1889
+ if (key in input) final.value[key] = void 0;
1890
+ } else final.value[key] = result.value;
1891
+ }
1892
+ function normalizeDef(def) {
1893
+ const keys = Object.keys(def.shape);
1894
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1895
+ const okeys = optionalKeys(def.shape);
1896
+ return {
1897
+ ...def,
1898
+ keys,
1899
+ keySet: new Set(keys),
1900
+ numKeys: keys.length,
1901
+ optionalKeys: new Set(okeys)
1902
+ };
1903
+ }
1904
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1905
+ const unrecognized = [];
1906
+ const keySet = def.keySet;
1907
+ const _catchall = def.catchall._zod;
1908
+ const t = _catchall.def.type;
1909
+ const isOptionalOut = _catchall.optout === "optional";
1910
+ for (const key in input) {
1911
+ if (keySet.has(key)) continue;
1912
+ if (t === "never") {
1913
+ unrecognized.push(key);
1914
+ continue;
1915
+ }
1916
+ const r = _catchall.run({
1917
+ value: input[key],
1918
+ issues: []
1919
+ }, ctx);
1920
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1921
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1922
+ }
1923
+ if (unrecognized.length) payload.issues.push({
1924
+ code: "unrecognized_keys",
1925
+ keys: unrecognized,
1926
+ input,
1927
+ inst
1928
+ });
1929
+ if (!proms.length) return payload;
1930
+ return Promise.all(proms).then(() => {
1931
+ return payload;
1932
+ });
1933
+ }
1934
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1935
+ $ZodType.init(inst, def);
1936
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1937
+ const sh = def.shape;
1938
+ Object.defineProperty(def, "shape", { get: () => {
1939
+ const newSh = { ...sh };
1940
+ Object.defineProperty(def, "shape", { value: newSh });
1941
+ return newSh;
1942
+ } });
1943
+ }
1944
+ const _normalized = cached(() => normalizeDef(def));
1945
+ defineLazy(inst._zod, "propValues", () => {
1946
+ const shape = def.shape;
1947
+ const propValues = {};
1948
+ for (const key in shape) {
1949
+ const field = shape[key]._zod;
1950
+ if (field.values) {
1951
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1952
+ for (const v of field.values) propValues[key].add(v);
1953
+ }
1954
+ }
1955
+ return propValues;
1956
+ });
1957
+ const isObject$2 = isObject;
1958
+ const catchall = def.catchall;
1959
+ let value;
1960
+ inst._zod.parse = (payload, ctx) => {
1961
+ value ?? (value = _normalized.value);
1962
+ const input = payload.value;
1963
+ if (!isObject$2(input)) {
1964
+ payload.issues.push({
1965
+ expected: "object",
1966
+ code: "invalid_type",
1967
+ input,
1968
+ inst
1969
+ });
1970
+ return payload;
1971
+ }
1972
+ payload.value = {};
1973
+ const proms = [];
1974
+ const shape = value.shape;
1975
+ for (const key of value.keys) {
1976
+ const el = shape[key];
1977
+ const isOptionalOut = el._zod.optout === "optional";
1978
+ const r = el._zod.run({
1979
+ value: input[key],
1980
+ issues: []
1981
+ }, ctx);
1982
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
1983
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
1984
+ }
1985
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1986
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1987
+ };
1988
+ });
1989
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1990
+ $ZodObject.init(inst, def);
1991
+ const superParse = inst._zod.parse;
1992
+ const _normalized = cached(() => normalizeDef(def));
1993
+ const generateFastpass = (shape) => {
1994
+ const doc = new Doc([
1995
+ "shape",
1996
+ "payload",
1997
+ "ctx"
1998
+ ]);
1999
+ const normalized = _normalized.value;
2000
+ const parseStr = (key) => {
2001
+ const k = esc(key);
2002
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2003
+ };
2004
+ doc.write(`const input = payload.value;`);
2005
+ const ids = Object.create(null);
2006
+ let counter = 0;
2007
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2008
+ doc.write(`const newResult = {};`);
2009
+ for (const key of normalized.keys) {
2010
+ const id = ids[key];
2011
+ const k = esc(key);
2012
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
2013
+ doc.write(`const ${id} = ${parseStr(key)};`);
2014
+ if (isOptionalOut) doc.write(`
2015
+ if (${id}.issues.length) {
2016
+ if (${k} in input) {
2017
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2018
+ ...iss,
2019
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2020
+ })));
2021
+ }
2022
+ }
2023
+
2024
+ if (${id}.value === undefined) {
2025
+ if (${k} in input) {
2026
+ newResult[${k}] = undefined;
2027
+ }
2028
+ } else {
2029
+ newResult[${k}] = ${id}.value;
2030
+ }
2031
+
2032
+ `);
2033
+ else doc.write(`
2034
+ if (${id}.issues.length) {
2035
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2036
+ ...iss,
2037
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2038
+ })));
2039
+ }
2040
+
2041
+ if (${id}.value === undefined) {
2042
+ if (${k} in input) {
2043
+ newResult[${k}] = undefined;
2044
+ }
2045
+ } else {
2046
+ newResult[${k}] = ${id}.value;
2047
+ }
2048
+
2049
+ `);
2050
+ }
2051
+ doc.write(`payload.value = newResult;`);
2052
+ doc.write(`return payload;`);
2053
+ const fn = doc.compile();
2054
+ return (payload, ctx) => fn(shape, payload, ctx);
2055
+ };
2056
+ let fastpass;
2057
+ const isObject$1 = isObject;
2058
+ const jit = !globalConfig.jitless;
2059
+ const allowsEval$1 = allowsEval;
2060
+ const fastEnabled = jit && allowsEval$1.value;
2061
+ const catchall = def.catchall;
2062
+ let value;
2063
+ inst._zod.parse = (payload, ctx) => {
2064
+ value ?? (value = _normalized.value);
2065
+ const input = payload.value;
2066
+ if (!isObject$1(input)) {
2067
+ payload.issues.push({
2068
+ expected: "object",
2069
+ code: "invalid_type",
2070
+ input,
2071
+ inst
2072
+ });
2073
+ return payload;
2074
+ }
2075
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
2076
+ if (!fastpass) fastpass = generateFastpass(def.shape);
2077
+ payload = fastpass(payload, ctx);
2078
+ if (!catchall) return payload;
2079
+ return handleCatchall([], input, payload, ctx, value, inst);
2080
+ }
2081
+ return superParse(payload, ctx);
2082
+ };
2083
+ });
2084
+ function handleUnionResults(results, final, inst, ctx) {
2085
+ for (const result of results) if (result.issues.length === 0) {
2086
+ final.value = result.value;
2087
+ return final;
2088
+ }
2089
+ const nonaborted = results.filter((r) => !aborted(r));
2090
+ if (nonaborted.length === 1) {
2091
+ final.value = nonaborted[0].value;
2092
+ return nonaborted[0];
2093
+ }
2094
+ final.issues.push({
2095
+ code: "invalid_union",
2096
+ input: final.value,
2097
+ inst,
2098
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
2099
+ });
2100
+ return final;
2101
+ }
2102
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
2103
+ $ZodType.init(inst, def);
2104
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
2105
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2106
+ defineLazy(inst._zod, "values", () => {
2107
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2108
+ });
2109
+ defineLazy(inst._zod, "pattern", () => {
2110
+ if (def.options.every((o) => o._zod.pattern)) {
2111
+ const patterns = def.options.map((o) => o._zod.pattern);
2112
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2113
+ }
2114
+ });
2115
+ const single = def.options.length === 1;
2116
+ const first = def.options[0]._zod.run;
2117
+ inst._zod.parse = (payload, ctx) => {
2118
+ if (single) return first(payload, ctx);
2119
+ let async = false;
2120
+ const results = [];
2121
+ for (const option of def.options) {
2122
+ const result = option._zod.run({
2123
+ value: payload.value,
2124
+ issues: []
2125
+ }, ctx);
2126
+ if (result instanceof Promise) {
2127
+ results.push(result);
2128
+ async = true;
2129
+ } else {
2130
+ if (result.issues.length === 0) return result;
2131
+ results.push(result);
2132
+ }
2133
+ }
2134
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
2135
+ return Promise.all(results).then((results) => {
2136
+ return handleUnionResults(results, payload, inst, ctx);
2137
+ });
2138
+ };
2139
+ });
2140
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
2141
+ $ZodType.init(inst, def);
2142
+ inst._zod.parse = (payload, ctx) => {
2143
+ const input = payload.value;
2144
+ const left = def.left._zod.run({
2145
+ value: input,
2146
+ issues: []
2147
+ }, ctx);
2148
+ const right = def.right._zod.run({
2149
+ value: input,
2150
+ issues: []
2151
+ }, ctx);
2152
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
2153
+ return handleIntersectionResults(payload, left, right);
2154
+ });
2155
+ return handleIntersectionResults(payload, left, right);
2156
+ };
2157
+ });
2158
+ function mergeValues(a, b) {
2159
+ if (a === b) return {
2160
+ valid: true,
2161
+ data: a
2162
+ };
2163
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
2164
+ valid: true,
2165
+ data: a
2166
+ };
2167
+ if (isPlainObject(a) && isPlainObject(b)) {
2168
+ const bKeys = Object.keys(b);
2169
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
2170
+ const newObj = {
2171
+ ...a,
2172
+ ...b
2173
+ };
2174
+ for (const key of sharedKeys) {
2175
+ const sharedValue = mergeValues(a[key], b[key]);
2176
+ if (!sharedValue.valid) return {
2177
+ valid: false,
2178
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
2179
+ };
2180
+ newObj[key] = sharedValue.data;
2181
+ }
2182
+ return {
2183
+ valid: true,
2184
+ data: newObj
2185
+ };
2186
+ }
2187
+ if (Array.isArray(a) && Array.isArray(b)) {
2188
+ if (a.length !== b.length) return {
2189
+ valid: false,
2190
+ mergeErrorPath: []
2191
+ };
2192
+ const newArray = [];
2193
+ for (let index = 0; index < a.length; index++) {
2194
+ const itemA = a[index];
2195
+ const itemB = b[index];
2196
+ const sharedValue = mergeValues(itemA, itemB);
2197
+ if (!sharedValue.valid) return {
2198
+ valid: false,
2199
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
2200
+ };
2201
+ newArray.push(sharedValue.data);
2202
+ }
2203
+ return {
2204
+ valid: true,
2205
+ data: newArray
2206
+ };
2207
+ }
2208
+ return {
2209
+ valid: false,
2210
+ mergeErrorPath: []
2211
+ };
2212
+ }
2213
+ function handleIntersectionResults(result, left, right) {
2214
+ const unrecKeys = /* @__PURE__ */ new Map();
2215
+ let unrecIssue;
2216
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
2217
+ unrecIssue ?? (unrecIssue = iss);
2218
+ for (const k of iss.keys) {
2219
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2220
+ unrecKeys.get(k).l = true;
2221
+ }
2222
+ } else result.issues.push(iss);
2223
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2224
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2225
+ unrecKeys.get(k).r = true;
2226
+ }
2227
+ else result.issues.push(iss);
2228
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2229
+ if (bothKeys.length && unrecIssue) result.issues.push({
2230
+ ...unrecIssue,
2231
+ keys: bothKeys
2232
+ });
2233
+ if (aborted(result)) return result;
2234
+ const merged = mergeValues(left.value, right.value);
2235
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2236
+ result.value = merged.data;
2237
+ return result;
2238
+ }
2239
+ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2240
+ $ZodType.init(inst, def);
2241
+ inst._zod.parse = (payload, ctx) => {
2242
+ const input = payload.value;
2243
+ if (!isPlainObject(input)) {
2244
+ payload.issues.push({
2245
+ expected: "record",
2246
+ code: "invalid_type",
2247
+ input,
2248
+ inst
2249
+ });
2250
+ return payload;
2251
+ }
2252
+ const proms = [];
2253
+ const values = def.keyType._zod.values;
2254
+ if (values) {
2255
+ payload.value = {};
2256
+ const recordKeys = /* @__PURE__ */ new Set();
2257
+ for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2258
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
2259
+ const result = def.valueType._zod.run({
2260
+ value: input[key],
2261
+ issues: []
2262
+ }, ctx);
2263
+ if (result instanceof Promise) proms.push(result.then((result) => {
2264
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2265
+ payload.value[key] = result.value;
2266
+ }));
2267
+ else {
2268
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2269
+ payload.value[key] = result.value;
2270
+ }
2271
+ }
2272
+ let unrecognized;
2273
+ for (const key in input) if (!recordKeys.has(key)) {
2274
+ unrecognized = unrecognized ?? [];
2275
+ unrecognized.push(key);
2276
+ }
2277
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
2278
+ code: "unrecognized_keys",
2279
+ input,
2280
+ inst,
2281
+ keys: unrecognized
2282
+ });
2283
+ } else {
2284
+ payload.value = {};
2285
+ for (const key of Reflect.ownKeys(input)) {
2286
+ if (key === "__proto__") continue;
2287
+ let keyResult = def.keyType._zod.run({
2288
+ value: key,
2289
+ issues: []
2290
+ }, ctx);
2291
+ if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2292
+ if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
2293
+ const retryResult = def.keyType._zod.run({
2294
+ value: Number(key),
2295
+ issues: []
2296
+ }, ctx);
2297
+ if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
2298
+ if (retryResult.issues.length === 0) keyResult = retryResult;
2299
+ }
2300
+ if (keyResult.issues.length) {
2301
+ if (def.mode === "loose") payload.value[key] = input[key];
2302
+ else payload.issues.push({
2303
+ code: "invalid_key",
2304
+ origin: "record",
2305
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2306
+ input: key,
2307
+ path: [key],
2308
+ inst
2309
+ });
2310
+ continue;
2311
+ }
2312
+ const result = def.valueType._zod.run({
2313
+ value: input[key],
2314
+ issues: []
2315
+ }, ctx);
2316
+ if (result instanceof Promise) proms.push(result.then((result) => {
2317
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2318
+ payload.value[keyResult.value] = result.value;
2319
+ }));
2320
+ else {
2321
+ if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2322
+ payload.value[keyResult.value] = result.value;
2323
+ }
2324
+ }
2325
+ }
2326
+ if (proms.length) return Promise.all(proms).then(() => payload);
2327
+ return payload;
2328
+ };
2329
+ });
2330
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2331
+ $ZodType.init(inst, def);
2332
+ const values = getEnumValues(def.entries);
2333
+ const valuesSet = new Set(values);
2334
+ inst._zod.values = valuesSet;
2335
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2336
+ inst._zod.parse = (payload, _ctx) => {
2337
+ const input = payload.value;
2338
+ if (valuesSet.has(input)) return payload;
2339
+ payload.issues.push({
2340
+ code: "invalid_value",
2341
+ values,
2342
+ input,
2343
+ inst
2344
+ });
2345
+ return payload;
2346
+ };
2347
+ });
2348
+ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
2349
+ $ZodType.init(inst, def);
2350
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
2351
+ const values = new Set(def.values);
2352
+ inst._zod.values = values;
2353
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2354
+ inst._zod.parse = (payload, _ctx) => {
2355
+ const input = payload.value;
2356
+ if (values.has(input)) return payload;
2357
+ payload.issues.push({
2358
+ code: "invalid_value",
2359
+ values: def.values,
2360
+ input,
2361
+ inst
2362
+ });
2363
+ return payload;
2364
+ };
2365
+ });
2366
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
2367
+ $ZodType.init(inst, def);
2368
+ inst._zod.parse = (payload, ctx) => {
2369
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2370
+ const _out = def.transform(payload.value, payload);
2371
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2372
+ payload.value = output;
2373
+ return payload;
2374
+ });
2375
+ if (_out instanceof Promise) throw new $ZodAsyncError();
2376
+ payload.value = _out;
2377
+ return payload;
2378
+ };
2379
+ });
2380
+ function handleOptionalResult(result, input) {
2381
+ if (result.issues.length && input === void 0) return {
2382
+ issues: [],
2383
+ value: void 0
2384
+ };
2385
+ return result;
2386
+ }
2387
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2388
+ $ZodType.init(inst, def);
2389
+ inst._zod.optin = "optional";
2390
+ inst._zod.optout = "optional";
2391
+ defineLazy(inst._zod, "values", () => {
2392
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2393
+ });
2394
+ defineLazy(inst._zod, "pattern", () => {
2395
+ const pattern = def.innerType._zod.pattern;
2396
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2397
+ });
2398
+ inst._zod.parse = (payload, ctx) => {
2399
+ if (def.innerType._zod.optin === "optional") {
2400
+ const result = def.innerType._zod.run(payload, ctx);
2401
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
2402
+ return handleOptionalResult(result, payload.value);
2403
+ }
2404
+ if (payload.value === void 0) return payload;
2405
+ return def.innerType._zod.run(payload, ctx);
2406
+ };
2407
+ });
2408
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2409
+ $ZodOptional.init(inst, def);
2410
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2411
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2412
+ inst._zod.parse = (payload, ctx) => {
2413
+ return def.innerType._zod.run(payload, ctx);
2414
+ };
2415
+ });
2416
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2417
+ $ZodType.init(inst, def);
2418
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2419
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2420
+ defineLazy(inst._zod, "pattern", () => {
2421
+ const pattern = def.innerType._zod.pattern;
2422
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2423
+ });
2424
+ defineLazy(inst._zod, "values", () => {
2425
+ return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2426
+ });
2427
+ inst._zod.parse = (payload, ctx) => {
2428
+ if (payload.value === null) return payload;
2429
+ return def.innerType._zod.run(payload, ctx);
2430
+ };
2431
+ });
2432
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
2433
+ $ZodType.init(inst, def);
2434
+ inst._zod.optin = "optional";
2435
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2436
+ inst._zod.parse = (payload, ctx) => {
2437
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2438
+ if (payload.value === void 0) {
2439
+ payload.value = def.defaultValue;
2440
+ /**
2441
+ * $ZodDefault returns the default value immediately in forward direction.
2442
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2443
+ return payload;
2444
+ }
2445
+ const result = def.innerType._zod.run(payload, ctx);
2446
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2447
+ return handleDefaultResult(result, def);
2448
+ };
2449
+ });
2450
+ function handleDefaultResult(payload, def) {
2451
+ if (payload.value === void 0) payload.value = def.defaultValue;
2452
+ return payload;
2453
+ }
2454
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
2455
+ $ZodType.init(inst, def);
2456
+ inst._zod.optin = "optional";
2457
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2458
+ inst._zod.parse = (payload, ctx) => {
2459
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2460
+ if (payload.value === void 0) payload.value = def.defaultValue;
2461
+ return def.innerType._zod.run(payload, ctx);
2462
+ };
2463
+ });
2464
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
2465
+ $ZodType.init(inst, def);
2466
+ defineLazy(inst._zod, "values", () => {
2467
+ const v = def.innerType._zod.values;
2468
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2469
+ });
2470
+ inst._zod.parse = (payload, ctx) => {
2471
+ const result = def.innerType._zod.run(payload, ctx);
2472
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2473
+ return handleNonOptionalResult(result, inst);
2474
+ };
2475
+ });
2476
+ function handleNonOptionalResult(payload, inst) {
2477
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2478
+ code: "invalid_type",
2479
+ expected: "nonoptional",
2480
+ input: payload.value,
2481
+ inst
2482
+ });
2483
+ return payload;
2484
+ }
2485
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
2486
+ $ZodType.init(inst, def);
2487
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2488
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2489
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2490
+ inst._zod.parse = (payload, ctx) => {
2491
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2492
+ const result = def.innerType._zod.run(payload, ctx);
2493
+ if (result instanceof Promise) return result.then((result) => {
2494
+ payload.value = result.value;
2495
+ if (result.issues.length) {
2496
+ payload.value = def.catchValue({
2497
+ ...payload,
2498
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2499
+ input: payload.value
2500
+ });
2501
+ payload.issues = [];
2502
+ }
2503
+ return payload;
2504
+ });
2505
+ payload.value = result.value;
2506
+ if (result.issues.length) {
2507
+ payload.value = def.catchValue({
2508
+ ...payload,
2509
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2510
+ input: payload.value
2511
+ });
2512
+ payload.issues = [];
2513
+ }
2514
+ return payload;
2515
+ };
2516
+ });
2517
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
2518
+ $ZodType.init(inst, def);
2519
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2520
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2521
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2522
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2523
+ inst._zod.parse = (payload, ctx) => {
2524
+ if (ctx.direction === "backward") {
2525
+ const right = def.out._zod.run(payload, ctx);
2526
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2527
+ return handlePipeResult(right, def.in, ctx);
2528
+ }
2529
+ const left = def.in._zod.run(payload, ctx);
2530
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2531
+ return handlePipeResult(left, def.out, ctx);
2532
+ };
2533
+ });
2534
+ function handlePipeResult(left, next, ctx) {
2535
+ if (left.issues.length) {
2536
+ left.aborted = true;
2537
+ return left;
2538
+ }
2539
+ return next._zod.run({
2540
+ value: left.value,
2541
+ issues: left.issues
2542
+ }, ctx);
2543
+ }
2544
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
2545
+ $ZodType.init(inst, def);
2546
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2547
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2548
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2549
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2550
+ inst._zod.parse = (payload, ctx) => {
2551
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2552
+ const result = def.innerType._zod.run(payload, ctx);
2553
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
2554
+ return handleReadonlyResult(result);
2555
+ };
2556
+ });
2557
+ function handleReadonlyResult(payload) {
2558
+ payload.value = Object.freeze(payload.value);
2559
+ return payload;
2560
+ }
2561
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
2562
+ $ZodCheck.init(inst, def);
2563
+ $ZodType.init(inst, def);
2564
+ inst._zod.parse = (payload, _) => {
2565
+ return payload;
2566
+ };
2567
+ inst._zod.check = (payload) => {
2568
+ const input = payload.value;
2569
+ const r = def.fn(input);
2570
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2571
+ handleRefineResult(r, payload, input, inst);
2572
+ };
2573
+ });
2574
+ function handleRefineResult(result, payload, input, inst) {
2575
+ if (!result) {
2576
+ const _iss = {
2577
+ code: "custom",
2578
+ input,
2579
+ inst,
2580
+ path: [...inst._zod.def.path ?? []],
2581
+ continue: !inst._zod.def.abort
2582
+ };
2583
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2584
+ payload.issues.push(issue(_iss));
2585
+ }
2586
+ }
2587
+
2588
+ //#endregion
2589
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
2590
+ var _a;
2591
+ var $ZodRegistry = class {
2592
+ constructor() {
2593
+ this._map = /* @__PURE__ */ new WeakMap();
2594
+ this._idmap = /* @__PURE__ */ new Map();
2595
+ }
2596
+ add(schema, ..._meta) {
2597
+ const meta = _meta[0];
2598
+ this._map.set(schema, meta);
2599
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2600
+ return this;
2601
+ }
2602
+ clear() {
2603
+ this._map = /* @__PURE__ */ new WeakMap();
2604
+ this._idmap = /* @__PURE__ */ new Map();
2605
+ return this;
2606
+ }
2607
+ remove(schema) {
2608
+ const meta = this._map.get(schema);
2609
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2610
+ this._map.delete(schema);
2611
+ return this;
2612
+ }
2613
+ get(schema) {
2614
+ const p = schema._zod.parent;
2615
+ if (p) {
2616
+ const pm = { ...this.get(p) ?? {} };
2617
+ delete pm.id;
2618
+ const f = {
2619
+ ...pm,
2620
+ ...this._map.get(schema)
2621
+ };
2622
+ return Object.keys(f).length ? f : void 0;
2623
+ }
2624
+ return this._map.get(schema);
2625
+ }
2626
+ has(schema) {
2627
+ return this._map.has(schema);
2628
+ }
2629
+ };
2630
+ function registry() {
2631
+ return new $ZodRegistry();
2632
+ }
2633
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2634
+ const globalRegistry = globalThis.__zod_globalRegistry;
2635
+
2636
+ //#endregion
2637
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/api.js
2638
+ /* @__NO_SIDE_EFFECTS__ */
2639
+ function _string(Class, params) {
2640
+ return new Class({
2641
+ type: "string",
2642
+ ...normalizeParams(params)
2643
+ });
2644
+ }
2645
+ /* @__NO_SIDE_EFFECTS__ */
2646
+ function _email(Class, params) {
2647
+ return new Class({
2648
+ type: "string",
2649
+ format: "email",
2650
+ check: "string_format",
2651
+ abort: false,
2652
+ ...normalizeParams(params)
2653
+ });
2654
+ }
2655
+ /* @__NO_SIDE_EFFECTS__ */
2656
+ function _guid(Class, params) {
2657
+ return new Class({
2658
+ type: "string",
2659
+ format: "guid",
2660
+ check: "string_format",
2661
+ abort: false,
2662
+ ...normalizeParams(params)
2663
+ });
2664
+ }
2665
+ /* @__NO_SIDE_EFFECTS__ */
2666
+ function _uuid(Class, params) {
2667
+ return new Class({
2668
+ type: "string",
2669
+ format: "uuid",
2670
+ check: "string_format",
2671
+ abort: false,
2672
+ ...normalizeParams(params)
2673
+ });
2674
+ }
2675
+ /* @__NO_SIDE_EFFECTS__ */
2676
+ function _uuidv4(Class, params) {
2677
+ return new Class({
2678
+ type: "string",
2679
+ format: "uuid",
2680
+ check: "string_format",
2681
+ abort: false,
2682
+ version: "v4",
2683
+ ...normalizeParams(params)
2684
+ });
2685
+ }
2686
+ /* @__NO_SIDE_EFFECTS__ */
2687
+ function _uuidv6(Class, params) {
2688
+ return new Class({
2689
+ type: "string",
2690
+ format: "uuid",
2691
+ check: "string_format",
2692
+ abort: false,
2693
+ version: "v6",
2694
+ ...normalizeParams(params)
2695
+ });
2696
+ }
2697
+ /* @__NO_SIDE_EFFECTS__ */
2698
+ function _uuidv7(Class, params) {
2699
+ return new Class({
2700
+ type: "string",
2701
+ format: "uuid",
2702
+ check: "string_format",
2703
+ abort: false,
2704
+ version: "v7",
2705
+ ...normalizeParams(params)
2706
+ });
2707
+ }
2708
+ /* @__NO_SIDE_EFFECTS__ */
2709
+ function _url(Class, params) {
2710
+ return new Class({
2711
+ type: "string",
2712
+ format: "url",
2713
+ check: "string_format",
2714
+ abort: false,
2715
+ ...normalizeParams(params)
2716
+ });
2717
+ }
2718
+ /* @__NO_SIDE_EFFECTS__ */
2719
+ function _emoji(Class, params) {
2720
+ return new Class({
2721
+ type: "string",
2722
+ format: "emoji",
2723
+ check: "string_format",
2724
+ abort: false,
2725
+ ...normalizeParams(params)
2726
+ });
2727
+ }
2728
+ /* @__NO_SIDE_EFFECTS__ */
2729
+ function _nanoid(Class, params) {
2730
+ return new Class({
2731
+ type: "string",
2732
+ format: "nanoid",
2733
+ check: "string_format",
2734
+ abort: false,
2735
+ ...normalizeParams(params)
2736
+ });
2737
+ }
2738
+ /* @__NO_SIDE_EFFECTS__ */
2739
+ function _cuid(Class, params) {
2740
+ return new Class({
2741
+ type: "string",
2742
+ format: "cuid",
2743
+ check: "string_format",
2744
+ abort: false,
2745
+ ...normalizeParams(params)
2746
+ });
2747
+ }
2748
+ /* @__NO_SIDE_EFFECTS__ */
2749
+ function _cuid2(Class, params) {
2750
+ return new Class({
2751
+ type: "string",
2752
+ format: "cuid2",
2753
+ check: "string_format",
2754
+ abort: false,
2755
+ ...normalizeParams(params)
2756
+ });
2757
+ }
2758
+ /* @__NO_SIDE_EFFECTS__ */
2759
+ function _ulid(Class, params) {
2760
+ return new Class({
2761
+ type: "string",
2762
+ format: "ulid",
2763
+ check: "string_format",
2764
+ abort: false,
2765
+ ...normalizeParams(params)
2766
+ });
2767
+ }
2768
+ /* @__NO_SIDE_EFFECTS__ */
2769
+ function _xid(Class, params) {
2770
+ return new Class({
2771
+ type: "string",
2772
+ format: "xid",
2773
+ check: "string_format",
2774
+ abort: false,
2775
+ ...normalizeParams(params)
2776
+ });
2777
+ }
2778
+ /* @__NO_SIDE_EFFECTS__ */
2779
+ function _ksuid(Class, params) {
2780
+ return new Class({
2781
+ type: "string",
2782
+ format: "ksuid",
2783
+ check: "string_format",
2784
+ abort: false,
2785
+ ...normalizeParams(params)
2786
+ });
2787
+ }
2788
+ /* @__NO_SIDE_EFFECTS__ */
2789
+ function _ipv4(Class, params) {
2790
+ return new Class({
2791
+ type: "string",
2792
+ format: "ipv4",
2793
+ check: "string_format",
2794
+ abort: false,
2795
+ ...normalizeParams(params)
2796
+ });
2797
+ }
2798
+ /* @__NO_SIDE_EFFECTS__ */
2799
+ function _ipv6(Class, params) {
2800
+ return new Class({
2801
+ type: "string",
2802
+ format: "ipv6",
2803
+ check: "string_format",
2804
+ abort: false,
2805
+ ...normalizeParams(params)
2806
+ });
2807
+ }
2808
+ /* @__NO_SIDE_EFFECTS__ */
2809
+ function _cidrv4(Class, params) {
2810
+ return new Class({
2811
+ type: "string",
2812
+ format: "cidrv4",
2813
+ check: "string_format",
2814
+ abort: false,
2815
+ ...normalizeParams(params)
2816
+ });
2817
+ }
2818
+ /* @__NO_SIDE_EFFECTS__ */
2819
+ function _cidrv6(Class, params) {
2820
+ return new Class({
2821
+ type: "string",
2822
+ format: "cidrv6",
2823
+ check: "string_format",
2824
+ abort: false,
2825
+ ...normalizeParams(params)
2826
+ });
2827
+ }
2828
+ /* @__NO_SIDE_EFFECTS__ */
2829
+ function _base64(Class, params) {
2830
+ return new Class({
2831
+ type: "string",
2832
+ format: "base64",
2833
+ check: "string_format",
2834
+ abort: false,
2835
+ ...normalizeParams(params)
2836
+ });
2837
+ }
2838
+ /* @__NO_SIDE_EFFECTS__ */
2839
+ function _base64url(Class, params) {
2840
+ return new Class({
2841
+ type: "string",
2842
+ format: "base64url",
2843
+ check: "string_format",
2844
+ abort: false,
2845
+ ...normalizeParams(params)
2846
+ });
2847
+ }
2848
+ /* @__NO_SIDE_EFFECTS__ */
2849
+ function _e164(Class, params) {
2850
+ return new Class({
2851
+ type: "string",
2852
+ format: "e164",
2853
+ check: "string_format",
2854
+ abort: false,
2855
+ ...normalizeParams(params)
2856
+ });
2857
+ }
2858
+ /* @__NO_SIDE_EFFECTS__ */
2859
+ function _jwt(Class, params) {
2860
+ return new Class({
2861
+ type: "string",
2862
+ format: "jwt",
2863
+ check: "string_format",
2864
+ abort: false,
2865
+ ...normalizeParams(params)
2866
+ });
2867
+ }
2868
+ /* @__NO_SIDE_EFFECTS__ */
2869
+ function _isoDateTime(Class, params) {
2870
+ return new Class({
2871
+ type: "string",
2872
+ format: "datetime",
2873
+ check: "string_format",
2874
+ offset: false,
2875
+ local: false,
2876
+ precision: null,
2877
+ ...normalizeParams(params)
2878
+ });
2879
+ }
2880
+ /* @__NO_SIDE_EFFECTS__ */
2881
+ function _isoDate(Class, params) {
2882
+ return new Class({
2883
+ type: "string",
2884
+ format: "date",
2885
+ check: "string_format",
2886
+ ...normalizeParams(params)
2887
+ });
2888
+ }
2889
+ /* @__NO_SIDE_EFFECTS__ */
2890
+ function _isoTime(Class, params) {
2891
+ return new Class({
2892
+ type: "string",
2893
+ format: "time",
2894
+ check: "string_format",
2895
+ precision: null,
2896
+ ...normalizeParams(params)
2897
+ });
2898
+ }
2899
+ /* @__NO_SIDE_EFFECTS__ */
2900
+ function _isoDuration(Class, params) {
2901
+ return new Class({
2902
+ type: "string",
2903
+ format: "duration",
2904
+ check: "string_format",
2905
+ ...normalizeParams(params)
2906
+ });
2907
+ }
2908
+ /* @__NO_SIDE_EFFECTS__ */
2909
+ function _number(Class, params) {
2910
+ return new Class({
2911
+ type: "number",
2912
+ checks: [],
2913
+ ...normalizeParams(params)
2914
+ });
2915
+ }
2916
+ /* @__NO_SIDE_EFFECTS__ */
2917
+ function _int(Class, params) {
2918
+ return new Class({
2919
+ type: "number",
2920
+ check: "number_format",
2921
+ abort: false,
2922
+ format: "safeint",
2923
+ ...normalizeParams(params)
2924
+ });
2925
+ }
2926
+ /* @__NO_SIDE_EFFECTS__ */
2927
+ function _boolean(Class, params) {
2928
+ return new Class({
2929
+ type: "boolean",
2930
+ ...normalizeParams(params)
2931
+ });
2932
+ }
2933
+ /* @__NO_SIDE_EFFECTS__ */
2934
+ function _unknown(Class) {
2935
+ return new Class({ type: "unknown" });
2936
+ }
2937
+ /* @__NO_SIDE_EFFECTS__ */
2938
+ function _never(Class, params) {
2939
+ return new Class({
2940
+ type: "never",
2941
+ ...normalizeParams(params)
2942
+ });
2943
+ }
2944
+ /* @__NO_SIDE_EFFECTS__ */
2945
+ function _lt(value, params) {
2946
+ return new $ZodCheckLessThan({
2947
+ check: "less_than",
2948
+ ...normalizeParams(params),
2949
+ value,
2950
+ inclusive: false
2951
+ });
2952
+ }
2953
+ /* @__NO_SIDE_EFFECTS__ */
2954
+ function _lte(value, params) {
2955
+ return new $ZodCheckLessThan({
2956
+ check: "less_than",
2957
+ ...normalizeParams(params),
2958
+ value,
2959
+ inclusive: true
2960
+ });
2961
+ }
2962
+ /* @__NO_SIDE_EFFECTS__ */
2963
+ function _gt(value, params) {
2964
+ return new $ZodCheckGreaterThan({
2965
+ check: "greater_than",
2966
+ ...normalizeParams(params),
2967
+ value,
2968
+ inclusive: false
2969
+ });
2970
+ }
2971
+ /* @__NO_SIDE_EFFECTS__ */
2972
+ function _gte(value, params) {
2973
+ return new $ZodCheckGreaterThan({
2974
+ check: "greater_than",
2975
+ ...normalizeParams(params),
2976
+ value,
2977
+ inclusive: true
2978
+ });
2979
+ }
2980
+ /* @__NO_SIDE_EFFECTS__ */
2981
+ function _multipleOf(value, params) {
2982
+ return new $ZodCheckMultipleOf({
2983
+ check: "multiple_of",
2984
+ ...normalizeParams(params),
2985
+ value
2986
+ });
2987
+ }
2988
+ /* @__NO_SIDE_EFFECTS__ */
2989
+ function _maxLength(maximum, params) {
2990
+ return new $ZodCheckMaxLength({
2991
+ check: "max_length",
2992
+ ...normalizeParams(params),
2993
+ maximum
2994
+ });
2995
+ }
2996
+ /* @__NO_SIDE_EFFECTS__ */
2997
+ function _minLength(minimum, params) {
2998
+ return new $ZodCheckMinLength({
2999
+ check: "min_length",
3000
+ ...normalizeParams(params),
3001
+ minimum
3002
+ });
3003
+ }
3004
+ /* @__NO_SIDE_EFFECTS__ */
3005
+ function _length(length, params) {
3006
+ return new $ZodCheckLengthEquals({
3007
+ check: "length_equals",
3008
+ ...normalizeParams(params),
3009
+ length
3010
+ });
3011
+ }
3012
+ /* @__NO_SIDE_EFFECTS__ */
3013
+ function _regex(pattern, params) {
3014
+ return new $ZodCheckRegex({
3015
+ check: "string_format",
3016
+ format: "regex",
3017
+ ...normalizeParams(params),
3018
+ pattern
3019
+ });
3020
+ }
3021
+ /* @__NO_SIDE_EFFECTS__ */
3022
+ function _lowercase(params) {
3023
+ return new $ZodCheckLowerCase({
3024
+ check: "string_format",
3025
+ format: "lowercase",
3026
+ ...normalizeParams(params)
3027
+ });
3028
+ }
3029
+ /* @__NO_SIDE_EFFECTS__ */
3030
+ function _uppercase(params) {
3031
+ return new $ZodCheckUpperCase({
3032
+ check: "string_format",
3033
+ format: "uppercase",
3034
+ ...normalizeParams(params)
3035
+ });
3036
+ }
3037
+ /* @__NO_SIDE_EFFECTS__ */
3038
+ function _includes(includes, params) {
3039
+ return new $ZodCheckIncludes({
3040
+ check: "string_format",
3041
+ format: "includes",
3042
+ ...normalizeParams(params),
3043
+ includes
3044
+ });
3045
+ }
3046
+ /* @__NO_SIDE_EFFECTS__ */
3047
+ function _startsWith(prefix, params) {
3048
+ return new $ZodCheckStartsWith({
3049
+ check: "string_format",
3050
+ format: "starts_with",
3051
+ ...normalizeParams(params),
3052
+ prefix
3053
+ });
3054
+ }
3055
+ /* @__NO_SIDE_EFFECTS__ */
3056
+ function _endsWith(suffix, params) {
3057
+ return new $ZodCheckEndsWith({
3058
+ check: "string_format",
3059
+ format: "ends_with",
3060
+ ...normalizeParams(params),
3061
+ suffix
3062
+ });
3063
+ }
3064
+ /* @__NO_SIDE_EFFECTS__ */
3065
+ function _overwrite(tx) {
3066
+ return new $ZodCheckOverwrite({
3067
+ check: "overwrite",
3068
+ tx
3069
+ });
3070
+ }
3071
+ /* @__NO_SIDE_EFFECTS__ */
3072
+ function _normalize(form) {
3073
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
3074
+ }
3075
+ /* @__NO_SIDE_EFFECTS__ */
3076
+ function _trim() {
3077
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
3078
+ }
3079
+ /* @__NO_SIDE_EFFECTS__ */
3080
+ function _toLowerCase() {
3081
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
3082
+ }
3083
+ /* @__NO_SIDE_EFFECTS__ */
3084
+ function _toUpperCase() {
3085
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
3086
+ }
3087
+ /* @__NO_SIDE_EFFECTS__ */
3088
+ function _slugify() {
3089
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
3090
+ }
3091
+ /* @__NO_SIDE_EFFECTS__ */
3092
+ function _array(Class, element, params) {
3093
+ return new Class({
3094
+ type: "array",
3095
+ element,
3096
+ ...normalizeParams(params)
3097
+ });
3098
+ }
3099
+ /* @__NO_SIDE_EFFECTS__ */
3100
+ function _refine(Class, fn, _params) {
3101
+ return new Class({
3102
+ type: "custom",
3103
+ check: "custom",
3104
+ fn,
3105
+ ...normalizeParams(_params)
3106
+ });
3107
+ }
3108
+ /* @__NO_SIDE_EFFECTS__ */
3109
+ function _superRefine(fn) {
3110
+ const ch = /* @__PURE__ */ _check((payload) => {
3111
+ payload.addIssue = (issue$2) => {
3112
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
3113
+ else {
3114
+ const _issue = issue$2;
3115
+ if (_issue.fatal) _issue.continue = false;
3116
+ _issue.code ?? (_issue.code = "custom");
3117
+ _issue.input ?? (_issue.input = payload.value);
3118
+ _issue.inst ?? (_issue.inst = ch);
3119
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
3120
+ payload.issues.push(issue(_issue));
3121
+ }
3122
+ };
3123
+ return fn(payload.value, payload);
3124
+ });
3125
+ return ch;
3126
+ }
3127
+ /* @__NO_SIDE_EFFECTS__ */
3128
+ function _check(fn, params) {
3129
+ const ch = new $ZodCheck({
3130
+ check: "custom",
3131
+ ...normalizeParams(params)
3132
+ });
3133
+ ch._zod.check = fn;
3134
+ return ch;
3135
+ }
3136
+
3137
+ //#endregion
3138
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
3139
+ function initializeContext(params) {
3140
+ let target = params?.target ?? "draft-2020-12";
3141
+ if (target === "draft-4") target = "draft-04";
3142
+ if (target === "draft-7") target = "draft-07";
3143
+ return {
3144
+ processors: params.processors ?? {},
3145
+ metadataRegistry: params?.metadata ?? globalRegistry,
3146
+ target,
3147
+ unrepresentable: params?.unrepresentable ?? "throw",
3148
+ override: params?.override ?? (() => {}),
3149
+ io: params?.io ?? "output",
3150
+ counter: 0,
3151
+ seen: /* @__PURE__ */ new Map(),
3152
+ cycles: params?.cycles ?? "ref",
3153
+ reused: params?.reused ?? "inline",
3154
+ external: params?.external ?? void 0
3155
+ };
3156
+ }
3157
+ function process$1(schema, ctx, _params = {
3158
+ path: [],
3159
+ schemaPath: []
3160
+ }) {
3161
+ var _a;
3162
+ const def = schema._zod.def;
3163
+ const seen = ctx.seen.get(schema);
3164
+ if (seen) {
3165
+ seen.count++;
3166
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
3167
+ return seen.schema;
3168
+ }
3169
+ const result = {
3170
+ schema: {},
3171
+ count: 1,
3172
+ cycle: void 0,
3173
+ path: _params.path
3174
+ };
3175
+ ctx.seen.set(schema, result);
3176
+ const overrideSchema = schema._zod.toJSONSchema?.();
3177
+ if (overrideSchema) result.schema = overrideSchema;
3178
+ else {
3179
+ const params = {
3180
+ ..._params,
3181
+ schemaPath: [..._params.schemaPath, schema],
3182
+ path: _params.path
3183
+ };
3184
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
3185
+ else {
3186
+ const _json = result.schema;
3187
+ const processor = ctx.processors[def.type];
3188
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3189
+ processor(schema, ctx, _json, params);
3190
+ }
3191
+ const parent = schema._zod.parent;
3192
+ if (parent) {
3193
+ if (!result.ref) result.ref = parent;
3194
+ process$1(parent, ctx, params);
3195
+ ctx.seen.get(parent).isParent = true;
3196
+ }
3197
+ }
3198
+ const meta = ctx.metadataRegistry.get(schema);
3199
+ if (meta) Object.assign(result.schema, meta);
3200
+ if (ctx.io === "input" && isTransforming(schema)) {
3201
+ delete result.schema.examples;
3202
+ delete result.schema.default;
3203
+ }
3204
+ if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3205
+ delete result.schema._prefault;
3206
+ return ctx.seen.get(schema).schema;
3207
+ }
3208
+ function extractDefs(ctx, schema) {
3209
+ const root = ctx.seen.get(schema);
3210
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3211
+ const idToSchema = /* @__PURE__ */ new Map();
3212
+ for (const entry of ctx.seen.entries()) {
3213
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3214
+ if (id) {
3215
+ const existing = idToSchema.get(id);
3216
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3217
+ idToSchema.set(id, entry[0]);
3218
+ }
3219
+ }
3220
+ const makeURI = (entry) => {
3221
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3222
+ if (ctx.external) {
3223
+ const externalId = ctx.external.registry.get(entry[0])?.id;
3224
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
3225
+ if (externalId) return { ref: uriGenerator(externalId) };
3226
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3227
+ entry[1].defId = id;
3228
+ return {
3229
+ defId: id,
3230
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3231
+ };
3232
+ }
3233
+ if (entry[1] === root) return { ref: "#" };
3234
+ const defUriPrefix = `#/${defsSegment}/`;
3235
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3236
+ return {
3237
+ defId,
3238
+ ref: defUriPrefix + defId
3239
+ };
3240
+ };
3241
+ const extractToDef = (entry) => {
3242
+ if (entry[1].schema.$ref) return;
3243
+ const seen = entry[1];
3244
+ const { ref, defId } = makeURI(entry);
3245
+ seen.def = { ...seen.schema };
3246
+ if (defId) seen.defId = defId;
3247
+ const schema = seen.schema;
3248
+ for (const key in schema) delete schema[key];
3249
+ schema.$ref = ref;
3250
+ };
3251
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
3252
+ const seen = entry[1];
3253
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
3254
+
3255
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
3256
+ }
3257
+ for (const entry of ctx.seen.entries()) {
3258
+ const seen = entry[1];
3259
+ if (schema === entry[0]) {
3260
+ extractToDef(entry);
3261
+ continue;
3262
+ }
3263
+ if (ctx.external) {
3264
+ const ext = ctx.external.registry.get(entry[0])?.id;
3265
+ if (schema !== entry[0] && ext) {
3266
+ extractToDef(entry);
3267
+ continue;
3268
+ }
3269
+ }
3270
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
3271
+ extractToDef(entry);
3272
+ continue;
3273
+ }
3274
+ if (seen.cycle) {
3275
+ extractToDef(entry);
3276
+ continue;
3277
+ }
3278
+ if (seen.count > 1) {
3279
+ if (ctx.reused === "ref") {
3280
+ extractToDef(entry);
3281
+ continue;
3282
+ }
3283
+ }
3284
+ }
3285
+ }
3286
+ function finalize(ctx, schema) {
3287
+ const root = ctx.seen.get(schema);
3288
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3289
+ const flattenRef = (zodSchema) => {
3290
+ const seen = ctx.seen.get(zodSchema);
3291
+ if (seen.ref === null) return;
3292
+ const schema = seen.def ?? seen.schema;
3293
+ const _cached = { ...schema };
3294
+ const ref = seen.ref;
3295
+ seen.ref = null;
3296
+ if (ref) {
3297
+ flattenRef(ref);
3298
+ const refSeen = ctx.seen.get(ref);
3299
+ const refSchema = refSeen.schema;
3300
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3301
+ schema.allOf = schema.allOf ?? [];
3302
+ schema.allOf.push(refSchema);
3303
+ } else Object.assign(schema, refSchema);
3304
+ Object.assign(schema, _cached);
3305
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
3306
+ if (key === "$ref" || key === "allOf") continue;
3307
+ if (!(key in _cached)) delete schema[key];
3308
+ }
3309
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
3310
+ if (key === "$ref" || key === "allOf") continue;
3311
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
3312
+ }
3313
+ }
3314
+ const parent = zodSchema._zod.parent;
3315
+ if (parent && parent !== ref) {
3316
+ flattenRef(parent);
3317
+ const parentSeen = ctx.seen.get(parent);
3318
+ if (parentSeen?.schema.$ref) {
3319
+ schema.$ref = parentSeen.schema.$ref;
3320
+ if (parentSeen.def) for (const key in schema) {
3321
+ if (key === "$ref" || key === "allOf") continue;
3322
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
3323
+ }
3324
+ }
3325
+ }
3326
+ ctx.override({
3327
+ zodSchema,
3328
+ jsonSchema: schema,
3329
+ path: seen.path ?? []
3330
+ });
3331
+ };
3332
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3333
+ const result = {};
3334
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
3335
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
3336
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
3337
+ else if (ctx.target === "openapi-3.0") {}
3338
+ if (ctx.external?.uri) {
3339
+ const id = ctx.external.registry.get(schema)?.id;
3340
+ if (!id) throw new Error("Schema is missing an `id` property");
3341
+ result.$id = ctx.external.uri(id);
3342
+ }
3343
+ Object.assign(result, root.def ?? root.schema);
3344
+ const defs = ctx.external?.defs ?? {};
3345
+ for (const entry of ctx.seen.entries()) {
3346
+ const seen = entry[1];
3347
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
3348
+ }
3349
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3350
+ else result.definitions = defs;
3351
+ try {
3352
+ const finalized = JSON.parse(JSON.stringify(result));
3353
+ Object.defineProperty(finalized, "~standard", {
3354
+ value: {
3355
+ ...schema["~standard"],
3356
+ jsonSchema: {
3357
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3358
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3359
+ }
3360
+ },
3361
+ enumerable: false,
3362
+ writable: false
3363
+ });
3364
+ return finalized;
3365
+ } catch (_err) {
3366
+ throw new Error("Error converting schema to JSON.");
3367
+ }
3368
+ }
3369
+ function isTransforming(_schema, _ctx) {
3370
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
3371
+ if (ctx.seen.has(_schema)) return false;
3372
+ ctx.seen.add(_schema);
3373
+ const def = _schema._zod.def;
3374
+ if (def.type === "transform") return true;
3375
+ if (def.type === "array") return isTransforming(def.element, ctx);
3376
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
3377
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3378
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
3379
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3380
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3381
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3382
+ if (def.type === "object") {
3383
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
3384
+ return false;
3385
+ }
3386
+ if (def.type === "union") {
3387
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
3388
+ return false;
3389
+ }
3390
+ if (def.type === "tuple") {
3391
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
3392
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
3393
+ return false;
3394
+ }
3395
+ return false;
3396
+ }
3397
+ /**
3398
+ * Creates a toJSONSchema method for a schema instance.
3399
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3400
+ */
3401
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3402
+ const ctx = initializeContext({
3403
+ ...params,
3404
+ processors
3405
+ });
3406
+ process$1(schema, ctx);
3407
+ extractDefs(ctx, schema);
3408
+ return finalize(ctx, schema);
3409
+ };
3410
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3411
+ const { libraryOptions, target } = params ?? {};
3412
+ const ctx = initializeContext({
3413
+ ...libraryOptions ?? {},
3414
+ target,
3415
+ io,
3416
+ processors
3417
+ });
3418
+ process$1(schema, ctx);
3419
+ extractDefs(ctx, schema);
3420
+ return finalize(ctx, schema);
3421
+ };
3422
+
3423
+ //#endregion
3424
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
3425
+ const formatMap = {
3426
+ guid: "uuid",
3427
+ url: "uri",
3428
+ datetime: "date-time",
3429
+ json_string: "json-string",
3430
+ regex: ""
3431
+ };
3432
+ const stringProcessor = (schema, ctx, _json, _params) => {
3433
+ const json = _json;
3434
+ json.type = "string";
3435
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3436
+ if (typeof minimum === "number") json.minLength = minimum;
3437
+ if (typeof maximum === "number") json.maxLength = maximum;
3438
+ if (format) {
3439
+ json.format = formatMap[format] ?? format;
3440
+ if (json.format === "") delete json.format;
3441
+ if (format === "time") delete json.format;
3442
+ }
3443
+ if (contentEncoding) json.contentEncoding = contentEncoding;
3444
+ if (patterns && patterns.size > 0) {
3445
+ const regexes = [...patterns];
3446
+ if (regexes.length === 1) json.pattern = regexes[0].source;
3447
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3448
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3449
+ pattern: regex.source
3450
+ }))];
3451
+ }
3452
+ };
3453
+ const numberProcessor = (schema, ctx, _json, _params) => {
3454
+ const json = _json;
3455
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3456
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
3457
+ else json.type = "number";
3458
+ if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3459
+ json.minimum = exclusiveMinimum;
3460
+ json.exclusiveMinimum = true;
3461
+ } else json.exclusiveMinimum = exclusiveMinimum;
3462
+ if (typeof minimum === "number") {
3463
+ json.minimum = minimum;
3464
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
3465
+ else delete json.exclusiveMinimum;
3466
+ }
3467
+ if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
3468
+ json.maximum = exclusiveMaximum;
3469
+ json.exclusiveMaximum = true;
3470
+ } else json.exclusiveMaximum = exclusiveMaximum;
3471
+ if (typeof maximum === "number") {
3472
+ json.maximum = maximum;
3473
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
3474
+ else delete json.exclusiveMaximum;
3475
+ }
3476
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3477
+ };
3478
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
3479
+ json.type = "boolean";
3480
+ };
3481
+ const neverProcessor = (_schema, _ctx, json, _params) => {
3482
+ json.not = {};
3483
+ };
3484
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
3485
+ const enumProcessor = (schema, _ctx, json, _params) => {
3486
+ const def = schema._zod.def;
3487
+ const values = getEnumValues(def.entries);
3488
+ if (values.every((v) => typeof v === "number")) json.type = "number";
3489
+ if (values.every((v) => typeof v === "string")) json.type = "string";
3490
+ json.enum = values;
3491
+ };
3492
+ const literalProcessor = (schema, ctx, json, _params) => {
3493
+ const def = schema._zod.def;
3494
+ const vals = [];
3495
+ for (const val of def.values) if (val === void 0) {
3496
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3497
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3498
+ else vals.push(Number(val));
3499
+ else vals.push(val);
3500
+ if (vals.length === 0) {} else if (vals.length === 1) {
3501
+ const val = vals[0];
3502
+ json.type = val === null ? "null" : typeof val;
3503
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3504
+ else json.const = val;
3505
+ } else {
3506
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
3507
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
3508
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3509
+ if (vals.every((v) => v === null)) json.type = "null";
3510
+ json.enum = vals;
3511
+ }
3512
+ };
3513
+ const customProcessor = (_schema, ctx, _json, _params) => {
3514
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3515
+ };
3516
+ const transformProcessor = (_schema, ctx, _json, _params) => {
3517
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3518
+ };
3519
+ const arrayProcessor = (schema, ctx, _json, params) => {
3520
+ const json = _json;
3521
+ const def = schema._zod.def;
3522
+ const { minimum, maximum } = schema._zod.bag;
3523
+ if (typeof minimum === "number") json.minItems = minimum;
3524
+ if (typeof maximum === "number") json.maxItems = maximum;
3525
+ json.type = "array";
3526
+ json.items = process$1(def.element, ctx, {
3527
+ ...params,
3528
+ path: [...params.path, "items"]
3529
+ });
3530
+ };
3531
+ const objectProcessor = (schema, ctx, _json, params) => {
3532
+ const json = _json;
3533
+ const def = schema._zod.def;
3534
+ json.type = "object";
3535
+ json.properties = {};
3536
+ const shape = def.shape;
3537
+ for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
3538
+ ...params,
3539
+ path: [
3540
+ ...params.path,
3541
+ "properties",
3542
+ key
3543
+ ]
3544
+ });
3545
+ const allKeys = new Set(Object.keys(shape));
3546
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3547
+ const v = def.shape[key]._zod;
3548
+ if (ctx.io === "input") return v.optin === void 0;
3549
+ else return v.optout === void 0;
3550
+ }));
3551
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3552
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3553
+ else if (!def.catchall) {
3554
+ if (ctx.io === "output") json.additionalProperties = false;
3555
+ } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
3556
+ ...params,
3557
+ path: [...params.path, "additionalProperties"]
3558
+ });
3559
+ };
3560
+ const unionProcessor = (schema, ctx, json, params) => {
3561
+ const def = schema._zod.def;
3562
+ const isExclusive = def.inclusive === false;
3563
+ const options = def.options.map((x, i) => process$1(x, ctx, {
3564
+ ...params,
3565
+ path: [
3566
+ ...params.path,
3567
+ isExclusive ? "oneOf" : "anyOf",
3568
+ i
3569
+ ]
3570
+ }));
3571
+ if (isExclusive) json.oneOf = options;
3572
+ else json.anyOf = options;
3573
+ };
3574
+ const intersectionProcessor = (schema, ctx, json, params) => {
3575
+ const def = schema._zod.def;
3576
+ const a = process$1(def.left, ctx, {
3577
+ ...params,
3578
+ path: [
3579
+ ...params.path,
3580
+ "allOf",
3581
+ 0
3582
+ ]
3583
+ });
3584
+ const b = process$1(def.right, ctx, {
3585
+ ...params,
3586
+ path: [
3587
+ ...params.path,
3588
+ "allOf",
3589
+ 1
3590
+ ]
3591
+ });
3592
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3593
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3594
+ };
3595
+ const recordProcessor = (schema, ctx, _json, params) => {
3596
+ const json = _json;
3597
+ const def = schema._zod.def;
3598
+ json.type = "object";
3599
+ const keyType = def.keyType;
3600
+ const patterns = keyType._zod.bag?.patterns;
3601
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
3602
+ const valueSchema = process$1(def.valueType, ctx, {
3603
+ ...params,
3604
+ path: [
3605
+ ...params.path,
3606
+ "patternProperties",
3607
+ "*"
3608
+ ]
3609
+ });
3610
+ json.patternProperties = {};
3611
+ for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
3612
+ } else {
3613
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
3614
+ ...params,
3615
+ path: [...params.path, "propertyNames"]
3616
+ });
3617
+ json.additionalProperties = process$1(def.valueType, ctx, {
3618
+ ...params,
3619
+ path: [...params.path, "additionalProperties"]
3620
+ });
3621
+ }
3622
+ const keyValues = keyType._zod.values;
3623
+ if (keyValues) {
3624
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3625
+ if (validKeyValues.length > 0) json.required = validKeyValues;
3626
+ }
3627
+ };
3628
+ const nullableProcessor = (schema, ctx, json, params) => {
3629
+ const def = schema._zod.def;
3630
+ const inner = process$1(def.innerType, ctx, params);
3631
+ const seen = ctx.seen.get(schema);
3632
+ if (ctx.target === "openapi-3.0") {
3633
+ seen.ref = def.innerType;
3634
+ json.nullable = true;
3635
+ } else json.anyOf = [inner, { type: "null" }];
3636
+ };
3637
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
3638
+ const def = schema._zod.def;
3639
+ process$1(def.innerType, ctx, params);
3640
+ const seen = ctx.seen.get(schema);
3641
+ seen.ref = def.innerType;
3642
+ };
3643
+ const defaultProcessor = (schema, ctx, json, params) => {
3644
+ const def = schema._zod.def;
3645
+ process$1(def.innerType, ctx, params);
3646
+ const seen = ctx.seen.get(schema);
3647
+ seen.ref = def.innerType;
3648
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3649
+ };
3650
+ const prefaultProcessor = (schema, ctx, json, params) => {
3651
+ const def = schema._zod.def;
3652
+ process$1(def.innerType, ctx, params);
3653
+ const seen = ctx.seen.get(schema);
3654
+ seen.ref = def.innerType;
3655
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3656
+ };
3657
+ const catchProcessor = (schema, ctx, json, params) => {
3658
+ const def = schema._zod.def;
3659
+ process$1(def.innerType, ctx, params);
3660
+ const seen = ctx.seen.get(schema);
3661
+ seen.ref = def.innerType;
3662
+ let catchValue;
3663
+ try {
3664
+ catchValue = def.catchValue(void 0);
3665
+ } catch {
3666
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3667
+ }
3668
+ json.default = catchValue;
3669
+ };
3670
+ const pipeProcessor = (schema, ctx, _json, params) => {
3671
+ const def = schema._zod.def;
3672
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
3673
+ process$1(innerType, ctx, params);
3674
+ const seen = ctx.seen.get(schema);
3675
+ seen.ref = innerType;
3676
+ };
3677
+ const readonlyProcessor = (schema, ctx, json, params) => {
3678
+ const def = schema._zod.def;
3679
+ process$1(def.innerType, ctx, params);
3680
+ const seen = ctx.seen.get(schema);
3681
+ seen.ref = def.innerType;
3682
+ json.readOnly = true;
3683
+ };
3684
+ const optionalProcessor = (schema, ctx, _json, params) => {
3685
+ const def = schema._zod.def;
3686
+ process$1(def.innerType, ctx, params);
3687
+ const seen = ctx.seen.get(schema);
3688
+ seen.ref = def.innerType;
3689
+ };
3690
+
3691
+ //#endregion
3692
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/iso.js
3693
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3694
+ $ZodISODateTime.init(inst, def);
3695
+ ZodStringFormat.init(inst, def);
3696
+ });
3697
+ function datetime(params) {
3698
+ return _isoDateTime(ZodISODateTime, params);
3699
+ }
3700
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
3701
+ $ZodISODate.init(inst, def);
3702
+ ZodStringFormat.init(inst, def);
3703
+ });
3704
+ function date(params) {
3705
+ return _isoDate(ZodISODate, params);
3706
+ }
3707
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
3708
+ $ZodISOTime.init(inst, def);
3709
+ ZodStringFormat.init(inst, def);
3710
+ });
3711
+ function time(params) {
3712
+ return _isoTime(ZodISOTime, params);
3713
+ }
3714
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
3715
+ $ZodISODuration.init(inst, def);
3716
+ ZodStringFormat.init(inst, def);
3717
+ });
3718
+ function duration(params) {
3719
+ return _isoDuration(ZodISODuration, params);
3720
+ }
3721
+
3722
+ //#endregion
3723
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
3724
+ const initializer = (inst, issues) => {
3725
+ $ZodError.init(inst, issues);
3726
+ inst.name = "ZodError";
3727
+ Object.defineProperties(inst, {
3728
+ format: { value: (mapper) => formatError(inst, mapper) },
3729
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
3730
+ addIssue: { value: (issue) => {
3731
+ inst.issues.push(issue);
3732
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3733
+ } },
3734
+ addIssues: { value: (issues) => {
3735
+ inst.issues.push(...issues);
3736
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3737
+ } },
3738
+ isEmpty: { get() {
3739
+ return inst.issues.length === 0;
3740
+ } }
3741
+ });
3742
+ };
3743
+ const ZodError = $constructor("ZodError", initializer);
3744
+ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
3745
+
3746
+ //#endregion
3747
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/parse.js
3748
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
3749
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3750
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3751
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3752
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
3753
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
3754
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3755
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3756
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3757
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3758
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3759
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3760
+
3761
+ //#endregion
3762
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
3763
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3764
+ $ZodType.init(inst, def);
3765
+ Object.assign(inst["~standard"], { jsonSchema: {
3766
+ input: createStandardJSONSchemaMethod(inst, "input"),
3767
+ output: createStandardJSONSchemaMethod(inst, "output")
3768
+ } });
3769
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3770
+ inst.def = def;
3771
+ inst.type = def.type;
3772
+ Object.defineProperty(inst, "_def", { value: def });
3773
+ inst.check = (...checks) => {
3774
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
3775
+ check: ch,
3776
+ def: { check: "custom" },
3777
+ onattach: []
3778
+ } } : ch)] }), { parent: true });
3779
+ };
3780
+ inst.with = inst.check;
3781
+ inst.clone = (def, params) => clone(inst, def, params);
3782
+ inst.brand = () => inst;
3783
+ inst.register = ((reg, meta) => {
3784
+ reg.add(inst, meta);
3785
+ return inst;
3786
+ });
3787
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3788
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3789
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3790
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3791
+ inst.spa = inst.safeParseAsync;
3792
+ inst.encode = (data, params) => encode(inst, data, params);
3793
+ inst.decode = (data, params) => decode(inst, data, params);
3794
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3795
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3796
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3797
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3798
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3799
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3800
+ inst.refine = (check, params) => inst.check(refine(check, params));
3801
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3802
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
3803
+ inst.optional = () => optional(inst);
3804
+ inst.exactOptional = () => exactOptional(inst);
3805
+ inst.nullable = () => nullable(inst);
3806
+ inst.nullish = () => optional(nullable(inst));
3807
+ inst.nonoptional = (params) => nonoptional(inst, params);
3808
+ inst.array = () => array(inst);
3809
+ inst.or = (arg) => union([inst, arg]);
3810
+ inst.and = (arg) => intersection(inst, arg);
3811
+ inst.transform = (tx) => pipe(inst, transform(tx));
3812
+ inst.default = (def) => _default(inst, def);
3813
+ inst.prefault = (def) => prefault(inst, def);
3814
+ inst.catch = (params) => _catch(inst, params);
3815
+ inst.pipe = (target) => pipe(inst, target);
3816
+ inst.readonly = () => readonly(inst);
3817
+ inst.describe = (description) => {
3818
+ const cl = inst.clone();
3819
+ globalRegistry.add(cl, { description });
3820
+ return cl;
3821
+ };
3822
+ Object.defineProperty(inst, "description", {
3823
+ get() {
3824
+ return globalRegistry.get(inst)?.description;
3825
+ },
3826
+ configurable: true
3827
+ });
3828
+ inst.meta = (...args) => {
3829
+ if (args.length === 0) return globalRegistry.get(inst);
3830
+ const cl = inst.clone();
3831
+ globalRegistry.add(cl, args[0]);
3832
+ return cl;
3833
+ };
3834
+ inst.isOptional = () => inst.safeParse(void 0).success;
3835
+ inst.isNullable = () => inst.safeParse(null).success;
3836
+ inst.apply = (fn) => fn(inst);
3837
+ return inst;
3838
+ });
3839
+ /** @internal */
3840
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
3841
+ $ZodString.init(inst, def);
3842
+ ZodType.init(inst, def);
3843
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3844
+ const bag = inst._zod.bag;
3845
+ inst.format = bag.format ?? null;
3846
+ inst.minLength = bag.minimum ?? null;
3847
+ inst.maxLength = bag.maximum ?? null;
3848
+ inst.regex = (...args) => inst.check(_regex(...args));
3849
+ inst.includes = (...args) => inst.check(_includes(...args));
3850
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
3851
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
3852
+ inst.min = (...args) => inst.check(_minLength(...args));
3853
+ inst.max = (...args) => inst.check(_maxLength(...args));
3854
+ inst.length = (...args) => inst.check(_length(...args));
3855
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
3856
+ inst.lowercase = (params) => inst.check(_lowercase(params));
3857
+ inst.uppercase = (params) => inst.check(_uppercase(params));
3858
+ inst.trim = () => inst.check(_trim());
3859
+ inst.normalize = (...args) => inst.check(_normalize(...args));
3860
+ inst.toLowerCase = () => inst.check(_toLowerCase());
3861
+ inst.toUpperCase = () => inst.check(_toUpperCase());
3862
+ inst.slugify = () => inst.check(_slugify());
3863
+ });
3864
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
3865
+ $ZodString.init(inst, def);
3866
+ _ZodString.init(inst, def);
3867
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
3868
+ inst.url = (params) => inst.check(_url(ZodURL, params));
3869
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
3870
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
3871
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3872
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
3873
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
3874
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
3875
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
3876
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
3877
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
3878
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
3879
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
3880
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
3881
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
3882
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
3883
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
3884
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
3885
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
3886
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
3887
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
3888
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
3889
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
3890
+ inst.datetime = (params) => inst.check(datetime(params));
3891
+ inst.date = (params) => inst.check(date(params));
3892
+ inst.time = (params) => inst.check(time(params));
3893
+ inst.duration = (params) => inst.check(duration(params));
3894
+ });
3895
+ function string(params) {
3896
+ return _string(ZodString, params);
3897
+ }
3898
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
3899
+ $ZodStringFormat.init(inst, def);
3900
+ _ZodString.init(inst, def);
3901
+ });
3902
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
3903
+ $ZodEmail.init(inst, def);
3904
+ ZodStringFormat.init(inst, def);
3905
+ });
3906
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
3907
+ $ZodGUID.init(inst, def);
3908
+ ZodStringFormat.init(inst, def);
3909
+ });
3910
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
3911
+ $ZodUUID.init(inst, def);
3912
+ ZodStringFormat.init(inst, def);
3913
+ });
3914
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
3915
+ $ZodURL.init(inst, def);
3916
+ ZodStringFormat.init(inst, def);
3917
+ });
3918
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
3919
+ $ZodEmoji.init(inst, def);
3920
+ ZodStringFormat.init(inst, def);
3921
+ });
3922
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
3923
+ $ZodNanoID.init(inst, def);
3924
+ ZodStringFormat.init(inst, def);
3925
+ });
3926
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
3927
+ $ZodCUID.init(inst, def);
3928
+ ZodStringFormat.init(inst, def);
3929
+ });
3930
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
3931
+ $ZodCUID2.init(inst, def);
3932
+ ZodStringFormat.init(inst, def);
3933
+ });
3934
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
3935
+ $ZodULID.init(inst, def);
3936
+ ZodStringFormat.init(inst, def);
3937
+ });
3938
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
3939
+ $ZodXID.init(inst, def);
3940
+ ZodStringFormat.init(inst, def);
3941
+ });
3942
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
3943
+ $ZodKSUID.init(inst, def);
3944
+ ZodStringFormat.init(inst, def);
3945
+ });
3946
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
3947
+ $ZodIPv4.init(inst, def);
3948
+ ZodStringFormat.init(inst, def);
3949
+ });
3950
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
3951
+ $ZodIPv6.init(inst, def);
3952
+ ZodStringFormat.init(inst, def);
3953
+ });
3954
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
3955
+ $ZodCIDRv4.init(inst, def);
3956
+ ZodStringFormat.init(inst, def);
3957
+ });
3958
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
3959
+ $ZodCIDRv6.init(inst, def);
3960
+ ZodStringFormat.init(inst, def);
3961
+ });
3962
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
3963
+ $ZodBase64.init(inst, def);
3964
+ ZodStringFormat.init(inst, def);
3965
+ });
3966
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
3967
+ $ZodBase64URL.init(inst, def);
3968
+ ZodStringFormat.init(inst, def);
3969
+ });
3970
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
3971
+ $ZodE164.init(inst, def);
3972
+ ZodStringFormat.init(inst, def);
3973
+ });
3974
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
3975
+ $ZodJWT.init(inst, def);
3976
+ ZodStringFormat.init(inst, def);
3977
+ });
3978
+ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
3979
+ $ZodNumber.init(inst, def);
3980
+ ZodType.init(inst, def);
3981
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3982
+ inst.gt = (value, params) => inst.check(_gt(value, params));
3983
+ inst.gte = (value, params) => inst.check(_gte(value, params));
3984
+ inst.min = (value, params) => inst.check(_gte(value, params));
3985
+ inst.lt = (value, params) => inst.check(_lt(value, params));
3986
+ inst.lte = (value, params) => inst.check(_lte(value, params));
3987
+ inst.max = (value, params) => inst.check(_lte(value, params));
3988
+ inst.int = (params) => inst.check(int(params));
3989
+ inst.safe = (params) => inst.check(int(params));
3990
+ inst.positive = (params) => inst.check(_gt(0, params));
3991
+ inst.nonnegative = (params) => inst.check(_gte(0, params));
3992
+ inst.negative = (params) => inst.check(_lt(0, params));
3993
+ inst.nonpositive = (params) => inst.check(_lte(0, params));
3994
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
3995
+ inst.step = (value, params) => inst.check(_multipleOf(value, params));
3996
+ inst.finite = () => inst;
3997
+ const bag = inst._zod.bag;
3998
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3999
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
4000
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
4001
+ inst.isFinite = true;
4002
+ inst.format = bag.format ?? null;
4003
+ });
4004
+ function number(params) {
4005
+ return _number(ZodNumber, params);
4006
+ }
4007
+ const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
4008
+ $ZodNumberFormat.init(inst, def);
4009
+ ZodNumber.init(inst, def);
4010
+ });
4011
+ function int(params) {
4012
+ return _int(ZodNumberFormat, params);
4013
+ }
4014
+ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
4015
+ $ZodBoolean.init(inst, def);
4016
+ ZodType.init(inst, def);
4017
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
4018
+ });
4019
+ function boolean(params) {
4020
+ return _boolean(ZodBoolean, params);
4021
+ }
4022
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
4023
+ $ZodUnknown.init(inst, def);
4024
+ ZodType.init(inst, def);
4025
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
4026
+ });
4027
+ function unknown() {
4028
+ return _unknown(ZodUnknown);
4029
+ }
4030
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
4031
+ $ZodNever.init(inst, def);
4032
+ ZodType.init(inst, def);
4033
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
4034
+ });
4035
+ function never(params) {
4036
+ return _never(ZodNever, params);
4037
+ }
4038
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
4039
+ $ZodArray.init(inst, def);
4040
+ ZodType.init(inst, def);
4041
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4042
+ inst.element = def.element;
4043
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
4044
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
4045
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
4046
+ inst.length = (len, params) => inst.check(_length(len, params));
4047
+ inst.unwrap = () => inst.element;
4048
+ });
4049
+ function array(element, params) {
4050
+ return _array(ZodArray, element, params);
4051
+ }
4052
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
4053
+ $ZodObjectJIT.init(inst, def);
4054
+ ZodType.init(inst, def);
4055
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4056
+ defineLazy(inst, "shape", () => {
4057
+ return def.shape;
4058
+ });
4059
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
4060
+ inst.catchall = (catchall) => inst.clone({
4061
+ ...inst._zod.def,
4062
+ catchall
4063
+ });
4064
+ inst.passthrough = () => inst.clone({
4065
+ ...inst._zod.def,
4066
+ catchall: unknown()
4067
+ });
4068
+ inst.loose = () => inst.clone({
4069
+ ...inst._zod.def,
4070
+ catchall: unknown()
4071
+ });
4072
+ inst.strict = () => inst.clone({
4073
+ ...inst._zod.def,
4074
+ catchall: never()
4075
+ });
4076
+ inst.strip = () => inst.clone({
4077
+ ...inst._zod.def,
4078
+ catchall: void 0
4079
+ });
4080
+ inst.extend = (incoming) => {
4081
+ return extend(inst, incoming);
4082
+ };
4083
+ inst.safeExtend = (incoming) => {
4084
+ return safeExtend(inst, incoming);
4085
+ };
4086
+ inst.merge = (other) => merge(inst, other);
4087
+ inst.pick = (mask) => pick(inst, mask);
4088
+ inst.omit = (mask) => omit(inst, mask);
4089
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
4090
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
4091
+ });
4092
+ function object(shape, params) {
4093
+ return new ZodObject({
4094
+ type: "object",
4095
+ shape: shape ?? {},
4096
+ ...normalizeParams(params)
4097
+ });
4098
+ }
4099
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
4100
+ $ZodUnion.init(inst, def);
4101
+ ZodType.init(inst, def);
4102
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4103
+ inst.options = def.options;
4104
+ });
4105
+ function union(options, params) {
4106
+ return new ZodUnion({
4107
+ type: "union",
4108
+ options,
4109
+ ...normalizeParams(params)
4110
+ });
4111
+ }
4112
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
4113
+ $ZodIntersection.init(inst, def);
4114
+ ZodType.init(inst, def);
4115
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4116
+ });
4117
+ function intersection(left, right) {
4118
+ return new ZodIntersection({
4119
+ type: "intersection",
4120
+ left,
4121
+ right
4122
+ });
4123
+ }
4124
+ const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4125
+ $ZodRecord.init(inst, def);
4126
+ ZodType.init(inst, def);
4127
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4128
+ inst.keyType = def.keyType;
4129
+ inst.valueType = def.valueType;
4130
+ });
4131
+ function record(keyType, valueType, params) {
4132
+ return new ZodRecord({
4133
+ type: "record",
4134
+ keyType,
4135
+ valueType,
4136
+ ...normalizeParams(params)
4137
+ });
4138
+ }
4139
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4140
+ $ZodEnum.init(inst, def);
4141
+ ZodType.init(inst, def);
4142
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
4143
+ inst.enum = def.entries;
4144
+ inst.options = Object.values(def.entries);
4145
+ const keys = new Set(Object.keys(def.entries));
4146
+ inst.extract = (values, params) => {
4147
+ const newEntries = {};
4148
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
4149
+ else throw new Error(`Key ${value} not found in enum`);
4150
+ return new ZodEnum({
4151
+ ...def,
4152
+ checks: [],
4153
+ ...normalizeParams(params),
4154
+ entries: newEntries
4155
+ });
4156
+ };
4157
+ inst.exclude = (values, params) => {
4158
+ const newEntries = { ...def.entries };
4159
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
4160
+ else throw new Error(`Key ${value} not found in enum`);
4161
+ return new ZodEnum({
4162
+ ...def,
4163
+ checks: [],
4164
+ ...normalizeParams(params),
4165
+ entries: newEntries
4166
+ });
4167
+ };
4168
+ });
4169
+ function _enum(values, params) {
4170
+ return new ZodEnum({
4171
+ type: "enum",
4172
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
4173
+ ...normalizeParams(params)
4174
+ });
4175
+ }
4176
+ const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
4177
+ $ZodLiteral.init(inst, def);
4178
+ ZodType.init(inst, def);
4179
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
4180
+ inst.values = new Set(def.values);
4181
+ Object.defineProperty(inst, "value", { get() {
4182
+ if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
4183
+ return def.values[0];
4184
+ } });
4185
+ });
4186
+ function literal(value, params) {
4187
+ return new ZodLiteral({
4188
+ type: "literal",
4189
+ values: Array.isArray(value) ? value : [value],
4190
+ ...normalizeParams(params)
4191
+ });
4192
+ }
4193
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
4194
+ $ZodTransform.init(inst, def);
4195
+ ZodType.init(inst, def);
4196
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
4197
+ inst._zod.parse = (payload, _ctx) => {
4198
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
4199
+ payload.addIssue = (issue$1) => {
4200
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
4201
+ else {
4202
+ const _issue = issue$1;
4203
+ if (_issue.fatal) _issue.continue = false;
4204
+ _issue.code ?? (_issue.code = "custom");
4205
+ _issue.input ?? (_issue.input = payload.value);
4206
+ _issue.inst ?? (_issue.inst = inst);
4207
+ payload.issues.push(issue(_issue));
4208
+ }
4209
+ };
4210
+ const output = def.transform(payload.value, payload);
4211
+ if (output instanceof Promise) return output.then((output) => {
4212
+ payload.value = output;
4213
+ return payload;
4214
+ });
4215
+ payload.value = output;
4216
+ return payload;
4217
+ };
4218
+ });
4219
+ function transform(fn) {
4220
+ return new ZodTransform({
4221
+ type: "transform",
4222
+ transform: fn
4223
+ });
4224
+ }
4225
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
4226
+ $ZodOptional.init(inst, def);
4227
+ ZodType.init(inst, def);
4228
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4229
+ inst.unwrap = () => inst._zod.def.innerType;
4230
+ });
4231
+ function optional(innerType) {
4232
+ return new ZodOptional({
4233
+ type: "optional",
4234
+ innerType
4235
+ });
4236
+ }
4237
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4238
+ $ZodExactOptional.init(inst, def);
4239
+ ZodType.init(inst, def);
4240
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4241
+ inst.unwrap = () => inst._zod.def.innerType;
4242
+ });
4243
+ function exactOptional(innerType) {
4244
+ return new ZodExactOptional({
4245
+ type: "optional",
4246
+ innerType
4247
+ });
4248
+ }
4249
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4250
+ $ZodNullable.init(inst, def);
4251
+ ZodType.init(inst, def);
4252
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4253
+ inst.unwrap = () => inst._zod.def.innerType;
4254
+ });
4255
+ function nullable(innerType) {
4256
+ return new ZodNullable({
4257
+ type: "nullable",
4258
+ innerType
4259
+ });
4260
+ }
4261
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
4262
+ $ZodDefault.init(inst, def);
4263
+ ZodType.init(inst, def);
4264
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4265
+ inst.unwrap = () => inst._zod.def.innerType;
4266
+ inst.removeDefault = inst.unwrap;
4267
+ });
4268
+ function _default(innerType, defaultValue) {
4269
+ return new ZodDefault({
4270
+ type: "default",
4271
+ innerType,
4272
+ get defaultValue() {
4273
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4274
+ }
4275
+ });
4276
+ }
4277
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
4278
+ $ZodPrefault.init(inst, def);
4279
+ ZodType.init(inst, def);
4280
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4281
+ inst.unwrap = () => inst._zod.def.innerType;
4282
+ });
4283
+ function prefault(innerType, defaultValue) {
4284
+ return new ZodPrefault({
4285
+ type: "prefault",
4286
+ innerType,
4287
+ get defaultValue() {
4288
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4289
+ }
4290
+ });
4291
+ }
4292
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
4293
+ $ZodNonOptional.init(inst, def);
4294
+ ZodType.init(inst, def);
4295
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4296
+ inst.unwrap = () => inst._zod.def.innerType;
4297
+ });
4298
+ function nonoptional(innerType, params) {
4299
+ return new ZodNonOptional({
4300
+ type: "nonoptional",
4301
+ innerType,
4302
+ ...normalizeParams(params)
4303
+ });
4304
+ }
4305
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
4306
+ $ZodCatch.init(inst, def);
4307
+ ZodType.init(inst, def);
4308
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4309
+ inst.unwrap = () => inst._zod.def.innerType;
4310
+ inst.removeCatch = inst.unwrap;
4311
+ });
4312
+ function _catch(innerType, catchValue) {
4313
+ return new ZodCatch({
4314
+ type: "catch",
4315
+ innerType,
4316
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4317
+ });
4318
+ }
4319
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
4320
+ $ZodPipe.init(inst, def);
4321
+ ZodType.init(inst, def);
4322
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4323
+ inst.in = def.in;
4324
+ inst.out = def.out;
4325
+ });
4326
+ function pipe(in_, out) {
4327
+ return new ZodPipe({
4328
+ type: "pipe",
4329
+ in: in_,
4330
+ out
4331
+ });
4332
+ }
4333
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
4334
+ $ZodReadonly.init(inst, def);
4335
+ ZodType.init(inst, def);
4336
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4337
+ inst.unwrap = () => inst._zod.def.innerType;
4338
+ });
4339
+ function readonly(innerType) {
4340
+ return new ZodReadonly({
4341
+ type: "readonly",
4342
+ innerType
4343
+ });
4344
+ }
4345
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
4346
+ $ZodCustom.init(inst, def);
4347
+ ZodType.init(inst, def);
4348
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4349
+ });
4350
+ function refine(fn, _params = {}) {
4351
+ return _refine(ZodCustom, fn, _params);
4352
+ }
4353
+ function superRefine(fn) {
4354
+ return _superRefine(fn);
4355
+ }
4356
+
458
4357
  //#endregion
459
4358
  //#region ../../packages/agent-core-v2/src/agent/usage/usageFact.ts
460
4359
  function normalizeUsageFact(raw, sourceAgentId) {
@@ -476,6 +4375,8 @@ function normalizeUsageFact(raw, sourceAgentId) {
476
4375
  time: raw.time,
477
4376
  model,
478
4377
  upstreamModelId: optionalString(raw["upstreamModelId"]),
4378
+ usageScope: raw["usageScope"] === "session" || raw["usageScope"] === "turn" ? raw["usageScope"] : void 0,
4379
+ executorId: optionalString(raw["executorId"]),
479
4380
  sourceAgentId,
480
4381
  invalid: invalid || void 0,
481
4382
  usage: invalid ? {
@@ -504,6 +4405,21 @@ function nonnegativeFinite(value) {
504
4405
  function optionalString(value) {
505
4406
  return typeof value === "string" && value.length > 0 ? value : void 0;
506
4407
  }
4408
+ const accountingTokenSchema = object({
4409
+ inputOther: number().nonnegative(),
4410
+ output: number().nonnegative(),
4411
+ inputCacheRead: number().nonnegative(),
4412
+ inputCacheCreation: number().nonnegative()
4413
+ });
4414
+ const usageFactTotalsSchema = object({
4415
+ version: literal(2),
4416
+ usage: accountingTokenSchema,
4417
+ byModel: record(string(), accountingTokenSchema),
4418
+ byModelMask: record(string(), record(string(), accountingTokenSchema)),
4419
+ records: number().int().nonnegative(),
4420
+ knownUsageRecords: number().int().nonnegative(),
4421
+ partial: boolean()
4422
+ });
507
4423
 
508
4424
  //#endregion
509
4425
  //#region ../../packages/agent-core-v2/src/agent/usage/usageWireFramer.ts
@@ -564,8 +4480,10 @@ var UsageReadAllowance = class {
564
4480
  }
565
4481
  }
566
4482
  };
567
- /** Pure source-local framing. Callers own byte acquisition, shared allowances, cooperative yields and durable prefix commits. State retains parsed usage fields, nesting and at most three undecoded UTF-8 bytes, never an unrelated body. */
4483
+ /** Pure source-local framing. Callers own byte acquisition, shared allowances, cooperative yields and durable prefix commits. Transferable state retains only usage fields, nesting and at most three undecoded UTF-8 bytes. A source-local 64 KiB text cache reuses normalized short usage records without removing their separate fact visits. */
568
4484
  var UsageWireFramer = class {
4485
+ parsed = /* @__PURE__ */ new Map();
4486
+ parsedBytes = 0;
569
4487
  offset;
570
4488
  cursor;
571
4489
  valid;
@@ -640,17 +4558,23 @@ var UsageWireFramer = class {
640
4558
  if (stop !== null || newline < 0) break;
641
4559
  }
642
4560
  let raw;
4561
+ let text;
4562
+ let cached;
643
4563
  try {
644
4564
  if (this.parser !== void 0) {
645
4565
  if (!this.invalid) {
646
4566
  this.parser.write(Buffer.from(this.utf8).toString("utf8"));
647
4567
  raw = this.parser.finish();
648
4568
  }
649
- } else if (end > start) raw = parseUsageJson(bytes.subarray(start, end));
4569
+ } else if (end > start) if (end - start <= 2048) {
4570
+ text = bytes.toString("utf8", start, end);
4571
+ cached = this.parsed.get(text);
4572
+ if (cached === void 0) raw = parseUsageJson(text);
4573
+ } else raw = parseUsageJson(bytes.subarray(start, end));
650
4574
  } catch {
651
4575
  this.invalid = true;
652
4576
  }
653
- const fact = this.invalid || raw !== void 0;
4577
+ const fact = this.invalid || raw !== void 0 || cached !== void 0;
654
4578
  if (!allowance.takeRecord(fact)) {
655
4579
  this.parser = void 0;
656
4580
  this.utf8 = new Uint8Array(0);
@@ -663,9 +4587,20 @@ var UsageWireFramer = class {
663
4587
  factCount++;
664
4588
  if (this.invalid) this.valid = false;
665
4589
  else {
666
- const record = normalizeUsageFact(raw, this.sourceAgentId);
4590
+ const record = cached ?? normalizeUsageFact(raw, this.sourceAgentId);
667
4591
  if (record === void 0) this.valid = false;
668
- else records.push(record);
4592
+ else {
4593
+ records.push(record);
4594
+ if (text !== void 0 && cached === void 0) {
4595
+ while (this.parsedBytes + text.length * 2 > 64 * 1024) {
4596
+ const oldest = this.parsed.keys().next().value;
4597
+ this.parsed.delete(oldest);
4598
+ this.parsedBytes -= oldest.length * 2;
4599
+ }
4600
+ this.parsed.set(text, record);
4601
+ this.parsedBytes += text.length * 2;
4602
+ }
4603
+ }
669
4604
  }
670
4605
  }
671
4606
  this.cursor += end - start + 1;
@@ -705,8 +4640,41 @@ var UsageWireFramer = class {
705
4640
  }
706
4641
  };
707
4642
 
4643
+ //#endregion
4644
+ //#region ../../packages/agent-core-v2/src/_base/node/resourceDefaults.ts
4645
+ function resourceDefaults(hardware = {
4646
+ parallelism: availableParallelism(),
4647
+ memoryBytes: totalmem()
4648
+ }) {
4649
+ const memoryMiB = Math.floor(hardware.memoryBytes / 1024 / 1024);
4650
+ const spareCpus = Math.max(1, hardware.parallelism - 1);
4651
+ const workerHeapMb = Math.max(512, Math.floor(memoryMiB / 64));
4652
+ const cpuWorkers = Math.max(1, Math.min(spareCpus, Math.floor(memoryMiB / 4 / workerHeapMb)));
4653
+ return {
4654
+ workerHeapMb,
4655
+ searchIndexerSoftMb: workerHeapMb * 2 + 256,
4656
+ searchIndexerHardMb: workerHeapMb * 3 + 256,
4657
+ cpuWorkers,
4658
+ workerQueue: Math.max(128, hardware.parallelism * 16),
4659
+ cpuQueue: Math.max(128, cpuWorkers * 16),
4660
+ cpuQueuedBytes: Math.max(64, Math.floor(memoryMiB / 128)) * 1024 * 1024,
4661
+ liveSessions: Math.max(16, Math.floor(memoryMiB / 128)),
4662
+ queuedRestores: Math.max(128, hardware.parallelism * 16),
4663
+ residentHeapBytes: Math.max(256, Math.floor(memoryMiB / 8)) * 1024 * 1024
4664
+ };
4665
+ }
4666
+ const RESOURCE_DEFAULTS = resourceDefaults();
4667
+
4668
+ //#endregion
4669
+ //#region ../../packages/agent-core-v2/src/_base/node/workerHeapPolicy.ts
4670
+ function warnIfWorkerHeapLimit(expectedMb) {
4671
+ const observedMb = getHeapStatistics().heap_size_limit / 1024 / 1024;
4672
+ if (observedMb < expectedMb * .9 || observedMb > expectedMb + 256) process.emitWarning(`Worker heap limit is ${Math.round(observedMb)} MiB; expected ${expectedMb} MiB old-space plus at most 256 MiB young/code space. Check inherited Node heap flags.`, { code: "KIKI_WORKER_HEAP_LIMIT" });
4673
+ }
4674
+
708
4675
  //#endregion
709
4676
  //#region ../../packages/kap-server/src/usage/worker/entry.ts
4677
+ warnIfWorkerHeapLimit(RESOURCE_DEFAULTS.workerHeapMb);
710
4678
  if (parentPort === null) throw new Error("Usage parser requires a worker port");
711
4679
  const port = parentPort;
712
4680
  let framer;