@c3-oss/prosa 0.8.1 → 0.9.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.
package/dist/cli/main.js CHANGED
@@ -9077,8 +9077,8 @@ var init_service_error_classification = __esm({
9077
9077
  "Load failed",
9078
9078
  "Network request failed"
9079
9079
  ]);
9080
- const isValid = error && error instanceof TypeError;
9081
- if (!isValid) {
9080
+ const isValid2 = error && error instanceof TypeError;
9081
+ if (!isValid2) {
9082
9082
  return false;
9083
9083
  }
9084
9084
  return errorMessages.has(error.message);
@@ -12436,11 +12436,11 @@ function validate2(xmlData, options) {
12436
12436
  if (attrStr[attrStr.length - 1] === "/") {
12437
12437
  const attrStrStart = i6 - attrStr.length;
12438
12438
  attrStr = attrStr.substring(0, attrStr.length - 1);
12439
- const isValid = validateAttributeString(attrStr, options);
12440
- if (isValid === true) {
12439
+ const isValid2 = validateAttributeString(attrStr, options);
12440
+ if (isValid2 === true) {
12441
12441
  tagFound = true;
12442
12442
  } else {
12443
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
12443
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid2.err.line));
12444
12444
  }
12445
12445
  } else if (closingTag) {
12446
12446
  if (!result.tagClosed) {
@@ -12460,9 +12460,9 @@ function validate2(xmlData, options) {
12460
12460
  }
12461
12461
  }
12462
12462
  } else {
12463
- const isValid = validateAttributeString(attrStr, options);
12464
- if (isValid !== true) {
12465
- return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid.err.line));
12463
+ const isValid2 = validateAttributeString(attrStr, options);
12464
+ if (isValid2 !== true) {
12465
+ return getErrorObject(isValid2.err.code, isValid2.err.msg, getLineNumberForPosition(xmlData, i6 - attrStr.length + isValid2.err.line));
12466
12466
  }
12467
12467
  if (reachedRoot === true) {
12468
12468
  return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i6));
@@ -28393,7 +28393,4762 @@ var CliUserError = class extends Error {
28393
28393
  // src/cli/auth/client.ts
28394
28394
  import { request as httpRequest } from "http";
28395
28395
  import { request as httpsRequest } from "https";
28396
- import { OBJECT_PACK_BINARY_CONTENT_TYPE, encodeBinaryObjectPack } from "@c3-oss/prosa-sync";
28396
+
28397
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
28398
+ var external_exports = {};
28399
+ __export(external_exports, {
28400
+ BRAND: () => BRAND,
28401
+ DIRTY: () => DIRTY,
28402
+ EMPTY_PATH: () => EMPTY_PATH,
28403
+ INVALID: () => INVALID,
28404
+ NEVER: () => NEVER,
28405
+ OK: () => OK,
28406
+ ParseStatus: () => ParseStatus,
28407
+ Schema: () => ZodType,
28408
+ ZodAny: () => ZodAny,
28409
+ ZodArray: () => ZodArray,
28410
+ ZodBigInt: () => ZodBigInt,
28411
+ ZodBoolean: () => ZodBoolean,
28412
+ ZodBranded: () => ZodBranded,
28413
+ ZodCatch: () => ZodCatch,
28414
+ ZodDate: () => ZodDate,
28415
+ ZodDefault: () => ZodDefault,
28416
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
28417
+ ZodEffects: () => ZodEffects,
28418
+ ZodEnum: () => ZodEnum,
28419
+ ZodError: () => ZodError,
28420
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
28421
+ ZodFunction: () => ZodFunction,
28422
+ ZodIntersection: () => ZodIntersection,
28423
+ ZodIssueCode: () => ZodIssueCode,
28424
+ ZodLazy: () => ZodLazy,
28425
+ ZodLiteral: () => ZodLiteral,
28426
+ ZodMap: () => ZodMap,
28427
+ ZodNaN: () => ZodNaN,
28428
+ ZodNativeEnum: () => ZodNativeEnum,
28429
+ ZodNever: () => ZodNever,
28430
+ ZodNull: () => ZodNull,
28431
+ ZodNullable: () => ZodNullable,
28432
+ ZodNumber: () => ZodNumber,
28433
+ ZodObject: () => ZodObject,
28434
+ ZodOptional: () => ZodOptional,
28435
+ ZodParsedType: () => ZodParsedType,
28436
+ ZodPipeline: () => ZodPipeline,
28437
+ ZodPromise: () => ZodPromise,
28438
+ ZodReadonly: () => ZodReadonly,
28439
+ ZodRecord: () => ZodRecord,
28440
+ ZodSchema: () => ZodType,
28441
+ ZodSet: () => ZodSet,
28442
+ ZodString: () => ZodString,
28443
+ ZodSymbol: () => ZodSymbol,
28444
+ ZodTransformer: () => ZodEffects,
28445
+ ZodTuple: () => ZodTuple,
28446
+ ZodType: () => ZodType,
28447
+ ZodUndefined: () => ZodUndefined,
28448
+ ZodUnion: () => ZodUnion,
28449
+ ZodUnknown: () => ZodUnknown,
28450
+ ZodVoid: () => ZodVoid,
28451
+ addIssueToContext: () => addIssueToContext,
28452
+ any: () => anyType,
28453
+ array: () => arrayType,
28454
+ bigint: () => bigIntType,
28455
+ boolean: () => booleanType,
28456
+ coerce: () => coerce,
28457
+ custom: () => custom,
28458
+ date: () => dateType,
28459
+ datetimeRegex: () => datetimeRegex,
28460
+ defaultErrorMap: () => en_default,
28461
+ discriminatedUnion: () => discriminatedUnionType,
28462
+ effect: () => effectsType,
28463
+ enum: () => enumType,
28464
+ function: () => functionType,
28465
+ getErrorMap: () => getErrorMap,
28466
+ getParsedType: () => getParsedType,
28467
+ instanceof: () => instanceOfType,
28468
+ intersection: () => intersectionType,
28469
+ isAborted: () => isAborted,
28470
+ isAsync: () => isAsync,
28471
+ isDirty: () => isDirty,
28472
+ isValid: () => isValid,
28473
+ late: () => late,
28474
+ lazy: () => lazyType,
28475
+ literal: () => literalType,
28476
+ makeIssue: () => makeIssue,
28477
+ map: () => mapType,
28478
+ nan: () => nanType,
28479
+ nativeEnum: () => nativeEnumType,
28480
+ never: () => neverType,
28481
+ null: () => nullType,
28482
+ nullable: () => nullableType,
28483
+ number: () => numberType,
28484
+ object: () => objectType,
28485
+ objectUtil: () => objectUtil,
28486
+ oboolean: () => oboolean,
28487
+ onumber: () => onumber,
28488
+ optional: () => optionalType,
28489
+ ostring: () => ostring,
28490
+ pipeline: () => pipelineType,
28491
+ preprocess: () => preprocessType,
28492
+ promise: () => promiseType,
28493
+ quotelessJson: () => quotelessJson,
28494
+ record: () => recordType,
28495
+ set: () => setType,
28496
+ setErrorMap: () => setErrorMap,
28497
+ strictObject: () => strictObjectType,
28498
+ string: () => stringType,
28499
+ symbol: () => symbolType,
28500
+ transformer: () => effectsType,
28501
+ tuple: () => tupleType,
28502
+ undefined: () => undefinedType,
28503
+ union: () => unionType,
28504
+ unknown: () => unknownType,
28505
+ util: () => util,
28506
+ void: () => voidType
28507
+ });
28508
+
28509
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
28510
+ var util;
28511
+ (function(util2) {
28512
+ util2.assertEqual = (_) => {
28513
+ };
28514
+ function assertIs(_arg) {
28515
+ }
28516
+ __name(assertIs, "assertIs");
28517
+ util2.assertIs = assertIs;
28518
+ function assertNever(_x2) {
28519
+ throw new Error();
28520
+ }
28521
+ __name(assertNever, "assertNever");
28522
+ util2.assertNever = assertNever;
28523
+ util2.arrayToEnum = (items) => {
28524
+ const obj = {};
28525
+ for (const item of items) {
28526
+ obj[item] = item;
28527
+ }
28528
+ return obj;
28529
+ };
28530
+ util2.getValidEnumValues = (obj) => {
28531
+ const validKeys = util2.objectKeys(obj).filter((k6) => typeof obj[obj[k6]] !== "number");
28532
+ const filtered = {};
28533
+ for (const k6 of validKeys) {
28534
+ filtered[k6] = obj[k6];
28535
+ }
28536
+ return util2.objectValues(filtered);
28537
+ };
28538
+ util2.objectValues = (obj) => {
28539
+ return util2.objectKeys(obj).map(function(e6) {
28540
+ return obj[e6];
28541
+ });
28542
+ };
28543
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
28544
+ const keys = [];
28545
+ for (const key in object) {
28546
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
28547
+ keys.push(key);
28548
+ }
28549
+ }
28550
+ return keys;
28551
+ };
28552
+ util2.find = (arr, checker) => {
28553
+ for (const item of arr) {
28554
+ if (checker(item)) return item;
28555
+ }
28556
+ return void 0;
28557
+ };
28558
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
28559
+ function joinValues(array, separator = " | ") {
28560
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
28561
+ }
28562
+ __name(joinValues, "joinValues");
28563
+ util2.joinValues = joinValues;
28564
+ util2.jsonStringifyReplacer = (_, value) => {
28565
+ if (typeof value === "bigint") {
28566
+ return value.toString();
28567
+ }
28568
+ return value;
28569
+ };
28570
+ })(util || (util = {}));
28571
+ var objectUtil;
28572
+ (function(objectUtil2) {
28573
+ objectUtil2.mergeShapes = (first, second) => {
28574
+ return {
28575
+ ...first,
28576
+ ...second
28577
+ };
28578
+ };
28579
+ })(objectUtil || (objectUtil = {}));
28580
+ var ZodParsedType = util.arrayToEnum([
28581
+ "string",
28582
+ "nan",
28583
+ "number",
28584
+ "integer",
28585
+ "float",
28586
+ "boolean",
28587
+ "date",
28588
+ "bigint",
28589
+ "symbol",
28590
+ "function",
28591
+ "undefined",
28592
+ "null",
28593
+ "array",
28594
+ "object",
28595
+ "unknown",
28596
+ "promise",
28597
+ "void",
28598
+ "never",
28599
+ "map",
28600
+ "set"
28601
+ ]);
28602
+ var getParsedType = /* @__PURE__ */ __name((data) => {
28603
+ const t8 = typeof data;
28604
+ switch (t8) {
28605
+ case "undefined":
28606
+ return ZodParsedType.undefined;
28607
+ case "string":
28608
+ return ZodParsedType.string;
28609
+ case "number":
28610
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
28611
+ case "boolean":
28612
+ return ZodParsedType.boolean;
28613
+ case "function":
28614
+ return ZodParsedType.function;
28615
+ case "bigint":
28616
+ return ZodParsedType.bigint;
28617
+ case "symbol":
28618
+ return ZodParsedType.symbol;
28619
+ case "object":
28620
+ if (Array.isArray(data)) {
28621
+ return ZodParsedType.array;
28622
+ }
28623
+ if (data === null) {
28624
+ return ZodParsedType.null;
28625
+ }
28626
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
28627
+ return ZodParsedType.promise;
28628
+ }
28629
+ if (typeof Map !== "undefined" && data instanceof Map) {
28630
+ return ZodParsedType.map;
28631
+ }
28632
+ if (typeof Set !== "undefined" && data instanceof Set) {
28633
+ return ZodParsedType.set;
28634
+ }
28635
+ if (typeof Date !== "undefined" && data instanceof Date) {
28636
+ return ZodParsedType.date;
28637
+ }
28638
+ return ZodParsedType.object;
28639
+ default:
28640
+ return ZodParsedType.unknown;
28641
+ }
28642
+ }, "getParsedType");
28643
+
28644
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
28645
+ var ZodIssueCode = util.arrayToEnum([
28646
+ "invalid_type",
28647
+ "invalid_literal",
28648
+ "custom",
28649
+ "invalid_union",
28650
+ "invalid_union_discriminator",
28651
+ "invalid_enum_value",
28652
+ "unrecognized_keys",
28653
+ "invalid_arguments",
28654
+ "invalid_return_type",
28655
+ "invalid_date",
28656
+ "invalid_string",
28657
+ "too_small",
28658
+ "too_big",
28659
+ "invalid_intersection_types",
28660
+ "not_multiple_of",
28661
+ "not_finite"
28662
+ ]);
28663
+ var quotelessJson = /* @__PURE__ */ __name((obj) => {
28664
+ const json = JSON.stringify(obj, null, 2);
28665
+ return json.replace(/"([^"]+)":/g, "$1:");
28666
+ }, "quotelessJson");
28667
+ var ZodError = class _ZodError extends Error {
28668
+ static {
28669
+ __name(this, "ZodError");
28670
+ }
28671
+ get errors() {
28672
+ return this.issues;
28673
+ }
28674
+ constructor(issues) {
28675
+ super();
28676
+ this.issues = [];
28677
+ this.addIssue = (sub) => {
28678
+ this.issues = [
28679
+ ...this.issues,
28680
+ sub
28681
+ ];
28682
+ };
28683
+ this.addIssues = (subs = []) => {
28684
+ this.issues = [
28685
+ ...this.issues,
28686
+ ...subs
28687
+ ];
28688
+ };
28689
+ const actualProto = new.target.prototype;
28690
+ if (Object.setPrototypeOf) {
28691
+ Object.setPrototypeOf(this, actualProto);
28692
+ } else {
28693
+ this.__proto__ = actualProto;
28694
+ }
28695
+ this.name = "ZodError";
28696
+ this.issues = issues;
28697
+ }
28698
+ format(_mapper) {
28699
+ const mapper = _mapper || function(issue) {
28700
+ return issue.message;
28701
+ };
28702
+ const fieldErrors = {
28703
+ _errors: []
28704
+ };
28705
+ const processError = /* @__PURE__ */ __name((error) => {
28706
+ for (const issue of error.issues) {
28707
+ if (issue.code === "invalid_union") {
28708
+ issue.unionErrors.map(processError);
28709
+ } else if (issue.code === "invalid_return_type") {
28710
+ processError(issue.returnTypeError);
28711
+ } else if (issue.code === "invalid_arguments") {
28712
+ processError(issue.argumentsError);
28713
+ } else if (issue.path.length === 0) {
28714
+ fieldErrors._errors.push(mapper(issue));
28715
+ } else {
28716
+ let curr = fieldErrors;
28717
+ let i6 = 0;
28718
+ while (i6 < issue.path.length) {
28719
+ const el = issue.path[i6];
28720
+ const terminal = i6 === issue.path.length - 1;
28721
+ if (!terminal) {
28722
+ curr[el] = curr[el] || {
28723
+ _errors: []
28724
+ };
28725
+ } else {
28726
+ curr[el] = curr[el] || {
28727
+ _errors: []
28728
+ };
28729
+ curr[el]._errors.push(mapper(issue));
28730
+ }
28731
+ curr = curr[el];
28732
+ i6++;
28733
+ }
28734
+ }
28735
+ }
28736
+ }, "processError");
28737
+ processError(this);
28738
+ return fieldErrors;
28739
+ }
28740
+ static assert(value) {
28741
+ if (!(value instanceof _ZodError)) {
28742
+ throw new Error(`Not a ZodError: ${value}`);
28743
+ }
28744
+ }
28745
+ toString() {
28746
+ return this.message;
28747
+ }
28748
+ get message() {
28749
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
28750
+ }
28751
+ get isEmpty() {
28752
+ return this.issues.length === 0;
28753
+ }
28754
+ flatten(mapper = (issue) => issue.message) {
28755
+ const fieldErrors = {};
28756
+ const formErrors = [];
28757
+ for (const sub of this.issues) {
28758
+ if (sub.path.length > 0) {
28759
+ const firstEl = sub.path[0];
28760
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
28761
+ fieldErrors[firstEl].push(mapper(sub));
28762
+ } else {
28763
+ formErrors.push(mapper(sub));
28764
+ }
28765
+ }
28766
+ return {
28767
+ formErrors,
28768
+ fieldErrors
28769
+ };
28770
+ }
28771
+ get formErrors() {
28772
+ return this.flatten();
28773
+ }
28774
+ };
28775
+ ZodError.create = (issues) => {
28776
+ const error = new ZodError(issues);
28777
+ return error;
28778
+ };
28779
+
28780
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
28781
+ var errorMap = /* @__PURE__ */ __name((issue, _ctx) => {
28782
+ let message;
28783
+ switch (issue.code) {
28784
+ case ZodIssueCode.invalid_type:
28785
+ if (issue.received === ZodParsedType.undefined) {
28786
+ message = "Required";
28787
+ } else {
28788
+ message = `Expected ${issue.expected}, received ${issue.received}`;
28789
+ }
28790
+ break;
28791
+ case ZodIssueCode.invalid_literal:
28792
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
28793
+ break;
28794
+ case ZodIssueCode.unrecognized_keys:
28795
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
28796
+ break;
28797
+ case ZodIssueCode.invalid_union:
28798
+ message = `Invalid input`;
28799
+ break;
28800
+ case ZodIssueCode.invalid_union_discriminator:
28801
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
28802
+ break;
28803
+ case ZodIssueCode.invalid_enum_value:
28804
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
28805
+ break;
28806
+ case ZodIssueCode.invalid_arguments:
28807
+ message = `Invalid function arguments`;
28808
+ break;
28809
+ case ZodIssueCode.invalid_return_type:
28810
+ message = `Invalid function return type`;
28811
+ break;
28812
+ case ZodIssueCode.invalid_date:
28813
+ message = `Invalid date`;
28814
+ break;
28815
+ case ZodIssueCode.invalid_string:
28816
+ if (typeof issue.validation === "object") {
28817
+ if ("includes" in issue.validation) {
28818
+ message = `Invalid input: must include "${issue.validation.includes}"`;
28819
+ if (typeof issue.validation.position === "number") {
28820
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
28821
+ }
28822
+ } else if ("startsWith" in issue.validation) {
28823
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
28824
+ } else if ("endsWith" in issue.validation) {
28825
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
28826
+ } else {
28827
+ util.assertNever(issue.validation);
28828
+ }
28829
+ } else if (issue.validation !== "regex") {
28830
+ message = `Invalid ${issue.validation}`;
28831
+ } else {
28832
+ message = "Invalid";
28833
+ }
28834
+ break;
28835
+ case ZodIssueCode.too_small:
28836
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
28837
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
28838
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
28839
+ else if (issue.type === "bigint") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
28840
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
28841
+ else message = "Invalid input";
28842
+ break;
28843
+ case ZodIssueCode.too_big:
28844
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
28845
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
28846
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
28847
+ else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
28848
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
28849
+ else message = "Invalid input";
28850
+ break;
28851
+ case ZodIssueCode.custom:
28852
+ message = `Invalid input`;
28853
+ break;
28854
+ case ZodIssueCode.invalid_intersection_types:
28855
+ message = `Intersection results could not be merged`;
28856
+ break;
28857
+ case ZodIssueCode.not_multiple_of:
28858
+ message = `Number must be a multiple of ${issue.multipleOf}`;
28859
+ break;
28860
+ case ZodIssueCode.not_finite:
28861
+ message = "Number must be finite";
28862
+ break;
28863
+ default:
28864
+ message = _ctx.defaultError;
28865
+ util.assertNever(issue);
28866
+ }
28867
+ return {
28868
+ message
28869
+ };
28870
+ }, "errorMap");
28871
+ var en_default = errorMap;
28872
+
28873
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
28874
+ var overrideErrorMap = en_default;
28875
+ function setErrorMap(map) {
28876
+ overrideErrorMap = map;
28877
+ }
28878
+ __name(setErrorMap, "setErrorMap");
28879
+ function getErrorMap() {
28880
+ return overrideErrorMap;
28881
+ }
28882
+ __name(getErrorMap, "getErrorMap");
28883
+
28884
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
28885
+ var makeIssue = /* @__PURE__ */ __name((params) => {
28886
+ const { data, path: path14, errorMaps, issueData } = params;
28887
+ const fullPath = [
28888
+ ...path14,
28889
+ ...issueData.path || []
28890
+ ];
28891
+ const fullIssue = {
28892
+ ...issueData,
28893
+ path: fullPath
28894
+ };
28895
+ if (issueData.message !== void 0) {
28896
+ return {
28897
+ ...issueData,
28898
+ path: fullPath,
28899
+ message: issueData.message
28900
+ };
28901
+ }
28902
+ let errorMessage = "";
28903
+ const maps = errorMaps.filter((m4) => !!m4).slice().reverse();
28904
+ for (const map of maps) {
28905
+ errorMessage = map(fullIssue, {
28906
+ data,
28907
+ defaultError: errorMessage
28908
+ }).message;
28909
+ }
28910
+ return {
28911
+ ...issueData,
28912
+ path: fullPath,
28913
+ message: errorMessage
28914
+ };
28915
+ }, "makeIssue");
28916
+ var EMPTY_PATH = [];
28917
+ function addIssueToContext(ctx, issueData) {
28918
+ const overrideMap = getErrorMap();
28919
+ const issue = makeIssue({
28920
+ issueData,
28921
+ data: ctx.data,
28922
+ path: ctx.path,
28923
+ errorMaps: [
28924
+ ctx.common.contextualErrorMap,
28925
+ ctx.schemaErrorMap,
28926
+ overrideMap,
28927
+ overrideMap === en_default ? void 0 : en_default
28928
+ ].filter((x2) => !!x2)
28929
+ });
28930
+ ctx.common.issues.push(issue);
28931
+ }
28932
+ __name(addIssueToContext, "addIssueToContext");
28933
+ var ParseStatus = class _ParseStatus {
28934
+ static {
28935
+ __name(this, "ParseStatus");
28936
+ }
28937
+ constructor() {
28938
+ this.value = "valid";
28939
+ }
28940
+ dirty() {
28941
+ if (this.value === "valid") this.value = "dirty";
28942
+ }
28943
+ abort() {
28944
+ if (this.value !== "aborted") this.value = "aborted";
28945
+ }
28946
+ static mergeArray(status, results) {
28947
+ const arrayValue = [];
28948
+ for (const s2 of results) {
28949
+ if (s2.status === "aborted") return INVALID;
28950
+ if (s2.status === "dirty") status.dirty();
28951
+ arrayValue.push(s2.value);
28952
+ }
28953
+ return {
28954
+ status: status.value,
28955
+ value: arrayValue
28956
+ };
28957
+ }
28958
+ static async mergeObjectAsync(status, pairs) {
28959
+ const syncPairs = [];
28960
+ for (const pair of pairs) {
28961
+ const key = await pair.key;
28962
+ const value = await pair.value;
28963
+ syncPairs.push({
28964
+ key,
28965
+ value
28966
+ });
28967
+ }
28968
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
28969
+ }
28970
+ static mergeObjectSync(status, pairs) {
28971
+ const finalObject = {};
28972
+ for (const pair of pairs) {
28973
+ const { key, value } = pair;
28974
+ if (key.status === "aborted") return INVALID;
28975
+ if (value.status === "aborted") return INVALID;
28976
+ if (key.status === "dirty") status.dirty();
28977
+ if (value.status === "dirty") status.dirty();
28978
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
28979
+ finalObject[key.value] = value.value;
28980
+ }
28981
+ }
28982
+ return {
28983
+ status: status.value,
28984
+ value: finalObject
28985
+ };
28986
+ }
28987
+ };
28988
+ var INVALID = Object.freeze({
28989
+ status: "aborted"
28990
+ });
28991
+ var DIRTY = /* @__PURE__ */ __name((value) => ({
28992
+ status: "dirty",
28993
+ value
28994
+ }), "DIRTY");
28995
+ var OK = /* @__PURE__ */ __name((value) => ({
28996
+ status: "valid",
28997
+ value
28998
+ }), "OK");
28999
+ var isAborted = /* @__PURE__ */ __name((x2) => x2.status === "aborted", "isAborted");
29000
+ var isDirty = /* @__PURE__ */ __name((x2) => x2.status === "dirty", "isDirty");
29001
+ var isValid = /* @__PURE__ */ __name((x2) => x2.status === "valid", "isValid");
29002
+ var isAsync = /* @__PURE__ */ __name((x2) => typeof Promise !== "undefined" && x2 instanceof Promise, "isAsync");
29003
+
29004
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
29005
+ var errorUtil;
29006
+ (function(errorUtil2) {
29007
+ errorUtil2.errToObj = (message) => typeof message === "string" ? {
29008
+ message
29009
+ } : message || {};
29010
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
29011
+ })(errorUtil || (errorUtil = {}));
29012
+
29013
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
29014
+ var ParseInputLazyPath = class ParseInputLazyPath2 {
29015
+ static {
29016
+ __name(this, "ParseInputLazyPath");
29017
+ }
29018
+ constructor(parent, value, path14, key) {
29019
+ this._cachedPath = [];
29020
+ this.parent = parent;
29021
+ this.data = value;
29022
+ this._path = path14;
29023
+ this._key = key;
29024
+ }
29025
+ get path() {
29026
+ if (!this._cachedPath.length) {
29027
+ if (Array.isArray(this._key)) {
29028
+ this._cachedPath.push(...this._path, ...this._key);
29029
+ } else {
29030
+ this._cachedPath.push(...this._path, this._key);
29031
+ }
29032
+ }
29033
+ return this._cachedPath;
29034
+ }
29035
+ };
29036
+ var handleResult = /* @__PURE__ */ __name((ctx, result) => {
29037
+ if (isValid(result)) {
29038
+ return {
29039
+ success: true,
29040
+ data: result.value
29041
+ };
29042
+ } else {
29043
+ if (!ctx.common.issues.length) {
29044
+ throw new Error("Validation failed but no issues detected.");
29045
+ }
29046
+ return {
29047
+ success: false,
29048
+ get error() {
29049
+ if (this._error) return this._error;
29050
+ const error = new ZodError(ctx.common.issues);
29051
+ this._error = error;
29052
+ return this._error;
29053
+ }
29054
+ };
29055
+ }
29056
+ }, "handleResult");
29057
+ function processCreateParams(params) {
29058
+ if (!params) return {};
29059
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
29060
+ if (errorMap2 && (invalid_type_error || required_error)) {
29061
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
29062
+ }
29063
+ if (errorMap2) return {
29064
+ errorMap: errorMap2,
29065
+ description
29066
+ };
29067
+ const customMap = /* @__PURE__ */ __name((iss, ctx) => {
29068
+ const { message } = params;
29069
+ if (iss.code === "invalid_enum_value") {
29070
+ return {
29071
+ message: message ?? ctx.defaultError
29072
+ };
29073
+ }
29074
+ if (typeof ctx.data === "undefined") {
29075
+ return {
29076
+ message: message ?? required_error ?? ctx.defaultError
29077
+ };
29078
+ }
29079
+ if (iss.code !== "invalid_type") return {
29080
+ message: ctx.defaultError
29081
+ };
29082
+ return {
29083
+ message: message ?? invalid_type_error ?? ctx.defaultError
29084
+ };
29085
+ }, "customMap");
29086
+ return {
29087
+ errorMap: customMap,
29088
+ description
29089
+ };
29090
+ }
29091
+ __name(processCreateParams, "processCreateParams");
29092
+ var ZodType = class {
29093
+ static {
29094
+ __name(this, "ZodType");
29095
+ }
29096
+ get description() {
29097
+ return this._def.description;
29098
+ }
29099
+ _getType(input) {
29100
+ return getParsedType(input.data);
29101
+ }
29102
+ _getOrReturnCtx(input, ctx) {
29103
+ return ctx || {
29104
+ common: input.parent.common,
29105
+ data: input.data,
29106
+ parsedType: getParsedType(input.data),
29107
+ schemaErrorMap: this._def.errorMap,
29108
+ path: input.path,
29109
+ parent: input.parent
29110
+ };
29111
+ }
29112
+ _processInputParams(input) {
29113
+ return {
29114
+ status: new ParseStatus(),
29115
+ ctx: {
29116
+ common: input.parent.common,
29117
+ data: input.data,
29118
+ parsedType: getParsedType(input.data),
29119
+ schemaErrorMap: this._def.errorMap,
29120
+ path: input.path,
29121
+ parent: input.parent
29122
+ }
29123
+ };
29124
+ }
29125
+ _parseSync(input) {
29126
+ const result = this._parse(input);
29127
+ if (isAsync(result)) {
29128
+ throw new Error("Synchronous parse encountered promise.");
29129
+ }
29130
+ return result;
29131
+ }
29132
+ _parseAsync(input) {
29133
+ const result = this._parse(input);
29134
+ return Promise.resolve(result);
29135
+ }
29136
+ parse(data, params) {
29137
+ const result = this.safeParse(data, params);
29138
+ if (result.success) return result.data;
29139
+ throw result.error;
29140
+ }
29141
+ safeParse(data, params) {
29142
+ const ctx = {
29143
+ common: {
29144
+ issues: [],
29145
+ async: params?.async ?? false,
29146
+ contextualErrorMap: params?.errorMap
29147
+ },
29148
+ path: params?.path || [],
29149
+ schemaErrorMap: this._def.errorMap,
29150
+ parent: null,
29151
+ data,
29152
+ parsedType: getParsedType(data)
29153
+ };
29154
+ const result = this._parseSync({
29155
+ data,
29156
+ path: ctx.path,
29157
+ parent: ctx
29158
+ });
29159
+ return handleResult(ctx, result);
29160
+ }
29161
+ "~validate"(data) {
29162
+ const ctx = {
29163
+ common: {
29164
+ issues: [],
29165
+ async: !!this["~standard"].async
29166
+ },
29167
+ path: [],
29168
+ schemaErrorMap: this._def.errorMap,
29169
+ parent: null,
29170
+ data,
29171
+ parsedType: getParsedType(data)
29172
+ };
29173
+ if (!this["~standard"].async) {
29174
+ try {
29175
+ const result = this._parseSync({
29176
+ data,
29177
+ path: [],
29178
+ parent: ctx
29179
+ });
29180
+ return isValid(result) ? {
29181
+ value: result.value
29182
+ } : {
29183
+ issues: ctx.common.issues
29184
+ };
29185
+ } catch (err) {
29186
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
29187
+ this["~standard"].async = true;
29188
+ }
29189
+ ctx.common = {
29190
+ issues: [],
29191
+ async: true
29192
+ };
29193
+ }
29194
+ }
29195
+ return this._parseAsync({
29196
+ data,
29197
+ path: [],
29198
+ parent: ctx
29199
+ }).then((result) => isValid(result) ? {
29200
+ value: result.value
29201
+ } : {
29202
+ issues: ctx.common.issues
29203
+ });
29204
+ }
29205
+ async parseAsync(data, params) {
29206
+ const result = await this.safeParseAsync(data, params);
29207
+ if (result.success) return result.data;
29208
+ throw result.error;
29209
+ }
29210
+ async safeParseAsync(data, params) {
29211
+ const ctx = {
29212
+ common: {
29213
+ issues: [],
29214
+ contextualErrorMap: params?.errorMap,
29215
+ async: true
29216
+ },
29217
+ path: params?.path || [],
29218
+ schemaErrorMap: this._def.errorMap,
29219
+ parent: null,
29220
+ data,
29221
+ parsedType: getParsedType(data)
29222
+ };
29223
+ const maybeAsyncResult = this._parse({
29224
+ data,
29225
+ path: ctx.path,
29226
+ parent: ctx
29227
+ });
29228
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
29229
+ return handleResult(ctx, result);
29230
+ }
29231
+ refine(check, message) {
29232
+ const getIssueProperties = /* @__PURE__ */ __name((val) => {
29233
+ if (typeof message === "string" || typeof message === "undefined") {
29234
+ return {
29235
+ message
29236
+ };
29237
+ } else if (typeof message === "function") {
29238
+ return message(val);
29239
+ } else {
29240
+ return message;
29241
+ }
29242
+ }, "getIssueProperties");
29243
+ return this._refinement((val, ctx) => {
29244
+ const result = check(val);
29245
+ const setError = /* @__PURE__ */ __name(() => ctx.addIssue({
29246
+ code: ZodIssueCode.custom,
29247
+ ...getIssueProperties(val)
29248
+ }), "setError");
29249
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
29250
+ return result.then((data) => {
29251
+ if (!data) {
29252
+ setError();
29253
+ return false;
29254
+ } else {
29255
+ return true;
29256
+ }
29257
+ });
29258
+ }
29259
+ if (!result) {
29260
+ setError();
29261
+ return false;
29262
+ } else {
29263
+ return true;
29264
+ }
29265
+ });
29266
+ }
29267
+ refinement(check, refinementData) {
29268
+ return this._refinement((val, ctx) => {
29269
+ if (!check(val)) {
29270
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
29271
+ return false;
29272
+ } else {
29273
+ return true;
29274
+ }
29275
+ });
29276
+ }
29277
+ _refinement(refinement) {
29278
+ return new ZodEffects({
29279
+ schema: this,
29280
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
29281
+ effect: {
29282
+ type: "refinement",
29283
+ refinement
29284
+ }
29285
+ });
29286
+ }
29287
+ superRefine(refinement) {
29288
+ return this._refinement(refinement);
29289
+ }
29290
+ constructor(def) {
29291
+ this.spa = this.safeParseAsync;
29292
+ this._def = def;
29293
+ this.parse = this.parse.bind(this);
29294
+ this.safeParse = this.safeParse.bind(this);
29295
+ this.parseAsync = this.parseAsync.bind(this);
29296
+ this.safeParseAsync = this.safeParseAsync.bind(this);
29297
+ this.spa = this.spa.bind(this);
29298
+ this.refine = this.refine.bind(this);
29299
+ this.refinement = this.refinement.bind(this);
29300
+ this.superRefine = this.superRefine.bind(this);
29301
+ this.optional = this.optional.bind(this);
29302
+ this.nullable = this.nullable.bind(this);
29303
+ this.nullish = this.nullish.bind(this);
29304
+ this.array = this.array.bind(this);
29305
+ this.promise = this.promise.bind(this);
29306
+ this.or = this.or.bind(this);
29307
+ this.and = this.and.bind(this);
29308
+ this.transform = this.transform.bind(this);
29309
+ this.brand = this.brand.bind(this);
29310
+ this.default = this.default.bind(this);
29311
+ this.catch = this.catch.bind(this);
29312
+ this.describe = this.describe.bind(this);
29313
+ this.pipe = this.pipe.bind(this);
29314
+ this.readonly = this.readonly.bind(this);
29315
+ this.isNullable = this.isNullable.bind(this);
29316
+ this.isOptional = this.isOptional.bind(this);
29317
+ this["~standard"] = {
29318
+ version: 1,
29319
+ vendor: "zod",
29320
+ validate: /* @__PURE__ */ __name((data) => this["~validate"](data), "validate")
29321
+ };
29322
+ }
29323
+ optional() {
29324
+ return ZodOptional.create(this, this._def);
29325
+ }
29326
+ nullable() {
29327
+ return ZodNullable.create(this, this._def);
29328
+ }
29329
+ nullish() {
29330
+ return this.nullable().optional();
29331
+ }
29332
+ array() {
29333
+ return ZodArray.create(this);
29334
+ }
29335
+ promise() {
29336
+ return ZodPromise.create(this, this._def);
29337
+ }
29338
+ or(option) {
29339
+ return ZodUnion.create([
29340
+ this,
29341
+ option
29342
+ ], this._def);
29343
+ }
29344
+ and(incoming) {
29345
+ return ZodIntersection.create(this, incoming, this._def);
29346
+ }
29347
+ transform(transform) {
29348
+ return new ZodEffects({
29349
+ ...processCreateParams(this._def),
29350
+ schema: this,
29351
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
29352
+ effect: {
29353
+ type: "transform",
29354
+ transform
29355
+ }
29356
+ });
29357
+ }
29358
+ default(def) {
29359
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
29360
+ return new ZodDefault({
29361
+ ...processCreateParams(this._def),
29362
+ innerType: this,
29363
+ defaultValue: defaultValueFunc,
29364
+ typeName: ZodFirstPartyTypeKind.ZodDefault
29365
+ });
29366
+ }
29367
+ brand() {
29368
+ return new ZodBranded({
29369
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
29370
+ type: this,
29371
+ ...processCreateParams(this._def)
29372
+ });
29373
+ }
29374
+ catch(def) {
29375
+ const catchValueFunc = typeof def === "function" ? def : () => def;
29376
+ return new ZodCatch({
29377
+ ...processCreateParams(this._def),
29378
+ innerType: this,
29379
+ catchValue: catchValueFunc,
29380
+ typeName: ZodFirstPartyTypeKind.ZodCatch
29381
+ });
29382
+ }
29383
+ describe(description) {
29384
+ const This = this.constructor;
29385
+ return new This({
29386
+ ...this._def,
29387
+ description
29388
+ });
29389
+ }
29390
+ pipe(target) {
29391
+ return ZodPipeline.create(this, target);
29392
+ }
29393
+ readonly() {
29394
+ return ZodReadonly.create(this);
29395
+ }
29396
+ isOptional() {
29397
+ return this.safeParse(void 0).success;
29398
+ }
29399
+ isNullable() {
29400
+ return this.safeParse(null).success;
29401
+ }
29402
+ };
29403
+ var cuidRegex = /^c[^\s-]{8,}$/i;
29404
+ var cuid2Regex = /^[0-9a-z]+$/;
29405
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
29406
+ var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
29407
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
29408
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
29409
+ var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
29410
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
29411
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
29412
+ var emojiRegex;
29413
+ var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
29414
+ var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
29415
+ var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
29416
+ var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
29417
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
29418
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
29419
+ var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
29420
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
29421
+ function timeRegexSource(args) {
29422
+ let secondsRegexSource = `[0-5]\\d`;
29423
+ if (args.precision) {
29424
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
29425
+ } else if (args.precision == null) {
29426
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
29427
+ }
29428
+ const secondsQuantifier = args.precision ? "+" : "?";
29429
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
29430
+ }
29431
+ __name(timeRegexSource, "timeRegexSource");
29432
+ function timeRegex(args) {
29433
+ return new RegExp(`^${timeRegexSource(args)}$`);
29434
+ }
29435
+ __name(timeRegex, "timeRegex");
29436
+ function datetimeRegex(args) {
29437
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
29438
+ const opts = [];
29439
+ opts.push(args.local ? `Z?` : `Z`);
29440
+ if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
29441
+ regex = `${regex}(${opts.join("|")})`;
29442
+ return new RegExp(`^${regex}$`);
29443
+ }
29444
+ __name(datetimeRegex, "datetimeRegex");
29445
+ function isValidIP(ip, version) {
29446
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
29447
+ return true;
29448
+ }
29449
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
29450
+ return true;
29451
+ }
29452
+ return false;
29453
+ }
29454
+ __name(isValidIP, "isValidIP");
29455
+ function isValidJWT(jwt, alg) {
29456
+ if (!jwtRegex.test(jwt)) return false;
29457
+ try {
29458
+ const [header] = jwt.split(".");
29459
+ if (!header) return false;
29460
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
29461
+ const decoded = JSON.parse(atob(base64));
29462
+ if (typeof decoded !== "object" || decoded === null) return false;
29463
+ if ("typ" in decoded && decoded?.typ !== "JWT") return false;
29464
+ if (!decoded.alg) return false;
29465
+ if (alg && decoded.alg !== alg) return false;
29466
+ return true;
29467
+ } catch {
29468
+ return false;
29469
+ }
29470
+ }
29471
+ __name(isValidJWT, "isValidJWT");
29472
+ function isValidCidr(ip, version) {
29473
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
29474
+ return true;
29475
+ }
29476
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
29477
+ return true;
29478
+ }
29479
+ return false;
29480
+ }
29481
+ __name(isValidCidr, "isValidCidr");
29482
+ var ZodString = class _ZodString extends ZodType {
29483
+ static {
29484
+ __name(this, "ZodString");
29485
+ }
29486
+ _parse(input) {
29487
+ if (this._def.coerce) {
29488
+ input.data = String(input.data);
29489
+ }
29490
+ const parsedType = this._getType(input);
29491
+ if (parsedType !== ZodParsedType.string) {
29492
+ const ctx2 = this._getOrReturnCtx(input);
29493
+ addIssueToContext(ctx2, {
29494
+ code: ZodIssueCode.invalid_type,
29495
+ expected: ZodParsedType.string,
29496
+ received: ctx2.parsedType
29497
+ });
29498
+ return INVALID;
29499
+ }
29500
+ const status = new ParseStatus();
29501
+ let ctx = void 0;
29502
+ for (const check of this._def.checks) {
29503
+ if (check.kind === "min") {
29504
+ if (input.data.length < check.value) {
29505
+ ctx = this._getOrReturnCtx(input, ctx);
29506
+ addIssueToContext(ctx, {
29507
+ code: ZodIssueCode.too_small,
29508
+ minimum: check.value,
29509
+ type: "string",
29510
+ inclusive: true,
29511
+ exact: false,
29512
+ message: check.message
29513
+ });
29514
+ status.dirty();
29515
+ }
29516
+ } else if (check.kind === "max") {
29517
+ if (input.data.length > check.value) {
29518
+ ctx = this._getOrReturnCtx(input, ctx);
29519
+ addIssueToContext(ctx, {
29520
+ code: ZodIssueCode.too_big,
29521
+ maximum: check.value,
29522
+ type: "string",
29523
+ inclusive: true,
29524
+ exact: false,
29525
+ message: check.message
29526
+ });
29527
+ status.dirty();
29528
+ }
29529
+ } else if (check.kind === "length") {
29530
+ const tooBig = input.data.length > check.value;
29531
+ const tooSmall = input.data.length < check.value;
29532
+ if (tooBig || tooSmall) {
29533
+ ctx = this._getOrReturnCtx(input, ctx);
29534
+ if (tooBig) {
29535
+ addIssueToContext(ctx, {
29536
+ code: ZodIssueCode.too_big,
29537
+ maximum: check.value,
29538
+ type: "string",
29539
+ inclusive: true,
29540
+ exact: true,
29541
+ message: check.message
29542
+ });
29543
+ } else if (tooSmall) {
29544
+ addIssueToContext(ctx, {
29545
+ code: ZodIssueCode.too_small,
29546
+ minimum: check.value,
29547
+ type: "string",
29548
+ inclusive: true,
29549
+ exact: true,
29550
+ message: check.message
29551
+ });
29552
+ }
29553
+ status.dirty();
29554
+ }
29555
+ } else if (check.kind === "email") {
29556
+ if (!emailRegex.test(input.data)) {
29557
+ ctx = this._getOrReturnCtx(input, ctx);
29558
+ addIssueToContext(ctx, {
29559
+ validation: "email",
29560
+ code: ZodIssueCode.invalid_string,
29561
+ message: check.message
29562
+ });
29563
+ status.dirty();
29564
+ }
29565
+ } else if (check.kind === "emoji") {
29566
+ if (!emojiRegex) {
29567
+ emojiRegex = new RegExp(_emojiRegex, "u");
29568
+ }
29569
+ if (!emojiRegex.test(input.data)) {
29570
+ ctx = this._getOrReturnCtx(input, ctx);
29571
+ addIssueToContext(ctx, {
29572
+ validation: "emoji",
29573
+ code: ZodIssueCode.invalid_string,
29574
+ message: check.message
29575
+ });
29576
+ status.dirty();
29577
+ }
29578
+ } else if (check.kind === "uuid") {
29579
+ if (!uuidRegex.test(input.data)) {
29580
+ ctx = this._getOrReturnCtx(input, ctx);
29581
+ addIssueToContext(ctx, {
29582
+ validation: "uuid",
29583
+ code: ZodIssueCode.invalid_string,
29584
+ message: check.message
29585
+ });
29586
+ status.dirty();
29587
+ }
29588
+ } else if (check.kind === "nanoid") {
29589
+ if (!nanoidRegex.test(input.data)) {
29590
+ ctx = this._getOrReturnCtx(input, ctx);
29591
+ addIssueToContext(ctx, {
29592
+ validation: "nanoid",
29593
+ code: ZodIssueCode.invalid_string,
29594
+ message: check.message
29595
+ });
29596
+ status.dirty();
29597
+ }
29598
+ } else if (check.kind === "cuid") {
29599
+ if (!cuidRegex.test(input.data)) {
29600
+ ctx = this._getOrReturnCtx(input, ctx);
29601
+ addIssueToContext(ctx, {
29602
+ validation: "cuid",
29603
+ code: ZodIssueCode.invalid_string,
29604
+ message: check.message
29605
+ });
29606
+ status.dirty();
29607
+ }
29608
+ } else if (check.kind === "cuid2") {
29609
+ if (!cuid2Regex.test(input.data)) {
29610
+ ctx = this._getOrReturnCtx(input, ctx);
29611
+ addIssueToContext(ctx, {
29612
+ validation: "cuid2",
29613
+ code: ZodIssueCode.invalid_string,
29614
+ message: check.message
29615
+ });
29616
+ status.dirty();
29617
+ }
29618
+ } else if (check.kind === "ulid") {
29619
+ if (!ulidRegex.test(input.data)) {
29620
+ ctx = this._getOrReturnCtx(input, ctx);
29621
+ addIssueToContext(ctx, {
29622
+ validation: "ulid",
29623
+ code: ZodIssueCode.invalid_string,
29624
+ message: check.message
29625
+ });
29626
+ status.dirty();
29627
+ }
29628
+ } else if (check.kind === "url") {
29629
+ try {
29630
+ new URL(input.data);
29631
+ } catch {
29632
+ ctx = this._getOrReturnCtx(input, ctx);
29633
+ addIssueToContext(ctx, {
29634
+ validation: "url",
29635
+ code: ZodIssueCode.invalid_string,
29636
+ message: check.message
29637
+ });
29638
+ status.dirty();
29639
+ }
29640
+ } else if (check.kind === "regex") {
29641
+ check.regex.lastIndex = 0;
29642
+ const testResult = check.regex.test(input.data);
29643
+ if (!testResult) {
29644
+ ctx = this._getOrReturnCtx(input, ctx);
29645
+ addIssueToContext(ctx, {
29646
+ validation: "regex",
29647
+ code: ZodIssueCode.invalid_string,
29648
+ message: check.message
29649
+ });
29650
+ status.dirty();
29651
+ }
29652
+ } else if (check.kind === "trim") {
29653
+ input.data = input.data.trim();
29654
+ } else if (check.kind === "includes") {
29655
+ if (!input.data.includes(check.value, check.position)) {
29656
+ ctx = this._getOrReturnCtx(input, ctx);
29657
+ addIssueToContext(ctx, {
29658
+ code: ZodIssueCode.invalid_string,
29659
+ validation: {
29660
+ includes: check.value,
29661
+ position: check.position
29662
+ },
29663
+ message: check.message
29664
+ });
29665
+ status.dirty();
29666
+ }
29667
+ } else if (check.kind === "toLowerCase") {
29668
+ input.data = input.data.toLowerCase();
29669
+ } else if (check.kind === "toUpperCase") {
29670
+ input.data = input.data.toUpperCase();
29671
+ } else if (check.kind === "startsWith") {
29672
+ if (!input.data.startsWith(check.value)) {
29673
+ ctx = this._getOrReturnCtx(input, ctx);
29674
+ addIssueToContext(ctx, {
29675
+ code: ZodIssueCode.invalid_string,
29676
+ validation: {
29677
+ startsWith: check.value
29678
+ },
29679
+ message: check.message
29680
+ });
29681
+ status.dirty();
29682
+ }
29683
+ } else if (check.kind === "endsWith") {
29684
+ if (!input.data.endsWith(check.value)) {
29685
+ ctx = this._getOrReturnCtx(input, ctx);
29686
+ addIssueToContext(ctx, {
29687
+ code: ZodIssueCode.invalid_string,
29688
+ validation: {
29689
+ endsWith: check.value
29690
+ },
29691
+ message: check.message
29692
+ });
29693
+ status.dirty();
29694
+ }
29695
+ } else if (check.kind === "datetime") {
29696
+ const regex = datetimeRegex(check);
29697
+ if (!regex.test(input.data)) {
29698
+ ctx = this._getOrReturnCtx(input, ctx);
29699
+ addIssueToContext(ctx, {
29700
+ code: ZodIssueCode.invalid_string,
29701
+ validation: "datetime",
29702
+ message: check.message
29703
+ });
29704
+ status.dirty();
29705
+ }
29706
+ } else if (check.kind === "date") {
29707
+ const regex = dateRegex;
29708
+ if (!regex.test(input.data)) {
29709
+ ctx = this._getOrReturnCtx(input, ctx);
29710
+ addIssueToContext(ctx, {
29711
+ code: ZodIssueCode.invalid_string,
29712
+ validation: "date",
29713
+ message: check.message
29714
+ });
29715
+ status.dirty();
29716
+ }
29717
+ } else if (check.kind === "time") {
29718
+ const regex = timeRegex(check);
29719
+ if (!regex.test(input.data)) {
29720
+ ctx = this._getOrReturnCtx(input, ctx);
29721
+ addIssueToContext(ctx, {
29722
+ code: ZodIssueCode.invalid_string,
29723
+ validation: "time",
29724
+ message: check.message
29725
+ });
29726
+ status.dirty();
29727
+ }
29728
+ } else if (check.kind === "duration") {
29729
+ if (!durationRegex.test(input.data)) {
29730
+ ctx = this._getOrReturnCtx(input, ctx);
29731
+ addIssueToContext(ctx, {
29732
+ validation: "duration",
29733
+ code: ZodIssueCode.invalid_string,
29734
+ message: check.message
29735
+ });
29736
+ status.dirty();
29737
+ }
29738
+ } else if (check.kind === "ip") {
29739
+ if (!isValidIP(input.data, check.version)) {
29740
+ ctx = this._getOrReturnCtx(input, ctx);
29741
+ addIssueToContext(ctx, {
29742
+ validation: "ip",
29743
+ code: ZodIssueCode.invalid_string,
29744
+ message: check.message
29745
+ });
29746
+ status.dirty();
29747
+ }
29748
+ } else if (check.kind === "jwt") {
29749
+ if (!isValidJWT(input.data, check.alg)) {
29750
+ ctx = this._getOrReturnCtx(input, ctx);
29751
+ addIssueToContext(ctx, {
29752
+ validation: "jwt",
29753
+ code: ZodIssueCode.invalid_string,
29754
+ message: check.message
29755
+ });
29756
+ status.dirty();
29757
+ }
29758
+ } else if (check.kind === "cidr") {
29759
+ if (!isValidCidr(input.data, check.version)) {
29760
+ ctx = this._getOrReturnCtx(input, ctx);
29761
+ addIssueToContext(ctx, {
29762
+ validation: "cidr",
29763
+ code: ZodIssueCode.invalid_string,
29764
+ message: check.message
29765
+ });
29766
+ status.dirty();
29767
+ }
29768
+ } else if (check.kind === "base64") {
29769
+ if (!base64Regex.test(input.data)) {
29770
+ ctx = this._getOrReturnCtx(input, ctx);
29771
+ addIssueToContext(ctx, {
29772
+ validation: "base64",
29773
+ code: ZodIssueCode.invalid_string,
29774
+ message: check.message
29775
+ });
29776
+ status.dirty();
29777
+ }
29778
+ } else if (check.kind === "base64url") {
29779
+ if (!base64urlRegex.test(input.data)) {
29780
+ ctx = this._getOrReturnCtx(input, ctx);
29781
+ addIssueToContext(ctx, {
29782
+ validation: "base64url",
29783
+ code: ZodIssueCode.invalid_string,
29784
+ message: check.message
29785
+ });
29786
+ status.dirty();
29787
+ }
29788
+ } else {
29789
+ util.assertNever(check);
29790
+ }
29791
+ }
29792
+ return {
29793
+ status: status.value,
29794
+ value: input.data
29795
+ };
29796
+ }
29797
+ _regex(regex, validation, message) {
29798
+ return this.refinement((data) => regex.test(data), {
29799
+ validation,
29800
+ code: ZodIssueCode.invalid_string,
29801
+ ...errorUtil.errToObj(message)
29802
+ });
29803
+ }
29804
+ _addCheck(check) {
29805
+ return new _ZodString({
29806
+ ...this._def,
29807
+ checks: [
29808
+ ...this._def.checks,
29809
+ check
29810
+ ]
29811
+ });
29812
+ }
29813
+ email(message) {
29814
+ return this._addCheck({
29815
+ kind: "email",
29816
+ ...errorUtil.errToObj(message)
29817
+ });
29818
+ }
29819
+ url(message) {
29820
+ return this._addCheck({
29821
+ kind: "url",
29822
+ ...errorUtil.errToObj(message)
29823
+ });
29824
+ }
29825
+ emoji(message) {
29826
+ return this._addCheck({
29827
+ kind: "emoji",
29828
+ ...errorUtil.errToObj(message)
29829
+ });
29830
+ }
29831
+ uuid(message) {
29832
+ return this._addCheck({
29833
+ kind: "uuid",
29834
+ ...errorUtil.errToObj(message)
29835
+ });
29836
+ }
29837
+ nanoid(message) {
29838
+ return this._addCheck({
29839
+ kind: "nanoid",
29840
+ ...errorUtil.errToObj(message)
29841
+ });
29842
+ }
29843
+ cuid(message) {
29844
+ return this._addCheck({
29845
+ kind: "cuid",
29846
+ ...errorUtil.errToObj(message)
29847
+ });
29848
+ }
29849
+ cuid2(message) {
29850
+ return this._addCheck({
29851
+ kind: "cuid2",
29852
+ ...errorUtil.errToObj(message)
29853
+ });
29854
+ }
29855
+ ulid(message) {
29856
+ return this._addCheck({
29857
+ kind: "ulid",
29858
+ ...errorUtil.errToObj(message)
29859
+ });
29860
+ }
29861
+ base64(message) {
29862
+ return this._addCheck({
29863
+ kind: "base64",
29864
+ ...errorUtil.errToObj(message)
29865
+ });
29866
+ }
29867
+ base64url(message) {
29868
+ return this._addCheck({
29869
+ kind: "base64url",
29870
+ ...errorUtil.errToObj(message)
29871
+ });
29872
+ }
29873
+ jwt(options) {
29874
+ return this._addCheck({
29875
+ kind: "jwt",
29876
+ ...errorUtil.errToObj(options)
29877
+ });
29878
+ }
29879
+ ip(options) {
29880
+ return this._addCheck({
29881
+ kind: "ip",
29882
+ ...errorUtil.errToObj(options)
29883
+ });
29884
+ }
29885
+ cidr(options) {
29886
+ return this._addCheck({
29887
+ kind: "cidr",
29888
+ ...errorUtil.errToObj(options)
29889
+ });
29890
+ }
29891
+ datetime(options) {
29892
+ if (typeof options === "string") {
29893
+ return this._addCheck({
29894
+ kind: "datetime",
29895
+ precision: null,
29896
+ offset: false,
29897
+ local: false,
29898
+ message: options
29899
+ });
29900
+ }
29901
+ return this._addCheck({
29902
+ kind: "datetime",
29903
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
29904
+ offset: options?.offset ?? false,
29905
+ local: options?.local ?? false,
29906
+ ...errorUtil.errToObj(options?.message)
29907
+ });
29908
+ }
29909
+ date(message) {
29910
+ return this._addCheck({
29911
+ kind: "date",
29912
+ message
29913
+ });
29914
+ }
29915
+ time(options) {
29916
+ if (typeof options === "string") {
29917
+ return this._addCheck({
29918
+ kind: "time",
29919
+ precision: null,
29920
+ message: options
29921
+ });
29922
+ }
29923
+ return this._addCheck({
29924
+ kind: "time",
29925
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
29926
+ ...errorUtil.errToObj(options?.message)
29927
+ });
29928
+ }
29929
+ duration(message) {
29930
+ return this._addCheck({
29931
+ kind: "duration",
29932
+ ...errorUtil.errToObj(message)
29933
+ });
29934
+ }
29935
+ regex(regex, message) {
29936
+ return this._addCheck({
29937
+ kind: "regex",
29938
+ regex,
29939
+ ...errorUtil.errToObj(message)
29940
+ });
29941
+ }
29942
+ includes(value, options) {
29943
+ return this._addCheck({
29944
+ kind: "includes",
29945
+ value,
29946
+ position: options?.position,
29947
+ ...errorUtil.errToObj(options?.message)
29948
+ });
29949
+ }
29950
+ startsWith(value, message) {
29951
+ return this._addCheck({
29952
+ kind: "startsWith",
29953
+ value,
29954
+ ...errorUtil.errToObj(message)
29955
+ });
29956
+ }
29957
+ endsWith(value, message) {
29958
+ return this._addCheck({
29959
+ kind: "endsWith",
29960
+ value,
29961
+ ...errorUtil.errToObj(message)
29962
+ });
29963
+ }
29964
+ min(minLength, message) {
29965
+ return this._addCheck({
29966
+ kind: "min",
29967
+ value: minLength,
29968
+ ...errorUtil.errToObj(message)
29969
+ });
29970
+ }
29971
+ max(maxLength, message) {
29972
+ return this._addCheck({
29973
+ kind: "max",
29974
+ value: maxLength,
29975
+ ...errorUtil.errToObj(message)
29976
+ });
29977
+ }
29978
+ length(len, message) {
29979
+ return this._addCheck({
29980
+ kind: "length",
29981
+ value: len,
29982
+ ...errorUtil.errToObj(message)
29983
+ });
29984
+ }
29985
+ /**
29986
+ * Equivalent to `.min(1)`
29987
+ */
29988
+ nonempty(message) {
29989
+ return this.min(1, errorUtil.errToObj(message));
29990
+ }
29991
+ trim() {
29992
+ return new _ZodString({
29993
+ ...this._def,
29994
+ checks: [
29995
+ ...this._def.checks,
29996
+ {
29997
+ kind: "trim"
29998
+ }
29999
+ ]
30000
+ });
30001
+ }
30002
+ toLowerCase() {
30003
+ return new _ZodString({
30004
+ ...this._def,
30005
+ checks: [
30006
+ ...this._def.checks,
30007
+ {
30008
+ kind: "toLowerCase"
30009
+ }
30010
+ ]
30011
+ });
30012
+ }
30013
+ toUpperCase() {
30014
+ return new _ZodString({
30015
+ ...this._def,
30016
+ checks: [
30017
+ ...this._def.checks,
30018
+ {
30019
+ kind: "toUpperCase"
30020
+ }
30021
+ ]
30022
+ });
30023
+ }
30024
+ get isDatetime() {
30025
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
30026
+ }
30027
+ get isDate() {
30028
+ return !!this._def.checks.find((ch) => ch.kind === "date");
30029
+ }
30030
+ get isTime() {
30031
+ return !!this._def.checks.find((ch) => ch.kind === "time");
30032
+ }
30033
+ get isDuration() {
30034
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
30035
+ }
30036
+ get isEmail() {
30037
+ return !!this._def.checks.find((ch) => ch.kind === "email");
30038
+ }
30039
+ get isURL() {
30040
+ return !!this._def.checks.find((ch) => ch.kind === "url");
30041
+ }
30042
+ get isEmoji() {
30043
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
30044
+ }
30045
+ get isUUID() {
30046
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
30047
+ }
30048
+ get isNANOID() {
30049
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
30050
+ }
30051
+ get isCUID() {
30052
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
30053
+ }
30054
+ get isCUID2() {
30055
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
30056
+ }
30057
+ get isULID() {
30058
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
30059
+ }
30060
+ get isIP() {
30061
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
30062
+ }
30063
+ get isCIDR() {
30064
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
30065
+ }
30066
+ get isBase64() {
30067
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
30068
+ }
30069
+ get isBase64url() {
30070
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
30071
+ }
30072
+ get minLength() {
30073
+ let min = null;
30074
+ for (const ch of this._def.checks) {
30075
+ if (ch.kind === "min") {
30076
+ if (min === null || ch.value > min) min = ch.value;
30077
+ }
30078
+ }
30079
+ return min;
30080
+ }
30081
+ get maxLength() {
30082
+ let max = null;
30083
+ for (const ch of this._def.checks) {
30084
+ if (ch.kind === "max") {
30085
+ if (max === null || ch.value < max) max = ch.value;
30086
+ }
30087
+ }
30088
+ return max;
30089
+ }
30090
+ };
30091
+ ZodString.create = (params) => {
30092
+ return new ZodString({
30093
+ checks: [],
30094
+ typeName: ZodFirstPartyTypeKind.ZodString,
30095
+ coerce: params?.coerce ?? false,
30096
+ ...processCreateParams(params)
30097
+ });
30098
+ };
30099
+ function floatSafeRemainder(val, step) {
30100
+ const valDecCount = (val.toString().split(".")[1] || "").length;
30101
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
30102
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
30103
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
30104
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
30105
+ return valInt % stepInt / 10 ** decCount;
30106
+ }
30107
+ __name(floatSafeRemainder, "floatSafeRemainder");
30108
+ var ZodNumber = class _ZodNumber extends ZodType {
30109
+ static {
30110
+ __name(this, "ZodNumber");
30111
+ }
30112
+ constructor() {
30113
+ super(...arguments);
30114
+ this.min = this.gte;
30115
+ this.max = this.lte;
30116
+ this.step = this.multipleOf;
30117
+ }
30118
+ _parse(input) {
30119
+ if (this._def.coerce) {
30120
+ input.data = Number(input.data);
30121
+ }
30122
+ const parsedType = this._getType(input);
30123
+ if (parsedType !== ZodParsedType.number) {
30124
+ const ctx2 = this._getOrReturnCtx(input);
30125
+ addIssueToContext(ctx2, {
30126
+ code: ZodIssueCode.invalid_type,
30127
+ expected: ZodParsedType.number,
30128
+ received: ctx2.parsedType
30129
+ });
30130
+ return INVALID;
30131
+ }
30132
+ let ctx = void 0;
30133
+ const status = new ParseStatus();
30134
+ for (const check of this._def.checks) {
30135
+ if (check.kind === "int") {
30136
+ if (!util.isInteger(input.data)) {
30137
+ ctx = this._getOrReturnCtx(input, ctx);
30138
+ addIssueToContext(ctx, {
30139
+ code: ZodIssueCode.invalid_type,
30140
+ expected: "integer",
30141
+ received: "float",
30142
+ message: check.message
30143
+ });
30144
+ status.dirty();
30145
+ }
30146
+ } else if (check.kind === "min") {
30147
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
30148
+ if (tooSmall) {
30149
+ ctx = this._getOrReturnCtx(input, ctx);
30150
+ addIssueToContext(ctx, {
30151
+ code: ZodIssueCode.too_small,
30152
+ minimum: check.value,
30153
+ type: "number",
30154
+ inclusive: check.inclusive,
30155
+ exact: false,
30156
+ message: check.message
30157
+ });
30158
+ status.dirty();
30159
+ }
30160
+ } else if (check.kind === "max") {
30161
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
30162
+ if (tooBig) {
30163
+ ctx = this._getOrReturnCtx(input, ctx);
30164
+ addIssueToContext(ctx, {
30165
+ code: ZodIssueCode.too_big,
30166
+ maximum: check.value,
30167
+ type: "number",
30168
+ inclusive: check.inclusive,
30169
+ exact: false,
30170
+ message: check.message
30171
+ });
30172
+ status.dirty();
30173
+ }
30174
+ } else if (check.kind === "multipleOf") {
30175
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
30176
+ ctx = this._getOrReturnCtx(input, ctx);
30177
+ addIssueToContext(ctx, {
30178
+ code: ZodIssueCode.not_multiple_of,
30179
+ multipleOf: check.value,
30180
+ message: check.message
30181
+ });
30182
+ status.dirty();
30183
+ }
30184
+ } else if (check.kind === "finite") {
30185
+ if (!Number.isFinite(input.data)) {
30186
+ ctx = this._getOrReturnCtx(input, ctx);
30187
+ addIssueToContext(ctx, {
30188
+ code: ZodIssueCode.not_finite,
30189
+ message: check.message
30190
+ });
30191
+ status.dirty();
30192
+ }
30193
+ } else {
30194
+ util.assertNever(check);
30195
+ }
30196
+ }
30197
+ return {
30198
+ status: status.value,
30199
+ value: input.data
30200
+ };
30201
+ }
30202
+ gte(value, message) {
30203
+ return this.setLimit("min", value, true, errorUtil.toString(message));
30204
+ }
30205
+ gt(value, message) {
30206
+ return this.setLimit("min", value, false, errorUtil.toString(message));
30207
+ }
30208
+ lte(value, message) {
30209
+ return this.setLimit("max", value, true, errorUtil.toString(message));
30210
+ }
30211
+ lt(value, message) {
30212
+ return this.setLimit("max", value, false, errorUtil.toString(message));
30213
+ }
30214
+ setLimit(kind, value, inclusive, message) {
30215
+ return new _ZodNumber({
30216
+ ...this._def,
30217
+ checks: [
30218
+ ...this._def.checks,
30219
+ {
30220
+ kind,
30221
+ value,
30222
+ inclusive,
30223
+ message: errorUtil.toString(message)
30224
+ }
30225
+ ]
30226
+ });
30227
+ }
30228
+ _addCheck(check) {
30229
+ return new _ZodNumber({
30230
+ ...this._def,
30231
+ checks: [
30232
+ ...this._def.checks,
30233
+ check
30234
+ ]
30235
+ });
30236
+ }
30237
+ int(message) {
30238
+ return this._addCheck({
30239
+ kind: "int",
30240
+ message: errorUtil.toString(message)
30241
+ });
30242
+ }
30243
+ positive(message) {
30244
+ return this._addCheck({
30245
+ kind: "min",
30246
+ value: 0,
30247
+ inclusive: false,
30248
+ message: errorUtil.toString(message)
30249
+ });
30250
+ }
30251
+ negative(message) {
30252
+ return this._addCheck({
30253
+ kind: "max",
30254
+ value: 0,
30255
+ inclusive: false,
30256
+ message: errorUtil.toString(message)
30257
+ });
30258
+ }
30259
+ nonpositive(message) {
30260
+ return this._addCheck({
30261
+ kind: "max",
30262
+ value: 0,
30263
+ inclusive: true,
30264
+ message: errorUtil.toString(message)
30265
+ });
30266
+ }
30267
+ nonnegative(message) {
30268
+ return this._addCheck({
30269
+ kind: "min",
30270
+ value: 0,
30271
+ inclusive: true,
30272
+ message: errorUtil.toString(message)
30273
+ });
30274
+ }
30275
+ multipleOf(value, message) {
30276
+ return this._addCheck({
30277
+ kind: "multipleOf",
30278
+ value,
30279
+ message: errorUtil.toString(message)
30280
+ });
30281
+ }
30282
+ finite(message) {
30283
+ return this._addCheck({
30284
+ kind: "finite",
30285
+ message: errorUtil.toString(message)
30286
+ });
30287
+ }
30288
+ safe(message) {
30289
+ return this._addCheck({
30290
+ kind: "min",
30291
+ inclusive: true,
30292
+ value: Number.MIN_SAFE_INTEGER,
30293
+ message: errorUtil.toString(message)
30294
+ })._addCheck({
30295
+ kind: "max",
30296
+ inclusive: true,
30297
+ value: Number.MAX_SAFE_INTEGER,
30298
+ message: errorUtil.toString(message)
30299
+ });
30300
+ }
30301
+ get minValue() {
30302
+ let min = null;
30303
+ for (const ch of this._def.checks) {
30304
+ if (ch.kind === "min") {
30305
+ if (min === null || ch.value > min) min = ch.value;
30306
+ }
30307
+ }
30308
+ return min;
30309
+ }
30310
+ get maxValue() {
30311
+ let max = null;
30312
+ for (const ch of this._def.checks) {
30313
+ if (ch.kind === "max") {
30314
+ if (max === null || ch.value < max) max = ch.value;
30315
+ }
30316
+ }
30317
+ return max;
30318
+ }
30319
+ get isInt() {
30320
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
30321
+ }
30322
+ get isFinite() {
30323
+ let max = null;
30324
+ let min = null;
30325
+ for (const ch of this._def.checks) {
30326
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
30327
+ return true;
30328
+ } else if (ch.kind === "min") {
30329
+ if (min === null || ch.value > min) min = ch.value;
30330
+ } else if (ch.kind === "max") {
30331
+ if (max === null || ch.value < max) max = ch.value;
30332
+ }
30333
+ }
30334
+ return Number.isFinite(min) && Number.isFinite(max);
30335
+ }
30336
+ };
30337
+ ZodNumber.create = (params) => {
30338
+ return new ZodNumber({
30339
+ checks: [],
30340
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
30341
+ coerce: params?.coerce || false,
30342
+ ...processCreateParams(params)
30343
+ });
30344
+ };
30345
+ var ZodBigInt = class _ZodBigInt extends ZodType {
30346
+ static {
30347
+ __name(this, "ZodBigInt");
30348
+ }
30349
+ constructor() {
30350
+ super(...arguments);
30351
+ this.min = this.gte;
30352
+ this.max = this.lte;
30353
+ }
30354
+ _parse(input) {
30355
+ if (this._def.coerce) {
30356
+ try {
30357
+ input.data = BigInt(input.data);
30358
+ } catch {
30359
+ return this._getInvalidInput(input);
30360
+ }
30361
+ }
30362
+ const parsedType = this._getType(input);
30363
+ if (parsedType !== ZodParsedType.bigint) {
30364
+ return this._getInvalidInput(input);
30365
+ }
30366
+ let ctx = void 0;
30367
+ const status = new ParseStatus();
30368
+ for (const check of this._def.checks) {
30369
+ if (check.kind === "min") {
30370
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
30371
+ if (tooSmall) {
30372
+ ctx = this._getOrReturnCtx(input, ctx);
30373
+ addIssueToContext(ctx, {
30374
+ code: ZodIssueCode.too_small,
30375
+ type: "bigint",
30376
+ minimum: check.value,
30377
+ inclusive: check.inclusive,
30378
+ message: check.message
30379
+ });
30380
+ status.dirty();
30381
+ }
30382
+ } else if (check.kind === "max") {
30383
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
30384
+ if (tooBig) {
30385
+ ctx = this._getOrReturnCtx(input, ctx);
30386
+ addIssueToContext(ctx, {
30387
+ code: ZodIssueCode.too_big,
30388
+ type: "bigint",
30389
+ maximum: check.value,
30390
+ inclusive: check.inclusive,
30391
+ message: check.message
30392
+ });
30393
+ status.dirty();
30394
+ }
30395
+ } else if (check.kind === "multipleOf") {
30396
+ if (input.data % check.value !== BigInt(0)) {
30397
+ ctx = this._getOrReturnCtx(input, ctx);
30398
+ addIssueToContext(ctx, {
30399
+ code: ZodIssueCode.not_multiple_of,
30400
+ multipleOf: check.value,
30401
+ message: check.message
30402
+ });
30403
+ status.dirty();
30404
+ }
30405
+ } else {
30406
+ util.assertNever(check);
30407
+ }
30408
+ }
30409
+ return {
30410
+ status: status.value,
30411
+ value: input.data
30412
+ };
30413
+ }
30414
+ _getInvalidInput(input) {
30415
+ const ctx = this._getOrReturnCtx(input);
30416
+ addIssueToContext(ctx, {
30417
+ code: ZodIssueCode.invalid_type,
30418
+ expected: ZodParsedType.bigint,
30419
+ received: ctx.parsedType
30420
+ });
30421
+ return INVALID;
30422
+ }
30423
+ gte(value, message) {
30424
+ return this.setLimit("min", value, true, errorUtil.toString(message));
30425
+ }
30426
+ gt(value, message) {
30427
+ return this.setLimit("min", value, false, errorUtil.toString(message));
30428
+ }
30429
+ lte(value, message) {
30430
+ return this.setLimit("max", value, true, errorUtil.toString(message));
30431
+ }
30432
+ lt(value, message) {
30433
+ return this.setLimit("max", value, false, errorUtil.toString(message));
30434
+ }
30435
+ setLimit(kind, value, inclusive, message) {
30436
+ return new _ZodBigInt({
30437
+ ...this._def,
30438
+ checks: [
30439
+ ...this._def.checks,
30440
+ {
30441
+ kind,
30442
+ value,
30443
+ inclusive,
30444
+ message: errorUtil.toString(message)
30445
+ }
30446
+ ]
30447
+ });
30448
+ }
30449
+ _addCheck(check) {
30450
+ return new _ZodBigInt({
30451
+ ...this._def,
30452
+ checks: [
30453
+ ...this._def.checks,
30454
+ check
30455
+ ]
30456
+ });
30457
+ }
30458
+ positive(message) {
30459
+ return this._addCheck({
30460
+ kind: "min",
30461
+ value: BigInt(0),
30462
+ inclusive: false,
30463
+ message: errorUtil.toString(message)
30464
+ });
30465
+ }
30466
+ negative(message) {
30467
+ return this._addCheck({
30468
+ kind: "max",
30469
+ value: BigInt(0),
30470
+ inclusive: false,
30471
+ message: errorUtil.toString(message)
30472
+ });
30473
+ }
30474
+ nonpositive(message) {
30475
+ return this._addCheck({
30476
+ kind: "max",
30477
+ value: BigInt(0),
30478
+ inclusive: true,
30479
+ message: errorUtil.toString(message)
30480
+ });
30481
+ }
30482
+ nonnegative(message) {
30483
+ return this._addCheck({
30484
+ kind: "min",
30485
+ value: BigInt(0),
30486
+ inclusive: true,
30487
+ message: errorUtil.toString(message)
30488
+ });
30489
+ }
30490
+ multipleOf(value, message) {
30491
+ return this._addCheck({
30492
+ kind: "multipleOf",
30493
+ value,
30494
+ message: errorUtil.toString(message)
30495
+ });
30496
+ }
30497
+ get minValue() {
30498
+ let min = null;
30499
+ for (const ch of this._def.checks) {
30500
+ if (ch.kind === "min") {
30501
+ if (min === null || ch.value > min) min = ch.value;
30502
+ }
30503
+ }
30504
+ return min;
30505
+ }
30506
+ get maxValue() {
30507
+ let max = null;
30508
+ for (const ch of this._def.checks) {
30509
+ if (ch.kind === "max") {
30510
+ if (max === null || ch.value < max) max = ch.value;
30511
+ }
30512
+ }
30513
+ return max;
30514
+ }
30515
+ };
30516
+ ZodBigInt.create = (params) => {
30517
+ return new ZodBigInt({
30518
+ checks: [],
30519
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
30520
+ coerce: params?.coerce ?? false,
30521
+ ...processCreateParams(params)
30522
+ });
30523
+ };
30524
+ var ZodBoolean = class extends ZodType {
30525
+ static {
30526
+ __name(this, "ZodBoolean");
30527
+ }
30528
+ _parse(input) {
30529
+ if (this._def.coerce) {
30530
+ input.data = Boolean(input.data);
30531
+ }
30532
+ const parsedType = this._getType(input);
30533
+ if (parsedType !== ZodParsedType.boolean) {
30534
+ const ctx = this._getOrReturnCtx(input);
30535
+ addIssueToContext(ctx, {
30536
+ code: ZodIssueCode.invalid_type,
30537
+ expected: ZodParsedType.boolean,
30538
+ received: ctx.parsedType
30539
+ });
30540
+ return INVALID;
30541
+ }
30542
+ return OK(input.data);
30543
+ }
30544
+ };
30545
+ ZodBoolean.create = (params) => {
30546
+ return new ZodBoolean({
30547
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
30548
+ coerce: params?.coerce || false,
30549
+ ...processCreateParams(params)
30550
+ });
30551
+ };
30552
+ var ZodDate = class _ZodDate extends ZodType {
30553
+ static {
30554
+ __name(this, "ZodDate");
30555
+ }
30556
+ _parse(input) {
30557
+ if (this._def.coerce) {
30558
+ input.data = new Date(input.data);
30559
+ }
30560
+ const parsedType = this._getType(input);
30561
+ if (parsedType !== ZodParsedType.date) {
30562
+ const ctx2 = this._getOrReturnCtx(input);
30563
+ addIssueToContext(ctx2, {
30564
+ code: ZodIssueCode.invalid_type,
30565
+ expected: ZodParsedType.date,
30566
+ received: ctx2.parsedType
30567
+ });
30568
+ return INVALID;
30569
+ }
30570
+ if (Number.isNaN(input.data.getTime())) {
30571
+ const ctx2 = this._getOrReturnCtx(input);
30572
+ addIssueToContext(ctx2, {
30573
+ code: ZodIssueCode.invalid_date
30574
+ });
30575
+ return INVALID;
30576
+ }
30577
+ const status = new ParseStatus();
30578
+ let ctx = void 0;
30579
+ for (const check of this._def.checks) {
30580
+ if (check.kind === "min") {
30581
+ if (input.data.getTime() < check.value) {
30582
+ ctx = this._getOrReturnCtx(input, ctx);
30583
+ addIssueToContext(ctx, {
30584
+ code: ZodIssueCode.too_small,
30585
+ message: check.message,
30586
+ inclusive: true,
30587
+ exact: false,
30588
+ minimum: check.value,
30589
+ type: "date"
30590
+ });
30591
+ status.dirty();
30592
+ }
30593
+ } else if (check.kind === "max") {
30594
+ if (input.data.getTime() > check.value) {
30595
+ ctx = this._getOrReturnCtx(input, ctx);
30596
+ addIssueToContext(ctx, {
30597
+ code: ZodIssueCode.too_big,
30598
+ message: check.message,
30599
+ inclusive: true,
30600
+ exact: false,
30601
+ maximum: check.value,
30602
+ type: "date"
30603
+ });
30604
+ status.dirty();
30605
+ }
30606
+ } else {
30607
+ util.assertNever(check);
30608
+ }
30609
+ }
30610
+ return {
30611
+ status: status.value,
30612
+ value: new Date(input.data.getTime())
30613
+ };
30614
+ }
30615
+ _addCheck(check) {
30616
+ return new _ZodDate({
30617
+ ...this._def,
30618
+ checks: [
30619
+ ...this._def.checks,
30620
+ check
30621
+ ]
30622
+ });
30623
+ }
30624
+ min(minDate, message) {
30625
+ return this._addCheck({
30626
+ kind: "min",
30627
+ value: minDate.getTime(),
30628
+ message: errorUtil.toString(message)
30629
+ });
30630
+ }
30631
+ max(maxDate, message) {
30632
+ return this._addCheck({
30633
+ kind: "max",
30634
+ value: maxDate.getTime(),
30635
+ message: errorUtil.toString(message)
30636
+ });
30637
+ }
30638
+ get minDate() {
30639
+ let min = null;
30640
+ for (const ch of this._def.checks) {
30641
+ if (ch.kind === "min") {
30642
+ if (min === null || ch.value > min) min = ch.value;
30643
+ }
30644
+ }
30645
+ return min != null ? new Date(min) : null;
30646
+ }
30647
+ get maxDate() {
30648
+ let max = null;
30649
+ for (const ch of this._def.checks) {
30650
+ if (ch.kind === "max") {
30651
+ if (max === null || ch.value < max) max = ch.value;
30652
+ }
30653
+ }
30654
+ return max != null ? new Date(max) : null;
30655
+ }
30656
+ };
30657
+ ZodDate.create = (params) => {
30658
+ return new ZodDate({
30659
+ checks: [],
30660
+ coerce: params?.coerce || false,
30661
+ typeName: ZodFirstPartyTypeKind.ZodDate,
30662
+ ...processCreateParams(params)
30663
+ });
30664
+ };
30665
+ var ZodSymbol = class extends ZodType {
30666
+ static {
30667
+ __name(this, "ZodSymbol");
30668
+ }
30669
+ _parse(input) {
30670
+ const parsedType = this._getType(input);
30671
+ if (parsedType !== ZodParsedType.symbol) {
30672
+ const ctx = this._getOrReturnCtx(input);
30673
+ addIssueToContext(ctx, {
30674
+ code: ZodIssueCode.invalid_type,
30675
+ expected: ZodParsedType.symbol,
30676
+ received: ctx.parsedType
30677
+ });
30678
+ return INVALID;
30679
+ }
30680
+ return OK(input.data);
30681
+ }
30682
+ };
30683
+ ZodSymbol.create = (params) => {
30684
+ return new ZodSymbol({
30685
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
30686
+ ...processCreateParams(params)
30687
+ });
30688
+ };
30689
+ var ZodUndefined = class extends ZodType {
30690
+ static {
30691
+ __name(this, "ZodUndefined");
30692
+ }
30693
+ _parse(input) {
30694
+ const parsedType = this._getType(input);
30695
+ if (parsedType !== ZodParsedType.undefined) {
30696
+ const ctx = this._getOrReturnCtx(input);
30697
+ addIssueToContext(ctx, {
30698
+ code: ZodIssueCode.invalid_type,
30699
+ expected: ZodParsedType.undefined,
30700
+ received: ctx.parsedType
30701
+ });
30702
+ return INVALID;
30703
+ }
30704
+ return OK(input.data);
30705
+ }
30706
+ };
30707
+ ZodUndefined.create = (params) => {
30708
+ return new ZodUndefined({
30709
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
30710
+ ...processCreateParams(params)
30711
+ });
30712
+ };
30713
+ var ZodNull = class extends ZodType {
30714
+ static {
30715
+ __name(this, "ZodNull");
30716
+ }
30717
+ _parse(input) {
30718
+ const parsedType = this._getType(input);
30719
+ if (parsedType !== ZodParsedType.null) {
30720
+ const ctx = this._getOrReturnCtx(input);
30721
+ addIssueToContext(ctx, {
30722
+ code: ZodIssueCode.invalid_type,
30723
+ expected: ZodParsedType.null,
30724
+ received: ctx.parsedType
30725
+ });
30726
+ return INVALID;
30727
+ }
30728
+ return OK(input.data);
30729
+ }
30730
+ };
30731
+ ZodNull.create = (params) => {
30732
+ return new ZodNull({
30733
+ typeName: ZodFirstPartyTypeKind.ZodNull,
30734
+ ...processCreateParams(params)
30735
+ });
30736
+ };
30737
+ var ZodAny = class extends ZodType {
30738
+ static {
30739
+ __name(this, "ZodAny");
30740
+ }
30741
+ constructor() {
30742
+ super(...arguments);
30743
+ this._any = true;
30744
+ }
30745
+ _parse(input) {
30746
+ return OK(input.data);
30747
+ }
30748
+ };
30749
+ ZodAny.create = (params) => {
30750
+ return new ZodAny({
30751
+ typeName: ZodFirstPartyTypeKind.ZodAny,
30752
+ ...processCreateParams(params)
30753
+ });
30754
+ };
30755
+ var ZodUnknown = class extends ZodType {
30756
+ static {
30757
+ __name(this, "ZodUnknown");
30758
+ }
30759
+ constructor() {
30760
+ super(...arguments);
30761
+ this._unknown = true;
30762
+ }
30763
+ _parse(input) {
30764
+ return OK(input.data);
30765
+ }
30766
+ };
30767
+ ZodUnknown.create = (params) => {
30768
+ return new ZodUnknown({
30769
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
30770
+ ...processCreateParams(params)
30771
+ });
30772
+ };
30773
+ var ZodNever = class extends ZodType {
30774
+ static {
30775
+ __name(this, "ZodNever");
30776
+ }
30777
+ _parse(input) {
30778
+ const ctx = this._getOrReturnCtx(input);
30779
+ addIssueToContext(ctx, {
30780
+ code: ZodIssueCode.invalid_type,
30781
+ expected: ZodParsedType.never,
30782
+ received: ctx.parsedType
30783
+ });
30784
+ return INVALID;
30785
+ }
30786
+ };
30787
+ ZodNever.create = (params) => {
30788
+ return new ZodNever({
30789
+ typeName: ZodFirstPartyTypeKind.ZodNever,
30790
+ ...processCreateParams(params)
30791
+ });
30792
+ };
30793
+ var ZodVoid = class extends ZodType {
30794
+ static {
30795
+ __name(this, "ZodVoid");
30796
+ }
30797
+ _parse(input) {
30798
+ const parsedType = this._getType(input);
30799
+ if (parsedType !== ZodParsedType.undefined) {
30800
+ const ctx = this._getOrReturnCtx(input);
30801
+ addIssueToContext(ctx, {
30802
+ code: ZodIssueCode.invalid_type,
30803
+ expected: ZodParsedType.void,
30804
+ received: ctx.parsedType
30805
+ });
30806
+ return INVALID;
30807
+ }
30808
+ return OK(input.data);
30809
+ }
30810
+ };
30811
+ ZodVoid.create = (params) => {
30812
+ return new ZodVoid({
30813
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
30814
+ ...processCreateParams(params)
30815
+ });
30816
+ };
30817
+ var ZodArray = class _ZodArray extends ZodType {
30818
+ static {
30819
+ __name(this, "ZodArray");
30820
+ }
30821
+ _parse(input) {
30822
+ const { ctx, status } = this._processInputParams(input);
30823
+ const def = this._def;
30824
+ if (ctx.parsedType !== ZodParsedType.array) {
30825
+ addIssueToContext(ctx, {
30826
+ code: ZodIssueCode.invalid_type,
30827
+ expected: ZodParsedType.array,
30828
+ received: ctx.parsedType
30829
+ });
30830
+ return INVALID;
30831
+ }
30832
+ if (def.exactLength !== null) {
30833
+ const tooBig = ctx.data.length > def.exactLength.value;
30834
+ const tooSmall = ctx.data.length < def.exactLength.value;
30835
+ if (tooBig || tooSmall) {
30836
+ addIssueToContext(ctx, {
30837
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
30838
+ minimum: tooSmall ? def.exactLength.value : void 0,
30839
+ maximum: tooBig ? def.exactLength.value : void 0,
30840
+ type: "array",
30841
+ inclusive: true,
30842
+ exact: true,
30843
+ message: def.exactLength.message
30844
+ });
30845
+ status.dirty();
30846
+ }
30847
+ }
30848
+ if (def.minLength !== null) {
30849
+ if (ctx.data.length < def.minLength.value) {
30850
+ addIssueToContext(ctx, {
30851
+ code: ZodIssueCode.too_small,
30852
+ minimum: def.minLength.value,
30853
+ type: "array",
30854
+ inclusive: true,
30855
+ exact: false,
30856
+ message: def.minLength.message
30857
+ });
30858
+ status.dirty();
30859
+ }
30860
+ }
30861
+ if (def.maxLength !== null) {
30862
+ if (ctx.data.length > def.maxLength.value) {
30863
+ addIssueToContext(ctx, {
30864
+ code: ZodIssueCode.too_big,
30865
+ maximum: def.maxLength.value,
30866
+ type: "array",
30867
+ inclusive: true,
30868
+ exact: false,
30869
+ message: def.maxLength.message
30870
+ });
30871
+ status.dirty();
30872
+ }
30873
+ }
30874
+ if (ctx.common.async) {
30875
+ return Promise.all([
30876
+ ...ctx.data
30877
+ ].map((item, i6) => {
30878
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
30879
+ })).then((result2) => {
30880
+ return ParseStatus.mergeArray(status, result2);
30881
+ });
30882
+ }
30883
+ const result = [
30884
+ ...ctx.data
30885
+ ].map((item, i6) => {
30886
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
30887
+ });
30888
+ return ParseStatus.mergeArray(status, result);
30889
+ }
30890
+ get element() {
30891
+ return this._def.type;
30892
+ }
30893
+ min(minLength, message) {
30894
+ return new _ZodArray({
30895
+ ...this._def,
30896
+ minLength: {
30897
+ value: minLength,
30898
+ message: errorUtil.toString(message)
30899
+ }
30900
+ });
30901
+ }
30902
+ max(maxLength, message) {
30903
+ return new _ZodArray({
30904
+ ...this._def,
30905
+ maxLength: {
30906
+ value: maxLength,
30907
+ message: errorUtil.toString(message)
30908
+ }
30909
+ });
30910
+ }
30911
+ length(len, message) {
30912
+ return new _ZodArray({
30913
+ ...this._def,
30914
+ exactLength: {
30915
+ value: len,
30916
+ message: errorUtil.toString(message)
30917
+ }
30918
+ });
30919
+ }
30920
+ nonempty(message) {
30921
+ return this.min(1, message);
30922
+ }
30923
+ };
30924
+ ZodArray.create = (schema, params) => {
30925
+ return new ZodArray({
30926
+ type: schema,
30927
+ minLength: null,
30928
+ maxLength: null,
30929
+ exactLength: null,
30930
+ typeName: ZodFirstPartyTypeKind.ZodArray,
30931
+ ...processCreateParams(params)
30932
+ });
30933
+ };
30934
+ function deepPartialify(schema) {
30935
+ if (schema instanceof ZodObject) {
30936
+ const newShape = {};
30937
+ for (const key in schema.shape) {
30938
+ const fieldSchema = schema.shape[key];
30939
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
30940
+ }
30941
+ return new ZodObject({
30942
+ ...schema._def,
30943
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
30944
+ });
30945
+ } else if (schema instanceof ZodArray) {
30946
+ return new ZodArray({
30947
+ ...schema._def,
30948
+ type: deepPartialify(schema.element)
30949
+ });
30950
+ } else if (schema instanceof ZodOptional) {
30951
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
30952
+ } else if (schema instanceof ZodNullable) {
30953
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
30954
+ } else if (schema instanceof ZodTuple) {
30955
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
30956
+ } else {
30957
+ return schema;
30958
+ }
30959
+ }
30960
+ __name(deepPartialify, "deepPartialify");
30961
+ var ZodObject = class _ZodObject extends ZodType {
30962
+ static {
30963
+ __name(this, "ZodObject");
30964
+ }
30965
+ constructor() {
30966
+ super(...arguments);
30967
+ this._cached = null;
30968
+ this.nonstrict = this.passthrough;
30969
+ this.augment = this.extend;
30970
+ }
30971
+ _getCached() {
30972
+ if (this._cached !== null) return this._cached;
30973
+ const shape = this._def.shape();
30974
+ const keys = util.objectKeys(shape);
30975
+ this._cached = {
30976
+ shape,
30977
+ keys
30978
+ };
30979
+ return this._cached;
30980
+ }
30981
+ _parse(input) {
30982
+ const parsedType = this._getType(input);
30983
+ if (parsedType !== ZodParsedType.object) {
30984
+ const ctx2 = this._getOrReturnCtx(input);
30985
+ addIssueToContext(ctx2, {
30986
+ code: ZodIssueCode.invalid_type,
30987
+ expected: ZodParsedType.object,
30988
+ received: ctx2.parsedType
30989
+ });
30990
+ return INVALID;
30991
+ }
30992
+ const { status, ctx } = this._processInputParams(input);
30993
+ const { shape, keys: shapeKeys } = this._getCached();
30994
+ const extraKeys = [];
30995
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
30996
+ for (const key in ctx.data) {
30997
+ if (!shapeKeys.includes(key)) {
30998
+ extraKeys.push(key);
30999
+ }
31000
+ }
31001
+ }
31002
+ const pairs = [];
31003
+ for (const key of shapeKeys) {
31004
+ const keyValidator = shape[key];
31005
+ const value = ctx.data[key];
31006
+ pairs.push({
31007
+ key: {
31008
+ status: "valid",
31009
+ value: key
31010
+ },
31011
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
31012
+ alwaysSet: key in ctx.data
31013
+ });
31014
+ }
31015
+ if (this._def.catchall instanceof ZodNever) {
31016
+ const unknownKeys = this._def.unknownKeys;
31017
+ if (unknownKeys === "passthrough") {
31018
+ for (const key of extraKeys) {
31019
+ pairs.push({
31020
+ key: {
31021
+ status: "valid",
31022
+ value: key
31023
+ },
31024
+ value: {
31025
+ status: "valid",
31026
+ value: ctx.data[key]
31027
+ }
31028
+ });
31029
+ }
31030
+ } else if (unknownKeys === "strict") {
31031
+ if (extraKeys.length > 0) {
31032
+ addIssueToContext(ctx, {
31033
+ code: ZodIssueCode.unrecognized_keys,
31034
+ keys: extraKeys
31035
+ });
31036
+ status.dirty();
31037
+ }
31038
+ } else if (unknownKeys === "strip") {
31039
+ } else {
31040
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
31041
+ }
31042
+ } else {
31043
+ const catchall = this._def.catchall;
31044
+ for (const key of extraKeys) {
31045
+ const value = ctx.data[key];
31046
+ pairs.push({
31047
+ key: {
31048
+ status: "valid",
31049
+ value: key
31050
+ },
31051
+ value: catchall._parse(
31052
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
31053
+ //, ctx.child(key), value, getParsedType(value)
31054
+ ),
31055
+ alwaysSet: key in ctx.data
31056
+ });
31057
+ }
31058
+ }
31059
+ if (ctx.common.async) {
31060
+ return Promise.resolve().then(async () => {
31061
+ const syncPairs = [];
31062
+ for (const pair of pairs) {
31063
+ const key = await pair.key;
31064
+ const value = await pair.value;
31065
+ syncPairs.push({
31066
+ key,
31067
+ value,
31068
+ alwaysSet: pair.alwaysSet
31069
+ });
31070
+ }
31071
+ return syncPairs;
31072
+ }).then((syncPairs) => {
31073
+ return ParseStatus.mergeObjectSync(status, syncPairs);
31074
+ });
31075
+ } else {
31076
+ return ParseStatus.mergeObjectSync(status, pairs);
31077
+ }
31078
+ }
31079
+ get shape() {
31080
+ return this._def.shape();
31081
+ }
31082
+ strict(message) {
31083
+ errorUtil.errToObj;
31084
+ return new _ZodObject({
31085
+ ...this._def,
31086
+ unknownKeys: "strict",
31087
+ ...message !== void 0 ? {
31088
+ errorMap: /* @__PURE__ */ __name((issue, ctx) => {
31089
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
31090
+ if (issue.code === "unrecognized_keys") return {
31091
+ message: errorUtil.errToObj(message).message ?? defaultError
31092
+ };
31093
+ return {
31094
+ message: defaultError
31095
+ };
31096
+ }, "errorMap")
31097
+ } : {}
31098
+ });
31099
+ }
31100
+ strip() {
31101
+ return new _ZodObject({
31102
+ ...this._def,
31103
+ unknownKeys: "strip"
31104
+ });
31105
+ }
31106
+ passthrough() {
31107
+ return new _ZodObject({
31108
+ ...this._def,
31109
+ unknownKeys: "passthrough"
31110
+ });
31111
+ }
31112
+ // const AugmentFactory =
31113
+ // <Def extends ZodObjectDef>(def: Def) =>
31114
+ // <Augmentation extends ZodRawShape>(
31115
+ // augmentation: Augmentation
31116
+ // ): ZodObject<
31117
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
31118
+ // Def["unknownKeys"],
31119
+ // Def["catchall"]
31120
+ // > => {
31121
+ // return new ZodObject({
31122
+ // ...def,
31123
+ // shape: () => ({
31124
+ // ...def.shape(),
31125
+ // ...augmentation,
31126
+ // }),
31127
+ // }) as any;
31128
+ // };
31129
+ extend(augmentation) {
31130
+ return new _ZodObject({
31131
+ ...this._def,
31132
+ shape: /* @__PURE__ */ __name(() => ({
31133
+ ...this._def.shape(),
31134
+ ...augmentation
31135
+ }), "shape")
31136
+ });
31137
+ }
31138
+ /**
31139
+ * Prior to zod@1.0.12 there was a bug in the
31140
+ * inferred type of merged objects. Please
31141
+ * upgrade if you are experiencing issues.
31142
+ */
31143
+ merge(merging) {
31144
+ const merged = new _ZodObject({
31145
+ unknownKeys: merging._def.unknownKeys,
31146
+ catchall: merging._def.catchall,
31147
+ shape: /* @__PURE__ */ __name(() => ({
31148
+ ...this._def.shape(),
31149
+ ...merging._def.shape()
31150
+ }), "shape"),
31151
+ typeName: ZodFirstPartyTypeKind.ZodObject
31152
+ });
31153
+ return merged;
31154
+ }
31155
+ // merge<
31156
+ // Incoming extends AnyZodObject,
31157
+ // Augmentation extends Incoming["shape"],
31158
+ // NewOutput extends {
31159
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
31160
+ // ? Augmentation[k]["_output"]
31161
+ // : k extends keyof Output
31162
+ // ? Output[k]
31163
+ // : never;
31164
+ // },
31165
+ // NewInput extends {
31166
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
31167
+ // ? Augmentation[k]["_input"]
31168
+ // : k extends keyof Input
31169
+ // ? Input[k]
31170
+ // : never;
31171
+ // }
31172
+ // >(
31173
+ // merging: Incoming
31174
+ // ): ZodObject<
31175
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
31176
+ // Incoming["_def"]["unknownKeys"],
31177
+ // Incoming["_def"]["catchall"],
31178
+ // NewOutput,
31179
+ // NewInput
31180
+ // > {
31181
+ // const merged: any = new ZodObject({
31182
+ // unknownKeys: merging._def.unknownKeys,
31183
+ // catchall: merging._def.catchall,
31184
+ // shape: () =>
31185
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
31186
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
31187
+ // }) as any;
31188
+ // return merged;
31189
+ // }
31190
+ setKey(key, schema) {
31191
+ return this.augment({
31192
+ [key]: schema
31193
+ });
31194
+ }
31195
+ // merge<Incoming extends AnyZodObject>(
31196
+ // merging: Incoming
31197
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
31198
+ // ZodObject<
31199
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
31200
+ // Incoming["_def"]["unknownKeys"],
31201
+ // Incoming["_def"]["catchall"]
31202
+ // > {
31203
+ // // const mergedShape = objectUtil.mergeShapes(
31204
+ // // this._def.shape(),
31205
+ // // merging._def.shape()
31206
+ // // );
31207
+ // const merged: any = new ZodObject({
31208
+ // unknownKeys: merging._def.unknownKeys,
31209
+ // catchall: merging._def.catchall,
31210
+ // shape: () =>
31211
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
31212
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
31213
+ // }) as any;
31214
+ // return merged;
31215
+ // }
31216
+ catchall(index) {
31217
+ return new _ZodObject({
31218
+ ...this._def,
31219
+ catchall: index
31220
+ });
31221
+ }
31222
+ pick(mask) {
31223
+ const shape = {};
31224
+ for (const key of util.objectKeys(mask)) {
31225
+ if (mask[key] && this.shape[key]) {
31226
+ shape[key] = this.shape[key];
31227
+ }
31228
+ }
31229
+ return new _ZodObject({
31230
+ ...this._def,
31231
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
31232
+ });
31233
+ }
31234
+ omit(mask) {
31235
+ const shape = {};
31236
+ for (const key of util.objectKeys(this.shape)) {
31237
+ if (!mask[key]) {
31238
+ shape[key] = this.shape[key];
31239
+ }
31240
+ }
31241
+ return new _ZodObject({
31242
+ ...this._def,
31243
+ shape: /* @__PURE__ */ __name(() => shape, "shape")
31244
+ });
31245
+ }
31246
+ /**
31247
+ * @deprecated
31248
+ */
31249
+ deepPartial() {
31250
+ return deepPartialify(this);
31251
+ }
31252
+ partial(mask) {
31253
+ const newShape = {};
31254
+ for (const key of util.objectKeys(this.shape)) {
31255
+ const fieldSchema = this.shape[key];
31256
+ if (mask && !mask[key]) {
31257
+ newShape[key] = fieldSchema;
31258
+ } else {
31259
+ newShape[key] = fieldSchema.optional();
31260
+ }
31261
+ }
31262
+ return new _ZodObject({
31263
+ ...this._def,
31264
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
31265
+ });
31266
+ }
31267
+ required(mask) {
31268
+ const newShape = {};
31269
+ for (const key of util.objectKeys(this.shape)) {
31270
+ if (mask && !mask[key]) {
31271
+ newShape[key] = this.shape[key];
31272
+ } else {
31273
+ const fieldSchema = this.shape[key];
31274
+ let newField = fieldSchema;
31275
+ while (newField instanceof ZodOptional) {
31276
+ newField = newField._def.innerType;
31277
+ }
31278
+ newShape[key] = newField;
31279
+ }
31280
+ }
31281
+ return new _ZodObject({
31282
+ ...this._def,
31283
+ shape: /* @__PURE__ */ __name(() => newShape, "shape")
31284
+ });
31285
+ }
31286
+ keyof() {
31287
+ return createZodEnum(util.objectKeys(this.shape));
31288
+ }
31289
+ };
31290
+ ZodObject.create = (shape, params) => {
31291
+ return new ZodObject({
31292
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
31293
+ unknownKeys: "strip",
31294
+ catchall: ZodNever.create(),
31295
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31296
+ ...processCreateParams(params)
31297
+ });
31298
+ };
31299
+ ZodObject.strictCreate = (shape, params) => {
31300
+ return new ZodObject({
31301
+ shape: /* @__PURE__ */ __name(() => shape, "shape"),
31302
+ unknownKeys: "strict",
31303
+ catchall: ZodNever.create(),
31304
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31305
+ ...processCreateParams(params)
31306
+ });
31307
+ };
31308
+ ZodObject.lazycreate = (shape, params) => {
31309
+ return new ZodObject({
31310
+ shape,
31311
+ unknownKeys: "strip",
31312
+ catchall: ZodNever.create(),
31313
+ typeName: ZodFirstPartyTypeKind.ZodObject,
31314
+ ...processCreateParams(params)
31315
+ });
31316
+ };
31317
+ var ZodUnion = class extends ZodType {
31318
+ static {
31319
+ __name(this, "ZodUnion");
31320
+ }
31321
+ _parse(input) {
31322
+ const { ctx } = this._processInputParams(input);
31323
+ const options = this._def.options;
31324
+ function handleResults(results) {
31325
+ for (const result of results) {
31326
+ if (result.result.status === "valid") {
31327
+ return result.result;
31328
+ }
31329
+ }
31330
+ for (const result of results) {
31331
+ if (result.result.status === "dirty") {
31332
+ ctx.common.issues.push(...result.ctx.common.issues);
31333
+ return result.result;
31334
+ }
31335
+ }
31336
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
31337
+ addIssueToContext(ctx, {
31338
+ code: ZodIssueCode.invalid_union,
31339
+ unionErrors
31340
+ });
31341
+ return INVALID;
31342
+ }
31343
+ __name(handleResults, "handleResults");
31344
+ if (ctx.common.async) {
31345
+ return Promise.all(options.map(async (option) => {
31346
+ const childCtx = {
31347
+ ...ctx,
31348
+ common: {
31349
+ ...ctx.common,
31350
+ issues: []
31351
+ },
31352
+ parent: null
31353
+ };
31354
+ return {
31355
+ result: await option._parseAsync({
31356
+ data: ctx.data,
31357
+ path: ctx.path,
31358
+ parent: childCtx
31359
+ }),
31360
+ ctx: childCtx
31361
+ };
31362
+ })).then(handleResults);
31363
+ } else {
31364
+ let dirty = void 0;
31365
+ const issues = [];
31366
+ for (const option of options) {
31367
+ const childCtx = {
31368
+ ...ctx,
31369
+ common: {
31370
+ ...ctx.common,
31371
+ issues: []
31372
+ },
31373
+ parent: null
31374
+ };
31375
+ const result = option._parseSync({
31376
+ data: ctx.data,
31377
+ path: ctx.path,
31378
+ parent: childCtx
31379
+ });
31380
+ if (result.status === "valid") {
31381
+ return result;
31382
+ } else if (result.status === "dirty" && !dirty) {
31383
+ dirty = {
31384
+ result,
31385
+ ctx: childCtx
31386
+ };
31387
+ }
31388
+ if (childCtx.common.issues.length) {
31389
+ issues.push(childCtx.common.issues);
31390
+ }
31391
+ }
31392
+ if (dirty) {
31393
+ ctx.common.issues.push(...dirty.ctx.common.issues);
31394
+ return dirty.result;
31395
+ }
31396
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
31397
+ addIssueToContext(ctx, {
31398
+ code: ZodIssueCode.invalid_union,
31399
+ unionErrors
31400
+ });
31401
+ return INVALID;
31402
+ }
31403
+ }
31404
+ get options() {
31405
+ return this._def.options;
31406
+ }
31407
+ };
31408
+ ZodUnion.create = (types, params) => {
31409
+ return new ZodUnion({
31410
+ options: types,
31411
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
31412
+ ...processCreateParams(params)
31413
+ });
31414
+ };
31415
+ var getDiscriminator = /* @__PURE__ */ __name((type) => {
31416
+ if (type instanceof ZodLazy) {
31417
+ return getDiscriminator(type.schema);
31418
+ } else if (type instanceof ZodEffects) {
31419
+ return getDiscriminator(type.innerType());
31420
+ } else if (type instanceof ZodLiteral) {
31421
+ return [
31422
+ type.value
31423
+ ];
31424
+ } else if (type instanceof ZodEnum) {
31425
+ return type.options;
31426
+ } else if (type instanceof ZodNativeEnum) {
31427
+ return util.objectValues(type.enum);
31428
+ } else if (type instanceof ZodDefault) {
31429
+ return getDiscriminator(type._def.innerType);
31430
+ } else if (type instanceof ZodUndefined) {
31431
+ return [
31432
+ void 0
31433
+ ];
31434
+ } else if (type instanceof ZodNull) {
31435
+ return [
31436
+ null
31437
+ ];
31438
+ } else if (type instanceof ZodOptional) {
31439
+ return [
31440
+ void 0,
31441
+ ...getDiscriminator(type.unwrap())
31442
+ ];
31443
+ } else if (type instanceof ZodNullable) {
31444
+ return [
31445
+ null,
31446
+ ...getDiscriminator(type.unwrap())
31447
+ ];
31448
+ } else if (type instanceof ZodBranded) {
31449
+ return getDiscriminator(type.unwrap());
31450
+ } else if (type instanceof ZodReadonly) {
31451
+ return getDiscriminator(type.unwrap());
31452
+ } else if (type instanceof ZodCatch) {
31453
+ return getDiscriminator(type._def.innerType);
31454
+ } else {
31455
+ return [];
31456
+ }
31457
+ }, "getDiscriminator");
31458
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
31459
+ static {
31460
+ __name(this, "ZodDiscriminatedUnion");
31461
+ }
31462
+ _parse(input) {
31463
+ const { ctx } = this._processInputParams(input);
31464
+ if (ctx.parsedType !== ZodParsedType.object) {
31465
+ addIssueToContext(ctx, {
31466
+ code: ZodIssueCode.invalid_type,
31467
+ expected: ZodParsedType.object,
31468
+ received: ctx.parsedType
31469
+ });
31470
+ return INVALID;
31471
+ }
31472
+ const discriminator = this.discriminator;
31473
+ const discriminatorValue = ctx.data[discriminator];
31474
+ const option = this.optionsMap.get(discriminatorValue);
31475
+ if (!option) {
31476
+ addIssueToContext(ctx, {
31477
+ code: ZodIssueCode.invalid_union_discriminator,
31478
+ options: Array.from(this.optionsMap.keys()),
31479
+ path: [
31480
+ discriminator
31481
+ ]
31482
+ });
31483
+ return INVALID;
31484
+ }
31485
+ if (ctx.common.async) {
31486
+ return option._parseAsync({
31487
+ data: ctx.data,
31488
+ path: ctx.path,
31489
+ parent: ctx
31490
+ });
31491
+ } else {
31492
+ return option._parseSync({
31493
+ data: ctx.data,
31494
+ path: ctx.path,
31495
+ parent: ctx
31496
+ });
31497
+ }
31498
+ }
31499
+ get discriminator() {
31500
+ return this._def.discriminator;
31501
+ }
31502
+ get options() {
31503
+ return this._def.options;
31504
+ }
31505
+ get optionsMap() {
31506
+ return this._def.optionsMap;
31507
+ }
31508
+ /**
31509
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
31510
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
31511
+ * have a different value for each object in the union.
31512
+ * @param discriminator the name of the discriminator property
31513
+ * @param types an array of object schemas
31514
+ * @param params
31515
+ */
31516
+ static create(discriminator, options, params) {
31517
+ const optionsMap = /* @__PURE__ */ new Map();
31518
+ for (const type of options) {
31519
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
31520
+ if (!discriminatorValues.length) {
31521
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
31522
+ }
31523
+ for (const value of discriminatorValues) {
31524
+ if (optionsMap.has(value)) {
31525
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
31526
+ }
31527
+ optionsMap.set(value, type);
31528
+ }
31529
+ }
31530
+ return new _ZodDiscriminatedUnion({
31531
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
31532
+ discriminator,
31533
+ options,
31534
+ optionsMap,
31535
+ ...processCreateParams(params)
31536
+ });
31537
+ }
31538
+ };
31539
+ function mergeValues(a6, b6) {
31540
+ const aType = getParsedType(a6);
31541
+ const bType = getParsedType(b6);
31542
+ if (a6 === b6) {
31543
+ return {
31544
+ valid: true,
31545
+ data: a6
31546
+ };
31547
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
31548
+ const bKeys = util.objectKeys(b6);
31549
+ const sharedKeys = util.objectKeys(a6).filter((key) => bKeys.indexOf(key) !== -1);
31550
+ const newObj = {
31551
+ ...a6,
31552
+ ...b6
31553
+ };
31554
+ for (const key of sharedKeys) {
31555
+ const sharedValue = mergeValues(a6[key], b6[key]);
31556
+ if (!sharedValue.valid) {
31557
+ return {
31558
+ valid: false
31559
+ };
31560
+ }
31561
+ newObj[key] = sharedValue.data;
31562
+ }
31563
+ return {
31564
+ valid: true,
31565
+ data: newObj
31566
+ };
31567
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
31568
+ if (a6.length !== b6.length) {
31569
+ return {
31570
+ valid: false
31571
+ };
31572
+ }
31573
+ const newArray = [];
31574
+ for (let index = 0; index < a6.length; index++) {
31575
+ const itemA = a6[index];
31576
+ const itemB = b6[index];
31577
+ const sharedValue = mergeValues(itemA, itemB);
31578
+ if (!sharedValue.valid) {
31579
+ return {
31580
+ valid: false
31581
+ };
31582
+ }
31583
+ newArray.push(sharedValue.data);
31584
+ }
31585
+ return {
31586
+ valid: true,
31587
+ data: newArray
31588
+ };
31589
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a6 === +b6) {
31590
+ return {
31591
+ valid: true,
31592
+ data: a6
31593
+ };
31594
+ } else {
31595
+ return {
31596
+ valid: false
31597
+ };
31598
+ }
31599
+ }
31600
+ __name(mergeValues, "mergeValues");
31601
+ var ZodIntersection = class extends ZodType {
31602
+ static {
31603
+ __name(this, "ZodIntersection");
31604
+ }
31605
+ _parse(input) {
31606
+ const { status, ctx } = this._processInputParams(input);
31607
+ const handleParsed = /* @__PURE__ */ __name((parsedLeft, parsedRight) => {
31608
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
31609
+ return INVALID;
31610
+ }
31611
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
31612
+ if (!merged.valid) {
31613
+ addIssueToContext(ctx, {
31614
+ code: ZodIssueCode.invalid_intersection_types
31615
+ });
31616
+ return INVALID;
31617
+ }
31618
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
31619
+ status.dirty();
31620
+ }
31621
+ return {
31622
+ status: status.value,
31623
+ value: merged.data
31624
+ };
31625
+ }, "handleParsed");
31626
+ if (ctx.common.async) {
31627
+ return Promise.all([
31628
+ this._def.left._parseAsync({
31629
+ data: ctx.data,
31630
+ path: ctx.path,
31631
+ parent: ctx
31632
+ }),
31633
+ this._def.right._parseAsync({
31634
+ data: ctx.data,
31635
+ path: ctx.path,
31636
+ parent: ctx
31637
+ })
31638
+ ]).then(([left, right]) => handleParsed(left, right));
31639
+ } else {
31640
+ return handleParsed(this._def.left._parseSync({
31641
+ data: ctx.data,
31642
+ path: ctx.path,
31643
+ parent: ctx
31644
+ }), this._def.right._parseSync({
31645
+ data: ctx.data,
31646
+ path: ctx.path,
31647
+ parent: ctx
31648
+ }));
31649
+ }
31650
+ }
31651
+ };
31652
+ ZodIntersection.create = (left, right, params) => {
31653
+ return new ZodIntersection({
31654
+ left,
31655
+ right,
31656
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
31657
+ ...processCreateParams(params)
31658
+ });
31659
+ };
31660
+ var ZodTuple = class _ZodTuple extends ZodType {
31661
+ static {
31662
+ __name(this, "ZodTuple");
31663
+ }
31664
+ _parse(input) {
31665
+ const { status, ctx } = this._processInputParams(input);
31666
+ if (ctx.parsedType !== ZodParsedType.array) {
31667
+ addIssueToContext(ctx, {
31668
+ code: ZodIssueCode.invalid_type,
31669
+ expected: ZodParsedType.array,
31670
+ received: ctx.parsedType
31671
+ });
31672
+ return INVALID;
31673
+ }
31674
+ if (ctx.data.length < this._def.items.length) {
31675
+ addIssueToContext(ctx, {
31676
+ code: ZodIssueCode.too_small,
31677
+ minimum: this._def.items.length,
31678
+ inclusive: true,
31679
+ exact: false,
31680
+ type: "array"
31681
+ });
31682
+ return INVALID;
31683
+ }
31684
+ const rest = this._def.rest;
31685
+ if (!rest && ctx.data.length > this._def.items.length) {
31686
+ addIssueToContext(ctx, {
31687
+ code: ZodIssueCode.too_big,
31688
+ maximum: this._def.items.length,
31689
+ inclusive: true,
31690
+ exact: false,
31691
+ type: "array"
31692
+ });
31693
+ status.dirty();
31694
+ }
31695
+ const items = [
31696
+ ...ctx.data
31697
+ ].map((item, itemIndex) => {
31698
+ const schema = this._def.items[itemIndex] || this._def.rest;
31699
+ if (!schema) return null;
31700
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
31701
+ }).filter((x2) => !!x2);
31702
+ if (ctx.common.async) {
31703
+ return Promise.all(items).then((results) => {
31704
+ return ParseStatus.mergeArray(status, results);
31705
+ });
31706
+ } else {
31707
+ return ParseStatus.mergeArray(status, items);
31708
+ }
31709
+ }
31710
+ get items() {
31711
+ return this._def.items;
31712
+ }
31713
+ rest(rest) {
31714
+ return new _ZodTuple({
31715
+ ...this._def,
31716
+ rest
31717
+ });
31718
+ }
31719
+ };
31720
+ ZodTuple.create = (schemas, params) => {
31721
+ if (!Array.isArray(schemas)) {
31722
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
31723
+ }
31724
+ return new ZodTuple({
31725
+ items: schemas,
31726
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
31727
+ rest: null,
31728
+ ...processCreateParams(params)
31729
+ });
31730
+ };
31731
+ var ZodRecord = class _ZodRecord extends ZodType {
31732
+ static {
31733
+ __name(this, "ZodRecord");
31734
+ }
31735
+ get keySchema() {
31736
+ return this._def.keyType;
31737
+ }
31738
+ get valueSchema() {
31739
+ return this._def.valueType;
31740
+ }
31741
+ _parse(input) {
31742
+ const { status, ctx } = this._processInputParams(input);
31743
+ if (ctx.parsedType !== ZodParsedType.object) {
31744
+ addIssueToContext(ctx, {
31745
+ code: ZodIssueCode.invalid_type,
31746
+ expected: ZodParsedType.object,
31747
+ received: ctx.parsedType
31748
+ });
31749
+ return INVALID;
31750
+ }
31751
+ const pairs = [];
31752
+ const keyType = this._def.keyType;
31753
+ const valueType = this._def.valueType;
31754
+ for (const key in ctx.data) {
31755
+ pairs.push({
31756
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
31757
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
31758
+ alwaysSet: key in ctx.data
31759
+ });
31760
+ }
31761
+ if (ctx.common.async) {
31762
+ return ParseStatus.mergeObjectAsync(status, pairs);
31763
+ } else {
31764
+ return ParseStatus.mergeObjectSync(status, pairs);
31765
+ }
31766
+ }
31767
+ get element() {
31768
+ return this._def.valueType;
31769
+ }
31770
+ static create(first, second, third) {
31771
+ if (second instanceof ZodType) {
31772
+ return new _ZodRecord({
31773
+ keyType: first,
31774
+ valueType: second,
31775
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
31776
+ ...processCreateParams(third)
31777
+ });
31778
+ }
31779
+ return new _ZodRecord({
31780
+ keyType: ZodString.create(),
31781
+ valueType: first,
31782
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
31783
+ ...processCreateParams(second)
31784
+ });
31785
+ }
31786
+ };
31787
+ var ZodMap = class extends ZodType {
31788
+ static {
31789
+ __name(this, "ZodMap");
31790
+ }
31791
+ get keySchema() {
31792
+ return this._def.keyType;
31793
+ }
31794
+ get valueSchema() {
31795
+ return this._def.valueType;
31796
+ }
31797
+ _parse(input) {
31798
+ const { status, ctx } = this._processInputParams(input);
31799
+ if (ctx.parsedType !== ZodParsedType.map) {
31800
+ addIssueToContext(ctx, {
31801
+ code: ZodIssueCode.invalid_type,
31802
+ expected: ZodParsedType.map,
31803
+ received: ctx.parsedType
31804
+ });
31805
+ return INVALID;
31806
+ }
31807
+ const keyType = this._def.keyType;
31808
+ const valueType = this._def.valueType;
31809
+ const pairs = [
31810
+ ...ctx.data.entries()
31811
+ ].map(([key, value], index) => {
31812
+ return {
31813
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
31814
+ index,
31815
+ "key"
31816
+ ])),
31817
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
31818
+ index,
31819
+ "value"
31820
+ ]))
31821
+ };
31822
+ });
31823
+ if (ctx.common.async) {
31824
+ const finalMap = /* @__PURE__ */ new Map();
31825
+ return Promise.resolve().then(async () => {
31826
+ for (const pair of pairs) {
31827
+ const key = await pair.key;
31828
+ const value = await pair.value;
31829
+ if (key.status === "aborted" || value.status === "aborted") {
31830
+ return INVALID;
31831
+ }
31832
+ if (key.status === "dirty" || value.status === "dirty") {
31833
+ status.dirty();
31834
+ }
31835
+ finalMap.set(key.value, value.value);
31836
+ }
31837
+ return {
31838
+ status: status.value,
31839
+ value: finalMap
31840
+ };
31841
+ });
31842
+ } else {
31843
+ const finalMap = /* @__PURE__ */ new Map();
31844
+ for (const pair of pairs) {
31845
+ const key = pair.key;
31846
+ const value = pair.value;
31847
+ if (key.status === "aborted" || value.status === "aborted") {
31848
+ return INVALID;
31849
+ }
31850
+ if (key.status === "dirty" || value.status === "dirty") {
31851
+ status.dirty();
31852
+ }
31853
+ finalMap.set(key.value, value.value);
31854
+ }
31855
+ return {
31856
+ status: status.value,
31857
+ value: finalMap
31858
+ };
31859
+ }
31860
+ }
31861
+ };
31862
+ ZodMap.create = (keyType, valueType, params) => {
31863
+ return new ZodMap({
31864
+ valueType,
31865
+ keyType,
31866
+ typeName: ZodFirstPartyTypeKind.ZodMap,
31867
+ ...processCreateParams(params)
31868
+ });
31869
+ };
31870
+ var ZodSet = class _ZodSet extends ZodType {
31871
+ static {
31872
+ __name(this, "ZodSet");
31873
+ }
31874
+ _parse(input) {
31875
+ const { status, ctx } = this._processInputParams(input);
31876
+ if (ctx.parsedType !== ZodParsedType.set) {
31877
+ addIssueToContext(ctx, {
31878
+ code: ZodIssueCode.invalid_type,
31879
+ expected: ZodParsedType.set,
31880
+ received: ctx.parsedType
31881
+ });
31882
+ return INVALID;
31883
+ }
31884
+ const def = this._def;
31885
+ if (def.minSize !== null) {
31886
+ if (ctx.data.size < def.minSize.value) {
31887
+ addIssueToContext(ctx, {
31888
+ code: ZodIssueCode.too_small,
31889
+ minimum: def.minSize.value,
31890
+ type: "set",
31891
+ inclusive: true,
31892
+ exact: false,
31893
+ message: def.minSize.message
31894
+ });
31895
+ status.dirty();
31896
+ }
31897
+ }
31898
+ if (def.maxSize !== null) {
31899
+ if (ctx.data.size > def.maxSize.value) {
31900
+ addIssueToContext(ctx, {
31901
+ code: ZodIssueCode.too_big,
31902
+ maximum: def.maxSize.value,
31903
+ type: "set",
31904
+ inclusive: true,
31905
+ exact: false,
31906
+ message: def.maxSize.message
31907
+ });
31908
+ status.dirty();
31909
+ }
31910
+ }
31911
+ const valueType = this._def.valueType;
31912
+ function finalizeSet(elements2) {
31913
+ const parsedSet = /* @__PURE__ */ new Set();
31914
+ for (const element of elements2) {
31915
+ if (element.status === "aborted") return INVALID;
31916
+ if (element.status === "dirty") status.dirty();
31917
+ parsedSet.add(element.value);
31918
+ }
31919
+ return {
31920
+ status: status.value,
31921
+ value: parsedSet
31922
+ };
31923
+ }
31924
+ __name(finalizeSet, "finalizeSet");
31925
+ const elements = [
31926
+ ...ctx.data.values()
31927
+ ].map((item, i6) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i6)));
31928
+ if (ctx.common.async) {
31929
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
31930
+ } else {
31931
+ return finalizeSet(elements);
31932
+ }
31933
+ }
31934
+ min(minSize, message) {
31935
+ return new _ZodSet({
31936
+ ...this._def,
31937
+ minSize: {
31938
+ value: minSize,
31939
+ message: errorUtil.toString(message)
31940
+ }
31941
+ });
31942
+ }
31943
+ max(maxSize, message) {
31944
+ return new _ZodSet({
31945
+ ...this._def,
31946
+ maxSize: {
31947
+ value: maxSize,
31948
+ message: errorUtil.toString(message)
31949
+ }
31950
+ });
31951
+ }
31952
+ size(size, message) {
31953
+ return this.min(size, message).max(size, message);
31954
+ }
31955
+ nonempty(message) {
31956
+ return this.min(1, message);
31957
+ }
31958
+ };
31959
+ ZodSet.create = (valueType, params) => {
31960
+ return new ZodSet({
31961
+ valueType,
31962
+ minSize: null,
31963
+ maxSize: null,
31964
+ typeName: ZodFirstPartyTypeKind.ZodSet,
31965
+ ...processCreateParams(params)
31966
+ });
31967
+ };
31968
+ var ZodFunction = class _ZodFunction extends ZodType {
31969
+ static {
31970
+ __name(this, "ZodFunction");
31971
+ }
31972
+ constructor() {
31973
+ super(...arguments);
31974
+ this.validate = this.implement;
31975
+ }
31976
+ _parse(input) {
31977
+ const { ctx } = this._processInputParams(input);
31978
+ if (ctx.parsedType !== ZodParsedType.function) {
31979
+ addIssueToContext(ctx, {
31980
+ code: ZodIssueCode.invalid_type,
31981
+ expected: ZodParsedType.function,
31982
+ received: ctx.parsedType
31983
+ });
31984
+ return INVALID;
31985
+ }
31986
+ function makeArgsIssue(args, error) {
31987
+ return makeIssue({
31988
+ data: args,
31989
+ path: ctx.path,
31990
+ errorMaps: [
31991
+ ctx.common.contextualErrorMap,
31992
+ ctx.schemaErrorMap,
31993
+ getErrorMap(),
31994
+ en_default
31995
+ ].filter((x2) => !!x2),
31996
+ issueData: {
31997
+ code: ZodIssueCode.invalid_arguments,
31998
+ argumentsError: error
31999
+ }
32000
+ });
32001
+ }
32002
+ __name(makeArgsIssue, "makeArgsIssue");
32003
+ function makeReturnsIssue(returns, error) {
32004
+ return makeIssue({
32005
+ data: returns,
32006
+ path: ctx.path,
32007
+ errorMaps: [
32008
+ ctx.common.contextualErrorMap,
32009
+ ctx.schemaErrorMap,
32010
+ getErrorMap(),
32011
+ en_default
32012
+ ].filter((x2) => !!x2),
32013
+ issueData: {
32014
+ code: ZodIssueCode.invalid_return_type,
32015
+ returnTypeError: error
32016
+ }
32017
+ });
32018
+ }
32019
+ __name(makeReturnsIssue, "makeReturnsIssue");
32020
+ const params = {
32021
+ errorMap: ctx.common.contextualErrorMap
32022
+ };
32023
+ const fn = ctx.data;
32024
+ if (this._def.returns instanceof ZodPromise) {
32025
+ const me = this;
32026
+ return OK(async function(...args) {
32027
+ const error = new ZodError([]);
32028
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e6) => {
32029
+ error.addIssue(makeArgsIssue(args, e6));
32030
+ throw error;
32031
+ });
32032
+ const result = await Reflect.apply(fn, this, parsedArgs);
32033
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e6) => {
32034
+ error.addIssue(makeReturnsIssue(result, e6));
32035
+ throw error;
32036
+ });
32037
+ return parsedReturns;
32038
+ });
32039
+ } else {
32040
+ const me = this;
32041
+ return OK(function(...args) {
32042
+ const parsedArgs = me._def.args.safeParse(args, params);
32043
+ if (!parsedArgs.success) {
32044
+ throw new ZodError([
32045
+ makeArgsIssue(args, parsedArgs.error)
32046
+ ]);
32047
+ }
32048
+ const result = Reflect.apply(fn, this, parsedArgs.data);
32049
+ const parsedReturns = me._def.returns.safeParse(result, params);
32050
+ if (!parsedReturns.success) {
32051
+ throw new ZodError([
32052
+ makeReturnsIssue(result, parsedReturns.error)
32053
+ ]);
32054
+ }
32055
+ return parsedReturns.data;
32056
+ });
32057
+ }
32058
+ }
32059
+ parameters() {
32060
+ return this._def.args;
32061
+ }
32062
+ returnType() {
32063
+ return this._def.returns;
32064
+ }
32065
+ args(...items) {
32066
+ return new _ZodFunction({
32067
+ ...this._def,
32068
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
32069
+ });
32070
+ }
32071
+ returns(returnType) {
32072
+ return new _ZodFunction({
32073
+ ...this._def,
32074
+ returns: returnType
32075
+ });
32076
+ }
32077
+ implement(func) {
32078
+ const validatedFunc = this.parse(func);
32079
+ return validatedFunc;
32080
+ }
32081
+ strictImplement(func) {
32082
+ const validatedFunc = this.parse(func);
32083
+ return validatedFunc;
32084
+ }
32085
+ static create(args, returns, params) {
32086
+ return new _ZodFunction({
32087
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
32088
+ returns: returns || ZodUnknown.create(),
32089
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
32090
+ ...processCreateParams(params)
32091
+ });
32092
+ }
32093
+ };
32094
+ var ZodLazy = class extends ZodType {
32095
+ static {
32096
+ __name(this, "ZodLazy");
32097
+ }
32098
+ get schema() {
32099
+ return this._def.getter();
32100
+ }
32101
+ _parse(input) {
32102
+ const { ctx } = this._processInputParams(input);
32103
+ const lazySchema = this._def.getter();
32104
+ return lazySchema._parse({
32105
+ data: ctx.data,
32106
+ path: ctx.path,
32107
+ parent: ctx
32108
+ });
32109
+ }
32110
+ };
32111
+ ZodLazy.create = (getter, params) => {
32112
+ return new ZodLazy({
32113
+ getter,
32114
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
32115
+ ...processCreateParams(params)
32116
+ });
32117
+ };
32118
+ var ZodLiteral = class extends ZodType {
32119
+ static {
32120
+ __name(this, "ZodLiteral");
32121
+ }
32122
+ _parse(input) {
32123
+ if (input.data !== this._def.value) {
32124
+ const ctx = this._getOrReturnCtx(input);
32125
+ addIssueToContext(ctx, {
32126
+ received: ctx.data,
32127
+ code: ZodIssueCode.invalid_literal,
32128
+ expected: this._def.value
32129
+ });
32130
+ return INVALID;
32131
+ }
32132
+ return {
32133
+ status: "valid",
32134
+ value: input.data
32135
+ };
32136
+ }
32137
+ get value() {
32138
+ return this._def.value;
32139
+ }
32140
+ };
32141
+ ZodLiteral.create = (value, params) => {
32142
+ return new ZodLiteral({
32143
+ value,
32144
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
32145
+ ...processCreateParams(params)
32146
+ });
32147
+ };
32148
+ function createZodEnum(values, params) {
32149
+ return new ZodEnum({
32150
+ values,
32151
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
32152
+ ...processCreateParams(params)
32153
+ });
32154
+ }
32155
+ __name(createZodEnum, "createZodEnum");
32156
+ var ZodEnum = class _ZodEnum extends ZodType {
32157
+ static {
32158
+ __name(this, "ZodEnum");
32159
+ }
32160
+ _parse(input) {
32161
+ if (typeof input.data !== "string") {
32162
+ const ctx = this._getOrReturnCtx(input);
32163
+ const expectedValues = this._def.values;
32164
+ addIssueToContext(ctx, {
32165
+ expected: util.joinValues(expectedValues),
32166
+ received: ctx.parsedType,
32167
+ code: ZodIssueCode.invalid_type
32168
+ });
32169
+ return INVALID;
32170
+ }
32171
+ if (!this._cache) {
32172
+ this._cache = new Set(this._def.values);
32173
+ }
32174
+ if (!this._cache.has(input.data)) {
32175
+ const ctx = this._getOrReturnCtx(input);
32176
+ const expectedValues = this._def.values;
32177
+ addIssueToContext(ctx, {
32178
+ received: ctx.data,
32179
+ code: ZodIssueCode.invalid_enum_value,
32180
+ options: expectedValues
32181
+ });
32182
+ return INVALID;
32183
+ }
32184
+ return OK(input.data);
32185
+ }
32186
+ get options() {
32187
+ return this._def.values;
32188
+ }
32189
+ get enum() {
32190
+ const enumValues = {};
32191
+ for (const val of this._def.values) {
32192
+ enumValues[val] = val;
32193
+ }
32194
+ return enumValues;
32195
+ }
32196
+ get Values() {
32197
+ const enumValues = {};
32198
+ for (const val of this._def.values) {
32199
+ enumValues[val] = val;
32200
+ }
32201
+ return enumValues;
32202
+ }
32203
+ get Enum() {
32204
+ const enumValues = {};
32205
+ for (const val of this._def.values) {
32206
+ enumValues[val] = val;
32207
+ }
32208
+ return enumValues;
32209
+ }
32210
+ extract(values, newDef = this._def) {
32211
+ return _ZodEnum.create(values, {
32212
+ ...this._def,
32213
+ ...newDef
32214
+ });
32215
+ }
32216
+ exclude(values, newDef = this._def) {
32217
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
32218
+ ...this._def,
32219
+ ...newDef
32220
+ });
32221
+ }
32222
+ };
32223
+ ZodEnum.create = createZodEnum;
32224
+ var ZodNativeEnum = class extends ZodType {
32225
+ static {
32226
+ __name(this, "ZodNativeEnum");
32227
+ }
32228
+ _parse(input) {
32229
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
32230
+ const ctx = this._getOrReturnCtx(input);
32231
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
32232
+ const expectedValues = util.objectValues(nativeEnumValues);
32233
+ addIssueToContext(ctx, {
32234
+ expected: util.joinValues(expectedValues),
32235
+ received: ctx.parsedType,
32236
+ code: ZodIssueCode.invalid_type
32237
+ });
32238
+ return INVALID;
32239
+ }
32240
+ if (!this._cache) {
32241
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
32242
+ }
32243
+ if (!this._cache.has(input.data)) {
32244
+ const expectedValues = util.objectValues(nativeEnumValues);
32245
+ addIssueToContext(ctx, {
32246
+ received: ctx.data,
32247
+ code: ZodIssueCode.invalid_enum_value,
32248
+ options: expectedValues
32249
+ });
32250
+ return INVALID;
32251
+ }
32252
+ return OK(input.data);
32253
+ }
32254
+ get enum() {
32255
+ return this._def.values;
32256
+ }
32257
+ };
32258
+ ZodNativeEnum.create = (values, params) => {
32259
+ return new ZodNativeEnum({
32260
+ values,
32261
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
32262
+ ...processCreateParams(params)
32263
+ });
32264
+ };
32265
+ var ZodPromise = class extends ZodType {
32266
+ static {
32267
+ __name(this, "ZodPromise");
32268
+ }
32269
+ unwrap() {
32270
+ return this._def.type;
32271
+ }
32272
+ _parse(input) {
32273
+ const { ctx } = this._processInputParams(input);
32274
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
32275
+ addIssueToContext(ctx, {
32276
+ code: ZodIssueCode.invalid_type,
32277
+ expected: ZodParsedType.promise,
32278
+ received: ctx.parsedType
32279
+ });
32280
+ return INVALID;
32281
+ }
32282
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
32283
+ return OK(promisified.then((data) => {
32284
+ return this._def.type.parseAsync(data, {
32285
+ path: ctx.path,
32286
+ errorMap: ctx.common.contextualErrorMap
32287
+ });
32288
+ }));
32289
+ }
32290
+ };
32291
+ ZodPromise.create = (schema, params) => {
32292
+ return new ZodPromise({
32293
+ type: schema,
32294
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
32295
+ ...processCreateParams(params)
32296
+ });
32297
+ };
32298
+ var ZodEffects = class extends ZodType {
32299
+ static {
32300
+ __name(this, "ZodEffects");
32301
+ }
32302
+ innerType() {
32303
+ return this._def.schema;
32304
+ }
32305
+ sourceType() {
32306
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
32307
+ }
32308
+ _parse(input) {
32309
+ const { status, ctx } = this._processInputParams(input);
32310
+ const effect = this._def.effect || null;
32311
+ const checkCtx = {
32312
+ addIssue: /* @__PURE__ */ __name((arg) => {
32313
+ addIssueToContext(ctx, arg);
32314
+ if (arg.fatal) {
32315
+ status.abort();
32316
+ } else {
32317
+ status.dirty();
32318
+ }
32319
+ }, "addIssue"),
32320
+ get path() {
32321
+ return ctx.path;
32322
+ }
32323
+ };
32324
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
32325
+ if (effect.type === "preprocess") {
32326
+ const processed = effect.transform(ctx.data, checkCtx);
32327
+ if (ctx.common.async) {
32328
+ return Promise.resolve(processed).then(async (processed2) => {
32329
+ if (status.value === "aborted") return INVALID;
32330
+ const result = await this._def.schema._parseAsync({
32331
+ data: processed2,
32332
+ path: ctx.path,
32333
+ parent: ctx
32334
+ });
32335
+ if (result.status === "aborted") return INVALID;
32336
+ if (result.status === "dirty") return DIRTY(result.value);
32337
+ if (status.value === "dirty") return DIRTY(result.value);
32338
+ return result;
32339
+ });
32340
+ } else {
32341
+ if (status.value === "aborted") return INVALID;
32342
+ const result = this._def.schema._parseSync({
32343
+ data: processed,
32344
+ path: ctx.path,
32345
+ parent: ctx
32346
+ });
32347
+ if (result.status === "aborted") return INVALID;
32348
+ if (result.status === "dirty") return DIRTY(result.value);
32349
+ if (status.value === "dirty") return DIRTY(result.value);
32350
+ return result;
32351
+ }
32352
+ }
32353
+ if (effect.type === "refinement") {
32354
+ const executeRefinement = /* @__PURE__ */ __name((acc) => {
32355
+ const result = effect.refinement(acc, checkCtx);
32356
+ if (ctx.common.async) {
32357
+ return Promise.resolve(result);
32358
+ }
32359
+ if (result instanceof Promise) {
32360
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
32361
+ }
32362
+ return acc;
32363
+ }, "executeRefinement");
32364
+ if (ctx.common.async === false) {
32365
+ const inner = this._def.schema._parseSync({
32366
+ data: ctx.data,
32367
+ path: ctx.path,
32368
+ parent: ctx
32369
+ });
32370
+ if (inner.status === "aborted") return INVALID;
32371
+ if (inner.status === "dirty") status.dirty();
32372
+ executeRefinement(inner.value);
32373
+ return {
32374
+ status: status.value,
32375
+ value: inner.value
32376
+ };
32377
+ } else {
32378
+ return this._def.schema._parseAsync({
32379
+ data: ctx.data,
32380
+ path: ctx.path,
32381
+ parent: ctx
32382
+ }).then((inner) => {
32383
+ if (inner.status === "aborted") return INVALID;
32384
+ if (inner.status === "dirty") status.dirty();
32385
+ return executeRefinement(inner.value).then(() => {
32386
+ return {
32387
+ status: status.value,
32388
+ value: inner.value
32389
+ };
32390
+ });
32391
+ });
32392
+ }
32393
+ }
32394
+ if (effect.type === "transform") {
32395
+ if (ctx.common.async === false) {
32396
+ const base = this._def.schema._parseSync({
32397
+ data: ctx.data,
32398
+ path: ctx.path,
32399
+ parent: ctx
32400
+ });
32401
+ if (!isValid(base)) return INVALID;
32402
+ const result = effect.transform(base.value, checkCtx);
32403
+ if (result instanceof Promise) {
32404
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
32405
+ }
32406
+ return {
32407
+ status: status.value,
32408
+ value: result
32409
+ };
32410
+ } else {
32411
+ return this._def.schema._parseAsync({
32412
+ data: ctx.data,
32413
+ path: ctx.path,
32414
+ parent: ctx
32415
+ }).then((base) => {
32416
+ if (!isValid(base)) return INVALID;
32417
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
32418
+ status: status.value,
32419
+ value: result
32420
+ }));
32421
+ });
32422
+ }
32423
+ }
32424
+ util.assertNever(effect);
32425
+ }
32426
+ };
32427
+ ZodEffects.create = (schema, effect, params) => {
32428
+ return new ZodEffects({
32429
+ schema,
32430
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
32431
+ effect,
32432
+ ...processCreateParams(params)
32433
+ });
32434
+ };
32435
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
32436
+ return new ZodEffects({
32437
+ schema,
32438
+ effect: {
32439
+ type: "preprocess",
32440
+ transform: preprocess
32441
+ },
32442
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
32443
+ ...processCreateParams(params)
32444
+ });
32445
+ };
32446
+ var ZodOptional = class extends ZodType {
32447
+ static {
32448
+ __name(this, "ZodOptional");
32449
+ }
32450
+ _parse(input) {
32451
+ const parsedType = this._getType(input);
32452
+ if (parsedType === ZodParsedType.undefined) {
32453
+ return OK(void 0);
32454
+ }
32455
+ return this._def.innerType._parse(input);
32456
+ }
32457
+ unwrap() {
32458
+ return this._def.innerType;
32459
+ }
32460
+ };
32461
+ ZodOptional.create = (type, params) => {
32462
+ return new ZodOptional({
32463
+ innerType: type,
32464
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
32465
+ ...processCreateParams(params)
32466
+ });
32467
+ };
32468
+ var ZodNullable = class extends ZodType {
32469
+ static {
32470
+ __name(this, "ZodNullable");
32471
+ }
32472
+ _parse(input) {
32473
+ const parsedType = this._getType(input);
32474
+ if (parsedType === ZodParsedType.null) {
32475
+ return OK(null);
32476
+ }
32477
+ return this._def.innerType._parse(input);
32478
+ }
32479
+ unwrap() {
32480
+ return this._def.innerType;
32481
+ }
32482
+ };
32483
+ ZodNullable.create = (type, params) => {
32484
+ return new ZodNullable({
32485
+ innerType: type,
32486
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
32487
+ ...processCreateParams(params)
32488
+ });
32489
+ };
32490
+ var ZodDefault = class extends ZodType {
32491
+ static {
32492
+ __name(this, "ZodDefault");
32493
+ }
32494
+ _parse(input) {
32495
+ const { ctx } = this._processInputParams(input);
32496
+ let data = ctx.data;
32497
+ if (ctx.parsedType === ZodParsedType.undefined) {
32498
+ data = this._def.defaultValue();
32499
+ }
32500
+ return this._def.innerType._parse({
32501
+ data,
32502
+ path: ctx.path,
32503
+ parent: ctx
32504
+ });
32505
+ }
32506
+ removeDefault() {
32507
+ return this._def.innerType;
32508
+ }
32509
+ };
32510
+ ZodDefault.create = (type, params) => {
32511
+ return new ZodDefault({
32512
+ innerType: type,
32513
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
32514
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
32515
+ ...processCreateParams(params)
32516
+ });
32517
+ };
32518
+ var ZodCatch = class extends ZodType {
32519
+ static {
32520
+ __name(this, "ZodCatch");
32521
+ }
32522
+ _parse(input) {
32523
+ const { ctx } = this._processInputParams(input);
32524
+ const newCtx = {
32525
+ ...ctx,
32526
+ common: {
32527
+ ...ctx.common,
32528
+ issues: []
32529
+ }
32530
+ };
32531
+ const result = this._def.innerType._parse({
32532
+ data: newCtx.data,
32533
+ path: newCtx.path,
32534
+ parent: {
32535
+ ...newCtx
32536
+ }
32537
+ });
32538
+ if (isAsync(result)) {
32539
+ return result.then((result2) => {
32540
+ return {
32541
+ status: "valid",
32542
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
32543
+ get error() {
32544
+ return new ZodError(newCtx.common.issues);
32545
+ },
32546
+ input: newCtx.data
32547
+ })
32548
+ };
32549
+ });
32550
+ } else {
32551
+ return {
32552
+ status: "valid",
32553
+ value: result.status === "valid" ? result.value : this._def.catchValue({
32554
+ get error() {
32555
+ return new ZodError(newCtx.common.issues);
32556
+ },
32557
+ input: newCtx.data
32558
+ })
32559
+ };
32560
+ }
32561
+ }
32562
+ removeCatch() {
32563
+ return this._def.innerType;
32564
+ }
32565
+ };
32566
+ ZodCatch.create = (type, params) => {
32567
+ return new ZodCatch({
32568
+ innerType: type,
32569
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
32570
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
32571
+ ...processCreateParams(params)
32572
+ });
32573
+ };
32574
+ var ZodNaN = class extends ZodType {
32575
+ static {
32576
+ __name(this, "ZodNaN");
32577
+ }
32578
+ _parse(input) {
32579
+ const parsedType = this._getType(input);
32580
+ if (parsedType !== ZodParsedType.nan) {
32581
+ const ctx = this._getOrReturnCtx(input);
32582
+ addIssueToContext(ctx, {
32583
+ code: ZodIssueCode.invalid_type,
32584
+ expected: ZodParsedType.nan,
32585
+ received: ctx.parsedType
32586
+ });
32587
+ return INVALID;
32588
+ }
32589
+ return {
32590
+ status: "valid",
32591
+ value: input.data
32592
+ };
32593
+ }
32594
+ };
32595
+ ZodNaN.create = (params) => {
32596
+ return new ZodNaN({
32597
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
32598
+ ...processCreateParams(params)
32599
+ });
32600
+ };
32601
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
32602
+ var ZodBranded = class extends ZodType {
32603
+ static {
32604
+ __name(this, "ZodBranded");
32605
+ }
32606
+ _parse(input) {
32607
+ const { ctx } = this._processInputParams(input);
32608
+ const data = ctx.data;
32609
+ return this._def.type._parse({
32610
+ data,
32611
+ path: ctx.path,
32612
+ parent: ctx
32613
+ });
32614
+ }
32615
+ unwrap() {
32616
+ return this._def.type;
32617
+ }
32618
+ };
32619
+ var ZodPipeline = class _ZodPipeline extends ZodType {
32620
+ static {
32621
+ __name(this, "ZodPipeline");
32622
+ }
32623
+ _parse(input) {
32624
+ const { status, ctx } = this._processInputParams(input);
32625
+ if (ctx.common.async) {
32626
+ const handleAsync = /* @__PURE__ */ __name(async () => {
32627
+ const inResult = await this._def.in._parseAsync({
32628
+ data: ctx.data,
32629
+ path: ctx.path,
32630
+ parent: ctx
32631
+ });
32632
+ if (inResult.status === "aborted") return INVALID;
32633
+ if (inResult.status === "dirty") {
32634
+ status.dirty();
32635
+ return DIRTY(inResult.value);
32636
+ } else {
32637
+ return this._def.out._parseAsync({
32638
+ data: inResult.value,
32639
+ path: ctx.path,
32640
+ parent: ctx
32641
+ });
32642
+ }
32643
+ }, "handleAsync");
32644
+ return handleAsync();
32645
+ } else {
32646
+ const inResult = this._def.in._parseSync({
32647
+ data: ctx.data,
32648
+ path: ctx.path,
32649
+ parent: ctx
32650
+ });
32651
+ if (inResult.status === "aborted") return INVALID;
32652
+ if (inResult.status === "dirty") {
32653
+ status.dirty();
32654
+ return {
32655
+ status: "dirty",
32656
+ value: inResult.value
32657
+ };
32658
+ } else {
32659
+ return this._def.out._parseSync({
32660
+ data: inResult.value,
32661
+ path: ctx.path,
32662
+ parent: ctx
32663
+ });
32664
+ }
32665
+ }
32666
+ }
32667
+ static create(a6, b6) {
32668
+ return new _ZodPipeline({
32669
+ in: a6,
32670
+ out: b6,
32671
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
32672
+ });
32673
+ }
32674
+ };
32675
+ var ZodReadonly = class extends ZodType {
32676
+ static {
32677
+ __name(this, "ZodReadonly");
32678
+ }
32679
+ _parse(input) {
32680
+ const result = this._def.innerType._parse(input);
32681
+ const freeze = /* @__PURE__ */ __name((data) => {
32682
+ if (isValid(data)) {
32683
+ data.value = Object.freeze(data.value);
32684
+ }
32685
+ return data;
32686
+ }, "freeze");
32687
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
32688
+ }
32689
+ unwrap() {
32690
+ return this._def.innerType;
32691
+ }
32692
+ };
32693
+ ZodReadonly.create = (type, params) => {
32694
+ return new ZodReadonly({
32695
+ innerType: type,
32696
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
32697
+ ...processCreateParams(params)
32698
+ });
32699
+ };
32700
+ function cleanParams(params, data) {
32701
+ const p3 = typeof params === "function" ? params(data) : typeof params === "string" ? {
32702
+ message: params
32703
+ } : params;
32704
+ const p22 = typeof p3 === "string" ? {
32705
+ message: p3
32706
+ } : p3;
32707
+ return p22;
32708
+ }
32709
+ __name(cleanParams, "cleanParams");
32710
+ function custom(check, _params = {}, fatal) {
32711
+ if (check) return ZodAny.create().superRefine((data, ctx) => {
32712
+ const r6 = check(data);
32713
+ if (r6 instanceof Promise) {
32714
+ return r6.then((r7) => {
32715
+ if (!r7) {
32716
+ const params = cleanParams(_params, data);
32717
+ const _fatal = params.fatal ?? fatal ?? true;
32718
+ ctx.addIssue({
32719
+ code: "custom",
32720
+ ...params,
32721
+ fatal: _fatal
32722
+ });
32723
+ }
32724
+ });
32725
+ }
32726
+ if (!r6) {
32727
+ const params = cleanParams(_params, data);
32728
+ const _fatal = params.fatal ?? fatal ?? true;
32729
+ ctx.addIssue({
32730
+ code: "custom",
32731
+ ...params,
32732
+ fatal: _fatal
32733
+ });
32734
+ }
32735
+ return;
32736
+ });
32737
+ return ZodAny.create();
32738
+ }
32739
+ __name(custom, "custom");
32740
+ var late = {
32741
+ object: ZodObject.lazycreate
32742
+ };
32743
+ var ZodFirstPartyTypeKind;
32744
+ (function(ZodFirstPartyTypeKind2) {
32745
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
32746
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
32747
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
32748
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
32749
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
32750
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
32751
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
32752
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
32753
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
32754
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
32755
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
32756
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
32757
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
32758
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
32759
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
32760
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
32761
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
32762
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
32763
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
32764
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
32765
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
32766
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
32767
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
32768
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
32769
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
32770
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
32771
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
32772
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
32773
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
32774
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
32775
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
32776
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
32777
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
32778
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
32779
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
32780
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
32781
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
32782
+ var instanceOfType = /* @__PURE__ */ __name((cls, params = {
32783
+ message: `Input not instance of ${cls.name}`
32784
+ }) => custom((data) => data instanceof cls, params), "instanceOfType");
32785
+ var stringType = ZodString.create;
32786
+ var numberType = ZodNumber.create;
32787
+ var nanType = ZodNaN.create;
32788
+ var bigIntType = ZodBigInt.create;
32789
+ var booleanType = ZodBoolean.create;
32790
+ var dateType = ZodDate.create;
32791
+ var symbolType = ZodSymbol.create;
32792
+ var undefinedType = ZodUndefined.create;
32793
+ var nullType = ZodNull.create;
32794
+ var anyType = ZodAny.create;
32795
+ var unknownType = ZodUnknown.create;
32796
+ var neverType = ZodNever.create;
32797
+ var voidType = ZodVoid.create;
32798
+ var arrayType = ZodArray.create;
32799
+ var objectType = ZodObject.create;
32800
+ var strictObjectType = ZodObject.strictCreate;
32801
+ var unionType = ZodUnion.create;
32802
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
32803
+ var intersectionType = ZodIntersection.create;
32804
+ var tupleType = ZodTuple.create;
32805
+ var recordType = ZodRecord.create;
32806
+ var mapType = ZodMap.create;
32807
+ var setType = ZodSet.create;
32808
+ var functionType = ZodFunction.create;
32809
+ var lazyType = ZodLazy.create;
32810
+ var literalType = ZodLiteral.create;
32811
+ var enumType = ZodEnum.create;
32812
+ var nativeEnumType = ZodNativeEnum.create;
32813
+ var promiseType = ZodPromise.create;
32814
+ var effectsType = ZodEffects.create;
32815
+ var optionalType = ZodOptional.create;
32816
+ var nullableType = ZodNullable.create;
32817
+ var preprocessType = ZodEffects.createWithPreprocess;
32818
+ var pipelineType = ZodPipeline.create;
32819
+ var ostring = /* @__PURE__ */ __name(() => stringType().optional(), "ostring");
32820
+ var onumber = /* @__PURE__ */ __name(() => numberType().optional(), "onumber");
32821
+ var oboolean = /* @__PURE__ */ __name(() => booleanType().optional(), "oboolean");
32822
+ var coerce = {
32823
+ string: /* @__PURE__ */ __name((arg) => ZodString.create({
32824
+ ...arg,
32825
+ coerce: true
32826
+ }), "string"),
32827
+ number: /* @__PURE__ */ __name((arg) => ZodNumber.create({
32828
+ ...arg,
32829
+ coerce: true
32830
+ }), "number"),
32831
+ boolean: /* @__PURE__ */ __name((arg) => ZodBoolean.create({
32832
+ ...arg,
32833
+ coerce: true
32834
+ }), "boolean"),
32835
+ bigint: /* @__PURE__ */ __name((arg) => ZodBigInt.create({
32836
+ ...arg,
32837
+ coerce: true
32838
+ }), "bigint"),
32839
+ date: /* @__PURE__ */ __name((arg) => ZodDate.create({
32840
+ ...arg,
32841
+ coerce: true
32842
+ }), "date")
32843
+ };
32844
+ var NEVER = INVALID;
32845
+
32846
+ // ../../packages/prosa-sync/src/schemas.ts
32847
+ var PROTOCOL_VERSION = 1;
32848
+ var objectManifestEntrySchema = external_exports.object({
32849
+ /** Canonical object id derived from the BLAKE3 of the original payload. */
32850
+ objectId: external_exports.string().regex(/^blake3:[0-9a-f]{64}$/i),
32851
+ /** BLAKE3 of the original (uncompressed) payload. */
32852
+ hash: external_exports.string().regex(/^[0-9a-f]{64}$/i),
32853
+ hashAlgorithm: external_exports.literal("blake3").default("blake3"),
32854
+ uncompressedSize: external_exports.number().int().nonnegative(),
32855
+ compressedSize: external_exports.number().int().nonnegative(),
32856
+ /**
32857
+ * Compression used for the on-disk / on-transport bytes. Defaults to `zstd`
32858
+ * to match the local bundle layout; `none` is used when compression would
32859
+ * not shrink the payload.
32860
+ */
32861
+ compression: external_exports.enum([
32862
+ "zstd",
32863
+ "none"
32864
+ ]).default("zstd"),
32865
+ /**
32866
+ * BLAKE3 of the bytes-on-the-wire (`compressed` bytes for `compression=zstd`,
32867
+ * identical to `hash` for `compression=none`). The server verifies the
32868
+ * uploaded body against this hash; `hash`/`objectId` remain canonical for
32869
+ * the original payload.
32870
+ */
32871
+ transportHash: external_exports.string().regex(/^[0-9a-f]{64}$/i).optional(),
32872
+ contentType: external_exports.string().optional()
32873
+ }).superRefine((value, ctx) => {
32874
+ if (value.objectId.toLowerCase() !== `blake3:${value.hash.toLowerCase()}`) {
32875
+ ctx.addIssue({
32876
+ code: external_exports.ZodIssueCode.custom,
32877
+ path: [
32878
+ "objectId"
32879
+ ],
32880
+ message: "objectId must be blake3:<hash>"
32881
+ });
32882
+ }
32883
+ });
32884
+ var sourceFileRowSchema = external_exports.object({
32885
+ id: external_exports.string().min(1),
32886
+ sourceKind: external_exports.string().min(1),
32887
+ path: external_exports.string().min(1),
32888
+ objectId: external_exports.string().min(1).nullable().optional(),
32889
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32890
+ });
32891
+ var rawRecordRowSchema = external_exports.object({
32892
+ id: external_exports.string().min(1),
32893
+ sourceFileId: external_exports.string().min(1),
32894
+ sequence: external_exports.number().int().nonnegative(),
32895
+ payload: external_exports.unknown(),
32896
+ objectId: external_exports.string().min(1).nullable().optional()
32897
+ });
32898
+ var projectionSessionRowSchema = external_exports.object({
32899
+ id: external_exports.string().min(1),
32900
+ sourceKind: external_exports.string().min(1),
32901
+ projectId: external_exports.string().min(1).nullable().optional(),
32902
+ title: external_exports.string().nullable().optional(),
32903
+ startedAt: external_exports.string().datetime().nullable().optional(),
32904
+ endedAt: external_exports.string().datetime().nullable().optional(),
32905
+ turnCount: external_exports.number().int().nonnegative().default(0),
32906
+ parentSessionId: external_exports.string().min(1).nullable().optional(),
32907
+ isSubagent: external_exports.boolean().nullable().optional(),
32908
+ agentRole: external_exports.string().nullable().optional(),
32909
+ agentNickname: external_exports.string().nullable().optional(),
32910
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32911
+ });
32912
+ var searchDocRowSchema = external_exports.object({
32913
+ id: external_exports.string().min(1),
32914
+ sessionId: external_exports.string().min(1),
32915
+ kind: external_exports.string().min(1),
32916
+ body: external_exports.string()
32917
+ });
32918
+ var projectionToolCallRowSchema = external_exports.object({
32919
+ id: external_exports.string().min(1),
32920
+ sessionId: external_exports.string().min(1),
32921
+ turnId: external_exports.string().min(1).nullable().optional(),
32922
+ name: external_exports.string().min(1),
32923
+ status: external_exports.string().nullable().optional(),
32924
+ inputObjectId: external_exports.string().min(1).nullable().optional(),
32925
+ createdAt: external_exports.string().datetime().nullable().optional()
32926
+ });
32927
+ var projectionToolResultRowSchema = external_exports.object({
32928
+ id: external_exports.string().min(1),
32929
+ toolCallId: external_exports.string().min(1),
32930
+ outputObjectId: external_exports.string().min(1).nullable().optional(),
32931
+ status: external_exports.string().nullable().optional(),
32932
+ finishedAt: external_exports.string().datetime().nullable().optional()
32933
+ });
32934
+ var projectionMessageRowSchema = external_exports.object({
32935
+ id: external_exports.string().min(1),
32936
+ sessionId: external_exports.string().min(1),
32937
+ turnId: external_exports.string().min(1).nullable().optional(),
32938
+ role: external_exports.string().min(1),
32939
+ model: external_exports.string().nullable().optional(),
32940
+ createdAt: external_exports.string().datetime().nullable().optional()
32941
+ });
32942
+ var projectionContentBlockRowSchema = external_exports.object({
32943
+ id: external_exports.string().min(1),
32944
+ messageId: external_exports.string().min(1),
32945
+ sequence: external_exports.number().int().nonnegative(),
32946
+ kind: external_exports.string().min(1),
32947
+ text: external_exports.string().nullable().optional(),
32948
+ tokenCount: external_exports.number().int().nonnegative().nullable().optional(),
32949
+ objectId: external_exports.string().min(1).nullable().optional(),
32950
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32951
+ });
32952
+ var projectionEventRowSchema = external_exports.object({
32953
+ id: external_exports.string().min(1),
32954
+ sessionId: external_exports.string().min(1),
32955
+ turnId: external_exports.string().min(1).nullable().optional(),
32956
+ sequence: external_exports.number().int().nonnegative(),
32957
+ kind: external_exports.string().min(1),
32958
+ payload: external_exports.unknown().optional(),
32959
+ occurredAt: external_exports.string().datetime().nullable().optional()
32960
+ });
32961
+ var projectionArtifactRowSchema = external_exports.object({
32962
+ id: external_exports.string().min(1),
32963
+ sessionId: external_exports.string().min(1).nullable().optional(),
32964
+ kind: external_exports.string().min(1),
32965
+ objectId: external_exports.string().min(1).nullable().optional(),
32966
+ sizeBytes: external_exports.number().int().nonnegative().nullable().optional(),
32967
+ metadata: external_exports.record(external_exports.unknown()).nullable().optional()
32968
+ });
32969
+ var projectionPayloadSchema = external_exports.object({
32970
+ sourceFiles: external_exports.array(sourceFileRowSchema).default([]),
32971
+ rawRecords: external_exports.array(rawRecordRowSchema).default([]),
32972
+ sessions: external_exports.array(projectionSessionRowSchema).default([]),
32973
+ searchDocs: external_exports.array(searchDocRowSchema).default([]),
32974
+ toolCalls: external_exports.array(projectionToolCallRowSchema).default([]),
32975
+ toolResults: external_exports.array(projectionToolResultRowSchema).default([]),
32976
+ // New transcript projections (F3). Older CLIs can omit them entirely.
32977
+ messages: external_exports.array(projectionMessageRowSchema).default([]),
32978
+ contentBlocks: external_exports.array(projectionContentBlockRowSchema).default([]),
32979
+ events: external_exports.array(projectionEventRowSchema).default([]),
32980
+ artifacts: external_exports.array(projectionArtifactRowSchema).default([])
32981
+ });
32982
+ var handshakeInputSchema = external_exports.object({
32983
+ cliVersion: external_exports.string().min(1),
32984
+ protocolVersion: external_exports.number().int().min(1).default(PROTOCOL_VERSION),
32985
+ device: external_exports.object({
32986
+ name: external_exports.string().min(1),
32987
+ platform: external_exports.string().optional()
32988
+ }),
32989
+ store: external_exports.object({
32990
+ path: external_exports.string().min(1),
32991
+ bundleVersion: external_exports.string().min(1)
32992
+ })
32993
+ });
32994
+ var handshakeOutputSchema = external_exports.object({
32995
+ serverVersion: external_exports.string(),
32996
+ protocolVersion: external_exports.number().int(),
32997
+ deviceId: external_exports.string().min(1),
32998
+ promoted: external_exports.boolean(),
32999
+ limits: external_exports.object({
33000
+ maxObjectsPerPlan: external_exports.number().int().positive(),
33001
+ maxRowsPerCommit: external_exports.number().int().positive(),
33002
+ maxObjectBytes: external_exports.number().int().positive()
33003
+ })
33004
+ });
33005
+ var planUploadInputSchema = external_exports.object({
33006
+ deviceId: external_exports.string().min(1),
33007
+ storePath: external_exports.string().min(1),
33008
+ objects: external_exports.array(objectManifestEntrySchema).default([])
33009
+ });
33010
+ var planUploadOutputSchema = external_exports.object({
33011
+ batchId: external_exports.string().min(1),
33012
+ missingObjectIds: external_exports.array(external_exports.string()),
33013
+ uploadUrlTemplate: external_exports.string()
33014
+ });
33015
+ var commitUploadInputSchema = external_exports.object({
33016
+ batchId: external_exports.string().min(1),
33017
+ deviceId: external_exports.string().min(1),
33018
+ storePath: external_exports.string().min(1),
33019
+ objects: external_exports.array(objectManifestEntrySchema).default([]),
33020
+ projection: projectionPayloadSchema.default({})
33021
+ });
33022
+ var commitUploadOutputSchema = external_exports.object({
33023
+ batchId: external_exports.string(),
33024
+ committedObjects: external_exports.number().int().nonnegative(),
33025
+ committedRows: external_exports.number().int().nonnegative()
33026
+ });
33027
+ var verifyPromotionInputSchema = external_exports.object({
33028
+ batchId: external_exports.string().min(1),
33029
+ storePath: external_exports.string().min(1),
33030
+ sampleSessionIds: external_exports.array(external_exports.string()).max(20).default([]),
33031
+ /**
33032
+ * Object IDs the client uploaded in this batch. Every entry must have a
33033
+ * matching `tenant_object` provenance row for the caller's tenant before
33034
+ * `verifyPromotion` will emit a receipt. Used to authorize destructive
33035
+ * cleanup.
33036
+ */
33037
+ declaredObjectIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33038
+ /** Source file ids the client claims were uploaded; verifier confirms each. */
33039
+ declaredSourceFileIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33040
+ /** Raw record ids the client claims were uploaded; verifier confirms each. */
33041
+ declaredRawRecordIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33042
+ /** Session ids the client claims were uploaded; verifier confirms each. */
33043
+ declaredSessionIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33044
+ /** Search doc ids the client claims were uploaded; verifier confirms each. */
33045
+ declaredSearchDocIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33046
+ /** Tool call ids the client claims were uploaded; verifier confirms each. */
33047
+ declaredToolCallIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33048
+ /** Tool result ids the client claims were uploaded; verifier confirms each. */
33049
+ declaredToolResultIds: external_exports.array(external_exports.string()).max(1e4).default([]),
33050
+ /** Message ids the client claims were uploaded; verifier confirms each. (F3) */
33051
+ declaredMessageIds: external_exports.array(external_exports.string()).max(5e4).default([]),
33052
+ /** Content-block ids the client claims were uploaded; verifier confirms each. (F3) */
33053
+ declaredContentBlockIds: external_exports.array(external_exports.string()).max(1e5).default([]),
33054
+ /** Event ids the client claims were uploaded; verifier confirms each. (F3) */
33055
+ declaredEventIds: external_exports.array(external_exports.string()).max(1e5).default([]),
33056
+ /** Artifact ids the client claims were uploaded; verifier confirms each. (F3) */
33057
+ declaredArtifactIds: external_exports.array(external_exports.string()).max(1e4).default([])
33058
+ });
33059
+ var promotionReceiptSchema = external_exports.object({
33060
+ batchId: external_exports.string(),
33061
+ tenantId: external_exports.string(),
33062
+ deviceId: external_exports.string(),
33063
+ storePath: external_exports.string(),
33064
+ manifestHash: external_exports.string(),
33065
+ sessionCount: external_exports.number().int().nonnegative(),
33066
+ objectCount: external_exports.number().int().nonnegative(),
33067
+ searchDocCount: external_exports.number().int().nonnegative(),
33068
+ batchObjectCount: external_exports.number().int().nonnegative().default(0),
33069
+ batchSourceFileCount: external_exports.number().int().nonnegative().default(0),
33070
+ batchRawRecordCount: external_exports.number().int().nonnegative().default(0),
33071
+ batchSessionCount: external_exports.number().int().nonnegative().default(0),
33072
+ batchSearchDocCount: external_exports.number().int().nonnegative().default(0),
33073
+ batchToolCallCount: external_exports.number().int().nonnegative().default(0),
33074
+ batchToolResultCount: external_exports.number().int().nonnegative().default(0),
33075
+ batchMessageCount: external_exports.number().int().nonnegative().default(0),
33076
+ batchContentBlockCount: external_exports.number().int().nonnegative().default(0),
33077
+ batchEventCount: external_exports.number().int().nonnegative().default(0),
33078
+ batchArtifactCount: external_exports.number().int().nonnegative().default(0),
33079
+ declaredObjectsVerified: external_exports.number().int().nonnegative().default(0),
33080
+ declaredSourceFilesVerified: external_exports.number().int().nonnegative().default(0),
33081
+ declaredRawRecordsVerified: external_exports.number().int().nonnegative().default(0),
33082
+ declaredSessionsVerified: external_exports.number().int().nonnegative().default(0),
33083
+ declaredSearchDocsVerified: external_exports.number().int().nonnegative().default(0),
33084
+ declaredToolCallsVerified: external_exports.number().int().nonnegative().default(0),
33085
+ declaredToolResultsVerified: external_exports.number().int().nonnegative().default(0),
33086
+ declaredMessagesVerified: external_exports.number().int().nonnegative().default(0),
33087
+ declaredContentBlocksVerified: external_exports.number().int().nonnegative().default(0),
33088
+ declaredEventsVerified: external_exports.number().int().nonnegative().default(0),
33089
+ declaredArtifactsVerified: external_exports.number().int().nonnegative().default(0),
33090
+ cleanupEligible: external_exports.boolean().default(false),
33091
+ verifiedAt: external_exports.string().datetime()
33092
+ });
33093
+ var verifyPromotionOutputSchema = external_exports.object({
33094
+ receipt: promotionReceiptSchema,
33095
+ sampledSessions: external_exports.array(external_exports.object({
33096
+ id: external_exports.string(),
33097
+ title: external_exports.string().nullable(),
33098
+ turnCount: external_exports.number().int()
33099
+ }))
33100
+ });
33101
+ var ackCleanupInputSchema = external_exports.object({
33102
+ batchId: external_exports.string().min(1),
33103
+ storePath: external_exports.string().min(1),
33104
+ removedPaths: external_exports.array(external_exports.string()).default([])
33105
+ });
33106
+
33107
+ // ../../packages/prosa-sync/src/object-pack.ts
33108
+ var OBJECT_PACK_BINARY_CONTENT_TYPE = "application/vnd.prosa.object-pack.v1+binary";
33109
+ var OBJECT_PACK_BINARY_MAGIC = "PROSAOP1";
33110
+ var MAGIC_BYTES = new TextEncoder().encode(OBJECT_PACK_BINARY_MAGIC);
33111
+ var HEADER_LENGTH_BYTES = 4;
33112
+ var textEncoder = new TextEncoder();
33113
+ var textDecoder = new TextDecoder("utf-8", {
33114
+ fatal: true
33115
+ });
33116
+ var objectPackWireEntrySchema = objectManifestEntrySchema.and(external_exports.object({
33117
+ offset: external_exports.number().int().nonnegative(),
33118
+ length: external_exports.number().int().nonnegative()
33119
+ }));
33120
+ var objectPackBinaryHeaderSchema = external_exports.object({
33121
+ entries: external_exports.array(objectPackWireEntrySchema)
33122
+ });
33123
+ var BinaryObjectPackFormatError = class extends Error {
33124
+ static {
33125
+ __name(this, "BinaryObjectPackFormatError");
33126
+ }
33127
+ name = "BinaryObjectPackFormatError";
33128
+ };
33129
+ function formatError(message) {
33130
+ throw new BinaryObjectPackFormatError(message);
33131
+ }
33132
+ __name(formatError, "formatError");
33133
+ function encodeBinaryObjectPack(pack) {
33134
+ const headerBytes = textEncoder.encode(JSON.stringify({
33135
+ entries: pack.entries
33136
+ }));
33137
+ if (headerBytes.byteLength > 4294967295) {
33138
+ formatError("binary object pack header is too large");
33139
+ }
33140
+ const headerOffset = MAGIC_BYTES.byteLength + HEADER_LENGTH_BYTES;
33141
+ const payloadOffset = headerOffset + headerBytes.byteLength;
33142
+ const out = new Uint8Array(payloadOffset + pack.payload.byteLength);
33143
+ out.set(MAGIC_BYTES, 0);
33144
+ new DataView(out.buffer, out.byteOffset + MAGIC_BYTES.byteLength, HEADER_LENGTH_BYTES).setUint32(0, headerBytes.byteLength);
33145
+ out.set(headerBytes, headerOffset);
33146
+ out.set(pack.payload, payloadOffset);
33147
+ return out;
33148
+ }
33149
+ __name(encodeBinaryObjectPack, "encodeBinaryObjectPack");
33150
+
33151
+ // src/cli/auth/client.ts
28397
33152
  var OBJECT_UPLOAD_MAX_ATTEMPTS = 6;
28398
33153
  var OBJECT_UPLOAD_BASE_BACKOFF_MS = 500;
28399
33154
  var OBJECT_UPLOAD_MAX_BACKOFF_MS = 15e3;
@@ -52705,8 +57460,8 @@ var getSsecPlugin = /* @__PURE__ */ __name((config) => ({
52705
57460
  }, "applyToStack")
52706
57461
  }), "getSsecPlugin");
52707
57462
  function isValidBase64EncodedSSECustomerKey(str, options) {
52708
- const base64Regex = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
52709
- if (!base64Regex.test(str)) return false;
57463
+ const base64Regex2 = /^(?:[A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
57464
+ if (!base64Regex2.test(str)) return false;
52710
57465
  try {
52711
57466
  const decodedBytes = options.base64Decoder(str);
52712
57467
  return decodedBytes.length === 32;
@@ -53023,6 +57778,7 @@ __name(isPreconditionFailed, "isPreconditionFailed");
53023
57778
  // src/cli/sync/bundle.ts
53024
57779
  function readSessionsForUpload(bundle) {
53025
57780
  const rows = bundle.db.prepare(`SELECT s.session_id, s.source_tool, s.project_id, s.title, s.start_ts, s.end_ts,
57781
+ s.parent_session_id, s.is_subagent, s.agent_role, s.agent_nickname,
53026
57782
  COALESCE(tc.cnt, 0) AS turn_count
53027
57783
  FROM sessions s
53028
57784
  LEFT JOIN (SELECT session_id, COUNT(*) AS cnt FROM turns GROUP BY session_id) tc
@@ -53036,7 +57792,11 @@ function readSessionsForUpload(bundle) {
53036
57792
  title: row.title,
53037
57793
  startedAt: row.start_ts,
53038
57794
  endedAt: row.end_ts,
53039
- turnCount: row.turn_count
57795
+ turnCount: row.turn_count,
57796
+ parentSessionId: row.parent_session_id,
57797
+ isSubagent: row.is_subagent === 1,
57798
+ agentRole: row.agent_role,
57799
+ agentNickname: row.agent_nickname
53040
57800
  }));
53041
57801
  }
53042
57802
  __name(readSessionsForUpload, "readSessionsForUpload");
@@ -53146,10 +57906,10 @@ function readContentBlocksForUpload(bundle) {
53146
57906
  sequence: row.ordinal,
53147
57907
  kind: row.block_type,
53148
57908
  text: row.text_inline,
57909
+ tokenCount: row.token_count,
53149
57910
  objectId: row.text_object_id,
53150
57911
  metadata: {
53151
57912
  mimeType: row.mime_type,
53152
- tokenCount: row.token_count,
53153
57913
  isError: row.is_error === 1,
53154
57914
  isRedacted: row.is_redacted === 1,
53155
57915
  visibility: row.visibility
@@ -54611,11 +59371,13 @@ function readRawRecordChunk(bundle, afterId, limit) {
54611
59371
  __name(readRawRecordChunk, "readRawRecordChunk");
54612
59372
  function readSessionChunk(bundle, afterId, limit) {
54613
59373
  const sql = afterId ? `SELECT s.session_id, s.source_tool, s.project_id, s.title, s.start_ts, s.end_ts,
59374
+ s.parent_session_id, s.is_subagent, s.agent_role, s.agent_nickname,
54614
59375
  (SELECT COUNT(*) FROM turns t WHERE t.session_id = s.session_id) AS turn_count
54615
59376
  FROM sessions s
54616
59377
  WHERE s.session_id > ?
54617
59378
  ORDER BY s.session_id
54618
59379
  LIMIT ?` : `SELECT s.session_id, s.source_tool, s.project_id, s.title, s.start_ts, s.end_ts,
59380
+ s.parent_session_id, s.is_subagent, s.agent_role, s.agent_nickname,
54619
59381
  (SELECT COUNT(*) FROM turns t WHERE t.session_id = s.session_id) AS turn_count
54620
59382
  FROM sessions s
54621
59383
  ORDER BY s.session_id
@@ -54634,7 +59396,11 @@ function readSessionChunk(bundle, afterId, limit) {
54634
59396
  title: row.title,
54635
59397
  startedAt: row.start_ts,
54636
59398
  endedAt: row.end_ts,
54637
- turnCount: row.turn_count
59399
+ turnCount: row.turn_count,
59400
+ parentSessionId: row.parent_session_id,
59401
+ isSubagent: row.is_subagent === 1,
59402
+ agentRole: row.agent_role,
59403
+ agentNickname: row.agent_nickname
54638
59404
  })),
54639
59405
  nextCursor: rows.length > 0 ? rows[rows.length - 1]?.session_id ?? null : null
54640
59406
  };
@@ -54785,10 +59551,10 @@ function readContentBlockChunk(bundle, afterId, limit) {
54785
59551
  sequence: row.ordinal,
54786
59552
  kind: row.block_type,
54787
59553
  text: row.text_inline,
59554
+ tokenCount: row.token_count,
54788
59555
  objectId: row.text_object_id,
54789
59556
  metadata: {
54790
59557
  mimeType: row.mime_type,
54791
- tokenCount: row.token_count,
54792
59558
  isError: row.is_error === 1,
54793
59559
  isRedacted: row.is_redacted === 1,
54794
59560
  visibility: row.visibility