@blockrun/clawrouter 0.12.85 → 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/index.js CHANGED
@@ -1040,7 +1040,7 @@ var version2;
1040
1040
  var init_version2 = __esm({
1041
1041
  "node_modules/viem/_esm/errors/version.js"() {
1042
1042
  "use strict";
1043
- version2 = "2.46.3";
1043
+ version2 = "2.47.6";
1044
1044
  }
1045
1045
  });
1046
1046
 
@@ -1198,9 +1198,10 @@ var init_abi = __esm({
1198
1198
  }
1199
1199
  };
1200
1200
  AbiDecodingZeroDataError = class extends BaseError2 {
1201
- constructor() {
1201
+ constructor({ cause } = {}) {
1202
1202
  super('Cannot decode zero data ("0x") with ABI parameters.', {
1203
- name: "AbiDecodingZeroDataError"
1203
+ name: "AbiDecodingZeroDataError",
1204
+ cause
1204
1205
  });
1205
1206
  }
1206
1207
  };
@@ -1251,14 +1252,15 @@ var init_abi = __esm({
1251
1252
  }
1252
1253
  };
1253
1254
  AbiErrorSignatureNotFoundError = class extends BaseError2 {
1254
- constructor(signature2, { docsPath: docsPath8 }) {
1255
+ constructor(signature2, { docsPath: docsPath8, cause }) {
1255
1256
  super([
1256
1257
  `Encoded error signature "${signature2}" not found on ABI.`,
1257
1258
  "Make sure you are using the correct ABI and that the error exists on it.",
1258
1259
  `You can look up the decoded signature here: https://4byte.sourcify.dev/?q=${signature2}.`
1259
1260
  ].join("\n"), {
1260
1261
  docsPath: docsPath8,
1261
- name: "AbiErrorSignatureNotFoundError"
1262
+ name: "AbiErrorSignatureNotFoundError",
1263
+ cause
1262
1264
  });
1263
1265
  Object.defineProperty(this, "signature", {
1264
1266
  enumerable: true,
@@ -2304,18 +2306,20 @@ var init_lru = __esm({
2304
2306
  }
2305
2307
  get(key) {
2306
2308
  const value = super.get(key);
2307
- if (super.has(key) && value !== void 0) {
2308
- this.delete(key);
2309
+ if (super.has(key)) {
2310
+ super.delete(key);
2309
2311
  super.set(key, value);
2310
2312
  }
2311
2313
  return value;
2312
2314
  }
2313
2315
  set(key, value) {
2316
+ if (super.has(key))
2317
+ super.delete(key);
2314
2318
  super.set(key, value);
2315
2319
  if (this.maxSize && this.size > this.maxSize) {
2316
- const firstKey = this.keys().next().value;
2317
- if (firstKey)
2318
- this.delete(firstKey);
2320
+ const firstKey = super.keys().next().value;
2321
+ if (firstKey !== void 0)
2322
+ super.delete(firstKey);
2319
2323
  }
2320
2324
  return this;
2321
2325
  }
@@ -3394,15 +3398,16 @@ var init_decodeAbiParameters = __esm({
3394
3398
 
3395
3399
  // node_modules/viem/_esm/utils/abi/decodeErrorResult.js
3396
3400
  function decodeErrorResult(parameters) {
3397
- const { abi: abi2, data } = parameters;
3401
+ const { abi: abi2, data, cause } = parameters;
3398
3402
  const signature2 = slice(data, 0, 4);
3399
3403
  if (signature2 === "0x")
3400
- throw new AbiDecodingZeroDataError();
3404
+ throw new AbiDecodingZeroDataError({ cause });
3401
3405
  const abi_ = [...abi2 || [], solidityError, solidityPanic];
3402
3406
  const abiItem = abi_.find((x) => x.type === "error" && signature2 === toFunctionSelector(formatAbiItem2(x)));
3403
3407
  if (!abiItem)
3404
3408
  throw new AbiErrorSignatureNotFoundError(signature2, {
3405
- docsPath: "/docs/contract/decodeErrorResult"
3409
+ docsPath: "/docs/contract/decodeErrorResult",
3410
+ cause
3406
3411
  });
3407
3412
  return {
3408
3413
  abiItem,
@@ -3841,14 +3846,14 @@ ${prettyStateOverride(stateOverride)}`;
3841
3846
  }
3842
3847
  };
3843
3848
  ContractFunctionRevertedError = class extends BaseError2 {
3844
- constructor({ abi: abi2, data, functionName, message }) {
3849
+ constructor({ abi: abi2, data, functionName, message, cause: error }) {
3845
3850
  let cause;
3846
3851
  let decodedData;
3847
3852
  let metaMessages;
3848
3853
  let reason;
3849
3854
  if (data && data !== "0x") {
3850
3855
  try {
3851
- decodedData = decodeErrorResult({ abi: abi2, data });
3856
+ decodedData = decodeErrorResult({ abi: abi2, data, cause: error });
3852
3857
  const { abiItem, errorName, args: errorArgs } = decodedData;
3853
3858
  if (errorName === "Error") {
3854
3859
  reason = errorArgs[0];
@@ -3886,7 +3891,7 @@ ${prettyStateOverride(stateOverride)}`;
3886
3891
  `The contract function "${functionName}" reverted with the following ${signature2 ? "signature" : "reason"}:`,
3887
3892
  reason || signature2
3888
3893
  ].join("\n") : `The contract function "${functionName}" reverted.`, {
3889
- cause,
3894
+ cause: cause ?? error,
3890
3895
  metaMessages,
3891
3896
  name: "ContractFunctionRevertedError"
3892
3897
  });
@@ -3921,7 +3926,7 @@ ${prettyStateOverride(stateOverride)}`;
3921
3926
  }
3922
3927
  };
3923
3928
  ContractFunctionZeroDataError = class extends BaseError2 {
3924
- constructor({ functionName }) {
3929
+ constructor({ functionName, cause }) {
3925
3930
  super(`The contract function "${functionName}" returned no data ("0x").`, {
3926
3931
  metaMessages: [
3927
3932
  "This could be due to any of the following:",
@@ -3929,7 +3934,8 @@ ${prettyStateOverride(stateOverride)}`;
3929
3934
  " - The parameters passed to the contract function may be invalid, or",
3930
3935
  " - The address is not a contract."
3931
3936
  ],
3932
- name: "ContractFunctionZeroDataError"
3937
+ name: "ContractFunctionZeroDataError",
3938
+ cause
3933
3939
  });
3934
3940
  }
3935
3941
  };
@@ -6714,11 +6720,11 @@ function mapToCurveSimpleSWU(Fp, opts) {
6714
6720
  tv5 = Fp.mul(tv6, opts.B);
6715
6721
  tv2 = Fp.add(tv2, tv5);
6716
6722
  x = Fp.mul(tv1, tv3);
6717
- const { isValid, value } = sqrtRatio(tv2, tv6);
6723
+ const { isValid: isValid2, value } = sqrtRatio(tv2, tv6);
6718
6724
  y = Fp.mul(tv1, u);
6719
6725
  y = Fp.mul(y, value);
6720
- x = Fp.cmov(x, tv3, isValid);
6721
- y = Fp.cmov(y, value, isValid);
6726
+ x = Fp.cmov(x, tv3, isValid2);
6727
+ y = Fp.cmov(y, value, isValid2);
6722
6728
  const e1 = Fp.isOdd(u) === Fp.isOdd(y);
6723
6729
  y = Fp.cmov(Fp.neg(y), y, e1);
6724
6730
  const tv4_inv = FpInvertBatch(Fp, [tv4], true)[0];
@@ -21919,8 +21925,8 @@ async function createKeyPairFromBytes(bytes, extractable = false) {
21919
21925
  const randomBytes3 = new Uint8Array(32);
21920
21926
  crypto.getRandomValues(randomBytes3);
21921
21927
  const signedData = await signBytes(privateKey, randomBytes3);
21922
- const isValid = await verifySignature(publicKey, signedData, randomBytes3);
21923
- if (!isValid) {
21928
+ const isValid2 = await verifySignature(publicKey, signedData, randomBytes3);
21929
+ if (!isValid2) {
21924
21930
  throw new SolanaError(SOLANA_ERROR__KEYS__PUBLIC_KEY_MUST_MATCH_PRIVATE_KEY);
21925
21931
  }
21926
21932
  return { privateKey, publicKey };
@@ -33863,13 +33869,14 @@ function getContractError(err, { abi: abi2, address: address2, args, docsPath: d
33863
33869
  const { code, data, details, message, shortMessage } = error;
33864
33870
  const cause = (() => {
33865
33871
  if (err instanceof AbiDecodingZeroDataError)
33866
- return new ContractFunctionZeroDataError({ functionName });
33872
+ return new ContractFunctionZeroDataError({ functionName, cause: err });
33867
33873
  if ([EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) && (data || details || message || shortMessage) || code === InvalidInputRpcError.code && details === "execution reverted" && data) {
33868
33874
  return new ContractFunctionRevertedError({
33869
33875
  abi: abi2,
33870
33876
  data: typeof data === "object" ? data.data : data,
33871
33877
  functionName,
33872
- message: error instanceof RpcRequestError ? details : shortMessage ?? message
33878
+ message: error instanceof RpcRequestError ? details : shortMessage ?? message,
33879
+ cause: err
33873
33880
  });
33874
33881
  }
33875
33882
  return err;
@@ -34500,14 +34507,14 @@ async function prepareTransactionRequest(client, args) {
34500
34507
  return {
34501
34508
  ...request,
34502
34509
  ...from14 ? { from: from14 } : {},
34503
- ...type2 ? { type: type2 } : {},
34510
+ ...type2 && !request.type ? { type: type2 } : {},
34504
34511
  ...typeof chainId2 !== "undefined" ? { chainId: chainId2 } : {},
34505
34512
  ...typeof gas2 !== "undefined" ? { gas: gas2 } : {},
34506
34513
  ...typeof gasPrice !== "undefined" ? { gasPrice } : {},
34507
34514
  ...typeof nonce2 !== "undefined" ? { nonce: nonce2 } : {},
34508
- ...typeof maxFeePerBlobGas !== "undefined" ? { maxFeePerBlobGas } : {},
34509
- ...typeof maxFeePerGas !== "undefined" ? { maxFeePerGas } : {},
34510
- ...typeof maxPriorityFeePerGas !== "undefined" ? { maxPriorityFeePerGas } : {},
34515
+ ...typeof maxFeePerBlobGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxFeePerBlobGas } : {},
34516
+ ...typeof maxFeePerGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxFeePerGas } : {},
34517
+ ...typeof maxPriorityFeePerGas !== "undefined" && request.type !== "legacy" && request.type !== "eip2930" ? { maxPriorityFeePerGas } : {},
34511
34518
  ..."nonceKey" in rest && typeof rest.nonceKey !== "undefined" ? { nonceKey: rest.nonceKey } : {}
34512
34519
  };
34513
34520
  }).catch((e7) => {
@@ -34516,7 +34523,7 @@ async function prepareTransactionRequest(client, args) {
34516
34523
  return request;
34517
34524
  const unsupported = error.walk?.((e8) => {
34518
34525
  const error2 = e8;
34519
- return error2.name === "MethodNotFoundRpcError" || error2.name === "MethodNotSupportedRpcError";
34526
+ return error2.name === "MethodNotFoundRpcError" || error2.name === "MethodNotSupportedRpcError" || error2.message?.includes("eth_fillTransaction is not available");
34520
34527
  });
34521
34528
  if (unsupported)
34522
34529
  supportsFillTransaction.set(client.uid, false);
@@ -35788,12 +35795,12 @@ async function isImageUri(uri) {
35788
35795
  });
35789
35796
  }
35790
35797
  }
35791
- function getGateway(custom, defaultGateway) {
35792
- if (!custom)
35798
+ function getGateway(custom2, defaultGateway) {
35799
+ if (!custom2)
35793
35800
  return defaultGateway;
35794
- if (custom.endsWith("/"))
35795
- return custom.slice(0, -1);
35796
- return custom;
35801
+ if (custom2.endsWith("/"))
35802
+ return custom2.slice(0, -1);
35803
+ return custom2;
35797
35804
  }
35798
35805
  function resolveAvatarUri({ uri, gatewayUrls }) {
35799
35806
  const isEncoded = base64Regex.test(uri);
@@ -36761,6 +36768,8 @@ function getHttpRpcClient(url_, options = {}) {
36761
36768
  }
36762
36769
  }
36763
36770
  if (!response.ok) {
36771
+ if (typeof data.error?.code === "number" && typeof data.error?.message === "string")
36772
+ return data;
36764
36773
  throw new HttpRequestError({
36765
36774
  body,
36766
36775
  details: stringify(data.error) || response.statusText,
@@ -40663,7 +40672,7 @@ async function simulateCalls(client, parameters) {
40663
40672
  }
40664
40673
  ] : [],
40665
40674
  {
40666
- calls: [...calls, {}].map((call2) => ({
40675
+ calls: [...calls, { to: zeroAddress }].map((call2) => ({
40667
40676
  ...call2,
40668
40677
  from: account?.address
40669
40678
  })),
@@ -40923,7 +40932,7 @@ init_toHex();
40923
40932
  init_serializeSignature();
40924
40933
  init_call();
40925
40934
  async function verifyHash(client, parameters) {
40926
- 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;
40935
+ 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;
40927
40936
  if (chain3?.verifyHash)
40928
40937
  return await chain3.verifyHash(client, parameters);
40929
40938
  const signature2 = (() => {
@@ -40935,6 +40944,14 @@ async function verifyHash(client, parameters) {
40935
40944
  return bytesToHex(signature3);
40936
40945
  })();
40937
40946
  try {
40947
+ if (mode === "eoa") {
40948
+ try {
40949
+ const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
40950
+ if (verified)
40951
+ return true;
40952
+ } catch {
40953
+ }
40954
+ }
40938
40955
  if (SignatureErc8010_exports.validate(signature2))
40939
40956
  return await verifyErc8010(client, {
40940
40957
  ...parameters,
@@ -40947,11 +40964,13 @@ async function verifyHash(client, parameters) {
40947
40964
  signature: signature2
40948
40965
  });
40949
40966
  } catch (error) {
40950
- try {
40951
- const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
40952
- if (verified)
40953
- return true;
40954
- } catch {
40967
+ if (mode !== "eoa") {
40968
+ try {
40969
+ const verified = isAddressEqual(getAddress(address2), await recoverAddress({ hash: hash3, signature: signature2 }));
40970
+ if (verified)
40971
+ return true;
40972
+ } catch {
40973
+ }
40955
40974
  }
40956
40975
  if (error instanceof VerificationError) {
40957
40976
  return false;
@@ -41762,7 +41781,7 @@ async function verifySiweMessage(client, parameters) {
41762
41781
  const parsed = parseSiweMessage(message);
41763
41782
  if (!parsed.address)
41764
41783
  return false;
41765
- const isValid = validateSiweMessage({
41784
+ const isValid2 = validateSiweMessage({
41766
41785
  address: address2,
41767
41786
  domain,
41768
41787
  message: parsed,
@@ -41770,7 +41789,7 @@ async function verifySiweMessage(client, parameters) {
41770
41789
  scheme,
41771
41790
  time
41772
41791
  });
41773
- if (!isValid)
41792
+ if (!isValid2)
41774
41793
  return false;
41775
41794
  const hash3 = hashMessage(message);
41776
41795
  return verifyHash(client, {
@@ -42153,6 +42172,4122 @@ var basePreconf = /* @__PURE__ */ defineChain({
42153
42172
  // src/proxy.ts
42154
42173
  init_accounts();
42155
42174
 
42175
+ // node_modules/zod/v3/external.js
42176
+ var external_exports = {};
42177
+ __export(external_exports, {
42178
+ BRAND: () => BRAND,
42179
+ DIRTY: () => DIRTY,
42180
+ EMPTY_PATH: () => EMPTY_PATH,
42181
+ INVALID: () => INVALID,
42182
+ NEVER: () => NEVER,
42183
+ OK: () => OK,
42184
+ ParseStatus: () => ParseStatus,
42185
+ Schema: () => ZodType,
42186
+ ZodAny: () => ZodAny,
42187
+ ZodArray: () => ZodArray,
42188
+ ZodBigInt: () => ZodBigInt,
42189
+ ZodBoolean: () => ZodBoolean,
42190
+ ZodBranded: () => ZodBranded,
42191
+ ZodCatch: () => ZodCatch,
42192
+ ZodDate: () => ZodDate,
42193
+ ZodDefault: () => ZodDefault,
42194
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
42195
+ ZodEffects: () => ZodEffects,
42196
+ ZodEnum: () => ZodEnum,
42197
+ ZodError: () => ZodError,
42198
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
42199
+ ZodFunction: () => ZodFunction,
42200
+ ZodIntersection: () => ZodIntersection,
42201
+ ZodIssueCode: () => ZodIssueCode,
42202
+ ZodLazy: () => ZodLazy,
42203
+ ZodLiteral: () => ZodLiteral,
42204
+ ZodMap: () => ZodMap,
42205
+ ZodNaN: () => ZodNaN,
42206
+ ZodNativeEnum: () => ZodNativeEnum,
42207
+ ZodNever: () => ZodNever,
42208
+ ZodNull: () => ZodNull,
42209
+ ZodNullable: () => ZodNullable,
42210
+ ZodNumber: () => ZodNumber,
42211
+ ZodObject: () => ZodObject,
42212
+ ZodOptional: () => ZodOptional,
42213
+ ZodParsedType: () => ZodParsedType,
42214
+ ZodPipeline: () => ZodPipeline,
42215
+ ZodPromise: () => ZodPromise,
42216
+ ZodReadonly: () => ZodReadonly,
42217
+ ZodRecord: () => ZodRecord,
42218
+ ZodSchema: () => ZodType,
42219
+ ZodSet: () => ZodSet,
42220
+ ZodString: () => ZodString,
42221
+ ZodSymbol: () => ZodSymbol,
42222
+ ZodTransformer: () => ZodEffects,
42223
+ ZodTuple: () => ZodTuple,
42224
+ ZodType: () => ZodType,
42225
+ ZodUndefined: () => ZodUndefined,
42226
+ ZodUnion: () => ZodUnion,
42227
+ ZodUnknown: () => ZodUnknown,
42228
+ ZodVoid: () => ZodVoid,
42229
+ addIssueToContext: () => addIssueToContext,
42230
+ any: () => anyType,
42231
+ array: () => arrayType,
42232
+ bigint: () => bigIntType,
42233
+ boolean: () => booleanType,
42234
+ coerce: () => coerce,
42235
+ custom: () => custom,
42236
+ date: () => dateType,
42237
+ datetimeRegex: () => datetimeRegex,
42238
+ defaultErrorMap: () => en_default,
42239
+ discriminatedUnion: () => discriminatedUnionType,
42240
+ effect: () => effectsType,
42241
+ enum: () => enumType,
42242
+ function: () => functionType,
42243
+ getErrorMap: () => getErrorMap,
42244
+ getParsedType: () => getParsedType,
42245
+ instanceof: () => instanceOfType,
42246
+ intersection: () => intersectionType,
42247
+ isAborted: () => isAborted,
42248
+ isAsync: () => isAsync,
42249
+ isDirty: () => isDirty,
42250
+ isValid: () => isValid,
42251
+ late: () => late,
42252
+ lazy: () => lazyType,
42253
+ literal: () => literalType,
42254
+ makeIssue: () => makeIssue,
42255
+ map: () => mapType,
42256
+ nan: () => nanType,
42257
+ nativeEnum: () => nativeEnumType,
42258
+ never: () => neverType,
42259
+ null: () => nullType,
42260
+ nullable: () => nullableType,
42261
+ number: () => numberType,
42262
+ object: () => objectType,
42263
+ objectUtil: () => objectUtil,
42264
+ oboolean: () => oboolean,
42265
+ onumber: () => onumber,
42266
+ optional: () => optionalType,
42267
+ ostring: () => ostring,
42268
+ pipeline: () => pipelineType,
42269
+ preprocess: () => preprocessType,
42270
+ promise: () => promiseType,
42271
+ quotelessJson: () => quotelessJson,
42272
+ record: () => recordType,
42273
+ set: () => setType,
42274
+ setErrorMap: () => setErrorMap,
42275
+ strictObject: () => strictObjectType,
42276
+ string: () => stringType,
42277
+ symbol: () => symbolType,
42278
+ transformer: () => effectsType,
42279
+ tuple: () => tupleType,
42280
+ undefined: () => undefinedType,
42281
+ union: () => unionType,
42282
+ unknown: () => unknownType,
42283
+ util: () => util,
42284
+ void: () => voidType
42285
+ });
42286
+
42287
+ // node_modules/zod/v3/helpers/util.js
42288
+ var util;
42289
+ (function(util2) {
42290
+ util2.assertEqual = (_) => {
42291
+ };
42292
+ function assertIs(_arg) {
42293
+ }
42294
+ util2.assertIs = assertIs;
42295
+ function assertNever(_x) {
42296
+ throw new Error();
42297
+ }
42298
+ util2.assertNever = assertNever;
42299
+ util2.arrayToEnum = (items) => {
42300
+ const obj = {};
42301
+ for (const item of items) {
42302
+ obj[item] = item;
42303
+ }
42304
+ return obj;
42305
+ };
42306
+ util2.getValidEnumValues = (obj) => {
42307
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
42308
+ const filtered = {};
42309
+ for (const k of validKeys) {
42310
+ filtered[k] = obj[k];
42311
+ }
42312
+ return util2.objectValues(filtered);
42313
+ };
42314
+ util2.objectValues = (obj) => {
42315
+ return util2.objectKeys(obj).map(function(e7) {
42316
+ return obj[e7];
42317
+ });
42318
+ };
42319
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
42320
+ const keys = [];
42321
+ for (const key in object) {
42322
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
42323
+ keys.push(key);
42324
+ }
42325
+ }
42326
+ return keys;
42327
+ };
42328
+ util2.find = (arr, checker) => {
42329
+ for (const item of arr) {
42330
+ if (checker(item))
42331
+ return item;
42332
+ }
42333
+ return void 0;
42334
+ };
42335
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
42336
+ function joinValues(array, separator = " | ") {
42337
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
42338
+ }
42339
+ util2.joinValues = joinValues;
42340
+ util2.jsonStringifyReplacer = (_, value) => {
42341
+ if (typeof value === "bigint") {
42342
+ return value.toString();
42343
+ }
42344
+ return value;
42345
+ };
42346
+ })(util || (util = {}));
42347
+ var objectUtil;
42348
+ (function(objectUtil2) {
42349
+ objectUtil2.mergeShapes = (first, second) => {
42350
+ return {
42351
+ ...first,
42352
+ ...second
42353
+ // second overwrites first
42354
+ };
42355
+ };
42356
+ })(objectUtil || (objectUtil = {}));
42357
+ var ZodParsedType = util.arrayToEnum([
42358
+ "string",
42359
+ "nan",
42360
+ "number",
42361
+ "integer",
42362
+ "float",
42363
+ "boolean",
42364
+ "date",
42365
+ "bigint",
42366
+ "symbol",
42367
+ "function",
42368
+ "undefined",
42369
+ "null",
42370
+ "array",
42371
+ "object",
42372
+ "unknown",
42373
+ "promise",
42374
+ "void",
42375
+ "never",
42376
+ "map",
42377
+ "set"
42378
+ ]);
42379
+ var getParsedType = (data) => {
42380
+ const t = typeof data;
42381
+ switch (t) {
42382
+ case "undefined":
42383
+ return ZodParsedType.undefined;
42384
+ case "string":
42385
+ return ZodParsedType.string;
42386
+ case "number":
42387
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
42388
+ case "boolean":
42389
+ return ZodParsedType.boolean;
42390
+ case "function":
42391
+ return ZodParsedType.function;
42392
+ case "bigint":
42393
+ return ZodParsedType.bigint;
42394
+ case "symbol":
42395
+ return ZodParsedType.symbol;
42396
+ case "object":
42397
+ if (Array.isArray(data)) {
42398
+ return ZodParsedType.array;
42399
+ }
42400
+ if (data === null) {
42401
+ return ZodParsedType.null;
42402
+ }
42403
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
42404
+ return ZodParsedType.promise;
42405
+ }
42406
+ if (typeof Map !== "undefined" && data instanceof Map) {
42407
+ return ZodParsedType.map;
42408
+ }
42409
+ if (typeof Set !== "undefined" && data instanceof Set) {
42410
+ return ZodParsedType.set;
42411
+ }
42412
+ if (typeof Date !== "undefined" && data instanceof Date) {
42413
+ return ZodParsedType.date;
42414
+ }
42415
+ return ZodParsedType.object;
42416
+ default:
42417
+ return ZodParsedType.unknown;
42418
+ }
42419
+ };
42420
+
42421
+ // node_modules/zod/v3/ZodError.js
42422
+ var ZodIssueCode = util.arrayToEnum([
42423
+ "invalid_type",
42424
+ "invalid_literal",
42425
+ "custom",
42426
+ "invalid_union",
42427
+ "invalid_union_discriminator",
42428
+ "invalid_enum_value",
42429
+ "unrecognized_keys",
42430
+ "invalid_arguments",
42431
+ "invalid_return_type",
42432
+ "invalid_date",
42433
+ "invalid_string",
42434
+ "too_small",
42435
+ "too_big",
42436
+ "invalid_intersection_types",
42437
+ "not_multiple_of",
42438
+ "not_finite"
42439
+ ]);
42440
+ var quotelessJson = (obj) => {
42441
+ const json = JSON.stringify(obj, null, 2);
42442
+ return json.replace(/"([^"]+)":/g, "$1:");
42443
+ };
42444
+ var ZodError = class _ZodError extends Error {
42445
+ get errors() {
42446
+ return this.issues;
42447
+ }
42448
+ constructor(issues) {
42449
+ super();
42450
+ this.issues = [];
42451
+ this.addIssue = (sub) => {
42452
+ this.issues = [...this.issues, sub];
42453
+ };
42454
+ this.addIssues = (subs = []) => {
42455
+ this.issues = [...this.issues, ...subs];
42456
+ };
42457
+ const actualProto = new.target.prototype;
42458
+ if (Object.setPrototypeOf) {
42459
+ Object.setPrototypeOf(this, actualProto);
42460
+ } else {
42461
+ this.__proto__ = actualProto;
42462
+ }
42463
+ this.name = "ZodError";
42464
+ this.issues = issues;
42465
+ }
42466
+ format(_mapper) {
42467
+ const mapper = _mapper || function(issue) {
42468
+ return issue.message;
42469
+ };
42470
+ const fieldErrors = { _errors: [] };
42471
+ const processError = (error) => {
42472
+ for (const issue of error.issues) {
42473
+ if (issue.code === "invalid_union") {
42474
+ issue.unionErrors.map(processError);
42475
+ } else if (issue.code === "invalid_return_type") {
42476
+ processError(issue.returnTypeError);
42477
+ } else if (issue.code === "invalid_arguments") {
42478
+ processError(issue.argumentsError);
42479
+ } else if (issue.path.length === 0) {
42480
+ fieldErrors._errors.push(mapper(issue));
42481
+ } else {
42482
+ let curr = fieldErrors;
42483
+ let i = 0;
42484
+ while (i < issue.path.length) {
42485
+ const el = issue.path[i];
42486
+ const terminal = i === issue.path.length - 1;
42487
+ if (!terminal) {
42488
+ curr[el] = curr[el] || { _errors: [] };
42489
+ } else {
42490
+ curr[el] = curr[el] || { _errors: [] };
42491
+ curr[el]._errors.push(mapper(issue));
42492
+ }
42493
+ curr = curr[el];
42494
+ i++;
42495
+ }
42496
+ }
42497
+ }
42498
+ };
42499
+ processError(this);
42500
+ return fieldErrors;
42501
+ }
42502
+ static assert(value) {
42503
+ if (!(value instanceof _ZodError)) {
42504
+ throw new Error(`Not a ZodError: ${value}`);
42505
+ }
42506
+ }
42507
+ toString() {
42508
+ return this.message;
42509
+ }
42510
+ get message() {
42511
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
42512
+ }
42513
+ get isEmpty() {
42514
+ return this.issues.length === 0;
42515
+ }
42516
+ flatten(mapper = (issue) => issue.message) {
42517
+ const fieldErrors = {};
42518
+ const formErrors = [];
42519
+ for (const sub of this.issues) {
42520
+ if (sub.path.length > 0) {
42521
+ const firstEl = sub.path[0];
42522
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
42523
+ fieldErrors[firstEl].push(mapper(sub));
42524
+ } else {
42525
+ formErrors.push(mapper(sub));
42526
+ }
42527
+ }
42528
+ return { formErrors, fieldErrors };
42529
+ }
42530
+ get formErrors() {
42531
+ return this.flatten();
42532
+ }
42533
+ };
42534
+ ZodError.create = (issues) => {
42535
+ const error = new ZodError(issues);
42536
+ return error;
42537
+ };
42538
+
42539
+ // node_modules/zod/v3/locales/en.js
42540
+ var errorMap = (issue, _ctx) => {
42541
+ let message;
42542
+ switch (issue.code) {
42543
+ case ZodIssueCode.invalid_type:
42544
+ if (issue.received === ZodParsedType.undefined) {
42545
+ message = "Required";
42546
+ } else {
42547
+ message = `Expected ${issue.expected}, received ${issue.received}`;
42548
+ }
42549
+ break;
42550
+ case ZodIssueCode.invalid_literal:
42551
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
42552
+ break;
42553
+ case ZodIssueCode.unrecognized_keys:
42554
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
42555
+ break;
42556
+ case ZodIssueCode.invalid_union:
42557
+ message = `Invalid input`;
42558
+ break;
42559
+ case ZodIssueCode.invalid_union_discriminator:
42560
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
42561
+ break;
42562
+ case ZodIssueCode.invalid_enum_value:
42563
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
42564
+ break;
42565
+ case ZodIssueCode.invalid_arguments:
42566
+ message = `Invalid function arguments`;
42567
+ break;
42568
+ case ZodIssueCode.invalid_return_type:
42569
+ message = `Invalid function return type`;
42570
+ break;
42571
+ case ZodIssueCode.invalid_date:
42572
+ message = `Invalid date`;
42573
+ break;
42574
+ case ZodIssueCode.invalid_string:
42575
+ if (typeof issue.validation === "object") {
42576
+ if ("includes" in issue.validation) {
42577
+ message = `Invalid input: must include "${issue.validation.includes}"`;
42578
+ if (typeof issue.validation.position === "number") {
42579
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
42580
+ }
42581
+ } else if ("startsWith" in issue.validation) {
42582
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
42583
+ } else if ("endsWith" in issue.validation) {
42584
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
42585
+ } else {
42586
+ util.assertNever(issue.validation);
42587
+ }
42588
+ } else if (issue.validation !== "regex") {
42589
+ message = `Invalid ${issue.validation}`;
42590
+ } else {
42591
+ message = "Invalid";
42592
+ }
42593
+ break;
42594
+ case ZodIssueCode.too_small:
42595
+ if (issue.type === "array")
42596
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
42597
+ else if (issue.type === "string")
42598
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
42599
+ else if (issue.type === "number")
42600
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
42601
+ else if (issue.type === "bigint")
42602
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
42603
+ else if (issue.type === "date")
42604
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
42605
+ else
42606
+ message = "Invalid input";
42607
+ break;
42608
+ case ZodIssueCode.too_big:
42609
+ if (issue.type === "array")
42610
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
42611
+ else if (issue.type === "string")
42612
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
42613
+ else if (issue.type === "number")
42614
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
42615
+ else if (issue.type === "bigint")
42616
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
42617
+ else if (issue.type === "date")
42618
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
42619
+ else
42620
+ message = "Invalid input";
42621
+ break;
42622
+ case ZodIssueCode.custom:
42623
+ message = `Invalid input`;
42624
+ break;
42625
+ case ZodIssueCode.invalid_intersection_types:
42626
+ message = `Intersection results could not be merged`;
42627
+ break;
42628
+ case ZodIssueCode.not_multiple_of:
42629
+ message = `Number must be a multiple of ${issue.multipleOf}`;
42630
+ break;
42631
+ case ZodIssueCode.not_finite:
42632
+ message = "Number must be finite";
42633
+ break;
42634
+ default:
42635
+ message = _ctx.defaultError;
42636
+ util.assertNever(issue);
42637
+ }
42638
+ return { message };
42639
+ };
42640
+ var en_default = errorMap;
42641
+
42642
+ // node_modules/zod/v3/errors.js
42643
+ var overrideErrorMap = en_default;
42644
+ function setErrorMap(map) {
42645
+ overrideErrorMap = map;
42646
+ }
42647
+ function getErrorMap() {
42648
+ return overrideErrorMap;
42649
+ }
42650
+
42651
+ // node_modules/zod/v3/helpers/parseUtil.js
42652
+ var makeIssue = (params) => {
42653
+ const { data, path: path2, errorMaps, issueData } = params;
42654
+ const fullPath = [...path2, ...issueData.path || []];
42655
+ const fullIssue = {
42656
+ ...issueData,
42657
+ path: fullPath
42658
+ };
42659
+ if (issueData.message !== void 0) {
42660
+ return {
42661
+ ...issueData,
42662
+ path: fullPath,
42663
+ message: issueData.message
42664
+ };
42665
+ }
42666
+ let errorMessage = "";
42667
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
42668
+ for (const map of maps) {
42669
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
42670
+ }
42671
+ return {
42672
+ ...issueData,
42673
+ path: fullPath,
42674
+ message: errorMessage
42675
+ };
42676
+ };
42677
+ var EMPTY_PATH = [];
42678
+ function addIssueToContext(ctx, issueData) {
42679
+ const overrideMap = getErrorMap();
42680
+ const issue = makeIssue({
42681
+ issueData,
42682
+ data: ctx.data,
42683
+ path: ctx.path,
42684
+ errorMaps: [
42685
+ ctx.common.contextualErrorMap,
42686
+ // contextual error map is first priority
42687
+ ctx.schemaErrorMap,
42688
+ // then schema-bound map if available
42689
+ overrideMap,
42690
+ // then global override map
42691
+ overrideMap === en_default ? void 0 : en_default
42692
+ // then global default map
42693
+ ].filter((x) => !!x)
42694
+ });
42695
+ ctx.common.issues.push(issue);
42696
+ }
42697
+ var ParseStatus = class _ParseStatus {
42698
+ constructor() {
42699
+ this.value = "valid";
42700
+ }
42701
+ dirty() {
42702
+ if (this.value === "valid")
42703
+ this.value = "dirty";
42704
+ }
42705
+ abort() {
42706
+ if (this.value !== "aborted")
42707
+ this.value = "aborted";
42708
+ }
42709
+ static mergeArray(status, results) {
42710
+ const arrayValue = [];
42711
+ for (const s3 of results) {
42712
+ if (s3.status === "aborted")
42713
+ return INVALID;
42714
+ if (s3.status === "dirty")
42715
+ status.dirty();
42716
+ arrayValue.push(s3.value);
42717
+ }
42718
+ return { status: status.value, value: arrayValue };
42719
+ }
42720
+ static async mergeObjectAsync(status, pairs) {
42721
+ const syncPairs = [];
42722
+ for (const pair of pairs) {
42723
+ const key = await pair.key;
42724
+ const value = await pair.value;
42725
+ syncPairs.push({
42726
+ key,
42727
+ value
42728
+ });
42729
+ }
42730
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
42731
+ }
42732
+ static mergeObjectSync(status, pairs) {
42733
+ const finalObject = {};
42734
+ for (const pair of pairs) {
42735
+ const { key, value } = pair;
42736
+ if (key.status === "aborted")
42737
+ return INVALID;
42738
+ if (value.status === "aborted")
42739
+ return INVALID;
42740
+ if (key.status === "dirty")
42741
+ status.dirty();
42742
+ if (value.status === "dirty")
42743
+ status.dirty();
42744
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
42745
+ finalObject[key.value] = value.value;
42746
+ }
42747
+ }
42748
+ return { status: status.value, value: finalObject };
42749
+ }
42750
+ };
42751
+ var INVALID = Object.freeze({
42752
+ status: "aborted"
42753
+ });
42754
+ var DIRTY = (value) => ({ status: "dirty", value });
42755
+ var OK = (value) => ({ status: "valid", value });
42756
+ var isAborted = (x) => x.status === "aborted";
42757
+ var isDirty = (x) => x.status === "dirty";
42758
+ var isValid = (x) => x.status === "valid";
42759
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
42760
+
42761
+ // node_modules/zod/v3/helpers/errorUtil.js
42762
+ var errorUtil;
42763
+ (function(errorUtil2) {
42764
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
42765
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
42766
+ })(errorUtil || (errorUtil = {}));
42767
+
42768
+ // node_modules/zod/v3/types.js
42769
+ var ParseInputLazyPath = class {
42770
+ constructor(parent, value, path2, key) {
42771
+ this._cachedPath = [];
42772
+ this.parent = parent;
42773
+ this.data = value;
42774
+ this._path = path2;
42775
+ this._key = key;
42776
+ }
42777
+ get path() {
42778
+ if (!this._cachedPath.length) {
42779
+ if (Array.isArray(this._key)) {
42780
+ this._cachedPath.push(...this._path, ...this._key);
42781
+ } else {
42782
+ this._cachedPath.push(...this._path, this._key);
42783
+ }
42784
+ }
42785
+ return this._cachedPath;
42786
+ }
42787
+ };
42788
+ var handleResult = (ctx, result) => {
42789
+ if (isValid(result)) {
42790
+ return { success: true, data: result.value };
42791
+ } else {
42792
+ if (!ctx.common.issues.length) {
42793
+ throw new Error("Validation failed but no issues detected.");
42794
+ }
42795
+ return {
42796
+ success: false,
42797
+ get error() {
42798
+ if (this._error)
42799
+ return this._error;
42800
+ const error = new ZodError(ctx.common.issues);
42801
+ this._error = error;
42802
+ return this._error;
42803
+ }
42804
+ };
42805
+ }
42806
+ };
42807
+ function processCreateParams(params) {
42808
+ if (!params)
42809
+ return {};
42810
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
42811
+ if (errorMap2 && (invalid_type_error || required_error)) {
42812
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
42813
+ }
42814
+ if (errorMap2)
42815
+ return { errorMap: errorMap2, description };
42816
+ const customMap = (iss, ctx) => {
42817
+ const { message } = params;
42818
+ if (iss.code === "invalid_enum_value") {
42819
+ return { message: message ?? ctx.defaultError };
42820
+ }
42821
+ if (typeof ctx.data === "undefined") {
42822
+ return { message: message ?? required_error ?? ctx.defaultError };
42823
+ }
42824
+ if (iss.code !== "invalid_type")
42825
+ return { message: ctx.defaultError };
42826
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
42827
+ };
42828
+ return { errorMap: customMap, description };
42829
+ }
42830
+ var ZodType = class {
42831
+ get description() {
42832
+ return this._def.description;
42833
+ }
42834
+ _getType(input) {
42835
+ return getParsedType(input.data);
42836
+ }
42837
+ _getOrReturnCtx(input, ctx) {
42838
+ return ctx || {
42839
+ common: input.parent.common,
42840
+ data: input.data,
42841
+ parsedType: getParsedType(input.data),
42842
+ schemaErrorMap: this._def.errorMap,
42843
+ path: input.path,
42844
+ parent: input.parent
42845
+ };
42846
+ }
42847
+ _processInputParams(input) {
42848
+ return {
42849
+ status: new ParseStatus(),
42850
+ ctx: {
42851
+ common: input.parent.common,
42852
+ data: input.data,
42853
+ parsedType: getParsedType(input.data),
42854
+ schemaErrorMap: this._def.errorMap,
42855
+ path: input.path,
42856
+ parent: input.parent
42857
+ }
42858
+ };
42859
+ }
42860
+ _parseSync(input) {
42861
+ const result = this._parse(input);
42862
+ if (isAsync(result)) {
42863
+ throw new Error("Synchronous parse encountered promise.");
42864
+ }
42865
+ return result;
42866
+ }
42867
+ _parseAsync(input) {
42868
+ const result = this._parse(input);
42869
+ return Promise.resolve(result);
42870
+ }
42871
+ parse(data, params) {
42872
+ const result = this.safeParse(data, params);
42873
+ if (result.success)
42874
+ return result.data;
42875
+ throw result.error;
42876
+ }
42877
+ safeParse(data, params) {
42878
+ const ctx = {
42879
+ common: {
42880
+ issues: [],
42881
+ async: params?.async ?? false,
42882
+ contextualErrorMap: params?.errorMap
42883
+ },
42884
+ path: params?.path || [],
42885
+ schemaErrorMap: this._def.errorMap,
42886
+ parent: null,
42887
+ data,
42888
+ parsedType: getParsedType(data)
42889
+ };
42890
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
42891
+ return handleResult(ctx, result);
42892
+ }
42893
+ "~validate"(data) {
42894
+ const ctx = {
42895
+ common: {
42896
+ issues: [],
42897
+ async: !!this["~standard"].async
42898
+ },
42899
+ path: [],
42900
+ schemaErrorMap: this._def.errorMap,
42901
+ parent: null,
42902
+ data,
42903
+ parsedType: getParsedType(data)
42904
+ };
42905
+ if (!this["~standard"].async) {
42906
+ try {
42907
+ const result = this._parseSync({ data, path: [], parent: ctx });
42908
+ return isValid(result) ? {
42909
+ value: result.value
42910
+ } : {
42911
+ issues: ctx.common.issues
42912
+ };
42913
+ } catch (err) {
42914
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
42915
+ this["~standard"].async = true;
42916
+ }
42917
+ ctx.common = {
42918
+ issues: [],
42919
+ async: true
42920
+ };
42921
+ }
42922
+ }
42923
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
42924
+ value: result.value
42925
+ } : {
42926
+ issues: ctx.common.issues
42927
+ });
42928
+ }
42929
+ async parseAsync(data, params) {
42930
+ const result = await this.safeParseAsync(data, params);
42931
+ if (result.success)
42932
+ return result.data;
42933
+ throw result.error;
42934
+ }
42935
+ async safeParseAsync(data, params) {
42936
+ const ctx = {
42937
+ common: {
42938
+ issues: [],
42939
+ contextualErrorMap: params?.errorMap,
42940
+ async: true
42941
+ },
42942
+ path: params?.path || [],
42943
+ schemaErrorMap: this._def.errorMap,
42944
+ parent: null,
42945
+ data,
42946
+ parsedType: getParsedType(data)
42947
+ };
42948
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
42949
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
42950
+ return handleResult(ctx, result);
42951
+ }
42952
+ refine(check, message) {
42953
+ const getIssueProperties = (val) => {
42954
+ if (typeof message === "string" || typeof message === "undefined") {
42955
+ return { message };
42956
+ } else if (typeof message === "function") {
42957
+ return message(val);
42958
+ } else {
42959
+ return message;
42960
+ }
42961
+ };
42962
+ return this._refinement((val, ctx) => {
42963
+ const result = check(val);
42964
+ const setError = () => ctx.addIssue({
42965
+ code: ZodIssueCode.custom,
42966
+ ...getIssueProperties(val)
42967
+ });
42968
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
42969
+ return result.then((data) => {
42970
+ if (!data) {
42971
+ setError();
42972
+ return false;
42973
+ } else {
42974
+ return true;
42975
+ }
42976
+ });
42977
+ }
42978
+ if (!result) {
42979
+ setError();
42980
+ return false;
42981
+ } else {
42982
+ return true;
42983
+ }
42984
+ });
42985
+ }
42986
+ refinement(check, refinementData) {
42987
+ return this._refinement((val, ctx) => {
42988
+ if (!check(val)) {
42989
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
42990
+ return false;
42991
+ } else {
42992
+ return true;
42993
+ }
42994
+ });
42995
+ }
42996
+ _refinement(refinement) {
42997
+ return new ZodEffects({
42998
+ schema: this,
42999
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
43000
+ effect: { type: "refinement", refinement }
43001
+ });
43002
+ }
43003
+ superRefine(refinement) {
43004
+ return this._refinement(refinement);
43005
+ }
43006
+ constructor(def) {
43007
+ this.spa = this.safeParseAsync;
43008
+ this._def = def;
43009
+ this.parse = this.parse.bind(this);
43010
+ this.safeParse = this.safeParse.bind(this);
43011
+ this.parseAsync = this.parseAsync.bind(this);
43012
+ this.safeParseAsync = this.safeParseAsync.bind(this);
43013
+ this.spa = this.spa.bind(this);
43014
+ this.refine = this.refine.bind(this);
43015
+ this.refinement = this.refinement.bind(this);
43016
+ this.superRefine = this.superRefine.bind(this);
43017
+ this.optional = this.optional.bind(this);
43018
+ this.nullable = this.nullable.bind(this);
43019
+ this.nullish = this.nullish.bind(this);
43020
+ this.array = this.array.bind(this);
43021
+ this.promise = this.promise.bind(this);
43022
+ this.or = this.or.bind(this);
43023
+ this.and = this.and.bind(this);
43024
+ this.transform = this.transform.bind(this);
43025
+ this.brand = this.brand.bind(this);
43026
+ this.default = this.default.bind(this);
43027
+ this.catch = this.catch.bind(this);
43028
+ this.describe = this.describe.bind(this);
43029
+ this.pipe = this.pipe.bind(this);
43030
+ this.readonly = this.readonly.bind(this);
43031
+ this.isNullable = this.isNullable.bind(this);
43032
+ this.isOptional = this.isOptional.bind(this);
43033
+ this["~standard"] = {
43034
+ version: 1,
43035
+ vendor: "zod",
43036
+ validate: (data) => this["~validate"](data)
43037
+ };
43038
+ }
43039
+ optional() {
43040
+ return ZodOptional.create(this, this._def);
43041
+ }
43042
+ nullable() {
43043
+ return ZodNullable.create(this, this._def);
43044
+ }
43045
+ nullish() {
43046
+ return this.nullable().optional();
43047
+ }
43048
+ array() {
43049
+ return ZodArray.create(this);
43050
+ }
43051
+ promise() {
43052
+ return ZodPromise.create(this, this._def);
43053
+ }
43054
+ or(option) {
43055
+ return ZodUnion.create([this, option], this._def);
43056
+ }
43057
+ and(incoming) {
43058
+ return ZodIntersection.create(this, incoming, this._def);
43059
+ }
43060
+ transform(transform) {
43061
+ return new ZodEffects({
43062
+ ...processCreateParams(this._def),
43063
+ schema: this,
43064
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
43065
+ effect: { type: "transform", transform }
43066
+ });
43067
+ }
43068
+ default(def) {
43069
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
43070
+ return new ZodDefault({
43071
+ ...processCreateParams(this._def),
43072
+ innerType: this,
43073
+ defaultValue: defaultValueFunc,
43074
+ typeName: ZodFirstPartyTypeKind.ZodDefault
43075
+ });
43076
+ }
43077
+ brand() {
43078
+ return new ZodBranded({
43079
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
43080
+ type: this,
43081
+ ...processCreateParams(this._def)
43082
+ });
43083
+ }
43084
+ catch(def) {
43085
+ const catchValueFunc = typeof def === "function" ? def : () => def;
43086
+ return new ZodCatch({
43087
+ ...processCreateParams(this._def),
43088
+ innerType: this,
43089
+ catchValue: catchValueFunc,
43090
+ typeName: ZodFirstPartyTypeKind.ZodCatch
43091
+ });
43092
+ }
43093
+ describe(description) {
43094
+ const This = this.constructor;
43095
+ return new This({
43096
+ ...this._def,
43097
+ description
43098
+ });
43099
+ }
43100
+ pipe(target) {
43101
+ return ZodPipeline.create(this, target);
43102
+ }
43103
+ readonly() {
43104
+ return ZodReadonly.create(this);
43105
+ }
43106
+ isOptional() {
43107
+ return this.safeParse(void 0).success;
43108
+ }
43109
+ isNullable() {
43110
+ return this.safeParse(null).success;
43111
+ }
43112
+ };
43113
+ var cuidRegex = /^c[^\s-]{8,}$/i;
43114
+ var cuid2Regex = /^[0-9a-z]+$/;
43115
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
43116
+ 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;
43117
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
43118
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
43119
+ 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)?)??$/;
43120
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
43121
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
43122
+ var emojiRegex;
43123
+ 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])$/;
43124
+ 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])$/;
43125
+ 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]))$/;
43126
+ 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])$/;
43127
+ var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
43128
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
43129
+ 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])))`;
43130
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
43131
+ function timeRegexSource(args) {
43132
+ let secondsRegexSource = `[0-5]\\d`;
43133
+ if (args.precision) {
43134
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
43135
+ } else if (args.precision == null) {
43136
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
43137
+ }
43138
+ const secondsQuantifier = args.precision ? "+" : "?";
43139
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
43140
+ }
43141
+ function timeRegex(args) {
43142
+ return new RegExp(`^${timeRegexSource(args)}$`);
43143
+ }
43144
+ function datetimeRegex(args) {
43145
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
43146
+ const opts = [];
43147
+ opts.push(args.local ? `Z?` : `Z`);
43148
+ if (args.offset)
43149
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
43150
+ regex = `${regex}(${opts.join("|")})`;
43151
+ return new RegExp(`^${regex}$`);
43152
+ }
43153
+ function isValidIP(ip, version4) {
43154
+ if ((version4 === "v4" || !version4) && ipv4Regex.test(ip)) {
43155
+ return true;
43156
+ }
43157
+ if ((version4 === "v6" || !version4) && ipv6Regex.test(ip)) {
43158
+ return true;
43159
+ }
43160
+ return false;
43161
+ }
43162
+ function isValidJWT(jwt, alg) {
43163
+ if (!jwtRegex.test(jwt))
43164
+ return false;
43165
+ try {
43166
+ const [header] = jwt.split(".");
43167
+ if (!header)
43168
+ return false;
43169
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
43170
+ const decoded = JSON.parse(atob(base64));
43171
+ if (typeof decoded !== "object" || decoded === null)
43172
+ return false;
43173
+ if ("typ" in decoded && decoded?.typ !== "JWT")
43174
+ return false;
43175
+ if (!decoded.alg)
43176
+ return false;
43177
+ if (alg && decoded.alg !== alg)
43178
+ return false;
43179
+ return true;
43180
+ } catch {
43181
+ return false;
43182
+ }
43183
+ }
43184
+ function isValidCidr(ip, version4) {
43185
+ if ((version4 === "v4" || !version4) && ipv4CidrRegex.test(ip)) {
43186
+ return true;
43187
+ }
43188
+ if ((version4 === "v6" || !version4) && ipv6CidrRegex.test(ip)) {
43189
+ return true;
43190
+ }
43191
+ return false;
43192
+ }
43193
+ var ZodString = class _ZodString extends ZodType {
43194
+ _parse(input) {
43195
+ if (this._def.coerce) {
43196
+ input.data = String(input.data);
43197
+ }
43198
+ const parsedType = this._getType(input);
43199
+ if (parsedType !== ZodParsedType.string) {
43200
+ const ctx2 = this._getOrReturnCtx(input);
43201
+ addIssueToContext(ctx2, {
43202
+ code: ZodIssueCode.invalid_type,
43203
+ expected: ZodParsedType.string,
43204
+ received: ctx2.parsedType
43205
+ });
43206
+ return INVALID;
43207
+ }
43208
+ const status = new ParseStatus();
43209
+ let ctx = void 0;
43210
+ for (const check of this._def.checks) {
43211
+ if (check.kind === "min") {
43212
+ if (input.data.length < check.value) {
43213
+ ctx = this._getOrReturnCtx(input, ctx);
43214
+ addIssueToContext(ctx, {
43215
+ code: ZodIssueCode.too_small,
43216
+ minimum: check.value,
43217
+ type: "string",
43218
+ inclusive: true,
43219
+ exact: false,
43220
+ message: check.message
43221
+ });
43222
+ status.dirty();
43223
+ }
43224
+ } else if (check.kind === "max") {
43225
+ if (input.data.length > check.value) {
43226
+ ctx = this._getOrReturnCtx(input, ctx);
43227
+ addIssueToContext(ctx, {
43228
+ code: ZodIssueCode.too_big,
43229
+ maximum: check.value,
43230
+ type: "string",
43231
+ inclusive: true,
43232
+ exact: false,
43233
+ message: check.message
43234
+ });
43235
+ status.dirty();
43236
+ }
43237
+ } else if (check.kind === "length") {
43238
+ const tooBig = input.data.length > check.value;
43239
+ const tooSmall = input.data.length < check.value;
43240
+ if (tooBig || tooSmall) {
43241
+ ctx = this._getOrReturnCtx(input, ctx);
43242
+ if (tooBig) {
43243
+ addIssueToContext(ctx, {
43244
+ code: ZodIssueCode.too_big,
43245
+ maximum: check.value,
43246
+ type: "string",
43247
+ inclusive: true,
43248
+ exact: true,
43249
+ message: check.message
43250
+ });
43251
+ } else if (tooSmall) {
43252
+ addIssueToContext(ctx, {
43253
+ code: ZodIssueCode.too_small,
43254
+ minimum: check.value,
43255
+ type: "string",
43256
+ inclusive: true,
43257
+ exact: true,
43258
+ message: check.message
43259
+ });
43260
+ }
43261
+ status.dirty();
43262
+ }
43263
+ } else if (check.kind === "email") {
43264
+ if (!emailRegex.test(input.data)) {
43265
+ ctx = this._getOrReturnCtx(input, ctx);
43266
+ addIssueToContext(ctx, {
43267
+ validation: "email",
43268
+ code: ZodIssueCode.invalid_string,
43269
+ message: check.message
43270
+ });
43271
+ status.dirty();
43272
+ }
43273
+ } else if (check.kind === "emoji") {
43274
+ if (!emojiRegex) {
43275
+ emojiRegex = new RegExp(_emojiRegex, "u");
43276
+ }
43277
+ if (!emojiRegex.test(input.data)) {
43278
+ ctx = this._getOrReturnCtx(input, ctx);
43279
+ addIssueToContext(ctx, {
43280
+ validation: "emoji",
43281
+ code: ZodIssueCode.invalid_string,
43282
+ message: check.message
43283
+ });
43284
+ status.dirty();
43285
+ }
43286
+ } else if (check.kind === "uuid") {
43287
+ if (!uuidRegex.test(input.data)) {
43288
+ ctx = this._getOrReturnCtx(input, ctx);
43289
+ addIssueToContext(ctx, {
43290
+ validation: "uuid",
43291
+ code: ZodIssueCode.invalid_string,
43292
+ message: check.message
43293
+ });
43294
+ status.dirty();
43295
+ }
43296
+ } else if (check.kind === "nanoid") {
43297
+ if (!nanoidRegex.test(input.data)) {
43298
+ ctx = this._getOrReturnCtx(input, ctx);
43299
+ addIssueToContext(ctx, {
43300
+ validation: "nanoid",
43301
+ code: ZodIssueCode.invalid_string,
43302
+ message: check.message
43303
+ });
43304
+ status.dirty();
43305
+ }
43306
+ } else if (check.kind === "cuid") {
43307
+ if (!cuidRegex.test(input.data)) {
43308
+ ctx = this._getOrReturnCtx(input, ctx);
43309
+ addIssueToContext(ctx, {
43310
+ validation: "cuid",
43311
+ code: ZodIssueCode.invalid_string,
43312
+ message: check.message
43313
+ });
43314
+ status.dirty();
43315
+ }
43316
+ } else if (check.kind === "cuid2") {
43317
+ if (!cuid2Regex.test(input.data)) {
43318
+ ctx = this._getOrReturnCtx(input, ctx);
43319
+ addIssueToContext(ctx, {
43320
+ validation: "cuid2",
43321
+ code: ZodIssueCode.invalid_string,
43322
+ message: check.message
43323
+ });
43324
+ status.dirty();
43325
+ }
43326
+ } else if (check.kind === "ulid") {
43327
+ if (!ulidRegex.test(input.data)) {
43328
+ ctx = this._getOrReturnCtx(input, ctx);
43329
+ addIssueToContext(ctx, {
43330
+ validation: "ulid",
43331
+ code: ZodIssueCode.invalid_string,
43332
+ message: check.message
43333
+ });
43334
+ status.dirty();
43335
+ }
43336
+ } else if (check.kind === "url") {
43337
+ try {
43338
+ new URL(input.data);
43339
+ } catch {
43340
+ ctx = this._getOrReturnCtx(input, ctx);
43341
+ addIssueToContext(ctx, {
43342
+ validation: "url",
43343
+ code: ZodIssueCode.invalid_string,
43344
+ message: check.message
43345
+ });
43346
+ status.dirty();
43347
+ }
43348
+ } else if (check.kind === "regex") {
43349
+ check.regex.lastIndex = 0;
43350
+ const testResult = check.regex.test(input.data);
43351
+ if (!testResult) {
43352
+ ctx = this._getOrReturnCtx(input, ctx);
43353
+ addIssueToContext(ctx, {
43354
+ validation: "regex",
43355
+ code: ZodIssueCode.invalid_string,
43356
+ message: check.message
43357
+ });
43358
+ status.dirty();
43359
+ }
43360
+ } else if (check.kind === "trim") {
43361
+ input.data = input.data.trim();
43362
+ } else if (check.kind === "includes") {
43363
+ if (!input.data.includes(check.value, check.position)) {
43364
+ ctx = this._getOrReturnCtx(input, ctx);
43365
+ addIssueToContext(ctx, {
43366
+ code: ZodIssueCode.invalid_string,
43367
+ validation: { includes: check.value, position: check.position },
43368
+ message: check.message
43369
+ });
43370
+ status.dirty();
43371
+ }
43372
+ } else if (check.kind === "toLowerCase") {
43373
+ input.data = input.data.toLowerCase();
43374
+ } else if (check.kind === "toUpperCase") {
43375
+ input.data = input.data.toUpperCase();
43376
+ } else if (check.kind === "startsWith") {
43377
+ if (!input.data.startsWith(check.value)) {
43378
+ ctx = this._getOrReturnCtx(input, ctx);
43379
+ addIssueToContext(ctx, {
43380
+ code: ZodIssueCode.invalid_string,
43381
+ validation: { startsWith: check.value },
43382
+ message: check.message
43383
+ });
43384
+ status.dirty();
43385
+ }
43386
+ } else if (check.kind === "endsWith") {
43387
+ if (!input.data.endsWith(check.value)) {
43388
+ ctx = this._getOrReturnCtx(input, ctx);
43389
+ addIssueToContext(ctx, {
43390
+ code: ZodIssueCode.invalid_string,
43391
+ validation: { endsWith: check.value },
43392
+ message: check.message
43393
+ });
43394
+ status.dirty();
43395
+ }
43396
+ } else if (check.kind === "datetime") {
43397
+ const regex = datetimeRegex(check);
43398
+ if (!regex.test(input.data)) {
43399
+ ctx = this._getOrReturnCtx(input, ctx);
43400
+ addIssueToContext(ctx, {
43401
+ code: ZodIssueCode.invalid_string,
43402
+ validation: "datetime",
43403
+ message: check.message
43404
+ });
43405
+ status.dirty();
43406
+ }
43407
+ } else if (check.kind === "date") {
43408
+ const regex = dateRegex;
43409
+ if (!regex.test(input.data)) {
43410
+ ctx = this._getOrReturnCtx(input, ctx);
43411
+ addIssueToContext(ctx, {
43412
+ code: ZodIssueCode.invalid_string,
43413
+ validation: "date",
43414
+ message: check.message
43415
+ });
43416
+ status.dirty();
43417
+ }
43418
+ } else if (check.kind === "time") {
43419
+ const regex = timeRegex(check);
43420
+ if (!regex.test(input.data)) {
43421
+ ctx = this._getOrReturnCtx(input, ctx);
43422
+ addIssueToContext(ctx, {
43423
+ code: ZodIssueCode.invalid_string,
43424
+ validation: "time",
43425
+ message: check.message
43426
+ });
43427
+ status.dirty();
43428
+ }
43429
+ } else if (check.kind === "duration") {
43430
+ if (!durationRegex.test(input.data)) {
43431
+ ctx = this._getOrReturnCtx(input, ctx);
43432
+ addIssueToContext(ctx, {
43433
+ validation: "duration",
43434
+ code: ZodIssueCode.invalid_string,
43435
+ message: check.message
43436
+ });
43437
+ status.dirty();
43438
+ }
43439
+ } else if (check.kind === "ip") {
43440
+ if (!isValidIP(input.data, check.version)) {
43441
+ ctx = this._getOrReturnCtx(input, ctx);
43442
+ addIssueToContext(ctx, {
43443
+ validation: "ip",
43444
+ code: ZodIssueCode.invalid_string,
43445
+ message: check.message
43446
+ });
43447
+ status.dirty();
43448
+ }
43449
+ } else if (check.kind === "jwt") {
43450
+ if (!isValidJWT(input.data, check.alg)) {
43451
+ ctx = this._getOrReturnCtx(input, ctx);
43452
+ addIssueToContext(ctx, {
43453
+ validation: "jwt",
43454
+ code: ZodIssueCode.invalid_string,
43455
+ message: check.message
43456
+ });
43457
+ status.dirty();
43458
+ }
43459
+ } else if (check.kind === "cidr") {
43460
+ if (!isValidCidr(input.data, check.version)) {
43461
+ ctx = this._getOrReturnCtx(input, ctx);
43462
+ addIssueToContext(ctx, {
43463
+ validation: "cidr",
43464
+ code: ZodIssueCode.invalid_string,
43465
+ message: check.message
43466
+ });
43467
+ status.dirty();
43468
+ }
43469
+ } else if (check.kind === "base64") {
43470
+ if (!base64Regex2.test(input.data)) {
43471
+ ctx = this._getOrReturnCtx(input, ctx);
43472
+ addIssueToContext(ctx, {
43473
+ validation: "base64",
43474
+ code: ZodIssueCode.invalid_string,
43475
+ message: check.message
43476
+ });
43477
+ status.dirty();
43478
+ }
43479
+ } else if (check.kind === "base64url") {
43480
+ if (!base64urlRegex.test(input.data)) {
43481
+ ctx = this._getOrReturnCtx(input, ctx);
43482
+ addIssueToContext(ctx, {
43483
+ validation: "base64url",
43484
+ code: ZodIssueCode.invalid_string,
43485
+ message: check.message
43486
+ });
43487
+ status.dirty();
43488
+ }
43489
+ } else {
43490
+ util.assertNever(check);
43491
+ }
43492
+ }
43493
+ return { status: status.value, value: input.data };
43494
+ }
43495
+ _regex(regex, validation, message) {
43496
+ return this.refinement((data) => regex.test(data), {
43497
+ validation,
43498
+ code: ZodIssueCode.invalid_string,
43499
+ ...errorUtil.errToObj(message)
43500
+ });
43501
+ }
43502
+ _addCheck(check) {
43503
+ return new _ZodString({
43504
+ ...this._def,
43505
+ checks: [...this._def.checks, check]
43506
+ });
43507
+ }
43508
+ email(message) {
43509
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
43510
+ }
43511
+ url(message) {
43512
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
43513
+ }
43514
+ emoji(message) {
43515
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
43516
+ }
43517
+ uuid(message) {
43518
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
43519
+ }
43520
+ nanoid(message) {
43521
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
43522
+ }
43523
+ cuid(message) {
43524
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
43525
+ }
43526
+ cuid2(message) {
43527
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
43528
+ }
43529
+ ulid(message) {
43530
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
43531
+ }
43532
+ base64(message) {
43533
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
43534
+ }
43535
+ base64url(message) {
43536
+ return this._addCheck({
43537
+ kind: "base64url",
43538
+ ...errorUtil.errToObj(message)
43539
+ });
43540
+ }
43541
+ jwt(options) {
43542
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
43543
+ }
43544
+ ip(options) {
43545
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
43546
+ }
43547
+ cidr(options) {
43548
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
43549
+ }
43550
+ datetime(options) {
43551
+ if (typeof options === "string") {
43552
+ return this._addCheck({
43553
+ kind: "datetime",
43554
+ precision: null,
43555
+ offset: false,
43556
+ local: false,
43557
+ message: options
43558
+ });
43559
+ }
43560
+ return this._addCheck({
43561
+ kind: "datetime",
43562
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
43563
+ offset: options?.offset ?? false,
43564
+ local: options?.local ?? false,
43565
+ ...errorUtil.errToObj(options?.message)
43566
+ });
43567
+ }
43568
+ date(message) {
43569
+ return this._addCheck({ kind: "date", message });
43570
+ }
43571
+ time(options) {
43572
+ if (typeof options === "string") {
43573
+ return this._addCheck({
43574
+ kind: "time",
43575
+ precision: null,
43576
+ message: options
43577
+ });
43578
+ }
43579
+ return this._addCheck({
43580
+ kind: "time",
43581
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
43582
+ ...errorUtil.errToObj(options?.message)
43583
+ });
43584
+ }
43585
+ duration(message) {
43586
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
43587
+ }
43588
+ regex(regex, message) {
43589
+ return this._addCheck({
43590
+ kind: "regex",
43591
+ regex,
43592
+ ...errorUtil.errToObj(message)
43593
+ });
43594
+ }
43595
+ includes(value, options) {
43596
+ return this._addCheck({
43597
+ kind: "includes",
43598
+ value,
43599
+ position: options?.position,
43600
+ ...errorUtil.errToObj(options?.message)
43601
+ });
43602
+ }
43603
+ startsWith(value, message) {
43604
+ return this._addCheck({
43605
+ kind: "startsWith",
43606
+ value,
43607
+ ...errorUtil.errToObj(message)
43608
+ });
43609
+ }
43610
+ endsWith(value, message) {
43611
+ return this._addCheck({
43612
+ kind: "endsWith",
43613
+ value,
43614
+ ...errorUtil.errToObj(message)
43615
+ });
43616
+ }
43617
+ min(minLength, message) {
43618
+ return this._addCheck({
43619
+ kind: "min",
43620
+ value: minLength,
43621
+ ...errorUtil.errToObj(message)
43622
+ });
43623
+ }
43624
+ max(maxLength, message) {
43625
+ return this._addCheck({
43626
+ kind: "max",
43627
+ value: maxLength,
43628
+ ...errorUtil.errToObj(message)
43629
+ });
43630
+ }
43631
+ length(len, message) {
43632
+ return this._addCheck({
43633
+ kind: "length",
43634
+ value: len,
43635
+ ...errorUtil.errToObj(message)
43636
+ });
43637
+ }
43638
+ /**
43639
+ * Equivalent to `.min(1)`
43640
+ */
43641
+ nonempty(message) {
43642
+ return this.min(1, errorUtil.errToObj(message));
43643
+ }
43644
+ trim() {
43645
+ return new _ZodString({
43646
+ ...this._def,
43647
+ checks: [...this._def.checks, { kind: "trim" }]
43648
+ });
43649
+ }
43650
+ toLowerCase() {
43651
+ return new _ZodString({
43652
+ ...this._def,
43653
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
43654
+ });
43655
+ }
43656
+ toUpperCase() {
43657
+ return new _ZodString({
43658
+ ...this._def,
43659
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
43660
+ });
43661
+ }
43662
+ get isDatetime() {
43663
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
43664
+ }
43665
+ get isDate() {
43666
+ return !!this._def.checks.find((ch) => ch.kind === "date");
43667
+ }
43668
+ get isTime() {
43669
+ return !!this._def.checks.find((ch) => ch.kind === "time");
43670
+ }
43671
+ get isDuration() {
43672
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
43673
+ }
43674
+ get isEmail() {
43675
+ return !!this._def.checks.find((ch) => ch.kind === "email");
43676
+ }
43677
+ get isURL() {
43678
+ return !!this._def.checks.find((ch) => ch.kind === "url");
43679
+ }
43680
+ get isEmoji() {
43681
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
43682
+ }
43683
+ get isUUID() {
43684
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
43685
+ }
43686
+ get isNANOID() {
43687
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
43688
+ }
43689
+ get isCUID() {
43690
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
43691
+ }
43692
+ get isCUID2() {
43693
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
43694
+ }
43695
+ get isULID() {
43696
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
43697
+ }
43698
+ get isIP() {
43699
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
43700
+ }
43701
+ get isCIDR() {
43702
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
43703
+ }
43704
+ get isBase64() {
43705
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
43706
+ }
43707
+ get isBase64url() {
43708
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
43709
+ }
43710
+ get minLength() {
43711
+ let min = null;
43712
+ for (const ch of this._def.checks) {
43713
+ if (ch.kind === "min") {
43714
+ if (min === null || ch.value > min)
43715
+ min = ch.value;
43716
+ }
43717
+ }
43718
+ return min;
43719
+ }
43720
+ get maxLength() {
43721
+ let max = null;
43722
+ for (const ch of this._def.checks) {
43723
+ if (ch.kind === "max") {
43724
+ if (max === null || ch.value < max)
43725
+ max = ch.value;
43726
+ }
43727
+ }
43728
+ return max;
43729
+ }
43730
+ };
43731
+ ZodString.create = (params) => {
43732
+ return new ZodString({
43733
+ checks: [],
43734
+ typeName: ZodFirstPartyTypeKind.ZodString,
43735
+ coerce: params?.coerce ?? false,
43736
+ ...processCreateParams(params)
43737
+ });
43738
+ };
43739
+ function floatSafeRemainder(val, step) {
43740
+ const valDecCount = (val.toString().split(".")[1] || "").length;
43741
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
43742
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
43743
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
43744
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
43745
+ return valInt % stepInt / 10 ** decCount;
43746
+ }
43747
+ var ZodNumber = class _ZodNumber extends ZodType {
43748
+ constructor() {
43749
+ super(...arguments);
43750
+ this.min = this.gte;
43751
+ this.max = this.lte;
43752
+ this.step = this.multipleOf;
43753
+ }
43754
+ _parse(input) {
43755
+ if (this._def.coerce) {
43756
+ input.data = Number(input.data);
43757
+ }
43758
+ const parsedType = this._getType(input);
43759
+ if (parsedType !== ZodParsedType.number) {
43760
+ const ctx2 = this._getOrReturnCtx(input);
43761
+ addIssueToContext(ctx2, {
43762
+ code: ZodIssueCode.invalid_type,
43763
+ expected: ZodParsedType.number,
43764
+ received: ctx2.parsedType
43765
+ });
43766
+ return INVALID;
43767
+ }
43768
+ let ctx = void 0;
43769
+ const status = new ParseStatus();
43770
+ for (const check of this._def.checks) {
43771
+ if (check.kind === "int") {
43772
+ if (!util.isInteger(input.data)) {
43773
+ ctx = this._getOrReturnCtx(input, ctx);
43774
+ addIssueToContext(ctx, {
43775
+ code: ZodIssueCode.invalid_type,
43776
+ expected: "integer",
43777
+ received: "float",
43778
+ message: check.message
43779
+ });
43780
+ status.dirty();
43781
+ }
43782
+ } else if (check.kind === "min") {
43783
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
43784
+ if (tooSmall) {
43785
+ ctx = this._getOrReturnCtx(input, ctx);
43786
+ addIssueToContext(ctx, {
43787
+ code: ZodIssueCode.too_small,
43788
+ minimum: check.value,
43789
+ type: "number",
43790
+ inclusive: check.inclusive,
43791
+ exact: false,
43792
+ message: check.message
43793
+ });
43794
+ status.dirty();
43795
+ }
43796
+ } else if (check.kind === "max") {
43797
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
43798
+ if (tooBig) {
43799
+ ctx = this._getOrReturnCtx(input, ctx);
43800
+ addIssueToContext(ctx, {
43801
+ code: ZodIssueCode.too_big,
43802
+ maximum: check.value,
43803
+ type: "number",
43804
+ inclusive: check.inclusive,
43805
+ exact: false,
43806
+ message: check.message
43807
+ });
43808
+ status.dirty();
43809
+ }
43810
+ } else if (check.kind === "multipleOf") {
43811
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
43812
+ ctx = this._getOrReturnCtx(input, ctx);
43813
+ addIssueToContext(ctx, {
43814
+ code: ZodIssueCode.not_multiple_of,
43815
+ multipleOf: check.value,
43816
+ message: check.message
43817
+ });
43818
+ status.dirty();
43819
+ }
43820
+ } else if (check.kind === "finite") {
43821
+ if (!Number.isFinite(input.data)) {
43822
+ ctx = this._getOrReturnCtx(input, ctx);
43823
+ addIssueToContext(ctx, {
43824
+ code: ZodIssueCode.not_finite,
43825
+ message: check.message
43826
+ });
43827
+ status.dirty();
43828
+ }
43829
+ } else {
43830
+ util.assertNever(check);
43831
+ }
43832
+ }
43833
+ return { status: status.value, value: input.data };
43834
+ }
43835
+ gte(value, message) {
43836
+ return this.setLimit("min", value, true, errorUtil.toString(message));
43837
+ }
43838
+ gt(value, message) {
43839
+ return this.setLimit("min", value, false, errorUtil.toString(message));
43840
+ }
43841
+ lte(value, message) {
43842
+ return this.setLimit("max", value, true, errorUtil.toString(message));
43843
+ }
43844
+ lt(value, message) {
43845
+ return this.setLimit("max", value, false, errorUtil.toString(message));
43846
+ }
43847
+ setLimit(kind, value, inclusive, message) {
43848
+ return new _ZodNumber({
43849
+ ...this._def,
43850
+ checks: [
43851
+ ...this._def.checks,
43852
+ {
43853
+ kind,
43854
+ value,
43855
+ inclusive,
43856
+ message: errorUtil.toString(message)
43857
+ }
43858
+ ]
43859
+ });
43860
+ }
43861
+ _addCheck(check) {
43862
+ return new _ZodNumber({
43863
+ ...this._def,
43864
+ checks: [...this._def.checks, check]
43865
+ });
43866
+ }
43867
+ int(message) {
43868
+ return this._addCheck({
43869
+ kind: "int",
43870
+ message: errorUtil.toString(message)
43871
+ });
43872
+ }
43873
+ positive(message) {
43874
+ return this._addCheck({
43875
+ kind: "min",
43876
+ value: 0,
43877
+ inclusive: false,
43878
+ message: errorUtil.toString(message)
43879
+ });
43880
+ }
43881
+ negative(message) {
43882
+ return this._addCheck({
43883
+ kind: "max",
43884
+ value: 0,
43885
+ inclusive: false,
43886
+ message: errorUtil.toString(message)
43887
+ });
43888
+ }
43889
+ nonpositive(message) {
43890
+ return this._addCheck({
43891
+ kind: "max",
43892
+ value: 0,
43893
+ inclusive: true,
43894
+ message: errorUtil.toString(message)
43895
+ });
43896
+ }
43897
+ nonnegative(message) {
43898
+ return this._addCheck({
43899
+ kind: "min",
43900
+ value: 0,
43901
+ inclusive: true,
43902
+ message: errorUtil.toString(message)
43903
+ });
43904
+ }
43905
+ multipleOf(value, message) {
43906
+ return this._addCheck({
43907
+ kind: "multipleOf",
43908
+ value,
43909
+ message: errorUtil.toString(message)
43910
+ });
43911
+ }
43912
+ finite(message) {
43913
+ return this._addCheck({
43914
+ kind: "finite",
43915
+ message: errorUtil.toString(message)
43916
+ });
43917
+ }
43918
+ safe(message) {
43919
+ return this._addCheck({
43920
+ kind: "min",
43921
+ inclusive: true,
43922
+ value: Number.MIN_SAFE_INTEGER,
43923
+ message: errorUtil.toString(message)
43924
+ })._addCheck({
43925
+ kind: "max",
43926
+ inclusive: true,
43927
+ value: Number.MAX_SAFE_INTEGER,
43928
+ message: errorUtil.toString(message)
43929
+ });
43930
+ }
43931
+ get minValue() {
43932
+ let min = null;
43933
+ for (const ch of this._def.checks) {
43934
+ if (ch.kind === "min") {
43935
+ if (min === null || ch.value > min)
43936
+ min = ch.value;
43937
+ }
43938
+ }
43939
+ return min;
43940
+ }
43941
+ get maxValue() {
43942
+ let max = null;
43943
+ for (const ch of this._def.checks) {
43944
+ if (ch.kind === "max") {
43945
+ if (max === null || ch.value < max)
43946
+ max = ch.value;
43947
+ }
43948
+ }
43949
+ return max;
43950
+ }
43951
+ get isInt() {
43952
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
43953
+ }
43954
+ get isFinite() {
43955
+ let max = null;
43956
+ let min = null;
43957
+ for (const ch of this._def.checks) {
43958
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
43959
+ return true;
43960
+ } else if (ch.kind === "min") {
43961
+ if (min === null || ch.value > min)
43962
+ min = ch.value;
43963
+ } else if (ch.kind === "max") {
43964
+ if (max === null || ch.value < max)
43965
+ max = ch.value;
43966
+ }
43967
+ }
43968
+ return Number.isFinite(min) && Number.isFinite(max);
43969
+ }
43970
+ };
43971
+ ZodNumber.create = (params) => {
43972
+ return new ZodNumber({
43973
+ checks: [],
43974
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
43975
+ coerce: params?.coerce || false,
43976
+ ...processCreateParams(params)
43977
+ });
43978
+ };
43979
+ var ZodBigInt = class _ZodBigInt extends ZodType {
43980
+ constructor() {
43981
+ super(...arguments);
43982
+ this.min = this.gte;
43983
+ this.max = this.lte;
43984
+ }
43985
+ _parse(input) {
43986
+ if (this._def.coerce) {
43987
+ try {
43988
+ input.data = BigInt(input.data);
43989
+ } catch {
43990
+ return this._getInvalidInput(input);
43991
+ }
43992
+ }
43993
+ const parsedType = this._getType(input);
43994
+ if (parsedType !== ZodParsedType.bigint) {
43995
+ return this._getInvalidInput(input);
43996
+ }
43997
+ let ctx = void 0;
43998
+ const status = new ParseStatus();
43999
+ for (const check of this._def.checks) {
44000
+ if (check.kind === "min") {
44001
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
44002
+ if (tooSmall) {
44003
+ ctx = this._getOrReturnCtx(input, ctx);
44004
+ addIssueToContext(ctx, {
44005
+ code: ZodIssueCode.too_small,
44006
+ type: "bigint",
44007
+ minimum: check.value,
44008
+ inclusive: check.inclusive,
44009
+ message: check.message
44010
+ });
44011
+ status.dirty();
44012
+ }
44013
+ } else if (check.kind === "max") {
44014
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
44015
+ if (tooBig) {
44016
+ ctx = this._getOrReturnCtx(input, ctx);
44017
+ addIssueToContext(ctx, {
44018
+ code: ZodIssueCode.too_big,
44019
+ type: "bigint",
44020
+ maximum: check.value,
44021
+ inclusive: check.inclusive,
44022
+ message: check.message
44023
+ });
44024
+ status.dirty();
44025
+ }
44026
+ } else if (check.kind === "multipleOf") {
44027
+ if (input.data % check.value !== BigInt(0)) {
44028
+ ctx = this._getOrReturnCtx(input, ctx);
44029
+ addIssueToContext(ctx, {
44030
+ code: ZodIssueCode.not_multiple_of,
44031
+ multipleOf: check.value,
44032
+ message: check.message
44033
+ });
44034
+ status.dirty();
44035
+ }
44036
+ } else {
44037
+ util.assertNever(check);
44038
+ }
44039
+ }
44040
+ return { status: status.value, value: input.data };
44041
+ }
44042
+ _getInvalidInput(input) {
44043
+ const ctx = this._getOrReturnCtx(input);
44044
+ addIssueToContext(ctx, {
44045
+ code: ZodIssueCode.invalid_type,
44046
+ expected: ZodParsedType.bigint,
44047
+ received: ctx.parsedType
44048
+ });
44049
+ return INVALID;
44050
+ }
44051
+ gte(value, message) {
44052
+ return this.setLimit("min", value, true, errorUtil.toString(message));
44053
+ }
44054
+ gt(value, message) {
44055
+ return this.setLimit("min", value, false, errorUtil.toString(message));
44056
+ }
44057
+ lte(value, message) {
44058
+ return this.setLimit("max", value, true, errorUtil.toString(message));
44059
+ }
44060
+ lt(value, message) {
44061
+ return this.setLimit("max", value, false, errorUtil.toString(message));
44062
+ }
44063
+ setLimit(kind, value, inclusive, message) {
44064
+ return new _ZodBigInt({
44065
+ ...this._def,
44066
+ checks: [
44067
+ ...this._def.checks,
44068
+ {
44069
+ kind,
44070
+ value,
44071
+ inclusive,
44072
+ message: errorUtil.toString(message)
44073
+ }
44074
+ ]
44075
+ });
44076
+ }
44077
+ _addCheck(check) {
44078
+ return new _ZodBigInt({
44079
+ ...this._def,
44080
+ checks: [...this._def.checks, check]
44081
+ });
44082
+ }
44083
+ positive(message) {
44084
+ return this._addCheck({
44085
+ kind: "min",
44086
+ value: BigInt(0),
44087
+ inclusive: false,
44088
+ message: errorUtil.toString(message)
44089
+ });
44090
+ }
44091
+ negative(message) {
44092
+ return this._addCheck({
44093
+ kind: "max",
44094
+ value: BigInt(0),
44095
+ inclusive: false,
44096
+ message: errorUtil.toString(message)
44097
+ });
44098
+ }
44099
+ nonpositive(message) {
44100
+ return this._addCheck({
44101
+ kind: "max",
44102
+ value: BigInt(0),
44103
+ inclusive: true,
44104
+ message: errorUtil.toString(message)
44105
+ });
44106
+ }
44107
+ nonnegative(message) {
44108
+ return this._addCheck({
44109
+ kind: "min",
44110
+ value: BigInt(0),
44111
+ inclusive: true,
44112
+ message: errorUtil.toString(message)
44113
+ });
44114
+ }
44115
+ multipleOf(value, message) {
44116
+ return this._addCheck({
44117
+ kind: "multipleOf",
44118
+ value,
44119
+ message: errorUtil.toString(message)
44120
+ });
44121
+ }
44122
+ get minValue() {
44123
+ let min = null;
44124
+ for (const ch of this._def.checks) {
44125
+ if (ch.kind === "min") {
44126
+ if (min === null || ch.value > min)
44127
+ min = ch.value;
44128
+ }
44129
+ }
44130
+ return min;
44131
+ }
44132
+ get maxValue() {
44133
+ let max = null;
44134
+ for (const ch of this._def.checks) {
44135
+ if (ch.kind === "max") {
44136
+ if (max === null || ch.value < max)
44137
+ max = ch.value;
44138
+ }
44139
+ }
44140
+ return max;
44141
+ }
44142
+ };
44143
+ ZodBigInt.create = (params) => {
44144
+ return new ZodBigInt({
44145
+ checks: [],
44146
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
44147
+ coerce: params?.coerce ?? false,
44148
+ ...processCreateParams(params)
44149
+ });
44150
+ };
44151
+ var ZodBoolean = class extends ZodType {
44152
+ _parse(input) {
44153
+ if (this._def.coerce) {
44154
+ input.data = Boolean(input.data);
44155
+ }
44156
+ const parsedType = this._getType(input);
44157
+ if (parsedType !== ZodParsedType.boolean) {
44158
+ const ctx = this._getOrReturnCtx(input);
44159
+ addIssueToContext(ctx, {
44160
+ code: ZodIssueCode.invalid_type,
44161
+ expected: ZodParsedType.boolean,
44162
+ received: ctx.parsedType
44163
+ });
44164
+ return INVALID;
44165
+ }
44166
+ return OK(input.data);
44167
+ }
44168
+ };
44169
+ ZodBoolean.create = (params) => {
44170
+ return new ZodBoolean({
44171
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
44172
+ coerce: params?.coerce || false,
44173
+ ...processCreateParams(params)
44174
+ });
44175
+ };
44176
+ var ZodDate = class _ZodDate extends ZodType {
44177
+ _parse(input) {
44178
+ if (this._def.coerce) {
44179
+ input.data = new Date(input.data);
44180
+ }
44181
+ const parsedType = this._getType(input);
44182
+ if (parsedType !== ZodParsedType.date) {
44183
+ const ctx2 = this._getOrReturnCtx(input);
44184
+ addIssueToContext(ctx2, {
44185
+ code: ZodIssueCode.invalid_type,
44186
+ expected: ZodParsedType.date,
44187
+ received: ctx2.parsedType
44188
+ });
44189
+ return INVALID;
44190
+ }
44191
+ if (Number.isNaN(input.data.getTime())) {
44192
+ const ctx2 = this._getOrReturnCtx(input);
44193
+ addIssueToContext(ctx2, {
44194
+ code: ZodIssueCode.invalid_date
44195
+ });
44196
+ return INVALID;
44197
+ }
44198
+ const status = new ParseStatus();
44199
+ let ctx = void 0;
44200
+ for (const check of this._def.checks) {
44201
+ if (check.kind === "min") {
44202
+ if (input.data.getTime() < check.value) {
44203
+ ctx = this._getOrReturnCtx(input, ctx);
44204
+ addIssueToContext(ctx, {
44205
+ code: ZodIssueCode.too_small,
44206
+ message: check.message,
44207
+ inclusive: true,
44208
+ exact: false,
44209
+ minimum: check.value,
44210
+ type: "date"
44211
+ });
44212
+ status.dirty();
44213
+ }
44214
+ } else if (check.kind === "max") {
44215
+ if (input.data.getTime() > check.value) {
44216
+ ctx = this._getOrReturnCtx(input, ctx);
44217
+ addIssueToContext(ctx, {
44218
+ code: ZodIssueCode.too_big,
44219
+ message: check.message,
44220
+ inclusive: true,
44221
+ exact: false,
44222
+ maximum: check.value,
44223
+ type: "date"
44224
+ });
44225
+ status.dirty();
44226
+ }
44227
+ } else {
44228
+ util.assertNever(check);
44229
+ }
44230
+ }
44231
+ return {
44232
+ status: status.value,
44233
+ value: new Date(input.data.getTime())
44234
+ };
44235
+ }
44236
+ _addCheck(check) {
44237
+ return new _ZodDate({
44238
+ ...this._def,
44239
+ checks: [...this._def.checks, check]
44240
+ });
44241
+ }
44242
+ min(minDate, message) {
44243
+ return this._addCheck({
44244
+ kind: "min",
44245
+ value: minDate.getTime(),
44246
+ message: errorUtil.toString(message)
44247
+ });
44248
+ }
44249
+ max(maxDate, message) {
44250
+ return this._addCheck({
44251
+ kind: "max",
44252
+ value: maxDate.getTime(),
44253
+ message: errorUtil.toString(message)
44254
+ });
44255
+ }
44256
+ get minDate() {
44257
+ let min = null;
44258
+ for (const ch of this._def.checks) {
44259
+ if (ch.kind === "min") {
44260
+ if (min === null || ch.value > min)
44261
+ min = ch.value;
44262
+ }
44263
+ }
44264
+ return min != null ? new Date(min) : null;
44265
+ }
44266
+ get maxDate() {
44267
+ let max = null;
44268
+ for (const ch of this._def.checks) {
44269
+ if (ch.kind === "max") {
44270
+ if (max === null || ch.value < max)
44271
+ max = ch.value;
44272
+ }
44273
+ }
44274
+ return max != null ? new Date(max) : null;
44275
+ }
44276
+ };
44277
+ ZodDate.create = (params) => {
44278
+ return new ZodDate({
44279
+ checks: [],
44280
+ coerce: params?.coerce || false,
44281
+ typeName: ZodFirstPartyTypeKind.ZodDate,
44282
+ ...processCreateParams(params)
44283
+ });
44284
+ };
44285
+ var ZodSymbol = class extends ZodType {
44286
+ _parse(input) {
44287
+ const parsedType = this._getType(input);
44288
+ if (parsedType !== ZodParsedType.symbol) {
44289
+ const ctx = this._getOrReturnCtx(input);
44290
+ addIssueToContext(ctx, {
44291
+ code: ZodIssueCode.invalid_type,
44292
+ expected: ZodParsedType.symbol,
44293
+ received: ctx.parsedType
44294
+ });
44295
+ return INVALID;
44296
+ }
44297
+ return OK(input.data);
44298
+ }
44299
+ };
44300
+ ZodSymbol.create = (params) => {
44301
+ return new ZodSymbol({
44302
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
44303
+ ...processCreateParams(params)
44304
+ });
44305
+ };
44306
+ var ZodUndefined = class extends ZodType {
44307
+ _parse(input) {
44308
+ const parsedType = this._getType(input);
44309
+ if (parsedType !== ZodParsedType.undefined) {
44310
+ const ctx = this._getOrReturnCtx(input);
44311
+ addIssueToContext(ctx, {
44312
+ code: ZodIssueCode.invalid_type,
44313
+ expected: ZodParsedType.undefined,
44314
+ received: ctx.parsedType
44315
+ });
44316
+ return INVALID;
44317
+ }
44318
+ return OK(input.data);
44319
+ }
44320
+ };
44321
+ ZodUndefined.create = (params) => {
44322
+ return new ZodUndefined({
44323
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
44324
+ ...processCreateParams(params)
44325
+ });
44326
+ };
44327
+ var ZodNull = class extends ZodType {
44328
+ _parse(input) {
44329
+ const parsedType = this._getType(input);
44330
+ if (parsedType !== ZodParsedType.null) {
44331
+ const ctx = this._getOrReturnCtx(input);
44332
+ addIssueToContext(ctx, {
44333
+ code: ZodIssueCode.invalid_type,
44334
+ expected: ZodParsedType.null,
44335
+ received: ctx.parsedType
44336
+ });
44337
+ return INVALID;
44338
+ }
44339
+ return OK(input.data);
44340
+ }
44341
+ };
44342
+ ZodNull.create = (params) => {
44343
+ return new ZodNull({
44344
+ typeName: ZodFirstPartyTypeKind.ZodNull,
44345
+ ...processCreateParams(params)
44346
+ });
44347
+ };
44348
+ var ZodAny = class extends ZodType {
44349
+ constructor() {
44350
+ super(...arguments);
44351
+ this._any = true;
44352
+ }
44353
+ _parse(input) {
44354
+ return OK(input.data);
44355
+ }
44356
+ };
44357
+ ZodAny.create = (params) => {
44358
+ return new ZodAny({
44359
+ typeName: ZodFirstPartyTypeKind.ZodAny,
44360
+ ...processCreateParams(params)
44361
+ });
44362
+ };
44363
+ var ZodUnknown = class extends ZodType {
44364
+ constructor() {
44365
+ super(...arguments);
44366
+ this._unknown = true;
44367
+ }
44368
+ _parse(input) {
44369
+ return OK(input.data);
44370
+ }
44371
+ };
44372
+ ZodUnknown.create = (params) => {
44373
+ return new ZodUnknown({
44374
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
44375
+ ...processCreateParams(params)
44376
+ });
44377
+ };
44378
+ var ZodNever = class extends ZodType {
44379
+ _parse(input) {
44380
+ const ctx = this._getOrReturnCtx(input);
44381
+ addIssueToContext(ctx, {
44382
+ code: ZodIssueCode.invalid_type,
44383
+ expected: ZodParsedType.never,
44384
+ received: ctx.parsedType
44385
+ });
44386
+ return INVALID;
44387
+ }
44388
+ };
44389
+ ZodNever.create = (params) => {
44390
+ return new ZodNever({
44391
+ typeName: ZodFirstPartyTypeKind.ZodNever,
44392
+ ...processCreateParams(params)
44393
+ });
44394
+ };
44395
+ var ZodVoid = class extends ZodType {
44396
+ _parse(input) {
44397
+ const parsedType = this._getType(input);
44398
+ if (parsedType !== ZodParsedType.undefined) {
44399
+ const ctx = this._getOrReturnCtx(input);
44400
+ addIssueToContext(ctx, {
44401
+ code: ZodIssueCode.invalid_type,
44402
+ expected: ZodParsedType.void,
44403
+ received: ctx.parsedType
44404
+ });
44405
+ return INVALID;
44406
+ }
44407
+ return OK(input.data);
44408
+ }
44409
+ };
44410
+ ZodVoid.create = (params) => {
44411
+ return new ZodVoid({
44412
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
44413
+ ...processCreateParams(params)
44414
+ });
44415
+ };
44416
+ var ZodArray = class _ZodArray extends ZodType {
44417
+ _parse(input) {
44418
+ const { ctx, status } = this._processInputParams(input);
44419
+ const def = this._def;
44420
+ if (ctx.parsedType !== ZodParsedType.array) {
44421
+ addIssueToContext(ctx, {
44422
+ code: ZodIssueCode.invalid_type,
44423
+ expected: ZodParsedType.array,
44424
+ received: ctx.parsedType
44425
+ });
44426
+ return INVALID;
44427
+ }
44428
+ if (def.exactLength !== null) {
44429
+ const tooBig = ctx.data.length > def.exactLength.value;
44430
+ const tooSmall = ctx.data.length < def.exactLength.value;
44431
+ if (tooBig || tooSmall) {
44432
+ addIssueToContext(ctx, {
44433
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
44434
+ minimum: tooSmall ? def.exactLength.value : void 0,
44435
+ maximum: tooBig ? def.exactLength.value : void 0,
44436
+ type: "array",
44437
+ inclusive: true,
44438
+ exact: true,
44439
+ message: def.exactLength.message
44440
+ });
44441
+ status.dirty();
44442
+ }
44443
+ }
44444
+ if (def.minLength !== null) {
44445
+ if (ctx.data.length < def.minLength.value) {
44446
+ addIssueToContext(ctx, {
44447
+ code: ZodIssueCode.too_small,
44448
+ minimum: def.minLength.value,
44449
+ type: "array",
44450
+ inclusive: true,
44451
+ exact: false,
44452
+ message: def.minLength.message
44453
+ });
44454
+ status.dirty();
44455
+ }
44456
+ }
44457
+ if (def.maxLength !== null) {
44458
+ if (ctx.data.length > def.maxLength.value) {
44459
+ addIssueToContext(ctx, {
44460
+ code: ZodIssueCode.too_big,
44461
+ maximum: def.maxLength.value,
44462
+ type: "array",
44463
+ inclusive: true,
44464
+ exact: false,
44465
+ message: def.maxLength.message
44466
+ });
44467
+ status.dirty();
44468
+ }
44469
+ }
44470
+ if (ctx.common.async) {
44471
+ return Promise.all([...ctx.data].map((item, i) => {
44472
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
44473
+ })).then((result2) => {
44474
+ return ParseStatus.mergeArray(status, result2);
44475
+ });
44476
+ }
44477
+ const result = [...ctx.data].map((item, i) => {
44478
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
44479
+ });
44480
+ return ParseStatus.mergeArray(status, result);
44481
+ }
44482
+ get element() {
44483
+ return this._def.type;
44484
+ }
44485
+ min(minLength, message) {
44486
+ return new _ZodArray({
44487
+ ...this._def,
44488
+ minLength: { value: minLength, message: errorUtil.toString(message) }
44489
+ });
44490
+ }
44491
+ max(maxLength, message) {
44492
+ return new _ZodArray({
44493
+ ...this._def,
44494
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
44495
+ });
44496
+ }
44497
+ length(len, message) {
44498
+ return new _ZodArray({
44499
+ ...this._def,
44500
+ exactLength: { value: len, message: errorUtil.toString(message) }
44501
+ });
44502
+ }
44503
+ nonempty(message) {
44504
+ return this.min(1, message);
44505
+ }
44506
+ };
44507
+ ZodArray.create = (schema, params) => {
44508
+ return new ZodArray({
44509
+ type: schema,
44510
+ minLength: null,
44511
+ maxLength: null,
44512
+ exactLength: null,
44513
+ typeName: ZodFirstPartyTypeKind.ZodArray,
44514
+ ...processCreateParams(params)
44515
+ });
44516
+ };
44517
+ function deepPartialify(schema) {
44518
+ if (schema instanceof ZodObject) {
44519
+ const newShape = {};
44520
+ for (const key in schema.shape) {
44521
+ const fieldSchema = schema.shape[key];
44522
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
44523
+ }
44524
+ return new ZodObject({
44525
+ ...schema._def,
44526
+ shape: () => newShape
44527
+ });
44528
+ } else if (schema instanceof ZodArray) {
44529
+ return new ZodArray({
44530
+ ...schema._def,
44531
+ type: deepPartialify(schema.element)
44532
+ });
44533
+ } else if (schema instanceof ZodOptional) {
44534
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
44535
+ } else if (schema instanceof ZodNullable) {
44536
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
44537
+ } else if (schema instanceof ZodTuple) {
44538
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
44539
+ } else {
44540
+ return schema;
44541
+ }
44542
+ }
44543
+ var ZodObject = class _ZodObject extends ZodType {
44544
+ constructor() {
44545
+ super(...arguments);
44546
+ this._cached = null;
44547
+ this.nonstrict = this.passthrough;
44548
+ this.augment = this.extend;
44549
+ }
44550
+ _getCached() {
44551
+ if (this._cached !== null)
44552
+ return this._cached;
44553
+ const shape = this._def.shape();
44554
+ const keys = util.objectKeys(shape);
44555
+ this._cached = { shape, keys };
44556
+ return this._cached;
44557
+ }
44558
+ _parse(input) {
44559
+ const parsedType = this._getType(input);
44560
+ if (parsedType !== ZodParsedType.object) {
44561
+ const ctx2 = this._getOrReturnCtx(input);
44562
+ addIssueToContext(ctx2, {
44563
+ code: ZodIssueCode.invalid_type,
44564
+ expected: ZodParsedType.object,
44565
+ received: ctx2.parsedType
44566
+ });
44567
+ return INVALID;
44568
+ }
44569
+ const { status, ctx } = this._processInputParams(input);
44570
+ const { shape, keys: shapeKeys } = this._getCached();
44571
+ const extraKeys = [];
44572
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
44573
+ for (const key in ctx.data) {
44574
+ if (!shapeKeys.includes(key)) {
44575
+ extraKeys.push(key);
44576
+ }
44577
+ }
44578
+ }
44579
+ const pairs = [];
44580
+ for (const key of shapeKeys) {
44581
+ const keyValidator = shape[key];
44582
+ const value = ctx.data[key];
44583
+ pairs.push({
44584
+ key: { status: "valid", value: key },
44585
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
44586
+ alwaysSet: key in ctx.data
44587
+ });
44588
+ }
44589
+ if (this._def.catchall instanceof ZodNever) {
44590
+ const unknownKeys = this._def.unknownKeys;
44591
+ if (unknownKeys === "passthrough") {
44592
+ for (const key of extraKeys) {
44593
+ pairs.push({
44594
+ key: { status: "valid", value: key },
44595
+ value: { status: "valid", value: ctx.data[key] }
44596
+ });
44597
+ }
44598
+ } else if (unknownKeys === "strict") {
44599
+ if (extraKeys.length > 0) {
44600
+ addIssueToContext(ctx, {
44601
+ code: ZodIssueCode.unrecognized_keys,
44602
+ keys: extraKeys
44603
+ });
44604
+ status.dirty();
44605
+ }
44606
+ } else if (unknownKeys === "strip") {
44607
+ } else {
44608
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
44609
+ }
44610
+ } else {
44611
+ const catchall = this._def.catchall;
44612
+ for (const key of extraKeys) {
44613
+ const value = ctx.data[key];
44614
+ pairs.push({
44615
+ key: { status: "valid", value: key },
44616
+ value: catchall._parse(
44617
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
44618
+ //, ctx.child(key), value, getParsedType(value)
44619
+ ),
44620
+ alwaysSet: key in ctx.data
44621
+ });
44622
+ }
44623
+ }
44624
+ if (ctx.common.async) {
44625
+ return Promise.resolve().then(async () => {
44626
+ const syncPairs = [];
44627
+ for (const pair of pairs) {
44628
+ const key = await pair.key;
44629
+ const value = await pair.value;
44630
+ syncPairs.push({
44631
+ key,
44632
+ value,
44633
+ alwaysSet: pair.alwaysSet
44634
+ });
44635
+ }
44636
+ return syncPairs;
44637
+ }).then((syncPairs) => {
44638
+ return ParseStatus.mergeObjectSync(status, syncPairs);
44639
+ });
44640
+ } else {
44641
+ return ParseStatus.mergeObjectSync(status, pairs);
44642
+ }
44643
+ }
44644
+ get shape() {
44645
+ return this._def.shape();
44646
+ }
44647
+ strict(message) {
44648
+ errorUtil.errToObj;
44649
+ return new _ZodObject({
44650
+ ...this._def,
44651
+ unknownKeys: "strict",
44652
+ ...message !== void 0 ? {
44653
+ errorMap: (issue, ctx) => {
44654
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
44655
+ if (issue.code === "unrecognized_keys")
44656
+ return {
44657
+ message: errorUtil.errToObj(message).message ?? defaultError
44658
+ };
44659
+ return {
44660
+ message: defaultError
44661
+ };
44662
+ }
44663
+ } : {}
44664
+ });
44665
+ }
44666
+ strip() {
44667
+ return new _ZodObject({
44668
+ ...this._def,
44669
+ unknownKeys: "strip"
44670
+ });
44671
+ }
44672
+ passthrough() {
44673
+ return new _ZodObject({
44674
+ ...this._def,
44675
+ unknownKeys: "passthrough"
44676
+ });
44677
+ }
44678
+ // const AugmentFactory =
44679
+ // <Def extends ZodObjectDef>(def: Def) =>
44680
+ // <Augmentation extends ZodRawShape>(
44681
+ // augmentation: Augmentation
44682
+ // ): ZodObject<
44683
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
44684
+ // Def["unknownKeys"],
44685
+ // Def["catchall"]
44686
+ // > => {
44687
+ // return new ZodObject({
44688
+ // ...def,
44689
+ // shape: () => ({
44690
+ // ...def.shape(),
44691
+ // ...augmentation,
44692
+ // }),
44693
+ // }) as any;
44694
+ // };
44695
+ extend(augmentation) {
44696
+ return new _ZodObject({
44697
+ ...this._def,
44698
+ shape: () => ({
44699
+ ...this._def.shape(),
44700
+ ...augmentation
44701
+ })
44702
+ });
44703
+ }
44704
+ /**
44705
+ * Prior to zod@1.0.12 there was a bug in the
44706
+ * inferred type of merged objects. Please
44707
+ * upgrade if you are experiencing issues.
44708
+ */
44709
+ merge(merging) {
44710
+ const merged = new _ZodObject({
44711
+ unknownKeys: merging._def.unknownKeys,
44712
+ catchall: merging._def.catchall,
44713
+ shape: () => ({
44714
+ ...this._def.shape(),
44715
+ ...merging._def.shape()
44716
+ }),
44717
+ typeName: ZodFirstPartyTypeKind.ZodObject
44718
+ });
44719
+ return merged;
44720
+ }
44721
+ // merge<
44722
+ // Incoming extends AnyZodObject,
44723
+ // Augmentation extends Incoming["shape"],
44724
+ // NewOutput extends {
44725
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
44726
+ // ? Augmentation[k]["_output"]
44727
+ // : k extends keyof Output
44728
+ // ? Output[k]
44729
+ // : never;
44730
+ // },
44731
+ // NewInput extends {
44732
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
44733
+ // ? Augmentation[k]["_input"]
44734
+ // : k extends keyof Input
44735
+ // ? Input[k]
44736
+ // : never;
44737
+ // }
44738
+ // >(
44739
+ // merging: Incoming
44740
+ // ): ZodObject<
44741
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
44742
+ // Incoming["_def"]["unknownKeys"],
44743
+ // Incoming["_def"]["catchall"],
44744
+ // NewOutput,
44745
+ // NewInput
44746
+ // > {
44747
+ // const merged: any = new ZodObject({
44748
+ // unknownKeys: merging._def.unknownKeys,
44749
+ // catchall: merging._def.catchall,
44750
+ // shape: () =>
44751
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
44752
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
44753
+ // }) as any;
44754
+ // return merged;
44755
+ // }
44756
+ setKey(key, schema) {
44757
+ return this.augment({ [key]: schema });
44758
+ }
44759
+ // merge<Incoming extends AnyZodObject>(
44760
+ // merging: Incoming
44761
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
44762
+ // ZodObject<
44763
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
44764
+ // Incoming["_def"]["unknownKeys"],
44765
+ // Incoming["_def"]["catchall"]
44766
+ // > {
44767
+ // // const mergedShape = objectUtil.mergeShapes(
44768
+ // // this._def.shape(),
44769
+ // // merging._def.shape()
44770
+ // // );
44771
+ // const merged: any = new ZodObject({
44772
+ // unknownKeys: merging._def.unknownKeys,
44773
+ // catchall: merging._def.catchall,
44774
+ // shape: () =>
44775
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
44776
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
44777
+ // }) as any;
44778
+ // return merged;
44779
+ // }
44780
+ catchall(index2) {
44781
+ return new _ZodObject({
44782
+ ...this._def,
44783
+ catchall: index2
44784
+ });
44785
+ }
44786
+ pick(mask) {
44787
+ const shape = {};
44788
+ for (const key of util.objectKeys(mask)) {
44789
+ if (mask[key] && this.shape[key]) {
44790
+ shape[key] = this.shape[key];
44791
+ }
44792
+ }
44793
+ return new _ZodObject({
44794
+ ...this._def,
44795
+ shape: () => shape
44796
+ });
44797
+ }
44798
+ omit(mask) {
44799
+ const shape = {};
44800
+ for (const key of util.objectKeys(this.shape)) {
44801
+ if (!mask[key]) {
44802
+ shape[key] = this.shape[key];
44803
+ }
44804
+ }
44805
+ return new _ZodObject({
44806
+ ...this._def,
44807
+ shape: () => shape
44808
+ });
44809
+ }
44810
+ /**
44811
+ * @deprecated
44812
+ */
44813
+ deepPartial() {
44814
+ return deepPartialify(this);
44815
+ }
44816
+ partial(mask) {
44817
+ const newShape = {};
44818
+ for (const key of util.objectKeys(this.shape)) {
44819
+ const fieldSchema = this.shape[key];
44820
+ if (mask && !mask[key]) {
44821
+ newShape[key] = fieldSchema;
44822
+ } else {
44823
+ newShape[key] = fieldSchema.optional();
44824
+ }
44825
+ }
44826
+ return new _ZodObject({
44827
+ ...this._def,
44828
+ shape: () => newShape
44829
+ });
44830
+ }
44831
+ required(mask) {
44832
+ const newShape = {};
44833
+ for (const key of util.objectKeys(this.shape)) {
44834
+ if (mask && !mask[key]) {
44835
+ newShape[key] = this.shape[key];
44836
+ } else {
44837
+ const fieldSchema = this.shape[key];
44838
+ let newField = fieldSchema;
44839
+ while (newField instanceof ZodOptional) {
44840
+ newField = newField._def.innerType;
44841
+ }
44842
+ newShape[key] = newField;
44843
+ }
44844
+ }
44845
+ return new _ZodObject({
44846
+ ...this._def,
44847
+ shape: () => newShape
44848
+ });
44849
+ }
44850
+ keyof() {
44851
+ return createZodEnum(util.objectKeys(this.shape));
44852
+ }
44853
+ };
44854
+ ZodObject.create = (shape, params) => {
44855
+ return new ZodObject({
44856
+ shape: () => shape,
44857
+ unknownKeys: "strip",
44858
+ catchall: ZodNever.create(),
44859
+ typeName: ZodFirstPartyTypeKind.ZodObject,
44860
+ ...processCreateParams(params)
44861
+ });
44862
+ };
44863
+ ZodObject.strictCreate = (shape, params) => {
44864
+ return new ZodObject({
44865
+ shape: () => shape,
44866
+ unknownKeys: "strict",
44867
+ catchall: ZodNever.create(),
44868
+ typeName: ZodFirstPartyTypeKind.ZodObject,
44869
+ ...processCreateParams(params)
44870
+ });
44871
+ };
44872
+ ZodObject.lazycreate = (shape, params) => {
44873
+ return new ZodObject({
44874
+ shape,
44875
+ unknownKeys: "strip",
44876
+ catchall: ZodNever.create(),
44877
+ typeName: ZodFirstPartyTypeKind.ZodObject,
44878
+ ...processCreateParams(params)
44879
+ });
44880
+ };
44881
+ var ZodUnion = class extends ZodType {
44882
+ _parse(input) {
44883
+ const { ctx } = this._processInputParams(input);
44884
+ const options = this._def.options;
44885
+ function handleResults(results) {
44886
+ for (const result of results) {
44887
+ if (result.result.status === "valid") {
44888
+ return result.result;
44889
+ }
44890
+ }
44891
+ for (const result of results) {
44892
+ if (result.result.status === "dirty") {
44893
+ ctx.common.issues.push(...result.ctx.common.issues);
44894
+ return result.result;
44895
+ }
44896
+ }
44897
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
44898
+ addIssueToContext(ctx, {
44899
+ code: ZodIssueCode.invalid_union,
44900
+ unionErrors
44901
+ });
44902
+ return INVALID;
44903
+ }
44904
+ if (ctx.common.async) {
44905
+ return Promise.all(options.map(async (option) => {
44906
+ const childCtx = {
44907
+ ...ctx,
44908
+ common: {
44909
+ ...ctx.common,
44910
+ issues: []
44911
+ },
44912
+ parent: null
44913
+ };
44914
+ return {
44915
+ result: await option._parseAsync({
44916
+ data: ctx.data,
44917
+ path: ctx.path,
44918
+ parent: childCtx
44919
+ }),
44920
+ ctx: childCtx
44921
+ };
44922
+ })).then(handleResults);
44923
+ } else {
44924
+ let dirty = void 0;
44925
+ const issues = [];
44926
+ for (const option of options) {
44927
+ const childCtx = {
44928
+ ...ctx,
44929
+ common: {
44930
+ ...ctx.common,
44931
+ issues: []
44932
+ },
44933
+ parent: null
44934
+ };
44935
+ const result = option._parseSync({
44936
+ data: ctx.data,
44937
+ path: ctx.path,
44938
+ parent: childCtx
44939
+ });
44940
+ if (result.status === "valid") {
44941
+ return result;
44942
+ } else if (result.status === "dirty" && !dirty) {
44943
+ dirty = { result, ctx: childCtx };
44944
+ }
44945
+ if (childCtx.common.issues.length) {
44946
+ issues.push(childCtx.common.issues);
44947
+ }
44948
+ }
44949
+ if (dirty) {
44950
+ ctx.common.issues.push(...dirty.ctx.common.issues);
44951
+ return dirty.result;
44952
+ }
44953
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
44954
+ addIssueToContext(ctx, {
44955
+ code: ZodIssueCode.invalid_union,
44956
+ unionErrors
44957
+ });
44958
+ return INVALID;
44959
+ }
44960
+ }
44961
+ get options() {
44962
+ return this._def.options;
44963
+ }
44964
+ };
44965
+ ZodUnion.create = (types, params) => {
44966
+ return new ZodUnion({
44967
+ options: types,
44968
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
44969
+ ...processCreateParams(params)
44970
+ });
44971
+ };
44972
+ var getDiscriminator = (type) => {
44973
+ if (type instanceof ZodLazy) {
44974
+ return getDiscriminator(type.schema);
44975
+ } else if (type instanceof ZodEffects) {
44976
+ return getDiscriminator(type.innerType());
44977
+ } else if (type instanceof ZodLiteral) {
44978
+ return [type.value];
44979
+ } else if (type instanceof ZodEnum) {
44980
+ return type.options;
44981
+ } else if (type instanceof ZodNativeEnum) {
44982
+ return util.objectValues(type.enum);
44983
+ } else if (type instanceof ZodDefault) {
44984
+ return getDiscriminator(type._def.innerType);
44985
+ } else if (type instanceof ZodUndefined) {
44986
+ return [void 0];
44987
+ } else if (type instanceof ZodNull) {
44988
+ return [null];
44989
+ } else if (type instanceof ZodOptional) {
44990
+ return [void 0, ...getDiscriminator(type.unwrap())];
44991
+ } else if (type instanceof ZodNullable) {
44992
+ return [null, ...getDiscriminator(type.unwrap())];
44993
+ } else if (type instanceof ZodBranded) {
44994
+ return getDiscriminator(type.unwrap());
44995
+ } else if (type instanceof ZodReadonly) {
44996
+ return getDiscriminator(type.unwrap());
44997
+ } else if (type instanceof ZodCatch) {
44998
+ return getDiscriminator(type._def.innerType);
44999
+ } else {
45000
+ return [];
45001
+ }
45002
+ };
45003
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
45004
+ _parse(input) {
45005
+ const { ctx } = this._processInputParams(input);
45006
+ if (ctx.parsedType !== ZodParsedType.object) {
45007
+ addIssueToContext(ctx, {
45008
+ code: ZodIssueCode.invalid_type,
45009
+ expected: ZodParsedType.object,
45010
+ received: ctx.parsedType
45011
+ });
45012
+ return INVALID;
45013
+ }
45014
+ const discriminator = this.discriminator;
45015
+ const discriminatorValue = ctx.data[discriminator];
45016
+ const option = this.optionsMap.get(discriminatorValue);
45017
+ if (!option) {
45018
+ addIssueToContext(ctx, {
45019
+ code: ZodIssueCode.invalid_union_discriminator,
45020
+ options: Array.from(this.optionsMap.keys()),
45021
+ path: [discriminator]
45022
+ });
45023
+ return INVALID;
45024
+ }
45025
+ if (ctx.common.async) {
45026
+ return option._parseAsync({
45027
+ data: ctx.data,
45028
+ path: ctx.path,
45029
+ parent: ctx
45030
+ });
45031
+ } else {
45032
+ return option._parseSync({
45033
+ data: ctx.data,
45034
+ path: ctx.path,
45035
+ parent: ctx
45036
+ });
45037
+ }
45038
+ }
45039
+ get discriminator() {
45040
+ return this._def.discriminator;
45041
+ }
45042
+ get options() {
45043
+ return this._def.options;
45044
+ }
45045
+ get optionsMap() {
45046
+ return this._def.optionsMap;
45047
+ }
45048
+ /**
45049
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
45050
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
45051
+ * have a different value for each object in the union.
45052
+ * @param discriminator the name of the discriminator property
45053
+ * @param types an array of object schemas
45054
+ * @param params
45055
+ */
45056
+ static create(discriminator, options, params) {
45057
+ const optionsMap = /* @__PURE__ */ new Map();
45058
+ for (const type of options) {
45059
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
45060
+ if (!discriminatorValues.length) {
45061
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
45062
+ }
45063
+ for (const value of discriminatorValues) {
45064
+ if (optionsMap.has(value)) {
45065
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
45066
+ }
45067
+ optionsMap.set(value, type);
45068
+ }
45069
+ }
45070
+ return new _ZodDiscriminatedUnion({
45071
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
45072
+ discriminator,
45073
+ options,
45074
+ optionsMap,
45075
+ ...processCreateParams(params)
45076
+ });
45077
+ }
45078
+ };
45079
+ function mergeValues(a, b) {
45080
+ const aType = getParsedType(a);
45081
+ const bType = getParsedType(b);
45082
+ if (a === b) {
45083
+ return { valid: true, data: a };
45084
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
45085
+ const bKeys = util.objectKeys(b);
45086
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
45087
+ const newObj = { ...a, ...b };
45088
+ for (const key of sharedKeys) {
45089
+ const sharedValue = mergeValues(a[key], b[key]);
45090
+ if (!sharedValue.valid) {
45091
+ return { valid: false };
45092
+ }
45093
+ newObj[key] = sharedValue.data;
45094
+ }
45095
+ return { valid: true, data: newObj };
45096
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
45097
+ if (a.length !== b.length) {
45098
+ return { valid: false };
45099
+ }
45100
+ const newArray = [];
45101
+ for (let index2 = 0; index2 < a.length; index2++) {
45102
+ const itemA = a[index2];
45103
+ const itemB = b[index2];
45104
+ const sharedValue = mergeValues(itemA, itemB);
45105
+ if (!sharedValue.valid) {
45106
+ return { valid: false };
45107
+ }
45108
+ newArray.push(sharedValue.data);
45109
+ }
45110
+ return { valid: true, data: newArray };
45111
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
45112
+ return { valid: true, data: a };
45113
+ } else {
45114
+ return { valid: false };
45115
+ }
45116
+ }
45117
+ var ZodIntersection = class extends ZodType {
45118
+ _parse(input) {
45119
+ const { status, ctx } = this._processInputParams(input);
45120
+ const handleParsed = (parsedLeft, parsedRight) => {
45121
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
45122
+ return INVALID;
45123
+ }
45124
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
45125
+ if (!merged.valid) {
45126
+ addIssueToContext(ctx, {
45127
+ code: ZodIssueCode.invalid_intersection_types
45128
+ });
45129
+ return INVALID;
45130
+ }
45131
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
45132
+ status.dirty();
45133
+ }
45134
+ return { status: status.value, value: merged.data };
45135
+ };
45136
+ if (ctx.common.async) {
45137
+ return Promise.all([
45138
+ this._def.left._parseAsync({
45139
+ data: ctx.data,
45140
+ path: ctx.path,
45141
+ parent: ctx
45142
+ }),
45143
+ this._def.right._parseAsync({
45144
+ data: ctx.data,
45145
+ path: ctx.path,
45146
+ parent: ctx
45147
+ })
45148
+ ]).then(([left, right]) => handleParsed(left, right));
45149
+ } else {
45150
+ return handleParsed(this._def.left._parseSync({
45151
+ data: ctx.data,
45152
+ path: ctx.path,
45153
+ parent: ctx
45154
+ }), this._def.right._parseSync({
45155
+ data: ctx.data,
45156
+ path: ctx.path,
45157
+ parent: ctx
45158
+ }));
45159
+ }
45160
+ }
45161
+ };
45162
+ ZodIntersection.create = (left, right, params) => {
45163
+ return new ZodIntersection({
45164
+ left,
45165
+ right,
45166
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
45167
+ ...processCreateParams(params)
45168
+ });
45169
+ };
45170
+ var ZodTuple = class _ZodTuple extends ZodType {
45171
+ _parse(input) {
45172
+ const { status, ctx } = this._processInputParams(input);
45173
+ if (ctx.parsedType !== ZodParsedType.array) {
45174
+ addIssueToContext(ctx, {
45175
+ code: ZodIssueCode.invalid_type,
45176
+ expected: ZodParsedType.array,
45177
+ received: ctx.parsedType
45178
+ });
45179
+ return INVALID;
45180
+ }
45181
+ if (ctx.data.length < this._def.items.length) {
45182
+ addIssueToContext(ctx, {
45183
+ code: ZodIssueCode.too_small,
45184
+ minimum: this._def.items.length,
45185
+ inclusive: true,
45186
+ exact: false,
45187
+ type: "array"
45188
+ });
45189
+ return INVALID;
45190
+ }
45191
+ const rest = this._def.rest;
45192
+ if (!rest && ctx.data.length > this._def.items.length) {
45193
+ addIssueToContext(ctx, {
45194
+ code: ZodIssueCode.too_big,
45195
+ maximum: this._def.items.length,
45196
+ inclusive: true,
45197
+ exact: false,
45198
+ type: "array"
45199
+ });
45200
+ status.dirty();
45201
+ }
45202
+ const items = [...ctx.data].map((item, itemIndex) => {
45203
+ const schema = this._def.items[itemIndex] || this._def.rest;
45204
+ if (!schema)
45205
+ return null;
45206
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
45207
+ }).filter((x) => !!x);
45208
+ if (ctx.common.async) {
45209
+ return Promise.all(items).then((results) => {
45210
+ return ParseStatus.mergeArray(status, results);
45211
+ });
45212
+ } else {
45213
+ return ParseStatus.mergeArray(status, items);
45214
+ }
45215
+ }
45216
+ get items() {
45217
+ return this._def.items;
45218
+ }
45219
+ rest(rest) {
45220
+ return new _ZodTuple({
45221
+ ...this._def,
45222
+ rest
45223
+ });
45224
+ }
45225
+ };
45226
+ ZodTuple.create = (schemas, params) => {
45227
+ if (!Array.isArray(schemas)) {
45228
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
45229
+ }
45230
+ return new ZodTuple({
45231
+ items: schemas,
45232
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
45233
+ rest: null,
45234
+ ...processCreateParams(params)
45235
+ });
45236
+ };
45237
+ var ZodRecord = class _ZodRecord extends ZodType {
45238
+ get keySchema() {
45239
+ return this._def.keyType;
45240
+ }
45241
+ get valueSchema() {
45242
+ return this._def.valueType;
45243
+ }
45244
+ _parse(input) {
45245
+ const { status, ctx } = this._processInputParams(input);
45246
+ if (ctx.parsedType !== ZodParsedType.object) {
45247
+ addIssueToContext(ctx, {
45248
+ code: ZodIssueCode.invalid_type,
45249
+ expected: ZodParsedType.object,
45250
+ received: ctx.parsedType
45251
+ });
45252
+ return INVALID;
45253
+ }
45254
+ const pairs = [];
45255
+ const keyType = this._def.keyType;
45256
+ const valueType = this._def.valueType;
45257
+ for (const key in ctx.data) {
45258
+ pairs.push({
45259
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
45260
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
45261
+ alwaysSet: key in ctx.data
45262
+ });
45263
+ }
45264
+ if (ctx.common.async) {
45265
+ return ParseStatus.mergeObjectAsync(status, pairs);
45266
+ } else {
45267
+ return ParseStatus.mergeObjectSync(status, pairs);
45268
+ }
45269
+ }
45270
+ get element() {
45271
+ return this._def.valueType;
45272
+ }
45273
+ static create(first, second, third) {
45274
+ if (second instanceof ZodType) {
45275
+ return new _ZodRecord({
45276
+ keyType: first,
45277
+ valueType: second,
45278
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
45279
+ ...processCreateParams(third)
45280
+ });
45281
+ }
45282
+ return new _ZodRecord({
45283
+ keyType: ZodString.create(),
45284
+ valueType: first,
45285
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
45286
+ ...processCreateParams(second)
45287
+ });
45288
+ }
45289
+ };
45290
+ var ZodMap = class extends ZodType {
45291
+ get keySchema() {
45292
+ return this._def.keyType;
45293
+ }
45294
+ get valueSchema() {
45295
+ return this._def.valueType;
45296
+ }
45297
+ _parse(input) {
45298
+ const { status, ctx } = this._processInputParams(input);
45299
+ if (ctx.parsedType !== ZodParsedType.map) {
45300
+ addIssueToContext(ctx, {
45301
+ code: ZodIssueCode.invalid_type,
45302
+ expected: ZodParsedType.map,
45303
+ received: ctx.parsedType
45304
+ });
45305
+ return INVALID;
45306
+ }
45307
+ const keyType = this._def.keyType;
45308
+ const valueType = this._def.valueType;
45309
+ const pairs = [...ctx.data.entries()].map(([key, value], index2) => {
45310
+ return {
45311
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index2, "key"])),
45312
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index2, "value"]))
45313
+ };
45314
+ });
45315
+ if (ctx.common.async) {
45316
+ const finalMap = /* @__PURE__ */ new Map();
45317
+ return Promise.resolve().then(async () => {
45318
+ for (const pair of pairs) {
45319
+ const key = await pair.key;
45320
+ const value = await pair.value;
45321
+ if (key.status === "aborted" || value.status === "aborted") {
45322
+ return INVALID;
45323
+ }
45324
+ if (key.status === "dirty" || value.status === "dirty") {
45325
+ status.dirty();
45326
+ }
45327
+ finalMap.set(key.value, value.value);
45328
+ }
45329
+ return { status: status.value, value: finalMap };
45330
+ });
45331
+ } else {
45332
+ const finalMap = /* @__PURE__ */ new Map();
45333
+ for (const pair of pairs) {
45334
+ const key = pair.key;
45335
+ const value = pair.value;
45336
+ if (key.status === "aborted" || value.status === "aborted") {
45337
+ return INVALID;
45338
+ }
45339
+ if (key.status === "dirty" || value.status === "dirty") {
45340
+ status.dirty();
45341
+ }
45342
+ finalMap.set(key.value, value.value);
45343
+ }
45344
+ return { status: status.value, value: finalMap };
45345
+ }
45346
+ }
45347
+ };
45348
+ ZodMap.create = (keyType, valueType, params) => {
45349
+ return new ZodMap({
45350
+ valueType,
45351
+ keyType,
45352
+ typeName: ZodFirstPartyTypeKind.ZodMap,
45353
+ ...processCreateParams(params)
45354
+ });
45355
+ };
45356
+ var ZodSet = class _ZodSet extends ZodType {
45357
+ _parse(input) {
45358
+ const { status, ctx } = this._processInputParams(input);
45359
+ if (ctx.parsedType !== ZodParsedType.set) {
45360
+ addIssueToContext(ctx, {
45361
+ code: ZodIssueCode.invalid_type,
45362
+ expected: ZodParsedType.set,
45363
+ received: ctx.parsedType
45364
+ });
45365
+ return INVALID;
45366
+ }
45367
+ const def = this._def;
45368
+ if (def.minSize !== null) {
45369
+ if (ctx.data.size < def.minSize.value) {
45370
+ addIssueToContext(ctx, {
45371
+ code: ZodIssueCode.too_small,
45372
+ minimum: def.minSize.value,
45373
+ type: "set",
45374
+ inclusive: true,
45375
+ exact: false,
45376
+ message: def.minSize.message
45377
+ });
45378
+ status.dirty();
45379
+ }
45380
+ }
45381
+ if (def.maxSize !== null) {
45382
+ if (ctx.data.size > def.maxSize.value) {
45383
+ addIssueToContext(ctx, {
45384
+ code: ZodIssueCode.too_big,
45385
+ maximum: def.maxSize.value,
45386
+ type: "set",
45387
+ inclusive: true,
45388
+ exact: false,
45389
+ message: def.maxSize.message
45390
+ });
45391
+ status.dirty();
45392
+ }
45393
+ }
45394
+ const valueType = this._def.valueType;
45395
+ function finalizeSet(elements2) {
45396
+ const parsedSet = /* @__PURE__ */ new Set();
45397
+ for (const element of elements2) {
45398
+ if (element.status === "aborted")
45399
+ return INVALID;
45400
+ if (element.status === "dirty")
45401
+ status.dirty();
45402
+ parsedSet.add(element.value);
45403
+ }
45404
+ return { status: status.value, value: parsedSet };
45405
+ }
45406
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
45407
+ if (ctx.common.async) {
45408
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
45409
+ } else {
45410
+ return finalizeSet(elements);
45411
+ }
45412
+ }
45413
+ min(minSize, message) {
45414
+ return new _ZodSet({
45415
+ ...this._def,
45416
+ minSize: { value: minSize, message: errorUtil.toString(message) }
45417
+ });
45418
+ }
45419
+ max(maxSize, message) {
45420
+ return new _ZodSet({
45421
+ ...this._def,
45422
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
45423
+ });
45424
+ }
45425
+ size(size5, message) {
45426
+ return this.min(size5, message).max(size5, message);
45427
+ }
45428
+ nonempty(message) {
45429
+ return this.min(1, message);
45430
+ }
45431
+ };
45432
+ ZodSet.create = (valueType, params) => {
45433
+ return new ZodSet({
45434
+ valueType,
45435
+ minSize: null,
45436
+ maxSize: null,
45437
+ typeName: ZodFirstPartyTypeKind.ZodSet,
45438
+ ...processCreateParams(params)
45439
+ });
45440
+ };
45441
+ var ZodFunction = class _ZodFunction extends ZodType {
45442
+ constructor() {
45443
+ super(...arguments);
45444
+ this.validate = this.implement;
45445
+ }
45446
+ _parse(input) {
45447
+ const { ctx } = this._processInputParams(input);
45448
+ if (ctx.parsedType !== ZodParsedType.function) {
45449
+ addIssueToContext(ctx, {
45450
+ code: ZodIssueCode.invalid_type,
45451
+ expected: ZodParsedType.function,
45452
+ received: ctx.parsedType
45453
+ });
45454
+ return INVALID;
45455
+ }
45456
+ function makeArgsIssue(args, error) {
45457
+ return makeIssue({
45458
+ data: args,
45459
+ path: ctx.path,
45460
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
45461
+ issueData: {
45462
+ code: ZodIssueCode.invalid_arguments,
45463
+ argumentsError: error
45464
+ }
45465
+ });
45466
+ }
45467
+ function makeReturnsIssue(returns, error) {
45468
+ return makeIssue({
45469
+ data: returns,
45470
+ path: ctx.path,
45471
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
45472
+ issueData: {
45473
+ code: ZodIssueCode.invalid_return_type,
45474
+ returnTypeError: error
45475
+ }
45476
+ });
45477
+ }
45478
+ const params = { errorMap: ctx.common.contextualErrorMap };
45479
+ const fn = ctx.data;
45480
+ if (this._def.returns instanceof ZodPromise) {
45481
+ const me = this;
45482
+ return OK(async function(...args) {
45483
+ const error = new ZodError([]);
45484
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e7) => {
45485
+ error.addIssue(makeArgsIssue(args, e7));
45486
+ throw error;
45487
+ });
45488
+ const result = await Reflect.apply(fn, this, parsedArgs);
45489
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e7) => {
45490
+ error.addIssue(makeReturnsIssue(result, e7));
45491
+ throw error;
45492
+ });
45493
+ return parsedReturns;
45494
+ });
45495
+ } else {
45496
+ const me = this;
45497
+ return OK(function(...args) {
45498
+ const parsedArgs = me._def.args.safeParse(args, params);
45499
+ if (!parsedArgs.success) {
45500
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
45501
+ }
45502
+ const result = Reflect.apply(fn, this, parsedArgs.data);
45503
+ const parsedReturns = me._def.returns.safeParse(result, params);
45504
+ if (!parsedReturns.success) {
45505
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
45506
+ }
45507
+ return parsedReturns.data;
45508
+ });
45509
+ }
45510
+ }
45511
+ parameters() {
45512
+ return this._def.args;
45513
+ }
45514
+ returnType() {
45515
+ return this._def.returns;
45516
+ }
45517
+ args(...items) {
45518
+ return new _ZodFunction({
45519
+ ...this._def,
45520
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
45521
+ });
45522
+ }
45523
+ returns(returnType) {
45524
+ return new _ZodFunction({
45525
+ ...this._def,
45526
+ returns: returnType
45527
+ });
45528
+ }
45529
+ implement(func) {
45530
+ const validatedFunc = this.parse(func);
45531
+ return validatedFunc;
45532
+ }
45533
+ strictImplement(func) {
45534
+ const validatedFunc = this.parse(func);
45535
+ return validatedFunc;
45536
+ }
45537
+ static create(args, returns, params) {
45538
+ return new _ZodFunction({
45539
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
45540
+ returns: returns || ZodUnknown.create(),
45541
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
45542
+ ...processCreateParams(params)
45543
+ });
45544
+ }
45545
+ };
45546
+ var ZodLazy = class extends ZodType {
45547
+ get schema() {
45548
+ return this._def.getter();
45549
+ }
45550
+ _parse(input) {
45551
+ const { ctx } = this._processInputParams(input);
45552
+ const lazySchema = this._def.getter();
45553
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
45554
+ }
45555
+ };
45556
+ ZodLazy.create = (getter, params) => {
45557
+ return new ZodLazy({
45558
+ getter,
45559
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
45560
+ ...processCreateParams(params)
45561
+ });
45562
+ };
45563
+ var ZodLiteral = class extends ZodType {
45564
+ _parse(input) {
45565
+ if (input.data !== this._def.value) {
45566
+ const ctx = this._getOrReturnCtx(input);
45567
+ addIssueToContext(ctx, {
45568
+ received: ctx.data,
45569
+ code: ZodIssueCode.invalid_literal,
45570
+ expected: this._def.value
45571
+ });
45572
+ return INVALID;
45573
+ }
45574
+ return { status: "valid", value: input.data };
45575
+ }
45576
+ get value() {
45577
+ return this._def.value;
45578
+ }
45579
+ };
45580
+ ZodLiteral.create = (value, params) => {
45581
+ return new ZodLiteral({
45582
+ value,
45583
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
45584
+ ...processCreateParams(params)
45585
+ });
45586
+ };
45587
+ function createZodEnum(values, params) {
45588
+ return new ZodEnum({
45589
+ values,
45590
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
45591
+ ...processCreateParams(params)
45592
+ });
45593
+ }
45594
+ var ZodEnum = class _ZodEnum extends ZodType {
45595
+ _parse(input) {
45596
+ if (typeof input.data !== "string") {
45597
+ const ctx = this._getOrReturnCtx(input);
45598
+ const expectedValues = this._def.values;
45599
+ addIssueToContext(ctx, {
45600
+ expected: util.joinValues(expectedValues),
45601
+ received: ctx.parsedType,
45602
+ code: ZodIssueCode.invalid_type
45603
+ });
45604
+ return INVALID;
45605
+ }
45606
+ if (!this._cache) {
45607
+ this._cache = new Set(this._def.values);
45608
+ }
45609
+ if (!this._cache.has(input.data)) {
45610
+ const ctx = this._getOrReturnCtx(input);
45611
+ const expectedValues = this._def.values;
45612
+ addIssueToContext(ctx, {
45613
+ received: ctx.data,
45614
+ code: ZodIssueCode.invalid_enum_value,
45615
+ options: expectedValues
45616
+ });
45617
+ return INVALID;
45618
+ }
45619
+ return OK(input.data);
45620
+ }
45621
+ get options() {
45622
+ return this._def.values;
45623
+ }
45624
+ get enum() {
45625
+ const enumValues = {};
45626
+ for (const val of this._def.values) {
45627
+ enumValues[val] = val;
45628
+ }
45629
+ return enumValues;
45630
+ }
45631
+ get Values() {
45632
+ const enumValues = {};
45633
+ for (const val of this._def.values) {
45634
+ enumValues[val] = val;
45635
+ }
45636
+ return enumValues;
45637
+ }
45638
+ get Enum() {
45639
+ const enumValues = {};
45640
+ for (const val of this._def.values) {
45641
+ enumValues[val] = val;
45642
+ }
45643
+ return enumValues;
45644
+ }
45645
+ extract(values, newDef = this._def) {
45646
+ return _ZodEnum.create(values, {
45647
+ ...this._def,
45648
+ ...newDef
45649
+ });
45650
+ }
45651
+ exclude(values, newDef = this._def) {
45652
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
45653
+ ...this._def,
45654
+ ...newDef
45655
+ });
45656
+ }
45657
+ };
45658
+ ZodEnum.create = createZodEnum;
45659
+ var ZodNativeEnum = class extends ZodType {
45660
+ _parse(input) {
45661
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
45662
+ const ctx = this._getOrReturnCtx(input);
45663
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
45664
+ const expectedValues = util.objectValues(nativeEnumValues);
45665
+ addIssueToContext(ctx, {
45666
+ expected: util.joinValues(expectedValues),
45667
+ received: ctx.parsedType,
45668
+ code: ZodIssueCode.invalid_type
45669
+ });
45670
+ return INVALID;
45671
+ }
45672
+ if (!this._cache) {
45673
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
45674
+ }
45675
+ if (!this._cache.has(input.data)) {
45676
+ const expectedValues = util.objectValues(nativeEnumValues);
45677
+ addIssueToContext(ctx, {
45678
+ received: ctx.data,
45679
+ code: ZodIssueCode.invalid_enum_value,
45680
+ options: expectedValues
45681
+ });
45682
+ return INVALID;
45683
+ }
45684
+ return OK(input.data);
45685
+ }
45686
+ get enum() {
45687
+ return this._def.values;
45688
+ }
45689
+ };
45690
+ ZodNativeEnum.create = (values, params) => {
45691
+ return new ZodNativeEnum({
45692
+ values,
45693
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
45694
+ ...processCreateParams(params)
45695
+ });
45696
+ };
45697
+ var ZodPromise = class extends ZodType {
45698
+ unwrap() {
45699
+ return this._def.type;
45700
+ }
45701
+ _parse(input) {
45702
+ const { ctx } = this._processInputParams(input);
45703
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
45704
+ addIssueToContext(ctx, {
45705
+ code: ZodIssueCode.invalid_type,
45706
+ expected: ZodParsedType.promise,
45707
+ received: ctx.parsedType
45708
+ });
45709
+ return INVALID;
45710
+ }
45711
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
45712
+ return OK(promisified.then((data) => {
45713
+ return this._def.type.parseAsync(data, {
45714
+ path: ctx.path,
45715
+ errorMap: ctx.common.contextualErrorMap
45716
+ });
45717
+ }));
45718
+ }
45719
+ };
45720
+ ZodPromise.create = (schema, params) => {
45721
+ return new ZodPromise({
45722
+ type: schema,
45723
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
45724
+ ...processCreateParams(params)
45725
+ });
45726
+ };
45727
+ var ZodEffects = class extends ZodType {
45728
+ innerType() {
45729
+ return this._def.schema;
45730
+ }
45731
+ sourceType() {
45732
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
45733
+ }
45734
+ _parse(input) {
45735
+ const { status, ctx } = this._processInputParams(input);
45736
+ const effect = this._def.effect || null;
45737
+ const checkCtx = {
45738
+ addIssue: (arg) => {
45739
+ addIssueToContext(ctx, arg);
45740
+ if (arg.fatal) {
45741
+ status.abort();
45742
+ } else {
45743
+ status.dirty();
45744
+ }
45745
+ },
45746
+ get path() {
45747
+ return ctx.path;
45748
+ }
45749
+ };
45750
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
45751
+ if (effect.type === "preprocess") {
45752
+ const processed = effect.transform(ctx.data, checkCtx);
45753
+ if (ctx.common.async) {
45754
+ return Promise.resolve(processed).then(async (processed2) => {
45755
+ if (status.value === "aborted")
45756
+ return INVALID;
45757
+ const result = await this._def.schema._parseAsync({
45758
+ data: processed2,
45759
+ path: ctx.path,
45760
+ parent: ctx
45761
+ });
45762
+ if (result.status === "aborted")
45763
+ return INVALID;
45764
+ if (result.status === "dirty")
45765
+ return DIRTY(result.value);
45766
+ if (status.value === "dirty")
45767
+ return DIRTY(result.value);
45768
+ return result;
45769
+ });
45770
+ } else {
45771
+ if (status.value === "aborted")
45772
+ return INVALID;
45773
+ const result = this._def.schema._parseSync({
45774
+ data: processed,
45775
+ path: ctx.path,
45776
+ parent: ctx
45777
+ });
45778
+ if (result.status === "aborted")
45779
+ return INVALID;
45780
+ if (result.status === "dirty")
45781
+ return DIRTY(result.value);
45782
+ if (status.value === "dirty")
45783
+ return DIRTY(result.value);
45784
+ return result;
45785
+ }
45786
+ }
45787
+ if (effect.type === "refinement") {
45788
+ const executeRefinement = (acc) => {
45789
+ const result = effect.refinement(acc, checkCtx);
45790
+ if (ctx.common.async) {
45791
+ return Promise.resolve(result);
45792
+ }
45793
+ if (result instanceof Promise) {
45794
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
45795
+ }
45796
+ return acc;
45797
+ };
45798
+ if (ctx.common.async === false) {
45799
+ const inner = this._def.schema._parseSync({
45800
+ data: ctx.data,
45801
+ path: ctx.path,
45802
+ parent: ctx
45803
+ });
45804
+ if (inner.status === "aborted")
45805
+ return INVALID;
45806
+ if (inner.status === "dirty")
45807
+ status.dirty();
45808
+ executeRefinement(inner.value);
45809
+ return { status: status.value, value: inner.value };
45810
+ } else {
45811
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
45812
+ if (inner.status === "aborted")
45813
+ return INVALID;
45814
+ if (inner.status === "dirty")
45815
+ status.dirty();
45816
+ return executeRefinement(inner.value).then(() => {
45817
+ return { status: status.value, value: inner.value };
45818
+ });
45819
+ });
45820
+ }
45821
+ }
45822
+ if (effect.type === "transform") {
45823
+ if (ctx.common.async === false) {
45824
+ const base2 = this._def.schema._parseSync({
45825
+ data: ctx.data,
45826
+ path: ctx.path,
45827
+ parent: ctx
45828
+ });
45829
+ if (!isValid(base2))
45830
+ return INVALID;
45831
+ const result = effect.transform(base2.value, checkCtx);
45832
+ if (result instanceof Promise) {
45833
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
45834
+ }
45835
+ return { status: status.value, value: result };
45836
+ } else {
45837
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base2) => {
45838
+ if (!isValid(base2))
45839
+ return INVALID;
45840
+ return Promise.resolve(effect.transform(base2.value, checkCtx)).then((result) => ({
45841
+ status: status.value,
45842
+ value: result
45843
+ }));
45844
+ });
45845
+ }
45846
+ }
45847
+ util.assertNever(effect);
45848
+ }
45849
+ };
45850
+ ZodEffects.create = (schema, effect, params) => {
45851
+ return new ZodEffects({
45852
+ schema,
45853
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
45854
+ effect,
45855
+ ...processCreateParams(params)
45856
+ });
45857
+ };
45858
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
45859
+ return new ZodEffects({
45860
+ schema,
45861
+ effect: { type: "preprocess", transform: preprocess },
45862
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
45863
+ ...processCreateParams(params)
45864
+ });
45865
+ };
45866
+ var ZodOptional = class extends ZodType {
45867
+ _parse(input) {
45868
+ const parsedType = this._getType(input);
45869
+ if (parsedType === ZodParsedType.undefined) {
45870
+ return OK(void 0);
45871
+ }
45872
+ return this._def.innerType._parse(input);
45873
+ }
45874
+ unwrap() {
45875
+ return this._def.innerType;
45876
+ }
45877
+ };
45878
+ ZodOptional.create = (type, params) => {
45879
+ return new ZodOptional({
45880
+ innerType: type,
45881
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
45882
+ ...processCreateParams(params)
45883
+ });
45884
+ };
45885
+ var ZodNullable = class extends ZodType {
45886
+ _parse(input) {
45887
+ const parsedType = this._getType(input);
45888
+ if (parsedType === ZodParsedType.null) {
45889
+ return OK(null);
45890
+ }
45891
+ return this._def.innerType._parse(input);
45892
+ }
45893
+ unwrap() {
45894
+ return this._def.innerType;
45895
+ }
45896
+ };
45897
+ ZodNullable.create = (type, params) => {
45898
+ return new ZodNullable({
45899
+ innerType: type,
45900
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
45901
+ ...processCreateParams(params)
45902
+ });
45903
+ };
45904
+ var ZodDefault = class extends ZodType {
45905
+ _parse(input) {
45906
+ const { ctx } = this._processInputParams(input);
45907
+ let data = ctx.data;
45908
+ if (ctx.parsedType === ZodParsedType.undefined) {
45909
+ data = this._def.defaultValue();
45910
+ }
45911
+ return this._def.innerType._parse({
45912
+ data,
45913
+ path: ctx.path,
45914
+ parent: ctx
45915
+ });
45916
+ }
45917
+ removeDefault() {
45918
+ return this._def.innerType;
45919
+ }
45920
+ };
45921
+ ZodDefault.create = (type, params) => {
45922
+ return new ZodDefault({
45923
+ innerType: type,
45924
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
45925
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
45926
+ ...processCreateParams(params)
45927
+ });
45928
+ };
45929
+ var ZodCatch = class extends ZodType {
45930
+ _parse(input) {
45931
+ const { ctx } = this._processInputParams(input);
45932
+ const newCtx = {
45933
+ ...ctx,
45934
+ common: {
45935
+ ...ctx.common,
45936
+ issues: []
45937
+ }
45938
+ };
45939
+ const result = this._def.innerType._parse({
45940
+ data: newCtx.data,
45941
+ path: newCtx.path,
45942
+ parent: {
45943
+ ...newCtx
45944
+ }
45945
+ });
45946
+ if (isAsync(result)) {
45947
+ return result.then((result2) => {
45948
+ return {
45949
+ status: "valid",
45950
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
45951
+ get error() {
45952
+ return new ZodError(newCtx.common.issues);
45953
+ },
45954
+ input: newCtx.data
45955
+ })
45956
+ };
45957
+ });
45958
+ } else {
45959
+ return {
45960
+ status: "valid",
45961
+ value: result.status === "valid" ? result.value : this._def.catchValue({
45962
+ get error() {
45963
+ return new ZodError(newCtx.common.issues);
45964
+ },
45965
+ input: newCtx.data
45966
+ })
45967
+ };
45968
+ }
45969
+ }
45970
+ removeCatch() {
45971
+ return this._def.innerType;
45972
+ }
45973
+ };
45974
+ ZodCatch.create = (type, params) => {
45975
+ return new ZodCatch({
45976
+ innerType: type,
45977
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
45978
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
45979
+ ...processCreateParams(params)
45980
+ });
45981
+ };
45982
+ var ZodNaN = class extends ZodType {
45983
+ _parse(input) {
45984
+ const parsedType = this._getType(input);
45985
+ if (parsedType !== ZodParsedType.nan) {
45986
+ const ctx = this._getOrReturnCtx(input);
45987
+ addIssueToContext(ctx, {
45988
+ code: ZodIssueCode.invalid_type,
45989
+ expected: ZodParsedType.nan,
45990
+ received: ctx.parsedType
45991
+ });
45992
+ return INVALID;
45993
+ }
45994
+ return { status: "valid", value: input.data };
45995
+ }
45996
+ };
45997
+ ZodNaN.create = (params) => {
45998
+ return new ZodNaN({
45999
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
46000
+ ...processCreateParams(params)
46001
+ });
46002
+ };
46003
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
46004
+ var ZodBranded = class extends ZodType {
46005
+ _parse(input) {
46006
+ const { ctx } = this._processInputParams(input);
46007
+ const data = ctx.data;
46008
+ return this._def.type._parse({
46009
+ data,
46010
+ path: ctx.path,
46011
+ parent: ctx
46012
+ });
46013
+ }
46014
+ unwrap() {
46015
+ return this._def.type;
46016
+ }
46017
+ };
46018
+ var ZodPipeline = class _ZodPipeline extends ZodType {
46019
+ _parse(input) {
46020
+ const { status, ctx } = this._processInputParams(input);
46021
+ if (ctx.common.async) {
46022
+ const handleAsync = async () => {
46023
+ const inResult = await this._def.in._parseAsync({
46024
+ data: ctx.data,
46025
+ path: ctx.path,
46026
+ parent: ctx
46027
+ });
46028
+ if (inResult.status === "aborted")
46029
+ return INVALID;
46030
+ if (inResult.status === "dirty") {
46031
+ status.dirty();
46032
+ return DIRTY(inResult.value);
46033
+ } else {
46034
+ return this._def.out._parseAsync({
46035
+ data: inResult.value,
46036
+ path: ctx.path,
46037
+ parent: ctx
46038
+ });
46039
+ }
46040
+ };
46041
+ return handleAsync();
46042
+ } else {
46043
+ const inResult = this._def.in._parseSync({
46044
+ data: ctx.data,
46045
+ path: ctx.path,
46046
+ parent: ctx
46047
+ });
46048
+ if (inResult.status === "aborted")
46049
+ return INVALID;
46050
+ if (inResult.status === "dirty") {
46051
+ status.dirty();
46052
+ return {
46053
+ status: "dirty",
46054
+ value: inResult.value
46055
+ };
46056
+ } else {
46057
+ return this._def.out._parseSync({
46058
+ data: inResult.value,
46059
+ path: ctx.path,
46060
+ parent: ctx
46061
+ });
46062
+ }
46063
+ }
46064
+ }
46065
+ static create(a, b) {
46066
+ return new _ZodPipeline({
46067
+ in: a,
46068
+ out: b,
46069
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
46070
+ });
46071
+ }
46072
+ };
46073
+ var ZodReadonly = class extends ZodType {
46074
+ _parse(input) {
46075
+ const result = this._def.innerType._parse(input);
46076
+ const freeze = (data) => {
46077
+ if (isValid(data)) {
46078
+ data.value = Object.freeze(data.value);
46079
+ }
46080
+ return data;
46081
+ };
46082
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
46083
+ }
46084
+ unwrap() {
46085
+ return this._def.innerType;
46086
+ }
46087
+ };
46088
+ ZodReadonly.create = (type, params) => {
46089
+ return new ZodReadonly({
46090
+ innerType: type,
46091
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
46092
+ ...processCreateParams(params)
46093
+ });
46094
+ };
46095
+ function cleanParams(params, data) {
46096
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
46097
+ const p2 = typeof p === "string" ? { message: p } : p;
46098
+ return p2;
46099
+ }
46100
+ function custom(check, _params = {}, fatal) {
46101
+ if (check)
46102
+ return ZodAny.create().superRefine((data, ctx) => {
46103
+ const r = check(data);
46104
+ if (r instanceof Promise) {
46105
+ return r.then((r2) => {
46106
+ if (!r2) {
46107
+ const params = cleanParams(_params, data);
46108
+ const _fatal = params.fatal ?? fatal ?? true;
46109
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
46110
+ }
46111
+ });
46112
+ }
46113
+ if (!r) {
46114
+ const params = cleanParams(_params, data);
46115
+ const _fatal = params.fatal ?? fatal ?? true;
46116
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
46117
+ }
46118
+ return;
46119
+ });
46120
+ return ZodAny.create();
46121
+ }
46122
+ var late = {
46123
+ object: ZodObject.lazycreate
46124
+ };
46125
+ var ZodFirstPartyTypeKind;
46126
+ (function(ZodFirstPartyTypeKind2) {
46127
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
46128
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
46129
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
46130
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
46131
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
46132
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
46133
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
46134
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
46135
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
46136
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
46137
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
46138
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
46139
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
46140
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
46141
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
46142
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
46143
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
46144
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
46145
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
46146
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
46147
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
46148
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
46149
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
46150
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
46151
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
46152
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
46153
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
46154
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
46155
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
46156
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
46157
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
46158
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
46159
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
46160
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
46161
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
46162
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
46163
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
46164
+ var instanceOfType = (cls, params = {
46165
+ message: `Input not instance of ${cls.name}`
46166
+ }) => custom((data) => data instanceof cls, params);
46167
+ var stringType = ZodString.create;
46168
+ var numberType = ZodNumber.create;
46169
+ var nanType = ZodNaN.create;
46170
+ var bigIntType = ZodBigInt.create;
46171
+ var booleanType = ZodBoolean.create;
46172
+ var dateType = ZodDate.create;
46173
+ var symbolType = ZodSymbol.create;
46174
+ var undefinedType = ZodUndefined.create;
46175
+ var nullType = ZodNull.create;
46176
+ var anyType = ZodAny.create;
46177
+ var unknownType = ZodUnknown.create;
46178
+ var neverType = ZodNever.create;
46179
+ var voidType = ZodVoid.create;
46180
+ var arrayType = ZodArray.create;
46181
+ var objectType = ZodObject.create;
46182
+ var strictObjectType = ZodObject.strictCreate;
46183
+ var unionType = ZodUnion.create;
46184
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
46185
+ var intersectionType = ZodIntersection.create;
46186
+ var tupleType = ZodTuple.create;
46187
+ var recordType = ZodRecord.create;
46188
+ var mapType = ZodMap.create;
46189
+ var setType = ZodSet.create;
46190
+ var functionType = ZodFunction.create;
46191
+ var lazyType = ZodLazy.create;
46192
+ var literalType = ZodLiteral.create;
46193
+ var enumType = ZodEnum.create;
46194
+ var nativeEnumType = ZodNativeEnum.create;
46195
+ var promiseType = ZodPromise.create;
46196
+ var effectsType = ZodEffects.create;
46197
+ var optionalType = ZodOptional.create;
46198
+ var nullableType = ZodNullable.create;
46199
+ var preprocessType = ZodEffects.createWithPreprocess;
46200
+ var pipelineType = ZodPipeline.create;
46201
+ var ostring = () => stringType().optional();
46202
+ var onumber = () => numberType().optional();
46203
+ var oboolean = () => booleanType().optional();
46204
+ var coerce = {
46205
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
46206
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
46207
+ boolean: ((arg) => ZodBoolean.create({
46208
+ ...arg,
46209
+ coerce: true
46210
+ })),
46211
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
46212
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
46213
+ };
46214
+ var NEVER = INVALID;
46215
+
46216
+ // node_modules/@x402/core/dist/esm/chunk-KMQH4MQI.mjs
46217
+ var NonEmptyString = external_exports.string().min(1);
46218
+ var Any = external_exports.record(external_exports.unknown());
46219
+ var OptionalAny = external_exports.record(external_exports.unknown()).optional().nullable();
46220
+ var NetworkSchemaV1 = NonEmptyString;
46221
+ var NetworkSchemaV2 = external_exports.string().min(3).refine((val) => val.includes(":"), {
46222
+ message: "Network must be in CAIP-2 format (e.g., 'eip155:84532')"
46223
+ });
46224
+ var NetworkSchema = external_exports.union([NetworkSchemaV1, NetworkSchemaV2]);
46225
+ var ResourceInfoSchema = external_exports.object({
46226
+ url: NonEmptyString,
46227
+ description: external_exports.string().optional(),
46228
+ mimeType: external_exports.string().optional()
46229
+ });
46230
+ var PaymentRequirementsV1Schema = external_exports.object({
46231
+ scheme: NonEmptyString,
46232
+ network: NetworkSchemaV1,
46233
+ maxAmountRequired: NonEmptyString,
46234
+ resource: NonEmptyString,
46235
+ // URL string in V1
46236
+ description: external_exports.string(),
46237
+ mimeType: external_exports.string().optional(),
46238
+ outputSchema: Any.optional().nullable(),
46239
+ payTo: NonEmptyString,
46240
+ maxTimeoutSeconds: external_exports.number().positive(),
46241
+ asset: NonEmptyString,
46242
+ extra: OptionalAny
46243
+ });
46244
+ var PaymentRequiredV1Schema = external_exports.object({
46245
+ x402Version: external_exports.literal(1),
46246
+ error: external_exports.string().optional(),
46247
+ accepts: external_exports.array(PaymentRequirementsV1Schema).min(1)
46248
+ });
46249
+ var PaymentPayloadV1Schema = external_exports.object({
46250
+ x402Version: external_exports.literal(1),
46251
+ scheme: NonEmptyString,
46252
+ network: NetworkSchemaV1,
46253
+ payload: Any
46254
+ });
46255
+ var PaymentRequirementsV2Schema = external_exports.object({
46256
+ scheme: NonEmptyString,
46257
+ network: NetworkSchemaV2,
46258
+ amount: NonEmptyString,
46259
+ asset: NonEmptyString,
46260
+ payTo: NonEmptyString,
46261
+ maxTimeoutSeconds: external_exports.number().positive(),
46262
+ extra: OptionalAny
46263
+ });
46264
+ var PaymentRequiredV2Schema = external_exports.object({
46265
+ x402Version: external_exports.literal(2),
46266
+ error: external_exports.string().optional(),
46267
+ resource: ResourceInfoSchema,
46268
+ accepts: external_exports.array(PaymentRequirementsV2Schema).min(1),
46269
+ extensions: OptionalAny
46270
+ });
46271
+ var PaymentPayloadV2Schema = external_exports.object({
46272
+ x402Version: external_exports.literal(2),
46273
+ resource: ResourceInfoSchema.optional(),
46274
+ accepted: PaymentRequirementsV2Schema,
46275
+ payload: Any,
46276
+ extensions: OptionalAny
46277
+ });
46278
+ var PaymentRequirementsSchema = external_exports.union([
46279
+ PaymentRequirementsV1Schema,
46280
+ PaymentRequirementsV2Schema
46281
+ ]);
46282
+ var PaymentRequiredSchema = external_exports.discriminatedUnion("x402Version", [
46283
+ PaymentRequiredV1Schema,
46284
+ PaymentRequiredV2Schema
46285
+ ]);
46286
+ var PaymentPayloadSchema = external_exports.discriminatedUnion("x402Version", [
46287
+ PaymentPayloadV1Schema,
46288
+ PaymentPayloadV2Schema
46289
+ ]);
46290
+
42156
46291
  // node_modules/@x402/core/dist/esm/chunk-VE37GDG2.mjs
42157
46292
  var x402Version = 2;
42158
46293
 
@@ -42196,7 +46331,36 @@ function safeBase64Decode(data) {
42196
46331
  return Buffer.from(data, "base64").toString("utf-8");
42197
46332
  }
42198
46333
 
42199
- // node_modules/@x402/core/dist/esm/chunk-5KCDBAZ7.mjs
46334
+ // node_modules/@x402/core/dist/esm/chunk-ACVTKVCM.mjs
46335
+ var verifyResponseSchema = external_exports.object({
46336
+ isValid: external_exports.boolean(),
46337
+ invalidReason: external_exports.string().nullish().transform((v) => v ?? void 0),
46338
+ invalidMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
46339
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
46340
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
46341
+ });
46342
+ var settleResponseSchema = external_exports.object({
46343
+ success: external_exports.boolean(),
46344
+ errorReason: external_exports.string().nullish().transform((v) => v ?? void 0),
46345
+ errorMessage: external_exports.string().nullish().transform((v) => v ?? void 0),
46346
+ payer: external_exports.string().nullish().transform((v) => v ?? void 0),
46347
+ transaction: external_exports.string(),
46348
+ network: external_exports.custom((value) => typeof value === "string"),
46349
+ extensions: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
46350
+ });
46351
+ var supportedKindSchema = external_exports.object({
46352
+ x402Version: external_exports.number(),
46353
+ scheme: external_exports.string(),
46354
+ network: external_exports.custom(
46355
+ (value) => typeof value === "string"
46356
+ ),
46357
+ extra: external_exports.record(external_exports.string(), external_exports.unknown()).nullish().transform((v) => v ?? void 0)
46358
+ });
46359
+ var supportedResponseSchema = external_exports.object({
46360
+ kinds: external_exports.array(supportedKindSchema),
46361
+ extensions: external_exports.array(external_exports.string()).default([]),
46362
+ signers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())).default({})
46363
+ });
42200
46364
  var x402HTTPClient = class {
42201
46365
  /**
42202
46366
  * Creates a new x402HTTPClient instance.
@@ -48486,7 +52650,7 @@ async function startProxy(options) {
48486
52650
  }
48487
52651
  return;
48488
52652
  }
48489
- if (req.url?.match(/^\/v1\/(?:x|partner)\//)) {
52653
+ if (req.url?.match(/^\/v1\/(?:x|partner|pm)\//)) {
48490
52654
  try {
48491
52655
  await proxyPartnerRequest(
48492
52656
  req,
@@ -50405,9 +54569,9 @@ data: [DONE]
50405
54569
  maxTokens,
50406
54570
  routingProfile ?? void 0
50407
54571
  );
50408
- logCost = costs.costEstimate;
54572
+ logCost = FREE_MODELS.has(logModel) ? 0 : costs.costEstimate;
50409
54573
  logBaseline = costs.baselineCost;
50410
- logSavings = costs.savings;
54574
+ logSavings = FREE_MODELS.has(logModel) ? 1 : costs.savings;
50411
54575
  }
50412
54576
  const entry = {
50413
54577
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),