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