@lousy-agents/agent-shell 5.22.13 → 5.22.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1882 -1323
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1587,7 +1587,11 @@ function safeRealpathSync(targetPath, cache) {
1587
1587
  return cached;
1588
1588
  }
1589
1589
  try {
1590
- const resolved = realpathSync(pathForWindowsFilesystem(targetPath));
1590
+ const ordinary = realpathSync(pathForWindowsFilesystem(targetPath));
1591
+ // Ordinary resolution keeps the caller's letter case. Its result has no symlinks or
1592
+ // dot segments left, so native resolution on POSIX only adopts the on-disk spelling
1593
+ // that root admission compares against. Windows root admission reconciles aliases.
1594
+ const resolved = process.platform === "win32" ? ordinary : realpathSync.native(ordinary);
1591
1595
  cache?.set(targetPath, resolved);
1592
1596
  cache?.set(resolved, resolved);
1593
1597
  return resolved;
@@ -3787,16 +3791,16 @@ const WORLD_SIDS = new Set([
3787
3791
  function windows_security_facts_unverified(message, cause) {
3788
3792
  throw new errors_FsSafeError("permission-unverified", message, cause === undefined ? {} : { cause });
3789
3793
  }
3790
- function record(value) {
3794
+ function windows_security_facts_record(value) {
3791
3795
  return value !== null && typeof value === "object" && !Array.isArray(value);
3792
3796
  }
3793
3797
  function uint32(value) {
3794
3798
  return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 0xffff_ffff;
3795
3799
  }
3796
3800
  function validateAce(value, allowUnknownFlags) {
3797
- if (!record(value) || typeof value.sid !== "string" || !SID_RE.test(value.sid) ||
3801
+ if (!windows_security_facts_record(value) || typeof value.sid !== "string" || !SID_RE.test(value.sid) ||
3798
3802
  !uint32(value.mask) || (value.aceType !== "allow" && value.aceType !== "deny") ||
3799
- !record(value.flags))
3803
+ !windows_security_facts_record(value.flags))
3800
3804
  return false;
3801
3805
  const { raw } = value.flags;
3802
3806
  if (!uint32(raw) || (raw & ~(allowUnknownFlags ? 0xff : 0xdf)) !== 0)
@@ -3810,10 +3814,11 @@ function validateAce(value, allowUnknownFlags) {
3810
3814
  return fields.every(([field, bit]) => typeof flags[field] === "boolean" && flags[field] === ((raw & bit) !== 0));
3811
3815
  }
3812
3816
  function validateDescriptor(value, allowUnknownFlags) {
3813
- if (!record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
3817
+ if (!windows_security_facts_record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
3814
3818
  typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
3815
3819
  (value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
3816
3820
  typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
3821
+ (value.isVolumeRoot !== undefined && typeof value.isVolumeRoot !== "boolean") ||
3817
3822
  typeof value.aceListComplete !== "boolean" || !Array.isArray(value.unsupportedAceTypes) ||
3818
3823
  !value.unsupportedAceTypes.every(uint32) || !Array.isArray(value.aces) ||
3819
3824
  !value.aces.every(ace => validateAce(ace, allowUnknownFlags))) {
@@ -3860,7 +3865,7 @@ function summarize(facts) {
3860
3865
  /** Raw reporting retains unknown flag bits; secure admission validates them below. */
3861
3866
  function windows_security_facts_parseWindowsSecurityCommandFacts(value) {
3862
3867
  const facts = validateDescriptor(value, true);
3863
- if (!record(value) || typeof value.daclProtected !== "boolean") {
3868
+ if (!windows_security_facts_record(value) || typeof value.daclProtected !== "boolean") {
3864
3869
  windows_security_facts_unverified("Windows security command returned malformed descriptor facts");
3865
3870
  }
3866
3871
  return {
@@ -12212,9 +12217,14 @@ const onCopySourceAdmission = Symbol("onCopySourceAdmission");
12212
12217
 
12213
12218
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/file-sync.js
12214
12219
 
12220
+ function syncFile(handle) {
12221
+ return typeof handle === "number"
12222
+ ? new Promise((resolve, reject) => external_node_fs_namespaceObject.fsync(handle, error => error ? reject(error) : resolve()))
12223
+ : handle.sync();
12224
+ }
12215
12225
  async function syncFileBestEffort(handle) {
12216
12226
  try {
12217
- await handle.sync();
12227
+ await syncFile(handle);
12218
12228
  }
12219
12229
  catch (error) {
12220
12230
  if (error?.code !== "EPERM")
@@ -12920,6 +12930,7 @@ class NativeStagedFile {
12920
12930
  #verifyMode;
12921
12931
  #state = { status: "open", publication: NOT_PUBLISHED };
12922
12932
  #receipt;
12933
+ #publicationFlush;
12923
12934
  #rejectFinalSymlink = false;
12924
12935
  #unsupportedNoReplace;
12925
12936
  #fallbackCleanup;
@@ -12956,8 +12967,7 @@ class NativeStagedFile {
12956
12967
  const env_1 = { stack: [], error: void 0, hasError: false };
12957
12968
  try {
12958
12969
  const exclusive = params.overwrite === false && params.input.kind === "buffer" && params.input.stageBeforePublish === false;
12959
- // This owner never escapes. Only the internal verifier borrows its fd;
12960
- // public descriptor methods remain await-free and cannot race disposal.
12970
+ // This owner never escapes; only the internal verifier borrows its fd.
12961
12971
  const staged = native_staged_file_addDisposableResource(env_1, await NativeStagedFile.create({
12962
12972
  binding, parentFd, closeParentFd, directory, mode: params.mode, sync: params.sync,
12963
12973
  // Public staging uses portable names; existing POSIX writes accept literal names.
@@ -12976,9 +12986,10 @@ class NativeStagedFile {
12976
12986
  }
12977
12987
  let published;
12978
12988
  try {
12979
- published = exclusive
12989
+ const publication = exclusive
12980
12990
  ? staged.#completePublication(params.basename, false, params.onPublished)
12981
- : await staged.publish(params.basename, { overwrite: params.overwrite !== false }, params.onPublished);
12991
+ : staged.publish(params.basename, { overwrite: params.overwrite !== false }, params.onPublished);
12992
+ published = publication instanceof Promise ? await publication : publication;
12982
12993
  }
12983
12994
  catch (error) {
12984
12995
  if (!staged.#unsupportedNoReplace || isFsSafeNativeRequired() ||
@@ -13141,29 +13152,21 @@ class NativeStagedFile {
13141
13152
  restoreCopyMetadata(fd, input.metadata);
13142
13153
  if (this.#verifyMode)
13143
13154
  this.#assertStagePermissions(fd);
13144
- if (this.#owner.sync !== false) {
13145
- if (this.#owner.strictFileSync)
13146
- external_node_fs_namespaceObject.fsyncSync(fd);
13147
- else
13148
- syncFileBestEffortSync(fd);
13149
- }
13155
+ if (this.#owner.sync !== false)
13156
+ await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
13150
13157
  const stat = external_node_fs_namespaceObject.fstatSync(fd, { bigint: true });
13151
13158
  this.#receipt = createStagedFileReceipt(this.#owner.directory, this.#owner.name, stat);
13152
13159
  this.#assertCurrent();
13153
13160
  }
13154
13161
  catch (error) {
13155
13162
  const { receipt: cleanup, error: cleanupError } = this.#finalize();
13156
- if (cleanupError) {
13157
- throw stagedFailure("file", new AggregateError([error, cleanupError], "preparation and cleanup failed"), { phase: "prepare", publication: cleanup.publication, cleanup });
13158
- }
13159
- if (cleanup.status === "preserved") {
13160
- throw stagedFailure("file", error, { phase: "prepare", publication: cleanup.publication, cleanup });
13163
+ if (cleanupError || cleanup.status === "preserved") {
13164
+ throw stagedFailure("file", cleanupError
13165
+ ? new AggregateError([error, cleanupError], "preparation and cleanup failed") : error, { phase: "prepare", publication: cleanup.publication, cleanup });
13161
13166
  }
13162
13167
  throw error;
13163
13168
  }
13164
13169
  }
13165
- // Keep public descriptor work await-free: each call completes its mutations
13166
- // before the next invocation, including closure and cached cleanup failures.
13167
13170
  async assertCurrent() {
13168
13171
  this.#assertCurrent();
13169
13172
  }
@@ -13208,7 +13211,8 @@ class NativeStagedFile {
13208
13211
  }
13209
13212
  throw error;
13210
13213
  }
13211
- return this.#completePublication(basename, overwrite, onPublished);
13214
+ const publication = this.#completePublication(basename, overwrite, onPublished);
13215
+ return publication instanceof Promise ? await publication : publication;
13212
13216
  }
13213
13217
  catch (error) {
13214
13218
  if (isMutationAuthorityError(error))
@@ -13234,17 +13238,21 @@ class NativeStagedFile {
13234
13238
  external_node_fs_namespaceObject.fchmodSync(fd, this.#owner.mode);
13235
13239
  // Content was synced during preparation. A lost chmod leaves 0600, no wider
13236
13240
  // than modes retaining owner rw; restrictive modes still need a durable correction.
13237
- if (this.#owner.sync !== false && ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0)) {
13238
- if (this.#owner.strictFileSync)
13239
- external_node_fs_namespaceObject.fsyncSync(fd);
13240
- else
13241
- syncFileBestEffortSync(fd);
13242
- }
13243
- if (this.#owner.sync !== false)
13244
- syncFileBestEffortSync(this.#owner.parentFd);
13245
- this.#assertNamed(basename, this.#owner.mode);
13246
- this.#assertDirectory();
13247
- return receipt;
13241
+ const verify = () => {
13242
+ this.#assertNamed(basename, this.#owner.mode);
13243
+ this.#assertDirectory();
13244
+ return receipt;
13245
+ };
13246
+ if (this.#owner.sync === false)
13247
+ return verify();
13248
+ this.#publicationFlush = Promise.resolve().then(async () => {
13249
+ if ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0) {
13250
+ await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
13251
+ }
13252
+ await syncFileBestEffort(this.#owner.parentFd);
13253
+ return verify();
13254
+ }).finally(() => { this.#publicationFlush = undefined; });
13255
+ return this.#publicationFlush;
13248
13256
  }
13249
13257
  #finalize() {
13250
13258
  if (this.#state.status === "closed") {
@@ -13299,6 +13307,9 @@ class NativeStagedFile {
13299
13307
  return this.#state;
13300
13308
  }
13301
13309
  async cleanup() {
13310
+ // Native descriptors cannot close or be recycled while libuv is synchronizing them.
13311
+ if (this.#publicationFlush)
13312
+ await this.#publicationFlush.catch(() => { });
13302
13313
  const closed = this.#finalize();
13303
13314
  if (closed.error) {
13304
13315
  throw closed.error;
@@ -22262,18 +22273,23 @@ function jsonStringifyReplacer(_, value) {
22262
22273
  return value.toString();
22263
22274
  return value;
22264
22275
  }
22276
+ // the accessor lives on a shared prototype: an own accessor makes every box a dictionary-mode object (~360 B and a slow load per read against ~100 B and an inlined getter here)
22277
+ class Cached {
22278
+ constructor(getter) {
22279
+ this._getter = getter;
22280
+ this._value = undefined;
22281
+ }
22282
+ get value() {
22283
+ const getter = this._getter;
22284
+ if (getter !== undefined) {
22285
+ this._value = getter();
22286
+ this._getter = undefined;
22287
+ }
22288
+ return this._value;
22289
+ }
22290
+ }
22265
22291
  function util_cached(getter) {
22266
- const set = false;
22267
- return {
22268
- get value() {
22269
- if (!set) {
22270
- const value = getter();
22271
- Object.defineProperty(this, "value", { value });
22272
- return value;
22273
- }
22274
- throw new Error("cached value already set");
22275
- },
22276
- };
22292
+ return new Cached(getter);
22277
22293
  }
22278
22294
  function nullish(input) {
22279
22295
  return input === null || input === undefined;
@@ -22328,6 +22344,71 @@ function util_assignProp(target, prop, value) {
22328
22344
  configurable: true,
22329
22345
  });
22330
22346
  }
22347
+ /**
22348
+ * Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
22349
+ *
22350
+ * 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.
22351
+ */
22352
+ function rawShape(def) {
22353
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
22354
+ return desc?.get ? desc.get.raw : desc?.value;
22355
+ }
22356
+ // where a builder reads its source's keys and descriptors, resolving only a shape a def answers for itself. A shape resolves by object spread, so only its enumerable keys are ever part of it.
22357
+ function sourceShape(schema) {
22358
+ return rawShape(schema._zod.def) ?? schema._zod.def.shape;
22359
+ }
22360
+ // a key whose value is not settled yet, self-caching so every read after the first gets the same one
22361
+ function deferProp(target, key, getter) {
22362
+ Object.defineProperty(target, key, {
22363
+ get() {
22364
+ const value = getter();
22365
+ util_assignProp(this, key, value);
22366
+ return value;
22367
+ },
22368
+ enumerable: true,
22369
+ configurable: true,
22370
+ });
22371
+ }
22372
+ // Writes a settled key. A plain assignment is much cheaper than `defineProperty` and produces the same descriptor, but it runs whatever setter already answers to the key — an accessor this shape deferred, or an inherited one, which `__proto__` has on every object and prototype pollution can add for any name.
22373
+ function putProp(target, key, value) {
22374
+ if (key in target)
22375
+ util_assignProp(target, key, value);
22376
+ else
22377
+ target[key] = value;
22378
+ }
22379
+ /**
22380
+ * Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
22381
+ *
22382
+ * 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.
22383
+ */
22384
+ function mirrorShape(target, source, keys, wrap) {
22385
+ const raw = sourceShape(source);
22386
+ for (const key of keys) {
22387
+ const desc = Object.getOwnPropertyDescriptor(raw, key);
22388
+ if (!desc.enumerable)
22389
+ continue;
22390
+ if (desc.get) {
22391
+ deferProp(target, key, () => {
22392
+ const value = source._zod.def.shape[key];
22393
+ return wrap ? wrap(value, key) : value;
22394
+ });
22395
+ }
22396
+ else
22397
+ putProp(target, key, wrap ? wrap(desc.value, key) : desc.value);
22398
+ }
22399
+ }
22400
+ // same, for a plain shape a caller passed rather than a schema's
22401
+ function mirrorProps(target, source) {
22402
+ for (const key of Reflect.ownKeys(source)) {
22403
+ const desc = Object.getOwnPropertyDescriptor(source, key);
22404
+ if (!desc.enumerable)
22405
+ continue;
22406
+ if (desc.get)
22407
+ deferProp(target, key, () => source[key]);
22408
+ else
22409
+ putProp(target, key, desc.value);
22410
+ }
22411
+ }
22331
22412
  function mergeDefs(...defs) {
22332
22413
  const mergedDescriptors = {};
22333
22414
  for (const def of defs) {
@@ -22579,24 +22660,23 @@ function pick(schema, mask) {
22579
22660
  if (hasChecks) {
22580
22661
  throw new Error(".pick() cannot be used on object schemas containing refinements");
22581
22662
  }
22582
- const def = mergeDefs(schema._zod.def, {
22583
- get shape() {
22584
- const newShape = {};
22585
- // `for...in` skips symbols, so a symbol in the mask would select nothing
22586
- for (const key of Reflect.ownKeys(mask)) {
22587
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
22588
- throw new Error(`Unrecognized key: "${String(key)}"`);
22589
- }
22590
- if (!mask[key])
22591
- continue;
22592
- util_assignProp(newShape, key, currDef.shape[key]);
22593
- }
22594
- util_assignProp(this, "shape", newShape); // self-caching
22595
- return newShape;
22596
- },
22597
- checks: [],
22598
- });
22599
- return util_clone(schema, def);
22663
+ const newShape = {};
22664
+ mirrorShape(newShape, schema, maskedKeys(schema, mask));
22665
+ return util_clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
22666
+ }
22667
+ // the mask keys that select something, checked against the source's shape without resolving it
22668
+ function maskedKeys(schema, mask) {
22669
+ const raw = sourceShape(schema);
22670
+ const keys = [];
22671
+ // `for...in` skips symbols, so a symbol in the mask would select nothing
22672
+ for (const key of Reflect.ownKeys(mask)) {
22673
+ if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
22674
+ throw new Error(`Unrecognized key: "${String(key)}"`);
22675
+ }
22676
+ if (mask[key])
22677
+ keys.push(key);
22678
+ }
22679
+ return keys;
22600
22680
  }
22601
22681
  function omit(schema, mask) {
22602
22682
  const currDef = schema._zod.def;
@@ -22605,23 +22685,10 @@ function omit(schema, mask) {
22605
22685
  if (hasChecks) {
22606
22686
  throw new Error(".omit() cannot be used on object schemas containing refinements");
22607
22687
  }
22608
- const def = mergeDefs(schema._zod.def, {
22609
- get shape() {
22610
- const newShape = { ...schema._zod.def.shape };
22611
- for (const key of Reflect.ownKeys(mask)) {
22612
- if (!Object.prototype.hasOwnProperty.call(currDef.shape, key)) {
22613
- throw new Error(`Unrecognized key: "${String(key)}"`);
22614
- }
22615
- if (!mask[key])
22616
- continue;
22617
- delete newShape[key];
22618
- }
22619
- util_assignProp(this, "shape", newShape); // self-caching
22620
- return newShape;
22621
- },
22622
- checks: [],
22623
- });
22624
- return util_clone(schema, def);
22688
+ const omitted = new Set(maskedKeys(schema, mask));
22689
+ const newShape = {};
22690
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)).filter((key) => !omitted.has(key)));
22691
+ return util_clone(schema, mergeDefs(currDef, { shape: newShape, checks: [] }));
22625
22692
  }
22626
22693
  function extend(schema, shape) {
22627
22694
  if (!isPlainObject(shape)) {
@@ -22631,48 +22698,40 @@ function extend(schema, shape) {
22631
22698
  const hasChecks = checks && checks.length > 0;
22632
22699
  if (hasChecks) {
22633
22700
  // Only throw if new shape overlaps with existing shape. Use getOwnPropertyDescriptor to check key existence without accessing values
22634
- const existingShape = schema._zod.def.shape;
22701
+ const existingShape = sourceShape(schema);
22635
22702
  for (const key of Reflect.ownKeys(shape)) {
22636
22703
  if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
22637
22704
  throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
22638
22705
  }
22639
22706
  }
22640
22707
  }
22641
- const def = mergeDefs(schema._zod.def, {
22642
- get shape() {
22643
- const _shape = { ...schema._zod.def.shape, ...shape };
22644
- util_assignProp(this, "shape", _shape); // self-caching
22645
- return _shape;
22646
- },
22647
- });
22648
- return util_clone(schema, def);
22708
+ return util_clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
22709
+ }
22710
+ // the source's keys, then the caller's overlaid on top
22711
+ function extended(schema, shape) {
22712
+ const newShape = {};
22713
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)));
22714
+ mirrorProps(newShape, shape);
22715
+ return newShape;
22649
22716
  }
22650
22717
  function safeExtend(schema, shape) {
22651
22718
  if (!isPlainObject(shape)) {
22652
22719
  throw new Error("Invalid input to safeExtend: expected a plain object");
22653
22720
  }
22654
- const def = mergeDefs(schema._zod.def, {
22655
- get shape() {
22656
- const _shape = { ...schema._zod.def.shape, ...shape };
22657
- util_assignProp(this, "shape", _shape); // self-caching
22658
- return _shape;
22659
- },
22660
- });
22661
- return util_clone(schema, def);
22721
+ return util_clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
22662
22722
  }
22663
- function merge(a, b) {
22723
+ function util_merge(a, b) {
22664
22724
  if (!b?._zod?.def) {
22665
22725
  throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
22666
22726
  }
22667
22727
  if (a._zod.def.checks?.length) {
22668
22728
  throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
22669
22729
  }
22730
+ const newShape = {};
22731
+ mirrorShape(newShape, a, Reflect.ownKeys(sourceShape(a)));
22732
+ mirrorShape(newShape, b, Reflect.ownKeys(sourceShape(b)));
22670
22733
  const def = mergeDefs(a._zod.def, {
22671
- get shape() {
22672
- const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
22673
- util_assignProp(this, "shape", _shape); // self-caching
22674
- return _shape;
22675
- },
22734
+ shape: newShape,
22676
22735
  get catchall() {
22677
22736
  return b._zod.def.catchall;
22678
22737
  },
@@ -22687,78 +22746,19 @@ function partial(Class, schema, mask, name = "partial") {
22687
22746
  if (hasChecks) {
22688
22747
  throw new Error(`.${name}() cannot be used on object schemas containing refinements`);
22689
22748
  }
22690
- const def = mergeDefs(schema._zod.def, {
22691
- get shape() {
22692
- const oldShape = schema._zod.def.shape;
22693
- const shape = { ...oldShape };
22694
- if (mask) {
22695
- for (const key of Reflect.ownKeys(mask)) {
22696
- if (!Object.prototype.hasOwnProperty.call(oldShape, key)) {
22697
- throw new Error(`Unrecognized key: "${String(key)}"`);
22698
- }
22699
- if (!mask[key])
22700
- continue;
22701
- // if (oldShape[key]!._zod.optin === "optional") continue;
22702
- shape[key] = Class
22703
- ? new Class({
22704
- type: "optional",
22705
- innerType: oldShape[key],
22706
- })
22707
- : oldShape[key];
22708
- }
22709
- }
22710
- else {
22711
- // the spread copies symbol keys; `for...in` would not reach them
22712
- for (const key of Reflect.ownKeys(oldShape)) {
22713
- // if (oldShape[key]!._zod.optin === "optional") continue;
22714
- shape[key] = Class
22715
- ? new Class({
22716
- type: "optional",
22717
- innerType: oldShape[key],
22718
- })
22719
- : oldShape[key];
22720
- }
22721
- }
22722
- util_assignProp(this, "shape", shape); // self-caching
22723
- return shape;
22724
- },
22725
- checks: [],
22726
- });
22727
- return util_clone(schema, def);
22749
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
22750
+ const newShape = {};
22751
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), Class &&
22752
+ ((value, key) => (selected && !selected.has(key) ? value : new Class({ type: "optional", innerType: value }))));
22753
+ return util_clone(schema, mergeDefs(schema._zod.def, { shape: newShape, checks: [] }));
22728
22754
  }
22729
22755
  function util_required(Class, schema, mask) {
22730
- const def = mergeDefs(schema._zod.def, {
22731
- get shape() {
22732
- const oldShape = schema._zod.def.shape;
22733
- const shape = { ...oldShape };
22734
- if (mask) {
22735
- for (const key of Reflect.ownKeys(mask)) {
22736
- if (!Object.prototype.hasOwnProperty.call(shape, key)) {
22737
- throw new Error(`Unrecognized key: "${String(key)}"`);
22738
- }
22739
- if (!mask[key])
22740
- continue;
22741
- // overwrite with non-optional
22742
- shape[key] = new Class({
22743
- type: "nonoptional",
22744
- innerType: oldShape[key],
22745
- });
22746
- }
22747
- }
22748
- else {
22749
- for (const key of Reflect.ownKeys(oldShape)) {
22750
- // overwrite with non-optional
22751
- shape[key] = new Class({
22752
- type: "nonoptional",
22753
- innerType: oldShape[key],
22754
- });
22755
- }
22756
- }
22757
- util_assignProp(this, "shape", shape); // self-caching
22758
- return shape;
22759
- },
22760
- });
22761
- return util_clone(schema, def);
22756
+ const selected = mask ? new Set(maskedKeys(schema, mask)) : undefined;
22757
+ const newShape = {};
22758
+ mirrorShape(newShape, schema, Reflect.ownKeys(sourceShape(schema)), (value, key) =>
22759
+ // overwrite with non-optional
22760
+ selected && !selected.has(key) ? value : new Class({ type: "nonoptional", innerType: value }));
22761
+ return util_clone(schema, mergeDefs(schema._zod.def, { shape: newShape }));
22762
22762
  }
22763
22763
  // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
22764
22764
  function aborted(x, startIndex = 0) {
@@ -22794,6 +22794,20 @@ function unwrapMessage(message) {
22794
22794
  return typeof message === "string" ? message : message?.message;
22795
22795
  }
22796
22796
  /* A check holds no link back to the schema it is attached to — the same check instance is shared by every clone of that schema — so the owner is stamped onto the issues a check just raised, at the only point where both are in scope. Runs on the failure path only; `start` is the issue count from before the check ran. */
22797
+ /** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
22798
+ function sizeCaps(defChecks) {
22799
+ const caps = [];
22800
+ for (const ch of defChecks ?? []) {
22801
+ const d = ch._zod.def;
22802
+ // a later check may rewrite the value
22803
+ if (!/_(length|size)$|_equals$/.test(d.check))
22804
+ break;
22805
+ const max = d.maximum ?? d.length ?? d.size;
22806
+ if (max >= 0)
22807
+ caps.push([max, ch]);
22808
+ }
22809
+ return caps;
22810
+ }
22797
22811
  function attachSchema(issues, start, inst) {
22798
22812
  var _a;
22799
22813
  for (let i = start; i < issues.length; i++) {
@@ -22820,13 +22834,19 @@ function finalizeIssue(iss, ctx, config) {
22820
22834
  unwrapMessage(config.customError?.(iss)) ??
22821
22835
  unwrapMessage(config.localeError?.(iss)) ??
22822
22836
  "Invalid input");
22823
- const { inst: _inst, schema: _schema, continue: _continue, input: _input, ...rest } = iss;
22824
- rest.path ?? (rest.path = []);
22825
- rest.message = message;
22837
+ // an explicit own-key copy beats object rest with excluded keys, which v8 routes through a generic runtime call; Object.keys rather than for-in so an issue pushed with a prototype does not leak inherited keys, and an own __proto__ key is dropped rather than assigned through the setter
22838
+ const full = {};
22839
+ for (const k of Object.keys(iss)) {
22840
+ if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
22841
+ continue;
22842
+ full[k] = iss[k];
22843
+ }
22844
+ full.path ?? (full.path = []);
22845
+ full.message = message;
22826
22846
  if (ctx?.reportInput) {
22827
- rest.input = _input;
22847
+ full.input = iss.input;
22828
22848
  }
22829
- return rest;
22849
+ return full;
22830
22850
  }
22831
22851
  function getSizableOrigin(input) {
22832
22852
  if (input instanceof Set)
@@ -22973,6 +22993,24 @@ function util_own(inst, key, value, enumerable = true) {
22973
22993
  function hide(inst, key, value) {
22974
22994
  return util_own(inst, key, value, false);
22975
22995
  }
22996
+ /** 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. */
22997
+ function derived(computes, table) {
22998
+ for (const key in computes) {
22999
+ const compute = computes[key];
23000
+ // an object literal's accessor is configurable and enumerable, and `members` copies the descriptor as written
23001
+ Object.defineProperty(table, key, {
23002
+ configurable: true,
23003
+ enumerable: true,
23004
+ get() {
23005
+ return util_own(this, key, compute(this));
23006
+ },
23007
+ set(value) {
23008
+ util_own(this, key, value);
23009
+ },
23010
+ });
23011
+ }
23012
+ return table;
23013
+ }
22976
23014
  function defineBound(proto, key, fn) {
22977
23015
  Object.defineProperty(proto, key, {
22978
23016
  configurable: true,
@@ -23139,7 +23177,7 @@ proto, params) {
23139
23177
  _zodDesc.value = undefined;
23140
23178
  }
23141
23179
  }
23142
- if (inst._zod.traits.has(name)) {
23180
+ else if (inst._zod.traits.has(name)) {
23143
23181
  return;
23144
23182
  }
23145
23183
  inst._zod.traits.add(name);
@@ -23222,6 +23260,7 @@ function core_config(newConfig) {
23222
23260
  }
23223
23261
 
23224
23262
  ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/memoizer.js
23263
+
23225
23264
  class $ZodCyclicError extends Error {
23226
23265
  constructor() {
23227
23266
  super(`Cannot parse a reference cycle that closes through a transform`);
@@ -23231,50 +23270,165 @@ class $ZodCyclicError extends Error {
23231
23270
  /** Keyed off the context object every schema in one parse call already shares. */
23232
23271
  const STATE = "~memo";
23233
23272
  const NO_ISSUES = [];
23273
+ // a value a cycle can close through
23274
+ function isRef(value) {
23275
+ return value !== null && typeof value === "object";
23276
+ }
23234
23277
  // Receivers prefix paths in place, so the cache and every hand-out need their own copies.
23235
23278
  function cloneIssues(issues) {
23236
23279
  return issues.map((iss) => (iss.path ? { ...iss, path: iss.path.slice() } : { ...iss }));
23237
23280
  }
23238
23281
  const recursive = /*@__PURE__*/ new WeakMap();
23282
+ /** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
23283
+ const NONE = 0;
23284
+ const ASSUMED = 1;
23285
+ const PROVEN = 2;
23239
23286
  /** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
23240
- function isRecursive(inst, stack) {
23287
+ function isRecursive(inst, stack, resolve) {
23241
23288
  const cached = recursive.get(inst);
23242
23289
  if (cached !== undefined)
23243
- return cached;
23290
+ return cached ? PROVEN : NONE;
23244
23291
  // Relative to the walk in progress, so not cached.
23245
23292
  if (stack.has(inst))
23246
- return true;
23293
+ return PROVEN;
23247
23294
  stack.add(inst);
23248
- let result = false;
23295
+ let result = NONE;
23249
23296
  const check = (child) => {
23250
- if (!result && child?._zod && isRecursive(child, stack))
23251
- result = true;
23297
+ if (result !== PROVEN && child?._zod) {
23298
+ const answer = isRecursive(child, stack, resolve);
23299
+ if (answer > result)
23300
+ result = answer;
23301
+ }
23252
23302
  };
23253
- const def = inst._zod.def;
23254
- if (def.type === "lazy") {
23255
- check(inst._zod.innerType);
23256
- }
23257
- else {
23258
- // $ZodObject redefines `shape` as a non-enumerable accessor, so `for...in` misses it.
23259
- const shape = def.shape;
23260
- // `for...in` skips symbols, so a cycle through a declared symbol key would read as non-recursive
23261
- if (shape)
23262
- for (const key of Reflect.ownKeys(shape))
23263
- check(shape[key]);
23264
- for (const key in def) {
23265
- const value = def[key];
23266
- if (!value || typeof value !== "object")
23303
+ // `Reflect.ownKeys` rather than `Object.keys`, so a cycle through a declared symbol key is still seen
23304
+ const shape = (sh, spread) => {
23305
+ let answer = NONE;
23306
+ for (const key of Reflect.ownKeys(sh)) {
23307
+ const desc = Object.getOwnPropertyDescriptor(sh, key);
23308
+ // an object resolves its shape by spread, so a key it does not enumerate is never parsed; `z.properties` reads every own key and so keeps them all
23309
+ if (spread && !desc.enumerable)
23267
23310
  continue;
23268
- if (value._zod)
23269
- check(value);
23270
- else if (Array.isArray(value))
23271
- for (const el of value)
23272
- check(el);
23311
+ // resolving runs user code, and a factory mints a fresh subtree per read, so an edge the walk can't follow counts as a cycle
23312
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve) : NONE;
23313
+ if (child > answer)
23314
+ answer = child;
23315
+ }
23316
+ return answer;
23317
+ };
23318
+ const merge = (answer) => {
23319
+ if (answer > result)
23320
+ result = answer;
23321
+ };
23322
+ const def = inst._zod.def;
23323
+ const kind = def.type;
23324
+ switch (kind) {
23325
+ case "object": {
23326
+ const raw = rawShape(def);
23327
+ // a def with no raw shape answers `shape` from an accessor of its own, and running that can mint a whole fresh subtree
23328
+ merge(raw ? shape(raw, true) : ASSUMED);
23329
+ check(def.catchall);
23330
+ break;
23331
+ }
23332
+ case "array":
23333
+ check(def.element);
23334
+ break;
23335
+ case "tuple":
23336
+ for (const el of def.items)
23337
+ check(el);
23338
+ check(def.rest);
23339
+ break;
23340
+ case "record":
23341
+ case "map":
23342
+ check(def.keyType);
23343
+ check(def.valueType);
23344
+ break;
23345
+ case "set":
23346
+ check(def.valueType);
23347
+ break;
23348
+ case "union":
23349
+ for (const el of def.options)
23350
+ check(el);
23351
+ break;
23352
+ case "intersection":
23353
+ check(def.left);
23354
+ check(def.right);
23355
+ break;
23356
+ case "optional":
23357
+ case "nullable":
23358
+ case "default":
23359
+ case "prefault":
23360
+ case "catch":
23361
+ case "readonly":
23362
+ case "nonoptional":
23363
+ case "promise":
23364
+ case "success":
23365
+ check(def.innerType);
23366
+ break;
23367
+ case "pipe":
23368
+ check(def.in);
23369
+ check(def.out);
23370
+ break;
23371
+ case "function":
23372
+ check(def.input);
23373
+ check(def.output);
23374
+ break;
23375
+ // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
23376
+ case "lazy": {
23377
+ const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : undefined);
23378
+ // walked with resolution off: one hop sees past the deferral, and a lazy that yields only another unresolved lazy is generative, so it stops there
23379
+ merge(inner ? isRecursive(inner, stack, false) : ASSUMED);
23380
+ break;
23381
+ }
23382
+ // a leaf by choice: `parts` are regex fragments, not data positions
23383
+ case "template_literal":
23384
+ // leaves
23385
+ case "string":
23386
+ case "number":
23387
+ case "int":
23388
+ case "boolean":
23389
+ case "bigint":
23390
+ case "symbol":
23391
+ case "undefined":
23392
+ case "null":
23393
+ case "void":
23394
+ case "never":
23395
+ case "any":
23396
+ case "unknown":
23397
+ case "date":
23398
+ case "nan":
23399
+ case "enum":
23400
+ case "literal":
23401
+ case "file":
23402
+ case "transform":
23403
+ case "custom":
23404
+ break;
23405
+ default: {
23406
+ // a new built-in kind becomes a compile error here
23407
+ kind;
23408
+ // a user-defined kind can still hold children, and only its author knows where, so fall back to scanning the def — skipping accessors, since reading one can run user code
23409
+ for (const key in def) {
23410
+ const desc = Object.getOwnPropertyDescriptor(def, key);
23411
+ if (!desc || desc.get)
23412
+ continue;
23413
+ const value = desc.value;
23414
+ if (!value || typeof value !== "object")
23415
+ continue;
23416
+ if (value._zod)
23417
+ check(value);
23418
+ else if (Array.isArray(value))
23419
+ for (const el of value)
23420
+ check(el);
23421
+ }
23273
23422
  }
23274
23423
  }
23275
23424
  stack.delete(inst);
23276
- recursive.set(inst, result);
23277
- return result;
23425
+ return settle(inst, result);
23426
+ }
23427
+ /** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
23428
+ function settle(inst, answer) {
23429
+ if (answer !== ASSUMED)
23430
+ recursive.set(inst, answer === PROVEN);
23431
+ return answer;
23278
23432
  }
23279
23433
  /**
23280
23434
  * Whether one parse can re-enter this schema, i.e. its subtree contains a cycle.
@@ -23283,12 +23437,13 @@ function isRecursive(inst, stack) {
23283
23437
  * generated fast path has no context to key on.
23284
23438
  */
23285
23439
  function isRecursiveSchema(inst) {
23286
- return isRecursive(inst, new Set());
23440
+ // z.compile never parses, so nothing would ever resolve a lazy for it; it runs once and already treats a throw here as recursive
23441
+ return isRecursive(inst, new Set(), true) !== NONE;
23287
23442
  }
23288
23443
  function bucketFor(state, inst) {
23289
23444
  let bucket = state.buckets.get(inst);
23290
23445
  if (!bucket) {
23291
- bucket = new Map();
23446
+ bucket = new WeakMap();
23292
23447
  state.buckets.set(inst, bucket);
23293
23448
  }
23294
23449
  return bucket;
@@ -23327,7 +23482,8 @@ const memoizer_memo = {
23327
23482
  attach(inst) {
23328
23483
  var _a;
23329
23484
  let isRecursiveInst;
23330
- // `bucket` memoized for one parse; a recursive schema is re-entered many times and its bucket never changes
23485
+ let rechecked = false;
23486
+ // a recursive schema is re-entered many times per parse and its bucket never changes
23331
23487
  let lastCtx;
23332
23488
  let lastBucket;
23333
23489
  // Wraps `parse` in a deferred so it sees the container's final parse. Core's own deferred copies `parse` into `run` when there are no checks, and it ran first, so `run` is patched to match; with checks, `run` reads `parse` dynamically.
@@ -23336,21 +23492,26 @@ const memoizer_memo = {
23336
23492
  const base = inst._zod.parse;
23337
23493
  const wrapped = (payload, ctx) => {
23338
23494
  if (isRecursiveInst === undefined) {
23339
- isRecursiveInst = isRecursive(inst, new Set());
23340
- if (!isRecursiveInst) {
23495
+ const walked = isRecursive(inst, new Set(), false);
23496
+ if (walked === NONE) {
23341
23497
  // Nothing here can ever fire, so take it back out.
23342
23498
  inst._zod.parse = base;
23343
23499
  if (inst._zod.run === wrapped)
23344
23500
  inst._zod.run = base;
23345
23501
  return base(payload, ctx);
23346
23502
  }
23503
+ // this parse resolves the deferred edges on its own path, so ask once more before latching
23504
+ if (walked === PROVEN || rechecked)
23505
+ isRecursiveInst = true;
23506
+ else
23507
+ rechecked = true;
23347
23508
  }
23348
23509
  const input = payload.value;
23349
- if (input === null || typeof input !== "object")
23510
+ if (!isRef(input))
23350
23511
  return base(payload, ctx);
23351
23512
  let state = ctx[STATE];
23352
23513
  if (!state) {
23353
- state = { buckets: new Map(), backEdges: undefined };
23514
+ state = { buckets: new WeakMap(), backEdges: undefined };
23354
23515
  ctx[STATE] = state;
23355
23516
  }
23356
23517
  let bucket;
@@ -23372,7 +23533,7 @@ const memoizer_memo = {
23372
23533
  else {
23373
23534
  // Still being parsed: its own checks cover it, so skip them here.
23374
23535
  payload.memo = true;
23375
- state.backEdges ?? (state.backEdges = new Set());
23536
+ state.backEdges ?? (state.backEdges = new WeakSet());
23376
23537
  state.backEdges.add(hit.value);
23377
23538
  }
23378
23539
  return payload;
@@ -23408,7 +23569,7 @@ function memoizer() {
23408
23569
  /** Whether this value is a node a back-edge resolved to before it finished. */
23409
23570
  function isBackEdge(ctx, value) {
23410
23571
  const backEdges = ctx[STATE]?.backEdges;
23411
- return backEdges !== undefined && value !== null && typeof value === "object" && backEdges.has(value);
23572
+ return backEdges !== undefined && isRef(value) && backEdges.has(value);
23412
23573
  }
23413
23574
 
23414
23575
  ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/regexes.js
@@ -23445,7 +23606,7 @@ const uuid4 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid
23445
23606
  const uuid6 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid(6)));
23446
23607
  const uuid7 = /*@__PURE__*/ (/* unused pure expression or super */ null && (uuid(7)));
23447
23608
  /** Practical email validation */
23448
- const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
23609
+ 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,}$/;
23449
23610
  /** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
23450
23611
  const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
23451
23612
  /** The classic emailregex.com regex for RFC 5322-compliant emails */
@@ -23455,8 +23616,8 @@ const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
23455
23616
  const idnEmail = (/* unused pure expression or super */ null && (unicodeEmail));
23456
23617
  const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
23457
23618
  // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
23458
- // Single character class, not an alternation: the two properties overlap (U+1F9B0-U+1F9B3), so `(A|B)+` backtracks exponentially on a failed match.
23459
- const _emoji = `^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
23619
+ // Single character class, not an alternation: the two properties overlap (U+1F9B0-U+1F9B3), so `(A|B)+` backtracks exponentially on a failed match. The leading lookahead then demands one anchor — a pictograph, a regional indicator, or the enclosing keycap — because `\p{Emoji_Component}` on its own covers ASCII digits, `#`, `*`, ZWJ, variation selectors and skin tone modifiers, none of which is an emoji without a base.
23620
+ const _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
23460
23621
  function emoji() {
23461
23622
  return new RegExp(_emoji, "u");
23462
23623
  }
@@ -23470,7 +23631,7 @@ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-
23470
23631
  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])$/;
23471
23632
  // https://stackoverflow.com/questions/7860392/determine-if-string-is-in-base64-using-javascript
23472
23633
  const regexes_base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
23473
- const regexes_base64url = /^[A-Za-z0-9_-]*$/;
23634
+ const regexes_base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
23474
23635
  // based on https://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
23475
23636
  // export const hostname: RegExp = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
23476
23637
  const regexes_hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
@@ -23480,6 +23641,10 @@ const httpProtocol = /^https?$/;
23480
23641
  const e164 = /^\+[1-9]\d{6,14}$/;
23481
23642
  // Credit card shape: 12–19 digits, optionally separated by single spaces or single hyphens. ISO/IEC 7812 caps the PAN at 19 digits; 12 is the shortest issued length (Maestro).
23482
23643
  const creditCard = /^\d(?:[ -]?\d){11,18}$/;
23644
+ // ISO 4217 alpha codes from the SIX list, regenerated by scripts/update-iso-4217.ts
23645
+ const currencyCode = /^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/;
23646
+ // iban electronic format: 2-letter country, check digits 02-98 (the only values `98 - remainder` can produce), 11-30 bban characters
23647
+ const regexes_iban = /^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/;
23483
23648
  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])))`;
23484
23649
  /** Anchors a pattern source. The interpolation lives here rather than at the call site because
23485
23650
  * esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
@@ -23515,6 +23680,8 @@ function datetime(args) {
23515
23680
  const timeRegex = args.local ? `${qualified}|${timeSource({ precision: args.precision })}` : qualified;
23516
23681
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
23517
23682
  }
23683
+ // the unbounded form of `string()` as a literal, so every plain string shares one instance instead of building its own
23684
+ const anyString = /^[\s\S]{0,}$/;
23518
23685
  const string = (params) => {
23519
23686
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
23520
23687
  return new RegExp(`^${regex}$`);
@@ -23592,16 +23759,6 @@ const numericOriginMap = {
23592
23759
  const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
23593
23760
  $ZodCheck.init(inst, def);
23594
23761
  const origin = numericOriginMap[typeof def.value];
23595
- inst._zod.onattach.push((inst) => {
23596
- const bag = inst._zod.bag;
23597
- const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
23598
- if (def.value < curr) {
23599
- if (def.inclusive)
23600
- bag.maximum = def.value;
23601
- else
23602
- bag.exclusiveMaximum = def.value;
23603
- }
23604
- });
23605
23762
  inst._zod.check = (payload) => {
23606
23763
  if (def.inclusive ? payload.value <= def.value : payload.value < def.value) {
23607
23764
  return;
@@ -23620,16 +23777,6 @@ const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst,
23620
23777
  const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
23621
23778
  $ZodCheck.init(inst, def);
23622
23779
  const origin = numericOriginMap[typeof def.value];
23623
- inst._zod.onattach.push((inst) => {
23624
- const bag = inst._zod.bag;
23625
- const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
23626
- if (def.value > curr) {
23627
- if (def.inclusive)
23628
- bag.minimum = def.value;
23629
- else
23630
- bag.exclusiveMinimum = def.value;
23631
- }
23632
- });
23633
23780
  inst._zod.check = (payload) => {
23634
23781
  if (def.inclusive ? payload.value >= def.value : payload.value > def.value) {
23635
23782
  return;
@@ -23648,10 +23795,6 @@ const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan",
23648
23795
  const $ZodCheckMultipleOf =
23649
23796
  /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
23650
23797
  $ZodCheck.init(inst, def);
23651
- inst._zod.onattach.push((inst) => {
23652
- var _a;
23653
- (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
23654
- });
23655
23798
  inst._zod.check = (payload) => {
23656
23799
  if (typeof payload.value !== typeof def.value)
23657
23800
  throw new Error("Cannot mix number and bigint in multiple_of check.");
@@ -23677,14 +23820,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
23677
23820
  const isInt = def.format?.includes("int");
23678
23821
  const origin = isInt ? "int" : "number";
23679
23822
  const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
23680
- inst._zod.onattach.push((inst) => {
23681
- const bag = inst._zod.bag;
23682
- bag.format = def.format;
23683
- bag.minimum = minimum;
23684
- bag.maximum = maximum;
23685
- if (isInt)
23686
- bag.pattern = integer;
23687
- });
23688
23823
  inst._zod.check = (payload) => {
23689
23824
  const input = payload.value;
23690
23825
  if (isInt) {
@@ -23773,12 +23908,6 @@ const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat"
23773
23908
  const $ZodCheckBigIntFormat = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckBigIntFormat", (inst, def) => {
23774
23909
  $ZodCheck.init(inst, def); // no format checks
23775
23910
  const [minimum, maximum] = util.BIGINT_FORMAT_RANGES[def.format];
23776
- inst._zod.onattach.push((inst) => {
23777
- const bag = inst._zod.bag;
23778
- bag.format = def.format;
23779
- bag.minimum = minimum;
23780
- bag.maximum = maximum;
23781
- });
23782
23911
  inst._zod.check = (payload) => {
23783
23912
  const input = payload.value;
23784
23913
  if (input < minimum) {
@@ -23809,11 +23938,6 @@ const $ZodCheckMaxSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
23809
23938
  var _a;
23810
23939
  $ZodCheck.init(inst, def);
23811
23940
  (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
23812
- inst._zod.onattach.push((inst) => {
23813
- const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
23814
- if (def.maximum < curr)
23815
- inst._zod.bag.maximum = def.maximum;
23816
- });
23817
23941
  inst._zod.check = (payload) => {
23818
23942
  const input = payload.value;
23819
23943
  const size = input.size;
@@ -23834,11 +23958,6 @@ const $ZodCheckMinSize = /*@__PURE__*/ (/* unused pure expression or super */ nu
23834
23958
  var _a;
23835
23959
  $ZodCheck.init(inst, def);
23836
23960
  (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
23837
- inst._zod.onattach.push((inst) => {
23838
- const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
23839
- if (def.minimum > curr)
23840
- inst._zod.bag.minimum = def.minimum;
23841
- });
23842
23961
  inst._zod.check = (payload) => {
23843
23962
  const input = payload.value;
23844
23963
  const size = input.size;
@@ -23859,12 +23978,6 @@ const $ZodCheckSizeEquals = /*@__PURE__*/ (/* unused pure expression or super */
23859
23978
  var _a;
23860
23979
  $ZodCheck.init(inst, def);
23861
23980
  (_a = inst._zod.def).when ?? (_a.when = _whenHasSize);
23862
- inst._zod.onattach.push((inst) => {
23863
- const bag = inst._zod.bag;
23864
- bag.minimum = def.size;
23865
- bag.maximum = def.size;
23866
- bag.size = def.size;
23867
- });
23868
23981
  inst._zod.check = (payload) => {
23869
23982
  const input = payload.value;
23870
23983
  const size = input.size;
@@ -23886,11 +23999,6 @@ const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (ins
23886
23999
  var _a;
23887
24000
  $ZodCheck.init(inst, def);
23888
24001
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
23889
- inst._zod.onattach.push((inst) => {
23890
- const curr = (inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY);
23891
- if (def.maximum < curr)
23892
- inst._zod.bag.maximum = def.maximum;
23893
- });
23894
24002
  inst._zod.check = (payload) => {
23895
24003
  const input = payload.value;
23896
24004
  const units = input.length;
@@ -23914,11 +24022,6 @@ const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (ins
23914
24022
  var _a;
23915
24023
  $ZodCheck.init(inst, def);
23916
24024
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
23917
- inst._zod.onattach.push((inst) => {
23918
- const curr = (inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY);
23919
- if (def.minimum > curr)
23920
- inst._zod.bag.minimum = def.minimum;
23921
- });
23922
24025
  inst._zod.check = (payload) => {
23923
24026
  const input = payload.value;
23924
24027
  const units = input.length;
@@ -23944,12 +24047,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
23944
24047
  var _a;
23945
24048
  $ZodCheck.init(inst, def);
23946
24049
  (_a = inst._zod.def).when ?? (_a.when = _whenHasLength);
23947
- inst._zod.onattach.push((inst) => {
23948
- const bag = inst._zod.bag;
23949
- bag.minimum = def.length;
23950
- bag.maximum = def.length;
23951
- bag.length = def.length;
23952
- });
23953
24050
  inst._zod.check = (payload) => {
23954
24051
  const input = payload.value;
23955
24052
  const units = input.length;
@@ -23975,14 +24072,6 @@ const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals"
23975
24072
  const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
23976
24073
  var _a, _b;
23977
24074
  $ZodCheck.init(inst, def);
23978
- inst._zod.onattach.push((inst) => {
23979
- const bag = inst._zod.bag;
23980
- bag.format = def.format;
23981
- if (def.pattern) {
23982
- bag.patterns ?? (bag.patterns = new Set());
23983
- bag.patterns.add(def.pattern);
23984
- }
23985
- });
23986
24075
  if (def.pattern)
23987
24076
  (_a = inst._zod).check ?? (_a.check = (payload) => {
23988
24077
  def.pattern.lastIndex = 0;
@@ -24034,11 +24123,6 @@ const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst,
24034
24123
  // (`{N,}`), not exactly `position` chars (`{N}`).
24035
24124
  const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position},}${escapedRegex}` : escapedRegex);
24036
24125
  def.pattern = pattern;
24037
- inst._zod.onattach.push((inst) => {
24038
- const bag = inst._zod.bag;
24039
- bag.patterns ?? (bag.patterns = new Set());
24040
- bag.patterns.add(pattern);
24041
- });
24042
24126
  inst._zod.check = (payload) => {
24043
24127
  if (payload.value.includes(def.includes, def.position))
24044
24128
  return;
@@ -24057,11 +24141,6 @@ const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (i
24057
24141
  $ZodCheck.init(inst, def);
24058
24142
  const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
24059
24143
  def.pattern ?? (def.pattern = pattern);
24060
- inst._zod.onattach.push((inst) => {
24061
- const bag = inst._zod.bag;
24062
- bag.patterns ?? (bag.patterns = new Set());
24063
- bag.patterns.add(pattern);
24064
- });
24065
24144
  inst._zod.check = (payload) => {
24066
24145
  if (payload.value.startsWith(def.prefix))
24067
24146
  return;
@@ -24080,11 +24159,6 @@ const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst,
24080
24159
  $ZodCheck.init(inst, def);
24081
24160
  const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
24082
24161
  def.pattern ?? (def.pattern = pattern);
24083
- inst._zod.onattach.push((inst) => {
24084
- const bag = inst._zod.bag;
24085
- bag.patterns ?? (bag.patterns = new Set());
24086
- bag.patterns.add(pattern);
24087
- });
24088
24162
  inst._zod.check = (payload) => {
24089
24163
  if (payload.value.endsWith(def.suffix))
24090
24164
  return;
@@ -24121,12 +24195,40 @@ const $ZodCheckProperty = /*@__PURE__*/ (/* unused pure expression or super */ n
24121
24195
  return;
24122
24196
  };
24123
24197
  })));
24198
+ const $ZodCheckProperties = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckProperties", (inst, def) => {
24199
+ $ZodCheck.init(inst, def);
24200
+ util.hide(inst, Symbol.iterator, function* () {
24201
+ yield inst;
24202
+ });
24203
+ // key and schema snapshotted together: reading one live and the other cached lets a later mutation of the caller's shape object pair a stale key with a missing schema
24204
+ let entries;
24205
+ inst._zod.check = (payload) => {
24206
+ // the base schema already typed the value, so only a nullish one is rejected here: the properties read on a primitive too, matching z.property() on a string's length
24207
+ if (payload.value == null) {
24208
+ payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
24209
+ return undefined;
24210
+ }
24211
+ entries ?? (entries = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
24212
+ const input = payload.value;
24213
+ let proms;
24214
+ for (const [key, schema] of entries) {
24215
+ const result = schema._zod.run({ value: input[key], issues: [] }, {});
24216
+ if (result instanceof Promise) {
24217
+ proms ?? (proms = []);
24218
+ proms.push(result.then((result) => handleCheckPropertyResult(result, payload, key)));
24219
+ }
24220
+ else {
24221
+ handleCheckPropertyResult(result, payload, key);
24222
+ }
24223
+ }
24224
+ if (proms)
24225
+ return Promise.all(proms).then(() => undefined);
24226
+ return undefined;
24227
+ };
24228
+ })));
24124
24229
  const $ZodCheckMimeType = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodCheckMimeType", (inst, def) => {
24125
24230
  $ZodCheck.init(inst, def);
24126
24231
  const mimeSet = new Set(def.mime);
24127
- inst._zod.onattach.push((inst) => {
24128
- inst._zod.bag.mime = def.mime;
24129
- });
24130
24232
  inst._zod.check = (payload) => {
24131
24233
  if (mimeSet.has(payload.value.type))
24132
24234
  return;
@@ -24154,10 +24256,15 @@ class Doc {
24154
24256
  this.args = args;
24155
24257
  this.closed = closed;
24156
24258
  }
24259
+ // the compiler catches a child's throw and keeps writing into this doc, so the indent has to unwind with it
24157
24260
  indented(fn) {
24158
24261
  this.indent += 1;
24159
- fn(this);
24160
- this.indent -= 1;
24262
+ try {
24263
+ fn(this);
24264
+ }
24265
+ finally {
24266
+ this.indent -= 1;
24267
+ }
24161
24268
  }
24162
24269
  write(arg) {
24163
24270
  if (typeof arg === "function") {
@@ -24181,658 +24288,261 @@ class Doc {
24181
24288
  }
24182
24289
  }
24183
24290
 
24184
- ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/errors.js
24291
+ ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/versions.js
24292
+ const versions_version = {
24293
+ major: 4,
24294
+ minor: 6,
24295
+ patch: 6,
24296
+ };
24185
24297
 
24298
+ ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/schemas.js
24186
24299
 
24187
- /* Computing the message eagerly is expensive (pretty-printed JSON of all
24188
- * issues), so defer it until first read. The accessor functions and
24189
- * descriptors are shared across instances to keep error construction
24190
- * cheap; the computed message is cached on the internals object. The
24191
- * setter preserves plain assignment semantics for consumers that
24192
- * overwrite `message`. */
24193
- function _getMessage() {
24194
- const internals = this._zod;
24195
- internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
24196
- return internals.message;
24197
- }
24198
- function _setMessage(value) {
24199
- this._zod.message = value;
24200
- }
24201
- const _messageDesc = {
24202
- get: _getMessage,
24203
- set: _setMessage,
24204
- enumerable: true,
24205
- configurable: true,
24206
- };
24207
- const errors_zodDesc = { value: undefined, enumerable: false };
24208
- const _issuesDesc = { value: undefined, enumerable: false };
24209
- /* Prototypes that already carry the lazy `toString`. Seeded with the
24210
- * intrinsics so that `init` on a foreign object — it accepts any object —
24211
- * can never install an accessor onto a prototype we do not own. */
24212
- const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
24213
- const errors_initializer = (inst, def) => {
24214
- inst.name = "$ZodError";
24215
- errors_zodDesc.value = inst._zod;
24216
- Object.defineProperty(inst, "_zod", errors_zodDesc);
24217
- _issuesDesc.value = def;
24218
- Object.defineProperty(inst, "issues", _issuesDesc);
24219
- // Clear the shared slots; a retained `value` pins the last error's issues.
24220
- errors_zodDesc.value = undefined;
24221
- _issuesDesc.value = undefined;
24222
- Object.defineProperty(inst, "message", _messageDesc);
24223
- /* `toString` lives as a non-enumerable lazy getter on the shared
24224
- * prototype; on first access it caches a per-instance closure so
24225
- * detached usage still works. */
24226
- const proto = Object.getPrototypeOf(inst);
24227
- if (!_installedToString.has(proto)) {
24228
- _installedToString.add(proto);
24229
- Object.defineProperty(proto, "toString", {
24230
- configurable: true,
24231
- enumerable: false,
24232
- get() {
24233
- const value = () => this.message;
24234
- Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
24235
- return value;
24236
- },
24237
- set(value) {
24238
- Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
24239
- },
24240
- });
24241
- }
24242
- };
24243
- const $ZodError = $constructor("$ZodError", errors_initializer);
24244
- const $ZodRealError = $constructor("$ZodError", errors_initializer, undefined, {
24245
- Parent: Error,
24246
- });
24247
- /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
24248
- * ("toString", "constructor") would otherwise read through to the prototype, and assigning
24249
- * "__proto__" would hit the setter instead of creating a key. */
24250
- function errors_node(obj, key, make) {
24251
- if (!Object.prototype.hasOwnProperty.call(obj, key)) {
24252
- if (key === "__proto__") {
24253
- Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
24254
- }
24255
- else {
24256
- obj[key] = make();
24300
+
24301
+
24302
+
24303
+
24304
+
24305
+
24306
+ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
24307
+ var _a;
24308
+ inst ?? (inst = {});
24309
+ inst._zod.def = def; // set _def property
24310
+ inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
24311
+ inst._zod.version = versions_version;
24312
+ const defChecks = inst._zod.def.checks;
24313
+ // if inst is itself a checks.$ZodCheck, run it as a check
24314
+ const checks = inst._zod.traits.has("$ZodCheck")
24315
+ ? [inst, ...(defChecks ?? [])]
24316
+ : defChecks?.length
24317
+ ? [...defChecks]
24318
+ : [];
24319
+ for (const ch of checks) {
24320
+ for (const fn of ch._zod.onattach) {
24321
+ fn(inst);
24257
24322
  }
24258
24323
  }
24259
- return obj[key];
24260
- }
24261
- function flattenError(error, mapper = (issue) => issue.message) {
24262
- const fieldErrors = {};
24263
- const formErrors = [];
24264
- for (const sub of error.issues) {
24265
- if (sub.path.length > 0) {
24266
- errors_node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
24267
- }
24268
- else {
24269
- formErrors.push(mapper(sub));
24270
- }
24324
+ if (checks.length === 0) {
24325
+ // deferred initializer inst._zod.parse is not yet defined
24326
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
24327
+ inst._zod.deferred?.push(() => {
24328
+ inst._zod.run = inst._zod.parse;
24329
+ });
24271
24330
  }
24272
- return { formErrors, fieldErrors };
24273
- }
24274
- function formatError(error, mapper = (issue) => issue.message) {
24275
- const fieldErrors = { _errors: [] };
24276
- const processError = (error, path = []) => {
24277
- for (const issue of error.issues) {
24278
- if (issue.code === "invalid_union" && issue.errors.length) {
24279
- issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
24280
- }
24281
- else if (issue.code === "invalid_key") {
24282
- processError({ issues: issue.issues }, [...path, ...issue.path]);
24283
- }
24284
- else if (issue.code === "invalid_element") {
24285
- processError({ issues: issue.issues }, [...path, ...issue.path]);
24286
- }
24287
- else {
24288
- const fullpath = [...path, ...issue.path];
24289
- if (fullpath.length === 0) {
24290
- fieldErrors._errors.push(mapper(issue));
24331
+ else {
24332
+ const runChecks = (payload, checks, ctx) => {
24333
+ if (payload.memo)
24334
+ return payload;
24335
+ let isAborted = aborted(payload);
24336
+ let asyncResult;
24337
+ for (const ch of checks) {
24338
+ if (ch._zod.def.when) {
24339
+ if (explicitlyAborted(payload))
24340
+ continue;
24341
+ const shouldRun = ch._zod.def.when(payload);
24342
+ if (!shouldRun)
24343
+ continue;
24344
+ }
24345
+ else if (isAborted) {
24346
+ continue;
24347
+ }
24348
+ const currLen = payload.issues.length;
24349
+ const _ = ch._zod.check(payload);
24350
+ if (_ instanceof Promise && ctx?.async === false) {
24351
+ throw new $ZodAsyncError();
24352
+ }
24353
+ if (asyncResult || _ instanceof Promise) {
24354
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
24355
+ await _;
24356
+ const nextLen = payload.issues.length;
24357
+ if (nextLen === currLen)
24358
+ return;
24359
+ attachSchema(payload.issues, currLen, inst);
24360
+ if (!isAborted)
24361
+ isAborted = aborted(payload, currLen);
24362
+ });
24291
24363
  }
24292
24364
  else {
24293
- let curr = fieldErrors;
24294
- let i = 0;
24295
- while (i < fullpath.length) {
24296
- const el = fullpath[i];
24297
- const terminal = i === fullpath.length - 1;
24298
- // `_errors` is reserved by this legacy format, so merge a matching path segment into the current node instead of treating its array as a child.
24299
- if (el === "_errors") {
24300
- if (terminal)
24301
- curr._errors.push(mapper(issue));
24302
- i++;
24303
- continue;
24304
- }
24305
- // A path element may collide with an inherited property name such as
24306
- // "__proto__" or "constructor". Truthiness checks read the prototype
24307
- // (so no node is created, then ._errors.push throws), and bracket
24308
- // assignment of "__proto__" hits the setter instead of creating an
24309
- // own key. Guard the read with hasOwnProperty and create the node
24310
- // with defineProperty so any path element becomes a real own key.
24311
- if (!Object.prototype.hasOwnProperty.call(curr, el)) {
24312
- Object.defineProperty(curr, el, {
24313
- value: { _errors: [] },
24314
- enumerable: true,
24315
- writable: true,
24316
- configurable: true,
24317
- });
24318
- }
24319
- const node = curr[el];
24320
- if (terminal) {
24321
- node._errors.push(mapper(issue));
24322
- }
24323
- curr = node;
24324
- i++;
24325
- }
24365
+ const nextLen = payload.issues.length;
24366
+ if (nextLen === currLen)
24367
+ continue;
24368
+ attachSchema(payload.issues, currLen, inst);
24369
+ if (!isAborted)
24370
+ isAborted = aborted(payload, currLen);
24326
24371
  }
24327
24372
  }
24328
- }
24329
- };
24330
- processError(error);
24331
- return fieldErrors;
24332
- }
24333
- function treeifyError(error, mapper = (issue) => issue.message) {
24334
- const result = { errors: [] };
24335
- const processError = (error, path = []) => {
24336
- var _a;
24337
- for (const issue of error.issues) {
24338
- if (issue.code === "invalid_union" && issue.errors.length) {
24339
- // regular union error
24340
- issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
24373
+ if (asyncResult) {
24374
+ return asyncResult.then(() => {
24375
+ return payload;
24376
+ });
24341
24377
  }
24342
- else if (issue.code === "invalid_key") {
24343
- processError({ issues: issue.issues }, [...path, ...issue.path]);
24378
+ return payload;
24379
+ };
24380
+ const handleCanaryResult = (canary, payload, ctx) => {
24381
+ // abort if the canary is aborted
24382
+ if (aborted(canary)) {
24383
+ canary.aborted = true;
24384
+ return canary;
24344
24385
  }
24345
- else if (issue.code === "invalid_element") {
24346
- processError({ issues: issue.issues }, [...path, ...issue.path]);
24386
+ // run checks first, then
24387
+ const checkResult = runChecks(payload, checks, ctx);
24388
+ if (checkResult instanceof Promise) {
24389
+ if (ctx.async === false)
24390
+ throw new $ZodAsyncError();
24391
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
24347
24392
  }
24348
- else {
24349
- const fullpath = [...path, ...issue.path];
24350
- if (fullpath.length === 0) {
24351
- result.errors.push(mapper(issue));
24352
- continue;
24353
- }
24354
- let curr = result;
24355
- let i = 0;
24356
- while (i < fullpath.length) {
24357
- const el = fullpath[i];
24358
- const terminal = i === fullpath.length - 1;
24359
- if (typeof el === "string") {
24360
- curr.properties ?? (curr.properties = {});
24361
- // el may collide with an inherited property name ("__proto__",
24362
- // "constructor", ...); ??= reads the prototype so the node is never
24363
- // created and curr.errors.push throws. Guard with hasOwnProperty and
24364
- // create the node with defineProperty so "__proto__" becomes a real
24365
- // own key rather than invoking the prototype setter.
24366
- if (!Object.prototype.hasOwnProperty.call(curr.properties, el)) {
24367
- Object.defineProperty(curr.properties, el, {
24368
- value: { errors: [] },
24369
- enumerable: true,
24370
- writable: true,
24371
- configurable: true,
24372
- });
24373
- }
24374
- curr = curr.properties[el];
24375
- }
24376
- else {
24377
- curr.items ?? (curr.items = []);
24378
- (_a = curr.items)[el] ?? (_a[el] = { errors: [] });
24379
- curr = curr.items[el];
24380
- }
24381
- if (terminal) {
24382
- curr.errors.push(mapper(issue));
24383
- }
24384
- i++;
24393
+ return inst._zod.parse(checkResult, ctx);
24394
+ };
24395
+ inst._zod.run = (payload, ctx) => {
24396
+ if (ctx.skipChecks) {
24397
+ return inst._zod.parse(payload, ctx);
24398
+ }
24399
+ if (ctx.direction === "backward") {
24400
+ // run canary initial pass (no checks)
24401
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
24402
+ if (canary instanceof Promise) {
24403
+ return canary.then((canary) => {
24404
+ return handleCanaryResult(canary, payload, ctx);
24405
+ });
24385
24406
  }
24407
+ return handleCanaryResult(canary, payload, ctx);
24386
24408
  }
24387
- }
24409
+ // forward
24410
+ const result = inst._zod.parse(payload, ctx);
24411
+ if (result instanceof Promise) {
24412
+ if (ctx.async === false)
24413
+ throw new $ZodAsyncError();
24414
+ return result.then((result) => runChecks(result, checks, ctx));
24415
+ }
24416
+ return runChecks(result, checks, ctx);
24417
+ };
24418
+ }
24419
+ }, {
24420
+ // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
24421
+ get "~standard"() {
24422
+ return hide(this, "~standard", standardProps(this));
24423
+ },
24424
+ set "~standard"(value) {
24425
+ util_own(this, "~standard", value);
24426
+ },
24427
+ });
24428
+ /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
24429
+ // a Standard Schema result only reports issues, so a failure finalizes them straight off the raw payload: no ZodError, and no lazy result to read through
24430
+ const toStandardResult = (r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, core_config())) } : { value: r.value };
24431
+ async function validateAsync(inst, value) {
24432
+ const ctx = { async: true };
24433
+ return toStandardResult((await inst._zod.run({ value, issues: [] }, ctx)), ctx);
24434
+ }
24435
+ function standardProps(inst) {
24436
+ return {
24437
+ validate: (value) => {
24438
+ const ctx = { async: false };
24439
+ try {
24440
+ const r = inst._zod.run({ value, issues: [] }, ctx);
24441
+ if (!(r instanceof Promise))
24442
+ return toStandardResult(r, ctx);
24443
+ }
24444
+ catch (_) { }
24445
+ // async function so a synchronously throwing check rejects instead of escaping validate
24446
+ return validateAsync(inst, value);
24447
+ },
24448
+ vendor: "zod",
24449
+ version: 1,
24388
24450
  };
24389
- processError(error);
24390
- return result;
24391
24451
  }
24392
- /** Format a ZodError as a human-readable string in the following form.
24393
- *
24394
- * From
24395
- *
24396
- * ```ts
24397
- * ZodError {
24398
- * issues: [
24399
- * {
24400
- * expected: 'string',
24401
- * code: 'invalid_type',
24402
- * path: [ 'username' ],
24403
- * message: 'Invalid input: expected string'
24404
- * },
24405
- * {
24406
- * expected: 'number',
24407
- * code: 'invalid_type',
24408
- * path: [ 'favoriteNumbers', 1 ],
24409
- * message: 'Invalid input: expected number'
24410
- * }
24411
- * ];
24412
- * }
24413
- * ```
24414
- *
24415
- * to
24416
- *
24417
- * ```
24418
- * username
24419
- * ✖ Expected number, received string at "username
24420
- * favoriteNumbers[0]
24421
- * ✖ Invalid input: expected number
24422
- * ```
24423
- */
24424
- function toDotPath(_path) {
24425
- const segs = [];
24426
- const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
24427
- for (const seg of path) {
24428
- if (typeof seg === "number")
24429
- segs.push(`[${seg}]`);
24430
- else if (typeof seg === "symbol")
24431
- segs.push(`[${JSON.stringify(String(seg))}]`);
24432
- else if (/[^\w$]/.test(seg))
24433
- segs.push(`[${JSON.stringify(seg)}]`);
24434
- else {
24435
- if (segs.length)
24436
- segs.push(".");
24437
- segs.push(seg);
24438
- }
24452
+
24453
+ const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
24454
+ $ZodType.init(inst, def);
24455
+ // a format's own pattern, else unbounded; a template literal derives the check-aware form itself
24456
+ inst._zod.pattern = def.pattern ?? anyString;
24457
+ inst._zod.parse = (payload, _) => {
24458
+ if (def.coerce)
24459
+ try {
24460
+ payload.value = String(payload.value);
24461
+ }
24462
+ catch (_) { }
24463
+ if (typeof payload.value === "string")
24464
+ return payload;
24465
+ payload.issues.push({
24466
+ expected: "string",
24467
+ code: "invalid_type",
24468
+ input: payload.value,
24469
+ inst,
24470
+ });
24471
+ return payload;
24472
+ };
24473
+ });
24474
+ const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
24475
+ // check initialization must come first
24476
+ $ZodCheckStringFormat.init(inst, def);
24477
+ $ZodString.init(inst, def);
24478
+ });
24479
+ const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
24480
+ def.pattern ?? (def.pattern = guid);
24481
+ $ZodStringFormat.init(inst, def);
24482
+ });
24483
+ const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
24484
+ if (def.version) {
24485
+ const versionMap = {
24486
+ v1: 1,
24487
+ v2: 2,
24488
+ v3: 3,
24489
+ v4: 4,
24490
+ v5: 5,
24491
+ v6: 6,
24492
+ v7: 7,
24493
+ v8: 8,
24494
+ };
24495
+ const v = versionMap[def.version];
24496
+ if (v === undefined)
24497
+ throw new Error(`Invalid UUID version: "${def.version}"`);
24498
+ def.pattern ?? (def.pattern = uuid(v));
24439
24499
  }
24440
- return segs.join("");
24441
- }
24442
- function prettifyError(error) {
24443
- const lines = [];
24444
- // sort by path length
24445
- const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
24446
- // Process each issue
24447
- for (const issue of issues) {
24448
- lines.push(`✖ ${issue.message}`);
24449
- if (issue.path?.length)
24450
- lines.push(` → at ${toDotPath(issue.path)}`);
24500
+ else
24501
+ def.pattern ?? (def.pattern = uuid());
24502
+ $ZodStringFormat.init(inst, def);
24503
+ });
24504
+ const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
24505
+ def.pattern ?? (def.pattern = email);
24506
+ $ZodStringFormat.init(inst, def);
24507
+ });
24508
+ /** The `://` guard rejected the input before the URL constructor saw it. */
24509
+ const URL_BAD_FORMAT = 1;
24510
+ /** The URL parser rejected the input. */
24511
+ const URL_UNPARSEABLE = 2;
24512
+ function canParseURL(input) {
24513
+ try {
24514
+ if (typeof URL !== "undefined" && typeof URL.canParse === "function")
24515
+ return URL.canParse(input);
24516
+ new URL(input);
24517
+ return true;
24518
+ }
24519
+ catch {
24520
+ return false;
24451
24521
  }
24452
- // Convert Map to formatted string
24453
- return lines.join("\n");
24454
24522
  }
24455
-
24456
- ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/parse.js
24457
-
24458
-
24459
-
24460
- // Always both keys, so the `_params` read site in `_parse` sees one object shape rather than two.
24461
- function finalizeParams(callee, params) {
24462
- return { callee: params?.callee ?? callee, Err: params?.Err };
24523
+ function validateURL(trimmed, def) {
24524
+ if (!("normalize" in def) && !("hostname" in def) && !("protocol" in def)) {
24525
+ return canParseURL(trimmed) || URL_UNPARSEABLE;
24526
+ }
24527
+ return parseURLObject(trimmed, def);
24463
24528
  }
24464
- const parse_parse = (_Err) => {
24465
- const fn = (schema, value, _ctx, _params) => {
24466
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
24467
- const result = schema._zod.run({ value, issues: [] }, ctx);
24468
- if (result instanceof Promise) {
24469
- throw new $ZodAsyncError();
24470
- }
24471
- if (result.issues.length) {
24472
- const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
24473
- captureStackTrace(e, _params?.callee ?? fn);
24474
- throw e;
24475
- }
24476
- return result.value;
24477
- };
24478
- return fn;
24479
- };
24480
- const core_parse_parse = /* @__PURE__*/ parse_parse($ZodRealError);
24481
- const parse_parseAsync = (_Err) => {
24482
- const fn = async (schema, value, _ctx, params) => {
24483
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
24484
- let result = schema._zod.run({ value, issues: [] }, ctx);
24485
- if (result instanceof Promise)
24486
- result = await result;
24487
- if (result.issues.length) {
24488
- const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
24489
- captureStackTrace(e, params?.callee ?? fn);
24490
- throw e;
24491
- }
24492
- return result.value;
24493
- };
24494
- return fn;
24495
- };
24496
- const core_parse_parseAsync = /* @__PURE__*/ parse_parseAsync($ZodRealError);
24497
- const _safeParse = (_Err) => (schema, value, _ctx) => {
24498
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
24499
- const result = schema._zod.run({ value, issues: [] }, ctx);
24500
- if (result instanceof Promise) {
24501
- throw new $ZodAsyncError();
24529
+ /** Parses a URL while preserving the non-normalizing HTTP guard. */
24530
+ function parseURLObject(trimmed, def) {
24531
+ // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
24532
+ if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
24533
+ return URL_BAD_FORMAT;
24502
24534
  }
24503
- return result.issues.length
24504
- ? {
24505
- success: false,
24506
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config()))),
24507
- }
24508
- : { success: true, data: result.value };
24509
- };
24510
- const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
24511
- const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
24512
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
24513
- let result = schema._zod.run({ value, issues: [] }, ctx);
24514
- if (result instanceof Promise)
24515
- result = await result;
24516
- return result.issues.length
24517
- ? {
24518
- success: false,
24519
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config()))),
24535
+ try {
24536
+ if (typeof URL !== "undefined") {
24537
+ const URLStatic = URL;
24538
+ if (typeof URLStatic.parse === "function")
24539
+ return URLStatic.parse(trimmed) ?? URL_UNPARSEABLE;
24520
24540
  }
24521
- : { success: true, data: result.value };
24522
- };
24523
- const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
24524
- // registry mirrors of the compiler's sentinels, so this module never imports the compiler
24525
- const COMPILE_INVALID = /* @__PURE__ */ (/* unused pure expression or super */ null && (Symbol.for("zod.compile.invalid")));
24526
- const COMPILE_FALLBACK = /* @__PURE__ */ (/* unused pure expression or super */ null && (Symbol.for("zod.compile.fallback")));
24527
- // Deliberately tiny, because v8 will not inline a body carrying the fallback's object literals and throw. Everything that is not the compiled happy path lives in validateFallback, and that split is worth ~35% on a compiled schema.
24528
- const validate = ((schema, value, _ctx) => {
24529
- const validator = schema._zod.bag.validator;
24530
- if (validator !== undefined && validator(value) !== COMPILE_INVALID)
24531
- return true;
24532
- return validateFallback(schema, value, _ctx);
24533
- });
24534
- function validateFallback(schema, value, _ctx) {
24535
- const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
24536
- const fallbackRun = schema._zod.bag.fallbackRun;
24537
- let result;
24538
- if (fallbackRun) {
24539
- // skip nested fast paths on the fallback, so user callbacks keep the at-most-twice bound
24540
- ctx[COMPILE_FALLBACK] = true;
24541
- result = fallbackRun({ value, issues: [] }, ctx);
24542
- }
24543
- else {
24544
- result = schema._zod.run({ value, issues: [] }, ctx);
24541
+ // @ts-ignore
24542
+ return new URL(trimmed);
24545
24543
  }
24546
- if (result instanceof Promise) {
24547
- throw new core.$ZodAsyncError();
24548
- }
24549
- return result.issues.length === 0;
24550
- }
24551
- // no fast path: the compiler keeps async parses on the runtime, because a promise-returning callback that is not declared async compiles to a throw
24552
- const validateAsync = async (schema, value, _ctx) => {
24553
- const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
24554
- let result = schema._zod.run({ value, issues: [] }, ctx);
24555
- if (result instanceof Promise)
24556
- result = await result;
24557
- return result.issues.length === 0;
24558
- };
24559
- const parse_encode = (_Err) => {
24560
- const parse = parse_parse(_Err);
24561
- const fn = (schema, value, _ctx, _params) => {
24562
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
24563
- return parse(schema, value, ctx, finalizeParams(fn, _params));
24564
- };
24565
- return fn;
24566
- };
24567
- const encode = /* @__PURE__*/ parse_encode($ZodRealError);
24568
- const parse_decode = (_Err) => {
24569
- const parse = parse_parse(_Err);
24570
- const fn = (schema, value, _ctx, _params) => {
24571
- return parse(schema, value, _ctx, finalizeParams(fn, _params));
24572
- };
24573
- return fn;
24574
- };
24575
- const decode = /* @__PURE__*/ parse_decode($ZodRealError);
24576
- const parse_encodeAsync = (_Err) => {
24577
- const parseAsync = parse_parseAsync(_Err);
24578
- const fn = async (schema, value, _ctx, _params) => {
24579
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
24580
- return (await parseAsync(schema, value, ctx, finalizeParams(fn, _params)));
24581
- };
24582
- return fn;
24583
- };
24584
- const encodeAsync = /* @__PURE__*/ parse_encodeAsync($ZodRealError);
24585
- const parse_decodeAsync = (_Err) => {
24586
- const parseAsync = parse_parseAsync(_Err);
24587
- const fn = async (schema, value, _ctx, _params) => {
24588
- return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
24589
- };
24590
- return fn;
24591
- };
24592
- const decodeAsync = /* @__PURE__*/ parse_decodeAsync($ZodRealError);
24593
- const _safeEncode = (_Err) => (schema, value, _ctx) => {
24594
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
24595
- return _safeParse(_Err)(schema, value, ctx);
24596
- };
24597
- const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
24598
- const _safeDecode = (_Err) => (schema, value, _ctx) => {
24599
- return _safeParse(_Err)(schema, value, _ctx);
24600
- };
24601
- const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
24602
- const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
24603
- const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
24604
- return _safeParseAsync(_Err)(schema, value, ctx);
24605
- };
24606
- const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
24607
- const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
24608
- return _safeParseAsync(_Err)(schema, value, _ctx);
24609
- };
24610
- const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
24611
-
24612
- ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/versions.js
24613
- const versions_version = {
24614
- major: 4,
24615
- minor: 5,
24616
- patch: 2,
24617
- };
24618
-
24619
- ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/schemas.js
24620
-
24621
-
24622
-
24623
-
24624
-
24625
-
24626
-
24627
- const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
24628
- var _a;
24629
- inst ?? (inst = {});
24630
- inst._zod.def = def; // set _def property
24631
- inst._zod.bag = inst._zod.bag || {}; // initialize _bag object
24632
- inst._zod.version = versions_version;
24633
- const defChecks = inst._zod.def.checks;
24634
- // if inst is itself a checks.$ZodCheck, run it as a check
24635
- const checks = inst._zod.traits.has("$ZodCheck")
24636
- ? [inst, ...(defChecks ?? [])]
24637
- : defChecks?.length
24638
- ? [...defChecks]
24639
- : [];
24640
- for (const ch of checks) {
24641
- for (const fn of ch._zod.onattach) {
24642
- fn(inst);
24643
- }
24644
- }
24645
- if (checks.length === 0) {
24646
- // deferred initializer inst._zod.parse is not yet defined
24647
- (_a = inst._zod).deferred ?? (_a.deferred = []);
24648
- inst._zod.deferred?.push(() => {
24649
- inst._zod.run = inst._zod.parse;
24650
- });
24651
- }
24652
- else {
24653
- const runChecks = (payload, checks, ctx) => {
24654
- if (payload.memo)
24655
- return payload;
24656
- let isAborted = aborted(payload);
24657
- let asyncResult;
24658
- for (const ch of checks) {
24659
- if (ch._zod.def.when) {
24660
- if (explicitlyAborted(payload))
24661
- continue;
24662
- const shouldRun = ch._zod.def.when(payload);
24663
- if (!shouldRun)
24664
- continue;
24665
- }
24666
- else if (isAborted) {
24667
- continue;
24668
- }
24669
- const currLen = payload.issues.length;
24670
- const _ = ch._zod.check(payload);
24671
- if (_ instanceof Promise && ctx?.async === false) {
24672
- throw new $ZodAsyncError();
24673
- }
24674
- if (asyncResult || _ instanceof Promise) {
24675
- asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
24676
- await _;
24677
- const nextLen = payload.issues.length;
24678
- if (nextLen === currLen)
24679
- return;
24680
- attachSchema(payload.issues, currLen, inst);
24681
- if (!isAborted)
24682
- isAborted = aborted(payload, currLen);
24683
- });
24684
- }
24685
- else {
24686
- const nextLen = payload.issues.length;
24687
- if (nextLen === currLen)
24688
- continue;
24689
- attachSchema(payload.issues, currLen, inst);
24690
- if (!isAborted)
24691
- isAborted = aborted(payload, currLen);
24692
- }
24693
- }
24694
- if (asyncResult) {
24695
- return asyncResult.then(() => {
24696
- return payload;
24697
- });
24698
- }
24699
- return payload;
24700
- };
24701
- const handleCanaryResult = (canary, payload, ctx) => {
24702
- // abort if the canary is aborted
24703
- if (aborted(canary)) {
24704
- canary.aborted = true;
24705
- return canary;
24706
- }
24707
- // run checks first, then
24708
- const checkResult = runChecks(payload, checks, ctx);
24709
- if (checkResult instanceof Promise) {
24710
- if (ctx.async === false)
24711
- throw new $ZodAsyncError();
24712
- return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
24713
- }
24714
- return inst._zod.parse(checkResult, ctx);
24715
- };
24716
- inst._zod.run = (payload, ctx) => {
24717
- if (ctx.skipChecks) {
24718
- return inst._zod.parse(payload, ctx);
24719
- }
24720
- if (ctx.direction === "backward") {
24721
- // run canary initial pass (no checks)
24722
- const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
24723
- if (canary instanceof Promise) {
24724
- return canary.then((canary) => {
24725
- return handleCanaryResult(canary, payload, ctx);
24726
- });
24727
- }
24728
- return handleCanaryResult(canary, payload, ctx);
24729
- }
24730
- // forward
24731
- const result = inst._zod.parse(payload, ctx);
24732
- if (result instanceof Promise) {
24733
- if (ctx.async === false)
24734
- throw new $ZodAsyncError();
24735
- return result.then((result) => runChecks(result, checks, ctx));
24736
- }
24737
- return runChecks(result, checks, ctx);
24738
- };
24739
- }
24740
- }, {
24741
- // Wrappers extend this by installing a richer factory over it; reading it eagerly would defeat the laziness.
24742
- get "~standard"() {
24743
- return hide(this, "~standard", standardProps(this));
24744
- },
24745
- set "~standard"(value) {
24746
- util_own(this, "~standard", value);
24747
- },
24748
- });
24749
- /** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
24750
- const toStandardResult = (r) => r.success ? { value: r.data } : { issues: r.error?.issues };
24751
- function standardProps(inst) {
24752
- return {
24753
- validate: (value) => {
24754
- try {
24755
- return toStandardResult(safeParse(inst, value));
24756
- }
24757
- catch (_) {
24758
- return safeParseAsync(inst, value).then(toStandardResult);
24759
- }
24760
- },
24761
- vendor: "zod",
24762
- version: 1,
24763
- };
24764
- }
24765
-
24766
- const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
24767
- $ZodType.init(inst, def);
24768
- inst._zod.pattern = [...(inst?._zod.bag?.patterns ?? [])].pop() ?? string(inst._zod.bag);
24769
- inst._zod.parse = (payload, _) => {
24770
- if (def.coerce)
24771
- try {
24772
- payload.value = String(payload.value);
24773
- }
24774
- catch (_) { }
24775
- if (typeof payload.value === "string")
24776
- return payload;
24777
- payload.issues.push({
24778
- expected: "string",
24779
- code: "invalid_type",
24780
- input: payload.value,
24781
- inst,
24782
- });
24783
- return payload;
24784
- };
24785
- });
24786
- const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
24787
- // check initialization must come first
24788
- $ZodCheckStringFormat.init(inst, def);
24789
- $ZodString.init(inst, def);
24790
- });
24791
- const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
24792
- def.pattern ?? (def.pattern = guid);
24793
- $ZodStringFormat.init(inst, def);
24794
- });
24795
- const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
24796
- if (def.version) {
24797
- const versionMap = {
24798
- v1: 1,
24799
- v2: 2,
24800
- v3: 3,
24801
- v4: 4,
24802
- v5: 5,
24803
- v6: 6,
24804
- v7: 7,
24805
- v8: 8,
24806
- };
24807
- const v = versionMap[def.version];
24808
- if (v === undefined)
24809
- throw new Error(`Invalid UUID version: "${def.version}"`);
24810
- def.pattern ?? (def.pattern = uuid(v));
24811
- }
24812
- else
24813
- def.pattern ?? (def.pattern = uuid());
24814
- $ZodStringFormat.init(inst, def);
24815
- });
24816
- const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
24817
- def.pattern ?? (def.pattern = email);
24818
- $ZodStringFormat.init(inst, def);
24819
- });
24820
- /** The `://` guard rejected the input before the URL constructor saw it. */
24821
- const URL_BAD_FORMAT = 1;
24822
- /** The URL constructor rejected the input. */
24823
- const URL_UNPARSEABLE = 2;
24824
- /** Parses a URL for `$ZodURL`, applying the one guard the URL constructor cannot express. Returns the parsed URL, or a code naming the stage that rejected it — the runtime needs that distinction to pick an issue note, and compiled code only needs to know it is not a URL. */
24825
- function parseURLObject(trimmed, def) {
24826
- // When normalize is off, require :// for http/https URLs. This prevents strings like "http:example.com" or "https:/path" from being silently accepted
24827
- if (!def.normalize && def.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(trimmed)) {
24828
- return URL_BAD_FORMAT;
24829
- }
24830
- try {
24831
- // @ts-ignore
24832
- return new URL(trimmed);
24833
- }
24834
- catch {
24835
- return URL_UNPARSEABLE;
24544
+ catch {
24545
+ return URL_UNPARSEABLE;
24836
24546
  }
24837
24547
  }
24838
24548
  const asciiTabOrNewline = /[\t\n\r]/g;
@@ -24854,7 +24564,7 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
24854
24564
  try {
24855
24565
  // Trim whitespace from input
24856
24566
  const trimmed = payload.value.trim();
24857
- const url = parseURLObject(trimmed, def);
24567
+ const url = validateURL(trimmed, def);
24858
24568
  if (url === URL_BAD_FORMAT) {
24859
24569
  payload.issues.push({
24860
24570
  code: "invalid_format",
@@ -24876,6 +24586,10 @@ const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
24876
24586
  });
24877
24587
  return;
24878
24588
  }
24589
+ if (url === true) {
24590
+ payload.value = stripTabAndNewline(trimmed);
24591
+ return;
24592
+ }
24879
24593
  if (def.hostname && !urlHostnameOk(url, def.hostname)) {
24880
24594
  payload.issues.push({
24881
24595
  code: "invalid_format",
@@ -24951,13 +24665,6 @@ const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
24951
24665
  const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
24952
24666
  def.pattern ?? (def.pattern = datetime(def));
24953
24667
  $ZodStringFormat.init(inst, def);
24954
- // these two drop the offset or seconds `date-time` requires — on the bag not the def, since `z.string().check(...)` lands the format on a different schema
24955
- if (def.local || def.precision === -1) {
24956
- inst._zod.bag.laxFormat = true;
24957
- inst._zod.onattach.push((s) => {
24958
- s._zod.bag.laxFormat = true;
24959
- });
24960
- }
24961
24668
  });
24962
24669
  const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
24963
24670
  def.pattern ?? (def.pattern = date);
@@ -24974,26 +24681,17 @@ const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def
24974
24681
  const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
24975
24682
  def.pattern ?? (def.pattern = ipv4);
24976
24683
  $ZodStringFormat.init(inst, def);
24977
- inst._zod.bag.format = `ipv4`;
24978
24684
  });
24979
24685
  /** 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`. */
24980
24686
  const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
24981
24687
  function isValidIPv6(value) {
24982
24688
  if (!ipv6Alphabet.test(value))
24983
24689
  return false;
24984
- try {
24985
- // @ts-ignore
24986
- new URL(`http://[${value}]`);
24987
- return true;
24988
- }
24989
- catch {
24990
- return false;
24991
- }
24690
+ return canParseURL(`http://[${value}]`);
24992
24691
  }
24993
24692
  const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
24994
24693
  def.pattern ?? (def.pattern = ipv6);
24995
24694
  $ZodStringFormat.init(inst, def);
24996
- inst._zod.bag.format = `ipv6`;
24997
24695
  inst._zod.check = (payload) => {
24998
24696
  if (!isValidIPv6(payload.value)) {
24999
24697
  payload.issues.push({
@@ -25009,7 +24707,6 @@ const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
25009
24707
  const $ZodMAC = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodMAC", (inst, def) => {
25010
24708
  def.pattern ?? (def.pattern = regexes.mac(def.delimiter));
25011
24709
  $ZodStringFormat.init(inst, def);
25012
- inst._zod.bag.format = `mac`;
25013
24710
  })));
25014
24711
  const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
25015
24712
  def.pattern ?? (def.pattern = cidrv4);
@@ -25062,10 +24759,11 @@ function isValidBase64(data) {
25062
24759
  return false;
25063
24760
  }
25064
24761
  }
24762
+ // lax on purpose: the quantified regexes.base64 overflows the regex stack on multi-MB input and its leading ^$| alternation leaks through template-literal composition; isValidBase64 enforces length and padding
24763
+ const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
25065
24764
  const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
25066
- def.pattern ?? (def.pattern = regexes_base64);
24765
+ def.pattern ?? (def.pattern = base64Charset);
25067
24766
  $ZodStringFormat.init(inst, def);
25068
- inst._zod.bag.contentEncoding = "base64";
25069
24767
  inst._zod.check = (payload) => {
25070
24768
  if (isValidBase64(payload.value))
25071
24769
  return;
@@ -25078,18 +24776,19 @@ const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
25078
24776
  });
25079
24777
  };
25080
24778
  });
25081
- ////////////////////////////// ZodBase64 //////////////////////////////
24779
+ ////////////////////////////// ZodBase64URL //////////////////////////////
24780
+ // lax on purpose: the quantified regexes.base64url overflows the regex stack on multi-MB input; isValidBase64 enforces length on the padded string
24781
+ const base64urlCharset = /^[A-Za-z0-9_-]*$/;
25082
24782
  function isValidBase64URL(data) {
25083
- if (!regexes_base64url.test(data))
24783
+ if (!base64urlCharset.test(data))
25084
24784
  return false;
25085
24785
  const base64 = data.replace(/[-_]/g, (c) => (c === "-" ? "+" : "/"));
25086
24786
  const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
25087
24787
  return isValidBase64(padded);
25088
24788
  }
25089
24789
  const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
25090
- def.pattern ?? (def.pattern = regexes_base64url);
24790
+ def.pattern ?? (def.pattern = base64urlCharset);
25091
24791
  $ZodStringFormat.init(inst, def);
25092
- inst._zod.bag.contentEncoding = "base64url";
25093
24792
  inst._zod.check = (payload) => {
25094
24793
  if (isValidBase64URL(payload.value))
25095
24794
  return;
@@ -25114,7 +24813,7 @@ function isLuhnAlgo(digits) {
25114
24813
  let bit = 1;
25115
24814
  let sum = 0;
25116
24815
  while (length) {
25117
- const value = +digits[--length];
24816
+ const value = digits.charCodeAt(--length) - 48;
25118
24817
  bit ^= 1;
25119
24818
  sum += bit ? [0, 2, 4, 6, 8, 1, 3, 5, 7, 9][value] : value;
25120
24819
  }
@@ -25141,6 +24840,42 @@ const $ZodCreditCard = /*@__PURE__*/ (/* unused pure expression or super */ null
25141
24840
  });
25142
24841
  };
25143
24842
  })));
24843
+ ////////////////////////////// ZodIBAN //////////////////////////////
24844
+ // iso 7064 mod 97-10 checksum without BigInt
24845
+ function isIso7064Mod97(iban) {
24846
+ let remainder = 0;
24847
+ const len = iban.length;
24848
+ for (let i = 4; i < len; i++) {
24849
+ const code = iban.charCodeAt(i);
24850
+ remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
24851
+ }
24852
+ for (let i = 0; i < 4; i++) {
24853
+ const code = iban.charCodeAt(i);
24854
+ remainder = (code >= 65 ? remainder * 100 + (code - 55) : remainder * 10 + (code - 48)) % 97;
24855
+ }
24856
+ return remainder === 1;
24857
+ }
24858
+ function isValidIBAN(input) {
24859
+ if (!regexes.iban.test(input))
24860
+ return false;
24861
+ return isIso7064Mod97(input);
24862
+ }
24863
+ const $ZodIBAN = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodIBAN", (inst, def) => {
24864
+ // shape only — checksum is not expressible as a pattern
24865
+ def.pattern ?? (def.pattern = regexes.iban);
24866
+ $ZodStringFormat.init(inst, def);
24867
+ inst._zod.check = (payload) => {
24868
+ if (isValidIBAN(payload.value))
24869
+ return;
24870
+ payload.issues.push({
24871
+ code: "invalid_format",
24872
+ format: "iban",
24873
+ input: payload.value,
24874
+ inst,
24875
+ continue: !def.abort,
24876
+ });
24877
+ };
24878
+ })));
25144
24879
  ////////////////////////////// ZodJWT //////////////////////////////
25145
24880
  function isValidJWT(token, algorithm = null) {
25146
24881
  try {
@@ -25194,7 +24929,7 @@ const $ZodCustomStringFormat = /*@__PURE__*/ (/* unused pure expression or super
25194
24929
  })));
25195
24930
  const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
25196
24931
  $ZodType.init(inst, def);
25197
- inst._zod.pattern = inst._zod.bag.pattern ?? number;
24932
+ inst._zod.pattern = number;
25198
24933
  inst._zod.parse = (payload, _ctx) => {
25199
24934
  if (def.coerce)
25200
24935
  try {
@@ -25379,13 +25114,40 @@ const $ZodDate = /*@__PURE__*/ (/* unused pure expression or super */ null && (c
25379
25114
  return payload;
25380
25115
  };
25381
25116
  })));
25382
- function handleArrayResult(result, final, index) {
25383
- if (result.issues.length) {
25384
- final.issues.push(...prefixIssues(index, result.issues));
25385
- }
25386
- final.value[index] = result.value;
25387
- }
25388
- const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
25117
+ // an oversized container fails its leading size checks before any element is parsed
25118
+ function capSize(inst, size) {
25119
+ const caps = sizeCaps(inst._zod.def.checks);
25120
+ if (!caps.length)
25121
+ return;
25122
+ const cap = Math.min(...caps.map((c) => c[0]));
25123
+ const parse = inst._zod.parse;
25124
+ inst._zod.parse = (payload, ctx) => {
25125
+ const n = size(payload.value);
25126
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
25127
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
25128
+ if (n > max && ch._zod.def.when(payload)) {
25129
+ const start = payload.issues.length;
25130
+ ch._zod.check(payload);
25131
+ // the value is still the raw input, so no later check may read it
25132
+ payload.issues[start].continue = false;
25133
+ attachSchema(payload.issues, start, inst);
25134
+ return payload;
25135
+ }
25136
+ }
25137
+ }
25138
+ return parse(payload, ctx);
25139
+ };
25140
+ }
25141
+ const arraySize = (input) => (Array.isArray(input) ? input.length : -1);
25142
+ const mapSize = (input) => (input instanceof Map ? input.size : -1);
25143
+ const setSize = (input) => (input instanceof Set ? input.size : -1);
25144
+ function handleArrayResult(result, final, index) {
25145
+ if (result.issues.length) {
25146
+ final.issues.push(...prefixIssues(index, result.issues));
25147
+ }
25148
+ final.value[index] = result.value;
25149
+ }
25150
+ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
25389
25151
  $ZodType.init(inst, def);
25390
25152
  const memo = globalConfig.memoizer;
25391
25153
  memo?.attach(inst);
@@ -25402,6 +25164,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
25402
25164
  }
25403
25165
  payload.value = memo ? memo.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
25404
25166
  const proms = [];
25167
+ const abortEarly = ctx?.abortEarly;
25405
25168
  for (let i = 0; i < input.length; i++) {
25406
25169
  const item = input[i];
25407
25170
  const result = def.element._zod.run({
@@ -25413,6 +25176,9 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
25413
25176
  }
25414
25177
  else {
25415
25178
  handleArrayResult(result, payload, i);
25179
+ // the element's payload is authoritative here, since handleArrayResult forwards every issue; an object's is not, because it drops a failed absent optional
25180
+ if (abortEarly && result.issues.length !== 0 && aborted(result))
25181
+ break;
25416
25182
  }
25417
25183
  }
25418
25184
  if (proms.length) {
@@ -25420,6 +25186,7 @@ const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
25420
25186
  }
25421
25187
  return payload; //handleArrayResultsAsync(parseResults, final);
25422
25188
  };
25189
+ capSize(inst, arraySize);
25423
25190
  });
25424
25191
  function handlePropertyResult(result, final, key, input, optin, optout) {
25425
25192
  const isPresent = key in input;
@@ -25447,7 +25214,7 @@ function handlePropertyResult(result, final, key, input, optin, optout) {
25447
25214
  return;
25448
25215
  }
25449
25216
  if (result.value === undefined) {
25450
- if (isPresent) {
25217
+ if (isPresent || (optin === "defaulted" && !isOptionalOut)) {
25451
25218
  final.value[key] = undefined;
25452
25219
  }
25453
25220
  }
@@ -25479,14 +25246,21 @@ function normalizeDef(def) {
25479
25246
  optionalKeys: new Set(okeys),
25480
25247
  };
25481
25248
  }
25482
- function handleCatchall(proms, input, payload, ctx, def, inst) {
25249
+ function handleCatchall(proms, input, payload, ctx, def, inst, abortEarly) {
25483
25250
  const unrecognized = [];
25484
25251
  const keySet = def.keySet;
25485
25252
  const _catchall = def.catchall._zod;
25486
25253
  const t = _catchall.def.type;
25487
25254
  const optin = _catchall.optin;
25488
25255
  const optout = _catchall.optout;
25256
+ // starts at 0, not the current length: the shape phase already ran and may have aborted
25257
+ let seen = 0;
25489
25258
  for (const key in input) {
25259
+ if (abortEarly && payload.issues.length !== seen) {
25260
+ if (aborted(payload, seen))
25261
+ break;
25262
+ seen = payload.issues.length;
25263
+ }
25490
25264
  // Must precede the __proto__ branch: a declared key is not unrecognized, even though the shape loop deliberately strips __proto__ from the parsed output.
25491
25265
  if (keySet.has(key))
25492
25266
  continue;
@@ -25524,26 +25298,22 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
25524
25298
  return payload;
25525
25299
  });
25526
25300
  }
25527
- // Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it. Keyed by def, so a def rebuilt by a builder is simply absent rather than inheriting the source's. Read its keys with `Object.keys`, which does not invoke them — that is what lets a discriminated union check its discriminator without resolving an option whose getters reference the union being constructed.
25528
- const propShapes = new WeakMap();
25529
25301
  const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
25530
25302
  // requires cast because technically $ZodObject doesn't extend
25531
25303
  $ZodType.init(inst, def);
25532
- // const sh = def.shape;
25533
25304
  const desc = Object.getOwnPropertyDescriptor(def, "shape");
25534
- if (!desc?.get) {
25535
- const sh = def.shape;
25536
- propShapes.set(def, sh);
25537
- Object.defineProperty(def, "shape", {
25538
- get: () => {
25539
- const newSh = { ...sh };
25540
- Object.defineProperty(def, "shape", {
25541
- value: newSh,
25542
- });
25543
- propShapes.set(def, newSh);
25544
- return newSh;
25545
- },
25546
- });
25305
+ // a cloned def carries its source's accessor, which knows the shape it answers from; adopting that keeps the clone's keys readable without running it
25306
+ const sh = desc?.get ? desc.get.raw : (def.shape ?? {});
25307
+ if (sh) {
25308
+ // Freezes the shape on first read, so its getters resolve once and every later read sees the same schemas.
25309
+ const get = () => {
25310
+ const newSh = { ...sh };
25311
+ Object.defineProperty(def, "shape", { value: newSh });
25312
+ get.raw = newSh;
25313
+ return newSh;
25314
+ };
25315
+ get.raw = sh;
25316
+ Object.defineProperty(def, "shape", { get });
25547
25317
  }
25548
25318
  const _normalized = util_cached(() => normalizeDef(def));
25549
25319
  defineLazyInternal(inst, "propValues", (zod) => {
@@ -25584,7 +25354,14 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
25584
25354
  payload.value = memo ? memo.alloc(inst, payload, {}, ctx) : {};
25585
25355
  const proms = [];
25586
25356
  const shape = value.shape;
25357
+ const abortEarly = ctx?.abortEarly;
25358
+ let seen = payload.issues.length;
25587
25359
  for (const key of value.allKeys) {
25360
+ if (abortEarly && payload.issues.length !== seen) {
25361
+ if (aborted(payload, seen))
25362
+ break;
25363
+ seen = payload.issues.length;
25364
+ }
25588
25365
  if (key === "__proto__")
25589
25366
  continue;
25590
25367
  const el = shape[key];
@@ -25601,7 +25378,7 @@ const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
25601
25378
  if (!catchall) {
25602
25379
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
25603
25380
  }
25604
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
25381
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst, abortEarly === true);
25605
25382
  };
25606
25383
  });
25607
25384
  const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -25616,12 +25393,18 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
25616
25393
  // a symbol has no source literal, so it is read as `syms[i]` off the closed-over scope
25617
25394
  const doc = new Doc(["payload", "ctx"], { shape, inst, memo, syms });
25618
25395
  const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
25619
- // Prefixes in place, like util.prefixIssues does for every interpreted path.
25396
+ // prefixes in place, like util.prefixIssues. newResult must land before the early return: a catchall runs after this and would otherwise write onto the caller's input
25620
25397
  const prefixStr = (id, k) => `
25398
+ let ${id}_ab = false;
25621
25399
  for (let i = 0; i < ${id}.issues.length; i++) {
25622
25400
  const iss = ${id}.issues[i];
25623
25401
  iss.path = iss.path ? [${k}, ...iss.path] : [${k}];
25624
25402
  payload.issues.push(iss);
25403
+ if (iss.continue !== true) ${id}_ab = true;
25404
+ }
25405
+ if (${id}_ab && ctx && ctx.abortEarly) {
25406
+ payload.value = newResult;
25407
+ return payload;
25625
25408
  }`;
25626
25409
  doc.write(`const input = payload.value;`);
25627
25410
  const ids = Object.create(null);
@@ -25670,6 +25453,10 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
25670
25453
  input: undefined,
25671
25454
  path: [${k}]
25672
25455
  });
25456
+ if (ctx && ctx.abortEarly) {
25457
+ payload.value = newResult;
25458
+ return payload;
25459
+ }
25673
25460
  }
25674
25461
 
25675
25462
  if (${id}_present) {
@@ -25682,16 +25469,17 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
25682
25469
  doc.write(`
25683
25470
  if (${id}.issues.length) {${prefixStr(id, k)}
25684
25471
  }
25685
-
25686
- if (${id}.value === undefined) {
25687
- if (${isPresent}) {
25688
- newResult[${k}] = undefined;
25689
- }
25690
- } else {
25472
+ `);
25473
+ if (optin === "defaulted") {
25474
+ doc.write(`newResult[${k}] = ${id}.value;`);
25475
+ }
25476
+ else {
25477
+ doc.write(`
25478
+ if (${id}.value !== undefined || ${isPresent}) {
25691
25479
  newResult[${k}] = ${id}.value;
25692
25480
  }
25693
-
25694
25481
  `);
25482
+ }
25695
25483
  }
25696
25484
  }
25697
25485
  doc.write(`payload.value = newResult;`);
@@ -25725,7 +25513,7 @@ const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) =>
25725
25513
  payload = fastpass(payload, ctx);
25726
25514
  if (!catchall)
25727
25515
  return payload;
25728
- return handleCatchall([], input, payload, ctx, value, inst);
25516
+ return handleCatchall([], input, payload, ctx, value, inst, ctx?.abortEarly === true);
25729
25517
  }
25730
25518
  return superParse(payload, ctx);
25731
25519
  };
@@ -25862,22 +25650,38 @@ const $ZodXor = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
25862
25650
  });
25863
25651
  };
25864
25652
  })));
25865
- /** Returns the option of `union` whose discriminator claims `value`. */
25653
+ /** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
25866
25654
  function getDiscriminatedOption(union, value) {
25867
25655
  const internals = union._zod;
25868
25656
  let map = internals.bag.optionsMap;
25869
25657
  if (!map) {
25870
- map = new Map();
25871
- const { options, discriminator } = internals.def;
25872
- for (const option of options) {
25873
- // First declaration wins, matching the order the parse path resolves a duplicate in.
25874
- for (const v of option._zod.propValues?.[discriminator] ?? [])
25875
- if (!map.has(v))
25876
- map.set(v, option);
25877
- }
25658
+ map = discriminatorMap(internals.def);
25878
25659
  internals.bag.optionsMap = map;
25879
25660
  }
25880
- return map.get(value);
25661
+ const option = map.get(value);
25662
+ if (option === null)
25663
+ throw new Error(`Ambiguous discriminator value "${String(value)}"`);
25664
+ return option;
25665
+ }
25666
+ function discriminatorMap(def) {
25667
+ const map = new Map();
25668
+ for (const option of def.options) {
25669
+ const values = option._zod.propValues?.[def.discriminator];
25670
+ if (!values || values.size === 0)
25671
+ throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
25672
+ for (const value of values) {
25673
+ if (map.has(value)) {
25674
+ if (value !== undefined)
25675
+ throw new Error(`Duplicate discriminator value "${String(value)}"`);
25676
+ // keep the collision marked so a later member cannot reclaim it
25677
+ map.set(value, null);
25678
+ }
25679
+ else {
25680
+ map.set(value, option);
25681
+ }
25682
+ }
25683
+ }
25684
+ return map;
25881
25685
  }
25882
25686
  const $ZodDiscriminatedUnion =
25883
25687
  /*@__PURE__*/
@@ -25887,10 +25691,13 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
25887
25691
  const _super = inst._zod.parse;
25888
25692
  defineLazyInternal(inst, "propValues", (zod) => {
25889
25693
  const propValues = {};
25694
+ let undefinedCount = 0;
25890
25695
  for (const option of zod.def.options) {
25891
25696
  const pv = option._zod.propValues;
25892
25697
  if (!pv || Object.keys(pv).length === 0)
25893
25698
  throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
25699
+ if (pv[zod.def.discriminator]?.has(undefined))
25700
+ undefinedCount++;
25894
25701
  for (const [k, v] of Object.entries(pv)) {
25895
25702
  if (!Object.prototype.hasOwnProperty.call(propValues, k)) {
25896
25703
  util_assignProp(propValues, k, new Set());
@@ -25900,31 +25707,18 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
25900
25707
  }
25901
25708
  }
25902
25709
  }
25710
+ if (!zod.def.unionFallback && undefinedCount > 1)
25711
+ propValues[zod.def.discriminator]?.delete(undefined);
25903
25712
  return propValues;
25904
25713
  });
25905
- // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes, lazies, and objects rebuilt by a builder such as `.extend()` — are left to the map.
25714
+ // Checked now rather than in the lookup map below, so an option that lacks the discriminator fails at the `discriminatedUnion` call instead of on the first object parsed. Options whose shape cannot be enumerated without resolving it — pipes and lazies — are left to the map.
25906
25715
  def.options.forEach((option, i) => {
25907
- const propShape = propShapes.get(option._zod.def);
25716
+ const propShape = rawShape(option._zod.def);
25908
25717
  if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) {
25909
25718
  throw new Error(`Invalid discriminated union option at index "${i}"`);
25910
25719
  }
25911
25720
  });
25912
- const disc = util_cached(() => {
25913
- const opts = def.options;
25914
- const map = new Map();
25915
- for (const o of opts) {
25916
- const values = o._zod.propValues?.[def.discriminator];
25917
- if (!values || values.size === 0)
25918
- throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
25919
- for (const v of values) {
25920
- if (map.has(v)) {
25921
- throw new Error(`Duplicate discriminator value "${String(v)}"`);
25922
- }
25923
- map.set(v, o);
25924
- }
25925
- }
25926
- return map;
25927
- });
25721
+ const disc = util_cached(() => discriminatorMap(def));
25928
25722
  inst._zod.parse = (payload, ctx) => {
25929
25723
  const input = payload.value;
25930
25724
  if (!util_isObject(input)) {
@@ -25936,8 +25730,10 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
25936
25730
  });
25937
25731
  return payload;
25938
25732
  }
25939
- const opt = disc.value.get(input?.[def.discriminator]);
25940
- if (opt) {
25733
+ const value = input?.[def.discriminator];
25734
+ const opt = disc.value.get(value);
25735
+ // forward metadata cannot choose an encoder for an absent tag
25736
+ if (opt && (value !== undefined || ctx.direction !== "backward")) {
25941
25737
  return opt._zod.run(payload, ctx);
25942
25738
  }
25943
25739
  // Fall back to union matching when the fast discriminator path fails:
@@ -25952,7 +25748,7 @@ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
25952
25748
  errors: [],
25953
25749
  note: "No matching discriminator",
25954
25750
  discriminator: def.discriminator,
25955
- options: Array.from(disc.value.keys()),
25751
+ options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
25956
25752
  input,
25957
25753
  path: [def.discriminator],
25958
25754
  inst,
@@ -26125,6 +25921,9 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
26125
25921
  }
26126
25922
  // Run every item in parallel, collecting results into an indexed array. The post-processing in `handleTupleResults` walks them in order so it can decide whether an absent optional-output error can truncate the tail or must be reported to preserve required output.
26127
25923
  const itemResults = new Array(items.length);
25924
+ // only tracked when there is a rest loop to skip
25925
+ const abortEarly = def.rest ? ctx?.abortEarly : undefined;
25926
+ let itemAborted = false;
26128
25927
  for (let i = 0; i < items.length; i++) {
26129
25928
  const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
26130
25929
  if (r instanceof Promise) {
@@ -26134,12 +25933,21 @@ const $ZodTuple = /*@__PURE__*/ (/* unused pure expression or super */ null && (
26134
25933
  }
26135
25934
  else {
26136
25935
  itemResults[i] = r;
25936
+ if (abortEarly && !itemAborted && r.issues.length)
25937
+ itemAborted = util.aborted(r);
26137
25938
  }
26138
25939
  }
26139
- if (def.rest) {
25940
+ // sound because rest is non-empty exactly when every fixed index is present, the one case handleTupleResults cannot discard an item's issues
25941
+ if (def.rest && !itemAborted) {
26140
25942
  let i = items.length - 1;
26141
25943
  const rest = input.slice(items.length);
25944
+ let seen = payload.issues.length;
26142
25945
  for (const el of rest) {
25946
+ if (abortEarly && payload.issues.length !== seen) {
25947
+ if (util.aborted(payload, seen))
25948
+ break;
25949
+ seen = payload.issues.length;
25950
+ }
26143
25951
  i++;
26144
25952
  const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
26145
25953
  if (result instanceof Promise) {
@@ -26221,6 +26029,7 @@ const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
26221
26029
  });
26222
26030
  return payload;
26223
26031
  }
26032
+ // no guard in either loop below: a record's invalid_key aborts but an enclosing intersection can reconcile it, so a stopped loop hides keys the sibling does not own and the intersection then rejects nothing
26224
26033
  const proms = [];
26225
26034
  const values = def.keyType._zod.values;
26226
26035
  if (values && !def.partial) {
@@ -26392,7 +26201,14 @@ const $ZodMap = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
26392
26201
  }
26393
26202
  const proms = [];
26394
26203
  payload.value = memo ? memo.alloc(inst, payload, new Map(), ctx) : new Map();
26204
+ const abortEarly = ctx?.abortEarly;
26205
+ let seen = payload.issues.length;
26395
26206
  for (const [key, value] of input) {
26207
+ if (abortEarly && payload.issues.length !== seen) {
26208
+ if (util.aborted(payload, seen))
26209
+ break;
26210
+ seen = payload.issues.length;
26211
+ }
26396
26212
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
26397
26213
  const valueResult = def.valueType._zod.run({ value: value, issues: [] }, ctx);
26398
26214
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
@@ -26408,6 +26224,7 @@ const $ZodMap = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
26408
26224
  return Promise.all(proms).then(() => payload);
26409
26225
  return payload;
26410
26226
  };
26227
+ capSize(inst, mapSize);
26411
26228
  })));
26412
26229
  function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
26413
26230
  if (keyResult.issues.length) {
@@ -26458,7 +26275,14 @@ const $ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
26458
26275
  }
26459
26276
  const proms = [];
26460
26277
  payload.value = memo ? memo.alloc(inst, payload, new Set(), ctx) : new Set();
26278
+ const abortEarly = ctx?.abortEarly;
26279
+ let seen = payload.issues.length;
26461
26280
  for (const item of input) {
26281
+ if (abortEarly && payload.issues.length !== seen) {
26282
+ if (util.aborted(payload, seen))
26283
+ break;
26284
+ seen = payload.issues.length;
26285
+ }
26462
26286
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
26463
26287
  if (result instanceof Promise) {
26464
26288
  proms.push(result.then((result) => handleSetResult(result, payload)));
@@ -26470,6 +26294,7 @@ const $ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
26470
26294
  return Promise.all(proms).then(() => payload);
26471
26295
  return payload;
26472
26296
  };
26297
+ capSize(inst, setSize);
26473
26298
  })));
26474
26299
  function handleSetResult(result, final) {
26475
26300
  if (result.issues.length) {
@@ -26482,9 +26307,11 @@ const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
26482
26307
  const values = getEnumValues(def.entries);
26483
26308
  const valuesSet = new Set(values);
26484
26309
  inst._zod.values = valuesSet;
26485
- const patternValues = values.filter((k) => propertyKeyTypes.has(typeof k));
26486
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
26487
- inst._zod.pattern = new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
26310
+ defineLazyInternal(inst, "pattern", (zod) => {
26311
+ const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
26312
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
26313
+ return new RegExp(patternValues.length ? `^(${patternValues.map((o) => escapeRegex(o.toString())).join("|")})$` : "^[^\\s\\S]$");
26314
+ });
26488
26315
  inst._zod.parse = (payload, _ctx) => {
26489
26316
  const input = payload.value;
26490
26317
  if (valuesSet.has(input)) {
@@ -26503,12 +26330,15 @@ const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
26503
26330
  $ZodType.init(inst, def);
26504
26331
  const values = new Set(def.values);
26505
26332
  inst._zod.values = values;
26506
- // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
26507
- inst._zod.pattern = new RegExp(def.values.length
26508
- ? `^(${def.values
26509
- .map((o) => (typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)))
26510
- .join("|")})$`
26511
- : "^[^\\s\\S]$");
26333
+ defineLazyInternal(inst, "pattern", (zod) => {
26334
+ const vals = zod.def.values;
26335
+ // unmatchable fallback, RE2-safe: an empty alternation would compile to /^()$/, which matches ""
26336
+ return new RegExp(vals.length
26337
+ ? `^(${vals
26338
+ .map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o))
26339
+ .join("|")})$`
26340
+ : "^[^\\s\\S]$");
26341
+ });
26512
26342
  inst._zod.parse = (payload, _ctx) => {
26513
26343
  const input = payload.value;
26514
26344
  if (values.has(input)) {
@@ -26872,22 +26702,67 @@ function handleReadonlyResult(payload) {
26872
26702
  payload.value = Object.freeze(payload.value);
26873
26703
  return payload;
26874
26704
  }
26705
+ // a leaf's pattern source with its own checks folded in: the last pattern-carrying check wins, else length bounds narrow the catch-all, else an integer format narrows the number form. the fold lives here instead of on `_zod.pattern` so a bundle without template literals never pays for it
26706
+ function leafPattern(schema) {
26707
+ const def = schema._zod.def;
26708
+ let pattern = def.pattern;
26709
+ let isInt = !!def.format?.includes("int");
26710
+ let minimum;
26711
+ let maximum;
26712
+ for (const ch of def.checks ?? []) {
26713
+ const d = ch._zod.def;
26714
+ if (d.pattern)
26715
+ pattern = d.pattern;
26716
+ isInt || (isInt = !!d.format?.includes("int"));
26717
+ const lo = d.minimum ?? d.length;
26718
+ const hi = d.maximum ?? d.length;
26719
+ if (lo !== undefined && (minimum === undefined || lo > minimum))
26720
+ minimum = lo;
26721
+ if (hi !== undefined && (maximum === undefined || hi < maximum))
26722
+ maximum = hi;
26723
+ }
26724
+ if (pattern)
26725
+ return pattern.source;
26726
+ // an empty range matches nothing at runtime, and `{8,5}` is not a legal quantifier
26727
+ if (minimum !== undefined && maximum !== undefined && minimum > maximum)
26728
+ return "(?!)";
26729
+ if (minimum !== undefined || maximum !== undefined)
26730
+ return regexes.string({ minimum, maximum }).source;
26731
+ const own = schema._zod.pattern;
26732
+ return (isInt && own === regexes.number ? regexes.integer : own)?.source;
26733
+ }
26734
+ // a part's pattern source. a wrapper's pattern embeds its inner pattern's source verbatim, so the folded form is substituted in place without knowing the wrapper's own composition; a union's options are joined the way the union builds its own pattern
26735
+ function partPattern(schema) {
26736
+ const def = schema._zod.def;
26737
+ const own = schema._zod.pattern?.source;
26738
+ // lazy resolves its inner on the internals, not the def
26739
+ const inner = def.innerType ?? schema._zod.innerType;
26740
+ if (inner) {
26741
+ const before = inner._zod.pattern?.source;
26742
+ const after = partPattern(inner);
26743
+ if (own && before && after && after !== before) {
26744
+ return own.replace(util.cleanRegex(before), () => util.cleanRegex(after));
26745
+ }
26746
+ return own;
26747
+ }
26748
+ if (def.options) {
26749
+ const sources = def.options.map(partPattern);
26750
+ if (sources.every(Boolean))
26751
+ return `^(${sources.map((s) => util.cleanRegex(s)).join("|")})$`;
26752
+ }
26753
+ return leafPattern(schema);
26754
+ }
26875
26755
  const $ZodTemplateLiteral = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("$ZodTemplateLiteral", (inst, def) => {
26876
26756
  $ZodType.init(inst, def);
26877
26757
  const regexParts = [];
26878
26758
  for (const part of def.parts) {
26879
26759
  if (typeof part === "object" && part !== null) {
26880
26760
  // is Zod schema
26881
- if (!part._zod.pattern) {
26882
- // if (!source)
26761
+ const source = partPattern(part);
26762
+ if (!source) {
26883
26763
  throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
26884
26764
  }
26885
- const source = part._zod.pattern instanceof RegExp ? part._zod.pattern.source : part._zod.pattern;
26886
- if (!source)
26887
- throw new Error(`Invalid template literal part: ${part._zod.traits}`);
26888
- const start = source.startsWith("^") ? 1 : 0;
26889
- const end = source.endsWith("$") ? source.length - 1 : source.length;
26890
- regexParts.push(source.slice(start, end));
26765
+ regexParts.push(util.cleanRegex(source));
26891
26766
  }
26892
26767
  else if (part === null || util.primitiveTypes.has(typeof part)) {
26893
26768
  regexParts.push(util.escapeRegex(`${part}`));
@@ -27116,20 +26991,18 @@ const globalRegistry = globalThis.__zod_globalRegistry;
27116
26991
 
27117
26992
 
27118
26993
 
26994
+ function snapshotChecks(def) {
26995
+ if (def.checks)
26996
+ def.checks = [...def.checks];
26997
+ return def;
26998
+ }
27119
26999
  // @__NO_SIDE_EFFECTS__
27120
27000
  function _string(Class, params) {
27121
- return new Class({
27122
- type: "string",
27123
- ...normalizeParams(params),
27124
- });
27001
+ return new Class(snapshotChecks({ type: "string", ...normalizeParams(params) }));
27125
27002
  }
27126
27003
  // @__NO_SIDE_EFFECTS__
27127
27004
  function _coercedString(Class, params) {
27128
- return new Class({
27129
- type: "string",
27130
- coerce: true,
27131
- ...util.normalizeParams(params),
27132
- });
27005
+ return new Class(snapshotChecks({ type: "string", coerce: true, ...util.normalizeParams(params) }));
27133
27006
  }
27134
27007
  // @__NO_SIDE_EFFECTS__
27135
27008
  function _email(Class, params) {
@@ -27370,6 +27243,16 @@ function _creditCard(Class, params) {
27370
27243
  });
27371
27244
  }
27372
27245
  // @__NO_SIDE_EFFECTS__
27246
+ function _iban(Class, params) {
27247
+ return new Class({
27248
+ type: "string",
27249
+ format: "iban",
27250
+ check: "string_format",
27251
+ abort: false,
27252
+ ...util.normalizeParams(params),
27253
+ });
27254
+ }
27255
+ // @__NO_SIDE_EFFECTS__
27373
27256
  function _jwt(Class, params) {
27374
27257
  return new Class({
27375
27258
  type: "string",
@@ -27428,20 +27311,11 @@ function _isoDuration(Class, params) {
27428
27311
  }
27429
27312
  // @__NO_SIDE_EFFECTS__
27430
27313
  function _number(Class, params) {
27431
- return new Class({
27432
- type: "number",
27433
- checks: [],
27434
- ...normalizeParams(params),
27435
- });
27314
+ return new Class(snapshotChecks({ type: "number", checks: [], ...normalizeParams(params) }));
27436
27315
  }
27437
27316
  // @__NO_SIDE_EFFECTS__
27438
27317
  function _coercedNumber(Class, params) {
27439
- return new Class({
27440
- type: "number",
27441
- coerce: true,
27442
- checks: [],
27443
- ...util.normalizeParams(params),
27444
- });
27318
+ return new Class(snapshotChecks({ type: "number", coerce: true, checks: [], ...util.normalizeParams(params) }));
27445
27319
  }
27446
27320
  // @__NO_SIDE_EFFECTS__
27447
27321
  function _int(Class, params) {
@@ -27788,8 +27662,12 @@ function _property(property, schema, params) {
27788
27662
  });
27789
27663
  }
27790
27664
  // @__NO_SIDE_EFFECTS__
27791
- function _properties(shape) {
27792
- return Object.entries(shape).map(([property, schema]) => new checks.$ZodCheckProperty({ check: "property", property, schema }));
27665
+ function _properties(shape, params) {
27666
+ return new checks.$ZodCheckProperties({
27667
+ check: "properties",
27668
+ shape,
27669
+ ...util.normalizeParams(params),
27670
+ });
27793
27671
  }
27794
27672
  // @__NO_SIDE_EFFECTS__
27795
27673
  function _mime(types, params) {
@@ -28255,6 +28133,7 @@ function to_json_schema_initializeContext(params) {
28255
28133
  cycles: params?.cycles ?? "ref",
28256
28134
  reused: params?.reused ?? "inline",
28257
28135
  intersections: [],
28136
+ deferred: [],
28258
28137
  external: params?.external ?? undefined,
28259
28138
  };
28260
28139
  }
@@ -28274,7 +28153,8 @@ function to_json_schema_handleUnrepresentable(schema, ctx, json, params, message
28274
28153
  Object.assign(json, result);
28275
28154
  return true;
28276
28155
  }
28277
- function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [] }) {
28156
+ // never rename this back to `process`: bundler polyfills inject a top-level `const process` that a lexical declaration of the same name collides with (#6397)
28157
+ function to_json_schema_processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
28278
28158
  var _a;
28279
28159
  const def = schema._zod.def;
28280
28160
  // check for schema in seens
@@ -28320,7 +28200,7 @@ function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [
28320
28200
  // Also set ref if processor didn't (for inheritance)
28321
28201
  if (!result.ref)
28322
28202
  result.ref = parent;
28323
- to_json_schema_process(parent, ctx, params);
28203
+ to_json_schema_processSchema(parent, ctx, params);
28324
28204
  ctx.seen.get(parent).isParent = true;
28325
28205
  }
28326
28206
  }
@@ -28341,6 +28221,8 @@ function to_json_schema_process(schema, ctx, _params = { path: [], schemaPath: [
28341
28221
  const _result = ctx.seen.get(schema);
28342
28222
  return _result.schema;
28343
28223
  }
28224
+ /** @deprecated Renamed to `processSchema`. An export alias declares no binding, so it is safe to keep. */
28225
+
28344
28226
  // Escape a reference token for use in a JSON Pointer fragment (RFC 6901): `~` becomes `~0` and `/` becomes `~1`. The `~` replacement must run first.
28345
28227
  function encodeJSONPointerSegment(segment) {
28346
28228
  return segment.replace(/~/g, "~0").replace(/\//g, "~1");
@@ -28457,8 +28339,6 @@ function to_json_schema_extractDefs(ctx, schema
28457
28339
  if (seen.count > 1) {
28458
28340
  if (ctx.reused === "ref") {
28459
28341
  extractToDef(entry);
28460
- // biome-ignore lint:
28461
- continue;
28462
28342
  }
28463
28343
  }
28464
28344
  }
@@ -28688,6 +28568,8 @@ function to_json_schema_finalize(ctx, schema) {
28688
28568
  compactTypeUnion(entry[1].def ?? entry[1].schema);
28689
28569
  }
28690
28570
  }
28571
+ for (const rewrite of ctx.deferred)
28572
+ rewrite();
28691
28573
  // After flattening, every member that was extracted is a `$ref`, so the fold sees the final shape. A schema that inherits an intersection — through `z.lazy`, or any `ref` chain — holds the same `allOf` array, so fold by array identity to catch every copy.
28692
28574
  if (ctx.intersections.length) {
28693
28575
  const carriers = new Map();
@@ -28850,14 +28732,14 @@ function isTransforming(_schema, _ctx) {
28850
28732
  */
28851
28733
  const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
28852
28734
  const ctx = to_json_schema_initializeContext({ ...params, processors });
28853
- to_json_schema_process(schema, ctx);
28735
+ to_json_schema_processSchema(schema, ctx);
28854
28736
  to_json_schema_extractDefs(ctx, schema);
28855
28737
  return to_json_schema_finalize(ctx, schema);
28856
28738
  };
28857
28739
  const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
28858
28740
  const { libraryOptions, target } = params ?? {};
28859
28741
  const ctx = to_json_schema_initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
28860
- to_json_schema_process(schema, ctx);
28742
+ to_json_schema_processSchema(schema, ctx);
28861
28743
  to_json_schema_extractDefs(ctx, schema);
28862
28744
  return to_json_schema_finalize(ctx, schema);
28863
28745
  };
@@ -28865,6 +28747,101 @@ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params)
28865
28747
  ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/json-schema-processors.js
28866
28748
 
28867
28749
 
28750
+
28751
+
28752
+ const narrowMin = (agg, key, value) => {
28753
+ if (agg[key] === undefined || value > agg[key])
28754
+ agg[key] = value;
28755
+ };
28756
+ const narrowMax = (agg, key, value) => {
28757
+ if (agg[key] === undefined || value < agg[key])
28758
+ agg[key] = value;
28759
+ };
28760
+ const narrowBoth = (agg, value) => {
28761
+ narrowMin(agg, "minimum", value);
28762
+ narrowMax(agg, "maximum", value);
28763
+ };
28764
+ const addDivisor = (agg, value) => {
28765
+ agg.multipleOf ?? (agg.multipleOf = []);
28766
+ if (!agg.multipleOf.includes(value))
28767
+ agg.multipleOf.push(value);
28768
+ };
28769
+ const addPattern = (agg, pattern) => {
28770
+ agg.patterns ?? (agg.patterns = new Set());
28771
+ agg.patterns.add(pattern);
28772
+ };
28773
+ const intersectMime = (agg, mime) => {
28774
+ agg.mime = agg.mime ? agg.mime.filter((m) => mime.includes(m)) : [...mime];
28775
+ };
28776
+ // last-wins, matching the bag's historical write order; the flag keeps an integer format from being lost to a later float one
28777
+ const setFormat = (agg, format) => {
28778
+ agg.format = format;
28779
+ if (format.includes("int"))
28780
+ agg.isInt = true;
28781
+ };
28782
+ const minContributor = (agg, def) => narrowMin(agg, "minimum", def.minimum);
28783
+ const maxContributor = (agg, def) => narrowMax(agg, "maximum", def.maximum);
28784
+ const formatContributor = (ranges) => (agg, def) => {
28785
+ setFormat(agg, def.format);
28786
+ const [minimum, maximum] = ranges[def.format];
28787
+ narrowMin(agg, "minimum", minimum);
28788
+ narrowMax(agg, "maximum", maximum);
28789
+ };
28790
+ const contributors = {
28791
+ greater_than: (agg, def) => narrowMin(agg, def.inclusive ? "minimum" : "exclusiveMinimum", def.value),
28792
+ less_than: (agg, def) => narrowMax(agg, def.inclusive ? "maximum" : "exclusiveMaximum", def.value),
28793
+ multiple_of: (agg, def) => addDivisor(agg, def.value),
28794
+ number_format: formatContributor(NUMBER_FORMAT_RANGES),
28795
+ bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
28796
+ min_length: minContributor,
28797
+ max_length: maxContributor,
28798
+ length_equals: (agg, def) => narrowBoth(agg, def.length),
28799
+ min_size: minContributor,
28800
+ max_size: maxContributor,
28801
+ size_equals: (agg, def) => narrowBoth(agg, def.size),
28802
+ string_format: (agg, def) => {
28803
+ setFormat(agg, def.format);
28804
+ if (def.pattern)
28805
+ addPattern(agg, def.pattern);
28806
+ if (def.format === "base64" || def.format === "base64url")
28807
+ agg.contentEncoding = def.format;
28808
+ if (def.local || def.precision === -1)
28809
+ agg.laxFormat = true;
28810
+ },
28811
+ mime_type: (agg, def) => intersectMime(agg, def.mime),
28812
+ };
28813
+ function aggregateChecks(schema) {
28814
+ const agg = {};
28815
+ const def = schema._zod.def;
28816
+ // a format schema is its own first check, same rule as $ZodType init
28817
+ const list = schema._zod.traits.has("$ZodCheck")
28818
+ ? [schema, ...(def.checks ?? [])]
28819
+ : (def.checks ?? []);
28820
+ for (const ch of list)
28821
+ contributors[ch._zod.def.check]?.(agg, ch._zod.def);
28822
+ // reconcile with the bag so third-party onattach contributions still land; first-party residue is never tighter than the fold, so merging it back is idempotent for one and additive for the other
28823
+ const bag = schema._zod.bag;
28824
+ if (bag.minimum !== undefined)
28825
+ narrowMin(agg, "minimum", bag.minimum);
28826
+ if (bag.exclusiveMinimum !== undefined)
28827
+ narrowMin(agg, "exclusiveMinimum", bag.exclusiveMinimum);
28828
+ if (bag.maximum !== undefined)
28829
+ narrowMax(agg, "maximum", bag.maximum);
28830
+ if (bag.exclusiveMaximum !== undefined)
28831
+ narrowMax(agg, "exclusiveMaximum", bag.exclusiveMaximum);
28832
+ if (bag.multipleOf !== undefined)
28833
+ addDivisor(agg, bag.multipleOf);
28834
+ if (bag.format !== undefined) {
28835
+ agg.format ?? (agg.format = bag.format);
28836
+ if (bag.format.includes("int"))
28837
+ agg.isInt = true;
28838
+ }
28839
+ if (bag.mime)
28840
+ intersectMime(agg, bag.mime);
28841
+ for (const pattern of bag.patterns ?? [])
28842
+ addPattern(agg, pattern);
28843
+ return agg;
28844
+ }
28868
28845
  const formatMap = {
28869
28846
  guid: "uuid",
28870
28847
  url: "uri",
@@ -28873,11 +28850,16 @@ const formatMap = {
28873
28850
  regex: "", // do not set
28874
28851
  };
28875
28852
  // ==================== SIMPLE TYPE PROCESSORS ====================
28853
+ // the runtime patterns are lax so parse paths never overflow the regex stack; the emitted schema swaps in the exact block forms, which zod itself never executes
28854
+ const exactPatterns = new Map([
28855
+ [base64Charset, regexes_base64],
28856
+ [base64urlCharset, regexes_base64url],
28857
+ ]);
28858
+ const exactPattern = (p) => exactPatterns.get(p) ?? p;
28876
28859
  const stringProcessor = (schema, ctx, _json, _params) => {
28877
28860
  const json = _json;
28878
28861
  json.type = "string";
28879
- const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = schema._zod
28880
- .bag;
28862
+ const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
28881
28863
  if (typeof minimum === "number")
28882
28864
  json.minLength = minimum;
28883
28865
  if (typeof maximum === "number")
@@ -28895,12 +28877,12 @@ const stringProcessor = (schema, ctx, _json, _params) => {
28895
28877
  if (contentEncoding)
28896
28878
  json.contentEncoding = contentEncoding;
28897
28879
  if (patterns && patterns.size > 0) {
28898
- const regexes = [...patterns];
28899
- if (regexes.length === 1)
28900
- json.pattern = regexes[0].source;
28901
- else if (regexes.length > 1) {
28880
+ const patternList = [...patterns].map(exactPattern);
28881
+ if (patternList.length === 1)
28882
+ json.pattern = patternList[0].source;
28883
+ else if (patternList.length > 1) {
28902
28884
  json.allOf = [
28903
- ...regexes.map((regex) => ({
28885
+ ...patternList.map((regex) => ({
28904
28886
  ...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
28905
28887
  ? { type: "string" }
28906
28888
  : {}),
@@ -28912,11 +28894,8 @@ const stringProcessor = (schema, ctx, _json, _params) => {
28912
28894
  };
28913
28895
  const numberProcessor = (schema, ctx, _json, params) => {
28914
28896
  const json = _json;
28915
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
28916
- if (typeof format === "string" && format.includes("int"))
28917
- json.type = "integer";
28918
- else
28919
- json.type = "number";
28897
+ const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
28898
+ json.type = isInt ? "integer" : "number";
28920
28899
  // when both minimum and exclusiveMinimum exist, pick the more restrictive one
28921
28900
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
28922
28901
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
@@ -28945,12 +28924,21 @@ const numberProcessor = (schema, ctx, _json, params) => {
28945
28924
  else if (typeof maximum === "number") {
28946
28925
  json.maximum = maximum;
28947
28926
  }
28948
- if (typeof multipleOf === "number") {
28927
+ if (multipleOf) {
28949
28928
  // JSON Schema requires a divisor strictly greater than zero, and a non-finite one does not survive JSON at all. A negative divisor accepts exactly what its absolute value accepts, so it still maps; zero, NaN and Infinity have no keyword form.
28950
- if (Number.isFinite(multipleOf) && multipleOf !== 0)
28951
- json.multipleOf = Math.abs(multipleOf);
28952
- else
28953
- to_json_schema_handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${multipleOf} cannot be represented in JSON Schema`);
28929
+ const divisors = new Set();
28930
+ for (const divisor of multipleOf) {
28931
+ if (Number.isFinite(divisor) && divisor !== 0)
28932
+ divisors.add(Math.abs(divisor));
28933
+ else
28934
+ to_json_schema_handleUnrepresentable(schema, ctx, json, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
28935
+ }
28936
+ // chained divisors are a conjunction the keyword cannot carry alone, so extras ride an allOf, same as stacked patterns
28937
+ const [first, ...rest] = divisors;
28938
+ if (first !== undefined)
28939
+ json.multipleOf = first;
28940
+ if (rest.length)
28941
+ json.allOf = [...(json.allOf ?? []), ...rest.map((m) => ({ multipleOf: m }))];
28954
28942
  }
28955
28943
  };
28956
28944
  const booleanProcessor = (_schema, _ctx, json, _params) => {
@@ -29067,29 +29055,24 @@ const templateLiteralProcessor = (schema, _ctx, json, _params) => {
29067
29055
  };
29068
29056
  const fileProcessor = (schema, _ctx, json, _params) => {
29069
29057
  const _json = json;
29070
- const file = {
29071
- type: "string",
29072
- format: "binary",
29073
- contentEncoding: "binary",
29074
- };
29075
- const { minimum, maximum, mime } = schema._zod.bag;
29058
+ _json.type = "string";
29059
+ _json.format = "binary";
29060
+ _json.contentEncoding = "binary";
29061
+ const { minimum, maximum, mime } = aggregateChecks(schema);
29076
29062
  if (minimum !== undefined)
29077
- file.minLength = minimum;
29063
+ _json.minLength = minimum;
29078
29064
  if (maximum !== undefined)
29079
- file.maxLength = maximum;
29080
- if (mime) {
29081
- if (mime.length === 1) {
29082
- file.contentMediaType = mime[0];
29083
- Object.assign(_json, file);
29084
- }
29085
- else {
29086
- Object.assign(_json, file); // shared props at root
29087
- _json.anyOf = mime.map((m) => ({ contentMediaType: m })); // only contentMediaType differs
29088
- }
29089
- }
29090
- else {
29091
- Object.assign(_json, file);
29092
- }
29065
+ _json.maxLength = maximum;
29066
+ if (!mime)
29067
+ return;
29068
+ // an empty intersection means the mime checks share no value, so nothing passes at runtime; `anyOf` must be non-empty, so the false schema is `not: {}`
29069
+ if (mime.length === 0)
29070
+ _json.not = {};
29071
+ else if (mime.length === 1)
29072
+ _json.contentMediaType = mime[0];
29073
+ // only contentMediaType differs, so the shared props stay at the root
29074
+ else
29075
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
29093
29076
  };
29094
29077
  const successProcessor = (_schema, _ctx, json, _params) => {
29095
29078
  json.type = "boolean";
@@ -29113,13 +29096,13 @@ const setProcessor = (schema, ctx, json, params) => {
29113
29096
  const arrayProcessor = (schema, ctx, _json, params) => {
29114
29097
  const json = _json;
29115
29098
  const def = schema._zod.def;
29116
- const { minimum, maximum } = schema._zod.bag;
29099
+ const { minimum, maximum } = aggregateChecks(schema);
29117
29100
  if (typeof minimum === "number")
29118
29101
  json.minItems = minimum;
29119
29102
  if (typeof maximum === "number")
29120
29103
  json.maxItems = maximum;
29121
29104
  json.type = "array";
29122
- json.items = to_json_schema_process(def.element, ctx, {
29105
+ json.items = to_json_schema_processSchema(def.element, ctx, {
29123
29106
  ...params,
29124
29107
  path: [...params.path, "items"],
29125
29108
  });
@@ -29153,24 +29136,21 @@ const objectProcessor = (schema, ctx, _json, params) => {
29153
29136
  json.properties = {};
29154
29137
  for (const key in shape) {
29155
29138
  // assignProp so a __proto__ key becomes an own property instead of hitting the inherited setter on the plain {} we build into
29156
- util_assignProp(json.properties, key, to_json_schema_process(shape[key], ctx, {
29139
+ util_assignProp(json.properties, key, to_json_schema_processSchema(shape[key], ctx, {
29157
29140
  ...params,
29158
29141
  path: [...params.path, "properties", key],
29159
29142
  }));
29160
29143
  }
29161
29144
  // required keys
29162
- const allKeys = new Set(Object.keys(shape));
29163
- const requiredKeys = new Set([...allKeys].filter((key) => {
29145
+ const requiredKeys = [];
29146
+ for (const key of Object.keys(shape)) {
29164
29147
  const field = def.shape[key];
29165
- if (ctx.io === "input") {
29166
- return inputOptin(field) === undefined;
29167
- }
29168
- else {
29169
- return field._zod.optout === undefined;
29148
+ if (ctx.io === "input" ? inputOptin(field) === undefined : field._zod.optout === undefined) {
29149
+ requiredKeys.push(key);
29170
29150
  }
29171
- }));
29172
- if (requiredKeys.size > 0) {
29173
- json.required = Array.from(requiredKeys);
29151
+ }
29152
+ if (requiredKeys.length > 0) {
29153
+ json.required = requiredKeys;
29174
29154
  }
29175
29155
  // catchall
29176
29156
  if (def.catchall?._zod.def.type === "never") {
@@ -29183,7 +29163,7 @@ const objectProcessor = (schema, ctx, _json, params) => {
29183
29163
  json.additionalProperties = false;
29184
29164
  }
29185
29165
  else if (def.catchall) {
29186
- json.additionalProperties = to_json_schema_process(def.catchall, ctx, {
29166
+ json.additionalProperties = to_json_schema_processSchema(def.catchall, ctx, {
29187
29167
  ...params,
29188
29168
  path: [...params.path, "additionalProperties"],
29189
29169
  });
@@ -29193,7 +29173,7 @@ const unionProcessor = (schema, ctx, json, params) => {
29193
29173
  const def = schema._zod.def;
29194
29174
  // Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches). This includes both z.xor() and discriminated unions
29195
29175
  const isExclusive = def.inclusive === false;
29196
- const options = def.options.map((x, i) => to_json_schema_process(x, ctx, {
29176
+ const options = def.options.map((x, i) => to_json_schema_processSchema(x, ctx, {
29197
29177
  ...params,
29198
29178
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
29199
29179
  }));
@@ -29206,11 +29186,11 @@ const unionProcessor = (schema, ctx, json, params) => {
29206
29186
  };
29207
29187
  const intersectionProcessor = (schema, ctx, json, params) => {
29208
29188
  const def = schema._zod.def;
29209
- const a = to_json_schema_process(def.left, ctx, {
29189
+ const a = to_json_schema_processSchema(def.left, ctx, {
29210
29190
  ...params,
29211
29191
  path: [...params.path, "allOf", 0],
29212
29192
  });
29213
- const b = to_json_schema_process(def.right, ctx, {
29193
+ const b = to_json_schema_processSchema(def.right, ctx, {
29214
29194
  ...params,
29215
29195
  path: [...params.path, "allOf", 1],
29216
29196
  });
@@ -29229,12 +29209,12 @@ const tupleProcessor = (schema, ctx, _json, params) => {
29229
29209
  json.type = "array";
29230
29210
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
29231
29211
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
29232
- const prefixItems = def.items.map((x, i) => process(x, ctx, {
29212
+ const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
29233
29213
  ...params,
29234
29214
  path: [...params.path, prefixPath, i],
29235
29215
  }));
29236
29216
  const rest = def.rest
29237
- ? process(def.rest, ctx, {
29217
+ ? processSchema(def.rest, ctx, {
29238
29218
  ...params,
29239
29219
  path: [...params.path, restPath, ...(ctx.target === "openapi-3.0" ? [def.items.length] : [])],
29240
29220
  })
@@ -29288,40 +29268,127 @@ const tupleProcessor = (schema, ctx, _json, params) => {
29288
29268
  json.maxItems = maxItems;
29289
29269
  }
29290
29270
  // explicit user-defined length checks take precedence
29291
- const { minimum, maximum } = schema._zod.bag;
29271
+ const { minimum, maximum } = aggregateChecks(schema);
29292
29272
  if (typeof minimum === "number")
29293
29273
  json.minItems = minimum;
29294
29274
  if (typeof maximum === "number")
29295
29275
  json.maxItems = maximum;
29296
29276
  };
29277
+ /** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
29278
+ * numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
29279
+ * behind a wrapper only carries its own `type` before then, and a union key only has its branches.
29280
+ *
29281
+ * A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
29282
+ * than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
29283
+ * exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
29284
+ * accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
29285
+ * outright. */
29286
+ function stringifyKeyNames(bySchema, json, visited) {
29287
+ // an extracted key that rewrites cannot go on sharing its definition — the string form a key position needs is not the number form every other reference wants — so it inlines. One that does not rewrite keeps the `$ref`.
29288
+ if (json.$ref) {
29289
+ // a recursive key holds its own reference inside its definition, so a node already on the path is left alone rather than resolved again
29290
+ if (visited.has(json))
29291
+ return json;
29292
+ visited.add(json);
29293
+ const def = bySchema.get(json)?.def;
29294
+ if (!def)
29295
+ return json;
29296
+ const inlined = stringifyKeyNames(bySchema, def, visited);
29297
+ return inlined === def ? json : inlined;
29298
+ }
29299
+ for (const keyword of ["anyOf", "oneOf"]) {
29300
+ const branches = json[keyword];
29301
+ if (!Array.isArray(branches))
29302
+ continue;
29303
+ const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
29304
+ // rebuilding regardless would detach a key that had nothing to re-express, dropping its `$ref` and leaking the internal `id`
29305
+ if (mapped.some((branch, i) => branch !== branches[i]))
29306
+ json = { ...json, [keyword]: mapped };
29307
+ }
29308
+ // a member that already admits a string leaves the key unconstrained, so the node's own type re-expresses only when every member is numeric
29309
+ const types = Array.isArray(json.type) ? json.type : [json.type];
29310
+ const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
29311
+ // a heterogeneous key carries no type at all, so its numeric members are caught here instead
29312
+ const values = json.enum ?? (json.const !== undefined ? [json.const] : undefined);
29313
+ if (!numericType && !values?.some((v) => typeof v === "number"))
29314
+ return json;
29315
+ const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json;
29316
+ if (rest.enum)
29317
+ rest.enum = rest.enum.map((v) => (typeof v === "number" ? String(v) : v));
29318
+ else if (typeof rest.const === "number")
29319
+ rest.const = String(rest.const);
29320
+ // a heterogeneous key keeps its absent type: the stringified members already say what a key may be
29321
+ if (!numericType)
29322
+ return rest;
29323
+ rest.type = "string";
29324
+ if (!values)
29325
+ rest.pattern = (types.includes("number") ? number : integer).source;
29326
+ return rest;
29327
+ }
29328
+ /** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
29329
+ const pendingRecords = new WeakMap();
29330
+ function rewriteKeyNames(ctx) {
29331
+ // an extracted key is resolved by the object `extractToDef` left in its place, so the map is built once rather than searched per reference. `_zod.toJSONSchema` can hand the same object to two schemas, so the first entry carrying a body wins, as a search would have found it.
29332
+ const bySchema = new Map();
29333
+ for (const entry of ctx.seen.values()) {
29334
+ if (entry.def && !bySchema.has(entry.schema))
29335
+ bySchema.set(entry.schema, entry);
29336
+ }
29337
+ const rewrites = new Map();
29338
+ for (const record of pendingRecords.get(ctx) ?? []) {
29339
+ const seen = ctx.seen.get(record);
29340
+ const names = (seen?.def ?? seen?.schema)?.propertyNames;
29341
+ if (!names || names === true || rewrites.has(names))
29342
+ continue;
29343
+ const rewritten = stringifyKeyNames(bySchema, names, new Set());
29344
+ if (rewritten !== names)
29345
+ rewrites.set(names, rewritten);
29346
+ }
29347
+ if (!rewrites.size)
29348
+ return;
29349
+ // the flatten has already copied each record's own properties onto every wrapper by reference, and an extracted body is another such copy, so every carrier holding a rewritten key is updated together
29350
+ for (const entry of ctx.seen.values()) {
29351
+ for (const carrier of [entry.schema, entry.def]) {
29352
+ const rewritten = carrier && rewrites.get(carrier.propertyNames);
29353
+ if (rewritten)
29354
+ carrier.propertyNames = rewritten;
29355
+ }
29356
+ }
29357
+ }
29297
29358
  const recordProcessor = (schema, ctx, _json, params) => {
29298
29359
  const json = _json;
29299
29360
  const def = schema._zod.def;
29300
29361
  json.type = "object";
29301
29362
  // For looseRecord with regex patterns, use patternProperties. This correctly represents "only validate keys matching the pattern" semantics and composes well with allOf (intersections)
29302
29363
  const keyType = def.keyType;
29303
- const keyBag = keyType._zod.bag;
29304
- const patterns = keyBag?.patterns;
29364
+ const patterns = aggregateChecks(keyType).patterns;
29305
29365
  if (def.mode === "loose" && patterns && patterns.size > 0) {
29306
29366
  // Use patternProperties for looseRecord with regex patterns
29307
- const valueSchema = to_json_schema_process(def.valueType, ctx, {
29367
+ const valueSchema = to_json_schema_processSchema(def.valueType, ctx, {
29308
29368
  ...params,
29309
29369
  path: [...params.path, "patternProperties", "*"],
29310
29370
  });
29311
29371
  json.patternProperties = {};
29312
29372
  for (const pattern of patterns) {
29313
- util_assignProp(json.patternProperties, pattern.source, valueSchema);
29373
+ util_assignProp(json.patternProperties, exactPattern(pattern).source, valueSchema);
29314
29374
  }
29315
29375
  }
29316
29376
  else {
29317
29377
  // Default behavior: use propertyNames + additionalProperties
29318
29378
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
29319
- json.propertyNames = to_json_schema_process(def.keyType, ctx, {
29379
+ json.propertyNames = to_json_schema_processSchema(def.keyType, ctx, {
29320
29380
  ...params,
29321
29381
  path: [...params.path, "propertyNames"],
29322
29382
  });
29383
+ let pending = pendingRecords.get(ctx);
29384
+ if (!pending) {
29385
+ pending = [];
29386
+ pendingRecords.set(ctx, pending);
29387
+ ctx.deferred.push(() => rewriteKeyNames(ctx));
29388
+ }
29389
+ pending.push(schema);
29323
29390
  }
29324
- json.additionalProperties = to_json_schema_process(def.valueType, ctx, {
29391
+ json.additionalProperties = to_json_schema_processSchema(def.valueType, ctx, {
29325
29392
  ...params,
29326
29393
  path: [...params.path, "additionalProperties"],
29327
29394
  });
@@ -29333,13 +29400,13 @@ const recordProcessor = (schema, ctx, _json, params) => {
29333
29400
  if (keyValues && !def.partial && !omittableOnInput) {
29334
29401
  const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
29335
29402
  if (validKeyValues.length > 0) {
29336
- json.required = validKeyValues;
29403
+ json.required = validKeyValues.map(String);
29337
29404
  }
29338
29405
  }
29339
29406
  };
29340
29407
  const nullableProcessor = (schema, ctx, json, params) => {
29341
29408
  const def = schema._zod.def;
29342
- const inner = to_json_schema_process(def.innerType, ctx, params);
29409
+ const inner = to_json_schema_processSchema(def.innerType, ctx, params);
29343
29410
  const seen = ctx.seen.get(schema);
29344
29411
  if (ctx.target === "openapi-3.0") {
29345
29412
  seen.ref = def.innerType;
@@ -29351,7 +29418,7 @@ const nullableProcessor = (schema, ctx, json, params) => {
29351
29418
  };
29352
29419
  const nonoptionalProcessor = (schema, ctx, _json, params) => {
29353
29420
  const def = schema._zod.def;
29354
- to_json_schema_process(def.innerType, ctx, params);
29421
+ to_json_schema_processSchema(def.innerType, ctx, params);
29355
29422
  const seen = ctx.seen.get(schema);
29356
29423
  seen.ref = def.innerType;
29357
29424
  };
@@ -29374,7 +29441,7 @@ function serializeDefaultValue(value, schema, ctx, json, params) {
29374
29441
  }
29375
29442
  const defaultProcessor = (schema, ctx, json, params) => {
29376
29443
  const def = schema._zod.def;
29377
- to_json_schema_process(def.innerType, ctx, params);
29444
+ to_json_schema_processSchema(def.innerType, ctx, params);
29378
29445
  const seen = ctx.seen.get(schema);
29379
29446
  seen.ref = def.innerType;
29380
29447
  const value = serializeDefaultValue(def.defaultValue, schema, ctx, json, params);
@@ -29383,7 +29450,7 @@ const defaultProcessor = (schema, ctx, json, params) => {
29383
29450
  };
29384
29451
  const prefaultProcessor = (schema, ctx, json, params) => {
29385
29452
  const def = schema._zod.def;
29386
- to_json_schema_process(def.innerType, ctx, params);
29453
+ to_json_schema_processSchema(def.innerType, ctx, params);
29387
29454
  const seen = ctx.seen.get(schema);
29388
29455
  seen.ref = def.innerType;
29389
29456
  if (ctx.io !== "input")
@@ -29394,7 +29461,7 @@ const prefaultProcessor = (schema, ctx, json, params) => {
29394
29461
  };
29395
29462
  const catchProcessor = (schema, ctx, json, params) => {
29396
29463
  const def = schema._zod.def;
29397
- to_json_schema_process(def.innerType, ctx, params);
29464
+ to_json_schema_processSchema(def.innerType, ctx, params);
29398
29465
  const seen = ctx.seen.get(schema);
29399
29466
  seen.ref = def.innerType;
29400
29467
  let catchValue;
@@ -29411,32 +29478,32 @@ const pipeProcessor = (schema, ctx, _json, params) => {
29411
29478
  const def = schema._zod.def;
29412
29479
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
29413
29480
  const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
29414
- to_json_schema_process(innerType, ctx, params);
29481
+ to_json_schema_processSchema(innerType, ctx, params);
29415
29482
  const seen = ctx.seen.get(schema);
29416
29483
  seen.ref = innerType;
29417
29484
  };
29418
29485
  const readonlyProcessor = (schema, ctx, json, params) => {
29419
29486
  const def = schema._zod.def;
29420
- to_json_schema_process(def.innerType, ctx, params);
29487
+ to_json_schema_processSchema(def.innerType, ctx, params);
29421
29488
  const seen = ctx.seen.get(schema);
29422
29489
  seen.ref = def.innerType;
29423
29490
  json.readOnly = true;
29424
29491
  };
29425
29492
  const promiseProcessor = (schema, ctx, _json, params) => {
29426
29493
  const def = schema._zod.def;
29427
- process(def.innerType, ctx, params);
29494
+ processSchema(def.innerType, ctx, params);
29428
29495
  const seen = ctx.seen.get(schema);
29429
29496
  seen.ref = def.innerType;
29430
29497
  };
29431
29498
  const optionalProcessor = (schema, ctx, _json, params) => {
29432
29499
  const def = schema._zod.def;
29433
- to_json_schema_process(def.innerType, ctx, params);
29500
+ to_json_schema_processSchema(def.innerType, ctx, params);
29434
29501
  const seen = ctx.seen.get(schema);
29435
29502
  seen.ref = def.innerType;
29436
29503
  };
29437
29504
  const lazyProcessor = (schema, ctx, _json, params) => {
29438
29505
  const innerType = schema._zod.innerType;
29439
- process(innerType, ctx, params);
29506
+ processSchema(innerType, ctx, params);
29440
29507
  const seen = ctx.seen.get(schema);
29441
29508
  seen.ref = innerType;
29442
29509
  };
@@ -29491,7 +29558,7 @@ function toJSONSchema(input, params) {
29491
29558
  // First pass: process all schemas to build the seen map
29492
29559
  for (const entry of registry._idmap.entries()) {
29493
29560
  const [_, schema] = entry;
29494
- process(schema, ctx);
29561
+ processSchema(schema, ctx);
29495
29562
  }
29496
29563
  const schemas = {};
29497
29564
  const external = {
@@ -29513,139 +29580,587 @@ function toJSONSchema(input, params) {
29513
29580
  [defsSegment]: defs,
29514
29581
  };
29515
29582
  }
29516
- return { schemas };
29583
+ return { schemas };
29584
+ }
29585
+ // Single schema case
29586
+ const ctx = initializeContext({ ...params, processors: allProcessors });
29587
+ processSchema(input, ctx);
29588
+ extractDefs(ctx, input);
29589
+ return finalize(ctx, input);
29590
+ }
29591
+
29592
+ ;// CONCATENATED MODULE: ./node_modules/zod/v4/locales/en.js
29593
+
29594
+ const en_error = () => {
29595
+ const Sizable = {
29596
+ string: { unit: "characters", verb: "to have" },
29597
+ file: { unit: "bytes", verb: "to have" },
29598
+ array: { unit: "items", verb: "to have" },
29599
+ set: { unit: "items", verb: "to have" },
29600
+ map: { unit: "entries", verb: "to have" },
29601
+ };
29602
+ function getSizing(origin) {
29603
+ return Sizable[origin] ?? null;
29604
+ }
29605
+ const FormatDictionary = {
29606
+ regex: "input",
29607
+ email: "email address",
29608
+ url: "URL",
29609
+ emoji: "emoji",
29610
+ uuid: "UUID",
29611
+ uuidv4: "UUIDv4",
29612
+ uuidv6: "UUIDv6",
29613
+ nanoid: "nanoid",
29614
+ guid: "GUID",
29615
+ cuid: "cuid",
29616
+ cuid2: "cuid2",
29617
+ ulid: "ULID",
29618
+ xid: "XID",
29619
+ ksuid: "KSUID",
29620
+ datetime: "ISO datetime",
29621
+ date: "ISO date",
29622
+ time: "ISO time",
29623
+ duration: "ISO duration",
29624
+ ipv4: "IPv4 address",
29625
+ ipv6: "IPv6 address",
29626
+ mac: "MAC address",
29627
+ cidrv4: "IPv4 range",
29628
+ cidrv6: "IPv6 range",
29629
+ base64: "base64-encoded string",
29630
+ base64url: "base64url-encoded string",
29631
+ json_string: "JSON string",
29632
+ e164: "E.164 number",
29633
+ currency_code: "currency code",
29634
+ credit_card: "credit card number",
29635
+ iban: "IBAN",
29636
+ jwt: "JWT",
29637
+ template_literal: "input",
29638
+ };
29639
+ // type names: missing keys = do not translate (use raw value via ?? fallback)
29640
+ const TypeDictionary = {
29641
+ // Compatibility: "nan" -> "NaN" for display
29642
+ nan: "NaN",
29643
+ // All other type names omitted - they fall back to raw values via ?? operator
29644
+ };
29645
+ function getTypeName(type, input) {
29646
+ if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
29647
+ return String(input);
29648
+ }
29649
+ return TypeDictionary[type] ?? type;
29650
+ }
29651
+ return (issue) => {
29652
+ switch (issue.code) {
29653
+ case "invalid_type": {
29654
+ const expected = getTypeName(issue.expected);
29655
+ const receivedType = parsedType(issue.input);
29656
+ const received = getTypeName(receivedType, issue.input);
29657
+ return `Invalid input: expected ${expected}, received ${received}`;
29658
+ }
29659
+ case "invalid_value":
29660
+ if (issue.values.length === 1)
29661
+ return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
29662
+ return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
29663
+ case "too_big": {
29664
+ const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
29665
+ const sizing = getSizing(issue.origin);
29666
+ if (sizing)
29667
+ return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
29668
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
29669
+ }
29670
+ case "too_small": {
29671
+ const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
29672
+ const sizing = getSizing(issue.origin);
29673
+ if (sizing) {
29674
+ return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
29675
+ }
29676
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
29677
+ }
29678
+ case "invalid_format": {
29679
+ const _issue = issue;
29680
+ if (_issue.format === "starts_with") {
29681
+ return `Invalid string: must start with "${_issue.prefix}"`;
29682
+ }
29683
+ if (_issue.format === "ends_with")
29684
+ return `Invalid string: must end with "${_issue.suffix}"`;
29685
+ if (_issue.format === "includes")
29686
+ return `Invalid string: must include "${_issue.includes}"`;
29687
+ if (_issue.format === "regex")
29688
+ return `Invalid string: must match pattern ${_issue.pattern}`;
29689
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
29690
+ }
29691
+ case "not_multiple_of":
29692
+ return `Invalid number: must be a multiple of ${issue.divisor}`;
29693
+ case "unrecognized_keys":
29694
+ return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
29695
+ case "invalid_key":
29696
+ return `Invalid key in ${issue.origin}`;
29697
+ case "invalid_union":
29698
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
29699
+ const opts = issue.options.map((o) => `'${o}'`).join(" | ");
29700
+ return `Invalid discriminator value. Expected ${opts}`;
29701
+ }
29702
+ if (issue.inclusive === false) {
29703
+ return "Invalid input: more than one option matched";
29704
+ }
29705
+ return "Invalid input";
29706
+ case "invalid_element":
29707
+ return `Invalid value in ${issue.origin}`;
29708
+ default:
29709
+ return `Invalid input`;
29710
+ }
29711
+ };
29712
+ };
29713
+ /* export default */ function en() {
29714
+ return {
29715
+ localeError: en_error(),
29716
+ };
29717
+ }
29718
+
29719
+ ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/errors.js
29720
+
29721
+
29722
+ /* Computing the message eagerly is expensive (pretty-printed JSON of all
29723
+ * issues), so defer it until first read. The accessor functions and
29724
+ * descriptors are shared across instances to keep error construction
29725
+ * cheap; the computed message is cached on the internals object. The
29726
+ * setter preserves plain assignment semantics for consumers that
29727
+ * overwrite `message`. */
29728
+ function _getMessage() {
29729
+ const internals = this._zod;
29730
+ internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
29731
+ return internals.message;
29732
+ }
29733
+ function _setMessage(value) {
29734
+ this._zod.message = value;
29735
+ }
29736
+ const _messageDesc = {
29737
+ get: _getMessage,
29738
+ set: _setMessage,
29739
+ enumerable: true,
29740
+ configurable: true,
29741
+ };
29742
+ const _issuesDesc = { value: undefined, enumerable: false };
29743
+ /* Prototypes that already carry the lazy `toString`. Seeded with the
29744
+ * intrinsics so that `init` on a foreign object — it accepts any object —
29745
+ * can never install an accessor onto a prototype we do not own. */
29746
+ const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
29747
+ const errors_initializer = (inst, def) => {
29748
+ inst.name = "$ZodError";
29749
+ // `_zod` is already non-enumerable: $constructor's init defined it with this same descriptor
29750
+ _issuesDesc.value = def;
29751
+ Object.defineProperty(inst, "issues", _issuesDesc);
29752
+ // Clear the shared slot; a retained `value` pins the last error's issues.
29753
+ _issuesDesc.value = undefined;
29754
+ Object.defineProperty(inst, "message", _messageDesc);
29755
+ /* `toString` lives as a non-enumerable lazy getter on the shared
29756
+ * prototype; on first access it caches a per-instance closure so
29757
+ * detached usage still works. */
29758
+ const proto = Object.getPrototypeOf(inst);
29759
+ if (!_installedToString.has(proto)) {
29760
+ _installedToString.add(proto);
29761
+ Object.defineProperty(proto, "toString", {
29762
+ configurable: true,
29763
+ enumerable: false,
29764
+ get() {
29765
+ const value = () => this.message;
29766
+ Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
29767
+ return value;
29768
+ },
29769
+ set(value) {
29770
+ Object.defineProperty(this, "toString", { value, configurable: true, writable: true });
29771
+ },
29772
+ });
29773
+ }
29774
+ };
29775
+ const $ZodError = $constructor("$ZodError", errors_initializer);
29776
+ const $ZodRealError = $constructor("$ZodError", errors_initializer, undefined, {
29777
+ Parent: Error,
29778
+ });
29779
+ /** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
29780
+ * ("toString", "constructor") would otherwise read through to the prototype, and assigning
29781
+ * "__proto__" would hit the setter instead of creating a key. */
29782
+ function errors_node(obj, key, make) {
29783
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
29784
+ if (key === "__proto__") {
29785
+ Object.defineProperty(obj, key, { value: make(), writable: true, enumerable: true, configurable: true });
29786
+ }
29787
+ else {
29788
+ obj[key] = make();
29789
+ }
29790
+ }
29791
+ return obj[key];
29792
+ }
29793
+ function flattenError(error, mapper = (issue) => issue.message) {
29794
+ const fieldErrors = {};
29795
+ const formErrors = [];
29796
+ for (const sub of error.issues) {
29797
+ if (sub.path.length > 0) {
29798
+ errors_node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
29799
+ }
29800
+ else {
29801
+ formErrors.push(mapper(sub));
29802
+ }
29803
+ }
29804
+ return { formErrors, fieldErrors };
29805
+ }
29806
+ function formatError(error, mapper = (issue) => issue.message) {
29807
+ const fieldErrors = { _errors: [] };
29808
+ const processError = (error, path = []) => {
29809
+ for (const issue of error.issues) {
29810
+ if (issue.code === "invalid_union" && issue.errors.length) {
29811
+ issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
29812
+ }
29813
+ else if (issue.code === "invalid_key") {
29814
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
29815
+ }
29816
+ else if (issue.code === "invalid_element") {
29817
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
29818
+ }
29819
+ else {
29820
+ const fullpath = [...path, ...issue.path];
29821
+ if (fullpath.length === 0) {
29822
+ fieldErrors._errors.push(mapper(issue));
29823
+ }
29824
+ else {
29825
+ let curr = fieldErrors;
29826
+ let i = 0;
29827
+ while (i < fullpath.length) {
29828
+ const el = fullpath[i];
29829
+ const terminal = i === fullpath.length - 1;
29830
+ // `_errors` is reserved by this legacy format, so merge a matching path segment into the current node instead of treating its array as a child.
29831
+ if (el === "_errors") {
29832
+ if (terminal)
29833
+ curr._errors.push(mapper(issue));
29834
+ i++;
29835
+ continue;
29836
+ }
29837
+ // A path element may collide with an inherited property name such as
29838
+ // "__proto__" or "constructor". Truthiness checks read the prototype
29839
+ // (so no node is created, then ._errors.push throws), and bracket
29840
+ // assignment of "__proto__" hits the setter instead of creating an
29841
+ // own key. Guard the read with hasOwnProperty and create the node
29842
+ // with defineProperty so any path element becomes a real own key.
29843
+ if (!Object.prototype.hasOwnProperty.call(curr, el)) {
29844
+ Object.defineProperty(curr, el, {
29845
+ value: { _errors: [] },
29846
+ enumerable: true,
29847
+ writable: true,
29848
+ configurable: true,
29849
+ });
29850
+ }
29851
+ const node = curr[el];
29852
+ if (terminal) {
29853
+ node._errors.push(mapper(issue));
29854
+ }
29855
+ curr = node;
29856
+ i++;
29857
+ }
29858
+ }
29859
+ }
29860
+ }
29861
+ };
29862
+ processError(error);
29863
+ return fieldErrors;
29864
+ }
29865
+ function treeifyError(error, mapper = (issue) => issue.message) {
29866
+ const result = { errors: [] };
29867
+ const processError = (error, path = []) => {
29868
+ var _a;
29869
+ for (const issue of error.issues) {
29870
+ if (issue.code === "invalid_union" && issue.errors.length) {
29871
+ // regular union error
29872
+ issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
29873
+ }
29874
+ else if (issue.code === "invalid_key") {
29875
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
29876
+ }
29877
+ else if (issue.code === "invalid_element") {
29878
+ processError({ issues: issue.issues }, [...path, ...issue.path]);
29879
+ }
29880
+ else {
29881
+ const fullpath = [...path, ...issue.path];
29882
+ if (fullpath.length === 0) {
29883
+ result.errors.push(mapper(issue));
29884
+ continue;
29885
+ }
29886
+ let curr = result;
29887
+ let i = 0;
29888
+ while (i < fullpath.length) {
29889
+ const el = fullpath[i];
29890
+ const terminal = i === fullpath.length - 1;
29891
+ if (typeof el === "string") {
29892
+ curr.properties ?? (curr.properties = {});
29893
+ // el may collide with an inherited property name ("__proto__",
29894
+ // "constructor", ...); ??= reads the prototype so the node is never
29895
+ // created and curr.errors.push throws. Guard with hasOwnProperty and
29896
+ // create the node with defineProperty so "__proto__" becomes a real
29897
+ // own key rather than invoking the prototype setter.
29898
+ if (!Object.prototype.hasOwnProperty.call(curr.properties, el)) {
29899
+ Object.defineProperty(curr.properties, el, {
29900
+ value: { errors: [] },
29901
+ enumerable: true,
29902
+ writable: true,
29903
+ configurable: true,
29904
+ });
29905
+ }
29906
+ curr = curr.properties[el];
29907
+ }
29908
+ else {
29909
+ curr.items ?? (curr.items = []);
29910
+ (_a = curr.items)[el] ?? (_a[el] = { errors: [] });
29911
+ curr = curr.items[el];
29912
+ }
29913
+ if (terminal) {
29914
+ curr.errors.push(mapper(issue));
29915
+ }
29916
+ i++;
29917
+ }
29918
+ }
29919
+ }
29920
+ };
29921
+ processError(error);
29922
+ return result;
29923
+ }
29924
+ /** Format a ZodError as a human-readable string in the following form.
29925
+ *
29926
+ * From
29927
+ *
29928
+ * ```ts
29929
+ * ZodError {
29930
+ * issues: [
29931
+ * {
29932
+ * expected: 'string',
29933
+ * code: 'invalid_type',
29934
+ * path: [ 'username' ],
29935
+ * message: 'Invalid input: expected string'
29936
+ * },
29937
+ * {
29938
+ * expected: 'number',
29939
+ * code: 'invalid_type',
29940
+ * path: [ 'favoriteNumbers', 1 ],
29941
+ * message: 'Invalid input: expected number'
29942
+ * }
29943
+ * ];
29944
+ * }
29945
+ * ```
29946
+ *
29947
+ * to
29948
+ *
29949
+ * ```
29950
+ * username
29951
+ * ✖ Expected number, received string at "username
29952
+ * favoriteNumbers[0]
29953
+ * ✖ Invalid input: expected number
29954
+ * ```
29955
+ */
29956
+ function toDotPath(_path) {
29957
+ const segs = [];
29958
+ const path = _path.map((seg) => (typeof seg === "object" ? seg.key : seg));
29959
+ for (const seg of path) {
29960
+ if (typeof seg === "number")
29961
+ segs.push(`[${seg}]`);
29962
+ else if (typeof seg === "symbol")
29963
+ segs.push(`[${JSON.stringify(String(seg))}]`);
29964
+ else if (/[^\w$]/.test(seg))
29965
+ segs.push(`[${JSON.stringify(seg)}]`);
29966
+ else {
29967
+ if (segs.length)
29968
+ segs.push(".");
29969
+ segs.push(seg);
29970
+ }
29971
+ }
29972
+ return segs.join("");
29973
+ }
29974
+ function prettifyError(error) {
29975
+ const lines = [];
29976
+ // sort by path length
29977
+ const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length);
29978
+ // Process each issue
29979
+ for (const issue of issues) {
29980
+ lines.push(`✖ ${issue.message}`);
29981
+ if (issue.path?.length)
29982
+ lines.push(` → at ${toDotPath(issue.path)}`);
29983
+ }
29984
+ // Convert Map to formatted string
29985
+ return lines.join("\n");
29986
+ }
29987
+
29988
+ ;// CONCATENATED MODULE: ./node_modules/zod/v4/core/parse.js
29989
+
29990
+
29991
+
29992
+ // Always both keys, so the `_params` read site in `_parse` sees one object shape rather than two.
29993
+ function finalizeParams(callee, params) {
29994
+ return { callee: params?.callee ?? callee, Err: params?.Err };
29995
+ }
29996
+ const parse_parse = (_Err) => {
29997
+ const fn = (schema, value, _ctx, _params) => {
29998
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
29999
+ const result = schema._zod.run({ value, issues: [] }, ctx);
30000
+ if (result instanceof Promise) {
30001
+ throw new $ZodAsyncError();
30002
+ }
30003
+ if (result.issues.length) {
30004
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
30005
+ captureStackTrace(e, _params?.callee ?? fn);
30006
+ throw e;
30007
+ }
30008
+ return result.value;
30009
+ };
30010
+ return fn;
30011
+ };
30012
+ const core_parse_parse = /* @__PURE__*/ parse_parse($ZodRealError);
30013
+ const parse_parseAsync = (_Err) => {
30014
+ const fn = async (schema, value, _ctx, params) => {
30015
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
30016
+ let result = schema._zod.run({ value, issues: [] }, ctx);
30017
+ if (result instanceof Promise)
30018
+ result = await result;
30019
+ if (result.issues.length) {
30020
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
30021
+ captureStackTrace(e, params?.callee ?? fn);
30022
+ throw e;
30023
+ }
30024
+ return result.value;
30025
+ };
30026
+ return fn;
30027
+ };
30028
+ const core_parse_parseAsync = /* @__PURE__*/ parse_parseAsync($ZodRealError);
30029
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
30030
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
30031
+ const result = schema._zod.run({ value, issues: [] }, ctx);
30032
+ if (result instanceof Promise) {
30033
+ throw new $ZodAsyncError();
29517
30034
  }
29518
- // Single schema case
29519
- const ctx = initializeContext({ ...params, processors: allProcessors });
29520
- process(input, ctx);
29521
- extractDefs(ctx, input);
29522
- return finalize(ctx, input);
29523
- }
29524
-
29525
- ;// CONCATENATED MODULE: ./node_modules/zod/v4/locales/en.js
29526
-
29527
- const en_error = () => {
29528
- const Sizable = {
29529
- string: { unit: "characters", verb: "to have" },
29530
- file: { unit: "bytes", verb: "to have" },
29531
- array: { unit: "items", verb: "to have" },
29532
- set: { unit: "items", verb: "to have" },
29533
- map: { unit: "entries", verb: "to have" },
30035
+ return result.issues.length ? parse_failure(_Err, result.issues, ctx) : { success: true, data: result.value };
30036
+ };
30037
+ const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
30038
+ // the error is built on the first read of `error`: finalizing the issues and constructing the instance is most of a failing parse, and a caller that only branches on `success` never pays it. a getter in the literal keeps this small; the alternative, one shared accessor descriptor plus a hidden state slot, reads ~15% faster but costs ~75 B gzipped in every bundle
30039
+ function parse_failure(Err, issues, ctx) {
30040
+ let error;
30041
+ return {
30042
+ success: false,
30043
+ get error() {
30044
+ if (!error) {
30045
+ error = new Err(issues.map((iss) => finalizeIssue(iss, ctx, core_config())));
30046
+ // finalizeIssue drops `input`, so the built error holds nothing; keeping the raw issues past this point pins the parsed value for the life of the result
30047
+ issues = undefined;
30048
+ ctx = undefined;
30049
+ }
30050
+ return error;
30051
+ },
30052
+ set error(e) {
30053
+ error = e;
30054
+ // a replacement makes the getter's branch unreachable, so the captures have to go here too
30055
+ issues = undefined;
30056
+ ctx = undefined;
30057
+ },
29534
30058
  };
29535
- function getSizing(origin) {
29536
- return Sizable[origin] ?? null;
30059
+ }
30060
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
30061
+ const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
30062
+ let result = schema._zod.run({ value, issues: [] }, ctx);
30063
+ if (result instanceof Promise)
30064
+ result = await result;
30065
+ return result.issues.length ? parse_failure(_Err, result.issues, ctx) : { success: true, data: result.value };
30066
+ };
30067
+ const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
30068
+ // registry mirrors of the compiler's sentinels, so this module never imports the compiler
30069
+ const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
30070
+ const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
30071
+ // Deliberately tiny, because v8 will not inline a body carrying the fallback's object literals and throw. Everything that is not the compiled happy path lives in validateFallback, and that split is worth ~35% on a compiled schema.
30072
+ const validate = ((schema, value, _ctx) => {
30073
+ const validator = schema._zod.bag.validator;
30074
+ if (validator !== undefined) {
30075
+ if (validator(value) !== COMPILE_INVALID)
30076
+ return true;
30077
+ // a definite sentinel means the runtime would reject, so skip the re-parse; a ctx can still change the answer
30078
+ if (validator.definite === true && _ctx === undefined)
30079
+ return false;
29537
30080
  }
29538
- const FormatDictionary = {
29539
- regex: "input",
29540
- email: "email address",
29541
- url: "URL",
29542
- emoji: "emoji",
29543
- uuid: "UUID",
29544
- uuidv4: "UUIDv4",
29545
- uuidv6: "UUIDv6",
29546
- nanoid: "nanoid",
29547
- guid: "GUID",
29548
- cuid: "cuid",
29549
- cuid2: "cuid2",
29550
- ulid: "ULID",
29551
- xid: "XID",
29552
- ksuid: "KSUID",
29553
- datetime: "ISO datetime",
29554
- date: "ISO date",
29555
- time: "ISO time",
29556
- duration: "ISO duration",
29557
- ipv4: "IPv4 address",
29558
- ipv6: "IPv6 address",
29559
- mac: "MAC address",
29560
- cidrv4: "IPv4 range",
29561
- cidrv6: "IPv6 range",
29562
- base64: "base64-encoded string",
29563
- base64url: "base64url-encoded string",
29564
- json_string: "JSON string",
29565
- e164: "E.164 number",
29566
- credit_card: "credit card number",
29567
- jwt: "JWT",
29568
- template_literal: "input",
30081
+ return validateFallback(schema, value, _ctx);
30082
+ });
30083
+ function validateFallback(schema, value, _ctx) {
30084
+ const ctx = _ctx
30085
+ ? { ..._ctx, async: false, abortEarly: true }
30086
+ : { async: false, abortEarly: true };
30087
+ const fallbackRun = schema._zod.bag.fallbackRun;
30088
+ let result;
30089
+ if (fallbackRun) {
30090
+ // skip nested fast paths on the fallback, so user callbacks keep the at-most-twice bound
30091
+ ctx[COMPILE_FALLBACK] = true;
30092
+ result = fallbackRun({ value, issues: [] }, ctx);
30093
+ }
30094
+ else {
30095
+ result = schema._zod.run({ value, issues: [] }, ctx);
30096
+ }
30097
+ if (result instanceof Promise) {
30098
+ throw new $ZodAsyncError();
30099
+ }
30100
+ return result.issues.length === 0;
30101
+ }
30102
+ // no fast path: the compiler keeps async parses on the runtime, because a promise-returning callback that is not declared async compiles to a throw
30103
+ const parse_validateAsync = async (schema, value, _ctx) => {
30104
+ const ctx = _ctx
30105
+ ? { ..._ctx, async: true, abortEarly: true }
30106
+ : { async: true, abortEarly: true };
30107
+ let result = schema._zod.run({ value, issues: [] }, ctx);
30108
+ if (result instanceof Promise)
30109
+ result = await result;
30110
+ return result.issues.length === 0;
30111
+ };
30112
+ const parse_encode = (_Err) => {
30113
+ const parse = parse_parse(_Err);
30114
+ const fn = (schema, value, _ctx, _params) => {
30115
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
30116
+ return parse(schema, value, ctx, finalizeParams(fn, _params));
29569
30117
  };
29570
- // type names: missing keys = do not translate (use raw value via ?? fallback)
29571
- const TypeDictionary = {
29572
- // Compatibility: "nan" -> "NaN" for display
29573
- nan: "NaN",
29574
- // All other type names omitted - they fall back to raw values via ?? operator
30118
+ return fn;
30119
+ };
30120
+ const encode = /* @__PURE__*/ parse_encode($ZodRealError);
30121
+ const parse_decode = (_Err) => {
30122
+ const parse = parse_parse(_Err);
30123
+ const fn = (schema, value, _ctx, _params) => {
30124
+ return parse(schema, value, _ctx, finalizeParams(fn, _params));
29575
30125
  };
29576
- function getTypeName(type, input) {
29577
- if (type === "number" && typeof input === "number" && !Number.isFinite(input)) {
29578
- return String(input);
29579
- }
29580
- return TypeDictionary[type] ?? type;
29581
- }
29582
- return (issue) => {
29583
- switch (issue.code) {
29584
- case "invalid_type": {
29585
- const expected = getTypeName(issue.expected);
29586
- const receivedType = parsedType(issue.input);
29587
- const received = getTypeName(receivedType, issue.input);
29588
- return `Invalid input: expected ${expected}, received ${received}`;
29589
- }
29590
- case "invalid_value":
29591
- if (issue.values.length === 1)
29592
- return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
29593
- return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
29594
- case "too_big": {
29595
- const adj = issue.exact ? "exactly " : issue.inclusive ? "<=" : "<";
29596
- const sizing = getSizing(issue.origin);
29597
- if (sizing)
29598
- return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
29599
- return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
29600
- }
29601
- case "too_small": {
29602
- const adj = issue.exact ? "exactly " : issue.inclusive ? ">=" : ">";
29603
- const sizing = getSizing(issue.origin);
29604
- if (sizing) {
29605
- return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
29606
- }
29607
- return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
29608
- }
29609
- case "invalid_format": {
29610
- const _issue = issue;
29611
- if (_issue.format === "starts_with") {
29612
- return `Invalid string: must start with "${_issue.prefix}"`;
29613
- }
29614
- if (_issue.format === "ends_with")
29615
- return `Invalid string: must end with "${_issue.suffix}"`;
29616
- if (_issue.format === "includes")
29617
- return `Invalid string: must include "${_issue.includes}"`;
29618
- if (_issue.format === "regex")
29619
- return `Invalid string: must match pattern ${_issue.pattern}`;
29620
- return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
29621
- }
29622
- case "not_multiple_of":
29623
- return `Invalid number: must be a multiple of ${issue.divisor}`;
29624
- case "unrecognized_keys":
29625
- return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
29626
- case "invalid_key":
29627
- return `Invalid key in ${issue.origin}`;
29628
- case "invalid_union":
29629
- if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
29630
- const opts = issue.options.map((o) => `'${o}'`).join(" | ");
29631
- return `Invalid discriminator value. Expected ${opts}`;
29632
- }
29633
- if (issue.inclusive === false) {
29634
- return "Invalid input: more than one option matched";
29635
- }
29636
- return "Invalid input";
29637
- case "invalid_element":
29638
- return `Invalid value in ${issue.origin}`;
29639
- default:
29640
- return `Invalid input`;
29641
- }
30126
+ return fn;
30127
+ };
30128
+ const decode = /* @__PURE__*/ parse_decode($ZodRealError);
30129
+ const parse_encodeAsync = (_Err) => {
30130
+ const parseAsync = parse_parseAsync(_Err);
30131
+ const fn = async (schema, value, _ctx, _params) => {
30132
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
30133
+ return (await parseAsync(schema, value, ctx, finalizeParams(fn, _params)));
29642
30134
  };
30135
+ return fn;
29643
30136
  };
29644
- /* export default */ function en() {
29645
- return {
29646
- localeError: en_error(),
30137
+ const encodeAsync = /* @__PURE__*/ parse_encodeAsync($ZodRealError);
30138
+ const parse_decodeAsync = (_Err) => {
30139
+ const parseAsync = parse_parseAsync(_Err);
30140
+ const fn = async (schema, value, _ctx, _params) => {
30141
+ return await parseAsync(schema, value, _ctx, finalizeParams(fn, _params));
29647
30142
  };
29648
- }
30143
+ return fn;
30144
+ };
30145
+ const decodeAsync = /* @__PURE__*/ parse_decodeAsync($ZodRealError);
30146
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
30147
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
30148
+ return _safeParse(_Err)(schema, value, ctx);
30149
+ };
30150
+ const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
30151
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
30152
+ return _safeParse(_Err)(schema, value, _ctx);
30153
+ };
30154
+ const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
30155
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
30156
+ const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
30157
+ return _safeParseAsync(_Err)(schema, value, ctx);
30158
+ };
30159
+ const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
30160
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
30161
+ return _safeParseAsync(_Err)(schema, value, _ctx);
30162
+ };
30163
+ const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
29649
30164
 
29650
30165
  ;// CONCATENATED MODULE: ./node_modules/zod/v4/classic/errors.js
29651
30166
 
@@ -29732,6 +30247,7 @@ const parse_safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
29732
30247
 
29733
30248
 
29734
30249
 
30250
+
29735
30251
  // Register English as the default locale on first ZodType construction. Hooked into the `ZodType` `$constructor` (rather than a top-level `config(en())` in `external.ts`) so bundlers honoring `sideEffects: false` can't tree-shake it out — see #5953, #5725. An explicit `z.config(z.locales.xx())` call wins regardless of order, since this only sets the default when none is present.
29736
30252
  function _ensureDefaultLocale() {
29737
30253
  if (!globalConfig.localeError)
@@ -29876,6 +30392,12 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
29876
30392
  set spa(value) {
29877
30393
  util_own(this, "spa", value);
29878
30394
  },
30395
+ validate(data, params) {
30396
+ return validate(this, data, params);
30397
+ },
30398
+ validateAsync(data, params) {
30399
+ return parse_validateAsync(this, data, params);
30400
+ },
29879
30401
  encode: function _encode(data, params) {
29880
30402
  return classic_parse_encode(this, data, params, { callee: _encode });
29881
30403
  },
@@ -29917,10 +30439,11 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
29917
30439
  $ZodString.init(inst, def);
29918
30440
  ZodType.init(inst, def);
29919
30441
  inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
29920
- const bag = inst._zod.bag;
29921
- inst.format = bag.format ?? null;
29922
- inst.minLength = bag.minimum ?? null;
29923
- inst.maxLength = bag.maximum ?? null;
30442
+ },
30443
+ /*@__PURE__*/ derived({
30444
+ format: (inst) => aggregateChecks(inst).format ?? null,
30445
+ minLength: (inst) => aggregateChecks(inst).minimum ?? null,
30446
+ maxLength: (inst) => aggregateChecks(inst).maximum ?? null,
29924
30447
  }, {
29925
30448
  regex(...args) {
29926
30449
  return this.check(_regex(...args));
@@ -29967,7 +30490,7 @@ const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
29967
30490
  slugify() {
29968
30491
  return this.check(_slugify());
29969
30492
  },
29970
- });
30493
+ }));
29971
30494
  const ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
29972
30495
  $ZodString.init(inst, def);
29973
30496
  _ZodString.init(inst, def);
@@ -30119,8 +30642,8 @@ function schemas_url(params) {
30119
30642
  }
30120
30643
  function httpUrl(params) {
30121
30644
  return core._url(ZodURL, {
30122
- protocol: core.regexes.httpProtocol,
30123
- hostname: core.regexes.domain,
30645
+ protocol: regexes.httpProtocol,
30646
+ hostname: regexes.domain,
30124
30647
  ...util.normalizeParams(params),
30125
30648
  });
30126
30649
  }
@@ -30261,6 +30784,13 @@ const ZodCreditCard = /*@__PURE__*/ (/* unused pure expression or super */ null
30261
30784
  function schemas_creditCard(params) {
30262
30785
  return core._creditCard(ZodCreditCard, params);
30263
30786
  }
30787
+ const ZodIBAN = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("ZodIBAN", (inst, def) => {
30788
+ core.$ZodIBAN.init(inst, def);
30789
+ ZodStringFormat.init(inst, def);
30790
+ })));
30791
+ function schemas_iban(params) {
30792
+ return core._iban(ZodIBAN, params);
30793
+ }
30264
30794
  const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
30265
30795
  // ZodStringFormat.init(inst, def);
30266
30796
  $ZodJWT.init(inst, def);
@@ -30278,10 +30808,13 @@ function stringFormat(format, fnOrRegex, _params = {}) {
30278
30808
  return core._stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
30279
30809
  }
30280
30810
  function schemas_hostname(_params) {
30281
- return core._stringFormat(ZodCustomStringFormat, "hostname", core.regexes.hostname, _params);
30811
+ return core._stringFormat(ZodCustomStringFormat, "hostname", regexes.hostname, _params);
30282
30812
  }
30283
30813
  function schemas_hex(_params) {
30284
- return core._stringFormat(ZodCustomStringFormat, "hex", core.regexes.hex, _params);
30814
+ return core._stringFormat(ZodCustomStringFormat, "hex", regexes.hex, _params);
30815
+ }
30816
+ function schemas_currencyCode(_params) {
30817
+ return core._stringFormat(ZodCustomStringFormat, "currency_code", regexes.currencyCode, _params);
30285
30818
  }
30286
30819
  function hash(alg, params) {
30287
30820
  const enc = params?.enc ?? "hex";
@@ -30295,14 +30828,22 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
30295
30828
  $ZodNumber.init(inst, def);
30296
30829
  ZodType.init(inst, def);
30297
30830
  inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
30298
- const bag = inst._zod.bag;
30299
- inst.minValue =
30300
- Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
30301
- inst.maxValue =
30302
- Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
30303
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
30304
30831
  inst.isFinite = true;
30305
- inst.format = bag.format ?? null;
30832
+ },
30833
+ /*@__PURE__*/ derived({
30834
+ minValue: (inst) => {
30835
+ const { minimum, exclusiveMinimum } = aggregateChecks(inst);
30836
+ return Math.max(minimum ?? Number.NEGATIVE_INFINITY, exclusiveMinimum ?? Number.NEGATIVE_INFINITY);
30837
+ },
30838
+ maxValue: (inst) => {
30839
+ const { maximum, exclusiveMaximum } = aggregateChecks(inst);
30840
+ return Math.min(maximum ?? Number.POSITIVE_INFINITY, exclusiveMaximum ?? Number.POSITIVE_INFINITY);
30841
+ },
30842
+ isInt: (inst) => {
30843
+ const { isInt, multipleOf } = aggregateChecks(inst);
30844
+ return !!isInt || !!multipleOf?.some(Number.isSafeInteger);
30845
+ },
30846
+ format: (inst) => aggregateChecks(inst).format ?? null,
30306
30847
  }, {
30307
30848
  gt(value, params) {
30308
30849
  return this.check(_gt(value, params));
@@ -30349,7 +30890,7 @@ const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
30349
30890
  finite() {
30350
30891
  return this;
30351
30892
  },
30352
- });
30893
+ }));
30353
30894
  function schemas_number(params) {
30354
30895
  return _number(ZodNumber, params);
30355
30896
  }
@@ -30384,10 +30925,11 @@ const ZodBigInt = /*@__PURE__*/ (/* unused pure expression or super */ null && (
30384
30925
  core.$ZodBigInt.init(inst, def);
30385
30926
  ZodType.init(inst, def);
30386
30927
  inst._zod.processJSONSchema = (ctx, json, params) => processors.bigintProcessor(inst, ctx, json, params);
30387
- const bag = inst._zod.bag;
30388
- inst.minValue = bag.minimum ?? null;
30389
- inst.maxValue = bag.maximum ?? null;
30390
- inst.format = bag.format ?? null;
30928
+ },
30929
+ /*@__PURE__*/ util.derived({
30930
+ minValue: (inst) => processors.aggregateChecks(inst).minimum ?? null,
30931
+ maxValue: (inst) => processors.aggregateChecks(inst).maximum ?? null,
30932
+ format: (inst) => processors.aggregateChecks(inst).format ?? null,
30391
30933
  }, {
30392
30934
  gte(value, params) {
30393
30935
  return this.check(checks.gte(value, params));
@@ -30422,7 +30964,7 @@ const ZodBigInt = /*@__PURE__*/ (/* unused pure expression or super */ null && (
30422
30964
  multipleOf(value, params) {
30423
30965
  return this.check(checks.multipleOf(value, params));
30424
30966
  },
30425
- })));
30967
+ }))));
30426
30968
  function schemas_bigint(params) {
30427
30969
  return core._bigint(ZodBigInt, params);
30428
30970
  }
@@ -30501,10 +31043,17 @@ const ZodDate = /*@__PURE__*/ (/* unused pure expression or super */ null && (co
30501
31043
  inst._zod.processJSONSchema = (ctx, json, params) => processors.dateProcessor(inst, ctx, json, params);
30502
31044
  inst.min = (value, params) => inst.check(checks.gte(value, params));
30503
31045
  inst.max = (value, params) => inst.check(checks.lte(value, params));
30504
- const c = inst._zod.bag;
30505
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
30506
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
30507
- })));
31046
+ },
31047
+ /*@__PURE__*/ util.derived({
31048
+ minDate: (inst) => {
31049
+ const { minimum } = processors.aggregateChecks(inst);
31050
+ return minimum ? new Date(minimum) : null;
31051
+ },
31052
+ maxDate: (inst) => {
31053
+ const { maximum } = processors.aggregateChecks(inst);
31054
+ return maximum ? new Date(maximum) : null;
31055
+ },
31056
+ }, {}))));
30508
31057
  function schemas_date(params) {
30509
31058
  return core._date(ZodDate, params);
30510
31059
  }
@@ -30550,19 +31099,20 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
30550
31099
  return schemas_enum(Object.keys(this._zod.def.shape));
30551
31100
  },
30552
31101
  catchall(catchall) {
30553
- return this.clone({ ...this._zod.def, catchall: catchall });
31102
+ // `mergeDefs` rather than a spread: spreading reads `shape`, and resolving it can mint a whole fresh subtree
31103
+ return this.clone(mergeDefs(this._zod.def, { catchall: catchall }));
30554
31104
  },
30555
31105
  passthrough() {
30556
- return this.clone({ ...this._zod.def, catchall: schemas_unknown() });
31106
+ return this.clone(mergeDefs(this._zod.def, { catchall: schemas_unknown() }));
30557
31107
  },
30558
31108
  loose() {
30559
- return this.clone({ ...this._zod.def, catchall: schemas_unknown() });
31109
+ return this.clone(mergeDefs(this._zod.def, { catchall: schemas_unknown() }));
30560
31110
  },
30561
31111
  strict() {
30562
- return this.clone({ ...this._zod.def, catchall: never() });
31112
+ return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
30563
31113
  },
30564
31114
  strip() {
30565
- return this.clone({ ...this._zod.def, catchall: undefined });
31115
+ return this.clone(mergeDefs(this._zod.def, { catchall: undefined }));
30566
31116
  },
30567
31117
  extend(incoming) {
30568
31118
  return extend(this, incoming);
@@ -30571,7 +31121,7 @@ const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
30571
31121
  return safeExtend(this, incoming);
30572
31122
  },
30573
31123
  merge(other) {
30574
- return merge(this, other);
31124
+ return util_merge(this, other);
30575
31125
  },
30576
31126
  pick(mask) {
30577
31127
  return pick(this, mask);
@@ -30778,7 +31328,7 @@ const ZodSet = /*@__PURE__*/ (/* unused pure expression or super */ null && (cor
30778
31328
  inst.max = (...args) => inst.check(core._maxSize(...args));
30779
31329
  inst.size = (...args) => inst.check(core._size(...args));
30780
31330
  })));
30781
- function schemas_set(valueType, params) {
31331
+ function set(valueType, params) {
30782
31332
  return new ZodSet({
30783
31333
  type: "set",
30784
31334
  valueType: valueType,
@@ -30790,7 +31340,8 @@ const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
30790
31340
  ZodType.init(inst, def);
30791
31341
  inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
30792
31342
  inst.enum = def.entries;
30793
- inst.options = Object.values(def.entries);
31343
+ // reuse the parsed value set so a numeric TS enum's reverse-mapping keys stay out
31344
+ inst.options = [...inst._zod.values];
30794
31345
  const keys = new Set(Object.keys(def.entries));
30795
31346
  inst.extract = (values, params) => {
30796
31347
  const newEntries = {};
@@ -31172,8 +31723,16 @@ function superRefine(fn, params) {
31172
31723
  // Re-export describe and meta from core
31173
31724
  const schemas_describe = describe;
31174
31725
  const schemas_meta = api_meta;
31726
+ const ZodInstanceOf = /*@__PURE__*/ (/* unused pure expression or super */ null && (core.$constructor("ZodInstanceOf", (inst, def) => {
31727
+ ZodCustom.init(inst, def);
31728
+ }, {
31729
+ properties(shape, params) {
31730
+ // asserts in place, so the narrowed output type is truthful without a wrapper
31731
+ return this.check(core._properties(shape, params));
31732
+ },
31733
+ })));
31175
31734
  function _instanceof(cls, params = {}) {
31176
- const inst = new ZodCustom({
31735
+ const inst = new ZodInstanceOf({
31177
31736
  type: "custom",
31178
31737
  check: "custom",
31179
31738
  fn: (data) => data instanceof cls,