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