@golemui/gui-lit 1.5.0-rc.1 → 1.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 (4) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/index.js +12 -2321
  3. package/index.umd.cjs +128 -130
  4. package/package.json +6 -6
package/index.js CHANGED
@@ -1,2318 +1,9 @@
1
1
  import "@golemui/gui-shared";
2
- import { safeDefine as on } from "@golemui/lit/internals";
3
- import { resolveFormInput as sn } from "@golemui/gui-shared/internals";
4
- import { standardValidate as oe, isStandardValidateSuccess as se, filterTap as an } from "@golemui/core";
5
- import { createFormComponent as cn } from "@golemui/lit";
6
- function u(e, n, t) {
7
- function r(a, c) {
8
- if (a._zod || Object.defineProperty(a, "_zod", {
9
- value: {
10
- def: c,
11
- constr: s,
12
- traits: /* @__PURE__ */ new Set()
13
- },
14
- enumerable: !1
15
- }), a._zod.traits.has(e))
16
- return;
17
- a._zod.traits.add(e), n(a, c);
18
- const f = s.prototype, m = Object.keys(f);
19
- for (let h = 0; h < m.length; h++) {
20
- const g = m[h];
21
- g in a || (a[g] = f[g].bind(a));
22
- }
23
- }
24
- const o = t?.Parent ?? Object;
25
- class i extends o {
26
- }
27
- Object.defineProperty(i, "name", { value: e });
28
- function s(a) {
29
- var c;
30
- const f = t?.Parent ? new i() : this;
31
- r(f, a), (c = f._zod).deferred ?? (c.deferred = []);
32
- for (const m of f._zod.deferred)
33
- m();
34
- return f;
35
- }
36
- return Object.defineProperty(s, "init", { value: r }), Object.defineProperty(s, Symbol.hasInstance, {
37
- value: (a) => t?.Parent && a instanceof t.Parent ? !0 : a?._zod?.traits?.has(e)
38
- }), Object.defineProperty(s, "name", { value: e }), s;
39
- }
40
- class A extends Error {
41
- constructor() {
42
- super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
43
- }
44
- }
45
- class Ie extends Error {
46
- constructor(n) {
47
- super(`Encountered unidirectional transform during encode: ${n}`), this.name = "ZodEncodeError";
48
- }
49
- }
50
- const un = {};
51
- function S(e) {
52
- return un;
53
- }
54
- function H(e, n) {
55
- return typeof n == "bigint" ? n.toString() : n;
56
- }
57
- function ie(e) {
58
- return e == null;
59
- }
60
- function ae(e) {
61
- const n = e.startsWith("^") ? 1 : 0, t = e.endsWith("$") ? e.length - 1 : e.length;
62
- return e.slice(n, t);
63
- }
64
- const le = /* @__PURE__ */ Symbol("evaluating");
65
- function p(e, n, t) {
66
- let r;
67
- Object.defineProperty(e, n, {
68
- get() {
69
- if (r !== le)
70
- return r === void 0 && (r = le, r = t()), r;
71
- },
72
- set(o) {
73
- Object.defineProperty(e, n, {
74
- value: o
75
- // configurable: true,
76
- });
77
- },
78
- configurable: !0
79
- });
80
- }
81
- function fn(...e) {
82
- const n = {};
83
- for (const t of e) {
84
- const r = Object.getOwnPropertyDescriptors(t);
85
- Object.assign(n, r);
86
- }
87
- return Object.defineProperties({}, n);
88
- }
89
- function mn(e) {
90
- return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
91
- }
92
- const Ae = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
93
- };
94
- function de(e) {
95
- return typeof e == "object" && e !== null && !Array.isArray(e);
96
- }
97
- function Q(e) {
98
- if (de(e) === !1)
99
- return !1;
100
- const n = e.constructor;
101
- if (n === void 0 || typeof n != "function")
102
- return !0;
103
- const t = n.prototype;
104
- return !(de(t) === !1 || Object.prototype.hasOwnProperty.call(t, "isPrototypeOf") === !1);
105
- }
106
- function Ne(e) {
107
- return Q(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
108
- }
109
- function ce(e) {
110
- return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
111
- }
112
- function Me(e, n, t) {
113
- const r = new e._zod.constr(n ?? e._zod.def);
114
- return (!n || t?.parent) && (r._zod.parent = e), r;
115
- }
116
- function l(e) {
117
- const n = e;
118
- if (!n)
119
- return {};
120
- if (typeof n == "string")
121
- return { error: () => n };
122
- if (n?.message !== void 0) {
123
- if (n?.error !== void 0)
124
- throw new Error("Cannot specify both `message` and `error` params");
125
- n.error = n.message;
126
- }
127
- return delete n.message, typeof n.error == "string" ? { ...n, error: () => n.error } : n;
128
- }
129
- const ln = {
130
- safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
131
- int32: [-2147483648, 2147483647],
132
- uint32: [0, 4294967295],
133
- float32: [-34028234663852886e22, 34028234663852886e22],
134
- float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
135
- };
136
- function I(e, n = 0) {
137
- if (e.aborted === !0)
138
- return !0;
139
- for (let t = n; t < e.issues.length; t++)
140
- if (e.issues[t]?.continue !== !0)
141
- return !0;
142
- return !1;
143
- }
144
- function dn(e, n) {
145
- return n.map((t) => {
146
- var r;
147
- return (r = t).path ?? (r.path = []), t.path.unshift(e), t;
148
- });
149
- }
150
- function U(e) {
151
- return typeof e == "string" ? e : e?.message;
152
- }
153
- function T(e, n, t) {
154
- const r = { ...e, path: e.path ?? [] };
155
- if (!e.message) {
156
- const o = U(e.inst?._zod.def?.error?.(e)) ?? U(n?.error?.(e)) ?? U(t.customError?.(e)) ?? U(t.localeError?.(e)) ?? "Invalid input";
157
- r.message = o;
158
- }
159
- return delete r.inst, delete r.continue, n?.reportInput || delete r.input, r;
160
- }
161
- function ue(e) {
162
- return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
163
- }
164
- function F(...e) {
165
- const [n, t, r] = e;
166
- return typeof n == "string" ? {
167
- message: n,
168
- code: "custom",
169
- input: t,
170
- inst: r
171
- } : { ...n };
172
- }
173
- const Re = (e, n) => {
174
- e.name = "$ZodError", Object.defineProperty(e, "_zod", {
175
- value: e._zod,
176
- enumerable: !1
177
- }), Object.defineProperty(e, "issues", {
178
- value: n,
179
- enumerable: !1
180
- }), e.message = JSON.stringify(n, H, 2), Object.defineProperty(e, "toString", {
181
- value: () => e.message,
182
- enumerable: !1
183
- });
184
- }, Ce = u("$ZodError", Re), V = u("$ZodError", Re, { Parent: Error });
185
- function pn(e, n = (t) => t.message) {
186
- const t = {}, r = [];
187
- for (const o of e.issues)
188
- o.path.length > 0 ? (t[o.path[0]] = t[o.path[0]] || [], t[o.path[0]].push(n(o))) : r.push(n(o));
189
- return { formErrors: r, fieldErrors: t };
190
- }
191
- function hn(e, n = (t) => t.message) {
192
- const t = { _errors: [] }, r = (o) => {
193
- for (const i of o.issues)
194
- if (i.code === "invalid_union" && i.errors.length)
195
- i.errors.map((s) => r({ issues: s }));
196
- else if (i.code === "invalid_key")
197
- r({ issues: i.issues });
198
- else if (i.code === "invalid_element")
199
- r({ issues: i.issues });
200
- else if (i.path.length === 0)
201
- t._errors.push(n(i));
202
- else {
203
- let s = t, a = 0;
204
- for (; a < i.path.length; ) {
205
- const c = i.path[a];
206
- a === i.path.length - 1 ? (s[c] = s[c] || { _errors: [] }, s[c]._errors.push(n(i))) : s[c] = s[c] || { _errors: [] }, s = s[c], a++;
207
- }
208
- }
209
- };
210
- return r(e), t;
211
- }
212
- const q = (e) => (n, t, r, o) => {
213
- const i = r ? Object.assign(r, { async: !1 }) : { async: !1 }, s = n._zod.run({ value: t, issues: [] }, i);
214
- if (s instanceof Promise)
215
- throw new A();
216
- if (s.issues.length) {
217
- const a = new (o?.Err ?? e)(s.issues.map((c) => T(c, i, S())));
218
- throw Ae(a, o?.callee), a;
219
- }
220
- return s.value;
221
- }, gn = /* @__PURE__ */ q(V), W = (e) => async (n, t, r, o) => {
222
- const i = r ? Object.assign(r, { async: !0 }) : { async: !0 };
223
- let s = n._zod.run({ value: t, issues: [] }, i);
224
- if (s instanceof Promise && (s = await s), s.issues.length) {
225
- const a = new (o?.Err ?? e)(s.issues.map((c) => T(c, i, S())));
226
- throw Ae(a, o?.callee), a;
227
- }
228
- return s.value;
229
- }, _n = /* @__PURE__ */ W(V), G = (e) => (n, t, r) => {
230
- const o = r ? { ...r, async: !1 } : { async: !1 }, i = n._zod.run({ value: t, issues: [] }, o);
231
- if (i instanceof Promise)
232
- throw new A();
233
- return i.issues.length ? {
234
- success: !1,
235
- error: new (e ?? Ce)(i.issues.map((s) => T(s, o, S())))
236
- } : { success: !0, data: i.value };
237
- }, je = /* @__PURE__ */ G(V), B = (e) => async (n, t, r) => {
238
- const o = r ? Object.assign(r, { async: !0 }) : { async: !0 };
239
- let i = n._zod.run({ value: t, issues: [] }, o);
240
- return i instanceof Promise && (i = await i), i.issues.length ? {
241
- success: !1,
242
- error: new e(i.issues.map((s) => T(s, o, S())))
243
- } : { success: !0, data: i.value };
244
- }, Fe = /* @__PURE__ */ B(V), yn = (e) => (n, t, r) => {
245
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
246
- return q(e)(n, t, o);
247
- }, wn = (e) => (n, t, r) => q(e)(n, t, r), vn = (e) => async (n, t, r) => {
248
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
249
- return W(e)(n, t, o);
250
- }, bn = (e) => async (n, t, r) => W(e)(n, t, r), zn = (e) => (n, t, r) => {
251
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
252
- return G(e)(n, t, o);
253
- }, kn = (e) => (n, t, r) => G(e)(n, t, r), $n = (e) => async (n, t, r) => {
254
- const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
255
- return B(e)(n, t, o);
256
- }, Zn = (e) => async (n, t, r) => B(e)(n, t, r), En = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, pe = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Sn = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Tn = /^(?:(?: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])$/, On = /^(([0-9a-fA-F]{1,4}:){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}|:))$/, Pn = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, De = "(?:(?:\\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])))", In = /* @__PURE__ */ new RegExp(`^${De}$`);
257
- function xe(e) {
258
- const n = "(?:[01]\\d|2[0-3]):[0-5]\\d";
259
- return typeof e.precision == "number" ? e.precision === -1 ? `${n}` : e.precision === 0 ? `${n}:[0-5]\\d` : `${n}:[0-5]\\d\\.\\d{${e.precision}}` : `${n}(?::[0-5]\\d(?:\\.\\d+)?)?`;
260
- }
261
- function An(e) {
262
- return new RegExp(`^${xe(e)}$`);
263
- }
264
- function Nn(e) {
265
- const n = xe({ precision: e.precision }), t = ["Z"];
266
- e.local && t.push(""), e.offset && t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
267
- const r = `${n}(?:${t.join("|")})`;
268
- return new RegExp(`^${De}T(?:${r})$`);
269
- }
270
- const Mn = (e) => {
271
- const n = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
272
- return new RegExp(`^${n}$`);
273
- }, Rn = /^-?\d+$/, Cn = /^-?\d+(?:\.\d+)?$/, jn = /^(?:true|false)$/i, Fn = /^[^A-Z]*$/, Dn = /^[^a-z]*$/, k = /* @__PURE__ */ u("$ZodCheck", (e, n) => {
274
- var t;
275
- e._zod ?? (e._zod = {}), e._zod.def = n, (t = e._zod).onattach ?? (t.onattach = []);
276
- }), Ue = {
277
- number: "number",
278
- bigint: "bigint",
279
- object: "date"
280
- }, xn = /* @__PURE__ */ u("$ZodCheckLessThan", (e, n) => {
281
- k.init(e, n);
282
- const t = Ue[typeof n.value];
283
- e._zod.onattach.push((r) => {
284
- const o = r._zod.bag, i = (n.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
285
- n.value < i && (n.inclusive ? o.maximum = n.value : o.exclusiveMaximum = n.value);
286
- }), e._zod.check = (r) => {
287
- (n.inclusive ? r.value <= n.value : r.value < n.value) || r.issues.push({
288
- origin: t,
289
- code: "too_big",
290
- maximum: typeof n.value == "object" ? n.value.getTime() : n.value,
291
- input: r.value,
292
- inclusive: n.inclusive,
293
- inst: e,
294
- continue: !n.abort
295
- });
296
- };
297
- }), Un = /* @__PURE__ */ u("$ZodCheckGreaterThan", (e, n) => {
298
- k.init(e, n);
299
- const t = Ue[typeof n.value];
300
- e._zod.onattach.push((r) => {
301
- const o = r._zod.bag, i = (n.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
302
- n.value > i && (n.inclusive ? o.minimum = n.value : o.exclusiveMinimum = n.value);
303
- }), e._zod.check = (r) => {
304
- (n.inclusive ? r.value >= n.value : r.value > n.value) || r.issues.push({
305
- origin: t,
306
- code: "too_small",
307
- minimum: typeof n.value == "object" ? n.value.getTime() : n.value,
308
- input: r.value,
309
- inclusive: n.inclusive,
310
- inst: e,
311
- continue: !n.abort
312
- });
313
- };
314
- }), Ln = /* @__PURE__ */ u("$ZodCheckNumberFormat", (e, n) => {
315
- k.init(e, n), n.format = n.format || "float64";
316
- const t = n.format?.includes("int"), r = t ? "int" : "number", [o, i] = ln[n.format];
317
- e._zod.onattach.push((s) => {
318
- const a = s._zod.bag;
319
- a.format = n.format, a.minimum = o, a.maximum = i, t && (a.pattern = Rn);
320
- }), e._zod.check = (s) => {
321
- const a = s.value;
322
- if (t) {
323
- if (!Number.isInteger(a)) {
324
- s.issues.push({
325
- expected: r,
326
- format: n.format,
327
- code: "invalid_type",
328
- continue: !1,
329
- input: a,
330
- inst: e
331
- });
332
- return;
333
- }
334
- if (!Number.isSafeInteger(a)) {
335
- a > 0 ? s.issues.push({
336
- input: a,
337
- code: "too_big",
338
- maximum: Number.MAX_SAFE_INTEGER,
339
- note: "Integers must be within the safe integer range.",
340
- inst: e,
341
- origin: r,
342
- inclusive: !0,
343
- continue: !n.abort
344
- }) : s.issues.push({
345
- input: a,
346
- code: "too_small",
347
- minimum: Number.MIN_SAFE_INTEGER,
348
- note: "Integers must be within the safe integer range.",
349
- inst: e,
350
- origin: r,
351
- inclusive: !0,
352
- continue: !n.abort
353
- });
354
- return;
355
- }
356
- }
357
- a < o && s.issues.push({
358
- origin: "number",
359
- input: a,
360
- code: "too_small",
361
- minimum: o,
362
- inclusive: !0,
363
- inst: e,
364
- continue: !n.abort
365
- }), a > i && s.issues.push({
366
- origin: "number",
367
- input: a,
368
- code: "too_big",
369
- maximum: i,
370
- inclusive: !0,
371
- inst: e,
372
- continue: !n.abort
373
- });
374
- };
375
- }), Jn = /* @__PURE__ */ u("$ZodCheckMaxLength", (e, n) => {
376
- var t;
377
- k.init(e, n), (t = e._zod.def).when ?? (t.when = (r) => {
378
- const o = r.value;
379
- return !ie(o) && o.length !== void 0;
380
- }), e._zod.onattach.push((r) => {
381
- const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
382
- n.maximum < o && (r._zod.bag.maximum = n.maximum);
383
- }), e._zod.check = (r) => {
384
- const o = r.value;
385
- if (o.length <= n.maximum)
386
- return;
387
- const s = ue(o);
388
- r.issues.push({
389
- origin: s,
390
- code: "too_big",
391
- maximum: n.maximum,
392
- inclusive: !0,
393
- input: o,
394
- inst: e,
395
- continue: !n.abort
396
- });
397
- };
398
- }), Vn = /* @__PURE__ */ u("$ZodCheckMinLength", (e, n) => {
399
- var t;
400
- k.init(e, n), (t = e._zod.def).when ?? (t.when = (r) => {
401
- const o = r.value;
402
- return !ie(o) && o.length !== void 0;
403
- }), e._zod.onattach.push((r) => {
404
- const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
405
- n.minimum > o && (r._zod.bag.minimum = n.minimum);
406
- }), e._zod.check = (r) => {
407
- const o = r.value;
408
- if (o.length >= n.minimum)
409
- return;
410
- const s = ue(o);
411
- r.issues.push({
412
- origin: s,
413
- code: "too_small",
414
- minimum: n.minimum,
415
- inclusive: !0,
416
- input: o,
417
- inst: e,
418
- continue: !n.abort
419
- });
420
- };
421
- }), qn = /* @__PURE__ */ u("$ZodCheckLengthEquals", (e, n) => {
422
- var t;
423
- k.init(e, n), (t = e._zod.def).when ?? (t.when = (r) => {
424
- const o = r.value;
425
- return !ie(o) && o.length !== void 0;
426
- }), e._zod.onattach.push((r) => {
427
- const o = r._zod.bag;
428
- o.minimum = n.length, o.maximum = n.length, o.length = n.length;
429
- }), e._zod.check = (r) => {
430
- const o = r.value, i = o.length;
431
- if (i === n.length)
432
- return;
433
- const s = ue(o), a = i > n.length;
434
- r.issues.push({
435
- origin: s,
436
- ...a ? { code: "too_big", maximum: n.length } : { code: "too_small", minimum: n.length },
437
- inclusive: !0,
438
- exact: !0,
439
- input: r.value,
440
- inst: e,
441
- continue: !n.abort
442
- });
443
- };
444
- }), K = /* @__PURE__ */ u("$ZodCheckStringFormat", (e, n) => {
445
- var t, r;
446
- k.init(e, n), e._zod.onattach.push((o) => {
447
- const i = o._zod.bag;
448
- i.format = n.format, n.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(n.pattern));
449
- }), n.pattern ? (t = e._zod).check ?? (t.check = (o) => {
450
- n.pattern.lastIndex = 0, !n.pattern.test(o.value) && o.issues.push({
451
- origin: "string",
452
- code: "invalid_format",
453
- format: n.format,
454
- input: o.value,
455
- ...n.pattern ? { pattern: n.pattern.toString() } : {},
456
- inst: e,
457
- continue: !n.abort
458
- });
459
- }) : (r = e._zod).check ?? (r.check = () => {
460
- });
461
- }), Wn = /* @__PURE__ */ u("$ZodCheckRegex", (e, n) => {
462
- K.init(e, n), e._zod.check = (t) => {
463
- n.pattern.lastIndex = 0, !n.pattern.test(t.value) && t.issues.push({
464
- origin: "string",
465
- code: "invalid_format",
466
- format: "regex",
467
- input: t.value,
468
- pattern: n.pattern.toString(),
469
- inst: e,
470
- continue: !n.abort
471
- });
472
- };
473
- }), Gn = /* @__PURE__ */ u("$ZodCheckLowerCase", (e, n) => {
474
- n.pattern ?? (n.pattern = Fn), K.init(e, n);
475
- }), Bn = /* @__PURE__ */ u("$ZodCheckUpperCase", (e, n) => {
476
- n.pattern ?? (n.pattern = Dn), K.init(e, n);
477
- }), Kn = /* @__PURE__ */ u("$ZodCheckIncludes", (e, n) => {
478
- k.init(e, n);
479
- const t = ce(n.includes), r = new RegExp(typeof n.position == "number" ? `^.{${n.position}}${t}` : t);
480
- n.pattern = r, e._zod.onattach.push((o) => {
481
- const i = o._zod.bag;
482
- i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(r);
483
- }), e._zod.check = (o) => {
484
- o.value.includes(n.includes, n.position) || o.issues.push({
485
- origin: "string",
486
- code: "invalid_format",
487
- format: "includes",
488
- includes: n.includes,
489
- input: o.value,
490
- inst: e,
491
- continue: !n.abort
492
- });
493
- };
494
- }), Yn = /* @__PURE__ */ u("$ZodCheckStartsWith", (e, n) => {
495
- k.init(e, n);
496
- const t = new RegExp(`^${ce(n.prefix)}.*`);
497
- n.pattern ?? (n.pattern = t), e._zod.onattach.push((r) => {
498
- const o = r._zod.bag;
499
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(t);
500
- }), e._zod.check = (r) => {
501
- r.value.startsWith(n.prefix) || r.issues.push({
502
- origin: "string",
503
- code: "invalid_format",
504
- format: "starts_with",
505
- prefix: n.prefix,
506
- input: r.value,
507
- inst: e,
508
- continue: !n.abort
509
- });
510
- };
511
- }), Xn = /* @__PURE__ */ u("$ZodCheckEndsWith", (e, n) => {
512
- k.init(e, n);
513
- const t = new RegExp(`.*${ce(n.suffix)}$`);
514
- n.pattern ?? (n.pattern = t), e._zod.onattach.push((r) => {
515
- const o = r._zod.bag;
516
- o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(t);
517
- }), e._zod.check = (r) => {
518
- r.value.endsWith(n.suffix) || r.issues.push({
519
- origin: "string",
520
- code: "invalid_format",
521
- format: "ends_with",
522
- suffix: n.suffix,
523
- input: r.value,
524
- inst: e,
525
- continue: !n.abort
526
- });
527
- };
528
- }), Hn = /* @__PURE__ */ u("$ZodCheckOverwrite", (e, n) => {
529
- k.init(e, n), e._zod.check = (t) => {
530
- t.value = n.tx(t.value);
531
- };
532
- }), Qn = {
533
- major: 4,
534
- minor: 3,
535
- patch: 6
536
- }, w = /* @__PURE__ */ u("$ZodType", (e, n) => {
537
- var t;
538
- e ?? (e = {}), e._zod.def = n, e._zod.bag = e._zod.bag || {}, e._zod.version = Qn;
539
- const r = [...e._zod.def.checks ?? []];
540
- e._zod.traits.has("$ZodCheck") && r.unshift(e);
541
- for (const o of r)
542
- for (const i of o._zod.onattach)
543
- i(e);
544
- if (r.length === 0)
545
- (t = e._zod).deferred ?? (t.deferred = []), e._zod.deferred?.push(() => {
546
- e._zod.run = e._zod.parse;
547
- });
548
- else {
549
- const o = (s, a, c) => {
550
- let f = I(s), m;
551
- for (const h of a) {
552
- if (h._zod.def.when) {
553
- if (!h._zod.def.when(s))
554
- continue;
555
- } else if (f)
556
- continue;
557
- const g = s.issues.length, _ = h._zod.check(s);
558
- if (_ instanceof Promise && c?.async === !1)
559
- throw new A();
560
- if (m || _ instanceof Promise)
561
- m = (m ?? Promise.resolve()).then(async () => {
562
- await _, s.issues.length !== g && (f || (f = I(s, g)));
563
- });
564
- else {
565
- if (s.issues.length === g)
566
- continue;
567
- f || (f = I(s, g));
568
- }
569
- }
570
- return m ? m.then(() => s) : s;
571
- }, i = (s, a, c) => {
572
- if (I(s))
573
- return s.aborted = !0, s;
574
- const f = o(a, r, c);
575
- if (f instanceof Promise) {
576
- if (c.async === !1)
577
- throw new A();
578
- return f.then((m) => e._zod.parse(m, c));
579
- }
580
- return e._zod.parse(f, c);
581
- };
582
- e._zod.run = (s, a) => {
583
- if (a.skipChecks)
584
- return e._zod.parse(s, a);
585
- if (a.direction === "backward") {
586
- const f = e._zod.parse({ value: s.value, issues: [] }, { ...a, skipChecks: !0 });
587
- return f instanceof Promise ? f.then((m) => i(m, s, a)) : i(f, s, a);
588
- }
589
- const c = e._zod.parse(s, a);
590
- if (c instanceof Promise) {
591
- if (a.async === !1)
592
- throw new A();
593
- return c.then((f) => o(f, r, a));
594
- }
595
- return o(c, r, a);
596
- };
597
- }
598
- p(e, "~standard", () => ({
599
- validate: (o) => {
600
- try {
601
- const i = je(e, o);
602
- return i.success ? { value: i.data } : { issues: i.error?.issues };
603
- } catch {
604
- return Fe(e, o).then((s) => s.success ? { value: s.data } : { issues: s.error?.issues });
605
- }
606
- },
607
- vendor: "zod",
608
- version: 1
609
- }));
610
- }), fe = /* @__PURE__ */ u("$ZodString", (e, n) => {
611
- w.init(e, n), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? Mn(e._zod.bag), e._zod.parse = (t, r) => {
612
- if (n.coerce)
613
- try {
614
- t.value = String(t.value);
615
- } catch {
616
- }
617
- return typeof t.value == "string" || t.issues.push({
618
- expected: "string",
619
- code: "invalid_type",
620
- input: t.value,
621
- inst: e
622
- }), t;
623
- };
624
- }), $ = /* @__PURE__ */ u("$ZodStringFormat", (e, n) => {
625
- K.init(e, n), fe.init(e, n);
626
- }), et = /* @__PURE__ */ u("$ZodUUID", (e, n) => {
627
- if (n.version) {
628
- const r = {
629
- v1: 1,
630
- v2: 2,
631
- v3: 3,
632
- v4: 4,
633
- v5: 5,
634
- v6: 6,
635
- v7: 7,
636
- v8: 8
637
- }[n.version];
638
- if (r === void 0)
639
- throw new Error(`Invalid UUID version: "${n.version}"`);
640
- n.pattern ?? (n.pattern = pe(r));
641
- } else
642
- n.pattern ?? (n.pattern = pe());
643
- $.init(e, n);
644
- }), nt = /* @__PURE__ */ u("$ZodEmail", (e, n) => {
645
- n.pattern ?? (n.pattern = Sn), $.init(e, n);
646
- }), tt = /* @__PURE__ */ u("$ZodURL", (e, n) => {
647
- $.init(e, n), e._zod.check = (t) => {
648
- try {
649
- const r = t.value.trim(), o = new URL(r);
650
- n.hostname && (n.hostname.lastIndex = 0, n.hostname.test(o.hostname) || t.issues.push({
651
- code: "invalid_format",
652
- format: "url",
653
- note: "Invalid hostname",
654
- pattern: n.hostname.source,
655
- input: t.value,
656
- inst: e,
657
- continue: !n.abort
658
- })), n.protocol && (n.protocol.lastIndex = 0, n.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || t.issues.push({
659
- code: "invalid_format",
660
- format: "url",
661
- note: "Invalid protocol",
662
- pattern: n.protocol.source,
663
- input: t.value,
664
- inst: e,
665
- continue: !n.abort
666
- })), n.normalize ? t.value = o.href : t.value = r;
667
- return;
668
- } catch {
669
- t.issues.push({
670
- code: "invalid_format",
671
- format: "url",
672
- input: t.value,
673
- inst: e,
674
- continue: !n.abort
675
- });
676
- }
677
- };
678
- }), rt = /* @__PURE__ */ u("$ZodISODateTime", (e, n) => {
679
- n.pattern ?? (n.pattern = Nn(n)), $.init(e, n);
680
- }), ot = /* @__PURE__ */ u("$ZodISODate", (e, n) => {
681
- n.pattern ?? (n.pattern = In), $.init(e, n);
682
- }), st = /* @__PURE__ */ u("$ZodISOTime", (e, n) => {
683
- n.pattern ?? (n.pattern = An(n)), $.init(e, n);
684
- }), it = /* @__PURE__ */ u("$ZodISODuration", (e, n) => {
685
- n.pattern ?? (n.pattern = En), $.init(e, n);
686
- }), at = /* @__PURE__ */ u("$ZodIPv4", (e, n) => {
687
- n.pattern ?? (n.pattern = Tn), $.init(e, n), e._zod.bag.format = "ipv4";
688
- }), ct = /* @__PURE__ */ u("$ZodIPv6", (e, n) => {
689
- n.pattern ?? (n.pattern = On), $.init(e, n), e._zod.bag.format = "ipv6", e._zod.check = (t) => {
690
- try {
691
- new URL(`http://[${t.value}]`);
692
- } catch {
693
- t.issues.push({
694
- code: "invalid_format",
695
- format: "ipv6",
696
- input: t.value,
697
- inst: e,
698
- continue: !n.abort
699
- });
700
- }
701
- };
702
- }), ut = /* @__PURE__ */ u("$ZodCustomStringFormat", (e, n) => {
703
- $.init(e, n), e._zod.check = (t) => {
704
- n.fn(t.value) || t.issues.push({
705
- code: "invalid_format",
706
- format: n.format,
707
- input: t.value,
708
- inst: e,
709
- continue: !n.abort
710
- });
711
- };
712
- }), Le = /* @__PURE__ */ u("$ZodNumber", (e, n) => {
713
- w.init(e, n), e._zod.pattern = e._zod.bag.pattern ?? Cn, e._zod.parse = (t, r) => {
714
- if (n.coerce)
715
- try {
716
- t.value = Number(t.value);
717
- } catch {
718
- }
719
- const o = t.value;
720
- if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o))
721
- return t;
722
- const i = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
723
- return t.issues.push({
724
- expected: "number",
725
- code: "invalid_type",
726
- input: o,
727
- inst: e,
728
- ...i ? { received: i } : {}
729
- }), t;
730
- };
731
- }), ft = /* @__PURE__ */ u("$ZodNumberFormat", (e, n) => {
732
- Ln.init(e, n), Le.init(e, n);
733
- }), mt = /* @__PURE__ */ u("$ZodBoolean", (e, n) => {
734
- w.init(e, n), e._zod.pattern = jn, e._zod.parse = (t, r) => {
735
- if (n.coerce)
736
- try {
737
- t.value = !!t.value;
738
- } catch {
739
- }
740
- const o = t.value;
741
- return typeof o == "boolean" || t.issues.push({
742
- expected: "boolean",
743
- code: "invalid_type",
744
- input: o,
745
- inst: e
746
- }), t;
747
- };
748
- }), lt = /* @__PURE__ */ u("$ZodAny", (e, n) => {
749
- w.init(e, n), e._zod.parse = (t) => t;
750
- });
751
- function he(e, n, t) {
752
- e.issues.length && n.issues.push(...dn(t, e.issues)), n.value[t] = e.value;
753
- }
754
- const Je = /* @__PURE__ */ u("$ZodArray", (e, n) => {
755
- w.init(e, n), e._zod.parse = (t, r) => {
756
- const o = t.value;
757
- if (!Array.isArray(o))
758
- return t.issues.push({
759
- expected: "array",
760
- code: "invalid_type",
761
- input: o,
762
- inst: e
763
- }), t;
764
- t.value = Array(o.length);
765
- const i = [];
766
- for (let s = 0; s < o.length; s++) {
767
- const a = o[s], c = n.element._zod.run({
768
- value: a,
769
- issues: []
770
- }, r);
771
- c instanceof Promise ? i.push(c.then((f) => he(f, t, s))) : he(c, t, s);
772
- }
773
- return i.length ? Promise.all(i).then(() => t) : t;
774
- };
775
- });
776
- function ge(e, n, t, r) {
777
- for (const i of e)
778
- if (i.issues.length === 0)
779
- return n.value = i.value, n;
780
- const o = e.filter((i) => !I(i));
781
- return o.length === 1 ? (n.value = o[0].value, o[0]) : (n.issues.push({
782
- code: "invalid_union",
783
- input: n.value,
784
- inst: t,
785
- errors: e.map((i) => i.issues.map((s) => T(s, r, S())))
786
- }), n);
787
- }
788
- const dt = /* @__PURE__ */ u("$ZodUnion", (e, n) => {
789
- w.init(e, n), p(e._zod, "optin", () => n.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), p(e._zod, "optout", () => n.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), p(e._zod, "values", () => {
790
- if (n.options.every((o) => o._zod.values))
791
- return new Set(n.options.flatMap((o) => Array.from(o._zod.values)));
792
- }), p(e._zod, "pattern", () => {
793
- if (n.options.every((o) => o._zod.pattern)) {
794
- const o = n.options.map((i) => i._zod.pattern);
795
- return new RegExp(`^(${o.map((i) => ae(i.source)).join("|")})$`);
796
- }
797
- });
798
- const t = n.options.length === 1, r = n.options[0]._zod.run;
799
- e._zod.parse = (o, i) => {
800
- if (t)
801
- return r(o, i);
802
- let s = !1;
803
- const a = [];
804
- for (const c of n.options) {
805
- const f = c._zod.run({
806
- value: o.value,
807
- issues: []
808
- }, i);
809
- if (f instanceof Promise)
810
- a.push(f), s = !0;
811
- else {
812
- if (f.issues.length === 0)
813
- return f;
814
- a.push(f);
815
- }
816
- }
817
- return s ? Promise.all(a).then((c) => ge(c, o, e, i)) : ge(a, o, e, i);
818
- };
819
- }), pt = /* @__PURE__ */ u("$ZodIntersection", (e, n) => {
820
- w.init(e, n), e._zod.parse = (t, r) => {
821
- const o = t.value, i = n.left._zod.run({ value: o, issues: [] }, r), s = n.right._zod.run({ value: o, issues: [] }, r);
822
- return i instanceof Promise || s instanceof Promise ? Promise.all([i, s]).then(([c, f]) => _e(t, c, f)) : _e(t, i, s);
823
- };
824
- });
825
- function ee(e, n) {
826
- if (e === n)
827
- return { valid: !0, data: e };
828
- if (e instanceof Date && n instanceof Date && +e == +n)
829
- return { valid: !0, data: e };
830
- if (Q(e) && Q(n)) {
831
- const t = Object.keys(n), r = Object.keys(e).filter((i) => t.indexOf(i) !== -1), o = { ...e, ...n };
832
- for (const i of r) {
833
- const s = ee(e[i], n[i]);
834
- if (!s.valid)
835
- return {
836
- valid: !1,
837
- mergeErrorPath: [i, ...s.mergeErrorPath]
838
- };
839
- o[i] = s.data;
840
- }
841
- return { valid: !0, data: o };
842
- }
843
- if (Array.isArray(e) && Array.isArray(n)) {
844
- if (e.length !== n.length)
845
- return { valid: !1, mergeErrorPath: [] };
846
- const t = [];
847
- for (let r = 0; r < e.length; r++) {
848
- const o = e[r], i = n[r], s = ee(o, i);
849
- if (!s.valid)
850
- return {
851
- valid: !1,
852
- mergeErrorPath: [r, ...s.mergeErrorPath]
853
- };
854
- t.push(s.data);
855
- }
856
- return { valid: !0, data: t };
857
- }
858
- return { valid: !1, mergeErrorPath: [] };
859
- }
860
- function _e(e, n, t) {
861
- const r = /* @__PURE__ */ new Map();
862
- let o;
863
- for (const a of n.issues)
864
- if (a.code === "unrecognized_keys") {
865
- o ?? (o = a);
866
- for (const c of a.keys)
867
- r.has(c) || r.set(c, {}), r.get(c).l = !0;
868
- } else
869
- e.issues.push(a);
870
- for (const a of t.issues)
871
- if (a.code === "unrecognized_keys")
872
- for (const c of a.keys)
873
- r.has(c) || r.set(c, {}), r.get(c).r = !0;
874
- else
875
- e.issues.push(a);
876
- const i = [...r].filter(([, a]) => a.l && a.r).map(([a]) => a);
877
- if (i.length && o && e.issues.push({ ...o, keys: i }), I(e))
878
- return e;
879
- const s = ee(n.value, t.value);
880
- if (!s.valid)
881
- throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);
882
- return e.value = s.data, e;
883
- }
884
- const ht = /* @__PURE__ */ u("$ZodTransform", (e, n) => {
885
- w.init(e, n), e._zod.parse = (t, r) => {
886
- if (r.direction === "backward")
887
- throw new Ie(e.constructor.name);
888
- const o = n.transform(t.value, t);
889
- if (r.async)
890
- return (o instanceof Promise ? o : Promise.resolve(o)).then((s) => (t.value = s, t));
891
- if (o instanceof Promise)
892
- throw new A();
893
- return t.value = o, t;
894
- };
895
- });
896
- function ye(e, n) {
897
- return e.issues.length && n === void 0 ? { issues: [], value: void 0 } : e;
898
- }
899
- const me = /* @__PURE__ */ u("$ZodOptional", (e, n) => {
900
- w.init(e, n), e._zod.optin = "optional", e._zod.optout = "optional", p(e._zod, "values", () => n.innerType._zod.values ? /* @__PURE__ */ new Set([...n.innerType._zod.values, void 0]) : void 0), p(e._zod, "pattern", () => {
901
- const t = n.innerType._zod.pattern;
902
- return t ? new RegExp(`^(${ae(t.source)})?$`) : void 0;
903
- }), e._zod.parse = (t, r) => {
904
- if (n.innerType._zod.optin === "optional") {
905
- const o = n.innerType._zod.run(t, r);
906
- return o instanceof Promise ? o.then((i) => ye(i, t.value)) : ye(o, t.value);
907
- }
908
- return t.value === void 0 ? t : n.innerType._zod.run(t, r);
909
- };
910
- }), gt = /* @__PURE__ */ u("$ZodExactOptional", (e, n) => {
911
- me.init(e, n), p(e._zod, "values", () => n.innerType._zod.values), p(e._zod, "pattern", () => n.innerType._zod.pattern), e._zod.parse = (t, r) => n.innerType._zod.run(t, r);
912
- }), _t = /* @__PURE__ */ u("$ZodNullable", (e, n) => {
913
- w.init(e, n), p(e._zod, "optin", () => n.innerType._zod.optin), p(e._zod, "optout", () => n.innerType._zod.optout), p(e._zod, "pattern", () => {
914
- const t = n.innerType._zod.pattern;
915
- return t ? new RegExp(`^(${ae(t.source)}|null)$`) : void 0;
916
- }), p(e._zod, "values", () => n.innerType._zod.values ? /* @__PURE__ */ new Set([...n.innerType._zod.values, null]) : void 0), e._zod.parse = (t, r) => t.value === null ? t : n.innerType._zod.run(t, r);
917
- }), yt = /* @__PURE__ */ u("$ZodDefault", (e, n) => {
918
- w.init(e, n), e._zod.optin = "optional", p(e._zod, "values", () => n.innerType._zod.values), e._zod.parse = (t, r) => {
919
- if (r.direction === "backward")
920
- return n.innerType._zod.run(t, r);
921
- if (t.value === void 0)
922
- return t.value = n.defaultValue, t;
923
- const o = n.innerType._zod.run(t, r);
924
- return o instanceof Promise ? o.then((i) => we(i, n)) : we(o, n);
925
- };
926
- });
927
- function we(e, n) {
928
- return e.value === void 0 && (e.value = n.defaultValue), e;
929
- }
930
- const wt = /* @__PURE__ */ u("$ZodPrefault", (e, n) => {
931
- w.init(e, n), e._zod.optin = "optional", p(e._zod, "values", () => n.innerType._zod.values), e._zod.parse = (t, r) => (r.direction === "backward" || t.value === void 0 && (t.value = n.defaultValue), n.innerType._zod.run(t, r));
932
- }), vt = /* @__PURE__ */ u("$ZodNonOptional", (e, n) => {
933
- w.init(e, n), p(e._zod, "values", () => {
934
- const t = n.innerType._zod.values;
935
- return t ? new Set([...t].filter((r) => r !== void 0)) : void 0;
936
- }), e._zod.parse = (t, r) => {
937
- const o = n.innerType._zod.run(t, r);
938
- return o instanceof Promise ? o.then((i) => ve(i, e)) : ve(o, e);
939
- };
940
- });
941
- function ve(e, n) {
942
- return !e.issues.length && e.value === void 0 && e.issues.push({
943
- code: "invalid_type",
944
- expected: "nonoptional",
945
- input: e.value,
946
- inst: n
947
- }), e;
948
- }
949
- const bt = /* @__PURE__ */ u("$ZodCatch", (e, n) => {
950
- w.init(e, n), p(e._zod, "optin", () => n.innerType._zod.optin), p(e._zod, "optout", () => n.innerType._zod.optout), p(e._zod, "values", () => n.innerType._zod.values), e._zod.parse = (t, r) => {
951
- if (r.direction === "backward")
952
- return n.innerType._zod.run(t, r);
953
- const o = n.innerType._zod.run(t, r);
954
- return o instanceof Promise ? o.then((i) => (t.value = i.value, i.issues.length && (t.value = n.catchValue({
955
- ...t,
956
- error: {
957
- issues: i.issues.map((s) => T(s, r, S()))
958
- },
959
- input: t.value
960
- }), t.issues = []), t)) : (t.value = o.value, o.issues.length && (t.value = n.catchValue({
961
- ...t,
962
- error: {
963
- issues: o.issues.map((i) => T(i, r, S()))
964
- },
965
- input: t.value
966
- }), t.issues = []), t);
967
- };
968
- }), zt = /* @__PURE__ */ u("$ZodPipe", (e, n) => {
969
- w.init(e, n), p(e._zod, "values", () => n.in._zod.values), p(e._zod, "optin", () => n.in._zod.optin), p(e._zod, "optout", () => n.out._zod.optout), p(e._zod, "propValues", () => n.in._zod.propValues), e._zod.parse = (t, r) => {
970
- if (r.direction === "backward") {
971
- const i = n.out._zod.run(t, r);
972
- return i instanceof Promise ? i.then((s) => L(s, n.in, r)) : L(i, n.in, r);
973
- }
974
- const o = n.in._zod.run(t, r);
975
- return o instanceof Promise ? o.then((i) => L(i, n.out, r)) : L(o, n.out, r);
976
- };
977
- });
978
- function L(e, n, t) {
979
- return e.issues.length ? (e.aborted = !0, e) : n._zod.run({ value: e.value, issues: e.issues }, t);
980
- }
981
- const kt = /* @__PURE__ */ u("$ZodReadonly", (e, n) => {
982
- w.init(e, n), p(e._zod, "propValues", () => n.innerType._zod.propValues), p(e._zod, "values", () => n.innerType._zod.values), p(e._zod, "optin", () => n.innerType?._zod?.optin), p(e._zod, "optout", () => n.innerType?._zod?.optout), e._zod.parse = (t, r) => {
983
- if (r.direction === "backward")
984
- return n.innerType._zod.run(t, r);
985
- const o = n.innerType._zod.run(t, r);
986
- return o instanceof Promise ? o.then(be) : be(o);
987
- };
988
- });
989
- function be(e) {
990
- return e.value = Object.freeze(e.value), e;
991
- }
992
- const Ve = /* @__PURE__ */ u("$ZodCustom", (e, n) => {
993
- k.init(e, n), w.init(e, n), e._zod.parse = (t, r) => t, e._zod.check = (t) => {
994
- const r = t.value, o = n.fn(r);
995
- if (o instanceof Promise)
996
- return o.then((i) => ze(i, t, r, e));
997
- ze(o, t, r, e);
998
- };
999
- });
1000
- function ze(e, n, t, r) {
1001
- if (!e) {
1002
- const o = {
1003
- code: "custom",
1004
- input: t,
1005
- inst: r,
1006
- // incorporates params.error into issue reporting
1007
- path: [...r._zod.def.path ?? []],
1008
- // incorporates params.error into issue reporting
1009
- continue: !r._zod.def.abort
1010
- // params: inst._zod.def.params,
1011
- };
1012
- r._zod.def.params && (o.params = r._zod.def.params), n.issues.push(F(o));
1013
- }
1014
- }
1015
- var ke;
1016
- class $t {
1017
- constructor() {
1018
- this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
1019
- }
1020
- add(n, ...t) {
1021
- const r = t[0];
1022
- return this._map.set(n, r), r && typeof r == "object" && "id" in r && this._idmap.set(r.id, n), this;
1023
- }
1024
- clear() {
1025
- return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
1026
- }
1027
- remove(n) {
1028
- const t = this._map.get(n);
1029
- return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(n), this;
1030
- }
1031
- get(n) {
1032
- const t = n._zod.parent;
1033
- if (t) {
1034
- const r = { ...this.get(t) ?? {} };
1035
- delete r.id;
1036
- const o = { ...r, ...this._map.get(n) };
1037
- return Object.keys(o).length ? o : void 0;
1038
- }
1039
- return this._map.get(n);
1040
- }
1041
- has(n) {
1042
- return this._map.has(n);
1043
- }
1044
- }
1045
- function Zt() {
1046
- return new $t();
1047
- }
1048
- (ke = globalThis).__zod_globalRegistry ?? (ke.__zod_globalRegistry = Zt());
1049
- const j = globalThis.__zod_globalRegistry;
1050
- // @__NO_SIDE_EFFECTS__
1051
- function Et(e, n) {
1052
- return new e({
1053
- type: "string",
1054
- ...l(n)
1055
- });
1056
- }
1057
- // @__NO_SIDE_EFFECTS__
1058
- function St(e, n) {
1059
- return new e({
1060
- type: "string",
1061
- format: "email",
1062
- check: "string_format",
1063
- abort: !1,
1064
- ...l(n)
1065
- });
1066
- }
1067
- // @__NO_SIDE_EFFECTS__
1068
- function Tt(e, n) {
1069
- return new e({
1070
- type: "string",
1071
- format: "uuid",
1072
- check: "string_format",
1073
- abort: !1,
1074
- ...l(n)
1075
- });
1076
- }
1077
- // @__NO_SIDE_EFFECTS__
1078
- function Ot(e, n) {
1079
- return new e({
1080
- type: "string",
1081
- format: "url",
1082
- check: "string_format",
1083
- abort: !1,
1084
- ...l(n)
1085
- });
1086
- }
1087
- // @__NO_SIDE_EFFECTS__
1088
- function Pt(e, n) {
1089
- return new e({
1090
- type: "string",
1091
- format: "ipv4",
1092
- check: "string_format",
1093
- abort: !1,
1094
- ...l(n)
1095
- });
1096
- }
1097
- // @__NO_SIDE_EFFECTS__
1098
- function It(e, n) {
1099
- return new e({
1100
- type: "string",
1101
- format: "ipv6",
1102
- check: "string_format",
1103
- abort: !1,
1104
- ...l(n)
1105
- });
1106
- }
1107
- // @__NO_SIDE_EFFECTS__
1108
- function At(e, n) {
1109
- return new e({
1110
- type: "string",
1111
- format: "datetime",
1112
- check: "string_format",
1113
- offset: !1,
1114
- local: !1,
1115
- precision: null,
1116
- ...l(n)
1117
- });
1118
- }
1119
- // @__NO_SIDE_EFFECTS__
1120
- function Nt(e, n) {
1121
- return new e({
1122
- type: "string",
1123
- format: "date",
1124
- check: "string_format",
1125
- ...l(n)
1126
- });
1127
- }
1128
- // @__NO_SIDE_EFFECTS__
1129
- function Mt(e, n) {
1130
- return new e({
1131
- type: "string",
1132
- format: "time",
1133
- check: "string_format",
1134
- precision: null,
1135
- ...l(n)
1136
- });
1137
- }
1138
- // @__NO_SIDE_EFFECTS__
1139
- function Rt(e, n) {
1140
- return new e({
1141
- type: "string",
1142
- format: "duration",
1143
- check: "string_format",
1144
- ...l(n)
1145
- });
1146
- }
1147
- // @__NO_SIDE_EFFECTS__
1148
- function Ct(e, n) {
1149
- return new e({
1150
- type: "number",
1151
- checks: [],
1152
- ...l(n)
1153
- });
1154
- }
1155
- // @__NO_SIDE_EFFECTS__
1156
- function jt(e, n) {
1157
- return new e({
1158
- type: "number",
1159
- check: "number_format",
1160
- abort: !1,
1161
- format: "safeint",
1162
- ...l(n)
1163
- });
1164
- }
1165
- // @__NO_SIDE_EFFECTS__
1166
- function Ft(e, n) {
1167
- return new e({
1168
- type: "boolean",
1169
- ...l(n)
1170
- });
1171
- }
1172
- // @__NO_SIDE_EFFECTS__
1173
- function Dt(e) {
1174
- return new e({
1175
- type: "any"
1176
- });
1177
- }
1178
- // @__NO_SIDE_EFFECTS__
1179
- function xt(e, n) {
1180
- return new xn({
1181
- check: "less_than",
1182
- ...l(n),
1183
- value: e,
1184
- inclusive: !0
1185
- });
1186
- }
1187
- // @__NO_SIDE_EFFECTS__
1188
- function Ut(e, n) {
1189
- return new Un({
1190
- check: "greater_than",
1191
- ...l(n),
1192
- value: e,
1193
- inclusive: !0
1194
- });
1195
- }
1196
- // @__NO_SIDE_EFFECTS__
1197
- function D(e, n) {
1198
- return new Jn({
1199
- check: "max_length",
1200
- ...l(n),
1201
- maximum: e
1202
- });
1203
- }
1204
- // @__NO_SIDE_EFFECTS__
1205
- function O(e, n) {
1206
- return new Vn({
1207
- check: "min_length",
1208
- ...l(n),
1209
- minimum: e
1210
- });
1211
- }
1212
- // @__NO_SIDE_EFFECTS__
1213
- function qe(e, n) {
1214
- return new qn({
1215
- check: "length_equals",
1216
- ...l(n),
1217
- length: e
1218
- });
1219
- }
1220
- // @__NO_SIDE_EFFECTS__
1221
- function We(e, n) {
1222
- return new Wn({
1223
- check: "string_format",
1224
- format: "regex",
1225
- ...l(n),
1226
- pattern: e
1227
- });
1228
- }
1229
- // @__NO_SIDE_EFFECTS__
1230
- function Lt(e) {
1231
- return new Gn({
1232
- check: "string_format",
1233
- format: "lowercase",
1234
- ...l(e)
1235
- });
1236
- }
1237
- // @__NO_SIDE_EFFECTS__
1238
- function Jt(e) {
1239
- return new Bn({
1240
- check: "string_format",
1241
- format: "uppercase",
1242
- ...l(e)
1243
- });
1244
- }
1245
- // @__NO_SIDE_EFFECTS__
1246
- function Vt(e, n) {
1247
- return new Kn({
1248
- check: "string_format",
1249
- format: "includes",
1250
- ...l(n),
1251
- includes: e
1252
- });
1253
- }
1254
- // @__NO_SIDE_EFFECTS__
1255
- function qt(e, n) {
1256
- return new Yn({
1257
- check: "string_format",
1258
- format: "starts_with",
1259
- ...l(n),
1260
- prefix: e
1261
- });
1262
- }
1263
- // @__NO_SIDE_EFFECTS__
1264
- function Wt(e, n) {
1265
- return new Xn({
1266
- check: "string_format",
1267
- format: "ends_with",
1268
- ...l(n),
1269
- suffix: e
1270
- });
1271
- }
1272
- // @__NO_SIDE_EFFECTS__
1273
- function M(e) {
1274
- return new Hn({
1275
- check: "overwrite",
1276
- tx: e
1277
- });
1278
- }
1279
- // @__NO_SIDE_EFFECTS__
1280
- function Gt(e) {
1281
- return /* @__PURE__ */ M((n) => n.normalize(e));
1282
- }
1283
- // @__NO_SIDE_EFFECTS__
1284
- function Bt() {
1285
- return /* @__PURE__ */ M((e) => e.trim());
1286
- }
1287
- // @__NO_SIDE_EFFECTS__
1288
- function Kt() {
1289
- return /* @__PURE__ */ M((e) => e.toLowerCase());
1290
- }
1291
- // @__NO_SIDE_EFFECTS__
1292
- function Yt() {
1293
- return /* @__PURE__ */ M((e) => e.toUpperCase());
1294
- }
1295
- // @__NO_SIDE_EFFECTS__
1296
- function Xt() {
1297
- return /* @__PURE__ */ M((e) => mn(e));
1298
- }
1299
- // @__NO_SIDE_EFFECTS__
1300
- function Ht(e, n, t) {
1301
- return new e({
1302
- type: "array",
1303
- element: n,
1304
- // get element() {
1305
- // return element;
1306
- // },
1307
- ...l(t)
1308
- });
1309
- }
1310
- // @__NO_SIDE_EFFECTS__
1311
- function Ge(e, n, t) {
1312
- return new e({
1313
- type: "custom",
1314
- check: "custom",
1315
- fn: n,
1316
- ...l(t)
1317
- });
1318
- }
1319
- // @__NO_SIDE_EFFECTS__
1320
- function Be(e) {
1321
- const n = /* @__PURE__ */ Qt((t) => (t.addIssue = (r) => {
1322
- if (typeof r == "string")
1323
- t.issues.push(F(r, t.value, n._zod.def));
1324
- else {
1325
- const o = r;
1326
- o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = t.value), o.inst ?? (o.inst = n), o.continue ?? (o.continue = !n._zod.def.abort), t.issues.push(F(o));
1327
- }
1328
- }, e(t.value, t)));
1329
- return n;
1330
- }
1331
- // @__NO_SIDE_EFFECTS__
1332
- function Qt(e, n) {
1333
- const t = new k({
1334
- check: "custom",
1335
- ...l(n)
1336
- });
1337
- return t._zod.check = e, t;
1338
- }
1339
- // @__NO_SIDE_EFFECTS__
1340
- function er(e, n, t, r = {}) {
1341
- const o = l(r), i = {
1342
- ...l(r),
1343
- check: "string_format",
1344
- type: "string",
1345
- format: n,
1346
- fn: typeof t == "function" ? t : (a) => t.test(a),
1347
- ...o
1348
- };
1349
- return t instanceof RegExp && (i.pattern = t), new e(i);
1350
- }
1351
- function Ke(e) {
1352
- let n = e?.target ?? "draft-2020-12";
1353
- return n === "draft-4" && (n = "draft-04"), n === "draft-7" && (n = "draft-07"), {
1354
- processors: e.processors ?? {},
1355
- metadataRegistry: e?.metadata ?? j,
1356
- target: n,
1357
- unrepresentable: e?.unrepresentable ?? "throw",
1358
- override: e?.override ?? (() => {
1359
- }),
1360
- io: e?.io ?? "output",
1361
- counter: 0,
1362
- seen: /* @__PURE__ */ new Map(),
1363
- cycles: e?.cycles ?? "ref",
1364
- reused: e?.reused ?? "inline",
1365
- external: e?.external ?? void 0
1366
- };
1367
- }
1368
- function b(e, n, t = { path: [], schemaPath: [] }) {
1369
- var r;
1370
- const o = e._zod.def, i = n.seen.get(e);
1371
- if (i)
1372
- return i.count++, t.schemaPath.includes(e) && (i.cycle = t.path), i.schema;
1373
- const s = { schema: {}, count: 1, cycle: void 0, path: t.path };
1374
- n.seen.set(e, s);
1375
- const a = e._zod.toJSONSchema?.();
1376
- if (a)
1377
- s.schema = a;
1378
- else {
1379
- const m = {
1380
- ...t,
1381
- schemaPath: [...t.schemaPath, e],
1382
- path: t.path
1383
- };
1384
- if (e._zod.processJSONSchema)
1385
- e._zod.processJSONSchema(n, s.schema, m);
1386
- else {
1387
- const g = s.schema, _ = n.processors[o.type];
1388
- if (!_)
1389
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);
1390
- _(e, n, g, m);
1391
- }
1392
- const h = e._zod.parent;
1393
- h && (s.ref || (s.ref = h), b(h, n, m), n.seen.get(h).isParent = !0);
1394
- }
1395
- const c = n.metadataRegistry.get(e);
1396
- return c && Object.assign(s.schema, c), n.io === "input" && v(e) && (delete s.schema.examples, delete s.schema.default), n.io === "input" && s.schema._prefault && ((r = s.schema).default ?? (r.default = s.schema._prefault)), delete s.schema._prefault, n.seen.get(e).schema;
1397
- }
1398
- function Ye(e, n) {
1399
- const t = e.seen.get(n);
1400
- if (!t)
1401
- throw new Error("Unprocessed schema. This is a bug in Zod.");
1402
- const r = /* @__PURE__ */ new Map();
1403
- for (const s of e.seen.entries()) {
1404
- const a = e.metadataRegistry.get(s[0])?.id;
1405
- if (a) {
1406
- const c = r.get(a);
1407
- if (c && c !== s[0])
1408
- throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
1409
- r.set(a, s[0]);
1410
- }
1411
- }
1412
- const o = (s) => {
1413
- const a = e.target === "draft-2020-12" ? "$defs" : "definitions";
1414
- if (e.external) {
1415
- const h = e.external.registry.get(s[0])?.id, g = e.external.uri ?? ((C) => C);
1416
- if (h)
1417
- return { ref: g(h) };
1418
- const _ = s[1].defId ?? s[1].schema.id ?? `schema${e.counter++}`;
1419
- return s[1].defId = _, { defId: _, ref: `${g("__shared")}#/${a}/${_}` };
1420
- }
1421
- if (s[1] === t)
1422
- return { ref: "#" };
1423
- const f = `#/${a}/`, m = s[1].schema.id ?? `__schema${e.counter++}`;
1424
- return { defId: m, ref: f + m };
1425
- }, i = (s) => {
1426
- if (s[1].schema.$ref)
1427
- return;
1428
- const a = s[1], { ref: c, defId: f } = o(s);
1429
- a.def = { ...a.schema }, f && (a.defId = f);
1430
- const m = a.schema;
1431
- for (const h in m)
1432
- delete m[h];
1433
- m.$ref = c;
1434
- };
1435
- if (e.cycles === "throw")
1436
- for (const s of e.seen.entries()) {
1437
- const a = s[1];
1438
- if (a.cycle)
1439
- throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
1440
-
1441
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
1442
- }
1443
- for (const s of e.seen.entries()) {
1444
- const a = s[1];
1445
- if (n === s[0]) {
1446
- i(s);
1447
- continue;
1448
- }
1449
- if (e.external) {
1450
- const f = e.external.registry.get(s[0])?.id;
1451
- if (n !== s[0] && f) {
1452
- i(s);
1453
- continue;
1454
- }
1455
- }
1456
- if (e.metadataRegistry.get(s[0])?.id) {
1457
- i(s);
1458
- continue;
1459
- }
1460
- if (a.cycle) {
1461
- i(s);
1462
- continue;
1463
- }
1464
- if (a.count > 1 && e.reused === "ref") {
1465
- i(s);
1466
- continue;
1467
- }
1468
- }
1469
- }
1470
- function Xe(e, n) {
1471
- const t = e.seen.get(n);
1472
- if (!t)
1473
- throw new Error("Unprocessed schema. This is a bug in Zod.");
1474
- const r = (s) => {
1475
- const a = e.seen.get(s);
1476
- if (a.ref === null)
1477
- return;
1478
- const c = a.def ?? a.schema, f = { ...c }, m = a.ref;
1479
- if (a.ref = null, m) {
1480
- r(m);
1481
- const g = e.seen.get(m), _ = g.schema;
1482
- if (_.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(_)) : Object.assign(c, _), Object.assign(c, f), s._zod.parent === m)
1483
- for (const E in c)
1484
- E === "$ref" || E === "allOf" || E in f || delete c[E];
1485
- if (_.$ref && g.def)
1486
- for (const E in c)
1487
- E === "$ref" || E === "allOf" || E in g.def && JSON.stringify(c[E]) === JSON.stringify(g.def[E]) && delete c[E];
1488
- }
1489
- const h = s._zod.parent;
1490
- if (h && h !== m) {
1491
- r(h);
1492
- const g = e.seen.get(h);
1493
- if (g?.schema.$ref && (c.$ref = g.schema.$ref, g.def))
1494
- for (const _ in c)
1495
- _ === "$ref" || _ === "allOf" || _ in g.def && JSON.stringify(c[_]) === JSON.stringify(g.def[_]) && delete c[_];
1496
- }
1497
- e.override({
1498
- zodSchema: s,
1499
- jsonSchema: c,
1500
- path: a.path ?? []
1501
- });
1502
- };
1503
- for (const s of [...e.seen.entries()].reverse())
1504
- r(s[0]);
1505
- const o = {};
1506
- if (e.target === "draft-2020-12" ? o.$schema = "https://json-schema.org/draft/2020-12/schema" : e.target === "draft-07" ? o.$schema = "http://json-schema.org/draft-07/schema#" : e.target === "draft-04" ? o.$schema = "http://json-schema.org/draft-04/schema#" : e.target, e.external?.uri) {
1507
- const s = e.external.registry.get(n)?.id;
1508
- if (!s)
1509
- throw new Error("Schema is missing an `id` property");
1510
- o.$id = e.external.uri(s);
1511
- }
1512
- Object.assign(o, t.def ?? t.schema);
1513
- const i = e.external?.defs ?? {};
1514
- for (const s of e.seen.entries()) {
1515
- const a = s[1];
1516
- a.def && a.defId && (i[a.defId] = a.def);
1517
- }
1518
- e.external || Object.keys(i).length > 0 && (e.target === "draft-2020-12" ? o.$defs = i : o.definitions = i);
1519
- try {
1520
- const s = JSON.parse(JSON.stringify(o));
1521
- return Object.defineProperty(s, "~standard", {
1522
- value: {
1523
- ...n["~standard"],
1524
- jsonSchema: {
1525
- input: J(n, "input", e.processors),
1526
- output: J(n, "output", e.processors)
1527
- }
1528
- },
1529
- enumerable: !1,
1530
- writable: !1
1531
- }), s;
1532
- } catch {
1533
- throw new Error("Error converting schema to JSON.");
1534
- }
1535
- }
1536
- function v(e, n) {
1537
- const t = n ?? { seen: /* @__PURE__ */ new Set() };
1538
- if (t.seen.has(e))
1539
- return !1;
1540
- t.seen.add(e);
1541
- const r = e._zod.def;
1542
- if (r.type === "transform")
1543
- return !0;
1544
- if (r.type === "array")
1545
- return v(r.element, t);
1546
- if (r.type === "set")
1547
- return v(r.valueType, t);
1548
- if (r.type === "lazy")
1549
- return v(r.getter(), t);
1550
- if (r.type === "promise" || r.type === "optional" || r.type === "nonoptional" || r.type === "nullable" || r.type === "readonly" || r.type === "default" || r.type === "prefault")
1551
- return v(r.innerType, t);
1552
- if (r.type === "intersection")
1553
- return v(r.left, t) || v(r.right, t);
1554
- if (r.type === "record" || r.type === "map")
1555
- return v(r.keyType, t) || v(r.valueType, t);
1556
- if (r.type === "pipe")
1557
- return v(r.in, t) || v(r.out, t);
1558
- if (r.type === "object") {
1559
- for (const o in r.shape)
1560
- if (v(r.shape[o], t))
1561
- return !0;
1562
- return !1;
1563
- }
1564
- if (r.type === "union") {
1565
- for (const o of r.options)
1566
- if (v(o, t))
1567
- return !0;
1568
- return !1;
1569
- }
1570
- if (r.type === "tuple") {
1571
- for (const o of r.items)
1572
- if (v(o, t))
1573
- return !0;
1574
- return !!(r.rest && v(r.rest, t));
1575
- }
1576
- return !1;
1577
- }
1578
- const nr = (e, n = {}) => (t) => {
1579
- const r = Ke({ ...t, processors: n });
1580
- return b(e, r), Ye(r, e), Xe(r, e);
1581
- }, J = (e, n, t = {}) => (r) => {
1582
- const { libraryOptions: o, target: i } = r ?? {}, s = Ke({ ...o ?? {}, target: i, io: n, processors: t });
1583
- return b(e, s), Ye(s, e), Xe(s, e);
1584
- }, tr = {
1585
- guid: "uuid",
1586
- url: "uri",
1587
- datetime: "date-time",
1588
- json_string: "json-string",
1589
- regex: ""
1590
- // do not set
1591
- }, rr = (e, n, t, r) => {
1592
- const o = t;
1593
- o.type = "string";
1594
- const { minimum: i, maximum: s, format: a, patterns: c, contentEncoding: f } = e._zod.bag;
1595
- if (typeof i == "number" && (o.minLength = i), typeof s == "number" && (o.maxLength = s), a && (o.format = tr[a] ?? a, o.format === "" && delete o.format, a === "time" && delete o.format), f && (o.contentEncoding = f), c && c.size > 0) {
1596
- const m = [...c];
1597
- m.length === 1 ? o.pattern = m[0].source : m.length > 1 && (o.allOf = [
1598
- ...m.map((h) => ({
1599
- ...n.target === "draft-07" || n.target === "draft-04" || n.target === "openapi-3.0" ? { type: "string" } : {},
1600
- pattern: h.source
1601
- }))
1602
- ]);
1603
- }
1604
- }, or = (e, n, t, r) => {
1605
- if (n.unrepresentable === "throw")
1606
- throw new Error("Custom types cannot be represented in JSON Schema");
1607
- }, sr = (e, n, t, r) => {
1608
- if (n.unrepresentable === "throw")
1609
- throw new Error("Transforms cannot be represented in JSON Schema");
1610
- }, ir = (e, n, t, r) => {
1611
- const o = t, i = e._zod.def, { minimum: s, maximum: a } = e._zod.bag;
1612
- typeof s == "number" && (o.minItems = s), typeof a == "number" && (o.maxItems = a), o.type = "array", o.items = b(i.element, n, { ...r, path: [...r.path, "items"] });
1613
- }, ar = (e, n, t, r) => {
1614
- const o = e._zod.def, i = o.inclusive === !1, s = o.options.map((a, c) => b(a, n, {
1615
- ...r,
1616
- path: [...r.path, i ? "oneOf" : "anyOf", c]
1617
- }));
1618
- i ? t.oneOf = s : t.anyOf = s;
1619
- }, cr = (e, n, t, r) => {
1620
- const o = e._zod.def, i = b(o.left, n, {
1621
- ...r,
1622
- path: [...r.path, "allOf", 0]
1623
- }), s = b(o.right, n, {
1624
- ...r,
1625
- path: [...r.path, "allOf", 1]
1626
- }), a = (f) => "allOf" in f && Object.keys(f).length === 1, c = [
1627
- ...a(i) ? i.allOf : [i],
1628
- ...a(s) ? s.allOf : [s]
1629
- ];
1630
- t.allOf = c;
1631
- }, ur = (e, n, t, r) => {
1632
- const o = e._zod.def, i = b(o.innerType, n, r), s = n.seen.get(e);
1633
- n.target === "openapi-3.0" ? (s.ref = o.innerType, t.nullable = !0) : t.anyOf = [i, { type: "null" }];
1634
- }, fr = (e, n, t, r) => {
1635
- const o = e._zod.def;
1636
- b(o.innerType, n, r);
1637
- const i = n.seen.get(e);
1638
- i.ref = o.innerType;
1639
- }, mr = (e, n, t, r) => {
1640
- const o = e._zod.def;
1641
- b(o.innerType, n, r);
1642
- const i = n.seen.get(e);
1643
- i.ref = o.innerType, t.default = JSON.parse(JSON.stringify(o.defaultValue));
1644
- }, lr = (e, n, t, r) => {
1645
- const o = e._zod.def;
1646
- b(o.innerType, n, r);
1647
- const i = n.seen.get(e);
1648
- i.ref = o.innerType, n.io === "input" && (t._prefault = JSON.parse(JSON.stringify(o.defaultValue)));
1649
- }, dr = (e, n, t, r) => {
1650
- const o = e._zod.def;
1651
- b(o.innerType, n, r);
1652
- const i = n.seen.get(e);
1653
- i.ref = o.innerType;
1654
- let s;
1655
- try {
1656
- s = o.catchValue(void 0);
1657
- } catch {
1658
- throw new Error("Dynamic catch values are not supported in JSON Schema");
1659
- }
1660
- t.default = s;
1661
- }, pr = (e, n, t, r) => {
1662
- const o = e._zod.def, i = n.io === "input" ? o.in._zod.def.type === "transform" ? o.out : o.in : o.out;
1663
- b(i, n, r);
1664
- const s = n.seen.get(e);
1665
- s.ref = i;
1666
- }, hr = (e, n, t, r) => {
1667
- const o = e._zod.def;
1668
- b(o.innerType, n, r);
1669
- const i = n.seen.get(e);
1670
- i.ref = o.innerType, t.readOnly = !0;
1671
- }, He = (e, n, t, r) => {
1672
- const o = e._zod.def;
1673
- b(o.innerType, n, r);
1674
- const i = n.seen.get(e);
1675
- i.ref = o.innerType;
1676
- }, gr = /* @__PURE__ */ u("ZodISODateTime", (e, n) => {
1677
- rt.init(e, n), Y.init(e, n);
1678
- });
1679
- function _r(e) {
1680
- return /* @__PURE__ */ At(gr, e);
1681
- }
1682
- const yr = /* @__PURE__ */ u("ZodISODate", (e, n) => {
1683
- ot.init(e, n), Y.init(e, n);
1684
- });
1685
- function wr(e) {
1686
- return /* @__PURE__ */ Nt(yr, e);
1687
- }
1688
- const vr = /* @__PURE__ */ u("ZodISOTime", (e, n) => {
1689
- st.init(e, n), Y.init(e, n);
1690
- });
1691
- function br(e) {
1692
- return /* @__PURE__ */ Mt(vr, e);
1693
- }
1694
- const zr = /* @__PURE__ */ u("ZodISODuration", (e, n) => {
1695
- it.init(e, n), Y.init(e, n);
1696
- });
1697
- function kr(e) {
1698
- return /* @__PURE__ */ Rt(zr, e);
1699
- }
1700
- const $r = (e, n) => {
1701
- Ce.init(e, n), e.name = "ZodError", Object.defineProperties(e, {
1702
- format: {
1703
- value: (t) => hn(e, t)
1704
- // enumerable: false,
1705
- },
1706
- flatten: {
1707
- value: (t) => pn(e, t)
1708
- // enumerable: false,
1709
- },
1710
- addIssue: {
1711
- value: (t) => {
1712
- e.issues.push(t), e.message = JSON.stringify(e.issues, H, 2);
1713
- }
1714
- // enumerable: false,
1715
- },
1716
- addIssues: {
1717
- value: (t) => {
1718
- e.issues.push(...t), e.message = JSON.stringify(e.issues, H, 2);
1719
- }
1720
- // enumerable: false,
1721
- },
1722
- isEmpty: {
1723
- get() {
1724
- return e.issues.length === 0;
1725
- }
1726
- // enumerable: false,
1727
- }
1728
- });
1729
- }, Z = u("ZodError", $r, {
1730
- Parent: Error
1731
- }), Zr = /* @__PURE__ */ q(Z), Er = /* @__PURE__ */ W(Z), Sr = /* @__PURE__ */ G(Z), Tr = /* @__PURE__ */ B(Z), Or = /* @__PURE__ */ yn(Z), Pr = /* @__PURE__ */ wn(Z), Ir = /* @__PURE__ */ vn(Z), Ar = /* @__PURE__ */ bn(Z), Nr = /* @__PURE__ */ zn(Z), Mr = /* @__PURE__ */ kn(Z), Rr = /* @__PURE__ */ $n(Z), Cr = /* @__PURE__ */ Zn(Z), z = /* @__PURE__ */ u("ZodType", (e, n) => (w.init(e, n), Object.assign(e["~standard"], {
1732
- jsonSchema: {
1733
- input: J(e, "input"),
1734
- output: J(e, "output")
1735
- }
1736
- }), e.toJSONSchema = nr(e, {}), e.def = n, e.type = n.type, Object.defineProperty(e, "_def", { value: n }), e.check = (...t) => e.clone(fn(n, {
1737
- checks: [
1738
- ...n.checks ?? [],
1739
- ...t.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
1740
- ]
1741
- }), {
1742
- parent: !0
1743
- }), e.with = e.check, e.clone = (t, r) => Me(e, t, r), e.brand = () => e, e.register = ((t, r) => (t.add(e, r), e)), e.parse = (t, r) => Zr(e, t, r, { callee: e.parse }), e.safeParse = (t, r) => Sr(e, t, r), e.parseAsync = async (t, r) => Er(e, t, r, { callee: e.parseAsync }), e.safeParseAsync = async (t, r) => Tr(e, t, r), e.spa = e.safeParseAsync, e.encode = (t, r) => Or(e, t, r), e.decode = (t, r) => Pr(e, t, r), e.encodeAsync = async (t, r) => Ir(e, t, r), e.decodeAsync = async (t, r) => Ar(e, t, r), e.safeEncode = (t, r) => Nr(e, t, r), e.safeDecode = (t, r) => Mr(e, t, r), e.safeEncodeAsync = async (t, r) => Rr(e, t, r), e.safeDecodeAsync = async (t, r) => Cr(e, t, r), e.refine = (t, r) => e.check(co(t, r)), e.superRefine = (t) => e.check(uo(t)), e.overwrite = (t) => e.check(/* @__PURE__ */ M(t)), e.optional = () => $e(e), e.exactOptional = () => Br(e), e.nullable = () => Ze(e), e.nullish = () => $e(Ze(e)), e.nonoptional = (t) => no(e, t), e.array = () => Dr(e), e.or = (t) => Ur([e, t]), e.and = (t) => Jr(e, t), e.transform = (t) => Ee(e, qr(t)), e.default = (t) => Xr(e, t), e.prefault = (t) => Qr(e, t), e.catch = (t) => ro(e, t), e.pipe = (t) => Ee(e, t), e.readonly = () => io(e), e.describe = (t) => {
1744
- const r = e.clone();
1745
- return j.add(r, { description: t }), r;
1746
- }, Object.defineProperty(e, "description", {
1747
- get() {
1748
- return j.get(e)?.description;
1749
- },
1750
- configurable: !0
1751
- }), e.meta = (...t) => {
1752
- if (t.length === 0)
1753
- return j.get(e);
1754
- const r = e.clone();
1755
- return j.add(r, t[0]), r;
1756
- }, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (t) => t(e), e)), jr = /* @__PURE__ */ u("_ZodString", (e, n) => {
1757
- fe.init(e, n), z.init(e, n), e._zod.processJSONSchema = (r, o, i) => rr(e, r, o);
1758
- const t = e._zod.bag;
1759
- e.format = t.format ?? null, e.minLength = t.minimum ?? null, e.maxLength = t.maximum ?? null, e.regex = (...r) => e.check(/* @__PURE__ */ We(...r)), e.includes = (...r) => e.check(/* @__PURE__ */ Vt(...r)), e.startsWith = (...r) => e.check(/* @__PURE__ */ qt(...r)), e.endsWith = (...r) => e.check(/* @__PURE__ */ Wt(...r)), e.min = (...r) => e.check(/* @__PURE__ */ O(...r)), e.max = (...r) => e.check(/* @__PURE__ */ D(...r)), e.length = (...r) => e.check(/* @__PURE__ */ qe(...r)), e.nonempty = (...r) => e.check(/* @__PURE__ */ O(1, ...r)), e.lowercase = (r) => e.check(/* @__PURE__ */ Lt(r)), e.uppercase = (r) => e.check(/* @__PURE__ */ Jt(r)), e.trim = () => e.check(/* @__PURE__ */ Bt()), e.normalize = (...r) => e.check(/* @__PURE__ */ Gt(...r)), e.toLowerCase = () => e.check(/* @__PURE__ */ Kt()), e.toUpperCase = () => e.check(/* @__PURE__ */ Yt()), e.slugify = () => e.check(/* @__PURE__ */ Xt());
1760
- }), Y = /* @__PURE__ */ u("ZodStringFormat", (e, n) => {
1761
- $.init(e, n), jr.init(e, n);
1762
- }), Fr = /* @__PURE__ */ u("ZodArray", (e, n) => {
1763
- Je.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => ir(e, t, r, o), e.element = n.element, e.min = (t, r) => e.check(/* @__PURE__ */ O(t, r)), e.nonempty = (t) => e.check(/* @__PURE__ */ O(1, t)), e.max = (t, r) => e.check(/* @__PURE__ */ D(t, r)), e.length = (t, r) => e.check(/* @__PURE__ */ qe(t, r)), e.unwrap = () => e.element;
1764
- });
1765
- function Dr(e, n) {
1766
- return /* @__PURE__ */ Ht(Fr, e, n);
1767
- }
1768
- const xr = /* @__PURE__ */ u("ZodUnion", (e, n) => {
1769
- dt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => ar(e, t, r, o), e.options = n.options;
1770
- });
1771
- function Ur(e, n) {
1772
- return new xr({
1773
- type: "union",
1774
- options: e,
1775
- ...l(n)
1776
- });
1777
- }
1778
- const Lr = /* @__PURE__ */ u("ZodIntersection", (e, n) => {
1779
- pt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => cr(e, t, r, o);
1780
- });
1781
- function Jr(e, n) {
1782
- return new Lr({
1783
- type: "intersection",
1784
- left: e,
1785
- right: n
1786
- });
1787
- }
1788
- const Vr = /* @__PURE__ */ u("ZodTransform", (e, n) => {
1789
- ht.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => sr(e, t), e._zod.parse = (t, r) => {
1790
- if (r.direction === "backward")
1791
- throw new Ie(e.constructor.name);
1792
- t.addIssue = (i) => {
1793
- if (typeof i == "string")
1794
- t.issues.push(F(i, t.value, n));
1795
- else {
1796
- const s = i;
1797
- s.fatal && (s.continue = !1), s.code ?? (s.code = "custom"), s.input ?? (s.input = t.value), s.inst ?? (s.inst = e), t.issues.push(F(s));
1798
- }
1799
- };
1800
- const o = n.transform(t.value, t);
1801
- return o instanceof Promise ? o.then((i) => (t.value = i, t)) : (t.value = o, t);
1802
- };
1803
- });
1804
- function qr(e) {
1805
- return new Vr({
1806
- type: "transform",
1807
- transform: e
1808
- });
1809
- }
1810
- const Wr = /* @__PURE__ */ u("ZodOptional", (e, n) => {
1811
- me.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => He(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1812
- });
1813
- function $e(e) {
1814
- return new Wr({
1815
- type: "optional",
1816
- innerType: e
1817
- });
1818
- }
1819
- const Gr = /* @__PURE__ */ u("ZodExactOptional", (e, n) => {
1820
- gt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => He(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1821
- });
1822
- function Br(e) {
1823
- return new Gr({
1824
- type: "optional",
1825
- innerType: e
1826
- });
1827
- }
1828
- const Kr = /* @__PURE__ */ u("ZodNullable", (e, n) => {
1829
- _t.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => ur(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1830
- });
1831
- function Ze(e) {
1832
- return new Kr({
1833
- type: "nullable",
1834
- innerType: e
1835
- });
1836
- }
1837
- const Yr = /* @__PURE__ */ u("ZodDefault", (e, n) => {
1838
- yt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => mr(e, t, r, o), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
1839
- });
1840
- function Xr(e, n) {
1841
- return new Yr({
1842
- type: "default",
1843
- innerType: e,
1844
- get defaultValue() {
1845
- return typeof n == "function" ? n() : Ne(n);
1846
- }
1847
- });
1848
- }
1849
- const Hr = /* @__PURE__ */ u("ZodPrefault", (e, n) => {
1850
- wt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => lr(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1851
- });
1852
- function Qr(e, n) {
1853
- return new Hr({
1854
- type: "prefault",
1855
- innerType: e,
1856
- get defaultValue() {
1857
- return typeof n == "function" ? n() : Ne(n);
1858
- }
1859
- });
1860
- }
1861
- const eo = /* @__PURE__ */ u("ZodNonOptional", (e, n) => {
1862
- vt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => fr(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1863
- });
1864
- function no(e, n) {
1865
- return new eo({
1866
- type: "nonoptional",
1867
- innerType: e,
1868
- ...l(n)
1869
- });
1870
- }
1871
- const to = /* @__PURE__ */ u("ZodCatch", (e, n) => {
1872
- bt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => dr(e, t, r, o), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
1873
- });
1874
- function ro(e, n) {
1875
- return new to({
1876
- type: "catch",
1877
- innerType: e,
1878
- catchValue: typeof n == "function" ? n : () => n
1879
- });
1880
- }
1881
- const oo = /* @__PURE__ */ u("ZodPipe", (e, n) => {
1882
- zt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => pr(e, t, r, o), e.in = n.in, e.out = n.out;
1883
- });
1884
- function Ee(e, n) {
1885
- return new oo({
1886
- type: "pipe",
1887
- in: e,
1888
- out: n
1889
- // ...util.normalizeParams(params),
1890
- });
1891
- }
1892
- const so = /* @__PURE__ */ u("ZodReadonly", (e, n) => {
1893
- kt.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => hr(e, t, r, o), e.unwrap = () => e._zod.def.innerType;
1894
- });
1895
- function io(e) {
1896
- return new so({
1897
- type: "readonly",
1898
- innerType: e
1899
- });
1900
- }
1901
- const ao = /* @__PURE__ */ u("ZodCustom", (e, n) => {
1902
- Ve.init(e, n), z.init(e, n), e._zod.processJSONSchema = (t, r, o) => or(e, t);
1903
- });
1904
- function co(e, n = {}) {
1905
- return /* @__PURE__ */ Ge(ao, e, n);
1906
- }
1907
- function uo(e) {
1908
- return /* @__PURE__ */ Be(e);
1909
- }
1910
- const P = /* @__PURE__ */ u("ZodMiniType", (e, n) => {
1911
- if (!e._zod)
1912
- throw new Error("Uninitialized schema in ZodMiniType.");
1913
- w.init(e, n), e.def = n, e.type = n.type, e.parse = (t, r) => gn(e, t, r, { callee: e.parse }), e.safeParse = (t, r) => je(e, t, r), e.parseAsync = async (t, r) => _n(e, t, r, { callee: e.parseAsync }), e.safeParseAsync = async (t, r) => Fe(e, t, r), e.check = (...t) => e.clone({
1914
- ...n,
1915
- checks: [
1916
- ...n.checks ?? [],
1917
- ...t.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
1918
- ]
1919
- }, { parent: !0 }), e.with = e.check, e.clone = (t, r) => Me(e, t, r), e.brand = () => e, e.register = ((t, r) => (t.add(e, r), e)), e.apply = (t) => t(e);
1920
- }), Qe = /* @__PURE__ */ u("ZodMiniString", (e, n) => {
1921
- fe.init(e, n), P.init(e, n);
1922
- });
1923
- // @__NO_SIDE_EFFECTS__
1924
- function Se(e) {
1925
- return /* @__PURE__ */ Et(Qe, e);
1926
- }
1927
- const R = /* @__PURE__ */ u("ZodMiniStringFormat", (e, n) => {
1928
- $.init(e, n), Qe.init(e, n);
1929
- }), fo = /* @__PURE__ */ u("ZodMiniEmail", (e, n) => {
1930
- nt.init(e, n), R.init(e, n);
1931
- });
1932
- // @__NO_SIDE_EFFECTS__
1933
- function mo(e) {
1934
- return /* @__PURE__ */ St(fo, e);
1935
- }
1936
- const lo = /* @__PURE__ */ u("ZodMiniUUID", (e, n) => {
1937
- et.init(e, n), R.init(e, n);
1938
- });
1939
- // @__NO_SIDE_EFFECTS__
1940
- function po(e) {
1941
- return /* @__PURE__ */ Tt(lo, e);
1942
- }
1943
- const ho = /* @__PURE__ */ u("ZodMiniURL", (e, n) => {
1944
- tt.init(e, n), R.init(e, n);
1945
- });
1946
- // @__NO_SIDE_EFFECTS__
1947
- function go(e) {
1948
- return /* @__PURE__ */ Ot(ho, e);
1949
- }
1950
- const _o = /* @__PURE__ */ u("ZodMiniIPv4", (e, n) => {
1951
- at.init(e, n), R.init(e, n);
1952
- });
1953
- // @__NO_SIDE_EFFECTS__
1954
- function yo(e) {
1955
- return /* @__PURE__ */ Pt(_o, e);
1956
- }
1957
- const wo = /* @__PURE__ */ u("ZodMiniIPv6", (e, n) => {
1958
- ct.init(e, n), R.init(e, n);
1959
- });
1960
- // @__NO_SIDE_EFFECTS__
1961
- function vo(e) {
1962
- return /* @__PURE__ */ It(wo, e);
1963
- }
1964
- const bo = /* @__PURE__ */ u("ZodMiniCustomStringFormat", (e, n) => {
1965
- ut.init(e, n), R.init(e, n);
1966
- });
1967
- // @__NO_SIDE_EFFECTS__
1968
- function zo(e) {
1969
- return /* @__PURE__ */ er(bo, "hostname", Pn, e);
1970
- }
1971
- const en = /* @__PURE__ */ u("ZodMiniNumber", (e, n) => {
1972
- Le.init(e, n), P.init(e, n);
1973
- });
1974
- // @__NO_SIDE_EFFECTS__
1975
- function Te(e) {
1976
- return /* @__PURE__ */ Ct(en, e);
1977
- }
1978
- const ko = /* @__PURE__ */ u("ZodMiniNumberFormat", (e, n) => {
1979
- ft.init(e, n), en.init(e, n);
1980
- });
1981
- // @__NO_SIDE_EFFECTS__
1982
- function $o(e) {
1983
- return /* @__PURE__ */ jt(ko, e);
1984
- }
1985
- const Zo = /* @__PURE__ */ u("ZodMiniBoolean", (e, n) => {
1986
- mt.init(e, n), P.init(e, n);
1987
- });
1988
- // @__NO_SIDE_EFFECTS__
1989
- function Oe(e) {
1990
- return /* @__PURE__ */ Ft(Zo, e);
1991
- }
1992
- const Eo = /* @__PURE__ */ u("ZodMiniAny", (e, n) => {
1993
- lt.init(e, n), P.init(e, n);
1994
- });
1995
- // @__NO_SIDE_EFFECTS__
1996
- function N() {
1997
- return /* @__PURE__ */ Dt(Eo);
1998
- }
1999
- const So = /* @__PURE__ */ u("ZodMiniArray", (e, n) => {
2000
- Je.init(e, n), P.init(e, n);
2001
- });
2002
- // @__NO_SIDE_EFFECTS__
2003
- function ne(e, n) {
2004
- return new So({
2005
- type: "array",
2006
- element: e,
2007
- ...l(n)
2008
- });
2009
- }
2010
- const To = /* @__PURE__ */ u("ZodMiniOptional", (e, n) => {
2011
- me.init(e, n), P.init(e, n);
2012
- });
2013
- // @__NO_SIDE_EFFECTS__
2014
- function Oo(e) {
2015
- return new To({
2016
- type: "optional",
2017
- innerType: e
2018
- });
2019
- }
2020
- const Po = /* @__PURE__ */ u("ZodMiniCustom", (e, n) => {
2021
- Ve.init(e, n), P.init(e, n);
2022
- });
2023
- // @__NO_SIDE_EFFECTS__
2024
- function y(e, n = {}) {
2025
- return /* @__PURE__ */ Ge(Po, e, n);
2026
- }
2027
- // @__NO_SIDE_EFFECTS__
2028
- function X(e) {
2029
- return /* @__PURE__ */ Be(e);
2030
- }
2031
- const te = {
2032
- email: { schema: /* @__PURE__ */ mo() },
2033
- hostname: { schema: /* @__PURE__ */ zo() },
2034
- ipv4: { schema: /* @__PURE__ */ yo() },
2035
- ipv6: { schema: /* @__PURE__ */ vo() },
2036
- url: { schema: /* @__PURE__ */ go() },
2037
- uuid: { schema: /* @__PURE__ */ po() },
2038
- date: { schema: wr() },
2039
- time: { schema: br() },
2040
- "date-time": { schema: _r({ local: !0, offset: !0 }) },
2041
- duration: { schema: kr() }
2042
- }, Pe = Object.keys(te), Io = ["uploading", "uploaded", "error"], Ao = (e) => (n, t) => {
2043
- switch (n.type) {
2044
- case "string":
2045
- return No(n, t);
2046
- case "integer":
2047
- case "number":
2048
- return Ro(n, t);
2049
- case "boolean":
2050
- return Co(n, t);
2051
- case "array":
2052
- return jo(n, t);
2053
- case "file":
2054
- return Fo(n, t);
2055
- case "files":
2056
- return Do(n, t);
2057
- case "custom": {
2058
- if (!e)
2059
- throw new Error(
2060
- 'Validator type "custom" requires a customValidators object, but it was not supplied.'
2061
- );
2062
- return Uo(n, e);
2063
- }
2064
- default: {
2065
- const r = n;
2066
- throw new Error(
2067
- `Unknown validator config: ${JSON.stringify(r)}. The "type" property must be one of: "string", "number", "integer", "boolean", "array", "file", "files", "custom".`
2068
- );
2069
- }
2070
- }
2071
- };
2072
- function d(e, n) {
2073
- if (e !== void 0)
2074
- return typeof e == "string" ? e : n?.translate(e.key, e.params, e.default) ?? e.default;
2075
- }
2076
- function No(e, n) {
2077
- return x(e, (t) => {
2078
- const r = d(t.messages?.invalid, n);
2079
- let o = r ? /* @__PURE__ */ Se(r) : /* @__PURE__ */ Se();
2080
- if (t.required === !0) {
2081
- const i = d(t.messages?.required, n) ?? "This field is required";
2082
- o = o.check(/* @__PURE__ */ y((s) => s.length > 0, { error: i }));
2083
- }
2084
- if (typeof t.minLength == "number") {
2085
- const i = d(t.messages?.minLength, n), s = t.minLength;
2086
- o = o.check(
2087
- i ? /* @__PURE__ */ y((a) => a.length >= s, { error: i }) : /* @__PURE__ */ O(s)
2088
- );
2089
- }
2090
- if (typeof t.maxLength == "number") {
2091
- const i = d(t.messages?.maxLength, n), s = t.maxLength;
2092
- o = o.check(
2093
- i ? /* @__PURE__ */ y((a) => a.length <= s, { error: i }) : /* @__PURE__ */ D(s)
2094
- );
2095
- }
2096
- if (typeof t.pattern == "string") {
2097
- const i = d(t.messages?.pattern, n), s = new RegExp(t.pattern);
2098
- o = o.check(
2099
- i ? /* @__PURE__ */ y((a) => s.test(a), { error: i }) : /* @__PURE__ */ We(s)
2100
- );
2101
- }
2102
- if (t.enum) {
2103
- const i = t.enum, s = d(t.messages?.enum, n);
2104
- o = o.check(/* @__PURE__ */ y((a) => i.includes(a), s ? { error: s } : void 0));
2105
- }
2106
- if (t.const !== void 0) {
2107
- const i = d(t.messages?.const, n);
2108
- o = o.check(/* @__PURE__ */ y((s) => s === t.const, i ? { error: i } : void 0));
2109
- }
2110
- if (t.format !== void 0)
2111
- if (Pe.includes(t.format)) {
2112
- const i = d(t.messages?.format, n);
2113
- o = o.check(
2114
- i ? /* @__PURE__ */ X((s, a) => {
2115
- const c = oe(
2116
- te[t.format].schema,
2117
- s
2118
- );
2119
- se(c) || a.addIssue({ code: "custom", path: [], message: i });
2120
- }) : te[t.format].schema
2121
- );
2122
- } else
2123
- throw new Error(
2124
- `Unknown string validation format: ${JSON.stringify(t.format)}. The "format" property must be one of: ${Pe.map((i) => `"${i}"`).join(", ")}.`
2125
- );
2126
- return o;
2127
- });
2128
- }
2129
- const Mo = (e, n) => {
2130
- if (n === 0)
2131
- return !1;
2132
- const t = e / n;
2133
- return Math.abs(t - Math.round(t)) < 1e-10;
2134
- };
2135
- function Ro(e, n) {
2136
- return x(e, (t) => {
2137
- const r = d(t.messages?.invalid, n);
2138
- let o = r ? /* @__PURE__ */ Te(r) : /* @__PURE__ */ Te();
2139
- if (t.type === "integer" && (o = o.check(/* @__PURE__ */ $o())), t.minimum !== void 0) {
2140
- const i = d(t.messages?.minimum, n), s = t.minimum;
2141
- o = o.check(i ? /* @__PURE__ */ y((a) => a >= s, { error: i }) : /* @__PURE__ */ Ut(s));
2142
- }
2143
- if (t.maximum !== void 0) {
2144
- const i = d(t.messages?.maximum, n), s = t.maximum;
2145
- o = o.check(i ? /* @__PURE__ */ y((a) => a <= s, { error: i }) : /* @__PURE__ */ xt(s));
2146
- }
2147
- if (t.exclusiveMinimum !== void 0) {
2148
- const i = d(t.messages?.exclusiveMinimum, n), s = t.exclusiveMinimum;
2149
- o = o.check(/* @__PURE__ */ y((a) => a > s, i ? { error: i } : void 0));
2150
- }
2151
- if (t.exclusiveMaximum !== void 0) {
2152
- const i = d(t.messages?.exclusiveMaximum, n), s = t.exclusiveMaximum;
2153
- o = o.check(/* @__PURE__ */ y((a) => a < s, i ? { error: i } : void 0));
2154
- }
2155
- if (t.multipleOf !== void 0) {
2156
- const i = d(t.messages?.multipleOf, n), s = t.multipleOf;
2157
- o = o.check(
2158
- /* @__PURE__ */ y((a) => Mo(a, s), i ? { error: i } : void 0)
2159
- );
2160
- }
2161
- if (t.enum) {
2162
- const i = t.enum, s = d(t.messages?.enum, n);
2163
- o = o.check(/* @__PURE__ */ y((a) => i.includes(a), s ? { error: s } : void 0));
2164
- }
2165
- if (t.const !== void 0) {
2166
- const i = d(t.messages?.const, n);
2167
- o = o.check(/* @__PURE__ */ y((s) => s === t.const, i ? { error: i } : void 0));
2168
- }
2169
- return o;
2170
- });
2171
- }
2172
- function Co(e, n) {
2173
- return x(e, (t) => {
2174
- const r = d(t.messages?.invalid, n);
2175
- let o = r ? /* @__PURE__ */ Oe(r) : /* @__PURE__ */ Oe();
2176
- if (t.const !== void 0) {
2177
- const i = d(t.messages?.const, n);
2178
- o = o.check(/* @__PURE__ */ y((s) => s === t.const, i ? { error: i } : void 0));
2179
- }
2180
- return o;
2181
- });
2182
- }
2183
- function jo(e, n) {
2184
- return x(e, (t) => {
2185
- const r = d(t.messages?.invalid, n);
2186
- let o = r ? /* @__PURE__ */ ne(/* @__PURE__ */ N(), r) : /* @__PURE__ */ ne(/* @__PURE__ */ N());
2187
- if (t.required === !0) {
2188
- const i = d(t.messages?.required, n) ?? "This field is required";
2189
- o = o.check(/* @__PURE__ */ y((s) => s.length > 0, { error: i }));
2190
- }
2191
- if (typeof t.minItems == "number") {
2192
- const i = d(t.messages?.minItems, n), s = t.minItems;
2193
- o = o.check(
2194
- i ? /* @__PURE__ */ y((a) => a.length >= s, { error: i }) : /* @__PURE__ */ O(s)
2195
- );
2196
- }
2197
- if (typeof t.maxItems == "number") {
2198
- const i = d(t.messages?.maxItems, n), s = t.maxItems;
2199
- o = o.check(
2200
- i ? /* @__PURE__ */ y((a) => a.length <= s, { error: i }) : /* @__PURE__ */ D(s)
2201
- );
2202
- }
2203
- return o;
2204
- });
2205
- }
2206
- const nn = "This field is required", tn = "Invalid file", rn = "Wait for the upload to finish";
2207
- function re(e) {
2208
- if (e === null || typeof e != "object")
2209
- return !1;
2210
- const n = e;
2211
- return typeof n.id == "string" && typeof n.name == "string" && typeof n.size == "number" && typeof n.type == "string" && typeof n.status == "string" && Io.includes(n.status);
2212
- }
2213
- function Fo(e, n) {
2214
- const t = d(e.messages?.invalid, n) ?? tn, r = d(e.messages?.required, n) ?? nn, o = d(e.messages?.pendingUploads, n) ?? rn, i = e.blockPendingUploads !== !1;
2215
- return (/* @__PURE__ */ N()).check(
2216
- /* @__PURE__ */ X((s, a) => {
2217
- if (s == null) {
2218
- e.required === !0 && a.addIssue({ code: "custom", message: r });
2219
- return;
2220
- }
2221
- if (!re(s)) {
2222
- a.addIssue({ code: "custom", message: t });
2223
- return;
2224
- }
2225
- i && s.status !== "uploaded" && a.addIssue({ code: "custom", message: o });
2226
- })
2227
- );
2228
- }
2229
- function Do(e, n) {
2230
- const t = d(e.messages?.required, n) ?? nn, r = xo(e, n, t);
2231
- return (/* @__PURE__ */ N()).check(
2232
- /* @__PURE__ */ X((o, i) => {
2233
- if (o == null) {
2234
- e.required === !0 && i.addIssue({ code: "custom", message: t });
2235
- return;
2236
- }
2237
- const s = oe(
2238
- r,
2239
- o
2240
- );
2241
- if (!se(s))
2242
- for (const a of s.issues)
2243
- i.addIssue({ code: "custom", message: a.message });
2244
- })
2245
- );
2246
- }
2247
- function xo(e, n, t) {
2248
- const r = d(e.messages?.invalid, n) ?? tn;
2249
- let o = (/* @__PURE__ */ ne(/* @__PURE__ */ N(), r)).check(
2250
- /* @__PURE__ */ y((i) => i.every(re), { error: r })
2251
- );
2252
- if (e.required === !0 && (o = o.check(/* @__PURE__ */ y((i) => i.length > 0, { error: t }))), typeof e.minItems == "number") {
2253
- const i = d(e.messages?.minItems, n), s = e.minItems;
2254
- o = o.check(
2255
- i ? /* @__PURE__ */ y((a) => a.length >= s, { error: i }) : /* @__PURE__ */ O(s)
2256
- );
2257
- }
2258
- if (typeof e.maxItems == "number") {
2259
- const i = d(e.messages?.maxItems, n), s = e.maxItems;
2260
- o = o.check(
2261
- i ? /* @__PURE__ */ y((a) => a.length <= s, { error: i }) : /* @__PURE__ */ D(s)
2262
- );
2263
- }
2264
- if (e.blockPendingUploads !== !1) {
2265
- const i = d(e.messages?.pendingUploads, n) ?? rn;
2266
- o = o.check(
2267
- /* @__PURE__ */ y(
2268
- (s) => s.every((a) => !re(a) || a.status === "uploaded"),
2269
- { error: i }
2270
- )
2271
- );
2272
- }
2273
- return o;
2274
- }
2275
- function Uo(e, n) {
2276
- return x(e, (t) => {
2277
- let r = /* @__PURE__ */ N();
2278
- return an(
2279
- Object.keys(t),
2280
- // filter non-custom validator keys
2281
- (o) => o !== "type" && o !== "required",
2282
- (o) => {
2283
- const i = t[o], s = n[o];
2284
- if (!s) {
2285
- const c = Object.keys(n).map((f) => `"${f}"`).join(", ");
2286
- throw new Error(
2287
- `Unknown custom validator rule "${o}". Registered rules: ${c || "(none)"}.`
2288
- );
2289
- }
2290
- const a = s(i);
2291
- r = r.check(
2292
- /* @__PURE__ */ X((c, f) => {
2293
- const m = oe(
2294
- a,
2295
- c
2296
- );
2297
- if (!se(m)) {
2298
- const h = m.issues[0];
2299
- f.addIssue({
2300
- code: "custom",
2301
- path: [],
2302
- message: h?.message || `Validation failed for ${o}`
2303
- });
2304
- }
2305
- })
2306
- );
2307
- }
2308
- ), r;
2309
- });
2310
- }
2311
- function x(e, n) {
2312
- const t = n(e);
2313
- return e.required ? t : /* @__PURE__ */ Oo(t);
2314
- }
2315
- const Lo = {
2
+ import { safeDefine as e } from "@golemui/lit/internals";
3
+ import { resolveFormInput as a } from "@golemui/gui-shared/internals";
4
+ import { initValidators as t } from "@golemui/gui-validators";
5
+ import { createFormComponent as i } from "@golemui/lit";
6
+ const n = {
2316
7
  // ACTION
2317
8
  button: async () => (await import("./button.element-CKYv0Glr.js")).ButtonElement,
2318
9
  // INPUTS
@@ -2361,14 +52,14 @@ const Lo = {
2361
52
  markdownText: async () => (await import("./markdown-text.element-DflCQwAo.js")).MarkdownTextElement,
2362
53
  renderer: async () => (await import("./renderer.element-BVwerbtL.js")).RendererElement
2363
54
  };
2364
- class Jo extends cn({
2365
- widgetLoaders: Lo,
2366
- validators: Ao,
2367
- resolveFormInput: sn
55
+ class m extends i({
56
+ widgetLoaders: n,
57
+ validators: t,
58
+ resolveFormInput: a
2368
59
  }) {
2369
60
  }
2370
- on("gui-form", Jo);
61
+ e("gui-form", m);
2371
62
  export {
2372
- Jo as FormElement,
2373
- Lo as widgetLoaders
63
+ m as FormElement,
64
+ n as widgetLoaders
2374
65
  };