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