@mulmoclaude/google-plugin 2.2.0 → 3.0.1

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.
package/dist/index.js CHANGED
@@ -52,82 +52,34 @@ function definePlugin(setup) {
52
52
  return setup;
53
53
  }
54
54
  //#endregion
55
- //#region ../../../node_modules/zod/v4/core/core.js
56
- var _a$1;
57
- function $constructor(name, initializer, params) {
58
- function init(inst, def) {
59
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
60
- value: {
61
- def,
62
- constr: _,
63
- traits: /* @__PURE__ */ new Set()
64
- },
65
- enumerable: false
66
- });
67
- if (inst._zod.traits.has(name)) return;
68
- inst._zod.traits.add(name);
69
- initializer(inst, def);
70
- const proto = _.prototype;
71
- const keys = Object.keys(proto);
72
- for (let i = 0; i < keys.length; i++) {
73
- const k = keys[i];
74
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
75
- }
76
- }
77
- const Parent = params?.Parent ?? Object;
78
- class Definition extends Parent {}
79
- Object.defineProperty(Definition, "name", { value: name });
80
- function _(def) {
81
- var _a;
82
- const inst = params?.Parent ? new Definition() : this;
83
- init(inst, def);
84
- (_a = inst._zod).deferred ?? (_a.deferred = []);
85
- for (const fn of inst._zod.deferred) fn();
86
- return inst;
87
- }
88
- Object.defineProperty(_, "init", { value: init });
89
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
90
- if (params?.Parent && inst instanceof params.Parent) return true;
91
- return inst?._zod?.traits?.has(name);
92
- } });
93
- Object.defineProperty(_, "name", { value: name });
94
- return _;
95
- }
96
- var $ZodAsyncError = class extends Error {
97
- constructor() {
98
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
99
- }
100
- };
101
- var $ZodEncodeError = class extends Error {
102
- constructor(name) {
103
- super(`Encountered unidirectional transform during encode: ${name}`);
104
- this.name = "ZodEncodeError";
105
- }
106
- };
107
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
108
- var globalConfig = globalThis.__zod_globalConfig;
109
- function config(newConfig) {
110
- if (newConfig) Object.assign(globalConfig, newConfig);
111
- return globalConfig;
112
- }
113
- //#endregion
114
55
  //#region ../../../node_modules/zod/v4/core/util.js
115
56
  function getEnumValues(entries) {
116
57
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
117
58
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
118
59
  }
60
+ function joinValues(array, separator = "|") {
61
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
62
+ }
119
63
  function jsonStringifyReplacer(_, value) {
120
64
  if (typeof value === "bigint") return value.toString();
121
65
  return value;
122
66
  }
123
- function cached(getter) {
124
- return { get value() {
125
- {
126
- const value = getter();
127
- Object.defineProperty(this, "value", { value });
128
- return value;
67
+ var Cached = class {
68
+ constructor(getter) {
69
+ this._getter = getter;
70
+ this._value = void 0;
71
+ }
72
+ get value() {
73
+ const getter = this._getter;
74
+ if (getter !== void 0) {
75
+ this._value = getter();
76
+ this._getter = void 0;
129
77
  }
130
- } };
78
+ return this._value;
79
+ }
80
+ };
81
+ function cached(getter) {
82
+ return new Cached(getter);
131
83
  }
132
84
  function nullish(input) {
133
85
  return input === null || input === void 0;
@@ -140,28 +92,10 @@ function cleanRegex(source) {
140
92
  function floatSafeRemainder(val, step) {
141
93
  const ratio = val / step;
142
94
  const roundedRatio = Math.round(ratio);
143
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
95
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
144
96
  if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
145
97
  return ratio - roundedRatio;
146
98
  }
147
- var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
148
- function defineLazy(object, key, getter) {
149
- let value = void 0;
150
- Object.defineProperty(object, key, {
151
- get() {
152
- if (value === EVALUATING) return;
153
- if (value === void 0) {
154
- value = EVALUATING;
155
- value = getter();
156
- }
157
- return value;
158
- },
159
- set(v) {
160
- Object.defineProperty(object, key, { value: v });
161
- },
162
- configurable: true
163
- });
164
- }
165
99
  function assignProp(target, prop, value) {
166
100
  Object.defineProperty(target, prop, {
167
101
  value,
@@ -170,6 +104,58 @@ function assignProp(target, prop, value) {
170
104
  configurable: true
171
105
  });
172
106
  }
107
+ /**
108
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
109
+ *
110
+ * Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
111
+ */
112
+ function rawShape(def) {
113
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
114
+ return desc?.get ? desc.get.raw : desc?.value;
115
+ }
116
+ function sourceShape(schema) {
117
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
118
+ }
119
+ function deferProp(target, key, getter) {
120
+ Object.defineProperty(target, key, {
121
+ get() {
122
+ const value = getter();
123
+ assignProp(this, key, value);
124
+ return value;
125
+ },
126
+ enumerable: true,
127
+ configurable: true
128
+ });
129
+ }
130
+ function putProp(target, key, value) {
131
+ if (key in target) assignProp(target, key, value);
132
+ else target[key] = value;
133
+ }
134
+ /**
135
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
136
+ *
137
+ * A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
138
+ */
139
+ function mirrorShape(target, source, keys, wrap) {
140
+ const raw = sourceShape(source);
141
+ for (const key of keys) {
142
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
143
+ if (!desc.enumerable) continue;
144
+ if (desc.get) deferProp(target, key, () => {
145
+ const value = source._zod.def.shape[key];
146
+ return wrap ? wrap(value, key) : value;
147
+ });
148
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
149
+ }
150
+ }
151
+ function mirrorProps(target, source) {
152
+ for (const key of Reflect.ownKeys(source)) {
153
+ const desc = Object.getOwnPropertyDescriptor(source, key);
154
+ if (!desc.enumerable) continue;
155
+ if (desc.get) deferProp(target, key, () => source[key]);
156
+ else putProp(target, key, desc.value);
157
+ }
158
+ }
173
159
  function mergeDefs(...defs) {
174
160
  const mergedDescriptors = {};
175
161
  for (const def of defs) {
@@ -243,51 +229,56 @@ function normalizeParams(_params) {
243
229
  };
244
230
  return params;
245
231
  }
232
+ function stringifyPrimitive(value) {
233
+ if (typeof value === "bigint") return value.toString() + "n";
234
+ if (typeof value === "string") return `"${value}"`;
235
+ return `${value}`;
236
+ }
246
237
  function optionalKeys(shape) {
247
238
  return Object.keys(shape).filter((k) => {
248
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
239
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
249
240
  });
250
241
  }
251
- var NUMBER_FORMAT_RANGES = {
242
+ var NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
252
243
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
253
244
  int32: [-2147483648, 2147483647],
254
245
  uint32: [0, 4294967295],
255
246
  float32: [-34028234663852886e22, 34028234663852886e22],
256
247
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
248
+ }))();
249
+ var BIGINT_FORMAT_RANGES = {
250
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
251
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
257
252
  };
258
253
  function pick(schema, mask) {
259
254
  const currDef = schema._zod.def;
260
255
  const checks = currDef.checks;
261
256
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
262
- return clone(schema, mergeDefs(schema._zod.def, {
263
- get shape() {
264
- const newShape = {};
265
- for (const key in mask) {
266
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
267
- if (!mask[key]) continue;
268
- newShape[key] = currDef.shape[key];
269
- }
270
- assignProp(this, "shape", newShape);
271
- return newShape;
272
- },
257
+ const newShape = {};
258
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
259
+ return clone(schema, mergeDefs(currDef, {
260
+ shape: newShape,
273
261
  checks: []
274
262
  }));
275
263
  }
264
+ function maskedKeys(schema, mask) {
265
+ const raw = sourceShape(schema);
266
+ const keys = [];
267
+ for (const key of Reflect.ownKeys(mask)) {
268
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
269
+ if (mask[key]) keys.push(key);
270
+ }
271
+ return keys;
272
+ }
276
273
  function omit(schema, mask) {
277
274
  const currDef = schema._zod.def;
278
275
  const checks = currDef.checks;
279
276
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
280
- return clone(schema, mergeDefs(schema._zod.def, {
281
- get shape() {
282
- const newShape = { ...schema._zod.def.shape };
283
- for (const key in mask) {
284
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
285
- if (!mask[key]) continue;
286
- delete newShape[key];
287
- }
288
- assignProp(this, "shape", newShape);
289
- return newShape;
290
- },
277
+ const omitted = new Set(maskedKeys(schema, mask));
278
+ const newShape = {};
279
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
280
+ return clone(schema, mergeDefs(currDef, {
281
+ shape: newShape,
291
282
  checks: []
292
283
  }));
293
284
  }
@@ -295,90 +286,57 @@ function extend(schema, shape) {
295
286
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
296
287
  const checks = schema._zod.def.checks;
297
288
  if (checks && checks.length > 0) {
298
- const existingShape = schema._zod.def.shape;
299
- 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.");
289
+ const existingShape = sourceShape(schema);
290
+ for (const key of Reflect.ownKeys(shape)) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
300
291
  }
301
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
302
- const _shape = {
303
- ...schema._zod.def.shape,
304
- ...shape
305
- };
306
- assignProp(this, "shape", _shape);
307
- return _shape;
308
- } }));
292
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
293
+ }
294
+ function extended(schema, shape) {
295
+ const newShape = {};
296
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
297
+ mirrorProps(newShape, shape);
298
+ return newShape;
309
299
  }
310
300
  function safeExtend(schema, shape) {
311
301
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
312
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
313
- const _shape = {
314
- ...schema._zod.def.shape,
315
- ...shape
316
- };
317
- assignProp(this, "shape", _shape);
318
- return _shape;
319
- } }));
302
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
320
303
  }
321
304
  function merge(a, b) {
305
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
322
306
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
307
+ const newShape = {};
308
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
309
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
323
310
  return clone(a, mergeDefs(a._zod.def, {
324
- get shape() {
325
- const _shape = {
326
- ...a._zod.def.shape,
327
- ...b._zod.def.shape
328
- };
329
- assignProp(this, "shape", _shape);
330
- return _shape;
331
- },
311
+ shape: newShape,
332
312
  get catchall() {
333
313
  return b._zod.def.catchall;
334
314
  },
335
315
  checks: b._zod.def.checks ?? []
336
316
  }));
337
317
  }
338
- function partial(Class, schema, mask) {
318
+ function partial(Class, schema, mask, name = "partial") {
339
319
  const checks = schema._zod.def.checks;
340
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
320
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
321
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
322
+ const newShape = {};
323
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
324
+ type: "optional",
325
+ innerType: value
326
+ })));
341
327
  return clone(schema, mergeDefs(schema._zod.def, {
342
- get shape() {
343
- const oldShape = schema._zod.def.shape;
344
- const shape = { ...oldShape };
345
- if (mask) for (const key in mask) {
346
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
347
- if (!mask[key]) continue;
348
- shape[key] = Class ? new Class({
349
- type: "optional",
350
- innerType: oldShape[key]
351
- }) : oldShape[key];
352
- }
353
- else for (const key in oldShape) shape[key] = Class ? new Class({
354
- type: "optional",
355
- innerType: oldShape[key]
356
- }) : oldShape[key];
357
- assignProp(this, "shape", shape);
358
- return shape;
359
- },
328
+ shape: newShape,
360
329
  checks: []
361
330
  }));
362
331
  }
363
332
  function required(Class, schema, mask) {
364
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
365
- const oldShape = schema._zod.def.shape;
366
- const shape = { ...oldShape };
367
- if (mask) for (const key in mask) {
368
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
369
- if (!mask[key]) continue;
370
- shape[key] = new Class({
371
- type: "nonoptional",
372
- innerType: oldShape[key]
373
- });
374
- }
375
- else for (const key in oldShape) shape[key] = new Class({
376
- type: "nonoptional",
377
- innerType: oldShape[key]
378
- });
379
- assignProp(this, "shape", shape);
380
- return shape;
381
- } }));
333
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
334
+ const newShape = {};
335
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
336
+ type: "nonoptional",
337
+ innerType: value
338
+ }));
339
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
382
340
  }
383
341
  function aborted(x, startIndex = 0) {
384
342
  if (x.aborted === true) return true;
@@ -401,19 +359,58 @@ function prefixIssues(path, issues) {
401
359
  function unwrapMessage(message) {
402
360
  return typeof message === "string" ? message : message?.message;
403
361
  }
362
+ function attachSchema(issues, start, inst) {
363
+ var _a;
364
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
365
+ }
404
366
  function finalizeIssue(iss, ctx, config) {
405
- 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";
406
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
407
- rest.path ?? (rest.path = []);
408
- rest.message = message;
409
- if (ctx?.reportInput) rest.input = _input;
410
- return rest;
367
+ var _a;
368
+ const traits = iss.inst?._zod?.traits;
369
+ if (traits?.has("$ZodType")) {
370
+ if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
371
+ else iss.schema = iss.inst;
372
+ }
373
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
374
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
375
+ const full = {};
376
+ for (const k of Object.keys(iss)) {
377
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
378
+ full[k] = iss[k];
379
+ }
380
+ full.path ?? (full.path = []);
381
+ full.message = message;
382
+ if (ctx?.reportInput) full.input = iss.input;
383
+ return full;
384
+ }
385
+ var highSurrogate = /[\uD800-\uDBFF]/;
386
+ function codePointLength(str) {
387
+ const units = str.length;
388
+ if (!highSurrogate.test(str)) return units;
389
+ let count = units;
390
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
391
+ count--;
392
+ i++;
393
+ }
394
+ return count;
411
395
  }
412
396
  function getLengthableOrigin(input) {
413
397
  if (Array.isArray(input)) return "array";
414
398
  if (typeof input === "string") return "string";
415
399
  return "unknown";
416
400
  }
401
+ function parsedType(data) {
402
+ const t = typeof data;
403
+ switch (t) {
404
+ case "number": return Number.isNaN(data) ? "nan" : "number";
405
+ case "object": {
406
+ if (data === null) return "null";
407
+ if (Array.isArray(data)) return "array";
408
+ const obj = data;
409
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
410
+ }
411
+ }
412
+ return t;
413
+ }
417
414
  function issue(...args) {
418
415
  const [iss, input, inst] = args;
419
416
  if (typeof iss === "string") return {
@@ -424,33 +421,341 @@ function issue(...args) {
424
421
  };
425
422
  return { ...iss };
426
423
  }
424
+ /**
425
+ * Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
426
+ *
427
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
428
+ */
429
+ function members(proto, table) {
430
+ for (const key in table) {
431
+ const desc = Object.getOwnPropertyDescriptor(table, key);
432
+ if (desc.get) Object.defineProperty(proto, key, {
433
+ ...desc,
434
+ enumerable: false
435
+ });
436
+ else defineBound(proto, key, desc.value);
437
+ }
438
+ for (const sym of Object.getOwnPropertySymbols(table)) defineBound(proto, sym, table[sym]);
439
+ }
440
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
441
+ function own(inst, key, value, enumerable = true) {
442
+ Object.defineProperty(inst, key, {
443
+ configurable: true,
444
+ writable: true,
445
+ enumerable,
446
+ value
447
+ });
448
+ return value;
449
+ }
450
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
451
+ function hide(inst, key, value) {
452
+ return own(inst, key, value, false);
453
+ }
454
+ /** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
455
+ function derived(computes, table) {
456
+ for (const key in computes) {
457
+ const compute = computes[key];
458
+ Object.defineProperty(table, key, {
459
+ configurable: true,
460
+ enumerable: true,
461
+ get() {
462
+ return own(this, key, compute(this));
463
+ },
464
+ set(value) {
465
+ own(this, key, value);
466
+ }
467
+ });
468
+ }
469
+ return table;
470
+ }
471
+ function defineBound(proto, key, fn) {
472
+ Object.defineProperty(proto, key, {
473
+ configurable: true,
474
+ get() {
475
+ return this == null ? fn : own(this, key, fn.bind(this));
476
+ },
477
+ set(value) {
478
+ own(this, key, value);
479
+ }
480
+ });
481
+ }
482
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
483
+ function claim(inst, sentinel) {
484
+ const proto = Object.getPrototypeOf(inst);
485
+ return sentinel in proto ? void 0 : proto;
486
+ }
487
+ var installing;
488
+ var broke = false;
489
+ var breaker = {
490
+ configurable: true,
491
+ get() {
492
+ broke = true;
493
+ }
494
+ };
495
+ /**
496
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
497
+ * constructor, computed from the internals object itself and cached there on
498
+ * first read. One accessor per constructor rather than one per instance.
499
+ */
500
+ function defineLazyInternal(inst, key, compute) {
501
+ const proto = Object.getPrototypeOf(inst._zod);
502
+ if (key in proto && installing !== inst._zod) {
503
+ installing = void 0;
504
+ return;
505
+ }
506
+ installing = inst._zod;
507
+ Object.defineProperty(proto, key, {
508
+ configurable: true,
509
+ get() {
510
+ Object.defineProperty(this, key, breaker);
511
+ const outer = broke;
512
+ broke = false;
513
+ try {
514
+ const value = compute(this);
515
+ if (broke) delete this[key];
516
+ else Object.defineProperty(this, key, {
517
+ configurable: true,
518
+ writable: true,
519
+ value
520
+ });
521
+ broke = broke || outer;
522
+ return value;
523
+ } catch (err) {
524
+ delete this[key];
525
+ broke = broke || outer;
526
+ throw err;
527
+ }
528
+ },
529
+ set(value) {
530
+ Object.defineProperty(this, key, {
531
+ configurable: true,
532
+ writable: true,
533
+ value
534
+ });
535
+ }
536
+ });
537
+ }
538
+ /**
539
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
540
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
541
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
542
+ */
543
+ function installLazyProp(inst, key, make, enumerable) {
544
+ const proto = claim(inst, key);
545
+ if (!proto) return;
546
+ Object.defineProperty(proto, key, {
547
+ configurable: true,
548
+ get() {
549
+ const desc = {
550
+ configurable: true,
551
+ writable: true,
552
+ enumerable,
553
+ value: void 0
554
+ };
555
+ Object.defineProperty(this, key, desc);
556
+ desc.value = make(this);
557
+ Object.defineProperty(this, key, desc);
558
+ return desc.value;
559
+ },
560
+ set(value) {
561
+ Object.defineProperty(this, key, {
562
+ configurable: true,
563
+ writable: true,
564
+ enumerable,
565
+ value
566
+ });
567
+ }
568
+ });
569
+ }
570
+ /** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
571
+ var CONSTANT_CATCH = "~constantCatch";
572
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
573
+ function constantCatch(value) {
574
+ const fn = () => value;
575
+ fn[CONSTANT_CATCH] = true;
576
+ return fn;
577
+ }
578
+ //#endregion
579
+ //#region ../../../node_modules/zod/v4/core/core.js
580
+ var _a$1;
581
+ var _zodDesc = {
582
+ value: void 0,
583
+ enumerable: false
584
+ };
585
+ var _E = "captureStackTrace" in Error ? Error : null;
586
+ function newError(Definition) {
587
+ const E = _E;
588
+ if (E) {
589
+ const saved = E.stackTraceLimit;
590
+ if (typeof saved === "number") {
591
+ try {
592
+ E.stackTraceLimit = 0;
593
+ } catch {
594
+ _E = null;
595
+ return new Definition();
596
+ }
597
+ try {
598
+ return new Definition();
599
+ } finally {
600
+ E.stackTraceLimit = saved;
601
+ }
602
+ }
603
+ }
604
+ return new Definition();
605
+ }
606
+ function $constructor(name, initializer, proto, params) {
607
+ const zodProto = {};
608
+ function Internals(def) {
609
+ this.def = def;
610
+ this.constr = _;
611
+ this.traits = /* @__PURE__ */ new Set();
612
+ }
613
+ Internals.prototype = zodProto;
614
+ const protoMembers = proto;
615
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
616
+ function init(inst, def) {
617
+ if (!inst._zod) {
618
+ _zodDesc.value = new Internals(def);
619
+ try {
620
+ Object.defineProperty(inst, "_zod", _zodDesc);
621
+ } finally {
622
+ _zodDesc.value = void 0;
623
+ }
624
+ }
625
+ if (inst._zod.traits.has(name)) return;
626
+ inst._zod.traits.add(name);
627
+ initializer(inst, def);
628
+ if (initialized) {
629
+ const own = Object.getPrototypeOf(inst);
630
+ const ctorProto = inst._zod.constr.prototype;
631
+ let up = own;
632
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
633
+ const target = up ?? own;
634
+ if (!initialized.has(target)) {
635
+ initialized.add(target);
636
+ members(target, protoMembers);
637
+ }
638
+ }
639
+ const proto = _.prototype;
640
+ for (const k in proto) {
641
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
642
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
643
+ }
644
+ }
645
+ const Parent = params?.Parent ?? Object;
646
+ class Definition extends Parent {}
647
+ Object.defineProperty(Definition, "name", { value: name });
648
+ function _(def) {
649
+ const inst = params?.Parent ? newError(Definition) : this;
650
+ init(inst, def);
651
+ const deferred = inst._zod.deferred;
652
+ if (deferred) {
653
+ for (const fn of deferred) fn();
654
+ inst._zod.deferred = void 0;
655
+ }
656
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
657
+ if (pp) pp(inst);
658
+ return inst;
659
+ }
660
+ Object.defineProperty(_, "init", { value: init });
661
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
662
+ if (params?.Parent && inst instanceof params.Parent) return true;
663
+ return inst?._zod?.traits?.has(name);
664
+ } });
665
+ Object.defineProperty(_, "name", { value: name });
666
+ return _;
667
+ }
668
+ var $ZodAsyncError = class extends Error {
669
+ constructor() {
670
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
671
+ }
672
+ };
673
+ var $ZodEncodeError = class extends Error {
674
+ constructor(name) {
675
+ super(`Encountered unidirectional transform during encode: ${name}`);
676
+ this.name = "ZodEncodeError";
677
+ }
678
+ };
679
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
680
+ var globalConfig = globalThis.__zod_globalConfig;
681
+ function config(newConfig) {
682
+ if (newConfig) Object.assign(globalConfig, newConfig);
683
+ return globalConfig;
684
+ }
427
685
  //#endregion
428
686
  //#region ../../../node_modules/zod/v4/core/errors.js
687
+ function _getMessage() {
688
+ const internals = this._zod;
689
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
690
+ return internals.message;
691
+ }
692
+ function _setMessage(value) {
693
+ this._zod.message = value;
694
+ }
695
+ var _messageDesc = {
696
+ get: _getMessage,
697
+ set: _setMessage,
698
+ enumerable: true,
699
+ configurable: true
700
+ };
701
+ var _issuesDesc = {
702
+ value: void 0,
703
+ enumerable: false
704
+ };
705
+ var _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
429
706
  var initializer$1 = (inst, def) => {
430
707
  inst.name = "$ZodError";
431
- Object.defineProperty(inst, "_zod", {
432
- value: inst._zod,
433
- enumerable: false
434
- });
435
- Object.defineProperty(inst, "issues", {
436
- value: def,
437
- enumerable: false
438
- });
439
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
440
- Object.defineProperty(inst, "toString", {
441
- value: () => inst.message,
442
- enumerable: false
443
- });
708
+ _issuesDesc.value = def;
709
+ Object.defineProperty(inst, "issues", _issuesDesc);
710
+ _issuesDesc.value = void 0;
711
+ Object.defineProperty(inst, "message", _messageDesc);
712
+ const proto = Object.getPrototypeOf(inst);
713
+ if (!_installedToString.has(proto)) {
714
+ _installedToString.add(proto);
715
+ Object.defineProperty(proto, "toString", {
716
+ configurable: true,
717
+ enumerable: false,
718
+ get() {
719
+ const value = () => this.message;
720
+ Object.defineProperty(this, "toString", {
721
+ value,
722
+ configurable: true,
723
+ writable: true
724
+ });
725
+ return value;
726
+ },
727
+ set(value) {
728
+ Object.defineProperty(this, "toString", {
729
+ value,
730
+ configurable: true,
731
+ writable: true
732
+ });
733
+ }
734
+ });
735
+ }
444
736
  };
445
737
  var $ZodError = $constructor("$ZodError", initializer$1);
446
- var $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
738
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
739
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
740
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
741
+ * "__proto__" would hit the setter instead of creating a key. */
742
+ function node(obj, key, make) {
743
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
744
+ if (key === "__proto__") Object.defineProperty(obj, key, {
745
+ value: make(),
746
+ writable: true,
747
+ enumerable: true,
748
+ configurable: true
749
+ });
750
+ else obj[key] = make();
751
+ }
752
+ return obj[key];
753
+ }
447
754
  function flattenError(error, mapper = (issue) => issue.message) {
448
755
  const fieldErrors = {};
449
756
  const formErrors = [];
450
- for (const sub of error.issues) if (sub.path.length > 0) {
451
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
452
- fieldErrors[sub.path[0]].push(mapper(sub));
453
- } else formErrors.push(mapper(sub));
757
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
758
+ else formErrors.push(mapper(sub));
454
759
  return {
455
760
  formErrors,
456
761
  fieldErrors
@@ -470,12 +775,21 @@ function formatError(error, mapper = (issue) => issue.message) {
470
775
  let i = 0;
471
776
  while (i < fullpath.length) {
472
777
  const el = fullpath[i];
473
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
474
- else {
475
- curr[el] = curr[el] || { _errors: [] };
476
- curr[el]._errors.push(mapper(issue));
778
+ const terminal = i === fullpath.length - 1;
779
+ if (el === "_errors") {
780
+ if (terminal) curr._errors.push(mapper(issue));
781
+ i++;
782
+ continue;
477
783
  }
478
- curr = curr[el];
784
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
785
+ value: { _errors: [] },
786
+ enumerable: true,
787
+ writable: true,
788
+ configurable: true
789
+ });
790
+ const node = curr[el];
791
+ if (terminal) node._errors.push(mapper(issue));
792
+ curr = node;
479
793
  i++;
480
794
  }
481
795
  }
@@ -486,39 +800,51 @@ function formatError(error, mapper = (issue) => issue.message) {
486
800
  }
487
801
  //#endregion
488
802
  //#region ../../../node_modules/zod/v4/core/parse.js
489
- var _parse = (_Err) => (schema, value, _ctx, _params) => {
490
- const ctx = _ctx ? {
491
- ..._ctx,
492
- async: false
493
- } : { async: false };
494
- const result = schema._zod.run({
495
- value,
496
- issues: []
497
- }, ctx);
498
- if (result instanceof Promise) throw new $ZodAsyncError();
499
- if (result.issues.length) {
500
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
501
- captureStackTrace(e, _params?.callee);
502
- throw e;
503
- }
504
- return result.value;
803
+ function finalizeParams(callee, params) {
804
+ return {
805
+ callee: params?.callee ?? callee,
806
+ Err: params?.Err
807
+ };
808
+ }
809
+ var _parse = (_Err) => {
810
+ const fn = (schema, value, _ctx, _params) => {
811
+ const ctx = _ctx ? {
812
+ ..._ctx,
813
+ async: false
814
+ } : { async: false };
815
+ const result = schema._zod.run({
816
+ value,
817
+ issues: []
818
+ }, ctx);
819
+ if (result instanceof Promise) throw new $ZodAsyncError();
820
+ if (result.issues.length) {
821
+ const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
822
+ captureStackTrace(e, _params?.callee ?? fn);
823
+ throw e;
824
+ }
825
+ return result.value;
826
+ };
827
+ return fn;
505
828
  };
506
- var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
507
- const ctx = _ctx ? {
508
- ..._ctx,
509
- async: true
510
- } : { async: true };
511
- let result = schema._zod.run({
512
- value,
513
- issues: []
514
- }, ctx);
515
- if (result instanceof Promise) result = await result;
516
- if (result.issues.length) {
517
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
518
- captureStackTrace(e, params?.callee);
519
- throw e;
520
- }
521
- return result.value;
829
+ var _parseAsync = (_Err) => {
830
+ const fn = async (schema, value, _ctx, params) => {
831
+ const ctx = _ctx ? {
832
+ ..._ctx,
833
+ async: true
834
+ } : { async: true };
835
+ let result = schema._zod.run({
836
+ value,
837
+ issues: []
838
+ }, ctx);
839
+ if (result instanceof Promise) result = await result;
840
+ if (result.issues.length) {
841
+ const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
842
+ captureStackTrace(e, params?.callee ?? fn);
843
+ throw e;
844
+ }
845
+ return result.value;
846
+ };
847
+ return fn;
522
848
  };
523
849
  var _safeParse = (_Err) => (schema, value, _ctx) => {
524
850
  const ctx = _ctx ? {
@@ -530,15 +856,30 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
530
856
  issues: []
531
857
  }, ctx);
532
858
  if (result instanceof Promise) throw new $ZodAsyncError();
533
- return result.issues.length ? {
534
- success: false,
535
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
536
- } : {
859
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
537
860
  success: true,
538
861
  data: result.value
539
862
  };
540
- };
541
- var safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
863
+ };
864
+ function failure(Err, issues, ctx) {
865
+ let error;
866
+ return {
867
+ success: false,
868
+ get error() {
869
+ if (!error) {
870
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
871
+ issues = void 0;
872
+ ctx = void 0;
873
+ }
874
+ return error;
875
+ },
876
+ set error(e) {
877
+ error = e;
878
+ issues = void 0;
879
+ ctx = void 0;
880
+ }
881
+ };
882
+ }
542
883
  var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
543
884
  const ctx = _ctx ? {
544
885
  ..._ctx,
@@ -549,34 +890,96 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
549
890
  issues: []
550
891
  }, ctx);
551
892
  if (result instanceof Promise) result = await result;
552
- return result.issues.length ? {
553
- success: false,
554
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
555
- } : {
893
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
556
894
  success: true,
557
895
  data: result.value
558
896
  };
559
897
  };
560
- var safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
561
- var _encode = (_Err) => (schema, value, _ctx) => {
898
+ var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
899
+ var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
900
+ var validate = ((schema, value, _ctx) => {
901
+ const validator = schema._zod.bag.validator;
902
+ if (validator !== void 0) {
903
+ if (validator(value) !== COMPILE_INVALID) return true;
904
+ if (validator.definite === true && _ctx === void 0) return false;
905
+ }
906
+ return validateFallback(schema, value, _ctx);
907
+ });
908
+ function validateFallback(schema, value, _ctx) {
562
909
  const ctx = _ctx ? {
563
910
  ..._ctx,
564
- direction: "backward"
565
- } : { direction: "backward" };
566
- return _parse(_Err)(schema, value, ctx);
567
- };
568
- var _decode = (_Err) => (schema, value, _ctx) => {
569
- return _parse(_Err)(schema, value, _ctx);
570
- };
571
- var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
911
+ async: false,
912
+ abortEarly: true
913
+ } : {
914
+ async: false,
915
+ abortEarly: true
916
+ };
917
+ const fallbackRun = schema._zod.bag.fallbackRun;
918
+ let result;
919
+ if (fallbackRun) {
920
+ ctx[COMPILE_FALLBACK] = true;
921
+ result = fallbackRun({
922
+ value,
923
+ issues: []
924
+ }, ctx);
925
+ } else result = schema._zod.run({
926
+ value,
927
+ issues: []
928
+ }, ctx);
929
+ if (result instanceof Promise) throw new $ZodAsyncError();
930
+ return result.issues.length === 0;
931
+ }
932
+ var validateAsync$1 = async (schema, value, _ctx) => {
572
933
  const ctx = _ctx ? {
573
934
  ..._ctx,
574
- direction: "backward"
575
- } : { direction: "backward" };
576
- return _parseAsync(_Err)(schema, value, ctx);
935
+ async: true,
936
+ abortEarly: true
937
+ } : {
938
+ async: true,
939
+ abortEarly: true
940
+ };
941
+ let result = schema._zod.run({
942
+ value,
943
+ issues: []
944
+ }, ctx);
945
+ if (result instanceof Promise) result = await result;
946
+ return result.issues.length === 0;
947
+ };
948
+ var _encode = (_Err) => {
949
+ const parse = _parse(_Err);
950
+ const fn = (schema, value, _ctx, _params) => {
951
+ const ctx = _ctx ? {
952
+ ..._ctx,
953
+ direction: "backward"
954
+ } : { direction: "backward" };
955
+ return parse(schema, value, ctx, finalizeParams(fn, _params));
956
+ };
957
+ return fn;
958
+ };
959
+ var _decode = (_Err) => {
960
+ const parse = _parse(_Err);
961
+ const fn = (schema, value, _ctx, _params) => {
962
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
963
+ };
964
+ return fn;
965
+ };
966
+ var _encodeAsync = (_Err) => {
967
+ const parseAsync = _parseAsync(_Err);
968
+ const fn = async (schema, value, _ctx, _params) => {
969
+ const ctx = _ctx ? {
970
+ ..._ctx,
971
+ direction: "backward"
972
+ } : { direction: "backward" };
973
+ return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
974
+ };
975
+ return fn;
577
976
  };
578
- var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
579
- return _parseAsync(_Err)(schema, value, _ctx);
977
+ var _decodeAsync = (_Err) => {
978
+ const parseAsync = _parseAsync(_Err);
979
+ const fn = async (schema, value, _ctx, _params) => {
980
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
981
+ };
982
+ return fn;
580
983
  };
581
984
  var _safeEncode = (_Err) => (schema, value, _ctx) => {
582
985
  const ctx = _ctx ? {
@@ -607,12 +1010,15 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
607
1010
  */
608
1011
  var cuid = /^[cC][0-9a-z]{6,}$/;
609
1012
  var cuid2 = /^[0-9a-z]+$/;
610
- var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
1013
+ var ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
611
1014
  var xid = /^[0-9a-vA-V]{20}$/;
612
1015
  var ksuid = /^[A-Za-z0-9]{27}$/;
613
1016
  var nanoid = /^[a-zA-Z0-9_-]{21}$/;
1017
+ function nanoidOfLength(length) {
1018
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
1019
+ }
614
1020
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
615
- var duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
1021
+ var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
616
1022
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
617
1023
  var 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})$/;
618
1024
  /** Returns a regex for validating an RFC 9562/4122 UUID.
@@ -623,41 +1029,45 @@ var uuid = (version) => {
623
1029
  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})$`);
624
1030
  };
625
1031
  /** Practical email validation */
626
- var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
627
- var _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1032
+ var email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1033
+ var _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
628
1034
  function emoji() {
629
1035
  return new RegExp(_emoji$1, "u");
630
1036
  }
631
1037
  var 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])$/;
632
1038
  var 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}|:))$/;
633
1039
  var 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])$/;
634
- var 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])$/;
1040
+ var cidrv6 = /^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
635
1041
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
636
- var base64url = /^[A-Za-z0-9_-]*$/;
1042
+ var base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
637
1043
  var httpProtocol = /^https?$/;
638
1044
  var e164 = /^\+[1-9]\d{6,14}$/;
639
1045
  var 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])))`;
640
- var date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1046
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
1047
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
1048
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
1049
+ function anchor(source) {
1050
+ return new RegExp(`^${source}$`);
1051
+ }
1052
+ var date = /*@__PURE__*/ anchor(dateSource);
641
1053
  function timeSource(args) {
642
1054
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
643
- 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+)?)?`;
1055
+ return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
644
1056
  }
645
- function time$1(args) {
1057
+ function time(args) {
646
1058
  return new RegExp(`^${timeSource(args)}$`);
647
1059
  }
648
- function datetime$1(args) {
649
- const time = timeSource({ precision: args.precision });
1060
+ function datetime(args) {
650
1061
  const opts = ["Z"];
651
- if (args.local) opts.push("");
652
1062
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
653
- const timeRegex = `${time}(?:${opts.join("|")})`;
1063
+ const qualified = `${timeSource({
1064
+ precision: args.precision,
1065
+ seconds: true
1066
+ })}(?:${opts.join("|")})`;
1067
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
654
1068
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
655
1069
  }
656
- var string$1 = (params) => {
657
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
658
- return new RegExp(`^${regex}$`);
659
- };
660
- var integer = /^-?\d+$/;
1070
+ var anyString = /^[\s\S]{0,}$/;
661
1071
  var number$1 = /^-?\d+(?:\.\d+)?$/;
662
1072
  var boolean$1 = /^(?:true|false)$/i;
663
1073
  var lowercase = /^[^A-Z]*$/;
@@ -670,6 +1080,11 @@ var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
670
1080
  inst._zod.def = def;
671
1081
  (_a = inst._zod).onattach ?? (_a.onattach = []);
672
1082
  });
1083
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1084
+ var _whenHasLength = (payload) => {
1085
+ const val = payload.value;
1086
+ return !nullish(val) && val.length !== void 0;
1087
+ };
673
1088
  var numericOriginMap = {
674
1089
  number: "number",
675
1090
  bigint: "bigint",
@@ -678,16 +1093,10 @@ var numericOriginMap = {
678
1093
  var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
679
1094
  $ZodCheck.init(inst, def);
680
1095
  const origin = numericOriginMap[typeof def.value];
681
- inst._zod.onattach.push((inst) => {
682
- const bag = inst._zod.bag;
683
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
684
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
685
- else bag.exclusiveMaximum = def.value;
686
- });
687
1096
  inst._zod.check = (payload) => {
688
1097
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
689
1098
  payload.issues.push({
690
- origin,
1099
+ origin: numericOriginMap[typeof payload.value] ?? origin,
691
1100
  code: "too_big",
692
1101
  maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
693
1102
  input: payload.value,
@@ -700,16 +1109,10 @@ var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, d
700
1109
  var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
701
1110
  $ZodCheck.init(inst, def);
702
1111
  const origin = numericOriginMap[typeof def.value];
703
- inst._zod.onattach.push((inst) => {
704
- const bag = inst._zod.bag;
705
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
706
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
707
- else bag.exclusiveMinimum = def.value;
708
- });
709
1112
  inst._zod.check = (payload) => {
710
1113
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
711
1114
  payload.issues.push({
712
- origin,
1115
+ origin: numericOriginMap[typeof payload.value] ?? origin,
713
1116
  code: "too_small",
714
1117
  minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
715
1118
  input: payload.value,
@@ -721,13 +1124,9 @@ var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (i
721
1124
  });
722
1125
  var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
723
1126
  $ZodCheck.init(inst, def);
724
- inst._zod.onattach.push((inst) => {
725
- var _a;
726
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
727
- });
728
1127
  inst._zod.check = (payload) => {
729
1128
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
730
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1129
+ if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
731
1130
  payload.issues.push({
732
1131
  origin: typeof payload.value,
733
1132
  code: "not_multiple_of",
@@ -744,13 +1143,6 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
744
1143
  const isInt = def.format?.includes("int");
745
1144
  const origin = isInt ? "int" : "number";
746
1145
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
747
- inst._zod.onattach.push((inst) => {
748
- const bag = inst._zod.bag;
749
- bag.format = def.format;
750
- bag.minimum = minimum;
751
- bag.maximum = maximum;
752
- if (isInt) bag.pattern = integer;
753
- });
754
1146
  inst._zod.check = (payload) => {
755
1147
  const input = payload.value;
756
1148
  if (isInt) {
@@ -812,17 +1204,11 @@ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat",
812
1204
  var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
813
1205
  var _a;
814
1206
  $ZodCheck.init(inst, def);
815
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
816
- const val = payload.value;
817
- return !nullish(val) && val.length !== void 0;
818
- });
819
- inst._zod.onattach.push((inst) => {
820
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
821
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
822
- });
1207
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
823
1208
  inst._zod.check = (payload) => {
824
1209
  const input = payload.value;
825
- if (input.length <= def.maximum) return;
1210
+ const units = input.length;
1211
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
826
1212
  const origin = getLengthableOrigin(input);
827
1213
  payload.issues.push({
828
1214
  origin,
@@ -838,17 +1224,11 @@ var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst,
838
1224
  var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
839
1225
  var _a;
840
1226
  $ZodCheck.init(inst, def);
841
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
842
- const val = payload.value;
843
- return !nullish(val) && val.length !== void 0;
844
- });
845
- inst._zod.onattach.push((inst) => {
846
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
847
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
848
- });
1227
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
849
1228
  inst._zod.check = (payload) => {
850
1229
  const input = payload.value;
851
- if (input.length >= def.minimum) return;
1230
+ const units = input.length;
1231
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
852
1232
  const origin = getLengthableOrigin(input);
853
1233
  payload.issues.push({
854
1234
  origin,
@@ -864,19 +1244,11 @@ var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst,
864
1244
  var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
865
1245
  var _a;
866
1246
  $ZodCheck.init(inst, def);
867
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
868
- const val = payload.value;
869
- return !nullish(val) && val.length !== void 0;
870
- });
871
- inst._zod.onattach.push((inst) => {
872
- const bag = inst._zod.bag;
873
- bag.minimum = def.length;
874
- bag.maximum = def.length;
875
- bag.length = def.length;
876
- });
1247
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
877
1248
  inst._zod.check = (payload) => {
878
1249
  const input = payload.value;
879
- const length = input.length;
1250
+ const units = input.length;
1251
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
880
1252
  if (length === def.length) return;
881
1253
  const origin = getLengthableOrigin(input);
882
1254
  const tooBig = length > def.length;
@@ -900,14 +1272,6 @@ var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals",
900
1272
  var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
901
1273
  var _a, _b;
902
1274
  $ZodCheck.init(inst, def);
903
- inst._zod.onattach.push((inst) => {
904
- const bag = inst._zod.bag;
905
- bag.format = def.format;
906
- if (def.pattern) {
907
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
908
- bag.patterns.add(def.pattern);
909
- }
910
- });
911
1275
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
912
1276
  def.pattern.lastIndex = 0;
913
1277
  if (def.pattern.test(payload.value)) return;
@@ -950,13 +1314,7 @@ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst,
950
1314
  var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
951
1315
  $ZodCheck.init(inst, def);
952
1316
  const escapedRegex = escapeRegex(def.includes);
953
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
954
- def.pattern = pattern;
955
- inst._zod.onattach.push((inst) => {
956
- const bag = inst._zod.bag;
957
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
958
- bag.patterns.add(pattern);
959
- });
1317
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
960
1318
  inst._zod.check = (payload) => {
961
1319
  if (payload.value.includes(def.includes, def.position)) return;
962
1320
  payload.issues.push({
@@ -974,11 +1332,6 @@ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (ins
974
1332
  $ZodCheck.init(inst, def);
975
1333
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
976
1334
  def.pattern ?? (def.pattern = pattern);
977
- inst._zod.onattach.push((inst) => {
978
- const bag = inst._zod.bag;
979
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
980
- bag.patterns.add(pattern);
981
- });
982
1335
  inst._zod.check = (payload) => {
983
1336
  if (payload.value.startsWith(def.prefix)) return;
984
1337
  payload.issues.push({
@@ -996,11 +1349,6 @@ var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, d
996
1349
  $ZodCheck.init(inst, def);
997
1350
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
998
1351
  def.pattern ?? (def.pattern = pattern);
999
- inst._zod.onattach.push((inst) => {
1000
- const bag = inst._zod.bag;
1001
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1002
- bag.patterns.add(pattern);
1003
- });
1004
1352
  inst._zod.check = (payload) => {
1005
1353
  if (payload.value.endsWith(def.suffix)) return;
1006
1354
  payload.issues.push({
@@ -1023,15 +1371,19 @@ var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst,
1023
1371
  //#endregion
1024
1372
  //#region ../../../node_modules/zod/v4/core/doc.js
1025
1373
  var Doc = class {
1026
- constructor(args = []) {
1374
+ constructor(args = [], closed = {}) {
1027
1375
  this.content = [];
1028
1376
  this.indent = 0;
1029
- if (this) this.args = args;
1377
+ this.args = args;
1378
+ this.closed = closed;
1030
1379
  }
1031
1380
  indented(fn) {
1032
1381
  this.indent += 1;
1033
- fn(this);
1034
- this.indent -= 1;
1382
+ try {
1383
+ fn(this);
1384
+ } finally {
1385
+ this.indent -= 1;
1386
+ }
1035
1387
  }
1036
1388
  write(arg) {
1037
1389
  if (typeof arg === "function") {
@@ -1046,17 +1398,16 @@ var Doc = class {
1046
1398
  }
1047
1399
  compile() {
1048
1400
  const F = Function;
1049
- const args = this?.args;
1050
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1051
- return new F(...args, lines.join("\n"));
1401
+ const content = this?.content ?? [``];
1402
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
1052
1403
  }
1053
1404
  };
1054
1405
  //#endregion
1055
1406
  //#region ../../../node_modules/zod/v4/core/versions.js
1056
1407
  var version = {
1057
1408
  major: 4,
1058
- minor: 4,
1059
- patch: 3
1409
+ minor: 6,
1410
+ patch: 2
1060
1411
  };
1061
1412
  //#endregion
1062
1413
  //#region ../../../node_modules/zod/v4/core/schemas.js
@@ -1066,8 +1417,8 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1066
1417
  inst._zod.def = def;
1067
1418
  inst._zod.bag = inst._zod.bag || {};
1068
1419
  inst._zod.version = version;
1069
- const checks = [...inst._zod.def.checks ?? []];
1070
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1420
+ const defChecks = inst._zod.def.checks;
1421
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1071
1422
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1072
1423
  if (checks.length === 0) {
1073
1424
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1076,6 +1427,7 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1076
1427
  });
1077
1428
  } else {
1078
1429
  const runChecks = (payload, checks, ctx) => {
1430
+ if (payload.memo) return payload;
1079
1431
  let isAborted = aborted(payload);
1080
1432
  let asyncResult;
1081
1433
  for (const ch of checks) {
@@ -1089,10 +1441,12 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1089
1441
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1090
1442
  await _;
1091
1443
  if (payload.issues.length === currLen) return;
1444
+ attachSchema(payload.issues, currLen, inst);
1092
1445
  if (!isAborted) isAborted = aborted(payload, currLen);
1093
1446
  });
1094
1447
  else {
1095
1448
  if (payload.issues.length === currLen) continue;
1449
+ attachSchema(payload.issues, currLen, inst);
1096
1450
  if (!isAborted) isAborted = aborted(payload, currLen);
1097
1451
  }
1098
1452
  }
@@ -1136,22 +1490,43 @@ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1136
1490
  return runChecks(result, checks, ctx);
1137
1491
  };
1138
1492
  }
1139
- defineLazy(inst, "~standard", () => ({
1493
+ }, {
1494
+ get "~standard"() {
1495
+ return hide(this, "~standard", standardProps(this));
1496
+ },
1497
+ set "~standard"(value) {
1498
+ own(this, "~standard", value);
1499
+ }
1500
+ });
1501
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1502
+ var toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1503
+ async function validateAsync(inst, value) {
1504
+ const ctx = { async: true };
1505
+ return toStandardResult(await inst._zod.run({
1506
+ value,
1507
+ issues: []
1508
+ }, ctx), ctx);
1509
+ }
1510
+ function standardProps(inst) {
1511
+ return {
1140
1512
  validate: (value) => {
1513
+ const ctx = { async: false };
1141
1514
  try {
1142
- const r = safeParse$1(inst, value);
1143
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1144
- } catch (_) {
1145
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1146
- }
1515
+ const r = inst._zod.run({
1516
+ value,
1517
+ issues: []
1518
+ }, ctx);
1519
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
1520
+ } catch (_) {}
1521
+ return validateAsync(inst, value);
1147
1522
  },
1148
1523
  vendor: "zod",
1149
1524
  version: 1
1150
- }));
1151
- });
1525
+ };
1526
+ }
1152
1527
  var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1153
1528
  $ZodType.init(inst, def);
1154
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1529
+ inst._zod.pattern = def.pattern ?? anyString;
1155
1530
  inst._zod.parse = (payload, _) => {
1156
1531
  if (def.coerce) try {
1157
1532
  payload.value = String(payload.value);
@@ -1195,51 +1570,74 @@ var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1195
1570
  def.pattern ?? (def.pattern = email);
1196
1571
  $ZodStringFormat.init(inst, def);
1197
1572
  });
1573
+ /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
1574
+ function parseURLObject(trimmed, def) {
1575
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1576
+ try {
1577
+ return new URL(trimmed);
1578
+ } catch {
1579
+ return 2;
1580
+ }
1581
+ }
1582
+ var asciiTabOrNewline = /[\t\n\r]/g;
1583
+ /** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
1584
+ function stripTabAndNewline(value) {
1585
+ return value.replace(asciiTabOrNewline, "");
1586
+ }
1587
+ function urlHostnameOk(url, hostname) {
1588
+ hostname.lastIndex = 0;
1589
+ return hostname.test(url.hostname);
1590
+ }
1591
+ function urlProtocolOk(url, protocol) {
1592
+ protocol.lastIndex = 0;
1593
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1594
+ }
1198
1595
  var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1199
1596
  $ZodStringFormat.init(inst, def);
1200
1597
  inst._zod.check = (payload) => {
1201
1598
  try {
1202
1599
  const trimmed = payload.value.trim();
1203
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1204
- if (!/^https?:\/\//i.test(trimmed)) {
1205
- payload.issues.push({
1206
- code: "invalid_format",
1207
- format: "url",
1208
- note: "Invalid URL format",
1209
- input: payload.value,
1210
- inst,
1211
- continue: !def.abort
1212
- });
1213
- return;
1214
- }
1215
- }
1216
- const url = new URL(trimmed);
1217
- if (def.hostname) {
1218
- def.hostname.lastIndex = 0;
1219
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1600
+ const url = parseURLObject(trimmed, def);
1601
+ if (url === 1) {
1602
+ payload.issues.push({
1220
1603
  code: "invalid_format",
1221
1604
  format: "url",
1222
- note: "Invalid hostname",
1223
- pattern: def.hostname.source,
1605
+ note: "Invalid URL format",
1224
1606
  input: payload.value,
1225
1607
  inst,
1226
1608
  continue: !def.abort
1227
1609
  });
1610
+ return;
1228
1611
  }
1229
- if (def.protocol) {
1230
- def.protocol.lastIndex = 0;
1231
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1612
+ if (url === 2) {
1613
+ payload.issues.push({
1232
1614
  code: "invalid_format",
1233
1615
  format: "url",
1234
- note: "Invalid protocol",
1235
- pattern: def.protocol.source,
1236
1616
  input: payload.value,
1237
1617
  inst,
1238
1618
  continue: !def.abort
1239
1619
  });
1620
+ return;
1240
1621
  }
1241
- if (def.normalize) payload.value = url.href;
1242
- else payload.value = trimmed;
1622
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1623
+ code: "invalid_format",
1624
+ format: "url",
1625
+ note: "Invalid hostname",
1626
+ pattern: def.hostname.source,
1627
+ input: payload.value,
1628
+ inst,
1629
+ continue: !def.abort
1630
+ });
1631
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1632
+ code: "invalid_format",
1633
+ format: "url",
1634
+ note: "Invalid protocol",
1635
+ pattern: def.protocol.source,
1636
+ input: payload.value,
1637
+ inst,
1638
+ continue: !def.abort
1639
+ });
1640
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1243
1641
  return;
1244
1642
  } catch (_) {
1245
1643
  payload.issues.push({
@@ -1257,7 +1655,8 @@ var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1257
1655
  $ZodStringFormat.init(inst, def);
1258
1656
  });
1259
1657
  var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1260
- def.pattern ?? (def.pattern = nanoid);
1658
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1659
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
1261
1660
  $ZodStringFormat.init(inst, def);
1262
1661
  });
1263
1662
  /**
@@ -1286,70 +1685,74 @@ var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1286
1685
  $ZodStringFormat.init(inst, def);
1287
1686
  });
1288
1687
  var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1289
- def.pattern ?? (def.pattern = datetime$1(def));
1688
+ def.pattern ?? (def.pattern = datetime(def));
1290
1689
  $ZodStringFormat.init(inst, def);
1291
1690
  });
1292
1691
  var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1293
- def.pattern ?? (def.pattern = date$1);
1692
+ def.pattern ?? (def.pattern = date);
1294
1693
  $ZodStringFormat.init(inst, def);
1295
1694
  });
1296
1695
  var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1297
- def.pattern ?? (def.pattern = time$1(def));
1696
+ def.pattern ?? (def.pattern = time(def));
1298
1697
  $ZodStringFormat.init(inst, def);
1299
1698
  });
1300
1699
  var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1301
- def.pattern ?? (def.pattern = duration$1);
1700
+ def.pattern ?? (def.pattern = duration);
1302
1701
  $ZodStringFormat.init(inst, def);
1303
1702
  });
1304
1703
  var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1305
1704
  def.pattern ?? (def.pattern = ipv4);
1306
1705
  $ZodStringFormat.init(inst, def);
1307
- inst._zod.bag.format = `ipv4`;
1308
1706
  });
1707
+ /** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
1708
+ var ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1709
+ function isValidIPv6(value) {
1710
+ if (!ipv6Alphabet.test(value)) return false;
1711
+ try {
1712
+ new URL(`http://[${value}]`);
1713
+ return true;
1714
+ } catch {
1715
+ return false;
1716
+ }
1717
+ }
1309
1718
  var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1310
1719
  def.pattern ?? (def.pattern = ipv6);
1311
1720
  $ZodStringFormat.init(inst, def);
1312
- inst._zod.bag.format = `ipv6`;
1313
1721
  inst._zod.check = (payload) => {
1314
- try {
1315
- new URL(`http://[${payload.value}]`);
1316
- } catch {
1317
- payload.issues.push({
1318
- code: "invalid_format",
1319
- format: "ipv6",
1320
- input: payload.value,
1321
- inst,
1322
- continue: !def.abort
1323
- });
1324
- }
1722
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1723
+ code: "invalid_format",
1724
+ format: "ipv6",
1725
+ input: payload.value,
1726
+ inst,
1727
+ continue: !def.abort
1728
+ });
1325
1729
  };
1326
1730
  });
1327
1731
  var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1328
1732
  def.pattern ?? (def.pattern = cidrv4);
1329
1733
  $ZodStringFormat.init(inst, def);
1330
1734
  });
1735
+ function isValidCIDRv6(value) {
1736
+ const parts = value.split("/");
1737
+ if (parts.length !== 2) return false;
1738
+ const [address, prefix] = parts;
1739
+ if (!prefix) return false;
1740
+ const prefixNum = Number(prefix);
1741
+ if (`${prefixNum}` !== prefix) return false;
1742
+ if (prefixNum < 0 || prefixNum > 128) return false;
1743
+ return isValidIPv6(address);
1744
+ }
1331
1745
  var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1332
1746
  def.pattern ?? (def.pattern = cidrv6);
1333
1747
  $ZodStringFormat.init(inst, def);
1334
1748
  inst._zod.check = (payload) => {
1335
- const parts = payload.value.split("/");
1336
- try {
1337
- if (parts.length !== 2) throw new Error();
1338
- const [address, prefix] = parts;
1339
- if (!prefix) throw new Error();
1340
- const prefixNum = Number(prefix);
1341
- if (`${prefixNum}` !== prefix) throw new Error();
1342
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1343
- new URL(`http://[${address}]`);
1344
- } catch {
1345
- payload.issues.push({
1346
- code: "invalid_format",
1347
- format: "cidrv6",
1348
- input: payload.value,
1349
- inst,
1350
- continue: !def.abort
1351
- });
1352
- }
1749
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1750
+ code: "invalid_format",
1751
+ format: "cidrv6",
1752
+ input: payload.value,
1753
+ inst,
1754
+ continue: !def.abort
1755
+ });
1353
1756
  };
1354
1757
  });
1355
1758
  function isValidBase64(data) {
@@ -1363,10 +1766,10 @@ function isValidBase64(data) {
1363
1766
  return false;
1364
1767
  }
1365
1768
  }
1769
+ var base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
1366
1770
  var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1367
- def.pattern ?? (def.pattern = base64);
1771
+ def.pattern ?? (def.pattern = base64Charset);
1368
1772
  $ZodStringFormat.init(inst, def);
1369
- inst._zod.bag.contentEncoding = "base64";
1370
1773
  inst._zod.check = (payload) => {
1371
1774
  if (isValidBase64(payload.value)) return;
1372
1775
  payload.issues.push({
@@ -1378,15 +1781,15 @@ var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1378
1781
  });
1379
1782
  };
1380
1783
  });
1784
+ var base64urlCharset = /^[A-Za-z0-9_-]*$/;
1381
1785
  function isValidBase64URL(data) {
1382
- if (!base64url.test(data)) return false;
1786
+ if (!base64urlCharset.test(data)) return false;
1383
1787
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1384
1788
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1385
1789
  }
1386
1790
  var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1387
- def.pattern ?? (def.pattern = base64url);
1791
+ def.pattern ?? (def.pattern = base64urlCharset);
1388
1792
  $ZodStringFormat.init(inst, def);
1389
- inst._zod.bag.contentEncoding = "base64url";
1390
1793
  inst._zod.check = (payload) => {
1391
1794
  if (isValidBase64URL(payload.value)) return;
1392
1795
  payload.issues.push({
@@ -1432,14 +1835,14 @@ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1432
1835
  });
1433
1836
  var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1434
1837
  $ZodType.init(inst, def);
1435
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1838
+ inst._zod.pattern = number$1;
1436
1839
  inst._zod.parse = (payload, _ctx) => {
1437
1840
  if (def.coerce) try {
1438
1841
  payload.value = Number(payload.value);
1439
1842
  } catch (_) {}
1440
1843
  const input = payload.value;
1441
1844
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1442
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1845
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
1443
1846
  payload.issues.push({
1444
1847
  expected: "number",
1445
1848
  code: "invalid_type",
@@ -1494,6 +1897,8 @@ function handleArrayResult(result, final, index) {
1494
1897
  }
1495
1898
  var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1496
1899
  $ZodType.init(inst, def);
1900
+ const memo = globalConfig.memoizer;
1901
+ memo?.attach(inst);
1497
1902
  inst._zod.parse = (payload, ctx) => {
1498
1903
  const input = payload.value;
1499
1904
  if (!Array.isArray(input)) {
@@ -1505,8 +1910,9 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1505
1910
  });
1506
1911
  return payload;
1507
1912
  }
1508
- payload.value = Array(input.length);
1913
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1509
1914
  const proms = [];
1915
+ const abortEarly = ctx?.abortEarly;
1510
1916
  for (let i = 0; i < input.length; i++) {
1511
1917
  const item = input[i];
1512
1918
  const result = def.element._zod.run({
@@ -1514,19 +1920,24 @@ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1514
1920
  issues: []
1515
1921
  }, ctx);
1516
1922
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1517
- else handleArrayResult(result, payload, i);
1923
+ else {
1924
+ handleArrayResult(result, payload, i);
1925
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
1926
+ }
1518
1927
  }
1519
1928
  if (proms.length) return Promise.all(proms).then(() => payload);
1520
1929
  return payload;
1521
1930
  };
1522
1931
  });
1523
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1932
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1524
1933
  const isPresent = key in input;
1934
+ const isOptionalOut = optout === "optional";
1935
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1525
1936
  if (result.issues.length) {
1526
- if (isOptionalIn && isOptionalOut && !isPresent) return;
1937
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1527
1938
  final.issues.push(...prefixIssues(key, result.issues));
1528
1939
  }
1529
- if (!isPresent && !isOptionalIn) {
1940
+ if (!isPresent && optin === void 0) {
1530
1941
  if (!result.issues.length) final.issues.push({
1531
1942
  code: "invalid_type",
1532
1943
  expected: "nonoptional",
@@ -1536,31 +1947,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1536
1947
  return;
1537
1948
  }
1538
1949
  if (result.value === void 0) {
1539
- if (isPresent) final.value[key] = void 0;
1950
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
1540
1951
  } else final.value[key] = result.value;
1541
1952
  }
1953
+ var NO_SYMBOL_KEYS = [];
1542
1954
  function normalizeDef(def) {
1543
1955
  const keys = Object.keys(def.shape);
1544
- 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`);
1956
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
1957
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
1958
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
1959
+ for (const k of allKeys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
1545
1960
  const okeys = optionalKeys(def.shape);
1546
1961
  return {
1547
1962
  ...def,
1548
- keys,
1963
+ allKeys,
1964
+ symbolKeys,
1549
1965
  keySet: new Set(keys),
1550
1966
  numKeys: keys.length,
1551
1967
  optionalKeys: new Set(okeys)
1552
1968
  };
1553
1969
  }
1554
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1970
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1555
1971
  const unrecognized = [];
1556
1972
  const keySet = def.keySet;
1557
1973
  const _catchall = def.catchall._zod;
1558
1974
  const t = _catchall.def.type;
1559
- const isOptionalIn = _catchall.optin === "optional";
1560
- const isOptionalOut = _catchall.optout === "optional";
1975
+ const optin = _catchall.optin;
1976
+ const optout = _catchall.optout;
1977
+ let seen = 0;
1561
1978
  for (const key in input) {
1562
- if (key === "__proto__") continue;
1979
+ if (abortEarly && payload.issues.length !== seen) {
1980
+ if (aborted(payload, seen)) break;
1981
+ seen = payload.issues.length;
1982
+ }
1563
1983
  if (keySet.has(key)) continue;
1984
+ if (key === "__proto__") {
1985
+ if (t === "never") unrecognized.push(key);
1986
+ continue;
1987
+ }
1564
1988
  if (t === "never") {
1565
1989
  unrecognized.push(key);
1566
1990
  continue;
@@ -1569,14 +1993,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1569
1993
  value: input[key],
1570
1994
  issues: []
1571
1995
  }, ctx);
1572
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1573
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1996
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1997
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1574
1998
  }
1575
1999
  if (unrecognized.length) payload.issues.push({
1576
2000
  code: "unrecognized_keys",
1577
2001
  keys: unrecognized,
1578
2002
  input,
1579
- inst
2003
+ inst,
2004
+ continue: true
1580
2005
  });
1581
2006
  if (!proms.length) return payload;
1582
2007
  return Promise.all(proms).then(() => {
@@ -1585,23 +2010,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1585
2010
  }
1586
2011
  var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1587
2012
  $ZodType.init(inst, def);
1588
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1589
- const sh = def.shape;
1590
- Object.defineProperty(def, "shape", { get: () => {
2013
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
2014
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
2015
+ if (sh) {
2016
+ const get = () => {
1591
2017
  const newSh = { ...sh };
1592
2018
  Object.defineProperty(def, "shape", { value: newSh });
2019
+ get.raw = newSh;
1593
2020
  return newSh;
1594
- } });
2021
+ };
2022
+ get.raw = sh;
2023
+ Object.defineProperty(def, "shape", { get });
1595
2024
  }
1596
2025
  const _normalized = cached(() => normalizeDef(def));
1597
- defineLazy(inst._zod, "propValues", () => {
1598
- const shape = def.shape;
2026
+ defineLazyInternal(inst, "propValues", (zod) => {
2027
+ const shape = zod.def.shape;
1599
2028
  const propValues = {};
1600
2029
  for (const key in shape) {
1601
2030
  const field = shape[key]._zod;
1602
2031
  if (field.values) {
1603
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2032
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1604
2033
  for (const v of field.values) propValues[key].add(v);
2034
+ if (field.optin !== void 0) propValues[key].add(void 0);
1605
2035
  }
1606
2036
  }
1607
2037
  return propValues;
@@ -1609,6 +2039,8 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1609
2039
  const isObject$2 = isObject;
1610
2040
  const catchall = def.catchall;
1611
2041
  let value;
2042
+ const memo = globalConfig.memoizer;
2043
+ memo?.attach(inst);
1612
2044
  inst._zod.parse = (payload, ctx) => {
1613
2045
  value ?? (value = _normalized.value);
1614
2046
  const input = payload.value;
@@ -1621,77 +2053,90 @@ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1621
2053
  });
1622
2054
  return payload;
1623
2055
  }
1624
- payload.value = {};
2056
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1625
2057
  const proms = [];
1626
2058
  const shape = value.shape;
1627
- for (const key of value.keys) {
2059
+ const abortEarly = ctx?.abortEarly;
2060
+ let seen = payload.issues.length;
2061
+ for (const key of value.allKeys) {
2062
+ if (abortEarly && payload.issues.length !== seen) {
2063
+ if (aborted(payload, seen)) break;
2064
+ seen = payload.issues.length;
2065
+ }
2066
+ if (key === "__proto__") continue;
1628
2067
  const el = shape[key];
1629
- const isOptionalIn = el._zod.optin === "optional";
1630
- const isOptionalOut = el._zod.optout === "optional";
2068
+ const optin = el._zod.optin;
2069
+ const optout = el._zod.optout;
1631
2070
  const r = el._zod.run({
1632
2071
  value: input[key],
1633
2072
  issues: []
1634
2073
  }, ctx);
1635
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1636
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2074
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2075
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1637
2076
  }
1638
2077
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1639
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2078
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1640
2079
  };
1641
2080
  });
1642
2081
  var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1643
2082
  $ZodObject.init(inst, def);
1644
2083
  const superParse = inst._zod.parse;
1645
2084
  const _normalized = cached(() => normalizeDef(def));
2085
+ const memo = globalConfig.memoizer;
1646
2086
  const generateFastpass = (shape) => {
1647
- const doc = new Doc([
1648
- "shape",
1649
- "payload",
1650
- "ctx"
1651
- ]);
1652
2087
  const normalized = _normalized.value;
1653
- const parseStr = (key) => {
1654
- const k = esc(key);
1655
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1656
- };
2088
+ const syms = normalized.symbolKeys;
2089
+ const doc = new Doc(["payload", "ctx"], {
2090
+ shape,
2091
+ inst,
2092
+ memo,
2093
+ syms
2094
+ });
2095
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2096
+ const prefixStr = (id, k) => `
2097
+ let ${id}_ab = false;
2098
+ for (let i = 0; i < ${id}.issues.length; i++) {
2099
+ const iss = ${id}.issues[i];
2100
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2101
+ payload.issues.push(iss);
2102
+ if (iss.continue !== true) ${id}_ab = true;
2103
+ }
2104
+ if (${id}_ab && ctx && ctx.abortEarly) {
2105
+ payload.value = newResult;
2106
+ return payload;
2107
+ }`;
1657
2108
  doc.write(`const input = payload.value;`);
1658
2109
  const ids = Object.create(null);
1659
2110
  let counter = 0;
1660
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1661
- doc.write(`const newResult = {};`);
1662
- for (const key of normalized.keys) {
2111
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2112
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2113
+ for (const key of normalized.allKeys) {
2114
+ if (key === "__proto__") continue;
1663
2115
  const id = ids[key];
1664
- const k = esc(key);
2116
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2117
+ const isPresent = `${k} in input`;
1665
2118
  const schema = shape[key];
1666
- const isOptionalIn = schema?._zod?.optin === "optional";
2119
+ const optin = schema?._zod?.optin;
2120
+ const isOptionalIn = optin !== void 0;
1667
2121
  const isOptionalOut = schema?._zod?.optout === "optional";
1668
- doc.write(`const ${id} = ${parseStr(key)};`);
1669
- if (isOptionalIn && isOptionalOut) doc.write(`
1670
- if (${id}.issues.length) {
1671
- if (${k} in input) {
1672
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1673
- ...iss,
1674
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1675
- })));
2122
+ doc.write(`const ${id} = ${parseStr(k)};`);
2123
+ if (isOptionalIn && isOptionalOut) {
2124
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2125
+ doc.write(`
2126
+ const ${id}_present = ${isPresent};
2127
+ if (!${id}.issues.length || ${id}_present) {
2128
+ if (${id}.issues.length) {${prefixStr(id, k)}
1676
2129
  }
1677
- }
1678
-
1679
- if (${id}.value === undefined) {
1680
- if (${k} in input) {
1681
- newResult[${k}] = undefined;
2130
+
2131
+ if (${assign}) {
2132
+ newResult[${k}] = ${id}.value;
1682
2133
  }
1683
- } else {
1684
- newResult[${k}] = ${id}.value;
1685
2134
  }
1686
-
2135
+
1687
2136
  `);
1688
- else if (!isOptionalIn) doc.write(`
1689
- const ${id}_present = ${k} in input;
1690
- if (${id}.issues.length) {
1691
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1692
- ...iss,
1693
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1694
- })));
2137
+ } else if (!isOptionalIn) doc.write(`
2138
+ const ${id}_present = ${isPresent};
2139
+ if (${id}.issues.length) {${prefixStr(id, k)}
1695
2140
  }
1696
2141
  if (!${id}_present && !${id}.issues.length) {
1697
2142
  payload.issues.push({
@@ -1700,39 +2145,33 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1700
2145
  input: undefined,
1701
2146
  path: [${k}]
1702
2147
  });
2148
+ if (ctx && ctx.abortEarly) {
2149
+ payload.value = newResult;
2150
+ return payload;
2151
+ }
1703
2152
  }
1704
2153
 
1705
2154
  if (${id}_present) {
1706
- if (${id}.value === undefined) {
1707
- newResult[${k}] = undefined;
1708
- } else {
1709
- newResult[${k}] = ${id}.value;
1710
- }
2155
+ newResult[${k}] = ${id}.value;
1711
2156
  }
1712
2157
 
1713
2158
  `);
1714
- else doc.write(`
1715
- if (${id}.issues.length) {
1716
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1717
- ...iss,
1718
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1719
- })));
2159
+ else {
2160
+ doc.write(`
2161
+ if (${id}.issues.length) {${prefixStr(id, k)}
1720
2162
  }
1721
-
1722
- if (${id}.value === undefined) {
1723
- if (${k} in input) {
1724
- newResult[${k}] = undefined;
1725
- }
1726
- } else {
2163
+ `);
2164
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
2165
+ else doc.write(`
2166
+ if (${id}.value !== undefined || ${isPresent}) {
1727
2167
  newResult[${k}] = ${id}.value;
1728
2168
  }
1729
-
1730
2169
  `);
2170
+ }
1731
2171
  }
1732
2172
  doc.write(`payload.value = newResult;`);
1733
2173
  doc.write(`return payload;`);
1734
- const fn = doc.compile();
1735
- return (payload, ctx) => fn(shape, payload, ctx);
2174
+ return doc.compile();
1736
2175
  };
1737
2176
  let fastpass;
1738
2177
  const isObject$1 = isObject;
@@ -1756,7 +2195,7 @@ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1756
2195
  if (!fastpass) fastpass = generateFastpass(def.shape);
1757
2196
  payload = fastpass(payload, ctx);
1758
2197
  if (!catchall) return payload;
1759
- return handleCatchall([], input, payload, ctx, value, inst);
2198
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1760
2199
  }
1761
2200
  return superParse(payload, ctx);
1762
2201
  };
@@ -1781,14 +2220,14 @@ function handleUnionResults(results, final, inst, ctx) {
1781
2220
  }
1782
2221
  var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1783
2222
  $ZodType.init(inst, def);
1784
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1785
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1786
- defineLazy(inst._zod, "values", () => {
1787
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2223
+ defineLazyInternal(inst, "optin", (zod) => zod.def.options.some((o) => o._zod.optin === "defaulted") ? "defaulted" : zod.def.options.some((o) => o._zod.optin !== void 0) ? "optional" : void 0);
2224
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2225
+ defineLazyInternal(inst, "values", (zod) => {
2226
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1788
2227
  });
1789
- defineLazy(inst._zod, "pattern", () => {
1790
- if (def.options.every((o) => o._zod.pattern)) {
1791
- const patterns = def.options.map((o) => o._zod.pattern);
2228
+ defineLazyInternal(inst, "pattern", (zod) => {
2229
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2230
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1792
2231
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1793
2232
  }
1794
2233
  });
@@ -1816,35 +2255,42 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1816
2255
  });
1817
2256
  };
1818
2257
  });
2258
+ function discriminatorMap(def) {
2259
+ const map = /* @__PURE__ */ new Map();
2260
+ for (const option of def.options) {
2261
+ const values = option._zod.propValues?.[def.discriminator];
2262
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2263
+ for (const value of values) if (map.has(value)) {
2264
+ if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
2265
+ map.set(value, null);
2266
+ } else map.set(value, option);
2267
+ }
2268
+ return map;
2269
+ }
1819
2270
  var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1820
2271
  def.inclusive = false;
1821
2272
  $ZodUnion.init(inst, def);
1822
2273
  const _super = inst._zod.parse;
1823
- defineLazy(inst._zod, "propValues", () => {
2274
+ defineLazyInternal(inst, "propValues", (zod) => {
1824
2275
  const propValues = {};
1825
- for (const option of def.options) {
2276
+ let undefinedCount = 0;
2277
+ for (const option of zod.def.options) {
1826
2278
  const pv = option._zod.propValues;
1827
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2279
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
2280
+ if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
1828
2281
  for (const [k, v] of Object.entries(pv)) {
1829
- if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
2282
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
1830
2283
  for (const val of v) propValues[k].add(val);
1831
2284
  }
1832
2285
  }
2286
+ if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
1833
2287
  return propValues;
1834
2288
  });
1835
- const disc = cached(() => {
1836
- const opts = def.options;
1837
- const map = /* @__PURE__ */ new Map();
1838
- for (const o of opts) {
1839
- const values = o._zod.propValues?.[def.discriminator];
1840
- if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1841
- for (const v of values) {
1842
- if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1843
- map.set(v, o);
1844
- }
1845
- }
1846
- return map;
2289
+ def.options.forEach((option, i) => {
2290
+ const propShape = rawShape(option._zod.def);
2291
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
1847
2292
  });
2293
+ const disc = cached(() => discriminatorMap(def));
1848
2294
  inst._zod.parse = (payload, ctx) => {
1849
2295
  const input = payload.value;
1850
2296
  if (!isObject(input)) {
@@ -1856,15 +2302,16 @@ var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion"
1856
2302
  });
1857
2303
  return payload;
1858
2304
  }
1859
- const opt = disc.value.get(input?.[def.discriminator]);
1860
- if (opt) return opt._zod.run(payload, ctx);
2305
+ const value = input?.[def.discriminator];
2306
+ const opt = disc.value.get(value);
2307
+ if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
1861
2308
  if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
1862
2309
  payload.issues.push({
1863
2310
  code: "invalid_union",
1864
2311
  errors: [],
1865
2312
  note: "No matching discriminator",
1866
2313
  discriminator: def.discriminator,
1867
- options: Array.from(disc.value.keys()),
2314
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
1868
2315
  input,
1869
2316
  path: [def.discriminator],
1870
2317
  inst
@@ -1906,7 +2353,9 @@ function mergeValues(a, b) {
1906
2353
  ...a,
1907
2354
  ...b
1908
2355
  };
2356
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
1909
2357
  for (const key of sharedKeys) {
2358
+ if (key === "__proto__") continue;
1910
2359
  const sharedValue = mergeValues(a[key], b[key]);
1911
2360
  if (!sharedValue.valid) return {
1912
2361
  valid: false,
@@ -1948,26 +2397,39 @@ function mergeValues(a, b) {
1948
2397
  function handleIntersectionResults(result, left, right) {
1949
2398
  const unrecKeys = /* @__PURE__ */ new Map();
1950
2399
  let unrecIssue;
1951
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1952
- unrecIssue ?? (unrecIssue = iss);
1953
- for (const k of iss.keys) {
2400
+ const keyIssues = /* @__PURE__ */ new Map();
2401
+ const collect = (iss, side) => {
2402
+ let keys;
2403
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2404
+ unrecIssue ?? (unrecIssue = iss);
2405
+ keys = iss.keys;
2406
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2407
+ const k = String(iss.path[0]);
2408
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2409
+ keys = [k];
2410
+ } else return false;
2411
+ for (const k of keys) {
1954
2412
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1955
- unrecKeys.get(k).l = true;
2413
+ unrecKeys.get(k)[side] = true;
1956
2414
  }
1957
- } else result.issues.push(iss);
1958
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1959
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1960
- unrecKeys.get(k).r = true;
1961
- }
1962
- else result.issues.push(iss);
2415
+ return true;
2416
+ };
2417
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2418
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
1963
2419
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1964
- if (bothKeys.length && unrecIssue) result.issues.push({
1965
- ...unrecIssue,
1966
- keys: bothKeys
1967
- });
1968
- if (aborted(result)) return result;
2420
+ if (bothKeys.length) {
2421
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2422
+ if (aggregated.length) result.issues.push({
2423
+ ...unrecIssue,
2424
+ keys: aggregated
2425
+ });
2426
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2427
+ }
1969
2428
  const merged = mergeValues(left.value, right.value);
1970
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2429
+ if (!merged.valid) {
2430
+ if (aborted(result)) return result;
2431
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2432
+ }
1971
2433
  result.value = merged.data;
1972
2434
  return result;
1973
2435
  }
@@ -1976,7 +2438,10 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1976
2438
  const values = getEnumValues(def.entries);
1977
2439
  const valuesSet = new Set(values);
1978
2440
  inst._zod.values = valuesSet;
1979
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2441
+ defineLazyInternal(inst, "pattern", (zod) => {
2442
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
2443
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2444
+ });
1980
2445
  inst._zod.parse = (payload, _ctx) => {
1981
2446
  const input = payload.value;
1982
2447
  if (valuesSet.has(input)) return payload;
@@ -1991,10 +2456,12 @@ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1991
2456
  });
1992
2457
  var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
1993
2458
  $ZodType.init(inst, def);
1994
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1995
2459
  const values = new Set(def.values);
1996
2460
  inst._zod.values = values;
1997
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
2461
+ defineLazyInternal(inst, "pattern", (zod) => {
2462
+ const vals = zod.def.values;
2463
+ return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
2464
+ });
1998
2465
  inst._zod.parse = (payload, _ctx) => {
1999
2466
  const input = payload.value;
2000
2467
  if (values.has(input)) return payload;
@@ -2010,67 +2477,66 @@ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
2010
2477
  var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2011
2478
  $ZodType.init(inst, def);
2012
2479
  inst._zod.optin = "optional";
2480
+ globalConfig.memoizer?.guard(inst);
2013
2481
  inst._zod.parse = (payload, ctx) => {
2014
2482
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2015
2483
  const _out = def.transform(payload.value, payload);
2016
2484
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2017
2485
  payload.value = output;
2018
- payload.fallback = true;
2019
2486
  return payload;
2020
2487
  });
2021
2488
  if (_out instanceof Promise) throw new $ZodAsyncError();
2022
2489
  payload.value = _out;
2023
- payload.fallback = true;
2024
2490
  return payload;
2025
2491
  };
2026
2492
  });
2027
- function handleOptionalResult(result, input) {
2028
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2029
- issues: [],
2030
- value: void 0
2031
- };
2032
- return result;
2493
+ function handleOptionalResult(payload, result) {
2494
+ payload.value = result.issues.length ? void 0 : result.value;
2495
+ return payload;
2033
2496
  }
2034
2497
  var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2035
2498
  $ZodType.init(inst, def);
2036
- inst._zod.optin = "optional";
2499
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2037
2500
  inst._zod.optout = "optional";
2038
- defineLazy(inst._zod, "values", () => {
2039
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
2501
+ defineLazyInternal(inst, "values", (zod) => {
2502
+ const values = zod.def.innerType._zod.values;
2503
+ return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
2040
2504
  });
2041
- defineLazy(inst._zod, "pattern", () => {
2042
- const pattern = def.innerType._zod.pattern;
2505
+ defineLazyInternal(inst, "pattern", (zod) => {
2506
+ const pattern = zod.def.innerType._zod.pattern;
2043
2507
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2044
2508
  });
2045
2509
  inst._zod.parse = (payload, ctx) => {
2046
- if (def.innerType._zod.optin === "optional") {
2047
- const input = payload.value;
2048
- const result = def.innerType._zod.run(payload, ctx);
2049
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2050
- return handleOptionalResult(result, input);
2510
+ if (payload.value === void 0) {
2511
+ if (def.innerType._zod.optin !== "defaulted") return payload;
2512
+ const result = def.innerType._zod.run({
2513
+ value: payload.value,
2514
+ issues: []
2515
+ }, ctx);
2516
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
2517
+ return handleOptionalResult(payload, result);
2051
2518
  }
2052
- if (payload.value === void 0) return payload;
2053
2519
  return def.innerType._zod.run(payload, ctx);
2054
2520
  };
2055
2521
  });
2056
2522
  var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2057
2523
  $ZodOptional.init(inst, def);
2058
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2059
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2524
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2525
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2060
2526
  inst._zod.parse = (payload, ctx) => {
2061
2527
  return def.innerType._zod.run(payload, ctx);
2062
2528
  };
2063
2529
  });
2064
2530
  var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2065
2531
  $ZodType.init(inst, def);
2066
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2067
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2068
- defineLazy(inst._zod, "pattern", () => {
2069
- const pattern = def.innerType._zod.pattern;
2532
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2533
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2534
+ defineLazyInternal(inst, "pattern", (zod) => {
2535
+ const pattern = zod.def.innerType._zod.pattern;
2070
2536
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2071
2537
  });
2072
- defineLazy(inst._zod, "values", () => {
2073
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
2538
+ defineLazyInternal(inst, "values", (zod) => {
2539
+ return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
2074
2540
  });
2075
2541
  inst._zod.parse = (payload, ctx) => {
2076
2542
  if (payload.value === null) return payload;
@@ -2079,8 +2545,8 @@ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2079
2545
  });
2080
2546
  var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2081
2547
  $ZodType.init(inst, def);
2082
- inst._zod.optin = "optional";
2083
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2548
+ inst._zod.optin = "defaulted";
2549
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2084
2550
  inst._zod.parse = (payload, ctx) => {
2085
2551
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2086
2552
  if (payload.value === void 0) {
@@ -2101,8 +2567,8 @@ function handleDefaultResult(payload, def) {
2101
2567
  }
2102
2568
  var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2103
2569
  $ZodType.init(inst, def);
2104
- inst._zod.optin = "optional";
2105
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2570
+ inst._zod.optin = "defaulted";
2571
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2106
2572
  inst._zod.parse = (payload, ctx) => {
2107
2573
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2108
2574
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -2111,8 +2577,8 @@ var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2111
2577
  });
2112
2578
  var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2113
2579
  $ZodType.init(inst, def);
2114
- defineLazy(inst._zod, "values", () => {
2115
- const v = def.innerType._zod.values;
2580
+ defineLazyInternal(inst, "values", (zod) => {
2581
+ const v = zod.def.innerType._zod.values;
2116
2582
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2117
2583
  });
2118
2584
  inst._zod.parse = (payload, ctx) => {
@@ -2130,46 +2596,41 @@ function handleNonOptionalResult(payload, inst) {
2130
2596
  });
2131
2597
  return payload;
2132
2598
  }
2599
+ function handleCatchResult(payload, result, def, ctx) {
2600
+ if (!result.issues.length) {
2601
+ payload.value = result.value;
2602
+ if (result.memo) payload.memo = true;
2603
+ return payload;
2604
+ }
2605
+ payload.value = def.catchValue({
2606
+ ...result,
2607
+ value: payload.value,
2608
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2609
+ input: payload.value
2610
+ });
2611
+ return payload;
2612
+ }
2133
2613
  var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2134
2614
  $ZodType.init(inst, def);
2135
- inst._zod.optin = "optional";
2136
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2137
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2615
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2616
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2617
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2138
2618
  inst._zod.parse = (payload, ctx) => {
2139
2619
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2140
- const result = def.innerType._zod.run(payload, ctx);
2141
- if (result instanceof Promise) return result.then((result) => {
2142
- payload.value = result.value;
2143
- if (result.issues.length) {
2144
- payload.value = def.catchValue({
2145
- ...payload,
2146
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2147
- input: payload.value
2148
- });
2149
- payload.issues = [];
2150
- payload.fallback = true;
2151
- }
2152
- return payload;
2153
- });
2154
- payload.value = result.value;
2155
- if (result.issues.length) {
2156
- payload.value = def.catchValue({
2157
- ...payload,
2158
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2159
- input: payload.value
2160
- });
2161
- payload.issues = [];
2162
- payload.fallback = true;
2163
- }
2164
- return payload;
2620
+ const result = def.innerType._zod.run({
2621
+ value: payload.value,
2622
+ issues: []
2623
+ }, ctx);
2624
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
2625
+ return handleCatchResult(payload, result, def, ctx);
2165
2626
  };
2166
2627
  });
2167
2628
  var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2168
2629
  $ZodType.init(inst, def);
2169
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2170
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2171
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2172
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2630
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2631
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2632
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2633
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2173
2634
  inst._zod.parse = (payload, ctx) => {
2174
2635
  if (ctx.direction === "backward") {
2175
2636
  const right = def.out._zod.run(payload, ctx);
@@ -2182,22 +2643,21 @@ var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2182
2643
  };
2183
2644
  });
2184
2645
  function handlePipeResult(left, next, ctx) {
2185
- if (left.issues.length) {
2646
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2186
2647
  left.aborted = true;
2187
2648
  return left;
2188
2649
  }
2189
2650
  return next._zod.run({
2190
2651
  value: left.value,
2191
- issues: left.issues,
2192
- fallback: left.fallback
2652
+ issues: left.issues
2193
2653
  }, ctx);
2194
2654
  }
2195
2655
  var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2196
2656
  $ZodType.init(inst, def);
2197
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2198
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2199
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2200
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2657
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2658
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2659
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2660
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2201
2661
  inst._zod.parse = (payload, ctx) => {
2202
2662
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2203
2663
  const result = def.innerType._zod.run(payload, ctx);
@@ -2206,7 +2666,7 @@ var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2206
2666
  };
2207
2667
  });
2208
2668
  function handleReadonlyResult(payload) {
2209
- payload.value = Object.freeze(payload.value);
2669
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
2210
2670
  return payload;
2211
2671
  }
2212
2672
  var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
@@ -2215,25 +2675,388 @@ var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2215
2675
  inst._zod.parse = (payload, _) => {
2216
2676
  return payload;
2217
2677
  };
2218
- inst._zod.check = (payload) => {
2219
- const input = payload.value;
2220
- const r = def.fn(input);
2221
- if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2222
- handleRefineResult(r, payload, input, inst);
2678
+ inst._zod.check = (payload) => {
2679
+ const input = payload.value;
2680
+ const r = def.fn(input);
2681
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2682
+ handleRefineResult(r, payload, input, inst);
2683
+ };
2684
+ });
2685
+ function handleRefineResult(result, payload, input, inst) {
2686
+ if (!result) {
2687
+ const _iss = {
2688
+ code: "custom",
2689
+ input,
2690
+ inst,
2691
+ path: [...inst._zod.def.path ?? []],
2692
+ continue: !inst._zod.def.abort
2693
+ };
2694
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2695
+ payload.issues.push(issue(_iss));
2696
+ }
2697
+ }
2698
+ //#endregion
2699
+ //#region ../../../node_modules/zod/v4/core/memoizer.js
2700
+ var $ZodCyclicError = class extends Error {
2701
+ constructor() {
2702
+ super(`Cannot parse a reference cycle that closes through a transform`);
2703
+ this.name = "ZodCyclicError";
2704
+ }
2705
+ };
2706
+ /** Keyed off the context object every schema in one parse call already shares. */
2707
+ var STATE = "~memo";
2708
+ var NO_ISSUES = [];
2709
+ function isRef(value) {
2710
+ return value !== null && (typeof value === "object" || typeof value === "function");
2711
+ }
2712
+ function cloneIssues(issues) {
2713
+ return issues.map((iss) => iss.path ? {
2714
+ ...iss,
2715
+ path: iss.path.slice()
2716
+ } : { ...iss });
2717
+ }
2718
+ var recursive = /*@__PURE__*/ new WeakMap();
2719
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
2720
+ var NONE = 0;
2721
+ var ASSUMED = 1;
2722
+ var PROVEN = 2;
2723
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
2724
+ function isRecursive(inst, stack, resolve) {
2725
+ const cached = recursive.get(inst);
2726
+ if (cached !== void 0) return cached ? PROVEN : NONE;
2727
+ if (stack.has(inst)) return PROVEN;
2728
+ stack.add(inst);
2729
+ let result = NONE;
2730
+ const check = (child) => {
2731
+ if (result !== PROVEN && child?._zod) {
2732
+ const answer = isRecursive(child, stack, resolve);
2733
+ if (answer > result) result = answer;
2734
+ }
2735
+ };
2736
+ const shape = (sh, spread) => {
2737
+ let answer = NONE;
2738
+ for (const key of Reflect.ownKeys(sh)) {
2739
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
2740
+ if (spread && !desc.enumerable) continue;
2741
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
2742
+ if (child > answer) answer = child;
2743
+ }
2744
+ return answer;
2745
+ };
2746
+ const merge = (answer) => {
2747
+ if (answer > result) result = answer;
2748
+ };
2749
+ const def = inst._zod.def;
2750
+ switch (def.type) {
2751
+ case "object": {
2752
+ const raw = rawShape(def);
2753
+ merge(raw ? shape(raw, true) : ASSUMED);
2754
+ check(def.catchall);
2755
+ break;
2756
+ }
2757
+ case "properties":
2758
+ merge(shape(def.shape, false));
2759
+ break;
2760
+ case "array":
2761
+ check(def.element);
2762
+ break;
2763
+ case "tuple":
2764
+ for (const el of def.items) check(el);
2765
+ check(def.rest);
2766
+ break;
2767
+ case "record":
2768
+ case "map":
2769
+ check(def.keyType);
2770
+ check(def.valueType);
2771
+ break;
2772
+ case "set":
2773
+ check(def.valueType);
2774
+ break;
2775
+ case "union":
2776
+ for (const el of def.options) check(el);
2777
+ break;
2778
+ case "intersection":
2779
+ check(def.left);
2780
+ check(def.right);
2781
+ break;
2782
+ case "optional":
2783
+ case "nullable":
2784
+ case "default":
2785
+ case "prefault":
2786
+ case "catch":
2787
+ case "readonly":
2788
+ case "nonoptional":
2789
+ case "promise":
2790
+ case "success":
2791
+ check(def.innerType);
2792
+ break;
2793
+ case "pipe":
2794
+ check(def.in);
2795
+ check(def.out);
2796
+ break;
2797
+ case "function":
2798
+ check(def.input);
2799
+ check(def.output);
2800
+ break;
2801
+ case "lazy": {
2802
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
2803
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
2804
+ break;
2805
+ }
2806
+ case "template_literal":
2807
+ case "string":
2808
+ case "number":
2809
+ case "int":
2810
+ case "boolean":
2811
+ case "bigint":
2812
+ case "symbol":
2813
+ case "undefined":
2814
+ case "null":
2815
+ case "void":
2816
+ case "never":
2817
+ case "any":
2818
+ case "unknown":
2819
+ case "date":
2820
+ case "nan":
2821
+ case "enum":
2822
+ case "literal":
2823
+ case "file":
2824
+ case "transform":
2825
+ case "custom": break;
2826
+ default: for (const key in def) {
2827
+ const desc = Object.getOwnPropertyDescriptor(def, key);
2828
+ if (!desc || desc.get) continue;
2829
+ const value = desc.value;
2830
+ if (!value || typeof value !== "object") continue;
2831
+ if (value._zod) check(value);
2832
+ else if (Array.isArray(value)) for (const el of value) check(el);
2833
+ }
2834
+ }
2835
+ stack.delete(inst);
2836
+ return settle(inst, result);
2837
+ }
2838
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
2839
+ function settle(inst, answer) {
2840
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
2841
+ return answer;
2842
+ }
2843
+ function bucketFor(state, inst) {
2844
+ let bucket = state.buckets.get(inst);
2845
+ if (!bucket) {
2846
+ bucket = /* @__PURE__ */ new WeakMap();
2847
+ state.buckets.set(inst, bucket);
2848
+ }
2849
+ return bucket;
2850
+ }
2851
+ var handoff;
2852
+ var open = [];
2853
+ var memo = {
2854
+ alloc(_inst, payload, empty) {
2855
+ const bucket = handoff;
2856
+ if (!bucket) return empty;
2857
+ handoff = void 0;
2858
+ const entry = {
2859
+ value: empty,
2860
+ issues: null
2861
+ };
2862
+ bucket.set(payload.value, entry);
2863
+ open.push(entry);
2864
+ return empty;
2865
+ },
2866
+ guard(inst) {
2867
+ var _a;
2868
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2869
+ inst._zod.deferred.push(() => {
2870
+ const base = inst._zod.parse;
2871
+ const wrapped = (payload, ctx) => {
2872
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
2873
+ return base(payload, ctx);
2874
+ };
2875
+ inst._zod.parse = wrapped;
2876
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2877
+ });
2878
+ },
2879
+ attach(inst) {
2880
+ var _a;
2881
+ let isRecursiveInst;
2882
+ let rechecked = false;
2883
+ let lastCtx;
2884
+ let lastBucket;
2885
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2886
+ inst._zod.deferred.push(() => {
2887
+ const base = inst._zod.parse;
2888
+ const wrapped = (payload, ctx) => {
2889
+ if (isRecursiveInst === void 0) {
2890
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
2891
+ if (walked === NONE) {
2892
+ inst._zod.parse = base;
2893
+ if (inst._zod.run === wrapped) inst._zod.run = base;
2894
+ return base(payload, ctx);
2895
+ }
2896
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
2897
+ else rechecked = true;
2898
+ }
2899
+ const input = payload.value;
2900
+ if (!isRef(input)) return base(payload, ctx);
2901
+ let state = ctx[STATE];
2902
+ if (!state) {
2903
+ state = {
2904
+ buckets: /* @__PURE__ */ new WeakMap(),
2905
+ backEdges: void 0
2906
+ };
2907
+ ctx[STATE] = state;
2908
+ }
2909
+ let bucket;
2910
+ if (lastCtx === ctx) bucket = lastBucket;
2911
+ else {
2912
+ bucket = bucketFor(state, inst);
2913
+ lastCtx = ctx;
2914
+ lastBucket = bucket;
2915
+ }
2916
+ const hit = bucket.get(input);
2917
+ if (hit) {
2918
+ payload.value = hit.value;
2919
+ if (hit.issues) {
2920
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
2921
+ } else {
2922
+ payload.memo = true;
2923
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
2924
+ state.backEdges.add(hit.value);
2925
+ }
2926
+ return payload;
2927
+ }
2928
+ handoff = bucket;
2929
+ const depth = open.length;
2930
+ const result = base(payload, ctx);
2931
+ handoff = void 0;
2932
+ const entry = open.length > depth ? open.pop() : void 0;
2933
+ if (result instanceof Promise) return result.then((r) => {
2934
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
2935
+ return r;
2936
+ });
2937
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
2938
+ return result;
2939
+ };
2940
+ inst._zod.parse = wrapped;
2941
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2942
+ });
2943
+ }
2944
+ };
2945
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
2946
+ function memoizer() {
2947
+ return memo;
2948
+ }
2949
+ /** Whether this value is a node a back-edge resolved to before it finished. */
2950
+ function isBackEdge(ctx, value) {
2951
+ const backEdges = ctx[STATE]?.backEdges;
2952
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
2953
+ }
2954
+ //#endregion
2955
+ //#region ../../../node_modules/zod/v4/locales/en.js
2956
+ var error = () => {
2957
+ const Sizable = {
2958
+ string: {
2959
+ unit: "characters",
2960
+ verb: "to have"
2961
+ },
2962
+ file: {
2963
+ unit: "bytes",
2964
+ verb: "to have"
2965
+ },
2966
+ array: {
2967
+ unit: "items",
2968
+ verb: "to have"
2969
+ },
2970
+ set: {
2971
+ unit: "items",
2972
+ verb: "to have"
2973
+ },
2974
+ map: {
2975
+ unit: "entries",
2976
+ verb: "to have"
2977
+ }
2978
+ };
2979
+ function getSizing(origin) {
2980
+ return Sizable[origin] ?? null;
2981
+ }
2982
+ const FormatDictionary = {
2983
+ regex: "input",
2984
+ email: "email address",
2985
+ url: "URL",
2986
+ emoji: "emoji",
2987
+ uuid: "UUID",
2988
+ uuidv4: "UUIDv4",
2989
+ uuidv6: "UUIDv6",
2990
+ nanoid: "nanoid",
2991
+ guid: "GUID",
2992
+ cuid: "cuid",
2993
+ cuid2: "cuid2",
2994
+ ulid: "ULID",
2995
+ xid: "XID",
2996
+ ksuid: "KSUID",
2997
+ datetime: "ISO datetime",
2998
+ date: "ISO date",
2999
+ time: "ISO time",
3000
+ duration: "ISO duration",
3001
+ ipv4: "IPv4 address",
3002
+ ipv6: "IPv6 address",
3003
+ mac: "MAC address",
3004
+ cidrv4: "IPv4 range",
3005
+ cidrv6: "IPv6 range",
3006
+ base64: "base64-encoded string",
3007
+ base64url: "base64url-encoded string",
3008
+ json_string: "JSON string",
3009
+ e164: "E.164 number",
3010
+ credit_card: "credit card number",
3011
+ iban: "IBAN",
3012
+ jwt: "JWT",
3013
+ template_literal: "input"
2223
3014
  };
2224
- });
2225
- function handleRefineResult(result, payload, input, inst) {
2226
- if (!result) {
2227
- const _iss = {
2228
- code: "custom",
2229
- input,
2230
- inst,
2231
- path: [...inst._zod.def.path ?? []],
2232
- continue: !inst._zod.def.abort
2233
- };
2234
- if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2235
- payload.issues.push(issue(_iss));
3015
+ const TypeDictionary = { nan: "NaN" };
3016
+ function getTypeName(type, input) {
3017
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
3018
+ return TypeDictionary[type] ?? type;
2236
3019
  }
3020
+ return (issue) => {
3021
+ switch (issue.code) {
3022
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
3023
+ case "invalid_value":
3024
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
3025
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
3026
+ case "too_big": {
3027
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
3028
+ const sizing = getSizing(issue.origin);
3029
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
3030
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
3031
+ }
3032
+ case "too_small": {
3033
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
3034
+ const sizing = getSizing(issue.origin);
3035
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
3036
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
3037
+ }
3038
+ case "invalid_format": {
3039
+ const _issue = issue;
3040
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
3041
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
3042
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
3043
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
3044
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
3045
+ }
3046
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
3047
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
3048
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
3049
+ case "invalid_union":
3050
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
3051
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
3052
+ return "Invalid input";
3053
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
3054
+ default: return `Invalid input`;
3055
+ }
3056
+ };
3057
+ };
3058
+ function en_default() {
3059
+ return { localeError: error() };
2237
3060
  }
2238
3061
  //#endregion
2239
3062
  //#region ../../../node_modules/zod/v4/core/registries.js
@@ -2768,7 +3591,7 @@ function _superRefine(fn, params) {
2768
3591
  const _issue = issue$2;
2769
3592
  if (_issue.fatal) _issue.continue = false;
2770
3593
  _issue.code ?? (_issue.code = "custom");
2771
- _issue.input ?? (_issue.input = payload.value);
3594
+ if (!("input" in _issue)) _issue.input = payload.value;
2772
3595
  _issue.inst ?? (_issue.inst = ch);
2773
3596
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2774
3597
  payload.issues.push(issue(_issue));
@@ -2789,6 +3612,10 @@ function _check(fn, params) {
2789
3612
  }
2790
3613
  //#endregion
2791
3614
  //#region ../../../node_modules/zod/v4/core/to-json-schema.js
3615
+ function assignProps(target, ...sources) {
3616
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
3617
+ return target;
3618
+ }
2792
3619
  function initializeContext(params) {
2793
3620
  let target = params?.target ?? "draft-2020-12";
2794
3621
  if (target === "draft-4") target = "draft-04";
@@ -2802,12 +3629,32 @@ function initializeContext(params) {
2802
3629
  io: params?.io ?? "output",
2803
3630
  counter: 0,
2804
3631
  seen: /* @__PURE__ */ new Map(),
3632
+ sharedDefsExtractedFor: void 0,
3633
+ sharedEmitDoneFor: void 0,
2805
3634
  cycles: params?.cycles ?? "ref",
2806
3635
  reused: params?.reused ?? "inline",
3636
+ intersections: [],
3637
+ deferred: [],
2807
3638
  external: params?.external ?? void 0
2808
3639
  };
2809
3640
  }
2810
- function process(schema, ctx, _params = {
3641
+ /**
3642
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
3643
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
3644
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
3645
+ */
3646
+ function handleUnrepresentable(schema, ctx, json, params, message) {
3647
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
3648
+ zodSchema: schema,
3649
+ path: params.path,
3650
+ message
3651
+ }) : ctx.unrepresentable;
3652
+ if (result === "any") return false;
3653
+ if (result === void 0 || result === "throw") throw new Error(message);
3654
+ Object.assign(json, result);
3655
+ return true;
3656
+ }
3657
+ function processSchema(schema, ctx, _params = {
2811
3658
  path: [],
2812
3659
  schemaPath: []
2813
3660
  }) {
@@ -2826,6 +3673,8 @@ function process(schema, ctx, _params = {
2826
3673
  path: _params.path
2827
3674
  };
2828
3675
  ctx.seen.set(schema, result);
3676
+ ctx.sharedDefsExtractedFor = void 0;
3677
+ ctx.sharedEmitDoneFor = void 0;
2829
3678
  const overrideSchema = schema._zod.toJSONSchema?.();
2830
3679
  if (overrideSchema) result.schema = overrideSchema;
2831
3680
  else {
@@ -2844,12 +3693,12 @@ function process(schema, ctx, _params = {
2844
3693
  const parent = schema._zod.parent;
2845
3694
  if (parent) {
2846
3695
  if (!result.ref) result.ref = parent;
2847
- process(parent, ctx, params);
3696
+ processSchema(parent, ctx, params);
2848
3697
  ctx.seen.get(parent).isParent = true;
2849
3698
  }
2850
3699
  }
2851
3700
  const meta = ctx.metadataRegistry.get(schema);
2852
- if (meta) Object.assign(result.schema, meta);
3701
+ if (meta) assignProps(result.schema, meta);
2853
3702
  if (ctx.io === "input" && isTransforming(schema)) {
2854
3703
  delete result.schema.examples;
2855
3704
  delete result.schema.default;
@@ -2858,9 +3707,13 @@ function process(schema, ctx, _params = {
2858
3707
  delete result.schema._prefault;
2859
3708
  return ctx.seen.get(schema).schema;
2860
3709
  }
3710
+ function encodeJSONPointerSegment(segment) {
3711
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
3712
+ }
2861
3713
  function extractDefs(ctx, schema) {
2862
3714
  const root = ctx.seen.get(schema);
2863
3715
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3716
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
2864
3717
  const idToSchema = /* @__PURE__ */ new Map();
2865
3718
  for (const entry of ctx.seen.entries()) {
2866
3719
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -2880,15 +3733,16 @@ function extractDefs(ctx, schema) {
2880
3733
  entry[1].defId = id;
2881
3734
  return {
2882
3735
  defId: id,
2883
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3736
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
2884
3737
  };
2885
3738
  }
2886
- if (entry[1] === root) return { ref: "#" };
2887
- const defUriPrefix = `#/${defsSegment}/`;
3739
+ const uriPrefix = `#`;
3740
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3741
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
2888
3742
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2889
3743
  return {
2890
3744
  defId,
2891
- ref: defUriPrefix + defId
3745
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
2892
3746
  };
2893
3747
  };
2894
3748
  const extractToDef = (entry) => {
@@ -2929,12 +3783,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
2929
3783
  continue;
2930
3784
  }
2931
3785
  if (seen.count > 1) {
2932
- if (ctx.reused === "ref") {
2933
- extractToDef(entry);
2934
- continue;
3786
+ if (ctx.reused === "ref") extractToDef(entry);
3787
+ }
3788
+ }
3789
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
3790
+ }
3791
+ /** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
3792
+ function compactTypeUnion(schema) {
3793
+ const options = schema.anyOf;
3794
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
3795
+ const types = [];
3796
+ for (const option of options) {
3797
+ if (!option || typeof option !== "object") return;
3798
+ compactTypeUnion(option);
3799
+ const keys = Object.keys(option);
3800
+ if (keys.length !== 1 || keys[0] !== "type") return;
3801
+ const type = option.type;
3802
+ for (const member of Array.isArray(type) ? type : [type]) {
3803
+ if (typeof member !== "string") return;
3804
+ if (!types.includes(member)) types.push(member);
3805
+ }
3806
+ }
3807
+ delete schema.anyOf;
3808
+ schema.type = types.length === 1 ? types[0] : types;
3809
+ }
3810
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
3811
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
3812
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
3813
+ var FOLDABLE_KEYS = /* @__PURE__ */ new Set([
3814
+ "type",
3815
+ "properties",
3816
+ "required",
3817
+ "additionalProperties"
3818
+ ]);
3819
+ var UNION_KEYS = ["oneOf", "anyOf"];
3820
+ /** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
3821
+ function undeclaredConstraint(member) {
3822
+ const extra = member.additionalProperties;
3823
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
3824
+ return Object.keys(extra).length ? extra : null;
3825
+ }
3826
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
3827
+ function foldObjects(members) {
3828
+ const objects = [];
3829
+ for (const member of members) {
3830
+ if (typeof member !== "object" || member.type !== "object") return null;
3831
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
3832
+ objects.push(member);
3833
+ }
3834
+ const properties = {};
3835
+ const required = /* @__PURE__ */ new Set();
3836
+ for (const object of objects) {
3837
+ for (const key in object.properties) {
3838
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
3839
+ const parts = [];
3840
+ for (const other of objects) {
3841
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
3842
+ if (part === null || part === void 0) continue;
3843
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
2935
3844
  }
3845
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
3846
+ }
3847
+ for (const key of object.required ?? []) required.add(key);
3848
+ }
3849
+ const folded = {
3850
+ type: "object",
3851
+ properties
3852
+ };
3853
+ if (required.size) folded.required = [...required];
3854
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
3855
+ else {
3856
+ const constraints = [];
3857
+ for (const object of objects) {
3858
+ const constraint = undeclaredConstraint(object);
3859
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
2936
3860
  }
3861
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
3862
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
3863
+ }
3864
+ return folded;
3865
+ }
3866
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
3867
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
3868
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
3869
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
3870
+ * into one object is the encoding that says so on every target.
3871
+ *
3872
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
3873
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
3874
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
3875
+ function foldIntersection(json) {
3876
+ const allOf = json.allOf;
3877
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
3878
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
3879
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
3880
+ let folded = null;
3881
+ if (!unions.length) folded = foldObjects(allOf);
3882
+ else {
3883
+ const union = unions[0];
3884
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
3885
+ if (Object.keys(union).length !== 1) return;
3886
+ const rest = allOf.filter((m) => m !== union);
3887
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
3888
+ if (branches.some((b) => !b)) return;
3889
+ folded = { [keyword]: branches };
2937
3890
  }
3891
+ if (!folded) return;
3892
+ delete json.allOf;
3893
+ assignProps(json, folded);
2938
3894
  }
2939
3895
  function finalize(ctx, schema) {
2940
3896
  const root = ctx.seen.get(schema);
@@ -2953,8 +3909,8 @@ function finalize(ctx, schema) {
2953
3909
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2954
3910
  schema.allOf = schema.allOf ?? [];
2955
3911
  schema.allOf.push(refSchema);
2956
- } else Object.assign(schema, refSchema);
2957
- Object.assign(schema, _cached);
3912
+ } else assignProps(schema, refSchema);
3913
+ assignProps(schema, _cached);
2958
3914
  if (zodSchema._zod.parent === ref) for (const key in schema) {
2959
3915
  if (key === "$ref" || key === "allOf") continue;
2960
3916
  if (!(key in _cached)) delete schema[key];
@@ -2982,7 +3938,22 @@ function finalize(ctx, schema) {
2982
3938
  path: seen.path ?? []
2983
3939
  });
2984
3940
  };
2985
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3941
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
3942
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3943
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
3944
+ for (const rewrite of ctx.deferred) rewrite();
3945
+ if (ctx.intersections.length) {
3946
+ const carriers = /* @__PURE__ */ new Map();
3947
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
3948
+ const allOf = json?.allOf;
3949
+ if (!Array.isArray(allOf)) continue;
3950
+ const existing = carriers.get(allOf);
3951
+ if (existing) existing.push(json);
3952
+ else carriers.set(allOf, [json]);
3953
+ }
3954
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
3955
+ }
3956
+ }
2986
3957
  const result = {};
2987
3958
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2988
3959
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -2993,19 +3964,22 @@ function finalize(ctx, schema) {
2993
3964
  if (!id) throw new Error("Schema is missing an `id` property");
2994
3965
  result.$id = ctx.external.uri(id);
2995
3966
  }
2996
- Object.assign(result, root.def ?? root.schema);
3967
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
2997
3968
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2998
3969
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2999
3970
  const defs = ctx.external?.defs ?? {};
3000
- for (const entry of ctx.seen.entries()) {
3971
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
3001
3972
  const seen = entry[1];
3002
3973
  if (seen.def && seen.defId) {
3003
3974
  if (seen.def.id === seen.defId) delete seen.def.id;
3004
- defs[seen.defId] = seen.def;
3975
+ assignProp(defs, seen.defId, seen.def);
3005
3976
  }
3006
3977
  }
3007
- if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
3008
- else result.definitions = defs;
3978
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
3979
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) {
3980
+ if (ctx.target === "draft-2020-12") result.$defs = defs;
3981
+ else result.definitions = defs;
3982
+ }
3009
3983
  try {
3010
3984
  const finalized = JSON.parse(JSON.stringify(result));
3011
3985
  Object.defineProperty(finalized, "~standard", {
@@ -3033,7 +4007,7 @@ function isTransforming(_schema, _ctx) {
3033
4007
  if (def.type === "array") return isTransforming(def.element, ctx);
3034
4008
  if (def.type === "set") return isTransforming(def.valueType, ctx);
3035
4009
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
3036
- 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);
4010
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault" || def.type === "catch") return isTransforming(def.innerType, ctx);
3037
4011
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3038
4012
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3039
4013
  if (def.type === "pipe") {
@@ -3064,7 +4038,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3064
4038
  ...params,
3065
4039
  processors
3066
4040
  });
3067
- process(schema, ctx);
4041
+ processSchema(schema, ctx);
3068
4042
  extractDefs(ctx, schema);
3069
4043
  return finalize(ctx, schema);
3070
4044
  };
@@ -3076,12 +4050,84 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
3076
4050
  io,
3077
4051
  processors
3078
4052
  });
3079
- process(schema, ctx);
4053
+ processSchema(schema, ctx);
3080
4054
  extractDefs(ctx, schema);
3081
4055
  return finalize(ctx, schema);
3082
4056
  };
3083
4057
  //#endregion
3084
4058
  //#region ../../../node_modules/zod/v4/core/json-schema-processors.js
4059
+ var narrowMin = (agg, key, value) => {
4060
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
4061
+ };
4062
+ var narrowMax = (agg, key, value) => {
4063
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
4064
+ };
4065
+ var narrowBoth = (agg, value) => {
4066
+ narrowMin(agg, "minimum", value);
4067
+ narrowMax(agg, "maximum", value);
4068
+ };
4069
+ var addDivisor = (agg, value) => {
4070
+ agg.multipleOf ?? (agg.multipleOf = []);
4071
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
4072
+ };
4073
+ var addPattern = (agg, pattern) => {
4074
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
4075
+ agg.patterns.add(pattern);
4076
+ };
4077
+ var intersectMime = (agg, mime) => {
4078
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
4079
+ };
4080
+ var setFormat = (agg, format) => {
4081
+ agg.format = format;
4082
+ if (format.includes("int")) agg.isInt = true;
4083
+ };
4084
+ var minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
4085
+ var maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
4086
+ var formatContributor = (ranges) => (agg, def) => {
4087
+ setFormat(agg, def.format);
4088
+ const [minimum, maximum] = ranges[def.format];
4089
+ narrowMin(agg, "minimum", minimum);
4090
+ narrowMax(agg, "maximum", maximum);
4091
+ };
4092
+ var contributors = {
4093
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
4094
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
4095
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
4096
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
4097
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
4098
+ min_length: minContributor,
4099
+ max_length: maxContributor,
4100
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
4101
+ min_size: minContributor,
4102
+ max_size: maxContributor,
4103
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
4104
+ string_format: (agg, def) => {
4105
+ setFormat(agg, def.format);
4106
+ if (def.pattern) addPattern(agg, def.pattern);
4107
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
4108
+ if (def.local || def.precision === -1) agg.laxFormat = true;
4109
+ },
4110
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
4111
+ };
4112
+ function aggregateChecks(schema) {
4113
+ const agg = {};
4114
+ const def = schema._zod.def;
4115
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
4116
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
4117
+ const bag = schema._zod.bag;
4118
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
4119
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
4120
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
4121
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
4122
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
4123
+ if (bag.format !== void 0) {
4124
+ agg.format ?? (agg.format = bag.format);
4125
+ if (bag.format.includes("int")) agg.isInt = true;
4126
+ }
4127
+ if (bag.mime) intersectMime(agg, bag.mime);
4128
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
4129
+ return agg;
4130
+ }
3085
4131
  var formatMap = {
3086
4132
  guid: "uuid",
3087
4133
  url: "uri",
@@ -3089,46 +4135,56 @@ var formatMap = {
3089
4135
  json_string: "json-string",
3090
4136
  regex: ""
3091
4137
  };
4138
+ var exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
4139
+ var exactPattern = (p) => exactPatterns.get(p) ?? p;
3092
4140
  var stringProcessor = (schema, ctx, _json, _params) => {
3093
4141
  const json = _json;
3094
4142
  json.type = "string";
3095
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
4143
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
3096
4144
  if (typeof minimum === "number") json.minLength = minimum;
3097
4145
  if (typeof maximum === "number") json.maxLength = maximum;
3098
4146
  if (format) {
3099
4147
  json.format = formatMap[format] ?? format;
3100
4148
  if (json.format === "") delete json.format;
3101
- if (format === "time") delete json.format;
4149
+ if (format === "time" || laxFormat) delete json.format;
3102
4150
  }
3103
4151
  if (contentEncoding) json.contentEncoding = contentEncoding;
3104
4152
  if (patterns && patterns.size > 0) {
3105
- const regexes = [...patterns];
3106
- if (regexes.length === 1) json.pattern = regexes[0].source;
3107
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
4153
+ const patternList = [...patterns].map(exactPattern);
4154
+ if (patternList.length === 1) json.pattern = patternList[0].source;
4155
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
3108
4156
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3109
4157
  pattern: regex.source
3110
4158
  }))];
3111
4159
  }
3112
4160
  };
3113
- var numberProcessor = (schema, ctx, _json, _params) => {
4161
+ var numberProcessor = (schema, ctx, _json, params) => {
3114
4162
  const json = _json;
3115
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3116
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
3117
- else json.type = "number";
4163
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
4164
+ json.type = isInt ? "integer" : "number";
3118
4165
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3119
4166
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3120
4167
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3121
- if (exMin) if (legacy) {
3122
- json.minimum = exclusiveMinimum;
3123
- json.exclusiveMinimum = true;
3124
- } else json.exclusiveMinimum = exclusiveMinimum;
3125
- else if (typeof minimum === "number") json.minimum = minimum;
3126
- if (exMax) if (legacy) {
3127
- json.maximum = exclusiveMaximum;
3128
- json.exclusiveMaximum = true;
3129
- } else json.exclusiveMaximum = exclusiveMaximum;
3130
- else if (typeof maximum === "number") json.maximum = maximum;
3131
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
4168
+ if (exMin) {
4169
+ if (legacy) {
4170
+ json.minimum = exclusiveMinimum;
4171
+ json.exclusiveMinimum = true;
4172
+ } else json.exclusiveMinimum = exclusiveMinimum;
4173
+ } else if (typeof minimum === "number") json.minimum = minimum;
4174
+ if (exMax) {
4175
+ if (legacy) {
4176
+ json.maximum = exclusiveMaximum;
4177
+ json.exclusiveMaximum = true;
4178
+ } else json.exclusiveMaximum = exclusiveMaximum;
4179
+ } else if (typeof maximum === "number") json.maximum = maximum;
4180
+ if (multipleOf) {
4181
+ const divisors = /* @__PURE__ */ new Set();
4182
+ for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
4183
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
4184
+ const [first, ...rest] = divisors;
4185
+ if (first !== void 0) json.multipleOf = first;
4186
+ if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
4187
+ }
3132
4188
  };
3133
4189
  var booleanProcessor = (_schema, _ctx, json, _params) => {
3134
4190
  json.type = "boolean";
@@ -3139,18 +4195,27 @@ var neverProcessor = (_schema, _ctx, json, _params) => {
3139
4195
  var enumProcessor = (schema, _ctx, json, _params) => {
3140
4196
  const def = schema._zod.def;
3141
4197
  const values = getEnumValues(def.entries);
4198
+ if (values.length === 0) {
4199
+ json.not = {};
4200
+ return;
4201
+ }
3142
4202
  if (values.every((v) => typeof v === "number")) json.type = "number";
3143
4203
  if (values.every((v) => typeof v === "string")) json.type = "string";
3144
4204
  json.enum = values;
3145
4205
  };
3146
- var literalProcessor = (schema, ctx, json, _params) => {
4206
+ var literalProcessor = (schema, ctx, json, params) => {
3147
4207
  const def = schema._zod.def;
4208
+ if (def.values.length === 0) {
4209
+ json.not = {};
4210
+ return;
4211
+ }
3148
4212
  const vals = [];
3149
4213
  for (const val of def.values) if (val === void 0) {
3150
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3151
- } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3152
- else vals.push(Number(val));
3153
- else vals.push(val);
4214
+ if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
4215
+ } else if (typeof val === "bigint") {
4216
+ if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
4217
+ vals.push(Number(val));
4218
+ } else vals.push(val);
3154
4219
  if (vals.length === 0) {} else if (vals.length === 1) {
3155
4220
  const val = vals[0];
3156
4221
  json.type = val === null ? "null" : typeof val;
@@ -3164,49 +4229,56 @@ var literalProcessor = (schema, ctx, json, _params) => {
3164
4229
  json.enum = vals;
3165
4230
  }
3166
4231
  };
3167
- var customProcessor = (_schema, ctx, _json, _params) => {
3168
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4232
+ var customProcessor = (schema, ctx, json, params) => {
4233
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
3169
4234
  };
3170
- var transformProcessor = (_schema, ctx, _json, _params) => {
3171
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4235
+ var transformProcessor = (schema, ctx, json, params) => {
4236
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
3172
4237
  };
3173
4238
  var arrayProcessor = (schema, ctx, _json, params) => {
3174
4239
  const json = _json;
3175
4240
  const def = schema._zod.def;
3176
- const { minimum, maximum } = schema._zod.bag;
4241
+ const { minimum, maximum } = aggregateChecks(schema);
3177
4242
  if (typeof minimum === "number") json.minItems = minimum;
3178
4243
  if (typeof maximum === "number") json.maxItems = maximum;
3179
4244
  json.type = "array";
3180
- json.items = process(def.element, ctx, {
4245
+ json.items = processSchema(def.element, ctx, {
3181
4246
  ...params,
3182
4247
  path: [...params.path, "items"]
3183
4248
  });
3184
4249
  };
4250
+ function inputOptin(schema) {
4251
+ const def = schema._zod.def;
4252
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
4253
+ if (def.type === "catch") return inputOptin(def.innerType);
4254
+ return schema._zod.optin;
4255
+ }
3185
4256
  var objectProcessor = (schema, ctx, _json, params) => {
3186
4257
  const json = _json;
3187
4258
  const def = schema._zod.def;
4259
+ const shape = def.shape;
4260
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
3188
4261
  json.type = "object";
3189
4262
  json.properties = {};
3190
- const shape = def.shape;
3191
- for (const key in shape) json.properties[key] = process(shape[key], ctx, {
4263
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
3192
4264
  ...params,
3193
4265
  path: [
3194
4266
  ...params.path,
3195
4267
  "properties",
3196
4268
  key
3197
4269
  ]
3198
- });
4270
+ }));
3199
4271
  const allKeys = new Set(Object.keys(shape));
3200
4272
  const requiredKeys = new Set([...allKeys].filter((key) => {
3201
- const v = def.shape[key]._zod;
3202
- if (ctx.io === "input") return v.optin === void 0;
3203
- else return v.optout === void 0;
4273
+ const field = def.shape[key];
4274
+ if (ctx.io === "input") return inputOptin(field) === void 0;
4275
+ else return field._zod.optout === void 0;
3204
4276
  }));
3205
4277
  if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3206
4278
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3207
4279
  else if (!def.catchall) {
3208
4280
  if (ctx.io === "output") json.additionalProperties = false;
3209
- } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
4281
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
3210
4282
  ...params,
3211
4283
  path: [...params.path, "additionalProperties"]
3212
4284
  });
@@ -3214,7 +4286,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
3214
4286
  var unionProcessor = (schema, ctx, json, params) => {
3215
4287
  const def = schema._zod.def;
3216
4288
  const isExclusive = def.inclusive === false;
3217
- const options = def.options.map((x, i) => process(x, ctx, {
4289
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
3218
4290
  ...params,
3219
4291
  path: [
3220
4292
  ...params.path,
@@ -3227,7 +4299,7 @@ var unionProcessor = (schema, ctx, json, params) => {
3227
4299
  };
3228
4300
  var intersectionProcessor = (schema, ctx, json, params) => {
3229
4301
  const def = schema._zod.def;
3230
- const a = process(def.left, ctx, {
4302
+ const a = processSchema(def.left, ctx, {
3231
4303
  ...params,
3232
4304
  path: [
3233
4305
  ...params.path,
@@ -3235,7 +4307,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3235
4307
  0
3236
4308
  ]
3237
4309
  });
3238
- const b = process(def.right, ctx, {
4310
+ const b = processSchema(def.right, ctx, {
3239
4311
  ...params,
3240
4312
  path: [
3241
4313
  ...params.path,
@@ -3244,11 +4316,13 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3244
4316
  ]
3245
4317
  });
3246
4318
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3247
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4319
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4320
+ json.allOf = allOf;
4321
+ ctx.intersections.push(allOf);
3248
4322
  };
3249
4323
  var nullableProcessor = (schema, ctx, json, params) => {
3250
4324
  const def = schema._zod.def;
3251
- const inner = process(def.innerType, ctx, params);
4325
+ const inner = processSchema(def.innerType, ctx, params);
3252
4326
  const seen = ctx.seen.get(schema);
3253
4327
  if (ctx.target === "openapi-3.0") {
3254
4328
  seen.ref = def.innerType;
@@ -3257,34 +4331,53 @@ var nullableProcessor = (schema, ctx, json, params) => {
3257
4331
  };
3258
4332
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
3259
4333
  const def = schema._zod.def;
3260
- process(def.innerType, ctx, params);
4334
+ processSchema(def.innerType, ctx, params);
3261
4335
  const seen = ctx.seen.get(schema);
3262
4336
  seen.ref = def.innerType;
3263
4337
  };
4338
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
4339
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
4340
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
4341
+ var UNREPRESENTABLE_DEFAULT = Symbol();
4342
+ function serializeDefaultValue(value, schema, ctx, json, params) {
4343
+ let unrepresentable = false;
4344
+ const serialized = JSON.stringify(value, (_, val) => {
4345
+ if (typeof val !== "bigint") return val;
4346
+ unrepresentable = true;
4347
+ return null;
4348
+ });
4349
+ if (!unrepresentable) return JSON.parse(serialized);
4350
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
4351
+ return UNREPRESENTABLE_DEFAULT;
4352
+ }
3264
4353
  var defaultProcessor = (schema, ctx, json, params) => {
3265
4354
  const def = schema._zod.def;
3266
- process(def.innerType, ctx, params);
4355
+ processSchema(def.innerType, ctx, params);
3267
4356
  const seen = ctx.seen.get(schema);
3268
4357
  seen.ref = def.innerType;
3269
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4358
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4359
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
3270
4360
  };
3271
4361
  var prefaultProcessor = (schema, ctx, json, params) => {
3272
4362
  const def = schema._zod.def;
3273
- process(def.innerType, ctx, params);
4363
+ processSchema(def.innerType, ctx, params);
3274
4364
  const seen = ctx.seen.get(schema);
3275
4365
  seen.ref = def.innerType;
3276
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4366
+ if (ctx.io !== "input") return;
4367
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4368
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
3277
4369
  };
3278
4370
  var catchProcessor = (schema, ctx, json, params) => {
3279
4371
  const def = schema._zod.def;
3280
- process(def.innerType, ctx, params);
4372
+ processSchema(def.innerType, ctx, params);
3281
4373
  const seen = ctx.seen.get(schema);
3282
4374
  seen.ref = def.innerType;
3283
4375
  let catchValue;
3284
4376
  try {
3285
4377
  catchValue = def.catchValue(void 0);
3286
4378
  } catch {
3287
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4379
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
4380
+ return;
3288
4381
  }
3289
4382
  json.default = catchValue;
3290
4383
  };
@@ -3292,75 +4385,73 @@ var pipeProcessor = (schema, ctx, _json, params) => {
3292
4385
  const def = schema._zod.def;
3293
4386
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3294
4387
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3295
- process(innerType, ctx, params);
4388
+ processSchema(innerType, ctx, params);
3296
4389
  const seen = ctx.seen.get(schema);
3297
4390
  seen.ref = innerType;
3298
4391
  };
3299
4392
  var readonlyProcessor = (schema, ctx, json, params) => {
3300
4393
  const def = schema._zod.def;
3301
- process(def.innerType, ctx, params);
4394
+ processSchema(def.innerType, ctx, params);
3302
4395
  const seen = ctx.seen.get(schema);
3303
4396
  seen.ref = def.innerType;
3304
4397
  json.readOnly = true;
3305
4398
  };
3306
4399
  var optionalProcessor = (schema, ctx, _json, params) => {
3307
4400
  const def = schema._zod.def;
3308
- process(def.innerType, ctx, params);
4401
+ processSchema(def.innerType, ctx, params);
3309
4402
  const seen = ctx.seen.get(schema);
3310
4403
  seen.ref = def.innerType;
3311
4404
  };
3312
4405
  //#endregion
3313
- //#region ../../../node_modules/zod/v4/classic/iso.js
3314
- var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3315
- $ZodISODateTime.init(inst, def);
3316
- ZodStringFormat.init(inst, def);
3317
- });
3318
- function datetime(params) {
3319
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3320
- }
3321
- var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3322
- $ZodISODate.init(inst, def);
3323
- ZodStringFormat.init(inst, def);
3324
- });
3325
- function date(params) {
3326
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3327
- }
3328
- var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3329
- $ZodISOTime.init(inst, def);
3330
- ZodStringFormat.init(inst, def);
3331
- });
3332
- function time(params) {
3333
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3334
- }
3335
- var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3336
- $ZodISODuration.init(inst, def);
3337
- ZodStringFormat.init(inst, def);
3338
- });
3339
- function duration(params) {
3340
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3341
- }
3342
- //#endregion
3343
4406
  //#region ../../../node_modules/zod/v4/classic/errors.js
4407
+ var _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
4408
+ function _lazyMethod(proto, key, make) {
4409
+ Object.defineProperty(proto, key, {
4410
+ configurable: true,
4411
+ enumerable: false,
4412
+ get() {
4413
+ const value = make(this);
4414
+ Object.defineProperty(this, key, {
4415
+ value,
4416
+ configurable: true,
4417
+ writable: true
4418
+ });
4419
+ return value;
4420
+ },
4421
+ set(value) {
4422
+ Object.defineProperty(this, key, {
4423
+ value,
4424
+ configurable: true,
4425
+ writable: true
4426
+ });
4427
+ }
4428
+ });
4429
+ }
3344
4430
  var initializer = (inst, issues) => {
3345
4431
  $ZodError.init(inst, issues);
3346
4432
  inst.name = "ZodError";
3347
- Object.defineProperties(inst, {
3348
- format: { value: (mapper) => formatError(inst, mapper) },
3349
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3350
- addIssue: { value: (issue) => {
3351
- inst.issues.push(issue);
3352
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3353
- } },
3354
- addIssues: { value: (issues) => {
3355
- inst.issues.push(...issues);
3356
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3357
- } },
3358
- isEmpty: { get() {
3359
- return inst.issues.length === 0;
3360
- } }
4433
+ const proto = Object.getPrototypeOf(inst);
4434
+ if (_installedErrorProtos.has(proto)) return;
4435
+ _installedErrorProtos.add(proto);
4436
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
4437
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
4438
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
4439
+ self.issues.push(issue);
4440
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4441
+ });
4442
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
4443
+ self.issues.push(...issues);
4444
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4445
+ });
4446
+ Object.defineProperty(proto, "isEmpty", {
4447
+ configurable: true,
4448
+ enumerable: false,
4449
+ get() {
4450
+ return this.issues.length === 0;
4451
+ }
3361
4452
  });
3362
4453
  };
3363
- var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4454
+ var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
3364
4455
  //#endregion
3365
4456
  //#region ../../../node_modules/zod/v4/classic/parse.js
3366
4457
  var parse = /* @__PURE__ */ _parse(ZodRealError);
@@ -3377,254 +4468,319 @@ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3377
4468
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3378
4469
  //#endregion
3379
4470
  //#region ../../../node_modules/zod/v4/classic/schemas.js
3380
- var _installedGroups = /* @__PURE__ */ new WeakMap();
3381
- function _installLazyMethods(inst, group, methods) {
3382
- const proto = Object.getPrototypeOf(inst);
3383
- let installed = _installedGroups.get(proto);
3384
- if (!installed) {
3385
- installed = /* @__PURE__ */ new Set();
3386
- _installedGroups.set(proto, installed);
3387
- }
3388
- if (installed.has(group)) return;
3389
- installed.add(group);
3390
- for (const key in methods) {
3391
- const fn = methods[key];
3392
- Object.defineProperty(proto, key, {
3393
- configurable: true,
3394
- enumerable: false,
3395
- get() {
3396
- const bound = fn.bind(this);
3397
- Object.defineProperty(this, key, {
3398
- configurable: true,
3399
- writable: true,
3400
- enumerable: true,
3401
- value: bound
3402
- });
3403
- return bound;
3404
- },
3405
- set(v) {
3406
- Object.defineProperty(this, key, {
3407
- configurable: true,
3408
- writable: true,
3409
- enumerable: true,
3410
- value: v
3411
- });
3412
- }
3413
- });
3414
- }
4471
+ function _ensureDefaultLocale() {
4472
+ if (!globalConfig.localeError) config(en_default());
4473
+ }
4474
+ function _ensureDefaultMemoizer() {
4475
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
3415
4476
  }
3416
4477
  var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4478
+ _ensureDefaultLocale();
3417
4479
  $ZodType.init(inst, def);
3418
- Object.assign(inst["~standard"], { jsonSchema: {
3419
- input: createStandardJSONSchemaMethod(inst, "input"),
3420
- output: createStandardJSONSchemaMethod(inst, "output")
3421
- } });
3422
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3423
4480
  inst.def = def;
3424
4481
  inst.type = def.type;
3425
- Object.defineProperty(inst, "_def", { value: def });
3426
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3427
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3428
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3429
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3430
- inst.spa = inst.safeParseAsync;
3431
- inst.encode = (data, params) => encode(inst, data, params);
3432
- inst.decode = (data, params) => decode(inst, data, params);
3433
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3434
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3435
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3436
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3437
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3438
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3439
- _installLazyMethods(inst, "ZodType", {
3440
- check(...chks) {
3441
- const def = this.def;
3442
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3443
- check: ch,
3444
- def: { check: "custom" },
3445
- onattach: []
3446
- } } : ch)] }), { parent: true });
3447
- },
3448
- with(...chks) {
3449
- return this.check(...chks);
3450
- },
3451
- clone(def, params) {
3452
- return clone(this, def, params);
3453
- },
3454
- brand() {
3455
- return this;
3456
- },
3457
- register(reg, meta) {
3458
- reg.add(this, meta);
3459
- return this;
3460
- },
3461
- refine(check, params) {
3462
- return this.check(refine(check, params));
3463
- },
3464
- superRefine(refinement, params) {
3465
- return this.check(superRefine(refinement, params));
3466
- },
3467
- overwrite(fn) {
3468
- return this.check(/* @__PURE__ */ _overwrite(fn));
3469
- },
3470
- optional() {
3471
- return optional(this);
3472
- },
3473
- exactOptional() {
3474
- return exactOptional(this);
3475
- },
3476
- nullable() {
3477
- return nullable(this);
3478
- },
3479
- nullish() {
3480
- return optional(nullable(this));
3481
- },
3482
- nonoptional(params) {
3483
- return nonoptional(this, params);
3484
- },
3485
- array() {
3486
- return array(this);
3487
- },
3488
- or(arg) {
3489
- return union([this, arg]);
3490
- },
3491
- and(arg) {
3492
- return intersection(this, arg);
3493
- },
3494
- transform(tx) {
3495
- return pipe(this, transform(tx));
3496
- },
3497
- default(d) {
3498
- return _default(this, d);
3499
- },
3500
- prefault(d) {
3501
- return prefault(this, d);
3502
- },
3503
- catch(params) {
3504
- return _catch(this, params);
3505
- },
3506
- pipe(target) {
3507
- return pipe(this, target);
3508
- },
3509
- readonly() {
3510
- return readonly(this);
3511
- },
3512
- describe(description) {
3513
- const cl = this.clone();
3514
- globalRegistry.add(cl, { description });
3515
- return cl;
3516
- },
3517
- meta(...args) {
3518
- if (args.length === 0) return globalRegistry.get(this);
3519
- const cl = this.clone();
3520
- globalRegistry.add(cl, args[0]);
3521
- return cl;
3522
- },
3523
- isOptional() {
3524
- return this.safeParse(void 0).success;
3525
- },
3526
- isNullable() {
3527
- return this.safeParse(null).success;
3528
- },
3529
- apply(fn) {
3530
- return fn(this);
3531
- }
3532
- });
3533
- Object.defineProperty(inst, "description", {
3534
- get() {
3535
- return globalRegistry.get(inst)?.description;
3536
- },
3537
- configurable: true
3538
- });
3539
4482
  return inst;
4483
+ }, {
4484
+ check(...chks) {
4485
+ const def = this.def;
4486
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4487
+ check: ch,
4488
+ def: { check: "custom" },
4489
+ onattach: []
4490
+ } } : ch)] }), { parent: true });
4491
+ },
4492
+ with(...chks) {
4493
+ return this.check(...chks);
4494
+ },
4495
+ clone(def, params) {
4496
+ return clone(this, def, params);
4497
+ },
4498
+ brand() {
4499
+ return this;
4500
+ },
4501
+ register(reg, meta) {
4502
+ reg.add(this, meta);
4503
+ return this;
4504
+ },
4505
+ refine(check, params) {
4506
+ return this.check(refine(check, params));
4507
+ },
4508
+ superRefine(refinement, params) {
4509
+ return this.check(superRefine(refinement, params));
4510
+ },
4511
+ overwrite(fn) {
4512
+ return this.check(/* @__PURE__ */ _overwrite(fn));
4513
+ },
4514
+ optional() {
4515
+ return optional(this);
4516
+ },
4517
+ exactOptional() {
4518
+ return exactOptional(this);
4519
+ },
4520
+ nullable() {
4521
+ return nullable(this);
4522
+ },
4523
+ nullish() {
4524
+ return optional(nullable(this));
4525
+ },
4526
+ nonoptional(params) {
4527
+ return nonoptional(this, params);
4528
+ },
4529
+ array() {
4530
+ return array(this);
4531
+ },
4532
+ or(arg) {
4533
+ return union([this, arg]);
4534
+ },
4535
+ and(arg) {
4536
+ return intersection(this, arg);
4537
+ },
4538
+ transform(tx) {
4539
+ return pipe(this, transform(tx));
4540
+ },
4541
+ default(d) {
4542
+ return _default(this, d);
4543
+ },
4544
+ prefault(d) {
4545
+ return prefault(this, d);
4546
+ },
4547
+ catch(params) {
4548
+ return _catch(this, params);
4549
+ },
4550
+ pipe(target) {
4551
+ return pipe(this, target);
4552
+ },
4553
+ readonly() {
4554
+ return readonly(this);
4555
+ },
4556
+ describe(description) {
4557
+ const cl = this.clone();
4558
+ globalRegistry.add(cl, { description });
4559
+ return cl;
4560
+ },
4561
+ meta(...args) {
4562
+ if (args.length === 0) return globalRegistry.get(this);
4563
+ const cl = this.clone();
4564
+ globalRegistry.add(cl, args[0]);
4565
+ return cl;
4566
+ },
4567
+ isOptional() {
4568
+ return this.safeParse(void 0).success;
4569
+ },
4570
+ isNullable() {
4571
+ return this.safeParse(null).success;
4572
+ },
4573
+ apply(fn, ...args) {
4574
+ return args.length === 0 ? fn(this) : fn(this, ...args);
4575
+ },
4576
+ get "~standard"() {
4577
+ return hide(this, "~standard", {
4578
+ ...standardProps(this),
4579
+ jsonSchema: {
4580
+ input: createStandardJSONSchemaMethod(this, "input"),
4581
+ output: createStandardJSONSchemaMethod(this, "output")
4582
+ }
4583
+ });
4584
+ },
4585
+ set "~standard"(value) {
4586
+ own(this, "~standard", value);
4587
+ },
4588
+ parse: function _parse(data, params) {
4589
+ return parse(this, data, params, { callee: _parse });
4590
+ },
4591
+ parseAsync: async function _parseAsync(data, params) {
4592
+ return await parseAsync(this, data, params, { callee: _parseAsync });
4593
+ },
4594
+ safeParse(data, params) {
4595
+ return safeParse(this, data, params);
4596
+ },
4597
+ async safeParseAsync(data, params) {
4598
+ return safeParseAsync(this, data, params);
4599
+ },
4600
+ get spa() {
4601
+ return this?.safeParseAsync;
4602
+ },
4603
+ set spa(value) {
4604
+ own(this, "spa", value);
4605
+ },
4606
+ validate(data, params) {
4607
+ return validate(this, data, params);
4608
+ },
4609
+ validateAsync(data, params) {
4610
+ return validateAsync$1(this, data, params);
4611
+ },
4612
+ encode: function _encode(data, params) {
4613
+ return encode(this, data, params, { callee: _encode });
4614
+ },
4615
+ decode: function _decode(data, params) {
4616
+ return decode(this, data, params, { callee: _decode });
4617
+ },
4618
+ encodeAsync: async function _encodeAsync(data, params) {
4619
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
4620
+ },
4621
+ decodeAsync: async function _decodeAsync(data, params) {
4622
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
4623
+ },
4624
+ safeEncode(data, params) {
4625
+ return safeEncode(this, data, params);
4626
+ },
4627
+ safeDecode(data, params) {
4628
+ return safeDecode(this, data, params);
4629
+ },
4630
+ async safeEncodeAsync(data, params) {
4631
+ return safeEncodeAsync(this, data, params);
4632
+ },
4633
+ async safeDecodeAsync(data, params) {
4634
+ return safeDecodeAsync(this, data, params);
4635
+ },
4636
+ toJSONSchema(params) {
4637
+ return createToJSONSchemaMethod(this, {})(params);
4638
+ },
4639
+ get description() {
4640
+ return globalRegistry.get(this)?.description;
4641
+ },
4642
+ get _def() {
4643
+ return this._zod.def;
4644
+ }
3540
4645
  });
3541
4646
  /** @internal */
3542
4647
  var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3543
4648
  $ZodString.init(inst, def);
3544
4649
  ZodType.init(inst, def);
3545
4650
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3546
- const bag = inst._zod.bag;
3547
- inst.format = bag.format ?? null;
3548
- inst.minLength = bag.minimum ?? null;
3549
- inst.maxLength = bag.maximum ?? null;
3550
- _installLazyMethods(inst, "_ZodString", {
3551
- regex(...args) {
3552
- return this.check(/* @__PURE__ */ _regex(...args));
3553
- },
3554
- includes(...args) {
3555
- return this.check(/* @__PURE__ */ _includes(...args));
3556
- },
3557
- startsWith(...args) {
3558
- return this.check(/* @__PURE__ */ _startsWith(...args));
3559
- },
3560
- endsWith(...args) {
3561
- return this.check(/* @__PURE__ */ _endsWith(...args));
3562
- },
3563
- min(...args) {
3564
- return this.check(/* @__PURE__ */ _minLength(...args));
3565
- },
3566
- max(...args) {
3567
- return this.check(/* @__PURE__ */ _maxLength(...args));
3568
- },
3569
- length(...args) {
3570
- return this.check(/* @__PURE__ */ _length(...args));
3571
- },
3572
- nonempty(...args) {
3573
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3574
- },
3575
- lowercase(params) {
3576
- return this.check(/* @__PURE__ */ _lowercase(params));
3577
- },
3578
- uppercase(params) {
3579
- return this.check(/* @__PURE__ */ _uppercase(params));
3580
- },
3581
- trim() {
3582
- return this.check(/* @__PURE__ */ _trim());
3583
- },
3584
- normalize(...args) {
3585
- return this.check(/* @__PURE__ */ _normalize(...args));
3586
- },
3587
- toLowerCase() {
3588
- return this.check(/* @__PURE__ */ _toLowerCase());
3589
- },
3590
- toUpperCase() {
3591
- return this.check(/* @__PURE__ */ _toUpperCase());
3592
- },
3593
- slugify() {
3594
- return this.check(/* @__PURE__ */ _slugify());
3595
- }
3596
- });
3597
- });
4651
+ }, /*@__PURE__*/ derived({
4652
+ format: (inst) => aggregateChecks(inst).format ?? null,
4653
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
4654
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
4655
+ }, {
4656
+ regex(...args) {
4657
+ return this.check(/* @__PURE__ */ _regex(...args));
4658
+ },
4659
+ includes(...args) {
4660
+ return this.check(/* @__PURE__ */ _includes(...args));
4661
+ },
4662
+ startsWith(...args) {
4663
+ return this.check(/* @__PURE__ */ _startsWith(...args));
4664
+ },
4665
+ endsWith(...args) {
4666
+ return this.check(/* @__PURE__ */ _endsWith(...args));
4667
+ },
4668
+ min(...args) {
4669
+ return this.check(/* @__PURE__ */ _minLength(...args));
4670
+ },
4671
+ max(...args) {
4672
+ return this.check(/* @__PURE__ */ _maxLength(...args));
4673
+ },
4674
+ length(...args) {
4675
+ return this.check(/* @__PURE__ */ _length(...args));
4676
+ },
4677
+ nonempty(...args) {
4678
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
4679
+ },
4680
+ lowercase(params) {
4681
+ return this.check(/* @__PURE__ */ _lowercase(params));
4682
+ },
4683
+ uppercase(params) {
4684
+ return this.check(/* @__PURE__ */ _uppercase(params));
4685
+ },
4686
+ trim() {
4687
+ return this.check(/* @__PURE__ */ _trim());
4688
+ },
4689
+ normalize(...args) {
4690
+ return this.check(/* @__PURE__ */ _normalize(...args));
4691
+ },
4692
+ toLowerCase() {
4693
+ return this.check(/* @__PURE__ */ _toLowerCase());
4694
+ },
4695
+ toUpperCase() {
4696
+ return this.check(/* @__PURE__ */ _toUpperCase());
4697
+ },
4698
+ slugify() {
4699
+ return this.check(/* @__PURE__ */ _slugify());
4700
+ }
4701
+ }));
3598
4702
  var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3599
4703
  $ZodString.init(inst, def);
3600
4704
  _ZodString.init(inst, def);
3601
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3602
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3603
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3604
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3605
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3606
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3607
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3608
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3609
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3610
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3611
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3612
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3613
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3614
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3615
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3616
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3617
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3618
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3619
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3620
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3621
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3622
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3623
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3624
- inst.datetime = (params) => inst.check(datetime(params));
3625
- inst.date = (params) => inst.check(date(params));
3626
- inst.time = (params) => inst.check(time(params));
3627
- inst.duration = (params) => inst.check(duration(params));
4705
+ }, {
4706
+ email(params) {
4707
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
4708
+ },
4709
+ url(params) {
4710
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
4711
+ },
4712
+ jwt(params) {
4713
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4714
+ },
4715
+ emoji(params) {
4716
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4717
+ },
4718
+ guid(params) {
4719
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
4720
+ },
4721
+ uuid(params) {
4722
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4723
+ },
4724
+ uuidv4(params) {
4725
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4726
+ },
4727
+ uuidv6(params) {
4728
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4729
+ },
4730
+ uuidv7(params) {
4731
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4732
+ },
4733
+ nanoid(params) {
4734
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4735
+ },
4736
+ cuid(params) {
4737
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4738
+ },
4739
+ cuid2(params) {
4740
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4741
+ },
4742
+ ulid(params) {
4743
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
4744
+ },
4745
+ base64(params) {
4746
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
4747
+ },
4748
+ base64url(params) {
4749
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4750
+ },
4751
+ xid(params) {
4752
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
4753
+ },
4754
+ ksuid(params) {
4755
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4756
+ },
4757
+ ipv4(params) {
4758
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4759
+ },
4760
+ ipv6(params) {
4761
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4762
+ },
4763
+ cidrv4(params) {
4764
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4765
+ },
4766
+ cidrv6(params) {
4767
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4768
+ },
4769
+ e164(params) {
4770
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
4771
+ },
4772
+ datetime(params) {
4773
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
4774
+ },
4775
+ date(params) {
4776
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
4777
+ },
4778
+ time(params) {
4779
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
4780
+ },
4781
+ duration(params) {
4782
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
4783
+ }
3628
4784
  });
3629
4785
  function string(params) {
3630
4786
  return /* @__PURE__ */ _string(ZodString, params);
@@ -3633,6 +4789,22 @@ var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def)
3633
4789
  $ZodStringFormat.init(inst, def);
3634
4790
  _ZodString.init(inst, def);
3635
4791
  });
4792
+ var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4793
+ $ZodISODateTime.init(inst, def);
4794
+ ZodStringFormat.init(inst, def);
4795
+ });
4796
+ var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4797
+ $ZodISODate.init(inst, def);
4798
+ ZodStringFormat.init(inst, def);
4799
+ });
4800
+ var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4801
+ $ZodISOTime.init(inst, def);
4802
+ ZodStringFormat.init(inst, def);
4803
+ });
4804
+ var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4805
+ $ZodISODuration.init(inst, def);
4806
+ ZodStringFormat.init(inst, def);
4807
+ });
3636
4808
  var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3637
4809
  $ZodEmail.init(inst, def);
3638
4810
  ZodStringFormat.init(inst, def);
@@ -3718,60 +4890,68 @@ var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
3718
4890
  $ZodNumber.init(inst, def);
3719
4891
  ZodType.init(inst, def);
3720
4892
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3721
- _installLazyMethods(inst, "ZodNumber", {
3722
- gt(value, params) {
3723
- return this.check(/* @__PURE__ */ _gt(value, params));
3724
- },
3725
- gte(value, params) {
3726
- return this.check(/* @__PURE__ */ _gte(value, params));
3727
- },
3728
- min(value, params) {
3729
- return this.check(/* @__PURE__ */ _gte(value, params));
3730
- },
3731
- lt(value, params) {
3732
- return this.check(/* @__PURE__ */ _lt(value, params));
3733
- },
3734
- lte(value, params) {
3735
- return this.check(/* @__PURE__ */ _lte(value, params));
3736
- },
3737
- max(value, params) {
3738
- return this.check(/* @__PURE__ */ _lte(value, params));
3739
- },
3740
- int(params) {
3741
- return this.check(int(params));
3742
- },
3743
- safe(params) {
3744
- return this.check(int(params));
3745
- },
3746
- positive(params) {
3747
- return this.check(/* @__PURE__ */ _gt(0, params));
3748
- },
3749
- nonnegative(params) {
3750
- return this.check(/* @__PURE__ */ _gte(0, params));
3751
- },
3752
- negative(params) {
3753
- return this.check(/* @__PURE__ */ _lt(0, params));
3754
- },
3755
- nonpositive(params) {
3756
- return this.check(/* @__PURE__ */ _lte(0, params));
3757
- },
3758
- multipleOf(value, params) {
3759
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3760
- },
3761
- step(value, params) {
3762
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3763
- },
3764
- finite() {
3765
- return this;
3766
- }
3767
- });
3768
- const bag = inst._zod.bag;
3769
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3770
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3771
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3772
4893
  inst.isFinite = true;
3773
- inst.format = bag.format ?? null;
3774
- });
4894
+ }, /*@__PURE__*/ derived({
4895
+ minValue: (inst) => {
4896
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
4897
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
4898
+ },
4899
+ maxValue: (inst) => {
4900
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
4901
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
4902
+ },
4903
+ isInt: (inst) => {
4904
+ const { isInt, multipleOf } = aggregateChecks(inst);
4905
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
4906
+ },
4907
+ format: (inst) => aggregateChecks(inst).format ?? null
4908
+ }, {
4909
+ gt(value, params) {
4910
+ return this.check(/* @__PURE__ */ _gt(value, params));
4911
+ },
4912
+ gte(value, params) {
4913
+ return this.check(/* @__PURE__ */ _gte(value, params));
4914
+ },
4915
+ min(value, params) {
4916
+ return this.check(/* @__PURE__ */ _gte(value, params));
4917
+ },
4918
+ lt(value, params) {
4919
+ return this.check(/* @__PURE__ */ _lt(value, params));
4920
+ },
4921
+ lte(value, params) {
4922
+ return this.check(/* @__PURE__ */ _lte(value, params));
4923
+ },
4924
+ max(value, params) {
4925
+ return this.check(/* @__PURE__ */ _lte(value, params));
4926
+ },
4927
+ int(params) {
4928
+ return this.check(int(params));
4929
+ },
4930
+ safe(params) {
4931
+ return this.check(int(params));
4932
+ },
4933
+ positive(params) {
4934
+ return this.check(/* @__PURE__ */ _gt(0, params));
4935
+ },
4936
+ nonnegative(params) {
4937
+ return this.check(/* @__PURE__ */ _gte(0, params));
4938
+ },
4939
+ negative(params) {
4940
+ return this.check(/* @__PURE__ */ _lt(0, params));
4941
+ },
4942
+ nonpositive(params) {
4943
+ return this.check(/* @__PURE__ */ _lte(0, params));
4944
+ },
4945
+ multipleOf(value, params) {
4946
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4947
+ },
4948
+ step(value, params) {
4949
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4950
+ },
4951
+ finite() {
4952
+ return this;
4953
+ }
4954
+ }));
3775
4955
  function number(params) {
3776
4956
  return /* @__PURE__ */ _number(ZodNumber, params);
3777
4957
  }
@@ -3807,94 +4987,80 @@ function never(params) {
3807
4987
  return /* @__PURE__ */ _never(ZodNever, params);
3808
4988
  }
3809
4989
  var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4990
+ _ensureDefaultMemoizer();
3810
4991
  $ZodArray.init(inst, def);
3811
4992
  ZodType.init(inst, def);
3812
4993
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3813
4994
  inst.element = def.element;
3814
- _installLazyMethods(inst, "ZodArray", {
3815
- min(n, params) {
3816
- return this.check(/* @__PURE__ */ _minLength(n, params));
3817
- },
3818
- nonempty(params) {
3819
- return this.check(/* @__PURE__ */ _minLength(1, params));
3820
- },
3821
- max(n, params) {
3822
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3823
- },
3824
- length(n, params) {
3825
- return this.check(/* @__PURE__ */ _length(n, params));
3826
- },
3827
- unwrap() {
3828
- return this.element;
3829
- }
3830
- });
4995
+ }, {
4996
+ min(n, params) {
4997
+ return this.check(/* @__PURE__ */ _minLength(n, params));
4998
+ },
4999
+ nonempty(params) {
5000
+ return this.check(/* @__PURE__ */ _minLength(1, params));
5001
+ },
5002
+ max(n, params) {
5003
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
5004
+ },
5005
+ length(n, params) {
5006
+ return this.check(/* @__PURE__ */ _length(n, params));
5007
+ },
5008
+ unwrap() {
5009
+ return this.element;
5010
+ }
3831
5011
  });
3832
5012
  function array(element, params) {
3833
5013
  return /* @__PURE__ */ _array(ZodArray, element, params);
3834
5014
  }
3835
5015
  var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
5016
+ _ensureDefaultMemoizer();
3836
5017
  $ZodObjectJIT.init(inst, def);
3837
5018
  ZodType.init(inst, def);
3838
5019
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3839
- defineLazy(inst, "shape", () => {
3840
- return def.shape;
3841
- });
3842
- _installLazyMethods(inst, "ZodObject", {
3843
- keyof() {
3844
- return _enum(Object.keys(this._zod.def.shape));
3845
- },
3846
- catchall(catchall) {
3847
- return this.clone({
3848
- ...this._zod.def,
3849
- catchall
3850
- });
3851
- },
3852
- passthrough() {
3853
- return this.clone({
3854
- ...this._zod.def,
3855
- catchall: unknown()
3856
- });
3857
- },
3858
- loose() {
3859
- return this.clone({
3860
- ...this._zod.def,
3861
- catchall: unknown()
3862
- });
3863
- },
3864
- strict() {
3865
- return this.clone({
3866
- ...this._zod.def,
3867
- catchall: never()
3868
- });
3869
- },
3870
- strip() {
3871
- return this.clone({
3872
- ...this._zod.def,
3873
- catchall: void 0
3874
- });
3875
- },
3876
- extend(incoming) {
3877
- return extend(this, incoming);
3878
- },
3879
- safeExtend(incoming) {
3880
- return safeExtend(this, incoming);
3881
- },
3882
- merge(other) {
3883
- return merge(this, other);
3884
- },
3885
- pick(mask) {
3886
- return pick(this, mask);
3887
- },
3888
- omit(mask) {
3889
- return omit(this, mask);
3890
- },
3891
- partial(...args) {
3892
- return partial(ZodOptional, this, args[0]);
3893
- },
3894
- required(...args) {
3895
- return required(ZodNonOptional, this, args[0]);
3896
- }
3897
- });
5020
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
5021
+ }, {
5022
+ keyof() {
5023
+ return _enum(Object.keys(this._zod.def.shape));
5024
+ },
5025
+ catchall(catchall) {
5026
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
5027
+ },
5028
+ passthrough() {
5029
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
5030
+ },
5031
+ loose() {
5032
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
5033
+ },
5034
+ strict() {
5035
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
5036
+ },
5037
+ strip() {
5038
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
5039
+ },
5040
+ extend(incoming) {
5041
+ return extend(this, incoming);
5042
+ },
5043
+ safeExtend(incoming) {
5044
+ return safeExtend(this, incoming);
5045
+ },
5046
+ merge(other) {
5047
+ return merge(this, other);
5048
+ },
5049
+ pick(mask) {
5050
+ return pick(this, mask);
5051
+ },
5052
+ omit(mask) {
5053
+ return omit(this, mask);
5054
+ },
5055
+ partial(...args) {
5056
+ return partial(ZodOptional, this, args[0]);
5057
+ },
5058
+ exactPartial(...args) {
5059
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
5060
+ },
5061
+ required(...args) {
5062
+ return required(ZodNonOptional, this, args[0]);
5063
+ }
3898
5064
  });
3899
5065
  function object(shape, params) {
3900
5066
  return new ZodObject({
@@ -3945,7 +5111,7 @@ var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3945
5111
  ZodType.init(inst, def);
3946
5112
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3947
5113
  inst.enum = def.entries;
3948
- inst.options = Object.values(def.entries);
5114
+ inst.options = [...inst._zod.values];
3949
5115
  const keys = new Set(Object.keys(def.entries));
3950
5116
  inst.extract = (values, params) => {
3951
5117
  const newEntries = {};
@@ -3995,6 +5161,7 @@ function literal(value, params) {
3995
5161
  });
3996
5162
  }
3997
5163
  var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
5164
+ _ensureDefaultMemoizer();
3998
5165
  $ZodTransform.init(inst, def);
3999
5166
  ZodType.init(inst, def);
4000
5167
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -4006,7 +5173,7 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4006
5173
  const _issue = issue$1;
4007
5174
  if (_issue.fatal) _issue.continue = false;
4008
5175
  _issue.code ?? (_issue.code = "custom");
4009
- _issue.input ?? (_issue.input = payload.value);
5176
+ if (!("input" in _issue)) _issue.input = payload.value;
4010
5177
  _issue.inst ?? (_issue.inst = inst);
4011
5178
  payload.issues.push(issue(_issue));
4012
5179
  }
@@ -4014,11 +5181,9 @@ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4014
5181
  const output = def.transform(payload.value, payload);
4015
5182
  if (output instanceof Promise) return output.then((output) => {
4016
5183
  payload.value = output;
4017
- payload.fallback = true;
4018
5184
  return payload;
4019
5185
  });
4020
5186
  payload.value = output;
4021
- payload.fallback = true;
4022
5187
  return payload;
4023
5188
  };
4024
5189
  });
@@ -4119,7 +5284,7 @@ function _catch(innerType, catchValue) {
4119
5284
  return new ZodCatch({
4120
5285
  type: "catch",
4121
5286
  innerType,
4122
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
5287
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
4123
5288
  });
4124
5289
  }
4125
5290
  var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {