@aka_openclaw_plugin/mychat 0.1.17 → 0.1.19

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