@ariestools/aries-chain-serve 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin/chainServer.mjs +2287 -1059
  2. package/package.json +9 -9
@@ -18,66 +18,7 @@ var __exportAll = (all, no_symbols) => {
18
18
  return target;
19
19
  };
20
20
  //#endregion
21
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
22
- var _a$1;
23
- function $constructor(name, initializer, params) {
24
- function init(inst, def) {
25
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
26
- value: {
27
- def,
28
- constr: _,
29
- traits: /* @__PURE__ */ new Set()
30
- },
31
- enumerable: false
32
- });
33
- if (inst._zod.traits.has(name)) return;
34
- inst._zod.traits.add(name);
35
- initializer(inst, def);
36
- const proto = _.prototype;
37
- const keys = Object.keys(proto);
38
- for (let i = 0; i < keys.length; i++) {
39
- const k = keys[i];
40
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
41
- }
42
- }
43
- const Parent = params?.Parent ?? Object;
44
- class Definition extends Parent {}
45
- Object.defineProperty(Definition, "name", { value: name });
46
- function _(def) {
47
- var _a;
48
- const inst = params?.Parent ? new Definition() : this;
49
- init(inst, def);
50
- (_a = inst._zod).deferred ?? (_a.deferred = []);
51
- for (const fn of inst._zod.deferred) fn();
52
- return inst;
53
- }
54
- Object.defineProperty(_, "init", { value: init });
55
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
56
- if (params?.Parent && inst instanceof params.Parent) return true;
57
- return inst?._zod?.traits?.has(name);
58
- } });
59
- Object.defineProperty(_, "name", { value: name });
60
- return _;
61
- }
62
- var $ZodAsyncError = class extends Error {
63
- constructor() {
64
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
65
- }
66
- };
67
- var $ZodEncodeError = class extends Error {
68
- constructor(name) {
69
- super(`Encountered unidirectional transform during encode: ${name}`);
70
- this.name = "ZodEncodeError";
71
- }
72
- };
73
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
74
- const globalConfig = globalThis.__zod_globalConfig;
75
- function config(newConfig) {
76
- if (newConfig) Object.assign(globalConfig, newConfig);
77
- return globalConfig;
78
- }
79
- //#endregion
80
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
21
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/util.js
81
22
  function getEnumValues(entries) {
82
23
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
83
24
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
@@ -109,7 +50,7 @@ function cleanRegex(source) {
109
50
  function floatSafeRemainder(val, step) {
110
51
  const ratio = val / step;
111
52
  const roundedRatio = Math.round(ratio);
112
- const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
53
+ const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
113
54
  if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
114
55
  return ratio - roundedRatio;
115
56
  }
@@ -227,16 +168,16 @@ function stringifyPrimitive(value) {
227
168
  }
228
169
  function optionalKeys(shape) {
229
170
  return Object.keys(shape).filter((k) => {
230
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
171
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
231
172
  });
232
173
  }
233
- const NUMBER_FORMAT_RANGES = {
174
+ const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
234
175
  safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
235
176
  int32: [-2147483648, 2147483647],
236
177
  uint32: [0, 4294967295],
237
178
  float32: [-34028234663852886e22, 34028234663852886e22],
238
179
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
239
- };
180
+ }))();
240
181
  const BIGINT_FORMAT_RANGES = {
241
182
  int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
242
183
  uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
@@ -248,10 +189,10 @@ function pick(schema, mask) {
248
189
  return clone(schema, mergeDefs(schema._zod.def, {
249
190
  get shape() {
250
191
  const newShape = {};
251
- for (const key in mask) {
252
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
192
+ for (const key of Reflect.ownKeys(mask)) {
193
+ if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
253
194
  if (!mask[key]) continue;
254
- newShape[key] = currDef.shape[key];
195
+ assignProp(newShape, key, currDef.shape[key]);
255
196
  }
256
197
  assignProp(this, "shape", newShape);
257
198
  return newShape;
@@ -266,8 +207,8 @@ function omit(schema, mask) {
266
207
  return clone(schema, mergeDefs(schema._zod.def, {
267
208
  get shape() {
268
209
  const newShape = { ...schema._zod.def.shape };
269
- for (const key in mask) {
270
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
210
+ for (const key of Reflect.ownKeys(mask)) {
211
+ if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
271
212
  if (!mask[key]) continue;
272
213
  delete newShape[key];
273
214
  }
@@ -282,7 +223,7 @@ function extend(schema, shape) {
282
223
  const checks = schema._zod.def.checks;
283
224
  if (checks && checks.length > 0) {
284
225
  const existingShape = schema._zod.def.shape;
285
- 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.");
226
+ 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.");
286
227
  }
287
228
  return clone(schema, mergeDefs(schema._zod.def, { get shape() {
288
229
  const _shape = {
@@ -305,6 +246,7 @@ function safeExtend(schema, shape) {
305
246
  } }));
306
247
  }
307
248
  function merge$1(a, b) {
249
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
308
250
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
309
251
  return clone(a, mergeDefs(a._zod.def, {
310
252
  get shape() {
@@ -321,22 +263,22 @@ function merge$1(a, b) {
321
263
  checks: b._zod.def.checks ?? []
322
264
  }));
323
265
  }
324
- function partial(Class, schema, mask) {
266
+ function partial(Class, schema, mask, name = "partial") {
325
267
  const checks = schema._zod.def.checks;
326
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
268
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
327
269
  return clone(schema, mergeDefs(schema._zod.def, {
328
270
  get shape() {
329
271
  const oldShape = schema._zod.def.shape;
330
272
  const shape = { ...oldShape };
331
- if (mask) for (const key in mask) {
332
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
273
+ if (mask) for (const key of Reflect.ownKeys(mask)) {
274
+ if (!Object.prototype.hasOwnProperty.call(oldShape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
333
275
  if (!mask[key]) continue;
334
276
  shape[key] = Class ? new Class({
335
277
  type: "optional",
336
278
  innerType: oldShape[key]
337
279
  }) : oldShape[key];
338
280
  }
339
- else for (const key in oldShape) shape[key] = Class ? new Class({
281
+ else for (const key of Reflect.ownKeys(oldShape)) shape[key] = Class ? new Class({
340
282
  type: "optional",
341
283
  innerType: oldShape[key]
342
284
  }) : oldShape[key];
@@ -350,15 +292,15 @@ function required(Class, schema, mask) {
350
292
  return clone(schema, mergeDefs(schema._zod.def, { get shape() {
351
293
  const oldShape = schema._zod.def.shape;
352
294
  const shape = { ...oldShape };
353
- if (mask) for (const key in mask) {
354
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
295
+ if (mask) for (const key of Reflect.ownKeys(mask)) {
296
+ if (!Object.prototype.hasOwnProperty.call(shape, key)) throw new Error(`Unrecognized key: "${String(key)}"`);
355
297
  if (!mask[key]) continue;
356
298
  shape[key] = new Class({
357
299
  type: "nonoptional",
358
300
  innerType: oldShape[key]
359
301
  });
360
302
  }
361
- else for (const key in oldShape) shape[key] = new Class({
303
+ else for (const key of Reflect.ownKeys(oldShape)) shape[key] = new Class({
362
304
  type: "nonoptional",
363
305
  innerType: oldShape[key]
364
306
  });
@@ -387,9 +329,20 @@ function prefixIssues(path, issues) {
387
329
  function unwrapMessage(message) {
388
330
  return typeof message === "string" ? message : message?.message;
389
331
  }
332
+ function attachSchema(issues, start, inst) {
333
+ var _a;
334
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
335
+ }
390
336
  function finalizeIssue(iss, ctx, config) {
391
- 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";
392
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
337
+ var _a;
338
+ const traits = iss.inst?._zod?.traits;
339
+ if (traits?.has("$ZodType")) {
340
+ if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
341
+ else iss.schema = iss.inst;
342
+ }
343
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
344
+ 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";
345
+ const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
393
346
  rest.path ?? (rest.path = []);
394
347
  rest.message = message;
395
348
  if (ctx?.reportInput) rest.input = _input;
@@ -401,6 +354,17 @@ function getSizableOrigin(input) {
401
354
  if (input instanceof File) return "file";
402
355
  return "unknown";
403
356
  }
357
+ const highSurrogate = /[\uD800-\uDBFF]/;
358
+ function codePointLength(str) {
359
+ const units = str.length;
360
+ if (!highSurrogate.test(str)) return units;
361
+ let count = units;
362
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
363
+ count--;
364
+ i++;
365
+ }
366
+ return count;
367
+ }
404
368
  function getLengthableOrigin(input) {
405
369
  if (Array.isArray(input)) return "array";
406
370
  if (typeof input === "string") return "string";
@@ -429,33 +393,330 @@ function issue(...args) {
429
393
  };
430
394
  return { ...iss };
431
395
  }
432
- //#endregion
433
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
434
- const initializer$1 = (inst, def) => {
435
- inst.name = "$ZodError";
436
- Object.defineProperty(inst, "_zod", {
437
- value: inst._zod,
438
- enumerable: false
396
+ /**
397
+ * 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.
398
+ *
399
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
400
+ */
401
+ function members(proto, table) {
402
+ for (const key in table) {
403
+ const desc = Object.getOwnPropertyDescriptor(table, key);
404
+ if (desc.get) Object.defineProperty(proto, key, {
405
+ ...desc,
406
+ enumerable: false
407
+ });
408
+ else defineBound(proto, key, desc.value);
409
+ }
410
+ }
411
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
412
+ function own(inst, key, value, enumerable = true) {
413
+ Object.defineProperty(inst, key, {
414
+ configurable: true,
415
+ writable: true,
416
+ enumerable,
417
+ value
418
+ });
419
+ return value;
420
+ }
421
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
422
+ function hide(inst, key, value) {
423
+ return own(inst, key, value, false);
424
+ }
425
+ function defineBound(proto, key, fn) {
426
+ Object.defineProperty(proto, key, {
427
+ configurable: true,
428
+ get() {
429
+ return own(this, key, fn.bind(this));
430
+ },
431
+ set(value) {
432
+ own(this, key, value);
433
+ }
439
434
  });
440
- Object.defineProperty(inst, "issues", {
441
- value: def,
442
- enumerable: false
435
+ }
436
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
437
+ function claim(inst, sentinel) {
438
+ const proto = Object.getPrototypeOf(inst);
439
+ return sentinel in proto ? void 0 : proto;
440
+ }
441
+ let installing;
442
+ let broke = false;
443
+ const breaker = {
444
+ configurable: true,
445
+ get() {
446
+ broke = true;
447
+ }
448
+ };
449
+ /**
450
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
451
+ * constructor, computed from the internals object itself and cached there on
452
+ * first read. One accessor per constructor rather than one per instance.
453
+ */
454
+ function defineLazyInternal(inst, key, compute) {
455
+ const proto = Object.getPrototypeOf(inst._zod);
456
+ if (key in proto && installing !== inst._zod) {
457
+ installing = void 0;
458
+ return;
459
+ }
460
+ installing = inst._zod;
461
+ Object.defineProperty(proto, key, {
462
+ configurable: true,
463
+ get() {
464
+ Object.defineProperty(this, key, breaker);
465
+ const outer = broke;
466
+ broke = false;
467
+ try {
468
+ const value = compute(this);
469
+ if (broke) delete this[key];
470
+ else Object.defineProperty(this, key, {
471
+ configurable: true,
472
+ writable: true,
473
+ value
474
+ });
475
+ broke = broke || outer;
476
+ return value;
477
+ } catch (err) {
478
+ delete this[key];
479
+ broke = broke || outer;
480
+ throw err;
481
+ }
482
+ },
483
+ set(value) {
484
+ Object.defineProperty(this, key, {
485
+ configurable: true,
486
+ writable: true,
487
+ value
488
+ });
489
+ }
443
490
  });
444
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
445
- Object.defineProperty(inst, "toString", {
446
- value: () => inst.message,
447
- enumerable: false
491
+ }
492
+ /**
493
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
494
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
495
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
496
+ */
497
+ function installLazyProp(inst, key, make, enumerable) {
498
+ const proto = claim(inst, key);
499
+ if (!proto) return;
500
+ Object.defineProperty(proto, key, {
501
+ configurable: true,
502
+ get() {
503
+ const desc = {
504
+ configurable: true,
505
+ writable: true,
506
+ enumerable,
507
+ value: void 0
508
+ };
509
+ Object.defineProperty(this, key, desc);
510
+ desc.value = make(this);
511
+ Object.defineProperty(this, key, desc);
512
+ return desc.value;
513
+ },
514
+ set(value) {
515
+ Object.defineProperty(this, key, {
516
+ configurable: true,
517
+ writable: true,
518
+ enumerable,
519
+ value
520
+ });
521
+ }
448
522
  });
523
+ }
524
+ /** 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. */
525
+ const CONSTANT_CATCH = "~constantCatch";
526
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
527
+ function constantCatch(value) {
528
+ const fn = () => value;
529
+ fn[CONSTANT_CATCH] = true;
530
+ return fn;
531
+ }
532
+ //#endregion
533
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/core.js
534
+ var _a$1;
535
+ const _zodDesc$1 = {
536
+ value: void 0,
537
+ enumerable: false
538
+ };
539
+ let _E = "captureStackTrace" in Error ? Error : null;
540
+ function newError(Definition) {
541
+ const E = _E;
542
+ if (E) {
543
+ const saved = E.stackTraceLimit;
544
+ if (typeof saved === "number") {
545
+ try {
546
+ E.stackTraceLimit = 0;
547
+ } catch {
548
+ _E = null;
549
+ return new Definition();
550
+ }
551
+ try {
552
+ return new Definition();
553
+ } finally {
554
+ E.stackTraceLimit = saved;
555
+ }
556
+ }
557
+ }
558
+ return new Definition();
559
+ }
560
+ function $constructor(name, initializer, proto, params) {
561
+ const zodProto = {};
562
+ function Internals(def) {
563
+ this.def = def;
564
+ this.constr = _;
565
+ this.traits = /* @__PURE__ */ new Set();
566
+ }
567
+ Internals.prototype = zodProto;
568
+ const protoMembers = proto;
569
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
570
+ function init(inst, def) {
571
+ if (!inst._zod) {
572
+ _zodDesc$1.value = new Internals(def);
573
+ try {
574
+ Object.defineProperty(inst, "_zod", _zodDesc$1);
575
+ } finally {
576
+ _zodDesc$1.value = void 0;
577
+ }
578
+ }
579
+ if (inst._zod.traits.has(name)) return;
580
+ inst._zod.traits.add(name);
581
+ initializer(inst, def);
582
+ if (initialized) {
583
+ const own = Object.getPrototypeOf(inst);
584
+ const ctorProto = inst._zod.constr.prototype;
585
+ let up = own;
586
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
587
+ const target = up ?? own;
588
+ if (!initialized.has(target)) {
589
+ initialized.add(target);
590
+ members(target, protoMembers);
591
+ }
592
+ }
593
+ const proto = _.prototype;
594
+ for (const k in proto) {
595
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
596
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
597
+ }
598
+ }
599
+ const Parent = params?.Parent ?? Object;
600
+ class Definition extends Parent {}
601
+ Object.defineProperty(Definition, "name", { value: name });
602
+ function _(def) {
603
+ const inst = params?.Parent ? newError(Definition) : this;
604
+ init(inst, def);
605
+ const deferred = inst._zod.deferred;
606
+ if (deferred) {
607
+ for (const fn of deferred) fn();
608
+ inst._zod.deferred = void 0;
609
+ }
610
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
611
+ if (pp) pp(inst);
612
+ return inst;
613
+ }
614
+ Object.defineProperty(_, "init", { value: init });
615
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
616
+ if (params?.Parent && inst instanceof params.Parent) return true;
617
+ return inst?._zod?.traits?.has(name);
618
+ } });
619
+ Object.defineProperty(_, "name", { value: name });
620
+ return _;
621
+ }
622
+ var $ZodAsyncError = class extends Error {
623
+ constructor() {
624
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
625
+ }
626
+ };
627
+ var $ZodEncodeError = class extends Error {
628
+ constructor(name) {
629
+ super(`Encountered unidirectional transform during encode: ${name}`);
630
+ this.name = "ZodEncodeError";
631
+ }
632
+ };
633
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
634
+ const globalConfig = globalThis.__zod_globalConfig;
635
+ function config(newConfig) {
636
+ if (newConfig) Object.assign(globalConfig, newConfig);
637
+ return globalConfig;
638
+ }
639
+ //#endregion
640
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/errors.js
641
+ function _getMessage() {
642
+ const internals = this._zod;
643
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
644
+ return internals.message;
645
+ }
646
+ function _setMessage(value) {
647
+ this._zod.message = value;
648
+ }
649
+ const _messageDesc = {
650
+ get: _getMessage,
651
+ set: _setMessage,
652
+ enumerable: true,
653
+ configurable: true
654
+ };
655
+ const _zodDesc = {
656
+ value: void 0,
657
+ enumerable: false
658
+ };
659
+ const _issuesDesc = {
660
+ value: void 0,
661
+ enumerable: false
662
+ };
663
+ const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
664
+ const initializer$1 = (inst, def) => {
665
+ inst.name = "$ZodError";
666
+ _zodDesc.value = inst._zod;
667
+ Object.defineProperty(inst, "_zod", _zodDesc);
668
+ _issuesDesc.value = def;
669
+ Object.defineProperty(inst, "issues", _issuesDesc);
670
+ _zodDesc.value = void 0;
671
+ _issuesDesc.value = void 0;
672
+ Object.defineProperty(inst, "message", _messageDesc);
673
+ const proto = Object.getPrototypeOf(inst);
674
+ if (!_installedToString.has(proto)) {
675
+ _installedToString.add(proto);
676
+ Object.defineProperty(proto, "toString", {
677
+ configurable: true,
678
+ enumerable: false,
679
+ get() {
680
+ const value = () => this.message;
681
+ Object.defineProperty(this, "toString", {
682
+ value,
683
+ configurable: true,
684
+ writable: true
685
+ });
686
+ return value;
687
+ },
688
+ set(value) {
689
+ Object.defineProperty(this, "toString", {
690
+ value,
691
+ configurable: true,
692
+ writable: true
693
+ });
694
+ }
695
+ });
696
+ }
449
697
  };
450
698
  const $ZodError = $constructor("$ZodError", initializer$1);
451
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
699
+ const $ZodRealError = $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
700
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
701
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
702
+ * "__proto__" would hit the setter instead of creating a key. */
703
+ function node(obj, key, make) {
704
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
705
+ if (key === "__proto__") Object.defineProperty(obj, key, {
706
+ value: make(),
707
+ writable: true,
708
+ enumerable: true,
709
+ configurable: true
710
+ });
711
+ else obj[key] = make();
712
+ }
713
+ return obj[key];
714
+ }
452
715
  function flattenError(error, mapper = (issue) => issue.message) {
453
716
  const fieldErrors = {};
454
717
  const formErrors = [];
455
- for (const sub of error.issues) if (sub.path.length > 0) {
456
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
457
- fieldErrors[sub.path[0]].push(mapper(sub));
458
- } else formErrors.push(mapper(sub));
718
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
719
+ else formErrors.push(mapper(sub));
459
720
  return {
460
721
  formErrors,
461
722
  fieldErrors
@@ -475,12 +736,21 @@ function formatError$1(error, mapper = (issue) => issue.message) {
475
736
  let i = 0;
476
737
  while (i < fullpath.length) {
477
738
  const el = fullpath[i];
478
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
479
- else {
480
- curr[el] = curr[el] || { _errors: [] };
481
- curr[el]._errors.push(mapper(issue));
739
+ const terminal = i === fullpath.length - 1;
740
+ if (el === "_errors") {
741
+ if (terminal) curr._errors.push(mapper(issue));
742
+ i++;
743
+ continue;
482
744
  }
483
- curr = curr[el];
745
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
746
+ value: { _errors: [] },
747
+ enumerable: true,
748
+ writable: true,
749
+ configurable: true
750
+ });
751
+ const node = curr[el];
752
+ if (terminal) node._errors.push(mapper(issue));
753
+ curr = node;
484
754
  i++;
485
755
  }
486
756
  }
@@ -490,41 +760,53 @@ function formatError$1(error, mapper = (issue) => issue.message) {
490
760
  return fieldErrors;
491
761
  }
492
762
  //#endregion
493
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
494
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
495
- const ctx = _ctx ? {
496
- ..._ctx,
497
- async: false
498
- } : { async: false };
499
- const result = schema._zod.run({
500
- value,
501
- issues: []
502
- }, ctx);
503
- if (result instanceof Promise) throw new $ZodAsyncError();
504
- if (result.issues.length) {
505
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
506
- captureStackTrace(e, _params?.callee);
507
- throw e;
508
- }
509
- return result.value;
763
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/parse.js
764
+ function finalizeParams(callee, params) {
765
+ return {
766
+ callee: params?.callee ?? callee,
767
+ Err: params?.Err
768
+ };
769
+ }
770
+ const _parse = (_Err) => {
771
+ const fn = (schema, value, _ctx, _params) => {
772
+ const ctx = _ctx ? {
773
+ ..._ctx,
774
+ async: false
775
+ } : { async: false };
776
+ const result = schema._zod.run({
777
+ value,
778
+ issues: []
779
+ }, ctx);
780
+ if (result instanceof Promise) throw new $ZodAsyncError();
781
+ if (result.issues.length) {
782
+ const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
783
+ captureStackTrace(e, _params?.callee ?? fn);
784
+ throw e;
785
+ }
786
+ return result.value;
787
+ };
788
+ return fn;
510
789
  };
511
790
  const parse$1 = /* @__PURE__*/ _parse($ZodRealError);
512
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
513
- const ctx = _ctx ? {
514
- ..._ctx,
515
- async: true
516
- } : { async: true };
517
- let result = schema._zod.run({
518
- value,
519
- issues: []
520
- }, ctx);
521
- if (result instanceof Promise) result = await result;
522
- if (result.issues.length) {
523
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
524
- captureStackTrace(e, params?.callee);
525
- throw e;
526
- }
527
- return result.value;
791
+ const _parseAsync = (_Err) => {
792
+ const fn = async (schema, value, _ctx, params) => {
793
+ const ctx = _ctx ? {
794
+ ..._ctx,
795
+ async: true
796
+ } : { async: true };
797
+ let result = schema._zod.run({
798
+ value,
799
+ issues: []
800
+ }, ctx);
801
+ if (result instanceof Promise) result = await result;
802
+ if (result.issues.length) {
803
+ const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
804
+ captureStackTrace(e, params?.callee ?? fn);
805
+ throw e;
806
+ }
807
+ return result.value;
808
+ };
809
+ return fn;
528
810
  };
529
811
  const parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
530
812
  const _safeParse = (_Err) => (schema, value, _ctx) => {
@@ -565,25 +847,41 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
565
847
  };
566
848
  };
567
849
  const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
568
- const _encode = (_Err) => (schema, value, _ctx) => {
569
- const ctx = _ctx ? {
570
- ..._ctx,
571
- direction: "backward"
572
- } : { direction: "backward" };
573
- return _parse(_Err)(schema, value, ctx);
850
+ const _encode = (_Err) => {
851
+ const parse = _parse(_Err);
852
+ const fn = (schema, value, _ctx, _params) => {
853
+ const ctx = _ctx ? {
854
+ ..._ctx,
855
+ direction: "backward"
856
+ } : { direction: "backward" };
857
+ return parse(schema, value, ctx, finalizeParams(fn, _params));
858
+ };
859
+ return fn;
574
860
  };
575
- const _decode = (_Err) => (schema, value, _ctx) => {
576
- return _parse(_Err)(schema, value, _ctx);
861
+ const _decode = (_Err) => {
862
+ const parse = _parse(_Err);
863
+ const fn = (schema, value, _ctx, _params) => {
864
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
865
+ };
866
+ return fn;
577
867
  };
578
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
579
- const ctx = _ctx ? {
580
- ..._ctx,
581
- direction: "backward"
582
- } : { direction: "backward" };
583
- return _parseAsync(_Err)(schema, value, ctx);
868
+ const _encodeAsync = (_Err) => {
869
+ const parseAsync = _parseAsync(_Err);
870
+ const fn = async (schema, value, _ctx, _params) => {
871
+ const ctx = _ctx ? {
872
+ ..._ctx,
873
+ direction: "backward"
874
+ } : { direction: "backward" };
875
+ return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
876
+ };
877
+ return fn;
584
878
  };
585
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
586
- return _parseAsync(_Err)(schema, value, _ctx);
879
+ const _decodeAsync = (_Err) => {
880
+ const parseAsync = _parseAsync(_Err);
881
+ const fn = async (schema, value, _ctx, _params) => {
882
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
883
+ };
884
+ return fn;
587
885
  };
588
886
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
589
887
  const ctx = _ctx ? {
@@ -606,7 +904,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
606
904
  return _safeParseAsync(_Err)(schema, value, _ctx);
607
905
  };
608
906
  //#endregion
609
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
907
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/regexes.js
610
908
  var regexes_exports = /* @__PURE__ */ __exportAll({
611
909
  base64: () => base64$1,
612
910
  base64url: () => base64url$1,
@@ -615,6 +913,7 @@ var regexes_exports = /* @__PURE__ */ __exportAll({
615
913
  browserEmail: () => browserEmail,
616
914
  cidrv4: () => cidrv4$1,
617
915
  cidrv6: () => cidrv6$1,
916
+ creditCard: () => creditCard$1,
618
917
  cuid: () => cuid$1,
619
918
  cuid2: () => cuid2$1,
620
919
  date: () => date$2,
@@ -641,6 +940,7 @@ var regexes_exports = /* @__PURE__ */ __exportAll({
641
940
  md5_base64url: () => md5_base64url,
642
941
  md5_hex: () => md5_hex,
643
942
  nanoid: () => nanoid$1,
943
+ nanoidOfLength: () => nanoidOfLength,
644
944
  null: () => _null$3,
645
945
  number: () => number$2,
646
946
  rfc5322Email: () => rfc5322Email,
@@ -675,10 +975,13 @@ var regexes_exports = /* @__PURE__ */ __exportAll({
675
975
  */
676
976
  const cuid$1 = /^[cC][0-9a-z]{6,}$/;
677
977
  const cuid2$1 = /^[0-9a-z]+$/;
678
- const ulid$1 = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
978
+ const ulid$1 = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
679
979
  const xid$1 = /^[0-9a-vA-V]{20}$/;
680
980
  const ksuid$1 = /^[A-Za-z0-9]{27}$/;
681
981
  const nanoid$1 = /^[a-zA-Z0-9_-]{21}$/;
982
+ function nanoidOfLength(length) {
983
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
984
+ }
682
985
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
683
986
  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)?)?)$/;
684
987
  /** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
@@ -705,7 +1008,7 @@ const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+
705
1008
  const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
706
1009
  const idnEmail = unicodeEmail;
707
1010
  const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
708
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1011
+ const _emoji$1 = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
709
1012
  function emoji$1() {
710
1013
  return new RegExp(_emoji$1, "u");
711
1014
  }
@@ -716,28 +1019,37 @@ const mac$1 = (delimiter) => {
716
1019
  return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
717
1020
  };
718
1021
  const cidrv4$1 = /^((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])$/;
719
- const cidrv6$1 = /^(([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])$/;
1022
+ const cidrv6$1 = /^(([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])$/;
720
1023
  const base64$1 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
721
1024
  const base64url$1 = /^[A-Za-z0-9_-]*$/;
722
1025
  const hostname$1 = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
723
- const domain = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
1026
+ const domain = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
724
1027
  const httpProtocol = /^https?$/;
725
1028
  const e164$1 = /^\+[1-9]\d{6,14}$/;
1029
+ const creditCard$1 = /^\d(?:[ -]?\d){11,18}$/;
726
1030
  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])))`;
727
- const date$2 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1031
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
1032
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
1033
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
1034
+ function anchor(source) {
1035
+ return new RegExp(`^${source}$`);
1036
+ }
1037
+ const date$2 = /*@__PURE__*/ anchor(dateSource);
728
1038
  function timeSource(args) {
729
1039
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
730
- 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+)?)?`;
1040
+ 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+)?)?`;
731
1041
  }
732
1042
  function time$1(args) {
733
1043
  return new RegExp(`^${timeSource(args)}$`);
734
1044
  }
735
1045
  function datetime$1(args) {
736
- const time = timeSource({ precision: args.precision });
737
1046
  const opts = ["Z"];
738
- if (args.local) opts.push("");
739
1047
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
740
- const timeRegex = `${time}(?:${opts.join("|")})`;
1048
+ const qualified = `${timeSource({
1049
+ precision: args.precision,
1050
+ seconds: true
1051
+ })}(?:${opts.join("|")})`;
1052
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
741
1053
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
742
1054
  }
743
1055
  const string$2 = (params) => {
@@ -775,13 +1087,23 @@ const sha512_hex = /^[0-9a-fA-F]{128}$/;
775
1087
  const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
776
1088
  const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
777
1089
  //#endregion
778
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
1090
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/checks.js
779
1091
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
780
1092
  var _a;
781
1093
  inst._zod ?? (inst._zod = {});
782
1094
  inst._zod.def = def;
783
1095
  (_a = inst._zod).onattach ?? (_a.onattach = []);
784
1096
  });
1097
+ /** Default `when` for size-based checks: run only on non-nullish values with a `size`. */
1098
+ const _whenHasSize = (payload) => {
1099
+ const val = payload.value;
1100
+ return !nullish$1(val) && val.size !== void 0;
1101
+ };
1102
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1103
+ const _whenHasLength = (payload) => {
1104
+ const val = payload.value;
1105
+ return !nullish$1(val) && val.length !== void 0;
1106
+ };
785
1107
  const numericOriginMap = {
786
1108
  number: "number",
787
1109
  bigint: "bigint",
@@ -801,7 +1123,7 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
801
1123
  inst._zod.check = (payload) => {
802
1124
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
803
1125
  payload.issues.push({
804
- origin,
1126
+ origin: numericOriginMap[typeof payload.value] ?? origin,
805
1127
  code: "too_big",
806
1128
  maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
807
1129
  input: payload.value,
@@ -825,7 +1147,7 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
825
1147
  inst._zod.check = (payload) => {
826
1148
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
827
1149
  payload.issues.push({
828
- origin,
1150
+ origin: numericOriginMap[typeof payload.value] ?? origin,
829
1151
  code: "too_small",
830
1152
  minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
831
1153
  input: payload.value,
@@ -843,7 +1165,7 @@ const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (i
843
1165
  });
844
1166
  inst._zod.check = (payload) => {
845
1167
  if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
846
- if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
1168
+ if (typeof payload.value === "bigint" ? def.value !== BigInt(0) && payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
847
1169
  payload.issues.push({
848
1170
  origin: typeof payload.value,
849
1171
  code: "not_multiple_of",
@@ -959,10 +1281,7 @@ const $ZodCheckBigIntFormat = /*@__PURE__*/ $constructor("$ZodCheckBigIntFormat"
959
1281
  const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (inst, def) => {
960
1282
  var _a;
961
1283
  $ZodCheck.init(inst, def);
962
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
963
- const val = payload.value;
964
- return !nullish$1(val) && val.size !== void 0;
965
- });
1284
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
966
1285
  inst._zod.onattach.push((inst) => {
967
1286
  const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
968
1287
  if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
@@ -984,10 +1303,7 @@ const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (inst, d
984
1303
  const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (inst, def) => {
985
1304
  var _a;
986
1305
  $ZodCheck.init(inst, def);
987
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
988
- const val = payload.value;
989
- return !nullish$1(val) && val.size !== void 0;
990
- });
1306
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
991
1307
  inst._zod.onattach.push((inst) => {
992
1308
  const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
993
1309
  if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
@@ -1009,10 +1325,7 @@ const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (inst, d
1009
1325
  const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (inst, def) => {
1010
1326
  var _a;
1011
1327
  $ZodCheck.init(inst, def);
1012
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1013
- const val = payload.value;
1014
- return !nullish$1(val) && val.size !== void 0;
1015
- });
1328
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
1016
1329
  inst._zod.onattach.push((inst) => {
1017
1330
  const bag = inst._zod.bag;
1018
1331
  bag.minimum = def.size;
@@ -1044,17 +1357,15 @@ const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (i
1044
1357
  const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
1045
1358
  var _a;
1046
1359
  $ZodCheck.init(inst, def);
1047
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1048
- const val = payload.value;
1049
- return !nullish$1(val) && val.length !== void 0;
1050
- });
1360
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
1051
1361
  inst._zod.onattach.push((inst) => {
1052
1362
  const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
1053
1363
  if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
1054
1364
  });
1055
1365
  inst._zod.check = (payload) => {
1056
1366
  const input = payload.value;
1057
- if (input.length <= def.maximum) return;
1367
+ const units = input.length;
1368
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
1058
1369
  const origin = getLengthableOrigin(input);
1059
1370
  payload.issues.push({
1060
1371
  origin,
@@ -1070,17 +1381,15 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
1070
1381
  const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
1071
1382
  var _a;
1072
1383
  $ZodCheck.init(inst, def);
1073
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1074
- const val = payload.value;
1075
- return !nullish$1(val) && val.length !== void 0;
1076
- });
1384
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
1077
1385
  inst._zod.onattach.push((inst) => {
1078
1386
  const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
1079
1387
  if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
1080
1388
  });
1081
1389
  inst._zod.check = (payload) => {
1082
1390
  const input = payload.value;
1083
- if (input.length >= def.minimum) return;
1391
+ const units = input.length;
1392
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
1084
1393
  const origin = getLengthableOrigin(input);
1085
1394
  payload.issues.push({
1086
1395
  origin,
@@ -1096,10 +1405,7 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
1096
1405
  const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1097
1406
  var _a;
1098
1407
  $ZodCheck.init(inst, def);
1099
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1100
- const val = payload.value;
1101
- return !nullish$1(val) && val.length !== void 0;
1102
- });
1408
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
1103
1409
  inst._zod.onattach.push((inst) => {
1104
1410
  const bag = inst._zod.bag;
1105
1411
  bag.minimum = def.length;
@@ -1108,7 +1414,8 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
1108
1414
  });
1109
1415
  inst._zod.check = (payload) => {
1110
1416
  const input = payload.value;
1111
- const length = input.length;
1417
+ const units = input.length;
1418
+ const length = typeof input === "string" && units >= def.length && units <= def.length * 2 ? codePointLength(input) : units;
1112
1419
  if (length === def.length) return;
1113
1420
  const origin = getLengthableOrigin(input);
1114
1421
  const tooBig = length > def.length;
@@ -1182,7 +1489,7 @@ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (ins
1182
1489
  const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1183
1490
  $ZodCheck.init(inst, def);
1184
1491
  const escapedRegex = escapeRegex(def.includes);
1185
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1492
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
1186
1493
  def.pattern = pattern;
1187
1494
  inst._zod.onattach.push((inst) => {
1188
1495
  const bag = inst._zod.bag;
@@ -1284,12 +1591,13 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
1284
1591
  };
1285
1592
  });
1286
1593
  //#endregion
1287
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
1594
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/doc.js
1288
1595
  var Doc = class {
1289
- constructor(args = []) {
1596
+ constructor(args = [], closed = {}) {
1290
1597
  this.content = [];
1291
1598
  this.indent = 0;
1292
- if (this) this.args = args;
1599
+ this.args = args;
1600
+ this.closed = closed;
1293
1601
  }
1294
1602
  indented(fn) {
1295
1603
  this.indent += 1;
@@ -1309,28 +1617,27 @@ var Doc = class {
1309
1617
  }
1310
1618
  compile() {
1311
1619
  const F = Function;
1312
- const args = this?.args;
1313
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1314
- return new F(...args, lines.join("\n"));
1620
+ const content = this?.content ?? [``];
1621
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
1315
1622
  }
1316
1623
  };
1317
1624
  //#endregion
1318
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
1625
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/versions.js
1319
1626
  const version = {
1320
1627
  major: 4,
1321
- minor: 4,
1322
- patch: 3
1628
+ minor: 5,
1629
+ patch: 1
1323
1630
  };
1324
1631
  //#endregion
1325
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
1632
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/schemas.js
1326
1633
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1327
1634
  var _a;
1328
1635
  inst ?? (inst = {});
1329
1636
  inst._zod.def = def;
1330
1637
  inst._zod.bag = inst._zod.bag || {};
1331
1638
  inst._zod.version = version;
1332
- const checks = [...inst._zod.def.checks ?? []];
1333
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1639
+ const defChecks = inst._zod.def.checks;
1640
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1334
1641
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1335
1642
  if (checks.length === 0) {
1336
1643
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1339,6 +1646,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1339
1646
  });
1340
1647
  } else {
1341
1648
  const runChecks = (payload, checks, ctx) => {
1649
+ if (payload.memo) return payload;
1342
1650
  let isAborted = aborted(payload);
1343
1651
  let asyncResult;
1344
1652
  for (const ch of checks) {
@@ -1352,10 +1660,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1352
1660
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1353
1661
  await _;
1354
1662
  if (payload.issues.length === currLen) return;
1663
+ attachSchema(payload.issues, currLen, inst);
1355
1664
  if (!isAborted) isAborted = aborted(payload, currLen);
1356
1665
  });
1357
1666
  else {
1358
1667
  if (payload.issues.length === currLen) continue;
1668
+ attachSchema(payload.issues, currLen, inst);
1359
1669
  if (!isAborted) isAborted = aborted(payload, currLen);
1360
1670
  }
1361
1671
  }
@@ -1399,19 +1709,29 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1399
1709
  return runChecks(result, checks, ctx);
1400
1710
  };
1401
1711
  }
1402
- defineLazy(inst, "~standard", () => ({
1712
+ }, {
1713
+ get "~standard"() {
1714
+ return hide(this, "~standard", standardProps(this));
1715
+ },
1716
+ set "~standard"(value) {
1717
+ own(this, "~standard", value);
1718
+ }
1719
+ });
1720
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1721
+ const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
1722
+ function standardProps(inst) {
1723
+ return {
1403
1724
  validate: (value) => {
1404
1725
  try {
1405
- const r = safeParse$1(inst, value);
1406
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1726
+ return toStandardResult(safeParse$1(inst, value));
1407
1727
  } catch (_) {
1408
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1728
+ return safeParseAsync$1(inst, value).then(toStandardResult);
1409
1729
  }
1410
1730
  },
1411
1731
  vendor: "zod",
1412
1732
  version: 1
1413
- }));
1414
- });
1733
+ };
1734
+ }
1415
1735
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1416
1736
  $ZodType.init(inst, def);
1417
1737
  inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$2(inst._zod.bag);
@@ -1458,51 +1778,74 @@ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1458
1778
  def.pattern ?? (def.pattern = email$1);
1459
1779
  $ZodStringFormat.init(inst, def);
1460
1780
  });
1461
- const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1462
- $ZodStringFormat.init(inst, def);
1463
- inst._zod.check = (payload) => {
1464
- try {
1465
- const trimmed = payload.value.trim();
1466
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1467
- if (!/^https?:\/\//i.test(trimmed)) {
1468
- payload.issues.push({
1469
- code: "invalid_format",
1470
- format: "url",
1471
- note: "Invalid URL format",
1472
- input: payload.value,
1473
- inst,
1474
- continue: !def.abort
1475
- });
1476
- return;
1477
- }
1478
- }
1479
- const url = new URL(trimmed);
1480
- if (def.hostname) {
1481
- def.hostname.lastIndex = 0;
1482
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1781
+ /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
1782
+ function parseURLObject(trimmed, def) {
1783
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1784
+ try {
1785
+ return new URL(trimmed);
1786
+ } catch {
1787
+ return 2;
1788
+ }
1789
+ }
1790
+ const asciiTabOrNewline = /[\t\n\r]/g;
1791
+ /** 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. */
1792
+ function stripTabAndNewline(value) {
1793
+ return value.replace(asciiTabOrNewline, "");
1794
+ }
1795
+ function urlHostnameOk(url, hostname) {
1796
+ hostname.lastIndex = 0;
1797
+ return hostname.test(url.hostname);
1798
+ }
1799
+ function urlProtocolOk(url, protocol) {
1800
+ protocol.lastIndex = 0;
1801
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1802
+ }
1803
+ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1804
+ $ZodStringFormat.init(inst, def);
1805
+ inst._zod.check = (payload) => {
1806
+ try {
1807
+ const trimmed = payload.value.trim();
1808
+ const url = parseURLObject(trimmed, def);
1809
+ if (url === 1) {
1810
+ payload.issues.push({
1483
1811
  code: "invalid_format",
1484
1812
  format: "url",
1485
- note: "Invalid hostname",
1486
- pattern: def.hostname.source,
1813
+ note: "Invalid URL format",
1487
1814
  input: payload.value,
1488
1815
  inst,
1489
1816
  continue: !def.abort
1490
1817
  });
1818
+ return;
1491
1819
  }
1492
- if (def.protocol) {
1493
- def.protocol.lastIndex = 0;
1494
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1820
+ if (url === 2) {
1821
+ payload.issues.push({
1495
1822
  code: "invalid_format",
1496
1823
  format: "url",
1497
- note: "Invalid protocol",
1498
- pattern: def.protocol.source,
1499
1824
  input: payload.value,
1500
1825
  inst,
1501
1826
  continue: !def.abort
1502
1827
  });
1828
+ return;
1503
1829
  }
1504
- if (def.normalize) payload.value = url.href;
1505
- else payload.value = trimmed;
1830
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1831
+ code: "invalid_format",
1832
+ format: "url",
1833
+ note: "Invalid hostname",
1834
+ pattern: def.hostname.source,
1835
+ input: payload.value,
1836
+ inst,
1837
+ continue: !def.abort
1838
+ });
1839
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1840
+ code: "invalid_format",
1841
+ format: "url",
1842
+ note: "Invalid protocol",
1843
+ pattern: def.protocol.source,
1844
+ input: payload.value,
1845
+ inst,
1846
+ continue: !def.abort
1847
+ });
1848
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1506
1849
  return;
1507
1850
  } catch (_) {
1508
1851
  payload.issues.push({
@@ -1520,7 +1863,8 @@ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1520
1863
  $ZodStringFormat.init(inst, def);
1521
1864
  });
1522
1865
  const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1523
- def.pattern ?? (def.pattern = nanoid$1);
1866
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1867
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid$1 : nanoidOfLength(def.length));
1524
1868
  $ZodStringFormat.init(inst, def);
1525
1869
  });
1526
1870
  /**
@@ -1551,6 +1895,12 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1551
1895
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1552
1896
  def.pattern ?? (def.pattern = datetime$1(def));
1553
1897
  $ZodStringFormat.init(inst, def);
1898
+ if (def.local || def.precision === -1) {
1899
+ inst._zod.bag.laxFormat = true;
1900
+ inst._zod.onattach.push((s) => {
1901
+ s._zod.bag.laxFormat = true;
1902
+ });
1903
+ }
1554
1904
  });
1555
1905
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1556
1906
  def.pattern ?? (def.pattern = date$2);
@@ -1569,22 +1919,29 @@ const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1569
1919
  $ZodStringFormat.init(inst, def);
1570
1920
  inst._zod.bag.format = `ipv4`;
1571
1921
  });
1922
+ /** 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`. */
1923
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1924
+ function isValidIPv6(value) {
1925
+ if (!ipv6Alphabet.test(value)) return false;
1926
+ try {
1927
+ new URL(`http://[${value}]`);
1928
+ return true;
1929
+ } catch {
1930
+ return false;
1931
+ }
1932
+ }
1572
1933
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1573
1934
  def.pattern ?? (def.pattern = ipv6$1);
1574
1935
  $ZodStringFormat.init(inst, def);
1575
1936
  inst._zod.bag.format = `ipv6`;
1576
1937
  inst._zod.check = (payload) => {
1577
- try {
1578
- new URL(`http://[${payload.value}]`);
1579
- } catch {
1580
- payload.issues.push({
1581
- code: "invalid_format",
1582
- format: "ipv6",
1583
- input: payload.value,
1584
- inst,
1585
- continue: !def.abort
1586
- });
1587
- }
1938
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1939
+ code: "invalid_format",
1940
+ format: "ipv6",
1941
+ input: payload.value,
1942
+ inst,
1943
+ continue: !def.abort
1944
+ });
1588
1945
  };
1589
1946
  });
1590
1947
  const $ZodMAC = /*@__PURE__*/ $constructor("$ZodMAC", (inst, def) => {
@@ -1596,28 +1953,27 @@ const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1596
1953
  def.pattern ?? (def.pattern = cidrv4$1);
1597
1954
  $ZodStringFormat.init(inst, def);
1598
1955
  });
1956
+ function isValidCIDRv6(value) {
1957
+ const parts = value.split("/");
1958
+ if (parts.length !== 2) return false;
1959
+ const [address, prefix] = parts;
1960
+ if (!prefix) return false;
1961
+ const prefixNum = Number(prefix);
1962
+ if (`${prefixNum}` !== prefix) return false;
1963
+ if (prefixNum < 0 || prefixNum > 128) return false;
1964
+ return isValidIPv6(address);
1965
+ }
1599
1966
  const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1600
1967
  def.pattern ?? (def.pattern = cidrv6$1);
1601
1968
  $ZodStringFormat.init(inst, def);
1602
1969
  inst._zod.check = (payload) => {
1603
- const parts = payload.value.split("/");
1604
- try {
1605
- if (parts.length !== 2) throw new Error();
1606
- const [address, prefix] = parts;
1607
- if (!prefix) throw new Error();
1608
- const prefixNum = Number(prefix);
1609
- if (`${prefixNum}` !== prefix) throw new Error();
1610
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1611
- new URL(`http://[${address}]`);
1612
- } catch {
1613
- payload.issues.push({
1614
- code: "invalid_format",
1615
- format: "cidrv6",
1616
- input: payload.value,
1617
- inst,
1618
- continue: !def.abort
1619
- });
1620
- }
1970
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1971
+ code: "invalid_format",
1972
+ format: "cidrv6",
1973
+ input: payload.value,
1974
+ inst,
1975
+ continue: !def.abort
1976
+ });
1621
1977
  };
1622
1978
  });
1623
1979
  function isValidBase64(data) {
@@ -1670,6 +2026,48 @@ const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1670
2026
  def.pattern ?? (def.pattern = e164$1);
1671
2027
  $ZodStringFormat.init(inst, def);
1672
2028
  });
2029
+ const CC_SANITIZE = /[- ]/g;
2030
+ /** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
2031
+ function isLuhnAlgo(digits) {
2032
+ let length = digits.length;
2033
+ let bit = 1;
2034
+ let sum = 0;
2035
+ while (length) {
2036
+ const value = +digits[--length];
2037
+ bit ^= 1;
2038
+ sum += bit ? [
2039
+ 0,
2040
+ 2,
2041
+ 4,
2042
+ 6,
2043
+ 8,
2044
+ 1,
2045
+ 3,
2046
+ 5,
2047
+ 7,
2048
+ 9
2049
+ ][value] : value;
2050
+ }
2051
+ return sum % 10 === 0;
2052
+ }
2053
+ function isValidCreditCard(input) {
2054
+ if (!creditCard$1.test(input)) return false;
2055
+ return isLuhnAlgo(input.replace(CC_SANITIZE, ""));
2056
+ }
2057
+ const $ZodCreditCard = /*@__PURE__*/ $constructor("$ZodCreditCard", (inst, def) => {
2058
+ def.pattern ?? (def.pattern = creditCard$1);
2059
+ $ZodStringFormat.init(inst, def);
2060
+ inst._zod.check = (payload) => {
2061
+ if (isValidCreditCard(payload.value)) return;
2062
+ payload.issues.push({
2063
+ code: "invalid_format",
2064
+ format: "credit_card",
2065
+ input: payload.value,
2066
+ inst,
2067
+ continue: !def.abort
2068
+ });
2069
+ };
2070
+ });
1673
2071
  function isValidJWT(token, algorithm = null) {
1674
2072
  try {
1675
2073
  const tokensParts = token.split(".");
@@ -1720,7 +2118,7 @@ const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1720
2118
  } catch (_) {}
1721
2119
  const input = payload.value;
1722
2120
  if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1723
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
2121
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? String(input) : void 0 : void 0;
1724
2122
  payload.issues.push({
1725
2123
  expected: "number",
1726
2124
  code: "invalid_type",
@@ -1879,6 +2277,8 @@ function handleArrayResult(result, final, index) {
1879
2277
  }
1880
2278
  const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1881
2279
  $ZodType.init(inst, def);
2280
+ const memo = globalConfig.memoizer;
2281
+ memo?.attach(inst);
1882
2282
  inst._zod.parse = (payload, ctx) => {
1883
2283
  const input = payload.value;
1884
2284
  if (!Array.isArray(input)) {
@@ -1890,7 +2290,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1890
2290
  });
1891
2291
  return payload;
1892
2292
  }
1893
- payload.value = Array(input.length);
2293
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1894
2294
  const proms = [];
1895
2295
  for (let i = 0; i < input.length; i++) {
1896
2296
  const item = input[i];
@@ -1905,13 +2305,15 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1905
2305
  return payload;
1906
2306
  };
1907
2307
  });
1908
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
2308
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1909
2309
  const isPresent = key in input;
2310
+ const isOptionalOut = optout === "optional";
2311
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1910
2312
  if (result.issues.length) {
1911
- if (isOptionalIn && isOptionalOut && !isPresent) return;
2313
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1912
2314
  final.issues.push(...prefixIssues(key, result.issues));
1913
2315
  }
1914
- if (!isPresent && !isOptionalIn) {
2316
+ if (!isPresent && optin === void 0) {
1915
2317
  if (!result.issues.length) final.issues.push({
1916
2318
  code: "invalid_type",
1917
2319
  expected: "nonoptional",
@@ -1924,13 +2326,18 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1924
2326
  if (isPresent) final.value[key] = void 0;
1925
2327
  } else final.value[key] = result.value;
1926
2328
  }
2329
+ const NO_SYMBOL_KEYS = [];
1927
2330
  function normalizeDef(def) {
1928
2331
  const keys = Object.keys(def.shape);
1929
- 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`);
2332
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
2333
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
2334
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
2335
+ 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`);
1930
2336
  const okeys = optionalKeys(def.shape);
1931
2337
  return {
1932
2338
  ...def,
1933
- keys,
2339
+ allKeys,
2340
+ symbolKeys,
1934
2341
  keySet: new Set(keys),
1935
2342
  numKeys: keys.length,
1936
2343
  optionalKeys: new Set(okeys)
@@ -1941,11 +2348,14 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1941
2348
  const keySet = def.keySet;
1942
2349
  const _catchall = def.catchall._zod;
1943
2350
  const t = _catchall.def.type;
1944
- const isOptionalIn = _catchall.optin === "optional";
1945
- const isOptionalOut = _catchall.optout === "optional";
2351
+ const optin = _catchall.optin;
2352
+ const optout = _catchall.optout;
1946
2353
  for (const key in input) {
1947
- if (key === "__proto__") continue;
1948
2354
  if (keySet.has(key)) continue;
2355
+ if (key === "__proto__") {
2356
+ if (t === "never") unrecognized.push(key);
2357
+ continue;
2358
+ }
1949
2359
  if (t === "never") {
1950
2360
  unrecognized.push(key);
1951
2361
  continue;
@@ -1954,39 +2364,44 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1954
2364
  value: input[key],
1955
2365
  issues: []
1956
2366
  }, ctx);
1957
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1958
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2367
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2368
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1959
2369
  }
1960
2370
  if (unrecognized.length) payload.issues.push({
1961
2371
  code: "unrecognized_keys",
1962
2372
  keys: unrecognized,
1963
2373
  input,
1964
- inst
2374
+ inst,
2375
+ continue: true
1965
2376
  });
1966
2377
  if (!proms.length) return payload;
1967
2378
  return Promise.all(proms).then(() => {
1968
2379
  return payload;
1969
2380
  });
1970
2381
  }
2382
+ const propShapes = /* @__PURE__ */ new WeakMap();
1971
2383
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1972
2384
  $ZodType.init(inst, def);
1973
2385
  if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1974
2386
  const sh = def.shape;
2387
+ propShapes.set(def, sh);
1975
2388
  Object.defineProperty(def, "shape", { get: () => {
1976
2389
  const newSh = { ...sh };
1977
2390
  Object.defineProperty(def, "shape", { value: newSh });
2391
+ propShapes.set(def, newSh);
1978
2392
  return newSh;
1979
2393
  } });
1980
2394
  }
1981
2395
  const _normalized = cached(() => normalizeDef(def));
1982
- defineLazy(inst._zod, "propValues", () => {
1983
- const shape = def.shape;
2396
+ defineLazyInternal(inst, "propValues", (zod) => {
2397
+ const shape = zod.def.shape;
1984
2398
  const propValues = {};
1985
2399
  for (const key in shape) {
1986
2400
  const field = shape[key]._zod;
1987
2401
  if (field.values) {
1988
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2402
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1989
2403
  for (const v of field.values) propValues[key].add(v);
2404
+ if (field.optin !== void 0) propValues[key].add(void 0);
1990
2405
  }
1991
2406
  }
1992
2407
  return propValues;
@@ -1994,6 +2409,8 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1994
2409
  const isObject = isObject$1;
1995
2410
  const catchall = def.catchall;
1996
2411
  let value;
2412
+ const memo = globalConfig.memoizer;
2413
+ memo?.attach(inst);
1997
2414
  inst._zod.parse = (payload, ctx) => {
1998
2415
  value ?? (value = _normalized.value);
1999
2416
  const input = payload.value;
@@ -2006,19 +2423,20 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
2006
2423
  });
2007
2424
  return payload;
2008
2425
  }
2009
- payload.value = {};
2426
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
2010
2427
  const proms = [];
2011
2428
  const shape = value.shape;
2012
- for (const key of value.keys) {
2429
+ for (const key of value.allKeys) {
2430
+ if (key === "__proto__") continue;
2013
2431
  const el = shape[key];
2014
- const isOptionalIn = el._zod.optin === "optional";
2015
- const isOptionalOut = el._zod.optout === "optional";
2432
+ const optin = el._zod.optin;
2433
+ const optout = el._zod.optout;
2016
2434
  const r = el._zod.run({
2017
2435
  value: input[key],
2018
2436
  issues: []
2019
2437
  }, ctx);
2020
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
2021
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2438
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2439
+ else handlePropertyResult(r, payload, key, input, optin, optout);
2022
2440
  }
2023
2441
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
2024
2442
  return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
@@ -2028,55 +2446,55 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
2028
2446
  $ZodObject.init(inst, def);
2029
2447
  const superParse = inst._zod.parse;
2030
2448
  const _normalized = cached(() => normalizeDef(def));
2449
+ const memo = globalConfig.memoizer;
2031
2450
  const generateFastpass = (shape) => {
2032
- const doc = new Doc([
2033
- "shape",
2034
- "payload",
2035
- "ctx"
2036
- ]);
2037
2451
  const normalized = _normalized.value;
2038
- const parseStr = (key) => {
2039
- const k = esc(key);
2040
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2041
- };
2452
+ const syms = normalized.symbolKeys;
2453
+ const doc = new Doc(["payload", "ctx"], {
2454
+ shape,
2455
+ inst,
2456
+ memo,
2457
+ syms
2458
+ });
2459
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2460
+ const prefixStr = (id, k) => `
2461
+ for (let i = 0; i < ${id}.issues.length; i++) {
2462
+ const iss = ${id}.issues[i];
2463
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2464
+ payload.issues.push(iss);
2465
+ }`;
2042
2466
  doc.write(`const input = payload.value;`);
2043
2467
  const ids = Object.create(null);
2044
2468
  let counter = 0;
2045
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
2046
- doc.write(`const newResult = {};`);
2047
- for (const key of normalized.keys) {
2469
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2470
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2471
+ for (const key of normalized.allKeys) {
2472
+ if (key === "__proto__") continue;
2048
2473
  const id = ids[key];
2049
- const k = esc(key);
2474
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2475
+ const isPresent = `${k} in input`;
2050
2476
  const schema = shape[key];
2051
- const isOptionalIn = schema?._zod?.optin === "optional";
2477
+ const optin = schema?._zod?.optin;
2478
+ const isOptionalIn = optin !== void 0;
2052
2479
  const isOptionalOut = schema?._zod?.optout === "optional";
2053
- doc.write(`const ${id} = ${parseStr(key)};`);
2054
- if (isOptionalIn && isOptionalOut) doc.write(`
2055
- if (${id}.issues.length) {
2056
- if (${k} in input) {
2057
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2058
- ...iss,
2059
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2060
- })));
2480
+ doc.write(`const ${id} = ${parseStr(k)};`);
2481
+ if (isOptionalIn && isOptionalOut) {
2482
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2483
+ doc.write(`
2484
+ const ${id}_present = ${isPresent};
2485
+ if (!${id}.issues.length || ${id}_present) {
2486
+ if (${id}.issues.length) {${prefixStr(id, k)}
2061
2487
  }
2062
- }
2063
-
2064
- if (${id}.value === undefined) {
2065
- if (${k} in input) {
2066
- newResult[${k}] = undefined;
2488
+
2489
+ if (${assign}) {
2490
+ newResult[${k}] = ${id}.value;
2067
2491
  }
2068
- } else {
2069
- newResult[${k}] = ${id}.value;
2070
2492
  }
2071
-
2493
+
2072
2494
  `);
2073
- else if (!isOptionalIn) doc.write(`
2074
- const ${id}_present = ${k} in input;
2075
- if (${id}.issues.length) {
2076
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2077
- ...iss,
2078
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2079
- })));
2495
+ } else if (!isOptionalIn) doc.write(`
2496
+ const ${id}_present = ${isPresent};
2497
+ if (${id}.issues.length) {${prefixStr(id, k)}
2080
2498
  }
2081
2499
  if (!${id}_present && !${id}.issues.length) {
2082
2500
  payload.issues.push({
@@ -2088,36 +2506,27 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
2088
2506
  }
2089
2507
 
2090
2508
  if (${id}_present) {
2091
- if (${id}.value === undefined) {
2092
- newResult[${k}] = undefined;
2093
- } else {
2094
- newResult[${k}] = ${id}.value;
2095
- }
2509
+ newResult[${k}] = ${id}.value;
2096
2510
  }
2097
2511
 
2098
2512
  `);
2099
2513
  else doc.write(`
2100
- if (${id}.issues.length) {
2101
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2102
- ...iss,
2103
- path: iss.path ? [${k}, ...iss.path] : [${k}]
2104
- })));
2514
+ if (${id}.issues.length) {${prefixStr(id, k)}
2105
2515
  }
2106
2516
 
2107
2517
  if (${id}.value === undefined) {
2108
- if (${k} in input) {
2518
+ if (${isPresent}) {
2109
2519
  newResult[${k}] = undefined;
2110
2520
  }
2111
2521
  } else {
2112
2522
  newResult[${k}] = ${id}.value;
2113
2523
  }
2114
-
2524
+
2115
2525
  `);
2116
2526
  }
2117
2527
  doc.write(`payload.value = newResult;`);
2118
2528
  doc.write(`return payload;`);
2119
- const fn = doc.compile();
2120
- return (payload, ctx) => fn(shape, payload, ctx);
2529
+ return doc.compile();
2121
2530
  };
2122
2531
  let fastpass;
2123
2532
  const isObject = isObject$1;
@@ -2166,14 +2575,14 @@ function handleUnionResults(results, final, inst, ctx) {
2166
2575
  }
2167
2576
  const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
2168
2577
  $ZodType.init(inst, def);
2169
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
2170
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2171
- defineLazy(inst._zod, "values", () => {
2172
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2173
- });
2174
- defineLazy(inst._zod, "pattern", () => {
2175
- if (def.options.every((o) => o._zod.pattern)) {
2176
- const patterns = def.options.map((o) => o._zod.pattern);
2578
+ 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);
2579
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2580
+ defineLazyInternal(inst, "values", (zod) => {
2581
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
2582
+ });
2583
+ defineLazyInternal(inst, "pattern", (zod) => {
2584
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2585
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
2177
2586
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
2178
2587
  }
2179
2588
  });
@@ -2202,12 +2611,13 @@ const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
2202
2611
  };
2203
2612
  });
2204
2613
  function handleExclusiveUnionResults(results, final, inst, ctx) {
2205
- const successes = results.filter((r) => r.issues.length === 0);
2206
- if (successes.length === 1) {
2207
- final.value = successes[0].value;
2614
+ const matches = [];
2615
+ for (let i = 0; i < results.length; i++) if (results[i].issues.length === 0) matches.push(i);
2616
+ if (matches.length === 1) {
2617
+ final.value = results[matches[0]].value;
2208
2618
  return final;
2209
2619
  }
2210
- if (successes.length === 0) final.issues.push({
2620
+ if (matches.length === 0) final.issues.push({
2211
2621
  code: "invalid_union",
2212
2622
  input: final.value,
2213
2623
  inst,
@@ -2218,7 +2628,8 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
2218
2628
  input: final.value,
2219
2629
  inst,
2220
2630
  errors: [],
2221
- inclusive: false
2631
+ inclusive: false,
2632
+ matches
2222
2633
  });
2223
2634
  return final;
2224
2635
  }
@@ -2250,18 +2661,22 @@ const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnio
2250
2661
  def.inclusive = false;
2251
2662
  $ZodUnion.init(inst, def);
2252
2663
  const _super = inst._zod.parse;
2253
- defineLazy(inst._zod, "propValues", () => {
2664
+ defineLazyInternal(inst, "propValues", (zod) => {
2254
2665
  const propValues = {};
2255
- for (const option of def.options) {
2666
+ for (const option of zod.def.options) {
2256
2667
  const pv = option._zod.propValues;
2257
- if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
2668
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
2258
2669
  for (const [k, v] of Object.entries(pv)) {
2259
- if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
2670
+ if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
2260
2671
  for (const val of v) propValues[k].add(val);
2261
2672
  }
2262
2673
  }
2263
2674
  return propValues;
2264
2675
  });
2676
+ def.options.forEach((option, i) => {
2677
+ const propShape = propShapes.get(option._zod.def);
2678
+ if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
2679
+ });
2265
2680
  const disc = cached(() => {
2266
2681
  const opts = def.options;
2267
2682
  const map = /* @__PURE__ */ new Map();
@@ -2336,7 +2751,9 @@ function mergeValues(a, b) {
2336
2751
  ...a,
2337
2752
  ...b
2338
2753
  };
2754
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
2339
2755
  for (const key of sharedKeys) {
2756
+ if (key === "__proto__") continue;
2340
2757
  const sharedValue = mergeValues(a[key], b[key]);
2341
2758
  if (!sharedValue.valid) return {
2342
2759
  valid: false,
@@ -2378,32 +2795,47 @@ function mergeValues(a, b) {
2378
2795
  function handleIntersectionResults(result, left, right) {
2379
2796
  const unrecKeys = /* @__PURE__ */ new Map();
2380
2797
  let unrecIssue;
2381
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
2382
- unrecIssue ?? (unrecIssue = iss);
2383
- for (const k of iss.keys) {
2798
+ const keyIssues = /* @__PURE__ */ new Map();
2799
+ const collect = (iss, side) => {
2800
+ let keys;
2801
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2802
+ unrecIssue ?? (unrecIssue = iss);
2803
+ keys = iss.keys;
2804
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2805
+ const k = String(iss.path[0]);
2806
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2807
+ keys = [k];
2808
+ } else return false;
2809
+ for (const k of keys) {
2384
2810
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2385
- unrecKeys.get(k).l = true;
2811
+ unrecKeys.get(k)[side] = true;
2386
2812
  }
2387
- } else result.issues.push(iss);
2388
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2389
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2390
- unrecKeys.get(k).r = true;
2391
- }
2392
- else result.issues.push(iss);
2813
+ return true;
2814
+ };
2815
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2816
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
2393
2817
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2394
- if (bothKeys.length && unrecIssue) result.issues.push({
2395
- ...unrecIssue,
2396
- keys: bothKeys
2397
- });
2398
- if (aborted(result)) return result;
2818
+ if (bothKeys.length) {
2819
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2820
+ if (aggregated.length) result.issues.push({
2821
+ ...unrecIssue,
2822
+ keys: aggregated
2823
+ });
2824
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2825
+ }
2399
2826
  const merged = mergeValues(left.value, right.value);
2400
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2827
+ if (!merged.valid) {
2828
+ if (aborted(result)) return result;
2829
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2830
+ }
2401
2831
  result.value = merged.data;
2402
2832
  return result;
2403
2833
  }
2404
2834
  const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
2405
2835
  $ZodType.init(inst, def);
2406
2836
  const items = def.items;
2837
+ const memo = globalConfig.memoizer;
2838
+ memo?.attach(inst);
2407
2839
  inst._zod.parse = (payload, ctx) => {
2408
2840
  const input = payload.value;
2409
2841
  if (!Array.isArray(input)) {
@@ -2415,7 +2847,7 @@ const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
2415
2847
  });
2416
2848
  return payload;
2417
2849
  }
2418
- payload.value = [];
2850
+ payload.value = memo ? memo.alloc(inst, payload, [], ctx) : [];
2419
2851
  const proms = [];
2420
2852
  const optinStart = getTupleOptStart(items, "optin");
2421
2853
  const optoutStart = getTupleOptStart(items, "optout");
@@ -2469,7 +2901,7 @@ const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (inst, def) => {
2469
2901
  };
2470
2902
  });
2471
2903
  function getTupleOptStart(items, key) {
2472
- for (let i = items.length - 1; i >= 0; i--) if (items[i]._zod[key] !== "optional") return i + 1;
2904
+ for (let i = items.length - 1; i >= 0; i--) if (!(key === "optin" ? items[i]._zod.optin !== void 0 : items[i]._zod.optout === "optional")) return i + 1;
2473
2905
  return 0;
2474
2906
  }
2475
2907
  function handleTupleResult(result, final, index) {
@@ -2480,6 +2912,10 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
2480
2912
  for (let i = 0; i < items.length; i++) {
2481
2913
  const r = itemResults[i];
2482
2914
  const isPresent = i < input.length;
2915
+ if (!isPresent && i >= optoutStart && items[i]._zod.optin === "optional") {
2916
+ final.value.length = i;
2917
+ break;
2918
+ }
2483
2919
  if (r.issues.length) {
2484
2920
  if (!isPresent && i >= optoutStart) {
2485
2921
  final.value.length = i;
@@ -2495,6 +2931,8 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
2495
2931
  }
2496
2932
  const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2497
2933
  $ZodType.init(inst, def);
2934
+ const memo = globalConfig.memoizer;
2935
+ memo?.attach(inst);
2498
2936
  inst._zod.parse = (payload, ctx) => {
2499
2937
  const input = payload.value;
2500
2938
  if (!isPlainObject$1(input)) {
@@ -2508,11 +2946,12 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2508
2946
  }
2509
2947
  const proms = [];
2510
2948
  const values = def.keyType._zod.values;
2511
- if (values) {
2512
- payload.value = {};
2949
+ if (values && !def.partial) {
2950
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
2513
2951
  const recordKeys = /* @__PURE__ */ new Set();
2514
2952
  for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2515
2953
  recordKeys.add(typeof key === "number" ? key.toString() : key);
2954
+ if (key === "__proto__") continue;
2516
2955
  const keyResult = def.keyType._zod.run({
2517
2956
  value: key,
2518
2957
  issues: []
@@ -2530,6 +2969,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2530
2969
  continue;
2531
2970
  }
2532
2971
  const outKey = keyResult.value;
2972
+ if (outKey === "__proto__") continue;
2533
2973
  const result = def.valueType._zod.run({
2534
2974
  value: input[key],
2535
2975
  issues: []
@@ -2545,17 +2985,24 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2545
2985
  }
2546
2986
  let unrecognized;
2547
2987
  for (const key in input) if (!recordKeys.has(key)) {
2548
- unrecognized = unrecognized ?? [];
2549
- unrecognized.push(key);
2988
+ if (def.mode === "loose") {
2989
+ if (key === "__proto__") continue;
2990
+ payload.value[key] = input[key];
2991
+ } else {
2992
+ unrecognized = unrecognized ?? [];
2993
+ unrecognized.push(key);
2994
+ }
2550
2995
  }
2551
2996
  if (unrecognized && unrecognized.length > 0) payload.issues.push({
2552
2997
  code: "unrecognized_keys",
2553
2998
  input,
2554
2999
  inst,
2555
- keys: unrecognized
3000
+ keys: unrecognized,
3001
+ continue: true
2556
3002
  });
2557
3003
  } else {
2558
- payload.value = {};
3004
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
3005
+ let unrecognized;
2559
3006
  for (const key of Reflect.ownKeys(input)) {
2560
3007
  if (key === "__proto__") continue;
2561
3008
  if (!Object.prototype.propertyIsEnumerable.call(input, key)) continue;
@@ -2574,7 +3021,10 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2574
3021
  }
2575
3022
  if (keyResult.issues.length) {
2576
3023
  if (def.mode === "loose") payload.value[key] = input[key];
2577
- else payload.issues.push({
3024
+ else if (values) {
3025
+ unrecognized = unrecognized ?? [];
3026
+ unrecognized.push(key);
3027
+ } else payload.issues.push({
2578
3028
  code: "invalid_key",
2579
3029
  origin: "record",
2580
3030
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
@@ -2584,19 +3034,28 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2584
3034
  });
2585
3035
  continue;
2586
3036
  }
3037
+ const outKey = keyResult.value;
3038
+ if (outKey === "__proto__") continue;
2587
3039
  const result = def.valueType._zod.run({
2588
3040
  value: input[key],
2589
3041
  issues: []
2590
3042
  }, ctx);
2591
3043
  if (result instanceof Promise) proms.push(result.then((result) => {
2592
3044
  if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2593
- payload.value[keyResult.value] = result.value;
3045
+ payload.value[outKey] = result.value;
2594
3046
  }));
2595
3047
  else {
2596
3048
  if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
2597
- payload.value[keyResult.value] = result.value;
3049
+ payload.value[outKey] = result.value;
2598
3050
  }
2599
3051
  }
3052
+ if (unrecognized && unrecognized.length > 0) payload.issues.push({
3053
+ code: "unrecognized_keys",
3054
+ input,
3055
+ inst,
3056
+ keys: unrecognized,
3057
+ continue: true
3058
+ });
2600
3059
  }
2601
3060
  if (proms.length) return Promise.all(proms).then(() => payload);
2602
3061
  return payload;
@@ -2604,6 +3063,8 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
2604
3063
  });
2605
3064
  const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (inst, def) => {
2606
3065
  $ZodType.init(inst, def);
3066
+ const memo = globalConfig.memoizer;
3067
+ memo?.attach(inst);
2607
3068
  inst._zod.parse = (payload, ctx) => {
2608
3069
  const input = payload.value;
2609
3070
  if (!(input instanceof Map)) {
@@ -2616,7 +3077,7 @@ const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (inst, def) => {
2616
3077
  return payload;
2617
3078
  }
2618
3079
  const proms = [];
2619
- payload.value = /* @__PURE__ */ new Map();
3080
+ payload.value = memo ? memo.alloc(inst, payload, /* @__PURE__ */ new Map(), ctx) : /* @__PURE__ */ new Map();
2620
3081
  for (const [key, value] of input) {
2621
3082
  const keyResult = def.keyType._zod.run({
2622
3083
  value: key,
@@ -2661,6 +3122,8 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
2661
3122
  }
2662
3123
  const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (inst, def) => {
2663
3124
  $ZodType.init(inst, def);
3125
+ const memo = globalConfig.memoizer;
3126
+ memo?.attach(inst);
2664
3127
  inst._zod.parse = (payload, ctx) => {
2665
3128
  const input = payload.value;
2666
3129
  if (!(input instanceof Set)) {
@@ -2673,7 +3136,7 @@ const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (inst, def) => {
2673
3136
  return payload;
2674
3137
  }
2675
3138
  const proms = [];
2676
- payload.value = /* @__PURE__ */ new Set();
3139
+ payload.value = memo ? memo.alloc(inst, payload, /* @__PURE__ */ new Set(), ctx) : /* @__PURE__ */ new Set();
2677
3140
  for (const item of input) {
2678
3141
  const result = def.valueType._zod.run({
2679
3142
  value: item,
@@ -2695,7 +3158,8 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2695
3158
  const values = getEnumValues(def.entries);
2696
3159
  const valuesSet = new Set(values);
2697
3160
  inst._zod.values = valuesSet;
2698
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
3161
+ const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
3162
+ inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2699
3163
  inst._zod.parse = (payload, _ctx) => {
2700
3164
  const input = payload.value;
2701
3165
  if (valuesSet.has(input)) return payload;
@@ -2710,10 +3174,9 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2710
3174
  });
2711
3175
  const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
2712
3176
  $ZodType.init(inst, def);
2713
- if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
2714
3177
  const values = new Set(def.values);
2715
3178
  inst._zod.values = values;
2716
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
3179
+ inst._zod.pattern = new RegExp(def.values.length ? `^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
2717
3180
  inst._zod.parse = (payload, _ctx) => {
2718
3181
  const input = payload.value;
2719
3182
  if (values.has(input)) return payload;
@@ -2743,67 +3206,66 @@ const $ZodFile = /*@__PURE__*/ $constructor("$ZodFile", (inst, def) => {
2743
3206
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2744
3207
  $ZodType.init(inst, def);
2745
3208
  inst._zod.optin = "optional";
3209
+ globalConfig.memoizer?.guard(inst);
2746
3210
  inst._zod.parse = (payload, ctx) => {
2747
3211
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2748
3212
  const _out = def.transform(payload.value, payload);
2749
3213
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2750
3214
  payload.value = output;
2751
- payload.fallback = true;
2752
3215
  return payload;
2753
3216
  });
2754
3217
  if (_out instanceof Promise) throw new $ZodAsyncError();
2755
3218
  payload.value = _out;
2756
- payload.fallback = true;
2757
3219
  return payload;
2758
3220
  };
2759
3221
  });
2760
- function handleOptionalResult(result, input) {
2761
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2762
- issues: [],
2763
- value: void 0
2764
- };
2765
- return result;
3222
+ function handleOptionalResult(payload, result) {
3223
+ payload.value = result.issues.length ? void 0 : result.value;
3224
+ return payload;
2766
3225
  }
2767
3226
  const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2768
3227
  $ZodType.init(inst, def);
2769
- inst._zod.optin = "optional";
3228
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2770
3229
  inst._zod.optout = "optional";
2771
- defineLazy(inst._zod, "values", () => {
2772
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
3230
+ defineLazyInternal(inst, "values", (zod) => {
3231
+ const values = zod.def.innerType._zod.values;
3232
+ return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
2773
3233
  });
2774
- defineLazy(inst._zod, "pattern", () => {
2775
- const pattern = def.innerType._zod.pattern;
3234
+ defineLazyInternal(inst, "pattern", (zod) => {
3235
+ const pattern = zod.def.innerType._zod.pattern;
2776
3236
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2777
3237
  });
2778
3238
  inst._zod.parse = (payload, ctx) => {
2779
- if (def.innerType._zod.optin === "optional") {
2780
- const input = payload.value;
2781
- const result = def.innerType._zod.run(payload, ctx);
2782
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2783
- return handleOptionalResult(result, input);
3239
+ if (payload.value === void 0) {
3240
+ if (def.innerType._zod.optin !== "defaulted") return payload;
3241
+ const result = def.innerType._zod.run({
3242
+ value: payload.value,
3243
+ issues: []
3244
+ }, ctx);
3245
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
3246
+ return handleOptionalResult(payload, result);
2784
3247
  }
2785
- if (payload.value === void 0) return payload;
2786
3248
  return def.innerType._zod.run(payload, ctx);
2787
3249
  };
2788
3250
  });
2789
3251
  const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2790
3252
  $ZodOptional.init(inst, def);
2791
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2792
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
3253
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3254
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2793
3255
  inst._zod.parse = (payload, ctx) => {
2794
3256
  return def.innerType._zod.run(payload, ctx);
2795
3257
  };
2796
3258
  });
2797
3259
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2798
3260
  $ZodType.init(inst, def);
2799
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2800
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2801
- defineLazy(inst._zod, "pattern", () => {
2802
- const pattern = def.innerType._zod.pattern;
3261
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
3262
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
3263
+ defineLazyInternal(inst, "pattern", (zod) => {
3264
+ const pattern = zod.def.innerType._zod.pattern;
2803
3265
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2804
3266
  });
2805
- defineLazy(inst._zod, "values", () => {
2806
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
3267
+ defineLazyInternal(inst, "values", (zod) => {
3268
+ return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
2807
3269
  });
2808
3270
  inst._zod.parse = (payload, ctx) => {
2809
3271
  if (payload.value === null) return payload;
@@ -2812,8 +3274,8 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2812
3274
  });
2813
3275
  const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2814
3276
  $ZodType.init(inst, def);
2815
- inst._zod.optin = "optional";
2816
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3277
+ inst._zod.optin = "defaulted";
3278
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2817
3279
  inst._zod.parse = (payload, ctx) => {
2818
3280
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2819
3281
  if (payload.value === void 0) {
@@ -2834,8 +3296,8 @@ function handleDefaultResult(payload, def) {
2834
3296
  }
2835
3297
  const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2836
3298
  $ZodType.init(inst, def);
2837
- inst._zod.optin = "optional";
2838
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3299
+ inst._zod.optin = "defaulted";
3300
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2839
3301
  inst._zod.parse = (payload, ctx) => {
2840
3302
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2841
3303
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -2844,8 +3306,8 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2844
3306
  });
2845
3307
  const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2846
3308
  $ZodType.init(inst, def);
2847
- defineLazy(inst._zod, "values", () => {
2848
- const v = def.innerType._zod.values;
3309
+ defineLazyInternal(inst, "values", (zod) => {
3310
+ const v = zod.def.innerType._zod.values;
2849
3311
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2850
3312
  });
2851
3313
  inst._zod.parse = (payload, ctx) => {
@@ -2876,38 +3338,33 @@ const $ZodSuccess = /*@__PURE__*/ $constructor("$ZodSuccess", (inst, def) => {
2876
3338
  return payload;
2877
3339
  };
2878
3340
  });
3341
+ function handleCatchResult(payload, result, def, ctx) {
3342
+ if (!result.issues.length) {
3343
+ payload.value = result.value;
3344
+ if (result.memo) payload.memo = true;
3345
+ return payload;
3346
+ }
3347
+ payload.value = def.catchValue({
3348
+ ...result,
3349
+ value: payload.value,
3350
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
3351
+ input: payload.value
3352
+ });
3353
+ return payload;
3354
+ }
2879
3355
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2880
3356
  $ZodType.init(inst, def);
2881
- inst._zod.optin = "optional";
2882
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2883
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3357
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
3358
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
3359
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2884
3360
  inst._zod.parse = (payload, ctx) => {
2885
3361
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2886
- const result = def.innerType._zod.run(payload, ctx);
2887
- if (result instanceof Promise) return result.then((result) => {
2888
- payload.value = result.value;
2889
- if (result.issues.length) {
2890
- payload.value = def.catchValue({
2891
- ...payload,
2892
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2893
- input: payload.value
2894
- });
2895
- payload.issues = [];
2896
- payload.fallback = true;
2897
- }
2898
- return payload;
2899
- });
2900
- payload.value = result.value;
2901
- if (result.issues.length) {
2902
- payload.value = def.catchValue({
2903
- ...payload,
2904
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2905
- input: payload.value
2906
- });
2907
- payload.issues = [];
2908
- payload.fallback = true;
2909
- }
2910
- return payload;
3362
+ const result = def.innerType._zod.run({
3363
+ value: payload.value,
3364
+ issues: []
3365
+ }, ctx);
3366
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
3367
+ return handleCatchResult(payload, result, def, ctx);
2911
3368
  };
2912
3369
  });
2913
3370
  const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (inst, def) => {
@@ -2927,10 +3384,10 @@ const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (inst, def) => {
2927
3384
  });
2928
3385
  const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2929
3386
  $ZodType.init(inst, def);
2930
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2931
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2932
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2933
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3387
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
3388
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
3389
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
3390
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2934
3391
  inst._zod.parse = (payload, ctx) => {
2935
3392
  if (ctx.direction === "backward") {
2936
3393
  const right = def.out._zod.run(payload, ctx);
@@ -2943,22 +3400,21 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2943
3400
  };
2944
3401
  });
2945
3402
  function handlePipeResult(left, next, ctx) {
2946
- if (left.issues.length) {
3403
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2947
3404
  left.aborted = true;
2948
3405
  return left;
2949
3406
  }
2950
3407
  return next._zod.run({
2951
3408
  value: left.value,
2952
- issues: left.issues,
2953
- fallback: left.fallback
3409
+ issues: left.issues
2954
3410
  }, ctx);
2955
3411
  }
2956
3412
  const $ZodCodec = /*@__PURE__*/ $constructor("$ZodCodec", (inst, def) => {
2957
3413
  $ZodType.init(inst, def);
2958
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2959
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2960
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2961
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
3414
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
3415
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
3416
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
3417
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2962
3418
  inst._zod.parse = (payload, ctx) => {
2963
3419
  if ((ctx.direction || "forward") === "forward") {
2964
3420
  const left = def.in._zod.run(payload, ctx);
@@ -3001,10 +3457,10 @@ const $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def)
3001
3457
  });
3002
3458
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
3003
3459
  $ZodType.init(inst, def);
3004
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
3005
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
3006
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
3007
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
3460
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
3461
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
3462
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
3463
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
3008
3464
  inst._zod.parse = (payload, ctx) => {
3009
3465
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
3010
3466
  const result = def.innerType._zod.run(payload, ctx);
@@ -3013,7 +3469,7 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
3013
3469
  };
3014
3470
  });
3015
3471
  function handleReadonlyResult(payload) {
3016
- payload.value = Object.freeze(payload.value);
3472
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
3017
3473
  return payload;
3018
3474
  }
3019
3475
  const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (inst, def) => {
@@ -3055,25 +3511,31 @@ const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (i
3055
3511
  });
3056
3512
  const $ZodFunction = /*@__PURE__*/ $constructor("$ZodFunction", (inst, def) => {
3057
3513
  $ZodType.init(inst, def);
3058
- inst._def = def;
3514
+ Object.defineProperty(inst, "_def", { value: def });
3059
3515
  inst._zod.def = def;
3060
3516
  inst.implement = (func) => {
3061
3517
  if (typeof func !== "function") throw new Error("implement() must be called with a function");
3062
- return function(...args) {
3518
+ return Object.defineProperty(function(...args) {
3063
3519
  const parsedArgs = inst._def.input ? parse$1(inst._def.input, args) : args;
3064
3520
  const result = Reflect.apply(func, this, parsedArgs);
3065
3521
  if (inst._def.output) return parse$1(inst._def.output, result);
3066
3522
  return result;
3067
- };
3523
+ }, "_zod", {
3524
+ value: inst._zod,
3525
+ enumerable: false
3526
+ });
3068
3527
  };
3069
3528
  inst.implementAsync = (func) => {
3070
3529
  if (typeof func !== "function") throw new Error("implementAsync() must be called with a function");
3071
- return async function(...args) {
3530
+ return Object.defineProperty(async function(...args) {
3072
3531
  const parsedArgs = inst._def.input ? await parseAsync$1(inst._def.input, args) : args;
3073
3532
  const result = await Reflect.apply(func, this, parsedArgs);
3074
3533
  if (inst._def.output) return await parseAsync$1(inst._def.output, result);
3075
3534
  return result;
3076
- };
3535
+ }, "_zod", {
3536
+ value: inst._zod,
3537
+ enumerable: false
3538
+ });
3077
3539
  };
3078
3540
  inst._zod.parse = (payload, _ctx) => {
3079
3541
  if (typeof payload.value !== "function") {
@@ -3132,10 +3594,10 @@ const $ZodLazy = /*@__PURE__*/ $constructor("$ZodLazy", (inst, def) => {
3132
3594
  if (!d._cachedInner) d._cachedInner = def.getter();
3133
3595
  return d._cachedInner;
3134
3596
  });
3135
- defineLazy(inst._zod, "pattern", () => inst._zod.innerType?._zod?.pattern);
3136
- defineLazy(inst._zod, "propValues", () => inst._zod.innerType?._zod?.propValues);
3137
- defineLazy(inst._zod, "optin", () => inst._zod.innerType?._zod?.optin ?? void 0);
3138
- defineLazy(inst._zod, "optout", () => inst._zod.innerType?._zod?.optout ?? void 0);
3597
+ defineLazyInternal(inst, "pattern", (zod) => zod.innerType?._zod?.pattern);
3598
+ defineLazyInternal(inst, "propValues", (zod) => zod.innerType?._zod?.propValues);
3599
+ defineLazyInternal(inst, "optin", (zod) => zod.innerType?._zod?.optin ?? void 0);
3600
+ defineLazyInternal(inst, "optout", (zod) => zod.innerType?._zod?.optout ?? void 0);
3139
3601
  inst._zod.parse = (payload, ctx) => {
3140
3602
  return inst._zod.innerType._zod.run(payload, ctx);
3141
3603
  };
@@ -3167,7 +3629,159 @@ function handleRefineResult(result, payload, input, inst) {
3167
3629
  }
3168
3630
  }
3169
3631
  //#endregion
3170
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/en.js
3632
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/memoizer.js
3633
+ var $ZodCyclicError = class extends Error {
3634
+ constructor() {
3635
+ super(`Cannot parse a reference cycle that closes through a transform`);
3636
+ this.name = "ZodCyclicError";
3637
+ }
3638
+ };
3639
+ /** Keyed off the context object every schema in one parse call already shares. */
3640
+ const STATE = "~memo";
3641
+ const NO_ISSUES = [];
3642
+ function cloneIssues(issues) {
3643
+ return issues.map((iss) => iss.path ? {
3644
+ ...iss,
3645
+ path: iss.path.slice()
3646
+ } : { ...iss });
3647
+ }
3648
+ const recursive = /*@__PURE__*/ new WeakMap();
3649
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
3650
+ function isRecursive(inst, stack) {
3651
+ const cached = recursive.get(inst);
3652
+ if (cached !== void 0) return cached;
3653
+ if (stack.has(inst)) return true;
3654
+ stack.add(inst);
3655
+ let result = false;
3656
+ const check = (child) => {
3657
+ if (!result && child?._zod && isRecursive(child, stack)) result = true;
3658
+ };
3659
+ const def = inst._zod.def;
3660
+ if (def.type === "lazy") check(inst._zod.innerType);
3661
+ else {
3662
+ const shape = def.shape;
3663
+ if (shape) for (const key of Reflect.ownKeys(shape)) check(shape[key]);
3664
+ for (const key in def) {
3665
+ const value = def[key];
3666
+ if (!value || typeof value !== "object") continue;
3667
+ if (value._zod) check(value);
3668
+ else if (Array.isArray(value)) for (const el of value) check(el);
3669
+ }
3670
+ }
3671
+ stack.delete(inst);
3672
+ recursive.set(inst, result);
3673
+ return result;
3674
+ }
3675
+ function bucketFor(state, inst) {
3676
+ let bucket = state.buckets.get(inst);
3677
+ if (!bucket) {
3678
+ bucket = /* @__PURE__ */ new Map();
3679
+ state.buckets.set(inst, bucket);
3680
+ }
3681
+ return bucket;
3682
+ }
3683
+ let handoff;
3684
+ const open = [];
3685
+ const memo = {
3686
+ alloc(_inst, payload, empty) {
3687
+ const bucket = handoff;
3688
+ if (!bucket) return empty;
3689
+ handoff = void 0;
3690
+ const entry = {
3691
+ value: empty,
3692
+ issues: null
3693
+ };
3694
+ bucket.set(payload.value, entry);
3695
+ open.push(entry);
3696
+ return empty;
3697
+ },
3698
+ guard(inst) {
3699
+ var _a;
3700
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
3701
+ inst._zod.deferred.push(() => {
3702
+ const base = inst._zod.parse;
3703
+ const wrapped = (payload, ctx) => {
3704
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
3705
+ return base(payload, ctx);
3706
+ };
3707
+ inst._zod.parse = wrapped;
3708
+ if (inst._zod.run === base) inst._zod.run = wrapped;
3709
+ });
3710
+ },
3711
+ attach(inst) {
3712
+ var _a;
3713
+ let isRecursiveInst;
3714
+ let lastCtx;
3715
+ let lastBucket;
3716
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
3717
+ inst._zod.deferred.push(() => {
3718
+ const base = inst._zod.parse;
3719
+ const wrapped = (payload, ctx) => {
3720
+ if (isRecursiveInst === void 0) {
3721
+ isRecursiveInst = isRecursive(inst, /* @__PURE__ */ new Set());
3722
+ if (!isRecursiveInst) {
3723
+ inst._zod.parse = base;
3724
+ if (inst._zod.run === wrapped) inst._zod.run = base;
3725
+ return base(payload, ctx);
3726
+ }
3727
+ }
3728
+ const input = payload.value;
3729
+ if (input === null || typeof input !== "object") return base(payload, ctx);
3730
+ let state = ctx[STATE];
3731
+ if (!state) {
3732
+ state = {
3733
+ buckets: /* @__PURE__ */ new Map(),
3734
+ backEdges: void 0
3735
+ };
3736
+ ctx[STATE] = state;
3737
+ }
3738
+ let bucket;
3739
+ if (lastCtx === ctx) bucket = lastBucket;
3740
+ else {
3741
+ bucket = bucketFor(state, inst);
3742
+ lastCtx = ctx;
3743
+ lastBucket = bucket;
3744
+ }
3745
+ const hit = bucket.get(input);
3746
+ if (hit) {
3747
+ payload.value = hit.value;
3748
+ if (hit.issues) {
3749
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
3750
+ } else {
3751
+ payload.memo = true;
3752
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new Set());
3753
+ state.backEdges.add(hit.value);
3754
+ }
3755
+ return payload;
3756
+ }
3757
+ handoff = bucket;
3758
+ const depth = open.length;
3759
+ const result = base(payload, ctx);
3760
+ handoff = void 0;
3761
+ const entry = open.length > depth ? open.pop() : void 0;
3762
+ if (result instanceof Promise) return result.then((r) => {
3763
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
3764
+ return r;
3765
+ });
3766
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
3767
+ return result;
3768
+ };
3769
+ inst._zod.parse = wrapped;
3770
+ if (inst._zod.run === base) inst._zod.run = wrapped;
3771
+ });
3772
+ }
3773
+ };
3774
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
3775
+ function memoizer() {
3776
+ return memo;
3777
+ }
3778
+ /** Whether this value is a node a back-edge resolved to before it finished. */
3779
+ function isBackEdge(ctx, value) {
3780
+ const backEdges = ctx[STATE]?.backEdges;
3781
+ return backEdges !== void 0 && value !== null && typeof value === "object" && backEdges.has(value);
3782
+ }
3783
+ //#endregion
3784
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/locales/en.js
3171
3785
  const error = () => {
3172
3786
  const Sizable = {
3173
3787
  string: {
@@ -3222,28 +3836,29 @@ const error = () => {
3222
3836
  base64url: "base64url-encoded string",
3223
3837
  json_string: "JSON string",
3224
3838
  e164: "E.164 number",
3839
+ credit_card: "credit card number",
3225
3840
  jwt: "JWT",
3226
3841
  template_literal: "input"
3227
3842
  };
3228
3843
  const TypeDictionary = { nan: "NaN" };
3844
+ function getTypeName(type, input) {
3845
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
3846
+ return TypeDictionary[type] ?? type;
3847
+ }
3229
3848
  return (issue) => {
3230
3849
  switch (issue.code) {
3231
- case "invalid_type": {
3232
- const expected = TypeDictionary[issue.expected] ?? issue.expected;
3233
- const receivedType = parsedType(issue.input);
3234
- return `Invalid input: expected ${expected}, received ${TypeDictionary[receivedType] ?? receivedType}`;
3235
- }
3850
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
3236
3851
  case "invalid_value":
3237
3852
  if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
3238
3853
  return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
3239
3854
  case "too_big": {
3240
- const adj = issue.inclusive ? "<=" : "<";
3855
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
3241
3856
  const sizing = getSizing(issue.origin);
3242
3857
  if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
3243
3858
  return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
3244
3859
  }
3245
3860
  case "too_small": {
3246
- const adj = issue.inclusive ? ">=" : ">";
3861
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
3247
3862
  const sizing = getSizing(issue.origin);
3248
3863
  if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
3249
3864
  return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
@@ -3261,6 +3876,7 @@ const error = () => {
3261
3876
  case "invalid_key": return `Invalid key in ${issue.origin}`;
3262
3877
  case "invalid_union":
3263
3878
  if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
3879
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
3264
3880
  return "Invalid input";
3265
3881
  case "invalid_element": return `Invalid value in ${issue.origin}`;
3266
3882
  default: return `Invalid input`;
@@ -3271,7 +3887,7 @@ function en_default() {
3271
3887
  return { localeError: error() };
3272
3888
  }
3273
3889
  //#endregion
3274
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
3890
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/registries.js
3275
3891
  var _a;
3276
3892
  var $ZodRegistry = class {
3277
3893
  constructor() {
@@ -3318,7 +3934,7 @@ function registry() {
3318
3934
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
3319
3935
  const globalRegistry = globalThis.__zod_globalRegistry;
3320
3936
  //#endregion
3321
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
3937
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/api.js
3322
3938
  // @__NO_SIDE_EFFECTS__
3323
3939
  function _string(Class, params) {
3324
3940
  return new Class({
@@ -3555,6 +4171,16 @@ function _e164(Class, params) {
3555
4171
  });
3556
4172
  }
3557
4173
  // @__NO_SIDE_EFFECTS__
4174
+ function _creditCard(Class, params) {
4175
+ return new Class({
4176
+ type: "string",
4177
+ format: "credit_card",
4178
+ check: "string_format",
4179
+ abort: false,
4180
+ ...normalizeParams(params)
4181
+ });
4182
+ }
4183
+ // @__NO_SIDE_EFFECTS__
3558
4184
  function _jwt(Class, params) {
3559
4185
  return new Class({
3560
4186
  type: "string",
@@ -3923,6 +4549,14 @@ function _property(property, schema, params) {
3923
4549
  });
3924
4550
  }
3925
4551
  // @__NO_SIDE_EFFECTS__
4552
+ function _properties(shape) {
4553
+ return Object.entries(shape).map(([property, schema]) => new $ZodCheckProperty({
4554
+ check: "property",
4555
+ property,
4556
+ schema
4557
+ }));
4558
+ }
4559
+ // @__NO_SIDE_EFFECTS__
3926
4560
  function _mime(types, params) {
3927
4561
  return new $ZodCheckMimeType({
3928
4562
  check: "mime_type",
@@ -4001,7 +4635,7 @@ function _superRefine(fn, params) {
4001
4635
  const _issue = issue$2;
4002
4636
  if (_issue.fatal) _issue.continue = false;
4003
4637
  _issue.code ?? (_issue.code = "custom");
4004
- _issue.input ?? (_issue.input = payload.value);
4638
+ if (!("input" in _issue)) _issue.input = payload.value;
4005
4639
  _issue.inst ?? (_issue.inst = ch);
4006
4640
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
4007
4641
  payload.issues.push(issue(_issue));
@@ -4106,13 +4740,15 @@ function _stringbool(Classes, _params) {
4106
4740
  }),
4107
4741
  error: params.error
4108
4742
  });
4743
+ codec._zod.bag.truthy = truthyArray;
4744
+ codec._zod.bag.falsy = falsyArray;
4745
+ codec._zod.bag.case = params.case ?? "insensitive";
4109
4746
  return codec;
4110
4747
  }
4111
4748
  // @__NO_SIDE_EFFECTS__
4112
4749
  function _stringFormat(Class, format, fnOrRegex, _params = {}) {
4113
4750
  const params = normalizeParams(_params);
4114
4751
  const def = {
4115
- ...normalizeParams(_params),
4116
4752
  check: "string_format",
4117
4753
  type: "string",
4118
4754
  format,
@@ -4123,7 +4759,11 @@ function _stringFormat(Class, format, fnOrRegex, _params = {}) {
4123
4759
  return new Class(def);
4124
4760
  }
4125
4761
  //#endregion
4126
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
4762
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/to-json-schema.js
4763
+ function assignProps(target, ...sources) {
4764
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
4765
+ return target;
4766
+ }
4127
4767
  function initializeContext(params) {
4128
4768
  let target = params?.target ?? "draft-2020-12";
4129
4769
  if (target === "draft-4") target = "draft-04";
@@ -4137,11 +4777,30 @@ function initializeContext(params) {
4137
4777
  io: params?.io ?? "output",
4138
4778
  counter: 0,
4139
4779
  seen: /* @__PURE__ */ new Map(),
4780
+ sharedDefsExtractedFor: void 0,
4781
+ sharedEmitDoneFor: void 0,
4140
4782
  cycles: params?.cycles ?? "ref",
4141
4783
  reused: params?.reused ?? "inline",
4784
+ intersections: [],
4142
4785
  external: params?.external ?? void 0
4143
4786
  };
4144
4787
  }
4788
+ /**
4789
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
4790
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
4791
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
4792
+ */
4793
+ function handleUnrepresentable(schema, ctx, json, params, message) {
4794
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
4795
+ zodSchema: schema,
4796
+ path: params.path,
4797
+ message
4798
+ }) : ctx.unrepresentable;
4799
+ if (result === "any") return false;
4800
+ if (result === void 0 || result === "throw") throw new Error(message);
4801
+ Object.assign(json, result);
4802
+ return true;
4803
+ }
4145
4804
  function process$1(schema, ctx, _params = {
4146
4805
  path: [],
4147
4806
  schemaPath: []
@@ -4161,6 +4820,8 @@ function process$1(schema, ctx, _params = {
4161
4820
  path: _params.path
4162
4821
  };
4163
4822
  ctx.seen.set(schema, result);
4823
+ ctx.sharedDefsExtractedFor = void 0;
4824
+ ctx.sharedEmitDoneFor = void 0;
4164
4825
  const overrideSchema = schema._zod.toJSONSchema?.();
4165
4826
  if (overrideSchema) result.schema = overrideSchema;
4166
4827
  else {
@@ -4184,7 +4845,7 @@ function process$1(schema, ctx, _params = {
4184
4845
  }
4185
4846
  }
4186
4847
  const meta = ctx.metadataRegistry.get(schema);
4187
- if (meta) Object.assign(result.schema, meta);
4848
+ if (meta) assignProps(result.schema, meta);
4188
4849
  if (ctx.io === "input" && isTransforming(schema)) {
4189
4850
  delete result.schema.examples;
4190
4851
  delete result.schema.default;
@@ -4193,9 +4854,13 @@ function process$1(schema, ctx, _params = {
4193
4854
  delete result.schema._prefault;
4194
4855
  return ctx.seen.get(schema).schema;
4195
4856
  }
4857
+ function encodeJSONPointerSegment(segment) {
4858
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
4859
+ }
4196
4860
  function extractDefs(ctx, schema) {
4197
4861
  const root = ctx.seen.get(schema);
4198
4862
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
4863
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
4199
4864
  const idToSchema = /* @__PURE__ */ new Map();
4200
4865
  for (const entry of ctx.seen.entries()) {
4201
4866
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -4215,15 +4880,16 @@ function extractDefs(ctx, schema) {
4215
4880
  entry[1].defId = id;
4216
4881
  return {
4217
4882
  defId: id,
4218
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
4883
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
4219
4884
  };
4220
4885
  }
4221
- if (entry[1] === root) return { ref: "#" };
4222
- const defUriPrefix = `#/${defsSegment}/`;
4886
+ const uriPrefix = `#`;
4887
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
4888
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
4223
4889
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
4224
4890
  return {
4225
4891
  defId,
4226
- ref: defUriPrefix + defId
4892
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
4227
4893
  };
4228
4894
  };
4229
4895
  const extractToDef = (entry) => {
@@ -4270,6 +4936,111 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4270
4936
  }
4271
4937
  }
4272
4938
  }
4939
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
4940
+ }
4941
+ /** 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. */
4942
+ function compactTypeUnion(schema) {
4943
+ const options = schema.anyOf;
4944
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
4945
+ const types = [];
4946
+ for (const option of options) {
4947
+ if (!option || typeof option !== "object") return;
4948
+ compactTypeUnion(option);
4949
+ const keys = Object.keys(option);
4950
+ if (keys.length !== 1 || keys[0] !== "type") return;
4951
+ const type = option.type;
4952
+ for (const member of Array.isArray(type) ? type : [type]) {
4953
+ if (typeof member !== "string") return;
4954
+ if (!types.includes(member)) types.push(member);
4955
+ }
4956
+ }
4957
+ delete schema.anyOf;
4958
+ schema.type = types.length === 1 ? types[0] : types;
4959
+ }
4960
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
4961
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
4962
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
4963
+ const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
4964
+ "type",
4965
+ "properties",
4966
+ "required",
4967
+ "additionalProperties"
4968
+ ]);
4969
+ const UNION_KEYS = ["oneOf", "anyOf"];
4970
+ /** 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. */
4971
+ function undeclaredConstraint(member) {
4972
+ const extra = member.additionalProperties;
4973
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
4974
+ return Object.keys(extra).length ? extra : null;
4975
+ }
4976
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
4977
+ function foldObjects(members) {
4978
+ const objects = [];
4979
+ for (const member of members) {
4980
+ if (typeof member !== "object" || member.type !== "object") return null;
4981
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
4982
+ objects.push(member);
4983
+ }
4984
+ const properties = {};
4985
+ const required = /* @__PURE__ */ new Set();
4986
+ for (const object of objects) {
4987
+ for (const key in object.properties) {
4988
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
4989
+ const parts = [];
4990
+ for (const other of objects) {
4991
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
4992
+ if (part === null || part === void 0) continue;
4993
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
4994
+ }
4995
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
4996
+ }
4997
+ for (const key of object.required ?? []) required.add(key);
4998
+ }
4999
+ const folded = {
5000
+ type: "object",
5001
+ properties
5002
+ };
5003
+ if (required.size) folded.required = [...required];
5004
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
5005
+ else {
5006
+ const constraints = [];
5007
+ for (const object of objects) {
5008
+ const constraint = undeclaredConstraint(object);
5009
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
5010
+ }
5011
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
5012
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
5013
+ }
5014
+ return folded;
5015
+ }
5016
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
5017
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
5018
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
5019
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
5020
+ * into one object is the encoding that says so on every target.
5021
+ *
5022
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
5023
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
5024
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
5025
+ function foldIntersection(json) {
5026
+ const allOf = json.allOf;
5027
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
5028
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
5029
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
5030
+ let folded = null;
5031
+ if (!unions.length) folded = foldObjects(allOf);
5032
+ else {
5033
+ const union = unions[0];
5034
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
5035
+ if (Object.keys(union).length !== 1) return;
5036
+ const rest = allOf.filter((m) => m !== union);
5037
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
5038
+ if (branches.some((b) => !b)) return;
5039
+ folded = { [keyword]: branches };
5040
+ }
5041
+ if (!folded) return;
5042
+ delete json.allOf;
5043
+ assignProps(json, folded);
4273
5044
  }
4274
5045
  function finalize(ctx, schema) {
4275
5046
  const root = ctx.seen.get(schema);
@@ -4288,8 +5059,8 @@ function finalize(ctx, schema) {
4288
5059
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
4289
5060
  schema.allOf = schema.allOf ?? [];
4290
5061
  schema.allOf.push(refSchema);
4291
- } else Object.assign(schema, refSchema);
4292
- Object.assign(schema, _cached);
5062
+ } else assignProps(schema, refSchema);
5063
+ assignProps(schema, _cached);
4293
5064
  if (zodSchema._zod.parent === ref) for (const key in schema) {
4294
5065
  if (key === "$ref" || key === "allOf") continue;
4295
5066
  if (!(key in _cached)) delete schema[key];
@@ -4317,7 +5088,21 @@ function finalize(ctx, schema) {
4317
5088
  path: seen.path ?? []
4318
5089
  });
4319
5090
  };
4320
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
5091
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
5092
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
5093
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
5094
+ if (ctx.intersections.length) {
5095
+ const carriers = /* @__PURE__ */ new Map();
5096
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
5097
+ const allOf = json?.allOf;
5098
+ if (!Array.isArray(allOf)) continue;
5099
+ const existing = carriers.get(allOf);
5100
+ if (existing) existing.push(json);
5101
+ else carriers.set(allOf, [json]);
5102
+ }
5103
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
5104
+ }
5105
+ }
4321
5106
  const result = {};
4322
5107
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
4323
5108
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -4328,17 +5113,18 @@ function finalize(ctx, schema) {
4328
5113
  if (!id) throw new Error("Schema is missing an `id` property");
4329
5114
  result.$id = ctx.external.uri(id);
4330
5115
  }
4331
- Object.assign(result, root.def ?? root.schema);
5116
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
4332
5117
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
4333
5118
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
4334
5119
  const defs = ctx.external?.defs ?? {};
4335
- for (const entry of ctx.seen.entries()) {
5120
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
4336
5121
  const seen = entry[1];
4337
5122
  if (seen.def && seen.defId) {
4338
5123
  if (seen.def.id === seen.defId) delete seen.def.id;
4339
- defs[seen.defId] = seen.def;
5124
+ assignProp(defs, seen.defId, seen.def);
4340
5125
  }
4341
5126
  }
5127
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
4342
5128
  if (ctx.external) {} else if (Object.keys(defs).length > 0) {
4343
5129
  if (ctx.target === "draft-2020-12") result.$defs = defs;
4344
5130
  else result.definitions = defs;
@@ -4370,7 +5156,7 @@ function isTransforming(_schema, _ctx) {
4370
5156
  if (def.type === "array") return isTransforming(def.element, ctx);
4371
5157
  if (def.type === "set") return isTransforming(def.valueType, ctx);
4372
5158
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
4373
- 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);
5159
+ 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);
4374
5160
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
4375
5161
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
4376
5162
  if (def.type === "pipe") {
@@ -4418,7 +5204,7 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
4418
5204
  return finalize(ctx, schema);
4419
5205
  };
4420
5206
  //#endregion
4421
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
5207
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/core/json-schema-processors.js
4422
5208
  const formatMap = {
4423
5209
  guid: "uuid",
4424
5210
  url: "uri",
@@ -4429,13 +5215,13 @@ const formatMap = {
4429
5215
  const stringProcessor = (schema, ctx, _json, _params) => {
4430
5216
  const json = _json;
4431
5217
  json.type = "string";
4432
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
5218
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema._zod.bag;
4433
5219
  if (typeof minimum === "number") json.minLength = minimum;
4434
5220
  if (typeof maximum === "number") json.maxLength = maximum;
4435
5221
  if (format) {
4436
5222
  json.format = formatMap[format] ?? format;
4437
5223
  if (json.format === "") delete json.format;
4438
- if (format === "time") delete json.format;
5224
+ if (format === "time" || laxFormat) delete json.format;
4439
5225
  }
4440
5226
  if (contentEncoding) json.contentEncoding = contentEncoding;
4441
5227
  if (patterns && patterns.size > 0) {
@@ -4447,7 +5233,7 @@ const stringProcessor = (schema, ctx, _json, _params) => {
4447
5233
  }))];
4448
5234
  }
4449
5235
  };
4450
- const numberProcessor = (schema, ctx, _json, _params) => {
5236
+ const numberProcessor = (schema, ctx, _json, params) => {
4451
5237
  const json = _json;
4452
5238
  const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
4453
5239
  if (typeof format === "string" && format.includes("int")) json.type = "integer";
@@ -4467,16 +5253,19 @@ const numberProcessor = (schema, ctx, _json, _params) => {
4467
5253
  json.exclusiveMaximum = true;
4468
5254
  } else json.exclusiveMaximum = exclusiveMaximum;
4469
5255
  } else if (typeof maximum === "number") json.maximum = maximum;
4470
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
5256
+ if (typeof multipleOf === "number") {
5257
+ if (Number.isFinite(multipleOf) && multipleOf !== 0) json.multipleOf = Math.abs(multipleOf);
5258
+ else handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`);
5259
+ }
4471
5260
  };
4472
5261
  const booleanProcessor = (_schema, _ctx, json, _params) => {
4473
5262
  json.type = "boolean";
4474
5263
  };
4475
- const bigintProcessor = (_schema, ctx, _json, _params) => {
4476
- if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
5264
+ const bigintProcessor = (schema, ctx, json, params) => {
5265
+ handleUnrepresentable(schema, ctx, json, params, "BigInt cannot be represented in JSON Schema");
4477
5266
  };
4478
- const symbolProcessor = (_schema, ctx, _json, _params) => {
4479
- if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
5267
+ const symbolProcessor = (schema, ctx, json, params) => {
5268
+ handleUnrepresentable(schema, ctx, json, params, "Symbols cannot be represented in JSON Schema");
4480
5269
  };
4481
5270
  const nullProcessor = (_schema, ctx, json, _params) => {
4482
5271
  if (ctx.target === "openapi-3.0") {
@@ -4485,33 +5274,41 @@ const nullProcessor = (_schema, ctx, json, _params) => {
4485
5274
  json.enum = [null];
4486
5275
  } else json.type = "null";
4487
5276
  };
4488
- const undefinedProcessor = (_schema, ctx, _json, _params) => {
4489
- if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
5277
+ const undefinedProcessor = (schema, ctx, json, params) => {
5278
+ handleUnrepresentable(schema, ctx, json, params, "Undefined cannot be represented in JSON Schema");
4490
5279
  };
4491
- const voidProcessor = (_schema, ctx, _json, _params) => {
4492
- if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
5280
+ const voidProcessor = (schema, ctx, json, params) => {
5281
+ handleUnrepresentable(schema, ctx, json, params, "Void cannot be represented in JSON Schema");
4493
5282
  };
4494
5283
  const neverProcessor = (_schema, _ctx, json, _params) => {
4495
5284
  json.not = {};
4496
5285
  };
4497
- const dateProcessor = (_schema, ctx, _json, _params) => {
4498
- if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
5286
+ const dateProcessor = (schema, ctx, json, params) => {
5287
+ handleUnrepresentable(schema, ctx, json, params, "Date cannot be represented in JSON Schema");
4499
5288
  };
4500
5289
  const enumProcessor = (schema, _ctx, json, _params) => {
4501
5290
  const def = schema._zod.def;
4502
5291
  const values = getEnumValues(def.entries);
5292
+ if (values.length === 0) {
5293
+ json.not = {};
5294
+ return;
5295
+ }
4503
5296
  if (values.every((v) => typeof v === "number")) json.type = "number";
4504
5297
  if (values.every((v) => typeof v === "string")) json.type = "string";
4505
5298
  json.enum = values;
4506
5299
  };
4507
- const literalProcessor = (schema, ctx, json, _params) => {
5300
+ const literalProcessor = (schema, ctx, json, params) => {
4508
5301
  const def = schema._zod.def;
5302
+ if (def.values.length === 0) {
5303
+ json.not = {};
5304
+ return;
5305
+ }
4509
5306
  const vals = [];
4510
5307
  for (const val of def.values) if (val === void 0) {
4511
- if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
5308
+ if (handleUnrepresentable(schema, ctx, json, params, "Literal `undefined` cannot be represented in JSON Schema")) return;
4512
5309
  } else if (typeof val === "bigint") {
4513
- if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
4514
- else vals.push(Number(val));
5310
+ if (handleUnrepresentable(schema, ctx, json, params, "BigInt literals cannot be represented in JSON Schema")) return;
5311
+ vals.push(Number(val));
4515
5312
  } else vals.push(val);
4516
5313
  if (vals.length === 0) {} else if (vals.length === 1) {
4517
5314
  const val = vals[0];
@@ -4526,8 +5323,8 @@ const literalProcessor = (schema, ctx, json, _params) => {
4526
5323
  json.enum = vals;
4527
5324
  }
4528
5325
  };
4529
- const nanProcessor = (_schema, ctx, _json, _params) => {
4530
- if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
5326
+ const nanProcessor = (schema, ctx, json, params) => {
5327
+ handleUnrepresentable(schema, ctx, json, params, "NaN cannot be represented in JSON Schema");
4531
5328
  };
4532
5329
  const templateLiteralProcessor = (schema, _ctx, json, _params) => {
4533
5330
  const _json = json;
@@ -4559,20 +5356,20 @@ const fileProcessor = (schema, _ctx, json, _params) => {
4559
5356
  const successProcessor = (_schema, _ctx, json, _params) => {
4560
5357
  json.type = "boolean";
4561
5358
  };
4562
- const customProcessor = (_schema, ctx, _json, _params) => {
4563
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
5359
+ const customProcessor = (schema, ctx, json, params) => {
5360
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
4564
5361
  };
4565
- const functionProcessor = (_schema, ctx, _json, _params) => {
4566
- if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
5362
+ const functionProcessor = (schema, ctx, json, params) => {
5363
+ handleUnrepresentable(schema, ctx, json, params, "Function types cannot be represented in JSON Schema");
4567
5364
  };
4568
- const transformProcessor = (_schema, ctx, _json, _params) => {
4569
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
5365
+ const transformProcessor = (schema, ctx, json, params) => {
5366
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
4570
5367
  };
4571
- const mapProcessor = (_schema, ctx, _json, _params) => {
4572
- if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
5368
+ const mapProcessor = (schema, ctx, json, params) => {
5369
+ handleUnrepresentable(schema, ctx, json, params, "Map cannot be represented in JSON Schema");
4573
5370
  };
4574
- const setProcessor = (_schema, ctx, _json, _params) => {
4575
- if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
5371
+ const setProcessor = (schema, ctx, json, params) => {
5372
+ handleUnrepresentable(schema, ctx, json, params, "Set cannot be represented in JSON Schema");
4576
5373
  };
4577
5374
  const arrayProcessor = (schema, ctx, _json, params) => {
4578
5375
  const json = _json;
@@ -4586,25 +5383,32 @@ const arrayProcessor = (schema, ctx, _json, params) => {
4586
5383
  path: [...params.path, "items"]
4587
5384
  });
4588
5385
  };
5386
+ function inputOptin(schema) {
5387
+ const def = schema._zod.def;
5388
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
5389
+ if (def.type === "catch") return inputOptin(def.innerType);
5390
+ return schema._zod.optin;
5391
+ }
4589
5392
  const objectProcessor = (schema, ctx, _json, params) => {
4590
5393
  const json = _json;
4591
5394
  const def = schema._zod.def;
5395
+ const shape = def.shape;
5396
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
4592
5397
  json.type = "object";
4593
5398
  json.properties = {};
4594
- const shape = def.shape;
4595
- for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
5399
+ for (const key in shape) assignProp(json.properties, key, process$1(shape[key], ctx, {
4596
5400
  ...params,
4597
5401
  path: [
4598
5402
  ...params.path,
4599
5403
  "properties",
4600
5404
  key
4601
5405
  ]
4602
- });
5406
+ }));
4603
5407
  const allKeys = new Set(Object.keys(shape));
4604
5408
  const requiredKeys = new Set([...allKeys].filter((key) => {
4605
- const v = def.shape[key]._zod;
4606
- if (ctx.io === "input") return v.optin === void 0;
4607
- else return v.optout === void 0;
5409
+ const field = def.shape[key];
5410
+ if (ctx.io === "input") return inputOptin(field) === void 0;
5411
+ else return field._zod.optout === void 0;
4608
5412
  }));
4609
5413
  if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
4610
5414
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
@@ -4648,7 +5452,9 @@ const intersectionProcessor = (schema, ctx, json, params) => {
4648
5452
  ]
4649
5453
  });
4650
5454
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
4651
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
5455
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
5456
+ json.allOf = allOf;
5457
+ ctx.intersections.push(allOf);
4652
5458
  };
4653
5459
  const tupleProcessor = (schema, ctx, _json, params) => {
4654
5460
  const json = _json;
@@ -4672,17 +5478,31 @@ const tupleProcessor = (schema, ctx, _json, params) => {
4672
5478
  ...ctx.target === "openapi-3.0" ? [def.items.length] : []
4673
5479
  ]
4674
5480
  }) : null;
5481
+ let minItems = def.items.length;
5482
+ while (minItems > 0) {
5483
+ const item = def.items[minItems - 1];
5484
+ if (!(ctx.io === "input" ? inputOptin(item) !== void 0 : item._zod.optout === "optional")) break;
5485
+ minItems--;
5486
+ }
5487
+ const maxItems = def.items.length;
5488
+ const isClosed = !def.rest;
4675
5489
  if (ctx.target === "draft-2020-12") {
4676
5490
  json.prefixItems = prefixItems;
4677
- if (rest) json.items = rest;
5491
+ if (isClosed) json.items = false;
5492
+ else if (rest) json.items = rest;
5493
+ if (minItems > 0) json.minItems = minItems;
5494
+ if (isClosed) json.maxItems = maxItems;
4678
5495
  } else if (ctx.target === "openapi-3.0") {
4679
5496
  json.items = { anyOf: prefixItems };
4680
5497
  if (rest) json.items.anyOf.push(rest);
4681
- json.minItems = prefixItems.length;
4682
- if (!rest) json.maxItems = prefixItems.length;
5498
+ if (minItems > 0) json.minItems = minItems;
5499
+ if (isClosed) json.maxItems = maxItems;
4683
5500
  } else {
4684
5501
  json.items = prefixItems;
4685
- if (rest) json.additionalItems = rest;
5502
+ if (isClosed) json.additionalItems = false;
5503
+ else if (rest) json.additionalItems = rest;
5504
+ if (minItems > 0) json.minItems = minItems;
5505
+ if (isClosed) json.maxItems = maxItems;
4686
5506
  }
4687
5507
  const { minimum, maximum } = schema._zod.bag;
4688
5508
  if (typeof minimum === "number") json.minItems = minimum;
@@ -4704,7 +5524,7 @@ const recordProcessor = (schema, ctx, _json, params) => {
4704
5524
  ]
4705
5525
  });
4706
5526
  json.patternProperties = {};
4707
- for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
5527
+ for (const pattern of patterns) assignProp(json.patternProperties, pattern.source, valueSchema);
4708
5528
  } else {
4709
5529
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
4710
5530
  ...params,
@@ -4716,7 +5536,8 @@ const recordProcessor = (schema, ctx, _json, params) => {
4716
5536
  });
4717
5537
  }
4718
5538
  const keyValues = keyType._zod.values;
4719
- if (keyValues) {
5539
+ const omittableOnInput = ctx.io === "input" && inputOptin(def.valueType) !== void 0;
5540
+ if (keyValues && !def.partial && !omittableOnInput) {
4720
5541
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
4721
5542
  if (validKeyValues.length > 0) json.required = validKeyValues;
4722
5543
  }
@@ -4736,19 +5557,37 @@ const nonoptionalProcessor = (schema, ctx, _json, params) => {
4736
5557
  const seen = ctx.seen.get(schema);
4737
5558
  seen.ref = def.innerType;
4738
5559
  };
5560
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
5561
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
5562
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
5563
+ const UNREPRESENTABLE_DEFAULT = Symbol();
5564
+ function serializeDefaultValue(value, schema, ctx, json, params) {
5565
+ let unrepresentable = false;
5566
+ const serialized = JSON.stringify(value, (_, val) => {
5567
+ if (typeof val !== "bigint") return val;
5568
+ unrepresentable = true;
5569
+ return null;
5570
+ });
5571
+ if (!unrepresentable) return JSON.parse(serialized);
5572
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
5573
+ return UNREPRESENTABLE_DEFAULT;
5574
+ }
4739
5575
  const defaultProcessor = (schema, ctx, json, params) => {
4740
5576
  const def = schema._zod.def;
4741
5577
  process$1(def.innerType, ctx, params);
4742
5578
  const seen = ctx.seen.get(schema);
4743
5579
  seen.ref = def.innerType;
4744
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
5580
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
5581
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
4745
5582
  };
4746
5583
  const prefaultProcessor = (schema, ctx, json, params) => {
4747
5584
  const def = schema._zod.def;
4748
5585
  process$1(def.innerType, ctx, params);
4749
5586
  const seen = ctx.seen.get(schema);
4750
5587
  seen.ref = def.innerType;
4751
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
5588
+ if (ctx.io !== "input") return;
5589
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
5590
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
4752
5591
  };
4753
5592
  const catchProcessor = (schema, ctx, json, params) => {
4754
5593
  const def = schema._zod.def;
@@ -4759,7 +5598,8 @@ const catchProcessor = (schema, ctx, json, params) => {
4759
5598
  try {
4760
5599
  catchValue = def.catchValue(void 0);
4761
5600
  } catch {
4762
- throw new Error("Dynamic catch values are not supported in JSON Schema");
5601
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
5602
+ return;
4763
5603
  }
4764
5604
  json.default = catchValue;
4765
5605
  };
@@ -4797,7 +5637,7 @@ const lazyProcessor = (schema, ctx, _json, params) => {
4797
5637
  seen.ref = innerType;
4798
5638
  };
4799
5639
  //#endregion
4800
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/checks.js
5640
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/classic/checks.js
4801
5641
  var checks_exports = /* @__PURE__ */ __exportAll({
4802
5642
  endsWith: () => _endsWith,
4803
5643
  gt: () => _gt,
@@ -4819,6 +5659,7 @@ var checks_exports = /* @__PURE__ */ __exportAll({
4819
5659
  normalize: () => _normalize,
4820
5660
  overwrite: () => _overwrite,
4821
5661
  positive: () => _positive,
5662
+ properties: () => _properties,
4822
5663
  property: () => _property,
4823
5664
  regex: () => _regex,
4824
5665
  size: () => _size,
@@ -4829,58 +5670,58 @@ var checks_exports = /* @__PURE__ */ __exportAll({
4829
5670
  trim: () => _trim,
4830
5671
  uppercase: () => _uppercase
4831
5672
  });
4832
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4833
- $ZodISODateTime.init(inst, def);
4834
- ZodStringFormat.init(inst, def);
4835
- });
4836
- function datetime(params) {
4837
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
4838
- }
4839
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4840
- $ZodISODate.init(inst, def);
4841
- ZodStringFormat.init(inst, def);
4842
- });
4843
- function date$1(params) {
4844
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
4845
- }
4846
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4847
- $ZodISOTime.init(inst, def);
4848
- ZodStringFormat.init(inst, def);
4849
- });
4850
- function time(params) {
4851
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
4852
- }
4853
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4854
- $ZodISODuration.init(inst, def);
4855
- ZodStringFormat.init(inst, def);
4856
- });
4857
- function duration(params) {
4858
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4859
- }
4860
5673
  //#endregion
4861
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
5674
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/classic/errors.js
5675
+ const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
5676
+ function _lazyMethod(proto, key, make) {
5677
+ Object.defineProperty(proto, key, {
5678
+ configurable: true,
5679
+ enumerable: false,
5680
+ get() {
5681
+ const value = make(this);
5682
+ Object.defineProperty(this, key, {
5683
+ value,
5684
+ configurable: true,
5685
+ writable: true
5686
+ });
5687
+ return value;
5688
+ },
5689
+ set(value) {
5690
+ Object.defineProperty(this, key, {
5691
+ value,
5692
+ configurable: true,
5693
+ writable: true
5694
+ });
5695
+ }
5696
+ });
5697
+ }
4862
5698
  const initializer = (inst, issues) => {
4863
5699
  $ZodError.init(inst, issues);
4864
5700
  inst.name = "ZodError";
4865
- Object.defineProperties(inst, {
4866
- format: { value: (mapper) => formatError$1(inst, mapper) },
4867
- flatten: { value: (mapper) => flattenError(inst, mapper) },
4868
- addIssue: { value: (issue) => {
4869
- inst.issues.push(issue);
4870
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4871
- } },
4872
- addIssues: { value: (issues) => {
4873
- inst.issues.push(...issues);
4874
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
4875
- } },
4876
- isEmpty: { get() {
4877
- return inst.issues.length === 0;
4878
- } }
4879
- });
4880
- };
4881
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
5701
+ const proto = Object.getPrototypeOf(inst);
5702
+ if (_installedErrorProtos.has(proto)) return;
5703
+ _installedErrorProtos.add(proto);
5704
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError$1(self, mapper));
5705
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
5706
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
5707
+ self.issues.push(issue);
5708
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
5709
+ });
5710
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
5711
+ self.issues.push(...issues);
5712
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
5713
+ });
5714
+ Object.defineProperty(proto, "isEmpty", {
5715
+ configurable: true,
5716
+ enumerable: false,
5717
+ get() {
5718
+ return this.issues.length === 0;
5719
+ }
5720
+ });
5721
+ };
5722
+ const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
4882
5723
  //#endregion
4883
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
5724
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/classic/parse.js
4884
5725
  const parse = /* @__PURE__ */ _parse(ZodRealError);
4885
5726
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
4886
5727
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -4894,7 +5735,7 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
4894
5735
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
4895
5736
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
4896
5737
  //#endregion
4897
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
5738
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/classic/schemas.js
4898
5739
  var schemas_exports = /* @__PURE__ */ __exportAll({
4899
5740
  ZodAny: () => ZodAny,
4900
5741
  ZodArray: () => ZodArray,
@@ -4909,6 +5750,7 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
4909
5750
  ZodCUID2: () => ZodCUID2,
4910
5751
  ZodCatch: () => ZodCatch,
4911
5752
  ZodCodec: () => ZodCodec,
5753
+ ZodCreditCard: () => ZodCreditCard,
4912
5754
  ZodCustom: () => ZodCustom,
4913
5755
  ZodCustomStringFormat: () => ZodCustomStringFormat,
4914
5756
  ZodDate: () => ZodDate,
@@ -4924,6 +5766,10 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
4924
5766
  ZodGUID: () => ZodGUID,
4925
5767
  ZodIPv4: () => ZodIPv4,
4926
5768
  ZodIPv6: () => ZodIPv6,
5769
+ ZodISODate: () => ZodISODate,
5770
+ ZodISODateTime: () => ZodISODateTime,
5771
+ ZodISODuration: () => ZodISODuration,
5772
+ ZodISOTime: () => ZodISOTime,
4927
5773
  ZodIntersection: () => ZodIntersection,
4928
5774
  ZodJWT: () => ZodJWT,
4929
5775
  ZodKSUID: () => ZodKSUID,
@@ -4979,10 +5825,11 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
4979
5825
  cidrv4: () => cidrv4,
4980
5826
  cidrv6: () => cidrv6,
4981
5827
  codec: () => codec,
5828
+ creditCard: () => creditCard,
4982
5829
  cuid: () => cuid,
4983
5830
  cuid2: () => cuid2,
4984
5831
  custom: () => custom,
4985
- date: () => date,
5832
+ date: () => date$1,
4986
5833
  describe: () => describe,
4987
5834
  discriminatedUnion: () => discriminatedUnion,
4988
5835
  e164: () => e164,
@@ -5063,166 +5910,177 @@ var schemas_exports = /* @__PURE__ */ __exportAll({
5063
5910
  xid: () => xid,
5064
5911
  xor: () => xor
5065
5912
  });
5066
- const _installedGroups = /* @__PURE__ */ new WeakMap();
5067
- function _installLazyMethods(inst, group, methods) {
5068
- const proto = Object.getPrototypeOf(inst);
5069
- let installed = _installedGroups.get(proto);
5070
- if (!installed) {
5071
- installed = /* @__PURE__ */ new Set();
5072
- _installedGroups.set(proto, installed);
5073
- }
5074
- if (installed.has(group)) return;
5075
- installed.add(group);
5076
- for (const key in methods) {
5077
- const fn = methods[key];
5078
- Object.defineProperty(proto, key, {
5079
- configurable: true,
5080
- enumerable: false,
5081
- get() {
5082
- const bound = fn.bind(this);
5083
- Object.defineProperty(this, key, {
5084
- configurable: true,
5085
- writable: true,
5086
- enumerable: true,
5087
- value: bound
5088
- });
5089
- return bound;
5090
- },
5091
- set(v) {
5092
- Object.defineProperty(this, key, {
5093
- configurable: true,
5094
- writable: true,
5095
- enumerable: true,
5096
- value: v
5097
- });
5098
- }
5099
- });
5100
- }
5913
+ function _ensureDefaultLocale() {
5914
+ if (!globalConfig.localeError) config(en_default());
5915
+ }
5916
+ function _ensureDefaultMemoizer() {
5917
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
5101
5918
  }
5102
5919
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
5920
+ _ensureDefaultLocale();
5103
5921
  $ZodType.init(inst, def);
5104
- Object.assign(inst["~standard"], { jsonSchema: {
5105
- input: createStandardJSONSchemaMethod(inst, "input"),
5106
- output: createStandardJSONSchemaMethod(inst, "output")
5107
- } });
5108
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
5109
5922
  inst.def = def;
5110
5923
  inst.type = def.type;
5111
- Object.defineProperty(inst, "_def", { value: def });
5112
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
5113
- inst.safeParse = (data, params) => safeParse(inst, data, params);
5114
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
5115
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
5116
- inst.spa = inst.safeParseAsync;
5117
- inst.encode = (data, params) => encode(inst, data, params);
5118
- inst.decode = (data, params) => decode(inst, data, params);
5119
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
5120
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
5121
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
5122
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
5123
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
5124
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
5125
- _installLazyMethods(inst, "ZodType", {
5126
- check(...chks) {
5127
- const def = this.def;
5128
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
5129
- check: ch,
5130
- def: { check: "custom" },
5131
- onattach: []
5132
- } } : ch)] }), { parent: true });
5133
- },
5134
- with(...chks) {
5135
- return this.check(...chks);
5136
- },
5137
- clone(def, params) {
5138
- return clone(this, def, params);
5139
- },
5140
- brand() {
5141
- return this;
5142
- },
5143
- register(reg, meta) {
5144
- reg.add(this, meta);
5145
- return this;
5146
- },
5147
- refine(check, params) {
5148
- return this.check(refine$1(check, params));
5149
- },
5150
- superRefine(refinement, params) {
5151
- return this.check(superRefine(refinement, params));
5152
- },
5153
- overwrite(fn) {
5154
- return this.check(/* @__PURE__ */ _overwrite(fn));
5155
- },
5156
- optional() {
5157
- return optional(this);
5158
- },
5159
- exactOptional() {
5160
- return exactOptional(this);
5161
- },
5162
- nullable() {
5163
- return nullable(this);
5164
- },
5165
- nullish() {
5166
- return optional(nullable(this));
5167
- },
5168
- nonoptional(params) {
5169
- return nonoptional(this, params);
5170
- },
5171
- array() {
5172
- return array$1(this);
5173
- },
5174
- or(arg) {
5175
- return union$1([this, arg]);
5176
- },
5177
- and(arg) {
5178
- return intersection(this, arg);
5179
- },
5180
- transform(tx) {
5181
- return pipe$1(this, transform$1(tx));
5182
- },
5183
- default(d) {
5184
- return _default(this, d);
5185
- },
5186
- prefault(d) {
5187
- return prefault(this, d);
5188
- },
5189
- catch(params) {
5190
- return _catch(this, params);
5191
- },
5192
- pipe(target) {
5193
- return pipe$1(this, target);
5194
- },
5195
- readonly() {
5196
- return readonly(this);
5197
- },
5198
- describe(description) {
5199
- const cl = this.clone();
5200
- globalRegistry.add(cl, { description });
5201
- return cl;
5202
- },
5203
- meta(...args) {
5204
- if (args.length === 0) return globalRegistry.get(this);
5205
- const cl = this.clone();
5206
- globalRegistry.add(cl, args[0]);
5207
- return cl;
5208
- },
5209
- isOptional() {
5210
- return this.safeParse(void 0).success;
5211
- },
5212
- isNullable() {
5213
- return this.safeParse(null).success;
5214
- },
5215
- apply(fn) {
5216
- return fn(this);
5217
- }
5218
- });
5219
- Object.defineProperty(inst, "description", {
5220
- get() {
5221
- return globalRegistry.get(inst)?.description;
5222
- },
5223
- configurable: true
5224
- });
5225
5924
  return inst;
5925
+ }, {
5926
+ check(...chks) {
5927
+ const def = this.def;
5928
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
5929
+ check: ch,
5930
+ def: { check: "custom" },
5931
+ onattach: []
5932
+ } } : ch)] }), { parent: true });
5933
+ },
5934
+ with(...chks) {
5935
+ return this.check(...chks);
5936
+ },
5937
+ clone(def, params) {
5938
+ return clone(this, def, params);
5939
+ },
5940
+ brand() {
5941
+ return this;
5942
+ },
5943
+ register(reg, meta) {
5944
+ reg.add(this, meta);
5945
+ return this;
5946
+ },
5947
+ refine(check, params) {
5948
+ return this.check(refine$1(check, params));
5949
+ },
5950
+ superRefine(refinement, params) {
5951
+ return this.check(superRefine(refinement, params));
5952
+ },
5953
+ overwrite(fn) {
5954
+ return this.check(/* @__PURE__ */ _overwrite(fn));
5955
+ },
5956
+ optional() {
5957
+ return optional(this);
5958
+ },
5959
+ exactOptional() {
5960
+ return exactOptional(this);
5961
+ },
5962
+ nullable() {
5963
+ return nullable(this);
5964
+ },
5965
+ nullish() {
5966
+ return optional(nullable(this));
5967
+ },
5968
+ nonoptional(params) {
5969
+ return nonoptional(this, params);
5970
+ },
5971
+ array() {
5972
+ return array$1(this);
5973
+ },
5974
+ or(arg) {
5975
+ return union$1([this, arg]);
5976
+ },
5977
+ and(arg) {
5978
+ return intersection(this, arg);
5979
+ },
5980
+ transform(tx) {
5981
+ return pipe$1(this, transform$1(tx));
5982
+ },
5983
+ default(d) {
5984
+ return _default(this, d);
5985
+ },
5986
+ prefault(d) {
5987
+ return prefault(this, d);
5988
+ },
5989
+ catch(params) {
5990
+ return _catch(this, params);
5991
+ },
5992
+ pipe(target) {
5993
+ return pipe$1(this, target);
5994
+ },
5995
+ readonly() {
5996
+ return readonly(this);
5997
+ },
5998
+ describe(description) {
5999
+ const cl = this.clone();
6000
+ globalRegistry.add(cl, { description });
6001
+ return cl;
6002
+ },
6003
+ meta(...args) {
6004
+ if (args.length === 0) return globalRegistry.get(this);
6005
+ const cl = this.clone();
6006
+ globalRegistry.add(cl, args[0]);
6007
+ return cl;
6008
+ },
6009
+ isOptional() {
6010
+ return this.safeParse(void 0).success;
6011
+ },
6012
+ isNullable() {
6013
+ return this.safeParse(null).success;
6014
+ },
6015
+ apply(fn, ...args) {
6016
+ return args.length === 0 ? fn(this) : fn(this, ...args);
6017
+ },
6018
+ get "~standard"() {
6019
+ return hide(this, "~standard", {
6020
+ ...standardProps(this),
6021
+ jsonSchema: {
6022
+ input: createStandardJSONSchemaMethod(this, "input"),
6023
+ output: createStandardJSONSchemaMethod(this, "output")
6024
+ }
6025
+ });
6026
+ },
6027
+ set "~standard"(value) {
6028
+ own(this, "~standard", value);
6029
+ },
6030
+ parse: function _parse(data, params) {
6031
+ return parse(this, data, params, { callee: _parse });
6032
+ },
6033
+ parseAsync: async function _parseAsync(data, params) {
6034
+ return await parseAsync(this, data, params, { callee: _parseAsync });
6035
+ },
6036
+ safeParse(data, params) {
6037
+ return safeParse(this, data, params);
6038
+ },
6039
+ async safeParseAsync(data, params) {
6040
+ return safeParseAsync(this, data, params);
6041
+ },
6042
+ get spa() {
6043
+ return this.safeParseAsync;
6044
+ },
6045
+ set spa(value) {
6046
+ own(this, "spa", value);
6047
+ },
6048
+ encode: function _encode(data, params) {
6049
+ return encode(this, data, params, { callee: _encode });
6050
+ },
6051
+ decode: function _decode(data, params) {
6052
+ return decode(this, data, params, { callee: _decode });
6053
+ },
6054
+ encodeAsync: async function _encodeAsync(data, params) {
6055
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
6056
+ },
6057
+ decodeAsync: async function _decodeAsync(data, params) {
6058
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
6059
+ },
6060
+ safeEncode(data, params) {
6061
+ return safeEncode(this, data, params);
6062
+ },
6063
+ safeDecode(data, params) {
6064
+ return safeDecode(this, data, params);
6065
+ },
6066
+ async safeEncodeAsync(data, params) {
6067
+ return safeEncodeAsync(this, data, params);
6068
+ },
6069
+ async safeDecodeAsync(data, params) {
6070
+ return safeDecodeAsync(this, data, params);
6071
+ },
6072
+ get toJSONSchema() {
6073
+ return own(this, "toJSONSchema", createToJSONSchemaMethod(this, {}));
6074
+ },
6075
+ set toJSONSchema(value) {
6076
+ own(this, "toJSONSchema", value);
6077
+ },
6078
+ get description() {
6079
+ return globalRegistry.get(this)?.description;
6080
+ },
6081
+ get _def() {
6082
+ return this._zod.def;
6083
+ }
5226
6084
  });
5227
6085
  /** @internal */
5228
6086
  const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
@@ -5233,84 +6091,135 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
5233
6091
  inst.format = bag.format ?? null;
5234
6092
  inst.minLength = bag.minimum ?? null;
5235
6093
  inst.maxLength = bag.maximum ?? null;
5236
- _installLazyMethods(inst, "_ZodString", {
5237
- regex(...args) {
5238
- return this.check(/* @__PURE__ */ _regex(...args));
5239
- },
5240
- includes(...args) {
5241
- return this.check(/* @__PURE__ */ _includes(...args));
5242
- },
5243
- startsWith(...args) {
5244
- return this.check(/* @__PURE__ */ _startsWith(...args));
5245
- },
5246
- endsWith(...args) {
5247
- return this.check(/* @__PURE__ */ _endsWith(...args));
5248
- },
5249
- min(...args) {
5250
- return this.check(/* @__PURE__ */ _minLength(...args));
5251
- },
5252
- max(...args) {
5253
- return this.check(/* @__PURE__ */ _maxLength(...args));
5254
- },
5255
- length(...args) {
5256
- return this.check(/* @__PURE__ */ _length(...args));
5257
- },
5258
- nonempty(...args) {
5259
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
5260
- },
5261
- lowercase(params) {
5262
- return this.check(/* @__PURE__ */ _lowercase(params));
5263
- },
5264
- uppercase(params) {
5265
- return this.check(/* @__PURE__ */ _uppercase(params));
5266
- },
5267
- trim() {
5268
- return this.check(/* @__PURE__ */ _trim());
5269
- },
5270
- normalize(...args) {
5271
- return this.check(/* @__PURE__ */ _normalize(...args));
5272
- },
5273
- toLowerCase() {
5274
- return this.check(/* @__PURE__ */ _toLowerCase());
5275
- },
5276
- toUpperCase() {
5277
- return this.check(/* @__PURE__ */ _toUpperCase());
5278
- },
5279
- slugify() {
5280
- return this.check(/* @__PURE__ */ _slugify());
5281
- }
5282
- });
6094
+ }, {
6095
+ regex(...args) {
6096
+ return this.check(/* @__PURE__ */ _regex(...args));
6097
+ },
6098
+ includes(...args) {
6099
+ return this.check(/* @__PURE__ */ _includes(...args));
6100
+ },
6101
+ startsWith(...args) {
6102
+ return this.check(/* @__PURE__ */ _startsWith(...args));
6103
+ },
6104
+ endsWith(...args) {
6105
+ return this.check(/* @__PURE__ */ _endsWith(...args));
6106
+ },
6107
+ min(...args) {
6108
+ return this.check(/* @__PURE__ */ _minLength(...args));
6109
+ },
6110
+ max(...args) {
6111
+ return this.check(/* @__PURE__ */ _maxLength(...args));
6112
+ },
6113
+ length(...args) {
6114
+ return this.check(/* @__PURE__ */ _length(...args));
6115
+ },
6116
+ nonempty(...args) {
6117
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
6118
+ },
6119
+ lowercase(params) {
6120
+ return this.check(/* @__PURE__ */ _lowercase(params));
6121
+ },
6122
+ uppercase(params) {
6123
+ return this.check(/* @__PURE__ */ _uppercase(params));
6124
+ },
6125
+ trim() {
6126
+ return this.check(/* @__PURE__ */ _trim());
6127
+ },
6128
+ normalize(...args) {
6129
+ return this.check(/* @__PURE__ */ _normalize(...args));
6130
+ },
6131
+ toLowerCase() {
6132
+ return this.check(/* @__PURE__ */ _toLowerCase());
6133
+ },
6134
+ toUpperCase() {
6135
+ return this.check(/* @__PURE__ */ _toUpperCase());
6136
+ },
6137
+ slugify() {
6138
+ return this.check(/* @__PURE__ */ _slugify());
6139
+ }
5283
6140
  });
5284
6141
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
5285
6142
  $ZodString.init(inst, def);
5286
6143
  _ZodString.init(inst, def);
5287
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
5288
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
5289
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
5290
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
5291
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
5292
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
5293
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
5294
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
5295
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
5296
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
5297
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
5298
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
5299
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
5300
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
5301
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
5302
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
5303
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
5304
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
5305
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
5306
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
5307
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
5308
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
5309
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
5310
- inst.datetime = (params) => inst.check(datetime(params));
5311
- inst.date = (params) => inst.check(date$1(params));
5312
- inst.time = (params) => inst.check(time(params));
5313
- inst.duration = (params) => inst.check(duration(params));
6144
+ }, {
6145
+ email(params) {
6146
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
6147
+ },
6148
+ url(params) {
6149
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
6150
+ },
6151
+ jwt(params) {
6152
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
6153
+ },
6154
+ emoji(params) {
6155
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
6156
+ },
6157
+ guid(params) {
6158
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
6159
+ },
6160
+ uuid(params) {
6161
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
6162
+ },
6163
+ uuidv4(params) {
6164
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
6165
+ },
6166
+ uuidv6(params) {
6167
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
6168
+ },
6169
+ uuidv7(params) {
6170
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
6171
+ },
6172
+ nanoid(params) {
6173
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
6174
+ },
6175
+ cuid(params) {
6176
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
6177
+ },
6178
+ cuid2(params) {
6179
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
6180
+ },
6181
+ ulid(params) {
6182
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
6183
+ },
6184
+ base64(params) {
6185
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
6186
+ },
6187
+ base64url(params) {
6188
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
6189
+ },
6190
+ xid(params) {
6191
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
6192
+ },
6193
+ ksuid(params) {
6194
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
6195
+ },
6196
+ ipv4(params) {
6197
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
6198
+ },
6199
+ ipv6(params) {
6200
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
6201
+ },
6202
+ cidrv4(params) {
6203
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
6204
+ },
6205
+ cidrv6(params) {
6206
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
6207
+ },
6208
+ e164(params) {
6209
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
6210
+ },
6211
+ datetime(params) {
6212
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
6213
+ },
6214
+ date(params) {
6215
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
6216
+ },
6217
+ time(params) {
6218
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
6219
+ },
6220
+ duration(params) {
6221
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
6222
+ }
5314
6223
  });
5315
6224
  function string$1(params) {
5316
6225
  return /* @__PURE__ */ _string(ZodString, params);
@@ -5319,6 +6228,22 @@ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def
5319
6228
  $ZodStringFormat.init(inst, def);
5320
6229
  _ZodString.init(inst, def);
5321
6230
  });
6231
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
6232
+ $ZodISODateTime.init(inst, def);
6233
+ ZodStringFormat.init(inst, def);
6234
+ });
6235
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
6236
+ $ZodISODate.init(inst, def);
6237
+ ZodStringFormat.init(inst, def);
6238
+ });
6239
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
6240
+ $ZodISOTime.init(inst, def);
6241
+ ZodStringFormat.init(inst, def);
6242
+ });
6243
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
6244
+ $ZodISODuration.init(inst, def);
6245
+ ZodStringFormat.init(inst, def);
6246
+ });
5322
6247
  const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
5323
6248
  $ZodEmail.init(inst, def);
5324
6249
  ZodStringFormat.init(inst, def);
@@ -5480,6 +6405,13 @@ const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
5480
6405
  function e164(params) {
5481
6406
  return /* @__PURE__ */ _e164(ZodE164, params);
5482
6407
  }
6408
+ const ZodCreditCard = /*@__PURE__*/ $constructor("ZodCreditCard", (inst, def) => {
6409
+ $ZodCreditCard.init(inst, def);
6410
+ ZodStringFormat.init(inst, def);
6411
+ });
6412
+ function creditCard(params) {
6413
+ return /* @__PURE__ */ _creditCard(ZodCreditCard, params);
6414
+ }
5483
6415
  const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
5484
6416
  $ZodJWT.init(inst, def);
5485
6417
  ZodStringFormat.init(inst, def);
@@ -5510,59 +6442,58 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
5510
6442
  $ZodNumber.init(inst, def);
5511
6443
  ZodType.init(inst, def);
5512
6444
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
5513
- _installLazyMethods(inst, "ZodNumber", {
5514
- gt(value, params) {
5515
- return this.check(/* @__PURE__ */ _gt(value, params));
5516
- },
5517
- gte(value, params) {
5518
- return this.check(/* @__PURE__ */ _gte(value, params));
5519
- },
5520
- min(value, params) {
5521
- return this.check(/* @__PURE__ */ _gte(value, params));
5522
- },
5523
- lt(value, params) {
5524
- return this.check(/* @__PURE__ */ _lt(value, params));
5525
- },
5526
- lte(value, params) {
5527
- return this.check(/* @__PURE__ */ _lte(value, params));
5528
- },
5529
- max(value, params) {
5530
- return this.check(/* @__PURE__ */ _lte(value, params));
5531
- },
5532
- int(params) {
5533
- return this.check(int(params));
5534
- },
5535
- safe(params) {
5536
- return this.check(int(params));
5537
- },
5538
- positive(params) {
5539
- return this.check(/* @__PURE__ */ _gt(0, params));
5540
- },
5541
- nonnegative(params) {
5542
- return this.check(/* @__PURE__ */ _gte(0, params));
5543
- },
5544
- negative(params) {
5545
- return this.check(/* @__PURE__ */ _lt(0, params));
5546
- },
5547
- nonpositive(params) {
5548
- return this.check(/* @__PURE__ */ _lte(0, params));
5549
- },
5550
- multipleOf(value, params) {
5551
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
5552
- },
5553
- step(value, params) {
5554
- return this.check(/* @__PURE__ */ _multipleOf(value, params));
5555
- },
5556
- finite() {
5557
- return this;
5558
- }
5559
- });
5560
6445
  const bag = inst._zod.bag;
5561
6446
  inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
5562
6447
  inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
5563
6448
  inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
5564
6449
  inst.isFinite = true;
5565
6450
  inst.format = bag.format ?? null;
6451
+ }, {
6452
+ gt(value, params) {
6453
+ return this.check(/* @__PURE__ */ _gt(value, params));
6454
+ },
6455
+ gte(value, params) {
6456
+ return this.check(/* @__PURE__ */ _gte(value, params));
6457
+ },
6458
+ min(value, params) {
6459
+ return this.check(/* @__PURE__ */ _gte(value, params));
6460
+ },
6461
+ lt(value, params) {
6462
+ return this.check(/* @__PURE__ */ _lt(value, params));
6463
+ },
6464
+ lte(value, params) {
6465
+ return this.check(/* @__PURE__ */ _lte(value, params));
6466
+ },
6467
+ max(value, params) {
6468
+ return this.check(/* @__PURE__ */ _lte(value, params));
6469
+ },
6470
+ int(params) {
6471
+ return this.check(int(params));
6472
+ },
6473
+ safe(params) {
6474
+ return this.check(int(params));
6475
+ },
6476
+ positive(params) {
6477
+ return this.check(/* @__PURE__ */ _gt(0, params));
6478
+ },
6479
+ nonnegative(params) {
6480
+ return this.check(/* @__PURE__ */ _gte(0, params));
6481
+ },
6482
+ negative(params) {
6483
+ return this.check(/* @__PURE__ */ _lt(0, params));
6484
+ },
6485
+ nonpositive(params) {
6486
+ return this.check(/* @__PURE__ */ _lte(0, params));
6487
+ },
6488
+ multipleOf(value, params) {
6489
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
6490
+ },
6491
+ step(value, params) {
6492
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
6493
+ },
6494
+ finite() {
6495
+ return this;
6496
+ }
5566
6497
  });
5567
6498
  function number$1(params) {
5568
6499
  return /* @__PURE__ */ _number(ZodNumber, params);
@@ -5598,23 +6529,44 @@ const ZodBigInt = /*@__PURE__*/ $constructor("ZodBigInt", (inst, def) => {
5598
6529
  $ZodBigInt.init(inst, def);
5599
6530
  ZodType.init(inst, def);
5600
6531
  inst._zod.processJSONSchema = (ctx, json, params) => bigintProcessor(inst, ctx, json, params);
5601
- inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
5602
- inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
5603
- inst.gt = (value, params) => inst.check(/* @__PURE__ */ _gt(value, params));
5604
- inst.gte = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
5605
- inst.min = (value, params) => inst.check(/* @__PURE__ */ _gte(value, params));
5606
- inst.lt = (value, params) => inst.check(/* @__PURE__ */ _lt(value, params));
5607
- inst.lte = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
5608
- inst.max = (value, params) => inst.check(/* @__PURE__ */ _lte(value, params));
5609
- inst.positive = (params) => inst.check(/* @__PURE__ */ _gt(BigInt(0), params));
5610
- inst.negative = (params) => inst.check(/* @__PURE__ */ _lt(BigInt(0), params));
5611
- inst.nonpositive = (params) => inst.check(/* @__PURE__ */ _lte(BigInt(0), params));
5612
- inst.nonnegative = (params) => inst.check(/* @__PURE__ */ _gte(BigInt(0), params));
5613
- inst.multipleOf = (value, params) => inst.check(/* @__PURE__ */ _multipleOf(value, params));
5614
6532
  const bag = inst._zod.bag;
5615
6533
  inst.minValue = bag.minimum ?? null;
5616
6534
  inst.maxValue = bag.maximum ?? null;
5617
6535
  inst.format = bag.format ?? null;
6536
+ }, {
6537
+ gte(value, params) {
6538
+ return this.check(/* @__PURE__ */ _gte(value, params));
6539
+ },
6540
+ min(value, params) {
6541
+ return this.check(/* @__PURE__ */ _gte(value, params));
6542
+ },
6543
+ gt(value, params) {
6544
+ return this.check(/* @__PURE__ */ _gt(value, params));
6545
+ },
6546
+ lt(value, params) {
6547
+ return this.check(/* @__PURE__ */ _lt(value, params));
6548
+ },
6549
+ lte(value, params) {
6550
+ return this.check(/* @__PURE__ */ _lte(value, params));
6551
+ },
6552
+ max(value, params) {
6553
+ return this.check(/* @__PURE__ */ _lte(value, params));
6554
+ },
6555
+ positive(params) {
6556
+ return this.check(/* @__PURE__ */ _gt(BigInt(0), params));
6557
+ },
6558
+ negative(params) {
6559
+ return this.check(/* @__PURE__ */ _lt(BigInt(0), params));
6560
+ },
6561
+ nonpositive(params) {
6562
+ return this.check(/* @__PURE__ */ _lte(BigInt(0), params));
6563
+ },
6564
+ nonnegative(params) {
6565
+ return this.check(/* @__PURE__ */ _gte(BigInt(0), params));
6566
+ },
6567
+ multipleOf(value, params) {
6568
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
6569
+ }
5618
6570
  });
5619
6571
  function bigint$1(params) {
5620
6572
  return /* @__PURE__ */ _bigint(ZodBigInt, params);
@@ -5695,31 +6647,31 @@ const ZodDate = /*@__PURE__*/ $constructor("ZodDate", (inst, def) => {
5695
6647
  inst.minDate = c.minimum ? new Date(c.minimum) : null;
5696
6648
  inst.maxDate = c.maximum ? new Date(c.maximum) : null;
5697
6649
  });
5698
- function date(params) {
6650
+ function date$1(params) {
5699
6651
  return /* @__PURE__ */ _date(ZodDate, params);
5700
6652
  }
5701
6653
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
6654
+ _ensureDefaultMemoizer();
5702
6655
  $ZodArray.init(inst, def);
5703
6656
  ZodType.init(inst, def);
5704
6657
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
5705
6658
  inst.element = def.element;
5706
- _installLazyMethods(inst, "ZodArray", {
5707
- min(n, params) {
5708
- return this.check(/* @__PURE__ */ _minLength(n, params));
5709
- },
5710
- nonempty(params) {
5711
- return this.check(/* @__PURE__ */ _minLength(1, params));
5712
- },
5713
- max(n, params) {
5714
- return this.check(/* @__PURE__ */ _maxLength(n, params));
5715
- },
5716
- length(n, params) {
5717
- return this.check(/* @__PURE__ */ _length(n, params));
5718
- },
5719
- unwrap() {
5720
- return this.element;
5721
- }
5722
- });
6659
+ }, {
6660
+ min(n, params) {
6661
+ return this.check(/* @__PURE__ */ _minLength(n, params));
6662
+ },
6663
+ nonempty(params) {
6664
+ return this.check(/* @__PURE__ */ _minLength(1, params));
6665
+ },
6666
+ max(n, params) {
6667
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
6668
+ },
6669
+ length(n, params) {
6670
+ return this.check(/* @__PURE__ */ _length(n, params));
6671
+ },
6672
+ unwrap() {
6673
+ return this.element;
6674
+ }
5723
6675
  });
5724
6676
  function array$1(element, params) {
5725
6677
  return /* @__PURE__ */ _array(ZodArray, element, params);
@@ -5729,68 +6681,69 @@ function keyof(schema) {
5729
6681
  return _enum(Object.keys(shape));
5730
6682
  }
5731
6683
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
6684
+ _ensureDefaultMemoizer();
5732
6685
  $ZodObjectJIT.init(inst, def);
5733
6686
  ZodType.init(inst, def);
5734
6687
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
5735
- defineLazy(inst, "shape", () => {
5736
- return def.shape;
5737
- });
5738
- _installLazyMethods(inst, "ZodObject", {
5739
- keyof() {
5740
- return _enum(Object.keys(this._zod.def.shape));
5741
- },
5742
- catchall(catchall) {
5743
- return this.clone({
5744
- ...this._zod.def,
5745
- catchall
5746
- });
5747
- },
5748
- passthrough() {
5749
- return this.clone({
5750
- ...this._zod.def,
5751
- catchall: unknown()
5752
- });
5753
- },
5754
- loose() {
5755
- return this.clone({
5756
- ...this._zod.def,
5757
- catchall: unknown()
5758
- });
5759
- },
5760
- strict() {
5761
- return this.clone({
5762
- ...this._zod.def,
5763
- catchall: never()
5764
- });
5765
- },
5766
- strip() {
5767
- return this.clone({
5768
- ...this._zod.def,
5769
- catchall: void 0
5770
- });
5771
- },
5772
- extend(incoming) {
5773
- return extend(this, incoming);
5774
- },
5775
- safeExtend(incoming) {
5776
- return safeExtend(this, incoming);
5777
- },
5778
- merge(other) {
5779
- return merge$1(this, other);
5780
- },
5781
- pick(mask) {
5782
- return pick(this, mask);
5783
- },
5784
- omit(mask) {
5785
- return omit(this, mask);
5786
- },
5787
- partial(...args) {
5788
- return partial(ZodOptional, this, args[0]);
5789
- },
5790
- required(...args) {
5791
- return required(ZodNonOptional, this, args[0]);
5792
- }
5793
- });
6688
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
6689
+ }, {
6690
+ keyof() {
6691
+ return _enum(Object.keys(this._zod.def.shape));
6692
+ },
6693
+ catchall(catchall) {
6694
+ return this.clone({
6695
+ ...this._zod.def,
6696
+ catchall
6697
+ });
6698
+ },
6699
+ passthrough() {
6700
+ return this.clone({
6701
+ ...this._zod.def,
6702
+ catchall: unknown()
6703
+ });
6704
+ },
6705
+ loose() {
6706
+ return this.clone({
6707
+ ...this._zod.def,
6708
+ catchall: unknown()
6709
+ });
6710
+ },
6711
+ strict() {
6712
+ return this.clone({
6713
+ ...this._zod.def,
6714
+ catchall: never()
6715
+ });
6716
+ },
6717
+ strip() {
6718
+ return this.clone({
6719
+ ...this._zod.def,
6720
+ catchall: void 0
6721
+ });
6722
+ },
6723
+ extend(incoming) {
6724
+ return extend(this, incoming);
6725
+ },
6726
+ safeExtend(incoming) {
6727
+ return safeExtend(this, incoming);
6728
+ },
6729
+ merge(other) {
6730
+ return merge$1(this, other);
6731
+ },
6732
+ pick(mask) {
6733
+ return pick(this, mask);
6734
+ },
6735
+ omit(mask) {
6736
+ return omit(this, mask);
6737
+ },
6738
+ partial(...args) {
6739
+ return partial(ZodOptional, this, args[0]);
6740
+ },
6741
+ exactPartial(...args) {
6742
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
6743
+ },
6744
+ required(...args) {
6745
+ return required(ZodNonOptional, this, args[0]);
6746
+ }
5794
6747
  });
5795
6748
  function object(shape, params) {
5796
6749
  const def = {
@@ -5871,13 +6824,28 @@ function intersection(left, right) {
5871
6824
  });
5872
6825
  }
5873
6826
  const ZodTuple = /*@__PURE__*/ $constructor("ZodTuple", (inst, def) => {
6827
+ _ensureDefaultMemoizer();
5874
6828
  $ZodTuple.init(inst, def);
5875
6829
  ZodType.init(inst, def);
5876
6830
  inst._zod.processJSONSchema = (ctx, json, params) => tupleProcessor(inst, ctx, json, params);
5877
- inst.rest = (rest) => inst.clone({
5878
- ...inst._zod.def,
5879
- rest
5880
- });
6831
+ }, {
6832
+ rest(rest) {
6833
+ return this.clone({
6834
+ ...this._zod.def,
6835
+ rest
6836
+ });
6837
+ },
6838
+ partial() {
6839
+ const def = this._zod.def;
6840
+ if (def.checks?.length) throw new Error(".partial() cannot be used on tuple schemas containing refinements");
6841
+ return this.clone({
6842
+ ...def,
6843
+ items: def.items.map((item) => new ZodOptional({
6844
+ type: "optional",
6845
+ innerType: item
6846
+ }))
6847
+ });
6848
+ }
5881
6849
  });
5882
6850
  function tuple(items, _paramsOrRest, _params) {
5883
6851
  const hasRest = _paramsOrRest instanceof $ZodType;
@@ -5889,6 +6857,7 @@ function tuple(items, _paramsOrRest, _params) {
5889
6857
  });
5890
6858
  }
5891
6859
  const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
6860
+ _ensureDefaultMemoizer();
5892
6861
  $ZodRecord.init(inst, def);
5893
6862
  ZodType.init(inst, def);
5894
6863
  inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
@@ -5910,13 +6879,12 @@ function record$1(keyType, valueType, params) {
5910
6879
  });
5911
6880
  }
5912
6881
  function partialRecord(keyType, valueType, params) {
5913
- const k = clone(keyType);
5914
- k._zod.values = void 0;
5915
6882
  return new ZodRecord({
5916
6883
  type: "record",
5917
- keyType: k,
6884
+ keyType,
5918
6885
  valueType,
5919
- ...normalizeParams(params)
6886
+ ...normalizeParams(params),
6887
+ partial: true
5920
6888
  });
5921
6889
  }
5922
6890
  function looseRecord(keyType, valueType, params) {
@@ -5929,6 +6897,7 @@ function looseRecord(keyType, valueType, params) {
5929
6897
  });
5930
6898
  }
5931
6899
  const ZodMap = /*@__PURE__*/ $constructor("ZodMap", (inst, def) => {
6900
+ _ensureDefaultMemoizer();
5932
6901
  $ZodMap.init(inst, def);
5933
6902
  ZodType.init(inst, def);
5934
6903
  inst._zod.processJSONSchema = (ctx, json, params) => mapProcessor(inst, ctx, json, params);
@@ -5948,6 +6917,7 @@ function map(keyType, valueType, params) {
5948
6917
  });
5949
6918
  }
5950
6919
  const ZodSet = /*@__PURE__*/ $constructor("ZodSet", (inst, def) => {
6920
+ _ensureDefaultMemoizer();
5951
6921
  $ZodSet.init(inst, def);
5952
6922
  ZodType.init(inst, def);
5953
6923
  inst._zod.processJSONSchema = (ctx, json, params) => setProcessor(inst, ctx, json, params);
@@ -6044,6 +7014,7 @@ function file(params) {
6044
7014
  return /* @__PURE__ */ _file(ZodFile, params);
6045
7015
  }
6046
7016
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
7017
+ _ensureDefaultMemoizer();
6047
7018
  $ZodTransform.init(inst, def);
6048
7019
  ZodType.init(inst, def);
6049
7020
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -6055,7 +7026,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
6055
7026
  const _issue = issue$1;
6056
7027
  if (_issue.fatal) _issue.continue = false;
6057
7028
  _issue.code ?? (_issue.code = "custom");
6058
- _issue.input ?? (_issue.input = payload.value);
7029
+ if (!("input" in _issue)) _issue.input = payload.value;
6059
7030
  _issue.inst ?? (_issue.inst = inst);
6060
7031
  payload.issues.push(issue(_issue));
6061
7032
  }
@@ -6063,11 +7034,9 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
6063
7034
  const output = def.transform(payload.value, payload);
6064
7035
  if (output instanceof Promise) return output.then((output) => {
6065
7036
  payload.value = output;
6066
- payload.fallback = true;
6067
7037
  return payload;
6068
7038
  });
6069
7039
  payload.value = output;
6070
- payload.fallback = true;
6071
7040
  return payload;
6072
7041
  };
6073
7042
  });
@@ -6183,7 +7152,7 @@ function _catch(innerType, catchValue) {
6183
7152
  return new ZodCatch({
6184
7153
  type: "catch",
6185
7154
  innerType,
6186
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
7155
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
6187
7156
  });
6188
7157
  }
6189
7158
  const ZodNaN = /*@__PURE__*/ $constructor("ZodNaN", (inst, def) => {
@@ -6362,7 +7331,7 @@ function preprocess(fn, schema) {
6362
7331
  });
6363
7332
  }
6364
7333
  //#endregion
6365
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/compat.js
7334
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/classic/compat.js
6366
7335
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6367
7336
  var ZodFirstPartyTypeKind;
6368
7337
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
@@ -6371,10 +7340,7 @@ ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6371
7340
  ...checks_exports
6372
7341
  });
6373
7342
  //#endregion
6374
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
6375
- config(en_default());
6376
- //#endregion
6377
- //#region ../../node_modules/.pnpm/@ariestools+provider-model@1.3.0_zod@4.4.3/node_modules/@ariestools/provider-model/dist/neutral/index.mjs
7343
+ //#region ../../node_modules/.pnpm/@ariestools+provider-model@1.3.0_zod@4.5.1/node_modules/@ariestools/provider-model/dist/neutral/index.mjs
6378
7344
  var ConnectionConfigZod = looseObject({ type: string$1().min(1) });
6379
7345
  var ConnectionsConfigZod = record$1(string$1(), ConnectionConfigZod).default({});
6380
7346
  strictObject({ dependencies: array$1(string$1().min(1)).default([]) });
@@ -6388,18 +7354,34 @@ var ProviderConfigFieldsZod = object({
6388
7354
  providerBindings: record$1(string$1(), ProviderBindingConfigZod).default({})
6389
7355
  });
6390
7356
  //#endregion
6391
- //#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/mini/schemas.js
7357
+ //#region ../../node_modules/.pnpm/zod@4.5.1/node_modules/zod/v4/mini/schemas.js
6392
7358
  const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
6393
7359
  if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType.");
6394
7360
  $ZodType.init(inst, def);
6395
7361
  inst.def = def;
6396
7362
  inst.type = def.type;
6397
- inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
6398
- inst.safeParse = (data, params) => safeParse$1(inst, data, params);
6399
- inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
6400
- inst.safeParseAsync = async (data, params) => safeParseAsync$1(inst, data, params);
6401
- inst.check = (...checks) => {
6402
- return inst.clone({
7363
+ }, {
7364
+ get with() {
7365
+ return this.check;
7366
+ },
7367
+ set with(value) {
7368
+ own(this, "with", value);
7369
+ },
7370
+ parse(data, params) {
7371
+ return parse$1(this, data, params, { callee: this.parse });
7372
+ },
7373
+ parseAsync(data, params) {
7374
+ return parseAsync$1(this, data, params, { callee: this.parseAsync });
7375
+ },
7376
+ safeParse(data, params) {
7377
+ return safeParse$1(this, data, params);
7378
+ },
7379
+ safeParseAsync(data, params) {
7380
+ return safeParseAsync$1(this, data, params);
7381
+ },
7382
+ check(...checks) {
7383
+ const def = this.def;
7384
+ return this.clone({
6403
7385
  ...def,
6404
7386
  checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
6405
7387
  check: ch,
@@ -6407,15 +7389,20 @@ const ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
6407
7389
  onattach: []
6408
7390
  } } : ch)]
6409
7391
  }, { parent: true });
6410
- };
6411
- inst.with = inst.check;
6412
- inst.clone = (_def, params) => clone(inst, _def, params);
6413
- inst.brand = () => inst;
6414
- inst.register = ((reg, meta) => {
6415
- reg.add(inst, meta);
6416
- return inst;
6417
- });
6418
- inst.apply = (fn) => fn(inst);
7392
+ },
7393
+ clone(_def, params) {
7394
+ return clone(this, _def, params);
7395
+ },
7396
+ brand() {
7397
+ return this;
7398
+ },
7399
+ register(reg, meta) {
7400
+ reg.add(this, meta);
7401
+ return this;
7402
+ },
7403
+ apply(fn, ...args) {
7404
+ return args.length === 0 ? fn(this) : fn(this, ...args);
7405
+ }
6419
7406
  });
6420
7407
  const ZodMiniString = /*@__PURE__*/ $constructor("ZodMiniString", (inst, def) => {
6421
7408
  $ZodString.init(inst, def);
@@ -7963,19 +8950,19 @@ const API_NAME = "trace";
7963
8950
  }
7964
8951
  }).getInstance();
7965
8952
  //#endregion
7966
- //#region ../../node_modules/.pnpm/@ariestools+telemetry@8.1.9_@opentelemetry+api@1.9.1/node_modules/@ariestools/telemetry/dist/neutral/index.mjs
7967
- var color = (open, close = 39) => {
8953
+ //#region ../../node_modules/.pnpm/@ariestools+telemetry@8.2.0_@opentelemetry+api@1.9.1/node_modules/@ariestools/telemetry/dist/neutral/index.mjs
8954
+ var color$1 = (open, close = 39) => {
7968
8955
  return (value) => `\x1B[${open}m${value}\x1B[${close}m`;
7969
8956
  };
7970
- var logColors = {
7971
- green: color(32),
7972
- grey: color(90),
7973
- magenta: color(35),
7974
- red: color(31),
7975
- white: color(37),
7976
- yellow: color(33)
8957
+ var logColors$1 = {
8958
+ green: color$1(32),
8959
+ grey: color$1(90),
8960
+ magenta: color$1(35),
8961
+ red: color$1(31),
8962
+ white: color$1(37),
8963
+ yellow: color$1(33)
7977
8964
  };
7978
- function spanDurationInMillis(span2) {
8965
+ function spanDurationInMillis$1(span2) {
7979
8966
  return span2.duration[0] * 1e3 + span2.duration[1] / 1e6;
7980
8967
  }
7981
8968
  (class _XyConsoleSpanExporterImplementation {
@@ -7989,11 +8976,11 @@ function spanDurationInMillis(span2) {
7989
8976
  ];
7990
8977
  /** Chalk color functions corresponding to each log level. */
7991
8978
  static logLevelToChalkColor = [
7992
- logColors.grey,
7993
- logColors.white,
7994
- logColors.green,
7995
- logColors.yellow,
7996
- logColors.red
8979
+ logColors$1.grey,
8980
+ logColors$1.white,
8981
+ logColors$1.green,
8982
+ logColors$1.yellow,
8983
+ logColors$1.red
7997
8984
  ];
7998
8985
  logger;
7999
8986
  _logLevel;
@@ -8009,8 +8996,8 @@ function spanDurationInMillis(span2) {
8009
8996
  for (const span2 of spans) {
8010
8997
  const spanLevel = this.spanLevel(span2);
8011
8998
  if (spanLevel < this.logLevel) continue;
8012
- const duration = spanDurationInMillis(span2);
8013
- this.logger.log(logColors.grey([
8999
+ const duration = spanDurationInMillis$1(span2);
9000
+ this.logger.log(logColors$1.grey([
8014
9001
  `Span [${span2.name}]`,
8015
9002
  this.logColor(spanLevel)(`${duration}ms`),
8016
9003
  `TraceId: ${span2.spanContext().traceId}`
@@ -8027,7 +9014,7 @@ function spanDurationInMillis(span2) {
8027
9014
  * @returns A chalk color function.
8028
9015
  */
8029
9016
  logColor(level) {
8030
- return _XyConsoleSpanExporterImplementation.logLevelToChalkColor[level] ?? logColors.magenta;
9017
+ return _XyConsoleSpanExporterImplementation.logLevelToChalkColor[level] ?? logColors$1.magenta;
8031
9018
  }
8032
9019
  shutdown() {
8033
9020
  return Promise.resolve();
@@ -8039,7 +9026,7 @@ function spanDurationInMillis(span2) {
8039
9026
  */
8040
9027
  spanLevel(span2) {
8041
9028
  let logLevel = 0;
8042
- const duration = spanDurationInMillis(span2);
9029
+ const duration = spanDurationInMillis$1(span2);
8043
9030
  for (let x = _XyConsoleSpanExporterImplementation.durationToLogLevel.length - 1; x >= 0; x--) if (duration > _XyConsoleSpanExporterImplementation.durationToLogLevel[x]) {
8044
9031
  logLevel = x;
8045
9032
  break;
@@ -8048,7 +9035,7 @@ function spanDurationInMillis(span2) {
8048
9035
  }
8049
9036
  });
8050
9037
  //#endregion
8051
- //#region ../../node_modules/.pnpm/@ariestools+sdk@8.1.9_@opentelemetry+api@1.9.1_zod@4.4.3/node_modules/@ariestools/sdk/dist/node/index.mjs
9038
+ //#region ../../node_modules/.pnpm/@ariestools+sdk@8.2.0_@opentelemetry+api@1.9.1_zod@4.5.1/node_modules/@ariestools/sdk/dist/node/index.mjs
8052
9039
  var __defProp$1 = Object.defineProperty;
8053
9040
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
8054
9041
  var __decorateClass$1 = (decorators, target, key, kind) => {
@@ -8197,12 +9184,119 @@ async function fetchCompress(url, options = {}) {
8197
9184
  });
8198
9185
  }
8199
9186
  }
8200
- async function parseJsonResponse(response, context = {}) {
9187
+ function validateMaxResponseBytes(maxResponseBytes) {
9188
+ if (maxResponseBytes !== void 0 && (!Number.isSafeInteger(maxResponseBytes) || maxResponseBytes <= 0)) throw new RangeError("maxResponseBytes must be a positive safe integer");
9189
+ }
9190
+ function abortError(signal) {
9191
+ const reason = signal.reason;
9192
+ let isTimeout = false;
9193
+ try {
9194
+ isTimeout = typeof reason === "object" && reason !== null && "name" in reason && reason.name === "TimeoutError" || classifyFetchError(reason).type === "timeout";
9195
+ } catch {}
9196
+ return new FetchError("Response body read was aborted", {
9197
+ type: isTimeout ? "timeout" : "aborted",
9198
+ cause: reason
9199
+ });
9200
+ }
9201
+ function readChunk(reader, signal) {
9202
+ if (signal == null) return reader.read();
9203
+ return new Promise((resolve, reject) => {
9204
+ let settled = false;
9205
+ const finish = (outcome) => {
9206
+ if (settled) return;
9207
+ settled = true;
9208
+ signal.removeEventListener("abort", onAbort);
9209
+ if ("error" in outcome) reject(toFetchError(outcome.error));
9210
+ else resolve(outcome.value);
9211
+ };
9212
+ const onAbort = () => finish({ error: abortError(signal) });
9213
+ signal.addEventListener("abort", onAbort, { once: true });
9214
+ if (signal.aborted) {
9215
+ onAbort();
9216
+ return;
9217
+ }
9218
+ try {
9219
+ reader.read().then((value) => signal.aborted ? onAbort() : finish({ value })).catch((error) => finish({ error }));
9220
+ } catch (error) {
9221
+ finish({ error });
9222
+ }
9223
+ });
9224
+ }
9225
+ function cancelReader(reader, reason) {
9226
+ try {
9227
+ reader.cancel(reason).catch(() => {});
9228
+ } catch {}
9229
+ }
9230
+ async function readStreamText(reader, maxResponseBytes, signal, response) {
9231
+ const decoder = new TextDecoder();
9232
+ const parts = [];
9233
+ let bytes = 0;
9234
+ let completed = false;
9235
+ let failure;
9236
+ try {
9237
+ while (true) {
9238
+ const result = await readChunk(reader, signal);
9239
+ if (signal?.aborted === true) throw abortError(signal);
9240
+ if (result.done) {
9241
+ parts.push(decoder.decode());
9242
+ completed = true;
9243
+ return parts.join("");
9244
+ }
9245
+ const chunk = result.value;
9246
+ if (!ArrayBuffer.isView(chunk) || Object.prototype.toString.call(chunk) !== "[object Uint8Array]") throw new TypeError("Response body chunks must be Uint8Array values");
9247
+ if (maxResponseBytes !== void 0) {
9248
+ if (chunk.byteLength > maxResponseBytes - bytes) throw new FetchError("Response body exceeds maxResponseBytes", {
9249
+ type: "response-too-large",
9250
+ status: response.status,
9251
+ statusText: response.statusText
9252
+ });
9253
+ bytes += chunk.byteLength;
9254
+ }
9255
+ const text = decoder.decode(chunk, { stream: true });
9256
+ if (text !== "") parts.push(text);
9257
+ }
9258
+ } catch (error) {
9259
+ failure = error;
9260
+ throw error;
9261
+ } finally {
9262
+ if (!completed) cancelReader(reader, failure);
9263
+ reader.releaseLock();
9264
+ }
9265
+ }
9266
+ async function readResponseText(response, options = {}) {
9267
+ const { maxResponseBytes, signal } = options;
9268
+ validateMaxResponseBytes(maxResponseBytes);
9269
+ if (maxResponseBytes === void 0 && signal == null) return await response.text();
9270
+ if (response.bodyUsed) throw new TypeError("Response body has already been consumed");
9271
+ const body = response.body;
9272
+ if (body === null) {
9273
+ if (signal?.aborted === true) throw abortError(signal);
9274
+ return "";
9275
+ }
9276
+ return await readStreamText(body.getReader(), maxResponseBytes, signal, response);
9277
+ }
9278
+ function contextualizeReadError(error, context, options) {
9279
+ const failure = toFetchError(error, context);
9280
+ if (options.maxResponseBytes === void 0 && options.signal == null) return failure;
9281
+ if ((failure.url !== void 0 || context.url === void 0) && (failure.method !== void 0 || context.method === void 0)) return failure;
9282
+ return new FetchError(failure.message, {
9283
+ body: failure.body,
9284
+ cause: failure.cause,
9285
+ code: failure.code,
9286
+ method: failure.method ?? context.method,
9287
+ response: failure.response,
9288
+ status: failure.status,
9289
+ statusText: failure.statusText,
9290
+ type: failure.type,
9291
+ url: failure.url ?? context.url
9292
+ });
9293
+ }
9294
+ async function parseJsonResponse(response, context = {}, options = {}) {
8201
9295
  let text;
8202
9296
  try {
8203
- text = await response.text();
9297
+ text = await readResponseText(response, options);
8204
9298
  } catch (error) {
8205
- throw toFetchError(error, context);
9299
+ throw contextualizeReadError(error, context, options);
8206
9300
  }
8207
9301
  if (text.trim() === "") return null;
8208
9302
  try {
@@ -8219,15 +9313,51 @@ async function parseJsonResponse(response, context = {}) {
8219
9313
  });
8220
9314
  }
8221
9315
  }
8222
- async function tryParseJson(response) {
9316
+ async function tryParseJson(response, options = {}, context = {}) {
9317
+ let text;
8223
9318
  try {
8224
- const text = await response.text();
8225
- if (text.trim() === "") return null;
8226
- return JSON.parse(text);
9319
+ text = await readResponseText(response, options);
9320
+ } catch (error) {
9321
+ if (options.maxResponseBytes !== void 0 || options.signal != null) throw contextualizeReadError(error, context, options);
9322
+ return null;
9323
+ }
9324
+ try {
9325
+ return text.trim() === "" ? null : JSON.parse(text);
8227
9326
  } catch {
8228
9327
  return null;
8229
9328
  }
8230
9329
  }
9330
+ function noop() {}
9331
+ function requestSignal(signal, timeout) {
9332
+ if (timeout === void 0 || timeout === 0) return {
9333
+ signal,
9334
+ close: noop
9335
+ };
9336
+ const timeoutSignal = AbortSignal.timeout(timeout);
9337
+ if (signal == null) return {
9338
+ signal: timeoutSignal,
9339
+ close: noop
9340
+ };
9341
+ const controller = new AbortController();
9342
+ const close = () => {
9343
+ signal.removeEventListener("abort", onCallerAbort);
9344
+ timeoutSignal.removeEventListener("abort", onTimeout);
9345
+ };
9346
+ const abort = (source) => {
9347
+ if (!controller.signal.aborted) controller.abort(source.reason);
9348
+ close();
9349
+ };
9350
+ const onCallerAbort = () => abort(signal);
9351
+ const onTimeout = () => abort(timeoutSignal);
9352
+ signal.addEventListener("abort", onCallerAbort, { once: true });
9353
+ timeoutSignal.addEventListener("abort", onTimeout, { once: true });
9354
+ if (signal.aborted) onCallerAbort();
9355
+ else if (timeoutSignal.aborted) onTimeout();
9356
+ return {
9357
+ signal: controller.signal,
9358
+ close
9359
+ };
9360
+ }
8231
9361
  var FetchClientError = class extends FetchError {
8232
9362
  /** Effective request configuration, including the resolved request URL. */
8233
9363
  config;
@@ -8328,32 +9458,45 @@ var FetchClient = class _FetchClient {
8328
9458
  ...config
8329
9459
  };
8330
9460
  const url = buildURL(merged);
8331
- const { baseURL: _baseURL, data: requestData, headers, method = "GET", params: _params, signal, timeout, url: _url, validateStatus: validateStatusOption, ...requestInit } = merged;
8332
- const init = {
8333
- ...requestInit,
8334
- method,
8335
- headers: buildHeaders(headers, requestData !== void 0),
8336
- signal: timeout !== void 0 && timeout !== 0 ? AbortSignal.timeout(timeout) : signal
8337
- };
8338
- if (requestData !== void 0) init.body = JSON.stringify(requestData);
8339
- const response = await fetchCompress(url, init);
8340
- const result = {
8341
- data: response.ok ? await parseJsonResponse(response, {
8342
- url,
8343
- method
8344
- }) : await tryParseJson(response),
8345
- headers: response.headers,
8346
- response,
8347
- status: response.status,
8348
- statusText: response.statusText
8349
- };
8350
- const validateStatus = validateStatusOption === void 0 ? (s) => s >= 200 && s < 300 : validateStatusOption;
8351
- if (validateStatus && !validateStatus(response.status)) throw new FetchClientError(`Request failed with status ${response.status} ${response.statusText}`, result, {
8352
- ...merged,
8353
- method,
8354
- url
8355
- });
8356
- return result;
9461
+ const { baseURL: _baseURL, data: requestData, headers, maxResponseBytes, method = "GET", params: _params, signal, timeout, url: _url, validateStatus: validateStatusOption, ...requestInit } = merged;
9462
+ validateMaxResponseBytes(maxResponseBytes);
9463
+ const scope = requestSignal(signal, timeout);
9464
+ try {
9465
+ const init = {
9466
+ ...requestInit,
9467
+ method,
9468
+ headers: buildHeaders(headers, requestData !== void 0),
9469
+ signal: scope.signal
9470
+ };
9471
+ if (requestData !== void 0) init.body = JSON.stringify(requestData);
9472
+ const response = await fetchCompress(url, init);
9473
+ const readOptions = {
9474
+ maxResponseBytes,
9475
+ signal: scope.signal
9476
+ };
9477
+ const result = {
9478
+ data: response.ok ? await parseJsonResponse(response, {
9479
+ url,
9480
+ method
9481
+ }, readOptions) : await tryParseJson(response, readOptions, {
9482
+ url,
9483
+ method
9484
+ }),
9485
+ headers: response.headers,
9486
+ response,
9487
+ status: response.status,
9488
+ statusText: response.statusText
9489
+ };
9490
+ const validateStatus = validateStatusOption === void 0 ? (s) => s >= 200 && s < 300 : validateStatusOption;
9491
+ if (validateStatus && !validateStatus(response.status)) throw new FetchClientError(`Request failed with status ${response.status} ${response.statusText}`, result, {
9492
+ ...merged,
9493
+ method,
9494
+ url
9495
+ });
9496
+ return result;
9497
+ } finally {
9498
+ scope.close();
9499
+ }
8357
9500
  }
8358
9501
  };
8359
9502
  new class _FetchJsonClient extends FetchClient {
@@ -9489,7 +10632,92 @@ var JsonValueZod = /* @__PURE__ */ _lazy(() => /* @__PURE__ */ union([
9489
10632
  ]));
9490
10633
  globalThis.crypto?.subtle;
9491
10634
  //#endregion
9492
- //#region ../../node_modules/.pnpm/@ariestools+actor@1.3.0_@ariestools+sdk@8.1.9_@opentelemetry+api@1.9.1_zod@4.4.3__@opentelemetry+api@1.9.1_zod@4.4.3/node_modules/@ariestools/actor/dist/neutral/index.mjs
10635
+ //#region ../../node_modules/.pnpm/@ariestools+telemetry@8.1.9_@opentelemetry+api@1.9.1/node_modules/@ariestools/telemetry/dist/neutral/index.mjs
10636
+ var color = (open, close = 39) => {
10637
+ return (value) => `\x1B[${open}m${value}\x1B[${close}m`;
10638
+ };
10639
+ var logColors = {
10640
+ green: color(32),
10641
+ grey: color(90),
10642
+ magenta: color(35),
10643
+ red: color(31),
10644
+ white: color(37),
10645
+ yellow: color(33)
10646
+ };
10647
+ function spanDurationInMillis(span2) {
10648
+ return span2.duration[0] * 1e3 + span2.duration[1] / 1e6;
10649
+ }
10650
+ (class _XyConsoleSpanExporterImplementation {
10651
+ /** Duration thresholds (in ms) that map to increasing log levels. */
10652
+ static durationToLogLevel = [
10653
+ 0,
10654
+ 1,
10655
+ 10,
10656
+ 100,
10657
+ 1e3
10658
+ ];
10659
+ /** Chalk color functions corresponding to each log level. */
10660
+ static logLevelToChalkColor = [
10661
+ logColors.grey,
10662
+ logColors.white,
10663
+ logColors.green,
10664
+ logColors.yellow,
10665
+ logColors.red
10666
+ ];
10667
+ logger;
10668
+ _logLevel;
10669
+ constructor(logLevel = 0, logger = console) {
10670
+ this._logLevel = logLevel;
10671
+ this.logger = logger;
10672
+ }
10673
+ /** The minimum log level required for a span to be exported. */
10674
+ get logLevel() {
10675
+ return this._logLevel;
10676
+ }
10677
+ export(spans, resultCallback) {
10678
+ for (const span2 of spans) {
10679
+ const spanLevel = this.spanLevel(span2);
10680
+ if (spanLevel < this.logLevel) continue;
10681
+ const duration = spanDurationInMillis(span2);
10682
+ this.logger.log(logColors.grey([
10683
+ `Span [${span2.name}]`,
10684
+ this.logColor(spanLevel)(`${duration}ms`),
10685
+ `TraceId: ${span2.spanContext().traceId}`
10686
+ ].join(", ")));
10687
+ }
10688
+ resultCallback?.({ code: 0 });
10689
+ }
10690
+ forceFlush() {
10691
+ return Promise.resolve();
10692
+ }
10693
+ /**
10694
+ * Returns the chalk color function for the given log level.
10695
+ * @param level - The log level index.
10696
+ * @returns A chalk color function.
10697
+ */
10698
+ logColor(level) {
10699
+ return _XyConsoleSpanExporterImplementation.logLevelToChalkColor[level] ?? logColors.magenta;
10700
+ }
10701
+ shutdown() {
10702
+ return Promise.resolve();
10703
+ }
10704
+ /**
10705
+ * Determines the log level of a span based on its duration.
10706
+ * @param span - The span to evaluate.
10707
+ * @returns The numeric log level (index into durationToLogLevel).
10708
+ */
10709
+ spanLevel(span2) {
10710
+ let logLevel = 0;
10711
+ const duration = spanDurationInMillis(span2);
10712
+ for (let x = _XyConsoleSpanExporterImplementation.durationToLogLevel.length - 1; x >= 0; x--) if (duration > _XyConsoleSpanExporterImplementation.durationToLogLevel[x]) {
10713
+ logLevel = x;
10714
+ break;
10715
+ }
10716
+ return logLevel;
10717
+ }
10718
+ });
10719
+ //#endregion
10720
+ //#region ../../node_modules/.pnpm/@ariestools+actor@1.3.0_@ariestools+sdk@8.2.0_@opentelemetry+api@1.9.1_zod@4.5.1__@opentelemetry+api@1.9.1_zod@4.5.1/node_modules/@ariestools/actor/dist/neutral/index.mjs
9493
10721
  var __defProp = Object.defineProperty;
9494
10722
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9495
10723
  var __decorateClass = (decorators, target, key, kind) => {
@@ -9742,7 +10970,7 @@ ${err.stack}` : "";
9742
10970
  return String(err);
9743
10971
  }
9744
10972
  //#endregion
9745
- //#region ../../node_modules/.pnpm/@ariestools+actor-system@1.3.0_@ariestools+sdk@8.1.9_@opentelemetry+api@1.9.1_zod@4.4.3_99589d3d6b11ec18e4a82403e89fc88c/node_modules/@ariestools/actor-system/dist/neutral/index.mjs
10973
+ //#region ../../node_modules/.pnpm/@ariestools+actor-system@1.3.0_@ariestools+sdk@8.2.0_@opentelemetry+api@1.9.1_zod@4.5.1_752b528cb5f988af784c74b301fa6850/node_modules/@ariestools/actor-system/dist/neutral/index.mjs
9746
10974
  var ActorSystemSelectionZod = strictObject({
9747
10975
  config: unknown().optional(),
9748
10976
  host: string$1().min(1).optional(),
@@ -9763,7 +10991,7 @@ var ActorSystemSelectionZod = strictObject({
9763
10991
  });
9764
10992
  ProviderConfigFieldsZod.extend({ actors: array$1(ActorSystemSelectionZod).default([]) });
9765
10993
  //#endregion
9766
- //#region ../../node_modules/.pnpm/@ariestools+cli-kit@1.2.3_@ariestools+actor-model@1.3.0_@ariestools+sdk@8.1.9_@opentele_37d14ccaa0e676b5af069d15cfccb615/node_modules/@ariestools/cli-kit/dist/node/index.mjs
10994
+ //#region ../../node_modules/.pnpm/@ariestools+cli-kit@1.2.3_@ariestools+actor-model@1.3.0_@ariestools+sdk@8.2.0_@opentele_5e4f1ac05713d1b486b4dc63d7c48617/node_modules/@ariestools/cli-kit/dist/node/index.mjs
9767
10995
  async function runServiceUntilInterrupt(host, stop) {
9768
10996
  await new Promise((resolve, reject) => {
9769
10997
  const dispose = host.onInterrupt(async () => {
@@ -9778,7 +11006,7 @@ async function runServiceUntilInterrupt(host, stop) {
9778
11006
  });
9779
11007
  }
9780
11008
  //#endregion
9781
- //#region ../../node_modules/.pnpm/@ariestools+cli-kit-node@1.2.3_@ariestools+actor-model@1.3.0_@ariestools+sdk@8.1.9_@ope_f0f84665a1b2bbb14be202b1673ab94b/node_modules/@ariestools/cli-kit-node/dist/node/index.mjs
11009
+ //#region ../../node_modules/.pnpm/@ariestools+cli-kit-node@1.2.3_@ariestools+actor-model@1.3.0_@ariestools+sdk@8.2.0_@ope_d8f4f361a702e5d537d1687709db0882/node_modules/@ariestools/cli-kit-node/dist/node/index.mjs
9782
11010
  function resolveEnvironmentValue(key, layers) {
9783
11011
  for (const layer of layers) {
9784
11012
  if (!Object.hasOwn(layer, key)) continue;