@wirecat/zoom-cli 0.65.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +2 -1
  2. package/constants.json +7 -0
  3. package/dist/answers.d.ts +4 -4
  4. package/dist/bin/main.js +3 -2
  5. package/dist/bin/main.js.map +1 -1
  6. package/dist/bin/zm.js +2 -2
  7. package/dist/bin/zm.js.map +1 -1
  8. package/dist/bundle/{all-profiles-SKMLZJSY.js → all-profiles-SEW2VL76.js} +12 -8
  9. package/dist/bundle/answer-policy-5OYUL6UF.js +103 -0
  10. package/dist/bundle/{anthropic-TVHK7CY2.js → anthropic-FSNASJML.js} +7 -4
  11. package/dist/bundle/{app-server-44ASFH47.js → app-server-EVSRYJ3H.js} +66 -59
  12. package/dist/bundle/{bun-O4WHGL2F.js → bun-DACL5SVO.js} +2 -2
  13. package/dist/bundle/{bun-sqlite-NS32GMM4.js → bun-sqlite-HQ2KOXSI.js} +6 -3
  14. package/dist/bundle/chunk-2UW533HQ.js +166 -0
  15. package/dist/bundle/{chunk-FYJL276J.js → chunk-3GO3KME7.js} +3 -3
  16. package/dist/bundle/{chunk-Z5424QL6.js → chunk-3ZIHUSMM.js} +2 -2
  17. package/dist/bundle/{chunk-MRWIXUYT.js → chunk-4GCKDO2H.js} +5 -3
  18. package/dist/bundle/{chunk-7SQJCKR6.js → chunk-4KDZ22RA.js} +1 -1
  19. package/dist/bundle/{chunk-25IDWPEN.js → chunk-4U2555EQ.js} +35 -31
  20. package/dist/bundle/{chunk-UKU6MYUI.js → chunk-4UVT2QCO.js} +9 -20
  21. package/dist/bundle/{chunk-ZOGYTDHG.js → chunk-4ZR5DJ26.js} +5 -3
  22. package/dist/bundle/{chunk-CVCRQW3A.js → chunk-54RTMQL6.js} +4 -4
  23. package/dist/bundle/chunk-6AJDVJVZ.js +35 -0
  24. package/dist/bundle/chunk-6IBM4Z3V.js +34 -0
  25. package/dist/bundle/{chunk-CNEE6TPE.js → chunk-6TZF2JP7.js} +13 -13
  26. package/dist/bundle/{chunk-QLCYAQ66.js → chunk-6UFWFKFH.js} +2 -2
  27. package/dist/bundle/chunk-6VFORXL3.js +101 -0
  28. package/dist/bundle/{chunk-M6IDHQ7N.js → chunk-7HAIM7GV.js} +1633 -683
  29. package/dist/bundle/{chunk-FYM27FCG.js → chunk-7K5TDTZY.js} +13 -7
  30. package/dist/bundle/{chunk-NO24PJNW.js → chunk-7LLUUXJB.js} +1 -1
  31. package/dist/bundle/{chunk-VJTGYBJJ.js → chunk-7VU5UGRR.js} +37 -29
  32. package/dist/bundle/{chunk-ZH743WNV.js → chunk-AAZFLJSH.js} +25 -24
  33. package/dist/bundle/{chunk-DYJXAY7Q.js → chunk-ASCHAVNW.js} +35 -27
  34. package/dist/bundle/{chunk-EA63UGWE.js → chunk-B3KWAULD.js} +2 -2
  35. package/dist/bundle/{chunk-H7762LDA.js → chunk-B5Z4XPVS.js} +2 -2
  36. package/dist/bundle/{chunk-UPJXN2CO.js → chunk-BKY4XVB4.js} +1787 -1224
  37. package/dist/bundle/{chunk-QI7BZS2G.js → chunk-C6UKW7JO.js} +6 -6
  38. package/dist/bundle/{chunk-U3ZUT557.js → chunk-CLEZE65P.js} +1 -1
  39. package/dist/bundle/{chunk-37PHGASE.js → chunk-CRLBTNC4.js} +5 -3
  40. package/dist/bundle/{chunk-VH4F2EK4.js → chunk-D4KBD63W.js} +1 -1
  41. package/dist/bundle/{chunk-DNCKH7CO.js → chunk-D6OXI2NV.js} +17 -17
  42. package/dist/bundle/{chunk-LPUFOWL3.js → chunk-D72URWJE.js} +1 -39
  43. package/dist/bundle/{chunk-GMTXCFI7.js → chunk-DFUPETW7.js} +449 -308
  44. package/dist/bundle/{chunk-VW2SW7ME.js → chunk-DG4DWAU7.js} +3 -3
  45. package/dist/bundle/{chunk-U5ASRBBF.js → chunk-EPDRF66S.js} +4 -4
  46. package/dist/bundle/{chunk-BNXH73OU.js → chunk-EQ7XRRKV.js} +14 -12
  47. package/dist/bundle/{chunk-5NGOP4EZ.js → chunk-ESFMHBHH.js} +38 -35
  48. package/dist/bundle/{chunk-GEX4V5TM.js → chunk-EUPZSR2G.js} +4 -4
  49. package/dist/bundle/{chunk-KZE3G4ZT.js → chunk-FGTPREAZ.js} +58 -54
  50. package/dist/bundle/{chunk-MH7AWCB4.js → chunk-FWU3ZYHE.js} +68 -64
  51. package/dist/bundle/{chunk-MPKKIL3U.js → chunk-FXQPK742.js} +63 -21
  52. package/dist/bundle/{chunk-PV3UDPCI.js → chunk-GP4NSYDU.js} +20 -14
  53. package/dist/bundle/{chunk-ZFNM3FNI.js → chunk-I7SOXH64.js} +75 -38
  54. package/dist/bundle/{chunk-S4GDDO5S.js → chunk-IFDO3YPJ.js} +1 -1
  55. package/dist/bundle/{chunk-LOL6JYYN.js → chunk-J3ZBEWQY.js} +375 -9
  56. package/dist/bundle/chunk-JVCHGI7W.js +37 -0
  57. package/dist/bundle/{chunk-MZ6U6HNJ.js → chunk-KANH7GBB.js} +2 -2
  58. package/dist/bundle/{chunk-3CZIWGZ6.js → chunk-KIJLM5UL.js} +1 -1
  59. package/dist/bundle/chunk-KV4267S4.js +23 -0
  60. package/dist/bundle/{chunk-266WOOB3.js → chunk-KWRSC6O6.js} +6 -6
  61. package/dist/bundle/{chunk-C6BG57FA.js → chunk-L643D4RJ.js} +14 -12
  62. package/dist/bundle/{chunk-IPTI3Y2E.js → chunk-L6CAUVMU.js} +7 -5
  63. package/dist/bundle/{chunk-MIB5X2XW.js → chunk-L6WUAGPN.js} +5 -5
  64. package/dist/bundle/{chunk-BWRBALXG.js → chunk-LFQ73UFK.js} +3 -3
  65. package/dist/bundle/{chunk-GBZF4IIP.js → chunk-LKJXTACE.js} +10 -89
  66. package/dist/bundle/{chunk-T3KICUOK.js → chunk-LM26DJOK.js} +8 -8
  67. package/dist/bundle/{chunk-GXCNCMUY.js → chunk-M43MBWJX.js} +3260 -1263
  68. package/dist/bundle/{chunk-TC7PD3LH.js → chunk-MWEOVTIF.js} +4 -4
  69. package/dist/bundle/chunk-NTZDM5SJ.js +2462 -0
  70. package/dist/bundle/{chunk-ERPRAYA7.js → chunk-OTMGAKUM.js} +11 -7
  71. package/dist/bundle/chunk-OZEYFJX2.js +93 -0
  72. package/dist/bundle/{chunk-NJSIHMAE.js → chunk-Q65SDEFN.js} +4 -4
  73. package/dist/bundle/{chunk-UMHJZWZU.js → chunk-QEI55M2F.js} +12 -10
  74. package/dist/bundle/{chunk-SQWRZZOQ.js → chunk-QX2MAT6I.js} +3 -3
  75. package/dist/bundle/{chunk-ZXGRK44F.js → chunk-RAMPYIO2.js} +17 -12
  76. package/dist/bundle/{chunk-BLT3LR3U.js → chunk-RYKG6AEH.js} +1 -1
  77. package/dist/bundle/{chunk-WLSF3GCC.js → chunk-SCFFCIIP.js} +4 -2
  78. package/dist/bundle/{chunk-2H5SXK7K.js → chunk-SMVO5R3T.js} +21 -19
  79. package/dist/bundle/{chunk-Y3EIK4XW.js → chunk-SOZVC3SV.js} +1 -1
  80. package/dist/bundle/{chunk-6CS7ETBK.js → chunk-SSXCOUP3.js} +1114 -282
  81. package/dist/bundle/{chunk-R5BAF5XE.js → chunk-SXFODCYK.js} +1 -1
  82. package/dist/bundle/{chunk-JF7ZEUXU.js → chunk-T6CZWSHF.js} +136 -2540
  83. package/dist/bundle/{chunk-KYLS5QGC.js → chunk-TBRG2DPE.js} +2 -2
  84. package/dist/bundle/{chunk-K6ATTKQR.js → chunk-V33VGWT3.js} +5 -5
  85. package/dist/bundle/{chunk-RZLNHNSS.js → chunk-VFIEYRYD.js} +8 -8
  86. package/dist/bundle/{chunk-OXUHTKO2.js → chunk-VNIBTNV4.js} +3 -2
  87. package/dist/bundle/{chunk-ZREFYKUB.js → chunk-VQTAU4DV.js} +13 -11
  88. package/dist/bundle/{chunk-NNNEVWFF.js → chunk-WHQ4ZCJI.js} +57 -34
  89. package/dist/bundle/chunk-WZ5XK74U.js +46 -0
  90. package/dist/bundle/{chunk-XJQB47IL.js → chunk-X67YD3QI.js} +6 -6
  91. package/dist/bundle/chunk-YPF6OS37.js +46 -0
  92. package/dist/bundle/{chunk-AMMD6YCJ.js → chunk-YRNZT4GQ.js} +7 -7
  93. package/dist/bundle/{chunk-TUIEDVI6.js → chunk-Z3WXI4DK.js} +5 -3
  94. package/dist/bundle/{chunk-U4RVOSX3.js → chunk-ZMPTO2WB.js} +1 -1
  95. package/dist/bundle/{chunk-24F7JBLY.js → chunk-ZRMZBMOF.js} +69 -9
  96. package/dist/bundle/{cli-FDO6CP6R.js → cli-YUATSOLA.js} +113 -81
  97. package/dist/bundle/command-contract-UWHY55UE.js +41 -0
  98. package/dist/bundle/config-TGF6E6ZD.js +89 -0
  99. package/dist/bundle/{decode-7SZI3TGZ.js → decode-IL44LNC3.js} +6 -3
  100. package/dist/bundle/dispatch-3BGIXSJR.js +412 -0
  101. package/dist/bundle/{dist-5GWUXW27.js → dist-3W27UQ2S.js} +48 -16
  102. package/dist/bundle/{echarts-FMACRZQC.js → echarts-CO4D26JF.js} +2 -2
  103. package/dist/bundle/{embed-24YSXHLP.js → embed-XH2X4DFM.js} +7 -4
  104. package/dist/bundle/{embedder-MEXN2TFB.js → embedder-WTFWDXBJ.js} +12 -9
  105. package/dist/bundle/failure-HTIS3NLS.js +25 -0
  106. package/dist/bundle/first-run-5RBH7FDO.js +28 -0
  107. package/dist/bundle/first-screen-PGFIXJAX.js +39 -0
  108. package/dist/bundle/{folders-DBAAMU26.js → folders-F4DNQPIY.js} +5 -2
  109. package/dist/bundle/{instructions-E5FXYCWF.js → instructions-EPPBL6TT.js} +1 -1
  110. package/dist/bundle/{main-EIUCXXDW.js → main-LVQTCDZS.js} +31 -25
  111. package/dist/bundle/{mcp-FUSDPAOL.js → mcp-PPVOM4SE.js} +5 -3
  112. package/dist/bundle/{meetings-JDTRGXZJ.js → meetings-BMELXRTR.js} +31 -4
  113. package/dist/bundle/{node-4SNKUPXT.js → node-CQVMWVIG.js} +2 -2
  114. package/dist/bundle/{node-sqlite-O4BAODFR.js → node-sqlite-QQEX7LZT.js} +7 -4
  115. package/dist/bundle/{oauth-3YLHXGUW.js → oauth-AYGX7CQS.js} +8 -5
  116. package/dist/bundle/{open-QGRMSNM2.js → open-MIL2TOT6.js} +6 -3
  117. package/dist/bundle/openai-7QZZXQW5.js +25 -0
  118. package/dist/bundle/{output-file-J26UQKRA.js → output-file-4XADZPYH.js} +7 -4
  119. package/dist/bundle/{process-HQZOTT6U.js → process-NJVQK6GB.js} +1 -1
  120. package/dist/bundle/{program-47DT7SHE.js → program-WUYRS6H7.js} +191 -135
  121. package/dist/bundle/{prompt-IUD7HCDC.js → prompt-J4QPFLEA.js} +6 -3
  122. package/dist/bundle/{recognize-DMJJHHXF.js → recognize-OLJZVNWW.js} +5 -2
  123. package/dist/bundle/{remote-5WFSOVVB.js → remote-JPUXNYLV.js} +8 -5
  124. package/dist/bundle/{rerank-UKQ65ECH.js → rerank-XVV3X5TT.js} +8 -5
  125. package/dist/bundle/run-log-DJXBEVS5.js +118 -0
  126. package/dist/bundle/{serve-WAOSED3I.js → serve-NYYUO3MR.js} +16 -13
  127. package/dist/bundle/{server-NWZFNXC5.js → server-4Z5E4YTT.js} +48 -42
  128. package/dist/bundle/server-VW5UVCH7.js +72 -0
  129. package/dist/bundle/{services-VPANRE72.js → services-EKWM76HP.js} +50 -28
  130. package/dist/bundle/{speech-O6UNUDRW.js → speech-WFJ44ACJ.js} +14 -11
  131. package/dist/bundle/{state-BNE7I65A.js → state-VIRCT4VW.js} +7 -4
  132. package/dist/bundle/{store-4IIVSCJ4.js → store-2Q4GEZJS.js} +30 -18
  133. package/dist/bundle/{store-QQH4FJXJ.js → store-ZTDZ6UY5.js} +20 -14
  134. package/dist/bundle/store-connection-FKVVQLEF.js +83 -0
  135. package/dist/bundle/store-maintenance-command-AU73UVUQ.js +62 -0
  136. package/dist/bundle/{streaming-S4EZB6P2.js → streaming-7BPKIGAS.js} +7 -4
  137. package/dist/bundle/{tokens-VCXIH7WZ.js → tokens-CQHMMKNX.js} +7 -4
  138. package/dist/bundle/zm.js +150 -1
  139. package/dist/bundle/zoom-app-OEKFMJS6.js +25 -0
  140. package/dist/config.d.ts +9 -0
  141. package/dist/config.d.ts.map +1 -1
  142. package/dist/config.js +46 -7
  143. package/dist/config.js.map +1 -1
  144. package/dist/meeting-source.d.ts.map +1 -1
  145. package/dist/meeting-source.js +2 -1
  146. package/dist/meeting-source.js.map +1 -1
  147. package/dist/meeting-stats-commands.d.ts +4 -2
  148. package/dist/meeting-stats-commands.d.ts.map +1 -1
  149. package/dist/meeting-stats-commands.js +27 -2
  150. package/dist/meeting-stats-commands.js.map +1 -1
  151. package/dist/program-bindings.d.ts.map +1 -1
  152. package/dist/program-bindings.js +3 -2
  153. package/dist/program-bindings.js.map +1 -1
  154. package/dist/recording-schedule-setup.d.ts.map +1 -1
  155. package/dist/recording-schedule-setup.js +5 -5
  156. package/dist/recording-schedule-setup.js.map +1 -1
  157. package/dist/run.d.ts.map +1 -1
  158. package/dist/run.js +2 -6
  159. package/dist/run.js.map +1 -1
  160. package/dist/setup-commands.d.ts +1 -1
  161. package/dist/setup-commands.d.ts.map +1 -1
  162. package/dist/setup-commands.js +30 -8
  163. package/dist/setup-commands.js.map +1 -1
  164. package/dist/store-commands.d.ts.map +1 -1
  165. package/dist/store-commands.js +6 -0
  166. package/dist/store-commands.js.map +1 -1
  167. package/dist/store-connection.d.ts +2 -1
  168. package/dist/store-connection.d.ts.map +1 -1
  169. package/dist/store-connection.js +4 -0
  170. package/dist/store-connection.js.map +1 -1
  171. package/dist/version.d.ts +1 -1
  172. package/dist/version.js +1 -1
  173. package/dist/watch-service.d.ts +1 -1
  174. package/dist/watch-service.d.ts.map +1 -1
  175. package/dist/watch-service.js +5 -3
  176. package/dist/watch-service.js.map +1 -1
  177. package/dist/zoom-app.d.ts +17 -0
  178. package/dist/zoom-app.d.ts.map +1 -0
  179. package/dist/zoom-app.js +22 -0
  180. package/dist/zoom-app.js.map +1 -0
  181. package/package.json +6 -4
  182. package/skills/zoom-cli/SKILL.md +4 -1
  183. package/dist/bundle/answer-policy-BHDNSJWX.js +0 -96
  184. package/dist/bundle/chunk-A6OA2EH2.js +0 -18
  185. package/dist/bundle/command-contract-O4FDXM4U.js +0 -37
  186. package/dist/bundle/config-UBHKZG3J.js +0 -78
  187. package/dist/bundle/first-run-OCVEJH63.js +0 -23
  188. package/dist/bundle/first-screen-KJIU25MH.js +0 -35
  189. package/dist/bundle/openai-7PSCSTH7.js +0 -22
  190. package/dist/bundle/run-log-UGYL6NW2.js +0 -111
  191. package/dist/bundle/server-HAXN772R.js +0 -66
  192. package/dist/bundle/store-connection-PPEQK2K3.js +0 -76
  193. package/dist/bundle/store-maintenance-command-JZXCT6NY.js +0 -56
  194. /package/dist/bundle/{chunk-NUN6OGOV.js → chunk-LU3WKZBA.js} +0 -0
@@ -0,0 +1,2462 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ errorCodes,
5
+ isCliError
6
+ } from "./chunk-WZ5XK74U.js";
7
+ import {
8
+ visibleControls
9
+ } from "./chunk-6IBM4Z3V.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/exit-codes.js
15
+ var EXIT_CODES = {
16
+ validation_error: 2,
17
+ configuration_error: 3,
18
+ authentication_error: 4,
19
+ permission_error: 5,
20
+ not_found: 6,
21
+ confirmation_required: 7,
22
+ rate_limited: 8,
23
+ timeout: 9,
24
+ network_error: 10,
25
+ provider_error: 11,
26
+ provider_unavailable: 12,
27
+ invalid_response: 13,
28
+ outcome_unknown: 14,
29
+ conflict: 15,
30
+ cancelled: 130
31
+ };
32
+ var exitCodeFor = /* @__PURE__ */ __name((code) => EXIT_CODES[code], "exitCodeFor");
33
+ var GENERIC_FAILURE = 1;
34
+
35
+ // node_modules/.pnpm/valibot@1.5.0_typescript@7.0.2/node_modules/valibot/dist/index.mjs
36
+ var store$4;
37
+ var DEFAULT_CONFIG = {
38
+ lang: void 0,
39
+ message: void 0,
40
+ abortEarly: void 0,
41
+ abortPipeEarly: void 0
42
+ };
43
+ // @__NO_SIDE_EFFECTS__
44
+ function getGlobalConfig(config$1) {
45
+ if (!config$1 && !store$4) return DEFAULT_CONFIG;
46
+ return {
47
+ lang: config$1?.lang ?? store$4?.lang,
48
+ message: config$1?.message,
49
+ abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
50
+ abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
51
+ };
52
+ }
53
+ __name(getGlobalConfig, "getGlobalConfig");
54
+ var store$3;
55
+ // @__NO_SIDE_EFFECTS__
56
+ function getGlobalMessage(lang) {
57
+ return store$3?.get(lang);
58
+ }
59
+ __name(getGlobalMessage, "getGlobalMessage");
60
+ var store$2;
61
+ // @__NO_SIDE_EFFECTS__
62
+ function getSchemaMessage(lang) {
63
+ return store$2?.get(lang);
64
+ }
65
+ __name(getSchemaMessage, "getSchemaMessage");
66
+ var store$1;
67
+ // @__NO_SIDE_EFFECTS__
68
+ function getSpecificMessage(reference2, lang) {
69
+ return store$1?.get(reference2)?.get(lang);
70
+ }
71
+ __name(getSpecificMessage, "getSpecificMessage");
72
+ // @__NO_SIDE_EFFECTS__
73
+ function _stringify(input) {
74
+ const type = typeof input;
75
+ if (type === "string") return `"${input}"`;
76
+ if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
77
+ if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
78
+ return type;
79
+ }
80
+ __name(_stringify, "_stringify");
81
+ function _addIssue(context, label, dataset, config$1, other) {
82
+ const input = other && "input" in other ? other.input : dataset.value;
83
+ const expected = other?.expected ?? context.expects ?? null;
84
+ const received = other?.received ?? /* @__PURE__ */ _stringify(input);
85
+ const issue = {
86
+ kind: context.kind,
87
+ type: context.type,
88
+ input,
89
+ expected,
90
+ received,
91
+ message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
92
+ requirement: context.requirement,
93
+ path: other?.path,
94
+ issues: other?.issues,
95
+ lang: config$1.lang,
96
+ abortEarly: config$1.abortEarly,
97
+ abortPipeEarly: config$1.abortPipeEarly
98
+ };
99
+ const isSchema = context.kind === "schema";
100
+ const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
101
+ if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
102
+ if (isSchema) dataset.typed = false;
103
+ if (dataset.issues) dataset.issues.push(issue);
104
+ else dataset.issues = [issue];
105
+ }
106
+ __name(_addIssue, "_addIssue");
107
+ // @__NO_SIDE_EFFECTS__
108
+ function _isSameValueZero(value1, value2) {
109
+ return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
110
+ }
111
+ __name(_isSameValueZero, "_isSameValueZero");
112
+ // @__NO_SIDE_EFFECTS__
113
+ function _isValidObjectKey(object$1, key) {
114
+ return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
115
+ }
116
+ __name(_isValidObjectKey, "_isValidObjectKey");
117
+ // @__NO_SIDE_EFFECTS__
118
+ function _joinExpects(values$1, separator) {
119
+ const list = [...new Set(values$1)];
120
+ if (list.length > 1) return `(${list.join(` ${separator} `)})`;
121
+ return list[0] ?? "never";
122
+ }
123
+ __name(_joinExpects, "_joinExpects");
124
+ function _standardSchema(schema) {
125
+ schema["~standard"] = {
126
+ version: 1,
127
+ vendor: "valibot",
128
+ validate: /* @__PURE__ */ __name((value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig()), "validate")
129
+ };
130
+ return schema;
131
+ }
132
+ __name(_standardSchema, "_standardSchema");
133
+ // @__NO_SIDE_EFFECTS__
134
+ function getDotPath(issue) {
135
+ if (issue.path) {
136
+ let key = "";
137
+ for (const item of issue.path) if (typeof item.key === "string" || typeof item.key === "number") if (key) key += `.${item.key}`;
138
+ else key += item.key;
139
+ else return null;
140
+ return key;
141
+ }
142
+ return null;
143
+ }
144
+ __name(getDotPath, "getDotPath");
145
+ var ValiError = class extends Error {
146
+ static {
147
+ __name(this, "ValiError");
148
+ }
149
+ /**
150
+ * Creates a Valibot error with useful information.
151
+ *
152
+ * @param issues The error issues.
153
+ */
154
+ constructor(issues) {
155
+ super(issues[0].message);
156
+ this.name = "ValiError";
157
+ this.issues = issues;
158
+ }
159
+ };
160
+ var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
161
+ var ISO_DATE_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])$/u;
162
+ var ISO_TIMESTAMP_REGEX = /^\d{4}-(?:0[1-9]|1[0-2])-(?:[12]\d|0[1-9]|3[01])[T ](?:0\d|1\d|2[0-3])(?::[0-5]\d){2}(?:\.\d{1,9})?(?:Z| ?[+-](?:0\d|1\d|2[0-3])(?::?[0-5]\d)?)$/u;
163
+ // @__NO_SIDE_EFFECTS__
164
+ function check(requirement, message$1) {
165
+ return {
166
+ kind: "validation",
167
+ type: "check",
168
+ reference: check,
169
+ async: false,
170
+ expects: null,
171
+ requirement,
172
+ message: message$1,
173
+ "~run"(dataset, config$1) {
174
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
175
+ return dataset;
176
+ }
177
+ };
178
+ }
179
+ __name(check, "check");
180
+ // @__NO_SIDE_EFFECTS__
181
+ function description(description_) {
182
+ return {
183
+ kind: "metadata",
184
+ type: "description",
185
+ reference: description,
186
+ description: description_
187
+ };
188
+ }
189
+ __name(description, "description");
190
+ // @__NO_SIDE_EFFECTS__
191
+ function endsWith(requirement, message$1) {
192
+ return {
193
+ kind: "validation",
194
+ type: "ends_with",
195
+ reference: endsWith,
196
+ async: false,
197
+ expects: `"${requirement}"`,
198
+ requirement,
199
+ message: message$1,
200
+ "~run"(dataset, config$1) {
201
+ if (dataset.typed && !dataset.value.endsWith(this.requirement)) _addIssue(this, "end", dataset, config$1, { received: `"${dataset.value.slice(-this.requirement.length)}"` });
202
+ return dataset;
203
+ }
204
+ };
205
+ }
206
+ __name(endsWith, "endsWith");
207
+ // @__NO_SIDE_EFFECTS__
208
+ function finite(message$1) {
209
+ return {
210
+ kind: "validation",
211
+ type: "finite",
212
+ reference: finite,
213
+ async: false,
214
+ expects: null,
215
+ requirement: Number.isFinite,
216
+ message: message$1,
217
+ "~run"(dataset, config$1) {
218
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "finite", dataset, config$1);
219
+ return dataset;
220
+ }
221
+ };
222
+ }
223
+ __name(finite, "finite");
224
+ // @__NO_SIDE_EFFECTS__
225
+ function integer(message$1) {
226
+ return {
227
+ kind: "validation",
228
+ type: "integer",
229
+ reference: integer,
230
+ async: false,
231
+ expects: null,
232
+ requirement: Number.isInteger,
233
+ message: message$1,
234
+ "~run"(dataset, config$1) {
235
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
236
+ return dataset;
237
+ }
238
+ };
239
+ }
240
+ __name(integer, "integer");
241
+ // @__NO_SIDE_EFFECTS__
242
+ function isoDate(message$1) {
243
+ return {
244
+ kind: "validation",
245
+ type: "iso_date",
246
+ reference: isoDate,
247
+ async: false,
248
+ expects: null,
249
+ requirement: ISO_DATE_REGEX,
250
+ message: message$1,
251
+ "~run"(dataset, config$1) {
252
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "date", dataset, config$1);
253
+ return dataset;
254
+ }
255
+ };
256
+ }
257
+ __name(isoDate, "isoDate");
258
+ // @__NO_SIDE_EFFECTS__
259
+ function isoTimestamp(message$1) {
260
+ return {
261
+ kind: "validation",
262
+ type: "iso_timestamp",
263
+ reference: isoTimestamp,
264
+ async: false,
265
+ expects: null,
266
+ requirement: ISO_TIMESTAMP_REGEX,
267
+ message: message$1,
268
+ "~run"(dataset, config$1) {
269
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "timestamp", dataset, config$1);
270
+ return dataset;
271
+ }
272
+ };
273
+ }
274
+ __name(isoTimestamp, "isoTimestamp");
275
+ // @__NO_SIDE_EFFECTS__
276
+ function maxLength(requirement, message$1) {
277
+ return {
278
+ kind: "validation",
279
+ type: "max_length",
280
+ reference: maxLength,
281
+ async: false,
282
+ expects: `<=${requirement}`,
283
+ requirement,
284
+ message: message$1,
285
+ "~run"(dataset, config$1) {
286
+ if (dataset.typed && dataset.value.length > this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
287
+ return dataset;
288
+ }
289
+ };
290
+ }
291
+ __name(maxLength, "maxLength");
292
+ // @__NO_SIDE_EFFECTS__
293
+ function maxValue(requirement, message$1) {
294
+ return {
295
+ kind: "validation",
296
+ type: "max_value",
297
+ reference: maxValue,
298
+ async: false,
299
+ expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
300
+ requirement,
301
+ message: message$1,
302
+ "~run"(dataset, config$1) {
303
+ if (dataset.typed && !(dataset.value <= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
304
+ return dataset;
305
+ }
306
+ };
307
+ }
308
+ __name(maxValue, "maxValue");
309
+ // @__NO_SIDE_EFFECTS__
310
+ function minLength(requirement, message$1) {
311
+ return {
312
+ kind: "validation",
313
+ type: "min_length",
314
+ reference: minLength,
315
+ async: false,
316
+ expects: `>=${requirement}`,
317
+ requirement,
318
+ message: message$1,
319
+ "~run"(dataset, config$1) {
320
+ if (dataset.typed && dataset.value.length < this.requirement) _addIssue(this, "length", dataset, config$1, { received: `${dataset.value.length}` });
321
+ return dataset;
322
+ }
323
+ };
324
+ }
325
+ __name(minLength, "minLength");
326
+ // @__NO_SIDE_EFFECTS__
327
+ function minValue(requirement, message$1) {
328
+ return {
329
+ kind: "validation",
330
+ type: "min_value",
331
+ reference: minValue,
332
+ async: false,
333
+ expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
334
+ requirement,
335
+ message: message$1,
336
+ "~run"(dataset, config$1) {
337
+ if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
338
+ return dataset;
339
+ }
340
+ };
341
+ }
342
+ __name(minValue, "minValue");
343
+ // @__NO_SIDE_EFFECTS__
344
+ function nonEmpty(message$1) {
345
+ return {
346
+ kind: "validation",
347
+ type: "non_empty",
348
+ reference: nonEmpty,
349
+ async: false,
350
+ expects: "!0",
351
+ message: message$1,
352
+ "~run"(dataset, config$1) {
353
+ if (dataset.typed && dataset.value.length === 0) _addIssue(this, "length", dataset, config$1, { received: "0" });
354
+ return dataset;
355
+ }
356
+ };
357
+ }
358
+ __name(nonEmpty, "nonEmpty");
359
+ // @__NO_SIDE_EFFECTS__
360
+ function regex(requirement, message$1) {
361
+ return {
362
+ kind: "validation",
363
+ type: "regex",
364
+ reference: regex,
365
+ async: false,
366
+ expects: `${requirement}`,
367
+ requirement,
368
+ message: message$1,
369
+ "~run"(dataset, config$1) {
370
+ if (dataset.typed && !this.requirement.test(dataset.value)) _addIssue(this, "format", dataset, config$1);
371
+ return dataset;
372
+ }
373
+ };
374
+ }
375
+ __name(regex, "regex");
376
+ // @__NO_SIDE_EFFECTS__
377
+ function safeInteger(message$1) {
378
+ return {
379
+ kind: "validation",
380
+ type: "safe_integer",
381
+ reference: safeInteger,
382
+ async: false,
383
+ expects: null,
384
+ requirement: Number.isSafeInteger,
385
+ message: message$1,
386
+ "~run"(dataset, config$1) {
387
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
388
+ return dataset;
389
+ }
390
+ };
391
+ }
392
+ __name(safeInteger, "safeInteger");
393
+ // @__NO_SIDE_EFFECTS__
394
+ function transform(operation) {
395
+ return {
396
+ kind: "transformation",
397
+ type: "transform",
398
+ reference: transform,
399
+ async: false,
400
+ operation,
401
+ "~run"(dataset) {
402
+ dataset.value = this.operation(dataset.value);
403
+ return dataset;
404
+ }
405
+ };
406
+ }
407
+ __name(transform, "transform");
408
+ // @__NO_SIDE_EFFECTS__
409
+ function trim() {
410
+ return {
411
+ kind: "transformation",
412
+ type: "trim",
413
+ reference: trim,
414
+ async: false,
415
+ "~run"(dataset) {
416
+ dataset.value = dataset.value.trim();
417
+ return dataset;
418
+ }
419
+ };
420
+ }
421
+ __name(trim, "trim");
422
+ var ABORT_EARLY_CONFIG = { abortEarly: true };
423
+ // @__NO_SIDE_EFFECTS__
424
+ function getFallback(schema, dataset, config$1) {
425
+ return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
426
+ }
427
+ __name(getFallback, "getFallback");
428
+ // @__NO_SIDE_EFFECTS__
429
+ function forward(action, path) {
430
+ return {
431
+ ...action,
432
+ "~run"(dataset, config$1) {
433
+ const prevIssues = dataset.issues && [...dataset.issues];
434
+ dataset = action["~run"](dataset, config$1);
435
+ if (dataset.issues) {
436
+ for (const issue of dataset.issues) if (!prevIssues?.includes(issue)) {
437
+ let pathInput = dataset.value;
438
+ for (const key of path) {
439
+ const pathValue = pathInput[key];
440
+ const pathItem = {
441
+ type: "unknown",
442
+ origin: "value",
443
+ input: pathInput,
444
+ key,
445
+ value: pathValue
446
+ };
447
+ if (issue.path) issue.path.push(pathItem);
448
+ else issue.path = [pathItem];
449
+ if (!pathValue) break;
450
+ pathInput = pathValue;
451
+ }
452
+ }
453
+ }
454
+ return dataset;
455
+ }
456
+ };
457
+ }
458
+ __name(forward, "forward");
459
+ // @__NO_SIDE_EFFECTS__
460
+ function getDefault(schema, dataset, config$1) {
461
+ return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
462
+ }
463
+ __name(getDefault, "getDefault");
464
+ // @__NO_SIDE_EFFECTS__
465
+ function array(item, message$1) {
466
+ return _standardSchema({
467
+ kind: "schema",
468
+ type: "array",
469
+ reference: array,
470
+ expects: "Array",
471
+ async: false,
472
+ item,
473
+ message: message$1,
474
+ "~run"(dataset, config$1) {
475
+ const input = dataset.value;
476
+ if (Array.isArray(input)) {
477
+ dataset.typed = true;
478
+ dataset.value = [];
479
+ for (let key = 0; key < input.length; key++) {
480
+ const value$1 = input[key];
481
+ const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
482
+ if (itemDataset.issues) {
483
+ const pathItem = {
484
+ type: "array",
485
+ origin: "value",
486
+ input,
487
+ key,
488
+ value: value$1
489
+ };
490
+ for (const issue of itemDataset.issues) {
491
+ if (issue.path) issue.path.unshift(pathItem);
492
+ else issue.path = [pathItem];
493
+ dataset.issues?.push(issue);
494
+ }
495
+ if (!dataset.issues) dataset.issues = itemDataset.issues;
496
+ if (config$1.abortEarly) {
497
+ dataset.typed = false;
498
+ break;
499
+ }
500
+ }
501
+ if (!itemDataset.typed) dataset.typed = false;
502
+ dataset.value.push(itemDataset.value);
503
+ }
504
+ } else _addIssue(this, "type", dataset, config$1);
505
+ return dataset;
506
+ }
507
+ });
508
+ }
509
+ __name(array, "array");
510
+ // @__NO_SIDE_EFFECTS__
511
+ function boolean(message$1) {
512
+ return _standardSchema({
513
+ kind: "schema",
514
+ type: "boolean",
515
+ reference: boolean,
516
+ expects: "boolean",
517
+ async: false,
518
+ message: message$1,
519
+ "~run"(dataset, config$1) {
520
+ if (typeof dataset.value === "boolean") dataset.typed = true;
521
+ else _addIssue(this, "type", dataset, config$1);
522
+ return dataset;
523
+ }
524
+ });
525
+ }
526
+ __name(boolean, "boolean");
527
+ // @__NO_SIDE_EFFECTS__
528
+ function custom(check$1, message$1) {
529
+ return _standardSchema({
530
+ kind: "schema",
531
+ type: "custom",
532
+ reference: custom,
533
+ expects: "unknown",
534
+ async: false,
535
+ check: check$1,
536
+ message: message$1,
537
+ "~run"(dataset, config$1) {
538
+ if (this.check(dataset.value)) dataset.typed = true;
539
+ else _addIssue(this, "type", dataset, config$1);
540
+ return dataset;
541
+ }
542
+ });
543
+ }
544
+ __name(custom, "custom");
545
+ // @__NO_SIDE_EFFECTS__
546
+ function lazy(getter) {
547
+ return _standardSchema({
548
+ kind: "schema",
549
+ type: "lazy",
550
+ reference: lazy,
551
+ expects: "unknown",
552
+ async: false,
553
+ getter,
554
+ "~run"(dataset, config$1) {
555
+ return this.getter(dataset.value)["~run"](dataset, config$1);
556
+ }
557
+ });
558
+ }
559
+ __name(lazy, "lazy");
560
+ // @__NO_SIDE_EFFECTS__
561
+ function literal(literal_, message$1) {
562
+ return _standardSchema({
563
+ kind: "schema",
564
+ type: "literal",
565
+ reference: literal,
566
+ expects: /* @__PURE__ */ _stringify(literal_),
567
+ async: false,
568
+ literal: literal_,
569
+ message: message$1,
570
+ "~run"(dataset, config$1) {
571
+ if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
572
+ else _addIssue(this, "type", dataset, config$1);
573
+ return dataset;
574
+ }
575
+ });
576
+ }
577
+ __name(literal, "literal");
578
+ // @__NO_SIDE_EFFECTS__
579
+ function looseObject(entries$1, message$1) {
580
+ return _standardSchema({
581
+ kind: "schema",
582
+ type: "loose_object",
583
+ reference: looseObject,
584
+ expects: "Object",
585
+ async: false,
586
+ entries: entries$1,
587
+ message: message$1,
588
+ "~run"(dataset, config$1) {
589
+ const input = dataset.value;
590
+ if (input && typeof input === "object") {
591
+ dataset.typed = true;
592
+ dataset.value = {};
593
+ for (const key in this.entries) {
594
+ const valueSchema = this.entries[key];
595
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
596
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
597
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
598
+ if (valueDataset.issues) {
599
+ const pathItem = {
600
+ type: "object",
601
+ origin: "value",
602
+ input,
603
+ key,
604
+ value: value$1
605
+ };
606
+ for (const issue of valueDataset.issues) {
607
+ if (issue.path) issue.path.unshift(pathItem);
608
+ else issue.path = [pathItem];
609
+ dataset.issues?.push(issue);
610
+ }
611
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
612
+ if (config$1.abortEarly) {
613
+ dataset.typed = false;
614
+ break;
615
+ }
616
+ }
617
+ if (!valueDataset.typed) dataset.typed = false;
618
+ dataset.value[key] = valueDataset.value;
619
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
620
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
621
+ _addIssue(this, "key", dataset, config$1, {
622
+ input: void 0,
623
+ expected: `"${key}"`,
624
+ path: [{
625
+ type: "object",
626
+ origin: "key",
627
+ input,
628
+ key,
629
+ value: input[key]
630
+ }]
631
+ });
632
+ if (config$1.abortEarly) break;
633
+ }
634
+ }
635
+ if (!dataset.issues || !config$1.abortEarly) {
636
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) dataset.value[key] = input[key];
637
+ }
638
+ } else _addIssue(this, "type", dataset, config$1);
639
+ return dataset;
640
+ }
641
+ });
642
+ }
643
+ __name(looseObject, "looseObject");
644
+ // @__NO_SIDE_EFFECTS__
645
+ function null_(message$1) {
646
+ return _standardSchema({
647
+ kind: "schema",
648
+ type: "null",
649
+ reference: null_,
650
+ expects: "null",
651
+ async: false,
652
+ message: message$1,
653
+ "~run"(dataset, config$1) {
654
+ if (dataset.value === null) dataset.typed = true;
655
+ else _addIssue(this, "type", dataset, config$1);
656
+ return dataset;
657
+ }
658
+ });
659
+ }
660
+ __name(null_, "null_");
661
+ // @__NO_SIDE_EFFECTS__
662
+ function nullable(wrapped, default_) {
663
+ return _standardSchema({
664
+ kind: "schema",
665
+ type: "nullable",
666
+ reference: nullable,
667
+ expects: `(${wrapped.expects} | null)`,
668
+ async: false,
669
+ wrapped,
670
+ default: default_,
671
+ "~run"(dataset, config$1) {
672
+ if (dataset.value === null) {
673
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
674
+ if (dataset.value === null) {
675
+ dataset.typed = true;
676
+ return dataset;
677
+ }
678
+ }
679
+ return this.wrapped["~run"](dataset, config$1);
680
+ }
681
+ });
682
+ }
683
+ __name(nullable, "nullable");
684
+ // @__NO_SIDE_EFFECTS__
685
+ function number(message$1) {
686
+ return _standardSchema({
687
+ kind: "schema",
688
+ type: "number",
689
+ reference: number,
690
+ expects: "number",
691
+ async: false,
692
+ message: message$1,
693
+ "~run"(dataset, config$1) {
694
+ if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
695
+ else _addIssue(this, "type", dataset, config$1);
696
+ return dataset;
697
+ }
698
+ });
699
+ }
700
+ __name(number, "number");
701
+ // @__NO_SIDE_EFFECTS__
702
+ function object(entries$1, message$1) {
703
+ return _standardSchema({
704
+ kind: "schema",
705
+ type: "object",
706
+ reference: object,
707
+ expects: "Object",
708
+ async: false,
709
+ entries: entries$1,
710
+ message: message$1,
711
+ "~run"(dataset, config$1) {
712
+ const input = dataset.value;
713
+ if (input && typeof input === "object") {
714
+ dataset.typed = true;
715
+ dataset.value = {};
716
+ for (const key in this.entries) {
717
+ const valueSchema = this.entries[key];
718
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
719
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
720
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
721
+ if (valueDataset.issues) {
722
+ const pathItem = {
723
+ type: "object",
724
+ origin: "value",
725
+ input,
726
+ key,
727
+ value: value$1
728
+ };
729
+ for (const issue of valueDataset.issues) {
730
+ if (issue.path) issue.path.unshift(pathItem);
731
+ else issue.path = [pathItem];
732
+ dataset.issues?.push(issue);
733
+ }
734
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
735
+ if (config$1.abortEarly) {
736
+ dataset.typed = false;
737
+ break;
738
+ }
739
+ }
740
+ if (!valueDataset.typed) dataset.typed = false;
741
+ dataset.value[key] = valueDataset.value;
742
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
743
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
744
+ _addIssue(this, "key", dataset, config$1, {
745
+ input: void 0,
746
+ expected: `"${key}"`,
747
+ path: [{
748
+ type: "object",
749
+ origin: "key",
750
+ input,
751
+ key,
752
+ value: input[key]
753
+ }]
754
+ });
755
+ if (config$1.abortEarly) break;
756
+ }
757
+ }
758
+ } else _addIssue(this, "type", dataset, config$1);
759
+ return dataset;
760
+ }
761
+ });
762
+ }
763
+ __name(object, "object");
764
+ // @__NO_SIDE_EFFECTS__
765
+ function objectWithRest(entries$1, rest, message$1) {
766
+ return _standardSchema({
767
+ kind: "schema",
768
+ type: "object_with_rest",
769
+ reference: objectWithRest,
770
+ expects: "Object",
771
+ async: false,
772
+ entries: entries$1,
773
+ rest,
774
+ message: message$1,
775
+ "~run"(dataset, config$1) {
776
+ const input = dataset.value;
777
+ if (input && typeof input === "object") {
778
+ dataset.typed = true;
779
+ dataset.value = {};
780
+ for (const key in this.entries) {
781
+ const valueSchema = this.entries[key];
782
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
783
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
784
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
785
+ if (valueDataset.issues) {
786
+ const pathItem = {
787
+ type: "object",
788
+ origin: "value",
789
+ input,
790
+ key,
791
+ value: value$1
792
+ };
793
+ for (const issue of valueDataset.issues) {
794
+ if (issue.path) issue.path.unshift(pathItem);
795
+ else issue.path = [pathItem];
796
+ dataset.issues?.push(issue);
797
+ }
798
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
799
+ if (config$1.abortEarly) {
800
+ dataset.typed = false;
801
+ break;
802
+ }
803
+ }
804
+ if (!valueDataset.typed) dataset.typed = false;
805
+ dataset.value[key] = valueDataset.value;
806
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
807
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
808
+ _addIssue(this, "key", dataset, config$1, {
809
+ input: void 0,
810
+ expected: `"${key}"`,
811
+ path: [{
812
+ type: "object",
813
+ origin: "key",
814
+ input,
815
+ key,
816
+ value: input[key]
817
+ }]
818
+ });
819
+ if (config$1.abortEarly) break;
820
+ }
821
+ }
822
+ if (!dataset.issues || !config$1.abortEarly) {
823
+ for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !Object.prototype.hasOwnProperty.call(this.entries, key)) {
824
+ const valueDataset = this.rest["~run"]({ value: input[key] }, config$1);
825
+ if (valueDataset.issues) {
826
+ const pathItem = {
827
+ type: "object",
828
+ origin: "value",
829
+ input,
830
+ key,
831
+ value: input[key]
832
+ };
833
+ for (const issue of valueDataset.issues) {
834
+ if (issue.path) issue.path.unshift(pathItem);
835
+ else issue.path = [pathItem];
836
+ dataset.issues?.push(issue);
837
+ }
838
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
839
+ if (config$1.abortEarly) {
840
+ dataset.typed = false;
841
+ break;
842
+ }
843
+ }
844
+ if (!valueDataset.typed) dataset.typed = false;
845
+ dataset.value[key] = valueDataset.value;
846
+ }
847
+ }
848
+ } else _addIssue(this, "type", dataset, config$1);
849
+ return dataset;
850
+ }
851
+ });
852
+ }
853
+ __name(objectWithRest, "objectWithRest");
854
+ // @__NO_SIDE_EFFECTS__
855
+ function optional(wrapped, default_) {
856
+ return _standardSchema({
857
+ kind: "schema",
858
+ type: "optional",
859
+ reference: optional,
860
+ expects: `(${wrapped.expects} | undefined)`,
861
+ async: false,
862
+ wrapped,
863
+ default: default_,
864
+ "~run"(dataset, config$1) {
865
+ if (dataset.value === void 0) {
866
+ if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
867
+ if (dataset.value === void 0) {
868
+ dataset.typed = true;
869
+ return dataset;
870
+ }
871
+ }
872
+ return this.wrapped["~run"](dataset, config$1);
873
+ }
874
+ });
875
+ }
876
+ __name(optional, "optional");
877
+ // @__NO_SIDE_EFFECTS__
878
+ function picklist(options, message$1) {
879
+ return _standardSchema({
880
+ kind: "schema",
881
+ type: "picklist",
882
+ reference: picklist,
883
+ expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
884
+ async: false,
885
+ options,
886
+ message: message$1,
887
+ "~run"(dataset, config$1) {
888
+ if (this.options.includes(dataset.value)) dataset.typed = true;
889
+ else _addIssue(this, "type", dataset, config$1);
890
+ return dataset;
891
+ }
892
+ });
893
+ }
894
+ __name(picklist, "picklist");
895
+ // @__NO_SIDE_EFFECTS__
896
+ function record(key, value$1, message$1) {
897
+ return _standardSchema({
898
+ kind: "schema",
899
+ type: "record",
900
+ reference: record,
901
+ expects: "Object",
902
+ async: false,
903
+ key,
904
+ value: value$1,
905
+ message: message$1,
906
+ "~run"(dataset, config$1) {
907
+ const input = dataset.value;
908
+ if (input && typeof input === "object") {
909
+ dataset.typed = true;
910
+ dataset.value = {};
911
+ for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
912
+ const entryValue = input[entryKey];
913
+ const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
914
+ if (keyDataset.issues) {
915
+ const pathItem = {
916
+ type: "object",
917
+ origin: "key",
918
+ input,
919
+ key: entryKey,
920
+ value: entryValue
921
+ };
922
+ for (const issue of keyDataset.issues) {
923
+ issue.path = [pathItem];
924
+ dataset.issues?.push(issue);
925
+ }
926
+ if (!dataset.issues) dataset.issues = keyDataset.issues;
927
+ if (config$1.abortEarly) {
928
+ dataset.typed = false;
929
+ break;
930
+ }
931
+ }
932
+ const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
933
+ if (valueDataset.issues) {
934
+ const pathItem = {
935
+ type: "object",
936
+ origin: "value",
937
+ input,
938
+ key: entryKey,
939
+ value: entryValue
940
+ };
941
+ for (const issue of valueDataset.issues) {
942
+ if (issue.path) issue.path.unshift(pathItem);
943
+ else issue.path = [pathItem];
944
+ dataset.issues?.push(issue);
945
+ }
946
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
947
+ if (config$1.abortEarly) {
948
+ dataset.typed = false;
949
+ break;
950
+ }
951
+ }
952
+ if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
953
+ if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
954
+ }
955
+ } else _addIssue(this, "type", dataset, config$1);
956
+ return dataset;
957
+ }
958
+ });
959
+ }
960
+ __name(record, "record");
961
+ // @__NO_SIDE_EFFECTS__
962
+ function strictObject(entries$1, message$1) {
963
+ return _standardSchema({
964
+ kind: "schema",
965
+ type: "strict_object",
966
+ reference: strictObject,
967
+ expects: "Object",
968
+ async: false,
969
+ entries: entries$1,
970
+ message: message$1,
971
+ "~run"(dataset, config$1) {
972
+ const input = dataset.value;
973
+ if (input && typeof input === "object") {
974
+ dataset.typed = true;
975
+ dataset.value = {};
976
+ for (const key in this.entries) {
977
+ const valueSchema = this.entries[key];
978
+ if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
979
+ const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
980
+ const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
981
+ if (valueDataset.issues) {
982
+ const pathItem = {
983
+ type: "object",
984
+ origin: "value",
985
+ input,
986
+ key,
987
+ value: value$1
988
+ };
989
+ for (const issue of valueDataset.issues) {
990
+ if (issue.path) issue.path.unshift(pathItem);
991
+ else issue.path = [pathItem];
992
+ dataset.issues?.push(issue);
993
+ }
994
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
995
+ if (config$1.abortEarly) {
996
+ dataset.typed = false;
997
+ break;
998
+ }
999
+ }
1000
+ if (!valueDataset.typed) dataset.typed = false;
1001
+ dataset.value[key] = valueDataset.value;
1002
+ } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
1003
+ else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
1004
+ _addIssue(this, "key", dataset, config$1, {
1005
+ input: void 0,
1006
+ expected: `"${key}"`,
1007
+ path: [{
1008
+ type: "object",
1009
+ origin: "key",
1010
+ input,
1011
+ key,
1012
+ value: input[key]
1013
+ }]
1014
+ });
1015
+ if (config$1.abortEarly) break;
1016
+ }
1017
+ }
1018
+ if (!dataset.issues || !config$1.abortEarly) {
1019
+ for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
1020
+ _addIssue(this, "key", dataset, config$1, {
1021
+ input: key,
1022
+ expected: "never",
1023
+ path: [{
1024
+ type: "object",
1025
+ origin: "key",
1026
+ input,
1027
+ key,
1028
+ value: input[key]
1029
+ }]
1030
+ });
1031
+ break;
1032
+ }
1033
+ }
1034
+ } else _addIssue(this, "type", dataset, config$1);
1035
+ return dataset;
1036
+ }
1037
+ });
1038
+ }
1039
+ __name(strictObject, "strictObject");
1040
+ // @__NO_SIDE_EFFECTS__
1041
+ function string(message$1) {
1042
+ return _standardSchema({
1043
+ kind: "schema",
1044
+ type: "string",
1045
+ reference: string,
1046
+ expects: "string",
1047
+ async: false,
1048
+ message: message$1,
1049
+ "~run"(dataset, config$1) {
1050
+ if (typeof dataset.value === "string") dataset.typed = true;
1051
+ else _addIssue(this, "type", dataset, config$1);
1052
+ return dataset;
1053
+ }
1054
+ });
1055
+ }
1056
+ __name(string, "string");
1057
+ // @__NO_SIDE_EFFECTS__
1058
+ function _subIssues(datasets) {
1059
+ let issues;
1060
+ if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
1061
+ else issues = dataset.issues;
1062
+ return issues;
1063
+ }
1064
+ __name(_subIssues, "_subIssues");
1065
+ // @__NO_SIDE_EFFECTS__
1066
+ function union(options, message$1) {
1067
+ return _standardSchema({
1068
+ kind: "schema",
1069
+ type: "union",
1070
+ reference: union,
1071
+ expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
1072
+ async: false,
1073
+ options,
1074
+ message: message$1,
1075
+ "~run"(dataset, config$1) {
1076
+ let validDataset;
1077
+ let typedDatasets;
1078
+ let untypedDatasets;
1079
+ for (const schema of this.options) {
1080
+ const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
1081
+ if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
1082
+ else typedDatasets = [optionDataset];
1083
+ else {
1084
+ validDataset = optionDataset;
1085
+ break;
1086
+ }
1087
+ else if (untypedDatasets) untypedDatasets.push(optionDataset);
1088
+ else untypedDatasets = [optionDataset];
1089
+ }
1090
+ if (validDataset) return validDataset;
1091
+ if (typedDatasets) {
1092
+ if (typedDatasets.length === 1) return typedDatasets[0];
1093
+ _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
1094
+ dataset.typed = true;
1095
+ } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
1096
+ else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
1097
+ return dataset;
1098
+ }
1099
+ });
1100
+ }
1101
+ __name(union, "union");
1102
+ // @__NO_SIDE_EFFECTS__
1103
+ function unknown() {
1104
+ return _standardSchema({
1105
+ kind: "schema",
1106
+ type: "unknown",
1107
+ reference: unknown,
1108
+ expects: "unknown",
1109
+ async: false,
1110
+ "~run"(dataset) {
1111
+ dataset.typed = true;
1112
+ return dataset;
1113
+ }
1114
+ });
1115
+ }
1116
+ __name(unknown, "unknown");
1117
+ // @__NO_SIDE_EFFECTS__
1118
+ function variant(key, options, message$1) {
1119
+ return _standardSchema({
1120
+ kind: "schema",
1121
+ type: "variant",
1122
+ reference: variant,
1123
+ expects: "Object",
1124
+ async: false,
1125
+ key,
1126
+ options,
1127
+ message: message$1,
1128
+ "~run"(dataset, config$1) {
1129
+ const input = dataset.value;
1130
+ if (input && typeof input === "object") {
1131
+ let outputDataset;
1132
+ let maxDiscriminatorPriority = 0;
1133
+ let invalidDiscriminatorKey = this.key;
1134
+ let expectedDiscriminators = [];
1135
+ const parseOptions = /* @__PURE__ */ __name((variant$1, allKeys) => {
1136
+ for (const schema of variant$1.options) {
1137
+ if (schema.type === "variant") parseOptions(schema, new Set(allKeys).add(schema.key));
1138
+ else {
1139
+ let keysAreValid = true;
1140
+ let currentPriority = 0;
1141
+ for (const currentKey of allKeys) {
1142
+ const discriminatorSchema = schema.entries[currentKey];
1143
+ if (currentKey in input ? discriminatorSchema["~run"]({
1144
+ typed: false,
1145
+ value: input[currentKey]
1146
+ }, ABORT_EARLY_CONFIG).issues : discriminatorSchema.type !== "exact_optional" && discriminatorSchema.type !== "optional" && discriminatorSchema.type !== "nullish") {
1147
+ keysAreValid = false;
1148
+ if (invalidDiscriminatorKey !== currentKey && (maxDiscriminatorPriority < currentPriority || maxDiscriminatorPriority === currentPriority && currentKey in input && !(invalidDiscriminatorKey in input))) {
1149
+ maxDiscriminatorPriority = currentPriority;
1150
+ invalidDiscriminatorKey = currentKey;
1151
+ expectedDiscriminators = [];
1152
+ }
1153
+ if (invalidDiscriminatorKey === currentKey) expectedDiscriminators.push(schema.entries[currentKey].expects);
1154
+ break;
1155
+ }
1156
+ currentPriority++;
1157
+ }
1158
+ if (keysAreValid) {
1159
+ const optionDataset = schema["~run"]({ value: input }, config$1);
1160
+ if (!outputDataset || !outputDataset.typed && optionDataset.typed) outputDataset = optionDataset;
1161
+ }
1162
+ }
1163
+ if (outputDataset && !outputDataset.issues) break;
1164
+ }
1165
+ }, "parseOptions");
1166
+ parseOptions(this, /* @__PURE__ */ new Set([this.key]));
1167
+ if (outputDataset) return outputDataset;
1168
+ _addIssue(this, "type", dataset, config$1, {
1169
+ input: input[invalidDiscriminatorKey],
1170
+ expected: /* @__PURE__ */ _joinExpects(expectedDiscriminators, "|"),
1171
+ path: [{
1172
+ type: "object",
1173
+ origin: "value",
1174
+ input,
1175
+ key: invalidDiscriminatorKey,
1176
+ value: input[invalidDiscriminatorKey]
1177
+ }]
1178
+ });
1179
+ } else _addIssue(this, "type", dataset, config$1);
1180
+ return dataset;
1181
+ }
1182
+ });
1183
+ }
1184
+ __name(variant, "variant");
1185
+ // @__NO_SIDE_EFFECTS__
1186
+ function omit(schema, keys) {
1187
+ const entries$1 = { ...schema.entries };
1188
+ for (const key of keys) delete entries$1[key];
1189
+ return _standardSchema({
1190
+ ...schema,
1191
+ entries: entries$1
1192
+ });
1193
+ }
1194
+ __name(omit, "omit");
1195
+ function parse(schema, input, config$1) {
1196
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1197
+ if (dataset.issues) throw new ValiError(dataset.issues);
1198
+ return dataset.value;
1199
+ }
1200
+ __name(parse, "parse");
1201
+ // @__NO_SIDE_EFFECTS__
1202
+ function partial(schema, keys) {
1203
+ const entries$1 = {};
1204
+ for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
1205
+ return _standardSchema({
1206
+ ...schema,
1207
+ entries: entries$1
1208
+ });
1209
+ }
1210
+ __name(partial, "partial");
1211
+ // @__NO_SIDE_EFFECTS__
1212
+ function pick(schema, keys) {
1213
+ const entries$1 = {};
1214
+ for (const key of keys) entries$1[key] = schema.entries[key];
1215
+ return _standardSchema({
1216
+ ...schema,
1217
+ entries: entries$1
1218
+ });
1219
+ }
1220
+ __name(pick, "pick");
1221
+ // @__NO_SIDE_EFFECTS__
1222
+ function pipe(...pipe$1) {
1223
+ return _standardSchema({
1224
+ ...pipe$1[0],
1225
+ pipe: pipe$1,
1226
+ "~run"(dataset, config$1) {
1227
+ for (const item of pipe$1) if (item.kind !== "metadata") {
1228
+ if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
1229
+ dataset.typed = false;
1230
+ break;
1231
+ }
1232
+ if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
1233
+ }
1234
+ return dataset;
1235
+ }
1236
+ });
1237
+ }
1238
+ __name(pipe, "pipe");
1239
+ // @__NO_SIDE_EFFECTS__
1240
+ function safeParse(schema, input, config$1) {
1241
+ const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
1242
+ return {
1243
+ typed: dataset.typed,
1244
+ success: !dataset.issues,
1245
+ output: dataset.value,
1246
+ issues: dataset.issues
1247
+ };
1248
+ }
1249
+ __name(safeParse, "safeParse");
1250
+ // @__NO_SIDE_EFFECTS__
1251
+ function summarize(issues) {
1252
+ let summary = "";
1253
+ for (const issue of issues) {
1254
+ if (summary) summary += "\n";
1255
+ summary += `\xD7 ${issue.message}`;
1256
+ const dotPath = /* @__PURE__ */ getDotPath(issue);
1257
+ if (dotPath) summary += `
1258
+ \u2192 at ${dotPath}`;
1259
+ }
1260
+ return summary;
1261
+ }
1262
+ __name(summarize, "summarize");
1263
+ // @__NO_SIDE_EFFECTS__
1264
+ function unwrap(schema) {
1265
+ return schema.wrapped;
1266
+ }
1267
+ __name(unwrap, "unwrap");
1268
+
1269
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/effects.js
1270
+ var EFFECT_LEVELS = ["none", "read", "write"];
1271
+ var effectsSchema = strictObject({
1272
+ remote: picklist(EFFECT_LEVELS),
1273
+ local: picklist(EFFECT_LEVELS)
1274
+ });
1275
+ var writes = /* @__PURE__ */ __name((effects) => effects === void 0 || effects.remote === "write" || effects.local === "write", "writes");
1276
+
1277
+ // node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@7.0.2_/node_modules/@valibot/to-json-schema/dist/index.mjs
1278
+ function addError(errors, message) {
1279
+ if (errors) {
1280
+ errors.push(message);
1281
+ return errors;
1282
+ }
1283
+ return [message];
1284
+ }
1285
+ __name(addError, "addError");
1286
+ var ESCAPE_REGEX = /[.*+?^${}()|[\]\\]/g;
1287
+ function escapeRegExp(string2) {
1288
+ return string2.replace(ESCAPE_REGEX, "\\$&");
1289
+ }
1290
+ __name(escapeRegExp, "escapeRegExp");
1291
+ function handleError(message, config) {
1292
+ switch (config?.errorMode) {
1293
+ case "ignore":
1294
+ break;
1295
+ case "warn":
1296
+ console.warn(message);
1297
+ break;
1298
+ default:
1299
+ throw new Error(message);
1300
+ }
1301
+ }
1302
+ __name(handleError, "handleError");
1303
+ function isJsonConstValue(value) {
1304
+ return typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || typeof value === "string";
1305
+ }
1306
+ __name(isJsonConstValue, "isJsonConstValue");
1307
+ function isJsonEnumValues(values) {
1308
+ return values.every(isJsonConstValue);
1309
+ }
1310
+ __name(isJsonEnumValues, "isJsonEnumValues");
1311
+ var ReferenceMap = class extends Map {
1312
+ static {
1313
+ __name(this, "ReferenceMap");
1314
+ }
1315
+ /**
1316
+ * Creates an empty schema reference map.
1317
+ */
1318
+ constructor() {
1319
+ super();
1320
+ this.count = 0;
1321
+ this.usedIds = /* @__PURE__ */ new Set();
1322
+ }
1323
+ /**
1324
+ * Adds a schema reference and reserves its ID.
1325
+ *
1326
+ * @param schema The Valibot schema.
1327
+ * @param referenceId The reference ID.
1328
+ *
1329
+ * @returns The reference map.
1330
+ */
1331
+ set(schema, referenceId) {
1332
+ this.usedIds.add(referenceId);
1333
+ return super.set(schema, referenceId);
1334
+ }
1335
+ /**
1336
+ * Creates a reference ID that is not yet used.
1337
+ *
1338
+ * @param definitions The JSON Schema definitions.
1339
+ *
1340
+ * @returns The unused reference ID.
1341
+ */
1342
+ createId(definitions) {
1343
+ while (this.usedIds.has(`${this.count}`) || `${this.count}` in definitions) this.count++;
1344
+ return `${this.count++}`;
1345
+ }
1346
+ };
1347
+ function getLowerBound(current, value) {
1348
+ if (typeof current !== "number" || !Number.isFinite(current) || value > current) return value;
1349
+ return current;
1350
+ }
1351
+ __name(getLowerBound, "getLowerBound");
1352
+ function getUpperBound(current, value) {
1353
+ if (typeof current !== "number" || !Number.isFinite(current) || value < current) return value;
1354
+ return current;
1355
+ }
1356
+ __name(getUpperBound, "getUpperBound");
1357
+ // @__NO_SIDE_EFFECTS__
1358
+ function getNotRestriction(current, value) {
1359
+ return current !== void 0 ? { anyOf: [current, value] } : value;
1360
+ }
1361
+ __name(getNotRestriction, "getNotRestriction");
1362
+ function intersectEnum(jsonSchema, values) {
1363
+ let enumValues = jsonSchema.enum ?? values;
1364
+ if (jsonSchema.enum) {
1365
+ const valueSet = new Set(values);
1366
+ enumValues = enumValues.filter((value) => valueSet.has(value));
1367
+ }
1368
+ if (enumValues.length) jsonSchema.enum = [...new Set(enumValues)];
1369
+ else {
1370
+ delete jsonSchema.enum;
1371
+ jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, {});
1372
+ }
1373
+ }
1374
+ __name(intersectEnum, "intersectEnum");
1375
+ function convertAction(jsonSchema, valibotAction, config) {
1376
+ if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1377
+ let errors;
1378
+ switch (valibotAction.type) {
1379
+ case "base64":
1380
+ jsonSchema.contentEncoding = "base64";
1381
+ break;
1382
+ case "bic":
1383
+ case "cuid2":
1384
+ case "decimal":
1385
+ case "digits":
1386
+ case "domain":
1387
+ case "emoji":
1388
+ case "hash":
1389
+ case "hexadecimal":
1390
+ case "hex_color":
1391
+ case "isrc":
1392
+ case "iso_time_second":
1393
+ case "iso_week":
1394
+ case "ksuid":
1395
+ case "mac":
1396
+ case "mac48":
1397
+ case "mac64":
1398
+ case "nanoid":
1399
+ case "octal":
1400
+ case "slug":
1401
+ case "ulid":
1402
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1403
+ else jsonSchema.pattern = valibotAction.requirement.source;
1404
+ break;
1405
+ case "description":
1406
+ jsonSchema.description = valibotAction.description;
1407
+ break;
1408
+ case "email":
1409
+ case "rfc_email":
1410
+ jsonSchema.format = "email";
1411
+ break;
1412
+ case "ends_with":
1413
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1414
+ else jsonSchema.pattern = `${escapeRegExp(valibotAction.requirement)}$`;
1415
+ break;
1416
+ case "empty":
1417
+ if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
1418
+ else {
1419
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1420
+ jsonSchema.maxLength = 0;
1421
+ }
1422
+ break;
1423
+ case "entries":
1424
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1425
+ errors = addError(errors, 'The requirement of the "entries" action must be a non-negative integer.');
1426
+ break;
1427
+ }
1428
+ jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1429
+ jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1430
+ break;
1431
+ case "examples":
1432
+ if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.examples];
1433
+ else jsonSchema.examples = valibotAction.examples;
1434
+ break;
1435
+ case "gt_value":
1436
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1437
+ errors = addError(errors, `The "gt_value" action is not supported on type "${jsonSchema.type}".`);
1438
+ break;
1439
+ }
1440
+ if (!Number.isFinite(valibotAction.requirement)) {
1441
+ errors = addError(errors, 'The requirement of the "gt_value" action is not JSON compatible.');
1442
+ break;
1443
+ }
1444
+ if (config?.target === "openapi-3.0") {
1445
+ errors = addError(errors, 'The "gt_value" action is not supported for OpenAPI 3.0.');
1446
+ break;
1447
+ }
1448
+ jsonSchema.exclusiveMinimum = getLowerBound(jsonSchema.exclusiveMinimum, valibotAction.requirement);
1449
+ break;
1450
+ case "includes":
1451
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1452
+ else jsonSchema.pattern = escapeRegExp(valibotAction.requirement);
1453
+ break;
1454
+ case "integer":
1455
+ jsonSchema.type = "integer";
1456
+ break;
1457
+ case "ipv4":
1458
+ jsonSchema.format = "ipv4";
1459
+ break;
1460
+ case "ipv6":
1461
+ jsonSchema.format = "ipv6";
1462
+ break;
1463
+ case "iso_date":
1464
+ jsonSchema.format = "date";
1465
+ break;
1466
+ case "iso_date_time":
1467
+ case "iso_timestamp":
1468
+ jsonSchema.format = "date-time";
1469
+ break;
1470
+ case "iso_time":
1471
+ jsonSchema.format = "time";
1472
+ break;
1473
+ case "jws_compact":
1474
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1475
+ else jsonSchema.pattern = valibotAction.requirement.source;
1476
+ break;
1477
+ case "length":
1478
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1479
+ errors = addError(errors, 'The requirement of the "length" action must be a non-negative integer.');
1480
+ break;
1481
+ }
1482
+ if (jsonSchema.type === "array") {
1483
+ jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1484
+ jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1485
+ } else {
1486
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1487
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1488
+ jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1489
+ }
1490
+ break;
1491
+ case "lt_value":
1492
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1493
+ errors = addError(errors, `The "lt_value" action is not supported on type "${jsonSchema.type}".`);
1494
+ break;
1495
+ }
1496
+ if (!Number.isFinite(valibotAction.requirement)) {
1497
+ errors = addError(errors, 'The requirement of the "lt_value" action is not JSON compatible.');
1498
+ break;
1499
+ }
1500
+ if (config?.target === "openapi-3.0") {
1501
+ errors = addError(errors, 'The "lt_value" action is not supported for OpenAPI 3.0.');
1502
+ break;
1503
+ }
1504
+ jsonSchema.exclusiveMaximum = getUpperBound(jsonSchema.exclusiveMaximum, valibotAction.requirement);
1505
+ break;
1506
+ case "max_entries":
1507
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1508
+ errors = addError(errors, 'The requirement of the "max_entries" action must be a non-negative integer.');
1509
+ break;
1510
+ }
1511
+ jsonSchema.maxProperties = getUpperBound(jsonSchema.maxProperties, valibotAction.requirement);
1512
+ break;
1513
+ case "max_length":
1514
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1515
+ errors = addError(errors, 'The requirement of the "max_length" action must be a non-negative integer.');
1516
+ break;
1517
+ }
1518
+ if (jsonSchema.type === "array") jsonSchema.maxItems = getUpperBound(jsonSchema.maxItems, valibotAction.requirement);
1519
+ else {
1520
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1521
+ jsonSchema.maxLength = getUpperBound(jsonSchema.maxLength, valibotAction.requirement);
1522
+ }
1523
+ break;
1524
+ case "max_value":
1525
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1526
+ errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
1527
+ break;
1528
+ }
1529
+ if (!Number.isFinite(valibotAction.requirement)) {
1530
+ errors = addError(errors, 'The requirement of the "max_value" action is not JSON compatible.');
1531
+ break;
1532
+ }
1533
+ jsonSchema.maximum = getUpperBound(jsonSchema.maximum, valibotAction.requirement);
1534
+ break;
1535
+ case "metadata":
1536
+ if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
1537
+ if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
1538
+ if (Array.isArray(valibotAction.metadata.examples)) if (Array.isArray(jsonSchema.examples)) jsonSchema.examples = [...jsonSchema.examples, ...valibotAction.metadata.examples];
1539
+ else jsonSchema.examples = valibotAction.metadata.examples;
1540
+ for (const key of Object.keys(valibotAction.metadata)) if (key !== "title" && key !== "description" && key !== "examples" && key !== "__proto__") jsonSchema[key] = valibotAction.metadata[key];
1541
+ break;
1542
+ case "min_entries":
1543
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1544
+ errors = addError(errors, 'The requirement of the "min_entries" action must be a non-negative integer.');
1545
+ break;
1546
+ }
1547
+ jsonSchema.minProperties = getLowerBound(jsonSchema.minProperties, valibotAction.requirement);
1548
+ break;
1549
+ case "min_length":
1550
+ if (!Number.isInteger(valibotAction.requirement) || valibotAction.requirement < 0) {
1551
+ errors = addError(errors, 'The requirement of the "min_length" action must be a non-negative integer.');
1552
+ break;
1553
+ }
1554
+ if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, valibotAction.requirement);
1555
+ else {
1556
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1557
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, valibotAction.requirement);
1558
+ }
1559
+ break;
1560
+ case "min_value":
1561
+ if (jsonSchema.type !== "number" && jsonSchema.type !== "integer") {
1562
+ errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
1563
+ break;
1564
+ }
1565
+ if (!Number.isFinite(valibotAction.requirement)) {
1566
+ errors = addError(errors, 'The requirement of the "min_value" action is not JSON compatible.');
1567
+ break;
1568
+ }
1569
+ jsonSchema.minimum = getLowerBound(jsonSchema.minimum, valibotAction.requirement);
1570
+ break;
1571
+ case "multiple_of":
1572
+ jsonSchema.multipleOf = valibotAction.requirement;
1573
+ break;
1574
+ case "non_empty":
1575
+ if (jsonSchema.type === "array") jsonSchema.minItems = getLowerBound(jsonSchema.minItems, 1);
1576
+ else {
1577
+ if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
1578
+ jsonSchema.minLength = getLowerBound(jsonSchema.minLength, 1);
1579
+ }
1580
+ break;
1581
+ case "not_value":
1582
+ if (!isJsonConstValue(valibotAction.requirement)) {
1583
+ errors = addError(errors, 'The requirement of the "not_value" action is not JSON compatible.');
1584
+ break;
1585
+ }
1586
+ jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, config?.target === "openapi-3.0" ? { enum: [valibotAction.requirement] } : { const: valibotAction.requirement });
1587
+ break;
1588
+ case "not_values":
1589
+ if (!isJsonEnumValues(valibotAction.requirement)) {
1590
+ errors = addError(errors, 'A requirement of the "not_values" action is not JSON compatible.');
1591
+ break;
1592
+ }
1593
+ if (valibotAction.requirement.length) jsonSchema.not = /* @__PURE__ */ getNotRestriction(jsonSchema.not, { enum: [...new Set(valibotAction.requirement)] });
1594
+ break;
1595
+ case "regex":
1596
+ if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
1597
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1598
+ else jsonSchema.pattern = valibotAction.requirement.source;
1599
+ break;
1600
+ case "safe_integer":
1601
+ jsonSchema.type = "integer";
1602
+ jsonSchema.minimum = getLowerBound(jsonSchema.minimum, Number.MIN_SAFE_INTEGER);
1603
+ jsonSchema.maximum = getUpperBound(jsonSchema.maximum, Number.MAX_SAFE_INTEGER);
1604
+ break;
1605
+ case "starts_with":
1606
+ if (jsonSchema.pattern) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with another regex action.`);
1607
+ else jsonSchema.pattern = `^${escapeRegExp(valibotAction.requirement)}`;
1608
+ break;
1609
+ case "title":
1610
+ jsonSchema.title = valibotAction.title;
1611
+ break;
1612
+ case "url":
1613
+ jsonSchema.format = "uri";
1614
+ break;
1615
+ case "uuid":
1616
+ jsonSchema.format = "uuid";
1617
+ break;
1618
+ case "value":
1619
+ if (!isJsonConstValue(valibotAction.requirement)) {
1620
+ errors = addError(errors, 'The requirement of the "value" action is not JSON compatible.');
1621
+ break;
1622
+ }
1623
+ if (config?.target === "openapi-3.0") intersectEnum(jsonSchema, [valibotAction.requirement]);
1624
+ else if ("const" in jsonSchema && jsonSchema.const !== valibotAction.requirement) errors = addError(errors, `The "${valibotAction.type}" action is not supported in combination with a different "const" restriction.`);
1625
+ else jsonSchema.const = valibotAction.requirement;
1626
+ break;
1627
+ case "values":
1628
+ if (!isJsonEnumValues(valibotAction.requirement)) {
1629
+ errors = addError(errors, 'A requirement of the "values" action is not JSON compatible.');
1630
+ break;
1631
+ }
1632
+ intersectEnum(jsonSchema, valibotAction.requirement);
1633
+ break;
1634
+ default:
1635
+ errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
1636
+ }
1637
+ if (config?.overrideAction) {
1638
+ const actionOverride = config.overrideAction({
1639
+ valibotAction,
1640
+ jsonSchema,
1641
+ errors
1642
+ });
1643
+ if (actionOverride) return { ...actionOverride };
1644
+ }
1645
+ if (errors) for (const message of errors) handleError(message, config);
1646
+ return jsonSchema;
1647
+ }
1648
+ __name(convertAction, "convertAction");
1649
+ function flattenPipe(pipe2) {
1650
+ return pipe2.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1651
+ }
1652
+ __name(flattenPipe, "flattenPipe");
1653
+ function getDefinitionRef(referenceId) {
1654
+ return `#/$defs/${referenceId.replaceAll("~", "~0").replaceAll("/", "~1")}`;
1655
+ }
1656
+ __name(getDefinitionRef, "getDefinitionRef");
1657
+ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1658
+ if (!skipRef) {
1659
+ const referenceId = context.referenceMap.get(valibotSchema);
1660
+ if (referenceId) {
1661
+ jsonSchema.$ref = getDefinitionRef(referenceId);
1662
+ if (config?.overrideRef) {
1663
+ const refOverride = config.overrideRef({
1664
+ ...context,
1665
+ referenceId,
1666
+ valibotSchema,
1667
+ jsonSchema
1668
+ });
1669
+ if (refOverride) jsonSchema.$ref = refOverride;
1670
+ }
1671
+ return jsonSchema;
1672
+ }
1673
+ }
1674
+ if ("pipe" in valibotSchema) {
1675
+ const flatPipe = flattenPipe(valibotSchema.pipe);
1676
+ let startIndex = 0;
1677
+ let stopIndex = flatPipe.length - 1;
1678
+ if (config?.typeMode === "input") {
1679
+ const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "to_bigint" || item.type === "to_boolean" || item.type === "to_date" || item.type === "to_number" || item.type === "to_string" || item.type === "transform"));
1680
+ if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1681
+ } else if (config?.typeMode === "output") {
1682
+ const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1683
+ if (outputStartIndex !== -1) startIndex = outputStartIndex;
1684
+ }
1685
+ for (let index = startIndex; index <= stopIndex; index++) {
1686
+ const valibotPipeItem = flatPipe[index];
1687
+ if (valibotPipeItem.kind === "schema") {
1688
+ if (index > startIndex) handleError('Set the "typeMode" config to "input" or "output" to convert pipelines with multiple schemas.', config);
1689
+ jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1690
+ } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1691
+ }
1692
+ return jsonSchema;
1693
+ }
1694
+ let errors;
1695
+ switch (valibotSchema.type) {
1696
+ case "boolean":
1697
+ jsonSchema.type = "boolean";
1698
+ break;
1699
+ case "null":
1700
+ if (config?.target === "openapi-3.0") jsonSchema.enum = [null];
1701
+ else jsonSchema.type = "null";
1702
+ break;
1703
+ case "number":
1704
+ jsonSchema.type = "number";
1705
+ break;
1706
+ case "string":
1707
+ jsonSchema.type = "string";
1708
+ break;
1709
+ case "array":
1710
+ jsonSchema.type = "array";
1711
+ jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
1712
+ break;
1713
+ case "tuple":
1714
+ case "tuple_with_rest":
1715
+ case "loose_tuple":
1716
+ case "strict_tuple":
1717
+ jsonSchema.type = "array";
1718
+ if (config?.target === "openapi-3.0") {
1719
+ jsonSchema.items = { anyOf: [] };
1720
+ jsonSchema.minItems = valibotSchema.items.length;
1721
+ for (const item of valibotSchema.items) jsonSchema.items.anyOf.push(convertSchema({}, item, config, context));
1722
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.items.anyOf.push(convertSchema({}, valibotSchema.rest, config, context));
1723
+ else if (valibotSchema.type === "strict_tuple" || valibotSchema.type === "tuple") jsonSchema.maxItems = valibotSchema.items.length;
1724
+ } else if (config?.target === "draft-2020-12") {
1725
+ jsonSchema.prefixItems = [];
1726
+ jsonSchema.minItems = valibotSchema.items.length;
1727
+ for (const item of valibotSchema.items) jsonSchema.prefixItems.push(convertSchema({}, item, config, context));
1728
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.items = convertSchema({}, valibotSchema.rest, config, context);
1729
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.items = false;
1730
+ } else {
1731
+ jsonSchema.items = [];
1732
+ jsonSchema.minItems = valibotSchema.items.length;
1733
+ for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
1734
+ if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
1735
+ else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
1736
+ }
1737
+ break;
1738
+ case "object":
1739
+ case "object_with_rest":
1740
+ case "loose_object":
1741
+ case "strict_object":
1742
+ jsonSchema.type = "object";
1743
+ jsonSchema.properties = {};
1744
+ jsonSchema.required = [];
1745
+ for (const key in valibotSchema.entries) {
1746
+ const entry = valibotSchema.entries[key];
1747
+ jsonSchema.properties[key] = convertSchema({}, entry, config, context);
1748
+ if (entry.type !== "exact_optional" && entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
1749
+ }
1750
+ if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
1751
+ else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
1752
+ break;
1753
+ case "record":
1754
+ if (config?.target === "openapi-3.0" && "pipe" in valibotSchema.key) errors = addError(errors, 'The "record" schema with a schema for the key that contains a "pipe" cannot be converted to JSON Schema.');
1755
+ if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
1756
+ jsonSchema.type = "object";
1757
+ if (config?.target !== "openapi-3.0") jsonSchema.propertyNames = convertSchema({}, valibotSchema.key, config, context);
1758
+ jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
1759
+ break;
1760
+ case "any":
1761
+ case "unknown":
1762
+ break;
1763
+ case "never":
1764
+ jsonSchema.not = {};
1765
+ break;
1766
+ case "nullable":
1767
+ case "nullish":
1768
+ if (config?.target === "openapi-3.0") {
1769
+ const innerSchema = convertSchema({}, valibotSchema.wrapped, config, context);
1770
+ Object.assign(jsonSchema, innerSchema);
1771
+ jsonSchema.nullable = true;
1772
+ } else jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
1773
+ if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1774
+ break;
1775
+ case "exact_optional":
1776
+ case "optional":
1777
+ case "undefinedable":
1778
+ jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
1779
+ if (valibotSchema.default !== void 0) jsonSchema.default = typeof valibotSchema.default === "function" ? valibotSchema.default() : valibotSchema.default;
1780
+ break;
1781
+ case "literal":
1782
+ if (!isJsonConstValue(valibotSchema.literal)) {
1783
+ errors = addError(errors, 'The value of the "literal" schema is not JSON compatible.');
1784
+ break;
1785
+ }
1786
+ if (config?.target === "openapi-3.0") jsonSchema.enum = [valibotSchema.literal];
1787
+ else jsonSchema.const = valibotSchema.literal;
1788
+ break;
1789
+ case "enum":
1790
+ case "picklist": {
1791
+ const options = valibotSchema.options;
1792
+ if (!options.every((option) => typeof option === "string" || typeof option === "number" && Number.isFinite(option))) {
1793
+ errors = addError(errors, `An option of the "${valibotSchema.type}" schema is not JSON compatible.`);
1794
+ break;
1795
+ }
1796
+ jsonSchema.enum = options;
1797
+ if (options.every((option) => typeof option === "string")) jsonSchema.type = "string";
1798
+ else if (options.every((option) => typeof option === "number")) jsonSchema.type = "number";
1799
+ else if (config?.target !== "openapi-3.0") jsonSchema.type = ["string", "number"];
1800
+ break;
1801
+ }
1802
+ case "union":
1803
+ jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1804
+ break;
1805
+ case "variant":
1806
+ jsonSchema.oneOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1807
+ break;
1808
+ case "intersect":
1809
+ jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
1810
+ break;
1811
+ case "lazy": {
1812
+ let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
1813
+ if (!wrappedValibotSchema) {
1814
+ wrappedValibotSchema = valibotSchema.getter(void 0);
1815
+ context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
1816
+ }
1817
+ let referenceId = context.referenceMap.get(wrappedValibotSchema);
1818
+ if (!referenceId) {
1819
+ referenceId = context.referenceMap.createId(context.definitions);
1820
+ context.referenceMap.set(wrappedValibotSchema, referenceId);
1821
+ context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
1822
+ }
1823
+ jsonSchema.$ref = getDefinitionRef(referenceId);
1824
+ if (config?.overrideRef) {
1825
+ const refOverride = config.overrideRef({
1826
+ ...context,
1827
+ referenceId,
1828
+ valibotSchema: wrappedValibotSchema,
1829
+ jsonSchema
1830
+ });
1831
+ if (refOverride) jsonSchema.$ref = refOverride;
1832
+ }
1833
+ break;
1834
+ }
1835
+ default:
1836
+ errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
1837
+ }
1838
+ if (config?.overrideSchema) {
1839
+ const schemaOverride = config.overrideSchema({
1840
+ ...context,
1841
+ referenceId: context.referenceMap.get(valibotSchema),
1842
+ valibotSchema,
1843
+ jsonSchema,
1844
+ errors
1845
+ });
1846
+ if (schemaOverride) return { ...schemaOverride };
1847
+ }
1848
+ if (errors) for (const message of errors) handleError(message, config);
1849
+ return jsonSchema;
1850
+ }
1851
+ __name(convertSchema, "convertSchema");
1852
+ var store;
1853
+ function getGlobalDefs() {
1854
+ return store;
1855
+ }
1856
+ __name(getGlobalDefs, "getGlobalDefs");
1857
+ function toJsonSchema(schema, config) {
1858
+ const context = {
1859
+ definitions: {},
1860
+ referenceMap: new ReferenceMap(),
1861
+ getterMap: /* @__PURE__ */ new Map()
1862
+ };
1863
+ const definitions = config?.definitions ?? getGlobalDefs();
1864
+ if (definitions) {
1865
+ for (const key in definitions) context.referenceMap.set(definitions[key], key);
1866
+ for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
1867
+ }
1868
+ const jsonSchema = convertSchema({}, schema, config, context);
1869
+ const target = config?.target ?? "draft-07";
1870
+ if (target === "draft-2020-12") jsonSchema.$schema = "https://json-schema.org/draft/2020-12/schema";
1871
+ else if (target === "draft-07") jsonSchema.$schema = "http://json-schema.org/draft-07/schema#";
1872
+ if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1873
+ return jsonSchema;
1874
+ }
1875
+ __name(toJsonSchema, "toJsonSchema");
1876
+ var SUPPORTED_TARGETS = [
1877
+ "draft-07",
1878
+ "draft-2020-12",
1879
+ "openapi-3.0"
1880
+ ];
1881
+ function toStandardJsonSchema(schema) {
1882
+ return { "~standard": {
1883
+ ...schema["~standard"],
1884
+ jsonSchema: {
1885
+ input(options) {
1886
+ if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
1887
+ typeMode: "input",
1888
+ target: options.target,
1889
+ ...options.libraryOptions
1890
+ });
1891
+ throw new Error(`Unsupported target: ${options.target}`);
1892
+ },
1893
+ output(options) {
1894
+ if (SUPPORTED_TARGETS.includes(options.target)) return toJsonSchema(schema, {
1895
+ typeMode: "output",
1896
+ target: options.target,
1897
+ ...options.libraryOptions
1898
+ });
1899
+ throw new Error(`Unsupported target: ${options.target}`);
1900
+ }
1901
+ }
1902
+ } };
1903
+ }
1904
+ __name(toStandardJsonSchema, "toStandardJsonSchema");
1905
+
1906
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/registry.js
1907
+ var word = pipe(string(), regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/, "a lower-case word, words joined by -"));
1908
+ var SNAKE_CASE = /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/;
1909
+ var text = pipe(string(), regex(/\S/, "must not be empty"));
1910
+ var dottedId = pipe(string(), regex(/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/, "dotted lower-case words, such as `page.next`"));
1911
+ var RegistryError = class extends Error {
1912
+ static {
1913
+ __name(this, "RegistryError");
1914
+ }
1915
+ registry;
1916
+ problems;
1917
+ constructor(registry, problems) {
1918
+ super(`${registry} registry: ${problems.join("; ")}`);
1919
+ this.registry = registry;
1920
+ this.problems = problems;
1921
+ this.name = "RegistryError";
1922
+ }
1923
+ };
1924
+ var issuesOf = /* @__PURE__ */ __name((issues) => issues.map((issue) => {
1925
+ const path = getDotPath(issue);
1926
+ return path ? `${path}: ${issue.message}` : issue.message;
1927
+ }), "issuesOf");
1928
+ var parseRegistry = /* @__PURE__ */ __name((registry, schema, input, check2 = () => []) => {
1929
+ const parsed = safeParse(schema, input);
1930
+ if (!parsed.success)
1931
+ throw new RegistryError(registry, issuesOf(parsed.issues));
1932
+ const problems = check2(parsed.output);
1933
+ if (problems.length > 0)
1934
+ throw new RegistryError(registry, problems);
1935
+ return parsed.output;
1936
+ }, "parseRegistry");
1937
+ var duplicates = /* @__PURE__ */ __name((values) => [...new Set(values.filter((value, index) => values.indexOf(value) !== index))].sort(), "duplicates");
1938
+ var jsonSchemaOf = /* @__PURE__ */ __name((schema, definitions) => toJsonSchema(schema, { target: "draft-2020-12", ...definitions ? { definitions } : {} }), "jsonSchemaOf");
1939
+ var PLACEHOLDER = /\{([a-z][a-z0-9]*(?:_[a-z0-9]+)*)\}/g;
1940
+ var placeholders = /* @__PURE__ */ __name((template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1] ?? ""), "placeholders");
1941
+ var fill = /* @__PURE__ */ __name((template, values) => template.replace(PLACEHOLDER, (_, name) => {
1942
+ const value = values[name];
1943
+ if (value === void 0)
1944
+ throw new Error(`no value for {${name}} in "${template}"`);
1945
+ return String(value);
1946
+ }), "fill");
1947
+
1948
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/output.js
1949
+ var MAX_NEXT_STEPS = 2;
1950
+ var COMPACT_FLAG = "--compact";
1951
+ var isoTime = pipe(string(), isoTimestamp("an ISO 8601 time in UTC"), endsWith("Z", "an ISO 8601 time in UTC, ending in `Z`"));
1952
+ var localTime = pipe(string(), regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}$/, "an ISO 8601 time with its offset"));
1953
+ var reference = pipe(string(), regex(/^[a-z]+:\S+$/, "a reference such as `note:42`"));
1954
+ var nextStepSchema = variant("kind", [
1955
+ strictObject({
1956
+ kind: literal("command"),
1957
+ step: dottedId,
1958
+ /** The command path as one string, `messages list` — what the MCP router tools take as `command`. */
1959
+ command: text,
1960
+ args: record(string(), unknown()),
1961
+ /**
1962
+ * The whole line to type, with the tool and the profile it ran with: `tg personal mcp config`. Only the CLI
1963
+ * knows the profile, so it fills this; MCP answers leave it out.
1964
+ */
1965
+ line: optional(text),
1966
+ why: text,
1967
+ /** True only when the target command is known to write nothing, here or at the provider. */
1968
+ safe_to_auto_execute: boolean()
1969
+ }),
1970
+ /** Something only the person can do — sign in on the phone, approve a device. */
1971
+ strictObject({
1972
+ kind: literal("user_action"),
1973
+ step: dottedId,
1974
+ why: text,
1975
+ safe_to_auto_execute: literal(false)
1976
+ })
1977
+ ]);
1978
+ var missingSchema = strictObject({
1979
+ field: text,
1980
+ why: text,
1981
+ /** Left out when there is nothing to run that would fill the field. */
1982
+ step: optional(dottedId)
1983
+ });
1984
+ var limit = pipe(number(), integer(), minValue(1));
1985
+ var totalSchema = strictObject({
1986
+ value: pipe(number(), integer(), minValue(0)),
1987
+ relation: picklist(["eq", "gte"])
1988
+ });
1989
+ var pageSchema = variant("mode", [
1990
+ strictObject({
1991
+ mode: literal("page"),
1992
+ limit,
1993
+ has_more: boolean(),
1994
+ next_page: optional(pipe(number(), integer(), minValue(2))),
1995
+ total: optional(totalSchema)
1996
+ }),
1997
+ strictObject({
1998
+ mode: literal("cursor"),
1999
+ limit,
2000
+ has_more: boolean(),
2001
+ next_cursor: optional(text),
2002
+ total: optional(totalSchema)
2003
+ })
2004
+ ]);
2005
+ var issueSchema = strictObject({
2006
+ code: picklist(errorCodes),
2007
+ reason: optional(dottedId),
2008
+ /** The account, provider or source that is missing from the answer. */
2009
+ source: text
2010
+ });
2011
+ var metaSchema = strictObject({
2012
+ run_id: text,
2013
+ duration_ms: pipe(number(), integer(), minValue(0)),
2014
+ accounts: optional(array(text)),
2015
+ complete: boolean(),
2016
+ issues: optional(array(issueSchema)),
2017
+ truncated: optional(boolean()),
2018
+ timezone: optional(text),
2019
+ /** When the command answered, for an agent that plans from "now" (WC-TIME-7); `timezone` names the zone of `now_local`. */
2020
+ now: optional(isoTime),
2021
+ now_local: optional(localTime),
2022
+ window: optional(strictObject({ since: optional(isoTime), until: optional(isoTime) }))
2023
+ });
2024
+ var offsetOf = /* @__PURE__ */ __name((at, zone) => {
2025
+ const name = new Intl.DateTimeFormat("en-US", { timeZone: zone, timeZoneName: "longOffset" }).formatToParts(at).find((part) => part.type === "timeZoneName")?.value ?? "GMT";
2026
+ return name === "GMT" ? "+00:00" : name.slice(3);
2027
+ }, "offsetOf");
2028
+ var clockMeta = /* @__PURE__ */ __name((at, zone) => {
2029
+ const offset = offsetOf(at, zone);
2030
+ const sign = offset.startsWith("-") ? -1 : 1;
2031
+ const [hours = 0, minutes = 0] = offset.slice(1).split(":").map(Number);
2032
+ const wall = new Date(at + sign * (hours * 60 + minutes) * 6e4).toISOString().slice(0, -1);
2033
+ return { now: new Date(at).toISOString(), now_local: `${wall}${offset}`, timezone: zone };
2034
+ }, "clockMeta");
2035
+ var nextSteps = optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS)));
2036
+ var listEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2037
+ items: array(item),
2038
+ page: pageSchema,
2039
+ next: nextSteps,
2040
+ missing: optional(array(missingSchema)),
2041
+ meta: metaSchema
2042
+ }), "listEnvelopeSchema");
2043
+ var itemEnvelopeSchema = /* @__PURE__ */ __name((item) => strictObject({
2044
+ item,
2045
+ next: nextSteps,
2046
+ missing: optional(array(missingSchema)),
2047
+ meta: metaSchema
2048
+ }), "itemEnvelopeSchema");
2049
+ var jsonlEndSchema = strictObject({
2050
+ type: literal("end"),
2051
+ complete: boolean(),
2052
+ issues: optional(array(issueSchema)),
2053
+ page: pageSchema
2054
+ });
2055
+ var jsonlOf = /* @__PURE__ */ __name(({ items, page, meta }) => [
2056
+ ...items.map((data) => JSON.stringify({ type: "item", data })),
2057
+ JSON.stringify({ type: "end", complete: meta.complete, ...meta.issues ? { issues: meta.issues } : {}, page })
2058
+ ].join("\n"), "jsonlOf");
2059
+
2060
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/errors.js
2061
+ var CRASH_CODE = "internal_error";
2062
+ var CRASH_REASON = "command.crashed";
2063
+ var errorObjectSchema = strictObject({
2064
+ error: strictObject({
2065
+ code: picklist([...errorCodes, CRASH_CODE]),
2066
+ reason: dottedId,
2067
+ message: text,
2068
+ /** The option or argument at fault. */
2069
+ param: optional(text),
2070
+ details: optional(record(string(), unknown())),
2071
+ next: optional(pipe(array(nextStepSchema), maxLength(MAX_NEXT_STEPS))),
2072
+ /** Whether running the same command again may work and cannot do harm; never for a write that may have landed. */
2073
+ retry: strictObject({
2074
+ safe: boolean(),
2075
+ after_ms: optional(pipe(number(), integer(), minValue(0)))
2076
+ }),
2077
+ /** Optional until every CLI keeps a run for each failure. */
2078
+ run_id: optional(text)
2079
+ })
2080
+ });
2081
+ var reasonSchema = strictObject({
2082
+ reason: dottedId,
2083
+ code: picklist([...errorCodes, CRASH_CODE]),
2084
+ /** `{name}` placeholders, each one of `details`. */
2085
+ message: pipe(text, maxLength(120)),
2086
+ details: array(pipe(string(), regex(SNAKE_CASE, "a snake_case key"))),
2087
+ step: optional(dottedId)
2088
+ });
2089
+ var defineReasons = /* @__PURE__ */ __name((input) => parseRegistry("error reasons", array(reasonSchema), input, (reasons) => [
2090
+ ...duplicates(reasons.map((entry) => entry.reason)).map((reason) => `"${reason}" is listed twice`),
2091
+ ...reasons.flatMap((entry) => placeholders(entry.message).filter((name) => !entry.details.includes(name)).map((name) => `${entry.reason}: the message names {${name}}, which is not one of its details`))
2092
+ ]), "defineReasons");
2093
+ var COMMON_DETAILS = ["attempts", "status", "request_id", "operation", "operation_id"];
2094
+ var BASE_REASONS = defineReasons([
2095
+ { reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
2096
+ {
2097
+ reason: "batch.read-budget",
2098
+ code: "validation_error",
2099
+ message: "batch stored-text read budget exhausted",
2100
+ details: []
2101
+ },
2102
+ { reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
2103
+ { reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
2104
+ { reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
2105
+ { reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
2106
+ { reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
2107
+ {
2108
+ reason: "tool.not-installed",
2109
+ code: "not_found",
2110
+ message: "no wcat-<name> program by that name is on PATH",
2111
+ details: ["tool", "installed"]
2112
+ },
2113
+ {
2114
+ reason: "confirmation.required",
2115
+ code: "confirmation_required",
2116
+ message: "this changes something; confirm it",
2117
+ details: []
2118
+ },
2119
+ { reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
2120
+ { reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeout_ms"] },
2121
+ { reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
2122
+ { reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
2123
+ { reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
2124
+ {
2125
+ reason: "provider.invalid-response",
2126
+ code: "invalid_response",
2127
+ message: "the answer could not be read",
2128
+ details: []
2129
+ },
2130
+ {
2131
+ reason: "output.too-large",
2132
+ code: "invalid_response",
2133
+ message: "the output is over {max_bytes} bytes",
2134
+ details: ["max_bytes", "buffered_bytes", "partial_output"]
2135
+ },
2136
+ {
2137
+ reason: "output.fields-unavailable",
2138
+ code: "invalid_response",
2139
+ message: "fields can be picked only from whole JSON values",
2140
+ details: []
2141
+ },
2142
+ { reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
2143
+ {
2144
+ reason: "write.conflict",
2145
+ code: "conflict",
2146
+ message: "it changed since it was read; read it again",
2147
+ details: []
2148
+ },
2149
+ { reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
2150
+ { reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] }
2151
+ ]);
2152
+
2153
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/standards/steps.js
2154
+ var SAME_COMMAND = "*";
2155
+ var commandPath = pipe(string(), regex(/^[a-z][a-z0-9-]*( [a-z][a-z0-9-]*)*$/, "a command path such as `messages sync`"));
2156
+ var stepSchema = union([
2157
+ strictObject({
2158
+ id: dottedId,
2159
+ kind: optional(literal("command"), "command"),
2160
+ command: union([literal(SAME_COMMAND), commandPath]),
2161
+ args: array(strictObject({
2162
+ name: pipe(string(), regex(SNAKE_CASE, "an argument or option name in snake_case")),
2163
+ required: boolean()
2164
+ })),
2165
+ why: pipe(text, maxLength(120))
2166
+ }),
2167
+ strictObject({ id: dottedId, kind: literal("user_action"), why: pipe(text, maxLength(120)) })
2168
+ ]);
2169
+ var argsOf = /* @__PURE__ */ __name((step) => step.kind === "command" ? step.args : [], "argsOf");
2170
+ var defineSteps = /* @__PURE__ */ __name((input) => parseRegistry("steps", array(stepSchema), input, (steps) => [
2171
+ ...duplicates(steps.map((step) => step.id)).map((id) => `"${id}" is listed twice`),
2172
+ ...steps.flatMap((step) => duplicates(argsOf(step).map((arg) => arg.name)).map((name) => `${step.id}: argument "${name}" is listed twice`))
2173
+ ]), "defineSteps");
2174
+ var BINDS = /^[^\p{Cc}\u2028\u2029]*$/u;
2175
+ var binds = /* @__PURE__ */ __name((value) => typeof value === "number" || typeof value === "boolean" || typeof value === "string" && BINDS.test(value), "binds");
2176
+ var stepOf = /* @__PURE__ */ __name((definition, input = {}) => {
2177
+ const args = input.args ?? {};
2178
+ if (definition.kind === "user_action")
2179
+ return {
2180
+ kind: "user_action",
2181
+ step: definition.id,
2182
+ why: fill(definition.why, { ...input.values }),
2183
+ safe_to_auto_execute: false
2184
+ };
2185
+ const command = definition.command === SAME_COMMAND ? input.command : definition.command;
2186
+ if (!command)
2187
+ throw new Error(`${definition.id}: the step runs the same command, so pass the command`);
2188
+ const known = new Set(definition.args.map((arg) => arg.name));
2189
+ if (definition.command !== SAME_COMMAND) {
2190
+ for (const name of Object.keys(args))
2191
+ if (!known.has(name))
2192
+ throw new Error(`${definition.id}: no argument "${name}"`);
2193
+ }
2194
+ for (const arg of definition.args)
2195
+ if (arg.required && args[arg.name] === void 0)
2196
+ throw new Error(`${definition.id}: argument "${arg.name}" is required`);
2197
+ for (const [name, value] of Object.entries(args))
2198
+ if (!(Array.isArray(value) ? value.every(binds) : binds(value)))
2199
+ throw new Error(`${definition.id}: "${name}" is not a value an option takes`);
2200
+ const target = input.targets?.(command);
2201
+ if (input.targets && !target)
2202
+ throw new Error(`${definition.id}: no command "${command}"`);
2203
+ const names = new Set(target?.names ?? []);
2204
+ if (target) {
2205
+ for (const name of Object.keys(args))
2206
+ if (!names.has(name))
2207
+ throw new Error(`${definition.id}: "${command}" takes no "${name}"`);
2208
+ }
2209
+ const scalars = Object.fromEntries(Object.entries(args).filter((entry) => ["string", "number"].includes(typeof entry[1])));
2210
+ return {
2211
+ kind: "command",
2212
+ step: definition.id,
2213
+ command,
2214
+ args: { ...args },
2215
+ why: fill(definition.why, { ...scalars, ...input.values }),
2216
+ safe_to_auto_execute: target?.effects !== void 0 && !writes(target.effects)
2217
+ };
2218
+ }, "stepOf");
2219
+ var STEPS = defineSteps([
2220
+ {
2221
+ id: "page.next",
2222
+ command: SAME_COMMAND,
2223
+ args: [
2224
+ { name: "cursor", required: false },
2225
+ { name: "page", required: false },
2226
+ { name: "limit", required: false }
2227
+ ],
2228
+ why: "{shown} shown, more exist"
2229
+ }
2230
+ ]);
2231
+
2232
+ // node_modules/.pnpm/@wirecat+cli-base@0.77.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/failure.js
2233
+ var recognise = /* @__PURE__ */ __name((failure) => {
2234
+ if (isCliError(failure))
2235
+ return failure;
2236
+ if (!(failure instanceof Error) || failure.name !== "CliError")
2237
+ return void 0;
2238
+ const { code, details } = failure;
2239
+ if (!errorCodes.includes(code))
2240
+ return void 0;
2241
+ return {
2242
+ code,
2243
+ message: failure.message,
2244
+ details: typeof details === "object" && details !== null ? details : {}
2245
+ };
2246
+ }, "recognise");
2247
+ var reasonFor = /* @__PURE__ */ __name((code, named, reasons) => reasons.find((entry) => entry.reason === named && entry.code === code) ?? BASE_REASONS.find((entry) => entry.reason === named && entry.code === code) ?? // The first base reason for each code is its fallback.
2248
+ BASE_REASONS.find((entry) => entry.code === code), "reasonFor");
2249
+ var nextFor = /* @__PURE__ */ __name((reason, details, context) => {
2250
+ const definition = reason.step ? context.steps?.find((step) => step.id === reason.step) : void 0;
2251
+ if (!definition)
2252
+ return [];
2253
+ const known = new Set(definition.kind === "command" ? definition.args.map((arg) => arg.name) : []);
2254
+ const args = Object.fromEntries(Object.entries(details).filter(([key, value]) => known.has(key) && value !== void 0));
2255
+ try {
2256
+ return [stepOf(definition, { args, ...context.targets ? { targets: context.targets } : {} })];
2257
+ } catch {
2258
+ return [];
2259
+ }
2260
+ }, "nextFor");
2261
+ var TRANSIENT = [
2262
+ "rate_limited",
2263
+ "timeout",
2264
+ "network_error",
2265
+ "provider_unavailable"
2266
+ ];
2267
+ var retryOf = /* @__PURE__ */ __name((code, details, effects) => {
2268
+ const transient = details.retryable !== false && (TRANSIENT.includes(code) || code === "provider_error" && details.retryable === true);
2269
+ const safe = code !== "outcome_unknown" && transient && (!writes(effects) || details.sent === false);
2270
+ const after = details.retry_after_ms;
2271
+ return safe && typeof after === "number" && Number.isInteger(after) && after >= 0 ? { safe, after_ms: after } : { safe };
2272
+ }, "retryOf");
2273
+ var errorObjectOf = /* @__PURE__ */ __name((failure, context = {}) => {
2274
+ const reasons = context.reasons ?? [];
2275
+ const recognised = recognise(failure);
2276
+ if (!recognised) {
2277
+ const reason2 = reasonFor(CRASH_CODE, CRASH_REASON, reasons);
2278
+ return {
2279
+ error: {
2280
+ code: CRASH_CODE,
2281
+ reason: reason2.reason,
2282
+ message: reason2.message,
2283
+ retry: { safe: false },
2284
+ ...context.runId ? { run_id: context.runId } : {}
2285
+ }
2286
+ };
2287
+ }
2288
+ const { code, message, details } = recognised;
2289
+ const reason = reasonFor(code, details.reason, reasons);
2290
+ const allowed = /* @__PURE__ */ new Set([...COMMON_DETAILS, ...context.details ?? [], ...reason.details]);
2291
+ allowed.delete("cause");
2292
+ const kept = Object.fromEntries(Object.entries(details).filter(([key, value]) => allowed.has(key) && value !== void 0));
2293
+ const next = nextFor(reason, details, context);
2294
+ const runId = context.runId ?? (typeof details.run_id === "string" ? details.run_id : void 0);
2295
+ return {
2296
+ error: {
2297
+ code,
2298
+ reason: reason.reason,
2299
+ message,
2300
+ ...typeof details.param === "string" ? { param: details.param } : {},
2301
+ ...Object.keys(kept).length > 0 ? { details: kept } : {},
2302
+ ...next.length > 0 ? { next } : {},
2303
+ retry: retryOf(code, details, context.effects),
2304
+ ...runId ? { run_id: runId } : {}
2305
+ }
2306
+ };
2307
+ }, "errorObjectOf");
2308
+ var exitCodeOfError = /* @__PURE__ */ __name(({ error }) => error.code === CRASH_CODE ? GENERIC_FAILURE : EXIT_CODES[error.code], "exitCodeOfError");
2309
+ var exitCodeOfAnswer = /* @__PURE__ */ __name((meta, partial2 = false) => {
2310
+ if (meta.complete || partial2)
2311
+ return 0;
2312
+ const code = meta.issues?.[0]?.code;
2313
+ return code === void 0 ? GENERIC_FAILURE : EXIT_CODES[code];
2314
+ }, "exitCodeOfAnswer");
2315
+ var kebab = /* @__PURE__ */ __name((name) => name.replaceAll("_", "-"), "kebab");
2316
+ var commandLine = /* @__PURE__ */ __name((cli, step) => [
2317
+ cli,
2318
+ step.command,
2319
+ ...Object.entries(step.args).map(([name, value]) => value === true ? `--${kebab(name)}` : `--${kebab(name)} ${JSON.stringify(value)}`)
2320
+ ].join(" "), "commandLine");
2321
+ var STACK_FRAMES = 10;
2322
+ var errorRecordOf = /* @__PURE__ */ __name((failure, object2, options) => {
2323
+ const thrown = failure instanceof Error ? failure : void 0;
2324
+ const { cause, ...details } = recognise(failure)?.details ?? {};
2325
+ const stack = thrown?.stack?.split("\n").slice(1, STACK_FRAMES + 1).map((line) => visibleControls(line.trim()));
2326
+ const reason = thrown?.cause ?? cause;
2327
+ return {
2328
+ time: (options.time ?? /* @__PURE__ */ new Date()).toISOString(),
2329
+ severity: "error",
2330
+ body: "command.failed",
2331
+ ...object2.error.run_id ? { run_id: object2.error.run_id } : {},
2332
+ command: options.command,
2333
+ attributes: {
2334
+ code: object2.error.code,
2335
+ reason: object2.error.reason,
2336
+ message: object2.error.message,
2337
+ ...Object.keys(details).length > 0 ? { details } : {},
2338
+ ...thrown ? { name: thrown.name, thrown_message: visibleControls(thrown.message) } : { thrown: String(failure) },
2339
+ ...reason === void 0 ? {} : { cause: visibleControls(reason instanceof Error ? reason.message : String(reason)) },
2340
+ ...stack && stack.length > 0 ? { stack } : {}
2341
+ },
2342
+ resource: { service: options.service, version: options.version }
2343
+ };
2344
+ }, "errorRecordOf");
2345
+ var renderError = /* @__PURE__ */ __name((object2, options) => {
2346
+ if (!options.interactive)
2347
+ return [JSON.stringify(object2), ...options.record ? [JSON.stringify(options.record)] : []].join("\n");
2348
+ const { message, next, run_id: runId } = object2.error;
2349
+ const step = next?.[0];
2350
+ return [
2351
+ `\u2717 ${visibleControls(message)}`,
2352
+ ...step?.kind === "command" ? [`\u2192 ${visibleControls(step.why)}: ${visibleControls(step.line ?? commandLine(options.cli, step))}`] : step ? [`\u2192 ${visibleControls(step.why)}`] : [],
2353
+ ...options.record ? [JSON.stringify(options.record, null, 2)] : runId ? [`details: ${options.cli} runs show ${runId}`] : []
2354
+ ].join("\n");
2355
+ }, "renderError");
2356
+ var mcpErrorResult = /* @__PURE__ */ __name((object2) => ({
2357
+ content: [{ type: "text", text: JSON.stringify(object2) }],
2358
+ structuredContent: object2,
2359
+ isError: true
2360
+ }), "mcpErrorResult");
2361
+ var catchCrashes = /* @__PURE__ */ __name((options) => {
2362
+ const target = options.target ?? process;
2363
+ const write = options.write ?? ((text2) => process.stderr.write(`${text2}
2364
+ `));
2365
+ const exit = options.exit ?? ((code) => process.exit(code));
2366
+ const crashed = /* @__PURE__ */ __name((failure) => {
2367
+ const object2 = errorObjectOf(failure, options);
2368
+ write(renderError(object2, { cli: options.cli, interactive: options.interactive }));
2369
+ exit(exitCodeOfError(object2));
2370
+ }, "crashed");
2371
+ target.on("uncaughtException", crashed);
2372
+ target.on("unhandledRejection", crashed);
2373
+ return () => {
2374
+ target.off("uncaughtException", crashed);
2375
+ target.off("unhandledRejection", crashed);
2376
+ };
2377
+ }, "catchCrashes");
2378
+
2379
+ export {
2380
+ EXIT_CODES,
2381
+ exitCodeFor,
2382
+ GENERIC_FAILURE,
2383
+ getDotPath,
2384
+ check,
2385
+ description,
2386
+ finite,
2387
+ integer,
2388
+ isoDate,
2389
+ isoTimestamp,
2390
+ maxLength,
2391
+ maxValue,
2392
+ minLength,
2393
+ minValue,
2394
+ nonEmpty,
2395
+ regex,
2396
+ safeInteger,
2397
+ transform,
2398
+ trim,
2399
+ forward,
2400
+ array,
2401
+ boolean,
2402
+ custom,
2403
+ lazy,
2404
+ literal,
2405
+ looseObject,
2406
+ null_,
2407
+ nullable,
2408
+ number,
2409
+ object,
2410
+ objectWithRest,
2411
+ optional,
2412
+ picklist,
2413
+ record,
2414
+ strictObject,
2415
+ string,
2416
+ union,
2417
+ unknown,
2418
+ variant,
2419
+ omit,
2420
+ parse,
2421
+ partial,
2422
+ pick,
2423
+ pipe,
2424
+ safeParse,
2425
+ summarize,
2426
+ unwrap,
2427
+ effectsSchema,
2428
+ writes,
2429
+ toJsonSchema,
2430
+ toStandardJsonSchema,
2431
+ word,
2432
+ SNAKE_CASE,
2433
+ text,
2434
+ dottedId,
2435
+ RegistryError,
2436
+ parseRegistry,
2437
+ duplicates,
2438
+ jsonSchemaOf,
2439
+ MAX_NEXT_STEPS,
2440
+ COMPACT_FLAG,
2441
+ isoTime,
2442
+ reference,
2443
+ pageSchema,
2444
+ clockMeta,
2445
+ listEnvelopeSchema,
2446
+ itemEnvelopeSchema,
2447
+ jsonlOf,
2448
+ CRASH_CODE,
2449
+ errorObjectSchema,
2450
+ defineReasons,
2451
+ defineSteps,
2452
+ stepOf,
2453
+ STEPS,
2454
+ retryOf,
2455
+ errorObjectOf,
2456
+ exitCodeOfError,
2457
+ exitCodeOfAnswer,
2458
+ errorRecordOf,
2459
+ renderError,
2460
+ mcpErrorResult,
2461
+ catchCrashes
2462
+ };