@syntrologie/adapt-nav 2.55.1 → 2.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4993 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
35
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
37
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
38
+
39
+ // ../../sdk-contracts/dist/mount-plumbing.js
40
+ var MOUNT_PLUMBING_KEYS = ["instanceId", "runtime", "tileId"];
41
+ function stripMountPlumbing(config) {
42
+ if (!config || typeof config !== "object") {
43
+ return {};
44
+ }
45
+ const out = { ...config };
46
+ for (const key of MOUNT_PLUMBING_KEYS) {
47
+ delete out[key];
48
+ }
49
+ return out;
50
+ }
51
+
52
+ // ../../sdk-contracts/dist/routes.js
53
+ var RESERVED_BYTES = /* @__PURE__ */ new Set([
54
+ 33,
55
+ // !
56
+ 35,
57
+ // #
58
+ 36,
59
+ // $
60
+ 38,
61
+ // &
62
+ 39,
63
+ // '
64
+ 40,
65
+ // (
66
+ 41,
67
+ // )
68
+ 42,
69
+ // *
70
+ 43,
71
+ // +
72
+ 44,
73
+ // ,
74
+ 47,
75
+ // /
76
+ 58,
77
+ // :
78
+ 59,
79
+ // ;
80
+ 61,
81
+ // =
82
+ 63,
83
+ // ?
84
+ 64,
85
+ // @
86
+ 91,
87
+ // [
88
+ 93
89
+ // ]
90
+ ]);
91
+ var utf8Decoder = new TextDecoder("utf-8", { fatal: false });
92
+ function decodeUnreservedOnly(input) {
93
+ let out = "";
94
+ let pending = [];
95
+ const flushPending = () => {
96
+ if (pending.length === 0)
97
+ return;
98
+ const bytes = new Uint8Array(pending);
99
+ out += utf8Decoder.decode(bytes);
100
+ pending = [];
101
+ };
102
+ let i2 = 0;
103
+ while (i2 < input.length) {
104
+ const ch = input[i2];
105
+ if (ch === "%" && i2 + 2 < input.length && isHex(input[i2 + 1]) && isHex(input[i2 + 2])) {
106
+ const byte = parseInt(input.slice(i2 + 1, i2 + 3), 16);
107
+ if (RESERVED_BYTES.has(byte)) {
108
+ flushPending();
109
+ out += `%${input.slice(i2 + 1, i2 + 3).toUpperCase()}`;
110
+ i2 += 3;
111
+ } else {
112
+ pending.push(byte);
113
+ i2 += 3;
114
+ }
115
+ } else {
116
+ flushPending();
117
+ out += ch;
118
+ i2 += 1;
119
+ }
120
+ }
121
+ flushPending();
122
+ return out;
123
+ }
124
+ function isHex(c2) {
125
+ return c2 >= "0" && c2 <= "9" || c2 >= "a" && c2 <= "f" || c2 >= "A" && c2 <= "F";
126
+ }
127
+ function stripQueryAndHash(s4) {
128
+ const q = s4.indexOf("?");
129
+ if (q !== -1)
130
+ s4 = s4.slice(0, q);
131
+ const h = s4.indexOf("#");
132
+ if (h !== -1)
133
+ s4 = s4.slice(0, h);
134
+ return s4;
135
+ }
136
+ function normalizeRoute(path) {
137
+ if (typeof path !== "string" || path.length === 0) {
138
+ throw new TypeError("normalizeRoute: input must be a non-empty string");
139
+ }
140
+ if (!path.startsWith("/")) {
141
+ throw new TypeError(`normalizeRoute: input must be absolute (start with '/'); got ${JSON.stringify(path)}`);
142
+ }
143
+ let s4 = stripQueryAndHash(path);
144
+ s4 = decodeUnreservedOnly(s4);
145
+ s4 = s4.replace(/\/+/g, "/");
146
+ if (s4.length > 1 && s4.endsWith("/"))
147
+ s4 = s4.slice(0, -1);
148
+ return s4;
149
+ }
150
+ function routesMatch(a, b) {
151
+ return a.toLowerCase() === b.toLowerCase();
152
+ }
153
+
154
+ // ../../../node_modules/zod/v3/external.js
155
+ var external_exports = {};
156
+ __export(external_exports, {
157
+ BRAND: () => BRAND,
158
+ DIRTY: () => DIRTY,
159
+ EMPTY_PATH: () => EMPTY_PATH,
160
+ INVALID: () => INVALID,
161
+ NEVER: () => NEVER,
162
+ OK: () => OK,
163
+ ParseStatus: () => ParseStatus,
164
+ Schema: () => ZodType,
165
+ ZodAny: () => ZodAny,
166
+ ZodArray: () => ZodArray,
167
+ ZodBigInt: () => ZodBigInt,
168
+ ZodBoolean: () => ZodBoolean,
169
+ ZodBranded: () => ZodBranded,
170
+ ZodCatch: () => ZodCatch,
171
+ ZodDate: () => ZodDate,
172
+ ZodDefault: () => ZodDefault,
173
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
174
+ ZodEffects: () => ZodEffects,
175
+ ZodEnum: () => ZodEnum,
176
+ ZodError: () => ZodError,
177
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
178
+ ZodFunction: () => ZodFunction,
179
+ ZodIntersection: () => ZodIntersection,
180
+ ZodIssueCode: () => ZodIssueCode,
181
+ ZodLazy: () => ZodLazy,
182
+ ZodLiteral: () => ZodLiteral,
183
+ ZodMap: () => ZodMap,
184
+ ZodNaN: () => ZodNaN,
185
+ ZodNativeEnum: () => ZodNativeEnum,
186
+ ZodNever: () => ZodNever,
187
+ ZodNull: () => ZodNull,
188
+ ZodNullable: () => ZodNullable,
189
+ ZodNumber: () => ZodNumber,
190
+ ZodObject: () => ZodObject,
191
+ ZodOptional: () => ZodOptional,
192
+ ZodParsedType: () => ZodParsedType,
193
+ ZodPipeline: () => ZodPipeline,
194
+ ZodPromise: () => ZodPromise,
195
+ ZodReadonly: () => ZodReadonly,
196
+ ZodRecord: () => ZodRecord,
197
+ ZodSchema: () => ZodType,
198
+ ZodSet: () => ZodSet,
199
+ ZodString: () => ZodString,
200
+ ZodSymbol: () => ZodSymbol,
201
+ ZodTransformer: () => ZodEffects,
202
+ ZodTuple: () => ZodTuple,
203
+ ZodType: () => ZodType,
204
+ ZodUndefined: () => ZodUndefined,
205
+ ZodUnion: () => ZodUnion,
206
+ ZodUnknown: () => ZodUnknown,
207
+ ZodVoid: () => ZodVoid,
208
+ addIssueToContext: () => addIssueToContext,
209
+ any: () => anyType,
210
+ array: () => arrayType,
211
+ bigint: () => bigIntType,
212
+ boolean: () => booleanType,
213
+ coerce: () => coerce,
214
+ custom: () => custom,
215
+ date: () => dateType,
216
+ datetimeRegex: () => datetimeRegex,
217
+ defaultErrorMap: () => en_default,
218
+ discriminatedUnion: () => discriminatedUnionType,
219
+ effect: () => effectsType,
220
+ enum: () => enumType,
221
+ function: () => functionType,
222
+ getErrorMap: () => getErrorMap,
223
+ getParsedType: () => getParsedType,
224
+ instanceof: () => instanceOfType,
225
+ intersection: () => intersectionType,
226
+ isAborted: () => isAborted,
227
+ isAsync: () => isAsync,
228
+ isDirty: () => isDirty,
229
+ isValid: () => isValid,
230
+ late: () => late,
231
+ lazy: () => lazyType,
232
+ literal: () => literalType,
233
+ makeIssue: () => makeIssue,
234
+ map: () => mapType,
235
+ nan: () => nanType,
236
+ nativeEnum: () => nativeEnumType,
237
+ never: () => neverType,
238
+ null: () => nullType,
239
+ nullable: () => nullableType,
240
+ number: () => numberType,
241
+ object: () => objectType,
242
+ objectUtil: () => objectUtil,
243
+ oboolean: () => oboolean,
244
+ onumber: () => onumber,
245
+ optional: () => optionalType,
246
+ ostring: () => ostring,
247
+ pipeline: () => pipelineType,
248
+ preprocess: () => preprocessType,
249
+ promise: () => promiseType,
250
+ quotelessJson: () => quotelessJson,
251
+ record: () => recordType,
252
+ set: () => setType,
253
+ setErrorMap: () => setErrorMap,
254
+ strictObject: () => strictObjectType,
255
+ string: () => stringType,
256
+ symbol: () => symbolType,
257
+ transformer: () => effectsType,
258
+ tuple: () => tupleType,
259
+ undefined: () => undefinedType,
260
+ union: () => unionType,
261
+ unknown: () => unknownType,
262
+ util: () => util,
263
+ void: () => voidType
264
+ });
265
+
266
+ // ../../../node_modules/zod/v3/helpers/util.js
267
+ var util;
268
+ (function(util2) {
269
+ util2.assertEqual = (_) => {
270
+ };
271
+ function assertIs(_arg) {
272
+ }
273
+ util2.assertIs = assertIs;
274
+ function assertNever(_x) {
275
+ throw new Error();
276
+ }
277
+ util2.assertNever = assertNever;
278
+ util2.arrayToEnum = (items) => {
279
+ const obj = {};
280
+ for (const item of items) {
281
+ obj[item] = item;
282
+ }
283
+ return obj;
284
+ };
285
+ util2.getValidEnumValues = (obj) => {
286
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
287
+ const filtered = {};
288
+ for (const k of validKeys) {
289
+ filtered[k] = obj[k];
290
+ }
291
+ return util2.objectValues(filtered);
292
+ };
293
+ util2.objectValues = (obj) => {
294
+ return util2.objectKeys(obj).map(function(e2) {
295
+ return obj[e2];
296
+ });
297
+ };
298
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
299
+ const keys = [];
300
+ for (const key in object) {
301
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
302
+ keys.push(key);
303
+ }
304
+ }
305
+ return keys;
306
+ };
307
+ util2.find = (arr, checker) => {
308
+ for (const item of arr) {
309
+ if (checker(item))
310
+ return item;
311
+ }
312
+ return void 0;
313
+ };
314
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
315
+ function joinValues(array, separator = " | ") {
316
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
317
+ }
318
+ util2.joinValues = joinValues;
319
+ util2.jsonStringifyReplacer = (_, value) => {
320
+ if (typeof value === "bigint") {
321
+ return value.toString();
322
+ }
323
+ return value;
324
+ };
325
+ })(util || (util = {}));
326
+ var objectUtil;
327
+ (function(objectUtil2) {
328
+ objectUtil2.mergeShapes = (first, second) => {
329
+ return {
330
+ ...first,
331
+ ...second
332
+ // second overwrites first
333
+ };
334
+ };
335
+ })(objectUtil || (objectUtil = {}));
336
+ var ZodParsedType = util.arrayToEnum([
337
+ "string",
338
+ "nan",
339
+ "number",
340
+ "integer",
341
+ "float",
342
+ "boolean",
343
+ "date",
344
+ "bigint",
345
+ "symbol",
346
+ "function",
347
+ "undefined",
348
+ "null",
349
+ "array",
350
+ "object",
351
+ "unknown",
352
+ "promise",
353
+ "void",
354
+ "never",
355
+ "map",
356
+ "set"
357
+ ]);
358
+ var getParsedType = (data) => {
359
+ const t2 = typeof data;
360
+ switch (t2) {
361
+ case "undefined":
362
+ return ZodParsedType.undefined;
363
+ case "string":
364
+ return ZodParsedType.string;
365
+ case "number":
366
+ return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
367
+ case "boolean":
368
+ return ZodParsedType.boolean;
369
+ case "function":
370
+ return ZodParsedType.function;
371
+ case "bigint":
372
+ return ZodParsedType.bigint;
373
+ case "symbol":
374
+ return ZodParsedType.symbol;
375
+ case "object":
376
+ if (Array.isArray(data)) {
377
+ return ZodParsedType.array;
378
+ }
379
+ if (data === null) {
380
+ return ZodParsedType.null;
381
+ }
382
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
383
+ return ZodParsedType.promise;
384
+ }
385
+ if (typeof Map !== "undefined" && data instanceof Map) {
386
+ return ZodParsedType.map;
387
+ }
388
+ if (typeof Set !== "undefined" && data instanceof Set) {
389
+ return ZodParsedType.set;
390
+ }
391
+ if (typeof Date !== "undefined" && data instanceof Date) {
392
+ return ZodParsedType.date;
393
+ }
394
+ return ZodParsedType.object;
395
+ default:
396
+ return ZodParsedType.unknown;
397
+ }
398
+ };
399
+
400
+ // ../../../node_modules/zod/v3/ZodError.js
401
+ var ZodIssueCode = util.arrayToEnum([
402
+ "invalid_type",
403
+ "invalid_literal",
404
+ "custom",
405
+ "invalid_union",
406
+ "invalid_union_discriminator",
407
+ "invalid_enum_value",
408
+ "unrecognized_keys",
409
+ "invalid_arguments",
410
+ "invalid_return_type",
411
+ "invalid_date",
412
+ "invalid_string",
413
+ "too_small",
414
+ "too_big",
415
+ "invalid_intersection_types",
416
+ "not_multiple_of",
417
+ "not_finite"
418
+ ]);
419
+ var quotelessJson = (obj) => {
420
+ const json = JSON.stringify(obj, null, 2);
421
+ return json.replace(/"([^"]+)":/g, "$1:");
422
+ };
423
+ var ZodError = class _ZodError extends Error {
424
+ get errors() {
425
+ return this.issues;
426
+ }
427
+ constructor(issues) {
428
+ super();
429
+ this.issues = [];
430
+ this.addIssue = (sub) => {
431
+ this.issues = [...this.issues, sub];
432
+ };
433
+ this.addIssues = (subs = []) => {
434
+ this.issues = [...this.issues, ...subs];
435
+ };
436
+ const actualProto = new.target.prototype;
437
+ if (Object.setPrototypeOf) {
438
+ Object.setPrototypeOf(this, actualProto);
439
+ } else {
440
+ this.__proto__ = actualProto;
441
+ }
442
+ this.name = "ZodError";
443
+ this.issues = issues;
444
+ }
445
+ format(_mapper) {
446
+ const mapper = _mapper || function(issue) {
447
+ return issue.message;
448
+ };
449
+ const fieldErrors = { _errors: [] };
450
+ const processError = (error) => {
451
+ for (const issue of error.issues) {
452
+ if (issue.code === "invalid_union") {
453
+ issue.unionErrors.map(processError);
454
+ } else if (issue.code === "invalid_return_type") {
455
+ processError(issue.returnTypeError);
456
+ } else if (issue.code === "invalid_arguments") {
457
+ processError(issue.argumentsError);
458
+ } else if (issue.path.length === 0) {
459
+ fieldErrors._errors.push(mapper(issue));
460
+ } else {
461
+ let curr = fieldErrors;
462
+ let i2 = 0;
463
+ while (i2 < issue.path.length) {
464
+ const el = issue.path[i2];
465
+ const terminal = i2 === issue.path.length - 1;
466
+ if (!terminal) {
467
+ curr[el] = curr[el] || { _errors: [] };
468
+ } else {
469
+ curr[el] = curr[el] || { _errors: [] };
470
+ curr[el]._errors.push(mapper(issue));
471
+ }
472
+ curr = curr[el];
473
+ i2++;
474
+ }
475
+ }
476
+ }
477
+ };
478
+ processError(this);
479
+ return fieldErrors;
480
+ }
481
+ static assert(value) {
482
+ if (!(value instanceof _ZodError)) {
483
+ throw new Error(`Not a ZodError: ${value}`);
484
+ }
485
+ }
486
+ toString() {
487
+ return this.message;
488
+ }
489
+ get message() {
490
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
491
+ }
492
+ get isEmpty() {
493
+ return this.issues.length === 0;
494
+ }
495
+ flatten(mapper = (issue) => issue.message) {
496
+ const fieldErrors = {};
497
+ const formErrors = [];
498
+ for (const sub of this.issues) {
499
+ if (sub.path.length > 0) {
500
+ const firstEl = sub.path[0];
501
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
502
+ fieldErrors[firstEl].push(mapper(sub));
503
+ } else {
504
+ formErrors.push(mapper(sub));
505
+ }
506
+ }
507
+ return { formErrors, fieldErrors };
508
+ }
509
+ get formErrors() {
510
+ return this.flatten();
511
+ }
512
+ };
513
+ ZodError.create = (issues) => {
514
+ const error = new ZodError(issues);
515
+ return error;
516
+ };
517
+
518
+ // ../../../node_modules/zod/v3/locales/en.js
519
+ var errorMap = (issue, _ctx) => {
520
+ let message;
521
+ switch (issue.code) {
522
+ case ZodIssueCode.invalid_type:
523
+ if (issue.received === ZodParsedType.undefined) {
524
+ message = "Required";
525
+ } else {
526
+ message = `Expected ${issue.expected}, received ${issue.received}`;
527
+ }
528
+ break;
529
+ case ZodIssueCode.invalid_literal:
530
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
531
+ break;
532
+ case ZodIssueCode.unrecognized_keys:
533
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
534
+ break;
535
+ case ZodIssueCode.invalid_union:
536
+ message = `Invalid input`;
537
+ break;
538
+ case ZodIssueCode.invalid_union_discriminator:
539
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
540
+ break;
541
+ case ZodIssueCode.invalid_enum_value:
542
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
543
+ break;
544
+ case ZodIssueCode.invalid_arguments:
545
+ message = `Invalid function arguments`;
546
+ break;
547
+ case ZodIssueCode.invalid_return_type:
548
+ message = `Invalid function return type`;
549
+ break;
550
+ case ZodIssueCode.invalid_date:
551
+ message = `Invalid date`;
552
+ break;
553
+ case ZodIssueCode.invalid_string:
554
+ if (typeof issue.validation === "object") {
555
+ if ("includes" in issue.validation) {
556
+ message = `Invalid input: must include "${issue.validation.includes}"`;
557
+ if (typeof issue.validation.position === "number") {
558
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
559
+ }
560
+ } else if ("startsWith" in issue.validation) {
561
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
562
+ } else if ("endsWith" in issue.validation) {
563
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
564
+ } else {
565
+ util.assertNever(issue.validation);
566
+ }
567
+ } else if (issue.validation !== "regex") {
568
+ message = `Invalid ${issue.validation}`;
569
+ } else {
570
+ message = "Invalid";
571
+ }
572
+ break;
573
+ case ZodIssueCode.too_small:
574
+ if (issue.type === "array")
575
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
576
+ else if (issue.type === "string")
577
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
578
+ else if (issue.type === "number")
579
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
580
+ else if (issue.type === "bigint")
581
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
582
+ else if (issue.type === "date")
583
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
584
+ else
585
+ message = "Invalid input";
586
+ break;
587
+ case ZodIssueCode.too_big:
588
+ if (issue.type === "array")
589
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
590
+ else if (issue.type === "string")
591
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
592
+ else if (issue.type === "number")
593
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
594
+ else if (issue.type === "bigint")
595
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
596
+ else if (issue.type === "date")
597
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
598
+ else
599
+ message = "Invalid input";
600
+ break;
601
+ case ZodIssueCode.custom:
602
+ message = `Invalid input`;
603
+ break;
604
+ case ZodIssueCode.invalid_intersection_types:
605
+ message = `Intersection results could not be merged`;
606
+ break;
607
+ case ZodIssueCode.not_multiple_of:
608
+ message = `Number must be a multiple of ${issue.multipleOf}`;
609
+ break;
610
+ case ZodIssueCode.not_finite:
611
+ message = "Number must be finite";
612
+ break;
613
+ default:
614
+ message = _ctx.defaultError;
615
+ util.assertNever(issue);
616
+ }
617
+ return { message };
618
+ };
619
+ var en_default = errorMap;
620
+
621
+ // ../../../node_modules/zod/v3/errors.js
622
+ var overrideErrorMap = en_default;
623
+ function setErrorMap(map) {
624
+ overrideErrorMap = map;
625
+ }
626
+ function getErrorMap() {
627
+ return overrideErrorMap;
628
+ }
629
+
630
+ // ../../../node_modules/zod/v3/helpers/parseUtil.js
631
+ var makeIssue = (params) => {
632
+ const { data, path, errorMaps, issueData } = params;
633
+ const fullPath = [...path, ...issueData.path || []];
634
+ const fullIssue = {
635
+ ...issueData,
636
+ path: fullPath
637
+ };
638
+ if (issueData.message !== void 0) {
639
+ return {
640
+ ...issueData,
641
+ path: fullPath,
642
+ message: issueData.message
643
+ };
644
+ }
645
+ let errorMessage = "";
646
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
647
+ for (const map of maps) {
648
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
649
+ }
650
+ return {
651
+ ...issueData,
652
+ path: fullPath,
653
+ message: errorMessage
654
+ };
655
+ };
656
+ var EMPTY_PATH = [];
657
+ function addIssueToContext(ctx, issueData) {
658
+ const overrideMap = getErrorMap();
659
+ const issue = makeIssue({
660
+ issueData,
661
+ data: ctx.data,
662
+ path: ctx.path,
663
+ errorMaps: [
664
+ ctx.common.contextualErrorMap,
665
+ // contextual error map is first priority
666
+ ctx.schemaErrorMap,
667
+ // then schema-bound map if available
668
+ overrideMap,
669
+ // then global override map
670
+ overrideMap === en_default ? void 0 : en_default
671
+ // then global default map
672
+ ].filter((x) => !!x)
673
+ });
674
+ ctx.common.issues.push(issue);
675
+ }
676
+ var ParseStatus = class _ParseStatus {
677
+ constructor() {
678
+ this.value = "valid";
679
+ }
680
+ dirty() {
681
+ if (this.value === "valid")
682
+ this.value = "dirty";
683
+ }
684
+ abort() {
685
+ if (this.value !== "aborted")
686
+ this.value = "aborted";
687
+ }
688
+ static mergeArray(status, results) {
689
+ const arrayValue = [];
690
+ for (const s4 of results) {
691
+ if (s4.status === "aborted")
692
+ return INVALID;
693
+ if (s4.status === "dirty")
694
+ status.dirty();
695
+ arrayValue.push(s4.value);
696
+ }
697
+ return { status: status.value, value: arrayValue };
698
+ }
699
+ static async mergeObjectAsync(status, pairs) {
700
+ const syncPairs = [];
701
+ for (const pair of pairs) {
702
+ const key = await pair.key;
703
+ const value = await pair.value;
704
+ syncPairs.push({
705
+ key,
706
+ value
707
+ });
708
+ }
709
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
710
+ }
711
+ static mergeObjectSync(status, pairs) {
712
+ const finalObject = {};
713
+ for (const pair of pairs) {
714
+ const { key, value } = pair;
715
+ if (key.status === "aborted")
716
+ return INVALID;
717
+ if (value.status === "aborted")
718
+ return INVALID;
719
+ if (key.status === "dirty")
720
+ status.dirty();
721
+ if (value.status === "dirty")
722
+ status.dirty();
723
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
724
+ finalObject[key.value] = value.value;
725
+ }
726
+ }
727
+ return { status: status.value, value: finalObject };
728
+ }
729
+ };
730
+ var INVALID = Object.freeze({
731
+ status: "aborted"
732
+ });
733
+ var DIRTY = (value) => ({ status: "dirty", value });
734
+ var OK = (value) => ({ status: "valid", value });
735
+ var isAborted = (x) => x.status === "aborted";
736
+ var isDirty = (x) => x.status === "dirty";
737
+ var isValid = (x) => x.status === "valid";
738
+ var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
739
+
740
+ // ../../../node_modules/zod/v3/helpers/errorUtil.js
741
+ var errorUtil;
742
+ (function(errorUtil2) {
743
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
744
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
745
+ })(errorUtil || (errorUtil = {}));
746
+
747
+ // ../../../node_modules/zod/v3/types.js
748
+ var ParseInputLazyPath = class {
749
+ constructor(parent, value, path, key) {
750
+ this._cachedPath = [];
751
+ this.parent = parent;
752
+ this.data = value;
753
+ this._path = path;
754
+ this._key = key;
755
+ }
756
+ get path() {
757
+ if (!this._cachedPath.length) {
758
+ if (Array.isArray(this._key)) {
759
+ this._cachedPath.push(...this._path, ...this._key);
760
+ } else {
761
+ this._cachedPath.push(...this._path, this._key);
762
+ }
763
+ }
764
+ return this._cachedPath;
765
+ }
766
+ };
767
+ var handleResult = (ctx, result) => {
768
+ if (isValid(result)) {
769
+ return { success: true, data: result.value };
770
+ } else {
771
+ if (!ctx.common.issues.length) {
772
+ throw new Error("Validation failed but no issues detected.");
773
+ }
774
+ return {
775
+ success: false,
776
+ get error() {
777
+ if (this._error)
778
+ return this._error;
779
+ const error = new ZodError(ctx.common.issues);
780
+ this._error = error;
781
+ return this._error;
782
+ }
783
+ };
784
+ }
785
+ };
786
+ function processCreateParams(params) {
787
+ if (!params)
788
+ return {};
789
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
790
+ if (errorMap2 && (invalid_type_error || required_error)) {
791
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
792
+ }
793
+ if (errorMap2)
794
+ return { errorMap: errorMap2, description };
795
+ const customMap = (iss, ctx) => {
796
+ const { message } = params;
797
+ if (iss.code === "invalid_enum_value") {
798
+ return { message: message ?? ctx.defaultError };
799
+ }
800
+ if (typeof ctx.data === "undefined") {
801
+ return { message: message ?? required_error ?? ctx.defaultError };
802
+ }
803
+ if (iss.code !== "invalid_type")
804
+ return { message: ctx.defaultError };
805
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
806
+ };
807
+ return { errorMap: customMap, description };
808
+ }
809
+ var ZodType = class {
810
+ get description() {
811
+ return this._def.description;
812
+ }
813
+ _getType(input) {
814
+ return getParsedType(input.data);
815
+ }
816
+ _getOrReturnCtx(input, ctx) {
817
+ return ctx || {
818
+ common: input.parent.common,
819
+ data: input.data,
820
+ parsedType: getParsedType(input.data),
821
+ schemaErrorMap: this._def.errorMap,
822
+ path: input.path,
823
+ parent: input.parent
824
+ };
825
+ }
826
+ _processInputParams(input) {
827
+ return {
828
+ status: new ParseStatus(),
829
+ ctx: {
830
+ common: input.parent.common,
831
+ data: input.data,
832
+ parsedType: getParsedType(input.data),
833
+ schemaErrorMap: this._def.errorMap,
834
+ path: input.path,
835
+ parent: input.parent
836
+ }
837
+ };
838
+ }
839
+ _parseSync(input) {
840
+ const result = this._parse(input);
841
+ if (isAsync(result)) {
842
+ throw new Error("Synchronous parse encountered promise.");
843
+ }
844
+ return result;
845
+ }
846
+ _parseAsync(input) {
847
+ const result = this._parse(input);
848
+ return Promise.resolve(result);
849
+ }
850
+ parse(data, params) {
851
+ const result = this.safeParse(data, params);
852
+ if (result.success)
853
+ return result.data;
854
+ throw result.error;
855
+ }
856
+ safeParse(data, params) {
857
+ const ctx = {
858
+ common: {
859
+ issues: [],
860
+ async: params?.async ?? false,
861
+ contextualErrorMap: params?.errorMap
862
+ },
863
+ path: params?.path || [],
864
+ schemaErrorMap: this._def.errorMap,
865
+ parent: null,
866
+ data,
867
+ parsedType: getParsedType(data)
868
+ };
869
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
870
+ return handleResult(ctx, result);
871
+ }
872
+ "~validate"(data) {
873
+ const ctx = {
874
+ common: {
875
+ issues: [],
876
+ async: !!this["~standard"].async
877
+ },
878
+ path: [],
879
+ schemaErrorMap: this._def.errorMap,
880
+ parent: null,
881
+ data,
882
+ parsedType: getParsedType(data)
883
+ };
884
+ if (!this["~standard"].async) {
885
+ try {
886
+ const result = this._parseSync({ data, path: [], parent: ctx });
887
+ return isValid(result) ? {
888
+ value: result.value
889
+ } : {
890
+ issues: ctx.common.issues
891
+ };
892
+ } catch (err) {
893
+ if (err?.message?.toLowerCase()?.includes("encountered")) {
894
+ this["~standard"].async = true;
895
+ }
896
+ ctx.common = {
897
+ issues: [],
898
+ async: true
899
+ };
900
+ }
901
+ }
902
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
903
+ value: result.value
904
+ } : {
905
+ issues: ctx.common.issues
906
+ });
907
+ }
908
+ async parseAsync(data, params) {
909
+ const result = await this.safeParseAsync(data, params);
910
+ if (result.success)
911
+ return result.data;
912
+ throw result.error;
913
+ }
914
+ async safeParseAsync(data, params) {
915
+ const ctx = {
916
+ common: {
917
+ issues: [],
918
+ contextualErrorMap: params?.errorMap,
919
+ async: true
920
+ },
921
+ path: params?.path || [],
922
+ schemaErrorMap: this._def.errorMap,
923
+ parent: null,
924
+ data,
925
+ parsedType: getParsedType(data)
926
+ };
927
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
928
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
929
+ return handleResult(ctx, result);
930
+ }
931
+ refine(check, message) {
932
+ const getIssueProperties = (val) => {
933
+ if (typeof message === "string" || typeof message === "undefined") {
934
+ return { message };
935
+ } else if (typeof message === "function") {
936
+ return message(val);
937
+ } else {
938
+ return message;
939
+ }
940
+ };
941
+ return this._refinement((val, ctx) => {
942
+ const result = check(val);
943
+ const setError = () => ctx.addIssue({
944
+ code: ZodIssueCode.custom,
945
+ ...getIssueProperties(val)
946
+ });
947
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
948
+ return result.then((data) => {
949
+ if (!data) {
950
+ setError();
951
+ return false;
952
+ } else {
953
+ return true;
954
+ }
955
+ });
956
+ }
957
+ if (!result) {
958
+ setError();
959
+ return false;
960
+ } else {
961
+ return true;
962
+ }
963
+ });
964
+ }
965
+ refinement(check, refinementData) {
966
+ return this._refinement((val, ctx) => {
967
+ if (!check(val)) {
968
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
969
+ return false;
970
+ } else {
971
+ return true;
972
+ }
973
+ });
974
+ }
975
+ _refinement(refinement) {
976
+ return new ZodEffects({
977
+ schema: this,
978
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
979
+ effect: { type: "refinement", refinement }
980
+ });
981
+ }
982
+ superRefine(refinement) {
983
+ return this._refinement(refinement);
984
+ }
985
+ constructor(def) {
986
+ this.spa = this.safeParseAsync;
987
+ this._def = def;
988
+ this.parse = this.parse.bind(this);
989
+ this.safeParse = this.safeParse.bind(this);
990
+ this.parseAsync = this.parseAsync.bind(this);
991
+ this.safeParseAsync = this.safeParseAsync.bind(this);
992
+ this.spa = this.spa.bind(this);
993
+ this.refine = this.refine.bind(this);
994
+ this.refinement = this.refinement.bind(this);
995
+ this.superRefine = this.superRefine.bind(this);
996
+ this.optional = this.optional.bind(this);
997
+ this.nullable = this.nullable.bind(this);
998
+ this.nullish = this.nullish.bind(this);
999
+ this.array = this.array.bind(this);
1000
+ this.promise = this.promise.bind(this);
1001
+ this.or = this.or.bind(this);
1002
+ this.and = this.and.bind(this);
1003
+ this.transform = this.transform.bind(this);
1004
+ this.brand = this.brand.bind(this);
1005
+ this.default = this.default.bind(this);
1006
+ this.catch = this.catch.bind(this);
1007
+ this.describe = this.describe.bind(this);
1008
+ this.pipe = this.pipe.bind(this);
1009
+ this.readonly = this.readonly.bind(this);
1010
+ this.isNullable = this.isNullable.bind(this);
1011
+ this.isOptional = this.isOptional.bind(this);
1012
+ this["~standard"] = {
1013
+ version: 1,
1014
+ vendor: "zod",
1015
+ validate: (data) => this["~validate"](data)
1016
+ };
1017
+ }
1018
+ optional() {
1019
+ return ZodOptional.create(this, this._def);
1020
+ }
1021
+ nullable() {
1022
+ return ZodNullable.create(this, this._def);
1023
+ }
1024
+ nullish() {
1025
+ return this.nullable().optional();
1026
+ }
1027
+ array() {
1028
+ return ZodArray.create(this);
1029
+ }
1030
+ promise() {
1031
+ return ZodPromise.create(this, this._def);
1032
+ }
1033
+ or(option) {
1034
+ return ZodUnion.create([this, option], this._def);
1035
+ }
1036
+ and(incoming) {
1037
+ return ZodIntersection.create(this, incoming, this._def);
1038
+ }
1039
+ transform(transform) {
1040
+ return new ZodEffects({
1041
+ ...processCreateParams(this._def),
1042
+ schema: this,
1043
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
1044
+ effect: { type: "transform", transform }
1045
+ });
1046
+ }
1047
+ default(def) {
1048
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
1049
+ return new ZodDefault({
1050
+ ...processCreateParams(this._def),
1051
+ innerType: this,
1052
+ defaultValue: defaultValueFunc,
1053
+ typeName: ZodFirstPartyTypeKind.ZodDefault
1054
+ });
1055
+ }
1056
+ brand() {
1057
+ return new ZodBranded({
1058
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
1059
+ type: this,
1060
+ ...processCreateParams(this._def)
1061
+ });
1062
+ }
1063
+ catch(def) {
1064
+ const catchValueFunc = typeof def === "function" ? def : () => def;
1065
+ return new ZodCatch({
1066
+ ...processCreateParams(this._def),
1067
+ innerType: this,
1068
+ catchValue: catchValueFunc,
1069
+ typeName: ZodFirstPartyTypeKind.ZodCatch
1070
+ });
1071
+ }
1072
+ describe(description) {
1073
+ const This = this.constructor;
1074
+ return new This({
1075
+ ...this._def,
1076
+ description
1077
+ });
1078
+ }
1079
+ pipe(target) {
1080
+ return ZodPipeline.create(this, target);
1081
+ }
1082
+ readonly() {
1083
+ return ZodReadonly.create(this);
1084
+ }
1085
+ isOptional() {
1086
+ return this.safeParse(void 0).success;
1087
+ }
1088
+ isNullable() {
1089
+ return this.safeParse(null).success;
1090
+ }
1091
+ };
1092
+ var cuidRegex = /^c[^\s-]{8,}$/i;
1093
+ var cuid2Regex = /^[0-9a-z]+$/;
1094
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
1095
+ 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;
1096
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
1097
+ var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
1098
+ 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)?)??$/;
1099
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
1100
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
1101
+ var emojiRegex;
1102
+ 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])$/;
1103
+ 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])$/;
1104
+ 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]))$/;
1105
+ 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])$/;
1106
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
1107
+ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
1108
+ 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])))`;
1109
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
1110
+ function timeRegexSource(args) {
1111
+ let secondsRegexSource = `[0-5]\\d`;
1112
+ if (args.precision) {
1113
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
1114
+ } else if (args.precision == null) {
1115
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
1116
+ }
1117
+ const secondsQuantifier = args.precision ? "+" : "?";
1118
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
1119
+ }
1120
+ function timeRegex(args) {
1121
+ return new RegExp(`^${timeRegexSource(args)}$`);
1122
+ }
1123
+ function datetimeRegex(args) {
1124
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
1125
+ const opts = [];
1126
+ opts.push(args.local ? `Z?` : `Z`);
1127
+ if (args.offset)
1128
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
1129
+ regex = `${regex}(${opts.join("|")})`;
1130
+ return new RegExp(`^${regex}$`);
1131
+ }
1132
+ function isValidIP(ip, version) {
1133
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
1134
+ return true;
1135
+ }
1136
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
1137
+ return true;
1138
+ }
1139
+ return false;
1140
+ }
1141
+ function isValidJWT(jwt, alg) {
1142
+ if (!jwtRegex.test(jwt))
1143
+ return false;
1144
+ try {
1145
+ const [header] = jwt.split(".");
1146
+ if (!header)
1147
+ return false;
1148
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
1149
+ const decoded = JSON.parse(atob(base64));
1150
+ if (typeof decoded !== "object" || decoded === null)
1151
+ return false;
1152
+ if ("typ" in decoded && decoded?.typ !== "JWT")
1153
+ return false;
1154
+ if (!decoded.alg)
1155
+ return false;
1156
+ if (alg && decoded.alg !== alg)
1157
+ return false;
1158
+ return true;
1159
+ } catch {
1160
+ return false;
1161
+ }
1162
+ }
1163
+ function isValidCidr(ip, version) {
1164
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
1165
+ return true;
1166
+ }
1167
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
1168
+ return true;
1169
+ }
1170
+ return false;
1171
+ }
1172
+ var ZodString = class _ZodString extends ZodType {
1173
+ _parse(input) {
1174
+ if (this._def.coerce) {
1175
+ input.data = String(input.data);
1176
+ }
1177
+ const parsedType = this._getType(input);
1178
+ if (parsedType !== ZodParsedType.string) {
1179
+ const ctx2 = this._getOrReturnCtx(input);
1180
+ addIssueToContext(ctx2, {
1181
+ code: ZodIssueCode.invalid_type,
1182
+ expected: ZodParsedType.string,
1183
+ received: ctx2.parsedType
1184
+ });
1185
+ return INVALID;
1186
+ }
1187
+ const status = new ParseStatus();
1188
+ let ctx = void 0;
1189
+ for (const check of this._def.checks) {
1190
+ if (check.kind === "min") {
1191
+ if (input.data.length < check.value) {
1192
+ ctx = this._getOrReturnCtx(input, ctx);
1193
+ addIssueToContext(ctx, {
1194
+ code: ZodIssueCode.too_small,
1195
+ minimum: check.value,
1196
+ type: "string",
1197
+ inclusive: true,
1198
+ exact: false,
1199
+ message: check.message
1200
+ });
1201
+ status.dirty();
1202
+ }
1203
+ } else if (check.kind === "max") {
1204
+ if (input.data.length > check.value) {
1205
+ ctx = this._getOrReturnCtx(input, ctx);
1206
+ addIssueToContext(ctx, {
1207
+ code: ZodIssueCode.too_big,
1208
+ maximum: check.value,
1209
+ type: "string",
1210
+ inclusive: true,
1211
+ exact: false,
1212
+ message: check.message
1213
+ });
1214
+ status.dirty();
1215
+ }
1216
+ } else if (check.kind === "length") {
1217
+ const tooBig = input.data.length > check.value;
1218
+ const tooSmall = input.data.length < check.value;
1219
+ if (tooBig || tooSmall) {
1220
+ ctx = this._getOrReturnCtx(input, ctx);
1221
+ if (tooBig) {
1222
+ addIssueToContext(ctx, {
1223
+ code: ZodIssueCode.too_big,
1224
+ maximum: check.value,
1225
+ type: "string",
1226
+ inclusive: true,
1227
+ exact: true,
1228
+ message: check.message
1229
+ });
1230
+ } else if (tooSmall) {
1231
+ addIssueToContext(ctx, {
1232
+ code: ZodIssueCode.too_small,
1233
+ minimum: check.value,
1234
+ type: "string",
1235
+ inclusive: true,
1236
+ exact: true,
1237
+ message: check.message
1238
+ });
1239
+ }
1240
+ status.dirty();
1241
+ }
1242
+ } else if (check.kind === "email") {
1243
+ if (!emailRegex.test(input.data)) {
1244
+ ctx = this._getOrReturnCtx(input, ctx);
1245
+ addIssueToContext(ctx, {
1246
+ validation: "email",
1247
+ code: ZodIssueCode.invalid_string,
1248
+ message: check.message
1249
+ });
1250
+ status.dirty();
1251
+ }
1252
+ } else if (check.kind === "emoji") {
1253
+ if (!emojiRegex) {
1254
+ emojiRegex = new RegExp(_emojiRegex, "u");
1255
+ }
1256
+ if (!emojiRegex.test(input.data)) {
1257
+ ctx = this._getOrReturnCtx(input, ctx);
1258
+ addIssueToContext(ctx, {
1259
+ validation: "emoji",
1260
+ code: ZodIssueCode.invalid_string,
1261
+ message: check.message
1262
+ });
1263
+ status.dirty();
1264
+ }
1265
+ } else if (check.kind === "uuid") {
1266
+ if (!uuidRegex.test(input.data)) {
1267
+ ctx = this._getOrReturnCtx(input, ctx);
1268
+ addIssueToContext(ctx, {
1269
+ validation: "uuid",
1270
+ code: ZodIssueCode.invalid_string,
1271
+ message: check.message
1272
+ });
1273
+ status.dirty();
1274
+ }
1275
+ } else if (check.kind === "nanoid") {
1276
+ if (!nanoidRegex.test(input.data)) {
1277
+ ctx = this._getOrReturnCtx(input, ctx);
1278
+ addIssueToContext(ctx, {
1279
+ validation: "nanoid",
1280
+ code: ZodIssueCode.invalid_string,
1281
+ message: check.message
1282
+ });
1283
+ status.dirty();
1284
+ }
1285
+ } else if (check.kind === "cuid") {
1286
+ if (!cuidRegex.test(input.data)) {
1287
+ ctx = this._getOrReturnCtx(input, ctx);
1288
+ addIssueToContext(ctx, {
1289
+ validation: "cuid",
1290
+ code: ZodIssueCode.invalid_string,
1291
+ message: check.message
1292
+ });
1293
+ status.dirty();
1294
+ }
1295
+ } else if (check.kind === "cuid2") {
1296
+ if (!cuid2Regex.test(input.data)) {
1297
+ ctx = this._getOrReturnCtx(input, ctx);
1298
+ addIssueToContext(ctx, {
1299
+ validation: "cuid2",
1300
+ code: ZodIssueCode.invalid_string,
1301
+ message: check.message
1302
+ });
1303
+ status.dirty();
1304
+ }
1305
+ } else if (check.kind === "ulid") {
1306
+ if (!ulidRegex.test(input.data)) {
1307
+ ctx = this._getOrReturnCtx(input, ctx);
1308
+ addIssueToContext(ctx, {
1309
+ validation: "ulid",
1310
+ code: ZodIssueCode.invalid_string,
1311
+ message: check.message
1312
+ });
1313
+ status.dirty();
1314
+ }
1315
+ } else if (check.kind === "url") {
1316
+ try {
1317
+ new URL(input.data);
1318
+ } catch {
1319
+ ctx = this._getOrReturnCtx(input, ctx);
1320
+ addIssueToContext(ctx, {
1321
+ validation: "url",
1322
+ code: ZodIssueCode.invalid_string,
1323
+ message: check.message
1324
+ });
1325
+ status.dirty();
1326
+ }
1327
+ } else if (check.kind === "regex") {
1328
+ check.regex.lastIndex = 0;
1329
+ const testResult = check.regex.test(input.data);
1330
+ if (!testResult) {
1331
+ ctx = this._getOrReturnCtx(input, ctx);
1332
+ addIssueToContext(ctx, {
1333
+ validation: "regex",
1334
+ code: ZodIssueCode.invalid_string,
1335
+ message: check.message
1336
+ });
1337
+ status.dirty();
1338
+ }
1339
+ } else if (check.kind === "trim") {
1340
+ input.data = input.data.trim();
1341
+ } else if (check.kind === "includes") {
1342
+ if (!input.data.includes(check.value, check.position)) {
1343
+ ctx = this._getOrReturnCtx(input, ctx);
1344
+ addIssueToContext(ctx, {
1345
+ code: ZodIssueCode.invalid_string,
1346
+ validation: { includes: check.value, position: check.position },
1347
+ message: check.message
1348
+ });
1349
+ status.dirty();
1350
+ }
1351
+ } else if (check.kind === "toLowerCase") {
1352
+ input.data = input.data.toLowerCase();
1353
+ } else if (check.kind === "toUpperCase") {
1354
+ input.data = input.data.toUpperCase();
1355
+ } else if (check.kind === "startsWith") {
1356
+ if (!input.data.startsWith(check.value)) {
1357
+ ctx = this._getOrReturnCtx(input, ctx);
1358
+ addIssueToContext(ctx, {
1359
+ code: ZodIssueCode.invalid_string,
1360
+ validation: { startsWith: check.value },
1361
+ message: check.message
1362
+ });
1363
+ status.dirty();
1364
+ }
1365
+ } else if (check.kind === "endsWith") {
1366
+ if (!input.data.endsWith(check.value)) {
1367
+ ctx = this._getOrReturnCtx(input, ctx);
1368
+ addIssueToContext(ctx, {
1369
+ code: ZodIssueCode.invalid_string,
1370
+ validation: { endsWith: check.value },
1371
+ message: check.message
1372
+ });
1373
+ status.dirty();
1374
+ }
1375
+ } else if (check.kind === "datetime") {
1376
+ const regex = datetimeRegex(check);
1377
+ if (!regex.test(input.data)) {
1378
+ ctx = this._getOrReturnCtx(input, ctx);
1379
+ addIssueToContext(ctx, {
1380
+ code: ZodIssueCode.invalid_string,
1381
+ validation: "datetime",
1382
+ message: check.message
1383
+ });
1384
+ status.dirty();
1385
+ }
1386
+ } else if (check.kind === "date") {
1387
+ const regex = dateRegex;
1388
+ if (!regex.test(input.data)) {
1389
+ ctx = this._getOrReturnCtx(input, ctx);
1390
+ addIssueToContext(ctx, {
1391
+ code: ZodIssueCode.invalid_string,
1392
+ validation: "date",
1393
+ message: check.message
1394
+ });
1395
+ status.dirty();
1396
+ }
1397
+ } else if (check.kind === "time") {
1398
+ const regex = timeRegex(check);
1399
+ if (!regex.test(input.data)) {
1400
+ ctx = this._getOrReturnCtx(input, ctx);
1401
+ addIssueToContext(ctx, {
1402
+ code: ZodIssueCode.invalid_string,
1403
+ validation: "time",
1404
+ message: check.message
1405
+ });
1406
+ status.dirty();
1407
+ }
1408
+ } else if (check.kind === "duration") {
1409
+ if (!durationRegex.test(input.data)) {
1410
+ ctx = this._getOrReturnCtx(input, ctx);
1411
+ addIssueToContext(ctx, {
1412
+ validation: "duration",
1413
+ code: ZodIssueCode.invalid_string,
1414
+ message: check.message
1415
+ });
1416
+ status.dirty();
1417
+ }
1418
+ } else if (check.kind === "ip") {
1419
+ if (!isValidIP(input.data, check.version)) {
1420
+ ctx = this._getOrReturnCtx(input, ctx);
1421
+ addIssueToContext(ctx, {
1422
+ validation: "ip",
1423
+ code: ZodIssueCode.invalid_string,
1424
+ message: check.message
1425
+ });
1426
+ status.dirty();
1427
+ }
1428
+ } else if (check.kind === "jwt") {
1429
+ if (!isValidJWT(input.data, check.alg)) {
1430
+ ctx = this._getOrReturnCtx(input, ctx);
1431
+ addIssueToContext(ctx, {
1432
+ validation: "jwt",
1433
+ code: ZodIssueCode.invalid_string,
1434
+ message: check.message
1435
+ });
1436
+ status.dirty();
1437
+ }
1438
+ } else if (check.kind === "cidr") {
1439
+ if (!isValidCidr(input.data, check.version)) {
1440
+ ctx = this._getOrReturnCtx(input, ctx);
1441
+ addIssueToContext(ctx, {
1442
+ validation: "cidr",
1443
+ code: ZodIssueCode.invalid_string,
1444
+ message: check.message
1445
+ });
1446
+ status.dirty();
1447
+ }
1448
+ } else if (check.kind === "base64") {
1449
+ if (!base64Regex.test(input.data)) {
1450
+ ctx = this._getOrReturnCtx(input, ctx);
1451
+ addIssueToContext(ctx, {
1452
+ validation: "base64",
1453
+ code: ZodIssueCode.invalid_string,
1454
+ message: check.message
1455
+ });
1456
+ status.dirty();
1457
+ }
1458
+ } else if (check.kind === "base64url") {
1459
+ if (!base64urlRegex.test(input.data)) {
1460
+ ctx = this._getOrReturnCtx(input, ctx);
1461
+ addIssueToContext(ctx, {
1462
+ validation: "base64url",
1463
+ code: ZodIssueCode.invalid_string,
1464
+ message: check.message
1465
+ });
1466
+ status.dirty();
1467
+ }
1468
+ } else {
1469
+ util.assertNever(check);
1470
+ }
1471
+ }
1472
+ return { status: status.value, value: input.data };
1473
+ }
1474
+ _regex(regex, validation, message) {
1475
+ return this.refinement((data) => regex.test(data), {
1476
+ validation,
1477
+ code: ZodIssueCode.invalid_string,
1478
+ ...errorUtil.errToObj(message)
1479
+ });
1480
+ }
1481
+ _addCheck(check) {
1482
+ return new _ZodString({
1483
+ ...this._def,
1484
+ checks: [...this._def.checks, check]
1485
+ });
1486
+ }
1487
+ email(message) {
1488
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
1489
+ }
1490
+ url(message) {
1491
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
1492
+ }
1493
+ emoji(message) {
1494
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
1495
+ }
1496
+ uuid(message) {
1497
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
1498
+ }
1499
+ nanoid(message) {
1500
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
1501
+ }
1502
+ cuid(message) {
1503
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
1504
+ }
1505
+ cuid2(message) {
1506
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
1507
+ }
1508
+ ulid(message) {
1509
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
1510
+ }
1511
+ base64(message) {
1512
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
1513
+ }
1514
+ base64url(message) {
1515
+ return this._addCheck({
1516
+ kind: "base64url",
1517
+ ...errorUtil.errToObj(message)
1518
+ });
1519
+ }
1520
+ jwt(options) {
1521
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
1522
+ }
1523
+ ip(options) {
1524
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
1525
+ }
1526
+ cidr(options) {
1527
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
1528
+ }
1529
+ datetime(options) {
1530
+ if (typeof options === "string") {
1531
+ return this._addCheck({
1532
+ kind: "datetime",
1533
+ precision: null,
1534
+ offset: false,
1535
+ local: false,
1536
+ message: options
1537
+ });
1538
+ }
1539
+ return this._addCheck({
1540
+ kind: "datetime",
1541
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1542
+ offset: options?.offset ?? false,
1543
+ local: options?.local ?? false,
1544
+ ...errorUtil.errToObj(options?.message)
1545
+ });
1546
+ }
1547
+ date(message) {
1548
+ return this._addCheck({ kind: "date", message });
1549
+ }
1550
+ time(options) {
1551
+ if (typeof options === "string") {
1552
+ return this._addCheck({
1553
+ kind: "time",
1554
+ precision: null,
1555
+ message: options
1556
+ });
1557
+ }
1558
+ return this._addCheck({
1559
+ kind: "time",
1560
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
1561
+ ...errorUtil.errToObj(options?.message)
1562
+ });
1563
+ }
1564
+ duration(message) {
1565
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
1566
+ }
1567
+ regex(regex, message) {
1568
+ return this._addCheck({
1569
+ kind: "regex",
1570
+ regex,
1571
+ ...errorUtil.errToObj(message)
1572
+ });
1573
+ }
1574
+ includes(value, options) {
1575
+ return this._addCheck({
1576
+ kind: "includes",
1577
+ value,
1578
+ position: options?.position,
1579
+ ...errorUtil.errToObj(options?.message)
1580
+ });
1581
+ }
1582
+ startsWith(value, message) {
1583
+ return this._addCheck({
1584
+ kind: "startsWith",
1585
+ value,
1586
+ ...errorUtil.errToObj(message)
1587
+ });
1588
+ }
1589
+ endsWith(value, message) {
1590
+ return this._addCheck({
1591
+ kind: "endsWith",
1592
+ value,
1593
+ ...errorUtil.errToObj(message)
1594
+ });
1595
+ }
1596
+ min(minLength, message) {
1597
+ return this._addCheck({
1598
+ kind: "min",
1599
+ value: minLength,
1600
+ ...errorUtil.errToObj(message)
1601
+ });
1602
+ }
1603
+ max(maxLength, message) {
1604
+ return this._addCheck({
1605
+ kind: "max",
1606
+ value: maxLength,
1607
+ ...errorUtil.errToObj(message)
1608
+ });
1609
+ }
1610
+ length(len, message) {
1611
+ return this._addCheck({
1612
+ kind: "length",
1613
+ value: len,
1614
+ ...errorUtil.errToObj(message)
1615
+ });
1616
+ }
1617
+ /**
1618
+ * Equivalent to `.min(1)`
1619
+ */
1620
+ nonempty(message) {
1621
+ return this.min(1, errorUtil.errToObj(message));
1622
+ }
1623
+ trim() {
1624
+ return new _ZodString({
1625
+ ...this._def,
1626
+ checks: [...this._def.checks, { kind: "trim" }]
1627
+ });
1628
+ }
1629
+ toLowerCase() {
1630
+ return new _ZodString({
1631
+ ...this._def,
1632
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
1633
+ });
1634
+ }
1635
+ toUpperCase() {
1636
+ return new _ZodString({
1637
+ ...this._def,
1638
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
1639
+ });
1640
+ }
1641
+ get isDatetime() {
1642
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
1643
+ }
1644
+ get isDate() {
1645
+ return !!this._def.checks.find((ch) => ch.kind === "date");
1646
+ }
1647
+ get isTime() {
1648
+ return !!this._def.checks.find((ch) => ch.kind === "time");
1649
+ }
1650
+ get isDuration() {
1651
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
1652
+ }
1653
+ get isEmail() {
1654
+ return !!this._def.checks.find((ch) => ch.kind === "email");
1655
+ }
1656
+ get isURL() {
1657
+ return !!this._def.checks.find((ch) => ch.kind === "url");
1658
+ }
1659
+ get isEmoji() {
1660
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
1661
+ }
1662
+ get isUUID() {
1663
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
1664
+ }
1665
+ get isNANOID() {
1666
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1667
+ }
1668
+ get isCUID() {
1669
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
1670
+ }
1671
+ get isCUID2() {
1672
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1673
+ }
1674
+ get isULID() {
1675
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
1676
+ }
1677
+ get isIP() {
1678
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
1679
+ }
1680
+ get isCIDR() {
1681
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
1682
+ }
1683
+ get isBase64() {
1684
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
1685
+ }
1686
+ get isBase64url() {
1687
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
1688
+ }
1689
+ get minLength() {
1690
+ let min = null;
1691
+ for (const ch of this._def.checks) {
1692
+ if (ch.kind === "min") {
1693
+ if (min === null || ch.value > min)
1694
+ min = ch.value;
1695
+ }
1696
+ }
1697
+ return min;
1698
+ }
1699
+ get maxLength() {
1700
+ let max = null;
1701
+ for (const ch of this._def.checks) {
1702
+ if (ch.kind === "max") {
1703
+ if (max === null || ch.value < max)
1704
+ max = ch.value;
1705
+ }
1706
+ }
1707
+ return max;
1708
+ }
1709
+ };
1710
+ ZodString.create = (params) => {
1711
+ return new ZodString({
1712
+ checks: [],
1713
+ typeName: ZodFirstPartyTypeKind.ZodString,
1714
+ coerce: params?.coerce ?? false,
1715
+ ...processCreateParams(params)
1716
+ });
1717
+ };
1718
+ function floatSafeRemainder(val, step) {
1719
+ const valDecCount = (val.toString().split(".")[1] || "").length;
1720
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
1721
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1722
+ const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
1723
+ const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
1724
+ return valInt % stepInt / 10 ** decCount;
1725
+ }
1726
+ var ZodNumber = class _ZodNumber extends ZodType {
1727
+ constructor() {
1728
+ super(...arguments);
1729
+ this.min = this.gte;
1730
+ this.max = this.lte;
1731
+ this.step = this.multipleOf;
1732
+ }
1733
+ _parse(input) {
1734
+ if (this._def.coerce) {
1735
+ input.data = Number(input.data);
1736
+ }
1737
+ const parsedType = this._getType(input);
1738
+ if (parsedType !== ZodParsedType.number) {
1739
+ const ctx2 = this._getOrReturnCtx(input);
1740
+ addIssueToContext(ctx2, {
1741
+ code: ZodIssueCode.invalid_type,
1742
+ expected: ZodParsedType.number,
1743
+ received: ctx2.parsedType
1744
+ });
1745
+ return INVALID;
1746
+ }
1747
+ let ctx = void 0;
1748
+ const status = new ParseStatus();
1749
+ for (const check of this._def.checks) {
1750
+ if (check.kind === "int") {
1751
+ if (!util.isInteger(input.data)) {
1752
+ ctx = this._getOrReturnCtx(input, ctx);
1753
+ addIssueToContext(ctx, {
1754
+ code: ZodIssueCode.invalid_type,
1755
+ expected: "integer",
1756
+ received: "float",
1757
+ message: check.message
1758
+ });
1759
+ status.dirty();
1760
+ }
1761
+ } else if (check.kind === "min") {
1762
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1763
+ if (tooSmall) {
1764
+ ctx = this._getOrReturnCtx(input, ctx);
1765
+ addIssueToContext(ctx, {
1766
+ code: ZodIssueCode.too_small,
1767
+ minimum: check.value,
1768
+ type: "number",
1769
+ inclusive: check.inclusive,
1770
+ exact: false,
1771
+ message: check.message
1772
+ });
1773
+ status.dirty();
1774
+ }
1775
+ } else if (check.kind === "max") {
1776
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1777
+ if (tooBig) {
1778
+ ctx = this._getOrReturnCtx(input, ctx);
1779
+ addIssueToContext(ctx, {
1780
+ code: ZodIssueCode.too_big,
1781
+ maximum: check.value,
1782
+ type: "number",
1783
+ inclusive: check.inclusive,
1784
+ exact: false,
1785
+ message: check.message
1786
+ });
1787
+ status.dirty();
1788
+ }
1789
+ } else if (check.kind === "multipleOf") {
1790
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
1791
+ ctx = this._getOrReturnCtx(input, ctx);
1792
+ addIssueToContext(ctx, {
1793
+ code: ZodIssueCode.not_multiple_of,
1794
+ multipleOf: check.value,
1795
+ message: check.message
1796
+ });
1797
+ status.dirty();
1798
+ }
1799
+ } else if (check.kind === "finite") {
1800
+ if (!Number.isFinite(input.data)) {
1801
+ ctx = this._getOrReturnCtx(input, ctx);
1802
+ addIssueToContext(ctx, {
1803
+ code: ZodIssueCode.not_finite,
1804
+ message: check.message
1805
+ });
1806
+ status.dirty();
1807
+ }
1808
+ } else {
1809
+ util.assertNever(check);
1810
+ }
1811
+ }
1812
+ return { status: status.value, value: input.data };
1813
+ }
1814
+ gte(value, message) {
1815
+ return this.setLimit("min", value, true, errorUtil.toString(message));
1816
+ }
1817
+ gt(value, message) {
1818
+ return this.setLimit("min", value, false, errorUtil.toString(message));
1819
+ }
1820
+ lte(value, message) {
1821
+ return this.setLimit("max", value, true, errorUtil.toString(message));
1822
+ }
1823
+ lt(value, message) {
1824
+ return this.setLimit("max", value, false, errorUtil.toString(message));
1825
+ }
1826
+ setLimit(kind, value, inclusive, message) {
1827
+ return new _ZodNumber({
1828
+ ...this._def,
1829
+ checks: [
1830
+ ...this._def.checks,
1831
+ {
1832
+ kind,
1833
+ value,
1834
+ inclusive,
1835
+ message: errorUtil.toString(message)
1836
+ }
1837
+ ]
1838
+ });
1839
+ }
1840
+ _addCheck(check) {
1841
+ return new _ZodNumber({
1842
+ ...this._def,
1843
+ checks: [...this._def.checks, check]
1844
+ });
1845
+ }
1846
+ int(message) {
1847
+ return this._addCheck({
1848
+ kind: "int",
1849
+ message: errorUtil.toString(message)
1850
+ });
1851
+ }
1852
+ positive(message) {
1853
+ return this._addCheck({
1854
+ kind: "min",
1855
+ value: 0,
1856
+ inclusive: false,
1857
+ message: errorUtil.toString(message)
1858
+ });
1859
+ }
1860
+ negative(message) {
1861
+ return this._addCheck({
1862
+ kind: "max",
1863
+ value: 0,
1864
+ inclusive: false,
1865
+ message: errorUtil.toString(message)
1866
+ });
1867
+ }
1868
+ nonpositive(message) {
1869
+ return this._addCheck({
1870
+ kind: "max",
1871
+ value: 0,
1872
+ inclusive: true,
1873
+ message: errorUtil.toString(message)
1874
+ });
1875
+ }
1876
+ nonnegative(message) {
1877
+ return this._addCheck({
1878
+ kind: "min",
1879
+ value: 0,
1880
+ inclusive: true,
1881
+ message: errorUtil.toString(message)
1882
+ });
1883
+ }
1884
+ multipleOf(value, message) {
1885
+ return this._addCheck({
1886
+ kind: "multipleOf",
1887
+ value,
1888
+ message: errorUtil.toString(message)
1889
+ });
1890
+ }
1891
+ finite(message) {
1892
+ return this._addCheck({
1893
+ kind: "finite",
1894
+ message: errorUtil.toString(message)
1895
+ });
1896
+ }
1897
+ safe(message) {
1898
+ return this._addCheck({
1899
+ kind: "min",
1900
+ inclusive: true,
1901
+ value: Number.MIN_SAFE_INTEGER,
1902
+ message: errorUtil.toString(message)
1903
+ })._addCheck({
1904
+ kind: "max",
1905
+ inclusive: true,
1906
+ value: Number.MAX_SAFE_INTEGER,
1907
+ message: errorUtil.toString(message)
1908
+ });
1909
+ }
1910
+ get minValue() {
1911
+ let min = null;
1912
+ for (const ch of this._def.checks) {
1913
+ if (ch.kind === "min") {
1914
+ if (min === null || ch.value > min)
1915
+ min = ch.value;
1916
+ }
1917
+ }
1918
+ return min;
1919
+ }
1920
+ get maxValue() {
1921
+ let max = null;
1922
+ for (const ch of this._def.checks) {
1923
+ if (ch.kind === "max") {
1924
+ if (max === null || ch.value < max)
1925
+ max = ch.value;
1926
+ }
1927
+ }
1928
+ return max;
1929
+ }
1930
+ get isInt() {
1931
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1932
+ }
1933
+ get isFinite() {
1934
+ let max = null;
1935
+ let min = null;
1936
+ for (const ch of this._def.checks) {
1937
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
1938
+ return true;
1939
+ } else if (ch.kind === "min") {
1940
+ if (min === null || ch.value > min)
1941
+ min = ch.value;
1942
+ } else if (ch.kind === "max") {
1943
+ if (max === null || ch.value < max)
1944
+ max = ch.value;
1945
+ }
1946
+ }
1947
+ return Number.isFinite(min) && Number.isFinite(max);
1948
+ }
1949
+ };
1950
+ ZodNumber.create = (params) => {
1951
+ return new ZodNumber({
1952
+ checks: [],
1953
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
1954
+ coerce: params?.coerce || false,
1955
+ ...processCreateParams(params)
1956
+ });
1957
+ };
1958
+ var ZodBigInt = class _ZodBigInt extends ZodType {
1959
+ constructor() {
1960
+ super(...arguments);
1961
+ this.min = this.gte;
1962
+ this.max = this.lte;
1963
+ }
1964
+ _parse(input) {
1965
+ if (this._def.coerce) {
1966
+ try {
1967
+ input.data = BigInt(input.data);
1968
+ } catch {
1969
+ return this._getInvalidInput(input);
1970
+ }
1971
+ }
1972
+ const parsedType = this._getType(input);
1973
+ if (parsedType !== ZodParsedType.bigint) {
1974
+ return this._getInvalidInput(input);
1975
+ }
1976
+ let ctx = void 0;
1977
+ const status = new ParseStatus();
1978
+ for (const check of this._def.checks) {
1979
+ if (check.kind === "min") {
1980
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
1981
+ if (tooSmall) {
1982
+ ctx = this._getOrReturnCtx(input, ctx);
1983
+ addIssueToContext(ctx, {
1984
+ code: ZodIssueCode.too_small,
1985
+ type: "bigint",
1986
+ minimum: check.value,
1987
+ inclusive: check.inclusive,
1988
+ message: check.message
1989
+ });
1990
+ status.dirty();
1991
+ }
1992
+ } else if (check.kind === "max") {
1993
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
1994
+ if (tooBig) {
1995
+ ctx = this._getOrReturnCtx(input, ctx);
1996
+ addIssueToContext(ctx, {
1997
+ code: ZodIssueCode.too_big,
1998
+ type: "bigint",
1999
+ maximum: check.value,
2000
+ inclusive: check.inclusive,
2001
+ message: check.message
2002
+ });
2003
+ status.dirty();
2004
+ }
2005
+ } else if (check.kind === "multipleOf") {
2006
+ if (input.data % check.value !== BigInt(0)) {
2007
+ ctx = this._getOrReturnCtx(input, ctx);
2008
+ addIssueToContext(ctx, {
2009
+ code: ZodIssueCode.not_multiple_of,
2010
+ multipleOf: check.value,
2011
+ message: check.message
2012
+ });
2013
+ status.dirty();
2014
+ }
2015
+ } else {
2016
+ util.assertNever(check);
2017
+ }
2018
+ }
2019
+ return { status: status.value, value: input.data };
2020
+ }
2021
+ _getInvalidInput(input) {
2022
+ const ctx = this._getOrReturnCtx(input);
2023
+ addIssueToContext(ctx, {
2024
+ code: ZodIssueCode.invalid_type,
2025
+ expected: ZodParsedType.bigint,
2026
+ received: ctx.parsedType
2027
+ });
2028
+ return INVALID;
2029
+ }
2030
+ gte(value, message) {
2031
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2032
+ }
2033
+ gt(value, message) {
2034
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2035
+ }
2036
+ lte(value, message) {
2037
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2038
+ }
2039
+ lt(value, message) {
2040
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2041
+ }
2042
+ setLimit(kind, value, inclusive, message) {
2043
+ return new _ZodBigInt({
2044
+ ...this._def,
2045
+ checks: [
2046
+ ...this._def.checks,
2047
+ {
2048
+ kind,
2049
+ value,
2050
+ inclusive,
2051
+ message: errorUtil.toString(message)
2052
+ }
2053
+ ]
2054
+ });
2055
+ }
2056
+ _addCheck(check) {
2057
+ return new _ZodBigInt({
2058
+ ...this._def,
2059
+ checks: [...this._def.checks, check]
2060
+ });
2061
+ }
2062
+ positive(message) {
2063
+ return this._addCheck({
2064
+ kind: "min",
2065
+ value: BigInt(0),
2066
+ inclusive: false,
2067
+ message: errorUtil.toString(message)
2068
+ });
2069
+ }
2070
+ negative(message) {
2071
+ return this._addCheck({
2072
+ kind: "max",
2073
+ value: BigInt(0),
2074
+ inclusive: false,
2075
+ message: errorUtil.toString(message)
2076
+ });
2077
+ }
2078
+ nonpositive(message) {
2079
+ return this._addCheck({
2080
+ kind: "max",
2081
+ value: BigInt(0),
2082
+ inclusive: true,
2083
+ message: errorUtil.toString(message)
2084
+ });
2085
+ }
2086
+ nonnegative(message) {
2087
+ return this._addCheck({
2088
+ kind: "min",
2089
+ value: BigInt(0),
2090
+ inclusive: true,
2091
+ message: errorUtil.toString(message)
2092
+ });
2093
+ }
2094
+ multipleOf(value, message) {
2095
+ return this._addCheck({
2096
+ kind: "multipleOf",
2097
+ value,
2098
+ message: errorUtil.toString(message)
2099
+ });
2100
+ }
2101
+ get minValue() {
2102
+ let min = null;
2103
+ for (const ch of this._def.checks) {
2104
+ if (ch.kind === "min") {
2105
+ if (min === null || ch.value > min)
2106
+ min = ch.value;
2107
+ }
2108
+ }
2109
+ return min;
2110
+ }
2111
+ get maxValue() {
2112
+ let max = null;
2113
+ for (const ch of this._def.checks) {
2114
+ if (ch.kind === "max") {
2115
+ if (max === null || ch.value < max)
2116
+ max = ch.value;
2117
+ }
2118
+ }
2119
+ return max;
2120
+ }
2121
+ };
2122
+ ZodBigInt.create = (params) => {
2123
+ return new ZodBigInt({
2124
+ checks: [],
2125
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
2126
+ coerce: params?.coerce ?? false,
2127
+ ...processCreateParams(params)
2128
+ });
2129
+ };
2130
+ var ZodBoolean = class extends ZodType {
2131
+ _parse(input) {
2132
+ if (this._def.coerce) {
2133
+ input.data = Boolean(input.data);
2134
+ }
2135
+ const parsedType = this._getType(input);
2136
+ if (parsedType !== ZodParsedType.boolean) {
2137
+ const ctx = this._getOrReturnCtx(input);
2138
+ addIssueToContext(ctx, {
2139
+ code: ZodIssueCode.invalid_type,
2140
+ expected: ZodParsedType.boolean,
2141
+ received: ctx.parsedType
2142
+ });
2143
+ return INVALID;
2144
+ }
2145
+ return OK(input.data);
2146
+ }
2147
+ };
2148
+ ZodBoolean.create = (params) => {
2149
+ return new ZodBoolean({
2150
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
2151
+ coerce: params?.coerce || false,
2152
+ ...processCreateParams(params)
2153
+ });
2154
+ };
2155
+ var ZodDate = class _ZodDate extends ZodType {
2156
+ _parse(input) {
2157
+ if (this._def.coerce) {
2158
+ input.data = new Date(input.data);
2159
+ }
2160
+ const parsedType = this._getType(input);
2161
+ if (parsedType !== ZodParsedType.date) {
2162
+ const ctx2 = this._getOrReturnCtx(input);
2163
+ addIssueToContext(ctx2, {
2164
+ code: ZodIssueCode.invalid_type,
2165
+ expected: ZodParsedType.date,
2166
+ received: ctx2.parsedType
2167
+ });
2168
+ return INVALID;
2169
+ }
2170
+ if (Number.isNaN(input.data.getTime())) {
2171
+ const ctx2 = this._getOrReturnCtx(input);
2172
+ addIssueToContext(ctx2, {
2173
+ code: ZodIssueCode.invalid_date
2174
+ });
2175
+ return INVALID;
2176
+ }
2177
+ const status = new ParseStatus();
2178
+ let ctx = void 0;
2179
+ for (const check of this._def.checks) {
2180
+ if (check.kind === "min") {
2181
+ if (input.data.getTime() < check.value) {
2182
+ ctx = this._getOrReturnCtx(input, ctx);
2183
+ addIssueToContext(ctx, {
2184
+ code: ZodIssueCode.too_small,
2185
+ message: check.message,
2186
+ inclusive: true,
2187
+ exact: false,
2188
+ minimum: check.value,
2189
+ type: "date"
2190
+ });
2191
+ status.dirty();
2192
+ }
2193
+ } else if (check.kind === "max") {
2194
+ if (input.data.getTime() > check.value) {
2195
+ ctx = this._getOrReturnCtx(input, ctx);
2196
+ addIssueToContext(ctx, {
2197
+ code: ZodIssueCode.too_big,
2198
+ message: check.message,
2199
+ inclusive: true,
2200
+ exact: false,
2201
+ maximum: check.value,
2202
+ type: "date"
2203
+ });
2204
+ status.dirty();
2205
+ }
2206
+ } else {
2207
+ util.assertNever(check);
2208
+ }
2209
+ }
2210
+ return {
2211
+ status: status.value,
2212
+ value: new Date(input.data.getTime())
2213
+ };
2214
+ }
2215
+ _addCheck(check) {
2216
+ return new _ZodDate({
2217
+ ...this._def,
2218
+ checks: [...this._def.checks, check]
2219
+ });
2220
+ }
2221
+ min(minDate, message) {
2222
+ return this._addCheck({
2223
+ kind: "min",
2224
+ value: minDate.getTime(),
2225
+ message: errorUtil.toString(message)
2226
+ });
2227
+ }
2228
+ max(maxDate, message) {
2229
+ return this._addCheck({
2230
+ kind: "max",
2231
+ value: maxDate.getTime(),
2232
+ message: errorUtil.toString(message)
2233
+ });
2234
+ }
2235
+ get minDate() {
2236
+ let min = null;
2237
+ for (const ch of this._def.checks) {
2238
+ if (ch.kind === "min") {
2239
+ if (min === null || ch.value > min)
2240
+ min = ch.value;
2241
+ }
2242
+ }
2243
+ return min != null ? new Date(min) : null;
2244
+ }
2245
+ get maxDate() {
2246
+ let max = null;
2247
+ for (const ch of this._def.checks) {
2248
+ if (ch.kind === "max") {
2249
+ if (max === null || ch.value < max)
2250
+ max = ch.value;
2251
+ }
2252
+ }
2253
+ return max != null ? new Date(max) : null;
2254
+ }
2255
+ };
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 !== ZodParsedType.symbol) {
2268
+ const ctx = this._getOrReturnCtx(input);
2269
+ addIssueToContext(ctx, {
2270
+ code: ZodIssueCode.invalid_type,
2271
+ expected: ZodParsedType.symbol,
2272
+ received: ctx.parsedType
2273
+ });
2274
+ return INVALID;
2275
+ }
2276
+ return OK(input.data);
2277
+ }
2278
+ };
2279
+ ZodSymbol.create = (params) => {
2280
+ return new ZodSymbol({
2281
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
2282
+ ...processCreateParams(params)
2283
+ });
2284
+ };
2285
+ var ZodUndefined = class extends ZodType {
2286
+ _parse(input) {
2287
+ const parsedType = this._getType(input);
2288
+ if (parsedType !== ZodParsedType.undefined) {
2289
+ const ctx = this._getOrReturnCtx(input);
2290
+ addIssueToContext(ctx, {
2291
+ code: ZodIssueCode.invalid_type,
2292
+ expected: ZodParsedType.undefined,
2293
+ received: ctx.parsedType
2294
+ });
2295
+ return INVALID;
2296
+ }
2297
+ return OK(input.data);
2298
+ }
2299
+ };
2300
+ ZodUndefined.create = (params) => {
2301
+ return new ZodUndefined({
2302
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
2303
+ ...processCreateParams(params)
2304
+ });
2305
+ };
2306
+ var ZodNull = class extends ZodType {
2307
+ _parse(input) {
2308
+ const parsedType = this._getType(input);
2309
+ if (parsedType !== ZodParsedType.null) {
2310
+ const ctx = this._getOrReturnCtx(input);
2311
+ addIssueToContext(ctx, {
2312
+ code: ZodIssueCode.invalid_type,
2313
+ expected: ZodParsedType.null,
2314
+ received: ctx.parsedType
2315
+ });
2316
+ return INVALID;
2317
+ }
2318
+ return OK(input.data);
2319
+ }
2320
+ };
2321
+ ZodNull.create = (params) => {
2322
+ return new ZodNull({
2323
+ typeName: ZodFirstPartyTypeKind.ZodNull,
2324
+ ...processCreateParams(params)
2325
+ });
2326
+ };
2327
+ var ZodAny = class extends ZodType {
2328
+ constructor() {
2329
+ super(...arguments);
2330
+ this._any = true;
2331
+ }
2332
+ _parse(input) {
2333
+ return OK(input.data);
2334
+ }
2335
+ };
2336
+ ZodAny.create = (params) => {
2337
+ return new ZodAny({
2338
+ typeName: ZodFirstPartyTypeKind.ZodAny,
2339
+ ...processCreateParams(params)
2340
+ });
2341
+ };
2342
+ var ZodUnknown = class extends ZodType {
2343
+ constructor() {
2344
+ super(...arguments);
2345
+ this._unknown = true;
2346
+ }
2347
+ _parse(input) {
2348
+ return OK(input.data);
2349
+ }
2350
+ };
2351
+ ZodUnknown.create = (params) => {
2352
+ return new ZodUnknown({
2353
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
2354
+ ...processCreateParams(params)
2355
+ });
2356
+ };
2357
+ var ZodNever = class extends ZodType {
2358
+ _parse(input) {
2359
+ const ctx = this._getOrReturnCtx(input);
2360
+ addIssueToContext(ctx, {
2361
+ code: ZodIssueCode.invalid_type,
2362
+ expected: ZodParsedType.never,
2363
+ received: ctx.parsedType
2364
+ });
2365
+ return INVALID;
2366
+ }
2367
+ };
2368
+ ZodNever.create = (params) => {
2369
+ return new ZodNever({
2370
+ typeName: ZodFirstPartyTypeKind.ZodNever,
2371
+ ...processCreateParams(params)
2372
+ });
2373
+ };
2374
+ var ZodVoid = class extends ZodType {
2375
+ _parse(input) {
2376
+ const parsedType = this._getType(input);
2377
+ if (parsedType !== ZodParsedType.undefined) {
2378
+ const ctx = this._getOrReturnCtx(input);
2379
+ addIssueToContext(ctx, {
2380
+ code: ZodIssueCode.invalid_type,
2381
+ expected: ZodParsedType.void,
2382
+ received: ctx.parsedType
2383
+ });
2384
+ return INVALID;
2385
+ }
2386
+ return OK(input.data);
2387
+ }
2388
+ };
2389
+ ZodVoid.create = (params) => {
2390
+ return new ZodVoid({
2391
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
2392
+ ...processCreateParams(params)
2393
+ });
2394
+ };
2395
+ var ZodArray = class _ZodArray extends ZodType {
2396
+ _parse(input) {
2397
+ const { ctx, status } = this._processInputParams(input);
2398
+ const def = this._def;
2399
+ if (ctx.parsedType !== ZodParsedType.array) {
2400
+ addIssueToContext(ctx, {
2401
+ code: ZodIssueCode.invalid_type,
2402
+ expected: ZodParsedType.array,
2403
+ received: ctx.parsedType
2404
+ });
2405
+ return INVALID;
2406
+ }
2407
+ if (def.exactLength !== null) {
2408
+ const tooBig = ctx.data.length > def.exactLength.value;
2409
+ const tooSmall = ctx.data.length < def.exactLength.value;
2410
+ if (tooBig || tooSmall) {
2411
+ addIssueToContext(ctx, {
2412
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2413
+ minimum: tooSmall ? def.exactLength.value : void 0,
2414
+ maximum: tooBig ? def.exactLength.value : void 0,
2415
+ type: "array",
2416
+ inclusive: true,
2417
+ exact: true,
2418
+ message: def.exactLength.message
2419
+ });
2420
+ status.dirty();
2421
+ }
2422
+ }
2423
+ if (def.minLength !== null) {
2424
+ if (ctx.data.length < def.minLength.value) {
2425
+ addIssueToContext(ctx, {
2426
+ code: ZodIssueCode.too_small,
2427
+ minimum: def.minLength.value,
2428
+ type: "array",
2429
+ inclusive: true,
2430
+ exact: false,
2431
+ message: def.minLength.message
2432
+ });
2433
+ status.dirty();
2434
+ }
2435
+ }
2436
+ if (def.maxLength !== null) {
2437
+ if (ctx.data.length > def.maxLength.value) {
2438
+ addIssueToContext(ctx, {
2439
+ code: ZodIssueCode.too_big,
2440
+ maximum: def.maxLength.value,
2441
+ type: "array",
2442
+ inclusive: true,
2443
+ exact: false,
2444
+ message: def.maxLength.message
2445
+ });
2446
+ status.dirty();
2447
+ }
2448
+ }
2449
+ if (ctx.common.async) {
2450
+ return Promise.all([...ctx.data].map((item, i2) => {
2451
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
2452
+ })).then((result2) => {
2453
+ return ParseStatus.mergeArray(status, result2);
2454
+ });
2455
+ }
2456
+ const result = [...ctx.data].map((item, i2) => {
2457
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));
2458
+ });
2459
+ return ParseStatus.mergeArray(status, result);
2460
+ }
2461
+ get element() {
2462
+ return this._def.type;
2463
+ }
2464
+ min(minLength, message) {
2465
+ return new _ZodArray({
2466
+ ...this._def,
2467
+ minLength: { value: minLength, message: errorUtil.toString(message) }
2468
+ });
2469
+ }
2470
+ max(maxLength, message) {
2471
+ return new _ZodArray({
2472
+ ...this._def,
2473
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
2474
+ });
2475
+ }
2476
+ length(len, message) {
2477
+ return new _ZodArray({
2478
+ ...this._def,
2479
+ exactLength: { value: len, message: errorUtil.toString(message) }
2480
+ });
2481
+ }
2482
+ nonempty(message) {
2483
+ return this.min(1, message);
2484
+ }
2485
+ };
2486
+ ZodArray.create = (schema, params) => {
2487
+ return new ZodArray({
2488
+ type: schema,
2489
+ minLength: null,
2490
+ maxLength: null,
2491
+ exactLength: null,
2492
+ typeName: ZodFirstPartyTypeKind.ZodArray,
2493
+ ...processCreateParams(params)
2494
+ });
2495
+ };
2496
+ function deepPartialify(schema) {
2497
+ if (schema instanceof ZodObject) {
2498
+ const newShape = {};
2499
+ for (const key in schema.shape) {
2500
+ const fieldSchema = schema.shape[key];
2501
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
2502
+ }
2503
+ return new ZodObject({
2504
+ ...schema._def,
2505
+ shape: () => newShape
2506
+ });
2507
+ } else if (schema instanceof ZodArray) {
2508
+ return new ZodArray({
2509
+ ...schema._def,
2510
+ type: deepPartialify(schema.element)
2511
+ });
2512
+ } else if (schema instanceof ZodOptional) {
2513
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
2514
+ } else if (schema instanceof ZodNullable) {
2515
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
2516
+ } else if (schema instanceof ZodTuple) {
2517
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2518
+ } else {
2519
+ return schema;
2520
+ }
2521
+ }
2522
+ var ZodObject = class _ZodObject extends ZodType {
2523
+ constructor() {
2524
+ super(...arguments);
2525
+ this._cached = null;
2526
+ this.nonstrict = this.passthrough;
2527
+ this.augment = this.extend;
2528
+ }
2529
+ _getCached() {
2530
+ if (this._cached !== null)
2531
+ return this._cached;
2532
+ const shape = this._def.shape();
2533
+ const keys = util.objectKeys(shape);
2534
+ this._cached = { shape, keys };
2535
+ return this._cached;
2536
+ }
2537
+ _parse(input) {
2538
+ const parsedType = this._getType(input);
2539
+ if (parsedType !== ZodParsedType.object) {
2540
+ const ctx2 = this._getOrReturnCtx(input);
2541
+ addIssueToContext(ctx2, {
2542
+ code: ZodIssueCode.invalid_type,
2543
+ expected: ZodParsedType.object,
2544
+ received: ctx2.parsedType
2545
+ });
2546
+ return INVALID;
2547
+ }
2548
+ const { status, ctx } = this._processInputParams(input);
2549
+ const { shape, keys: shapeKeys } = this._getCached();
2550
+ const extraKeys = [];
2551
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
2552
+ for (const key in ctx.data) {
2553
+ if (!shapeKeys.includes(key)) {
2554
+ extraKeys.push(key);
2555
+ }
2556
+ }
2557
+ }
2558
+ const pairs = [];
2559
+ for (const key of shapeKeys) {
2560
+ const keyValidator = shape[key];
2561
+ const value = ctx.data[key];
2562
+ pairs.push({
2563
+ key: { status: "valid", value: key },
2564
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2565
+ alwaysSet: key in ctx.data
2566
+ });
2567
+ }
2568
+ if (this._def.catchall instanceof ZodNever) {
2569
+ const unknownKeys = this._def.unknownKeys;
2570
+ if (unknownKeys === "passthrough") {
2571
+ for (const key of extraKeys) {
2572
+ pairs.push({
2573
+ key: { status: "valid", value: key },
2574
+ value: { status: "valid", value: ctx.data[key] }
2575
+ });
2576
+ }
2577
+ } else if (unknownKeys === "strict") {
2578
+ if (extraKeys.length > 0) {
2579
+ addIssueToContext(ctx, {
2580
+ code: ZodIssueCode.unrecognized_keys,
2581
+ keys: extraKeys
2582
+ });
2583
+ status.dirty();
2584
+ }
2585
+ } else if (unknownKeys === "strip") {
2586
+ } else {
2587
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2588
+ }
2589
+ } else {
2590
+ const catchall = this._def.catchall;
2591
+ for (const key of extraKeys) {
2592
+ const value = ctx.data[key];
2593
+ pairs.push({
2594
+ key: { status: "valid", value: key },
2595
+ value: catchall._parse(
2596
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
2597
+ //, ctx.child(key), value, getParsedType(value)
2598
+ ),
2599
+ alwaysSet: key in ctx.data
2600
+ });
2601
+ }
2602
+ }
2603
+ if (ctx.common.async) {
2604
+ return Promise.resolve().then(async () => {
2605
+ const syncPairs = [];
2606
+ for (const pair of pairs) {
2607
+ const key = await pair.key;
2608
+ const value = await pair.value;
2609
+ syncPairs.push({
2610
+ key,
2611
+ value,
2612
+ alwaysSet: pair.alwaysSet
2613
+ });
2614
+ }
2615
+ return syncPairs;
2616
+ }).then((syncPairs) => {
2617
+ return ParseStatus.mergeObjectSync(status, syncPairs);
2618
+ });
2619
+ } else {
2620
+ return ParseStatus.mergeObjectSync(status, pairs);
2621
+ }
2622
+ }
2623
+ get shape() {
2624
+ return this._def.shape();
2625
+ }
2626
+ strict(message) {
2627
+ errorUtil.errToObj;
2628
+ return new _ZodObject({
2629
+ ...this._def,
2630
+ unknownKeys: "strict",
2631
+ ...message !== void 0 ? {
2632
+ errorMap: (issue, ctx) => {
2633
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2634
+ if (issue.code === "unrecognized_keys")
2635
+ return {
2636
+ message: errorUtil.errToObj(message).message ?? defaultError
2637
+ };
2638
+ return {
2639
+ message: defaultError
2640
+ };
2641
+ }
2642
+ } : {}
2643
+ });
2644
+ }
2645
+ strip() {
2646
+ return new _ZodObject({
2647
+ ...this._def,
2648
+ unknownKeys: "strip"
2649
+ });
2650
+ }
2651
+ passthrough() {
2652
+ return new _ZodObject({
2653
+ ...this._def,
2654
+ unknownKeys: "passthrough"
2655
+ });
2656
+ }
2657
+ // const AugmentFactory =
2658
+ // <Def extends ZodObjectDef>(def: Def) =>
2659
+ // <Augmentation extends ZodRawShape>(
2660
+ // augmentation: Augmentation
2661
+ // ): ZodObject<
2662
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
2663
+ // Def["unknownKeys"],
2664
+ // Def["catchall"]
2665
+ // > => {
2666
+ // return new ZodObject({
2667
+ // ...def,
2668
+ // shape: () => ({
2669
+ // ...def.shape(),
2670
+ // ...augmentation,
2671
+ // }),
2672
+ // }) as any;
2673
+ // };
2674
+ extend(augmentation) {
2675
+ return new _ZodObject({
2676
+ ...this._def,
2677
+ shape: () => ({
2678
+ ...this._def.shape(),
2679
+ ...augmentation
2680
+ })
2681
+ });
2682
+ }
2683
+ /**
2684
+ * Prior to zod@1.0.12 there was a bug in the
2685
+ * inferred type of merged objects. Please
2686
+ * upgrade if you are experiencing issues.
2687
+ */
2688
+ merge(merging) {
2689
+ const merged = new _ZodObject({
2690
+ unknownKeys: merging._def.unknownKeys,
2691
+ catchall: merging._def.catchall,
2692
+ shape: () => ({
2693
+ ...this._def.shape(),
2694
+ ...merging._def.shape()
2695
+ }),
2696
+ typeName: ZodFirstPartyTypeKind.ZodObject
2697
+ });
2698
+ return merged;
2699
+ }
2700
+ // merge<
2701
+ // Incoming extends AnyZodObject,
2702
+ // Augmentation extends Incoming["shape"],
2703
+ // NewOutput extends {
2704
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
2705
+ // ? Augmentation[k]["_output"]
2706
+ // : k extends keyof Output
2707
+ // ? Output[k]
2708
+ // : never;
2709
+ // },
2710
+ // NewInput extends {
2711
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
2712
+ // ? Augmentation[k]["_input"]
2713
+ // : k extends keyof Input
2714
+ // ? Input[k]
2715
+ // : never;
2716
+ // }
2717
+ // >(
2718
+ // merging: Incoming
2719
+ // ): ZodObject<
2720
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2721
+ // Incoming["_def"]["unknownKeys"],
2722
+ // Incoming["_def"]["catchall"],
2723
+ // NewOutput,
2724
+ // NewInput
2725
+ // > {
2726
+ // const merged: any = new ZodObject({
2727
+ // unknownKeys: merging._def.unknownKeys,
2728
+ // catchall: merging._def.catchall,
2729
+ // shape: () =>
2730
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2731
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2732
+ // }) as any;
2733
+ // return merged;
2734
+ // }
2735
+ setKey(key, schema) {
2736
+ return this.augment({ [key]: schema });
2737
+ }
2738
+ // merge<Incoming extends AnyZodObject>(
2739
+ // merging: Incoming
2740
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
2741
+ // ZodObject<
2742
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
2743
+ // Incoming["_def"]["unknownKeys"],
2744
+ // Incoming["_def"]["catchall"]
2745
+ // > {
2746
+ // // const mergedShape = objectUtil.mergeShapes(
2747
+ // // this._def.shape(),
2748
+ // // merging._def.shape()
2749
+ // // );
2750
+ // const merged: any = new ZodObject({
2751
+ // unknownKeys: merging._def.unknownKeys,
2752
+ // catchall: merging._def.catchall,
2753
+ // shape: () =>
2754
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
2755
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
2756
+ // }) as any;
2757
+ // return merged;
2758
+ // }
2759
+ catchall(index) {
2760
+ return new _ZodObject({
2761
+ ...this._def,
2762
+ catchall: index
2763
+ });
2764
+ }
2765
+ pick(mask) {
2766
+ const shape = {};
2767
+ for (const key of util.objectKeys(mask)) {
2768
+ if (mask[key] && this.shape[key]) {
2769
+ shape[key] = this.shape[key];
2770
+ }
2771
+ }
2772
+ return new _ZodObject({
2773
+ ...this._def,
2774
+ shape: () => shape
2775
+ });
2776
+ }
2777
+ omit(mask) {
2778
+ const shape = {};
2779
+ for (const key of util.objectKeys(this.shape)) {
2780
+ if (!mask[key]) {
2781
+ shape[key] = this.shape[key];
2782
+ }
2783
+ }
2784
+ return new _ZodObject({
2785
+ ...this._def,
2786
+ shape: () => shape
2787
+ });
2788
+ }
2789
+ /**
2790
+ * @deprecated
2791
+ */
2792
+ deepPartial() {
2793
+ return deepPartialify(this);
2794
+ }
2795
+ partial(mask) {
2796
+ const newShape = {};
2797
+ for (const key of util.objectKeys(this.shape)) {
2798
+ const fieldSchema = this.shape[key];
2799
+ if (mask && !mask[key]) {
2800
+ newShape[key] = fieldSchema;
2801
+ } else {
2802
+ newShape[key] = fieldSchema.optional();
2803
+ }
2804
+ }
2805
+ return new _ZodObject({
2806
+ ...this._def,
2807
+ shape: () => newShape
2808
+ });
2809
+ }
2810
+ required(mask) {
2811
+ const newShape = {};
2812
+ for (const key of util.objectKeys(this.shape)) {
2813
+ if (mask && !mask[key]) {
2814
+ newShape[key] = this.shape[key];
2815
+ } else {
2816
+ const fieldSchema = this.shape[key];
2817
+ let newField = fieldSchema;
2818
+ while (newField instanceof ZodOptional) {
2819
+ newField = newField._def.innerType;
2820
+ }
2821
+ newShape[key] = newField;
2822
+ }
2823
+ }
2824
+ return new _ZodObject({
2825
+ ...this._def,
2826
+ shape: () => newShape
2827
+ });
2828
+ }
2829
+ keyof() {
2830
+ return createZodEnum(util.objectKeys(this.shape));
2831
+ }
2832
+ };
2833
+ ZodObject.create = (shape, params) => {
2834
+ return new ZodObject({
2835
+ shape: () => shape,
2836
+ unknownKeys: "strip",
2837
+ catchall: ZodNever.create(),
2838
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2839
+ ...processCreateParams(params)
2840
+ });
2841
+ };
2842
+ ZodObject.strictCreate = (shape, params) => {
2843
+ return new ZodObject({
2844
+ shape: () => shape,
2845
+ unknownKeys: "strict",
2846
+ catchall: ZodNever.create(),
2847
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2848
+ ...processCreateParams(params)
2849
+ });
2850
+ };
2851
+ ZodObject.lazycreate = (shape, params) => {
2852
+ return new ZodObject({
2853
+ shape,
2854
+ unknownKeys: "strip",
2855
+ catchall: ZodNever.create(),
2856
+ typeName: ZodFirstPartyTypeKind.ZodObject,
2857
+ ...processCreateParams(params)
2858
+ });
2859
+ };
2860
+ var ZodUnion = class extends ZodType {
2861
+ _parse(input) {
2862
+ const { ctx } = this._processInputParams(input);
2863
+ const options = this._def.options;
2864
+ function handleResults(results) {
2865
+ for (const result of results) {
2866
+ if (result.result.status === "valid") {
2867
+ return result.result;
2868
+ }
2869
+ }
2870
+ for (const result of results) {
2871
+ if (result.result.status === "dirty") {
2872
+ ctx.common.issues.push(...result.ctx.common.issues);
2873
+ return result.result;
2874
+ }
2875
+ }
2876
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
2877
+ addIssueToContext(ctx, {
2878
+ code: ZodIssueCode.invalid_union,
2879
+ unionErrors
2880
+ });
2881
+ return INVALID;
2882
+ }
2883
+ if (ctx.common.async) {
2884
+ return Promise.all(options.map(async (option) => {
2885
+ const childCtx = {
2886
+ ...ctx,
2887
+ common: {
2888
+ ...ctx.common,
2889
+ issues: []
2890
+ },
2891
+ parent: null
2892
+ };
2893
+ return {
2894
+ result: await option._parseAsync({
2895
+ data: ctx.data,
2896
+ path: ctx.path,
2897
+ parent: childCtx
2898
+ }),
2899
+ ctx: childCtx
2900
+ };
2901
+ })).then(handleResults);
2902
+ } else {
2903
+ let dirty = void 0;
2904
+ const issues = [];
2905
+ for (const option of options) {
2906
+ const childCtx = {
2907
+ ...ctx,
2908
+ common: {
2909
+ ...ctx.common,
2910
+ issues: []
2911
+ },
2912
+ parent: null
2913
+ };
2914
+ const result = option._parseSync({
2915
+ data: ctx.data,
2916
+ path: ctx.path,
2917
+ parent: childCtx
2918
+ });
2919
+ if (result.status === "valid") {
2920
+ return result;
2921
+ } else if (result.status === "dirty" && !dirty) {
2922
+ dirty = { result, ctx: childCtx };
2923
+ }
2924
+ if (childCtx.common.issues.length) {
2925
+ issues.push(childCtx.common.issues);
2926
+ }
2927
+ }
2928
+ if (dirty) {
2929
+ ctx.common.issues.push(...dirty.ctx.common.issues);
2930
+ return dirty.result;
2931
+ }
2932
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
2933
+ addIssueToContext(ctx, {
2934
+ code: ZodIssueCode.invalid_union,
2935
+ unionErrors
2936
+ });
2937
+ return INVALID;
2938
+ }
2939
+ }
2940
+ get options() {
2941
+ return this._def.options;
2942
+ }
2943
+ };
2944
+ ZodUnion.create = (types, params) => {
2945
+ return new ZodUnion({
2946
+ options: types,
2947
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
2948
+ ...processCreateParams(params)
2949
+ });
2950
+ };
2951
+ var getDiscriminator = (type) => {
2952
+ if (type instanceof ZodLazy) {
2953
+ return getDiscriminator(type.schema);
2954
+ } else if (type instanceof ZodEffects) {
2955
+ return getDiscriminator(type.innerType());
2956
+ } else if (type instanceof ZodLiteral) {
2957
+ return [type.value];
2958
+ } else if (type instanceof ZodEnum) {
2959
+ return type.options;
2960
+ } else if (type instanceof ZodNativeEnum) {
2961
+ return util.objectValues(type.enum);
2962
+ } else if (type instanceof ZodDefault) {
2963
+ return getDiscriminator(type._def.innerType);
2964
+ } else if (type instanceof ZodUndefined) {
2965
+ return [void 0];
2966
+ } else if (type instanceof ZodNull) {
2967
+ return [null];
2968
+ } else if (type instanceof ZodOptional) {
2969
+ return [void 0, ...getDiscriminator(type.unwrap())];
2970
+ } else if (type instanceof ZodNullable) {
2971
+ return [null, ...getDiscriminator(type.unwrap())];
2972
+ } else if (type instanceof ZodBranded) {
2973
+ return getDiscriminator(type.unwrap());
2974
+ } else if (type instanceof ZodReadonly) {
2975
+ return getDiscriminator(type.unwrap());
2976
+ } else if (type instanceof ZodCatch) {
2977
+ return getDiscriminator(type._def.innerType);
2978
+ } else {
2979
+ return [];
2980
+ }
2981
+ };
2982
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
2983
+ _parse(input) {
2984
+ const { ctx } = this._processInputParams(input);
2985
+ if (ctx.parsedType !== ZodParsedType.object) {
2986
+ addIssueToContext(ctx, {
2987
+ code: ZodIssueCode.invalid_type,
2988
+ expected: ZodParsedType.object,
2989
+ received: ctx.parsedType
2990
+ });
2991
+ return INVALID;
2992
+ }
2993
+ const discriminator = this.discriminator;
2994
+ const discriminatorValue = ctx.data[discriminator];
2995
+ const option = this.optionsMap.get(discriminatorValue);
2996
+ if (!option) {
2997
+ addIssueToContext(ctx, {
2998
+ code: ZodIssueCode.invalid_union_discriminator,
2999
+ options: Array.from(this.optionsMap.keys()),
3000
+ path: [discriminator]
3001
+ });
3002
+ return INVALID;
3003
+ }
3004
+ if (ctx.common.async) {
3005
+ return option._parseAsync({
3006
+ data: ctx.data,
3007
+ path: ctx.path,
3008
+ parent: ctx
3009
+ });
3010
+ } else {
3011
+ return option._parseSync({
3012
+ data: ctx.data,
3013
+ path: ctx.path,
3014
+ parent: ctx
3015
+ });
3016
+ }
3017
+ }
3018
+ get discriminator() {
3019
+ return this._def.discriminator;
3020
+ }
3021
+ get options() {
3022
+ return this._def.options;
3023
+ }
3024
+ get optionsMap() {
3025
+ return this._def.optionsMap;
3026
+ }
3027
+ /**
3028
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
3029
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
3030
+ * have a different value for each object in the union.
3031
+ * @param discriminator the name of the discriminator property
3032
+ * @param types an array of object schemas
3033
+ * @param params
3034
+ */
3035
+ static create(discriminator, options, params) {
3036
+ const optionsMap = /* @__PURE__ */ new Map();
3037
+ for (const type of options) {
3038
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
3039
+ if (!discriminatorValues.length) {
3040
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
3041
+ }
3042
+ for (const value of discriminatorValues) {
3043
+ if (optionsMap.has(value)) {
3044
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
3045
+ }
3046
+ optionsMap.set(value, type);
3047
+ }
3048
+ }
3049
+ return new _ZodDiscriminatedUnion({
3050
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
3051
+ discriminator,
3052
+ options,
3053
+ optionsMap,
3054
+ ...processCreateParams(params)
3055
+ });
3056
+ }
3057
+ };
3058
+ function mergeValues(a, b) {
3059
+ const aType = getParsedType(a);
3060
+ const bType = getParsedType(b);
3061
+ if (a === b) {
3062
+ return { valid: true, data: a };
3063
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
3064
+ const bKeys = util.objectKeys(b);
3065
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
3066
+ const newObj = { ...a, ...b };
3067
+ for (const key of sharedKeys) {
3068
+ const sharedValue = mergeValues(a[key], b[key]);
3069
+ if (!sharedValue.valid) {
3070
+ return { valid: false };
3071
+ }
3072
+ newObj[key] = sharedValue.data;
3073
+ }
3074
+ return { valid: true, data: newObj };
3075
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
3076
+ if (a.length !== b.length) {
3077
+ return { valid: false };
3078
+ }
3079
+ const newArray = [];
3080
+ for (let index = 0; index < a.length; index++) {
3081
+ const itemA = a[index];
3082
+ const itemB = b[index];
3083
+ const sharedValue = mergeValues(itemA, itemB);
3084
+ if (!sharedValue.valid) {
3085
+ return { valid: false };
3086
+ }
3087
+ newArray.push(sharedValue.data);
3088
+ }
3089
+ return { valid: true, data: newArray };
3090
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
3091
+ return { valid: true, data: a };
3092
+ } else {
3093
+ return { valid: false };
3094
+ }
3095
+ }
3096
+ var ZodIntersection = class extends ZodType {
3097
+ _parse(input) {
3098
+ const { status, ctx } = this._processInputParams(input);
3099
+ const handleParsed = (parsedLeft, parsedRight) => {
3100
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
3101
+ return INVALID;
3102
+ }
3103
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
3104
+ if (!merged.valid) {
3105
+ addIssueToContext(ctx, {
3106
+ code: ZodIssueCode.invalid_intersection_types
3107
+ });
3108
+ return INVALID;
3109
+ }
3110
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
3111
+ status.dirty();
3112
+ }
3113
+ return { status: status.value, value: merged.data };
3114
+ };
3115
+ if (ctx.common.async) {
3116
+ return Promise.all([
3117
+ this._def.left._parseAsync({
3118
+ data: ctx.data,
3119
+ path: ctx.path,
3120
+ parent: ctx
3121
+ }),
3122
+ this._def.right._parseAsync({
3123
+ data: ctx.data,
3124
+ path: ctx.path,
3125
+ parent: ctx
3126
+ })
3127
+ ]).then(([left, right]) => handleParsed(left, right));
3128
+ } else {
3129
+ return handleParsed(this._def.left._parseSync({
3130
+ data: ctx.data,
3131
+ path: ctx.path,
3132
+ parent: ctx
3133
+ }), this._def.right._parseSync({
3134
+ data: ctx.data,
3135
+ path: ctx.path,
3136
+ parent: ctx
3137
+ }));
3138
+ }
3139
+ }
3140
+ };
3141
+ ZodIntersection.create = (left, right, params) => {
3142
+ return new ZodIntersection({
3143
+ left,
3144
+ right,
3145
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
3146
+ ...processCreateParams(params)
3147
+ });
3148
+ };
3149
+ var ZodTuple = class _ZodTuple extends ZodType {
3150
+ _parse(input) {
3151
+ const { status, ctx } = this._processInputParams(input);
3152
+ if (ctx.parsedType !== ZodParsedType.array) {
3153
+ addIssueToContext(ctx, {
3154
+ code: ZodIssueCode.invalid_type,
3155
+ expected: ZodParsedType.array,
3156
+ received: ctx.parsedType
3157
+ });
3158
+ return INVALID;
3159
+ }
3160
+ if (ctx.data.length < this._def.items.length) {
3161
+ addIssueToContext(ctx, {
3162
+ code: ZodIssueCode.too_small,
3163
+ minimum: this._def.items.length,
3164
+ inclusive: true,
3165
+ exact: false,
3166
+ type: "array"
3167
+ });
3168
+ return INVALID;
3169
+ }
3170
+ const rest = this._def.rest;
3171
+ if (!rest && ctx.data.length > this._def.items.length) {
3172
+ addIssueToContext(ctx, {
3173
+ code: ZodIssueCode.too_big,
3174
+ maximum: this._def.items.length,
3175
+ inclusive: true,
3176
+ exact: false,
3177
+ type: "array"
3178
+ });
3179
+ status.dirty();
3180
+ }
3181
+ const items = [...ctx.data].map((item, itemIndex) => {
3182
+ const schema = this._def.items[itemIndex] || this._def.rest;
3183
+ if (!schema)
3184
+ return null;
3185
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
3186
+ }).filter((x) => !!x);
3187
+ if (ctx.common.async) {
3188
+ return Promise.all(items).then((results) => {
3189
+ return ParseStatus.mergeArray(status, results);
3190
+ });
3191
+ } else {
3192
+ return ParseStatus.mergeArray(status, items);
3193
+ }
3194
+ }
3195
+ get items() {
3196
+ return this._def.items;
3197
+ }
3198
+ rest(rest) {
3199
+ return new _ZodTuple({
3200
+ ...this._def,
3201
+ rest
3202
+ });
3203
+ }
3204
+ };
3205
+ ZodTuple.create = (schemas, params) => {
3206
+ if (!Array.isArray(schemas)) {
3207
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
3208
+ }
3209
+ return new ZodTuple({
3210
+ items: schemas,
3211
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
3212
+ rest: null,
3213
+ ...processCreateParams(params)
3214
+ });
3215
+ };
3216
+ var ZodRecord = class _ZodRecord extends ZodType {
3217
+ get keySchema() {
3218
+ return this._def.keyType;
3219
+ }
3220
+ get valueSchema() {
3221
+ return this._def.valueType;
3222
+ }
3223
+ _parse(input) {
3224
+ const { status, ctx } = this._processInputParams(input);
3225
+ if (ctx.parsedType !== ZodParsedType.object) {
3226
+ addIssueToContext(ctx, {
3227
+ code: ZodIssueCode.invalid_type,
3228
+ expected: ZodParsedType.object,
3229
+ received: ctx.parsedType
3230
+ });
3231
+ return INVALID;
3232
+ }
3233
+ const pairs = [];
3234
+ const keyType = this._def.keyType;
3235
+ const valueType = this._def.valueType;
3236
+ for (const key in ctx.data) {
3237
+ pairs.push({
3238
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
3239
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
3240
+ alwaysSet: key in ctx.data
3241
+ });
3242
+ }
3243
+ if (ctx.common.async) {
3244
+ return ParseStatus.mergeObjectAsync(status, pairs);
3245
+ } else {
3246
+ return ParseStatus.mergeObjectSync(status, pairs);
3247
+ }
3248
+ }
3249
+ get element() {
3250
+ return this._def.valueType;
3251
+ }
3252
+ static create(first, second, third) {
3253
+ if (second instanceof ZodType) {
3254
+ return new _ZodRecord({
3255
+ keyType: first,
3256
+ valueType: second,
3257
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3258
+ ...processCreateParams(third)
3259
+ });
3260
+ }
3261
+ return new _ZodRecord({
3262
+ keyType: ZodString.create(),
3263
+ valueType: first,
3264
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
3265
+ ...processCreateParams(second)
3266
+ });
3267
+ }
3268
+ };
3269
+ var ZodMap = class extends ZodType {
3270
+ get keySchema() {
3271
+ return this._def.keyType;
3272
+ }
3273
+ get valueSchema() {
3274
+ return this._def.valueType;
3275
+ }
3276
+ _parse(input) {
3277
+ const { status, ctx } = this._processInputParams(input);
3278
+ if (ctx.parsedType !== ZodParsedType.map) {
3279
+ addIssueToContext(ctx, {
3280
+ code: ZodIssueCode.invalid_type,
3281
+ expected: ZodParsedType.map,
3282
+ received: ctx.parsedType
3283
+ });
3284
+ return INVALID;
3285
+ }
3286
+ const keyType = this._def.keyType;
3287
+ const valueType = this._def.valueType;
3288
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
3289
+ return {
3290
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
3291
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
3292
+ };
3293
+ });
3294
+ if (ctx.common.async) {
3295
+ const finalMap = /* @__PURE__ */ new Map();
3296
+ return Promise.resolve().then(async () => {
3297
+ for (const pair of pairs) {
3298
+ const key = await pair.key;
3299
+ const value = await pair.value;
3300
+ if (key.status === "aborted" || value.status === "aborted") {
3301
+ return INVALID;
3302
+ }
3303
+ if (key.status === "dirty" || value.status === "dirty") {
3304
+ status.dirty();
3305
+ }
3306
+ finalMap.set(key.value, value.value);
3307
+ }
3308
+ return { status: status.value, value: finalMap };
3309
+ });
3310
+ } else {
3311
+ const finalMap = /* @__PURE__ */ new Map();
3312
+ for (const pair of pairs) {
3313
+ const key = pair.key;
3314
+ const value = pair.value;
3315
+ if (key.status === "aborted" || value.status === "aborted") {
3316
+ return INVALID;
3317
+ }
3318
+ if (key.status === "dirty" || value.status === "dirty") {
3319
+ status.dirty();
3320
+ }
3321
+ finalMap.set(key.value, value.value);
3322
+ }
3323
+ return { status: status.value, value: finalMap };
3324
+ }
3325
+ }
3326
+ };
3327
+ ZodMap.create = (keyType, valueType, params) => {
3328
+ return new ZodMap({
3329
+ valueType,
3330
+ keyType,
3331
+ typeName: ZodFirstPartyTypeKind.ZodMap,
3332
+ ...processCreateParams(params)
3333
+ });
3334
+ };
3335
+ var ZodSet = class _ZodSet extends ZodType {
3336
+ _parse(input) {
3337
+ const { status, ctx } = this._processInputParams(input);
3338
+ if (ctx.parsedType !== ZodParsedType.set) {
3339
+ addIssueToContext(ctx, {
3340
+ code: ZodIssueCode.invalid_type,
3341
+ expected: ZodParsedType.set,
3342
+ received: ctx.parsedType
3343
+ });
3344
+ return INVALID;
3345
+ }
3346
+ const def = this._def;
3347
+ if (def.minSize !== null) {
3348
+ if (ctx.data.size < def.minSize.value) {
3349
+ addIssueToContext(ctx, {
3350
+ code: ZodIssueCode.too_small,
3351
+ minimum: def.minSize.value,
3352
+ type: "set",
3353
+ inclusive: true,
3354
+ exact: false,
3355
+ message: def.minSize.message
3356
+ });
3357
+ status.dirty();
3358
+ }
3359
+ }
3360
+ if (def.maxSize !== null) {
3361
+ if (ctx.data.size > def.maxSize.value) {
3362
+ addIssueToContext(ctx, {
3363
+ code: ZodIssueCode.too_big,
3364
+ maximum: def.maxSize.value,
3365
+ type: "set",
3366
+ inclusive: true,
3367
+ exact: false,
3368
+ message: def.maxSize.message
3369
+ });
3370
+ status.dirty();
3371
+ }
3372
+ }
3373
+ const valueType = this._def.valueType;
3374
+ function finalizeSet(elements2) {
3375
+ const parsedSet = /* @__PURE__ */ new Set();
3376
+ for (const element of elements2) {
3377
+ if (element.status === "aborted")
3378
+ return INVALID;
3379
+ if (element.status === "dirty")
3380
+ status.dirty();
3381
+ parsedSet.add(element.value);
3382
+ }
3383
+ return { status: status.value, value: parsedSet };
3384
+ }
3385
+ const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));
3386
+ if (ctx.common.async) {
3387
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
3388
+ } else {
3389
+ return finalizeSet(elements);
3390
+ }
3391
+ }
3392
+ min(minSize, message) {
3393
+ return new _ZodSet({
3394
+ ...this._def,
3395
+ minSize: { value: minSize, message: errorUtil.toString(message) }
3396
+ });
3397
+ }
3398
+ max(maxSize, message) {
3399
+ return new _ZodSet({
3400
+ ...this._def,
3401
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
3402
+ });
3403
+ }
3404
+ size(size, message) {
3405
+ return this.min(size, message).max(size, message);
3406
+ }
3407
+ nonempty(message) {
3408
+ return this.min(1, message);
3409
+ }
3410
+ };
3411
+ ZodSet.create = (valueType, params) => {
3412
+ return new ZodSet({
3413
+ valueType,
3414
+ minSize: null,
3415
+ maxSize: null,
3416
+ typeName: ZodFirstPartyTypeKind.ZodSet,
3417
+ ...processCreateParams(params)
3418
+ });
3419
+ };
3420
+ var ZodFunction = class _ZodFunction extends ZodType {
3421
+ constructor() {
3422
+ super(...arguments);
3423
+ this.validate = this.implement;
3424
+ }
3425
+ _parse(input) {
3426
+ const { ctx } = this._processInputParams(input);
3427
+ if (ctx.parsedType !== ZodParsedType.function) {
3428
+ addIssueToContext(ctx, {
3429
+ code: ZodIssueCode.invalid_type,
3430
+ expected: ZodParsedType.function,
3431
+ received: ctx.parsedType
3432
+ });
3433
+ return INVALID;
3434
+ }
3435
+ function makeArgsIssue(args, error) {
3436
+ return makeIssue({
3437
+ data: args,
3438
+ path: ctx.path,
3439
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3440
+ issueData: {
3441
+ code: ZodIssueCode.invalid_arguments,
3442
+ argumentsError: error
3443
+ }
3444
+ });
3445
+ }
3446
+ function makeReturnsIssue(returns, error) {
3447
+ return makeIssue({
3448
+ data: returns,
3449
+ path: ctx.path,
3450
+ errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
3451
+ issueData: {
3452
+ code: ZodIssueCode.invalid_return_type,
3453
+ returnTypeError: error
3454
+ }
3455
+ });
3456
+ }
3457
+ const params = { errorMap: ctx.common.contextualErrorMap };
3458
+ const fn = ctx.data;
3459
+ if (this._def.returns instanceof ZodPromise) {
3460
+ const me = this;
3461
+ return OK(async function(...args) {
3462
+ const error = new ZodError([]);
3463
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e2) => {
3464
+ error.addIssue(makeArgsIssue(args, e2));
3465
+ throw error;
3466
+ });
3467
+ const result = await Reflect.apply(fn, this, parsedArgs);
3468
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e2) => {
3469
+ error.addIssue(makeReturnsIssue(result, e2));
3470
+ throw error;
3471
+ });
3472
+ return parsedReturns;
3473
+ });
3474
+ } else {
3475
+ const me = this;
3476
+ return OK(function(...args) {
3477
+ const parsedArgs = me._def.args.safeParse(args, params);
3478
+ if (!parsedArgs.success) {
3479
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
3480
+ }
3481
+ const result = Reflect.apply(fn, this, parsedArgs.data);
3482
+ const parsedReturns = me._def.returns.safeParse(result, params);
3483
+ if (!parsedReturns.success) {
3484
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
3485
+ }
3486
+ return parsedReturns.data;
3487
+ });
3488
+ }
3489
+ }
3490
+ parameters() {
3491
+ return this._def.args;
3492
+ }
3493
+ returnType() {
3494
+ return this._def.returns;
3495
+ }
3496
+ args(...items) {
3497
+ return new _ZodFunction({
3498
+ ...this._def,
3499
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
3500
+ });
3501
+ }
3502
+ returns(returnType) {
3503
+ return new _ZodFunction({
3504
+ ...this._def,
3505
+ returns: returnType
3506
+ });
3507
+ }
3508
+ implement(func) {
3509
+ const validatedFunc = this.parse(func);
3510
+ return validatedFunc;
3511
+ }
3512
+ strictImplement(func) {
3513
+ const validatedFunc = this.parse(func);
3514
+ return validatedFunc;
3515
+ }
3516
+ static create(args, returns, params) {
3517
+ return new _ZodFunction({
3518
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
3519
+ returns: returns || ZodUnknown.create(),
3520
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
3521
+ ...processCreateParams(params)
3522
+ });
3523
+ }
3524
+ };
3525
+ var ZodLazy = class extends ZodType {
3526
+ get schema() {
3527
+ return this._def.getter();
3528
+ }
3529
+ _parse(input) {
3530
+ const { ctx } = this._processInputParams(input);
3531
+ const lazySchema = this._def.getter();
3532
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
3533
+ }
3534
+ };
3535
+ ZodLazy.create = (getter, params) => {
3536
+ return new ZodLazy({
3537
+ getter,
3538
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
3539
+ ...processCreateParams(params)
3540
+ });
3541
+ };
3542
+ var ZodLiteral = class extends ZodType {
3543
+ _parse(input) {
3544
+ if (input.data !== this._def.value) {
3545
+ const ctx = this._getOrReturnCtx(input);
3546
+ addIssueToContext(ctx, {
3547
+ received: ctx.data,
3548
+ code: ZodIssueCode.invalid_literal,
3549
+ expected: this._def.value
3550
+ });
3551
+ return INVALID;
3552
+ }
3553
+ return { status: "valid", value: input.data };
3554
+ }
3555
+ get value() {
3556
+ return this._def.value;
3557
+ }
3558
+ };
3559
+ ZodLiteral.create = (value, params) => {
3560
+ return new ZodLiteral({
3561
+ value,
3562
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
3563
+ ...processCreateParams(params)
3564
+ });
3565
+ };
3566
+ function createZodEnum(values, params) {
3567
+ return new ZodEnum({
3568
+ values,
3569
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
3570
+ ...processCreateParams(params)
3571
+ });
3572
+ }
3573
+ var ZodEnum = class _ZodEnum extends ZodType {
3574
+ _parse(input) {
3575
+ if (typeof input.data !== "string") {
3576
+ const ctx = this._getOrReturnCtx(input);
3577
+ const expectedValues = this._def.values;
3578
+ addIssueToContext(ctx, {
3579
+ expected: util.joinValues(expectedValues),
3580
+ received: ctx.parsedType,
3581
+ code: ZodIssueCode.invalid_type
3582
+ });
3583
+ return INVALID;
3584
+ }
3585
+ if (!this._cache) {
3586
+ this._cache = new Set(this._def.values);
3587
+ }
3588
+ if (!this._cache.has(input.data)) {
3589
+ const ctx = this._getOrReturnCtx(input);
3590
+ const expectedValues = this._def.values;
3591
+ addIssueToContext(ctx, {
3592
+ received: ctx.data,
3593
+ code: ZodIssueCode.invalid_enum_value,
3594
+ options: expectedValues
3595
+ });
3596
+ return INVALID;
3597
+ }
3598
+ return OK(input.data);
3599
+ }
3600
+ get options() {
3601
+ return this._def.values;
3602
+ }
3603
+ get enum() {
3604
+ const enumValues = {};
3605
+ for (const val of this._def.values) {
3606
+ enumValues[val] = val;
3607
+ }
3608
+ return enumValues;
3609
+ }
3610
+ get Values() {
3611
+ const enumValues = {};
3612
+ for (const val of this._def.values) {
3613
+ enumValues[val] = val;
3614
+ }
3615
+ return enumValues;
3616
+ }
3617
+ get Enum() {
3618
+ const enumValues = {};
3619
+ for (const val of this._def.values) {
3620
+ enumValues[val] = val;
3621
+ }
3622
+ return enumValues;
3623
+ }
3624
+ extract(values, newDef = this._def) {
3625
+ return _ZodEnum.create(values, {
3626
+ ...this._def,
3627
+ ...newDef
3628
+ });
3629
+ }
3630
+ exclude(values, newDef = this._def) {
3631
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
3632
+ ...this._def,
3633
+ ...newDef
3634
+ });
3635
+ }
3636
+ };
3637
+ ZodEnum.create = createZodEnum;
3638
+ var ZodNativeEnum = class extends ZodType {
3639
+ _parse(input) {
3640
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
3641
+ const ctx = this._getOrReturnCtx(input);
3642
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3643
+ const expectedValues = util.objectValues(nativeEnumValues);
3644
+ addIssueToContext(ctx, {
3645
+ expected: util.joinValues(expectedValues),
3646
+ received: ctx.parsedType,
3647
+ code: ZodIssueCode.invalid_type
3648
+ });
3649
+ return INVALID;
3650
+ }
3651
+ if (!this._cache) {
3652
+ this._cache = new Set(util.getValidEnumValues(this._def.values));
3653
+ }
3654
+ if (!this._cache.has(input.data)) {
3655
+ const expectedValues = util.objectValues(nativeEnumValues);
3656
+ addIssueToContext(ctx, {
3657
+ received: ctx.data,
3658
+ code: ZodIssueCode.invalid_enum_value,
3659
+ options: expectedValues
3660
+ });
3661
+ return INVALID;
3662
+ }
3663
+ return OK(input.data);
3664
+ }
3665
+ get enum() {
3666
+ return this._def.values;
3667
+ }
3668
+ };
3669
+ ZodNativeEnum.create = (values, params) => {
3670
+ return new ZodNativeEnum({
3671
+ values,
3672
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3673
+ ...processCreateParams(params)
3674
+ });
3675
+ };
3676
+ var ZodPromise = class extends ZodType {
3677
+ unwrap() {
3678
+ return this._def.type;
3679
+ }
3680
+ _parse(input) {
3681
+ const { ctx } = this._processInputParams(input);
3682
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3683
+ addIssueToContext(ctx, {
3684
+ code: ZodIssueCode.invalid_type,
3685
+ expected: ZodParsedType.promise,
3686
+ received: ctx.parsedType
3687
+ });
3688
+ return INVALID;
3689
+ }
3690
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
3691
+ return OK(promisified.then((data) => {
3692
+ return this._def.type.parseAsync(data, {
3693
+ path: ctx.path,
3694
+ errorMap: ctx.common.contextualErrorMap
3695
+ });
3696
+ }));
3697
+ }
3698
+ };
3699
+ ZodPromise.create = (schema, params) => {
3700
+ return new ZodPromise({
3701
+ type: schema,
3702
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
3703
+ ...processCreateParams(params)
3704
+ });
3705
+ };
3706
+ var ZodEffects = class extends ZodType {
3707
+ innerType() {
3708
+ return this._def.schema;
3709
+ }
3710
+ sourceType() {
3711
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3712
+ }
3713
+ _parse(input) {
3714
+ const { status, ctx } = this._processInputParams(input);
3715
+ const effect = this._def.effect || null;
3716
+ const checkCtx = {
3717
+ addIssue: (arg) => {
3718
+ addIssueToContext(ctx, arg);
3719
+ if (arg.fatal) {
3720
+ status.abort();
3721
+ } else {
3722
+ status.dirty();
3723
+ }
3724
+ },
3725
+ get path() {
3726
+ return ctx.path;
3727
+ }
3728
+ };
3729
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3730
+ if (effect.type === "preprocess") {
3731
+ const processed = effect.transform(ctx.data, checkCtx);
3732
+ if (ctx.common.async) {
3733
+ return Promise.resolve(processed).then(async (processed2) => {
3734
+ if (status.value === "aborted")
3735
+ return INVALID;
3736
+ const result = await this._def.schema._parseAsync({
3737
+ data: processed2,
3738
+ path: ctx.path,
3739
+ parent: ctx
3740
+ });
3741
+ if (result.status === "aborted")
3742
+ return INVALID;
3743
+ if (result.status === "dirty")
3744
+ return DIRTY(result.value);
3745
+ if (status.value === "dirty")
3746
+ return DIRTY(result.value);
3747
+ return result;
3748
+ });
3749
+ } else {
3750
+ if (status.value === "aborted")
3751
+ return INVALID;
3752
+ const result = this._def.schema._parseSync({
3753
+ data: processed,
3754
+ path: ctx.path,
3755
+ parent: ctx
3756
+ });
3757
+ if (result.status === "aborted")
3758
+ return INVALID;
3759
+ if (result.status === "dirty")
3760
+ return DIRTY(result.value);
3761
+ if (status.value === "dirty")
3762
+ return DIRTY(result.value);
3763
+ return result;
3764
+ }
3765
+ }
3766
+ if (effect.type === "refinement") {
3767
+ const executeRefinement = (acc) => {
3768
+ const result = effect.refinement(acc, checkCtx);
3769
+ if (ctx.common.async) {
3770
+ return Promise.resolve(result);
3771
+ }
3772
+ if (result instanceof Promise) {
3773
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3774
+ }
3775
+ return acc;
3776
+ };
3777
+ if (ctx.common.async === false) {
3778
+ const inner = this._def.schema._parseSync({
3779
+ data: ctx.data,
3780
+ path: ctx.path,
3781
+ parent: ctx
3782
+ });
3783
+ if (inner.status === "aborted")
3784
+ return INVALID;
3785
+ if (inner.status === "dirty")
3786
+ status.dirty();
3787
+ executeRefinement(inner.value);
3788
+ return { status: status.value, value: inner.value };
3789
+ } else {
3790
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
3791
+ if (inner.status === "aborted")
3792
+ return INVALID;
3793
+ if (inner.status === "dirty")
3794
+ status.dirty();
3795
+ return executeRefinement(inner.value).then(() => {
3796
+ return { status: status.value, value: inner.value };
3797
+ });
3798
+ });
3799
+ }
3800
+ }
3801
+ if (effect.type === "transform") {
3802
+ if (ctx.common.async === false) {
3803
+ const base = this._def.schema._parseSync({
3804
+ data: ctx.data,
3805
+ path: ctx.path,
3806
+ parent: ctx
3807
+ });
3808
+ if (!isValid(base))
3809
+ return INVALID;
3810
+ const result = effect.transform(base.value, checkCtx);
3811
+ if (result instanceof Promise) {
3812
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3813
+ }
3814
+ return { status: status.value, value: result };
3815
+ } else {
3816
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
3817
+ if (!isValid(base))
3818
+ return INVALID;
3819
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3820
+ status: status.value,
3821
+ value: result
3822
+ }));
3823
+ });
3824
+ }
3825
+ }
3826
+ util.assertNever(effect);
3827
+ }
3828
+ };
3829
+ ZodEffects.create = (schema, effect, params) => {
3830
+ return new ZodEffects({
3831
+ schema,
3832
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3833
+ effect,
3834
+ ...processCreateParams(params)
3835
+ });
3836
+ };
3837
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3838
+ return new ZodEffects({
3839
+ schema,
3840
+ effect: { type: "preprocess", transform: preprocess },
3841
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
3842
+ ...processCreateParams(params)
3843
+ });
3844
+ };
3845
+ var ZodOptional = class extends ZodType {
3846
+ _parse(input) {
3847
+ const parsedType = this._getType(input);
3848
+ if (parsedType === ZodParsedType.undefined) {
3849
+ return OK(void 0);
3850
+ }
3851
+ return this._def.innerType._parse(input);
3852
+ }
3853
+ unwrap() {
3854
+ return this._def.innerType;
3855
+ }
3856
+ };
3857
+ ZodOptional.create = (type, params) => {
3858
+ return new ZodOptional({
3859
+ innerType: type,
3860
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
3861
+ ...processCreateParams(params)
3862
+ });
3863
+ };
3864
+ var ZodNullable = class extends ZodType {
3865
+ _parse(input) {
3866
+ const parsedType = this._getType(input);
3867
+ if (parsedType === ZodParsedType.null) {
3868
+ return OK(null);
3869
+ }
3870
+ return this._def.innerType._parse(input);
3871
+ }
3872
+ unwrap() {
3873
+ return this._def.innerType;
3874
+ }
3875
+ };
3876
+ ZodNullable.create = (type, params) => {
3877
+ return new ZodNullable({
3878
+ innerType: type,
3879
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
3880
+ ...processCreateParams(params)
3881
+ });
3882
+ };
3883
+ var ZodDefault = class extends ZodType {
3884
+ _parse(input) {
3885
+ const { ctx } = this._processInputParams(input);
3886
+ let data = ctx.data;
3887
+ if (ctx.parsedType === ZodParsedType.undefined) {
3888
+ data = this._def.defaultValue();
3889
+ }
3890
+ return this._def.innerType._parse({
3891
+ data,
3892
+ path: ctx.path,
3893
+ parent: ctx
3894
+ });
3895
+ }
3896
+ removeDefault() {
3897
+ return this._def.innerType;
3898
+ }
3899
+ };
3900
+ ZodDefault.create = (type, params) => {
3901
+ return new ZodDefault({
3902
+ innerType: type,
3903
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
3904
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3905
+ ...processCreateParams(params)
3906
+ });
3907
+ };
3908
+ var ZodCatch = class extends ZodType {
3909
+ _parse(input) {
3910
+ const { ctx } = this._processInputParams(input);
3911
+ const newCtx = {
3912
+ ...ctx,
3913
+ common: {
3914
+ ...ctx.common,
3915
+ issues: []
3916
+ }
3917
+ };
3918
+ const result = this._def.innerType._parse({
3919
+ data: newCtx.data,
3920
+ path: newCtx.path,
3921
+ parent: {
3922
+ ...newCtx
3923
+ }
3924
+ });
3925
+ if (isAsync(result)) {
3926
+ return result.then((result2) => {
3927
+ return {
3928
+ status: "valid",
3929
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
3930
+ get error() {
3931
+ return new ZodError(newCtx.common.issues);
3932
+ },
3933
+ input: newCtx.data
3934
+ })
3935
+ };
3936
+ });
3937
+ } else {
3938
+ return {
3939
+ status: "valid",
3940
+ value: result.status === "valid" ? result.value : this._def.catchValue({
3941
+ get error() {
3942
+ return new ZodError(newCtx.common.issues);
3943
+ },
3944
+ input: newCtx.data
3945
+ })
3946
+ };
3947
+ }
3948
+ }
3949
+ removeCatch() {
3950
+ return this._def.innerType;
3951
+ }
3952
+ };
3953
+ ZodCatch.create = (type, params) => {
3954
+ return new ZodCatch({
3955
+ innerType: type,
3956
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
3957
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3958
+ ...processCreateParams(params)
3959
+ });
3960
+ };
3961
+ var ZodNaN = class extends ZodType {
3962
+ _parse(input) {
3963
+ const parsedType = this._getType(input);
3964
+ if (parsedType !== ZodParsedType.nan) {
3965
+ const ctx = this._getOrReturnCtx(input);
3966
+ addIssueToContext(ctx, {
3967
+ code: ZodIssueCode.invalid_type,
3968
+ expected: ZodParsedType.nan,
3969
+ received: ctx.parsedType
3970
+ });
3971
+ return INVALID;
3972
+ }
3973
+ return { status: "valid", value: input.data };
3974
+ }
3975
+ };
3976
+ ZodNaN.create = (params) => {
3977
+ return new ZodNaN({
3978
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
3979
+ ...processCreateParams(params)
3980
+ });
3981
+ };
3982
+ var BRAND = /* @__PURE__ */ Symbol("zod_brand");
3983
+ var ZodBranded = class extends ZodType {
3984
+ _parse(input) {
3985
+ const { ctx } = this._processInputParams(input);
3986
+ const data = ctx.data;
3987
+ return this._def.type._parse({
3988
+ data,
3989
+ path: ctx.path,
3990
+ parent: ctx
3991
+ });
3992
+ }
3993
+ unwrap() {
3994
+ return this._def.type;
3995
+ }
3996
+ };
3997
+ var ZodPipeline = class _ZodPipeline extends ZodType {
3998
+ _parse(input) {
3999
+ const { status, ctx } = this._processInputParams(input);
4000
+ if (ctx.common.async) {
4001
+ const handleAsync = async () => {
4002
+ const inResult = await this._def.in._parseAsync({
4003
+ data: ctx.data,
4004
+ path: ctx.path,
4005
+ parent: ctx
4006
+ });
4007
+ if (inResult.status === "aborted")
4008
+ return INVALID;
4009
+ if (inResult.status === "dirty") {
4010
+ status.dirty();
4011
+ return DIRTY(inResult.value);
4012
+ } else {
4013
+ return this._def.out._parseAsync({
4014
+ data: inResult.value,
4015
+ path: ctx.path,
4016
+ parent: ctx
4017
+ });
4018
+ }
4019
+ };
4020
+ return handleAsync();
4021
+ } else {
4022
+ const inResult = this._def.in._parseSync({
4023
+ data: ctx.data,
4024
+ path: ctx.path,
4025
+ parent: ctx
4026
+ });
4027
+ if (inResult.status === "aborted")
4028
+ return INVALID;
4029
+ if (inResult.status === "dirty") {
4030
+ status.dirty();
4031
+ return {
4032
+ status: "dirty",
4033
+ value: inResult.value
4034
+ };
4035
+ } else {
4036
+ return this._def.out._parseSync({
4037
+ data: inResult.value,
4038
+ path: ctx.path,
4039
+ parent: ctx
4040
+ });
4041
+ }
4042
+ }
4043
+ }
4044
+ static create(a, b) {
4045
+ return new _ZodPipeline({
4046
+ in: a,
4047
+ out: b,
4048
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
4049
+ });
4050
+ }
4051
+ };
4052
+ var ZodReadonly = class extends ZodType {
4053
+ _parse(input) {
4054
+ const result = this._def.innerType._parse(input);
4055
+ const freeze = (data) => {
4056
+ if (isValid(data)) {
4057
+ data.value = Object.freeze(data.value);
4058
+ }
4059
+ return data;
4060
+ };
4061
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
4062
+ }
4063
+ unwrap() {
4064
+ return this._def.innerType;
4065
+ }
4066
+ };
4067
+ ZodReadonly.create = (type, params) => {
4068
+ return new ZodReadonly({
4069
+ innerType: type,
4070
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
4071
+ ...processCreateParams(params)
4072
+ });
4073
+ };
4074
+ function cleanParams(params, data) {
4075
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
4076
+ const p2 = typeof p === "string" ? { message: p } : p;
4077
+ return p2;
4078
+ }
4079
+ function custom(check, _params = {}, fatal) {
4080
+ if (check)
4081
+ return ZodAny.create().superRefine((data, ctx) => {
4082
+ const r = check(data);
4083
+ if (r instanceof Promise) {
4084
+ return r.then((r2) => {
4085
+ if (!r2) {
4086
+ const params = cleanParams(_params, data);
4087
+ const _fatal = params.fatal ?? fatal ?? true;
4088
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4089
+ }
4090
+ });
4091
+ }
4092
+ if (!r) {
4093
+ const params = cleanParams(_params, data);
4094
+ const _fatal = params.fatal ?? fatal ?? true;
4095
+ ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
4096
+ }
4097
+ return;
4098
+ });
4099
+ return ZodAny.create();
4100
+ }
4101
+ var late = {
4102
+ object: ZodObject.lazycreate
4103
+ };
4104
+ var ZodFirstPartyTypeKind;
4105
+ (function(ZodFirstPartyTypeKind2) {
4106
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
4107
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
4108
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
4109
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
4110
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
4111
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
4112
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
4113
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
4114
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
4115
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
4116
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
4117
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
4118
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
4119
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
4120
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
4121
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
4122
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
4123
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
4124
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
4125
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
4126
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
4127
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
4128
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
4129
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
4130
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
4131
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
4132
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
4133
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
4134
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
4135
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
4136
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
4137
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
4138
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
4139
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
4140
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
4141
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
4142
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
4143
+ var instanceOfType = (cls, params = {
4144
+ message: `Input not instance of ${cls.name}`
4145
+ }) => custom((data) => data instanceof cls, params);
4146
+ var stringType = ZodString.create;
4147
+ var numberType = ZodNumber.create;
4148
+ var nanType = ZodNaN.create;
4149
+ var bigIntType = ZodBigInt.create;
4150
+ var booleanType = ZodBoolean.create;
4151
+ var dateType = ZodDate.create;
4152
+ var symbolType = ZodSymbol.create;
4153
+ var undefinedType = ZodUndefined.create;
4154
+ var nullType = ZodNull.create;
4155
+ var anyType = ZodAny.create;
4156
+ var unknownType = ZodUnknown.create;
4157
+ var neverType = ZodNever.create;
4158
+ var voidType = ZodVoid.create;
4159
+ var arrayType = ZodArray.create;
4160
+ var objectType = ZodObject.create;
4161
+ var strictObjectType = ZodObject.strictCreate;
4162
+ var unionType = ZodUnion.create;
4163
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
4164
+ var intersectionType = ZodIntersection.create;
4165
+ var tupleType = ZodTuple.create;
4166
+ var recordType = ZodRecord.create;
4167
+ var mapType = ZodMap.create;
4168
+ var setType = ZodSet.create;
4169
+ var functionType = ZodFunction.create;
4170
+ var lazyType = ZodLazy.create;
4171
+ var literalType = ZodLiteral.create;
4172
+ var enumType = ZodEnum.create;
4173
+ var nativeEnumType = ZodNativeEnum.create;
4174
+ var promiseType = ZodPromise.create;
4175
+ var effectsType = ZodEffects.create;
4176
+ var optionalType = ZodOptional.create;
4177
+ var nullableType = ZodNullable.create;
4178
+ var preprocessType = ZodEffects.createWithPreprocess;
4179
+ var pipelineType = ZodPipeline.create;
4180
+ var ostring = () => stringType().optional();
4181
+ var onumber = () => numberType().optional();
4182
+ var oboolean = () => booleanType().optional();
4183
+ var coerce = {
4184
+ string: ((arg) => ZodString.create({ ...arg, coerce: true })),
4185
+ number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
4186
+ boolean: ((arg) => ZodBoolean.create({
4187
+ ...arg,
4188
+ coerce: true
4189
+ })),
4190
+ bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
4191
+ date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
4192
+ };
4193
+ var NEVER = INVALID;
4194
+
4195
+ // ../../sdk-contracts/dist/schemas.js
4196
+ var NO_CSS_BREAKOUT_PATTERN = /^[^{}]*$/;
4197
+ var AnchorIdZ = external_exports.object({
4198
+ selector: external_exports.string().regex(NO_CSS_BREAKOUT_PATTERN, {
4199
+ message: 'selector must not contain "{" or "}" \u2014 not valid CSS selector syntax, and content:hideBySelector injects this value directly into a <style> element where these characters would break out of the generated rule.'
4200
+ }).describe("CSS selector for the target element"),
4201
+ route: external_exports.union([external_exports.string(), external_exports.array(external_exports.string())]).superRefine((value, ctx) => {
4202
+ for (const route of Array.isArray(value) ? value : [value]) {
4203
+ let canonical;
4204
+ try {
4205
+ canonical = normalizeRoute(route);
4206
+ } catch (err) {
4207
+ ctx.addIssue({
4208
+ code: external_exports.ZodIssueCode.custom,
4209
+ message: `route must be an absolute path starting with "/" (got ${JSON.stringify(route)}): ${err instanceof Error ? err.message : String(err)}`
4210
+ });
4211
+ continue;
4212
+ }
4213
+ if (canonical !== route) {
4214
+ ctx.addIssue({
4215
+ code: external_exports.ZodIssueCode.custom,
4216
+ message: `route ${JSON.stringify(route)} is not canonical \u2014 use ${JSON.stringify(canonical)} (this must match what the backend's RouteCanonicalityCheck accepts)`
4217
+ });
4218
+ }
4219
+ }
4220
+ }).describe("URL path(s) where this element exists")
4221
+ }).strict().describe("DOM element target. selector = CSS selector, route = URL path(s) where the element exists.");
4222
+ var AuthoringFieldsZ = {
4223
+ id: external_exports.string().optional().describe('Stable action identifier (e.g. "act_3db6a14d2ab0").'),
4224
+ title: external_exports.string().max(200).optional().describe("Authoring-only: short label shown on the action plan dashboard. Stripped before serving to the runtime SDK."),
4225
+ description: external_exports.string().max(1e3).optional().describe("Authoring-only: one-sentence explanation of what this action does and why. Stripped before serving to the runtime SDK."),
4226
+ validation: external_exports.array(external_exports.string().max(500)).max(10).optional().describe("Authoring-only: ordered steps a reviewer can follow to trigger this action and visually confirm it works. Each entry is one step. Stripped before serving to the runtime SDK.")
4227
+ };
4228
+ var COUNTABLE_EVENTS = [
4229
+ // User interactions (from PostHog autocapture normalization)
4230
+ "ui.click",
4231
+ "ui.scroll",
4232
+ "ui.input",
4233
+ "ui.change",
4234
+ "ui.submit",
4235
+ // Behavioral detectors (from event-processor)
4236
+ "ui.hover",
4237
+ "ui.idle",
4238
+ "ui.scroll_thrash",
4239
+ "ui.focus_bounce",
4240
+ "ui.hesitate",
4241
+ "ui.rage_click",
4242
+ // Navigation
4243
+ "nav.page_view",
4244
+ "nav.page_leave"
4245
+ ];
4246
+ var CountableEventZ = external_exports.enum(COUNTABLE_EVENTS).describe("Event name to count. ui.* = user interactions and behavioral detectors (hesitate, rage_click, scroll_thrash, focus_bounce, idle, hover); nav.* = page navigation.");
4247
+ var SESSION_METRIC_KEYS = ["time_on_page", "page_views", "scroll_depth"];
4248
+ var SessionMetricKeyZ = external_exports.enum(SESSION_METRIC_KEYS).describe("Session metric key. time_on_page = seconds on current page, page_views = pages visited this session, scroll_depth = 0-100 percentage.");
4249
+ var PageUrlConditionZ = external_exports.object({
4250
+ type: external_exports.literal("page_url"),
4251
+ url: external_exports.string().describe('URL path to match (e.g. "/pricing", "/dashboard")')
4252
+ }).describe('Fires when the current page URL matches. Use for page-specific actions. Example: {"type": "page_url", "url": "/pricing"}');
4253
+ var RouteConditionZ = external_exports.object({
4254
+ type: external_exports.literal("route"),
4255
+ routeId: external_exports.string().describe("Named route ID from the route filter")
4256
+ }).describe("Fires when the current route matches a named route ID.");
4257
+ var AnchorVisibleConditionZ = external_exports.object({
4258
+ type: external_exports.literal("anchor_visible"),
4259
+ anchorId: external_exports.string().describe("CSS selector of the anchor element"),
4260
+ state: external_exports.enum(["visible", "present", "absent"]).describe('"visible" = in viewport, "present" = in DOM, "absent" = not in DOM')
4261
+ }).describe(`Fires based on a DOM element's visibility state. Example: {"type": "anchor_visible", "anchorId": "#cta-button", "state": "visible"}`);
4262
+ var EventOccurredConditionZ = external_exports.object({
4263
+ type: external_exports.literal("event_occurred"),
4264
+ eventName: external_exports.string().describe('Event name (e.g. "ui.click", "$pageview")'),
4265
+ withinMs: external_exports.number().optional().describe("Time window in ms. Omit = any time this session.")
4266
+ }).describe('Fires when a specific event has occurred during this session. Example: {"type": "event_occurred", "eventName": "ui.click", "withinMs": 5000}');
4267
+ var StateEqualsConditionZ = external_exports.object({
4268
+ type: external_exports.literal("state_equals"),
4269
+ key: external_exports.string().describe("Key in the SDK persistent state store (localStorage). Only valid for keys the host app explicitly sets via syntro.state.set()."),
4270
+ value: external_exports.unknown().describe("Expected value to match against")
4271
+ }).describe("Checks the SDK persistent state store (localStorage). ONLY for host-app state set via syntro.state.set() \u2014 NOT for user attributes like region, device, or UTM params (those are handled by segment targeting). Do NOT use this for targeting. If you do not know the valid state keys, do not use this condition type.");
4272
+ var ViewportConditionZ = external_exports.object({
4273
+ type: external_exports.literal("viewport"),
4274
+ minWidth: external_exports.number().optional().describe("Minimum viewport width in pixels"),
4275
+ maxWidth: external_exports.number().optional().describe("Maximum viewport width in pixels"),
4276
+ minHeight: external_exports.number().optional().describe("Minimum viewport height in pixels"),
4277
+ maxHeight: external_exports.number().optional().describe("Maximum viewport height in pixels")
4278
+ }).describe('Fires based on viewport (screen) size. Use for responsive behavior. Example: {"type": "viewport", "minWidth": 768} \u2014 fires on tablet and larger.');
4279
+ var SessionMetricConditionZ = external_exports.object({
4280
+ type: external_exports.literal("session_metric"),
4281
+ key: SessionMetricKeyZ,
4282
+ operator: external_exports.enum(["gte", "lte", "eq", "gt", "lt"]),
4283
+ threshold: external_exports.number().describe("Numeric threshold to compare against")
4284
+ }).describe('Fires when a session metric crosses a threshold. Valid keys: "time_on_page" (seconds), "page_views" (count), "scroll_depth" (0-100). Example: {"type": "session_metric", "key": "time_on_page", "operator": "gte", "threshold": 30}');
4285
+ var DismissedConditionZ = external_exports.object({
4286
+ type: external_exports.literal("dismissed"),
4287
+ key: external_exports.string().describe("Dismissal key (usually a tile or action ID)"),
4288
+ inverted: external_exports.boolean().optional().describe("When true, fires if NOT dismissed (default behavior)")
4289
+ }).describe("Checks if an item has been dismissed by the user. Use with inverted: true to show only if not dismissed.");
4290
+ var CooldownActiveConditionZ = external_exports.object({
4291
+ type: external_exports.literal("cooldown_active"),
4292
+ key: external_exports.string().describe("Cooldown key"),
4293
+ inverted: external_exports.boolean().optional().describe("When true, fires if cooldown is NOT active")
4294
+ }).describe("Checks if a cooldown timer is currently active. Use to prevent showing the same intervention too frequently.");
4295
+ var FrequencyLimitConditionZ = external_exports.object({
4296
+ type: external_exports.literal("frequency_limit"),
4297
+ key: external_exports.string().describe("Frequency counter key"),
4298
+ limit: external_exports.number().describe("Maximum allowed count"),
4299
+ inverted: external_exports.boolean().optional().describe("When true, fires if limit NOT reached")
4300
+ }).describe("Checks if a frequency limit has been reached. Use to cap how many times an action fires per session.");
4301
+ var MatchOpZ = external_exports.object({
4302
+ equals: external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()]).optional(),
4303
+ contains: external_exports.string().optional()
4304
+ }).refine((operator) => Number(operator.equals !== void 0) + Number(operator.contains !== void 0) === 1, {
4305
+ message: "Exactly one of equals or contains must be specified."
4306
+ }).describe("Match operator for counter filters. Exactly one of equals or contains must be specified.");
4307
+ var CounterDefZ = external_exports.object({
4308
+ events: external_exports.array(CountableEventZ).min(1).describe("Event names to count. Use values from the countable events enum."),
4309
+ match: external_exports.record(external_exports.string(), MatchOpZ).optional().describe("Property filters. Keys are event prop names or element-chain fields (tag_name, $el_text, attr__*). All entries AND together.")
4310
+ }).describe("Defines what events to count. Registered as an accumulator predicate at config-load time.");
4311
+ var EventCountConditionZ = external_exports.object({
4312
+ type: external_exports.literal("event_count"),
4313
+ key: external_exports.string().describe("Unique key for this counter (used for accumulator registration)"),
4314
+ operator: external_exports.enum(["gte", "lte", "eq", "gt", "lt"]),
4315
+ count: external_exports.number().int().min(0).describe("Target count threshold"),
4316
+ withinMs: external_exports.number().positive().optional().describe("Time window in ms. Omit = count across entire session."),
4317
+ counter: CounterDefZ.optional().describe("Inline counter definition. Defines what events to count.")
4318
+ }).describe('Fires when accumulated event count crosses a threshold. Most powerful trigger type. Example: {"type": "event_count", "key": "pricing-clicks", "operator": "gte", "count": 3, "counter": {"events": ["ui.click"], "match": {"attr__data-cta": {"contains": "pricing"}}}}');
4319
+ var ConditionZ = external_exports.discriminatedUnion("type", [
4320
+ PageUrlConditionZ,
4321
+ RouteConditionZ,
4322
+ AnchorVisibleConditionZ,
4323
+ EventOccurredConditionZ,
4324
+ StateEqualsConditionZ,
4325
+ ViewportConditionZ,
4326
+ SessionMetricConditionZ,
4327
+ DismissedConditionZ,
4328
+ CooldownActiveConditionZ,
4329
+ FrequencyLimitConditionZ,
4330
+ EventCountConditionZ
4331
+ ]);
4332
+ var RuleZ = external_exports.object({
4333
+ conditions: external_exports.array(ConditionZ).describe("Array of conditions \u2014 ALL must match (AND logic) for this rule to fire."),
4334
+ value: external_exports.unknown().describe("Value returned when all conditions match. For triggerWhen: true = fire the action.")
4335
+ }).describe("A single rule. ALL conditions must match (AND logic). Rules in a strategy are evaluated top-to-bottom \u2014 first rule where all conditions match wins and returns its value.");
4336
+ var RuleStrategyZ = external_exports.object({
4337
+ type: external_exports.literal("rules"),
4338
+ rules: external_exports.array(RuleZ).describe("Ordered list of rules. Evaluated top-to-bottom \u2014 first match wins."),
4339
+ default: external_exports.unknown().describe("Fallback value when no rule matches. For triggerWhen: false = do not fire by default.")
4340
+ }).describe("Rule-based strategy. Evaluates rules top-to-bottom. First rule where ALL conditions match returns its value. If no rule matches, returns default. For triggerWhen: set value=true on matching rules, default=false.");
4341
+ var ScoreStrategyZ = external_exports.object({
4342
+ type: external_exports.literal("score"),
4343
+ field: external_exports.string(),
4344
+ threshold: external_exports.number(),
4345
+ above: external_exports.unknown(),
4346
+ below: external_exports.unknown()
4347
+ }).describe("Score-based strategy. Compares a field value against a threshold.");
4348
+ var ModelStrategyZ = external_exports.object({
4349
+ type: external_exports.literal("model"),
4350
+ modelId: external_exports.string(),
4351
+ inputs: external_exports.array(external_exports.string()),
4352
+ outputMapping: external_exports.record(external_exports.string(), external_exports.unknown()),
4353
+ default: external_exports.unknown()
4354
+ }).describe("ML model strategy. Sends inputs to a model and maps outputs.");
4355
+ var ExternalStrategyZ = external_exports.object({
4356
+ type: external_exports.literal("external"),
4357
+ endpoint: external_exports.string(),
4358
+ method: external_exports.enum(["GET", "POST"]).optional(),
4359
+ default: external_exports.unknown(),
4360
+ timeoutMs: external_exports.number().optional()
4361
+ }).describe("External API strategy. Calls an endpoint to determine the value.");
4362
+ var DecisionStrategyZ = external_exports.discriminatedUnion("type", [
4363
+ RuleStrategyZ,
4364
+ ScoreStrategyZ,
4365
+ ModelStrategyZ,
4366
+ ExternalStrategyZ
4367
+ ]);
4368
+ var TriggerWhenZ = DecisionStrategyZ.nullable().optional();
4369
+ var EventScopeZ = external_exports.object({
4370
+ events: external_exports.array(external_exports.string()),
4371
+ urlContains: external_exports.string().optional(),
4372
+ props: external_exports.record(external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean()])).optional()
4373
+ });
4374
+ var NotifyZ = external_exports.object({
4375
+ title: external_exports.string().optional().describe("Notification title"),
4376
+ body: external_exports.string().optional().describe("Notification body text"),
4377
+ icon: external_exports.string().optional().describe("Notification icon (emoji or URL)")
4378
+ }).describe("Optional toast notification shown when this action triggers.").nullable().optional();
4379
+
4380
+ // ../../../node_modules/@lit/context/lib/create-context.js
4381
+ function n(n2) {
4382
+ return n2;
4383
+ }
4384
+
4385
+ // ../../sdk-contracts/dist/canvas-context.js
4386
+ var canvasRuntimeContext = n("syntrologie:canvas-runtime");
4387
+
4388
+ // ../../sdk-contracts/dist/telemetry-events.js
4389
+ var entry = (e2) => e2;
4390
+ var TELEMETRY_EVENTS = {
4391
+ // --- intervention metrics (April 2026) — wire names unchanged, all plan-scope
4392
+ syntro_config_served: entry({
4393
+ subject: "config",
4394
+ verb: "served",
4395
+ scope: "plan",
4396
+ props: ["tiles", "actions"]
4397
+ }),
4398
+ syntro_intervention_seen: entry({
4399
+ subject: "intervention",
4400
+ verb: "seen",
4401
+ scope: "plan",
4402
+ props: ["intervention_id", "intervention_kind"]
4403
+ }),
4404
+ syntro_intervention_triggered: entry({
4405
+ subject: "intervention",
4406
+ verb: "triggered",
4407
+ scope: "plan",
4408
+ props: ["intervention_id", "intervention_kind"]
4409
+ }),
4410
+ syntro_intervention_interacted: entry({
4411
+ subject: "intervention",
4412
+ verb: "interacted",
4413
+ scope: "plan",
4414
+ props: ["intervention_id", "intervention_kind", "interaction_type"]
4415
+ }),
4416
+ // --- concierge (FEAT-1789150184) ---------------------------------------
4417
+ syntro_concierge_opened: entry({
4418
+ subject: "concierge",
4419
+ verb: "opened",
4420
+ scope: "open",
4421
+ props: ["trigger", "page_path"]
4422
+ // trigger: ConciergeOpenTrigger
4423
+ }),
4424
+ syntro_concierge_closed: entry({
4425
+ subject: "concierge",
4426
+ verb: "closed",
4427
+ scope: "open",
4428
+ props: ["duration_ms", "reason", "messages_sent", "tiles_dismissed", "pages_viewed"]
4429
+ // reason: ConciergeCloseReason
4430
+ }),
4431
+ /**
4432
+ * The shopper asked to leave the canvas by a link. Emitted on intent, before
4433
+ * the host answers, so refused or denied opens are counted too (parity with
4434
+ * syntro_concierge_closed reason navigation).
4435
+ *
4436
+ * On a merchant's own page a link tap closes the canvas, and
4437
+ * `syntro_concierge_closed { reason: 'navigation' }` is the row that
4438
+ * records it. Inside a chat app's card the frame is sandboxed: the canvas
4439
+ * cannot navigate, does not close, and asks the host to open the link
4440
+ * instead, so that close row never fires. This is its counterpart, and it
4441
+ * carries the same `reason` so one query covers both surfaces.
4442
+ */
4443
+ syntro_link_opened: entry({
4444
+ subject: "link",
4445
+ verb: "opened",
4446
+ scope: "open",
4447
+ props: ["kind", "reason"]
4448
+ // kind: LinkOpenKind, reason: ConciergeCloseReason
4449
+ }),
4450
+ /**
4451
+ * A store's product page opened inside a chat-app card instead of leaving
4452
+ * through the host (the card's product view). `product` is the store's
4453
+ * handle, never the display name; a rail switch is a new open. Its
4454
+ * counterpart when the shopper goes back to the conversation's picks is
4455
+ * syntro_product_view_closed.
4456
+ *
4457
+ * Plan scope, like the card's own syntro_card_lifecycle_seen: an inline
4458
+ * card holds an open scope only while the host has it fullscreen, and a
4459
+ * view opened from a tile fires before the host answers that request (or
4460
+ * after it refused), so an open-scope row here would be dropped. The core
4461
+ * still stamps surface and open_id whenever an open is live.
4462
+ */
4463
+ syntro_product_view_opened: entry({
4464
+ subject: "product_view",
4465
+ verb: "opened",
4466
+ scope: "plan",
4467
+ props: ["product", "from"]
4468
+ // from: ProductViewOpenSource
4469
+ }),
4470
+ syntro_product_view_closed: entry({
4471
+ subject: "product_view",
4472
+ verb: "closed",
4473
+ scope: "plan",
4474
+ props: ["product"]
4475
+ }),
4476
+ syntro_deck_paged: entry({
4477
+ subject: "deck",
4478
+ verb: "paged",
4479
+ scope: "open",
4480
+ props: ["from_index", "to_index", "method"]
4481
+ // method: DeckPageMethod
4482
+ }),
4483
+ syntro_tile_dismissed: entry({
4484
+ subject: "tile",
4485
+ verb: "dismissed",
4486
+ scope: "open",
4487
+ props: ["tile_id", "tile_kind", "visible_ms"]
4488
+ }),
4489
+ // A tile's own data load finished: the network wait between the concierge
4490
+ // mounting a tile and the shopper seeing its content (BUG-1784767817 was a
4491
+ // 30 s reviews hang here). `outcome` is 'ok' | 'error'; `requested` is how
4492
+ // many items the tile asked for, `received` how many came back.
4493
+ syntro_tile_data_received: entry({
4494
+ subject: "tile_data",
4495
+ verb: "received",
4496
+ scope: "open",
4497
+ props: ["tile_id", "tile_kind", "total_ms", "outcome", "requested", "received"]
4498
+ }),
4499
+ // The three chat atoms are OPEN-scope: they carry `surface` / `open_id` and
4500
+ // only make sense inside a concierge open. An INLINE chat bar (no concierge)
4501
+ // still dispatches them on every turn, and the core drops each one and
4502
+ // increments the `telemetry_dropped` health counter. That is EXPECTED on an
4503
+ // inline-chat host page, not a bug — `telemetry_dropped` there mixes "real
4504
+ // defect" with "inline chat has no open scope", so do not alert on it alone.
4505
+ syntro_chat_message_sent: entry({
4506
+ subject: "chat_message",
4507
+ verb: "sent",
4508
+ scope: "open",
4509
+ props: ["turn", "chars", "via"]
4510
+ // via: ChatSendVia
4511
+ }),
4512
+ syntro_chat_reply_received: entry({
4513
+ subject: "chat_reply",
4514
+ verb: "received",
4515
+ scope: "open",
4516
+ // mount_tools: the mount_* tool name of every mount this reply fired, in order (two product cards appear twice).
4517
+ props: ["turn", "ttft_ms", "total_ms", "mounts", "cards", "mount_tools"]
4518
+ }),
4519
+ syntro_chat_interrupted: entry({
4520
+ subject: "chat",
4521
+ verb: "interrupted",
4522
+ scope: "open",
4523
+ props: ["turn", "after_ms"]
4524
+ }),
4525
+ syntro_chat_maximize_toggled: entry({
4526
+ subject: "chat_maximize",
4527
+ verb: "toggled",
4528
+ scope: "open",
4529
+ props: ["maximized"]
4530
+ }),
4531
+ syntro_chat_takeover_triggered: entry({
4532
+ subject: "chat_takeover",
4533
+ verb: "triggered",
4534
+ scope: "open",
4535
+ props: ["turn"]
4536
+ }),
4537
+ // --- search takeover (2026-09-17) ---------------------------------------
4538
+ // All plan-scope: the search interceptor fires before any concierge open
4539
+ // exists. No prop here ever carries query text (SEE the contract test's
4540
+ // no-text-prop rule) — classification/signal_hits are the interceptor's
4541
+ // own derived signals, never the string itself.
4542
+ syntro_search_sent: entry({
4543
+ subject: "search",
4544
+ verb: "sent",
4545
+ scope: "plan",
4546
+ props: ["classification", "word_count", "signal_hits", "entry_point", "platform"]
4547
+ // classification: SearchClassification, entry_point: SearchEntryPoint
4548
+ }),
4549
+ // `ms_to_skeleton` is intentionally the only timing prop: it is always
4550
+ // knowable the instant the surface mounts. `ms_to_first_content` is NOT
4551
+ // declared here (revision 1 defect) because a surface that never painted
4552
+ // content still fires this event, and a required prop it cannot supply
4553
+ // would make TelemetryCore.emit drop exactly the row worth measuring.
4554
+ syntro_search_surface_seen: entry({
4555
+ subject: "search_surface",
4556
+ verb: "seen",
4557
+ scope: "plan",
4558
+ props: ["variant", "classification", "result_count", "ms_to_skeleton"]
4559
+ // variant: SearchVariant, classification: SearchClassification
4560
+ }),
4561
+ syntro_search_result_tapped: entry({
4562
+ subject: "search_result",
4563
+ verb: "tapped",
4564
+ scope: "plan",
4565
+ props: ["variant", "region_id", "module", "position"]
4566
+ // variant: SearchVariant
4567
+ }),
4568
+ syntro_search_followup_sent: entry({
4569
+ subject: "search_followup",
4570
+ verb: "sent",
4571
+ scope: "plan",
4572
+ props: ["delta_kind", "variant"]
4573
+ // delta_kind: SearchDeltaKind, variant: SearchVariant
4574
+ }),
4575
+ // Declares `ms_since_boot` (not a "since surface mounted" timing prop) so a
4576
+ // not-ready fallback the takeover never rendered is still measurable —
4577
+ // revision 1 emitted nothing on this path.
4578
+ syntro_search_native_served: entry({
4579
+ subject: "search_native",
4580
+ verb: "served",
4581
+ scope: "plan",
4582
+ props: ["reason", "platform", "ms_since_boot"]
4583
+ // reason: SearchFallbackReason
4584
+ }),
4585
+ syntro_search_takeover_dismissed: entry({
4586
+ subject: "search_takeover",
4587
+ verb: "dismissed",
4588
+ scope: "plan",
4589
+ props: ["variant", "reason"]
4590
+ // variant: SearchVariant, reason: SearchDismissReason
4591
+ }),
4592
+ // --- chat-app card lifecycle (2026-09-24) --------------------------------
4593
+ // One row per stage a card reached, from `reportCardStage` in
4594
+ // card-lifecycle.ts. Plan scope: most stages happen before a config is
4595
+ // served and none happen inside a concierge open. `stage` is a
4596
+ // CardLifecycleStage; `since_shell_ms` is the card shell's own clock, so a
4597
+ // card's rows order themselves from the first byte of the page. The same
4598
+ // stages reach the connector through the shell's beacon, which is the only
4599
+ // record of a card whose SDK never booted.
4600
+ syntro_card_lifecycle_seen: entry({
4601
+ subject: "card_lifecycle",
4602
+ verb: "seen",
4603
+ scope: "plan",
4604
+ props: ["stage", "since_shell_ms"]
4605
+ // stage: CardLifecycleStage
4606
+ })
4607
+ };
4608
+ var TELEMETRY_EVENT_NAMES = Object.keys(TELEMETRY_EVENTS);
4609
+
4610
+ // ../../sdk-contracts/dist/card-lifecycle.js
4611
+ var MCP_APP_SURFACE_ATTRIBUTES = Object.freeze({
4612
+ surface_type: "mcp-app",
4613
+ surface: "personal_agent"
4614
+ });
4615
+
4616
+ // ../../sdk-contracts/dist/color-scheme.js
4617
+ function normalize(value) {
4618
+ const scheme = (value || "").trim().toLowerCase();
4619
+ return scheme === "dark" || scheme === "light" ? scheme : null;
4620
+ }
4621
+ function declaredByDocument() {
4622
+ if (typeof document === "undefined")
4623
+ return null;
4624
+ const root = document.documentElement;
4625
+ if (!root)
4626
+ return null;
4627
+ if (typeof getComputedStyle === "function") {
4628
+ const computed = normalize(getComputedStyle(root).colorScheme);
4629
+ if (computed)
4630
+ return computed;
4631
+ }
4632
+ const inline = normalize(root.style?.colorScheme);
4633
+ if (inline)
4634
+ return inline;
4635
+ const attr = normalize(root.getAttribute?.("data-theme"));
4636
+ if (attr)
4637
+ return attr;
4638
+ if (root.classList?.contains("dark"))
4639
+ return "dark";
4640
+ return null;
4641
+ }
4642
+ function resolveColorScheme(declared) {
4643
+ if (declared === "dark")
4644
+ return "dark";
4645
+ if (declared === "light")
4646
+ return "light";
4647
+ const fromDocument = declaredByDocument();
4648
+ if (fromDocument)
4649
+ return fromDocument;
4650
+ if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
4651
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4652
+ }
4653
+ return "light";
4654
+ }
4655
+
4656
+ // ../../sdk-contracts/dist/detector-events.js
4657
+ var DETECTOR_EVENT_NAMES = [
4658
+ "ui.hover",
4659
+ "ui.idle",
4660
+ "ui.hesitate",
4661
+ "ui.rage_click",
4662
+ "ui.scroll_thrash",
4663
+ "ui.focus_bounce"
4664
+ ];
4665
+ var CANONICAL_BUS_EVENT_NAMES = [
4666
+ ...DETECTOR_EVENT_NAMES,
4667
+ "nav.section_viewed",
4668
+ "nav.scroll_depth"
4669
+ ];
4670
+
4671
+ // ../../sdk-contracts/dist/icons.js
4672
+ var PREFIX = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"';
4673
+ var EMOJI_SVG_PATHS = {
4674
+ // ── existing in adaptive-nav ─────────────────────────────────────────────
4675
+ "\u{1F4B5}": [
4676
+ '<rect width="20" height="12" x="2" y="6" rx="2"/>',
4677
+ '<circle cx="12" cy="12" r="2"/>',
4678
+ '<path d="M6 12h.01M18 12h.01"/>'
4679
+ ],
4680
+ "\u{1F3DB}\uFE0F": [
4681
+ '<line x1="3" x2="21" y1="22" y2="22"/>',
4682
+ '<line x1="6" x2="6" y1="18" y2="11"/>',
4683
+ '<line x1="10" x2="10" y1="18" y2="11"/>',
4684
+ '<line x1="14" x2="14" y1="18" y2="11"/>',
4685
+ '<line x1="18" x2="18" y1="18" y2="11"/>',
4686
+ '<polygon points="12 2 20 7 4 7"/>'
4687
+ ],
4688
+ "\u23ED\uFE0F": ['<polygon points="5 4 15 12 5 20 5 4"/>', '<line x1="19" x2="19" y1="5" y2="19"/>'],
4689
+ "\u27A1\uFE0F": ['<path d="M5 12h14"/>', '<path d="m12 5 7 7-7 7"/>'],
4690
+ "\u{1F4A1}": [
4691
+ '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/>',
4692
+ '<path d="M9 18h6"/>',
4693
+ '<path d="M10 22h4"/>'
4694
+ ],
4695
+ "\u{1F4B0}": [
4696
+ '<rect width="20" height="12" x="2" y="6" rx="2"/>',
4697
+ '<circle cx="12" cy="12" r="2"/>',
4698
+ '<path d="M6 12h.01M18 12h.01"/>'
4699
+ ],
4700
+ "\u{1F4CB}": [
4701
+ '<rect width="8" height="4" x="8" y="2" rx="1" ry="1"/>',
4702
+ '<path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>',
4703
+ '<path d="M12 11h4"/>',
4704
+ '<path d="M12 16h4"/>',
4705
+ '<path d="M8 11h.01"/>',
4706
+ '<path d="M8 16h.01"/>'
4707
+ ],
4708
+ "\u2705": ['<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>', '<path d="m9 11 3 3L22 4"/>'],
4709
+ "\u26A0\uFE0F": [
4710
+ '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/>',
4711
+ '<path d="M12 9v4"/>',
4712
+ '<path d="M12 17h.01"/>'
4713
+ ],
4714
+ // ── added for healthmaxxer action_plans ──────────────────────────────────
4715
+ "\u{1F6E1}\uFE0F": [
4716
+ '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>'
4717
+ ],
4718
+ "\u{1F4C8}": [
4719
+ '<polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/>',
4720
+ '<polyline points="16 7 22 7 22 13"/>'
4721
+ ],
4722
+ "\u{1F52C}": [
4723
+ '<path d="M6 18h8"/>',
4724
+ '<path d="M3 22h18"/>',
4725
+ '<path d="M14 22a7 7 0 1 0 0-14h-1"/>',
4726
+ '<path d="M9 14h2"/>',
4727
+ '<path d="M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z"/>',
4728
+ '<path d="M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3"/>'
4729
+ ],
4730
+ "\u{1F48A}": [
4731
+ '<path d="m10.5 20.5 10-10a4.95 4.95 0 1 0-7-7l-10 10a4.95 4.95 0 1 0 7 7Z"/>',
4732
+ '<path d="m8.5 8.5 7 7"/>'
4733
+ ],
4734
+ "\u{1F4C4}": [
4735
+ '<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/>',
4736
+ '<path d="M14 2v4a2 2 0 0 0 2 2h4"/>',
4737
+ '<path d="M10 9H8"/>',
4738
+ '<path d="M16 13H8"/>',
4739
+ '<path d="M16 17H8"/>'
4740
+ ],
4741
+ "\u{1F9EA}": [
4742
+ '<path d="M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2"/>',
4743
+ '<path d="M6.453 15h11.094"/>',
4744
+ '<path d="M8.5 2h7"/>'
4745
+ ],
4746
+ "\u{1F501}": [
4747
+ '<path d="m17 2 4 4-4 4"/>',
4748
+ '<path d="M3 11v-1a4 4 0 0 1 4-4h14"/>',
4749
+ '<path d="m7 22-4-4 4-4"/>',
4750
+ '<path d="M21 13v1a4 4 0 0 1-4 4H3"/>'
4751
+ ],
4752
+ "\u{1F9E0}": [
4753
+ '<path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/>',
4754
+ '<path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/>',
4755
+ '<path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/>',
4756
+ '<path d="M17.599 6.5a3 3 0 0 0 .399-1.375"/>',
4757
+ '<path d="M6.003 5.125A3 3 0 0 0 6.401 6.5"/>',
4758
+ '<path d="M3.477 10.896a4 4 0 0 1 .585-.396"/>',
4759
+ '<path d="M19.938 10.5a4 4 0 0 1 .585.396"/>',
4760
+ '<path d="M6 18a4 4 0 0 1-1.967-.516"/>',
4761
+ '<path d="M19.967 17.484A4 4 0 0 1 18 18"/>'
4762
+ ],
4763
+ "\u{1F319}": ['<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'],
4764
+ "\u{1F4E6}": [
4765
+ '<path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"/>',
4766
+ '<path d="M12 22V12"/>',
4767
+ '<path d="m3.3 7 8.7 5 8.7-5"/>',
4768
+ '<path d="m7.5 4.27 9 5.15"/>'
4769
+ ],
4770
+ "\u{1F69A}": [
4771
+ // Lucide truck
4772
+ '<path d="M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2"/>',
4773
+ '<path d="M15 18H9"/>',
4774
+ '<path d="M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14"/>',
4775
+ '<circle cx="17" cy="18" r="2"/>',
4776
+ '<circle cx="7" cy="18" r="2"/>'
4777
+ ],
4778
+ "\u{1F331}": [
4779
+ '<path d="M7 20h10"/>',
4780
+ '<path d="M10 20c5.5-2.5.8-6.4 3-10"/>',
4781
+ '<path d="M9.5 9.4c1.1.8 1.8 2.2 2.3 3.7-2 .4-3.5.4-4.8-.3-1.2-.6-2.3-1.9-3-4.2 2.8-.5 4.4 0 5.5.8z"/>',
4782
+ '<path d="M14.1 6a7 7 0 0 0-1.1 4c1.9-.1 3.3-.6 4.3-1.4 1-1 1.6-2.3 1.7-4.6-2.7.1-4 1-4.9 2z"/>'
4783
+ ],
4784
+ "\u26A1": [
4785
+ '<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>'
4786
+ ],
4787
+ "\u{1F525}": [
4788
+ // Lucide flame
4789
+ '<path d="M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"/>'
4790
+ ],
4791
+ "\u{1F333}": [
4792
+ '<path d="M12 22V8"/>',
4793
+ '<path d="m17 8-5-6-5 6"/>',
4794
+ '<path d="M12 12c-2-2-4-2-4-2 0 0 0 4 2 6 1.5 1.5 3 1 4 0"/>',
4795
+ '<path d="M12 12c2-2 4-2 4-2 0 0 0 4-2 6-1.5 1.5-3 1-4 0"/>'
4796
+ ],
4797
+ "\u{1F33F}": [
4798
+ '<path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19.2 2.96a1 1 0 0 1 1.8.5c0 6-2 11-9 16.5"/>',
4799
+ '<path d="M2 21c0-3 1.85-5.36 5.08-6"/>'
4800
+ ],
4801
+ // ── added for runtime-sdk SyntroTileCard / SyntroToastStack ──────────────
4802
+ "\u2753": [
4803
+ // HelpCircle
4804
+ '<circle cx="12" cy="12" r="10"/>',
4805
+ '<path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>',
4806
+ '<path d="M12 17h.01"/>'
4807
+ ],
4808
+ "\u{1F9ED}": [
4809
+ // Compass
4810
+ '<circle cx="12" cy="12" r="10"/>',
4811
+ '<polygon points="16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76"/>'
4812
+ ],
4813
+ "\u{1F4DD}": [
4814
+ // FileText
4815
+ '<path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>',
4816
+ '<polyline points="14 2 14 8 20 8"/>',
4817
+ '<line x1="16" y1="13" x2="8" y2="13"/>',
4818
+ '<line x1="16" y1="17" x2="8" y2="17"/>',
4819
+ '<line x1="10" y1="9" x2="8" y2="9"/>'
4820
+ ],
4821
+ "\u{1F3AF}": [
4822
+ // Layers (bullseye-shaped emoji rendered as Lucide Layers — historical)
4823
+ '<polygon points="12 2 2 7 12 12 22 7 12 2"/>',
4824
+ '<polyline points="2 17 12 22 22 17"/>',
4825
+ '<polyline points="2 12 12 17 22 12"/>'
4826
+ ],
4827
+ "\u{1F3C6}": [
4828
+ // Trophy
4829
+ '<path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"/>',
4830
+ '<path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"/>',
4831
+ '<path d="M4 22h16"/>',
4832
+ '<path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"/>',
4833
+ '<path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"/>',
4834
+ '<path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"/>'
4835
+ ],
4836
+ "\u2728": [
4837
+ // Sparkles
4838
+ '<path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1 1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/>',
4839
+ '<path d="M5 3v4"/>',
4840
+ '<path d="M19 17v4"/>',
4841
+ '<path d="M3 5h4"/>',
4842
+ '<path d="M17 19h4"/>'
4843
+ ],
4844
+ "\u{1F4AC}": [
4845
+ // MessageCircle
4846
+ '<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>'
4847
+ ],
4848
+ "\u{1F3AE}": [
4849
+ // Gamepad2
4850
+ '<line x1="6" y1="11" x2="10" y2="11"/>',
4851
+ '<line x1="8" y1="9" x2="8" y2="13"/>',
4852
+ '<line x1="15" y1="12" x2="15.01" y2="12"/>',
4853
+ '<line x1="18" y1="10" x2="18.01" y2="10"/>',
4854
+ '<path d="M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z"/>'
4855
+ ],
4856
+ "\u23F1\uFE0F": [
4857
+ // Timer
4858
+ '<line x1="10" y1="2" x2="14" y2="2"/>',
4859
+ '<line x1="12" y1="14" x2="12" y2="8"/>',
4860
+ '<circle cx="12" cy="14" r="8"/>'
4861
+ ],
4862
+ "\u{1F4D6}": [
4863
+ // BookOpen
4864
+ '<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/>',
4865
+ '<path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/>'
4866
+ ],
4867
+ "\u{1F514}": [
4868
+ // Bell
4869
+ '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/>',
4870
+ '<path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>'
4871
+ ],
4872
+ // ── common UI icons ──────────────────────────────────────────────────────
4873
+ "\u{1F393}": [
4874
+ // GraduationCap
4875
+ '<path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z"/>',
4876
+ '<path d="M22 10v6"/>',
4877
+ '<path d="M6 12.5V16a6 3 0 0 0 12 0v-3.5"/>'
4878
+ ],
4879
+ "\u23F0": [
4880
+ // AlarmClock
4881
+ '<circle cx="12" cy="13" r="8"/>',
4882
+ '<path d="M12 9v4l2 2"/>',
4883
+ '<path d="M5 3 2 6"/>',
4884
+ '<path d="m22 6-3-3"/>',
4885
+ '<path d="M6.38 18.7 4 21"/>',
4886
+ '<path d="M17.64 18.67 20 21"/>'
4887
+ ],
4888
+ "\u{1F504}": [
4889
+ // RefreshCw
4890
+ '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/>',
4891
+ '<path d="M21 3v5h-5"/>',
4892
+ '<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/>',
4893
+ '<path d="M8 16H3v5"/>'
4894
+ ],
4895
+ "\u{1F464}": [
4896
+ // User
4897
+ '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/>',
4898
+ '<circle cx="12" cy="7" r="4"/>'
4899
+ ],
4900
+ "\u{1F3E0}": [
4901
+ // House
4902
+ '<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"/>',
4903
+ '<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>'
4904
+ ],
4905
+ "\u{1F6D2}": [
4906
+ // ShoppingCart
4907
+ '<circle cx="8" cy="21" r="1"/>',
4908
+ '<circle cx="19" cy="21" r="1"/>',
4909
+ '<path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/>'
4910
+ ],
4911
+ // ── viz / chart icons (paired with adaptive-viz) ─────────────────────────
4912
+ "\u{1F4CA}": [
4913
+ // BarChart3 — pairs with 📈 (TrendingUp)
4914
+ '<path d="M3 3v18h18"/>',
4915
+ '<path d="M18 17V9"/>',
4916
+ '<path d="M13 17V5"/>',
4917
+ '<path d="M8 17v-3"/>'
4918
+ ],
4919
+ "\u{1F4C9}": [
4920
+ // TrendingDown
4921
+ '<polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/>',
4922
+ '<polyline points="16 17 22 17 22 11"/>'
4923
+ ],
4924
+ "\u{1F967}": [
4925
+ // PieChart
4926
+ '<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z"/>',
4927
+ '<path d="M21.21 15.89A10 10 0 1 1 8 2.83"/>'
4928
+ ],
4929
+ "\u{1F4B9}": [
4930
+ // Activity — line-chart-style waveform
4931
+ '<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.5.5 0 0 1-.96 0L9.24 2.18a.5.5 0 0 0-.96 0l-2.35 8.36A2 2 0 0 1 4.02 12H2"/>'
4932
+ ],
4933
+ "\u{1F321}\uFE0F": [
4934
+ // Thermometer — gauge-style indicator
4935
+ '<path d="M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z"/>'
4936
+ ]
4937
+ };
4938
+ function renderIcon(emoji, options = {}) {
4939
+ const paths = EMOJI_SVG_PATHS[emoji];
4940
+ if (!paths)
4941
+ return "";
4942
+ const size = options.size ?? 14;
4943
+ const stroke = options.color ?? "currentColor";
4944
+ return `${PREFIX} width="${size}" height="${size}" stroke="${stroke}">${paths.join("")}</svg>`;
4945
+ }
4946
+
4947
+ export {
4948
+ __commonJS,
4949
+ __toESM,
4950
+ __privateGet,
4951
+ __privateAdd,
4952
+ __privateSet,
4953
+ __privateMethod,
4954
+ resolveColorScheme,
4955
+ renderIcon,
4956
+ stripMountPlumbing,
4957
+ normalizeRoute,
4958
+ routesMatch,
4959
+ external_exports,
4960
+ AnchorIdZ,
4961
+ AuthoringFieldsZ,
4962
+ TriggerWhenZ,
4963
+ NotifyZ
4964
+ };
4965
+ /*! Bundled license information:
4966
+
4967
+ @lit/context/lib/context-request-event.js:
4968
+ @lit/context/lib/create-context.js:
4969
+ @lit/context/lib/controllers/context-consumer.js:
4970
+ @lit/context/lib/value-notifier.js:
4971
+ @lit/context/lib/controllers/context-provider.js:
4972
+ @lit/context/lib/context-root.js:
4973
+ (**
4974
+ * @license
4975
+ * Copyright 2021 Google LLC
4976
+ * SPDX-License-Identifier: BSD-3-Clause
4977
+ *)
4978
+
4979
+ @lit/context/lib/decorators/provide.js:
4980
+ (**
4981
+ * @license
4982
+ * Copyright 2017 Google LLC
4983
+ * SPDX-License-Identifier: BSD-3-Clause
4984
+ *)
4985
+
4986
+ @lit/context/lib/decorators/consume.js:
4987
+ (**
4988
+ * @license
4989
+ * Copyright 2022 Google LLC
4990
+ * SPDX-License-Identifier: BSD-3-Clause
4991
+ *)
4992
+ */
4993
+ //# sourceMappingURL=chunk-HFMNL3HQ.js.map