@cmflow/source-pack 0.0.0-stage → 3.20.0

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