@learncard/network-plugin 2.1.7 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1135,8 +1135,4297 @@ var experimental_formDataLink = httpLinkFactory({
1135
1135
  });
1136
1136
 
1137
1137
  // ../../learn-card-network/brain-client/dist/brain-client.esm.js
1138
+ var __create = Object.create;
1138
1139
  var __defProp2 = Object.defineProperty;
1140
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1141
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1142
+ var __getProtoOf = Object.getPrototypeOf;
1143
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1139
1144
  var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
1145
+ var __commonJS = /* @__PURE__ */ __name((cb, mod2) => /* @__PURE__ */ __name(function __require() {
1146
+ return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
1147
+ }, "__require"), "__commonJS");
1148
+ var __copyProps = /* @__PURE__ */ __name((to, from, except, desc) => {
1149
+ if (from && typeof from === "object" || typeof from === "function") {
1150
+ for (let key of __getOwnPropNames(from))
1151
+ if (!__hasOwnProp.call(to, key) && key !== except)
1152
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1153
+ }
1154
+ return to;
1155
+ }, "__copyProps");
1156
+ var __toESM = /* @__PURE__ */ __name((mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
1157
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp2(target, "default", { value: mod2, enumerable: true }) : target,
1158
+ mod2
1159
+ )), "__toESM");
1160
+ var require_helpers_cjs_development = __commonJS({
1161
+ "../../learn-card-helpers/dist/helpers.cjs.development.js"(exports, module) {
1162
+ var __create2 = Object.create;
1163
+ var __defProp22 = Object.defineProperty;
1164
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1165
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
1166
+ var __getProtoOf2 = Object.getPrototypeOf;
1167
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1168
+ var __name22 = /* @__PURE__ */ __name2((target, value) => __defProp22(target, "name", { value, configurable: true }), "__name");
1169
+ var __commonJS2 = /* @__PURE__ */ __name2((cb, mod2) => /* @__PURE__ */ __name2(/* @__PURE__ */ __name(function __require() {
1170
+ return mod2 || (0, cb[__getOwnPropNames2(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
1171
+ }, "__require"), "__require"), "__commonJS");
1172
+ var __export = /* @__PURE__ */ __name2((target, all) => {
1173
+ for (var name in all)
1174
+ __defProp22(target, name, { get: all[name], enumerable: true });
1175
+ }, "__export");
1176
+ var __copyProps2 = /* @__PURE__ */ __name2((to, from, except, desc) => {
1177
+ if (from && typeof from === "object" || typeof from === "function") {
1178
+ for (let key of __getOwnPropNames2(from))
1179
+ if (!__hasOwnProp2.call(to, key) && key !== except)
1180
+ __defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
1181
+ }
1182
+ return to;
1183
+ }, "__copyProps");
1184
+ var __toESM2 = /* @__PURE__ */ __name2((mod2, isNodeMode, target) => (target = mod2 != null ? __create2(__getProtoOf2(mod2)) : {}, __copyProps2(
1185
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp22(target, "default", { value: mod2, enumerable: true }) : target,
1186
+ mod2
1187
+ )), "__toESM");
1188
+ var __toCommonJS = /* @__PURE__ */ __name2((mod2) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod2), "__toCommonJS");
1189
+ var require_types_cjs_development = __commonJS2({
1190
+ "../learn-card-types/dist/types.cjs.development.js"(exports2, module2) {
1191
+ "use strict";
1192
+ var __defProp222 = Object.defineProperty;
1193
+ var __getOwnPropDesc22 = Object.getOwnPropertyDescriptor;
1194
+ var __getOwnPropNames22 = Object.getOwnPropertyNames;
1195
+ var __hasOwnProp22 = Object.prototype.hasOwnProperty;
1196
+ var __name222 = /* @__PURE__ */ __name22((target, value) => __defProp222(target, "name", { value, configurable: true }), "__name");
1197
+ var __export2 = /* @__PURE__ */ __name22((target, all) => {
1198
+ for (var name in all)
1199
+ __defProp222(target, name, { get: all[name], enumerable: true });
1200
+ }, "__export");
1201
+ var __copyProps22 = /* @__PURE__ */ __name22((to, from, except, desc) => {
1202
+ if (from && typeof from === "object" || typeof from === "function") {
1203
+ for (let key of __getOwnPropNames22(from))
1204
+ if (!__hasOwnProp22.call(to, key) && key !== except)
1205
+ __defProp222(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc22(from, key)) || desc.enumerable });
1206
+ }
1207
+ return to;
1208
+ }, "__copyProps");
1209
+ var __toCommonJS2 = /* @__PURE__ */ __name22((mod22) => __copyProps22(__defProp222({}, "__esModule", { value: true }), mod22), "__toCommonJS");
1210
+ var src_exports2 = {};
1211
+ __export2(src_exports2, {
1212
+ AchievementCredentialValidator: () => AchievementCredentialValidator2,
1213
+ AchievementCriteriaValidator: () => AchievementCriteriaValidator2,
1214
+ AchievementSubjectValidator: () => AchievementSubjectValidator2,
1215
+ AchievementTypeValidator: () => AchievementTypeValidator2,
1216
+ AchievementValidator: () => AchievementValidator2,
1217
+ AddressValidator: () => AddressValidator2,
1218
+ AlignmentTargetTypeValidator: () => AlignmentTargetTypeValidator2,
1219
+ AlignmentValidator: () => AlignmentValidator2,
1220
+ BoostPermissionsValidator: () => BoostPermissionsValidator2,
1221
+ BoostQueryValidator: () => BoostQueryValidator2,
1222
+ BoostRecipientValidator: () => BoostRecipientValidator2,
1223
+ BoostValidator: () => BoostValidator2,
1224
+ ConsentFlowContractDataValidator: () => ConsentFlowContractDataValidator2,
1225
+ ConsentFlowContractDetailsValidator: () => ConsentFlowContractDetailsValidator2,
1226
+ ConsentFlowContractQueryValidator: () => ConsentFlowContractQueryValidator2,
1227
+ ConsentFlowContractValidator: () => ConsentFlowContractValidator2,
1228
+ ConsentFlowDataQueryValidator: () => ConsentFlowDataQueryValidator2,
1229
+ ConsentFlowTermValidator: () => ConsentFlowTermValidator2,
1230
+ ConsentFlowTermsQueryValidator: () => ConsentFlowTermsQueryValidator2,
1231
+ ConsentFlowTermsStatusValidator: () => ConsentFlowTermsStatusValidator2,
1232
+ ConsentFlowTermsValidator: () => ConsentFlowTermsValidator2,
1233
+ ConsentFlowTransactionActionValidator: () => ConsentFlowTransactionActionValidator2,
1234
+ ConsentFlowTransactionValidator: () => ConsentFlowTransactionValidator2,
1235
+ ConsentFlowTransactionsQueryValidator: () => ConsentFlowTransactionsQueryValidator2,
1236
+ ContextValidator: () => ContextValidator2,
1237
+ CredentialInfoValidator: () => CredentialInfoValidator2,
1238
+ CredentialRecordValidator: () => CredentialRecordValidator2,
1239
+ CredentialSchemaValidator: () => CredentialSchemaValidator2,
1240
+ CredentialStatusValidator: () => CredentialStatusValidator2,
1241
+ CredentialSubjectValidator: () => CredentialSubjectValidator2,
1242
+ CriteriaValidator: () => CriteriaValidator2,
1243
+ DidDocumentValidator: () => DidDocumentValidator2,
1244
+ EncryptedCredentialRecordValidator: () => EncryptedCredentialRecordValidator2,
1245
+ EncryptedRecordValidator: () => EncryptedRecordValidator2,
1246
+ EndorsementCredentialValidator: () => EndorsementCredentialValidator2,
1247
+ EndorsementSubjectValidator: () => EndorsementSubjectValidator2,
1248
+ EvidenceValidator: () => EvidenceValidator2,
1249
+ GeoCoordinatesValidator: () => GeoCoordinatesValidator2,
1250
+ IdentifierEntryValidator: () => IdentifierEntryValidator2,
1251
+ IdentifierTypeValidator: () => IdentifierTypeValidator2,
1252
+ IdentityObjectValidator: () => IdentityObjectValidator2,
1253
+ ImageValidator: () => ImageValidator2,
1254
+ JWERecipientHeaderValidator: () => JWERecipientHeaderValidator2,
1255
+ JWERecipientValidator: () => JWERecipientValidator2,
1256
+ JWEValidator: () => JWEValidator2,
1257
+ JWKValidator: () => JWKValidator2,
1258
+ KnownAchievementTypeValidator: () => KnownAchievementTypeValidator2,
1259
+ LCNBoostClaimLinkOptionsValidator: () => LCNBoostClaimLinkOptionsValidator2,
1260
+ LCNBoostClaimLinkSigningAuthorityValidator: () => LCNBoostClaimLinkSigningAuthorityValidator2,
1261
+ LCNBoostStatus: () => LCNBoostStatus2,
1262
+ LCNNotificationDataValidator: () => LCNNotificationDataValidator2,
1263
+ LCNNotificationMessageValidator: () => LCNNotificationMessageValidator2,
1264
+ LCNNotificationTypeEnumValidator: () => LCNNotificationTypeEnumValidator2,
1265
+ LCNNotificationValidator: () => LCNNotificationValidator2,
1266
+ LCNProfileConnectionStatusEnum: () => LCNProfileConnectionStatusEnum2,
1267
+ LCNProfileQueryValidator: () => LCNProfileQueryValidator2,
1268
+ LCNProfileValidator: () => LCNProfileValidator2,
1269
+ LCNSigningAuthorityForUserValidator: () => LCNSigningAuthorityForUserValidator2,
1270
+ LCNSigningAuthorityValidator: () => LCNSigningAuthorityValidator2,
1271
+ PaginatedBoostRecipientsValidator: () => PaginatedBoostRecipientsValidator2,
1272
+ PaginatedBoostsValidator: () => PaginatedBoostsValidator2,
1273
+ PaginatedConsentFlowContractsValidator: () => PaginatedConsentFlowContractsValidator2,
1274
+ PaginatedConsentFlowDataValidator: () => PaginatedConsentFlowDataValidator2,
1275
+ PaginatedConsentFlowTermsValidator: () => PaginatedConsentFlowTermsValidator2,
1276
+ PaginatedConsentFlowTransactionsValidator: () => PaginatedConsentFlowTransactionsValidator2,
1277
+ PaginatedEncryptedCredentialRecordsValidator: () => PaginatedEncryptedCredentialRecordsValidator2,
1278
+ PaginatedEncryptedRecordsValidator: () => PaginatedEncryptedRecordsValidator2,
1279
+ PaginatedLCNProfilesValidator: () => PaginatedLCNProfilesValidator2,
1280
+ PaginationOptionsValidator: () => PaginationOptionsValidator2,
1281
+ PaginationResponseValidator: () => PaginationResponseValidator2,
1282
+ ProfileValidator: () => ProfileValidator2,
1283
+ ProofValidator: () => ProofValidator2,
1284
+ RefreshServiceValidator: () => RefreshServiceValidator2,
1285
+ RelatedValidator: () => RelatedValidator2,
1286
+ ResultDescriptionValidator: () => ResultDescriptionValidator2,
1287
+ ResultStatusTypeValidator: () => ResultStatusTypeValidator2,
1288
+ ResultTypeValidator: () => ResultTypeValidator2,
1289
+ ResultValidator: () => ResultValidator2,
1290
+ RubricCriterionValidator: () => RubricCriterionValidator2,
1291
+ SentCredentialInfoValidator: () => SentCredentialInfoValidator2,
1292
+ ServiceValidator: () => ServiceValidator2,
1293
+ UnsignedAchievementCredentialValidator: () => UnsignedAchievementCredentialValidator2,
1294
+ UnsignedVCValidator: () => UnsignedVCValidator2,
1295
+ UnsignedVPValidator: () => UnsignedVPValidator2,
1296
+ VCValidator: () => VCValidator2,
1297
+ VPValidator: () => VPValidator2,
1298
+ VerificationCheckValidator: () => VerificationCheckValidator2,
1299
+ VerificationItemValidator: () => VerificationItemValidator2,
1300
+ VerificationMethodValidator: () => VerificationMethodValidator2,
1301
+ VerificationStatusEnum: () => VerificationStatusEnum2,
1302
+ VerificationStatusValidator: () => VerificationStatusValidator2
1303
+ });
1304
+ module2.exports = __toCommonJS2(src_exports2);
1305
+ var util2;
1306
+ (function(util22) {
1307
+ util22.assertEqual = (val) => val;
1308
+ function assertIs(_arg) {
1309
+ }
1310
+ __name(assertIs, "assertIs");
1311
+ __name2(assertIs, "assertIs");
1312
+ __name22(assertIs, "assertIs");
1313
+ __name222(assertIs, "assertIs");
1314
+ util22.assertIs = assertIs;
1315
+ function assertNever(_x) {
1316
+ throw new Error();
1317
+ }
1318
+ __name(assertNever, "assertNever");
1319
+ __name2(assertNever, "assertNever");
1320
+ __name22(assertNever, "assertNever");
1321
+ __name222(assertNever, "assertNever");
1322
+ util22.assertNever = assertNever;
1323
+ util22.arrayToEnum = (items) => {
1324
+ const obj = {};
1325
+ for (const item of items) {
1326
+ obj[item] = item;
1327
+ }
1328
+ return obj;
1329
+ };
1330
+ util22.getValidEnumValues = (obj) => {
1331
+ const validKeys = util22.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
1332
+ const filtered = {};
1333
+ for (const k of validKeys) {
1334
+ filtered[k] = obj[k];
1335
+ }
1336
+ return util22.objectValues(filtered);
1337
+ };
1338
+ util22.objectValues = (obj) => {
1339
+ return util22.objectKeys(obj).map(function(e) {
1340
+ return obj[e];
1341
+ });
1342
+ };
1343
+ util22.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
1344
+ const keys = [];
1345
+ for (const key in object) {
1346
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
1347
+ keys.push(key);
1348
+ }
1349
+ }
1350
+ return keys;
1351
+ };
1352
+ util22.find = (arr, checker) => {
1353
+ for (const item of arr) {
1354
+ if (checker(item))
1355
+ return item;
1356
+ }
1357
+ return void 0;
1358
+ };
1359
+ util22.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
1360
+ function joinValues(array, separator = " | ") {
1361
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
1362
+ }
1363
+ __name(joinValues, "joinValues");
1364
+ __name2(joinValues, "joinValues");
1365
+ __name22(joinValues, "joinValues");
1366
+ __name222(joinValues, "joinValues");
1367
+ util22.joinValues = joinValues;
1368
+ util22.jsonStringifyReplacer = (_, value) => {
1369
+ if (typeof value === "bigint") {
1370
+ return value.toString();
1371
+ }
1372
+ return value;
1373
+ };
1374
+ })(util2 || (util2 = {}));
1375
+ var ZodParsedType2 = util2.arrayToEnum([
1376
+ "string",
1377
+ "nan",
1378
+ "number",
1379
+ "integer",
1380
+ "float",
1381
+ "boolean",
1382
+ "date",
1383
+ "bigint",
1384
+ "symbol",
1385
+ "function",
1386
+ "undefined",
1387
+ "null",
1388
+ "array",
1389
+ "object",
1390
+ "unknown",
1391
+ "promise",
1392
+ "void",
1393
+ "never",
1394
+ "map",
1395
+ "set"
1396
+ ]);
1397
+ var getParsedType2 = /* @__PURE__ */ __name222((data) => {
1398
+ const t = typeof data;
1399
+ switch (t) {
1400
+ case "undefined":
1401
+ return ZodParsedType2.undefined;
1402
+ case "string":
1403
+ return ZodParsedType2.string;
1404
+ case "number":
1405
+ return isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
1406
+ case "boolean":
1407
+ return ZodParsedType2.boolean;
1408
+ case "function":
1409
+ return ZodParsedType2.function;
1410
+ case "bigint":
1411
+ return ZodParsedType2.bigint;
1412
+ case "symbol":
1413
+ return ZodParsedType2.symbol;
1414
+ case "object":
1415
+ if (Array.isArray(data)) {
1416
+ return ZodParsedType2.array;
1417
+ }
1418
+ if (data === null) {
1419
+ return ZodParsedType2.null;
1420
+ }
1421
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1422
+ return ZodParsedType2.promise;
1423
+ }
1424
+ if (typeof Map !== "undefined" && data instanceof Map) {
1425
+ return ZodParsedType2.map;
1426
+ }
1427
+ if (typeof Set !== "undefined" && data instanceof Set) {
1428
+ return ZodParsedType2.set;
1429
+ }
1430
+ if (typeof Date !== "undefined" && data instanceof Date) {
1431
+ return ZodParsedType2.date;
1432
+ }
1433
+ return ZodParsedType2.object;
1434
+ default:
1435
+ return ZodParsedType2.unknown;
1436
+ }
1437
+ }, "getParsedType");
1438
+ var ZodIssueCode2 = util2.arrayToEnum([
1439
+ "invalid_type",
1440
+ "invalid_literal",
1441
+ "custom",
1442
+ "invalid_union",
1443
+ "invalid_union_discriminator",
1444
+ "invalid_enum_value",
1445
+ "unrecognized_keys",
1446
+ "invalid_arguments",
1447
+ "invalid_return_type",
1448
+ "invalid_date",
1449
+ "invalid_string",
1450
+ "too_small",
1451
+ "too_big",
1452
+ "invalid_intersection_types",
1453
+ "not_multiple_of",
1454
+ "not_finite"
1455
+ ]);
1456
+ var quotelessJson2 = /* @__PURE__ */ __name222((obj) => {
1457
+ const json = JSON.stringify(obj, null, 2);
1458
+ return json.replace(/"([^"]+)":/g, "$1:");
1459
+ }, "quotelessJson");
1460
+ var ZodError2 = /* @__PURE__ */ __name22(class extends Error {
1461
+ constructor(issues) {
1462
+ super();
1463
+ this.issues = [];
1464
+ this.addIssue = (sub) => {
1465
+ this.issues = [...this.issues, sub];
1466
+ };
1467
+ this.addIssues = (subs = []) => {
1468
+ this.issues = [...this.issues, ...subs];
1469
+ };
1470
+ const actualProto = new.target.prototype;
1471
+ if (Object.setPrototypeOf) {
1472
+ Object.setPrototypeOf(this, actualProto);
1473
+ } else {
1474
+ this.__proto__ = actualProto;
1475
+ }
1476
+ this.name = "ZodError";
1477
+ this.issues = issues;
1478
+ }
1479
+ get errors() {
1480
+ return this.issues;
1481
+ }
1482
+ format(_mapper) {
1483
+ const mapper = _mapper || function(issue) {
1484
+ return issue.message;
1485
+ };
1486
+ const fieldErrors = { _errors: [] };
1487
+ const processError = /* @__PURE__ */ __name222((error) => {
1488
+ for (const issue of error.issues) {
1489
+ if (issue.code === "invalid_union") {
1490
+ issue.unionErrors.map(processError);
1491
+ } else if (issue.code === "invalid_return_type") {
1492
+ processError(issue.returnTypeError);
1493
+ } else if (issue.code === "invalid_arguments") {
1494
+ processError(issue.argumentsError);
1495
+ } else if (issue.path.length === 0) {
1496
+ fieldErrors._errors.push(mapper(issue));
1497
+ } else {
1498
+ let curr = fieldErrors;
1499
+ let i = 0;
1500
+ while (i < issue.path.length) {
1501
+ const el = issue.path[i];
1502
+ const terminal = i === issue.path.length - 1;
1503
+ if (!terminal) {
1504
+ curr[el] = curr[el] || { _errors: [] };
1505
+ } else {
1506
+ curr[el] = curr[el] || { _errors: [] };
1507
+ curr[el]._errors.push(mapper(issue));
1508
+ }
1509
+ curr = curr[el];
1510
+ i++;
1511
+ }
1512
+ }
1513
+ }
1514
+ }, "processError");
1515
+ processError(this);
1516
+ return fieldErrors;
1517
+ }
1518
+ toString() {
1519
+ return this.message;
1520
+ }
1521
+ get message() {
1522
+ return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
1523
+ }
1524
+ get isEmpty() {
1525
+ return this.issues.length === 0;
1526
+ }
1527
+ flatten(mapper = (issue) => issue.message) {
1528
+ const fieldErrors = {};
1529
+ const formErrors = [];
1530
+ for (const sub of this.issues) {
1531
+ if (sub.path.length > 0) {
1532
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1533
+ fieldErrors[sub.path[0]].push(mapper(sub));
1534
+ } else {
1535
+ formErrors.push(mapper(sub));
1536
+ }
1537
+ }
1538
+ return { formErrors, fieldErrors };
1539
+ }
1540
+ get formErrors() {
1541
+ return this.flatten();
1542
+ }
1543
+ }, "ZodError");
1544
+ __name222(ZodError2, "ZodError");
1545
+ ZodError2.create = (issues) => {
1546
+ const error = new ZodError2(issues);
1547
+ return error;
1548
+ };
1549
+ var errorMap2 = /* @__PURE__ */ __name222((issue, _ctx) => {
1550
+ let message;
1551
+ switch (issue.code) {
1552
+ case ZodIssueCode2.invalid_type:
1553
+ if (issue.received === ZodParsedType2.undefined) {
1554
+ message = "Required";
1555
+ } else {
1556
+ message = `Expected ${issue.expected}, received ${issue.received}`;
1557
+ }
1558
+ break;
1559
+ case ZodIssueCode2.invalid_literal:
1560
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util2.jsonStringifyReplacer)}`;
1561
+ break;
1562
+ case ZodIssueCode2.unrecognized_keys:
1563
+ message = `Unrecognized key(s) in object: ${util2.joinValues(issue.keys, ", ")}`;
1564
+ break;
1565
+ case ZodIssueCode2.invalid_union:
1566
+ message = `Invalid input`;
1567
+ break;
1568
+ case ZodIssueCode2.invalid_union_discriminator:
1569
+ message = `Invalid discriminator value. Expected ${util2.joinValues(issue.options)}`;
1570
+ break;
1571
+ case ZodIssueCode2.invalid_enum_value:
1572
+ message = `Invalid enum value. Expected ${util2.joinValues(issue.options)}, received '${issue.received}'`;
1573
+ break;
1574
+ case ZodIssueCode2.invalid_arguments:
1575
+ message = `Invalid function arguments`;
1576
+ break;
1577
+ case ZodIssueCode2.invalid_return_type:
1578
+ message = `Invalid function return type`;
1579
+ break;
1580
+ case ZodIssueCode2.invalid_date:
1581
+ message = `Invalid date`;
1582
+ break;
1583
+ case ZodIssueCode2.invalid_string:
1584
+ if (typeof issue.validation === "object") {
1585
+ if ("startsWith" in issue.validation) {
1586
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1587
+ } else if ("endsWith" in issue.validation) {
1588
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1589
+ } else {
1590
+ util2.assertNever(issue.validation);
1591
+ }
1592
+ } else if (issue.validation !== "regex") {
1593
+ message = `Invalid ${issue.validation}`;
1594
+ } else {
1595
+ message = "Invalid";
1596
+ }
1597
+ break;
1598
+ case ZodIssueCode2.too_small:
1599
+ if (issue.type === "array")
1600
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1601
+ else if (issue.type === "string")
1602
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1603
+ else if (issue.type === "number")
1604
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1605
+ else if (issue.type === "date")
1606
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(issue.minimum)}`;
1607
+ else
1608
+ message = "Invalid input";
1609
+ break;
1610
+ case ZodIssueCode2.too_big:
1611
+ if (issue.type === "array")
1612
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1613
+ else if (issue.type === "string")
1614
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1615
+ else if (issue.type === "number")
1616
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1617
+ else if (issue.type === "date")
1618
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(issue.maximum)}`;
1619
+ else
1620
+ message = "Invalid input";
1621
+ break;
1622
+ case ZodIssueCode2.custom:
1623
+ message = `Invalid input`;
1624
+ break;
1625
+ case ZodIssueCode2.invalid_intersection_types:
1626
+ message = `Intersection results could not be merged`;
1627
+ break;
1628
+ case ZodIssueCode2.not_multiple_of:
1629
+ message = `Number must be a multiple of ${issue.multipleOf}`;
1630
+ break;
1631
+ case ZodIssueCode2.not_finite:
1632
+ message = "Number must be finite";
1633
+ break;
1634
+ default:
1635
+ message = _ctx.defaultError;
1636
+ util2.assertNever(issue);
1637
+ }
1638
+ return { message };
1639
+ }, "errorMap");
1640
+ var overrideErrorMap2 = errorMap2;
1641
+ function setErrorMap2(map) {
1642
+ overrideErrorMap2 = map;
1643
+ }
1644
+ __name(setErrorMap2, "setErrorMap");
1645
+ __name2(setErrorMap2, "setErrorMap");
1646
+ __name22(setErrorMap2, "setErrorMap");
1647
+ __name222(setErrorMap2, "setErrorMap");
1648
+ function getErrorMap2() {
1649
+ return overrideErrorMap2;
1650
+ }
1651
+ __name(getErrorMap2, "getErrorMap");
1652
+ __name2(getErrorMap2, "getErrorMap");
1653
+ __name22(getErrorMap2, "getErrorMap");
1654
+ __name222(getErrorMap2, "getErrorMap");
1655
+ var makeIssue2 = /* @__PURE__ */ __name222((params) => {
1656
+ const { data, path, errorMaps, issueData } = params;
1657
+ const fullPath = [...path, ...issueData.path || []];
1658
+ const fullIssue = {
1659
+ ...issueData,
1660
+ path: fullPath
1661
+ };
1662
+ let errorMessage = "";
1663
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
1664
+ for (const map of maps) {
1665
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1666
+ }
1667
+ return {
1668
+ ...issueData,
1669
+ path: fullPath,
1670
+ message: issueData.message || errorMessage
1671
+ };
1672
+ }, "makeIssue");
1673
+ var EMPTY_PATH2 = [];
1674
+ function addIssueToContext2(ctx, issueData) {
1675
+ const issue = makeIssue2({
1676
+ issueData,
1677
+ data: ctx.data,
1678
+ path: ctx.path,
1679
+ errorMaps: [
1680
+ ctx.common.contextualErrorMap,
1681
+ ctx.schemaErrorMap,
1682
+ getErrorMap2(),
1683
+ errorMap2
1684
+ ].filter((x) => !!x)
1685
+ });
1686
+ ctx.common.issues.push(issue);
1687
+ }
1688
+ __name(addIssueToContext2, "addIssueToContext");
1689
+ __name2(addIssueToContext2, "addIssueToContext");
1690
+ __name22(addIssueToContext2, "addIssueToContext");
1691
+ __name222(addIssueToContext2, "addIssueToContext");
1692
+ var ParseStatus2 = /* @__PURE__ */ __name22(class {
1693
+ constructor() {
1694
+ this.value = "valid";
1695
+ }
1696
+ dirty() {
1697
+ if (this.value === "valid")
1698
+ this.value = "dirty";
1699
+ }
1700
+ abort() {
1701
+ if (this.value !== "aborted")
1702
+ this.value = "aborted";
1703
+ }
1704
+ static mergeArray(status, results) {
1705
+ const arrayValue = [];
1706
+ for (const s of results) {
1707
+ if (s.status === "aborted")
1708
+ return INVALID2;
1709
+ if (s.status === "dirty")
1710
+ status.dirty();
1711
+ arrayValue.push(s.value);
1712
+ }
1713
+ return { status: status.value, value: arrayValue };
1714
+ }
1715
+ static async mergeObjectAsync(status, pairs) {
1716
+ const syncPairs = [];
1717
+ for (const pair of pairs) {
1718
+ syncPairs.push({
1719
+ key: await pair.key,
1720
+ value: await pair.value
1721
+ });
1722
+ }
1723
+ return ParseStatus2.mergeObjectSync(status, syncPairs);
1724
+ }
1725
+ static mergeObjectSync(status, pairs) {
1726
+ const finalObject = {};
1727
+ for (const pair of pairs) {
1728
+ const { key, value } = pair;
1729
+ if (key.status === "aborted")
1730
+ return INVALID2;
1731
+ if (value.status === "aborted")
1732
+ return INVALID2;
1733
+ if (key.status === "dirty")
1734
+ status.dirty();
1735
+ if (value.status === "dirty")
1736
+ status.dirty();
1737
+ if (typeof value.value !== "undefined" || pair.alwaysSet) {
1738
+ finalObject[key.value] = value.value;
1739
+ }
1740
+ }
1741
+ return { status: status.value, value: finalObject };
1742
+ }
1743
+ }, "ParseStatus");
1744
+ __name222(ParseStatus2, "ParseStatus");
1745
+ var INVALID2 = Object.freeze({
1746
+ status: "aborted"
1747
+ });
1748
+ var DIRTY2 = /* @__PURE__ */ __name222((value) => ({ status: "dirty", value }), "DIRTY");
1749
+ var OK2 = /* @__PURE__ */ __name222((value) => ({ status: "valid", value }), "OK");
1750
+ var isAborted2 = /* @__PURE__ */ __name222((x) => x.status === "aborted", "isAborted");
1751
+ var isDirty2 = /* @__PURE__ */ __name222((x) => x.status === "dirty", "isDirty");
1752
+ var isValid2 = /* @__PURE__ */ __name222((x) => x.status === "valid", "isValid");
1753
+ var isAsync2 = /* @__PURE__ */ __name222((x) => typeof Promise !== void 0 && x instanceof Promise, "isAsync");
1754
+ var errorUtil2;
1755
+ (function(errorUtil22) {
1756
+ errorUtil22.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1757
+ errorUtil22.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1758
+ })(errorUtil2 || (errorUtil2 = {}));
1759
+ var ParseInputLazyPath2 = /* @__PURE__ */ __name22(class {
1760
+ constructor(parent, value, path, key) {
1761
+ this.parent = parent;
1762
+ this.data = value;
1763
+ this._path = path;
1764
+ this._key = key;
1765
+ }
1766
+ get path() {
1767
+ return this._path.concat(this._key);
1768
+ }
1769
+ }, "ParseInputLazyPath");
1770
+ __name222(ParseInputLazyPath2, "ParseInputLazyPath");
1771
+ var handleResult2 = /* @__PURE__ */ __name222((ctx, result) => {
1772
+ if (isValid2(result)) {
1773
+ return { success: true, data: result.value };
1774
+ } else {
1775
+ if (!ctx.common.issues.length) {
1776
+ throw new Error("Validation failed but no issues detected.");
1777
+ }
1778
+ const error = new ZodError2(ctx.common.issues);
1779
+ return { success: false, error };
1780
+ }
1781
+ }, "handleResult");
1782
+ function processCreateParams2(params) {
1783
+ if (!params)
1784
+ return {};
1785
+ const { errorMap: errorMap22, invalid_type_error, required_error, description } = params;
1786
+ if (errorMap22 && (invalid_type_error || required_error)) {
1787
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
1788
+ }
1789
+ if (errorMap22)
1790
+ return { errorMap: errorMap22, description };
1791
+ const customMap = /* @__PURE__ */ __name222((iss, ctx) => {
1792
+ if (iss.code !== "invalid_type")
1793
+ return { message: ctx.defaultError };
1794
+ if (typeof ctx.data === "undefined") {
1795
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
1796
+ }
1797
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
1798
+ }, "customMap");
1799
+ return { errorMap: customMap, description };
1800
+ }
1801
+ __name(processCreateParams2, "processCreateParams");
1802
+ __name2(processCreateParams2, "processCreateParams");
1803
+ __name22(processCreateParams2, "processCreateParams");
1804
+ __name222(processCreateParams2, "processCreateParams");
1805
+ var ZodType2 = /* @__PURE__ */ __name22(class {
1806
+ constructor(def) {
1807
+ this.spa = this.safeParseAsync;
1808
+ this._def = def;
1809
+ this.parse = this.parse.bind(this);
1810
+ this.safeParse = this.safeParse.bind(this);
1811
+ this.parseAsync = this.parseAsync.bind(this);
1812
+ this.safeParseAsync = this.safeParseAsync.bind(this);
1813
+ this.spa = this.spa.bind(this);
1814
+ this.refine = this.refine.bind(this);
1815
+ this.refinement = this.refinement.bind(this);
1816
+ this.superRefine = this.superRefine.bind(this);
1817
+ this.optional = this.optional.bind(this);
1818
+ this.nullable = this.nullable.bind(this);
1819
+ this.nullish = this.nullish.bind(this);
1820
+ this.array = this.array.bind(this);
1821
+ this.promise = this.promise.bind(this);
1822
+ this.or = this.or.bind(this);
1823
+ this.and = this.and.bind(this);
1824
+ this.transform = this.transform.bind(this);
1825
+ this.brand = this.brand.bind(this);
1826
+ this.default = this.default.bind(this);
1827
+ this.catch = this.catch.bind(this);
1828
+ this.describe = this.describe.bind(this);
1829
+ this.pipe = this.pipe.bind(this);
1830
+ this.isNullable = this.isNullable.bind(this);
1831
+ this.isOptional = this.isOptional.bind(this);
1832
+ }
1833
+ get description() {
1834
+ return this._def.description;
1835
+ }
1836
+ _getType(input) {
1837
+ return getParsedType2(input.data);
1838
+ }
1839
+ _getOrReturnCtx(input, ctx) {
1840
+ return ctx || {
1841
+ common: input.parent.common,
1842
+ data: input.data,
1843
+ parsedType: getParsedType2(input.data),
1844
+ schemaErrorMap: this._def.errorMap,
1845
+ path: input.path,
1846
+ parent: input.parent
1847
+ };
1848
+ }
1849
+ _processInputParams(input) {
1850
+ return {
1851
+ status: new ParseStatus2(),
1852
+ ctx: {
1853
+ common: input.parent.common,
1854
+ data: input.data,
1855
+ parsedType: getParsedType2(input.data),
1856
+ schemaErrorMap: this._def.errorMap,
1857
+ path: input.path,
1858
+ parent: input.parent
1859
+ }
1860
+ };
1861
+ }
1862
+ _parseSync(input) {
1863
+ const result = this._parse(input);
1864
+ if (isAsync2(result)) {
1865
+ throw new Error("Synchronous parse encountered promise.");
1866
+ }
1867
+ return result;
1868
+ }
1869
+ _parseAsync(input) {
1870
+ const result = this._parse(input);
1871
+ return Promise.resolve(result);
1872
+ }
1873
+ parse(data, params) {
1874
+ const result = this.safeParse(data, params);
1875
+ if (result.success)
1876
+ return result.data;
1877
+ throw result.error;
1878
+ }
1879
+ safeParse(data, params) {
1880
+ var _a;
1881
+ const ctx = {
1882
+ common: {
1883
+ issues: [],
1884
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
1885
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
1886
+ },
1887
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1888
+ schemaErrorMap: this._def.errorMap,
1889
+ parent: null,
1890
+ data,
1891
+ parsedType: getParsedType2(data)
1892
+ };
1893
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
1894
+ return handleResult2(ctx, result);
1895
+ }
1896
+ async parseAsync(data, params) {
1897
+ const result = await this.safeParseAsync(data, params);
1898
+ if (result.success)
1899
+ return result.data;
1900
+ throw result.error;
1901
+ }
1902
+ async safeParseAsync(data, params) {
1903
+ const ctx = {
1904
+ common: {
1905
+ issues: [],
1906
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
1907
+ async: true
1908
+ },
1909
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
1910
+ schemaErrorMap: this._def.errorMap,
1911
+ parent: null,
1912
+ data,
1913
+ parsedType: getParsedType2(data)
1914
+ };
1915
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
1916
+ const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
1917
+ return handleResult2(ctx, result);
1918
+ }
1919
+ refine(check, message) {
1920
+ const getIssueProperties = /* @__PURE__ */ __name222((val) => {
1921
+ if (typeof message === "string" || typeof message === "undefined") {
1922
+ return { message };
1923
+ } else if (typeof message === "function") {
1924
+ return message(val);
1925
+ } else {
1926
+ return message;
1927
+ }
1928
+ }, "getIssueProperties");
1929
+ return this._refinement((val, ctx) => {
1930
+ const result = check(val);
1931
+ const setError = /* @__PURE__ */ __name222(() => ctx.addIssue({
1932
+ code: ZodIssueCode2.custom,
1933
+ ...getIssueProperties(val)
1934
+ }), "setError");
1935
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
1936
+ return result.then((data) => {
1937
+ if (!data) {
1938
+ setError();
1939
+ return false;
1940
+ } else {
1941
+ return true;
1942
+ }
1943
+ });
1944
+ }
1945
+ if (!result) {
1946
+ setError();
1947
+ return false;
1948
+ } else {
1949
+ return true;
1950
+ }
1951
+ });
1952
+ }
1953
+ refinement(check, refinementData) {
1954
+ return this._refinement((val, ctx) => {
1955
+ if (!check(val)) {
1956
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
1957
+ return false;
1958
+ } else {
1959
+ return true;
1960
+ }
1961
+ });
1962
+ }
1963
+ _refinement(refinement) {
1964
+ return new ZodEffects2({
1965
+ schema: this,
1966
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
1967
+ effect: { type: "refinement", refinement }
1968
+ });
1969
+ }
1970
+ superRefine(refinement) {
1971
+ return this._refinement(refinement);
1972
+ }
1973
+ optional() {
1974
+ return ZodOptional2.create(this);
1975
+ }
1976
+ nullable() {
1977
+ return ZodNullable2.create(this);
1978
+ }
1979
+ nullish() {
1980
+ return this.optional().nullable();
1981
+ }
1982
+ array() {
1983
+ return ZodArray2.create(this);
1984
+ }
1985
+ promise() {
1986
+ return ZodPromise2.create(this);
1987
+ }
1988
+ or(option) {
1989
+ return ZodUnion2.create([this, option]);
1990
+ }
1991
+ and(incoming) {
1992
+ return ZodIntersection2.create(this, incoming);
1993
+ }
1994
+ transform(transform) {
1995
+ return new ZodEffects2({
1996
+ schema: this,
1997
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
1998
+ effect: { type: "transform", transform }
1999
+ });
2000
+ }
2001
+ default(def) {
2002
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
2003
+ return new ZodDefault2({
2004
+ innerType: this,
2005
+ defaultValue: defaultValueFunc,
2006
+ typeName: ZodFirstPartyTypeKind2.ZodDefault
2007
+ });
2008
+ }
2009
+ brand() {
2010
+ return new ZodBranded2({
2011
+ typeName: ZodFirstPartyTypeKind2.ZodBranded,
2012
+ type: this,
2013
+ ...processCreateParams2(void 0)
2014
+ });
2015
+ }
2016
+ catch(def) {
2017
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
2018
+ return new ZodCatch2({
2019
+ innerType: this,
2020
+ defaultValue: defaultValueFunc,
2021
+ typeName: ZodFirstPartyTypeKind2.ZodCatch
2022
+ });
2023
+ }
2024
+ describe(description) {
2025
+ const This = this.constructor;
2026
+ return new This({
2027
+ ...this._def,
2028
+ description
2029
+ });
2030
+ }
2031
+ pipe(target) {
2032
+ return ZodPipeline2.create(this, target);
2033
+ }
2034
+ isOptional() {
2035
+ return this.safeParse(void 0).success;
2036
+ }
2037
+ isNullable() {
2038
+ return this.safeParse(null).success;
2039
+ }
2040
+ }, "ZodType");
2041
+ __name222(ZodType2, "ZodType");
2042
+ var cuidRegex2 = /^c[^\s-]{8,}$/i;
2043
+ var uuidRegex2 = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
2044
+ var emailRegex2 = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
2045
+ var datetimeRegex2 = /* @__PURE__ */ __name222((args) => {
2046
+ if (args.precision) {
2047
+ if (args.offset) {
2048
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}:\\d{2})|Z)$`);
2049
+ } else {
2050
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
2051
+ }
2052
+ } else if (args.precision === 0) {
2053
+ if (args.offset) {
2054
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$`);
2055
+ } else {
2056
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
2057
+ }
2058
+ } else {
2059
+ if (args.offset) {
2060
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$`);
2061
+ } else {
2062
+ return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
2063
+ }
2064
+ }
2065
+ }, "datetimeRegex");
2066
+ var ZodString2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2067
+ constructor() {
2068
+ super(...arguments);
2069
+ this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), {
2070
+ validation,
2071
+ code: ZodIssueCode2.invalid_string,
2072
+ ...errorUtil2.errToObj(message)
2073
+ });
2074
+ this.nonempty = (message) => this.min(1, errorUtil2.errToObj(message));
2075
+ this.trim = () => new ZodString2({
2076
+ ...this._def,
2077
+ checks: [...this._def.checks, { kind: "trim" }]
2078
+ });
2079
+ }
2080
+ _parse(input) {
2081
+ if (this._def.coerce) {
2082
+ input.data = String(input.data);
2083
+ }
2084
+ const parsedType = this._getType(input);
2085
+ if (parsedType !== ZodParsedType2.string) {
2086
+ const ctx2 = this._getOrReturnCtx(input);
2087
+ addIssueToContext2(
2088
+ ctx2,
2089
+ {
2090
+ code: ZodIssueCode2.invalid_type,
2091
+ expected: ZodParsedType2.string,
2092
+ received: ctx2.parsedType
2093
+ }
2094
+ );
2095
+ return INVALID2;
2096
+ }
2097
+ const status = new ParseStatus2();
2098
+ let ctx = void 0;
2099
+ for (const check of this._def.checks) {
2100
+ if (check.kind === "min") {
2101
+ if (input.data.length < check.value) {
2102
+ ctx = this._getOrReturnCtx(input, ctx);
2103
+ addIssueToContext2(ctx, {
2104
+ code: ZodIssueCode2.too_small,
2105
+ minimum: check.value,
2106
+ type: "string",
2107
+ inclusive: true,
2108
+ exact: false,
2109
+ message: check.message
2110
+ });
2111
+ status.dirty();
2112
+ }
2113
+ } else if (check.kind === "max") {
2114
+ if (input.data.length > check.value) {
2115
+ ctx = this._getOrReturnCtx(input, ctx);
2116
+ addIssueToContext2(ctx, {
2117
+ code: ZodIssueCode2.too_big,
2118
+ maximum: check.value,
2119
+ type: "string",
2120
+ inclusive: true,
2121
+ exact: false,
2122
+ message: check.message
2123
+ });
2124
+ status.dirty();
2125
+ }
2126
+ } else if (check.kind === "length") {
2127
+ const tooBig = input.data.length > check.value;
2128
+ const tooSmall = input.data.length < check.value;
2129
+ if (tooBig || tooSmall) {
2130
+ ctx = this._getOrReturnCtx(input, ctx);
2131
+ if (tooBig) {
2132
+ addIssueToContext2(ctx, {
2133
+ code: ZodIssueCode2.too_big,
2134
+ maximum: check.value,
2135
+ type: "string",
2136
+ inclusive: true,
2137
+ exact: true,
2138
+ message: check.message
2139
+ });
2140
+ } else if (tooSmall) {
2141
+ addIssueToContext2(ctx, {
2142
+ code: ZodIssueCode2.too_small,
2143
+ minimum: check.value,
2144
+ type: "string",
2145
+ inclusive: true,
2146
+ exact: true,
2147
+ message: check.message
2148
+ });
2149
+ }
2150
+ status.dirty();
2151
+ }
2152
+ } else if (check.kind === "email") {
2153
+ if (!emailRegex2.test(input.data)) {
2154
+ ctx = this._getOrReturnCtx(input, ctx);
2155
+ addIssueToContext2(ctx, {
2156
+ validation: "email",
2157
+ code: ZodIssueCode2.invalid_string,
2158
+ message: check.message
2159
+ });
2160
+ status.dirty();
2161
+ }
2162
+ } else if (check.kind === "uuid") {
2163
+ if (!uuidRegex2.test(input.data)) {
2164
+ ctx = this._getOrReturnCtx(input, ctx);
2165
+ addIssueToContext2(ctx, {
2166
+ validation: "uuid",
2167
+ code: ZodIssueCode2.invalid_string,
2168
+ message: check.message
2169
+ });
2170
+ status.dirty();
2171
+ }
2172
+ } else if (check.kind === "cuid") {
2173
+ if (!cuidRegex2.test(input.data)) {
2174
+ ctx = this._getOrReturnCtx(input, ctx);
2175
+ addIssueToContext2(ctx, {
2176
+ validation: "cuid",
2177
+ code: ZodIssueCode2.invalid_string,
2178
+ message: check.message
2179
+ });
2180
+ status.dirty();
2181
+ }
2182
+ } else if (check.kind === "url") {
2183
+ try {
2184
+ new URL(input.data);
2185
+ } catch (_a) {
2186
+ ctx = this._getOrReturnCtx(input, ctx);
2187
+ addIssueToContext2(ctx, {
2188
+ validation: "url",
2189
+ code: ZodIssueCode2.invalid_string,
2190
+ message: check.message
2191
+ });
2192
+ status.dirty();
2193
+ }
2194
+ } else if (check.kind === "regex") {
2195
+ check.regex.lastIndex = 0;
2196
+ const testResult = check.regex.test(input.data);
2197
+ if (!testResult) {
2198
+ ctx = this._getOrReturnCtx(input, ctx);
2199
+ addIssueToContext2(ctx, {
2200
+ validation: "regex",
2201
+ code: ZodIssueCode2.invalid_string,
2202
+ message: check.message
2203
+ });
2204
+ status.dirty();
2205
+ }
2206
+ } else if (check.kind === "trim") {
2207
+ input.data = input.data.trim();
2208
+ } else if (check.kind === "startsWith") {
2209
+ if (!input.data.startsWith(check.value)) {
2210
+ ctx = this._getOrReturnCtx(input, ctx);
2211
+ addIssueToContext2(ctx, {
2212
+ code: ZodIssueCode2.invalid_string,
2213
+ validation: { startsWith: check.value },
2214
+ message: check.message
2215
+ });
2216
+ status.dirty();
2217
+ }
2218
+ } else if (check.kind === "endsWith") {
2219
+ if (!input.data.endsWith(check.value)) {
2220
+ ctx = this._getOrReturnCtx(input, ctx);
2221
+ addIssueToContext2(ctx, {
2222
+ code: ZodIssueCode2.invalid_string,
2223
+ validation: { endsWith: check.value },
2224
+ message: check.message
2225
+ });
2226
+ status.dirty();
2227
+ }
2228
+ } else if (check.kind === "datetime") {
2229
+ const regex = datetimeRegex2(check);
2230
+ if (!regex.test(input.data)) {
2231
+ ctx = this._getOrReturnCtx(input, ctx);
2232
+ addIssueToContext2(ctx, {
2233
+ code: ZodIssueCode2.invalid_string,
2234
+ validation: "datetime",
2235
+ message: check.message
2236
+ });
2237
+ status.dirty();
2238
+ }
2239
+ } else {
2240
+ util2.assertNever(check);
2241
+ }
2242
+ }
2243
+ return { status: status.value, value: input.data };
2244
+ }
2245
+ _addCheck(check) {
2246
+ return new ZodString2({
2247
+ ...this._def,
2248
+ checks: [...this._def.checks, check]
2249
+ });
2250
+ }
2251
+ email(message) {
2252
+ return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
2253
+ }
2254
+ url(message) {
2255
+ return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
2256
+ }
2257
+ uuid(message) {
2258
+ return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
2259
+ }
2260
+ cuid(message) {
2261
+ return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
2262
+ }
2263
+ datetime(options) {
2264
+ var _a;
2265
+ if (typeof options === "string") {
2266
+ return this._addCheck({
2267
+ kind: "datetime",
2268
+ precision: null,
2269
+ offset: false,
2270
+ message: options
2271
+ });
2272
+ }
2273
+ return this._addCheck({
2274
+ kind: "datetime",
2275
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2276
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2277
+ ...errorUtil2.errToObj(options === null || options === void 0 ? void 0 : options.message)
2278
+ });
2279
+ }
2280
+ regex(regex, message) {
2281
+ return this._addCheck({
2282
+ kind: "regex",
2283
+ regex,
2284
+ ...errorUtil2.errToObj(message)
2285
+ });
2286
+ }
2287
+ startsWith(value, message) {
2288
+ return this._addCheck({
2289
+ kind: "startsWith",
2290
+ value,
2291
+ ...errorUtil2.errToObj(message)
2292
+ });
2293
+ }
2294
+ endsWith(value, message) {
2295
+ return this._addCheck({
2296
+ kind: "endsWith",
2297
+ value,
2298
+ ...errorUtil2.errToObj(message)
2299
+ });
2300
+ }
2301
+ min(minLength, message) {
2302
+ return this._addCheck({
2303
+ kind: "min",
2304
+ value: minLength,
2305
+ ...errorUtil2.errToObj(message)
2306
+ });
2307
+ }
2308
+ max(maxLength, message) {
2309
+ return this._addCheck({
2310
+ kind: "max",
2311
+ value: maxLength,
2312
+ ...errorUtil2.errToObj(message)
2313
+ });
2314
+ }
2315
+ length(len, message) {
2316
+ return this._addCheck({
2317
+ kind: "length",
2318
+ value: len,
2319
+ ...errorUtil2.errToObj(message)
2320
+ });
2321
+ }
2322
+ get isDatetime() {
2323
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
2324
+ }
2325
+ get isEmail() {
2326
+ return !!this._def.checks.find((ch) => ch.kind === "email");
2327
+ }
2328
+ get isURL() {
2329
+ return !!this._def.checks.find((ch) => ch.kind === "url");
2330
+ }
2331
+ get isUUID() {
2332
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
2333
+ }
2334
+ get isCUID() {
2335
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
2336
+ }
2337
+ get minLength() {
2338
+ let min = null;
2339
+ for (const ch of this._def.checks) {
2340
+ if (ch.kind === "min") {
2341
+ if (min === null || ch.value > min)
2342
+ min = ch.value;
2343
+ }
2344
+ }
2345
+ return min;
2346
+ }
2347
+ get maxLength() {
2348
+ let max = null;
2349
+ for (const ch of this._def.checks) {
2350
+ if (ch.kind === "max") {
2351
+ if (max === null || ch.value < max)
2352
+ max = ch.value;
2353
+ }
2354
+ }
2355
+ return max;
2356
+ }
2357
+ }, "ZodString");
2358
+ __name222(ZodString2, "ZodString");
2359
+ ZodString2.create = (params) => {
2360
+ var _a;
2361
+ return new ZodString2({
2362
+ checks: [],
2363
+ typeName: ZodFirstPartyTypeKind2.ZodString,
2364
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2365
+ ...processCreateParams2(params)
2366
+ });
2367
+ };
2368
+ function floatSafeRemainder2(val, step) {
2369
+ const valDecCount = (val.toString().split(".")[1] || "").length;
2370
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
2371
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2372
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
2373
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
2374
+ return valInt % stepInt / Math.pow(10, decCount);
2375
+ }
2376
+ __name(floatSafeRemainder2, "floatSafeRemainder");
2377
+ __name2(floatSafeRemainder2, "floatSafeRemainder");
2378
+ __name22(floatSafeRemainder2, "floatSafeRemainder");
2379
+ __name222(floatSafeRemainder2, "floatSafeRemainder");
2380
+ var ZodNumber2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2381
+ constructor() {
2382
+ super(...arguments);
2383
+ this.min = this.gte;
2384
+ this.max = this.lte;
2385
+ this.step = this.multipleOf;
2386
+ }
2387
+ _parse(input) {
2388
+ if (this._def.coerce) {
2389
+ input.data = Number(input.data);
2390
+ }
2391
+ const parsedType = this._getType(input);
2392
+ if (parsedType !== ZodParsedType2.number) {
2393
+ const ctx2 = this._getOrReturnCtx(input);
2394
+ addIssueToContext2(ctx2, {
2395
+ code: ZodIssueCode2.invalid_type,
2396
+ expected: ZodParsedType2.number,
2397
+ received: ctx2.parsedType
2398
+ });
2399
+ return INVALID2;
2400
+ }
2401
+ let ctx = void 0;
2402
+ const status = new ParseStatus2();
2403
+ for (const check of this._def.checks) {
2404
+ if (check.kind === "int") {
2405
+ if (!util2.isInteger(input.data)) {
2406
+ ctx = this._getOrReturnCtx(input, ctx);
2407
+ addIssueToContext2(ctx, {
2408
+ code: ZodIssueCode2.invalid_type,
2409
+ expected: "integer",
2410
+ received: "float",
2411
+ message: check.message
2412
+ });
2413
+ status.dirty();
2414
+ }
2415
+ } else if (check.kind === "min") {
2416
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2417
+ if (tooSmall) {
2418
+ ctx = this._getOrReturnCtx(input, ctx);
2419
+ addIssueToContext2(ctx, {
2420
+ code: ZodIssueCode2.too_small,
2421
+ minimum: check.value,
2422
+ type: "number",
2423
+ inclusive: check.inclusive,
2424
+ exact: false,
2425
+ message: check.message
2426
+ });
2427
+ status.dirty();
2428
+ }
2429
+ } else if (check.kind === "max") {
2430
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2431
+ if (tooBig) {
2432
+ ctx = this._getOrReturnCtx(input, ctx);
2433
+ addIssueToContext2(ctx, {
2434
+ code: ZodIssueCode2.too_big,
2435
+ maximum: check.value,
2436
+ type: "number",
2437
+ inclusive: check.inclusive,
2438
+ exact: false,
2439
+ message: check.message
2440
+ });
2441
+ status.dirty();
2442
+ }
2443
+ } else if (check.kind === "multipleOf") {
2444
+ if (floatSafeRemainder2(input.data, check.value) !== 0) {
2445
+ ctx = this._getOrReturnCtx(input, ctx);
2446
+ addIssueToContext2(ctx, {
2447
+ code: ZodIssueCode2.not_multiple_of,
2448
+ multipleOf: check.value,
2449
+ message: check.message
2450
+ });
2451
+ status.dirty();
2452
+ }
2453
+ } else if (check.kind === "finite") {
2454
+ if (!Number.isFinite(input.data)) {
2455
+ ctx = this._getOrReturnCtx(input, ctx);
2456
+ addIssueToContext2(ctx, {
2457
+ code: ZodIssueCode2.not_finite,
2458
+ message: check.message
2459
+ });
2460
+ status.dirty();
2461
+ }
2462
+ } else {
2463
+ util2.assertNever(check);
2464
+ }
2465
+ }
2466
+ return { status: status.value, value: input.data };
2467
+ }
2468
+ gte(value, message) {
2469
+ return this.setLimit("min", value, true, errorUtil2.toString(message));
2470
+ }
2471
+ gt(value, message) {
2472
+ return this.setLimit("min", value, false, errorUtil2.toString(message));
2473
+ }
2474
+ lte(value, message) {
2475
+ return this.setLimit("max", value, true, errorUtil2.toString(message));
2476
+ }
2477
+ lt(value, message) {
2478
+ return this.setLimit("max", value, false, errorUtil2.toString(message));
2479
+ }
2480
+ setLimit(kind, value, inclusive, message) {
2481
+ return new ZodNumber2({
2482
+ ...this._def,
2483
+ checks: [
2484
+ ...this._def.checks,
2485
+ {
2486
+ kind,
2487
+ value,
2488
+ inclusive,
2489
+ message: errorUtil2.toString(message)
2490
+ }
2491
+ ]
2492
+ });
2493
+ }
2494
+ _addCheck(check) {
2495
+ return new ZodNumber2({
2496
+ ...this._def,
2497
+ checks: [...this._def.checks, check]
2498
+ });
2499
+ }
2500
+ int(message) {
2501
+ return this._addCheck({
2502
+ kind: "int",
2503
+ message: errorUtil2.toString(message)
2504
+ });
2505
+ }
2506
+ positive(message) {
2507
+ return this._addCheck({
2508
+ kind: "min",
2509
+ value: 0,
2510
+ inclusive: false,
2511
+ message: errorUtil2.toString(message)
2512
+ });
2513
+ }
2514
+ negative(message) {
2515
+ return this._addCheck({
2516
+ kind: "max",
2517
+ value: 0,
2518
+ inclusive: false,
2519
+ message: errorUtil2.toString(message)
2520
+ });
2521
+ }
2522
+ nonpositive(message) {
2523
+ return this._addCheck({
2524
+ kind: "max",
2525
+ value: 0,
2526
+ inclusive: true,
2527
+ message: errorUtil2.toString(message)
2528
+ });
2529
+ }
2530
+ nonnegative(message) {
2531
+ return this._addCheck({
2532
+ kind: "min",
2533
+ value: 0,
2534
+ inclusive: true,
2535
+ message: errorUtil2.toString(message)
2536
+ });
2537
+ }
2538
+ multipleOf(value, message) {
2539
+ return this._addCheck({
2540
+ kind: "multipleOf",
2541
+ value,
2542
+ message: errorUtil2.toString(message)
2543
+ });
2544
+ }
2545
+ finite(message) {
2546
+ return this._addCheck({
2547
+ kind: "finite",
2548
+ message: errorUtil2.toString(message)
2549
+ });
2550
+ }
2551
+ get minValue() {
2552
+ let min = null;
2553
+ for (const ch of this._def.checks) {
2554
+ if (ch.kind === "min") {
2555
+ if (min === null || ch.value > min)
2556
+ min = ch.value;
2557
+ }
2558
+ }
2559
+ return min;
2560
+ }
2561
+ get maxValue() {
2562
+ let max = null;
2563
+ for (const ch of this._def.checks) {
2564
+ if (ch.kind === "max") {
2565
+ if (max === null || ch.value < max)
2566
+ max = ch.value;
2567
+ }
2568
+ }
2569
+ return max;
2570
+ }
2571
+ get isInt() {
2572
+ return !!this._def.checks.find((ch) => ch.kind === "int");
2573
+ }
2574
+ }, "ZodNumber");
2575
+ __name222(ZodNumber2, "ZodNumber");
2576
+ ZodNumber2.create = (params) => {
2577
+ return new ZodNumber2({
2578
+ checks: [],
2579
+ typeName: ZodFirstPartyTypeKind2.ZodNumber,
2580
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2581
+ ...processCreateParams2(params)
2582
+ });
2583
+ };
2584
+ var ZodBigInt2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2585
+ _parse(input) {
2586
+ if (this._def.coerce) {
2587
+ input.data = BigInt(input.data);
2588
+ }
2589
+ const parsedType = this._getType(input);
2590
+ if (parsedType !== ZodParsedType2.bigint) {
2591
+ const ctx = this._getOrReturnCtx(input);
2592
+ addIssueToContext2(ctx, {
2593
+ code: ZodIssueCode2.invalid_type,
2594
+ expected: ZodParsedType2.bigint,
2595
+ received: ctx.parsedType
2596
+ });
2597
+ return INVALID2;
2598
+ }
2599
+ return OK2(input.data);
2600
+ }
2601
+ }, "ZodBigInt");
2602
+ __name222(ZodBigInt2, "ZodBigInt");
2603
+ ZodBigInt2.create = (params) => {
2604
+ var _a;
2605
+ return new ZodBigInt2({
2606
+ typeName: ZodFirstPartyTypeKind2.ZodBigInt,
2607
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2608
+ ...processCreateParams2(params)
2609
+ });
2610
+ };
2611
+ var ZodBoolean2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2612
+ _parse(input) {
2613
+ if (this._def.coerce) {
2614
+ input.data = Boolean(input.data);
2615
+ }
2616
+ const parsedType = this._getType(input);
2617
+ if (parsedType !== ZodParsedType2.boolean) {
2618
+ const ctx = this._getOrReturnCtx(input);
2619
+ addIssueToContext2(ctx, {
2620
+ code: ZodIssueCode2.invalid_type,
2621
+ expected: ZodParsedType2.boolean,
2622
+ received: ctx.parsedType
2623
+ });
2624
+ return INVALID2;
2625
+ }
2626
+ return OK2(input.data);
2627
+ }
2628
+ }, "ZodBoolean");
2629
+ __name222(ZodBoolean2, "ZodBoolean");
2630
+ ZodBoolean2.create = (params) => {
2631
+ return new ZodBoolean2({
2632
+ typeName: ZodFirstPartyTypeKind2.ZodBoolean,
2633
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2634
+ ...processCreateParams2(params)
2635
+ });
2636
+ };
2637
+ var ZodDate2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2638
+ _parse(input) {
2639
+ if (this._def.coerce) {
2640
+ input.data = new Date(input.data);
2641
+ }
2642
+ const parsedType = this._getType(input);
2643
+ if (parsedType !== ZodParsedType2.date) {
2644
+ const ctx2 = this._getOrReturnCtx(input);
2645
+ addIssueToContext2(ctx2, {
2646
+ code: ZodIssueCode2.invalid_type,
2647
+ expected: ZodParsedType2.date,
2648
+ received: ctx2.parsedType
2649
+ });
2650
+ return INVALID2;
2651
+ }
2652
+ if (isNaN(input.data.getTime())) {
2653
+ const ctx2 = this._getOrReturnCtx(input);
2654
+ addIssueToContext2(ctx2, {
2655
+ code: ZodIssueCode2.invalid_date
2656
+ });
2657
+ return INVALID2;
2658
+ }
2659
+ const status = new ParseStatus2();
2660
+ let ctx = void 0;
2661
+ for (const check of this._def.checks) {
2662
+ if (check.kind === "min") {
2663
+ if (input.data.getTime() < check.value) {
2664
+ ctx = this._getOrReturnCtx(input, ctx);
2665
+ addIssueToContext2(ctx, {
2666
+ code: ZodIssueCode2.too_small,
2667
+ message: check.message,
2668
+ inclusive: true,
2669
+ exact: false,
2670
+ minimum: check.value,
2671
+ type: "date"
2672
+ });
2673
+ status.dirty();
2674
+ }
2675
+ } else if (check.kind === "max") {
2676
+ if (input.data.getTime() > check.value) {
2677
+ ctx = this._getOrReturnCtx(input, ctx);
2678
+ addIssueToContext2(ctx, {
2679
+ code: ZodIssueCode2.too_big,
2680
+ message: check.message,
2681
+ inclusive: true,
2682
+ exact: false,
2683
+ maximum: check.value,
2684
+ type: "date"
2685
+ });
2686
+ status.dirty();
2687
+ }
2688
+ } else {
2689
+ util2.assertNever(check);
2690
+ }
2691
+ }
2692
+ return {
2693
+ status: status.value,
2694
+ value: new Date(input.data.getTime())
2695
+ };
2696
+ }
2697
+ _addCheck(check) {
2698
+ return new ZodDate2({
2699
+ ...this._def,
2700
+ checks: [...this._def.checks, check]
2701
+ });
2702
+ }
2703
+ min(minDate, message) {
2704
+ return this._addCheck({
2705
+ kind: "min",
2706
+ value: minDate.getTime(),
2707
+ message: errorUtil2.toString(message)
2708
+ });
2709
+ }
2710
+ max(maxDate, message) {
2711
+ return this._addCheck({
2712
+ kind: "max",
2713
+ value: maxDate.getTime(),
2714
+ message: errorUtil2.toString(message)
2715
+ });
2716
+ }
2717
+ get minDate() {
2718
+ let min = null;
2719
+ for (const ch of this._def.checks) {
2720
+ if (ch.kind === "min") {
2721
+ if (min === null || ch.value > min)
2722
+ min = ch.value;
2723
+ }
2724
+ }
2725
+ return min != null ? new Date(min) : null;
2726
+ }
2727
+ get maxDate() {
2728
+ let max = null;
2729
+ for (const ch of this._def.checks) {
2730
+ if (ch.kind === "max") {
2731
+ if (max === null || ch.value < max)
2732
+ max = ch.value;
2733
+ }
2734
+ }
2735
+ return max != null ? new Date(max) : null;
2736
+ }
2737
+ }, "ZodDate");
2738
+ __name222(ZodDate2, "ZodDate");
2739
+ ZodDate2.create = (params) => {
2740
+ return new ZodDate2({
2741
+ checks: [],
2742
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
2743
+ typeName: ZodFirstPartyTypeKind2.ZodDate,
2744
+ ...processCreateParams2(params)
2745
+ });
2746
+ };
2747
+ var ZodSymbol2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2748
+ _parse(input) {
2749
+ const parsedType = this._getType(input);
2750
+ if (parsedType !== ZodParsedType2.symbol) {
2751
+ const ctx = this._getOrReturnCtx(input);
2752
+ addIssueToContext2(ctx, {
2753
+ code: ZodIssueCode2.invalid_type,
2754
+ expected: ZodParsedType2.symbol,
2755
+ received: ctx.parsedType
2756
+ });
2757
+ return INVALID2;
2758
+ }
2759
+ return OK2(input.data);
2760
+ }
2761
+ }, "ZodSymbol");
2762
+ __name222(ZodSymbol2, "ZodSymbol");
2763
+ ZodSymbol2.create = (params) => {
2764
+ return new ZodSymbol2({
2765
+ typeName: ZodFirstPartyTypeKind2.ZodSymbol,
2766
+ ...processCreateParams2(params)
2767
+ });
2768
+ };
2769
+ var ZodUndefined2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2770
+ _parse(input) {
2771
+ const parsedType = this._getType(input);
2772
+ if (parsedType !== ZodParsedType2.undefined) {
2773
+ const ctx = this._getOrReturnCtx(input);
2774
+ addIssueToContext2(ctx, {
2775
+ code: ZodIssueCode2.invalid_type,
2776
+ expected: ZodParsedType2.undefined,
2777
+ received: ctx.parsedType
2778
+ });
2779
+ return INVALID2;
2780
+ }
2781
+ return OK2(input.data);
2782
+ }
2783
+ }, "ZodUndefined");
2784
+ __name222(ZodUndefined2, "ZodUndefined");
2785
+ ZodUndefined2.create = (params) => {
2786
+ return new ZodUndefined2({
2787
+ typeName: ZodFirstPartyTypeKind2.ZodUndefined,
2788
+ ...processCreateParams2(params)
2789
+ });
2790
+ };
2791
+ var ZodNull2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2792
+ _parse(input) {
2793
+ const parsedType = this._getType(input);
2794
+ if (parsedType !== ZodParsedType2.null) {
2795
+ const ctx = this._getOrReturnCtx(input);
2796
+ addIssueToContext2(ctx, {
2797
+ code: ZodIssueCode2.invalid_type,
2798
+ expected: ZodParsedType2.null,
2799
+ received: ctx.parsedType
2800
+ });
2801
+ return INVALID2;
2802
+ }
2803
+ return OK2(input.data);
2804
+ }
2805
+ }, "ZodNull");
2806
+ __name222(ZodNull2, "ZodNull");
2807
+ ZodNull2.create = (params) => {
2808
+ return new ZodNull2({
2809
+ typeName: ZodFirstPartyTypeKind2.ZodNull,
2810
+ ...processCreateParams2(params)
2811
+ });
2812
+ };
2813
+ var ZodAny2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2814
+ constructor() {
2815
+ super(...arguments);
2816
+ this._any = true;
2817
+ }
2818
+ _parse(input) {
2819
+ return OK2(input.data);
2820
+ }
2821
+ }, "ZodAny");
2822
+ __name222(ZodAny2, "ZodAny");
2823
+ ZodAny2.create = (params) => {
2824
+ return new ZodAny2({
2825
+ typeName: ZodFirstPartyTypeKind2.ZodAny,
2826
+ ...processCreateParams2(params)
2827
+ });
2828
+ };
2829
+ var ZodUnknown2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2830
+ constructor() {
2831
+ super(...arguments);
2832
+ this._unknown = true;
2833
+ }
2834
+ _parse(input) {
2835
+ return OK2(input.data);
2836
+ }
2837
+ }, "ZodUnknown");
2838
+ __name222(ZodUnknown2, "ZodUnknown");
2839
+ ZodUnknown2.create = (params) => {
2840
+ return new ZodUnknown2({
2841
+ typeName: ZodFirstPartyTypeKind2.ZodUnknown,
2842
+ ...processCreateParams2(params)
2843
+ });
2844
+ };
2845
+ var ZodNever2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2846
+ _parse(input) {
2847
+ const ctx = this._getOrReturnCtx(input);
2848
+ addIssueToContext2(ctx, {
2849
+ code: ZodIssueCode2.invalid_type,
2850
+ expected: ZodParsedType2.never,
2851
+ received: ctx.parsedType
2852
+ });
2853
+ return INVALID2;
2854
+ }
2855
+ }, "ZodNever");
2856
+ __name222(ZodNever2, "ZodNever");
2857
+ ZodNever2.create = (params) => {
2858
+ return new ZodNever2({
2859
+ typeName: ZodFirstPartyTypeKind2.ZodNever,
2860
+ ...processCreateParams2(params)
2861
+ });
2862
+ };
2863
+ var ZodVoid2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2864
+ _parse(input) {
2865
+ const parsedType = this._getType(input);
2866
+ if (parsedType !== ZodParsedType2.undefined) {
2867
+ const ctx = this._getOrReturnCtx(input);
2868
+ addIssueToContext2(ctx, {
2869
+ code: ZodIssueCode2.invalid_type,
2870
+ expected: ZodParsedType2.void,
2871
+ received: ctx.parsedType
2872
+ });
2873
+ return INVALID2;
2874
+ }
2875
+ return OK2(input.data);
2876
+ }
2877
+ }, "ZodVoid");
2878
+ __name222(ZodVoid2, "ZodVoid");
2879
+ ZodVoid2.create = (params) => {
2880
+ return new ZodVoid2({
2881
+ typeName: ZodFirstPartyTypeKind2.ZodVoid,
2882
+ ...processCreateParams2(params)
2883
+ });
2884
+ };
2885
+ var ZodArray2 = /* @__PURE__ */ __name22(class extends ZodType2 {
2886
+ _parse(input) {
2887
+ const { ctx, status } = this._processInputParams(input);
2888
+ const def = this._def;
2889
+ if (ctx.parsedType !== ZodParsedType2.array) {
2890
+ addIssueToContext2(ctx, {
2891
+ code: ZodIssueCode2.invalid_type,
2892
+ expected: ZodParsedType2.array,
2893
+ received: ctx.parsedType
2894
+ });
2895
+ return INVALID2;
2896
+ }
2897
+ if (def.exactLength !== null) {
2898
+ const tooBig = ctx.data.length > def.exactLength.value;
2899
+ const tooSmall = ctx.data.length < def.exactLength.value;
2900
+ if (tooBig || tooSmall) {
2901
+ addIssueToContext2(ctx, {
2902
+ code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
2903
+ minimum: tooSmall ? def.exactLength.value : void 0,
2904
+ maximum: tooBig ? def.exactLength.value : void 0,
2905
+ type: "array",
2906
+ inclusive: true,
2907
+ exact: true,
2908
+ message: def.exactLength.message
2909
+ });
2910
+ status.dirty();
2911
+ }
2912
+ }
2913
+ if (def.minLength !== null) {
2914
+ if (ctx.data.length < def.minLength.value) {
2915
+ addIssueToContext2(ctx, {
2916
+ code: ZodIssueCode2.too_small,
2917
+ minimum: def.minLength.value,
2918
+ type: "array",
2919
+ inclusive: true,
2920
+ exact: false,
2921
+ message: def.minLength.message
2922
+ });
2923
+ status.dirty();
2924
+ }
2925
+ }
2926
+ if (def.maxLength !== null) {
2927
+ if (ctx.data.length > def.maxLength.value) {
2928
+ addIssueToContext2(ctx, {
2929
+ code: ZodIssueCode2.too_big,
2930
+ maximum: def.maxLength.value,
2931
+ type: "array",
2932
+ inclusive: true,
2933
+ exact: false,
2934
+ message: def.maxLength.message
2935
+ });
2936
+ status.dirty();
2937
+ }
2938
+ }
2939
+ if (ctx.common.async) {
2940
+ return Promise.all(ctx.data.map((item, i) => {
2941
+ return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
2942
+ })).then((result2) => {
2943
+ return ParseStatus2.mergeArray(status, result2);
2944
+ });
2945
+ }
2946
+ const result = ctx.data.map((item, i) => {
2947
+ return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
2948
+ });
2949
+ return ParseStatus2.mergeArray(status, result);
2950
+ }
2951
+ get element() {
2952
+ return this._def.type;
2953
+ }
2954
+ min(minLength, message) {
2955
+ return new ZodArray2({
2956
+ ...this._def,
2957
+ minLength: { value: minLength, message: errorUtil2.toString(message) }
2958
+ });
2959
+ }
2960
+ max(maxLength, message) {
2961
+ return new ZodArray2({
2962
+ ...this._def,
2963
+ maxLength: { value: maxLength, message: errorUtil2.toString(message) }
2964
+ });
2965
+ }
2966
+ length(len, message) {
2967
+ return new ZodArray2({
2968
+ ...this._def,
2969
+ exactLength: { value: len, message: errorUtil2.toString(message) }
2970
+ });
2971
+ }
2972
+ nonempty(message) {
2973
+ return this.min(1, message);
2974
+ }
2975
+ }, "ZodArray");
2976
+ __name222(ZodArray2, "ZodArray");
2977
+ ZodArray2.create = (schema, params) => {
2978
+ return new ZodArray2({
2979
+ type: schema,
2980
+ minLength: null,
2981
+ maxLength: null,
2982
+ exactLength: null,
2983
+ typeName: ZodFirstPartyTypeKind2.ZodArray,
2984
+ ...processCreateParams2(params)
2985
+ });
2986
+ };
2987
+ var objectUtil2;
2988
+ (function(objectUtil22) {
2989
+ objectUtil22.mergeShapes = (first, second) => {
2990
+ return {
2991
+ ...first,
2992
+ ...second
2993
+ };
2994
+ };
2995
+ })(objectUtil2 || (objectUtil2 = {}));
2996
+ var AugmentFactory2 = /* @__PURE__ */ __name222((def) => (augmentation) => {
2997
+ return new ZodObject2({
2998
+ ...def,
2999
+ shape: () => ({
3000
+ ...def.shape(),
3001
+ ...augmentation
3002
+ })
3003
+ });
3004
+ }, "AugmentFactory");
3005
+ function deepPartialify2(schema) {
3006
+ if (schema instanceof ZodObject2) {
3007
+ const newShape = {};
3008
+ for (const key in schema.shape) {
3009
+ const fieldSchema = schema.shape[key];
3010
+ newShape[key] = ZodOptional2.create(deepPartialify2(fieldSchema));
3011
+ }
3012
+ return new ZodObject2({
3013
+ ...schema._def,
3014
+ shape: () => newShape
3015
+ });
3016
+ } else if (schema instanceof ZodArray2) {
3017
+ return ZodArray2.create(deepPartialify2(schema.element));
3018
+ } else if (schema instanceof ZodOptional2) {
3019
+ return ZodOptional2.create(deepPartialify2(schema.unwrap()));
3020
+ } else if (schema instanceof ZodNullable2) {
3021
+ return ZodNullable2.create(deepPartialify2(schema.unwrap()));
3022
+ } else if (schema instanceof ZodTuple2) {
3023
+ return ZodTuple2.create(schema.items.map((item) => deepPartialify2(item)));
3024
+ } else {
3025
+ return schema;
3026
+ }
3027
+ }
3028
+ __name(deepPartialify2, "deepPartialify");
3029
+ __name2(deepPartialify2, "deepPartialify");
3030
+ __name22(deepPartialify2, "deepPartialify");
3031
+ __name222(deepPartialify2, "deepPartialify");
3032
+ var ZodObject2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3033
+ constructor() {
3034
+ super(...arguments);
3035
+ this._cached = null;
3036
+ this.nonstrict = this.passthrough;
3037
+ this.augment = AugmentFactory2(this._def);
3038
+ this.extend = AugmentFactory2(this._def);
3039
+ }
3040
+ _getCached() {
3041
+ if (this._cached !== null)
3042
+ return this._cached;
3043
+ const shape = this._def.shape();
3044
+ const keys = util2.objectKeys(shape);
3045
+ return this._cached = { shape, keys };
3046
+ }
3047
+ _parse(input) {
3048
+ const parsedType = this._getType(input);
3049
+ if (parsedType !== ZodParsedType2.object) {
3050
+ const ctx2 = this._getOrReturnCtx(input);
3051
+ addIssueToContext2(ctx2, {
3052
+ code: ZodIssueCode2.invalid_type,
3053
+ expected: ZodParsedType2.object,
3054
+ received: ctx2.parsedType
3055
+ });
3056
+ return INVALID2;
3057
+ }
3058
+ const { status, ctx } = this._processInputParams(input);
3059
+ const { shape, keys: shapeKeys } = this._getCached();
3060
+ const extraKeys = [];
3061
+ if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
3062
+ for (const key in ctx.data) {
3063
+ if (!shapeKeys.includes(key)) {
3064
+ extraKeys.push(key);
3065
+ }
3066
+ }
3067
+ }
3068
+ const pairs = [];
3069
+ for (const key of shapeKeys) {
3070
+ const keyValidator = shape[key];
3071
+ const value = ctx.data[key];
3072
+ pairs.push({
3073
+ key: { status: "valid", value: key },
3074
+ value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
3075
+ alwaysSet: key in ctx.data
3076
+ });
3077
+ }
3078
+ if (this._def.catchall instanceof ZodNever2) {
3079
+ const unknownKeys = this._def.unknownKeys;
3080
+ if (unknownKeys === "passthrough") {
3081
+ for (const key of extraKeys) {
3082
+ pairs.push({
3083
+ key: { status: "valid", value: key },
3084
+ value: { status: "valid", value: ctx.data[key] }
3085
+ });
3086
+ }
3087
+ } else if (unknownKeys === "strict") {
3088
+ if (extraKeys.length > 0) {
3089
+ addIssueToContext2(ctx, {
3090
+ code: ZodIssueCode2.unrecognized_keys,
3091
+ keys: extraKeys
3092
+ });
3093
+ status.dirty();
3094
+ }
3095
+ } else if (unknownKeys === "strip")
3096
+ ;
3097
+ else {
3098
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
3099
+ }
3100
+ } else {
3101
+ const catchall = this._def.catchall;
3102
+ for (const key of extraKeys) {
3103
+ const value = ctx.data[key];
3104
+ pairs.push({
3105
+ key: { status: "valid", value: key },
3106
+ value: catchall._parse(
3107
+ new ParseInputLazyPath2(ctx, value, ctx.path, key)
3108
+ ),
3109
+ alwaysSet: key in ctx.data
3110
+ });
3111
+ }
3112
+ }
3113
+ if (ctx.common.async) {
3114
+ return Promise.resolve().then(async () => {
3115
+ const syncPairs = [];
3116
+ for (const pair of pairs) {
3117
+ const key = await pair.key;
3118
+ syncPairs.push({
3119
+ key,
3120
+ value: await pair.value,
3121
+ alwaysSet: pair.alwaysSet
3122
+ });
3123
+ }
3124
+ return syncPairs;
3125
+ }).then((syncPairs) => {
3126
+ return ParseStatus2.mergeObjectSync(status, syncPairs);
3127
+ });
3128
+ } else {
3129
+ return ParseStatus2.mergeObjectSync(status, pairs);
3130
+ }
3131
+ }
3132
+ get shape() {
3133
+ return this._def.shape();
3134
+ }
3135
+ strict(message) {
3136
+ errorUtil2.errToObj;
3137
+ return new ZodObject2({
3138
+ ...this._def,
3139
+ unknownKeys: "strict",
3140
+ ...message !== void 0 ? {
3141
+ errorMap: (issue, ctx) => {
3142
+ var _a, _b, _c, _d;
3143
+ 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;
3144
+ if (issue.code === "unrecognized_keys")
3145
+ return {
3146
+ message: (_d = errorUtil2.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
3147
+ };
3148
+ return {
3149
+ message: defaultError
3150
+ };
3151
+ }
3152
+ } : {}
3153
+ });
3154
+ }
3155
+ strip() {
3156
+ return new ZodObject2({
3157
+ ...this._def,
3158
+ unknownKeys: "strip"
3159
+ });
3160
+ }
3161
+ passthrough() {
3162
+ return new ZodObject2({
3163
+ ...this._def,
3164
+ unknownKeys: "passthrough"
3165
+ });
3166
+ }
3167
+ setKey(key, schema) {
3168
+ return this.augment({ [key]: schema });
3169
+ }
3170
+ merge(merging) {
3171
+ const merged = new ZodObject2({
3172
+ unknownKeys: merging._def.unknownKeys,
3173
+ catchall: merging._def.catchall,
3174
+ shape: () => objectUtil2.mergeShapes(this._def.shape(), merging._def.shape()),
3175
+ typeName: ZodFirstPartyTypeKind2.ZodObject
3176
+ });
3177
+ return merged;
3178
+ }
3179
+ catchall(index) {
3180
+ return new ZodObject2({
3181
+ ...this._def,
3182
+ catchall: index
3183
+ });
3184
+ }
3185
+ pick(mask) {
3186
+ const shape = {};
3187
+ util2.objectKeys(mask).map((key) => {
3188
+ if (this.shape[key])
3189
+ shape[key] = this.shape[key];
3190
+ });
3191
+ return new ZodObject2({
3192
+ ...this._def,
3193
+ shape: () => shape
3194
+ });
3195
+ }
3196
+ omit(mask) {
3197
+ const shape = {};
3198
+ util2.objectKeys(this.shape).map((key) => {
3199
+ if (util2.objectKeys(mask).indexOf(key) === -1) {
3200
+ shape[key] = this.shape[key];
3201
+ }
3202
+ });
3203
+ return new ZodObject2({
3204
+ ...this._def,
3205
+ shape: () => shape
3206
+ });
3207
+ }
3208
+ deepPartial() {
3209
+ return deepPartialify2(this);
3210
+ }
3211
+ partial(mask) {
3212
+ const newShape = {};
3213
+ if (mask) {
3214
+ util2.objectKeys(this.shape).map((key) => {
3215
+ if (util2.objectKeys(mask).indexOf(key) === -1) {
3216
+ newShape[key] = this.shape[key];
3217
+ } else {
3218
+ newShape[key] = this.shape[key].optional();
3219
+ }
3220
+ });
3221
+ return new ZodObject2({
3222
+ ...this._def,
3223
+ shape: () => newShape
3224
+ });
3225
+ } else {
3226
+ for (const key in this.shape) {
3227
+ const fieldSchema = this.shape[key];
3228
+ newShape[key] = fieldSchema.optional();
3229
+ }
3230
+ }
3231
+ return new ZodObject2({
3232
+ ...this._def,
3233
+ shape: () => newShape
3234
+ });
3235
+ }
3236
+ required(mask) {
3237
+ const newShape = {};
3238
+ if (mask) {
3239
+ util2.objectKeys(this.shape).map((key) => {
3240
+ if (util2.objectKeys(mask).indexOf(key) === -1) {
3241
+ newShape[key] = this.shape[key];
3242
+ } else {
3243
+ const fieldSchema = this.shape[key];
3244
+ let newField = fieldSchema;
3245
+ while (newField instanceof ZodOptional2) {
3246
+ newField = newField._def.innerType;
3247
+ }
3248
+ newShape[key] = newField;
3249
+ }
3250
+ });
3251
+ } else {
3252
+ for (const key in this.shape) {
3253
+ const fieldSchema = this.shape[key];
3254
+ let newField = fieldSchema;
3255
+ while (newField instanceof ZodOptional2) {
3256
+ newField = newField._def.innerType;
3257
+ }
3258
+ newShape[key] = newField;
3259
+ }
3260
+ }
3261
+ return new ZodObject2({
3262
+ ...this._def,
3263
+ shape: () => newShape
3264
+ });
3265
+ }
3266
+ keyof() {
3267
+ return createZodEnum2(util2.objectKeys(this.shape));
3268
+ }
3269
+ }, "ZodObject");
3270
+ __name222(ZodObject2, "ZodObject");
3271
+ ZodObject2.create = (shape, params) => {
3272
+ return new ZodObject2({
3273
+ shape: () => shape,
3274
+ unknownKeys: "strip",
3275
+ catchall: ZodNever2.create(),
3276
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
3277
+ ...processCreateParams2(params)
3278
+ });
3279
+ };
3280
+ ZodObject2.strictCreate = (shape, params) => {
3281
+ return new ZodObject2({
3282
+ shape: () => shape,
3283
+ unknownKeys: "strict",
3284
+ catchall: ZodNever2.create(),
3285
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
3286
+ ...processCreateParams2(params)
3287
+ });
3288
+ };
3289
+ ZodObject2.lazycreate = (shape, params) => {
3290
+ return new ZodObject2({
3291
+ shape,
3292
+ unknownKeys: "strip",
3293
+ catchall: ZodNever2.create(),
3294
+ typeName: ZodFirstPartyTypeKind2.ZodObject,
3295
+ ...processCreateParams2(params)
3296
+ });
3297
+ };
3298
+ var ZodUnion2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3299
+ _parse(input) {
3300
+ const { ctx } = this._processInputParams(input);
3301
+ const options = this._def.options;
3302
+ function handleResults(results) {
3303
+ for (const result of results) {
3304
+ if (result.result.status === "valid") {
3305
+ return result.result;
3306
+ }
3307
+ }
3308
+ for (const result of results) {
3309
+ if (result.result.status === "dirty") {
3310
+ ctx.common.issues.push(...result.ctx.common.issues);
3311
+ return result.result;
3312
+ }
3313
+ }
3314
+ const unionErrors = results.map((result) => new ZodError2(result.ctx.common.issues));
3315
+ addIssueToContext2(ctx, {
3316
+ code: ZodIssueCode2.invalid_union,
3317
+ unionErrors
3318
+ });
3319
+ return INVALID2;
3320
+ }
3321
+ __name(handleResults, "handleResults");
3322
+ __name2(handleResults, "handleResults");
3323
+ __name22(handleResults, "handleResults");
3324
+ __name222(handleResults, "handleResults");
3325
+ if (ctx.common.async) {
3326
+ return Promise.all(options.map(async (option) => {
3327
+ const childCtx = {
3328
+ ...ctx,
3329
+ common: {
3330
+ ...ctx.common,
3331
+ issues: []
3332
+ },
3333
+ parent: null
3334
+ };
3335
+ return {
3336
+ result: await option._parseAsync({
3337
+ data: ctx.data,
3338
+ path: ctx.path,
3339
+ parent: childCtx
3340
+ }),
3341
+ ctx: childCtx
3342
+ };
3343
+ })).then(handleResults);
3344
+ } else {
3345
+ let dirty = void 0;
3346
+ const issues = [];
3347
+ for (const option of options) {
3348
+ const childCtx = {
3349
+ ...ctx,
3350
+ common: {
3351
+ ...ctx.common,
3352
+ issues: []
3353
+ },
3354
+ parent: null
3355
+ };
3356
+ const result = option._parseSync({
3357
+ data: ctx.data,
3358
+ path: ctx.path,
3359
+ parent: childCtx
3360
+ });
3361
+ if (result.status === "valid") {
3362
+ return result;
3363
+ } else if (result.status === "dirty" && !dirty) {
3364
+ dirty = { result, ctx: childCtx };
3365
+ }
3366
+ if (childCtx.common.issues.length) {
3367
+ issues.push(childCtx.common.issues);
3368
+ }
3369
+ }
3370
+ if (dirty) {
3371
+ ctx.common.issues.push(...dirty.ctx.common.issues);
3372
+ return dirty.result;
3373
+ }
3374
+ const unionErrors = issues.map((issues2) => new ZodError2(issues2));
3375
+ addIssueToContext2(ctx, {
3376
+ code: ZodIssueCode2.invalid_union,
3377
+ unionErrors
3378
+ });
3379
+ return INVALID2;
3380
+ }
3381
+ }
3382
+ get options() {
3383
+ return this._def.options;
3384
+ }
3385
+ }, "ZodUnion");
3386
+ __name222(ZodUnion2, "ZodUnion");
3387
+ ZodUnion2.create = (types, params) => {
3388
+ return new ZodUnion2({
3389
+ options: types,
3390
+ typeName: ZodFirstPartyTypeKind2.ZodUnion,
3391
+ ...processCreateParams2(params)
3392
+ });
3393
+ };
3394
+ var getDiscriminator2 = /* @__PURE__ */ __name222((type) => {
3395
+ if (type instanceof ZodLazy2) {
3396
+ return getDiscriminator2(type.schema);
3397
+ } else if (type instanceof ZodEffects2) {
3398
+ return getDiscriminator2(type.innerType());
3399
+ } else if (type instanceof ZodLiteral2) {
3400
+ return [type.value];
3401
+ } else if (type instanceof ZodEnum2) {
3402
+ return type.options;
3403
+ } else if (type instanceof ZodNativeEnum2) {
3404
+ return Object.keys(type.enum);
3405
+ } else if (type instanceof ZodDefault2) {
3406
+ return getDiscriminator2(type._def.innerType);
3407
+ } else if (type instanceof ZodUndefined2) {
3408
+ return [void 0];
3409
+ } else if (type instanceof ZodNull2) {
3410
+ return [null];
3411
+ } else {
3412
+ return null;
3413
+ }
3414
+ }, "getDiscriminator");
3415
+ var ZodDiscriminatedUnion2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3416
+ _parse(input) {
3417
+ const { ctx } = this._processInputParams(input);
3418
+ if (ctx.parsedType !== ZodParsedType2.object) {
3419
+ addIssueToContext2(ctx, {
3420
+ code: ZodIssueCode2.invalid_type,
3421
+ expected: ZodParsedType2.object,
3422
+ received: ctx.parsedType
3423
+ });
3424
+ return INVALID2;
3425
+ }
3426
+ const discriminator = this.discriminator;
3427
+ const discriminatorValue = ctx.data[discriminator];
3428
+ const option = this.optionsMap.get(discriminatorValue);
3429
+ if (!option) {
3430
+ addIssueToContext2(ctx, {
3431
+ code: ZodIssueCode2.invalid_union_discriminator,
3432
+ options: Array.from(this.optionsMap.keys()),
3433
+ path: [discriminator]
3434
+ });
3435
+ return INVALID2;
3436
+ }
3437
+ if (ctx.common.async) {
3438
+ return option._parseAsync({
3439
+ data: ctx.data,
3440
+ path: ctx.path,
3441
+ parent: ctx
3442
+ });
3443
+ } else {
3444
+ return option._parseSync({
3445
+ data: ctx.data,
3446
+ path: ctx.path,
3447
+ parent: ctx
3448
+ });
3449
+ }
3450
+ }
3451
+ get discriminator() {
3452
+ return this._def.discriminator;
3453
+ }
3454
+ get options() {
3455
+ return this._def.options;
3456
+ }
3457
+ get optionsMap() {
3458
+ return this._def.optionsMap;
3459
+ }
3460
+ static create(discriminator, options, params) {
3461
+ const optionsMap = /* @__PURE__ */ new Map();
3462
+ for (const type of options) {
3463
+ const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
3464
+ if (!discriminatorValues) {
3465
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3466
+ }
3467
+ for (const value of discriminatorValues) {
3468
+ if (optionsMap.has(value)) {
3469
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3470
+ }
3471
+ optionsMap.set(value, type);
3472
+ }
3473
+ }
3474
+ return new ZodDiscriminatedUnion2({
3475
+ typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
3476
+ discriminator,
3477
+ options,
3478
+ optionsMap,
3479
+ ...processCreateParams2(params)
3480
+ });
3481
+ }
3482
+ }, "ZodDiscriminatedUnion");
3483
+ __name222(ZodDiscriminatedUnion2, "ZodDiscriminatedUnion");
3484
+ function mergeValues2(a, b) {
3485
+ const aType = getParsedType2(a);
3486
+ const bType = getParsedType2(b);
3487
+ if (a === b) {
3488
+ return { valid: true, data: a };
3489
+ } else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
3490
+ const bKeys = util2.objectKeys(b);
3491
+ const sharedKeys = util2.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3492
+ const newObj = { ...a, ...b };
3493
+ for (const key of sharedKeys) {
3494
+ const sharedValue = mergeValues2(a[key], b[key]);
3495
+ if (!sharedValue.valid) {
3496
+ return { valid: false };
3497
+ }
3498
+ newObj[key] = sharedValue.data;
3499
+ }
3500
+ return { valid: true, data: newObj };
3501
+ } else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
3502
+ if (a.length !== b.length) {
3503
+ return { valid: false };
3504
+ }
3505
+ const newArray = [];
3506
+ for (let index = 0; index < a.length; index++) {
3507
+ const itemA = a[index];
3508
+ const itemB = b[index];
3509
+ const sharedValue = mergeValues2(itemA, itemB);
3510
+ if (!sharedValue.valid) {
3511
+ return { valid: false };
3512
+ }
3513
+ newArray.push(sharedValue.data);
3514
+ }
3515
+ return { valid: true, data: newArray };
3516
+ } else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
3517
+ return { valid: true, data: a };
3518
+ } else {
3519
+ return { valid: false };
3520
+ }
3521
+ }
3522
+ __name(mergeValues2, "mergeValues");
3523
+ __name2(mergeValues2, "mergeValues");
3524
+ __name22(mergeValues2, "mergeValues");
3525
+ __name222(mergeValues2, "mergeValues");
3526
+ var ZodIntersection2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3527
+ _parse(input) {
3528
+ const { status, ctx } = this._processInputParams(input);
3529
+ const handleParsed = /* @__PURE__ */ __name222((parsedLeft, parsedRight) => {
3530
+ if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
3531
+ return INVALID2;
3532
+ }
3533
+ const merged = mergeValues2(parsedLeft.value, parsedRight.value);
3534
+ if (!merged.valid) {
3535
+ addIssueToContext2(ctx, {
3536
+ code: ZodIssueCode2.invalid_intersection_types
3537
+ });
3538
+ return INVALID2;
3539
+ }
3540
+ if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
3541
+ status.dirty();
3542
+ }
3543
+ return { status: status.value, value: merged.data };
3544
+ }, "handleParsed");
3545
+ if (ctx.common.async) {
3546
+ return Promise.all([
3547
+ this._def.left._parseAsync({
3548
+ data: ctx.data,
3549
+ path: ctx.path,
3550
+ parent: ctx
3551
+ }),
3552
+ this._def.right._parseAsync({
3553
+ data: ctx.data,
3554
+ path: ctx.path,
3555
+ parent: ctx
3556
+ })
3557
+ ]).then(([left, right]) => handleParsed(left, right));
3558
+ } else {
3559
+ return handleParsed(this._def.left._parseSync({
3560
+ data: ctx.data,
3561
+ path: ctx.path,
3562
+ parent: ctx
3563
+ }), this._def.right._parseSync({
3564
+ data: ctx.data,
3565
+ path: ctx.path,
3566
+ parent: ctx
3567
+ }));
3568
+ }
3569
+ }
3570
+ }, "ZodIntersection");
3571
+ __name222(ZodIntersection2, "ZodIntersection");
3572
+ ZodIntersection2.create = (left, right, params) => {
3573
+ return new ZodIntersection2({
3574
+ left,
3575
+ right,
3576
+ typeName: ZodFirstPartyTypeKind2.ZodIntersection,
3577
+ ...processCreateParams2(params)
3578
+ });
3579
+ };
3580
+ var ZodTuple2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3581
+ _parse(input) {
3582
+ const { status, ctx } = this._processInputParams(input);
3583
+ if (ctx.parsedType !== ZodParsedType2.array) {
3584
+ addIssueToContext2(ctx, {
3585
+ code: ZodIssueCode2.invalid_type,
3586
+ expected: ZodParsedType2.array,
3587
+ received: ctx.parsedType
3588
+ });
3589
+ return INVALID2;
3590
+ }
3591
+ if (ctx.data.length < this._def.items.length) {
3592
+ addIssueToContext2(ctx, {
3593
+ code: ZodIssueCode2.too_small,
3594
+ minimum: this._def.items.length,
3595
+ inclusive: true,
3596
+ exact: false,
3597
+ type: "array"
3598
+ });
3599
+ return INVALID2;
3600
+ }
3601
+ const rest = this._def.rest;
3602
+ if (!rest && ctx.data.length > this._def.items.length) {
3603
+ addIssueToContext2(ctx, {
3604
+ code: ZodIssueCode2.too_big,
3605
+ maximum: this._def.items.length,
3606
+ inclusive: true,
3607
+ exact: false,
3608
+ type: "array"
3609
+ });
3610
+ status.dirty();
3611
+ }
3612
+ const items = ctx.data.map((item, itemIndex) => {
3613
+ const schema = this._def.items[itemIndex] || this._def.rest;
3614
+ if (!schema)
3615
+ return null;
3616
+ return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
3617
+ }).filter((x) => !!x);
3618
+ if (ctx.common.async) {
3619
+ return Promise.all(items).then((results) => {
3620
+ return ParseStatus2.mergeArray(status, results);
3621
+ });
3622
+ } else {
3623
+ return ParseStatus2.mergeArray(status, items);
3624
+ }
3625
+ }
3626
+ get items() {
3627
+ return this._def.items;
3628
+ }
3629
+ rest(rest) {
3630
+ return new ZodTuple2({
3631
+ ...this._def,
3632
+ rest
3633
+ });
3634
+ }
3635
+ }, "ZodTuple");
3636
+ __name222(ZodTuple2, "ZodTuple");
3637
+ ZodTuple2.create = (schemas, params) => {
3638
+ if (!Array.isArray(schemas)) {
3639
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3640
+ }
3641
+ return new ZodTuple2({
3642
+ items: schemas,
3643
+ typeName: ZodFirstPartyTypeKind2.ZodTuple,
3644
+ rest: null,
3645
+ ...processCreateParams2(params)
3646
+ });
3647
+ };
3648
+ var ZodRecord2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3649
+ get keySchema() {
3650
+ return this._def.keyType;
3651
+ }
3652
+ get valueSchema() {
3653
+ return this._def.valueType;
3654
+ }
3655
+ _parse(input) {
3656
+ const { status, ctx } = this._processInputParams(input);
3657
+ if (ctx.parsedType !== ZodParsedType2.object) {
3658
+ addIssueToContext2(ctx, {
3659
+ code: ZodIssueCode2.invalid_type,
3660
+ expected: ZodParsedType2.object,
3661
+ received: ctx.parsedType
3662
+ });
3663
+ return INVALID2;
3664
+ }
3665
+ const pairs = [];
3666
+ const keyType = this._def.keyType;
3667
+ const valueType = this._def.valueType;
3668
+ for (const key in ctx.data) {
3669
+ pairs.push({
3670
+ key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
3671
+ value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key))
3672
+ });
3673
+ }
3674
+ if (ctx.common.async) {
3675
+ return ParseStatus2.mergeObjectAsync(status, pairs);
3676
+ } else {
3677
+ return ParseStatus2.mergeObjectSync(status, pairs);
3678
+ }
3679
+ }
3680
+ get element() {
3681
+ return this._def.valueType;
3682
+ }
3683
+ static create(first, second, third) {
3684
+ if (second instanceof ZodType2) {
3685
+ return new ZodRecord2({
3686
+ keyType: first,
3687
+ valueType: second,
3688
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
3689
+ ...processCreateParams2(third)
3690
+ });
3691
+ }
3692
+ return new ZodRecord2({
3693
+ keyType: ZodString2.create(),
3694
+ valueType: first,
3695
+ typeName: ZodFirstPartyTypeKind2.ZodRecord,
3696
+ ...processCreateParams2(second)
3697
+ });
3698
+ }
3699
+ }, "ZodRecord");
3700
+ __name222(ZodRecord2, "ZodRecord");
3701
+ var ZodMap2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3702
+ _parse(input) {
3703
+ const { status, ctx } = this._processInputParams(input);
3704
+ if (ctx.parsedType !== ZodParsedType2.map) {
3705
+ addIssueToContext2(ctx, {
3706
+ code: ZodIssueCode2.invalid_type,
3707
+ expected: ZodParsedType2.map,
3708
+ received: ctx.parsedType
3709
+ });
3710
+ return INVALID2;
3711
+ }
3712
+ const keyType = this._def.keyType;
3713
+ const valueType = this._def.valueType;
3714
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3715
+ return {
3716
+ key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
3717
+ value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
3718
+ };
3719
+ });
3720
+ if (ctx.common.async) {
3721
+ const finalMap = /* @__PURE__ */ new Map();
3722
+ return Promise.resolve().then(async () => {
3723
+ for (const pair of pairs) {
3724
+ const key = await pair.key;
3725
+ const value = await pair.value;
3726
+ if (key.status === "aborted" || value.status === "aborted") {
3727
+ return INVALID2;
3728
+ }
3729
+ if (key.status === "dirty" || value.status === "dirty") {
3730
+ status.dirty();
3731
+ }
3732
+ finalMap.set(key.value, value.value);
3733
+ }
3734
+ return { status: status.value, value: finalMap };
3735
+ });
3736
+ } else {
3737
+ const finalMap = /* @__PURE__ */ new Map();
3738
+ for (const pair of pairs) {
3739
+ const key = pair.key;
3740
+ const value = pair.value;
3741
+ if (key.status === "aborted" || value.status === "aborted") {
3742
+ return INVALID2;
3743
+ }
3744
+ if (key.status === "dirty" || value.status === "dirty") {
3745
+ status.dirty();
3746
+ }
3747
+ finalMap.set(key.value, value.value);
3748
+ }
3749
+ return { status: status.value, value: finalMap };
3750
+ }
3751
+ }
3752
+ }, "ZodMap");
3753
+ __name222(ZodMap2, "ZodMap");
3754
+ ZodMap2.create = (keyType, valueType, params) => {
3755
+ return new ZodMap2({
3756
+ valueType,
3757
+ keyType,
3758
+ typeName: ZodFirstPartyTypeKind2.ZodMap,
3759
+ ...processCreateParams2(params)
3760
+ });
3761
+ };
3762
+ var ZodSet2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3763
+ _parse(input) {
3764
+ const { status, ctx } = this._processInputParams(input);
3765
+ if (ctx.parsedType !== ZodParsedType2.set) {
3766
+ addIssueToContext2(ctx, {
3767
+ code: ZodIssueCode2.invalid_type,
3768
+ expected: ZodParsedType2.set,
3769
+ received: ctx.parsedType
3770
+ });
3771
+ return INVALID2;
3772
+ }
3773
+ const def = this._def;
3774
+ if (def.minSize !== null) {
3775
+ if (ctx.data.size < def.minSize.value) {
3776
+ addIssueToContext2(ctx, {
3777
+ code: ZodIssueCode2.too_small,
3778
+ minimum: def.minSize.value,
3779
+ type: "set",
3780
+ inclusive: true,
3781
+ exact: false,
3782
+ message: def.minSize.message
3783
+ });
3784
+ status.dirty();
3785
+ }
3786
+ }
3787
+ if (def.maxSize !== null) {
3788
+ if (ctx.data.size > def.maxSize.value) {
3789
+ addIssueToContext2(ctx, {
3790
+ code: ZodIssueCode2.too_big,
3791
+ maximum: def.maxSize.value,
3792
+ type: "set",
3793
+ inclusive: true,
3794
+ exact: false,
3795
+ message: def.maxSize.message
3796
+ });
3797
+ status.dirty();
3798
+ }
3799
+ }
3800
+ const valueType = this._def.valueType;
3801
+ function finalizeSet(elements2) {
3802
+ const parsedSet = /* @__PURE__ */ new Set();
3803
+ for (const element of elements2) {
3804
+ if (element.status === "aborted")
3805
+ return INVALID2;
3806
+ if (element.status === "dirty")
3807
+ status.dirty();
3808
+ parsedSet.add(element.value);
3809
+ }
3810
+ return { status: status.value, value: parsedSet };
3811
+ }
3812
+ __name(finalizeSet, "finalizeSet");
3813
+ __name2(finalizeSet, "finalizeSet");
3814
+ __name22(finalizeSet, "finalizeSet");
3815
+ __name222(finalizeSet, "finalizeSet");
3816
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
3817
+ if (ctx.common.async) {
3818
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3819
+ } else {
3820
+ return finalizeSet(elements);
3821
+ }
3822
+ }
3823
+ min(minSize, message) {
3824
+ return new ZodSet2({
3825
+ ...this._def,
3826
+ minSize: { value: minSize, message: errorUtil2.toString(message) }
3827
+ });
3828
+ }
3829
+ max(maxSize, message) {
3830
+ return new ZodSet2({
3831
+ ...this._def,
3832
+ maxSize: { value: maxSize, message: errorUtil2.toString(message) }
3833
+ });
3834
+ }
3835
+ size(size, message) {
3836
+ return this.min(size, message).max(size, message);
3837
+ }
3838
+ nonempty(message) {
3839
+ return this.min(1, message);
3840
+ }
3841
+ }, "ZodSet");
3842
+ __name222(ZodSet2, "ZodSet");
3843
+ ZodSet2.create = (valueType, params) => {
3844
+ return new ZodSet2({
3845
+ valueType,
3846
+ minSize: null,
3847
+ maxSize: null,
3848
+ typeName: ZodFirstPartyTypeKind2.ZodSet,
3849
+ ...processCreateParams2(params)
3850
+ });
3851
+ };
3852
+ var ZodFunction2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3853
+ constructor() {
3854
+ super(...arguments);
3855
+ this.validate = this.implement;
3856
+ }
3857
+ _parse(input) {
3858
+ const { ctx } = this._processInputParams(input);
3859
+ if (ctx.parsedType !== ZodParsedType2.function) {
3860
+ addIssueToContext2(ctx, {
3861
+ code: ZodIssueCode2.invalid_type,
3862
+ expected: ZodParsedType2.function,
3863
+ received: ctx.parsedType
3864
+ });
3865
+ return INVALID2;
3866
+ }
3867
+ function makeArgsIssue(args, error) {
3868
+ return makeIssue2({
3869
+ data: args,
3870
+ path: ctx.path,
3871
+ errorMaps: [
3872
+ ctx.common.contextualErrorMap,
3873
+ ctx.schemaErrorMap,
3874
+ getErrorMap2(),
3875
+ errorMap2
3876
+ ].filter((x) => !!x),
3877
+ issueData: {
3878
+ code: ZodIssueCode2.invalid_arguments,
3879
+ argumentsError: error
3880
+ }
3881
+ });
3882
+ }
3883
+ __name(makeArgsIssue, "makeArgsIssue");
3884
+ __name2(makeArgsIssue, "makeArgsIssue");
3885
+ __name22(makeArgsIssue, "makeArgsIssue");
3886
+ __name222(makeArgsIssue, "makeArgsIssue");
3887
+ function makeReturnsIssue(returns, error) {
3888
+ return makeIssue2({
3889
+ data: returns,
3890
+ path: ctx.path,
3891
+ errorMaps: [
3892
+ ctx.common.contextualErrorMap,
3893
+ ctx.schemaErrorMap,
3894
+ getErrorMap2(),
3895
+ errorMap2
3896
+ ].filter((x) => !!x),
3897
+ issueData: {
3898
+ code: ZodIssueCode2.invalid_return_type,
3899
+ returnTypeError: error
3900
+ }
3901
+ });
3902
+ }
3903
+ __name(makeReturnsIssue, "makeReturnsIssue");
3904
+ __name2(makeReturnsIssue, "makeReturnsIssue");
3905
+ __name22(makeReturnsIssue, "makeReturnsIssue");
3906
+ __name222(makeReturnsIssue, "makeReturnsIssue");
3907
+ const params = { errorMap: ctx.common.contextualErrorMap };
3908
+ const fn = ctx.data;
3909
+ if (this._def.returns instanceof ZodPromise2) {
3910
+ return OK2(async (...args) => {
3911
+ const error = new ZodError2([]);
3912
+ const parsedArgs = await this._def.args.parseAsync(args, params).catch((e) => {
3913
+ error.addIssue(makeArgsIssue(args, e));
3914
+ throw error;
3915
+ });
3916
+ const result = await fn(...parsedArgs);
3917
+ const parsedReturns = await this._def.returns._def.type.parseAsync(result, params).catch((e) => {
3918
+ error.addIssue(makeReturnsIssue(result, e));
3919
+ throw error;
3920
+ });
3921
+ return parsedReturns;
3922
+ });
3923
+ } else {
3924
+ return OK2((...args) => {
3925
+ const parsedArgs = this._def.args.safeParse(args, params);
3926
+ if (!parsedArgs.success) {
3927
+ throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]);
3928
+ }
3929
+ const result = fn(...parsedArgs.data);
3930
+ const parsedReturns = this._def.returns.safeParse(result, params);
3931
+ if (!parsedReturns.success) {
3932
+ throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]);
3933
+ }
3934
+ return parsedReturns.data;
3935
+ });
3936
+ }
3937
+ }
3938
+ parameters() {
3939
+ return this._def.args;
3940
+ }
3941
+ returnType() {
3942
+ return this._def.returns;
3943
+ }
3944
+ args(...items) {
3945
+ return new ZodFunction2({
3946
+ ...this._def,
3947
+ args: ZodTuple2.create(items).rest(ZodUnknown2.create())
3948
+ });
3949
+ }
3950
+ returns(returnType) {
3951
+ return new ZodFunction2({
3952
+ ...this._def,
3953
+ returns: returnType
3954
+ });
3955
+ }
3956
+ implement(func) {
3957
+ const validatedFunc = this.parse(func);
3958
+ return validatedFunc;
3959
+ }
3960
+ strictImplement(func) {
3961
+ const validatedFunc = this.parse(func);
3962
+ return validatedFunc;
3963
+ }
3964
+ static create(args, returns, params) {
3965
+ return new ZodFunction2({
3966
+ args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
3967
+ returns: returns || ZodUnknown2.create(),
3968
+ typeName: ZodFirstPartyTypeKind2.ZodFunction,
3969
+ ...processCreateParams2(params)
3970
+ });
3971
+ }
3972
+ }, "ZodFunction");
3973
+ __name222(ZodFunction2, "ZodFunction");
3974
+ var ZodLazy2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3975
+ get schema() {
3976
+ return this._def.getter();
3977
+ }
3978
+ _parse(input) {
3979
+ const { ctx } = this._processInputParams(input);
3980
+ const lazySchema = this._def.getter();
3981
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3982
+ }
3983
+ }, "ZodLazy");
3984
+ __name222(ZodLazy2, "ZodLazy");
3985
+ ZodLazy2.create = (getter, params) => {
3986
+ return new ZodLazy2({
3987
+ getter,
3988
+ typeName: ZodFirstPartyTypeKind2.ZodLazy,
3989
+ ...processCreateParams2(params)
3990
+ });
3991
+ };
3992
+ var ZodLiteral2 = /* @__PURE__ */ __name22(class extends ZodType2 {
3993
+ _parse(input) {
3994
+ if (input.data !== this._def.value) {
3995
+ const ctx = this._getOrReturnCtx(input);
3996
+ addIssueToContext2(ctx, {
3997
+ code: ZodIssueCode2.invalid_literal,
3998
+ expected: this._def.value
3999
+ });
4000
+ return INVALID2;
4001
+ }
4002
+ return { status: "valid", value: input.data };
4003
+ }
4004
+ get value() {
4005
+ return this._def.value;
4006
+ }
4007
+ }, "ZodLiteral");
4008
+ __name222(ZodLiteral2, "ZodLiteral");
4009
+ ZodLiteral2.create = (value, params) => {
4010
+ return new ZodLiteral2({
4011
+ value,
4012
+ typeName: ZodFirstPartyTypeKind2.ZodLiteral,
4013
+ ...processCreateParams2(params)
4014
+ });
4015
+ };
4016
+ function createZodEnum2(values, params) {
4017
+ return new ZodEnum2({
4018
+ values,
4019
+ typeName: ZodFirstPartyTypeKind2.ZodEnum,
4020
+ ...processCreateParams2(params)
4021
+ });
4022
+ }
4023
+ __name(createZodEnum2, "createZodEnum");
4024
+ __name2(createZodEnum2, "createZodEnum");
4025
+ __name22(createZodEnum2, "createZodEnum");
4026
+ __name222(createZodEnum2, "createZodEnum");
4027
+ var ZodEnum2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4028
+ _parse(input) {
4029
+ if (typeof input.data !== "string") {
4030
+ const ctx = this._getOrReturnCtx(input);
4031
+ const expectedValues = this._def.values;
4032
+ addIssueToContext2(ctx, {
4033
+ expected: util2.joinValues(expectedValues),
4034
+ received: ctx.parsedType,
4035
+ code: ZodIssueCode2.invalid_type
4036
+ });
4037
+ return INVALID2;
4038
+ }
4039
+ if (this._def.values.indexOf(input.data) === -1) {
4040
+ const ctx = this._getOrReturnCtx(input);
4041
+ const expectedValues = this._def.values;
4042
+ addIssueToContext2(ctx, {
4043
+ received: ctx.data,
4044
+ code: ZodIssueCode2.invalid_enum_value,
4045
+ options: expectedValues
4046
+ });
4047
+ return INVALID2;
4048
+ }
4049
+ return OK2(input.data);
4050
+ }
4051
+ get options() {
4052
+ return this._def.values;
4053
+ }
4054
+ get enum() {
4055
+ const enumValues = {};
4056
+ for (const val of this._def.values) {
4057
+ enumValues[val] = val;
4058
+ }
4059
+ return enumValues;
4060
+ }
4061
+ get Values() {
4062
+ const enumValues = {};
4063
+ for (const val of this._def.values) {
4064
+ enumValues[val] = val;
4065
+ }
4066
+ return enumValues;
4067
+ }
4068
+ get Enum() {
4069
+ const enumValues = {};
4070
+ for (const val of this._def.values) {
4071
+ enumValues[val] = val;
4072
+ }
4073
+ return enumValues;
4074
+ }
4075
+ }, "ZodEnum");
4076
+ __name222(ZodEnum2, "ZodEnum");
4077
+ ZodEnum2.create = createZodEnum2;
4078
+ var ZodNativeEnum2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4079
+ _parse(input) {
4080
+ const nativeEnumValues = util2.getValidEnumValues(this._def.values);
4081
+ const ctx = this._getOrReturnCtx(input);
4082
+ if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
4083
+ const expectedValues = util2.objectValues(nativeEnumValues);
4084
+ addIssueToContext2(ctx, {
4085
+ expected: util2.joinValues(expectedValues),
4086
+ received: ctx.parsedType,
4087
+ code: ZodIssueCode2.invalid_type
4088
+ });
4089
+ return INVALID2;
4090
+ }
4091
+ if (nativeEnumValues.indexOf(input.data) === -1) {
4092
+ const expectedValues = util2.objectValues(nativeEnumValues);
4093
+ addIssueToContext2(ctx, {
4094
+ received: ctx.data,
4095
+ code: ZodIssueCode2.invalid_enum_value,
4096
+ options: expectedValues
4097
+ });
4098
+ return INVALID2;
4099
+ }
4100
+ return OK2(input.data);
4101
+ }
4102
+ get enum() {
4103
+ return this._def.values;
4104
+ }
4105
+ }, "ZodNativeEnum");
4106
+ __name222(ZodNativeEnum2, "ZodNativeEnum");
4107
+ ZodNativeEnum2.create = (values, params) => {
4108
+ return new ZodNativeEnum2({
4109
+ values,
4110
+ typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
4111
+ ...processCreateParams2(params)
4112
+ });
4113
+ };
4114
+ var ZodPromise2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4115
+ _parse(input) {
4116
+ const { ctx } = this._processInputParams(input);
4117
+ if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
4118
+ addIssueToContext2(ctx, {
4119
+ code: ZodIssueCode2.invalid_type,
4120
+ expected: ZodParsedType2.promise,
4121
+ received: ctx.parsedType
4122
+ });
4123
+ return INVALID2;
4124
+ }
4125
+ const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
4126
+ return OK2(promisified.then((data) => {
4127
+ return this._def.type.parseAsync(data, {
4128
+ path: ctx.path,
4129
+ errorMap: ctx.common.contextualErrorMap
4130
+ });
4131
+ }));
4132
+ }
4133
+ }, "ZodPromise");
4134
+ __name222(ZodPromise2, "ZodPromise");
4135
+ ZodPromise2.create = (schema, params) => {
4136
+ return new ZodPromise2({
4137
+ type: schema,
4138
+ typeName: ZodFirstPartyTypeKind2.ZodPromise,
4139
+ ...processCreateParams2(params)
4140
+ });
4141
+ };
4142
+ var ZodEffects2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4143
+ innerType() {
4144
+ return this._def.schema;
4145
+ }
4146
+ sourceType() {
4147
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
4148
+ }
4149
+ _parse(input) {
4150
+ const { status, ctx } = this._processInputParams(input);
4151
+ const effect = this._def.effect || null;
4152
+ if (effect.type === "preprocess") {
4153
+ const processed = effect.transform(ctx.data);
4154
+ if (ctx.common.async) {
4155
+ return Promise.resolve(processed).then((processed2) => {
4156
+ return this._def.schema._parseAsync({
4157
+ data: processed2,
4158
+ path: ctx.path,
4159
+ parent: ctx
4160
+ });
4161
+ });
4162
+ } else {
4163
+ return this._def.schema._parseSync({
4164
+ data: processed,
4165
+ path: ctx.path,
4166
+ parent: ctx
4167
+ });
4168
+ }
4169
+ }
4170
+ const checkCtx = {
4171
+ addIssue: (arg) => {
4172
+ addIssueToContext2(ctx, arg);
4173
+ if (arg.fatal) {
4174
+ status.abort();
4175
+ } else {
4176
+ status.dirty();
4177
+ }
4178
+ },
4179
+ get path() {
4180
+ return ctx.path;
4181
+ }
4182
+ };
4183
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4184
+ if (effect.type === "refinement") {
4185
+ const executeRefinement = /* @__PURE__ */ __name222((acc) => {
4186
+ const result = effect.refinement(acc, checkCtx);
4187
+ if (ctx.common.async) {
4188
+ return Promise.resolve(result);
4189
+ }
4190
+ if (result instanceof Promise) {
4191
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
4192
+ }
4193
+ return acc;
4194
+ }, "executeRefinement");
4195
+ if (ctx.common.async === false) {
4196
+ const inner = this._def.schema._parseSync({
4197
+ data: ctx.data,
4198
+ path: ctx.path,
4199
+ parent: ctx
4200
+ });
4201
+ if (inner.status === "aborted")
4202
+ return INVALID2;
4203
+ if (inner.status === "dirty")
4204
+ status.dirty();
4205
+ executeRefinement(inner.value);
4206
+ return { status: status.value, value: inner.value };
4207
+ } else {
4208
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4209
+ if (inner.status === "aborted")
4210
+ return INVALID2;
4211
+ if (inner.status === "dirty")
4212
+ status.dirty();
4213
+ return executeRefinement(inner.value).then(() => {
4214
+ return { status: status.value, value: inner.value };
4215
+ });
4216
+ });
4217
+ }
4218
+ }
4219
+ if (effect.type === "transform") {
4220
+ if (ctx.common.async === false) {
4221
+ const base = this._def.schema._parseSync({
4222
+ data: ctx.data,
4223
+ path: ctx.path,
4224
+ parent: ctx
4225
+ });
4226
+ if (!isValid2(base))
4227
+ return base;
4228
+ const result = effect.transform(base.value, checkCtx);
4229
+ if (result instanceof Promise) {
4230
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4231
+ }
4232
+ return { status: status.value, value: result };
4233
+ } else {
4234
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4235
+ if (!isValid2(base))
4236
+ return base;
4237
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
4238
+ });
4239
+ }
4240
+ }
4241
+ util2.assertNever(effect);
4242
+ }
4243
+ }, "ZodEffects");
4244
+ __name222(ZodEffects2, "ZodEffects");
4245
+ ZodEffects2.create = (schema, effect, params) => {
4246
+ return new ZodEffects2({
4247
+ schema,
4248
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
4249
+ effect,
4250
+ ...processCreateParams2(params)
4251
+ });
4252
+ };
4253
+ ZodEffects2.createWithPreprocess = (preprocess, schema, params) => {
4254
+ return new ZodEffects2({
4255
+ schema,
4256
+ effect: { type: "preprocess", transform: preprocess },
4257
+ typeName: ZodFirstPartyTypeKind2.ZodEffects,
4258
+ ...processCreateParams2(params)
4259
+ });
4260
+ };
4261
+ var ZodOptional2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4262
+ _parse(input) {
4263
+ const parsedType = this._getType(input);
4264
+ if (parsedType === ZodParsedType2.undefined) {
4265
+ return OK2(void 0);
4266
+ }
4267
+ return this._def.innerType._parse(input);
4268
+ }
4269
+ unwrap() {
4270
+ return this._def.innerType;
4271
+ }
4272
+ }, "ZodOptional");
4273
+ __name222(ZodOptional2, "ZodOptional");
4274
+ ZodOptional2.create = (type, params) => {
4275
+ return new ZodOptional2({
4276
+ innerType: type,
4277
+ typeName: ZodFirstPartyTypeKind2.ZodOptional,
4278
+ ...processCreateParams2(params)
4279
+ });
4280
+ };
4281
+ var ZodNullable2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4282
+ _parse(input) {
4283
+ const parsedType = this._getType(input);
4284
+ if (parsedType === ZodParsedType2.null) {
4285
+ return OK2(null);
4286
+ }
4287
+ return this._def.innerType._parse(input);
4288
+ }
4289
+ unwrap() {
4290
+ return this._def.innerType;
4291
+ }
4292
+ }, "ZodNullable");
4293
+ __name222(ZodNullable2, "ZodNullable");
4294
+ ZodNullable2.create = (type, params) => {
4295
+ return new ZodNullable2({
4296
+ innerType: type,
4297
+ typeName: ZodFirstPartyTypeKind2.ZodNullable,
4298
+ ...processCreateParams2(params)
4299
+ });
4300
+ };
4301
+ var ZodDefault2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4302
+ _parse(input) {
4303
+ const { ctx } = this._processInputParams(input);
4304
+ let data = ctx.data;
4305
+ if (ctx.parsedType === ZodParsedType2.undefined) {
4306
+ data = this._def.defaultValue();
4307
+ }
4308
+ return this._def.innerType._parse({
4309
+ data,
4310
+ path: ctx.path,
4311
+ parent: ctx
4312
+ });
4313
+ }
4314
+ removeDefault() {
4315
+ return this._def.innerType;
4316
+ }
4317
+ }, "ZodDefault");
4318
+ __name222(ZodDefault2, "ZodDefault");
4319
+ ZodDefault2.create = (type, params) => {
4320
+ return new ZodDefault2({
4321
+ innerType: type,
4322
+ typeName: ZodFirstPartyTypeKind2.ZodDefault,
4323
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4324
+ ...processCreateParams2(params)
4325
+ });
4326
+ };
4327
+ var ZodCatch2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4328
+ _parse(input) {
4329
+ const { ctx } = this._processInputParams(input);
4330
+ const result = this._def.innerType._parse({
4331
+ data: ctx.data,
4332
+ path: ctx.path,
4333
+ parent: ctx
4334
+ });
4335
+ if (isAsync2(result)) {
4336
+ return result.then((result2) => {
4337
+ return {
4338
+ status: "valid",
4339
+ value: result2.status === "valid" ? result2.value : this._def.defaultValue()
4340
+ };
4341
+ });
4342
+ } else {
4343
+ return {
4344
+ status: "valid",
4345
+ value: result.status === "valid" ? result.value : this._def.defaultValue()
4346
+ };
4347
+ }
4348
+ }
4349
+ removeDefault() {
4350
+ return this._def.innerType;
4351
+ }
4352
+ }, "ZodCatch");
4353
+ __name222(ZodCatch2, "ZodCatch");
4354
+ ZodCatch2.create = (type, params) => {
4355
+ return new ZodCatch2({
4356
+ innerType: type,
4357
+ typeName: ZodFirstPartyTypeKind2.ZodCatch,
4358
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
4359
+ ...processCreateParams2(params)
4360
+ });
4361
+ };
4362
+ var ZodNaN2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4363
+ _parse(input) {
4364
+ const parsedType = this._getType(input);
4365
+ if (parsedType !== ZodParsedType2.nan) {
4366
+ const ctx = this._getOrReturnCtx(input);
4367
+ addIssueToContext2(ctx, {
4368
+ code: ZodIssueCode2.invalid_type,
4369
+ expected: ZodParsedType2.nan,
4370
+ received: ctx.parsedType
4371
+ });
4372
+ return INVALID2;
4373
+ }
4374
+ return { status: "valid", value: input.data };
4375
+ }
4376
+ }, "ZodNaN");
4377
+ __name222(ZodNaN2, "ZodNaN");
4378
+ ZodNaN2.create = (params) => {
4379
+ return new ZodNaN2({
4380
+ typeName: ZodFirstPartyTypeKind2.ZodNaN,
4381
+ ...processCreateParams2(params)
4382
+ });
4383
+ };
4384
+ var BRAND2 = Symbol("zod_brand");
4385
+ var ZodBranded2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4386
+ _parse(input) {
4387
+ const { ctx } = this._processInputParams(input);
4388
+ const data = ctx.data;
4389
+ return this._def.type._parse({
4390
+ data,
4391
+ path: ctx.path,
4392
+ parent: ctx
4393
+ });
4394
+ }
4395
+ unwrap() {
4396
+ return this._def.type;
4397
+ }
4398
+ }, "ZodBranded");
4399
+ __name222(ZodBranded2, "ZodBranded");
4400
+ var ZodPipeline2 = /* @__PURE__ */ __name22(class extends ZodType2 {
4401
+ _parse(input) {
4402
+ const { status, ctx } = this._processInputParams(input);
4403
+ if (ctx.common.async) {
4404
+ const handleAsync = /* @__PURE__ */ __name222(async () => {
4405
+ const inResult = await this._def.in._parseAsync({
4406
+ data: ctx.data,
4407
+ path: ctx.path,
4408
+ parent: ctx
4409
+ });
4410
+ if (inResult.status === "aborted")
4411
+ return INVALID2;
4412
+ if (inResult.status === "dirty") {
4413
+ status.dirty();
4414
+ return DIRTY2(inResult.value);
4415
+ } else {
4416
+ return this._def.out._parseAsync({
4417
+ data: inResult.value,
4418
+ path: ctx.path,
4419
+ parent: ctx
4420
+ });
4421
+ }
4422
+ }, "handleAsync");
4423
+ return handleAsync();
4424
+ } else {
4425
+ const inResult = this._def.in._parseSync({
4426
+ data: ctx.data,
4427
+ path: ctx.path,
4428
+ parent: ctx
4429
+ });
4430
+ if (inResult.status === "aborted")
4431
+ return INVALID2;
4432
+ if (inResult.status === "dirty") {
4433
+ status.dirty();
4434
+ return {
4435
+ status: "dirty",
4436
+ value: inResult.value
4437
+ };
4438
+ } else {
4439
+ return this._def.out._parseSync({
4440
+ data: inResult.value,
4441
+ path: ctx.path,
4442
+ parent: ctx
4443
+ });
4444
+ }
4445
+ }
4446
+ }
4447
+ static create(a, b) {
4448
+ return new ZodPipeline2({
4449
+ in: a,
4450
+ out: b,
4451
+ typeName: ZodFirstPartyTypeKind2.ZodPipeline
4452
+ });
4453
+ }
4454
+ }, "ZodPipeline");
4455
+ __name222(ZodPipeline2, "ZodPipeline");
4456
+ var custom2 = /* @__PURE__ */ __name222((check, params = {}, fatal) => {
4457
+ if (check)
4458
+ return ZodAny2.create().superRefine((data, ctx) => {
4459
+ if (!check(data)) {
4460
+ const p = typeof params === "function" ? params(data) : params;
4461
+ const p2 = typeof p === "string" ? { message: p } : p;
4462
+ ctx.addIssue({ code: "custom", ...p2, fatal });
4463
+ }
4464
+ });
4465
+ return ZodAny2.create();
4466
+ }, "custom");
4467
+ var late2 = {
4468
+ object: ZodObject2.lazycreate
4469
+ };
4470
+ var ZodFirstPartyTypeKind2;
4471
+ (function(ZodFirstPartyTypeKind22) {
4472
+ ZodFirstPartyTypeKind22["ZodString"] = "ZodString";
4473
+ ZodFirstPartyTypeKind22["ZodNumber"] = "ZodNumber";
4474
+ ZodFirstPartyTypeKind22["ZodNaN"] = "ZodNaN";
4475
+ ZodFirstPartyTypeKind22["ZodBigInt"] = "ZodBigInt";
4476
+ ZodFirstPartyTypeKind22["ZodBoolean"] = "ZodBoolean";
4477
+ ZodFirstPartyTypeKind22["ZodDate"] = "ZodDate";
4478
+ ZodFirstPartyTypeKind22["ZodSymbol"] = "ZodSymbol";
4479
+ ZodFirstPartyTypeKind22["ZodUndefined"] = "ZodUndefined";
4480
+ ZodFirstPartyTypeKind22["ZodNull"] = "ZodNull";
4481
+ ZodFirstPartyTypeKind22["ZodAny"] = "ZodAny";
4482
+ ZodFirstPartyTypeKind22["ZodUnknown"] = "ZodUnknown";
4483
+ ZodFirstPartyTypeKind22["ZodNever"] = "ZodNever";
4484
+ ZodFirstPartyTypeKind22["ZodVoid"] = "ZodVoid";
4485
+ ZodFirstPartyTypeKind22["ZodArray"] = "ZodArray";
4486
+ ZodFirstPartyTypeKind22["ZodObject"] = "ZodObject";
4487
+ ZodFirstPartyTypeKind22["ZodUnion"] = "ZodUnion";
4488
+ ZodFirstPartyTypeKind22["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4489
+ ZodFirstPartyTypeKind22["ZodIntersection"] = "ZodIntersection";
4490
+ ZodFirstPartyTypeKind22["ZodTuple"] = "ZodTuple";
4491
+ ZodFirstPartyTypeKind22["ZodRecord"] = "ZodRecord";
4492
+ ZodFirstPartyTypeKind22["ZodMap"] = "ZodMap";
4493
+ ZodFirstPartyTypeKind22["ZodSet"] = "ZodSet";
4494
+ ZodFirstPartyTypeKind22["ZodFunction"] = "ZodFunction";
4495
+ ZodFirstPartyTypeKind22["ZodLazy"] = "ZodLazy";
4496
+ ZodFirstPartyTypeKind22["ZodLiteral"] = "ZodLiteral";
4497
+ ZodFirstPartyTypeKind22["ZodEnum"] = "ZodEnum";
4498
+ ZodFirstPartyTypeKind22["ZodEffects"] = "ZodEffects";
4499
+ ZodFirstPartyTypeKind22["ZodNativeEnum"] = "ZodNativeEnum";
4500
+ ZodFirstPartyTypeKind22["ZodOptional"] = "ZodOptional";
4501
+ ZodFirstPartyTypeKind22["ZodNullable"] = "ZodNullable";
4502
+ ZodFirstPartyTypeKind22["ZodDefault"] = "ZodDefault";
4503
+ ZodFirstPartyTypeKind22["ZodCatch"] = "ZodCatch";
4504
+ ZodFirstPartyTypeKind22["ZodPromise"] = "ZodPromise";
4505
+ ZodFirstPartyTypeKind22["ZodBranded"] = "ZodBranded";
4506
+ ZodFirstPartyTypeKind22["ZodPipeline"] = "ZodPipeline";
4507
+ })(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
4508
+ var instanceOfType2 = /* @__PURE__ */ __name222((cls, params = {
4509
+ message: `Input not instance of ${cls.name}`
4510
+ }) => custom2((data) => data instanceof cls, params, true), "instanceOfType");
4511
+ var stringType2 = ZodString2.create;
4512
+ var numberType2 = ZodNumber2.create;
4513
+ var nanType2 = ZodNaN2.create;
4514
+ var bigIntType2 = ZodBigInt2.create;
4515
+ var booleanType2 = ZodBoolean2.create;
4516
+ var dateType2 = ZodDate2.create;
4517
+ var symbolType2 = ZodSymbol2.create;
4518
+ var undefinedType2 = ZodUndefined2.create;
4519
+ var nullType2 = ZodNull2.create;
4520
+ var anyType2 = ZodAny2.create;
4521
+ var unknownType2 = ZodUnknown2.create;
4522
+ var neverType2 = ZodNever2.create;
4523
+ var voidType2 = ZodVoid2.create;
4524
+ var arrayType2 = ZodArray2.create;
4525
+ var objectType2 = ZodObject2.create;
4526
+ var strictObjectType2 = ZodObject2.strictCreate;
4527
+ var unionType2 = ZodUnion2.create;
4528
+ var discriminatedUnionType2 = ZodDiscriminatedUnion2.create;
4529
+ var intersectionType2 = ZodIntersection2.create;
4530
+ var tupleType2 = ZodTuple2.create;
4531
+ var recordType2 = ZodRecord2.create;
4532
+ var mapType2 = ZodMap2.create;
4533
+ var setType2 = ZodSet2.create;
4534
+ var functionType2 = ZodFunction2.create;
4535
+ var lazyType2 = ZodLazy2.create;
4536
+ var literalType2 = ZodLiteral2.create;
4537
+ var enumType2 = ZodEnum2.create;
4538
+ var nativeEnumType2 = ZodNativeEnum2.create;
4539
+ var promiseType2 = ZodPromise2.create;
4540
+ var effectsType2 = ZodEffects2.create;
4541
+ var optionalType2 = ZodOptional2.create;
4542
+ var nullableType2 = ZodNullable2.create;
4543
+ var preprocessType2 = ZodEffects2.createWithPreprocess;
4544
+ var pipelineType2 = ZodPipeline2.create;
4545
+ var ostring2 = /* @__PURE__ */ __name222(() => stringType2().optional(), "ostring");
4546
+ var onumber2 = /* @__PURE__ */ __name222(() => numberType2().optional(), "onumber");
4547
+ var oboolean2 = /* @__PURE__ */ __name222(() => booleanType2().optional(), "oboolean");
4548
+ var coerce2 = {
4549
+ string: (arg) => ZodString2.create({ ...arg, coerce: true }),
4550
+ number: (arg) => ZodNumber2.create({ ...arg, coerce: true }),
4551
+ boolean: (arg) => ZodBoolean2.create({ ...arg, coerce: true }),
4552
+ bigint: (arg) => ZodBigInt2.create({ ...arg, coerce: true }),
4553
+ date: (arg) => ZodDate2.create({ ...arg, coerce: true })
4554
+ };
4555
+ var NEVER2 = INVALID2;
4556
+ var mod2 = /* @__PURE__ */ Object.freeze({
4557
+ __proto__: null,
4558
+ defaultErrorMap: errorMap2,
4559
+ setErrorMap: setErrorMap2,
4560
+ getErrorMap: getErrorMap2,
4561
+ makeIssue: makeIssue2,
4562
+ EMPTY_PATH: EMPTY_PATH2,
4563
+ addIssueToContext: addIssueToContext2,
4564
+ ParseStatus: ParseStatus2,
4565
+ INVALID: INVALID2,
4566
+ DIRTY: DIRTY2,
4567
+ OK: OK2,
4568
+ isAborted: isAborted2,
4569
+ isDirty: isDirty2,
4570
+ isValid: isValid2,
4571
+ isAsync: isAsync2,
4572
+ get util() {
4573
+ return util2;
4574
+ },
4575
+ ZodParsedType: ZodParsedType2,
4576
+ getParsedType: getParsedType2,
4577
+ ZodType: ZodType2,
4578
+ ZodString: ZodString2,
4579
+ ZodNumber: ZodNumber2,
4580
+ ZodBigInt: ZodBigInt2,
4581
+ ZodBoolean: ZodBoolean2,
4582
+ ZodDate: ZodDate2,
4583
+ ZodSymbol: ZodSymbol2,
4584
+ ZodUndefined: ZodUndefined2,
4585
+ ZodNull: ZodNull2,
4586
+ ZodAny: ZodAny2,
4587
+ ZodUnknown: ZodUnknown2,
4588
+ ZodNever: ZodNever2,
4589
+ ZodVoid: ZodVoid2,
4590
+ ZodArray: ZodArray2,
4591
+ get objectUtil() {
4592
+ return objectUtil2;
4593
+ },
4594
+ ZodObject: ZodObject2,
4595
+ ZodUnion: ZodUnion2,
4596
+ ZodDiscriminatedUnion: ZodDiscriminatedUnion2,
4597
+ ZodIntersection: ZodIntersection2,
4598
+ ZodTuple: ZodTuple2,
4599
+ ZodRecord: ZodRecord2,
4600
+ ZodMap: ZodMap2,
4601
+ ZodSet: ZodSet2,
4602
+ ZodFunction: ZodFunction2,
4603
+ ZodLazy: ZodLazy2,
4604
+ ZodLiteral: ZodLiteral2,
4605
+ ZodEnum: ZodEnum2,
4606
+ ZodNativeEnum: ZodNativeEnum2,
4607
+ ZodPromise: ZodPromise2,
4608
+ ZodEffects: ZodEffects2,
4609
+ ZodTransformer: ZodEffects2,
4610
+ ZodOptional: ZodOptional2,
4611
+ ZodNullable: ZodNullable2,
4612
+ ZodDefault: ZodDefault2,
4613
+ ZodCatch: ZodCatch2,
4614
+ ZodNaN: ZodNaN2,
4615
+ BRAND: BRAND2,
4616
+ ZodBranded: ZodBranded2,
4617
+ ZodPipeline: ZodPipeline2,
4618
+ custom: custom2,
4619
+ Schema: ZodType2,
4620
+ ZodSchema: ZodType2,
4621
+ late: late2,
4622
+ get ZodFirstPartyTypeKind() {
4623
+ return ZodFirstPartyTypeKind2;
4624
+ },
4625
+ coerce: coerce2,
4626
+ any: anyType2,
4627
+ array: arrayType2,
4628
+ bigint: bigIntType2,
4629
+ boolean: booleanType2,
4630
+ date: dateType2,
4631
+ discriminatedUnion: discriminatedUnionType2,
4632
+ effect: effectsType2,
4633
+ "enum": enumType2,
4634
+ "function": functionType2,
4635
+ "instanceof": instanceOfType2,
4636
+ intersection: intersectionType2,
4637
+ lazy: lazyType2,
4638
+ literal: literalType2,
4639
+ map: mapType2,
4640
+ nan: nanType2,
4641
+ nativeEnum: nativeEnumType2,
4642
+ never: neverType2,
4643
+ "null": nullType2,
4644
+ nullable: nullableType2,
4645
+ number: numberType2,
4646
+ object: objectType2,
4647
+ oboolean: oboolean2,
4648
+ onumber: onumber2,
4649
+ optional: optionalType2,
4650
+ ostring: ostring2,
4651
+ pipeline: pipelineType2,
4652
+ preprocess: preprocessType2,
4653
+ promise: promiseType2,
4654
+ record: recordType2,
4655
+ set: setType2,
4656
+ strictObject: strictObjectType2,
4657
+ string: stringType2,
4658
+ symbol: symbolType2,
4659
+ transformer: effectsType2,
4660
+ tuple: tupleType2,
4661
+ "undefined": undefinedType2,
4662
+ union: unionType2,
4663
+ unknown: unknownType2,
4664
+ "void": voidType2,
4665
+ NEVER: NEVER2,
4666
+ ZodIssueCode: ZodIssueCode2,
4667
+ quotelessJson: quotelessJson2,
4668
+ ZodError: ZodError2
4669
+ });
4670
+ var ContextValidator2 = mod2.array(mod2.string().or(mod2.record(mod2.any())));
4671
+ var AchievementCriteriaValidator2 = mod2.object({
4672
+ type: mod2.string().optional(),
4673
+ narrative: mod2.string().optional()
4674
+ });
4675
+ var ImageValidator2 = mod2.string().or(
4676
+ mod2.object({
4677
+ id: mod2.string(),
4678
+ type: mod2.string(),
4679
+ caption: mod2.string().optional()
4680
+ })
4681
+ );
4682
+ var GeoCoordinatesValidator2 = mod2.object({
4683
+ type: mod2.string().min(1).or(mod2.string().array().nonempty()),
4684
+ latitude: mod2.number(),
4685
+ longitude: mod2.number()
4686
+ });
4687
+ var AddressValidator2 = mod2.object({
4688
+ type: mod2.string().min(1).or(mod2.string().array().nonempty()),
4689
+ addressCountry: mod2.string().optional(),
4690
+ addressCountryCode: mod2.string().optional(),
4691
+ addressRegion: mod2.string().optional(),
4692
+ addressLocality: mod2.string().optional(),
4693
+ streetAddress: mod2.string().optional(),
4694
+ postOfficeBoxNumber: mod2.string().optional(),
4695
+ postalCode: mod2.string().optional(),
4696
+ geo: GeoCoordinatesValidator2.optional()
4697
+ });
4698
+ var IdentifierTypeValidator2 = mod2.enum([
4699
+ "sourcedId",
4700
+ "systemId",
4701
+ "productId",
4702
+ "userName",
4703
+ "accountId",
4704
+ "emailAddress",
4705
+ "nationalIdentityNumber",
4706
+ "isbn",
4707
+ "issn",
4708
+ "lisSourcedId",
4709
+ "oneRosterSourcedId",
4710
+ "sisSourcedId",
4711
+ "ltiContextId",
4712
+ "ltiDeploymentId",
4713
+ "ltiToolId",
4714
+ "ltiPlatformId",
4715
+ "ltiUserId",
4716
+ "identifier"
4717
+ ]).or(mod2.string());
4718
+ var IdentifierEntryValidator2 = mod2.object({
4719
+ type: mod2.string().min(1).or(mod2.string().array().nonempty()),
4720
+ identifier: mod2.string(),
4721
+ identifierType: IdentifierTypeValidator2
4722
+ });
4723
+ var ProfileValidator2 = mod2.string().or(
4724
+ mod2.object({
4725
+ id: mod2.string().optional(),
4726
+ type: mod2.string().or(mod2.string().array().nonempty().optional()),
4727
+ name: mod2.string().optional(),
4728
+ url: mod2.string().optional(),
4729
+ phone: mod2.string().optional(),
4730
+ description: mod2.string().optional(),
4731
+ endorsement: mod2.any().array().optional(),
4732
+ image: ImageValidator2.optional(),
4733
+ email: mod2.string().email().optional(),
4734
+ address: AddressValidator2.optional(),
4735
+ otherIdentifier: IdentifierEntryValidator2.array().optional(),
4736
+ official: mod2.string().optional(),
4737
+ parentOrg: mod2.any().optional(),
4738
+ familyName: mod2.string().optional(),
4739
+ givenName: mod2.string().optional(),
4740
+ additionalName: mod2.string().optional(),
4741
+ patronymicName: mod2.string().optional(),
4742
+ honorificPrefix: mod2.string().optional(),
4743
+ honorificSuffix: mod2.string().optional(),
4744
+ familyNamePrefix: mod2.string().optional(),
4745
+ dateOfBirth: mod2.string().optional()
4746
+ }).catchall(mod2.any())
4747
+ );
4748
+ var CredentialSubjectValidator2 = mod2.object({ id: mod2.string().optional() }).catchall(mod2.any());
4749
+ var CredentialStatusValidator2 = mod2.object({ type: mod2.string(), id: mod2.string() }).catchall(mod2.any());
4750
+ var CredentialSchemaValidator2 = mod2.object({ id: mod2.string(), type: mod2.string() }).catchall(mod2.any());
4751
+ var RefreshServiceValidator2 = mod2.object({ id: mod2.string(), type: mod2.string() }).catchall(mod2.any());
4752
+ var UnsignedVCValidator2 = mod2.object({
4753
+ "@context": ContextValidator2,
4754
+ id: mod2.string().optional(),
4755
+ type: mod2.string().array().nonempty(),
4756
+ issuer: ProfileValidator2,
4757
+ issuanceDate: mod2.string(),
4758
+ expirationDate: mod2.string().optional(),
4759
+ credentialSubject: CredentialSubjectValidator2.or(CredentialSubjectValidator2.array()),
4760
+ credentialStatus: CredentialStatusValidator2.optional(),
4761
+ credentialSchema: CredentialSchemaValidator2.array().optional(),
4762
+ refreshService: RefreshServiceValidator2.optional()
4763
+ }).catchall(mod2.any());
4764
+ var ProofValidator2 = mod2.object({
4765
+ type: mod2.string(),
4766
+ created: mod2.string(),
4767
+ challenge: mod2.string().optional(),
4768
+ domain: mod2.string().optional(),
4769
+ nonce: mod2.string().optional(),
4770
+ proofPurpose: mod2.string(),
4771
+ verificationMethod: mod2.string(),
4772
+ jws: mod2.string().optional()
4773
+ }).catchall(mod2.any());
4774
+ var VCValidator2 = UnsignedVCValidator2.extend({
4775
+ proof: ProofValidator2.or(ProofValidator2.array())
4776
+ });
4777
+ var UnsignedVPValidator2 = mod2.object({
4778
+ "@context": ContextValidator2,
4779
+ id: mod2.string().optional(),
4780
+ type: mod2.string().or(mod2.string().array().nonempty()),
4781
+ verifiableCredential: VCValidator2.or(VCValidator2.array()).optional(),
4782
+ holder: mod2.string().optional()
4783
+ }).catchall(mod2.any());
4784
+ var VPValidator2 = UnsignedVPValidator2.extend({
4785
+ proof: ProofValidator2.or(ProofValidator2.array())
4786
+ });
4787
+ var JWKValidator2 = mod2.object({
4788
+ kty: mod2.string(),
4789
+ crv: mod2.string(),
4790
+ x: mod2.string(),
4791
+ y: mod2.string().optional(),
4792
+ n: mod2.string().optional(),
4793
+ d: mod2.string()
4794
+ });
4795
+ var JWERecipientHeaderValidator2 = mod2.object({
4796
+ alg: mod2.string(),
4797
+ iv: mod2.string(),
4798
+ tag: mod2.string(),
4799
+ epk: JWKValidator2.partial().optional(),
4800
+ kid: mod2.string().optional(),
4801
+ apv: mod2.string().optional(),
4802
+ apu: mod2.string().optional()
4803
+ });
4804
+ var JWERecipientValidator2 = mod2.object({
4805
+ header: JWERecipientHeaderValidator2,
4806
+ encrypted_key: mod2.string()
4807
+ });
4808
+ var JWEValidator2 = mod2.object({
4809
+ protected: mod2.string(),
4810
+ iv: mod2.string(),
4811
+ ciphertext: mod2.string(),
4812
+ tag: mod2.string(),
4813
+ aad: mod2.string().optional(),
4814
+ recipients: JWERecipientValidator2.array().optional()
4815
+ });
4816
+ var VerificationMethodValidator2 = mod2.string().or(
4817
+ mod2.object({
4818
+ "@context": ContextValidator2.optional(),
4819
+ id: mod2.string(),
4820
+ type: mod2.string(),
4821
+ controller: mod2.string(),
4822
+ publicKeyJwk: JWKValidator2.optional(),
4823
+ publicKeyBase58: mod2.string().optional(),
4824
+ blockChainAccountId: mod2.string().optional()
4825
+ }).catchall(mod2.any())
4826
+ );
4827
+ var ServiceValidator2 = mod2.object({
4828
+ id: mod2.string(),
4829
+ type: mod2.string().or(mod2.string().array().nonempty()),
4830
+ serviceEndpoint: mod2.any().or(mod2.any().array().nonempty())
4831
+ }).catchall(mod2.any());
4832
+ var DidDocumentValidator2 = mod2.object({
4833
+ "@context": ContextValidator2,
4834
+ id: mod2.string(),
4835
+ alsoKnownAs: mod2.string().optional(),
4836
+ controller: mod2.string().or(mod2.string().array().nonempty()).optional(),
4837
+ verificationMethod: VerificationMethodValidator2.array().optional(),
4838
+ authentication: VerificationMethodValidator2.array().optional(),
4839
+ assertionMethod: VerificationMethodValidator2.array().optional(),
4840
+ keyAgreement: VerificationMethodValidator2.array().optional(),
4841
+ capabilityInvocation: VerificationMethodValidator2.array().optional(),
4842
+ capabilityDelegation: VerificationMethodValidator2.array().optional(),
4843
+ publicKey: VerificationMethodValidator2.array().optional(),
4844
+ service: ServiceValidator2.array().optional(),
4845
+ proof: ProofValidator2.or(ProofValidator2.array()).optional()
4846
+ }).catchall(mod2.any());
4847
+ var AlignmentTargetTypeValidator2 = mod2.enum([
4848
+ "ceasn:Competency",
4849
+ "ceterms:Credential",
4850
+ "CFItem",
4851
+ "CFRubric",
4852
+ "CFRubricCriterion",
4853
+ "CFRubricCriterionLevel",
4854
+ "CTDL"
4855
+ ]).or(mod2.string());
4856
+ var AlignmentValidator2 = mod2.object({
4857
+ type: mod2.string().array().nonempty(),
4858
+ targetCode: mod2.string().optional(),
4859
+ targetDescription: mod2.string().optional(),
4860
+ targetName: mod2.string(),
4861
+ targetFramework: mod2.string().optional(),
4862
+ targetType: AlignmentTargetTypeValidator2.optional(),
4863
+ targetUrl: mod2.string()
4864
+ });
4865
+ var KnownAchievementTypeValidator2 = mod2.enum([
4866
+ "Achievement",
4867
+ "ApprenticeshipCertificate",
4868
+ "Assessment",
4869
+ "Assignment",
4870
+ "AssociateDegree",
4871
+ "Award",
4872
+ "Badge",
4873
+ "BachelorDegree",
4874
+ "Certificate",
4875
+ "CertificateOfCompletion",
4876
+ "Certification",
4877
+ "CommunityService",
4878
+ "Competency",
4879
+ "Course",
4880
+ "CoCurricular",
4881
+ "Degree",
4882
+ "Diploma",
4883
+ "DoctoralDegree",
4884
+ "Fieldwork",
4885
+ "GeneralEducationDevelopment",
4886
+ "JourneymanCertificate",
4887
+ "LearningProgram",
4888
+ "License",
4889
+ "Membership",
4890
+ "ProfessionalDoctorate",
4891
+ "QualityAssuranceCredential",
4892
+ "MasterCertificate",
4893
+ "MasterDegree",
4894
+ "MicroCredential",
4895
+ "ResearchDoctorate",
4896
+ "SecondarySchoolDiploma"
4897
+ ]);
4898
+ var AchievementTypeValidator2 = KnownAchievementTypeValidator2.or(mod2.string());
4899
+ var CriteriaValidator2 = mod2.object({ id: mod2.string().optional(), narrative: mod2.string().optional() }).catchall(mod2.any());
4900
+ var EndorsementSubjectValidator2 = mod2.object({
4901
+ id: mod2.string(),
4902
+ type: mod2.string().array().nonempty(),
4903
+ endorsementComment: mod2.string().optional()
4904
+ });
4905
+ var EndorsementCredentialValidator2 = UnsignedVCValidator2.extend({
4906
+ credentialSubject: EndorsementSubjectValidator2,
4907
+ proof: ProofValidator2.or(ProofValidator2.array()).optional()
4908
+ });
4909
+ var RelatedValidator2 = mod2.object({
4910
+ id: mod2.string(),
4911
+ "@language": mod2.string().optional(),
4912
+ version: mod2.string().optional()
4913
+ });
4914
+ var ResultTypeValidator2 = mod2.enum([
4915
+ "GradePointAverage",
4916
+ "LetterGrade",
4917
+ "Percent",
4918
+ "PerformanceLevel",
4919
+ "PredictedScore",
4920
+ "RawScore",
4921
+ "Result",
4922
+ "RubricCriterion",
4923
+ "RubricCriterionLevel",
4924
+ "RubricScore",
4925
+ "ScaledScore",
4926
+ "Status"
4927
+ ]).or(mod2.string());
4928
+ var RubricCriterionValidator2 = mod2.object({
4929
+ id: mod2.string(),
4930
+ type: mod2.string().array().nonempty(),
4931
+ alignment: AlignmentValidator2.array().optional(),
4932
+ description: mod2.string().optional(),
4933
+ level: mod2.string().optional(),
4934
+ name: mod2.string(),
4935
+ points: mod2.string().optional()
4936
+ }).catchall(mod2.any());
4937
+ var ResultDescriptionValidator2 = mod2.object({
4938
+ id: mod2.string(),
4939
+ type: mod2.string().array().nonempty(),
4940
+ alignment: AlignmentValidator2.array().optional(),
4941
+ allowedValue: mod2.string().array().optional(),
4942
+ name: mod2.string(),
4943
+ requiredLevel: mod2.string().optional(),
4944
+ requiredValue: mod2.string().optional(),
4945
+ resultType: ResultTypeValidator2,
4946
+ rubricCriterionLevel: RubricCriterionValidator2.array().optional(),
4947
+ valueMax: mod2.string().optional(),
4948
+ valueMin: mod2.string().optional()
4949
+ }).catchall(mod2.any());
4950
+ var AchievementValidator2 = mod2.object({
4951
+ id: mod2.string().optional(),
4952
+ type: mod2.string().array().nonempty(),
4953
+ alignment: AlignmentValidator2.array().optional(),
4954
+ achievementType: AchievementTypeValidator2.optional(),
4955
+ creator: ProfileValidator2.optional(),
4956
+ creditsAvailable: mod2.number().optional(),
4957
+ criteria: CriteriaValidator2,
4958
+ description: mod2.string(),
4959
+ endorsement: EndorsementCredentialValidator2.array().optional(),
4960
+ fieldOfStudy: mod2.string().optional(),
4961
+ humanCode: mod2.string().optional(),
4962
+ image: ImageValidator2.optional(),
4963
+ "@language": mod2.string().optional(),
4964
+ name: mod2.string(),
4965
+ otherIdentifier: IdentifierEntryValidator2.array().optional(),
4966
+ related: RelatedValidator2.array().optional(),
4967
+ resultDescription: ResultDescriptionValidator2.array().optional(),
4968
+ specialization: mod2.string().optional(),
4969
+ tag: mod2.string().array().optional(),
4970
+ version: mod2.string().optional()
4971
+ }).catchall(mod2.any());
4972
+ var IdentityObjectValidator2 = mod2.object({
4973
+ type: mod2.string(),
4974
+ hashed: mod2.boolean(),
4975
+ identityHash: mod2.string(),
4976
+ identityType: mod2.string(),
4977
+ salt: mod2.string().optional()
4978
+ });
4979
+ var ResultStatusTypeValidator2 = mod2.enum([
4980
+ "Completed",
4981
+ "Enrolled",
4982
+ "Failed",
4983
+ "InProgress",
4984
+ "OnHold",
4985
+ "Withdrew"
4986
+ ]);
4987
+ var ResultValidator2 = mod2.object({
4988
+ type: mod2.string().array().nonempty(),
4989
+ achievedLevel: mod2.string().optional(),
4990
+ alignment: AlignmentValidator2.array().optional(),
4991
+ resultDescription: mod2.string().optional(),
4992
+ status: ResultStatusTypeValidator2.optional(),
4993
+ value: mod2.string().optional()
4994
+ }).catchall(mod2.any());
4995
+ var AchievementSubjectValidator2 = mod2.object({
4996
+ id: mod2.string().optional(),
4997
+ type: mod2.string().array().nonempty(),
4998
+ activityEndDate: mod2.string().optional(),
4999
+ activityStartDate: mod2.string().optional(),
5000
+ creditsEarned: mod2.number().optional(),
5001
+ achievement: AchievementValidator2.optional(),
5002
+ identifier: IdentityObjectValidator2.array().optional(),
5003
+ image: ImageValidator2.optional(),
5004
+ licenseNumber: mod2.string().optional(),
5005
+ narrative: mod2.string().optional(),
5006
+ result: ResultValidator2.array().optional(),
5007
+ role: mod2.string().optional(),
5008
+ source: ProfileValidator2.optional(),
5009
+ term: mod2.string().optional()
5010
+ }).catchall(mod2.any());
5011
+ var EvidenceValidator2 = mod2.object({
5012
+ id: mod2.string().optional(),
5013
+ type: mod2.string().array().nonempty(),
5014
+ narrative: mod2.string().optional(),
5015
+ name: mod2.string().optional(),
5016
+ description: mod2.string().optional(),
5017
+ genre: mod2.string().optional(),
5018
+ audience: mod2.string().optional()
5019
+ }).catchall(mod2.any());
5020
+ var UnsignedAchievementCredentialValidator2 = UnsignedVCValidator2.extend({
5021
+ name: mod2.string().optional(),
5022
+ description: mod2.string().optional(),
5023
+ image: ImageValidator2.optional(),
5024
+ credentialSubject: AchievementSubjectValidator2.or(
5025
+ AchievementSubjectValidator2.array()
5026
+ ),
5027
+ endorsement: UnsignedVCValidator2.array().optional(),
5028
+ evidence: EvidenceValidator2.array().optional()
5029
+ });
5030
+ var AchievementCredentialValidator2 = UnsignedAchievementCredentialValidator2.extend({
5031
+ proof: ProofValidator2.or(ProofValidator2.array())
5032
+ });
5033
+ var VerificationCheckValidator2 = mod2.object({
5034
+ checks: mod2.string().array(),
5035
+ warnings: mod2.string().array(),
5036
+ errors: mod2.string().array()
5037
+ });
5038
+ var VerificationStatusValidator2 = mod2.enum(["Success", "Failed", "Error"]);
5039
+ var VerificationStatusEnum2 = VerificationStatusValidator2.enum;
5040
+ var VerificationItemValidator2 = mod2.object({
5041
+ check: mod2.string(),
5042
+ status: VerificationStatusValidator2,
5043
+ message: mod2.string().optional(),
5044
+ details: mod2.string().optional()
5045
+ });
5046
+ var CredentialInfoValidator2 = mod2.object({
5047
+ title: mod2.string().optional(),
5048
+ createdAt: mod2.string().optional(),
5049
+ issuer: ProfileValidator2.optional(),
5050
+ issuee: ProfileValidator2.optional(),
5051
+ credentialSubject: CredentialSubjectValidator2.optional()
5052
+ });
5053
+ var CredentialRecordValidator2 = mod2.object({ id: mod2.string(), uri: mod2.string() }).catchall(mod2.any());
5054
+ var PaginationOptionsValidator2 = mod2.object({
5055
+ limit: mod2.number(),
5056
+ cursor: mod2.string().optional(),
5057
+ sort: mod2.string().optional()
5058
+ });
5059
+ var PaginationResponseValidator2 = mod2.object({
5060
+ cursor: mod2.string().optional(),
5061
+ hasMore: mod2.boolean()
5062
+ });
5063
+ var EncryptedRecordValidator2 = mod2.object({ encryptedRecord: JWEValidator2, fields: mod2.string().array() }).catchall(mod2.any());
5064
+ var PaginatedEncryptedRecordsValidator2 = PaginationResponseValidator2.extend({
5065
+ records: EncryptedRecordValidator2.array()
5066
+ });
5067
+ var EncryptedCredentialRecordValidator2 = EncryptedRecordValidator2.extend({
5068
+ id: mod2.string()
5069
+ });
5070
+ var PaginatedEncryptedCredentialRecordsValidator2 = PaginationResponseValidator2.extend({
5071
+ records: EncryptedCredentialRecordValidator2.array()
5072
+ });
5073
+ var parseRegexString2 = /* @__PURE__ */ __name222((regexStr) => {
5074
+ const match = regexStr.match(/^\/(.*)\/([gimsuy]*)$/);
5075
+ if (!match)
5076
+ throw new Error("Invalid RegExp string format");
5077
+ return { pattern: match[1], flags: match[2] };
5078
+ }, "parseRegexString");
5079
+ var RegExpValidator2 = mod2.instanceof(RegExp).or(
5080
+ mod2.string().refine(
5081
+ (str) => {
5082
+ try {
5083
+ parseRegexString2(str);
5084
+ return true;
5085
+ } catch (e) {
5086
+ return false;
5087
+ }
5088
+ },
5089
+ {
5090
+ message: "Invalid RegExp string format. Must be in format '/pattern/flags'"
5091
+ }
5092
+ ).transform((str) => {
5093
+ const { pattern, flags } = parseRegexString2(str);
5094
+ try {
5095
+ return new RegExp(pattern, flags);
5096
+ } catch (error) {
5097
+ throw new Error(`Invalid RegExp: ${error.message}`);
5098
+ }
5099
+ })
5100
+ );
5101
+ var StringQuery2 = mod2.string().or(mod2.object({ $in: mod2.string().array() })).or(mod2.object({ $regex: RegExpValidator2 }));
5102
+ var LCNProfileValidator2 = mod2.object({
5103
+ profileId: mod2.string().min(3).max(40),
5104
+ displayName: mod2.string().default(""),
5105
+ shortBio: mod2.string().default(""),
5106
+ bio: mod2.string().default(""),
5107
+ did: mod2.string(),
5108
+ email: mod2.string().optional(),
5109
+ image: mod2.string().optional(),
5110
+ heroImage: mod2.string().optional(),
5111
+ websiteLink: mod2.string().optional(),
5112
+ isServiceProfile: mod2.boolean().default(false).optional(),
5113
+ type: mod2.string().optional(),
5114
+ notificationsWebhook: mod2.string().url().startsWith("http").optional()
5115
+ });
5116
+ var LCNProfileQueryValidator2 = mod2.object({
5117
+ profileId: StringQuery2,
5118
+ displayName: StringQuery2,
5119
+ shortBio: StringQuery2,
5120
+ bio: StringQuery2,
5121
+ email: StringQuery2,
5122
+ websiteLink: StringQuery2,
5123
+ isServiceProfile: mod2.boolean(),
5124
+ type: StringQuery2
5125
+ }).partial();
5126
+ var PaginatedLCNProfilesValidator2 = PaginationResponseValidator2.extend({
5127
+ records: LCNProfileValidator2.array()
5128
+ });
5129
+ var LCNProfileConnectionStatusEnum2 = mod2.enum([
5130
+ "CONNECTED",
5131
+ "PENDING_REQUEST_SENT",
5132
+ "PENDING_REQUEST_RECEIVED",
5133
+ "NOT_CONNECTED"
5134
+ ]);
5135
+ var SentCredentialInfoValidator2 = mod2.object({
5136
+ uri: mod2.string(),
5137
+ to: mod2.string(),
5138
+ from: mod2.string(),
5139
+ sent: mod2.string().datetime(),
5140
+ received: mod2.string().datetime().optional()
5141
+ });
5142
+ var BoostPermissionsValidator2 = mod2.object({
5143
+ role: mod2.string(),
5144
+ canEdit: mod2.boolean(),
5145
+ canIssue: mod2.boolean(),
5146
+ canRevoke: mod2.boolean(),
5147
+ canManagePermissions: mod2.boolean(),
5148
+ canIssueChildren: mod2.string(),
5149
+ canCreateChildren: mod2.string(),
5150
+ canEditChildren: mod2.string(),
5151
+ canRevokeChildren: mod2.string(),
5152
+ canManageChildrenPermissions: mod2.string(),
5153
+ canViewAnalytics: mod2.boolean()
5154
+ });
5155
+ var LCNBoostStatus2 = mod2.enum(["DRAFT", "LIVE"]);
5156
+ var BoostValidator2 = mod2.object({
5157
+ uri: mod2.string(),
5158
+ name: mod2.string().optional(),
5159
+ type: mod2.string().optional(),
5160
+ category: mod2.string().optional(),
5161
+ status: LCNBoostStatus2.optional(),
5162
+ autoConnectRecipients: mod2.boolean().optional(),
5163
+ meta: mod2.record(mod2.any()).optional(),
5164
+ claimPermissions: BoostPermissionsValidator2.optional()
5165
+ });
5166
+ var BoostQueryValidator2 = mod2.object({
5167
+ uri: StringQuery2,
5168
+ name: StringQuery2,
5169
+ type: StringQuery2,
5170
+ category: StringQuery2,
5171
+ meta: mod2.record(StringQuery2),
5172
+ status: LCNBoostStatus2.or(mod2.object({ $in: LCNBoostStatus2.array() })),
5173
+ autoConnectRecipients: mod2.boolean()
5174
+ }).partial();
5175
+ var PaginatedBoostsValidator2 = PaginationResponseValidator2.extend({
5176
+ records: BoostValidator2.array()
5177
+ });
5178
+ var BoostRecipientValidator2 = mod2.object({
5179
+ to: LCNProfileValidator2,
5180
+ from: mod2.string(),
5181
+ received: mod2.string().optional(),
5182
+ uri: mod2.string().optional()
5183
+ });
5184
+ var PaginatedBoostRecipientsValidator2 = PaginationResponseValidator2.extend({
5185
+ records: BoostRecipientValidator2.array()
5186
+ });
5187
+ var LCNBoostClaimLinkSigningAuthorityValidator2 = mod2.object({
5188
+ endpoint: mod2.string(),
5189
+ name: mod2.string(),
5190
+ did: mod2.string().optional()
5191
+ });
5192
+ var LCNBoostClaimLinkOptionsValidator2 = mod2.object({
5193
+ ttlSeconds: mod2.number().optional(),
5194
+ totalUses: mod2.number().optional()
5195
+ });
5196
+ var LCNSigningAuthorityValidator2 = mod2.object({
5197
+ endpoint: mod2.string()
5198
+ });
5199
+ var LCNSigningAuthorityForUserValidator2 = mod2.object({
5200
+ signingAuthority: LCNSigningAuthorityValidator2,
5201
+ relationship: mod2.object({
5202
+ name: mod2.string().max(15).regex(/^[a-z0-9-]+$/, {
5203
+ message: "The input string must contain only lowercase letters, numbers, and hyphens."
5204
+ }),
5205
+ did: mod2.string()
5206
+ })
5207
+ });
5208
+ var ConsentFlowTermsStatusValidator2 = mod2.enum(["live", "stale", "withdrawn"]);
5209
+ var ConsentFlowContractValidator2 = mod2.object({
5210
+ read: mod2.object({
5211
+ anonymize: mod2.boolean().optional(),
5212
+ credentials: mod2.object({ categories: mod2.record(mod2.object({ required: mod2.boolean() })).default({}) }).default({}),
5213
+ personal: mod2.record(mod2.object({ required: mod2.boolean() })).default({})
5214
+ }).default({}),
5215
+ write: mod2.object({
5216
+ credentials: mod2.object({ categories: mod2.record(mod2.object({ required: mod2.boolean() })).default({}) }).default({}),
5217
+ personal: mod2.record(mod2.object({ required: mod2.boolean() })).default({})
5218
+ }).default({})
5219
+ });
5220
+ var ConsentFlowContractDetailsValidator2 = mod2.object({
5221
+ contract: ConsentFlowContractValidator2,
5222
+ owner: LCNProfileValidator2,
5223
+ name: mod2.string(),
5224
+ subtitle: mod2.string().optional(),
5225
+ description: mod2.string().optional(),
5226
+ reasonForAccessing: mod2.string().optional(),
5227
+ image: mod2.string().optional(),
5228
+ uri: mod2.string(),
5229
+ createdAt: mod2.string(),
5230
+ updatedAt: mod2.string(),
5231
+ expiresAt: mod2.string().optional()
5232
+ });
5233
+ var PaginatedConsentFlowContractsValidator2 = PaginationResponseValidator2.extend({
5234
+ records: ConsentFlowContractDetailsValidator2.omit({ owner: true }).array()
5235
+ });
5236
+ var ConsentFlowContractDataValidator2 = mod2.object({
5237
+ credentials: mod2.object({ categories: mod2.record(mod2.string().array()).default({}) }),
5238
+ personal: mod2.record(mod2.string()).default({}),
5239
+ date: mod2.string()
5240
+ });
5241
+ var PaginatedConsentFlowDataValidator2 = PaginationResponseValidator2.extend({
5242
+ records: ConsentFlowContractDataValidator2.array()
5243
+ });
5244
+ var ConsentFlowTermValidator2 = mod2.object({
5245
+ sharing: mod2.boolean().optional(),
5246
+ shared: mod2.string().array().optional(),
5247
+ shareAll: mod2.boolean().optional(),
5248
+ shareUntil: mod2.string().optional()
5249
+ });
5250
+ var ConsentFlowTermsValidator2 = mod2.object({
5251
+ read: mod2.object({
5252
+ anonymize: mod2.boolean().optional(),
5253
+ credentials: mod2.object({
5254
+ shareAll: mod2.boolean().optional(),
5255
+ sharing: mod2.boolean().optional(),
5256
+ categories: mod2.record(ConsentFlowTermValidator2).default({})
5257
+ }).default({}),
5258
+ personal: mod2.record(mod2.string()).default({})
5259
+ }).default({}),
5260
+ write: mod2.object({
5261
+ credentials: mod2.object({ categories: mod2.record(mod2.boolean()).default({}) }).default({}),
5262
+ personal: mod2.record(mod2.boolean()).default({})
5263
+ }).default({})
5264
+ });
5265
+ var PaginatedConsentFlowTermsValidator2 = PaginationResponseValidator2.extend({
5266
+ records: mod2.object({
5267
+ expiresAt: mod2.string().optional(),
5268
+ oneTime: mod2.boolean().optional(),
5269
+ terms: ConsentFlowTermsValidator2,
5270
+ contract: ConsentFlowContractDetailsValidator2,
5271
+ uri: mod2.string(),
5272
+ consenter: LCNProfileValidator2,
5273
+ status: ConsentFlowTermsStatusValidator2
5274
+ }).array()
5275
+ });
5276
+ var ConsentFlowContractQueryValidator2 = mod2.object({
5277
+ read: mod2.object({
5278
+ anonymize: mod2.boolean().optional(),
5279
+ credentials: mod2.object({
5280
+ categories: mod2.record(mod2.object({ required: mod2.boolean().optional() })).optional()
5281
+ }).optional(),
5282
+ personal: mod2.record(mod2.object({ required: mod2.boolean().optional() })).optional()
5283
+ }).optional(),
5284
+ write: mod2.object({
5285
+ credentials: mod2.object({
5286
+ categories: mod2.record(mod2.object({ required: mod2.boolean().optional() })).optional()
5287
+ }).optional(),
5288
+ personal: mod2.record(mod2.object({ required: mod2.boolean().optional() })).optional()
5289
+ }).optional()
5290
+ });
5291
+ var ConsentFlowDataQueryValidator2 = mod2.object({
5292
+ anonymize: mod2.boolean().optional(),
5293
+ credentials: mod2.object({ categories: mod2.record(mod2.boolean()).optional() }).optional(),
5294
+ personal: mod2.record(mod2.boolean()).optional()
5295
+ });
5296
+ var ConsentFlowTermsQueryValidator2 = mod2.object({
5297
+ read: mod2.object({
5298
+ anonymize: mod2.boolean().optional(),
5299
+ credentials: mod2.object({
5300
+ shareAll: mod2.boolean().optional(),
5301
+ sharing: mod2.boolean().optional(),
5302
+ categories: mod2.record(ConsentFlowTermValidator2.optional()).optional()
5303
+ }).optional(),
5304
+ personal: mod2.record(mod2.string()).optional()
5305
+ }).optional(),
5306
+ write: mod2.object({
5307
+ credentials: mod2.object({ categories: mod2.record(mod2.boolean()).optional() }).optional(),
5308
+ personal: mod2.record(mod2.boolean()).optional()
5309
+ }).optional()
5310
+ });
5311
+ var ConsentFlowTransactionActionValidator2 = mod2.enum([
5312
+ "consent",
5313
+ "update",
5314
+ "sync",
5315
+ "withdraw"
5316
+ ]);
5317
+ var ConsentFlowTransactionsQueryValidator2 = mod2.object({
5318
+ terms: ConsentFlowTermsQueryValidator2.optional(),
5319
+ action: ConsentFlowTransactionActionValidator2.or(
5320
+ ConsentFlowTransactionActionValidator2.array()
5321
+ ).optional(),
5322
+ date: mod2.object({ $gt: mod2.string() }).or(mod2.object({ $lt: mod2.string() })).or(mod2.object({ $eq: mod2.string() })).optional(),
5323
+ expiresAt: mod2.object({ $gt: mod2.string() }).or(mod2.object({ $lt: mod2.string() })).or(mod2.object({ $eq: mod2.string() })).optional(),
5324
+ oneTime: mod2.boolean().optional()
5325
+ });
5326
+ var ConsentFlowTransactionValidator2 = mod2.object({
5327
+ expiresAt: mod2.string().optional(),
5328
+ oneTime: mod2.boolean().optional(),
5329
+ terms: ConsentFlowTermsValidator2.optional(),
5330
+ id: mod2.string(),
5331
+ action: ConsentFlowTransactionActionValidator2,
5332
+ date: mod2.string()
5333
+ });
5334
+ var PaginatedConsentFlowTransactionsValidator2 = PaginationResponseValidator2.extend({
5335
+ records: ConsentFlowTransactionValidator2.array()
5336
+ });
5337
+ var LCNNotificationTypeEnumValidator2 = mod2.enum([
5338
+ "CONNECTION_REQUEST",
5339
+ "CONNECTION_ACCEPTED",
5340
+ "CREDENTIAL_RECEIVED",
5341
+ "CREDENTIAL_ACCEPTED",
5342
+ "BOOST_RECEIVED",
5343
+ "BOOST_ACCEPTED",
5344
+ "PRESENTATION_REQUEST",
5345
+ "PRESENTATION_RECEIVED",
5346
+ "CONSENT_FLOW_TRANSACTION"
5347
+ ]);
5348
+ var LCNNotificationMessageValidator2 = mod2.object({
5349
+ title: mod2.string().optional(),
5350
+ body: mod2.string().optional()
5351
+ });
5352
+ var LCNNotificationDataValidator2 = mod2.object({
5353
+ vcUris: mod2.array(mod2.string()).optional(),
5354
+ vpUris: mod2.array(mod2.string()).optional(),
5355
+ transaction: ConsentFlowTransactionValidator2.optional()
5356
+ });
5357
+ var LCNNotificationValidator2 = mod2.object({
5358
+ type: LCNNotificationTypeEnumValidator2,
5359
+ to: LCNProfileValidator2.partial().and(mod2.object({ did: mod2.string() })),
5360
+ from: LCNProfileValidator2.partial().and(mod2.object({ did: mod2.string() })),
5361
+ message: LCNNotificationMessageValidator2.optional(),
5362
+ data: LCNNotificationDataValidator2.optional(),
5363
+ sent: mod2.string().datetime().optional()
5364
+ });
5365
+ }
5366
+ });
5367
+ var require_dist2 = __commonJS2({
5368
+ "../learn-card-types/dist/index.js"(exports2, module2) {
5369
+ "use strict";
5370
+ if (false) {
5371
+ module2.exports = null;
5372
+ } else {
5373
+ module2.exports = require_types_cjs_development();
5374
+ }
5375
+ }
5376
+ });
5377
+ var src_exports = {};
5378
+ __export(src_exports, {
5379
+ RegExpTransformer: () => RegExpTransformer2,
5380
+ isEncrypted: () => isEncrypted,
5381
+ isHex: () => isHex
5382
+ });
5383
+ module.exports = __toCommonJS(src_exports);
5384
+ var import_types2 = __toESM2(require_dist2());
5385
+ var isHex = /* @__PURE__ */ __name22((str) => /^[0-9a-f]+$/i.test(str), "isHex");
5386
+ var isEncrypted = /* @__PURE__ */ __name22((item) => {
5387
+ return import_types2.JWEValidator.safeParse(item).success;
5388
+ }, "isEncrypted");
5389
+ var RegExpTransformer2 = {
5390
+ serialize(object) {
5391
+ return JSON.stringify(object, (_key, value) => {
5392
+ if (value instanceof RegExp)
5393
+ return value.toString();
5394
+ return value;
5395
+ });
5396
+ },
5397
+ deserialize(object) {
5398
+ if (typeof object !== "string")
5399
+ return object;
5400
+ return JSON.parse(object, (_key, value) => {
5401
+ if (typeof value === "string") {
5402
+ const match = value.match(/^\/(.*)\/([gimsuy]*)$/);
5403
+ if (match) {
5404
+ try {
5405
+ return new RegExp(match[1], match[2]);
5406
+ } catch (error) {
5407
+ console.warn(`Failed to parse RegExp: ${error}`);
5408
+ return value;
5409
+ }
5410
+ }
5411
+ }
5412
+ return value;
5413
+ });
5414
+ }
5415
+ };
5416
+ }
5417
+ });
5418
+ var require_dist = __commonJS({
5419
+ "../../learn-card-helpers/dist/index.js"(exports, module) {
5420
+ "use strict";
5421
+ if (false) {
5422
+ module.exports = null;
5423
+ } else {
5424
+ module.exports = require_helpers_cjs_development();
5425
+ }
5426
+ }
5427
+ });
5428
+ var import_helpers = __toESM(require_dist());
1140
5429
  var callbackLink = /* @__PURE__ */ __name2((callback) => {
1141
5430
  return () => {
1142
5431
  return ({ next, op }) => {
@@ -1174,6 +5463,7 @@ var callbackLink = /* @__PURE__ */ __name2((callback) => {
1174
5463
  var getClient = /* @__PURE__ */ __name2(async (url, didAuthFunction) => {
1175
5464
  let challenges = [];
1176
5465
  const challengeRequester = createTRPCProxyClient({
5466
+ transformer: import_helpers.RegExpTransformer,
1177
5467
  links: [
1178
5468
  httpBatchLink({
1179
5469
  url,
@@ -1187,6 +5477,7 @@ var getClient = /* @__PURE__ */ __name2(async (url, didAuthFunction) => {
1187
5477
  }, "getChallenges");
1188
5478
  challenges = await getChallenges();
1189
5479
  const trpc = createTRPCProxyClient({
5480
+ transformer: import_helpers.RegExpTransformer,
1190
5481
  links: [
1191
5482
  callbackLink(async () => {
1192
5483
  challenges = await getChallenges();
@@ -4528,6 +8819,8 @@ var mod = /* @__PURE__ */ Object.freeze({
4528
8819
  });
4529
8820
 
4530
8821
  // ../../learn-card-types/dist/types.esm.js
8822
+ var __defProp3 = Object.defineProperty;
8823
+ var __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", { value, configurable: true }), "__name");
4531
8824
  var ContextValidator = mod.array(mod.string().or(mod.record(mod.any())));
4532
8825
  var AchievementCriteriaValidator = mod.object({
4533
8826
  type: mod.string().optional(),
@@ -4931,6 +9224,35 @@ var EncryptedCredentialRecordValidator = EncryptedRecordValidator.extend({
4931
9224
  var PaginatedEncryptedCredentialRecordsValidator = PaginationResponseValidator.extend({
4932
9225
  records: EncryptedCredentialRecordValidator.array()
4933
9226
  });
9227
+ var parseRegexString = /* @__PURE__ */ __name3((regexStr) => {
9228
+ const match = regexStr.match(/^\/(.*)\/([gimsuy]*)$/);
9229
+ if (!match)
9230
+ throw new Error("Invalid RegExp string format");
9231
+ return { pattern: match[1], flags: match[2] };
9232
+ }, "parseRegexString");
9233
+ var RegExpValidator = mod.instanceof(RegExp).or(
9234
+ mod.string().refine(
9235
+ (str) => {
9236
+ try {
9237
+ parseRegexString(str);
9238
+ return true;
9239
+ } catch {
9240
+ return false;
9241
+ }
9242
+ },
9243
+ {
9244
+ message: "Invalid RegExp string format. Must be in format '/pattern/flags'"
9245
+ }
9246
+ ).transform((str) => {
9247
+ const { pattern, flags } = parseRegexString(str);
9248
+ try {
9249
+ return new RegExp(pattern, flags);
9250
+ } catch (error) {
9251
+ throw new Error(`Invalid RegExp: ${error.message}`);
9252
+ }
9253
+ })
9254
+ );
9255
+ var StringQuery = mod.string().or(mod.object({ $in: mod.string().array() })).or(mod.object({ $regex: RegExpValidator }));
4934
9256
  var LCNProfileValidator = mod.object({
4935
9257
  profileId: mod.string().min(3).max(40),
4936
9258
  displayName: mod.string().default(""),
@@ -4945,6 +9267,16 @@ var LCNProfileValidator = mod.object({
4945
9267
  type: mod.string().optional(),
4946
9268
  notificationsWebhook: mod.string().url().startsWith("http").optional()
4947
9269
  });
9270
+ var LCNProfileQueryValidator = mod.object({
9271
+ profileId: StringQuery,
9272
+ displayName: StringQuery,
9273
+ shortBio: StringQuery,
9274
+ bio: StringQuery,
9275
+ email: StringQuery,
9276
+ websiteLink: StringQuery,
9277
+ isServiceProfile: mod.boolean(),
9278
+ type: StringQuery
9279
+ }).partial();
4948
9280
  var PaginatedLCNProfilesValidator = PaginationResponseValidator.extend({
4949
9281
  records: LCNProfileValidator.array()
4950
9282
  });
@@ -4985,7 +9317,6 @@ var BoostValidator = mod.object({
4985
9317
  meta: mod.record(mod.any()).optional(),
4986
9318
  claimPermissions: BoostPermissionsValidator.optional()
4987
9319
  });
4988
- var StringQuery = mod.string().or(mod.object({ $in: mod.string().array() })).or(mod.object({ $regex: mod.instanceof(RegExp) }));
4989
9320
  var BoostQueryValidator = mod.object({
4990
9321
  uri: StringQuery,
4991
9322
  name: StringQuery,
@@ -5001,7 +9332,8 @@ var PaginatedBoostsValidator = PaginationResponseValidator.extend({
5001
9332
  var BoostRecipientValidator = mod.object({
5002
9333
  to: LCNProfileValidator,
5003
9334
  from: mod.string(),
5004
- received: mod.string().optional()
9335
+ received: mod.string().optional(),
9336
+ uri: mod.string().optional()
5005
9337
  });
5006
9338
  var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
5007
9339
  records: BoostRecipientValidator.array()
@@ -5575,14 +9907,15 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
5575
9907
  includeUnacceptedBoosts
5576
9908
  });
5577
9909
  },
5578
- getPaginatedBoostRecipients: async (_learnCard, uri, limit = 25, cursor = void 0, includeUnacceptedBoosts = true) => {
9910
+ getPaginatedBoostRecipients: async (_learnCard, uri, limit = 25, cursor = void 0, includeUnacceptedBoosts = true, query) => {
5579
9911
  if (!userData)
5580
9912
  throw new Error("Please make an account first!");
5581
9913
  return client.boost.getPaginatedBoostRecipients.query({
5582
9914
  uri,
5583
9915
  limit,
5584
9916
  cursor,
5585
- includeUnacceptedBoosts
9917
+ includeUnacceptedBoosts,
9918
+ query
5586
9919
  });
5587
9920
  },
5588
9921
  countBoostRecipients: async (_learnCard, uri, includeUnacceptedBoosts = true) => {