@claude-sync/cli 0.1.2 → 0.1.4

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.
@@ -1,24 +1,4458 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
3
+ var __create = Object.create;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
4
15
  var __esm = (fn, res) => function __init() {
5
16
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
17
  };
18
+ var __commonJS = (cb, mod) => function __require2() {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ };
7
21
  var __export = (target, all) => {
8
22
  for (var name in all)
9
23
  __defProp(target, name, { get: all[name], enumerable: true });
10
24
  };
25
+ var __copyProps = (to, from, except, desc) => {
26
+ if (from && typeof from === "object" || typeof from === "function") {
27
+ for (let key of __getOwnPropNames(from))
28
+ if (!__hasOwnProp.call(to, key) && key !== except)
29
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
30
+ }
31
+ return to;
32
+ };
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
+ // If the importer is in node compatibility mode or this is not an ESM
35
+ // file that has been converted to a CommonJS file using a Babel-
36
+ // compatible transform (i.e. "__esModule" has not been set), then set
37
+ // "default" to the CommonJS "module.exports" for node compatibility.
38
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
+ mod
40
+ ));
41
+
42
+ // ../../node_modules/tsup/assets/esm_shims.js
43
+ import path from "path";
44
+ import { fileURLToPath } from "url";
45
+ var init_esm_shims = __esm({
46
+ "../../node_modules/tsup/assets/esm_shims.js"() {
47
+ "use strict";
48
+ }
49
+ });
50
+
51
+ // ../../packages/utils/dist/path-encoding.js
52
+ var require_path_encoding = __commonJS({
53
+ "../../packages/utils/dist/path-encoding.js"(exports) {
54
+ "use strict";
55
+ init_esm_shims();
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.ROOT_PATTERN = void 0;
58
+ exports.encodePath = encodePath3;
59
+ exports.decodeSuffix = decodeSuffix;
60
+ exports.decodeRoot = decodeRoot;
61
+ exports.extractCanonicalPath = extractCanonicalPath;
62
+ exports.ROOT_PATTERN = /^-(home-[^-]+|Users-[^-]+)/;
63
+ function encodePath3(p) {
64
+ return p.replace(/\//g, "-").replace(/\./g, "-");
65
+ }
66
+ function decodeSuffix(suffix, projectPath) {
67
+ if (!suffix)
68
+ return "(home directory)";
69
+ if (projectPath) {
70
+ const parts = projectPath.split("/");
71
+ const homeIdx = parts.findIndex((p) => p === "home" || p === "Users");
72
+ if (homeIdx !== -1 && homeIdx + 2 < parts.length) {
73
+ return parts.slice(homeIdx + 2).join("/");
74
+ }
75
+ }
76
+ return suffix.slice(1).replace(/-/g, "/");
77
+ }
78
+ function decodeRoot(root) {
79
+ return "/" + root.slice(1).replace(/-/g, "/");
80
+ }
81
+ function extractCanonicalPath(fullPath, homeDir) {
82
+ const relative = fullPath.startsWith(homeDir) ? fullPath.slice(homeDir.length) : fullPath;
83
+ return encodePath3(relative.startsWith("/") ? relative : "/" + relative);
84
+ }
85
+ }
86
+ });
87
+
88
+ // ../../packages/utils/dist/manifest.js
89
+ var require_manifest = __commonJS({
90
+ "../../packages/utils/dist/manifest.js"(exports) {
91
+ "use strict";
92
+ init_esm_shims();
93
+ Object.defineProperty(exports, "__esModule", { value: true });
94
+ exports.hashFile = hashFile2;
95
+ exports.hashManifest = hashManifest;
96
+ exports.diffManifests = diffManifests2;
97
+ var crypto_1 = __require("crypto");
98
+ var promises_1 = __require("fs/promises");
99
+ async function hashFile2(filePath) {
100
+ const content = await (0, promises_1.readFile)(filePath);
101
+ return (0, crypto_1.createHash)("sha256").update(content).digest("hex");
102
+ }
103
+ function hashManifest(entries) {
104
+ const sorted = [...entries].sort((a, b) => a.path.localeCompare(b.path));
105
+ const content = sorted.map((e) => `${e.path}:${e.hash}:${e.size}`).join("\n");
106
+ return (0, crypto_1.createHash)("sha256").update(content).digest("hex");
107
+ }
108
+ function diffManifests2(local, remote) {
109
+ const remoteMap = new Map(remote.map((e) => [e.path, e]));
110
+ const localMap = new Map(local.map((e) => [e.path, e]));
111
+ const added = [];
112
+ const modified = [];
113
+ const deleted = [];
114
+ for (const entry of local) {
115
+ const remoteEntry = remoteMap.get(entry.path);
116
+ if (!remoteEntry) {
117
+ added.push(entry);
118
+ } else if (remoteEntry.hash !== entry.hash) {
119
+ modified.push(entry);
120
+ }
121
+ }
122
+ for (const entry of remote) {
123
+ if (!localMap.has(entry.path)) {
124
+ deleted.push(entry);
125
+ }
126
+ }
127
+ return { added, modified, deleted };
128
+ }
129
+ }
130
+ });
131
+
132
+ // ../../packages/utils/dist/constants.js
133
+ var require_constants = __commonJS({
134
+ "../../packages/utils/dist/constants.js"(exports) {
135
+ "use strict";
136
+ init_esm_shims();
137
+ Object.defineProperty(exports, "__esModule", { value: true });
138
+ exports.PROJECTS_DIR = exports.CLAUDE_DIR = exports.MANIFEST_FILE = exports.CONFIG_FILE = exports.CONFIG_DIR = exports.API_VERSION = exports.BUCKET_MANIFESTS = exports.BUCKET_DATA = exports.SYNC_EXCLUDE_PATTERNS = void 0;
139
+ exports.SYNC_EXCLUDE_PATTERNS = [
140
+ "node_modules",
141
+ ".git",
142
+ ".DS_Store",
143
+ "Thumbs.db",
144
+ "*.swp",
145
+ "*.swo",
146
+ "*~",
147
+ ".env",
148
+ ".env.local"
149
+ ];
150
+ exports.BUCKET_DATA = "claude-sync-data";
151
+ exports.BUCKET_MANIFESTS = "claude-sync-manifests";
152
+ exports.API_VERSION = "v1";
153
+ exports.CONFIG_DIR = ".claude-sync";
154
+ exports.CONFIG_FILE = "config.json";
155
+ exports.MANIFEST_FILE = "manifest.json";
156
+ exports.CLAUDE_DIR = ".claude";
157
+ exports.PROJECTS_DIR = "projects";
158
+ }
159
+ });
160
+
161
+ // ../../node_modules/zod/v3/helpers/util.cjs
162
+ var require_util = __commonJS({
163
+ "../../node_modules/zod/v3/helpers/util.cjs"(exports) {
164
+ "use strict";
165
+ init_esm_shims();
166
+ Object.defineProperty(exports, "__esModule", { value: true });
167
+ exports.getParsedType = exports.ZodParsedType = exports.objectUtil = exports.util = void 0;
168
+ var util;
169
+ (function(util2) {
170
+ util2.assertEqual = (_) => {
171
+ };
172
+ function assertIs(_arg) {
173
+ }
174
+ util2.assertIs = assertIs;
175
+ function assertNever(_x) {
176
+ throw new Error();
177
+ }
178
+ util2.assertNever = assertNever;
179
+ util2.arrayToEnum = (items) => {
180
+ const obj = {};
181
+ for (const item of items) {
182
+ obj[item] = item;
183
+ }
184
+ return obj;
185
+ };
186
+ util2.getValidEnumValues = (obj) => {
187
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
188
+ const filtered = {};
189
+ for (const k of validKeys) {
190
+ filtered[k] = obj[k];
191
+ }
192
+ return util2.objectValues(filtered);
193
+ };
194
+ util2.objectValues = (obj) => {
195
+ return util2.objectKeys(obj).map(function(e) {
196
+ return obj[e];
197
+ });
198
+ };
199
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
200
+ const keys = [];
201
+ for (const key in object) {
202
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
203
+ keys.push(key);
204
+ }
205
+ }
206
+ return keys;
207
+ };
208
+ util2.find = (arr, checker) => {
209
+ for (const item of arr) {
210
+ if (checker(item))
211
+ return item;
212
+ }
213
+ return void 0;
214
+ };
215
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
216
+ function joinValues(array, separator = " | ") {
217
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
218
+ }
219
+ util2.joinValues = joinValues;
220
+ util2.jsonStringifyReplacer = (_, value) => {
221
+ if (typeof value === "bigint") {
222
+ return value.toString();
223
+ }
224
+ return value;
225
+ };
226
+ })(util || (exports.util = util = {}));
227
+ var objectUtil;
228
+ (function(objectUtil2) {
229
+ objectUtil2.mergeShapes = (first, second) => {
230
+ return {
231
+ ...first,
232
+ ...second
233
+ // second overwrites first
234
+ };
235
+ };
236
+ })(objectUtil || (exports.objectUtil = objectUtil = {}));
237
+ exports.ZodParsedType = util.arrayToEnum([
238
+ "string",
239
+ "nan",
240
+ "number",
241
+ "integer",
242
+ "float",
243
+ "boolean",
244
+ "date",
245
+ "bigint",
246
+ "symbol",
247
+ "function",
248
+ "undefined",
249
+ "null",
250
+ "array",
251
+ "object",
252
+ "unknown",
253
+ "promise",
254
+ "void",
255
+ "never",
256
+ "map",
257
+ "set"
258
+ ]);
259
+ var getParsedType = (data) => {
260
+ const t = typeof data;
261
+ switch (t) {
262
+ case "undefined":
263
+ return exports.ZodParsedType.undefined;
264
+ case "string":
265
+ return exports.ZodParsedType.string;
266
+ case "number":
267
+ return Number.isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
268
+ case "boolean":
269
+ return exports.ZodParsedType.boolean;
270
+ case "function":
271
+ return exports.ZodParsedType.function;
272
+ case "bigint":
273
+ return exports.ZodParsedType.bigint;
274
+ case "symbol":
275
+ return exports.ZodParsedType.symbol;
276
+ case "object":
277
+ if (Array.isArray(data)) {
278
+ return exports.ZodParsedType.array;
279
+ }
280
+ if (data === null) {
281
+ return exports.ZodParsedType.null;
282
+ }
283
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
284
+ return exports.ZodParsedType.promise;
285
+ }
286
+ if (typeof Map !== "undefined" && data instanceof Map) {
287
+ return exports.ZodParsedType.map;
288
+ }
289
+ if (typeof Set !== "undefined" && data instanceof Set) {
290
+ return exports.ZodParsedType.set;
291
+ }
292
+ if (typeof Date !== "undefined" && data instanceof Date) {
293
+ return exports.ZodParsedType.date;
294
+ }
295
+ return exports.ZodParsedType.object;
296
+ default:
297
+ return exports.ZodParsedType.unknown;
298
+ }
299
+ };
300
+ exports.getParsedType = getParsedType;
301
+ }
302
+ });
303
+
304
+ // ../../node_modules/zod/v3/ZodError.cjs
305
+ var require_ZodError = __commonJS({
306
+ "../../node_modules/zod/v3/ZodError.cjs"(exports) {
307
+ "use strict";
308
+ init_esm_shims();
309
+ Object.defineProperty(exports, "__esModule", { value: true });
310
+ exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
311
+ var util_js_1 = require_util();
312
+ exports.ZodIssueCode = util_js_1.util.arrayToEnum([
313
+ "invalid_type",
314
+ "invalid_literal",
315
+ "custom",
316
+ "invalid_union",
317
+ "invalid_union_discriminator",
318
+ "invalid_enum_value",
319
+ "unrecognized_keys",
320
+ "invalid_arguments",
321
+ "invalid_return_type",
322
+ "invalid_date",
323
+ "invalid_string",
324
+ "too_small",
325
+ "too_big",
326
+ "invalid_intersection_types",
327
+ "not_multiple_of",
328
+ "not_finite"
329
+ ]);
330
+ var quotelessJson = (obj) => {
331
+ const json = JSON.stringify(obj, null, 2);
332
+ return json.replace(/"([^"]+)":/g, "$1:");
333
+ };
334
+ exports.quotelessJson = quotelessJson;
335
+ var ZodError = class _ZodError extends Error {
336
+ get errors() {
337
+ return this.issues;
338
+ }
339
+ constructor(issues) {
340
+ super();
341
+ this.issues = [];
342
+ this.addIssue = (sub) => {
343
+ this.issues = [...this.issues, sub];
344
+ };
345
+ this.addIssues = (subs = []) => {
346
+ this.issues = [...this.issues, ...subs];
347
+ };
348
+ const actualProto = new.target.prototype;
349
+ if (Object.setPrototypeOf) {
350
+ Object.setPrototypeOf(this, actualProto);
351
+ } else {
352
+ this.__proto__ = actualProto;
353
+ }
354
+ this.name = "ZodError";
355
+ this.issues = issues;
356
+ }
357
+ format(_mapper) {
358
+ const mapper = _mapper || function(issue) {
359
+ return issue.message;
360
+ };
361
+ const fieldErrors = { _errors: [] };
362
+ const processError = (error2) => {
363
+ for (const issue of error2.issues) {
364
+ if (issue.code === "invalid_union") {
365
+ issue.unionErrors.map(processError);
366
+ } else if (issue.code === "invalid_return_type") {
367
+ processError(issue.returnTypeError);
368
+ } else if (issue.code === "invalid_arguments") {
369
+ processError(issue.argumentsError);
370
+ } else if (issue.path.length === 0) {
371
+ fieldErrors._errors.push(mapper(issue));
372
+ } else {
373
+ let curr = fieldErrors;
374
+ let i = 0;
375
+ while (i < issue.path.length) {
376
+ const el = issue.path[i];
377
+ const terminal = i === issue.path.length - 1;
378
+ if (!terminal) {
379
+ curr[el] = curr[el] || { _errors: [] };
380
+ } else {
381
+ curr[el] = curr[el] || { _errors: [] };
382
+ curr[el]._errors.push(mapper(issue));
383
+ }
384
+ curr = curr[el];
385
+ i++;
386
+ }
387
+ }
388
+ }
389
+ };
390
+ processError(this);
391
+ return fieldErrors;
392
+ }
393
+ static assert(value) {
394
+ if (!(value instanceof _ZodError)) {
395
+ throw new Error(`Not a ZodError: ${value}`);
396
+ }
397
+ }
398
+ toString() {
399
+ return this.message;
400
+ }
401
+ get message() {
402
+ return JSON.stringify(this.issues, util_js_1.util.jsonStringifyReplacer, 2);
403
+ }
404
+ get isEmpty() {
405
+ return this.issues.length === 0;
406
+ }
407
+ flatten(mapper = (issue) => issue.message) {
408
+ const fieldErrors = {};
409
+ const formErrors = [];
410
+ for (const sub of this.issues) {
411
+ if (sub.path.length > 0) {
412
+ const firstEl = sub.path[0];
413
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
414
+ fieldErrors[firstEl].push(mapper(sub));
415
+ } else {
416
+ formErrors.push(mapper(sub));
417
+ }
418
+ }
419
+ return { formErrors, fieldErrors };
420
+ }
421
+ get formErrors() {
422
+ return this.flatten();
423
+ }
424
+ };
425
+ exports.ZodError = ZodError;
426
+ ZodError.create = (issues) => {
427
+ const error2 = new ZodError(issues);
428
+ return error2;
429
+ };
430
+ }
431
+ });
432
+
433
+ // ../../node_modules/zod/v3/locales/en.cjs
434
+ var require_en = __commonJS({
435
+ "../../node_modules/zod/v3/locales/en.cjs"(exports) {
436
+ "use strict";
437
+ init_esm_shims();
438
+ Object.defineProperty(exports, "__esModule", { value: true });
439
+ var ZodError_js_1 = require_ZodError();
440
+ var util_js_1 = require_util();
441
+ var errorMap = (issue, _ctx) => {
442
+ let message;
443
+ switch (issue.code) {
444
+ case ZodError_js_1.ZodIssueCode.invalid_type:
445
+ if (issue.received === util_js_1.ZodParsedType.undefined) {
446
+ message = "Required";
447
+ } else {
448
+ message = `Expected ${issue.expected}, received ${issue.received}`;
449
+ }
450
+ break;
451
+ case ZodError_js_1.ZodIssueCode.invalid_literal:
452
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util_js_1.util.jsonStringifyReplacer)}`;
453
+ break;
454
+ case ZodError_js_1.ZodIssueCode.unrecognized_keys:
455
+ message = `Unrecognized key(s) in object: ${util_js_1.util.joinValues(issue.keys, ", ")}`;
456
+ break;
457
+ case ZodError_js_1.ZodIssueCode.invalid_union:
458
+ message = `Invalid input`;
459
+ break;
460
+ case ZodError_js_1.ZodIssueCode.invalid_union_discriminator:
461
+ message = `Invalid discriminator value. Expected ${util_js_1.util.joinValues(issue.options)}`;
462
+ break;
463
+ case ZodError_js_1.ZodIssueCode.invalid_enum_value:
464
+ message = `Invalid enum value. Expected ${util_js_1.util.joinValues(issue.options)}, received '${issue.received}'`;
465
+ break;
466
+ case ZodError_js_1.ZodIssueCode.invalid_arguments:
467
+ message = `Invalid function arguments`;
468
+ break;
469
+ case ZodError_js_1.ZodIssueCode.invalid_return_type:
470
+ message = `Invalid function return type`;
471
+ break;
472
+ case ZodError_js_1.ZodIssueCode.invalid_date:
473
+ message = `Invalid date`;
474
+ break;
475
+ case ZodError_js_1.ZodIssueCode.invalid_string:
476
+ if (typeof issue.validation === "object") {
477
+ if ("includes" in issue.validation) {
478
+ message = `Invalid input: must include "${issue.validation.includes}"`;
479
+ if (typeof issue.validation.position === "number") {
480
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
481
+ }
482
+ } else if ("startsWith" in issue.validation) {
483
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
484
+ } else if ("endsWith" in issue.validation) {
485
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
486
+ } else {
487
+ util_js_1.util.assertNever(issue.validation);
488
+ }
489
+ } else if (issue.validation !== "regex") {
490
+ message = `Invalid ${issue.validation}`;
491
+ } else {
492
+ message = "Invalid";
493
+ }
494
+ break;
495
+ case ZodError_js_1.ZodIssueCode.too_small:
496
+ if (issue.type === "array")
497
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
498
+ else if (issue.type === "string")
499
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
500
+ else if (issue.type === "number")
501
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
502
+ else if (issue.type === "bigint")
503
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
504
+ else if (issue.type === "date")
505
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
506
+ else
507
+ message = "Invalid input";
508
+ break;
509
+ case ZodError_js_1.ZodIssueCode.too_big:
510
+ if (issue.type === "array")
511
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
512
+ else if (issue.type === "string")
513
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
514
+ else if (issue.type === "number")
515
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
516
+ else if (issue.type === "bigint")
517
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
518
+ else if (issue.type === "date")
519
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
520
+ else
521
+ message = "Invalid input";
522
+ break;
523
+ case ZodError_js_1.ZodIssueCode.custom:
524
+ message = `Invalid input`;
525
+ break;
526
+ case ZodError_js_1.ZodIssueCode.invalid_intersection_types:
527
+ message = `Intersection results could not be merged`;
528
+ break;
529
+ case ZodError_js_1.ZodIssueCode.not_multiple_of:
530
+ message = `Number must be a multiple of ${issue.multipleOf}`;
531
+ break;
532
+ case ZodError_js_1.ZodIssueCode.not_finite:
533
+ message = "Number must be finite";
534
+ break;
535
+ default:
536
+ message = _ctx.defaultError;
537
+ util_js_1.util.assertNever(issue);
538
+ }
539
+ return { message };
540
+ };
541
+ exports.default = errorMap;
542
+ }
543
+ });
544
+
545
+ // ../../node_modules/zod/v3/errors.cjs
546
+ var require_errors = __commonJS({
547
+ "../../node_modules/zod/v3/errors.cjs"(exports) {
548
+ "use strict";
549
+ init_esm_shims();
550
+ var __importDefault = exports && exports.__importDefault || function(mod) {
551
+ return mod && mod.__esModule ? mod : { "default": mod };
552
+ };
553
+ Object.defineProperty(exports, "__esModule", { value: true });
554
+ exports.defaultErrorMap = void 0;
555
+ exports.setErrorMap = setErrorMap;
556
+ exports.getErrorMap = getErrorMap;
557
+ var en_js_1 = __importDefault(require_en());
558
+ exports.defaultErrorMap = en_js_1.default;
559
+ var overrideErrorMap = en_js_1.default;
560
+ function setErrorMap(map) {
561
+ overrideErrorMap = map;
562
+ }
563
+ function getErrorMap() {
564
+ return overrideErrorMap;
565
+ }
566
+ }
567
+ });
568
+
569
+ // ../../node_modules/zod/v3/helpers/parseUtil.cjs
570
+ var require_parseUtil = __commonJS({
571
+ "../../node_modules/zod/v3/helpers/parseUtil.cjs"(exports) {
572
+ "use strict";
573
+ init_esm_shims();
574
+ var __importDefault = exports && exports.__importDefault || function(mod) {
575
+ return mod && mod.__esModule ? mod : { "default": mod };
576
+ };
577
+ Object.defineProperty(exports, "__esModule", { value: true });
578
+ exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.EMPTY_PATH = exports.makeIssue = void 0;
579
+ exports.addIssueToContext = addIssueToContext;
580
+ var errors_js_1 = require_errors();
581
+ var en_js_1 = __importDefault(require_en());
582
+ var makeIssue = (params) => {
583
+ const { data, path: path2, errorMaps, issueData } = params;
584
+ const fullPath = [...path2, ...issueData.path || []];
585
+ const fullIssue = {
586
+ ...issueData,
587
+ path: fullPath
588
+ };
589
+ if (issueData.message !== void 0) {
590
+ return {
591
+ ...issueData,
592
+ path: fullPath,
593
+ message: issueData.message
594
+ };
595
+ }
596
+ let errorMessage = "";
597
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
598
+ for (const map of maps) {
599
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
600
+ }
601
+ return {
602
+ ...issueData,
603
+ path: fullPath,
604
+ message: errorMessage
605
+ };
606
+ };
607
+ exports.makeIssue = makeIssue;
608
+ exports.EMPTY_PATH = [];
609
+ function addIssueToContext(ctx, issueData) {
610
+ const overrideMap = (0, errors_js_1.getErrorMap)();
611
+ const issue = (0, exports.makeIssue)({
612
+ issueData,
613
+ data: ctx.data,
614
+ path: ctx.path,
615
+ errorMaps: [
616
+ ctx.common.contextualErrorMap,
617
+ // contextual error map is first priority
618
+ ctx.schemaErrorMap,
619
+ // then schema-bound map if available
620
+ overrideMap,
621
+ // then global override map
622
+ overrideMap === en_js_1.default ? void 0 : en_js_1.default
623
+ // then global default map
624
+ ].filter((x) => !!x)
625
+ });
626
+ ctx.common.issues.push(issue);
627
+ }
628
+ var ParseStatus = class _ParseStatus {
629
+ constructor() {
630
+ this.value = "valid";
631
+ }
632
+ dirty() {
633
+ if (this.value === "valid")
634
+ this.value = "dirty";
635
+ }
636
+ abort() {
637
+ if (this.value !== "aborted")
638
+ this.value = "aborted";
639
+ }
640
+ static mergeArray(status, results) {
641
+ const arrayValue = [];
642
+ for (const s of results) {
643
+ if (s.status === "aborted")
644
+ return exports.INVALID;
645
+ if (s.status === "dirty")
646
+ status.dirty();
647
+ arrayValue.push(s.value);
648
+ }
649
+ return { status: status.value, value: arrayValue };
650
+ }
651
+ static async mergeObjectAsync(status, pairs) {
652
+ const syncPairs = [];
653
+ for (const pair of pairs) {
654
+ const key = await pair.key;
655
+ const value = await pair.value;
656
+ syncPairs.push({
657
+ key,
658
+ value
659
+ });
660
+ }
661
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
662
+ }
663
+ static mergeObjectSync(status, pairs) {
664
+ const finalObject = {};
665
+ for (const pair of pairs) {
666
+ const { key, value } = pair;
667
+ if (key.status === "aborted")
668
+ return exports.INVALID;
669
+ if (value.status === "aborted")
670
+ return exports.INVALID;
671
+ if (key.status === "dirty")
672
+ status.dirty();
673
+ if (value.status === "dirty")
674
+ status.dirty();
675
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
676
+ finalObject[key.value] = value.value;
677
+ }
678
+ }
679
+ return { status: status.value, value: finalObject };
680
+ }
681
+ };
682
+ exports.ParseStatus = ParseStatus;
683
+ exports.INVALID = Object.freeze({
684
+ status: "aborted"
685
+ });
686
+ var DIRTY = (value) => ({ status: "dirty", value });
687
+ exports.DIRTY = DIRTY;
688
+ var OK = (value) => ({ status: "valid", value });
689
+ exports.OK = OK;
690
+ var isAborted = (x) => x.status === "aborted";
691
+ exports.isAborted = isAborted;
692
+ var isDirty = (x) => x.status === "dirty";
693
+ exports.isDirty = isDirty;
694
+ var isValid = (x) => x.status === "valid";
695
+ exports.isValid = isValid;
696
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
697
+ exports.isAsync = isAsync;
698
+ }
699
+ });
700
+
701
+ // ../../node_modules/zod/v3/helpers/typeAliases.cjs
702
+ var require_typeAliases = __commonJS({
703
+ "../../node_modules/zod/v3/helpers/typeAliases.cjs"(exports) {
704
+ "use strict";
705
+ init_esm_shims();
706
+ Object.defineProperty(exports, "__esModule", { value: true });
707
+ }
708
+ });
709
+
710
+ // ../../node_modules/zod/v3/helpers/errorUtil.cjs
711
+ var require_errorUtil = __commonJS({
712
+ "../../node_modules/zod/v3/helpers/errorUtil.cjs"(exports) {
713
+ "use strict";
714
+ init_esm_shims();
715
+ Object.defineProperty(exports, "__esModule", { value: true });
716
+ exports.errorUtil = void 0;
717
+ var errorUtil;
718
+ (function(errorUtil2) {
719
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
720
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
721
+ })(errorUtil || (exports.errorUtil = errorUtil = {}));
722
+ }
723
+ });
724
+
725
+ // ../../node_modules/zod/v3/types.cjs
726
+ var require_types = __commonJS({
727
+ "../../node_modules/zod/v3/types.cjs"(exports) {
728
+ "use strict";
729
+ init_esm_shims();
730
+ Object.defineProperty(exports, "__esModule", { value: true });
731
+ exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.coerce = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.ZodReadonly = exports.ZodPipeline = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodCatch = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
732
+ exports.NEVER = exports.void = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.symbol = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.pipeline = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports.null = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports.instanceof = exports.function = exports.enum = exports.effect = void 0;
733
+ exports.datetimeRegex = datetimeRegex;
734
+ exports.custom = custom;
735
+ var ZodError_js_1 = require_ZodError();
736
+ var errors_js_1 = require_errors();
737
+ var errorUtil_js_1 = require_errorUtil();
738
+ var parseUtil_js_1 = require_parseUtil();
739
+ var util_js_1 = require_util();
740
+ var ParseInputLazyPath = class {
741
+ constructor(parent, value, path2, key) {
742
+ this._cachedPath = [];
743
+ this.parent = parent;
744
+ this.data = value;
745
+ this._path = path2;
746
+ this._key = key;
747
+ }
748
+ get path() {
749
+ if (!this._cachedPath.length) {
750
+ if (Array.isArray(this._key)) {
751
+ this._cachedPath.push(...this._path, ...this._key);
752
+ } else {
753
+ this._cachedPath.push(...this._path, this._key);
754
+ }
755
+ }
756
+ return this._cachedPath;
757
+ }
758
+ };
759
+ var handleResult = (ctx, result) => {
760
+ if ((0, parseUtil_js_1.isValid)(result)) {
761
+ return { success: true, data: result.value };
762
+ } else {
763
+ if (!ctx.common.issues.length) {
764
+ throw new Error("Validation failed but no issues detected.");
765
+ }
766
+ return {
767
+ success: false,
768
+ get error() {
769
+ if (this._error)
770
+ return this._error;
771
+ const error2 = new ZodError_js_1.ZodError(ctx.common.issues);
772
+ this._error = error2;
773
+ return this._error;
774
+ }
775
+ };
776
+ }
777
+ };
778
+ function processCreateParams(params) {
779
+ if (!params)
780
+ return {};
781
+ const { errorMap, invalid_type_error, required_error, description } = params;
782
+ if (errorMap && (invalid_type_error || required_error)) {
783
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
784
+ }
785
+ if (errorMap)
786
+ return { errorMap, description };
787
+ const customMap = (iss, ctx) => {
788
+ const { message } = params;
789
+ if (iss.code === "invalid_enum_value") {
790
+ return { message: message ?? ctx.defaultError };
791
+ }
792
+ if (typeof ctx.data === "undefined") {
793
+ return { message: message ?? required_error ?? ctx.defaultError };
794
+ }
795
+ if (iss.code !== "invalid_type")
796
+ return { message: ctx.defaultError };
797
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
798
+ };
799
+ return { errorMap: customMap, description };
800
+ }
801
+ var ZodType = class {
802
+ get description() {
803
+ return this._def.description;
804
+ }
805
+ _getType(input) {
806
+ return (0, util_js_1.getParsedType)(input.data);
807
+ }
808
+ _getOrReturnCtx(input, ctx) {
809
+ return ctx || {
810
+ common: input.parent.common,
811
+ data: input.data,
812
+ parsedType: (0, util_js_1.getParsedType)(input.data),
813
+ schemaErrorMap: this._def.errorMap,
814
+ path: input.path,
815
+ parent: input.parent
816
+ };
817
+ }
818
+ _processInputParams(input) {
819
+ return {
820
+ status: new parseUtil_js_1.ParseStatus(),
821
+ ctx: {
822
+ common: input.parent.common,
823
+ data: input.data,
824
+ parsedType: (0, util_js_1.getParsedType)(input.data),
825
+ schemaErrorMap: this._def.errorMap,
826
+ path: input.path,
827
+ parent: input.parent
828
+ }
829
+ };
830
+ }
831
+ _parseSync(input) {
832
+ const result = this._parse(input);
833
+ if ((0, parseUtil_js_1.isAsync)(result)) {
834
+ throw new Error("Synchronous parse encountered promise.");
835
+ }
836
+ return result;
837
+ }
838
+ _parseAsync(input) {
839
+ const result = this._parse(input);
840
+ return Promise.resolve(result);
841
+ }
842
+ parse(data, params) {
843
+ const result = this.safeParse(data, params);
844
+ if (result.success)
845
+ return result.data;
846
+ throw result.error;
847
+ }
848
+ safeParse(data, params) {
849
+ const ctx = {
850
+ common: {
851
+ issues: [],
852
+ async: params?.async ?? false,
853
+ contextualErrorMap: params?.errorMap
854
+ },
855
+ path: params?.path || [],
856
+ schemaErrorMap: this._def.errorMap,
857
+ parent: null,
858
+ data,
859
+ parsedType: (0, util_js_1.getParsedType)(data)
860
+ };
861
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
862
+ return handleResult(ctx, result);
863
+ }
864
+ "~validate"(data) {
865
+ const ctx = {
866
+ common: {
867
+ issues: [],
868
+ async: !!this["~standard"].async
869
+ },
870
+ path: [],
871
+ schemaErrorMap: this._def.errorMap,
872
+ parent: null,
873
+ data,
874
+ parsedType: (0, util_js_1.getParsedType)(data)
875
+ };
876
+ if (!this["~standard"].async) {
877
+ try {
878
+ const result = this._parseSync({ data, path: [], parent: ctx });
879
+ return (0, parseUtil_js_1.isValid)(result) ? {
880
+ value: result.value
881
+ } : {
882
+ issues: ctx.common.issues
883
+ };
884
+ } catch (err) {
885
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
886
+ this["~standard"].async = true;
887
+ }
888
+ ctx.common = {
889
+ issues: [],
890
+ async: true
891
+ };
892
+ }
893
+ }
894
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => (0, parseUtil_js_1.isValid)(result) ? {
895
+ value: result.value
896
+ } : {
897
+ issues: ctx.common.issues
898
+ });
899
+ }
900
+ async parseAsync(data, params) {
901
+ const result = await this.safeParseAsync(data, params);
902
+ if (result.success)
903
+ return result.data;
904
+ throw result.error;
905
+ }
906
+ async safeParseAsync(data, params) {
907
+ const ctx = {
908
+ common: {
909
+ issues: [],
910
+ contextualErrorMap: params?.errorMap,
911
+ async: true
912
+ },
913
+ path: params?.path || [],
914
+ schemaErrorMap: this._def.errorMap,
915
+ parent: null,
916
+ data,
917
+ parsedType: (0, util_js_1.getParsedType)(data)
918
+ };
919
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
920
+ const result = await ((0, parseUtil_js_1.isAsync)(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
921
+ return handleResult(ctx, result);
922
+ }
923
+ refine(check, message) {
924
+ const getIssueProperties = (val) => {
925
+ if (typeof message === "string" || typeof message === "undefined") {
926
+ return { message };
927
+ } else if (typeof message === "function") {
928
+ return message(val);
929
+ } else {
930
+ return message;
931
+ }
932
+ };
933
+ return this._refinement((val, ctx) => {
934
+ const result = check(val);
935
+ const setError = () => ctx.addIssue({
936
+ code: ZodError_js_1.ZodIssueCode.custom,
937
+ ...getIssueProperties(val)
938
+ });
939
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
940
+ return result.then((data) => {
941
+ if (!data) {
942
+ setError();
943
+ return false;
944
+ } else {
945
+ return true;
946
+ }
947
+ });
948
+ }
949
+ if (!result) {
950
+ setError();
951
+ return false;
952
+ } else {
953
+ return true;
954
+ }
955
+ });
956
+ }
957
+ refinement(check, refinementData) {
958
+ return this._refinement((val, ctx) => {
959
+ if (!check(val)) {
960
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
961
+ return false;
962
+ } else {
963
+ return true;
964
+ }
965
+ });
966
+ }
967
+ _refinement(refinement) {
968
+ return new ZodEffects({
969
+ schema: this,
970
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
971
+ effect: { type: "refinement", refinement }
972
+ });
973
+ }
974
+ superRefine(refinement) {
975
+ return this._refinement(refinement);
976
+ }
977
+ constructor(def) {
978
+ this.spa = this.safeParseAsync;
979
+ this._def = def;
980
+ this.parse = this.parse.bind(this);
981
+ this.safeParse = this.safeParse.bind(this);
982
+ this.parseAsync = this.parseAsync.bind(this);
983
+ this.safeParseAsync = this.safeParseAsync.bind(this);
984
+ this.spa = this.spa.bind(this);
985
+ this.refine = this.refine.bind(this);
986
+ this.refinement = this.refinement.bind(this);
987
+ this.superRefine = this.superRefine.bind(this);
988
+ this.optional = this.optional.bind(this);
989
+ this.nullable = this.nullable.bind(this);
990
+ this.nullish = this.nullish.bind(this);
991
+ this.array = this.array.bind(this);
992
+ this.promise = this.promise.bind(this);
993
+ this.or = this.or.bind(this);
994
+ this.and = this.and.bind(this);
995
+ this.transform = this.transform.bind(this);
996
+ this.brand = this.brand.bind(this);
997
+ this.default = this.default.bind(this);
998
+ this.catch = this.catch.bind(this);
999
+ this.describe = this.describe.bind(this);
1000
+ this.pipe = this.pipe.bind(this);
1001
+ this.readonly = this.readonly.bind(this);
1002
+ this.isNullable = this.isNullable.bind(this);
1003
+ this.isOptional = this.isOptional.bind(this);
1004
+ this["~standard"] = {
1005
+ version: 1,
1006
+ vendor: "zod",
1007
+ validate: (data) => this["~validate"](data)
1008
+ };
1009
+ }
1010
+ optional() {
1011
+ return ZodOptional.create(this, this._def);
1012
+ }
1013
+ nullable() {
1014
+ return ZodNullable.create(this, this._def);
1015
+ }
1016
+ nullish() {
1017
+ return this.nullable().optional();
1018
+ }
1019
+ array() {
1020
+ return ZodArray.create(this);
1021
+ }
1022
+ promise() {
1023
+ return ZodPromise.create(this, this._def);
1024
+ }
1025
+ or(option) {
1026
+ return ZodUnion.create([this, option], this._def);
1027
+ }
1028
+ and(incoming) {
1029
+ return ZodIntersection.create(this, incoming, this._def);
1030
+ }
1031
+ transform(transform) {
1032
+ return new ZodEffects({
1033
+ ...processCreateParams(this._def),
1034
+ schema: this,
1035
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1036
+ effect: { type: "transform", transform }
1037
+ });
1038
+ }
1039
+ default(def) {
1040
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1041
+ return new ZodDefault({
1042
+ ...processCreateParams(this._def),
1043
+ innerType: this,
1044
+ defaultValue: defaultValueFunc,
1045
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1046
+ });
1047
+ }
1048
+ brand() {
1049
+ return new ZodBranded({
1050
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1051
+ type: this,
1052
+ ...processCreateParams(this._def)
1053
+ });
1054
+ }
1055
+ catch(def) {
1056
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1057
+ return new ZodCatch({
1058
+ ...processCreateParams(this._def),
1059
+ innerType: this,
1060
+ catchValue: catchValueFunc,
1061
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1062
+ });
1063
+ }
1064
+ describe(description) {
1065
+ const This = this.constructor;
1066
+ return new This({
1067
+ ...this._def,
1068
+ description
1069
+ });
1070
+ }
1071
+ pipe(target) {
1072
+ return ZodPipeline.create(this, target);
1073
+ }
1074
+ readonly() {
1075
+ return ZodReadonly.create(this);
1076
+ }
1077
+ isOptional() {
1078
+ return this.safeParse(void 0).success;
1079
+ }
1080
+ isNullable() {
1081
+ return this.safeParse(null).success;
1082
+ }
1083
+ };
1084
+ exports.ZodType = ZodType;
1085
+ exports.Schema = ZodType;
1086
+ exports.ZodSchema = ZodType;
1087
+ var cuidRegex = /^c[^\s-]{8,}$/i;
1088
+ var cuid2Regex = /^[0-9a-z]+$/;
1089
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1090
+ 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;
1091
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1092
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1093
+ 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)?)??$/;
1094
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1095
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1096
+ var emojiRegex;
1097
+ 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])$/;
1098
+ 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])$/;
1099
+ 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]))$/;
1100
+ 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])$/;
1101
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1102
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1103
+ 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])))`;
1104
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1105
+ function timeRegexSource(args) {
1106
+ let secondsRegexSource = `[0-5]\\d`;
1107
+ if (args.precision) {
1108
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1109
+ } else if (args.precision == null) {
1110
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1111
+ }
1112
+ const secondsQuantifier = args.precision ? "+" : "?";
1113
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1114
+ }
1115
+ function timeRegex(args) {
1116
+ return new RegExp(`^${timeRegexSource(args)}$`);
1117
+ }
1118
+ function datetimeRegex(args) {
1119
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1120
+ const opts = [];
1121
+ opts.push(args.local ? `Z?` : `Z`);
1122
+ if (args.offset)
1123
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1124
+ regex = `${regex}(${opts.join("|")})`;
1125
+ return new RegExp(`^${regex}$`);
1126
+ }
1127
+ function isValidIP(ip, version) {
1128
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1129
+ return true;
1130
+ }
1131
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1132
+ return true;
1133
+ }
1134
+ return false;
1135
+ }
1136
+ function isValidJWT(jwt, alg) {
1137
+ if (!jwtRegex.test(jwt))
1138
+ return false;
1139
+ try {
1140
+ const [header] = jwt.split(".");
1141
+ if (!header)
1142
+ return false;
1143
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1144
+ const decoded = JSON.parse(atob(base64));
1145
+ if (typeof decoded !== "object" || decoded === null)
1146
+ return false;
1147
+ if ("typ" in decoded && decoded?.typ !== "JWT")
1148
+ return false;
1149
+ if (!decoded.alg)
1150
+ return false;
1151
+ if (alg && decoded.alg !== alg)
1152
+ return false;
1153
+ return true;
1154
+ } catch {
1155
+ return false;
1156
+ }
1157
+ }
1158
+ function isValidCidr(ip, version) {
1159
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1160
+ return true;
1161
+ }
1162
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1163
+ return true;
1164
+ }
1165
+ return false;
1166
+ }
1167
+ var ZodString = class _ZodString extends ZodType {
1168
+ _parse(input) {
1169
+ if (this._def.coerce) {
1170
+ input.data = String(input.data);
1171
+ }
1172
+ const parsedType = this._getType(input);
1173
+ if (parsedType !== util_js_1.ZodParsedType.string) {
1174
+ const ctx2 = this._getOrReturnCtx(input);
1175
+ (0, parseUtil_js_1.addIssueToContext)(ctx2, {
1176
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1177
+ expected: util_js_1.ZodParsedType.string,
1178
+ received: ctx2.parsedType
1179
+ });
1180
+ return parseUtil_js_1.INVALID;
1181
+ }
1182
+ const status = new parseUtil_js_1.ParseStatus();
1183
+ let ctx = void 0;
1184
+ for (const check of this._def.checks) {
1185
+ if (check.kind === "min") {
1186
+ if (input.data.length < check.value) {
1187
+ ctx = this._getOrReturnCtx(input, ctx);
1188
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1189
+ code: ZodError_js_1.ZodIssueCode.too_small,
1190
+ minimum: check.value,
1191
+ type: "string",
1192
+ inclusive: true,
1193
+ exact: false,
1194
+ message: check.message
1195
+ });
1196
+ status.dirty();
1197
+ }
1198
+ } else if (check.kind === "max") {
1199
+ if (input.data.length > check.value) {
1200
+ ctx = this._getOrReturnCtx(input, ctx);
1201
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1202
+ code: ZodError_js_1.ZodIssueCode.too_big,
1203
+ maximum: check.value,
1204
+ type: "string",
1205
+ inclusive: true,
1206
+ exact: false,
1207
+ message: check.message
1208
+ });
1209
+ status.dirty();
1210
+ }
1211
+ } else if (check.kind === "length") {
1212
+ const tooBig = input.data.length > check.value;
1213
+ const tooSmall = input.data.length < check.value;
1214
+ if (tooBig || tooSmall) {
1215
+ ctx = this._getOrReturnCtx(input, ctx);
1216
+ if (tooBig) {
1217
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1218
+ code: ZodError_js_1.ZodIssueCode.too_big,
1219
+ maximum: check.value,
1220
+ type: "string",
1221
+ inclusive: true,
1222
+ exact: true,
1223
+ message: check.message
1224
+ });
1225
+ } else if (tooSmall) {
1226
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1227
+ code: ZodError_js_1.ZodIssueCode.too_small,
1228
+ minimum: check.value,
1229
+ type: "string",
1230
+ inclusive: true,
1231
+ exact: true,
1232
+ message: check.message
1233
+ });
1234
+ }
1235
+ status.dirty();
1236
+ }
1237
+ } else if (check.kind === "email") {
1238
+ if (!emailRegex.test(input.data)) {
1239
+ ctx = this._getOrReturnCtx(input, ctx);
1240
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1241
+ validation: "email",
1242
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1243
+ message: check.message
1244
+ });
1245
+ status.dirty();
1246
+ }
1247
+ } else if (check.kind === "emoji") {
1248
+ if (!emojiRegex) {
1249
+ emojiRegex = new RegExp(_emojiRegex, "u");
1250
+ }
1251
+ if (!emojiRegex.test(input.data)) {
1252
+ ctx = this._getOrReturnCtx(input, ctx);
1253
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1254
+ validation: "emoji",
1255
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1256
+ message: check.message
1257
+ });
1258
+ status.dirty();
1259
+ }
1260
+ } else if (check.kind === "uuid") {
1261
+ if (!uuidRegex.test(input.data)) {
1262
+ ctx = this._getOrReturnCtx(input, ctx);
1263
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1264
+ validation: "uuid",
1265
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1266
+ message: check.message
1267
+ });
1268
+ status.dirty();
1269
+ }
1270
+ } else if (check.kind === "nanoid") {
1271
+ if (!nanoidRegex.test(input.data)) {
1272
+ ctx = this._getOrReturnCtx(input, ctx);
1273
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1274
+ validation: "nanoid",
1275
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1276
+ message: check.message
1277
+ });
1278
+ status.dirty();
1279
+ }
1280
+ } else if (check.kind === "cuid") {
1281
+ if (!cuidRegex.test(input.data)) {
1282
+ ctx = this._getOrReturnCtx(input, ctx);
1283
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1284
+ validation: "cuid",
1285
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1286
+ message: check.message
1287
+ });
1288
+ status.dirty();
1289
+ }
1290
+ } else if (check.kind === "cuid2") {
1291
+ if (!cuid2Regex.test(input.data)) {
1292
+ ctx = this._getOrReturnCtx(input, ctx);
1293
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1294
+ validation: "cuid2",
1295
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1296
+ message: check.message
1297
+ });
1298
+ status.dirty();
1299
+ }
1300
+ } else if (check.kind === "ulid") {
1301
+ if (!ulidRegex.test(input.data)) {
1302
+ ctx = this._getOrReturnCtx(input, ctx);
1303
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1304
+ validation: "ulid",
1305
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1306
+ message: check.message
1307
+ });
1308
+ status.dirty();
1309
+ }
1310
+ } else if (check.kind === "url") {
1311
+ try {
1312
+ new URL(input.data);
1313
+ } catch {
1314
+ ctx = this._getOrReturnCtx(input, ctx);
1315
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1316
+ validation: "url",
1317
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1318
+ message: check.message
1319
+ });
1320
+ status.dirty();
1321
+ }
1322
+ } else if (check.kind === "regex") {
1323
+ check.regex.lastIndex = 0;
1324
+ const testResult = check.regex.test(input.data);
1325
+ if (!testResult) {
1326
+ ctx = this._getOrReturnCtx(input, ctx);
1327
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1328
+ validation: "regex",
1329
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1330
+ message: check.message
1331
+ });
1332
+ status.dirty();
1333
+ }
1334
+ } else if (check.kind === "trim") {
1335
+ input.data = input.data.trim();
1336
+ } else if (check.kind === "includes") {
1337
+ if (!input.data.includes(check.value, check.position)) {
1338
+ ctx = this._getOrReturnCtx(input, ctx);
1339
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1340
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1341
+ validation: { includes: check.value, position: check.position },
1342
+ message: check.message
1343
+ });
1344
+ status.dirty();
1345
+ }
1346
+ } else if (check.kind === "toLowerCase") {
1347
+ input.data = input.data.toLowerCase();
1348
+ } else if (check.kind === "toUpperCase") {
1349
+ input.data = input.data.toUpperCase();
1350
+ } else if (check.kind === "startsWith") {
1351
+ if (!input.data.startsWith(check.value)) {
1352
+ ctx = this._getOrReturnCtx(input, ctx);
1353
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1354
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1355
+ validation: { startsWith: check.value },
1356
+ message: check.message
1357
+ });
1358
+ status.dirty();
1359
+ }
1360
+ } else if (check.kind === "endsWith") {
1361
+ if (!input.data.endsWith(check.value)) {
1362
+ ctx = this._getOrReturnCtx(input, ctx);
1363
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1364
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1365
+ validation: { endsWith: check.value },
1366
+ message: check.message
1367
+ });
1368
+ status.dirty();
1369
+ }
1370
+ } else if (check.kind === "datetime") {
1371
+ const regex = datetimeRegex(check);
1372
+ if (!regex.test(input.data)) {
1373
+ ctx = this._getOrReturnCtx(input, ctx);
1374
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1375
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1376
+ validation: "datetime",
1377
+ message: check.message
1378
+ });
1379
+ status.dirty();
1380
+ }
1381
+ } else if (check.kind === "date") {
1382
+ const regex = dateRegex;
1383
+ if (!regex.test(input.data)) {
1384
+ ctx = this._getOrReturnCtx(input, ctx);
1385
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1386
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1387
+ validation: "date",
1388
+ message: check.message
1389
+ });
1390
+ status.dirty();
1391
+ }
1392
+ } else if (check.kind === "time") {
1393
+ const regex = timeRegex(check);
1394
+ if (!regex.test(input.data)) {
1395
+ ctx = this._getOrReturnCtx(input, ctx);
1396
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1397
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1398
+ validation: "time",
1399
+ message: check.message
1400
+ });
1401
+ status.dirty();
1402
+ }
1403
+ } else if (check.kind === "duration") {
1404
+ if (!durationRegex.test(input.data)) {
1405
+ ctx = this._getOrReturnCtx(input, ctx);
1406
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1407
+ validation: "duration",
1408
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1409
+ message: check.message
1410
+ });
1411
+ status.dirty();
1412
+ }
1413
+ } else if (check.kind === "ip") {
1414
+ if (!isValidIP(input.data, check.version)) {
1415
+ ctx = this._getOrReturnCtx(input, ctx);
1416
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1417
+ validation: "ip",
1418
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1419
+ message: check.message
1420
+ });
1421
+ status.dirty();
1422
+ }
1423
+ } else if (check.kind === "jwt") {
1424
+ if (!isValidJWT(input.data, check.alg)) {
1425
+ ctx = this._getOrReturnCtx(input, ctx);
1426
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1427
+ validation: "jwt",
1428
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1429
+ message: check.message
1430
+ });
1431
+ status.dirty();
1432
+ }
1433
+ } else if (check.kind === "cidr") {
1434
+ if (!isValidCidr(input.data, check.version)) {
1435
+ ctx = this._getOrReturnCtx(input, ctx);
1436
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1437
+ validation: "cidr",
1438
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1439
+ message: check.message
1440
+ });
1441
+ status.dirty();
1442
+ }
1443
+ } else if (check.kind === "base64") {
1444
+ if (!base64Regex.test(input.data)) {
1445
+ ctx = this._getOrReturnCtx(input, ctx);
1446
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1447
+ validation: "base64",
1448
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1449
+ message: check.message
1450
+ });
1451
+ status.dirty();
1452
+ }
1453
+ } else if (check.kind === "base64url") {
1454
+ if (!base64urlRegex.test(input.data)) {
1455
+ ctx = this._getOrReturnCtx(input, ctx);
1456
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1457
+ validation: "base64url",
1458
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1459
+ message: check.message
1460
+ });
1461
+ status.dirty();
1462
+ }
1463
+ } else {
1464
+ util_js_1.util.assertNever(check);
1465
+ }
1466
+ }
1467
+ return { status: status.value, value: input.data };
1468
+ }
1469
+ _regex(regex, validation, message) {
1470
+ return this.refinement((data) => regex.test(data), {
1471
+ validation,
1472
+ code: ZodError_js_1.ZodIssueCode.invalid_string,
1473
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1474
+ });
1475
+ }
1476
+ _addCheck(check) {
1477
+ return new _ZodString({
1478
+ ...this._def,
1479
+ checks: [...this._def.checks, check]
1480
+ });
1481
+ }
1482
+ email(message) {
1483
+ return this._addCheck({ kind: "email", ...errorUtil_js_1.errorUtil.errToObj(message) });
1484
+ }
1485
+ url(message) {
1486
+ return this._addCheck({ kind: "url", ...errorUtil_js_1.errorUtil.errToObj(message) });
1487
+ }
1488
+ emoji(message) {
1489
+ return this._addCheck({ kind: "emoji", ...errorUtil_js_1.errorUtil.errToObj(message) });
1490
+ }
1491
+ uuid(message) {
1492
+ return this._addCheck({ kind: "uuid", ...errorUtil_js_1.errorUtil.errToObj(message) });
1493
+ }
1494
+ nanoid(message) {
1495
+ return this._addCheck({ kind: "nanoid", ...errorUtil_js_1.errorUtil.errToObj(message) });
1496
+ }
1497
+ cuid(message) {
1498
+ return this._addCheck({ kind: "cuid", ...errorUtil_js_1.errorUtil.errToObj(message) });
1499
+ }
1500
+ cuid2(message) {
1501
+ return this._addCheck({ kind: "cuid2", ...errorUtil_js_1.errorUtil.errToObj(message) });
1502
+ }
1503
+ ulid(message) {
1504
+ return this._addCheck({ kind: "ulid", ...errorUtil_js_1.errorUtil.errToObj(message) });
1505
+ }
1506
+ base64(message) {
1507
+ return this._addCheck({ kind: "base64", ...errorUtil_js_1.errorUtil.errToObj(message) });
1508
+ }
1509
+ base64url(message) {
1510
+ return this._addCheck({
1511
+ kind: "base64url",
1512
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1513
+ });
1514
+ }
1515
+ jwt(options) {
1516
+ return this._addCheck({ kind: "jwt", ...errorUtil_js_1.errorUtil.errToObj(options) });
1517
+ }
1518
+ ip(options) {
1519
+ return this._addCheck({ kind: "ip", ...errorUtil_js_1.errorUtil.errToObj(options) });
1520
+ }
1521
+ cidr(options) {
1522
+ return this._addCheck({ kind: "cidr", ...errorUtil_js_1.errorUtil.errToObj(options) });
1523
+ }
1524
+ datetime(options) {
1525
+ if (typeof options === "string") {
1526
+ return this._addCheck({
1527
+ kind: "datetime",
1528
+ precision: null,
1529
+ offset: false,
1530
+ local: false,
1531
+ message: options
1532
+ });
1533
+ }
1534
+ return this._addCheck({
1535
+ kind: "datetime",
1536
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1537
+ offset: options?.offset ?? false,
1538
+ local: options?.local ?? false,
1539
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1540
+ });
1541
+ }
1542
+ date(message) {
1543
+ return this._addCheck({ kind: "date", message });
1544
+ }
1545
+ time(options) {
1546
+ if (typeof options === "string") {
1547
+ return this._addCheck({
1548
+ kind: "time",
1549
+ precision: null,
1550
+ message: options
1551
+ });
1552
+ }
1553
+ return this._addCheck({
1554
+ kind: "time",
1555
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1556
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1557
+ });
1558
+ }
1559
+ duration(message) {
1560
+ return this._addCheck({ kind: "duration", ...errorUtil_js_1.errorUtil.errToObj(message) });
1561
+ }
1562
+ regex(regex, message) {
1563
+ return this._addCheck({
1564
+ kind: "regex",
1565
+ regex,
1566
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1567
+ });
1568
+ }
1569
+ includes(value, options) {
1570
+ return this._addCheck({
1571
+ kind: "includes",
1572
+ value,
1573
+ position: options?.position,
1574
+ ...errorUtil_js_1.errorUtil.errToObj(options?.message)
1575
+ });
1576
+ }
1577
+ startsWith(value, message) {
1578
+ return this._addCheck({
1579
+ kind: "startsWith",
1580
+ value,
1581
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1582
+ });
1583
+ }
1584
+ endsWith(value, message) {
1585
+ return this._addCheck({
1586
+ kind: "endsWith",
1587
+ value,
1588
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1589
+ });
1590
+ }
1591
+ min(minLength, message) {
1592
+ return this._addCheck({
1593
+ kind: "min",
1594
+ value: minLength,
1595
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1596
+ });
1597
+ }
1598
+ max(maxLength, message) {
1599
+ return this._addCheck({
1600
+ kind: "max",
1601
+ value: maxLength,
1602
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1603
+ });
1604
+ }
1605
+ length(len, message) {
1606
+ return this._addCheck({
1607
+ kind: "length",
1608
+ value: len,
1609
+ ...errorUtil_js_1.errorUtil.errToObj(message)
1610
+ });
1611
+ }
1612
+ /**
1613
+ * Equivalent to `.min(1)`
1614
+ */
1615
+ nonempty(message) {
1616
+ return this.min(1, errorUtil_js_1.errorUtil.errToObj(message));
1617
+ }
1618
+ trim() {
1619
+ return new _ZodString({
1620
+ ...this._def,
1621
+ checks: [...this._def.checks, { kind: "trim" }]
1622
+ });
1623
+ }
1624
+ toLowerCase() {
1625
+ return new _ZodString({
1626
+ ...this._def,
1627
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1628
+ });
1629
+ }
1630
+ toUpperCase() {
1631
+ return new _ZodString({
1632
+ ...this._def,
1633
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1634
+ });
1635
+ }
1636
+ get isDatetime() {
1637
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1638
+ }
1639
+ get isDate() {
1640
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1641
+ }
1642
+ get isTime() {
1643
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1644
+ }
1645
+ get isDuration() {
1646
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1647
+ }
1648
+ get isEmail() {
1649
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1650
+ }
1651
+ get isURL() {
1652
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1653
+ }
1654
+ get isEmoji() {
1655
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1656
+ }
1657
+ get isUUID() {
1658
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1659
+ }
1660
+ get isNANOID() {
1661
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1662
+ }
1663
+ get isCUID() {
1664
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1665
+ }
1666
+ get isCUID2() {
1667
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1668
+ }
1669
+ get isULID() {
1670
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1671
+ }
1672
+ get isIP() {
1673
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1674
+ }
1675
+ get isCIDR() {
1676
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1677
+ }
1678
+ get isBase64() {
1679
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1680
+ }
1681
+ get isBase64url() {
1682
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1683
+ }
1684
+ get minLength() {
1685
+ let min = null;
1686
+ for (const ch of this._def.checks) {
1687
+ if (ch.kind === "min") {
1688
+ if (min === null || ch.value > min)
1689
+ min = ch.value;
1690
+ }
1691
+ }
1692
+ return min;
1693
+ }
1694
+ get maxLength() {
1695
+ let max = null;
1696
+ for (const ch of this._def.checks) {
1697
+ if (ch.kind === "max") {
1698
+ if (max === null || ch.value < max)
1699
+ max = ch.value;
1700
+ }
1701
+ }
1702
+ return max;
1703
+ }
1704
+ };
1705
+ exports.ZodString = ZodString;
1706
+ ZodString.create = (params) => {
1707
+ return new ZodString({
1708
+ checks: [],
1709
+ typeName: ZodFirstPartyTypeKind.ZodString,
1710
+ coerce: params?.coerce ?? false,
1711
+ ...processCreateParams(params)
1712
+ });
1713
+ };
1714
+ function floatSafeRemainder(val, step) {
1715
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1716
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1717
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1718
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1719
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1720
+ return valInt % stepInt / 10 ** decCount;
1721
+ }
1722
+ var ZodNumber = class _ZodNumber extends ZodType {
1723
+ constructor() {
1724
+ super(...arguments);
1725
+ this.min = this.gte;
1726
+ this.max = this.lte;
1727
+ this.step = this.multipleOf;
1728
+ }
1729
+ _parse(input) {
1730
+ if (this._def.coerce) {
1731
+ input.data = Number(input.data);
1732
+ }
1733
+ const parsedType = this._getType(input);
1734
+ if (parsedType !== util_js_1.ZodParsedType.number) {
1735
+ const ctx2 = this._getOrReturnCtx(input);
1736
+ (0, parseUtil_js_1.addIssueToContext)(ctx2, {
1737
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1738
+ expected: util_js_1.ZodParsedType.number,
1739
+ received: ctx2.parsedType
1740
+ });
1741
+ return parseUtil_js_1.INVALID;
1742
+ }
1743
+ let ctx = void 0;
1744
+ const status = new parseUtil_js_1.ParseStatus();
1745
+ for (const check of this._def.checks) {
1746
+ if (check.kind === "int") {
1747
+ if (!util_js_1.util.isInteger(input.data)) {
1748
+ ctx = this._getOrReturnCtx(input, ctx);
1749
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1750
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
1751
+ expected: "integer",
1752
+ received: "float",
1753
+ message: check.message
1754
+ });
1755
+ status.dirty();
1756
+ }
1757
+ } else if (check.kind === "min") {
1758
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1759
+ if (tooSmall) {
1760
+ ctx = this._getOrReturnCtx(input, ctx);
1761
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1762
+ code: ZodError_js_1.ZodIssueCode.too_small,
1763
+ minimum: check.value,
1764
+ type: "number",
1765
+ inclusive: check.inclusive,
1766
+ exact: false,
1767
+ message: check.message
1768
+ });
1769
+ status.dirty();
1770
+ }
1771
+ } else if (check.kind === "max") {
1772
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1773
+ if (tooBig) {
1774
+ ctx = this._getOrReturnCtx(input, ctx);
1775
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1776
+ code: ZodError_js_1.ZodIssueCode.too_big,
1777
+ maximum: check.value,
1778
+ type: "number",
1779
+ inclusive: check.inclusive,
1780
+ exact: false,
1781
+ message: check.message
1782
+ });
1783
+ status.dirty();
1784
+ }
1785
+ } else if (check.kind === "multipleOf") {
1786
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1787
+ ctx = this._getOrReturnCtx(input, ctx);
1788
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1789
+ code: ZodError_js_1.ZodIssueCode.not_multiple_of,
1790
+ multipleOf: check.value,
1791
+ message: check.message
1792
+ });
1793
+ status.dirty();
1794
+ }
1795
+ } else if (check.kind === "finite") {
1796
+ if (!Number.isFinite(input.data)) {
1797
+ ctx = this._getOrReturnCtx(input, ctx);
1798
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1799
+ code: ZodError_js_1.ZodIssueCode.not_finite,
1800
+ message: check.message
1801
+ });
1802
+ status.dirty();
1803
+ }
1804
+ } else {
1805
+ util_js_1.util.assertNever(check);
1806
+ }
1807
+ }
1808
+ return { status: status.value, value: input.data };
1809
+ }
1810
+ gte(value, message) {
1811
+ return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
1812
+ }
1813
+ gt(value, message) {
1814
+ return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
1815
+ }
1816
+ lte(value, message) {
1817
+ return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
1818
+ }
1819
+ lt(value, message) {
1820
+ return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
1821
+ }
1822
+ setLimit(kind, value, inclusive, message) {
1823
+ return new _ZodNumber({
1824
+ ...this._def,
1825
+ checks: [
1826
+ ...this._def.checks,
1827
+ {
1828
+ kind,
1829
+ value,
1830
+ inclusive,
1831
+ message: errorUtil_js_1.errorUtil.toString(message)
1832
+ }
1833
+ ]
1834
+ });
1835
+ }
1836
+ _addCheck(check) {
1837
+ return new _ZodNumber({
1838
+ ...this._def,
1839
+ checks: [...this._def.checks, check]
1840
+ });
1841
+ }
1842
+ int(message) {
1843
+ return this._addCheck({
1844
+ kind: "int",
1845
+ message: errorUtil_js_1.errorUtil.toString(message)
1846
+ });
1847
+ }
1848
+ positive(message) {
1849
+ return this._addCheck({
1850
+ kind: "min",
1851
+ value: 0,
1852
+ inclusive: false,
1853
+ message: errorUtil_js_1.errorUtil.toString(message)
1854
+ });
1855
+ }
1856
+ negative(message) {
1857
+ return this._addCheck({
1858
+ kind: "max",
1859
+ value: 0,
1860
+ inclusive: false,
1861
+ message: errorUtil_js_1.errorUtil.toString(message)
1862
+ });
1863
+ }
1864
+ nonpositive(message) {
1865
+ return this._addCheck({
1866
+ kind: "max",
1867
+ value: 0,
1868
+ inclusive: true,
1869
+ message: errorUtil_js_1.errorUtil.toString(message)
1870
+ });
1871
+ }
1872
+ nonnegative(message) {
1873
+ return this._addCheck({
1874
+ kind: "min",
1875
+ value: 0,
1876
+ inclusive: true,
1877
+ message: errorUtil_js_1.errorUtil.toString(message)
1878
+ });
1879
+ }
1880
+ multipleOf(value, message) {
1881
+ return this._addCheck({
1882
+ kind: "multipleOf",
1883
+ value,
1884
+ message: errorUtil_js_1.errorUtil.toString(message)
1885
+ });
1886
+ }
1887
+ finite(message) {
1888
+ return this._addCheck({
1889
+ kind: "finite",
1890
+ message: errorUtil_js_1.errorUtil.toString(message)
1891
+ });
1892
+ }
1893
+ safe(message) {
1894
+ return this._addCheck({
1895
+ kind: "min",
1896
+ inclusive: true,
1897
+ value: Number.MIN_SAFE_INTEGER,
1898
+ message: errorUtil_js_1.errorUtil.toString(message)
1899
+ })._addCheck({
1900
+ kind: "max",
1901
+ inclusive: true,
1902
+ value: Number.MAX_SAFE_INTEGER,
1903
+ message: errorUtil_js_1.errorUtil.toString(message)
1904
+ });
1905
+ }
1906
+ get minValue() {
1907
+ let min = null;
1908
+ for (const ch of this._def.checks) {
1909
+ if (ch.kind === "min") {
1910
+ if (min === null || ch.value > min)
1911
+ min = ch.value;
1912
+ }
1913
+ }
1914
+ return min;
1915
+ }
1916
+ get maxValue() {
1917
+ let max = null;
1918
+ for (const ch of this._def.checks) {
1919
+ if (ch.kind === "max") {
1920
+ if (max === null || ch.value < max)
1921
+ max = ch.value;
1922
+ }
1923
+ }
1924
+ return max;
1925
+ }
1926
+ get isInt() {
1927
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util_js_1.util.isInteger(ch.value));
1928
+ }
1929
+ get isFinite() {
1930
+ let max = null;
1931
+ let min = null;
1932
+ for (const ch of this._def.checks) {
1933
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1934
+ return true;
1935
+ } else if (ch.kind === "min") {
1936
+ if (min === null || ch.value > min)
1937
+ min = ch.value;
1938
+ } else if (ch.kind === "max") {
1939
+ if (max === null || ch.value < max)
1940
+ max = ch.value;
1941
+ }
1942
+ }
1943
+ return Number.isFinite(min) && Number.isFinite(max);
1944
+ }
1945
+ };
1946
+ exports.ZodNumber = ZodNumber;
1947
+ ZodNumber.create = (params) => {
1948
+ return new ZodNumber({
1949
+ checks: [],
1950
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1951
+ coerce: params?.coerce || false,
1952
+ ...processCreateParams(params)
1953
+ });
1954
+ };
1955
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1956
+ constructor() {
1957
+ super(...arguments);
1958
+ this.min = this.gte;
1959
+ this.max = this.lte;
1960
+ }
1961
+ _parse(input) {
1962
+ if (this._def.coerce) {
1963
+ try {
1964
+ input.data = BigInt(input.data);
1965
+ } catch {
1966
+ return this._getInvalidInput(input);
1967
+ }
1968
+ }
1969
+ const parsedType = this._getType(input);
1970
+ if (parsedType !== util_js_1.ZodParsedType.bigint) {
1971
+ return this._getInvalidInput(input);
1972
+ }
1973
+ let ctx = void 0;
1974
+ const status = new parseUtil_js_1.ParseStatus();
1975
+ for (const check of this._def.checks) {
1976
+ if (check.kind === "min") {
1977
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1978
+ if (tooSmall) {
1979
+ ctx = this._getOrReturnCtx(input, ctx);
1980
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1981
+ code: ZodError_js_1.ZodIssueCode.too_small,
1982
+ type: "bigint",
1983
+ minimum: check.value,
1984
+ inclusive: check.inclusive,
1985
+ message: check.message
1986
+ });
1987
+ status.dirty();
1988
+ }
1989
+ } else if (check.kind === "max") {
1990
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1991
+ if (tooBig) {
1992
+ ctx = this._getOrReturnCtx(input, ctx);
1993
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
1994
+ code: ZodError_js_1.ZodIssueCode.too_big,
1995
+ type: "bigint",
1996
+ maximum: check.value,
1997
+ inclusive: check.inclusive,
1998
+ message: check.message
1999
+ });
2000
+ status.dirty();
2001
+ }
2002
+ } else if (check.kind === "multipleOf") {
2003
+ if (input.data % check.value !== BigInt(0)) {
2004
+ ctx = this._getOrReturnCtx(input, ctx);
2005
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2006
+ code: ZodError_js_1.ZodIssueCode.not_multiple_of,
2007
+ multipleOf: check.value,
2008
+ message: check.message
2009
+ });
2010
+ status.dirty();
2011
+ }
2012
+ } else {
2013
+ util_js_1.util.assertNever(check);
2014
+ }
2015
+ }
2016
+ return { status: status.value, value: input.data };
2017
+ }
2018
+ _getInvalidInput(input) {
2019
+ const ctx = this._getOrReturnCtx(input);
2020
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2021
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2022
+ expected: util_js_1.ZodParsedType.bigint,
2023
+ received: ctx.parsedType
2024
+ });
2025
+ return parseUtil_js_1.INVALID;
2026
+ }
2027
+ gte(value, message) {
2028
+ return this.setLimit("min", value, true, errorUtil_js_1.errorUtil.toString(message));
2029
+ }
2030
+ gt(value, message) {
2031
+ return this.setLimit("min", value, false, errorUtil_js_1.errorUtil.toString(message));
2032
+ }
2033
+ lte(value, message) {
2034
+ return this.setLimit("max", value, true, errorUtil_js_1.errorUtil.toString(message));
2035
+ }
2036
+ lt(value, message) {
2037
+ return this.setLimit("max", value, false, errorUtil_js_1.errorUtil.toString(message));
2038
+ }
2039
+ setLimit(kind, value, inclusive, message) {
2040
+ return new _ZodBigInt({
2041
+ ...this._def,
2042
+ checks: [
2043
+ ...this._def.checks,
2044
+ {
2045
+ kind,
2046
+ value,
2047
+ inclusive,
2048
+ message: errorUtil_js_1.errorUtil.toString(message)
2049
+ }
2050
+ ]
2051
+ });
2052
+ }
2053
+ _addCheck(check) {
2054
+ return new _ZodBigInt({
2055
+ ...this._def,
2056
+ checks: [...this._def.checks, check]
2057
+ });
2058
+ }
2059
+ positive(message) {
2060
+ return this._addCheck({
2061
+ kind: "min",
2062
+ value: BigInt(0),
2063
+ inclusive: false,
2064
+ message: errorUtil_js_1.errorUtil.toString(message)
2065
+ });
2066
+ }
2067
+ negative(message) {
2068
+ return this._addCheck({
2069
+ kind: "max",
2070
+ value: BigInt(0),
2071
+ inclusive: false,
2072
+ message: errorUtil_js_1.errorUtil.toString(message)
2073
+ });
2074
+ }
2075
+ nonpositive(message) {
2076
+ return this._addCheck({
2077
+ kind: "max",
2078
+ value: BigInt(0),
2079
+ inclusive: true,
2080
+ message: errorUtil_js_1.errorUtil.toString(message)
2081
+ });
2082
+ }
2083
+ nonnegative(message) {
2084
+ return this._addCheck({
2085
+ kind: "min",
2086
+ value: BigInt(0),
2087
+ inclusive: true,
2088
+ message: errorUtil_js_1.errorUtil.toString(message)
2089
+ });
2090
+ }
2091
+ multipleOf(value, message) {
2092
+ return this._addCheck({
2093
+ kind: "multipleOf",
2094
+ value,
2095
+ message: errorUtil_js_1.errorUtil.toString(message)
2096
+ });
2097
+ }
2098
+ get minValue() {
2099
+ let min = null;
2100
+ for (const ch of this._def.checks) {
2101
+ if (ch.kind === "min") {
2102
+ if (min === null || ch.value > min)
2103
+ min = ch.value;
2104
+ }
2105
+ }
2106
+ return min;
2107
+ }
2108
+ get maxValue() {
2109
+ let max = null;
2110
+ for (const ch of this._def.checks) {
2111
+ if (ch.kind === "max") {
2112
+ if (max === null || ch.value < max)
2113
+ max = ch.value;
2114
+ }
2115
+ }
2116
+ return max;
2117
+ }
2118
+ };
2119
+ exports.ZodBigInt = ZodBigInt;
2120
+ ZodBigInt.create = (params) => {
2121
+ return new ZodBigInt({
2122
+ checks: [],
2123
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2124
+ coerce: params?.coerce ?? false,
2125
+ ...processCreateParams(params)
2126
+ });
2127
+ };
2128
+ var ZodBoolean = class extends ZodType {
2129
+ _parse(input) {
2130
+ if (this._def.coerce) {
2131
+ input.data = Boolean(input.data);
2132
+ }
2133
+ const parsedType = this._getType(input);
2134
+ if (parsedType !== util_js_1.ZodParsedType.boolean) {
2135
+ const ctx = this._getOrReturnCtx(input);
2136
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2137
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2138
+ expected: util_js_1.ZodParsedType.boolean,
2139
+ received: ctx.parsedType
2140
+ });
2141
+ return parseUtil_js_1.INVALID;
2142
+ }
2143
+ return (0, parseUtil_js_1.OK)(input.data);
2144
+ }
2145
+ };
2146
+ exports.ZodBoolean = ZodBoolean;
2147
+ ZodBoolean.create = (params) => {
2148
+ return new ZodBoolean({
2149
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2150
+ coerce: params?.coerce || false,
2151
+ ...processCreateParams(params)
2152
+ });
2153
+ };
2154
+ var ZodDate = class _ZodDate extends ZodType {
2155
+ _parse(input) {
2156
+ if (this._def.coerce) {
2157
+ input.data = new Date(input.data);
2158
+ }
2159
+ const parsedType = this._getType(input);
2160
+ if (parsedType !== util_js_1.ZodParsedType.date) {
2161
+ const ctx2 = this._getOrReturnCtx(input);
2162
+ (0, parseUtil_js_1.addIssueToContext)(ctx2, {
2163
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2164
+ expected: util_js_1.ZodParsedType.date,
2165
+ received: ctx2.parsedType
2166
+ });
2167
+ return parseUtil_js_1.INVALID;
2168
+ }
2169
+ if (Number.isNaN(input.data.getTime())) {
2170
+ const ctx2 = this._getOrReturnCtx(input);
2171
+ (0, parseUtil_js_1.addIssueToContext)(ctx2, {
2172
+ code: ZodError_js_1.ZodIssueCode.invalid_date
2173
+ });
2174
+ return parseUtil_js_1.INVALID;
2175
+ }
2176
+ const status = new parseUtil_js_1.ParseStatus();
2177
+ let ctx = void 0;
2178
+ for (const check of this._def.checks) {
2179
+ if (check.kind === "min") {
2180
+ if (input.data.getTime() < check.value) {
2181
+ ctx = this._getOrReturnCtx(input, ctx);
2182
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2183
+ code: ZodError_js_1.ZodIssueCode.too_small,
2184
+ message: check.message,
2185
+ inclusive: true,
2186
+ exact: false,
2187
+ minimum: check.value,
2188
+ type: "date"
2189
+ });
2190
+ status.dirty();
2191
+ }
2192
+ } else if (check.kind === "max") {
2193
+ if (input.data.getTime() > check.value) {
2194
+ ctx = this._getOrReturnCtx(input, ctx);
2195
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2196
+ code: ZodError_js_1.ZodIssueCode.too_big,
2197
+ message: check.message,
2198
+ inclusive: true,
2199
+ exact: false,
2200
+ maximum: check.value,
2201
+ type: "date"
2202
+ });
2203
+ status.dirty();
2204
+ }
2205
+ } else {
2206
+ util_js_1.util.assertNever(check);
2207
+ }
2208
+ }
2209
+ return {
2210
+ status: status.value,
2211
+ value: new Date(input.data.getTime())
2212
+ };
2213
+ }
2214
+ _addCheck(check) {
2215
+ return new _ZodDate({
2216
+ ...this._def,
2217
+ checks: [...this._def.checks, check]
2218
+ });
2219
+ }
2220
+ min(minDate, message) {
2221
+ return this._addCheck({
2222
+ kind: "min",
2223
+ value: minDate.getTime(),
2224
+ message: errorUtil_js_1.errorUtil.toString(message)
2225
+ });
2226
+ }
2227
+ max(maxDate, message) {
2228
+ return this._addCheck({
2229
+ kind: "max",
2230
+ value: maxDate.getTime(),
2231
+ message: errorUtil_js_1.errorUtil.toString(message)
2232
+ });
2233
+ }
2234
+ get minDate() {
2235
+ let min = null;
2236
+ for (const ch of this._def.checks) {
2237
+ if (ch.kind === "min") {
2238
+ if (min === null || ch.value > min)
2239
+ min = ch.value;
2240
+ }
2241
+ }
2242
+ return min != null ? new Date(min) : null;
2243
+ }
2244
+ get maxDate() {
2245
+ let max = null;
2246
+ for (const ch of this._def.checks) {
2247
+ if (ch.kind === "max") {
2248
+ if (max === null || ch.value < max)
2249
+ max = ch.value;
2250
+ }
2251
+ }
2252
+ return max != null ? new Date(max) : null;
2253
+ }
2254
+ };
2255
+ exports.ZodDate = ZodDate;
2256
+ ZodDate.create = (params) => {
2257
+ return new ZodDate({
2258
+ checks: [],
2259
+ coerce: params?.coerce || false,
2260
+ typeName: ZodFirstPartyTypeKind.ZodDate,
2261
+ ...processCreateParams(params)
2262
+ });
2263
+ };
2264
+ var ZodSymbol = class extends ZodType {
2265
+ _parse(input) {
2266
+ const parsedType = this._getType(input);
2267
+ if (parsedType !== util_js_1.ZodParsedType.symbol) {
2268
+ const ctx = this._getOrReturnCtx(input);
2269
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2270
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2271
+ expected: util_js_1.ZodParsedType.symbol,
2272
+ received: ctx.parsedType
2273
+ });
2274
+ return parseUtil_js_1.INVALID;
2275
+ }
2276
+ return (0, parseUtil_js_1.OK)(input.data);
2277
+ }
2278
+ };
2279
+ exports.ZodSymbol = ZodSymbol;
2280
+ ZodSymbol.create = (params) => {
2281
+ return new ZodSymbol({
2282
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2283
+ ...processCreateParams(params)
2284
+ });
2285
+ };
2286
+ var ZodUndefined = class extends ZodType {
2287
+ _parse(input) {
2288
+ const parsedType = this._getType(input);
2289
+ if (parsedType !== util_js_1.ZodParsedType.undefined) {
2290
+ const ctx = this._getOrReturnCtx(input);
2291
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2292
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2293
+ expected: util_js_1.ZodParsedType.undefined,
2294
+ received: ctx.parsedType
2295
+ });
2296
+ return parseUtil_js_1.INVALID;
2297
+ }
2298
+ return (0, parseUtil_js_1.OK)(input.data);
2299
+ }
2300
+ };
2301
+ exports.ZodUndefined = ZodUndefined;
2302
+ ZodUndefined.create = (params) => {
2303
+ return new ZodUndefined({
2304
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2305
+ ...processCreateParams(params)
2306
+ });
2307
+ };
2308
+ var ZodNull = class extends ZodType {
2309
+ _parse(input) {
2310
+ const parsedType = this._getType(input);
2311
+ if (parsedType !== util_js_1.ZodParsedType.null) {
2312
+ const ctx = this._getOrReturnCtx(input);
2313
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2314
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2315
+ expected: util_js_1.ZodParsedType.null,
2316
+ received: ctx.parsedType
2317
+ });
2318
+ return parseUtil_js_1.INVALID;
2319
+ }
2320
+ return (0, parseUtil_js_1.OK)(input.data);
2321
+ }
2322
+ };
2323
+ exports.ZodNull = ZodNull;
2324
+ ZodNull.create = (params) => {
2325
+ return new ZodNull({
2326
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2327
+ ...processCreateParams(params)
2328
+ });
2329
+ };
2330
+ var ZodAny = class extends ZodType {
2331
+ constructor() {
2332
+ super(...arguments);
2333
+ this._any = true;
2334
+ }
2335
+ _parse(input) {
2336
+ return (0, parseUtil_js_1.OK)(input.data);
2337
+ }
2338
+ };
2339
+ exports.ZodAny = ZodAny;
2340
+ ZodAny.create = (params) => {
2341
+ return new ZodAny({
2342
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2343
+ ...processCreateParams(params)
2344
+ });
2345
+ };
2346
+ var ZodUnknown = class extends ZodType {
2347
+ constructor() {
2348
+ super(...arguments);
2349
+ this._unknown = true;
2350
+ }
2351
+ _parse(input) {
2352
+ return (0, parseUtil_js_1.OK)(input.data);
2353
+ }
2354
+ };
2355
+ exports.ZodUnknown = ZodUnknown;
2356
+ ZodUnknown.create = (params) => {
2357
+ return new ZodUnknown({
2358
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2359
+ ...processCreateParams(params)
2360
+ });
2361
+ };
2362
+ var ZodNever = class extends ZodType {
2363
+ _parse(input) {
2364
+ const ctx = this._getOrReturnCtx(input);
2365
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2366
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2367
+ expected: util_js_1.ZodParsedType.never,
2368
+ received: ctx.parsedType
2369
+ });
2370
+ return parseUtil_js_1.INVALID;
2371
+ }
2372
+ };
2373
+ exports.ZodNever = ZodNever;
2374
+ ZodNever.create = (params) => {
2375
+ return new ZodNever({
2376
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2377
+ ...processCreateParams(params)
2378
+ });
2379
+ };
2380
+ var ZodVoid = class extends ZodType {
2381
+ _parse(input) {
2382
+ const parsedType = this._getType(input);
2383
+ if (parsedType !== util_js_1.ZodParsedType.undefined) {
2384
+ const ctx = this._getOrReturnCtx(input);
2385
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2386
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2387
+ expected: util_js_1.ZodParsedType.void,
2388
+ received: ctx.parsedType
2389
+ });
2390
+ return parseUtil_js_1.INVALID;
2391
+ }
2392
+ return (0, parseUtil_js_1.OK)(input.data);
2393
+ }
2394
+ };
2395
+ exports.ZodVoid = ZodVoid;
2396
+ ZodVoid.create = (params) => {
2397
+ return new ZodVoid({
2398
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2399
+ ...processCreateParams(params)
2400
+ });
2401
+ };
2402
+ var ZodArray = class _ZodArray extends ZodType {
2403
+ _parse(input) {
2404
+ const { ctx, status } = this._processInputParams(input);
2405
+ const def = this._def;
2406
+ if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
2407
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2408
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2409
+ expected: util_js_1.ZodParsedType.array,
2410
+ received: ctx.parsedType
2411
+ });
2412
+ return parseUtil_js_1.INVALID;
2413
+ }
2414
+ if (def.exactLength !== null) {
2415
+ const tooBig = ctx.data.length > def.exactLength.value;
2416
+ const tooSmall = ctx.data.length < def.exactLength.value;
2417
+ if (tooBig || tooSmall) {
2418
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2419
+ code: tooBig ? ZodError_js_1.ZodIssueCode.too_big : ZodError_js_1.ZodIssueCode.too_small,
2420
+ minimum: tooSmall ? def.exactLength.value : void 0,
2421
+ maximum: tooBig ? def.exactLength.value : void 0,
2422
+ type: "array",
2423
+ inclusive: true,
2424
+ exact: true,
2425
+ message: def.exactLength.message
2426
+ });
2427
+ status.dirty();
2428
+ }
2429
+ }
2430
+ if (def.minLength !== null) {
2431
+ if (ctx.data.length < def.minLength.value) {
2432
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2433
+ code: ZodError_js_1.ZodIssueCode.too_small,
2434
+ minimum: def.minLength.value,
2435
+ type: "array",
2436
+ inclusive: true,
2437
+ exact: false,
2438
+ message: def.minLength.message
2439
+ });
2440
+ status.dirty();
2441
+ }
2442
+ }
2443
+ if (def.maxLength !== null) {
2444
+ if (ctx.data.length > def.maxLength.value) {
2445
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2446
+ code: ZodError_js_1.ZodIssueCode.too_big,
2447
+ maximum: def.maxLength.value,
2448
+ type: "array",
2449
+ inclusive: true,
2450
+ exact: false,
2451
+ message: def.maxLength.message
2452
+ });
2453
+ status.dirty();
2454
+ }
2455
+ }
2456
+ if (ctx.common.async) {
2457
+ return Promise.all([...ctx.data].map((item, i) => {
2458
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2459
+ })).then((result2) => {
2460
+ return parseUtil_js_1.ParseStatus.mergeArray(status, result2);
2461
+ });
2462
+ }
2463
+ const result = [...ctx.data].map((item, i) => {
2464
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2465
+ });
2466
+ return parseUtil_js_1.ParseStatus.mergeArray(status, result);
2467
+ }
2468
+ get element() {
2469
+ return this._def.type;
2470
+ }
2471
+ min(minLength, message) {
2472
+ return new _ZodArray({
2473
+ ...this._def,
2474
+ minLength: { value: minLength, message: errorUtil_js_1.errorUtil.toString(message) }
2475
+ });
2476
+ }
2477
+ max(maxLength, message) {
2478
+ return new _ZodArray({
2479
+ ...this._def,
2480
+ maxLength: { value: maxLength, message: errorUtil_js_1.errorUtil.toString(message) }
2481
+ });
2482
+ }
2483
+ length(len, message) {
2484
+ return new _ZodArray({
2485
+ ...this._def,
2486
+ exactLength: { value: len, message: errorUtil_js_1.errorUtil.toString(message) }
2487
+ });
2488
+ }
2489
+ nonempty(message) {
2490
+ return this.min(1, message);
2491
+ }
2492
+ };
2493
+ exports.ZodArray = ZodArray;
2494
+ ZodArray.create = (schema, params) => {
2495
+ return new ZodArray({
2496
+ type: schema,
2497
+ minLength: null,
2498
+ maxLength: null,
2499
+ exactLength: null,
2500
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2501
+ ...processCreateParams(params)
2502
+ });
2503
+ };
2504
+ function deepPartialify(schema) {
2505
+ if (schema instanceof ZodObject) {
2506
+ const newShape = {};
2507
+ for (const key in schema.shape) {
2508
+ const fieldSchema = schema.shape[key];
2509
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2510
+ }
2511
+ return new ZodObject({
2512
+ ...schema._def,
2513
+ shape: () => newShape
2514
+ });
2515
+ } else if (schema instanceof ZodArray) {
2516
+ return new ZodArray({
2517
+ ...schema._def,
2518
+ type: deepPartialify(schema.element)
2519
+ });
2520
+ } else if (schema instanceof ZodOptional) {
2521
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2522
+ } else if (schema instanceof ZodNullable) {
2523
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2524
+ } else if (schema instanceof ZodTuple) {
2525
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2526
+ } else {
2527
+ return schema;
2528
+ }
2529
+ }
2530
+ var ZodObject = class _ZodObject extends ZodType {
2531
+ constructor() {
2532
+ super(...arguments);
2533
+ this._cached = null;
2534
+ this.nonstrict = this.passthrough;
2535
+ this.augment = this.extend;
2536
+ }
2537
+ _getCached() {
2538
+ if (this._cached !== null)
2539
+ return this._cached;
2540
+ const shape = this._def.shape();
2541
+ const keys = util_js_1.util.objectKeys(shape);
2542
+ this._cached = { shape, keys };
2543
+ return this._cached;
2544
+ }
2545
+ _parse(input) {
2546
+ const parsedType = this._getType(input);
2547
+ if (parsedType !== util_js_1.ZodParsedType.object) {
2548
+ const ctx2 = this._getOrReturnCtx(input);
2549
+ (0, parseUtil_js_1.addIssueToContext)(ctx2, {
2550
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2551
+ expected: util_js_1.ZodParsedType.object,
2552
+ received: ctx2.parsedType
2553
+ });
2554
+ return parseUtil_js_1.INVALID;
2555
+ }
2556
+ const { status, ctx } = this._processInputParams(input);
2557
+ const { shape, keys: shapeKeys } = this._getCached();
2558
+ const extraKeys = [];
2559
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2560
+ for (const key in ctx.data) {
2561
+ if (!shapeKeys.includes(key)) {
2562
+ extraKeys.push(key);
2563
+ }
2564
+ }
2565
+ }
2566
+ const pairs = [];
2567
+ for (const key of shapeKeys) {
2568
+ const keyValidator = shape[key];
2569
+ const value = ctx.data[key];
2570
+ pairs.push({
2571
+ key: { status: "valid", value: key },
2572
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2573
+ alwaysSet: key in ctx.data
2574
+ });
2575
+ }
2576
+ if (this._def.catchall instanceof ZodNever) {
2577
+ const unknownKeys = this._def.unknownKeys;
2578
+ if (unknownKeys === "passthrough") {
2579
+ for (const key of extraKeys) {
2580
+ pairs.push({
2581
+ key: { status: "valid", value: key },
2582
+ value: { status: "valid", value: ctx.data[key] }
2583
+ });
2584
+ }
2585
+ } else if (unknownKeys === "strict") {
2586
+ if (extraKeys.length > 0) {
2587
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2588
+ code: ZodError_js_1.ZodIssueCode.unrecognized_keys,
2589
+ keys: extraKeys
2590
+ });
2591
+ status.dirty();
2592
+ }
2593
+ } else if (unknownKeys === "strip") {
2594
+ } else {
2595
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2596
+ }
2597
+ } else {
2598
+ const catchall = this._def.catchall;
2599
+ for (const key of extraKeys) {
2600
+ const value = ctx.data[key];
2601
+ pairs.push({
2602
+ key: { status: "valid", value: key },
2603
+ value: catchall._parse(
2604
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2605
+ //, ctx.child(key), value, getParsedType(value)
2606
+ ),
2607
+ alwaysSet: key in ctx.data
2608
+ });
2609
+ }
2610
+ }
2611
+ if (ctx.common.async) {
2612
+ return Promise.resolve().then(async () => {
2613
+ const syncPairs = [];
2614
+ for (const pair of pairs) {
2615
+ const key = await pair.key;
2616
+ const value = await pair.value;
2617
+ syncPairs.push({
2618
+ key,
2619
+ value,
2620
+ alwaysSet: pair.alwaysSet
2621
+ });
2622
+ }
2623
+ return syncPairs;
2624
+ }).then((syncPairs) => {
2625
+ return parseUtil_js_1.ParseStatus.mergeObjectSync(status, syncPairs);
2626
+ });
2627
+ } else {
2628
+ return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
2629
+ }
2630
+ }
2631
+ get shape() {
2632
+ return this._def.shape();
2633
+ }
2634
+ strict(message) {
2635
+ errorUtil_js_1.errorUtil.errToObj;
2636
+ return new _ZodObject({
2637
+ ...this._def,
2638
+ unknownKeys: "strict",
2639
+ ...message !== void 0 ? {
2640
+ errorMap: (issue, ctx) => {
2641
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2642
+ if (issue.code === "unrecognized_keys")
2643
+ return {
2644
+ message: errorUtil_js_1.errorUtil.errToObj(message).message ?? defaultError
2645
+ };
2646
+ return {
2647
+ message: defaultError
2648
+ };
2649
+ }
2650
+ } : {}
2651
+ });
2652
+ }
2653
+ strip() {
2654
+ return new _ZodObject({
2655
+ ...this._def,
2656
+ unknownKeys: "strip"
2657
+ });
2658
+ }
2659
+ passthrough() {
2660
+ return new _ZodObject({
2661
+ ...this._def,
2662
+ unknownKeys: "passthrough"
2663
+ });
2664
+ }
2665
+ // const AugmentFactory =
2666
+ // <Def extends ZodObjectDef>(def: Def) =>
2667
+ // <Augmentation extends ZodRawShape>(
2668
+ // augmentation: Augmentation
2669
+ // ): ZodObject<
2670
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2671
+ // Def["unknownKeys"],
2672
+ // Def["catchall"]
2673
+ // > => {
2674
+ // return new ZodObject({
2675
+ // ...def,
2676
+ // shape: () => ({
2677
+ // ...def.shape(),
2678
+ // ...augmentation,
2679
+ // }),
2680
+ // }) as any;
2681
+ // };
2682
+ extend(augmentation) {
2683
+ return new _ZodObject({
2684
+ ...this._def,
2685
+ shape: () => ({
2686
+ ...this._def.shape(),
2687
+ ...augmentation
2688
+ })
2689
+ });
2690
+ }
2691
+ /**
2692
+ * Prior to zod@1.0.12 there was a bug in the
2693
+ * inferred type of merged objects. Please
2694
+ * upgrade if you are experiencing issues.
2695
+ */
2696
+ merge(merging) {
2697
+ const merged = new _ZodObject({
2698
+ unknownKeys: merging._def.unknownKeys,
2699
+ catchall: merging._def.catchall,
2700
+ shape: () => ({
2701
+ ...this._def.shape(),
2702
+ ...merging._def.shape()
2703
+ }),
2704
+ typeName: ZodFirstPartyTypeKind.ZodObject
2705
+ });
2706
+ return merged;
2707
+ }
2708
+ // merge<
2709
+ // Incoming extends AnyZodObject,
2710
+ // Augmentation extends Incoming["shape"],
2711
+ // NewOutput extends {
2712
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2713
+ // ? Augmentation[k]["_output"]
2714
+ // : k extends keyof Output
2715
+ // ? Output[k]
2716
+ // : never;
2717
+ // },
2718
+ // NewInput extends {
2719
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2720
+ // ? Augmentation[k]["_input"]
2721
+ // : k extends keyof Input
2722
+ // ? Input[k]
2723
+ // : never;
2724
+ // }
2725
+ // >(
2726
+ // merging: Incoming
2727
+ // ): ZodObject<
2728
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2729
+ // Incoming["_def"]["unknownKeys"],
2730
+ // Incoming["_def"]["catchall"],
2731
+ // NewOutput,
2732
+ // NewInput
2733
+ // > {
2734
+ // const merged: any = new ZodObject({
2735
+ // unknownKeys: merging._def.unknownKeys,
2736
+ // catchall: merging._def.catchall,
2737
+ // shape: () =>
2738
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2739
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2740
+ // }) as any;
2741
+ // return merged;
2742
+ // }
2743
+ setKey(key, schema) {
2744
+ return this.augment({ [key]: schema });
2745
+ }
2746
+ // merge<Incoming extends AnyZodObject>(
2747
+ // merging: Incoming
2748
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2749
+ // ZodObject<
2750
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2751
+ // Incoming["_def"]["unknownKeys"],
2752
+ // Incoming["_def"]["catchall"]
2753
+ // > {
2754
+ // // const mergedShape = objectUtil.mergeShapes(
2755
+ // // this._def.shape(),
2756
+ // // merging._def.shape()
2757
+ // // );
2758
+ // const merged: any = new ZodObject({
2759
+ // unknownKeys: merging._def.unknownKeys,
2760
+ // catchall: merging._def.catchall,
2761
+ // shape: () =>
2762
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2763
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2764
+ // }) as any;
2765
+ // return merged;
2766
+ // }
2767
+ catchall(index) {
2768
+ return new _ZodObject({
2769
+ ...this._def,
2770
+ catchall: index
2771
+ });
2772
+ }
2773
+ pick(mask) {
2774
+ const shape = {};
2775
+ for (const key of util_js_1.util.objectKeys(mask)) {
2776
+ if (mask[key] && this.shape[key]) {
2777
+ shape[key] = this.shape[key];
2778
+ }
2779
+ }
2780
+ return new _ZodObject({
2781
+ ...this._def,
2782
+ shape: () => shape
2783
+ });
2784
+ }
2785
+ omit(mask) {
2786
+ const shape = {};
2787
+ for (const key of util_js_1.util.objectKeys(this.shape)) {
2788
+ if (!mask[key]) {
2789
+ shape[key] = this.shape[key];
2790
+ }
2791
+ }
2792
+ return new _ZodObject({
2793
+ ...this._def,
2794
+ shape: () => shape
2795
+ });
2796
+ }
2797
+ /**
2798
+ * @deprecated
2799
+ */
2800
+ deepPartial() {
2801
+ return deepPartialify(this);
2802
+ }
2803
+ partial(mask) {
2804
+ const newShape = {};
2805
+ for (const key of util_js_1.util.objectKeys(this.shape)) {
2806
+ const fieldSchema = this.shape[key];
2807
+ if (mask && !mask[key]) {
2808
+ newShape[key] = fieldSchema;
2809
+ } else {
2810
+ newShape[key] = fieldSchema.optional();
2811
+ }
2812
+ }
2813
+ return new _ZodObject({
2814
+ ...this._def,
2815
+ shape: () => newShape
2816
+ });
2817
+ }
2818
+ required(mask) {
2819
+ const newShape = {};
2820
+ for (const key of util_js_1.util.objectKeys(this.shape)) {
2821
+ if (mask && !mask[key]) {
2822
+ newShape[key] = this.shape[key];
2823
+ } else {
2824
+ const fieldSchema = this.shape[key];
2825
+ let newField = fieldSchema;
2826
+ while (newField instanceof ZodOptional) {
2827
+ newField = newField._def.innerType;
2828
+ }
2829
+ newShape[key] = newField;
2830
+ }
2831
+ }
2832
+ return new _ZodObject({
2833
+ ...this._def,
2834
+ shape: () => newShape
2835
+ });
2836
+ }
2837
+ keyof() {
2838
+ return createZodEnum(util_js_1.util.objectKeys(this.shape));
2839
+ }
2840
+ };
2841
+ exports.ZodObject = ZodObject;
2842
+ ZodObject.create = (shape, params) => {
2843
+ return new ZodObject({
2844
+ shape: () => shape,
2845
+ unknownKeys: "strip",
2846
+ catchall: ZodNever.create(),
2847
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2848
+ ...processCreateParams(params)
2849
+ });
2850
+ };
2851
+ ZodObject.strictCreate = (shape, params) => {
2852
+ return new ZodObject({
2853
+ shape: () => shape,
2854
+ unknownKeys: "strict",
2855
+ catchall: ZodNever.create(),
2856
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2857
+ ...processCreateParams(params)
2858
+ });
2859
+ };
2860
+ ZodObject.lazycreate = (shape, params) => {
2861
+ return new ZodObject({
2862
+ shape,
2863
+ unknownKeys: "strip",
2864
+ catchall: ZodNever.create(),
2865
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2866
+ ...processCreateParams(params)
2867
+ });
2868
+ };
2869
+ var ZodUnion = class extends ZodType {
2870
+ _parse(input) {
2871
+ const { ctx } = this._processInputParams(input);
2872
+ const options = this._def.options;
2873
+ function handleResults(results) {
2874
+ for (const result of results) {
2875
+ if (result.result.status === "valid") {
2876
+ return result.result;
2877
+ }
2878
+ }
2879
+ for (const result of results) {
2880
+ if (result.result.status === "dirty") {
2881
+ ctx.common.issues.push(...result.ctx.common.issues);
2882
+ return result.result;
2883
+ }
2884
+ }
2885
+ const unionErrors = results.map((result) => new ZodError_js_1.ZodError(result.ctx.common.issues));
2886
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2887
+ code: ZodError_js_1.ZodIssueCode.invalid_union,
2888
+ unionErrors
2889
+ });
2890
+ return parseUtil_js_1.INVALID;
2891
+ }
2892
+ if (ctx.common.async) {
2893
+ return Promise.all(options.map(async (option) => {
2894
+ const childCtx = {
2895
+ ...ctx,
2896
+ common: {
2897
+ ...ctx.common,
2898
+ issues: []
2899
+ },
2900
+ parent: null
2901
+ };
2902
+ return {
2903
+ result: await option._parseAsync({
2904
+ data: ctx.data,
2905
+ path: ctx.path,
2906
+ parent: childCtx
2907
+ }),
2908
+ ctx: childCtx
2909
+ };
2910
+ })).then(handleResults);
2911
+ } else {
2912
+ let dirty = void 0;
2913
+ const issues = [];
2914
+ for (const option of options) {
2915
+ const childCtx = {
2916
+ ...ctx,
2917
+ common: {
2918
+ ...ctx.common,
2919
+ issues: []
2920
+ },
2921
+ parent: null
2922
+ };
2923
+ const result = option._parseSync({
2924
+ data: ctx.data,
2925
+ path: ctx.path,
2926
+ parent: childCtx
2927
+ });
2928
+ if (result.status === "valid") {
2929
+ return result;
2930
+ } else if (result.status === "dirty" && !dirty) {
2931
+ dirty = { result, ctx: childCtx };
2932
+ }
2933
+ if (childCtx.common.issues.length) {
2934
+ issues.push(childCtx.common.issues);
2935
+ }
2936
+ }
2937
+ if (dirty) {
2938
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2939
+ return dirty.result;
2940
+ }
2941
+ const unionErrors = issues.map((issues2) => new ZodError_js_1.ZodError(issues2));
2942
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2943
+ code: ZodError_js_1.ZodIssueCode.invalid_union,
2944
+ unionErrors
2945
+ });
2946
+ return parseUtil_js_1.INVALID;
2947
+ }
2948
+ }
2949
+ get options() {
2950
+ return this._def.options;
2951
+ }
2952
+ };
2953
+ exports.ZodUnion = ZodUnion;
2954
+ ZodUnion.create = (types, params) => {
2955
+ return new ZodUnion({
2956
+ options: types,
2957
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2958
+ ...processCreateParams(params)
2959
+ });
2960
+ };
2961
+ var getDiscriminator = (type) => {
2962
+ if (type instanceof ZodLazy) {
2963
+ return getDiscriminator(type.schema);
2964
+ } else if (type instanceof ZodEffects) {
2965
+ return getDiscriminator(type.innerType());
2966
+ } else if (type instanceof ZodLiteral) {
2967
+ return [type.value];
2968
+ } else if (type instanceof ZodEnum) {
2969
+ return type.options;
2970
+ } else if (type instanceof ZodNativeEnum) {
2971
+ return util_js_1.util.objectValues(type.enum);
2972
+ } else if (type instanceof ZodDefault) {
2973
+ return getDiscriminator(type._def.innerType);
2974
+ } else if (type instanceof ZodUndefined) {
2975
+ return [void 0];
2976
+ } else if (type instanceof ZodNull) {
2977
+ return [null];
2978
+ } else if (type instanceof ZodOptional) {
2979
+ return [void 0, ...getDiscriminator(type.unwrap())];
2980
+ } else if (type instanceof ZodNullable) {
2981
+ return [null, ...getDiscriminator(type.unwrap())];
2982
+ } else if (type instanceof ZodBranded) {
2983
+ return getDiscriminator(type.unwrap());
2984
+ } else if (type instanceof ZodReadonly) {
2985
+ return getDiscriminator(type.unwrap());
2986
+ } else if (type instanceof ZodCatch) {
2987
+ return getDiscriminator(type._def.innerType);
2988
+ } else {
2989
+ return [];
2990
+ }
2991
+ };
2992
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2993
+ _parse(input) {
2994
+ const { ctx } = this._processInputParams(input);
2995
+ if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
2996
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
2997
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
2998
+ expected: util_js_1.ZodParsedType.object,
2999
+ received: ctx.parsedType
3000
+ });
3001
+ return parseUtil_js_1.INVALID;
3002
+ }
3003
+ const discriminator = this.discriminator;
3004
+ const discriminatorValue = ctx.data[discriminator];
3005
+ const option = this.optionsMap.get(discriminatorValue);
3006
+ if (!option) {
3007
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3008
+ code: ZodError_js_1.ZodIssueCode.invalid_union_discriminator,
3009
+ options: Array.from(this.optionsMap.keys()),
3010
+ path: [discriminator]
3011
+ });
3012
+ return parseUtil_js_1.INVALID;
3013
+ }
3014
+ if (ctx.common.async) {
3015
+ return option._parseAsync({
3016
+ data: ctx.data,
3017
+ path: ctx.path,
3018
+ parent: ctx
3019
+ });
3020
+ } else {
3021
+ return option._parseSync({
3022
+ data: ctx.data,
3023
+ path: ctx.path,
3024
+ parent: ctx
3025
+ });
3026
+ }
3027
+ }
3028
+ get discriminator() {
3029
+ return this._def.discriminator;
3030
+ }
3031
+ get options() {
3032
+ return this._def.options;
3033
+ }
3034
+ get optionsMap() {
3035
+ return this._def.optionsMap;
3036
+ }
3037
+ /**
3038
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3039
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3040
+ * have a different value for each object in the union.
3041
+ * @param discriminator the name of the discriminator property
3042
+ * @param types an array of object schemas
3043
+ * @param params
3044
+ */
3045
+ static create(discriminator, options, params) {
3046
+ const optionsMap = /* @__PURE__ */ new Map();
3047
+ for (const type of options) {
3048
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3049
+ if (!discriminatorValues.length) {
3050
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3051
+ }
3052
+ for (const value of discriminatorValues) {
3053
+ if (optionsMap.has(value)) {
3054
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3055
+ }
3056
+ optionsMap.set(value, type);
3057
+ }
3058
+ }
3059
+ return new _ZodDiscriminatedUnion({
3060
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3061
+ discriminator,
3062
+ options,
3063
+ optionsMap,
3064
+ ...processCreateParams(params)
3065
+ });
3066
+ }
3067
+ };
3068
+ exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
3069
+ function mergeValues(a, b) {
3070
+ const aType = (0, util_js_1.getParsedType)(a);
3071
+ const bType = (0, util_js_1.getParsedType)(b);
3072
+ if (a === b) {
3073
+ return { valid: true, data: a };
3074
+ } else if (aType === util_js_1.ZodParsedType.object && bType === util_js_1.ZodParsedType.object) {
3075
+ const bKeys = util_js_1.util.objectKeys(b);
3076
+ const sharedKeys = util_js_1.util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3077
+ const newObj = { ...a, ...b };
3078
+ for (const key of sharedKeys) {
3079
+ const sharedValue = mergeValues(a[key], b[key]);
3080
+ if (!sharedValue.valid) {
3081
+ return { valid: false };
3082
+ }
3083
+ newObj[key] = sharedValue.data;
3084
+ }
3085
+ return { valid: true, data: newObj };
3086
+ } else if (aType === util_js_1.ZodParsedType.array && bType === util_js_1.ZodParsedType.array) {
3087
+ if (a.length !== b.length) {
3088
+ return { valid: false };
3089
+ }
3090
+ const newArray = [];
3091
+ for (let index = 0; index < a.length; index++) {
3092
+ const itemA = a[index];
3093
+ const itemB = b[index];
3094
+ const sharedValue = mergeValues(itemA, itemB);
3095
+ if (!sharedValue.valid) {
3096
+ return { valid: false };
3097
+ }
3098
+ newArray.push(sharedValue.data);
3099
+ }
3100
+ return { valid: true, data: newArray };
3101
+ } else if (aType === util_js_1.ZodParsedType.date && bType === util_js_1.ZodParsedType.date && +a === +b) {
3102
+ return { valid: true, data: a };
3103
+ } else {
3104
+ return { valid: false };
3105
+ }
3106
+ }
3107
+ var ZodIntersection = class extends ZodType {
3108
+ _parse(input) {
3109
+ const { status, ctx } = this._processInputParams(input);
3110
+ const handleParsed = (parsedLeft, parsedRight) => {
3111
+ if ((0, parseUtil_js_1.isAborted)(parsedLeft) || (0, parseUtil_js_1.isAborted)(parsedRight)) {
3112
+ return parseUtil_js_1.INVALID;
3113
+ }
3114
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3115
+ if (!merged.valid) {
3116
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3117
+ code: ZodError_js_1.ZodIssueCode.invalid_intersection_types
3118
+ });
3119
+ return parseUtil_js_1.INVALID;
3120
+ }
3121
+ if ((0, parseUtil_js_1.isDirty)(parsedLeft) || (0, parseUtil_js_1.isDirty)(parsedRight)) {
3122
+ status.dirty();
3123
+ }
3124
+ return { status: status.value, value: merged.data };
3125
+ };
3126
+ if (ctx.common.async) {
3127
+ return Promise.all([
3128
+ this._def.left._parseAsync({
3129
+ data: ctx.data,
3130
+ path: ctx.path,
3131
+ parent: ctx
3132
+ }),
3133
+ this._def.right._parseAsync({
3134
+ data: ctx.data,
3135
+ path: ctx.path,
3136
+ parent: ctx
3137
+ })
3138
+ ]).then(([left, right]) => handleParsed(left, right));
3139
+ } else {
3140
+ return handleParsed(this._def.left._parseSync({
3141
+ data: ctx.data,
3142
+ path: ctx.path,
3143
+ parent: ctx
3144
+ }), this._def.right._parseSync({
3145
+ data: ctx.data,
3146
+ path: ctx.path,
3147
+ parent: ctx
3148
+ }));
3149
+ }
3150
+ }
3151
+ };
3152
+ exports.ZodIntersection = ZodIntersection;
3153
+ ZodIntersection.create = (left, right, params) => {
3154
+ return new ZodIntersection({
3155
+ left,
3156
+ right,
3157
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3158
+ ...processCreateParams(params)
3159
+ });
3160
+ };
3161
+ var ZodTuple = class _ZodTuple extends ZodType {
3162
+ _parse(input) {
3163
+ const { status, ctx } = this._processInputParams(input);
3164
+ if (ctx.parsedType !== util_js_1.ZodParsedType.array) {
3165
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3166
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3167
+ expected: util_js_1.ZodParsedType.array,
3168
+ received: ctx.parsedType
3169
+ });
3170
+ return parseUtil_js_1.INVALID;
3171
+ }
3172
+ if (ctx.data.length < this._def.items.length) {
3173
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3174
+ code: ZodError_js_1.ZodIssueCode.too_small,
3175
+ minimum: this._def.items.length,
3176
+ inclusive: true,
3177
+ exact: false,
3178
+ type: "array"
3179
+ });
3180
+ return parseUtil_js_1.INVALID;
3181
+ }
3182
+ const rest = this._def.rest;
3183
+ if (!rest && ctx.data.length > this._def.items.length) {
3184
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3185
+ code: ZodError_js_1.ZodIssueCode.too_big,
3186
+ maximum: this._def.items.length,
3187
+ inclusive: true,
3188
+ exact: false,
3189
+ type: "array"
3190
+ });
3191
+ status.dirty();
3192
+ }
3193
+ const items = [...ctx.data].map((item, itemIndex) => {
3194
+ const schema = this._def.items[itemIndex] || this._def.rest;
3195
+ if (!schema)
3196
+ return null;
3197
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3198
+ }).filter((x) => !!x);
3199
+ if (ctx.common.async) {
3200
+ return Promise.all(items).then((results) => {
3201
+ return parseUtil_js_1.ParseStatus.mergeArray(status, results);
3202
+ });
3203
+ } else {
3204
+ return parseUtil_js_1.ParseStatus.mergeArray(status, items);
3205
+ }
3206
+ }
3207
+ get items() {
3208
+ return this._def.items;
3209
+ }
3210
+ rest(rest) {
3211
+ return new _ZodTuple({
3212
+ ...this._def,
3213
+ rest
3214
+ });
3215
+ }
3216
+ };
3217
+ exports.ZodTuple = ZodTuple;
3218
+ ZodTuple.create = (schemas, params) => {
3219
+ if (!Array.isArray(schemas)) {
3220
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3221
+ }
3222
+ return new ZodTuple({
3223
+ items: schemas,
3224
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3225
+ rest: null,
3226
+ ...processCreateParams(params)
3227
+ });
3228
+ };
3229
+ var ZodRecord = class _ZodRecord extends ZodType {
3230
+ get keySchema() {
3231
+ return this._def.keyType;
3232
+ }
3233
+ get valueSchema() {
3234
+ return this._def.valueType;
3235
+ }
3236
+ _parse(input) {
3237
+ const { status, ctx } = this._processInputParams(input);
3238
+ if (ctx.parsedType !== util_js_1.ZodParsedType.object) {
3239
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3240
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3241
+ expected: util_js_1.ZodParsedType.object,
3242
+ received: ctx.parsedType
3243
+ });
3244
+ return parseUtil_js_1.INVALID;
3245
+ }
3246
+ const pairs = [];
3247
+ const keyType = this._def.keyType;
3248
+ const valueType = this._def.valueType;
3249
+ for (const key in ctx.data) {
3250
+ pairs.push({
3251
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3252
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3253
+ alwaysSet: key in ctx.data
3254
+ });
3255
+ }
3256
+ if (ctx.common.async) {
3257
+ return parseUtil_js_1.ParseStatus.mergeObjectAsync(status, pairs);
3258
+ } else {
3259
+ return parseUtil_js_1.ParseStatus.mergeObjectSync(status, pairs);
3260
+ }
3261
+ }
3262
+ get element() {
3263
+ return this._def.valueType;
3264
+ }
3265
+ static create(first, second, third) {
3266
+ if (second instanceof ZodType) {
3267
+ return new _ZodRecord({
3268
+ keyType: first,
3269
+ valueType: second,
3270
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3271
+ ...processCreateParams(third)
3272
+ });
3273
+ }
3274
+ return new _ZodRecord({
3275
+ keyType: ZodString.create(),
3276
+ valueType: first,
3277
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3278
+ ...processCreateParams(second)
3279
+ });
3280
+ }
3281
+ };
3282
+ exports.ZodRecord = ZodRecord;
3283
+ var ZodMap = class extends ZodType {
3284
+ get keySchema() {
3285
+ return this._def.keyType;
3286
+ }
3287
+ get valueSchema() {
3288
+ return this._def.valueType;
3289
+ }
3290
+ _parse(input) {
3291
+ const { status, ctx } = this._processInputParams(input);
3292
+ if (ctx.parsedType !== util_js_1.ZodParsedType.map) {
3293
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3294
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3295
+ expected: util_js_1.ZodParsedType.map,
3296
+ received: ctx.parsedType
3297
+ });
3298
+ return parseUtil_js_1.INVALID;
3299
+ }
3300
+ const keyType = this._def.keyType;
3301
+ const valueType = this._def.valueType;
3302
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3303
+ return {
3304
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3305
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3306
+ };
3307
+ });
3308
+ if (ctx.common.async) {
3309
+ const finalMap = /* @__PURE__ */ new Map();
3310
+ return Promise.resolve().then(async () => {
3311
+ for (const pair of pairs) {
3312
+ const key = await pair.key;
3313
+ const value = await pair.value;
3314
+ if (key.status === "aborted" || value.status === "aborted") {
3315
+ return parseUtil_js_1.INVALID;
3316
+ }
3317
+ if (key.status === "dirty" || value.status === "dirty") {
3318
+ status.dirty();
3319
+ }
3320
+ finalMap.set(key.value, value.value);
3321
+ }
3322
+ return { status: status.value, value: finalMap };
3323
+ });
3324
+ } else {
3325
+ const finalMap = /* @__PURE__ */ new Map();
3326
+ for (const pair of pairs) {
3327
+ const key = pair.key;
3328
+ const value = pair.value;
3329
+ if (key.status === "aborted" || value.status === "aborted") {
3330
+ return parseUtil_js_1.INVALID;
3331
+ }
3332
+ if (key.status === "dirty" || value.status === "dirty") {
3333
+ status.dirty();
3334
+ }
3335
+ finalMap.set(key.value, value.value);
3336
+ }
3337
+ return { status: status.value, value: finalMap };
3338
+ }
3339
+ }
3340
+ };
3341
+ exports.ZodMap = ZodMap;
3342
+ ZodMap.create = (keyType, valueType, params) => {
3343
+ return new ZodMap({
3344
+ valueType,
3345
+ keyType,
3346
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3347
+ ...processCreateParams(params)
3348
+ });
3349
+ };
3350
+ var ZodSet = class _ZodSet extends ZodType {
3351
+ _parse(input) {
3352
+ const { status, ctx } = this._processInputParams(input);
3353
+ if (ctx.parsedType !== util_js_1.ZodParsedType.set) {
3354
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3355
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3356
+ expected: util_js_1.ZodParsedType.set,
3357
+ received: ctx.parsedType
3358
+ });
3359
+ return parseUtil_js_1.INVALID;
3360
+ }
3361
+ const def = this._def;
3362
+ if (def.minSize !== null) {
3363
+ if (ctx.data.size < def.minSize.value) {
3364
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3365
+ code: ZodError_js_1.ZodIssueCode.too_small,
3366
+ minimum: def.minSize.value,
3367
+ type: "set",
3368
+ inclusive: true,
3369
+ exact: false,
3370
+ message: def.minSize.message
3371
+ });
3372
+ status.dirty();
3373
+ }
3374
+ }
3375
+ if (def.maxSize !== null) {
3376
+ if (ctx.data.size > def.maxSize.value) {
3377
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3378
+ code: ZodError_js_1.ZodIssueCode.too_big,
3379
+ maximum: def.maxSize.value,
3380
+ type: "set",
3381
+ inclusive: true,
3382
+ exact: false,
3383
+ message: def.maxSize.message
3384
+ });
3385
+ status.dirty();
3386
+ }
3387
+ }
3388
+ const valueType = this._def.valueType;
3389
+ function finalizeSet(elements2) {
3390
+ const parsedSet = /* @__PURE__ */ new Set();
3391
+ for (const element of elements2) {
3392
+ if (element.status === "aborted")
3393
+ return parseUtil_js_1.INVALID;
3394
+ if (element.status === "dirty")
3395
+ status.dirty();
3396
+ parsedSet.add(element.value);
3397
+ }
3398
+ return { status: status.value, value: parsedSet };
3399
+ }
3400
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
3401
+ if (ctx.common.async) {
3402
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3403
+ } else {
3404
+ return finalizeSet(elements);
3405
+ }
3406
+ }
3407
+ min(minSize, message) {
3408
+ return new _ZodSet({
3409
+ ...this._def,
3410
+ minSize: { value: minSize, message: errorUtil_js_1.errorUtil.toString(message) }
3411
+ });
3412
+ }
3413
+ max(maxSize, message) {
3414
+ return new _ZodSet({
3415
+ ...this._def,
3416
+ maxSize: { value: maxSize, message: errorUtil_js_1.errorUtil.toString(message) }
3417
+ });
3418
+ }
3419
+ size(size, message) {
3420
+ return this.min(size, message).max(size, message);
3421
+ }
3422
+ nonempty(message) {
3423
+ return this.min(1, message);
3424
+ }
3425
+ };
3426
+ exports.ZodSet = ZodSet;
3427
+ ZodSet.create = (valueType, params) => {
3428
+ return new ZodSet({
3429
+ valueType,
3430
+ minSize: null,
3431
+ maxSize: null,
3432
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3433
+ ...processCreateParams(params)
3434
+ });
3435
+ };
3436
+ var ZodFunction = class _ZodFunction extends ZodType {
3437
+ constructor() {
3438
+ super(...arguments);
3439
+ this.validate = this.implement;
3440
+ }
3441
+ _parse(input) {
3442
+ const { ctx } = this._processInputParams(input);
3443
+ if (ctx.parsedType !== util_js_1.ZodParsedType.function) {
3444
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3445
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3446
+ expected: util_js_1.ZodParsedType.function,
3447
+ received: ctx.parsedType
3448
+ });
3449
+ return parseUtil_js_1.INVALID;
3450
+ }
3451
+ function makeArgsIssue(args, error2) {
3452
+ return (0, parseUtil_js_1.makeIssue)({
3453
+ data: args,
3454
+ path: ctx.path,
3455
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_js_1.getErrorMap)(), errors_js_1.defaultErrorMap].filter((x) => !!x),
3456
+ issueData: {
3457
+ code: ZodError_js_1.ZodIssueCode.invalid_arguments,
3458
+ argumentsError: error2
3459
+ }
3460
+ });
3461
+ }
3462
+ function makeReturnsIssue(returns, error2) {
3463
+ return (0, parseUtil_js_1.makeIssue)({
3464
+ data: returns,
3465
+ path: ctx.path,
3466
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, (0, errors_js_1.getErrorMap)(), errors_js_1.defaultErrorMap].filter((x) => !!x),
3467
+ issueData: {
3468
+ code: ZodError_js_1.ZodIssueCode.invalid_return_type,
3469
+ returnTypeError: error2
3470
+ }
3471
+ });
3472
+ }
3473
+ const params = { errorMap: ctx.common.contextualErrorMap };
3474
+ const fn = ctx.data;
3475
+ if (this._def.returns instanceof ZodPromise) {
3476
+ const me = this;
3477
+ return (0, parseUtil_js_1.OK)(async function(...args) {
3478
+ const error2 = new ZodError_js_1.ZodError([]);
3479
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3480
+ error2.addIssue(makeArgsIssue(args, e));
3481
+ throw error2;
3482
+ });
3483
+ const result = await Reflect.apply(fn, this, parsedArgs);
3484
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3485
+ error2.addIssue(makeReturnsIssue(result, e));
3486
+ throw error2;
3487
+ });
3488
+ return parsedReturns;
3489
+ });
3490
+ } else {
3491
+ const me = this;
3492
+ return (0, parseUtil_js_1.OK)(function(...args) {
3493
+ const parsedArgs = me._def.args.safeParse(args, params);
3494
+ if (!parsedArgs.success) {
3495
+ throw new ZodError_js_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
3496
+ }
3497
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3498
+ const parsedReturns = me._def.returns.safeParse(result, params);
3499
+ if (!parsedReturns.success) {
3500
+ throw new ZodError_js_1.ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3501
+ }
3502
+ return parsedReturns.data;
3503
+ });
3504
+ }
3505
+ }
3506
+ parameters() {
3507
+ return this._def.args;
3508
+ }
3509
+ returnType() {
3510
+ return this._def.returns;
3511
+ }
3512
+ args(...items) {
3513
+ return new _ZodFunction({
3514
+ ...this._def,
3515
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3516
+ });
3517
+ }
3518
+ returns(returnType) {
3519
+ return new _ZodFunction({
3520
+ ...this._def,
3521
+ returns: returnType
3522
+ });
3523
+ }
3524
+ implement(func) {
3525
+ const validatedFunc = this.parse(func);
3526
+ return validatedFunc;
3527
+ }
3528
+ strictImplement(func) {
3529
+ const validatedFunc = this.parse(func);
3530
+ return validatedFunc;
3531
+ }
3532
+ static create(args, returns, params) {
3533
+ return new _ZodFunction({
3534
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3535
+ returns: returns || ZodUnknown.create(),
3536
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3537
+ ...processCreateParams(params)
3538
+ });
3539
+ }
3540
+ };
3541
+ exports.ZodFunction = ZodFunction;
3542
+ var ZodLazy = class extends ZodType {
3543
+ get schema() {
3544
+ return this._def.getter();
3545
+ }
3546
+ _parse(input) {
3547
+ const { ctx } = this._processInputParams(input);
3548
+ const lazySchema = this._def.getter();
3549
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3550
+ }
3551
+ };
3552
+ exports.ZodLazy = ZodLazy;
3553
+ ZodLazy.create = (getter, params) => {
3554
+ return new ZodLazy({
3555
+ getter,
3556
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3557
+ ...processCreateParams(params)
3558
+ });
3559
+ };
3560
+ var ZodLiteral = class extends ZodType {
3561
+ _parse(input) {
3562
+ if (input.data !== this._def.value) {
3563
+ const ctx = this._getOrReturnCtx(input);
3564
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3565
+ received: ctx.data,
3566
+ code: ZodError_js_1.ZodIssueCode.invalid_literal,
3567
+ expected: this._def.value
3568
+ });
3569
+ return parseUtil_js_1.INVALID;
3570
+ }
3571
+ return { status: "valid", value: input.data };
3572
+ }
3573
+ get value() {
3574
+ return this._def.value;
3575
+ }
3576
+ };
3577
+ exports.ZodLiteral = ZodLiteral;
3578
+ ZodLiteral.create = (value, params) => {
3579
+ return new ZodLiteral({
3580
+ value,
3581
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3582
+ ...processCreateParams(params)
3583
+ });
3584
+ };
3585
+ function createZodEnum(values, params) {
3586
+ return new ZodEnum({
3587
+ values,
3588
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3589
+ ...processCreateParams(params)
3590
+ });
3591
+ }
3592
+ var ZodEnum = class _ZodEnum extends ZodType {
3593
+ _parse(input) {
3594
+ if (typeof input.data !== "string") {
3595
+ const ctx = this._getOrReturnCtx(input);
3596
+ const expectedValues = this._def.values;
3597
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3598
+ expected: util_js_1.util.joinValues(expectedValues),
3599
+ received: ctx.parsedType,
3600
+ code: ZodError_js_1.ZodIssueCode.invalid_type
3601
+ });
3602
+ return parseUtil_js_1.INVALID;
3603
+ }
3604
+ if (!this._cache) {
3605
+ this._cache = new Set(this._def.values);
3606
+ }
3607
+ if (!this._cache.has(input.data)) {
3608
+ const ctx = this._getOrReturnCtx(input);
3609
+ const expectedValues = this._def.values;
3610
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3611
+ received: ctx.data,
3612
+ code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3613
+ options: expectedValues
3614
+ });
3615
+ return parseUtil_js_1.INVALID;
3616
+ }
3617
+ return (0, parseUtil_js_1.OK)(input.data);
3618
+ }
3619
+ get options() {
3620
+ return this._def.values;
3621
+ }
3622
+ get enum() {
3623
+ const enumValues = {};
3624
+ for (const val of this._def.values) {
3625
+ enumValues[val] = val;
3626
+ }
3627
+ return enumValues;
3628
+ }
3629
+ get Values() {
3630
+ const enumValues = {};
3631
+ for (const val of this._def.values) {
3632
+ enumValues[val] = val;
3633
+ }
3634
+ return enumValues;
3635
+ }
3636
+ get Enum() {
3637
+ const enumValues = {};
3638
+ for (const val of this._def.values) {
3639
+ enumValues[val] = val;
3640
+ }
3641
+ return enumValues;
3642
+ }
3643
+ extract(values, newDef = this._def) {
3644
+ return _ZodEnum.create(values, {
3645
+ ...this._def,
3646
+ ...newDef
3647
+ });
3648
+ }
3649
+ exclude(values, newDef = this._def) {
3650
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3651
+ ...this._def,
3652
+ ...newDef
3653
+ });
3654
+ }
3655
+ };
3656
+ exports.ZodEnum = ZodEnum;
3657
+ ZodEnum.create = createZodEnum;
3658
+ var ZodNativeEnum = class extends ZodType {
3659
+ _parse(input) {
3660
+ const nativeEnumValues = util_js_1.util.getValidEnumValues(this._def.values);
3661
+ const ctx = this._getOrReturnCtx(input);
3662
+ if (ctx.parsedType !== util_js_1.ZodParsedType.string && ctx.parsedType !== util_js_1.ZodParsedType.number) {
3663
+ const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3664
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3665
+ expected: util_js_1.util.joinValues(expectedValues),
3666
+ received: ctx.parsedType,
3667
+ code: ZodError_js_1.ZodIssueCode.invalid_type
3668
+ });
3669
+ return parseUtil_js_1.INVALID;
3670
+ }
3671
+ if (!this._cache) {
3672
+ this._cache = new Set(util_js_1.util.getValidEnumValues(this._def.values));
3673
+ }
3674
+ if (!this._cache.has(input.data)) {
3675
+ const expectedValues = util_js_1.util.objectValues(nativeEnumValues);
3676
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3677
+ received: ctx.data,
3678
+ code: ZodError_js_1.ZodIssueCode.invalid_enum_value,
3679
+ options: expectedValues
3680
+ });
3681
+ return parseUtil_js_1.INVALID;
3682
+ }
3683
+ return (0, parseUtil_js_1.OK)(input.data);
3684
+ }
3685
+ get enum() {
3686
+ return this._def.values;
3687
+ }
3688
+ };
3689
+ exports.ZodNativeEnum = ZodNativeEnum;
3690
+ ZodNativeEnum.create = (values, params) => {
3691
+ return new ZodNativeEnum({
3692
+ values,
3693
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3694
+ ...processCreateParams(params)
3695
+ });
3696
+ };
3697
+ var ZodPromise = class extends ZodType {
3698
+ unwrap() {
3699
+ return this._def.type;
3700
+ }
3701
+ _parse(input) {
3702
+ const { ctx } = this._processInputParams(input);
3703
+ if (ctx.parsedType !== util_js_1.ZodParsedType.promise && ctx.common.async === false) {
3704
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3705
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3706
+ expected: util_js_1.ZodParsedType.promise,
3707
+ received: ctx.parsedType
3708
+ });
3709
+ return parseUtil_js_1.INVALID;
3710
+ }
3711
+ const promisified = ctx.parsedType === util_js_1.ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3712
+ return (0, parseUtil_js_1.OK)(promisified.then((data) => {
3713
+ return this._def.type.parseAsync(data, {
3714
+ path: ctx.path,
3715
+ errorMap: ctx.common.contextualErrorMap
3716
+ });
3717
+ }));
3718
+ }
3719
+ };
3720
+ exports.ZodPromise = ZodPromise;
3721
+ ZodPromise.create = (schema, params) => {
3722
+ return new ZodPromise({
3723
+ type: schema,
3724
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3725
+ ...processCreateParams(params)
3726
+ });
3727
+ };
3728
+ var ZodEffects = class extends ZodType {
3729
+ innerType() {
3730
+ return this._def.schema;
3731
+ }
3732
+ sourceType() {
3733
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3734
+ }
3735
+ _parse(input) {
3736
+ const { status, ctx } = this._processInputParams(input);
3737
+ const effect = this._def.effect || null;
3738
+ const checkCtx = {
3739
+ addIssue: (arg) => {
3740
+ (0, parseUtil_js_1.addIssueToContext)(ctx, arg);
3741
+ if (arg.fatal) {
3742
+ status.abort();
3743
+ } else {
3744
+ status.dirty();
3745
+ }
3746
+ },
3747
+ get path() {
3748
+ return ctx.path;
3749
+ }
3750
+ };
3751
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3752
+ if (effect.type === "preprocess") {
3753
+ const processed = effect.transform(ctx.data, checkCtx);
3754
+ if (ctx.common.async) {
3755
+ return Promise.resolve(processed).then(async (processed2) => {
3756
+ if (status.value === "aborted")
3757
+ return parseUtil_js_1.INVALID;
3758
+ const result = await this._def.schema._parseAsync({
3759
+ data: processed2,
3760
+ path: ctx.path,
3761
+ parent: ctx
3762
+ });
3763
+ if (result.status === "aborted")
3764
+ return parseUtil_js_1.INVALID;
3765
+ if (result.status === "dirty")
3766
+ return (0, parseUtil_js_1.DIRTY)(result.value);
3767
+ if (status.value === "dirty")
3768
+ return (0, parseUtil_js_1.DIRTY)(result.value);
3769
+ return result;
3770
+ });
3771
+ } else {
3772
+ if (status.value === "aborted")
3773
+ return parseUtil_js_1.INVALID;
3774
+ const result = this._def.schema._parseSync({
3775
+ data: processed,
3776
+ path: ctx.path,
3777
+ parent: ctx
3778
+ });
3779
+ if (result.status === "aborted")
3780
+ return parseUtil_js_1.INVALID;
3781
+ if (result.status === "dirty")
3782
+ return (0, parseUtil_js_1.DIRTY)(result.value);
3783
+ if (status.value === "dirty")
3784
+ return (0, parseUtil_js_1.DIRTY)(result.value);
3785
+ return result;
3786
+ }
3787
+ }
3788
+ if (effect.type === "refinement") {
3789
+ const executeRefinement = (acc) => {
3790
+ const result = effect.refinement(acc, checkCtx);
3791
+ if (ctx.common.async) {
3792
+ return Promise.resolve(result);
3793
+ }
3794
+ if (result instanceof Promise) {
3795
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3796
+ }
3797
+ return acc;
3798
+ };
3799
+ if (ctx.common.async === false) {
3800
+ const inner = this._def.schema._parseSync({
3801
+ data: ctx.data,
3802
+ path: ctx.path,
3803
+ parent: ctx
3804
+ });
3805
+ if (inner.status === "aborted")
3806
+ return parseUtil_js_1.INVALID;
3807
+ if (inner.status === "dirty")
3808
+ status.dirty();
3809
+ executeRefinement(inner.value);
3810
+ return { status: status.value, value: inner.value };
3811
+ } else {
3812
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3813
+ if (inner.status === "aborted")
3814
+ return parseUtil_js_1.INVALID;
3815
+ if (inner.status === "dirty")
3816
+ status.dirty();
3817
+ return executeRefinement(inner.value).then(() => {
3818
+ return { status: status.value, value: inner.value };
3819
+ });
3820
+ });
3821
+ }
3822
+ }
3823
+ if (effect.type === "transform") {
3824
+ if (ctx.common.async === false) {
3825
+ const base = this._def.schema._parseSync({
3826
+ data: ctx.data,
3827
+ path: ctx.path,
3828
+ parent: ctx
3829
+ });
3830
+ if (!(0, parseUtil_js_1.isValid)(base))
3831
+ return parseUtil_js_1.INVALID;
3832
+ const result = effect.transform(base.value, checkCtx);
3833
+ if (result instanceof Promise) {
3834
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3835
+ }
3836
+ return { status: status.value, value: result };
3837
+ } else {
3838
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3839
+ if (!(0, parseUtil_js_1.isValid)(base))
3840
+ return parseUtil_js_1.INVALID;
3841
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3842
+ status: status.value,
3843
+ value: result
3844
+ }));
3845
+ });
3846
+ }
3847
+ }
3848
+ util_js_1.util.assertNever(effect);
3849
+ }
3850
+ };
3851
+ exports.ZodEffects = ZodEffects;
3852
+ exports.ZodTransformer = ZodEffects;
3853
+ ZodEffects.create = (schema, effect, params) => {
3854
+ return new ZodEffects({
3855
+ schema,
3856
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3857
+ effect,
3858
+ ...processCreateParams(params)
3859
+ });
3860
+ };
3861
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3862
+ return new ZodEffects({
3863
+ schema,
3864
+ effect: { type: "preprocess", transform: preprocess },
3865
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3866
+ ...processCreateParams(params)
3867
+ });
3868
+ };
3869
+ var ZodOptional = class extends ZodType {
3870
+ _parse(input) {
3871
+ const parsedType = this._getType(input);
3872
+ if (parsedType === util_js_1.ZodParsedType.undefined) {
3873
+ return (0, parseUtil_js_1.OK)(void 0);
3874
+ }
3875
+ return this._def.innerType._parse(input);
3876
+ }
3877
+ unwrap() {
3878
+ return this._def.innerType;
3879
+ }
3880
+ };
3881
+ exports.ZodOptional = ZodOptional;
3882
+ ZodOptional.create = (type, params) => {
3883
+ return new ZodOptional({
3884
+ innerType: type,
3885
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3886
+ ...processCreateParams(params)
3887
+ });
3888
+ };
3889
+ var ZodNullable = class extends ZodType {
3890
+ _parse(input) {
3891
+ const parsedType = this._getType(input);
3892
+ if (parsedType === util_js_1.ZodParsedType.null) {
3893
+ return (0, parseUtil_js_1.OK)(null);
3894
+ }
3895
+ return this._def.innerType._parse(input);
3896
+ }
3897
+ unwrap() {
3898
+ return this._def.innerType;
3899
+ }
3900
+ };
3901
+ exports.ZodNullable = ZodNullable;
3902
+ ZodNullable.create = (type, params) => {
3903
+ return new ZodNullable({
3904
+ innerType: type,
3905
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3906
+ ...processCreateParams(params)
3907
+ });
3908
+ };
3909
+ var ZodDefault = class extends ZodType {
3910
+ _parse(input) {
3911
+ const { ctx } = this._processInputParams(input);
3912
+ let data = ctx.data;
3913
+ if (ctx.parsedType === util_js_1.ZodParsedType.undefined) {
3914
+ data = this._def.defaultValue();
3915
+ }
3916
+ return this._def.innerType._parse({
3917
+ data,
3918
+ path: ctx.path,
3919
+ parent: ctx
3920
+ });
3921
+ }
3922
+ removeDefault() {
3923
+ return this._def.innerType;
3924
+ }
3925
+ };
3926
+ exports.ZodDefault = ZodDefault;
3927
+ ZodDefault.create = (type, params) => {
3928
+ return new ZodDefault({
3929
+ innerType: type,
3930
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3931
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3932
+ ...processCreateParams(params)
3933
+ });
3934
+ };
3935
+ var ZodCatch = class extends ZodType {
3936
+ _parse(input) {
3937
+ const { ctx } = this._processInputParams(input);
3938
+ const newCtx = {
3939
+ ...ctx,
3940
+ common: {
3941
+ ...ctx.common,
3942
+ issues: []
3943
+ }
3944
+ };
3945
+ const result = this._def.innerType._parse({
3946
+ data: newCtx.data,
3947
+ path: newCtx.path,
3948
+ parent: {
3949
+ ...newCtx
3950
+ }
3951
+ });
3952
+ if ((0, parseUtil_js_1.isAsync)(result)) {
3953
+ return result.then((result2) => {
3954
+ return {
3955
+ status: "valid",
3956
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3957
+ get error() {
3958
+ return new ZodError_js_1.ZodError(newCtx.common.issues);
3959
+ },
3960
+ input: newCtx.data
3961
+ })
3962
+ };
3963
+ });
3964
+ } else {
3965
+ return {
3966
+ status: "valid",
3967
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3968
+ get error() {
3969
+ return new ZodError_js_1.ZodError(newCtx.common.issues);
3970
+ },
3971
+ input: newCtx.data
3972
+ })
3973
+ };
3974
+ }
3975
+ }
3976
+ removeCatch() {
3977
+ return this._def.innerType;
3978
+ }
3979
+ };
3980
+ exports.ZodCatch = ZodCatch;
3981
+ ZodCatch.create = (type, params) => {
3982
+ return new ZodCatch({
3983
+ innerType: type,
3984
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3985
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3986
+ ...processCreateParams(params)
3987
+ });
3988
+ };
3989
+ var ZodNaN = class extends ZodType {
3990
+ _parse(input) {
3991
+ const parsedType = this._getType(input);
3992
+ if (parsedType !== util_js_1.ZodParsedType.nan) {
3993
+ const ctx = this._getOrReturnCtx(input);
3994
+ (0, parseUtil_js_1.addIssueToContext)(ctx, {
3995
+ code: ZodError_js_1.ZodIssueCode.invalid_type,
3996
+ expected: util_js_1.ZodParsedType.nan,
3997
+ received: ctx.parsedType
3998
+ });
3999
+ return parseUtil_js_1.INVALID;
4000
+ }
4001
+ return { status: "valid", value: input.data };
4002
+ }
4003
+ };
4004
+ exports.ZodNaN = ZodNaN;
4005
+ ZodNaN.create = (params) => {
4006
+ return new ZodNaN({
4007
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
4008
+ ...processCreateParams(params)
4009
+ });
4010
+ };
4011
+ exports.BRAND = /* @__PURE__ */ Symbol("zod_brand");
4012
+ var ZodBranded = class extends ZodType {
4013
+ _parse(input) {
4014
+ const { ctx } = this._processInputParams(input);
4015
+ const data = ctx.data;
4016
+ return this._def.type._parse({
4017
+ data,
4018
+ path: ctx.path,
4019
+ parent: ctx
4020
+ });
4021
+ }
4022
+ unwrap() {
4023
+ return this._def.type;
4024
+ }
4025
+ };
4026
+ exports.ZodBranded = ZodBranded;
4027
+ var ZodPipeline = class _ZodPipeline extends ZodType {
4028
+ _parse(input) {
4029
+ const { status, ctx } = this._processInputParams(input);
4030
+ if (ctx.common.async) {
4031
+ const handleAsync = async () => {
4032
+ const inResult = await this._def.in._parseAsync({
4033
+ data: ctx.data,
4034
+ path: ctx.path,
4035
+ parent: ctx
4036
+ });
4037
+ if (inResult.status === "aborted")
4038
+ return parseUtil_js_1.INVALID;
4039
+ if (inResult.status === "dirty") {
4040
+ status.dirty();
4041
+ return (0, parseUtil_js_1.DIRTY)(inResult.value);
4042
+ } else {
4043
+ return this._def.out._parseAsync({
4044
+ data: inResult.value,
4045
+ path: ctx.path,
4046
+ parent: ctx
4047
+ });
4048
+ }
4049
+ };
4050
+ return handleAsync();
4051
+ } else {
4052
+ const inResult = this._def.in._parseSync({
4053
+ data: ctx.data,
4054
+ path: ctx.path,
4055
+ parent: ctx
4056
+ });
4057
+ if (inResult.status === "aborted")
4058
+ return parseUtil_js_1.INVALID;
4059
+ if (inResult.status === "dirty") {
4060
+ status.dirty();
4061
+ return {
4062
+ status: "dirty",
4063
+ value: inResult.value
4064
+ };
4065
+ } else {
4066
+ return this._def.out._parseSync({
4067
+ data: inResult.value,
4068
+ path: ctx.path,
4069
+ parent: ctx
4070
+ });
4071
+ }
4072
+ }
4073
+ }
4074
+ static create(a, b) {
4075
+ return new _ZodPipeline({
4076
+ in: a,
4077
+ out: b,
4078
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4079
+ });
4080
+ }
4081
+ };
4082
+ exports.ZodPipeline = ZodPipeline;
4083
+ var ZodReadonly = class extends ZodType {
4084
+ _parse(input) {
4085
+ const result = this._def.innerType._parse(input);
4086
+ const freeze = (data) => {
4087
+ if ((0, parseUtil_js_1.isValid)(data)) {
4088
+ data.value = Object.freeze(data.value);
4089
+ }
4090
+ return data;
4091
+ };
4092
+ return (0, parseUtil_js_1.isAsync)(result) ? result.then((data) => freeze(data)) : freeze(result);
4093
+ }
4094
+ unwrap() {
4095
+ return this._def.innerType;
4096
+ }
4097
+ };
4098
+ exports.ZodReadonly = ZodReadonly;
4099
+ ZodReadonly.create = (type, params) => {
4100
+ return new ZodReadonly({
4101
+ innerType: type,
4102
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4103
+ ...processCreateParams(params)
4104
+ });
4105
+ };
4106
+ function cleanParams(params, data) {
4107
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4108
+ const p2 = typeof p === "string" ? { message: p } : p;
4109
+ return p2;
4110
+ }
4111
+ function custom(check, _params = {}, fatal) {
4112
+ if (check)
4113
+ return ZodAny.create().superRefine((data, ctx) => {
4114
+ const r = check(data);
4115
+ if (r instanceof Promise) {
4116
+ return r.then((r2) => {
4117
+ if (!r2) {
4118
+ const params = cleanParams(_params, data);
4119
+ const _fatal = params.fatal ?? fatal ?? true;
4120
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4121
+ }
4122
+ });
4123
+ }
4124
+ if (!r) {
4125
+ const params = cleanParams(_params, data);
4126
+ const _fatal = params.fatal ?? fatal ?? true;
4127
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4128
+ }
4129
+ return;
4130
+ });
4131
+ return ZodAny.create();
4132
+ }
4133
+ exports.late = {
4134
+ object: ZodObject.lazycreate
4135
+ };
4136
+ var ZodFirstPartyTypeKind;
4137
+ (function(ZodFirstPartyTypeKind2) {
4138
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4139
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4140
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4141
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4142
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4143
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4144
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4145
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4146
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4147
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4148
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4149
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4150
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4151
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4152
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4153
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4154
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4155
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4156
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4157
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4158
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4159
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4160
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4161
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4162
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4163
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4164
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4165
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4166
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4167
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4168
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4169
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4170
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4171
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4172
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4173
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4174
+ })(ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = ZodFirstPartyTypeKind = {}));
4175
+ var instanceOfType = (cls, params = {
4176
+ message: `Input not instance of ${cls.name}`
4177
+ }) => custom((data) => data instanceof cls, params);
4178
+ exports.instanceof = instanceOfType;
4179
+ var stringType = ZodString.create;
4180
+ exports.string = stringType;
4181
+ var numberType = ZodNumber.create;
4182
+ exports.number = numberType;
4183
+ var nanType = ZodNaN.create;
4184
+ exports.nan = nanType;
4185
+ var bigIntType = ZodBigInt.create;
4186
+ exports.bigint = bigIntType;
4187
+ var booleanType = ZodBoolean.create;
4188
+ exports.boolean = booleanType;
4189
+ var dateType = ZodDate.create;
4190
+ exports.date = dateType;
4191
+ var symbolType = ZodSymbol.create;
4192
+ exports.symbol = symbolType;
4193
+ var undefinedType = ZodUndefined.create;
4194
+ exports.undefined = undefinedType;
4195
+ var nullType = ZodNull.create;
4196
+ exports.null = nullType;
4197
+ var anyType = ZodAny.create;
4198
+ exports.any = anyType;
4199
+ var unknownType = ZodUnknown.create;
4200
+ exports.unknown = unknownType;
4201
+ var neverType = ZodNever.create;
4202
+ exports.never = neverType;
4203
+ var voidType = ZodVoid.create;
4204
+ exports.void = voidType;
4205
+ var arrayType = ZodArray.create;
4206
+ exports.array = arrayType;
4207
+ var objectType = ZodObject.create;
4208
+ exports.object = objectType;
4209
+ var strictObjectType = ZodObject.strictCreate;
4210
+ exports.strictObject = strictObjectType;
4211
+ var unionType = ZodUnion.create;
4212
+ exports.union = unionType;
4213
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4214
+ exports.discriminatedUnion = discriminatedUnionType;
4215
+ var intersectionType = ZodIntersection.create;
4216
+ exports.intersection = intersectionType;
4217
+ var tupleType = ZodTuple.create;
4218
+ exports.tuple = tupleType;
4219
+ var recordType = ZodRecord.create;
4220
+ exports.record = recordType;
4221
+ var mapType = ZodMap.create;
4222
+ exports.map = mapType;
4223
+ var setType = ZodSet.create;
4224
+ exports.set = setType;
4225
+ var functionType = ZodFunction.create;
4226
+ exports.function = functionType;
4227
+ var lazyType = ZodLazy.create;
4228
+ exports.lazy = lazyType;
4229
+ var literalType = ZodLiteral.create;
4230
+ exports.literal = literalType;
4231
+ var enumType = ZodEnum.create;
4232
+ exports.enum = enumType;
4233
+ var nativeEnumType = ZodNativeEnum.create;
4234
+ exports.nativeEnum = nativeEnumType;
4235
+ var promiseType = ZodPromise.create;
4236
+ exports.promise = promiseType;
4237
+ var effectsType = ZodEffects.create;
4238
+ exports.effect = effectsType;
4239
+ exports.transformer = effectsType;
4240
+ var optionalType = ZodOptional.create;
4241
+ exports.optional = optionalType;
4242
+ var nullableType = ZodNullable.create;
4243
+ exports.nullable = nullableType;
4244
+ var preprocessType = ZodEffects.createWithPreprocess;
4245
+ exports.preprocess = preprocessType;
4246
+ var pipelineType = ZodPipeline.create;
4247
+ exports.pipeline = pipelineType;
4248
+ var ostring = () => stringType().optional();
4249
+ exports.ostring = ostring;
4250
+ var onumber = () => numberType().optional();
4251
+ exports.onumber = onumber;
4252
+ var oboolean = () => booleanType().optional();
4253
+ exports.oboolean = oboolean;
4254
+ exports.coerce = {
4255
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4256
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4257
+ boolean: ((arg) => ZodBoolean.create({
4258
+ ...arg,
4259
+ coerce: true
4260
+ })),
4261
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4262
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4263
+ };
4264
+ exports.NEVER = parseUtil_js_1.INVALID;
4265
+ }
4266
+ });
4267
+
4268
+ // ../../node_modules/zod/v3/external.cjs
4269
+ var require_external = __commonJS({
4270
+ "../../node_modules/zod/v3/external.cjs"(exports) {
4271
+ "use strict";
4272
+ init_esm_shims();
4273
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4274
+ if (k2 === void 0) k2 = k;
4275
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4276
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4277
+ desc = { enumerable: true, get: function() {
4278
+ return m[k];
4279
+ } };
4280
+ }
4281
+ Object.defineProperty(o, k2, desc);
4282
+ }) : (function(o, m, k, k2) {
4283
+ if (k2 === void 0) k2 = k;
4284
+ o[k2] = m[k];
4285
+ }));
4286
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
4287
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
4288
+ };
4289
+ Object.defineProperty(exports, "__esModule", { value: true });
4290
+ __exportStar(require_errors(), exports);
4291
+ __exportStar(require_parseUtil(), exports);
4292
+ __exportStar(require_typeAliases(), exports);
4293
+ __exportStar(require_util(), exports);
4294
+ __exportStar(require_types(), exports);
4295
+ __exportStar(require_ZodError(), exports);
4296
+ }
4297
+ });
4298
+
4299
+ // ../../node_modules/zod/index.cjs
4300
+ var require_zod = __commonJS({
4301
+ "../../node_modules/zod/index.cjs"(exports) {
4302
+ "use strict";
4303
+ init_esm_shims();
4304
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4305
+ if (k2 === void 0) k2 = k;
4306
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4307
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4308
+ desc = { enumerable: true, get: function() {
4309
+ return m[k];
4310
+ } };
4311
+ }
4312
+ Object.defineProperty(o, k2, desc);
4313
+ }) : (function(o, m, k, k2) {
4314
+ if (k2 === void 0) k2 = k;
4315
+ o[k2] = m[k];
4316
+ }));
4317
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
4318
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4319
+ }) : function(o, v) {
4320
+ o["default"] = v;
4321
+ });
4322
+ var __importStar = exports && exports.__importStar || function(mod) {
4323
+ if (mod && mod.__esModule) return mod;
4324
+ var result = {};
4325
+ if (mod != null) {
4326
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4327
+ }
4328
+ __setModuleDefault(result, mod);
4329
+ return result;
4330
+ };
4331
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
4332
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
4333
+ };
4334
+ Object.defineProperty(exports, "__esModule", { value: true });
4335
+ exports.z = void 0;
4336
+ var z = __importStar(require_external());
4337
+ exports.z = z;
4338
+ __exportStar(require_external(), exports);
4339
+ exports.default = z;
4340
+ }
4341
+ });
4342
+
4343
+ // ../../packages/utils/dist/validation.js
4344
+ var require_validation = __commonJS({
4345
+ "../../packages/utils/dist/validation.js"(exports) {
4346
+ "use strict";
4347
+ init_esm_shims();
4348
+ Object.defineProperty(exports, "__esModule", { value: true });
4349
+ exports.updateProfileSchema = exports.refreshTokenSchema = exports.syncCompleteSchema = exports.downloadUrlSchema = exports.uploadUrlSchema = exports.pullRequestSchema = exports.pushManifestSchema = exports.updateDeviceSchema = exports.createDeviceSchema = exports.registerSchema = exports.loginSchema = void 0;
4350
+ var zod_1 = require_zod();
4351
+ exports.loginSchema = zod_1.z.object({
4352
+ email: zod_1.z.string().email(),
4353
+ password: zod_1.z.string().min(8)
4354
+ });
4355
+ exports.registerSchema = zod_1.z.object({
4356
+ email: zod_1.z.string().email(),
4357
+ password: zod_1.z.string().min(8),
4358
+ name: zod_1.z.string().min(1).max(100)
4359
+ });
4360
+ exports.createDeviceSchema = zod_1.z.object({
4361
+ name: zod_1.z.string().min(1).max(100),
4362
+ hostname: zod_1.z.string().min(1),
4363
+ platform: zod_1.z.enum(["darwin", "linux", "win32"]),
4364
+ homeDir: zod_1.z.string().min(1),
4365
+ arch: zod_1.z.string().min(1)
4366
+ });
4367
+ exports.updateDeviceSchema = zod_1.z.object({
4368
+ name: zod_1.z.string().min(1).max(100).optional(),
4369
+ isActive: zod_1.z.boolean().optional()
4370
+ });
4371
+ exports.pushManifestSchema = zod_1.z.object({
4372
+ deviceId: zod_1.z.string().uuid(),
4373
+ projectPath: zod_1.z.string().min(1),
4374
+ projectId: zod_1.z.string().uuid().optional(),
4375
+ manifest: zod_1.z.array(zod_1.z.object({
4376
+ path: zod_1.z.string(),
4377
+ hash: zod_1.z.string(),
4378
+ size: zod_1.z.number(),
4379
+ modifiedAt: zod_1.z.string(),
4380
+ isCompressed: zod_1.z.boolean()
4381
+ }))
4382
+ });
4383
+ exports.pullRequestSchema = zod_1.z.object({
4384
+ deviceId: zod_1.z.string().uuid(),
4385
+ projectPath: zod_1.z.string().optional(),
4386
+ fromDeviceId: zod_1.z.string().uuid().optional(),
4387
+ projectId: zod_1.z.string().uuid().optional()
4388
+ });
4389
+ exports.uploadUrlSchema = zod_1.z.object({
4390
+ syncEventId: zod_1.z.string().uuid(),
4391
+ key: zod_1.z.string().min(1),
4392
+ contentType: zod_1.z.string().optional()
4393
+ });
4394
+ exports.downloadUrlSchema = zod_1.z.object({
4395
+ syncEventId: zod_1.z.string().uuid(),
4396
+ key: zod_1.z.string().min(1)
4397
+ });
4398
+ exports.syncCompleteSchema = zod_1.z.object({
4399
+ syncEventId: zod_1.z.string().uuid(),
4400
+ manifest: zod_1.z.array(zod_1.z.object({
4401
+ path: zod_1.z.string(),
4402
+ hash: zod_1.z.string(),
4403
+ size: zod_1.z.number(),
4404
+ modifiedAt: zod_1.z.string(),
4405
+ isCompressed: zod_1.z.boolean()
4406
+ }))
4407
+ });
4408
+ exports.refreshTokenSchema = zod_1.z.object({
4409
+ refreshToken: zod_1.z.string()
4410
+ });
4411
+ exports.updateProfileSchema = zod_1.z.object({
4412
+ name: zod_1.z.string().min(1).max(100).optional(),
4413
+ avatarUrl: zod_1.z.string().url().nullable().optional()
4414
+ });
4415
+ }
4416
+ });
4417
+
4418
+ // ../../packages/utils/dist/index.js
4419
+ var require_dist = __commonJS({
4420
+ "../../packages/utils/dist/index.js"(exports) {
4421
+ "use strict";
4422
+ init_esm_shims();
4423
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
4424
+ if (k2 === void 0) k2 = k;
4425
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4426
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
4427
+ desc = { enumerable: true, get: function() {
4428
+ return m[k];
4429
+ } };
4430
+ }
4431
+ Object.defineProperty(o, k2, desc);
4432
+ }) : (function(o, m, k, k2) {
4433
+ if (k2 === void 0) k2 = k;
4434
+ o[k2] = m[k];
4435
+ }));
4436
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
4437
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
4438
+ };
4439
+ Object.defineProperty(exports, "__esModule", { value: true });
4440
+ __exportStar(require_path_encoding(), exports);
4441
+ __exportStar(require_manifest(), exports);
4442
+ __exportStar(require_constants(), exports);
4443
+ __exportStar(require_validation(), exports);
4444
+ }
4445
+ });
11
4446
 
12
4447
  // src/lib/config.ts
13
4448
  import { join, dirname } from "path";
14
4449
  import { homedir } from "os";
15
4450
  import { readFile, writeFile, mkdir } from "fs/promises";
16
- import { CONFIG_DIR, CONFIG_FILE, MANIFEST_FILE, encodePath } from "@claude-sync/utils";
17
4451
  function getConfigDir() {
18
- return join(homedir(), CONFIG_DIR);
4452
+ return join(homedir(), import_utils.CONFIG_DIR);
19
4453
  }
20
4454
  function getConfigPath() {
21
- return join(getConfigDir(), CONFIG_FILE);
4455
+ return join(getConfigDir(), import_utils.CONFIG_FILE);
22
4456
  }
23
4457
  async function loadConfig() {
24
4458
  try {
@@ -39,7 +4473,7 @@ async function clearConfig() {
39
4473
  }
40
4474
  async function loadProjectManifest(projectPath) {
41
4475
  try {
42
- const encoded = encodePath(projectPath);
4476
+ const encoded = (0, import_utils.encodePath)(projectPath);
43
4477
  const manifestPath = join(getConfigDir(), "manifests", `${encoded}.json`);
44
4478
  const content = await readFile(manifestPath, "utf-8");
45
4479
  return JSON.parse(content);
@@ -48,7 +4482,7 @@ async function loadProjectManifest(projectPath) {
48
4482
  }
49
4483
  }
50
4484
  async function saveProjectManifest(projectPath, entries) {
51
- const encoded = encodePath(projectPath);
4485
+ const encoded = (0, import_utils.encodePath)(projectPath);
52
4486
  const manifestPath = join(getConfigDir(), "manifests", `${encoded}.json`);
53
4487
  await mkdir(dirname(manifestPath), { recursive: true });
54
4488
  await writeFile(manifestPath, JSON.stringify(entries, null, 2));
@@ -58,7 +4492,7 @@ function isAuthenticated(config) {
58
4492
  }
59
4493
  async function loadProjectLink(projectPath) {
60
4494
  try {
61
- const encoded = encodePath(projectPath);
4495
+ const encoded = (0, import_utils.encodePath)(projectPath);
62
4496
  const linkPath = join(getConfigDir(), "project-links", `${encoded}.json`);
63
4497
  const content = await readFile(linkPath, "utf-8");
64
4498
  return JSON.parse(content);
@@ -67,15 +4501,17 @@ async function loadProjectLink(projectPath) {
67
4501
  }
68
4502
  }
69
4503
  async function saveProjectLink(projectPath, link) {
70
- const encoded = encodePath(projectPath);
4504
+ const encoded = (0, import_utils.encodePath)(projectPath);
71
4505
  const linkPath = join(getConfigDir(), "project-links", `${encoded}.json`);
72
4506
  await mkdir(dirname(linkPath), { recursive: true });
73
4507
  await writeFile(linkPath, JSON.stringify(link, null, 2));
74
4508
  }
75
- var DEFAULT_CONFIG;
4509
+ var import_utils, DEFAULT_CONFIG;
76
4510
  var init_config = __esm({
77
4511
  "src/lib/config.ts"() {
78
4512
  "use strict";
4513
+ init_esm_shims();
4514
+ import_utils = __toESM(require_dist(), 1);
79
4515
  DEFAULT_CONFIG = {
80
4516
  apiUrl: "https://api.claude-sync.com",
81
4517
  accessToken: null,
@@ -93,18 +4529,19 @@ var ApiClient;
93
4529
  var init_api_client = __esm({
94
4530
  "src/lib/api-client.ts"() {
95
4531
  "use strict";
4532
+ init_esm_shims();
96
4533
  init_auth();
97
4534
  ApiClient = class {
98
4535
  baseUrl;
99
4536
  constructor(baseUrl) {
100
4537
  this.baseUrl = baseUrl.replace(/\/$/, "");
101
4538
  }
102
- async rawRequest(path, options = {}) {
4539
+ async rawRequest(path2, options = {}) {
103
4540
  const controller = new AbortController();
104
4541
  const timeout = setTimeout(() => controller.abort(), 15e3);
105
4542
  let response;
106
4543
  try {
107
- response = await fetch(`${this.baseUrl}${path}`, {
4544
+ response = await fetch(`${this.baseUrl}${path2}`, {
108
4545
  ...options,
109
4546
  signal: controller.signal
110
4547
  });
@@ -130,7 +4567,7 @@ var init_api_client = __esm({
130
4567
  const json = await response.json();
131
4568
  return json.data !== void 0 ? json.data : json;
132
4569
  }
133
- async request(path, options = {}) {
4570
+ async request(path2, options = {}) {
134
4571
  const token = await getValidToken();
135
4572
  const headers = {
136
4573
  "Content-Type": "application/json",
@@ -139,32 +4576,32 @@ var init_api_client = __esm({
139
4576
  if (token) {
140
4577
  headers["Authorization"] = `Bearer ${token}`;
141
4578
  }
142
- return this.rawRequest(path, { ...options, headers });
4579
+ return this.rawRequest(path2, { ...options, headers });
143
4580
  }
144
- async requestNoAuth(path, options = {}) {
4581
+ async requestNoAuth(path2, options = {}) {
145
4582
  const headers = {
146
4583
  "Content-Type": "application/json",
147
4584
  ...options.headers
148
4585
  };
149
- return this.rawRequest(path, { ...options, headers });
4586
+ return this.rawRequest(path2, { ...options, headers });
150
4587
  }
151
- async get(path) {
152
- return this.request(path, { method: "GET" });
4588
+ async get(path2) {
4589
+ return this.request(path2, { method: "GET" });
153
4590
  }
154
- async post(path, body) {
155
- return this.request(path, {
4591
+ async post(path2, body) {
4592
+ return this.request(path2, {
156
4593
  method: "POST",
157
4594
  body: body ? JSON.stringify(body) : void 0
158
4595
  });
159
4596
  }
160
- async patch(path, body) {
161
- return this.request(path, {
4597
+ async patch(path2, body) {
4598
+ return this.request(path2, {
162
4599
  method: "PATCH",
163
4600
  body: body ? JSON.stringify(body) : void 0
164
4601
  });
165
4602
  }
166
- async delete(path) {
167
- return this.request(path, { method: "DELETE" });
4603
+ async delete(path2) {
4604
+ return this.request(path2, { method: "DELETE" });
168
4605
  }
169
4606
  };
170
4607
  }
@@ -214,6 +4651,7 @@ async function getValidToken() {
214
4651
  var init_auth = __esm({
215
4652
  "src/lib/auth.ts"() {
216
4653
  "use strict";
4654
+ init_esm_shims();
217
4655
  init_config();
218
4656
  init_api_client();
219
4657
  }
@@ -240,6 +4678,7 @@ var brandColor;
240
4678
  var init_progress = __esm({
241
4679
  "src/lib/progress.ts"() {
242
4680
  "use strict";
4681
+ init_esm_shims();
243
4682
  brandColor = chalk.hex("#8a8cdd");
244
4683
  }
245
4684
  });
@@ -280,6 +4719,7 @@ var BRAND_HEX, BRAND_DIM_HEX, SUCCESS_HEX, WARN_HEX, ERROR_HEX, brand, brandBold
280
4719
  var init_theme = __esm({
281
4720
  "src/lib/theme.ts"() {
282
4721
  "use strict";
4722
+ init_esm_shims();
283
4723
  BRAND_HEX = "#8a8cdd";
284
4724
  BRAND_DIM_HEX = "#6b6db8";
285
4725
  SUCCESS_HEX = "#8adda0";
@@ -397,6 +4837,7 @@ function loginCommand() {
397
4837
  var init_login = __esm({
398
4838
  "src/commands/login.ts"() {
399
4839
  "use strict";
4840
+ init_esm_shims();
400
4841
  init_config();
401
4842
  init_auth();
402
4843
  init_api_client();
@@ -435,6 +4876,7 @@ function logoutCommand() {
435
4876
  var init_logout = __esm({
436
4877
  "src/commands/logout.ts"() {
437
4878
  "use strict";
4879
+ init_esm_shims();
438
4880
  init_config();
439
4881
  init_api_client();
440
4882
  init_theme();
@@ -560,6 +5002,7 @@ function deviceCommand() {
560
5002
  var init_device = __esm({
561
5003
  "src/commands/device.ts"() {
562
5004
  "use strict";
5005
+ init_esm_shims();
563
5006
  init_config();
564
5007
  init_api_client();
565
5008
  init_progress();
@@ -571,9 +5014,8 @@ var init_device = __esm({
571
5014
  import { join as join2 } from "path";
572
5015
  import { homedir as homedir3 } from "os";
573
5016
  import { readdir, stat, lstat, readlink } from "fs/promises";
574
- import { hashFile, diffManifests, encodePath as encodePath2, CLAUDE_DIR, PROJECTS_DIR, SYNC_EXCLUDE_PATTERNS } from "@claude-sync/utils";
575
5017
  function shouldExclude(name) {
576
- return SYNC_EXCLUDE_PATTERNS.some((pattern) => {
5018
+ return import_utils2.SYNC_EXCLUDE_PATTERNS.some((pattern) => {
577
5019
  if (pattern.startsWith("*")) {
578
5020
  return name.endsWith(pattern.slice(1));
579
5021
  }
@@ -592,7 +5034,7 @@ async function walkDirectory(dir, basePath = "") {
592
5034
  entries.push(...subEntries);
593
5035
  } else if (item.isFile()) {
594
5036
  const fileStat = await stat(fullPath);
595
- const hash = await hashFile(fullPath);
5037
+ const hash = await (0, import_utils2.hashFile)(fullPath);
596
5038
  const isText = !isBinaryPath(item.name);
597
5039
  entries.push({
598
5040
  path: relativePath,
@@ -610,8 +5052,8 @@ function isBinaryPath(name) {
610
5052
  return binaryExtensions.some((ext) => name.endsWith(ext));
611
5053
  }
612
5054
  async function resolveProjectState(cwd) {
613
- const projectsDir = join2(homedir3(), CLAUDE_DIR, PROJECTS_DIR);
614
- const encoded = encodePath2(cwd);
5055
+ const projectsDir = join2(homedir3(), import_utils2.CLAUDE_DIR, import_utils2.PROJECTS_DIR);
5056
+ const encoded = (0, import_utils2.encodePath)(cwd);
615
5057
  const projectDir = join2(projectsDir, encoded);
616
5058
  let state = "none";
617
5059
  let symlinkTarget;
@@ -631,7 +5073,7 @@ async function resolveProjectState(cwd) {
631
5073
  async function buildProjectManifest(cwd) {
632
5074
  const ctx = await resolveProjectState(cwd);
633
5075
  if (ctx.state === "none") return [];
634
- const projectsDir = join2(homedir3(), CLAUDE_DIR, PROJECTS_DIR);
5076
+ const projectsDir = join2(homedir3(), import_utils2.CLAUDE_DIR, import_utils2.PROJECTS_DIR);
635
5077
  let targetDir = ctx.projectDir;
636
5078
  if (ctx.state === "symlink" && ctx.symlinkTarget) {
637
5079
  targetDir = join2(projectsDir, ctx.symlinkTarget);
@@ -643,11 +5085,14 @@ async function buildProjectManifest(cwd) {
643
5085
  }
644
5086
  }
645
5087
  function computeDiff(local, remote) {
646
- return diffManifests(local, remote);
5088
+ return (0, import_utils2.diffManifests)(local, remote);
647
5089
  }
5090
+ var import_utils2;
648
5091
  var init_sync_engine = __esm({
649
5092
  "src/lib/sync-engine.ts"() {
650
5093
  "use strict";
5094
+ init_esm_shims();
5095
+ import_utils2 = __toESM(require_dist(), 1);
651
5096
  }
652
5097
  });
653
5098
 
@@ -678,6 +5123,7 @@ function decompressBuffer(data) {
678
5123
  var init_compress = __esm({
679
5124
  "src/lib/compress.ts"() {
680
5125
  "use strict";
5126
+ init_esm_shims();
681
5127
  }
682
5128
  });
683
5129
 
@@ -692,7 +5138,6 @@ import { select as select2, isCancel as isCancel3 } from "@clack/prompts";
692
5138
  import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, lstat as lstat2, symlink, unlink } from "fs/promises";
693
5139
  import { join as join3, dirname as dirname2 } from "path";
694
5140
  import { homedir as homedir4 } from "os";
695
- import { CLAUDE_DIR as CLAUDE_DIR2, PROJECTS_DIR as PROJECTS_DIR2 } from "@claude-sync/utils";
696
5141
  async function runSync(options) {
697
5142
  printIntro("Sync");
698
5143
  const config = await loadConfig();
@@ -707,7 +5152,7 @@ async function runSync(options) {
707
5152
  const cwd = process.cwd();
708
5153
  const ctx = await resolveProjectState(cwd);
709
5154
  const client = new ApiClient(config.apiUrl);
710
- const projectsDir = join3(homedir4(), CLAUDE_DIR2, PROJECTS_DIR2);
5155
+ const projectsDir = join3(homedir4(), import_utils3.CLAUDE_DIR, import_utils3.PROJECTS_DIR);
711
5156
  const projectLink = await loadProjectLink(cwd);
712
5157
  let projectDir = ctx.projectDir;
713
5158
  if (ctx.state === "symlink" && ctx.symlinkTarget) {
@@ -1079,14 +5524,17 @@ function syncCommand() {
1079
5524
  await runSync(options);
1080
5525
  });
1081
5526
  }
5527
+ var import_utils3;
1082
5528
  var init_sync = __esm({
1083
5529
  "src/commands/sync.ts"() {
1084
5530
  "use strict";
5531
+ init_esm_shims();
1085
5532
  init_config();
1086
5533
  init_api_client();
1087
5534
  init_sync_engine();
1088
5535
  init_progress();
1089
5536
  init_compress();
5537
+ import_utils3 = __toESM(require_dist(), 1);
1090
5538
  init_theme();
1091
5539
  }
1092
5540
  });
@@ -1126,6 +5574,7 @@ function statusCommand() {
1126
5574
  var init_status = __esm({
1127
5575
  "src/commands/status.ts"() {
1128
5576
  "use strict";
5577
+ init_esm_shims();
1129
5578
  init_config();
1130
5579
  init_sync_engine();
1131
5580
  init_progress();
@@ -1168,6 +5617,7 @@ function whoamiCommand() {
1168
5617
  var init_whoami = __esm({
1169
5618
  "src/commands/whoami.ts"() {
1170
5619
  "use strict";
5620
+ init_esm_shims();
1171
5621
  init_config();
1172
5622
  init_api_client();
1173
5623
  init_progress();
@@ -1175,7 +5625,11 @@ var init_whoami = __esm({
1175
5625
  }
1176
5626
  });
1177
5627
 
5628
+ // bin/claude-sync.ts
5629
+ init_esm_shims();
5630
+
1178
5631
  // src/index.ts
5632
+ init_esm_shims();
1179
5633
  init_login();
1180
5634
  init_logout();
1181
5635
  init_device();
@@ -1185,6 +5639,7 @@ init_whoami();
1185
5639
  import { Command as Command7 } from "commander";
1186
5640
 
1187
5641
  // src/commands/tui.ts
5642
+ init_esm_shims();
1188
5643
  init_theme();
1189
5644
  init_config();
1190
5645
  import { select as select3, isCancel as isCancel4 } from "@clack/prompts";