@ayepi/files 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,82 +1,33 @@
1
- import { createHmac, timingSafeEqual } from "node:crypto";
1
+ import { createHash, createHmac, timingSafeEqual } from "node:crypto";
2
2
  import { endpoint, implement, reject, spec } from "@ayepi/core";
3
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
4
- var _a$1;
5
- function $constructor(name, initializer, params) {
6
- function init(inst, def) {
7
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
8
- value: {
9
- def,
10
- constr: _,
11
- traits: /* @__PURE__ */ new Set()
12
- },
13
- enumerable: false
14
- });
15
- if (inst._zod.traits.has(name)) return;
16
- inst._zod.traits.add(name);
17
- initializer(inst, def);
18
- const proto = _.prototype;
19
- const keys = Object.keys(proto);
20
- for (let i = 0; i < keys.length; i++) {
21
- const k = keys[i];
22
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
23
- }
24
- }
25
- const Parent = params?.Parent ?? Object;
26
- class Definition extends Parent {}
27
- Object.defineProperty(Definition, "name", { value: name });
28
- function _(def) {
29
- var _a;
30
- const inst = params?.Parent ? new Definition() : this;
31
- init(inst, def);
32
- (_a = inst._zod).deferred ?? (_a.deferred = []);
33
- for (const fn of inst._zod.deferred) fn();
34
- return inst;
35
- }
36
- Object.defineProperty(_, "init", { value: init });
37
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
38
- if (params?.Parent && inst instanceof params.Parent) return true;
39
- return inst?._zod?.traits?.has(name);
40
- } });
41
- Object.defineProperty(_, "name", { value: name });
42
- return _;
43
- }
44
- var $ZodAsyncError = class extends Error {
45
- constructor() {
46
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
47
- }
48
- };
49
- var $ZodEncodeError = class extends Error {
50
- constructor(name) {
51
- super(`Encountered unidirectional transform during encode: ${name}`);
52
- this.name = "ZodEncodeError";
53
- }
54
- };
55
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
56
- const globalConfig = globalThis.__zod_globalConfig;
57
- function config(newConfig) {
58
- if (newConfig) Object.assign(globalConfig, newConfig);
59
- return globalConfig;
60
- }
61
- //#endregion
62
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
3
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
63
4
  function getEnumValues(entries) {
64
5
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
65
6
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
66
7
  }
8
+ function joinValues(array, separator = "|") {
9
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
10
+ }
67
11
  function jsonStringifyReplacer(_, value) {
68
12
  if (typeof value === "bigint") return value.toString();
69
13
  return value;
70
14
  }
71
- function cached(getter) {
72
- return { get value() {
73
- {
74
- const value = getter();
75
- Object.defineProperty(this, "value", { value });
76
- return value;
15
+ var Cached = class {
16
+ constructor(getter) {
17
+ this._getter = getter;
18
+ this._value = void 0;
19
+ }
20
+ get value() {
21
+ const getter = this._getter;
22
+ if (getter !== void 0) {
23
+ this._value = getter();
24
+ this._getter = void 0;
77
25
  }
78
- throw new Error("cached value already set");
79
- } };
26
+ return this._value;
27
+ }
28
+ };
29
+ function cached(getter) {
30
+ return new Cached(getter);
80
31
  }
81
32
  function nullish(input) {
82
33
  return input === null || input === void 0;
@@ -89,28 +40,10 @@ function cleanRegex(source) {
89
40
  function floatSafeRemainder(val, step) {
90
41
  const ratio = val / step;
91
42
  const roundedRatio = Math.round(ratio);
92
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
43
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
93
44
  if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
94
45
  return ratio - roundedRatio;
95
46
  }
96
- const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
97
- function defineLazy(object, key, getter) {
98
- let value = void 0;
99
- Object.defineProperty(object, key, {
100
- get() {
101
- if (value === EVALUATING) return;
102
- if (value === void 0) {
103
- value = EVALUATING;
104
- value = getter();
105
- }
106
- return value;
107
- },
108
- set(v) {
109
- Object.defineProperty(object, key, { value: v });
110
- },
111
- configurable: true
112
- });
113
- }
114
47
  function assignProp(target, prop, value) {
115
48
  Object.defineProperty(target, prop, {
116
49
  value,
@@ -119,6 +52,58 @@ function assignProp(target, prop, value) {
119
52
  configurable: true
120
53
  });
121
54
  }
55
+ /**
56
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
57
+ *
58
+ * 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.
59
+ */
60
+ function rawShape(def) {
61
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
62
+ return desc?.get ? desc.get.raw : desc?.value;
63
+ }
64
+ function sourceShape(schema) {
65
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
66
+ }
67
+ function deferProp(target, key, getter) {
68
+ Object.defineProperty(target, key, {
69
+ get() {
70
+ const value = getter();
71
+ assignProp(this, key, value);
72
+ return value;
73
+ },
74
+ enumerable: true,
75
+ configurable: true
76
+ });
77
+ }
78
+ function putProp(target, key, value) {
79
+ if (key in target) assignProp(target, key, value);
80
+ else target[key] = value;
81
+ }
82
+ /**
83
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
84
+ *
85
+ * 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.
86
+ */
87
+ function mirrorShape(target, source, keys, wrap) {
88
+ const raw = sourceShape(source);
89
+ for (const key of keys) {
90
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
91
+ if (!desc.enumerable) continue;
92
+ if (desc.get) deferProp(target, key, () => {
93
+ const value = source._zod.def.shape[key];
94
+ return wrap ? wrap(value, key) : value;
95
+ });
96
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
97
+ }
98
+ }
99
+ function mirrorProps(target, source) {
100
+ for (const key of Reflect.ownKeys(source)) {
101
+ const desc = Object.getOwnPropertyDescriptor(source, key);
102
+ if (!desc.enumerable) continue;
103
+ if (desc.get) deferProp(target, key, () => source[key]);
104
+ else putProp(target, key, desc.value);
105
+ }
106
+ }
122
107
  function mergeDefs(...defs) {
123
108
  const mergedDescriptors = {};
124
109
  for (const def of defs) Object.assign(mergedDescriptors, Object.getOwnPropertyDescriptors(def));
@@ -189,51 +174,56 @@ function normalizeParams(_params) {
189
174
  };
190
175
  return params;
191
176
  }
177
+ function stringifyPrimitive(value) {
178
+ if (typeof value === "bigint") return value.toString() + "n";
179
+ if (typeof value === "string") return `"${value}"`;
180
+ return `${value}`;
181
+ }
192
182
  function optionalKeys(shape) {
193
183
  return Object.keys(shape).filter((k) => {
194
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
184
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
195
185
  });
196
186
  }
197
- const NUMBER_FORMAT_RANGES = {
187
+ const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
198
188
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
199
189
  int32: [-2147483648, 2147483647],
200
190
  uint32: [0, 4294967295],
201
191
  float32: [-34028234663852886e22, 34028234663852886e22],
202
192
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
193
+ }))();
194
+ const BIGINT_FORMAT_RANGES = {
195
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
196
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
203
197
  };
204
198
  function pick(schema, mask) {
205
199
  const currDef = schema._zod.def;
206
200
  const checks = currDef.checks;
207
201
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
208
- return clone(schema, mergeDefs(schema._zod.def, {
209
- get shape() {
210
- const newShape = {};
211
- for (const key in mask) {
212
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
213
- if (!mask[key]) continue;
214
- newShape[key] = currDef.shape[key];
215
- }
216
- assignProp(this, "shape", newShape);
217
- return newShape;
218
- },
202
+ const newShape = {};
203
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
204
+ return clone(schema, mergeDefs(currDef, {
205
+ shape: newShape,
219
206
  checks: []
220
207
  }));
221
208
  }
209
+ function maskedKeys(schema, mask) {
210
+ const raw = sourceShape(schema);
211
+ const keys = [];
212
+ for (const key of Reflect.ownKeys(mask)) {
213
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
214
+ if (mask[key]) keys.push(key);
215
+ }
216
+ return keys;
217
+ }
222
218
  function omit(schema, mask) {
223
219
  const currDef = schema._zod.def;
224
220
  const checks = currDef.checks;
225
221
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
226
- return clone(schema, mergeDefs(schema._zod.def, {
227
- get shape() {
228
- const newShape = { ...schema._zod.def.shape };
229
- for (const key in mask) {
230
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
231
- if (!mask[key]) continue;
232
- delete newShape[key];
233
- }
234
- assignProp(this, "shape", newShape);
235
- return newShape;
236
- },
222
+ const omitted = new Set(maskedKeys(schema, mask));
223
+ const newShape = {};
224
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
225
+ return clone(schema, mergeDefs(currDef, {
226
+ shape: newShape,
237
227
  checks: []
238
228
  }));
239
229
  }
@@ -241,90 +231,57 @@ function extend(schema, shape) {
241
231
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
242
232
  const checks = schema._zod.def.checks;
243
233
  if (checks && checks.length > 0) {
244
- const existingShape = schema._zod.def.shape;
245
- 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.");
234
+ const existingShape = sourceShape(schema);
235
+ 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.");
246
236
  }
247
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
248
- const _shape = {
249
- ...schema._zod.def.shape,
250
- ...shape
251
- };
252
- assignProp(this, "shape", _shape);
253
- return _shape;
254
- } }));
237
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
238
+ }
239
+ function extended(schema, shape) {
240
+ const newShape = {};
241
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
242
+ mirrorProps(newShape, shape);
243
+ return newShape;
255
244
  }
256
245
  function safeExtend(schema, shape) {
257
246
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
258
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
259
- const _shape = {
260
- ...schema._zod.def.shape,
261
- ...shape
262
- };
263
- assignProp(this, "shape", _shape);
264
- return _shape;
265
- } }));
247
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
266
248
  }
267
249
  function merge(a, b) {
250
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
268
251
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
252
+ const newShape = {};
253
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
254
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
269
255
  return clone(a, mergeDefs(a._zod.def, {
270
- get shape() {
271
- const _shape = {
272
- ...a._zod.def.shape,
273
- ...b._zod.def.shape
274
- };
275
- assignProp(this, "shape", _shape);
276
- return _shape;
277
- },
256
+ shape: newShape,
278
257
  get catchall() {
279
258
  return b._zod.def.catchall;
280
259
  },
281
260
  checks: b._zod.def.checks ?? []
282
261
  }));
283
262
  }
284
- function partial(Class, schema, mask) {
263
+ function partial(Class, schema, mask, name = "partial") {
285
264
  const checks = schema._zod.def.checks;
286
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
265
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
266
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
267
+ const newShape = {};
268
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
269
+ type: "optional",
270
+ innerType: value
271
+ })));
287
272
  return clone(schema, mergeDefs(schema._zod.def, {
288
- get shape() {
289
- const oldShape = schema._zod.def.shape;
290
- const shape = { ...oldShape };
291
- if (mask) for (const key in mask) {
292
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
293
- if (!mask[key]) continue;
294
- shape[key] = Class ? new Class({
295
- type: "optional",
296
- innerType: oldShape[key]
297
- }) : oldShape[key];
298
- }
299
- else for (const key in oldShape) shape[key] = Class ? new Class({
300
- type: "optional",
301
- innerType: oldShape[key]
302
- }) : oldShape[key];
303
- assignProp(this, "shape", shape);
304
- return shape;
305
- },
273
+ shape: newShape,
306
274
  checks: []
307
275
  }));
308
276
  }
309
277
  function required(Class, schema, mask) {
310
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
311
- const oldShape = schema._zod.def.shape;
312
- const shape = { ...oldShape };
313
- if (mask) for (const key in mask) {
314
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
315
- if (!mask[key]) continue;
316
- shape[key] = new Class({
317
- type: "nonoptional",
318
- innerType: oldShape[key]
319
- });
320
- }
321
- else for (const key in oldShape) shape[key] = new Class({
322
- type: "nonoptional",
323
- innerType: oldShape[key]
324
- });
325
- assignProp(this, "shape", shape);
326
- return shape;
327
- } }));
278
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
279
+ const newShape = {};
280
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
281
+ type: "nonoptional",
282
+ innerType: value
283
+ }));
284
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
328
285
  }
329
286
  function aborted(x, startIndex = 0) {
330
287
  if (x.aborted === true) return true;
@@ -347,19 +304,67 @@ function prefixIssues(path, issues) {
347
304
  function unwrapMessage(message) {
348
305
  return typeof message === "string" ? message : message?.message;
349
306
  }
307
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
308
+ function sizeCaps(defChecks) {
309
+ const caps = [];
310
+ for (const ch of defChecks ?? []) {
311
+ const d = ch._zod.def;
312
+ if (!/_(length|size)$|_equals$/.test(d.check)) break;
313
+ const max = d.maximum ?? d.length ?? d.size;
314
+ if (max >= 0) caps.push([max, ch]);
315
+ }
316
+ return caps;
317
+ }
318
+ function attachSchema(issues, start, inst) {
319
+ var _a;
320
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
321
+ }
350
322
  function finalizeIssue(iss, ctx, config) {
351
- 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";
352
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
353
- rest.path ?? (rest.path = []);
354
- rest.message = message;
355
- if (ctx?.reportInput) rest.input = _input;
356
- return rest;
323
+ var _a;
324
+ const traits = iss.inst?._zod?.traits;
325
+ if (traits?.has("$ZodType")) if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
326
+ else iss.schema = iss.inst;
327
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
328
+ 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";
329
+ const full = {};
330
+ for (const k of Object.keys(iss)) {
331
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
332
+ full[k] = iss[k];
333
+ }
334
+ full.path ?? (full.path = []);
335
+ full.message = message;
336
+ if (ctx?.reportInput) full.input = iss.input;
337
+ return full;
338
+ }
339
+ const highSurrogate = /[\uD800-\uDBFF]/;
340
+ function codePointLength(str) {
341
+ const units = str.length;
342
+ if (!highSurrogate.test(str)) return units;
343
+ let count = units;
344
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
345
+ count--;
346
+ i++;
347
+ }
348
+ return count;
357
349
  }
358
350
  function getLengthableOrigin(input) {
359
351
  if (Array.isArray(input)) return "array";
360
352
  if (typeof input === "string") return "string";
361
353
  return "unknown";
362
354
  }
355
+ function parsedType(data) {
356
+ const t = typeof data;
357
+ switch (t) {
358
+ case "number": return Number.isNaN(data) ? "nan" : "number";
359
+ case "object": {
360
+ if (data === null) return "null";
361
+ if (Array.isArray(data)) return "array";
362
+ const obj = data;
363
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
364
+ }
365
+ }
366
+ return t;
367
+ }
363
368
  function issue(...args) {
364
369
  const [iss, input, inst] = args;
365
370
  if (typeof iss === "string") return {
@@ -370,33 +375,337 @@ function issue(...args) {
370
375
  };
371
376
  return { ...iss };
372
377
  }
373
- //#endregion
374
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
375
- const initializer$1 = (inst, def) => {
376
- inst.name = "$ZodError";
377
- Object.defineProperty(inst, "_zod", {
378
- value: inst._zod,
379
- enumerable: false
378
+ /**
379
+ * 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.
380
+ *
381
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
382
+ */
383
+ function members(proto, table) {
384
+ for (const key in table) {
385
+ const desc = Object.getOwnPropertyDescriptor(table, key);
386
+ if (desc.get) Object.defineProperty(proto, key, {
387
+ ...desc,
388
+ enumerable: false
389
+ });
390
+ else defineBound(proto, key, desc.value);
391
+ }
392
+ }
393
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
394
+ function own(inst, key, value, enumerable = true) {
395
+ Object.defineProperty(inst, key, {
396
+ configurable: true,
397
+ writable: true,
398
+ enumerable,
399
+ value
380
400
  });
381
- Object.defineProperty(inst, "issues", {
382
- value: def,
383
- enumerable: false
401
+ return value;
402
+ }
403
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
404
+ function hide(inst, key, value) {
405
+ return own(inst, key, value, false);
406
+ }
407
+ /** 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. */
408
+ function derived(computes, table) {
409
+ for (const key in computes) {
410
+ const compute = computes[key];
411
+ Object.defineProperty(table, key, {
412
+ configurable: true,
413
+ enumerable: true,
414
+ get() {
415
+ return own(this, key, compute(this));
416
+ },
417
+ set(value) {
418
+ own(this, key, value);
419
+ }
420
+ });
421
+ }
422
+ return table;
423
+ }
424
+ function defineBound(proto, key, fn) {
425
+ Object.defineProperty(proto, key, {
426
+ configurable: true,
427
+ get() {
428
+ return this == null ? fn : own(this, key, fn.bind(this));
429
+ },
430
+ set(value) {
431
+ own(this, key, value);
432
+ }
384
433
  });
385
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
386
- Object.defineProperty(inst, "toString", {
387
- value: () => inst.message,
388
- enumerable: false
434
+ }
435
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
436
+ function claim(inst, sentinel) {
437
+ const proto = Object.getPrototypeOf(inst);
438
+ return sentinel in proto ? void 0 : proto;
439
+ }
440
+ let installing;
441
+ let broke = false;
442
+ const breaker = {
443
+ configurable: true,
444
+ get() {
445
+ broke = true;
446
+ }
447
+ };
448
+ /**
449
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
450
+ * constructor, computed from the internals object itself and cached there on
451
+ * first read. One accessor per constructor rather than one per instance.
452
+ */
453
+ function defineLazyInternal(inst, key, compute) {
454
+ const proto = Object.getPrototypeOf(inst._zod);
455
+ if (key in proto && installing !== inst._zod) {
456
+ installing = void 0;
457
+ return;
458
+ }
459
+ installing = inst._zod;
460
+ Object.defineProperty(proto, key, {
461
+ configurable: true,
462
+ get() {
463
+ Object.defineProperty(this, key, breaker);
464
+ const outer = broke;
465
+ broke = false;
466
+ try {
467
+ const value = compute(this);
468
+ if (broke) delete this[key];
469
+ else Object.defineProperty(this, key, {
470
+ configurable: true,
471
+ writable: true,
472
+ value
473
+ });
474
+ broke = broke || outer;
475
+ return value;
476
+ } catch (err) {
477
+ delete this[key];
478
+ broke = broke || outer;
479
+ throw err;
480
+ }
481
+ },
482
+ set(value) {
483
+ Object.defineProperty(this, key, {
484
+ configurable: true,
485
+ writable: true,
486
+ value
487
+ });
488
+ }
489
+ });
490
+ }
491
+ /**
492
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
493
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
494
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
495
+ */
496
+ function installLazyProp(inst, key, make, enumerable) {
497
+ const proto = claim(inst, key);
498
+ if (!proto) return;
499
+ Object.defineProperty(proto, key, {
500
+ configurable: true,
501
+ get() {
502
+ const desc = {
503
+ configurable: true,
504
+ writable: true,
505
+ enumerable,
506
+ value: void 0
507
+ };
508
+ Object.defineProperty(this, key, desc);
509
+ desc.value = make(this);
510
+ Object.defineProperty(this, key, desc);
511
+ return desc.value;
512
+ },
513
+ set(value) {
514
+ Object.defineProperty(this, key, {
515
+ configurable: true,
516
+ writable: true,
517
+ enumerable,
518
+ value
519
+ });
520
+ }
389
521
  });
522
+ }
523
+ /** 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. */
524
+ const CONSTANT_CATCH = "~constantCatch";
525
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
526
+ function constantCatch(value) {
527
+ const fn = () => value;
528
+ fn[CONSTANT_CATCH] = true;
529
+ return fn;
530
+ }
531
+ //#endregion
532
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
533
+ var _a$1;
534
+ const _zodDesc = {
535
+ value: void 0,
536
+ enumerable: false
537
+ };
538
+ let _E = "captureStackTrace" in Error ? Error : null;
539
+ function newError(Definition) {
540
+ const E = _E;
541
+ if (E) {
542
+ const saved = E.stackTraceLimit;
543
+ if (typeof saved === "number") {
544
+ try {
545
+ E.stackTraceLimit = 0;
546
+ } catch {
547
+ _E = null;
548
+ return new Definition();
549
+ }
550
+ try {
551
+ return new Definition();
552
+ } finally {
553
+ E.stackTraceLimit = saved;
554
+ }
555
+ }
556
+ }
557
+ return new Definition();
558
+ }
559
+ function $constructor(name, initializer, proto, params) {
560
+ const zodProto = {};
561
+ function Internals(def) {
562
+ this.def = def;
563
+ this.constr = _;
564
+ this.traits = /* @__PURE__ */ new Set();
565
+ }
566
+ Internals.prototype = zodProto;
567
+ const protoMembers = proto;
568
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
569
+ function init(inst, def) {
570
+ if (!inst._zod) {
571
+ _zodDesc.value = new Internals(def);
572
+ try {
573
+ Object.defineProperty(inst, "_zod", _zodDesc);
574
+ } finally {
575
+ _zodDesc.value = void 0;
576
+ }
577
+ } else if (inst._zod.traits.has(name)) return;
578
+ inst._zod.traits.add(name);
579
+ initializer(inst, def);
580
+ if (initialized) {
581
+ const own = Object.getPrototypeOf(inst);
582
+ const ctorProto = inst._zod.constr.prototype;
583
+ let up = own;
584
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
585
+ const target = up ?? own;
586
+ if (!initialized.has(target)) {
587
+ initialized.add(target);
588
+ members(target, protoMembers);
589
+ }
590
+ }
591
+ const proto = _.prototype;
592
+ for (const k in proto) {
593
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
594
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
595
+ }
596
+ }
597
+ const Parent = params?.Parent ?? Object;
598
+ class Definition extends Parent {}
599
+ Object.defineProperty(Definition, "name", { value: name });
600
+ function _(def) {
601
+ const inst = params?.Parent ? newError(Definition) : this;
602
+ init(inst, def);
603
+ const deferred = inst._zod.deferred;
604
+ if (deferred) {
605
+ for (const fn of deferred) fn();
606
+ inst._zod.deferred = void 0;
607
+ }
608
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
609
+ if (pp) pp(inst);
610
+ return inst;
611
+ }
612
+ Object.defineProperty(_, "init", { value: init });
613
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
614
+ if (params?.Parent && inst instanceof params.Parent) return true;
615
+ return inst?._zod?.traits?.has(name);
616
+ } });
617
+ Object.defineProperty(_, "name", { value: name });
618
+ return _;
619
+ }
620
+ var $ZodAsyncError = class extends Error {
621
+ constructor() {
622
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
623
+ }
624
+ };
625
+ var $ZodEncodeError = class extends Error {
626
+ constructor(name) {
627
+ super(`Encountered unidirectional transform during encode: ${name}`);
628
+ this.name = "ZodEncodeError";
629
+ }
630
+ };
631
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
632
+ const globalConfig = globalThis.__zod_globalConfig;
633
+ function config(newConfig) {
634
+ if (newConfig) Object.assign(globalConfig, newConfig);
635
+ return globalConfig;
636
+ }
637
+ //#endregion
638
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/errors.js
639
+ function _getMessage() {
640
+ const internals = this._zod;
641
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
642
+ return internals.message;
643
+ }
644
+ function _setMessage(value) {
645
+ this._zod.message = value;
646
+ }
647
+ const _messageDesc = {
648
+ get: _getMessage,
649
+ set: _setMessage,
650
+ enumerable: true,
651
+ configurable: true
652
+ };
653
+ const _issuesDesc = {
654
+ value: void 0,
655
+ enumerable: false
656
+ };
657
+ const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
658
+ const initializer$1 = (inst, def) => {
659
+ inst.name = "$ZodError";
660
+ _issuesDesc.value = def;
661
+ Object.defineProperty(inst, "issues", _issuesDesc);
662
+ _issuesDesc.value = void 0;
663
+ Object.defineProperty(inst, "message", _messageDesc);
664
+ const proto = Object.getPrototypeOf(inst);
665
+ if (!_installedToString.has(proto)) {
666
+ _installedToString.add(proto);
667
+ Object.defineProperty(proto, "toString", {
668
+ configurable: true,
669
+ enumerable: false,
670
+ get() {
671
+ const value = () => this.message;
672
+ Object.defineProperty(this, "toString", {
673
+ value,
674
+ configurable: true,
675
+ writable: true
676
+ });
677
+ return value;
678
+ },
679
+ set(value) {
680
+ Object.defineProperty(this, "toString", {
681
+ value,
682
+ configurable: true,
683
+ writable: true
684
+ });
685
+ }
686
+ });
687
+ }
390
688
  };
391
689
  const $ZodError = $constructor("$ZodError", initializer$1);
392
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
690
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
691
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
692
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
693
+ * "__proto__" would hit the setter instead of creating a key. */
694
+ function node(obj, key, make) {
695
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) if (key === "__proto__") Object.defineProperty(obj, key, {
696
+ value: make(),
697
+ writable: true,
698
+ enumerable: true,
699
+ configurable: true
700
+ });
701
+ else obj[key] = make();
702
+ return obj[key];
703
+ }
393
704
  function flattenError(error, mapper = (issue) => issue.message) {
394
705
  const fieldErrors = {};
395
706
  const formErrors = [];
396
- for (const sub of error.issues) if (sub.path.length > 0) {
397
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
398
- fieldErrors[sub.path[0]].push(mapper(sub));
399
- } else formErrors.push(mapper(sub));
707
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
708
+ else formErrors.push(mapper(sub));
400
709
  return {
401
710
  formErrors,
402
711
  fieldErrors
@@ -416,12 +725,21 @@ function formatError(error, mapper = (issue) => issue.message) {
416
725
  let i = 0;
417
726
  while (i < fullpath.length) {
418
727
  const el = fullpath[i];
419
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
420
- else {
421
- curr[el] = curr[el] || { _errors: [] };
422
- curr[el]._errors.push(mapper(issue));
728
+ const terminal = i === fullpath.length - 1;
729
+ if (el === "_errors") {
730
+ if (terminal) curr._errors.push(mapper(issue));
731
+ i++;
732
+ continue;
423
733
  }
424
- curr = curr[el];
734
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
735
+ value: { _errors: [] },
736
+ enumerable: true,
737
+ writable: true,
738
+ configurable: true
739
+ });
740
+ const node = curr[el];
741
+ if (terminal) node._errors.push(mapper(issue));
742
+ curr = node;
425
743
  i++;
426
744
  }
427
745
  }
@@ -431,40 +749,52 @@ function formatError(error, mapper = (issue) => issue.message) {
431
749
  return fieldErrors;
432
750
  }
433
751
  //#endregion
434
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
435
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
436
- const ctx = _ctx ? {
437
- ..._ctx,
438
- async: false
439
- } : { async: false };
440
- const result = schema._zod.run({
441
- value,
442
- issues: []
443
- }, ctx);
444
- if (result instanceof Promise) throw new $ZodAsyncError();
445
- if (result.issues.length) {
446
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
447
- captureStackTrace(e, _params?.callee);
448
- throw e;
449
- }
450
- return result.value;
752
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/parse.js
753
+ function finalizeParams(callee, params) {
754
+ return {
755
+ callee: params?.callee ?? callee,
756
+ Err: params?.Err
757
+ };
758
+ }
759
+ const _parse = (_Err) => {
760
+ const fn = (schema, value, _ctx, _params) => {
761
+ const ctx = _ctx ? {
762
+ ..._ctx,
763
+ async: false
764
+ } : { async: false };
765
+ const result = schema._zod.run({
766
+ value,
767
+ issues: []
768
+ }, ctx);
769
+ if (result instanceof Promise) throw new $ZodAsyncError();
770
+ if (result.issues.length) {
771
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
772
+ captureStackTrace(e, _params?.callee ?? fn);
773
+ throw e;
774
+ }
775
+ return result.value;
776
+ };
777
+ return fn;
451
778
  };
452
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
453
- const ctx = _ctx ? {
454
- ..._ctx,
455
- async: true
456
- } : { async: true };
457
- let result = schema._zod.run({
458
- value,
459
- issues: []
460
- }, ctx);
461
- if (result instanceof Promise) result = await result;
462
- if (result.issues.length) {
463
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
464
- captureStackTrace(e, params?.callee);
465
- throw e;
466
- }
467
- return result.value;
779
+ const _parseAsync = (_Err) => {
780
+ const fn = async (schema, value, _ctx, params) => {
781
+ const ctx = _ctx ? {
782
+ ..._ctx,
783
+ async: true
784
+ } : { async: true };
785
+ let result = schema._zod.run({
786
+ value,
787
+ issues: []
788
+ }, ctx);
789
+ if (result instanceof Promise) result = await result;
790
+ if (result.issues.length) {
791
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
792
+ captureStackTrace(e, params?.callee ?? fn);
793
+ throw e;
794
+ }
795
+ return result.value;
796
+ };
797
+ return fn;
468
798
  };
469
799
  const _safeParse = (_Err) => (schema, value, _ctx) => {
470
800
  const ctx = _ctx ? {
@@ -475,16 +805,31 @@ const _safeParse = (_Err) => (schema, value, _ctx) => {
475
805
  value,
476
806
  issues: []
477
807
  }, ctx);
478
- if (result instanceof Promise) throw new $ZodAsyncError();
479
- return result.issues.length ? {
480
- success: false,
481
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
482
- } : {
808
+ if (result instanceof Promise) throw new $ZodAsyncError();
809
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
483
810
  success: true,
484
811
  data: result.value
485
812
  };
486
813
  };
487
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
814
+ function failure(Err, issues, ctx) {
815
+ let error;
816
+ return {
817
+ success: false,
818
+ get error() {
819
+ if (!error) {
820
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
821
+ issues = void 0;
822
+ ctx = void 0;
823
+ }
824
+ return error;
825
+ },
826
+ set error(e) {
827
+ error = e;
828
+ issues = void 0;
829
+ ctx = void 0;
830
+ }
831
+ };
832
+ }
488
833
  const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
489
834
  const ctx = _ctx ? {
490
835
  ..._ctx,
@@ -495,34 +840,94 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
495
840
  issues: []
496
841
  }, ctx);
497
842
  if (result instanceof Promise) result = await result;
498
- return result.issues.length ? {
499
- success: false,
500
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
501
- } : {
843
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
502
844
  success: true,
503
845
  data: result.value
504
846
  };
505
847
  };
506
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
507
- const _encode = (_Err) => (schema, value, _ctx) => {
848
+ const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
849
+ const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
850
+ const validate = ((schema, value, _ctx) => {
851
+ const validator = schema._zod.bag.validator;
852
+ if (validator !== void 0) {
853
+ if (validator(value) !== COMPILE_INVALID) return true;
854
+ if (validator.definite === true && _ctx === void 0) return false;
855
+ }
856
+ return validateFallback(schema, value, _ctx);
857
+ });
858
+ function validateFallback(schema, value, _ctx) {
508
859
  const ctx = _ctx ? {
509
860
  ..._ctx,
510
- direction: "backward"
511
- } : { direction: "backward" };
512
- return _parse(_Err)(schema, value, ctx);
513
- };
514
- const _decode = (_Err) => (schema, value, _ctx) => {
515
- return _parse(_Err)(schema, value, _ctx);
516
- };
517
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
861
+ async: false,
862
+ abortEarly: true
863
+ } : {
864
+ async: false,
865
+ abortEarly: true
866
+ };
867
+ const fallbackRun = schema._zod.bag.fallbackRun;
868
+ let result;
869
+ if (fallbackRun) {
870
+ ctx[COMPILE_FALLBACK] = true;
871
+ result = fallbackRun({
872
+ value,
873
+ issues: []
874
+ }, ctx);
875
+ } else result = schema._zod.run({
876
+ value,
877
+ issues: []
878
+ }, ctx);
879
+ if (result instanceof Promise) throw new $ZodAsyncError();
880
+ return result.issues.length === 0;
881
+ }
882
+ const validateAsync$1 = async (schema, value, _ctx) => {
518
883
  const ctx = _ctx ? {
519
884
  ..._ctx,
520
- direction: "backward"
521
- } : { direction: "backward" };
522
- return _parseAsync(_Err)(schema, value, ctx);
885
+ async: true,
886
+ abortEarly: true
887
+ } : {
888
+ async: true,
889
+ abortEarly: true
890
+ };
891
+ let result = schema._zod.run({
892
+ value,
893
+ issues: []
894
+ }, ctx);
895
+ if (result instanceof Promise) result = await result;
896
+ return result.issues.length === 0;
897
+ };
898
+ const _encode = (_Err) => {
899
+ const parse = _parse(_Err);
900
+ const fn = (schema, value, _ctx, _params) => {
901
+ return parse(schema, value, _ctx ? {
902
+ ..._ctx,
903
+ direction: "backward"
904
+ } : { direction: "backward" }, finalizeParams(fn, _params));
905
+ };
906
+ return fn;
907
+ };
908
+ const _decode = (_Err) => {
909
+ const parse = _parse(_Err);
910
+ const fn = (schema, value, _ctx, _params) => {
911
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
912
+ };
913
+ return fn;
914
+ };
915
+ const _encodeAsync = (_Err) => {
916
+ const parseAsync = _parseAsync(_Err);
917
+ const fn = async (schema, value, _ctx, _params) => {
918
+ return await parseAsync(schema, value, _ctx ? {
919
+ ..._ctx,
920
+ direction: "backward"
921
+ } : { direction: "backward" }, finalizeParams(fn, _params));
922
+ };
923
+ return fn;
523
924
  };
524
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
525
- return _parseAsync(_Err)(schema, value, _ctx);
925
+ const _decodeAsync = (_Err) => {
926
+ const parseAsync = _parseAsync(_Err);
927
+ const fn = async (schema, value, _ctx, _params) => {
928
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
929
+ };
930
+ return fn;
526
931
  };
527
932
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
528
933
  const ctx = _ctx ? {
@@ -545,7 +950,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
545
950
  return _safeParseAsync(_Err)(schema, value, _ctx);
546
951
  };
547
952
  //#endregion
548
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
953
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/regexes.js
549
954
  /**
550
955
  * @deprecated CUID v1 is deprecated by its authors due to information leakage
551
956
  * (timestamps embedded in the id). Use {@link cuid2} instead.
@@ -553,12 +958,15 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
553
958
  */
554
959
  const cuid = /^[cC][0-9a-z]{6,}$/;
555
960
  const cuid2 = /^[0-9a-z]+$/;
556
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
961
+ const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
557
962
  const xid = /^[0-9a-vA-V]{20}$/;
558
963
  const ksuid = /^[A-Za-z0-9]{27}$/;
559
964
  const nanoid = /^[a-zA-Z0-9_-]{21}$/;
965
+ function nanoidOfLength(length) {
966
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
967
+ }
560
968
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
561
- const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
969
+ const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
562
970
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
563
971
  const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
564
972
  /** Returns a regex for validating an RFC 9562/4122 UUID.
@@ -569,52 +977,61 @@ const uuid = (version) => {
569
977
  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})$`);
570
978
  };
571
979
  /** Practical email validation */
572
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
573
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
980
+ const 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,}$/;
981
+ const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
574
982
  function emoji() {
575
983
  return new RegExp(_emoji$1, "u");
576
984
  }
577
985
  const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
578
986
  const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
579
987
  const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
580
- const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
988
+ const 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])$/;
581
989
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
582
- const base64url = /^[A-Za-z0-9_-]*$/;
990
+ const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
583
991
  const httpProtocol = /^https?$/;
584
992
  const e164 = /^\+[1-9]\d{6,14}$/;
585
993
  const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
586
- const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
994
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
995
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
996
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
997
+ function anchor(source) {
998
+ return new RegExp(`^${source}$`);
999
+ }
1000
+ const date = /*@__PURE__*/ anchor(dateSource);
587
1001
  function timeSource(args) {
588
1002
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
589
- 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+)?)?`;
1003
+ 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+)?)?`;
590
1004
  }
591
- function time$1(args) {
1005
+ function time(args) {
592
1006
  return new RegExp(`^${timeSource(args)}$`);
593
1007
  }
594
- function datetime$1(args) {
595
- const time = timeSource({ precision: args.precision });
1008
+ function datetime(args) {
596
1009
  const opts = ["Z"];
597
- if (args.local) opts.push("");
598
1010
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
599
- const timeRegex = `${time}(?:${opts.join("|")})`;
1011
+ const qualified = `${timeSource({
1012
+ precision: args.precision,
1013
+ seconds: true
1014
+ })}(?:${opts.join("|")})`;
1015
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
600
1016
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
601
1017
  }
602
- const string$1 = (params) => {
603
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
604
- return new RegExp(`^${regex}$`);
605
- };
606
- const integer = /^-?\d+$/;
1018
+ const anyString = /^[\s\S]{0,}$/;
607
1019
  const number$1 = /^-?\d+(?:\.\d+)?$/;
608
1020
  const lowercase = /^[^A-Z]*$/;
609
1021
  const uppercase = /^[^a-z]*$/;
610
1022
  //#endregion
611
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1023
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/checks.js
612
1024
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
613
1025
  var _a;
614
1026
  inst._zod ?? (inst._zod = {});
615
1027
  inst._zod.def = def;
616
1028
  (_a = inst._zod).onattach ?? (_a.onattach = []);
617
1029
  });
1030
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1031
+ const _whenHasLength = (payload) => {
1032
+ const val = payload.value;
1033
+ return !nullish(val) && val.length !== void 0;
1034
+ };
618
1035
  const numericOriginMap = {
619
1036
  number: "number",
620
1037
  bigint: "bigint",
@@ -623,16 +1040,10 @@ const numericOriginMap = {
623
1040
  const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
624
1041
  $ZodCheck.init(inst, def);
625
1042
  const origin = numericOriginMap[typeof def.value];
626
- inst._zod.onattach.push((inst) => {
627
- const bag = inst._zod.bag;
628
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
629
- if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
630
- else bag.exclusiveMaximum = def.value;
631
- });
632
1043
  inst._zod.check = (payload) => {
633
1044
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
634
1045
  payload.issues.push({
635
- origin,
1046
+ origin: numericOriginMap[typeof payload.value] ?? origin,
636
1047
  code: "too_big",
637
1048
  maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
638
1049
  input: payload.value,
@@ -645,16 +1056,10 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
645
1056
  const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
646
1057
  $ZodCheck.init(inst, def);
647
1058
  const origin = numericOriginMap[typeof def.value];
648
- inst._zod.onattach.push((inst) => {
649
- const bag = inst._zod.bag;
650
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
651
- if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
652
- else bag.exclusiveMinimum = def.value;
653
- });
654
1059
  inst._zod.check = (payload) => {
655
1060
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
656
1061
  payload.issues.push({
657
- origin,
1062
+ origin: numericOriginMap[typeof payload.value] ?? origin,
658
1063
  code: "too_small",
659
1064
  minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
660
1065
  input: payload.value,
@@ -666,13 +1071,9 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
666
1071
  });
667
1072
  const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
668
1073
  $ZodCheck.init(inst, def);
669
- inst._zod.onattach.push((inst) => {
670
- var _a;
671
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
672
- });
673
1074
  inst._zod.check = (payload) => {
674
1075
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
675
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1076
+ if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
676
1077
  payload.issues.push({
677
1078
  origin: typeof payload.value,
678
1079
  code: "not_multiple_of",
@@ -689,13 +1090,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
689
1090
  const isInt = def.format?.includes("int");
690
1091
  const origin = isInt ? "int" : "number";
691
1092
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
692
- inst._zod.onattach.push((inst) => {
693
- const bag = inst._zod.bag;
694
- bag.format = def.format;
695
- bag.minimum = minimum;
696
- bag.maximum = maximum;
697
- if (isInt) bag.pattern = integer;
698
- });
699
1093
  inst._zod.check = (payload) => {
700
1094
  const input = payload.value;
701
1095
  if (isInt) {
@@ -757,17 +1151,11 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
757
1151
  const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
758
1152
  var _a;
759
1153
  $ZodCheck.init(inst, def);
760
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
761
- const val = payload.value;
762
- return !nullish(val) && val.length !== void 0;
763
- });
764
- inst._zod.onattach.push((inst) => {
765
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
766
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
767
- });
1154
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
768
1155
  inst._zod.check = (payload) => {
769
1156
  const input = payload.value;
770
- if (input.length <= def.maximum) return;
1157
+ const units = input.length;
1158
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
771
1159
  const origin = getLengthableOrigin(input);
772
1160
  payload.issues.push({
773
1161
  origin,
@@ -783,17 +1171,11 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
783
1171
  const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
784
1172
  var _a;
785
1173
  $ZodCheck.init(inst, def);
786
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
787
- const val = payload.value;
788
- return !nullish(val) && val.length !== void 0;
789
- });
790
- inst._zod.onattach.push((inst) => {
791
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
792
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
793
- });
1174
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
794
1175
  inst._zod.check = (payload) => {
795
1176
  const input = payload.value;
796
- if (input.length >= def.minimum) return;
1177
+ const units = input.length;
1178
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
797
1179
  const origin = getLengthableOrigin(input);
798
1180
  payload.issues.push({
799
1181
  origin,
@@ -809,19 +1191,11 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
809
1191
  const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
810
1192
  var _a;
811
1193
  $ZodCheck.init(inst, def);
812
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
813
- const val = payload.value;
814
- return !nullish(val) && val.length !== void 0;
815
- });
816
- inst._zod.onattach.push((inst) => {
817
- const bag = inst._zod.bag;
818
- bag.minimum = def.length;
819
- bag.maximum = def.length;
820
- bag.length = def.length;
821
- });
1194
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
822
1195
  inst._zod.check = (payload) => {
823
1196
  const input = payload.value;
824
- const length = input.length;
1197
+ const units = input.length;
1198
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
825
1199
  if (length === def.length) return;
826
1200
  const origin = getLengthableOrigin(input);
827
1201
  const tooBig = length > def.length;
@@ -845,14 +1219,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
845
1219
  const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
846
1220
  var _a, _b;
847
1221
  $ZodCheck.init(inst, def);
848
- inst._zod.onattach.push((inst) => {
849
- const bag = inst._zod.bag;
850
- bag.format = def.format;
851
- if (def.pattern) {
852
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
853
- bag.patterns.add(def.pattern);
854
- }
855
- });
856
1222
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
857
1223
  def.pattern.lastIndex = 0;
858
1224
  if (def.pattern.test(payload.value)) return;
@@ -895,13 +1261,7 @@ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (ins
895
1261
  const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
896
1262
  $ZodCheck.init(inst, def);
897
1263
  const escapedRegex = escapeRegex(def.includes);
898
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
899
- def.pattern = pattern;
900
- inst._zod.onattach.push((inst) => {
901
- const bag = inst._zod.bag;
902
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
903
- bag.patterns.add(pattern);
904
- });
1264
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
905
1265
  inst._zod.check = (payload) => {
906
1266
  if (payload.value.includes(def.includes, def.position)) return;
907
1267
  payload.issues.push({
@@ -919,11 +1279,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
919
1279
  $ZodCheck.init(inst, def);
920
1280
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
921
1281
  def.pattern ?? (def.pattern = pattern);
922
- inst._zod.onattach.push((inst) => {
923
- const bag = inst._zod.bag;
924
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
925
- bag.patterns.add(pattern);
926
- });
927
1282
  inst._zod.check = (payload) => {
928
1283
  if (payload.value.startsWith(def.prefix)) return;
929
1284
  payload.issues.push({
@@ -941,11 +1296,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
941
1296
  $ZodCheck.init(inst, def);
942
1297
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
943
1298
  def.pattern ?? (def.pattern = pattern);
944
- inst._zod.onattach.push((inst) => {
945
- const bag = inst._zod.bag;
946
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
947
- bag.patterns.add(pattern);
948
- });
949
1299
  inst._zod.check = (payload) => {
950
1300
  if (payload.value.endsWith(def.suffix)) return;
951
1301
  payload.issues.push({
@@ -966,17 +1316,21 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
966
1316
  };
967
1317
  });
968
1318
  //#endregion
969
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1319
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/doc.js
970
1320
  var Doc = class {
971
- constructor(args = []) {
1321
+ constructor(args = [], closed = {}) {
972
1322
  this.content = [];
973
1323
  this.indent = 0;
974
- if (this) this.args = args;
1324
+ this.args = args;
1325
+ this.closed = closed;
975
1326
  }
976
1327
  indented(fn) {
977
1328
  this.indent += 1;
978
- fn(this);
979
- this.indent -= 1;
1329
+ try {
1330
+ fn(this);
1331
+ } finally {
1332
+ this.indent -= 1;
1333
+ }
980
1334
  }
981
1335
  write(arg) {
982
1336
  if (typeof arg === "function") {
@@ -991,28 +1345,27 @@ var Doc = class {
991
1345
  }
992
1346
  compile() {
993
1347
  const F = Function;
994
- const args = this?.args;
995
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
996
- return new F(...args, lines.join("\n"));
1348
+ const content = this?.content ?? [``];
1349
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
997
1350
  }
998
1351
  };
999
1352
  //#endregion
1000
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1353
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/versions.js
1001
1354
  const version = {
1002
1355
  major: 4,
1003
- minor: 4,
1004
- patch: 3
1356
+ minor: 6,
1357
+ patch: 7
1005
1358
  };
1006
1359
  //#endregion
1007
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1360
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/schemas.js
1008
1361
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1009
1362
  var _a;
1010
1363
  inst ?? (inst = {});
1011
1364
  inst._zod.def = def;
1012
1365
  inst._zod.bag = inst._zod.bag || {};
1013
1366
  inst._zod.version = version;
1014
- const checks = [...inst._zod.def.checks ?? []];
1015
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1367
+ const defChecks = inst._zod.def.checks;
1368
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1016
1369
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1017
1370
  if (checks.length === 0) {
1018
1371
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1021,6 +1374,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1021
1374
  });
1022
1375
  } else {
1023
1376
  const runChecks = (payload, checks, ctx) => {
1377
+ if (payload.memo) return payload;
1024
1378
  let isAborted = aborted(payload);
1025
1379
  let asyncResult;
1026
1380
  for (const ch of checks) {
@@ -1034,10 +1388,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1034
1388
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1035
1389
  await _;
1036
1390
  if (payload.issues.length === currLen) return;
1391
+ attachSchema(payload.issues, currLen, inst);
1037
1392
  if (!isAborted) isAborted = aborted(payload, currLen);
1038
1393
  });
1039
1394
  else {
1040
1395
  if (payload.issues.length === currLen) continue;
1396
+ attachSchema(payload.issues, currLen, inst);
1041
1397
  if (!isAborted) isAborted = aborted(payload, currLen);
1042
1398
  }
1043
1399
  }
@@ -1081,22 +1437,43 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1081
1437
  return runChecks(result, checks, ctx);
1082
1438
  };
1083
1439
  }
1084
- defineLazy(inst, "~standard", () => ({
1440
+ }, {
1441
+ get "~standard"() {
1442
+ return hide(this, "~standard", standardProps(this));
1443
+ },
1444
+ set "~standard"(value) {
1445
+ own(this, "~standard", value);
1446
+ }
1447
+ });
1448
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1449
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1450
+ async function validateAsync(inst, value) {
1451
+ const ctx = { async: true };
1452
+ return toStandardResult(await inst._zod.run({
1453
+ value,
1454
+ issues: []
1455
+ }, ctx), ctx);
1456
+ }
1457
+ function standardProps(inst) {
1458
+ return {
1085
1459
  validate: (value) => {
1460
+ const ctx = { async: false };
1086
1461
  try {
1087
- const r = safeParse$1(inst, value);
1088
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1089
- } catch (_) {
1090
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1091
- }
1462
+ const r = inst._zod.run({
1463
+ value,
1464
+ issues: []
1465
+ }, ctx);
1466
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
1467
+ } catch (_) {}
1468
+ return validateAsync(inst, value);
1092
1469
  },
1093
1470
  vendor: "zod",
1094
1471
  version: 1
1095
- }));
1096
- });
1472
+ };
1473
+ }
1097
1474
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1098
1475
  $ZodType.init(inst, def);
1099
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1476
+ inst._zod.pattern = def.pattern ?? anyString;
1100
1477
  inst._zod.parse = (payload, _) => {
1101
1478
  if (def.coerce) try {
1102
1479
  payload.value = String(payload.value);
@@ -1140,51 +1517,95 @@ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1140
1517
  def.pattern ?? (def.pattern = email);
1141
1518
  $ZodStringFormat.init(inst, def);
1142
1519
  });
1520
+ function canParseURL(input) {
1521
+ try {
1522
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
1523
+ new URL(input);
1524
+ return true;
1525
+ } catch {
1526
+ return false;
1527
+ }
1528
+ }
1529
+ function validateURL(trimmed, def) {
1530
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
1531
+ return parseURLObject(trimmed, def);
1532
+ }
1533
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
1534
+ function parseURLObject(trimmed, def) {
1535
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1536
+ try {
1537
+ if (typeof URL !== "undefined") {
1538
+ const URLStatic = URL;
1539
+ if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
1540
+ }
1541
+ return new URL(trimmed);
1542
+ } catch {
1543
+ return 2;
1544
+ }
1545
+ }
1546
+ const asciiTabOrNewline = /[\t\n\r]/g;
1547
+ /** 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. */
1548
+ function stripTabAndNewline(value) {
1549
+ return value.replace(asciiTabOrNewline, "");
1550
+ }
1551
+ function urlHostnameOk(url, hostname) {
1552
+ hostname.lastIndex = 0;
1553
+ return hostname.test(url.hostname);
1554
+ }
1555
+ function urlProtocolOk(url, protocol) {
1556
+ protocol.lastIndex = 0;
1557
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1558
+ }
1143
1559
  const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1144
1560
  $ZodStringFormat.init(inst, def);
1145
1561
  inst._zod.check = (payload) => {
1146
1562
  try {
1147
1563
  const trimmed = payload.value.trim();
1148
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1149
- if (!/^https?:\/\//i.test(trimmed)) {
1150
- payload.issues.push({
1151
- code: "invalid_format",
1152
- format: "url",
1153
- note: "Invalid URL format",
1154
- input: payload.value,
1155
- inst,
1156
- continue: !def.abort
1157
- });
1158
- return;
1159
- }
1160
- }
1161
- const url = new URL(trimmed);
1162
- if (def.hostname) {
1163
- def.hostname.lastIndex = 0;
1164
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1564
+ const url = validateURL(trimmed, def);
1565
+ if (url === 1) {
1566
+ payload.issues.push({
1165
1567
  code: "invalid_format",
1166
1568
  format: "url",
1167
- note: "Invalid hostname",
1168
- pattern: def.hostname.source,
1569
+ note: "Invalid URL format",
1169
1570
  input: payload.value,
1170
1571
  inst,
1171
1572
  continue: !def.abort
1172
1573
  });
1574
+ return;
1173
1575
  }
1174
- if (def.protocol) {
1175
- def.protocol.lastIndex = 0;
1176
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1576
+ if (url === 2) {
1577
+ payload.issues.push({
1177
1578
  code: "invalid_format",
1178
1579
  format: "url",
1179
- note: "Invalid protocol",
1180
- pattern: def.protocol.source,
1181
1580
  input: payload.value,
1182
1581
  inst,
1183
1582
  continue: !def.abort
1184
1583
  });
1584
+ return;
1585
+ }
1586
+ if (url === true) {
1587
+ payload.value = stripTabAndNewline(trimmed);
1588
+ return;
1185
1589
  }
1186
- if (def.normalize) payload.value = url.href;
1187
- else payload.value = trimmed;
1590
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1591
+ code: "invalid_format",
1592
+ format: "url",
1593
+ note: "Invalid hostname",
1594
+ pattern: def.hostname.source,
1595
+ input: payload.value,
1596
+ inst,
1597
+ continue: !def.abort
1598
+ });
1599
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1600
+ code: "invalid_format",
1601
+ format: "url",
1602
+ note: "Invalid protocol",
1603
+ pattern: def.protocol.source,
1604
+ input: payload.value,
1605
+ inst,
1606
+ continue: !def.abort
1607
+ });
1608
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1188
1609
  return;
1189
1610
  } catch (_) {
1190
1611
  payload.issues.push({
@@ -1202,7 +1623,8 @@ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1202
1623
  $ZodStringFormat.init(inst, def);
1203
1624
  });
1204
1625
  const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1205
- def.pattern ?? (def.pattern = nanoid);
1626
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1627
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
1206
1628
  $ZodStringFormat.init(inst, def);
1207
1629
  });
1208
1630
  /**
@@ -1231,70 +1653,69 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1231
1653
  $ZodStringFormat.init(inst, def);
1232
1654
  });
1233
1655
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1234
- def.pattern ?? (def.pattern = datetime$1(def));
1656
+ def.pattern ?? (def.pattern = datetime(def));
1235
1657
  $ZodStringFormat.init(inst, def);
1236
1658
  });
1237
1659
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1238
- def.pattern ?? (def.pattern = date$1);
1660
+ def.pattern ?? (def.pattern = date);
1239
1661
  $ZodStringFormat.init(inst, def);
1240
1662
  });
1241
1663
  const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1242
- def.pattern ?? (def.pattern = time$1(def));
1664
+ def.pattern ?? (def.pattern = time(def));
1243
1665
  $ZodStringFormat.init(inst, def);
1244
1666
  });
1245
1667
  const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1246
- def.pattern ?? (def.pattern = duration$1);
1668
+ def.pattern ?? (def.pattern = duration);
1247
1669
  $ZodStringFormat.init(inst, def);
1248
1670
  });
1249
1671
  const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1250
1672
  def.pattern ?? (def.pattern = ipv4);
1251
1673
  $ZodStringFormat.init(inst, def);
1252
- inst._zod.bag.format = `ipv4`;
1253
1674
  });
1675
+ /** 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`. */
1676
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1677
+ function isValidIPv6(value) {
1678
+ if (!ipv6Alphabet.test(value)) return false;
1679
+ return canParseURL(`http://[${value}]`);
1680
+ }
1254
1681
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1255
1682
  def.pattern ?? (def.pattern = ipv6);
1256
1683
  $ZodStringFormat.init(inst, def);
1257
- inst._zod.bag.format = `ipv6`;
1258
1684
  inst._zod.check = (payload) => {
1259
- try {
1260
- new URL(`http://[${payload.value}]`);
1261
- } catch {
1262
- payload.issues.push({
1263
- code: "invalid_format",
1264
- format: "ipv6",
1265
- input: payload.value,
1266
- inst,
1267
- continue: !def.abort
1268
- });
1269
- }
1685
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1686
+ code: "invalid_format",
1687
+ format: "ipv6",
1688
+ input: payload.value,
1689
+ inst,
1690
+ continue: !def.abort
1691
+ });
1270
1692
  };
1271
1693
  });
1272
1694
  const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1273
1695
  def.pattern ?? (def.pattern = cidrv4);
1274
1696
  $ZodStringFormat.init(inst, def);
1275
1697
  });
1698
+ function isValidCIDRv6(value) {
1699
+ const parts = value.split("/");
1700
+ if (parts.length !== 2) return false;
1701
+ const [address, prefix] = parts;
1702
+ if (!prefix) return false;
1703
+ const prefixNum = Number(prefix);
1704
+ if (`${prefixNum}` !== prefix) return false;
1705
+ if (prefixNum < 0 || prefixNum > 128) return false;
1706
+ return isValidIPv6(address);
1707
+ }
1276
1708
  const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1277
1709
  def.pattern ?? (def.pattern = cidrv6);
1278
1710
  $ZodStringFormat.init(inst, def);
1279
1711
  inst._zod.check = (payload) => {
1280
- const parts = payload.value.split("/");
1281
- try {
1282
- if (parts.length !== 2) throw new Error();
1283
- const [address, prefix] = parts;
1284
- if (!prefix) throw new Error();
1285
- const prefixNum = Number(prefix);
1286
- if (`${prefixNum}` !== prefix) throw new Error();
1287
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1288
- new URL(`http://[${address}]`);
1289
- } catch {
1290
- payload.issues.push({
1291
- code: "invalid_format",
1292
- format: "cidrv6",
1293
- input: payload.value,
1294
- inst,
1295
- continue: !def.abort
1296
- });
1297
- }
1712
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1713
+ code: "invalid_format",
1714
+ format: "cidrv6",
1715
+ input: payload.value,
1716
+ inst,
1717
+ continue: !def.abort
1718
+ });
1298
1719
  };
1299
1720
  });
1300
1721
  function isValidBase64(data) {
@@ -1308,10 +1729,10 @@ function isValidBase64(data) {
1308
1729
  return false;
1309
1730
  }
1310
1731
  }
1732
+ const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
1311
1733
  const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1312
- def.pattern ?? (def.pattern = base64);
1734
+ def.pattern ?? (def.pattern = base64Charset);
1313
1735
  $ZodStringFormat.init(inst, def);
1314
- inst._zod.bag.contentEncoding = "base64";
1315
1736
  inst._zod.check = (payload) => {
1316
1737
  if (isValidBase64(payload.value)) return;
1317
1738
  payload.issues.push({
@@ -1323,15 +1744,15 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1323
1744
  });
1324
1745
  };
1325
1746
  });
1747
+ const base64urlCharset = /^[A-Za-z0-9_-]*$/;
1326
1748
  function isValidBase64URL(data) {
1327
- if (!base64url.test(data)) return false;
1749
+ if (!base64urlCharset.test(data)) return false;
1328
1750
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1329
1751
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1330
1752
  }
1331
1753
  const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1332
- def.pattern ?? (def.pattern = base64url);
1754
+ def.pattern ?? (def.pattern = base64urlCharset);
1333
1755
  $ZodStringFormat.init(inst, def);
1334
- inst._zod.bag.contentEncoding = "base64url";
1335
1756
  inst._zod.check = (payload) => {
1336
1757
  if (isValidBase64URL(payload.value)) return;
1337
1758
  payload.issues.push({
@@ -1377,14 +1798,14 @@ const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1377
1798
  });
1378
1799
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1379
1800
  $ZodType.init(inst, def);
1380
- inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1801
+ inst._zod.pattern = number$1;
1381
1802
  inst._zod.parse = (payload, _ctx) => {
1382
1803
  if (def.coerce) try {
1383
1804
  payload.value = Number(payload.value);
1384
1805
  } catch (_) {}
1385
1806
  const input = payload.value;
1386
1807
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1387
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1808
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
1388
1809
  payload.issues.push({
1389
1810
  expected: "number",
1390
1811
  code: "invalid_type",
@@ -1415,12 +1836,34 @@ const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
1415
1836
  return payload;
1416
1837
  };
1417
1838
  });
1839
+ function capSize(inst, size) {
1840
+ const caps = sizeCaps(inst._zod.def.checks);
1841
+ if (!caps.length) return;
1842
+ const cap = Math.min(...caps.map((c) => c[0]));
1843
+ const parse = inst._zod.parse;
1844
+ inst._zod.parse = (payload, ctx) => {
1845
+ const n = size(payload.value);
1846
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
1847
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) if (n > max && ch._zod.def.when(payload)) {
1848
+ const start = payload.issues.length;
1849
+ ch._zod.check(payload);
1850
+ payload.issues[start].continue = false;
1851
+ attachSchema(payload.issues, start, inst);
1852
+ return payload;
1853
+ }
1854
+ }
1855
+ return parse(payload, ctx);
1856
+ };
1857
+ }
1858
+ const arraySize = (input) => Array.isArray(input) ? input.length : -1;
1418
1859
  function handleArrayResult(result, final, index) {
1419
1860
  if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1420
1861
  final.value[index] = result.value;
1421
1862
  }
1422
1863
  const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1423
1864
  $ZodType.init(inst, def);
1865
+ const memo = globalConfig.memoizer;
1866
+ memo?.attach(inst);
1424
1867
  inst._zod.parse = (payload, ctx) => {
1425
1868
  const input = payload.value;
1426
1869
  if (!Array.isArray(input)) {
@@ -1432,8 +1875,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1432
1875
  });
1433
1876
  return payload;
1434
1877
  }
1435
- payload.value = Array(input.length);
1878
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1436
1879
  const proms = [];
1880
+ const abortEarly = ctx?.abortEarly;
1437
1881
  for (let i = 0; i < input.length; i++) {
1438
1882
  const item = input[i];
1439
1883
  const result = def.element._zod.run({
@@ -1441,19 +1885,25 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1441
1885
  issues: []
1442
1886
  }, ctx);
1443
1887
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1444
- else handleArrayResult(result, payload, i);
1888
+ else {
1889
+ handleArrayResult(result, payload, i);
1890
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
1891
+ }
1445
1892
  }
1446
1893
  if (proms.length) return Promise.all(proms).then(() => payload);
1447
1894
  return payload;
1448
1895
  };
1896
+ capSize(inst, arraySize);
1449
1897
  });
1450
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1898
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1451
1899
  const isPresent = key in input;
1900
+ const isOptionalOut = optout === "optional";
1901
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1452
1902
  if (result.issues.length) {
1453
- if (isOptionalIn && isOptionalOut && !isPresent) return;
1903
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1454
1904
  final.issues.push(...prefixIssues(key, result.issues));
1455
1905
  }
1456
- if (!isPresent && !isOptionalIn) {
1906
+ if (!isPresent && optin === void 0) {
1457
1907
  if (!result.issues.length) final.issues.push({
1458
1908
  code: "invalid_type",
1459
1909
  expected: "nonoptional",
@@ -1463,31 +1913,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1463
1913
  return;
1464
1914
  }
1465
1915
  if (result.value === void 0) {
1466
- if (isPresent) final.value[key] = void 0;
1916
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
1467
1917
  } else final.value[key] = result.value;
1468
1918
  }
1919
+ const NO_SYMBOL_KEYS = [];
1469
1920
  function normalizeDef(def) {
1470
1921
  const keys = Object.keys(def.shape);
1471
- 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`);
1922
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
1923
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
1924
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
1925
+ 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`);
1472
1926
  const okeys = optionalKeys(def.shape);
1473
1927
  return {
1474
1928
  ...def,
1475
- keys,
1929
+ allKeys,
1930
+ symbolKeys,
1476
1931
  keySet: new Set(keys),
1477
1932
  numKeys: keys.length,
1478
1933
  optionalKeys: new Set(okeys)
1479
1934
  };
1480
1935
  }
1481
- function handleCatchall(proms, input, payload, ctx, def, inst) {
1936
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1482
1937
  const unrecognized = [];
1483
1938
  const keySet = def.keySet;
1484
1939
  const _catchall = def.catchall._zod;
1485
1940
  const t = _catchall.def.type;
1486
- const isOptionalIn = _catchall.optin === "optional";
1487
- const isOptionalOut = _catchall.optout === "optional";
1941
+ const optin = _catchall.optin;
1942
+ const optout = _catchall.optout;
1943
+ let seen = 0;
1488
1944
  for (const key in input) {
1489
- if (key === "__proto__") continue;
1945
+ if (abortEarly && payload.issues.length !== seen) {
1946
+ if (aborted(payload, seen)) break;
1947
+ seen = payload.issues.length;
1948
+ }
1490
1949
  if (keySet.has(key)) continue;
1950
+ if (key === "__proto__") {
1951
+ if (t === "never") unrecognized.push(key);
1952
+ continue;
1953
+ }
1491
1954
  if (t === "never") {
1492
1955
  unrecognized.push(key);
1493
1956
  continue;
@@ -1496,14 +1959,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1496
1959
  value: input[key],
1497
1960
  issues: []
1498
1961
  }, ctx);
1499
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1500
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1962
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
1963
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1501
1964
  }
1502
1965
  if (unrecognized.length) payload.issues.push({
1503
1966
  code: "unrecognized_keys",
1504
1967
  keys: unrecognized,
1505
1968
  input,
1506
- inst
1969
+ inst,
1970
+ continue: true
1507
1971
  });
1508
1972
  if (!proms.length) return payload;
1509
1973
  return Promise.all(proms).then(() => {
@@ -1512,23 +1976,28 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1512
1976
  }
1513
1977
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1514
1978
  $ZodType.init(inst, def);
1515
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1516
- const sh = def.shape;
1517
- Object.defineProperty(def, "shape", { get: () => {
1979
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1980
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
1981
+ if (sh) {
1982
+ const get = () => {
1518
1983
  const newSh = { ...sh };
1519
1984
  Object.defineProperty(def, "shape", { value: newSh });
1985
+ get.raw = newSh;
1520
1986
  return newSh;
1521
- } });
1987
+ };
1988
+ get.raw = sh;
1989
+ Object.defineProperty(def, "shape", { get });
1522
1990
  }
1523
1991
  const _normalized = cached(() => normalizeDef(def));
1524
- defineLazy(inst._zod, "propValues", () => {
1525
- const shape = def.shape;
1992
+ defineLazyInternal(inst, "propValues", (zod) => {
1993
+ const shape = zod.def.shape;
1526
1994
  const propValues = {};
1527
1995
  for (const key in shape) {
1528
1996
  const field = shape[key]._zod;
1529
1997
  if (field.values) {
1530
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1998
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1531
1999
  for (const v of field.values) propValues[key].add(v);
2000
+ if (field.optin !== void 0) propValues[key].add(void 0);
1532
2001
  }
1533
2002
  }
1534
2003
  return propValues;
@@ -1536,6 +2005,8 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1536
2005
  const isObject$1 = isObject;
1537
2006
  const catchall = def.catchall;
1538
2007
  let value;
2008
+ const memo = globalConfig.memoizer;
2009
+ memo?.attach(inst);
1539
2010
  inst._zod.parse = (payload, ctx) => {
1540
2011
  value ?? (value = _normalized.value);
1541
2012
  const input = payload.value;
@@ -1548,77 +2019,90 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1548
2019
  });
1549
2020
  return payload;
1550
2021
  }
1551
- payload.value = {};
2022
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1552
2023
  const proms = [];
1553
2024
  const shape = value.shape;
1554
- for (const key of value.keys) {
2025
+ const abortEarly = ctx?.abortEarly;
2026
+ let seen = payload.issues.length;
2027
+ for (const key of value.allKeys) {
2028
+ if (abortEarly && payload.issues.length !== seen) {
2029
+ if (aborted(payload, seen)) break;
2030
+ seen = payload.issues.length;
2031
+ }
2032
+ if (key === "__proto__") continue;
1555
2033
  const el = shape[key];
1556
- const isOptionalIn = el._zod.optin === "optional";
1557
- const isOptionalOut = el._zod.optout === "optional";
2034
+ const optin = el._zod.optin;
2035
+ const optout = el._zod.optout;
1558
2036
  const r = el._zod.run({
1559
2037
  value: input[key],
1560
2038
  issues: []
1561
2039
  }, ctx);
1562
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1563
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2040
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2041
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1564
2042
  }
1565
2043
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1566
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2044
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1567
2045
  };
1568
2046
  });
1569
2047
  const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1570
2048
  $ZodObject.init(inst, def);
1571
2049
  const superParse = inst._zod.parse;
1572
2050
  const _normalized = cached(() => normalizeDef(def));
2051
+ const memo = globalConfig.memoizer;
1573
2052
  const generateFastpass = (shape) => {
1574
- const doc = new Doc([
1575
- "shape",
1576
- "payload",
1577
- "ctx"
1578
- ]);
1579
2053
  const normalized = _normalized.value;
1580
- const parseStr = (key) => {
1581
- const k = esc(key);
1582
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1583
- };
2054
+ const syms = normalized.symbolKeys;
2055
+ const doc = new Doc(["payload", "ctx"], {
2056
+ shape,
2057
+ inst,
2058
+ memo,
2059
+ syms
2060
+ });
2061
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2062
+ const prefixStr = (id, k) => `
2063
+ let ${id}_ab = false;
2064
+ for (let i = 0; i < ${id}.issues.length; i++) {
2065
+ const iss = ${id}.issues[i];
2066
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2067
+ payload.issues.push(iss);
2068
+ if (iss.continue !== true) ${id}_ab = true;
2069
+ }
2070
+ if (${id}_ab && ctx && ctx.abortEarly) {
2071
+ payload.value = newResult;
2072
+ return payload;
2073
+ }`;
1584
2074
  doc.write(`const input = payload.value;`);
1585
2075
  const ids = Object.create(null);
1586
2076
  let counter = 0;
1587
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1588
- doc.write(`const newResult = {};`);
1589
- for (const key of normalized.keys) {
2077
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2078
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2079
+ for (const key of normalized.allKeys) {
2080
+ if (key === "__proto__") continue;
1590
2081
  const id = ids[key];
1591
- const k = esc(key);
2082
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2083
+ const isPresent = `${k} in input`;
1592
2084
  const schema = shape[key];
1593
- const isOptionalIn = schema?._zod?.optin === "optional";
2085
+ const optin = schema?._zod?.optin;
2086
+ const isOptionalIn = optin !== void 0;
1594
2087
  const isOptionalOut = schema?._zod?.optout === "optional";
1595
- doc.write(`const ${id} = ${parseStr(key)};`);
1596
- if (isOptionalIn && isOptionalOut) doc.write(`
1597
- if (${id}.issues.length) {
1598
- if (${k} in input) {
1599
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1600
- ...iss,
1601
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1602
- })));
2088
+ doc.write(`const ${id} = ${parseStr(k)};`);
2089
+ if (isOptionalIn && isOptionalOut) {
2090
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2091
+ doc.write(`
2092
+ const ${id}_present = ${isPresent};
2093
+ if (!${id}.issues.length || ${id}_present) {
2094
+ if (${id}.issues.length) {${prefixStr(id, k)}
1603
2095
  }
1604
- }
1605
-
1606
- if (${id}.value === undefined) {
1607
- if (${k} in input) {
1608
- newResult[${k}] = undefined;
2096
+
2097
+ if (${assign}) {
2098
+ newResult[${k}] = ${id}.value;
1609
2099
  }
1610
- } else {
1611
- newResult[${k}] = ${id}.value;
1612
2100
  }
1613
-
2101
+
1614
2102
  `);
1615
- else if (!isOptionalIn) doc.write(`
1616
- const ${id}_present = ${k} in input;
1617
- if (${id}.issues.length) {
1618
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1619
- ...iss,
1620
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1621
- })));
2103
+ } else if (!isOptionalIn) doc.write(`
2104
+ const ${id}_present = ${isPresent};
2105
+ if (${id}.issues.length) {${prefixStr(id, k)}
1622
2106
  }
1623
2107
  if (!${id}_present && !${id}.issues.length) {
1624
2108
  payload.issues.push({
@@ -1627,39 +2111,33 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1627
2111
  input: undefined,
1628
2112
  path: [${k}]
1629
2113
  });
2114
+ if (ctx && ctx.abortEarly) {
2115
+ payload.value = newResult;
2116
+ return payload;
2117
+ }
1630
2118
  }
1631
2119
 
1632
2120
  if (${id}_present) {
1633
- if (${id}.value === undefined) {
1634
- newResult[${k}] = undefined;
1635
- } else {
1636
- newResult[${k}] = ${id}.value;
1637
- }
2121
+ newResult[${k}] = ${id}.value;
1638
2122
  }
1639
2123
 
1640
2124
  `);
1641
- else doc.write(`
1642
- if (${id}.issues.length) {
1643
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1644
- ...iss,
1645
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1646
- })));
2125
+ else {
2126
+ doc.write(`
2127
+ if (${id}.issues.length) {${prefixStr(id, k)}
1647
2128
  }
1648
-
1649
- if (${id}.value === undefined) {
1650
- if (${k} in input) {
1651
- newResult[${k}] = undefined;
1652
- }
1653
- } else {
2129
+ `);
2130
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
2131
+ else doc.write(`
2132
+ if (${id}.value !== undefined || ${isPresent}) {
1654
2133
  newResult[${k}] = ${id}.value;
1655
2134
  }
1656
-
1657
2135
  `);
2136
+ }
1658
2137
  }
1659
2138
  doc.write(`payload.value = newResult;`);
1660
2139
  doc.write(`return payload;`);
1661
- const fn = doc.compile();
1662
- return (payload, ctx) => fn(shape, payload, ctx);
2140
+ return doc.compile();
1663
2141
  };
1664
2142
  let fastpass;
1665
2143
  const isObject$2 = isObject;
@@ -1683,7 +2161,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1683
2161
  if (!fastpass) fastpass = generateFastpass(def.shape);
1684
2162
  payload = fastpass(payload, ctx);
1685
2163
  if (!catchall) return payload;
1686
- return handleCatchall([], input, payload, ctx, value, inst);
2164
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1687
2165
  }
1688
2166
  return superParse(payload, ctx);
1689
2167
  };
@@ -1708,14 +2186,14 @@ function handleUnionResults(results, final, inst, ctx) {
1708
2186
  }
1709
2187
  const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1710
2188
  $ZodType.init(inst, def);
1711
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1712
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1713
- defineLazy(inst._zod, "values", () => {
1714
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2189
+ 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);
2190
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2191
+ defineLazyInternal(inst, "values", (zod) => {
2192
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1715
2193
  });
1716
- defineLazy(inst._zod, "pattern", () => {
1717
- if (def.options.every((o) => o._zod.pattern)) {
1718
- const patterns = def.options.map((o) => o._zod.pattern);
2194
+ defineLazyInternal(inst, "pattern", (zod) => {
2195
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2196
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1719
2197
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1720
2198
  }
1721
2199
  });
@@ -1777,7 +2255,9 @@ function mergeValues(a, b) {
1777
2255
  ...a,
1778
2256
  ...b
1779
2257
  };
2258
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
1780
2259
  for (const key of sharedKeys) {
2260
+ if (key === "__proto__") continue;
1781
2261
  const sharedValue = mergeValues(a[key], b[key]);
1782
2262
  if (!sharedValue.valid) return {
1783
2263
  valid: false,
@@ -1819,26 +2299,39 @@ function mergeValues(a, b) {
1819
2299
  function handleIntersectionResults(result, left, right) {
1820
2300
  const unrecKeys = /* @__PURE__ */ new Map();
1821
2301
  let unrecIssue;
1822
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1823
- unrecIssue ?? (unrecIssue = iss);
1824
- for (const k of iss.keys) {
2302
+ const keyIssues = /* @__PURE__ */ new Map();
2303
+ const collect = (iss, side) => {
2304
+ let keys;
2305
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2306
+ unrecIssue ?? (unrecIssue = iss);
2307
+ keys = iss.keys;
2308
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2309
+ const k = String(iss.path[0]);
2310
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2311
+ keys = [k];
2312
+ } else return false;
2313
+ for (const k of keys) {
1825
2314
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1826
- unrecKeys.get(k).l = true;
2315
+ unrecKeys.get(k)[side] = true;
1827
2316
  }
1828
- } else result.issues.push(iss);
1829
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1830
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1831
- unrecKeys.get(k).r = true;
1832
- }
1833
- else result.issues.push(iss);
2317
+ return true;
2318
+ };
2319
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2320
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
1834
2321
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1835
- if (bothKeys.length && unrecIssue) result.issues.push({
1836
- ...unrecIssue,
1837
- keys: bothKeys
1838
- });
1839
- if (aborted(result)) return result;
2322
+ if (bothKeys.length) {
2323
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2324
+ if (aggregated.length) result.issues.push({
2325
+ ...unrecIssue,
2326
+ keys: aggregated
2327
+ });
2328
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2329
+ }
1840
2330
  const merged = mergeValues(left.value, right.value);
1841
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2331
+ if (!merged.valid) {
2332
+ if (aborted(result)) return result;
2333
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2334
+ }
1842
2335
  result.value = merged.data;
1843
2336
  return result;
1844
2337
  }
@@ -1847,7 +2340,10 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1847
2340
  const values = getEnumValues(def.entries);
1848
2341
  const valuesSet = new Set(values);
1849
2342
  inst._zod.values = valuesSet;
1850
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2343
+ defineLazyInternal(inst, "pattern", (zod) => {
2344
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
2345
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2346
+ });
1851
2347
  inst._zod.parse = (payload, _ctx) => {
1852
2348
  const input = payload.value;
1853
2349
  if (valuesSet.has(input)) return payload;
@@ -1863,67 +2359,66 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1863
2359
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
1864
2360
  $ZodType.init(inst, def);
1865
2361
  inst._zod.optin = "optional";
2362
+ globalConfig.memoizer?.guard(inst);
1866
2363
  inst._zod.parse = (payload, ctx) => {
1867
2364
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1868
2365
  const _out = def.transform(payload.value, payload);
1869
2366
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1870
2367
  payload.value = output;
1871
- payload.fallback = true;
1872
2368
  return payload;
1873
2369
  });
1874
2370
  if (_out instanceof Promise) throw new $ZodAsyncError();
1875
2371
  payload.value = _out;
1876
- payload.fallback = true;
1877
2372
  return payload;
1878
2373
  };
1879
2374
  });
1880
- function handleOptionalResult(result, input) {
1881
- if (input === void 0 && (result.issues.length || result.fallback)) return {
1882
- issues: [],
1883
- value: void 0
1884
- };
1885
- return result;
2375
+ function handleOptionalResult(payload, result) {
2376
+ payload.value = result.issues.length ? void 0 : result.value;
2377
+ return payload;
1886
2378
  }
1887
2379
  const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1888
2380
  $ZodType.init(inst, def);
1889
- inst._zod.optin = "optional";
2381
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
1890
2382
  inst._zod.optout = "optional";
1891
- defineLazy(inst._zod, "values", () => {
1892
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
2383
+ defineLazyInternal(inst, "values", (zod) => {
2384
+ const values = zod.def.innerType._zod.values;
2385
+ return values ? new Set([...values, void 0]) : void 0;
1893
2386
  });
1894
- defineLazy(inst._zod, "pattern", () => {
1895
- const pattern = def.innerType._zod.pattern;
2387
+ defineLazyInternal(inst, "pattern", (zod) => {
2388
+ const pattern = zod.def.innerType._zod.pattern;
1896
2389
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1897
2390
  });
1898
2391
  inst._zod.parse = (payload, ctx) => {
1899
- if (def.innerType._zod.optin === "optional") {
1900
- const input = payload.value;
1901
- const result = def.innerType._zod.run(payload, ctx);
1902
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
1903
- return handleOptionalResult(result, input);
2392
+ if (payload.value === void 0) {
2393
+ if (def.innerType._zod.optin !== "defaulted") return payload;
2394
+ const result = def.innerType._zod.run({
2395
+ value: payload.value,
2396
+ issues: []
2397
+ }, ctx);
2398
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
2399
+ return handleOptionalResult(payload, result);
1904
2400
  }
1905
- if (payload.value === void 0) return payload;
1906
2401
  return def.innerType._zod.run(payload, ctx);
1907
2402
  };
1908
2403
  });
1909
2404
  const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1910
2405
  $ZodOptional.init(inst, def);
1911
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1912
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2406
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2407
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
1913
2408
  inst._zod.parse = (payload, ctx) => {
1914
2409
  return def.innerType._zod.run(payload, ctx);
1915
2410
  };
1916
2411
  });
1917
2412
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1918
2413
  $ZodType.init(inst, def);
1919
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1920
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1921
- defineLazy(inst._zod, "pattern", () => {
1922
- const pattern = def.innerType._zod.pattern;
2414
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2415
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2416
+ defineLazyInternal(inst, "pattern", (zod) => {
2417
+ const pattern = zod.def.innerType._zod.pattern;
1923
2418
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1924
2419
  });
1925
- defineLazy(inst._zod, "values", () => {
1926
- return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
2420
+ defineLazyInternal(inst, "values", (zod) => {
2421
+ return zod.def.innerType._zod.values ? new Set([...zod.def.innerType._zod.values, null]) : void 0;
1927
2422
  });
1928
2423
  inst._zod.parse = (payload, ctx) => {
1929
2424
  if (payload.value === null) return payload;
@@ -1932,8 +2427,8 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1932
2427
  });
1933
2428
  const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
1934
2429
  $ZodType.init(inst, def);
1935
- inst._zod.optin = "optional";
1936
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2430
+ inst._zod.optin = "defaulted";
2431
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1937
2432
  inst._zod.parse = (payload, ctx) => {
1938
2433
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1939
2434
  if (payload.value === void 0) {
@@ -1954,8 +2449,8 @@ function handleDefaultResult(payload, def) {
1954
2449
  }
1955
2450
  const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
1956
2451
  $ZodType.init(inst, def);
1957
- inst._zod.optin = "optional";
1958
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2452
+ inst._zod.optin = "defaulted";
2453
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1959
2454
  inst._zod.parse = (payload, ctx) => {
1960
2455
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1961
2456
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -1964,8 +2459,8 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
1964
2459
  });
1965
2460
  const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
1966
2461
  $ZodType.init(inst, def);
1967
- defineLazy(inst._zod, "values", () => {
1968
- const v = def.innerType._zod.values;
2462
+ defineLazyInternal(inst, "values", (zod) => {
2463
+ const v = zod.def.innerType._zod.values;
1969
2464
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1970
2465
  });
1971
2466
  inst._zod.parse = (payload, ctx) => {
@@ -1983,46 +2478,41 @@ function handleNonOptionalResult(payload, inst) {
1983
2478
  });
1984
2479
  return payload;
1985
2480
  }
2481
+ function handleCatchResult(payload, result, def, ctx) {
2482
+ if (!result.issues.length) {
2483
+ payload.value = result.value;
2484
+ if (result.memo) payload.memo = true;
2485
+ return payload;
2486
+ }
2487
+ payload.value = def.catchValue({
2488
+ ...result,
2489
+ value: payload.value,
2490
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2491
+ input: payload.value
2492
+ });
2493
+ return payload;
2494
+ }
1986
2495
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
1987
2496
  $ZodType.init(inst, def);
1988
- inst._zod.optin = "optional";
1989
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1990
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2497
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2498
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2499
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
1991
2500
  inst._zod.parse = (payload, ctx) => {
1992
2501
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
1993
- const result = def.innerType._zod.run(payload, ctx);
1994
- if (result instanceof Promise) return result.then((result) => {
1995
- payload.value = result.value;
1996
- if (result.issues.length) {
1997
- payload.value = def.catchValue({
1998
- ...payload,
1999
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2000
- input: payload.value
2001
- });
2002
- payload.issues = [];
2003
- payload.fallback = true;
2004
- }
2005
- return payload;
2006
- });
2007
- payload.value = result.value;
2008
- if (result.issues.length) {
2009
- payload.value = def.catchValue({
2010
- ...payload,
2011
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2012
- input: payload.value
2013
- });
2014
- payload.issues = [];
2015
- payload.fallback = true;
2016
- }
2017
- return payload;
2502
+ const result = def.innerType._zod.run({
2503
+ value: payload.value,
2504
+ issues: []
2505
+ }, ctx);
2506
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
2507
+ return handleCatchResult(payload, result, def, ctx);
2018
2508
  };
2019
2509
  });
2020
2510
  const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2021
2511
  $ZodType.init(inst, def);
2022
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2023
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2024
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2025
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2512
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2513
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2514
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2515
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2026
2516
  inst._zod.parse = (payload, ctx) => {
2027
2517
  if (ctx.direction === "backward") {
2028
2518
  const right = def.out._zod.run(payload, ctx);
@@ -2035,22 +2525,21 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2035
2525
  };
2036
2526
  });
2037
2527
  function handlePipeResult(left, next, ctx) {
2038
- if (left.issues.length) {
2528
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2039
2529
  left.aborted = true;
2040
2530
  return left;
2041
2531
  }
2042
2532
  return next._zod.run({
2043
2533
  value: left.value,
2044
- issues: left.issues,
2045
- fallback: left.fallback
2534
+ issues: left.issues
2046
2535
  }, ctx);
2047
2536
  }
2048
2537
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2049
2538
  $ZodType.init(inst, def);
2050
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2051
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2052
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2053
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2539
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2540
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2541
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2542
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2054
2543
  inst._zod.parse = (payload, ctx) => {
2055
2544
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2056
2545
  const result = def.innerType._zod.run(payload, ctx);
@@ -2059,7 +2548,7 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2059
2548
  };
2060
2549
  });
2061
2550
  function handleReadonlyResult(payload) {
2062
- payload.value = Object.freeze(payload.value);
2551
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
2063
2552
  return payload;
2064
2553
  }
2065
2554
  const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
@@ -2089,7 +2578,368 @@ function handleRefineResult(result, payload, input, inst) {
2089
2578
  }
2090
2579
  }
2091
2580
  //#endregion
2092
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
2581
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
2582
+ var $ZodCyclicError = class extends Error {
2583
+ constructor() {
2584
+ super(`Cannot parse a reference cycle that closes through a transform`);
2585
+ this.name = "ZodCyclicError";
2586
+ }
2587
+ };
2588
+ /** Keyed off the context object every schema in one parse call already shares. */
2589
+ const STATE = "~memo";
2590
+ const NO_ISSUES = [];
2591
+ function isRef(value) {
2592
+ return value !== null && typeof value === "object";
2593
+ }
2594
+ function cloneIssues(issues) {
2595
+ return issues.map((iss) => iss.path ? {
2596
+ ...iss,
2597
+ path: iss.path.slice()
2598
+ } : { ...iss });
2599
+ }
2600
+ const recursive = /*@__PURE__*/ new WeakMap();
2601
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
2602
+ const NONE = 0;
2603
+ const ASSUMED = 1;
2604
+ const PROVEN = 2;
2605
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
2606
+ function isRecursive(inst, stack, resolve) {
2607
+ const cached = recursive.get(inst);
2608
+ if (cached !== void 0) return cached ? PROVEN : NONE;
2609
+ if (stack.has(inst)) return PROVEN;
2610
+ stack.add(inst);
2611
+ let result = NONE;
2612
+ const check = (child) => {
2613
+ if (result !== PROVEN && child?._zod) {
2614
+ const answer = isRecursive(child, stack, resolve);
2615
+ if (answer > result) result = answer;
2616
+ }
2617
+ };
2618
+ const shape = (sh, spread) => {
2619
+ let answer = NONE;
2620
+ for (const key of Reflect.ownKeys(sh)) {
2621
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
2622
+ if (spread && !desc.enumerable) continue;
2623
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
2624
+ if (child > answer) answer = child;
2625
+ }
2626
+ return answer;
2627
+ };
2628
+ const merge = (answer) => {
2629
+ if (answer > result) result = answer;
2630
+ };
2631
+ const def = inst._zod.def;
2632
+ switch (def.type) {
2633
+ case "object": {
2634
+ const raw = rawShape(def);
2635
+ merge(raw ? shape(raw, true) : ASSUMED);
2636
+ check(def.catchall);
2637
+ break;
2638
+ }
2639
+ case "array":
2640
+ check(def.element);
2641
+ break;
2642
+ case "tuple":
2643
+ for (const el of def.items) check(el);
2644
+ check(def.rest);
2645
+ break;
2646
+ case "record":
2647
+ case "map":
2648
+ check(def.keyType);
2649
+ check(def.valueType);
2650
+ break;
2651
+ case "set":
2652
+ check(def.valueType);
2653
+ break;
2654
+ case "union":
2655
+ for (const el of def.options) check(el);
2656
+ break;
2657
+ case "intersection":
2658
+ check(def.left);
2659
+ check(def.right);
2660
+ break;
2661
+ case "optional":
2662
+ case "nullable":
2663
+ case "default":
2664
+ case "prefault":
2665
+ case "catch":
2666
+ case "readonly":
2667
+ case "nonoptional":
2668
+ case "promise":
2669
+ case "success":
2670
+ check(def.innerType);
2671
+ break;
2672
+ case "pipe":
2673
+ check(def.in);
2674
+ check(def.out);
2675
+ break;
2676
+ case "function":
2677
+ check(def.input);
2678
+ check(def.output);
2679
+ break;
2680
+ case "lazy": {
2681
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
2682
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
2683
+ break;
2684
+ }
2685
+ case "template_literal":
2686
+ case "string":
2687
+ case "number":
2688
+ case "int":
2689
+ case "boolean":
2690
+ case "bigint":
2691
+ case "symbol":
2692
+ case "undefined":
2693
+ case "null":
2694
+ case "void":
2695
+ case "never":
2696
+ case "any":
2697
+ case "unknown":
2698
+ case "date":
2699
+ case "nan":
2700
+ case "enum":
2701
+ case "literal":
2702
+ case "file":
2703
+ case "transform":
2704
+ case "custom": break;
2705
+ default: for (const key in def) {
2706
+ const desc = Object.getOwnPropertyDescriptor(def, key);
2707
+ if (!desc || desc.get) continue;
2708
+ const value = desc.value;
2709
+ if (!value || typeof value !== "object") continue;
2710
+ if (value._zod) check(value);
2711
+ else if (Array.isArray(value)) for (const el of value) check(el);
2712
+ }
2713
+ }
2714
+ stack.delete(inst);
2715
+ return settle(inst, result);
2716
+ }
2717
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
2718
+ function settle(inst, answer) {
2719
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
2720
+ return answer;
2721
+ }
2722
+ function bucketFor(state, inst) {
2723
+ let bucket = state.buckets.get(inst);
2724
+ if (!bucket) {
2725
+ bucket = /* @__PURE__ */ new WeakMap();
2726
+ state.buckets.set(inst, bucket);
2727
+ }
2728
+ return bucket;
2729
+ }
2730
+ let handoff;
2731
+ const open = [];
2732
+ const memo = {
2733
+ alloc(_inst, payload, empty) {
2734
+ const bucket = handoff;
2735
+ if (!bucket) return empty;
2736
+ handoff = void 0;
2737
+ const entry = {
2738
+ value: empty,
2739
+ issues: null
2740
+ };
2741
+ bucket.set(payload.value, entry);
2742
+ open.push(entry);
2743
+ return empty;
2744
+ },
2745
+ guard(inst) {
2746
+ var _a;
2747
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2748
+ inst._zod.deferred.push(() => {
2749
+ const base = inst._zod.parse;
2750
+ const wrapped = (payload, ctx) => {
2751
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
2752
+ return base(payload, ctx);
2753
+ };
2754
+ inst._zod.parse = wrapped;
2755
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2756
+ });
2757
+ },
2758
+ attach(inst) {
2759
+ var _a;
2760
+ let isRecursiveInst;
2761
+ let rechecked = false;
2762
+ let lastCtx;
2763
+ let lastBucket;
2764
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2765
+ inst._zod.deferred.push(() => {
2766
+ const base = inst._zod.parse;
2767
+ const wrapped = (payload, ctx) => {
2768
+ if (isRecursiveInst === void 0) {
2769
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
2770
+ if (walked === NONE) {
2771
+ inst._zod.parse = base;
2772
+ if (inst._zod.run === wrapped) inst._zod.run = base;
2773
+ return base(payload, ctx);
2774
+ }
2775
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
2776
+ else rechecked = true;
2777
+ }
2778
+ const input = payload.value;
2779
+ if (!isRef(input)) return base(payload, ctx);
2780
+ let state = ctx[STATE];
2781
+ if (!state) {
2782
+ state = {
2783
+ buckets: /* @__PURE__ */ new WeakMap(),
2784
+ backEdges: void 0
2785
+ };
2786
+ ctx[STATE] = state;
2787
+ }
2788
+ let bucket;
2789
+ if (lastCtx === ctx) bucket = lastBucket;
2790
+ else {
2791
+ bucket = bucketFor(state, inst);
2792
+ lastCtx = ctx;
2793
+ lastBucket = bucket;
2794
+ }
2795
+ const hit = bucket.get(input);
2796
+ if (hit) {
2797
+ payload.value = hit.value;
2798
+ if (hit.issues) {
2799
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
2800
+ } else {
2801
+ payload.memo = true;
2802
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
2803
+ state.backEdges.add(hit.value);
2804
+ }
2805
+ return payload;
2806
+ }
2807
+ handoff = bucket;
2808
+ const depth = open.length;
2809
+ const result = base(payload, ctx);
2810
+ handoff = void 0;
2811
+ const entry = open.length > depth ? open.pop() : void 0;
2812
+ if (result instanceof Promise) return result.then((r) => {
2813
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
2814
+ return r;
2815
+ });
2816
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
2817
+ return result;
2818
+ };
2819
+ inst._zod.parse = wrapped;
2820
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2821
+ });
2822
+ }
2823
+ };
2824
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
2825
+ function memoizer() {
2826
+ return memo;
2827
+ }
2828
+ /** Whether this value is a node a back-edge resolved to before it finished. */
2829
+ function isBackEdge(ctx, value) {
2830
+ const backEdges = ctx[STATE]?.backEdges;
2831
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
2832
+ }
2833
+ //#endregion
2834
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/en.js
2835
+ const error = () => {
2836
+ const Sizable = {
2837
+ string: {
2838
+ unit: "characters",
2839
+ verb: "to have"
2840
+ },
2841
+ file: {
2842
+ unit: "bytes",
2843
+ verb: "to have"
2844
+ },
2845
+ array: {
2846
+ unit: "items",
2847
+ verb: "to have"
2848
+ },
2849
+ set: {
2850
+ unit: "items",
2851
+ verb: "to have"
2852
+ },
2853
+ map: {
2854
+ unit: "entries",
2855
+ verb: "to have"
2856
+ }
2857
+ };
2858
+ function getSizing(origin) {
2859
+ return Sizable[origin] ?? null;
2860
+ }
2861
+ const FormatDictionary = {
2862
+ regex: "input",
2863
+ email: "email address",
2864
+ url: "URL",
2865
+ emoji: "emoji",
2866
+ uuid: "UUID",
2867
+ uuidv4: "UUIDv4",
2868
+ uuidv6: "UUIDv6",
2869
+ nanoid: "nanoid",
2870
+ guid: "GUID",
2871
+ cuid: "cuid",
2872
+ cuid2: "cuid2",
2873
+ ulid: "ULID",
2874
+ xid: "XID",
2875
+ ksuid: "KSUID",
2876
+ datetime: "ISO datetime",
2877
+ date: "ISO date",
2878
+ time: "ISO time",
2879
+ duration: "ISO duration",
2880
+ ipv4: "IPv4 address",
2881
+ ipv6: "IPv6 address",
2882
+ mac: "MAC address",
2883
+ cidrv4: "IPv4 range",
2884
+ cidrv6: "IPv6 range",
2885
+ base64: "base64-encoded string",
2886
+ base64url: "base64url-encoded string",
2887
+ json_string: "JSON string",
2888
+ e164: "E.164 number",
2889
+ currency_code: "currency code",
2890
+ credit_card: "credit card number",
2891
+ iban: "IBAN",
2892
+ jwt: "JWT",
2893
+ template_literal: "input"
2894
+ };
2895
+ const TypeDictionary = { nan: "NaN" };
2896
+ function getTypeName(type, input) {
2897
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
2898
+ return TypeDictionary[type] ?? type;
2899
+ }
2900
+ return (issue) => {
2901
+ switch (issue.code) {
2902
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
2903
+ case "invalid_value":
2904
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
2905
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
2906
+ case "too_big": {
2907
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
2908
+ const sizing = getSizing(issue.origin);
2909
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
2910
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
2911
+ }
2912
+ case "too_small": {
2913
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
2914
+ const sizing = getSizing(issue.origin);
2915
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
2916
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
2917
+ }
2918
+ case "invalid_format": {
2919
+ const _issue = issue;
2920
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
2921
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
2922
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
2923
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
2924
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
2925
+ }
2926
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
2927
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
2928
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
2929
+ case "invalid_union":
2930
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
2931
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
2932
+ return "Invalid input";
2933
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
2934
+ default: return `Invalid input`;
2935
+ }
2936
+ };
2937
+ };
2938
+ function en_default() {
2939
+ return { localeError: error() };
2940
+ }
2941
+ //#endregion
2942
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
2093
2943
  var _a;
2094
2944
  var $ZodRegistry = class {
2095
2945
  constructor() {
@@ -2136,13 +2986,17 @@ function registry() {
2136
2986
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2137
2987
  const globalRegistry = globalThis.__zod_globalRegistry;
2138
2988
  //#endregion
2139
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
2989
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/api.js
2990
+ function snapshotChecks(def) {
2991
+ if (def.checks) def.checks = [...def.checks];
2992
+ return def;
2993
+ }
2140
2994
  // @__NO_SIDE_EFFECTS__
2141
2995
  function _string(Class, params) {
2142
- return new Class({
2996
+ return new Class(snapshotChecks({
2143
2997
  type: "string",
2144
2998
  ...normalizeParams(params)
2145
- });
2999
+ }));
2146
3000
  }
2147
3001
  // @__NO_SIDE_EFFECTS__
2148
3002
  function _email(Class, params) {
@@ -2414,11 +3268,11 @@ function _isoDuration(Class, params) {
2414
3268
  }
2415
3269
  // @__NO_SIDE_EFFECTS__
2416
3270
  function _number(Class, params) {
2417
- return new Class({
3271
+ return new Class(snapshotChecks({
2418
3272
  type: "number",
2419
3273
  checks: [],
2420
3274
  ...normalizeParams(params)
2421
- });
3275
+ }));
2422
3276
  }
2423
3277
  // @__NO_SIDE_EFFECTS__
2424
3278
  function _int(Class, params) {
@@ -2614,7 +3468,7 @@ function _superRefine(fn, params) {
2614
3468
  const _issue = issue$2;
2615
3469
  if (_issue.fatal) _issue.continue = false;
2616
3470
  _issue.code ?? (_issue.code = "custom");
2617
- _issue.input ?? (_issue.input = payload.value);
3471
+ if (!("input" in _issue)) _issue.input = payload.value;
2618
3472
  _issue.inst ?? (_issue.inst = ch);
2619
3473
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2620
3474
  payload.issues.push(issue(_issue));
@@ -2634,7 +3488,11 @@ function _check(fn, params) {
2634
3488
  return ch;
2635
3489
  }
2636
3490
  //#endregion
2637
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
3491
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
3492
+ function assignProps(target, ...sources) {
3493
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
3494
+ return target;
3495
+ }
2638
3496
  function initializeContext(params) {
2639
3497
  let target = params?.target ?? "draft-2020-12";
2640
3498
  if (target === "draft-4") target = "draft-04";
@@ -2648,12 +3506,32 @@ function initializeContext(params) {
2648
3506
  io: params?.io ?? "output",
2649
3507
  counter: 0,
2650
3508
  seen: /* @__PURE__ */ new Map(),
3509
+ sharedDefsExtractedFor: void 0,
3510
+ sharedEmitDoneFor: void 0,
2651
3511
  cycles: params?.cycles ?? "ref",
2652
3512
  reused: params?.reused ?? "inline",
3513
+ intersections: [],
3514
+ deferred: [],
2653
3515
  external: params?.external ?? void 0
2654
3516
  };
2655
3517
  }
2656
- function process(schema, ctx, _params = {
3518
+ /**
3519
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
3520
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
3521
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
3522
+ */
3523
+ function handleUnrepresentable(schema, ctx, json, params, message) {
3524
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
3525
+ zodSchema: schema,
3526
+ path: params.path,
3527
+ message
3528
+ }) : ctx.unrepresentable;
3529
+ if (result === "any") return false;
3530
+ if (result === void 0 || result === "throw") throw new Error(message);
3531
+ Object.assign(json, result);
3532
+ return true;
3533
+ }
3534
+ function processSchema(schema, ctx, _params = {
2657
3535
  path: [],
2658
3536
  schemaPath: []
2659
3537
  }) {
@@ -2672,6 +3550,8 @@ function process(schema, ctx, _params = {
2672
3550
  path: _params.path
2673
3551
  };
2674
3552
  ctx.seen.set(schema, result);
3553
+ ctx.sharedDefsExtractedFor = void 0;
3554
+ ctx.sharedEmitDoneFor = void 0;
2675
3555
  const overrideSchema = schema._zod.toJSONSchema?.();
2676
3556
  if (overrideSchema) result.schema = overrideSchema;
2677
3557
  else {
@@ -2690,12 +3570,12 @@ function process(schema, ctx, _params = {
2690
3570
  const parent = schema._zod.parent;
2691
3571
  if (parent) {
2692
3572
  if (!result.ref) result.ref = parent;
2693
- process(parent, ctx, params);
3573
+ processSchema(parent, ctx, params);
2694
3574
  ctx.seen.get(parent).isParent = true;
2695
3575
  }
2696
3576
  }
2697
3577
  const meta = ctx.metadataRegistry.get(schema);
2698
- if (meta) Object.assign(result.schema, meta);
3578
+ if (meta) assignProps(result.schema, meta);
2699
3579
  if (ctx.io === "input" && isTransforming(schema)) {
2700
3580
  delete result.schema.examples;
2701
3581
  delete result.schema.default;
@@ -2704,9 +3584,13 @@ function process(schema, ctx, _params = {
2704
3584
  delete result.schema._prefault;
2705
3585
  return ctx.seen.get(schema).schema;
2706
3586
  }
3587
+ function encodeJSONPointerSegment(segment) {
3588
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
3589
+ }
2707
3590
  function extractDefs(ctx, schema) {
2708
3591
  const root = ctx.seen.get(schema);
2709
3592
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3593
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
2710
3594
  const idToSchema = /* @__PURE__ */ new Map();
2711
3595
  for (const entry of ctx.seen.entries()) {
2712
3596
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -2726,15 +3610,16 @@ function extractDefs(ctx, schema) {
2726
3610
  entry[1].defId = id;
2727
3611
  return {
2728
3612
  defId: id,
2729
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3613
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
2730
3614
  };
2731
3615
  }
2732
- if (entry[1] === root) return { ref: "#" };
2733
- const defUriPrefix = `#/${defsSegment}/`;
3616
+ const uriPrefix = `#`;
3617
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3618
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
2734
3619
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2735
3620
  return {
2736
3621
  defId,
2737
- ref: defUriPrefix + defId
3622
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
2738
3623
  };
2739
3624
  };
2740
3625
  const extractToDef = (entry) => {
@@ -2775,12 +3660,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
2775
3660
  continue;
2776
3661
  }
2777
3662
  if (seen.count > 1) {
2778
- if (ctx.reused === "ref") {
2779
- extractToDef(entry);
2780
- continue;
3663
+ if (ctx.reused === "ref") extractToDef(entry);
3664
+ }
3665
+ }
3666
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
3667
+ }
3668
+ /** 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. */
3669
+ function compactTypeUnion(schema) {
3670
+ const options = schema.anyOf;
3671
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
3672
+ const types = [];
3673
+ for (const option of options) {
3674
+ if (!option || typeof option !== "object") return;
3675
+ compactTypeUnion(option);
3676
+ const keys = Object.keys(option);
3677
+ if (keys.length !== 1 || keys[0] !== "type") return;
3678
+ const type = option.type;
3679
+ for (const member of Array.isArray(type) ? type : [type]) {
3680
+ if (typeof member !== "string") return;
3681
+ if (!types.includes(member)) types.push(member);
3682
+ }
3683
+ }
3684
+ delete schema.anyOf;
3685
+ schema.type = types.length === 1 ? types[0] : types;
3686
+ }
3687
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
3688
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
3689
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
3690
+ const FOLDABLE_KEYS = new Set([
3691
+ "type",
3692
+ "properties",
3693
+ "required",
3694
+ "additionalProperties"
3695
+ ]);
3696
+ const UNION_KEYS = ["oneOf", "anyOf"];
3697
+ /** 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. */
3698
+ function undeclaredConstraint(member) {
3699
+ const extra = member.additionalProperties;
3700
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
3701
+ return Object.keys(extra).length ? extra : null;
3702
+ }
3703
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
3704
+ function foldObjects(members) {
3705
+ const objects = [];
3706
+ for (const member of members) {
3707
+ if (typeof member !== "object" || member.type !== "object") return null;
3708
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
3709
+ objects.push(member);
3710
+ }
3711
+ const properties = {};
3712
+ const required = /* @__PURE__ */ new Set();
3713
+ for (const object of objects) {
3714
+ for (const key in object.properties) {
3715
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
3716
+ const parts = [];
3717
+ for (const other of objects) {
3718
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
3719
+ if (part === null || part === void 0) continue;
3720
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
2781
3721
  }
3722
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
3723
+ }
3724
+ for (const key of object.required ?? []) required.add(key);
3725
+ }
3726
+ const folded = {
3727
+ type: "object",
3728
+ properties
3729
+ };
3730
+ if (required.size) folded.required = [...required];
3731
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
3732
+ else {
3733
+ const constraints = [];
3734
+ for (const object of objects) {
3735
+ const constraint = undeclaredConstraint(object);
3736
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
2782
3737
  }
3738
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
3739
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
2783
3740
  }
3741
+ return folded;
3742
+ }
3743
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
3744
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
3745
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
3746
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
3747
+ * into one object is the encoding that says so on every target.
3748
+ *
3749
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
3750
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
3751
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
3752
+ function foldIntersection(json) {
3753
+ const allOf = json.allOf;
3754
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
3755
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
3756
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
3757
+ let folded = null;
3758
+ if (!unions.length) folded = foldObjects(allOf);
3759
+ else {
3760
+ const union = unions[0];
3761
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
3762
+ if (Object.keys(union).length !== 1) return;
3763
+ const rest = allOf.filter((m) => m !== union);
3764
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
3765
+ if (branches.some((b) => !b)) return;
3766
+ folded = { [keyword]: branches };
3767
+ }
3768
+ if (!folded) return;
3769
+ delete json.allOf;
3770
+ assignProps(json, folded);
2784
3771
  }
2785
3772
  function finalize(ctx, schema) {
2786
3773
  const root = ctx.seen.get(schema);
@@ -2799,8 +3786,8 @@ function finalize(ctx, schema) {
2799
3786
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2800
3787
  schema.allOf = schema.allOf ?? [];
2801
3788
  schema.allOf.push(refSchema);
2802
- } else Object.assign(schema, refSchema);
2803
- Object.assign(schema, _cached);
3789
+ } else assignProps(schema, refSchema);
3790
+ assignProps(schema, _cached);
2804
3791
  if (zodSchema._zod.parent === ref) for (const key in schema) {
2805
3792
  if (key === "$ref" || key === "allOf") continue;
2806
3793
  if (!(key in _cached)) delete schema[key];
@@ -2828,7 +3815,22 @@ function finalize(ctx, schema) {
2828
3815
  path: seen.path ?? []
2829
3816
  });
2830
3817
  };
2831
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3818
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
3819
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3820
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
3821
+ for (const rewrite of ctx.deferred) rewrite();
3822
+ if (ctx.intersections.length) {
3823
+ const carriers = /* @__PURE__ */ new Map();
3824
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
3825
+ const allOf = json?.allOf;
3826
+ if (!Array.isArray(allOf)) continue;
3827
+ const existing = carriers.get(allOf);
3828
+ if (existing) existing.push(json);
3829
+ else carriers.set(allOf, [json]);
3830
+ }
3831
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
3832
+ }
3833
+ }
2832
3834
  const result = {};
2833
3835
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2834
3836
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -2839,17 +3841,18 @@ function finalize(ctx, schema) {
2839
3841
  if (!id) throw new Error("Schema is missing an `id` property");
2840
3842
  result.$id = ctx.external.uri(id);
2841
3843
  }
2842
- Object.assign(result, root.def ?? root.schema);
3844
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
2843
3845
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2844
3846
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2845
3847
  const defs = ctx.external?.defs ?? {};
2846
- for (const entry of ctx.seen.entries()) {
3848
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
2847
3849
  const seen = entry[1];
2848
3850
  if (seen.def && seen.defId) {
2849
3851
  if (seen.def.id === seen.defId) delete seen.def.id;
2850
- defs[seen.defId] = seen.def;
3852
+ assignProp(defs, seen.defId, seen.def);
2851
3853
  }
2852
3854
  }
3855
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
2853
3856
  if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2854
3857
  else result.definitions = defs;
2855
3858
  try {
@@ -2879,7 +3882,7 @@ function isTransforming(_schema, _ctx) {
2879
3882
  if (def.type === "array") return isTransforming(def.element, ctx);
2880
3883
  if (def.type === "set") return isTransforming(def.valueType, ctx);
2881
3884
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2882
- 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);
3885
+ 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);
2883
3886
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2884
3887
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2885
3888
  if (def.type === "pipe") {
@@ -2910,7 +3913,7 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2910
3913
  ...params,
2911
3914
  processors
2912
3915
  });
2913
- process(schema, ctx);
3916
+ processSchema(schema, ctx);
2914
3917
  extractDefs(ctx, schema);
2915
3918
  return finalize(ctx, schema);
2916
3919
  };
@@ -2922,12 +3925,84 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
2922
3925
  io,
2923
3926
  processors
2924
3927
  });
2925
- process(schema, ctx);
3928
+ processSchema(schema, ctx);
2926
3929
  extractDefs(ctx, schema);
2927
3930
  return finalize(ctx, schema);
2928
3931
  };
2929
3932
  //#endregion
2930
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
3933
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
3934
+ const narrowMin = (agg, key, value) => {
3935
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
3936
+ };
3937
+ const narrowMax = (agg, key, value) => {
3938
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
3939
+ };
3940
+ const narrowBoth = (agg, value) => {
3941
+ narrowMin(agg, "minimum", value);
3942
+ narrowMax(agg, "maximum", value);
3943
+ };
3944
+ const addDivisor = (agg, value) => {
3945
+ agg.multipleOf ?? (agg.multipleOf = []);
3946
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
3947
+ };
3948
+ const addPattern = (agg, pattern) => {
3949
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
3950
+ agg.patterns.add(pattern);
3951
+ };
3952
+ const intersectMime = (agg, mime) => {
3953
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
3954
+ };
3955
+ const setFormat = (agg, format) => {
3956
+ agg.format = format;
3957
+ if (format.includes("int")) agg.isInt = true;
3958
+ };
3959
+ const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
3960
+ const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
3961
+ const formatContributor = (ranges) => (agg, def) => {
3962
+ setFormat(agg, def.format);
3963
+ const [minimum, maximum] = ranges[def.format];
3964
+ narrowMin(agg, "minimum", minimum);
3965
+ narrowMax(agg, "maximum", maximum);
3966
+ };
3967
+ const contributors = {
3968
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
3969
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
3970
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
3971
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
3972
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
3973
+ min_length: minContributor,
3974
+ max_length: maxContributor,
3975
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
3976
+ min_size: minContributor,
3977
+ max_size: maxContributor,
3978
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
3979
+ string_format: (agg, def) => {
3980
+ setFormat(agg, def.format);
3981
+ if (def.pattern) addPattern(agg, def.pattern);
3982
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
3983
+ if (def.local || def.precision === -1) agg.laxFormat = true;
3984
+ },
3985
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
3986
+ };
3987
+ function aggregateChecks(schema) {
3988
+ const agg = {};
3989
+ const def = schema._zod.def;
3990
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
3991
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
3992
+ const bag = schema._zod.bag;
3993
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
3994
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
3995
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
3996
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
3997
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
3998
+ if (bag.format !== void 0) {
3999
+ agg.format ?? (agg.format = bag.format);
4000
+ if (bag.format.includes("int")) agg.isInt = true;
4001
+ }
4002
+ if (bag.mime) intersectMime(agg, bag.mime);
4003
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
4004
+ return agg;
4005
+ }
2931
4006
  const formatMap = {
2932
4007
  guid: "uuid",
2933
4008
  url: "uri",
@@ -2935,32 +4010,33 @@ const formatMap = {
2935
4010
  json_string: "json-string",
2936
4011
  regex: ""
2937
4012
  };
4013
+ const exactPatterns = new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
4014
+ const exactPattern = (p) => exactPatterns.get(p) ?? p;
2938
4015
  const stringProcessor = (schema, ctx, _json, _params) => {
2939
4016
  const json = _json;
2940
4017
  json.type = "string";
2941
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
4018
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
2942
4019
  if (typeof minimum === "number") json.minLength = minimum;
2943
4020
  if (typeof maximum === "number") json.maxLength = maximum;
2944
4021
  if (format) {
2945
4022
  json.format = formatMap[format] ?? format;
2946
4023
  if (json.format === "") delete json.format;
2947
- if (format === "time") delete json.format;
4024
+ if (format === "time" || laxFormat) delete json.format;
2948
4025
  }
2949
4026
  if (contentEncoding) json.contentEncoding = contentEncoding;
2950
4027
  if (patterns && patterns.size > 0) {
2951
- const regexes = [...patterns];
2952
- if (regexes.length === 1) json.pattern = regexes[0].source;
2953
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
4028
+ const patternList = [...patterns].map(exactPattern);
4029
+ if (patternList.length === 1) json.pattern = patternList[0].source;
4030
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
2954
4031
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
2955
4032
  pattern: regex.source
2956
4033
  }))];
2957
4034
  }
2958
4035
  };
2959
- const numberProcessor = (schema, ctx, _json, _params) => {
4036
+ const numberProcessor = (schema, ctx, _json, params) => {
2960
4037
  const json = _json;
2961
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
2962
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
2963
- else json.type = "number";
4038
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
4039
+ json.type = isInt ? "integer" : "number";
2964
4040
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
2965
4041
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
2966
4042
  const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
@@ -2974,7 +4050,14 @@ const numberProcessor = (schema, ctx, _json, _params) => {
2974
4050
  json.exclusiveMaximum = true;
2975
4051
  } else json.exclusiveMaximum = exclusiveMaximum;
2976
4052
  else if (typeof maximum === "number") json.maximum = maximum;
2977
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
4053
+ if (multipleOf) {
4054
+ const divisors = /* @__PURE__ */ new Set();
4055
+ for (const divisor of multipleOf) if (Number.isFinite(divisor) && divisor !== 0) divisors.add(Math.abs(divisor));
4056
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
4057
+ const [first, ...rest] = divisors;
4058
+ if (first !== void 0) json.multipleOf = first;
4059
+ if (rest.length) json.allOf = [...json.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
4060
+ }
2978
4061
  };
2979
4062
  const neverProcessor = (_schema, _ctx, json, _params) => {
2980
4063
  json.not = {};
@@ -2982,53 +4065,63 @@ const neverProcessor = (_schema, _ctx, json, _params) => {
2982
4065
  const enumProcessor = (schema, _ctx, json, _params) => {
2983
4066
  const def = schema._zod.def;
2984
4067
  const values = getEnumValues(def.entries);
4068
+ if (values.length === 0) {
4069
+ json.not = {};
4070
+ return;
4071
+ }
2985
4072
  if (values.every((v) => typeof v === "number")) json.type = "number";
2986
4073
  if (values.every((v) => typeof v === "string")) json.type = "string";
2987
4074
  json.enum = values;
2988
4075
  };
2989
- const customProcessor = (_schema, ctx, _json, _params) => {
2990
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4076
+ const customProcessor = (schema, ctx, json, params) => {
4077
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
2991
4078
  };
2992
- const transformProcessor = (_schema, ctx, _json, _params) => {
2993
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4079
+ const transformProcessor = (schema, ctx, json, params) => {
4080
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
2994
4081
  };
2995
4082
  const arrayProcessor = (schema, ctx, _json, params) => {
2996
4083
  const json = _json;
2997
4084
  const def = schema._zod.def;
2998
- const { minimum, maximum } = schema._zod.bag;
4085
+ const { minimum, maximum } = aggregateChecks(schema);
2999
4086
  if (typeof minimum === "number") json.minItems = minimum;
3000
4087
  if (typeof maximum === "number") json.maxItems = maximum;
3001
4088
  json.type = "array";
3002
- json.items = process(def.element, ctx, {
4089
+ json.items = processSchema(def.element, ctx, {
3003
4090
  ...params,
3004
4091
  path: [...params.path, "items"]
3005
4092
  });
3006
4093
  };
4094
+ function inputOptin(schema) {
4095
+ const def = schema._zod.def;
4096
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
4097
+ if (def.type === "catch") return inputOptin(def.innerType);
4098
+ return schema._zod.optin;
4099
+ }
3007
4100
  const objectProcessor = (schema, ctx, _json, params) => {
3008
4101
  const json = _json;
3009
4102
  const def = schema._zod.def;
4103
+ const shape = def.shape;
4104
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
3010
4105
  json.type = "object";
3011
4106
  json.properties = {};
3012
- const shape = def.shape;
3013
- for (const key in shape) json.properties[key] = process(shape[key], ctx, {
4107
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
3014
4108
  ...params,
3015
4109
  path: [
3016
4110
  ...params.path,
3017
4111
  "properties",
3018
4112
  key
3019
4113
  ]
3020
- });
3021
- const allKeys = new Set(Object.keys(shape));
3022
- const requiredKeys = new Set([...allKeys].filter((key) => {
3023
- const v = def.shape[key]._zod;
3024
- if (ctx.io === "input") return v.optin === void 0;
3025
- else return v.optout === void 0;
3026
4114
  }));
3027
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
4115
+ const requiredKeys = [];
4116
+ for (const key of Object.keys(shape)) {
4117
+ const field = def.shape[key];
4118
+ if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
4119
+ }
4120
+ if (requiredKeys.length > 0) json.required = requiredKeys;
3028
4121
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3029
4122
  else if (!def.catchall) {
3030
4123
  if (ctx.io === "output") json.additionalProperties = false;
3031
- } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
4124
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
3032
4125
  ...params,
3033
4126
  path: [...params.path, "additionalProperties"]
3034
4127
  });
@@ -3036,7 +4129,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
3036
4129
  const unionProcessor = (schema, ctx, json, params) => {
3037
4130
  const def = schema._zod.def;
3038
4131
  const isExclusive = def.inclusive === false;
3039
- const options = def.options.map((x, i) => process(x, ctx, {
4132
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
3040
4133
  ...params,
3041
4134
  path: [
3042
4135
  ...params.path,
@@ -3049,7 +4142,7 @@ const unionProcessor = (schema, ctx, json, params) => {
3049
4142
  };
3050
4143
  const intersectionProcessor = (schema, ctx, json, params) => {
3051
4144
  const def = schema._zod.def;
3052
- const a = process(def.left, ctx, {
4145
+ const a = processSchema(def.left, ctx, {
3053
4146
  ...params,
3054
4147
  path: [
3055
4148
  ...params.path,
@@ -3057,7 +4150,7 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3057
4150
  0
3058
4151
  ]
3059
4152
  });
3060
- const b = process(def.right, ctx, {
4153
+ const b = processSchema(def.right, ctx, {
3061
4154
  ...params,
3062
4155
  path: [
3063
4156
  ...params.path,
@@ -3066,11 +4159,13 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3066
4159
  ]
3067
4160
  });
3068
4161
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3069
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4162
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4163
+ json.allOf = allOf;
4164
+ ctx.intersections.push(allOf);
3070
4165
  };
3071
4166
  const nullableProcessor = (schema, ctx, json, params) => {
3072
4167
  const def = schema._zod.def;
3073
- const inner = process(def.innerType, ctx, params);
4168
+ const inner = processSchema(def.innerType, ctx, params);
3074
4169
  const seen = ctx.seen.get(schema);
3075
4170
  if (ctx.target === "openapi-3.0") {
3076
4171
  seen.ref = def.innerType;
@@ -3079,34 +4174,53 @@ const nullableProcessor = (schema, ctx, json, params) => {
3079
4174
  };
3080
4175
  const nonoptionalProcessor = (schema, ctx, _json, params) => {
3081
4176
  const def = schema._zod.def;
3082
- process(def.innerType, ctx, params);
4177
+ processSchema(def.innerType, ctx, params);
3083
4178
  const seen = ctx.seen.get(schema);
3084
4179
  seen.ref = def.innerType;
3085
4180
  };
4181
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
4182
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
4183
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
4184
+ const UNREPRESENTABLE_DEFAULT = Symbol();
4185
+ function serializeDefaultValue(value, schema, ctx, json, params) {
4186
+ let unrepresentable = false;
4187
+ const serialized = JSON.stringify(value, (_, val) => {
4188
+ if (typeof val !== "bigint") return val;
4189
+ unrepresentable = true;
4190
+ return null;
4191
+ });
4192
+ if (!unrepresentable) return JSON.parse(serialized);
4193
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
4194
+ return UNREPRESENTABLE_DEFAULT;
4195
+ }
3086
4196
  const defaultProcessor = (schema, ctx, json, params) => {
3087
4197
  const def = schema._zod.def;
3088
- process(def.innerType, ctx, params);
4198
+ processSchema(def.innerType, ctx, params);
3089
4199
  const seen = ctx.seen.get(schema);
3090
4200
  seen.ref = def.innerType;
3091
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4201
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4202
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
3092
4203
  };
3093
4204
  const prefaultProcessor = (schema, ctx, json, params) => {
3094
4205
  const def = schema._zod.def;
3095
- process(def.innerType, ctx, params);
4206
+ processSchema(def.innerType, ctx, params);
3096
4207
  const seen = ctx.seen.get(schema);
3097
4208
  seen.ref = def.innerType;
3098
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4209
+ if (ctx.io !== "input") return;
4210
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4211
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
3099
4212
  };
3100
4213
  const catchProcessor = (schema, ctx, json, params) => {
3101
4214
  const def = schema._zod.def;
3102
- process(def.innerType, ctx, params);
4215
+ processSchema(def.innerType, ctx, params);
3103
4216
  const seen = ctx.seen.get(schema);
3104
4217
  seen.ref = def.innerType;
3105
4218
  let catchValue;
3106
4219
  try {
3107
4220
  catchValue = def.catchValue(void 0);
3108
4221
  } catch {
3109
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4222
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
4223
+ return;
3110
4224
  }
3111
4225
  json.default = catchValue;
3112
4226
  };
@@ -3114,77 +4228,75 @@ const pipeProcessor = (schema, ctx, _json, params) => {
3114
4228
  const def = schema._zod.def;
3115
4229
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3116
4230
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3117
- process(innerType, ctx, params);
4231
+ processSchema(innerType, ctx, params);
3118
4232
  const seen = ctx.seen.get(schema);
3119
4233
  seen.ref = innerType;
3120
4234
  };
3121
4235
  const readonlyProcessor = (schema, ctx, json, params) => {
3122
4236
  const def = schema._zod.def;
3123
- process(def.innerType, ctx, params);
4237
+ processSchema(def.innerType, ctx, params);
3124
4238
  const seen = ctx.seen.get(schema);
3125
4239
  seen.ref = def.innerType;
3126
4240
  json.readOnly = true;
3127
4241
  };
3128
4242
  const optionalProcessor = (schema, ctx, _json, params) => {
3129
4243
  const def = schema._zod.def;
3130
- process(def.innerType, ctx, params);
4244
+ processSchema(def.innerType, ctx, params);
3131
4245
  const seen = ctx.seen.get(schema);
3132
4246
  seen.ref = def.innerType;
3133
4247
  };
3134
4248
  //#endregion
3135
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
3136
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3137
- $ZodISODateTime.init(inst, def);
3138
- ZodStringFormat.init(inst, def);
3139
- });
3140
- function datetime(params) {
3141
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3142
- }
3143
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3144
- $ZodISODate.init(inst, def);
3145
- ZodStringFormat.init(inst, def);
3146
- });
3147
- function date(params) {
3148
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3149
- }
3150
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3151
- $ZodISOTime.init(inst, def);
3152
- ZodStringFormat.init(inst, def);
3153
- });
3154
- function time(params) {
3155
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3156
- }
3157
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3158
- $ZodISODuration.init(inst, def);
3159
- ZodStringFormat.init(inst, def);
3160
- });
3161
- function duration(params) {
3162
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4249
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/errors.js
4250
+ const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
4251
+ function _lazyMethod(proto, key, make) {
4252
+ Object.defineProperty(proto, key, {
4253
+ configurable: true,
4254
+ enumerable: false,
4255
+ get() {
4256
+ const value = make(this);
4257
+ Object.defineProperty(this, key, {
4258
+ value,
4259
+ configurable: true,
4260
+ writable: true
4261
+ });
4262
+ return value;
4263
+ },
4264
+ set(value) {
4265
+ Object.defineProperty(this, key, {
4266
+ value,
4267
+ configurable: true,
4268
+ writable: true
4269
+ });
4270
+ }
4271
+ });
3163
4272
  }
3164
- //#endregion
3165
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
3166
4273
  const initializer = (inst, issues) => {
3167
4274
  $ZodError.init(inst, issues);
3168
4275
  inst.name = "ZodError";
3169
- Object.defineProperties(inst, {
3170
- format: { value: (mapper) => formatError(inst, mapper) },
3171
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3172
- addIssue: { value: (issue) => {
3173
- inst.issues.push(issue);
3174
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3175
- } },
3176
- addIssues: { value: (issues) => {
3177
- inst.issues.push(...issues);
3178
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3179
- } },
3180
- isEmpty: { get() {
3181
- return inst.issues.length === 0;
3182
- } }
4276
+ const proto = Object.getPrototypeOf(inst);
4277
+ if (_installedErrorProtos.has(proto)) return;
4278
+ _installedErrorProtos.add(proto);
4279
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
4280
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
4281
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
4282
+ self.issues.push(issue);
4283
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4284
+ });
4285
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
4286
+ self.issues.push(...issues);
4287
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4288
+ });
4289
+ Object.defineProperty(proto, "isEmpty", {
4290
+ configurable: true,
4291
+ enumerable: false,
4292
+ get() {
4293
+ return this.issues.length === 0;
4294
+ }
3183
4295
  });
3184
4296
  };
3185
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4297
+ const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
3186
4298
  //#endregion
3187
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
4299
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/parse.js
3188
4300
  const parse = /* @__PURE__ */ _parse(ZodRealError);
3189
4301
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3190
4302
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -3198,255 +4310,320 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3198
4310
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3199
4311
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3200
4312
  //#endregion
3201
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
3202
- const _installedGroups = /* @__PURE__ */ new WeakMap();
3203
- function _installLazyMethods(inst, group, methods) {
3204
- const proto = Object.getPrototypeOf(inst);
3205
- let installed = _installedGroups.get(proto);
3206
- if (!installed) {
3207
- installed = /* @__PURE__ */ new Set();
3208
- _installedGroups.set(proto, installed);
3209
- }
3210
- if (installed.has(group)) return;
3211
- installed.add(group);
3212
- for (const key in methods) {
3213
- const fn = methods[key];
3214
- Object.defineProperty(proto, key, {
3215
- configurable: true,
3216
- enumerable: false,
3217
- get() {
3218
- const bound = fn.bind(this);
3219
- Object.defineProperty(this, key, {
3220
- configurable: true,
3221
- writable: true,
3222
- enumerable: true,
3223
- value: bound
3224
- });
3225
- return bound;
3226
- },
3227
- set(v) {
3228
- Object.defineProperty(this, key, {
3229
- configurable: true,
3230
- writable: true,
3231
- enumerable: true,
3232
- value: v
3233
- });
3234
- }
3235
- });
3236
- }
4313
+ //#region ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/schemas.js
4314
+ function _ensureDefaultLocale() {
4315
+ if (!globalConfig.localeError) config(en_default());
4316
+ }
4317
+ function _ensureDefaultMemoizer() {
4318
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
3237
4319
  }
3238
4320
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4321
+ _ensureDefaultLocale();
3239
4322
  $ZodType.init(inst, def);
3240
- Object.assign(inst["~standard"], { jsonSchema: {
3241
- input: createStandardJSONSchemaMethod(inst, "input"),
3242
- output: createStandardJSONSchemaMethod(inst, "output")
3243
- } });
3244
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3245
4323
  inst.def = def;
3246
4324
  inst.type = def.type;
3247
- Object.defineProperty(inst, "_def", { value: def });
3248
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3249
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3250
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3251
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3252
- inst.spa = inst.safeParseAsync;
3253
- inst.encode = (data, params) => encode(inst, data, params);
3254
- inst.decode = (data, params) => decode(inst, data, params);
3255
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3256
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3257
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3258
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3259
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3260
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3261
- _installLazyMethods(inst, "ZodType", {
3262
- check(...chks) {
3263
- const def = this.def;
3264
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3265
- check: ch,
3266
- def: { check: "custom" },
3267
- onattach: []
3268
- } } : ch)] }), { parent: true });
3269
- },
3270
- with(...chks) {
3271
- return this.check(...chks);
3272
- },
3273
- clone(def, params) {
3274
- return clone(this, def, params);
3275
- },
3276
- brand() {
3277
- return this;
3278
- },
3279
- register(reg, meta) {
3280
- reg.add(this, meta);
3281
- return this;
3282
- },
3283
- refine(check, params) {
3284
- return this.check(refine(check, params));
3285
- },
3286
- superRefine(refinement, params) {
3287
- return this.check(superRefine(refinement, params));
3288
- },
3289
- overwrite(fn) {
3290
- return this.check(/* @__PURE__ */ _overwrite(fn));
3291
- },
3292
- optional() {
3293
- return optional(this);
3294
- },
3295
- exactOptional() {
3296
- return exactOptional(this);
3297
- },
3298
- nullable() {
3299
- return nullable(this);
3300
- },
3301
- nullish() {
3302
- return optional(nullable(this));
3303
- },
3304
- nonoptional(params) {
3305
- return nonoptional(this, params);
3306
- },
3307
- array() {
3308
- return array(this);
3309
- },
3310
- or(arg) {
3311
- return union([this, arg]);
3312
- },
3313
- and(arg) {
3314
- return intersection(this, arg);
3315
- },
3316
- transform(tx) {
3317
- return pipe(this, transform(tx));
3318
- },
3319
- default(d) {
3320
- return _default(this, d);
3321
- },
3322
- prefault(d) {
3323
- return prefault(this, d);
3324
- },
3325
- catch(params) {
3326
- return _catch(this, params);
3327
- },
3328
- pipe(target) {
3329
- return pipe(this, target);
3330
- },
3331
- readonly() {
3332
- return readonly(this);
3333
- },
3334
- describe(description) {
3335
- const cl = this.clone();
3336
- globalRegistry.add(cl, { description });
3337
- return cl;
3338
- },
3339
- meta(...args) {
3340
- if (args.length === 0) return globalRegistry.get(this);
3341
- const cl = this.clone();
3342
- globalRegistry.add(cl, args[0]);
3343
- return cl;
3344
- },
3345
- isOptional() {
3346
- return this.safeParse(void 0).success;
3347
- },
3348
- isNullable() {
3349
- return this.safeParse(null).success;
3350
- },
3351
- apply(fn) {
3352
- return fn(this);
3353
- }
3354
- });
3355
- Object.defineProperty(inst, "description", {
3356
- get() {
3357
- return globalRegistry.get(inst)?.description;
3358
- },
3359
- configurable: true
3360
- });
3361
4325
  return inst;
4326
+ }, {
4327
+ check(...chks) {
4328
+ const def = this.def;
4329
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4330
+ check: ch,
4331
+ def: { check: "custom" },
4332
+ onattach: []
4333
+ } } : ch)] }), { parent: true });
4334
+ },
4335
+ with(...chks) {
4336
+ return this.check(...chks);
4337
+ },
4338
+ clone(def, params) {
4339
+ return clone(this, def, params);
4340
+ },
4341
+ brand() {
4342
+ return this;
4343
+ },
4344
+ register(reg, meta) {
4345
+ reg.add(this, meta);
4346
+ return this;
4347
+ },
4348
+ refine(check, params) {
4349
+ return this.check(refine(check, params));
4350
+ },
4351
+ superRefine(refinement, params) {
4352
+ return this.check(superRefine(refinement, params));
4353
+ },
4354
+ overwrite(fn) {
4355
+ return this.check(/* @__PURE__ */ _overwrite(fn));
4356
+ },
4357
+ optional() {
4358
+ return optional(this);
4359
+ },
4360
+ exactOptional() {
4361
+ return exactOptional(this);
4362
+ },
4363
+ nullable() {
4364
+ return nullable(this);
4365
+ },
4366
+ nullish() {
4367
+ return optional(nullable(this));
4368
+ },
4369
+ nonoptional(params) {
4370
+ return nonoptional(this, params);
4371
+ },
4372
+ array() {
4373
+ return array(this);
4374
+ },
4375
+ or(arg) {
4376
+ return union([this, arg]);
4377
+ },
4378
+ and(arg) {
4379
+ return intersection(this, arg);
4380
+ },
4381
+ transform(tx) {
4382
+ return pipe(this, transform(tx));
4383
+ },
4384
+ default(d) {
4385
+ return _default(this, d);
4386
+ },
4387
+ prefault(d) {
4388
+ return prefault(this, d);
4389
+ },
4390
+ catch(params) {
4391
+ return _catch(this, params);
4392
+ },
4393
+ pipe(target) {
4394
+ return pipe(this, target);
4395
+ },
4396
+ readonly() {
4397
+ return readonly(this);
4398
+ },
4399
+ describe(description) {
4400
+ const cl = this.clone();
4401
+ globalRegistry.add(cl, { description });
4402
+ return cl;
4403
+ },
4404
+ meta(...args) {
4405
+ if (args.length === 0) return globalRegistry.get(this);
4406
+ const cl = this.clone();
4407
+ globalRegistry.add(cl, args[0]);
4408
+ return cl;
4409
+ },
4410
+ isOptional() {
4411
+ return this.safeParse(void 0).success;
4412
+ },
4413
+ isNullable() {
4414
+ return this.safeParse(null).success;
4415
+ },
4416
+ apply(fn, ...args) {
4417
+ return args.length === 0 ? fn(this) : fn(this, ...args);
4418
+ },
4419
+ get "~standard"() {
4420
+ return hide(this, "~standard", {
4421
+ ...standardProps(this),
4422
+ jsonSchema: {
4423
+ input: createStandardJSONSchemaMethod(this, "input"),
4424
+ output: createStandardJSONSchemaMethod(this, "output")
4425
+ }
4426
+ });
4427
+ },
4428
+ set "~standard"(value) {
4429
+ own(this, "~standard", value);
4430
+ },
4431
+ parse: function _parse(data, params) {
4432
+ return parse(this, data, params, { callee: _parse });
4433
+ },
4434
+ parseAsync: async function _parseAsync(data, params) {
4435
+ return await parseAsync(this, data, params, { callee: _parseAsync });
4436
+ },
4437
+ safeParse(data, params) {
4438
+ return safeParse(this, data, params);
4439
+ },
4440
+ async safeParseAsync(data, params) {
4441
+ return safeParseAsync(this, data, params);
4442
+ },
4443
+ get spa() {
4444
+ return this?.safeParseAsync;
4445
+ },
4446
+ set spa(value) {
4447
+ own(this, "spa", value);
4448
+ },
4449
+ validate(data, params) {
4450
+ return validate(this, data, params);
4451
+ },
4452
+ validateAsync(data, params) {
4453
+ return validateAsync$1(this, data, params);
4454
+ },
4455
+ encode: function _encode(data, params) {
4456
+ return encode(this, data, params, { callee: _encode });
4457
+ },
4458
+ decode: function _decode(data, params) {
4459
+ return decode(this, data, params, { callee: _decode });
4460
+ },
4461
+ encodeAsync: async function _encodeAsync(data, params) {
4462
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
4463
+ },
4464
+ decodeAsync: async function _decodeAsync(data, params) {
4465
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
4466
+ },
4467
+ safeEncode(data, params) {
4468
+ return safeEncode(this, data, params);
4469
+ },
4470
+ safeDecode(data, params) {
4471
+ return safeDecode(this, data, params);
4472
+ },
4473
+ async safeEncodeAsync(data, params) {
4474
+ return safeEncodeAsync(this, data, params);
4475
+ },
4476
+ async safeDecodeAsync(data, params) {
4477
+ return safeDecodeAsync(this, data, params);
4478
+ },
4479
+ toJSONSchema(params) {
4480
+ return createToJSONSchemaMethod(this, {})(params);
4481
+ },
4482
+ get description() {
4483
+ return globalRegistry.get(this)?.description;
4484
+ },
4485
+ get _def() {
4486
+ return this._zod.def;
4487
+ }
3362
4488
  });
3363
4489
  /** @internal */
3364
4490
  const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3365
4491
  $ZodString.init(inst, def);
3366
4492
  ZodType.init(inst, def);
3367
4493
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3368
- const bag = inst._zod.bag;
3369
- inst.format = bag.format ?? null;
3370
- inst.minLength = bag.minimum ?? null;
3371
- inst.maxLength = bag.maximum ?? null;
3372
- _installLazyMethods(inst, "_ZodString", {
3373
- regex(...args) {
3374
- return this.check(/* @__PURE__ */ _regex(...args));
3375
- },
3376
- includes(...args) {
3377
- return this.check(/* @__PURE__ */ _includes(...args));
3378
- },
3379
- startsWith(...args) {
3380
- return this.check(/* @__PURE__ */ _startsWith(...args));
3381
- },
3382
- endsWith(...args) {
3383
- return this.check(/* @__PURE__ */ _endsWith(...args));
3384
- },
3385
- min(...args) {
3386
- return this.check(/* @__PURE__ */ _minLength(...args));
3387
- },
3388
- max(...args) {
3389
- return this.check(/* @__PURE__ */ _maxLength(...args));
3390
- },
3391
- length(...args) {
3392
- return this.check(/* @__PURE__ */ _length(...args));
3393
- },
3394
- nonempty(...args) {
3395
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3396
- },
3397
- lowercase(params) {
3398
- return this.check(/* @__PURE__ */ _lowercase(params));
3399
- },
3400
- uppercase(params) {
3401
- return this.check(/* @__PURE__ */ _uppercase(params));
3402
- },
3403
- trim() {
3404
- return this.check(/* @__PURE__ */ _trim());
3405
- },
3406
- normalize(...args) {
3407
- return this.check(/* @__PURE__ */ _normalize(...args));
3408
- },
3409
- toLowerCase() {
3410
- return this.check(/* @__PURE__ */ _toLowerCase());
3411
- },
3412
- toUpperCase() {
3413
- return this.check(/* @__PURE__ */ _toUpperCase());
3414
- },
3415
- slugify() {
3416
- return this.check(/* @__PURE__ */ _slugify());
3417
- }
3418
- });
3419
- });
4494
+ }, /*@__PURE__*/ derived({
4495
+ format: (inst) => aggregateChecks(inst).format ?? null,
4496
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
4497
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
4498
+ }, {
4499
+ regex(...args) {
4500
+ return this.check(/* @__PURE__ */ _regex(...args));
4501
+ },
4502
+ includes(...args) {
4503
+ return this.check(/* @__PURE__ */ _includes(...args));
4504
+ },
4505
+ startsWith(...args) {
4506
+ return this.check(/* @__PURE__ */ _startsWith(...args));
4507
+ },
4508
+ endsWith(...args) {
4509
+ return this.check(/* @__PURE__ */ _endsWith(...args));
4510
+ },
4511
+ min(...args) {
4512
+ return this.check(/* @__PURE__ */ _minLength(...args));
4513
+ },
4514
+ max(...args) {
4515
+ return this.check(/* @__PURE__ */ _maxLength(...args));
4516
+ },
4517
+ length(...args) {
4518
+ return this.check(/* @__PURE__ */ _length(...args));
4519
+ },
4520
+ nonempty(...args) {
4521
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
4522
+ },
4523
+ lowercase(params) {
4524
+ return this.check(/* @__PURE__ */ _lowercase(params));
4525
+ },
4526
+ uppercase(params) {
4527
+ return this.check(/* @__PURE__ */ _uppercase(params));
4528
+ },
4529
+ trim() {
4530
+ return this.check(/* @__PURE__ */ _trim());
4531
+ },
4532
+ normalize(...args) {
4533
+ return this.check(/* @__PURE__ */ _normalize(...args));
4534
+ },
4535
+ toLowerCase() {
4536
+ return this.check(/* @__PURE__ */ _toLowerCase());
4537
+ },
4538
+ toUpperCase() {
4539
+ return this.check(/* @__PURE__ */ _toUpperCase());
4540
+ },
4541
+ slugify() {
4542
+ return this.check(/* @__PURE__ */ _slugify());
4543
+ }
4544
+ }));
3420
4545
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3421
4546
  $ZodString.init(inst, def);
3422
4547
  _ZodString.init(inst, def);
3423
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3424
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3425
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3426
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3427
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3428
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3429
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3430
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3431
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3432
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3433
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3434
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3435
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3436
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3437
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3438
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3439
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3440
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3441
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3442
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3443
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3444
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3445
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3446
- inst.datetime = (params) => inst.check(datetime(params));
3447
- inst.date = (params) => inst.check(date(params));
3448
- inst.time = (params) => inst.check(time(params));
3449
- inst.duration = (params) => inst.check(duration(params));
4548
+ }, {
4549
+ email(params) {
4550
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
4551
+ },
4552
+ url(params) {
4553
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
4554
+ },
4555
+ jwt(params) {
4556
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4557
+ },
4558
+ emoji(params) {
4559
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4560
+ },
4561
+ guid(params) {
4562
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
4563
+ },
4564
+ uuid(params) {
4565
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4566
+ },
4567
+ uuidv4(params) {
4568
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4569
+ },
4570
+ uuidv6(params) {
4571
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4572
+ },
4573
+ uuidv7(params) {
4574
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4575
+ },
4576
+ nanoid(params) {
4577
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4578
+ },
4579
+ cuid(params) {
4580
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4581
+ },
4582
+ cuid2(params) {
4583
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4584
+ },
4585
+ ulid(params) {
4586
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
4587
+ },
4588
+ base64(params) {
4589
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
4590
+ },
4591
+ base64url(params) {
4592
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4593
+ },
4594
+ xid(params) {
4595
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
4596
+ },
4597
+ ksuid(params) {
4598
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4599
+ },
4600
+ ipv4(params) {
4601
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4602
+ },
4603
+ ipv6(params) {
4604
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4605
+ },
4606
+ cidrv4(params) {
4607
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4608
+ },
4609
+ cidrv6(params) {
4610
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4611
+ },
4612
+ e164(params) {
4613
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
4614
+ },
4615
+ datetime(params) {
4616
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
4617
+ },
4618
+ date(params) {
4619
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
4620
+ },
4621
+ time(params) {
4622
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
4623
+ },
4624
+ duration(params) {
4625
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
4626
+ }
3450
4627
  });
3451
4628
  function string(params) {
3452
4629
  return /* @__PURE__ */ _string(ZodString, params);
@@ -3455,6 +4632,22 @@ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def
3455
4632
  $ZodStringFormat.init(inst, def);
3456
4633
  _ZodString.init(inst, def);
3457
4634
  });
4635
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4636
+ $ZodISODateTime.init(inst, def);
4637
+ ZodStringFormat.init(inst, def);
4638
+ });
4639
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4640
+ $ZodISODate.init(inst, def);
4641
+ ZodStringFormat.init(inst, def);
4642
+ });
4643
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4644
+ $ZodISOTime.init(inst, def);
4645
+ ZodStringFormat.init(inst, def);
4646
+ });
4647
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4648
+ $ZodISODuration.init(inst, def);
4649
+ ZodStringFormat.init(inst, def);
4650
+ });
3458
4651
  const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3459
4652
  $ZodEmail.init(inst, def);
3460
4653
  ZodStringFormat.init(inst, def);
@@ -3540,60 +4733,68 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
3540
4733
  $ZodNumber.init(inst, def);
3541
4734
  ZodType.init(inst, def);
3542
4735
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3543
- _installLazyMethods(inst, "ZodNumber", {
3544
- gt(value, params) {
3545
- return this.check(/* @__PURE__ */ _gt(value, params));
3546
- },
3547
- gte(value, params) {
3548
- return this.check(/* @__PURE__ */ _gte(value, params));
3549
- },
3550
- min(value, params) {
3551
- return this.check(/* @__PURE__ */ _gte(value, params));
3552
- },
3553
- lt(value, params) {
3554
- return this.check(/* @__PURE__ */ _lt(value, params));
3555
- },
3556
- lte(value, params) {
3557
- return this.check(/* @__PURE__ */ _lte(value, params));
3558
- },
3559
- max(value, params) {
3560
- return this.check(/* @__PURE__ */ _lte(value, params));
3561
- },
3562
- int(params) {
3563
- return this.check(int(params));
3564
- },
3565
- safe(params) {
3566
- return this.check(int(params));
3567
- },
3568
- positive(params) {
3569
- return this.check(/* @__PURE__ */ _gt(0, params));
3570
- },
3571
- nonnegative(params) {
3572
- return this.check(/* @__PURE__ */ _gte(0, params));
3573
- },
3574
- negative(params) {
3575
- return this.check(/* @__PURE__ */ _lt(0, params));
3576
- },
3577
- nonpositive(params) {
3578
- return this.check(/* @__PURE__ */ _lte(0, params));
3579
- },
3580
- multipleOf(value, params) {
3581
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3582
- },
3583
- step(value, params) {
3584
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
3585
- },
3586
- finite() {
3587
- return this;
3588
- }
3589
- });
3590
- const bag = inst._zod.bag;
3591
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3592
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3593
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3594
4736
  inst.isFinite = true;
3595
- inst.format = bag.format ?? null;
3596
- });
4737
+ }, /*@__PURE__*/ derived({
4738
+ minValue: (inst) => {
4739
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
4740
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
4741
+ },
4742
+ maxValue: (inst) => {
4743
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
4744
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
4745
+ },
4746
+ isInt: (inst) => {
4747
+ const { isInt, multipleOf } = aggregateChecks(inst);
4748
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
4749
+ },
4750
+ format: (inst) => aggregateChecks(inst).format ?? null
4751
+ }, {
4752
+ gt(value, params) {
4753
+ return this.check(/* @__PURE__ */ _gt(value, params));
4754
+ },
4755
+ gte(value, params) {
4756
+ return this.check(/* @__PURE__ */ _gte(value, params));
4757
+ },
4758
+ min(value, params) {
4759
+ return this.check(/* @__PURE__ */ _gte(value, params));
4760
+ },
4761
+ lt(value, params) {
4762
+ return this.check(/* @__PURE__ */ _lt(value, params));
4763
+ },
4764
+ lte(value, params) {
4765
+ return this.check(/* @__PURE__ */ _lte(value, params));
4766
+ },
4767
+ max(value, params) {
4768
+ return this.check(/* @__PURE__ */ _lte(value, params));
4769
+ },
4770
+ int(params) {
4771
+ return this.check(int(params));
4772
+ },
4773
+ safe(params) {
4774
+ return this.check(int(params));
4775
+ },
4776
+ positive(params) {
4777
+ return this.check(/* @__PURE__ */ _gt(0, params));
4778
+ },
4779
+ nonnegative(params) {
4780
+ return this.check(/* @__PURE__ */ _gte(0, params));
4781
+ },
4782
+ negative(params) {
4783
+ return this.check(/* @__PURE__ */ _lt(0, params));
4784
+ },
4785
+ nonpositive(params) {
4786
+ return this.check(/* @__PURE__ */ _lte(0, params));
4787
+ },
4788
+ multipleOf(value, params) {
4789
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4790
+ },
4791
+ step(value, params) {
4792
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
4793
+ },
4794
+ finite() {
4795
+ return this;
4796
+ }
4797
+ }));
3597
4798
  function number(params) {
3598
4799
  return /* @__PURE__ */ _number(ZodNumber, params);
3599
4800
  }
@@ -3621,94 +4822,80 @@ function never(params) {
3621
4822
  return /* @__PURE__ */ _never(ZodNever, params);
3622
4823
  }
3623
4824
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4825
+ _ensureDefaultMemoizer();
3624
4826
  $ZodArray.init(inst, def);
3625
4827
  ZodType.init(inst, def);
3626
4828
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3627
4829
  inst.element = def.element;
3628
- _installLazyMethods(inst, "ZodArray", {
3629
- min(n, params) {
3630
- return this.check(/* @__PURE__ */ _minLength(n, params));
3631
- },
3632
- nonempty(params) {
3633
- return this.check(/* @__PURE__ */ _minLength(1, params));
3634
- },
3635
- max(n, params) {
3636
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3637
- },
3638
- length(n, params) {
3639
- return this.check(/* @__PURE__ */ _length(n, params));
3640
- },
3641
- unwrap() {
3642
- return this.element;
3643
- }
3644
- });
4830
+ }, {
4831
+ min(n, params) {
4832
+ return this.check(/* @__PURE__ */ _minLength(n, params));
4833
+ },
4834
+ nonempty(params) {
4835
+ return this.check(/* @__PURE__ */ _minLength(1, params));
4836
+ },
4837
+ max(n, params) {
4838
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
4839
+ },
4840
+ length(n, params) {
4841
+ return this.check(/* @__PURE__ */ _length(n, params));
4842
+ },
4843
+ unwrap() {
4844
+ return this.element;
4845
+ }
3645
4846
  });
3646
4847
  function array(element, params) {
3647
4848
  return /* @__PURE__ */ _array(ZodArray, element, params);
3648
4849
  }
3649
4850
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4851
+ _ensureDefaultMemoizer();
3650
4852
  $ZodObjectJIT.init(inst, def);
3651
4853
  ZodType.init(inst, def);
3652
4854
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3653
- defineLazy(inst, "shape", () => {
3654
- return def.shape;
3655
- });
3656
- _installLazyMethods(inst, "ZodObject", {
3657
- keyof() {
3658
- return _enum(Object.keys(this._zod.def.shape));
3659
- },
3660
- catchall(catchall) {
3661
- return this.clone({
3662
- ...this._zod.def,
3663
- catchall
3664
- });
3665
- },
3666
- passthrough() {
3667
- return this.clone({
3668
- ...this._zod.def,
3669
- catchall: unknown()
3670
- });
3671
- },
3672
- loose() {
3673
- return this.clone({
3674
- ...this._zod.def,
3675
- catchall: unknown()
3676
- });
3677
- },
3678
- strict() {
3679
- return this.clone({
3680
- ...this._zod.def,
3681
- catchall: never()
3682
- });
3683
- },
3684
- strip() {
3685
- return this.clone({
3686
- ...this._zod.def,
3687
- catchall: void 0
3688
- });
3689
- },
3690
- extend(incoming) {
3691
- return extend(this, incoming);
3692
- },
3693
- safeExtend(incoming) {
3694
- return safeExtend(this, incoming);
3695
- },
3696
- merge(other) {
3697
- return merge(this, other);
3698
- },
3699
- pick(mask) {
3700
- return pick(this, mask);
3701
- },
3702
- omit(mask) {
3703
- return omit(this, mask);
3704
- },
3705
- partial(...args) {
3706
- return partial(ZodOptional, this, args[0]);
3707
- },
3708
- required(...args) {
3709
- return required(ZodNonOptional, this, args[0]);
3710
- }
3711
- });
4855
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
4856
+ }, {
4857
+ keyof() {
4858
+ return _enum(Object.keys(this._zod.def.shape));
4859
+ },
4860
+ catchall(catchall) {
4861
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
4862
+ },
4863
+ passthrough() {
4864
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4865
+ },
4866
+ loose() {
4867
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4868
+ },
4869
+ strict() {
4870
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
4871
+ },
4872
+ strip() {
4873
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
4874
+ },
4875
+ extend(incoming) {
4876
+ return extend(this, incoming);
4877
+ },
4878
+ safeExtend(incoming) {
4879
+ return safeExtend(this, incoming);
4880
+ },
4881
+ merge(other) {
4882
+ return merge(this, other);
4883
+ },
4884
+ pick(mask) {
4885
+ return pick(this, mask);
4886
+ },
4887
+ omit(mask) {
4888
+ return omit(this, mask);
4889
+ },
4890
+ partial(...args) {
4891
+ return partial(ZodOptional, this, args[0]);
4892
+ },
4893
+ exactPartial(...args) {
4894
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
4895
+ },
4896
+ required(...args) {
4897
+ return required(ZodNonOptional, this, args[0]);
4898
+ }
3712
4899
  });
3713
4900
  function object(shape, params) {
3714
4901
  return new ZodObject({
@@ -3747,7 +4934,7 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3747
4934
  ZodType.init(inst, def);
3748
4935
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3749
4936
  inst.enum = def.entries;
3750
- inst.options = Object.values(def.entries);
4937
+ inst.options = [...inst._zod.values];
3751
4938
  const keys = new Set(Object.keys(def.entries));
3752
4939
  inst.extract = (values, params) => {
3753
4940
  const newEntries = {};
@@ -3780,6 +4967,7 @@ function _enum(values, params) {
3780
4967
  });
3781
4968
  }
3782
4969
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4970
+ _ensureDefaultMemoizer();
3783
4971
  $ZodTransform.init(inst, def);
3784
4972
  ZodType.init(inst, def);
3785
4973
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -3791,7 +4979,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3791
4979
  const _issue = issue$1;
3792
4980
  if (_issue.fatal) _issue.continue = false;
3793
4981
  _issue.code ?? (_issue.code = "custom");
3794
- _issue.input ?? (_issue.input = payload.value);
4982
+ if (!("input" in _issue)) _issue.input = payload.value;
3795
4983
  _issue.inst ?? (_issue.inst = inst);
3796
4984
  payload.issues.push(issue(_issue));
3797
4985
  }
@@ -3799,11 +4987,9 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3799
4987
  const output = def.transform(payload.value, payload);
3800
4988
  if (output instanceof Promise) return output.then((output) => {
3801
4989
  payload.value = output;
3802
- payload.fallback = true;
3803
4990
  return payload;
3804
4991
  });
3805
4992
  payload.value = output;
3806
- payload.fallback = true;
3807
4993
  return payload;
3808
4994
  };
3809
4995
  });
@@ -3904,7 +5090,7 @@ function _catch(innerType, catchValue) {
3904
5090
  return new ZodCatch({
3905
5091
  type: "catch",
3906
5092
  innerType,
3907
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
5093
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
3908
5094
  });
3909
5095
  }
3910
5096
  const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
@@ -3969,6 +5155,60 @@ const DEFAULT_EXPIRES_IN = 900;
3969
5155
  const DEFAULT_BASE_PATH = "/_files";
3970
5156
  const OCTET_STREAM = "application/octet-stream";
3971
5157
  const MS_PER_SECOND = 1e3;
5158
+ /** Why an upload was refused: its body broke a limit its token pins. */
5159
+ var UploadRefused = class extends Error {
5160
+ /** The HTTP status the refusal answers with. */
5161
+ status;
5162
+ /** A stable code: `TOO_LARGE` or `CHECKSUM_MISMATCH`. */
5163
+ code;
5164
+ constructor(status, code, message) {
5165
+ super(message);
5166
+ this.name = "UploadRefused";
5167
+ this.status = status;
5168
+ this.code = code;
5169
+ }
5170
+ };
5171
+ /**
5172
+ * Check an upload body against its token while it streams: past `m` bytes, or at the end when the bytes don't
5173
+ * hash to `h`, the stream errors with {@link UploadRefused}, so the store never publishes the object.
5174
+ */
5175
+ function guardUpload(body, token) {
5176
+ const { m: max, h: sha256 } = token;
5177
+ if (max === void 0 && sha256 === void 0) return body;
5178
+ const hash = sha256 === void 0 ? void 0 : createHash("sha256");
5179
+ let size = 0;
5180
+ return body.pipeThrough(new TransformStream({
5181
+ transform(chunk, controller) {
5182
+ size += chunk.length;
5183
+ if (max !== void 0 && size > max) throw new UploadRefused(413, "TOO_LARGE", `upload is larger than ${max} bytes`);
5184
+ hash?.update(chunk);
5185
+ controller.enqueue(chunk);
5186
+ },
5187
+ flush() {
5188
+ if (hash !== void 0 && hash.digest("hex") !== sha256) throw new UploadRefused(422, "CHECKSUM_MISMATCH", "upload does not match its sha256");
5189
+ }
5190
+ }));
5191
+ }
5192
+ /**
5193
+ * Store a presigned upload under its token's key, refusing it up front when a declared `Content-Length` already
5194
+ * breaks the token's `maxSize`. Throws {@link UploadRefused} when the body breaks a pinned limit.
5195
+ */
5196
+ async function storeUpload(store, token, body, declared) {
5197
+ const length = declared === null ? void 0 : Number(declared);
5198
+ if (token.m !== void 0 && length !== void 0 && length > token.m) {
5199
+ await body.cancel().catch(() => void 0);
5200
+ throw new UploadRefused(413, "TOO_LARGE", `upload is larger than ${token.m} bytes`);
5201
+ }
5202
+ try {
5203
+ return await store.put(token.k, guardUpload(body, token), { contentType: token.c });
5204
+ } catch (err) {
5205
+ throw refusalIn(err) ?? err;
5206
+ }
5207
+ }
5208
+ /** The {@link UploadRefused} behind a store failure, if a guard caused it (stores may wrap stream errors). */
5209
+ function refusalIn(err) {
5210
+ for (let e = err, depth = 0; e instanceof Error && depth < 4; e = e.cause, depth++) if (e instanceof UploadRefused) return e;
5211
+ }
3972
5212
  const b64url = (buf) => Buffer.from(buf).toString("base64url");
3973
5213
  /** Sign a {@link Token} into the opaque `?t=` value. */
3974
5214
  function signToken(secret, token) {
@@ -4011,7 +5251,9 @@ function makePresigner(opts) {
4011
5251
  k: key,
4012
5252
  o: "put",
4013
5253
  e: exp(o?.expiresIn),
4014
- c: o?.contentType
5254
+ c: o?.contentType,
5255
+ m: o?.maxSize,
5256
+ h: o?.sha256?.toLowerCase()
4015
5257
  }))
4016
5258
  };
4017
5259
  }
@@ -4058,14 +5300,19 @@ function mountFiles(app, store, opts) {
4058
5300
  length(obj.info.size);
4059
5301
  return obj.stream();
4060
5302
  },
4061
- ayepiFilesUpload: async ({ data, stream }) => {
5303
+ ayepiFilesUpload: async ({ data, stream, req }) => {
4062
5304
  const token = verifyToken(opts.secret, data.t, Math.floor((opts.now ?? Date.now)() / MS_PER_SECOND));
4063
5305
  if (!token || token.o !== "put") throw reject(403, "FORBIDDEN", "invalid or expired token");
4064
- const info = await store.put(token.k, stream, { contentType: token.c });
4065
- return {
4066
- key: info.key,
4067
- size: info.size
4068
- };
5306
+ try {
5307
+ const info = await storeUpload(store, token, stream, req.headers.get("content-length"));
5308
+ return {
5309
+ key: info.key,
5310
+ size: info.size
5311
+ };
5312
+ } catch (err) {
5313
+ if (err instanceof UploadRefused) throw reject(err.status, err.code, err.message);
5314
+ throw err;
5315
+ }
4069
5316
  }
4070
5317
  });
4071
5318
  const install = app.install;
@@ -4106,11 +5353,19 @@ function createFilesHandler(store, opts) {
4106
5353
  if (req.method === "PUT") {
4107
5354
  if (!token || token.o !== "put") return new Response("forbidden", { status: 403 });
4108
5355
  const body = req.body ?? new ReadableStream({ start: (c) => c.close() });
4109
- const info = await store.put(token.k, body, { contentType: token.c });
4110
- return Response.json({
4111
- key: info.key,
4112
- size: info.size
4113
- });
5356
+ try {
5357
+ const info = await storeUpload(store, token, body, req.headers.get("content-length"));
5358
+ return Response.json({
5359
+ key: info.key,
5360
+ size: info.size
5361
+ });
5362
+ } catch (err) {
5363
+ if (err instanceof UploadRefused) return Response.json({ error: {
5364
+ code: err.code,
5365
+ message: err.message
5366
+ } }, { status: err.status });
5367
+ throw err;
5368
+ }
4114
5369
  }
4115
5370
  return new Response("method not allowed", { status: 405 });
4116
5371
  };
@@ -4120,4 +5375,4 @@ function createFilesHandler(store, opts) {
4120
5375
  };
4121
5376
  }
4122
5377
  //#endregion
4123
- export { createFilesHandler, mountFiles };
5378
+ export { UploadRefused, createFilesHandler, mountFiles };