@chainflip/sdk 0.2.17 → 0.2.19

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/funding.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  var ethers = require('ethers');
4
4
  var axios = require('axios');
5
- var zod = require('zod');
6
5
 
7
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
7
 
@@ -908,9 +907,3840 @@ var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
908
907
  const flip = ERC20__factory.connect(flipAddress, signer);
909
908
  return flip.balanceOf(await signer.getAddress());
910
909
  }, "getFlipBalance");
911
- var numberOrHex = zod.z.union([
912
- zod.z.string(),
913
- zod.z.number()
910
+
911
+ // ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
912
+ var util;
913
+ (function(util2) {
914
+ util2.assertEqual = (val) => val;
915
+ function assertIs(_arg) {
916
+ }
917
+ __name(assertIs, "assertIs");
918
+ util2.assertIs = assertIs;
919
+ function assertNever(_x) {
920
+ throw new Error();
921
+ }
922
+ __name(assertNever, "assertNever");
923
+ util2.assertNever = assertNever;
924
+ util2.arrayToEnum = (items) => {
925
+ const obj = {};
926
+ for (const item of items) {
927
+ obj[item] = item;
928
+ }
929
+ return obj;
930
+ };
931
+ util2.getValidEnumValues = (obj) => {
932
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
933
+ const filtered = {};
934
+ for (const k of validKeys) {
935
+ filtered[k] = obj[k];
936
+ }
937
+ return util2.objectValues(filtered);
938
+ };
939
+ util2.objectValues = (obj) => {
940
+ return util2.objectKeys(obj).map(function(e) {
941
+ return obj[e];
942
+ });
943
+ };
944
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
945
+ const keys = [];
946
+ for (const key in object) {
947
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
948
+ keys.push(key);
949
+ }
950
+ }
951
+ return keys;
952
+ };
953
+ util2.find = (arr, checker) => {
954
+ for (const item of arr) {
955
+ if (checker(item))
956
+ return item;
957
+ }
958
+ return void 0;
959
+ };
960
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
961
+ function joinValues(array, separator = " | ") {
962
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
963
+ }
964
+ __name(joinValues, "joinValues");
965
+ util2.joinValues = joinValues;
966
+ util2.jsonStringifyReplacer = (_, value) => {
967
+ if (typeof value === "bigint") {
968
+ return value.toString();
969
+ }
970
+ return value;
971
+ };
972
+ })(util || (util = {}));
973
+ var objectUtil;
974
+ (function(objectUtil2) {
975
+ objectUtil2.mergeShapes = (first, second) => {
976
+ return {
977
+ ...first,
978
+ ...second
979
+ // second overwrites first
980
+ };
981
+ };
982
+ })(objectUtil || (objectUtil = {}));
983
+ var ZodParsedType = util.arrayToEnum([
984
+ "string",
985
+ "nan",
986
+ "number",
987
+ "integer",
988
+ "float",
989
+ "boolean",
990
+ "date",
991
+ "bigint",
992
+ "symbol",
993
+ "function",
994
+ "undefined",
995
+ "null",
996
+ "array",
997
+ "object",
998
+ "unknown",
999
+ "promise",
1000
+ "void",
1001
+ "never",
1002
+ "map",
1003
+ "set"
1004
+ ]);
1005
+ var getParsedType = /* @__PURE__ */ __name((data) => {
1006
+ const t = typeof data;
1007
+ switch (t) {
1008
+ case "undefined":
1009
+ return ZodParsedType.undefined;
1010
+ case "string":
1011
+ return ZodParsedType.string;
1012
+ case "number":
1013
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1014
+ case "boolean":
1015
+ return ZodParsedType.boolean;
1016
+ case "function":
1017
+ return ZodParsedType.function;
1018
+ case "bigint":
1019
+ return ZodParsedType.bigint;
1020
+ case "symbol":
1021
+ return ZodParsedType.symbol;
1022
+ case "object":
1023
+ if (Array.isArray(data)) {
1024
+ return ZodParsedType.array;
1025
+ }
1026
+ if (data === null) {
1027
+ return ZodParsedType.null;
1028
+ }
1029
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1030
+ return ZodParsedType.promise;
1031
+ }
1032
+ if (typeof Map !== "undefined" && data instanceof Map) {
1033
+ return ZodParsedType.map;
1034
+ }
1035
+ if (typeof Set !== "undefined" && data instanceof Set) {
1036
+ return ZodParsedType.set;
1037
+ }
1038
+ if (typeof Date !== "undefined" && data instanceof Date) {
1039
+ return ZodParsedType.date;
1040
+ }
1041
+ return ZodParsedType.object;
1042
+ default:
1043
+ return ZodParsedType.unknown;
1044
+ }
1045
+ }, "getParsedType");
1046
+ var ZodIssueCode = util.arrayToEnum([
1047
+ "invalid_type",
1048
+ "invalid_literal",
1049
+ "custom",
1050
+ "invalid_union",
1051
+ "invalid_union_discriminator",
1052
+ "invalid_enum_value",
1053
+ "unrecognized_keys",
1054
+ "invalid_arguments",
1055
+ "invalid_return_type",
1056
+ "invalid_date",
1057
+ "invalid_string",
1058
+ "too_small",
1059
+ "too_big",
1060
+ "invalid_intersection_types",
1061
+ "not_multiple_of",
1062
+ "not_finite"
1063
+ ]);
1064
+ var quotelessJson = /* @__PURE__ */ __name((obj) => {
1065
+ const json = JSON.stringify(obj, null, 2);
1066
+ return json.replace(/"([^"]+)":/g, "$1:");
1067
+ }, "quotelessJson");
1068
+ var _ZodError = class _ZodError extends Error {
1069
+ constructor(issues) {
1070
+ super();
1071
+ this.issues = [];
1072
+ this.addIssue = (sub) => {
1073
+ this.issues = [...this.issues, sub];
1074
+ };
1075
+ this.addIssues = (subs = []) => {
1076
+ this.issues = [...this.issues, ...subs];
1077
+ };
1078
+ const actualProto = new.target.prototype;
1079
+ if (Object.setPrototypeOf) {
1080
+ Object.setPrototypeOf(this, actualProto);
1081
+ } else {
1082
+ this.__proto__ = actualProto;
1083
+ }
1084
+ this.name = "ZodError";
1085
+ this.issues = issues;
1086
+ }
1087
+ get errors() {
1088
+ return this.issues;
1089
+ }
1090
+ format(_mapper) {
1091
+ const mapper = _mapper || function(issue) {
1092
+ return issue.message;
1093
+ };
1094
+ const fieldErrors = { _errors: [] };
1095
+ const processError = /* @__PURE__ */ __name((error) => {
1096
+ for (const issue of error.issues) {
1097
+ if (issue.code === "invalid_union") {
1098
+ issue.unionErrors.map(processError);
1099
+ } else if (issue.code === "invalid_return_type") {
1100
+ processError(issue.returnTypeError);
1101
+ } else if (issue.code === "invalid_arguments") {
1102
+ processError(issue.argumentsError);
1103
+ } else if (issue.path.length === 0) {
1104
+ fieldErrors._errors.push(mapper(issue));
1105
+ } else {
1106
+ let curr = fieldErrors;
1107
+ let i = 0;
1108
+ while (i < issue.path.length) {
1109
+ const el = issue.path[i];
1110
+ const terminal = i === issue.path.length - 1;
1111
+ if (!terminal) {
1112
+ curr[el] = curr[el] || { _errors: [] };
1113
+ } else {
1114
+ curr[el] = curr[el] || { _errors: [] };
1115
+ curr[el]._errors.push(mapper(issue));
1116
+ }
1117
+ curr = curr[el];
1118
+ i++;
1119
+ }
1120
+ }
1121
+ }
1122
+ }, "processError");
1123
+ processError(this);
1124
+ return fieldErrors;
1125
+ }
1126
+ toString() {
1127
+ return this.message;
1128
+ }
1129
+ get message() {
1130
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1131
+ }
1132
+ get isEmpty() {
1133
+ return this.issues.length === 0;
1134
+ }
1135
+ flatten(mapper = (issue) => issue.message) {
1136
+ const fieldErrors = {};
1137
+ const formErrors = [];
1138
+ for (const sub of this.issues) {
1139
+ if (sub.path.length > 0) {
1140
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1141
+ fieldErrors[sub.path[0]].push(mapper(sub));
1142
+ } else {
1143
+ formErrors.push(mapper(sub));
1144
+ }
1145
+ }
1146
+ return { formErrors, fieldErrors };
1147
+ }
1148
+ get formErrors() {
1149
+ return this.flatten();
1150
+ }
1151
+ };
1152
+ __name(_ZodError, "ZodError");
1153
+ var ZodError = _ZodError;
1154
+ ZodError.create = (issues) => {
1155
+ const error = new ZodError(issues);
1156
+ return error;
1157
+ };
1158
+ var errorMap = /* @__PURE__ */ __name((issue, _ctx) => {
1159
+ let message;
1160
+ switch (issue.code) {
1161
+ case ZodIssueCode.invalid_type:
1162
+ if (issue.received === ZodParsedType.undefined) {
1163
+ message = "Required";
1164
+ } else {
1165
+ message = `Expected ${issue.expected}, received ${issue.received}`;
1166
+ }
1167
+ break;
1168
+ case ZodIssueCode.invalid_literal:
1169
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
1170
+ break;
1171
+ case ZodIssueCode.unrecognized_keys:
1172
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
1173
+ break;
1174
+ case ZodIssueCode.invalid_union:
1175
+ message = `Invalid input`;
1176
+ break;
1177
+ case ZodIssueCode.invalid_union_discriminator:
1178
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
1179
+ break;
1180
+ case ZodIssueCode.invalid_enum_value:
1181
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
1182
+ break;
1183
+ case ZodIssueCode.invalid_arguments:
1184
+ message = `Invalid function arguments`;
1185
+ break;
1186
+ case ZodIssueCode.invalid_return_type:
1187
+ message = `Invalid function return type`;
1188
+ break;
1189
+ case ZodIssueCode.invalid_date:
1190
+ message = `Invalid date`;
1191
+ break;
1192
+ case ZodIssueCode.invalid_string:
1193
+ if (typeof issue.validation === "object") {
1194
+ if ("includes" in issue.validation) {
1195
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1196
+ if (typeof issue.validation.position === "number") {
1197
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1198
+ }
1199
+ } else if ("startsWith" in issue.validation) {
1200
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1201
+ } else if ("endsWith" in issue.validation) {
1202
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1203
+ } else {
1204
+ util.assertNever(issue.validation);
1205
+ }
1206
+ } else if (issue.validation !== "regex") {
1207
+ message = `Invalid ${issue.validation}`;
1208
+ } else {
1209
+ message = "Invalid";
1210
+ }
1211
+ break;
1212
+ case ZodIssueCode.too_small:
1213
+ if (issue.type === "array")
1214
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1215
+ else if (issue.type === "string")
1216
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1217
+ else if (issue.type === "number")
1218
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1219
+ else if (issue.type === "date")
1220
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1221
+ else
1222
+ message = "Invalid input";
1223
+ break;
1224
+ case ZodIssueCode.too_big:
1225
+ if (issue.type === "array")
1226
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1227
+ else if (issue.type === "string")
1228
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1229
+ else if (issue.type === "number")
1230
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1231
+ else if (issue.type === "bigint")
1232
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1233
+ else if (issue.type === "date")
1234
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1235
+ else
1236
+ message = "Invalid input";
1237
+ break;
1238
+ case ZodIssueCode.custom:
1239
+ message = `Invalid input`;
1240
+ break;
1241
+ case ZodIssueCode.invalid_intersection_types:
1242
+ message = `Intersection results could not be merged`;
1243
+ break;
1244
+ case ZodIssueCode.not_multiple_of:
1245
+ message = `Number must be a multiple of ${issue.multipleOf}`;
1246
+ break;
1247
+ case ZodIssueCode.not_finite:
1248
+ message = "Number must be finite";
1249
+ break;
1250
+ default:
1251
+ message = _ctx.defaultError;
1252
+ util.assertNever(issue);
1253
+ }
1254
+ return { message };
1255
+ }, "errorMap");
1256
+ var overrideErrorMap = errorMap;
1257
+ function setErrorMap(map) {
1258
+ overrideErrorMap = map;
1259
+ }
1260
+ __name(setErrorMap, "setErrorMap");
1261
+ function getErrorMap() {
1262
+ return overrideErrorMap;
1263
+ }
1264
+ __name(getErrorMap, "getErrorMap");
1265
+ var makeIssue = /* @__PURE__ */ __name((params) => {
1266
+ const { data, path, errorMaps, issueData } = params;
1267
+ const fullPath = [...path, ...issueData.path || []];
1268
+ const fullIssue = {
1269
+ ...issueData,
1270
+ path: fullPath
1271
+ };
1272
+ let errorMessage = "";
1273
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
1274
+ for (const map of maps) {
1275
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1276
+ }
1277
+ return {
1278
+ ...issueData,
1279
+ path: fullPath,
1280
+ message: issueData.message || errorMessage
1281
+ };
1282
+ }, "makeIssue");
1283
+ var EMPTY_PATH = [];
1284
+ function addIssueToContext(ctx, issueData) {
1285
+ const issue = makeIssue({
1286
+ issueData,
1287
+ data: ctx.data,
1288
+ path: ctx.path,
1289
+ errorMaps: [
1290
+ ctx.common.contextualErrorMap,
1291
+ ctx.schemaErrorMap,
1292
+ getErrorMap(),
1293
+ errorMap
1294
+ // then global default map
1295
+ ].filter((x) => !!x)
1296
+ });
1297
+ ctx.common.issues.push(issue);
1298
+ }
1299
+ __name(addIssueToContext, "addIssueToContext");
1300
+ var _ParseStatus = class _ParseStatus {
1301
+ constructor() {
1302
+ this.value = "valid";
1303
+ }
1304
+ dirty() {
1305
+ if (this.value === "valid")
1306
+ this.value = "dirty";
1307
+ }
1308
+ abort() {
1309
+ if (this.value !== "aborted")
1310
+ this.value = "aborted";
1311
+ }
1312
+ static mergeArray(status, results) {
1313
+ const arrayValue = [];
1314
+ for (const s of results) {
1315
+ if (s.status === "aborted")
1316
+ return INVALID;
1317
+ if (s.status === "dirty")
1318
+ status.dirty();
1319
+ arrayValue.push(s.value);
1320
+ }
1321
+ return { status: status.value, value: arrayValue };
1322
+ }
1323
+ static async mergeObjectAsync(status, pairs) {
1324
+ const syncPairs = [];
1325
+ for (const pair of pairs) {
1326
+ syncPairs.push({
1327
+ key: await pair.key,
1328
+ value: await pair.value
1329
+ });
1330
+ }
1331
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
1332
+ }
1333
+ static mergeObjectSync(status, pairs) {
1334
+ const finalObject = {};
1335
+ for (const pair of pairs) {
1336
+ const { key, value } = pair;
1337
+ if (key.status === "aborted")
1338
+ return INVALID;
1339
+ if (value.status === "aborted")
1340
+ return INVALID;
1341
+ if (key.status === "dirty")
1342
+ status.dirty();
1343
+ if (value.status === "dirty")
1344
+ status.dirty();
1345
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1346
+ finalObject[key.value] = value.value;
1347
+ }
1348
+ }
1349
+ return { status: status.value, value: finalObject };
1350
+ }
1351
+ };
1352
+ __name(_ParseStatus, "ParseStatus");
1353
+ var ParseStatus = _ParseStatus;
1354
+ var INVALID = Object.freeze({
1355
+ status: "aborted"
1356
+ });
1357
+ var DIRTY = /* @__PURE__ */ __name((value) => ({ status: "dirty", value }), "DIRTY");
1358
+ var OK = /* @__PURE__ */ __name((value) => ({ status: "valid", value }), "OK");
1359
+ var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted");
1360
+ var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
1361
+ var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
1362
+ var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
1363
+ var errorUtil;
1364
+ (function(errorUtil2) {
1365
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1366
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1367
+ })(errorUtil || (errorUtil = {}));
1368
+ var _ParseInputLazyPath = class _ParseInputLazyPath {
1369
+ constructor(parent, value, path, key) {
1370
+ this._cachedPath = [];
1371
+ this.parent = parent;
1372
+ this.data = value;
1373
+ this._path = path;
1374
+ this._key = key;
1375
+ }
1376
+ get path() {
1377
+ if (!this._cachedPath.length) {
1378
+ if (this._key instanceof Array) {
1379
+ this._cachedPath.push(...this._path, ...this._key);
1380
+ } else {
1381
+ this._cachedPath.push(...this._path, this._key);
1382
+ }
1383
+ }
1384
+ return this._cachedPath;
1385
+ }
1386
+ };
1387
+ __name(_ParseInputLazyPath, "ParseInputLazyPath");
1388
+ var ParseInputLazyPath = _ParseInputLazyPath;
1389
+ var handleResult = /* @__PURE__ */ __name((ctx, result) => {
1390
+ if (isValid(result)) {
1391
+ return { success: true, data: result.value };
1392
+ } else {
1393
+ if (!ctx.common.issues.length) {
1394
+ throw new Error("Validation failed but no issues detected.");
1395
+ }
1396
+ return {
1397
+ success: false,
1398
+ get error() {
1399
+ if (this._error)
1400
+ return this._error;
1401
+ const error = new ZodError(ctx.common.issues);
1402
+ this._error = error;
1403
+ return this._error;
1404
+ }
1405
+ };
1406
+ }
1407
+ }, "handleResult");
1408
+ function processCreateParams(params) {
1409
+ if (!params)
1410
+ return {};
1411
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
1412
+ if (errorMap2 && (invalid_type_error || required_error)) {
1413
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1414
+ }
1415
+ if (errorMap2)
1416
+ return { errorMap: errorMap2, description };
1417
+ const customMap = /* @__PURE__ */ __name((iss, ctx) => {
1418
+ if (iss.code !== "invalid_type")
1419
+ return { message: ctx.defaultError };
1420
+ if (typeof ctx.data === "undefined") {
1421
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1422
+ }
1423
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1424
+ }, "customMap");
1425
+ return { errorMap: customMap, description };
1426
+ }
1427
+ __name(processCreateParams, "processCreateParams");
1428
+ var _ZodType = class _ZodType {
1429
+ constructor(def) {
1430
+ this.spa = this.safeParseAsync;
1431
+ this._def = def;
1432
+ this.parse = this.parse.bind(this);
1433
+ this.safeParse = this.safeParse.bind(this);
1434
+ this.parseAsync = this.parseAsync.bind(this);
1435
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1436
+ this.spa = this.spa.bind(this);
1437
+ this.refine = this.refine.bind(this);
1438
+ this.refinement = this.refinement.bind(this);
1439
+ this.superRefine = this.superRefine.bind(this);
1440
+ this.optional = this.optional.bind(this);
1441
+ this.nullable = this.nullable.bind(this);
1442
+ this.nullish = this.nullish.bind(this);
1443
+ this.array = this.array.bind(this);
1444
+ this.promise = this.promise.bind(this);
1445
+ this.or = this.or.bind(this);
1446
+ this.and = this.and.bind(this);
1447
+ this.transform = this.transform.bind(this);
1448
+ this.brand = this.brand.bind(this);
1449
+ this.default = this.default.bind(this);
1450
+ this.catch = this.catch.bind(this);
1451
+ this.describe = this.describe.bind(this);
1452
+ this.pipe = this.pipe.bind(this);
1453
+ this.readonly = this.readonly.bind(this);
1454
+ this.isNullable = this.isNullable.bind(this);
1455
+ this.isOptional = this.isOptional.bind(this);
1456
+ }
1457
+ get description() {
1458
+ return this._def.description;
1459
+ }
1460
+ _getType(input) {
1461
+ return getParsedType(input.data);
1462
+ }
1463
+ _getOrReturnCtx(input, ctx) {
1464
+ return ctx || {
1465
+ common: input.parent.common,
1466
+ data: input.data,
1467
+ parsedType: getParsedType(input.data),
1468
+ schemaErrorMap: this._def.errorMap,
1469
+ path: input.path,
1470
+ parent: input.parent
1471
+ };
1472
+ }
1473
+ _processInputParams(input) {
1474
+ return {
1475
+ status: new ParseStatus(),
1476
+ ctx: {
1477
+ common: input.parent.common,
1478
+ data: input.data,
1479
+ parsedType: getParsedType(input.data),
1480
+ schemaErrorMap: this._def.errorMap,
1481
+ path: input.path,
1482
+ parent: input.parent
1483
+ }
1484
+ };
1485
+ }
1486
+ _parseSync(input) {
1487
+ const result = this._parse(input);
1488
+ if (isAsync(result)) {
1489
+ throw new Error("Synchronous parse encountered promise.");
1490
+ }
1491
+ return result;
1492
+ }
1493
+ _parseAsync(input) {
1494
+ const result = this._parse(input);
1495
+ return Promise.resolve(result);
1496
+ }
1497
+ parse(data, params) {
1498
+ const result = this.safeParse(data, params);
1499
+ if (result.success)
1500
+ return result.data;
1501
+ throw result.error;
1502
+ }
1503
+ safeParse(data, params) {
1504
+ var _a;
1505
+ const ctx = {
1506
+ common: {
1507
+ issues: [],
1508
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
1509
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
1510
+ },
1511
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1512
+ schemaErrorMap: this._def.errorMap,
1513
+ parent: null,
1514
+ data,
1515
+ parsedType: getParsedType(data)
1516
+ };
1517
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1518
+ return handleResult(ctx, result);
1519
+ }
1520
+ async parseAsync(data, params) {
1521
+ const result = await this.safeParseAsync(data, params);
1522
+ if (result.success)
1523
+ return result.data;
1524
+ throw result.error;
1525
+ }
1526
+ async safeParseAsync(data, params) {
1527
+ const ctx = {
1528
+ common: {
1529
+ issues: [],
1530
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
1531
+ async: true
1532
+ },
1533
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1534
+ schemaErrorMap: this._def.errorMap,
1535
+ parent: null,
1536
+ data,
1537
+ parsedType: getParsedType(data)
1538
+ };
1539
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1540
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1541
+ return handleResult(ctx, result);
1542
+ }
1543
+ refine(check, message) {
1544
+ const getIssueProperties = /* @__PURE__ */ __name((val) => {
1545
+ if (typeof message === "string" || typeof message === "undefined") {
1546
+ return { message };
1547
+ } else if (typeof message === "function") {
1548
+ return message(val);
1549
+ } else {
1550
+ return message;
1551
+ }
1552
+ }, "getIssueProperties");
1553
+ return this._refinement((val, ctx) => {
1554
+ const result = check(val);
1555
+ const setError = /* @__PURE__ */ __name(() => ctx.addIssue({
1556
+ code: ZodIssueCode.custom,
1557
+ ...getIssueProperties(val)
1558
+ }), "setError");
1559
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
1560
+ return result.then((data) => {
1561
+ if (!data) {
1562
+ setError();
1563
+ return false;
1564
+ } else {
1565
+ return true;
1566
+ }
1567
+ });
1568
+ }
1569
+ if (!result) {
1570
+ setError();
1571
+ return false;
1572
+ } else {
1573
+ return true;
1574
+ }
1575
+ });
1576
+ }
1577
+ refinement(check, refinementData) {
1578
+ return this._refinement((val, ctx) => {
1579
+ if (!check(val)) {
1580
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1581
+ return false;
1582
+ } else {
1583
+ return true;
1584
+ }
1585
+ });
1586
+ }
1587
+ _refinement(refinement) {
1588
+ return new ZodEffects({
1589
+ schema: this,
1590
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1591
+ effect: { type: "refinement", refinement }
1592
+ });
1593
+ }
1594
+ superRefine(refinement) {
1595
+ return this._refinement(refinement);
1596
+ }
1597
+ optional() {
1598
+ return ZodOptional.create(this, this._def);
1599
+ }
1600
+ nullable() {
1601
+ return ZodNullable.create(this, this._def);
1602
+ }
1603
+ nullish() {
1604
+ return this.nullable().optional();
1605
+ }
1606
+ array() {
1607
+ return ZodArray.create(this, this._def);
1608
+ }
1609
+ promise() {
1610
+ return ZodPromise.create(this, this._def);
1611
+ }
1612
+ or(option) {
1613
+ return ZodUnion.create([this, option], this._def);
1614
+ }
1615
+ and(incoming) {
1616
+ return ZodIntersection.create(this, incoming, this._def);
1617
+ }
1618
+ transform(transform) {
1619
+ return new ZodEffects({
1620
+ ...processCreateParams(this._def),
1621
+ schema: this,
1622
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1623
+ effect: { type: "transform", transform }
1624
+ });
1625
+ }
1626
+ default(def) {
1627
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1628
+ return new ZodDefault({
1629
+ ...processCreateParams(this._def),
1630
+ innerType: this,
1631
+ defaultValue: defaultValueFunc,
1632
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1633
+ });
1634
+ }
1635
+ brand() {
1636
+ return new ZodBranded({
1637
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1638
+ type: this,
1639
+ ...processCreateParams(this._def)
1640
+ });
1641
+ }
1642
+ catch(def) {
1643
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1644
+ return new ZodCatch({
1645
+ ...processCreateParams(this._def),
1646
+ innerType: this,
1647
+ catchValue: catchValueFunc,
1648
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1649
+ });
1650
+ }
1651
+ describe(description) {
1652
+ const This = this.constructor;
1653
+ return new This({
1654
+ ...this._def,
1655
+ description
1656
+ });
1657
+ }
1658
+ pipe(target) {
1659
+ return ZodPipeline.create(this, target);
1660
+ }
1661
+ readonly() {
1662
+ return ZodReadonly.create(this);
1663
+ }
1664
+ isOptional() {
1665
+ return this.safeParse(void 0).success;
1666
+ }
1667
+ isNullable() {
1668
+ return this.safeParse(null).success;
1669
+ }
1670
+ };
1671
+ __name(_ZodType, "ZodType");
1672
+ var ZodType = _ZodType;
1673
+ var cuidRegex = /^c[^\s-]{8,}$/i;
1674
+ var cuid2Regex = /^[a-z][a-z0-9]*$/;
1675
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
1676
+ 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;
1677
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1678
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1679
+ var emojiRegex;
1680
+ var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
1681
+ var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
1682
+ var datetimeRegex = /* @__PURE__ */ __name((args) => {
1683
+ if (args.precision) {
1684
+ if (args.offset) {
1685
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
1686
+ } else {
1687
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
1688
+ }
1689
+ } else if (args.precision === 0) {
1690
+ if (args.offset) {
1691
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
1692
+ } else {
1693
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
1694
+ }
1695
+ } else {
1696
+ if (args.offset) {
1697
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
1698
+ } else {
1699
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
1700
+ }
1701
+ }
1702
+ }, "datetimeRegex");
1703
+ function isValidIP(ip, version) {
1704
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1705
+ return true;
1706
+ }
1707
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1708
+ return true;
1709
+ }
1710
+ return false;
1711
+ }
1712
+ __name(isValidIP, "isValidIP");
1713
+ var _ZodString = class _ZodString extends ZodType {
1714
+ _parse(input) {
1715
+ if (this._def.coerce) {
1716
+ input.data = String(input.data);
1717
+ }
1718
+ const parsedType = this._getType(input);
1719
+ if (parsedType !== ZodParsedType.string) {
1720
+ const ctx2 = this._getOrReturnCtx(input);
1721
+ addIssueToContext(
1722
+ ctx2,
1723
+ {
1724
+ code: ZodIssueCode.invalid_type,
1725
+ expected: ZodParsedType.string,
1726
+ received: ctx2.parsedType
1727
+ }
1728
+ //
1729
+ );
1730
+ return INVALID;
1731
+ }
1732
+ const status = new ParseStatus();
1733
+ let ctx = void 0;
1734
+ for (const check of this._def.checks) {
1735
+ if (check.kind === "min") {
1736
+ if (input.data.length < check.value) {
1737
+ ctx = this._getOrReturnCtx(input, ctx);
1738
+ addIssueToContext(ctx, {
1739
+ code: ZodIssueCode.too_small,
1740
+ minimum: check.value,
1741
+ type: "string",
1742
+ inclusive: true,
1743
+ exact: false,
1744
+ message: check.message
1745
+ });
1746
+ status.dirty();
1747
+ }
1748
+ } else if (check.kind === "max") {
1749
+ if (input.data.length > check.value) {
1750
+ ctx = this._getOrReturnCtx(input, ctx);
1751
+ addIssueToContext(ctx, {
1752
+ code: ZodIssueCode.too_big,
1753
+ maximum: check.value,
1754
+ type: "string",
1755
+ inclusive: true,
1756
+ exact: false,
1757
+ message: check.message
1758
+ });
1759
+ status.dirty();
1760
+ }
1761
+ } else if (check.kind === "length") {
1762
+ const tooBig = input.data.length > check.value;
1763
+ const tooSmall = input.data.length < check.value;
1764
+ if (tooBig || tooSmall) {
1765
+ ctx = this._getOrReturnCtx(input, ctx);
1766
+ if (tooBig) {
1767
+ addIssueToContext(ctx, {
1768
+ code: ZodIssueCode.too_big,
1769
+ maximum: check.value,
1770
+ type: "string",
1771
+ inclusive: true,
1772
+ exact: true,
1773
+ message: check.message
1774
+ });
1775
+ } else if (tooSmall) {
1776
+ addIssueToContext(ctx, {
1777
+ code: ZodIssueCode.too_small,
1778
+ minimum: check.value,
1779
+ type: "string",
1780
+ inclusive: true,
1781
+ exact: true,
1782
+ message: check.message
1783
+ });
1784
+ }
1785
+ status.dirty();
1786
+ }
1787
+ } else if (check.kind === "email") {
1788
+ if (!emailRegex.test(input.data)) {
1789
+ ctx = this._getOrReturnCtx(input, ctx);
1790
+ addIssueToContext(ctx, {
1791
+ validation: "email",
1792
+ code: ZodIssueCode.invalid_string,
1793
+ message: check.message
1794
+ });
1795
+ status.dirty();
1796
+ }
1797
+ } else if (check.kind === "emoji") {
1798
+ if (!emojiRegex) {
1799
+ emojiRegex = new RegExp(_emojiRegex, "u");
1800
+ }
1801
+ if (!emojiRegex.test(input.data)) {
1802
+ ctx = this._getOrReturnCtx(input, ctx);
1803
+ addIssueToContext(ctx, {
1804
+ validation: "emoji",
1805
+ code: ZodIssueCode.invalid_string,
1806
+ message: check.message
1807
+ });
1808
+ status.dirty();
1809
+ }
1810
+ } else if (check.kind === "uuid") {
1811
+ if (!uuidRegex.test(input.data)) {
1812
+ ctx = this._getOrReturnCtx(input, ctx);
1813
+ addIssueToContext(ctx, {
1814
+ validation: "uuid",
1815
+ code: ZodIssueCode.invalid_string,
1816
+ message: check.message
1817
+ });
1818
+ status.dirty();
1819
+ }
1820
+ } else if (check.kind === "cuid") {
1821
+ if (!cuidRegex.test(input.data)) {
1822
+ ctx = this._getOrReturnCtx(input, ctx);
1823
+ addIssueToContext(ctx, {
1824
+ validation: "cuid",
1825
+ code: ZodIssueCode.invalid_string,
1826
+ message: check.message
1827
+ });
1828
+ status.dirty();
1829
+ }
1830
+ } else if (check.kind === "cuid2") {
1831
+ if (!cuid2Regex.test(input.data)) {
1832
+ ctx = this._getOrReturnCtx(input, ctx);
1833
+ addIssueToContext(ctx, {
1834
+ validation: "cuid2",
1835
+ code: ZodIssueCode.invalid_string,
1836
+ message: check.message
1837
+ });
1838
+ status.dirty();
1839
+ }
1840
+ } else if (check.kind === "ulid") {
1841
+ if (!ulidRegex.test(input.data)) {
1842
+ ctx = this._getOrReturnCtx(input, ctx);
1843
+ addIssueToContext(ctx, {
1844
+ validation: "ulid",
1845
+ code: ZodIssueCode.invalid_string,
1846
+ message: check.message
1847
+ });
1848
+ status.dirty();
1849
+ }
1850
+ } else if (check.kind === "url") {
1851
+ try {
1852
+ new URL(input.data);
1853
+ } catch (_a) {
1854
+ ctx = this._getOrReturnCtx(input, ctx);
1855
+ addIssueToContext(ctx, {
1856
+ validation: "url",
1857
+ code: ZodIssueCode.invalid_string,
1858
+ message: check.message
1859
+ });
1860
+ status.dirty();
1861
+ }
1862
+ } else if (check.kind === "regex") {
1863
+ check.regex.lastIndex = 0;
1864
+ const testResult = check.regex.test(input.data);
1865
+ if (!testResult) {
1866
+ ctx = this._getOrReturnCtx(input, ctx);
1867
+ addIssueToContext(ctx, {
1868
+ validation: "regex",
1869
+ code: ZodIssueCode.invalid_string,
1870
+ message: check.message
1871
+ });
1872
+ status.dirty();
1873
+ }
1874
+ } else if (check.kind === "trim") {
1875
+ input.data = input.data.trim();
1876
+ } else if (check.kind === "includes") {
1877
+ if (!input.data.includes(check.value, check.position)) {
1878
+ ctx = this._getOrReturnCtx(input, ctx);
1879
+ addIssueToContext(ctx, {
1880
+ code: ZodIssueCode.invalid_string,
1881
+ validation: { includes: check.value, position: check.position },
1882
+ message: check.message
1883
+ });
1884
+ status.dirty();
1885
+ }
1886
+ } else if (check.kind === "toLowerCase") {
1887
+ input.data = input.data.toLowerCase();
1888
+ } else if (check.kind === "toUpperCase") {
1889
+ input.data = input.data.toUpperCase();
1890
+ } else if (check.kind === "startsWith") {
1891
+ if (!input.data.startsWith(check.value)) {
1892
+ ctx = this._getOrReturnCtx(input, ctx);
1893
+ addIssueToContext(ctx, {
1894
+ code: ZodIssueCode.invalid_string,
1895
+ validation: { startsWith: check.value },
1896
+ message: check.message
1897
+ });
1898
+ status.dirty();
1899
+ }
1900
+ } else if (check.kind === "endsWith") {
1901
+ if (!input.data.endsWith(check.value)) {
1902
+ ctx = this._getOrReturnCtx(input, ctx);
1903
+ addIssueToContext(ctx, {
1904
+ code: ZodIssueCode.invalid_string,
1905
+ validation: { endsWith: check.value },
1906
+ message: check.message
1907
+ });
1908
+ status.dirty();
1909
+ }
1910
+ } else if (check.kind === "datetime") {
1911
+ const regex = datetimeRegex(check);
1912
+ if (!regex.test(input.data)) {
1913
+ ctx = this._getOrReturnCtx(input, ctx);
1914
+ addIssueToContext(ctx, {
1915
+ code: ZodIssueCode.invalid_string,
1916
+ validation: "datetime",
1917
+ message: check.message
1918
+ });
1919
+ status.dirty();
1920
+ }
1921
+ } else if (check.kind === "ip") {
1922
+ if (!isValidIP(input.data, check.version)) {
1923
+ ctx = this._getOrReturnCtx(input, ctx);
1924
+ addIssueToContext(ctx, {
1925
+ validation: "ip",
1926
+ code: ZodIssueCode.invalid_string,
1927
+ message: check.message
1928
+ });
1929
+ status.dirty();
1930
+ }
1931
+ } else {
1932
+ util.assertNever(check);
1933
+ }
1934
+ }
1935
+ return { status: status.value, value: input.data };
1936
+ }
1937
+ _regex(regex, validation, message) {
1938
+ return this.refinement((data) => regex.test(data), {
1939
+ validation,
1940
+ code: ZodIssueCode.invalid_string,
1941
+ ...errorUtil.errToObj(message)
1942
+ });
1943
+ }
1944
+ _addCheck(check) {
1945
+ return new _ZodString({
1946
+ ...this._def,
1947
+ checks: [...this._def.checks, check]
1948
+ });
1949
+ }
1950
+ email(message) {
1951
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1952
+ }
1953
+ url(message) {
1954
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1955
+ }
1956
+ emoji(message) {
1957
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1958
+ }
1959
+ uuid(message) {
1960
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1961
+ }
1962
+ cuid(message) {
1963
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1964
+ }
1965
+ cuid2(message) {
1966
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1967
+ }
1968
+ ulid(message) {
1969
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1970
+ }
1971
+ ip(options) {
1972
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1973
+ }
1974
+ datetime(options) {
1975
+ var _a;
1976
+ if (typeof options === "string") {
1977
+ return this._addCheck({
1978
+ kind: "datetime",
1979
+ precision: null,
1980
+ offset: false,
1981
+ message: options
1982
+ });
1983
+ }
1984
+ return this._addCheck({
1985
+ kind: "datetime",
1986
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
1987
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
1988
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
1989
+ });
1990
+ }
1991
+ regex(regex, message) {
1992
+ return this._addCheck({
1993
+ kind: "regex",
1994
+ regex,
1995
+ ...errorUtil.errToObj(message)
1996
+ });
1997
+ }
1998
+ includes(value, options) {
1999
+ return this._addCheck({
2000
+ kind: "includes",
2001
+ value,
2002
+ position: options === null || options === void 0 ? void 0 : options.position,
2003
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2004
+ });
2005
+ }
2006
+ startsWith(value, message) {
2007
+ return this._addCheck({
2008
+ kind: "startsWith",
2009
+ value,
2010
+ ...errorUtil.errToObj(message)
2011
+ });
2012
+ }
2013
+ endsWith(value, message) {
2014
+ return this._addCheck({
2015
+ kind: "endsWith",
2016
+ value,
2017
+ ...errorUtil.errToObj(message)
2018
+ });
2019
+ }
2020
+ min(minLength, message) {
2021
+ return this._addCheck({
2022
+ kind: "min",
2023
+ value: minLength,
2024
+ ...errorUtil.errToObj(message)
2025
+ });
2026
+ }
2027
+ max(maxLength, message) {
2028
+ return this._addCheck({
2029
+ kind: "max",
2030
+ value: maxLength,
2031
+ ...errorUtil.errToObj(message)
2032
+ });
2033
+ }
2034
+ length(len, message) {
2035
+ return this._addCheck({
2036
+ kind: "length",
2037
+ value: len,
2038
+ ...errorUtil.errToObj(message)
2039
+ });
2040
+ }
2041
+ /**
2042
+ * @deprecated Use z.string().min(1) instead.
2043
+ * @see {@link ZodString.min}
2044
+ */
2045
+ nonempty(message) {
2046
+ return this.min(1, errorUtil.errToObj(message));
2047
+ }
2048
+ trim() {
2049
+ return new _ZodString({
2050
+ ...this._def,
2051
+ checks: [...this._def.checks, { kind: "trim" }]
2052
+ });
2053
+ }
2054
+ toLowerCase() {
2055
+ return new _ZodString({
2056
+ ...this._def,
2057
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
2058
+ });
2059
+ }
2060
+ toUpperCase() {
2061
+ return new _ZodString({
2062
+ ...this._def,
2063
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
2064
+ });
2065
+ }
2066
+ get isDatetime() {
2067
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
2068
+ }
2069
+ get isEmail() {
2070
+ return !!this._def.checks.find((ch) => ch.kind === "email");
2071
+ }
2072
+ get isURL() {
2073
+ return !!this._def.checks.find((ch) => ch.kind === "url");
2074
+ }
2075
+ get isEmoji() {
2076
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
2077
+ }
2078
+ get isUUID() {
2079
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
2080
+ }
2081
+ get isCUID() {
2082
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
2083
+ }
2084
+ get isCUID2() {
2085
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2086
+ }
2087
+ get isULID() {
2088
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
2089
+ }
2090
+ get isIP() {
2091
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
2092
+ }
2093
+ get minLength() {
2094
+ let min = null;
2095
+ for (const ch of this._def.checks) {
2096
+ if (ch.kind === "min") {
2097
+ if (min === null || ch.value > min)
2098
+ min = ch.value;
2099
+ }
2100
+ }
2101
+ return min;
2102
+ }
2103
+ get maxLength() {
2104
+ let max = null;
2105
+ for (const ch of this._def.checks) {
2106
+ if (ch.kind === "max") {
2107
+ if (max === null || ch.value < max)
2108
+ max = ch.value;
2109
+ }
2110
+ }
2111
+ return max;
2112
+ }
2113
+ };
2114
+ __name(_ZodString, "ZodString");
2115
+ var ZodString = _ZodString;
2116
+ ZodString.create = (params) => {
2117
+ var _a;
2118
+ return new ZodString({
2119
+ checks: [],
2120
+ typeName: ZodFirstPartyTypeKind.ZodString,
2121
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2122
+ ...processCreateParams(params)
2123
+ });
2124
+ };
2125
+ function floatSafeRemainder(val, step) {
2126
+ const valDecCount = (val.toString().split(".")[1] || "").length;
2127
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
2128
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2129
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
2130
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
2131
+ return valInt % stepInt / Math.pow(10, decCount);
2132
+ }
2133
+ __name(floatSafeRemainder, "floatSafeRemainder");
2134
+ var _ZodNumber = class _ZodNumber extends ZodType {
2135
+ constructor() {
2136
+ super(...arguments);
2137
+ this.min = this.gte;
2138
+ this.max = this.lte;
2139
+ this.step = this.multipleOf;
2140
+ }
2141
+ _parse(input) {
2142
+ if (this._def.coerce) {
2143
+ input.data = Number(input.data);
2144
+ }
2145
+ const parsedType = this._getType(input);
2146
+ if (parsedType !== ZodParsedType.number) {
2147
+ const ctx2 = this._getOrReturnCtx(input);
2148
+ addIssueToContext(ctx2, {
2149
+ code: ZodIssueCode.invalid_type,
2150
+ expected: ZodParsedType.number,
2151
+ received: ctx2.parsedType
2152
+ });
2153
+ return INVALID;
2154
+ }
2155
+ let ctx = void 0;
2156
+ const status = new ParseStatus();
2157
+ for (const check of this._def.checks) {
2158
+ if (check.kind === "int") {
2159
+ if (!util.isInteger(input.data)) {
2160
+ ctx = this._getOrReturnCtx(input, ctx);
2161
+ addIssueToContext(ctx, {
2162
+ code: ZodIssueCode.invalid_type,
2163
+ expected: "integer",
2164
+ received: "float",
2165
+ message: check.message
2166
+ });
2167
+ status.dirty();
2168
+ }
2169
+ } else if (check.kind === "min") {
2170
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2171
+ if (tooSmall) {
2172
+ ctx = this._getOrReturnCtx(input, ctx);
2173
+ addIssueToContext(ctx, {
2174
+ code: ZodIssueCode.too_small,
2175
+ minimum: check.value,
2176
+ type: "number",
2177
+ inclusive: check.inclusive,
2178
+ exact: false,
2179
+ message: check.message
2180
+ });
2181
+ status.dirty();
2182
+ }
2183
+ } else if (check.kind === "max") {
2184
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2185
+ if (tooBig) {
2186
+ ctx = this._getOrReturnCtx(input, ctx);
2187
+ addIssueToContext(ctx, {
2188
+ code: ZodIssueCode.too_big,
2189
+ maximum: check.value,
2190
+ type: "number",
2191
+ inclusive: check.inclusive,
2192
+ exact: false,
2193
+ message: check.message
2194
+ });
2195
+ status.dirty();
2196
+ }
2197
+ } else if (check.kind === "multipleOf") {
2198
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2199
+ ctx = this._getOrReturnCtx(input, ctx);
2200
+ addIssueToContext(ctx, {
2201
+ code: ZodIssueCode.not_multiple_of,
2202
+ multipleOf: check.value,
2203
+ message: check.message
2204
+ });
2205
+ status.dirty();
2206
+ }
2207
+ } else if (check.kind === "finite") {
2208
+ if (!Number.isFinite(input.data)) {
2209
+ ctx = this._getOrReturnCtx(input, ctx);
2210
+ addIssueToContext(ctx, {
2211
+ code: ZodIssueCode.not_finite,
2212
+ message: check.message
2213
+ });
2214
+ status.dirty();
2215
+ }
2216
+ } else {
2217
+ util.assertNever(check);
2218
+ }
2219
+ }
2220
+ return { status: status.value, value: input.data };
2221
+ }
2222
+ gte(value, message) {
2223
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2224
+ }
2225
+ gt(value, message) {
2226
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2227
+ }
2228
+ lte(value, message) {
2229
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2230
+ }
2231
+ lt(value, message) {
2232
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2233
+ }
2234
+ setLimit(kind, value, inclusive, message) {
2235
+ return new _ZodNumber({
2236
+ ...this._def,
2237
+ checks: [
2238
+ ...this._def.checks,
2239
+ {
2240
+ kind,
2241
+ value,
2242
+ inclusive,
2243
+ message: errorUtil.toString(message)
2244
+ }
2245
+ ]
2246
+ });
2247
+ }
2248
+ _addCheck(check) {
2249
+ return new _ZodNumber({
2250
+ ...this._def,
2251
+ checks: [...this._def.checks, check]
2252
+ });
2253
+ }
2254
+ int(message) {
2255
+ return this._addCheck({
2256
+ kind: "int",
2257
+ message: errorUtil.toString(message)
2258
+ });
2259
+ }
2260
+ positive(message) {
2261
+ return this._addCheck({
2262
+ kind: "min",
2263
+ value: 0,
2264
+ inclusive: false,
2265
+ message: errorUtil.toString(message)
2266
+ });
2267
+ }
2268
+ negative(message) {
2269
+ return this._addCheck({
2270
+ kind: "max",
2271
+ value: 0,
2272
+ inclusive: false,
2273
+ message: errorUtil.toString(message)
2274
+ });
2275
+ }
2276
+ nonpositive(message) {
2277
+ return this._addCheck({
2278
+ kind: "max",
2279
+ value: 0,
2280
+ inclusive: true,
2281
+ message: errorUtil.toString(message)
2282
+ });
2283
+ }
2284
+ nonnegative(message) {
2285
+ return this._addCheck({
2286
+ kind: "min",
2287
+ value: 0,
2288
+ inclusive: true,
2289
+ message: errorUtil.toString(message)
2290
+ });
2291
+ }
2292
+ multipleOf(value, message) {
2293
+ return this._addCheck({
2294
+ kind: "multipleOf",
2295
+ value,
2296
+ message: errorUtil.toString(message)
2297
+ });
2298
+ }
2299
+ finite(message) {
2300
+ return this._addCheck({
2301
+ kind: "finite",
2302
+ message: errorUtil.toString(message)
2303
+ });
2304
+ }
2305
+ safe(message) {
2306
+ return this._addCheck({
2307
+ kind: "min",
2308
+ inclusive: true,
2309
+ value: Number.MIN_SAFE_INTEGER,
2310
+ message: errorUtil.toString(message)
2311
+ })._addCheck({
2312
+ kind: "max",
2313
+ inclusive: true,
2314
+ value: Number.MAX_SAFE_INTEGER,
2315
+ message: errorUtil.toString(message)
2316
+ });
2317
+ }
2318
+ get minValue() {
2319
+ let min = null;
2320
+ for (const ch of this._def.checks) {
2321
+ if (ch.kind === "min") {
2322
+ if (min === null || ch.value > min)
2323
+ min = ch.value;
2324
+ }
2325
+ }
2326
+ return min;
2327
+ }
2328
+ get maxValue() {
2329
+ let max = null;
2330
+ for (const ch of this._def.checks) {
2331
+ if (ch.kind === "max") {
2332
+ if (max === null || ch.value < max)
2333
+ max = ch.value;
2334
+ }
2335
+ }
2336
+ return max;
2337
+ }
2338
+ get isInt() {
2339
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
2340
+ }
2341
+ get isFinite() {
2342
+ let max = null, min = null;
2343
+ for (const ch of this._def.checks) {
2344
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
2345
+ return true;
2346
+ } else if (ch.kind === "min") {
2347
+ if (min === null || ch.value > min)
2348
+ min = ch.value;
2349
+ } else if (ch.kind === "max") {
2350
+ if (max === null || ch.value < max)
2351
+ max = ch.value;
2352
+ }
2353
+ }
2354
+ return Number.isFinite(min) && Number.isFinite(max);
2355
+ }
2356
+ };
2357
+ __name(_ZodNumber, "ZodNumber");
2358
+ var ZodNumber = _ZodNumber;
2359
+ ZodNumber.create = (params) => {
2360
+ return new ZodNumber({
2361
+ checks: [],
2362
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
2363
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2364
+ ...processCreateParams(params)
2365
+ });
2366
+ };
2367
+ var _ZodBigInt = class _ZodBigInt extends ZodType {
2368
+ constructor() {
2369
+ super(...arguments);
2370
+ this.min = this.gte;
2371
+ this.max = this.lte;
2372
+ }
2373
+ _parse(input) {
2374
+ if (this._def.coerce) {
2375
+ input.data = BigInt(input.data);
2376
+ }
2377
+ const parsedType = this._getType(input);
2378
+ if (parsedType !== ZodParsedType.bigint) {
2379
+ const ctx2 = this._getOrReturnCtx(input);
2380
+ addIssueToContext(ctx2, {
2381
+ code: ZodIssueCode.invalid_type,
2382
+ expected: ZodParsedType.bigint,
2383
+ received: ctx2.parsedType
2384
+ });
2385
+ return INVALID;
2386
+ }
2387
+ let ctx = void 0;
2388
+ const status = new ParseStatus();
2389
+ for (const check of this._def.checks) {
2390
+ if (check.kind === "min") {
2391
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2392
+ if (tooSmall) {
2393
+ ctx = this._getOrReturnCtx(input, ctx);
2394
+ addIssueToContext(ctx, {
2395
+ code: ZodIssueCode.too_small,
2396
+ type: "bigint",
2397
+ minimum: check.value,
2398
+ inclusive: check.inclusive,
2399
+ message: check.message
2400
+ });
2401
+ status.dirty();
2402
+ }
2403
+ } else if (check.kind === "max") {
2404
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2405
+ if (tooBig) {
2406
+ ctx = this._getOrReturnCtx(input, ctx);
2407
+ addIssueToContext(ctx, {
2408
+ code: ZodIssueCode.too_big,
2409
+ type: "bigint",
2410
+ maximum: check.value,
2411
+ inclusive: check.inclusive,
2412
+ message: check.message
2413
+ });
2414
+ status.dirty();
2415
+ }
2416
+ } else if (check.kind === "multipleOf") {
2417
+ if (input.data % check.value !== BigInt(0)) {
2418
+ ctx = this._getOrReturnCtx(input, ctx);
2419
+ addIssueToContext(ctx, {
2420
+ code: ZodIssueCode.not_multiple_of,
2421
+ multipleOf: check.value,
2422
+ message: check.message
2423
+ });
2424
+ status.dirty();
2425
+ }
2426
+ } else {
2427
+ util.assertNever(check);
2428
+ }
2429
+ }
2430
+ return { status: status.value, value: input.data };
2431
+ }
2432
+ gte(value, message) {
2433
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2434
+ }
2435
+ gt(value, message) {
2436
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2437
+ }
2438
+ lte(value, message) {
2439
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2440
+ }
2441
+ lt(value, message) {
2442
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2443
+ }
2444
+ setLimit(kind, value, inclusive, message) {
2445
+ return new _ZodBigInt({
2446
+ ...this._def,
2447
+ checks: [
2448
+ ...this._def.checks,
2449
+ {
2450
+ kind,
2451
+ value,
2452
+ inclusive,
2453
+ message: errorUtil.toString(message)
2454
+ }
2455
+ ]
2456
+ });
2457
+ }
2458
+ _addCheck(check) {
2459
+ return new _ZodBigInt({
2460
+ ...this._def,
2461
+ checks: [...this._def.checks, check]
2462
+ });
2463
+ }
2464
+ positive(message) {
2465
+ return this._addCheck({
2466
+ kind: "min",
2467
+ value: BigInt(0),
2468
+ inclusive: false,
2469
+ message: errorUtil.toString(message)
2470
+ });
2471
+ }
2472
+ negative(message) {
2473
+ return this._addCheck({
2474
+ kind: "max",
2475
+ value: BigInt(0),
2476
+ inclusive: false,
2477
+ message: errorUtil.toString(message)
2478
+ });
2479
+ }
2480
+ nonpositive(message) {
2481
+ return this._addCheck({
2482
+ kind: "max",
2483
+ value: BigInt(0),
2484
+ inclusive: true,
2485
+ message: errorUtil.toString(message)
2486
+ });
2487
+ }
2488
+ nonnegative(message) {
2489
+ return this._addCheck({
2490
+ kind: "min",
2491
+ value: BigInt(0),
2492
+ inclusive: true,
2493
+ message: errorUtil.toString(message)
2494
+ });
2495
+ }
2496
+ multipleOf(value, message) {
2497
+ return this._addCheck({
2498
+ kind: "multipleOf",
2499
+ value,
2500
+ message: errorUtil.toString(message)
2501
+ });
2502
+ }
2503
+ get minValue() {
2504
+ let min = null;
2505
+ for (const ch of this._def.checks) {
2506
+ if (ch.kind === "min") {
2507
+ if (min === null || ch.value > min)
2508
+ min = ch.value;
2509
+ }
2510
+ }
2511
+ return min;
2512
+ }
2513
+ get maxValue() {
2514
+ let max = null;
2515
+ for (const ch of this._def.checks) {
2516
+ if (ch.kind === "max") {
2517
+ if (max === null || ch.value < max)
2518
+ max = ch.value;
2519
+ }
2520
+ }
2521
+ return max;
2522
+ }
2523
+ };
2524
+ __name(_ZodBigInt, "ZodBigInt");
2525
+ var ZodBigInt = _ZodBigInt;
2526
+ ZodBigInt.create = (params) => {
2527
+ var _a;
2528
+ return new ZodBigInt({
2529
+ checks: [],
2530
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2531
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2532
+ ...processCreateParams(params)
2533
+ });
2534
+ };
2535
+ var _ZodBoolean = class _ZodBoolean extends ZodType {
2536
+ _parse(input) {
2537
+ if (this._def.coerce) {
2538
+ input.data = Boolean(input.data);
2539
+ }
2540
+ const parsedType = this._getType(input);
2541
+ if (parsedType !== ZodParsedType.boolean) {
2542
+ const ctx = this._getOrReturnCtx(input);
2543
+ addIssueToContext(ctx, {
2544
+ code: ZodIssueCode.invalid_type,
2545
+ expected: ZodParsedType.boolean,
2546
+ received: ctx.parsedType
2547
+ });
2548
+ return INVALID;
2549
+ }
2550
+ return OK(input.data);
2551
+ }
2552
+ };
2553
+ __name(_ZodBoolean, "ZodBoolean");
2554
+ var ZodBoolean = _ZodBoolean;
2555
+ ZodBoolean.create = (params) => {
2556
+ return new ZodBoolean({
2557
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2558
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2559
+ ...processCreateParams(params)
2560
+ });
2561
+ };
2562
+ var _ZodDate = class _ZodDate extends ZodType {
2563
+ _parse(input) {
2564
+ if (this._def.coerce) {
2565
+ input.data = new Date(input.data);
2566
+ }
2567
+ const parsedType = this._getType(input);
2568
+ if (parsedType !== ZodParsedType.date) {
2569
+ const ctx2 = this._getOrReturnCtx(input);
2570
+ addIssueToContext(ctx2, {
2571
+ code: ZodIssueCode.invalid_type,
2572
+ expected: ZodParsedType.date,
2573
+ received: ctx2.parsedType
2574
+ });
2575
+ return INVALID;
2576
+ }
2577
+ if (isNaN(input.data.getTime())) {
2578
+ const ctx2 = this._getOrReturnCtx(input);
2579
+ addIssueToContext(ctx2, {
2580
+ code: ZodIssueCode.invalid_date
2581
+ });
2582
+ return INVALID;
2583
+ }
2584
+ const status = new ParseStatus();
2585
+ let ctx = void 0;
2586
+ for (const check of this._def.checks) {
2587
+ if (check.kind === "min") {
2588
+ if (input.data.getTime() < check.value) {
2589
+ ctx = this._getOrReturnCtx(input, ctx);
2590
+ addIssueToContext(ctx, {
2591
+ code: ZodIssueCode.too_small,
2592
+ message: check.message,
2593
+ inclusive: true,
2594
+ exact: false,
2595
+ minimum: check.value,
2596
+ type: "date"
2597
+ });
2598
+ status.dirty();
2599
+ }
2600
+ } else if (check.kind === "max") {
2601
+ if (input.data.getTime() > check.value) {
2602
+ ctx = this._getOrReturnCtx(input, ctx);
2603
+ addIssueToContext(ctx, {
2604
+ code: ZodIssueCode.too_big,
2605
+ message: check.message,
2606
+ inclusive: true,
2607
+ exact: false,
2608
+ maximum: check.value,
2609
+ type: "date"
2610
+ });
2611
+ status.dirty();
2612
+ }
2613
+ } else {
2614
+ util.assertNever(check);
2615
+ }
2616
+ }
2617
+ return {
2618
+ status: status.value,
2619
+ value: new Date(input.data.getTime())
2620
+ };
2621
+ }
2622
+ _addCheck(check) {
2623
+ return new _ZodDate({
2624
+ ...this._def,
2625
+ checks: [...this._def.checks, check]
2626
+ });
2627
+ }
2628
+ min(minDate, message) {
2629
+ return this._addCheck({
2630
+ kind: "min",
2631
+ value: minDate.getTime(),
2632
+ message: errorUtil.toString(message)
2633
+ });
2634
+ }
2635
+ max(maxDate, message) {
2636
+ return this._addCheck({
2637
+ kind: "max",
2638
+ value: maxDate.getTime(),
2639
+ message: errorUtil.toString(message)
2640
+ });
2641
+ }
2642
+ get minDate() {
2643
+ let min = null;
2644
+ for (const ch of this._def.checks) {
2645
+ if (ch.kind === "min") {
2646
+ if (min === null || ch.value > min)
2647
+ min = ch.value;
2648
+ }
2649
+ }
2650
+ return min != null ? new Date(min) : null;
2651
+ }
2652
+ get maxDate() {
2653
+ let max = null;
2654
+ for (const ch of this._def.checks) {
2655
+ if (ch.kind === "max") {
2656
+ if (max === null || ch.value < max)
2657
+ max = ch.value;
2658
+ }
2659
+ }
2660
+ return max != null ? new Date(max) : null;
2661
+ }
2662
+ };
2663
+ __name(_ZodDate, "ZodDate");
2664
+ var ZodDate = _ZodDate;
2665
+ ZodDate.create = (params) => {
2666
+ return new ZodDate({
2667
+ checks: [],
2668
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2669
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2670
+ ...processCreateParams(params)
2671
+ });
2672
+ };
2673
+ var _ZodSymbol = class _ZodSymbol extends ZodType {
2674
+ _parse(input) {
2675
+ const parsedType = this._getType(input);
2676
+ if (parsedType !== ZodParsedType.symbol) {
2677
+ const ctx = this._getOrReturnCtx(input);
2678
+ addIssueToContext(ctx, {
2679
+ code: ZodIssueCode.invalid_type,
2680
+ expected: ZodParsedType.symbol,
2681
+ received: ctx.parsedType
2682
+ });
2683
+ return INVALID;
2684
+ }
2685
+ return OK(input.data);
2686
+ }
2687
+ };
2688
+ __name(_ZodSymbol, "ZodSymbol");
2689
+ var ZodSymbol = _ZodSymbol;
2690
+ ZodSymbol.create = (params) => {
2691
+ return new ZodSymbol({
2692
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2693
+ ...processCreateParams(params)
2694
+ });
2695
+ };
2696
+ var _ZodUndefined = class _ZodUndefined extends ZodType {
2697
+ _parse(input) {
2698
+ const parsedType = this._getType(input);
2699
+ if (parsedType !== ZodParsedType.undefined) {
2700
+ const ctx = this._getOrReturnCtx(input);
2701
+ addIssueToContext(ctx, {
2702
+ code: ZodIssueCode.invalid_type,
2703
+ expected: ZodParsedType.undefined,
2704
+ received: ctx.parsedType
2705
+ });
2706
+ return INVALID;
2707
+ }
2708
+ return OK(input.data);
2709
+ }
2710
+ };
2711
+ __name(_ZodUndefined, "ZodUndefined");
2712
+ var ZodUndefined = _ZodUndefined;
2713
+ ZodUndefined.create = (params) => {
2714
+ return new ZodUndefined({
2715
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2716
+ ...processCreateParams(params)
2717
+ });
2718
+ };
2719
+ var _ZodNull = class _ZodNull extends ZodType {
2720
+ _parse(input) {
2721
+ const parsedType = this._getType(input);
2722
+ if (parsedType !== ZodParsedType.null) {
2723
+ const ctx = this._getOrReturnCtx(input);
2724
+ addIssueToContext(ctx, {
2725
+ code: ZodIssueCode.invalid_type,
2726
+ expected: ZodParsedType.null,
2727
+ received: ctx.parsedType
2728
+ });
2729
+ return INVALID;
2730
+ }
2731
+ return OK(input.data);
2732
+ }
2733
+ };
2734
+ __name(_ZodNull, "ZodNull");
2735
+ var ZodNull = _ZodNull;
2736
+ ZodNull.create = (params) => {
2737
+ return new ZodNull({
2738
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2739
+ ...processCreateParams(params)
2740
+ });
2741
+ };
2742
+ var _ZodAny = class _ZodAny extends ZodType {
2743
+ constructor() {
2744
+ super(...arguments);
2745
+ this._any = true;
2746
+ }
2747
+ _parse(input) {
2748
+ return OK(input.data);
2749
+ }
2750
+ };
2751
+ __name(_ZodAny, "ZodAny");
2752
+ var ZodAny = _ZodAny;
2753
+ ZodAny.create = (params) => {
2754
+ return new ZodAny({
2755
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2756
+ ...processCreateParams(params)
2757
+ });
2758
+ };
2759
+ var _ZodUnknown = class _ZodUnknown extends ZodType {
2760
+ constructor() {
2761
+ super(...arguments);
2762
+ this._unknown = true;
2763
+ }
2764
+ _parse(input) {
2765
+ return OK(input.data);
2766
+ }
2767
+ };
2768
+ __name(_ZodUnknown, "ZodUnknown");
2769
+ var ZodUnknown = _ZodUnknown;
2770
+ ZodUnknown.create = (params) => {
2771
+ return new ZodUnknown({
2772
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2773
+ ...processCreateParams(params)
2774
+ });
2775
+ };
2776
+ var _ZodNever = class _ZodNever extends ZodType {
2777
+ _parse(input) {
2778
+ const ctx = this._getOrReturnCtx(input);
2779
+ addIssueToContext(ctx, {
2780
+ code: ZodIssueCode.invalid_type,
2781
+ expected: ZodParsedType.never,
2782
+ received: ctx.parsedType
2783
+ });
2784
+ return INVALID;
2785
+ }
2786
+ };
2787
+ __name(_ZodNever, "ZodNever");
2788
+ var ZodNever = _ZodNever;
2789
+ ZodNever.create = (params) => {
2790
+ return new ZodNever({
2791
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2792
+ ...processCreateParams(params)
2793
+ });
2794
+ };
2795
+ var _ZodVoid = class _ZodVoid extends ZodType {
2796
+ _parse(input) {
2797
+ const parsedType = this._getType(input);
2798
+ if (parsedType !== ZodParsedType.undefined) {
2799
+ const ctx = this._getOrReturnCtx(input);
2800
+ addIssueToContext(ctx, {
2801
+ code: ZodIssueCode.invalid_type,
2802
+ expected: ZodParsedType.void,
2803
+ received: ctx.parsedType
2804
+ });
2805
+ return INVALID;
2806
+ }
2807
+ return OK(input.data);
2808
+ }
2809
+ };
2810
+ __name(_ZodVoid, "ZodVoid");
2811
+ var ZodVoid = _ZodVoid;
2812
+ ZodVoid.create = (params) => {
2813
+ return new ZodVoid({
2814
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2815
+ ...processCreateParams(params)
2816
+ });
2817
+ };
2818
+ var _ZodArray = class _ZodArray extends ZodType {
2819
+ _parse(input) {
2820
+ const { ctx, status } = this._processInputParams(input);
2821
+ const def = this._def;
2822
+ if (ctx.parsedType !== ZodParsedType.array) {
2823
+ addIssueToContext(ctx, {
2824
+ code: ZodIssueCode.invalid_type,
2825
+ expected: ZodParsedType.array,
2826
+ received: ctx.parsedType
2827
+ });
2828
+ return INVALID;
2829
+ }
2830
+ if (def.exactLength !== null) {
2831
+ const tooBig = ctx.data.length > def.exactLength.value;
2832
+ const tooSmall = ctx.data.length < def.exactLength.value;
2833
+ if (tooBig || tooSmall) {
2834
+ addIssueToContext(ctx, {
2835
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2836
+ minimum: tooSmall ? def.exactLength.value : void 0,
2837
+ maximum: tooBig ? def.exactLength.value : void 0,
2838
+ type: "array",
2839
+ inclusive: true,
2840
+ exact: true,
2841
+ message: def.exactLength.message
2842
+ });
2843
+ status.dirty();
2844
+ }
2845
+ }
2846
+ if (def.minLength !== null) {
2847
+ if (ctx.data.length < def.minLength.value) {
2848
+ addIssueToContext(ctx, {
2849
+ code: ZodIssueCode.too_small,
2850
+ minimum: def.minLength.value,
2851
+ type: "array",
2852
+ inclusive: true,
2853
+ exact: false,
2854
+ message: def.minLength.message
2855
+ });
2856
+ status.dirty();
2857
+ }
2858
+ }
2859
+ if (def.maxLength !== null) {
2860
+ if (ctx.data.length > def.maxLength.value) {
2861
+ addIssueToContext(ctx, {
2862
+ code: ZodIssueCode.too_big,
2863
+ maximum: def.maxLength.value,
2864
+ type: "array",
2865
+ inclusive: true,
2866
+ exact: false,
2867
+ message: def.maxLength.message
2868
+ });
2869
+ status.dirty();
2870
+ }
2871
+ }
2872
+ if (ctx.common.async) {
2873
+ return Promise.all([...ctx.data].map((item, i) => {
2874
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2875
+ })).then((result2) => {
2876
+ return ParseStatus.mergeArray(status, result2);
2877
+ });
2878
+ }
2879
+ const result = [...ctx.data].map((item, i) => {
2880
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2881
+ });
2882
+ return ParseStatus.mergeArray(status, result);
2883
+ }
2884
+ get element() {
2885
+ return this._def.type;
2886
+ }
2887
+ min(minLength, message) {
2888
+ return new _ZodArray({
2889
+ ...this._def,
2890
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2891
+ });
2892
+ }
2893
+ max(maxLength, message) {
2894
+ return new _ZodArray({
2895
+ ...this._def,
2896
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2897
+ });
2898
+ }
2899
+ length(len, message) {
2900
+ return new _ZodArray({
2901
+ ...this._def,
2902
+ exactLength: { value: len, message: errorUtil.toString(message) }
2903
+ });
2904
+ }
2905
+ nonempty(message) {
2906
+ return this.min(1, message);
2907
+ }
2908
+ };
2909
+ __name(_ZodArray, "ZodArray");
2910
+ var ZodArray = _ZodArray;
2911
+ ZodArray.create = (schema, params) => {
2912
+ return new ZodArray({
2913
+ type: schema,
2914
+ minLength: null,
2915
+ maxLength: null,
2916
+ exactLength: null,
2917
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2918
+ ...processCreateParams(params)
2919
+ });
2920
+ };
2921
+ function deepPartialify(schema) {
2922
+ if (schema instanceof ZodObject) {
2923
+ const newShape = {};
2924
+ for (const key in schema.shape) {
2925
+ const fieldSchema = schema.shape[key];
2926
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2927
+ }
2928
+ return new ZodObject({
2929
+ ...schema._def,
2930
+ shape: () => newShape
2931
+ });
2932
+ } else if (schema instanceof ZodArray) {
2933
+ return new ZodArray({
2934
+ ...schema._def,
2935
+ type: deepPartialify(schema.element)
2936
+ });
2937
+ } else if (schema instanceof ZodOptional) {
2938
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2939
+ } else if (schema instanceof ZodNullable) {
2940
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2941
+ } else if (schema instanceof ZodTuple) {
2942
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2943
+ } else {
2944
+ return schema;
2945
+ }
2946
+ }
2947
+ __name(deepPartialify, "deepPartialify");
2948
+ var _ZodObject = class _ZodObject extends ZodType {
2949
+ constructor() {
2950
+ super(...arguments);
2951
+ this._cached = null;
2952
+ this.nonstrict = this.passthrough;
2953
+ this.augment = this.extend;
2954
+ }
2955
+ _getCached() {
2956
+ if (this._cached !== null)
2957
+ return this._cached;
2958
+ const shape = this._def.shape();
2959
+ const keys = util.objectKeys(shape);
2960
+ return this._cached = { shape, keys };
2961
+ }
2962
+ _parse(input) {
2963
+ const parsedType = this._getType(input);
2964
+ if (parsedType !== ZodParsedType.object) {
2965
+ const ctx2 = this._getOrReturnCtx(input);
2966
+ addIssueToContext(ctx2, {
2967
+ code: ZodIssueCode.invalid_type,
2968
+ expected: ZodParsedType.object,
2969
+ received: ctx2.parsedType
2970
+ });
2971
+ return INVALID;
2972
+ }
2973
+ const { status, ctx } = this._processInputParams(input);
2974
+ const { shape, keys: shapeKeys } = this._getCached();
2975
+ const extraKeys = [];
2976
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2977
+ for (const key in ctx.data) {
2978
+ if (!shapeKeys.includes(key)) {
2979
+ extraKeys.push(key);
2980
+ }
2981
+ }
2982
+ }
2983
+ const pairs = [];
2984
+ for (const key of shapeKeys) {
2985
+ const keyValidator = shape[key];
2986
+ const value = ctx.data[key];
2987
+ pairs.push({
2988
+ key: { status: "valid", value: key },
2989
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2990
+ alwaysSet: key in ctx.data
2991
+ });
2992
+ }
2993
+ if (this._def.catchall instanceof ZodNever) {
2994
+ const unknownKeys = this._def.unknownKeys;
2995
+ if (unknownKeys === "passthrough") {
2996
+ for (const key of extraKeys) {
2997
+ pairs.push({
2998
+ key: { status: "valid", value: key },
2999
+ value: { status: "valid", value: ctx.data[key] }
3000
+ });
3001
+ }
3002
+ } else if (unknownKeys === "strict") {
3003
+ if (extraKeys.length > 0) {
3004
+ addIssueToContext(ctx, {
3005
+ code: ZodIssueCode.unrecognized_keys,
3006
+ keys: extraKeys
3007
+ });
3008
+ status.dirty();
3009
+ }
3010
+ } else if (unknownKeys === "strip")
3011
+ ;
3012
+ else {
3013
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
3014
+ }
3015
+ } else {
3016
+ const catchall = this._def.catchall;
3017
+ for (const key of extraKeys) {
3018
+ const value = ctx.data[key];
3019
+ pairs.push({
3020
+ key: { status: "valid", value: key },
3021
+ value: catchall._parse(
3022
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
3023
+ //, ctx.child(key), value, getParsedType(value)
3024
+ ),
3025
+ alwaysSet: key in ctx.data
3026
+ });
3027
+ }
3028
+ }
3029
+ if (ctx.common.async) {
3030
+ return Promise.resolve().then(async () => {
3031
+ const syncPairs = [];
3032
+ for (const pair of pairs) {
3033
+ const key = await pair.key;
3034
+ syncPairs.push({
3035
+ key,
3036
+ value: await pair.value,
3037
+ alwaysSet: pair.alwaysSet
3038
+ });
3039
+ }
3040
+ return syncPairs;
3041
+ }).then((syncPairs) => {
3042
+ return ParseStatus.mergeObjectSync(status, syncPairs);
3043
+ });
3044
+ } else {
3045
+ return ParseStatus.mergeObjectSync(status, pairs);
3046
+ }
3047
+ }
3048
+ get shape() {
3049
+ return this._def.shape();
3050
+ }
3051
+ strict(message) {
3052
+ errorUtil.errToObj;
3053
+ return new _ZodObject({
3054
+ ...this._def,
3055
+ unknownKeys: "strict",
3056
+ ...message !== void 0 ? {
3057
+ errorMap: (issue, ctx) => {
3058
+ var _a, _b, _c, _d;
3059
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
3060
+ if (issue.code === "unrecognized_keys")
3061
+ return {
3062
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
3063
+ };
3064
+ return {
3065
+ message: defaultError
3066
+ };
3067
+ }
3068
+ } : {}
3069
+ });
3070
+ }
3071
+ strip() {
3072
+ return new _ZodObject({
3073
+ ...this._def,
3074
+ unknownKeys: "strip"
3075
+ });
3076
+ }
3077
+ passthrough() {
3078
+ return new _ZodObject({
3079
+ ...this._def,
3080
+ unknownKeys: "passthrough"
3081
+ });
3082
+ }
3083
+ // const AugmentFactory =
3084
+ // <Def extends ZodObjectDef>(def: Def) =>
3085
+ // <Augmentation extends ZodRawShape>(
3086
+ // augmentation: Augmentation
3087
+ // ): ZodObject<
3088
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3089
+ // Def["unknownKeys"],
3090
+ // Def["catchall"]
3091
+ // > => {
3092
+ // return new ZodObject({
3093
+ // ...def,
3094
+ // shape: () => ({
3095
+ // ...def.shape(),
3096
+ // ...augmentation,
3097
+ // }),
3098
+ // }) as any;
3099
+ // };
3100
+ extend(augmentation) {
3101
+ return new _ZodObject({
3102
+ ...this._def,
3103
+ shape: () => ({
3104
+ ...this._def.shape(),
3105
+ ...augmentation
3106
+ })
3107
+ });
3108
+ }
3109
+ /**
3110
+ * Prior to zod@1.0.12 there was a bug in the
3111
+ * inferred type of merged objects. Please
3112
+ * upgrade if you are experiencing issues.
3113
+ */
3114
+ merge(merging) {
3115
+ const merged = new _ZodObject({
3116
+ unknownKeys: merging._def.unknownKeys,
3117
+ catchall: merging._def.catchall,
3118
+ shape: () => ({
3119
+ ...this._def.shape(),
3120
+ ...merging._def.shape()
3121
+ }),
3122
+ typeName: ZodFirstPartyTypeKind.ZodObject
3123
+ });
3124
+ return merged;
3125
+ }
3126
+ // merge<
3127
+ // Incoming extends AnyZodObject,
3128
+ // Augmentation extends Incoming["shape"],
3129
+ // NewOutput extends {
3130
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3131
+ // ? Augmentation[k]["_output"]
3132
+ // : k extends keyof Output
3133
+ // ? Output[k]
3134
+ // : never;
3135
+ // },
3136
+ // NewInput extends {
3137
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3138
+ // ? Augmentation[k]["_input"]
3139
+ // : k extends keyof Input
3140
+ // ? Input[k]
3141
+ // : never;
3142
+ // }
3143
+ // >(
3144
+ // merging: Incoming
3145
+ // ): ZodObject<
3146
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3147
+ // Incoming["_def"]["unknownKeys"],
3148
+ // Incoming["_def"]["catchall"],
3149
+ // NewOutput,
3150
+ // NewInput
3151
+ // > {
3152
+ // const merged: any = new ZodObject({
3153
+ // unknownKeys: merging._def.unknownKeys,
3154
+ // catchall: merging._def.catchall,
3155
+ // shape: () =>
3156
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3157
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3158
+ // }) as any;
3159
+ // return merged;
3160
+ // }
3161
+ setKey(key, schema) {
3162
+ return this.augment({ [key]: schema });
3163
+ }
3164
+ // merge<Incoming extends AnyZodObject>(
3165
+ // merging: Incoming
3166
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3167
+ // ZodObject<
3168
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3169
+ // Incoming["_def"]["unknownKeys"],
3170
+ // Incoming["_def"]["catchall"]
3171
+ // > {
3172
+ // // const mergedShape = objectUtil.mergeShapes(
3173
+ // // this._def.shape(),
3174
+ // // merging._def.shape()
3175
+ // // );
3176
+ // const merged: any = new ZodObject({
3177
+ // unknownKeys: merging._def.unknownKeys,
3178
+ // catchall: merging._def.catchall,
3179
+ // shape: () =>
3180
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3181
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3182
+ // }) as any;
3183
+ // return merged;
3184
+ // }
3185
+ catchall(index) {
3186
+ return new _ZodObject({
3187
+ ...this._def,
3188
+ catchall: index
3189
+ });
3190
+ }
3191
+ pick(mask) {
3192
+ const shape = {};
3193
+ util.objectKeys(mask).forEach((key) => {
3194
+ if (mask[key] && this.shape[key]) {
3195
+ shape[key] = this.shape[key];
3196
+ }
3197
+ });
3198
+ return new _ZodObject({
3199
+ ...this._def,
3200
+ shape: () => shape
3201
+ });
3202
+ }
3203
+ omit(mask) {
3204
+ const shape = {};
3205
+ util.objectKeys(this.shape).forEach((key) => {
3206
+ if (!mask[key]) {
3207
+ shape[key] = this.shape[key];
3208
+ }
3209
+ });
3210
+ return new _ZodObject({
3211
+ ...this._def,
3212
+ shape: () => shape
3213
+ });
3214
+ }
3215
+ /**
3216
+ * @deprecated
3217
+ */
3218
+ deepPartial() {
3219
+ return deepPartialify(this);
3220
+ }
3221
+ partial(mask) {
3222
+ const newShape = {};
3223
+ util.objectKeys(this.shape).forEach((key) => {
3224
+ const fieldSchema = this.shape[key];
3225
+ if (mask && !mask[key]) {
3226
+ newShape[key] = fieldSchema;
3227
+ } else {
3228
+ newShape[key] = fieldSchema.optional();
3229
+ }
3230
+ });
3231
+ return new _ZodObject({
3232
+ ...this._def,
3233
+ shape: () => newShape
3234
+ });
3235
+ }
3236
+ required(mask) {
3237
+ const newShape = {};
3238
+ util.objectKeys(this.shape).forEach((key) => {
3239
+ if (mask && !mask[key]) {
3240
+ newShape[key] = this.shape[key];
3241
+ } else {
3242
+ const fieldSchema = this.shape[key];
3243
+ let newField = fieldSchema;
3244
+ while (newField instanceof ZodOptional) {
3245
+ newField = newField._def.innerType;
3246
+ }
3247
+ newShape[key] = newField;
3248
+ }
3249
+ });
3250
+ return new _ZodObject({
3251
+ ...this._def,
3252
+ shape: () => newShape
3253
+ });
3254
+ }
3255
+ keyof() {
3256
+ return createZodEnum(util.objectKeys(this.shape));
3257
+ }
3258
+ };
3259
+ __name(_ZodObject, "ZodObject");
3260
+ var ZodObject = _ZodObject;
3261
+ ZodObject.create = (shape, params) => {
3262
+ return new ZodObject({
3263
+ shape: () => shape,
3264
+ unknownKeys: "strip",
3265
+ catchall: ZodNever.create(),
3266
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3267
+ ...processCreateParams(params)
3268
+ });
3269
+ };
3270
+ ZodObject.strictCreate = (shape, params) => {
3271
+ return new ZodObject({
3272
+ shape: () => shape,
3273
+ unknownKeys: "strict",
3274
+ catchall: ZodNever.create(),
3275
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3276
+ ...processCreateParams(params)
3277
+ });
3278
+ };
3279
+ ZodObject.lazycreate = (shape, params) => {
3280
+ return new ZodObject({
3281
+ shape,
3282
+ unknownKeys: "strip",
3283
+ catchall: ZodNever.create(),
3284
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3285
+ ...processCreateParams(params)
3286
+ });
3287
+ };
3288
+ var _ZodUnion = class _ZodUnion extends ZodType {
3289
+ _parse(input) {
3290
+ const { ctx } = this._processInputParams(input);
3291
+ const options = this._def.options;
3292
+ function handleResults(results) {
3293
+ for (const result of results) {
3294
+ if (result.result.status === "valid") {
3295
+ return result.result;
3296
+ }
3297
+ }
3298
+ for (const result of results) {
3299
+ if (result.result.status === "dirty") {
3300
+ ctx.common.issues.push(...result.ctx.common.issues);
3301
+ return result.result;
3302
+ }
3303
+ }
3304
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3305
+ addIssueToContext(ctx, {
3306
+ code: ZodIssueCode.invalid_union,
3307
+ unionErrors
3308
+ });
3309
+ return INVALID;
3310
+ }
3311
+ __name(handleResults, "handleResults");
3312
+ if (ctx.common.async) {
3313
+ return Promise.all(options.map(async (option) => {
3314
+ const childCtx = {
3315
+ ...ctx,
3316
+ common: {
3317
+ ...ctx.common,
3318
+ issues: []
3319
+ },
3320
+ parent: null
3321
+ };
3322
+ return {
3323
+ result: await option._parseAsync({
3324
+ data: ctx.data,
3325
+ path: ctx.path,
3326
+ parent: childCtx
3327
+ }),
3328
+ ctx: childCtx
3329
+ };
3330
+ })).then(handleResults);
3331
+ } else {
3332
+ let dirty = void 0;
3333
+ const issues = [];
3334
+ for (const option of options) {
3335
+ const childCtx = {
3336
+ ...ctx,
3337
+ common: {
3338
+ ...ctx.common,
3339
+ issues: []
3340
+ },
3341
+ parent: null
3342
+ };
3343
+ const result = option._parseSync({
3344
+ data: ctx.data,
3345
+ path: ctx.path,
3346
+ parent: childCtx
3347
+ });
3348
+ if (result.status === "valid") {
3349
+ return result;
3350
+ } else if (result.status === "dirty" && !dirty) {
3351
+ dirty = { result, ctx: childCtx };
3352
+ }
3353
+ if (childCtx.common.issues.length) {
3354
+ issues.push(childCtx.common.issues);
3355
+ }
3356
+ }
3357
+ if (dirty) {
3358
+ ctx.common.issues.push(...dirty.ctx.common.issues);
3359
+ return dirty.result;
3360
+ }
3361
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
3362
+ addIssueToContext(ctx, {
3363
+ code: ZodIssueCode.invalid_union,
3364
+ unionErrors
3365
+ });
3366
+ return INVALID;
3367
+ }
3368
+ }
3369
+ get options() {
3370
+ return this._def.options;
3371
+ }
3372
+ };
3373
+ __name(_ZodUnion, "ZodUnion");
3374
+ var ZodUnion = _ZodUnion;
3375
+ ZodUnion.create = (types, params) => {
3376
+ return new ZodUnion({
3377
+ options: types,
3378
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
3379
+ ...processCreateParams(params)
3380
+ });
3381
+ };
3382
+ var getDiscriminator = /* @__PURE__ */ __name((type) => {
3383
+ if (type instanceof ZodLazy) {
3384
+ return getDiscriminator(type.schema);
3385
+ } else if (type instanceof ZodEffects) {
3386
+ return getDiscriminator(type.innerType());
3387
+ } else if (type instanceof ZodLiteral) {
3388
+ return [type.value];
3389
+ } else if (type instanceof ZodEnum) {
3390
+ return type.options;
3391
+ } else if (type instanceof ZodNativeEnum) {
3392
+ return Object.keys(type.enum);
3393
+ } else if (type instanceof ZodDefault) {
3394
+ return getDiscriminator(type._def.innerType);
3395
+ } else if (type instanceof ZodUndefined) {
3396
+ return [void 0];
3397
+ } else if (type instanceof ZodNull) {
3398
+ return [null];
3399
+ } else {
3400
+ return null;
3401
+ }
3402
+ }, "getDiscriminator");
3403
+ var _ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
3404
+ _parse(input) {
3405
+ const { ctx } = this._processInputParams(input);
3406
+ if (ctx.parsedType !== ZodParsedType.object) {
3407
+ addIssueToContext(ctx, {
3408
+ code: ZodIssueCode.invalid_type,
3409
+ expected: ZodParsedType.object,
3410
+ received: ctx.parsedType
3411
+ });
3412
+ return INVALID;
3413
+ }
3414
+ const discriminator = this.discriminator;
3415
+ const discriminatorValue = ctx.data[discriminator];
3416
+ const option = this.optionsMap.get(discriminatorValue);
3417
+ if (!option) {
3418
+ addIssueToContext(ctx, {
3419
+ code: ZodIssueCode.invalid_union_discriminator,
3420
+ options: Array.from(this.optionsMap.keys()),
3421
+ path: [discriminator]
3422
+ });
3423
+ return INVALID;
3424
+ }
3425
+ if (ctx.common.async) {
3426
+ return option._parseAsync({
3427
+ data: ctx.data,
3428
+ path: ctx.path,
3429
+ parent: ctx
3430
+ });
3431
+ } else {
3432
+ return option._parseSync({
3433
+ data: ctx.data,
3434
+ path: ctx.path,
3435
+ parent: ctx
3436
+ });
3437
+ }
3438
+ }
3439
+ get discriminator() {
3440
+ return this._def.discriminator;
3441
+ }
3442
+ get options() {
3443
+ return this._def.options;
3444
+ }
3445
+ get optionsMap() {
3446
+ return this._def.optionsMap;
3447
+ }
3448
+ /**
3449
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3450
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3451
+ * have a different value for each object in the union.
3452
+ * @param discriminator the name of the discriminator property
3453
+ * @param types an array of object schemas
3454
+ * @param params
3455
+ */
3456
+ static create(discriminator, options, params) {
3457
+ const optionsMap = /* @__PURE__ */ new Map();
3458
+ for (const type of options) {
3459
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3460
+ if (!discriminatorValues) {
3461
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3462
+ }
3463
+ for (const value of discriminatorValues) {
3464
+ if (optionsMap.has(value)) {
3465
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3466
+ }
3467
+ optionsMap.set(value, type);
3468
+ }
3469
+ }
3470
+ return new _ZodDiscriminatedUnion({
3471
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3472
+ discriminator,
3473
+ options,
3474
+ optionsMap,
3475
+ ...processCreateParams(params)
3476
+ });
3477
+ }
3478
+ };
3479
+ __name(_ZodDiscriminatedUnion, "ZodDiscriminatedUnion");
3480
+ var ZodDiscriminatedUnion = _ZodDiscriminatedUnion;
3481
+ function mergeValues(a, b) {
3482
+ const aType = getParsedType(a);
3483
+ const bType = getParsedType(b);
3484
+ if (a === b) {
3485
+ return { valid: true, data: a };
3486
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3487
+ const bKeys = util.objectKeys(b);
3488
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3489
+ const newObj = { ...a, ...b };
3490
+ for (const key of sharedKeys) {
3491
+ const sharedValue = mergeValues(a[key], b[key]);
3492
+ if (!sharedValue.valid) {
3493
+ return { valid: false };
3494
+ }
3495
+ newObj[key] = sharedValue.data;
3496
+ }
3497
+ return { valid: true, data: newObj };
3498
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3499
+ if (a.length !== b.length) {
3500
+ return { valid: false };
3501
+ }
3502
+ const newArray = [];
3503
+ for (let index = 0; index < a.length; index++) {
3504
+ const itemA = a[index];
3505
+ const itemB = b[index];
3506
+ const sharedValue = mergeValues(itemA, itemB);
3507
+ if (!sharedValue.valid) {
3508
+ return { valid: false };
3509
+ }
3510
+ newArray.push(sharedValue.data);
3511
+ }
3512
+ return { valid: true, data: newArray };
3513
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
3514
+ return { valid: true, data: a };
3515
+ } else {
3516
+ return { valid: false };
3517
+ }
3518
+ }
3519
+ __name(mergeValues, "mergeValues");
3520
+ var _ZodIntersection = class _ZodIntersection extends ZodType {
3521
+ _parse(input) {
3522
+ const { status, ctx } = this._processInputParams(input);
3523
+ const handleParsed = /* @__PURE__ */ __name((parsedLeft, parsedRight) => {
3524
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3525
+ return INVALID;
3526
+ }
3527
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3528
+ if (!merged.valid) {
3529
+ addIssueToContext(ctx, {
3530
+ code: ZodIssueCode.invalid_intersection_types
3531
+ });
3532
+ return INVALID;
3533
+ }
3534
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3535
+ status.dirty();
3536
+ }
3537
+ return { status: status.value, value: merged.data };
3538
+ }, "handleParsed");
3539
+ if (ctx.common.async) {
3540
+ return Promise.all([
3541
+ this._def.left._parseAsync({
3542
+ data: ctx.data,
3543
+ path: ctx.path,
3544
+ parent: ctx
3545
+ }),
3546
+ this._def.right._parseAsync({
3547
+ data: ctx.data,
3548
+ path: ctx.path,
3549
+ parent: ctx
3550
+ })
3551
+ ]).then(([left, right]) => handleParsed(left, right));
3552
+ } else {
3553
+ return handleParsed(this._def.left._parseSync({
3554
+ data: ctx.data,
3555
+ path: ctx.path,
3556
+ parent: ctx
3557
+ }), this._def.right._parseSync({
3558
+ data: ctx.data,
3559
+ path: ctx.path,
3560
+ parent: ctx
3561
+ }));
3562
+ }
3563
+ }
3564
+ };
3565
+ __name(_ZodIntersection, "ZodIntersection");
3566
+ var ZodIntersection = _ZodIntersection;
3567
+ ZodIntersection.create = (left, right, params) => {
3568
+ return new ZodIntersection({
3569
+ left,
3570
+ right,
3571
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3572
+ ...processCreateParams(params)
3573
+ });
3574
+ };
3575
+ var _ZodTuple = class _ZodTuple extends ZodType {
3576
+ _parse(input) {
3577
+ const { status, ctx } = this._processInputParams(input);
3578
+ if (ctx.parsedType !== ZodParsedType.array) {
3579
+ addIssueToContext(ctx, {
3580
+ code: ZodIssueCode.invalid_type,
3581
+ expected: ZodParsedType.array,
3582
+ received: ctx.parsedType
3583
+ });
3584
+ return INVALID;
3585
+ }
3586
+ if (ctx.data.length < this._def.items.length) {
3587
+ addIssueToContext(ctx, {
3588
+ code: ZodIssueCode.too_small,
3589
+ minimum: this._def.items.length,
3590
+ inclusive: true,
3591
+ exact: false,
3592
+ type: "array"
3593
+ });
3594
+ return INVALID;
3595
+ }
3596
+ const rest = this._def.rest;
3597
+ if (!rest && ctx.data.length > this._def.items.length) {
3598
+ addIssueToContext(ctx, {
3599
+ code: ZodIssueCode.too_big,
3600
+ maximum: this._def.items.length,
3601
+ inclusive: true,
3602
+ exact: false,
3603
+ type: "array"
3604
+ });
3605
+ status.dirty();
3606
+ }
3607
+ const items = [...ctx.data].map((item, itemIndex) => {
3608
+ const schema = this._def.items[itemIndex] || this._def.rest;
3609
+ if (!schema)
3610
+ return null;
3611
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3612
+ }).filter((x) => !!x);
3613
+ if (ctx.common.async) {
3614
+ return Promise.all(items).then((results) => {
3615
+ return ParseStatus.mergeArray(status, results);
3616
+ });
3617
+ } else {
3618
+ return ParseStatus.mergeArray(status, items);
3619
+ }
3620
+ }
3621
+ get items() {
3622
+ return this._def.items;
3623
+ }
3624
+ rest(rest) {
3625
+ return new _ZodTuple({
3626
+ ...this._def,
3627
+ rest
3628
+ });
3629
+ }
3630
+ };
3631
+ __name(_ZodTuple, "ZodTuple");
3632
+ var ZodTuple = _ZodTuple;
3633
+ ZodTuple.create = (schemas, params) => {
3634
+ if (!Array.isArray(schemas)) {
3635
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3636
+ }
3637
+ return new ZodTuple({
3638
+ items: schemas,
3639
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3640
+ rest: null,
3641
+ ...processCreateParams(params)
3642
+ });
3643
+ };
3644
+ var _ZodRecord = class _ZodRecord extends ZodType {
3645
+ get keySchema() {
3646
+ return this._def.keyType;
3647
+ }
3648
+ get valueSchema() {
3649
+ return this._def.valueType;
3650
+ }
3651
+ _parse(input) {
3652
+ const { status, ctx } = this._processInputParams(input);
3653
+ if (ctx.parsedType !== ZodParsedType.object) {
3654
+ addIssueToContext(ctx, {
3655
+ code: ZodIssueCode.invalid_type,
3656
+ expected: ZodParsedType.object,
3657
+ received: ctx.parsedType
3658
+ });
3659
+ return INVALID;
3660
+ }
3661
+ const pairs = [];
3662
+ const keyType = this._def.keyType;
3663
+ const valueType = this._def.valueType;
3664
+ for (const key in ctx.data) {
3665
+ pairs.push({
3666
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3667
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
3668
+ });
3669
+ }
3670
+ if (ctx.common.async) {
3671
+ return ParseStatus.mergeObjectAsync(status, pairs);
3672
+ } else {
3673
+ return ParseStatus.mergeObjectSync(status, pairs);
3674
+ }
3675
+ }
3676
+ get element() {
3677
+ return this._def.valueType;
3678
+ }
3679
+ static create(first, second, third) {
3680
+ if (second instanceof ZodType) {
3681
+ return new _ZodRecord({
3682
+ keyType: first,
3683
+ valueType: second,
3684
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3685
+ ...processCreateParams(third)
3686
+ });
3687
+ }
3688
+ return new _ZodRecord({
3689
+ keyType: ZodString.create(),
3690
+ valueType: first,
3691
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3692
+ ...processCreateParams(second)
3693
+ });
3694
+ }
3695
+ };
3696
+ __name(_ZodRecord, "ZodRecord");
3697
+ var ZodRecord = _ZodRecord;
3698
+ var _ZodMap = class _ZodMap extends ZodType {
3699
+ get keySchema() {
3700
+ return this._def.keyType;
3701
+ }
3702
+ get valueSchema() {
3703
+ return this._def.valueType;
3704
+ }
3705
+ _parse(input) {
3706
+ const { status, ctx } = this._processInputParams(input);
3707
+ if (ctx.parsedType !== ZodParsedType.map) {
3708
+ addIssueToContext(ctx, {
3709
+ code: ZodIssueCode.invalid_type,
3710
+ expected: ZodParsedType.map,
3711
+ received: ctx.parsedType
3712
+ });
3713
+ return INVALID;
3714
+ }
3715
+ const keyType = this._def.keyType;
3716
+ const valueType = this._def.valueType;
3717
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3718
+ return {
3719
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3720
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3721
+ };
3722
+ });
3723
+ if (ctx.common.async) {
3724
+ const finalMap = /* @__PURE__ */ new Map();
3725
+ return Promise.resolve().then(async () => {
3726
+ for (const pair of pairs) {
3727
+ const key = await pair.key;
3728
+ const value = await pair.value;
3729
+ if (key.status === "aborted" || value.status === "aborted") {
3730
+ return INVALID;
3731
+ }
3732
+ if (key.status === "dirty" || value.status === "dirty") {
3733
+ status.dirty();
3734
+ }
3735
+ finalMap.set(key.value, value.value);
3736
+ }
3737
+ return { status: status.value, value: finalMap };
3738
+ });
3739
+ } else {
3740
+ const finalMap = /* @__PURE__ */ new Map();
3741
+ for (const pair of pairs) {
3742
+ const key = pair.key;
3743
+ const value = pair.value;
3744
+ if (key.status === "aborted" || value.status === "aborted") {
3745
+ return INVALID;
3746
+ }
3747
+ if (key.status === "dirty" || value.status === "dirty") {
3748
+ status.dirty();
3749
+ }
3750
+ finalMap.set(key.value, value.value);
3751
+ }
3752
+ return { status: status.value, value: finalMap };
3753
+ }
3754
+ }
3755
+ };
3756
+ __name(_ZodMap, "ZodMap");
3757
+ var ZodMap = _ZodMap;
3758
+ ZodMap.create = (keyType, valueType, params) => {
3759
+ return new ZodMap({
3760
+ valueType,
3761
+ keyType,
3762
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3763
+ ...processCreateParams(params)
3764
+ });
3765
+ };
3766
+ var _ZodSet = class _ZodSet extends ZodType {
3767
+ _parse(input) {
3768
+ const { status, ctx } = this._processInputParams(input);
3769
+ if (ctx.parsedType !== ZodParsedType.set) {
3770
+ addIssueToContext(ctx, {
3771
+ code: ZodIssueCode.invalid_type,
3772
+ expected: ZodParsedType.set,
3773
+ received: ctx.parsedType
3774
+ });
3775
+ return INVALID;
3776
+ }
3777
+ const def = this._def;
3778
+ if (def.minSize !== null) {
3779
+ if (ctx.data.size < def.minSize.value) {
3780
+ addIssueToContext(ctx, {
3781
+ code: ZodIssueCode.too_small,
3782
+ minimum: def.minSize.value,
3783
+ type: "set",
3784
+ inclusive: true,
3785
+ exact: false,
3786
+ message: def.minSize.message
3787
+ });
3788
+ status.dirty();
3789
+ }
3790
+ }
3791
+ if (def.maxSize !== null) {
3792
+ if (ctx.data.size > def.maxSize.value) {
3793
+ addIssueToContext(ctx, {
3794
+ code: ZodIssueCode.too_big,
3795
+ maximum: def.maxSize.value,
3796
+ type: "set",
3797
+ inclusive: true,
3798
+ exact: false,
3799
+ message: def.maxSize.message
3800
+ });
3801
+ status.dirty();
3802
+ }
3803
+ }
3804
+ const valueType = this._def.valueType;
3805
+ function finalizeSet(elements2) {
3806
+ const parsedSet = /* @__PURE__ */ new Set();
3807
+ for (const element of elements2) {
3808
+ if (element.status === "aborted")
3809
+ return INVALID;
3810
+ if (element.status === "dirty")
3811
+ status.dirty();
3812
+ parsedSet.add(element.value);
3813
+ }
3814
+ return { status: status.value, value: parsedSet };
3815
+ }
3816
+ __name(finalizeSet, "finalizeSet");
3817
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3818
+ if (ctx.common.async) {
3819
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3820
+ } else {
3821
+ return finalizeSet(elements);
3822
+ }
3823
+ }
3824
+ min(minSize, message) {
3825
+ return new _ZodSet({
3826
+ ...this._def,
3827
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3828
+ });
3829
+ }
3830
+ max(maxSize, message) {
3831
+ return new _ZodSet({
3832
+ ...this._def,
3833
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3834
+ });
3835
+ }
3836
+ size(size, message) {
3837
+ return this.min(size, message).max(size, message);
3838
+ }
3839
+ nonempty(message) {
3840
+ return this.min(1, message);
3841
+ }
3842
+ };
3843
+ __name(_ZodSet, "ZodSet");
3844
+ var ZodSet = _ZodSet;
3845
+ ZodSet.create = (valueType, params) => {
3846
+ return new ZodSet({
3847
+ valueType,
3848
+ minSize: null,
3849
+ maxSize: null,
3850
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3851
+ ...processCreateParams(params)
3852
+ });
3853
+ };
3854
+ var _ZodFunction = class _ZodFunction extends ZodType {
3855
+ constructor() {
3856
+ super(...arguments);
3857
+ this.validate = this.implement;
3858
+ }
3859
+ _parse(input) {
3860
+ const { ctx } = this._processInputParams(input);
3861
+ if (ctx.parsedType !== ZodParsedType.function) {
3862
+ addIssueToContext(ctx, {
3863
+ code: ZodIssueCode.invalid_type,
3864
+ expected: ZodParsedType.function,
3865
+ received: ctx.parsedType
3866
+ });
3867
+ return INVALID;
3868
+ }
3869
+ function makeArgsIssue(args, error) {
3870
+ return makeIssue({
3871
+ data: args,
3872
+ path: ctx.path,
3873
+ errorMaps: [
3874
+ ctx.common.contextualErrorMap,
3875
+ ctx.schemaErrorMap,
3876
+ getErrorMap(),
3877
+ errorMap
3878
+ ].filter((x) => !!x),
3879
+ issueData: {
3880
+ code: ZodIssueCode.invalid_arguments,
3881
+ argumentsError: error
3882
+ }
3883
+ });
3884
+ }
3885
+ __name(makeArgsIssue, "makeArgsIssue");
3886
+ function makeReturnsIssue(returns, error) {
3887
+ return makeIssue({
3888
+ data: returns,
3889
+ path: ctx.path,
3890
+ errorMaps: [
3891
+ ctx.common.contextualErrorMap,
3892
+ ctx.schemaErrorMap,
3893
+ getErrorMap(),
3894
+ errorMap
3895
+ ].filter((x) => !!x),
3896
+ issueData: {
3897
+ code: ZodIssueCode.invalid_return_type,
3898
+ returnTypeError: error
3899
+ }
3900
+ });
3901
+ }
3902
+ __name(makeReturnsIssue, "makeReturnsIssue");
3903
+ const params = { errorMap: ctx.common.contextualErrorMap };
3904
+ const fn = ctx.data;
3905
+ if (this._def.returns instanceof ZodPromise) {
3906
+ const me = this;
3907
+ return OK(async function(...args) {
3908
+ const error = new ZodError([]);
3909
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3910
+ error.addIssue(makeArgsIssue(args, e));
3911
+ throw error;
3912
+ });
3913
+ const result = await Reflect.apply(fn, this, parsedArgs);
3914
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3915
+ error.addIssue(makeReturnsIssue(result, e));
3916
+ throw error;
3917
+ });
3918
+ return parsedReturns;
3919
+ });
3920
+ } else {
3921
+ const me = this;
3922
+ return OK(function(...args) {
3923
+ const parsedArgs = me._def.args.safeParse(args, params);
3924
+ if (!parsedArgs.success) {
3925
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3926
+ }
3927
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3928
+ const parsedReturns = me._def.returns.safeParse(result, params);
3929
+ if (!parsedReturns.success) {
3930
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3931
+ }
3932
+ return parsedReturns.data;
3933
+ });
3934
+ }
3935
+ }
3936
+ parameters() {
3937
+ return this._def.args;
3938
+ }
3939
+ returnType() {
3940
+ return this._def.returns;
3941
+ }
3942
+ args(...items) {
3943
+ return new _ZodFunction({
3944
+ ...this._def,
3945
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3946
+ });
3947
+ }
3948
+ returns(returnType) {
3949
+ return new _ZodFunction({
3950
+ ...this._def,
3951
+ returns: returnType
3952
+ });
3953
+ }
3954
+ implement(func) {
3955
+ const validatedFunc = this.parse(func);
3956
+ return validatedFunc;
3957
+ }
3958
+ strictImplement(func) {
3959
+ const validatedFunc = this.parse(func);
3960
+ return validatedFunc;
3961
+ }
3962
+ static create(args, returns, params) {
3963
+ return new _ZodFunction({
3964
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3965
+ returns: returns || ZodUnknown.create(),
3966
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3967
+ ...processCreateParams(params)
3968
+ });
3969
+ }
3970
+ };
3971
+ __name(_ZodFunction, "ZodFunction");
3972
+ var ZodFunction = _ZodFunction;
3973
+ var _ZodLazy = class _ZodLazy extends ZodType {
3974
+ get schema() {
3975
+ return this._def.getter();
3976
+ }
3977
+ _parse(input) {
3978
+ const { ctx } = this._processInputParams(input);
3979
+ const lazySchema = this._def.getter();
3980
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3981
+ }
3982
+ };
3983
+ __name(_ZodLazy, "ZodLazy");
3984
+ var ZodLazy = _ZodLazy;
3985
+ ZodLazy.create = (getter, params) => {
3986
+ return new ZodLazy({
3987
+ getter,
3988
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3989
+ ...processCreateParams(params)
3990
+ });
3991
+ };
3992
+ var _ZodLiteral = class _ZodLiteral extends ZodType {
3993
+ _parse(input) {
3994
+ if (input.data !== this._def.value) {
3995
+ const ctx = this._getOrReturnCtx(input);
3996
+ addIssueToContext(ctx, {
3997
+ received: ctx.data,
3998
+ code: ZodIssueCode.invalid_literal,
3999
+ expected: this._def.value
4000
+ });
4001
+ return INVALID;
4002
+ }
4003
+ return { status: "valid", value: input.data };
4004
+ }
4005
+ get value() {
4006
+ return this._def.value;
4007
+ }
4008
+ };
4009
+ __name(_ZodLiteral, "ZodLiteral");
4010
+ var ZodLiteral = _ZodLiteral;
4011
+ ZodLiteral.create = (value, params) => {
4012
+ return new ZodLiteral({
4013
+ value,
4014
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
4015
+ ...processCreateParams(params)
4016
+ });
4017
+ };
4018
+ function createZodEnum(values, params) {
4019
+ return new ZodEnum({
4020
+ values,
4021
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
4022
+ ...processCreateParams(params)
4023
+ });
4024
+ }
4025
+ __name(createZodEnum, "createZodEnum");
4026
+ var _ZodEnum = class _ZodEnum extends ZodType {
4027
+ _parse(input) {
4028
+ if (typeof input.data !== "string") {
4029
+ const ctx = this._getOrReturnCtx(input);
4030
+ const expectedValues = this._def.values;
4031
+ addIssueToContext(ctx, {
4032
+ expected: util.joinValues(expectedValues),
4033
+ received: ctx.parsedType,
4034
+ code: ZodIssueCode.invalid_type
4035
+ });
4036
+ return INVALID;
4037
+ }
4038
+ if (this._def.values.indexOf(input.data) === -1) {
4039
+ const ctx = this._getOrReturnCtx(input);
4040
+ const expectedValues = this._def.values;
4041
+ addIssueToContext(ctx, {
4042
+ received: ctx.data,
4043
+ code: ZodIssueCode.invalid_enum_value,
4044
+ options: expectedValues
4045
+ });
4046
+ return INVALID;
4047
+ }
4048
+ return OK(input.data);
4049
+ }
4050
+ get options() {
4051
+ return this._def.values;
4052
+ }
4053
+ get enum() {
4054
+ const enumValues = {};
4055
+ for (const val of this._def.values) {
4056
+ enumValues[val] = val;
4057
+ }
4058
+ return enumValues;
4059
+ }
4060
+ get Values() {
4061
+ const enumValues = {};
4062
+ for (const val of this._def.values) {
4063
+ enumValues[val] = val;
4064
+ }
4065
+ return enumValues;
4066
+ }
4067
+ get Enum() {
4068
+ const enumValues = {};
4069
+ for (const val of this._def.values) {
4070
+ enumValues[val] = val;
4071
+ }
4072
+ return enumValues;
4073
+ }
4074
+ extract(values) {
4075
+ return _ZodEnum.create(values);
4076
+ }
4077
+ exclude(values) {
4078
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
4079
+ }
4080
+ };
4081
+ __name(_ZodEnum, "ZodEnum");
4082
+ var ZodEnum = _ZodEnum;
4083
+ ZodEnum.create = createZodEnum;
4084
+ var _ZodNativeEnum = class _ZodNativeEnum extends ZodType {
4085
+ _parse(input) {
4086
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
4087
+ const ctx = this._getOrReturnCtx(input);
4088
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
4089
+ const expectedValues = util.objectValues(nativeEnumValues);
4090
+ addIssueToContext(ctx, {
4091
+ expected: util.joinValues(expectedValues),
4092
+ received: ctx.parsedType,
4093
+ code: ZodIssueCode.invalid_type
4094
+ });
4095
+ return INVALID;
4096
+ }
4097
+ if (nativeEnumValues.indexOf(input.data) === -1) {
4098
+ const expectedValues = util.objectValues(nativeEnumValues);
4099
+ addIssueToContext(ctx, {
4100
+ received: ctx.data,
4101
+ code: ZodIssueCode.invalid_enum_value,
4102
+ options: expectedValues
4103
+ });
4104
+ return INVALID;
4105
+ }
4106
+ return OK(input.data);
4107
+ }
4108
+ get enum() {
4109
+ return this._def.values;
4110
+ }
4111
+ };
4112
+ __name(_ZodNativeEnum, "ZodNativeEnum");
4113
+ var ZodNativeEnum = _ZodNativeEnum;
4114
+ ZodNativeEnum.create = (values, params) => {
4115
+ return new ZodNativeEnum({
4116
+ values,
4117
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
4118
+ ...processCreateParams(params)
4119
+ });
4120
+ };
4121
+ var _ZodPromise = class _ZodPromise extends ZodType {
4122
+ unwrap() {
4123
+ return this._def.type;
4124
+ }
4125
+ _parse(input) {
4126
+ const { ctx } = this._processInputParams(input);
4127
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
4128
+ addIssueToContext(ctx, {
4129
+ code: ZodIssueCode.invalid_type,
4130
+ expected: ZodParsedType.promise,
4131
+ received: ctx.parsedType
4132
+ });
4133
+ return INVALID;
4134
+ }
4135
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
4136
+ return OK(promisified.then((data) => {
4137
+ return this._def.type.parseAsync(data, {
4138
+ path: ctx.path,
4139
+ errorMap: ctx.common.contextualErrorMap
4140
+ });
4141
+ }));
4142
+ }
4143
+ };
4144
+ __name(_ZodPromise, "ZodPromise");
4145
+ var ZodPromise = _ZodPromise;
4146
+ ZodPromise.create = (schema, params) => {
4147
+ return new ZodPromise({
4148
+ type: schema,
4149
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
4150
+ ...processCreateParams(params)
4151
+ });
4152
+ };
4153
+ var _ZodEffects = class _ZodEffects extends ZodType {
4154
+ innerType() {
4155
+ return this._def.schema;
4156
+ }
4157
+ sourceType() {
4158
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
4159
+ }
4160
+ _parse(input) {
4161
+ const { status, ctx } = this._processInputParams(input);
4162
+ const effect = this._def.effect || null;
4163
+ const checkCtx = {
4164
+ addIssue: (arg) => {
4165
+ addIssueToContext(ctx, arg);
4166
+ if (arg.fatal) {
4167
+ status.abort();
4168
+ } else {
4169
+ status.dirty();
4170
+ }
4171
+ },
4172
+ get path() {
4173
+ return ctx.path;
4174
+ }
4175
+ };
4176
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4177
+ if (effect.type === "preprocess") {
4178
+ const processed = effect.transform(ctx.data, checkCtx);
4179
+ if (ctx.common.issues.length) {
4180
+ return {
4181
+ status: "dirty",
4182
+ value: ctx.data
4183
+ };
4184
+ }
4185
+ if (ctx.common.async) {
4186
+ return Promise.resolve(processed).then((processed2) => {
4187
+ return this._def.schema._parseAsync({
4188
+ data: processed2,
4189
+ path: ctx.path,
4190
+ parent: ctx
4191
+ });
4192
+ });
4193
+ } else {
4194
+ return this._def.schema._parseSync({
4195
+ data: processed,
4196
+ path: ctx.path,
4197
+ parent: ctx
4198
+ });
4199
+ }
4200
+ }
4201
+ if (effect.type === "refinement") {
4202
+ const executeRefinement = /* @__PURE__ */ __name((acc) => {
4203
+ const result = effect.refinement(acc, checkCtx);
4204
+ if (ctx.common.async) {
4205
+ return Promise.resolve(result);
4206
+ }
4207
+ if (result instanceof Promise) {
4208
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
4209
+ }
4210
+ return acc;
4211
+ }, "executeRefinement");
4212
+ if (ctx.common.async === false) {
4213
+ const inner = this._def.schema._parseSync({
4214
+ data: ctx.data,
4215
+ path: ctx.path,
4216
+ parent: ctx
4217
+ });
4218
+ if (inner.status === "aborted")
4219
+ return INVALID;
4220
+ if (inner.status === "dirty")
4221
+ status.dirty();
4222
+ executeRefinement(inner.value);
4223
+ return { status: status.value, value: inner.value };
4224
+ } else {
4225
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4226
+ if (inner.status === "aborted")
4227
+ return INVALID;
4228
+ if (inner.status === "dirty")
4229
+ status.dirty();
4230
+ return executeRefinement(inner.value).then(() => {
4231
+ return { status: status.value, value: inner.value };
4232
+ });
4233
+ });
4234
+ }
4235
+ }
4236
+ if (effect.type === "transform") {
4237
+ if (ctx.common.async === false) {
4238
+ const base = this._def.schema._parseSync({
4239
+ data: ctx.data,
4240
+ path: ctx.path,
4241
+ parent: ctx
4242
+ });
4243
+ if (!isValid(base))
4244
+ return base;
4245
+ const result = effect.transform(base.value, checkCtx);
4246
+ if (result instanceof Promise) {
4247
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4248
+ }
4249
+ return { status: status.value, value: result };
4250
+ } else {
4251
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4252
+ if (!isValid(base))
4253
+ return base;
4254
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
4255
+ });
4256
+ }
4257
+ }
4258
+ util.assertNever(effect);
4259
+ }
4260
+ };
4261
+ __name(_ZodEffects, "ZodEffects");
4262
+ var ZodEffects = _ZodEffects;
4263
+ ZodEffects.create = (schema, effect, params) => {
4264
+ return new ZodEffects({
4265
+ schema,
4266
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4267
+ effect,
4268
+ ...processCreateParams(params)
4269
+ });
4270
+ };
4271
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4272
+ return new ZodEffects({
4273
+ schema,
4274
+ effect: { type: "preprocess", transform: preprocess },
4275
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4276
+ ...processCreateParams(params)
4277
+ });
4278
+ };
4279
+ var _ZodOptional = class _ZodOptional extends ZodType {
4280
+ _parse(input) {
4281
+ const parsedType = this._getType(input);
4282
+ if (parsedType === ZodParsedType.undefined) {
4283
+ return OK(void 0);
4284
+ }
4285
+ return this._def.innerType._parse(input);
4286
+ }
4287
+ unwrap() {
4288
+ return this._def.innerType;
4289
+ }
4290
+ };
4291
+ __name(_ZodOptional, "ZodOptional");
4292
+ var ZodOptional = _ZodOptional;
4293
+ ZodOptional.create = (type, params) => {
4294
+ return new ZodOptional({
4295
+ innerType: type,
4296
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
4297
+ ...processCreateParams(params)
4298
+ });
4299
+ };
4300
+ var _ZodNullable = class _ZodNullable extends ZodType {
4301
+ _parse(input) {
4302
+ const parsedType = this._getType(input);
4303
+ if (parsedType === ZodParsedType.null) {
4304
+ return OK(null);
4305
+ }
4306
+ return this._def.innerType._parse(input);
4307
+ }
4308
+ unwrap() {
4309
+ return this._def.innerType;
4310
+ }
4311
+ };
4312
+ __name(_ZodNullable, "ZodNullable");
4313
+ var ZodNullable = _ZodNullable;
4314
+ ZodNullable.create = (type, params) => {
4315
+ return new ZodNullable({
4316
+ innerType: type,
4317
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
4318
+ ...processCreateParams(params)
4319
+ });
4320
+ };
4321
+ var _ZodDefault = class _ZodDefault extends ZodType {
4322
+ _parse(input) {
4323
+ const { ctx } = this._processInputParams(input);
4324
+ let data = ctx.data;
4325
+ if (ctx.parsedType === ZodParsedType.undefined) {
4326
+ data = this._def.defaultValue();
4327
+ }
4328
+ return this._def.innerType._parse({
4329
+ data,
4330
+ path: ctx.path,
4331
+ parent: ctx
4332
+ });
4333
+ }
4334
+ removeDefault() {
4335
+ return this._def.innerType;
4336
+ }
4337
+ };
4338
+ __name(_ZodDefault, "ZodDefault");
4339
+ var ZodDefault = _ZodDefault;
4340
+ ZodDefault.create = (type, params) => {
4341
+ return new ZodDefault({
4342
+ innerType: type,
4343
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
4344
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4345
+ ...processCreateParams(params)
4346
+ });
4347
+ };
4348
+ var _ZodCatch = class _ZodCatch extends ZodType {
4349
+ _parse(input) {
4350
+ const { ctx } = this._processInputParams(input);
4351
+ const newCtx = {
4352
+ ...ctx,
4353
+ common: {
4354
+ ...ctx.common,
4355
+ issues: []
4356
+ }
4357
+ };
4358
+ const result = this._def.innerType._parse({
4359
+ data: newCtx.data,
4360
+ path: newCtx.path,
4361
+ parent: {
4362
+ ...newCtx
4363
+ }
4364
+ });
4365
+ if (isAsync(result)) {
4366
+ return result.then((result2) => {
4367
+ return {
4368
+ status: "valid",
4369
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
4370
+ get error() {
4371
+ return new ZodError(newCtx.common.issues);
4372
+ },
4373
+ input: newCtx.data
4374
+ })
4375
+ };
4376
+ });
4377
+ } else {
4378
+ return {
4379
+ status: "valid",
4380
+ value: result.status === "valid" ? result.value : this._def.catchValue({
4381
+ get error() {
4382
+ return new ZodError(newCtx.common.issues);
4383
+ },
4384
+ input: newCtx.data
4385
+ })
4386
+ };
4387
+ }
4388
+ }
4389
+ removeCatch() {
4390
+ return this._def.innerType;
4391
+ }
4392
+ };
4393
+ __name(_ZodCatch, "ZodCatch");
4394
+ var ZodCatch = _ZodCatch;
4395
+ ZodCatch.create = (type, params) => {
4396
+ return new ZodCatch({
4397
+ innerType: type,
4398
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
4399
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
4400
+ ...processCreateParams(params)
4401
+ });
4402
+ };
4403
+ var _ZodNaN = class _ZodNaN extends ZodType {
4404
+ _parse(input) {
4405
+ const parsedType = this._getType(input);
4406
+ if (parsedType !== ZodParsedType.nan) {
4407
+ const ctx = this._getOrReturnCtx(input);
4408
+ addIssueToContext(ctx, {
4409
+ code: ZodIssueCode.invalid_type,
4410
+ expected: ZodParsedType.nan,
4411
+ received: ctx.parsedType
4412
+ });
4413
+ return INVALID;
4414
+ }
4415
+ return { status: "valid", value: input.data };
4416
+ }
4417
+ };
4418
+ __name(_ZodNaN, "ZodNaN");
4419
+ var ZodNaN = _ZodNaN;
4420
+ ZodNaN.create = (params) => {
4421
+ return new ZodNaN({
4422
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
4423
+ ...processCreateParams(params)
4424
+ });
4425
+ };
4426
+ var BRAND = Symbol("zod_brand");
4427
+ var _ZodBranded = class _ZodBranded extends ZodType {
4428
+ _parse(input) {
4429
+ const { ctx } = this._processInputParams(input);
4430
+ const data = ctx.data;
4431
+ return this._def.type._parse({
4432
+ data,
4433
+ path: ctx.path,
4434
+ parent: ctx
4435
+ });
4436
+ }
4437
+ unwrap() {
4438
+ return this._def.type;
4439
+ }
4440
+ };
4441
+ __name(_ZodBranded, "ZodBranded");
4442
+ var ZodBranded = _ZodBranded;
4443
+ var _ZodPipeline = class _ZodPipeline extends ZodType {
4444
+ _parse(input) {
4445
+ const { status, ctx } = this._processInputParams(input);
4446
+ if (ctx.common.async) {
4447
+ const handleAsync = /* @__PURE__ */ __name(async () => {
4448
+ const inResult = await this._def.in._parseAsync({
4449
+ data: ctx.data,
4450
+ path: ctx.path,
4451
+ parent: ctx
4452
+ });
4453
+ if (inResult.status === "aborted")
4454
+ return INVALID;
4455
+ if (inResult.status === "dirty") {
4456
+ status.dirty();
4457
+ return DIRTY(inResult.value);
4458
+ } else {
4459
+ return this._def.out._parseAsync({
4460
+ data: inResult.value,
4461
+ path: ctx.path,
4462
+ parent: ctx
4463
+ });
4464
+ }
4465
+ }, "handleAsync");
4466
+ return handleAsync();
4467
+ } else {
4468
+ const inResult = this._def.in._parseSync({
4469
+ data: ctx.data,
4470
+ path: ctx.path,
4471
+ parent: ctx
4472
+ });
4473
+ if (inResult.status === "aborted")
4474
+ return INVALID;
4475
+ if (inResult.status === "dirty") {
4476
+ status.dirty();
4477
+ return {
4478
+ status: "dirty",
4479
+ value: inResult.value
4480
+ };
4481
+ } else {
4482
+ return this._def.out._parseSync({
4483
+ data: inResult.value,
4484
+ path: ctx.path,
4485
+ parent: ctx
4486
+ });
4487
+ }
4488
+ }
4489
+ }
4490
+ static create(a, b) {
4491
+ return new _ZodPipeline({
4492
+ in: a,
4493
+ out: b,
4494
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4495
+ });
4496
+ }
4497
+ };
4498
+ __name(_ZodPipeline, "ZodPipeline");
4499
+ var ZodPipeline = _ZodPipeline;
4500
+ var _ZodReadonly = class _ZodReadonly extends ZodType {
4501
+ _parse(input) {
4502
+ const result = this._def.innerType._parse(input);
4503
+ if (isValid(result)) {
4504
+ result.value = Object.freeze(result.value);
4505
+ }
4506
+ return result;
4507
+ }
4508
+ };
4509
+ __name(_ZodReadonly, "ZodReadonly");
4510
+ var ZodReadonly = _ZodReadonly;
4511
+ ZodReadonly.create = (type, params) => {
4512
+ return new ZodReadonly({
4513
+ innerType: type,
4514
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4515
+ ...processCreateParams(params)
4516
+ });
4517
+ };
4518
+ var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
4519
+ if (check)
4520
+ return ZodAny.create().superRefine((data, ctx) => {
4521
+ var _a, _b;
4522
+ if (!check(data)) {
4523
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4524
+ const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
4525
+ const p2 = typeof p === "string" ? { message: p } : p;
4526
+ ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
4527
+ }
4528
+ });
4529
+ return ZodAny.create();
4530
+ }, "custom");
4531
+ var late = {
4532
+ object: ZodObject.lazycreate
4533
+ };
4534
+ var ZodFirstPartyTypeKind;
4535
+ (function(ZodFirstPartyTypeKind2) {
4536
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4537
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4538
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4539
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4540
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4541
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4542
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4543
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4544
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4545
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4546
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4547
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4548
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4549
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4550
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4551
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4552
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4553
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4554
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4555
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4556
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4557
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4558
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4559
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4560
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4561
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4562
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4563
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4564
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4565
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4566
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4567
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4568
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4569
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4570
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4571
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4572
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4573
+ var instanceOfType = /* @__PURE__ */ __name((cls, params = {
4574
+ message: `Input not instance of ${cls.name}`
4575
+ }) => custom((data) => data instanceof cls, params), "instanceOfType");
4576
+ var stringType = ZodString.create;
4577
+ var numberType = ZodNumber.create;
4578
+ var nanType = ZodNaN.create;
4579
+ var bigIntType = ZodBigInt.create;
4580
+ var booleanType = ZodBoolean.create;
4581
+ var dateType = ZodDate.create;
4582
+ var symbolType = ZodSymbol.create;
4583
+ var undefinedType = ZodUndefined.create;
4584
+ var nullType = ZodNull.create;
4585
+ var anyType = ZodAny.create;
4586
+ var unknownType = ZodUnknown.create;
4587
+ var neverType = ZodNever.create;
4588
+ var voidType = ZodVoid.create;
4589
+ var arrayType = ZodArray.create;
4590
+ var objectType = ZodObject.create;
4591
+ var strictObjectType = ZodObject.strictCreate;
4592
+ var unionType = ZodUnion.create;
4593
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4594
+ var intersectionType = ZodIntersection.create;
4595
+ var tupleType = ZodTuple.create;
4596
+ var recordType = ZodRecord.create;
4597
+ var mapType = ZodMap.create;
4598
+ var setType = ZodSet.create;
4599
+ var functionType = ZodFunction.create;
4600
+ var lazyType = ZodLazy.create;
4601
+ var literalType = ZodLiteral.create;
4602
+ var enumType = ZodEnum.create;
4603
+ var nativeEnumType = ZodNativeEnum.create;
4604
+ var promiseType = ZodPromise.create;
4605
+ var effectsType = ZodEffects.create;
4606
+ var optionalType = ZodOptional.create;
4607
+ var nullableType = ZodNullable.create;
4608
+ var preprocessType = ZodEffects.createWithPreprocess;
4609
+ var pipelineType = ZodPipeline.create;
4610
+ var ostring = /* @__PURE__ */ __name(() => stringType().optional(), "ostring");
4611
+ var onumber = /* @__PURE__ */ __name(() => numberType().optional(), "onumber");
4612
+ var oboolean = /* @__PURE__ */ __name(() => booleanType().optional(), "oboolean");
4613
+ var coerce = {
4614
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
4615
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
4616
+ boolean: (arg) => ZodBoolean.create({
4617
+ ...arg,
4618
+ coerce: true
4619
+ }),
4620
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
4621
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
4622
+ };
4623
+ var NEVER = INVALID;
4624
+ var z = /* @__PURE__ */ Object.freeze({
4625
+ __proto__: null,
4626
+ defaultErrorMap: errorMap,
4627
+ setErrorMap,
4628
+ getErrorMap,
4629
+ makeIssue,
4630
+ EMPTY_PATH,
4631
+ addIssueToContext,
4632
+ ParseStatus,
4633
+ INVALID,
4634
+ DIRTY,
4635
+ OK,
4636
+ isAborted,
4637
+ isDirty,
4638
+ isValid,
4639
+ isAsync,
4640
+ get util() {
4641
+ return util;
4642
+ },
4643
+ get objectUtil() {
4644
+ return objectUtil;
4645
+ },
4646
+ ZodParsedType,
4647
+ getParsedType,
4648
+ ZodType,
4649
+ ZodString,
4650
+ ZodNumber,
4651
+ ZodBigInt,
4652
+ ZodBoolean,
4653
+ ZodDate,
4654
+ ZodSymbol,
4655
+ ZodUndefined,
4656
+ ZodNull,
4657
+ ZodAny,
4658
+ ZodUnknown,
4659
+ ZodNever,
4660
+ ZodVoid,
4661
+ ZodArray,
4662
+ ZodObject,
4663
+ ZodUnion,
4664
+ ZodDiscriminatedUnion,
4665
+ ZodIntersection,
4666
+ ZodTuple,
4667
+ ZodRecord,
4668
+ ZodMap,
4669
+ ZodSet,
4670
+ ZodFunction,
4671
+ ZodLazy,
4672
+ ZodLiteral,
4673
+ ZodEnum,
4674
+ ZodNativeEnum,
4675
+ ZodPromise,
4676
+ ZodEffects,
4677
+ ZodTransformer: ZodEffects,
4678
+ ZodOptional,
4679
+ ZodNullable,
4680
+ ZodDefault,
4681
+ ZodCatch,
4682
+ ZodNaN,
4683
+ BRAND,
4684
+ ZodBranded,
4685
+ ZodPipeline,
4686
+ ZodReadonly,
4687
+ custom,
4688
+ Schema: ZodType,
4689
+ ZodSchema: ZodType,
4690
+ late,
4691
+ get ZodFirstPartyTypeKind() {
4692
+ return ZodFirstPartyTypeKind;
4693
+ },
4694
+ coerce,
4695
+ any: anyType,
4696
+ array: arrayType,
4697
+ bigint: bigIntType,
4698
+ boolean: booleanType,
4699
+ date: dateType,
4700
+ discriminatedUnion: discriminatedUnionType,
4701
+ effect: effectsType,
4702
+ "enum": enumType,
4703
+ "function": functionType,
4704
+ "instanceof": instanceOfType,
4705
+ intersection: intersectionType,
4706
+ lazy: lazyType,
4707
+ literal: literalType,
4708
+ map: mapType,
4709
+ nan: nanType,
4710
+ nativeEnum: nativeEnumType,
4711
+ never: neverType,
4712
+ "null": nullType,
4713
+ nullable: nullableType,
4714
+ number: numberType,
4715
+ object: objectType,
4716
+ oboolean,
4717
+ onumber,
4718
+ optional: optionalType,
4719
+ ostring,
4720
+ pipeline: pipelineType,
4721
+ preprocess: preprocessType,
4722
+ promise: promiseType,
4723
+ record: recordType,
4724
+ set: setType,
4725
+ strictObject: strictObjectType,
4726
+ string: stringType,
4727
+ symbol: symbolType,
4728
+ transformer: effectsType,
4729
+ tuple: tupleType,
4730
+ "undefined": undefinedType,
4731
+ union: unionType,
4732
+ unknown: unknownType,
4733
+ "void": voidType,
4734
+ NEVER,
4735
+ ZodIssueCode,
4736
+ quotelessJson,
4737
+ ZodError
4738
+ });
4739
+
4740
+ // ../shared/src/rpc/index.ts
4741
+ var numberOrHex = z.union([
4742
+ z.string(),
4743
+ z.number()
914
4744
  ]).transform((str) => BigInt(str));
915
4745
  var camelCase = /* @__PURE__ */ __name((str) => str.replace(/_([a-z])/g, (_, char) => char.toUpperCase()), "camelCase");
916
4746
  var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
@@ -943,82 +4773,82 @@ var createRequest = /* @__PURE__ */ __name((method, responseParser, paramsParser
943
4773
  cause: data.error
944
4774
  });
945
4775
  }, "createRequest");
946
- var fundingEnvironment = zod.z.object({
4776
+ var fundingEnvironment = z.object({
947
4777
  redemption_tax: numberOrHex,
948
4778
  minimum_funding_amount: numberOrHex
949
4779
  });
950
4780
  var getFundingEnvironment = createRequest("cf_funding_environment", fundingEnvironment);
951
- var chainAssetMap = /* @__PURE__ */ __name((parser) => zod.z.object({
952
- Bitcoin: zod.z.object({
4781
+ var chainAssetMap = /* @__PURE__ */ __name((parser) => z.object({
4782
+ Bitcoin: z.object({
953
4783
  BTC: parser
954
4784
  }),
955
- Ethereum: zod.z.object({
4785
+ Ethereum: z.object({
956
4786
  ETH: parser,
957
4787
  USDC: parser,
958
4788
  FLIP: parser
959
4789
  }),
960
- Polkadot: zod.z.object({
4790
+ Polkadot: z.object({
961
4791
  DOT: parser
962
4792
  })
963
4793
  }), "chainAssetMap");
964
4794
  var chainAssetNumberMap = chainAssetMap(numberOrHex);
965
- var swappingEnvironment = zod.z.object({
4795
+ var swappingEnvironment = z.object({
966
4796
  minimum_swap_amounts: chainAssetNumberMap
967
4797
  });
968
4798
  createRequest("cf_swapping_environment", swappingEnvironment);
969
- var ingressEgressEnvironment = zod.z.object({
4799
+ var ingressEgressEnvironment = z.object({
970
4800
  minimum_deposit_amounts: chainAssetNumberMap
971
4801
  });
972
4802
  createRequest("cf_ingress_egress_environment", ingressEgressEnvironment);
973
- var rpcAsset = zod.z.union([
974
- zod.z.literal("BTC"),
975
- zod.z.object({
976
- chain: zod.z.literal("Bitcoin"),
977
- asset: zod.z.literal("BTC")
4803
+ var rpcAsset = z.union([
4804
+ z.literal("BTC"),
4805
+ z.object({
4806
+ chain: z.literal("Bitcoin"),
4807
+ asset: z.literal("BTC")
978
4808
  }),
979
- zod.z.literal("DOT"),
980
- zod.z.object({
981
- chain: zod.z.literal("Polkadot"),
982
- asset: zod.z.literal("DOT")
4809
+ z.literal("DOT"),
4810
+ z.object({
4811
+ chain: z.literal("Polkadot"),
4812
+ asset: z.literal("DOT")
983
4813
  }),
984
- zod.z.literal("FLIP"),
985
- zod.z.object({
986
- chain: zod.z.literal("Ethereum"),
987
- asset: zod.z.literal("FLIP")
4814
+ z.literal("FLIP"),
4815
+ z.object({
4816
+ chain: z.literal("Ethereum"),
4817
+ asset: z.literal("FLIP")
988
4818
  }),
989
- zod.z.literal("ETH"),
990
- zod.z.object({
991
- chain: zod.z.literal("Ethereum"),
992
- asset: zod.z.literal("ETH")
4819
+ z.literal("ETH"),
4820
+ z.object({
4821
+ chain: z.literal("Ethereum"),
4822
+ asset: z.literal("ETH")
993
4823
  }),
994
- zod.z.literal("USDC"),
995
- zod.z.object({
996
- chain: zod.z.literal("Ethereum"),
997
- asset: zod.z.literal("USDC")
4824
+ z.literal("USDC"),
4825
+ z.object({
4826
+ chain: z.literal("Ethereum"),
4827
+ asset: z.literal("USDC")
998
4828
  })
999
4829
  ]);
1000
- var poolInfo = zod.z.object({
1001
- limit_order_fee_hundredth_pips: zod.z.number(),
1002
- range_order_fee_hundredth_pips: zod.z.number(),
4830
+ var poolInfo = z.object({
4831
+ limit_order_fee_hundredth_pips: z.number(),
4832
+ range_order_fee_hundredth_pips: z.number(),
1003
4833
  pair_asset: rpcAsset
1004
4834
  });
1005
- var feesInfo = zod.z.object({
1006
- Bitcoin: zod.z.object({
4835
+ var feesInfo = z.object({
4836
+ Bitcoin: z.object({
1007
4837
  BTC: poolInfo
1008
4838
  }),
1009
- Ethereum: zod.z.object({
4839
+ Ethereum: z.object({
1010
4840
  ETH: poolInfo,
1011
4841
  FLIP: poolInfo
1012
4842
  }),
1013
- Polkadot: zod.z.object({
4843
+ Polkadot: z.object({
1014
4844
  DOT: poolInfo
1015
4845
  })
1016
4846
  });
1017
- var poolsEnvironment = zod.z.object({
4847
+ var poolsEnvironment = z.object({
1018
4848
  fees: feesInfo
1019
4849
  });
1020
4850
  createRequest("cf_pool_info", poolsEnvironment);
1021
- createRequest("cf_environment", zod.z.object({
4851
+ createRequest("cf_environment", z.object({
1022
4852
  ingress_egress: ingressEgressEnvironment,
1023
4853
  swapping: swappingEnvironment,
1024
4854
  funding: fundingEnvironment,