@fre4x/arxiv 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +114 -4155
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1147,9 +1147,9 @@ var require_util = __commonJS({
1147
1147
  }
1148
1148
  }
1149
1149
  exports2.eachItem = eachItem;
1150
- function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues4, resultToName }) {
1150
+ function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues3, resultToName }) {
1151
1151
  return (gen, from, to, toName) => {
1152
- const res = to === void 0 ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues4(from, to);
1152
+ const res = to === void 0 ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues3(from, to);
1153
1153
  return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
1154
1154
  };
1155
1155
  }
@@ -6809,7 +6809,7 @@ var require_dist = __commonJS({
6809
6809
  var require_delayed_stream = __commonJS({
6810
6810
  "../node_modules/delayed-stream/lib/delayed_stream.js"(exports2, module) {
6811
6811
  var Stream = __require("stream").Stream;
6812
- var util5 = __require("util");
6812
+ var util4 = __require("util");
6813
6813
  module.exports = DelayedStream;
6814
6814
  function DelayedStream() {
6815
6815
  this.source = null;
@@ -6820,7 +6820,7 @@ var require_delayed_stream = __commonJS({
6820
6820
  this._released = false;
6821
6821
  this._bufferedEvents = [];
6822
6822
  }
6823
- util5.inherits(DelayedStream, Stream);
6823
+ util4.inherits(DelayedStream, Stream);
6824
6824
  DelayedStream.create = function(source, options) {
6825
6825
  var delayedStream = new this();
6826
6826
  options = options || {};
@@ -6899,7 +6899,7 @@ var require_delayed_stream = __commonJS({
6899
6899
  // ../node_modules/combined-stream/lib/combined_stream.js
6900
6900
  var require_combined_stream = __commonJS({
6901
6901
  "../node_modules/combined-stream/lib/combined_stream.js"(exports2, module) {
6902
- var util5 = __require("util");
6902
+ var util4 = __require("util");
6903
6903
  var Stream = __require("stream").Stream;
6904
6904
  var DelayedStream = require_delayed_stream();
6905
6905
  module.exports = CombinedStream;
@@ -6915,7 +6915,7 @@ var require_combined_stream = __commonJS({
6915
6915
  this._insideLoop = false;
6916
6916
  this._pendingNext = false;
6917
6917
  }
6918
- util5.inherits(CombinedStream, Stream);
6918
+ util4.inherits(CombinedStream, Stream);
6919
6919
  CombinedStream.create = function(options) {
6920
6920
  var combinedStream = new this();
6921
6921
  options = options || {};
@@ -15708,12 +15708,12 @@ var require_async = __commonJS({
15708
15708
  var defer = require_defer();
15709
15709
  module.exports = async;
15710
15710
  function async(callback) {
15711
- var isAsync3 = false;
15711
+ var isAsync2 = false;
15712
15712
  defer(function() {
15713
- isAsync3 = true;
15713
+ isAsync2 = true;
15714
15714
  });
15715
15715
  return function async_callback(err, result) {
15716
- if (isAsync3) {
15716
+ if (isAsync2) {
15717
15717
  callback(err, result);
15718
15718
  } else {
15719
15719
  defer(function nextTick_callback() {
@@ -16760,7 +16760,7 @@ var require_form_data = __commonJS({
16760
16760
  "../node_modules/form-data/lib/form_data.js"(exports2, module) {
16761
16761
  "use strict";
16762
16762
  var CombinedStream = require_combined_stream();
16763
- var util5 = __require("util");
16763
+ var util4 = __require("util");
16764
16764
  var path = __require("path");
16765
16765
  var http3 = __require("http");
16766
16766
  var https2 = __require("https");
@@ -16786,7 +16786,7 @@ var require_form_data = __commonJS({
16786
16786
  this[option] = options[option];
16787
16787
  }
16788
16788
  }
16789
- util5.inherits(FormData3, CombinedStream);
16789
+ util4.inherits(FormData3, CombinedStream);
16790
16790
  FormData3.LINE_BREAK = "\r\n";
16791
16791
  FormData3.DEFAULT_CONTENT_TYPE = "application/octet-stream";
16792
16792
  FormData3.prototype.append = function(field, value, options) {
@@ -17266,7 +17266,7 @@ var require_common = __commonJS({
17266
17266
  function setup(env) {
17267
17267
  createDebug.debug = createDebug;
17268
17268
  createDebug.default = createDebug;
17269
- createDebug.coerce = coerce2;
17269
+ createDebug.coerce = coerce;
17270
17270
  createDebug.disable = disable;
17271
17271
  createDebug.enable = enable;
17272
17272
  createDebug.enabled = enabled;
@@ -17421,7 +17421,7 @@ var require_common = __commonJS({
17421
17421
  }
17422
17422
  return false;
17423
17423
  }
17424
- function coerce2(val) {
17424
+ function coerce(val) {
17425
17425
  if (val instanceof Error) {
17426
17426
  return val.stack || val.message;
17427
17427
  }
@@ -17738,14 +17738,14 @@ var require_supports_color = __commonJS({
17738
17738
  var require_node = __commonJS({
17739
17739
  "../node_modules/debug/src/node.js"(exports2, module) {
17740
17740
  var tty = __require("tty");
17741
- var util5 = __require("util");
17741
+ var util4 = __require("util");
17742
17742
  exports2.init = init;
17743
17743
  exports2.log = log;
17744
17744
  exports2.formatArgs = formatArgs;
17745
17745
  exports2.save = save;
17746
17746
  exports2.load = load;
17747
17747
  exports2.useColors = useColors;
17748
- exports2.destroy = util5.deprecate(
17748
+ exports2.destroy = util4.deprecate(
17749
17749
  () => {
17750
17750
  },
17751
17751
  "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
@@ -17876,7 +17876,7 @@ var require_node = __commonJS({
17876
17876
  return (/* @__PURE__ */ new Date()).toISOString() + " ";
17877
17877
  }
17878
17878
  function log(...args) {
17879
- return process.stderr.write(util5.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
17879
+ return process.stderr.write(util4.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
17880
17880
  }
17881
17881
  function save(namespaces) {
17882
17882
  if (namespaces) {
@@ -17899,11 +17899,11 @@ var require_node = __commonJS({
17899
17899
  var { formatters } = module.exports;
17900
17900
  formatters.o = function(v) {
17901
17901
  this.inspectOpts.colors = this.useColors;
17902
- return util5.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
17902
+ return util4.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
17903
17903
  };
17904
17904
  formatters.O = function(v) {
17905
17905
  this.inspectOpts.colors = this.useColors;
17906
- return util5.inspect(v, this.inspectOpts);
17906
+ return util4.inspect(v, this.inspectOpts);
17907
17907
  };
17908
17908
  }
17909
17909
  });
@@ -18437,37 +18437,37 @@ var require_follow_redirects = __commonJS({
18437
18437
 
18438
18438
  // ../node_modules/zod/v3/helpers/util.js
18439
18439
  var util;
18440
- (function(util5) {
18441
- util5.assertEqual = (_) => {
18440
+ (function(util4) {
18441
+ util4.assertEqual = (_) => {
18442
18442
  };
18443
18443
  function assertIs2(_arg) {
18444
18444
  }
18445
- util5.assertIs = assertIs2;
18445
+ util4.assertIs = assertIs2;
18446
18446
  function assertNever2(_x) {
18447
18447
  throw new Error();
18448
18448
  }
18449
- util5.assertNever = assertNever2;
18450
- util5.arrayToEnum = (items) => {
18449
+ util4.assertNever = assertNever2;
18450
+ util4.arrayToEnum = (items) => {
18451
18451
  const obj = {};
18452
18452
  for (const item of items) {
18453
18453
  obj[item] = item;
18454
18454
  }
18455
18455
  return obj;
18456
18456
  };
18457
- util5.getValidEnumValues = (obj) => {
18458
- const validKeys = util5.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
18457
+ util4.getValidEnumValues = (obj) => {
18458
+ const validKeys = util4.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
18459
18459
  const filtered = {};
18460
18460
  for (const k of validKeys) {
18461
18461
  filtered[k] = obj[k];
18462
18462
  }
18463
- return util5.objectValues(filtered);
18463
+ return util4.objectValues(filtered);
18464
18464
  };
18465
- util5.objectValues = (obj) => {
18466
- return util5.objectKeys(obj).map(function(e) {
18465
+ util4.objectValues = (obj) => {
18466
+ return util4.objectKeys(obj).map(function(e) {
18467
18467
  return obj[e];
18468
18468
  });
18469
18469
  };
18470
- util5.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
18470
+ util4.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
18471
18471
  const keys = [];
18472
18472
  for (const key in object3) {
18473
18473
  if (Object.prototype.hasOwnProperty.call(object3, key)) {
@@ -18476,19 +18476,19 @@ var util;
18476
18476
  }
18477
18477
  return keys;
18478
18478
  };
18479
- util5.find = (arr, checker) => {
18479
+ util4.find = (arr, checker) => {
18480
18480
  for (const item of arr) {
18481
18481
  if (checker(item))
18482
18482
  return item;
18483
18483
  }
18484
18484
  return void 0;
18485
18485
  };
18486
- util5.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
18486
+ util4.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
18487
18487
  function joinValues2(array2, separator = " | ") {
18488
18488
  return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
18489
18489
  }
18490
- util5.joinValues = joinValues2;
18491
- util5.jsonStringifyReplacer = (_, value) => {
18490
+ util4.joinValues = joinValues2;
18491
+ util4.jsonStringifyReplacer = (_, value) => {
18492
18492
  if (typeof value === "bigint") {
18493
18493
  return value.toString();
18494
18494
  }
@@ -18496,8 +18496,8 @@ var util;
18496
18496
  };
18497
18497
  })(util || (util = {}));
18498
18498
  var objectUtil;
18499
- (function(objectUtil3) {
18500
- objectUtil3.mergeShapes = (first, second) => {
18499
+ (function(objectUtil2) {
18500
+ objectUtil2.mergeShapes = (first, second) => {
18501
18501
  return {
18502
18502
  ...first,
18503
18503
  ...second
@@ -18903,9 +18903,9 @@ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
18903
18903
 
18904
18904
  // ../node_modules/zod/v3/helpers/errorUtil.js
18905
18905
  var errorUtil;
18906
- (function(errorUtil3) {
18907
- errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
18908
- errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
18906
+ (function(errorUtil2) {
18907
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
18908
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
18909
18909
  })(errorUtil || (errorUtil = {}));
18910
18910
 
18911
18911
  // ../node_modules/zod/v3/types.js
@@ -18950,12 +18950,12 @@ var handleResult = (ctx, result) => {
18950
18950
  function processCreateParams(params) {
18951
18951
  if (!params)
18952
18952
  return {};
18953
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
18954
- if (errorMap3 && (invalid_type_error || required_error)) {
18953
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
18954
+ if (errorMap2 && (invalid_type_error || required_error)) {
18955
18955
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
18956
18956
  }
18957
- if (errorMap3)
18958
- return { errorMap: errorMap3, description };
18957
+ if (errorMap2)
18958
+ return { errorMap: errorMap2, description };
18959
18959
  const customMap = (iss, ctx) => {
18960
18960
  const { message } = params;
18961
18961
  if (iss.code === "invalid_enum_value") {
@@ -22238,43 +22238,43 @@ var late = {
22238
22238
  object: ZodObject.lazycreate
22239
22239
  };
22240
22240
  var ZodFirstPartyTypeKind;
22241
- (function(ZodFirstPartyTypeKind4) {
22242
- ZodFirstPartyTypeKind4["ZodString"] = "ZodString";
22243
- ZodFirstPartyTypeKind4["ZodNumber"] = "ZodNumber";
22244
- ZodFirstPartyTypeKind4["ZodNaN"] = "ZodNaN";
22245
- ZodFirstPartyTypeKind4["ZodBigInt"] = "ZodBigInt";
22246
- ZodFirstPartyTypeKind4["ZodBoolean"] = "ZodBoolean";
22247
- ZodFirstPartyTypeKind4["ZodDate"] = "ZodDate";
22248
- ZodFirstPartyTypeKind4["ZodSymbol"] = "ZodSymbol";
22249
- ZodFirstPartyTypeKind4["ZodUndefined"] = "ZodUndefined";
22250
- ZodFirstPartyTypeKind4["ZodNull"] = "ZodNull";
22251
- ZodFirstPartyTypeKind4["ZodAny"] = "ZodAny";
22252
- ZodFirstPartyTypeKind4["ZodUnknown"] = "ZodUnknown";
22253
- ZodFirstPartyTypeKind4["ZodNever"] = "ZodNever";
22254
- ZodFirstPartyTypeKind4["ZodVoid"] = "ZodVoid";
22255
- ZodFirstPartyTypeKind4["ZodArray"] = "ZodArray";
22256
- ZodFirstPartyTypeKind4["ZodObject"] = "ZodObject";
22257
- ZodFirstPartyTypeKind4["ZodUnion"] = "ZodUnion";
22258
- ZodFirstPartyTypeKind4["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
22259
- ZodFirstPartyTypeKind4["ZodIntersection"] = "ZodIntersection";
22260
- ZodFirstPartyTypeKind4["ZodTuple"] = "ZodTuple";
22261
- ZodFirstPartyTypeKind4["ZodRecord"] = "ZodRecord";
22262
- ZodFirstPartyTypeKind4["ZodMap"] = "ZodMap";
22263
- ZodFirstPartyTypeKind4["ZodSet"] = "ZodSet";
22264
- ZodFirstPartyTypeKind4["ZodFunction"] = "ZodFunction";
22265
- ZodFirstPartyTypeKind4["ZodLazy"] = "ZodLazy";
22266
- ZodFirstPartyTypeKind4["ZodLiteral"] = "ZodLiteral";
22267
- ZodFirstPartyTypeKind4["ZodEnum"] = "ZodEnum";
22268
- ZodFirstPartyTypeKind4["ZodEffects"] = "ZodEffects";
22269
- ZodFirstPartyTypeKind4["ZodNativeEnum"] = "ZodNativeEnum";
22270
- ZodFirstPartyTypeKind4["ZodOptional"] = "ZodOptional";
22271
- ZodFirstPartyTypeKind4["ZodNullable"] = "ZodNullable";
22272
- ZodFirstPartyTypeKind4["ZodDefault"] = "ZodDefault";
22273
- ZodFirstPartyTypeKind4["ZodCatch"] = "ZodCatch";
22274
- ZodFirstPartyTypeKind4["ZodPromise"] = "ZodPromise";
22275
- ZodFirstPartyTypeKind4["ZodBranded"] = "ZodBranded";
22276
- ZodFirstPartyTypeKind4["ZodPipeline"] = "ZodPipeline";
22277
- ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
22241
+ (function(ZodFirstPartyTypeKind3) {
22242
+ ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
22243
+ ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
22244
+ ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
22245
+ ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
22246
+ ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
22247
+ ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
22248
+ ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
22249
+ ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
22250
+ ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
22251
+ ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
22252
+ ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
22253
+ ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
22254
+ ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
22255
+ ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
22256
+ ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
22257
+ ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
22258
+ ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
22259
+ ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
22260
+ ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
22261
+ ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
22262
+ ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
22263
+ ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
22264
+ ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
22265
+ ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
22266
+ ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
22267
+ ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
22268
+ ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
22269
+ ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
22270
+ ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
22271
+ ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
22272
+ ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
22273
+ ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
22274
+ ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
22275
+ ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
22276
+ ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
22277
+ ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
22278
22278
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
22279
22279
  var stringType = ZodString.create;
22280
22280
  var numberType = ZodNumber.create;
@@ -23686,8 +23686,8 @@ function datetime(args) {
23686
23686
  opts.push("");
23687
23687
  if (args.offset)
23688
23688
  opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
23689
- const timeRegex3 = `${time3}(?:${opts.join("|")})`;
23690
- return new RegExp(`^${dateSource}T(?:${timeRegex3})$`);
23689
+ const timeRegex2 = `${time3}(?:${opts.join("|")})`;
23690
+ return new RegExp(`^${dateSource}T(?:${timeRegex2})$`);
23691
23691
  }
23692
23692
  var string = (params) => {
23693
23693
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
@@ -24338,14 +24338,14 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
24338
24338
  });
24339
24339
  } else {
24340
24340
  const runChecks = (payload, checks2, ctx) => {
24341
- let isAborted3 = aborted(payload);
24341
+ let isAborted2 = aborted(payload);
24342
24342
  let asyncResult;
24343
24343
  for (const ch of checks2) {
24344
24344
  if (ch._zod.def.when) {
24345
24345
  const shouldRun = ch._zod.def.when(payload);
24346
24346
  if (!shouldRun)
24347
24347
  continue;
24348
- } else if (isAborted3) {
24348
+ } else if (isAborted2) {
24349
24349
  continue;
24350
24350
  }
24351
24351
  const currLen = payload.issues.length;
@@ -24359,15 +24359,15 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
24359
24359
  const nextLen = payload.issues.length;
24360
24360
  if (nextLen === currLen)
24361
24361
  return;
24362
- if (!isAborted3)
24363
- isAborted3 = aborted(payload, currLen);
24362
+ if (!isAborted2)
24363
+ isAborted2 = aborted(payload, currLen);
24364
24364
  });
24365
24365
  } else {
24366
24366
  const nextLen = payload.issues.length;
24367
24367
  if (nextLen === currLen)
24368
24368
  continue;
24369
- if (!isAborted3)
24370
- isAborted3 = aborted(payload, currLen);
24369
+ if (!isAborted2)
24370
+ isAborted2 = aborted(payload, currLen);
24371
24371
  }
24372
24372
  }
24373
24373
  if (asyncResult) {
@@ -35762,7 +35762,7 @@ function getErrorMap2() {
35762
35762
  return config().customError;
35763
35763
  }
35764
35764
  var ZodFirstPartyTypeKind2;
35765
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind4) {
35765
+ /* @__PURE__ */ (function(ZodFirstPartyTypeKind3) {
35766
35766
  })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
35767
35767
 
35768
35768
  // ../node_modules/zod/v4/classic/from-json-schema.js
@@ -41969,4047 +41969,6 @@ var StdioServerTransport = class {
41969
41969
  }
41970
41970
  };
41971
41971
 
41972
- // node_modules/zod/v3/external.js
41973
- var external_exports4 = {};
41974
- __export(external_exports4, {
41975
- BRAND: () => BRAND,
41976
- DIRTY: () => DIRTY2,
41977
- EMPTY_PATH: () => EMPTY_PATH,
41978
- INVALID: () => INVALID2,
41979
- NEVER: () => NEVER2,
41980
- OK: () => OK2,
41981
- ParseStatus: () => ParseStatus2,
41982
- Schema: () => ZodType3,
41983
- ZodAny: () => ZodAny3,
41984
- ZodArray: () => ZodArray3,
41985
- ZodBigInt: () => ZodBigInt3,
41986
- ZodBoolean: () => ZodBoolean3,
41987
- ZodBranded: () => ZodBranded2,
41988
- ZodCatch: () => ZodCatch3,
41989
- ZodDate: () => ZodDate3,
41990
- ZodDefault: () => ZodDefault3,
41991
- ZodDiscriminatedUnion: () => ZodDiscriminatedUnion3,
41992
- ZodEffects: () => ZodEffects2,
41993
- ZodEnum: () => ZodEnum3,
41994
- ZodError: () => ZodError3,
41995
- ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind3,
41996
- ZodFunction: () => ZodFunction3,
41997
- ZodIntersection: () => ZodIntersection3,
41998
- ZodIssueCode: () => ZodIssueCode3,
41999
- ZodLazy: () => ZodLazy3,
42000
- ZodLiteral: () => ZodLiteral3,
42001
- ZodMap: () => ZodMap3,
42002
- ZodNaN: () => ZodNaN3,
42003
- ZodNativeEnum: () => ZodNativeEnum2,
42004
- ZodNever: () => ZodNever3,
42005
- ZodNull: () => ZodNull3,
42006
- ZodNullable: () => ZodNullable3,
42007
- ZodNumber: () => ZodNumber3,
42008
- ZodObject: () => ZodObject3,
42009
- ZodOptional: () => ZodOptional3,
42010
- ZodParsedType: () => ZodParsedType2,
42011
- ZodPipeline: () => ZodPipeline2,
42012
- ZodPromise: () => ZodPromise3,
42013
- ZodReadonly: () => ZodReadonly3,
42014
- ZodRecord: () => ZodRecord3,
42015
- ZodSchema: () => ZodType3,
42016
- ZodSet: () => ZodSet3,
42017
- ZodString: () => ZodString3,
42018
- ZodSymbol: () => ZodSymbol3,
42019
- ZodTransformer: () => ZodEffects2,
42020
- ZodTuple: () => ZodTuple3,
42021
- ZodType: () => ZodType3,
42022
- ZodUndefined: () => ZodUndefined3,
42023
- ZodUnion: () => ZodUnion3,
42024
- ZodUnknown: () => ZodUnknown3,
42025
- ZodVoid: () => ZodVoid3,
42026
- addIssueToContext: () => addIssueToContext2,
42027
- any: () => anyType2,
42028
- array: () => arrayType2,
42029
- bigint: () => bigIntType2,
42030
- boolean: () => booleanType2,
42031
- coerce: () => coerce,
42032
- custom: () => custom2,
42033
- date: () => dateType2,
42034
- datetimeRegex: () => datetimeRegex2,
42035
- defaultErrorMap: () => en_default3,
42036
- discriminatedUnion: () => discriminatedUnionType2,
42037
- effect: () => effectsType2,
42038
- enum: () => enumType2,
42039
- function: () => functionType2,
42040
- getErrorMap: () => getErrorMap3,
42041
- getParsedType: () => getParsedType3,
42042
- instanceof: () => instanceOfType,
42043
- intersection: () => intersectionType2,
42044
- isAborted: () => isAborted2,
42045
- isAsync: () => isAsync2,
42046
- isDirty: () => isDirty2,
42047
- isValid: () => isValid2,
42048
- late: () => late2,
42049
- lazy: () => lazyType2,
42050
- literal: () => literalType2,
42051
- makeIssue: () => makeIssue2,
42052
- map: () => mapType2,
42053
- nan: () => nanType2,
42054
- nativeEnum: () => nativeEnumType2,
42055
- never: () => neverType2,
42056
- null: () => nullType2,
42057
- nullable: () => nullableType2,
42058
- number: () => numberType2,
42059
- object: () => objectType2,
42060
- objectUtil: () => objectUtil2,
42061
- oboolean: () => oboolean,
42062
- onumber: () => onumber,
42063
- optional: () => optionalType2,
42064
- ostring: () => ostring,
42065
- pipeline: () => pipelineType2,
42066
- preprocess: () => preprocessType2,
42067
- promise: () => promiseType2,
42068
- quotelessJson: () => quotelessJson,
42069
- record: () => recordType2,
42070
- set: () => setType2,
42071
- setErrorMap: () => setErrorMap2,
42072
- strictObject: () => strictObjectType2,
42073
- string: () => stringType2,
42074
- symbol: () => symbolType2,
42075
- transformer: () => effectsType2,
42076
- tuple: () => tupleType2,
42077
- undefined: () => undefinedType2,
42078
- union: () => unionType2,
42079
- unknown: () => unknownType2,
42080
- util: () => util2,
42081
- void: () => voidType2
42082
- });
42083
-
42084
- // node_modules/zod/v3/helpers/util.js
42085
- var util2;
42086
- (function(util5) {
42087
- util5.assertEqual = (_) => {
42088
- };
42089
- function assertIs2(_arg) {
42090
- }
42091
- util5.assertIs = assertIs2;
42092
- function assertNever2(_x) {
42093
- throw new Error();
42094
- }
42095
- util5.assertNever = assertNever2;
42096
- util5.arrayToEnum = (items) => {
42097
- const obj = {};
42098
- for (const item of items) {
42099
- obj[item] = item;
42100
- }
42101
- return obj;
42102
- };
42103
- util5.getValidEnumValues = (obj) => {
42104
- const validKeys = util5.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
42105
- const filtered = {};
42106
- for (const k of validKeys) {
42107
- filtered[k] = obj[k];
42108
- }
42109
- return util5.objectValues(filtered);
42110
- };
42111
- util5.objectValues = (obj) => {
42112
- return util5.objectKeys(obj).map(function(e) {
42113
- return obj[e];
42114
- });
42115
- };
42116
- util5.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
42117
- const keys = [];
42118
- for (const key in object3) {
42119
- if (Object.prototype.hasOwnProperty.call(object3, key)) {
42120
- keys.push(key);
42121
- }
42122
- }
42123
- return keys;
42124
- };
42125
- util5.find = (arr, checker) => {
42126
- for (const item of arr) {
42127
- if (checker(item))
42128
- return item;
42129
- }
42130
- return void 0;
42131
- };
42132
- util5.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
42133
- function joinValues2(array2, separator = " | ") {
42134
- return array2.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
42135
- }
42136
- util5.joinValues = joinValues2;
42137
- util5.jsonStringifyReplacer = (_, value) => {
42138
- if (typeof value === "bigint") {
42139
- return value.toString();
42140
- }
42141
- return value;
42142
- };
42143
- })(util2 || (util2 = {}));
42144
- var objectUtil2;
42145
- (function(objectUtil3) {
42146
- objectUtil3.mergeShapes = (first, second) => {
42147
- return {
42148
- ...first,
42149
- ...second
42150
- // second overwrites first
42151
- };
42152
- };
42153
- })(objectUtil2 || (objectUtil2 = {}));
42154
- var ZodParsedType2 = util2.arrayToEnum([
42155
- "string",
42156
- "nan",
42157
- "number",
42158
- "integer",
42159
- "float",
42160
- "boolean",
42161
- "date",
42162
- "bigint",
42163
- "symbol",
42164
- "function",
42165
- "undefined",
42166
- "null",
42167
- "array",
42168
- "object",
42169
- "unknown",
42170
- "promise",
42171
- "void",
42172
- "never",
42173
- "map",
42174
- "set"
42175
- ]);
42176
- var getParsedType3 = (data) => {
42177
- const t = typeof data;
42178
- switch (t) {
42179
- case "undefined":
42180
- return ZodParsedType2.undefined;
42181
- case "string":
42182
- return ZodParsedType2.string;
42183
- case "number":
42184
- return Number.isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
42185
- case "boolean":
42186
- return ZodParsedType2.boolean;
42187
- case "function":
42188
- return ZodParsedType2.function;
42189
- case "bigint":
42190
- return ZodParsedType2.bigint;
42191
- case "symbol":
42192
- return ZodParsedType2.symbol;
42193
- case "object":
42194
- if (Array.isArray(data)) {
42195
- return ZodParsedType2.array;
42196
- }
42197
- if (data === null) {
42198
- return ZodParsedType2.null;
42199
- }
42200
- if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
42201
- return ZodParsedType2.promise;
42202
- }
42203
- if (typeof Map !== "undefined" && data instanceof Map) {
42204
- return ZodParsedType2.map;
42205
- }
42206
- if (typeof Set !== "undefined" && data instanceof Set) {
42207
- return ZodParsedType2.set;
42208
- }
42209
- if (typeof Date !== "undefined" && data instanceof Date) {
42210
- return ZodParsedType2.date;
42211
- }
42212
- return ZodParsedType2.object;
42213
- default:
42214
- return ZodParsedType2.unknown;
42215
- }
42216
- };
42217
-
42218
- // node_modules/zod/v3/ZodError.js
42219
- var ZodIssueCode3 = util2.arrayToEnum([
42220
- "invalid_type",
42221
- "invalid_literal",
42222
- "custom",
42223
- "invalid_union",
42224
- "invalid_union_discriminator",
42225
- "invalid_enum_value",
42226
- "unrecognized_keys",
42227
- "invalid_arguments",
42228
- "invalid_return_type",
42229
- "invalid_date",
42230
- "invalid_string",
42231
- "too_small",
42232
- "too_big",
42233
- "invalid_intersection_types",
42234
- "not_multiple_of",
42235
- "not_finite"
42236
- ]);
42237
- var quotelessJson = (obj) => {
42238
- const json2 = JSON.stringify(obj, null, 2);
42239
- return json2.replace(/"([^"]+)":/g, "$1:");
42240
- };
42241
- var ZodError3 = class _ZodError extends Error {
42242
- get errors() {
42243
- return this.issues;
42244
- }
42245
- constructor(issues) {
42246
- super();
42247
- this.issues = [];
42248
- this.addIssue = (sub) => {
42249
- this.issues = [...this.issues, sub];
42250
- };
42251
- this.addIssues = (subs = []) => {
42252
- this.issues = [...this.issues, ...subs];
42253
- };
42254
- const actualProto = new.target.prototype;
42255
- if (Object.setPrototypeOf) {
42256
- Object.setPrototypeOf(this, actualProto);
42257
- } else {
42258
- this.__proto__ = actualProto;
42259
- }
42260
- this.name = "ZodError";
42261
- this.issues = issues;
42262
- }
42263
- format(_mapper) {
42264
- const mapper = _mapper || function(issue2) {
42265
- return issue2.message;
42266
- };
42267
- const fieldErrors = { _errors: [] };
42268
- const processError = (error48) => {
42269
- for (const issue2 of error48.issues) {
42270
- if (issue2.code === "invalid_union") {
42271
- issue2.unionErrors.map(processError);
42272
- } else if (issue2.code === "invalid_return_type") {
42273
- processError(issue2.returnTypeError);
42274
- } else if (issue2.code === "invalid_arguments") {
42275
- processError(issue2.argumentsError);
42276
- } else if (issue2.path.length === 0) {
42277
- fieldErrors._errors.push(mapper(issue2));
42278
- } else {
42279
- let curr = fieldErrors;
42280
- let i = 0;
42281
- while (i < issue2.path.length) {
42282
- const el = issue2.path[i];
42283
- const terminal = i === issue2.path.length - 1;
42284
- if (!terminal) {
42285
- curr[el] = curr[el] || { _errors: [] };
42286
- } else {
42287
- curr[el] = curr[el] || { _errors: [] };
42288
- curr[el]._errors.push(mapper(issue2));
42289
- }
42290
- curr = curr[el];
42291
- i++;
42292
- }
42293
- }
42294
- }
42295
- };
42296
- processError(this);
42297
- return fieldErrors;
42298
- }
42299
- static assert(value) {
42300
- if (!(value instanceof _ZodError)) {
42301
- throw new Error(`Not a ZodError: ${value}`);
42302
- }
42303
- }
42304
- toString() {
42305
- return this.message;
42306
- }
42307
- get message() {
42308
- return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
42309
- }
42310
- get isEmpty() {
42311
- return this.issues.length === 0;
42312
- }
42313
- flatten(mapper = (issue2) => issue2.message) {
42314
- const fieldErrors = {};
42315
- const formErrors = [];
42316
- for (const sub of this.issues) {
42317
- if (sub.path.length > 0) {
42318
- const firstEl = sub.path[0];
42319
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
42320
- fieldErrors[firstEl].push(mapper(sub));
42321
- } else {
42322
- formErrors.push(mapper(sub));
42323
- }
42324
- }
42325
- return { formErrors, fieldErrors };
42326
- }
42327
- get formErrors() {
42328
- return this.flatten();
42329
- }
42330
- };
42331
- ZodError3.create = (issues) => {
42332
- const error48 = new ZodError3(issues);
42333
- return error48;
42334
- };
42335
-
42336
- // node_modules/zod/v3/locales/en.js
42337
- var errorMap2 = (issue2, _ctx) => {
42338
- let message;
42339
- switch (issue2.code) {
42340
- case ZodIssueCode3.invalid_type:
42341
- if (issue2.received === ZodParsedType2.undefined) {
42342
- message = "Required";
42343
- } else {
42344
- message = `Expected ${issue2.expected}, received ${issue2.received}`;
42345
- }
42346
- break;
42347
- case ZodIssueCode3.invalid_literal:
42348
- message = `Invalid literal value, expected ${JSON.stringify(issue2.expected, util2.jsonStringifyReplacer)}`;
42349
- break;
42350
- case ZodIssueCode3.unrecognized_keys:
42351
- message = `Unrecognized key(s) in object: ${util2.joinValues(issue2.keys, ", ")}`;
42352
- break;
42353
- case ZodIssueCode3.invalid_union:
42354
- message = `Invalid input`;
42355
- break;
42356
- case ZodIssueCode3.invalid_union_discriminator:
42357
- message = `Invalid discriminator value. Expected ${util2.joinValues(issue2.options)}`;
42358
- break;
42359
- case ZodIssueCode3.invalid_enum_value:
42360
- message = `Invalid enum value. Expected ${util2.joinValues(issue2.options)}, received '${issue2.received}'`;
42361
- break;
42362
- case ZodIssueCode3.invalid_arguments:
42363
- message = `Invalid function arguments`;
42364
- break;
42365
- case ZodIssueCode3.invalid_return_type:
42366
- message = `Invalid function return type`;
42367
- break;
42368
- case ZodIssueCode3.invalid_date:
42369
- message = `Invalid date`;
42370
- break;
42371
- case ZodIssueCode3.invalid_string:
42372
- if (typeof issue2.validation === "object") {
42373
- if ("includes" in issue2.validation) {
42374
- message = `Invalid input: must include "${issue2.validation.includes}"`;
42375
- if (typeof issue2.validation.position === "number") {
42376
- message = `${message} at one or more positions greater than or equal to ${issue2.validation.position}`;
42377
- }
42378
- } else if ("startsWith" in issue2.validation) {
42379
- message = `Invalid input: must start with "${issue2.validation.startsWith}"`;
42380
- } else if ("endsWith" in issue2.validation) {
42381
- message = `Invalid input: must end with "${issue2.validation.endsWith}"`;
42382
- } else {
42383
- util2.assertNever(issue2.validation);
42384
- }
42385
- } else if (issue2.validation !== "regex") {
42386
- message = `Invalid ${issue2.validation}`;
42387
- } else {
42388
- message = "Invalid";
42389
- }
42390
- break;
42391
- case ZodIssueCode3.too_small:
42392
- if (issue2.type === "array")
42393
- message = `Array must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `more than`} ${issue2.minimum} element(s)`;
42394
- else if (issue2.type === "string")
42395
- message = `String must contain ${issue2.exact ? "exactly" : issue2.inclusive ? `at least` : `over`} ${issue2.minimum} character(s)`;
42396
- else if (issue2.type === "number")
42397
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
42398
- else if (issue2.type === "bigint")
42399
- message = `Number must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${issue2.minimum}`;
42400
- else if (issue2.type === "date")
42401
- message = `Date must be ${issue2.exact ? `exactly equal to ` : issue2.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue2.minimum))}`;
42402
- else
42403
- message = "Invalid input";
42404
- break;
42405
- case ZodIssueCode3.too_big:
42406
- if (issue2.type === "array")
42407
- message = `Array must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `less than`} ${issue2.maximum} element(s)`;
42408
- else if (issue2.type === "string")
42409
- message = `String must contain ${issue2.exact ? `exactly` : issue2.inclusive ? `at most` : `under`} ${issue2.maximum} character(s)`;
42410
- else if (issue2.type === "number")
42411
- message = `Number must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
42412
- else if (issue2.type === "bigint")
42413
- message = `BigInt must be ${issue2.exact ? `exactly` : issue2.inclusive ? `less than or equal to` : `less than`} ${issue2.maximum}`;
42414
- else if (issue2.type === "date")
42415
- message = `Date must be ${issue2.exact ? `exactly` : issue2.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue2.maximum))}`;
42416
- else
42417
- message = "Invalid input";
42418
- break;
42419
- case ZodIssueCode3.custom:
42420
- message = `Invalid input`;
42421
- break;
42422
- case ZodIssueCode3.invalid_intersection_types:
42423
- message = `Intersection results could not be merged`;
42424
- break;
42425
- case ZodIssueCode3.not_multiple_of:
42426
- message = `Number must be a multiple of ${issue2.multipleOf}`;
42427
- break;
42428
- case ZodIssueCode3.not_finite:
42429
- message = "Number must be finite";
42430
- break;
42431
- default:
42432
- message = _ctx.defaultError;
42433
- util2.assertNever(issue2);
42434
- }
42435
- return { message };
42436
- };
42437
- var en_default3 = errorMap2;
42438
-
42439
- // node_modules/zod/v3/errors.js
42440
- var overrideErrorMap2 = en_default3;
42441
- function setErrorMap2(map2) {
42442
- overrideErrorMap2 = map2;
42443
- }
42444
- function getErrorMap3() {
42445
- return overrideErrorMap2;
42446
- }
42447
-
42448
- // node_modules/zod/v3/helpers/parseUtil.js
42449
- var makeIssue2 = (params) => {
42450
- const { data, path, errorMaps, issueData } = params;
42451
- const fullPath = [...path, ...issueData.path || []];
42452
- const fullIssue = {
42453
- ...issueData,
42454
- path: fullPath
42455
- };
42456
- if (issueData.message !== void 0) {
42457
- return {
42458
- ...issueData,
42459
- path: fullPath,
42460
- message: issueData.message
42461
- };
42462
- }
42463
- let errorMessage = "";
42464
- const maps = errorMaps.filter((m) => !!m).slice().reverse();
42465
- for (const map2 of maps) {
42466
- errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
42467
- }
42468
- return {
42469
- ...issueData,
42470
- path: fullPath,
42471
- message: errorMessage
42472
- };
42473
- };
42474
- var EMPTY_PATH = [];
42475
- function addIssueToContext2(ctx, issueData) {
42476
- const overrideMap = getErrorMap3();
42477
- const issue2 = makeIssue2({
42478
- issueData,
42479
- data: ctx.data,
42480
- path: ctx.path,
42481
- errorMaps: [
42482
- ctx.common.contextualErrorMap,
42483
- // contextual error map is first priority
42484
- ctx.schemaErrorMap,
42485
- // then schema-bound map if available
42486
- overrideMap,
42487
- // then global override map
42488
- overrideMap === en_default3 ? void 0 : en_default3
42489
- // then global default map
42490
- ].filter((x) => !!x)
42491
- });
42492
- ctx.common.issues.push(issue2);
42493
- }
42494
- var ParseStatus2 = class _ParseStatus {
42495
- constructor() {
42496
- this.value = "valid";
42497
- }
42498
- dirty() {
42499
- if (this.value === "valid")
42500
- this.value = "dirty";
42501
- }
42502
- abort() {
42503
- if (this.value !== "aborted")
42504
- this.value = "aborted";
42505
- }
42506
- static mergeArray(status, results) {
42507
- const arrayValue = [];
42508
- for (const s of results) {
42509
- if (s.status === "aborted")
42510
- return INVALID2;
42511
- if (s.status === "dirty")
42512
- status.dirty();
42513
- arrayValue.push(s.value);
42514
- }
42515
- return { status: status.value, value: arrayValue };
42516
- }
42517
- static async mergeObjectAsync(status, pairs) {
42518
- const syncPairs = [];
42519
- for (const pair of pairs) {
42520
- const key = await pair.key;
42521
- const value = await pair.value;
42522
- syncPairs.push({
42523
- key,
42524
- value
42525
- });
42526
- }
42527
- return _ParseStatus.mergeObjectSync(status, syncPairs);
42528
- }
42529
- static mergeObjectSync(status, pairs) {
42530
- const finalObject = {};
42531
- for (const pair of pairs) {
42532
- const { key, value } = pair;
42533
- if (key.status === "aborted")
42534
- return INVALID2;
42535
- if (value.status === "aborted")
42536
- return INVALID2;
42537
- if (key.status === "dirty")
42538
- status.dirty();
42539
- if (value.status === "dirty")
42540
- status.dirty();
42541
- if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
42542
- finalObject[key.value] = value.value;
42543
- }
42544
- }
42545
- return { status: status.value, value: finalObject };
42546
- }
42547
- };
42548
- var INVALID2 = Object.freeze({
42549
- status: "aborted"
42550
- });
42551
- var DIRTY2 = (value) => ({ status: "dirty", value });
42552
- var OK2 = (value) => ({ status: "valid", value });
42553
- var isAborted2 = (x) => x.status === "aborted";
42554
- var isDirty2 = (x) => x.status === "dirty";
42555
- var isValid2 = (x) => x.status === "valid";
42556
- var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise;
42557
-
42558
- // node_modules/zod/v3/helpers/errorUtil.js
42559
- var errorUtil2;
42560
- (function(errorUtil3) {
42561
- errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
42562
- errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
42563
- })(errorUtil2 || (errorUtil2 = {}));
42564
-
42565
- // node_modules/zod/v3/types.js
42566
- var ParseInputLazyPath2 = class {
42567
- constructor(parent, value, path, key) {
42568
- this._cachedPath = [];
42569
- this.parent = parent;
42570
- this.data = value;
42571
- this._path = path;
42572
- this._key = key;
42573
- }
42574
- get path() {
42575
- if (!this._cachedPath.length) {
42576
- if (Array.isArray(this._key)) {
42577
- this._cachedPath.push(...this._path, ...this._key);
42578
- } else {
42579
- this._cachedPath.push(...this._path, this._key);
42580
- }
42581
- }
42582
- return this._cachedPath;
42583
- }
42584
- };
42585
- var handleResult2 = (ctx, result) => {
42586
- if (isValid2(result)) {
42587
- return { success: true, data: result.value };
42588
- } else {
42589
- if (!ctx.common.issues.length) {
42590
- throw new Error("Validation failed but no issues detected.");
42591
- }
42592
- return {
42593
- success: false,
42594
- get error() {
42595
- if (this._error)
42596
- return this._error;
42597
- const error48 = new ZodError3(ctx.common.issues);
42598
- this._error = error48;
42599
- return this._error;
42600
- }
42601
- };
42602
- }
42603
- };
42604
- function processCreateParams2(params) {
42605
- if (!params)
42606
- return {};
42607
- const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
42608
- if (errorMap3 && (invalid_type_error || required_error)) {
42609
- throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
42610
- }
42611
- if (errorMap3)
42612
- return { errorMap: errorMap3, description };
42613
- const customMap = (iss, ctx) => {
42614
- const { message } = params;
42615
- if (iss.code === "invalid_enum_value") {
42616
- return { message: message ?? ctx.defaultError };
42617
- }
42618
- if (typeof ctx.data === "undefined") {
42619
- return { message: message ?? required_error ?? ctx.defaultError };
42620
- }
42621
- if (iss.code !== "invalid_type")
42622
- return { message: ctx.defaultError };
42623
- return { message: message ?? invalid_type_error ?? ctx.defaultError };
42624
- };
42625
- return { errorMap: customMap, description };
42626
- }
42627
- var ZodType3 = class {
42628
- get description() {
42629
- return this._def.description;
42630
- }
42631
- _getType(input) {
42632
- return getParsedType3(input.data);
42633
- }
42634
- _getOrReturnCtx(input, ctx) {
42635
- return ctx || {
42636
- common: input.parent.common,
42637
- data: input.data,
42638
- parsedType: getParsedType3(input.data),
42639
- schemaErrorMap: this._def.errorMap,
42640
- path: input.path,
42641
- parent: input.parent
42642
- };
42643
- }
42644
- _processInputParams(input) {
42645
- return {
42646
- status: new ParseStatus2(),
42647
- ctx: {
42648
- common: input.parent.common,
42649
- data: input.data,
42650
- parsedType: getParsedType3(input.data),
42651
- schemaErrorMap: this._def.errorMap,
42652
- path: input.path,
42653
- parent: input.parent
42654
- }
42655
- };
42656
- }
42657
- _parseSync(input) {
42658
- const result = this._parse(input);
42659
- if (isAsync2(result)) {
42660
- throw new Error("Synchronous parse encountered promise.");
42661
- }
42662
- return result;
42663
- }
42664
- _parseAsync(input) {
42665
- const result = this._parse(input);
42666
- return Promise.resolve(result);
42667
- }
42668
- parse(data, params) {
42669
- const result = this.safeParse(data, params);
42670
- if (result.success)
42671
- return result.data;
42672
- throw result.error;
42673
- }
42674
- safeParse(data, params) {
42675
- const ctx = {
42676
- common: {
42677
- issues: [],
42678
- async: params?.async ?? false,
42679
- contextualErrorMap: params?.errorMap
42680
- },
42681
- path: params?.path || [],
42682
- schemaErrorMap: this._def.errorMap,
42683
- parent: null,
42684
- data,
42685
- parsedType: getParsedType3(data)
42686
- };
42687
- const result = this._parseSync({ data, path: ctx.path, parent: ctx });
42688
- return handleResult2(ctx, result);
42689
- }
42690
- "~validate"(data) {
42691
- const ctx = {
42692
- common: {
42693
- issues: [],
42694
- async: !!this["~standard"].async
42695
- },
42696
- path: [],
42697
- schemaErrorMap: this._def.errorMap,
42698
- parent: null,
42699
- data,
42700
- parsedType: getParsedType3(data)
42701
- };
42702
- if (!this["~standard"].async) {
42703
- try {
42704
- const result = this._parseSync({ data, path: [], parent: ctx });
42705
- return isValid2(result) ? {
42706
- value: result.value
42707
- } : {
42708
- issues: ctx.common.issues
42709
- };
42710
- } catch (err) {
42711
- if (err?.message?.toLowerCase()?.includes("encountered")) {
42712
- this["~standard"].async = true;
42713
- }
42714
- ctx.common = {
42715
- issues: [],
42716
- async: true
42717
- };
42718
- }
42719
- }
42720
- return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid2(result) ? {
42721
- value: result.value
42722
- } : {
42723
- issues: ctx.common.issues
42724
- });
42725
- }
42726
- async parseAsync(data, params) {
42727
- const result = await this.safeParseAsync(data, params);
42728
- if (result.success)
42729
- return result.data;
42730
- throw result.error;
42731
- }
42732
- async safeParseAsync(data, params) {
42733
- const ctx = {
42734
- common: {
42735
- issues: [],
42736
- contextualErrorMap: params?.errorMap,
42737
- async: true
42738
- },
42739
- path: params?.path || [],
42740
- schemaErrorMap: this._def.errorMap,
42741
- parent: null,
42742
- data,
42743
- parsedType: getParsedType3(data)
42744
- };
42745
- const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
42746
- const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
42747
- return handleResult2(ctx, result);
42748
- }
42749
- refine(check2, message) {
42750
- const getIssueProperties = (val) => {
42751
- if (typeof message === "string" || typeof message === "undefined") {
42752
- return { message };
42753
- } else if (typeof message === "function") {
42754
- return message(val);
42755
- } else {
42756
- return message;
42757
- }
42758
- };
42759
- return this._refinement((val, ctx) => {
42760
- const result = check2(val);
42761
- const setError = () => ctx.addIssue({
42762
- code: ZodIssueCode3.custom,
42763
- ...getIssueProperties(val)
42764
- });
42765
- if (typeof Promise !== "undefined" && result instanceof Promise) {
42766
- return result.then((data) => {
42767
- if (!data) {
42768
- setError();
42769
- return false;
42770
- } else {
42771
- return true;
42772
- }
42773
- });
42774
- }
42775
- if (!result) {
42776
- setError();
42777
- return false;
42778
- } else {
42779
- return true;
42780
- }
42781
- });
42782
- }
42783
- refinement(check2, refinementData) {
42784
- return this._refinement((val, ctx) => {
42785
- if (!check2(val)) {
42786
- ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
42787
- return false;
42788
- } else {
42789
- return true;
42790
- }
42791
- });
42792
- }
42793
- _refinement(refinement) {
42794
- return new ZodEffects2({
42795
- schema: this,
42796
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
42797
- effect: { type: "refinement", refinement }
42798
- });
42799
- }
42800
- superRefine(refinement) {
42801
- return this._refinement(refinement);
42802
- }
42803
- constructor(def) {
42804
- this.spa = this.safeParseAsync;
42805
- this._def = def;
42806
- this.parse = this.parse.bind(this);
42807
- this.safeParse = this.safeParse.bind(this);
42808
- this.parseAsync = this.parseAsync.bind(this);
42809
- this.safeParseAsync = this.safeParseAsync.bind(this);
42810
- this.spa = this.spa.bind(this);
42811
- this.refine = this.refine.bind(this);
42812
- this.refinement = this.refinement.bind(this);
42813
- this.superRefine = this.superRefine.bind(this);
42814
- this.optional = this.optional.bind(this);
42815
- this.nullable = this.nullable.bind(this);
42816
- this.nullish = this.nullish.bind(this);
42817
- this.array = this.array.bind(this);
42818
- this.promise = this.promise.bind(this);
42819
- this.or = this.or.bind(this);
42820
- this.and = this.and.bind(this);
42821
- this.transform = this.transform.bind(this);
42822
- this.brand = this.brand.bind(this);
42823
- this.default = this.default.bind(this);
42824
- this.catch = this.catch.bind(this);
42825
- this.describe = this.describe.bind(this);
42826
- this.pipe = this.pipe.bind(this);
42827
- this.readonly = this.readonly.bind(this);
42828
- this.isNullable = this.isNullable.bind(this);
42829
- this.isOptional = this.isOptional.bind(this);
42830
- this["~standard"] = {
42831
- version: 1,
42832
- vendor: "zod",
42833
- validate: (data) => this["~validate"](data)
42834
- };
42835
- }
42836
- optional() {
42837
- return ZodOptional3.create(this, this._def);
42838
- }
42839
- nullable() {
42840
- return ZodNullable3.create(this, this._def);
42841
- }
42842
- nullish() {
42843
- return this.nullable().optional();
42844
- }
42845
- array() {
42846
- return ZodArray3.create(this);
42847
- }
42848
- promise() {
42849
- return ZodPromise3.create(this, this._def);
42850
- }
42851
- or(option) {
42852
- return ZodUnion3.create([this, option], this._def);
42853
- }
42854
- and(incoming) {
42855
- return ZodIntersection3.create(this, incoming, this._def);
42856
- }
42857
- transform(transform2) {
42858
- return new ZodEffects2({
42859
- ...processCreateParams2(this._def),
42860
- schema: this,
42861
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
42862
- effect: { type: "transform", transform: transform2 }
42863
- });
42864
- }
42865
- default(def) {
42866
- const defaultValueFunc = typeof def === "function" ? def : () => def;
42867
- return new ZodDefault3({
42868
- ...processCreateParams2(this._def),
42869
- innerType: this,
42870
- defaultValue: defaultValueFunc,
42871
- typeName: ZodFirstPartyTypeKind3.ZodDefault
42872
- });
42873
- }
42874
- brand() {
42875
- return new ZodBranded2({
42876
- typeName: ZodFirstPartyTypeKind3.ZodBranded,
42877
- type: this,
42878
- ...processCreateParams2(this._def)
42879
- });
42880
- }
42881
- catch(def) {
42882
- const catchValueFunc = typeof def === "function" ? def : () => def;
42883
- return new ZodCatch3({
42884
- ...processCreateParams2(this._def),
42885
- innerType: this,
42886
- catchValue: catchValueFunc,
42887
- typeName: ZodFirstPartyTypeKind3.ZodCatch
42888
- });
42889
- }
42890
- describe(description) {
42891
- const This = this.constructor;
42892
- return new This({
42893
- ...this._def,
42894
- description
42895
- });
42896
- }
42897
- pipe(target) {
42898
- return ZodPipeline2.create(this, target);
42899
- }
42900
- readonly() {
42901
- return ZodReadonly3.create(this);
42902
- }
42903
- isOptional() {
42904
- return this.safeParse(void 0).success;
42905
- }
42906
- isNullable() {
42907
- return this.safeParse(null).success;
42908
- }
42909
- };
42910
- var cuidRegex2 = /^c[^\s-]{8,}$/i;
42911
- var cuid2Regex2 = /^[0-9a-z]+$/;
42912
- var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
42913
- var uuidRegex2 = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
42914
- var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
42915
- var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
42916
- var durationRegex2 = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
42917
- var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
42918
- var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
42919
- var emojiRegex3;
42920
- var ipv4Regex2 = /^(?:(?: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])$/;
42921
- var ipv4CidrRegex2 = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
42922
- var ipv6Regex2 = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
42923
- var ipv6CidrRegex2 = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
42924
- var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
42925
- var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
42926
- var dateRegexSource2 = `((\\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])))`;
42927
- var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
42928
- function timeRegexSource2(args) {
42929
- let secondsRegexSource = `[0-5]\\d`;
42930
- if (args.precision) {
42931
- secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
42932
- } else if (args.precision == null) {
42933
- secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
42934
- }
42935
- const secondsQuantifier = args.precision ? "+" : "?";
42936
- return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
42937
- }
42938
- function timeRegex2(args) {
42939
- return new RegExp(`^${timeRegexSource2(args)}$`);
42940
- }
42941
- function datetimeRegex2(args) {
42942
- let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
42943
- const opts = [];
42944
- opts.push(args.local ? `Z?` : `Z`);
42945
- if (args.offset)
42946
- opts.push(`([+-]\\d{2}:?\\d{2})`);
42947
- regex = `${regex}(${opts.join("|")})`;
42948
- return new RegExp(`^${regex}$`);
42949
- }
42950
- function isValidIP2(ip, version2) {
42951
- if ((version2 === "v4" || !version2) && ipv4Regex2.test(ip)) {
42952
- return true;
42953
- }
42954
- if ((version2 === "v6" || !version2) && ipv6Regex2.test(ip)) {
42955
- return true;
42956
- }
42957
- return false;
42958
- }
42959
- function isValidJWT3(jwt2, alg) {
42960
- if (!jwtRegex2.test(jwt2))
42961
- return false;
42962
- try {
42963
- const [header] = jwt2.split(".");
42964
- if (!header)
42965
- return false;
42966
- const base643 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
42967
- const decoded = JSON.parse(atob(base643));
42968
- if (typeof decoded !== "object" || decoded === null)
42969
- return false;
42970
- if ("typ" in decoded && decoded?.typ !== "JWT")
42971
- return false;
42972
- if (!decoded.alg)
42973
- return false;
42974
- if (alg && decoded.alg !== alg)
42975
- return false;
42976
- return true;
42977
- } catch {
42978
- return false;
42979
- }
42980
- }
42981
- function isValidCidr2(ip, version2) {
42982
- if ((version2 === "v4" || !version2) && ipv4CidrRegex2.test(ip)) {
42983
- return true;
42984
- }
42985
- if ((version2 === "v6" || !version2) && ipv6CidrRegex2.test(ip)) {
42986
- return true;
42987
- }
42988
- return false;
42989
- }
42990
- var ZodString3 = class _ZodString2 extends ZodType3 {
42991
- _parse(input) {
42992
- if (this._def.coerce) {
42993
- input.data = String(input.data);
42994
- }
42995
- const parsedType2 = this._getType(input);
42996
- if (parsedType2 !== ZodParsedType2.string) {
42997
- const ctx2 = this._getOrReturnCtx(input);
42998
- addIssueToContext2(ctx2, {
42999
- code: ZodIssueCode3.invalid_type,
43000
- expected: ZodParsedType2.string,
43001
- received: ctx2.parsedType
43002
- });
43003
- return INVALID2;
43004
- }
43005
- const status = new ParseStatus2();
43006
- let ctx = void 0;
43007
- for (const check2 of this._def.checks) {
43008
- if (check2.kind === "min") {
43009
- if (input.data.length < check2.value) {
43010
- ctx = this._getOrReturnCtx(input, ctx);
43011
- addIssueToContext2(ctx, {
43012
- code: ZodIssueCode3.too_small,
43013
- minimum: check2.value,
43014
- type: "string",
43015
- inclusive: true,
43016
- exact: false,
43017
- message: check2.message
43018
- });
43019
- status.dirty();
43020
- }
43021
- } else if (check2.kind === "max") {
43022
- if (input.data.length > check2.value) {
43023
- ctx = this._getOrReturnCtx(input, ctx);
43024
- addIssueToContext2(ctx, {
43025
- code: ZodIssueCode3.too_big,
43026
- maximum: check2.value,
43027
- type: "string",
43028
- inclusive: true,
43029
- exact: false,
43030
- message: check2.message
43031
- });
43032
- status.dirty();
43033
- }
43034
- } else if (check2.kind === "length") {
43035
- const tooBig = input.data.length > check2.value;
43036
- const tooSmall = input.data.length < check2.value;
43037
- if (tooBig || tooSmall) {
43038
- ctx = this._getOrReturnCtx(input, ctx);
43039
- if (tooBig) {
43040
- addIssueToContext2(ctx, {
43041
- code: ZodIssueCode3.too_big,
43042
- maximum: check2.value,
43043
- type: "string",
43044
- inclusive: true,
43045
- exact: true,
43046
- message: check2.message
43047
- });
43048
- } else if (tooSmall) {
43049
- addIssueToContext2(ctx, {
43050
- code: ZodIssueCode3.too_small,
43051
- minimum: check2.value,
43052
- type: "string",
43053
- inclusive: true,
43054
- exact: true,
43055
- message: check2.message
43056
- });
43057
- }
43058
- status.dirty();
43059
- }
43060
- } else if (check2.kind === "email") {
43061
- if (!emailRegex2.test(input.data)) {
43062
- ctx = this._getOrReturnCtx(input, ctx);
43063
- addIssueToContext2(ctx, {
43064
- validation: "email",
43065
- code: ZodIssueCode3.invalid_string,
43066
- message: check2.message
43067
- });
43068
- status.dirty();
43069
- }
43070
- } else if (check2.kind === "emoji") {
43071
- if (!emojiRegex3) {
43072
- emojiRegex3 = new RegExp(_emojiRegex2, "u");
43073
- }
43074
- if (!emojiRegex3.test(input.data)) {
43075
- ctx = this._getOrReturnCtx(input, ctx);
43076
- addIssueToContext2(ctx, {
43077
- validation: "emoji",
43078
- code: ZodIssueCode3.invalid_string,
43079
- message: check2.message
43080
- });
43081
- status.dirty();
43082
- }
43083
- } else if (check2.kind === "uuid") {
43084
- if (!uuidRegex2.test(input.data)) {
43085
- ctx = this._getOrReturnCtx(input, ctx);
43086
- addIssueToContext2(ctx, {
43087
- validation: "uuid",
43088
- code: ZodIssueCode3.invalid_string,
43089
- message: check2.message
43090
- });
43091
- status.dirty();
43092
- }
43093
- } else if (check2.kind === "nanoid") {
43094
- if (!nanoidRegex2.test(input.data)) {
43095
- ctx = this._getOrReturnCtx(input, ctx);
43096
- addIssueToContext2(ctx, {
43097
- validation: "nanoid",
43098
- code: ZodIssueCode3.invalid_string,
43099
- message: check2.message
43100
- });
43101
- status.dirty();
43102
- }
43103
- } else if (check2.kind === "cuid") {
43104
- if (!cuidRegex2.test(input.data)) {
43105
- ctx = this._getOrReturnCtx(input, ctx);
43106
- addIssueToContext2(ctx, {
43107
- validation: "cuid",
43108
- code: ZodIssueCode3.invalid_string,
43109
- message: check2.message
43110
- });
43111
- status.dirty();
43112
- }
43113
- } else if (check2.kind === "cuid2") {
43114
- if (!cuid2Regex2.test(input.data)) {
43115
- ctx = this._getOrReturnCtx(input, ctx);
43116
- addIssueToContext2(ctx, {
43117
- validation: "cuid2",
43118
- code: ZodIssueCode3.invalid_string,
43119
- message: check2.message
43120
- });
43121
- status.dirty();
43122
- }
43123
- } else if (check2.kind === "ulid") {
43124
- if (!ulidRegex2.test(input.data)) {
43125
- ctx = this._getOrReturnCtx(input, ctx);
43126
- addIssueToContext2(ctx, {
43127
- validation: "ulid",
43128
- code: ZodIssueCode3.invalid_string,
43129
- message: check2.message
43130
- });
43131
- status.dirty();
43132
- }
43133
- } else if (check2.kind === "url") {
43134
- try {
43135
- new URL(input.data);
43136
- } catch {
43137
- ctx = this._getOrReturnCtx(input, ctx);
43138
- addIssueToContext2(ctx, {
43139
- validation: "url",
43140
- code: ZodIssueCode3.invalid_string,
43141
- message: check2.message
43142
- });
43143
- status.dirty();
43144
- }
43145
- } else if (check2.kind === "regex") {
43146
- check2.regex.lastIndex = 0;
43147
- const testResult = check2.regex.test(input.data);
43148
- if (!testResult) {
43149
- ctx = this._getOrReturnCtx(input, ctx);
43150
- addIssueToContext2(ctx, {
43151
- validation: "regex",
43152
- code: ZodIssueCode3.invalid_string,
43153
- message: check2.message
43154
- });
43155
- status.dirty();
43156
- }
43157
- } else if (check2.kind === "trim") {
43158
- input.data = input.data.trim();
43159
- } else if (check2.kind === "includes") {
43160
- if (!input.data.includes(check2.value, check2.position)) {
43161
- ctx = this._getOrReturnCtx(input, ctx);
43162
- addIssueToContext2(ctx, {
43163
- code: ZodIssueCode3.invalid_string,
43164
- validation: { includes: check2.value, position: check2.position },
43165
- message: check2.message
43166
- });
43167
- status.dirty();
43168
- }
43169
- } else if (check2.kind === "toLowerCase") {
43170
- input.data = input.data.toLowerCase();
43171
- } else if (check2.kind === "toUpperCase") {
43172
- input.data = input.data.toUpperCase();
43173
- } else if (check2.kind === "startsWith") {
43174
- if (!input.data.startsWith(check2.value)) {
43175
- ctx = this._getOrReturnCtx(input, ctx);
43176
- addIssueToContext2(ctx, {
43177
- code: ZodIssueCode3.invalid_string,
43178
- validation: { startsWith: check2.value },
43179
- message: check2.message
43180
- });
43181
- status.dirty();
43182
- }
43183
- } else if (check2.kind === "endsWith") {
43184
- if (!input.data.endsWith(check2.value)) {
43185
- ctx = this._getOrReturnCtx(input, ctx);
43186
- addIssueToContext2(ctx, {
43187
- code: ZodIssueCode3.invalid_string,
43188
- validation: { endsWith: check2.value },
43189
- message: check2.message
43190
- });
43191
- status.dirty();
43192
- }
43193
- } else if (check2.kind === "datetime") {
43194
- const regex = datetimeRegex2(check2);
43195
- if (!regex.test(input.data)) {
43196
- ctx = this._getOrReturnCtx(input, ctx);
43197
- addIssueToContext2(ctx, {
43198
- code: ZodIssueCode3.invalid_string,
43199
- validation: "datetime",
43200
- message: check2.message
43201
- });
43202
- status.dirty();
43203
- }
43204
- } else if (check2.kind === "date") {
43205
- const regex = dateRegex2;
43206
- if (!regex.test(input.data)) {
43207
- ctx = this._getOrReturnCtx(input, ctx);
43208
- addIssueToContext2(ctx, {
43209
- code: ZodIssueCode3.invalid_string,
43210
- validation: "date",
43211
- message: check2.message
43212
- });
43213
- status.dirty();
43214
- }
43215
- } else if (check2.kind === "time") {
43216
- const regex = timeRegex2(check2);
43217
- if (!regex.test(input.data)) {
43218
- ctx = this._getOrReturnCtx(input, ctx);
43219
- addIssueToContext2(ctx, {
43220
- code: ZodIssueCode3.invalid_string,
43221
- validation: "time",
43222
- message: check2.message
43223
- });
43224
- status.dirty();
43225
- }
43226
- } else if (check2.kind === "duration") {
43227
- if (!durationRegex2.test(input.data)) {
43228
- ctx = this._getOrReturnCtx(input, ctx);
43229
- addIssueToContext2(ctx, {
43230
- validation: "duration",
43231
- code: ZodIssueCode3.invalid_string,
43232
- message: check2.message
43233
- });
43234
- status.dirty();
43235
- }
43236
- } else if (check2.kind === "ip") {
43237
- if (!isValidIP2(input.data, check2.version)) {
43238
- ctx = this._getOrReturnCtx(input, ctx);
43239
- addIssueToContext2(ctx, {
43240
- validation: "ip",
43241
- code: ZodIssueCode3.invalid_string,
43242
- message: check2.message
43243
- });
43244
- status.dirty();
43245
- }
43246
- } else if (check2.kind === "jwt") {
43247
- if (!isValidJWT3(input.data, check2.alg)) {
43248
- ctx = this._getOrReturnCtx(input, ctx);
43249
- addIssueToContext2(ctx, {
43250
- validation: "jwt",
43251
- code: ZodIssueCode3.invalid_string,
43252
- message: check2.message
43253
- });
43254
- status.dirty();
43255
- }
43256
- } else if (check2.kind === "cidr") {
43257
- if (!isValidCidr2(input.data, check2.version)) {
43258
- ctx = this._getOrReturnCtx(input, ctx);
43259
- addIssueToContext2(ctx, {
43260
- validation: "cidr",
43261
- code: ZodIssueCode3.invalid_string,
43262
- message: check2.message
43263
- });
43264
- status.dirty();
43265
- }
43266
- } else if (check2.kind === "base64") {
43267
- if (!base64Regex2.test(input.data)) {
43268
- ctx = this._getOrReturnCtx(input, ctx);
43269
- addIssueToContext2(ctx, {
43270
- validation: "base64",
43271
- code: ZodIssueCode3.invalid_string,
43272
- message: check2.message
43273
- });
43274
- status.dirty();
43275
- }
43276
- } else if (check2.kind === "base64url") {
43277
- if (!base64urlRegex2.test(input.data)) {
43278
- ctx = this._getOrReturnCtx(input, ctx);
43279
- addIssueToContext2(ctx, {
43280
- validation: "base64url",
43281
- code: ZodIssueCode3.invalid_string,
43282
- message: check2.message
43283
- });
43284
- status.dirty();
43285
- }
43286
- } else {
43287
- util2.assertNever(check2);
43288
- }
43289
- }
43290
- return { status: status.value, value: input.data };
43291
- }
43292
- _regex(regex, validation, message) {
43293
- return this.refinement((data) => regex.test(data), {
43294
- validation,
43295
- code: ZodIssueCode3.invalid_string,
43296
- ...errorUtil2.errToObj(message)
43297
- });
43298
- }
43299
- _addCheck(check2) {
43300
- return new _ZodString2({
43301
- ...this._def,
43302
- checks: [...this._def.checks, check2]
43303
- });
43304
- }
43305
- email(message) {
43306
- return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
43307
- }
43308
- url(message) {
43309
- return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
43310
- }
43311
- emoji(message) {
43312
- return this._addCheck({ kind: "emoji", ...errorUtil2.errToObj(message) });
43313
- }
43314
- uuid(message) {
43315
- return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
43316
- }
43317
- nanoid(message) {
43318
- return this._addCheck({ kind: "nanoid", ...errorUtil2.errToObj(message) });
43319
- }
43320
- cuid(message) {
43321
- return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
43322
- }
43323
- cuid2(message) {
43324
- return this._addCheck({ kind: "cuid2", ...errorUtil2.errToObj(message) });
43325
- }
43326
- ulid(message) {
43327
- return this._addCheck({ kind: "ulid", ...errorUtil2.errToObj(message) });
43328
- }
43329
- base64(message) {
43330
- return this._addCheck({ kind: "base64", ...errorUtil2.errToObj(message) });
43331
- }
43332
- base64url(message) {
43333
- return this._addCheck({
43334
- kind: "base64url",
43335
- ...errorUtil2.errToObj(message)
43336
- });
43337
- }
43338
- jwt(options) {
43339
- return this._addCheck({ kind: "jwt", ...errorUtil2.errToObj(options) });
43340
- }
43341
- ip(options) {
43342
- return this._addCheck({ kind: "ip", ...errorUtil2.errToObj(options) });
43343
- }
43344
- cidr(options) {
43345
- return this._addCheck({ kind: "cidr", ...errorUtil2.errToObj(options) });
43346
- }
43347
- datetime(options) {
43348
- if (typeof options === "string") {
43349
- return this._addCheck({
43350
- kind: "datetime",
43351
- precision: null,
43352
- offset: false,
43353
- local: false,
43354
- message: options
43355
- });
43356
- }
43357
- return this._addCheck({
43358
- kind: "datetime",
43359
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
43360
- offset: options?.offset ?? false,
43361
- local: options?.local ?? false,
43362
- ...errorUtil2.errToObj(options?.message)
43363
- });
43364
- }
43365
- date(message) {
43366
- return this._addCheck({ kind: "date", message });
43367
- }
43368
- time(options) {
43369
- if (typeof options === "string") {
43370
- return this._addCheck({
43371
- kind: "time",
43372
- precision: null,
43373
- message: options
43374
- });
43375
- }
43376
- return this._addCheck({
43377
- kind: "time",
43378
- precision: typeof options?.precision === "undefined" ? null : options?.precision,
43379
- ...errorUtil2.errToObj(options?.message)
43380
- });
43381
- }
43382
- duration(message) {
43383
- return this._addCheck({ kind: "duration", ...errorUtil2.errToObj(message) });
43384
- }
43385
- regex(regex, message) {
43386
- return this._addCheck({
43387
- kind: "regex",
43388
- regex,
43389
- ...errorUtil2.errToObj(message)
43390
- });
43391
- }
43392
- includes(value, options) {
43393
- return this._addCheck({
43394
- kind: "includes",
43395
- value,
43396
- position: options?.position,
43397
- ...errorUtil2.errToObj(options?.message)
43398
- });
43399
- }
43400
- startsWith(value, message) {
43401
- return this._addCheck({
43402
- kind: "startsWith",
43403
- value,
43404
- ...errorUtil2.errToObj(message)
43405
- });
43406
- }
43407
- endsWith(value, message) {
43408
- return this._addCheck({
43409
- kind: "endsWith",
43410
- value,
43411
- ...errorUtil2.errToObj(message)
43412
- });
43413
- }
43414
- min(minLength, message) {
43415
- return this._addCheck({
43416
- kind: "min",
43417
- value: minLength,
43418
- ...errorUtil2.errToObj(message)
43419
- });
43420
- }
43421
- max(maxLength, message) {
43422
- return this._addCheck({
43423
- kind: "max",
43424
- value: maxLength,
43425
- ...errorUtil2.errToObj(message)
43426
- });
43427
- }
43428
- length(len, message) {
43429
- return this._addCheck({
43430
- kind: "length",
43431
- value: len,
43432
- ...errorUtil2.errToObj(message)
43433
- });
43434
- }
43435
- /**
43436
- * Equivalent to `.min(1)`
43437
- */
43438
- nonempty(message) {
43439
- return this.min(1, errorUtil2.errToObj(message));
43440
- }
43441
- trim() {
43442
- return new _ZodString2({
43443
- ...this._def,
43444
- checks: [...this._def.checks, { kind: "trim" }]
43445
- });
43446
- }
43447
- toLowerCase() {
43448
- return new _ZodString2({
43449
- ...this._def,
43450
- checks: [...this._def.checks, { kind: "toLowerCase" }]
43451
- });
43452
- }
43453
- toUpperCase() {
43454
- return new _ZodString2({
43455
- ...this._def,
43456
- checks: [...this._def.checks, { kind: "toUpperCase" }]
43457
- });
43458
- }
43459
- get isDatetime() {
43460
- return !!this._def.checks.find((ch) => ch.kind === "datetime");
43461
- }
43462
- get isDate() {
43463
- return !!this._def.checks.find((ch) => ch.kind === "date");
43464
- }
43465
- get isTime() {
43466
- return !!this._def.checks.find((ch) => ch.kind === "time");
43467
- }
43468
- get isDuration() {
43469
- return !!this._def.checks.find((ch) => ch.kind === "duration");
43470
- }
43471
- get isEmail() {
43472
- return !!this._def.checks.find((ch) => ch.kind === "email");
43473
- }
43474
- get isURL() {
43475
- return !!this._def.checks.find((ch) => ch.kind === "url");
43476
- }
43477
- get isEmoji() {
43478
- return !!this._def.checks.find((ch) => ch.kind === "emoji");
43479
- }
43480
- get isUUID() {
43481
- return !!this._def.checks.find((ch) => ch.kind === "uuid");
43482
- }
43483
- get isNANOID() {
43484
- return !!this._def.checks.find((ch) => ch.kind === "nanoid");
43485
- }
43486
- get isCUID() {
43487
- return !!this._def.checks.find((ch) => ch.kind === "cuid");
43488
- }
43489
- get isCUID2() {
43490
- return !!this._def.checks.find((ch) => ch.kind === "cuid2");
43491
- }
43492
- get isULID() {
43493
- return !!this._def.checks.find((ch) => ch.kind === "ulid");
43494
- }
43495
- get isIP() {
43496
- return !!this._def.checks.find((ch) => ch.kind === "ip");
43497
- }
43498
- get isCIDR() {
43499
- return !!this._def.checks.find((ch) => ch.kind === "cidr");
43500
- }
43501
- get isBase64() {
43502
- return !!this._def.checks.find((ch) => ch.kind === "base64");
43503
- }
43504
- get isBase64url() {
43505
- return !!this._def.checks.find((ch) => ch.kind === "base64url");
43506
- }
43507
- get minLength() {
43508
- let min = null;
43509
- for (const ch of this._def.checks) {
43510
- if (ch.kind === "min") {
43511
- if (min === null || ch.value > min)
43512
- min = ch.value;
43513
- }
43514
- }
43515
- return min;
43516
- }
43517
- get maxLength() {
43518
- let max = null;
43519
- for (const ch of this._def.checks) {
43520
- if (ch.kind === "max") {
43521
- if (max === null || ch.value < max)
43522
- max = ch.value;
43523
- }
43524
- }
43525
- return max;
43526
- }
43527
- };
43528
- ZodString3.create = (params) => {
43529
- return new ZodString3({
43530
- checks: [],
43531
- typeName: ZodFirstPartyTypeKind3.ZodString,
43532
- coerce: params?.coerce ?? false,
43533
- ...processCreateParams2(params)
43534
- });
43535
- };
43536
- function floatSafeRemainder3(val, step) {
43537
- const valDecCount = (val.toString().split(".")[1] || "").length;
43538
- const stepDecCount = (step.toString().split(".")[1] || "").length;
43539
- const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
43540
- const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
43541
- const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
43542
- return valInt % stepInt / 10 ** decCount;
43543
- }
43544
- var ZodNumber3 = class _ZodNumber extends ZodType3 {
43545
- constructor() {
43546
- super(...arguments);
43547
- this.min = this.gte;
43548
- this.max = this.lte;
43549
- this.step = this.multipleOf;
43550
- }
43551
- _parse(input) {
43552
- if (this._def.coerce) {
43553
- input.data = Number(input.data);
43554
- }
43555
- const parsedType2 = this._getType(input);
43556
- if (parsedType2 !== ZodParsedType2.number) {
43557
- const ctx2 = this._getOrReturnCtx(input);
43558
- addIssueToContext2(ctx2, {
43559
- code: ZodIssueCode3.invalid_type,
43560
- expected: ZodParsedType2.number,
43561
- received: ctx2.parsedType
43562
- });
43563
- return INVALID2;
43564
- }
43565
- let ctx = void 0;
43566
- const status = new ParseStatus2();
43567
- for (const check2 of this._def.checks) {
43568
- if (check2.kind === "int") {
43569
- if (!util2.isInteger(input.data)) {
43570
- ctx = this._getOrReturnCtx(input, ctx);
43571
- addIssueToContext2(ctx, {
43572
- code: ZodIssueCode3.invalid_type,
43573
- expected: "integer",
43574
- received: "float",
43575
- message: check2.message
43576
- });
43577
- status.dirty();
43578
- }
43579
- } else if (check2.kind === "min") {
43580
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
43581
- if (tooSmall) {
43582
- ctx = this._getOrReturnCtx(input, ctx);
43583
- addIssueToContext2(ctx, {
43584
- code: ZodIssueCode3.too_small,
43585
- minimum: check2.value,
43586
- type: "number",
43587
- inclusive: check2.inclusive,
43588
- exact: false,
43589
- message: check2.message
43590
- });
43591
- status.dirty();
43592
- }
43593
- } else if (check2.kind === "max") {
43594
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
43595
- if (tooBig) {
43596
- ctx = this._getOrReturnCtx(input, ctx);
43597
- addIssueToContext2(ctx, {
43598
- code: ZodIssueCode3.too_big,
43599
- maximum: check2.value,
43600
- type: "number",
43601
- inclusive: check2.inclusive,
43602
- exact: false,
43603
- message: check2.message
43604
- });
43605
- status.dirty();
43606
- }
43607
- } else if (check2.kind === "multipleOf") {
43608
- if (floatSafeRemainder3(input.data, check2.value) !== 0) {
43609
- ctx = this._getOrReturnCtx(input, ctx);
43610
- addIssueToContext2(ctx, {
43611
- code: ZodIssueCode3.not_multiple_of,
43612
- multipleOf: check2.value,
43613
- message: check2.message
43614
- });
43615
- status.dirty();
43616
- }
43617
- } else if (check2.kind === "finite") {
43618
- if (!Number.isFinite(input.data)) {
43619
- ctx = this._getOrReturnCtx(input, ctx);
43620
- addIssueToContext2(ctx, {
43621
- code: ZodIssueCode3.not_finite,
43622
- message: check2.message
43623
- });
43624
- status.dirty();
43625
- }
43626
- } else {
43627
- util2.assertNever(check2);
43628
- }
43629
- }
43630
- return { status: status.value, value: input.data };
43631
- }
43632
- gte(value, message) {
43633
- return this.setLimit("min", value, true, errorUtil2.toString(message));
43634
- }
43635
- gt(value, message) {
43636
- return this.setLimit("min", value, false, errorUtil2.toString(message));
43637
- }
43638
- lte(value, message) {
43639
- return this.setLimit("max", value, true, errorUtil2.toString(message));
43640
- }
43641
- lt(value, message) {
43642
- return this.setLimit("max", value, false, errorUtil2.toString(message));
43643
- }
43644
- setLimit(kind, value, inclusive, message) {
43645
- return new _ZodNumber({
43646
- ...this._def,
43647
- checks: [
43648
- ...this._def.checks,
43649
- {
43650
- kind,
43651
- value,
43652
- inclusive,
43653
- message: errorUtil2.toString(message)
43654
- }
43655
- ]
43656
- });
43657
- }
43658
- _addCheck(check2) {
43659
- return new _ZodNumber({
43660
- ...this._def,
43661
- checks: [...this._def.checks, check2]
43662
- });
43663
- }
43664
- int(message) {
43665
- return this._addCheck({
43666
- kind: "int",
43667
- message: errorUtil2.toString(message)
43668
- });
43669
- }
43670
- positive(message) {
43671
- return this._addCheck({
43672
- kind: "min",
43673
- value: 0,
43674
- inclusive: false,
43675
- message: errorUtil2.toString(message)
43676
- });
43677
- }
43678
- negative(message) {
43679
- return this._addCheck({
43680
- kind: "max",
43681
- value: 0,
43682
- inclusive: false,
43683
- message: errorUtil2.toString(message)
43684
- });
43685
- }
43686
- nonpositive(message) {
43687
- return this._addCheck({
43688
- kind: "max",
43689
- value: 0,
43690
- inclusive: true,
43691
- message: errorUtil2.toString(message)
43692
- });
43693
- }
43694
- nonnegative(message) {
43695
- return this._addCheck({
43696
- kind: "min",
43697
- value: 0,
43698
- inclusive: true,
43699
- message: errorUtil2.toString(message)
43700
- });
43701
- }
43702
- multipleOf(value, message) {
43703
- return this._addCheck({
43704
- kind: "multipleOf",
43705
- value,
43706
- message: errorUtil2.toString(message)
43707
- });
43708
- }
43709
- finite(message) {
43710
- return this._addCheck({
43711
- kind: "finite",
43712
- message: errorUtil2.toString(message)
43713
- });
43714
- }
43715
- safe(message) {
43716
- return this._addCheck({
43717
- kind: "min",
43718
- inclusive: true,
43719
- value: Number.MIN_SAFE_INTEGER,
43720
- message: errorUtil2.toString(message)
43721
- })._addCheck({
43722
- kind: "max",
43723
- inclusive: true,
43724
- value: Number.MAX_SAFE_INTEGER,
43725
- message: errorUtil2.toString(message)
43726
- });
43727
- }
43728
- get minValue() {
43729
- let min = null;
43730
- for (const ch of this._def.checks) {
43731
- if (ch.kind === "min") {
43732
- if (min === null || ch.value > min)
43733
- min = ch.value;
43734
- }
43735
- }
43736
- return min;
43737
- }
43738
- get maxValue() {
43739
- let max = null;
43740
- for (const ch of this._def.checks) {
43741
- if (ch.kind === "max") {
43742
- if (max === null || ch.value < max)
43743
- max = ch.value;
43744
- }
43745
- }
43746
- return max;
43747
- }
43748
- get isInt() {
43749
- return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util2.isInteger(ch.value));
43750
- }
43751
- get isFinite() {
43752
- let max = null;
43753
- let min = null;
43754
- for (const ch of this._def.checks) {
43755
- if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
43756
- return true;
43757
- } else if (ch.kind === "min") {
43758
- if (min === null || ch.value > min)
43759
- min = ch.value;
43760
- } else if (ch.kind === "max") {
43761
- if (max === null || ch.value < max)
43762
- max = ch.value;
43763
- }
43764
- }
43765
- return Number.isFinite(min) && Number.isFinite(max);
43766
- }
43767
- };
43768
- ZodNumber3.create = (params) => {
43769
- return new ZodNumber3({
43770
- checks: [],
43771
- typeName: ZodFirstPartyTypeKind3.ZodNumber,
43772
- coerce: params?.coerce || false,
43773
- ...processCreateParams2(params)
43774
- });
43775
- };
43776
- var ZodBigInt3 = class _ZodBigInt extends ZodType3 {
43777
- constructor() {
43778
- super(...arguments);
43779
- this.min = this.gte;
43780
- this.max = this.lte;
43781
- }
43782
- _parse(input) {
43783
- if (this._def.coerce) {
43784
- try {
43785
- input.data = BigInt(input.data);
43786
- } catch {
43787
- return this._getInvalidInput(input);
43788
- }
43789
- }
43790
- const parsedType2 = this._getType(input);
43791
- if (parsedType2 !== ZodParsedType2.bigint) {
43792
- return this._getInvalidInput(input);
43793
- }
43794
- let ctx = void 0;
43795
- const status = new ParseStatus2();
43796
- for (const check2 of this._def.checks) {
43797
- if (check2.kind === "min") {
43798
- const tooSmall = check2.inclusive ? input.data < check2.value : input.data <= check2.value;
43799
- if (tooSmall) {
43800
- ctx = this._getOrReturnCtx(input, ctx);
43801
- addIssueToContext2(ctx, {
43802
- code: ZodIssueCode3.too_small,
43803
- type: "bigint",
43804
- minimum: check2.value,
43805
- inclusive: check2.inclusive,
43806
- message: check2.message
43807
- });
43808
- status.dirty();
43809
- }
43810
- } else if (check2.kind === "max") {
43811
- const tooBig = check2.inclusive ? input.data > check2.value : input.data >= check2.value;
43812
- if (tooBig) {
43813
- ctx = this._getOrReturnCtx(input, ctx);
43814
- addIssueToContext2(ctx, {
43815
- code: ZodIssueCode3.too_big,
43816
- type: "bigint",
43817
- maximum: check2.value,
43818
- inclusive: check2.inclusive,
43819
- message: check2.message
43820
- });
43821
- status.dirty();
43822
- }
43823
- } else if (check2.kind === "multipleOf") {
43824
- if (input.data % check2.value !== BigInt(0)) {
43825
- ctx = this._getOrReturnCtx(input, ctx);
43826
- addIssueToContext2(ctx, {
43827
- code: ZodIssueCode3.not_multiple_of,
43828
- multipleOf: check2.value,
43829
- message: check2.message
43830
- });
43831
- status.dirty();
43832
- }
43833
- } else {
43834
- util2.assertNever(check2);
43835
- }
43836
- }
43837
- return { status: status.value, value: input.data };
43838
- }
43839
- _getInvalidInput(input) {
43840
- const ctx = this._getOrReturnCtx(input);
43841
- addIssueToContext2(ctx, {
43842
- code: ZodIssueCode3.invalid_type,
43843
- expected: ZodParsedType2.bigint,
43844
- received: ctx.parsedType
43845
- });
43846
- return INVALID2;
43847
- }
43848
- gte(value, message) {
43849
- return this.setLimit("min", value, true, errorUtil2.toString(message));
43850
- }
43851
- gt(value, message) {
43852
- return this.setLimit("min", value, false, errorUtil2.toString(message));
43853
- }
43854
- lte(value, message) {
43855
- return this.setLimit("max", value, true, errorUtil2.toString(message));
43856
- }
43857
- lt(value, message) {
43858
- return this.setLimit("max", value, false, errorUtil2.toString(message));
43859
- }
43860
- setLimit(kind, value, inclusive, message) {
43861
- return new _ZodBigInt({
43862
- ...this._def,
43863
- checks: [
43864
- ...this._def.checks,
43865
- {
43866
- kind,
43867
- value,
43868
- inclusive,
43869
- message: errorUtil2.toString(message)
43870
- }
43871
- ]
43872
- });
43873
- }
43874
- _addCheck(check2) {
43875
- return new _ZodBigInt({
43876
- ...this._def,
43877
- checks: [...this._def.checks, check2]
43878
- });
43879
- }
43880
- positive(message) {
43881
- return this._addCheck({
43882
- kind: "min",
43883
- value: BigInt(0),
43884
- inclusive: false,
43885
- message: errorUtil2.toString(message)
43886
- });
43887
- }
43888
- negative(message) {
43889
- return this._addCheck({
43890
- kind: "max",
43891
- value: BigInt(0),
43892
- inclusive: false,
43893
- message: errorUtil2.toString(message)
43894
- });
43895
- }
43896
- nonpositive(message) {
43897
- return this._addCheck({
43898
- kind: "max",
43899
- value: BigInt(0),
43900
- inclusive: true,
43901
- message: errorUtil2.toString(message)
43902
- });
43903
- }
43904
- nonnegative(message) {
43905
- return this._addCheck({
43906
- kind: "min",
43907
- value: BigInt(0),
43908
- inclusive: true,
43909
- message: errorUtil2.toString(message)
43910
- });
43911
- }
43912
- multipleOf(value, message) {
43913
- return this._addCheck({
43914
- kind: "multipleOf",
43915
- value,
43916
- message: errorUtil2.toString(message)
43917
- });
43918
- }
43919
- get minValue() {
43920
- let min = null;
43921
- for (const ch of this._def.checks) {
43922
- if (ch.kind === "min") {
43923
- if (min === null || ch.value > min)
43924
- min = ch.value;
43925
- }
43926
- }
43927
- return min;
43928
- }
43929
- get maxValue() {
43930
- let max = null;
43931
- for (const ch of this._def.checks) {
43932
- if (ch.kind === "max") {
43933
- if (max === null || ch.value < max)
43934
- max = ch.value;
43935
- }
43936
- }
43937
- return max;
43938
- }
43939
- };
43940
- ZodBigInt3.create = (params) => {
43941
- return new ZodBigInt3({
43942
- checks: [],
43943
- typeName: ZodFirstPartyTypeKind3.ZodBigInt,
43944
- coerce: params?.coerce ?? false,
43945
- ...processCreateParams2(params)
43946
- });
43947
- };
43948
- var ZodBoolean3 = class extends ZodType3 {
43949
- _parse(input) {
43950
- if (this._def.coerce) {
43951
- input.data = Boolean(input.data);
43952
- }
43953
- const parsedType2 = this._getType(input);
43954
- if (parsedType2 !== ZodParsedType2.boolean) {
43955
- const ctx = this._getOrReturnCtx(input);
43956
- addIssueToContext2(ctx, {
43957
- code: ZodIssueCode3.invalid_type,
43958
- expected: ZodParsedType2.boolean,
43959
- received: ctx.parsedType
43960
- });
43961
- return INVALID2;
43962
- }
43963
- return OK2(input.data);
43964
- }
43965
- };
43966
- ZodBoolean3.create = (params) => {
43967
- return new ZodBoolean3({
43968
- typeName: ZodFirstPartyTypeKind3.ZodBoolean,
43969
- coerce: params?.coerce || false,
43970
- ...processCreateParams2(params)
43971
- });
43972
- };
43973
- var ZodDate3 = class _ZodDate extends ZodType3 {
43974
- _parse(input) {
43975
- if (this._def.coerce) {
43976
- input.data = new Date(input.data);
43977
- }
43978
- const parsedType2 = this._getType(input);
43979
- if (parsedType2 !== ZodParsedType2.date) {
43980
- const ctx2 = this._getOrReturnCtx(input);
43981
- addIssueToContext2(ctx2, {
43982
- code: ZodIssueCode3.invalid_type,
43983
- expected: ZodParsedType2.date,
43984
- received: ctx2.parsedType
43985
- });
43986
- return INVALID2;
43987
- }
43988
- if (Number.isNaN(input.data.getTime())) {
43989
- const ctx2 = this._getOrReturnCtx(input);
43990
- addIssueToContext2(ctx2, {
43991
- code: ZodIssueCode3.invalid_date
43992
- });
43993
- return INVALID2;
43994
- }
43995
- const status = new ParseStatus2();
43996
- let ctx = void 0;
43997
- for (const check2 of this._def.checks) {
43998
- if (check2.kind === "min") {
43999
- if (input.data.getTime() < check2.value) {
44000
- ctx = this._getOrReturnCtx(input, ctx);
44001
- addIssueToContext2(ctx, {
44002
- code: ZodIssueCode3.too_small,
44003
- message: check2.message,
44004
- inclusive: true,
44005
- exact: false,
44006
- minimum: check2.value,
44007
- type: "date"
44008
- });
44009
- status.dirty();
44010
- }
44011
- } else if (check2.kind === "max") {
44012
- if (input.data.getTime() > check2.value) {
44013
- ctx = this._getOrReturnCtx(input, ctx);
44014
- addIssueToContext2(ctx, {
44015
- code: ZodIssueCode3.too_big,
44016
- message: check2.message,
44017
- inclusive: true,
44018
- exact: false,
44019
- maximum: check2.value,
44020
- type: "date"
44021
- });
44022
- status.dirty();
44023
- }
44024
- } else {
44025
- util2.assertNever(check2);
44026
- }
44027
- }
44028
- return {
44029
- status: status.value,
44030
- value: new Date(input.data.getTime())
44031
- };
44032
- }
44033
- _addCheck(check2) {
44034
- return new _ZodDate({
44035
- ...this._def,
44036
- checks: [...this._def.checks, check2]
44037
- });
44038
- }
44039
- min(minDate, message) {
44040
- return this._addCheck({
44041
- kind: "min",
44042
- value: minDate.getTime(),
44043
- message: errorUtil2.toString(message)
44044
- });
44045
- }
44046
- max(maxDate, message) {
44047
- return this._addCheck({
44048
- kind: "max",
44049
- value: maxDate.getTime(),
44050
- message: errorUtil2.toString(message)
44051
- });
44052
- }
44053
- get minDate() {
44054
- let min = null;
44055
- for (const ch of this._def.checks) {
44056
- if (ch.kind === "min") {
44057
- if (min === null || ch.value > min)
44058
- min = ch.value;
44059
- }
44060
- }
44061
- return min != null ? new Date(min) : null;
44062
- }
44063
- get maxDate() {
44064
- let max = null;
44065
- for (const ch of this._def.checks) {
44066
- if (ch.kind === "max") {
44067
- if (max === null || ch.value < max)
44068
- max = ch.value;
44069
- }
44070
- }
44071
- return max != null ? new Date(max) : null;
44072
- }
44073
- };
44074
- ZodDate3.create = (params) => {
44075
- return new ZodDate3({
44076
- checks: [],
44077
- coerce: params?.coerce || false,
44078
- typeName: ZodFirstPartyTypeKind3.ZodDate,
44079
- ...processCreateParams2(params)
44080
- });
44081
- };
44082
- var ZodSymbol3 = class extends ZodType3 {
44083
- _parse(input) {
44084
- const parsedType2 = this._getType(input);
44085
- if (parsedType2 !== ZodParsedType2.symbol) {
44086
- const ctx = this._getOrReturnCtx(input);
44087
- addIssueToContext2(ctx, {
44088
- code: ZodIssueCode3.invalid_type,
44089
- expected: ZodParsedType2.symbol,
44090
- received: ctx.parsedType
44091
- });
44092
- return INVALID2;
44093
- }
44094
- return OK2(input.data);
44095
- }
44096
- };
44097
- ZodSymbol3.create = (params) => {
44098
- return new ZodSymbol3({
44099
- typeName: ZodFirstPartyTypeKind3.ZodSymbol,
44100
- ...processCreateParams2(params)
44101
- });
44102
- };
44103
- var ZodUndefined3 = class extends ZodType3 {
44104
- _parse(input) {
44105
- const parsedType2 = this._getType(input);
44106
- if (parsedType2 !== ZodParsedType2.undefined) {
44107
- const ctx = this._getOrReturnCtx(input);
44108
- addIssueToContext2(ctx, {
44109
- code: ZodIssueCode3.invalid_type,
44110
- expected: ZodParsedType2.undefined,
44111
- received: ctx.parsedType
44112
- });
44113
- return INVALID2;
44114
- }
44115
- return OK2(input.data);
44116
- }
44117
- };
44118
- ZodUndefined3.create = (params) => {
44119
- return new ZodUndefined3({
44120
- typeName: ZodFirstPartyTypeKind3.ZodUndefined,
44121
- ...processCreateParams2(params)
44122
- });
44123
- };
44124
- var ZodNull3 = class extends ZodType3 {
44125
- _parse(input) {
44126
- const parsedType2 = this._getType(input);
44127
- if (parsedType2 !== ZodParsedType2.null) {
44128
- const ctx = this._getOrReturnCtx(input);
44129
- addIssueToContext2(ctx, {
44130
- code: ZodIssueCode3.invalid_type,
44131
- expected: ZodParsedType2.null,
44132
- received: ctx.parsedType
44133
- });
44134
- return INVALID2;
44135
- }
44136
- return OK2(input.data);
44137
- }
44138
- };
44139
- ZodNull3.create = (params) => {
44140
- return new ZodNull3({
44141
- typeName: ZodFirstPartyTypeKind3.ZodNull,
44142
- ...processCreateParams2(params)
44143
- });
44144
- };
44145
- var ZodAny3 = class extends ZodType3 {
44146
- constructor() {
44147
- super(...arguments);
44148
- this._any = true;
44149
- }
44150
- _parse(input) {
44151
- return OK2(input.data);
44152
- }
44153
- };
44154
- ZodAny3.create = (params) => {
44155
- return new ZodAny3({
44156
- typeName: ZodFirstPartyTypeKind3.ZodAny,
44157
- ...processCreateParams2(params)
44158
- });
44159
- };
44160
- var ZodUnknown3 = class extends ZodType3 {
44161
- constructor() {
44162
- super(...arguments);
44163
- this._unknown = true;
44164
- }
44165
- _parse(input) {
44166
- return OK2(input.data);
44167
- }
44168
- };
44169
- ZodUnknown3.create = (params) => {
44170
- return new ZodUnknown3({
44171
- typeName: ZodFirstPartyTypeKind3.ZodUnknown,
44172
- ...processCreateParams2(params)
44173
- });
44174
- };
44175
- var ZodNever3 = class extends ZodType3 {
44176
- _parse(input) {
44177
- const ctx = this._getOrReturnCtx(input);
44178
- addIssueToContext2(ctx, {
44179
- code: ZodIssueCode3.invalid_type,
44180
- expected: ZodParsedType2.never,
44181
- received: ctx.parsedType
44182
- });
44183
- return INVALID2;
44184
- }
44185
- };
44186
- ZodNever3.create = (params) => {
44187
- return new ZodNever3({
44188
- typeName: ZodFirstPartyTypeKind3.ZodNever,
44189
- ...processCreateParams2(params)
44190
- });
44191
- };
44192
- var ZodVoid3 = class extends ZodType3 {
44193
- _parse(input) {
44194
- const parsedType2 = this._getType(input);
44195
- if (parsedType2 !== ZodParsedType2.undefined) {
44196
- const ctx = this._getOrReturnCtx(input);
44197
- addIssueToContext2(ctx, {
44198
- code: ZodIssueCode3.invalid_type,
44199
- expected: ZodParsedType2.void,
44200
- received: ctx.parsedType
44201
- });
44202
- return INVALID2;
44203
- }
44204
- return OK2(input.data);
44205
- }
44206
- };
44207
- ZodVoid3.create = (params) => {
44208
- return new ZodVoid3({
44209
- typeName: ZodFirstPartyTypeKind3.ZodVoid,
44210
- ...processCreateParams2(params)
44211
- });
44212
- };
44213
- var ZodArray3 = class _ZodArray extends ZodType3 {
44214
- _parse(input) {
44215
- const { ctx, status } = this._processInputParams(input);
44216
- const def = this._def;
44217
- if (ctx.parsedType !== ZodParsedType2.array) {
44218
- addIssueToContext2(ctx, {
44219
- code: ZodIssueCode3.invalid_type,
44220
- expected: ZodParsedType2.array,
44221
- received: ctx.parsedType
44222
- });
44223
- return INVALID2;
44224
- }
44225
- if (def.exactLength !== null) {
44226
- const tooBig = ctx.data.length > def.exactLength.value;
44227
- const tooSmall = ctx.data.length < def.exactLength.value;
44228
- if (tooBig || tooSmall) {
44229
- addIssueToContext2(ctx, {
44230
- code: tooBig ? ZodIssueCode3.too_big : ZodIssueCode3.too_small,
44231
- minimum: tooSmall ? def.exactLength.value : void 0,
44232
- maximum: tooBig ? def.exactLength.value : void 0,
44233
- type: "array",
44234
- inclusive: true,
44235
- exact: true,
44236
- message: def.exactLength.message
44237
- });
44238
- status.dirty();
44239
- }
44240
- }
44241
- if (def.minLength !== null) {
44242
- if (ctx.data.length < def.minLength.value) {
44243
- addIssueToContext2(ctx, {
44244
- code: ZodIssueCode3.too_small,
44245
- minimum: def.minLength.value,
44246
- type: "array",
44247
- inclusive: true,
44248
- exact: false,
44249
- message: def.minLength.message
44250
- });
44251
- status.dirty();
44252
- }
44253
- }
44254
- if (def.maxLength !== null) {
44255
- if (ctx.data.length > def.maxLength.value) {
44256
- addIssueToContext2(ctx, {
44257
- code: ZodIssueCode3.too_big,
44258
- maximum: def.maxLength.value,
44259
- type: "array",
44260
- inclusive: true,
44261
- exact: false,
44262
- message: def.maxLength.message
44263
- });
44264
- status.dirty();
44265
- }
44266
- }
44267
- if (ctx.common.async) {
44268
- return Promise.all([...ctx.data].map((item, i) => {
44269
- return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
44270
- })).then((result2) => {
44271
- return ParseStatus2.mergeArray(status, result2);
44272
- });
44273
- }
44274
- const result = [...ctx.data].map((item, i) => {
44275
- return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
44276
- });
44277
- return ParseStatus2.mergeArray(status, result);
44278
- }
44279
- get element() {
44280
- return this._def.type;
44281
- }
44282
- min(minLength, message) {
44283
- return new _ZodArray({
44284
- ...this._def,
44285
- minLength: { value: minLength, message: errorUtil2.toString(message) }
44286
- });
44287
- }
44288
- max(maxLength, message) {
44289
- return new _ZodArray({
44290
- ...this._def,
44291
- maxLength: { value: maxLength, message: errorUtil2.toString(message) }
44292
- });
44293
- }
44294
- length(len, message) {
44295
- return new _ZodArray({
44296
- ...this._def,
44297
- exactLength: { value: len, message: errorUtil2.toString(message) }
44298
- });
44299
- }
44300
- nonempty(message) {
44301
- return this.min(1, message);
44302
- }
44303
- };
44304
- ZodArray3.create = (schema, params) => {
44305
- return new ZodArray3({
44306
- type: schema,
44307
- minLength: null,
44308
- maxLength: null,
44309
- exactLength: null,
44310
- typeName: ZodFirstPartyTypeKind3.ZodArray,
44311
- ...processCreateParams2(params)
44312
- });
44313
- };
44314
- function deepPartialify2(schema) {
44315
- if (schema instanceof ZodObject3) {
44316
- const newShape = {};
44317
- for (const key in schema.shape) {
44318
- const fieldSchema = schema.shape[key];
44319
- newShape[key] = ZodOptional3.create(deepPartialify2(fieldSchema));
44320
- }
44321
- return new ZodObject3({
44322
- ...schema._def,
44323
- shape: () => newShape
44324
- });
44325
- } else if (schema instanceof ZodArray3) {
44326
- return new ZodArray3({
44327
- ...schema._def,
44328
- type: deepPartialify2(schema.element)
44329
- });
44330
- } else if (schema instanceof ZodOptional3) {
44331
- return ZodOptional3.create(deepPartialify2(schema.unwrap()));
44332
- } else if (schema instanceof ZodNullable3) {
44333
- return ZodNullable3.create(deepPartialify2(schema.unwrap()));
44334
- } else if (schema instanceof ZodTuple3) {
44335
- return ZodTuple3.create(schema.items.map((item) => deepPartialify2(item)));
44336
- } else {
44337
- return schema;
44338
- }
44339
- }
44340
- var ZodObject3 = class _ZodObject extends ZodType3 {
44341
- constructor() {
44342
- super(...arguments);
44343
- this._cached = null;
44344
- this.nonstrict = this.passthrough;
44345
- this.augment = this.extend;
44346
- }
44347
- _getCached() {
44348
- if (this._cached !== null)
44349
- return this._cached;
44350
- const shape = this._def.shape();
44351
- const keys = util2.objectKeys(shape);
44352
- this._cached = { shape, keys };
44353
- return this._cached;
44354
- }
44355
- _parse(input) {
44356
- const parsedType2 = this._getType(input);
44357
- if (parsedType2 !== ZodParsedType2.object) {
44358
- const ctx2 = this._getOrReturnCtx(input);
44359
- addIssueToContext2(ctx2, {
44360
- code: ZodIssueCode3.invalid_type,
44361
- expected: ZodParsedType2.object,
44362
- received: ctx2.parsedType
44363
- });
44364
- return INVALID2;
44365
- }
44366
- const { status, ctx } = this._processInputParams(input);
44367
- const { shape, keys: shapeKeys } = this._getCached();
44368
- const extraKeys = [];
44369
- if (!(this._def.catchall instanceof ZodNever3 && this._def.unknownKeys === "strip")) {
44370
- for (const key in ctx.data) {
44371
- if (!shapeKeys.includes(key)) {
44372
- extraKeys.push(key);
44373
- }
44374
- }
44375
- }
44376
- const pairs = [];
44377
- for (const key of shapeKeys) {
44378
- const keyValidator = shape[key];
44379
- const value = ctx.data[key];
44380
- pairs.push({
44381
- key: { status: "valid", value: key },
44382
- value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
44383
- alwaysSet: key in ctx.data
44384
- });
44385
- }
44386
- if (this._def.catchall instanceof ZodNever3) {
44387
- const unknownKeys = this._def.unknownKeys;
44388
- if (unknownKeys === "passthrough") {
44389
- for (const key of extraKeys) {
44390
- pairs.push({
44391
- key: { status: "valid", value: key },
44392
- value: { status: "valid", value: ctx.data[key] }
44393
- });
44394
- }
44395
- } else if (unknownKeys === "strict") {
44396
- if (extraKeys.length > 0) {
44397
- addIssueToContext2(ctx, {
44398
- code: ZodIssueCode3.unrecognized_keys,
44399
- keys: extraKeys
44400
- });
44401
- status.dirty();
44402
- }
44403
- } else if (unknownKeys === "strip") {
44404
- } else {
44405
- throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
44406
- }
44407
- } else {
44408
- const catchall = this._def.catchall;
44409
- for (const key of extraKeys) {
44410
- const value = ctx.data[key];
44411
- pairs.push({
44412
- key: { status: "valid", value: key },
44413
- value: catchall._parse(
44414
- new ParseInputLazyPath2(ctx, value, ctx.path, key)
44415
- //, ctx.child(key), value, getParsedType(value)
44416
- ),
44417
- alwaysSet: key in ctx.data
44418
- });
44419
- }
44420
- }
44421
- if (ctx.common.async) {
44422
- return Promise.resolve().then(async () => {
44423
- const syncPairs = [];
44424
- for (const pair of pairs) {
44425
- const key = await pair.key;
44426
- const value = await pair.value;
44427
- syncPairs.push({
44428
- key,
44429
- value,
44430
- alwaysSet: pair.alwaysSet
44431
- });
44432
- }
44433
- return syncPairs;
44434
- }).then((syncPairs) => {
44435
- return ParseStatus2.mergeObjectSync(status, syncPairs);
44436
- });
44437
- } else {
44438
- return ParseStatus2.mergeObjectSync(status, pairs);
44439
- }
44440
- }
44441
- get shape() {
44442
- return this._def.shape();
44443
- }
44444
- strict(message) {
44445
- errorUtil2.errToObj;
44446
- return new _ZodObject({
44447
- ...this._def,
44448
- unknownKeys: "strict",
44449
- ...message !== void 0 ? {
44450
- errorMap: (issue2, ctx) => {
44451
- const defaultError = this._def.errorMap?.(issue2, ctx).message ?? ctx.defaultError;
44452
- if (issue2.code === "unrecognized_keys")
44453
- return {
44454
- message: errorUtil2.errToObj(message).message ?? defaultError
44455
- };
44456
- return {
44457
- message: defaultError
44458
- };
44459
- }
44460
- } : {}
44461
- });
44462
- }
44463
- strip() {
44464
- return new _ZodObject({
44465
- ...this._def,
44466
- unknownKeys: "strip"
44467
- });
44468
- }
44469
- passthrough() {
44470
- return new _ZodObject({
44471
- ...this._def,
44472
- unknownKeys: "passthrough"
44473
- });
44474
- }
44475
- // const AugmentFactory =
44476
- // <Def extends ZodObjectDef>(def: Def) =>
44477
- // <Augmentation extends ZodRawShape>(
44478
- // augmentation: Augmentation
44479
- // ): ZodObject<
44480
- // extendShape<ReturnType<Def["shape"]>, Augmentation>,
44481
- // Def["unknownKeys"],
44482
- // Def["catchall"]
44483
- // > => {
44484
- // return new ZodObject({
44485
- // ...def,
44486
- // shape: () => ({
44487
- // ...def.shape(),
44488
- // ...augmentation,
44489
- // }),
44490
- // }) as any;
44491
- // };
44492
- extend(augmentation) {
44493
- return new _ZodObject({
44494
- ...this._def,
44495
- shape: () => ({
44496
- ...this._def.shape(),
44497
- ...augmentation
44498
- })
44499
- });
44500
- }
44501
- /**
44502
- * Prior to zod@1.0.12 there was a bug in the
44503
- * inferred type of merged objects. Please
44504
- * upgrade if you are experiencing issues.
44505
- */
44506
- merge(merging) {
44507
- const merged = new _ZodObject({
44508
- unknownKeys: merging._def.unknownKeys,
44509
- catchall: merging._def.catchall,
44510
- shape: () => ({
44511
- ...this._def.shape(),
44512
- ...merging._def.shape()
44513
- }),
44514
- typeName: ZodFirstPartyTypeKind3.ZodObject
44515
- });
44516
- return merged;
44517
- }
44518
- // merge<
44519
- // Incoming extends AnyZodObject,
44520
- // Augmentation extends Incoming["shape"],
44521
- // NewOutput extends {
44522
- // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
44523
- // ? Augmentation[k]["_output"]
44524
- // : k extends keyof Output
44525
- // ? Output[k]
44526
- // : never;
44527
- // },
44528
- // NewInput extends {
44529
- // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
44530
- // ? Augmentation[k]["_input"]
44531
- // : k extends keyof Input
44532
- // ? Input[k]
44533
- // : never;
44534
- // }
44535
- // >(
44536
- // merging: Incoming
44537
- // ): ZodObject<
44538
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
44539
- // Incoming["_def"]["unknownKeys"],
44540
- // Incoming["_def"]["catchall"],
44541
- // NewOutput,
44542
- // NewInput
44543
- // > {
44544
- // const merged: any = new ZodObject({
44545
- // unknownKeys: merging._def.unknownKeys,
44546
- // catchall: merging._def.catchall,
44547
- // shape: () =>
44548
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
44549
- // typeName: ZodFirstPartyTypeKind.ZodObject,
44550
- // }) as any;
44551
- // return merged;
44552
- // }
44553
- setKey(key, schema) {
44554
- return this.augment({ [key]: schema });
44555
- }
44556
- // merge<Incoming extends AnyZodObject>(
44557
- // merging: Incoming
44558
- // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
44559
- // ZodObject<
44560
- // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
44561
- // Incoming["_def"]["unknownKeys"],
44562
- // Incoming["_def"]["catchall"]
44563
- // > {
44564
- // // const mergedShape = objectUtil.mergeShapes(
44565
- // // this._def.shape(),
44566
- // // merging._def.shape()
44567
- // // );
44568
- // const merged: any = new ZodObject({
44569
- // unknownKeys: merging._def.unknownKeys,
44570
- // catchall: merging._def.catchall,
44571
- // shape: () =>
44572
- // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
44573
- // typeName: ZodFirstPartyTypeKind.ZodObject,
44574
- // }) as any;
44575
- // return merged;
44576
- // }
44577
- catchall(index) {
44578
- return new _ZodObject({
44579
- ...this._def,
44580
- catchall: index
44581
- });
44582
- }
44583
- pick(mask) {
44584
- const shape = {};
44585
- for (const key of util2.objectKeys(mask)) {
44586
- if (mask[key] && this.shape[key]) {
44587
- shape[key] = this.shape[key];
44588
- }
44589
- }
44590
- return new _ZodObject({
44591
- ...this._def,
44592
- shape: () => shape
44593
- });
44594
- }
44595
- omit(mask) {
44596
- const shape = {};
44597
- for (const key of util2.objectKeys(this.shape)) {
44598
- if (!mask[key]) {
44599
- shape[key] = this.shape[key];
44600
- }
44601
- }
44602
- return new _ZodObject({
44603
- ...this._def,
44604
- shape: () => shape
44605
- });
44606
- }
44607
- /**
44608
- * @deprecated
44609
- */
44610
- deepPartial() {
44611
- return deepPartialify2(this);
44612
- }
44613
- partial(mask) {
44614
- const newShape = {};
44615
- for (const key of util2.objectKeys(this.shape)) {
44616
- const fieldSchema = this.shape[key];
44617
- if (mask && !mask[key]) {
44618
- newShape[key] = fieldSchema;
44619
- } else {
44620
- newShape[key] = fieldSchema.optional();
44621
- }
44622
- }
44623
- return new _ZodObject({
44624
- ...this._def,
44625
- shape: () => newShape
44626
- });
44627
- }
44628
- required(mask) {
44629
- const newShape = {};
44630
- for (const key of util2.objectKeys(this.shape)) {
44631
- if (mask && !mask[key]) {
44632
- newShape[key] = this.shape[key];
44633
- } else {
44634
- const fieldSchema = this.shape[key];
44635
- let newField = fieldSchema;
44636
- while (newField instanceof ZodOptional3) {
44637
- newField = newField._def.innerType;
44638
- }
44639
- newShape[key] = newField;
44640
- }
44641
- }
44642
- return new _ZodObject({
44643
- ...this._def,
44644
- shape: () => newShape
44645
- });
44646
- }
44647
- keyof() {
44648
- return createZodEnum2(util2.objectKeys(this.shape));
44649
- }
44650
- };
44651
- ZodObject3.create = (shape, params) => {
44652
- return new ZodObject3({
44653
- shape: () => shape,
44654
- unknownKeys: "strip",
44655
- catchall: ZodNever3.create(),
44656
- typeName: ZodFirstPartyTypeKind3.ZodObject,
44657
- ...processCreateParams2(params)
44658
- });
44659
- };
44660
- ZodObject3.strictCreate = (shape, params) => {
44661
- return new ZodObject3({
44662
- shape: () => shape,
44663
- unknownKeys: "strict",
44664
- catchall: ZodNever3.create(),
44665
- typeName: ZodFirstPartyTypeKind3.ZodObject,
44666
- ...processCreateParams2(params)
44667
- });
44668
- };
44669
- ZodObject3.lazycreate = (shape, params) => {
44670
- return new ZodObject3({
44671
- shape,
44672
- unknownKeys: "strip",
44673
- catchall: ZodNever3.create(),
44674
- typeName: ZodFirstPartyTypeKind3.ZodObject,
44675
- ...processCreateParams2(params)
44676
- });
44677
- };
44678
- var ZodUnion3 = class extends ZodType3 {
44679
- _parse(input) {
44680
- const { ctx } = this._processInputParams(input);
44681
- const options = this._def.options;
44682
- function handleResults(results) {
44683
- for (const result of results) {
44684
- if (result.result.status === "valid") {
44685
- return result.result;
44686
- }
44687
- }
44688
- for (const result of results) {
44689
- if (result.result.status === "dirty") {
44690
- ctx.common.issues.push(...result.ctx.common.issues);
44691
- return result.result;
44692
- }
44693
- }
44694
- const unionErrors = results.map((result) => new ZodError3(result.ctx.common.issues));
44695
- addIssueToContext2(ctx, {
44696
- code: ZodIssueCode3.invalid_union,
44697
- unionErrors
44698
- });
44699
- return INVALID2;
44700
- }
44701
- if (ctx.common.async) {
44702
- return Promise.all(options.map(async (option) => {
44703
- const childCtx = {
44704
- ...ctx,
44705
- common: {
44706
- ...ctx.common,
44707
- issues: []
44708
- },
44709
- parent: null
44710
- };
44711
- return {
44712
- result: await option._parseAsync({
44713
- data: ctx.data,
44714
- path: ctx.path,
44715
- parent: childCtx
44716
- }),
44717
- ctx: childCtx
44718
- };
44719
- })).then(handleResults);
44720
- } else {
44721
- let dirty = void 0;
44722
- const issues = [];
44723
- for (const option of options) {
44724
- const childCtx = {
44725
- ...ctx,
44726
- common: {
44727
- ...ctx.common,
44728
- issues: []
44729
- },
44730
- parent: null
44731
- };
44732
- const result = option._parseSync({
44733
- data: ctx.data,
44734
- path: ctx.path,
44735
- parent: childCtx
44736
- });
44737
- if (result.status === "valid") {
44738
- return result;
44739
- } else if (result.status === "dirty" && !dirty) {
44740
- dirty = { result, ctx: childCtx };
44741
- }
44742
- if (childCtx.common.issues.length) {
44743
- issues.push(childCtx.common.issues);
44744
- }
44745
- }
44746
- if (dirty) {
44747
- ctx.common.issues.push(...dirty.ctx.common.issues);
44748
- return dirty.result;
44749
- }
44750
- const unionErrors = issues.map((issues2) => new ZodError3(issues2));
44751
- addIssueToContext2(ctx, {
44752
- code: ZodIssueCode3.invalid_union,
44753
- unionErrors
44754
- });
44755
- return INVALID2;
44756
- }
44757
- }
44758
- get options() {
44759
- return this._def.options;
44760
- }
44761
- };
44762
- ZodUnion3.create = (types, params) => {
44763
- return new ZodUnion3({
44764
- options: types,
44765
- typeName: ZodFirstPartyTypeKind3.ZodUnion,
44766
- ...processCreateParams2(params)
44767
- });
44768
- };
44769
- var getDiscriminator2 = (type) => {
44770
- if (type instanceof ZodLazy3) {
44771
- return getDiscriminator2(type.schema);
44772
- } else if (type instanceof ZodEffects2) {
44773
- return getDiscriminator2(type.innerType());
44774
- } else if (type instanceof ZodLiteral3) {
44775
- return [type.value];
44776
- } else if (type instanceof ZodEnum3) {
44777
- return type.options;
44778
- } else if (type instanceof ZodNativeEnum2) {
44779
- return util2.objectValues(type.enum);
44780
- } else if (type instanceof ZodDefault3) {
44781
- return getDiscriminator2(type._def.innerType);
44782
- } else if (type instanceof ZodUndefined3) {
44783
- return [void 0];
44784
- } else if (type instanceof ZodNull3) {
44785
- return [null];
44786
- } else if (type instanceof ZodOptional3) {
44787
- return [void 0, ...getDiscriminator2(type.unwrap())];
44788
- } else if (type instanceof ZodNullable3) {
44789
- return [null, ...getDiscriminator2(type.unwrap())];
44790
- } else if (type instanceof ZodBranded2) {
44791
- return getDiscriminator2(type.unwrap());
44792
- } else if (type instanceof ZodReadonly3) {
44793
- return getDiscriminator2(type.unwrap());
44794
- } else if (type instanceof ZodCatch3) {
44795
- return getDiscriminator2(type._def.innerType);
44796
- } else {
44797
- return [];
44798
- }
44799
- };
44800
- var ZodDiscriminatedUnion3 = class _ZodDiscriminatedUnion extends ZodType3 {
44801
- _parse(input) {
44802
- const { ctx } = this._processInputParams(input);
44803
- if (ctx.parsedType !== ZodParsedType2.object) {
44804
- addIssueToContext2(ctx, {
44805
- code: ZodIssueCode3.invalid_type,
44806
- expected: ZodParsedType2.object,
44807
- received: ctx.parsedType
44808
- });
44809
- return INVALID2;
44810
- }
44811
- const discriminator = this.discriminator;
44812
- const discriminatorValue = ctx.data[discriminator];
44813
- const option = this.optionsMap.get(discriminatorValue);
44814
- if (!option) {
44815
- addIssueToContext2(ctx, {
44816
- code: ZodIssueCode3.invalid_union_discriminator,
44817
- options: Array.from(this.optionsMap.keys()),
44818
- path: [discriminator]
44819
- });
44820
- return INVALID2;
44821
- }
44822
- if (ctx.common.async) {
44823
- return option._parseAsync({
44824
- data: ctx.data,
44825
- path: ctx.path,
44826
- parent: ctx
44827
- });
44828
- } else {
44829
- return option._parseSync({
44830
- data: ctx.data,
44831
- path: ctx.path,
44832
- parent: ctx
44833
- });
44834
- }
44835
- }
44836
- get discriminator() {
44837
- return this._def.discriminator;
44838
- }
44839
- get options() {
44840
- return this._def.options;
44841
- }
44842
- get optionsMap() {
44843
- return this._def.optionsMap;
44844
- }
44845
- /**
44846
- * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
44847
- * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
44848
- * have a different value for each object in the union.
44849
- * @param discriminator the name of the discriminator property
44850
- * @param types an array of object schemas
44851
- * @param params
44852
- */
44853
- static create(discriminator, options, params) {
44854
- const optionsMap = /* @__PURE__ */ new Map();
44855
- for (const type of options) {
44856
- const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
44857
- if (!discriminatorValues.length) {
44858
- throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
44859
- }
44860
- for (const value of discriminatorValues) {
44861
- if (optionsMap.has(value)) {
44862
- throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
44863
- }
44864
- optionsMap.set(value, type);
44865
- }
44866
- }
44867
- return new _ZodDiscriminatedUnion({
44868
- typeName: ZodFirstPartyTypeKind3.ZodDiscriminatedUnion,
44869
- discriminator,
44870
- options,
44871
- optionsMap,
44872
- ...processCreateParams2(params)
44873
- });
44874
- }
44875
- };
44876
- function mergeValues3(a, b) {
44877
- const aType = getParsedType3(a);
44878
- const bType = getParsedType3(b);
44879
- if (a === b) {
44880
- return { valid: true, data: a };
44881
- } else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
44882
- const bKeys = util2.objectKeys(b);
44883
- const sharedKeys = util2.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
44884
- const newObj = { ...a, ...b };
44885
- for (const key of sharedKeys) {
44886
- const sharedValue = mergeValues3(a[key], b[key]);
44887
- if (!sharedValue.valid) {
44888
- return { valid: false };
44889
- }
44890
- newObj[key] = sharedValue.data;
44891
- }
44892
- return { valid: true, data: newObj };
44893
- } else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
44894
- if (a.length !== b.length) {
44895
- return { valid: false };
44896
- }
44897
- const newArray = [];
44898
- for (let index = 0; index < a.length; index++) {
44899
- const itemA = a[index];
44900
- const itemB = b[index];
44901
- const sharedValue = mergeValues3(itemA, itemB);
44902
- if (!sharedValue.valid) {
44903
- return { valid: false };
44904
- }
44905
- newArray.push(sharedValue.data);
44906
- }
44907
- return { valid: true, data: newArray };
44908
- } else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
44909
- return { valid: true, data: a };
44910
- } else {
44911
- return { valid: false };
44912
- }
44913
- }
44914
- var ZodIntersection3 = class extends ZodType3 {
44915
- _parse(input) {
44916
- const { status, ctx } = this._processInputParams(input);
44917
- const handleParsed = (parsedLeft, parsedRight) => {
44918
- if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
44919
- return INVALID2;
44920
- }
44921
- const merged = mergeValues3(parsedLeft.value, parsedRight.value);
44922
- if (!merged.valid) {
44923
- addIssueToContext2(ctx, {
44924
- code: ZodIssueCode3.invalid_intersection_types
44925
- });
44926
- return INVALID2;
44927
- }
44928
- if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
44929
- status.dirty();
44930
- }
44931
- return { status: status.value, value: merged.data };
44932
- };
44933
- if (ctx.common.async) {
44934
- return Promise.all([
44935
- this._def.left._parseAsync({
44936
- data: ctx.data,
44937
- path: ctx.path,
44938
- parent: ctx
44939
- }),
44940
- this._def.right._parseAsync({
44941
- data: ctx.data,
44942
- path: ctx.path,
44943
- parent: ctx
44944
- })
44945
- ]).then(([left, right]) => handleParsed(left, right));
44946
- } else {
44947
- return handleParsed(this._def.left._parseSync({
44948
- data: ctx.data,
44949
- path: ctx.path,
44950
- parent: ctx
44951
- }), this._def.right._parseSync({
44952
- data: ctx.data,
44953
- path: ctx.path,
44954
- parent: ctx
44955
- }));
44956
- }
44957
- }
44958
- };
44959
- ZodIntersection3.create = (left, right, params) => {
44960
- return new ZodIntersection3({
44961
- left,
44962
- right,
44963
- typeName: ZodFirstPartyTypeKind3.ZodIntersection,
44964
- ...processCreateParams2(params)
44965
- });
44966
- };
44967
- var ZodTuple3 = class _ZodTuple extends ZodType3 {
44968
- _parse(input) {
44969
- const { status, ctx } = this._processInputParams(input);
44970
- if (ctx.parsedType !== ZodParsedType2.array) {
44971
- addIssueToContext2(ctx, {
44972
- code: ZodIssueCode3.invalid_type,
44973
- expected: ZodParsedType2.array,
44974
- received: ctx.parsedType
44975
- });
44976
- return INVALID2;
44977
- }
44978
- if (ctx.data.length < this._def.items.length) {
44979
- addIssueToContext2(ctx, {
44980
- code: ZodIssueCode3.too_small,
44981
- minimum: this._def.items.length,
44982
- inclusive: true,
44983
- exact: false,
44984
- type: "array"
44985
- });
44986
- return INVALID2;
44987
- }
44988
- const rest = this._def.rest;
44989
- if (!rest && ctx.data.length > this._def.items.length) {
44990
- addIssueToContext2(ctx, {
44991
- code: ZodIssueCode3.too_big,
44992
- maximum: this._def.items.length,
44993
- inclusive: true,
44994
- exact: false,
44995
- type: "array"
44996
- });
44997
- status.dirty();
44998
- }
44999
- const items = [...ctx.data].map((item, itemIndex) => {
45000
- const schema = this._def.items[itemIndex] || this._def.rest;
45001
- if (!schema)
45002
- return null;
45003
- return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
45004
- }).filter((x) => !!x);
45005
- if (ctx.common.async) {
45006
- return Promise.all(items).then((results) => {
45007
- return ParseStatus2.mergeArray(status, results);
45008
- });
45009
- } else {
45010
- return ParseStatus2.mergeArray(status, items);
45011
- }
45012
- }
45013
- get items() {
45014
- return this._def.items;
45015
- }
45016
- rest(rest) {
45017
- return new _ZodTuple({
45018
- ...this._def,
45019
- rest
45020
- });
45021
- }
45022
- };
45023
- ZodTuple3.create = (schemas, params) => {
45024
- if (!Array.isArray(schemas)) {
45025
- throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
45026
- }
45027
- return new ZodTuple3({
45028
- items: schemas,
45029
- typeName: ZodFirstPartyTypeKind3.ZodTuple,
45030
- rest: null,
45031
- ...processCreateParams2(params)
45032
- });
45033
- };
45034
- var ZodRecord3 = class _ZodRecord extends ZodType3 {
45035
- get keySchema() {
45036
- return this._def.keyType;
45037
- }
45038
- get valueSchema() {
45039
- return this._def.valueType;
45040
- }
45041
- _parse(input) {
45042
- const { status, ctx } = this._processInputParams(input);
45043
- if (ctx.parsedType !== ZodParsedType2.object) {
45044
- addIssueToContext2(ctx, {
45045
- code: ZodIssueCode3.invalid_type,
45046
- expected: ZodParsedType2.object,
45047
- received: ctx.parsedType
45048
- });
45049
- return INVALID2;
45050
- }
45051
- const pairs = [];
45052
- const keyType = this._def.keyType;
45053
- const valueType = this._def.valueType;
45054
- for (const key in ctx.data) {
45055
- pairs.push({
45056
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
45057
- value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
45058
- alwaysSet: key in ctx.data
45059
- });
45060
- }
45061
- if (ctx.common.async) {
45062
- return ParseStatus2.mergeObjectAsync(status, pairs);
45063
- } else {
45064
- return ParseStatus2.mergeObjectSync(status, pairs);
45065
- }
45066
- }
45067
- get element() {
45068
- return this._def.valueType;
45069
- }
45070
- static create(first, second, third) {
45071
- if (second instanceof ZodType3) {
45072
- return new _ZodRecord({
45073
- keyType: first,
45074
- valueType: second,
45075
- typeName: ZodFirstPartyTypeKind3.ZodRecord,
45076
- ...processCreateParams2(third)
45077
- });
45078
- }
45079
- return new _ZodRecord({
45080
- keyType: ZodString3.create(),
45081
- valueType: first,
45082
- typeName: ZodFirstPartyTypeKind3.ZodRecord,
45083
- ...processCreateParams2(second)
45084
- });
45085
- }
45086
- };
45087
- var ZodMap3 = class extends ZodType3 {
45088
- get keySchema() {
45089
- return this._def.keyType;
45090
- }
45091
- get valueSchema() {
45092
- return this._def.valueType;
45093
- }
45094
- _parse(input) {
45095
- const { status, ctx } = this._processInputParams(input);
45096
- if (ctx.parsedType !== ZodParsedType2.map) {
45097
- addIssueToContext2(ctx, {
45098
- code: ZodIssueCode3.invalid_type,
45099
- expected: ZodParsedType2.map,
45100
- received: ctx.parsedType
45101
- });
45102
- return INVALID2;
45103
- }
45104
- const keyType = this._def.keyType;
45105
- const valueType = this._def.valueType;
45106
- const pairs = [...ctx.data.entries()].map(([key, value], index) => {
45107
- return {
45108
- key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
45109
- value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
45110
- };
45111
- });
45112
- if (ctx.common.async) {
45113
- const finalMap = /* @__PURE__ */ new Map();
45114
- return Promise.resolve().then(async () => {
45115
- for (const pair of pairs) {
45116
- const key = await pair.key;
45117
- const value = await pair.value;
45118
- if (key.status === "aborted" || value.status === "aborted") {
45119
- return INVALID2;
45120
- }
45121
- if (key.status === "dirty" || value.status === "dirty") {
45122
- status.dirty();
45123
- }
45124
- finalMap.set(key.value, value.value);
45125
- }
45126
- return { status: status.value, value: finalMap };
45127
- });
45128
- } else {
45129
- const finalMap = /* @__PURE__ */ new Map();
45130
- for (const pair of pairs) {
45131
- const key = pair.key;
45132
- const value = pair.value;
45133
- if (key.status === "aborted" || value.status === "aborted") {
45134
- return INVALID2;
45135
- }
45136
- if (key.status === "dirty" || value.status === "dirty") {
45137
- status.dirty();
45138
- }
45139
- finalMap.set(key.value, value.value);
45140
- }
45141
- return { status: status.value, value: finalMap };
45142
- }
45143
- }
45144
- };
45145
- ZodMap3.create = (keyType, valueType, params) => {
45146
- return new ZodMap3({
45147
- valueType,
45148
- keyType,
45149
- typeName: ZodFirstPartyTypeKind3.ZodMap,
45150
- ...processCreateParams2(params)
45151
- });
45152
- };
45153
- var ZodSet3 = class _ZodSet extends ZodType3 {
45154
- _parse(input) {
45155
- const { status, ctx } = this._processInputParams(input);
45156
- if (ctx.parsedType !== ZodParsedType2.set) {
45157
- addIssueToContext2(ctx, {
45158
- code: ZodIssueCode3.invalid_type,
45159
- expected: ZodParsedType2.set,
45160
- received: ctx.parsedType
45161
- });
45162
- return INVALID2;
45163
- }
45164
- const def = this._def;
45165
- if (def.minSize !== null) {
45166
- if (ctx.data.size < def.minSize.value) {
45167
- addIssueToContext2(ctx, {
45168
- code: ZodIssueCode3.too_small,
45169
- minimum: def.minSize.value,
45170
- type: "set",
45171
- inclusive: true,
45172
- exact: false,
45173
- message: def.minSize.message
45174
- });
45175
- status.dirty();
45176
- }
45177
- }
45178
- if (def.maxSize !== null) {
45179
- if (ctx.data.size > def.maxSize.value) {
45180
- addIssueToContext2(ctx, {
45181
- code: ZodIssueCode3.too_big,
45182
- maximum: def.maxSize.value,
45183
- type: "set",
45184
- inclusive: true,
45185
- exact: false,
45186
- message: def.maxSize.message
45187
- });
45188
- status.dirty();
45189
- }
45190
- }
45191
- const valueType = this._def.valueType;
45192
- function finalizeSet(elements2) {
45193
- const parsedSet = /* @__PURE__ */ new Set();
45194
- for (const element of elements2) {
45195
- if (element.status === "aborted")
45196
- return INVALID2;
45197
- if (element.status === "dirty")
45198
- status.dirty();
45199
- parsedSet.add(element.value);
45200
- }
45201
- return { status: status.value, value: parsedSet };
45202
- }
45203
- const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
45204
- if (ctx.common.async) {
45205
- return Promise.all(elements).then((elements2) => finalizeSet(elements2));
45206
- } else {
45207
- return finalizeSet(elements);
45208
- }
45209
- }
45210
- min(minSize, message) {
45211
- return new _ZodSet({
45212
- ...this._def,
45213
- minSize: { value: minSize, message: errorUtil2.toString(message) }
45214
- });
45215
- }
45216
- max(maxSize, message) {
45217
- return new _ZodSet({
45218
- ...this._def,
45219
- maxSize: { value: maxSize, message: errorUtil2.toString(message) }
45220
- });
45221
- }
45222
- size(size, message) {
45223
- return this.min(size, message).max(size, message);
45224
- }
45225
- nonempty(message) {
45226
- return this.min(1, message);
45227
- }
45228
- };
45229
- ZodSet3.create = (valueType, params) => {
45230
- return new ZodSet3({
45231
- valueType,
45232
- minSize: null,
45233
- maxSize: null,
45234
- typeName: ZodFirstPartyTypeKind3.ZodSet,
45235
- ...processCreateParams2(params)
45236
- });
45237
- };
45238
- var ZodFunction3 = class _ZodFunction extends ZodType3 {
45239
- constructor() {
45240
- super(...arguments);
45241
- this.validate = this.implement;
45242
- }
45243
- _parse(input) {
45244
- const { ctx } = this._processInputParams(input);
45245
- if (ctx.parsedType !== ZodParsedType2.function) {
45246
- addIssueToContext2(ctx, {
45247
- code: ZodIssueCode3.invalid_type,
45248
- expected: ZodParsedType2.function,
45249
- received: ctx.parsedType
45250
- });
45251
- return INVALID2;
45252
- }
45253
- function makeArgsIssue(args, error48) {
45254
- return makeIssue2({
45255
- data: args,
45256
- path: ctx.path,
45257
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
45258
- issueData: {
45259
- code: ZodIssueCode3.invalid_arguments,
45260
- argumentsError: error48
45261
- }
45262
- });
45263
- }
45264
- function makeReturnsIssue(returns, error48) {
45265
- return makeIssue2({
45266
- data: returns,
45267
- path: ctx.path,
45268
- errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
45269
- issueData: {
45270
- code: ZodIssueCode3.invalid_return_type,
45271
- returnTypeError: error48
45272
- }
45273
- });
45274
- }
45275
- const params = { errorMap: ctx.common.contextualErrorMap };
45276
- const fn = ctx.data;
45277
- if (this._def.returns instanceof ZodPromise3) {
45278
- const me = this;
45279
- return OK2(async function(...args) {
45280
- const error48 = new ZodError3([]);
45281
- const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
45282
- error48.addIssue(makeArgsIssue(args, e));
45283
- throw error48;
45284
- });
45285
- const result = await Reflect.apply(fn, this, parsedArgs);
45286
- const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
45287
- error48.addIssue(makeReturnsIssue(result, e));
45288
- throw error48;
45289
- });
45290
- return parsedReturns;
45291
- });
45292
- } else {
45293
- const me = this;
45294
- return OK2(function(...args) {
45295
- const parsedArgs = me._def.args.safeParse(args, params);
45296
- if (!parsedArgs.success) {
45297
- throw new ZodError3([makeArgsIssue(args, parsedArgs.error)]);
45298
- }
45299
- const result = Reflect.apply(fn, this, parsedArgs.data);
45300
- const parsedReturns = me._def.returns.safeParse(result, params);
45301
- if (!parsedReturns.success) {
45302
- throw new ZodError3([makeReturnsIssue(result, parsedReturns.error)]);
45303
- }
45304
- return parsedReturns.data;
45305
- });
45306
- }
45307
- }
45308
- parameters() {
45309
- return this._def.args;
45310
- }
45311
- returnType() {
45312
- return this._def.returns;
45313
- }
45314
- args(...items) {
45315
- return new _ZodFunction({
45316
- ...this._def,
45317
- args: ZodTuple3.create(items).rest(ZodUnknown3.create())
45318
- });
45319
- }
45320
- returns(returnType) {
45321
- return new _ZodFunction({
45322
- ...this._def,
45323
- returns: returnType
45324
- });
45325
- }
45326
- implement(func) {
45327
- const validatedFunc = this.parse(func);
45328
- return validatedFunc;
45329
- }
45330
- strictImplement(func) {
45331
- const validatedFunc = this.parse(func);
45332
- return validatedFunc;
45333
- }
45334
- static create(args, returns, params) {
45335
- return new _ZodFunction({
45336
- args: args ? args : ZodTuple3.create([]).rest(ZodUnknown3.create()),
45337
- returns: returns || ZodUnknown3.create(),
45338
- typeName: ZodFirstPartyTypeKind3.ZodFunction,
45339
- ...processCreateParams2(params)
45340
- });
45341
- }
45342
- };
45343
- var ZodLazy3 = class extends ZodType3 {
45344
- get schema() {
45345
- return this._def.getter();
45346
- }
45347
- _parse(input) {
45348
- const { ctx } = this._processInputParams(input);
45349
- const lazySchema = this._def.getter();
45350
- return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
45351
- }
45352
- };
45353
- ZodLazy3.create = (getter, params) => {
45354
- return new ZodLazy3({
45355
- getter,
45356
- typeName: ZodFirstPartyTypeKind3.ZodLazy,
45357
- ...processCreateParams2(params)
45358
- });
45359
- };
45360
- var ZodLiteral3 = class extends ZodType3 {
45361
- _parse(input) {
45362
- if (input.data !== this._def.value) {
45363
- const ctx = this._getOrReturnCtx(input);
45364
- addIssueToContext2(ctx, {
45365
- received: ctx.data,
45366
- code: ZodIssueCode3.invalid_literal,
45367
- expected: this._def.value
45368
- });
45369
- return INVALID2;
45370
- }
45371
- return { status: "valid", value: input.data };
45372
- }
45373
- get value() {
45374
- return this._def.value;
45375
- }
45376
- };
45377
- ZodLiteral3.create = (value, params) => {
45378
- return new ZodLiteral3({
45379
- value,
45380
- typeName: ZodFirstPartyTypeKind3.ZodLiteral,
45381
- ...processCreateParams2(params)
45382
- });
45383
- };
45384
- function createZodEnum2(values, params) {
45385
- return new ZodEnum3({
45386
- values,
45387
- typeName: ZodFirstPartyTypeKind3.ZodEnum,
45388
- ...processCreateParams2(params)
45389
- });
45390
- }
45391
- var ZodEnum3 = class _ZodEnum extends ZodType3 {
45392
- _parse(input) {
45393
- if (typeof input.data !== "string") {
45394
- const ctx = this._getOrReturnCtx(input);
45395
- const expectedValues = this._def.values;
45396
- addIssueToContext2(ctx, {
45397
- expected: util2.joinValues(expectedValues),
45398
- received: ctx.parsedType,
45399
- code: ZodIssueCode3.invalid_type
45400
- });
45401
- return INVALID2;
45402
- }
45403
- if (!this._cache) {
45404
- this._cache = new Set(this._def.values);
45405
- }
45406
- if (!this._cache.has(input.data)) {
45407
- const ctx = this._getOrReturnCtx(input);
45408
- const expectedValues = this._def.values;
45409
- addIssueToContext2(ctx, {
45410
- received: ctx.data,
45411
- code: ZodIssueCode3.invalid_enum_value,
45412
- options: expectedValues
45413
- });
45414
- return INVALID2;
45415
- }
45416
- return OK2(input.data);
45417
- }
45418
- get options() {
45419
- return this._def.values;
45420
- }
45421
- get enum() {
45422
- const enumValues = {};
45423
- for (const val of this._def.values) {
45424
- enumValues[val] = val;
45425
- }
45426
- return enumValues;
45427
- }
45428
- get Values() {
45429
- const enumValues = {};
45430
- for (const val of this._def.values) {
45431
- enumValues[val] = val;
45432
- }
45433
- return enumValues;
45434
- }
45435
- get Enum() {
45436
- const enumValues = {};
45437
- for (const val of this._def.values) {
45438
- enumValues[val] = val;
45439
- }
45440
- return enumValues;
45441
- }
45442
- extract(values, newDef = this._def) {
45443
- return _ZodEnum.create(values, {
45444
- ...this._def,
45445
- ...newDef
45446
- });
45447
- }
45448
- exclude(values, newDef = this._def) {
45449
- return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
45450
- ...this._def,
45451
- ...newDef
45452
- });
45453
- }
45454
- };
45455
- ZodEnum3.create = createZodEnum2;
45456
- var ZodNativeEnum2 = class extends ZodType3 {
45457
- _parse(input) {
45458
- const nativeEnumValues = util2.getValidEnumValues(this._def.values);
45459
- const ctx = this._getOrReturnCtx(input);
45460
- if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
45461
- const expectedValues = util2.objectValues(nativeEnumValues);
45462
- addIssueToContext2(ctx, {
45463
- expected: util2.joinValues(expectedValues),
45464
- received: ctx.parsedType,
45465
- code: ZodIssueCode3.invalid_type
45466
- });
45467
- return INVALID2;
45468
- }
45469
- if (!this._cache) {
45470
- this._cache = new Set(util2.getValidEnumValues(this._def.values));
45471
- }
45472
- if (!this._cache.has(input.data)) {
45473
- const expectedValues = util2.objectValues(nativeEnumValues);
45474
- addIssueToContext2(ctx, {
45475
- received: ctx.data,
45476
- code: ZodIssueCode3.invalid_enum_value,
45477
- options: expectedValues
45478
- });
45479
- return INVALID2;
45480
- }
45481
- return OK2(input.data);
45482
- }
45483
- get enum() {
45484
- return this._def.values;
45485
- }
45486
- };
45487
- ZodNativeEnum2.create = (values, params) => {
45488
- return new ZodNativeEnum2({
45489
- values,
45490
- typeName: ZodFirstPartyTypeKind3.ZodNativeEnum,
45491
- ...processCreateParams2(params)
45492
- });
45493
- };
45494
- var ZodPromise3 = class extends ZodType3 {
45495
- unwrap() {
45496
- return this._def.type;
45497
- }
45498
- _parse(input) {
45499
- const { ctx } = this._processInputParams(input);
45500
- if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
45501
- addIssueToContext2(ctx, {
45502
- code: ZodIssueCode3.invalid_type,
45503
- expected: ZodParsedType2.promise,
45504
- received: ctx.parsedType
45505
- });
45506
- return INVALID2;
45507
- }
45508
- const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
45509
- return OK2(promisified.then((data) => {
45510
- return this._def.type.parseAsync(data, {
45511
- path: ctx.path,
45512
- errorMap: ctx.common.contextualErrorMap
45513
- });
45514
- }));
45515
- }
45516
- };
45517
- ZodPromise3.create = (schema, params) => {
45518
- return new ZodPromise3({
45519
- type: schema,
45520
- typeName: ZodFirstPartyTypeKind3.ZodPromise,
45521
- ...processCreateParams2(params)
45522
- });
45523
- };
45524
- var ZodEffects2 = class extends ZodType3 {
45525
- innerType() {
45526
- return this._def.schema;
45527
- }
45528
- sourceType() {
45529
- return this._def.schema._def.typeName === ZodFirstPartyTypeKind3.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
45530
- }
45531
- _parse(input) {
45532
- const { status, ctx } = this._processInputParams(input);
45533
- const effect = this._def.effect || null;
45534
- const checkCtx = {
45535
- addIssue: (arg) => {
45536
- addIssueToContext2(ctx, arg);
45537
- if (arg.fatal) {
45538
- status.abort();
45539
- } else {
45540
- status.dirty();
45541
- }
45542
- },
45543
- get path() {
45544
- return ctx.path;
45545
- }
45546
- };
45547
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
45548
- if (effect.type === "preprocess") {
45549
- const processed = effect.transform(ctx.data, checkCtx);
45550
- if (ctx.common.async) {
45551
- return Promise.resolve(processed).then(async (processed2) => {
45552
- if (status.value === "aborted")
45553
- return INVALID2;
45554
- const result = await this._def.schema._parseAsync({
45555
- data: processed2,
45556
- path: ctx.path,
45557
- parent: ctx
45558
- });
45559
- if (result.status === "aborted")
45560
- return INVALID2;
45561
- if (result.status === "dirty")
45562
- return DIRTY2(result.value);
45563
- if (status.value === "dirty")
45564
- return DIRTY2(result.value);
45565
- return result;
45566
- });
45567
- } else {
45568
- if (status.value === "aborted")
45569
- return INVALID2;
45570
- const result = this._def.schema._parseSync({
45571
- data: processed,
45572
- path: ctx.path,
45573
- parent: ctx
45574
- });
45575
- if (result.status === "aborted")
45576
- return INVALID2;
45577
- if (result.status === "dirty")
45578
- return DIRTY2(result.value);
45579
- if (status.value === "dirty")
45580
- return DIRTY2(result.value);
45581
- return result;
45582
- }
45583
- }
45584
- if (effect.type === "refinement") {
45585
- const executeRefinement = (acc) => {
45586
- const result = effect.refinement(acc, checkCtx);
45587
- if (ctx.common.async) {
45588
- return Promise.resolve(result);
45589
- }
45590
- if (result instanceof Promise) {
45591
- throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
45592
- }
45593
- return acc;
45594
- };
45595
- if (ctx.common.async === false) {
45596
- const inner = this._def.schema._parseSync({
45597
- data: ctx.data,
45598
- path: ctx.path,
45599
- parent: ctx
45600
- });
45601
- if (inner.status === "aborted")
45602
- return INVALID2;
45603
- if (inner.status === "dirty")
45604
- status.dirty();
45605
- executeRefinement(inner.value);
45606
- return { status: status.value, value: inner.value };
45607
- } else {
45608
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
45609
- if (inner.status === "aborted")
45610
- return INVALID2;
45611
- if (inner.status === "dirty")
45612
- status.dirty();
45613
- return executeRefinement(inner.value).then(() => {
45614
- return { status: status.value, value: inner.value };
45615
- });
45616
- });
45617
- }
45618
- }
45619
- if (effect.type === "transform") {
45620
- if (ctx.common.async === false) {
45621
- const base = this._def.schema._parseSync({
45622
- data: ctx.data,
45623
- path: ctx.path,
45624
- parent: ctx
45625
- });
45626
- if (!isValid2(base))
45627
- return INVALID2;
45628
- const result = effect.transform(base.value, checkCtx);
45629
- if (result instanceof Promise) {
45630
- throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
45631
- }
45632
- return { status: status.value, value: result };
45633
- } else {
45634
- return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
45635
- if (!isValid2(base))
45636
- return INVALID2;
45637
- return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
45638
- status: status.value,
45639
- value: result
45640
- }));
45641
- });
45642
- }
45643
- }
45644
- util2.assertNever(effect);
45645
- }
45646
- };
45647
- ZodEffects2.create = (schema, effect, params) => {
45648
- return new ZodEffects2({
45649
- schema,
45650
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
45651
- effect,
45652
- ...processCreateParams2(params)
45653
- });
45654
- };
45655
- ZodEffects2.createWithPreprocess = (preprocess2, schema, params) => {
45656
- return new ZodEffects2({
45657
- schema,
45658
- effect: { type: "preprocess", transform: preprocess2 },
45659
- typeName: ZodFirstPartyTypeKind3.ZodEffects,
45660
- ...processCreateParams2(params)
45661
- });
45662
- };
45663
- var ZodOptional3 = class extends ZodType3 {
45664
- _parse(input) {
45665
- const parsedType2 = this._getType(input);
45666
- if (parsedType2 === ZodParsedType2.undefined) {
45667
- return OK2(void 0);
45668
- }
45669
- return this._def.innerType._parse(input);
45670
- }
45671
- unwrap() {
45672
- return this._def.innerType;
45673
- }
45674
- };
45675
- ZodOptional3.create = (type, params) => {
45676
- return new ZodOptional3({
45677
- innerType: type,
45678
- typeName: ZodFirstPartyTypeKind3.ZodOptional,
45679
- ...processCreateParams2(params)
45680
- });
45681
- };
45682
- var ZodNullable3 = class extends ZodType3 {
45683
- _parse(input) {
45684
- const parsedType2 = this._getType(input);
45685
- if (parsedType2 === ZodParsedType2.null) {
45686
- return OK2(null);
45687
- }
45688
- return this._def.innerType._parse(input);
45689
- }
45690
- unwrap() {
45691
- return this._def.innerType;
45692
- }
45693
- };
45694
- ZodNullable3.create = (type, params) => {
45695
- return new ZodNullable3({
45696
- innerType: type,
45697
- typeName: ZodFirstPartyTypeKind3.ZodNullable,
45698
- ...processCreateParams2(params)
45699
- });
45700
- };
45701
- var ZodDefault3 = class extends ZodType3 {
45702
- _parse(input) {
45703
- const { ctx } = this._processInputParams(input);
45704
- let data = ctx.data;
45705
- if (ctx.parsedType === ZodParsedType2.undefined) {
45706
- data = this._def.defaultValue();
45707
- }
45708
- return this._def.innerType._parse({
45709
- data,
45710
- path: ctx.path,
45711
- parent: ctx
45712
- });
45713
- }
45714
- removeDefault() {
45715
- return this._def.innerType;
45716
- }
45717
- };
45718
- ZodDefault3.create = (type, params) => {
45719
- return new ZodDefault3({
45720
- innerType: type,
45721
- typeName: ZodFirstPartyTypeKind3.ZodDefault,
45722
- defaultValue: typeof params.default === "function" ? params.default : () => params.default,
45723
- ...processCreateParams2(params)
45724
- });
45725
- };
45726
- var ZodCatch3 = class extends ZodType3 {
45727
- _parse(input) {
45728
- const { ctx } = this._processInputParams(input);
45729
- const newCtx = {
45730
- ...ctx,
45731
- common: {
45732
- ...ctx.common,
45733
- issues: []
45734
- }
45735
- };
45736
- const result = this._def.innerType._parse({
45737
- data: newCtx.data,
45738
- path: newCtx.path,
45739
- parent: {
45740
- ...newCtx
45741
- }
45742
- });
45743
- if (isAsync2(result)) {
45744
- return result.then((result2) => {
45745
- return {
45746
- status: "valid",
45747
- value: result2.status === "valid" ? result2.value : this._def.catchValue({
45748
- get error() {
45749
- return new ZodError3(newCtx.common.issues);
45750
- },
45751
- input: newCtx.data
45752
- })
45753
- };
45754
- });
45755
- } else {
45756
- return {
45757
- status: "valid",
45758
- value: result.status === "valid" ? result.value : this._def.catchValue({
45759
- get error() {
45760
- return new ZodError3(newCtx.common.issues);
45761
- },
45762
- input: newCtx.data
45763
- })
45764
- };
45765
- }
45766
- }
45767
- removeCatch() {
45768
- return this._def.innerType;
45769
- }
45770
- };
45771
- ZodCatch3.create = (type, params) => {
45772
- return new ZodCatch3({
45773
- innerType: type,
45774
- typeName: ZodFirstPartyTypeKind3.ZodCatch,
45775
- catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
45776
- ...processCreateParams2(params)
45777
- });
45778
- };
45779
- var ZodNaN3 = class extends ZodType3 {
45780
- _parse(input) {
45781
- const parsedType2 = this._getType(input);
45782
- if (parsedType2 !== ZodParsedType2.nan) {
45783
- const ctx = this._getOrReturnCtx(input);
45784
- addIssueToContext2(ctx, {
45785
- code: ZodIssueCode3.invalid_type,
45786
- expected: ZodParsedType2.nan,
45787
- received: ctx.parsedType
45788
- });
45789
- return INVALID2;
45790
- }
45791
- return { status: "valid", value: input.data };
45792
- }
45793
- };
45794
- ZodNaN3.create = (params) => {
45795
- return new ZodNaN3({
45796
- typeName: ZodFirstPartyTypeKind3.ZodNaN,
45797
- ...processCreateParams2(params)
45798
- });
45799
- };
45800
- var BRAND = /* @__PURE__ */ Symbol("zod_brand");
45801
- var ZodBranded2 = class extends ZodType3 {
45802
- _parse(input) {
45803
- const { ctx } = this._processInputParams(input);
45804
- const data = ctx.data;
45805
- return this._def.type._parse({
45806
- data,
45807
- path: ctx.path,
45808
- parent: ctx
45809
- });
45810
- }
45811
- unwrap() {
45812
- return this._def.type;
45813
- }
45814
- };
45815
- var ZodPipeline2 = class _ZodPipeline extends ZodType3 {
45816
- _parse(input) {
45817
- const { status, ctx } = this._processInputParams(input);
45818
- if (ctx.common.async) {
45819
- const handleAsync = async () => {
45820
- const inResult = await this._def.in._parseAsync({
45821
- data: ctx.data,
45822
- path: ctx.path,
45823
- parent: ctx
45824
- });
45825
- if (inResult.status === "aborted")
45826
- return INVALID2;
45827
- if (inResult.status === "dirty") {
45828
- status.dirty();
45829
- return DIRTY2(inResult.value);
45830
- } else {
45831
- return this._def.out._parseAsync({
45832
- data: inResult.value,
45833
- path: ctx.path,
45834
- parent: ctx
45835
- });
45836
- }
45837
- };
45838
- return handleAsync();
45839
- } else {
45840
- const inResult = this._def.in._parseSync({
45841
- data: ctx.data,
45842
- path: ctx.path,
45843
- parent: ctx
45844
- });
45845
- if (inResult.status === "aborted")
45846
- return INVALID2;
45847
- if (inResult.status === "dirty") {
45848
- status.dirty();
45849
- return {
45850
- status: "dirty",
45851
- value: inResult.value
45852
- };
45853
- } else {
45854
- return this._def.out._parseSync({
45855
- data: inResult.value,
45856
- path: ctx.path,
45857
- parent: ctx
45858
- });
45859
- }
45860
- }
45861
- }
45862
- static create(a, b) {
45863
- return new _ZodPipeline({
45864
- in: a,
45865
- out: b,
45866
- typeName: ZodFirstPartyTypeKind3.ZodPipeline
45867
- });
45868
- }
45869
- };
45870
- var ZodReadonly3 = class extends ZodType3 {
45871
- _parse(input) {
45872
- const result = this._def.innerType._parse(input);
45873
- const freeze = (data) => {
45874
- if (isValid2(data)) {
45875
- data.value = Object.freeze(data.value);
45876
- }
45877
- return data;
45878
- };
45879
- return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
45880
- }
45881
- unwrap() {
45882
- return this._def.innerType;
45883
- }
45884
- };
45885
- ZodReadonly3.create = (type, params) => {
45886
- return new ZodReadonly3({
45887
- innerType: type,
45888
- typeName: ZodFirstPartyTypeKind3.ZodReadonly,
45889
- ...processCreateParams2(params)
45890
- });
45891
- };
45892
- function cleanParams(params, data) {
45893
- const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
45894
- const p2 = typeof p === "string" ? { message: p } : p;
45895
- return p2;
45896
- }
45897
- function custom2(check2, _params = {}, fatal) {
45898
- if (check2)
45899
- return ZodAny3.create().superRefine((data, ctx) => {
45900
- const r = check2(data);
45901
- if (r instanceof Promise) {
45902
- return r.then((r2) => {
45903
- if (!r2) {
45904
- const params = cleanParams(_params, data);
45905
- const _fatal = params.fatal ?? fatal ?? true;
45906
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
45907
- }
45908
- });
45909
- }
45910
- if (!r) {
45911
- const params = cleanParams(_params, data);
45912
- const _fatal = params.fatal ?? fatal ?? true;
45913
- ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
45914
- }
45915
- return;
45916
- });
45917
- return ZodAny3.create();
45918
- }
45919
- var late2 = {
45920
- object: ZodObject3.lazycreate
45921
- };
45922
- var ZodFirstPartyTypeKind3;
45923
- (function(ZodFirstPartyTypeKind4) {
45924
- ZodFirstPartyTypeKind4["ZodString"] = "ZodString";
45925
- ZodFirstPartyTypeKind4["ZodNumber"] = "ZodNumber";
45926
- ZodFirstPartyTypeKind4["ZodNaN"] = "ZodNaN";
45927
- ZodFirstPartyTypeKind4["ZodBigInt"] = "ZodBigInt";
45928
- ZodFirstPartyTypeKind4["ZodBoolean"] = "ZodBoolean";
45929
- ZodFirstPartyTypeKind4["ZodDate"] = "ZodDate";
45930
- ZodFirstPartyTypeKind4["ZodSymbol"] = "ZodSymbol";
45931
- ZodFirstPartyTypeKind4["ZodUndefined"] = "ZodUndefined";
45932
- ZodFirstPartyTypeKind4["ZodNull"] = "ZodNull";
45933
- ZodFirstPartyTypeKind4["ZodAny"] = "ZodAny";
45934
- ZodFirstPartyTypeKind4["ZodUnknown"] = "ZodUnknown";
45935
- ZodFirstPartyTypeKind4["ZodNever"] = "ZodNever";
45936
- ZodFirstPartyTypeKind4["ZodVoid"] = "ZodVoid";
45937
- ZodFirstPartyTypeKind4["ZodArray"] = "ZodArray";
45938
- ZodFirstPartyTypeKind4["ZodObject"] = "ZodObject";
45939
- ZodFirstPartyTypeKind4["ZodUnion"] = "ZodUnion";
45940
- ZodFirstPartyTypeKind4["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
45941
- ZodFirstPartyTypeKind4["ZodIntersection"] = "ZodIntersection";
45942
- ZodFirstPartyTypeKind4["ZodTuple"] = "ZodTuple";
45943
- ZodFirstPartyTypeKind4["ZodRecord"] = "ZodRecord";
45944
- ZodFirstPartyTypeKind4["ZodMap"] = "ZodMap";
45945
- ZodFirstPartyTypeKind4["ZodSet"] = "ZodSet";
45946
- ZodFirstPartyTypeKind4["ZodFunction"] = "ZodFunction";
45947
- ZodFirstPartyTypeKind4["ZodLazy"] = "ZodLazy";
45948
- ZodFirstPartyTypeKind4["ZodLiteral"] = "ZodLiteral";
45949
- ZodFirstPartyTypeKind4["ZodEnum"] = "ZodEnum";
45950
- ZodFirstPartyTypeKind4["ZodEffects"] = "ZodEffects";
45951
- ZodFirstPartyTypeKind4["ZodNativeEnum"] = "ZodNativeEnum";
45952
- ZodFirstPartyTypeKind4["ZodOptional"] = "ZodOptional";
45953
- ZodFirstPartyTypeKind4["ZodNullable"] = "ZodNullable";
45954
- ZodFirstPartyTypeKind4["ZodDefault"] = "ZodDefault";
45955
- ZodFirstPartyTypeKind4["ZodCatch"] = "ZodCatch";
45956
- ZodFirstPartyTypeKind4["ZodPromise"] = "ZodPromise";
45957
- ZodFirstPartyTypeKind4["ZodBranded"] = "ZodBranded";
45958
- ZodFirstPartyTypeKind4["ZodPipeline"] = "ZodPipeline";
45959
- ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
45960
- })(ZodFirstPartyTypeKind3 || (ZodFirstPartyTypeKind3 = {}));
45961
- var instanceOfType = (cls, params = {
45962
- message: `Input not instance of ${cls.name}`
45963
- }) => custom2((data) => data instanceof cls, params);
45964
- var stringType2 = ZodString3.create;
45965
- var numberType2 = ZodNumber3.create;
45966
- var nanType2 = ZodNaN3.create;
45967
- var bigIntType2 = ZodBigInt3.create;
45968
- var booleanType2 = ZodBoolean3.create;
45969
- var dateType2 = ZodDate3.create;
45970
- var symbolType2 = ZodSymbol3.create;
45971
- var undefinedType2 = ZodUndefined3.create;
45972
- var nullType2 = ZodNull3.create;
45973
- var anyType2 = ZodAny3.create;
45974
- var unknownType2 = ZodUnknown3.create;
45975
- var neverType2 = ZodNever3.create;
45976
- var voidType2 = ZodVoid3.create;
45977
- var arrayType2 = ZodArray3.create;
45978
- var objectType2 = ZodObject3.create;
45979
- var strictObjectType2 = ZodObject3.strictCreate;
45980
- var unionType2 = ZodUnion3.create;
45981
- var discriminatedUnionType2 = ZodDiscriminatedUnion3.create;
45982
- var intersectionType2 = ZodIntersection3.create;
45983
- var tupleType2 = ZodTuple3.create;
45984
- var recordType2 = ZodRecord3.create;
45985
- var mapType2 = ZodMap3.create;
45986
- var setType2 = ZodSet3.create;
45987
- var functionType2 = ZodFunction3.create;
45988
- var lazyType2 = ZodLazy3.create;
45989
- var literalType2 = ZodLiteral3.create;
45990
- var enumType2 = ZodEnum3.create;
45991
- var nativeEnumType2 = ZodNativeEnum2.create;
45992
- var promiseType2 = ZodPromise3.create;
45993
- var effectsType2 = ZodEffects2.create;
45994
- var optionalType2 = ZodOptional3.create;
45995
- var nullableType2 = ZodNullable3.create;
45996
- var preprocessType2 = ZodEffects2.createWithPreprocess;
45997
- var pipelineType2 = ZodPipeline2.create;
45998
- var ostring = () => stringType2().optional();
45999
- var onumber = () => numberType2().optional();
46000
- var oboolean = () => booleanType2().optional();
46001
- var coerce = {
46002
- string: ((arg) => ZodString3.create({ ...arg, coerce: true })),
46003
- number: ((arg) => ZodNumber3.create({ ...arg, coerce: true })),
46004
- boolean: ((arg) => ZodBoolean3.create({
46005
- ...arg,
46006
- coerce: true
46007
- })),
46008
- bigint: ((arg) => ZodBigInt3.create({ ...arg, coerce: true })),
46009
- date: ((arg) => ZodDate3.create({ ...arg, coerce: true }))
46010
- };
46011
- var NEVER2 = INVALID2;
46012
-
46013
41972
  // ../node_modules/axios/lib/helpers/bind.js
46014
41973
  function bind(fn, thisArg) {
46015
41974
  return function wrap() {
@@ -47381,7 +43340,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
47381
43340
  import http from "http";
47382
43341
  import https from "https";
47383
43342
  import http2 from "http2";
47384
- import util4 from "util";
43343
+ import util3 from "util";
47385
43344
  import zlib from "zlib";
47386
43345
 
47387
43346
  // ../node_modules/axios/lib/env/data.js
@@ -47552,7 +43511,7 @@ var AxiosTransformStream_default = AxiosTransformStream;
47552
43511
  import { EventEmitter } from "events";
47553
43512
 
47554
43513
  // ../node_modules/axios/lib/helpers/formDataToStream.js
47555
- import util3 from "util";
43514
+ import util2 from "util";
47556
43515
  import { Readable } from "stream";
47557
43516
 
47558
43517
  // ../node_modules/axios/lib/helpers/readBlob.js
@@ -47572,7 +43531,7 @@ var readBlob_default = readBlob;
47572
43531
 
47573
43532
  // ../node_modules/axios/lib/helpers/formDataToStream.js
47574
43533
  var BOUNDARY_ALPHABET = platform_default.ALPHABET.ALPHA_DIGIT + "-_";
47575
- var textEncoder = typeof TextEncoder === "function" ? new TextEncoder() : new util3.TextEncoder();
43534
+ var textEncoder = typeof TextEncoder === "function" ? new TextEncoder() : new util2.TextEncoder();
47576
43535
  var CRLF = "\r\n";
47577
43536
  var CRLF_BYTES = textEncoder.encode(CRLF);
47578
43537
  var CRLF_BYTES_COUNT = 2;
@@ -47886,7 +43845,7 @@ var Http2Sessions = class {
47886
43845
  let len = authoritySessions.length;
47887
43846
  for (let i = 0; i < len; i++) {
47888
43847
  const [sessionHandle, sessionOptions] = authoritySessions[i];
47889
- if (!sessionHandle.destroyed && !sessionHandle.closed && util4.isDeepStrictEqual(sessionOptions, options)) {
43848
+ if (!sessionHandle.destroyed && !sessionHandle.closed && util3.isDeepStrictEqual(sessionOptions, options)) {
47890
43849
  return sessionHandle;
47891
43850
  }
47892
43851
  }
@@ -48190,7 +44149,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config2) {
48190
44149
  headers.set(data.getHeaders());
48191
44150
  if (!headers.hasContentLength()) {
48192
44151
  try {
48193
- const knownLength = await util4.promisify(data.getLength).call(data);
44152
+ const knownLength = await util3.promisify(data.getLength).call(data);
48194
44153
  Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
48195
44154
  } catch (e) {
48196
44155
  }
@@ -49873,11 +45832,11 @@ function validate(xmlData, options) {
49873
45832
  if (attrStr[attrStr.length - 1] === "/") {
49874
45833
  const attrStrStart = i - attrStr.length;
49875
45834
  attrStr = attrStr.substring(0, attrStr.length - 1);
49876
- const isValid3 = validateAttributeString(attrStr, options);
49877
- if (isValid3 === true) {
45835
+ const isValid2 = validateAttributeString(attrStr, options);
45836
+ if (isValid2 === true) {
49878
45837
  tagFound = true;
49879
45838
  } else {
49880
- return getErrorObject(isValid3.err.code, isValid3.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid3.err.line));
45839
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid2.err.line));
49881
45840
  }
49882
45841
  } else if (closingTag) {
49883
45842
  if (!result.tagClosed) {
@@ -49901,9 +45860,9 @@ function validate(xmlData, options) {
49901
45860
  }
49902
45861
  }
49903
45862
  } else {
49904
- const isValid3 = validateAttributeString(attrStr, options);
49905
- if (isValid3 !== true) {
49906
- return getErrorObject(isValid3.err.code, isValid3.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid3.err.line));
45863
+ const isValid2 = validateAttributeString(attrStr, options);
45864
+ if (isValid2 !== true) {
45865
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid2.err.line));
49907
45866
  }
49908
45867
  if (reachedRoot === true) {
49909
45868
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
@@ -51642,19 +47601,19 @@ function formatPaperListMarkdown(papers, total, start) {
51642
47601
  return lines.join("\n");
51643
47602
  }
51644
47603
  var sortSchema = {
51645
- sort_by: external_exports4.enum(Object.values(SortBy)).default("relevance" /* RELEVANCE */).describe("Sort field: relevance | lastUpdatedDate | submittedDate"),
51646
- sort_order: external_exports4.enum(Object.values(SortOrder)).default("descending" /* DESCENDING */).describe("Sort order: ascending | descending")
47604
+ sort_by: external_exports3.enum(Object.values(SortBy)).default("relevance" /* RELEVANCE */).describe("Sort field: relevance | lastUpdatedDate | submittedDate"),
47605
+ sort_order: external_exports3.enum(Object.values(SortOrder)).default("descending" /* DESCENDING */).describe("Sort order: ascending | descending")
51647
47606
  };
51648
47607
  var responseFormatSchema = {
51649
- response_format: external_exports4.enum(Object.values(ResponseFormat)).default("markdown" /* MARKDOWN */).describe("Output format: markdown or json")
47608
+ response_format: external_exports3.enum(Object.values(ResponseFormat)).default("markdown" /* MARKDOWN */).describe("Output format: markdown or json")
51650
47609
  };
51651
47610
  server.registerTool(
51652
47611
  "arxiv_search_papers",
51653
47612
  {
51654
47613
  title: "Search arXiv Papers",
51655
47614
  description: "Search arXiv for academic papers using a query.",
51656
- inputSchema: external_exports4.object({
51657
- query: external_exports4.string().describe("Search query with optional arXiv prefixes"),
47615
+ inputSchema: external_exports3.object({
47616
+ query: external_exports3.string().describe("Search query with optional arXiv prefixes"),
51658
47617
  ...paginationSchema.shape,
51659
47618
  ...sortSchema,
51660
47619
  ...responseFormatSchema
@@ -51711,8 +47670,8 @@ server.registerTool(
51711
47670
  {
51712
47671
  title: "Get arXiv Paper Details",
51713
47672
  description: "Retrieve full details for one or more arXiv papers by ID.",
51714
- inputSchema: external_exports4.object({
51715
- ids: external_exports4.array(external_exports4.string()).min(1).max(20).describe("List of arXiv paper IDs"),
47673
+ inputSchema: external_exports3.object({
47674
+ ids: external_exports3.array(external_exports3.string()).min(1).max(20).describe("List of arXiv paper IDs"),
51716
47675
  ...responseFormatSchema
51717
47676
  }),
51718
47677
  annotations: {
@@ -51765,8 +47724,8 @@ server.registerTool(
51765
47724
  {
51766
47725
  title: "Search arXiv Papers by Author",
51767
47726
  description: "Search arXiv for papers by a specific author name.",
51768
- inputSchema: external_exports4.object({
51769
- author: external_exports4.string().describe("Author name to search for (e.g. 'Yann LeCun')"),
47727
+ inputSchema: external_exports3.object({
47728
+ author: external_exports3.string().describe("Author name to search for (e.g. 'Yann LeCun')"),
51770
47729
  ...paginationSchema.shape,
51771
47730
  ...sortSchema,
51772
47731
  ...responseFormatSchema
@@ -51823,14 +47782,14 @@ server.registerTool(
51823
47782
  {
51824
47783
  title: "Search arXiv Papers by Category",
51825
47784
  description: "Browse or search papers within a specific arXiv subject category.",
51826
- inputSchema: external_exports4.object({
51827
- category: external_exports4.string().describe("arXiv category code (e.g. 'cs.AI')"),
51828
- query: external_exports4.string().optional().describe("Optional additional search query to filter"),
47785
+ inputSchema: external_exports3.object({
47786
+ category: external_exports3.string().describe("arXiv category code (e.g. 'cs.AI')"),
47787
+ query: external_exports3.string().optional().describe("Optional additional search query to filter"),
51829
47788
  ...paginationSchema.shape,
51830
- sort_by: external_exports4.enum(Object.values(SortBy)).default("submittedDate" /* SUBMITTED */).describe(
47789
+ sort_by: external_exports3.enum(Object.values(SortBy)).default("submittedDate" /* SUBMITTED */).describe(
51831
47790
  "Sort field: relevance | lastUpdatedDate | submittedDate"
51832
47791
  ),
51833
- sort_order: external_exports4.enum(Object.values(SortOrder)).default("descending" /* DESCENDING */).describe("Sort order: ascending | descending"),
47792
+ sort_order: external_exports3.enum(Object.values(SortOrder)).default("descending" /* DESCENDING */).describe("Sort order: ascending | descending"),
51834
47793
  ...responseFormatSchema
51835
47794
  }),
51836
47795
  annotations: {
@@ -51887,7 +47846,7 @@ server.registerTool(
51887
47846
  {
51888
47847
  title: "List arXiv Subject Categories",
51889
47848
  description: "List the commonly used arXiv subject categories with their descriptions.",
51890
- inputSchema: external_exports4.object({
47849
+ inputSchema: external_exports3.object({
51891
47850
  ...paginationSchema.shape
51892
47851
  }),
51893
47852
  annotations: {