@gamaro.io/widget 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/README.md +662 -0
- package/dist/config.d.ts +6 -0
- package/dist/iframe-loader.d.ts +78 -0
- package/dist/index.d.ts +64 -0
- package/dist/loader.d.ts +146 -0
- package/dist/logger.d.ts +26 -0
- package/dist/postmessage.d.ts +52 -0
- package/dist/types.d.ts +185 -0
- package/dist/widget.es.js +3529 -0
- package/dist/widget.umd.js +39 -0
- package/package.json +87 -0
|
@@ -0,0 +1,3529 @@
|
|
|
1
|
+
var ut = {
|
|
2
|
+
instant: 0,
|
|
3
|
+
fast: 150,
|
|
4
|
+
base: 250,
|
|
5
|
+
slow: 400,
|
|
6
|
+
slower: 600
|
|
7
|
+
}, M = {
|
|
8
|
+
standard: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
9
|
+
enter: "cubic-bezier(0, 0, 0.2, 1)",
|
|
10
|
+
exit: "cubic-bezier(0.4, 0, 1, 1)",
|
|
11
|
+
emphasized: "cubic-bezier(0.2, 0, 0, 1)"
|
|
12
|
+
}, de = "[Versiq]";
|
|
13
|
+
function oe(e, ...t) {
|
|
14
|
+
console.error(de, e, ...t);
|
|
15
|
+
}
|
|
16
|
+
function Ne(e, ...t) {
|
|
17
|
+
console.warn(de, e, ...t);
|
|
18
|
+
}
|
|
19
|
+
function ie(e, ...t) {
|
|
20
|
+
console.info(de, e, ...t);
|
|
21
|
+
}
|
|
22
|
+
function ne(e, ...t) {
|
|
23
|
+
console.debug(de, e, ...t);
|
|
24
|
+
}
|
|
25
|
+
function Bt(e) {
|
|
26
|
+
return e ? ne : () => {
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var Ht = "versiq:", Gt = ["https://gamaro.io"];
|
|
30
|
+
function lt(e, t) {
|
|
31
|
+
return t.includes(e);
|
|
32
|
+
}
|
|
33
|
+
function dt(e) {
|
|
34
|
+
const t = e.data;
|
|
35
|
+
return typeof t == "object" && t !== null && typeof t.type == "string" && t.type.startsWith(Ht);
|
|
36
|
+
}
|
|
37
|
+
function j(e, t, r) {
|
|
38
|
+
if (!e.contentWindow) {
|
|
39
|
+
Ne("Cannot send command: iframe not ready");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
e.contentWindow.postMessage(t, r);
|
|
44
|
+
} catch {
|
|
45
|
+
Ne("Failed to post message to iframe");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function Kt(e) {
|
|
49
|
+
const { allowedOrigins: t = Gt, onMessage: r, debug: n, sourceWindow: o } = e, a = (i) => {
|
|
50
|
+
if (!(o && i.source && i.source !== o)) {
|
|
51
|
+
if (!lt(i.origin, t)) {
|
|
52
|
+
n && ne("Ignored message from untrusted origin:", i.origin);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (dt(i)) {
|
|
56
|
+
if (n) try {
|
|
57
|
+
ne("Received message:", JSON.parse(JSON.stringify(i.data)));
|
|
58
|
+
} catch {
|
|
59
|
+
ne("Received message:", i.data?.type ?? "[Unserializable]");
|
|
60
|
+
}
|
|
61
|
+
r(i.data, i.origin);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return window.addEventListener("message", a), () => {
|
|
66
|
+
window.removeEventListener("message", a);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function Yt(e) {
|
|
70
|
+
return btoa(JSON.stringify(e));
|
|
71
|
+
}
|
|
72
|
+
var ss = Object.freeze({ status: "aborted" });
|
|
73
|
+
function u(e, t, r) {
|
|
74
|
+
function n(s, c) {
|
|
75
|
+
if (s._zod || Object.defineProperty(s, "_zod", {
|
|
76
|
+
value: {
|
|
77
|
+
def: c,
|
|
78
|
+
constr: i,
|
|
79
|
+
traits: /* @__PURE__ */ new Set()
|
|
80
|
+
},
|
|
81
|
+
enumerable: !1
|
|
82
|
+
}), s._zod.traits.has(e)) return;
|
|
83
|
+
s._zod.traits.add(e), t(s, c);
|
|
84
|
+
const l = i.prototype, d = Object.keys(l);
|
|
85
|
+
for (let p = 0; p < d.length; p++) {
|
|
86
|
+
const h = d[p];
|
|
87
|
+
h in s || (s[h] = l[h].bind(s));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const o = r?.Parent ?? Object;
|
|
91
|
+
class a extends o {
|
|
92
|
+
}
|
|
93
|
+
Object.defineProperty(a, "name", { value: e });
|
|
94
|
+
function i(s) {
|
|
95
|
+
var c;
|
|
96
|
+
const l = r?.Parent ? new a() : this;
|
|
97
|
+
n(l, s), (c = l._zod).deferred ?? (c.deferred = []);
|
|
98
|
+
for (const d of l._zod.deferred) d();
|
|
99
|
+
return l;
|
|
100
|
+
}
|
|
101
|
+
return Object.defineProperty(i, "init", { value: n }), Object.defineProperty(i, Symbol.hasInstance, { value: (s) => r?.Parent && s instanceof r.Parent ? !0 : s?._zod?.traits?.has(e) }), Object.defineProperty(i, "name", { value: e }), i;
|
|
102
|
+
}
|
|
103
|
+
var q = class extends Error {
|
|
104
|
+
constructor() {
|
|
105
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
106
|
+
}
|
|
107
|
+
}, ft = class extends Error {
|
|
108
|
+
constructor(e) {
|
|
109
|
+
super(`Encountered unidirectional transform during encode: ${e}`), this.name = "ZodEncodeError";
|
|
110
|
+
}
|
|
111
|
+
}, we = {};
|
|
112
|
+
function D(e) {
|
|
113
|
+
return e && Object.assign(we, e), we;
|
|
114
|
+
}
|
|
115
|
+
function ht(e) {
|
|
116
|
+
const t = Object.values(e).filter((r) => typeof r == "number");
|
|
117
|
+
return Object.entries(e).filter(([r, n]) => t.indexOf(+r) === -1).map(([r, n]) => n);
|
|
118
|
+
}
|
|
119
|
+
function ye(e, t) {
|
|
120
|
+
return typeof t == "bigint" ? t.toString() : t;
|
|
121
|
+
}
|
|
122
|
+
function $e(e) {
|
|
123
|
+
return { get value() {
|
|
124
|
+
{
|
|
125
|
+
const t = e();
|
|
126
|
+
return Object.defineProperty(this, "value", { value: t }), t;
|
|
127
|
+
}
|
|
128
|
+
throw new Error("cached value already set");
|
|
129
|
+
} };
|
|
130
|
+
}
|
|
131
|
+
function Se(e) {
|
|
132
|
+
return e == null;
|
|
133
|
+
}
|
|
134
|
+
function Oe(e) {
|
|
135
|
+
const t = e.startsWith("^") ? 1 : 0, r = e.endsWith("$") ? e.length - 1 : e.length;
|
|
136
|
+
return e.slice(t, r);
|
|
137
|
+
}
|
|
138
|
+
function Qt(e, t) {
|
|
139
|
+
const r = (e.toString().split(".")[1] || "").length, n = t.toString();
|
|
140
|
+
let o = (n.split(".")[1] || "").length;
|
|
141
|
+
if (o === 0 && /\d?e-\d?/.test(n)) {
|
|
142
|
+
const i = n.match(/\d?e-(\d?)/);
|
|
143
|
+
i?.[1] && (o = Number.parseInt(i[1]));
|
|
144
|
+
}
|
|
145
|
+
const a = r > o ? r : o;
|
|
146
|
+
return Number.parseInt(e.toFixed(a).replace(".", "")) % Number.parseInt(t.toFixed(a).replace(".", "")) / 10 ** a;
|
|
147
|
+
}
|
|
148
|
+
var Re = /* @__PURE__ */ Symbol("evaluating");
|
|
149
|
+
function g(e, t, r) {
|
|
150
|
+
let n;
|
|
151
|
+
Object.defineProperty(e, t, {
|
|
152
|
+
get() {
|
|
153
|
+
if (n !== Re)
|
|
154
|
+
return n === void 0 && (n = Re, n = r()), n;
|
|
155
|
+
},
|
|
156
|
+
set(o) {
|
|
157
|
+
Object.defineProperty(e, t, { value: o });
|
|
158
|
+
},
|
|
159
|
+
configurable: !0
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function U(e, t, r) {
|
|
163
|
+
Object.defineProperty(e, t, {
|
|
164
|
+
value: r,
|
|
165
|
+
writable: !0,
|
|
166
|
+
enumerable: !0,
|
|
167
|
+
configurable: !0
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function R(...e) {
|
|
171
|
+
const t = {};
|
|
172
|
+
for (const r of e) {
|
|
173
|
+
const n = Object.getOwnPropertyDescriptors(r);
|
|
174
|
+
Object.assign(t, n);
|
|
175
|
+
}
|
|
176
|
+
return Object.defineProperties({}, t);
|
|
177
|
+
}
|
|
178
|
+
function xe(e) {
|
|
179
|
+
return JSON.stringify(e);
|
|
180
|
+
}
|
|
181
|
+
function Xt(e) {
|
|
182
|
+
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
183
|
+
}
|
|
184
|
+
var pt = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
185
|
+
};
|
|
186
|
+
function ae(e) {
|
|
187
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
188
|
+
}
|
|
189
|
+
var er = $e(() => {
|
|
190
|
+
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare")) return !1;
|
|
191
|
+
try {
|
|
192
|
+
return new Function(""), !0;
|
|
193
|
+
} catch {
|
|
194
|
+
return !1;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
function K(e) {
|
|
198
|
+
if (ae(e) === !1) return !1;
|
|
199
|
+
const t = e.constructor;
|
|
200
|
+
if (t === void 0 || typeof t != "function") return !0;
|
|
201
|
+
const r = t.prototype;
|
|
202
|
+
return !(ae(r) === !1 || Object.prototype.hasOwnProperty.call(r, "isPrototypeOf") === !1);
|
|
203
|
+
}
|
|
204
|
+
function mt(e) {
|
|
205
|
+
return K(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
|
|
206
|
+
}
|
|
207
|
+
var tr = /* @__PURE__ */ new Set([
|
|
208
|
+
"string",
|
|
209
|
+
"number",
|
|
210
|
+
"symbol"
|
|
211
|
+
]);
|
|
212
|
+
function fe(e) {
|
|
213
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
214
|
+
}
|
|
215
|
+
function x(e, t, r) {
|
|
216
|
+
const n = new e._zod.constr(t ?? e._zod.def);
|
|
217
|
+
return (!t || r?.parent) && (n._zod.parent = e), n;
|
|
218
|
+
}
|
|
219
|
+
function f(e) {
|
|
220
|
+
const t = e;
|
|
221
|
+
if (!t) return {};
|
|
222
|
+
if (typeof t == "string") return { error: () => t };
|
|
223
|
+
if (t?.message !== void 0) {
|
|
224
|
+
if (t?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
225
|
+
t.error = t.message;
|
|
226
|
+
}
|
|
227
|
+
return delete t.message, typeof t.error == "string" ? {
|
|
228
|
+
...t,
|
|
229
|
+
error: () => t.error
|
|
230
|
+
} : t;
|
|
231
|
+
}
|
|
232
|
+
function rr(e) {
|
|
233
|
+
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
|
|
234
|
+
}
|
|
235
|
+
var nr = {
|
|
236
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
237
|
+
int32: [-2147483648, 2147483647],
|
|
238
|
+
uint32: [0, 4294967295],
|
|
239
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
240
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
241
|
+
};
|
|
242
|
+
function or(e, t) {
|
|
243
|
+
const r = e._zod.def, n = r.checks;
|
|
244
|
+
if (n && n.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
245
|
+
return x(e, R(e._zod.def, {
|
|
246
|
+
get shape() {
|
|
247
|
+
const o = {};
|
|
248
|
+
for (const a in t) {
|
|
249
|
+
if (!(a in r.shape)) throw new Error(`Unrecognized key: "${a}"`);
|
|
250
|
+
t[a] && (o[a] = r.shape[a]);
|
|
251
|
+
}
|
|
252
|
+
return U(this, "shape", o), o;
|
|
253
|
+
},
|
|
254
|
+
checks: []
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
function ir(e, t) {
|
|
258
|
+
const r = e._zod.def, n = r.checks;
|
|
259
|
+
if (n && n.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
260
|
+
return x(e, R(e._zod.def, {
|
|
261
|
+
get shape() {
|
|
262
|
+
const o = { ...e._zod.def.shape };
|
|
263
|
+
for (const a in t) {
|
|
264
|
+
if (!(a in r.shape)) throw new Error(`Unrecognized key: "${a}"`);
|
|
265
|
+
t[a] && delete o[a];
|
|
266
|
+
}
|
|
267
|
+
return U(this, "shape", o), o;
|
|
268
|
+
},
|
|
269
|
+
checks: []
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
function ar(e, t) {
|
|
273
|
+
if (!K(t)) throw new Error("Invalid input to extend: expected a plain object");
|
|
274
|
+
const r = e._zod.def.checks;
|
|
275
|
+
if (r && r.length > 0) {
|
|
276
|
+
const n = e._zod.def.shape;
|
|
277
|
+
for (const o in t) if (Object.getOwnPropertyDescriptor(n, o) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
278
|
+
}
|
|
279
|
+
return x(e, R(e._zod.def, { get shape() {
|
|
280
|
+
const n = {
|
|
281
|
+
...e._zod.def.shape,
|
|
282
|
+
...t
|
|
283
|
+
};
|
|
284
|
+
return U(this, "shape", n), n;
|
|
285
|
+
} }));
|
|
286
|
+
}
|
|
287
|
+
function sr(e, t) {
|
|
288
|
+
if (!K(t)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
289
|
+
return x(e, R(e._zod.def, { get shape() {
|
|
290
|
+
const r = {
|
|
291
|
+
...e._zod.def.shape,
|
|
292
|
+
...t
|
|
293
|
+
};
|
|
294
|
+
return U(this, "shape", r), r;
|
|
295
|
+
} }));
|
|
296
|
+
}
|
|
297
|
+
function cr(e, t) {
|
|
298
|
+
return x(e, R(e._zod.def, {
|
|
299
|
+
get shape() {
|
|
300
|
+
const r = {
|
|
301
|
+
...e._zod.def.shape,
|
|
302
|
+
...t._zod.def.shape
|
|
303
|
+
};
|
|
304
|
+
return U(this, "shape", r), r;
|
|
305
|
+
},
|
|
306
|
+
get catchall() {
|
|
307
|
+
return t._zod.def.catchall;
|
|
308
|
+
},
|
|
309
|
+
checks: []
|
|
310
|
+
}));
|
|
311
|
+
}
|
|
312
|
+
function ur(e, t, r) {
|
|
313
|
+
const n = t._zod.def.checks;
|
|
314
|
+
if (n && n.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
315
|
+
return x(t, R(t._zod.def, {
|
|
316
|
+
get shape() {
|
|
317
|
+
const o = t._zod.def.shape, a = { ...o };
|
|
318
|
+
if (r) for (const i in r) {
|
|
319
|
+
if (!(i in o)) throw new Error(`Unrecognized key: "${i}"`);
|
|
320
|
+
r[i] && (a[i] = e ? new e({
|
|
321
|
+
type: "optional",
|
|
322
|
+
innerType: o[i]
|
|
323
|
+
}) : o[i]);
|
|
324
|
+
}
|
|
325
|
+
else for (const i in o) a[i] = e ? new e({
|
|
326
|
+
type: "optional",
|
|
327
|
+
innerType: o[i]
|
|
328
|
+
}) : o[i];
|
|
329
|
+
return U(this, "shape", a), a;
|
|
330
|
+
},
|
|
331
|
+
checks: []
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
function lr(e, t, r) {
|
|
335
|
+
return x(t, R(t._zod.def, { get shape() {
|
|
336
|
+
const n = t._zod.def.shape, o = { ...n };
|
|
337
|
+
if (r) for (const a in r) {
|
|
338
|
+
if (!(a in o)) throw new Error(`Unrecognized key: "${a}"`);
|
|
339
|
+
r[a] && (o[a] = new e({
|
|
340
|
+
type: "nonoptional",
|
|
341
|
+
innerType: n[a]
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
344
|
+
else for (const a in n) o[a] = new e({
|
|
345
|
+
type: "nonoptional",
|
|
346
|
+
innerType: n[a]
|
|
347
|
+
});
|
|
348
|
+
return U(this, "shape", o), o;
|
|
349
|
+
} }));
|
|
350
|
+
}
|
|
351
|
+
function V(e, t = 0) {
|
|
352
|
+
if (e.aborted === !0) return !0;
|
|
353
|
+
for (let r = t; r < e.issues.length; r++) if (e.issues[r]?.continue !== !0) return !0;
|
|
354
|
+
return !1;
|
|
355
|
+
}
|
|
356
|
+
function gt(e, t) {
|
|
357
|
+
return t.map((r) => {
|
|
358
|
+
var n;
|
|
359
|
+
return (n = r).path ?? (n.path = []), r.path.unshift(e), r;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function Q(e) {
|
|
363
|
+
return typeof e == "string" ? e : e?.message;
|
|
364
|
+
}
|
|
365
|
+
function L(e, t, r) {
|
|
366
|
+
const n = {
|
|
367
|
+
...e,
|
|
368
|
+
path: e.path ?? []
|
|
369
|
+
};
|
|
370
|
+
return e.message || (n.message = Q(e.inst?._zod.def?.error?.(e)) ?? Q(t?.error?.(e)) ?? Q(r.customError?.(e)) ?? Q(r.localeError?.(e)) ?? "Invalid input"), delete n.inst, delete n.continue, t?.reportInput || delete n.input, n;
|
|
371
|
+
}
|
|
372
|
+
function Ie(e) {
|
|
373
|
+
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
|
|
374
|
+
}
|
|
375
|
+
function Y(...e) {
|
|
376
|
+
const [t, r, n] = e;
|
|
377
|
+
return typeof t == "string" ? {
|
|
378
|
+
message: t,
|
|
379
|
+
code: "custom",
|
|
380
|
+
input: r,
|
|
381
|
+
inst: n
|
|
382
|
+
} : { ...t };
|
|
383
|
+
}
|
|
384
|
+
var vt = (e, t) => {
|
|
385
|
+
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
386
|
+
value: e._zod,
|
|
387
|
+
enumerable: !1
|
|
388
|
+
}), Object.defineProperty(e, "issues", {
|
|
389
|
+
value: t,
|
|
390
|
+
enumerable: !1
|
|
391
|
+
}), e.message = JSON.stringify(t, ye, 2), Object.defineProperty(e, "toString", {
|
|
392
|
+
value: () => e.message,
|
|
393
|
+
enumerable: !1
|
|
394
|
+
});
|
|
395
|
+
}, bt = u("$ZodError", vt), _t = u("$ZodError", vt, { Parent: Error });
|
|
396
|
+
function dr(e, t = (r) => r.message) {
|
|
397
|
+
const r = {}, n = [];
|
|
398
|
+
for (const o of e.issues) o.path.length > 0 ? (r[o.path[0]] = r[o.path[0]] || [], r[o.path[0]].push(t(o))) : n.push(t(o));
|
|
399
|
+
return {
|
|
400
|
+
formErrors: n,
|
|
401
|
+
fieldErrors: r
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function fr(e, t = (r) => r.message) {
|
|
405
|
+
const r = { _errors: [] }, n = (o) => {
|
|
406
|
+
for (const a of o.issues) if (a.code === "invalid_union" && a.errors.length) a.errors.map((i) => n({ issues: i }));
|
|
407
|
+
else if (a.code === "invalid_key") n({ issues: a.issues });
|
|
408
|
+
else if (a.code === "invalid_element") n({ issues: a.issues });
|
|
409
|
+
else if (a.path.length === 0) r._errors.push(t(a));
|
|
410
|
+
else {
|
|
411
|
+
let i = r, s = 0;
|
|
412
|
+
for (; s < a.path.length; ) {
|
|
413
|
+
const c = a.path[s];
|
|
414
|
+
s !== a.path.length - 1 ? i[c] = i[c] || { _errors: [] } : (i[c] = i[c] || { _errors: [] }, i[c]._errors.push(t(a))), i = i[c], s++;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
return n(e), r;
|
|
419
|
+
}
|
|
420
|
+
var Ze = (e) => (t, r, n, o) => {
|
|
421
|
+
const a = n ? Object.assign(n, { async: !1 }) : { async: !1 }, i = t._zod.run({
|
|
422
|
+
value: r,
|
|
423
|
+
issues: []
|
|
424
|
+
}, a);
|
|
425
|
+
if (i instanceof Promise) throw new q();
|
|
426
|
+
if (i.issues.length) {
|
|
427
|
+
const s = new (o?.Err ?? e)(i.issues.map((c) => L(c, a, D())));
|
|
428
|
+
throw pt(s, o?.callee), s;
|
|
429
|
+
}
|
|
430
|
+
return i.value;
|
|
431
|
+
}, Te = (e) => async (t, r, n, o) => {
|
|
432
|
+
const a = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
433
|
+
let i = t._zod.run({
|
|
434
|
+
value: r,
|
|
435
|
+
issues: []
|
|
436
|
+
}, a);
|
|
437
|
+
if (i instanceof Promise && (i = await i), i.issues.length) {
|
|
438
|
+
const s = new (o?.Err ?? e)(i.issues.map((c) => L(c, a, D())));
|
|
439
|
+
throw pt(s, o?.callee), s;
|
|
440
|
+
}
|
|
441
|
+
return i.value;
|
|
442
|
+
}, he = (e) => (t, r, n) => {
|
|
443
|
+
const o = n ? {
|
|
444
|
+
...n,
|
|
445
|
+
async: !1
|
|
446
|
+
} : { async: !1 }, a = t._zod.run({
|
|
447
|
+
value: r,
|
|
448
|
+
issues: []
|
|
449
|
+
}, o);
|
|
450
|
+
if (a instanceof Promise) throw new q();
|
|
451
|
+
return a.issues.length ? {
|
|
452
|
+
success: !1,
|
|
453
|
+
error: new (e ?? bt)(a.issues.map((i) => L(i, o, D())))
|
|
454
|
+
} : {
|
|
455
|
+
success: !0,
|
|
456
|
+
data: a.value
|
|
457
|
+
};
|
|
458
|
+
}, hr = /* @__PURE__ */ he(_t), pe = (e) => async (t, r, n) => {
|
|
459
|
+
const o = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
460
|
+
let a = t._zod.run({
|
|
461
|
+
value: r,
|
|
462
|
+
issues: []
|
|
463
|
+
}, o);
|
|
464
|
+
return a instanceof Promise && (a = await a), a.issues.length ? {
|
|
465
|
+
success: !1,
|
|
466
|
+
error: new e(a.issues.map((i) => L(i, o, D())))
|
|
467
|
+
} : {
|
|
468
|
+
success: !0,
|
|
469
|
+
data: a.value
|
|
470
|
+
};
|
|
471
|
+
}, pr = /* @__PURE__ */ pe(_t), mr = (e) => (t, r, n) => {
|
|
472
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
473
|
+
return Ze(e)(t, r, o);
|
|
474
|
+
}, gr = (e) => (t, r, n) => Ze(e)(t, r, n), vr = (e) => async (t, r, n) => {
|
|
475
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
476
|
+
return Te(e)(t, r, o);
|
|
477
|
+
}, br = (e) => async (t, r, n) => Te(e)(t, r, n), _r = (e) => (t, r, n) => {
|
|
478
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
479
|
+
return he(e)(t, r, o);
|
|
480
|
+
}, wr = (e) => (t, r, n) => he(e)(t, r, n), yr = (e) => async (t, r, n) => {
|
|
481
|
+
const o = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
482
|
+
return pe(e)(t, r, o);
|
|
483
|
+
}, zr = (e) => async (t, r, n) => pe(e)(t, r, n), kr = /^[cC][^\s-]{8,}$/, Er = /^[0-9a-z]+$/, $r = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Sr = /^[0-9a-vA-V]{20}$/, Or = /^[A-Za-z0-9]{27}$/, Ir = /^[a-zA-Z0-9_-]{21}$/, Zr = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Tr = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, je = (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)$/, Ar = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Cr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
484
|
+
function Pr() {
|
|
485
|
+
return new RegExp(Cr, "u");
|
|
486
|
+
}
|
|
487
|
+
var Nr = /^(?:(?: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])$/, Rr = /^(([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}|:))$/, xr = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/, jr = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Mr = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, wt = /^[A-Za-z0-9_-]*$/, Dr = /^\+[1-9]\d{6,14}$/, yt = "(?:(?:\\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])))", Lr = /* @__PURE__ */ new RegExp(`^${yt}$`);
|
|
488
|
+
function zt(e) {
|
|
489
|
+
const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
490
|
+
return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
491
|
+
}
|
|
492
|
+
function Ur(e) {
|
|
493
|
+
return new RegExp(`^${zt(e)}$`);
|
|
494
|
+
}
|
|
495
|
+
function Fr(e) {
|
|
496
|
+
const t = zt({ precision: e.precision }), r = ["Z"];
|
|
497
|
+
e.local && r.push(""), e.offset && r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
498
|
+
const n = `${t}(?:${r.join("|")})`;
|
|
499
|
+
return new RegExp(`^${yt}T(?:${n})$`);
|
|
500
|
+
}
|
|
501
|
+
var Vr = (e) => {
|
|
502
|
+
const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
503
|
+
return new RegExp(`^${t}$`);
|
|
504
|
+
}, qr = /^-?\d+$/, Jr = /^-?\d+(?:\.\d+)?$/, Wr = /^(?:true|false)$/i, Br = /^[^A-Z]*$/, Hr = /^[^a-z]*$/, S = /* @__PURE__ */ u("$ZodCheck", (e, t) => {
|
|
505
|
+
var r;
|
|
506
|
+
e._zod ?? (e._zod = {}), e._zod.def = t, (r = e._zod).onattach ?? (r.onattach = []);
|
|
507
|
+
}), kt = {
|
|
508
|
+
number: "number",
|
|
509
|
+
bigint: "bigint",
|
|
510
|
+
object: "date"
|
|
511
|
+
}, Et = /* @__PURE__ */ u("$ZodCheckLessThan", (e, t) => {
|
|
512
|
+
S.init(e, t);
|
|
513
|
+
const r = kt[typeof t.value];
|
|
514
|
+
e._zod.onattach.push((n) => {
|
|
515
|
+
const o = n._zod.bag, a = (t.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
516
|
+
t.value < a && (t.inclusive ? o.maximum = t.value : o.exclusiveMaximum = t.value);
|
|
517
|
+
}), e._zod.check = (n) => {
|
|
518
|
+
(t.inclusive ? n.value <= t.value : n.value < t.value) || n.issues.push({
|
|
519
|
+
origin: r,
|
|
520
|
+
code: "too_big",
|
|
521
|
+
maximum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
522
|
+
input: n.value,
|
|
523
|
+
inclusive: t.inclusive,
|
|
524
|
+
inst: e,
|
|
525
|
+
continue: !t.abort
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
}), $t = /* @__PURE__ */ u("$ZodCheckGreaterThan", (e, t) => {
|
|
529
|
+
S.init(e, t);
|
|
530
|
+
const r = kt[typeof t.value];
|
|
531
|
+
e._zod.onattach.push((n) => {
|
|
532
|
+
const o = n._zod.bag, a = (t.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
533
|
+
t.value > a && (t.inclusive ? o.minimum = t.value : o.exclusiveMinimum = t.value);
|
|
534
|
+
}), e._zod.check = (n) => {
|
|
535
|
+
(t.inclusive ? n.value >= t.value : n.value > t.value) || n.issues.push({
|
|
536
|
+
origin: r,
|
|
537
|
+
code: "too_small",
|
|
538
|
+
minimum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
539
|
+
input: n.value,
|
|
540
|
+
inclusive: t.inclusive,
|
|
541
|
+
inst: e,
|
|
542
|
+
continue: !t.abort
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
}), Gr = /* @__PURE__ */ u("$ZodCheckMultipleOf", (e, t) => {
|
|
546
|
+
S.init(e, t), e._zod.onattach.push((r) => {
|
|
547
|
+
var n;
|
|
548
|
+
(n = r._zod.bag).multipleOf ?? (n.multipleOf = t.value);
|
|
549
|
+
}), e._zod.check = (r) => {
|
|
550
|
+
if (typeof r.value != typeof t.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
551
|
+
(typeof r.value == "bigint" ? r.value % t.value === BigInt(0) : Qt(r.value, t.value) === 0) || r.issues.push({
|
|
552
|
+
origin: typeof r.value,
|
|
553
|
+
code: "not_multiple_of",
|
|
554
|
+
divisor: t.value,
|
|
555
|
+
input: r.value,
|
|
556
|
+
inst: e,
|
|
557
|
+
continue: !t.abort
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
}), Kr = /* @__PURE__ */ u("$ZodCheckNumberFormat", (e, t) => {
|
|
561
|
+
S.init(e, t), t.format = t.format || "float64";
|
|
562
|
+
const r = t.format?.includes("int"), n = r ? "int" : "number", [o, a] = nr[t.format];
|
|
563
|
+
e._zod.onattach.push((i) => {
|
|
564
|
+
const s = i._zod.bag;
|
|
565
|
+
s.format = t.format, s.minimum = o, s.maximum = a, r && (s.pattern = qr);
|
|
566
|
+
}), e._zod.check = (i) => {
|
|
567
|
+
const s = i.value;
|
|
568
|
+
if (r) {
|
|
569
|
+
if (!Number.isInteger(s)) {
|
|
570
|
+
i.issues.push({
|
|
571
|
+
expected: n,
|
|
572
|
+
format: t.format,
|
|
573
|
+
code: "invalid_type",
|
|
574
|
+
continue: !1,
|
|
575
|
+
input: s,
|
|
576
|
+
inst: e
|
|
577
|
+
});
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (!Number.isSafeInteger(s)) {
|
|
581
|
+
s > 0 ? i.issues.push({
|
|
582
|
+
input: s,
|
|
583
|
+
code: "too_big",
|
|
584
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
585
|
+
note: "Integers must be within the safe integer range.",
|
|
586
|
+
inst: e,
|
|
587
|
+
origin: n,
|
|
588
|
+
inclusive: !0,
|
|
589
|
+
continue: !t.abort
|
|
590
|
+
}) : i.issues.push({
|
|
591
|
+
input: s,
|
|
592
|
+
code: "too_small",
|
|
593
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
594
|
+
note: "Integers must be within the safe integer range.",
|
|
595
|
+
inst: e,
|
|
596
|
+
origin: n,
|
|
597
|
+
inclusive: !0,
|
|
598
|
+
continue: !t.abort
|
|
599
|
+
});
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
s < o && i.issues.push({
|
|
604
|
+
origin: "number",
|
|
605
|
+
input: s,
|
|
606
|
+
code: "too_small",
|
|
607
|
+
minimum: o,
|
|
608
|
+
inclusive: !0,
|
|
609
|
+
inst: e,
|
|
610
|
+
continue: !t.abort
|
|
611
|
+
}), s > a && i.issues.push({
|
|
612
|
+
origin: "number",
|
|
613
|
+
input: s,
|
|
614
|
+
code: "too_big",
|
|
615
|
+
maximum: a,
|
|
616
|
+
inclusive: !0,
|
|
617
|
+
inst: e,
|
|
618
|
+
continue: !t.abort
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
}), Yr = /* @__PURE__ */ u("$ZodCheckMaxLength", (e, t) => {
|
|
622
|
+
var r;
|
|
623
|
+
S.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
624
|
+
const o = n.value;
|
|
625
|
+
return !Se(o) && o.length !== void 0;
|
|
626
|
+
}), e._zod.onattach.push((n) => {
|
|
627
|
+
const o = n._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
628
|
+
t.maximum < o && (n._zod.bag.maximum = t.maximum);
|
|
629
|
+
}), e._zod.check = (n) => {
|
|
630
|
+
const o = n.value;
|
|
631
|
+
if (o.length <= t.maximum) return;
|
|
632
|
+
const a = Ie(o);
|
|
633
|
+
n.issues.push({
|
|
634
|
+
origin: a,
|
|
635
|
+
code: "too_big",
|
|
636
|
+
maximum: t.maximum,
|
|
637
|
+
inclusive: !0,
|
|
638
|
+
input: o,
|
|
639
|
+
inst: e,
|
|
640
|
+
continue: !t.abort
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
}), Qr = /* @__PURE__ */ u("$ZodCheckMinLength", (e, t) => {
|
|
644
|
+
var r;
|
|
645
|
+
S.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
646
|
+
const o = n.value;
|
|
647
|
+
return !Se(o) && o.length !== void 0;
|
|
648
|
+
}), e._zod.onattach.push((n) => {
|
|
649
|
+
const o = n._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
650
|
+
t.minimum > o && (n._zod.bag.minimum = t.minimum);
|
|
651
|
+
}), e._zod.check = (n) => {
|
|
652
|
+
const o = n.value;
|
|
653
|
+
if (o.length >= t.minimum) return;
|
|
654
|
+
const a = Ie(o);
|
|
655
|
+
n.issues.push({
|
|
656
|
+
origin: a,
|
|
657
|
+
code: "too_small",
|
|
658
|
+
minimum: t.minimum,
|
|
659
|
+
inclusive: !0,
|
|
660
|
+
input: o,
|
|
661
|
+
inst: e,
|
|
662
|
+
continue: !t.abort
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
}), Xr = /* @__PURE__ */ u("$ZodCheckLengthEquals", (e, t) => {
|
|
666
|
+
var r;
|
|
667
|
+
S.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
668
|
+
const o = n.value;
|
|
669
|
+
return !Se(o) && o.length !== void 0;
|
|
670
|
+
}), e._zod.onattach.push((n) => {
|
|
671
|
+
const o = n._zod.bag;
|
|
672
|
+
o.minimum = t.length, o.maximum = t.length, o.length = t.length;
|
|
673
|
+
}), e._zod.check = (n) => {
|
|
674
|
+
const o = n.value, a = o.length;
|
|
675
|
+
if (a === t.length) return;
|
|
676
|
+
const i = Ie(o), s = a > t.length;
|
|
677
|
+
n.issues.push({
|
|
678
|
+
origin: i,
|
|
679
|
+
...s ? {
|
|
680
|
+
code: "too_big",
|
|
681
|
+
maximum: t.length
|
|
682
|
+
} : {
|
|
683
|
+
code: "too_small",
|
|
684
|
+
minimum: t.length
|
|
685
|
+
},
|
|
686
|
+
inclusive: !0,
|
|
687
|
+
exact: !0,
|
|
688
|
+
input: n.value,
|
|
689
|
+
inst: e,
|
|
690
|
+
continue: !t.abort
|
|
691
|
+
});
|
|
692
|
+
};
|
|
693
|
+
}), me = /* @__PURE__ */ u("$ZodCheckStringFormat", (e, t) => {
|
|
694
|
+
var r, n;
|
|
695
|
+
S.init(e, t), e._zod.onattach.push((o) => {
|
|
696
|
+
const a = o._zod.bag;
|
|
697
|
+
a.format = t.format, t.pattern && (a.patterns ?? (a.patterns = /* @__PURE__ */ new Set()), a.patterns.add(t.pattern));
|
|
698
|
+
}), t.pattern ? (r = e._zod).check ?? (r.check = (o) => {
|
|
699
|
+
t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
|
|
700
|
+
origin: "string",
|
|
701
|
+
code: "invalid_format",
|
|
702
|
+
format: t.format,
|
|
703
|
+
input: o.value,
|
|
704
|
+
...t.pattern ? { pattern: t.pattern.toString() } : {},
|
|
705
|
+
inst: e,
|
|
706
|
+
continue: !t.abort
|
|
707
|
+
});
|
|
708
|
+
}) : (n = e._zod).check ?? (n.check = () => {
|
|
709
|
+
});
|
|
710
|
+
}), en = /* @__PURE__ */ u("$ZodCheckRegex", (e, t) => {
|
|
711
|
+
me.init(e, t), e._zod.check = (r) => {
|
|
712
|
+
t.pattern.lastIndex = 0, !t.pattern.test(r.value) && r.issues.push({
|
|
713
|
+
origin: "string",
|
|
714
|
+
code: "invalid_format",
|
|
715
|
+
format: "regex",
|
|
716
|
+
input: r.value,
|
|
717
|
+
pattern: t.pattern.toString(),
|
|
718
|
+
inst: e,
|
|
719
|
+
continue: !t.abort
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
}), tn = /* @__PURE__ */ u("$ZodCheckLowerCase", (e, t) => {
|
|
723
|
+
t.pattern ?? (t.pattern = Br), me.init(e, t);
|
|
724
|
+
}), rn = /* @__PURE__ */ u("$ZodCheckUpperCase", (e, t) => {
|
|
725
|
+
t.pattern ?? (t.pattern = Hr), me.init(e, t);
|
|
726
|
+
}), nn = /* @__PURE__ */ u("$ZodCheckIncludes", (e, t) => {
|
|
727
|
+
S.init(e, t);
|
|
728
|
+
const r = fe(t.includes), n = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${r}` : r);
|
|
729
|
+
t.pattern = n, e._zod.onattach.push((o) => {
|
|
730
|
+
const a = o._zod.bag;
|
|
731
|
+
a.patterns ?? (a.patterns = /* @__PURE__ */ new Set()), a.patterns.add(n);
|
|
732
|
+
}), e._zod.check = (o) => {
|
|
733
|
+
o.value.includes(t.includes, t.position) || o.issues.push({
|
|
734
|
+
origin: "string",
|
|
735
|
+
code: "invalid_format",
|
|
736
|
+
format: "includes",
|
|
737
|
+
includes: t.includes,
|
|
738
|
+
input: o.value,
|
|
739
|
+
inst: e,
|
|
740
|
+
continue: !t.abort
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
}), on = /* @__PURE__ */ u("$ZodCheckStartsWith", (e, t) => {
|
|
744
|
+
S.init(e, t);
|
|
745
|
+
const r = new RegExp(`^${fe(t.prefix)}.*`);
|
|
746
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
747
|
+
const o = n._zod.bag;
|
|
748
|
+
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(r);
|
|
749
|
+
}), e._zod.check = (n) => {
|
|
750
|
+
n.value.startsWith(t.prefix) || n.issues.push({
|
|
751
|
+
origin: "string",
|
|
752
|
+
code: "invalid_format",
|
|
753
|
+
format: "starts_with",
|
|
754
|
+
prefix: t.prefix,
|
|
755
|
+
input: n.value,
|
|
756
|
+
inst: e,
|
|
757
|
+
continue: !t.abort
|
|
758
|
+
});
|
|
759
|
+
};
|
|
760
|
+
}), an = /* @__PURE__ */ u("$ZodCheckEndsWith", (e, t) => {
|
|
761
|
+
S.init(e, t);
|
|
762
|
+
const r = new RegExp(`.*${fe(t.suffix)}$`);
|
|
763
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
764
|
+
const o = n._zod.bag;
|
|
765
|
+
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(r);
|
|
766
|
+
}), e._zod.check = (n) => {
|
|
767
|
+
n.value.endsWith(t.suffix) || n.issues.push({
|
|
768
|
+
origin: "string",
|
|
769
|
+
code: "invalid_format",
|
|
770
|
+
format: "ends_with",
|
|
771
|
+
suffix: t.suffix,
|
|
772
|
+
input: n.value,
|
|
773
|
+
inst: e,
|
|
774
|
+
continue: !t.abort
|
|
775
|
+
});
|
|
776
|
+
};
|
|
777
|
+
}), sn = /* @__PURE__ */ u("$ZodCheckOverwrite", (e, t) => {
|
|
778
|
+
S.init(e, t), e._zod.check = (r) => {
|
|
779
|
+
r.value = t.tx(r.value);
|
|
780
|
+
};
|
|
781
|
+
}), cn = class {
|
|
782
|
+
constructor(e = []) {
|
|
783
|
+
this.content = [], this.indent = 0, this && (this.args = e);
|
|
784
|
+
}
|
|
785
|
+
indented(e) {
|
|
786
|
+
this.indent += 1, e(this), this.indent -= 1;
|
|
787
|
+
}
|
|
788
|
+
write(e) {
|
|
789
|
+
if (typeof e == "function") {
|
|
790
|
+
e(this, { execution: "sync" }), e(this, { execution: "async" });
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
const t = e.split(`
|
|
794
|
+
`).filter((o) => o), r = Math.min(...t.map((o) => o.length - o.trimStart().length)), n = t.map((o) => o.slice(r)).map((o) => " ".repeat(this.indent * 2) + o);
|
|
795
|
+
for (const o of n) this.content.push(o);
|
|
796
|
+
}
|
|
797
|
+
compile() {
|
|
798
|
+
const e = Function, t = this?.args, r = [...(this?.content ?? [""]).map((n) => ` ${n}`)];
|
|
799
|
+
return new e(...t, r.join(`
|
|
800
|
+
`));
|
|
801
|
+
}
|
|
802
|
+
}, un = {
|
|
803
|
+
major: 4,
|
|
804
|
+
minor: 3,
|
|
805
|
+
patch: 6
|
|
806
|
+
}, y = /* @__PURE__ */ u("$ZodType", (e, t) => {
|
|
807
|
+
var r;
|
|
808
|
+
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = un;
|
|
809
|
+
const n = [...e._zod.def.checks ?? []];
|
|
810
|
+
e._zod.traits.has("$ZodCheck") && n.unshift(e);
|
|
811
|
+
for (const o of n) for (const a of o._zod.onattach) a(e);
|
|
812
|
+
if (n.length === 0)
|
|
813
|
+
(r = e._zod).deferred ?? (r.deferred = []), e._zod.deferred?.push(() => {
|
|
814
|
+
e._zod.run = e._zod.parse;
|
|
815
|
+
});
|
|
816
|
+
else {
|
|
817
|
+
const o = (i, s, c) => {
|
|
818
|
+
let l = V(i), d;
|
|
819
|
+
for (const p of s) {
|
|
820
|
+
if (p._zod.def.when) {
|
|
821
|
+
if (!p._zod.def.when(i)) continue;
|
|
822
|
+
} else if (l) continue;
|
|
823
|
+
const h = i.issues.length, m = p._zod.check(i);
|
|
824
|
+
if (m instanceof Promise && c?.async === !1) throw new q();
|
|
825
|
+
if (d || m instanceof Promise) d = (d ?? Promise.resolve()).then(async () => {
|
|
826
|
+
await m, i.issues.length !== h && (l || (l = V(i, h)));
|
|
827
|
+
});
|
|
828
|
+
else {
|
|
829
|
+
if (i.issues.length === h) continue;
|
|
830
|
+
l || (l = V(i, h));
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return d ? d.then(() => i) : i;
|
|
834
|
+
}, a = (i, s, c) => {
|
|
835
|
+
if (V(i))
|
|
836
|
+
return i.aborted = !0, i;
|
|
837
|
+
const l = o(s, n, c);
|
|
838
|
+
if (l instanceof Promise) {
|
|
839
|
+
if (c.async === !1) throw new q();
|
|
840
|
+
return l.then((d) => e._zod.parse(d, c));
|
|
841
|
+
}
|
|
842
|
+
return e._zod.parse(l, c);
|
|
843
|
+
};
|
|
844
|
+
e._zod.run = (i, s) => {
|
|
845
|
+
if (s.skipChecks) return e._zod.parse(i, s);
|
|
846
|
+
if (s.direction === "backward") {
|
|
847
|
+
const l = e._zod.parse({
|
|
848
|
+
value: i.value,
|
|
849
|
+
issues: []
|
|
850
|
+
}, {
|
|
851
|
+
...s,
|
|
852
|
+
skipChecks: !0
|
|
853
|
+
});
|
|
854
|
+
return l instanceof Promise ? l.then((d) => a(d, i, s)) : a(l, i, s);
|
|
855
|
+
}
|
|
856
|
+
const c = e._zod.parse(i, s);
|
|
857
|
+
if (c instanceof Promise) {
|
|
858
|
+
if (s.async === !1) throw new q();
|
|
859
|
+
return c.then((l) => o(l, n, s));
|
|
860
|
+
}
|
|
861
|
+
return o(c, n, s);
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
g(e, "~standard", () => ({
|
|
865
|
+
validate: (o) => {
|
|
866
|
+
try {
|
|
867
|
+
const a = hr(e, o);
|
|
868
|
+
return a.success ? { value: a.data } : { issues: a.error?.issues };
|
|
869
|
+
} catch {
|
|
870
|
+
return pr(e, o).then((i) => i.success ? { value: i.data } : { issues: i.error?.issues });
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
vendor: "zod",
|
|
874
|
+
version: 1
|
|
875
|
+
}));
|
|
876
|
+
}), Ae = /* @__PURE__ */ u("$ZodString", (e, t) => {
|
|
877
|
+
y.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? Vr(e._zod.bag), e._zod.parse = (r, n) => {
|
|
878
|
+
if (t.coerce) try {
|
|
879
|
+
r.value = String(r.value);
|
|
880
|
+
} catch {
|
|
881
|
+
}
|
|
882
|
+
return typeof r.value == "string" || r.issues.push({
|
|
883
|
+
expected: "string",
|
|
884
|
+
code: "invalid_type",
|
|
885
|
+
input: r.value,
|
|
886
|
+
inst: e
|
|
887
|
+
}), r;
|
|
888
|
+
};
|
|
889
|
+
}), _ = /* @__PURE__ */ u("$ZodStringFormat", (e, t) => {
|
|
890
|
+
me.init(e, t), Ae.init(e, t);
|
|
891
|
+
}), ln = /* @__PURE__ */ u("$ZodGUID", (e, t) => {
|
|
892
|
+
t.pattern ?? (t.pattern = Tr), _.init(e, t);
|
|
893
|
+
}), dn = /* @__PURE__ */ u("$ZodUUID", (e, t) => {
|
|
894
|
+
if (t.version) {
|
|
895
|
+
const r = {
|
|
896
|
+
v1: 1,
|
|
897
|
+
v2: 2,
|
|
898
|
+
v3: 3,
|
|
899
|
+
v4: 4,
|
|
900
|
+
v5: 5,
|
|
901
|
+
v6: 6,
|
|
902
|
+
v7: 7,
|
|
903
|
+
v8: 8
|
|
904
|
+
}[t.version];
|
|
905
|
+
if (r === void 0) throw new Error(`Invalid UUID version: "${t.version}"`);
|
|
906
|
+
t.pattern ?? (t.pattern = je(r));
|
|
907
|
+
} else t.pattern ?? (t.pattern = je());
|
|
908
|
+
_.init(e, t);
|
|
909
|
+
}), fn = /* @__PURE__ */ u("$ZodEmail", (e, t) => {
|
|
910
|
+
t.pattern ?? (t.pattern = Ar), _.init(e, t);
|
|
911
|
+
}), hn = /* @__PURE__ */ u("$ZodURL", (e, t) => {
|
|
912
|
+
_.init(e, t), e._zod.check = (r) => {
|
|
913
|
+
try {
|
|
914
|
+
const n = r.value.trim(), o = new URL(n);
|
|
915
|
+
t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || r.issues.push({
|
|
916
|
+
code: "invalid_format",
|
|
917
|
+
format: "url",
|
|
918
|
+
note: "Invalid hostname",
|
|
919
|
+
pattern: t.hostname.source,
|
|
920
|
+
input: r.value,
|
|
921
|
+
inst: e,
|
|
922
|
+
continue: !t.abort
|
|
923
|
+
})), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || r.issues.push({
|
|
924
|
+
code: "invalid_format",
|
|
925
|
+
format: "url",
|
|
926
|
+
note: "Invalid protocol",
|
|
927
|
+
pattern: t.protocol.source,
|
|
928
|
+
input: r.value,
|
|
929
|
+
inst: e,
|
|
930
|
+
continue: !t.abort
|
|
931
|
+
})), t.normalize ? r.value = o.href : r.value = n;
|
|
932
|
+
return;
|
|
933
|
+
} catch {
|
|
934
|
+
r.issues.push({
|
|
935
|
+
code: "invalid_format",
|
|
936
|
+
format: "url",
|
|
937
|
+
input: r.value,
|
|
938
|
+
inst: e,
|
|
939
|
+
continue: !t.abort
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}), pn = /* @__PURE__ */ u("$ZodEmoji", (e, t) => {
|
|
944
|
+
t.pattern ?? (t.pattern = Pr()), _.init(e, t);
|
|
945
|
+
}), mn = /* @__PURE__ */ u("$ZodNanoID", (e, t) => {
|
|
946
|
+
t.pattern ?? (t.pattern = Ir), _.init(e, t);
|
|
947
|
+
}), gn = /* @__PURE__ */ u("$ZodCUID", (e, t) => {
|
|
948
|
+
t.pattern ?? (t.pattern = kr), _.init(e, t);
|
|
949
|
+
}), vn = /* @__PURE__ */ u("$ZodCUID2", (e, t) => {
|
|
950
|
+
t.pattern ?? (t.pattern = Er), _.init(e, t);
|
|
951
|
+
}), bn = /* @__PURE__ */ u("$ZodULID", (e, t) => {
|
|
952
|
+
t.pattern ?? (t.pattern = $r), _.init(e, t);
|
|
953
|
+
}), _n = /* @__PURE__ */ u("$ZodXID", (e, t) => {
|
|
954
|
+
t.pattern ?? (t.pattern = Sr), _.init(e, t);
|
|
955
|
+
}), wn = /* @__PURE__ */ u("$ZodKSUID", (e, t) => {
|
|
956
|
+
t.pattern ?? (t.pattern = Or), _.init(e, t);
|
|
957
|
+
}), yn = /* @__PURE__ */ u("$ZodISODateTime", (e, t) => {
|
|
958
|
+
t.pattern ?? (t.pattern = Fr(t)), _.init(e, t);
|
|
959
|
+
}), zn = /* @__PURE__ */ u("$ZodISODate", (e, t) => {
|
|
960
|
+
t.pattern ?? (t.pattern = Lr), _.init(e, t);
|
|
961
|
+
}), kn = /* @__PURE__ */ u("$ZodISOTime", (e, t) => {
|
|
962
|
+
t.pattern ?? (t.pattern = Ur(t)), _.init(e, t);
|
|
963
|
+
}), En = /* @__PURE__ */ u("$ZodISODuration", (e, t) => {
|
|
964
|
+
t.pattern ?? (t.pattern = Zr), _.init(e, t);
|
|
965
|
+
}), $n = /* @__PURE__ */ u("$ZodIPv4", (e, t) => {
|
|
966
|
+
t.pattern ?? (t.pattern = Nr), _.init(e, t), e._zod.bag.format = "ipv4";
|
|
967
|
+
}), Sn = /* @__PURE__ */ u("$ZodIPv6", (e, t) => {
|
|
968
|
+
t.pattern ?? (t.pattern = Rr), _.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (r) => {
|
|
969
|
+
try {
|
|
970
|
+
new URL(`http://[${r.value}]`);
|
|
971
|
+
} catch {
|
|
972
|
+
r.issues.push({
|
|
973
|
+
code: "invalid_format",
|
|
974
|
+
format: "ipv6",
|
|
975
|
+
input: r.value,
|
|
976
|
+
inst: e,
|
|
977
|
+
continue: !t.abort
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
}), On = /* @__PURE__ */ u("$ZodCIDRv4", (e, t) => {
|
|
982
|
+
t.pattern ?? (t.pattern = xr), _.init(e, t);
|
|
983
|
+
}), In = /* @__PURE__ */ u("$ZodCIDRv6", (e, t) => {
|
|
984
|
+
t.pattern ?? (t.pattern = jr), _.init(e, t), e._zod.check = (r) => {
|
|
985
|
+
const n = r.value.split("/");
|
|
986
|
+
try {
|
|
987
|
+
if (n.length !== 2) throw new Error();
|
|
988
|
+
const [o, a] = n;
|
|
989
|
+
if (!a) throw new Error();
|
|
990
|
+
const i = Number(a);
|
|
991
|
+
if (`${i}` !== a) throw new Error();
|
|
992
|
+
if (i < 0 || i > 128) throw new Error();
|
|
993
|
+
new URL(`http://[${o}]`);
|
|
994
|
+
} catch {
|
|
995
|
+
r.issues.push({
|
|
996
|
+
code: "invalid_format",
|
|
997
|
+
format: "cidrv6",
|
|
998
|
+
input: r.value,
|
|
999
|
+
inst: e,
|
|
1000
|
+
continue: !t.abort
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
});
|
|
1005
|
+
function St(e) {
|
|
1006
|
+
if (e === "") return !0;
|
|
1007
|
+
if (e.length % 4 !== 0) return !1;
|
|
1008
|
+
try {
|
|
1009
|
+
return atob(e), !0;
|
|
1010
|
+
} catch {
|
|
1011
|
+
return !1;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
var Zn = /* @__PURE__ */ u("$ZodBase64", (e, t) => {
|
|
1015
|
+
t.pattern ?? (t.pattern = Mr), _.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (r) => {
|
|
1016
|
+
St(r.value) || r.issues.push({
|
|
1017
|
+
code: "invalid_format",
|
|
1018
|
+
format: "base64",
|
|
1019
|
+
input: r.value,
|
|
1020
|
+
inst: e,
|
|
1021
|
+
continue: !t.abort
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
});
|
|
1025
|
+
function Tn(e) {
|
|
1026
|
+
if (!wt.test(e)) return !1;
|
|
1027
|
+
const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/");
|
|
1028
|
+
return St(t.padEnd(Math.ceil(t.length / 4) * 4, "="));
|
|
1029
|
+
}
|
|
1030
|
+
var An = /* @__PURE__ */ u("$ZodBase64URL", (e, t) => {
|
|
1031
|
+
t.pattern ?? (t.pattern = wt), _.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (r) => {
|
|
1032
|
+
Tn(r.value) || r.issues.push({
|
|
1033
|
+
code: "invalid_format",
|
|
1034
|
+
format: "base64url",
|
|
1035
|
+
input: r.value,
|
|
1036
|
+
inst: e,
|
|
1037
|
+
continue: !t.abort
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
}), Cn = /* @__PURE__ */ u("$ZodE164", (e, t) => {
|
|
1041
|
+
t.pattern ?? (t.pattern = Dr), _.init(e, t);
|
|
1042
|
+
});
|
|
1043
|
+
function Pn(e, t = null) {
|
|
1044
|
+
try {
|
|
1045
|
+
const r = e.split(".");
|
|
1046
|
+
if (r.length !== 3) return !1;
|
|
1047
|
+
const [n] = r;
|
|
1048
|
+
if (!n) return !1;
|
|
1049
|
+
const o = JSON.parse(atob(n));
|
|
1050
|
+
return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
|
|
1051
|
+
} catch {
|
|
1052
|
+
return !1;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
var Nn = /* @__PURE__ */ u("$ZodJWT", (e, t) => {
|
|
1056
|
+
_.init(e, t), e._zod.check = (r) => {
|
|
1057
|
+
Pn(r.value, t.alg) || r.issues.push({
|
|
1058
|
+
code: "invalid_format",
|
|
1059
|
+
format: "jwt",
|
|
1060
|
+
input: r.value,
|
|
1061
|
+
inst: e,
|
|
1062
|
+
continue: !t.abort
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
}), Ot = /* @__PURE__ */ u("$ZodNumber", (e, t) => {
|
|
1066
|
+
y.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? Jr, e._zod.parse = (r, n) => {
|
|
1067
|
+
if (t.coerce) try {
|
|
1068
|
+
r.value = Number(r.value);
|
|
1069
|
+
} catch {
|
|
1070
|
+
}
|
|
1071
|
+
const o = r.value;
|
|
1072
|
+
if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o)) return r;
|
|
1073
|
+
const a = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
|
|
1074
|
+
return r.issues.push({
|
|
1075
|
+
expected: "number",
|
|
1076
|
+
code: "invalid_type",
|
|
1077
|
+
input: o,
|
|
1078
|
+
inst: e,
|
|
1079
|
+
...a ? { received: a } : {}
|
|
1080
|
+
}), r;
|
|
1081
|
+
};
|
|
1082
|
+
}), Rn = /* @__PURE__ */ u("$ZodNumberFormat", (e, t) => {
|
|
1083
|
+
Kr.init(e, t), Ot.init(e, t);
|
|
1084
|
+
}), xn = /* @__PURE__ */ u("$ZodBoolean", (e, t) => {
|
|
1085
|
+
y.init(e, t), e._zod.pattern = Wr, e._zod.parse = (r, n) => {
|
|
1086
|
+
if (t.coerce) try {
|
|
1087
|
+
r.value = !!r.value;
|
|
1088
|
+
} catch {
|
|
1089
|
+
}
|
|
1090
|
+
const o = r.value;
|
|
1091
|
+
return typeof o == "boolean" || r.issues.push({
|
|
1092
|
+
expected: "boolean",
|
|
1093
|
+
code: "invalid_type",
|
|
1094
|
+
input: o,
|
|
1095
|
+
inst: e
|
|
1096
|
+
}), r;
|
|
1097
|
+
};
|
|
1098
|
+
}), jn = /* @__PURE__ */ u("$ZodUnknown", (e, t) => {
|
|
1099
|
+
y.init(e, t), e._zod.parse = (r) => r;
|
|
1100
|
+
}), Mn = /* @__PURE__ */ u("$ZodNever", (e, t) => {
|
|
1101
|
+
y.init(e, t), e._zod.parse = (r, n) => (r.issues.push({
|
|
1102
|
+
expected: "never",
|
|
1103
|
+
code: "invalid_type",
|
|
1104
|
+
input: r.value,
|
|
1105
|
+
inst: e
|
|
1106
|
+
}), r);
|
|
1107
|
+
});
|
|
1108
|
+
function Me(e, t, r) {
|
|
1109
|
+
e.issues.length && t.issues.push(...gt(r, e.issues)), t.value[r] = e.value;
|
|
1110
|
+
}
|
|
1111
|
+
var Dn = /* @__PURE__ */ u("$ZodArray", (e, t) => {
|
|
1112
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1113
|
+
const o = r.value;
|
|
1114
|
+
if (!Array.isArray(o))
|
|
1115
|
+
return r.issues.push({
|
|
1116
|
+
expected: "array",
|
|
1117
|
+
code: "invalid_type",
|
|
1118
|
+
input: o,
|
|
1119
|
+
inst: e
|
|
1120
|
+
}), r;
|
|
1121
|
+
r.value = Array(o.length);
|
|
1122
|
+
const a = [];
|
|
1123
|
+
for (let i = 0; i < o.length; i++) {
|
|
1124
|
+
const s = o[i], c = t.element._zod.run({
|
|
1125
|
+
value: s,
|
|
1126
|
+
issues: []
|
|
1127
|
+
}, n);
|
|
1128
|
+
c instanceof Promise ? a.push(c.then((l) => Me(l, r, i))) : Me(c, r, i);
|
|
1129
|
+
}
|
|
1130
|
+
return a.length ? Promise.all(a).then(() => r) : r;
|
|
1131
|
+
};
|
|
1132
|
+
});
|
|
1133
|
+
function se(e, t, r, n, o) {
|
|
1134
|
+
if (e.issues.length) {
|
|
1135
|
+
if (o && !(r in n)) return;
|
|
1136
|
+
t.issues.push(...gt(r, e.issues));
|
|
1137
|
+
}
|
|
1138
|
+
e.value === void 0 ? r in n && (t.value[r] = void 0) : t.value[r] = e.value;
|
|
1139
|
+
}
|
|
1140
|
+
function It(e) {
|
|
1141
|
+
const t = Object.keys(e.shape);
|
|
1142
|
+
for (const n of t) if (!e.shape?.[n]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${n}": expected a Zod schema`);
|
|
1143
|
+
const r = rr(e.shape);
|
|
1144
|
+
return {
|
|
1145
|
+
...e,
|
|
1146
|
+
keys: t,
|
|
1147
|
+
keySet: new Set(t),
|
|
1148
|
+
numKeys: t.length,
|
|
1149
|
+
optionalKeys: new Set(r)
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function Zt(e, t, r, n, o, a) {
|
|
1153
|
+
const i = [], s = o.keySet, c = o.catchall._zod, l = c.def.type, d = c.optout === "optional";
|
|
1154
|
+
for (const p in t) {
|
|
1155
|
+
if (s.has(p)) continue;
|
|
1156
|
+
if (l === "never") {
|
|
1157
|
+
i.push(p);
|
|
1158
|
+
continue;
|
|
1159
|
+
}
|
|
1160
|
+
const h = c.run({
|
|
1161
|
+
value: t[p],
|
|
1162
|
+
issues: []
|
|
1163
|
+
}, n);
|
|
1164
|
+
h instanceof Promise ? e.push(h.then((m) => se(m, r, p, t, d))) : se(h, r, p, t, d);
|
|
1165
|
+
}
|
|
1166
|
+
return i.length && r.issues.push({
|
|
1167
|
+
code: "unrecognized_keys",
|
|
1168
|
+
keys: i,
|
|
1169
|
+
input: t,
|
|
1170
|
+
inst: a
|
|
1171
|
+
}), e.length ? Promise.all(e).then(() => r) : r;
|
|
1172
|
+
}
|
|
1173
|
+
var Ln = /* @__PURE__ */ u("$ZodObject", (e, t) => {
|
|
1174
|
+
if (y.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
|
|
1175
|
+
const i = t.shape;
|
|
1176
|
+
Object.defineProperty(t, "shape", { get: () => {
|
|
1177
|
+
const s = { ...i };
|
|
1178
|
+
return Object.defineProperty(t, "shape", { value: s }), s;
|
|
1179
|
+
} });
|
|
1180
|
+
}
|
|
1181
|
+
const r = $e(() => It(t));
|
|
1182
|
+
g(e._zod, "propValues", () => {
|
|
1183
|
+
const i = t.shape, s = {};
|
|
1184
|
+
for (const c in i) {
|
|
1185
|
+
const l = i[c]._zod;
|
|
1186
|
+
if (l.values) {
|
|
1187
|
+
s[c] ?? (s[c] = /* @__PURE__ */ new Set());
|
|
1188
|
+
for (const d of l.values) s[c].add(d);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
return s;
|
|
1192
|
+
});
|
|
1193
|
+
const n = ae, o = t.catchall;
|
|
1194
|
+
let a;
|
|
1195
|
+
e._zod.parse = (i, s) => {
|
|
1196
|
+
a ?? (a = r.value);
|
|
1197
|
+
const c = i.value;
|
|
1198
|
+
if (!n(c))
|
|
1199
|
+
return i.issues.push({
|
|
1200
|
+
expected: "object",
|
|
1201
|
+
code: "invalid_type",
|
|
1202
|
+
input: c,
|
|
1203
|
+
inst: e
|
|
1204
|
+
}), i;
|
|
1205
|
+
i.value = {};
|
|
1206
|
+
const l = [], d = a.shape;
|
|
1207
|
+
for (const p of a.keys) {
|
|
1208
|
+
const h = d[p], m = h._zod.optout === "optional", v = h._zod.run({
|
|
1209
|
+
value: c[p],
|
|
1210
|
+
issues: []
|
|
1211
|
+
}, s);
|
|
1212
|
+
v instanceof Promise ? l.push(v.then((C) => se(C, i, p, c, m))) : se(v, i, p, c, m);
|
|
1213
|
+
}
|
|
1214
|
+
return o ? Zt(l, c, i, s, r.value, e) : l.length ? Promise.all(l).then(() => i) : i;
|
|
1215
|
+
};
|
|
1216
|
+
}), Un = /* @__PURE__ */ u("$ZodObjectJIT", (e, t) => {
|
|
1217
|
+
Ln.init(e, t);
|
|
1218
|
+
const r = e._zod.parse, n = $e(() => It(t)), o = (h) => {
|
|
1219
|
+
const m = new cn([
|
|
1220
|
+
"shape",
|
|
1221
|
+
"payload",
|
|
1222
|
+
"ctx"
|
|
1223
|
+
]), v = n.value, C = (A) => {
|
|
1224
|
+
const $ = xe(A);
|
|
1225
|
+
return `shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`;
|
|
1226
|
+
};
|
|
1227
|
+
m.write("const input = payload.value;");
|
|
1228
|
+
const B = /* @__PURE__ */ Object.create(null);
|
|
1229
|
+
let P = 0;
|
|
1230
|
+
for (const A of v.keys) B[A] = `key_${P++}`;
|
|
1231
|
+
m.write("const newResult = {};");
|
|
1232
|
+
for (const A of v.keys) {
|
|
1233
|
+
const $ = B[A], Z = xe(A), Wt = h[A]?._zod?.optout === "optional";
|
|
1234
|
+
m.write(`const ${$} = ${C(A)};`), Wt ? m.write(`
|
|
1235
|
+
if (${$}.issues.length) {
|
|
1236
|
+
if (${Z} in input) {
|
|
1237
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
1238
|
+
...iss,
|
|
1239
|
+
path: iss.path ? [${Z}, ...iss.path] : [${Z}]
|
|
1240
|
+
})));
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
if (${$}.value === undefined) {
|
|
1245
|
+
if (${Z} in input) {
|
|
1246
|
+
newResult[${Z}] = undefined;
|
|
1247
|
+
}
|
|
1248
|
+
} else {
|
|
1249
|
+
newResult[${Z}] = ${$}.value;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
`) : m.write(`
|
|
1253
|
+
if (${$}.issues.length) {
|
|
1254
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
1255
|
+
...iss,
|
|
1256
|
+
path: iss.path ? [${Z}, ...iss.path] : [${Z}]
|
|
1257
|
+
})));
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if (${$}.value === undefined) {
|
|
1261
|
+
if (${Z} in input) {
|
|
1262
|
+
newResult[${Z}] = undefined;
|
|
1263
|
+
}
|
|
1264
|
+
} else {
|
|
1265
|
+
newResult[${Z}] = ${$}.value;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
`);
|
|
1269
|
+
}
|
|
1270
|
+
m.write("payload.value = newResult;"), m.write("return payload;");
|
|
1271
|
+
const Jt = m.compile();
|
|
1272
|
+
return (A, $) => Jt(h, A, $);
|
|
1273
|
+
};
|
|
1274
|
+
let a;
|
|
1275
|
+
const i = ae, s = !we.jitless, l = s && er.value, d = t.catchall;
|
|
1276
|
+
let p;
|
|
1277
|
+
e._zod.parse = (h, m) => {
|
|
1278
|
+
p ?? (p = n.value);
|
|
1279
|
+
const v = h.value;
|
|
1280
|
+
return i(v) ? s && l && m?.async === !1 && m.jitless !== !0 ? (a || (a = o(t.shape)), h = a(h, m), d ? Zt([], v, h, m, p, e) : h) : r(h, m) : (h.issues.push({
|
|
1281
|
+
expected: "object",
|
|
1282
|
+
code: "invalid_type",
|
|
1283
|
+
input: v,
|
|
1284
|
+
inst: e
|
|
1285
|
+
}), h);
|
|
1286
|
+
};
|
|
1287
|
+
});
|
|
1288
|
+
function De(e, t, r, n) {
|
|
1289
|
+
for (const a of e) if (a.issues.length === 0)
|
|
1290
|
+
return t.value = a.value, t;
|
|
1291
|
+
const o = e.filter((a) => !V(a));
|
|
1292
|
+
return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
|
|
1293
|
+
code: "invalid_union",
|
|
1294
|
+
input: t.value,
|
|
1295
|
+
inst: r,
|
|
1296
|
+
errors: e.map((a) => a.issues.map((i) => L(i, n, D())))
|
|
1297
|
+
}), t);
|
|
1298
|
+
}
|
|
1299
|
+
var Fn = /* @__PURE__ */ u("$ZodUnion", (e, t) => {
|
|
1300
|
+
y.init(e, t), g(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), g(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), g(e._zod, "values", () => {
|
|
1301
|
+
if (t.options.every((o) => o._zod.values)) return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
|
|
1302
|
+
}), g(e._zod, "pattern", () => {
|
|
1303
|
+
if (t.options.every((o) => o._zod.pattern)) {
|
|
1304
|
+
const o = t.options.map((a) => a._zod.pattern);
|
|
1305
|
+
return new RegExp(`^(${o.map((a) => Oe(a.source)).join("|")})$`);
|
|
1306
|
+
}
|
|
1307
|
+
});
|
|
1308
|
+
const r = t.options.length === 1, n = t.options[0]._zod.run;
|
|
1309
|
+
e._zod.parse = (o, a) => {
|
|
1310
|
+
if (r) return n(o, a);
|
|
1311
|
+
let i = !1;
|
|
1312
|
+
const s = [];
|
|
1313
|
+
for (const c of t.options) {
|
|
1314
|
+
const l = c._zod.run({
|
|
1315
|
+
value: o.value,
|
|
1316
|
+
issues: []
|
|
1317
|
+
}, a);
|
|
1318
|
+
if (l instanceof Promise)
|
|
1319
|
+
s.push(l), i = !0;
|
|
1320
|
+
else {
|
|
1321
|
+
if (l.issues.length === 0) return l;
|
|
1322
|
+
s.push(l);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return i ? Promise.all(s).then((c) => De(c, o, e, a)) : De(s, o, e, a);
|
|
1326
|
+
};
|
|
1327
|
+
}), Vn = /* @__PURE__ */ u("$ZodIntersection", (e, t) => {
|
|
1328
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1329
|
+
const o = r.value, a = t.left._zod.run({
|
|
1330
|
+
value: o,
|
|
1331
|
+
issues: []
|
|
1332
|
+
}, n), i = t.right._zod.run({
|
|
1333
|
+
value: o,
|
|
1334
|
+
issues: []
|
|
1335
|
+
}, n);
|
|
1336
|
+
return a instanceof Promise || i instanceof Promise ? Promise.all([a, i]).then(([s, c]) => Le(r, s, c)) : Le(r, a, i);
|
|
1337
|
+
};
|
|
1338
|
+
});
|
|
1339
|
+
function ze(e, t) {
|
|
1340
|
+
if (e === t) return {
|
|
1341
|
+
valid: !0,
|
|
1342
|
+
data: e
|
|
1343
|
+
};
|
|
1344
|
+
if (e instanceof Date && t instanceof Date && +e == +t) return {
|
|
1345
|
+
valid: !0,
|
|
1346
|
+
data: e
|
|
1347
|
+
};
|
|
1348
|
+
if (K(e) && K(t)) {
|
|
1349
|
+
const r = Object.keys(t), n = Object.keys(e).filter((a) => r.indexOf(a) !== -1), o = {
|
|
1350
|
+
...e,
|
|
1351
|
+
...t
|
|
1352
|
+
};
|
|
1353
|
+
for (const a of n) {
|
|
1354
|
+
const i = ze(e[a], t[a]);
|
|
1355
|
+
if (!i.valid) return {
|
|
1356
|
+
valid: !1,
|
|
1357
|
+
mergeErrorPath: [a, ...i.mergeErrorPath]
|
|
1358
|
+
};
|
|
1359
|
+
o[a] = i.data;
|
|
1360
|
+
}
|
|
1361
|
+
return {
|
|
1362
|
+
valid: !0,
|
|
1363
|
+
data: o
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
1367
|
+
if (e.length !== t.length) return {
|
|
1368
|
+
valid: !1,
|
|
1369
|
+
mergeErrorPath: []
|
|
1370
|
+
};
|
|
1371
|
+
const r = [];
|
|
1372
|
+
for (let n = 0; n < e.length; n++) {
|
|
1373
|
+
const o = e[n], a = t[n], i = ze(o, a);
|
|
1374
|
+
if (!i.valid) return {
|
|
1375
|
+
valid: !1,
|
|
1376
|
+
mergeErrorPath: [n, ...i.mergeErrorPath]
|
|
1377
|
+
};
|
|
1378
|
+
r.push(i.data);
|
|
1379
|
+
}
|
|
1380
|
+
return {
|
|
1381
|
+
valid: !0,
|
|
1382
|
+
data: r
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
return {
|
|
1386
|
+
valid: !1,
|
|
1387
|
+
mergeErrorPath: []
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
function Le(e, t, r) {
|
|
1391
|
+
const n = /* @__PURE__ */ new Map();
|
|
1392
|
+
let o;
|
|
1393
|
+
for (const s of t.issues) if (s.code === "unrecognized_keys") {
|
|
1394
|
+
o ?? (o = s);
|
|
1395
|
+
for (const c of s.keys)
|
|
1396
|
+
n.has(c) || n.set(c, {}), n.get(c).l = !0;
|
|
1397
|
+
} else e.issues.push(s);
|
|
1398
|
+
for (const s of r.issues) if (s.code === "unrecognized_keys") for (const c of s.keys)
|
|
1399
|
+
n.has(c) || n.set(c, {}), n.get(c).r = !0;
|
|
1400
|
+
else e.issues.push(s);
|
|
1401
|
+
const a = [...n].filter(([, s]) => s.l && s.r).map(([s]) => s);
|
|
1402
|
+
if (a.length && o && e.issues.push({
|
|
1403
|
+
...o,
|
|
1404
|
+
keys: a
|
|
1405
|
+
}), V(e)) return e;
|
|
1406
|
+
const i = ze(t.value, r.value);
|
|
1407
|
+
if (!i.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);
|
|
1408
|
+
return e.value = i.data, e;
|
|
1409
|
+
}
|
|
1410
|
+
var qn = /* @__PURE__ */ u("$ZodEnum", (e, t) => {
|
|
1411
|
+
y.init(e, t);
|
|
1412
|
+
const r = ht(t.entries), n = new Set(r);
|
|
1413
|
+
e._zod.values = n, e._zod.pattern = new RegExp(`^(${r.filter((o) => tr.has(typeof o)).map((o) => typeof o == "string" ? fe(o) : o.toString()).join("|")})$`), e._zod.parse = (o, a) => {
|
|
1414
|
+
const i = o.value;
|
|
1415
|
+
return n.has(i) || o.issues.push({
|
|
1416
|
+
code: "invalid_value",
|
|
1417
|
+
values: r,
|
|
1418
|
+
input: i,
|
|
1419
|
+
inst: e
|
|
1420
|
+
}), o;
|
|
1421
|
+
};
|
|
1422
|
+
}), Jn = /* @__PURE__ */ u("$ZodTransform", (e, t) => {
|
|
1423
|
+
y.init(e, t), e._zod.parse = (r, n) => {
|
|
1424
|
+
if (n.direction === "backward") throw new ft(e.constructor.name);
|
|
1425
|
+
const o = t.transform(r.value, r);
|
|
1426
|
+
if (n.async) return (o instanceof Promise ? o : Promise.resolve(o)).then((a) => (r.value = a, r));
|
|
1427
|
+
if (o instanceof Promise) throw new q();
|
|
1428
|
+
return r.value = o, r;
|
|
1429
|
+
};
|
|
1430
|
+
});
|
|
1431
|
+
function Ue(e, t) {
|
|
1432
|
+
return e.issues.length && t === void 0 ? {
|
|
1433
|
+
issues: [],
|
|
1434
|
+
value: void 0
|
|
1435
|
+
} : e;
|
|
1436
|
+
}
|
|
1437
|
+
var Tt = /* @__PURE__ */ u("$ZodOptional", (e, t) => {
|
|
1438
|
+
y.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), g(e._zod, "pattern", () => {
|
|
1439
|
+
const r = t.innerType._zod.pattern;
|
|
1440
|
+
return r ? new RegExp(`^(${Oe(r.source)})?$`) : void 0;
|
|
1441
|
+
}), e._zod.parse = (r, n) => {
|
|
1442
|
+
if (t.innerType._zod.optin === "optional") {
|
|
1443
|
+
const o = t.innerType._zod.run(r, n);
|
|
1444
|
+
return o instanceof Promise ? o.then((a) => Ue(a, r.value)) : Ue(o, r.value);
|
|
1445
|
+
}
|
|
1446
|
+
return r.value === void 0 ? r : t.innerType._zod.run(r, n);
|
|
1447
|
+
};
|
|
1448
|
+
}), Wn = /* @__PURE__ */ u("$ZodExactOptional", (e, t) => {
|
|
1449
|
+
Tt.init(e, t), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (r, n) => t.innerType._zod.run(r, n);
|
|
1450
|
+
}), Bn = /* @__PURE__ */ u("$ZodNullable", (e, t) => {
|
|
1451
|
+
y.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "pattern", () => {
|
|
1452
|
+
const r = t.innerType._zod.pattern;
|
|
1453
|
+
return r ? new RegExp(`^(${Oe(r.source)}|null)$`) : void 0;
|
|
1454
|
+
}), g(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (r, n) => r.value === null ? r : t.innerType._zod.run(r, n);
|
|
1455
|
+
}), Hn = /* @__PURE__ */ u("$ZodDefault", (e, t) => {
|
|
1456
|
+
y.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
1457
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1458
|
+
if (r.value === void 0)
|
|
1459
|
+
return r.value = t.defaultValue, r;
|
|
1460
|
+
const o = t.innerType._zod.run(r, n);
|
|
1461
|
+
return o instanceof Promise ? o.then((a) => Fe(a, t)) : Fe(o, t);
|
|
1462
|
+
};
|
|
1463
|
+
});
|
|
1464
|
+
function Fe(e, t) {
|
|
1465
|
+
return e.value === void 0 && (e.value = t.defaultValue), e;
|
|
1466
|
+
}
|
|
1467
|
+
var Gn = /* @__PURE__ */ u("$ZodPrefault", (e, t) => {
|
|
1468
|
+
y.init(e, t), e._zod.optin = "optional", g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => (n.direction === "backward" || r.value === void 0 && (r.value = t.defaultValue), t.innerType._zod.run(r, n));
|
|
1469
|
+
}), Kn = /* @__PURE__ */ u("$ZodNonOptional", (e, t) => {
|
|
1470
|
+
y.init(e, t), g(e._zod, "values", () => {
|
|
1471
|
+
const r = t.innerType._zod.values;
|
|
1472
|
+
return r ? new Set([...r].filter((n) => n !== void 0)) : void 0;
|
|
1473
|
+
}), e._zod.parse = (r, n) => {
|
|
1474
|
+
const o = t.innerType._zod.run(r, n);
|
|
1475
|
+
return o instanceof Promise ? o.then((a) => Ve(a, e)) : Ve(o, e);
|
|
1476
|
+
};
|
|
1477
|
+
});
|
|
1478
|
+
function Ve(e, t) {
|
|
1479
|
+
return !e.issues.length && e.value === void 0 && e.issues.push({
|
|
1480
|
+
code: "invalid_type",
|
|
1481
|
+
expected: "nonoptional",
|
|
1482
|
+
input: e.value,
|
|
1483
|
+
inst: t
|
|
1484
|
+
}), e;
|
|
1485
|
+
}
|
|
1486
|
+
var Yn = /* @__PURE__ */ u("$ZodCatch", (e, t) => {
|
|
1487
|
+
y.init(e, t), g(e._zod, "optin", () => t.innerType._zod.optin), g(e._zod, "optout", () => t.innerType._zod.optout), g(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
1488
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1489
|
+
const o = t.innerType._zod.run(r, n);
|
|
1490
|
+
return o instanceof Promise ? o.then((a) => (r.value = a.value, a.issues.length && (r.value = t.catchValue({
|
|
1491
|
+
...r,
|
|
1492
|
+
error: { issues: a.issues.map((i) => L(i, n, D())) },
|
|
1493
|
+
input: r.value
|
|
1494
|
+
}), r.issues = []), r)) : (r.value = o.value, o.issues.length && (r.value = t.catchValue({
|
|
1495
|
+
...r,
|
|
1496
|
+
error: { issues: o.issues.map((a) => L(a, n, D())) },
|
|
1497
|
+
input: r.value
|
|
1498
|
+
}), r.issues = []), r);
|
|
1499
|
+
};
|
|
1500
|
+
}), Qn = /* @__PURE__ */ u("$ZodPipe", (e, t) => {
|
|
1501
|
+
y.init(e, t), g(e._zod, "values", () => t.in._zod.values), g(e._zod, "optin", () => t.in._zod.optin), g(e._zod, "optout", () => t.out._zod.optout), g(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (r, n) => {
|
|
1502
|
+
if (n.direction === "backward") {
|
|
1503
|
+
const a = t.out._zod.run(r, n);
|
|
1504
|
+
return a instanceof Promise ? a.then((i) => X(i, t.in, n)) : X(a, t.in, n);
|
|
1505
|
+
}
|
|
1506
|
+
const o = t.in._zod.run(r, n);
|
|
1507
|
+
return o instanceof Promise ? o.then((a) => X(a, t.out, n)) : X(o, t.out, n);
|
|
1508
|
+
};
|
|
1509
|
+
});
|
|
1510
|
+
function X(e, t, r) {
|
|
1511
|
+
return e.issues.length ? (e.aborted = !0, e) : t._zod.run({
|
|
1512
|
+
value: e.value,
|
|
1513
|
+
issues: e.issues
|
|
1514
|
+
}, r);
|
|
1515
|
+
}
|
|
1516
|
+
var Xn = /* @__PURE__ */ u("$ZodReadonly", (e, t) => {
|
|
1517
|
+
y.init(e, t), g(e._zod, "propValues", () => t.innerType._zod.propValues), g(e._zod, "values", () => t.innerType._zod.values), g(e._zod, "optin", () => t.innerType?._zod?.optin), g(e._zod, "optout", () => t.innerType?._zod?.optout), e._zod.parse = (r, n) => {
|
|
1518
|
+
if (n.direction === "backward") return t.innerType._zod.run(r, n);
|
|
1519
|
+
const o = t.innerType._zod.run(r, n);
|
|
1520
|
+
return o instanceof Promise ? o.then(qe) : qe(o);
|
|
1521
|
+
};
|
|
1522
|
+
});
|
|
1523
|
+
function qe(e) {
|
|
1524
|
+
return e.value = Object.freeze(e.value), e;
|
|
1525
|
+
}
|
|
1526
|
+
var eo = /* @__PURE__ */ u("$ZodCustom", (e, t) => {
|
|
1527
|
+
S.init(e, t), y.init(e, t), e._zod.parse = (r, n) => r, e._zod.check = (r) => {
|
|
1528
|
+
const n = r.value, o = t.fn(n);
|
|
1529
|
+
if (o instanceof Promise) return o.then((a) => Je(a, r, n, e));
|
|
1530
|
+
Je(o, r, n, e);
|
|
1531
|
+
};
|
|
1532
|
+
});
|
|
1533
|
+
function Je(e, t, r, n) {
|
|
1534
|
+
if (!e) {
|
|
1535
|
+
const o = {
|
|
1536
|
+
code: "custom",
|
|
1537
|
+
input: r,
|
|
1538
|
+
inst: n,
|
|
1539
|
+
path: [...n._zod.def.path ?? []],
|
|
1540
|
+
continue: !n._zod.def.abort
|
|
1541
|
+
};
|
|
1542
|
+
n._zod.def.params && (o.params = n._zod.def.params), t.issues.push(Y(o));
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
var We, to = class {
|
|
1546
|
+
constructor() {
|
|
1547
|
+
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
1548
|
+
}
|
|
1549
|
+
add(e, ...t) {
|
|
1550
|
+
const r = t[0];
|
|
1551
|
+
return this._map.set(e, r), r && typeof r == "object" && "id" in r && this._idmap.set(r.id, e), this;
|
|
1552
|
+
}
|
|
1553
|
+
clear() {
|
|
1554
|
+
return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
1555
|
+
}
|
|
1556
|
+
remove(e) {
|
|
1557
|
+
const t = this._map.get(e);
|
|
1558
|
+
return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
|
|
1559
|
+
}
|
|
1560
|
+
get(e) {
|
|
1561
|
+
const t = e._zod.parent;
|
|
1562
|
+
if (t) {
|
|
1563
|
+
const r = { ...this.get(t) ?? {} };
|
|
1564
|
+
delete r.id;
|
|
1565
|
+
const n = {
|
|
1566
|
+
...r,
|
|
1567
|
+
...this._map.get(e)
|
|
1568
|
+
};
|
|
1569
|
+
return Object.keys(n).length ? n : void 0;
|
|
1570
|
+
}
|
|
1571
|
+
return this._map.get(e);
|
|
1572
|
+
}
|
|
1573
|
+
has(e) {
|
|
1574
|
+
return this._map.has(e);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
function ro() {
|
|
1578
|
+
return new to();
|
|
1579
|
+
}
|
|
1580
|
+
(We = globalThis).__zod_globalRegistry ?? (We.__zod_globalRegistry = ro());
|
|
1581
|
+
var G = globalThis.__zod_globalRegistry;
|
|
1582
|
+
// @__NO_SIDE_EFFECTS__
|
|
1583
|
+
function no(e, t) {
|
|
1584
|
+
return new e({
|
|
1585
|
+
type: "string",
|
|
1586
|
+
...f(t)
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
// @__NO_SIDE_EFFECTS__
|
|
1590
|
+
function oo(e, t) {
|
|
1591
|
+
return new e({
|
|
1592
|
+
type: "string",
|
|
1593
|
+
format: "email",
|
|
1594
|
+
check: "string_format",
|
|
1595
|
+
abort: !1,
|
|
1596
|
+
...f(t)
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
// @__NO_SIDE_EFFECTS__
|
|
1600
|
+
function Be(e, t) {
|
|
1601
|
+
return new e({
|
|
1602
|
+
type: "string",
|
|
1603
|
+
format: "guid",
|
|
1604
|
+
check: "string_format",
|
|
1605
|
+
abort: !1,
|
|
1606
|
+
...f(t)
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
// @__NO_SIDE_EFFECTS__
|
|
1610
|
+
function io(e, t) {
|
|
1611
|
+
return new e({
|
|
1612
|
+
type: "string",
|
|
1613
|
+
format: "uuid",
|
|
1614
|
+
check: "string_format",
|
|
1615
|
+
abort: !1,
|
|
1616
|
+
...f(t)
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
// @__NO_SIDE_EFFECTS__
|
|
1620
|
+
function ao(e, t) {
|
|
1621
|
+
return new e({
|
|
1622
|
+
type: "string",
|
|
1623
|
+
format: "uuid",
|
|
1624
|
+
check: "string_format",
|
|
1625
|
+
abort: !1,
|
|
1626
|
+
version: "v4",
|
|
1627
|
+
...f(t)
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
// @__NO_SIDE_EFFECTS__
|
|
1631
|
+
function so(e, t) {
|
|
1632
|
+
return new e({
|
|
1633
|
+
type: "string",
|
|
1634
|
+
format: "uuid",
|
|
1635
|
+
check: "string_format",
|
|
1636
|
+
abort: !1,
|
|
1637
|
+
version: "v6",
|
|
1638
|
+
...f(t)
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
// @__NO_SIDE_EFFECTS__
|
|
1642
|
+
function co(e, t) {
|
|
1643
|
+
return new e({
|
|
1644
|
+
type: "string",
|
|
1645
|
+
format: "uuid",
|
|
1646
|
+
check: "string_format",
|
|
1647
|
+
abort: !1,
|
|
1648
|
+
version: "v7",
|
|
1649
|
+
...f(t)
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
// @__NO_SIDE_EFFECTS__
|
|
1653
|
+
function uo(e, t) {
|
|
1654
|
+
return new e({
|
|
1655
|
+
type: "string",
|
|
1656
|
+
format: "url",
|
|
1657
|
+
check: "string_format",
|
|
1658
|
+
abort: !1,
|
|
1659
|
+
...f(t)
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
// @__NO_SIDE_EFFECTS__
|
|
1663
|
+
function lo(e, t) {
|
|
1664
|
+
return new e({
|
|
1665
|
+
type: "string",
|
|
1666
|
+
format: "emoji",
|
|
1667
|
+
check: "string_format",
|
|
1668
|
+
abort: !1,
|
|
1669
|
+
...f(t)
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
// @__NO_SIDE_EFFECTS__
|
|
1673
|
+
function fo(e, t) {
|
|
1674
|
+
return new e({
|
|
1675
|
+
type: "string",
|
|
1676
|
+
format: "nanoid",
|
|
1677
|
+
check: "string_format",
|
|
1678
|
+
abort: !1,
|
|
1679
|
+
...f(t)
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
// @__NO_SIDE_EFFECTS__
|
|
1683
|
+
function ho(e, t) {
|
|
1684
|
+
return new e({
|
|
1685
|
+
type: "string",
|
|
1686
|
+
format: "cuid",
|
|
1687
|
+
check: "string_format",
|
|
1688
|
+
abort: !1,
|
|
1689
|
+
...f(t)
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
// @__NO_SIDE_EFFECTS__
|
|
1693
|
+
function po(e, t) {
|
|
1694
|
+
return new e({
|
|
1695
|
+
type: "string",
|
|
1696
|
+
format: "cuid2",
|
|
1697
|
+
check: "string_format",
|
|
1698
|
+
abort: !1,
|
|
1699
|
+
...f(t)
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
// @__NO_SIDE_EFFECTS__
|
|
1703
|
+
function mo(e, t) {
|
|
1704
|
+
return new e({
|
|
1705
|
+
type: "string",
|
|
1706
|
+
format: "ulid",
|
|
1707
|
+
check: "string_format",
|
|
1708
|
+
abort: !1,
|
|
1709
|
+
...f(t)
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
// @__NO_SIDE_EFFECTS__
|
|
1713
|
+
function go(e, t) {
|
|
1714
|
+
return new e({
|
|
1715
|
+
type: "string",
|
|
1716
|
+
format: "xid",
|
|
1717
|
+
check: "string_format",
|
|
1718
|
+
abort: !1,
|
|
1719
|
+
...f(t)
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
// @__NO_SIDE_EFFECTS__
|
|
1723
|
+
function vo(e, t) {
|
|
1724
|
+
return new e({
|
|
1725
|
+
type: "string",
|
|
1726
|
+
format: "ksuid",
|
|
1727
|
+
check: "string_format",
|
|
1728
|
+
abort: !1,
|
|
1729
|
+
...f(t)
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
// @__NO_SIDE_EFFECTS__
|
|
1733
|
+
function bo(e, t) {
|
|
1734
|
+
return new e({
|
|
1735
|
+
type: "string",
|
|
1736
|
+
format: "ipv4",
|
|
1737
|
+
check: "string_format",
|
|
1738
|
+
abort: !1,
|
|
1739
|
+
...f(t)
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
// @__NO_SIDE_EFFECTS__
|
|
1743
|
+
function _o(e, t) {
|
|
1744
|
+
return new e({
|
|
1745
|
+
type: "string",
|
|
1746
|
+
format: "ipv6",
|
|
1747
|
+
check: "string_format",
|
|
1748
|
+
abort: !1,
|
|
1749
|
+
...f(t)
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
// @__NO_SIDE_EFFECTS__
|
|
1753
|
+
function wo(e, t) {
|
|
1754
|
+
return new e({
|
|
1755
|
+
type: "string",
|
|
1756
|
+
format: "cidrv4",
|
|
1757
|
+
check: "string_format",
|
|
1758
|
+
abort: !1,
|
|
1759
|
+
...f(t)
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
// @__NO_SIDE_EFFECTS__
|
|
1763
|
+
function yo(e, t) {
|
|
1764
|
+
return new e({
|
|
1765
|
+
type: "string",
|
|
1766
|
+
format: "cidrv6",
|
|
1767
|
+
check: "string_format",
|
|
1768
|
+
abort: !1,
|
|
1769
|
+
...f(t)
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
// @__NO_SIDE_EFFECTS__
|
|
1773
|
+
function zo(e, t) {
|
|
1774
|
+
return new e({
|
|
1775
|
+
type: "string",
|
|
1776
|
+
format: "base64",
|
|
1777
|
+
check: "string_format",
|
|
1778
|
+
abort: !1,
|
|
1779
|
+
...f(t)
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
// @__NO_SIDE_EFFECTS__
|
|
1783
|
+
function ko(e, t) {
|
|
1784
|
+
return new e({
|
|
1785
|
+
type: "string",
|
|
1786
|
+
format: "base64url",
|
|
1787
|
+
check: "string_format",
|
|
1788
|
+
abort: !1,
|
|
1789
|
+
...f(t)
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
// @__NO_SIDE_EFFECTS__
|
|
1793
|
+
function Eo(e, t) {
|
|
1794
|
+
return new e({
|
|
1795
|
+
type: "string",
|
|
1796
|
+
format: "e164",
|
|
1797
|
+
check: "string_format",
|
|
1798
|
+
abort: !1,
|
|
1799
|
+
...f(t)
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
// @__NO_SIDE_EFFECTS__
|
|
1803
|
+
function $o(e, t) {
|
|
1804
|
+
return new e({
|
|
1805
|
+
type: "string",
|
|
1806
|
+
format: "jwt",
|
|
1807
|
+
check: "string_format",
|
|
1808
|
+
abort: !1,
|
|
1809
|
+
...f(t)
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
// @__NO_SIDE_EFFECTS__
|
|
1813
|
+
function So(e, t) {
|
|
1814
|
+
return new e({
|
|
1815
|
+
type: "string",
|
|
1816
|
+
format: "datetime",
|
|
1817
|
+
check: "string_format",
|
|
1818
|
+
offset: !1,
|
|
1819
|
+
local: !1,
|
|
1820
|
+
precision: null,
|
|
1821
|
+
...f(t)
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
// @__NO_SIDE_EFFECTS__
|
|
1825
|
+
function Oo(e, t) {
|
|
1826
|
+
return new e({
|
|
1827
|
+
type: "string",
|
|
1828
|
+
format: "date",
|
|
1829
|
+
check: "string_format",
|
|
1830
|
+
...f(t)
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
// @__NO_SIDE_EFFECTS__
|
|
1834
|
+
function Io(e, t) {
|
|
1835
|
+
return new e({
|
|
1836
|
+
type: "string",
|
|
1837
|
+
format: "time",
|
|
1838
|
+
check: "string_format",
|
|
1839
|
+
precision: null,
|
|
1840
|
+
...f(t)
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
// @__NO_SIDE_EFFECTS__
|
|
1844
|
+
function Zo(e, t) {
|
|
1845
|
+
return new e({
|
|
1846
|
+
type: "string",
|
|
1847
|
+
format: "duration",
|
|
1848
|
+
check: "string_format",
|
|
1849
|
+
...f(t)
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
// @__NO_SIDE_EFFECTS__
|
|
1853
|
+
function To(e, t) {
|
|
1854
|
+
return new e({
|
|
1855
|
+
type: "number",
|
|
1856
|
+
checks: [],
|
|
1857
|
+
...f(t)
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
// @__NO_SIDE_EFFECTS__
|
|
1861
|
+
function Ao(e, t) {
|
|
1862
|
+
return new e({
|
|
1863
|
+
type: "number",
|
|
1864
|
+
check: "number_format",
|
|
1865
|
+
abort: !1,
|
|
1866
|
+
format: "safeint",
|
|
1867
|
+
...f(t)
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
// @__NO_SIDE_EFFECTS__
|
|
1871
|
+
function Co(e, t) {
|
|
1872
|
+
return new e({
|
|
1873
|
+
type: "boolean",
|
|
1874
|
+
...f(t)
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
// @__NO_SIDE_EFFECTS__
|
|
1878
|
+
function Po(e) {
|
|
1879
|
+
return new e({ type: "unknown" });
|
|
1880
|
+
}
|
|
1881
|
+
// @__NO_SIDE_EFFECTS__
|
|
1882
|
+
function No(e, t) {
|
|
1883
|
+
return new e({
|
|
1884
|
+
type: "never",
|
|
1885
|
+
...f(t)
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
// @__NO_SIDE_EFFECTS__
|
|
1889
|
+
function He(e, t) {
|
|
1890
|
+
return new Et({
|
|
1891
|
+
check: "less_than",
|
|
1892
|
+
...f(t),
|
|
1893
|
+
value: e,
|
|
1894
|
+
inclusive: !1
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
// @__NO_SIDE_EFFECTS__
|
|
1898
|
+
function ge(e, t) {
|
|
1899
|
+
return new Et({
|
|
1900
|
+
check: "less_than",
|
|
1901
|
+
...f(t),
|
|
1902
|
+
value: e,
|
|
1903
|
+
inclusive: !0
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
// @__NO_SIDE_EFFECTS__
|
|
1907
|
+
function Ge(e, t) {
|
|
1908
|
+
return new $t({
|
|
1909
|
+
check: "greater_than",
|
|
1910
|
+
...f(t),
|
|
1911
|
+
value: e,
|
|
1912
|
+
inclusive: !1
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
// @__NO_SIDE_EFFECTS__
|
|
1916
|
+
function ve(e, t) {
|
|
1917
|
+
return new $t({
|
|
1918
|
+
check: "greater_than",
|
|
1919
|
+
...f(t),
|
|
1920
|
+
value: e,
|
|
1921
|
+
inclusive: !0
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
// @__NO_SIDE_EFFECTS__
|
|
1925
|
+
function Ke(e, t) {
|
|
1926
|
+
return new Gr({
|
|
1927
|
+
check: "multiple_of",
|
|
1928
|
+
...f(t),
|
|
1929
|
+
value: e
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
// @__NO_SIDE_EFFECTS__
|
|
1933
|
+
function At(e, t) {
|
|
1934
|
+
return new Yr({
|
|
1935
|
+
check: "max_length",
|
|
1936
|
+
...f(t),
|
|
1937
|
+
maximum: e
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
// @__NO_SIDE_EFFECTS__
|
|
1941
|
+
function ce(e, t) {
|
|
1942
|
+
return new Qr({
|
|
1943
|
+
check: "min_length",
|
|
1944
|
+
...f(t),
|
|
1945
|
+
minimum: e
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
// @__NO_SIDE_EFFECTS__
|
|
1949
|
+
function Ct(e, t) {
|
|
1950
|
+
return new Xr({
|
|
1951
|
+
check: "length_equals",
|
|
1952
|
+
...f(t),
|
|
1953
|
+
length: e
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
// @__NO_SIDE_EFFECTS__
|
|
1957
|
+
function Ro(e, t) {
|
|
1958
|
+
return new en({
|
|
1959
|
+
check: "string_format",
|
|
1960
|
+
format: "regex",
|
|
1961
|
+
...f(t),
|
|
1962
|
+
pattern: e
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
// @__NO_SIDE_EFFECTS__
|
|
1966
|
+
function xo(e) {
|
|
1967
|
+
return new tn({
|
|
1968
|
+
check: "string_format",
|
|
1969
|
+
format: "lowercase",
|
|
1970
|
+
...f(e)
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
// @__NO_SIDE_EFFECTS__
|
|
1974
|
+
function jo(e) {
|
|
1975
|
+
return new rn({
|
|
1976
|
+
check: "string_format",
|
|
1977
|
+
format: "uppercase",
|
|
1978
|
+
...f(e)
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
// @__NO_SIDE_EFFECTS__
|
|
1982
|
+
function Mo(e, t) {
|
|
1983
|
+
return new nn({
|
|
1984
|
+
check: "string_format",
|
|
1985
|
+
format: "includes",
|
|
1986
|
+
...f(t),
|
|
1987
|
+
includes: e
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
// @__NO_SIDE_EFFECTS__
|
|
1991
|
+
function Do(e, t) {
|
|
1992
|
+
return new on({
|
|
1993
|
+
check: "string_format",
|
|
1994
|
+
format: "starts_with",
|
|
1995
|
+
...f(t),
|
|
1996
|
+
prefix: e
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
// @__NO_SIDE_EFFECTS__
|
|
2000
|
+
function Lo(e, t) {
|
|
2001
|
+
return new an({
|
|
2002
|
+
check: "string_format",
|
|
2003
|
+
format: "ends_with",
|
|
2004
|
+
...f(t),
|
|
2005
|
+
suffix: e
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
// @__NO_SIDE_EFFECTS__
|
|
2009
|
+
function W(e) {
|
|
2010
|
+
return new sn({
|
|
2011
|
+
check: "overwrite",
|
|
2012
|
+
tx: e
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
// @__NO_SIDE_EFFECTS__
|
|
2016
|
+
function Uo(e) {
|
|
2017
|
+
return /* @__PURE__ */ W((t) => t.normalize(e));
|
|
2018
|
+
}
|
|
2019
|
+
// @__NO_SIDE_EFFECTS__
|
|
2020
|
+
function Fo() {
|
|
2021
|
+
return /* @__PURE__ */ W((e) => e.trim());
|
|
2022
|
+
}
|
|
2023
|
+
// @__NO_SIDE_EFFECTS__
|
|
2024
|
+
function Vo() {
|
|
2025
|
+
return /* @__PURE__ */ W((e) => e.toLowerCase());
|
|
2026
|
+
}
|
|
2027
|
+
// @__NO_SIDE_EFFECTS__
|
|
2028
|
+
function qo() {
|
|
2029
|
+
return /* @__PURE__ */ W((e) => e.toUpperCase());
|
|
2030
|
+
}
|
|
2031
|
+
// @__NO_SIDE_EFFECTS__
|
|
2032
|
+
function Jo() {
|
|
2033
|
+
return /* @__PURE__ */ W((e) => Xt(e));
|
|
2034
|
+
}
|
|
2035
|
+
// @__NO_SIDE_EFFECTS__
|
|
2036
|
+
function Wo(e, t, r) {
|
|
2037
|
+
return new e({
|
|
2038
|
+
type: "array",
|
|
2039
|
+
element: t,
|
|
2040
|
+
...f(r)
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
// @__NO_SIDE_EFFECTS__
|
|
2044
|
+
function Bo(e, t, r) {
|
|
2045
|
+
const n = f(r);
|
|
2046
|
+
return n.abort ?? (n.abort = !0), new e({
|
|
2047
|
+
type: "custom",
|
|
2048
|
+
check: "custom",
|
|
2049
|
+
fn: t,
|
|
2050
|
+
...n
|
|
2051
|
+
});
|
|
2052
|
+
}
|
|
2053
|
+
// @__NO_SIDE_EFFECTS__
|
|
2054
|
+
function Ho(e, t, r) {
|
|
2055
|
+
return new e({
|
|
2056
|
+
type: "custom",
|
|
2057
|
+
check: "custom",
|
|
2058
|
+
fn: t,
|
|
2059
|
+
...f(r)
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
// @__NO_SIDE_EFFECTS__
|
|
2063
|
+
function Go(e) {
|
|
2064
|
+
const t = /* @__PURE__ */ Ko((r) => (r.addIssue = (n) => {
|
|
2065
|
+
if (typeof n == "string") r.issues.push(Y(n, r.value, t._zod.def));
|
|
2066
|
+
else {
|
|
2067
|
+
const o = n;
|
|
2068
|
+
o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = r.value), o.inst ?? (o.inst = t), o.continue ?? (o.continue = !t._zod.def.abort), r.issues.push(Y(o));
|
|
2069
|
+
}
|
|
2070
|
+
}, e(r.value, r)));
|
|
2071
|
+
return t;
|
|
2072
|
+
}
|
|
2073
|
+
// @__NO_SIDE_EFFECTS__
|
|
2074
|
+
function Ko(e, t) {
|
|
2075
|
+
const r = new S({
|
|
2076
|
+
check: "custom",
|
|
2077
|
+
...f(t)
|
|
2078
|
+
});
|
|
2079
|
+
return r._zod.check = e, r;
|
|
2080
|
+
}
|
|
2081
|
+
function Pt(e) {
|
|
2082
|
+
let t = e?.target ?? "draft-2020-12";
|
|
2083
|
+
return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
|
|
2084
|
+
processors: e.processors ?? {},
|
|
2085
|
+
metadataRegistry: e?.metadata ?? G,
|
|
2086
|
+
target: t,
|
|
2087
|
+
unrepresentable: e?.unrepresentable ?? "throw",
|
|
2088
|
+
override: e?.override ?? (() => {
|
|
2089
|
+
}),
|
|
2090
|
+
io: e?.io ?? "output",
|
|
2091
|
+
counter: 0,
|
|
2092
|
+
seen: /* @__PURE__ */ new Map(),
|
|
2093
|
+
cycles: e?.cycles ?? "ref",
|
|
2094
|
+
reused: e?.reused ?? "inline",
|
|
2095
|
+
external: e?.external ?? void 0
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
function k(e, t, r = {
|
|
2099
|
+
path: [],
|
|
2100
|
+
schemaPath: []
|
|
2101
|
+
}) {
|
|
2102
|
+
var n;
|
|
2103
|
+
const o = e._zod.def, a = t.seen.get(e);
|
|
2104
|
+
if (a)
|
|
2105
|
+
return a.count++, r.schemaPath.includes(e) && (a.cycle = r.path), a.schema;
|
|
2106
|
+
const i = {
|
|
2107
|
+
schema: {},
|
|
2108
|
+
count: 1,
|
|
2109
|
+
cycle: void 0,
|
|
2110
|
+
path: r.path
|
|
2111
|
+
};
|
|
2112
|
+
t.seen.set(e, i);
|
|
2113
|
+
const s = e._zod.toJSONSchema?.();
|
|
2114
|
+
if (s) i.schema = s;
|
|
2115
|
+
else {
|
|
2116
|
+
const l = {
|
|
2117
|
+
...r,
|
|
2118
|
+
schemaPath: [...r.schemaPath, e],
|
|
2119
|
+
path: r.path
|
|
2120
|
+
};
|
|
2121
|
+
if (e._zod.processJSONSchema) e._zod.processJSONSchema(t, i.schema, l);
|
|
2122
|
+
else {
|
|
2123
|
+
const p = i.schema, h = t.processors[o.type];
|
|
2124
|
+
if (!h) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);
|
|
2125
|
+
h(e, t, p, l);
|
|
2126
|
+
}
|
|
2127
|
+
const d = e._zod.parent;
|
|
2128
|
+
d && (i.ref || (i.ref = d), k(d, t, l), t.seen.get(d).isParent = !0);
|
|
2129
|
+
}
|
|
2130
|
+
const c = t.metadataRegistry.get(e);
|
|
2131
|
+
return c && Object.assign(i.schema, c), t.io === "input" && E(e) && (delete i.schema.examples, delete i.schema.default), t.io === "input" && i.schema._prefault && ((n = i.schema).default ?? (n.default = i.schema._prefault)), delete i.schema._prefault, t.seen.get(e).schema;
|
|
2132
|
+
}
|
|
2133
|
+
function Nt(e, t) {
|
|
2134
|
+
const r = e.seen.get(t);
|
|
2135
|
+
if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2136
|
+
const n = /* @__PURE__ */ new Map();
|
|
2137
|
+
for (const i of e.seen.entries()) {
|
|
2138
|
+
const s = e.metadataRegistry.get(i[0])?.id;
|
|
2139
|
+
if (s) {
|
|
2140
|
+
const c = n.get(s);
|
|
2141
|
+
if (c && c !== i[0]) throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
2142
|
+
n.set(s, i[0]);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
const o = (i) => {
|
|
2146
|
+
const s = e.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
2147
|
+
if (e.external) {
|
|
2148
|
+
const d = e.external.registry.get(i[0])?.id, p = e.external.uri ?? ((m) => m);
|
|
2149
|
+
if (d) return { ref: p(d) };
|
|
2150
|
+
const h = i[1].defId ?? i[1].schema.id ?? `schema${e.counter++}`;
|
|
2151
|
+
return i[1].defId = h, {
|
|
2152
|
+
defId: h,
|
|
2153
|
+
ref: `${p("__shared")}#/${s}/${h}`
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
if (i[1] === r) return { ref: "#" };
|
|
2157
|
+
const c = `#/${s}/`, l = i[1].schema.id ?? `__schema${e.counter++}`;
|
|
2158
|
+
return {
|
|
2159
|
+
defId: l,
|
|
2160
|
+
ref: c + l
|
|
2161
|
+
};
|
|
2162
|
+
}, a = (i) => {
|
|
2163
|
+
if (i[1].schema.$ref) return;
|
|
2164
|
+
const s = i[1], { ref: c, defId: l } = o(i);
|
|
2165
|
+
s.def = { ...s.schema }, l && (s.defId = l);
|
|
2166
|
+
const d = s.schema;
|
|
2167
|
+
for (const p in d) delete d[p];
|
|
2168
|
+
d.$ref = c;
|
|
2169
|
+
};
|
|
2170
|
+
if (e.cycles === "throw") for (const i of e.seen.entries()) {
|
|
2171
|
+
const s = i[1];
|
|
2172
|
+
if (s.cycle) throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
2173
|
+
|
|
2174
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
2175
|
+
}
|
|
2176
|
+
for (const i of e.seen.entries()) {
|
|
2177
|
+
const s = i[1];
|
|
2178
|
+
if (t === i[0]) {
|
|
2179
|
+
a(i);
|
|
2180
|
+
continue;
|
|
2181
|
+
}
|
|
2182
|
+
if (e.external) {
|
|
2183
|
+
const c = e.external.registry.get(i[0])?.id;
|
|
2184
|
+
if (t !== i[0] && c) {
|
|
2185
|
+
a(i);
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
if (e.metadataRegistry.get(i[0])?.id) {
|
|
2190
|
+
a(i);
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
if (s.cycle) {
|
|
2194
|
+
a(i);
|
|
2195
|
+
continue;
|
|
2196
|
+
}
|
|
2197
|
+
if (s.count > 1 && e.reused === "ref") {
|
|
2198
|
+
a(i);
|
|
2199
|
+
continue;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function Rt(e, t) {
|
|
2204
|
+
const r = e.seen.get(t);
|
|
2205
|
+
if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
2206
|
+
const n = (i) => {
|
|
2207
|
+
const s = e.seen.get(i);
|
|
2208
|
+
if (s.ref === null) return;
|
|
2209
|
+
const c = s.def ?? s.schema, l = { ...c }, d = s.ref;
|
|
2210
|
+
if (s.ref = null, d) {
|
|
2211
|
+
n(d);
|
|
2212
|
+
const h = e.seen.get(d), m = h.schema;
|
|
2213
|
+
if (m.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(m)) : Object.assign(c, m), Object.assign(c, l), i._zod.parent === d) for (const v in c)
|
|
2214
|
+
v === "$ref" || v === "allOf" || v in l || delete c[v];
|
|
2215
|
+
if (m.$ref && h.def) for (const v in c)
|
|
2216
|
+
v === "$ref" || v === "allOf" || v in h.def && JSON.stringify(c[v]) === JSON.stringify(h.def[v]) && delete c[v];
|
|
2217
|
+
}
|
|
2218
|
+
const p = i._zod.parent;
|
|
2219
|
+
if (p && p !== d) {
|
|
2220
|
+
n(p);
|
|
2221
|
+
const h = e.seen.get(p);
|
|
2222
|
+
if (h?.schema.$ref && (c.$ref = h.schema.$ref, h.def))
|
|
2223
|
+
for (const m in c)
|
|
2224
|
+
m === "$ref" || m === "allOf" || m in h.def && JSON.stringify(c[m]) === JSON.stringify(h.def[m]) && delete c[m];
|
|
2225
|
+
}
|
|
2226
|
+
e.override({
|
|
2227
|
+
zodSchema: i,
|
|
2228
|
+
jsonSchema: c,
|
|
2229
|
+
path: s.path ?? []
|
|
2230
|
+
});
|
|
2231
|
+
};
|
|
2232
|
+
for (const i of [...e.seen.entries()].reverse()) n(i[0]);
|
|
2233
|
+
const o = {};
|
|
2234
|
+
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) {
|
|
2235
|
+
const i = e.external.registry.get(t)?.id;
|
|
2236
|
+
if (!i) throw new Error("Schema is missing an `id` property");
|
|
2237
|
+
o.$id = e.external.uri(i);
|
|
2238
|
+
}
|
|
2239
|
+
Object.assign(o, r.def ?? r.schema);
|
|
2240
|
+
const a = e.external?.defs ?? {};
|
|
2241
|
+
for (const i of e.seen.entries()) {
|
|
2242
|
+
const s = i[1];
|
|
2243
|
+
s.def && s.defId && (a[s.defId] = s.def);
|
|
2244
|
+
}
|
|
2245
|
+
e.external || Object.keys(a).length > 0 && (e.target === "draft-2020-12" ? o.$defs = a : o.definitions = a);
|
|
2246
|
+
try {
|
|
2247
|
+
const i = JSON.parse(JSON.stringify(o));
|
|
2248
|
+
return Object.defineProperty(i, "~standard", {
|
|
2249
|
+
value: {
|
|
2250
|
+
...t["~standard"],
|
|
2251
|
+
jsonSchema: {
|
|
2252
|
+
input: ue(t, "input", e.processors),
|
|
2253
|
+
output: ue(t, "output", e.processors)
|
|
2254
|
+
}
|
|
2255
|
+
},
|
|
2256
|
+
enumerable: !1,
|
|
2257
|
+
writable: !1
|
|
2258
|
+
}), i;
|
|
2259
|
+
} catch {
|
|
2260
|
+
throw new Error("Error converting schema to JSON.");
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function E(e, t) {
|
|
2264
|
+
const r = t ?? { seen: /* @__PURE__ */ new Set() };
|
|
2265
|
+
if (r.seen.has(e)) return !1;
|
|
2266
|
+
r.seen.add(e);
|
|
2267
|
+
const n = e._zod.def;
|
|
2268
|
+
if (n.type === "transform") return !0;
|
|
2269
|
+
if (n.type === "array") return E(n.element, r);
|
|
2270
|
+
if (n.type === "set") return E(n.valueType, r);
|
|
2271
|
+
if (n.type === "lazy") return E(n.getter(), r);
|
|
2272
|
+
if (n.type === "promise" || n.type === "optional" || n.type === "nonoptional" || n.type === "nullable" || n.type === "readonly" || n.type === "default" || n.type === "prefault") return E(n.innerType, r);
|
|
2273
|
+
if (n.type === "intersection") return E(n.left, r) || E(n.right, r);
|
|
2274
|
+
if (n.type === "record" || n.type === "map") return E(n.keyType, r) || E(n.valueType, r);
|
|
2275
|
+
if (n.type === "pipe") return E(n.in, r) || E(n.out, r);
|
|
2276
|
+
if (n.type === "object") {
|
|
2277
|
+
for (const o in n.shape) if (E(n.shape[o], r)) return !0;
|
|
2278
|
+
return !1;
|
|
2279
|
+
}
|
|
2280
|
+
if (n.type === "union") {
|
|
2281
|
+
for (const o of n.options) if (E(o, r)) return !0;
|
|
2282
|
+
return !1;
|
|
2283
|
+
}
|
|
2284
|
+
if (n.type === "tuple") {
|
|
2285
|
+
for (const o of n.items) if (E(o, r)) return !0;
|
|
2286
|
+
return !!(n.rest && E(n.rest, r));
|
|
2287
|
+
}
|
|
2288
|
+
return !1;
|
|
2289
|
+
}
|
|
2290
|
+
var Yo = (e, t = {}) => (r) => {
|
|
2291
|
+
const n = Pt({
|
|
2292
|
+
...r,
|
|
2293
|
+
processors: t
|
|
2294
|
+
});
|
|
2295
|
+
return k(e, n), Nt(n, e), Rt(n, e);
|
|
2296
|
+
}, ue = (e, t, r = {}) => (n) => {
|
|
2297
|
+
const { libraryOptions: o, target: a } = n ?? {}, i = Pt({
|
|
2298
|
+
...o ?? {},
|
|
2299
|
+
target: a,
|
|
2300
|
+
io: t,
|
|
2301
|
+
processors: r
|
|
2302
|
+
});
|
|
2303
|
+
return k(e, i), Nt(i, e), Rt(i, e);
|
|
2304
|
+
}, Qo = {
|
|
2305
|
+
guid: "uuid",
|
|
2306
|
+
url: "uri",
|
|
2307
|
+
datetime: "date-time",
|
|
2308
|
+
json_string: "json-string",
|
|
2309
|
+
regex: ""
|
|
2310
|
+
}, Xo = (e, t, r, n) => {
|
|
2311
|
+
const o = r;
|
|
2312
|
+
o.type = "string";
|
|
2313
|
+
const { minimum: a, maximum: i, format: s, patterns: c, contentEncoding: l } = e._zod.bag;
|
|
2314
|
+
if (typeof a == "number" && (o.minLength = a), typeof i == "number" && (o.maxLength = i), s && (o.format = Qo[s] ?? s, o.format === "" && delete o.format, s === "time" && delete o.format), l && (o.contentEncoding = l), c && c.size > 0) {
|
|
2315
|
+
const d = [...c];
|
|
2316
|
+
d.length === 1 ? o.pattern = d[0].source : d.length > 1 && (o.allOf = [...d.map((p) => ({
|
|
2317
|
+
...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
|
|
2318
|
+
pattern: p.source
|
|
2319
|
+
}))]);
|
|
2320
|
+
}
|
|
2321
|
+
}, ei = (e, t, r, n) => {
|
|
2322
|
+
const o = r, { minimum: a, maximum: i, format: s, multipleOf: c, exclusiveMaximum: l, exclusiveMinimum: d } = e._zod.bag;
|
|
2323
|
+
typeof s == "string" && s.includes("int") ? o.type = "integer" : o.type = "number", typeof d == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.minimum = d, o.exclusiveMinimum = !0) : o.exclusiveMinimum = d), typeof a == "number" && (o.minimum = a, typeof d == "number" && t.target !== "draft-04" && (d >= a ? delete o.minimum : delete o.exclusiveMinimum)), typeof l == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (o.maximum = l, o.exclusiveMaximum = !0) : o.exclusiveMaximum = l), typeof i == "number" && (o.maximum = i, typeof l == "number" && t.target !== "draft-04" && (l <= i ? delete o.maximum : delete o.exclusiveMaximum)), typeof c == "number" && (o.multipleOf = c);
|
|
2324
|
+
}, ti = (e, t, r, n) => {
|
|
2325
|
+
r.type = "boolean";
|
|
2326
|
+
}, ri = (e, t, r, n) => {
|
|
2327
|
+
r.not = {};
|
|
2328
|
+
}, ni = (e, t, r, n) => {
|
|
2329
|
+
}, oi = (e, t, r, n) => {
|
|
2330
|
+
const o = e._zod.def, a = ht(o.entries);
|
|
2331
|
+
a.every((i) => typeof i == "number") && (r.type = "number"), a.every((i) => typeof i == "string") && (r.type = "string"), r.enum = a;
|
|
2332
|
+
}, ii = (e, t, r, n) => {
|
|
2333
|
+
if (t.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
2334
|
+
}, ai = (e, t, r, n) => {
|
|
2335
|
+
if (t.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
2336
|
+
}, si = (e, t, r, n) => {
|
|
2337
|
+
const o = r, a = e._zod.def, { minimum: i, maximum: s } = e._zod.bag;
|
|
2338
|
+
typeof i == "number" && (o.minItems = i), typeof s == "number" && (o.maxItems = s), o.type = "array", o.items = k(a.element, t, {
|
|
2339
|
+
...n,
|
|
2340
|
+
path: [...n.path, "items"]
|
|
2341
|
+
});
|
|
2342
|
+
}, ci = (e, t, r, n) => {
|
|
2343
|
+
const o = r, a = e._zod.def;
|
|
2344
|
+
o.type = "object", o.properties = {};
|
|
2345
|
+
const i = a.shape;
|
|
2346
|
+
for (const l in i) o.properties[l] = k(i[l], t, {
|
|
2347
|
+
...n,
|
|
2348
|
+
path: [
|
|
2349
|
+
...n.path,
|
|
2350
|
+
"properties",
|
|
2351
|
+
l
|
|
2352
|
+
]
|
|
2353
|
+
});
|
|
2354
|
+
const s = new Set(Object.keys(i)), c = new Set([...s].filter((l) => {
|
|
2355
|
+
const d = a.shape[l]._zod;
|
|
2356
|
+
return t.io === "input" ? d.optin === void 0 : d.optout === void 0;
|
|
2357
|
+
}));
|
|
2358
|
+
c.size > 0 && (o.required = Array.from(c)), a.catchall?._zod.def.type === "never" ? o.additionalProperties = !1 : a.catchall ? a.catchall && (o.additionalProperties = k(a.catchall, t, {
|
|
2359
|
+
...n,
|
|
2360
|
+
path: [...n.path, "additionalProperties"]
|
|
2361
|
+
})) : t.io === "output" && (o.additionalProperties = !1);
|
|
2362
|
+
}, ui = (e, t, r, n) => {
|
|
2363
|
+
const o = e._zod.def, a = o.inclusive === !1, i = o.options.map((s, c) => k(s, t, {
|
|
2364
|
+
...n,
|
|
2365
|
+
path: [
|
|
2366
|
+
...n.path,
|
|
2367
|
+
a ? "oneOf" : "anyOf",
|
|
2368
|
+
c
|
|
2369
|
+
]
|
|
2370
|
+
}));
|
|
2371
|
+
a ? r.oneOf = i : r.anyOf = i;
|
|
2372
|
+
}, li = (e, t, r, n) => {
|
|
2373
|
+
const o = e._zod.def, a = k(o.left, t, {
|
|
2374
|
+
...n,
|
|
2375
|
+
path: [
|
|
2376
|
+
...n.path,
|
|
2377
|
+
"allOf",
|
|
2378
|
+
0
|
|
2379
|
+
]
|
|
2380
|
+
}), i = k(o.right, t, {
|
|
2381
|
+
...n,
|
|
2382
|
+
path: [
|
|
2383
|
+
...n.path,
|
|
2384
|
+
"allOf",
|
|
2385
|
+
1
|
|
2386
|
+
]
|
|
2387
|
+
}), s = (c) => "allOf" in c && Object.keys(c).length === 1;
|
|
2388
|
+
r.allOf = [...s(a) ? a.allOf : [a], ...s(i) ? i.allOf : [i]];
|
|
2389
|
+
}, di = (e, t, r, n) => {
|
|
2390
|
+
const o = e._zod.def, a = k(o.innerType, t, n), i = t.seen.get(e);
|
|
2391
|
+
t.target === "openapi-3.0" ? (i.ref = o.innerType, r.nullable = !0) : r.anyOf = [a, { type: "null" }];
|
|
2392
|
+
}, fi = (e, t, r, n) => {
|
|
2393
|
+
const o = e._zod.def;
|
|
2394
|
+
k(o.innerType, t, n);
|
|
2395
|
+
const a = t.seen.get(e);
|
|
2396
|
+
a.ref = o.innerType;
|
|
2397
|
+
}, hi = (e, t, r, n) => {
|
|
2398
|
+
const o = e._zod.def;
|
|
2399
|
+
k(o.innerType, t, n);
|
|
2400
|
+
const a = t.seen.get(e);
|
|
2401
|
+
a.ref = o.innerType, r.default = JSON.parse(JSON.stringify(o.defaultValue));
|
|
2402
|
+
}, pi = (e, t, r, n) => {
|
|
2403
|
+
const o = e._zod.def;
|
|
2404
|
+
k(o.innerType, t, n);
|
|
2405
|
+
const a = t.seen.get(e);
|
|
2406
|
+
a.ref = o.innerType, t.io === "input" && (r._prefault = JSON.parse(JSON.stringify(o.defaultValue)));
|
|
2407
|
+
}, mi = (e, t, r, n) => {
|
|
2408
|
+
const o = e._zod.def;
|
|
2409
|
+
k(o.innerType, t, n);
|
|
2410
|
+
const a = t.seen.get(e);
|
|
2411
|
+
a.ref = o.innerType;
|
|
2412
|
+
let i;
|
|
2413
|
+
try {
|
|
2414
|
+
i = o.catchValue(void 0);
|
|
2415
|
+
} catch {
|
|
2416
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
2417
|
+
}
|
|
2418
|
+
r.default = i;
|
|
2419
|
+
}, gi = (e, t, r, n) => {
|
|
2420
|
+
const o = e._zod.def, a = t.io === "input" ? o.in._zod.def.type === "transform" ? o.out : o.in : o.out;
|
|
2421
|
+
k(a, t, n);
|
|
2422
|
+
const i = t.seen.get(e);
|
|
2423
|
+
i.ref = a;
|
|
2424
|
+
}, vi = (e, t, r, n) => {
|
|
2425
|
+
const o = e._zod.def;
|
|
2426
|
+
k(o.innerType, t, n);
|
|
2427
|
+
const a = t.seen.get(e);
|
|
2428
|
+
a.ref = o.innerType, r.readOnly = !0;
|
|
2429
|
+
}, xt = (e, t, r, n) => {
|
|
2430
|
+
const o = e._zod.def;
|
|
2431
|
+
k(o.innerType, t, n);
|
|
2432
|
+
const a = t.seen.get(e);
|
|
2433
|
+
a.ref = o.innerType;
|
|
2434
|
+
}, bi = /* @__PURE__ */ u("ZodISODateTime", (e, t) => {
|
|
2435
|
+
yn.init(e, t), w.init(e, t);
|
|
2436
|
+
});
|
|
2437
|
+
function _i(e) {
|
|
2438
|
+
return /* @__PURE__ */ So(bi, e);
|
|
2439
|
+
}
|
|
2440
|
+
var wi = /* @__PURE__ */ u("ZodISODate", (e, t) => {
|
|
2441
|
+
zn.init(e, t), w.init(e, t);
|
|
2442
|
+
});
|
|
2443
|
+
function yi(e) {
|
|
2444
|
+
return /* @__PURE__ */ Oo(wi, e);
|
|
2445
|
+
}
|
|
2446
|
+
var zi = /* @__PURE__ */ u("ZodISOTime", (e, t) => {
|
|
2447
|
+
kn.init(e, t), w.init(e, t);
|
|
2448
|
+
});
|
|
2449
|
+
function ki(e) {
|
|
2450
|
+
return /* @__PURE__ */ Io(zi, e);
|
|
2451
|
+
}
|
|
2452
|
+
var Ei = /* @__PURE__ */ u("ZodISODuration", (e, t) => {
|
|
2453
|
+
En.init(e, t), w.init(e, t);
|
|
2454
|
+
});
|
|
2455
|
+
function $i(e) {
|
|
2456
|
+
return /* @__PURE__ */ Zo(Ei, e);
|
|
2457
|
+
}
|
|
2458
|
+
var jt = (e, t) => {
|
|
2459
|
+
bt.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
|
|
2460
|
+
format: { value: (r) => fr(e, r) },
|
|
2461
|
+
flatten: { value: (r) => dr(e, r) },
|
|
2462
|
+
addIssue: { value: (r) => {
|
|
2463
|
+
e.issues.push(r), e.message = JSON.stringify(e.issues, ye, 2);
|
|
2464
|
+
} },
|
|
2465
|
+
addIssues: { value: (r) => {
|
|
2466
|
+
e.issues.push(...r), e.message = JSON.stringify(e.issues, ye, 2);
|
|
2467
|
+
} },
|
|
2468
|
+
isEmpty: { get() {
|
|
2469
|
+
return e.issues.length === 0;
|
|
2470
|
+
} }
|
|
2471
|
+
});
|
|
2472
|
+
}, cs = u("ZodError", jt), I = u("ZodError", jt, { Parent: Error }), Si = /* @__PURE__ */ Ze(I), Oi = /* @__PURE__ */ Te(I), Ii = /* @__PURE__ */ he(I), Zi = /* @__PURE__ */ pe(I), Ti = /* @__PURE__ */ mr(I), Ai = /* @__PURE__ */ gr(I), Ci = /* @__PURE__ */ vr(I), Pi = /* @__PURE__ */ br(I), Ni = /* @__PURE__ */ _r(I), Ri = /* @__PURE__ */ wr(I), xi = /* @__PURE__ */ yr(I), ji = /* @__PURE__ */ zr(I), z = /* @__PURE__ */ u("ZodType", (e, t) => (y.init(e, t), Object.assign(e["~standard"], { jsonSchema: {
|
|
2473
|
+
input: ue(e, "input"),
|
|
2474
|
+
output: ue(e, "output")
|
|
2475
|
+
} }), e.toJSONSchema = Yo(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...r) => e.clone(R(t, { checks: [...t.checks ?? [], ...r.map((n) => typeof n == "function" ? { _zod: {
|
|
2476
|
+
check: n,
|
|
2477
|
+
def: { check: "custom" },
|
|
2478
|
+
onattach: []
|
|
2479
|
+
} } : n)] }), { parent: !0 }), e.with = e.check, e.clone = (r, n) => x(e, r, n), e.brand = () => e, e.register = ((r, n) => (r.add(e, n), e)), e.parse = (r, n) => Si(e, r, n, { callee: e.parse }), e.safeParse = (r, n) => Ii(e, r, n), e.parseAsync = async (r, n) => Oi(e, r, n, { callee: e.parseAsync }), e.safeParseAsync = async (r, n) => Zi(e, r, n), e.spa = e.safeParseAsync, e.encode = (r, n) => Ti(e, r, n), e.decode = (r, n) => Ai(e, r, n), e.encodeAsync = async (r, n) => Ci(e, r, n), e.decodeAsync = async (r, n) => Pi(e, r, n), e.safeEncode = (r, n) => Ni(e, r, n), e.safeDecode = (r, n) => Ri(e, r, n), e.safeEncodeAsync = async (r, n) => xi(e, r, n), e.safeDecodeAsync = async (r, n) => ji(e, r, n), e.refine = (r, n) => e.check(Ia(r, n)), e.superRefine = (r) => e.check(Za(r)), e.overwrite = (r) => e.check(/* @__PURE__ */ W(r)), e.optional = () => et(e), e.exactOptional = () => ma(e), e.nullable = () => tt(e), e.nullish = () => et(tt(e)), e.nonoptional = (r) => ya(e, r), e.array = () => Ce(e), e.or = (r) => Lt([e, r]), e.and = (r) => da(e, r), e.transform = (r) => rt(e, ha(r)), e.default = (r) => ba(e, r), e.prefault = (r) => wa(e, r), e.catch = (r) => ka(e, r), e.pipe = (r) => rt(e, r), e.readonly = () => Sa(e), e.describe = (r) => {
|
|
2480
|
+
const n = e.clone();
|
|
2481
|
+
return G.add(n, { description: r }), n;
|
|
2482
|
+
}, Object.defineProperty(e, "description", {
|
|
2483
|
+
get() {
|
|
2484
|
+
return G.get(e)?.description;
|
|
2485
|
+
},
|
|
2486
|
+
configurable: !0
|
|
2487
|
+
}), e.meta = (...r) => {
|
|
2488
|
+
if (r.length === 0) return G.get(e);
|
|
2489
|
+
const n = e.clone();
|
|
2490
|
+
return G.add(n, r[0]), n;
|
|
2491
|
+
}, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (r) => r(e), e)), Mt = /* @__PURE__ */ u("_ZodString", (e, t) => {
|
|
2492
|
+
Ae.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => Xo(e, n, o, a);
|
|
2493
|
+
const r = e._zod.bag;
|
|
2494
|
+
e.format = r.format ?? null, e.minLength = r.minimum ?? null, e.maxLength = r.maximum ?? null, e.regex = (...n) => e.check(/* @__PURE__ */ Ro(...n)), e.includes = (...n) => e.check(/* @__PURE__ */ Mo(...n)), e.startsWith = (...n) => e.check(/* @__PURE__ */ Do(...n)), e.endsWith = (...n) => e.check(/* @__PURE__ */ Lo(...n)), e.min = (...n) => e.check(/* @__PURE__ */ ce(...n)), e.max = (...n) => e.check(/* @__PURE__ */ At(...n)), e.length = (...n) => e.check(/* @__PURE__ */ Ct(...n)), e.nonempty = (...n) => e.check(/* @__PURE__ */ ce(1, ...n)), e.lowercase = (n) => e.check(/* @__PURE__ */ xo(n)), e.uppercase = (n) => e.check(/* @__PURE__ */ jo(n)), e.trim = () => e.check(/* @__PURE__ */ Fo()), e.normalize = (...n) => e.check(/* @__PURE__ */ Uo(...n)), e.toLowerCase = () => e.check(/* @__PURE__ */ Vo()), e.toUpperCase = () => e.check(/* @__PURE__ */ qo()), e.slugify = () => e.check(/* @__PURE__ */ Jo());
|
|
2495
|
+
}), Mi = /* @__PURE__ */ u("ZodString", (e, t) => {
|
|
2496
|
+
Ae.init(e, t), Mt.init(e, t), e.email = (r) => e.check(/* @__PURE__ */ oo(Di, r)), e.url = (r) => e.check(/* @__PURE__ */ uo(Li, r)), e.jwt = (r) => e.check(/* @__PURE__ */ $o(ta, r)), e.emoji = (r) => e.check(/* @__PURE__ */ lo(Ui, r)), e.guid = (r) => e.check(/* @__PURE__ */ Be(Ye, r)), e.uuid = (r) => e.check(/* @__PURE__ */ io(ee, r)), e.uuidv4 = (r) => e.check(/* @__PURE__ */ ao(ee, r)), e.uuidv6 = (r) => e.check(/* @__PURE__ */ so(ee, r)), e.uuidv7 = (r) => e.check(/* @__PURE__ */ co(ee, r)), e.nanoid = (r) => e.check(/* @__PURE__ */ fo(Fi, r)), e.guid = (r) => e.check(/* @__PURE__ */ Be(Ye, r)), e.cuid = (r) => e.check(/* @__PURE__ */ ho(Vi, r)), e.cuid2 = (r) => e.check(/* @__PURE__ */ po(qi, r)), e.ulid = (r) => e.check(/* @__PURE__ */ mo(Ji, r)), e.base64 = (r) => e.check(/* @__PURE__ */ zo(Qi, r)), e.base64url = (r) => e.check(/* @__PURE__ */ ko(Xi, r)), e.xid = (r) => e.check(/* @__PURE__ */ go(Wi, r)), e.ksuid = (r) => e.check(/* @__PURE__ */ vo(Bi, r)), e.ipv4 = (r) => e.check(/* @__PURE__ */ bo(Hi, r)), e.ipv6 = (r) => e.check(/* @__PURE__ */ _o(Gi, r)), e.cidrv4 = (r) => e.check(/* @__PURE__ */ wo(Ki, r)), e.cidrv6 = (r) => e.check(/* @__PURE__ */ yo(Yi, r)), e.e164 = (r) => e.check(/* @__PURE__ */ Eo(ea, r)), e.datetime = (r) => e.check(_i(r)), e.date = (r) => e.check(yi(r)), e.time = (r) => e.check(ki(r)), e.duration = (r) => e.check($i(r));
|
|
2497
|
+
});
|
|
2498
|
+
function b(e) {
|
|
2499
|
+
return /* @__PURE__ */ no(Mi, e);
|
|
2500
|
+
}
|
|
2501
|
+
var w = /* @__PURE__ */ u("ZodStringFormat", (e, t) => {
|
|
2502
|
+
_.init(e, t), Mt.init(e, t);
|
|
2503
|
+
}), Di = /* @__PURE__ */ u("ZodEmail", (e, t) => {
|
|
2504
|
+
fn.init(e, t), w.init(e, t);
|
|
2505
|
+
}), Ye = /* @__PURE__ */ u("ZodGUID", (e, t) => {
|
|
2506
|
+
ln.init(e, t), w.init(e, t);
|
|
2507
|
+
}), ee = /* @__PURE__ */ u("ZodUUID", (e, t) => {
|
|
2508
|
+
dn.init(e, t), w.init(e, t);
|
|
2509
|
+
}), Li = /* @__PURE__ */ u("ZodURL", (e, t) => {
|
|
2510
|
+
hn.init(e, t), w.init(e, t);
|
|
2511
|
+
}), Ui = /* @__PURE__ */ u("ZodEmoji", (e, t) => {
|
|
2512
|
+
pn.init(e, t), w.init(e, t);
|
|
2513
|
+
}), Fi = /* @__PURE__ */ u("ZodNanoID", (e, t) => {
|
|
2514
|
+
mn.init(e, t), w.init(e, t);
|
|
2515
|
+
}), Vi = /* @__PURE__ */ u("ZodCUID", (e, t) => {
|
|
2516
|
+
gn.init(e, t), w.init(e, t);
|
|
2517
|
+
}), qi = /* @__PURE__ */ u("ZodCUID2", (e, t) => {
|
|
2518
|
+
vn.init(e, t), w.init(e, t);
|
|
2519
|
+
}), Ji = /* @__PURE__ */ u("ZodULID", (e, t) => {
|
|
2520
|
+
bn.init(e, t), w.init(e, t);
|
|
2521
|
+
}), Wi = /* @__PURE__ */ u("ZodXID", (e, t) => {
|
|
2522
|
+
_n.init(e, t), w.init(e, t);
|
|
2523
|
+
}), Bi = /* @__PURE__ */ u("ZodKSUID", (e, t) => {
|
|
2524
|
+
wn.init(e, t), w.init(e, t);
|
|
2525
|
+
}), Hi = /* @__PURE__ */ u("ZodIPv4", (e, t) => {
|
|
2526
|
+
$n.init(e, t), w.init(e, t);
|
|
2527
|
+
}), Gi = /* @__PURE__ */ u("ZodIPv6", (e, t) => {
|
|
2528
|
+
Sn.init(e, t), w.init(e, t);
|
|
2529
|
+
}), Ki = /* @__PURE__ */ u("ZodCIDRv4", (e, t) => {
|
|
2530
|
+
On.init(e, t), w.init(e, t);
|
|
2531
|
+
}), Yi = /* @__PURE__ */ u("ZodCIDRv6", (e, t) => {
|
|
2532
|
+
In.init(e, t), w.init(e, t);
|
|
2533
|
+
}), Qi = /* @__PURE__ */ u("ZodBase64", (e, t) => {
|
|
2534
|
+
Zn.init(e, t), w.init(e, t);
|
|
2535
|
+
}), Xi = /* @__PURE__ */ u("ZodBase64URL", (e, t) => {
|
|
2536
|
+
An.init(e, t), w.init(e, t);
|
|
2537
|
+
}), ea = /* @__PURE__ */ u("ZodE164", (e, t) => {
|
|
2538
|
+
Cn.init(e, t), w.init(e, t);
|
|
2539
|
+
}), ta = /* @__PURE__ */ u("ZodJWT", (e, t) => {
|
|
2540
|
+
Nn.init(e, t), w.init(e, t);
|
|
2541
|
+
}), Dt = /* @__PURE__ */ u("ZodNumber", (e, t) => {
|
|
2542
|
+
Ot.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => ei(e, n, o, a), e.gt = (n, o) => e.check(/* @__PURE__ */ Ge(n, o)), e.gte = (n, o) => e.check(/* @__PURE__ */ ve(n, o)), e.min = (n, o) => e.check(/* @__PURE__ */ ve(n, o)), e.lt = (n, o) => e.check(/* @__PURE__ */ He(n, o)), e.lte = (n, o) => e.check(/* @__PURE__ */ ge(n, o)), e.max = (n, o) => e.check(/* @__PURE__ */ ge(n, o)), e.int = (n) => e.check(Qe(n)), e.safe = (n) => e.check(Qe(n)), e.positive = (n) => e.check(/* @__PURE__ */ Ge(0, n)), e.nonnegative = (n) => e.check(/* @__PURE__ */ ve(0, n)), e.negative = (n) => e.check(/* @__PURE__ */ He(0, n)), e.nonpositive = (n) => e.check(/* @__PURE__ */ ge(0, n)), e.multipleOf = (n, o) => e.check(/* @__PURE__ */ Ke(n, o)), e.step = (n, o) => e.check(/* @__PURE__ */ Ke(n, o)), e.finite = () => e;
|
|
2543
|
+
const r = e._zod.bag;
|
|
2544
|
+
e.minValue = Math.max(r.minimum ?? Number.NEGATIVE_INFINITY, r.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(r.maximum ?? Number.POSITIVE_INFINITY, r.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (r.format ?? "").includes("int") || Number.isSafeInteger(r.multipleOf ?? 0.5), e.isFinite = !0, e.format = r.format ?? null;
|
|
2545
|
+
});
|
|
2546
|
+
function le(e) {
|
|
2547
|
+
return /* @__PURE__ */ To(Dt, e);
|
|
2548
|
+
}
|
|
2549
|
+
var ra = /* @__PURE__ */ u("ZodNumberFormat", (e, t) => {
|
|
2550
|
+
Rn.init(e, t), Dt.init(e, t);
|
|
2551
|
+
});
|
|
2552
|
+
function Qe(e) {
|
|
2553
|
+
return /* @__PURE__ */ Ao(ra, e);
|
|
2554
|
+
}
|
|
2555
|
+
var na = /* @__PURE__ */ u("ZodBoolean", (e, t) => {
|
|
2556
|
+
xn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ti(e, r, n, o);
|
|
2557
|
+
});
|
|
2558
|
+
function N(e) {
|
|
2559
|
+
return /* @__PURE__ */ Co(na, e);
|
|
2560
|
+
}
|
|
2561
|
+
var oa = /* @__PURE__ */ u("ZodUnknown", (e, t) => {
|
|
2562
|
+
jn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ni(e, r, n, o);
|
|
2563
|
+
});
|
|
2564
|
+
function Xe() {
|
|
2565
|
+
return /* @__PURE__ */ Po(oa);
|
|
2566
|
+
}
|
|
2567
|
+
var ia = /* @__PURE__ */ u("ZodNever", (e, t) => {
|
|
2568
|
+
Mn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ri(e, r, n, o);
|
|
2569
|
+
});
|
|
2570
|
+
function aa(e) {
|
|
2571
|
+
return /* @__PURE__ */ No(ia, e);
|
|
2572
|
+
}
|
|
2573
|
+
var sa = /* @__PURE__ */ u("ZodArray", (e, t) => {
|
|
2574
|
+
Dn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => si(e, r, n, o), e.element = t.element, e.min = (r, n) => e.check(/* @__PURE__ */ ce(r, n)), e.nonempty = (r) => e.check(/* @__PURE__ */ ce(1, r)), e.max = (r, n) => e.check(/* @__PURE__ */ At(r, n)), e.length = (r, n) => e.check(/* @__PURE__ */ Ct(r, n)), e.unwrap = () => e.element;
|
|
2575
|
+
});
|
|
2576
|
+
function Ce(e, t) {
|
|
2577
|
+
return /* @__PURE__ */ Wo(sa, e, t);
|
|
2578
|
+
}
|
|
2579
|
+
var ca = /* @__PURE__ */ u("ZodObject", (e, t) => {
|
|
2580
|
+
Un.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ci(e, r, n, o), g(e, "shape", () => t.shape), e.keyof = () => O(Object.keys(e._zod.def.shape)), e.catchall = (r) => e.clone({
|
|
2581
|
+
...e._zod.def,
|
|
2582
|
+
catchall: r
|
|
2583
|
+
}), e.passthrough = () => e.clone({
|
|
2584
|
+
...e._zod.def,
|
|
2585
|
+
catchall: Xe()
|
|
2586
|
+
}), e.loose = () => e.clone({
|
|
2587
|
+
...e._zod.def,
|
|
2588
|
+
catchall: Xe()
|
|
2589
|
+
}), e.strict = () => e.clone({
|
|
2590
|
+
...e._zod.def,
|
|
2591
|
+
catchall: aa()
|
|
2592
|
+
}), e.strip = () => e.clone({
|
|
2593
|
+
...e._zod.def,
|
|
2594
|
+
catchall: void 0
|
|
2595
|
+
}), e.extend = (r) => ar(e, r), e.safeExtend = (r) => sr(e, r), e.merge = (r) => cr(e, r), e.pick = (r) => or(e, r), e.omit = (r) => ir(e, r), e.partial = (...r) => ur(Ut, e, r[0]), e.required = (...r) => lr(Ft, e, r[0]);
|
|
2596
|
+
});
|
|
2597
|
+
function T(e, t) {
|
|
2598
|
+
const r = {
|
|
2599
|
+
type: "object",
|
|
2600
|
+
shape: e ?? {},
|
|
2601
|
+
...f(t)
|
|
2602
|
+
};
|
|
2603
|
+
return new ca(r);
|
|
2604
|
+
}
|
|
2605
|
+
var ua = /* @__PURE__ */ u("ZodUnion", (e, t) => {
|
|
2606
|
+
Fn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ui(e, r, n, o), e.options = t.options;
|
|
2607
|
+
});
|
|
2608
|
+
function Lt(e, t) {
|
|
2609
|
+
return new ua({
|
|
2610
|
+
type: "union",
|
|
2611
|
+
options: e,
|
|
2612
|
+
...f(t)
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
var la = /* @__PURE__ */ u("ZodIntersection", (e, t) => {
|
|
2616
|
+
Vn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => li(e, r, n, o);
|
|
2617
|
+
});
|
|
2618
|
+
function da(e, t) {
|
|
2619
|
+
return new la({
|
|
2620
|
+
type: "intersection",
|
|
2621
|
+
left: e,
|
|
2622
|
+
right: t
|
|
2623
|
+
});
|
|
2624
|
+
}
|
|
2625
|
+
var ke = /* @__PURE__ */ u("ZodEnum", (e, t) => {
|
|
2626
|
+
qn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (n, o, a) => oi(e, n, o, a), e.enum = t.entries, e.options = Object.values(t.entries);
|
|
2627
|
+
const r = new Set(Object.keys(t.entries));
|
|
2628
|
+
e.extract = (n, o) => {
|
|
2629
|
+
const a = {};
|
|
2630
|
+
for (const i of n) if (r.has(i)) a[i] = t.entries[i];
|
|
2631
|
+
else throw new Error(`Key ${i} not found in enum`);
|
|
2632
|
+
return new ke({
|
|
2633
|
+
...t,
|
|
2634
|
+
checks: [],
|
|
2635
|
+
...f(o),
|
|
2636
|
+
entries: a
|
|
2637
|
+
});
|
|
2638
|
+
}, e.exclude = (n, o) => {
|
|
2639
|
+
const a = { ...t.entries };
|
|
2640
|
+
for (const i of n) if (r.has(i)) delete a[i];
|
|
2641
|
+
else throw new Error(`Key ${i} not found in enum`);
|
|
2642
|
+
return new ke({
|
|
2643
|
+
...t,
|
|
2644
|
+
checks: [],
|
|
2645
|
+
...f(o),
|
|
2646
|
+
entries: a
|
|
2647
|
+
});
|
|
2648
|
+
};
|
|
2649
|
+
});
|
|
2650
|
+
function O(e, t) {
|
|
2651
|
+
const r = Array.isArray(e) ? Object.fromEntries(e.map((n) => [n, n])) : e;
|
|
2652
|
+
return new ke({
|
|
2653
|
+
type: "enum",
|
|
2654
|
+
entries: r,
|
|
2655
|
+
...f(t)
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
var fa = /* @__PURE__ */ u("ZodTransform", (e, t) => {
|
|
2659
|
+
Jn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ai(e, r, n, o), e._zod.parse = (r, n) => {
|
|
2660
|
+
if (n.direction === "backward") throw new ft(e.constructor.name);
|
|
2661
|
+
r.addIssue = (a) => {
|
|
2662
|
+
if (typeof a == "string") r.issues.push(Y(a, r.value, t));
|
|
2663
|
+
else {
|
|
2664
|
+
const i = a;
|
|
2665
|
+
i.fatal && (i.continue = !1), i.code ?? (i.code = "custom"), i.input ?? (i.input = r.value), i.inst ?? (i.inst = e), r.issues.push(Y(i));
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
const o = t.transform(r.value, r);
|
|
2669
|
+
return o instanceof Promise ? o.then((a) => (r.value = a, r)) : (r.value = o, r);
|
|
2670
|
+
};
|
|
2671
|
+
});
|
|
2672
|
+
function ha(e) {
|
|
2673
|
+
return new fa({
|
|
2674
|
+
type: "transform",
|
|
2675
|
+
transform: e
|
|
2676
|
+
});
|
|
2677
|
+
}
|
|
2678
|
+
var Ut = /* @__PURE__ */ u("ZodOptional", (e, t) => {
|
|
2679
|
+
Tt.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => xt(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2680
|
+
});
|
|
2681
|
+
function et(e) {
|
|
2682
|
+
return new Ut({
|
|
2683
|
+
type: "optional",
|
|
2684
|
+
innerType: e
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
var pa = /* @__PURE__ */ u("ZodExactOptional", (e, t) => {
|
|
2688
|
+
Wn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => xt(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2689
|
+
});
|
|
2690
|
+
function ma(e) {
|
|
2691
|
+
return new pa({
|
|
2692
|
+
type: "optional",
|
|
2693
|
+
innerType: e
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
var ga = /* @__PURE__ */ u("ZodNullable", (e, t) => {
|
|
2697
|
+
Bn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => di(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2698
|
+
});
|
|
2699
|
+
function tt(e) {
|
|
2700
|
+
return new ga({
|
|
2701
|
+
type: "nullable",
|
|
2702
|
+
innerType: e
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
var va = /* @__PURE__ */ u("ZodDefault", (e, t) => {
|
|
2706
|
+
Hn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => hi(e, r, n, o), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
|
|
2707
|
+
});
|
|
2708
|
+
function ba(e, t) {
|
|
2709
|
+
return new va({
|
|
2710
|
+
type: "default",
|
|
2711
|
+
innerType: e,
|
|
2712
|
+
get defaultValue() {
|
|
2713
|
+
return typeof t == "function" ? t() : mt(t);
|
|
2714
|
+
}
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2717
|
+
var _a = /* @__PURE__ */ u("ZodPrefault", (e, t) => {
|
|
2718
|
+
Gn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => pi(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2719
|
+
});
|
|
2720
|
+
function wa(e, t) {
|
|
2721
|
+
return new _a({
|
|
2722
|
+
type: "prefault",
|
|
2723
|
+
innerType: e,
|
|
2724
|
+
get defaultValue() {
|
|
2725
|
+
return typeof t == "function" ? t() : mt(t);
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
var Ft = /* @__PURE__ */ u("ZodNonOptional", (e, t) => {
|
|
2730
|
+
Kn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => fi(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2731
|
+
});
|
|
2732
|
+
function ya(e, t) {
|
|
2733
|
+
return new Ft({
|
|
2734
|
+
type: "nonoptional",
|
|
2735
|
+
innerType: e,
|
|
2736
|
+
...f(t)
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
var za = /* @__PURE__ */ u("ZodCatch", (e, t) => {
|
|
2740
|
+
Yn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => mi(e, r, n, o), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
|
|
2741
|
+
});
|
|
2742
|
+
function ka(e, t) {
|
|
2743
|
+
return new za({
|
|
2744
|
+
type: "catch",
|
|
2745
|
+
innerType: e,
|
|
2746
|
+
catchValue: typeof t == "function" ? t : () => t
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
var Ea = /* @__PURE__ */ u("ZodPipe", (e, t) => {
|
|
2750
|
+
Qn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => gi(e, r, n, o), e.in = t.in, e.out = t.out;
|
|
2751
|
+
});
|
|
2752
|
+
function rt(e, t) {
|
|
2753
|
+
return new Ea({
|
|
2754
|
+
type: "pipe",
|
|
2755
|
+
in: e,
|
|
2756
|
+
out: t
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
var $a = /* @__PURE__ */ u("ZodReadonly", (e, t) => {
|
|
2760
|
+
Xn.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => vi(e, r, n, o), e.unwrap = () => e._zod.def.innerType;
|
|
2761
|
+
});
|
|
2762
|
+
function Sa(e) {
|
|
2763
|
+
return new $a({
|
|
2764
|
+
type: "readonly",
|
|
2765
|
+
innerType: e
|
|
2766
|
+
});
|
|
2767
|
+
}
|
|
2768
|
+
var Vt = /* @__PURE__ */ u("ZodCustom", (e, t) => {
|
|
2769
|
+
eo.init(e, t), z.init(e, t), e._zod.processJSONSchema = (r, n, o) => ii(e, r, n, o);
|
|
2770
|
+
});
|
|
2771
|
+
function Oa(e, t) {
|
|
2772
|
+
return /* @__PURE__ */ Bo(Vt, e ?? (() => !0), t);
|
|
2773
|
+
}
|
|
2774
|
+
function Ia(e, t = {}) {
|
|
2775
|
+
return /* @__PURE__ */ Ho(Vt, e, t);
|
|
2776
|
+
}
|
|
2777
|
+
function Za(e) {
|
|
2778
|
+
return /* @__PURE__ */ Go(e);
|
|
2779
|
+
}
|
|
2780
|
+
var be = /^#[0-9a-fA-F]{6}$/, _e = "Color must be a 6-digit hex code (e.g. '#3B82F6'). Short hex, rgb(), and named colors are not supported.", Pe = T({
|
|
2781
|
+
primaryColor: b().max(20).regex(be, _e).describe("Primary brand color (hex format, e.g., '#3B82F6')").optional(),
|
|
2782
|
+
backgroundColor: b().max(20).regex(be, _e).describe("Background color for the widget container").optional(),
|
|
2783
|
+
textColor: b().max(20).regex(be, _e).describe("Text color").optional(),
|
|
2784
|
+
borderRadius: le().describe("Border radius in pixels").optional(),
|
|
2785
|
+
fontFamily: b().max(100).describe("Font family").optional(),
|
|
2786
|
+
colorScheme: O([
|
|
2787
|
+
"light",
|
|
2788
|
+
"dark",
|
|
2789
|
+
"auto"
|
|
2790
|
+
]).describe("Widget color scheme: 'light' (default), 'dark', or 'auto' (follows the visitor's prefers-color-scheme).").optional()
|
|
2791
|
+
}), us = O([
|
|
2792
|
+
"mobile",
|
|
2793
|
+
"tablet",
|
|
2794
|
+
"desktop"
|
|
2795
|
+
]).describe("Viewport mode: mobile (<480px), tablet (480-768px), desktop (>768px)"), qt = O([
|
|
2796
|
+
"bottom-right",
|
|
2797
|
+
"bottom-left",
|
|
2798
|
+
"inline"
|
|
2799
|
+
]).describe("Widget position on the page"), Ta = T({
|
|
2800
|
+
mobile: le().min(0).max(1e3).describe("Max width for mobile viewport (default: 480)").optional(),
|
|
2801
|
+
tablet: le().min(0).max(2e3).describe("Max width for tablet viewport (default: 768)").optional()
|
|
2802
|
+
}), Aa = T({
|
|
2803
|
+
enabled: N().describe("Enable responsive behavior (default: true)").optional(),
|
|
2804
|
+
breakpoints: Ta.describe("Custom breakpoint values").optional()
|
|
2805
|
+
}), ls = T({
|
|
2806
|
+
theme: Pe.describe("Custom theme configuration").optional(),
|
|
2807
|
+
position: qt.describe("Widget position (default: 'bottom-right')").optional(),
|
|
2808
|
+
open: N().describe("Initial open state (default: false)").optional(),
|
|
2809
|
+
container: Lt([Oa((e) => e instanceof HTMLElement), b().max(200)]).describe("Container element for inline mode").optional(),
|
|
2810
|
+
baseUrl: b().url().max(200).describe("Base URL for the widget embed (default: production URL)").optional(),
|
|
2811
|
+
debug: N().describe("Enable debug logging").optional(),
|
|
2812
|
+
responsive: Aa.describe("Responsive behavior configuration").optional(),
|
|
2813
|
+
showProfile: N().describe("Show profile panel in widget header (default: false)").optional(),
|
|
2814
|
+
language: b().max(10).describe("Language for UI labels (e.g., 'fr', 'en'). Defaults to browser language.").optional(),
|
|
2815
|
+
apiKey: b().max(100).describe("Publishable API key (pk_*) for application authentication"),
|
|
2816
|
+
email: b().email().max(255).describe("Pre-identified user email (host-attested identity)").optional(),
|
|
2817
|
+
userId: b().max(255).describe("Host-side unique user identifier").optional(),
|
|
2818
|
+
userHash: b().max(128).describe("HMAC-SHA256 of email (or userId), signed with identity secret").optional()
|
|
2819
|
+
}), Ca = T({
|
|
2820
|
+
theme: Pe.describe("Full visual theme palette applied by the widget. Admin-configured, no client-side override.").optional(),
|
|
2821
|
+
position: qt.describe("Default launcher position. `inline` only applies when integrator supplies `data-container`.").optional(),
|
|
2822
|
+
language: b().max(10).describe("Locale forced for widget UI labels (ISO 639-1). Falls back to browser language when null.").optional(),
|
|
2823
|
+
showProfile: N().describe("Whether the widget header exposes the profile panel to end-users.").optional(),
|
|
2824
|
+
open: N().describe("Default open state on load. Host can still call `window.Versiq.open()` programmatically.").optional(),
|
|
2825
|
+
brand: T({
|
|
2826
|
+
title: b().max(60).describe("Custom widget header title. Falls back to a vertical-specific default (e.g. 'Versiq Chat' for B2B) when unset.").optional(),
|
|
2827
|
+
avatarUrl: b().url().max(2048).describe("Public URL of the custom widget avatar (PNG or JPEG). MUST originate from the branding-upload endpoint — arbitrary external URLs are rejected at the API boundary.").optional()
|
|
2828
|
+
}).strict().describe("White-label branding overrides (issue #1083 Piste 5). Both fields are optional.").optional()
|
|
2829
|
+
}).strict(), Pa = T({
|
|
2830
|
+
applicationId: b().uuid().describe("Application UUID"),
|
|
2831
|
+
applicationSlug: b().max(100).describe("Application slug (kebab-case)"),
|
|
2832
|
+
applicationName: b().max(200).describe("Application display name"),
|
|
2833
|
+
vertical: b().max(50).describe("Vertical resolved from Application config"),
|
|
2834
|
+
theme: Pe.nullable().describe("Application theme"),
|
|
2835
|
+
allowedOrigins: Ce(b().max(200)).max(50).describe("Allowed origins for this application"),
|
|
2836
|
+
monitoring: N().describe("Monitoring enabled flag"),
|
|
2837
|
+
primaryObjective: T({
|
|
2838
|
+
id: b().uuid(),
|
|
2839
|
+
type: b(),
|
|
2840
|
+
label: b(),
|
|
2841
|
+
ctaLabel: b().nullable()
|
|
2842
|
+
}).nullable().describe("Primary conversion objective"),
|
|
2843
|
+
identityVerificationRequired: N().describe("Whether HMAC identity verification is required"),
|
|
2844
|
+
widget: Ca.nullable().describe("Admin-configured widget runtime config (theme, position, language, showProfile, open). Null when the application has not yet persisted a widget_config JSONB.")
|
|
2845
|
+
}), Na = O(["user", "assistant"]).describe("Message sender role"), ds = T({
|
|
2846
|
+
role: Na.describe("Message sender role"),
|
|
2847
|
+
content: b().max(1e4).describe("Message content (max 10000 characters)")
|
|
2848
|
+
}), Ra = {
|
|
2849
|
+
INIT: "versiq:init",
|
|
2850
|
+
OPEN: "versiq:open",
|
|
2851
|
+
CLOSE: "versiq:close",
|
|
2852
|
+
RESET: "versiq:reset",
|
|
2853
|
+
SET_THEME: "versiq:setTheme",
|
|
2854
|
+
VIEWPORT: "versiq:viewport",
|
|
2855
|
+
IDENTIFY: "versiq:identify",
|
|
2856
|
+
READY: "versiq:ready",
|
|
2857
|
+
PROFILE_UPDATE: "versiq:profile-update",
|
|
2858
|
+
MESSAGE: "versiq:message",
|
|
2859
|
+
QUALIFIED: "versiq:qualified",
|
|
2860
|
+
ERROR: "versiq:error",
|
|
2861
|
+
QUOTA_WARNING: "versiq:quota-warning",
|
|
2862
|
+
QUOTA_EXCEEDED: "versiq:quota-exceeded",
|
|
2863
|
+
FUNNEL_STAGE_CHANGE: "versiq:funnel-stage-change",
|
|
2864
|
+
CTA_SHOWN: "versiq:cta-shown",
|
|
2865
|
+
CTA_CLICKED: "versiq:cta-clicked",
|
|
2866
|
+
LEAD_CAPTURED: "versiq:lead-captured",
|
|
2867
|
+
IDENTITY_VERIFIED: "versiq:identity-verified"
|
|
2868
|
+
}, fs = T({
|
|
2869
|
+
reason: O(["timeout", "error"]).describe("Why the iframe load failed (timeout vs. transport error)"),
|
|
2870
|
+
attempts: le().int().min(1).describe("Total attempts made before giving up (e.g. 3 = 1 + 2 retries)")
|
|
2871
|
+
}).describe("Payload emitted with the widget-unavailable SDK event (#867)"), xa = O([
|
|
2872
|
+
"prospect",
|
|
2873
|
+
"partner",
|
|
2874
|
+
"unknown"
|
|
2875
|
+
]).describe("Type of user"), ja = O([
|
|
2876
|
+
"ecommerce",
|
|
2877
|
+
"real-estate",
|
|
2878
|
+
"automotive",
|
|
2879
|
+
"travel",
|
|
2880
|
+
"recruitment",
|
|
2881
|
+
"other"
|
|
2882
|
+
]).describe("Business sector"), Ma = O([
|
|
2883
|
+
"startup",
|
|
2884
|
+
"pme",
|
|
2885
|
+
"eti",
|
|
2886
|
+
"grand-groupe"
|
|
2887
|
+
]).describe("Company size category"), Da = O([
|
|
2888
|
+
"< 10k",
|
|
2889
|
+
"10k-50k",
|
|
2890
|
+
"50k-200k",
|
|
2891
|
+
"> 200k"
|
|
2892
|
+
]).describe("Monthly website traffic"), La = O([
|
|
2893
|
+
"lead-qualification",
|
|
2894
|
+
"personalization",
|
|
2895
|
+
"cart-abandonment",
|
|
2896
|
+
"conversion",
|
|
2897
|
+
"other"
|
|
2898
|
+
]).describe("Business objective"), Ua = O([
|
|
2899
|
+
"shopify",
|
|
2900
|
+
"woocommerce",
|
|
2901
|
+
"prestashop",
|
|
2902
|
+
"custom",
|
|
2903
|
+
"none"
|
|
2904
|
+
]).describe("E-commerce platform"), Fa = O([
|
|
2905
|
+
"immediate",
|
|
2906
|
+
"1-month",
|
|
2907
|
+
"3-months",
|
|
2908
|
+
"exploring"
|
|
2909
|
+
]).describe("Implementation timeline"), Va = O([
|
|
2910
|
+
"< 500",
|
|
2911
|
+
"500-2000",
|
|
2912
|
+
"2000-5000",
|
|
2913
|
+
"> 5000"
|
|
2914
|
+
]).describe("Monthly budget range in EUR"), hs = T({
|
|
2915
|
+
userType: xa.optional().describe("User type: prospect, partner, or unknown"),
|
|
2916
|
+
sector: ja.optional().describe("Business sector"),
|
|
2917
|
+
companySize: Ma.optional().describe("Company size range"),
|
|
2918
|
+
monthlyTraffic: Da.optional().describe("Monthly website traffic"),
|
|
2919
|
+
objectives: Ce(La).max(5).describe("List of business objectives (max 5)").optional(),
|
|
2920
|
+
platform: Ua.optional().describe("E-commerce platform"),
|
|
2921
|
+
timeline: Fa.optional().describe("Project timeline"),
|
|
2922
|
+
budgetRange: Va.optional().describe("Monthly budget range")
|
|
2923
|
+
}), F = class extends Error {
|
|
2924
|
+
constructor(e, t) {
|
|
2925
|
+
super(e), this.code = t, this.name = "ConfigFetchError";
|
|
2926
|
+
}
|
|
2927
|
+
}, nt = 1e4;
|
|
2928
|
+
async function qa(e, t, r) {
|
|
2929
|
+
const n = t.endsWith("/") ? t : `${t}/`, o = new URL("api/application/config", n), a = new AbortController(), i = setTimeout(() => a.abort(), nt), s = r ? AbortSignal.any([a.signal, r]) : a.signal;
|
|
2930
|
+
let c;
|
|
2931
|
+
try {
|
|
2932
|
+
c = await fetch(o.toString(), {
|
|
2933
|
+
signal: s,
|
|
2934
|
+
headers: { "x-versiq-key": e }
|
|
2935
|
+
});
|
|
2936
|
+
} catch (p) {
|
|
2937
|
+
throw clearTimeout(i), r?.aborted ? new F("Config fetch aborted by caller", "ABORTED") : p instanceof DOMException && p.name === "AbortError" ? new F(`Config fetch timed out after ${nt}ms`, "TIMEOUT") : new F(`Network error fetching application config: ${p instanceof Error ? p.message : String(p)}`, "NETWORK_ERROR");
|
|
2938
|
+
}
|
|
2939
|
+
if (clearTimeout(i), !c.ok) {
|
|
2940
|
+
const p = await c.text().catch(() => "");
|
|
2941
|
+
throw new F(`HTTP ${c.status} fetching application config: ${p}`, `HTTP_${c.status}`);
|
|
2942
|
+
}
|
|
2943
|
+
const l = await c.json(), d = Pa.safeParse(l);
|
|
2944
|
+
if (!d.success) throw new F(`Invalid application config response: ${d.error.message}`, "PARSE_ERROR");
|
|
2945
|
+
return d.data;
|
|
2946
|
+
}
|
|
2947
|
+
var Ja = [1e3, 3e3], J = class extends Error {
|
|
2948
|
+
constructor(e, t) {
|
|
2949
|
+
super(`Iframe load failed after ${t} attempt(s): ${e}`), this.reason = e, this.attempts = t, this.name = "IframeLoadError";
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
function Wa(e, t) {
|
|
2953
|
+
return new Promise((r, n) => {
|
|
2954
|
+
if (t?.aborted) {
|
|
2955
|
+
n(new DOMException("Aborted", "AbortError"));
|
|
2956
|
+
return;
|
|
2957
|
+
}
|
|
2958
|
+
const o = () => {
|
|
2959
|
+
clearTimeout(a), n(new DOMException("Aborted", "AbortError"));
|
|
2960
|
+
}, a = setTimeout(() => {
|
|
2961
|
+
t?.removeEventListener("abort", o), r();
|
|
2962
|
+
}, e);
|
|
2963
|
+
t?.addEventListener("abort", o, { once: !0 });
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
function Ba(e, t) {
|
|
2967
|
+
return new Promise((r, n) => {
|
|
2968
|
+
if (e.signal?.aborted) {
|
|
2969
|
+
n(new DOMException("Aborted", "AbortError"));
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
const o = e.buildIframe(), a = e.timeoutMs ?? 5e3;
|
|
2973
|
+
let i = !1, s = !1, c = !1, l = null, d = null, p = null, h = null, m = null;
|
|
2974
|
+
const v = () => {
|
|
2975
|
+
l !== null && (clearTimeout(l), l = null), d && o.removeEventListener("load", d), p && o.removeEventListener("error", p), h && window.removeEventListener("message", h), m && e.signal?.removeEventListener("abort", m);
|
|
2976
|
+
}, C = () => {
|
|
2977
|
+
v(), !i && o.parentNode && o.parentNode.removeChild(o);
|
|
2978
|
+
}, B = () => {
|
|
2979
|
+
s && c && !i && (i = !0, v(), r(o));
|
|
2980
|
+
};
|
|
2981
|
+
if (d = () => {
|
|
2982
|
+
s = !0, B();
|
|
2983
|
+
}, p = () => {
|
|
2984
|
+
C(), n(new J("error", t + 1));
|
|
2985
|
+
}, h = (P) => {
|
|
2986
|
+
P.source && (P.source && P.source !== o.contentWindow || lt(P.origin, e.allowedOrigins) && dt(P) && P.data.type === Ra.READY && (c = !0, B()));
|
|
2987
|
+
}, m = () => {
|
|
2988
|
+
C(), n(new DOMException("Aborted", "AbortError"));
|
|
2989
|
+
}, o.addEventListener("load", d), o.addEventListener("error", p), window.addEventListener("message", h), e.signal?.addEventListener("abort", m, { once: !0 }), l = setTimeout(() => {
|
|
2990
|
+
C(), n(new J("timeout", t + 1));
|
|
2991
|
+
}, a), e.signal?.aborted) {
|
|
2992
|
+
C(), n(new DOMException("Aborted", "AbortError"));
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
e.container.appendChild(o);
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
async function Ha(e) {
|
|
2999
|
+
const t = e.backoffMs ?? Ja, r = t.length + 1;
|
|
3000
|
+
for (let n = 0; n < r; n++) {
|
|
3001
|
+
e.onStateChange?.({
|
|
3002
|
+
kind: "loading",
|
|
3003
|
+
attempt: n
|
|
3004
|
+
});
|
|
3005
|
+
try {
|
|
3006
|
+
const o = await Ba(e, n);
|
|
3007
|
+
return e.onStateChange?.({
|
|
3008
|
+
kind: "loaded",
|
|
3009
|
+
iframe: o
|
|
3010
|
+
}), o;
|
|
3011
|
+
} catch (o) {
|
|
3012
|
+
if (o instanceof DOMException && o.name === "AbortError") throw o;
|
|
3013
|
+
const a = o instanceof J ? o.reason : "error";
|
|
3014
|
+
if (n === r - 1)
|
|
3015
|
+
throw e.onStateChange?.({
|
|
3016
|
+
kind: "failed",
|
|
3017
|
+
reason: a,
|
|
3018
|
+
attempts: r
|
|
3019
|
+
}), oe(`Iframe load failed permanently after ${r} attempt(s) (reason: ${a})`), new J(a, r);
|
|
3020
|
+
const i = t[n] ?? 1e3;
|
|
3021
|
+
e.onStateChange?.({
|
|
3022
|
+
kind: "retrying",
|
|
3023
|
+
attempt: n + 1,
|
|
3024
|
+
reason: a
|
|
3025
|
+
}), ie(`Iframe load attempt ${n + 1} ${a === "timeout" ? "timed out" : "errored"}, retrying in ${i}ms`), await Wa(i, e.signal);
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
throw new J("error", r);
|
|
3029
|
+
}
|
|
3030
|
+
var Ga = "0.1.0", te = "https://gamaro.io/app", Ka = 0, Ya = {
|
|
3031
|
+
mobile: 480,
|
|
3032
|
+
tablet: 768
|
|
3033
|
+
}, ot = {
|
|
3034
|
+
mobile: {
|
|
3035
|
+
width: "100vw",
|
|
3036
|
+
height: "100vh"
|
|
3037
|
+
},
|
|
3038
|
+
tablet: {
|
|
3039
|
+
width: "90vw",
|
|
3040
|
+
height: "80vh"
|
|
3041
|
+
},
|
|
3042
|
+
desktop: {
|
|
3043
|
+
width: "380px",
|
|
3044
|
+
height: "600px"
|
|
3045
|
+
}
|
|
3046
|
+
}, Qa = 100, Xa = {
|
|
3047
|
+
position: "fixed",
|
|
3048
|
+
zIndex: "999999",
|
|
3049
|
+
border: "none",
|
|
3050
|
+
overflow: "hidden"
|
|
3051
|
+
}, H = `${ut.slow}ms`, it = `${ut.base}ms`, es = [
|
|
3052
|
+
`width ${H} ${M.emphasized}`,
|
|
3053
|
+
`height ${H} ${M.emphasized}`,
|
|
3054
|
+
`border-radius ${H} ${M.emphasized}`,
|
|
3055
|
+
`box-shadow ${H} ${M.emphasized}`,
|
|
3056
|
+
`transform ${H} ${M.emphasized}`
|
|
3057
|
+
].join(", "), ts = [`opacity ${it} ${M.standard}`, `background ${it} ${M.standard}`].join(", ");
|
|
3058
|
+
function at() {
|
|
3059
|
+
return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
3060
|
+
}
|
|
3061
|
+
var re = {
|
|
3062
|
+
"bottom-right": {
|
|
3063
|
+
bottom: "20px",
|
|
3064
|
+
right: "20px"
|
|
3065
|
+
},
|
|
3066
|
+
"bottom-left": {
|
|
3067
|
+
bottom: "20px",
|
|
3068
|
+
left: "20px"
|
|
3069
|
+
}
|
|
3070
|
+
}, rs = {
|
|
3071
|
+
width: "100%",
|
|
3072
|
+
height: "100%",
|
|
3073
|
+
border: "none",
|
|
3074
|
+
backgroundColor: "transparent"
|
|
3075
|
+
}, ns = class {
|
|
3076
|
+
get applicationId() {
|
|
3077
|
+
return this._applicationId;
|
|
3078
|
+
}
|
|
3079
|
+
constructor(e) {
|
|
3080
|
+
this.version = Ga, this.iframe = null, this.container = null, this.skeletonButton = null, this.isOpen = !1, this.isReady = !1, this.isInitialized = !1, this.isDestroyed = !1, this.fetchAbortController = null, this.iframeLoadAbortController = null, this._applicationId = "", this.vertical = "", this.pendingCommands = [], this.eventHandlers = /* @__PURE__ */ new Map(), this.cleanupListener = null, this.currentViewportMode = "desktop", this.mobileMediaQuery = null, this.tabletMediaQuery = null, this.debounceTimer = null, this.viewportChangeHandler = null, this.originalConfig = { ...e }, this.config = {
|
|
3081
|
+
position: "bottom-right",
|
|
3082
|
+
open: !1,
|
|
3083
|
+
baseUrl: te,
|
|
3084
|
+
debug: !1,
|
|
3085
|
+
...e
|
|
3086
|
+
}, this.instanceId = ++Ka, this.debugLog = Bt(this.config.debug ?? !1), this.renderSkeleton(), this.resolveConfig();
|
|
3087
|
+
}
|
|
3088
|
+
renderSkeleton() {
|
|
3089
|
+
this.config.position !== "inline" && (this.container = this.createContainer(), this.renderSkeletonInto(this.container), document.body.appendChild(this.container));
|
|
3090
|
+
}
|
|
3091
|
+
renderSkeletonInto(e) {
|
|
3092
|
+
const t = document.createElement("button");
|
|
3093
|
+
return t.type = "button", t.setAttribute("aria-label", "Loading widget…"), t.style.cssText = [
|
|
3094
|
+
"width: 100%",
|
|
3095
|
+
"height: 100%",
|
|
3096
|
+
"border: none",
|
|
3097
|
+
"border-radius: 50%",
|
|
3098
|
+
"background: #9ca3af",
|
|
3099
|
+
"cursor: default",
|
|
3100
|
+
"opacity: 0.6",
|
|
3101
|
+
`transition: ${at() ? "none" : ts}`
|
|
3102
|
+
].join(";"), e.appendChild(t), this.skeletonButton = t, t;
|
|
3103
|
+
}
|
|
3104
|
+
setSkeletonStateUnavailable() {
|
|
3105
|
+
this.skeletonButton && (this.skeletonButton.dataset.state = "unavailable", this.skeletonButton.style.transition = "none", this.skeletonButton.style.opacity = "0.4", this.skeletonButton.style.cursor = "not-allowed", this.skeletonButton.setAttribute("aria-label", "Widget temporarily unavailable"));
|
|
3106
|
+
}
|
|
3107
|
+
resolveConfig() {
|
|
3108
|
+
const e = this.config.baseUrl ?? te;
|
|
3109
|
+
this.fetchAbortController = new AbortController();
|
|
3110
|
+
const t = (r) => qa(this.config.apiKey, e, this.fetchAbortController?.signal).then((n) => this.applyServerConfig(n)).catch((n) => {
|
|
3111
|
+
const o = n instanceof F ? n.code : "UNKNOWN_ERROR", a = n instanceof Error ? n.message : "Unknown config fetch error";
|
|
3112
|
+
if (!(o === "ABORTED" || this.isDestroyed)) {
|
|
3113
|
+
if (r === 0 && this.isTransientFetchError(o))
|
|
3114
|
+
return ie(`Config fetch failed transiently (${o}), retrying after 1s backoff`), new Promise((i) => setTimeout(() => {
|
|
3115
|
+
this.isDestroyed || i(t(1));
|
|
3116
|
+
}, 1e3));
|
|
3117
|
+
oe(`Config fetch failed — widget stays in degraded mode: ${a}`), this.emit("error", {
|
|
3118
|
+
code: o,
|
|
3119
|
+
message: a
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
t(0);
|
|
3124
|
+
}
|
|
3125
|
+
isTransientFetchError(e) {
|
|
3126
|
+
return e === "NETWORK_ERROR" || e === "TIMEOUT" || e.startsWith("HTTP_5");
|
|
3127
|
+
}
|
|
3128
|
+
applyServerConfig(e) {
|
|
3129
|
+
if (this.isDestroyed) return;
|
|
3130
|
+
this._applicationId = e.applicationId, this.vertical = e.vertical;
|
|
3131
|
+
const t = e.widget ?? {};
|
|
3132
|
+
this.config = {
|
|
3133
|
+
...this.config,
|
|
3134
|
+
theme: {
|
|
3135
|
+
...e.theme ?? {},
|
|
3136
|
+
...t.theme ?? {},
|
|
3137
|
+
...this.originalConfig.theme ?? {}
|
|
3138
|
+
},
|
|
3139
|
+
position: this.originalConfig.position ?? t.position ?? this.config.position,
|
|
3140
|
+
language: this.originalConfig.language ?? t.language ?? this.config.language,
|
|
3141
|
+
showProfile: this.originalConfig.showProfile ?? t.showProfile ?? this.config.showProfile,
|
|
3142
|
+
open: this.originalConfig.open ?? t.open ?? this.config.open
|
|
3143
|
+
}, this.init().then(() => ie(`Widget v${this.version} ready (app: ${e.applicationSlug})`));
|
|
3144
|
+
}
|
|
3145
|
+
flushPendingCommands() {
|
|
3146
|
+
const e = this.pendingCommands;
|
|
3147
|
+
this.pendingCommands = [], e.forEach((t) => t());
|
|
3148
|
+
}
|
|
3149
|
+
async init() {
|
|
3150
|
+
if (this.isDestroyed) return;
|
|
3151
|
+
this.container?.remove(), this.skeletonButton = null, this.container = this.createContainer();
|
|
3152
|
+
let e = null;
|
|
3153
|
+
this.config.position !== "inline" && (e = this.renderSkeletonInto(this.container)), this.attachContainerToDom(), this.iframeLoadAbortController = new AbortController();
|
|
3154
|
+
let t;
|
|
3155
|
+
try {
|
|
3156
|
+
t = await Ha({
|
|
3157
|
+
buildIframe: () => this.createIframe(),
|
|
3158
|
+
container: this.container,
|
|
3159
|
+
allowedOrigins: [this.resolveReadyOrigin()],
|
|
3160
|
+
signal: this.iframeLoadAbortController.signal,
|
|
3161
|
+
onStateChange: (r) => {
|
|
3162
|
+
r.kind === "failed" && this.setSkeletonStateUnavailable();
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
} catch (r) {
|
|
3166
|
+
if (this.isDestroyed || r instanceof DOMException && r.name === "AbortError") return;
|
|
3167
|
+
r instanceof J ? (this.emit("widget-unavailable", {
|
|
3168
|
+
reason: r.reason,
|
|
3169
|
+
attempts: r.attempts
|
|
3170
|
+
}), this.emit("error", {
|
|
3171
|
+
code: "IFRAME_UNAVAILABLE",
|
|
3172
|
+
message: `Iframe load failed after ${r.attempts} attempt(s): ${r.reason}`
|
|
3173
|
+
})) : this.emit("error", {
|
|
3174
|
+
code: "IFRAME_UNAVAILABLE",
|
|
3175
|
+
message: r instanceof Error ? r.message : String(r)
|
|
3176
|
+
});
|
|
3177
|
+
return;
|
|
3178
|
+
}
|
|
3179
|
+
if (this.isDestroyed) {
|
|
3180
|
+
t.remove();
|
|
3181
|
+
return;
|
|
3182
|
+
}
|
|
3183
|
+
this.iframe = t, e?.remove(), this.skeletonButton = null, this.isReady = !0, this.sendConfig(), this.emit("ready", void 0), this.cleanupListener = Kt({
|
|
3184
|
+
onMessage: (r) => this.handleMessage(r),
|
|
3185
|
+
debug: this.config.debug,
|
|
3186
|
+
sourceWindow: this.iframe.contentWindow,
|
|
3187
|
+
allowedOrigins: [this.resolveReadyOrigin()]
|
|
3188
|
+
}), this.config.open && (this.isOpen = !0, this.updateVisibility()), this.setupViewportListener(), this.isInitialized = !0, this.flushPendingCommands(), this.log("Widget initialized", this.config);
|
|
3189
|
+
}
|
|
3190
|
+
resolveReadyOrigin() {
|
|
3191
|
+
const e = this.config.baseUrl ?? te;
|
|
3192
|
+
try {
|
|
3193
|
+
return new URL(e).origin;
|
|
3194
|
+
} catch {
|
|
3195
|
+
return e;
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
attachContainerToDom() {
|
|
3199
|
+
this.container && (this.config.position === "inline" && this.config.container ? (typeof this.config.container == "string" ? document.querySelector(this.config.container) : this.config.container)?.appendChild(this.container) : document.body.appendChild(this.container));
|
|
3200
|
+
}
|
|
3201
|
+
createContainer() {
|
|
3202
|
+
const e = document.createElement("div");
|
|
3203
|
+
if (e.id = `versiq-widget-container-${this.instanceId}`, this.config.position === "inline") Object.assign(e.style, {
|
|
3204
|
+
position: "relative",
|
|
3205
|
+
width: "100%",
|
|
3206
|
+
height: "100%",
|
|
3207
|
+
border: "none",
|
|
3208
|
+
borderRadius: "16px",
|
|
3209
|
+
overflow: "hidden",
|
|
3210
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)"
|
|
3211
|
+
});
|
|
3212
|
+
else {
|
|
3213
|
+
Object.assign(e.style, Xa);
|
|
3214
|
+
const t = re[this.config.position ?? "bottom-right"];
|
|
3215
|
+
Object.assign(e.style, t), e.style.width = "60px", e.style.height = "60px", e.style.borderRadius = "50%";
|
|
3216
|
+
}
|
|
3217
|
+
return e;
|
|
3218
|
+
}
|
|
3219
|
+
createIframe() {
|
|
3220
|
+
const e = document.createElement("iframe");
|
|
3221
|
+
return e.id = `versiq-widget-iframe-${this.instanceId}`, e.src = this.buildIframeUrl(), e.setAttribute("title", "Versiq Chat Widget"), e.setAttribute("allow", "clipboard-write; geolocation"), Object.assign(e.style, rs), e;
|
|
3222
|
+
}
|
|
3223
|
+
buildIframeUrl() {
|
|
3224
|
+
const e = this.config.baseUrl ?? te, t = new URL("/app/widget/embed", e);
|
|
3225
|
+
return this.vertical && t.searchParams.set("vertical", this.vertical), this.config.theme && t.searchParams.set("theme", Yt(this.config.theme)), this.config.position === "inline" && t.searchParams.set("mode", "inline"), this.config.open && t.searchParams.set("open", "true"), this.config.showProfile && t.searchParams.set("showProfile", "true"), this.config.language && t.searchParams.set("language", this.config.language), this.config.apiKey && t.searchParams.set("apiKey", this.config.apiKey), t.searchParams.set("hostOrigin", window.location.origin), t.toString();
|
|
3226
|
+
}
|
|
3227
|
+
setupViewportListener() {
|
|
3228
|
+
if (this.config.position === "inline" || this.config.responsive?.enabled === !1) return;
|
|
3229
|
+
const e = {
|
|
3230
|
+
...Ya,
|
|
3231
|
+
...this.config.responsive?.breakpoints
|
|
3232
|
+
};
|
|
3233
|
+
this.mobileMediaQuery = window.matchMedia(`(max-width: ${e.mobile}px)`), this.tabletMediaQuery = window.matchMedia(`(max-width: ${e.tablet}px)`), this.viewportChangeHandler = () => this.handleViewportChange(), this.mobileMediaQuery.addEventListener("change", this.viewportChangeHandler), this.tabletMediaQuery.addEventListener("change", this.viewportChangeHandler), this.currentViewportMode = this.getViewportMode(), this.log("Initial viewport mode:", this.currentViewportMode);
|
|
3234
|
+
}
|
|
3235
|
+
handleViewportChange() {
|
|
3236
|
+
this.debounceTimer && clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => {
|
|
3237
|
+
const e = this.getViewportMode();
|
|
3238
|
+
e !== this.currentViewportMode && (this.currentViewportMode = e, this.log("Viewport changed:", e), this.isOpen && this.updateContainerForViewport(e), this.iframe && this.isReady && j(this.iframe, {
|
|
3239
|
+
type: "versiq:viewport",
|
|
3240
|
+
mode: e
|
|
3241
|
+
}, this.resolveReadyOrigin()));
|
|
3242
|
+
}, Qa);
|
|
3243
|
+
}
|
|
3244
|
+
getViewportMode() {
|
|
3245
|
+
return this.mobileMediaQuery?.matches ? "mobile" : this.tabletMediaQuery?.matches ? "tablet" : "desktop";
|
|
3246
|
+
}
|
|
3247
|
+
applyContainerTransition() {
|
|
3248
|
+
this.container && (this.container.style.transition = at() ? "none" : es);
|
|
3249
|
+
}
|
|
3250
|
+
updateContainerForViewport(e) {
|
|
3251
|
+
if (!this.container) return;
|
|
3252
|
+
this.applyContainerTransition();
|
|
3253
|
+
const t = ot[e];
|
|
3254
|
+
if (e === "mobile") Object.assign(this.container.style, {
|
|
3255
|
+
width: t.width,
|
|
3256
|
+
height: t.height,
|
|
3257
|
+
inset: "0",
|
|
3258
|
+
bottom: "auto",
|
|
3259
|
+
right: "auto",
|
|
3260
|
+
left: "auto",
|
|
3261
|
+
borderRadius: "0",
|
|
3262
|
+
maxWidth: "none",
|
|
3263
|
+
transform: "none"
|
|
3264
|
+
});
|
|
3265
|
+
else if (e === "tablet") {
|
|
3266
|
+
const r = re[this.config.position ?? "bottom-right"];
|
|
3267
|
+
Object.assign(this.container.style, {
|
|
3268
|
+
width: t.width,
|
|
3269
|
+
height: t.height,
|
|
3270
|
+
inset: "auto",
|
|
3271
|
+
maxWidth: "500px",
|
|
3272
|
+
borderRadius: "16px",
|
|
3273
|
+
left: "50%",
|
|
3274
|
+
right: "auto",
|
|
3275
|
+
transform: "translateX(-50%)",
|
|
3276
|
+
bottom: r.bottom ?? "20px"
|
|
3277
|
+
});
|
|
3278
|
+
} else {
|
|
3279
|
+
const r = re[this.config.position ?? "bottom-right"];
|
|
3280
|
+
Object.assign(this.container.style, {
|
|
3281
|
+
width: t.width,
|
|
3282
|
+
height: t.height,
|
|
3283
|
+
inset: "auto",
|
|
3284
|
+
maxWidth: "none",
|
|
3285
|
+
borderRadius: "16px",
|
|
3286
|
+
transform: "none",
|
|
3287
|
+
...r
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
handleMessage(e) {
|
|
3292
|
+
switch (this.log("Received event:", e), e.type) {
|
|
3293
|
+
case "versiq:ready":
|
|
3294
|
+
if (this.isReady) break;
|
|
3295
|
+
this.isReady = !0, this.sendConfig(), this.emit("ready", void 0);
|
|
3296
|
+
break;
|
|
3297
|
+
case "versiq:profile-update":
|
|
3298
|
+
this.emit("profile-update", void 0);
|
|
3299
|
+
break;
|
|
3300
|
+
case "versiq:message":
|
|
3301
|
+
this.emit("message", e.message);
|
|
3302
|
+
break;
|
|
3303
|
+
case "versiq:qualified":
|
|
3304
|
+
this.emit("qualified", void 0);
|
|
3305
|
+
break;
|
|
3306
|
+
case "versiq:error":
|
|
3307
|
+
this.emit("error", {
|
|
3308
|
+
code: e.code,
|
|
3309
|
+
message: e.message
|
|
3310
|
+
});
|
|
3311
|
+
break;
|
|
3312
|
+
case "versiq:open":
|
|
3313
|
+
this.isOpen = !0, this.updateVisibility(), this.emit("open", void 0);
|
|
3314
|
+
break;
|
|
3315
|
+
case "versiq:close":
|
|
3316
|
+
this.isOpen = !1, this.updateVisibility(), this.emit("close", void 0);
|
|
3317
|
+
break;
|
|
3318
|
+
case "versiq:quota-warning":
|
|
3319
|
+
this.emit("quota-warning", {
|
|
3320
|
+
remaining: e.remaining,
|
|
3321
|
+
limit: e.limit
|
|
3322
|
+
});
|
|
3323
|
+
break;
|
|
3324
|
+
case "versiq:quota-exceeded":
|
|
3325
|
+
this.emit("quota-exceeded", void 0);
|
|
3326
|
+
break;
|
|
3327
|
+
case "versiq:identity-verified":
|
|
3328
|
+
this.emit("identity-verified", {
|
|
3329
|
+
email: e.email,
|
|
3330
|
+
userId: e.userId
|
|
3331
|
+
});
|
|
3332
|
+
break;
|
|
3333
|
+
case "versiq:funnel-stage-change":
|
|
3334
|
+
this.emit("funnel-stage-change", {
|
|
3335
|
+
stage: e.stage,
|
|
3336
|
+
previousStage: e.previousStage
|
|
3337
|
+
});
|
|
3338
|
+
break;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
sendConfig() {
|
|
3342
|
+
if (!this.iframe || !this.isReady) return;
|
|
3343
|
+
const { container: e, ...t } = this.config, r = {
|
|
3344
|
+
type: "versiq:init",
|
|
3345
|
+
config: t
|
|
3346
|
+
};
|
|
3347
|
+
j(this.iframe, r, this.resolveReadyOrigin());
|
|
3348
|
+
}
|
|
3349
|
+
updateVisibility() {
|
|
3350
|
+
if (this.container && this.config.position !== "inline")
|
|
3351
|
+
if (this.applyContainerTransition(), this.isOpen) {
|
|
3352
|
+
if (this.config.responsive?.enabled !== !1) this.updateContainerForViewport(this.currentViewportMode);
|
|
3353
|
+
else {
|
|
3354
|
+
const e = ot.desktop;
|
|
3355
|
+
this.container.style.width = e.width, this.container.style.height = e.height, this.container.style.borderRadius = "16px";
|
|
3356
|
+
}
|
|
3357
|
+
this.container.style.boxShadow = "0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05)";
|
|
3358
|
+
} else {
|
|
3359
|
+
const e = re[this.config.position ?? "bottom-right"];
|
|
3360
|
+
Object.assign(this.container.style, {
|
|
3361
|
+
width: "60px",
|
|
3362
|
+
height: "60px",
|
|
3363
|
+
borderRadius: "50%",
|
|
3364
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
3365
|
+
inset: "auto",
|
|
3366
|
+
maxWidth: "none",
|
|
3367
|
+
transform: "none",
|
|
3368
|
+
...e
|
|
3369
|
+
});
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
emit(e, t) {
|
|
3373
|
+
const r = this.eventHandlers.get(e);
|
|
3374
|
+
r && r.forEach((n) => {
|
|
3375
|
+
try {
|
|
3376
|
+
n(t);
|
|
3377
|
+
} catch (o) {
|
|
3378
|
+
oe(`Error in event handler for "${e}":`, o);
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3382
|
+
open() {
|
|
3383
|
+
if (!this.isInitialized) {
|
|
3384
|
+
this.pendingCommands.push(() => this.open());
|
|
3385
|
+
return;
|
|
3386
|
+
}
|
|
3387
|
+
this.iframe && (this.isOpen = !0, this.updateVisibility(), this.isReady && j(this.iframe, { type: "versiq:open" }, this.resolveReadyOrigin()));
|
|
3388
|
+
}
|
|
3389
|
+
close() {
|
|
3390
|
+
if (!this.isInitialized) {
|
|
3391
|
+
this.pendingCommands.push(() => this.close());
|
|
3392
|
+
return;
|
|
3393
|
+
}
|
|
3394
|
+
this.iframe && (this.isOpen = !1, this.updateVisibility(), this.isReady && j(this.iframe, { type: "versiq:close" }, this.resolveReadyOrigin()));
|
|
3395
|
+
}
|
|
3396
|
+
reset() {
|
|
3397
|
+
if (!this.isInitialized) {
|
|
3398
|
+
this.pendingCommands.push(() => this.reset());
|
|
3399
|
+
return;
|
|
3400
|
+
}
|
|
3401
|
+
!this.iframe || !this.isReady || j(this.iframe, { type: "versiq:reset" }, this.resolveReadyOrigin());
|
|
3402
|
+
}
|
|
3403
|
+
identify(e) {
|
|
3404
|
+
if (this.config = {
|
|
3405
|
+
...this.config,
|
|
3406
|
+
email: e.email,
|
|
3407
|
+
userId: e.userId,
|
|
3408
|
+
userHash: e.userHash
|
|
3409
|
+
}, !this.isInitialized) {
|
|
3410
|
+
this.pendingCommands.push(() => this.identify(e));
|
|
3411
|
+
return;
|
|
3412
|
+
}
|
|
3413
|
+
this.iframe && this.isReady && j(this.iframe, {
|
|
3414
|
+
type: "versiq:identify",
|
|
3415
|
+
email: e.email,
|
|
3416
|
+
userId: e.userId,
|
|
3417
|
+
userHash: e.userHash
|
|
3418
|
+
}, this.resolveReadyOrigin());
|
|
3419
|
+
}
|
|
3420
|
+
setTheme(e) {
|
|
3421
|
+
if (this.config.theme = {
|
|
3422
|
+
...this.config.theme,
|
|
3423
|
+
...e
|
|
3424
|
+
}, !this.isInitialized) {
|
|
3425
|
+
this.pendingCommands.push(() => this.setTheme(e));
|
|
3426
|
+
return;
|
|
3427
|
+
}
|
|
3428
|
+
this.iframe && this.isReady && j(this.iframe, {
|
|
3429
|
+
type: "versiq:setTheme",
|
|
3430
|
+
theme: this.config.theme
|
|
3431
|
+
}, this.resolveReadyOrigin());
|
|
3432
|
+
}
|
|
3433
|
+
setColorScheme(e) {
|
|
3434
|
+
this.setTheme({ colorScheme: e });
|
|
3435
|
+
}
|
|
3436
|
+
on(e, t) {
|
|
3437
|
+
this.eventHandlers.has(e) || this.eventHandlers.set(e, /* @__PURE__ */ new Set()), this.eventHandlers.get(e).add(t);
|
|
3438
|
+
}
|
|
3439
|
+
off(e, t) {
|
|
3440
|
+
const r = this.eventHandlers.get(e);
|
|
3441
|
+
r && r.delete(t);
|
|
3442
|
+
}
|
|
3443
|
+
destroy() {
|
|
3444
|
+
this.isDestroyed || (this.isDestroyed = !0, this.fetchAbortController?.abort(), this.fetchAbortController = null, this.iframeLoadAbortController?.abort(), this.iframeLoadAbortController = null, this.cleanupListener?.(), this.viewportChangeHandler && (this.mobileMediaQuery?.removeEventListener("change", this.viewportChangeHandler), this.tabletMediaQuery?.removeEventListener("change", this.viewportChangeHandler), this.viewportChangeHandler = null), this.debounceTimer && (clearTimeout(this.debounceTimer), this.debounceTimer = null), this.container?.remove(), this.iframe = null, this.container = null, this.skeletonButton = null, this.mobileMediaQuery = null, this.tabletMediaQuery = null, this.eventHandlers.clear(), this.pendingCommands = []);
|
|
3445
|
+
}
|
|
3446
|
+
log(e, ...t) {
|
|
3447
|
+
const r = t.map((n) => {
|
|
3448
|
+
if (n == null || typeof n != "object") return n;
|
|
3449
|
+
if (n instanceof HTMLElement) return `[HTMLElement: ${n.tagName}]`;
|
|
3450
|
+
try {
|
|
3451
|
+
const o = /* @__PURE__ */ new WeakSet();
|
|
3452
|
+
return JSON.parse(JSON.stringify(n, (a, i) => {
|
|
3453
|
+
if (i instanceof HTMLElement) return `[HTMLElement: ${i.tagName}]`;
|
|
3454
|
+
if (typeof i == "object" && i !== null) {
|
|
3455
|
+
if (o.has(i)) return "[Circular]";
|
|
3456
|
+
o.add(i);
|
|
3457
|
+
}
|
|
3458
|
+
return i;
|
|
3459
|
+
}));
|
|
3460
|
+
} catch {
|
|
3461
|
+
return "[Unserializable]";
|
|
3462
|
+
}
|
|
3463
|
+
});
|
|
3464
|
+
this.debugLog(e, ...r);
|
|
3465
|
+
}
|
|
3466
|
+
};
|
|
3467
|
+
function os(e) {
|
|
3468
|
+
return new ns(e);
|
|
3469
|
+
}
|
|
3470
|
+
var Ee = /* @__PURE__ */ new WeakSet();
|
|
3471
|
+
function is(e) {
|
|
3472
|
+
const t = e.getAttribute("data-api-key") ?? void 0;
|
|
3473
|
+
if (!t)
|
|
3474
|
+
return oe("Missing required data-api-key attribute on script tag"), null;
|
|
3475
|
+
const r = e.dataset.container, n = e.dataset.baseUrl, o = e.dataset.debug === "true", a = e.dataset.email, i = e.getAttribute("data-user-id") ?? void 0, s = e.getAttribute("data-user-hash") ?? void 0;
|
|
3476
|
+
return {
|
|
3477
|
+
apiKey: t,
|
|
3478
|
+
container: r,
|
|
3479
|
+
baseUrl: n,
|
|
3480
|
+
debug: o,
|
|
3481
|
+
...a && { email: a },
|
|
3482
|
+
...i && { userId: i },
|
|
3483
|
+
...s && { userHash: s }
|
|
3484
|
+
};
|
|
3485
|
+
}
|
|
3486
|
+
function as() {
|
|
3487
|
+
if (document.currentScript instanceof HTMLScriptElement) return document.currentScript;
|
|
3488
|
+
const e = document.querySelectorAll("script[src]");
|
|
3489
|
+
for (const t of e) {
|
|
3490
|
+
const r = t.src.toLowerCase();
|
|
3491
|
+
if (r.includes("versiq") || r.includes("widget")) return t;
|
|
3492
|
+
}
|
|
3493
|
+
return null;
|
|
3494
|
+
}
|
|
3495
|
+
function st() {
|
|
3496
|
+
const e = document.querySelectorAll("script[data-api-key]");
|
|
3497
|
+
if (e.length === 0) {
|
|
3498
|
+
const t = as();
|
|
3499
|
+
t && t.hasAttribute("data-api-key") && !Ee.has(t) && ct(t);
|
|
3500
|
+
return;
|
|
3501
|
+
}
|
|
3502
|
+
for (const t of e) ct(t);
|
|
3503
|
+
}
|
|
3504
|
+
function ct(e) {
|
|
3505
|
+
if (Ee.has(e)) return;
|
|
3506
|
+
Ee.add(e);
|
|
3507
|
+
const t = is(e);
|
|
3508
|
+
if (!t) return;
|
|
3509
|
+
const r = os(t);
|
|
3510
|
+
window.Versiq || (window.Versiq = r), window.VersiqApps || (window.VersiqApps = /* @__PURE__ */ new Map()), r.on("ready", () => {
|
|
3511
|
+
r.applicationId && window.VersiqApps && window.VersiqApps.set(r.applicationId, r);
|
|
3512
|
+
}), ie(`Widget v${r.version} initializing...`);
|
|
3513
|
+
}
|
|
3514
|
+
typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", st) : st());
|
|
3515
|
+
export {
|
|
3516
|
+
F as ConfigFetchError,
|
|
3517
|
+
ns as VersiqWidget,
|
|
3518
|
+
st as __autoInit,
|
|
3519
|
+
as as __getCurrentScript,
|
|
3520
|
+
is as __parseScriptAttributes,
|
|
3521
|
+
Pa as applicationConfigResponseSchema,
|
|
3522
|
+
hs as b2bProfileSchema,
|
|
3523
|
+
os as createWidget,
|
|
3524
|
+
qa as fetchApplicationConfig,
|
|
3525
|
+
Pe as themeConfigSchema,
|
|
3526
|
+
ls as widgetConfigSchema,
|
|
3527
|
+
ds as widgetMessageSchema,
|
|
3528
|
+
qt as widgetPositionSchema
|
|
3529
|
+
};
|