@abraca/mcp 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -220,7 +220,7 @@ var ZodError$1 = class ZodError$1 extends Error {
220
220
  return this.issues.length === 0;
221
221
  }
222
222
  flatten(mapper = (issue) => issue.message) {
223
- const fieldErrors = {};
223
+ const fieldErrors = Object.create(null);
224
224
  const formErrors = [];
225
225
  for (const sub of this.issues) if (sub.path.length > 0) {
226
226
  const firstEl = sub.path[0];
@@ -3595,17 +3595,23 @@ const pipelineType = ZodPipeline.create;
3595
3595
  const NEVER = Object.freeze({ status: "aborted" });
3596
3596
  function $constructor(name, initializer, params) {
3597
3597
  function init(inst, def) {
3598
- var _a;
3599
- Object.defineProperty(inst, "_zod", {
3600
- value: inst._zod ?? {},
3598
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
3599
+ value: {
3600
+ def,
3601
+ constr: _,
3602
+ traits: /* @__PURE__ */ new Set()
3603
+ },
3601
3604
  enumerable: false
3602
3605
  });
3603
- (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
3606
+ if (inst._zod.traits.has(name)) return;
3604
3607
  inst._zod.traits.add(name);
3605
3608
  initializer(inst, def);
3606
- for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
3607
- inst._zod.constr = _;
3608
- inst._zod.def = def;
3609
+ const proto = _.prototype;
3610
+ const keys = Object.keys(proto);
3611
+ for (let i = 0; i < keys.length; i++) {
3612
+ const k = keys[i];
3613
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
3614
+ }
3609
3615
  }
3610
3616
  const Parent = params?.Parent ?? Object;
3611
3617
  class Definition extends Parent {}
@@ -3631,6 +3637,12 @@ var $ZodAsyncError = class extends Error {
3631
3637
  super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
3632
3638
  }
3633
3639
  };
3640
+ var $ZodEncodeError = class extends Error {
3641
+ constructor(name) {
3642
+ super(`Encountered unidirectional transform during encode: ${name}`);
3643
+ this.name = "ZodEncodeError";
3644
+ }
3645
+ };
3634
3646
  const globalConfig = {};
3635
3647
  function config(newConfig) {
3636
3648
  if (newConfig) Object.assign(globalConfig, newConfig);
@@ -3667,19 +3679,26 @@ function cleanRegex(source) {
3667
3679
  }
3668
3680
  function floatSafeRemainder(val, step) {
3669
3681
  const valDecCount = (val.toString().split(".")[1] || "").length;
3670
- const stepDecCount = (step.toString().split(".")[1] || "").length;
3682
+ const stepString = step.toString();
3683
+ let stepDecCount = (stepString.split(".")[1] || "").length;
3684
+ if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
3685
+ const match = stepString.match(/\d?e-(\d?)/);
3686
+ if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
3687
+ }
3671
3688
  const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
3672
3689
  return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
3673
3690
  }
3691
+ const EVALUATING = Symbol("evaluating");
3674
3692
  function defineLazy(object, key, getter) {
3693
+ let value = void 0;
3675
3694
  Object.defineProperty(object, key, {
3676
3695
  get() {
3677
- {
3678
- const value = getter();
3679
- object[key] = value;
3680
- return value;
3696
+ if (value === EVALUATING) return;
3697
+ if (value === void 0) {
3698
+ value = EVALUATING;
3699
+ value = getter();
3681
3700
  }
3682
- throw new Error("cached value already set");
3701
+ return value;
3683
3702
  },
3684
3703
  set(v) {
3685
3704
  Object.defineProperty(object, key, { value: v });
@@ -3695,10 +3714,21 @@ function assignProp(target, prop, value) {
3695
3714
  configurable: true
3696
3715
  });
3697
3716
  }
3717
+ function mergeDefs(...defs) {
3718
+ const mergedDescriptors = {};
3719
+ for (const def of defs) {
3720
+ const descriptors = Object.getOwnPropertyDescriptors(def);
3721
+ Object.assign(mergedDescriptors, descriptors);
3722
+ }
3723
+ return Object.defineProperties({}, mergedDescriptors);
3724
+ }
3698
3725
  function esc(str) {
3699
3726
  return JSON.stringify(str);
3700
3727
  }
3701
- const captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
3728
+ function slugify(input) {
3729
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
3730
+ }
3731
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
3702
3732
  function isObject(data) {
3703
3733
  return typeof data === "object" && data !== null && !Array.isArray(data);
3704
3734
  }
@@ -3715,11 +3745,17 @@ function isPlainObject$1(o) {
3715
3745
  if (isObject(o) === false) return false;
3716
3746
  const ctor = o.constructor;
3717
3747
  if (ctor === void 0) return true;
3748
+ if (typeof ctor !== "function") return true;
3718
3749
  const prot = ctor.prototype;
3719
3750
  if (isObject(prot) === false) return false;
3720
3751
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
3721
3752
  return true;
3722
3753
  }
3754
+ function shallowClone(o) {
3755
+ if (isPlainObject$1(o)) return { ...o };
3756
+ if (Array.isArray(o)) return [...o];
3757
+ return o;
3758
+ }
3723
3759
  const propertyKeyTypes = new Set([
3724
3760
  "string",
3725
3761
  "number",
@@ -3761,51 +3797,70 @@ const NUMBER_FORMAT_RANGES = {
3761
3797
  float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
3762
3798
  };
3763
3799
  function pick(schema, mask) {
3764
- const newShape = {};
3765
3800
  const currDef = schema._zod.def;
3766
- for (const key in mask) {
3767
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3768
- if (!mask[key]) continue;
3769
- newShape[key] = currDef.shape[key];
3770
- }
3771
- return clone(schema, {
3772
- ...schema._zod.def,
3773
- shape: newShape,
3801
+ const checks = currDef.checks;
3802
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
3803
+ return clone(schema, mergeDefs(schema._zod.def, {
3804
+ get shape() {
3805
+ const newShape = {};
3806
+ for (const key in mask) {
3807
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3808
+ if (!mask[key]) continue;
3809
+ newShape[key] = currDef.shape[key];
3810
+ }
3811
+ assignProp(this, "shape", newShape);
3812
+ return newShape;
3813
+ },
3774
3814
  checks: []
3775
- });
3815
+ }));
3776
3816
  }
3777
3817
  function omit(schema, mask) {
3778
- const newShape = { ...schema._zod.def.shape };
3779
3818
  const currDef = schema._zod.def;
3780
- for (const key in mask) {
3781
- if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3782
- if (!mask[key]) continue;
3783
- delete newShape[key];
3784
- }
3785
- return clone(schema, {
3786
- ...schema._zod.def,
3787
- shape: newShape,
3819
+ const checks = currDef.checks;
3820
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
3821
+ return clone(schema, mergeDefs(schema._zod.def, {
3822
+ get shape() {
3823
+ const newShape = { ...schema._zod.def.shape };
3824
+ for (const key in mask) {
3825
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3826
+ if (!mask[key]) continue;
3827
+ delete newShape[key];
3828
+ }
3829
+ assignProp(this, "shape", newShape);
3830
+ return newShape;
3831
+ },
3788
3832
  checks: []
3789
- });
3833
+ }));
3790
3834
  }
3791
3835
  function extend(schema, shape) {
3792
3836
  if (!isPlainObject$1(shape)) throw new Error("Invalid input to extend: expected a plain object");
3793
- return clone(schema, {
3794
- ...schema._zod.def,
3795
- get shape() {
3796
- const _shape = {
3797
- ...schema._zod.def.shape,
3798
- ...shape
3799
- };
3800
- assignProp(this, "shape", _shape);
3801
- return _shape;
3802
- },
3803
- checks: []
3804
- });
3837
+ const checks = schema._zod.def.checks;
3838
+ if (checks && checks.length > 0) {
3839
+ const existingShape = schema._zod.def.shape;
3840
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
3841
+ }
3842
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
3843
+ const _shape = {
3844
+ ...schema._zod.def.shape,
3845
+ ...shape
3846
+ };
3847
+ assignProp(this, "shape", _shape);
3848
+ return _shape;
3849
+ } }));
3850
+ }
3851
+ function safeExtend(schema, shape) {
3852
+ if (!isPlainObject$1(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
3853
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
3854
+ const _shape = {
3855
+ ...schema._zod.def.shape,
3856
+ ...shape
3857
+ };
3858
+ assignProp(this, "shape", _shape);
3859
+ return _shape;
3860
+ } }));
3805
3861
  }
3806
3862
  function merge(a, b) {
3807
- return clone(a, {
3808
- ...a._zod.def,
3863
+ return clone(a, mergeDefs(a._zod.def, {
3809
3864
  get shape() {
3810
3865
  const _shape = {
3811
3866
  ...a._zod.def.shape,
@@ -3814,53 +3869,59 @@ function merge(a, b) {
3814
3869
  assignProp(this, "shape", _shape);
3815
3870
  return _shape;
3816
3871
  },
3817
- catchall: b._zod.def.catchall,
3872
+ get catchall() {
3873
+ return b._zod.def.catchall;
3874
+ },
3818
3875
  checks: []
3819
- });
3876
+ }));
3820
3877
  }
3821
3878
  function partial(Class, schema, mask) {
3822
- const oldShape = schema._zod.def.shape;
3823
- const shape = { ...oldShape };
3824
- if (mask) for (const key in mask) {
3825
- if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
3826
- if (!mask[key]) continue;
3827
- shape[key] = Class ? new Class({
3828
- type: "optional",
3829
- innerType: oldShape[key]
3830
- }) : oldShape[key];
3831
- }
3832
- else for (const key in oldShape) shape[key] = Class ? new Class({
3833
- type: "optional",
3834
- innerType: oldShape[key]
3835
- }) : oldShape[key];
3836
- return clone(schema, {
3837
- ...schema._zod.def,
3838
- shape,
3879
+ const checks = schema._zod.def.checks;
3880
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
3881
+ return clone(schema, mergeDefs(schema._zod.def, {
3882
+ get shape() {
3883
+ const oldShape = schema._zod.def.shape;
3884
+ const shape = { ...oldShape };
3885
+ if (mask) for (const key in mask) {
3886
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
3887
+ if (!mask[key]) continue;
3888
+ shape[key] = Class ? new Class({
3889
+ type: "optional",
3890
+ innerType: oldShape[key]
3891
+ }) : oldShape[key];
3892
+ }
3893
+ else for (const key in oldShape) shape[key] = Class ? new Class({
3894
+ type: "optional",
3895
+ innerType: oldShape[key]
3896
+ }) : oldShape[key];
3897
+ assignProp(this, "shape", shape);
3898
+ return shape;
3899
+ },
3839
3900
  checks: []
3840
- });
3901
+ }));
3841
3902
  }
3842
3903
  function required(Class, schema, mask) {
3843
- const oldShape = schema._zod.def.shape;
3844
- const shape = { ...oldShape };
3845
- if (mask) for (const key in mask) {
3846
- if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
3847
- if (!mask[key]) continue;
3848
- shape[key] = new Class({
3904
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
3905
+ const oldShape = schema._zod.def.shape;
3906
+ const shape = { ...oldShape };
3907
+ if (mask) for (const key in mask) {
3908
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
3909
+ if (!mask[key]) continue;
3910
+ shape[key] = new Class({
3911
+ type: "nonoptional",
3912
+ innerType: oldShape[key]
3913
+ });
3914
+ }
3915
+ else for (const key in oldShape) shape[key] = new Class({
3849
3916
  type: "nonoptional",
3850
3917
  innerType: oldShape[key]
3851
3918
  });
3852
- }
3853
- else for (const key in oldShape) shape[key] = new Class({
3854
- type: "nonoptional",
3855
- innerType: oldShape[key]
3856
- });
3857
- return clone(schema, {
3858
- ...schema._zod.def,
3859
- shape,
3860
- checks: []
3861
- });
3919
+ assignProp(this, "shape", shape);
3920
+ return shape;
3921
+ } }));
3862
3922
  }
3863
3923
  function aborted(x, startIndex = 0) {
3924
+ if (x.aborted === true) return true;
3864
3925
  for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
3865
3926
  return false;
3866
3927
  }
@@ -3914,12 +3975,7 @@ const initializer$1 = (inst, def) => {
3914
3975
  value: def,
3915
3976
  enumerable: false
3916
3977
  });
3917
- Object.defineProperty(inst, "message", {
3918
- get() {
3919
- return JSON.stringify(def, jsonStringifyReplacer, 2);
3920
- },
3921
- enumerable: true
3922
- });
3978
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
3923
3979
  Object.defineProperty(inst, "toString", {
3924
3980
  value: () => inst.message,
3925
3981
  enumerable: false
@@ -3939,10 +3995,7 @@ function flattenError(error, mapper = (issue) => issue.message) {
3939
3995
  fieldErrors
3940
3996
  };
3941
3997
  }
3942
- function formatError(error, _mapper) {
3943
- const mapper = _mapper || function(issue) {
3944
- return issue.message;
3945
- };
3998
+ function formatError(error, mapper = (issue) => issue.message) {
3946
3999
  const fieldErrors = { _errors: [] };
3947
4000
  const processError = (error) => {
3948
4001
  for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
@@ -4035,6 +4088,42 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
4035
4088
  };
4036
4089
  };
4037
4090
  const safeParseAsync$2 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
4091
+ const _encode = (_Err) => (schema, value, _ctx) => {
4092
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
4093
+ return _parse(_Err)(schema, value, ctx);
4094
+ };
4095
+ const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
4096
+ const _decode = (_Err) => (schema, value, _ctx) => {
4097
+ return _parse(_Err)(schema, value, _ctx);
4098
+ };
4099
+ const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
4100
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
4101
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
4102
+ return _parseAsync(_Err)(schema, value, ctx);
4103
+ };
4104
+ const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
4105
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
4106
+ return _parseAsync(_Err)(schema, value, _ctx);
4107
+ };
4108
+ const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
4109
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
4110
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
4111
+ return _safeParse(_Err)(schema, value, ctx);
4112
+ };
4113
+ const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
4114
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
4115
+ return _safeParse(_Err)(schema, value, _ctx);
4116
+ };
4117
+ const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
4118
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
4119
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
4120
+ return _safeParseAsync(_Err)(schema, value, ctx);
4121
+ };
4122
+ const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
4123
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
4124
+ return _safeParseAsync(_Err)(schema, value, _ctx);
4125
+ };
4126
+ const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
4038
4127
 
4039
4128
  //#endregion
4040
4129
  //#region node_modules/zod/v4/core/regexes.js
@@ -4048,11 +4137,11 @@ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
4048
4137
  const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
4049
4138
  /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
4050
4139
  const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
4051
- /** Returns a regex for validating an RFC 4122 UUID.
4140
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
4052
4141
  *
4053
4142
  * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
4054
4143
  const uuid = (version) => {
4055
- if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
4144
+ if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
4056
4145
  return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
4057
4146
  };
4058
4147
  /** Practical email validation */
@@ -4062,13 +4151,12 @@ function emoji() {
4062
4151
  return new RegExp(_emoji$1, "u");
4063
4152
  }
4064
4153
  const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
4065
- const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
4154
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
4066
4155
  const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
4067
4156
  const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4068
4157
  const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
4069
4158
  const base64url = /^[A-Za-z0-9_-]*$/;
4070
- const hostname$1 = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
4071
- const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
4159
+ const e164 = /^\+[1-9]\d{6,14}$/;
4072
4160
  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])))`;
4073
4161
  const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
4074
4162
  function timeSource(args) {
@@ -4082,7 +4170,7 @@ function datetime$1(args) {
4082
4170
  const time = timeSource({ precision: args.precision });
4083
4171
  const opts = ["Z"];
4084
4172
  if (args.local) opts.push("");
4085
- if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
4173
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
4086
4174
  const timeRegex = `${time}(?:${opts.join("|")})`;
4087
4175
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
4088
4176
  }
@@ -4090,10 +4178,10 @@ const string$1 = (params) => {
4090
4178
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
4091
4179
  return new RegExp(`^${regex}$`);
4092
4180
  };
4093
- const integer = /^\d+$/;
4094
- const number$1 = /^-?\d+(?:\.\d+)?/i;
4095
- const boolean$1 = /true|false/i;
4096
- const _null$2 = /null/i;
4181
+ const integer = /^-?\d+$/;
4182
+ const number$1 = /^-?\d+(?:\.\d+)?$/;
4183
+ const boolean$1 = /^(?:true|false)$/i;
4184
+ const _null$2 = /^null$/i;
4097
4185
  const lowercase = /^[^A-Z]*$/;
4098
4186
  const uppercase = /^[^a-z]*$/;
4099
4187
 
@@ -4124,7 +4212,7 @@ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (ins
4124
4212
  payload.issues.push({
4125
4213
  origin,
4126
4214
  code: "too_big",
4127
- maximum: def.value,
4215
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
4128
4216
  input: payload.value,
4129
4217
  inclusive: def.inclusive,
4130
4218
  inst,
@@ -4146,7 +4234,7 @@ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan"
4146
4234
  payload.issues.push({
4147
4235
  origin,
4148
4236
  code: "too_small",
4149
- minimum: def.value,
4237
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
4150
4238
  input: payload.value,
4151
4239
  inclusive: def.inclusive,
4152
4240
  inst,
@@ -4194,6 +4282,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
4194
4282
  expected: origin,
4195
4283
  format: def.format,
4196
4284
  code: "invalid_type",
4285
+ continue: false,
4197
4286
  input,
4198
4287
  inst
4199
4288
  });
@@ -4207,6 +4296,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
4207
4296
  note: "Integers must be within the safe integer range.",
4208
4297
  inst,
4209
4298
  origin,
4299
+ inclusive: true,
4210
4300
  continue: !def.abort
4211
4301
  });
4212
4302
  else payload.issues.push({
@@ -4216,6 +4306,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
4216
4306
  note: "Integers must be within the safe integer range.",
4217
4307
  inst,
4218
4308
  origin,
4309
+ inclusive: true,
4219
4310
  continue: !def.abort
4220
4311
  });
4221
4312
  return;
@@ -4235,7 +4326,9 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
4235
4326
  input,
4236
4327
  code: "too_big",
4237
4328
  maximum,
4238
- inst
4329
+ inclusive: true,
4330
+ inst,
4331
+ continue: !def.abort
4239
4332
  });
4240
4333
  };
4241
4334
  });
@@ -4487,8 +4580,8 @@ var Doc = class {
4487
4580
  //#region node_modules/zod/v4/core/versions.js
4488
4581
  const version = {
4489
4582
  major: 4,
4490
- minor: 0,
4491
- patch: 0
4583
+ minor: 3,
4584
+ patch: 6
4492
4585
  };
4493
4586
 
4494
4587
  //#endregion
@@ -4533,7 +4626,33 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
4533
4626
  });
4534
4627
  return payload;
4535
4628
  };
4629
+ const handleCanaryResult = (canary, payload, ctx) => {
4630
+ if (aborted(canary)) {
4631
+ canary.aborted = true;
4632
+ return canary;
4633
+ }
4634
+ const checkResult = runChecks(payload, checks, ctx);
4635
+ if (checkResult instanceof Promise) {
4636
+ if (ctx.async === false) throw new $ZodAsyncError();
4637
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
4638
+ }
4639
+ return inst._zod.parse(checkResult, ctx);
4640
+ };
4536
4641
  inst._zod.run = (payload, ctx) => {
4642
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
4643
+ if (ctx.direction === "backward") {
4644
+ const canary = inst._zod.parse({
4645
+ value: payload.value,
4646
+ issues: []
4647
+ }, {
4648
+ ...ctx,
4649
+ skipChecks: true
4650
+ });
4651
+ if (canary instanceof Promise) return canary.then((canary) => {
4652
+ return handleCanaryResult(canary, payload, ctx);
4653
+ });
4654
+ return handleCanaryResult(canary, payload, ctx);
4655
+ }
4537
4656
  const result = inst._zod.parse(payload, ctx);
4538
4657
  if (result instanceof Promise) {
4539
4658
  if (ctx.async === false) throw new $ZodAsyncError();
@@ -4542,7 +4661,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
4542
4661
  return runChecks(result, checks, ctx);
4543
4662
  };
4544
4663
  }
4545
- inst["~standard"] = {
4664
+ defineLazy(inst, "~standard", () => ({
4546
4665
  validate: (value) => {
4547
4666
  try {
4548
4667
  const r = safeParse$2(inst, value);
@@ -4553,7 +4672,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
4553
4672
  },
4554
4673
  vendor: "zod",
4555
4674
  version: 1
4556
- };
4675
+ }));
4557
4676
  });
4558
4677
  const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
4559
4678
  $ZodType.init(inst, def);
@@ -4605,16 +4724,15 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
4605
4724
  $ZodStringFormat.init(inst, def);
4606
4725
  inst._zod.check = (payload) => {
4607
4726
  try {
4608
- const orig = payload.value;
4609
- const url = new URL(orig);
4610
- const href = url.href;
4727
+ const trimmed = payload.value.trim();
4728
+ const url = new URL(trimmed);
4611
4729
  if (def.hostname) {
4612
4730
  def.hostname.lastIndex = 0;
4613
4731
  if (!def.hostname.test(url.hostname)) payload.issues.push({
4614
4732
  code: "invalid_format",
4615
4733
  format: "url",
4616
4734
  note: "Invalid hostname",
4617
- pattern: hostname$1.source,
4735
+ pattern: def.hostname.source,
4618
4736
  input: payload.value,
4619
4737
  inst,
4620
4738
  continue: !def.abort
@@ -4632,8 +4750,8 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
4632
4750
  continue: !def.abort
4633
4751
  });
4634
4752
  }
4635
- if (!orig.endsWith("/") && href.endsWith("/")) payload.value = href.slice(0, -1);
4636
- else payload.value = href;
4753
+ if (def.normalize) payload.value = url.href;
4754
+ else payload.value = trimmed;
4637
4755
  return;
4638
4756
  } catch (_) {
4639
4757
  payload.issues.push({
@@ -4693,18 +4811,12 @@ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, d
4693
4811
  const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
4694
4812
  def.pattern ?? (def.pattern = ipv4);
4695
4813
  $ZodStringFormat.init(inst, def);
4696
- inst._zod.onattach.push((inst) => {
4697
- const bag = inst._zod.bag;
4698
- bag.format = `ipv4`;
4699
- });
4814
+ inst._zod.bag.format = `ipv4`;
4700
4815
  });
4701
4816
  const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
4702
4817
  def.pattern ?? (def.pattern = ipv6);
4703
4818
  $ZodStringFormat.init(inst, def);
4704
- inst._zod.onattach.push((inst) => {
4705
- const bag = inst._zod.bag;
4706
- bag.format = `ipv6`;
4707
- });
4819
+ inst._zod.bag.format = `ipv6`;
4708
4820
  inst._zod.check = (payload) => {
4709
4821
  try {
4710
4822
  new URL(`http://[${payload.value}]`);
@@ -4727,8 +4839,10 @@ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
4727
4839
  def.pattern ?? (def.pattern = cidrv6);
4728
4840
  $ZodStringFormat.init(inst, def);
4729
4841
  inst._zod.check = (payload) => {
4730
- const [address, prefix] = payload.value.split("/");
4842
+ const parts = payload.value.split("/");
4731
4843
  try {
4844
+ if (parts.length !== 2) throw new Error();
4845
+ const [address, prefix] = parts;
4732
4846
  if (!prefix) throw new Error();
4733
4847
  const prefixNum = Number(prefix);
4734
4848
  if (`${prefixNum}` !== prefix) throw new Error();
@@ -4758,9 +4872,7 @@ function isValidBase64(data) {
4758
4872
  const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
4759
4873
  def.pattern ?? (def.pattern = base64);
4760
4874
  $ZodStringFormat.init(inst, def);
4761
- inst._zod.onattach.push((inst) => {
4762
- inst._zod.bag.contentEncoding = "base64";
4763
- });
4875
+ inst._zod.bag.contentEncoding = "base64";
4764
4876
  inst._zod.check = (payload) => {
4765
4877
  if (isValidBase64(payload.value)) return;
4766
4878
  payload.issues.push({
@@ -4780,9 +4892,7 @@ function isValidBase64URL(data) {
4780
4892
  const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
4781
4893
  def.pattern ?? (def.pattern = base64url);
4782
4894
  $ZodStringFormat.init(inst, def);
4783
- inst._zod.onattach.push((inst) => {
4784
- inst._zod.bag.contentEncoding = "base64url";
4785
- });
4895
+ inst._zod.bag.contentEncoding = "base64url";
4786
4896
  inst._zod.check = (payload) => {
4787
4897
  if (isValidBase64URL(payload.value)) return;
4788
4898
  payload.issues.push({
@@ -4846,7 +4956,7 @@ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
4846
4956
  return payload;
4847
4957
  };
4848
4958
  });
4849
- const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
4959
+ const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
4850
4960
  $ZodCheckNumberFormat.init(inst, def);
4851
4961
  $ZodNumber.init(inst, def);
4852
4962
  });
@@ -4932,32 +5042,68 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
4932
5042
  return payload;
4933
5043
  };
4934
5044
  });
4935
- function handleObjectResult(result, final, key) {
4936
- if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
4937
- final.value[key] = result.value;
4938
- }
4939
- function handleOptionalObjectResult(result, final, key, input) {
4940
- if (result.issues.length) if (input[key] === void 0) if (key in input) final.value[key] = void 0;
4941
- else final.value[key] = result.value;
4942
- else final.issues.push(...prefixIssues(key, result.issues));
4943
- else if (result.value === void 0) {
5045
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
5046
+ if (result.issues.length) {
5047
+ if (isOptionalOut && !(key in input)) return;
5048
+ final.issues.push(...prefixIssues(key, result.issues));
5049
+ }
5050
+ if (result.value === void 0) {
4944
5051
  if (key in input) final.value[key] = void 0;
4945
5052
  } else final.value[key] = result.value;
4946
5053
  }
5054
+ function normalizeDef(def) {
5055
+ const keys = Object.keys(def.shape);
5056
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
5057
+ const okeys = optionalKeys(def.shape);
5058
+ return {
5059
+ ...def,
5060
+ keys,
5061
+ keySet: new Set(keys),
5062
+ numKeys: keys.length,
5063
+ optionalKeys: new Set(okeys)
5064
+ };
5065
+ }
5066
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
5067
+ const unrecognized = [];
5068
+ const keySet = def.keySet;
5069
+ const _catchall = def.catchall._zod;
5070
+ const t = _catchall.def.type;
5071
+ const isOptionalOut = _catchall.optout === "optional";
5072
+ for (const key in input) {
5073
+ if (keySet.has(key)) continue;
5074
+ if (t === "never") {
5075
+ unrecognized.push(key);
5076
+ continue;
5077
+ }
5078
+ const r = _catchall.run({
5079
+ value: input[key],
5080
+ issues: []
5081
+ }, ctx);
5082
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
5083
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
5084
+ }
5085
+ if (unrecognized.length) payload.issues.push({
5086
+ code: "unrecognized_keys",
5087
+ keys: unrecognized,
5088
+ input,
5089
+ inst
5090
+ });
5091
+ if (!proms.length) return payload;
5092
+ return Promise.all(proms).then(() => {
5093
+ return payload;
5094
+ });
5095
+ }
4947
5096
  const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
4948
5097
  $ZodType.init(inst, def);
4949
- const _normalized = cached(() => {
4950
- const keys = Object.keys(def.shape);
4951
- for (const k of keys) if (!(def.shape[k] instanceof $ZodType)) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
4952
- const okeys = optionalKeys(def.shape);
4953
- return {
4954
- shape: def.shape,
4955
- keys,
4956
- keySet: new Set(keys),
4957
- numKeys: keys.length,
4958
- optionalKeys: new Set(okeys)
4959
- };
4960
- });
5098
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
5099
+ const sh = def.shape;
5100
+ Object.defineProperty(def, "shape", { get: () => {
5101
+ const newSh = { ...sh };
5102
+ Object.defineProperty(def, "shape", { value: newSh });
5103
+ return newSh;
5104
+ } });
5105
+ }
5106
+ const _normalized = cached(() => normalizeDef(def));
4961
5107
  defineLazy(inst._zod, "propValues", () => {
4962
5108
  const shape = def.shape;
4963
5109
  const propValues = {};
@@ -4970,6 +5116,42 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
4970
5116
  }
4971
5117
  return propValues;
4972
5118
  });
5119
+ const isObject$2 = isObject;
5120
+ const catchall = def.catchall;
5121
+ let value;
5122
+ inst._zod.parse = (payload, ctx) => {
5123
+ value ?? (value = _normalized.value);
5124
+ const input = payload.value;
5125
+ if (!isObject$2(input)) {
5126
+ payload.issues.push({
5127
+ expected: "object",
5128
+ code: "invalid_type",
5129
+ input,
5130
+ inst
5131
+ });
5132
+ return payload;
5133
+ }
5134
+ payload.value = {};
5135
+ const proms = [];
5136
+ const shape = value.shape;
5137
+ for (const key of value.keys) {
5138
+ const el = shape[key];
5139
+ const isOptionalOut = el._zod.optout === "optional";
5140
+ const r = el._zod.run({
5141
+ value: input[key],
5142
+ issues: []
5143
+ }, ctx);
5144
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
5145
+ else handlePropertyResult(r, payload, key, input, isOptionalOut);
5146
+ }
5147
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
5148
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
5149
+ };
5150
+ });
5151
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
5152
+ $ZodObject.init(inst, def);
5153
+ const superParse = inst._zod.parse;
5154
+ const _normalized = cached(() => normalizeDef(def));
4973
5155
  const generateFastpass = (shape) => {
4974
5156
  const doc = new Doc([
4975
5157
  "shape",
@@ -4985,40 +5167,48 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
4985
5167
  const ids = Object.create(null);
4986
5168
  let counter = 0;
4987
5169
  for (const key of normalized.keys) ids[key] = `key_${counter++}`;
4988
- doc.write(`const newResult = {}`);
4989
- for (const key of normalized.keys) if (normalized.optionalKeys.has(key)) {
5170
+ doc.write(`const newResult = {};`);
5171
+ for (const key of normalized.keys) {
4990
5172
  const id = ids[key];
4991
- doc.write(`const ${id} = ${parseStr(key)};`);
4992
5173
  const k = esc(key);
4993
- doc.write(`
5174
+ const isOptionalOut = shape[key]?._zod?.optout === "optional";
5175
+ doc.write(`const ${id} = ${parseStr(key)};`);
5176
+ if (isOptionalOut) doc.write(`
4994
5177
  if (${id}.issues.length) {
4995
- if (input[${k}] === undefined) {
4996
- if (${k} in input) {
4997
- newResult[${k}] = undefined;
4998
- }
4999
- } else {
5000
- payload.issues = payload.issues.concat(
5001
- ${id}.issues.map((iss) => ({
5002
- ...iss,
5003
- path: iss.path ? [${k}, ...iss.path] : [${k}],
5004
- }))
5005
- );
5178
+ if (${k} in input) {
5179
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
5180
+ ...iss,
5181
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
5182
+ })));
5183
+ }
5184
+ }
5185
+
5186
+ if (${id}.value === undefined) {
5187
+ if (${k} in input) {
5188
+ newResult[${k}] = undefined;
5006
5189
  }
5007
- } else if (${id}.value === undefined) {
5008
- if (${k} in input) newResult[${k}] = undefined;
5009
5190
  } else {
5010
5191
  newResult[${k}] = ${id}.value;
5011
5192
  }
5012
- `);
5013
- } else {
5014
- const id = ids[key];
5015
- doc.write(`const ${id} = ${parseStr(key)};`);
5016
- doc.write(`
5017
- if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
5193
+
5194
+ `);
5195
+ else doc.write(`
5196
+ if (${id}.issues.length) {
5197
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
5018
5198
  ...iss,
5019
- path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
5020
- })));`);
5021
- doc.write(`newResult[${esc(key)}] = ${id}.value`);
5199
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
5200
+ })));
5201
+ }
5202
+
5203
+ if (${id}.value === undefined) {
5204
+ if (${k} in input) {
5205
+ newResult[${k}] = undefined;
5206
+ }
5207
+ } else {
5208
+ newResult[${k}] = ${id}.value;
5209
+ }
5210
+
5211
+ `);
5022
5212
  }
5023
5213
  doc.write(`payload.value = newResult;`);
5024
5214
  doc.write(`return payload;`);
@@ -5044,53 +5234,13 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
5044
5234
  });
5045
5235
  return payload;
5046
5236
  }
5047
- const proms = [];
5048
5237
  if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
5049
5238
  if (!fastpass) fastpass = generateFastpass(def.shape);
5050
5239
  payload = fastpass(payload, ctx);
5051
- } else {
5052
- payload.value = {};
5053
- const shape = value.shape;
5054
- for (const key of value.keys) {
5055
- const el = shape[key];
5056
- const r = el._zod.run({
5057
- value: input[key],
5058
- issues: []
5059
- }, ctx);
5060
- const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
5061
- if (r instanceof Promise) proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
5062
- else if (isOptional) handleOptionalObjectResult(r, payload, key, input);
5063
- else handleObjectResult(r, payload, key);
5064
- }
5240
+ if (!catchall) return payload;
5241
+ return handleCatchall([], input, payload, ctx, value, inst);
5065
5242
  }
5066
- if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
5067
- const unrecognized = [];
5068
- const keySet = value.keySet;
5069
- const _catchall = catchall._zod;
5070
- const t = _catchall.def.type;
5071
- for (const key of Object.keys(input)) {
5072
- if (keySet.has(key)) continue;
5073
- if (t === "never") {
5074
- unrecognized.push(key);
5075
- continue;
5076
- }
5077
- const r = _catchall.run({
5078
- value: input[key],
5079
- issues: []
5080
- }, ctx);
5081
- if (r instanceof Promise) proms.push(r.then((r) => handleObjectResult(r, payload, key)));
5082
- else handleObjectResult(r, payload, key);
5083
- }
5084
- if (unrecognized.length) payload.issues.push({
5085
- code: "unrecognized_keys",
5086
- keys: unrecognized,
5087
- input,
5088
- inst
5089
- });
5090
- if (!proms.length) return payload;
5091
- return Promise.all(proms).then(() => {
5092
- return payload;
5093
- });
5243
+ return superParse(payload, ctx);
5094
5244
  };
5095
5245
  });
5096
5246
  function handleUnionResults(results, final, inst, ctx) {
@@ -5098,6 +5248,11 @@ function handleUnionResults(results, final, inst, ctx) {
5098
5248
  final.value = result.value;
5099
5249
  return final;
5100
5250
  }
5251
+ const nonaborted = results.filter((r) => !aborted(r));
5252
+ if (nonaborted.length === 1) {
5253
+ final.value = nonaborted[0].value;
5254
+ return nonaborted[0];
5255
+ }
5101
5256
  final.issues.push({
5102
5257
  code: "invalid_union",
5103
5258
  input: final.value,
@@ -5119,7 +5274,10 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
5119
5274
  return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
5120
5275
  }
5121
5276
  });
5277
+ const single = def.options.length === 1;
5278
+ const first = def.options[0]._zod.run;
5122
5279
  inst._zod.parse = (payload, ctx) => {
5280
+ if (single) return first(payload, ctx);
5123
5281
  let async = false;
5124
5282
  const results = [];
5125
5283
  for (const option of def.options) {
@@ -5142,6 +5300,7 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
5142
5300
  };
5143
5301
  });
5144
5302
  const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
5303
+ def.inclusive = false;
5145
5304
  $ZodUnion.init(inst, def);
5146
5305
  const _super = inst._zod.parse;
5147
5306
  defineLazy(inst._zod, "propValues", () => {
@@ -5160,7 +5319,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
5160
5319
  const opts = def.options;
5161
5320
  const map = /* @__PURE__ */ new Map();
5162
5321
  for (const o of opts) {
5163
- const values = o._zod.propValues[def.discriminator];
5322
+ const values = o._zod.propValues?.[def.discriminator];
5164
5323
  if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
5165
5324
  for (const v of values) {
5166
5325
  if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
@@ -5187,6 +5346,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
5187
5346
  code: "invalid_union",
5188
5347
  errors: [],
5189
5348
  note: "No matching discriminator",
5349
+ discriminator: def.discriminator,
5190
5350
  input,
5191
5351
  path: [def.discriminator],
5192
5352
  inst
@@ -5268,8 +5428,25 @@ function mergeValues(a, b) {
5268
5428
  };
5269
5429
  }
5270
5430
  function handleIntersectionResults(result, left, right) {
5271
- if (left.issues.length) result.issues.push(...left.issues);
5272
- if (right.issues.length) result.issues.push(...right.issues);
5431
+ const unrecKeys = /* @__PURE__ */ new Map();
5432
+ let unrecIssue;
5433
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
5434
+ unrecIssue ?? (unrecIssue = iss);
5435
+ for (const k of iss.keys) {
5436
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
5437
+ unrecKeys.get(k).l = true;
5438
+ }
5439
+ } else result.issues.push(iss);
5440
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
5441
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
5442
+ unrecKeys.get(k).r = true;
5443
+ }
5444
+ else result.issues.push(iss);
5445
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
5446
+ if (bothKeys.length && unrecIssue) result.issues.push({
5447
+ ...unrecIssue,
5448
+ keys: bothKeys
5449
+ });
5273
5450
  if (aborted(result)) return result;
5274
5451
  const merged = mergeValues(left.value, right.value);
5275
5452
  if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
@@ -5290,10 +5467,12 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
5290
5467
  return payload;
5291
5468
  }
5292
5469
  const proms = [];
5293
- if (def.keyType._zod.values) {
5294
- const values = def.keyType._zod.values;
5470
+ const values = def.keyType._zod.values;
5471
+ if (values) {
5295
5472
  payload.value = {};
5473
+ const recordKeys = /* @__PURE__ */ new Set();
5296
5474
  for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
5475
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
5297
5476
  const result = def.valueType._zod.run({
5298
5477
  value: input[key],
5299
5478
  issues: []
@@ -5308,7 +5487,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
5308
5487
  }
5309
5488
  }
5310
5489
  let unrecognized;
5311
- for (const key in input) if (!values.has(key)) {
5490
+ for (const key in input) if (!recordKeys.has(key)) {
5312
5491
  unrecognized = unrecognized ?? [];
5313
5492
  unrecognized.push(key);
5314
5493
  }
@@ -5322,21 +5501,29 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
5322
5501
  payload.value = {};
5323
5502
  for (const key of Reflect.ownKeys(input)) {
5324
5503
  if (key === "__proto__") continue;
5325
- const keyResult = def.keyType._zod.run({
5504
+ let keyResult = def.keyType._zod.run({
5326
5505
  value: key,
5327
5506
  issues: []
5328
5507
  }, ctx);
5329
5508
  if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
5509
+ if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
5510
+ const retryResult = def.keyType._zod.run({
5511
+ value: Number(key),
5512
+ issues: []
5513
+ }, ctx);
5514
+ if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
5515
+ if (retryResult.issues.length === 0) keyResult = retryResult;
5516
+ }
5330
5517
  if (keyResult.issues.length) {
5331
- payload.issues.push({
5332
- origin: "record",
5518
+ if (def.mode === "loose") payload.value[key] = input[key];
5519
+ else payload.issues.push({
5333
5520
  code: "invalid_key",
5521
+ origin: "record",
5334
5522
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
5335
5523
  input: key,
5336
5524
  path: [key],
5337
5525
  inst
5338
5526
  });
5339
- payload.value[keyResult.value] = keyResult.value;
5340
5527
  continue;
5341
5528
  }
5342
5529
  const result = def.valueType._zod.run({
@@ -5360,11 +5547,12 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
5360
5547
  const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
5361
5548
  $ZodType.init(inst, def);
5362
5549
  const values = getEnumValues(def.entries);
5363
- inst._zod.values = new Set(values);
5550
+ const valuesSet = new Set(values);
5551
+ inst._zod.values = valuesSet;
5364
5552
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
5365
5553
  inst._zod.parse = (payload, _ctx) => {
5366
5554
  const input = payload.value;
5367
- if (inst._zod.values.has(input)) return payload;
5555
+ if (valuesSet.has(input)) return payload;
5368
5556
  payload.issues.push({
5369
5557
  code: "invalid_value",
5370
5558
  values,
@@ -5376,11 +5564,13 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
5376
5564
  });
5377
5565
  const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
5378
5566
  $ZodType.init(inst, def);
5379
- inst._zod.values = new Set(def.values);
5380
- inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)).join("|")})$`);
5567
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
5568
+ const values = new Set(def.values);
5569
+ inst._zod.values = values;
5570
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
5381
5571
  inst._zod.parse = (payload, _ctx) => {
5382
5572
  const input = payload.value;
5383
- if (inst._zod.values.has(input)) return payload;
5573
+ if (values.has(input)) return payload;
5384
5574
  payload.issues.push({
5385
5575
  code: "invalid_value",
5386
5576
  values: def.values,
@@ -5392,9 +5582,10 @@ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
5392
5582
  });
5393
5583
  const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
5394
5584
  $ZodType.init(inst, def);
5395
- inst._zod.parse = (payload, _ctx) => {
5585
+ inst._zod.parse = (payload, ctx) => {
5586
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
5396
5587
  const _out = def.transform(payload.value, payload);
5397
- if (_ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
5588
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
5398
5589
  payload.value = output;
5399
5590
  return payload;
5400
5591
  });
@@ -5403,6 +5594,13 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
5403
5594
  return payload;
5404
5595
  };
5405
5596
  });
5597
+ function handleOptionalResult(result, input) {
5598
+ if (result.issues.length && input === void 0) return {
5599
+ issues: [],
5600
+ value: void 0
5601
+ };
5602
+ return result;
5603
+ }
5406
5604
  const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
5407
5605
  $ZodType.init(inst, def);
5408
5606
  inst._zod.optin = "optional";
@@ -5415,11 +5613,23 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
5415
5613
  return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
5416
5614
  });
5417
5615
  inst._zod.parse = (payload, ctx) => {
5418
- if (def.innerType._zod.optin === "optional") return def.innerType._zod.run(payload, ctx);
5616
+ if (def.innerType._zod.optin === "optional") {
5617
+ const result = def.innerType._zod.run(payload, ctx);
5618
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
5619
+ return handleOptionalResult(result, payload.value);
5620
+ }
5419
5621
  if (payload.value === void 0) return payload;
5420
5622
  return def.innerType._zod.run(payload, ctx);
5421
5623
  };
5422
5624
  });
5625
+ const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
5626
+ $ZodOptional.init(inst, def);
5627
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5628
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
5629
+ inst._zod.parse = (payload, ctx) => {
5630
+ return def.innerType._zod.run(payload, ctx);
5631
+ };
5632
+ });
5423
5633
  const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
5424
5634
  $ZodType.init(inst, def);
5425
5635
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -5441,10 +5651,11 @@ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
5441
5651
  inst._zod.optin = "optional";
5442
5652
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5443
5653
  inst._zod.parse = (payload, ctx) => {
5654
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
5444
5655
  if (payload.value === void 0) {
5445
5656
  payload.value = def.defaultValue;
5446
5657
  /**
5447
- * $ZodDefault always returns the default value immediately.
5658
+ * $ZodDefault returns the default value immediately in forward direction.
5448
5659
  * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
5449
5660
  return payload;
5450
5661
  }
@@ -5462,6 +5673,7 @@ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) =>
5462
5673
  inst._zod.optin = "optional";
5463
5674
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5464
5675
  inst._zod.parse = (payload, ctx) => {
5676
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
5465
5677
  if (payload.value === void 0) payload.value = def.defaultValue;
5466
5678
  return def.innerType._zod.run(payload, ctx);
5467
5679
  };
@@ -5489,10 +5701,11 @@ function handleNonOptionalResult(payload, inst) {
5489
5701
  }
5490
5702
  const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
5491
5703
  $ZodType.init(inst, def);
5492
- inst._zod.optin = "optional";
5704
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
5493
5705
  defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
5494
5706
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5495
5707
  inst._zod.parse = (payload, ctx) => {
5708
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
5496
5709
  const result = def.innerType._zod.run(payload, ctx);
5497
5710
  if (result instanceof Promise) return result.then((result) => {
5498
5711
  payload.value = result.value;
@@ -5523,15 +5736,24 @@ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
5523
5736
  defineLazy(inst._zod, "values", () => def.in._zod.values);
5524
5737
  defineLazy(inst._zod, "optin", () => def.in._zod.optin);
5525
5738
  defineLazy(inst._zod, "optout", () => def.out._zod.optout);
5739
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
5526
5740
  inst._zod.parse = (payload, ctx) => {
5741
+ if (ctx.direction === "backward") {
5742
+ const right = def.out._zod.run(payload, ctx);
5743
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
5744
+ return handlePipeResult(right, def.in, ctx);
5745
+ }
5527
5746
  const left = def.in._zod.run(payload, ctx);
5528
- if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def, ctx));
5529
- return handlePipeResult(left, def, ctx);
5747
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
5748
+ return handlePipeResult(left, def.out, ctx);
5530
5749
  };
5531
5750
  });
5532
- function handlePipeResult(left, def, ctx) {
5533
- if (aborted(left)) return left;
5534
- return def.out._zod.run({
5751
+ function handlePipeResult(left, next, ctx) {
5752
+ if (left.issues.length) {
5753
+ left.aborted = true;
5754
+ return left;
5755
+ }
5756
+ return next._zod.run({
5535
5757
  value: left.value,
5536
5758
  issues: left.issues
5537
5759
  }, ctx);
@@ -5540,9 +5762,10 @@ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) =>
5540
5762
  $ZodType.init(inst, def);
5541
5763
  defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
5542
5764
  defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5543
- defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
5544
- defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
5765
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
5766
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
5545
5767
  inst._zod.parse = (payload, ctx) => {
5768
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
5546
5769
  const result = def.innerType._zod.run(payload, ctx);
5547
5770
  if (result instanceof Promise) return result.then(handleReadonlyResult);
5548
5771
  return handleReadonlyResult(result);
@@ -5581,22 +5804,20 @@ function handleRefineResult(result, payload, input, inst) {
5581
5804
 
5582
5805
  //#endregion
5583
5806
  //#region node_modules/zod/v4/core/registries.js
5807
+ var _a$1;
5584
5808
  var $ZodRegistry = class {
5585
5809
  constructor() {
5586
- this._map = /* @__PURE__ */ new Map();
5810
+ this._map = /* @__PURE__ */ new WeakMap();
5587
5811
  this._idmap = /* @__PURE__ */ new Map();
5588
5812
  }
5589
5813
  add(schema, ..._meta) {
5590
5814
  const meta = _meta[0];
5591
5815
  this._map.set(schema, meta);
5592
- if (meta && typeof meta === "object" && "id" in meta) {
5593
- if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
5594
- this._idmap.set(meta.id, schema);
5595
- }
5816
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
5596
5817
  return this;
5597
5818
  }
5598
5819
  clear() {
5599
- this._map = /* @__PURE__ */ new Map();
5820
+ this._map = /* @__PURE__ */ new WeakMap();
5600
5821
  this._idmap = /* @__PURE__ */ new Map();
5601
5822
  return this;
5602
5823
  }
@@ -5611,10 +5832,11 @@ var $ZodRegistry = class {
5611
5832
  if (p) {
5612
5833
  const pm = { ...this.get(p) ?? {} };
5613
5834
  delete pm.id;
5614
- return {
5835
+ const f = {
5615
5836
  ...pm,
5616
5837
  ...this._map.get(schema)
5617
5838
  };
5839
+ return Object.keys(f).length ? f : void 0;
5618
5840
  }
5619
5841
  return this._map.get(schema);
5620
5842
  }
@@ -5625,16 +5847,19 @@ var $ZodRegistry = class {
5625
5847
  function registry() {
5626
5848
  return new $ZodRegistry();
5627
5849
  }
5628
- const globalRegistry = /* @__PURE__ */ registry();
5850
+ (_a$1 = globalThis).__zod_globalRegistry ?? (_a$1.__zod_globalRegistry = registry());
5851
+ const globalRegistry = globalThis.__zod_globalRegistry;
5629
5852
 
5630
5853
  //#endregion
5631
5854
  //#region node_modules/zod/v4/core/api.js
5855
+ /* @__NO_SIDE_EFFECTS__ */
5632
5856
  function _string(Class, params) {
5633
5857
  return new Class({
5634
5858
  type: "string",
5635
5859
  ...normalizeParams(params)
5636
5860
  });
5637
5861
  }
5862
+ /* @__NO_SIDE_EFFECTS__ */
5638
5863
  function _email(Class, params) {
5639
5864
  return new Class({
5640
5865
  type: "string",
@@ -5644,6 +5869,7 @@ function _email(Class, params) {
5644
5869
  ...normalizeParams(params)
5645
5870
  });
5646
5871
  }
5872
+ /* @__NO_SIDE_EFFECTS__ */
5647
5873
  function _guid(Class, params) {
5648
5874
  return new Class({
5649
5875
  type: "string",
@@ -5653,6 +5879,7 @@ function _guid(Class, params) {
5653
5879
  ...normalizeParams(params)
5654
5880
  });
5655
5881
  }
5882
+ /* @__NO_SIDE_EFFECTS__ */
5656
5883
  function _uuid(Class, params) {
5657
5884
  return new Class({
5658
5885
  type: "string",
@@ -5662,6 +5889,7 @@ function _uuid(Class, params) {
5662
5889
  ...normalizeParams(params)
5663
5890
  });
5664
5891
  }
5892
+ /* @__NO_SIDE_EFFECTS__ */
5665
5893
  function _uuidv4(Class, params) {
5666
5894
  return new Class({
5667
5895
  type: "string",
@@ -5672,6 +5900,7 @@ function _uuidv4(Class, params) {
5672
5900
  ...normalizeParams(params)
5673
5901
  });
5674
5902
  }
5903
+ /* @__NO_SIDE_EFFECTS__ */
5675
5904
  function _uuidv6(Class, params) {
5676
5905
  return new Class({
5677
5906
  type: "string",
@@ -5682,6 +5911,7 @@ function _uuidv6(Class, params) {
5682
5911
  ...normalizeParams(params)
5683
5912
  });
5684
5913
  }
5914
+ /* @__NO_SIDE_EFFECTS__ */
5685
5915
  function _uuidv7(Class, params) {
5686
5916
  return new Class({
5687
5917
  type: "string",
@@ -5692,6 +5922,7 @@ function _uuidv7(Class, params) {
5692
5922
  ...normalizeParams(params)
5693
5923
  });
5694
5924
  }
5925
+ /* @__NO_SIDE_EFFECTS__ */
5695
5926
  function _url(Class, params) {
5696
5927
  return new Class({
5697
5928
  type: "string",
@@ -5701,6 +5932,7 @@ function _url(Class, params) {
5701
5932
  ...normalizeParams(params)
5702
5933
  });
5703
5934
  }
5935
+ /* @__NO_SIDE_EFFECTS__ */
5704
5936
  function _emoji(Class, params) {
5705
5937
  return new Class({
5706
5938
  type: "string",
@@ -5710,6 +5942,7 @@ function _emoji(Class, params) {
5710
5942
  ...normalizeParams(params)
5711
5943
  });
5712
5944
  }
5945
+ /* @__NO_SIDE_EFFECTS__ */
5713
5946
  function _nanoid(Class, params) {
5714
5947
  return new Class({
5715
5948
  type: "string",
@@ -5719,6 +5952,7 @@ function _nanoid(Class, params) {
5719
5952
  ...normalizeParams(params)
5720
5953
  });
5721
5954
  }
5955
+ /* @__NO_SIDE_EFFECTS__ */
5722
5956
  function _cuid(Class, params) {
5723
5957
  return new Class({
5724
5958
  type: "string",
@@ -5728,6 +5962,7 @@ function _cuid(Class, params) {
5728
5962
  ...normalizeParams(params)
5729
5963
  });
5730
5964
  }
5965
+ /* @__NO_SIDE_EFFECTS__ */
5731
5966
  function _cuid2(Class, params) {
5732
5967
  return new Class({
5733
5968
  type: "string",
@@ -5737,6 +5972,7 @@ function _cuid2(Class, params) {
5737
5972
  ...normalizeParams(params)
5738
5973
  });
5739
5974
  }
5975
+ /* @__NO_SIDE_EFFECTS__ */
5740
5976
  function _ulid(Class, params) {
5741
5977
  return new Class({
5742
5978
  type: "string",
@@ -5746,6 +5982,7 @@ function _ulid(Class, params) {
5746
5982
  ...normalizeParams(params)
5747
5983
  });
5748
5984
  }
5985
+ /* @__NO_SIDE_EFFECTS__ */
5749
5986
  function _xid(Class, params) {
5750
5987
  return new Class({
5751
5988
  type: "string",
@@ -5755,6 +5992,7 @@ function _xid(Class, params) {
5755
5992
  ...normalizeParams(params)
5756
5993
  });
5757
5994
  }
5995
+ /* @__NO_SIDE_EFFECTS__ */
5758
5996
  function _ksuid(Class, params) {
5759
5997
  return new Class({
5760
5998
  type: "string",
@@ -5764,6 +6002,7 @@ function _ksuid(Class, params) {
5764
6002
  ...normalizeParams(params)
5765
6003
  });
5766
6004
  }
6005
+ /* @__NO_SIDE_EFFECTS__ */
5767
6006
  function _ipv4(Class, params) {
5768
6007
  return new Class({
5769
6008
  type: "string",
@@ -5773,6 +6012,7 @@ function _ipv4(Class, params) {
5773
6012
  ...normalizeParams(params)
5774
6013
  });
5775
6014
  }
6015
+ /* @__NO_SIDE_EFFECTS__ */
5776
6016
  function _ipv6(Class, params) {
5777
6017
  return new Class({
5778
6018
  type: "string",
@@ -5782,6 +6022,7 @@ function _ipv6(Class, params) {
5782
6022
  ...normalizeParams(params)
5783
6023
  });
5784
6024
  }
6025
+ /* @__NO_SIDE_EFFECTS__ */
5785
6026
  function _cidrv4(Class, params) {
5786
6027
  return new Class({
5787
6028
  type: "string",
@@ -5791,6 +6032,7 @@ function _cidrv4(Class, params) {
5791
6032
  ...normalizeParams(params)
5792
6033
  });
5793
6034
  }
6035
+ /* @__NO_SIDE_EFFECTS__ */
5794
6036
  function _cidrv6(Class, params) {
5795
6037
  return new Class({
5796
6038
  type: "string",
@@ -5800,6 +6042,7 @@ function _cidrv6(Class, params) {
5800
6042
  ...normalizeParams(params)
5801
6043
  });
5802
6044
  }
6045
+ /* @__NO_SIDE_EFFECTS__ */
5803
6046
  function _base64(Class, params) {
5804
6047
  return new Class({
5805
6048
  type: "string",
@@ -5809,6 +6052,7 @@ function _base64(Class, params) {
5809
6052
  ...normalizeParams(params)
5810
6053
  });
5811
6054
  }
6055
+ /* @__NO_SIDE_EFFECTS__ */
5812
6056
  function _base64url(Class, params) {
5813
6057
  return new Class({
5814
6058
  type: "string",
@@ -5818,6 +6062,7 @@ function _base64url(Class, params) {
5818
6062
  ...normalizeParams(params)
5819
6063
  });
5820
6064
  }
6065
+ /* @__NO_SIDE_EFFECTS__ */
5821
6066
  function _e164(Class, params) {
5822
6067
  return new Class({
5823
6068
  type: "string",
@@ -5827,6 +6072,7 @@ function _e164(Class, params) {
5827
6072
  ...normalizeParams(params)
5828
6073
  });
5829
6074
  }
6075
+ /* @__NO_SIDE_EFFECTS__ */
5830
6076
  function _jwt(Class, params) {
5831
6077
  return new Class({
5832
6078
  type: "string",
@@ -5836,6 +6082,7 @@ function _jwt(Class, params) {
5836
6082
  ...normalizeParams(params)
5837
6083
  });
5838
6084
  }
6085
+ /* @__NO_SIDE_EFFECTS__ */
5839
6086
  function _isoDateTime(Class, params) {
5840
6087
  return new Class({
5841
6088
  type: "string",
@@ -5847,6 +6094,7 @@ function _isoDateTime(Class, params) {
5847
6094
  ...normalizeParams(params)
5848
6095
  });
5849
6096
  }
6097
+ /* @__NO_SIDE_EFFECTS__ */
5850
6098
  function _isoDate(Class, params) {
5851
6099
  return new Class({
5852
6100
  type: "string",
@@ -5855,6 +6103,7 @@ function _isoDate(Class, params) {
5855
6103
  ...normalizeParams(params)
5856
6104
  });
5857
6105
  }
6106
+ /* @__NO_SIDE_EFFECTS__ */
5858
6107
  function _isoTime(Class, params) {
5859
6108
  return new Class({
5860
6109
  type: "string",
@@ -5864,6 +6113,7 @@ function _isoTime(Class, params) {
5864
6113
  ...normalizeParams(params)
5865
6114
  });
5866
6115
  }
6116
+ /* @__NO_SIDE_EFFECTS__ */
5867
6117
  function _isoDuration(Class, params) {
5868
6118
  return new Class({
5869
6119
  type: "string",
@@ -5872,6 +6122,7 @@ function _isoDuration(Class, params) {
5872
6122
  ...normalizeParams(params)
5873
6123
  });
5874
6124
  }
6125
+ /* @__NO_SIDE_EFFECTS__ */
5875
6126
  function _number(Class, params) {
5876
6127
  return new Class({
5877
6128
  type: "number",
@@ -5879,6 +6130,7 @@ function _number(Class, params) {
5879
6130
  ...normalizeParams(params)
5880
6131
  });
5881
6132
  }
6133
+ /* @__NO_SIDE_EFFECTS__ */
5882
6134
  function _int(Class, params) {
5883
6135
  return new Class({
5884
6136
  type: "number",
@@ -5888,27 +6140,32 @@ function _int(Class, params) {
5888
6140
  ...normalizeParams(params)
5889
6141
  });
5890
6142
  }
6143
+ /* @__NO_SIDE_EFFECTS__ */
5891
6144
  function _boolean(Class, params) {
5892
6145
  return new Class({
5893
6146
  type: "boolean",
5894
6147
  ...normalizeParams(params)
5895
6148
  });
5896
6149
  }
6150
+ /* @__NO_SIDE_EFFECTS__ */
5897
6151
  function _null$1(Class, params) {
5898
6152
  return new Class({
5899
6153
  type: "null",
5900
6154
  ...normalizeParams(params)
5901
6155
  });
5902
6156
  }
6157
+ /* @__NO_SIDE_EFFECTS__ */
5903
6158
  function _unknown(Class) {
5904
6159
  return new Class({ type: "unknown" });
5905
6160
  }
6161
+ /* @__NO_SIDE_EFFECTS__ */
5906
6162
  function _never(Class, params) {
5907
6163
  return new Class({
5908
6164
  type: "never",
5909
6165
  ...normalizeParams(params)
5910
6166
  });
5911
6167
  }
6168
+ /* @__NO_SIDE_EFFECTS__ */
5912
6169
  function _lt(value, params) {
5913
6170
  return new $ZodCheckLessThan({
5914
6171
  check: "less_than",
@@ -5917,6 +6174,7 @@ function _lt(value, params) {
5917
6174
  inclusive: false
5918
6175
  });
5919
6176
  }
6177
+ /* @__NO_SIDE_EFFECTS__ */
5920
6178
  function _lte(value, params) {
5921
6179
  return new $ZodCheckLessThan({
5922
6180
  check: "less_than",
@@ -5925,6 +6183,7 @@ function _lte(value, params) {
5925
6183
  inclusive: true
5926
6184
  });
5927
6185
  }
6186
+ /* @__NO_SIDE_EFFECTS__ */
5928
6187
  function _gt(value, params) {
5929
6188
  return new $ZodCheckGreaterThan({
5930
6189
  check: "greater_than",
@@ -5933,6 +6192,7 @@ function _gt(value, params) {
5933
6192
  inclusive: false
5934
6193
  });
5935
6194
  }
6195
+ /* @__NO_SIDE_EFFECTS__ */
5936
6196
  function _gte(value, params) {
5937
6197
  return new $ZodCheckGreaterThan({
5938
6198
  check: "greater_than",
@@ -5941,6 +6201,7 @@ function _gte(value, params) {
5941
6201
  inclusive: true
5942
6202
  });
5943
6203
  }
6204
+ /* @__NO_SIDE_EFFECTS__ */
5944
6205
  function _multipleOf(value, params) {
5945
6206
  return new $ZodCheckMultipleOf({
5946
6207
  check: "multiple_of",
@@ -5948,6 +6209,7 @@ function _multipleOf(value, params) {
5948
6209
  value
5949
6210
  });
5950
6211
  }
6212
+ /* @__NO_SIDE_EFFECTS__ */
5951
6213
  function _maxLength(maximum, params) {
5952
6214
  return new $ZodCheckMaxLength({
5953
6215
  check: "max_length",
@@ -5955,6 +6217,7 @@ function _maxLength(maximum, params) {
5955
6217
  maximum
5956
6218
  });
5957
6219
  }
6220
+ /* @__NO_SIDE_EFFECTS__ */
5958
6221
  function _minLength(minimum, params) {
5959
6222
  return new $ZodCheckMinLength({
5960
6223
  check: "min_length",
@@ -5962,6 +6225,7 @@ function _minLength(minimum, params) {
5962
6225
  minimum
5963
6226
  });
5964
6227
  }
6228
+ /* @__NO_SIDE_EFFECTS__ */
5965
6229
  function _length(length, params) {
5966
6230
  return new $ZodCheckLengthEquals({
5967
6231
  check: "length_equals",
@@ -5969,6 +6233,7 @@ function _length(length, params) {
5969
6233
  length
5970
6234
  });
5971
6235
  }
6236
+ /* @__NO_SIDE_EFFECTS__ */
5972
6237
  function _regex(pattern, params) {
5973
6238
  return new $ZodCheckRegex({
5974
6239
  check: "string_format",
@@ -5977,6 +6242,7 @@ function _regex(pattern, params) {
5977
6242
  pattern
5978
6243
  });
5979
6244
  }
6245
+ /* @__NO_SIDE_EFFECTS__ */
5980
6246
  function _lowercase(params) {
5981
6247
  return new $ZodCheckLowerCase({
5982
6248
  check: "string_format",
@@ -5984,6 +6250,7 @@ function _lowercase(params) {
5984
6250
  ...normalizeParams(params)
5985
6251
  });
5986
6252
  }
6253
+ /* @__NO_SIDE_EFFECTS__ */
5987
6254
  function _uppercase(params) {
5988
6255
  return new $ZodCheckUpperCase({
5989
6256
  check: "string_format",
@@ -5991,6 +6258,7 @@ function _uppercase(params) {
5991
6258
  ...normalizeParams(params)
5992
6259
  });
5993
6260
  }
6261
+ /* @__NO_SIDE_EFFECTS__ */
5994
6262
  function _includes(includes, params) {
5995
6263
  return new $ZodCheckIncludes({
5996
6264
  check: "string_format",
@@ -5999,6 +6267,7 @@ function _includes(includes, params) {
5999
6267
  includes
6000
6268
  });
6001
6269
  }
6270
+ /* @__NO_SIDE_EFFECTS__ */
6002
6271
  function _startsWith(prefix, params) {
6003
6272
  return new $ZodCheckStartsWith({
6004
6273
  check: "string_format",
@@ -6007,6 +6276,7 @@ function _startsWith(prefix, params) {
6007
6276
  prefix
6008
6277
  });
6009
6278
  }
6279
+ /* @__NO_SIDE_EFFECTS__ */
6010
6280
  function _endsWith(suffix, params) {
6011
6281
  return new $ZodCheckEndsWith({
6012
6282
  check: "string_format",
@@ -6015,24 +6285,34 @@ function _endsWith(suffix, params) {
6015
6285
  suffix
6016
6286
  });
6017
6287
  }
6288
+ /* @__NO_SIDE_EFFECTS__ */
6018
6289
  function _overwrite(tx) {
6019
6290
  return new $ZodCheckOverwrite({
6020
6291
  check: "overwrite",
6021
6292
  tx
6022
6293
  });
6023
6294
  }
6295
+ /* @__NO_SIDE_EFFECTS__ */
6024
6296
  function _normalize(form) {
6025
- return _overwrite((input) => input.normalize(form));
6297
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
6026
6298
  }
6299
+ /* @__NO_SIDE_EFFECTS__ */
6027
6300
  function _trim() {
6028
- return _overwrite((input) => input.trim());
6301
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
6029
6302
  }
6303
+ /* @__NO_SIDE_EFFECTS__ */
6030
6304
  function _toLowerCase() {
6031
- return _overwrite((input) => input.toLowerCase());
6305
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
6032
6306
  }
6307
+ /* @__NO_SIDE_EFFECTS__ */
6033
6308
  function _toUpperCase() {
6034
- return _overwrite((input) => input.toUpperCase());
6309
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
6310
+ }
6311
+ /* @__NO_SIDE_EFFECTS__ */
6312
+ function _slugify() {
6313
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
6035
6314
  }
6315
+ /* @__NO_SIDE_EFFECTS__ */
6036
6316
  function _array(Class, element, params) {
6037
6317
  return new Class({
6038
6318
  type: "array",
@@ -6040,6 +6320,7 @@ function _array(Class, element, params) {
6040
6320
  ...normalizeParams(params)
6041
6321
  });
6042
6322
  }
6323
+ /* @__NO_SIDE_EFFECTS__ */
6043
6324
  function _custom(Class, fn, _params) {
6044
6325
  const norm = normalizeParams(_params);
6045
6326
  norm.abort ?? (norm.abort = true);
@@ -6050,6 +6331,7 @@ function _custom(Class, fn, _params) {
6050
6331
  ...norm
6051
6332
  });
6052
6333
  }
6334
+ /* @__NO_SIDE_EFFECTS__ */
6053
6335
  function _refine(Class, fn, _params) {
6054
6336
  return new Class({
6055
6337
  type: "custom",
@@ -6058,599 +6340,802 @@ function _refine(Class, fn, _params) {
6058
6340
  ...normalizeParams(_params)
6059
6341
  });
6060
6342
  }
6061
-
6062
- //#endregion
6063
- //#region node_modules/zod/v4/core/to-json-schema.js
6064
- var JSONSchemaGenerator = class {
6065
- constructor(params) {
6066
- this.counter = 0;
6067
- this.metadataRegistry = params?.metadata ?? globalRegistry;
6068
- this.target = params?.target ?? "draft-2020-12";
6069
- this.unrepresentable = params?.unrepresentable ?? "throw";
6070
- this.override = params?.override ?? (() => {});
6071
- this.io = params?.io ?? "output";
6072
- this.seen = /* @__PURE__ */ new Map();
6073
- }
6074
- process(schema, _params = {
6075
- path: [],
6076
- schemaPath: []
6077
- }) {
6078
- var _a;
6079
- const def = schema._zod.def;
6080
- const formatMap = {
6081
- guid: "uuid",
6082
- url: "uri",
6083
- datetime: "date-time",
6084
- json_string: "json-string",
6085
- regex: ""
6086
- };
6087
- const seen = this.seen.get(schema);
6088
- if (seen) {
6089
- seen.count++;
6090
- if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
6091
- return seen.schema;
6092
- }
6093
- const result = {
6094
- schema: {},
6095
- count: 1,
6096
- cycle: void 0,
6097
- path: _params.path
6098
- };
6099
- this.seen.set(schema, result);
6100
- const overrideSchema = schema._zod.toJSONSchema?.();
6101
- if (overrideSchema) result.schema = overrideSchema;
6102
- else {
6103
- const params = {
6104
- ..._params,
6105
- schemaPath: [..._params.schemaPath, schema],
6106
- path: _params.path
6107
- };
6108
- const parent = schema._zod.parent;
6109
- if (parent) {
6110
- result.ref = parent;
6111
- this.process(parent, params);
6112
- this.seen.get(parent).isParent = true;
6113
- } else {
6114
- const _json = result.schema;
6115
- switch (def.type) {
6116
- case "string": {
6117
- const json = _json;
6118
- json.type = "string";
6119
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
6120
- if (typeof minimum === "number") json.minLength = minimum;
6121
- if (typeof maximum === "number") json.maxLength = maximum;
6122
- if (format) {
6123
- json.format = formatMap[format] ?? format;
6124
- if (json.format === "") delete json.format;
6125
- }
6126
- if (contentEncoding) json.contentEncoding = contentEncoding;
6127
- if (patterns && patterns.size > 0) {
6128
- const regexes = [...patterns];
6129
- if (regexes.length === 1) json.pattern = regexes[0].source;
6130
- else if (regexes.length > 1) result.schema.allOf = [...regexes.map((regex) => ({
6131
- ...this.target === "draft-7" ? { type: "string" } : {},
6132
- pattern: regex.source
6133
- }))];
6134
- }
6135
- break;
6136
- }
6137
- case "number": {
6138
- const json = _json;
6139
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
6140
- if (typeof format === "string" && format.includes("int")) json.type = "integer";
6141
- else json.type = "number";
6142
- if (typeof exclusiveMinimum === "number") json.exclusiveMinimum = exclusiveMinimum;
6143
- if (typeof minimum === "number") {
6144
- json.minimum = minimum;
6145
- if (typeof exclusiveMinimum === "number") if (exclusiveMinimum >= minimum) delete json.minimum;
6146
- else delete json.exclusiveMinimum;
6147
- }
6148
- if (typeof exclusiveMaximum === "number") json.exclusiveMaximum = exclusiveMaximum;
6149
- if (typeof maximum === "number") {
6150
- json.maximum = maximum;
6151
- if (typeof exclusiveMaximum === "number") if (exclusiveMaximum <= maximum) delete json.maximum;
6152
- else delete json.exclusiveMaximum;
6153
- }
6154
- if (typeof multipleOf === "number") json.multipleOf = multipleOf;
6155
- break;
6156
- }
6157
- case "boolean": {
6158
- const json = _json;
6159
- json.type = "boolean";
6160
- break;
6161
- }
6162
- case "bigint":
6163
- if (this.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
6164
- break;
6165
- case "symbol":
6166
- if (this.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
6167
- break;
6168
- case "null":
6169
- _json.type = "null";
6170
- break;
6171
- case "any": break;
6172
- case "unknown": break;
6173
- case "undefined":
6174
- if (this.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
6175
- break;
6176
- case "void":
6177
- if (this.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
6178
- break;
6179
- case "never":
6180
- _json.not = {};
6181
- break;
6182
- case "date":
6183
- if (this.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
6184
- break;
6185
- case "array": {
6186
- const json = _json;
6187
- const { minimum, maximum } = schema._zod.bag;
6188
- if (typeof minimum === "number") json.minItems = minimum;
6189
- if (typeof maximum === "number") json.maxItems = maximum;
6190
- json.type = "array";
6191
- json.items = this.process(def.element, {
6192
- ...params,
6193
- path: [...params.path, "items"]
6194
- });
6195
- break;
6196
- }
6197
- case "object": {
6198
- const json = _json;
6199
- json.type = "object";
6200
- json.properties = {};
6201
- const shape = def.shape;
6202
- for (const key in shape) json.properties[key] = this.process(shape[key], {
6203
- ...params,
6204
- path: [
6205
- ...params.path,
6206
- "properties",
6207
- key
6208
- ]
6209
- });
6210
- const allKeys = new Set(Object.keys(shape));
6211
- const requiredKeys = new Set([...allKeys].filter((key) => {
6212
- const v = def.shape[key]._zod;
6213
- if (this.io === "input") return v.optin === void 0;
6214
- else return v.optout === void 0;
6215
- }));
6216
- if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
6217
- if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
6218
- else if (!def.catchall) {
6219
- if (this.io === "output") json.additionalProperties = false;
6220
- } else if (def.catchall) json.additionalProperties = this.process(def.catchall, {
6221
- ...params,
6222
- path: [...params.path, "additionalProperties"]
6223
- });
6224
- break;
6225
- }
6226
- case "union": {
6227
- const json = _json;
6228
- json.anyOf = def.options.map((x, i) => this.process(x, {
6229
- ...params,
6230
- path: [
6231
- ...params.path,
6232
- "anyOf",
6233
- i
6234
- ]
6235
- }));
6236
- break;
6237
- }
6238
- case "intersection": {
6239
- const json = _json;
6240
- const a = this.process(def.left, {
6241
- ...params,
6242
- path: [
6243
- ...params.path,
6244
- "allOf",
6245
- 0
6246
- ]
6247
- });
6248
- const b = this.process(def.right, {
6249
- ...params,
6250
- path: [
6251
- ...params.path,
6252
- "allOf",
6253
- 1
6254
- ]
6255
- });
6256
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
6257
- json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
6258
- break;
6259
- }
6260
- case "tuple": {
6261
- const json = _json;
6262
- json.type = "array";
6263
- const prefixItems = def.items.map((x, i) => this.process(x, {
6264
- ...params,
6265
- path: [
6266
- ...params.path,
6267
- "prefixItems",
6268
- i
6269
- ]
6270
- }));
6271
- if (this.target === "draft-2020-12") json.prefixItems = prefixItems;
6272
- else json.items = prefixItems;
6273
- if (def.rest) {
6274
- const rest = this.process(def.rest, {
6275
- ...params,
6276
- path: [...params.path, "items"]
6277
- });
6278
- if (this.target === "draft-2020-12") json.items = rest;
6279
- else json.additionalItems = rest;
6280
- }
6281
- if (def.rest) json.items = this.process(def.rest, {
6282
- ...params,
6283
- path: [...params.path, "items"]
6284
- });
6285
- const { minimum, maximum } = schema._zod.bag;
6286
- if (typeof minimum === "number") json.minItems = minimum;
6287
- if (typeof maximum === "number") json.maxItems = maximum;
6288
- break;
6289
- }
6290
- case "record": {
6291
- const json = _json;
6292
- json.type = "object";
6293
- json.propertyNames = this.process(def.keyType, {
6294
- ...params,
6295
- path: [...params.path, "propertyNames"]
6296
- });
6297
- json.additionalProperties = this.process(def.valueType, {
6298
- ...params,
6299
- path: [...params.path, "additionalProperties"]
6300
- });
6301
- break;
6302
- }
6303
- case "map":
6304
- if (this.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
6305
- break;
6306
- case "set":
6307
- if (this.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
6308
- break;
6309
- case "enum": {
6310
- const json = _json;
6311
- const values = getEnumValues(def.entries);
6312
- if (values.every((v) => typeof v === "number")) json.type = "number";
6313
- if (values.every((v) => typeof v === "string")) json.type = "string";
6314
- json.enum = values;
6315
- break;
6316
- }
6317
- case "literal": {
6318
- const json = _json;
6319
- const vals = [];
6320
- for (const val of def.values) if (val === void 0) {
6321
- if (this.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
6322
- } else if (typeof val === "bigint") if (this.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
6323
- else vals.push(Number(val));
6324
- else vals.push(val);
6325
- if (vals.length === 0) {} else if (vals.length === 1) {
6326
- const val = vals[0];
6327
- json.type = val === null ? "null" : typeof val;
6328
- json.const = val;
6329
- } else {
6330
- if (vals.every((v) => typeof v === "number")) json.type = "number";
6331
- if (vals.every((v) => typeof v === "string")) json.type = "string";
6332
- if (vals.every((v) => typeof v === "boolean")) json.type = "string";
6333
- if (vals.every((v) => v === null)) json.type = "null";
6334
- json.enum = vals;
6335
- }
6336
- break;
6337
- }
6338
- case "file": {
6339
- const json = _json;
6340
- const file = {
6341
- type: "string",
6342
- format: "binary",
6343
- contentEncoding: "binary"
6344
- };
6345
- const { minimum, maximum, mime } = schema._zod.bag;
6346
- if (minimum !== void 0) file.minLength = minimum;
6347
- if (maximum !== void 0) file.maxLength = maximum;
6348
- if (mime) if (mime.length === 1) {
6349
- file.contentMediaType = mime[0];
6350
- Object.assign(json, file);
6351
- } else json.anyOf = mime.map((m) => {
6352
- return {
6353
- ...file,
6354
- contentMediaType: m
6355
- };
6356
- });
6357
- else Object.assign(json, file);
6358
- break;
6359
- }
6360
- case "transform":
6361
- if (this.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
6362
- break;
6363
- case "nullable":
6364
- _json.anyOf = [this.process(def.innerType, params), { type: "null" }];
6365
- break;
6366
- case "nonoptional":
6367
- this.process(def.innerType, params);
6368
- result.ref = def.innerType;
6369
- break;
6370
- case "success": {
6371
- const json = _json;
6372
- json.type = "boolean";
6373
- break;
6374
- }
6375
- case "default":
6376
- this.process(def.innerType, params);
6377
- result.ref = def.innerType;
6378
- _json.default = JSON.parse(JSON.stringify(def.defaultValue));
6379
- break;
6380
- case "prefault":
6381
- this.process(def.innerType, params);
6382
- result.ref = def.innerType;
6383
- if (this.io === "input") _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
6384
- break;
6385
- case "catch": {
6386
- this.process(def.innerType, params);
6387
- result.ref = def.innerType;
6388
- let catchValue;
6389
- try {
6390
- catchValue = def.catchValue(void 0);
6391
- } catch {
6392
- throw new Error("Dynamic catch values are not supported in JSON Schema");
6393
- }
6394
- _json.default = catchValue;
6395
- break;
6396
- }
6397
- case "nan":
6398
- if (this.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
6399
- break;
6400
- case "template_literal": {
6401
- const json = _json;
6402
- const pattern = schema._zod.pattern;
6403
- if (!pattern) throw new Error("Pattern not found in template literal");
6404
- json.type = "string";
6405
- json.pattern = pattern.source;
6406
- break;
6407
- }
6408
- case "pipe": {
6409
- const innerType = this.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
6410
- this.process(innerType, params);
6411
- result.ref = innerType;
6412
- break;
6413
- }
6414
- case "readonly":
6415
- this.process(def.innerType, params);
6416
- result.ref = def.innerType;
6417
- _json.readOnly = true;
6418
- break;
6419
- case "promise":
6420
- this.process(def.innerType, params);
6421
- result.ref = def.innerType;
6422
- break;
6423
- case "optional":
6424
- this.process(def.innerType, params);
6425
- result.ref = def.innerType;
6426
- break;
6427
- case "lazy": {
6428
- const innerType = schema._zod.innerType;
6429
- this.process(innerType, params);
6430
- result.ref = innerType;
6431
- break;
6432
- }
6433
- case "custom":
6434
- if (this.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
6435
- break;
6436
- default:
6437
- }
6343
+ /* @__NO_SIDE_EFFECTS__ */
6344
+ function _superRefine(fn) {
6345
+ const ch = /* @__PURE__ */ _check((payload) => {
6346
+ payload.addIssue = (issue$2) => {
6347
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
6348
+ else {
6349
+ const _issue = issue$2;
6350
+ if (_issue.fatal) _issue.continue = false;
6351
+ _issue.code ?? (_issue.code = "custom");
6352
+ _issue.input ?? (_issue.input = payload.value);
6353
+ _issue.inst ?? (_issue.inst = ch);
6354
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
6355
+ payload.issues.push(issue(_issue));
6438
6356
  }
6439
- }
6440
- const meta = this.metadataRegistry.get(schema);
6441
- if (meta) Object.assign(result.schema, meta);
6442
- if (this.io === "input" && isTransforming(schema)) {
6443
- delete result.schema.examples;
6444
- delete result.schema.default;
6445
- }
6446
- if (this.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
6447
- delete result.schema._prefault;
6448
- return this.seen.get(schema).schema;
6357
+ };
6358
+ return fn(payload.value, payload);
6359
+ });
6360
+ return ch;
6361
+ }
6362
+ /* @__NO_SIDE_EFFECTS__ */
6363
+ function _check(fn, params) {
6364
+ const ch = new $ZodCheck({
6365
+ check: "custom",
6366
+ ...normalizeParams(params)
6367
+ });
6368
+ ch._zod.check = fn;
6369
+ return ch;
6370
+ }
6371
+ /* @__NO_SIDE_EFFECTS__ */
6372
+ function describe$2(description) {
6373
+ const ch = new $ZodCheck({ check: "describe" });
6374
+ ch._zod.onattach = [(inst) => {
6375
+ const existing = globalRegistry.get(inst) ?? {};
6376
+ globalRegistry.add(inst, {
6377
+ ...existing,
6378
+ description
6379
+ });
6380
+ }];
6381
+ ch._zod.check = () => {};
6382
+ return ch;
6383
+ }
6384
+ /* @__NO_SIDE_EFFECTS__ */
6385
+ function meta$2(metadata) {
6386
+ const ch = new $ZodCheck({ check: "meta" });
6387
+ ch._zod.onattach = [(inst) => {
6388
+ const existing = globalRegistry.get(inst) ?? {};
6389
+ globalRegistry.add(inst, {
6390
+ ...existing,
6391
+ ...metadata
6392
+ });
6393
+ }];
6394
+ ch._zod.check = () => {};
6395
+ return ch;
6396
+ }
6397
+
6398
+ //#endregion
6399
+ //#region node_modules/zod/v4/core/to-json-schema.js
6400
+ function initializeContext(params) {
6401
+ let target = params?.target ?? "draft-2020-12";
6402
+ if (target === "draft-4") target = "draft-04";
6403
+ if (target === "draft-7") target = "draft-07";
6404
+ return {
6405
+ processors: params.processors ?? {},
6406
+ metadataRegistry: params?.metadata ?? globalRegistry,
6407
+ target,
6408
+ unrepresentable: params?.unrepresentable ?? "throw",
6409
+ override: params?.override ?? (() => {}),
6410
+ io: params?.io ?? "output",
6411
+ counter: 0,
6412
+ seen: /* @__PURE__ */ new Map(),
6413
+ cycles: params?.cycles ?? "ref",
6414
+ reused: params?.reused ?? "inline",
6415
+ external: params?.external ?? void 0
6416
+ };
6417
+ }
6418
+ function process$2(schema, ctx, _params = {
6419
+ path: [],
6420
+ schemaPath: []
6421
+ }) {
6422
+ var _a;
6423
+ const def = schema._zod.def;
6424
+ const seen = ctx.seen.get(schema);
6425
+ if (seen) {
6426
+ seen.count++;
6427
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
6428
+ return seen.schema;
6449
6429
  }
6450
- emit(schema, _params) {
6430
+ const result = {
6431
+ schema: {},
6432
+ count: 1,
6433
+ cycle: void 0,
6434
+ path: _params.path
6435
+ };
6436
+ ctx.seen.set(schema, result);
6437
+ const overrideSchema = schema._zod.toJSONSchema?.();
6438
+ if (overrideSchema) result.schema = overrideSchema;
6439
+ else {
6451
6440
  const params = {
6452
- cycles: _params?.cycles ?? "ref",
6453
- reused: _params?.reused ?? "inline",
6454
- external: _params?.external ?? void 0
6441
+ ..._params,
6442
+ schemaPath: [..._params.schemaPath, schema],
6443
+ path: _params.path
6455
6444
  };
6456
- const root = this.seen.get(schema);
6457
- if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
6458
- const makeURI = (entry) => {
6459
- const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
6460
- if (params.external) {
6461
- const externalId = params.external.registry.get(entry[0])?.id;
6462
- const uriGenerator = params.external.uri ?? ((id) => id);
6463
- if (externalId) return { ref: uriGenerator(externalId) };
6464
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
6465
- entry[1].defId = id;
6466
- return {
6467
- defId: id,
6468
- ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
6469
- };
6470
- }
6471
- if (entry[1] === root) return { ref: "#" };
6472
- const defUriPrefix = `#/${defsSegment}/`;
6473
- const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
6445
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
6446
+ else {
6447
+ const _json = result.schema;
6448
+ const processor = ctx.processors[def.type];
6449
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
6450
+ processor(schema, ctx, _json, params);
6451
+ }
6452
+ const parent = schema._zod.parent;
6453
+ if (parent) {
6454
+ if (!result.ref) result.ref = parent;
6455
+ process$2(parent, ctx, params);
6456
+ ctx.seen.get(parent).isParent = true;
6457
+ }
6458
+ }
6459
+ const meta = ctx.metadataRegistry.get(schema);
6460
+ if (meta) Object.assign(result.schema, meta);
6461
+ if (ctx.io === "input" && isTransforming(schema)) {
6462
+ delete result.schema.examples;
6463
+ delete result.schema.default;
6464
+ }
6465
+ if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
6466
+ delete result.schema._prefault;
6467
+ return ctx.seen.get(schema).schema;
6468
+ }
6469
+ function extractDefs(ctx, schema) {
6470
+ const root = ctx.seen.get(schema);
6471
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
6472
+ const idToSchema = /* @__PURE__ */ new Map();
6473
+ for (const entry of ctx.seen.entries()) {
6474
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
6475
+ if (id) {
6476
+ const existing = idToSchema.get(id);
6477
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
6478
+ idToSchema.set(id, entry[0]);
6479
+ }
6480
+ }
6481
+ const makeURI = (entry) => {
6482
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
6483
+ if (ctx.external) {
6484
+ const externalId = ctx.external.registry.get(entry[0])?.id;
6485
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
6486
+ if (externalId) return { ref: uriGenerator(externalId) };
6487
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
6488
+ entry[1].defId = id;
6474
6489
  return {
6475
- defId,
6476
- ref: defUriPrefix + defId
6490
+ defId: id,
6491
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
6477
6492
  };
6493
+ }
6494
+ if (entry[1] === root) return { ref: "#" };
6495
+ const defUriPrefix = `#/${defsSegment}/`;
6496
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
6497
+ return {
6498
+ defId,
6499
+ ref: defUriPrefix + defId
6478
6500
  };
6479
- const extractToDef = (entry) => {
6480
- if (entry[1].schema.$ref) return;
6481
- const seen = entry[1];
6482
- const { ref, defId } = makeURI(entry);
6483
- seen.def = { ...seen.schema };
6484
- if (defId) seen.defId = defId;
6485
- const schema = seen.schema;
6486
- for (const key in schema) delete schema[key];
6487
- schema.$ref = ref;
6488
- };
6489
- if (params.cycles === "throw") for (const entry of this.seen.entries()) {
6490
- const seen = entry[1];
6491
- if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
6501
+ };
6502
+ const extractToDef = (entry) => {
6503
+ if (entry[1].schema.$ref) return;
6504
+ const seen = entry[1];
6505
+ const { ref, defId } = makeURI(entry);
6506
+ seen.def = { ...seen.schema };
6507
+ if (defId) seen.defId = defId;
6508
+ const schema = seen.schema;
6509
+ for (const key in schema) delete schema[key];
6510
+ schema.$ref = ref;
6511
+ };
6512
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
6513
+ const seen = entry[1];
6514
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
6492
6515
 
6493
6516
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
6517
+ }
6518
+ for (const entry of ctx.seen.entries()) {
6519
+ const seen = entry[1];
6520
+ if (schema === entry[0]) {
6521
+ extractToDef(entry);
6522
+ continue;
6494
6523
  }
6495
- for (const entry of this.seen.entries()) {
6496
- const seen = entry[1];
6497
- if (schema === entry[0]) {
6524
+ if (ctx.external) {
6525
+ const ext = ctx.external.registry.get(entry[0])?.id;
6526
+ if (schema !== entry[0] && ext) {
6498
6527
  extractToDef(entry);
6499
6528
  continue;
6500
6529
  }
6501
- if (params.external) {
6502
- const ext = params.external.registry.get(entry[0])?.id;
6503
- if (schema !== entry[0] && ext) {
6504
- extractToDef(entry);
6505
- continue;
6506
- }
6507
- }
6508
- if (this.metadataRegistry.get(entry[0])?.id) {
6509
- extractToDef(entry);
6510
- continue;
6511
- }
6512
- if (seen.cycle) {
6530
+ }
6531
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
6532
+ extractToDef(entry);
6533
+ continue;
6534
+ }
6535
+ if (seen.cycle) {
6536
+ extractToDef(entry);
6537
+ continue;
6538
+ }
6539
+ if (seen.count > 1) {
6540
+ if (ctx.reused === "ref") {
6513
6541
  extractToDef(entry);
6514
6542
  continue;
6515
6543
  }
6516
- if (seen.count > 1) {
6517
- if (params.reused === "ref") {
6518
- extractToDef(entry);
6519
- continue;
6520
- }
6521
- }
6522
6544
  }
6523
- const flattenRef = (zodSchema, params) => {
6524
- const seen = this.seen.get(zodSchema);
6525
- const schema = seen.def ?? seen.schema;
6526
- const _cached = { ...schema };
6527
- if (seen.ref === null) return;
6528
- const ref = seen.ref;
6529
- seen.ref = null;
6530
- if (ref) {
6531
- flattenRef(ref, params);
6532
- const refSchema = this.seen.get(ref).schema;
6533
- if (refSchema.$ref && params.target === "draft-7") {
6534
- schema.allOf = schema.allOf ?? [];
6535
- schema.allOf.push(refSchema);
6536
- } else {
6537
- Object.assign(schema, refSchema);
6538
- Object.assign(schema, _cached);
6545
+ }
6546
+ }
6547
+ function finalize(ctx, schema) {
6548
+ const root = ctx.seen.get(schema);
6549
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
6550
+ const flattenRef = (zodSchema) => {
6551
+ const seen = ctx.seen.get(zodSchema);
6552
+ if (seen.ref === null) return;
6553
+ const schema = seen.def ?? seen.schema;
6554
+ const _cached = { ...schema };
6555
+ const ref = seen.ref;
6556
+ seen.ref = null;
6557
+ if (ref) {
6558
+ flattenRef(ref);
6559
+ const refSeen = ctx.seen.get(ref);
6560
+ const refSchema = refSeen.schema;
6561
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
6562
+ schema.allOf = schema.allOf ?? [];
6563
+ schema.allOf.push(refSchema);
6564
+ } else Object.assign(schema, refSchema);
6565
+ Object.assign(schema, _cached);
6566
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
6567
+ if (key === "$ref" || key === "allOf") continue;
6568
+ if (!(key in _cached)) delete schema[key];
6569
+ }
6570
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
6571
+ if (key === "$ref" || key === "allOf") continue;
6572
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
6573
+ }
6574
+ }
6575
+ const parent = zodSchema._zod.parent;
6576
+ if (parent && parent !== ref) {
6577
+ flattenRef(parent);
6578
+ const parentSeen = ctx.seen.get(parent);
6579
+ if (parentSeen?.schema.$ref) {
6580
+ schema.$ref = parentSeen.schema.$ref;
6581
+ if (parentSeen.def) for (const key in schema) {
6582
+ if (key === "$ref" || key === "allOf") continue;
6583
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
6539
6584
  }
6540
6585
  }
6541
- if (!seen.isParent) this.override({
6542
- zodSchema,
6543
- jsonSchema: schema,
6544
- path: seen.path ?? []
6545
- });
6546
- };
6547
- for (const entry of [...this.seen.entries()].reverse()) flattenRef(entry[0], { target: this.target });
6548
- const result = {};
6549
- if (this.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
6550
- else if (this.target === "draft-7") result.$schema = "http://json-schema.org/draft-07/schema#";
6551
- else console.warn(`Invalid target: ${this.target}`);
6552
- if (params.external?.uri) {
6553
- const id = params.external.registry.get(schema)?.id;
6554
- if (!id) throw new Error("Schema is missing an `id` property");
6555
- result.$id = params.external.uri(id);
6556
- }
6557
- Object.assign(result, root.def);
6558
- const defs = params.external?.defs ?? {};
6559
- for (const entry of this.seen.entries()) {
6560
- const seen = entry[1];
6561
- if (seen.def && seen.defId) defs[seen.defId] = seen.def;
6562
- }
6563
- if (params.external) {} else if (Object.keys(defs).length > 0) if (this.target === "draft-2020-12") result.$defs = defs;
6564
- else result.definitions = defs;
6565
- try {
6566
- return JSON.parse(JSON.stringify(result));
6567
- } catch (_err) {
6568
- throw new Error("Error converting schema to JSON.");
6569
6586
  }
6587
+ ctx.override({
6588
+ zodSchema,
6589
+ jsonSchema: schema,
6590
+ path: seen.path ?? []
6591
+ });
6592
+ };
6593
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
6594
+ const result = {};
6595
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
6596
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
6597
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
6598
+ else if (ctx.target === "openapi-3.0") {}
6599
+ if (ctx.external?.uri) {
6600
+ const id = ctx.external.registry.get(schema)?.id;
6601
+ if (!id) throw new Error("Schema is missing an `id` property");
6602
+ result.$id = ctx.external.uri(id);
6603
+ }
6604
+ Object.assign(result, root.def ?? root.schema);
6605
+ const defs = ctx.external?.defs ?? {};
6606
+ for (const entry of ctx.seen.entries()) {
6607
+ const seen = entry[1];
6608
+ if (seen.def && seen.defId) defs[seen.defId] = seen.def;
6609
+ }
6610
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
6611
+ else result.definitions = defs;
6612
+ try {
6613
+ const finalized = JSON.parse(JSON.stringify(result));
6614
+ Object.defineProperty(finalized, "~standard", {
6615
+ value: {
6616
+ ...schema["~standard"],
6617
+ jsonSchema: {
6618
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
6619
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
6620
+ }
6621
+ },
6622
+ enumerable: false,
6623
+ writable: false
6624
+ });
6625
+ return finalized;
6626
+ } catch (_err) {
6627
+ throw new Error("Error converting schema to JSON.");
6628
+ }
6629
+ }
6630
+ function isTransforming(_schema, _ctx) {
6631
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
6632
+ if (ctx.seen.has(_schema)) return false;
6633
+ ctx.seen.add(_schema);
6634
+ const def = _schema._zod.def;
6635
+ if (def.type === "transform") return true;
6636
+ if (def.type === "array") return isTransforming(def.element, ctx);
6637
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
6638
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
6639
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
6640
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
6641
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
6642
+ if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
6643
+ if (def.type === "object") {
6644
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
6645
+ return false;
6646
+ }
6647
+ if (def.type === "union") {
6648
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
6649
+ return false;
6650
+ }
6651
+ if (def.type === "tuple") {
6652
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
6653
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
6654
+ return false;
6655
+ }
6656
+ return false;
6657
+ }
6658
+ /**
6659
+ * Creates a toJSONSchema method for a schema instance.
6660
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
6661
+ */
6662
+ const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
6663
+ const ctx = initializeContext({
6664
+ ...params,
6665
+ processors
6666
+ });
6667
+ process$2(schema, ctx);
6668
+ extractDefs(ctx, schema);
6669
+ return finalize(ctx, schema);
6670
+ };
6671
+ const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
6672
+ const { libraryOptions, target } = params ?? {};
6673
+ const ctx = initializeContext({
6674
+ ...libraryOptions ?? {},
6675
+ target,
6676
+ io,
6677
+ processors
6678
+ });
6679
+ process$2(schema, ctx);
6680
+ extractDefs(ctx, schema);
6681
+ return finalize(ctx, schema);
6682
+ };
6683
+
6684
+ //#endregion
6685
+ //#region node_modules/zod/v4/core/json-schema-processors.js
6686
+ const formatMap = {
6687
+ guid: "uuid",
6688
+ url: "uri",
6689
+ datetime: "date-time",
6690
+ json_string: "json-string",
6691
+ regex: ""
6692
+ };
6693
+ const stringProcessor = (schema, ctx, _json, _params) => {
6694
+ const json = _json;
6695
+ json.type = "string";
6696
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
6697
+ if (typeof minimum === "number") json.minLength = minimum;
6698
+ if (typeof maximum === "number") json.maxLength = maximum;
6699
+ if (format) {
6700
+ json.format = formatMap[format] ?? format;
6701
+ if (json.format === "") delete json.format;
6702
+ if (format === "time") delete json.format;
6703
+ }
6704
+ if (contentEncoding) json.contentEncoding = contentEncoding;
6705
+ if (patterns && patterns.size > 0) {
6706
+ const regexes = [...patterns];
6707
+ if (regexes.length === 1) json.pattern = regexes[0].source;
6708
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
6709
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
6710
+ pattern: regex.source
6711
+ }))];
6712
+ }
6713
+ };
6714
+ const numberProcessor = (schema, ctx, _json, _params) => {
6715
+ const json = _json;
6716
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
6717
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
6718
+ else json.type = "number";
6719
+ if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
6720
+ json.minimum = exclusiveMinimum;
6721
+ json.exclusiveMinimum = true;
6722
+ } else json.exclusiveMinimum = exclusiveMinimum;
6723
+ if (typeof minimum === "number") {
6724
+ json.minimum = minimum;
6725
+ if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
6726
+ else delete json.exclusiveMinimum;
6727
+ }
6728
+ if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
6729
+ json.maximum = exclusiveMaximum;
6730
+ json.exclusiveMaximum = true;
6731
+ } else json.exclusiveMaximum = exclusiveMaximum;
6732
+ if (typeof maximum === "number") {
6733
+ json.maximum = maximum;
6734
+ if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
6735
+ else delete json.exclusiveMaximum;
6736
+ }
6737
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
6738
+ };
6739
+ const booleanProcessor = (_schema, _ctx, json, _params) => {
6740
+ json.type = "boolean";
6741
+ };
6742
+ const bigintProcessor = (_schema, ctx, _json, _params) => {
6743
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
6744
+ };
6745
+ const symbolProcessor = (_schema, ctx, _json, _params) => {
6746
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
6747
+ };
6748
+ const nullProcessor = (_schema, ctx, json, _params) => {
6749
+ if (ctx.target === "openapi-3.0") {
6750
+ json.type = "string";
6751
+ json.nullable = true;
6752
+ json.enum = [null];
6753
+ } else json.type = "null";
6754
+ };
6755
+ const undefinedProcessor = (_schema, ctx, _json, _params) => {
6756
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
6757
+ };
6758
+ const voidProcessor = (_schema, ctx, _json, _params) => {
6759
+ if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
6760
+ };
6761
+ const neverProcessor = (_schema, _ctx, json, _params) => {
6762
+ json.not = {};
6763
+ };
6764
+ const anyProcessor = (_schema, _ctx, _json, _params) => {};
6765
+ const unknownProcessor = (_schema, _ctx, _json, _params) => {};
6766
+ const dateProcessor = (_schema, ctx, _json, _params) => {
6767
+ if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
6768
+ };
6769
+ const enumProcessor = (schema, _ctx, json, _params) => {
6770
+ const def = schema._zod.def;
6771
+ const values = getEnumValues(def.entries);
6772
+ if (values.every((v) => typeof v === "number")) json.type = "number";
6773
+ if (values.every((v) => typeof v === "string")) json.type = "string";
6774
+ json.enum = values;
6775
+ };
6776
+ const literalProcessor = (schema, ctx, json, _params) => {
6777
+ const def = schema._zod.def;
6778
+ const vals = [];
6779
+ for (const val of def.values) if (val === void 0) {
6780
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
6781
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
6782
+ else vals.push(Number(val));
6783
+ else vals.push(val);
6784
+ if (vals.length === 0) {} else if (vals.length === 1) {
6785
+ const val = vals[0];
6786
+ json.type = val === null ? "null" : typeof val;
6787
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
6788
+ else json.const = val;
6789
+ } else {
6790
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
6791
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
6792
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
6793
+ if (vals.every((v) => v === null)) json.type = "null";
6794
+ json.enum = vals;
6795
+ }
6796
+ };
6797
+ const nanProcessor = (_schema, ctx, _json, _params) => {
6798
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
6799
+ };
6800
+ const templateLiteralProcessor = (schema, _ctx, json, _params) => {
6801
+ const _json = json;
6802
+ const pattern = schema._zod.pattern;
6803
+ if (!pattern) throw new Error("Pattern not found in template literal");
6804
+ _json.type = "string";
6805
+ _json.pattern = pattern.source;
6806
+ };
6807
+ const fileProcessor = (schema, _ctx, json, _params) => {
6808
+ const _json = json;
6809
+ const file = {
6810
+ type: "string",
6811
+ format: "binary",
6812
+ contentEncoding: "binary"
6813
+ };
6814
+ const { minimum, maximum, mime } = schema._zod.bag;
6815
+ if (minimum !== void 0) file.minLength = minimum;
6816
+ if (maximum !== void 0) file.maxLength = maximum;
6817
+ if (mime) if (mime.length === 1) {
6818
+ file.contentMediaType = mime[0];
6819
+ Object.assign(_json, file);
6820
+ } else {
6821
+ Object.assign(_json, file);
6822
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
6823
+ }
6824
+ else Object.assign(_json, file);
6825
+ };
6826
+ const successProcessor = (_schema, _ctx, json, _params) => {
6827
+ json.type = "boolean";
6828
+ };
6829
+ const customProcessor = (_schema, ctx, _json, _params) => {
6830
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
6831
+ };
6832
+ const functionProcessor = (_schema, ctx, _json, _params) => {
6833
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
6834
+ };
6835
+ const transformProcessor = (_schema, ctx, _json, _params) => {
6836
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
6837
+ };
6838
+ const mapProcessor = (_schema, ctx, _json, _params) => {
6839
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
6840
+ };
6841
+ const setProcessor = (_schema, ctx, _json, _params) => {
6842
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
6843
+ };
6844
+ const arrayProcessor = (schema, ctx, _json, params) => {
6845
+ const json = _json;
6846
+ const def = schema._zod.def;
6847
+ const { minimum, maximum } = schema._zod.bag;
6848
+ if (typeof minimum === "number") json.minItems = minimum;
6849
+ if (typeof maximum === "number") json.maxItems = maximum;
6850
+ json.type = "array";
6851
+ json.items = process$2(def.element, ctx, {
6852
+ ...params,
6853
+ path: [...params.path, "items"]
6854
+ });
6855
+ };
6856
+ const objectProcessor = (schema, ctx, _json, params) => {
6857
+ const json = _json;
6858
+ const def = schema._zod.def;
6859
+ json.type = "object";
6860
+ json.properties = {};
6861
+ const shape = def.shape;
6862
+ for (const key in shape) json.properties[key] = process$2(shape[key], ctx, {
6863
+ ...params,
6864
+ path: [
6865
+ ...params.path,
6866
+ "properties",
6867
+ key
6868
+ ]
6869
+ });
6870
+ const allKeys = new Set(Object.keys(shape));
6871
+ const requiredKeys = new Set([...allKeys].filter((key) => {
6872
+ const v = def.shape[key]._zod;
6873
+ if (ctx.io === "input") return v.optin === void 0;
6874
+ else return v.optout === void 0;
6875
+ }));
6876
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
6877
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
6878
+ else if (!def.catchall) {
6879
+ if (ctx.io === "output") json.additionalProperties = false;
6880
+ } else if (def.catchall) json.additionalProperties = process$2(def.catchall, ctx, {
6881
+ ...params,
6882
+ path: [...params.path, "additionalProperties"]
6883
+ });
6884
+ };
6885
+ const unionProcessor = (schema, ctx, json, params) => {
6886
+ const def = schema._zod.def;
6887
+ const isExclusive = def.inclusive === false;
6888
+ const options = def.options.map((x, i) => process$2(x, ctx, {
6889
+ ...params,
6890
+ path: [
6891
+ ...params.path,
6892
+ isExclusive ? "oneOf" : "anyOf",
6893
+ i
6894
+ ]
6895
+ }));
6896
+ if (isExclusive) json.oneOf = options;
6897
+ else json.anyOf = options;
6898
+ };
6899
+ const intersectionProcessor = (schema, ctx, json, params) => {
6900
+ const def = schema._zod.def;
6901
+ const a = process$2(def.left, ctx, {
6902
+ ...params,
6903
+ path: [
6904
+ ...params.path,
6905
+ "allOf",
6906
+ 0
6907
+ ]
6908
+ });
6909
+ const b = process$2(def.right, ctx, {
6910
+ ...params,
6911
+ path: [
6912
+ ...params.path,
6913
+ "allOf",
6914
+ 1
6915
+ ]
6916
+ });
6917
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
6918
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
6919
+ };
6920
+ const tupleProcessor = (schema, ctx, _json, params) => {
6921
+ const json = _json;
6922
+ const def = schema._zod.def;
6923
+ json.type = "array";
6924
+ const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
6925
+ const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
6926
+ const prefixItems = def.items.map((x, i) => process$2(x, ctx, {
6927
+ ...params,
6928
+ path: [
6929
+ ...params.path,
6930
+ prefixPath,
6931
+ i
6932
+ ]
6933
+ }));
6934
+ const rest = def.rest ? process$2(def.rest, ctx, {
6935
+ ...params,
6936
+ path: [
6937
+ ...params.path,
6938
+ restPath,
6939
+ ...ctx.target === "openapi-3.0" ? [def.items.length] : []
6940
+ ]
6941
+ }) : null;
6942
+ if (ctx.target === "draft-2020-12") {
6943
+ json.prefixItems = prefixItems;
6944
+ if (rest) json.items = rest;
6945
+ } else if (ctx.target === "openapi-3.0") {
6946
+ json.items = { anyOf: prefixItems };
6947
+ if (rest) json.items.anyOf.push(rest);
6948
+ json.minItems = prefixItems.length;
6949
+ if (!rest) json.maxItems = prefixItems.length;
6950
+ } else {
6951
+ json.items = prefixItems;
6952
+ if (rest) json.additionalItems = rest;
6953
+ }
6954
+ const { minimum, maximum } = schema._zod.bag;
6955
+ if (typeof minimum === "number") json.minItems = minimum;
6956
+ if (typeof maximum === "number") json.maxItems = maximum;
6957
+ };
6958
+ const recordProcessor = (schema, ctx, _json, params) => {
6959
+ const json = _json;
6960
+ const def = schema._zod.def;
6961
+ json.type = "object";
6962
+ const keyType = def.keyType;
6963
+ const patterns = keyType._zod.bag?.patterns;
6964
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
6965
+ const valueSchema = process$2(def.valueType, ctx, {
6966
+ ...params,
6967
+ path: [
6968
+ ...params.path,
6969
+ "patternProperties",
6970
+ "*"
6971
+ ]
6972
+ });
6973
+ json.patternProperties = {};
6974
+ for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
6975
+ } else {
6976
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$2(def.keyType, ctx, {
6977
+ ...params,
6978
+ path: [...params.path, "propertyNames"]
6979
+ });
6980
+ json.additionalProperties = process$2(def.valueType, ctx, {
6981
+ ...params,
6982
+ path: [...params.path, "additionalProperties"]
6983
+ });
6984
+ }
6985
+ const keyValues = keyType._zod.values;
6986
+ if (keyValues) {
6987
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
6988
+ if (validKeyValues.length > 0) json.required = validKeyValues;
6989
+ }
6990
+ };
6991
+ const nullableProcessor = (schema, ctx, json, params) => {
6992
+ const def = schema._zod.def;
6993
+ const inner = process$2(def.innerType, ctx, params);
6994
+ const seen = ctx.seen.get(schema);
6995
+ if (ctx.target === "openapi-3.0") {
6996
+ seen.ref = def.innerType;
6997
+ json.nullable = true;
6998
+ } else json.anyOf = [inner, { type: "null" }];
6999
+ };
7000
+ const nonoptionalProcessor = (schema, ctx, _json, params) => {
7001
+ const def = schema._zod.def;
7002
+ process$2(def.innerType, ctx, params);
7003
+ const seen = ctx.seen.get(schema);
7004
+ seen.ref = def.innerType;
7005
+ };
7006
+ const defaultProcessor = (schema, ctx, json, params) => {
7007
+ const def = schema._zod.def;
7008
+ process$2(def.innerType, ctx, params);
7009
+ const seen = ctx.seen.get(schema);
7010
+ seen.ref = def.innerType;
7011
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
7012
+ };
7013
+ const prefaultProcessor = (schema, ctx, json, params) => {
7014
+ const def = schema._zod.def;
7015
+ process$2(def.innerType, ctx, params);
7016
+ const seen = ctx.seen.get(schema);
7017
+ seen.ref = def.innerType;
7018
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
7019
+ };
7020
+ const catchProcessor = (schema, ctx, json, params) => {
7021
+ const def = schema._zod.def;
7022
+ process$2(def.innerType, ctx, params);
7023
+ const seen = ctx.seen.get(schema);
7024
+ seen.ref = def.innerType;
7025
+ let catchValue;
7026
+ try {
7027
+ catchValue = def.catchValue(void 0);
7028
+ } catch {
7029
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
6570
7030
  }
7031
+ json.default = catchValue;
7032
+ };
7033
+ const pipeProcessor = (schema, ctx, _json, params) => {
7034
+ const def = schema._zod.def;
7035
+ const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
7036
+ process$2(innerType, ctx, params);
7037
+ const seen = ctx.seen.get(schema);
7038
+ seen.ref = innerType;
7039
+ };
7040
+ const readonlyProcessor = (schema, ctx, json, params) => {
7041
+ const def = schema._zod.def;
7042
+ process$2(def.innerType, ctx, params);
7043
+ const seen = ctx.seen.get(schema);
7044
+ seen.ref = def.innerType;
7045
+ json.readOnly = true;
7046
+ };
7047
+ const promiseProcessor = (schema, ctx, _json, params) => {
7048
+ const def = schema._zod.def;
7049
+ process$2(def.innerType, ctx, params);
7050
+ const seen = ctx.seen.get(schema);
7051
+ seen.ref = def.innerType;
7052
+ };
7053
+ const optionalProcessor = (schema, ctx, _json, params) => {
7054
+ const def = schema._zod.def;
7055
+ process$2(def.innerType, ctx, params);
7056
+ const seen = ctx.seen.get(schema);
7057
+ seen.ref = def.innerType;
7058
+ };
7059
+ const lazyProcessor = (schema, ctx, _json, params) => {
7060
+ const innerType = schema._zod.innerType;
7061
+ process$2(innerType, ctx, params);
7062
+ const seen = ctx.seen.get(schema);
7063
+ seen.ref = innerType;
7064
+ };
7065
+ const allProcessors = {
7066
+ string: stringProcessor,
7067
+ number: numberProcessor,
7068
+ boolean: booleanProcessor,
7069
+ bigint: bigintProcessor,
7070
+ symbol: symbolProcessor,
7071
+ null: nullProcessor,
7072
+ undefined: undefinedProcessor,
7073
+ void: voidProcessor,
7074
+ never: neverProcessor,
7075
+ any: anyProcessor,
7076
+ unknown: unknownProcessor,
7077
+ date: dateProcessor,
7078
+ enum: enumProcessor,
7079
+ literal: literalProcessor,
7080
+ nan: nanProcessor,
7081
+ template_literal: templateLiteralProcessor,
7082
+ file: fileProcessor,
7083
+ success: successProcessor,
7084
+ custom: customProcessor,
7085
+ function: functionProcessor,
7086
+ transform: transformProcessor,
7087
+ map: mapProcessor,
7088
+ set: setProcessor,
7089
+ array: arrayProcessor,
7090
+ object: objectProcessor,
7091
+ union: unionProcessor,
7092
+ intersection: intersectionProcessor,
7093
+ tuple: tupleProcessor,
7094
+ record: recordProcessor,
7095
+ nullable: nullableProcessor,
7096
+ nonoptional: nonoptionalProcessor,
7097
+ default: defaultProcessor,
7098
+ prefault: prefaultProcessor,
7099
+ catch: catchProcessor,
7100
+ pipe: pipeProcessor,
7101
+ readonly: readonlyProcessor,
7102
+ promise: promiseProcessor,
7103
+ optional: optionalProcessor,
7104
+ lazy: lazyProcessor
6571
7105
  };
6572
- function toJSONSchema(input, _params) {
6573
- if (input instanceof $ZodRegistry) {
6574
- const gen = new JSONSchemaGenerator(_params);
7106
+ function toJSONSchema(input, params) {
7107
+ if ("_idmap" in input) {
7108
+ const registry = input;
7109
+ const ctx = initializeContext({
7110
+ ...params,
7111
+ processors: allProcessors
7112
+ });
6575
7113
  const defs = {};
6576
- for (const entry of input._idmap.entries()) {
7114
+ for (const entry of registry._idmap.entries()) {
6577
7115
  const [_, schema] = entry;
6578
- gen.process(schema);
7116
+ process$2(schema, ctx);
6579
7117
  }
6580
7118
  const schemas = {};
6581
- const external = {
6582
- registry: input,
6583
- uri: _params?.uri,
7119
+ ctx.external = {
7120
+ registry,
7121
+ uri: params?.uri,
6584
7122
  defs
6585
7123
  };
6586
- for (const entry of input._idmap.entries()) {
7124
+ for (const entry of registry._idmap.entries()) {
6587
7125
  const [key, schema] = entry;
6588
- schemas[key] = gen.emit(schema, {
6589
- ..._params,
6590
- external
6591
- });
7126
+ extractDefs(ctx, schema);
7127
+ schemas[key] = finalize(ctx, schema);
6592
7128
  }
6593
- if (Object.keys(defs).length > 0) schemas.__shared = { [gen.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
7129
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
6594
7130
  return { schemas };
6595
7131
  }
6596
- const gen = new JSONSchemaGenerator(_params);
6597
- gen.process(input);
6598
- return gen.emit(input, _params);
6599
- }
6600
- function isTransforming(_schema, _ctx) {
6601
- const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
6602
- if (ctx.seen.has(_schema)) return false;
6603
- ctx.seen.add(_schema);
6604
- const def = _schema._zod.def;
6605
- switch (def.type) {
6606
- case "string":
6607
- case "number":
6608
- case "bigint":
6609
- case "boolean":
6610
- case "date":
6611
- case "symbol":
6612
- case "undefined":
6613
- case "null":
6614
- case "any":
6615
- case "unknown":
6616
- case "never":
6617
- case "void":
6618
- case "literal":
6619
- case "enum":
6620
- case "nan":
6621
- case "file":
6622
- case "template_literal": return false;
6623
- case "array": return isTransforming(def.element, ctx);
6624
- case "object":
6625
- for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
6626
- return false;
6627
- case "union":
6628
- for (const option of def.options) if (isTransforming(option, ctx)) return true;
6629
- return false;
6630
- case "intersection": return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
6631
- case "tuple":
6632
- for (const item of def.items) if (isTransforming(item, ctx)) return true;
6633
- if (def.rest && isTransforming(def.rest, ctx)) return true;
6634
- return false;
6635
- case "record": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
6636
- case "map": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
6637
- case "set": return isTransforming(def.valueType, ctx);
6638
- case "promise":
6639
- case "optional":
6640
- case "nonoptional":
6641
- case "nullable":
6642
- case "readonly": return isTransforming(def.innerType, ctx);
6643
- case "lazy": return isTransforming(def.getter(), ctx);
6644
- case "default": return isTransforming(def.innerType, ctx);
6645
- case "prefault": return isTransforming(def.innerType, ctx);
6646
- case "custom": return false;
6647
- case "transform": return true;
6648
- case "pipe": return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
6649
- case "success": return false;
6650
- case "catch": return false;
6651
- default:
6652
- }
6653
- throw new Error(`Unknown schema type: ${def.type}`);
7132
+ const ctx = initializeContext({
7133
+ ...params,
7134
+ processors: allProcessors
7135
+ });
7136
+ process$2(input, ctx);
7137
+ extractDefs(ctx, input);
7138
+ return finalize(ctx, input);
6654
7139
  }
6655
7140
 
6656
7141
  //#endregion
@@ -6659,6 +7144,7 @@ const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
6659
7144
  if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType.");
6660
7145
  $ZodType.init(inst, def);
6661
7146
  inst.def = def;
7147
+ inst.type = def.type;
6662
7148
  inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
6663
7149
  inst.safeParse = (data, params) => safeParse$2(inst, data, params);
6664
7150
  inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
@@ -6671,30 +7157,32 @@ const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
6671
7157
  def: { check: "custom" },
6672
7158
  onattach: []
6673
7159
  } } : ch)]
6674
- });
7160
+ }, { parent: true });
6675
7161
  };
7162
+ inst.with = inst.check;
6676
7163
  inst.clone = (_def, params) => clone(inst, _def, params);
6677
7164
  inst.brand = () => inst;
6678
7165
  inst.register = ((reg, meta) => {
6679
7166
  reg.add(inst, meta);
6680
7167
  return inst;
6681
7168
  });
7169
+ inst.apply = (fn) => fn(inst);
6682
7170
  });
6683
7171
  const ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
6684
7172
  $ZodObject.init(inst, def);
6685
7173
  ZodMiniType.init(inst, def);
6686
7174
  defineLazy(inst, "shape", () => def.shape);
6687
7175
  });
7176
+ /* @__NO_SIDE_EFFECTS__ */
6688
7177
  function object$1(shape, params) {
6689
7178
  return new ZodMiniObject({
6690
7179
  type: "object",
6691
- get shape() {
6692
- assignProp(this, "shape", { ...shape });
6693
- return this.shape;
6694
- },
7180
+ shape: shape ?? {},
6695
7181
  ...normalizeParams(params)
6696
7182
  });
6697
7183
  }
7184
+ const describe$1 = describe$2;
7185
+ const meta$1 = meta$2;
6698
7186
 
6699
7187
  //#endregion
6700
7188
  //#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
@@ -6851,8 +7339,14 @@ const initializer = (inst, issues) => {
6851
7339
  Object.defineProperties(inst, {
6852
7340
  format: { value: (mapper) => formatError(inst, mapper) },
6853
7341
  flatten: { value: (mapper) => flattenError(inst, mapper) },
6854
- addIssue: { value: (issue) => inst.issues.push(issue) },
6855
- addIssues: { value: (issues) => inst.issues.push(...issues) },
7342
+ addIssue: { value: (issue) => {
7343
+ inst.issues.push(issue);
7344
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
7345
+ } },
7346
+ addIssues: { value: (issues) => {
7347
+ inst.issues.push(...issues);
7348
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
7349
+ } },
6856
7350
  isEmpty: { get() {
6857
7351
  return inst.issues.length === 0;
6858
7352
  } }
@@ -6867,23 +7361,35 @@ const parse = /* @__PURE__ */ _parse(ZodRealError);
6867
7361
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
6868
7362
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
6869
7363
  const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
7364
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
7365
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
7366
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
7367
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
7368
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
7369
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
7370
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
7371
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
6870
7372
 
6871
7373
  //#endregion
6872
7374
  //#region node_modules/zod/v4/classic/schemas.js
6873
7375
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
6874
7376
  $ZodType.init(inst, def);
7377
+ Object.assign(inst["~standard"], { jsonSchema: {
7378
+ input: createStandardJSONSchemaMethod(inst, "input"),
7379
+ output: createStandardJSONSchemaMethod(inst, "output")
7380
+ } });
7381
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
6875
7382
  inst.def = def;
7383
+ inst.type = def.type;
6876
7384
  Object.defineProperty(inst, "_def", { value: def });
6877
7385
  inst.check = (...checks) => {
6878
- return inst.clone({
6879
- ...def,
6880
- checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
6881
- check: ch,
6882
- def: { check: "custom" },
6883
- onattach: []
6884
- } } : ch)]
6885
- });
7386
+ return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
7387
+ check: ch,
7388
+ def: { check: "custom" },
7389
+ onattach: []
7390
+ } } : ch)] }), { parent: true });
6886
7391
  };
7392
+ inst.with = inst.check;
6887
7393
  inst.clone = (def, params) => clone(inst, def, params);
6888
7394
  inst.brand = () => inst;
6889
7395
  inst.register = ((reg, meta) => {
@@ -6895,10 +7401,19 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
6895
7401
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
6896
7402
  inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
6897
7403
  inst.spa = inst.safeParseAsync;
7404
+ inst.encode = (data, params) => encode(inst, data, params);
7405
+ inst.decode = (data, params) => decode(inst, data, params);
7406
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
7407
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
7408
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
7409
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
7410
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
7411
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
6898
7412
  inst.refine = (check, params) => inst.check(refine(check, params));
6899
7413
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
6900
7414
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
6901
7415
  inst.optional = () => optional(inst);
7416
+ inst.exactOptional = () => exactOptional(inst);
6902
7417
  inst.nullable = () => nullable(inst);
6903
7418
  inst.nullish = () => optional(nullable(inst));
6904
7419
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -6930,12 +7445,14 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
6930
7445
  };
6931
7446
  inst.isOptional = () => inst.safeParse(void 0).success;
6932
7447
  inst.isNullable = () => inst.safeParse(null).success;
7448
+ inst.apply = (fn) => fn(inst);
6933
7449
  return inst;
6934
7450
  });
6935
7451
  /** @internal */
6936
7452
  const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
6937
7453
  $ZodString.init(inst, def);
6938
7454
  ZodType.init(inst, def);
7455
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
6939
7456
  const bag = inst._zod.bag;
6940
7457
  inst.format = bag.format ?? null;
6941
7458
  inst.minLength = bag.minimum ?? null;
@@ -6954,6 +7471,7 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
6954
7471
  inst.normalize = (...args) => inst.check(_normalize(...args));
6955
7472
  inst.toLowerCase = () => inst.check(_toLowerCase());
6956
7473
  inst.toUpperCase = () => inst.check(_toUpperCase());
7474
+ inst.slugify = () => inst.check(_slugify());
6957
7475
  });
6958
7476
  const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
6959
7477
  $ZodString.init(inst, def);
@@ -7072,6 +7590,7 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
7072
7590
  const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
7073
7591
  $ZodNumber.init(inst, def);
7074
7592
  ZodType.init(inst, def);
7593
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
7075
7594
  inst.gt = (value, params) => inst.check(_gt(value, params));
7076
7595
  inst.gte = (value, params) => inst.check(_gte(value, params));
7077
7596
  inst.min = (value, params) => inst.check(_gte(value, params));
@@ -7107,6 +7626,7 @@ function int(params) {
7107
7626
  const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
7108
7627
  $ZodBoolean.init(inst, def);
7109
7628
  ZodType.init(inst, def);
7629
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
7110
7630
  });
7111
7631
  function boolean(params) {
7112
7632
  return _boolean(ZodBoolean, params);
@@ -7114,6 +7634,7 @@ function boolean(params) {
7114
7634
  const ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
7115
7635
  $ZodNull.init(inst, def);
7116
7636
  ZodType.init(inst, def);
7637
+ inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
7117
7638
  });
7118
7639
  function _null(params) {
7119
7640
  return _null$1(ZodNull, params);
@@ -7121,6 +7642,7 @@ function _null(params) {
7121
7642
  const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
7122
7643
  $ZodUnknown.init(inst, def);
7123
7644
  ZodType.init(inst, def);
7645
+ inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
7124
7646
  });
7125
7647
  function unknown() {
7126
7648
  return _unknown(ZodUnknown);
@@ -7128,6 +7650,7 @@ function unknown() {
7128
7650
  const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
7129
7651
  $ZodNever.init(inst, def);
7130
7652
  ZodType.init(inst, def);
7653
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
7131
7654
  });
7132
7655
  function never(params) {
7133
7656
  return _never(ZodNever, params);
@@ -7135,6 +7658,7 @@ function never(params) {
7135
7658
  const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
7136
7659
  $ZodArray.init(inst, def);
7137
7660
  ZodType.init(inst, def);
7661
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
7138
7662
  inst.element = def.element;
7139
7663
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
7140
7664
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -7146,9 +7670,12 @@ function array(element, params) {
7146
7670
  return _array(ZodArray, element, params);
7147
7671
  }
7148
7672
  const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
7149
- $ZodObject.init(inst, def);
7673
+ $ZodObjectJIT.init(inst, def);
7150
7674
  ZodType.init(inst, def);
7151
- defineLazy(inst, "shape", () => def.shape);
7675
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
7676
+ defineLazy(inst, "shape", () => {
7677
+ return def.shape;
7678
+ });
7152
7679
  inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
7153
7680
  inst.catchall = (catchall) => inst.clone({
7154
7681
  ...inst._zod.def,
@@ -7173,6 +7700,9 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
7173
7700
  inst.extend = (incoming) => {
7174
7701
  return extend(inst, incoming);
7175
7702
  };
7703
+ inst.safeExtend = (incoming) => {
7704
+ return safeExtend(inst, incoming);
7705
+ };
7176
7706
  inst.merge = (other) => merge(inst, other);
7177
7707
  inst.pick = (mask) => pick(inst, mask);
7178
7708
  inst.omit = (mask) => omit(inst, mask);
@@ -7182,20 +7712,14 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
7182
7712
  function object(shape, params) {
7183
7713
  return new ZodObject({
7184
7714
  type: "object",
7185
- get shape() {
7186
- assignProp(this, "shape", { ...shape });
7187
- return this.shape;
7188
- },
7715
+ shape: shape ?? {},
7189
7716
  ...normalizeParams(params)
7190
7717
  });
7191
7718
  }
7192
7719
  function looseObject(shape, params) {
7193
7720
  return new ZodObject({
7194
7721
  type: "object",
7195
- get shape() {
7196
- assignProp(this, "shape", { ...shape });
7197
- return this.shape;
7198
- },
7722
+ shape,
7199
7723
  catchall: unknown(),
7200
7724
  ...normalizeParams(params)
7201
7725
  });
@@ -7203,6 +7727,7 @@ function looseObject(shape, params) {
7203
7727
  const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
7204
7728
  $ZodUnion.init(inst, def);
7205
7729
  ZodType.init(inst, def);
7730
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
7206
7731
  inst.options = def.options;
7207
7732
  });
7208
7733
  function union(options, params) {
@@ -7227,6 +7752,7 @@ function discriminatedUnion(discriminator, options, params) {
7227
7752
  const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
7228
7753
  $ZodIntersection.init(inst, def);
7229
7754
  ZodType.init(inst, def);
7755
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
7230
7756
  });
7231
7757
  function intersection(left, right) {
7232
7758
  return new ZodIntersection({
@@ -7238,6 +7764,7 @@ function intersection(left, right) {
7238
7764
  const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
7239
7765
  $ZodRecord.init(inst, def);
7240
7766
  ZodType.init(inst, def);
7767
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
7241
7768
  inst.keyType = def.keyType;
7242
7769
  inst.valueType = def.valueType;
7243
7770
  });
@@ -7252,6 +7779,7 @@ function record(keyType, valueType, params) {
7252
7779
  const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
7253
7780
  $ZodEnum.init(inst, def);
7254
7781
  ZodType.init(inst, def);
7782
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
7255
7783
  inst.enum = def.entries;
7256
7784
  inst.options = Object.values(def.entries);
7257
7785
  const keys = new Set(Object.keys(def.entries));
@@ -7288,6 +7816,7 @@ function _enum(values, params) {
7288
7816
  const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
7289
7817
  $ZodLiteral.init(inst, def);
7290
7818
  ZodType.init(inst, def);
7819
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
7291
7820
  inst.values = new Set(def.values);
7292
7821
  Object.defineProperty(inst, "value", { get() {
7293
7822
  if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
@@ -7304,16 +7833,17 @@ function literal(value, params) {
7304
7833
  const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
7305
7834
  $ZodTransform.init(inst, def);
7306
7835
  ZodType.init(inst, def);
7836
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
7307
7837
  inst._zod.parse = (payload, _ctx) => {
7308
- payload.addIssue = (issue$2) => {
7309
- if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, def));
7838
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
7839
+ payload.addIssue = (issue$1) => {
7840
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
7310
7841
  else {
7311
- const _issue = issue$2;
7842
+ const _issue = issue$1;
7312
7843
  if (_issue.fatal) _issue.continue = false;
7313
7844
  _issue.code ?? (_issue.code = "custom");
7314
7845
  _issue.input ?? (_issue.input = payload.value);
7315
7846
  _issue.inst ?? (_issue.inst = inst);
7316
- _issue.continue ?? (_issue.continue = true);
7317
7847
  payload.issues.push(issue(_issue));
7318
7848
  }
7319
7849
  };
@@ -7335,6 +7865,7 @@ function transform(fn) {
7335
7865
  const ZodOptional$1 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
7336
7866
  $ZodOptional.init(inst, def);
7337
7867
  ZodType.init(inst, def);
7868
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
7338
7869
  inst.unwrap = () => inst._zod.def.innerType;
7339
7870
  });
7340
7871
  function optional(innerType) {
@@ -7343,9 +7874,22 @@ function optional(innerType) {
7343
7874
  innerType
7344
7875
  });
7345
7876
  }
7877
+ const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
7878
+ $ZodExactOptional.init(inst, def);
7879
+ ZodType.init(inst, def);
7880
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
7881
+ inst.unwrap = () => inst._zod.def.innerType;
7882
+ });
7883
+ function exactOptional(innerType) {
7884
+ return new ZodExactOptional({
7885
+ type: "optional",
7886
+ innerType
7887
+ });
7888
+ }
7346
7889
  const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
7347
7890
  $ZodNullable.init(inst, def);
7348
7891
  ZodType.init(inst, def);
7892
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
7349
7893
  inst.unwrap = () => inst._zod.def.innerType;
7350
7894
  });
7351
7895
  function nullable(innerType) {
@@ -7357,6 +7901,7 @@ function nullable(innerType) {
7357
7901
  const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
7358
7902
  $ZodDefault.init(inst, def);
7359
7903
  ZodType.init(inst, def);
7904
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
7360
7905
  inst.unwrap = () => inst._zod.def.innerType;
7361
7906
  inst.removeDefault = inst.unwrap;
7362
7907
  });
@@ -7365,13 +7910,14 @@ function _default(innerType, defaultValue) {
7365
7910
  type: "default",
7366
7911
  innerType,
7367
7912
  get defaultValue() {
7368
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
7913
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
7369
7914
  }
7370
7915
  });
7371
7916
  }
7372
7917
  const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
7373
7918
  $ZodPrefault.init(inst, def);
7374
7919
  ZodType.init(inst, def);
7920
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
7375
7921
  inst.unwrap = () => inst._zod.def.innerType;
7376
7922
  });
7377
7923
  function prefault(innerType, defaultValue) {
@@ -7379,13 +7925,14 @@ function prefault(innerType, defaultValue) {
7379
7925
  type: "prefault",
7380
7926
  innerType,
7381
7927
  get defaultValue() {
7382
- return typeof defaultValue === "function" ? defaultValue() : defaultValue;
7928
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
7383
7929
  }
7384
7930
  });
7385
7931
  }
7386
7932
  const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
7387
7933
  $ZodNonOptional.init(inst, def);
7388
7934
  ZodType.init(inst, def);
7935
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
7389
7936
  inst.unwrap = () => inst._zod.def.innerType;
7390
7937
  });
7391
7938
  function nonoptional(innerType, params) {
@@ -7398,6 +7945,7 @@ function nonoptional(innerType, params) {
7398
7945
  const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
7399
7946
  $ZodCatch.init(inst, def);
7400
7947
  ZodType.init(inst, def);
7948
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
7401
7949
  inst.unwrap = () => inst._zod.def.innerType;
7402
7950
  inst.removeCatch = inst.unwrap;
7403
7951
  });
@@ -7411,6 +7959,7 @@ function _catch(innerType, catchValue) {
7411
7959
  const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
7412
7960
  $ZodPipe.init(inst, def);
7413
7961
  ZodType.init(inst, def);
7962
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
7414
7963
  inst.in = def.in;
7415
7964
  inst.out = def.out;
7416
7965
  });
@@ -7424,6 +7973,8 @@ function pipe(in_, out) {
7424
7973
  const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
7425
7974
  $ZodReadonly.init(inst, def);
7426
7975
  ZodType.init(inst, def);
7976
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
7977
+ inst.unwrap = () => inst._zod.def.innerType;
7427
7978
  });
7428
7979
  function readonly(innerType) {
7429
7980
  return new ZodReadonly({
@@ -7434,12 +7985,8 @@ function readonly(innerType) {
7434
7985
  const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
7435
7986
  $ZodCustom.init(inst, def);
7436
7987
  ZodType.init(inst, def);
7988
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
7437
7989
  });
7438
- function check(fn) {
7439
- const ch = new $ZodCheck({ check: "custom" });
7440
- ch._zod.check = fn;
7441
- return ch;
7442
- }
7443
7990
  function custom(fn, _params) {
7444
7991
  return _custom(ZodCustom, fn ?? (() => true), _params);
7445
7992
  }
@@ -7447,23 +7994,10 @@ function refine(fn, _params = {}) {
7447
7994
  return _refine(ZodCustom, fn, _params);
7448
7995
  }
7449
7996
  function superRefine(fn) {
7450
- const ch = check((payload) => {
7451
- payload.addIssue = (issue$1) => {
7452
- if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
7453
- else {
7454
- const _issue = issue$1;
7455
- if (_issue.fatal) _issue.continue = false;
7456
- _issue.code ?? (_issue.code = "custom");
7457
- _issue.input ?? (_issue.input = payload.value);
7458
- _issue.inst ?? (_issue.inst = ch);
7459
- _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
7460
- payload.issues.push(issue(_issue));
7461
- }
7462
- };
7463
- return fn(payload.value, payload);
7464
- });
7465
- return ch;
7997
+ return _superRefine(fn);
7466
7998
  }
7999
+ const describe = describe$2;
8000
+ const meta = meta$2;
7467
8001
  function preprocess(fn, schema) {
7468
8002
  return pipe(transform(fn), schema);
7469
8003
  }
@@ -7498,7 +8032,7 @@ const CursorSchema = string();
7498
8032
  * Task creation parameters, used to ask that the server create a task to represent a request.
7499
8033
  */
7500
8034
  const TaskCreationParamsSchema = looseObject({
7501
- ttl: union([number(), _null()]).optional(),
8035
+ ttl: number().optional(),
7502
8036
  pollInterval: number().optional()
7503
8037
  });
7504
8038
  const TaskMetadataSchema = object({ ttl: number().optional() });
@@ -7704,7 +8238,8 @@ const ClientCapabilitiesSchema = object({
7704
8238
  }).optional(),
7705
8239
  elicitation: ElicitationCapabilitySchema.optional(),
7706
8240
  roots: object({ listChanged: boolean().optional() }).optional(),
7707
- tasks: ClientTasksCapabilitySchema.optional()
8241
+ tasks: ClientTasksCapabilitySchema.optional(),
8242
+ extensions: record(string(), AssertObjectSchema).optional()
7708
8243
  });
7709
8244
  const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
7710
8245
  protocolVersion: string(),
@@ -7731,7 +8266,8 @@ const ServerCapabilitiesSchema = object({
7731
8266
  listChanged: boolean().optional()
7732
8267
  }).optional(),
7733
8268
  tools: object({ listChanged: boolean().optional() }).optional(),
7734
- tasks: ServerTasksCapabilitySchema.optional()
8269
+ tasks: ServerTasksCapabilitySchema.optional(),
8270
+ extensions: record(string(), AssertObjectSchema).optional()
7735
8271
  });
7736
8272
  /**
7737
8273
  * After receiving an initialize request from the client, the server sends this response.
@@ -7903,6 +8439,7 @@ const ResourceSchema = object({
7903
8439
  uri: string(),
7904
8440
  description: optional(string()),
7905
8441
  mimeType: optional(string()),
8442
+ size: optional(number()),
7906
8443
  annotations: AnnotationsSchema.optional(),
7907
8444
  _meta: optional(looseObject({}))
7908
8445
  });
@@ -10060,6 +10597,8 @@ var Protocol = class {
10060
10597
  this._progressHandlers.clear();
10061
10598
  this._taskProgressTokens.clear();
10062
10599
  this._pendingDebouncedNotifications.clear();
10600
+ for (const info of this._timeoutInfo.values()) clearTimeout(info.timeoutId);
10601
+ this._timeoutInfo.clear();
10063
10602
  for (const controller of this._requestHandlerAbortControllers.values()) controller.abort();
10064
10603
  this._requestHandlerAbortControllers.clear();
10065
10604
  const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
@@ -10163,7 +10702,7 @@ var Protocol = class {
10163
10702
  }, capturedTransport?.sessionId);
10164
10703
  else await capturedTransport?.send(errorResponse);
10165
10704
  }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send response: ${error}`))).finally(() => {
10166
- this._requestHandlerAbortControllers.delete(request.id);
10705
+ if (this._requestHandlerAbortControllers.get(request.id) === abortController) this._requestHandlerAbortControllers.delete(request.id);
10167
10706
  });
10168
10707
  }
10169
10708
  _onprogress(notification) {
@@ -18191,7 +18730,10 @@ var McpServer = class {
18191
18730
  if (isZodRawShapeCompat(firstArg)) {
18192
18731
  inputSchema = rest.shift();
18193
18732
  if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) annotations = rest.shift();
18194
- } else if (typeof firstArg === "object" && firstArg !== null) annotations = rest.shift();
18733
+ } else if (typeof firstArg === "object" && firstArg !== null) {
18734
+ if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
18735
+ annotations = rest.shift();
18736
+ }
18195
18737
  }
18196
18738
  const callback = rest[0];
18197
18739
  return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
@@ -18301,11 +18843,12 @@ function isZodRawShapeCompat(obj) {
18301
18843
  }
18302
18844
  /**
18303
18845
  * Converts a provided Zod schema to a Zod object if it is a ZodRawShapeCompat,
18304
- * otherwise returns the schema as is.
18846
+ * otherwise returns the schema as is. Throws if the value is not a valid Zod schema.
18305
18847
  */
18306
18848
  function getZodSchemaObject(schema) {
18307
18849
  if (!schema) return;
18308
18850
  if (isZodRawShapeCompat(schema)) return objectFromShape(schema);
18851
+ if (!isZodSchemaInstance(schema)) throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
18309
18852
  return schema;
18310
18853
  }
18311
18854
  function promptArgumentsFromSchema(schema) {