@mastra/slack 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -350,82 +350,34 @@ function buildManifest(options) {
350
350
  return manifest;
351
351
  }
352
352
  //#endregion
353
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/core.js
354
- var _a$1;
355
- function $constructor(name, initializer, params) {
356
- function init(inst, def) {
357
- if (!inst._zod) Object.defineProperty(inst, "_zod", {
358
- value: {
359
- def,
360
- constr: _,
361
- traits: /* @__PURE__ */ new Set()
362
- },
363
- enumerable: false
364
- });
365
- if (inst._zod.traits.has(name)) return;
366
- inst._zod.traits.add(name);
367
- initializer(inst, def);
368
- const proto = _.prototype;
369
- const keys = Object.keys(proto);
370
- for (let i = 0; i < keys.length; i++) {
371
- const k = keys[i];
372
- if (!(k in inst)) inst[k] = proto[k].bind(inst);
373
- }
374
- }
375
- const Parent = params?.Parent ?? Object;
376
- class Definition extends Parent {}
377
- Object.defineProperty(Definition, "name", { value: name });
378
- function _(def) {
379
- var _a;
380
- const inst = params?.Parent ? new Definition() : this;
381
- init(inst, def);
382
- (_a = inst._zod).deferred ?? (_a.deferred = []);
383
- for (const fn of inst._zod.deferred) fn();
384
- return inst;
385
- }
386
- Object.defineProperty(_, "init", { value: init });
387
- Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
388
- if (params?.Parent && inst instanceof params.Parent) return true;
389
- return inst?._zod?.traits?.has(name);
390
- } });
391
- Object.defineProperty(_, "name", { value: name });
392
- return _;
393
- }
394
- var $ZodAsyncError = class extends Error {
395
- constructor() {
396
- super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
397
- }
398
- };
399
- var $ZodEncodeError = class extends Error {
400
- constructor(name) {
401
- super(`Encountered unidirectional transform during encode: ${name}`);
402
- this.name = "ZodEncodeError";
403
- }
404
- };
405
- (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
406
- const globalConfig = globalThis.__zod_globalConfig;
407
- function config(newConfig) {
408
- if (newConfig) Object.assign(globalConfig, newConfig);
409
- return globalConfig;
410
- }
411
- //#endregion
412
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/util.js
353
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/util.js
413
354
  function getEnumValues(entries) {
414
355
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
415
356
  return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
416
357
  }
358
+ function joinValues(array, separator = "|") {
359
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
360
+ }
417
361
  function jsonStringifyReplacer(_, value) {
418
362
  if (typeof value === "bigint") return value.toString();
419
363
  return value;
420
364
  }
421
- function cached(getter) {
422
- return { get value() {
423
- {
424
- const value = getter();
425
- Object.defineProperty(this, "value", { value });
426
- return value;
365
+ var Cached = class {
366
+ constructor(getter) {
367
+ this._getter = getter;
368
+ this._value = void 0;
369
+ }
370
+ get value() {
371
+ const getter = this._getter;
372
+ if (getter !== void 0) {
373
+ this._value = getter();
374
+ this._getter = void 0;
427
375
  }
428
- } };
376
+ return this._value;
377
+ }
378
+ };
379
+ function cached(getter) {
380
+ return new Cached(getter);
429
381
  }
430
382
  function nullish(input) {
431
383
  return input === null || input === void 0;
@@ -435,24 +387,6 @@ function cleanRegex(source) {
435
387
  const end = source.endsWith("$") ? source.length - 1 : source.length;
436
388
  return source.slice(start, end);
437
389
  }
438
- const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
439
- function defineLazy(object, key, getter) {
440
- let value = void 0;
441
- Object.defineProperty(object, key, {
442
- get() {
443
- if (value === EVALUATING) return;
444
- if (value === void 0) {
445
- value = EVALUATING;
446
- value = getter();
447
- }
448
- return value;
449
- },
450
- set(v) {
451
- Object.defineProperty(object, key, { value: v });
452
- },
453
- configurable: true
454
- });
455
- }
456
390
  function assignProp(target, prop, value) {
457
391
  Object.defineProperty(target, prop, {
458
392
  value,
@@ -461,6 +395,58 @@ function assignProp(target, prop, value) {
461
395
  configurable: true
462
396
  });
463
397
  }
398
+ /**
399
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
400
+ *
401
+ * Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
402
+ */
403
+ function rawShape(def) {
404
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
405
+ return desc?.get ? desc.get.raw : desc?.value;
406
+ }
407
+ function sourceShape(schema) {
408
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
409
+ }
410
+ function deferProp(target, key, getter) {
411
+ Object.defineProperty(target, key, {
412
+ get() {
413
+ const value = getter();
414
+ assignProp(this, key, value);
415
+ return value;
416
+ },
417
+ enumerable: true,
418
+ configurable: true
419
+ });
420
+ }
421
+ function putProp(target, key, value) {
422
+ if (key in target) assignProp(target, key, value);
423
+ else target[key] = value;
424
+ }
425
+ /**
426
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
427
+ *
428
+ * A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
429
+ */
430
+ function mirrorShape(target, source, keys, wrap) {
431
+ const raw = sourceShape(source);
432
+ for (const key of keys) {
433
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
434
+ if (!desc.enumerable) continue;
435
+ if (desc.get) deferProp(target, key, () => {
436
+ const value = source._zod.def.shape[key];
437
+ return wrap ? wrap(value, key) : value;
438
+ });
439
+ else putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
440
+ }
441
+ }
442
+ function mirrorProps(target, source) {
443
+ for (const key of Reflect.ownKeys(source)) {
444
+ const desc = Object.getOwnPropertyDescriptor(source, key);
445
+ if (!desc.enumerable) continue;
446
+ if (desc.get) deferProp(target, key, () => source[key]);
447
+ else putProp(target, key, desc.value);
448
+ }
449
+ }
464
450
  function mergeDefs(...defs) {
465
451
  const mergedDescriptors = {};
466
452
  for (const def of defs) {
@@ -534,45 +520,56 @@ function normalizeParams(_params) {
534
520
  };
535
521
  return params;
536
522
  }
523
+ function stringifyPrimitive(value) {
524
+ if (typeof value === "bigint") return value.toString() + "n";
525
+ if (typeof value === "string") return `"${value}"`;
526
+ return `${value}`;
527
+ }
537
528
  function optionalKeys(shape) {
538
529
  return Object.keys(shape).filter((k) => {
539
- return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
530
+ return shape[k]._zod.optin !== void 0 && shape[k]._zod.optout === "optional";
540
531
  });
541
532
  }
542
- Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, -Number.MAX_VALUE, Number.MAX_VALUE;
533
+ const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
534
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
535
+ int32: [-2147483648, 2147483647],
536
+ uint32: [0, 4294967295],
537
+ float32: [-34028234663852886e22, 34028234663852886e22],
538
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
539
+ }))();
540
+ const BIGINT_FORMAT_RANGES = {
541
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
542
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
543
+ };
543
544
  function pick(schema, mask) {
544
545
  const currDef = schema._zod.def;
545
546
  const checks = currDef.checks;
546
547
  if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
547
- return clone(schema, mergeDefs(schema._zod.def, {
548
- get shape() {
549
- const newShape = {};
550
- for (const key in mask) {
551
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
552
- if (!mask[key]) continue;
553
- newShape[key] = currDef.shape[key];
554
- }
555
- assignProp(this, "shape", newShape);
556
- return newShape;
557
- },
548
+ const newShape = {};
549
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
550
+ return clone(schema, mergeDefs(currDef, {
551
+ shape: newShape,
558
552
  checks: []
559
553
  }));
560
554
  }
555
+ function maskedKeys(schema, mask) {
556
+ const raw = sourceShape(schema);
557
+ const keys = [];
558
+ for (const key of Reflect.ownKeys(mask)) {
559
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) throw new Error(`Unrecognized key: "${String(key)}"`);
560
+ if (mask[key]) keys.push(key);
561
+ }
562
+ return keys;
563
+ }
561
564
  function omit(schema, mask) {
562
565
  const currDef = schema._zod.def;
563
566
  const checks = currDef.checks;
564
567
  if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
565
- return clone(schema, mergeDefs(schema._zod.def, {
566
- get shape() {
567
- const newShape = { ...schema._zod.def.shape };
568
- for (const key in mask) {
569
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
570
- if (!mask[key]) continue;
571
- delete newShape[key];
572
- }
573
- assignProp(this, "shape", newShape);
574
- return newShape;
575
- },
568
+ const omitted = new Set(maskedKeys(schema, mask));
569
+ const newShape = {};
570
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
571
+ return clone(schema, mergeDefs(currDef, {
572
+ shape: newShape,
576
573
  checks: []
577
574
  }));
578
575
  }
@@ -580,90 +577,57 @@ function extend(schema, shape) {
580
577
  if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
581
578
  const checks = schema._zod.def.checks;
582
579
  if (checks && checks.length > 0) {
583
- const existingShape = schema._zod.def.shape;
584
- 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.");
580
+ const existingShape = sourceShape(schema);
581
+ 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.");
585
582
  }
586
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
587
- const _shape = {
588
- ...schema._zod.def.shape,
589
- ...shape
590
- };
591
- assignProp(this, "shape", _shape);
592
- return _shape;
593
- } }));
583
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
584
+ }
585
+ function extended(schema, shape) {
586
+ const newShape = {};
587
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
588
+ mirrorProps(newShape, shape);
589
+ return newShape;
594
590
  }
595
591
  function safeExtend(schema, shape) {
596
592
  if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
597
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
598
- const _shape = {
599
- ...schema._zod.def.shape,
600
- ...shape
601
- };
602
- assignProp(this, "shape", _shape);
603
- return _shape;
604
- } }));
593
+ return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
605
594
  }
606
595
  function merge(a, b) {
596
+ if (!b?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
607
597
  if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
598
+ const newShape = {};
599
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
600
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
608
601
  return clone(a, mergeDefs(a._zod.def, {
609
- get shape() {
610
- const _shape = {
611
- ...a._zod.def.shape,
612
- ...b._zod.def.shape
613
- };
614
- assignProp(this, "shape", _shape);
615
- return _shape;
616
- },
602
+ shape: newShape,
617
603
  get catchall() {
618
604
  return b._zod.def.catchall;
619
605
  },
620
606
  checks: b._zod.def.checks ?? []
621
607
  }));
622
608
  }
623
- function partial(Class, schema, mask) {
609
+ function partial(Class, schema, mask, name = "partial") {
624
610
  const checks = schema._zod.def.checks;
625
- if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
611
+ if (checks && checks.length > 0) throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
612
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
613
+ const newShape = {};
614
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class && ((value, key) => selected && !selected.has(key) ? value : new Class({
615
+ type: "optional",
616
+ innerType: value
617
+ })));
626
618
  return clone(schema, mergeDefs(schema._zod.def, {
627
- get shape() {
628
- const oldShape = schema._zod.def.shape;
629
- const shape = { ...oldShape };
630
- if (mask) for (const key in mask) {
631
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
632
- if (!mask[key]) continue;
633
- shape[key] = Class ? new Class({
634
- type: "optional",
635
- innerType: oldShape[key]
636
- }) : oldShape[key];
637
- }
638
- else for (const key in oldShape) shape[key] = Class ? new Class({
639
- type: "optional",
640
- innerType: oldShape[key]
641
- }) : oldShape[key];
642
- assignProp(this, "shape", shape);
643
- return shape;
644
- },
619
+ shape: newShape,
645
620
  checks: []
646
621
  }));
647
622
  }
648
623
  function required(Class, schema, mask) {
649
- return clone(schema, mergeDefs(schema._zod.def, { get shape() {
650
- const oldShape = schema._zod.def.shape;
651
- const shape = { ...oldShape };
652
- if (mask) for (const key in mask) {
653
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
654
- if (!mask[key]) continue;
655
- shape[key] = new Class({
656
- type: "nonoptional",
657
- innerType: oldShape[key]
658
- });
659
- }
660
- else for (const key in oldShape) shape[key] = new Class({
661
- type: "nonoptional",
662
- innerType: oldShape[key]
663
- });
664
- assignProp(this, "shape", shape);
665
- return shape;
666
- } }));
624
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : void 0;
625
+ const newShape = {};
626
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) => selected && !selected.has(key) ? value : new Class({
627
+ type: "nonoptional",
628
+ innerType: value
629
+ }));
630
+ return clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
667
631
  }
668
632
  function aborted(x, startIndex = 0) {
669
633
  if (x.aborted === true) return true;
@@ -686,19 +650,56 @@ function prefixIssues(path, issues) {
686
650
  function unwrapMessage(message) {
687
651
  return typeof message === "string" ? message : message?.message;
688
652
  }
653
+ function attachSchema(issues, start, inst) {
654
+ var _a;
655
+ for (let i = start; i < issues.length; i++) (_a = issues[i]).schema ?? (_a.schema = inst);
656
+ }
689
657
  function finalizeIssue(iss, ctx, config) {
690
- 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";
691
- const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
692
- rest.path ?? (rest.path = []);
693
- rest.message = message;
694
- if (ctx?.reportInput) rest.input = _input;
695
- return rest;
658
+ var _a;
659
+ const traits = iss.inst?._zod?.traits;
660
+ if (traits?.has("$ZodType")) if (traits.has("$ZodCheck")) (_a = iss).schema ?? (_a.schema = iss.inst);
661
+ else iss.schema = iss.inst;
662
+ const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
663
+ 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";
664
+ const full = {};
665
+ for (const k of Object.keys(iss)) {
666
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__") continue;
667
+ full[k] = iss[k];
668
+ }
669
+ full.path ?? (full.path = []);
670
+ full.message = message;
671
+ if (ctx?.reportInput) full.input = iss.input;
672
+ return full;
673
+ }
674
+ const highSurrogate = /[\uD800-\uDBFF]/;
675
+ function codePointLength(str) {
676
+ const units = str.length;
677
+ if (!highSurrogate.test(str)) return units;
678
+ let count = units;
679
+ for (let i = 0; i < units - 1; i++) if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
680
+ count--;
681
+ i++;
682
+ }
683
+ return count;
696
684
  }
697
685
  function getLengthableOrigin(input) {
698
686
  if (Array.isArray(input)) return "array";
699
687
  if (typeof input === "string") return "string";
700
688
  return "unknown";
701
689
  }
690
+ function parsedType(data) {
691
+ const t = typeof data;
692
+ switch (t) {
693
+ case "number": return Number.isNaN(data) ? "nan" : "number";
694
+ case "object": {
695
+ if (data === null) return "null";
696
+ if (Array.isArray(data)) return "array";
697
+ const obj = data;
698
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) return obj.constructor.name;
699
+ }
700
+ }
701
+ return t;
702
+ }
702
703
  function issue(...args) {
703
704
  const [iss, input, inst] = args;
704
705
  if (typeof iss === "string") return {
@@ -709,33 +710,337 @@ function issue(...args) {
709
710
  };
710
711
  return { ...iss };
711
712
  }
712
- //#endregion
713
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/errors.js
714
- const initializer$1 = (inst, def) => {
715
- inst.name = "$ZodError";
716
- Object.defineProperty(inst, "_zod", {
717
- value: inst._zod,
718
- enumerable: false
713
+ /**
714
+ * 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.
715
+ *
716
+ * Call this from a `proto` initializer, which runs once per prototype — never per instance.
717
+ */
718
+ function members(proto, table) {
719
+ for (const key in table) {
720
+ const desc = Object.getOwnPropertyDescriptor(table, key);
721
+ if (desc.get) Object.defineProperty(proto, key, {
722
+ ...desc,
723
+ enumerable: false
724
+ });
725
+ else defineBound(proto, key, desc.value);
726
+ }
727
+ }
728
+ /** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
729
+ function own(inst, key, value, enumerable = true) {
730
+ Object.defineProperty(inst, key, {
731
+ configurable: true,
732
+ writable: true,
733
+ enumerable,
734
+ value
735
+ });
736
+ return value;
737
+ }
738
+ /** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
739
+ function hide(inst, key, value) {
740
+ return own(inst, key, value, false);
741
+ }
742
+ /** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
743
+ function derived(computes, table) {
744
+ for (const key in computes) {
745
+ const compute = computes[key];
746
+ Object.defineProperty(table, key, {
747
+ configurable: true,
748
+ enumerable: true,
749
+ get() {
750
+ return own(this, key, compute(this));
751
+ },
752
+ set(value) {
753
+ own(this, key, value);
754
+ }
755
+ });
756
+ }
757
+ return table;
758
+ }
759
+ function defineBound(proto, key, fn) {
760
+ Object.defineProperty(proto, key, {
761
+ configurable: true,
762
+ get() {
763
+ return this == null ? fn : own(this, key, fn.bind(this));
764
+ },
765
+ set(value) {
766
+ own(this, key, value);
767
+ }
719
768
  });
720
- Object.defineProperty(inst, "issues", {
721
- value: def,
722
- enumerable: false
769
+ }
770
+ /** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
771
+ function claim(inst, sentinel) {
772
+ const proto = Object.getPrototypeOf(inst);
773
+ return sentinel in proto ? void 0 : proto;
774
+ }
775
+ let installing;
776
+ let broke = false;
777
+ const breaker = {
778
+ configurable: true,
779
+ get() {
780
+ broke = true;
781
+ }
782
+ };
783
+ /**
784
+ * Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
785
+ * constructor, computed from the internals object itself and cached there on
786
+ * first read. One accessor per constructor rather than one per instance.
787
+ */
788
+ function defineLazyInternal(inst, key, compute) {
789
+ const proto = Object.getPrototypeOf(inst._zod);
790
+ if (key in proto && installing !== inst._zod) {
791
+ installing = void 0;
792
+ return;
793
+ }
794
+ installing = inst._zod;
795
+ Object.defineProperty(proto, key, {
796
+ configurable: true,
797
+ get() {
798
+ Object.defineProperty(this, key, breaker);
799
+ const outer = broke;
800
+ broke = false;
801
+ try {
802
+ const value = compute(this);
803
+ if (broke) delete this[key];
804
+ else Object.defineProperty(this, key, {
805
+ configurable: true,
806
+ writable: true,
807
+ value
808
+ });
809
+ broke = broke || outer;
810
+ return value;
811
+ } catch (err) {
812
+ delete this[key];
813
+ broke = broke || outer;
814
+ throw err;
815
+ }
816
+ },
817
+ set(value) {
818
+ Object.defineProperty(this, key, {
819
+ configurable: true,
820
+ writable: true,
821
+ value
822
+ });
823
+ }
723
824
  });
724
- inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
725
- Object.defineProperty(inst, "toString", {
726
- value: () => inst.message,
727
- enumerable: false
825
+ }
826
+ /**
827
+ * Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
828
+ * data property. One accessor per constructor rather than one per instance, because an own accessor
829
+ * puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
830
+ */
831
+ function installLazyProp(inst, key, make, enumerable) {
832
+ const proto = claim(inst, key);
833
+ if (!proto) return;
834
+ Object.defineProperty(proto, key, {
835
+ configurable: true,
836
+ get() {
837
+ const desc = {
838
+ configurable: true,
839
+ writable: true,
840
+ enumerable,
841
+ value: void 0
842
+ };
843
+ Object.defineProperty(this, key, desc);
844
+ desc.value = make(this);
845
+ Object.defineProperty(this, key, desc);
846
+ return desc.value;
847
+ },
848
+ set(value) {
849
+ Object.defineProperty(this, key, {
850
+ configurable: true,
851
+ writable: true,
852
+ enumerable,
853
+ value
854
+ });
855
+ }
728
856
  });
857
+ }
858
+ /** 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. */
859
+ const CONSTANT_CATCH = "~constantCatch";
860
+ /** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
861
+ function constantCatch(value) {
862
+ const fn = () => value;
863
+ fn[CONSTANT_CATCH] = true;
864
+ return fn;
865
+ }
866
+ //#endregion
867
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/core.js
868
+ var _a$1;
869
+ const _zodDesc = {
870
+ value: void 0,
871
+ enumerable: false
872
+ };
873
+ let _E = "captureStackTrace" in Error ? Error : null;
874
+ function newError(Definition) {
875
+ const E = _E;
876
+ if (E) {
877
+ const saved = E.stackTraceLimit;
878
+ if (typeof saved === "number") {
879
+ try {
880
+ E.stackTraceLimit = 0;
881
+ } catch {
882
+ _E = null;
883
+ return new Definition();
884
+ }
885
+ try {
886
+ return new Definition();
887
+ } finally {
888
+ E.stackTraceLimit = saved;
889
+ }
890
+ }
891
+ }
892
+ return new Definition();
893
+ }
894
+ function $constructor(name, initializer, proto, params) {
895
+ const zodProto = {};
896
+ function Internals(def) {
897
+ this.def = def;
898
+ this.constr = _;
899
+ this.traits = /* @__PURE__ */ new Set();
900
+ }
901
+ Internals.prototype = zodProto;
902
+ const protoMembers = proto;
903
+ const initialized = protoMembers && /* @__PURE__ */ new WeakSet();
904
+ function init(inst, def) {
905
+ if (!inst._zod) {
906
+ _zodDesc.value = new Internals(def);
907
+ try {
908
+ Object.defineProperty(inst, "_zod", _zodDesc);
909
+ } finally {
910
+ _zodDesc.value = void 0;
911
+ }
912
+ } else if (inst._zod.traits.has(name)) return;
913
+ inst._zod.traits.add(name);
914
+ initializer(inst, def);
915
+ if (initialized) {
916
+ const own = Object.getPrototypeOf(inst);
917
+ const ctorProto = inst._zod.constr.prototype;
918
+ let up = own;
919
+ while (up && up !== ctorProto) up = Object.getPrototypeOf(up);
920
+ const target = up ?? own;
921
+ if (!initialized.has(target)) {
922
+ initialized.add(target);
923
+ members(target, protoMembers);
924
+ }
925
+ }
926
+ const proto = _.prototype;
927
+ for (const k in proto) {
928
+ if (!Object.prototype.hasOwnProperty.call(proto, k)) continue;
929
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
930
+ }
931
+ }
932
+ const Parent = params?.Parent ?? Object;
933
+ class Definition extends Parent {}
934
+ Object.defineProperty(Definition, "name", { value: name });
935
+ function _(def) {
936
+ const inst = params?.Parent ? newError(Definition) : this;
937
+ init(inst, def);
938
+ const deferred = inst._zod.deferred;
939
+ if (deferred) {
940
+ for (const fn of deferred) fn();
941
+ inst._zod.deferred = void 0;
942
+ }
943
+ const pp = globalThis.__zod_globalConfig?.postProcessor;
944
+ if (pp) pp(inst);
945
+ return inst;
946
+ }
947
+ Object.defineProperty(_, "init", { value: init });
948
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
949
+ if (params?.Parent && inst instanceof params.Parent) return true;
950
+ return inst?._zod?.traits?.has(name);
951
+ } });
952
+ Object.defineProperty(_, "name", { value: name });
953
+ return _;
954
+ }
955
+ var $ZodAsyncError = class extends Error {
956
+ constructor() {
957
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
958
+ }
959
+ };
960
+ var $ZodEncodeError = class extends Error {
961
+ constructor(name) {
962
+ super(`Encountered unidirectional transform during encode: ${name}`);
963
+ this.name = "ZodEncodeError";
964
+ }
965
+ };
966
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
967
+ const globalConfig = globalThis.__zod_globalConfig;
968
+ function config(newConfig) {
969
+ if (newConfig) Object.assign(globalConfig, newConfig);
970
+ return globalConfig;
971
+ }
972
+ //#endregion
973
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/errors.js
974
+ function _getMessage() {
975
+ const internals = this._zod;
976
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
977
+ return internals.message;
978
+ }
979
+ function _setMessage(value) {
980
+ this._zod.message = value;
981
+ }
982
+ const _messageDesc = {
983
+ get: _getMessage,
984
+ set: _setMessage,
985
+ enumerable: true,
986
+ configurable: true
987
+ };
988
+ const _issuesDesc = {
989
+ value: void 0,
990
+ enumerable: false
991
+ };
992
+ const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
993
+ const initializer$1 = (inst, def) => {
994
+ inst.name = "$ZodError";
995
+ _issuesDesc.value = def;
996
+ Object.defineProperty(inst, "issues", _issuesDesc);
997
+ _issuesDesc.value = void 0;
998
+ Object.defineProperty(inst, "message", _messageDesc);
999
+ const proto = Object.getPrototypeOf(inst);
1000
+ if (!_installedToString.has(proto)) {
1001
+ _installedToString.add(proto);
1002
+ Object.defineProperty(proto, "toString", {
1003
+ configurable: true,
1004
+ enumerable: false,
1005
+ get() {
1006
+ const value = () => this.message;
1007
+ Object.defineProperty(this, "toString", {
1008
+ value,
1009
+ configurable: true,
1010
+ writable: true
1011
+ });
1012
+ return value;
1013
+ },
1014
+ set(value) {
1015
+ Object.defineProperty(this, "toString", {
1016
+ value,
1017
+ configurable: true,
1018
+ writable: true
1019
+ });
1020
+ }
1021
+ });
1022
+ }
729
1023
  };
730
1024
  const $ZodError = $constructor("$ZodError", initializer$1);
731
- const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
1025
+ $constructor("$ZodError", initializer$1, void 0, { Parent: Error });
1026
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
1027
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
1028
+ * "__proto__" would hit the setter instead of creating a key. */
1029
+ function node(obj, key, make) {
1030
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) if (key === "__proto__") Object.defineProperty(obj, key, {
1031
+ value: make(),
1032
+ writable: true,
1033
+ enumerable: true,
1034
+ configurable: true
1035
+ });
1036
+ else obj[key] = make();
1037
+ return obj[key];
1038
+ }
732
1039
  function flattenError(error, mapper = (issue) => issue.message) {
733
1040
  const fieldErrors = {};
734
1041
  const formErrors = [];
735
- for (const sub of error.issues) if (sub.path.length > 0) {
736
- fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
737
- fieldErrors[sub.path[0]].push(mapper(sub));
738
- } else formErrors.push(mapper(sub));
1042
+ for (const sub of error.issues) if (sub.path.length > 0) node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
1043
+ else formErrors.push(mapper(sub));
739
1044
  return {
740
1045
  formErrors,
741
1046
  fieldErrors
@@ -755,12 +1060,21 @@ function formatError(error, mapper = (issue) => issue.message) {
755
1060
  let i = 0;
756
1061
  while (i < fullpath.length) {
757
1062
  const el = fullpath[i];
758
- if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
759
- else {
760
- curr[el] = curr[el] || { _errors: [] };
761
- curr[el]._errors.push(mapper(issue));
1063
+ const terminal = i === fullpath.length - 1;
1064
+ if (el === "_errors") {
1065
+ if (terminal) curr._errors.push(mapper(issue));
1066
+ i++;
1067
+ continue;
762
1068
  }
763
- curr = curr[el];
1069
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) Object.defineProperty(curr, el, {
1070
+ value: { _errors: [] },
1071
+ enumerable: true,
1072
+ writable: true,
1073
+ configurable: true
1074
+ });
1075
+ const node = curr[el];
1076
+ if (terminal) node._errors.push(mapper(issue));
1077
+ curr = node;
764
1078
  i++;
765
1079
  }
766
1080
  }
@@ -770,8 +1084,54 @@ function formatError(error, mapper = (issue) => issue.message) {
770
1084
  return fieldErrors;
771
1085
  }
772
1086
  //#endregion
773
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/parse.js
774
- const _parse = (_Err) => (schema, value, _ctx, _params) => {
1087
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/parse.js
1088
+ function finalizeParams(callee, params) {
1089
+ return {
1090
+ callee: params?.callee ?? callee,
1091
+ Err: params?.Err
1092
+ };
1093
+ }
1094
+ const _parse = (_Err) => {
1095
+ const fn = (schema, value, _ctx, _params) => {
1096
+ const ctx = _ctx ? {
1097
+ ..._ctx,
1098
+ async: false
1099
+ } : { async: false };
1100
+ const result = schema._zod.run({
1101
+ value,
1102
+ issues: []
1103
+ }, ctx);
1104
+ if (result instanceof Promise) throw new $ZodAsyncError();
1105
+ if (result.issues.length) {
1106
+ const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1107
+ captureStackTrace(e, _params?.callee ?? fn);
1108
+ throw e;
1109
+ }
1110
+ return result.value;
1111
+ };
1112
+ return fn;
1113
+ };
1114
+ const _parseAsync = (_Err) => {
1115
+ const fn = async (schema, value, _ctx, params) => {
1116
+ const ctx = _ctx ? {
1117
+ ..._ctx,
1118
+ async: true
1119
+ } : { async: true };
1120
+ let result = schema._zod.run({
1121
+ value,
1122
+ issues: []
1123
+ }, ctx);
1124
+ if (result instanceof Promise) result = await result;
1125
+ if (result.issues.length) {
1126
+ const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
1127
+ captureStackTrace(e, params?.callee ?? fn);
1128
+ throw e;
1129
+ }
1130
+ return result.value;
1131
+ };
1132
+ return fn;
1133
+ };
1134
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
775
1135
  const ctx = _ctx ? {
776
1136
  ..._ctx,
777
1137
  async: false
@@ -781,14 +1141,31 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
781
1141
  issues: []
782
1142
  }, ctx);
783
1143
  if (result instanceof Promise) throw new $ZodAsyncError();
784
- if (result.issues.length) {
785
- const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
786
- captureStackTrace(e, _params?.callee);
787
- throw e;
788
- }
789
- return result.value;
1144
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
1145
+ success: true,
1146
+ data: result.value
1147
+ };
790
1148
  };
791
- const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
1149
+ function failure(Err, issues, ctx) {
1150
+ let error;
1151
+ return {
1152
+ success: false,
1153
+ get error() {
1154
+ if (!error) {
1155
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
1156
+ issues = void 0;
1157
+ ctx = void 0;
1158
+ }
1159
+ return error;
1160
+ },
1161
+ set error(e) {
1162
+ error = e;
1163
+ issues = void 0;
1164
+ ctx = void 0;
1165
+ }
1166
+ };
1167
+ }
1168
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
792
1169
  const ctx = _ctx ? {
793
1170
  ..._ctx,
794
1171
  async: true
@@ -798,70 +1175,96 @@ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
798
1175
  issues: []
799
1176
  }, ctx);
800
1177
  if (result instanceof Promise) result = await result;
801
- if (result.issues.length) {
802
- const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
803
- captureStackTrace(e, params?.callee);
804
- throw e;
805
- }
806
- return result.value;
1178
+ return result.issues.length ? failure(_Err, result.issues, ctx) : {
1179
+ success: true,
1180
+ data: result.value
1181
+ };
807
1182
  };
808
- const _safeParse = (_Err) => (schema, value, _ctx) => {
1183
+ const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
1184
+ const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
1185
+ const validate = ((schema, value, _ctx) => {
1186
+ const validator = schema._zod.bag.validator;
1187
+ if (validator !== void 0) {
1188
+ if (validator(value) !== COMPILE_INVALID) return true;
1189
+ if (validator.definite === true && _ctx === void 0) return false;
1190
+ }
1191
+ return validateFallback(schema, value, _ctx);
1192
+ });
1193
+ function validateFallback(schema, value, _ctx) {
809
1194
  const ctx = _ctx ? {
810
1195
  ..._ctx,
811
- async: false
812
- } : { async: false };
813
- const result = schema._zod.run({
1196
+ async: false,
1197
+ abortEarly: true
1198
+ } : {
1199
+ async: false,
1200
+ abortEarly: true
1201
+ };
1202
+ const fallbackRun = schema._zod.bag.fallbackRun;
1203
+ let result;
1204
+ if (fallbackRun) {
1205
+ ctx[COMPILE_FALLBACK] = true;
1206
+ result = fallbackRun({
1207
+ value,
1208
+ issues: []
1209
+ }, ctx);
1210
+ } else result = schema._zod.run({
814
1211
  value,
815
1212
  issues: []
816
1213
  }, ctx);
817
1214
  if (result instanceof Promise) throw new $ZodAsyncError();
818
- return result.issues.length ? {
819
- success: false,
820
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
821
- } : {
822
- success: true,
823
- data: result.value
824
- };
825
- };
826
- const safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
827
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
1215
+ return result.issues.length === 0;
1216
+ }
1217
+ const validateAsync$1 = async (schema, value, _ctx) => {
828
1218
  const ctx = _ctx ? {
829
1219
  ..._ctx,
830
- async: true
831
- } : { async: true };
1220
+ async: true,
1221
+ abortEarly: true
1222
+ } : {
1223
+ async: true,
1224
+ abortEarly: true
1225
+ };
832
1226
  let result = schema._zod.run({
833
1227
  value,
834
1228
  issues: []
835
1229
  }, ctx);
836
1230
  if (result instanceof Promise) result = await result;
837
- return result.issues.length ? {
838
- success: false,
839
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
840
- } : {
841
- success: true,
842
- data: result.value
843
- };
1231
+ return result.issues.length === 0;
844
1232
  };
845
- const safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
846
- const _encode = (_Err) => (schema, value, _ctx) => {
847
- const ctx = _ctx ? {
848
- ..._ctx,
849
- direction: "backward"
850
- } : { direction: "backward" };
851
- return _parse(_Err)(schema, value, ctx);
1233
+ const _encode = (_Err) => {
1234
+ const parse = _parse(_Err);
1235
+ const fn = (schema, value, _ctx, _params) => {
1236
+ const ctx = _ctx ? {
1237
+ ..._ctx,
1238
+ direction: "backward"
1239
+ } : { direction: "backward" };
1240
+ return parse(schema, value, ctx, finalizeParams(fn, _params));
1241
+ };
1242
+ return fn;
852
1243
  };
853
- const _decode = (_Err) => (schema, value, _ctx) => {
854
- return _parse(_Err)(schema, value, _ctx);
1244
+ const _decode = (_Err) => {
1245
+ const parse = _parse(_Err);
1246
+ const fn = (schema, value, _ctx, _params) => {
1247
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
1248
+ };
1249
+ return fn;
855
1250
  };
856
- const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
857
- const ctx = _ctx ? {
858
- ..._ctx,
859
- direction: "backward"
860
- } : { direction: "backward" };
861
- return _parseAsync(_Err)(schema, value, ctx);
1251
+ const _encodeAsync = (_Err) => {
1252
+ const parseAsync = _parseAsync(_Err);
1253
+ const fn = async (schema, value, _ctx, _params) => {
1254
+ const ctx = _ctx ? {
1255
+ ..._ctx,
1256
+ direction: "backward"
1257
+ } : { direction: "backward" };
1258
+ return await parseAsync(schema, value, ctx, finalizeParams(fn, _params));
1259
+ };
1260
+ return fn;
862
1261
  };
863
- const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
864
- return _parseAsync(_Err)(schema, value, _ctx);
1262
+ const _decodeAsync = (_Err) => {
1263
+ const parseAsync = _parseAsync(_Err);
1264
+ const fn = async (schema, value, _ctx, _params) => {
1265
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
1266
+ };
1267
+ return fn;
865
1268
  };
866
1269
  const _safeEncode = (_Err) => (schema, value, _ctx) => {
867
1270
  const ctx = _ctx ? {
@@ -884,7 +1287,7 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
884
1287
  return _safeParseAsync(_Err)(schema, value, _ctx);
885
1288
  };
886
1289
  //#endregion
887
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/regexes.js
1290
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/regexes.js
888
1291
  /**
889
1292
  * @deprecated CUID v1 is deprecated by its authors due to information leakage
890
1293
  * (timestamps embedded in the id). Use {@link cuid2} instead.
@@ -892,12 +1295,15 @@ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
892
1295
  */
893
1296
  const cuid = /^[cC][0-9a-z]{6,}$/;
894
1297
  const cuid2 = /^[0-9a-z]+$/;
895
- const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
1298
+ const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
896
1299
  const xid = /^[0-9a-vA-V]{20}$/;
897
1300
  const ksuid = /^[A-Za-z0-9]{27}$/;
898
1301
  const nanoid = /^[a-zA-Z0-9_-]{21}$/;
1302
+ function nanoidOfLength(length) {
1303
+ return new RegExp(`^[a-zA-Z0-9_-]{${length}}$`);
1304
+ }
899
1305
  /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
900
- 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)?)?)$/;
1306
+ const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
901
1307
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
902
1308
  const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
903
1309
  /** Returns a regex for validating an RFC 9562/4122 UUID.
@@ -908,64 +1314,68 @@ const uuid = (version) => {
908
1314
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
909
1315
  };
910
1316
  /** Practical email validation */
911
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
912
- const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1317
+ const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
1318
+ const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
913
1319
  function emoji() {
914
1320
  return new RegExp(_emoji$1, "u");
915
1321
  }
916
1322
  const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
917
1323
  const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
918
1324
  const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
919
- const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
1325
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
920
1326
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
921
- const base64url = /^[A-Za-z0-9_-]*$/;
1327
+ const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
922
1328
  const httpProtocol = /^https?$/;
923
1329
  const e164 = /^\+[1-9]\d{6,14}$/;
924
1330
  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])))`;
925
- const date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
1331
+ /** Anchors a pattern source. The interpolation lives here rather than at the call site because
1332
+ * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
1333
+ * will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
1334
+ function anchor(source) {
1335
+ return new RegExp(`^${source}$`);
1336
+ }
1337
+ const date = /*@__PURE__*/ anchor(dateSource);
926
1338
  function timeSource(args) {
927
1339
  const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
928
- 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+)?)?`;
1340
+ 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+)?)?`;
929
1341
  }
930
- function time$1(args) {
1342
+ function time(args) {
931
1343
  return new RegExp(`^${timeSource(args)}$`);
932
1344
  }
933
- function datetime$1(args) {
934
- const time = timeSource({ precision: args.precision });
1345
+ function datetime(args) {
935
1346
  const opts = ["Z"];
936
- if (args.local) opts.push("");
937
1347
  if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
938
- const timeRegex = `${time}(?:${opts.join("|")})`;
1348
+ const qualified = `${timeSource({
1349
+ precision: args.precision,
1350
+ seconds: true
1351
+ })}(?:${opts.join("|")})`;
1352
+ const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
939
1353
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
940
1354
  }
941
- const string$1 = (params) => {
942
- const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
943
- return new RegExp(`^${regex}$`);
944
- };
1355
+ const anyString = /^[\s\S]{0,}$/;
945
1356
  const lowercase = /^[^A-Z]*$/;
946
1357
  const uppercase = /^[^a-z]*$/;
947
1358
  //#endregion
948
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/checks.js
1359
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/checks.js
949
1360
  const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
950
1361
  var _a;
951
1362
  inst._zod ?? (inst._zod = {});
952
1363
  inst._zod.def = def;
953
1364
  (_a = inst._zod).onattach ?? (_a.onattach = []);
954
1365
  });
1366
+ /** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
1367
+ const _whenHasLength = (payload) => {
1368
+ const val = payload.value;
1369
+ return !nullish(val) && val.length !== void 0;
1370
+ };
955
1371
  const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
956
1372
  var _a;
957
1373
  $ZodCheck.init(inst, def);
958
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
959
- const val = payload.value;
960
- return !nullish(val) && val.length !== void 0;
961
- });
962
- inst._zod.onattach.push((inst) => {
963
- const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
964
- if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
965
- });
1374
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
966
1375
  inst._zod.check = (payload) => {
967
1376
  const input = payload.value;
968
- if (input.length <= def.maximum) return;
1377
+ const units = input.length;
1378
+ if ((typeof input === "string" && units > def.maximum ? codePointLength(input) : units) <= def.maximum) return;
969
1379
  const origin = getLengthableOrigin(input);
970
1380
  payload.issues.push({
971
1381
  origin,
@@ -981,17 +1391,11 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
981
1391
  const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
982
1392
  var _a;
983
1393
  $ZodCheck.init(inst, def);
984
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
985
- const val = payload.value;
986
- return !nullish(val) && val.length !== void 0;
987
- });
988
- inst._zod.onattach.push((inst) => {
989
- const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
990
- if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
991
- });
1394
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
992
1395
  inst._zod.check = (payload) => {
993
1396
  const input = payload.value;
994
- if (input.length >= def.minimum) return;
1397
+ const units = input.length;
1398
+ if ((typeof input === "string" && units >= def.minimum && units < def.minimum * 2 ? codePointLength(input) : units) >= def.minimum) return;
995
1399
  const origin = getLengthableOrigin(input);
996
1400
  payload.issues.push({
997
1401
  origin,
@@ -1007,19 +1411,11 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
1007
1411
  const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
1008
1412
  var _a;
1009
1413
  $ZodCheck.init(inst, def);
1010
- (_a = inst._zod.def).when ?? (_a.when = (payload) => {
1011
- const val = payload.value;
1012
- return !nullish(val) && val.length !== void 0;
1013
- });
1014
- inst._zod.onattach.push((inst) => {
1015
- const bag = inst._zod.bag;
1016
- bag.minimum = def.length;
1017
- bag.maximum = def.length;
1018
- bag.length = def.length;
1019
- });
1414
+ (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
1020
1415
  inst._zod.check = (payload) => {
1021
1416
  const input = payload.value;
1022
- 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;
1023
1419
  if (length === def.length) return;
1024
1420
  const origin = getLengthableOrigin(input);
1025
1421
  const tooBig = length > def.length;
@@ -1043,14 +1439,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
1043
1439
  const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
1044
1440
  var _a, _b;
1045
1441
  $ZodCheck.init(inst, def);
1046
- inst._zod.onattach.push((inst) => {
1047
- const bag = inst._zod.bag;
1048
- bag.format = def.format;
1049
- if (def.pattern) {
1050
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1051
- bag.patterns.add(def.pattern);
1052
- }
1053
- });
1054
1442
  if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
1055
1443
  def.pattern.lastIndex = 0;
1056
1444
  if (def.pattern.test(payload.value)) return;
@@ -1093,13 +1481,7 @@ const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (ins
1093
1481
  const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
1094
1482
  $ZodCheck.init(inst, def);
1095
1483
  const escapedRegex = escapeRegex(def.includes);
1096
- const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
1097
- def.pattern = pattern;
1098
- inst._zod.onattach.push((inst) => {
1099
- const bag = inst._zod.bag;
1100
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1101
- bag.patterns.add(pattern);
1102
- });
1484
+ def.pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
1103
1485
  inst._zod.check = (payload) => {
1104
1486
  if (payload.value.includes(def.includes, def.position)) return;
1105
1487
  payload.issues.push({
@@ -1117,11 +1499,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
1117
1499
  $ZodCheck.init(inst, def);
1118
1500
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
1119
1501
  def.pattern ?? (def.pattern = pattern);
1120
- inst._zod.onattach.push((inst) => {
1121
- const bag = inst._zod.bag;
1122
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1123
- bag.patterns.add(pattern);
1124
- });
1125
1502
  inst._zod.check = (payload) => {
1126
1503
  if (payload.value.startsWith(def.prefix)) return;
1127
1504
  payload.issues.push({
@@ -1139,11 +1516,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
1139
1516
  $ZodCheck.init(inst, def);
1140
1517
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
1141
1518
  def.pattern ?? (def.pattern = pattern);
1142
- inst._zod.onattach.push((inst) => {
1143
- const bag = inst._zod.bag;
1144
- bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
1145
- bag.patterns.add(pattern);
1146
- });
1147
1519
  inst._zod.check = (payload) => {
1148
1520
  if (payload.value.endsWith(def.suffix)) return;
1149
1521
  payload.issues.push({
@@ -1164,17 +1536,21 @@ const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (ins
1164
1536
  };
1165
1537
  });
1166
1538
  //#endregion
1167
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/doc.js
1539
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/doc.js
1168
1540
  var Doc = class {
1169
- constructor(args = []) {
1541
+ constructor(args = [], closed = {}) {
1170
1542
  this.content = [];
1171
1543
  this.indent = 0;
1172
- if (this) this.args = args;
1544
+ this.args = args;
1545
+ this.closed = closed;
1173
1546
  }
1174
1547
  indented(fn) {
1175
1548
  this.indent += 1;
1176
- fn(this);
1177
- this.indent -= 1;
1549
+ try {
1550
+ fn(this);
1551
+ } finally {
1552
+ this.indent -= 1;
1553
+ }
1178
1554
  }
1179
1555
  write(arg) {
1180
1556
  if (typeof arg === "function") {
@@ -1189,28 +1565,27 @@ var Doc = class {
1189
1565
  }
1190
1566
  compile() {
1191
1567
  const F = Function;
1192
- const args = this?.args;
1193
- const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1194
- return new F(...args, lines.join("\n"));
1568
+ const content = this?.content ?? [``];
1569
+ return new F(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${content.join("\n")}\n};`)(...Object.values(this.closed));
1195
1570
  }
1196
1571
  };
1197
1572
  //#endregion
1198
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/versions.js
1573
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/versions.js
1199
1574
  const version = {
1200
1575
  major: 4,
1201
- minor: 4,
1202
- patch: 3
1576
+ minor: 6,
1577
+ patch: 5
1203
1578
  };
1204
1579
  //#endregion
1205
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/schemas.js
1580
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/schemas.js
1206
1581
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1207
1582
  var _a;
1208
1583
  inst ?? (inst = {});
1209
1584
  inst._zod.def = def;
1210
1585
  inst._zod.bag = inst._zod.bag || {};
1211
1586
  inst._zod.version = version;
1212
- const checks = [...inst._zod.def.checks ?? []];
1213
- if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1587
+ const defChecks = inst._zod.def.checks;
1588
+ const checks = inst._zod.traits.has("$ZodCheck") ? [inst, ...defChecks ?? []] : defChecks?.length ? [...defChecks] : [];
1214
1589
  for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1215
1590
  if (checks.length === 0) {
1216
1591
  (_a = inst._zod).deferred ?? (_a.deferred = []);
@@ -1219,6 +1594,7 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1219
1594
  });
1220
1595
  } else {
1221
1596
  const runChecks = (payload, checks, ctx) => {
1597
+ if (payload.memo) return payload;
1222
1598
  let isAborted = aborted(payload);
1223
1599
  let asyncResult;
1224
1600
  for (const ch of checks) {
@@ -1232,10 +1608,12 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1232
1608
  if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1233
1609
  await _;
1234
1610
  if (payload.issues.length === currLen) return;
1611
+ attachSchema(payload.issues, currLen, inst);
1235
1612
  if (!isAborted) isAborted = aborted(payload, currLen);
1236
1613
  });
1237
1614
  else {
1238
1615
  if (payload.issues.length === currLen) continue;
1616
+ attachSchema(payload.issues, currLen, inst);
1239
1617
  if (!isAborted) isAborted = aborted(payload, currLen);
1240
1618
  }
1241
1619
  }
@@ -1279,22 +1657,43 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1279
1657
  return runChecks(result, checks, ctx);
1280
1658
  };
1281
1659
  }
1282
- defineLazy(inst, "~standard", () => ({
1660
+ }, {
1661
+ get "~standard"() {
1662
+ return hide(this, "~standard", standardProps(this));
1663
+ },
1664
+ set "~standard"(value) {
1665
+ own(this, "~standard", value);
1666
+ }
1667
+ });
1668
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
1669
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config())) } : { value: r.value };
1670
+ async function validateAsync(inst, value) {
1671
+ const ctx = { async: true };
1672
+ return toStandardResult(await inst._zod.run({
1673
+ value,
1674
+ issues: []
1675
+ }, ctx), ctx);
1676
+ }
1677
+ function standardProps(inst) {
1678
+ return {
1283
1679
  validate: (value) => {
1680
+ const ctx = { async: false };
1284
1681
  try {
1285
- const r = safeParse$1(inst, value);
1286
- return r.success ? { value: r.data } : { issues: r.error?.issues };
1287
- } catch (_) {
1288
- return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1289
- }
1682
+ const r = inst._zod.run({
1683
+ value,
1684
+ issues: []
1685
+ }, ctx);
1686
+ if (!(r instanceof Promise)) return toStandardResult(r, ctx);
1687
+ } catch (_) {}
1688
+ return validateAsync(inst, value);
1290
1689
  },
1291
1690
  vendor: "zod",
1292
1691
  version: 1
1293
- }));
1294
- });
1692
+ };
1693
+ }
1295
1694
  const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1296
1695
  $ZodType.init(inst, def);
1297
- inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1696
+ inst._zod.pattern = def.pattern ?? anyString;
1298
1697
  inst._zod.parse = (payload, _) => {
1299
1698
  if (def.coerce) try {
1300
1699
  payload.value = String(payload.value);
@@ -1338,51 +1737,95 @@ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1338
1737
  def.pattern ?? (def.pattern = email);
1339
1738
  $ZodStringFormat.init(inst, def);
1340
1739
  });
1740
+ function canParseURL(input) {
1741
+ try {
1742
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(input);
1743
+ new URL(input);
1744
+ return true;
1745
+ } catch {
1746
+ return false;
1747
+ }
1748
+ }
1749
+ function validateURL(trimmed, def) {
1750
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) return canParseURL(trimmed) || 2;
1751
+ return parseURLObject(trimmed, def);
1752
+ }
1753
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
1754
+ function parseURLObject(trimmed, def) {
1755
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) return 1;
1756
+ try {
1757
+ if (typeof URL !== "undefined") {
1758
+ const URLStatic = URL;
1759
+ if (typeof URLStatic.parse === "function") return URLStatic.parse(trimmed) ?? 2;
1760
+ }
1761
+ return new URL(trimmed);
1762
+ } catch {
1763
+ return 2;
1764
+ }
1765
+ }
1766
+ const asciiTabOrNewline = /[\t\n\r]/g;
1767
+ /** 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. */
1768
+ function stripTabAndNewline(value) {
1769
+ return value.replace(asciiTabOrNewline, "");
1770
+ }
1771
+ function urlHostnameOk(url, hostname) {
1772
+ hostname.lastIndex = 0;
1773
+ return hostname.test(url.hostname);
1774
+ }
1775
+ function urlProtocolOk(url, protocol) {
1776
+ protocol.lastIndex = 0;
1777
+ return protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol);
1778
+ }
1341
1779
  const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1342
1780
  $ZodStringFormat.init(inst, def);
1343
1781
  inst._zod.check = (payload) => {
1344
1782
  try {
1345
1783
  const trimmed = payload.value.trim();
1346
- if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1347
- if (!/^https?:\/\//i.test(trimmed)) {
1348
- payload.issues.push({
1349
- code: "invalid_format",
1350
- format: "url",
1351
- note: "Invalid URL format",
1352
- input: payload.value,
1353
- inst,
1354
- continue: !def.abort
1355
- });
1356
- return;
1357
- }
1358
- }
1359
- const url = new URL(trimmed);
1360
- if (def.hostname) {
1361
- def.hostname.lastIndex = 0;
1362
- if (!def.hostname.test(url.hostname)) payload.issues.push({
1784
+ const url = validateURL(trimmed, def);
1785
+ if (url === 1) {
1786
+ payload.issues.push({
1363
1787
  code: "invalid_format",
1364
1788
  format: "url",
1365
- note: "Invalid hostname",
1366
- pattern: def.hostname.source,
1789
+ note: "Invalid URL format",
1367
1790
  input: payload.value,
1368
1791
  inst,
1369
1792
  continue: !def.abort
1370
1793
  });
1794
+ return;
1371
1795
  }
1372
- if (def.protocol) {
1373
- def.protocol.lastIndex = 0;
1374
- if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1796
+ if (url === 2) {
1797
+ payload.issues.push({
1375
1798
  code: "invalid_format",
1376
1799
  format: "url",
1377
- note: "Invalid protocol",
1378
- pattern: def.protocol.source,
1379
1800
  input: payload.value,
1380
1801
  inst,
1381
1802
  continue: !def.abort
1382
1803
  });
1804
+ return;
1383
1805
  }
1384
- if (def.normalize) payload.value = url.href;
1385
- else payload.value = trimmed;
1806
+ if (url === true) {
1807
+ payload.value = stripTabAndNewline(trimmed);
1808
+ return;
1809
+ }
1810
+ if (def.hostname && !urlHostnameOk(url, def.hostname)) payload.issues.push({
1811
+ code: "invalid_format",
1812
+ format: "url",
1813
+ note: "Invalid hostname",
1814
+ pattern: def.hostname.source,
1815
+ input: payload.value,
1816
+ inst,
1817
+ continue: !def.abort
1818
+ });
1819
+ if (def.protocol && !urlProtocolOk(url, def.protocol)) payload.issues.push({
1820
+ code: "invalid_format",
1821
+ format: "url",
1822
+ note: "Invalid protocol",
1823
+ pattern: def.protocol.source,
1824
+ input: payload.value,
1825
+ inst,
1826
+ continue: !def.abort
1827
+ });
1828
+ payload.value = def.normalize ? url.href : stripTabAndNewline(trimmed);
1386
1829
  return;
1387
1830
  } catch (_) {
1388
1831
  payload.issues.push({
@@ -1400,7 +1843,8 @@ const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1400
1843
  $ZodStringFormat.init(inst, def);
1401
1844
  });
1402
1845
  const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1403
- def.pattern ?? (def.pattern = nanoid);
1846
+ if (def.length !== void 0 && (!Number.isInteger(def.length) || def.length < 1)) throw new Error(`Invalid nanoid length: ${def.length}`);
1847
+ def.pattern ?? (def.pattern = def.length === void 0 ? nanoid : nanoidOfLength(def.length));
1404
1848
  $ZodStringFormat.init(inst, def);
1405
1849
  });
1406
1850
  /**
@@ -1429,70 +1873,69 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1429
1873
  $ZodStringFormat.init(inst, def);
1430
1874
  });
1431
1875
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1432
- def.pattern ?? (def.pattern = datetime$1(def));
1876
+ def.pattern ?? (def.pattern = datetime(def));
1433
1877
  $ZodStringFormat.init(inst, def);
1434
1878
  });
1435
1879
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1436
- def.pattern ?? (def.pattern = date$1);
1880
+ def.pattern ?? (def.pattern = date);
1437
1881
  $ZodStringFormat.init(inst, def);
1438
1882
  });
1439
1883
  const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1440
- def.pattern ?? (def.pattern = time$1(def));
1884
+ def.pattern ?? (def.pattern = time(def));
1441
1885
  $ZodStringFormat.init(inst, def);
1442
1886
  });
1443
1887
  const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1444
- def.pattern ?? (def.pattern = duration$1);
1888
+ def.pattern ?? (def.pattern = duration);
1445
1889
  $ZodStringFormat.init(inst, def);
1446
1890
  });
1447
1891
  const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1448
1892
  def.pattern ?? (def.pattern = ipv4);
1449
1893
  $ZodStringFormat.init(inst, def);
1450
- inst._zod.bag.format = `ipv4`;
1451
1894
  });
1895
+ /** 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`. */
1896
+ const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
1897
+ function isValidIPv6(value) {
1898
+ if (!ipv6Alphabet.test(value)) return false;
1899
+ return canParseURL(`http://[${value}]`);
1900
+ }
1452
1901
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1453
1902
  def.pattern ?? (def.pattern = ipv6);
1454
1903
  $ZodStringFormat.init(inst, def);
1455
- inst._zod.bag.format = `ipv6`;
1456
1904
  inst._zod.check = (payload) => {
1457
- try {
1458
- new URL(`http://[${payload.value}]`);
1459
- } catch {
1460
- payload.issues.push({
1461
- code: "invalid_format",
1462
- format: "ipv6",
1463
- input: payload.value,
1464
- inst,
1465
- continue: !def.abort
1466
- });
1467
- }
1905
+ if (!isValidIPv6(payload.value)) payload.issues.push({
1906
+ code: "invalid_format",
1907
+ format: "ipv6",
1908
+ input: payload.value,
1909
+ inst,
1910
+ continue: !def.abort
1911
+ });
1468
1912
  };
1469
1913
  });
1470
1914
  const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1471
1915
  def.pattern ?? (def.pattern = cidrv4);
1472
1916
  $ZodStringFormat.init(inst, def);
1473
1917
  });
1918
+ function isValidCIDRv6(value) {
1919
+ const parts = value.split("/");
1920
+ if (parts.length !== 2) return false;
1921
+ const [address, prefix] = parts;
1922
+ if (!prefix) return false;
1923
+ const prefixNum = Number(prefix);
1924
+ if (`${prefixNum}` !== prefix) return false;
1925
+ if (prefixNum < 0 || prefixNum > 128) return false;
1926
+ return isValidIPv6(address);
1927
+ }
1474
1928
  const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1475
1929
  def.pattern ?? (def.pattern = cidrv6);
1476
1930
  $ZodStringFormat.init(inst, def);
1477
1931
  inst._zod.check = (payload) => {
1478
- const parts = payload.value.split("/");
1479
- try {
1480
- if (parts.length !== 2) throw new Error();
1481
- const [address, prefix] = parts;
1482
- if (!prefix) throw new Error();
1483
- const prefixNum = Number(prefix);
1484
- if (`${prefixNum}` !== prefix) throw new Error();
1485
- if (prefixNum < 0 || prefixNum > 128) throw new Error();
1486
- new URL(`http://[${address}]`);
1487
- } catch {
1488
- payload.issues.push({
1489
- code: "invalid_format",
1490
- format: "cidrv6",
1491
- input: payload.value,
1492
- inst,
1493
- continue: !def.abort
1494
- });
1495
- }
1932
+ if (!isValidCIDRv6(payload.value)) payload.issues.push({
1933
+ code: "invalid_format",
1934
+ format: "cidrv6",
1935
+ input: payload.value,
1936
+ inst,
1937
+ continue: !def.abort
1938
+ });
1496
1939
  };
1497
1940
  });
1498
1941
  function isValidBase64(data) {
@@ -1506,10 +1949,10 @@ function isValidBase64(data) {
1506
1949
  return false;
1507
1950
  }
1508
1951
  }
1952
+ const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
1509
1953
  const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1510
- def.pattern ?? (def.pattern = base64);
1954
+ def.pattern ?? (def.pattern = base64Charset);
1511
1955
  $ZodStringFormat.init(inst, def);
1512
- inst._zod.bag.contentEncoding = "base64";
1513
1956
  inst._zod.check = (payload) => {
1514
1957
  if (isValidBase64(payload.value)) return;
1515
1958
  payload.issues.push({
@@ -1521,15 +1964,15 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1521
1964
  });
1522
1965
  };
1523
1966
  });
1967
+ const base64urlCharset = /^[A-Za-z0-9_-]*$/;
1524
1968
  function isValidBase64URL(data) {
1525
- if (!base64url.test(data)) return false;
1969
+ if (!base64urlCharset.test(data)) return false;
1526
1970
  const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1527
1971
  return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1528
1972
  }
1529
1973
  const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1530
- def.pattern ?? (def.pattern = base64url);
1974
+ def.pattern ?? (def.pattern = base64urlCharset);
1531
1975
  $ZodStringFormat.init(inst, def);
1532
- inst._zod.bag.contentEncoding = "base64url";
1533
1976
  inst._zod.check = (payload) => {
1534
1977
  if (isValidBase64URL(payload.value)) return;
1535
1978
  payload.issues.push({
@@ -1595,6 +2038,8 @@ function handleArrayResult(result, final, index) {
1595
2038
  }
1596
2039
  const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1597
2040
  $ZodType.init(inst, def);
2041
+ const memo = globalConfig.memoizer;
2042
+ memo?.attach(inst);
1598
2043
  inst._zod.parse = (payload, ctx) => {
1599
2044
  const input = payload.value;
1600
2045
  if (!Array.isArray(input)) {
@@ -1606,8 +2051,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1606
2051
  });
1607
2052
  return payload;
1608
2053
  }
1609
- payload.value = Array(input.length);
2054
+ payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
1610
2055
  const proms = [];
2056
+ const abortEarly = ctx?.abortEarly;
1611
2057
  for (let i = 0; i < input.length; i++) {
1612
2058
  const item = input[i];
1613
2059
  const result = def.element._zod.run({
@@ -1615,19 +2061,24 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1615
2061
  issues: []
1616
2062
  }, ctx);
1617
2063
  if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1618
- else handleArrayResult(result, payload, i);
2064
+ else {
2065
+ handleArrayResult(result, payload, i);
2066
+ if (abortEarly && result.issues.length !== 0 && aborted(result)) break;
2067
+ }
1619
2068
  }
1620
2069
  if (proms.length) return Promise.all(proms).then(() => payload);
1621
2070
  return payload;
1622
2071
  };
1623
2072
  });
1624
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
2073
+ function handlePropertyResult(result, final, key, input, optin, optout) {
1625
2074
  const isPresent = key in input;
2075
+ const isOptionalOut = optout === "optional";
2076
+ if (!isPresent && isOptionalOut && optin === "optional") return;
1626
2077
  if (result.issues.length) {
1627
- if (isOptionalIn && isOptionalOut && !isPresent) return;
2078
+ if (optin !== void 0 && isOptionalOut && !isPresent) return;
1628
2079
  final.issues.push(...prefixIssues(key, result.issues));
1629
2080
  }
1630
- if (!isPresent && !isOptionalIn) {
2081
+ if (!isPresent && optin === void 0) {
1631
2082
  if (!result.issues.length) final.issues.push({
1632
2083
  code: "invalid_type",
1633
2084
  expected: "nonoptional",
@@ -1637,31 +2088,44 @@ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptiona
1637
2088
  return;
1638
2089
  }
1639
2090
  if (result.value === void 0) {
1640
- if (isPresent) final.value[key] = void 0;
2091
+ if (isPresent || optin === "defaulted" && !isOptionalOut) final.value[key] = void 0;
1641
2092
  } else final.value[key] = result.value;
1642
2093
  }
2094
+ const NO_SYMBOL_KEYS = [];
1643
2095
  function normalizeDef(def) {
1644
2096
  const keys = Object.keys(def.shape);
1645
- 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`);
2097
+ const ownSymbols = Object.getOwnPropertySymbols(def.shape);
2098
+ const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
2099
+ const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
2100
+ 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`);
1646
2101
  const okeys = optionalKeys(def.shape);
1647
2102
  return {
1648
2103
  ...def,
1649
- keys,
2104
+ allKeys,
2105
+ symbolKeys,
1650
2106
  keySet: new Set(keys),
1651
2107
  numKeys: keys.length,
1652
2108
  optionalKeys: new Set(okeys)
1653
2109
  };
1654
2110
  }
1655
- function handleCatchall(proms, input, payload, ctx, def, inst) {
2111
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
1656
2112
  const unrecognized = [];
1657
2113
  const keySet = def.keySet;
1658
2114
  const _catchall = def.catchall._zod;
1659
2115
  const t = _catchall.def.type;
1660
- const isOptionalIn = _catchall.optin === "optional";
1661
- const isOptionalOut = _catchall.optout === "optional";
2116
+ const optin = _catchall.optin;
2117
+ const optout = _catchall.optout;
2118
+ let seen = 0;
1662
2119
  for (const key in input) {
1663
- if (key === "__proto__") continue;
2120
+ if (abortEarly && payload.issues.length !== seen) {
2121
+ if (aborted(payload, seen)) break;
2122
+ seen = payload.issues.length;
2123
+ }
1664
2124
  if (keySet.has(key)) continue;
2125
+ if (key === "__proto__") {
2126
+ if (t === "never") unrecognized.push(key);
2127
+ continue;
2128
+ }
1665
2129
  if (t === "never") {
1666
2130
  unrecognized.push(key);
1667
2131
  continue;
@@ -1670,14 +2134,15 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1670
2134
  value: input[key],
1671
2135
  issues: []
1672
2136
  }, ctx);
1673
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1674
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2137
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2138
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1675
2139
  }
1676
2140
  if (unrecognized.length) payload.issues.push({
1677
2141
  code: "unrecognized_keys",
1678
2142
  keys: unrecognized,
1679
2143
  input,
1680
- inst
2144
+ inst,
2145
+ continue: true
1681
2146
  });
1682
2147
  if (!proms.length) return payload;
1683
2148
  return Promise.all(proms).then(() => {
@@ -1686,34 +2151,41 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1686
2151
  }
1687
2152
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1688
2153
  $ZodType.init(inst, def);
1689
- if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1690
- const sh = def.shape;
1691
- Object.defineProperty(def, "shape", { get: () => {
2154
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
2155
+ const sh = desc?.get ? desc.get.raw : def.shape ?? {};
2156
+ if (sh) {
2157
+ const get = () => {
1692
2158
  const newSh = { ...sh };
1693
2159
  Object.defineProperty(def, "shape", { value: newSh });
2160
+ get.raw = newSh;
1694
2161
  return newSh;
1695
- } });
2162
+ };
2163
+ get.raw = sh;
2164
+ Object.defineProperty(def, "shape", { get });
1696
2165
  }
1697
2166
  const _normalized = cached(() => normalizeDef(def));
1698
- defineLazy(inst._zod, "propValues", () => {
1699
- const shape = def.shape;
2167
+ defineLazyInternal(inst, "propValues", (zod) => {
2168
+ const shape = zod.def.shape;
1700
2169
  const propValues = {};
1701
2170
  for (const key in shape) {
1702
2171
  const field = shape[key]._zod;
1703
2172
  if (field.values) {
1704
- propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
2173
+ if (!Object.prototype.hasOwnProperty.call(propValues, key)) assignProp(propValues, key, /* @__PURE__ */ new Set());
1705
2174
  for (const v of field.values) propValues[key].add(v);
2175
+ if (field.optin !== void 0) propValues[key].add(void 0);
1706
2176
  }
1707
2177
  }
1708
2178
  return propValues;
1709
2179
  });
1710
- const isObject$2 = isObject;
2180
+ const isObject$1 = isObject;
1711
2181
  const catchall = def.catchall;
1712
2182
  let value;
2183
+ const memo = globalConfig.memoizer;
2184
+ memo?.attach(inst);
1713
2185
  inst._zod.parse = (payload, ctx) => {
1714
2186
  value ?? (value = _normalized.value);
1715
2187
  const input = payload.value;
1716
- if (!isObject$2(input)) {
2188
+ if (!isObject$1(input)) {
1717
2189
  payload.issues.push({
1718
2190
  expected: "object",
1719
2191
  code: "invalid_type",
@@ -1722,77 +2194,90 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1722
2194
  });
1723
2195
  return payload;
1724
2196
  }
1725
- payload.value = {};
2197
+ payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
1726
2198
  const proms = [];
1727
2199
  const shape = value.shape;
1728
- for (const key of value.keys) {
2200
+ const abortEarly = ctx?.abortEarly;
2201
+ let seen = payload.issues.length;
2202
+ for (const key of value.allKeys) {
2203
+ if (abortEarly && payload.issues.length !== seen) {
2204
+ if (aborted(payload, seen)) break;
2205
+ seen = payload.issues.length;
2206
+ }
2207
+ if (key === "__proto__") continue;
1729
2208
  const el = shape[key];
1730
- const isOptionalIn = el._zod.optin === "optional";
1731
- const isOptionalOut = el._zod.optout === "optional";
2209
+ const optin = el._zod.optin;
2210
+ const optout = el._zod.optout;
1732
2211
  const r = el._zod.run({
1733
2212
  value: input[key],
1734
2213
  issues: []
1735
2214
  }, ctx);
1736
- if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1737
- else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
2215
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, optin, optout)));
2216
+ else handlePropertyResult(r, payload, key, input, optin, optout);
1738
2217
  }
1739
2218
  if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1740
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
2219
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
1741
2220
  };
1742
2221
  });
1743
2222
  const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1744
2223
  $ZodObject.init(inst, def);
1745
2224
  const superParse = inst._zod.parse;
1746
2225
  const _normalized = cached(() => normalizeDef(def));
2226
+ const memo = globalConfig.memoizer;
1747
2227
  const generateFastpass = (shape) => {
1748
- const doc = new Doc([
1749
- "shape",
1750
- "payload",
1751
- "ctx"
1752
- ]);
1753
2228
  const normalized = _normalized.value;
1754
- const parseStr = (key) => {
1755
- const k = esc(key);
1756
- return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1757
- };
2229
+ const syms = normalized.symbolKeys;
2230
+ const doc = new Doc(["payload", "ctx"], {
2231
+ shape,
2232
+ inst,
2233
+ memo,
2234
+ syms
2235
+ });
2236
+ const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
2237
+ const prefixStr = (id, k) => `
2238
+ let ${id}_ab = false;
2239
+ for (let i = 0; i < ${id}.issues.length; i++) {
2240
+ const iss = ${id}.issues[i];
2241
+ iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
2242
+ payload.issues.push(iss);
2243
+ if (iss.continue !== true) ${id}_ab = true;
2244
+ }
2245
+ if (${id}_ab && ctx && ctx.abortEarly) {
2246
+ payload.value = newResult;
2247
+ return payload;
2248
+ }`;
1758
2249
  doc.write(`const input = payload.value;`);
1759
2250
  const ids = Object.create(null);
1760
2251
  let counter = 0;
1761
- for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1762
- doc.write(`const newResult = {};`);
1763
- for (const key of normalized.keys) {
2252
+ for (const key of normalized.allKeys) ids[key] = `key_${counter++}`;
2253
+ doc.write(memo ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
2254
+ for (const key of normalized.allKeys) {
2255
+ if (key === "__proto__") continue;
1764
2256
  const id = ids[key];
1765
- const k = esc(key);
2257
+ const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc(key);
2258
+ const isPresent = `${k} in input`;
1766
2259
  const schema = shape[key];
1767
- const isOptionalIn = schema?._zod?.optin === "optional";
2260
+ const optin = schema?._zod?.optin;
2261
+ const isOptionalIn = optin !== void 0;
1768
2262
  const isOptionalOut = schema?._zod?.optout === "optional";
1769
- doc.write(`const ${id} = ${parseStr(key)};`);
1770
- if (isOptionalIn && isOptionalOut) doc.write(`
1771
- if (${id}.issues.length) {
1772
- if (${k} in input) {
1773
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1774
- ...iss,
1775
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1776
- })));
2263
+ doc.write(`const ${id} = ${parseStr(k)};`);
2264
+ if (isOptionalIn && isOptionalOut) {
2265
+ const assign = optin === "optional" ? `${id}_present` : `${id}.value !== undefined || ${id}_present`;
2266
+ doc.write(`
2267
+ const ${id}_present = ${isPresent};
2268
+ if (!${id}.issues.length || ${id}_present) {
2269
+ if (${id}.issues.length) {${prefixStr(id, k)}
1777
2270
  }
1778
- }
1779
-
1780
- if (${id}.value === undefined) {
1781
- if (${k} in input) {
1782
- newResult[${k}] = undefined;
2271
+
2272
+ if (${assign}) {
2273
+ newResult[${k}] = ${id}.value;
1783
2274
  }
1784
- } else {
1785
- newResult[${k}] = ${id}.value;
1786
2275
  }
1787
-
2276
+
1788
2277
  `);
1789
- else if (!isOptionalIn) doc.write(`
1790
- const ${id}_present = ${k} in input;
1791
- if (${id}.issues.length) {
1792
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1793
- ...iss,
1794
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1795
- })));
2278
+ } else if (!isOptionalIn) doc.write(`
2279
+ const ${id}_present = ${isPresent};
2280
+ if (${id}.issues.length) {${prefixStr(id, k)}
1796
2281
  }
1797
2282
  if (!${id}_present && !${id}.issues.length) {
1798
2283
  payload.issues.push({
@@ -1801,42 +2286,36 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1801
2286
  input: undefined,
1802
2287
  path: [${k}]
1803
2288
  });
2289
+ if (ctx && ctx.abortEarly) {
2290
+ payload.value = newResult;
2291
+ return payload;
2292
+ }
1804
2293
  }
1805
2294
 
1806
2295
  if (${id}_present) {
1807
- if (${id}.value === undefined) {
1808
- newResult[${k}] = undefined;
1809
- } else {
1810
- newResult[${k}] = ${id}.value;
1811
- }
2296
+ newResult[${k}] = ${id}.value;
1812
2297
  }
1813
2298
 
1814
2299
  `);
1815
- else doc.write(`
1816
- if (${id}.issues.length) {
1817
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1818
- ...iss,
1819
- path: iss.path ? [${k}, ...iss.path] : [${k}]
1820
- })));
2300
+ else {
2301
+ doc.write(`
2302
+ if (${id}.issues.length) {${prefixStr(id, k)}
1821
2303
  }
1822
-
1823
- if (${id}.value === undefined) {
1824
- if (${k} in input) {
1825
- newResult[${k}] = undefined;
1826
- }
1827
- } else {
2304
+ `);
2305
+ if (optin === "defaulted") doc.write(`newResult[${k}] = ${id}.value;`);
2306
+ else doc.write(`
2307
+ if (${id}.value !== undefined || ${isPresent}) {
1828
2308
  newResult[${k}] = ${id}.value;
1829
2309
  }
1830
-
1831
2310
  `);
2311
+ }
1832
2312
  }
1833
2313
  doc.write(`payload.value = newResult;`);
1834
2314
  doc.write(`return payload;`);
1835
- const fn = doc.compile();
1836
- return (payload, ctx) => fn(shape, payload, ctx);
2315
+ return doc.compile();
1837
2316
  };
1838
2317
  let fastpass;
1839
- const isObject$1 = isObject;
2318
+ const isObject$2 = isObject;
1840
2319
  const jit = !globalConfig.jitless;
1841
2320
  const fastEnabled = jit && allowsEval.value;
1842
2321
  const catchall = def.catchall;
@@ -1844,7 +2323,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1844
2323
  inst._zod.parse = (payload, ctx) => {
1845
2324
  value ?? (value = _normalized.value);
1846
2325
  const input = payload.value;
1847
- if (!isObject$1(input)) {
2326
+ if (!isObject$2(input)) {
1848
2327
  payload.issues.push({
1849
2328
  expected: "object",
1850
2329
  code: "invalid_type",
@@ -1857,7 +2336,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
1857
2336
  if (!fastpass) fastpass = generateFastpass(def.shape);
1858
2337
  payload = fastpass(payload, ctx);
1859
2338
  if (!catchall) return payload;
1860
- return handleCatchall([], input, payload, ctx, value, inst);
2339
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
1861
2340
  }
1862
2341
  return superParse(payload, ctx);
1863
2342
  };
@@ -1882,14 +2361,14 @@ function handleUnionResults(results, final, inst, ctx) {
1882
2361
  }
1883
2362
  const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1884
2363
  $ZodType.init(inst, def);
1885
- defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1886
- defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1887
- defineLazy(inst._zod, "values", () => {
1888
- if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
2364
+ 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);
2365
+ defineLazyInternal(inst, "optout", (zod) => zod.def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
2366
+ defineLazyInternal(inst, "values", (zod) => {
2367
+ if (zod.def.options.every((o) => o._zod.values)) return new Set(zod.def.options.flatMap((option) => Array.from(option._zod.values)));
1889
2368
  });
1890
- defineLazy(inst._zod, "pattern", () => {
1891
- if (def.options.every((o) => o._zod.pattern)) {
1892
- const patterns = def.options.map((o) => o._zod.pattern);
2369
+ defineLazyInternal(inst, "pattern", (zod) => {
2370
+ if (zod.def.options.every((o) => o._zod.pattern)) {
2371
+ const patterns = zod.def.options.map((o) => o._zod.pattern);
1893
2372
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1894
2373
  }
1895
2374
  });
@@ -1951,7 +2430,9 @@ function mergeValues(a, b) {
1951
2430
  ...a,
1952
2431
  ...b
1953
2432
  };
2433
+ if (Object.prototype.hasOwnProperty.call(newObj, "__proto__")) delete newObj.__proto__;
1954
2434
  for (const key of sharedKeys) {
2435
+ if (key === "__proto__") continue;
1955
2436
  const sharedValue = mergeValues(a[key], b[key]);
1956
2437
  if (!sharedValue.valid) return {
1957
2438
  valid: false,
@@ -1993,26 +2474,39 @@ function mergeValues(a, b) {
1993
2474
  function handleIntersectionResults(result, left, right) {
1994
2475
  const unrecKeys = /* @__PURE__ */ new Map();
1995
2476
  let unrecIssue;
1996
- for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1997
- unrecIssue ?? (unrecIssue = iss);
1998
- for (const k of iss.keys) {
2477
+ const keyIssues = /* @__PURE__ */ new Map();
2478
+ const collect = (iss, side) => {
2479
+ let keys;
2480
+ if (iss.code === "unrecognized_keys" && !iss.path?.length) {
2481
+ unrecIssue ?? (unrecIssue = iss);
2482
+ keys = iss.keys;
2483
+ } else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
2484
+ const k = String(iss.path[0]);
2485
+ if (!keyIssues.has(k)) keyIssues.set(k, iss);
2486
+ keys = [k];
2487
+ } else return false;
2488
+ for (const k of keys) {
1999
2489
  if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2000
- unrecKeys.get(k).l = true;
2490
+ unrecKeys.get(k)[side] = true;
2001
2491
  }
2002
- } else result.issues.push(iss);
2003
- for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
2004
- if (!unrecKeys.has(k)) unrecKeys.set(k, {});
2005
- unrecKeys.get(k).r = true;
2006
- }
2007
- else result.issues.push(iss);
2492
+ return true;
2493
+ };
2494
+ for (const iss of left.issues) if (!collect(iss, "l")) result.issues.push(iss);
2495
+ for (const iss of right.issues) if (!collect(iss, "r")) result.issues.push(iss);
2008
2496
  const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2009
- if (bothKeys.length && unrecIssue) result.issues.push({
2010
- ...unrecIssue,
2011
- keys: bothKeys
2012
- });
2013
- if (aborted(result)) return result;
2497
+ if (bothKeys.length) {
2498
+ const aggregated = unrecIssue ? bothKeys.filter((k) => unrecIssue.keys.includes(k)) : [];
2499
+ if (aggregated.length) result.issues.push({
2500
+ ...unrecIssue,
2501
+ keys: aggregated
2502
+ });
2503
+ for (const k of bothKeys) if (!aggregated.includes(k) && keyIssues.has(k)) result.issues.push(keyIssues.get(k));
2504
+ }
2014
2505
  const merged = mergeValues(left.value, right.value);
2015
- if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2506
+ if (!merged.valid) {
2507
+ if (aborted(result)) return result;
2508
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
2509
+ }
2016
2510
  result.value = merged.data;
2017
2511
  return result;
2018
2512
  }
@@ -2021,7 +2515,10 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2021
2515
  const values = getEnumValues(def.entries);
2022
2516
  const valuesSet = new Set(values);
2023
2517
  inst._zod.values = valuesSet;
2024
- inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
2518
+ defineLazyInternal(inst, "pattern", (zod) => {
2519
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
2520
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
2521
+ });
2025
2522
  inst._zod.parse = (payload, _ctx) => {
2026
2523
  const input = payload.value;
2027
2524
  if (valuesSet.has(input)) return payload;
@@ -2037,67 +2534,66 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
2037
2534
  const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
2038
2535
  $ZodType.init(inst, def);
2039
2536
  inst._zod.optin = "optional";
2537
+ globalConfig.memoizer?.guard(inst);
2040
2538
  inst._zod.parse = (payload, ctx) => {
2041
2539
  if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
2042
2540
  const _out = def.transform(payload.value, payload);
2043
2541
  if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
2044
2542
  payload.value = output;
2045
- payload.fallback = true;
2046
2543
  return payload;
2047
2544
  });
2048
2545
  if (_out instanceof Promise) throw new $ZodAsyncError();
2049
2546
  payload.value = _out;
2050
- payload.fallback = true;
2051
2547
  return payload;
2052
2548
  };
2053
2549
  });
2054
- function handleOptionalResult(result, input) {
2055
- if (input === void 0 && (result.issues.length || result.fallback)) return {
2056
- issues: [],
2057
- value: void 0
2058
- };
2059
- return result;
2550
+ function handleOptionalResult(payload, result) {
2551
+ payload.value = result.issues.length ? void 0 : result.value;
2552
+ return payload;
2060
2553
  }
2061
2554
  const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
2062
2555
  $ZodType.init(inst, def);
2063
- inst._zod.optin = "optional";
2556
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2064
2557
  inst._zod.optout = "optional";
2065
- defineLazy(inst._zod, "values", () => {
2066
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
2558
+ defineLazyInternal(inst, "values", (zod) => {
2559
+ const values = zod.def.innerType._zod.values;
2560
+ return values ? /* @__PURE__ */ new Set([...values, void 0]) : void 0;
2067
2561
  });
2068
- defineLazy(inst._zod, "pattern", () => {
2069
- const pattern = def.innerType._zod.pattern;
2562
+ defineLazyInternal(inst, "pattern", (zod) => {
2563
+ const pattern = zod.def.innerType._zod.pattern;
2070
2564
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
2071
2565
  });
2072
2566
  inst._zod.parse = (payload, ctx) => {
2073
- if (def.innerType._zod.optin === "optional") {
2074
- const input = payload.value;
2075
- const result = def.innerType._zod.run(payload, ctx);
2076
- if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
2077
- return handleOptionalResult(result, input);
2567
+ if (payload.value === void 0) {
2568
+ if (def.innerType._zod.optin !== "defaulted") return payload;
2569
+ const result = def.innerType._zod.run({
2570
+ value: payload.value,
2571
+ issues: []
2572
+ }, ctx);
2573
+ if (result instanceof Promise) return result.then((result) => handleOptionalResult(payload, result));
2574
+ return handleOptionalResult(payload, result);
2078
2575
  }
2079
- if (payload.value === void 0) return payload;
2080
2576
  return def.innerType._zod.run(payload, ctx);
2081
2577
  };
2082
2578
  });
2083
2579
  const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
2084
2580
  $ZodOptional.init(inst, def);
2085
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2086
- defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2581
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2582
+ defineLazyInternal(inst, "pattern", (zod) => zod.def.innerType._zod.pattern);
2087
2583
  inst._zod.parse = (payload, ctx) => {
2088
2584
  return def.innerType._zod.run(payload, ctx);
2089
2585
  };
2090
2586
  });
2091
2587
  const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2092
2588
  $ZodType.init(inst, def);
2093
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2094
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2095
- defineLazy(inst._zod, "pattern", () => {
2096
- const pattern = def.innerType._zod.pattern;
2589
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin);
2590
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2591
+ defineLazyInternal(inst, "pattern", (zod) => {
2592
+ const pattern = zod.def.innerType._zod.pattern;
2097
2593
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2098
2594
  });
2099
- defineLazy(inst._zod, "values", () => {
2100
- return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
2595
+ defineLazyInternal(inst, "values", (zod) => {
2596
+ return zod.def.innerType._zod.values ? /* @__PURE__ */ new Set([...zod.def.innerType._zod.values, null]) : void 0;
2101
2597
  });
2102
2598
  inst._zod.parse = (payload, ctx) => {
2103
2599
  if (payload.value === null) return payload;
@@ -2106,8 +2602,8 @@ const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
2106
2602
  });
2107
2603
  const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2108
2604
  $ZodType.init(inst, def);
2109
- inst._zod.optin = "optional";
2110
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2605
+ inst._zod.optin = "defaulted";
2606
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2111
2607
  inst._zod.parse = (payload, ctx) => {
2112
2608
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2113
2609
  if (payload.value === void 0) {
@@ -2128,8 +2624,8 @@ function handleDefaultResult(payload, def) {
2128
2624
  }
2129
2625
  const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2130
2626
  $ZodType.init(inst, def);
2131
- inst._zod.optin = "optional";
2132
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2627
+ inst._zod.optin = "defaulted";
2628
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2133
2629
  inst._zod.parse = (payload, ctx) => {
2134
2630
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2135
2631
  if (payload.value === void 0) payload.value = def.defaultValue;
@@ -2138,8 +2634,8 @@ const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2138
2634
  });
2139
2635
  const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2140
2636
  $ZodType.init(inst, def);
2141
- defineLazy(inst._zod, "values", () => {
2142
- const v = def.innerType._zod.values;
2637
+ defineLazyInternal(inst, "values", (zod) => {
2638
+ const v = zod.def.innerType._zod.values;
2143
2639
  return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2144
2640
  });
2145
2641
  inst._zod.parse = (payload, ctx) => {
@@ -2157,46 +2653,41 @@ function handleNonOptionalResult(payload, inst) {
2157
2653
  });
2158
2654
  return payload;
2159
2655
  }
2656
+ function handleCatchResult(payload, result, def, ctx) {
2657
+ if (!result.issues.length) {
2658
+ payload.value = result.value;
2659
+ if (result.memo) payload.memo = true;
2660
+ return payload;
2661
+ }
2662
+ payload.value = def.catchValue({
2663
+ ...result,
2664
+ value: payload.value,
2665
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2666
+ input: payload.value
2667
+ });
2668
+ return payload;
2669
+ }
2160
2670
  const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2161
2671
  $ZodType.init(inst, def);
2162
- inst._zod.optin = "optional";
2163
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2164
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2672
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
2673
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType._zod.optout);
2674
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2165
2675
  inst._zod.parse = (payload, ctx) => {
2166
2676
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2167
- const result = def.innerType._zod.run(payload, ctx);
2168
- if (result instanceof Promise) return result.then((result) => {
2169
- payload.value = result.value;
2170
- if (result.issues.length) {
2171
- payload.value = def.catchValue({
2172
- ...payload,
2173
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2174
- input: payload.value
2175
- });
2176
- payload.issues = [];
2177
- payload.fallback = true;
2178
- }
2179
- return payload;
2180
- });
2181
- payload.value = result.value;
2182
- if (result.issues.length) {
2183
- payload.value = def.catchValue({
2184
- ...payload,
2185
- error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2186
- input: payload.value
2187
- });
2188
- payload.issues = [];
2189
- payload.fallback = true;
2190
- }
2191
- return payload;
2677
+ const result = def.innerType._zod.run({
2678
+ value: payload.value,
2679
+ issues: []
2680
+ }, ctx);
2681
+ if (result instanceof Promise) return result.then((result) => handleCatchResult(payload, result, def, ctx));
2682
+ return handleCatchResult(payload, result, def, ctx);
2192
2683
  };
2193
2684
  });
2194
2685
  const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2195
2686
  $ZodType.init(inst, def);
2196
- defineLazy(inst._zod, "values", () => def.in._zod.values);
2197
- defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2198
- defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2199
- defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2687
+ defineLazyInternal(inst, "values", (zod) => zod.def.in._zod.values);
2688
+ defineLazyInternal(inst, "optin", (zod) => zod.def.in._zod.optin);
2689
+ defineLazyInternal(inst, "optout", (zod) => zod.def.out._zod.optout);
2690
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.in._zod.propValues);
2200
2691
  inst._zod.parse = (payload, ctx) => {
2201
2692
  if (ctx.direction === "backward") {
2202
2693
  const right = def.out._zod.run(payload, ctx);
@@ -2209,22 +2700,21 @@ const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2209
2700
  };
2210
2701
  });
2211
2702
  function handlePipeResult(left, next, ctx) {
2212
- if (left.issues.length) {
2703
+ if (left.issues.some((iss) => iss.code !== "unrecognized_keys")) {
2213
2704
  left.aborted = true;
2214
2705
  return left;
2215
2706
  }
2216
2707
  return next._zod.run({
2217
2708
  value: left.value,
2218
- issues: left.issues,
2219
- fallback: left.fallback
2709
+ issues: left.issues
2220
2710
  }, ctx);
2221
2711
  }
2222
2712
  const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2223
2713
  $ZodType.init(inst, def);
2224
- defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2225
- defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2226
- defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2227
- defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2714
+ defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
2715
+ defineLazyInternal(inst, "values", (zod) => zod.def.innerType._zod.values);
2716
+ defineLazyInternal(inst, "optin", (zod) => zod.def.innerType?._zod?.optin);
2717
+ defineLazyInternal(inst, "optout", (zod) => zod.def.innerType?._zod?.optout);
2228
2718
  inst._zod.parse = (payload, ctx) => {
2229
2719
  if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2230
2720
  const result = def.innerType._zod.run(payload, ctx);
@@ -2233,7 +2723,7 @@ const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2233
2723
  };
2234
2724
  });
2235
2725
  function handleReadonlyResult(payload) {
2236
- payload.value = Object.freeze(payload.value);
2726
+ if (!payload.memo) payload.value = Object.freeze(payload.value);
2237
2727
  return payload;
2238
2728
  }
2239
2729
  const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
@@ -2263,7 +2753,368 @@ function handleRefineResult(result, payload, input, inst) {
2263
2753
  }
2264
2754
  }
2265
2755
  //#endregion
2266
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/registries.js
2756
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/memoizer.js
2757
+ var $ZodCyclicError = class extends Error {
2758
+ constructor() {
2759
+ super(`Cannot parse a reference cycle that closes through a transform`);
2760
+ this.name = "ZodCyclicError";
2761
+ }
2762
+ };
2763
+ /** Keyed off the context object every schema in one parse call already shares. */
2764
+ const STATE = "~memo";
2765
+ const NO_ISSUES = [];
2766
+ function isRef(value) {
2767
+ return value !== null && typeof value === "object";
2768
+ }
2769
+ function cloneIssues(issues) {
2770
+ return issues.map((iss) => iss.path ? {
2771
+ ...iss,
2772
+ path: iss.path.slice()
2773
+ } : { ...iss });
2774
+ }
2775
+ const recursive = /*@__PURE__*/ new WeakMap();
2776
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
2777
+ const NONE = 0;
2778
+ const ASSUMED = 1;
2779
+ const PROVEN = 2;
2780
+ /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
2781
+ function isRecursive(inst, stack, resolve) {
2782
+ const cached = recursive.get(inst);
2783
+ if (cached !== void 0) return cached ? PROVEN : NONE;
2784
+ if (stack.has(inst)) return PROVEN;
2785
+ stack.add(inst);
2786
+ let result = NONE;
2787
+ const check = (child) => {
2788
+ if (result !== PROVEN && child?._zod) {
2789
+ const answer = isRecursive(child, stack, resolve);
2790
+ if (answer > result) result = answer;
2791
+ }
2792
+ };
2793
+ const shape = (sh, spread) => {
2794
+ let answer = NONE;
2795
+ for (const key of Reflect.ownKeys(sh)) {
2796
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
2797
+ if (spread && !desc.enumerable) continue;
2798
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
2799
+ if (child > answer) answer = child;
2800
+ }
2801
+ return answer;
2802
+ };
2803
+ const merge = (answer) => {
2804
+ if (answer > result) result = answer;
2805
+ };
2806
+ const def = inst._zod.def;
2807
+ switch (def.type) {
2808
+ case "object": {
2809
+ const raw = rawShape(def);
2810
+ merge(raw ? shape(raw, true) : ASSUMED);
2811
+ check(def.catchall);
2812
+ break;
2813
+ }
2814
+ case "array":
2815
+ check(def.element);
2816
+ break;
2817
+ case "tuple":
2818
+ for (const el of def.items) check(el);
2819
+ check(def.rest);
2820
+ break;
2821
+ case "record":
2822
+ case "map":
2823
+ check(def.keyType);
2824
+ check(def.valueType);
2825
+ break;
2826
+ case "set":
2827
+ check(def.valueType);
2828
+ break;
2829
+ case "union":
2830
+ for (const el of def.options) check(el);
2831
+ break;
2832
+ case "intersection":
2833
+ check(def.left);
2834
+ check(def.right);
2835
+ break;
2836
+ case "optional":
2837
+ case "nullable":
2838
+ case "default":
2839
+ case "prefault":
2840
+ case "catch":
2841
+ case "readonly":
2842
+ case "nonoptional":
2843
+ case "promise":
2844
+ case "success":
2845
+ check(def.innerType);
2846
+ break;
2847
+ case "pipe":
2848
+ check(def.in);
2849
+ check(def.out);
2850
+ break;
2851
+ case "function":
2852
+ check(def.input);
2853
+ check(def.output);
2854
+ break;
2855
+ case "lazy": {
2856
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
2857
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
2858
+ break;
2859
+ }
2860
+ case "template_literal":
2861
+ case "string":
2862
+ case "number":
2863
+ case "int":
2864
+ case "boolean":
2865
+ case "bigint":
2866
+ case "symbol":
2867
+ case "undefined":
2868
+ case "null":
2869
+ case "void":
2870
+ case "never":
2871
+ case "any":
2872
+ case "unknown":
2873
+ case "date":
2874
+ case "nan":
2875
+ case "enum":
2876
+ case "literal":
2877
+ case "file":
2878
+ case "transform":
2879
+ case "custom": break;
2880
+ default: for (const key in def) {
2881
+ const desc = Object.getOwnPropertyDescriptor(def, key);
2882
+ if (!desc || desc.get) continue;
2883
+ const value = desc.value;
2884
+ if (!value || typeof value !== "object") continue;
2885
+ if (value._zod) check(value);
2886
+ else if (Array.isArray(value)) for (const el of value) check(el);
2887
+ }
2888
+ }
2889
+ stack.delete(inst);
2890
+ return settle(inst, result);
2891
+ }
2892
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
2893
+ function settle(inst, answer) {
2894
+ if (answer !== ASSUMED) recursive.set(inst, answer === PROVEN);
2895
+ return answer;
2896
+ }
2897
+ function bucketFor(state, inst) {
2898
+ let bucket = state.buckets.get(inst);
2899
+ if (!bucket) {
2900
+ bucket = /* @__PURE__ */ new WeakMap();
2901
+ state.buckets.set(inst, bucket);
2902
+ }
2903
+ return bucket;
2904
+ }
2905
+ let handoff;
2906
+ const open = [];
2907
+ const memo = {
2908
+ alloc(_inst, payload, empty) {
2909
+ const bucket = handoff;
2910
+ if (!bucket) return empty;
2911
+ handoff = void 0;
2912
+ const entry = {
2913
+ value: empty,
2914
+ issues: null
2915
+ };
2916
+ bucket.set(payload.value, entry);
2917
+ open.push(entry);
2918
+ return empty;
2919
+ },
2920
+ guard(inst) {
2921
+ var _a;
2922
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2923
+ inst._zod.deferred.push(() => {
2924
+ const base = inst._zod.parse;
2925
+ const wrapped = (payload, ctx) => {
2926
+ if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value)) throw new $ZodCyclicError();
2927
+ return base(payload, ctx);
2928
+ };
2929
+ inst._zod.parse = wrapped;
2930
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2931
+ });
2932
+ },
2933
+ attach(inst) {
2934
+ var _a;
2935
+ let isRecursiveInst;
2936
+ let rechecked = false;
2937
+ let lastCtx;
2938
+ let lastBucket;
2939
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
2940
+ inst._zod.deferred.push(() => {
2941
+ const base = inst._zod.parse;
2942
+ const wrapped = (payload, ctx) => {
2943
+ if (isRecursiveInst === void 0) {
2944
+ const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
2945
+ if (walked === NONE) {
2946
+ inst._zod.parse = base;
2947
+ if (inst._zod.run === wrapped) inst._zod.run = base;
2948
+ return base(payload, ctx);
2949
+ }
2950
+ if (walked === PROVEN || rechecked) isRecursiveInst = true;
2951
+ else rechecked = true;
2952
+ }
2953
+ const input = payload.value;
2954
+ if (!isRef(input)) return base(payload, ctx);
2955
+ let state = ctx[STATE];
2956
+ if (!state) {
2957
+ state = {
2958
+ buckets: /* @__PURE__ */ new WeakMap(),
2959
+ backEdges: void 0
2960
+ };
2961
+ ctx[STATE] = state;
2962
+ }
2963
+ let bucket;
2964
+ if (lastCtx === ctx) bucket = lastBucket;
2965
+ else {
2966
+ bucket = bucketFor(state, inst);
2967
+ lastCtx = ctx;
2968
+ lastBucket = bucket;
2969
+ }
2970
+ const hit = bucket.get(input);
2971
+ if (hit) {
2972
+ payload.value = hit.value;
2973
+ if (hit.issues) {
2974
+ if (hit.issues.length) payload.issues.push(...cloneIssues(hit.issues));
2975
+ } else {
2976
+ payload.memo = true;
2977
+ state.backEdges ?? (state.backEdges = /* @__PURE__ */ new WeakSet());
2978
+ state.backEdges.add(hit.value);
2979
+ }
2980
+ return payload;
2981
+ }
2982
+ handoff = bucket;
2983
+ const depth = open.length;
2984
+ const result = base(payload, ctx);
2985
+ handoff = void 0;
2986
+ const entry = open.length > depth ? open.pop() : void 0;
2987
+ if (result instanceof Promise) return result.then((r) => {
2988
+ if (entry) entry.issues = r.issues.length ? cloneIssues(r.issues) : NO_ISSUES;
2989
+ return r;
2990
+ });
2991
+ if (entry) entry.issues = result.issues.length ? cloneIssues(result.issues) : NO_ISSUES;
2992
+ return result;
2993
+ };
2994
+ inst._zod.parse = wrapped;
2995
+ if (inst._zod.run === base) inst._zod.run = wrapped;
2996
+ });
2997
+ }
2998
+ };
2999
+ /** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
3000
+ function memoizer() {
3001
+ return memo;
3002
+ }
3003
+ /** Whether this value is a node a back-edge resolved to before it finished. */
3004
+ function isBackEdge(ctx, value) {
3005
+ const backEdges = ctx[STATE]?.backEdges;
3006
+ return backEdges !== void 0 && isRef(value) && backEdges.has(value);
3007
+ }
3008
+ //#endregion
3009
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/locales/en.js
3010
+ const error = () => {
3011
+ const Sizable = {
3012
+ string: {
3013
+ unit: "characters",
3014
+ verb: "to have"
3015
+ },
3016
+ file: {
3017
+ unit: "bytes",
3018
+ verb: "to have"
3019
+ },
3020
+ array: {
3021
+ unit: "items",
3022
+ verb: "to have"
3023
+ },
3024
+ set: {
3025
+ unit: "items",
3026
+ verb: "to have"
3027
+ },
3028
+ map: {
3029
+ unit: "entries",
3030
+ verb: "to have"
3031
+ }
3032
+ };
3033
+ function getSizing(origin) {
3034
+ return Sizable[origin] ?? null;
3035
+ }
3036
+ const FormatDictionary = {
3037
+ regex: "input",
3038
+ email: "email address",
3039
+ url: "URL",
3040
+ emoji: "emoji",
3041
+ uuid: "UUID",
3042
+ uuidv4: "UUIDv4",
3043
+ uuidv6: "UUIDv6",
3044
+ nanoid: "nanoid",
3045
+ guid: "GUID",
3046
+ cuid: "cuid",
3047
+ cuid2: "cuid2",
3048
+ ulid: "ULID",
3049
+ xid: "XID",
3050
+ ksuid: "KSUID",
3051
+ datetime: "ISO datetime",
3052
+ date: "ISO date",
3053
+ time: "ISO time",
3054
+ duration: "ISO duration",
3055
+ ipv4: "IPv4 address",
3056
+ ipv6: "IPv6 address",
3057
+ mac: "MAC address",
3058
+ cidrv4: "IPv4 range",
3059
+ cidrv6: "IPv6 range",
3060
+ base64: "base64-encoded string",
3061
+ base64url: "base64url-encoded string",
3062
+ json_string: "JSON string",
3063
+ e164: "E.164 number",
3064
+ currency_code: "currency code",
3065
+ credit_card: "credit card number",
3066
+ iban: "IBAN",
3067
+ jwt: "JWT",
3068
+ template_literal: "input"
3069
+ };
3070
+ const TypeDictionary = { nan: "NaN" };
3071
+ function getTypeName(type, input) {
3072
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) return String(input);
3073
+ return TypeDictionary[type] ?? type;
3074
+ }
3075
+ return (issue) => {
3076
+ switch (issue.code) {
3077
+ case "invalid_type": return `Invalid input: expected ${getTypeName(issue.expected)}, received ${getTypeName(parsedType(issue.input), issue.input)}`;
3078
+ case "invalid_value":
3079
+ if (issue.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
3080
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
3081
+ case "too_big": {
3082
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
3083
+ const sizing = getSizing(issue.origin);
3084
+ if (sizing) return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
3085
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
3086
+ }
3087
+ case "too_small": {
3088
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
3089
+ const sizing = getSizing(issue.origin);
3090
+ if (sizing) return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
3091
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
3092
+ }
3093
+ case "invalid_format": {
3094
+ const _issue = issue;
3095
+ if (_issue.format === "starts_with") return `Invalid string: must start with "${_issue.prefix}"`;
3096
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
3097
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
3098
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
3099
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
3100
+ }
3101
+ case "not_multiple_of": return `Invalid number: must be a multiple of ${issue.divisor}`;
3102
+ case "unrecognized_keys": return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
3103
+ case "invalid_key": return `Invalid key in ${issue.origin}`;
3104
+ case "invalid_union":
3105
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) return `Invalid discriminator value. Expected ${issue.options.map((o) => `'${o}'`).join(" | ")}`;
3106
+ if (issue.inclusive === false) return "Invalid input: more than one option matched";
3107
+ return "Invalid input";
3108
+ case "invalid_element": return `Invalid value in ${issue.origin}`;
3109
+ default: return `Invalid input`;
3110
+ }
3111
+ };
3112
+ };
3113
+ function en_default() {
3114
+ return { localeError: error() };
3115
+ }
3116
+ //#endregion
3117
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/registries.js
2267
3118
  var _a;
2268
3119
  var $ZodRegistry = class {
2269
3120
  constructor() {
@@ -2310,13 +3161,17 @@ function registry() {
2310
3161
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2311
3162
  const globalRegistry = globalThis.__zod_globalRegistry;
2312
3163
  //#endregion
2313
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/api.js
3164
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/api.js
3165
+ function snapshotChecks(def) {
3166
+ if (def.checks) def.checks = [...def.checks];
3167
+ return def;
3168
+ }
2314
3169
  // @__NO_SIDE_EFFECTS__
2315
3170
  function _string(Class, params) {
2316
- return new Class({
3171
+ return new Class(snapshotChecks({
2317
3172
  type: "string",
2318
3173
  ...normalizeParams(params)
2319
- });
3174
+ }));
2320
3175
  }
2321
3176
  // @__NO_SIDE_EFFECTS__
2322
3177
  function _email(Class, params) {
@@ -2726,7 +3581,7 @@ function _superRefine(fn, params) {
2726
3581
  const _issue = issue$2;
2727
3582
  if (_issue.fatal) _issue.continue = false;
2728
3583
  _issue.code ?? (_issue.code = "custom");
2729
- _issue.input ?? (_issue.input = payload.value);
3584
+ if (!("input" in _issue)) _issue.input = payload.value;
2730
3585
  _issue.inst ?? (_issue.inst = ch);
2731
3586
  _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2732
3587
  payload.issues.push(issue(_issue));
@@ -2746,7 +3601,11 @@ function _check(fn, params) {
2746
3601
  return ch;
2747
3602
  }
2748
3603
  //#endregion
2749
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/to-json-schema.js
3604
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/to-json-schema.js
3605
+ function assignProps(target, ...sources) {
3606
+ for (const source of sources) for (const key of Reflect.ownKeys(source)) if (Object.prototype.propertyIsEnumerable.call(source, key)) assignProp(target, key, source[key]);
3607
+ return target;
3608
+ }
2750
3609
  function initializeContext(params) {
2751
3610
  let target = params?.target ?? "draft-2020-12";
2752
3611
  if (target === "draft-4") target = "draft-04";
@@ -2760,12 +3619,32 @@ function initializeContext(params) {
2760
3619
  io: params?.io ?? "output",
2761
3620
  counter: 0,
2762
3621
  seen: /* @__PURE__ */ new Map(),
3622
+ sharedDefsExtractedFor: void 0,
3623
+ sharedEmitDoneFor: void 0,
2763
3624
  cycles: params?.cycles ?? "ref",
2764
3625
  reused: params?.reused ?? "inline",
3626
+ intersections: [],
3627
+ deferred: [],
2765
3628
  external: params?.external ?? void 0
2766
3629
  };
2767
3630
  }
2768
- function process$1(schema, ctx, _params = {
3631
+ /**
3632
+ * Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
3633
+ * `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
3634
+ * custom JSON Schema was written into `json`, in which case the caller must not write its own.
3635
+ */
3636
+ function handleUnrepresentable(schema, ctx, json, params, message) {
3637
+ const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({
3638
+ zodSchema: schema,
3639
+ path: params.path,
3640
+ message
3641
+ }) : ctx.unrepresentable;
3642
+ if (result === "any") return false;
3643
+ if (result === void 0 || result === "throw") throw new Error(message);
3644
+ Object.assign(json, result);
3645
+ return true;
3646
+ }
3647
+ function processSchema(schema, ctx, _params = {
2769
3648
  path: [],
2770
3649
  schemaPath: []
2771
3650
  }) {
@@ -2784,6 +3663,8 @@ function process$1(schema, ctx, _params = {
2784
3663
  path: _params.path
2785
3664
  };
2786
3665
  ctx.seen.set(schema, result);
3666
+ ctx.sharedDefsExtractedFor = void 0;
3667
+ ctx.sharedEmitDoneFor = void 0;
2787
3668
  const overrideSchema = schema._zod.toJSONSchema?.();
2788
3669
  if (overrideSchema) result.schema = overrideSchema;
2789
3670
  else {
@@ -2802,12 +3683,12 @@ function process$1(schema, ctx, _params = {
2802
3683
  const parent = schema._zod.parent;
2803
3684
  if (parent) {
2804
3685
  if (!result.ref) result.ref = parent;
2805
- process$1(parent, ctx, params);
3686
+ processSchema(parent, ctx, params);
2806
3687
  ctx.seen.get(parent).isParent = true;
2807
3688
  }
2808
3689
  }
2809
3690
  const meta = ctx.metadataRegistry.get(schema);
2810
- if (meta) Object.assign(result.schema, meta);
3691
+ if (meta) assignProps(result.schema, meta);
2811
3692
  if (ctx.io === "input" && isTransforming(schema)) {
2812
3693
  delete result.schema.examples;
2813
3694
  delete result.schema.default;
@@ -2816,9 +3697,13 @@ function process$1(schema, ctx, _params = {
2816
3697
  delete result.schema._prefault;
2817
3698
  return ctx.seen.get(schema).schema;
2818
3699
  }
3700
+ function encodeJSONPointerSegment(segment) {
3701
+ return segment.replace(/~/g, "~0").replace(/\//g, "~1");
3702
+ }
2819
3703
  function extractDefs(ctx, schema) {
2820
3704
  const root = ctx.seen.get(schema);
2821
3705
  if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
3706
+ if (ctx.external && ctx.sharedDefsExtractedFor === ctx.external) return;
2822
3707
  const idToSchema = /* @__PURE__ */ new Map();
2823
3708
  for (const entry of ctx.seen.entries()) {
2824
3709
  const id = ctx.metadataRegistry.get(entry[0])?.id;
@@ -2838,15 +3723,16 @@ function extractDefs(ctx, schema) {
2838
3723
  entry[1].defId = id;
2839
3724
  return {
2840
3725
  defId: id,
2841
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
3726
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${encodeJSONPointerSegment(id)}`
2842
3727
  };
2843
3728
  }
2844
- if (entry[1] === root) return { ref: "#" };
2845
- const defUriPrefix = `#/${defsSegment}/`;
3729
+ const uriPrefix = `#`;
3730
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3731
+ if (entry[1] === root && !entry[1].schema.id) return { ref: uriPrefix };
2846
3732
  const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2847
3733
  return {
2848
3734
  defId,
2849
- ref: defUriPrefix + defId
3735
+ ref: defUriPrefix + encodeJSONPointerSegment(defId)
2850
3736
  };
2851
3737
  };
2852
3738
  const extractToDef = (entry) => {
@@ -2887,12 +3773,114 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
2887
3773
  continue;
2888
3774
  }
2889
3775
  if (seen.count > 1) {
2890
- if (ctx.reused === "ref") {
2891
- extractToDef(entry);
2892
- continue;
3776
+ if (ctx.reused === "ref") extractToDef(entry);
3777
+ }
3778
+ }
3779
+ if (ctx.external) ctx.sharedDefsExtractedFor = ctx.external;
3780
+ }
3781
+ /** 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. */
3782
+ function compactTypeUnion(schema) {
3783
+ const options = schema.anyOf;
3784
+ if (!Array.isArray(options) || options.length === 0 || schema.type !== void 0) return;
3785
+ const types = [];
3786
+ for (const option of options) {
3787
+ if (!option || typeof option !== "object") return;
3788
+ compactTypeUnion(option);
3789
+ const keys = Object.keys(option);
3790
+ if (keys.length !== 1 || keys[0] !== "type") return;
3791
+ const type = option.type;
3792
+ for (const member of Array.isArray(type) ? type : [type]) {
3793
+ if (typeof member !== "string") return;
3794
+ if (!types.includes(member)) types.push(member);
3795
+ }
3796
+ }
3797
+ delete schema.anyOf;
3798
+ schema.type = types.length === 1 ? types[0] : types;
3799
+ }
3800
+ /** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
3801
+ * an annotation like `description` — makes a member unfoldable, so a constraint this does not
3802
+ * understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
3803
+ const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
3804
+ "type",
3805
+ "properties",
3806
+ "required",
3807
+ "additionalProperties"
3808
+ ]);
3809
+ const UNION_KEYS = ["oneOf", "anyOf"];
3810
+ /** 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. */
3811
+ function undeclaredConstraint(member) {
3812
+ const extra = member.additionalProperties;
3813
+ if (extra === void 0 || extra === false || typeof extra !== "object" || extra === null) return null;
3814
+ return Object.keys(extra).length ? extra : null;
3815
+ }
3816
+ /** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
3817
+ function foldObjects(members) {
3818
+ const objects = [];
3819
+ for (const member of members) {
3820
+ if (typeof member !== "object" || member.type !== "object") return null;
3821
+ for (const key in member) if (!FOLDABLE_KEYS.has(key)) return null;
3822
+ objects.push(member);
3823
+ }
3824
+ const properties = {};
3825
+ const required = /* @__PURE__ */ new Set();
3826
+ for (const object of objects) {
3827
+ for (const key in object.properties) {
3828
+ if (Object.prototype.hasOwnProperty.call(properties, key)) continue;
3829
+ const parts = [];
3830
+ for (const other of objects) {
3831
+ const part = other.properties?.[key] ?? undeclaredConstraint(other);
3832
+ if (part === null || part === void 0) continue;
3833
+ if (!parts.some((seen) => JSON.stringify(seen) === JSON.stringify(part))) parts.push(part);
2893
3834
  }
3835
+ assignProp(properties, key, parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts });
2894
3836
  }
3837
+ for (const key of object.required ?? []) required.add(key);
3838
+ }
3839
+ const folded = {
3840
+ type: "object",
3841
+ properties
3842
+ };
3843
+ if (required.size) folded.required = [...required];
3844
+ if (objects.every((object) => object.additionalProperties === false)) folded.additionalProperties = false;
3845
+ else {
3846
+ const constraints = [];
3847
+ for (const object of objects) {
3848
+ const constraint = undeclaredConstraint(object);
3849
+ if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint))) constraints.push(constraint);
3850
+ }
3851
+ if (constraints.length === 1) folded.additionalProperties = constraints[0];
3852
+ else if (constraints.length > 1) folded.additionalProperties = { allOf: constraints };
3853
+ }
3854
+ return folded;
3855
+ }
3856
+ /** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
3857
+ * closed object members reject each other's keys and the schema validates nothing. Zod's parser
3858
+ * pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
3859
+ * *every* side rejects it — so the emitted schema has to pool them too, and folding the members
3860
+ * into one object is the encoding that says so on every target.
3861
+ *
3862
+ * This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
3863
+ * machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
3864
+ * keeps its reference and its own closedness rather than being inlined as a stale copy. */
3865
+ function foldIntersection(json) {
3866
+ const allOf = json.allOf;
3867
+ if (!Array.isArray(allOf) || allOf.length < 2) return;
3868
+ for (const key of FOLDABLE_KEYS) if (key in json) return;
3869
+ const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
3870
+ let folded = null;
3871
+ if (!unions.length) folded = foldObjects(allOf);
3872
+ else {
3873
+ const union = unions[0];
3874
+ const keyword = UNION_KEYS.find((k) => Array.isArray(union[k]));
3875
+ if (Object.keys(union).length !== 1) return;
3876
+ const rest = allOf.filter((m) => m !== union);
3877
+ const branches = union[keyword].map((branch) => foldObjects([...rest, branch]));
3878
+ if (branches.some((b) => !b)) return;
3879
+ folded = { [keyword]: branches };
2895
3880
  }
3881
+ if (!folded) return;
3882
+ delete json.allOf;
3883
+ assignProps(json, folded);
2896
3884
  }
2897
3885
  function finalize(ctx, schema) {
2898
3886
  const root = ctx.seen.get(schema);
@@ -2911,8 +3899,8 @@ function finalize(ctx, schema) {
2911
3899
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2912
3900
  schema.allOf = schema.allOf ?? [];
2913
3901
  schema.allOf.push(refSchema);
2914
- } else Object.assign(schema, refSchema);
2915
- Object.assign(schema, _cached);
3902
+ } else assignProps(schema, refSchema);
3903
+ assignProps(schema, _cached);
2916
3904
  if (zodSchema._zod.parent === ref) for (const key in schema) {
2917
3905
  if (key === "$ref" || key === "allOf") continue;
2918
3906
  if (!(key in _cached)) delete schema[key];
@@ -2940,7 +3928,22 @@ function finalize(ctx, schema) {
2940
3928
  path: seen.path ?? []
2941
3929
  });
2942
3930
  };
2943
- for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3931
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) {
3932
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
3933
+ if (ctx.target !== "openapi-3.0") for (const entry of ctx.seen.entries()) compactTypeUnion(entry[1].def ?? entry[1].schema);
3934
+ for (const rewrite of ctx.deferred) rewrite();
3935
+ if (ctx.intersections.length) {
3936
+ const carriers = /* @__PURE__ */ new Map();
3937
+ for (const seen of ctx.seen.values()) for (const json of [seen.schema, seen.def]) {
3938
+ const allOf = json?.allOf;
3939
+ if (!Array.isArray(allOf)) continue;
3940
+ const existing = carriers.get(allOf);
3941
+ if (existing) existing.push(json);
3942
+ else carriers.set(allOf, [json]);
3943
+ }
3944
+ for (const allOf of ctx.intersections) for (const json of carriers.get(allOf) ?? []) foldIntersection(json);
3945
+ }
3946
+ }
2944
3947
  const result = {};
2945
3948
  if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2946
3949
  else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
@@ -2951,17 +3954,18 @@ function finalize(ctx, schema) {
2951
3954
  if (!id) throw new Error("Schema is missing an `id` property");
2952
3955
  result.$id = ctx.external.uri(id);
2953
3956
  }
2954
- Object.assign(result, root.def ?? root.schema);
3957
+ assignProps(result, root.defId ? root.schema : root.def ?? root.schema);
2955
3958
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2956
3959
  if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2957
3960
  const defs = ctx.external?.defs ?? {};
2958
- for (const entry of ctx.seen.entries()) {
3961
+ if (!ctx.external || ctx.sharedEmitDoneFor !== ctx.external) for (const entry of ctx.seen.entries()) {
2959
3962
  const seen = entry[1];
2960
3963
  if (seen.def && seen.defId) {
2961
3964
  if (seen.def.id === seen.defId) delete seen.def.id;
2962
- defs[seen.defId] = seen.def;
3965
+ assignProp(defs, seen.defId, seen.def);
2963
3966
  }
2964
3967
  }
3968
+ if (ctx.external) ctx.sharedEmitDoneFor = ctx.external;
2965
3969
  if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2966
3970
  else result.definitions = defs;
2967
3971
  try {
@@ -2991,7 +3995,7 @@ function isTransforming(_schema, _ctx) {
2991
3995
  if (def.type === "array") return isTransforming(def.element, ctx);
2992
3996
  if (def.type === "set") return isTransforming(def.valueType, ctx);
2993
3997
  if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2994
- 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);
3998
+ 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);
2995
3999
  if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2996
4000
  if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2997
4001
  if (def.type === "pipe") {
@@ -3022,7 +4026,7 @@ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3022
4026
  ...params,
3023
4027
  processors
3024
4028
  });
3025
- process$1(schema, ctx);
4029
+ processSchema(schema, ctx);
3026
4030
  extractDefs(ctx, schema);
3027
4031
  return finalize(ctx, schema);
3028
4032
  };
@@ -3034,12 +4038,84 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
3034
4038
  io,
3035
4039
  processors
3036
4040
  });
3037
- process$1(schema, ctx);
4041
+ processSchema(schema, ctx);
3038
4042
  extractDefs(ctx, schema);
3039
4043
  return finalize(ctx, schema);
3040
4044
  };
3041
4045
  //#endregion
3042
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/core/json-schema-processors.js
4046
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/core/json-schema-processors.js
4047
+ const narrowMin = (agg, key, value) => {
4048
+ if (agg[key] === void 0 || value > agg[key]) agg[key] = value;
4049
+ };
4050
+ const narrowMax = (agg, key, value) => {
4051
+ if (agg[key] === void 0 || value < agg[key]) agg[key] = value;
4052
+ };
4053
+ const narrowBoth = (agg, value) => {
4054
+ narrowMin(agg, "minimum", value);
4055
+ narrowMax(agg, "maximum", value);
4056
+ };
4057
+ const addDivisor = (agg, value) => {
4058
+ agg.multipleOf ?? (agg.multipleOf = []);
4059
+ if (!agg.multipleOf.includes(value)) agg.multipleOf.push(value);
4060
+ };
4061
+ const addPattern = (agg, pattern) => {
4062
+ agg.patterns ?? (agg.patterns = /* @__PURE__ */ new Set());
4063
+ agg.patterns.add(pattern);
4064
+ };
4065
+ const intersectMime = (agg, mime) => {
4066
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
4067
+ };
4068
+ const setFormat = (agg, format) => {
4069
+ agg.format = format;
4070
+ if (format.includes("int")) agg.isInt = true;
4071
+ };
4072
+ const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
4073
+ const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
4074
+ const formatContributor = (ranges) => (agg, def) => {
4075
+ setFormat(agg, def.format);
4076
+ const [minimum, maximum] = ranges[def.format];
4077
+ narrowMin(agg, "minimum", minimum);
4078
+ narrowMax(agg, "maximum", maximum);
4079
+ };
4080
+ const contributors = {
4081
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
4082
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
4083
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
4084
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
4085
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
4086
+ min_length: minContributor,
4087
+ max_length: maxContributor,
4088
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
4089
+ min_size: minContributor,
4090
+ max_size: maxContributor,
4091
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
4092
+ string_format: (agg, def) => {
4093
+ setFormat(agg, def.format);
4094
+ if (def.pattern) addPattern(agg, def.pattern);
4095
+ if (def.format === "base64" || def.format === "base64url") agg.contentEncoding = def.format;
4096
+ if (def.local || def.precision === -1) agg.laxFormat = true;
4097
+ },
4098
+ mime_type: (agg, def) => intersectMime(agg, def.mime)
4099
+ };
4100
+ function aggregateChecks(schema) {
4101
+ const agg = {};
4102
+ const def = schema._zod.def;
4103
+ const list = schema._zod.traits.has("$ZodCheck") ? [schema, ...def.checks ?? []] : def.checks ?? [];
4104
+ for (const ch of list) contributors[ch._zod.def.check]?.(agg, ch._zod.def);
4105
+ const bag = schema._zod.bag;
4106
+ if (bag.minimum !== void 0) narrowMin(agg, "minimum", bag.minimum);
4107
+ if (bag.exclusiveMinimum !== void 0) narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
4108
+ if (bag.maximum !== void 0) narrowMax(agg, "maximum", bag.maximum);
4109
+ if (bag.exclusiveMaximum !== void 0) narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
4110
+ if (bag.multipleOf !== void 0) addDivisor(agg, bag.multipleOf);
4111
+ if (bag.format !== void 0) {
4112
+ agg.format ?? (agg.format = bag.format);
4113
+ if (bag.format.includes("int")) agg.isInt = true;
4114
+ }
4115
+ if (bag.mime) intersectMime(agg, bag.mime);
4116
+ for (const pattern of bag.patterns ?? []) addPattern(agg, pattern);
4117
+ return agg;
4118
+ }
3043
4119
  const formatMap = {
3044
4120
  guid: "uuid",
3045
4121
  url: "uri",
@@ -3047,22 +4123,24 @@ const formatMap = {
3047
4123
  json_string: "json-string",
3048
4124
  regex: ""
3049
4125
  };
4126
+ const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
4127
+ const exactPattern = (p) => exactPatterns.get(p) ?? p;
3050
4128
  const stringProcessor = (schema, ctx, _json, _params) => {
3051
4129
  const json = _json;
3052
4130
  json.type = "string";
3053
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
4131
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
3054
4132
  if (typeof minimum === "number") json.minLength = minimum;
3055
4133
  if (typeof maximum === "number") json.maxLength = maximum;
3056
4134
  if (format) {
3057
4135
  json.format = formatMap[format] ?? format;
3058
4136
  if (json.format === "") delete json.format;
3059
- if (format === "time") delete json.format;
4137
+ if (format === "time" || laxFormat) delete json.format;
3060
4138
  }
3061
4139
  if (contentEncoding) json.contentEncoding = contentEncoding;
3062
4140
  if (patterns && patterns.size > 0) {
3063
- const regexes = [...patterns];
3064
- if (regexes.length === 1) json.pattern = regexes[0].source;
3065
- else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
4141
+ const patternList = [...patterns].map(exactPattern);
4142
+ if (patternList.length === 1) json.pattern = patternList[0].source;
4143
+ else if (patternList.length > 1) json.allOf = [...patternList.map((regex) => ({
3066
4144
  ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3067
4145
  pattern: regex.source
3068
4146
  }))];
@@ -3074,53 +4152,63 @@ const neverProcessor = (_schema, _ctx, json, _params) => {
3074
4152
  const enumProcessor = (schema, _ctx, json, _params) => {
3075
4153
  const def = schema._zod.def;
3076
4154
  const values = getEnumValues(def.entries);
4155
+ if (values.length === 0) {
4156
+ json.not = {};
4157
+ return;
4158
+ }
3077
4159
  if (values.every((v) => typeof v === "number")) json.type = "number";
3078
4160
  if (values.every((v) => typeof v === "string")) json.type = "string";
3079
4161
  json.enum = values;
3080
4162
  };
3081
- const customProcessor = (_schema, ctx, _json, _params) => {
3082
- if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4163
+ const customProcessor = (schema, ctx, json, params) => {
4164
+ handleUnrepresentable(schema, ctx, json, params, "Custom types cannot be represented in JSON Schema");
3083
4165
  };
3084
- const transformProcessor = (_schema, ctx, _json, _params) => {
3085
- if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4166
+ const transformProcessor = (schema, ctx, json, params) => {
4167
+ handleUnrepresentable(schema, ctx, json, params, "Transforms cannot be represented in JSON Schema");
3086
4168
  };
3087
4169
  const arrayProcessor = (schema, ctx, _json, params) => {
3088
4170
  const json = _json;
3089
4171
  const def = schema._zod.def;
3090
- const { minimum, maximum } = schema._zod.bag;
4172
+ const { minimum, maximum } = aggregateChecks(schema);
3091
4173
  if (typeof minimum === "number") json.minItems = minimum;
3092
4174
  if (typeof maximum === "number") json.maxItems = maximum;
3093
4175
  json.type = "array";
3094
- json.items = process$1(def.element, ctx, {
4176
+ json.items = processSchema(def.element, ctx, {
3095
4177
  ...params,
3096
4178
  path: [...params.path, "items"]
3097
4179
  });
3098
4180
  };
4181
+ function inputOptin(schema) {
4182
+ const def = schema._zod.def;
4183
+ if (def.type === "pipe" && def.in._zod.traits.has("$ZodTransform")) return inputOptin(def.out);
4184
+ if (def.type === "catch") return inputOptin(def.innerType);
4185
+ return schema._zod.optin;
4186
+ }
3099
4187
  const objectProcessor = (schema, ctx, _json, params) => {
3100
4188
  const json = _json;
3101
4189
  const def = schema._zod.def;
4190
+ const shape = def.shape;
4191
+ if (Object.getOwnPropertySymbols(shape).length && handleUnrepresentable(schema, ctx, json, params, "Symbol keys cannot be represented in JSON Schema")) return;
3102
4192
  json.type = "object";
3103
4193
  json.properties = {};
3104
- const shape = def.shape;
3105
- for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
4194
+ for (const key in shape) assignProp(json.properties, key, processSchema(shape[key], ctx, {
3106
4195
  ...params,
3107
4196
  path: [
3108
4197
  ...params.path,
3109
4198
  "properties",
3110
4199
  key
3111
4200
  ]
3112
- });
3113
- const allKeys = new Set(Object.keys(shape));
3114
- const requiredKeys = new Set([...allKeys].filter((key) => {
3115
- const v = def.shape[key]._zod;
3116
- if (ctx.io === "input") return v.optin === void 0;
3117
- else return v.optout === void 0;
3118
4201
  }));
3119
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
4202
+ const requiredKeys = [];
4203
+ for (const key of Object.keys(shape)) {
4204
+ const field = def.shape[key];
4205
+ if (ctx.io === "input" ? inputOptin(field) === void 0 : field._zod.optout === void 0) requiredKeys.push(key);
4206
+ }
4207
+ if (requiredKeys.length > 0) json.required = requiredKeys;
3120
4208
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3121
4209
  else if (!def.catchall) {
3122
4210
  if (ctx.io === "output") json.additionalProperties = false;
3123
- } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
4211
+ } else if (def.catchall) json.additionalProperties = processSchema(def.catchall, ctx, {
3124
4212
  ...params,
3125
4213
  path: [...params.path, "additionalProperties"]
3126
4214
  });
@@ -3128,7 +4216,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
3128
4216
  const unionProcessor = (schema, ctx, json, params) => {
3129
4217
  const def = schema._zod.def;
3130
4218
  const isExclusive = def.inclusive === false;
3131
- const options = def.options.map((x, i) => process$1(x, ctx, {
4219
+ const options = def.options.map((x, i) => processSchema(x, ctx, {
3132
4220
  ...params,
3133
4221
  path: [
3134
4222
  ...params.path,
@@ -3141,7 +4229,7 @@ const unionProcessor = (schema, ctx, json, params) => {
3141
4229
  };
3142
4230
  const intersectionProcessor = (schema, ctx, json, params) => {
3143
4231
  const def = schema._zod.def;
3144
- const a = process$1(def.left, ctx, {
4232
+ const a = processSchema(def.left, ctx, {
3145
4233
  ...params,
3146
4234
  path: [
3147
4235
  ...params.path,
@@ -3149,7 +4237,7 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3149
4237
  0
3150
4238
  ]
3151
4239
  });
3152
- const b = process$1(def.right, ctx, {
4240
+ const b = processSchema(def.right, ctx, {
3153
4241
  ...params,
3154
4242
  path: [
3155
4243
  ...params.path,
@@ -3158,11 +4246,13 @@ const intersectionProcessor = (schema, ctx, json, params) => {
3158
4246
  ]
3159
4247
  });
3160
4248
  const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3161
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4249
+ const allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
4250
+ json.allOf = allOf;
4251
+ ctx.intersections.push(allOf);
3162
4252
  };
3163
4253
  const nullableProcessor = (schema, ctx, json, params) => {
3164
4254
  const def = schema._zod.def;
3165
- const inner = process$1(def.innerType, ctx, params);
4255
+ const inner = processSchema(def.innerType, ctx, params);
3166
4256
  const seen = ctx.seen.get(schema);
3167
4257
  if (ctx.target === "openapi-3.0") {
3168
4258
  seen.ref = def.innerType;
@@ -3171,34 +4261,53 @@ const nullableProcessor = (schema, ctx, json, params) => {
3171
4261
  };
3172
4262
  const nonoptionalProcessor = (schema, ctx, _json, params) => {
3173
4263
  const def = schema._zod.def;
3174
- process$1(def.innerType, ctx, params);
4264
+ processSchema(def.innerType, ctx, params);
3175
4265
  const seen = ctx.seen.get(schema);
3176
4266
  seen.ref = def.innerType;
3177
4267
  };
4268
+ /** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
4269
+ * A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
4270
+ * unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
4271
+ const UNREPRESENTABLE_DEFAULT = Symbol();
4272
+ function serializeDefaultValue(value, schema, ctx, json, params) {
4273
+ let unrepresentable = false;
4274
+ const serialized = JSON.stringify(value, (_, val) => {
4275
+ if (typeof val !== "bigint") return val;
4276
+ unrepresentable = true;
4277
+ return null;
4278
+ });
4279
+ if (!unrepresentable) return JSON.parse(serialized);
4280
+ handleUnrepresentable(schema, ctx, json, params, "BigInt defaults cannot be represented in JSON Schema");
4281
+ return UNREPRESENTABLE_DEFAULT;
4282
+ }
3178
4283
  const defaultProcessor = (schema, ctx, json, params) => {
3179
4284
  const def = schema._zod.def;
3180
- process$1(def.innerType, ctx, params);
4285
+ processSchema(def.innerType, ctx, params);
3181
4286
  const seen = ctx.seen.get(schema);
3182
4287
  seen.ref = def.innerType;
3183
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4288
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4289
+ if (value !== UNREPRESENTABLE_DEFAULT) json.default = value;
3184
4290
  };
3185
4291
  const prefaultProcessor = (schema, ctx, json, params) => {
3186
4292
  const def = schema._zod.def;
3187
- process$1(def.innerType, ctx, params);
4293
+ processSchema(def.innerType, ctx, params);
3188
4294
  const seen = ctx.seen.get(schema);
3189
4295
  seen.ref = def.innerType;
3190
- if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4296
+ if (ctx.io !== "input") return;
4297
+ const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
4298
+ if (value !== UNREPRESENTABLE_DEFAULT) json._prefault = value;
3191
4299
  };
3192
4300
  const catchProcessor = (schema, ctx, json, params) => {
3193
4301
  const def = schema._zod.def;
3194
- process$1(def.innerType, ctx, params);
4302
+ processSchema(def.innerType, ctx, params);
3195
4303
  const seen = ctx.seen.get(schema);
3196
4304
  seen.ref = def.innerType;
3197
4305
  let catchValue;
3198
4306
  try {
3199
4307
  catchValue = def.catchValue(void 0);
3200
4308
  } catch {
3201
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4309
+ handleUnrepresentable(schema, ctx, json, params, "Dynamic catch values are not supported in JSON Schema");
4310
+ return;
3202
4311
  }
3203
4312
  json.default = catchValue;
3204
4313
  };
@@ -3206,77 +4315,75 @@ const pipeProcessor = (schema, ctx, _json, params) => {
3206
4315
  const def = schema._zod.def;
3207
4316
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3208
4317
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3209
- process$1(innerType, ctx, params);
4318
+ processSchema(innerType, ctx, params);
3210
4319
  const seen = ctx.seen.get(schema);
3211
4320
  seen.ref = innerType;
3212
4321
  };
3213
4322
  const readonlyProcessor = (schema, ctx, json, params) => {
3214
4323
  const def = schema._zod.def;
3215
- process$1(def.innerType, ctx, params);
4324
+ processSchema(def.innerType, ctx, params);
3216
4325
  const seen = ctx.seen.get(schema);
3217
4326
  seen.ref = def.innerType;
3218
4327
  json.readOnly = true;
3219
4328
  };
3220
4329
  const optionalProcessor = (schema, ctx, _json, params) => {
3221
4330
  const def = schema._zod.def;
3222
- process$1(def.innerType, ctx, params);
4331
+ processSchema(def.innerType, ctx, params);
3223
4332
  const seen = ctx.seen.get(schema);
3224
4333
  seen.ref = def.innerType;
3225
4334
  };
3226
4335
  //#endregion
3227
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/iso.js
3228
- const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3229
- $ZodISODateTime.init(inst, def);
3230
- ZodStringFormat.init(inst, def);
3231
- });
3232
- function datetime(params) {
3233
- return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3234
- }
3235
- const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3236
- $ZodISODate.init(inst, def);
3237
- ZodStringFormat.init(inst, def);
3238
- });
3239
- function date(params) {
3240
- return /* @__PURE__ */ _isoDate(ZodISODate, params);
3241
- }
3242
- const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3243
- $ZodISOTime.init(inst, def);
3244
- ZodStringFormat.init(inst, def);
3245
- });
3246
- function time(params) {
3247
- return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3248
- }
3249
- const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3250
- $ZodISODuration.init(inst, def);
3251
- ZodStringFormat.init(inst, def);
3252
- });
3253
- function duration(params) {
3254
- return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
4336
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/classic/errors.js
4337
+ const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
4338
+ function _lazyMethod(proto, key, make) {
4339
+ Object.defineProperty(proto, key, {
4340
+ configurable: true,
4341
+ enumerable: false,
4342
+ get() {
4343
+ const value = make(this);
4344
+ Object.defineProperty(this, key, {
4345
+ value,
4346
+ configurable: true,
4347
+ writable: true
4348
+ });
4349
+ return value;
4350
+ },
4351
+ set(value) {
4352
+ Object.defineProperty(this, key, {
4353
+ value,
4354
+ configurable: true,
4355
+ writable: true
4356
+ });
4357
+ }
4358
+ });
3255
4359
  }
3256
- //#endregion
3257
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/errors.js
3258
4360
  const initializer = (inst, issues) => {
3259
4361
  $ZodError.init(inst, issues);
3260
4362
  inst.name = "ZodError";
3261
- Object.defineProperties(inst, {
3262
- format: { value: (mapper) => formatError(inst, mapper) },
3263
- flatten: { value: (mapper) => flattenError(inst, mapper) },
3264
- addIssue: { value: (issue) => {
3265
- inst.issues.push(issue);
3266
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3267
- } },
3268
- addIssues: { value: (issues) => {
3269
- inst.issues.push(...issues);
3270
- inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3271
- } },
3272
- isEmpty: { get() {
3273
- return inst.issues.length === 0;
3274
- } }
4363
+ const proto = Object.getPrototypeOf(inst);
4364
+ if (_installedErrorProtos.has(proto)) return;
4365
+ _installedErrorProtos.add(proto);
4366
+ _lazyMethod(proto, "format", (self) => (mapper) => formatError(self, mapper));
4367
+ _lazyMethod(proto, "flatten", (self) => (mapper) => flattenError(self, mapper));
4368
+ _lazyMethod(proto, "addIssue", (self) => (issue) => {
4369
+ self.issues.push(issue);
4370
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4371
+ });
4372
+ _lazyMethod(proto, "addIssues", (self) => (issues) => {
4373
+ self.issues.push(...issues);
4374
+ self.message = JSON.stringify(self.issues, jsonStringifyReplacer, 2);
4375
+ });
4376
+ Object.defineProperty(proto, "isEmpty", {
4377
+ configurable: true,
4378
+ enumerable: false,
4379
+ get() {
4380
+ return this.issues.length === 0;
4381
+ }
3275
4382
  });
3276
4383
  };
3277
- const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
4384
+ const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
3278
4385
  //#endregion
3279
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/parse.js
4386
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/classic/parse.js
3280
4387
  const parse = /* @__PURE__ */ _parse(ZodRealError);
3281
4388
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3282
4389
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -3290,255 +4397,320 @@ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3290
4397
  const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3291
4398
  const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3292
4399
  //#endregion
3293
- //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.4.3/09b4e1f4024540142723f154808f0d43eb14b44b685c1085d435a20f90e89165/node_modules/zod/v4/classic/schemas.js
3294
- const _installedGroups = /* @__PURE__ */ new WeakMap();
3295
- function _installLazyMethods(inst, group, methods) {
3296
- const proto = Object.getPrototypeOf(inst);
3297
- let installed = _installedGroups.get(proto);
3298
- if (!installed) {
3299
- installed = /* @__PURE__ */ new Set();
3300
- _installedGroups.set(proto, installed);
3301
- }
3302
- if (installed.has(group)) return;
3303
- installed.add(group);
3304
- for (const key in methods) {
3305
- const fn = methods[key];
3306
- Object.defineProperty(proto, key, {
3307
- configurable: true,
3308
- enumerable: false,
3309
- get() {
3310
- const bound = fn.bind(this);
3311
- Object.defineProperty(this, key, {
3312
- configurable: true,
3313
- writable: true,
3314
- enumerable: true,
3315
- value: bound
3316
- });
3317
- return bound;
3318
- },
3319
- set(v) {
3320
- Object.defineProperty(this, key, {
3321
- configurable: true,
3322
- writable: true,
3323
- enumerable: true,
3324
- value: v
3325
- });
3326
- }
3327
- });
3328
- }
4400
+ //#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod/4.6.5/6448fd814698825170f93bd428080c609bd45ccbc007f4c2dfd5fac1bb52f28d/node_modules/zod/v4/classic/schemas.js
4401
+ function _ensureDefaultLocale() {
4402
+ if (!globalConfig.localeError) config(en_default());
4403
+ }
4404
+ function _ensureDefaultMemoizer() {
4405
+ if (!globalConfig.memoizer) config({ memoizer: memoizer() });
3329
4406
  }
3330
4407
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4408
+ _ensureDefaultLocale();
3331
4409
  $ZodType.init(inst, def);
3332
- Object.assign(inst["~standard"], { jsonSchema: {
3333
- input: createStandardJSONSchemaMethod(inst, "input"),
3334
- output: createStandardJSONSchemaMethod(inst, "output")
3335
- } });
3336
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3337
4410
  inst.def = def;
3338
4411
  inst.type = def.type;
3339
- Object.defineProperty(inst, "_def", { value: def });
3340
- inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3341
- inst.safeParse = (data, params) => safeParse(inst, data, params);
3342
- inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3343
- inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3344
- inst.spa = inst.safeParseAsync;
3345
- inst.encode = (data, params) => encode(inst, data, params);
3346
- inst.decode = (data, params) => decode(inst, data, params);
3347
- inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3348
- inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3349
- inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3350
- inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3351
- inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3352
- inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3353
- _installLazyMethods(inst, "ZodType", {
3354
- check(...chks) {
3355
- const def = this.def;
3356
- return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3357
- check: ch,
3358
- def: { check: "custom" },
3359
- onattach: []
3360
- } } : ch)] }), { parent: true });
3361
- },
3362
- with(...chks) {
3363
- return this.check(...chks);
3364
- },
3365
- clone(def, params) {
3366
- return clone(this, def, params);
3367
- },
3368
- brand() {
3369
- return this;
3370
- },
3371
- register(reg, meta) {
3372
- reg.add(this, meta);
3373
- return this;
3374
- },
3375
- refine(check, params) {
3376
- return this.check(refine(check, params));
3377
- },
3378
- superRefine(refinement, params) {
3379
- return this.check(superRefine(refinement, params));
3380
- },
3381
- overwrite(fn) {
3382
- return this.check(/* @__PURE__ */ _overwrite(fn));
3383
- },
3384
- optional() {
3385
- return optional(this);
3386
- },
3387
- exactOptional() {
3388
- return exactOptional(this);
3389
- },
3390
- nullable() {
3391
- return nullable(this);
3392
- },
3393
- nullish() {
3394
- return optional(nullable(this));
3395
- },
3396
- nonoptional(params) {
3397
- return nonoptional(this, params);
3398
- },
3399
- array() {
3400
- return array(this);
3401
- },
3402
- or(arg) {
3403
- return union([this, arg]);
3404
- },
3405
- and(arg) {
3406
- return intersection(this, arg);
3407
- },
3408
- transform(tx) {
3409
- return pipe(this, transform(tx));
3410
- },
3411
- default(d) {
3412
- return _default(this, d);
3413
- },
3414
- prefault(d) {
3415
- return prefault(this, d);
3416
- },
3417
- catch(params) {
3418
- return _catch(this, params);
3419
- },
3420
- pipe(target) {
3421
- return pipe(this, target);
3422
- },
3423
- readonly() {
3424
- return readonly(this);
3425
- },
3426
- describe(description) {
3427
- const cl = this.clone();
3428
- globalRegistry.add(cl, { description });
3429
- return cl;
3430
- },
3431
- meta(...args) {
3432
- if (args.length === 0) return globalRegistry.get(this);
3433
- const cl = this.clone();
3434
- globalRegistry.add(cl, args[0]);
3435
- return cl;
3436
- },
3437
- isOptional() {
3438
- return this.safeParse(void 0).success;
3439
- },
3440
- isNullable() {
3441
- return this.safeParse(null).success;
3442
- },
3443
- apply(fn) {
3444
- return fn(this);
3445
- }
3446
- });
3447
- Object.defineProperty(inst, "description", {
3448
- get() {
3449
- return globalRegistry.get(inst)?.description;
3450
- },
3451
- configurable: true
3452
- });
3453
4412
  return inst;
4413
+ }, {
4414
+ check(...chks) {
4415
+ const def = this.def;
4416
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
4417
+ check: ch,
4418
+ def: { check: "custom" },
4419
+ onattach: []
4420
+ } } : ch)] }), { parent: true });
4421
+ },
4422
+ with(...chks) {
4423
+ return this.check(...chks);
4424
+ },
4425
+ clone(def, params) {
4426
+ return clone(this, def, params);
4427
+ },
4428
+ brand() {
4429
+ return this;
4430
+ },
4431
+ register(reg, meta) {
4432
+ reg.add(this, meta);
4433
+ return this;
4434
+ },
4435
+ refine(check, params) {
4436
+ return this.check(refine(check, params));
4437
+ },
4438
+ superRefine(refinement, params) {
4439
+ return this.check(superRefine(refinement, params));
4440
+ },
4441
+ overwrite(fn) {
4442
+ return this.check(/* @__PURE__ */ _overwrite(fn));
4443
+ },
4444
+ optional() {
4445
+ return optional(this);
4446
+ },
4447
+ exactOptional() {
4448
+ return exactOptional(this);
4449
+ },
4450
+ nullable() {
4451
+ return nullable(this);
4452
+ },
4453
+ nullish() {
4454
+ return optional(nullable(this));
4455
+ },
4456
+ nonoptional(params) {
4457
+ return nonoptional(this, params);
4458
+ },
4459
+ array() {
4460
+ return array(this);
4461
+ },
4462
+ or(arg) {
4463
+ return union([this, arg]);
4464
+ },
4465
+ and(arg) {
4466
+ return intersection(this, arg);
4467
+ },
4468
+ transform(tx) {
4469
+ return pipe(this, transform(tx));
4470
+ },
4471
+ default(d) {
4472
+ return _default(this, d);
4473
+ },
4474
+ prefault(d) {
4475
+ return prefault(this, d);
4476
+ },
4477
+ catch(params) {
4478
+ return _catch(this, params);
4479
+ },
4480
+ pipe(target) {
4481
+ return pipe(this, target);
4482
+ },
4483
+ readonly() {
4484
+ return readonly(this);
4485
+ },
4486
+ describe(description) {
4487
+ const cl = this.clone();
4488
+ globalRegistry.add(cl, { description });
4489
+ return cl;
4490
+ },
4491
+ meta(...args) {
4492
+ if (args.length === 0) return globalRegistry.get(this);
4493
+ const cl = this.clone();
4494
+ globalRegistry.add(cl, args[0]);
4495
+ return cl;
4496
+ },
4497
+ isOptional() {
4498
+ return this.safeParse(void 0).success;
4499
+ },
4500
+ isNullable() {
4501
+ return this.safeParse(null).success;
4502
+ },
4503
+ apply(fn, ...args) {
4504
+ return args.length === 0 ? fn(this) : fn(this, ...args);
4505
+ },
4506
+ get "~standard"() {
4507
+ return hide(this, "~standard", {
4508
+ ...standardProps(this),
4509
+ jsonSchema: {
4510
+ input: createStandardJSONSchemaMethod(this, "input"),
4511
+ output: createStandardJSONSchemaMethod(this, "output")
4512
+ }
4513
+ });
4514
+ },
4515
+ set "~standard"(value) {
4516
+ own(this, "~standard", value);
4517
+ },
4518
+ parse: function _parse(data, params) {
4519
+ return parse(this, data, params, { callee: _parse });
4520
+ },
4521
+ parseAsync: async function _parseAsync(data, params) {
4522
+ return await parseAsync(this, data, params, { callee: _parseAsync });
4523
+ },
4524
+ safeParse(data, params) {
4525
+ return safeParse(this, data, params);
4526
+ },
4527
+ async safeParseAsync(data, params) {
4528
+ return safeParseAsync(this, data, params);
4529
+ },
4530
+ get spa() {
4531
+ return this?.safeParseAsync;
4532
+ },
4533
+ set spa(value) {
4534
+ own(this, "spa", value);
4535
+ },
4536
+ validate(data, params) {
4537
+ return validate(this, data, params);
4538
+ },
4539
+ validateAsync(data, params) {
4540
+ return validateAsync$1(this, data, params);
4541
+ },
4542
+ encode: function _encode(data, params) {
4543
+ return encode(this, data, params, { callee: _encode });
4544
+ },
4545
+ decode: function _decode(data, params) {
4546
+ return decode(this, data, params, { callee: _decode });
4547
+ },
4548
+ encodeAsync: async function _encodeAsync(data, params) {
4549
+ return await encodeAsync(this, data, params, { callee: _encodeAsync });
4550
+ },
4551
+ decodeAsync: async function _decodeAsync(data, params) {
4552
+ return await decodeAsync(this, data, params, { callee: _decodeAsync });
4553
+ },
4554
+ safeEncode(data, params) {
4555
+ return safeEncode(this, data, params);
4556
+ },
4557
+ safeDecode(data, params) {
4558
+ return safeDecode(this, data, params);
4559
+ },
4560
+ async safeEncodeAsync(data, params) {
4561
+ return safeEncodeAsync(this, data, params);
4562
+ },
4563
+ async safeDecodeAsync(data, params) {
4564
+ return safeDecodeAsync(this, data, params);
4565
+ },
4566
+ toJSONSchema(params) {
4567
+ return createToJSONSchemaMethod(this, {})(params);
4568
+ },
4569
+ get description() {
4570
+ return globalRegistry.get(this)?.description;
4571
+ },
4572
+ get _def() {
4573
+ return this._zod.def;
4574
+ }
3454
4575
  });
3455
4576
  /** @internal */
3456
4577
  const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3457
4578
  $ZodString.init(inst, def);
3458
4579
  ZodType.init(inst, def);
3459
4580
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3460
- const bag = inst._zod.bag;
3461
- inst.format = bag.format ?? null;
3462
- inst.minLength = bag.minimum ?? null;
3463
- inst.maxLength = bag.maximum ?? null;
3464
- _installLazyMethods(inst, "_ZodString", {
3465
- regex(...args) {
3466
- return this.check(/* @__PURE__ */ _regex(...args));
3467
- },
3468
- includes(...args) {
3469
- return this.check(/* @__PURE__ */ _includes(...args));
3470
- },
3471
- startsWith(...args) {
3472
- return this.check(/* @__PURE__ */ _startsWith(...args));
3473
- },
3474
- endsWith(...args) {
3475
- return this.check(/* @__PURE__ */ _endsWith(...args));
3476
- },
3477
- min(...args) {
3478
- return this.check(/* @__PURE__ */ _minLength(...args));
3479
- },
3480
- max(...args) {
3481
- return this.check(/* @__PURE__ */ _maxLength(...args));
3482
- },
3483
- length(...args) {
3484
- return this.check(/* @__PURE__ */ _length(...args));
3485
- },
3486
- nonempty(...args) {
3487
- return this.check(/* @__PURE__ */ _minLength(1, ...args));
3488
- },
3489
- lowercase(params) {
3490
- return this.check(/* @__PURE__ */ _lowercase(params));
3491
- },
3492
- uppercase(params) {
3493
- return this.check(/* @__PURE__ */ _uppercase(params));
3494
- },
3495
- trim() {
3496
- return this.check(/* @__PURE__ */ _trim());
3497
- },
3498
- normalize(...args) {
3499
- return this.check(/* @__PURE__ */ _normalize(...args));
3500
- },
3501
- toLowerCase() {
3502
- return this.check(/* @__PURE__ */ _toLowerCase());
3503
- },
3504
- toUpperCase() {
3505
- return this.check(/* @__PURE__ */ _toUpperCase());
3506
- },
3507
- slugify() {
3508
- return this.check(/* @__PURE__ */ _slugify());
3509
- }
3510
- });
3511
- });
4581
+ }, /*@__PURE__*/ derived({
4582
+ format: (inst) => aggregateChecks(inst).format ?? null,
4583
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
4584
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null
4585
+ }, {
4586
+ regex(...args) {
4587
+ return this.check(/* @__PURE__ */ _regex(...args));
4588
+ },
4589
+ includes(...args) {
4590
+ return this.check(/* @__PURE__ */ _includes(...args));
4591
+ },
4592
+ startsWith(...args) {
4593
+ return this.check(/* @__PURE__ */ _startsWith(...args));
4594
+ },
4595
+ endsWith(...args) {
4596
+ return this.check(/* @__PURE__ */ _endsWith(...args));
4597
+ },
4598
+ min(...args) {
4599
+ return this.check(/* @__PURE__ */ _minLength(...args));
4600
+ },
4601
+ max(...args) {
4602
+ return this.check(/* @__PURE__ */ _maxLength(...args));
4603
+ },
4604
+ length(...args) {
4605
+ return this.check(/* @__PURE__ */ _length(...args));
4606
+ },
4607
+ nonempty(...args) {
4608
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
4609
+ },
4610
+ lowercase(params) {
4611
+ return this.check(/* @__PURE__ */ _lowercase(params));
4612
+ },
4613
+ uppercase(params) {
4614
+ return this.check(/* @__PURE__ */ _uppercase(params));
4615
+ },
4616
+ trim() {
4617
+ return this.check(/* @__PURE__ */ _trim());
4618
+ },
4619
+ normalize(...args) {
4620
+ return this.check(/* @__PURE__ */ _normalize(...args));
4621
+ },
4622
+ toLowerCase() {
4623
+ return this.check(/* @__PURE__ */ _toLowerCase());
4624
+ },
4625
+ toUpperCase() {
4626
+ return this.check(/* @__PURE__ */ _toUpperCase());
4627
+ },
4628
+ slugify() {
4629
+ return this.check(/* @__PURE__ */ _slugify());
4630
+ }
4631
+ }));
3512
4632
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3513
4633
  $ZodString.init(inst, def);
3514
4634
  _ZodString.init(inst, def);
3515
- inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3516
- inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3517
- inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3518
- inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3519
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3520
- inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3521
- inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3522
- inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3523
- inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3524
- inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3525
- inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3526
- inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3527
- inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3528
- inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3529
- inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3530
- inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3531
- inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3532
- inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3533
- inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3534
- inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3535
- inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3536
- inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3537
- inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3538
- inst.datetime = (params) => inst.check(datetime(params));
3539
- inst.date = (params) => inst.check(date(params));
3540
- inst.time = (params) => inst.check(time(params));
3541
- inst.duration = (params) => inst.check(duration(params));
4635
+ }, {
4636
+ email(params) {
4637
+ return this.check(/* @__PURE__ */ _email(ZodEmail, params));
4638
+ },
4639
+ url(params) {
4640
+ return this.check(/* @__PURE__ */ _url(ZodURL, params));
4641
+ },
4642
+ jwt(params) {
4643
+ return this.check(/* @__PURE__ */ _jwt(ZodJWT, params));
4644
+ },
4645
+ emoji(params) {
4646
+ return this.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
4647
+ },
4648
+ guid(params) {
4649
+ return this.check(/* @__PURE__ */ _guid(ZodGUID, params));
4650
+ },
4651
+ uuid(params) {
4652
+ return this.check(/* @__PURE__ */ _uuid(ZodUUID, params));
4653
+ },
4654
+ uuidv4(params) {
4655
+ return this.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
4656
+ },
4657
+ uuidv6(params) {
4658
+ return this.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
4659
+ },
4660
+ uuidv7(params) {
4661
+ return this.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
4662
+ },
4663
+ nanoid(params) {
4664
+ return this.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
4665
+ },
4666
+ cuid(params) {
4667
+ return this.check(/* @__PURE__ */ _cuid(ZodCUID, params));
4668
+ },
4669
+ cuid2(params) {
4670
+ return this.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
4671
+ },
4672
+ ulid(params) {
4673
+ return this.check(/* @__PURE__ */ _ulid(ZodULID, params));
4674
+ },
4675
+ base64(params) {
4676
+ return this.check(/* @__PURE__ */ _base64(ZodBase64, params));
4677
+ },
4678
+ base64url(params) {
4679
+ return this.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
4680
+ },
4681
+ xid(params) {
4682
+ return this.check(/* @__PURE__ */ _xid(ZodXID, params));
4683
+ },
4684
+ ksuid(params) {
4685
+ return this.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
4686
+ },
4687
+ ipv4(params) {
4688
+ return this.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
4689
+ },
4690
+ ipv6(params) {
4691
+ return this.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
4692
+ },
4693
+ cidrv4(params) {
4694
+ return this.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
4695
+ },
4696
+ cidrv6(params) {
4697
+ return this.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
4698
+ },
4699
+ e164(params) {
4700
+ return this.check(/* @__PURE__ */ _e164(ZodE164, params));
4701
+ },
4702
+ datetime(params) {
4703
+ return this.check(/* @__PURE__ */ _isoDateTime(ZodISODateTime, params));
4704
+ },
4705
+ date(params) {
4706
+ return this.check(/* @__PURE__ */ _isoDate(ZodISODate, params));
4707
+ },
4708
+ time(params) {
4709
+ return this.check(/* @__PURE__ */ _isoTime(ZodISOTime, params));
4710
+ },
4711
+ duration(params) {
4712
+ return this.check(/* @__PURE__ */ _isoDuration(ZodISODuration, params));
4713
+ }
3542
4714
  });
3543
4715
  function string(params) {
3544
4716
  return /* @__PURE__ */ _string(ZodString, params);
@@ -3547,6 +4719,22 @@ const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def
3547
4719
  $ZodStringFormat.init(inst, def);
3548
4720
  _ZodString.init(inst, def);
3549
4721
  });
4722
+ const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4723
+ $ZodISODateTime.init(inst, def);
4724
+ ZodStringFormat.init(inst, def);
4725
+ });
4726
+ const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
4727
+ $ZodISODate.init(inst, def);
4728
+ ZodStringFormat.init(inst, def);
4729
+ });
4730
+ const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
4731
+ $ZodISOTime.init(inst, def);
4732
+ ZodStringFormat.init(inst, def);
4733
+ });
4734
+ const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
4735
+ $ZodISODuration.init(inst, def);
4736
+ ZodStringFormat.init(inst, def);
4737
+ });
3550
4738
  const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3551
4739
  $ZodEmail.init(inst, def);
3552
4740
  ZodStringFormat.init(inst, def);
@@ -3645,94 +4833,80 @@ function never(params) {
3645
4833
  return /* @__PURE__ */ _never(ZodNever, params);
3646
4834
  }
3647
4835
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4836
+ _ensureDefaultMemoizer();
3648
4837
  $ZodArray.init(inst, def);
3649
4838
  ZodType.init(inst, def);
3650
4839
  inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3651
4840
  inst.element = def.element;
3652
- _installLazyMethods(inst, "ZodArray", {
3653
- min(n, params) {
3654
- return this.check(/* @__PURE__ */ _minLength(n, params));
3655
- },
3656
- nonempty(params) {
3657
- return this.check(/* @__PURE__ */ _minLength(1, params));
3658
- },
3659
- max(n, params) {
3660
- return this.check(/* @__PURE__ */ _maxLength(n, params));
3661
- },
3662
- length(n, params) {
3663
- return this.check(/* @__PURE__ */ _length(n, params));
3664
- },
3665
- unwrap() {
3666
- return this.element;
3667
- }
3668
- });
4841
+ }, {
4842
+ min(n, params) {
4843
+ return this.check(/* @__PURE__ */ _minLength(n, params));
4844
+ },
4845
+ nonempty(params) {
4846
+ return this.check(/* @__PURE__ */ _minLength(1, params));
4847
+ },
4848
+ max(n, params) {
4849
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
4850
+ },
4851
+ length(n, params) {
4852
+ return this.check(/* @__PURE__ */ _length(n, params));
4853
+ },
4854
+ unwrap() {
4855
+ return this.element;
4856
+ }
3669
4857
  });
3670
4858
  function array(element, params) {
3671
4859
  return /* @__PURE__ */ _array(ZodArray, element, params);
3672
4860
  }
3673
4861
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4862
+ _ensureDefaultMemoizer();
3674
4863
  $ZodObjectJIT.init(inst, def);
3675
4864
  ZodType.init(inst, def);
3676
4865
  inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3677
- defineLazy(inst, "shape", () => {
3678
- return def.shape;
3679
- });
3680
- _installLazyMethods(inst, "ZodObject", {
3681
- keyof() {
3682
- return _enum(Object.keys(this._zod.def.shape));
3683
- },
3684
- catchall(catchall) {
3685
- return this.clone({
3686
- ...this._zod.def,
3687
- catchall
3688
- });
3689
- },
3690
- passthrough() {
3691
- return this.clone({
3692
- ...this._zod.def,
3693
- catchall: unknown()
3694
- });
3695
- },
3696
- loose() {
3697
- return this.clone({
3698
- ...this._zod.def,
3699
- catchall: unknown()
3700
- });
3701
- },
3702
- strict() {
3703
- return this.clone({
3704
- ...this._zod.def,
3705
- catchall: never()
3706
- });
3707
- },
3708
- strip() {
3709
- return this.clone({
3710
- ...this._zod.def,
3711
- catchall: void 0
3712
- });
3713
- },
3714
- extend(incoming) {
3715
- return extend(this, incoming);
3716
- },
3717
- safeExtend(incoming) {
3718
- return safeExtend(this, incoming);
3719
- },
3720
- merge(other) {
3721
- return merge(this, other);
3722
- },
3723
- pick(mask) {
3724
- return pick(this, mask);
3725
- },
3726
- omit(mask) {
3727
- return omit(this, mask);
3728
- },
3729
- partial(...args) {
3730
- return partial(ZodOptional, this, args[0]);
3731
- },
3732
- required(...args) {
3733
- return required(ZodNonOptional, this, args[0]);
3734
- }
3735
- });
4866
+ installLazyProp(inst, "shape", (self) => self._zod.def.shape, false);
4867
+ }, {
4868
+ keyof() {
4869
+ return _enum(Object.keys(this._zod.def.shape));
4870
+ },
4871
+ catchall(catchall) {
4872
+ return this.clone(mergeDefs(this._zod.def, { catchall }));
4873
+ },
4874
+ passthrough() {
4875
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4876
+ },
4877
+ loose() {
4878
+ return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
4879
+ },
4880
+ strict() {
4881
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
4882
+ },
4883
+ strip() {
4884
+ return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
4885
+ },
4886
+ extend(incoming) {
4887
+ return extend(this, incoming);
4888
+ },
4889
+ safeExtend(incoming) {
4890
+ return safeExtend(this, incoming);
4891
+ },
4892
+ merge(other) {
4893
+ return merge(this, other);
4894
+ },
4895
+ pick(mask) {
4896
+ return pick(this, mask);
4897
+ },
4898
+ omit(mask) {
4899
+ return omit(this, mask);
4900
+ },
4901
+ partial(...args) {
4902
+ return partial(ZodOptional, this, args[0]);
4903
+ },
4904
+ exactPartial(...args) {
4905
+ return partial(ZodExactOptional, this, args[0], "exactPartial");
4906
+ },
4907
+ required(...args) {
4908
+ return required(ZodNonOptional, this, args[0]);
4909
+ }
3736
4910
  });
3737
4911
  function object(shape, params) {
3738
4912
  const def = {
@@ -3772,7 +4946,7 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3772
4946
  ZodType.init(inst, def);
3773
4947
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3774
4948
  inst.enum = def.entries;
3775
- inst.options = Object.values(def.entries);
4949
+ inst.options = [...inst._zod.values];
3776
4950
  const keys = new Set(Object.keys(def.entries));
3777
4951
  inst.extract = (values, params) => {
3778
4952
  const newEntries = {};
@@ -3806,6 +4980,7 @@ function _enum(values, params) {
3806
4980
  });
3807
4981
  }
3808
4982
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4983
+ _ensureDefaultMemoizer();
3809
4984
  $ZodTransform.init(inst, def);
3810
4985
  ZodType.init(inst, def);
3811
4986
  inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
@@ -3817,7 +4992,7 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3817
4992
  const _issue = issue$1;
3818
4993
  if (_issue.fatal) _issue.continue = false;
3819
4994
  _issue.code ?? (_issue.code = "custom");
3820
- _issue.input ?? (_issue.input = payload.value);
4995
+ if (!("input" in _issue)) _issue.input = payload.value;
3821
4996
  _issue.inst ?? (_issue.inst = inst);
3822
4997
  payload.issues.push(issue(_issue));
3823
4998
  }
@@ -3825,11 +5000,9 @@ const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3825
5000
  const output = def.transform(payload.value, payload);
3826
5001
  if (output instanceof Promise) return output.then((output) => {
3827
5002
  payload.value = output;
3828
- payload.fallback = true;
3829
5003
  return payload;
3830
5004
  });
3831
5005
  payload.value = output;
3832
- payload.fallback = true;
3833
5006
  return payload;
3834
5007
  };
3835
5008
  });
@@ -3930,7 +5103,7 @@ function _catch(innerType, catchValue) {
3930
5103
  return new ZodCatch({
3931
5104
  type: "catch",
3932
5105
  innerType,
3933
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
5106
+ catchValue: typeof catchValue === "function" ? catchValue : constantCatch(catchValue)
3934
5107
  });
3935
5108
  }
3936
5109
  const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {