@authhero/cloudflare-adapter 0.1.0 → 0.3.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.
@@ -1,308 +1,3092 @@
1
- const q = "application/json", D = "Content-Type", w = Symbol(), M = Symbol();
2
- function R(t = {}) {
3
- var e;
4
- const n = t instanceof Array ? Object.fromEntries(t) : t;
5
- return (e = Object.entries(n).find(([o]) => o.toLowerCase() === D.toLowerCase())) === null || e === void 0 ? void 0 : e[1];
6
- }
7
- function S(t) {
8
- return /^application\/.*json.*/.test(t);
9
- }
10
- const T = function(t, e, n = !1) {
11
- return Object.entries(e).reduce((o, [i, l]) => {
12
- const h = t[i];
13
- return Array.isArray(h) && Array.isArray(l) ? o[i] = n ? [...h, ...l] : l : typeof h == "object" && typeof l == "object" ? o[i] = T(h, l, n) : o[i] = l, o;
14
- }, { ...t });
15
- }, C = {
16
- // Default options
17
- options: {},
18
- // Error type
19
- errorType: "text",
20
- // Polyfills
21
- polyfills: {
22
- // fetch: null,
23
- // FormData: null,
24
- // URL: null,
25
- // URLSearchParams: null,
26
- // performance: null,
27
- // PerformanceObserver: null,
28
- // AbortController: null,
29
- },
30
- polyfill(t, e = !0, n = !1, ...o) {
31
- const i = this.polyfills[t] || (typeof self < "u" ? self[t] : null) || (typeof global < "u" ? global[t] : null);
32
- if (e && !i)
33
- throw new Error(t + " is not defined");
34
- return n && i ? new i(...o) : i;
1
+ import tt from "wretch";
2
+ const rt = (r, e) => e.skipDedupe || e.method !== "GET", nt = (r, e) => e.method + "@" + r, st = (r) => r.clone(), at = ({ skip: r = rt, key: e = nt, resolver: t = st } = {}) => {
3
+ const n = /* @__PURE__ */ new Map();
4
+ return (s) => (a, o) => {
5
+ if (r(a, o))
6
+ return s(a, o);
7
+ const i = e(a, o);
8
+ if (!n.has(i))
9
+ n.set(i, []);
10
+ else
11
+ return new Promise((u, d) => {
12
+ n.get(i).push([u, d]);
13
+ });
14
+ try {
15
+ return s(a, o).then((u) => (n.get(i).forEach(([d]) => d(t(u))), n.delete(i), u)).catch((u) => {
16
+ throw n.get(i).forEach(([, d]) => d(u)), n.delete(i), u;
17
+ });
18
+ } catch (u) {
19
+ return n.delete(i), Promise.reject(u);
20
+ }
21
+ };
22
+ }, it = (r, e) => r * e, ot = (r) => r && r.ok, dt = ({ delayTimer: r = 500, delayRamp: e = it, maxAttempts: t = 10, until: n = ot, onRetry: s = null, retryOnNetworkError: a = !1, resolveWithLatestResponse: o = !1, skip: i } = {}) => (u) => (d, h) => {
23
+ let k = 0;
24
+ if (i && i(d, h))
25
+ return u(d, h);
26
+ const O = (w, P) => Promise.resolve(n(w, P)).then((Ee) => Ee ? w && o ? w : P ? Promise.reject(P) : w : (k++, !t || k <= t ? new Promise(($) => {
27
+ const ge = e(r, k);
28
+ setTimeout(() => {
29
+ typeof s == "function" ? Promise.resolve(s({
30
+ response: w,
31
+ error: P,
32
+ url: d,
33
+ options: h
34
+ })).then((B = {}) => {
35
+ var F, ee;
36
+ $(u((F = B && B.url) !== null && F !== void 0 ? F : d, (ee = B && B.options) !== null && ee !== void 0 ? ee : h));
37
+ }) : $(u(d, h));
38
+ }, ge);
39
+ }).then(O).catch(($) => {
40
+ if (!a)
41
+ throw $;
42
+ return O(null, $);
43
+ }) : w && o ? w : Promise.reject(P || new Error("Number of attempts exceeded."))));
44
+ return u(d, h).then(O).catch((w) => {
45
+ if (!a)
46
+ throw w;
47
+ return O(null, w);
48
+ });
49
+ };
50
+ function ct(r, e) {
51
+ var t = {};
52
+ for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
53
+ if (r != null && typeof Object.getOwnPropertySymbols == "function")
54
+ for (var s = 0, n = Object.getOwnPropertySymbols(r); s < n.length; s++)
55
+ e.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[s]) && (t[n[s]] = r[n[s]]);
56
+ return t;
57
+ }
58
+ function ut(r, e) {
59
+ var t;
60
+ return ((t = r == null ? void 0 : r._def) === null || t === void 0 ? void 0 : t.typeName) === e;
61
+ }
62
+ function te(r, e) {
63
+ const t = r.ZodType.prototype[e];
64
+ r.ZodType.prototype[e] = function(...n) {
65
+ const s = t.apply(this, n);
66
+ return s._def.openapi = this._def.openapi, s;
67
+ };
68
+ }
69
+ function lt(r) {
70
+ if (typeof r.ZodType.prototype.openapi < "u")
71
+ return;
72
+ r.ZodType.prototype.openapi = function(s, a) {
73
+ var o, i, u, d, h, k;
74
+ const O = typeof s == "string" ? a : s, w = O ?? {}, { param: P } = w, Ee = ct(w, ["param"]), $ = Object.assign(Object.assign({}, (o = this._def.openapi) === null || o === void 0 ? void 0 : o._internal), typeof s == "string" ? { refId: s } : void 0), ge = Object.assign(Object.assign(Object.assign({}, (i = this._def.openapi) === null || i === void 0 ? void 0 : i.metadata), Ee), !((d = (u = this._def.openapi) === null || u === void 0 ? void 0 : u.metadata) === null || d === void 0) && d.param || P ? {
75
+ param: Object.assign(Object.assign({}, (k = (h = this._def.openapi) === null || h === void 0 ? void 0 : h.metadata) === null || k === void 0 ? void 0 : k.param), P)
76
+ } : void 0), B = new this.constructor(Object.assign(Object.assign({}, this._def), { openapi: Object.assign(Object.assign({}, Object.keys($).length > 0 ? { _internal: $ } : void 0), Object.keys(ge).length > 0 ? { metadata: ge } : void 0) }));
77
+ if (ut(this, "ZodObject")) {
78
+ const F = this.extend;
79
+ B.extend = function(...ee) {
80
+ var je, Ce, Ne, Re, Ie, Ae;
81
+ const Me = F.apply(this, ee);
82
+ return Me._def.openapi = {
83
+ _internal: {
84
+ extendedFrom: !((Ce = (je = this._def.openapi) === null || je === void 0 ? void 0 : je._internal) === null || Ce === void 0) && Ce.refId ? { refId: (Re = (Ne = this._def.openapi) === null || Ne === void 0 ? void 0 : Ne._internal) === null || Re === void 0 ? void 0 : Re.refId, schema: this } : (Ie = this._def.openapi) === null || Ie === void 0 ? void 0 : Ie._internal.extendedFrom
85
+ },
86
+ metadata: (Ae = Me._def.openapi) === null || Ae === void 0 ? void 0 : Ae.metadata
87
+ }, Me;
88
+ };
89
+ }
90
+ return B;
91
+ }, te(r, "optional"), te(r, "nullable"), te(r, "default"), te(r, "transform"), te(r, "refine");
92
+ const e = r.ZodObject.prototype.deepPartial;
93
+ r.ZodObject.prototype.deepPartial = function() {
94
+ const s = this._def.shape(), a = e.apply(this), o = a._def.shape();
95
+ return Object.entries(o).forEach(([i, u]) => {
96
+ var d, h;
97
+ u._def.openapi = (h = (d = s[i]) === null || d === void 0 ? void 0 : d._def) === null || h === void 0 ? void 0 : h.openapi;
98
+ }), a._def.openapi = void 0, a;
99
+ };
100
+ const t = r.ZodObject.prototype.pick;
101
+ r.ZodObject.prototype.pick = function(...s) {
102
+ const a = t.apply(this, s);
103
+ return a._def.openapi = void 0, a;
104
+ };
105
+ const n = r.ZodObject.prototype.omit;
106
+ r.ZodObject.prototype.omit = function(...s) {
107
+ const a = n.apply(this, s);
108
+ return a._def.openapi = void 0, a;
109
+ };
110
+ }
111
+ new Set(".\\+*[^]$()");
112
+ var x;
113
+ (function(r) {
114
+ r.assertEqual = (s) => s;
115
+ function e(s) {
116
+ }
117
+ r.assertIs = e;
118
+ function t(s) {
119
+ throw new Error();
120
+ }
121
+ r.assertNever = t, r.arrayToEnum = (s) => {
122
+ const a = {};
123
+ for (const o of s)
124
+ a[o] = o;
125
+ return a;
126
+ }, r.getValidEnumValues = (s) => {
127
+ const a = r.objectKeys(s).filter((i) => typeof s[s[i]] != "number"), o = {};
128
+ for (const i of a)
129
+ o[i] = s[i];
130
+ return r.objectValues(o);
131
+ }, r.objectValues = (s) => r.objectKeys(s).map(function(a) {
132
+ return s[a];
133
+ }), r.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
134
+ const a = [];
135
+ for (const o in s)
136
+ Object.prototype.hasOwnProperty.call(s, o) && a.push(o);
137
+ return a;
138
+ }, r.find = (s, a) => {
139
+ for (const o of s)
140
+ if (a(o))
141
+ return o;
142
+ }, r.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
143
+ function n(s, a = " | ") {
144
+ return s.map((o) => typeof o == "string" ? `'${o}'` : o).join(a);
145
+ }
146
+ r.joinValues = n, r.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
147
+ })(x || (x = {}));
148
+ var $e;
149
+ (function(r) {
150
+ r.mergeShapes = (e, t) => ({
151
+ ...e,
152
+ ...t
153
+ // second overwrites first
154
+ });
155
+ })($e || ($e = {}));
156
+ const f = x.arrayToEnum([
157
+ "string",
158
+ "nan",
159
+ "number",
160
+ "integer",
161
+ "float",
162
+ "boolean",
163
+ "date",
164
+ "bigint",
165
+ "symbol",
166
+ "function",
167
+ "undefined",
168
+ "null",
169
+ "array",
170
+ "object",
171
+ "unknown",
172
+ "promise",
173
+ "void",
174
+ "never",
175
+ "map",
176
+ "set"
177
+ ]), V = (r) => {
178
+ switch (typeof r) {
179
+ case "undefined":
180
+ return f.undefined;
181
+ case "string":
182
+ return f.string;
183
+ case "number":
184
+ return isNaN(r) ? f.nan : f.number;
185
+ case "boolean":
186
+ return f.boolean;
187
+ case "function":
188
+ return f.function;
189
+ case "bigint":
190
+ return f.bigint;
191
+ case "symbol":
192
+ return f.symbol;
193
+ case "object":
194
+ return Array.isArray(r) ? f.array : r === null ? f.null : r.then && typeof r.then == "function" && r.catch && typeof r.catch == "function" ? f.promise : typeof Map < "u" && r instanceof Map ? f.map : typeof Set < "u" && r instanceof Set ? f.set : typeof Date < "u" && r instanceof Date ? f.date : f.object;
195
+ default:
196
+ return f.unknown;
197
+ }
198
+ }, c = x.arrayToEnum([
199
+ "invalid_type",
200
+ "invalid_literal",
201
+ "custom",
202
+ "invalid_union",
203
+ "invalid_union_discriminator",
204
+ "invalid_enum_value",
205
+ "unrecognized_keys",
206
+ "invalid_arguments",
207
+ "invalid_return_type",
208
+ "invalid_date",
209
+ "invalid_string",
210
+ "too_small",
211
+ "too_big",
212
+ "invalid_intersection_types",
213
+ "not_multiple_of",
214
+ "not_finite"
215
+ ]), ft = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
216
+ class S extends Error {
217
+ constructor(e) {
218
+ super(), this.issues = [], this.addIssue = (n) => {
219
+ this.issues = [...this.issues, n];
220
+ }, this.addIssues = (n = []) => {
221
+ this.issues = [...this.issues, ...n];
222
+ };
223
+ const t = new.target.prototype;
224
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
225
+ }
226
+ get errors() {
227
+ return this.issues;
35
228
  }
229
+ format(e) {
230
+ const t = e || function(a) {
231
+ return a.message;
232
+ }, n = { _errors: [] }, s = (a) => {
233
+ for (const o of a.issues)
234
+ if (o.code === "invalid_union")
235
+ o.unionErrors.map(s);
236
+ else if (o.code === "invalid_return_type")
237
+ s(o.returnTypeError);
238
+ else if (o.code === "invalid_arguments")
239
+ s(o.argumentsError);
240
+ else if (o.path.length === 0)
241
+ n._errors.push(t(o));
242
+ else {
243
+ let i = n, u = 0;
244
+ for (; u < o.path.length; ) {
245
+ const d = o.path[u];
246
+ u === o.path.length - 1 ? (i[d] = i[d] || { _errors: [] }, i[d]._errors.push(t(o))) : i[d] = i[d] || { _errors: [] }, i = i[d], u++;
247
+ }
248
+ }
249
+ };
250
+ return s(this), n;
251
+ }
252
+ static assert(e) {
253
+ if (!(e instanceof S))
254
+ throw new Error(`Not a ZodError: ${e}`);
255
+ }
256
+ toString() {
257
+ return this.message;
258
+ }
259
+ get message() {
260
+ return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
261
+ }
262
+ get isEmpty() {
263
+ return this.issues.length === 0;
264
+ }
265
+ flatten(e = (t) => t.message) {
266
+ const t = {}, n = [];
267
+ for (const s of this.issues)
268
+ s.path.length > 0 ? (t[s.path[0]] = t[s.path[0]] || [], t[s.path[0]].push(e(s))) : n.push(e(s));
269
+ return { formErrors: n, fieldErrors: t };
270
+ }
271
+ get formErrors() {
272
+ return this.flatten();
273
+ }
274
+ }
275
+ S.create = (r) => new S(r);
276
+ const X = (r, e) => {
277
+ let t;
278
+ switch (r.code) {
279
+ case c.invalid_type:
280
+ r.received === f.undefined ? t = "Required" : t = `Expected ${r.expected}, received ${r.received}`;
281
+ break;
282
+ case c.invalid_literal:
283
+ t = `Invalid literal value, expected ${JSON.stringify(r.expected, x.jsonStringifyReplacer)}`;
284
+ break;
285
+ case c.unrecognized_keys:
286
+ t = `Unrecognized key(s) in object: ${x.joinValues(r.keys, ", ")}`;
287
+ break;
288
+ case c.invalid_union:
289
+ t = "Invalid input";
290
+ break;
291
+ case c.invalid_union_discriminator:
292
+ t = `Invalid discriminator value. Expected ${x.joinValues(r.options)}`;
293
+ break;
294
+ case c.invalid_enum_value:
295
+ t = `Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;
296
+ break;
297
+ case c.invalid_arguments:
298
+ t = "Invalid function arguments";
299
+ break;
300
+ case c.invalid_return_type:
301
+ t = "Invalid function return type";
302
+ break;
303
+ case c.invalid_date:
304
+ t = "Invalid date";
305
+ break;
306
+ case c.invalid_string:
307
+ typeof r.validation == "object" ? "includes" in r.validation ? (t = `Invalid input: must include "${r.validation.includes}"`, typeof r.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${r.validation.position}`)) : "startsWith" in r.validation ? t = `Invalid input: must start with "${r.validation.startsWith}"` : "endsWith" in r.validation ? t = `Invalid input: must end with "${r.validation.endsWith}"` : x.assertNever(r.validation) : r.validation !== "regex" ? t = `Invalid ${r.validation}` : t = "Invalid";
308
+ break;
309
+ case c.too_small:
310
+ r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "more than"} ${r.minimum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at least" : "over"} ${r.minimum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${r.minimum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly equal to " : r.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(r.minimum))}` : t = "Invalid input";
311
+ break;
312
+ case c.too_big:
313
+ r.type === "array" ? t = `Array must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "less than"} ${r.maximum} element(s)` : r.type === "string" ? t = `String must contain ${r.exact ? "exactly" : r.inclusive ? "at most" : "under"} ${r.maximum} character(s)` : r.type === "number" ? t = `Number must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "bigint" ? t = `BigInt must be ${r.exact ? "exactly" : r.inclusive ? "less than or equal to" : "less than"} ${r.maximum}` : r.type === "date" ? t = `Date must be ${r.exact ? "exactly" : r.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(r.maximum))}` : t = "Invalid input";
314
+ break;
315
+ case c.custom:
316
+ t = "Invalid input";
317
+ break;
318
+ case c.invalid_intersection_types:
319
+ t = "Intersection results could not be merged";
320
+ break;
321
+ case c.not_multiple_of:
322
+ t = `Number must be a multiple of ${r.multipleOf}`;
323
+ break;
324
+ case c.not_finite:
325
+ t = "Number must be finite";
326
+ break;
327
+ default:
328
+ t = e.defaultError, x.assertNever(r);
329
+ }
330
+ return { message: t };
36
331
  };
37
- function x(t, e = !1) {
38
- C.options = e ? t : T(C.options, t);
39
- }
40
- function z(t, e = !1) {
41
- C.polyfills = e ? t : T(C.polyfills, t);
42
- }
43
- function F(t) {
44
- C.errorType = t;
45
- }
46
- const L = (t) => (e) => t.reduceRight((n, o) => o(n), e) || e;
47
- class k extends Error {
48
- }
49
- const N = (t) => {
50
- const e = /* @__PURE__ */ Object.create(null);
51
- t = t._addons.reduce((r, s) => s.beforeRequest && s.beforeRequest(r, t._options, e) || r, t);
52
- const { _url: n, _options: o, _config: i, _catchers: l, _resolvers: h, _middlewares: f, _addons: u } = t, a = new Map(l), m = T(i.options, o);
53
- let v = n;
54
- const E = L(f)((r, s) => (v = r, i.polyfill("fetch")(r, s)))(n, m), d = new Error(), g = E.catch((r) => {
55
- throw { [w]: r };
56
- }).then((r) => {
57
- var s;
58
- if (!r.ok) {
59
- const c = new k();
60
- if (c.cause = d, c.stack = c.stack + `
61
- CAUSE: ` + d.stack, c.response = r, c.status = r.status, c.url = v, r.type === "opaque")
62
- throw c;
63
- const p = i.errorType === "json" || ((s = r.headers.get("Content-Type")) === null || s === void 0 ? void 0 : s.split(";")[0]) === "application/json";
64
- return (i.errorType ? p ? r.text() : r[i.errorType]() : Promise.resolve(r.body)).then((y) => {
65
- throw c.message = typeof y == "string" ? y : r.statusText, y && (p && typeof y == "string" ? (c.text = y, c.json = JSON.parse(y)) : c[i.errorType] = y), c;
332
+ let qe = X;
333
+ function ht(r) {
334
+ qe = r;
335
+ }
336
+ function xe() {
337
+ return qe;
338
+ }
339
+ const be = (r) => {
340
+ const { data: e, path: t, errorMaps: n, issueData: s } = r, a = [...t, ...s.path || []], o = {
341
+ ...s,
342
+ path: a
343
+ };
344
+ if (s.message !== void 0)
345
+ return {
346
+ ...s,
347
+ path: a,
348
+ message: s.message
349
+ };
350
+ let i = "";
351
+ const u = n.filter((d) => !!d).slice().reverse();
352
+ for (const d of u)
353
+ i = d(o, { data: e, defaultError: i }).message;
354
+ return {
355
+ ...s,
356
+ path: a,
357
+ message: i
358
+ };
359
+ }, pt = [];
360
+ function l(r, e) {
361
+ const t = xe(), n = be({
362
+ issueData: e,
363
+ data: r.data,
364
+ path: r.path,
365
+ errorMaps: [
366
+ r.common.contextualErrorMap,
367
+ r.schemaErrorMap,
368
+ t,
369
+ t === X ? void 0 : X
370
+ // then global default map
371
+ ].filter((s) => !!s)
372
+ });
373
+ r.common.issues.push(n);
374
+ }
375
+ class T {
376
+ constructor() {
377
+ this.value = "valid";
378
+ }
379
+ dirty() {
380
+ this.value === "valid" && (this.value = "dirty");
381
+ }
382
+ abort() {
383
+ this.value !== "aborted" && (this.value = "aborted");
384
+ }
385
+ static mergeArray(e, t) {
386
+ const n = [];
387
+ for (const s of t) {
388
+ if (s.status === "aborted")
389
+ return y;
390
+ s.status === "dirty" && e.dirty(), n.push(s.value);
391
+ }
392
+ return { status: e.value, value: n };
393
+ }
394
+ static async mergeObjectAsync(e, t) {
395
+ const n = [];
396
+ for (const s of t) {
397
+ const a = await s.key, o = await s.value;
398
+ n.push({
399
+ key: a,
400
+ value: o
66
401
  });
67
402
  }
68
- return r;
69
- }), P = (r) => r.catch((s) => {
70
- const c = Object.prototype.hasOwnProperty.call(s, w), p = c ? s[w] : s, A = (p == null ? void 0 : p.status) && a.get(p.status) || a.get(p == null ? void 0 : p.name) || c && a.has(w) && a.get(w);
71
- if (A)
72
- return A(p, t);
73
- const y = a.get(M);
74
- if (y)
75
- return y(p, t);
76
- throw p;
77
- }), _ = (r) => (s) => /* If a callback is provided, then callback with the body result otherwise return the parsed body itself. */ P(r ? g.then((c) => c && c[r]()).then((c) => s ? s(c) : c) : g.then((c) => s ? s(c) : c)), O = {
78
- _wretchReq: t,
79
- _fetchReq: E,
80
- _sharedState: e,
81
- res: _(null),
82
- json: _("json"),
83
- blob: _("blob"),
84
- formData: _("formData"),
85
- arrayBuffer: _("arrayBuffer"),
86
- text: _("text"),
87
- error(r, s) {
88
- return a.set(r, s), this;
89
- },
90
- badRequest(r) {
91
- return this.error(400, r);
92
- },
93
- unauthorized(r) {
94
- return this.error(401, r);
95
- },
96
- forbidden(r) {
97
- return this.error(403, r);
98
- },
99
- notFound(r) {
100
- return this.error(404, r);
101
- },
102
- timeout(r) {
103
- return this.error(408, r);
104
- },
105
- internalError(r) {
106
- return this.error(500, r);
107
- },
108
- fetchError(r) {
109
- return this.error(w, r);
403
+ return T.mergeObjectSync(e, n);
404
+ }
405
+ static mergeObjectSync(e, t) {
406
+ const n = {};
407
+ for (const s of t) {
408
+ const { key: a, value: o } = s;
409
+ if (a.status === "aborted" || o.status === "aborted")
410
+ return y;
411
+ a.status === "dirty" && e.dirty(), o.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof o.value < "u" || s.alwaysSet) && (n[a.value] = o.value);
110
412
  }
111
- }, b = u.reduce((r, s) => ({
112
- ...r,
113
- ...typeof s.resolver == "function" ? s.resolver(r) : s.resolver
114
- }), O);
115
- return h.reduce((r, s) => s(r, t), b);
116
- }, B = {
117
- _url: "",
118
- _options: {},
119
- _config: C,
120
- _catchers: /* @__PURE__ */ new Map(),
121
- _resolvers: [],
122
- _deferred: [],
123
- _middlewares: [],
124
- _addons: [],
125
- addon(t) {
126
- return { ...this, _addons: [...this._addons, t], ...t.wretch };
127
- },
128
- errorType(t) {
129
- return {
130
- ...this,
131
- _config: {
132
- ...this._config,
133
- errorType: t
134
- }
413
+ return { status: e.value, value: n };
414
+ }
415
+ }
416
+ const y = Object.freeze({
417
+ status: "aborted"
418
+ }), H = (r) => ({ status: "dirty", value: r }), Z = (r) => ({ status: "valid", value: r }), Ve = (r) => r.status === "aborted", De = (r) => r.status === "dirty", se = (r) => r.status === "valid", ae = (r) => typeof Promise < "u" && r instanceof Promise;
419
+ function ke(r, e, t, n) {
420
+ if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
421
+ return e.get(r);
422
+ }
423
+ function Je(r, e, t, n, s) {
424
+ if (typeof e == "function" ? r !== e || !s : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
425
+ return e.set(r, t), t;
426
+ }
427
+ var m;
428
+ (function(r) {
429
+ r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
430
+ })(m || (m = {}));
431
+ var re, ne;
432
+ class R {
433
+ constructor(e, t, n, s) {
434
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = s;
435
+ }
436
+ get path() {
437
+ return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
438
+ }
439
+ }
440
+ const ze = (r, e) => {
441
+ if (se(e))
442
+ return { success: !0, data: e.value };
443
+ if (!r.common.issues.length)
444
+ throw new Error("Validation failed but no issues detected.");
445
+ return {
446
+ success: !1,
447
+ get error() {
448
+ if (this._error)
449
+ return this._error;
450
+ const t = new S(r.common.issues);
451
+ return this._error = t, this._error;
452
+ }
453
+ };
454
+ };
455
+ function v(r) {
456
+ if (!r)
457
+ return {};
458
+ const { errorMap: e, invalid_type_error: t, required_error: n, description: s } = r;
459
+ if (e && (t || n))
460
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
461
+ return e ? { errorMap: e, description: s } : { errorMap: (o, i) => {
462
+ var u, d;
463
+ const { message: h } = r;
464
+ return o.code === "invalid_enum_value" ? { message: h ?? i.defaultError } : typeof i.data > "u" ? { message: (u = h ?? n) !== null && u !== void 0 ? u : i.defaultError } : o.code !== "invalid_type" ? { message: i.defaultError } : { message: (d = h ?? t) !== null && d !== void 0 ? d : i.defaultError };
465
+ }, description: s };
466
+ }
467
+ class g {
468
+ constructor(e) {
469
+ 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);
470
+ }
471
+ get description() {
472
+ return this._def.description;
473
+ }
474
+ _getType(e) {
475
+ return V(e.data);
476
+ }
477
+ _getOrReturnCtx(e, t) {
478
+ return t || {
479
+ common: e.parent.common,
480
+ data: e.data,
481
+ parsedType: V(e.data),
482
+ schemaErrorMap: this._def.errorMap,
483
+ path: e.path,
484
+ parent: e.parent
135
485
  };
136
- },
137
- polyfills(t, e = !1) {
486
+ }
487
+ _processInputParams(e) {
138
488
  return {
139
- ...this,
140
- _config: {
141
- ...this._config,
142
- polyfills: e ? t : T(this._config.polyfills, t)
489
+ status: new T(),
490
+ ctx: {
491
+ common: e.parent.common,
492
+ data: e.data,
493
+ parsedType: V(e.data),
494
+ schemaErrorMap: this._def.errorMap,
495
+ path: e.path,
496
+ parent: e.parent
143
497
  }
144
498
  };
145
- },
146
- url(t, e = !1) {
147
- if (e)
148
- return { ...this, _url: t };
149
- const n = this._url.split("?");
150
- return {
151
- ...this,
152
- _url: n.length > 1 ? n[0] + t + "?" + n[1] : this._url + t
153
- };
154
- },
155
- options(t, e = !1) {
156
- return { ...this, _options: e ? t : T(this._options, t) };
157
- },
158
- headers(t) {
159
- const e = t ? Array.isArray(t) ? Object.fromEntries(t) : "entries" in t ? Object.fromEntries(t.entries()) : t : {};
160
- return { ...this, _options: T(this._options, { headers: e }) };
161
- },
162
- accept(t) {
163
- return this.headers({ Accept: t });
164
- },
165
- content(t) {
166
- return this.headers({ [D]: t });
167
- },
168
- auth(t) {
169
- return this.headers({ Authorization: t });
170
- },
171
- catcher(t, e) {
172
- const n = new Map(this._catchers);
173
- return n.set(t, e), { ...this, _catchers: n };
174
- },
175
- catcherFallback(t) {
176
- return this.catcher(M, t);
177
- },
178
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
179
- resolve(t, e = !1) {
180
- return { ...this, _resolvers: e ? [t] : [...this._resolvers, t] };
181
- },
182
- defer(t, e = !1) {
499
+ }
500
+ _parseSync(e) {
501
+ const t = this._parse(e);
502
+ if (ae(t))
503
+ throw new Error("Synchronous parse encountered promise.");
504
+ return t;
505
+ }
506
+ _parseAsync(e) {
507
+ const t = this._parse(e);
508
+ return Promise.resolve(t);
509
+ }
510
+ parse(e, t) {
511
+ const n = this.safeParse(e, t);
512
+ if (n.success)
513
+ return n.data;
514
+ throw n.error;
515
+ }
516
+ safeParse(e, t) {
517
+ var n;
518
+ const s = {
519
+ common: {
520
+ issues: [],
521
+ async: (n = t == null ? void 0 : t.async) !== null && n !== void 0 ? n : !1,
522
+ contextualErrorMap: t == null ? void 0 : t.errorMap
523
+ },
524
+ path: (t == null ? void 0 : t.path) || [],
525
+ schemaErrorMap: this._def.errorMap,
526
+ parent: null,
527
+ data: e,
528
+ parsedType: V(e)
529
+ }, a = this._parseSync({ data: e, path: s.path, parent: s });
530
+ return ze(s, a);
531
+ }
532
+ async parseAsync(e, t) {
533
+ const n = await this.safeParseAsync(e, t);
534
+ if (n.success)
535
+ return n.data;
536
+ throw n.error;
537
+ }
538
+ async safeParseAsync(e, t) {
539
+ const n = {
540
+ common: {
541
+ issues: [],
542
+ contextualErrorMap: t == null ? void 0 : t.errorMap,
543
+ async: !0
544
+ },
545
+ path: (t == null ? void 0 : t.path) || [],
546
+ schemaErrorMap: this._def.errorMap,
547
+ parent: null,
548
+ data: e,
549
+ parsedType: V(e)
550
+ }, s = this._parse({ data: e, path: n.path, parent: n }), a = await (ae(s) ? s : Promise.resolve(s));
551
+ return ze(n, a);
552
+ }
553
+ refine(e, t) {
554
+ const n = (s) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(s) : t;
555
+ return this._refinement((s, a) => {
556
+ const o = e(s), i = () => a.addIssue({
557
+ code: c.custom,
558
+ ...n(s)
559
+ });
560
+ return typeof Promise < "u" && o instanceof Promise ? o.then((u) => u ? !0 : (i(), !1)) : o ? !0 : (i(), !1);
561
+ });
562
+ }
563
+ refinement(e, t) {
564
+ return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof t == "function" ? t(n, s) : t), !1));
565
+ }
566
+ _refinement(e) {
567
+ return new C({
568
+ schema: this,
569
+ typeName: _.ZodEffects,
570
+ effect: { type: "refinement", refinement: e }
571
+ });
572
+ }
573
+ superRefine(e) {
574
+ return this._refinement(e);
575
+ }
576
+ optional() {
577
+ return N.create(this, this._def);
578
+ }
579
+ nullable() {
580
+ return z.create(this, this._def);
581
+ }
582
+ nullish() {
583
+ return this.nullable().optional();
584
+ }
585
+ array() {
586
+ return j.create(this, this._def);
587
+ }
588
+ promise() {
589
+ return Q.create(this, this._def);
590
+ }
591
+ or(e) {
592
+ return ce.create([this, e], this._def);
593
+ }
594
+ and(e) {
595
+ return ue.create(this, e, this._def);
596
+ }
597
+ transform(e) {
598
+ return new C({
599
+ ...v(this._def),
600
+ schema: this,
601
+ typeName: _.ZodEffects,
602
+ effect: { type: "transform", transform: e }
603
+ });
604
+ }
605
+ default(e) {
606
+ const t = typeof e == "function" ? e : () => e;
607
+ return new me({
608
+ ...v(this._def),
609
+ innerType: this,
610
+ defaultValue: t,
611
+ typeName: _.ZodDefault
612
+ });
613
+ }
614
+ brand() {
615
+ return new Ue({
616
+ typeName: _.ZodBranded,
617
+ type: this,
618
+ ...v(this._def)
619
+ });
620
+ }
621
+ catch(e) {
622
+ const t = typeof e == "function" ? e : () => e;
623
+ return new _e({
624
+ ...v(this._def),
625
+ innerType: this,
626
+ catchValue: t,
627
+ typeName: _.ZodCatch
628
+ });
629
+ }
630
+ describe(e) {
631
+ const t = this.constructor;
632
+ return new t({
633
+ ...this._def,
634
+ description: e
635
+ });
636
+ }
637
+ pipe(e) {
638
+ return ve.create(this, e);
639
+ }
640
+ readonly() {
641
+ return ye.create(this);
642
+ }
643
+ isOptional() {
644
+ return this.safeParse(void 0).success;
645
+ }
646
+ isNullable() {
647
+ return this.safeParse(null).success;
648
+ }
649
+ }
650
+ const mt = /^c[^\s-]{8,}$/i, _t = /^[0-9a-z]+$/, yt = /^[0-9A-HJKMNP-TV-Z]{26}$/, vt = /^[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, gt = /^[a-z0-9_-]{21}$/i, xt = /^[-+]?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)?)??$/, bt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
651
+ let Pe;
652
+ const wt = /^(?:(?: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])$/, Tt = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, Zt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ye = "((\\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])))", St = new RegExp(`^${Ye}$`);
653
+ function He(r) {
654
+ let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
655
+ return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
656
+ }
657
+ function Ot(r) {
658
+ return new RegExp(`^${He(r)}$`);
659
+ }
660
+ function Ge(r) {
661
+ let e = `${Ye}T${He(r)}`;
662
+ const t = [];
663
+ return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
664
+ }
665
+ function Et(r, e) {
666
+ return !!((e === "v4" || !e) && wt.test(r) || (e === "v6" || !e) && Tt.test(r));
667
+ }
668
+ class E extends g {
669
+ _parse(e) {
670
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
671
+ const a = this._getOrReturnCtx(e);
672
+ return l(a, {
673
+ code: c.invalid_type,
674
+ expected: f.string,
675
+ received: a.parsedType
676
+ }), y;
677
+ }
678
+ const n = new T();
679
+ let s;
680
+ for (const a of this._def.checks)
681
+ if (a.kind === "min")
682
+ e.data.length < a.value && (s = this._getOrReturnCtx(e, s), l(s, {
683
+ code: c.too_small,
684
+ minimum: a.value,
685
+ type: "string",
686
+ inclusive: !0,
687
+ exact: !1,
688
+ message: a.message
689
+ }), n.dirty());
690
+ else if (a.kind === "max")
691
+ e.data.length > a.value && (s = this._getOrReturnCtx(e, s), l(s, {
692
+ code: c.too_big,
693
+ maximum: a.value,
694
+ type: "string",
695
+ inclusive: !0,
696
+ exact: !1,
697
+ message: a.message
698
+ }), n.dirty());
699
+ else if (a.kind === "length") {
700
+ const o = e.data.length > a.value, i = e.data.length < a.value;
701
+ (o || i) && (s = this._getOrReturnCtx(e, s), o ? l(s, {
702
+ code: c.too_big,
703
+ maximum: a.value,
704
+ type: "string",
705
+ inclusive: !0,
706
+ exact: !0,
707
+ message: a.message
708
+ }) : i && l(s, {
709
+ code: c.too_small,
710
+ minimum: a.value,
711
+ type: "string",
712
+ inclusive: !0,
713
+ exact: !0,
714
+ message: a.message
715
+ }), n.dirty());
716
+ } else if (a.kind === "email")
717
+ bt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
718
+ validation: "email",
719
+ code: c.invalid_string,
720
+ message: a.message
721
+ }), n.dirty());
722
+ else if (a.kind === "emoji")
723
+ Pe || (Pe = new RegExp(kt, "u")), Pe.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
724
+ validation: "emoji",
725
+ code: c.invalid_string,
726
+ message: a.message
727
+ }), n.dirty());
728
+ else if (a.kind === "uuid")
729
+ vt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
730
+ validation: "uuid",
731
+ code: c.invalid_string,
732
+ message: a.message
733
+ }), n.dirty());
734
+ else if (a.kind === "nanoid")
735
+ gt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
736
+ validation: "nanoid",
737
+ code: c.invalid_string,
738
+ message: a.message
739
+ }), n.dirty());
740
+ else if (a.kind === "cuid")
741
+ mt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
742
+ validation: "cuid",
743
+ code: c.invalid_string,
744
+ message: a.message
745
+ }), n.dirty());
746
+ else if (a.kind === "cuid2")
747
+ _t.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
748
+ validation: "cuid2",
749
+ code: c.invalid_string,
750
+ message: a.message
751
+ }), n.dirty());
752
+ else if (a.kind === "ulid")
753
+ yt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
754
+ validation: "ulid",
755
+ code: c.invalid_string,
756
+ message: a.message
757
+ }), n.dirty());
758
+ else if (a.kind === "url")
759
+ try {
760
+ new URL(e.data);
761
+ } catch {
762
+ s = this._getOrReturnCtx(e, s), l(s, {
763
+ validation: "url",
764
+ code: c.invalid_string,
765
+ message: a.message
766
+ }), n.dirty();
767
+ }
768
+ else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
769
+ validation: "regex",
770
+ code: c.invalid_string,
771
+ message: a.message
772
+ }), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), l(s, {
773
+ code: c.invalid_string,
774
+ validation: { includes: a.value, position: a.position },
775
+ message: a.message
776
+ }), n.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), l(s, {
777
+ code: c.invalid_string,
778
+ validation: { startsWith: a.value },
779
+ message: a.message
780
+ }), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), l(s, {
781
+ code: c.invalid_string,
782
+ validation: { endsWith: a.value },
783
+ message: a.message
784
+ }), n.dirty()) : a.kind === "datetime" ? Ge(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
785
+ code: c.invalid_string,
786
+ validation: "datetime",
787
+ message: a.message
788
+ }), n.dirty()) : a.kind === "date" ? St.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
789
+ code: c.invalid_string,
790
+ validation: "date",
791
+ message: a.message
792
+ }), n.dirty()) : a.kind === "time" ? Ot(a).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
793
+ code: c.invalid_string,
794
+ validation: "time",
795
+ message: a.message
796
+ }), n.dirty()) : a.kind === "duration" ? xt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
797
+ validation: "duration",
798
+ code: c.invalid_string,
799
+ message: a.message
800
+ }), n.dirty()) : a.kind === "ip" ? Et(e.data, a.version) || (s = this._getOrReturnCtx(e, s), l(s, {
801
+ validation: "ip",
802
+ code: c.invalid_string,
803
+ message: a.message
804
+ }), n.dirty()) : a.kind === "base64" ? Zt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
805
+ validation: "base64",
806
+ code: c.invalid_string,
807
+ message: a.message
808
+ }), n.dirty()) : x.assertNever(a);
809
+ return { status: n.value, value: e.data };
810
+ }
811
+ _regex(e, t, n) {
812
+ return this.refinement((s) => e.test(s), {
813
+ validation: t,
814
+ code: c.invalid_string,
815
+ ...m.errToObj(n)
816
+ });
817
+ }
818
+ _addCheck(e) {
819
+ return new E({
820
+ ...this._def,
821
+ checks: [...this._def.checks, e]
822
+ });
823
+ }
824
+ email(e) {
825
+ return this._addCheck({ kind: "email", ...m.errToObj(e) });
826
+ }
827
+ url(e) {
828
+ return this._addCheck({ kind: "url", ...m.errToObj(e) });
829
+ }
830
+ emoji(e) {
831
+ return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
832
+ }
833
+ uuid(e) {
834
+ return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
835
+ }
836
+ nanoid(e) {
837
+ return this._addCheck({ kind: "nanoid", ...m.errToObj(e) });
838
+ }
839
+ cuid(e) {
840
+ return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
841
+ }
842
+ cuid2(e) {
843
+ return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
844
+ }
845
+ ulid(e) {
846
+ return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
847
+ }
848
+ base64(e) {
849
+ return this._addCheck({ kind: "base64", ...m.errToObj(e) });
850
+ }
851
+ ip(e) {
852
+ return this._addCheck({ kind: "ip", ...m.errToObj(e) });
853
+ }
854
+ datetime(e) {
855
+ var t, n;
856
+ return typeof e == "string" ? this._addCheck({
857
+ kind: "datetime",
858
+ precision: null,
859
+ offset: !1,
860
+ local: !1,
861
+ message: e
862
+ }) : this._addCheck({
863
+ kind: "datetime",
864
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
865
+ offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
866
+ local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
867
+ ...m.errToObj(e == null ? void 0 : e.message)
868
+ });
869
+ }
870
+ date(e) {
871
+ return this._addCheck({ kind: "date", message: e });
872
+ }
873
+ time(e) {
874
+ return typeof e == "string" ? this._addCheck({
875
+ kind: "time",
876
+ precision: null,
877
+ message: e
878
+ }) : this._addCheck({
879
+ kind: "time",
880
+ precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
881
+ ...m.errToObj(e == null ? void 0 : e.message)
882
+ });
883
+ }
884
+ duration(e) {
885
+ return this._addCheck({ kind: "duration", ...m.errToObj(e) });
886
+ }
887
+ regex(e, t) {
888
+ return this._addCheck({
889
+ kind: "regex",
890
+ regex: e,
891
+ ...m.errToObj(t)
892
+ });
893
+ }
894
+ includes(e, t) {
895
+ return this._addCheck({
896
+ kind: "includes",
897
+ value: e,
898
+ position: t == null ? void 0 : t.position,
899
+ ...m.errToObj(t == null ? void 0 : t.message)
900
+ });
901
+ }
902
+ startsWith(e, t) {
903
+ return this._addCheck({
904
+ kind: "startsWith",
905
+ value: e,
906
+ ...m.errToObj(t)
907
+ });
908
+ }
909
+ endsWith(e, t) {
910
+ return this._addCheck({
911
+ kind: "endsWith",
912
+ value: e,
913
+ ...m.errToObj(t)
914
+ });
915
+ }
916
+ min(e, t) {
917
+ return this._addCheck({
918
+ kind: "min",
919
+ value: e,
920
+ ...m.errToObj(t)
921
+ });
922
+ }
923
+ max(e, t) {
924
+ return this._addCheck({
925
+ kind: "max",
926
+ value: e,
927
+ ...m.errToObj(t)
928
+ });
929
+ }
930
+ length(e, t) {
931
+ return this._addCheck({
932
+ kind: "length",
933
+ value: e,
934
+ ...m.errToObj(t)
935
+ });
936
+ }
937
+ /**
938
+ * @deprecated Use z.string().min(1) instead.
939
+ * @see {@link ZodString.min}
940
+ */
941
+ nonempty(e) {
942
+ return this.min(1, m.errToObj(e));
943
+ }
944
+ trim() {
945
+ return new E({
946
+ ...this._def,
947
+ checks: [...this._def.checks, { kind: "trim" }]
948
+ });
949
+ }
950
+ toLowerCase() {
951
+ return new E({
952
+ ...this._def,
953
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
954
+ });
955
+ }
956
+ toUpperCase() {
957
+ return new E({
958
+ ...this._def,
959
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
960
+ });
961
+ }
962
+ get isDatetime() {
963
+ return !!this._def.checks.find((e) => e.kind === "datetime");
964
+ }
965
+ get isDate() {
966
+ return !!this._def.checks.find((e) => e.kind === "date");
967
+ }
968
+ get isTime() {
969
+ return !!this._def.checks.find((e) => e.kind === "time");
970
+ }
971
+ get isDuration() {
972
+ return !!this._def.checks.find((e) => e.kind === "duration");
973
+ }
974
+ get isEmail() {
975
+ return !!this._def.checks.find((e) => e.kind === "email");
976
+ }
977
+ get isURL() {
978
+ return !!this._def.checks.find((e) => e.kind === "url");
979
+ }
980
+ get isEmoji() {
981
+ return !!this._def.checks.find((e) => e.kind === "emoji");
982
+ }
983
+ get isUUID() {
984
+ return !!this._def.checks.find((e) => e.kind === "uuid");
985
+ }
986
+ get isNANOID() {
987
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
988
+ }
989
+ get isCUID() {
990
+ return !!this._def.checks.find((e) => e.kind === "cuid");
991
+ }
992
+ get isCUID2() {
993
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
994
+ }
995
+ get isULID() {
996
+ return !!this._def.checks.find((e) => e.kind === "ulid");
997
+ }
998
+ get isIP() {
999
+ return !!this._def.checks.find((e) => e.kind === "ip");
1000
+ }
1001
+ get isBase64() {
1002
+ return !!this._def.checks.find((e) => e.kind === "base64");
1003
+ }
1004
+ get minLength() {
1005
+ let e = null;
1006
+ for (const t of this._def.checks)
1007
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1008
+ return e;
1009
+ }
1010
+ get maxLength() {
1011
+ let e = null;
1012
+ for (const t of this._def.checks)
1013
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1014
+ return e;
1015
+ }
1016
+ }
1017
+ E.create = (r) => {
1018
+ var e;
1019
+ return new E({
1020
+ checks: [],
1021
+ typeName: _.ZodString,
1022
+ coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
1023
+ ...v(r)
1024
+ });
1025
+ };
1026
+ function jt(r, e) {
1027
+ const t = (r.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = t > n ? t : n, a = parseInt(r.toFixed(s).replace(".", "")), o = parseInt(e.toFixed(s).replace(".", ""));
1028
+ return a % o / Math.pow(10, s);
1029
+ }
1030
+ class D extends g {
1031
+ constructor() {
1032
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1033
+ }
1034
+ _parse(e) {
1035
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1036
+ const a = this._getOrReturnCtx(e);
1037
+ return l(a, {
1038
+ code: c.invalid_type,
1039
+ expected: f.number,
1040
+ received: a.parsedType
1041
+ }), y;
1042
+ }
1043
+ let n;
1044
+ const s = new T();
1045
+ for (const a of this._def.checks)
1046
+ a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
1047
+ code: c.invalid_type,
1048
+ expected: "integer",
1049
+ received: "float",
1050
+ message: a.message
1051
+ }), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1052
+ code: c.too_small,
1053
+ minimum: a.value,
1054
+ type: "number",
1055
+ inclusive: a.inclusive,
1056
+ exact: !1,
1057
+ message: a.message
1058
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1059
+ code: c.too_big,
1060
+ maximum: a.value,
1061
+ type: "number",
1062
+ inclusive: a.inclusive,
1063
+ exact: !1,
1064
+ message: a.message
1065
+ }), s.dirty()) : a.kind === "multipleOf" ? jt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
1066
+ code: c.not_multiple_of,
1067
+ multipleOf: a.value,
1068
+ message: a.message
1069
+ }), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
1070
+ code: c.not_finite,
1071
+ message: a.message
1072
+ }), s.dirty()) : x.assertNever(a);
1073
+ return { status: s.value, value: e.data };
1074
+ }
1075
+ gte(e, t) {
1076
+ return this.setLimit("min", e, !0, m.toString(t));
1077
+ }
1078
+ gt(e, t) {
1079
+ return this.setLimit("min", e, !1, m.toString(t));
1080
+ }
1081
+ lte(e, t) {
1082
+ return this.setLimit("max", e, !0, m.toString(t));
1083
+ }
1084
+ lt(e, t) {
1085
+ return this.setLimit("max", e, !1, m.toString(t));
1086
+ }
1087
+ setLimit(e, t, n, s) {
1088
+ return new D({
1089
+ ...this._def,
1090
+ checks: [
1091
+ ...this._def.checks,
1092
+ {
1093
+ kind: e,
1094
+ value: t,
1095
+ inclusive: n,
1096
+ message: m.toString(s)
1097
+ }
1098
+ ]
1099
+ });
1100
+ }
1101
+ _addCheck(e) {
1102
+ return new D({
1103
+ ...this._def,
1104
+ checks: [...this._def.checks, e]
1105
+ });
1106
+ }
1107
+ int(e) {
1108
+ return this._addCheck({
1109
+ kind: "int",
1110
+ message: m.toString(e)
1111
+ });
1112
+ }
1113
+ positive(e) {
1114
+ return this._addCheck({
1115
+ kind: "min",
1116
+ value: 0,
1117
+ inclusive: !1,
1118
+ message: m.toString(e)
1119
+ });
1120
+ }
1121
+ negative(e) {
1122
+ return this._addCheck({
1123
+ kind: "max",
1124
+ value: 0,
1125
+ inclusive: !1,
1126
+ message: m.toString(e)
1127
+ });
1128
+ }
1129
+ nonpositive(e) {
1130
+ return this._addCheck({
1131
+ kind: "max",
1132
+ value: 0,
1133
+ inclusive: !0,
1134
+ message: m.toString(e)
1135
+ });
1136
+ }
1137
+ nonnegative(e) {
1138
+ return this._addCheck({
1139
+ kind: "min",
1140
+ value: 0,
1141
+ inclusive: !0,
1142
+ message: m.toString(e)
1143
+ });
1144
+ }
1145
+ multipleOf(e, t) {
1146
+ return this._addCheck({
1147
+ kind: "multipleOf",
1148
+ value: e,
1149
+ message: m.toString(t)
1150
+ });
1151
+ }
1152
+ finite(e) {
1153
+ return this._addCheck({
1154
+ kind: "finite",
1155
+ message: m.toString(e)
1156
+ });
1157
+ }
1158
+ safe(e) {
1159
+ return this._addCheck({
1160
+ kind: "min",
1161
+ inclusive: !0,
1162
+ value: Number.MIN_SAFE_INTEGER,
1163
+ message: m.toString(e)
1164
+ })._addCheck({
1165
+ kind: "max",
1166
+ inclusive: !0,
1167
+ value: Number.MAX_SAFE_INTEGER,
1168
+ message: m.toString(e)
1169
+ });
1170
+ }
1171
+ get minValue() {
1172
+ let e = null;
1173
+ for (const t of this._def.checks)
1174
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1175
+ return e;
1176
+ }
1177
+ get maxValue() {
1178
+ let e = null;
1179
+ for (const t of this._def.checks)
1180
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1181
+ return e;
1182
+ }
1183
+ get isInt() {
1184
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
1185
+ }
1186
+ get isFinite() {
1187
+ let e = null, t = null;
1188
+ for (const n of this._def.checks) {
1189
+ if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
1190
+ return !0;
1191
+ n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
1192
+ }
1193
+ return Number.isFinite(t) && Number.isFinite(e);
1194
+ }
1195
+ }
1196
+ D.create = (r) => new D({
1197
+ checks: [],
1198
+ typeName: _.ZodNumber,
1199
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1200
+ ...v(r)
1201
+ });
1202
+ class L extends g {
1203
+ constructor() {
1204
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1205
+ }
1206
+ _parse(e) {
1207
+ if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== f.bigint) {
1208
+ const a = this._getOrReturnCtx(e);
1209
+ return l(a, {
1210
+ code: c.invalid_type,
1211
+ expected: f.bigint,
1212
+ received: a.parsedType
1213
+ }), y;
1214
+ }
1215
+ let n;
1216
+ const s = new T();
1217
+ for (const a of this._def.checks)
1218
+ a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1219
+ code: c.too_small,
1220
+ type: "bigint",
1221
+ minimum: a.value,
1222
+ inclusive: a.inclusive,
1223
+ message: a.message
1224
+ }), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
1225
+ code: c.too_big,
1226
+ type: "bigint",
1227
+ maximum: a.value,
1228
+ inclusive: a.inclusive,
1229
+ message: a.message
1230
+ }), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), l(n, {
1231
+ code: c.not_multiple_of,
1232
+ multipleOf: a.value,
1233
+ message: a.message
1234
+ }), s.dirty()) : x.assertNever(a);
1235
+ return { status: s.value, value: e.data };
1236
+ }
1237
+ gte(e, t) {
1238
+ return this.setLimit("min", e, !0, m.toString(t));
1239
+ }
1240
+ gt(e, t) {
1241
+ return this.setLimit("min", e, !1, m.toString(t));
1242
+ }
1243
+ lte(e, t) {
1244
+ return this.setLimit("max", e, !0, m.toString(t));
1245
+ }
1246
+ lt(e, t) {
1247
+ return this.setLimit("max", e, !1, m.toString(t));
1248
+ }
1249
+ setLimit(e, t, n, s) {
1250
+ return new L({
1251
+ ...this._def,
1252
+ checks: [
1253
+ ...this._def.checks,
1254
+ {
1255
+ kind: e,
1256
+ value: t,
1257
+ inclusive: n,
1258
+ message: m.toString(s)
1259
+ }
1260
+ ]
1261
+ });
1262
+ }
1263
+ _addCheck(e) {
1264
+ return new L({
1265
+ ...this._def,
1266
+ checks: [...this._def.checks, e]
1267
+ });
1268
+ }
1269
+ positive(e) {
1270
+ return this._addCheck({
1271
+ kind: "min",
1272
+ value: BigInt(0),
1273
+ inclusive: !1,
1274
+ message: m.toString(e)
1275
+ });
1276
+ }
1277
+ negative(e) {
1278
+ return this._addCheck({
1279
+ kind: "max",
1280
+ value: BigInt(0),
1281
+ inclusive: !1,
1282
+ message: m.toString(e)
1283
+ });
1284
+ }
1285
+ nonpositive(e) {
1286
+ return this._addCheck({
1287
+ kind: "max",
1288
+ value: BigInt(0),
1289
+ inclusive: !0,
1290
+ message: m.toString(e)
1291
+ });
1292
+ }
1293
+ nonnegative(e) {
1294
+ return this._addCheck({
1295
+ kind: "min",
1296
+ value: BigInt(0),
1297
+ inclusive: !0,
1298
+ message: m.toString(e)
1299
+ });
1300
+ }
1301
+ multipleOf(e, t) {
1302
+ return this._addCheck({
1303
+ kind: "multipleOf",
1304
+ value: e,
1305
+ message: m.toString(t)
1306
+ });
1307
+ }
1308
+ get minValue() {
1309
+ let e = null;
1310
+ for (const t of this._def.checks)
1311
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1312
+ return e;
1313
+ }
1314
+ get maxValue() {
1315
+ let e = null;
1316
+ for (const t of this._def.checks)
1317
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1318
+ return e;
1319
+ }
1320
+ }
1321
+ L.create = (r) => {
1322
+ var e;
1323
+ return new L({
1324
+ checks: [],
1325
+ typeName: _.ZodBigInt,
1326
+ coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1,
1327
+ ...v(r)
1328
+ });
1329
+ };
1330
+ class ie extends g {
1331
+ _parse(e) {
1332
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1333
+ const n = this._getOrReturnCtx(e);
1334
+ return l(n, {
1335
+ code: c.invalid_type,
1336
+ expected: f.boolean,
1337
+ received: n.parsedType
1338
+ }), y;
1339
+ }
1340
+ return Z(e.data);
1341
+ }
1342
+ }
1343
+ ie.create = (r) => new ie({
1344
+ typeName: _.ZodBoolean,
1345
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1346
+ ...v(r)
1347
+ });
1348
+ class q extends g {
1349
+ _parse(e) {
1350
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1351
+ const a = this._getOrReturnCtx(e);
1352
+ return l(a, {
1353
+ code: c.invalid_type,
1354
+ expected: f.date,
1355
+ received: a.parsedType
1356
+ }), y;
1357
+ }
1358
+ if (isNaN(e.data.getTime())) {
1359
+ const a = this._getOrReturnCtx(e);
1360
+ return l(a, {
1361
+ code: c.invalid_date
1362
+ }), y;
1363
+ }
1364
+ const n = new T();
1365
+ let s;
1366
+ for (const a of this._def.checks)
1367
+ a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), l(s, {
1368
+ code: c.too_small,
1369
+ message: a.message,
1370
+ inclusive: !0,
1371
+ exact: !1,
1372
+ minimum: a.value,
1373
+ type: "date"
1374
+ }), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), l(s, {
1375
+ code: c.too_big,
1376
+ message: a.message,
1377
+ inclusive: !0,
1378
+ exact: !1,
1379
+ maximum: a.value,
1380
+ type: "date"
1381
+ }), n.dirty()) : x.assertNever(a);
183
1382
  return {
184
- ...this,
185
- _deferred: e ? [t] : [...this._deferred, t]
1383
+ status: n.value,
1384
+ value: new Date(e.data.getTime())
186
1385
  };
187
- },
188
- middlewares(t, e = !1) {
189
- return {
190
- ...this,
191
- _middlewares: e ? t : [...this._middlewares, ...t]
1386
+ }
1387
+ _addCheck(e) {
1388
+ return new q({
1389
+ ...this._def,
1390
+ checks: [...this._def.checks, e]
1391
+ });
1392
+ }
1393
+ min(e, t) {
1394
+ return this._addCheck({
1395
+ kind: "min",
1396
+ value: e.getTime(),
1397
+ message: m.toString(t)
1398
+ });
1399
+ }
1400
+ max(e, t) {
1401
+ return this._addCheck({
1402
+ kind: "max",
1403
+ value: e.getTime(),
1404
+ message: m.toString(t)
1405
+ });
1406
+ }
1407
+ get minDate() {
1408
+ let e = null;
1409
+ for (const t of this._def.checks)
1410
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1411
+ return e != null ? new Date(e) : null;
1412
+ }
1413
+ get maxDate() {
1414
+ let e = null;
1415
+ for (const t of this._def.checks)
1416
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1417
+ return e != null ? new Date(e) : null;
1418
+ }
1419
+ }
1420
+ q.create = (r) => new q({
1421
+ checks: [],
1422
+ coerce: (r == null ? void 0 : r.coerce) || !1,
1423
+ typeName: _.ZodDate,
1424
+ ...v(r)
1425
+ });
1426
+ class we extends g {
1427
+ _parse(e) {
1428
+ if (this._getType(e) !== f.symbol) {
1429
+ const n = this._getOrReturnCtx(e);
1430
+ return l(n, {
1431
+ code: c.invalid_type,
1432
+ expected: f.symbol,
1433
+ received: n.parsedType
1434
+ }), y;
1435
+ }
1436
+ return Z(e.data);
1437
+ }
1438
+ }
1439
+ we.create = (r) => new we({
1440
+ typeName: _.ZodSymbol,
1441
+ ...v(r)
1442
+ });
1443
+ class oe extends g {
1444
+ _parse(e) {
1445
+ if (this._getType(e) !== f.undefined) {
1446
+ const n = this._getOrReturnCtx(e);
1447
+ return l(n, {
1448
+ code: c.invalid_type,
1449
+ expected: f.undefined,
1450
+ received: n.parsedType
1451
+ }), y;
1452
+ }
1453
+ return Z(e.data);
1454
+ }
1455
+ }
1456
+ oe.create = (r) => new oe({
1457
+ typeName: _.ZodUndefined,
1458
+ ...v(r)
1459
+ });
1460
+ class de extends g {
1461
+ _parse(e) {
1462
+ if (this._getType(e) !== f.null) {
1463
+ const n = this._getOrReturnCtx(e);
1464
+ return l(n, {
1465
+ code: c.invalid_type,
1466
+ expected: f.null,
1467
+ received: n.parsedType
1468
+ }), y;
1469
+ }
1470
+ return Z(e.data);
1471
+ }
1472
+ }
1473
+ de.create = (r) => new de({
1474
+ typeName: _.ZodNull,
1475
+ ...v(r)
1476
+ });
1477
+ class K extends g {
1478
+ constructor() {
1479
+ super(...arguments), this._any = !0;
1480
+ }
1481
+ _parse(e) {
1482
+ return Z(e.data);
1483
+ }
1484
+ }
1485
+ K.create = (r) => new K({
1486
+ typeName: _.ZodAny,
1487
+ ...v(r)
1488
+ });
1489
+ class W extends g {
1490
+ constructor() {
1491
+ super(...arguments), this._unknown = !0;
1492
+ }
1493
+ _parse(e) {
1494
+ return Z(e.data);
1495
+ }
1496
+ }
1497
+ W.create = (r) => new W({
1498
+ typeName: _.ZodUnknown,
1499
+ ...v(r)
1500
+ });
1501
+ class M extends g {
1502
+ _parse(e) {
1503
+ const t = this._getOrReturnCtx(e);
1504
+ return l(t, {
1505
+ code: c.invalid_type,
1506
+ expected: f.never,
1507
+ received: t.parsedType
1508
+ }), y;
1509
+ }
1510
+ }
1511
+ M.create = (r) => new M({
1512
+ typeName: _.ZodNever,
1513
+ ...v(r)
1514
+ });
1515
+ class Te extends g {
1516
+ _parse(e) {
1517
+ if (this._getType(e) !== f.undefined) {
1518
+ const n = this._getOrReturnCtx(e);
1519
+ return l(n, {
1520
+ code: c.invalid_type,
1521
+ expected: f.void,
1522
+ received: n.parsedType
1523
+ }), y;
1524
+ }
1525
+ return Z(e.data);
1526
+ }
1527
+ }
1528
+ Te.create = (r) => new Te({
1529
+ typeName: _.ZodVoid,
1530
+ ...v(r)
1531
+ });
1532
+ class j extends g {
1533
+ _parse(e) {
1534
+ const { ctx: t, status: n } = this._processInputParams(e), s = this._def;
1535
+ if (t.parsedType !== f.array)
1536
+ return l(t, {
1537
+ code: c.invalid_type,
1538
+ expected: f.array,
1539
+ received: t.parsedType
1540
+ }), y;
1541
+ if (s.exactLength !== null) {
1542
+ const o = t.data.length > s.exactLength.value, i = t.data.length < s.exactLength.value;
1543
+ (o || i) && (l(t, {
1544
+ code: o ? c.too_big : c.too_small,
1545
+ minimum: i ? s.exactLength.value : void 0,
1546
+ maximum: o ? s.exactLength.value : void 0,
1547
+ type: "array",
1548
+ inclusive: !0,
1549
+ exact: !0,
1550
+ message: s.exactLength.message
1551
+ }), n.dirty());
1552
+ }
1553
+ if (s.minLength !== null && t.data.length < s.minLength.value && (l(t, {
1554
+ code: c.too_small,
1555
+ minimum: s.minLength.value,
1556
+ type: "array",
1557
+ inclusive: !0,
1558
+ exact: !1,
1559
+ message: s.minLength.message
1560
+ }), n.dirty()), s.maxLength !== null && t.data.length > s.maxLength.value && (l(t, {
1561
+ code: c.too_big,
1562
+ maximum: s.maxLength.value,
1563
+ type: "array",
1564
+ inclusive: !0,
1565
+ exact: !1,
1566
+ message: s.maxLength.message
1567
+ }), n.dirty()), t.common.async)
1568
+ return Promise.all([...t.data].map((o, i) => s.type._parseAsync(new R(t, o, t.path, i)))).then((o) => T.mergeArray(n, o));
1569
+ const a = [...t.data].map((o, i) => s.type._parseSync(new R(t, o, t.path, i)));
1570
+ return T.mergeArray(n, a);
1571
+ }
1572
+ get element() {
1573
+ return this._def.type;
1574
+ }
1575
+ min(e, t) {
1576
+ return new j({
1577
+ ...this._def,
1578
+ minLength: { value: e, message: m.toString(t) }
1579
+ });
1580
+ }
1581
+ max(e, t) {
1582
+ return new j({
1583
+ ...this._def,
1584
+ maxLength: { value: e, message: m.toString(t) }
1585
+ });
1586
+ }
1587
+ length(e, t) {
1588
+ return new j({
1589
+ ...this._def,
1590
+ exactLength: { value: e, message: m.toString(t) }
1591
+ });
1592
+ }
1593
+ nonempty(e) {
1594
+ return this.min(1, e);
1595
+ }
1596
+ }
1597
+ j.create = (r, e) => new j({
1598
+ type: r,
1599
+ minLength: null,
1600
+ maxLength: null,
1601
+ exactLength: null,
1602
+ typeName: _.ZodArray,
1603
+ ...v(e)
1604
+ });
1605
+ function Y(r) {
1606
+ if (r instanceof b) {
1607
+ const e = {};
1608
+ for (const t in r.shape) {
1609
+ const n = r.shape[t];
1610
+ e[t] = N.create(Y(n));
1611
+ }
1612
+ return new b({
1613
+ ...r._def,
1614
+ shape: () => e
1615
+ });
1616
+ } else return r instanceof j ? new j({
1617
+ ...r._def,
1618
+ type: Y(r.element)
1619
+ }) : r instanceof N ? N.create(Y(r.unwrap())) : r instanceof z ? z.create(Y(r.unwrap())) : r instanceof I ? I.create(r.items.map((e) => Y(e))) : r;
1620
+ }
1621
+ class b extends g {
1622
+ constructor() {
1623
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1624
+ }
1625
+ _getCached() {
1626
+ if (this._cached !== null)
1627
+ return this._cached;
1628
+ const e = this._def.shape(), t = x.objectKeys(e);
1629
+ return this._cached = { shape: e, keys: t };
1630
+ }
1631
+ _parse(e) {
1632
+ if (this._getType(e) !== f.object) {
1633
+ const d = this._getOrReturnCtx(e);
1634
+ return l(d, {
1635
+ code: c.invalid_type,
1636
+ expected: f.object,
1637
+ received: d.parsedType
1638
+ }), y;
1639
+ }
1640
+ const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: o } = this._getCached(), i = [];
1641
+ if (!(this._def.catchall instanceof M && this._def.unknownKeys === "strip"))
1642
+ for (const d in s.data)
1643
+ o.includes(d) || i.push(d);
1644
+ const u = [];
1645
+ for (const d of o) {
1646
+ const h = a[d], k = s.data[d];
1647
+ u.push({
1648
+ key: { status: "valid", value: d },
1649
+ value: h._parse(new R(s, k, s.path, d)),
1650
+ alwaysSet: d in s.data
1651
+ });
1652
+ }
1653
+ if (this._def.catchall instanceof M) {
1654
+ const d = this._def.unknownKeys;
1655
+ if (d === "passthrough")
1656
+ for (const h of i)
1657
+ u.push({
1658
+ key: { status: "valid", value: h },
1659
+ value: { status: "valid", value: s.data[h] }
1660
+ });
1661
+ else if (d === "strict")
1662
+ i.length > 0 && (l(s, {
1663
+ code: c.unrecognized_keys,
1664
+ keys: i
1665
+ }), n.dirty());
1666
+ else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1667
+ } else {
1668
+ const d = this._def.catchall;
1669
+ for (const h of i) {
1670
+ const k = s.data[h];
1671
+ u.push({
1672
+ key: { status: "valid", value: h },
1673
+ value: d._parse(
1674
+ new R(s, k, s.path, h)
1675
+ //, ctx.child(key), value, getParsedType(value)
1676
+ ),
1677
+ alwaysSet: h in s.data
1678
+ });
1679
+ }
1680
+ }
1681
+ return s.common.async ? Promise.resolve().then(async () => {
1682
+ const d = [];
1683
+ for (const h of u) {
1684
+ const k = await h.key, O = await h.value;
1685
+ d.push({
1686
+ key: k,
1687
+ value: O,
1688
+ alwaysSet: h.alwaysSet
1689
+ });
1690
+ }
1691
+ return d;
1692
+ }).then((d) => T.mergeObjectSync(n, d)) : T.mergeObjectSync(n, u);
1693
+ }
1694
+ get shape() {
1695
+ return this._def.shape();
1696
+ }
1697
+ strict(e) {
1698
+ return m.errToObj, new b({
1699
+ ...this._def,
1700
+ unknownKeys: "strict",
1701
+ ...e !== void 0 ? {
1702
+ errorMap: (t, n) => {
1703
+ var s, a, o, i;
1704
+ const u = (o = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, t, n).message) !== null && o !== void 0 ? o : n.defaultError;
1705
+ return t.code === "unrecognized_keys" ? {
1706
+ message: (i = m.errToObj(e).message) !== null && i !== void 0 ? i : u
1707
+ } : {
1708
+ message: u
1709
+ };
1710
+ }
1711
+ } : {}
1712
+ });
1713
+ }
1714
+ strip() {
1715
+ return new b({
1716
+ ...this._def,
1717
+ unknownKeys: "strip"
1718
+ });
1719
+ }
1720
+ passthrough() {
1721
+ return new b({
1722
+ ...this._def,
1723
+ unknownKeys: "passthrough"
1724
+ });
1725
+ }
1726
+ // const AugmentFactory =
1727
+ // <Def extends ZodObjectDef>(def: Def) =>
1728
+ // <Augmentation extends ZodRawShape>(
1729
+ // augmentation: Augmentation
1730
+ // ): ZodObject<
1731
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1732
+ // Def["unknownKeys"],
1733
+ // Def["catchall"]
1734
+ // > => {
1735
+ // return new ZodObject({
1736
+ // ...def,
1737
+ // shape: () => ({
1738
+ // ...def.shape(),
1739
+ // ...augmentation,
1740
+ // }),
1741
+ // }) as any;
1742
+ // };
1743
+ extend(e) {
1744
+ return new b({
1745
+ ...this._def,
1746
+ shape: () => ({
1747
+ ...this._def.shape(),
1748
+ ...e
1749
+ })
1750
+ });
1751
+ }
1752
+ /**
1753
+ * Prior to zod@1.0.12 there was a bug in the
1754
+ * inferred type of merged objects. Please
1755
+ * upgrade if you are experiencing issues.
1756
+ */
1757
+ merge(e) {
1758
+ return new b({
1759
+ unknownKeys: e._def.unknownKeys,
1760
+ catchall: e._def.catchall,
1761
+ shape: () => ({
1762
+ ...this._def.shape(),
1763
+ ...e._def.shape()
1764
+ }),
1765
+ typeName: _.ZodObject
1766
+ });
1767
+ }
1768
+ // merge<
1769
+ // Incoming extends AnyZodObject,
1770
+ // Augmentation extends Incoming["shape"],
1771
+ // NewOutput extends {
1772
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1773
+ // ? Augmentation[k]["_output"]
1774
+ // : k extends keyof Output
1775
+ // ? Output[k]
1776
+ // : never;
1777
+ // },
1778
+ // NewInput extends {
1779
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1780
+ // ? Augmentation[k]["_input"]
1781
+ // : k extends keyof Input
1782
+ // ? Input[k]
1783
+ // : never;
1784
+ // }
1785
+ // >(
1786
+ // merging: Incoming
1787
+ // ): ZodObject<
1788
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1789
+ // Incoming["_def"]["unknownKeys"],
1790
+ // Incoming["_def"]["catchall"],
1791
+ // NewOutput,
1792
+ // NewInput
1793
+ // > {
1794
+ // const merged: any = new ZodObject({
1795
+ // unknownKeys: merging._def.unknownKeys,
1796
+ // catchall: merging._def.catchall,
1797
+ // shape: () =>
1798
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1799
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1800
+ // }) as any;
1801
+ // return merged;
1802
+ // }
1803
+ setKey(e, t) {
1804
+ return this.augment({ [e]: t });
1805
+ }
1806
+ // merge<Incoming extends AnyZodObject>(
1807
+ // merging: Incoming
1808
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1809
+ // ZodObject<
1810
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1811
+ // Incoming["_def"]["unknownKeys"],
1812
+ // Incoming["_def"]["catchall"]
1813
+ // > {
1814
+ // // const mergedShape = objectUtil.mergeShapes(
1815
+ // // this._def.shape(),
1816
+ // // merging._def.shape()
1817
+ // // );
1818
+ // const merged: any = new ZodObject({
1819
+ // unknownKeys: merging._def.unknownKeys,
1820
+ // catchall: merging._def.catchall,
1821
+ // shape: () =>
1822
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1823
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1824
+ // }) as any;
1825
+ // return merged;
1826
+ // }
1827
+ catchall(e) {
1828
+ return new b({
1829
+ ...this._def,
1830
+ catchall: e
1831
+ });
1832
+ }
1833
+ pick(e) {
1834
+ const t = {};
1835
+ return x.objectKeys(e).forEach((n) => {
1836
+ e[n] && this.shape[n] && (t[n] = this.shape[n]);
1837
+ }), new b({
1838
+ ...this._def,
1839
+ shape: () => t
1840
+ });
1841
+ }
1842
+ omit(e) {
1843
+ const t = {};
1844
+ return x.objectKeys(this.shape).forEach((n) => {
1845
+ e[n] || (t[n] = this.shape[n]);
1846
+ }), new b({
1847
+ ...this._def,
1848
+ shape: () => t
1849
+ });
1850
+ }
1851
+ /**
1852
+ * @deprecated
1853
+ */
1854
+ deepPartial() {
1855
+ return Y(this);
1856
+ }
1857
+ partial(e) {
1858
+ const t = {};
1859
+ return x.objectKeys(this.shape).forEach((n) => {
1860
+ const s = this.shape[n];
1861
+ e && !e[n] ? t[n] = s : t[n] = s.optional();
1862
+ }), new b({
1863
+ ...this._def,
1864
+ shape: () => t
1865
+ });
1866
+ }
1867
+ required(e) {
1868
+ const t = {};
1869
+ return x.objectKeys(this.shape).forEach((n) => {
1870
+ if (e && !e[n])
1871
+ t[n] = this.shape[n];
1872
+ else {
1873
+ let a = this.shape[n];
1874
+ for (; a instanceof N; )
1875
+ a = a._def.innerType;
1876
+ t[n] = a;
1877
+ }
1878
+ }), new b({
1879
+ ...this._def,
1880
+ shape: () => t
1881
+ });
1882
+ }
1883
+ keyof() {
1884
+ return Xe(x.objectKeys(this.shape));
1885
+ }
1886
+ }
1887
+ b.create = (r, e) => new b({
1888
+ shape: () => r,
1889
+ unknownKeys: "strip",
1890
+ catchall: M.create(),
1891
+ typeName: _.ZodObject,
1892
+ ...v(e)
1893
+ });
1894
+ b.strictCreate = (r, e) => new b({
1895
+ shape: () => r,
1896
+ unknownKeys: "strict",
1897
+ catchall: M.create(),
1898
+ typeName: _.ZodObject,
1899
+ ...v(e)
1900
+ });
1901
+ b.lazycreate = (r, e) => new b({
1902
+ shape: r,
1903
+ unknownKeys: "strip",
1904
+ catchall: M.create(),
1905
+ typeName: _.ZodObject,
1906
+ ...v(e)
1907
+ });
1908
+ class ce extends g {
1909
+ _parse(e) {
1910
+ const { ctx: t } = this._processInputParams(e), n = this._def.options;
1911
+ function s(a) {
1912
+ for (const i of a)
1913
+ if (i.result.status === "valid")
1914
+ return i.result;
1915
+ for (const i of a)
1916
+ if (i.result.status === "dirty")
1917
+ return t.common.issues.push(...i.ctx.common.issues), i.result;
1918
+ const o = a.map((i) => new S(i.ctx.common.issues));
1919
+ return l(t, {
1920
+ code: c.invalid_union,
1921
+ unionErrors: o
1922
+ }), y;
1923
+ }
1924
+ if (t.common.async)
1925
+ return Promise.all(n.map(async (a) => {
1926
+ const o = {
1927
+ ...t,
1928
+ common: {
1929
+ ...t.common,
1930
+ issues: []
1931
+ },
1932
+ parent: null
1933
+ };
1934
+ return {
1935
+ result: await a._parseAsync({
1936
+ data: t.data,
1937
+ path: t.path,
1938
+ parent: o
1939
+ }),
1940
+ ctx: o
1941
+ };
1942
+ })).then(s);
1943
+ {
1944
+ let a;
1945
+ const o = [];
1946
+ for (const u of n) {
1947
+ const d = {
1948
+ ...t,
1949
+ common: {
1950
+ ...t.common,
1951
+ issues: []
1952
+ },
1953
+ parent: null
1954
+ }, h = u._parseSync({
1955
+ data: t.data,
1956
+ path: t.path,
1957
+ parent: d
1958
+ });
1959
+ if (h.status === "valid")
1960
+ return h;
1961
+ h.status === "dirty" && !a && (a = { result: h, ctx: d }), d.common.issues.length && o.push(d.common.issues);
1962
+ }
1963
+ if (a)
1964
+ return t.common.issues.push(...a.ctx.common.issues), a.result;
1965
+ const i = o.map((u) => new S(u));
1966
+ return l(t, {
1967
+ code: c.invalid_union,
1968
+ unionErrors: i
1969
+ }), y;
1970
+ }
1971
+ }
1972
+ get options() {
1973
+ return this._def.options;
1974
+ }
1975
+ }
1976
+ ce.create = (r, e) => new ce({
1977
+ options: r,
1978
+ typeName: _.ZodUnion,
1979
+ ...v(e)
1980
+ });
1981
+ const A = (r) => r instanceof fe ? A(r.schema) : r instanceof C ? A(r.innerType()) : r instanceof he ? [r.value] : r instanceof U ? r.options : r instanceof pe ? x.objectValues(r.enum) : r instanceof me ? A(r._def.innerType) : r instanceof oe ? [void 0] : r instanceof de ? [null] : r instanceof N ? [void 0, ...A(r.unwrap())] : r instanceof z ? [null, ...A(r.unwrap())] : r instanceof Ue || r instanceof ye ? A(r.unwrap()) : r instanceof _e ? A(r._def.innerType) : [];
1982
+ class Oe extends g {
1983
+ _parse(e) {
1984
+ const { ctx: t } = this._processInputParams(e);
1985
+ if (t.parsedType !== f.object)
1986
+ return l(t, {
1987
+ code: c.invalid_type,
1988
+ expected: f.object,
1989
+ received: t.parsedType
1990
+ }), y;
1991
+ const n = this.discriminator, s = t.data[n], a = this.optionsMap.get(s);
1992
+ return a ? t.common.async ? a._parseAsync({
1993
+ data: t.data,
1994
+ path: t.path,
1995
+ parent: t
1996
+ }) : a._parseSync({
1997
+ data: t.data,
1998
+ path: t.path,
1999
+ parent: t
2000
+ }) : (l(t, {
2001
+ code: c.invalid_union_discriminator,
2002
+ options: Array.from(this.optionsMap.keys()),
2003
+ path: [n]
2004
+ }), y);
2005
+ }
2006
+ get discriminator() {
2007
+ return this._def.discriminator;
2008
+ }
2009
+ get options() {
2010
+ return this._def.options;
2011
+ }
2012
+ get optionsMap() {
2013
+ return this._def.optionsMap;
2014
+ }
2015
+ /**
2016
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2017
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2018
+ * have a different value for each object in the union.
2019
+ * @param discriminator the name of the discriminator property
2020
+ * @param types an array of object schemas
2021
+ * @param params
2022
+ */
2023
+ static create(e, t, n) {
2024
+ const s = /* @__PURE__ */ new Map();
2025
+ for (const a of t) {
2026
+ const o = A(a.shape[e]);
2027
+ if (!o.length)
2028
+ throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
2029
+ for (const i of o) {
2030
+ if (s.has(i))
2031
+ throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);
2032
+ s.set(i, a);
2033
+ }
2034
+ }
2035
+ return new Oe({
2036
+ typeName: _.ZodDiscriminatedUnion,
2037
+ discriminator: e,
2038
+ options: t,
2039
+ optionsMap: s,
2040
+ ...v(n)
2041
+ });
2042
+ }
2043
+ }
2044
+ function Le(r, e) {
2045
+ const t = V(r), n = V(e);
2046
+ if (r === e)
2047
+ return { valid: !0, data: r };
2048
+ if (t === f.object && n === f.object) {
2049
+ const s = x.objectKeys(e), a = x.objectKeys(r).filter((i) => s.indexOf(i) !== -1), o = { ...r, ...e };
2050
+ for (const i of a) {
2051
+ const u = Le(r[i], e[i]);
2052
+ if (!u.valid)
2053
+ return { valid: !1 };
2054
+ o[i] = u.data;
2055
+ }
2056
+ return { valid: !0, data: o };
2057
+ } else if (t === f.array && n === f.array) {
2058
+ if (r.length !== e.length)
2059
+ return { valid: !1 };
2060
+ const s = [];
2061
+ for (let a = 0; a < r.length; a++) {
2062
+ const o = r[a], i = e[a], u = Le(o, i);
2063
+ if (!u.valid)
2064
+ return { valid: !1 };
2065
+ s.push(u.data);
2066
+ }
2067
+ return { valid: !0, data: s };
2068
+ } else return t === f.date && n === f.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
2069
+ }
2070
+ class ue extends g {
2071
+ _parse(e) {
2072
+ const { status: t, ctx: n } = this._processInputParams(e), s = (a, o) => {
2073
+ if (Ve(a) || Ve(o))
2074
+ return y;
2075
+ const i = Le(a.value, o.value);
2076
+ return i.valid ? ((De(a) || De(o)) && t.dirty(), { status: t.value, value: i.data }) : (l(n, {
2077
+ code: c.invalid_intersection_types
2078
+ }), y);
192
2079
  };
193
- },
194
- fetch(t = this._options.method, e = "", n = null) {
195
- let o = this.url(e).options({ method: t });
196
- const i = R(o._options.headers), l = this._config.polyfill("FormData", !1), h = typeof n == "object" && !(l && n instanceof l) && (!o._options.headers || !i || S(i));
197
- return o = n ? h ? o.json(n, i) : o.body(n) : o, N(o._deferred.reduce((f, u) => u(f, f._url, f._options), o));
198
- },
199
- get(t = "") {
200
- return this.fetch("GET", t);
201
- },
202
- delete(t = "") {
203
- return this.fetch("DELETE", t);
204
- },
205
- put(t, e = "") {
206
- return this.fetch("PUT", e, t);
207
- },
208
- post(t, e = "") {
209
- return this.fetch("POST", e, t);
210
- },
211
- patch(t, e = "") {
212
- return this.fetch("PATCH", e, t);
213
- },
214
- head(t = "") {
215
- return this.fetch("HEAD", t);
216
- },
217
- opts(t = "") {
218
- return this.fetch("OPTIONS", t);
219
- },
220
- body(t) {
221
- return { ...this, _options: { ...this._options, body: t } };
222
- },
223
- json(t, e) {
224
- const n = R(this._options.headers);
225
- return this.content(e || S(n) && n || q).body(JSON.stringify(t));
2080
+ return n.common.async ? Promise.all([
2081
+ this._def.left._parseAsync({
2082
+ data: n.data,
2083
+ path: n.path,
2084
+ parent: n
2085
+ }),
2086
+ this._def.right._parseAsync({
2087
+ data: n.data,
2088
+ path: n.path,
2089
+ parent: n
2090
+ })
2091
+ ]).then(([a, o]) => s(a, o)) : s(this._def.left._parseSync({
2092
+ data: n.data,
2093
+ path: n.path,
2094
+ parent: n
2095
+ }), this._def.right._parseSync({
2096
+ data: n.data,
2097
+ path: n.path,
2098
+ parent: n
2099
+ }));
2100
+ }
2101
+ }
2102
+ ue.create = (r, e, t) => new ue({
2103
+ left: r,
2104
+ right: e,
2105
+ typeName: _.ZodIntersection,
2106
+ ...v(t)
2107
+ });
2108
+ class I extends g {
2109
+ _parse(e) {
2110
+ const { status: t, ctx: n } = this._processInputParams(e);
2111
+ if (n.parsedType !== f.array)
2112
+ return l(n, {
2113
+ code: c.invalid_type,
2114
+ expected: f.array,
2115
+ received: n.parsedType
2116
+ }), y;
2117
+ if (n.data.length < this._def.items.length)
2118
+ return l(n, {
2119
+ code: c.too_small,
2120
+ minimum: this._def.items.length,
2121
+ inclusive: !0,
2122
+ exact: !1,
2123
+ type: "array"
2124
+ }), y;
2125
+ !this._def.rest && n.data.length > this._def.items.length && (l(n, {
2126
+ code: c.too_big,
2127
+ maximum: this._def.items.length,
2128
+ inclusive: !0,
2129
+ exact: !1,
2130
+ type: "array"
2131
+ }), t.dirty());
2132
+ const a = [...n.data].map((o, i) => {
2133
+ const u = this._def.items[i] || this._def.rest;
2134
+ return u ? u._parse(new R(n, o, n.path, i)) : null;
2135
+ }).filter((o) => !!o);
2136
+ return n.common.async ? Promise.all(a).then((o) => T.mergeArray(t, o)) : T.mergeArray(t, a);
2137
+ }
2138
+ get items() {
2139
+ return this._def.items;
226
2140
  }
2141
+ rest(e) {
2142
+ return new I({
2143
+ ...this._def,
2144
+ rest: e
2145
+ });
2146
+ }
2147
+ }
2148
+ I.create = (r, e) => {
2149
+ if (!Array.isArray(r))
2150
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2151
+ return new I({
2152
+ items: r,
2153
+ typeName: _.ZodTuple,
2154
+ rest: null,
2155
+ ...v(e)
2156
+ });
227
2157
  };
228
- function j(t = "", e = {}) {
229
- return { ...B, _url: t, _options: e };
230
- }
231
- j.default = j;
232
- j.options = x;
233
- j.errorType = F;
234
- j.polyfills = z;
235
- j.WretchError = k;
236
- const J = (t, e) => e.skipDedupe || e.method !== "GET", U = (t, e) => e.method + "@" + t, $ = (t) => t.clone(), G = ({ skip: t = J, key: e = U, resolver: n = $ } = {}) => {
237
- const o = /* @__PURE__ */ new Map();
238
- return (i) => (l, h) => {
239
- if (t(l, h))
240
- return i(l, h);
241
- const f = e(l, h);
242
- if (!o.has(f))
243
- o.set(f, []);
244
- else
245
- return new Promise((u, a) => {
246
- o.get(f).push([u, a]);
2158
+ class le extends g {
2159
+ get keySchema() {
2160
+ return this._def.keyType;
2161
+ }
2162
+ get valueSchema() {
2163
+ return this._def.valueType;
2164
+ }
2165
+ _parse(e) {
2166
+ const { status: t, ctx: n } = this._processInputParams(e);
2167
+ if (n.parsedType !== f.object)
2168
+ return l(n, {
2169
+ code: c.invalid_type,
2170
+ expected: f.object,
2171
+ received: n.parsedType
2172
+ }), y;
2173
+ const s = [], a = this._def.keyType, o = this._def.valueType;
2174
+ for (const i in n.data)
2175
+ s.push({
2176
+ key: a._parse(new R(n, i, n.path, i)),
2177
+ value: o._parse(new R(n, n.data[i], n.path, i)),
2178
+ alwaysSet: i in n.data
247
2179
  });
248
- try {
249
- return i(l, h).then((u) => (o.get(f).forEach(([a]) => a(n(u))), o.delete(f), u)).catch((u) => {
250
- throw o.get(f).forEach(([, a]) => a(u)), o.delete(f), u;
2180
+ return n.common.async ? T.mergeObjectAsync(t, s) : T.mergeObjectSync(t, s);
2181
+ }
2182
+ get element() {
2183
+ return this._def.valueType;
2184
+ }
2185
+ static create(e, t, n) {
2186
+ return t instanceof g ? new le({
2187
+ keyType: e,
2188
+ valueType: t,
2189
+ typeName: _.ZodRecord,
2190
+ ...v(n)
2191
+ }) : new le({
2192
+ keyType: E.create(),
2193
+ valueType: e,
2194
+ typeName: _.ZodRecord,
2195
+ ...v(t)
2196
+ });
2197
+ }
2198
+ }
2199
+ class Ze extends g {
2200
+ get keySchema() {
2201
+ return this._def.keyType;
2202
+ }
2203
+ get valueSchema() {
2204
+ return this._def.valueType;
2205
+ }
2206
+ _parse(e) {
2207
+ const { status: t, ctx: n } = this._processInputParams(e);
2208
+ if (n.parsedType !== f.map)
2209
+ return l(n, {
2210
+ code: c.invalid_type,
2211
+ expected: f.map,
2212
+ received: n.parsedType
2213
+ }), y;
2214
+ const s = this._def.keyType, a = this._def.valueType, o = [...n.data.entries()].map(([i, u], d) => ({
2215
+ key: s._parse(new R(n, i, n.path, [d, "key"])),
2216
+ value: a._parse(new R(n, u, n.path, [d, "value"]))
2217
+ }));
2218
+ if (n.common.async) {
2219
+ const i = /* @__PURE__ */ new Map();
2220
+ return Promise.resolve().then(async () => {
2221
+ for (const u of o) {
2222
+ const d = await u.key, h = await u.value;
2223
+ if (d.status === "aborted" || h.status === "aborted")
2224
+ return y;
2225
+ (d.status === "dirty" || h.status === "dirty") && t.dirty(), i.set(d.value, h.value);
2226
+ }
2227
+ return { status: t.value, value: i };
251
2228
  });
252
- } catch (u) {
253
- return o.delete(f), Promise.reject(u);
2229
+ } else {
2230
+ const i = /* @__PURE__ */ new Map();
2231
+ for (const u of o) {
2232
+ const d = u.key, h = u.value;
2233
+ if (d.status === "aborted" || h.status === "aborted")
2234
+ return y;
2235
+ (d.status === "dirty" || h.status === "dirty") && t.dirty(), i.set(d.value, h.value);
2236
+ }
2237
+ return { status: t.value, value: i };
254
2238
  }
255
- };
256
- }, I = (t, e) => t * e, K = (t) => t && t.ok, W = ({ delayTimer: t = 500, delayRamp: e = I, maxAttempts: n = 10, until: o = K, onRetry: i = null, retryOnNetworkError: l = !1, resolveWithLatestResponse: h = !1, skip: f } = {}) => (u) => (a, m) => {
257
- let v = 0;
258
- if (f && f(a, m))
259
- return u(a, m);
260
- const E = (d, g) => Promise.resolve(o(d, g)).then((P) => P ? d && h ? d : g ? Promise.reject(g) : d : (v++, !n || v <= n ? new Promise((_) => {
261
- const O = e(t, v);
262
- setTimeout(() => {
263
- typeof i == "function" ? Promise.resolve(i({
264
- response: d,
265
- error: g,
266
- url: a,
267
- options: m
268
- })).then((b = {}) => {
269
- var r, s;
270
- _(u((r = b && b.url) !== null && r !== void 0 ? r : a, (s = b && b.options) !== null && s !== void 0 ? s : m));
271
- }) : _(u(a, m));
272
- }, O);
273
- }).then(E).catch((_) => {
274
- if (!l)
275
- throw _;
276
- return E(null, _);
277
- }) : d && h ? d : Promise.reject(g || new Error("Number of attempts exceeded."))));
278
- return u(a, m).then(E).catch((d) => {
279
- if (!l)
280
- throw d;
281
- return E(null, d);
2239
+ }
2240
+ }
2241
+ Ze.create = (r, e, t) => new Ze({
2242
+ valueType: e,
2243
+ keyType: r,
2244
+ typeName: _.ZodMap,
2245
+ ...v(t)
2246
+ });
2247
+ class J extends g {
2248
+ _parse(e) {
2249
+ const { status: t, ctx: n } = this._processInputParams(e);
2250
+ if (n.parsedType !== f.set)
2251
+ return l(n, {
2252
+ code: c.invalid_type,
2253
+ expected: f.set,
2254
+ received: n.parsedType
2255
+ }), y;
2256
+ const s = this._def;
2257
+ s.minSize !== null && n.data.size < s.minSize.value && (l(n, {
2258
+ code: c.too_small,
2259
+ minimum: s.minSize.value,
2260
+ type: "set",
2261
+ inclusive: !0,
2262
+ exact: !1,
2263
+ message: s.minSize.message
2264
+ }), t.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (l(n, {
2265
+ code: c.too_big,
2266
+ maximum: s.maxSize.value,
2267
+ type: "set",
2268
+ inclusive: !0,
2269
+ exact: !1,
2270
+ message: s.maxSize.message
2271
+ }), t.dirty());
2272
+ const a = this._def.valueType;
2273
+ function o(u) {
2274
+ const d = /* @__PURE__ */ new Set();
2275
+ for (const h of u) {
2276
+ if (h.status === "aborted")
2277
+ return y;
2278
+ h.status === "dirty" && t.dirty(), d.add(h.value);
2279
+ }
2280
+ return { status: t.value, value: d };
2281
+ }
2282
+ const i = [...n.data.values()].map((u, d) => a._parse(new R(n, u, n.path, d)));
2283
+ return n.common.async ? Promise.all(i).then((u) => o(u)) : o(i);
2284
+ }
2285
+ min(e, t) {
2286
+ return new J({
2287
+ ...this._def,
2288
+ minSize: { value: e, message: m.toString(t) }
2289
+ });
2290
+ }
2291
+ max(e, t) {
2292
+ return new J({
2293
+ ...this._def,
2294
+ maxSize: { value: e, message: m.toString(t) }
2295
+ });
2296
+ }
2297
+ size(e, t) {
2298
+ return this.min(e, t).max(e, t);
2299
+ }
2300
+ nonempty(e) {
2301
+ return this.min(1, e);
2302
+ }
2303
+ }
2304
+ J.create = (r, e) => new J({
2305
+ valueType: r,
2306
+ minSize: null,
2307
+ maxSize: null,
2308
+ typeName: _.ZodSet,
2309
+ ...v(e)
2310
+ });
2311
+ class G extends g {
2312
+ constructor() {
2313
+ super(...arguments), this.validate = this.implement;
2314
+ }
2315
+ _parse(e) {
2316
+ const { ctx: t } = this._processInputParams(e);
2317
+ if (t.parsedType !== f.function)
2318
+ return l(t, {
2319
+ code: c.invalid_type,
2320
+ expected: f.function,
2321
+ received: t.parsedType
2322
+ }), y;
2323
+ function n(i, u) {
2324
+ return be({
2325
+ data: i,
2326
+ path: t.path,
2327
+ errorMaps: [
2328
+ t.common.contextualErrorMap,
2329
+ t.schemaErrorMap,
2330
+ xe(),
2331
+ X
2332
+ ].filter((d) => !!d),
2333
+ issueData: {
2334
+ code: c.invalid_arguments,
2335
+ argumentsError: u
2336
+ }
2337
+ });
2338
+ }
2339
+ function s(i, u) {
2340
+ return be({
2341
+ data: i,
2342
+ path: t.path,
2343
+ errorMaps: [
2344
+ t.common.contextualErrorMap,
2345
+ t.schemaErrorMap,
2346
+ xe(),
2347
+ X
2348
+ ].filter((d) => !!d),
2349
+ issueData: {
2350
+ code: c.invalid_return_type,
2351
+ returnTypeError: u
2352
+ }
2353
+ });
2354
+ }
2355
+ const a = { errorMap: t.common.contextualErrorMap }, o = t.data;
2356
+ if (this._def.returns instanceof Q) {
2357
+ const i = this;
2358
+ return Z(async function(...u) {
2359
+ const d = new S([]), h = await i._def.args.parseAsync(u, a).catch((w) => {
2360
+ throw d.addIssue(n(u, w)), d;
2361
+ }), k = await Reflect.apply(o, this, h);
2362
+ return await i._def.returns._def.type.parseAsync(k, a).catch((w) => {
2363
+ throw d.addIssue(s(k, w)), d;
2364
+ });
2365
+ });
2366
+ } else {
2367
+ const i = this;
2368
+ return Z(function(...u) {
2369
+ const d = i._def.args.safeParse(u, a);
2370
+ if (!d.success)
2371
+ throw new S([n(u, d.error)]);
2372
+ const h = Reflect.apply(o, this, d.data), k = i._def.returns.safeParse(h, a);
2373
+ if (!k.success)
2374
+ throw new S([s(h, k.error)]);
2375
+ return k.data;
2376
+ });
2377
+ }
2378
+ }
2379
+ parameters() {
2380
+ return this._def.args;
2381
+ }
2382
+ returnType() {
2383
+ return this._def.returns;
2384
+ }
2385
+ args(...e) {
2386
+ return new G({
2387
+ ...this._def,
2388
+ args: I.create(e).rest(W.create())
2389
+ });
2390
+ }
2391
+ returns(e) {
2392
+ return new G({
2393
+ ...this._def,
2394
+ returns: e
2395
+ });
2396
+ }
2397
+ implement(e) {
2398
+ return this.parse(e);
2399
+ }
2400
+ strictImplement(e) {
2401
+ return this.parse(e);
2402
+ }
2403
+ static create(e, t, n) {
2404
+ return new G({
2405
+ args: e || I.create([]).rest(W.create()),
2406
+ returns: t || W.create(),
2407
+ typeName: _.ZodFunction,
2408
+ ...v(n)
2409
+ });
2410
+ }
2411
+ }
2412
+ class fe extends g {
2413
+ get schema() {
2414
+ return this._def.getter();
2415
+ }
2416
+ _parse(e) {
2417
+ const { ctx: t } = this._processInputParams(e);
2418
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2419
+ }
2420
+ }
2421
+ fe.create = (r, e) => new fe({
2422
+ getter: r,
2423
+ typeName: _.ZodLazy,
2424
+ ...v(e)
2425
+ });
2426
+ class he extends g {
2427
+ _parse(e) {
2428
+ if (e.data !== this._def.value) {
2429
+ const t = this._getOrReturnCtx(e);
2430
+ return l(t, {
2431
+ received: t.data,
2432
+ code: c.invalid_literal,
2433
+ expected: this._def.value
2434
+ }), y;
2435
+ }
2436
+ return { status: "valid", value: e.data };
2437
+ }
2438
+ get value() {
2439
+ return this._def.value;
2440
+ }
2441
+ }
2442
+ he.create = (r, e) => new he({
2443
+ value: r,
2444
+ typeName: _.ZodLiteral,
2445
+ ...v(e)
2446
+ });
2447
+ function Xe(r, e) {
2448
+ return new U({
2449
+ values: r,
2450
+ typeName: _.ZodEnum,
2451
+ ...v(e)
282
2452
  });
2453
+ }
2454
+ class U extends g {
2455
+ constructor() {
2456
+ super(...arguments), re.set(this, void 0);
2457
+ }
2458
+ _parse(e) {
2459
+ if (typeof e.data != "string") {
2460
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2461
+ return l(t, {
2462
+ expected: x.joinValues(n),
2463
+ received: t.parsedType,
2464
+ code: c.invalid_type
2465
+ }), y;
2466
+ }
2467
+ if (ke(this, re) || Je(this, re, new Set(this._def.values)), !ke(this, re).has(e.data)) {
2468
+ const t = this._getOrReturnCtx(e), n = this._def.values;
2469
+ return l(t, {
2470
+ received: t.data,
2471
+ code: c.invalid_enum_value,
2472
+ options: n
2473
+ }), y;
2474
+ }
2475
+ return Z(e.data);
2476
+ }
2477
+ get options() {
2478
+ return this._def.values;
2479
+ }
2480
+ get enum() {
2481
+ const e = {};
2482
+ for (const t of this._def.values)
2483
+ e[t] = t;
2484
+ return e;
2485
+ }
2486
+ get Values() {
2487
+ const e = {};
2488
+ for (const t of this._def.values)
2489
+ e[t] = t;
2490
+ return e;
2491
+ }
2492
+ get Enum() {
2493
+ const e = {};
2494
+ for (const t of this._def.values)
2495
+ e[t] = t;
2496
+ return e;
2497
+ }
2498
+ extract(e, t = this._def) {
2499
+ return U.create(e, {
2500
+ ...this._def,
2501
+ ...t
2502
+ });
2503
+ }
2504
+ exclude(e, t = this._def) {
2505
+ return U.create(this.options.filter((n) => !e.includes(n)), {
2506
+ ...this._def,
2507
+ ...t
2508
+ });
2509
+ }
2510
+ }
2511
+ re = /* @__PURE__ */ new WeakMap();
2512
+ U.create = Xe;
2513
+ class pe extends g {
2514
+ constructor() {
2515
+ super(...arguments), ne.set(this, void 0);
2516
+ }
2517
+ _parse(e) {
2518
+ const t = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
2519
+ if (n.parsedType !== f.string && n.parsedType !== f.number) {
2520
+ const s = x.objectValues(t);
2521
+ return l(n, {
2522
+ expected: x.joinValues(s),
2523
+ received: n.parsedType,
2524
+ code: c.invalid_type
2525
+ }), y;
2526
+ }
2527
+ if (ke(this, ne) || Je(this, ne, new Set(x.getValidEnumValues(this._def.values))), !ke(this, ne).has(e.data)) {
2528
+ const s = x.objectValues(t);
2529
+ return l(n, {
2530
+ received: n.data,
2531
+ code: c.invalid_enum_value,
2532
+ options: s
2533
+ }), y;
2534
+ }
2535
+ return Z(e.data);
2536
+ }
2537
+ get enum() {
2538
+ return this._def.values;
2539
+ }
2540
+ }
2541
+ ne = /* @__PURE__ */ new WeakMap();
2542
+ pe.create = (r, e) => new pe({
2543
+ values: r,
2544
+ typeName: _.ZodNativeEnum,
2545
+ ...v(e)
2546
+ });
2547
+ class Q extends g {
2548
+ unwrap() {
2549
+ return this._def.type;
2550
+ }
2551
+ _parse(e) {
2552
+ const { ctx: t } = this._processInputParams(e);
2553
+ if (t.parsedType !== f.promise && t.common.async === !1)
2554
+ return l(t, {
2555
+ code: c.invalid_type,
2556
+ expected: f.promise,
2557
+ received: t.parsedType
2558
+ }), y;
2559
+ const n = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2560
+ return Z(n.then((s) => this._def.type.parseAsync(s, {
2561
+ path: t.path,
2562
+ errorMap: t.common.contextualErrorMap
2563
+ })));
2564
+ }
2565
+ }
2566
+ Q.create = (r, e) => new Q({
2567
+ type: r,
2568
+ typeName: _.ZodPromise,
2569
+ ...v(e)
2570
+ });
2571
+ class C extends g {
2572
+ innerType() {
2573
+ return this._def.schema;
2574
+ }
2575
+ sourceType() {
2576
+ return this._def.schema._def.typeName === _.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2577
+ }
2578
+ _parse(e) {
2579
+ const { status: t, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
2580
+ addIssue: (o) => {
2581
+ l(n, o), o.fatal ? t.abort() : t.dirty();
2582
+ },
2583
+ get path() {
2584
+ return n.path;
2585
+ }
2586
+ };
2587
+ if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
2588
+ const o = s.transform(n.data, a);
2589
+ if (n.common.async)
2590
+ return Promise.resolve(o).then(async (i) => {
2591
+ if (t.value === "aborted")
2592
+ return y;
2593
+ const u = await this._def.schema._parseAsync({
2594
+ data: i,
2595
+ path: n.path,
2596
+ parent: n
2597
+ });
2598
+ return u.status === "aborted" ? y : u.status === "dirty" || t.value === "dirty" ? H(u.value) : u;
2599
+ });
2600
+ {
2601
+ if (t.value === "aborted")
2602
+ return y;
2603
+ const i = this._def.schema._parseSync({
2604
+ data: o,
2605
+ path: n.path,
2606
+ parent: n
2607
+ });
2608
+ return i.status === "aborted" ? y : i.status === "dirty" || t.value === "dirty" ? H(i.value) : i;
2609
+ }
2610
+ }
2611
+ if (s.type === "refinement") {
2612
+ const o = (i) => {
2613
+ const u = s.refinement(i, a);
2614
+ if (n.common.async)
2615
+ return Promise.resolve(u);
2616
+ if (u instanceof Promise)
2617
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2618
+ return i;
2619
+ };
2620
+ if (n.common.async === !1) {
2621
+ const i = this._def.schema._parseSync({
2622
+ data: n.data,
2623
+ path: n.path,
2624
+ parent: n
2625
+ });
2626
+ return i.status === "aborted" ? y : (i.status === "dirty" && t.dirty(), o(i.value), { status: t.value, value: i.value });
2627
+ } else
2628
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => i.status === "aborted" ? y : (i.status === "dirty" && t.dirty(), o(i.value).then(() => ({ status: t.value, value: i.value }))));
2629
+ }
2630
+ if (s.type === "transform")
2631
+ if (n.common.async === !1) {
2632
+ const o = this._def.schema._parseSync({
2633
+ data: n.data,
2634
+ path: n.path,
2635
+ parent: n
2636
+ });
2637
+ if (!se(o))
2638
+ return o;
2639
+ const i = s.transform(o.value, a);
2640
+ if (i instanceof Promise)
2641
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2642
+ return { status: t.value, value: i };
2643
+ } else
2644
+ return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => se(o) ? Promise.resolve(s.transform(o.value, a)).then((i) => ({ status: t.value, value: i })) : o);
2645
+ x.assertNever(s);
2646
+ }
2647
+ }
2648
+ C.create = (r, e, t) => new C({
2649
+ schema: r,
2650
+ typeName: _.ZodEffects,
2651
+ effect: e,
2652
+ ...v(t)
2653
+ });
2654
+ C.createWithPreprocess = (r, e, t) => new C({
2655
+ schema: e,
2656
+ effect: { type: "preprocess", transform: r },
2657
+ typeName: _.ZodEffects,
2658
+ ...v(t)
2659
+ });
2660
+ class N extends g {
2661
+ _parse(e) {
2662
+ return this._getType(e) === f.undefined ? Z(void 0) : this._def.innerType._parse(e);
2663
+ }
2664
+ unwrap() {
2665
+ return this._def.innerType;
2666
+ }
2667
+ }
2668
+ N.create = (r, e) => new N({
2669
+ innerType: r,
2670
+ typeName: _.ZodOptional,
2671
+ ...v(e)
2672
+ });
2673
+ class z extends g {
2674
+ _parse(e) {
2675
+ return this._getType(e) === f.null ? Z(null) : this._def.innerType._parse(e);
2676
+ }
2677
+ unwrap() {
2678
+ return this._def.innerType;
2679
+ }
2680
+ }
2681
+ z.create = (r, e) => new z({
2682
+ innerType: r,
2683
+ typeName: _.ZodNullable,
2684
+ ...v(e)
2685
+ });
2686
+ class me extends g {
2687
+ _parse(e) {
2688
+ const { ctx: t } = this._processInputParams(e);
2689
+ let n = t.data;
2690
+ return t.parsedType === f.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
2691
+ data: n,
2692
+ path: t.path,
2693
+ parent: t
2694
+ });
2695
+ }
2696
+ removeDefault() {
2697
+ return this._def.innerType;
2698
+ }
2699
+ }
2700
+ me.create = (r, e) => new me({
2701
+ innerType: r,
2702
+ typeName: _.ZodDefault,
2703
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2704
+ ...v(e)
2705
+ });
2706
+ class _e extends g {
2707
+ _parse(e) {
2708
+ const { ctx: t } = this._processInputParams(e), n = {
2709
+ ...t,
2710
+ common: {
2711
+ ...t.common,
2712
+ issues: []
2713
+ }
2714
+ }, s = this._def.innerType._parse({
2715
+ data: n.data,
2716
+ path: n.path,
2717
+ parent: {
2718
+ ...n
2719
+ }
2720
+ });
2721
+ return ae(s) ? s.then((a) => ({
2722
+ status: "valid",
2723
+ value: a.status === "valid" ? a.value : this._def.catchValue({
2724
+ get error() {
2725
+ return new S(n.common.issues);
2726
+ },
2727
+ input: n.data
2728
+ })
2729
+ })) : {
2730
+ status: "valid",
2731
+ value: s.status === "valid" ? s.value : this._def.catchValue({
2732
+ get error() {
2733
+ return new S(n.common.issues);
2734
+ },
2735
+ input: n.data
2736
+ })
2737
+ };
2738
+ }
2739
+ removeCatch() {
2740
+ return this._def.innerType;
2741
+ }
2742
+ }
2743
+ _e.create = (r, e) => new _e({
2744
+ innerType: r,
2745
+ typeName: _.ZodCatch,
2746
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2747
+ ...v(e)
2748
+ });
2749
+ class Se extends g {
2750
+ _parse(e) {
2751
+ if (this._getType(e) !== f.nan) {
2752
+ const n = this._getOrReturnCtx(e);
2753
+ return l(n, {
2754
+ code: c.invalid_type,
2755
+ expected: f.nan,
2756
+ received: n.parsedType
2757
+ }), y;
2758
+ }
2759
+ return { status: "valid", value: e.data };
2760
+ }
2761
+ }
2762
+ Se.create = (r) => new Se({
2763
+ typeName: _.ZodNaN,
2764
+ ...v(r)
2765
+ });
2766
+ const Ct = Symbol("zod_brand");
2767
+ class Ue extends g {
2768
+ _parse(e) {
2769
+ const { ctx: t } = this._processInputParams(e), n = t.data;
2770
+ return this._def.type._parse({
2771
+ data: n,
2772
+ path: t.path,
2773
+ parent: t
2774
+ });
2775
+ }
2776
+ unwrap() {
2777
+ return this._def.type;
2778
+ }
2779
+ }
2780
+ class ve extends g {
2781
+ _parse(e) {
2782
+ const { status: t, ctx: n } = this._processInputParams(e);
2783
+ if (n.common.async)
2784
+ return (async () => {
2785
+ const a = await this._def.in._parseAsync({
2786
+ data: n.data,
2787
+ path: n.path,
2788
+ parent: n
2789
+ });
2790
+ return a.status === "aborted" ? y : a.status === "dirty" ? (t.dirty(), H(a.value)) : this._def.out._parseAsync({
2791
+ data: a.value,
2792
+ path: n.path,
2793
+ parent: n
2794
+ });
2795
+ })();
2796
+ {
2797
+ const s = this._def.in._parseSync({
2798
+ data: n.data,
2799
+ path: n.path,
2800
+ parent: n
2801
+ });
2802
+ return s.status === "aborted" ? y : s.status === "dirty" ? (t.dirty(), {
2803
+ status: "dirty",
2804
+ value: s.value
2805
+ }) : this._def.out._parseSync({
2806
+ data: s.value,
2807
+ path: n.path,
2808
+ parent: n
2809
+ });
2810
+ }
2811
+ }
2812
+ static create(e, t) {
2813
+ return new ve({
2814
+ in: e,
2815
+ out: t,
2816
+ typeName: _.ZodPipeline
2817
+ });
2818
+ }
2819
+ }
2820
+ class ye extends g {
2821
+ _parse(e) {
2822
+ const t = this._def.innerType._parse(e), n = (s) => (se(s) && (s.value = Object.freeze(s.value)), s);
2823
+ return ae(t) ? t.then((s) => n(s)) : n(t);
2824
+ }
2825
+ unwrap() {
2826
+ return this._def.innerType;
2827
+ }
2828
+ }
2829
+ ye.create = (r, e) => new ye({
2830
+ innerType: r,
2831
+ typeName: _.ZodReadonly,
2832
+ ...v(e)
2833
+ });
2834
+ function Ke(r, e = {}, t) {
2835
+ return r ? K.create().superRefine((n, s) => {
2836
+ var a, o;
2837
+ if (!r(n)) {
2838
+ const i = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (o = (a = i.fatal) !== null && a !== void 0 ? a : t) !== null && o !== void 0 ? o : !0, d = typeof i == "string" ? { message: i } : i;
2839
+ s.addIssue({ code: "custom", ...d, fatal: u });
2840
+ }
2841
+ }) : K.create();
2842
+ }
2843
+ const Nt = {
2844
+ object: b.lazycreate
283
2845
  };
284
- function H(t) {
285
- return j(`https://api.cloudflare.com/client/v4/zones/${t.zone_id}`).headers({
286
- Authorization: `Bearer ${t.api_key}`,
2846
+ var _;
2847
+ (function(r) {
2848
+ r.ZodString = "ZodString", r.ZodNumber = "ZodNumber", r.ZodNaN = "ZodNaN", r.ZodBigInt = "ZodBigInt", r.ZodBoolean = "ZodBoolean", r.ZodDate = "ZodDate", r.ZodSymbol = "ZodSymbol", r.ZodUndefined = "ZodUndefined", r.ZodNull = "ZodNull", r.ZodAny = "ZodAny", r.ZodUnknown = "ZodUnknown", r.ZodNever = "ZodNever", r.ZodVoid = "ZodVoid", r.ZodArray = "ZodArray", r.ZodObject = "ZodObject", r.ZodUnion = "ZodUnion", r.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", r.ZodIntersection = "ZodIntersection", r.ZodTuple = "ZodTuple", r.ZodRecord = "ZodRecord", r.ZodMap = "ZodMap", r.ZodSet = "ZodSet", r.ZodFunction = "ZodFunction", r.ZodLazy = "ZodLazy", r.ZodLiteral = "ZodLiteral", r.ZodEnum = "ZodEnum", r.ZodEffects = "ZodEffects", r.ZodNativeEnum = "ZodNativeEnum", r.ZodOptional = "ZodOptional", r.ZodNullable = "ZodNullable", r.ZodDefault = "ZodDefault", r.ZodCatch = "ZodCatch", r.ZodPromise = "ZodPromise", r.ZodBranded = "ZodBranded", r.ZodPipeline = "ZodPipeline", r.ZodReadonly = "ZodReadonly";
2849
+ })(_ || (_ = {}));
2850
+ const Rt = (r, e = {
2851
+ message: `Input not instance of ${r.name}`
2852
+ }) => Ke((t) => t instanceof r, e), Qe = E.create, Fe = D.create, It = Se.create, At = L.create, et = ie.create, Mt = q.create, Pt = we.create, $t = oe.create, Vt = de.create, Dt = K.create, Lt = W.create, Ut = M.create, zt = Te.create, Bt = j.create, Wt = b.create, qt = b.strictCreate, Jt = ce.create, Yt = Oe.create, Ht = ue.create, Gt = I.create, Xt = le.create, Kt = Ze.create, Qt = J.create, Ft = G.create, er = fe.create, tr = he.create, rr = U.create, nr = pe.create, sr = Q.create, Be = C.create, ar = N.create, ir = z.create, or = C.createWithPreprocess, dr = ve.create, cr = () => Qe().optional(), ur = () => Fe().optional(), lr = () => et().optional(), fr = {
2853
+ string: (r) => E.create({ ...r, coerce: !0 }),
2854
+ number: (r) => D.create({ ...r, coerce: !0 }),
2855
+ boolean: (r) => ie.create({
2856
+ ...r,
2857
+ coerce: !0
2858
+ }),
2859
+ bigint: (r) => L.create({ ...r, coerce: !0 }),
2860
+ date: (r) => q.create({ ...r, coerce: !0 })
2861
+ }, hr = y;
2862
+ var p = /* @__PURE__ */ Object.freeze({
2863
+ __proto__: null,
2864
+ defaultErrorMap: X,
2865
+ setErrorMap: ht,
2866
+ getErrorMap: xe,
2867
+ makeIssue: be,
2868
+ EMPTY_PATH: pt,
2869
+ addIssueToContext: l,
2870
+ ParseStatus: T,
2871
+ INVALID: y,
2872
+ DIRTY: H,
2873
+ OK: Z,
2874
+ isAborted: Ve,
2875
+ isDirty: De,
2876
+ isValid: se,
2877
+ isAsync: ae,
2878
+ get util() {
2879
+ return x;
2880
+ },
2881
+ get objectUtil() {
2882
+ return $e;
2883
+ },
2884
+ ZodParsedType: f,
2885
+ getParsedType: V,
2886
+ ZodType: g,
2887
+ datetimeRegex: Ge,
2888
+ ZodString: E,
2889
+ ZodNumber: D,
2890
+ ZodBigInt: L,
2891
+ ZodBoolean: ie,
2892
+ ZodDate: q,
2893
+ ZodSymbol: we,
2894
+ ZodUndefined: oe,
2895
+ ZodNull: de,
2896
+ ZodAny: K,
2897
+ ZodUnknown: W,
2898
+ ZodNever: M,
2899
+ ZodVoid: Te,
2900
+ ZodArray: j,
2901
+ ZodObject: b,
2902
+ ZodUnion: ce,
2903
+ ZodDiscriminatedUnion: Oe,
2904
+ ZodIntersection: ue,
2905
+ ZodTuple: I,
2906
+ ZodRecord: le,
2907
+ ZodMap: Ze,
2908
+ ZodSet: J,
2909
+ ZodFunction: G,
2910
+ ZodLazy: fe,
2911
+ ZodLiteral: he,
2912
+ ZodEnum: U,
2913
+ ZodNativeEnum: pe,
2914
+ ZodPromise: Q,
2915
+ ZodEffects: C,
2916
+ ZodTransformer: C,
2917
+ ZodOptional: N,
2918
+ ZodNullable: z,
2919
+ ZodDefault: me,
2920
+ ZodCatch: _e,
2921
+ ZodNaN: Se,
2922
+ BRAND: Ct,
2923
+ ZodBranded: Ue,
2924
+ ZodPipeline: ve,
2925
+ ZodReadonly: ye,
2926
+ custom: Ke,
2927
+ Schema: g,
2928
+ ZodSchema: g,
2929
+ late: Nt,
2930
+ get ZodFirstPartyTypeKind() {
2931
+ return _;
2932
+ },
2933
+ coerce: fr,
2934
+ any: Dt,
2935
+ array: Bt,
2936
+ bigint: At,
2937
+ boolean: et,
2938
+ date: Mt,
2939
+ discriminatedUnion: Yt,
2940
+ effect: Be,
2941
+ enum: rr,
2942
+ function: Ft,
2943
+ instanceof: Rt,
2944
+ intersection: Ht,
2945
+ lazy: er,
2946
+ literal: tr,
2947
+ map: Kt,
2948
+ nan: It,
2949
+ nativeEnum: nr,
2950
+ never: Ut,
2951
+ null: Vt,
2952
+ nullable: ir,
2953
+ number: Fe,
2954
+ object: Wt,
2955
+ oboolean: lr,
2956
+ onumber: ur,
2957
+ optional: ar,
2958
+ ostring: cr,
2959
+ pipeline: dr,
2960
+ preprocess: or,
2961
+ promise: sr,
2962
+ record: Xt,
2963
+ set: Qt,
2964
+ strictObject: qt,
2965
+ string: Qe,
2966
+ symbol: Pt,
2967
+ transformer: Be,
2968
+ tuple: Gt,
2969
+ undefined: $t,
2970
+ union: Jt,
2971
+ unknown: Lt,
2972
+ void: zt,
2973
+ NEVER: hr,
2974
+ ZodIssueCode: c,
2975
+ quotelessJson: ft,
2976
+ ZodError: S
2977
+ });
2978
+ lt(p);
2979
+ const We = p.object({
2980
+ code: p.number(),
2981
+ message: p.string()
2982
+ }), pr = p.object({
2983
+ message: p.string()
2984
+ }), mr = p.object({
2985
+ emails: p.array(p.string()),
2986
+ http_body: p.string(),
2987
+ http_url: p.string(),
2988
+ txt_name: p.string(),
2989
+ txt_value: p.string()
2990
+ }), _r = p.object({
2991
+ ciphers: p.array(p.string()),
2992
+ early_hints: p.string(),
2993
+ http2: p.string(),
2994
+ min_tls_version: p.string(),
2995
+ tls_1_3: p.string()
2996
+ }), yr = p.object({
2997
+ id: p.string(),
2998
+ bundle_method: p.string(),
2999
+ certificate_authority: p.string(),
3000
+ custom_certificate: p.string(),
3001
+ custom_csr_id: p.string(),
3002
+ custom_key: p.string(),
3003
+ expires_on: p.string(),
3004
+ hosts: p.array(p.string()),
3005
+ issuer: p.string(),
3006
+ method: p.string(),
3007
+ serial_number: p.string(),
3008
+ settings: _r,
3009
+ signature: p.string(),
3010
+ type: p.string(),
3011
+ uploaded_on: p.string(),
3012
+ validation_errors: p.array(pr),
3013
+ validation_records: p.array(mr),
3014
+ wildcard: p.boolean()
3015
+ }), vr = p.object({
3016
+ name: p.string(),
3017
+ type: p.string(),
3018
+ value: p.string()
3019
+ }), gr = p.object({
3020
+ http_body: p.string(),
3021
+ http_url: p.string()
3022
+ }), xr = p.object({
3023
+ id: p.string(),
3024
+ ssl: yr,
3025
+ custom_metadata: p.record(p.string()),
3026
+ custom_origin_server: p.string(),
3027
+ custom_origin_sni: p.string(),
3028
+ ownership_verification: vr,
3029
+ ownership_verification_http: gr,
3030
+ status: p.string(),
3031
+ verification_errors: p.array(p.string())
3032
+ }), br = p.object({
3033
+ errors: p.array(We),
3034
+ messages: p.array(We),
3035
+ success: p.boolean(),
3036
+ result: xr
3037
+ });
3038
+ function kr(r) {
3039
+ return tt(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({
3040
+ "X-Auth-Email": r.authEmail,
3041
+ "X-Auth-Key": r.authKey,
287
3042
  "Content-Type": "application/json"
288
- }).middlewares([W(), G()]);
3043
+ }).middlewares([dt(), at()]);
289
3044
  }
290
- async function Y(t) {
291
- return await H(t).post(
292
- {
293
- hostname: t.domain,
294
- ssl: {
295
- method: "http",
296
- type: "dv"
297
- }
3045
+ function wr(r) {
3046
+ return {
3047
+ create: async (e, t) => {
3048
+ const { result: n, errors: s, success: a } = br.parse(
3049
+ await kr(r).post(
3050
+ {
3051
+ hostname: t.domain,
3052
+ ssl: {
3053
+ method: "http",
3054
+ type: "dv"
3055
+ }
3056
+ },
3057
+ "/custom_hostnames"
3058
+ ).json()
3059
+ );
3060
+ if (!a)
3061
+ throw new Error(JSON.stringify(s));
3062
+ return {
3063
+ custom_domain_id: n.id,
3064
+ tenant_id: e,
3065
+ domain: n.ssl.hosts[0],
3066
+ primary: !1,
3067
+ status: n.status === "active" ? "ready" : "pending",
3068
+ type: "auth0_managed_certs"
3069
+ };
298
3070
  },
299
- "/custom_hostnames"
300
- ).json();
3071
+ get: async (e, t) => {
3072
+ throw console.log("get", e, t), new Error("Not implemented");
3073
+ },
3074
+ list: async (e) => {
3075
+ throw console.log("list", e), new Error("Not implemented");
3076
+ },
3077
+ remove: async (e, t) => {
3078
+ throw console.log("remove", e, t), new Error("Not implemented");
3079
+ },
3080
+ update: async (e, t) => {
3081
+ throw console.log("update", e, t), new Error("Not implemented");
3082
+ }
3083
+ };
301
3084
  }
302
- async function Q(t) {
303
- return await H(t).get(`/custom_hostnames/${t.domain}`).json();
3085
+ function Zr(r) {
3086
+ return {
3087
+ customDomains: wr(r)
3088
+ };
304
3089
  }
305
3090
  export {
306
- Q as getCustomDomain,
307
- Y as registerCustomDomain
3091
+ Zr as default
308
3092
  };