@blockrun/clawrouter 0.12.86 → 0.12.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1041,7 +1041,7 @@ var version2;
1041
1041
  var init_version2 = __esm({
1042
1042
  "node_modules/viem/_esm/errors/version.js"() {
1043
1043
  "use strict";
1044
- version2 = "2.46.3";
1044
+ version2 = "2.47.6";
1045
1045
  }
1046
1046
  });
1047
1047
 
@@ -1199,9 +1199,10 @@ var init_abi = __esm({
1199
1199
  }
1200
1200
  };
1201
1201
  AbiDecodingZeroDataError = class extends BaseError2 {
1202
- constructor() {
1202
+ constructor({ cause } = {}) {
1203
1203
  super('Cannot decode zero data ("0x") with ABI parameters.', {
1204
- name: "AbiDecodingZeroDataError"
1204
+ name: "AbiDecodingZeroDataError",
1205
+ cause
1205
1206
  });
1206
1207
  }
1207
1208
  };
@@ -1252,14 +1253,15 @@ var init_abi = __esm({
1252
1253
  }
1253
1254
  };
1254
1255
  AbiErrorSignatureNotFoundError = class extends BaseError2 {
1255
- constructor(signature2, { docsPath: docsPath8 }) {
1256
+ constructor(signature2, { docsPath: docsPath8, cause }) {
1256
1257
  super([
1257
1258
  `Encoded error signature "${signature2}" not found on ABI.`,
1258
1259
  "Make sure you are using the correct ABI and that the error exists on it.",
1259
1260
  `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${signature2}.`
1260
1261
  ].join("\n"), {
1261
1262
  docsPath: docsPath8,
1262
- name: "AbiErrorSignatureNotFoundError"
1263
+ name: "AbiErrorSignatureNotFoundError",
1264
+ cause
1263
1265
  });
1264
1266
  Object.defineProperty(this, "signature", {
1265
1267
  enumerable: true,
@@ -2305,18 +2307,20 @@ var init_lru = __esm({
2305
2307
  }
2306
2308
  get(key) {
2307
2309
  const value = super.get(key);
2308
- if (super.has(key) && value !== void 0) {
2309
- this.delete(key);
2310
+ if (super.has(key)) {
2311
+ super.delete(key);
2310
2312
  super.set(key, value);
2311
2313
  }
2312
2314
  return value;
2313
2315
  }
2314
2316
  set(key, value) {
2317
+ if (super.has(key))
2318
+ super.delete(key);
2315
2319
  super.set(key, value);
2316
2320
  if (this.maxSize && this.size > this.maxSize) {
2317
- const firstKey = this.keys().next().value;
2318
- if (firstKey)
2319
- this.delete(firstKey);
2321
+ const firstKey = super.keys().next().value;
2322
+ if (firstKey !== void 0)
2323
+ super.delete(firstKey);
2320
2324
  }
2321
2325
  return this;
2322
2326
  }
@@ -3395,15 +3399,16 @@ var init_decodeAbiParameters = __esm({
3395
3399
 
3396
3400
  // node_modules/viem/_esm/utils/abi/decodeErrorResult.js
3397
3401
  function decodeErrorResult(parameters) {
3398
- const { abi: abi2, data } = parameters;
3402
+ const { abi: abi2, data, cause } = parameters;
3399
3403
  const signature2 = slice(data, 0, 4);
3400
3404
  if (signature2 === "0x")
3401
- throw new AbiDecodingZeroDataError();
3405
+ throw new AbiDecodingZeroDataError({ cause });
3402
3406
  const abi_ = [...abi2 || [], solidityError, solidityPanic];
3403
3407
  const abiItem = abi_.find((x) => x.type === "error" && signature2 === toFunctionSelector(formatAbiItem2(x)));
3404
3408
  if (!abiItem)
3405
3409
  throw new AbiErrorSignatureNotFoundError(signature2, {
3406
- docsPath: "/docs/contract/decodeErrorResult"
3410
+ docsPath: "/docs/contract/decodeErrorResult",
3411
+ cause
3407
3412
  });
3408
3413
  return {
3409
3414
  abiItem,
@@ -3842,14 +3847,14 @@ ${prettyStateOverride(stateOverride)}`;
3842
3847
  }
3843
3848
  };
3844
3849
  ContractFunctionRevertedError = class extends BaseError2 {
3845
- constructor({ abi: abi2, data, functionName, message }) {
3850
+ constructor({ abi: abi2, data, functionName, message, cause: error }) {
3846
3851
  let cause;
3847
3852
  let decodedData;
3848
3853
  let metaMessages;
3849
3854
  let reason;
3850
3855
  if (data && data !== "0x") {
3851
3856
  try {
3852
- decodedData = decodeErrorResult({ abi: abi2, data });
3857
+ decodedData = decodeErrorResult({ abi: abi2, data, cause: error });
3853
3858
  const { abiItem, errorName, args: errorArgs } = decodedData;
3854
3859
  if (errorName === "Error") {
3855
3860
  reason = errorArgs[0];
@@ -3887,7 +3892,7 @@ ${prettyStateOverride(stateOverride)}`;
3887
3892
  `The contract function "${functionName}" reverted with the following ${signature2 ? "signature" : "reason"}:`,
3888
3893
  reason || signature2
3889
3894
  ].join("\n") : `The contract function "${functionName}" reverted.`, {
3890
- cause,
3895
+ cause: cause ?? error,
3891
3896
  metaMessages,
3892
3897
  name: "ContractFunctionRevertedError"
3893
3898
  });
@@ -3922,7 +3927,7 @@ ${prettyStateOverride(stateOverride)}`;
3922
3927
  }
3923
3928
  };
3924
3929
  ContractFunctionZeroDataError = class extends BaseError2 {
3925
- constructor({ functionName }) {
3930
+ constructor({ functionName, cause }) {
3926
3931
  super(`The contract function "${functionName}" returned no data ("0x").`, {
3927
3932
  metaMessages: [
3928
3933
  "This could be due to any of the following:",
@@ -3930,7 +3935,8 @@ ${prettyStateOverride(stateOverride)}`;
3930
3935
  " - The parameters passed to the contract function may be invalid, or",
3931
3936
  " - The address is not a contract."
3932
3937
  ],
3933
- name: "ContractFunctionZeroDataError"
3938
+ name: "ContractFunctionZeroDataError",
3939
+ cause
3934
3940
  });
3935
3941
  }
3936
3942
  };
@@ -6702,11 +6708,11 @@ function mapToCurveSimpleSWU(Fp, opts) {
6702
6708
  tv5 = Fp.mul(tv6, opts.B);
6703
6709
  tv2 = Fp.add(tv2, tv5);
6704
6710
  x = Fp.mul(tv1, tv3);
6705
- const { isValid, value } = sqrtRatio(tv2, tv6);
6711
+ const { isValid: isValid2, value } = sqrtRatio(tv2, tv6);
6706
6712
  y = Fp.mul(tv1, u);
6707
6713
  y = Fp.mul(y, value);
6708
- x = Fp.cmov(x, tv3, isValid);
6709
- y = Fp.cmov(y, value, isValid);
6714
+ x = Fp.cmov(x, tv3, isValid2);
6715
+ y = Fp.cmov(y, value, isValid2);
6710
6716
  const e1 = Fp.isOdd(u) === Fp.isOdd(y);
6711
6717
  y = Fp.cmov(Fp.neg(y), y, e1);
6712
6718
  const tv4_inv = FpInvertBatch(Fp, [tv4], true)[0];
@@ -14683,8 +14689,8 @@ async function createKeyPairFromBytes(bytes, extractable = false) {
14683
14689
  const randomBytes3 = new Uint8Array(32);
14684
14690
  crypto.getRandomValues(randomBytes3);
14685
14691
  const signedData = await signBytes(privateKey, randomBytes3);
14686
- const isValid = await verifySignature(publicKey, signedData, randomBytes3);
14687
- if (!isValid) {
14692
+ const isValid2 = await verifySignature(publicKey, signedData, randomBytes3);
14693
+ if (!isValid2) {
14688
14694
  throw new SolanaError(SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY);
14689
14695
  }
14690
14696
  return { privateKey, publicKey };
@@ -25675,13 +25681,14 @@ function getContractError(err, { abi: abi2, address: address2, args, docsPath: d
25675
25681
  const { code, data, details, message, shortMessage } = error;
25676
25682
  const cause = (() => {
25677
25683
  if (err instanceof AbiDecodingZeroDataError)
25678
- return new ContractFunctionZeroDataError({ functionName });
25684
+ return new ContractFunctionZeroDataError({ functionName, cause: err });
25679
25685
  if ([EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) && (data || details || message || shortMessage) || code === InvalidInputRpcError.code && details === "execution reverted" && data) {
25680
25686
  return new ContractFunctionRevertedError({
25681
25687
  abi: abi2,
25682
25688
  data: typeof data === "object" ? data.data : data,
25683
25689
  functionName,
25684
- message: error instanceof RpcRequestError ? details : shortMessage ?? message
25690
+ message: error instanceof RpcRequestError ? details : shortMessage ?? message,
25691
+ cause: err
25685
25692
  });
25686
25693
  }
25687
25694
  return err;
@@ -26637,14 +26644,14 @@ async function prepareTransactionRequest(client, args) {
26637
26644
  return {
26638
26645
  ...request,
26639
26646
  ...from14 ? { from: from14 } : {},
26640
- ...type2 ? { type: type2 } : {},
26647
+ ...type2 && !request.type ? { type: type2 } : {},
26641
26648
  ...typeof chainId2 !== "undefined" ? { chainId: chainId2 } : {},
26642
26649
  ...typeof gas2 !== "undefined" ? { gas: gas2 } : {},
26643
26650
  ...typeof gasPrice !== "undefined" ? { gasPrice } : {},
26644
26651
  ...typeof nonce2 !== "undefined" ? { nonce: nonce2 } : {},
26645
- ...typeof maxFeePerBlobGas !== "undefined" ? { maxFeePerBlobGas } : {},
26646
- ...typeof maxFeePerGas !== "undefined" ? { maxFeePerGas } : {},
26647
- ...typeof maxPriorityFeePerGas !== "undefined" ? { maxPriorityFeePerGas } : {},
26652
+ ...typeof maxFeePerBlobGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxFeePerBlobGas } : {},
26653
+ ...typeof maxFeePerGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxFeePerGas } : {},
26654
+ ...typeof maxPriorityFeePerGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxPriorityFeePerGas } : {},
26648
26655
  ..."nonceKey" in rest && typeof rest.nonceKey !== "undefined" ? { nonceKey: rest.nonceKey } : {}
26649
26656
  };
26650
26657
  }).catch((e7) => {
@@ -26653,7 +26660,7 @@ async function prepareTransactionRequest(client, args) {
26653
26660
  return request;
26654
26661
  const unsupported = error.walk?.((e8) => {
26655
26662
  const error2 = e8;
26656
- return error2.name === "MethodNotFoundRpcError" || error2.name === "MethodNotSupportedRpcError";
26663
+ return error2.name === "MethodNotFoundRpcError" || error2.name === "MethodNotSupportedRpcError" || error2.message?.includes("eth_fillTransaction is not available");
26657
26664
  });
26658
26665
  if (unsupported)
26659
26666
  supportsFillTransaction.set(client.uid, false);
@@ -27925,12 +27932,12 @@ async function isImageUri(uri) {
27925
27932
  });
27926
27933
  }
27927
27934
  }
27928
- function getGateway(custom, defaultGateway) {
27929
- if (!custom)
27935
+ function getGateway(custom2, defaultGateway) {
27936
+ if (!custom2)
27930
27937
  return defaultGateway;
27931
- if (custom.endsWith("/"))
27932
- return custom.slice(0, -1);
27933
- return custom;
27938
+ if (custom2.endsWith("/"))
27939
+ return custom2.slice(0, -1);
27940
+ return custom2;
27934
27941
  }
27935
27942
  function resolveAvatarUri({ uri, gatewayUrls }) {
27936
27943
  const isEncoded = base64Regex.test(uri);
@@ -29225,6 +29232,8 @@ function getHttpRpcClient(url_, options = {}) {
29225
29232
  }
29226
29233
  }
29227
29234
  if (!response.ok) {
29235
+ if (typeof data.error?.code === "number" && typeof data.error?.message === "string")
29236
+ return data;
29228
29237
  throw new HttpRequestError({
29229
29238
  body,
29230
29239
  details: stringify(data.error) || response.statusText,
@@ -33367,7 +33376,7 @@ async function simulateCalls(client, parameters) {
33367
33376
  }
33368
33377
  ] : [],
33369
33378
  {
33370
- calls: [...calls, {}].map((call2) => ({
33379
+ calls: [...calls, { to: zeroAddress }].map((call2) => ({
33371
33380
  ...call2,
33372
33381
  from: account?.address
33373
33382
  })),
@@ -33646,7 +33655,7 @@ function serializeSignature({ r, s: s3, to = "hex", v, yParity }) {
33646
33655
  // node_modules/viem/_esm/actions/public/verifyHash.js
33647
33656
  init_call();
33648
33657
  async function verifyHash(client, parameters) {
33649
- const { address: address2, chain: chain3 = client.chain, hash: hash3, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? chain3?.contracts?.erc6492Verifier?.address, multicallAddress = parameters.multicallAddress ?? chain3?.contracts?.multicall3?.address } = parameters;
33658
+ const { address: address2, chain: chain3 = client.chain, hash: hash3, erc6492VerifierAddress: verifierAddress = parameters.universalSignatureVerifierAddress ?? chain3?.contracts?.erc6492Verifier?.address, multicallAddress = parameters.multicallAddress ?? chain3?.contracts?.multicall3?.address, mode = "auto" } = parameters;
33650
33659
  if (chain3?.verifyHash)
33651
33660
  return await chain3.verifyHash(client, parameters);
33652
33661
  const signature2 = (() => {
@@ -33658,6 +33667,14 @@ async function verifyHash(client, parameters) {
33658
33667
  return bytesToHex(signature3);
33659
33668
  })();
33660
33669
  try {
33670
+ if (mode === "eoa") {
33671
+ try {
33672
+ const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
33673
+ if (verified)
33674
+ return true;
33675
+ } catch {
33676
+ }
33677
+ }
33661
33678
  if (SignatureErc8010_exports.validate(signature2))
33662
33679
  return await verifyErc8010(client, {
33663
33680
  ...parameters,
@@ -33670,11 +33687,13 @@ async function verifyHash(client, parameters) {
33670
33687
  signature: signature2
33671
33688
  });
33672
33689
  } catch (error) {
33673
- try {
33674
- const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
33675
- if (verified)
33676
- return true;
33677
- } catch {
33690
+ if (mode !== "eoa") {
33691
+ try {
33692
+ const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
33693
+ if (verified)
33694
+ return true;
33695
+ } catch {
33696
+ }
33678
33697
  }
33679
33698
  if (error instanceof VerificationError) {
33680
33699
  return false;
@@ -34480,7 +34499,7 @@ async function verifySiweMessage(client, parameters) {
34480
34499
  const parsed = parseSiweMessage(message);
34481
34500
  if (!parsed.address)
34482
34501
  return false;
34483
- const isValid = validateSiweMessage({
34502
+ const isValid2 = validateSiweMessage({
34484
34503
  address: address2,
34485
34504
  domain,
34486
34505
  message: parsed,
@@ -34488,7 +34507,7 @@ async function verifySiweMessage(client, parameters) {
34488
34507
  scheme,
34489
34508
  time
34490
34509
  });
34491
- if (!isValid)
34510
+ if (!isValid2)
34492
34511
  return false;
34493
34512
  const hash3 = hashMessage(message);
34494
34513
  return verifyHash(client, {
@@ -37447,6 +37466,4122 @@ zero
37447
37466
  zone
37448
37467
  zoo`.split("\n");
37449
37468
 
37469
+ // node_modules/zod/v3/external.js
37470
+ var external_exports = {};
37471
+ __export(external_exports, {
37472
+ BRAND: () => BRAND,
37473
+ DIRTY: () => DIRTY,
37474
+ EMPTY_PATH: () => EMPTY_PATH,
37475
+ INVALID: () => INVALID,
37476
+ NEVER: () => NEVER,
37477
+ OK: () => OK,
37478
+ ParseStatus: () => ParseStatus,
37479
+ Schema: () => ZodType,
37480
+ ZodAny: () => ZodAny,
37481
+ ZodArray: () => ZodArray,
37482
+ ZodBigInt: () => ZodBigInt,
37483
+ ZodBoolean: () => ZodBoolean,
37484
+ ZodBranded: () => ZodBranded,
37485
+ ZodCatch: () => ZodCatch,
37486
+ ZodDate: () => ZodDate,
37487
+ ZodDefault: () => ZodDefault,
37488
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
37489
+ ZodEffects: () => ZodEffects,
37490
+ ZodEnum: () => ZodEnum,
37491
+ ZodError: () => ZodError,
37492
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
37493
+ ZodFunction: () => ZodFunction,
37494
+ ZodIntersection: () => ZodIntersection,
37495
+ ZodIssueCode: () => ZodIssueCode,
37496
+ ZodLazy: () => ZodLazy,
37497
+ ZodLiteral: () => ZodLiteral,
37498
+ ZodMap: () => ZodMap,
37499
+ ZodNaN: () => ZodNaN,
37500
+ ZodNativeEnum: () => ZodNativeEnum,
37501
+ ZodNever: () => ZodNever,
37502
+ ZodNull: () => ZodNull,
37503
+ ZodNullable: () => ZodNullable,
37504
+ ZodNumber: () => ZodNumber,
37505
+ ZodObject: () => ZodObject,
37506
+ ZodOptional: () => ZodOptional,
37507
+ ZodParsedType: () => ZodParsedType,
37508
+ ZodPipeline: () => ZodPipeline,
37509
+ ZodPromise: () => ZodPromise,
37510
+ ZodReadonly: () => ZodReadonly,
37511
+ ZodRecord: () => ZodRecord,
37512
+ ZodSchema: () => ZodType,
37513
+ ZodSet: () => ZodSet,
37514
+ ZodString: () => ZodString,
37515
+ ZodSymbol: () => ZodSymbol,
37516
+ ZodTransformer: () => ZodEffects,
37517
+ ZodTuple: () => ZodTuple,
37518
+ ZodType: () => ZodType,
37519
+ ZodUndefined: () => ZodUndefined,
37520
+ ZodUnion: () => ZodUnion,
37521
+ ZodUnknown: () => ZodUnknown,
37522
+ ZodVoid: () => ZodVoid,
37523
+ addIssueToContext: () => addIssueToContext,
37524
+ any: () => anyType,
37525
+ array: () => arrayType,
37526
+ bigint: () => bigIntType,
37527
+ boolean: () => booleanType,
37528
+ coerce: () => coerce,
37529
+ custom: () => custom,
37530
+ date: () => dateType,
37531
+ datetimeRegex: () => datetimeRegex,
37532
+ defaultErrorMap: () => en_default,
37533
+ discriminatedUnion: () => discriminatedUnionType,
37534
+ effect: () => effectsType,
37535
+ enum: () => enumType,
37536
+ function: () => functionType,
37537
+ getErrorMap: () => getErrorMap,
37538
+ getParsedType: () => getParsedType,
37539
+ instanceof: () => instanceOfType,
37540
+ intersection: () => intersectionType,
37541
+ isAborted: () => isAborted,
37542
+ isAsync: () => isAsync,
37543
+ isDirty: () => isDirty,
37544
+ isValid: () => isValid,
37545
+ late: () => late,
37546
+ lazy: () => lazyType,
37547
+ literal: () => literalType,
37548
+ makeIssue: () => makeIssue,
37549
+ map: () => mapType,
37550
+ nan: () => nanType,
37551
+ nativeEnum: () => nativeEnumType,
37552
+ never: () => neverType,
37553
+ null: () => nullType,
37554
+ nullable: () => nullableType,
37555
+ number: () => numberType,
37556
+ object: () => objectType,
37557
+ objectUtil: () => objectUtil,
37558
+ oboolean: () => oboolean,
37559
+ onumber: () => onumber,
37560
+ optional: () => optionalType,
37561
+ ostring: () => ostring,
37562
+ pipeline: () => pipelineType,
37563
+ preprocess: () => preprocessType,
37564
+ promise: () => promiseType,
37565
+ quotelessJson: () => quotelessJson,
37566
+ record: () => recordType,
37567
+ set: () => setType,
37568
+ setErrorMap: () => setErrorMap,
37569
+ strictObject: () => strictObjectType,
37570
+ string: () => stringType,
37571
+ symbol: () => symbolType,
37572
+ transformer: () => effectsType,
37573
+ tuple: () => tupleType,
37574
+ undefined: () => undefinedType,
37575
+ union: () => unionType,
37576
+ unknown: () => unknownType,
37577
+ util: () => util,
37578
+ void: () => voidType
37579
+ });
37580
+
37581
+ // node_modules/zod/v3/helpers/util.js
37582
+ var util;
37583
+ (function(util2) {
37584
+ util2.assertEqual = (_) => {
37585
+ };
37586
+ function assertIs(_arg) {
37587
+ }
37588
+ util2.assertIs = assertIs;
37589
+ function assertNever(_x) {
37590
+ throw new Error();
37591
+ }
37592
+ util2.assertNever = assertNever;
37593
+ util2.arrayToEnum = (items) => {
37594
+ const obj = {};
37595
+ for (const item of items) {
37596
+ obj[item] = item;
37597
+ }
37598
+ return obj;
37599
+ };
37600
+ util2.getValidEnumValues = (obj) => {
37601
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
37602
+ const filtered = {};
37603
+ for (const k of validKeys) {
37604
+ filtered[k] = obj[k];
37605
+ }
37606
+ return util2.objectValues(filtered);
37607
+ };
37608
+ util2.objectValues = (obj) => {
37609
+ return util2.objectKeys(obj).map(function(e7) {
37610
+ return obj[e7];
37611
+ });
37612
+ };
37613
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
37614
+ const keys = [];
37615
+ for (const key in object) {
37616
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
37617
+ keys.push(key);
37618
+ }
37619
+ }
37620
+ return keys;
37621
+ };
37622
+ util2.find = (arr, checker) => {
37623
+ for (const item of arr) {
37624
+ if (checker(item))
37625
+ return item;
37626
+ }
37627
+ return void 0;
37628
+ };
37629
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
37630
+ function joinValues(array, separator = " | ") {
37631
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
37632
+ }
37633
+ util2.joinValues = joinValues;
37634
+ util2.jsonStringifyReplacer = (_, value) => {
37635
+ if (typeof value === "bigint") {
37636
+ return value.toString();
37637
+ }
37638
+ return value;
37639
+ };
37640
+ })(util || (util = {}));
37641
+ var objectUtil;
37642
+ (function(objectUtil2) {
37643
+ objectUtil2.mergeShapes = (first, second) => {
37644
+ return {
37645
+ ...first,
37646
+ ...second
37647
+ // second overwrites first
37648
+ };
37649
+ };
37650
+ })(objectUtil || (objectUtil = {}));
37651
+ var ZodParsedType = util.arrayToEnum([
37652
+ "string",
37653
+ "nan",
37654
+ "number",
37655
+ "integer",
37656
+ "float",
37657
+ "boolean",
37658
+ "date",
37659
+ "bigint",
37660
+ "symbol",
37661
+ "function",
37662
+ "undefined",
37663
+ "null",
37664
+ "array",
37665
+ "object",
37666
+ "unknown",
37667
+ "promise",
37668
+ "void",
37669
+ "never",
37670
+ "map",
37671
+ "set"
37672
+ ]);
37673
+ var getParsedType = (data) => {
37674
+ const t = typeof data;
37675
+ switch (t) {
37676
+ case "undefined":
37677
+ return ZodParsedType.undefined;
37678
+ case "string":
37679
+ return ZodParsedType.string;
37680
+ case "number":
37681
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
37682
+ case "boolean":
37683
+ return ZodParsedType.boolean;
37684
+ case "function":
37685
+ return ZodParsedType.function;
37686
+ case "bigint":
37687
+ return ZodParsedType.bigint;
37688
+ case "symbol":
37689
+ return ZodParsedType.symbol;
37690
+ case "object":
37691
+ if (Array.isArray(data)) {
37692
+ return ZodParsedType.array;
37693
+ }
37694
+ if (data === null) {
37695
+ return ZodParsedType.null;
37696
+ }
37697
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
37698
+ return ZodParsedType.promise;
37699
+ }
37700
+ if (typeof Map !== "undefined" && data instanceof Map) {
37701
+ return ZodParsedType.map;
37702
+ }
37703
+ if (typeof Set !== "undefined" && data instanceof Set) {
37704
+ return ZodParsedType.set;
37705
+ }
37706
+ if (typeof Date !== "undefined" && data instanceof Date) {
37707
+ return ZodParsedType.date;
37708
+ }
37709
+ return ZodParsedType.object;
37710
+ default:
37711
+ return ZodParsedType.unknown;
37712
+ }
37713
+ };
37714
+
37715
+ // node_modules/zod/v3/ZodError.js
37716
+ var ZodIssueCode = util.arrayToEnum([
37717
+ "invalid_type",
37718
+ "invalid_literal",
37719
+ "custom",
37720
+ "invalid_union",
37721
+ "invalid_union_discriminator",
37722
+ "invalid_enum_value",
37723
+ "unrecognized_keys",
37724
+ "invalid_arguments",
37725
+ "invalid_return_type",
37726
+ "invalid_date",
37727
+ "invalid_string",
37728
+ "too_small",
37729
+ "too_big",
37730
+ "invalid_intersection_types",
37731
+ "not_multiple_of",
37732
+ "not_finite"
37733
+ ]);
37734
+ var quotelessJson = (obj) => {
37735
+ const json = JSON.stringify(obj, null, 2);
37736
+ return json.replace(/"([^"]+)":/g, "$1:");
37737
+ };
37738
+ var ZodError = class _ZodError extends Error {
37739
+ get errors() {
37740
+ return this.issues;
37741
+ }
37742
+ constructor(issues) {
37743
+ super();
37744
+ this.issues = [];
37745
+ this.addIssue = (sub) => {
37746
+ this.issues = [...this.issues, sub];
37747
+ };
37748
+ this.addIssues = (subs = []) => {
37749
+ this.issues = [...this.issues, ...subs];
37750
+ };
37751
+ const actualProto = new.target.prototype;
37752
+ if (Object.setPrototypeOf) {
37753
+ Object.setPrototypeOf(this, actualProto);
37754
+ } else {
37755
+ this.__proto__ = actualProto;
37756
+ }
37757
+ this.name = "ZodError";
37758
+ this.issues = issues;
37759
+ }
37760
+ format(_mapper) {
37761
+ const mapper = _mapper || function(issue) {
37762
+ return issue.message;
37763
+ };
37764
+ const fieldErrors = { _errors: [] };
37765
+ const processError = (error) => {
37766
+ for (const issue of error.issues) {
37767
+ if (issue.code === "invalid_union") {
37768
+ issue.unionErrors.map(processError);
37769
+ } else if (issue.code === "invalid_return_type") {
37770
+ processError(issue.returnTypeError);
37771
+ } else if (issue.code === "invalid_arguments") {
37772
+ processError(issue.argumentsError);
37773
+ } else if (issue.path.length === 0) {
37774
+ fieldErrors._errors.push(mapper(issue));
37775
+ } else {
37776
+ let curr = fieldErrors;
37777
+ let i = 0;
37778
+ while (i < issue.path.length) {
37779
+ const el = issue.path[i];
37780
+ const terminal = i === issue.path.length - 1;
37781
+ if (!terminal) {
37782
+ curr[el] = curr[el] || { _errors: [] };
37783
+ } else {
37784
+ curr[el] = curr[el] || { _errors: [] };
37785
+ curr[el]._errors.push(mapper(issue));
37786
+ }
37787
+ curr = curr[el];
37788
+ i++;
37789
+ }
37790
+ }
37791
+ }
37792
+ };
37793
+ processError(this);
37794
+ return fieldErrors;
37795
+ }
37796
+ static assert(value) {
37797
+ if (!(value instanceof _ZodError)) {
37798
+ throw new Error(`Not a ZodError: ${value}`);
37799
+ }
37800
+ }
37801
+ toString() {
37802
+ return this.message;
37803
+ }
37804
+ get message() {
37805
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
37806
+ }
37807
+ get isEmpty() {
37808
+ return this.issues.length === 0;
37809
+ }
37810
+ flatten(mapper = (issue) => issue.message) {
37811
+ const fieldErrors = {};
37812
+ const formErrors = [];
37813
+ for (const sub of this.issues) {
37814
+ if (sub.path.length > 0) {
37815
+ const firstEl = sub.path[0];
37816
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
37817
+ fieldErrors[firstEl].push(mapper(sub));
37818
+ } else {
37819
+ formErrors.push(mapper(sub));
37820
+ }
37821
+ }
37822
+ return { formErrors, fieldErrors };
37823
+ }
37824
+ get formErrors() {
37825
+ return this.flatten();
37826
+ }
37827
+ };
37828
+ ZodError.create = (issues) => {
37829
+ const error = new ZodError(issues);
37830
+ return error;
37831
+ };
37832
+
37833
+ // node_modules/zod/v3/locales/en.js
37834
+ var errorMap = (issue, _ctx) => {
37835
+ let message;
37836
+ switch (issue.code) {
37837
+ case ZodIssueCode.invalid_type:
37838
+ if (issue.received === ZodParsedType.undefined) {
37839
+ message = "Required";
37840
+ } else {
37841
+ message = `Expected ${issue.expected}, received ${issue.received}`;
37842
+ }
37843
+ break;
37844
+ case ZodIssueCode.invalid_literal:
37845
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
37846
+ break;
37847
+ case ZodIssueCode.unrecognized_keys:
37848
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
37849
+ break;
37850
+ case ZodIssueCode.invalid_union:
37851
+ message = `Invalid input`;
37852
+ break;
37853
+ case ZodIssueCode.invalid_union_discriminator:
37854
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
37855
+ break;
37856
+ case ZodIssueCode.invalid_enum_value:
37857
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
37858
+ break;
37859
+ case ZodIssueCode.invalid_arguments:
37860
+ message = `Invalid function arguments`;
37861
+ break;
37862
+ case ZodIssueCode.invalid_return_type:
37863
+ message = `Invalid function return type`;
37864
+ break;
37865
+ case ZodIssueCode.invalid_date:
37866
+ message = `Invalid date`;
37867
+ break;
37868
+ case ZodIssueCode.invalid_string:
37869
+ if (typeof issue.validation === "object") {
37870
+ if ("includes" in issue.validation) {
37871
+ message = `Invalid input: must include "${issue.validation.includes}"`;
37872
+ if (typeof issue.validation.position === "number") {
37873
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
37874
+ }
37875
+ } else if ("startsWith" in issue.validation) {
37876
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
37877
+ } else if ("endsWith" in issue.validation) {
37878
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
37879
+ } else {
37880
+ util.assertNever(issue.validation);
37881
+ }
37882
+ } else if (issue.validation !== "regex") {
37883
+ message = `Invalid ${issue.validation}`;
37884
+ } else {
37885
+ message = "Invalid";
37886
+ }
37887
+ break;
37888
+ case ZodIssueCode.too_small:
37889
+ if (issue.type === "array")
37890
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
37891
+ else if (issue.type === "string")
37892
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
37893
+ else if (issue.type === "number")
37894
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
37895
+ else if (issue.type === "bigint")
37896
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
37897
+ else if (issue.type === "date")
37898
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
37899
+ else
37900
+ message = "Invalid input";
37901
+ break;
37902
+ case ZodIssueCode.too_big:
37903
+ if (issue.type === "array")
37904
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
37905
+ else if (issue.type === "string")
37906
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
37907
+ else if (issue.type === "number")
37908
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
37909
+ else if (issue.type === "bigint")
37910
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
37911
+ else if (issue.type === "date")
37912
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
37913
+ else
37914
+ message = "Invalid input";
37915
+ break;
37916
+ case ZodIssueCode.custom:
37917
+ message = `Invalid input`;
37918
+ break;
37919
+ case ZodIssueCode.invalid_intersection_types:
37920
+ message = `Intersection results could not be merged`;
37921
+ break;
37922
+ case ZodIssueCode.not_multiple_of:
37923
+ message = `Number must be a multiple of ${issue.multipleOf}`;
37924
+ break;
37925
+ case ZodIssueCode.not_finite:
37926
+ message = "Number must be finite";
37927
+ break;
37928
+ default:
37929
+ message = _ctx.defaultError;
37930
+ util.assertNever(issue);
37931
+ }
37932
+ return { message };
37933
+ };
37934
+ var en_default = errorMap;
37935
+
37936
+ // node_modules/zod/v3/errors.js
37937
+ var overrideErrorMap = en_default;
37938
+ function setErrorMap(map) {
37939
+ overrideErrorMap = map;
37940
+ }
37941
+ function getErrorMap() {
37942
+ return overrideErrorMap;
37943
+ }
37944
+
37945
+ // node_modules/zod/v3/helpers/parseUtil.js
37946
+ var makeIssue = (params) => {
37947
+ const { data, path, errorMaps, issueData } = params;
37948
+ const fullPath = [...path, ...issueData.path || []];
37949
+ const fullIssue = {
37950
+ ...issueData,
37951
+ path: fullPath
37952
+ };
37953
+ if (issueData.message !== void 0) {
37954
+ return {
37955
+ ...issueData,
37956
+ path: fullPath,
37957
+ message: issueData.message
37958
+ };
37959
+ }
37960
+ let errorMessage = "";
37961
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
37962
+ for (const map of maps) {
37963
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
37964
+ }
37965
+ return {
37966
+ ...issueData,
37967
+ path: fullPath,
37968
+ message: errorMessage
37969
+ };
37970
+ };
37971
+ var EMPTY_PATH = [];
37972
+ function addIssueToContext(ctx, issueData) {
37973
+ const overrideMap = getErrorMap();
37974
+ const issue = makeIssue({
37975
+ issueData,
37976
+ data: ctx.data,
37977
+ path: ctx.path,
37978
+ errorMaps: [
37979
+ ctx.common.contextualErrorMap,
37980
+ // contextual error map is first priority
37981
+ ctx.schemaErrorMap,
37982
+ // then schema-bound map if available
37983
+ overrideMap,
37984
+ // then global override map
37985
+ overrideMap === en_default ? void 0 : en_default
37986
+ // then global default map
37987
+ ].filter((x) => !!x)
37988
+ });
37989
+ ctx.common.issues.push(issue);
37990
+ }
37991
+ var ParseStatus = class _ParseStatus {
37992
+ constructor() {
37993
+ this.value = "valid";
37994
+ }
37995
+ dirty() {
37996
+ if (this.value === "valid")
37997
+ this.value = "dirty";
37998
+ }
37999
+ abort() {
38000
+ if (this.value !== "aborted")
38001
+ this.value = "aborted";
38002
+ }
38003
+ static mergeArray(status, results) {
38004
+ const arrayValue = [];
38005
+ for (const s3 of results) {
38006
+ if (s3.status === "aborted")
38007
+ return INVALID;
38008
+ if (s3.status === "dirty")
38009
+ status.dirty();
38010
+ arrayValue.push(s3.value);
38011
+ }
38012
+ return { status: status.value, value: arrayValue };
38013
+ }
38014
+ static async mergeObjectAsync(status, pairs) {
38015
+ const syncPairs = [];
38016
+ for (const pair of pairs) {
38017
+ const key = await pair.key;
38018
+ const value = await pair.value;
38019
+ syncPairs.push({
38020
+ key,
38021
+ value
38022
+ });
38023
+ }
38024
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
38025
+ }
38026
+ static mergeObjectSync(status, pairs) {
38027
+ const finalObject = {};
38028
+ for (const pair of pairs) {
38029
+ const { key, value } = pair;
38030
+ if (key.status === "aborted")
38031
+ return INVALID;
38032
+ if (value.status === "aborted")
38033
+ return INVALID;
38034
+ if (key.status === "dirty")
38035
+ status.dirty();
38036
+ if (value.status === "dirty")
38037
+ status.dirty();
38038
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
38039
+ finalObject[key.value] = value.value;
38040
+ }
38041
+ }
38042
+ return { status: status.value, value: finalObject };
38043
+ }
38044
+ };
38045
+ var INVALID = Object.freeze({
38046
+ status: "aborted"
38047
+ });
38048
+ var DIRTY = (value) => ({ status: "dirty", value });
38049
+ var OK = (value) => ({ status: "valid", value });
38050
+ var isAborted = (x) => x.status === "aborted";
38051
+ var isDirty = (x) => x.status === "dirty";
38052
+ var isValid = (x) => x.status === "valid";
38053
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
38054
+
38055
+ // node_modules/zod/v3/helpers/errorUtil.js
38056
+ var errorUtil;
38057
+ (function(errorUtil2) {
38058
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
38059
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
38060
+ })(errorUtil || (errorUtil = {}));
38061
+
38062
+ // node_modules/zod/v3/types.js
38063
+ var ParseInputLazyPath = class {
38064
+ constructor(parent, value, path, key) {
38065
+ this._cachedPath = [];
38066
+ this.parent = parent;
38067
+ this.data = value;
38068
+ this._path = path;
38069
+ this._key = key;
38070
+ }
38071
+ get path() {
38072
+ if (!this._cachedPath.length) {
38073
+ if (Array.isArray(this._key)) {
38074
+ this._cachedPath.push(...this._path, ...this._key);
38075
+ } else {
38076
+ this._cachedPath.push(...this._path, this._key);
38077
+ }
38078
+ }
38079
+ return this._cachedPath;
38080
+ }
38081
+ };
38082
+ var handleResult = (ctx, result) => {
38083
+ if (isValid(result)) {
38084
+ return { success: true, data: result.value };
38085
+ } else {
38086
+ if (!ctx.common.issues.length) {
38087
+ throw new Error("Validation failed but no issues detected.");
38088
+ }
38089
+ return {
38090
+ success: false,
38091
+ get error() {
38092
+ if (this._error)
38093
+ return this._error;
38094
+ const error = new ZodError(ctx.common.issues);
38095
+ this._error = error;
38096
+ return this._error;
38097
+ }
38098
+ };
38099
+ }
38100
+ };
38101
+ function processCreateParams(params) {
38102
+ if (!params)
38103
+ return {};
38104
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
38105
+ if (errorMap2 && (invalid_type_error || required_error)) {
38106
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
38107
+ }
38108
+ if (errorMap2)
38109
+ return { errorMap: errorMap2, description };
38110
+ const customMap = (iss, ctx) => {
38111
+ const { message } = params;
38112
+ if (iss.code === "invalid_enum_value") {
38113
+ return { message: message ?? ctx.defaultError };
38114
+ }
38115
+ if (typeof ctx.data === "undefined") {
38116
+ return { message: message ?? required_error ?? ctx.defaultError };
38117
+ }
38118
+ if (iss.code !== "invalid_type")
38119
+ return { message: ctx.defaultError };
38120
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
38121
+ };
38122
+ return { errorMap: customMap, description };
38123
+ }
38124
+ var ZodType = class {
38125
+ get description() {
38126
+ return this._def.description;
38127
+ }
38128
+ _getType(input) {
38129
+ return getParsedType(input.data);
38130
+ }
38131
+ _getOrReturnCtx(input, ctx) {
38132
+ return ctx || {
38133
+ common: input.parent.common,
38134
+ data: input.data,
38135
+ parsedType: getParsedType(input.data),
38136
+ schemaErrorMap: this._def.errorMap,
38137
+ path: input.path,
38138
+ parent: input.parent
38139
+ };
38140
+ }
38141
+ _processInputParams(input) {
38142
+ return {
38143
+ status: new ParseStatus(),
38144
+ ctx: {
38145
+ common: input.parent.common,
38146
+ data: input.data,
38147
+ parsedType: getParsedType(input.data),
38148
+ schemaErrorMap: this._def.errorMap,
38149
+ path: input.path,
38150
+ parent: input.parent
38151
+ }
38152
+ };
38153
+ }
38154
+ _parseSync(input) {
38155
+ const result = this._parse(input);
38156
+ if (isAsync(result)) {
38157
+ throw new Error("Synchronous parse encountered promise.");
38158
+ }
38159
+ return result;
38160
+ }
38161
+ _parseAsync(input) {
38162
+ const result = this._parse(input);
38163
+ return Promise.resolve(result);
38164
+ }
38165
+ parse(data, params) {
38166
+ const result = this.safeParse(data, params);
38167
+ if (result.success)
38168
+ return result.data;
38169
+ throw result.error;
38170
+ }
38171
+ safeParse(data, params) {
38172
+ const ctx = {
38173
+ common: {
38174
+ issues: [],
38175
+ async: params?.async ?? false,
38176
+ contextualErrorMap: params?.errorMap
38177
+ },
38178
+ path: params?.path || [],
38179
+ schemaErrorMap: this._def.errorMap,
38180
+ parent: null,
38181
+ data,
38182
+ parsedType: getParsedType(data)
38183
+ };
38184
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
38185
+ return handleResult(ctx, result);
38186
+ }
38187
+ "~validate"(data) {
38188
+ const ctx = {
38189
+ common: {
38190
+ issues: [],
38191
+ async: !!this["~standard"].async
38192
+ },
38193
+ path: [],
38194
+ schemaErrorMap: this._def.errorMap,
38195
+ parent: null,
38196
+ data,
38197
+ parsedType: getParsedType(data)
38198
+ };
38199
+ if (!this["~standard"].async) {
38200
+ try {
38201
+ const result = this._parseSync({ data, path: [], parent: ctx });
38202
+ return isValid(result) ? {
38203
+ value: result.value
38204
+ } : {
38205
+ issues: ctx.common.issues
38206
+ };
38207
+ } catch (err) {
38208
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
38209
+ this["~standard"].async = true;
38210
+ }
38211
+ ctx.common = {
38212
+ issues: [],
38213
+ async: true
38214
+ };
38215
+ }
38216
+ }
38217
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
38218
+ value: result.value
38219
+ } : {
38220
+ issues: ctx.common.issues
38221
+ });
38222
+ }
38223
+ async parseAsync(data, params) {
38224
+ const result = await this.safeParseAsync(data, params);
38225
+ if (result.success)
38226
+ return result.data;
38227
+ throw result.error;
38228
+ }
38229
+ async safeParseAsync(data, params) {
38230
+ const ctx = {
38231
+ common: {
38232
+ issues: [],
38233
+ contextualErrorMap: params?.errorMap,
38234
+ async: true
38235
+ },
38236
+ path: params?.path || [],
38237
+ schemaErrorMap: this._def.errorMap,
38238
+ parent: null,
38239
+ data,
38240
+ parsedType: getParsedType(data)
38241
+ };
38242
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
38243
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
38244
+ return handleResult(ctx, result);
38245
+ }
38246
+ refine(check, message) {
38247
+ const getIssueProperties = (val) => {
38248
+ if (typeof message === "string" || typeof message === "undefined") {
38249
+ return { message };
38250
+ } else if (typeof message === "function") {
38251
+ return message(val);
38252
+ } else {
38253
+ return message;
38254
+ }
38255
+ };
38256
+ return this._refinement((val, ctx) => {
38257
+ const result = check(val);
38258
+ const setError = () => ctx.addIssue({
38259
+ code: ZodIssueCode.custom,
38260
+ ...getIssueProperties(val)
38261
+ });
38262
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
38263
+ return result.then((data) => {
38264
+ if (!data) {
38265
+ setError();
38266
+ return false;
38267
+ } else {
38268
+ return true;
38269
+ }
38270
+ });
38271
+ }
38272
+ if (!result) {
38273
+ setError();
38274
+ return false;
38275
+ } else {
38276
+ return true;
38277
+ }
38278
+ });
38279
+ }
38280
+ refinement(check, refinementData) {
38281
+ return this._refinement((val, ctx) => {
38282
+ if (!check(val)) {
38283
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
38284
+ return false;
38285
+ } else {
38286
+ return true;
38287
+ }
38288
+ });
38289
+ }
38290
+ _refinement(refinement) {
38291
+ return new ZodEffects({
38292
+ schema: this,
38293
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
38294
+ effect: { type: "refinement", refinement }
38295
+ });
38296
+ }
38297
+ superRefine(refinement) {
38298
+ return this._refinement(refinement);
38299
+ }
38300
+ constructor(def) {
38301
+ this.spa = this.safeParseAsync;
38302
+ this._def = def;
38303
+ this.parse = this.parse.bind(this);
38304
+ this.safeParse = this.safeParse.bind(this);
38305
+ this.parseAsync = this.parseAsync.bind(this);
38306
+ this.safeParseAsync = this.safeParseAsync.bind(this);
38307
+ this.spa = this.spa.bind(this);
38308
+ this.refine = this.refine.bind(this);
38309
+ this.refinement = this.refinement.bind(this);
38310
+ this.superRefine = this.superRefine.bind(this);
38311
+ this.optional = this.optional.bind(this);
38312
+ this.nullable = this.nullable.bind(this);
38313
+ this.nullish = this.nullish.bind(this);
38314
+ this.array = this.array.bind(this);
38315
+ this.promise = this.promise.bind(this);
38316
+ this.or = this.or.bind(this);
38317
+ this.and = this.and.bind(this);
38318
+ this.transform = this.transform.bind(this);
38319
+ this.brand = this.brand.bind(this);
38320
+ this.default = this.default.bind(this);
38321
+ this.catch = this.catch.bind(this);
38322
+ this.describe = this.describe.bind(this);
38323
+ this.pipe = this.pipe.bind(this);
38324
+ this.readonly = this.readonly.bind(this);
38325
+ this.isNullable = this.isNullable.bind(this);
38326
+ this.isOptional = this.isOptional.bind(this);
38327
+ this["~standard"] = {
38328
+ version: 1,
38329
+ vendor: "zod",
38330
+ validate: (data) => this["~validate"](data)
38331
+ };
38332
+ }
38333
+ optional() {
38334
+ return ZodOptional.create(this, this._def);
38335
+ }
38336
+ nullable() {
38337
+ return ZodNullable.create(this, this._def);
38338
+ }
38339
+ nullish() {
38340
+ return this.nullable().optional();
38341
+ }
38342
+ array() {
38343
+ return ZodArray.create(this);
38344
+ }
38345
+ promise() {
38346
+ return ZodPromise.create(this, this._def);
38347
+ }
38348
+ or(option) {
38349
+ return ZodUnion.create([this, option], this._def);
38350
+ }
38351
+ and(incoming) {
38352
+ return ZodIntersection.create(this, incoming, this._def);
38353
+ }
38354
+ transform(transform) {
38355
+ return new ZodEffects({
38356
+ ...processCreateParams(this._def),
38357
+ schema: this,
38358
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
38359
+ effect: { type: "transform", transform }
38360
+ });
38361
+ }
38362
+ default(def) {
38363
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
38364
+ return new ZodDefault({
38365
+ ...processCreateParams(this._def),
38366
+ innerType: this,
38367
+ defaultValue: defaultValueFunc,
38368
+ typeName: ZodFirstPartyTypeKind.ZodDefault
38369
+ });
38370
+ }
38371
+ brand() {
38372
+ return new ZodBranded({
38373
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
38374
+ type: this,
38375
+ ...processCreateParams(this._def)
38376
+ });
38377
+ }
38378
+ catch(def) {
38379
+ const catchValueFunc = typeof def === "function" ? def : () => def;
38380
+ return new ZodCatch({
38381
+ ...processCreateParams(this._def),
38382
+ innerType: this,
38383
+ catchValue: catchValueFunc,
38384
+ typeName: ZodFirstPartyTypeKind.ZodCatch
38385
+ });
38386
+ }
38387
+ describe(description) {
38388
+ const This = this.constructor;
38389
+ return new This({
38390
+ ...this._def,
38391
+ description
38392
+ });
38393
+ }
38394
+ pipe(target) {
38395
+ return ZodPipeline.create(this, target);
38396
+ }
38397
+ readonly() {
38398
+ return ZodReadonly.create(this);
38399
+ }
38400
+ isOptional() {
38401
+ return this.safeParse(void 0).success;
38402
+ }
38403
+ isNullable() {
38404
+ return this.safeParse(null).success;
38405
+ }
38406
+ };
38407
+ var cuidRegex = /^c[^\s-]{8,}$/i;
38408
+ var cuid2Regex = /^[0-9a-z]+$/;
38409
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
38410
+ var uuidRegex = /^[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;
38411
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
38412
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
38413
+ var durationRegex = /^[-+]?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)?)??$/;
38414
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
38415
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
38416
+ var emojiRegex;
38417
+ var ipv4Regex = /^(?:(?: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])$/;
38418
+ var ipv4CidrRegex = /^(?:(?: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])$/;
38419
+ var ipv6Regex = /^(([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]))$/;
38420
+ var ipv6CidrRegex = /^(([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])$/;
38421
+ var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
38422
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
38423
+ var dateRegexSource = `((\\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])))`;
38424
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
38425
+ function timeRegexSource(args) {
38426
+ let secondsRegexSource = `[0-5]\\d`;
38427
+ if (args.precision) {
38428
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
38429
+ } else if (args.precision == null) {
38430
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
38431
+ }
38432
+ const secondsQuantifier = args.precision ? "+" : "?";
38433
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
38434
+ }
38435
+ function timeRegex(args) {
38436
+ return new RegExp(`^${timeRegexSource(args)}$`);
38437
+ }
38438
+ function datetimeRegex(args) {
38439
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
38440
+ const opts = [];
38441
+ opts.push(args.local ? `Z?` : `Z`);
38442
+ if (args.offset)
38443
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
38444
+ regex = `${regex}(${opts.join("|")})`;
38445
+ return new RegExp(`^${regex}$`);
38446
+ }
38447
+ function isValidIP(ip, version4) {
38448
+ if ((version4 === "v4" || !version4) && ipv4Regex.test(ip)) {
38449
+ return true;
38450
+ }
38451
+ if ((version4 === "v6" || !version4) && ipv6Regex.test(ip)) {
38452
+ return true;
38453
+ }
38454
+ return false;
38455
+ }
38456
+ function isValidJWT(jwt, alg) {
38457
+ if (!jwtRegex.test(jwt))
38458
+ return false;
38459
+ try {
38460
+ const [header] = jwt.split(".");
38461
+ if (!header)
38462
+ return false;
38463
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
38464
+ const decoded = JSON.parse(atob(base64));
38465
+ if (typeof decoded !== "object" || decoded === null)
38466
+ return false;
38467
+ if ("typ" in decoded && decoded?.typ !== "JWT")
38468
+ return false;
38469
+ if (!decoded.alg)
38470
+ return false;
38471
+ if (alg && decoded.alg !== alg)
38472
+ return false;
38473
+ return true;
38474
+ } catch {
38475
+ return false;
38476
+ }
38477
+ }
38478
+ function isValidCidr(ip, version4) {
38479
+ if ((version4 === "v4" || !version4) && ipv4CidrRegex.test(ip)) {
38480
+ return true;
38481
+ }
38482
+ if ((version4 === "v6" || !version4) && ipv6CidrRegex.test(ip)) {
38483
+ return true;
38484
+ }
38485
+ return false;
38486
+ }
38487
+ var ZodString = class _ZodString extends ZodType {
38488
+ _parse(input) {
38489
+ if (this._def.coerce) {
38490
+ input.data = String(input.data);
38491
+ }
38492
+ const parsedType = this._getType(input);
38493
+ if (parsedType !== ZodParsedType.string) {
38494
+ const ctx2 = this._getOrReturnCtx(input);
38495
+ addIssueToContext(ctx2, {
38496
+ code: ZodIssueCode.invalid_type,
38497
+ expected: ZodParsedType.string,
38498
+ received: ctx2.parsedType
38499
+ });
38500
+ return INVALID;
38501
+ }
38502
+ const status = new ParseStatus();
38503
+ let ctx = void 0;
38504
+ for (const check of this._def.checks) {
38505
+ if (check.kind === "min") {
38506
+ if (input.data.length < check.value) {
38507
+ ctx = this._getOrReturnCtx(input, ctx);
38508
+ addIssueToContext(ctx, {
38509
+ code: ZodIssueCode.too_small,
38510
+ minimum: check.value,
38511
+ type: "string",
38512
+ inclusive: true,
38513
+ exact: false,
38514
+ message: check.message
38515
+ });
38516
+ status.dirty();
38517
+ }
38518
+ } else if (check.kind === "max") {
38519
+ if (input.data.length > check.value) {
38520
+ ctx = this._getOrReturnCtx(input, ctx);
38521
+ addIssueToContext(ctx, {
38522
+ code: ZodIssueCode.too_big,
38523
+ maximum: check.value,
38524
+ type: "string",
38525
+ inclusive: true,
38526
+ exact: false,
38527
+ message: check.message
38528
+ });
38529
+ status.dirty();
38530
+ }
38531
+ } else if (check.kind === "length") {
38532
+ const tooBig = input.data.length > check.value;
38533
+ const tooSmall = input.data.length < check.value;
38534
+ if (tooBig || tooSmall) {
38535
+ ctx = this._getOrReturnCtx(input, ctx);
38536
+ if (tooBig) {
38537
+ addIssueToContext(ctx, {
38538
+ code: ZodIssueCode.too_big,
38539
+ maximum: check.value,
38540
+ type: "string",
38541
+ inclusive: true,
38542
+ exact: true,
38543
+ message: check.message
38544
+ });
38545
+ } else if (tooSmall) {
38546
+ addIssueToContext(ctx, {
38547
+ code: ZodIssueCode.too_small,
38548
+ minimum: check.value,
38549
+ type: "string",
38550
+ inclusive: true,
38551
+ exact: true,
38552
+ message: check.message
38553
+ });
38554
+ }
38555
+ status.dirty();
38556
+ }
38557
+ } else if (check.kind === "email") {
38558
+ if (!emailRegex.test(input.data)) {
38559
+ ctx = this._getOrReturnCtx(input, ctx);
38560
+ addIssueToContext(ctx, {
38561
+ validation: "email",
38562
+ code: ZodIssueCode.invalid_string,
38563
+ message: check.message
38564
+ });
38565
+ status.dirty();
38566
+ }
38567
+ } else if (check.kind === "emoji") {
38568
+ if (!emojiRegex) {
38569
+ emojiRegex = new RegExp(_emojiRegex, "u");
38570
+ }
38571
+ if (!emojiRegex.test(input.data)) {
38572
+ ctx = this._getOrReturnCtx(input, ctx);
38573
+ addIssueToContext(ctx, {
38574
+ validation: "emoji",
38575
+ code: ZodIssueCode.invalid_string,
38576
+ message: check.message
38577
+ });
38578
+ status.dirty();
38579
+ }
38580
+ } else if (check.kind === "uuid") {
38581
+ if (!uuidRegex.test(input.data)) {
38582
+ ctx = this._getOrReturnCtx(input, ctx);
38583
+ addIssueToContext(ctx, {
38584
+ validation: "uuid",
38585
+ code: ZodIssueCode.invalid_string,
38586
+ message: check.message
38587
+ });
38588
+ status.dirty();
38589
+ }
38590
+ } else if (check.kind === "nanoid") {
38591
+ if (!nanoidRegex.test(input.data)) {
38592
+ ctx = this._getOrReturnCtx(input, ctx);
38593
+ addIssueToContext(ctx, {
38594
+ validation: "nanoid",
38595
+ code: ZodIssueCode.invalid_string,
38596
+ message: check.message
38597
+ });
38598
+ status.dirty();
38599
+ }
38600
+ } else if (check.kind === "cuid") {
38601
+ if (!cuidRegex.test(input.data)) {
38602
+ ctx = this._getOrReturnCtx(input, ctx);
38603
+ addIssueToContext(ctx, {
38604
+ validation: "cuid",
38605
+ code: ZodIssueCode.invalid_string,
38606
+ message: check.message
38607
+ });
38608
+ status.dirty();
38609
+ }
38610
+ } else if (check.kind === "cuid2") {
38611
+ if (!cuid2Regex.test(input.data)) {
38612
+ ctx = this._getOrReturnCtx(input, ctx);
38613
+ addIssueToContext(ctx, {
38614
+ validation: "cuid2",
38615
+ code: ZodIssueCode.invalid_string,
38616
+ message: check.message
38617
+ });
38618
+ status.dirty();
38619
+ }
38620
+ } else if (check.kind === "ulid") {
38621
+ if (!ulidRegex.test(input.data)) {
38622
+ ctx = this._getOrReturnCtx(input, ctx);
38623
+ addIssueToContext(ctx, {
38624
+ validation: "ulid",
38625
+ code: ZodIssueCode.invalid_string,
38626
+ message: check.message
38627
+ });
38628
+ status.dirty();
38629
+ }
38630
+ } else if (check.kind === "url") {
38631
+ try {
38632
+ new URL(input.data);
38633
+ } catch {
38634
+ ctx = this._getOrReturnCtx(input, ctx);
38635
+ addIssueToContext(ctx, {
38636
+ validation: "url",
38637
+ code: ZodIssueCode.invalid_string,
38638
+ message: check.message
38639
+ });
38640
+ status.dirty();
38641
+ }
38642
+ } else if (check.kind === "regex") {
38643
+ check.regex.lastIndex = 0;
38644
+ const testResult = check.regex.test(input.data);
38645
+ if (!testResult) {
38646
+ ctx = this._getOrReturnCtx(input, ctx);
38647
+ addIssueToContext(ctx, {
38648
+ validation: "regex",
38649
+ code: ZodIssueCode.invalid_string,
38650
+ message: check.message
38651
+ });
38652
+ status.dirty();
38653
+ }
38654
+ } else if (check.kind === "trim") {
38655
+ input.data = input.data.trim();
38656
+ } else if (check.kind === "includes") {
38657
+ if (!input.data.includes(check.value, check.position)) {
38658
+ ctx = this._getOrReturnCtx(input, ctx);
38659
+ addIssueToContext(ctx, {
38660
+ code: ZodIssueCode.invalid_string,
38661
+ validation: { includes: check.value, position: check.position },
38662
+ message: check.message
38663
+ });
38664
+ status.dirty();
38665
+ }
38666
+ } else if (check.kind === "toLowerCase") {
38667
+ input.data = input.data.toLowerCase();
38668
+ } else if (check.kind === "toUpperCase") {
38669
+ input.data = input.data.toUpperCase();
38670
+ } else if (check.kind === "startsWith") {
38671
+ if (!input.data.startsWith(check.value)) {
38672
+ ctx = this._getOrReturnCtx(input, ctx);
38673
+ addIssueToContext(ctx, {
38674
+ code: ZodIssueCode.invalid_string,
38675
+ validation: { startsWith: check.value },
38676
+ message: check.message
38677
+ });
38678
+ status.dirty();
38679
+ }
38680
+ } else if (check.kind === "endsWith") {
38681
+ if (!input.data.endsWith(check.value)) {
38682
+ ctx = this._getOrReturnCtx(input, ctx);
38683
+ addIssueToContext(ctx, {
38684
+ code: ZodIssueCode.invalid_string,
38685
+ validation: { endsWith: check.value },
38686
+ message: check.message
38687
+ });
38688
+ status.dirty();
38689
+ }
38690
+ } else if (check.kind === "datetime") {
38691
+ const regex = datetimeRegex(check);
38692
+ if (!regex.test(input.data)) {
38693
+ ctx = this._getOrReturnCtx(input, ctx);
38694
+ addIssueToContext(ctx, {
38695
+ code: ZodIssueCode.invalid_string,
38696
+ validation: "datetime",
38697
+ message: check.message
38698
+ });
38699
+ status.dirty();
38700
+ }
38701
+ } else if (check.kind === "date") {
38702
+ const regex = dateRegex;
38703
+ if (!regex.test(input.data)) {
38704
+ ctx = this._getOrReturnCtx(input, ctx);
38705
+ addIssueToContext(ctx, {
38706
+ code: ZodIssueCode.invalid_string,
38707
+ validation: "date",
38708
+ message: check.message
38709
+ });
38710
+ status.dirty();
38711
+ }
38712
+ } else if (check.kind === "time") {
38713
+ const regex = timeRegex(check);
38714
+ if (!regex.test(input.data)) {
38715
+ ctx = this._getOrReturnCtx(input, ctx);
38716
+ addIssueToContext(ctx, {
38717
+ code: ZodIssueCode.invalid_string,
38718
+ validation: "time",
38719
+ message: check.message
38720
+ });
38721
+ status.dirty();
38722
+ }
38723
+ } else if (check.kind === "duration") {
38724
+ if (!durationRegex.test(input.data)) {
38725
+ ctx = this._getOrReturnCtx(input, ctx);
38726
+ addIssueToContext(ctx, {
38727
+ validation: "duration",
38728
+ code: ZodIssueCode.invalid_string,
38729
+ message: check.message
38730
+ });
38731
+ status.dirty();
38732
+ }
38733
+ } else if (check.kind === "ip") {
38734
+ if (!isValidIP(input.data, check.version)) {
38735
+ ctx = this._getOrReturnCtx(input, ctx);
38736
+ addIssueToContext(ctx, {
38737
+ validation: "ip",
38738
+ code: ZodIssueCode.invalid_string,
38739
+ message: check.message
38740
+ });
38741
+ status.dirty();
38742
+ }
38743
+ } else if (check.kind === "jwt") {
38744
+ if (!isValidJWT(input.data, check.alg)) {
38745
+ ctx = this._getOrReturnCtx(input, ctx);
38746
+ addIssueToContext(ctx, {
38747
+ validation: "jwt",
38748
+ code: ZodIssueCode.invalid_string,
38749
+ message: check.message
38750
+ });
38751
+ status.dirty();
38752
+ }
38753
+ } else if (check.kind === "cidr") {
38754
+ if (!isValidCidr(input.data, check.version)) {
38755
+ ctx = this._getOrReturnCtx(input, ctx);
38756
+ addIssueToContext(ctx, {
38757
+ validation: "cidr",
38758
+ code: ZodIssueCode.invalid_string,
38759
+ message: check.message
38760
+ });
38761
+ status.dirty();
38762
+ }
38763
+ } else if (check.kind === "base64") {
38764
+ if (!base64Regex2.test(input.data)) {
38765
+ ctx = this._getOrReturnCtx(input, ctx);
38766
+ addIssueToContext(ctx, {
38767
+ validation: "base64",
38768
+ code: ZodIssueCode.invalid_string,
38769
+ message: check.message
38770
+ });
38771
+ status.dirty();
38772
+ }
38773
+ } else if (check.kind === "base64url") {
38774
+ if (!base64urlRegex.test(input.data)) {
38775
+ ctx = this._getOrReturnCtx(input, ctx);
38776
+ addIssueToContext(ctx, {
38777
+ validation: "base64url",
38778
+ code: ZodIssueCode.invalid_string,
38779
+ message: check.message
38780
+ });
38781
+ status.dirty();
38782
+ }
38783
+ } else {
38784
+ util.assertNever(check);
38785
+ }
38786
+ }
38787
+ return { status: status.value, value: input.data };
38788
+ }
38789
+ _regex(regex, validation, message) {
38790
+ return this.refinement((data) => regex.test(data), {
38791
+ validation,
38792
+ code: ZodIssueCode.invalid_string,
38793
+ ...errorUtil.errToObj(message)
38794
+ });
38795
+ }
38796
+ _addCheck(check) {
38797
+ return new _ZodString({
38798
+ ...this._def,
38799
+ checks: [...this._def.checks, check]
38800
+ });
38801
+ }
38802
+ email(message) {
38803
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
38804
+ }
38805
+ url(message) {
38806
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
38807
+ }
38808
+ emoji(message) {
38809
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
38810
+ }
38811
+ uuid(message) {
38812
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
38813
+ }
38814
+ nanoid(message) {
38815
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
38816
+ }
38817
+ cuid(message) {
38818
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
38819
+ }
38820
+ cuid2(message) {
38821
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
38822
+ }
38823
+ ulid(message) {
38824
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
38825
+ }
38826
+ base64(message) {
38827
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
38828
+ }
38829
+ base64url(message) {
38830
+ return this._addCheck({
38831
+ kind: "base64url",
38832
+ ...errorUtil.errToObj(message)
38833
+ });
38834
+ }
38835
+ jwt(options) {
38836
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
38837
+ }
38838
+ ip(options) {
38839
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
38840
+ }
38841
+ cidr(options) {
38842
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
38843
+ }
38844
+ datetime(options) {
38845
+ if (typeof options === "string") {
38846
+ return this._addCheck({
38847
+ kind: "datetime",
38848
+ precision: null,
38849
+ offset: false,
38850
+ local: false,
38851
+ message: options
38852
+ });
38853
+ }
38854
+ return this._addCheck({
38855
+ kind: "datetime",
38856
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
38857
+ offset: options?.offset ?? false,
38858
+ local: options?.local ?? false,
38859
+ ...errorUtil.errToObj(options?.message)
38860
+ });
38861
+ }
38862
+ date(message) {
38863
+ return this._addCheck({ kind: "date", message });
38864
+ }
38865
+ time(options) {
38866
+ if (typeof options === "string") {
38867
+ return this._addCheck({
38868
+ kind: "time",
38869
+ precision: null,
38870
+ message: options
38871
+ });
38872
+ }
38873
+ return this._addCheck({
38874
+ kind: "time",
38875
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
38876
+ ...errorUtil.errToObj(options?.message)
38877
+ });
38878
+ }
38879
+ duration(message) {
38880
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
38881
+ }
38882
+ regex(regex, message) {
38883
+ return this._addCheck({
38884
+ kind: "regex",
38885
+ regex,
38886
+ ...errorUtil.errToObj(message)
38887
+ });
38888
+ }
38889
+ includes(value, options) {
38890
+ return this._addCheck({
38891
+ kind: "includes",
38892
+ value,
38893
+ position: options?.position,
38894
+ ...errorUtil.errToObj(options?.message)
38895
+ });
38896
+ }
38897
+ startsWith(value, message) {
38898
+ return this._addCheck({
38899
+ kind: "startsWith",
38900
+ value,
38901
+ ...errorUtil.errToObj(message)
38902
+ });
38903
+ }
38904
+ endsWith(value, message) {
38905
+ return this._addCheck({
38906
+ kind: "endsWith",
38907
+ value,
38908
+ ...errorUtil.errToObj(message)
38909
+ });
38910
+ }
38911
+ min(minLength, message) {
38912
+ return this._addCheck({
38913
+ kind: "min",
38914
+ value: minLength,
38915
+ ...errorUtil.errToObj(message)
38916
+ });
38917
+ }
38918
+ max(maxLength, message) {
38919
+ return this._addCheck({
38920
+ kind: "max",
38921
+ value: maxLength,
38922
+ ...errorUtil.errToObj(message)
38923
+ });
38924
+ }
38925
+ length(len, message) {
38926
+ return this._addCheck({
38927
+ kind: "length",
38928
+ value: len,
38929
+ ...errorUtil.errToObj(message)
38930
+ });
38931
+ }
38932
+ /**
38933
+ * Equivalent to `.min(1)`
38934
+ */
38935
+ nonempty(message) {
38936
+ return this.min(1, errorUtil.errToObj(message));
38937
+ }
38938
+ trim() {
38939
+ return new _ZodString({
38940
+ ...this._def,
38941
+ checks: [...this._def.checks, { kind: "trim" }]
38942
+ });
38943
+ }
38944
+ toLowerCase() {
38945
+ return new _ZodString({
38946
+ ...this._def,
38947
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
38948
+ });
38949
+ }
38950
+ toUpperCase() {
38951
+ return new _ZodString({
38952
+ ...this._def,
38953
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
38954
+ });
38955
+ }
38956
+ get isDatetime() {
38957
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
38958
+ }
38959
+ get isDate() {
38960
+ return !!this._def.checks.find((ch) => ch.kind === "date");
38961
+ }
38962
+ get isTime() {
38963
+ return !!this._def.checks.find((ch) => ch.kind === "time");
38964
+ }
38965
+ get isDuration() {
38966
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
38967
+ }
38968
+ get isEmail() {
38969
+ return !!this._def.checks.find((ch) => ch.kind === "email");
38970
+ }
38971
+ get isURL() {
38972
+ return !!this._def.checks.find((ch) => ch.kind === "url");
38973
+ }
38974
+ get isEmoji() {
38975
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
38976
+ }
38977
+ get isUUID() {
38978
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
38979
+ }
38980
+ get isNANOID() {
38981
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
38982
+ }
38983
+ get isCUID() {
38984
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
38985
+ }
38986
+ get isCUID2() {
38987
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
38988
+ }
38989
+ get isULID() {
38990
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
38991
+ }
38992
+ get isIP() {
38993
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
38994
+ }
38995
+ get isCIDR() {
38996
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
38997
+ }
38998
+ get isBase64() {
38999
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
39000
+ }
39001
+ get isBase64url() {
39002
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
39003
+ }
39004
+ get minLength() {
39005
+ let min = null;
39006
+ for (const ch of this._def.checks) {
39007
+ if (ch.kind === "min") {
39008
+ if (min === null || ch.value > min)
39009
+ min = ch.value;
39010
+ }
39011
+ }
39012
+ return min;
39013
+ }
39014
+ get maxLength() {
39015
+ let max = null;
39016
+ for (const ch of this._def.checks) {
39017
+ if (ch.kind === "max") {
39018
+ if (max === null || ch.value < max)
39019
+ max = ch.value;
39020
+ }
39021
+ }
39022
+ return max;
39023
+ }
39024
+ };
39025
+ ZodString.create = (params) => {
39026
+ return new ZodString({
39027
+ checks: [],
39028
+ typeName: ZodFirstPartyTypeKind.ZodString,
39029
+ coerce: params?.coerce ?? false,
39030
+ ...processCreateParams(params)
39031
+ });
39032
+ };
39033
+ function floatSafeRemainder(val, step) {
39034
+ const valDecCount = (val.toString().split(".")[1] || "").length;
39035
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
39036
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
39037
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
39038
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
39039
+ return valInt % stepInt / 10 ** decCount;
39040
+ }
39041
+ var ZodNumber = class _ZodNumber extends ZodType {
39042
+ constructor() {
39043
+ super(...arguments);
39044
+ this.min = this.gte;
39045
+ this.max = this.lte;
39046
+ this.step = this.multipleOf;
39047
+ }
39048
+ _parse(input) {
39049
+ if (this._def.coerce) {
39050
+ input.data = Number(input.data);
39051
+ }
39052
+ const parsedType = this._getType(input);
39053
+ if (parsedType !== ZodParsedType.number) {
39054
+ const ctx2 = this._getOrReturnCtx(input);
39055
+ addIssueToContext(ctx2, {
39056
+ code: ZodIssueCode.invalid_type,
39057
+ expected: ZodParsedType.number,
39058
+ received: ctx2.parsedType
39059
+ });
39060
+ return INVALID;
39061
+ }
39062
+ let ctx = void 0;
39063
+ const status = new ParseStatus();
39064
+ for (const check of this._def.checks) {
39065
+ if (check.kind === "int") {
39066
+ if (!util.isInteger(input.data)) {
39067
+ ctx = this._getOrReturnCtx(input, ctx);
39068
+ addIssueToContext(ctx, {
39069
+ code: ZodIssueCode.invalid_type,
39070
+ expected: "integer",
39071
+ received: "float",
39072
+ message: check.message
39073
+ });
39074
+ status.dirty();
39075
+ }
39076
+ } else if (check.kind === "min") {
39077
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
39078
+ if (tooSmall) {
39079
+ ctx = this._getOrReturnCtx(input, ctx);
39080
+ addIssueToContext(ctx, {
39081
+ code: ZodIssueCode.too_small,
39082
+ minimum: check.value,
39083
+ type: "number",
39084
+ inclusive: check.inclusive,
39085
+ exact: false,
39086
+ message: check.message
39087
+ });
39088
+ status.dirty();
39089
+ }
39090
+ } else if (check.kind === "max") {
39091
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
39092
+ if (tooBig) {
39093
+ ctx = this._getOrReturnCtx(input, ctx);
39094
+ addIssueToContext(ctx, {
39095
+ code: ZodIssueCode.too_big,
39096
+ maximum: check.value,
39097
+ type: "number",
39098
+ inclusive: check.inclusive,
39099
+ exact: false,
39100
+ message: check.message
39101
+ });
39102
+ status.dirty();
39103
+ }
39104
+ } else if (check.kind === "multipleOf") {
39105
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
39106
+ ctx = this._getOrReturnCtx(input, ctx);
39107
+ addIssueToContext(ctx, {
39108
+ code: ZodIssueCode.not_multiple_of,
39109
+ multipleOf: check.value,
39110
+ message: check.message
39111
+ });
39112
+ status.dirty();
39113
+ }
39114
+ } else if (check.kind === "finite") {
39115
+ if (!Number.isFinite(input.data)) {
39116
+ ctx = this._getOrReturnCtx(input, ctx);
39117
+ addIssueToContext(ctx, {
39118
+ code: ZodIssueCode.not_finite,
39119
+ message: check.message
39120
+ });
39121
+ status.dirty();
39122
+ }
39123
+ } else {
39124
+ util.assertNever(check);
39125
+ }
39126
+ }
39127
+ return { status: status.value, value: input.data };
39128
+ }
39129
+ gte(value, message) {
39130
+ return this.setLimit("min", value, true, errorUtil.toString(message));
39131
+ }
39132
+ gt(value, message) {
39133
+ return this.setLimit("min", value, false, errorUtil.toString(message));
39134
+ }
39135
+ lte(value, message) {
39136
+ return this.setLimit("max", value, true, errorUtil.toString(message));
39137
+ }
39138
+ lt(value, message) {
39139
+ return this.setLimit("max", value, false, errorUtil.toString(message));
39140
+ }
39141
+ setLimit(kind, value, inclusive, message) {
39142
+ return new _ZodNumber({
39143
+ ...this._def,
39144
+ checks: [
39145
+ ...this._def.checks,
39146
+ {
39147
+ kind,
39148
+ value,
39149
+ inclusive,
39150
+ message: errorUtil.toString(message)
39151
+ }
39152
+ ]
39153
+ });
39154
+ }
39155
+ _addCheck(check) {
39156
+ return new _ZodNumber({
39157
+ ...this._def,
39158
+ checks: [...this._def.checks, check]
39159
+ });
39160
+ }
39161
+ int(message) {
39162
+ return this._addCheck({
39163
+ kind: "int",
39164
+ message: errorUtil.toString(message)
39165
+ });
39166
+ }
39167
+ positive(message) {
39168
+ return this._addCheck({
39169
+ kind: "min",
39170
+ value: 0,
39171
+ inclusive: false,
39172
+ message: errorUtil.toString(message)
39173
+ });
39174
+ }
39175
+ negative(message) {
39176
+ return this._addCheck({
39177
+ kind: "max",
39178
+ value: 0,
39179
+ inclusive: false,
39180
+ message: errorUtil.toString(message)
39181
+ });
39182
+ }
39183
+ nonpositive(message) {
39184
+ return this._addCheck({
39185
+ kind: "max",
39186
+ value: 0,
39187
+ inclusive: true,
39188
+ message: errorUtil.toString(message)
39189
+ });
39190
+ }
39191
+ nonnegative(message) {
39192
+ return this._addCheck({
39193
+ kind: "min",
39194
+ value: 0,
39195
+ inclusive: true,
39196
+ message: errorUtil.toString(message)
39197
+ });
39198
+ }
39199
+ multipleOf(value, message) {
39200
+ return this._addCheck({
39201
+ kind: "multipleOf",
39202
+ value,
39203
+ message: errorUtil.toString(message)
39204
+ });
39205
+ }
39206
+ finite(message) {
39207
+ return this._addCheck({
39208
+ kind: "finite",
39209
+ message: errorUtil.toString(message)
39210
+ });
39211
+ }
39212
+ safe(message) {
39213
+ return this._addCheck({
39214
+ kind: "min",
39215
+ inclusive: true,
39216
+ value: Number.MIN_SAFE_INTEGER,
39217
+ message: errorUtil.toString(message)
39218
+ })._addCheck({
39219
+ kind: "max",
39220
+ inclusive: true,
39221
+ value: Number.MAX_SAFE_INTEGER,
39222
+ message: errorUtil.toString(message)
39223
+ });
39224
+ }
39225
+ get minValue() {
39226
+ let min = null;
39227
+ for (const ch of this._def.checks) {
39228
+ if (ch.kind === "min") {
39229
+ if (min === null || ch.value > min)
39230
+ min = ch.value;
39231
+ }
39232
+ }
39233
+ return min;
39234
+ }
39235
+ get maxValue() {
39236
+ let max = null;
39237
+ for (const ch of this._def.checks) {
39238
+ if (ch.kind === "max") {
39239
+ if (max === null || ch.value < max)
39240
+ max = ch.value;
39241
+ }
39242
+ }
39243
+ return max;
39244
+ }
39245
+ get isInt() {
39246
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
39247
+ }
39248
+ get isFinite() {
39249
+ let max = null;
39250
+ let min = null;
39251
+ for (const ch of this._def.checks) {
39252
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
39253
+ return true;
39254
+ } else if (ch.kind === "min") {
39255
+ if (min === null || ch.value > min)
39256
+ min = ch.value;
39257
+ } else if (ch.kind === "max") {
39258
+ if (max === null || ch.value < max)
39259
+ max = ch.value;
39260
+ }
39261
+ }
39262
+ return Number.isFinite(min) && Number.isFinite(max);
39263
+ }
39264
+ };
39265
+ ZodNumber.create = (params) => {
39266
+ return new ZodNumber({
39267
+ checks: [],
39268
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
39269
+ coerce: params?.coerce || false,
39270
+ ...processCreateParams(params)
39271
+ });
39272
+ };
39273
+ var ZodBigInt = class _ZodBigInt extends ZodType {
39274
+ constructor() {
39275
+ super(...arguments);
39276
+ this.min = this.gte;
39277
+ this.max = this.lte;
39278
+ }
39279
+ _parse(input) {
39280
+ if (this._def.coerce) {
39281
+ try {
39282
+ input.data = BigInt(input.data);
39283
+ } catch {
39284
+ return this._getInvalidInput(input);
39285
+ }
39286
+ }
39287
+ const parsedType = this._getType(input);
39288
+ if (parsedType !== ZodParsedType.bigint) {
39289
+ return this._getInvalidInput(input);
39290
+ }
39291
+ let ctx = void 0;
39292
+ const status = new ParseStatus();
39293
+ for (const check of this._def.checks) {
39294
+ if (check.kind === "min") {
39295
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
39296
+ if (tooSmall) {
39297
+ ctx = this._getOrReturnCtx(input, ctx);
39298
+ addIssueToContext(ctx, {
39299
+ code: ZodIssueCode.too_small,
39300
+ type: "bigint",
39301
+ minimum: check.value,
39302
+ inclusive: check.inclusive,
39303
+ message: check.message
39304
+ });
39305
+ status.dirty();
39306
+ }
39307
+ } else if (check.kind === "max") {
39308
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
39309
+ if (tooBig) {
39310
+ ctx = this._getOrReturnCtx(input, ctx);
39311
+ addIssueToContext(ctx, {
39312
+ code: ZodIssueCode.too_big,
39313
+ type: "bigint",
39314
+ maximum: check.value,
39315
+ inclusive: check.inclusive,
39316
+ message: check.message
39317
+ });
39318
+ status.dirty();
39319
+ }
39320
+ } else if (check.kind === "multipleOf") {
39321
+ if (input.data % check.value !== BigInt(0)) {
39322
+ ctx = this._getOrReturnCtx(input, ctx);
39323
+ addIssueToContext(ctx, {
39324
+ code: ZodIssueCode.not_multiple_of,
39325
+ multipleOf: check.value,
39326
+ message: check.message
39327
+ });
39328
+ status.dirty();
39329
+ }
39330
+ } else {
39331
+ util.assertNever(check);
39332
+ }
39333
+ }
39334
+ return { status: status.value, value: input.data };
39335
+ }
39336
+ _getInvalidInput(input) {
39337
+ const ctx = this._getOrReturnCtx(input);
39338
+ addIssueToContext(ctx, {
39339
+ code: ZodIssueCode.invalid_type,
39340
+ expected: ZodParsedType.bigint,
39341
+ received: ctx.parsedType
39342
+ });
39343
+ return INVALID;
39344
+ }
39345
+ gte(value, message) {
39346
+ return this.setLimit("min", value, true, errorUtil.toString(message));
39347
+ }
39348
+ gt(value, message) {
39349
+ return this.setLimit("min", value, false, errorUtil.toString(message));
39350
+ }
39351
+ lte(value, message) {
39352
+ return this.setLimit("max", value, true, errorUtil.toString(message));
39353
+ }
39354
+ lt(value, message) {
39355
+ return this.setLimit("max", value, false, errorUtil.toString(message));
39356
+ }
39357
+ setLimit(kind, value, inclusive, message) {
39358
+ return new _ZodBigInt({
39359
+ ...this._def,
39360
+ checks: [
39361
+ ...this._def.checks,
39362
+ {
39363
+ kind,
39364
+ value,
39365
+ inclusive,
39366
+ message: errorUtil.toString(message)
39367
+ }
39368
+ ]
39369
+ });
39370
+ }
39371
+ _addCheck(check) {
39372
+ return new _ZodBigInt({
39373
+ ...this._def,
39374
+ checks: [...this._def.checks, check]
39375
+ });
39376
+ }
39377
+ positive(message) {
39378
+ return this._addCheck({
39379
+ kind: "min",
39380
+ value: BigInt(0),
39381
+ inclusive: false,
39382
+ message: errorUtil.toString(message)
39383
+ });
39384
+ }
39385
+ negative(message) {
39386
+ return this._addCheck({
39387
+ kind: "max",
39388
+ value: BigInt(0),
39389
+ inclusive: false,
39390
+ message: errorUtil.toString(message)
39391
+ });
39392
+ }
39393
+ nonpositive(message) {
39394
+ return this._addCheck({
39395
+ kind: "max",
39396
+ value: BigInt(0),
39397
+ inclusive: true,
39398
+ message: errorUtil.toString(message)
39399
+ });
39400
+ }
39401
+ nonnegative(message) {
39402
+ return this._addCheck({
39403
+ kind: "min",
39404
+ value: BigInt(0),
39405
+ inclusive: true,
39406
+ message: errorUtil.toString(message)
39407
+ });
39408
+ }
39409
+ multipleOf(value, message) {
39410
+ return this._addCheck({
39411
+ kind: "multipleOf",
39412
+ value,
39413
+ message: errorUtil.toString(message)
39414
+ });
39415
+ }
39416
+ get minValue() {
39417
+ let min = null;
39418
+ for (const ch of this._def.checks) {
39419
+ if (ch.kind === "min") {
39420
+ if (min === null || ch.value > min)
39421
+ min = ch.value;
39422
+ }
39423
+ }
39424
+ return min;
39425
+ }
39426
+ get maxValue() {
39427
+ let max = null;
39428
+ for (const ch of this._def.checks) {
39429
+ if (ch.kind === "max") {
39430
+ if (max === null || ch.value < max)
39431
+ max = ch.value;
39432
+ }
39433
+ }
39434
+ return max;
39435
+ }
39436
+ };
39437
+ ZodBigInt.create = (params) => {
39438
+ return new ZodBigInt({
39439
+ checks: [],
39440
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
39441
+ coerce: params?.coerce ?? false,
39442
+ ...processCreateParams(params)
39443
+ });
39444
+ };
39445
+ var ZodBoolean = class extends ZodType {
39446
+ _parse(input) {
39447
+ if (this._def.coerce) {
39448
+ input.data = Boolean(input.data);
39449
+ }
39450
+ const parsedType = this._getType(input);
39451
+ if (parsedType !== ZodParsedType.boolean) {
39452
+ const ctx = this._getOrReturnCtx(input);
39453
+ addIssueToContext(ctx, {
39454
+ code: ZodIssueCode.invalid_type,
39455
+ expected: ZodParsedType.boolean,
39456
+ received: ctx.parsedType
39457
+ });
39458
+ return INVALID;
39459
+ }
39460
+ return OK(input.data);
39461
+ }
39462
+ };
39463
+ ZodBoolean.create = (params) => {
39464
+ return new ZodBoolean({
39465
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
39466
+ coerce: params?.coerce || false,
39467
+ ...processCreateParams(params)
39468
+ });
39469
+ };
39470
+ var ZodDate = class _ZodDate extends ZodType {
39471
+ _parse(input) {
39472
+ if (this._def.coerce) {
39473
+ input.data = new Date(input.data);
39474
+ }
39475
+ const parsedType = this._getType(input);
39476
+ if (parsedType !== ZodParsedType.date) {
39477
+ const ctx2 = this._getOrReturnCtx(input);
39478
+ addIssueToContext(ctx2, {
39479
+ code: ZodIssueCode.invalid_type,
39480
+ expected: ZodParsedType.date,
39481
+ received: ctx2.parsedType
39482
+ });
39483
+ return INVALID;
39484
+ }
39485
+ if (Number.isNaN(input.data.getTime())) {
39486
+ const ctx2 = this._getOrReturnCtx(input);
39487
+ addIssueToContext(ctx2, {
39488
+ code: ZodIssueCode.invalid_date
39489
+ });
39490
+ return INVALID;
39491
+ }
39492
+ const status = new ParseStatus();
39493
+ let ctx = void 0;
39494
+ for (const check of this._def.checks) {
39495
+ if (check.kind === "min") {
39496
+ if (input.data.getTime() < check.value) {
39497
+ ctx = this._getOrReturnCtx(input, ctx);
39498
+ addIssueToContext(ctx, {
39499
+ code: ZodIssueCode.too_small,
39500
+ message: check.message,
39501
+ inclusive: true,
39502
+ exact: false,
39503
+ minimum: check.value,
39504
+ type: "date"
39505
+ });
39506
+ status.dirty();
39507
+ }
39508
+ } else if (check.kind === "max") {
39509
+ if (input.data.getTime() > check.value) {
39510
+ ctx = this._getOrReturnCtx(input, ctx);
39511
+ addIssueToContext(ctx, {
39512
+ code: ZodIssueCode.too_big,
39513
+ message: check.message,
39514
+ inclusive: true,
39515
+ exact: false,
39516
+ maximum: check.value,
39517
+ type: "date"
39518
+ });
39519
+ status.dirty();
39520
+ }
39521
+ } else {
39522
+ util.assertNever(check);
39523
+ }
39524
+ }
39525
+ return {
39526
+ status: status.value,
39527
+ value: new Date(input.data.getTime())
39528
+ };
39529
+ }
39530
+ _addCheck(check) {
39531
+ return new _ZodDate({
39532
+ ...this._def,
39533
+ checks: [...this._def.checks, check]
39534
+ });
39535
+ }
39536
+ min(minDate, message) {
39537
+ return this._addCheck({
39538
+ kind: "min",
39539
+ value: minDate.getTime(),
39540
+ message: errorUtil.toString(message)
39541
+ });
39542
+ }
39543
+ max(maxDate, message) {
39544
+ return this._addCheck({
39545
+ kind: "max",
39546
+ value: maxDate.getTime(),
39547
+ message: errorUtil.toString(message)
39548
+ });
39549
+ }
39550
+ get minDate() {
39551
+ let min = null;
39552
+ for (const ch of this._def.checks) {
39553
+ if (ch.kind === "min") {
39554
+ if (min === null || ch.value > min)
39555
+ min = ch.value;
39556
+ }
39557
+ }
39558
+ return min != null ? new Date(min) : null;
39559
+ }
39560
+ get maxDate() {
39561
+ let max = null;
39562
+ for (const ch of this._def.checks) {
39563
+ if (ch.kind === "max") {
39564
+ if (max === null || ch.value < max)
39565
+ max = ch.value;
39566
+ }
39567
+ }
39568
+ return max != null ? new Date(max) : null;
39569
+ }
39570
+ };
39571
+ ZodDate.create = (params) => {
39572
+ return new ZodDate({
39573
+ checks: [],
39574
+ coerce: params?.coerce || false,
39575
+ typeName: ZodFirstPartyTypeKind.ZodDate,
39576
+ ...processCreateParams(params)
39577
+ });
39578
+ };
39579
+ var ZodSymbol = class extends ZodType {
39580
+ _parse(input) {
39581
+ const parsedType = this._getType(input);
39582
+ if (parsedType !== ZodParsedType.symbol) {
39583
+ const ctx = this._getOrReturnCtx(input);
39584
+ addIssueToContext(ctx, {
39585
+ code: ZodIssueCode.invalid_type,
39586
+ expected: ZodParsedType.symbol,
39587
+ received: ctx.parsedType
39588
+ });
39589
+ return INVALID;
39590
+ }
39591
+ return OK(input.data);
39592
+ }
39593
+ };
39594
+ ZodSymbol.create = (params) => {
39595
+ return new ZodSymbol({
39596
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
39597
+ ...processCreateParams(params)
39598
+ });
39599
+ };
39600
+ var ZodUndefined = class extends ZodType {
39601
+ _parse(input) {
39602
+ const parsedType = this._getType(input);
39603
+ if (parsedType !== ZodParsedType.undefined) {
39604
+ const ctx = this._getOrReturnCtx(input);
39605
+ addIssueToContext(ctx, {
39606
+ code: ZodIssueCode.invalid_type,
39607
+ expected: ZodParsedType.undefined,
39608
+ received: ctx.parsedType
39609
+ });
39610
+ return INVALID;
39611
+ }
39612
+ return OK(input.data);
39613
+ }
39614
+ };
39615
+ ZodUndefined.create = (params) => {
39616
+ return new ZodUndefined({
39617
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
39618
+ ...processCreateParams(params)
39619
+ });
39620
+ };
39621
+ var ZodNull = class extends ZodType {
39622
+ _parse(input) {
39623
+ const parsedType = this._getType(input);
39624
+ if (parsedType !== ZodParsedType.null) {
39625
+ const ctx = this._getOrReturnCtx(input);
39626
+ addIssueToContext(ctx, {
39627
+ code: ZodIssueCode.invalid_type,
39628
+ expected: ZodParsedType.null,
39629
+ received: ctx.parsedType
39630
+ });
39631
+ return INVALID;
39632
+ }
39633
+ return OK(input.data);
39634
+ }
39635
+ };
39636
+ ZodNull.create = (params) => {
39637
+ return new ZodNull({
39638
+ typeName: ZodFirstPartyTypeKind.ZodNull,
39639
+ ...processCreateParams(params)
39640
+ });
39641
+ };
39642
+ var ZodAny = class extends ZodType {
39643
+ constructor() {
39644
+ super(...arguments);
39645
+ this._any = true;
39646
+ }
39647
+ _parse(input) {
39648
+ return OK(input.data);
39649
+ }
39650
+ };
39651
+ ZodAny.create = (params) => {
39652
+ return new ZodAny({
39653
+ typeName: ZodFirstPartyTypeKind.ZodAny,
39654
+ ...processCreateParams(params)
39655
+ });
39656
+ };
39657
+ var ZodUnknown = class extends ZodType {
39658
+ constructor() {
39659
+ super(...arguments);
39660
+ this._unknown = true;
39661
+ }
39662
+ _parse(input) {
39663
+ return OK(input.data);
39664
+ }
39665
+ };
39666
+ ZodUnknown.create = (params) => {
39667
+ return new ZodUnknown({
39668
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
39669
+ ...processCreateParams(params)
39670
+ });
39671
+ };
39672
+ var ZodNever = class extends ZodType {
39673
+ _parse(input) {
39674
+ const ctx = this._getOrReturnCtx(input);
39675
+ addIssueToContext(ctx, {
39676
+ code: ZodIssueCode.invalid_type,
39677
+ expected: ZodParsedType.never,
39678
+ received: ctx.parsedType
39679
+ });
39680
+ return INVALID;
39681
+ }
39682
+ };
39683
+ ZodNever.create = (params) => {
39684
+ return new ZodNever({
39685
+ typeName: ZodFirstPartyTypeKind.ZodNever,
39686
+ ...processCreateParams(params)
39687
+ });
39688
+ };
39689
+ var ZodVoid = class extends ZodType {
39690
+ _parse(input) {
39691
+ const parsedType = this._getType(input);
39692
+ if (parsedType !== ZodParsedType.undefined) {
39693
+ const ctx = this._getOrReturnCtx(input);
39694
+ addIssueToContext(ctx, {
39695
+ code: ZodIssueCode.invalid_type,
39696
+ expected: ZodParsedType.void,
39697
+ received: ctx.parsedType
39698
+ });
39699
+ return INVALID;
39700
+ }
39701
+ return OK(input.data);
39702
+ }
39703
+ };
39704
+ ZodVoid.create = (params) => {
39705
+ return new ZodVoid({
39706
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
39707
+ ...processCreateParams(params)
39708
+ });
39709
+ };
39710
+ var ZodArray = class _ZodArray extends ZodType {
39711
+ _parse(input) {
39712
+ const { ctx, status } = this._processInputParams(input);
39713
+ const def = this._def;
39714
+ if (ctx.parsedType !== ZodParsedType.array) {
39715
+ addIssueToContext(ctx, {
39716
+ code: ZodIssueCode.invalid_type,
39717
+ expected: ZodParsedType.array,
39718
+ received: ctx.parsedType
39719
+ });
39720
+ return INVALID;
39721
+ }
39722
+ if (def.exactLength !== null) {
39723
+ const tooBig = ctx.data.length > def.exactLength.value;
39724
+ const tooSmall = ctx.data.length < def.exactLength.value;
39725
+ if (tooBig || tooSmall) {
39726
+ addIssueToContext(ctx, {
39727
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
39728
+ minimum: tooSmall ? def.exactLength.value : void 0,
39729
+ maximum: tooBig ? def.exactLength.value : void 0,
39730
+ type: "array",
39731
+ inclusive: true,
39732
+ exact: true,
39733
+ message: def.exactLength.message
39734
+ });
39735
+ status.dirty();
39736
+ }
39737
+ }
39738
+ if (def.minLength !== null) {
39739
+ if (ctx.data.length < def.minLength.value) {
39740
+ addIssueToContext(ctx, {
39741
+ code: ZodIssueCode.too_small,
39742
+ minimum: def.minLength.value,
39743
+ type: "array",
39744
+ inclusive: true,
39745
+ exact: false,
39746
+ message: def.minLength.message
39747
+ });
39748
+ status.dirty();
39749
+ }
39750
+ }
39751
+ if (def.maxLength !== null) {
39752
+ if (ctx.data.length > def.maxLength.value) {
39753
+ addIssueToContext(ctx, {
39754
+ code: ZodIssueCode.too_big,
39755
+ maximum: def.maxLength.value,
39756
+ type: "array",
39757
+ inclusive: true,
39758
+ exact: false,
39759
+ message: def.maxLength.message
39760
+ });
39761
+ status.dirty();
39762
+ }
39763
+ }
39764
+ if (ctx.common.async) {
39765
+ return Promise.all([...ctx.data].map((item, i) => {
39766
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
39767
+ })).then((result2) => {
39768
+ return ParseStatus.mergeArray(status, result2);
39769
+ });
39770
+ }
39771
+ const result = [...ctx.data].map((item, i) => {
39772
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
39773
+ });
39774
+ return ParseStatus.mergeArray(status, result);
39775
+ }
39776
+ get element() {
39777
+ return this._def.type;
39778
+ }
39779
+ min(minLength, message) {
39780
+ return new _ZodArray({
39781
+ ...this._def,
39782
+ minLength: { value: minLength, message: errorUtil.toString(message) }
39783
+ });
39784
+ }
39785
+ max(maxLength, message) {
39786
+ return new _ZodArray({
39787
+ ...this._def,
39788
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
39789
+ });
39790
+ }
39791
+ length(len, message) {
39792
+ return new _ZodArray({
39793
+ ...this._def,
39794
+ exactLength: { value: len, message: errorUtil.toString(message) }
39795
+ });
39796
+ }
39797
+ nonempty(message) {
39798
+ return this.min(1, message);
39799
+ }
39800
+ };
39801
+ ZodArray.create = (schema, params) => {
39802
+ return new ZodArray({
39803
+ type: schema,
39804
+ minLength: null,
39805
+ maxLength: null,
39806
+ exactLength: null,
39807
+ typeName: ZodFirstPartyTypeKind.ZodArray,
39808
+ ...processCreateParams(params)
39809
+ });
39810
+ };
39811
+ function deepPartialify(schema) {
39812
+ if (schema instanceof ZodObject) {
39813
+ const newShape = {};
39814
+ for (const key in schema.shape) {
39815
+ const fieldSchema = schema.shape[key];
39816
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
39817
+ }
39818
+ return new ZodObject({
39819
+ ...schema._def,
39820
+ shape: () => newShape
39821
+ });
39822
+ } else if (schema instanceof ZodArray) {
39823
+ return new ZodArray({
39824
+ ...schema._def,
39825
+ type: deepPartialify(schema.element)
39826
+ });
39827
+ } else if (schema instanceof ZodOptional) {
39828
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
39829
+ } else if (schema instanceof ZodNullable) {
39830
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
39831
+ } else if (schema instanceof ZodTuple) {
39832
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
39833
+ } else {
39834
+ return schema;
39835
+ }
39836
+ }
39837
+ var ZodObject = class _ZodObject extends ZodType {
39838
+ constructor() {
39839
+ super(...arguments);
39840
+ this._cached = null;
39841
+ this.nonstrict = this.passthrough;
39842
+ this.augment = this.extend;
39843
+ }
39844
+ _getCached() {
39845
+ if (this._cached !== null)
39846
+ return this._cached;
39847
+ const shape = this._def.shape();
39848
+ const keys = util.objectKeys(shape);
39849
+ this._cached = { shape, keys };
39850
+ return this._cached;
39851
+ }
39852
+ _parse(input) {
39853
+ const parsedType = this._getType(input);
39854
+ if (parsedType !== ZodParsedType.object) {
39855
+ const ctx2 = this._getOrReturnCtx(input);
39856
+ addIssueToContext(ctx2, {
39857
+ code: ZodIssueCode.invalid_type,
39858
+ expected: ZodParsedType.object,
39859
+ received: ctx2.parsedType
39860
+ });
39861
+ return INVALID;
39862
+ }
39863
+ const { status, ctx } = this._processInputParams(input);
39864
+ const { shape, keys: shapeKeys } = this._getCached();
39865
+ const extraKeys = [];
39866
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
39867
+ for (const key in ctx.data) {
39868
+ if (!shapeKeys.includes(key)) {
39869
+ extraKeys.push(key);
39870
+ }
39871
+ }
39872
+ }
39873
+ const pairs = [];
39874
+ for (const key of shapeKeys) {
39875
+ const keyValidator = shape[key];
39876
+ const value = ctx.data[key];
39877
+ pairs.push({
39878
+ key: { status: "valid", value: key },
39879
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
39880
+ alwaysSet: key in ctx.data
39881
+ });
39882
+ }
39883
+ if (this._def.catchall instanceof ZodNever) {
39884
+ const unknownKeys = this._def.unknownKeys;
39885
+ if (unknownKeys === "passthrough") {
39886
+ for (const key of extraKeys) {
39887
+ pairs.push({
39888
+ key: { status: "valid", value: key },
39889
+ value: { status: "valid", value: ctx.data[key] }
39890
+ });
39891
+ }
39892
+ } else if (unknownKeys === "strict") {
39893
+ if (extraKeys.length > 0) {
39894
+ addIssueToContext(ctx, {
39895
+ code: ZodIssueCode.unrecognized_keys,
39896
+ keys: extraKeys
39897
+ });
39898
+ status.dirty();
39899
+ }
39900
+ } else if (unknownKeys === "strip") {
39901
+ } else {
39902
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
39903
+ }
39904
+ } else {
39905
+ const catchall = this._def.catchall;
39906
+ for (const key of extraKeys) {
39907
+ const value = ctx.data[key];
39908
+ pairs.push({
39909
+ key: { status: "valid", value: key },
39910
+ value: catchall._parse(
39911
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
39912
+ //, ctx.child(key), value, getParsedType(value)
39913
+ ),
39914
+ alwaysSet: key in ctx.data
39915
+ });
39916
+ }
39917
+ }
39918
+ if (ctx.common.async) {
39919
+ return Promise.resolve().then(async () => {
39920
+ const syncPairs = [];
39921
+ for (const pair of pairs) {
39922
+ const key = await pair.key;
39923
+ const value = await pair.value;
39924
+ syncPairs.push({
39925
+ key,
39926
+ value,
39927
+ alwaysSet: pair.alwaysSet
39928
+ });
39929
+ }
39930
+ return syncPairs;
39931
+ }).then((syncPairs) => {
39932
+ return ParseStatus.mergeObjectSync(status, syncPairs);
39933
+ });
39934
+ } else {
39935
+ return ParseStatus.mergeObjectSync(status, pairs);
39936
+ }
39937
+ }
39938
+ get shape() {
39939
+ return this._def.shape();
39940
+ }
39941
+ strict(message) {
39942
+ errorUtil.errToObj;
39943
+ return new _ZodObject({
39944
+ ...this._def,
39945
+ unknownKeys: "strict",
39946
+ ...message !== void 0 ? {
39947
+ errorMap: (issue, ctx) => {
39948
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
39949
+ if (issue.code === "unrecognized_keys")
39950
+ return {
39951
+ message: errorUtil.errToObj(message).message ?? defaultError
39952
+ };
39953
+ return {
39954
+ message: defaultError
39955
+ };
39956
+ }
39957
+ } : {}
39958
+ });
39959
+ }
39960
+ strip() {
39961
+ return new _ZodObject({
39962
+ ...this._def,
39963
+ unknownKeys: "strip"
39964
+ });
39965
+ }
39966
+ passthrough() {
39967
+ return new _ZodObject({
39968
+ ...this._def,
39969
+ unknownKeys: "passthrough"
39970
+ });
39971
+ }
39972
+ // const AugmentFactory =
39973
+ // <Def extends ZodObjectDef>(def: Def) =>
39974
+ // <Augmentation extends ZodRawShape>(
39975
+ // augmentation: Augmentation
39976
+ // ): ZodObject<
39977
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
39978
+ // Def["unknownKeys"],
39979
+ // Def["catchall"]
39980
+ // > => {
39981
+ // return new ZodObject({
39982
+ // ...def,
39983
+ // shape: () => ({
39984
+ // ...def.shape(),
39985
+ // ...augmentation,
39986
+ // }),
39987
+ // }) as any;
39988
+ // };
39989
+ extend(augmentation) {
39990
+ return new _ZodObject({
39991
+ ...this._def,
39992
+ shape: () => ({
39993
+ ...this._def.shape(),
39994
+ ...augmentation
39995
+ })
39996
+ });
39997
+ }
39998
+ /**
39999
+ * Prior to zod@1.0.12 there was a bug in the
40000
+ * inferred type of merged objects. Please
40001
+ * upgrade if you are experiencing issues.
40002
+ */
40003
+ merge(merging) {
40004
+ const merged = new _ZodObject({
40005
+ unknownKeys: merging._def.unknownKeys,
40006
+ catchall: merging._def.catchall,
40007
+ shape: () => ({
40008
+ ...this._def.shape(),
40009
+ ...merging._def.shape()
40010
+ }),
40011
+ typeName: ZodFirstPartyTypeKind.ZodObject
40012
+ });
40013
+ return merged;
40014
+ }
40015
+ // merge<
40016
+ // Incoming extends AnyZodObject,
40017
+ // Augmentation extends Incoming["shape"],
40018
+ // NewOutput extends {
40019
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
40020
+ // ? Augmentation[k]["_output"]
40021
+ // : k extends keyof Output
40022
+ // ? Output[k]
40023
+ // : never;
40024
+ // },
40025
+ // NewInput extends {
40026
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
40027
+ // ? Augmentation[k]["_input"]
40028
+ // : k extends keyof Input
40029
+ // ? Input[k]
40030
+ // : never;
40031
+ // }
40032
+ // >(
40033
+ // merging: Incoming
40034
+ // ): ZodObject<
40035
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
40036
+ // Incoming["_def"]["unknownKeys"],
40037
+ // Incoming["_def"]["catchall"],
40038
+ // NewOutput,
40039
+ // NewInput
40040
+ // > {
40041
+ // const merged: any = new ZodObject({
40042
+ // unknownKeys: merging._def.unknownKeys,
40043
+ // catchall: merging._def.catchall,
40044
+ // shape: () =>
40045
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
40046
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
40047
+ // }) as any;
40048
+ // return merged;
40049
+ // }
40050
+ setKey(key, schema) {
40051
+ return this.augment({ [key]: schema });
40052
+ }
40053
+ // merge<Incoming extends AnyZodObject>(
40054
+ // merging: Incoming
40055
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
40056
+ // ZodObject<
40057
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
40058
+ // Incoming["_def"]["unknownKeys"],
40059
+ // Incoming["_def"]["catchall"]
40060
+ // > {
40061
+ // // const mergedShape = objectUtil.mergeShapes(
40062
+ // // this._def.shape(),
40063
+ // // merging._def.shape()
40064
+ // // );
40065
+ // const merged: any = new ZodObject({
40066
+ // unknownKeys: merging._def.unknownKeys,
40067
+ // catchall: merging._def.catchall,
40068
+ // shape: () =>
40069
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
40070
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
40071
+ // }) as any;
40072
+ // return merged;
40073
+ // }
40074
+ catchall(index2) {
40075
+ return new _ZodObject({
40076
+ ...this._def,
40077
+ catchall: index2
40078
+ });
40079
+ }
40080
+ pick(mask) {
40081
+ const shape = {};
40082
+ for (const key of util.objectKeys(mask)) {
40083
+ if (mask[key] && this.shape[key]) {
40084
+ shape[key] = this.shape[key];
40085
+ }
40086
+ }
40087
+ return new _ZodObject({
40088
+ ...this._def,
40089
+ shape: () => shape
40090
+ });
40091
+ }
40092
+ omit(mask) {
40093
+ const shape = {};
40094
+ for (const key of util.objectKeys(this.shape)) {
40095
+ if (!mask[key]) {
40096
+ shape[key] = this.shape[key];
40097
+ }
40098
+ }
40099
+ return new _ZodObject({
40100
+ ...this._def,
40101
+ shape: () => shape
40102
+ });
40103
+ }
40104
+ /**
40105
+ * @deprecated
40106
+ */
40107
+ deepPartial() {
40108
+ return deepPartialify(this);
40109
+ }
40110
+ partial(mask) {
40111
+ const newShape = {};
40112
+ for (const key of util.objectKeys(this.shape)) {
40113
+ const fieldSchema = this.shape[key];
40114
+ if (mask && !mask[key]) {
40115
+ newShape[key] = fieldSchema;
40116
+ } else {
40117
+ newShape[key] = fieldSchema.optional();
40118
+ }
40119
+ }
40120
+ return new _ZodObject({
40121
+ ...this._def,
40122
+ shape: () => newShape
40123
+ });
40124
+ }
40125
+ required(mask) {
40126
+ const newShape = {};
40127
+ for (const key of util.objectKeys(this.shape)) {
40128
+ if (mask && !mask[key]) {
40129
+ newShape[key] = this.shape[key];
40130
+ } else {
40131
+ const fieldSchema = this.shape[key];
40132
+ let newField = fieldSchema;
40133
+ while (newField instanceof ZodOptional) {
40134
+ newField = newField._def.innerType;
40135
+ }
40136
+ newShape[key] = newField;
40137
+ }
40138
+ }
40139
+ return new _ZodObject({
40140
+ ...this._def,
40141
+ shape: () => newShape
40142
+ });
40143
+ }
40144
+ keyof() {
40145
+ return createZodEnum(util.objectKeys(this.shape));
40146
+ }
40147
+ };
40148
+ ZodObject.create = (shape, params) => {
40149
+ return new ZodObject({
40150
+ shape: () => shape,
40151
+ unknownKeys: "strip",
40152
+ catchall: ZodNever.create(),
40153
+ typeName: ZodFirstPartyTypeKind.ZodObject,
40154
+ ...processCreateParams(params)
40155
+ });
40156
+ };
40157
+ ZodObject.strictCreate = (shape, params) => {
40158
+ return new ZodObject({
40159
+ shape: () => shape,
40160
+ unknownKeys: "strict",
40161
+ catchall: ZodNever.create(),
40162
+ typeName: ZodFirstPartyTypeKind.ZodObject,
40163
+ ...processCreateParams(params)
40164
+ });
40165
+ };
40166
+ ZodObject.lazycreate = (shape, params) => {
40167
+ return new ZodObject({
40168
+ shape,
40169
+ unknownKeys: "strip",
40170
+ catchall: ZodNever.create(),
40171
+ typeName: ZodFirstPartyTypeKind.ZodObject,
40172
+ ...processCreateParams(params)
40173
+ });
40174
+ };
40175
+ var ZodUnion = class extends ZodType {
40176
+ _parse(input) {
40177
+ const { ctx } = this._processInputParams(input);
40178
+ const options = this._def.options;
40179
+ function handleResults(results) {
40180
+ for (const result of results) {
40181
+ if (result.result.status === "valid") {
40182
+ return result.result;
40183
+ }
40184
+ }
40185
+ for (const result of results) {
40186
+ if (result.result.status === "dirty") {
40187
+ ctx.common.issues.push(...result.ctx.common.issues);
40188
+ return result.result;
40189
+ }
40190
+ }
40191
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
40192
+ addIssueToContext(ctx, {
40193
+ code: ZodIssueCode.invalid_union,
40194
+ unionErrors
40195
+ });
40196
+ return INVALID;
40197
+ }
40198
+ if (ctx.common.async) {
40199
+ return Promise.all(options.map(async (option) => {
40200
+ const childCtx = {
40201
+ ...ctx,
40202
+ common: {
40203
+ ...ctx.common,
40204
+ issues: []
40205
+ },
40206
+ parent: null
40207
+ };
40208
+ return {
40209
+ result: await option._parseAsync({
40210
+ data: ctx.data,
40211
+ path: ctx.path,
40212
+ parent: childCtx
40213
+ }),
40214
+ ctx: childCtx
40215
+ };
40216
+ })).then(handleResults);
40217
+ } else {
40218
+ let dirty = void 0;
40219
+ const issues = [];
40220
+ for (const option of options) {
40221
+ const childCtx = {
40222
+ ...ctx,
40223
+ common: {
40224
+ ...ctx.common,
40225
+ issues: []
40226
+ },
40227
+ parent: null
40228
+ };
40229
+ const result = option._parseSync({
40230
+ data: ctx.data,
40231
+ path: ctx.path,
40232
+ parent: childCtx
40233
+ });
40234
+ if (result.status === "valid") {
40235
+ return result;
40236
+ } else if (result.status === "dirty" && !dirty) {
40237
+ dirty = { result, ctx: childCtx };
40238
+ }
40239
+ if (childCtx.common.issues.length) {
40240
+ issues.push(childCtx.common.issues);
40241
+ }
40242
+ }
40243
+ if (dirty) {
40244
+ ctx.common.issues.push(...dirty.ctx.common.issues);
40245
+ return dirty.result;
40246
+ }
40247
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
40248
+ addIssueToContext(ctx, {
40249
+ code: ZodIssueCode.invalid_union,
40250
+ unionErrors
40251
+ });
40252
+ return INVALID;
40253
+ }
40254
+ }
40255
+ get options() {
40256
+ return this._def.options;
40257
+ }
40258
+ };
40259
+ ZodUnion.create = (types, params) => {
40260
+ return new ZodUnion({
40261
+ options: types,
40262
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
40263
+ ...processCreateParams(params)
40264
+ });
40265
+ };
40266
+ var getDiscriminator = (type) => {
40267
+ if (type instanceof ZodLazy) {
40268
+ return getDiscriminator(type.schema);
40269
+ } else if (type instanceof ZodEffects) {
40270
+ return getDiscriminator(type.innerType());
40271
+ } else if (type instanceof ZodLiteral) {
40272
+ return [type.value];
40273
+ } else if (type instanceof ZodEnum) {
40274
+ return type.options;
40275
+ } else if (type instanceof ZodNativeEnum) {
40276
+ return util.objectValues(type.enum);
40277
+ } else if (type instanceof ZodDefault) {
40278
+ return getDiscriminator(type._def.innerType);
40279
+ } else if (type instanceof ZodUndefined) {
40280
+ return [void 0];
40281
+ } else if (type instanceof ZodNull) {
40282
+ return [null];
40283
+ } else if (type instanceof ZodOptional) {
40284
+ return [void 0, ...getDiscriminator(type.unwrap())];
40285
+ } else if (type instanceof ZodNullable) {
40286
+ return [null, ...getDiscriminator(type.unwrap())];
40287
+ } else if (type instanceof ZodBranded) {
40288
+ return getDiscriminator(type.unwrap());
40289
+ } else if (type instanceof ZodReadonly) {
40290
+ return getDiscriminator(type.unwrap());
40291
+ } else if (type instanceof ZodCatch) {
40292
+ return getDiscriminator(type._def.innerType);
40293
+ } else {
40294
+ return [];
40295
+ }
40296
+ };
40297
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
40298
+ _parse(input) {
40299
+ const { ctx } = this._processInputParams(input);
40300
+ if (ctx.parsedType !== ZodParsedType.object) {
40301
+ addIssueToContext(ctx, {
40302
+ code: ZodIssueCode.invalid_type,
40303
+ expected: ZodParsedType.object,
40304
+ received: ctx.parsedType
40305
+ });
40306
+ return INVALID;
40307
+ }
40308
+ const discriminator = this.discriminator;
40309
+ const discriminatorValue = ctx.data[discriminator];
40310
+ const option = this.optionsMap.get(discriminatorValue);
40311
+ if (!option) {
40312
+ addIssueToContext(ctx, {
40313
+ code: ZodIssueCode.invalid_union_discriminator,
40314
+ options: Array.from(this.optionsMap.keys()),
40315
+ path: [discriminator]
40316
+ });
40317
+ return INVALID;
40318
+ }
40319
+ if (ctx.common.async) {
40320
+ return option._parseAsync({
40321
+ data: ctx.data,
40322
+ path: ctx.path,
40323
+ parent: ctx
40324
+ });
40325
+ } else {
40326
+ return option._parseSync({
40327
+ data: ctx.data,
40328
+ path: ctx.path,
40329
+ parent: ctx
40330
+ });
40331
+ }
40332
+ }
40333
+ get discriminator() {
40334
+ return this._def.discriminator;
40335
+ }
40336
+ get options() {
40337
+ return this._def.options;
40338
+ }
40339
+ get optionsMap() {
40340
+ return this._def.optionsMap;
40341
+ }
40342
+ /**
40343
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
40344
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
40345
+ * have a different value for each object in the union.
40346
+ * @param discriminator the name of the discriminator property
40347
+ * @param types an array of object schemas
40348
+ * @param params
40349
+ */
40350
+ static create(discriminator, options, params) {
40351
+ const optionsMap = /* @__PURE__ */ new Map();
40352
+ for (const type of options) {
40353
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
40354
+ if (!discriminatorValues.length) {
40355
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
40356
+ }
40357
+ for (const value of discriminatorValues) {
40358
+ if (optionsMap.has(value)) {
40359
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
40360
+ }
40361
+ optionsMap.set(value, type);
40362
+ }
40363
+ }
40364
+ return new _ZodDiscriminatedUnion({
40365
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
40366
+ discriminator,
40367
+ options,
40368
+ optionsMap,
40369
+ ...processCreateParams(params)
40370
+ });
40371
+ }
40372
+ };
40373
+ function mergeValues(a, b) {
40374
+ const aType = getParsedType(a);
40375
+ const bType = getParsedType(b);
40376
+ if (a === b) {
40377
+ return { valid: true, data: a };
40378
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
40379
+ const bKeys = util.objectKeys(b);
40380
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
40381
+ const newObj = { ...a, ...b };
40382
+ for (const key of sharedKeys) {
40383
+ const sharedValue = mergeValues(a[key], b[key]);
40384
+ if (!sharedValue.valid) {
40385
+ return { valid: false };
40386
+ }
40387
+ newObj[key] = sharedValue.data;
40388
+ }
40389
+ return { valid: true, data: newObj };
40390
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
40391
+ if (a.length !== b.length) {
40392
+ return { valid: false };
40393
+ }
40394
+ const newArray = [];
40395
+ for (let index2 = 0; index2 < a.length; index2++) {
40396
+ const itemA = a[index2];
40397
+ const itemB = b[index2];
40398
+ const sharedValue = mergeValues(itemA, itemB);
40399
+ if (!sharedValue.valid) {
40400
+ return { valid: false };
40401
+ }
40402
+ newArray.push(sharedValue.data);
40403
+ }
40404
+ return { valid: true, data: newArray };
40405
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
40406
+ return { valid: true, data: a };
40407
+ } else {
40408
+ return { valid: false };
40409
+ }
40410
+ }
40411
+ var ZodIntersection = class extends ZodType {
40412
+ _parse(input) {
40413
+ const { status, ctx } = this._processInputParams(input);
40414
+ const handleParsed = (parsedLeft, parsedRight) => {
40415
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
40416
+ return INVALID;
40417
+ }
40418
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
40419
+ if (!merged.valid) {
40420
+ addIssueToContext(ctx, {
40421
+ code: ZodIssueCode.invalid_intersection_types
40422
+ });
40423
+ return INVALID;
40424
+ }
40425
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
40426
+ status.dirty();
40427
+ }
40428
+ return { status: status.value, value: merged.data };
40429
+ };
40430
+ if (ctx.common.async) {
40431
+ return Promise.all([
40432
+ this._def.left._parseAsync({
40433
+ data: ctx.data,
40434
+ path: ctx.path,
40435
+ parent: ctx
40436
+ }),
40437
+ this._def.right._parseAsync({
40438
+ data: ctx.data,
40439
+ path: ctx.path,
40440
+ parent: ctx
40441
+ })
40442
+ ]).then(([left, right]) => handleParsed(left, right));
40443
+ } else {
40444
+ return handleParsed(this._def.left._parseSync({
40445
+ data: ctx.data,
40446
+ path: ctx.path,
40447
+ parent: ctx
40448
+ }), this._def.right._parseSync({
40449
+ data: ctx.data,
40450
+ path: ctx.path,
40451
+ parent: ctx
40452
+ }));
40453
+ }
40454
+ }
40455
+ };
40456
+ ZodIntersection.create = (left, right, params) => {
40457
+ return new ZodIntersection({
40458
+ left,
40459
+ right,
40460
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
40461
+ ...processCreateParams(params)
40462
+ });
40463
+ };
40464
+ var ZodTuple = class _ZodTuple extends ZodType {
40465
+ _parse(input) {
40466
+ const { status, ctx } = this._processInputParams(input);
40467
+ if (ctx.parsedType !== ZodParsedType.array) {
40468
+ addIssueToContext(ctx, {
40469
+ code: ZodIssueCode.invalid_type,
40470
+ expected: ZodParsedType.array,
40471
+ received: ctx.parsedType
40472
+ });
40473
+ return INVALID;
40474
+ }
40475
+ if (ctx.data.length < this._def.items.length) {
40476
+ addIssueToContext(ctx, {
40477
+ code: ZodIssueCode.too_small,
40478
+ minimum: this._def.items.length,
40479
+ inclusive: true,
40480
+ exact: false,
40481
+ type: "array"
40482
+ });
40483
+ return INVALID;
40484
+ }
40485
+ const rest = this._def.rest;
40486
+ if (!rest && ctx.data.length > this._def.items.length) {
40487
+ addIssueToContext(ctx, {
40488
+ code: ZodIssueCode.too_big,
40489
+ maximum: this._def.items.length,
40490
+ inclusive: true,
40491
+ exact: false,
40492
+ type: "array"
40493
+ });
40494
+ status.dirty();
40495
+ }
40496
+ const items = [...ctx.data].map((item, itemIndex) => {
40497
+ const schema = this._def.items[itemIndex] || this._def.rest;
40498
+ if (!schema)
40499
+ return null;
40500
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
40501
+ }).filter((x) => !!x);
40502
+ if (ctx.common.async) {
40503
+ return Promise.all(items).then((results) => {
40504
+ return ParseStatus.mergeArray(status, results);
40505
+ });
40506
+ } else {
40507
+ return ParseStatus.mergeArray(status, items);
40508
+ }
40509
+ }
40510
+ get items() {
40511
+ return this._def.items;
40512
+ }
40513
+ rest(rest) {
40514
+ return new _ZodTuple({
40515
+ ...this._def,
40516
+ rest
40517
+ });
40518
+ }
40519
+ };
40520
+ ZodTuple.create = (schemas, params) => {
40521
+ if (!Array.isArray(schemas)) {
40522
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
40523
+ }
40524
+ return new ZodTuple({
40525
+ items: schemas,
40526
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
40527
+ rest: null,
40528
+ ...processCreateParams(params)
40529
+ });
40530
+ };
40531
+ var ZodRecord = class _ZodRecord extends ZodType {
40532
+ get keySchema() {
40533
+ return this._def.keyType;
40534
+ }
40535
+ get valueSchema() {
40536
+ return this._def.valueType;
40537
+ }
40538
+ _parse(input) {
40539
+ const { status, ctx } = this._processInputParams(input);
40540
+ if (ctx.parsedType !== ZodParsedType.object) {
40541
+ addIssueToContext(ctx, {
40542
+ code: ZodIssueCode.invalid_type,
40543
+ expected: ZodParsedType.object,
40544
+ received: ctx.parsedType
40545
+ });
40546
+ return INVALID;
40547
+ }
40548
+ const pairs = [];
40549
+ const keyType = this._def.keyType;
40550
+ const valueType = this._def.valueType;
40551
+ for (const key in ctx.data) {
40552
+ pairs.push({
40553
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
40554
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
40555
+ alwaysSet: key in ctx.data
40556
+ });
40557
+ }
40558
+ if (ctx.common.async) {
40559
+ return ParseStatus.mergeObjectAsync(status, pairs);
40560
+ } else {
40561
+ return ParseStatus.mergeObjectSync(status, pairs);
40562
+ }
40563
+ }
40564
+ get element() {
40565
+ return this._def.valueType;
40566
+ }
40567
+ static create(first, second, third) {
40568
+ if (second instanceof ZodType) {
40569
+ return new _ZodRecord({
40570
+ keyType: first,
40571
+ valueType: second,
40572
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
40573
+ ...processCreateParams(third)
40574
+ });
40575
+ }
40576
+ return new _ZodRecord({
40577
+ keyType: ZodString.create(),
40578
+ valueType: first,
40579
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
40580
+ ...processCreateParams(second)
40581
+ });
40582
+ }
40583
+ };
40584
+ var ZodMap = class extends ZodType {
40585
+ get keySchema() {
40586
+ return this._def.keyType;
40587
+ }
40588
+ get valueSchema() {
40589
+ return this._def.valueType;
40590
+ }
40591
+ _parse(input) {
40592
+ const { status, ctx } = this._processInputParams(input);
40593
+ if (ctx.parsedType !== ZodParsedType.map) {
40594
+ addIssueToContext(ctx, {
40595
+ code: ZodIssueCode.invalid_type,
40596
+ expected: ZodParsedType.map,
40597
+ received: ctx.parsedType
40598
+ });
40599
+ return INVALID;
40600
+ }
40601
+ const keyType = this._def.keyType;
40602
+ const valueType = this._def.valueType;
40603
+ const pairs = [...ctx.data.entries()].map(([key, value], index2) => {
40604
+ return {
40605
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])),
40606
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"]))
40607
+ };
40608
+ });
40609
+ if (ctx.common.async) {
40610
+ const finalMap = /* @__PURE__ */ new Map();
40611
+ return Promise.resolve().then(async () => {
40612
+ for (const pair of pairs) {
40613
+ const key = await pair.key;
40614
+ const value = await pair.value;
40615
+ if (key.status === "aborted" || value.status === "aborted") {
40616
+ return INVALID;
40617
+ }
40618
+ if (key.status === "dirty" || value.status === "dirty") {
40619
+ status.dirty();
40620
+ }
40621
+ finalMap.set(key.value, value.value);
40622
+ }
40623
+ return { status: status.value, value: finalMap };
40624
+ });
40625
+ } else {
40626
+ const finalMap = /* @__PURE__ */ new Map();
40627
+ for (const pair of pairs) {
40628
+ const key = pair.key;
40629
+ const value = pair.value;
40630
+ if (key.status === "aborted" || value.status === "aborted") {
40631
+ return INVALID;
40632
+ }
40633
+ if (key.status === "dirty" || value.status === "dirty") {
40634
+ status.dirty();
40635
+ }
40636
+ finalMap.set(key.value, value.value);
40637
+ }
40638
+ return { status: status.value, value: finalMap };
40639
+ }
40640
+ }
40641
+ };
40642
+ ZodMap.create = (keyType, valueType, params) => {
40643
+ return new ZodMap({
40644
+ valueType,
40645
+ keyType,
40646
+ typeName: ZodFirstPartyTypeKind.ZodMap,
40647
+ ...processCreateParams(params)
40648
+ });
40649
+ };
40650
+ var ZodSet = class _ZodSet extends ZodType {
40651
+ _parse(input) {
40652
+ const { status, ctx } = this._processInputParams(input);
40653
+ if (ctx.parsedType !== ZodParsedType.set) {
40654
+ addIssueToContext(ctx, {
40655
+ code: ZodIssueCode.invalid_type,
40656
+ expected: ZodParsedType.set,
40657
+ received: ctx.parsedType
40658
+ });
40659
+ return INVALID;
40660
+ }
40661
+ const def = this._def;
40662
+ if (def.minSize !== null) {
40663
+ if (ctx.data.size < def.minSize.value) {
40664
+ addIssueToContext(ctx, {
40665
+ code: ZodIssueCode.too_small,
40666
+ minimum: def.minSize.value,
40667
+ type: "set",
40668
+ inclusive: true,
40669
+ exact: false,
40670
+ message: def.minSize.message
40671
+ });
40672
+ status.dirty();
40673
+ }
40674
+ }
40675
+ if (def.maxSize !== null) {
40676
+ if (ctx.data.size > def.maxSize.value) {
40677
+ addIssueToContext(ctx, {
40678
+ code: ZodIssueCode.too_big,
40679
+ maximum: def.maxSize.value,
40680
+ type: "set",
40681
+ inclusive: true,
40682
+ exact: false,
40683
+ message: def.maxSize.message
40684
+ });
40685
+ status.dirty();
40686
+ }
40687
+ }
40688
+ const valueType = this._def.valueType;
40689
+ function finalizeSet(elements2) {
40690
+ const parsedSet = /* @__PURE__ */ new Set();
40691
+ for (const element of elements2) {
40692
+ if (element.status === "aborted")
40693
+ return INVALID;
40694
+ if (element.status === "dirty")
40695
+ status.dirty();
40696
+ parsedSet.add(element.value);
40697
+ }
40698
+ return { status: status.value, value: parsedSet };
40699
+ }
40700
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
40701
+ if (ctx.common.async) {
40702
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
40703
+ } else {
40704
+ return finalizeSet(elements);
40705
+ }
40706
+ }
40707
+ min(minSize, message) {
40708
+ return new _ZodSet({
40709
+ ...this._def,
40710
+ minSize: { value: minSize, message: errorUtil.toString(message) }
40711
+ });
40712
+ }
40713
+ max(maxSize, message) {
40714
+ return new _ZodSet({
40715
+ ...this._def,
40716
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
40717
+ });
40718
+ }
40719
+ size(size5, message) {
40720
+ return this.min(size5, message).max(size5, message);
40721
+ }
40722
+ nonempty(message) {
40723
+ return this.min(1, message);
40724
+ }
40725
+ };
40726
+ ZodSet.create = (valueType, params) => {
40727
+ return new ZodSet({
40728
+ valueType,
40729
+ minSize: null,
40730
+ maxSize: null,
40731
+ typeName: ZodFirstPartyTypeKind.ZodSet,
40732
+ ...processCreateParams(params)
40733
+ });
40734
+ };
40735
+ var ZodFunction = class _ZodFunction extends ZodType {
40736
+ constructor() {
40737
+ super(...arguments);
40738
+ this.validate = this.implement;
40739
+ }
40740
+ _parse(input) {
40741
+ const { ctx } = this._processInputParams(input);
40742
+ if (ctx.parsedType !== ZodParsedType.function) {
40743
+ addIssueToContext(ctx, {
40744
+ code: ZodIssueCode.invalid_type,
40745
+ expected: ZodParsedType.function,
40746
+ received: ctx.parsedType
40747
+ });
40748
+ return INVALID;
40749
+ }
40750
+ function makeArgsIssue(args, error) {
40751
+ return makeIssue({
40752
+ data: args,
40753
+ path: ctx.path,
40754
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
40755
+ issueData: {
40756
+ code: ZodIssueCode.invalid_arguments,
40757
+ argumentsError: error
40758
+ }
40759
+ });
40760
+ }
40761
+ function makeReturnsIssue(returns, error) {
40762
+ return makeIssue({
40763
+ data: returns,
40764
+ path: ctx.path,
40765
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
40766
+ issueData: {
40767
+ code: ZodIssueCode.invalid_return_type,
40768
+ returnTypeError: error
40769
+ }
40770
+ });
40771
+ }
40772
+ const params = { errorMap: ctx.common.contextualErrorMap };
40773
+ const fn = ctx.data;
40774
+ if (this._def.returns instanceof ZodPromise) {
40775
+ const me = this;
40776
+ return OK(async function(...args) {
40777
+ const error = new ZodError([]);
40778
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e7) => {
40779
+ error.addIssue(makeArgsIssue(args, e7));
40780
+ throw error;
40781
+ });
40782
+ const result = await Reflect.apply(fn, this, parsedArgs);
40783
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e7) => {
40784
+ error.addIssue(makeReturnsIssue(result, e7));
40785
+ throw error;
40786
+ });
40787
+ return parsedReturns;
40788
+ });
40789
+ } else {
40790
+ const me = this;
40791
+ return OK(function(...args) {
40792
+ const parsedArgs = me._def.args.safeParse(args, params);
40793
+ if (!parsedArgs.success) {
40794
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
40795
+ }
40796
+ const result = Reflect.apply(fn, this, parsedArgs.data);
40797
+ const parsedReturns = me._def.returns.safeParse(result, params);
40798
+ if (!parsedReturns.success) {
40799
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
40800
+ }
40801
+ return parsedReturns.data;
40802
+ });
40803
+ }
40804
+ }
40805
+ parameters() {
40806
+ return this._def.args;
40807
+ }
40808
+ returnType() {
40809
+ return this._def.returns;
40810
+ }
40811
+ args(...items) {
40812
+ return new _ZodFunction({
40813
+ ...this._def,
40814
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
40815
+ });
40816
+ }
40817
+ returns(returnType) {
40818
+ return new _ZodFunction({
40819
+ ...this._def,
40820
+ returns: returnType
40821
+ });
40822
+ }
40823
+ implement(func) {
40824
+ const validatedFunc = this.parse(func);
40825
+ return validatedFunc;
40826
+ }
40827
+ strictImplement(func) {
40828
+ const validatedFunc = this.parse(func);
40829
+ return validatedFunc;
40830
+ }
40831
+ static create(args, returns, params) {
40832
+ return new _ZodFunction({
40833
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
40834
+ returns: returns || ZodUnknown.create(),
40835
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
40836
+ ...processCreateParams(params)
40837
+ });
40838
+ }
40839
+ };
40840
+ var ZodLazy = class extends ZodType {
40841
+ get schema() {
40842
+ return this._def.getter();
40843
+ }
40844
+ _parse(input) {
40845
+ const { ctx } = this._processInputParams(input);
40846
+ const lazySchema = this._def.getter();
40847
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
40848
+ }
40849
+ };
40850
+ ZodLazy.create = (getter, params) => {
40851
+ return new ZodLazy({
40852
+ getter,
40853
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
40854
+ ...processCreateParams(params)
40855
+ });
40856
+ };
40857
+ var ZodLiteral = class extends ZodType {
40858
+ _parse(input) {
40859
+ if (input.data !== this._def.value) {
40860
+ const ctx = this._getOrReturnCtx(input);
40861
+ addIssueToContext(ctx, {
40862
+ received: ctx.data,
40863
+ code: ZodIssueCode.invalid_literal,
40864
+ expected: this._def.value
40865
+ });
40866
+ return INVALID;
40867
+ }
40868
+ return { status: "valid", value: input.data };
40869
+ }
40870
+ get value() {
40871
+ return this._def.value;
40872
+ }
40873
+ };
40874
+ ZodLiteral.create = (value, params) => {
40875
+ return new ZodLiteral({
40876
+ value,
40877
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
40878
+ ...processCreateParams(params)
40879
+ });
40880
+ };
40881
+ function createZodEnum(values, params) {
40882
+ return new ZodEnum({
40883
+ values,
40884
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
40885
+ ...processCreateParams(params)
40886
+ });
40887
+ }
40888
+ var ZodEnum = class _ZodEnum extends ZodType {
40889
+ _parse(input) {
40890
+ if (typeof input.data !== "string") {
40891
+ const ctx = this._getOrReturnCtx(input);
40892
+ const expectedValues = this._def.values;
40893
+ addIssueToContext(ctx, {
40894
+ expected: util.joinValues(expectedValues),
40895
+ received: ctx.parsedType,
40896
+ code: ZodIssueCode.invalid_type
40897
+ });
40898
+ return INVALID;
40899
+ }
40900
+ if (!this._cache) {
40901
+ this._cache = new Set(this._def.values);
40902
+ }
40903
+ if (!this._cache.has(input.data)) {
40904
+ const ctx = this._getOrReturnCtx(input);
40905
+ const expectedValues = this._def.values;
40906
+ addIssueToContext(ctx, {
40907
+ received: ctx.data,
40908
+ code: ZodIssueCode.invalid_enum_value,
40909
+ options: expectedValues
40910
+ });
40911
+ return INVALID;
40912
+ }
40913
+ return OK(input.data);
40914
+ }
40915
+ get options() {
40916
+ return this._def.values;
40917
+ }
40918
+ get enum() {
40919
+ const enumValues = {};
40920
+ for (const val of this._def.values) {
40921
+ enumValues[val] = val;
40922
+ }
40923
+ return enumValues;
40924
+ }
40925
+ get Values() {
40926
+ const enumValues = {};
40927
+ for (const val of this._def.values) {
40928
+ enumValues[val] = val;
40929
+ }
40930
+ return enumValues;
40931
+ }
40932
+ get Enum() {
40933
+ const enumValues = {};
40934
+ for (const val of this._def.values) {
40935
+ enumValues[val] = val;
40936
+ }
40937
+ return enumValues;
40938
+ }
40939
+ extract(values, newDef = this._def) {
40940
+ return _ZodEnum.create(values, {
40941
+ ...this._def,
40942
+ ...newDef
40943
+ });
40944
+ }
40945
+ exclude(values, newDef = this._def) {
40946
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
40947
+ ...this._def,
40948
+ ...newDef
40949
+ });
40950
+ }
40951
+ };
40952
+ ZodEnum.create = createZodEnum;
40953
+ var ZodNativeEnum = class extends ZodType {
40954
+ _parse(input) {
40955
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
40956
+ const ctx = this._getOrReturnCtx(input);
40957
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
40958
+ const expectedValues = util.objectValues(nativeEnumValues);
40959
+ addIssueToContext(ctx, {
40960
+ expected: util.joinValues(expectedValues),
40961
+ received: ctx.parsedType,
40962
+ code: ZodIssueCode.invalid_type
40963
+ });
40964
+ return INVALID;
40965
+ }
40966
+ if (!this._cache) {
40967
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
40968
+ }
40969
+ if (!this._cache.has(input.data)) {
40970
+ const expectedValues = util.objectValues(nativeEnumValues);
40971
+ addIssueToContext(ctx, {
40972
+ received: ctx.data,
40973
+ code: ZodIssueCode.invalid_enum_value,
40974
+ options: expectedValues
40975
+ });
40976
+ return INVALID;
40977
+ }
40978
+ return OK(input.data);
40979
+ }
40980
+ get enum() {
40981
+ return this._def.values;
40982
+ }
40983
+ };
40984
+ ZodNativeEnum.create = (values, params) => {
40985
+ return new ZodNativeEnum({
40986
+ values,
40987
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
40988
+ ...processCreateParams(params)
40989
+ });
40990
+ };
40991
+ var ZodPromise = class extends ZodType {
40992
+ unwrap() {
40993
+ return this._def.type;
40994
+ }
40995
+ _parse(input) {
40996
+ const { ctx } = this._processInputParams(input);
40997
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
40998
+ addIssueToContext(ctx, {
40999
+ code: ZodIssueCode.invalid_type,
41000
+ expected: ZodParsedType.promise,
41001
+ received: ctx.parsedType
41002
+ });
41003
+ return INVALID;
41004
+ }
41005
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
41006
+ return OK(promisified.then((data) => {
41007
+ return this._def.type.parseAsync(data, {
41008
+ path: ctx.path,
41009
+ errorMap: ctx.common.contextualErrorMap
41010
+ });
41011
+ }));
41012
+ }
41013
+ };
41014
+ ZodPromise.create = (schema, params) => {
41015
+ return new ZodPromise({
41016
+ type: schema,
41017
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
41018
+ ...processCreateParams(params)
41019
+ });
41020
+ };
41021
+ var ZodEffects = class extends ZodType {
41022
+ innerType() {
41023
+ return this._def.schema;
41024
+ }
41025
+ sourceType() {
41026
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
41027
+ }
41028
+ _parse(input) {
41029
+ const { status, ctx } = this._processInputParams(input);
41030
+ const effect = this._def.effect || null;
41031
+ const checkCtx = {
41032
+ addIssue: (arg) => {
41033
+ addIssueToContext(ctx, arg);
41034
+ if (arg.fatal) {
41035
+ status.abort();
41036
+ } else {
41037
+ status.dirty();
41038
+ }
41039
+ },
41040
+ get path() {
41041
+ return ctx.path;
41042
+ }
41043
+ };
41044
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
41045
+ if (effect.type === "preprocess") {
41046
+ const processed = effect.transform(ctx.data, checkCtx);
41047
+ if (ctx.common.async) {
41048
+ return Promise.resolve(processed).then(async (processed2) => {
41049
+ if (status.value === "aborted")
41050
+ return INVALID;
41051
+ const result = await this._def.schema._parseAsync({
41052
+ data: processed2,
41053
+ path: ctx.path,
41054
+ parent: ctx
41055
+ });
41056
+ if (result.status === "aborted")
41057
+ return INVALID;
41058
+ if (result.status === "dirty")
41059
+ return DIRTY(result.value);
41060
+ if (status.value === "dirty")
41061
+ return DIRTY(result.value);
41062
+ return result;
41063
+ });
41064
+ } else {
41065
+ if (status.value === "aborted")
41066
+ return INVALID;
41067
+ const result = this._def.schema._parseSync({
41068
+ data: processed,
41069
+ path: ctx.path,
41070
+ parent: ctx
41071
+ });
41072
+ if (result.status === "aborted")
41073
+ return INVALID;
41074
+ if (result.status === "dirty")
41075
+ return DIRTY(result.value);
41076
+ if (status.value === "dirty")
41077
+ return DIRTY(result.value);
41078
+ return result;
41079
+ }
41080
+ }
41081
+ if (effect.type === "refinement") {
41082
+ const executeRefinement = (acc) => {
41083
+ const result = effect.refinement(acc, checkCtx);
41084
+ if (ctx.common.async) {
41085
+ return Promise.resolve(result);
41086
+ }
41087
+ if (result instanceof Promise) {
41088
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
41089
+ }
41090
+ return acc;
41091
+ };
41092
+ if (ctx.common.async === false) {
41093
+ const inner = this._def.schema._parseSync({
41094
+ data: ctx.data,
41095
+ path: ctx.path,
41096
+ parent: ctx
41097
+ });
41098
+ if (inner.status === "aborted")
41099
+ return INVALID;
41100
+ if (inner.status === "dirty")
41101
+ status.dirty();
41102
+ executeRefinement(inner.value);
41103
+ return { status: status.value, value: inner.value };
41104
+ } else {
41105
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
41106
+ if (inner.status === "aborted")
41107
+ return INVALID;
41108
+ if (inner.status === "dirty")
41109
+ status.dirty();
41110
+ return executeRefinement(inner.value).then(() => {
41111
+ return { status: status.value, value: inner.value };
41112
+ });
41113
+ });
41114
+ }
41115
+ }
41116
+ if (effect.type === "transform") {
41117
+ if (ctx.common.async === false) {
41118
+ const base2 = this._def.schema._parseSync({
41119
+ data: ctx.data,
41120
+ path: ctx.path,
41121
+ parent: ctx
41122
+ });
41123
+ if (!isValid(base2))
41124
+ return INVALID;
41125
+ const result = effect.transform(base2.value, checkCtx);
41126
+ if (result instanceof Promise) {
41127
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
41128
+ }
41129
+ return { status: status.value, value: result };
41130
+ } else {
41131
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base2) => {
41132
+ if (!isValid(base2))
41133
+ return INVALID;
41134
+ return Promise.resolve(effect.transform(base2.value, checkCtx)).then((result) => ({
41135
+ status: status.value,
41136
+ value: result
41137
+ }));
41138
+ });
41139
+ }
41140
+ }
41141
+ util.assertNever(effect);
41142
+ }
41143
+ };
41144
+ ZodEffects.create = (schema, effect, params) => {
41145
+ return new ZodEffects({
41146
+ schema,
41147
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
41148
+ effect,
41149
+ ...processCreateParams(params)
41150
+ });
41151
+ };
41152
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
41153
+ return new ZodEffects({
41154
+ schema,
41155
+ effect: { type: "preprocess", transform: preprocess },
41156
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
41157
+ ...processCreateParams(params)
41158
+ });
41159
+ };
41160
+ var ZodOptional = class extends ZodType {
41161
+ _parse(input) {
41162
+ const parsedType = this._getType(input);
41163
+ if (parsedType === ZodParsedType.undefined) {
41164
+ return OK(void 0);
41165
+ }
41166
+ return this._def.innerType._parse(input);
41167
+ }
41168
+ unwrap() {
41169
+ return this._def.innerType;
41170
+ }
41171
+ };
41172
+ ZodOptional.create = (type, params) => {
41173
+ return new ZodOptional({
41174
+ innerType: type,
41175
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
41176
+ ...processCreateParams(params)
41177
+ });
41178
+ };
41179
+ var ZodNullable = class extends ZodType {
41180
+ _parse(input) {
41181
+ const parsedType = this._getType(input);
41182
+ if (parsedType === ZodParsedType.null) {
41183
+ return OK(null);
41184
+ }
41185
+ return this._def.innerType._parse(input);
41186
+ }
41187
+ unwrap() {
41188
+ return this._def.innerType;
41189
+ }
41190
+ };
41191
+ ZodNullable.create = (type, params) => {
41192
+ return new ZodNullable({
41193
+ innerType: type,
41194
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
41195
+ ...processCreateParams(params)
41196
+ });
41197
+ };
41198
+ var ZodDefault = class extends ZodType {
41199
+ _parse(input) {
41200
+ const { ctx } = this._processInputParams(input);
41201
+ let data = ctx.data;
41202
+ if (ctx.parsedType === ZodParsedType.undefined) {
41203
+ data = this._def.defaultValue();
41204
+ }
41205
+ return this._def.innerType._parse({
41206
+ data,
41207
+ path: ctx.path,
41208
+ parent: ctx
41209
+ });
41210
+ }
41211
+ removeDefault() {
41212
+ return this._def.innerType;
41213
+ }
41214
+ };
41215
+ ZodDefault.create = (type, params) => {
41216
+ return new ZodDefault({
41217
+ innerType: type,
41218
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
41219
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
41220
+ ...processCreateParams(params)
41221
+ });
41222
+ };
41223
+ var ZodCatch = class extends ZodType {
41224
+ _parse(input) {
41225
+ const { ctx } = this._processInputParams(input);
41226
+ const newCtx = {
41227
+ ...ctx,
41228
+ common: {
41229
+ ...ctx.common,
41230
+ issues: []
41231
+ }
41232
+ };
41233
+ const result = this._def.innerType._parse({
41234
+ data: newCtx.data,
41235
+ path: newCtx.path,
41236
+ parent: {
41237
+ ...newCtx
41238
+ }
41239
+ });
41240
+ if (isAsync(result)) {
41241
+ return result.then((result2) => {
41242
+ return {
41243
+ status: "valid",
41244
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
41245
+ get error() {
41246
+ return new ZodError(newCtx.common.issues);
41247
+ },
41248
+ input: newCtx.data
41249
+ })
41250
+ };
41251
+ });
41252
+ } else {
41253
+ return {
41254
+ status: "valid",
41255
+ value: result.status === "valid" ? result.value : this._def.catchValue({
41256
+ get error() {
41257
+ return new ZodError(newCtx.common.issues);
41258
+ },
41259
+ input: newCtx.data
41260
+ })
41261
+ };
41262
+ }
41263
+ }
41264
+ removeCatch() {
41265
+ return this._def.innerType;
41266
+ }
41267
+ };
41268
+ ZodCatch.create = (type, params) => {
41269
+ return new ZodCatch({
41270
+ innerType: type,
41271
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
41272
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
41273
+ ...processCreateParams(params)
41274
+ });
41275
+ };
41276
+ var ZodNaN = class extends ZodType {
41277
+ _parse(input) {
41278
+ const parsedType = this._getType(input);
41279
+ if (parsedType !== ZodParsedType.nan) {
41280
+ const ctx = this._getOrReturnCtx(input);
41281
+ addIssueToContext(ctx, {
41282
+ code: ZodIssueCode.invalid_type,
41283
+ expected: ZodParsedType.nan,
41284
+ received: ctx.parsedType
41285
+ });
41286
+ return INVALID;
41287
+ }
41288
+ return { status: "valid", value: input.data };
41289
+ }
41290
+ };
41291
+ ZodNaN.create = (params) => {
41292
+ return new ZodNaN({
41293
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
41294
+ ...processCreateParams(params)
41295
+ });
41296
+ };
41297
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
41298
+ var ZodBranded = class extends ZodType {
41299
+ _parse(input) {
41300
+ const { ctx } = this._processInputParams(input);
41301
+ const data = ctx.data;
41302
+ return this._def.type._parse({
41303
+ data,
41304
+ path: ctx.path,
41305
+ parent: ctx
41306
+ });
41307
+ }
41308
+ unwrap() {
41309
+ return this._def.type;
41310
+ }
41311
+ };
41312
+ var ZodPipeline = class _ZodPipeline extends ZodType {
41313
+ _parse(input) {
41314
+ const { status, ctx } = this._processInputParams(input);
41315
+ if (ctx.common.async) {
41316
+ const handleAsync = async () => {
41317
+ const inResult = await this._def.in._parseAsync({
41318
+ data: ctx.data,
41319
+ path: ctx.path,
41320
+ parent: ctx
41321
+ });
41322
+ if (inResult.status === "aborted")
41323
+ return INVALID;
41324
+ if (inResult.status === "dirty") {
41325
+ status.dirty();
41326
+ return DIRTY(inResult.value);
41327
+ } else {
41328
+ return this._def.out._parseAsync({
41329
+ data: inResult.value,
41330
+ path: ctx.path,
41331
+ parent: ctx
41332
+ });
41333
+ }
41334
+ };
41335
+ return handleAsync();
41336
+ } else {
41337
+ const inResult = this._def.in._parseSync({
41338
+ data: ctx.data,
41339
+ path: ctx.path,
41340
+ parent: ctx
41341
+ });
41342
+ if (inResult.status === "aborted")
41343
+ return INVALID;
41344
+ if (inResult.status === "dirty") {
41345
+ status.dirty();
41346
+ return {
41347
+ status: "dirty",
41348
+ value: inResult.value
41349
+ };
41350
+ } else {
41351
+ return this._def.out._parseSync({
41352
+ data: inResult.value,
41353
+ path: ctx.path,
41354
+ parent: ctx
41355
+ });
41356
+ }
41357
+ }
41358
+ }
41359
+ static create(a, b) {
41360
+ return new _ZodPipeline({
41361
+ in: a,
41362
+ out: b,
41363
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
41364
+ });
41365
+ }
41366
+ };
41367
+ var ZodReadonly = class extends ZodType {
41368
+ _parse(input) {
41369
+ const result = this._def.innerType._parse(input);
41370
+ const freeze = (data) => {
41371
+ if (isValid(data)) {
41372
+ data.value = Object.freeze(data.value);
41373
+ }
41374
+ return data;
41375
+ };
41376
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
41377
+ }
41378
+ unwrap() {
41379
+ return this._def.innerType;
41380
+ }
41381
+ };
41382
+ ZodReadonly.create = (type, params) => {
41383
+ return new ZodReadonly({
41384
+ innerType: type,
41385
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
41386
+ ...processCreateParams(params)
41387
+ });
41388
+ };
41389
+ function cleanParams(params, data) {
41390
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
41391
+ const p2 = typeof p === "string" ? { message: p } : p;
41392
+ return p2;
41393
+ }
41394
+ function custom(check, _params = {}, fatal) {
41395
+ if (check)
41396
+ return ZodAny.create().superRefine((data, ctx) => {
41397
+ const r = check(data);
41398
+ if (r instanceof Promise) {
41399
+ return r.then((r2) => {
41400
+ if (!r2) {
41401
+ const params = cleanParams(_params, data);
41402
+ const _fatal = params.fatal ?? fatal ?? true;
41403
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
41404
+ }
41405
+ });
41406
+ }
41407
+ if (!r) {
41408
+ const params = cleanParams(_params, data);
41409
+ const _fatal = params.fatal ?? fatal ?? true;
41410
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
41411
+ }
41412
+ return;
41413
+ });
41414
+ return ZodAny.create();
41415
+ }
41416
+ var late = {
41417
+ object: ZodObject.lazycreate
41418
+ };
41419
+ var ZodFirstPartyTypeKind;
41420
+ (function(ZodFirstPartyTypeKind2) {
41421
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
41422
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
41423
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
41424
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
41425
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
41426
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
41427
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
41428
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
41429
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
41430
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
41431
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
41432
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
41433
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
41434
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
41435
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
41436
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
41437
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
41438
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
41439
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
41440
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
41441
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
41442
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
41443
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
41444
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
41445
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
41446
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
41447
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
41448
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
41449
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
41450
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
41451
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
41452
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
41453
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
41454
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
41455
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
41456
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
41457
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
41458
+ var instanceOfType = (cls, params = {
41459
+ message: `Input not instance of ${cls.name}`
41460
+ }) => custom((data) => data instanceof cls, params);
41461
+ var stringType = ZodString.create;
41462
+ var numberType = ZodNumber.create;
41463
+ var nanType = ZodNaN.create;
41464
+ var bigIntType = ZodBigInt.create;
41465
+ var booleanType = ZodBoolean.create;
41466
+ var dateType = ZodDate.create;
41467
+ var symbolType = ZodSymbol.create;
41468
+ var undefinedType = ZodUndefined.create;
41469
+ var nullType = ZodNull.create;
41470
+ var anyType = ZodAny.create;
41471
+ var unknownType = ZodUnknown.create;
41472
+ var neverType = ZodNever.create;
41473
+ var voidType = ZodVoid.create;
41474
+ var arrayType = ZodArray.create;
41475
+ var objectType = ZodObject.create;
41476
+ var strictObjectType = ZodObject.strictCreate;
41477
+ var unionType = ZodUnion.create;
41478
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
41479
+ var intersectionType = ZodIntersection.create;
41480
+ var tupleType = ZodTuple.create;
41481
+ var recordType = ZodRecord.create;
41482
+ var mapType = ZodMap.create;
41483
+ var setType = ZodSet.create;
41484
+ var functionType = ZodFunction.create;
41485
+ var lazyType = ZodLazy.create;
41486
+ var literalType = ZodLiteral.create;
41487
+ var enumType = ZodEnum.create;
41488
+ var nativeEnumType = ZodNativeEnum.create;
41489
+ var promiseType = ZodPromise.create;
41490
+ var effectsType = ZodEffects.create;
41491
+ var optionalType = ZodOptional.create;
41492
+ var nullableType = ZodNullable.create;
41493
+ var preprocessType = ZodEffects.createWithPreprocess;
41494
+ var pipelineType = ZodPipeline.create;
41495
+ var ostring = () => stringType().optional();
41496
+ var onumber = () => numberType().optional();
41497
+ var oboolean = () => booleanType().optional();
41498
+ var coerce = {
41499
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
41500
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
41501
+ boolean: ((arg) => ZodBoolean.create({
41502
+ ...arg,
41503
+ coerce: true
41504
+ })),
41505
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
41506
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
41507
+ };
41508
+ var NEVER = INVALID;
41509
+
41510
+ // node_modules/@x402/core/dist/esm/chunk-KMQH4MQI.mjs
41511
+ var NonEmptyString = external_exports.string().min(1);
41512
+ var Any = external_exports.record(external_exports.unknown());
41513
+ var OptionalAny = external_exports.record(external_exports.unknown()).optional().nullable();
41514
+ var NetworkSchemaV1 = NonEmptyString;
41515
+ var NetworkSchemaV2 = external_exports.string().min(3).refine((val) => val.includes(":"), {
41516
+ message: "Network must be in CAIP-2 format (e.g., 'eip155:84532')"
41517
+ });
41518
+ var NetworkSchema = external_exports.union([NetworkSchemaV1, NetworkSchemaV2]);
41519
+ var ResourceInfoSchema = external_exports.object({
41520
+ url: NonEmptyString,
41521
+ description: external_exports.string().optional(),
41522
+ mimeType: external_exports.string().optional()
41523
+ });
41524
+ var PaymentRequirementsV1Schema = external_exports.object({
41525
+ scheme: NonEmptyString,
41526
+ network: NetworkSchemaV1,
41527
+ maxAmountRequired: NonEmptyString,
41528
+ resource: NonEmptyString,
41529
+ // URL string in V1
41530
+ description: external_exports.string(),
41531
+ mimeType: external_exports.string().optional(),
41532
+ outputSchema: Any.optional().nullable(),
41533
+ payTo: NonEmptyString,
41534
+ maxTimeoutSeconds: external_exports.number().positive(),
41535
+ asset: NonEmptyString,
41536
+ extra: OptionalAny
41537
+ });
41538
+ var PaymentRequiredV1Schema = external_exports.object({
41539
+ x402Version: external_exports.literal(1),
41540
+ error: external_exports.string().optional(),
41541
+ accepts: external_exports.array(PaymentRequirementsV1Schema).min(1)
41542
+ });
41543
+ var PaymentPayloadV1Schema = external_exports.object({
41544
+ x402Version: external_exports.literal(1),
41545
+ scheme: NonEmptyString,
41546
+ network: NetworkSchemaV1,
41547
+ payload: Any
41548
+ });
41549
+ var PaymentRequirementsV2Schema = external_exports.object({
41550
+ scheme: NonEmptyString,
41551
+ network: NetworkSchemaV2,
41552
+ amount: NonEmptyString,
41553
+ asset: NonEmptyString,
41554
+ payTo: NonEmptyString,
41555
+ maxTimeoutSeconds: external_exports.number().positive(),
41556
+ extra: OptionalAny
41557
+ });
41558
+ var PaymentRequiredV2Schema = external_exports.object({
41559
+ x402Version: external_exports.literal(2),
41560
+ error: external_exports.string().optional(),
41561
+ resource: ResourceInfoSchema,
41562
+ accepts: external_exports.array(PaymentRequirementsV2Schema).min(1),
41563
+ extensions: OptionalAny
41564
+ });
41565
+ var PaymentPayloadV2Schema = external_exports.object({
41566
+ x402Version: external_exports.literal(2),
41567
+ resource: ResourceInfoSchema.optional(),
41568
+ accepted: PaymentRequirementsV2Schema,
41569
+ payload: Any,
41570
+ extensions: OptionalAny
41571
+ });
41572
+ var PaymentRequirementsSchema = external_exports.union([
41573
+ PaymentRequirementsV1Schema,
41574
+ PaymentRequirementsV2Schema
41575
+ ]);
41576
+ var PaymentRequiredSchema = external_exports.discriminatedUnion("x402Version", [
41577
+ PaymentRequiredV1Schema,
41578
+ PaymentRequiredV2Schema
41579
+ ]);
41580
+ var PaymentPayloadSchema = external_exports.discriminatedUnion("x402Version", [
41581
+ PaymentPayloadV1Schema,
41582
+ PaymentPayloadV2Schema
41583
+ ]);
41584
+
37450
41585
  // node_modules/@x402/core/dist/esm/chunk-VE37GDG2.mjs
37451
41586
  var x402Version = 2;
37452
41587
 
@@ -37490,7 +41625,36 @@ function safeBase64Decode(data) {
37490
41625
  return Buffer.from(data, "base64").toString("utf-8");
37491
41626
  }
37492
41627
 
37493
- // node_modules/@x402/core/dist/esm/chunk-5KCDBAZ7.mjs
41628
+ // node_modules/@x402/core/dist/esm/chunk-ACVTKVCM.mjs
41629
+ var verifyResponseSchema = external_exports.object({
41630
+ isValid: external_exports.boolean(),
41631
+ invalidReason: external_exports.string().nullish().transform((v) => v ?? void 0),
41632
+ invalidMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
41633
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
41634
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
41635
+ });
41636
+ var settleResponseSchema = external_exports.object({
41637
+ success: external_exports.boolean(),
41638
+ errorReason: external_exports.string().nullish().transform((v) => v ?? void 0),
41639
+ errorMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
41640
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
41641
+ transaction: external_exports.string(),
41642
+ network: external_exports.custom((value) => typeof value === "string"),
41643
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
41644
+ });
41645
+ var supportedKindSchema = external_exports.object({
41646
+ x402Version: external_exports.number(),
41647
+ scheme: external_exports.string(),
41648
+ network: external_exports.custom(
41649
+ (value) => typeof value === "string"
41650
+ ),
41651
+ extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
41652
+ });
41653
+ var supportedResponseSchema = external_exports.object({
41654
+ kinds: external_exports.array(supportedKindSchema),
41655
+ extensions: external_exports.array(external_exports.string()).default([]),
41656
+ signers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default({})
41657
+ });
37494
41658
  var x402HTTPClient = class {
37495
41659
  /**
37496
41660
  * Creates a new x402HTTPClient instance.
@@ -47966,7 +52130,7 @@ async function startProxy(options) {
47966
52130
  }
47967
52131
  return;
47968
52132
  }
47969
- if (req.url?.match(/^\/v1\/(?:x|partner)\//)) {
52133
+ if (req.url?.match(/^\/v1\/(?:x|partner|pm)\//)) {
47970
52134
  try {
47971
52135
  await proxyPartnerRequest(
47972
52136
  req,
@@ -50125,7 +54289,9 @@ function printDiagnostics(result) {
50125
54289
  const chainLabel = result.wallet.paymentChain === "solana" ? "Solana" : "Base";
50126
54290
  console.log(` ${green(`Chain: ${chainLabel}`)}`);
50127
54291
  if (result.wallet.isEmpty) {
50128
- console.log(` ${red(`Balance: $0.00 - NEED TO FUND WITH USDC ON ${chainLabel.toUpperCase()}!`)}`);
54292
+ console.log(
54293
+ ` ${red(`Balance: $0.00 - NEED TO FUND WITH USDC ON ${chainLabel.toUpperCase()}!`)}`
54294
+ );
50129
54295
  if (result.wallet.paymentChain === "base" && result.wallet.solanaAddress) {
50130
54296
  console.log(` ${yellow(`Tip: funded Solana instead? Run /wallet solana to switch`)}`);
50131
54297
  }