@animaapp/anima-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3988 @@
1
+ var fn = Object.defineProperty, hn = Object.defineProperties;
2
+ var pn = Object.getOwnPropertyDescriptors;
3
+ var It = Object.getOwnPropertySymbols;
4
+ var mn = Object.prototype.hasOwnProperty, yn = Object.prototype.propertyIsEnumerable;
5
+ var Zt = (n) => {
6
+ throw TypeError(n);
7
+ };
8
+ var Rt = (n, e, t) => e in n ? fn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, d = (n, e) => {
9
+ for (var t in e || (e = {}))
10
+ mn.call(e, t) && Rt(n, t, e[t]);
11
+ if (It)
12
+ for (var t of It(e))
13
+ yn.call(e, t) && Rt(n, t, e[t]);
14
+ return n;
15
+ }, y = (n, e) => hn(n, pn(e));
16
+ var Mt = (n, e, t) => e.has(n) || Zt("Cannot " + t);
17
+ var G = (n, e, t) => (Mt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), ot = (n, e, t) => e.has(n) ? Zt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), ct = (n, e, t, r) => (Mt(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t);
18
+ var F = (n, e, t) => new Promise((r, s) => {
19
+ var a = (c) => {
20
+ try {
21
+ o(t.next(c));
22
+ } catch (u) {
23
+ s(u);
24
+ }
25
+ }, i = (c) => {
26
+ try {
27
+ o(t.throw(c));
28
+ } catch (u) {
29
+ s(u);
30
+ }
31
+ }, o = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(a, i);
32
+ o((t = t.apply(n, e)).next());
33
+ });
34
+ class Ae extends Error {
35
+ constructor({ name: e, reason: t, status: r }) {
36
+ super(), this.name = `[Codegen Error] ${e}`, this.message = t, this.status = r;
37
+ }
38
+ }
39
+ var x;
40
+ (function(n) {
41
+ n.assertEqual = (s) => s;
42
+ function e(s) {
43
+ }
44
+ n.assertIs = e;
45
+ function t(s) {
46
+ throw new Error();
47
+ }
48
+ n.assertNever = t, n.arrayToEnum = (s) => {
49
+ const a = {};
50
+ for (const i of s)
51
+ a[i] = i;
52
+ return a;
53
+ }, n.getValidEnumValues = (s) => {
54
+ const a = n.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
55
+ for (const o of a)
56
+ i[o] = s[o];
57
+ return n.objectValues(i);
58
+ }, n.objectValues = (s) => n.objectKeys(s).map(function(a) {
59
+ return s[a];
60
+ }), n.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
61
+ const a = [];
62
+ for (const i in s)
63
+ Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
64
+ return a;
65
+ }, n.find = (s, a) => {
66
+ for (const i of s)
67
+ if (a(i))
68
+ return i;
69
+ }, n.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
70
+ function r(s, a = " | ") {
71
+ return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
72
+ }
73
+ n.joinValues = r, n.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
74
+ })(x || (x = {}));
75
+ var ht;
76
+ (function(n) {
77
+ n.mergeShapes = (e, t) => d(d({}, e), t);
78
+ })(ht || (ht = {}));
79
+ const p = x.arrayToEnum([
80
+ "string",
81
+ "nan",
82
+ "number",
83
+ "integer",
84
+ "float",
85
+ "boolean",
86
+ "date",
87
+ "bigint",
88
+ "symbol",
89
+ "function",
90
+ "undefined",
91
+ "null",
92
+ "array",
93
+ "object",
94
+ "unknown",
95
+ "promise",
96
+ "void",
97
+ "never",
98
+ "map",
99
+ "set"
100
+ ]), se = (n) => {
101
+ switch (typeof n) {
102
+ case "undefined":
103
+ return p.undefined;
104
+ case "string":
105
+ return p.string;
106
+ case "number":
107
+ return isNaN(n) ? p.nan : p.number;
108
+ case "boolean":
109
+ return p.boolean;
110
+ case "function":
111
+ return p.function;
112
+ case "bigint":
113
+ return p.bigint;
114
+ case "symbol":
115
+ return p.symbol;
116
+ case "object":
117
+ return Array.isArray(n) ? p.array : n === null ? p.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? p.promise : typeof Map != "undefined" && n instanceof Map ? p.map : typeof Set != "undefined" && n instanceof Set ? p.set : typeof Date != "undefined" && n instanceof Date ? p.date : p.object;
118
+ default:
119
+ return p.unknown;
120
+ }
121
+ }, l = x.arrayToEnum([
122
+ "invalid_type",
123
+ "invalid_literal",
124
+ "custom",
125
+ "invalid_union",
126
+ "invalid_union_discriminator",
127
+ "invalid_enum_value",
128
+ "unrecognized_keys",
129
+ "invalid_arguments",
130
+ "invalid_return_type",
131
+ "invalid_date",
132
+ "invalid_string",
133
+ "too_small",
134
+ "too_big",
135
+ "invalid_intersection_types",
136
+ "not_multiple_of",
137
+ "not_finite"
138
+ ]), gn = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
139
+ class z extends Error {
140
+ get errors() {
141
+ return this.issues;
142
+ }
143
+ constructor(e) {
144
+ super(), this.issues = [], this.addIssue = (r) => {
145
+ this.issues = [...this.issues, r];
146
+ }, this.addIssues = (r = []) => {
147
+ this.issues = [...this.issues, ...r];
148
+ };
149
+ const t = new.target.prototype;
150
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
151
+ }
152
+ format(e) {
153
+ const t = e || function(a) {
154
+ return a.message;
155
+ }, r = { _errors: [] }, s = (a) => {
156
+ for (const i of a.issues)
157
+ if (i.code === "invalid_union")
158
+ i.unionErrors.map(s);
159
+ else if (i.code === "invalid_return_type")
160
+ s(i.returnTypeError);
161
+ else if (i.code === "invalid_arguments")
162
+ s(i.argumentsError);
163
+ else if (i.path.length === 0)
164
+ r._errors.push(t(i));
165
+ else {
166
+ let o = r, c = 0;
167
+ for (; c < i.path.length; ) {
168
+ const u = i.path[c];
169
+ c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
170
+ }
171
+ }
172
+ };
173
+ return s(this), r;
174
+ }
175
+ static assert(e) {
176
+ if (!(e instanceof z))
177
+ throw new Error(`Not a ZodError: ${e}`);
178
+ }
179
+ toString() {
180
+ return this.message;
181
+ }
182
+ get message() {
183
+ return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
184
+ }
185
+ get isEmpty() {
186
+ return this.issues.length === 0;
187
+ }
188
+ flatten(e = (t) => t.message) {
189
+ const t = {}, r = [];
190
+ for (const s of this.issues)
191
+ s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : r.push(e(s));
192
+ return { formErrors: r, fieldErrors: t };
193
+ }
194
+ get formErrors() {
195
+ return this.flatten();
196
+ }
197
+ }
198
+ z.create = (n) => new z(n);
199
+ const xe = (n, e) => {
200
+ let t;
201
+ switch (n.code) {
202
+ case l.invalid_type:
203
+ n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
204
+ break;
205
+ case l.invalid_literal:
206
+ t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
207
+ break;
208
+ case l.unrecognized_keys:
209
+ t = `Unrecognized key(s) in object: ${x.joinValues(n.keys, ", ")}`;
210
+ break;
211
+ case l.invalid_union:
212
+ t = "Invalid input";
213
+ break;
214
+ case l.invalid_union_discriminator:
215
+ t = `Invalid discriminator value. Expected ${x.joinValues(n.options)}`;
216
+ break;
217
+ case l.invalid_enum_value:
218
+ t = `Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;
219
+ break;
220
+ case l.invalid_arguments:
221
+ t = "Invalid function arguments";
222
+ break;
223
+ case l.invalid_return_type:
224
+ t = "Invalid function return type";
225
+ break;
226
+ case l.invalid_date:
227
+ t = "Invalid date";
228
+ break;
229
+ case l.invalid_string:
230
+ typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : x.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
231
+ break;
232
+ case l.too_small:
233
+ n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
234
+ break;
235
+ case l.too_big:
236
+ n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
237
+ break;
238
+ case l.custom:
239
+ t = "Invalid input";
240
+ break;
241
+ case l.invalid_intersection_types:
242
+ t = "Intersection results could not be merged";
243
+ break;
244
+ case l.not_multiple_of:
245
+ t = `Number must be a multiple of ${n.multipleOf}`;
246
+ break;
247
+ case l.not_finite:
248
+ t = "Number must be finite";
249
+ break;
250
+ default:
251
+ t = e.defaultError, x.assertNever(n);
252
+ }
253
+ return { message: t };
254
+ };
255
+ let qt = xe;
256
+ function vn(n) {
257
+ qt = n;
258
+ }
259
+ function Qe() {
260
+ return qt;
261
+ }
262
+ const et = (n) => {
263
+ const { data: e, path: t, errorMaps: r, issueData: s } = n, a = [...t, ...s.path || []], i = y(d({}, s), {
264
+ path: a
265
+ });
266
+ if (s.message !== void 0)
267
+ return y(d({}, s), {
268
+ path: a,
269
+ message: s.message
270
+ });
271
+ let o = "";
272
+ const c = r.filter((u) => !!u).slice().reverse();
273
+ for (const u of c)
274
+ o = u(i, { data: e, defaultError: o }).message;
275
+ return y(d({}, s), {
276
+ path: a,
277
+ message: o
278
+ });
279
+ }, _n = [];
280
+ function f(n, e) {
281
+ const t = Qe(), r = et({
282
+ issueData: e,
283
+ data: n.data,
284
+ path: n.path,
285
+ errorMaps: [
286
+ n.common.contextualErrorMap,
287
+ // contextual error map is first priority
288
+ n.schemaErrorMap,
289
+ // then schema-bound map if available
290
+ t,
291
+ // then global override map
292
+ t === xe ? void 0 : xe
293
+ // then global default map
294
+ ].filter((s) => !!s)
295
+ });
296
+ n.common.issues.push(r);
297
+ }
298
+ class I {
299
+ constructor() {
300
+ this.value = "valid";
301
+ }
302
+ dirty() {
303
+ this.value === "valid" && (this.value = "dirty");
304
+ }
305
+ abort() {
306
+ this.value !== "aborted" && (this.value = "aborted");
307
+ }
308
+ static mergeArray(e, t) {
309
+ const r = [];
310
+ for (const s of t) {
311
+ if (s.status === "aborted")
312
+ return v;
313
+ s.status === "dirty" && e.dirty(), r.push(s.value);
314
+ }
315
+ return { status: e.value, value: r };
316
+ }
317
+ static mergeObjectAsync(e, t) {
318
+ return F(this, null, function* () {
319
+ const r = [];
320
+ for (const s of t) {
321
+ const a = yield s.key, i = yield s.value;
322
+ r.push({
323
+ key: a,
324
+ value: i
325
+ });
326
+ }
327
+ return I.mergeObjectSync(e, r);
328
+ });
329
+ }
330
+ static mergeObjectSync(e, t) {
331
+ const r = {};
332
+ for (const s of t) {
333
+ const { key: a, value: i } = s;
334
+ if (a.status === "aborted" || i.status === "aborted")
335
+ return v;
336
+ a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value != "undefined" || s.alwaysSet) && (r[a.value] = i.value);
337
+ }
338
+ return { status: e.value, value: r };
339
+ }
340
+ }
341
+ const v = Object.freeze({
342
+ status: "aborted"
343
+ }), be = (n) => ({ status: "dirty", value: n }), M = (n) => ({ status: "valid", value: n }), pt = (n) => n.status === "aborted", mt = (n) => n.status === "dirty", ye = (n) => n.status === "valid", Re = (n) => typeof Promise != "undefined" && n instanceof Promise;
344
+ function tt(n, e, t, r) {
345
+ if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
346
+ return e.get(n);
347
+ }
348
+ function Ht(n, e, t, r, s) {
349
+ if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
350
+ return e.set(n, t), t;
351
+ }
352
+ var m;
353
+ (function(n) {
354
+ n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
355
+ })(m || (m = {}));
356
+ var Oe, Ce;
357
+ class ee {
358
+ constructor(e, t, r, s) {
359
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = r, this._key = s;
360
+ }
361
+ get path() {
362
+ return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
363
+ }
364
+ }
365
+ const Pt = (n, e) => {
366
+ if (ye(e))
367
+ return { success: !0, data: e.value };
368
+ if (!n.common.issues.length)
369
+ throw new Error("Validation failed but no issues detected.");
370
+ return {
371
+ success: !1,
372
+ get error() {
373
+ if (this._error)
374
+ return this._error;
375
+ const t = new z(n.common.issues);
376
+ return this._error = t, this._error;
377
+ }
378
+ };
379
+ };
380
+ function b(n) {
381
+ if (!n)
382
+ return {};
383
+ const { errorMap: e, invalid_type_error: t, required_error: r, description: s } = n;
384
+ if (e && (t || r))
385
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
386
+ return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
387
+ var c, u;
388
+ const { message: h } = n;
389
+ return i.code === "invalid_enum_value" ? { message: h != null ? h : o.defaultError } : typeof o.data == "undefined" ? { message: (c = h != null ? h : r) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = h != null ? h : t) !== null && u !== void 0 ? u : o.defaultError };
390
+ }, description: s };
391
+ }
392
+ class w {
393
+ get description() {
394
+ return this._def.description;
395
+ }
396
+ _getType(e) {
397
+ return se(e.data);
398
+ }
399
+ _getOrReturnCtx(e, t) {
400
+ return t || {
401
+ common: e.parent.common,
402
+ data: e.data,
403
+ parsedType: se(e.data),
404
+ schemaErrorMap: this._def.errorMap,
405
+ path: e.path,
406
+ parent: e.parent
407
+ };
408
+ }
409
+ _processInputParams(e) {
410
+ return {
411
+ status: new I(),
412
+ ctx: {
413
+ common: e.parent.common,
414
+ data: e.data,
415
+ parsedType: se(e.data),
416
+ schemaErrorMap: this._def.errorMap,
417
+ path: e.path,
418
+ parent: e.parent
419
+ }
420
+ };
421
+ }
422
+ _parseSync(e) {
423
+ const t = this._parse(e);
424
+ if (Re(t))
425
+ throw new Error("Synchronous parse encountered promise.");
426
+ return t;
427
+ }
428
+ _parseAsync(e) {
429
+ const t = this._parse(e);
430
+ return Promise.resolve(t);
431
+ }
432
+ parse(e, t) {
433
+ const r = this.safeParse(e, t);
434
+ if (r.success)
435
+ return r.data;
436
+ throw r.error;
437
+ }
438
+ safeParse(e, t) {
439
+ var r;
440
+ const s = {
441
+ common: {
442
+ issues: [],
443
+ async: (r = t == null ? void 0 : t.async) !== null && r !== void 0 ? r : !1,
444
+ contextualErrorMap: t == null ? void 0 : t.errorMap
445
+ },
446
+ path: (t == null ? void 0 : t.path) || [],
447
+ schemaErrorMap: this._def.errorMap,
448
+ parent: null,
449
+ data: e,
450
+ parsedType: se(e)
451
+ }, a = this._parseSync({ data: e, path: s.path, parent: s });
452
+ return Pt(s, a);
453
+ }
454
+ "~validate"(e) {
455
+ var t, r;
456
+ const s = {
457
+ common: {
458
+ issues: [],
459
+ async: !!this["~standard"].async
460
+ },
461
+ path: [],
462
+ schemaErrorMap: this._def.errorMap,
463
+ parent: null,
464
+ data: e,
465
+ parsedType: se(e)
466
+ };
467
+ if (!this["~standard"].async)
468
+ try {
469
+ const a = this._parseSync({ data: e, path: [], parent: s });
470
+ return ye(a) ? {
471
+ value: a.value
472
+ } : {
473
+ issues: s.common.issues
474
+ };
475
+ } catch (a) {
476
+ !((r = (t = a == null ? void 0 : a.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || r === void 0) && r.includes("encountered") && (this["~standard"].async = !0), s.common = {
477
+ issues: [],
478
+ async: !0
479
+ };
480
+ }
481
+ return this._parseAsync({ data: e, path: [], parent: s }).then((a) => ye(a) ? {
482
+ value: a.value
483
+ } : {
484
+ issues: s.common.issues
485
+ });
486
+ }
487
+ parseAsync(e, t) {
488
+ return F(this, null, function* () {
489
+ const r = yield this.safeParseAsync(e, t);
490
+ if (r.success)
491
+ return r.data;
492
+ throw r.error;
493
+ });
494
+ }
495
+ safeParseAsync(e, t) {
496
+ return F(this, null, function* () {
497
+ const r = {
498
+ common: {
499
+ issues: [],
500
+ contextualErrorMap: t == null ? void 0 : t.errorMap,
501
+ async: !0
502
+ },
503
+ path: (t == null ? void 0 : t.path) || [],
504
+ schemaErrorMap: this._def.errorMap,
505
+ parent: null,
506
+ data: e,
507
+ parsedType: se(e)
508
+ }, s = this._parse({ data: e, path: r.path, parent: r }), a = yield Re(s) ? s : Promise.resolve(s);
509
+ return Pt(r, a);
510
+ });
511
+ }
512
+ refine(e, t) {
513
+ const r = (s) => typeof t == "string" || typeof t == "undefined" ? { message: t } : typeof t == "function" ? t(s) : t;
514
+ return this._refinement((s, a) => {
515
+ const i = e(s), o = () => a.addIssue(d({
516
+ code: l.custom
517
+ }, r(s)));
518
+ return typeof Promise != "undefined" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
519
+ });
520
+ }
521
+ refinement(e, t) {
522
+ return this._refinement((r, s) => e(r) ? !0 : (s.addIssue(typeof t == "function" ? t(r, s) : t), !1));
523
+ }
524
+ _refinement(e) {
525
+ return new J({
526
+ schema: this,
527
+ typeName: g.ZodEffects,
528
+ effect: { type: "refinement", refinement: e }
529
+ });
530
+ }
531
+ superRefine(e) {
532
+ return this._refinement(e);
533
+ }
534
+ constructor(e) {
535
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
536
+ version: 1,
537
+ vendor: "zod",
538
+ validate: (t) => this["~validate"](t)
539
+ };
540
+ }
541
+ optional() {
542
+ return Q.create(this, this._def);
543
+ }
544
+ nullable() {
545
+ return fe.create(this, this._def);
546
+ }
547
+ nullish() {
548
+ return this.nullable().optional();
549
+ }
550
+ array() {
551
+ return H.create(this);
552
+ }
553
+ promise() {
554
+ return Te.create(this, this._def);
555
+ }
556
+ or(e) {
557
+ return $e.create([this, e], this._def);
558
+ }
559
+ and(e) {
560
+ return Fe.create(this, e, this._def);
561
+ }
562
+ transform(e) {
563
+ return new J(y(d({}, b(this._def)), {
564
+ schema: this,
565
+ typeName: g.ZodEffects,
566
+ effect: { type: "transform", transform: e }
567
+ }));
568
+ }
569
+ default(e) {
570
+ const t = typeof e == "function" ? e : () => e;
571
+ return new Ue(y(d({}, b(this._def)), {
572
+ innerType: this,
573
+ defaultValue: t,
574
+ typeName: g.ZodDefault
575
+ }));
576
+ }
577
+ brand() {
578
+ return new At(d({
579
+ typeName: g.ZodBranded,
580
+ type: this
581
+ }, b(this._def)));
582
+ }
583
+ catch(e) {
584
+ const t = typeof e == "function" ? e : () => e;
585
+ return new Be(y(d({}, b(this._def)), {
586
+ innerType: this,
587
+ catchValue: t,
588
+ typeName: g.ZodCatch
589
+ }));
590
+ }
591
+ describe(e) {
592
+ const t = this.constructor;
593
+ return new t(y(d({}, this._def), {
594
+ description: e
595
+ }));
596
+ }
597
+ pipe(e) {
598
+ return He.create(this, e);
599
+ }
600
+ readonly() {
601
+ return We.create(this);
602
+ }
603
+ isOptional() {
604
+ return this.safeParse(void 0).success;
605
+ }
606
+ isNullable() {
607
+ return this.safeParse(null).success;
608
+ }
609
+ }
610
+ const bn = /^c[^\s-]{8,}$/i, wn = /^[0-9a-z]+$/, xn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kn = /^[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, Tn = /^[a-z0-9_-]{21}$/i, Sn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, An = /^[-+]?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)?)??$/, En = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, On = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
611
+ let dt;
612
+ const Cn = /^(?:(?: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])$/, Nn = /^(?:(?: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])$/, jn = /^(([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]))$/, In = /^(([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])$/, Rn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Zn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Jt = "((\\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])))", Mn = new RegExp(`^${Jt}$`);
613
+ function Gt(n) {
614
+ let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
615
+ return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
616
+ }
617
+ function Pn(n) {
618
+ return new RegExp(`^${Gt(n)}$`);
619
+ }
620
+ function Kt(n) {
621
+ let e = `${Jt}T${Gt(n)}`;
622
+ const t = [];
623
+ return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
624
+ }
625
+ function $n(n, e) {
626
+ return !!((e === "v4" || !e) && Cn.test(n) || (e === "v6" || !e) && jn.test(n));
627
+ }
628
+ function Fn(n, e) {
629
+ if (!Sn.test(n))
630
+ return !1;
631
+ try {
632
+ const [t] = n.split("."), r = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), s = JSON.parse(atob(r));
633
+ return !(typeof s != "object" || s === null || !s.typ || !s.alg || e && s.alg !== e);
634
+ } catch (t) {
635
+ return !1;
636
+ }
637
+ }
638
+ function Dn(n, e) {
639
+ return !!((e === "v4" || !e) && Nn.test(n) || (e === "v6" || !e) && In.test(n));
640
+ }
641
+ class q extends w {
642
+ _parse(e) {
643
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
644
+ const a = this._getOrReturnCtx(e);
645
+ return f(a, {
646
+ code: l.invalid_type,
647
+ expected: p.string,
648
+ received: a.parsedType
649
+ }), v;
650
+ }
651
+ const r = new I();
652
+ let s;
653
+ for (const a of this._def.checks)
654
+ if (a.kind === "min")
655
+ e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
656
+ code: l.too_small,
657
+ minimum: a.value,
658
+ type: "string",
659
+ inclusive: !0,
660
+ exact: !1,
661
+ message: a.message
662
+ }), r.dirty());
663
+ else if (a.kind === "max")
664
+ e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
665
+ code: l.too_big,
666
+ maximum: a.value,
667
+ type: "string",
668
+ inclusive: !0,
669
+ exact: !1,
670
+ message: a.message
671
+ }), r.dirty());
672
+ else if (a.kind === "length") {
673
+ const i = e.data.length > a.value, o = e.data.length < a.value;
674
+ (i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
675
+ code: l.too_big,
676
+ maximum: a.value,
677
+ type: "string",
678
+ inclusive: !0,
679
+ exact: !0,
680
+ message: a.message
681
+ }) : o && f(s, {
682
+ code: l.too_small,
683
+ minimum: a.value,
684
+ type: "string",
685
+ inclusive: !0,
686
+ exact: !0,
687
+ message: a.message
688
+ }), r.dirty());
689
+ } else if (a.kind === "email")
690
+ En.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
691
+ validation: "email",
692
+ code: l.invalid_string,
693
+ message: a.message
694
+ }), r.dirty());
695
+ else if (a.kind === "emoji")
696
+ dt || (dt = new RegExp(On, "u")), dt.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
697
+ validation: "emoji",
698
+ code: l.invalid_string,
699
+ message: a.message
700
+ }), r.dirty());
701
+ else if (a.kind === "uuid")
702
+ kn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
703
+ validation: "uuid",
704
+ code: l.invalid_string,
705
+ message: a.message
706
+ }), r.dirty());
707
+ else if (a.kind === "nanoid")
708
+ Tn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
709
+ validation: "nanoid",
710
+ code: l.invalid_string,
711
+ message: a.message
712
+ }), r.dirty());
713
+ else if (a.kind === "cuid")
714
+ bn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
715
+ validation: "cuid",
716
+ code: l.invalid_string,
717
+ message: a.message
718
+ }), r.dirty());
719
+ else if (a.kind === "cuid2")
720
+ wn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
721
+ validation: "cuid2",
722
+ code: l.invalid_string,
723
+ message: a.message
724
+ }), r.dirty());
725
+ else if (a.kind === "ulid")
726
+ xn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
727
+ validation: "ulid",
728
+ code: l.invalid_string,
729
+ message: a.message
730
+ }), r.dirty());
731
+ else if (a.kind === "url")
732
+ try {
733
+ new URL(e.data);
734
+ } catch (i) {
735
+ s = this._getOrReturnCtx(e, s), f(s, {
736
+ validation: "url",
737
+ code: l.invalid_string,
738
+ message: a.message
739
+ }), r.dirty();
740
+ }
741
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
742
+ validation: "regex",
743
+ code: l.invalid_string,
744
+ message: a.message
745
+ }), r.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
746
+ code: l.invalid_string,
747
+ validation: { includes: a.value, position: a.position },
748
+ message: a.message
749
+ }), r.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
750
+ code: l.invalid_string,
751
+ validation: { startsWith: a.value },
752
+ message: a.message
753
+ }), r.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
754
+ code: l.invalid_string,
755
+ validation: { endsWith: a.value },
756
+ message: a.message
757
+ }), r.dirty()) : a.kind === "datetime" ? Kt(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
758
+ code: l.invalid_string,
759
+ validation: "datetime",
760
+ message: a.message
761
+ }), r.dirty()) : a.kind === "date" ? Mn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
762
+ code: l.invalid_string,
763
+ validation: "date",
764
+ message: a.message
765
+ }), r.dirty()) : a.kind === "time" ? Pn(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
766
+ code: l.invalid_string,
767
+ validation: "time",
768
+ message: a.message
769
+ }), r.dirty()) : a.kind === "duration" ? An.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
770
+ validation: "duration",
771
+ code: l.invalid_string,
772
+ message: a.message
773
+ }), r.dirty()) : a.kind === "ip" ? $n(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
774
+ validation: "ip",
775
+ code: l.invalid_string,
776
+ message: a.message
777
+ }), r.dirty()) : a.kind === "jwt" ? Fn(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
778
+ validation: "jwt",
779
+ code: l.invalid_string,
780
+ message: a.message
781
+ }), r.dirty()) : a.kind === "cidr" ? Dn(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
782
+ validation: "cidr",
783
+ code: l.invalid_string,
784
+ message: a.message
785
+ }), r.dirty()) : a.kind === "base64" ? Rn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
786
+ validation: "base64",
787
+ code: l.invalid_string,
788
+ message: a.message
789
+ }), r.dirty()) : a.kind === "base64url" ? Zn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
790
+ validation: "base64url",
791
+ code: l.invalid_string,
792
+ message: a.message
793
+ }), r.dirty()) : x.assertNever(a);
794
+ return { status: r.value, value: e.data };
795
+ }
796
+ _regex(e, t, r) {
797
+ return this.refinement((s) => e.test(s), d({
798
+ validation: t,
799
+ code: l.invalid_string
800
+ }, m.errToObj(r)));
801
+ }
802
+ _addCheck(e) {
803
+ return new q(y(d({}, this._def), {
804
+ checks: [...this._def.checks, e]
805
+ }));
806
+ }
807
+ email(e) {
808
+ return this._addCheck(d({ kind: "email" }, m.errToObj(e)));
809
+ }
810
+ url(e) {
811
+ return this._addCheck(d({ kind: "url" }, m.errToObj(e)));
812
+ }
813
+ emoji(e) {
814
+ return this._addCheck(d({ kind: "emoji" }, m.errToObj(e)));
815
+ }
816
+ uuid(e) {
817
+ return this._addCheck(d({ kind: "uuid" }, m.errToObj(e)));
818
+ }
819
+ nanoid(e) {
820
+ return this._addCheck(d({ kind: "nanoid" }, m.errToObj(e)));
821
+ }
822
+ cuid(e) {
823
+ return this._addCheck(d({ kind: "cuid" }, m.errToObj(e)));
824
+ }
825
+ cuid2(e) {
826
+ return this._addCheck(d({ kind: "cuid2" }, m.errToObj(e)));
827
+ }
828
+ ulid(e) {
829
+ return this._addCheck(d({ kind: "ulid" }, m.errToObj(e)));
830
+ }
831
+ base64(e) {
832
+ return this._addCheck(d({ kind: "base64" }, m.errToObj(e)));
833
+ }
834
+ base64url(e) {
835
+ return this._addCheck(d({
836
+ kind: "base64url"
837
+ }, m.errToObj(e)));
838
+ }
839
+ jwt(e) {
840
+ return this._addCheck(d({ kind: "jwt" }, m.errToObj(e)));
841
+ }
842
+ ip(e) {
843
+ return this._addCheck(d({ kind: "ip" }, m.errToObj(e)));
844
+ }
845
+ cidr(e) {
846
+ return this._addCheck(d({ kind: "cidr" }, m.errToObj(e)));
847
+ }
848
+ datetime(e) {
849
+ var t, r;
850
+ return typeof e == "string" ? this._addCheck({
851
+ kind: "datetime",
852
+ precision: null,
853
+ offset: !1,
854
+ local: !1,
855
+ message: e
856
+ }) : this._addCheck(d({
857
+ kind: "datetime",
858
+ precision: typeof (e == null ? void 0 : e.precision) == "undefined" ? null : e == null ? void 0 : e.precision,
859
+ offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
860
+ local: (r = e == null ? void 0 : e.local) !== null && r !== void 0 ? r : !1
861
+ }, m.errToObj(e == null ? void 0 : e.message)));
862
+ }
863
+ date(e) {
864
+ return this._addCheck({ kind: "date", message: e });
865
+ }
866
+ time(e) {
867
+ return typeof e == "string" ? this._addCheck({
868
+ kind: "time",
869
+ precision: null,
870
+ message: e
871
+ }) : this._addCheck(d({
872
+ kind: "time",
873
+ precision: typeof (e == null ? void 0 : e.precision) == "undefined" ? null : e == null ? void 0 : e.precision
874
+ }, m.errToObj(e == null ? void 0 : e.message)));
875
+ }
876
+ duration(e) {
877
+ return this._addCheck(d({ kind: "duration" }, m.errToObj(e)));
878
+ }
879
+ regex(e, t) {
880
+ return this._addCheck(d({
881
+ kind: "regex",
882
+ regex: e
883
+ }, m.errToObj(t)));
884
+ }
885
+ includes(e, t) {
886
+ return this._addCheck(d({
887
+ kind: "includes",
888
+ value: e,
889
+ position: t == null ? void 0 : t.position
890
+ }, m.errToObj(t == null ? void 0 : t.message)));
891
+ }
892
+ startsWith(e, t) {
893
+ return this._addCheck(d({
894
+ kind: "startsWith",
895
+ value: e
896
+ }, m.errToObj(t)));
897
+ }
898
+ endsWith(e, t) {
899
+ return this._addCheck(d({
900
+ kind: "endsWith",
901
+ value: e
902
+ }, m.errToObj(t)));
903
+ }
904
+ min(e, t) {
905
+ return this._addCheck(d({
906
+ kind: "min",
907
+ value: e
908
+ }, m.errToObj(t)));
909
+ }
910
+ max(e, t) {
911
+ return this._addCheck(d({
912
+ kind: "max",
913
+ value: e
914
+ }, m.errToObj(t)));
915
+ }
916
+ length(e, t) {
917
+ return this._addCheck(d({
918
+ kind: "length",
919
+ value: e
920
+ }, m.errToObj(t)));
921
+ }
922
+ /**
923
+ * Equivalent to `.min(1)`
924
+ */
925
+ nonempty(e) {
926
+ return this.min(1, m.errToObj(e));
927
+ }
928
+ trim() {
929
+ return new q(y(d({}, this._def), {
930
+ checks: [...this._def.checks, { kind: "trim" }]
931
+ }));
932
+ }
933
+ toLowerCase() {
934
+ return new q(y(d({}, this._def), {
935
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
936
+ }));
937
+ }
938
+ toUpperCase() {
939
+ return new q(y(d({}, this._def), {
940
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
941
+ }));
942
+ }
943
+ get isDatetime() {
944
+ return !!this._def.checks.find((e) => e.kind === "datetime");
945
+ }
946
+ get isDate() {
947
+ return !!this._def.checks.find((e) => e.kind === "date");
948
+ }
949
+ get isTime() {
950
+ return !!this._def.checks.find((e) => e.kind === "time");
951
+ }
952
+ get isDuration() {
953
+ return !!this._def.checks.find((e) => e.kind === "duration");
954
+ }
955
+ get isEmail() {
956
+ return !!this._def.checks.find((e) => e.kind === "email");
957
+ }
958
+ get isURL() {
959
+ return !!this._def.checks.find((e) => e.kind === "url");
960
+ }
961
+ get isEmoji() {
962
+ return !!this._def.checks.find((e) => e.kind === "emoji");
963
+ }
964
+ get isUUID() {
965
+ return !!this._def.checks.find((e) => e.kind === "uuid");
966
+ }
967
+ get isNANOID() {
968
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
969
+ }
970
+ get isCUID() {
971
+ return !!this._def.checks.find((e) => e.kind === "cuid");
972
+ }
973
+ get isCUID2() {
974
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
975
+ }
976
+ get isULID() {
977
+ return !!this._def.checks.find((e) => e.kind === "ulid");
978
+ }
979
+ get isIP() {
980
+ return !!this._def.checks.find((e) => e.kind === "ip");
981
+ }
982
+ get isCIDR() {
983
+ return !!this._def.checks.find((e) => e.kind === "cidr");
984
+ }
985
+ get isBase64() {
986
+ return !!this._def.checks.find((e) => e.kind === "base64");
987
+ }
988
+ get isBase64url() {
989
+ return !!this._def.checks.find((e) => e.kind === "base64url");
990
+ }
991
+ get minLength() {
992
+ let e = null;
993
+ for (const t of this._def.checks)
994
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
995
+ return e;
996
+ }
997
+ get maxLength() {
998
+ let e = null;
999
+ for (const t of this._def.checks)
1000
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1001
+ return e;
1002
+ }
1003
+ }
1004
+ q.create = (n) => {
1005
+ var e;
1006
+ return new q(d({
1007
+ checks: [],
1008
+ typeName: g.ZodString,
1009
+ coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1
1010
+ }, b(n)));
1011
+ };
1012
+ function Ln(n, e) {
1013
+ const t = (n.toString().split(".")[1] || "").length, r = (e.toString().split(".")[1] || "").length, s = t > r ? t : r, a = parseInt(n.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
1014
+ return a % i / Math.pow(10, s);
1015
+ }
1016
+ class de extends w {
1017
+ constructor() {
1018
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1019
+ }
1020
+ _parse(e) {
1021
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
1022
+ const a = this._getOrReturnCtx(e);
1023
+ return f(a, {
1024
+ code: l.invalid_type,
1025
+ expected: p.number,
1026
+ received: a.parsedType
1027
+ }), v;
1028
+ }
1029
+ let r;
1030
+ const s = new I();
1031
+ for (const a of this._def.checks)
1032
+ a.kind === "int" ? x.isInteger(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1033
+ code: l.invalid_type,
1034
+ expected: "integer",
1035
+ received: "float",
1036
+ message: a.message
1037
+ }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1038
+ code: l.too_small,
1039
+ minimum: a.value,
1040
+ type: "number",
1041
+ inclusive: a.inclusive,
1042
+ exact: !1,
1043
+ message: a.message
1044
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1045
+ code: l.too_big,
1046
+ maximum: a.value,
1047
+ type: "number",
1048
+ inclusive: a.inclusive,
1049
+ exact: !1,
1050
+ message: a.message
1051
+ }), s.dirty()) : a.kind === "multipleOf" ? Ln(e.data, a.value) !== 0 && (r = this._getOrReturnCtx(e, r), f(r, {
1052
+ code: l.not_multiple_of,
1053
+ multipleOf: a.value,
1054
+ message: a.message
1055
+ }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (r = this._getOrReturnCtx(e, r), f(r, {
1056
+ code: l.not_finite,
1057
+ message: a.message
1058
+ }), s.dirty()) : x.assertNever(a);
1059
+ return { status: s.value, value: e.data };
1060
+ }
1061
+ gte(e, t) {
1062
+ return this.setLimit("min", e, !0, m.toString(t));
1063
+ }
1064
+ gt(e, t) {
1065
+ return this.setLimit("min", e, !1, m.toString(t));
1066
+ }
1067
+ lte(e, t) {
1068
+ return this.setLimit("max", e, !0, m.toString(t));
1069
+ }
1070
+ lt(e, t) {
1071
+ return this.setLimit("max", e, !1, m.toString(t));
1072
+ }
1073
+ setLimit(e, t, r, s) {
1074
+ return new de(y(d({}, this._def), {
1075
+ checks: [
1076
+ ...this._def.checks,
1077
+ {
1078
+ kind: e,
1079
+ value: t,
1080
+ inclusive: r,
1081
+ message: m.toString(s)
1082
+ }
1083
+ ]
1084
+ }));
1085
+ }
1086
+ _addCheck(e) {
1087
+ return new de(y(d({}, this._def), {
1088
+ checks: [...this._def.checks, e]
1089
+ }));
1090
+ }
1091
+ int(e) {
1092
+ return this._addCheck({
1093
+ kind: "int",
1094
+ message: m.toString(e)
1095
+ });
1096
+ }
1097
+ positive(e) {
1098
+ return this._addCheck({
1099
+ kind: "min",
1100
+ value: 0,
1101
+ inclusive: !1,
1102
+ message: m.toString(e)
1103
+ });
1104
+ }
1105
+ negative(e) {
1106
+ return this._addCheck({
1107
+ kind: "max",
1108
+ value: 0,
1109
+ inclusive: !1,
1110
+ message: m.toString(e)
1111
+ });
1112
+ }
1113
+ nonpositive(e) {
1114
+ return this._addCheck({
1115
+ kind: "max",
1116
+ value: 0,
1117
+ inclusive: !0,
1118
+ message: m.toString(e)
1119
+ });
1120
+ }
1121
+ nonnegative(e) {
1122
+ return this._addCheck({
1123
+ kind: "min",
1124
+ value: 0,
1125
+ inclusive: !0,
1126
+ message: m.toString(e)
1127
+ });
1128
+ }
1129
+ multipleOf(e, t) {
1130
+ return this._addCheck({
1131
+ kind: "multipleOf",
1132
+ value: e,
1133
+ message: m.toString(t)
1134
+ });
1135
+ }
1136
+ finite(e) {
1137
+ return this._addCheck({
1138
+ kind: "finite",
1139
+ message: m.toString(e)
1140
+ });
1141
+ }
1142
+ safe(e) {
1143
+ return this._addCheck({
1144
+ kind: "min",
1145
+ inclusive: !0,
1146
+ value: Number.MIN_SAFE_INTEGER,
1147
+ message: m.toString(e)
1148
+ })._addCheck({
1149
+ kind: "max",
1150
+ inclusive: !0,
1151
+ value: Number.MAX_SAFE_INTEGER,
1152
+ message: m.toString(e)
1153
+ });
1154
+ }
1155
+ get minValue() {
1156
+ let e = null;
1157
+ for (const t of this._def.checks)
1158
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1159
+ return e;
1160
+ }
1161
+ get maxValue() {
1162
+ let e = null;
1163
+ for (const t of this._def.checks)
1164
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1165
+ return e;
1166
+ }
1167
+ get isInt() {
1168
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1169
+ }
1170
+ get isFinite() {
1171
+ let e = null, t = null;
1172
+ for (const r of this._def.checks) {
1173
+ if (r.kind === "finite" || r.kind === "int" || r.kind === "multipleOf")
1174
+ return !0;
1175
+ r.kind === "min" ? (t === null || r.value > t) && (t = r.value) : r.kind === "max" && (e === null || r.value < e) && (e = r.value);
1176
+ }
1177
+ return Number.isFinite(t) && Number.isFinite(e);
1178
+ }
1179
+ }
1180
+ de.create = (n) => new de(d({
1181
+ checks: [],
1182
+ typeName: g.ZodNumber,
1183
+ coerce: (n == null ? void 0 : n.coerce) || !1
1184
+ }, b(n)));
1185
+ class ue extends w {
1186
+ constructor() {
1187
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1188
+ }
1189
+ _parse(e) {
1190
+ if (this._def.coerce)
1191
+ try {
1192
+ e.data = BigInt(e.data);
1193
+ } catch (a) {
1194
+ return this._getInvalidInput(e);
1195
+ }
1196
+ if (this._getType(e) !== p.bigint)
1197
+ return this._getInvalidInput(e);
1198
+ let r;
1199
+ const s = new I();
1200
+ for (const a of this._def.checks)
1201
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1202
+ code: l.too_small,
1203
+ type: "bigint",
1204
+ minimum: a.value,
1205
+ inclusive: a.inclusive,
1206
+ message: a.message
1207
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (r = this._getOrReturnCtx(e, r), f(r, {
1208
+ code: l.too_big,
1209
+ type: "bigint",
1210
+ maximum: a.value,
1211
+ inclusive: a.inclusive,
1212
+ message: a.message
1213
+ }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (r = this._getOrReturnCtx(e, r), f(r, {
1214
+ code: l.not_multiple_of,
1215
+ multipleOf: a.value,
1216
+ message: a.message
1217
+ }), s.dirty()) : x.assertNever(a);
1218
+ return { status: s.value, value: e.data };
1219
+ }
1220
+ _getInvalidInput(e) {
1221
+ const t = this._getOrReturnCtx(e);
1222
+ return f(t, {
1223
+ code: l.invalid_type,
1224
+ expected: p.bigint,
1225
+ received: t.parsedType
1226
+ }), v;
1227
+ }
1228
+ gte(e, t) {
1229
+ return this.setLimit("min", e, !0, m.toString(t));
1230
+ }
1231
+ gt(e, t) {
1232
+ return this.setLimit("min", e, !1, m.toString(t));
1233
+ }
1234
+ lte(e, t) {
1235
+ return this.setLimit("max", e, !0, m.toString(t));
1236
+ }
1237
+ lt(e, t) {
1238
+ return this.setLimit("max", e, !1, m.toString(t));
1239
+ }
1240
+ setLimit(e, t, r, s) {
1241
+ return new ue(y(d({}, this._def), {
1242
+ checks: [
1243
+ ...this._def.checks,
1244
+ {
1245
+ kind: e,
1246
+ value: t,
1247
+ inclusive: r,
1248
+ message: m.toString(s)
1249
+ }
1250
+ ]
1251
+ }));
1252
+ }
1253
+ _addCheck(e) {
1254
+ return new ue(y(d({}, this._def), {
1255
+ checks: [...this._def.checks, e]
1256
+ }));
1257
+ }
1258
+ positive(e) {
1259
+ return this._addCheck({
1260
+ kind: "min",
1261
+ value: BigInt(0),
1262
+ inclusive: !1,
1263
+ message: m.toString(e)
1264
+ });
1265
+ }
1266
+ negative(e) {
1267
+ return this._addCheck({
1268
+ kind: "max",
1269
+ value: BigInt(0),
1270
+ inclusive: !1,
1271
+ message: m.toString(e)
1272
+ });
1273
+ }
1274
+ nonpositive(e) {
1275
+ return this._addCheck({
1276
+ kind: "max",
1277
+ value: BigInt(0),
1278
+ inclusive: !0,
1279
+ message: m.toString(e)
1280
+ });
1281
+ }
1282
+ nonnegative(e) {
1283
+ return this._addCheck({
1284
+ kind: "min",
1285
+ value: BigInt(0),
1286
+ inclusive: !0,
1287
+ message: m.toString(e)
1288
+ });
1289
+ }
1290
+ multipleOf(e, t) {
1291
+ return this._addCheck({
1292
+ kind: "multipleOf",
1293
+ value: e,
1294
+ message: m.toString(t)
1295
+ });
1296
+ }
1297
+ get minValue() {
1298
+ let e = null;
1299
+ for (const t of this._def.checks)
1300
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1301
+ return e;
1302
+ }
1303
+ get maxValue() {
1304
+ let e = null;
1305
+ for (const t of this._def.checks)
1306
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1307
+ return e;
1308
+ }
1309
+ }
1310
+ ue.create = (n) => {
1311
+ var e;
1312
+ return new ue(d({
1313
+ checks: [],
1314
+ typeName: g.ZodBigInt,
1315
+ coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1
1316
+ }, b(n)));
1317
+ };
1318
+ class Ze extends w {
1319
+ _parse(e) {
1320
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
1321
+ const r = this._getOrReturnCtx(e);
1322
+ return f(r, {
1323
+ code: l.invalid_type,
1324
+ expected: p.boolean,
1325
+ received: r.parsedType
1326
+ }), v;
1327
+ }
1328
+ return M(e.data);
1329
+ }
1330
+ }
1331
+ Ze.create = (n) => new Ze(d({
1332
+ typeName: g.ZodBoolean,
1333
+ coerce: (n == null ? void 0 : n.coerce) || !1
1334
+ }, b(n)));
1335
+ class ge extends w {
1336
+ _parse(e) {
1337
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
1338
+ const a = this._getOrReturnCtx(e);
1339
+ return f(a, {
1340
+ code: l.invalid_type,
1341
+ expected: p.date,
1342
+ received: a.parsedType
1343
+ }), v;
1344
+ }
1345
+ if (isNaN(e.data.getTime())) {
1346
+ const a = this._getOrReturnCtx(e);
1347
+ return f(a, {
1348
+ code: l.invalid_date
1349
+ }), v;
1350
+ }
1351
+ const r = new I();
1352
+ let s;
1353
+ for (const a of this._def.checks)
1354
+ a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
1355
+ code: l.too_small,
1356
+ message: a.message,
1357
+ inclusive: !0,
1358
+ exact: !1,
1359
+ minimum: a.value,
1360
+ type: "date"
1361
+ }), r.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
1362
+ code: l.too_big,
1363
+ message: a.message,
1364
+ inclusive: !0,
1365
+ exact: !1,
1366
+ maximum: a.value,
1367
+ type: "date"
1368
+ }), r.dirty()) : x.assertNever(a);
1369
+ return {
1370
+ status: r.value,
1371
+ value: new Date(e.data.getTime())
1372
+ };
1373
+ }
1374
+ _addCheck(e) {
1375
+ return new ge(y(d({}, this._def), {
1376
+ checks: [...this._def.checks, e]
1377
+ }));
1378
+ }
1379
+ min(e, t) {
1380
+ return this._addCheck({
1381
+ kind: "min",
1382
+ value: e.getTime(),
1383
+ message: m.toString(t)
1384
+ });
1385
+ }
1386
+ max(e, t) {
1387
+ return this._addCheck({
1388
+ kind: "max",
1389
+ value: e.getTime(),
1390
+ message: m.toString(t)
1391
+ });
1392
+ }
1393
+ get minDate() {
1394
+ let e = null;
1395
+ for (const t of this._def.checks)
1396
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1397
+ return e != null ? new Date(e) : null;
1398
+ }
1399
+ get maxDate() {
1400
+ let e = null;
1401
+ for (const t of this._def.checks)
1402
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1403
+ return e != null ? new Date(e) : null;
1404
+ }
1405
+ }
1406
+ ge.create = (n) => new ge(d({
1407
+ checks: [],
1408
+ coerce: (n == null ? void 0 : n.coerce) || !1,
1409
+ typeName: g.ZodDate
1410
+ }, b(n)));
1411
+ class nt extends w {
1412
+ _parse(e) {
1413
+ if (this._getType(e) !== p.symbol) {
1414
+ const r = this._getOrReturnCtx(e);
1415
+ return f(r, {
1416
+ code: l.invalid_type,
1417
+ expected: p.symbol,
1418
+ received: r.parsedType
1419
+ }), v;
1420
+ }
1421
+ return M(e.data);
1422
+ }
1423
+ }
1424
+ nt.create = (n) => new nt(d({
1425
+ typeName: g.ZodSymbol
1426
+ }, b(n)));
1427
+ class Me extends w {
1428
+ _parse(e) {
1429
+ if (this._getType(e) !== p.undefined) {
1430
+ const r = this._getOrReturnCtx(e);
1431
+ return f(r, {
1432
+ code: l.invalid_type,
1433
+ expected: p.undefined,
1434
+ received: r.parsedType
1435
+ }), v;
1436
+ }
1437
+ return M(e.data);
1438
+ }
1439
+ }
1440
+ Me.create = (n) => new Me(d({
1441
+ typeName: g.ZodUndefined
1442
+ }, b(n)));
1443
+ class Pe extends w {
1444
+ _parse(e) {
1445
+ if (this._getType(e) !== p.null) {
1446
+ const r = this._getOrReturnCtx(e);
1447
+ return f(r, {
1448
+ code: l.invalid_type,
1449
+ expected: p.null,
1450
+ received: r.parsedType
1451
+ }), v;
1452
+ }
1453
+ return M(e.data);
1454
+ }
1455
+ }
1456
+ Pe.create = (n) => new Pe(d({
1457
+ typeName: g.ZodNull
1458
+ }, b(n)));
1459
+ class ke extends w {
1460
+ constructor() {
1461
+ super(...arguments), this._any = !0;
1462
+ }
1463
+ _parse(e) {
1464
+ return M(e.data);
1465
+ }
1466
+ }
1467
+ ke.create = (n) => new ke(d({
1468
+ typeName: g.ZodAny
1469
+ }, b(n)));
1470
+ class me extends w {
1471
+ constructor() {
1472
+ super(...arguments), this._unknown = !0;
1473
+ }
1474
+ _parse(e) {
1475
+ return M(e.data);
1476
+ }
1477
+ }
1478
+ me.create = (n) => new me(d({
1479
+ typeName: g.ZodUnknown
1480
+ }, b(n)));
1481
+ class ae extends w {
1482
+ _parse(e) {
1483
+ const t = this._getOrReturnCtx(e);
1484
+ return f(t, {
1485
+ code: l.invalid_type,
1486
+ expected: p.never,
1487
+ received: t.parsedType
1488
+ }), v;
1489
+ }
1490
+ }
1491
+ ae.create = (n) => new ae(d({
1492
+ typeName: g.ZodNever
1493
+ }, b(n)));
1494
+ class rt extends w {
1495
+ _parse(e) {
1496
+ if (this._getType(e) !== p.undefined) {
1497
+ const r = this._getOrReturnCtx(e);
1498
+ return f(r, {
1499
+ code: l.invalid_type,
1500
+ expected: p.void,
1501
+ received: r.parsedType
1502
+ }), v;
1503
+ }
1504
+ return M(e.data);
1505
+ }
1506
+ }
1507
+ rt.create = (n) => new rt(d({
1508
+ typeName: g.ZodVoid
1509
+ }, b(n)));
1510
+ class H extends w {
1511
+ _parse(e) {
1512
+ const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
1513
+ if (t.parsedType !== p.array)
1514
+ return f(t, {
1515
+ code: l.invalid_type,
1516
+ expected: p.array,
1517
+ received: t.parsedType
1518
+ }), v;
1519
+ if (s.exactLength !== null) {
1520
+ const i = t.data.length > s.exactLength.value, o = t.data.length < s.exactLength.value;
1521
+ (i || o) && (f(t, {
1522
+ code: i ? l.too_big : l.too_small,
1523
+ minimum: o ? s.exactLength.value : void 0,
1524
+ maximum: i ? s.exactLength.value : void 0,
1525
+ type: "array",
1526
+ inclusive: !0,
1527
+ exact: !0,
1528
+ message: s.exactLength.message
1529
+ }), r.dirty());
1530
+ }
1531
+ if (s.minLength !== null && t.data.length < s.minLength.value && (f(t, {
1532
+ code: l.too_small,
1533
+ minimum: s.minLength.value,
1534
+ type: "array",
1535
+ inclusive: !0,
1536
+ exact: !1,
1537
+ message: s.minLength.message
1538
+ }), r.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (f(t, {
1539
+ code: l.too_big,
1540
+ maximum: s.maxLength.value,
1541
+ type: "array",
1542
+ inclusive: !0,
1543
+ exact: !1,
1544
+ message: s.maxLength.message
1545
+ }), r.dirty()), t.common.async)
1546
+ return Promise.all([...t.data].map((i, o) => s.type._parseAsync(new ee(t, i, t.path, o)))).then((i) => I.mergeArray(r, i));
1547
+ const a = [...t.data].map((i, o) => s.type._parseSync(new ee(t, i, t.path, o)));
1548
+ return I.mergeArray(r, a);
1549
+ }
1550
+ get element() {
1551
+ return this._def.type;
1552
+ }
1553
+ min(e, t) {
1554
+ return new H(y(d({}, this._def), {
1555
+ minLength: { value: e, message: m.toString(t) }
1556
+ }));
1557
+ }
1558
+ max(e, t) {
1559
+ return new H(y(d({}, this._def), {
1560
+ maxLength: { value: e, message: m.toString(t) }
1561
+ }));
1562
+ }
1563
+ length(e, t) {
1564
+ return new H(y(d({}, this._def), {
1565
+ exactLength: { value: e, message: m.toString(t) }
1566
+ }));
1567
+ }
1568
+ nonempty(e) {
1569
+ return this.min(1, e);
1570
+ }
1571
+ }
1572
+ H.create = (n, e) => new H(d({
1573
+ type: n,
1574
+ minLength: null,
1575
+ maxLength: null,
1576
+ exactLength: null,
1577
+ typeName: g.ZodArray
1578
+ }, b(e)));
1579
+ function _e(n) {
1580
+ if (n instanceof S) {
1581
+ const e = {};
1582
+ for (const t in n.shape) {
1583
+ const r = n.shape[t];
1584
+ e[t] = Q.create(_e(r));
1585
+ }
1586
+ return new S(y(d({}, n._def), {
1587
+ shape: () => e
1588
+ }));
1589
+ } else return n instanceof H ? new H(y(d({}, n._def), {
1590
+ type: _e(n.element)
1591
+ })) : n instanceof Q ? Q.create(_e(n.unwrap())) : n instanceof fe ? fe.create(_e(n.unwrap())) : n instanceof te ? te.create(n.items.map((e) => _e(e))) : n;
1592
+ }
1593
+ class S extends w {
1594
+ constructor() {
1595
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1596
+ }
1597
+ _getCached() {
1598
+ if (this._cached !== null)
1599
+ return this._cached;
1600
+ const e = this._def.shape(), t = x.objectKeys(e);
1601
+ return this._cached = { shape: e, keys: t };
1602
+ }
1603
+ _parse(e) {
1604
+ if (this._getType(e) !== p.object) {
1605
+ const u = this._getOrReturnCtx(e);
1606
+ return f(u, {
1607
+ code: l.invalid_type,
1608
+ expected: p.object,
1609
+ received: u.parsedType
1610
+ }), v;
1611
+ }
1612
+ const { status: r, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
1613
+ if (!(this._def.catchall instanceof ae && this._def.unknownKeys === "strip"))
1614
+ for (const u in s.data)
1615
+ i.includes(u) || o.push(u);
1616
+ const c = [];
1617
+ for (const u of i) {
1618
+ const h = a[u], _ = s.data[u];
1619
+ c.push({
1620
+ key: { status: "valid", value: u },
1621
+ value: h._parse(new ee(s, _, s.path, u)),
1622
+ alwaysSet: u in s.data
1623
+ });
1624
+ }
1625
+ if (this._def.catchall instanceof ae) {
1626
+ const u = this._def.unknownKeys;
1627
+ if (u === "passthrough")
1628
+ for (const h of o)
1629
+ c.push({
1630
+ key: { status: "valid", value: h },
1631
+ value: { status: "valid", value: s.data[h] }
1632
+ });
1633
+ else if (u === "strict")
1634
+ o.length > 0 && (f(s, {
1635
+ code: l.unrecognized_keys,
1636
+ keys: o
1637
+ }), r.dirty());
1638
+ else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1639
+ } else {
1640
+ const u = this._def.catchall;
1641
+ for (const h of o) {
1642
+ const _ = s.data[h];
1643
+ c.push({
1644
+ key: { status: "valid", value: h },
1645
+ value: u._parse(
1646
+ new ee(s, _, s.path, h)
1647
+ //, ctx.child(key), value, getParsedType(value)
1648
+ ),
1649
+ alwaysSet: h in s.data
1650
+ });
1651
+ }
1652
+ }
1653
+ return s.common.async ? Promise.resolve().then(() => F(this, null, function* () {
1654
+ const u = [];
1655
+ for (const h of c) {
1656
+ const _ = yield h.key, C = yield h.value;
1657
+ u.push({
1658
+ key: _,
1659
+ value: C,
1660
+ alwaysSet: h.alwaysSet
1661
+ });
1662
+ }
1663
+ return u;
1664
+ })).then((u) => I.mergeObjectSync(r, u)) : I.mergeObjectSync(r, c);
1665
+ }
1666
+ get shape() {
1667
+ return this._def.shape();
1668
+ }
1669
+ strict(e) {
1670
+ return m.errToObj, new S(d(y(d({}, this._def), {
1671
+ unknownKeys: "strict"
1672
+ }), e !== void 0 ? {
1673
+ errorMap: (t, r) => {
1674
+ var s, a, i, o;
1675
+ const c = (i = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, r).message) !== null && i !== void 0 ? i : r.defaultError;
1676
+ return t.code === "unrecognized_keys" ? {
1677
+ message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o : c
1678
+ } : {
1679
+ message: c
1680
+ };
1681
+ }
1682
+ } : {}));
1683
+ }
1684
+ strip() {
1685
+ return new S(y(d({}, this._def), {
1686
+ unknownKeys: "strip"
1687
+ }));
1688
+ }
1689
+ passthrough() {
1690
+ return new S(y(d({}, this._def), {
1691
+ unknownKeys: "passthrough"
1692
+ }));
1693
+ }
1694
+ // const AugmentFactory =
1695
+ // <Def extends ZodObjectDef>(def: Def) =>
1696
+ // <Augmentation extends ZodRawShape>(
1697
+ // augmentation: Augmentation
1698
+ // ): ZodObject<
1699
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1700
+ // Def["unknownKeys"],
1701
+ // Def["catchall"]
1702
+ // > => {
1703
+ // return new ZodObject({
1704
+ // ...def,
1705
+ // shape: () => ({
1706
+ // ...def.shape(),
1707
+ // ...augmentation,
1708
+ // }),
1709
+ // }) as any;
1710
+ // };
1711
+ extend(e) {
1712
+ return new S(y(d({}, this._def), {
1713
+ shape: () => d(d({}, this._def.shape()), e)
1714
+ }));
1715
+ }
1716
+ /**
1717
+ * Prior to zod@1.0.12 there was a bug in the
1718
+ * inferred type of merged objects. Please
1719
+ * upgrade if you are experiencing issues.
1720
+ */
1721
+ merge(e) {
1722
+ return new S({
1723
+ unknownKeys: e._def.unknownKeys,
1724
+ catchall: e._def.catchall,
1725
+ shape: () => d(d({}, this._def.shape()), e._def.shape()),
1726
+ typeName: g.ZodObject
1727
+ });
1728
+ }
1729
+ // merge<
1730
+ // Incoming extends AnyZodObject,
1731
+ // Augmentation extends Incoming["shape"],
1732
+ // NewOutput extends {
1733
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1734
+ // ? Augmentation[k]["_output"]
1735
+ // : k extends keyof Output
1736
+ // ? Output[k]
1737
+ // : never;
1738
+ // },
1739
+ // NewInput extends {
1740
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1741
+ // ? Augmentation[k]["_input"]
1742
+ // : k extends keyof Input
1743
+ // ? Input[k]
1744
+ // : never;
1745
+ // }
1746
+ // >(
1747
+ // merging: Incoming
1748
+ // ): ZodObject<
1749
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1750
+ // Incoming["_def"]["unknownKeys"],
1751
+ // Incoming["_def"]["catchall"],
1752
+ // NewOutput,
1753
+ // NewInput
1754
+ // > {
1755
+ // const merged: any = new ZodObject({
1756
+ // unknownKeys: merging._def.unknownKeys,
1757
+ // catchall: merging._def.catchall,
1758
+ // shape: () =>
1759
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1760
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1761
+ // }) as any;
1762
+ // return merged;
1763
+ // }
1764
+ setKey(e, t) {
1765
+ return this.augment({ [e]: t });
1766
+ }
1767
+ // merge<Incoming extends AnyZodObject>(
1768
+ // merging: Incoming
1769
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1770
+ // ZodObject<
1771
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1772
+ // Incoming["_def"]["unknownKeys"],
1773
+ // Incoming["_def"]["catchall"]
1774
+ // > {
1775
+ // // const mergedShape = objectUtil.mergeShapes(
1776
+ // // this._def.shape(),
1777
+ // // merging._def.shape()
1778
+ // // );
1779
+ // const merged: any = new ZodObject({
1780
+ // unknownKeys: merging._def.unknownKeys,
1781
+ // catchall: merging._def.catchall,
1782
+ // shape: () =>
1783
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1784
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1785
+ // }) as any;
1786
+ // return merged;
1787
+ // }
1788
+ catchall(e) {
1789
+ return new S(y(d({}, this._def), {
1790
+ catchall: e
1791
+ }));
1792
+ }
1793
+ pick(e) {
1794
+ const t = {};
1795
+ return x.objectKeys(e).forEach((r) => {
1796
+ e[r] && this.shape[r] && (t[r] = this.shape[r]);
1797
+ }), new S(y(d({}, this._def), {
1798
+ shape: () => t
1799
+ }));
1800
+ }
1801
+ omit(e) {
1802
+ const t = {};
1803
+ return x.objectKeys(this.shape).forEach((r) => {
1804
+ e[r] || (t[r] = this.shape[r]);
1805
+ }), new S(y(d({}, this._def), {
1806
+ shape: () => t
1807
+ }));
1808
+ }
1809
+ /**
1810
+ * @deprecated
1811
+ */
1812
+ deepPartial() {
1813
+ return _e(this);
1814
+ }
1815
+ partial(e) {
1816
+ const t = {};
1817
+ return x.objectKeys(this.shape).forEach((r) => {
1818
+ const s = this.shape[r];
1819
+ e && !e[r] ? t[r] = s : t[r] = s.optional();
1820
+ }), new S(y(d({}, this._def), {
1821
+ shape: () => t
1822
+ }));
1823
+ }
1824
+ required(e) {
1825
+ const t = {};
1826
+ return x.objectKeys(this.shape).forEach((r) => {
1827
+ if (e && !e[r])
1828
+ t[r] = this.shape[r];
1829
+ else {
1830
+ let a = this.shape[r];
1831
+ for (; a instanceof Q; )
1832
+ a = a._def.innerType;
1833
+ t[r] = a;
1834
+ }
1835
+ }), new S(y(d({}, this._def), {
1836
+ shape: () => t
1837
+ }));
1838
+ }
1839
+ keyof() {
1840
+ return Xt(x.objectKeys(this.shape));
1841
+ }
1842
+ }
1843
+ S.create = (n, e) => new S(d({
1844
+ shape: () => n,
1845
+ unknownKeys: "strip",
1846
+ catchall: ae.create(),
1847
+ typeName: g.ZodObject
1848
+ }, b(e)));
1849
+ S.strictCreate = (n, e) => new S(d({
1850
+ shape: () => n,
1851
+ unknownKeys: "strict",
1852
+ catchall: ae.create(),
1853
+ typeName: g.ZodObject
1854
+ }, b(e)));
1855
+ S.lazycreate = (n, e) => new S(d({
1856
+ shape: n,
1857
+ unknownKeys: "strip",
1858
+ catchall: ae.create(),
1859
+ typeName: g.ZodObject
1860
+ }, b(e)));
1861
+ class $e extends w {
1862
+ _parse(e) {
1863
+ const { ctx: t } = this._processInputParams(e), r = this._def.options;
1864
+ function s(a) {
1865
+ for (const o of a)
1866
+ if (o.result.status === "valid")
1867
+ return o.result;
1868
+ for (const o of a)
1869
+ if (o.result.status === "dirty")
1870
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
1871
+ const i = a.map((o) => new z(o.ctx.common.issues));
1872
+ return f(t, {
1873
+ code: l.invalid_union,
1874
+ unionErrors: i
1875
+ }), v;
1876
+ }
1877
+ if (t.common.async)
1878
+ return Promise.all(r.map((a) => F(this, null, function* () {
1879
+ const i = y(d({}, t), {
1880
+ common: y(d({}, t.common), {
1881
+ issues: []
1882
+ }),
1883
+ parent: null
1884
+ });
1885
+ return {
1886
+ result: yield a._parseAsync({
1887
+ data: t.data,
1888
+ path: t.path,
1889
+ parent: i
1890
+ }),
1891
+ ctx: i
1892
+ };
1893
+ }))).then(s);
1894
+ {
1895
+ let a;
1896
+ const i = [];
1897
+ for (const c of r) {
1898
+ const u = y(d({}, t), {
1899
+ common: y(d({}, t.common), {
1900
+ issues: []
1901
+ }),
1902
+ parent: null
1903
+ }), h = c._parseSync({
1904
+ data: t.data,
1905
+ path: t.path,
1906
+ parent: u
1907
+ });
1908
+ if (h.status === "valid")
1909
+ return h;
1910
+ h.status === "dirty" && !a && (a = { result: h, ctx: u }), u.common.issues.length && i.push(u.common.issues);
1911
+ }
1912
+ if (a)
1913
+ return t.common.issues.push(...a.ctx.common.issues), a.result;
1914
+ const o = i.map((c) => new z(c));
1915
+ return f(t, {
1916
+ code: l.invalid_union,
1917
+ unionErrors: o
1918
+ }), v;
1919
+ }
1920
+ }
1921
+ get options() {
1922
+ return this._def.options;
1923
+ }
1924
+ }
1925
+ $e.create = (n, e) => new $e(d({
1926
+ options: n,
1927
+ typeName: g.ZodUnion
1928
+ }, b(e)));
1929
+ const re = (n) => n instanceof Le ? re(n.schema) : n instanceof J ? re(n.innerType()) : n instanceof Ve ? [n.value] : n instanceof le ? n.options : n instanceof ze ? x.objectValues(n.enum) : n instanceof Ue ? re(n._def.innerType) : n instanceof Me ? [void 0] : n instanceof Pe ? [null] : n instanceof Q ? [void 0, ...re(n.unwrap())] : n instanceof fe ? [null, ...re(n.unwrap())] : n instanceof At || n instanceof We ? re(n.unwrap()) : n instanceof Be ? re(n._def.innerType) : [];
1930
+ class it extends w {
1931
+ _parse(e) {
1932
+ const { ctx: t } = this._processInputParams(e);
1933
+ if (t.parsedType !== p.object)
1934
+ return f(t, {
1935
+ code: l.invalid_type,
1936
+ expected: p.object,
1937
+ received: t.parsedType
1938
+ }), v;
1939
+ const r = this.discriminator, s = t.data[r], a = this.optionsMap.get(s);
1940
+ return a ? t.common.async ? a._parseAsync({
1941
+ data: t.data,
1942
+ path: t.path,
1943
+ parent: t
1944
+ }) : a._parseSync({
1945
+ data: t.data,
1946
+ path: t.path,
1947
+ parent: t
1948
+ }) : (f(t, {
1949
+ code: l.invalid_union_discriminator,
1950
+ options: Array.from(this.optionsMap.keys()),
1951
+ path: [r]
1952
+ }), v);
1953
+ }
1954
+ get discriminator() {
1955
+ return this._def.discriminator;
1956
+ }
1957
+ get options() {
1958
+ return this._def.options;
1959
+ }
1960
+ get optionsMap() {
1961
+ return this._def.optionsMap;
1962
+ }
1963
+ /**
1964
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
1965
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
1966
+ * have a different value for each object in the union.
1967
+ * @param discriminator the name of the discriminator property
1968
+ * @param types an array of object schemas
1969
+ * @param params
1970
+ */
1971
+ static create(e, t, r) {
1972
+ const s = /* @__PURE__ */ new Map();
1973
+ for (const a of t) {
1974
+ const i = re(a.shape[e]);
1975
+ if (!i.length)
1976
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
1977
+ for (const o of i) {
1978
+ if (s.has(o))
1979
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
1980
+ s.set(o, a);
1981
+ }
1982
+ }
1983
+ return new it(d({
1984
+ typeName: g.ZodDiscriminatedUnion,
1985
+ discriminator: e,
1986
+ options: t,
1987
+ optionsMap: s
1988
+ }, b(r)));
1989
+ }
1990
+ }
1991
+ function yt(n, e) {
1992
+ const t = se(n), r = se(e);
1993
+ if (n === e)
1994
+ return { valid: !0, data: n };
1995
+ if (t === p.object && r === p.object) {
1996
+ const s = x.objectKeys(e), a = x.objectKeys(n).filter((o) => s.indexOf(o) !== -1), i = d(d({}, n), e);
1997
+ for (const o of a) {
1998
+ const c = yt(n[o], e[o]);
1999
+ if (!c.valid)
2000
+ return { valid: !1 };
2001
+ i[o] = c.data;
2002
+ }
2003
+ return { valid: !0, data: i };
2004
+ } else if (t === p.array && r === p.array) {
2005
+ if (n.length !== e.length)
2006
+ return { valid: !1 };
2007
+ const s = [];
2008
+ for (let a = 0; a < n.length; a++) {
2009
+ const i = n[a], o = e[a], c = yt(i, o);
2010
+ if (!c.valid)
2011
+ return { valid: !1 };
2012
+ s.push(c.data);
2013
+ }
2014
+ return { valid: !0, data: s };
2015
+ } else return t === p.date && r === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2016
+ }
2017
+ class Fe extends w {
2018
+ _parse(e) {
2019
+ const { status: t, ctx: r } = this._processInputParams(e), s = (a, i) => {
2020
+ if (pt(a) || pt(i))
2021
+ return v;
2022
+ const o = yt(a.value, i.value);
2023
+ return o.valid ? ((mt(a) || mt(i)) && t.dirty(), { status: t.value, value: o.data }) : (f(r, {
2024
+ code: l.invalid_intersection_types
2025
+ }), v);
2026
+ };
2027
+ return r.common.async ? Promise.all([
2028
+ this._def.left._parseAsync({
2029
+ data: r.data,
2030
+ path: r.path,
2031
+ parent: r
2032
+ }),
2033
+ this._def.right._parseAsync({
2034
+ data: r.data,
2035
+ path: r.path,
2036
+ parent: r
2037
+ })
2038
+ ]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
2039
+ data: r.data,
2040
+ path: r.path,
2041
+ parent: r
2042
+ }), this._def.right._parseSync({
2043
+ data: r.data,
2044
+ path: r.path,
2045
+ parent: r
2046
+ }));
2047
+ }
2048
+ }
2049
+ Fe.create = (n, e, t) => new Fe(d({
2050
+ left: n,
2051
+ right: e,
2052
+ typeName: g.ZodIntersection
2053
+ }, b(t)));
2054
+ class te extends w {
2055
+ _parse(e) {
2056
+ const { status: t, ctx: r } = this._processInputParams(e);
2057
+ if (r.parsedType !== p.array)
2058
+ return f(r, {
2059
+ code: l.invalid_type,
2060
+ expected: p.array,
2061
+ received: r.parsedType
2062
+ }), v;
2063
+ if (r.data.length < this._def.items.length)
2064
+ return f(r, {
2065
+ code: l.too_small,
2066
+ minimum: this._def.items.length,
2067
+ inclusive: !0,
2068
+ exact: !1,
2069
+ type: "array"
2070
+ }), v;
2071
+ !this._def.rest && r.data.length > this._def.items.length && (f(r, {
2072
+ code: l.too_big,
2073
+ maximum: this._def.items.length,
2074
+ inclusive: !0,
2075
+ exact: !1,
2076
+ type: "array"
2077
+ }), t.dirty());
2078
+ const a = [...r.data].map((i, o) => {
2079
+ const c = this._def.items[o] || this._def.rest;
2080
+ return c ? c._parse(new ee(r, i, r.path, o)) : null;
2081
+ }).filter((i) => !!i);
2082
+ return r.common.async ? Promise.all(a).then((i) => I.mergeArray(t, i)) : I.mergeArray(t, a);
2083
+ }
2084
+ get items() {
2085
+ return this._def.items;
2086
+ }
2087
+ rest(e) {
2088
+ return new te(y(d({}, this._def), {
2089
+ rest: e
2090
+ }));
2091
+ }
2092
+ }
2093
+ te.create = (n, e) => {
2094
+ if (!Array.isArray(n))
2095
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2096
+ return new te(d({
2097
+ items: n,
2098
+ typeName: g.ZodTuple,
2099
+ rest: null
2100
+ }, b(e)));
2101
+ };
2102
+ class De extends w {
2103
+ get keySchema() {
2104
+ return this._def.keyType;
2105
+ }
2106
+ get valueSchema() {
2107
+ return this._def.valueType;
2108
+ }
2109
+ _parse(e) {
2110
+ const { status: t, ctx: r } = this._processInputParams(e);
2111
+ if (r.parsedType !== p.object)
2112
+ return f(r, {
2113
+ code: l.invalid_type,
2114
+ expected: p.object,
2115
+ received: r.parsedType
2116
+ }), v;
2117
+ const s = [], a = this._def.keyType, i = this._def.valueType;
2118
+ for (const o in r.data)
2119
+ s.push({
2120
+ key: a._parse(new ee(r, o, r.path, o)),
2121
+ value: i._parse(new ee(r, r.data[o], r.path, o)),
2122
+ alwaysSet: o in r.data
2123
+ });
2124
+ return r.common.async ? I.mergeObjectAsync(t, s) : I.mergeObjectSync(t, s);
2125
+ }
2126
+ get element() {
2127
+ return this._def.valueType;
2128
+ }
2129
+ static create(e, t, r) {
2130
+ return t instanceof w ? new De(d({
2131
+ keyType: e,
2132
+ valueType: t,
2133
+ typeName: g.ZodRecord
2134
+ }, b(r))) : new De(d({
2135
+ keyType: q.create(),
2136
+ valueType: e,
2137
+ typeName: g.ZodRecord
2138
+ }, b(t)));
2139
+ }
2140
+ }
2141
+ class st extends w {
2142
+ get keySchema() {
2143
+ return this._def.keyType;
2144
+ }
2145
+ get valueSchema() {
2146
+ return this._def.valueType;
2147
+ }
2148
+ _parse(e) {
2149
+ const { status: t, ctx: r } = this._processInputParams(e);
2150
+ if (r.parsedType !== p.map)
2151
+ return f(r, {
2152
+ code: l.invalid_type,
2153
+ expected: p.map,
2154
+ received: r.parsedType
2155
+ }), v;
2156
+ const s = this._def.keyType, a = this._def.valueType, i = [...r.data.entries()].map(([o, c], u) => ({
2157
+ key: s._parse(new ee(r, o, r.path, [u, "key"])),
2158
+ value: a._parse(new ee(r, c, r.path, [u, "value"]))
2159
+ }));
2160
+ if (r.common.async) {
2161
+ const o = /* @__PURE__ */ new Map();
2162
+ return Promise.resolve().then(() => F(this, null, function* () {
2163
+ for (const c of i) {
2164
+ const u = yield c.key, h = yield c.value;
2165
+ if (u.status === "aborted" || h.status === "aborted")
2166
+ return v;
2167
+ (u.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(u.value, h.value);
2168
+ }
2169
+ return { status: t.value, value: o };
2170
+ }));
2171
+ } else {
2172
+ const o = /* @__PURE__ */ new Map();
2173
+ for (const c of i) {
2174
+ const u = c.key, h = c.value;
2175
+ if (u.status === "aborted" || h.status === "aborted")
2176
+ return v;
2177
+ (u.status === "dirty" || h.status === "dirty") && t.dirty(), o.set(u.value, h.value);
2178
+ }
2179
+ return { status: t.value, value: o };
2180
+ }
2181
+ }
2182
+ }
2183
+ st.create = (n, e, t) => new st(d({
2184
+ valueType: e,
2185
+ keyType: n,
2186
+ typeName: g.ZodMap
2187
+ }, b(t)));
2188
+ class ve extends w {
2189
+ _parse(e) {
2190
+ const { status: t, ctx: r } = this._processInputParams(e);
2191
+ if (r.parsedType !== p.set)
2192
+ return f(r, {
2193
+ code: l.invalid_type,
2194
+ expected: p.set,
2195
+ received: r.parsedType
2196
+ }), v;
2197
+ const s = this._def;
2198
+ s.minSize !== null && r.data.size < s.minSize.value && (f(r, {
2199
+ code: l.too_small,
2200
+ minimum: s.minSize.value,
2201
+ type: "set",
2202
+ inclusive: !0,
2203
+ exact: !1,
2204
+ message: s.minSize.message
2205
+ }), t.dirty()), s.maxSize !== null && r.data.size > s.maxSize.value && (f(r, {
2206
+ code: l.too_big,
2207
+ maximum: s.maxSize.value,
2208
+ type: "set",
2209
+ inclusive: !0,
2210
+ exact: !1,
2211
+ message: s.maxSize.message
2212
+ }), t.dirty());
2213
+ const a = this._def.valueType;
2214
+ function i(c) {
2215
+ const u = /* @__PURE__ */ new Set();
2216
+ for (const h of c) {
2217
+ if (h.status === "aborted")
2218
+ return v;
2219
+ h.status === "dirty" && t.dirty(), u.add(h.value);
2220
+ }
2221
+ return { status: t.value, value: u };
2222
+ }
2223
+ const o = [...r.data.values()].map((c, u) => a._parse(new ee(r, c, r.path, u)));
2224
+ return r.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
2225
+ }
2226
+ min(e, t) {
2227
+ return new ve(y(d({}, this._def), {
2228
+ minSize: { value: e, message: m.toString(t) }
2229
+ }));
2230
+ }
2231
+ max(e, t) {
2232
+ return new ve(y(d({}, this._def), {
2233
+ maxSize: { value: e, message: m.toString(t) }
2234
+ }));
2235
+ }
2236
+ size(e, t) {
2237
+ return this.min(e, t).max(e, t);
2238
+ }
2239
+ nonempty(e) {
2240
+ return this.min(1, e);
2241
+ }
2242
+ }
2243
+ ve.create = (n, e) => new ve(d({
2244
+ valueType: n,
2245
+ minSize: null,
2246
+ maxSize: null,
2247
+ typeName: g.ZodSet
2248
+ }, b(e)));
2249
+ class we extends w {
2250
+ constructor() {
2251
+ super(...arguments), this.validate = this.implement;
2252
+ }
2253
+ _parse(e) {
2254
+ const { ctx: t } = this._processInputParams(e);
2255
+ if (t.parsedType !== p.function)
2256
+ return f(t, {
2257
+ code: l.invalid_type,
2258
+ expected: p.function,
2259
+ received: t.parsedType
2260
+ }), v;
2261
+ function r(o, c) {
2262
+ return et({
2263
+ data: o,
2264
+ path: t.path,
2265
+ errorMaps: [
2266
+ t.common.contextualErrorMap,
2267
+ t.schemaErrorMap,
2268
+ Qe(),
2269
+ xe
2270
+ ].filter((u) => !!u),
2271
+ issueData: {
2272
+ code: l.invalid_arguments,
2273
+ argumentsError: c
2274
+ }
2275
+ });
2276
+ }
2277
+ function s(o, c) {
2278
+ return et({
2279
+ data: o,
2280
+ path: t.path,
2281
+ errorMaps: [
2282
+ t.common.contextualErrorMap,
2283
+ t.schemaErrorMap,
2284
+ Qe(),
2285
+ xe
2286
+ ].filter((u) => !!u),
2287
+ issueData: {
2288
+ code: l.invalid_return_type,
2289
+ returnTypeError: c
2290
+ }
2291
+ });
2292
+ }
2293
+ const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2294
+ if (this._def.returns instanceof Te) {
2295
+ const o = this;
2296
+ return M(function(...c) {
2297
+ return F(this, null, function* () {
2298
+ const u = new z([]), h = yield o._def.args.parseAsync(c, a).catch((E) => {
2299
+ throw u.addIssue(r(c, E)), u;
2300
+ }), _ = yield Reflect.apply(i, this, h);
2301
+ return yield o._def.returns._def.type.parseAsync(_, a).catch((E) => {
2302
+ throw u.addIssue(s(_, E)), u;
2303
+ });
2304
+ });
2305
+ });
2306
+ } else {
2307
+ const o = this;
2308
+ return M(function(...c) {
2309
+ const u = o._def.args.safeParse(c, a);
2310
+ if (!u.success)
2311
+ throw new z([r(c, u.error)]);
2312
+ const h = Reflect.apply(i, this, u.data), _ = o._def.returns.safeParse(h, a);
2313
+ if (!_.success)
2314
+ throw new z([s(h, _.error)]);
2315
+ return _.data;
2316
+ });
2317
+ }
2318
+ }
2319
+ parameters() {
2320
+ return this._def.args;
2321
+ }
2322
+ returnType() {
2323
+ return this._def.returns;
2324
+ }
2325
+ args(...e) {
2326
+ return new we(y(d({}, this._def), {
2327
+ args: te.create(e).rest(me.create())
2328
+ }));
2329
+ }
2330
+ returns(e) {
2331
+ return new we(y(d({}, this._def), {
2332
+ returns: e
2333
+ }));
2334
+ }
2335
+ implement(e) {
2336
+ return this.parse(e);
2337
+ }
2338
+ strictImplement(e) {
2339
+ return this.parse(e);
2340
+ }
2341
+ static create(e, t, r) {
2342
+ return new we(d({
2343
+ args: e || te.create([]).rest(me.create()),
2344
+ returns: t || me.create(),
2345
+ typeName: g.ZodFunction
2346
+ }, b(r)));
2347
+ }
2348
+ }
2349
+ class Le extends w {
2350
+ get schema() {
2351
+ return this._def.getter();
2352
+ }
2353
+ _parse(e) {
2354
+ const { ctx: t } = this._processInputParams(e);
2355
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2356
+ }
2357
+ }
2358
+ Le.create = (n, e) => new Le(d({
2359
+ getter: n,
2360
+ typeName: g.ZodLazy
2361
+ }, b(e)));
2362
+ class Ve extends w {
2363
+ _parse(e) {
2364
+ if (e.data !== this._def.value) {
2365
+ const t = this._getOrReturnCtx(e);
2366
+ return f(t, {
2367
+ received: t.data,
2368
+ code: l.invalid_literal,
2369
+ expected: this._def.value
2370
+ }), v;
2371
+ }
2372
+ return { status: "valid", value: e.data };
2373
+ }
2374
+ get value() {
2375
+ return this._def.value;
2376
+ }
2377
+ }
2378
+ Ve.create = (n, e) => new Ve(d({
2379
+ value: n,
2380
+ typeName: g.ZodLiteral
2381
+ }, b(e)));
2382
+ function Xt(n, e) {
2383
+ return new le(d({
2384
+ values: n,
2385
+ typeName: g.ZodEnum
2386
+ }, b(e)));
2387
+ }
2388
+ class le extends w {
2389
+ constructor() {
2390
+ super(...arguments), Oe.set(this, void 0);
2391
+ }
2392
+ _parse(e) {
2393
+ if (typeof e.data != "string") {
2394
+ const t = this._getOrReturnCtx(e), r = this._def.values;
2395
+ return f(t, {
2396
+ expected: x.joinValues(r),
2397
+ received: t.parsedType,
2398
+ code: l.invalid_type
2399
+ }), v;
2400
+ }
2401
+ if (tt(this, Oe) || Ht(this, Oe, new Set(this._def.values)), !tt(this, Oe).has(e.data)) {
2402
+ const t = this._getOrReturnCtx(e), r = this._def.values;
2403
+ return f(t, {
2404
+ received: t.data,
2405
+ code: l.invalid_enum_value,
2406
+ options: r
2407
+ }), v;
2408
+ }
2409
+ return M(e.data);
2410
+ }
2411
+ get options() {
2412
+ return this._def.values;
2413
+ }
2414
+ get enum() {
2415
+ const e = {};
2416
+ for (const t of this._def.values)
2417
+ e[t] = t;
2418
+ return e;
2419
+ }
2420
+ get Values() {
2421
+ const e = {};
2422
+ for (const t of this._def.values)
2423
+ e[t] = t;
2424
+ return e;
2425
+ }
2426
+ get Enum() {
2427
+ const e = {};
2428
+ for (const t of this._def.values)
2429
+ e[t] = t;
2430
+ return e;
2431
+ }
2432
+ extract(e, t = this._def) {
2433
+ return le.create(e, d(d({}, this._def), t));
2434
+ }
2435
+ exclude(e, t = this._def) {
2436
+ return le.create(this.options.filter((r) => !e.includes(r)), d(d({}, this._def), t));
2437
+ }
2438
+ }
2439
+ Oe = /* @__PURE__ */ new WeakMap();
2440
+ le.create = Xt;
2441
+ class ze extends w {
2442
+ constructor() {
2443
+ super(...arguments), Ce.set(this, void 0);
2444
+ }
2445
+ _parse(e) {
2446
+ const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2447
+ if (r.parsedType !== p.string && r.parsedType !== p.number) {
2448
+ const s = x.objectValues(t);
2449
+ return f(r, {
2450
+ expected: x.joinValues(s),
2451
+ received: r.parsedType,
2452
+ code: l.invalid_type
2453
+ }), v;
2454
+ }
2455
+ if (tt(this, Ce) || Ht(this, Ce, new Set(x.getValidEnumValues(this._def.values))), !tt(this, Ce).has(e.data)) {
2456
+ const s = x.objectValues(t);
2457
+ return f(r, {
2458
+ received: r.data,
2459
+ code: l.invalid_enum_value,
2460
+ options: s
2461
+ }), v;
2462
+ }
2463
+ return M(e.data);
2464
+ }
2465
+ get enum() {
2466
+ return this._def.values;
2467
+ }
2468
+ }
2469
+ Ce = /* @__PURE__ */ new WeakMap();
2470
+ ze.create = (n, e) => new ze(d({
2471
+ values: n,
2472
+ typeName: g.ZodNativeEnum
2473
+ }, b(e)));
2474
+ class Te extends w {
2475
+ unwrap() {
2476
+ return this._def.type;
2477
+ }
2478
+ _parse(e) {
2479
+ const { ctx: t } = this._processInputParams(e);
2480
+ if (t.parsedType !== p.promise && t.common.async === !1)
2481
+ return f(t, {
2482
+ code: l.invalid_type,
2483
+ expected: p.promise,
2484
+ received: t.parsedType
2485
+ }), v;
2486
+ const r = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
2487
+ return M(r.then((s) => this._def.type.parseAsync(s, {
2488
+ path: t.path,
2489
+ errorMap: t.common.contextualErrorMap
2490
+ })));
2491
+ }
2492
+ }
2493
+ Te.create = (n, e) => new Te(d({
2494
+ type: n,
2495
+ typeName: g.ZodPromise
2496
+ }, b(e)));
2497
+ class J extends w {
2498
+ innerType() {
2499
+ return this._def.schema;
2500
+ }
2501
+ sourceType() {
2502
+ return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2503
+ }
2504
+ _parse(e) {
2505
+ const { status: t, ctx: r } = this._processInputParams(e), s = this._def.effect || null, a = {
2506
+ addIssue: (i) => {
2507
+ f(r, i), i.fatal ? t.abort() : t.dirty();
2508
+ },
2509
+ get path() {
2510
+ return r.path;
2511
+ }
2512
+ };
2513
+ if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2514
+ const i = s.transform(r.data, a);
2515
+ if (r.common.async)
2516
+ return Promise.resolve(i).then((o) => F(this, null, function* () {
2517
+ if (t.value === "aborted")
2518
+ return v;
2519
+ const c = yield this._def.schema._parseAsync({
2520
+ data: o,
2521
+ path: r.path,
2522
+ parent: r
2523
+ });
2524
+ return c.status === "aborted" ? v : c.status === "dirty" || t.value === "dirty" ? be(c.value) : c;
2525
+ }));
2526
+ {
2527
+ if (t.value === "aborted")
2528
+ return v;
2529
+ const o = this._def.schema._parseSync({
2530
+ data: i,
2531
+ path: r.path,
2532
+ parent: r
2533
+ });
2534
+ return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? be(o.value) : o;
2535
+ }
2536
+ }
2537
+ if (s.type === "refinement") {
2538
+ const i = (o) => {
2539
+ const c = s.refinement(o, a);
2540
+ if (r.common.async)
2541
+ return Promise.resolve(c);
2542
+ if (c instanceof Promise)
2543
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2544
+ return o;
2545
+ };
2546
+ if (r.common.async === !1) {
2547
+ const o = this._def.schema._parseSync({
2548
+ data: r.data,
2549
+ path: r.path,
2550
+ parent: r
2551
+ });
2552
+ return o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2553
+ } else
2554
+ return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((o) => o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2555
+ }
2556
+ if (s.type === "transform")
2557
+ if (r.common.async === !1) {
2558
+ const i = this._def.schema._parseSync({
2559
+ data: r.data,
2560
+ path: r.path,
2561
+ parent: r
2562
+ });
2563
+ if (!ye(i))
2564
+ return i;
2565
+ const o = s.transform(i.value, a);
2566
+ if (o instanceof Promise)
2567
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2568
+ return { status: t.value, value: o };
2569
+ } else
2570
+ return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => ye(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
2571
+ x.assertNever(s);
2572
+ }
2573
+ }
2574
+ J.create = (n, e, t) => new J(d({
2575
+ schema: n,
2576
+ typeName: g.ZodEffects,
2577
+ effect: e
2578
+ }, b(t)));
2579
+ J.createWithPreprocess = (n, e, t) => new J(d({
2580
+ schema: e,
2581
+ effect: { type: "preprocess", transform: n },
2582
+ typeName: g.ZodEffects
2583
+ }, b(t)));
2584
+ class Q extends w {
2585
+ _parse(e) {
2586
+ return this._getType(e) === p.undefined ? M(void 0) : this._def.innerType._parse(e);
2587
+ }
2588
+ unwrap() {
2589
+ return this._def.innerType;
2590
+ }
2591
+ }
2592
+ Q.create = (n, e) => new Q(d({
2593
+ innerType: n,
2594
+ typeName: g.ZodOptional
2595
+ }, b(e)));
2596
+ class fe extends w {
2597
+ _parse(e) {
2598
+ return this._getType(e) === p.null ? M(null) : this._def.innerType._parse(e);
2599
+ }
2600
+ unwrap() {
2601
+ return this._def.innerType;
2602
+ }
2603
+ }
2604
+ fe.create = (n, e) => new fe(d({
2605
+ innerType: n,
2606
+ typeName: g.ZodNullable
2607
+ }, b(e)));
2608
+ class Ue extends w {
2609
+ _parse(e) {
2610
+ const { ctx: t } = this._processInputParams(e);
2611
+ let r = t.data;
2612
+ return t.parsedType === p.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
2613
+ data: r,
2614
+ path: t.path,
2615
+ parent: t
2616
+ });
2617
+ }
2618
+ removeDefault() {
2619
+ return this._def.innerType;
2620
+ }
2621
+ }
2622
+ Ue.create = (n, e) => new Ue(d({
2623
+ innerType: n,
2624
+ typeName: g.ZodDefault,
2625
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default
2626
+ }, b(e)));
2627
+ class Be extends w {
2628
+ _parse(e) {
2629
+ const { ctx: t } = this._processInputParams(e), r = y(d({}, t), {
2630
+ common: y(d({}, t.common), {
2631
+ issues: []
2632
+ })
2633
+ }), s = this._def.innerType._parse({
2634
+ data: r.data,
2635
+ path: r.path,
2636
+ parent: d({}, r)
2637
+ });
2638
+ return Re(s) ? s.then((a) => ({
2639
+ status: "valid",
2640
+ value: a.status === "valid" ? a.value : this._def.catchValue({
2641
+ get error() {
2642
+ return new z(r.common.issues);
2643
+ },
2644
+ input: r.data
2645
+ })
2646
+ })) : {
2647
+ status: "valid",
2648
+ value: s.status === "valid" ? s.value : this._def.catchValue({
2649
+ get error() {
2650
+ return new z(r.common.issues);
2651
+ },
2652
+ input: r.data
2653
+ })
2654
+ };
2655
+ }
2656
+ removeCatch() {
2657
+ return this._def.innerType;
2658
+ }
2659
+ }
2660
+ Be.create = (n, e) => new Be(d({
2661
+ innerType: n,
2662
+ typeName: g.ZodCatch,
2663
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch
2664
+ }, b(e)));
2665
+ class at extends w {
2666
+ _parse(e) {
2667
+ if (this._getType(e) !== p.nan) {
2668
+ const r = this._getOrReturnCtx(e);
2669
+ return f(r, {
2670
+ code: l.invalid_type,
2671
+ expected: p.nan,
2672
+ received: r.parsedType
2673
+ }), v;
2674
+ }
2675
+ return { status: "valid", value: e.data };
2676
+ }
2677
+ }
2678
+ at.create = (n) => new at(d({
2679
+ typeName: g.ZodNaN
2680
+ }, b(n)));
2681
+ const Vn = Symbol("zod_brand");
2682
+ class At extends w {
2683
+ _parse(e) {
2684
+ const { ctx: t } = this._processInputParams(e), r = t.data;
2685
+ return this._def.type._parse({
2686
+ data: r,
2687
+ path: t.path,
2688
+ parent: t
2689
+ });
2690
+ }
2691
+ unwrap() {
2692
+ return this._def.type;
2693
+ }
2694
+ }
2695
+ class He extends w {
2696
+ _parse(e) {
2697
+ const { status: t, ctx: r } = this._processInputParams(e);
2698
+ if (r.common.async)
2699
+ return F(this, null, function* () {
2700
+ const a = yield this._def.in._parseAsync({
2701
+ data: r.data,
2702
+ path: r.path,
2703
+ parent: r
2704
+ });
2705
+ return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(), be(a.value)) : this._def.out._parseAsync({
2706
+ data: a.value,
2707
+ path: r.path,
2708
+ parent: r
2709
+ });
2710
+ });
2711
+ {
2712
+ const s = this._def.in._parseSync({
2713
+ data: r.data,
2714
+ path: r.path,
2715
+ parent: r
2716
+ });
2717
+ return s.status === "aborted" ? v : s.status === "dirty" ? (t.dirty(), {
2718
+ status: "dirty",
2719
+ value: s.value
2720
+ }) : this._def.out._parseSync({
2721
+ data: s.value,
2722
+ path: r.path,
2723
+ parent: r
2724
+ });
2725
+ }
2726
+ }
2727
+ static create(e, t) {
2728
+ return new He({
2729
+ in: e,
2730
+ out: t,
2731
+ typeName: g.ZodPipeline
2732
+ });
2733
+ }
2734
+ }
2735
+ class We extends w {
2736
+ _parse(e) {
2737
+ const t = this._def.innerType._parse(e), r = (s) => (ye(s) && (s.value = Object.freeze(s.value)), s);
2738
+ return Re(t) ? t.then((s) => r(s)) : r(t);
2739
+ }
2740
+ unwrap() {
2741
+ return this._def.innerType;
2742
+ }
2743
+ }
2744
+ We.create = (n, e) => new We(d({
2745
+ innerType: n,
2746
+ typeName: g.ZodReadonly
2747
+ }, b(e)));
2748
+ function Yt(n, e = {}, t) {
2749
+ return n ? ke.create().superRefine((r, s) => {
2750
+ var a, i;
2751
+ if (!n(r)) {
2752
+ const o = typeof e == "function" ? e(r) : typeof e == "string" ? { message: e } : e, c = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, u = typeof o == "string" ? { message: o } : o;
2753
+ s.addIssue(y(d({ code: "custom" }, u), { fatal: c }));
2754
+ }
2755
+ }) : ke.create();
2756
+ }
2757
+ const zn = {
2758
+ object: S.lazycreate
2759
+ };
2760
+ var g;
2761
+ (function(n) {
2762
+ n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
2763
+ })(g || (g = {}));
2764
+ const Un = (n, e = {
2765
+ message: `Input not instance of ${n.name}`
2766
+ }) => Yt((t) => t instanceof n, e), Qt = q.create, en = de.create, Bn = at.create, Wn = ue.create, tn = Ze.create, qn = ge.create, Hn = nt.create, Jn = Me.create, Gn = Pe.create, Kn = ke.create, Xn = me.create, Yn = ae.create, Qn = rt.create, er = H.create, tr = S.create, nr = S.strictCreate, rr = $e.create, sr = it.create, ar = Fe.create, ir = te.create, or = De.create, cr = st.create, dr = ve.create, ur = we.create, lr = Le.create, fr = Ve.create, hr = le.create, pr = ze.create, mr = Te.create, $t = J.create, yr = Q.create, gr = fe.create, vr = J.createWithPreprocess, _r = He.create, br = () => Qt().optional(), wr = () => en().optional(), xr = () => tn().optional(), kr = {
2767
+ string: (n) => q.create(y(d({}, n), { coerce: !0 })),
2768
+ number: (n) => de.create(y(d({}, n), { coerce: !0 })),
2769
+ boolean: (n) => Ze.create(y(d({}, n), {
2770
+ coerce: !0
2771
+ })),
2772
+ bigint: (n) => ue.create(y(d({}, n), { coerce: !0 })),
2773
+ date: (n) => ge.create(y(d({}, n), { coerce: !0 }))
2774
+ }, Tr = v;
2775
+ var W = /* @__PURE__ */ Object.freeze({
2776
+ __proto__: null,
2777
+ defaultErrorMap: xe,
2778
+ setErrorMap: vn,
2779
+ getErrorMap: Qe,
2780
+ makeIssue: et,
2781
+ EMPTY_PATH: _n,
2782
+ addIssueToContext: f,
2783
+ ParseStatus: I,
2784
+ INVALID: v,
2785
+ DIRTY: be,
2786
+ OK: M,
2787
+ isAborted: pt,
2788
+ isDirty: mt,
2789
+ isValid: ye,
2790
+ isAsync: Re,
2791
+ get util() {
2792
+ return x;
2793
+ },
2794
+ get objectUtil() {
2795
+ return ht;
2796
+ },
2797
+ ZodParsedType: p,
2798
+ getParsedType: se,
2799
+ ZodType: w,
2800
+ datetimeRegex: Kt,
2801
+ ZodString: q,
2802
+ ZodNumber: de,
2803
+ ZodBigInt: ue,
2804
+ ZodBoolean: Ze,
2805
+ ZodDate: ge,
2806
+ ZodSymbol: nt,
2807
+ ZodUndefined: Me,
2808
+ ZodNull: Pe,
2809
+ ZodAny: ke,
2810
+ ZodUnknown: me,
2811
+ ZodNever: ae,
2812
+ ZodVoid: rt,
2813
+ ZodArray: H,
2814
+ ZodObject: S,
2815
+ ZodUnion: $e,
2816
+ ZodDiscriminatedUnion: it,
2817
+ ZodIntersection: Fe,
2818
+ ZodTuple: te,
2819
+ ZodRecord: De,
2820
+ ZodMap: st,
2821
+ ZodSet: ve,
2822
+ ZodFunction: we,
2823
+ ZodLazy: Le,
2824
+ ZodLiteral: Ve,
2825
+ ZodEnum: le,
2826
+ ZodNativeEnum: ze,
2827
+ ZodPromise: Te,
2828
+ ZodEffects: J,
2829
+ ZodTransformer: J,
2830
+ ZodOptional: Q,
2831
+ ZodNullable: fe,
2832
+ ZodDefault: Ue,
2833
+ ZodCatch: Be,
2834
+ ZodNaN: at,
2835
+ BRAND: Vn,
2836
+ ZodBranded: At,
2837
+ ZodPipeline: He,
2838
+ ZodReadonly: We,
2839
+ custom: Yt,
2840
+ Schema: w,
2841
+ ZodSchema: w,
2842
+ late: zn,
2843
+ get ZodFirstPartyTypeKind() {
2844
+ return g;
2845
+ },
2846
+ coerce: kr,
2847
+ any: Kn,
2848
+ array: er,
2849
+ bigint: Wn,
2850
+ boolean: tn,
2851
+ date: qn,
2852
+ discriminatedUnion: sr,
2853
+ effect: $t,
2854
+ enum: hr,
2855
+ function: ur,
2856
+ instanceof: Un,
2857
+ intersection: ar,
2858
+ lazy: lr,
2859
+ literal: fr,
2860
+ map: cr,
2861
+ nan: Bn,
2862
+ nativeEnum: pr,
2863
+ never: Yn,
2864
+ null: Gn,
2865
+ nullable: gr,
2866
+ number: en,
2867
+ object: tr,
2868
+ oboolean: xr,
2869
+ onumber: wr,
2870
+ optional: yr,
2871
+ ostring: br,
2872
+ pipeline: _r,
2873
+ preprocess: vr,
2874
+ promise: mr,
2875
+ record: or,
2876
+ set: dr,
2877
+ strictObject: nr,
2878
+ string: Qt,
2879
+ symbol: Hn,
2880
+ transformer: $t,
2881
+ tuple: ir,
2882
+ undefined: Jn,
2883
+ union: rr,
2884
+ unknown: Xn,
2885
+ void: Qn,
2886
+ NEVER: Tr,
2887
+ ZodIssueCode: l,
2888
+ quotelessJson: gn,
2889
+ ZodError: z
2890
+ });
2891
+ const Sr = W.object({
2892
+ language: W.enum(["typescript", "javascript"]).optional()
2893
+ }).and(
2894
+ W.union([
2895
+ W.object({
2896
+ framework: W.literal("react"),
2897
+ styling: W.enum([
2898
+ "plain_css",
2899
+ "css_modules",
2900
+ "styled_components",
2901
+ "tailwind",
2902
+ "sass",
2903
+ "scss",
2904
+ "inline_styles"
2905
+ ]),
2906
+ uiLibrary: W.enum(["mui", "antd", "radix", "shadcn"]).optional()
2907
+ }),
2908
+ W.object({
2909
+ framework: W.literal("html"),
2910
+ styling: W.enum(["plain_css", "inline_styles"]),
2911
+ enableTranslation: W.boolean().optional()
2912
+ })
2913
+ ])
2914
+ ), Ar = (n) => {
2915
+ const e = Sr.safeParse(n);
2916
+ if (e.success === !1) {
2917
+ const t = new Error("Invalid codegen settings");
2918
+ throw t.cause = e.error, t;
2919
+ }
2920
+ return e.data;
2921
+ }, Er = (n) => Object.entries(n).reduce(
2922
+ (e, [t, r]) => (e[t] = { content: r.code, isBinary: !1 }, e),
2923
+ {}
2924
+ );
2925
+ var U, qe;
2926
+ class Is {
2927
+ constructor({
2928
+ auth: e,
2929
+ apiBaseAddress: t = "https://public-api.animaapp.com"
2930
+ } = {}) {
2931
+ ot(this, U);
2932
+ ot(this, qe);
2933
+ ct(this, qe, t), e && (this.auth = e);
2934
+ }
2935
+ hasAuth() {
2936
+ return !!G(this, U);
2937
+ }
2938
+ set auth(e) {
2939
+ ct(this, U, e);
2940
+ }
2941
+ get headers() {
2942
+ const e = {
2943
+ "Content-Type": "application/json"
2944
+ };
2945
+ return G(this, U) && (e.Authorization = `Bearer ${G(this, U).token}`, "teamId" in G(this, U) && (e["X-Team-Id"] = G(this, U).teamId), "userId" in G(this, U) && G(this, U).userId && (e["X-User-Id"] = G(this, U).userId)), e;
2946
+ }
2947
+ generateCode(r) {
2948
+ return F(this, arguments, function* (e, t = {}) {
2949
+ var h, _, C, E, O, P;
2950
+ if (this.hasAuth() === !1)
2951
+ throw new Error('It needs to set "auth" before calling this method.');
2952
+ const s = {}, a = Ar(e.settings), i = yield fetch(`${G(this, qe)}/v1/codegen`, {
2953
+ method: "POST",
2954
+ headers: y(d({}, this.headers), {
2955
+ Accept: "text/event-stream"
2956
+ }),
2957
+ body: JSON.stringify({
2958
+ fileKey: e.fileKey,
2959
+ figmaToken: e.figmaToken,
2960
+ nodesId: e.nodesId,
2961
+ language: a.language,
2962
+ framework: a.framework,
2963
+ styling: a.styling,
2964
+ uiLibrary: a.uiLibrary,
2965
+ enableTranslation: a.enableTranslation
2966
+ })
2967
+ });
2968
+ if (!i.ok) {
2969
+ let $;
2970
+ try {
2971
+ $ = (yield i.json()).message || `HTTP error! status: ${i.status}`;
2972
+ } catch (ie) {
2973
+ $ = `HTTP error! status: ${i.status}`;
2974
+ }
2975
+ throw new Ae({
2976
+ name: "HTTP Error",
2977
+ reason: $,
2978
+ status: i.status
2979
+ });
2980
+ }
2981
+ if (!i.body)
2982
+ throw new Ae({
2983
+ name: "Stream Error",
2984
+ reason: "Response body is null",
2985
+ status: i.status
2986
+ });
2987
+ const o = i.body.getReader(), c = new TextDecoder();
2988
+ let u = "";
2989
+ try {
2990
+ for (; ; ) {
2991
+ const { done: $, value: ie } = yield o.read();
2992
+ if ($)
2993
+ break;
2994
+ u += c.decode(ie, { stream: !0 });
2995
+ const oe = u.split(`
2996
+ `);
2997
+ u = oe.pop() || "";
2998
+ for (const R of oe)
2999
+ if (!(!R.trim() || R.startsWith(":")) && R.startsWith("data: ")) {
3000
+ let T;
3001
+ try {
3002
+ T = JSON.parse(R.slice(6));
3003
+ } catch (Je) {
3004
+ continue;
3005
+ }
3006
+ switch (T.type) {
3007
+ case "start": {
3008
+ s.sessionId = T.sessionId, typeof t == "function" ? t(T) : (h = t.onStart) == null || h.call(t, { sessionId: T.sessionId });
3009
+ break;
3010
+ }
3011
+ case "pre_codegen": {
3012
+ typeof t == "function" ? t(T) : (_ = t.onPreCodegen) == null || _.call(t, { message: T.message });
3013
+ break;
3014
+ }
3015
+ case "assets_uploaded": {
3016
+ typeof t == "function" ? t(T) : (C = t.onAssetsUploaded) == null || C.call(t);
3017
+ break;
3018
+ }
3019
+ case "figma_metadata": {
3020
+ s.figmaFileName = T.figmaFileName, s.figmaSelectedFrameName = T.figmaSelectedFrameName, typeof t == "function" ? t(T) : (E = t.onFigmaMetadata) == null || E.call(t, {
3021
+ figmaFileName: T.figmaFileName,
3022
+ figmaSelectedFrameName: T.figmaSelectedFrameName
3023
+ });
3024
+ break;
3025
+ }
3026
+ case "generating_code": {
3027
+ const Je = T.payload.files, Ge = Er(Je);
3028
+ T.payload.status === "success" && (s.files = Ge), typeof t == "function" ? t(T) : (O = t.onGeneratingCode) == null || O.call(t, {
3029
+ status: T.payload.status,
3030
+ progress: T.payload.progress,
3031
+ files: Ge
3032
+ });
3033
+ break;
3034
+ }
3035
+ case "codegen_completed": {
3036
+ typeof t == "function" ? t(T) : (P = t.onCodegenCompleted) == null || P.call(t);
3037
+ break;
3038
+ }
3039
+ case "error":
3040
+ throw new Ae({
3041
+ name: T.payload.errorName,
3042
+ reason: T.payload.reason
3043
+ });
3044
+ case "done": {
3045
+ if (!s.files)
3046
+ throw new Ae({
3047
+ name: "Invalid response",
3048
+ reason: "No files found"
3049
+ });
3050
+ return s;
3051
+ }
3052
+ }
3053
+ }
3054
+ }
3055
+ } finally {
3056
+ o.cancel();
3057
+ }
3058
+ throw new Ae({
3059
+ name: "Connection",
3060
+ reason: "Connection closed before the 'done' message",
3061
+ status: 500
3062
+ });
3063
+ });
3064
+ }
3065
+ }
3066
+ U = new WeakMap(), qe = new WeakMap();
3067
+ const Rs = (n) => {
3068
+ var e;
3069
+ if (!n)
3070
+ return [!1, "", ""];
3071
+ try {
3072
+ const t = new URL(n), r = t.pathname;
3073
+ if (t.origin !== "https://www.figma.com")
3074
+ return [!1, "", ""];
3075
+ const s = ((e = t.searchParams.get("node-id")) != null ? e : "").replace(/-/g, ":"), a = r.split("/")[2];
3076
+ return [(r.startsWith("/file/") && t.searchParams.get("type") !== "whiteboard" || r.startsWith("/design/")) && a.length === 22, a, s];
3077
+ } catch (t) {
3078
+ return [!1, "", ""];
3079
+ }
3080
+ }, Zs = ({
3081
+ fileKey: n,
3082
+ nodeId: e
3083
+ }) => {
3084
+ const t = new URL("https://www.figma.com");
3085
+ return t.pathname = `design/${n}`, e && t.searchParams.set("node-id", e.replace(":", "-")), t;
3086
+ }, nn = "Figma Token Issue";
3087
+ class Or extends Error {
3088
+ constructor({ fileKey: e, reason: t }) {
3089
+ super(nn), this.fileKey = e, this.reason = t;
3090
+ }
3091
+ }
3092
+ const rn = "Rate Limit Exceeded";
3093
+ class Cr extends Error {
3094
+ constructor({ fileKey: e }) {
3095
+ super(rn), this.fileKey = e;
3096
+ }
3097
+ }
3098
+ const sn = "Not Found";
3099
+ class Nr extends Error {
3100
+ constructor({ fileKey: e }) {
3101
+ super(sn), this.fileKey = e;
3102
+ }
3103
+ }
3104
+ const jr = (n) => n.message === sn, an = "Unknown Figma API Exception";
3105
+ class Ir extends Error {
3106
+ constructor({ fileKey: e, cause: t }) {
3107
+ super(an), this.name = "UnknownFigmaApiException", this.fileKey = e, this.cause = t;
3108
+ }
3109
+ }
3110
+ const Ms = (n) => n.message === an, Rr = (n) => n.message === rn, Zr = (n) => [nn, ...[
3111
+ "Invalid Figma token",
3112
+ "Figma token expired"
3113
+ ]].includes(
3114
+ n.message
3115
+ ), Mr = (n, e) => {
3116
+ var r, s;
3117
+ const t = ((r = n == null ? void 0 : n.cause) == null ? void 0 : r.body) || n.body;
3118
+ throw (t == null ? void 0 : t.status) === 403 ? new Or({
3119
+ fileKey: e,
3120
+ reason: ((s = n == null ? void 0 : n.cause) == null ? void 0 : s.body) || n.body
3121
+ }) : (t == null ? void 0 : t.status) === 429 ? new Cr({ fileKey: e }) : (t == null ? void 0 : t.status) === 404 ? new Nr({ fileKey: e }) : new Ir({ fileKey: e, cause: n });
3122
+ }, Ps = (n) => jr(n) ? "NotFound" : Rr(n) ? "RateLimitExceeded" : Zr(n) ? "FigmaTokenIssue" : "UnknownFigmaApiException";
3123
+ var Pr = Object.defineProperty, $r = Object.defineProperties, Fr = Object.getOwnPropertyDescriptors, Ft = Object.getOwnPropertySymbols, Dr = Object.prototype.hasOwnProperty, Lr = Object.prototype.propertyIsEnumerable, Dt = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), on = (n) => {
3124
+ throw TypeError(n);
3125
+ }, Lt = (n, e, t) => e in n ? Pr(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, V = (n, e) => {
3126
+ for (var t in e || (e = {}))
3127
+ Dr.call(e, t) && Lt(n, t, e[t]);
3128
+ if (Ft)
3129
+ for (var t of Ft(e))
3130
+ Lr.call(e, t) && Lt(n, t, e[t]);
3131
+ return n;
3132
+ }, Et = (n, e) => $r(n, Fr(e)), Ot = (n, e, t) => e.has(n) || on("Cannot " + t), k = (n, e, t) => (Ot(n, e, "read from private field"), t ? t.call(n) : e.get(n)), B = (n, e, t) => e.has(n) ? on("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), j = (n, e, t, r) => (Ot(n, e, "write to private field"), e.set(n, t), t), Y = (n, e, t) => (Ot(n, e, "access private method"), t), A = (n, e, t) => new Promise((r, s) => {
3133
+ var a = (c) => {
3134
+ try {
3135
+ o(t.next(c));
3136
+ } catch (u) {
3137
+ s(u);
3138
+ }
3139
+ }, i = (c) => {
3140
+ try {
3141
+ o(t.throw(c));
3142
+ } catch (u) {
3143
+ s(u);
3144
+ }
3145
+ }, o = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(a, i);
3146
+ o((t = t.apply(n, e)).next());
3147
+ }), Vr = (n, e, t) => (e = n[Dt("asyncIterator")]) ? e.call(n) : (n = n[Dt("iterator")](), e = {}, t = (r, s) => (s = n[r]) && (e[r] = (a) => new Promise((i, o, c) => (a = s.call(n, a), c = a.done, Promise.resolve(a.value).then((u) => i({ value: u, done: c }), o)))), t("next"), t("return"), e), zr = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
3148
+ function Ur(n) {
3149
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
3150
+ }
3151
+ var gt = { exports: {} }, Br = gt.exports, Vt;
3152
+ function Wr() {
3153
+ return Vt || (Vt = 1, function(n, e) {
3154
+ (function(t, r) {
3155
+ n.exports = r();
3156
+ })(Br, function() {
3157
+ var t = typeof Promise == "function", r = typeof self == "object" ? self : zr, s = typeof Symbol != "undefined", a = typeof Map != "undefined", i = typeof Set != "undefined", o = typeof WeakMap != "undefined", c = typeof WeakSet != "undefined", u = typeof DataView != "undefined", h = s && typeof Symbol.iterator != "undefined", _ = s && typeof Symbol.toStringTag != "undefined", C = i && typeof Set.prototype.entries == "function", E = a && typeof Map.prototype.entries == "function", O = C && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries()), P = E && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries()), $ = h && typeof Array.prototype[Symbol.iterator] == "function", ie = $ && Object.getPrototypeOf([][Symbol.iterator]()), oe = h && typeof String.prototype[Symbol.iterator] == "function", R = oe && Object.getPrototypeOf(""[Symbol.iterator]()), T = 8, Je = -1;
3158
+ function Ge(N) {
3159
+ var Nt = typeof N;
3160
+ if (Nt !== "object")
3161
+ return Nt;
3162
+ if (N === null)
3163
+ return "null";
3164
+ if (N === r)
3165
+ return "global";
3166
+ if (Array.isArray(N) && (_ === !1 || !(Symbol.toStringTag in N)))
3167
+ return "Array";
3168
+ if (typeof window == "object" && window !== null) {
3169
+ if (typeof window.location == "object" && N === window.location)
3170
+ return "Location";
3171
+ if (typeof window.document == "object" && N === window.document)
3172
+ return "Document";
3173
+ if (typeof window.navigator == "object") {
3174
+ if (typeof window.navigator.mimeTypes == "object" && N === window.navigator.mimeTypes)
3175
+ return "MimeTypeArray";
3176
+ if (typeof window.navigator.plugins == "object" && N === window.navigator.plugins)
3177
+ return "PluginArray";
3178
+ }
3179
+ if ((typeof window.HTMLElement == "function" || typeof window.HTMLElement == "object") && N instanceof window.HTMLElement) {
3180
+ if (N.tagName === "BLOCKQUOTE")
3181
+ return "HTMLQuoteElement";
3182
+ if (N.tagName === "TD")
3183
+ return "HTMLTableDataCellElement";
3184
+ if (N.tagName === "TH")
3185
+ return "HTMLTableHeaderCellElement";
3186
+ }
3187
+ }
3188
+ var jt = _ && N[Symbol.toStringTag];
3189
+ if (typeof jt == "string")
3190
+ return jt;
3191
+ var L = Object.getPrototypeOf(N);
3192
+ return L === RegExp.prototype ? "RegExp" : L === Date.prototype ? "Date" : t && L === Promise.prototype ? "Promise" : i && L === Set.prototype ? "Set" : a && L === Map.prototype ? "Map" : c && L === WeakSet.prototype ? "WeakSet" : o && L === WeakMap.prototype ? "WeakMap" : u && L === DataView.prototype ? "DataView" : a && L === P ? "Map Iterator" : i && L === O ? "Set Iterator" : $ && L === ie ? "Array Iterator" : oe && L === R ? "String Iterator" : L === null ? "Object" : Object.prototype.toString.call(N).slice(T, Je);
3193
+ }
3194
+ return Ge;
3195
+ });
3196
+ }(gt)), gt.exports;
3197
+ }
3198
+ var qr = Wr();
3199
+ const Hr = /* @__PURE__ */ Ur(qr), Ct = typeof Buffer != "undefined", Jr = Ct && typeof Buffer.from != "undefined", Gr = Ct ? (
3200
+ /**
3201
+ * is value is Buffer?
3202
+ *
3203
+ * @param {*} value
3204
+ * @return {boolean}
3205
+ */
3206
+ function(n) {
3207
+ return Buffer.isBuffer(n);
3208
+ }
3209
+ ) : (
3210
+ /**
3211
+ * return false
3212
+ *
3213
+ * NOTE: for Buffer unsupported
3214
+ *
3215
+ * @return {boolean}
3216
+ */
3217
+ function() {
3218
+ return !1;
3219
+ }
3220
+ ), Kr = Jr ? (
3221
+ /**
3222
+ * copy Buffer
3223
+ *
3224
+ * @param {Buffer} value
3225
+ * @return {Buffer}
3226
+ */
3227
+ function(n) {
3228
+ return Buffer.from(n);
3229
+ }
3230
+ ) : Ct ? (
3231
+ /**
3232
+ * copy Buffer
3233
+ *
3234
+ * NOTE: for old node.js
3235
+ *
3236
+ * @param {Buffer} value
3237
+ * @return {Buffer}
3238
+ */
3239
+ function(n) {
3240
+ return new Buffer(n);
3241
+ }
3242
+ ) : (
3243
+ /**
3244
+ * shallow copy
3245
+ *
3246
+ * NOTE: for Buffer unsupported
3247
+ *
3248
+ * @param {*}
3249
+ * @return {*}
3250
+ */
3251
+ function(n) {
3252
+ return n;
3253
+ }
3254
+ );
3255
+ function Se(n) {
3256
+ return Gr(n) ? "Buffer" : Hr(n);
3257
+ }
3258
+ const Xr = /* @__PURE__ */ new Set([
3259
+ "Arguments",
3260
+ "Array",
3261
+ "Map",
3262
+ "Object",
3263
+ "Set"
3264
+ ]);
3265
+ function Yr(n, e, t = null) {
3266
+ switch (t || Se(n)) {
3267
+ case "Arguments":
3268
+ case "Array":
3269
+ case "Object":
3270
+ return n[e];
3271
+ case "Map":
3272
+ return n.get(e);
3273
+ case "Set":
3274
+ return e;
3275
+ }
3276
+ }
3277
+ function vt(n) {
3278
+ return Xr.has(n);
3279
+ }
3280
+ function zt(n, e, t, r = null) {
3281
+ switch (r || Se(n)) {
3282
+ case "Arguments":
3283
+ case "Array":
3284
+ case "Object":
3285
+ n[e] = t;
3286
+ break;
3287
+ case "Map":
3288
+ n.set(e, t);
3289
+ break;
3290
+ case "Set":
3291
+ n.add(t);
3292
+ break;
3293
+ }
3294
+ return n;
3295
+ }
3296
+ const Qr = typeof globalThis != "undefined" && globalThis !== null && globalThis.Object === Object && globalThis, es = typeof global != "undefined" && global !== null && global.Object === Object && global, ts = typeof self != "undefined" && self !== null && self.Object === Object && self, ut = Qr || es || ts || Function("return this")();
3297
+ function ns(n) {
3298
+ return n.slice(0);
3299
+ }
3300
+ function rs(n) {
3301
+ return new Boolean(n.valueOf());
3302
+ }
3303
+ function ss(n) {
3304
+ return new DataView(n.buffer);
3305
+ }
3306
+ function as(n) {
3307
+ return Kr(n);
3308
+ }
3309
+ function is(n) {
3310
+ return new Date(n.getTime());
3311
+ }
3312
+ function os(n) {
3313
+ return new Number(n);
3314
+ }
3315
+ function cs(n) {
3316
+ return new RegExp(n.source, n.flags);
3317
+ }
3318
+ function ds(n) {
3319
+ return new String(n);
3320
+ }
3321
+ function ne(n, e) {
3322
+ return ut[e].from ? ut[e].from(n) : new ut[e](n);
3323
+ }
3324
+ function Z(n) {
3325
+ return n;
3326
+ }
3327
+ function Ut() {
3328
+ return [];
3329
+ }
3330
+ function us() {
3331
+ return /* @__PURE__ */ new Map();
3332
+ }
3333
+ function ls() {
3334
+ return {};
3335
+ }
3336
+ function fs() {
3337
+ return /* @__PURE__ */ new Set();
3338
+ }
3339
+ const hs = /* @__PURE__ */ new Map([
3340
+ // deep copy
3341
+ ["ArrayBuffer", ns],
3342
+ ["Boolean", rs],
3343
+ ["Buffer", as],
3344
+ ["DataView", ss],
3345
+ ["Date", is],
3346
+ ["Number", os],
3347
+ ["RegExp", cs],
3348
+ ["String", ds],
3349
+ // typed arrays
3350
+ // TODO: pass bound function
3351
+ ["Float32Array", ne],
3352
+ ["Float64Array", ne],
3353
+ ["Int16Array", ne],
3354
+ ["Int32Array", ne],
3355
+ ["Int8Array", ne],
3356
+ ["Uint16Array", ne],
3357
+ ["Uint32Array", ne],
3358
+ ["Uint8Array", ne],
3359
+ ["Uint8ClampedArray", ne],
3360
+ // shallow copy
3361
+ ["Array Iterator", Z],
3362
+ ["Map Iterator", Z],
3363
+ ["Promise", Z],
3364
+ ["Set Iterator", Z],
3365
+ ["String Iterator", Z],
3366
+ ["function", Z],
3367
+ ["global", Z],
3368
+ // NOTE: WeakMap and WeakSet cannot get entries
3369
+ ["WeakMap", Z],
3370
+ ["WeakSet", Z],
3371
+ // primitives
3372
+ ["boolean", Z],
3373
+ ["null", Z],
3374
+ ["number", Z],
3375
+ ["string", Z],
3376
+ ["symbol", Z],
3377
+ ["undefined", Z],
3378
+ // collections
3379
+ // NOTE: return empty value, because recursively copy later.
3380
+ ["Arguments", Ut],
3381
+ ["Array", Ut],
3382
+ ["Map", us],
3383
+ ["Object", ls],
3384
+ ["Set", fs]
3385
+ // NOTE: type-detect returns following types
3386
+ // 'Location'
3387
+ // 'Document'
3388
+ // 'MimeTypeArray'
3389
+ // 'PluginArray'
3390
+ // 'HTMLQuoteElement'
3391
+ // 'HTMLTableDataCellElement'
3392
+ // 'HTMLTableHeaderCellElement'
3393
+ // TODO: is type-detect never return 'object'?
3394
+ // 'object'
3395
+ ]);
3396
+ function ps() {
3397
+ }
3398
+ function _t(n, e = null, t = ps) {
3399
+ arguments.length === 2 && typeof e == "function" && (t = e, e = null);
3400
+ const r = e || Se(n), s = hs.get(r);
3401
+ if (r === "Object") {
3402
+ const a = t(n, r);
3403
+ if (a !== void 0)
3404
+ return a;
3405
+ }
3406
+ return s ? s(n, r) : n;
3407
+ }
3408
+ function Ee(n, e = {}) {
3409
+ typeof e == "function" && (e = {
3410
+ customizer: e
3411
+ });
3412
+ const {
3413
+ // TODO: before/after customizer
3414
+ customizer: t
3415
+ // TODO: max depth
3416
+ // depth = Infinity,
3417
+ } = e, r = Se(n);
3418
+ if (!vt(r))
3419
+ return bt(n, null, null, null);
3420
+ const s = _t(n, r, t), a = new WeakMap([[n, s]]), i = new WeakSet([n]);
3421
+ return bt(n, s, a, i);
3422
+ }
3423
+ function bt(n, e, t, r, s) {
3424
+ const a = Se(n), i = _t(n, a);
3425
+ if (!vt(a))
3426
+ return i;
3427
+ let o;
3428
+ switch (a) {
3429
+ case "Arguments":
3430
+ case "Array":
3431
+ o = Object.keys(n);
3432
+ break;
3433
+ case "Object":
3434
+ o = Object.keys(n), o.push(...Object.getOwnPropertySymbols(n));
3435
+ break;
3436
+ case "Map":
3437
+ case "Set":
3438
+ o = n.keys();
3439
+ break;
3440
+ }
3441
+ for (let c of o) {
3442
+ const u = Yr(n, c, a);
3443
+ if (r.has(u))
3444
+ zt(e, c, t.get(u), a);
3445
+ else {
3446
+ const h = Se(u), _ = _t(u, h);
3447
+ vt(h) && (t.set(u, _), r.add(u)), zt(
3448
+ e,
3449
+ c,
3450
+ bt(
3451
+ u,
3452
+ _,
3453
+ t,
3454
+ r
3455
+ ),
3456
+ a
3457
+ );
3458
+ }
3459
+ }
3460
+ return e;
3461
+ }
3462
+ const ms = (n) => new Promise((e) => setTimeout(e, n));
3463
+ var Ke, he, Xe, wt, cn;
3464
+ class ys {
3465
+ constructor({ maxAttempts: e = 3, func: t }) {
3466
+ B(this, wt), B(this, Ke), B(this, he), B(this, Xe), j(this, Ke, e), j(this, Xe, t), j(this, he, 0);
3467
+ }
3468
+ run() {
3469
+ return A(this, null, function* () {
3470
+ try {
3471
+ return yield k(this, Xe).call(this);
3472
+ } catch (e) {
3473
+ if (j(this, he, k(this, he) + 1), k(this, he) > k(this, Ke))
3474
+ throw console.error("Max attempts reached"), e;
3475
+ const t = Y(this, wt, cn).call(this);
3476
+ return yield ms(t), yield this.run();
3477
+ }
3478
+ });
3479
+ }
3480
+ }
3481
+ Ke = /* @__PURE__ */ new WeakMap(), he = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), wt = /* @__PURE__ */ new WeakSet(), cn = function() {
3482
+ return k(this, he) * 1e3 * 1.5;
3483
+ };
3484
+ function gs() {
3485
+ return typeof CompressionStream != "undefined";
3486
+ }
3487
+ function vs(n) {
3488
+ return A(this, null, function* () {
3489
+ const e = new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")), t = [];
3490
+ try {
3491
+ for (var r = Vr(e), s, a, i; s = !(a = yield r.next()).done; s = !1) {
3492
+ const o = a.value;
3493
+ t.push(o);
3494
+ }
3495
+ } catch (o) {
3496
+ i = [o];
3497
+ } finally {
3498
+ try {
3499
+ s && (a = r.return) && (yield a.call(r));
3500
+ } finally {
3501
+ if (i)
3502
+ throw i[0];
3503
+ }
3504
+ }
3505
+ return yield _s(t);
3506
+ });
3507
+ }
3508
+ function _s(n) {
3509
+ return A(this, null, function* () {
3510
+ const e = yield new Blob(n).arrayBuffer();
3511
+ return new Uint8Array(e);
3512
+ });
3513
+ }
3514
+ class bs extends Error {
3515
+ constructor({ resource: e, api: t, args: r, cause: s }) {
3516
+ if (super(`API Error on resource "${e}" at api "${t}"`), this.causeProperties = {}, this.name = "API Error", this.resource = e, this.api = t, this.cause = s, this.args = r, s instanceof Error)
3517
+ for (const [i, o] of Object.entries(s))
3518
+ if (typeof Headers != "undefined" && o instanceof Headers) {
3519
+ const c = {};
3520
+ o.forEach((u, h) => {
3521
+ c[h] = u;
3522
+ }), this.causeProperties[i] = c;
3523
+ } else
3524
+ this.causeProperties[i] = o;
3525
+ const a = this.causeProperties.body;
3526
+ a && typeof a == "object" && "code" in a && (this.code = a.code);
3527
+ }
3528
+ }
3529
+ class Bt extends Error {
3530
+ constructor({
3531
+ url: e,
3532
+ method: t,
3533
+ statusCode: r,
3534
+ requestHeaders: s,
3535
+ responseHeaders: a,
3536
+ body: i
3537
+ }) {
3538
+ if (super("Fetch Error"), this.name = "Fetch Error", this.url = e, this.method = t, this.statusNumber = r, this.requestHeaders = s, this.responseHeaders = a, i)
3539
+ try {
3540
+ const o = JSON.parse(i);
3541
+ this.body = o;
3542
+ } catch (o) {
3543
+ this.body = i;
3544
+ }
3545
+ }
3546
+ }
3547
+ class Ne extends Error {
3548
+ constructor(e = {}) {
3549
+ const { canceled: t = !1 } = e;
3550
+ super("Abort Error"), this.name = "Abort Error", this.canceled = t;
3551
+ }
3552
+ }
3553
+ class ws extends Error {
3554
+ constructor(e) {
3555
+ super(`Async API Error: ${JSON.stringify(e)}`), this.name = "Async API Error", this.body = e;
3556
+ }
3557
+ }
3558
+ class lt extends Error {
3559
+ constructor(e) {
3560
+ super(e), this.name = "Request Validation Error";
3561
+ }
3562
+ }
3563
+ function dn() {
3564
+ return Array.from(
3565
+ { length: 32 },
3566
+ () => Math.floor(Math.random() * 256).toString(16).padStart(2, "0")
3567
+ ).join("");
3568
+ }
3569
+ function xt() {
3570
+ return Math.floor(Date.now() / 1e3).toString();
3571
+ }
3572
+ const xs = 5 * 60 * 1e3, ks = 1 * 1e3;
3573
+ var pe, D, K, kt, Tt, je;
3574
+ class Ts {
3575
+ constructor({ fetch: e = globalThis.fetch.bind(globalThis), baseAddress: t }) {
3576
+ B(this, K), B(this, pe), B(this, D), this.baseAddress = t, j(this, pe, e), j(this, D, {}), this.plugins = [];
3577
+ }
3578
+ get headers() {
3579
+ throw new Error("Missing implementation");
3580
+ }
3581
+ addPlugin(e) {
3582
+ this.plugins.push(e);
3583
+ }
3584
+ removePlugin(e) {
3585
+ this.plugins = this.plugins.filter((t) => t.name !== e);
3586
+ }
3587
+ withOptions(e = {}) {
3588
+ return j(this, D, e), this;
3589
+ }
3590
+ get(e) {
3591
+ return A(this, arguments, function* (t, r = {}) {
3592
+ const { overrideBaseAddress: s, overrideDefaultHeaders: a } = r, i = s != null ? s : this.baseAddress;
3593
+ let o = a != null ? a : this.headers;
3594
+ const c = Ee(k(this, D));
3595
+ return j(this, D, {}), c.extraHeaders && (o = V(V({}, o), c.extraHeaders)), c.requestValidation && (o = Et(V({}, o), { "X-Request-Nonce": dn(), "X-Request-Timestamp": xt() })), c.async ? yield Y(this, K, Tt).call(this, `${i}${t}`, c.async, { headers: o }) : yield Y(this, K, kt).call(this, `${i}${t}`, c, { headers: o });
3596
+ });
3597
+ }
3598
+ post(e, t) {
3599
+ return A(this, arguments, function* (r, s, a = {}) {
3600
+ const i = Ee(k(this, D));
3601
+ return j(this, D, {}), Y(this, K, je).call(this, r, "POST", s, a, i);
3602
+ });
3603
+ }
3604
+ put(e, t) {
3605
+ return A(this, arguments, function* (r, s, a = {}) {
3606
+ const i = Ee(k(this, D));
3607
+ return j(this, D, {}), Y(this, K, je).call(this, r, "PUT", s, a, i);
3608
+ });
3609
+ }
3610
+ delete(e, t) {
3611
+ return A(this, arguments, function* (r, s, a = {}) {
3612
+ const i = Ee(k(this, D));
3613
+ return j(this, D, {}), Y(this, K, je).call(this, r, "DELETE", s, a, i);
3614
+ });
3615
+ }
3616
+ patch(e, t) {
3617
+ return A(this, arguments, function* (r, s, a = {}) {
3618
+ const i = Ee(k(this, D));
3619
+ return j(this, D, {}), Y(this, K, je).call(this, r, "PATCH", s, a, i);
3620
+ });
3621
+ }
3622
+ }
3623
+ pe = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakSet(), kt = function(n, e, t) {
3624
+ return A(this, null, function* () {
3625
+ const r = () => A(this, null, function* () {
3626
+ var c, u;
3627
+ try {
3628
+ return yield k(this, pe).call(this, n, V(V({}, t), e.abortSignal && { signal: e.abortSignal }));
3629
+ } catch (h) {
3630
+ throw h instanceof Error && h.name === "AbortError" ? new Ne({ canceled: (u = (c = e.abortSignal) == null ? void 0 : c.aborted) != null ? u : !1 }) : h;
3631
+ }
3632
+ }), { headers: s } = t != null ? t : {}, a = (c, u) => {
3633
+ var h, _;
3634
+ return ((h = c == null ? void 0 : c.headers) == null ? void 0 : h.get(u)) || ((_ = c == null ? void 0 : c.headersObject) == null ? void 0 : _[u]) || "";
3635
+ }, i = (c) => A(this, null, function* () {
3636
+ var u;
3637
+ if (!c.ok) {
3638
+ const _ = yield c.text().catch();
3639
+ throw new Bt({
3640
+ url: n,
3641
+ method: (u = t == null ? void 0 : t.method) != null ? u : "GET",
3642
+ statusCode: c.status,
3643
+ requestHeaders: s,
3644
+ responseHeaders: c.headers,
3645
+ body: _
3646
+ });
3647
+ }
3648
+ if (e.requestValidation && process.env.UI_TESTS !== !0)
3649
+ try {
3650
+ const _ = a(c, "x-response-nonce"), C = s == null ? void 0 : s["X-Request-Nonce"];
3651
+ if (!_ || _ !== C)
3652
+ throw new lt("Response nonce mismatch");
3653
+ const E = Number(a(c, "x-response-timestamp")), O = Number(xt()), P = 60 * 60 * 24;
3654
+ if (isNaN(E) || Math.abs(O - E) > P)
3655
+ throw new lt("Invalid response timestamp");
3656
+ } catch (_) {
3657
+ const C = _ instanceof Error ? _.message : "Request validation failed";
3658
+ throw new lt(C);
3659
+ }
3660
+ let h = yield c.text();
3661
+ try {
3662
+ h = JSON.parse(h);
3663
+ } catch (_) {
3664
+ }
3665
+ return h;
3666
+ });
3667
+ if (e.retry) {
3668
+ const c = yield new ys({
3669
+ maxAttempts: e.retry,
3670
+ func: r
3671
+ }).run();
3672
+ return yield i(c);
3673
+ }
3674
+ const o = yield r();
3675
+ return yield i(o);
3676
+ });
3677
+ }, Tt = function(n, e, t) {
3678
+ return A(this, null, function* () {
3679
+ var r, s;
3680
+ const {
3681
+ onProgress: a,
3682
+ abortSignal: i,
3683
+ pollingInterval: o = () => ks,
3684
+ maxTimeout: c = xs
3685
+ } = e, u = `${n}/async`, h = `${n}/async/job`;
3686
+ let _;
3687
+ try {
3688
+ _ = yield k(this, pe).call(this, u, V(V({}, t), i && { signal: i }));
3689
+ } catch (O) {
3690
+ throw O instanceof Error && O.name === "AbortError" ? new Ne({ canceled: (r = i == null ? void 0 : i.aborted) != null ? r : !1 }) : O;
3691
+ }
3692
+ if (!_.ok) {
3693
+ const O = yield _.text().catch();
3694
+ throw new Bt({
3695
+ url: n,
3696
+ method: (s = t == null ? void 0 : t.method) != null ? s : "GET",
3697
+ statusCode: _.status,
3698
+ requestHeaders: this.headers,
3699
+ responseHeaders: _.headers,
3700
+ body: O
3701
+ });
3702
+ }
3703
+ const C = yield _.json(), { job_id: E } = C;
3704
+ if (!E)
3705
+ throw new Error("Job ID not found in response");
3706
+ return new Promise((O, P) => A(this, null, function* () {
3707
+ const $ = setTimeout(() => {
3708
+ P(new Error("Job timed out"));
3709
+ }, c), ie = (oe = 0) => A(this, null, function* () {
3710
+ if (i != null && i.aborted) {
3711
+ clearTimeout($), k(this, pe).call(this, `${h}/${E}/cancel`, { method: "POST", headers: this.headers }).then(() => {
3712
+ P(new Ne({ canceled: !0 }));
3713
+ }).catch((R) => {
3714
+ P(new Ne({ canceled: !1 }));
3715
+ });
3716
+ return;
3717
+ }
3718
+ try {
3719
+ const R = yield (yield k(this, pe).call(this, `${h}/${E}`, { headers: this.headers })).json();
3720
+ if (R.status === "success") {
3721
+ clearTimeout($);
3722
+ const T = R.response_json;
3723
+ O(T);
3724
+ } else if (R.status === "failed")
3725
+ clearTimeout($), P(new ws(R.response_json));
3726
+ else {
3727
+ a && a(R.response_json);
3728
+ const T = o(oe);
3729
+ setTimeout(() => ie(oe + 1), T);
3730
+ }
3731
+ } catch (R) {
3732
+ P(R);
3733
+ }
3734
+ });
3735
+ ie();
3736
+ }));
3737
+ });
3738
+ }, je = function(n, e, t, r, s) {
3739
+ return A(this, null, function* () {
3740
+ const { overrideBaseAddress: a, overrideDefaultHeaders: i } = r, o = a != null ? a : this.baseAddress;
3741
+ let c = i != null ? i : this.headers;
3742
+ s.extraHeaders && (c = V(V({}, c), s.extraHeaders)), s.requestValidation && (c = Et(V({}, c), { "X-Request-Nonce": dn(), "X-Request-Timestamp": xt() }));
3743
+ let u = r.skipBodyJsonStringify ? t : JSON.stringify(t);
3744
+ return s.compress && gs() && (c["Content-Encoding"] = "gzip", u = yield vs(u)), s.async ? yield Y(this, K, Tt).call(this, `${o}${n}`, s.async, {
3745
+ method: e,
3746
+ headers: c,
3747
+ body: u
3748
+ }) : yield Y(this, K, kt).call(this, `${o}${n}`, s, { method: e, headers: c, body: u });
3749
+ });
3750
+ };
3751
+ const Wt = (n, e, t, r) => n instanceof Ne ? n : new bs({ resource: e, api: String(t), args: r, cause: n }), ft = (n, e) => new Proxy(e, {
3752
+ get(t, r) {
3753
+ return (...s) => {
3754
+ var a;
3755
+ for (const o of n.plugins) {
3756
+ const c = (a = o.beforeApi) == null ? void 0 : a.call(o, { resource: t.resourceName, api: r, args: s });
3757
+ if (c !== void 0)
3758
+ return c;
3759
+ }
3760
+ let i;
3761
+ try {
3762
+ i = t[r](...s);
3763
+ } catch (o) {
3764
+ throw Wt(o, t.resourceName, r, s);
3765
+ }
3766
+ return i instanceof Promise ? i.catch((o) => {
3767
+ throw Wt(o, t.resourceName, r, s);
3768
+ }) : i;
3769
+ };
3770
+ }
3771
+ });
3772
+ var Ie;
3773
+ class Ss {
3774
+ constructor(e) {
3775
+ B(this, Ie), this.resourceName = "Files", j(this, Ie, e);
3776
+ }
3777
+ get(e) {
3778
+ return A(this, arguments, function* ({ fileKey: t, params: r = {} }) {
3779
+ const s = new URLSearchParams(V({
3780
+ plugin_data: "857346721138427857"
3781
+ }, r)).toString(), a = `v1/files/${t}?${s}`;
3782
+ return yield k(this, Ie).get(a);
3783
+ });
3784
+ }
3785
+ getImageFills(e) {
3786
+ return A(this, arguments, function* ({ fileKey: t }) {
3787
+ var r, s;
3788
+ const a = `v1/files/${t}/images`;
3789
+ return (s = (r = (yield k(this, Ie).get(a)).meta) == null ? void 0 : r.images) != null ? s : {};
3790
+ });
3791
+ }
3792
+ }
3793
+ Ie = /* @__PURE__ */ new WeakMap();
3794
+ const As = (n, e, t) => {
3795
+ const r = e.sort();
3796
+ return `${n}-${r.join("-")}-${t}`;
3797
+ }, Es = (n) => n ? n.ts > Date.now() - 1e3 * 30 : !1;
3798
+ var X, St, un;
3799
+ class Os {
3800
+ constructor(e) {
3801
+ B(this, St), B(this, X), this.resourceName = "Images", j(this, X, e);
3802
+ }
3803
+ /**
3804
+ * Return the URL for the _layer_ images for the given nodes.
3805
+ * Note: Use the `file.images` API to get the _source_ images used on the node fills, which has better quality.
3806
+ */
3807
+ get(e) {
3808
+ return A(this, arguments, function* ({ fileKey: t, nodeIds: r, format: s = "jpg", scale: a }) {
3809
+ const i = As(t, r, s), o = k(this, X).cache.images.entries.get(i);
3810
+ if (Es(o))
3811
+ return o.result;
3812
+ o && k(this, X).cache.images.entries.delete(i);
3813
+ const c = k(this, X).cache.images.pendingRequests.get(i);
3814
+ if (c)
3815
+ return c;
3816
+ const u = Y(this, St, un).call(this, i, t, r, s, a);
3817
+ k(this, X).cache.images.pendingRequests.set(i, u);
3818
+ try {
3819
+ return yield u;
3820
+ } finally {
3821
+ k(this, X).cache.images.pendingRequests.delete(i);
3822
+ }
3823
+ });
3824
+ }
3825
+ }
3826
+ X = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakSet(), un = function(n, e, t, r, s) {
3827
+ return A(this, null, function* () {
3828
+ const a = yield k(this, X).get(
3829
+ `v1/images/${e}?ids=${t}&format=${r}${s ? `&scale=${s}` : ""}`
3830
+ );
3831
+ return k(this, X).cache.images.entries.set(n, {
3832
+ result: a,
3833
+ ts: Date.now()
3834
+ }), a;
3835
+ });
3836
+ };
3837
+ var Ye;
3838
+ class Cs {
3839
+ constructor(e) {
3840
+ B(this, Ye), this.resourceName = "Nodes", j(this, Ye, e);
3841
+ }
3842
+ get(e) {
3843
+ return A(this, arguments, function* ({ fileKey: t, nodeIds: r, params: s = {} }) {
3844
+ const a = Et(V({}, s), {
3845
+ ids: r.join(",")
3846
+ }), i = new URLSearchParams(V({
3847
+ plugin_data: "857346721138427857"
3848
+ }, a)).toString(), o = `v1/files/${t}/nodes?${i}`;
3849
+ return yield k(this, Ye).get(o);
3850
+ });
3851
+ }
3852
+ }
3853
+ Ye = /* @__PURE__ */ new WeakMap();
3854
+ var ce;
3855
+ class ln extends Ts {
3856
+ constructor({
3857
+ baseAddress: e = "https://api.figma.com/",
3858
+ fetch: t = globalThis.fetch.bind(globalThis)
3859
+ } = {}) {
3860
+ super({ fetch: t, baseAddress: e }), B(this, ce, ""), this.cache = {
3861
+ images: {
3862
+ entries: /* @__PURE__ */ new Map(),
3863
+ pendingRequests: /* @__PURE__ */ new Map()
3864
+ }
3865
+ }, this.files = ft(this, new Ss(this)), this.nodes = ft(this, new Cs(this)), this.images = ft(this, new Os(this));
3866
+ }
3867
+ set token(e) {
3868
+ if (!e.startsWith("figd_") && !e.startsWith("figu_"))
3869
+ throw new Error("Invalid Figma access token");
3870
+ j(this, ce, e);
3871
+ }
3872
+ get token() {
3873
+ return k(this, ce);
3874
+ }
3875
+ get headers() {
3876
+ const e = {
3877
+ "Content-Type": "application/json"
3878
+ };
3879
+ return k(this, ce).startsWith("figd_") ? e["X-FIGMA-TOKEN"] = k(this, ce) : k(this, ce).startsWith("figu_") && (e.Authorization = `Bearer ${k(this, ce)}`), e;
3880
+ }
3881
+ }
3882
+ ce = /* @__PURE__ */ new WeakMap();
3883
+ const $s = (s) => F(void 0, [s], function* ({
3884
+ fileKey: n,
3885
+ authToken: e,
3886
+ figmaRestApi: t = new ln(),
3887
+ params: r = {}
3888
+ }) {
3889
+ e && (t.token = e);
3890
+ try {
3891
+ return yield t.files.get({
3892
+ fileKey: n,
3893
+ params: r
3894
+ });
3895
+ } catch (a) {
3896
+ throw console.error(a), a;
3897
+ }
3898
+ }), Fs = (a) => F(void 0, [a], function* ({
3899
+ fileKey: n,
3900
+ authToken: e,
3901
+ nodeIds: t,
3902
+ figmaRestApi: r = new ln(),
3903
+ params: s = {}
3904
+ }) {
3905
+ e && (r.token = e);
3906
+ try {
3907
+ return (yield r.nodes.get({
3908
+ fileKey: n,
3909
+ nodeIds: t,
3910
+ params: d({}, s)
3911
+ })).nodes;
3912
+ } catch (i) {
3913
+ return Mr(i, n);
3914
+ }
3915
+ }), Ns = (n, e) => new ReadableStream({
3916
+ start(t) {
3917
+ n.generateCode(e, (r) => {
3918
+ r.type === "error" ? (console.log("NOT SURE IF THIS IS REACHABLE, ALL ERRORS ARE THROWING"), t.enqueue({
3919
+ type: "error",
3920
+ payload: { message: r.payload.reason }
3921
+ })) : t.enqueue(r), (r.type === "aborted" || r.type === "error") && t.close();
3922
+ }).then((r) => {
3923
+ t.enqueue({ type: "done" }), t.close();
3924
+ }).catch((r) => {
3925
+ t.enqueue({
3926
+ type: "error",
3927
+ payload: {
3928
+ message: "message" in r ? r.message : "Unknown",
3929
+ status: "status" in r ? r.status : void 0
3930
+ }
3931
+ }), t.close();
3932
+ });
3933
+ }
3934
+ }), Ds = (n, e) => F(void 0, null, function* () {
3935
+ var o, c, u, h, _, C, E;
3936
+ const t = Ns(n, e), [r, s] = t.tee(), a = yield r.getReader().read();
3937
+ if (a.done || !a.value || ((o = a.value) == null ? void 0 : o.type) === "error" && ((u = (c = a.value) == null ? void 0 : c.payload) != null && u.status))
3938
+ return new Response(JSON.stringify(a.value), {
3939
+ status: ((h = a.value) == null ? void 0 : h.type) === "error" && (E = (C = (_ = a.value) == null ? void 0 : _.payload) == null ? void 0 : C.status) != null ? E : 500,
3940
+ headers: {
3941
+ "Content-Type": "application/json"
3942
+ }
3943
+ });
3944
+ const i = s.pipeThrough(
3945
+ new TransformStream({
3946
+ transform(O, P) {
3947
+ const $ = `event: ${O.type}
3948
+ data: ${JSON.stringify(
3949
+ O
3950
+ )}
3951
+
3952
+ `;
3953
+ P.enqueue($);
3954
+ }
3955
+ })
3956
+ );
3957
+ return new Response(i, {
3958
+ status: 200,
3959
+ headers: {
3960
+ "Content-Type": "text/event-stream; charset=utf-8",
3961
+ Connection: "keep-alive",
3962
+ "Cache-Control": "no-cache"
3963
+ }
3964
+ });
3965
+ });
3966
+ export {
3967
+ Is as Anima,
3968
+ Ae as CodegenError,
3969
+ Or as FigmaTokenIssue,
3970
+ Nr as NotFound,
3971
+ Cr as RateLimitExceeded,
3972
+ Ir as UnknownFigmaApiException,
3973
+ Er as convertCodegenFilesToAnimaFiles,
3974
+ Ds as createCodegenResponseEventStream,
3975
+ Ns as createCodegenStream,
3976
+ Zs as formatToFigmaLink,
3977
+ Ps as getFigmaApiErrorType,
3978
+ $s as getFigmaFile,
3979
+ Fs as getFileNodes,
3980
+ Mr as handleFigmaApiError,
3981
+ Zr as isFigmaTokenIssue,
3982
+ jr as isNotFound,
3983
+ Rr as isRateLimitExceeded,
3984
+ Ms as isUnknownFigmaApiException,
3985
+ Rs as isValidFigmaUrl,
3986
+ Ar as validateSettings
3987
+ };
3988
+ //# sourceMappingURL=index.js.map