@resenty/widget 0.0.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 +21 -0
- package/README.md +32 -0
- package/dist/chunks/chat-CJ6R7eoG.js +592 -0
- package/dist/chunks/chat-CZS20945.js +54622 -0
- package/dist/chunks/core-Cpyk9a29.js +214 -0
- package/dist/chunks/index-Df7cNTmq.js +348 -0
- package/dist/chunks/query-common-D_G8O-M_.js +7754 -0
- package/dist/chunks/react-dom-B4CdVWWC.js +1176 -0
- package/dist/chunks/react-root-BBU2MuNT.js +5 -0
- package/dist/chunks/react-root-ChAKSfvh.js +18956 -0
- package/dist/chunks/rolldown-runtime-B_fQOXul.js +11 -0
- package/dist/chunks/schemas-B2StEWw-.js +4326 -0
- package/dist/chunks/ui-common-DfZ7eP4u.js +2372 -0
- package/dist/chunks/ui-f9sPMhJV.js +135 -0
- package/dist/chunks/vendor-CAJw9nfJ.js +68985 -0
- package/dist/resenty.js +676 -0
- package/dist/styles/resenty.css +2 -0
- package/package.json +94 -0
|
@@ -0,0 +1,4326 @@
|
|
|
1
|
+
const createClientConfig = (u) => ({
|
|
2
|
+
...u,
|
|
3
|
+
baseUrl: "https://api.resenty.com/__internal"
|
|
4
|
+
}), jsonBodySerializer = { bodySerializer: (u) => JSON.stringify(u, (u, z) => typeof z == "bigint" ? z.toString() : z) };
|
|
5
|
+
Object.entries({
|
|
6
|
+
$body_: "body",
|
|
7
|
+
$headers_: "headers",
|
|
8
|
+
$path_: "path",
|
|
9
|
+
$query_: "query"
|
|
10
|
+
});
|
|
11
|
+
const createSseClient = ({ onRequest: u, onSseError: z, onSseEvent: B, responseTransformer: V, responseValidator: H, sseDefaultRetryDelay: U, sseMaxRetryAttempts: W, sseMaxRetryDelay: G, sseSleepFn: K, url: q,...J }) => {
|
|
12
|
+
let Y, X = K ?? ((u) => new Promise((z) => setTimeout(z, u)));
|
|
13
|
+
return { stream: async function* () {
|
|
14
|
+
let K = U ?? 3e3, Z = 0, Q = J.signal ?? new AbortController().signal;
|
|
15
|
+
for (; !Q.aborted;) {
|
|
16
|
+
Z++;
|
|
17
|
+
let U = J.headers instanceof Headers ? J.headers : new Headers(J.headers);
|
|
18
|
+
Y !== void 0 && U.set("Last-Event-ID", Y);
|
|
19
|
+
try {
|
|
20
|
+
let z = {
|
|
21
|
+
redirect: "follow",
|
|
22
|
+
...J,
|
|
23
|
+
body: J.serializedBody,
|
|
24
|
+
headers: U,
|
|
25
|
+
signal: Q
|
|
26
|
+
}, W = new Request(q, z);
|
|
27
|
+
u && (W = await u(q, z));
|
|
28
|
+
let G = await (J.fetch ?? globalThis.fetch)(W);
|
|
29
|
+
if (!G.ok) throw Error(`SSE failed: ${G.status} ${G.statusText}`);
|
|
30
|
+
if (!G.body) throw Error("No body in SSE response");
|
|
31
|
+
let X = G.body.pipeThrough(new TextDecoderStream()).getReader(), Z = "", $ = () => {
|
|
32
|
+
try {
|
|
33
|
+
X.cancel();
|
|
34
|
+
} catch {}
|
|
35
|
+
};
|
|
36
|
+
Q.addEventListener("abort", $);
|
|
37
|
+
try {
|
|
38
|
+
for (;;) {
|
|
39
|
+
let { done: u, value: z } = await X.read();
|
|
40
|
+
if (u) break;
|
|
41
|
+
Z += z, Z = Z.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
42
|
+
let U = Z.split("\n\n");
|
|
43
|
+
Z = U.pop() ?? "";
|
|
44
|
+
for (let u of U) {
|
|
45
|
+
let z = u.split("\n"), U = [], W;
|
|
46
|
+
for (let u of z) if (u.startsWith("data:")) U.push(u.replace(/^data:\s*/, ""));
|
|
47
|
+
else if (u.startsWith("event:")) W = u.replace(/^event:\s*/, "");
|
|
48
|
+
else if (u.startsWith("id:")) Y = u.replace(/^id:\s*/, "");
|
|
49
|
+
else if (u.startsWith("retry:")) {
|
|
50
|
+
let z = Number.parseInt(u.replace(/^retry:\s*/, ""), 10);
|
|
51
|
+
Number.isNaN(z) || (K = z);
|
|
52
|
+
}
|
|
53
|
+
let G, q = !1;
|
|
54
|
+
if (U.length) {
|
|
55
|
+
let u = U.join("\n");
|
|
56
|
+
try {
|
|
57
|
+
G = JSON.parse(u), q = !0;
|
|
58
|
+
} catch {
|
|
59
|
+
G = u;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
q && (H && await H(G), V && (G = await V(G))), B?.({
|
|
63
|
+
data: G,
|
|
64
|
+
event: W,
|
|
65
|
+
id: Y,
|
|
66
|
+
retry: K
|
|
67
|
+
}), U.length && (yield G);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} finally {
|
|
71
|
+
Q.removeEventListener("abort", $), X.releaseLock();
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
} catch (u) {
|
|
75
|
+
if (z?.(u), W !== void 0 && Z >= W) break;
|
|
76
|
+
await X(Math.min(K * 2 ** (Z - 1), G ?? 3e4));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}() };
|
|
80
|
+
}, separatorArrayExplode = (u) => {
|
|
81
|
+
switch (u) {
|
|
82
|
+
case "label": return ".";
|
|
83
|
+
case "matrix": return ";";
|
|
84
|
+
case "simple": return ",";
|
|
85
|
+
default: return "&";
|
|
86
|
+
}
|
|
87
|
+
}, separatorArrayNoExplode = (u) => {
|
|
88
|
+
switch (u) {
|
|
89
|
+
case "form": return ",";
|
|
90
|
+
case "pipeDelimited": return "|";
|
|
91
|
+
case "spaceDelimited": return "%20";
|
|
92
|
+
default: return ",";
|
|
93
|
+
}
|
|
94
|
+
}, separatorObjectExplode = (u) => {
|
|
95
|
+
switch (u) {
|
|
96
|
+
case "label": return ".";
|
|
97
|
+
case "matrix": return ";";
|
|
98
|
+
case "simple": return ",";
|
|
99
|
+
default: return "&";
|
|
100
|
+
}
|
|
101
|
+
}, serializeArrayParam = ({ allowReserved: u, explode: z, name: B, style: U, value: W }) => {
|
|
102
|
+
if (!z) {
|
|
103
|
+
let z = (u ? W : W.map((u) => encodeURIComponent(u))).join(separatorArrayNoExplode(U));
|
|
104
|
+
switch (U) {
|
|
105
|
+
case "label": return `.${z}`;
|
|
106
|
+
case "matrix": return `;${B}=${z}`;
|
|
107
|
+
case "simple": return z;
|
|
108
|
+
default: return `${B}=${z}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
let K = separatorArrayExplode(U), q = W.map((z) => U === "label" || U === "simple" ? u ? z : encodeURIComponent(z) : serializePrimitiveParam({
|
|
112
|
+
allowReserved: u,
|
|
113
|
+
name: B,
|
|
114
|
+
value: z
|
|
115
|
+
})).join(K);
|
|
116
|
+
return U === "label" || U === "matrix" ? K + q : q;
|
|
117
|
+
}, serializePrimitiveParam = ({ allowReserved: u, name: z, value: B }) => {
|
|
118
|
+
if (B == null) return "";
|
|
119
|
+
if (typeof B == "object") throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
120
|
+
return `${z}=${u ? B : encodeURIComponent(B)}`;
|
|
121
|
+
}, serializeObjectParam = ({ allowReserved: u, explode: z, name: B, style: V, value: H, valueOnly: W }) => {
|
|
122
|
+
if (H instanceof Date) return W ? H.toISOString() : `${B}=${H.toISOString()}`;
|
|
123
|
+
if (V !== "deepObject" && !z) {
|
|
124
|
+
let z = [];
|
|
125
|
+
Object.entries(H).forEach(([B, V]) => {
|
|
126
|
+
z = [
|
|
127
|
+
...z,
|
|
128
|
+
B,
|
|
129
|
+
u ? V : encodeURIComponent(V)
|
|
130
|
+
];
|
|
131
|
+
});
|
|
132
|
+
let U = z.join(",");
|
|
133
|
+
switch (V) {
|
|
134
|
+
case "form": return `${B}=${U}`;
|
|
135
|
+
case "label": return `.${U}`;
|
|
136
|
+
case "matrix": return `;${B}=${U}`;
|
|
137
|
+
default: return U;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
let K = separatorObjectExplode(V), q = Object.entries(H).map(([z, H]) => serializePrimitiveParam({
|
|
141
|
+
allowReserved: u,
|
|
142
|
+
name: V === "deepObject" ? `${B}[${z}]` : z,
|
|
143
|
+
value: H
|
|
144
|
+
})).join(K);
|
|
145
|
+
return V === "label" || V === "matrix" ? K + q : q;
|
|
146
|
+
}, PATH_PARAM_RE = /\{[^{}]+\}/g, defaultPathSerializer = ({ path: u, url: z }) => {
|
|
147
|
+
let B = z, V = z.match(PATH_PARAM_RE);
|
|
148
|
+
if (V) for (let z of V) {
|
|
149
|
+
let V = !1, H = z.substring(1, z.length - 1), U = "simple";
|
|
150
|
+
H.endsWith("*") && (V = !0, H = H.substring(0, H.length - 1)), H.startsWith(".") ? (H = H.substring(1), U = "label") : H.startsWith(";") && (H = H.substring(1), U = "matrix");
|
|
151
|
+
let q = u[H];
|
|
152
|
+
if (q == null) continue;
|
|
153
|
+
if (Array.isArray(q)) {
|
|
154
|
+
B = B.replace(z, serializeArrayParam({
|
|
155
|
+
explode: V,
|
|
156
|
+
name: H,
|
|
157
|
+
style: U,
|
|
158
|
+
value: q
|
|
159
|
+
}));
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (typeof q == "object") {
|
|
163
|
+
B = B.replace(z, serializeObjectParam({
|
|
164
|
+
explode: V,
|
|
165
|
+
name: H,
|
|
166
|
+
style: U,
|
|
167
|
+
value: q,
|
|
168
|
+
valueOnly: !0
|
|
169
|
+
}));
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (U === "matrix") {
|
|
173
|
+
B = B.replace(z, `;${serializePrimitiveParam({
|
|
174
|
+
name: H,
|
|
175
|
+
value: q
|
|
176
|
+
})}`);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
let J = encodeURIComponent(U === "label" ? `.${q}` : q);
|
|
180
|
+
B = B.replace(z, J);
|
|
181
|
+
}
|
|
182
|
+
return B;
|
|
183
|
+
}, getUrl = ({ baseUrl: u, path: z, query: B, querySerializer: V, url: H }) => {
|
|
184
|
+
let U = H.startsWith("/") ? H : `/${H}`, W = (u ?? "") + U;
|
|
185
|
+
z && (W = defaultPathSerializer({
|
|
186
|
+
path: z,
|
|
187
|
+
url: W
|
|
188
|
+
}));
|
|
189
|
+
let G = B ? V(B) : "";
|
|
190
|
+
return G.startsWith("?") && (G = G.substring(1)), G && (W += `?${G}`), W;
|
|
191
|
+
};
|
|
192
|
+
function getValidRequestBody(u) {
|
|
193
|
+
let z = u.body !== void 0;
|
|
194
|
+
if (z && u.bodySerializer) return "serializedBody" in u ? u.serializedBody !== void 0 && u.serializedBody !== "" ? u.serializedBody : null : u.body === "" ? null : u.body;
|
|
195
|
+
if (z) return u.body;
|
|
196
|
+
}
|
|
197
|
+
const getAuthToken = async (u, z) => {
|
|
198
|
+
let B = typeof z == "function" ? await z(u) : z;
|
|
199
|
+
if (B) return u.scheme === "bearer" ? `Bearer ${B}` : u.scheme === "basic" ? `Basic ${btoa(B)}` : B;
|
|
200
|
+
}, createQuerySerializer = ({ parameters: u = {},...z } = {}) => (B) => {
|
|
201
|
+
let V = [];
|
|
202
|
+
if (B && typeof B == "object") for (let H in B) {
|
|
203
|
+
let U = B[H];
|
|
204
|
+
if (U == null) continue;
|
|
205
|
+
let q = u[H] || z;
|
|
206
|
+
if (Array.isArray(U)) {
|
|
207
|
+
let u = serializeArrayParam({
|
|
208
|
+
allowReserved: q.allowReserved,
|
|
209
|
+
explode: !0,
|
|
210
|
+
name: H,
|
|
211
|
+
style: "form",
|
|
212
|
+
value: U,
|
|
213
|
+
...q.array
|
|
214
|
+
});
|
|
215
|
+
u && V.push(u);
|
|
216
|
+
} else if (typeof U == "object") {
|
|
217
|
+
let u = serializeObjectParam({
|
|
218
|
+
allowReserved: q.allowReserved,
|
|
219
|
+
explode: !0,
|
|
220
|
+
name: H,
|
|
221
|
+
style: "deepObject",
|
|
222
|
+
value: U,
|
|
223
|
+
...q.object
|
|
224
|
+
});
|
|
225
|
+
u && V.push(u);
|
|
226
|
+
} else {
|
|
227
|
+
let u = serializePrimitiveParam({
|
|
228
|
+
allowReserved: q.allowReserved,
|
|
229
|
+
name: H,
|
|
230
|
+
value: U
|
|
231
|
+
});
|
|
232
|
+
u && V.push(u);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return V.join("&");
|
|
236
|
+
}, getParseAs = (u) => {
|
|
237
|
+
if (!u) return "stream";
|
|
238
|
+
let z = u.split(";")[0]?.trim();
|
|
239
|
+
if (z) {
|
|
240
|
+
if (z.startsWith("application/json") || z.endsWith("+json")) return "json";
|
|
241
|
+
if (z === "multipart/form-data") return "formData";
|
|
242
|
+
if ([
|
|
243
|
+
"application/",
|
|
244
|
+
"audio/",
|
|
245
|
+
"image/",
|
|
246
|
+
"video/"
|
|
247
|
+
].some((u) => z.startsWith(u))) return "blob";
|
|
248
|
+
if (z.startsWith("text/")) return "text";
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var checkForExistence = (u, z) => z ? !!(u.headers.has(z) || u.query?.[z] || u.headers.get("Cookie")?.includes(`${z}=`)) : !1;
|
|
252
|
+
const setAuthParams = async ({ security: u,...z }) => {
|
|
253
|
+
for (let B of u) {
|
|
254
|
+
if (checkForExistence(z, B.name)) continue;
|
|
255
|
+
let u = await getAuthToken(B, z.auth);
|
|
256
|
+
if (!u) continue;
|
|
257
|
+
let V = B.name ?? "Authorization";
|
|
258
|
+
switch (B.in) {
|
|
259
|
+
case "query":
|
|
260
|
+
z.query ||= {}, z.query[V] = u;
|
|
261
|
+
break;
|
|
262
|
+
case "cookie":
|
|
263
|
+
z.headers.append("Cookie", `${V}=${u}`);
|
|
264
|
+
break;
|
|
265
|
+
case "header":
|
|
266
|
+
default:
|
|
267
|
+
z.headers.set(V, u);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}, buildUrl = (u) => getUrl({
|
|
272
|
+
baseUrl: u.baseUrl,
|
|
273
|
+
path: u.path,
|
|
274
|
+
query: u.query,
|
|
275
|
+
querySerializer: typeof u.querySerializer == "function" ? u.querySerializer : createQuerySerializer(u.querySerializer),
|
|
276
|
+
url: u.url
|
|
277
|
+
}), mergeConfigs = (u, z) => {
|
|
278
|
+
let B = {
|
|
279
|
+
...u,
|
|
280
|
+
...z
|
|
281
|
+
};
|
|
282
|
+
return B.baseUrl?.endsWith("/") && (B.baseUrl = B.baseUrl.substring(0, B.baseUrl.length - 1)), B.headers = mergeHeaders(u.headers, z.headers), B;
|
|
283
|
+
};
|
|
284
|
+
var headersEntries = (u) => {
|
|
285
|
+
let z = [];
|
|
286
|
+
return u.forEach((u, B) => {
|
|
287
|
+
z.push([B, u]);
|
|
288
|
+
}), z;
|
|
289
|
+
};
|
|
290
|
+
const mergeHeaders = (...u) => {
|
|
291
|
+
let z = new Headers();
|
|
292
|
+
for (let B of u) {
|
|
293
|
+
if (!B) continue;
|
|
294
|
+
let u = B instanceof Headers ? headersEntries(B) : Object.entries(B);
|
|
295
|
+
for (let [B, V] of u) if (V === null) z.delete(B);
|
|
296
|
+
else if (Array.isArray(V)) for (let u of V) z.append(B, u);
|
|
297
|
+
else V !== void 0 && z.set(B, typeof V == "object" ? JSON.stringify(V) : V);
|
|
298
|
+
}
|
|
299
|
+
return z;
|
|
300
|
+
};
|
|
301
|
+
var Interceptors = class {
|
|
302
|
+
constructor() {
|
|
303
|
+
this.fns = [];
|
|
304
|
+
}
|
|
305
|
+
clear() {
|
|
306
|
+
this.fns = [];
|
|
307
|
+
}
|
|
308
|
+
eject(u) {
|
|
309
|
+
let z = this.getInterceptorIndex(u);
|
|
310
|
+
this.fns[z] && (this.fns[z] = null);
|
|
311
|
+
}
|
|
312
|
+
exists(u) {
|
|
313
|
+
let z = this.getInterceptorIndex(u);
|
|
314
|
+
return !!this.fns[z];
|
|
315
|
+
}
|
|
316
|
+
getInterceptorIndex(u) {
|
|
317
|
+
return typeof u == "number" ? this.fns[u] ? u : -1 : this.fns.indexOf(u);
|
|
318
|
+
}
|
|
319
|
+
update(u, z) {
|
|
320
|
+
let B = this.getInterceptorIndex(u);
|
|
321
|
+
return this.fns[B] ? (this.fns[B] = z, u) : !1;
|
|
322
|
+
}
|
|
323
|
+
use(u) {
|
|
324
|
+
return this.fns.push(u), this.fns.length - 1;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const createInterceptors = () => ({
|
|
328
|
+
error: new Interceptors(),
|
|
329
|
+
request: new Interceptors(),
|
|
330
|
+
response: new Interceptors()
|
|
331
|
+
});
|
|
332
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
333
|
+
allowReserved: !1,
|
|
334
|
+
array: {
|
|
335
|
+
explode: !0,
|
|
336
|
+
style: "form"
|
|
337
|
+
},
|
|
338
|
+
object: {
|
|
339
|
+
explode: !0,
|
|
340
|
+
style: "deepObject"
|
|
341
|
+
}
|
|
342
|
+
}), defaultHeaders = { "Content-Type": "application/json" };
|
|
343
|
+
const createConfig = (u = {}) => ({
|
|
344
|
+
...jsonBodySerializer,
|
|
345
|
+
headers: defaultHeaders,
|
|
346
|
+
parseAs: "auto",
|
|
347
|
+
querySerializer: defaultQuerySerializer,
|
|
348
|
+
...u
|
|
349
|
+
}), client = ((u = {}) => {
|
|
350
|
+
let z = mergeConfigs(createConfig(), u), V = () => ({ ...z }), H = (u) => (z = mergeConfigs(z, u), V()), U = createInterceptors(), W = async (u) => {
|
|
351
|
+
let B = {
|
|
352
|
+
...z,
|
|
353
|
+
...u,
|
|
354
|
+
fetch: u.fetch ?? z.fetch ?? globalThis.fetch,
|
|
355
|
+
headers: mergeHeaders(z.headers, u.headers),
|
|
356
|
+
serializedBody: void 0
|
|
357
|
+
};
|
|
358
|
+
return B.security && await setAuthParams({
|
|
359
|
+
...B,
|
|
360
|
+
security: B.security
|
|
361
|
+
}), B.requestValidator && await B.requestValidator(B), B.body !== void 0 && B.bodySerializer && (B.serializedBody = B.bodySerializer(B.body)), (B.body === void 0 || B.serializedBody === "") && B.headers.delete("Content-Type"), {
|
|
362
|
+
opts: B,
|
|
363
|
+
url: buildUrl(B)
|
|
364
|
+
};
|
|
365
|
+
}, G = async (u) => {
|
|
366
|
+
let { opts: z, url: B } = await W(u), V = {
|
|
367
|
+
redirect: "follow",
|
|
368
|
+
...z,
|
|
369
|
+
body: getValidRequestBody(z)
|
|
370
|
+
}, H = new Request(B, V);
|
|
371
|
+
for (let u of U.request.fns) u && (H = await u(H, z));
|
|
372
|
+
let G = z.fetch, K;
|
|
373
|
+
try {
|
|
374
|
+
K = await G(H);
|
|
375
|
+
} catch (u) {
|
|
376
|
+
let B = u;
|
|
377
|
+
for (let V of U.error.fns) V && (B = await V(u, void 0, H, z));
|
|
378
|
+
if (B ||= {}, z.throwOnError) throw B;
|
|
379
|
+
return z.responseStyle === "data" ? void 0 : {
|
|
380
|
+
error: B,
|
|
381
|
+
request: H,
|
|
382
|
+
response: void 0
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
for (let u of U.response.fns) u && (K = await u(K, H, z));
|
|
386
|
+
let q = {
|
|
387
|
+
request: H,
|
|
388
|
+
response: K
|
|
389
|
+
};
|
|
390
|
+
if (K.ok) {
|
|
391
|
+
let u = (z.parseAs === "auto" ? getParseAs(K.headers.get("Content-Type")) : z.parseAs) ?? "json";
|
|
392
|
+
if (K.status === 204 || K.headers.get("Content-Length") === "0") {
|
|
393
|
+
let B;
|
|
394
|
+
switch (u) {
|
|
395
|
+
case "arrayBuffer":
|
|
396
|
+
case "blob":
|
|
397
|
+
case "text":
|
|
398
|
+
B = await K[u]();
|
|
399
|
+
break;
|
|
400
|
+
case "formData":
|
|
401
|
+
B = new FormData();
|
|
402
|
+
break;
|
|
403
|
+
case "stream":
|
|
404
|
+
B = K.body;
|
|
405
|
+
break;
|
|
406
|
+
case "json":
|
|
407
|
+
default:
|
|
408
|
+
B = {};
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
return z.responseStyle === "data" ? B : {
|
|
412
|
+
data: B,
|
|
413
|
+
...q
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
let B;
|
|
417
|
+
switch (u) {
|
|
418
|
+
case "arrayBuffer":
|
|
419
|
+
case "blob":
|
|
420
|
+
case "formData":
|
|
421
|
+
case "text":
|
|
422
|
+
B = await K[u]();
|
|
423
|
+
break;
|
|
424
|
+
case "json": {
|
|
425
|
+
let u = await K.text();
|
|
426
|
+
B = u ? JSON.parse(u) : {};
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
case "stream": return z.responseStyle === "data" ? K.body : {
|
|
430
|
+
data: K.body,
|
|
431
|
+
...q
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
return u === "json" && (z.responseValidator && await z.responseValidator(B), z.responseTransformer && (B = await z.responseTransformer(B))), z.responseStyle === "data" ? B : {
|
|
435
|
+
data: B,
|
|
436
|
+
...q
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
let J = await K.text(), Y;
|
|
440
|
+
try {
|
|
441
|
+
Y = JSON.parse(J);
|
|
442
|
+
} catch {}
|
|
443
|
+
let Z = Y ?? J, Q = Z;
|
|
444
|
+
for (let u of U.error.fns) u && (Q = await u(Z, K, H, z));
|
|
445
|
+
if (Q ||= {}, z.throwOnError) throw Q;
|
|
446
|
+
return z.responseStyle === "data" ? void 0 : {
|
|
447
|
+
error: Q,
|
|
448
|
+
...q
|
|
449
|
+
};
|
|
450
|
+
}, K = (u) => (z) => G({
|
|
451
|
+
...z,
|
|
452
|
+
method: u
|
|
453
|
+
}), q = (u) => async (z) => {
|
|
454
|
+
let { opts: V, url: H } = await W(z);
|
|
455
|
+
return createSseClient({
|
|
456
|
+
...V,
|
|
457
|
+
body: V.body,
|
|
458
|
+
headers: V.headers,
|
|
459
|
+
method: u,
|
|
460
|
+
onRequest: async (u, z) => {
|
|
461
|
+
let B = new Request(u, z);
|
|
462
|
+
for (let u of U.request.fns) u && (B = await u(B, V));
|
|
463
|
+
return B;
|
|
464
|
+
},
|
|
465
|
+
serializedBody: getValidRequestBody(V),
|
|
466
|
+
url: H
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
return {
|
|
470
|
+
buildUrl,
|
|
471
|
+
connect: K("CONNECT"),
|
|
472
|
+
delete: K("DELETE"),
|
|
473
|
+
get: K("GET"),
|
|
474
|
+
getConfig: V,
|
|
475
|
+
head: K("HEAD"),
|
|
476
|
+
interceptors: U,
|
|
477
|
+
options: K("OPTIONS"),
|
|
478
|
+
patch: K("PATCH"),
|
|
479
|
+
post: K("POST"),
|
|
480
|
+
put: K("PUT"),
|
|
481
|
+
request: G,
|
|
482
|
+
setConfig: H,
|
|
483
|
+
sse: {
|
|
484
|
+
connect: q("CONNECT"),
|
|
485
|
+
delete: q("DELETE"),
|
|
486
|
+
get: q("GET"),
|
|
487
|
+
head: q("HEAD"),
|
|
488
|
+
options: q("OPTIONS"),
|
|
489
|
+
patch: q("PATCH"),
|
|
490
|
+
post: q("POST"),
|
|
491
|
+
put: q("PUT"),
|
|
492
|
+
trace: q("TRACE")
|
|
493
|
+
},
|
|
494
|
+
trace: K("TRACE")
|
|
495
|
+
};
|
|
496
|
+
})(createClientConfig(createConfig({ baseUrl: "https://api.lcl-resenty.com/__internal" })));
|
|
497
|
+
var HeyApiClient = class {
|
|
498
|
+
constructor(u) {
|
|
499
|
+
this.client = u?.client ?? client;
|
|
500
|
+
}
|
|
501
|
+
}, HeyApiRegistry = class {
|
|
502
|
+
constructor() {
|
|
503
|
+
this.defaultKey = "default", this.instances = /* @__PURE__ */ new Map();
|
|
504
|
+
}
|
|
505
|
+
get(u) {
|
|
506
|
+
let z = this.instances.get(u ?? this.defaultKey);
|
|
507
|
+
if (!z) throw Error("No SDK client found. Create one with \"new Client()\" to fix this error.");
|
|
508
|
+
return z;
|
|
509
|
+
}
|
|
510
|
+
set(u, z) {
|
|
511
|
+
this.instances.set(z ?? this.defaultKey, u);
|
|
512
|
+
}
|
|
513
|
+
}, Sessions = class extends HeyApiClient {
|
|
514
|
+
createSession(u) {
|
|
515
|
+
return (u?.client ?? this.client).post({
|
|
516
|
+
url: "/widget/sessions",
|
|
517
|
+
...u,
|
|
518
|
+
headers: {
|
|
519
|
+
"Content-Type": "application/json",
|
|
520
|
+
...u?.headers
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}, Messages = class extends HeyApiClient {
|
|
525
|
+
sendMessage(u) {
|
|
526
|
+
return (u.client ?? this.client).post({
|
|
527
|
+
url: "/widget/messages",
|
|
528
|
+
...u,
|
|
529
|
+
headers: {
|
|
530
|
+
"Content-Type": "application/json",
|
|
531
|
+
...u.headers
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
getMessages(u) {
|
|
536
|
+
return (u.client ?? this.client).get({
|
|
537
|
+
url: "/widget/messages/{threadId}",
|
|
538
|
+
...u
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}, Threads = class extends HeyApiClient {
|
|
542
|
+
getThreads(u) {
|
|
543
|
+
return (u?.client ?? this.client).get({
|
|
544
|
+
url: "/widget/threads",
|
|
545
|
+
...u
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}, Widget = class extends HeyApiClient {
|
|
549
|
+
get sessions() {
|
|
550
|
+
return this._sessions ??= new Sessions({ client: this.client });
|
|
551
|
+
}
|
|
552
|
+
get messages() {
|
|
553
|
+
return this._messages ??= new Messages({ client: this.client });
|
|
554
|
+
}
|
|
555
|
+
get threads() {
|
|
556
|
+
return this._threads ??= new Threads({ client: this.client });
|
|
557
|
+
}
|
|
558
|
+
}, Client = class u extends HeyApiClient {
|
|
559
|
+
static #e = this.__registry = new HeyApiRegistry();
|
|
560
|
+
constructor(z) {
|
|
561
|
+
super(z), u.__registry.set(this, z?.key);
|
|
562
|
+
}
|
|
563
|
+
get widget() {
|
|
564
|
+
return this._widget ??= new Widget({ client: this.client });
|
|
565
|
+
}
|
|
566
|
+
}, Subscribable = class {
|
|
567
|
+
constructor() {
|
|
568
|
+
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
569
|
+
}
|
|
570
|
+
subscribe(u) {
|
|
571
|
+
return this.listeners.add(u), this.onSubscribe(), () => {
|
|
572
|
+
this.listeners.delete(u), this.onUnsubscribe();
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
hasListeners() {
|
|
576
|
+
return this.listeners.size > 0;
|
|
577
|
+
}
|
|
578
|
+
onSubscribe() {}
|
|
579
|
+
onUnsubscribe() {}
|
|
580
|
+
}, focusManager = new class extends Subscribable {
|
|
581
|
+
#e;
|
|
582
|
+
#t;
|
|
583
|
+
#n;
|
|
584
|
+
constructor() {
|
|
585
|
+
super(), this.#n = (u) => {
|
|
586
|
+
if (typeof window < "u" && window.addEventListener) {
|
|
587
|
+
let z = () => u();
|
|
588
|
+
return window.addEventListener("visibilitychange", z, !1), () => {
|
|
589
|
+
window.removeEventListener("visibilitychange", z);
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
onSubscribe() {
|
|
595
|
+
this.#t || this.setEventListener(this.#n);
|
|
596
|
+
}
|
|
597
|
+
onUnsubscribe() {
|
|
598
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
599
|
+
}
|
|
600
|
+
setEventListener(u) {
|
|
601
|
+
this.#n = u, this.#t?.(), this.#t = u((u) => {
|
|
602
|
+
typeof u == "boolean" ? this.setFocused(u) : this.onFocus();
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
setFocused(u) {
|
|
606
|
+
this.#e !== u && (this.#e = u, this.onFocus());
|
|
607
|
+
}
|
|
608
|
+
onFocus() {
|
|
609
|
+
let u = this.isFocused();
|
|
610
|
+
this.listeners.forEach((z) => {
|
|
611
|
+
z(u);
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
isFocused() {
|
|
615
|
+
return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
|
|
616
|
+
}
|
|
617
|
+
}(), defaultTimeoutProvider = {
|
|
618
|
+
setTimeout: (u, z) => setTimeout(u, z),
|
|
619
|
+
clearTimeout: (u) => clearTimeout(u),
|
|
620
|
+
setInterval: (u, z) => setInterval(u, z),
|
|
621
|
+
clearInterval: (u) => clearInterval(u)
|
|
622
|
+
}, timeoutManager = new class {
|
|
623
|
+
#e = defaultTimeoutProvider;
|
|
624
|
+
#t = !1;
|
|
625
|
+
setTimeoutProvider(u) {
|
|
626
|
+
process.env.NODE_ENV !== "production" && this.#t && u !== this.#e && console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.", {
|
|
627
|
+
previous: this.#e,
|
|
628
|
+
provider: u
|
|
629
|
+
}), this.#e = u, process.env.NODE_ENV !== "production" && (this.#t = !1);
|
|
630
|
+
}
|
|
631
|
+
setTimeout(u, z) {
|
|
632
|
+
return process.env.NODE_ENV !== "production" && (this.#t = !0), this.#e.setTimeout(u, z);
|
|
633
|
+
}
|
|
634
|
+
clearTimeout(u) {
|
|
635
|
+
this.#e.clearTimeout(u);
|
|
636
|
+
}
|
|
637
|
+
setInterval(u, z) {
|
|
638
|
+
return process.env.NODE_ENV !== "production" && (this.#t = !0), this.#e.setInterval(u, z);
|
|
639
|
+
}
|
|
640
|
+
clearInterval(u) {
|
|
641
|
+
this.#e.clearInterval(u);
|
|
642
|
+
}
|
|
643
|
+
}();
|
|
644
|
+
function systemSetTimeoutZero(u) {
|
|
645
|
+
setTimeout(u, 0);
|
|
646
|
+
}
|
|
647
|
+
var isServer = typeof window > "u" || "Deno" in globalThis;
|
|
648
|
+
function noop() {}
|
|
649
|
+
function functionalUpdate(u, z) {
|
|
650
|
+
return typeof u == "function" ? u(z) : u;
|
|
651
|
+
}
|
|
652
|
+
function isValidTimeout(u) {
|
|
653
|
+
return typeof u == "number" && u >= 0 && u !== Infinity;
|
|
654
|
+
}
|
|
655
|
+
function timeUntilStale(u, z) {
|
|
656
|
+
return Math.max(u + (z || 0) - Date.now(), 0);
|
|
657
|
+
}
|
|
658
|
+
function resolveStaleTime(u, z) {
|
|
659
|
+
return typeof u == "function" ? u(z) : u;
|
|
660
|
+
}
|
|
661
|
+
function resolveQueryBoolean(u, z) {
|
|
662
|
+
return typeof u == "function" ? u(z) : u;
|
|
663
|
+
}
|
|
664
|
+
function matchQuery(u, z) {
|
|
665
|
+
let { type: B = "all", exact: V, fetchStatus: H, predicate: U, queryKey: W, stale: G } = u;
|
|
666
|
+
if (W) {
|
|
667
|
+
if (V) {
|
|
668
|
+
if (z.queryHash !== hashQueryKeyByOptions(W, z.options)) return !1;
|
|
669
|
+
} else if (!partialMatchKey(z.queryKey, W)) return !1;
|
|
670
|
+
}
|
|
671
|
+
if (B !== "all") {
|
|
672
|
+
let u = z.isActive();
|
|
673
|
+
if (B === "active" && !u || B === "inactive" && u) return !1;
|
|
674
|
+
}
|
|
675
|
+
return !(typeof G == "boolean" && z.isStale() !== G || H && H !== z.state.fetchStatus || U && !U(z));
|
|
676
|
+
}
|
|
677
|
+
function matchMutation(u, z) {
|
|
678
|
+
let { exact: B, status: V, predicate: H, mutationKey: U } = u;
|
|
679
|
+
if (U) {
|
|
680
|
+
if (!z.options.mutationKey) return !1;
|
|
681
|
+
if (B) {
|
|
682
|
+
if (hashKey(z.options.mutationKey) !== hashKey(U)) return !1;
|
|
683
|
+
} else if (!partialMatchKey(z.options.mutationKey, U)) return !1;
|
|
684
|
+
}
|
|
685
|
+
return !(V && z.state.status !== V || H && !H(z));
|
|
686
|
+
}
|
|
687
|
+
function hashQueryKeyByOptions(u, z) {
|
|
688
|
+
return (z?.queryKeyHashFn || hashKey)(u);
|
|
689
|
+
}
|
|
690
|
+
function hashKey(u) {
|
|
691
|
+
return JSON.stringify(u, (u, z) => isPlainObject$1(z) ? Object.keys(z).sort().reduce((u, B) => (u[B] = z[B], u), {}) : z);
|
|
692
|
+
}
|
|
693
|
+
function partialMatchKey(u, z) {
|
|
694
|
+
return u === z ? !0 : typeof u == typeof z && u && z && typeof u == "object" && typeof z == "object" ? Object.keys(z).every((B) => partialMatchKey(u[B], z[B])) : !1;
|
|
695
|
+
}
|
|
696
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
697
|
+
function replaceEqualDeep(u, z, B = 0) {
|
|
698
|
+
if (u === z) return u;
|
|
699
|
+
if (B > 500) return z;
|
|
700
|
+
let V = isPlainArray(u) && isPlainArray(z);
|
|
701
|
+
if (!V && !(isPlainObject$1(u) && isPlainObject$1(z))) return z;
|
|
702
|
+
let H = (V ? u : Object.keys(u)).length, U = V ? z : Object.keys(z), W = U.length, G = V ? Array(W) : {}, K = 0;
|
|
703
|
+
for (let q = 0; q < W; q++) {
|
|
704
|
+
let W = V ? q : U[q], J = u[W], Y = z[W];
|
|
705
|
+
if (J === Y) {
|
|
706
|
+
G[W] = J, (V ? q < H : hasOwn.call(u, W)) && K++;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (J === null || Y === null || typeof J != "object" || typeof Y != "object") {
|
|
710
|
+
G[W] = Y;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
let X = replaceEqualDeep(J, Y, B + 1);
|
|
714
|
+
G[W] = X, X === J && K++;
|
|
715
|
+
}
|
|
716
|
+
return H === W && K === H ? u : G;
|
|
717
|
+
}
|
|
718
|
+
function shallowEqualObjects(u, z) {
|
|
719
|
+
if (!z || Object.keys(u).length !== Object.keys(z).length) return !1;
|
|
720
|
+
for (let B in u) if (u[B] !== z[B]) return !1;
|
|
721
|
+
return !0;
|
|
722
|
+
}
|
|
723
|
+
function isPlainArray(u) {
|
|
724
|
+
return Array.isArray(u) && u.length === Object.keys(u).length;
|
|
725
|
+
}
|
|
726
|
+
function isPlainObject$1(u) {
|
|
727
|
+
if (!hasObjectPrototype(u)) return !1;
|
|
728
|
+
let z = u.constructor;
|
|
729
|
+
if (z === void 0) return !0;
|
|
730
|
+
let B = z.prototype;
|
|
731
|
+
return !(!hasObjectPrototype(B) || !B.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(u) !== Object.prototype);
|
|
732
|
+
}
|
|
733
|
+
function hasObjectPrototype(u) {
|
|
734
|
+
return Object.prototype.toString.call(u) === "[object Object]";
|
|
735
|
+
}
|
|
736
|
+
function sleep(u) {
|
|
737
|
+
return new Promise((z) => {
|
|
738
|
+
timeoutManager.setTimeout(z, u);
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
function replaceData(u, z, B) {
|
|
742
|
+
if (typeof B.structuralSharing == "function") return B.structuralSharing(u, z);
|
|
743
|
+
if (B.structuralSharing !== !1) {
|
|
744
|
+
if (process.env.NODE_ENV !== "production") try {
|
|
745
|
+
return replaceEqualDeep(u, z);
|
|
746
|
+
} catch (u) {
|
|
747
|
+
throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${B.queryHash}]: ${u}`), u;
|
|
748
|
+
}
|
|
749
|
+
return replaceEqualDeep(u, z);
|
|
750
|
+
}
|
|
751
|
+
return z;
|
|
752
|
+
}
|
|
753
|
+
function addToEnd(u, z, B = 0) {
|
|
754
|
+
let V = [...u, z];
|
|
755
|
+
return B && V.length > B ? V.slice(1) : V;
|
|
756
|
+
}
|
|
757
|
+
function addToStart(u, z, B = 0) {
|
|
758
|
+
let V = [z, ...u];
|
|
759
|
+
return B && V.length > B ? V.slice(0, -1) : V;
|
|
760
|
+
}
|
|
761
|
+
var skipToken = /* @__PURE__ */ Symbol();
|
|
762
|
+
function ensureQueryFn(u, z) {
|
|
763
|
+
return process.env.NODE_ENV !== "production" && u.queryFn === skipToken && console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${u.queryHash}'`), !u.queryFn && z?.initialPromise ? () => z.initialPromise : !u.queryFn || u.queryFn === skipToken ? () => Promise.reject(/* @__PURE__ */ Error(`Missing queryFn: '${u.queryHash}'`)) : u.queryFn;
|
|
764
|
+
}
|
|
765
|
+
function shouldThrowError(u, z) {
|
|
766
|
+
return typeof u == "function" ? u(...z) : !!u;
|
|
767
|
+
}
|
|
768
|
+
function addConsumeAwareSignal(u, z, B) {
|
|
769
|
+
let V = !1, H;
|
|
770
|
+
return Object.defineProperty(u, "signal", {
|
|
771
|
+
enumerable: !0,
|
|
772
|
+
get: () => (H ??= z(), V ? H : (V = !0, H.aborted ? B() : H.addEventListener("abort", B, { once: !0 }), H))
|
|
773
|
+
}), u;
|
|
774
|
+
}
|
|
775
|
+
var environmentManager = /* @__PURE__ */ (() => {
|
|
776
|
+
let u = () => isServer;
|
|
777
|
+
return {
|
|
778
|
+
isServer() {
|
|
779
|
+
return u();
|
|
780
|
+
},
|
|
781
|
+
setIsServer(z) {
|
|
782
|
+
u = z;
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
})();
|
|
786
|
+
function pendingThenable() {
|
|
787
|
+
let u, z, B = new Promise((B, V) => {
|
|
788
|
+
u = B, z = V;
|
|
789
|
+
});
|
|
790
|
+
B.status = "pending", B.catch(() => {});
|
|
791
|
+
function V(u) {
|
|
792
|
+
Object.assign(B, u), delete B.resolve, delete B.reject;
|
|
793
|
+
}
|
|
794
|
+
return B.resolve = (z) => {
|
|
795
|
+
V({
|
|
796
|
+
status: "fulfilled",
|
|
797
|
+
value: z
|
|
798
|
+
}), u(z);
|
|
799
|
+
}, B.reject = (u) => {
|
|
800
|
+
V({
|
|
801
|
+
status: "rejected",
|
|
802
|
+
reason: u
|
|
803
|
+
}), z(u);
|
|
804
|
+
}, B;
|
|
805
|
+
}
|
|
806
|
+
var defaultScheduler = systemSetTimeoutZero;
|
|
807
|
+
function createNotifyManager() {
|
|
808
|
+
let u = [], z = 0, B = (u) => {
|
|
809
|
+
u();
|
|
810
|
+
}, V = (u) => {
|
|
811
|
+
u();
|
|
812
|
+
}, H = defaultScheduler, U = (V) => {
|
|
813
|
+
z ? u.push(V) : H(() => {
|
|
814
|
+
B(V);
|
|
815
|
+
});
|
|
816
|
+
}, W = () => {
|
|
817
|
+
let z = u;
|
|
818
|
+
u = [], z.length && H(() => {
|
|
819
|
+
V(() => {
|
|
820
|
+
z.forEach((u) => {
|
|
821
|
+
B(u);
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
});
|
|
825
|
+
};
|
|
826
|
+
return {
|
|
827
|
+
batch: (u) => {
|
|
828
|
+
let B;
|
|
829
|
+
z++;
|
|
830
|
+
try {
|
|
831
|
+
B = u();
|
|
832
|
+
} finally {
|
|
833
|
+
z--, z || W();
|
|
834
|
+
}
|
|
835
|
+
return B;
|
|
836
|
+
},
|
|
837
|
+
batchCalls: (u) => (...z) => {
|
|
838
|
+
U(() => {
|
|
839
|
+
u(...z);
|
|
840
|
+
});
|
|
841
|
+
},
|
|
842
|
+
schedule: U,
|
|
843
|
+
setNotifyFunction: (u) => {
|
|
844
|
+
B = u;
|
|
845
|
+
},
|
|
846
|
+
setBatchNotifyFunction: (u) => {
|
|
847
|
+
V = u;
|
|
848
|
+
},
|
|
849
|
+
setScheduler: (u) => {
|
|
850
|
+
H = u;
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
var notifyManager = createNotifyManager(), onlineManager = new class extends Subscribable {
|
|
855
|
+
#e = !0;
|
|
856
|
+
#t;
|
|
857
|
+
#n;
|
|
858
|
+
constructor() {
|
|
859
|
+
super(), this.#n = (u) => {
|
|
860
|
+
if (typeof window < "u" && window.addEventListener) {
|
|
861
|
+
let z = () => u(!0), B = () => u(!1);
|
|
862
|
+
return window.addEventListener("online", z, !1), window.addEventListener("offline", B, !1), () => {
|
|
863
|
+
window.removeEventListener("online", z), window.removeEventListener("offline", B);
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
onSubscribe() {
|
|
869
|
+
this.#t || this.setEventListener(this.#n);
|
|
870
|
+
}
|
|
871
|
+
onUnsubscribe() {
|
|
872
|
+
this.hasListeners() || (this.#t?.(), this.#t = void 0);
|
|
873
|
+
}
|
|
874
|
+
setEventListener(u) {
|
|
875
|
+
this.#n = u, this.#t?.(), this.#t = u(this.setOnline.bind(this));
|
|
876
|
+
}
|
|
877
|
+
setOnline(u) {
|
|
878
|
+
this.#e !== u && (this.#e = u, this.listeners.forEach((z) => {
|
|
879
|
+
z(u);
|
|
880
|
+
}));
|
|
881
|
+
}
|
|
882
|
+
isOnline() {
|
|
883
|
+
return this.#e;
|
|
884
|
+
}
|
|
885
|
+
}();
|
|
886
|
+
function defaultRetryDelay(u) {
|
|
887
|
+
return Math.min(1e3 * 2 ** u, 3e4);
|
|
888
|
+
}
|
|
889
|
+
function canFetch(u) {
|
|
890
|
+
return (u ?? "online") === "online" ? onlineManager.isOnline() : !0;
|
|
891
|
+
}
|
|
892
|
+
var CancelledError = class extends Error {
|
|
893
|
+
constructor(u) {
|
|
894
|
+
super("CancelledError"), this.revert = u?.revert, this.silent = u?.silent;
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
function createRetryer(u) {
|
|
898
|
+
let z = !1, B = 0, V, H = pendingThenable(), U = () => H.status !== "pending", W = (z) => {
|
|
899
|
+
if (!U()) {
|
|
900
|
+
let B = new CancelledError(z);
|
|
901
|
+
X(B), u.onCancel?.(B);
|
|
902
|
+
}
|
|
903
|
+
}, G = () => {
|
|
904
|
+
z = !0;
|
|
905
|
+
}, K = () => {
|
|
906
|
+
z = !1;
|
|
907
|
+
}, q = () => focusManager.isFocused() && (u.networkMode === "always" || onlineManager.isOnline()) && u.canRun(), J = () => canFetch(u.networkMode) && u.canRun(), Y = (u) => {
|
|
908
|
+
U() || (V?.(), H.resolve(u));
|
|
909
|
+
}, X = (u) => {
|
|
910
|
+
U() || (V?.(), H.reject(u));
|
|
911
|
+
}, Z = () => new Promise((z) => {
|
|
912
|
+
V = (u) => {
|
|
913
|
+
(U() || q()) && z(u);
|
|
914
|
+
}, u.onPause?.();
|
|
915
|
+
}).then(() => {
|
|
916
|
+
V = void 0, U() || u.onContinue?.();
|
|
917
|
+
}), Q = () => {
|
|
918
|
+
if (U()) return;
|
|
919
|
+
let V, H = B === 0 ? u.initialPromise : void 0;
|
|
920
|
+
try {
|
|
921
|
+
V = H ?? u.fn();
|
|
922
|
+
} catch (u) {
|
|
923
|
+
V = Promise.reject(u);
|
|
924
|
+
}
|
|
925
|
+
Promise.resolve(V).then(Y).catch((V) => {
|
|
926
|
+
if (U()) return;
|
|
927
|
+
let H = u.retry ?? (environmentManager.isServer() ? 0 : 3), W = u.retryDelay ?? defaultRetryDelay, G = typeof W == "function" ? W(B, V) : W, K = H === !0 || typeof H == "number" && B < H || typeof H == "function" && H(B, V);
|
|
928
|
+
if (z || !K) {
|
|
929
|
+
X(V);
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
B++, u.onFail?.(B, V), sleep(G).then(() => q() ? void 0 : Z()).then(() => {
|
|
933
|
+
z ? X(V) : Q();
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
return {
|
|
938
|
+
promise: H,
|
|
939
|
+
status: () => H.status,
|
|
940
|
+
cancel: W,
|
|
941
|
+
continue: () => (V?.(), H),
|
|
942
|
+
cancelRetry: G,
|
|
943
|
+
continueRetry: K,
|
|
944
|
+
canStart: J,
|
|
945
|
+
start: () => (J() ? Q() : Z().then(Q), H)
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
var Removable = class {
|
|
949
|
+
#e;
|
|
950
|
+
destroy() {
|
|
951
|
+
this.clearGcTimeout();
|
|
952
|
+
}
|
|
953
|
+
scheduleGc() {
|
|
954
|
+
this.clearGcTimeout(), isValidTimeout(this.gcTime) && (this.#e = timeoutManager.setTimeout(() => {
|
|
955
|
+
this.optionalRemove();
|
|
956
|
+
}, this.gcTime));
|
|
957
|
+
}
|
|
958
|
+
updateGcTime(u) {
|
|
959
|
+
this.gcTime = Math.max(this.gcTime || 0, u ?? (environmentManager.isServer() ? Infinity : 300 * 1e3));
|
|
960
|
+
}
|
|
961
|
+
clearGcTimeout() {
|
|
962
|
+
this.#e !== void 0 && (timeoutManager.clearTimeout(this.#e), this.#e = void 0);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
function infiniteQueryBehavior(u) {
|
|
966
|
+
return { onFetch: (z, B) => {
|
|
967
|
+
let V = z.options, H = z.fetchOptions?.meta?.fetchMore?.direction, U = z.state.data?.pages || [], W = z.state.data?.pageParams || [], G = {
|
|
968
|
+
pages: [],
|
|
969
|
+
pageParams: []
|
|
970
|
+
}, K = 0, q = async () => {
|
|
971
|
+
let B = !1, q = (u) => {
|
|
972
|
+
addConsumeAwareSignal(u, () => z.signal, () => B = !0);
|
|
973
|
+
}, J = ensureQueryFn(z.options, z.fetchOptions), Y = async (u, V, H) => {
|
|
974
|
+
if (B) return Promise.reject(z.signal.reason);
|
|
975
|
+
if (V == null && u.pages.length) return Promise.resolve(u);
|
|
976
|
+
let U = await J((() => {
|
|
977
|
+
let u = {
|
|
978
|
+
client: z.client,
|
|
979
|
+
queryKey: z.queryKey,
|
|
980
|
+
pageParam: V,
|
|
981
|
+
direction: H ? "backward" : "forward",
|
|
982
|
+
meta: z.options.meta
|
|
983
|
+
};
|
|
984
|
+
return q(u), u;
|
|
985
|
+
})()), { maxPages: W } = z.options, G = H ? addToStart : addToEnd;
|
|
986
|
+
return {
|
|
987
|
+
pages: G(u.pages, U, W),
|
|
988
|
+
pageParams: G(u.pageParams, V, W)
|
|
989
|
+
};
|
|
990
|
+
};
|
|
991
|
+
if (H && U.length) {
|
|
992
|
+
let u = H === "backward", z = u ? getPreviousPageParam : getNextPageParam, B = {
|
|
993
|
+
pages: U,
|
|
994
|
+
pageParams: W
|
|
995
|
+
};
|
|
996
|
+
G = await Y(B, z(V, B), u);
|
|
997
|
+
} else {
|
|
998
|
+
let z = u ?? U.length;
|
|
999
|
+
do {
|
|
1000
|
+
let u = K === 0 ? W[0] ?? V.initialPageParam : getNextPageParam(V, G);
|
|
1001
|
+
if (K > 0 && u == null) break;
|
|
1002
|
+
G = await Y(G, u), K++;
|
|
1003
|
+
} while (K < z);
|
|
1004
|
+
}
|
|
1005
|
+
return G;
|
|
1006
|
+
};
|
|
1007
|
+
z.options.persister ? z.fetchFn = () => z.options.persister?.(q, {
|
|
1008
|
+
client: z.client,
|
|
1009
|
+
queryKey: z.queryKey,
|
|
1010
|
+
meta: z.options.meta,
|
|
1011
|
+
signal: z.signal
|
|
1012
|
+
}, B) : z.fetchFn = q;
|
|
1013
|
+
} };
|
|
1014
|
+
}
|
|
1015
|
+
function getNextPageParam(u, { pages: z, pageParams: B }) {
|
|
1016
|
+
let V = z.length - 1;
|
|
1017
|
+
return z.length > 0 ? u.getNextPageParam(z[V], z, B[V], B) : void 0;
|
|
1018
|
+
}
|
|
1019
|
+
function getPreviousPageParam(u, { pages: z, pageParams: B }) {
|
|
1020
|
+
return z.length > 0 ? u.getPreviousPageParam?.(z[0], z, B[0], B) : void 0;
|
|
1021
|
+
}
|
|
1022
|
+
var Query = class extends Removable {
|
|
1023
|
+
#e;
|
|
1024
|
+
#t;
|
|
1025
|
+
#n;
|
|
1026
|
+
#r;
|
|
1027
|
+
#i;
|
|
1028
|
+
#a;
|
|
1029
|
+
#o;
|
|
1030
|
+
#s;
|
|
1031
|
+
constructor(u) {
|
|
1032
|
+
super(), this.#s = !1, this.#o = u.defaultOptions, this.setOptions(u.options), this.observers = [], this.#i = u.client, this.#r = this.#i.getQueryCache(), this.queryKey = u.queryKey, this.queryHash = u.queryHash, this.#t = getDefaultState$1(this.options), this.state = u.state ?? this.#t, this.scheduleGc();
|
|
1033
|
+
}
|
|
1034
|
+
get meta() {
|
|
1035
|
+
return this.options.meta;
|
|
1036
|
+
}
|
|
1037
|
+
get queryType() {
|
|
1038
|
+
return this.#e;
|
|
1039
|
+
}
|
|
1040
|
+
get promise() {
|
|
1041
|
+
return this.#a?.promise;
|
|
1042
|
+
}
|
|
1043
|
+
setOptions(u) {
|
|
1044
|
+
if (this.options = {
|
|
1045
|
+
...this.#o,
|
|
1046
|
+
...u
|
|
1047
|
+
}, u?._type && (this.#e = u._type), this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
|
|
1048
|
+
let u = getDefaultState$1(this.options);
|
|
1049
|
+
u.data !== void 0 && (this.setState(successState(u.data, u.dataUpdatedAt)), this.#t = u);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
optionalRemove() {
|
|
1053
|
+
!this.observers.length && this.state.fetchStatus === "idle" && this.#r.remove(this);
|
|
1054
|
+
}
|
|
1055
|
+
setData(u, z) {
|
|
1056
|
+
let B = replaceData(this.state.data, u, this.options);
|
|
1057
|
+
return this.#l({
|
|
1058
|
+
data: B,
|
|
1059
|
+
type: "success",
|
|
1060
|
+
dataUpdatedAt: z?.updatedAt,
|
|
1061
|
+
manual: z?.manual
|
|
1062
|
+
}), B;
|
|
1063
|
+
}
|
|
1064
|
+
setState(u) {
|
|
1065
|
+
this.#l({
|
|
1066
|
+
type: "setState",
|
|
1067
|
+
state: u
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
cancel(u) {
|
|
1071
|
+
let z = this.#a?.promise;
|
|
1072
|
+
return this.#a?.cancel(u), z ? z.then(noop).catch(noop) : Promise.resolve();
|
|
1073
|
+
}
|
|
1074
|
+
destroy() {
|
|
1075
|
+
super.destroy(), this.cancel({ silent: !0 });
|
|
1076
|
+
}
|
|
1077
|
+
get resetState() {
|
|
1078
|
+
return this.#t;
|
|
1079
|
+
}
|
|
1080
|
+
reset() {
|
|
1081
|
+
this.destroy(), this.setState(this.resetState);
|
|
1082
|
+
}
|
|
1083
|
+
isActive() {
|
|
1084
|
+
return this.observers.some((u) => resolveQueryBoolean(u.options.enabled, this) !== !1);
|
|
1085
|
+
}
|
|
1086
|
+
isDisabled() {
|
|
1087
|
+
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === skipToken || !this.isFetched();
|
|
1088
|
+
}
|
|
1089
|
+
isFetched() {
|
|
1090
|
+
return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
|
|
1091
|
+
}
|
|
1092
|
+
isStatic() {
|
|
1093
|
+
return this.getObserversCount() > 0 ? this.observers.some((u) => resolveStaleTime(u.options.staleTime, this) === "static") : !1;
|
|
1094
|
+
}
|
|
1095
|
+
isStale() {
|
|
1096
|
+
return this.getObserversCount() > 0 ? this.observers.some((u) => u.getCurrentResult().isStale) : this.state.data === void 0 || this.state.isInvalidated;
|
|
1097
|
+
}
|
|
1098
|
+
isStaleByTime(u = 0) {
|
|
1099
|
+
return this.state.data === void 0 ? !0 : u === "static" ? !1 : this.state.isInvalidated ? !0 : !timeUntilStale(this.state.dataUpdatedAt, u);
|
|
1100
|
+
}
|
|
1101
|
+
onFocus() {
|
|
1102
|
+
this.observers.find((u) => u.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#a?.continue();
|
|
1103
|
+
}
|
|
1104
|
+
onOnline() {
|
|
1105
|
+
this.observers.find((u) => u.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#a?.continue();
|
|
1106
|
+
}
|
|
1107
|
+
addObserver(u) {
|
|
1108
|
+
this.observers.includes(u) || (this.observers.push(u), this.clearGcTimeout(), this.#r.notify({
|
|
1109
|
+
type: "observerAdded",
|
|
1110
|
+
query: this,
|
|
1111
|
+
observer: u
|
|
1112
|
+
}));
|
|
1113
|
+
}
|
|
1114
|
+
removeObserver(u) {
|
|
1115
|
+
this.observers.includes(u) && (this.observers = this.observers.filter((z) => z !== u), this.observers.length || (this.#a && (this.#s || this.#c() ? this.#a.cancel({ revert: !0 }) : this.#a.cancelRetry()), this.scheduleGc()), this.#r.notify({
|
|
1116
|
+
type: "observerRemoved",
|
|
1117
|
+
query: this,
|
|
1118
|
+
observer: u
|
|
1119
|
+
}));
|
|
1120
|
+
}
|
|
1121
|
+
getObserversCount() {
|
|
1122
|
+
return this.observers.length;
|
|
1123
|
+
}
|
|
1124
|
+
#c() {
|
|
1125
|
+
return this.state.fetchStatus === "paused" && this.state.status === "pending";
|
|
1126
|
+
}
|
|
1127
|
+
invalidate() {
|
|
1128
|
+
this.state.isInvalidated || this.#l({ type: "invalidate" });
|
|
1129
|
+
}
|
|
1130
|
+
async fetch(u, z) {
|
|
1131
|
+
if (this.state.fetchStatus !== "idle" && this.#a?.status() !== "rejected") {
|
|
1132
|
+
if (this.state.data !== void 0 && z?.cancelRefetch) this.cancel({ silent: !0 });
|
|
1133
|
+
else if (this.#a) return this.#a.continueRetry(), this.#a.promise;
|
|
1134
|
+
}
|
|
1135
|
+
if (u && this.setOptions(u), !this.options.queryFn) {
|
|
1136
|
+
let u = this.observers.find((u) => u.options.queryFn);
|
|
1137
|
+
u && this.setOptions(u.options);
|
|
1138
|
+
}
|
|
1139
|
+
process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));
|
|
1140
|
+
let B = new AbortController(), V = (u) => {
|
|
1141
|
+
Object.defineProperty(u, "signal", {
|
|
1142
|
+
enumerable: !0,
|
|
1143
|
+
get: () => (this.#s = !0, B.signal)
|
|
1144
|
+
});
|
|
1145
|
+
}, H = () => {
|
|
1146
|
+
let u = ensureQueryFn(this.options, z), B = (() => {
|
|
1147
|
+
let u = {
|
|
1148
|
+
client: this.#i,
|
|
1149
|
+
queryKey: this.queryKey,
|
|
1150
|
+
meta: this.meta
|
|
1151
|
+
};
|
|
1152
|
+
return V(u), u;
|
|
1153
|
+
})();
|
|
1154
|
+
return this.#s = !1, this.options.persister ? this.options.persister(u, B, this) : u(B);
|
|
1155
|
+
}, U = (() => {
|
|
1156
|
+
let u = {
|
|
1157
|
+
fetchOptions: z,
|
|
1158
|
+
options: this.options,
|
|
1159
|
+
queryKey: this.queryKey,
|
|
1160
|
+
client: this.#i,
|
|
1161
|
+
state: this.state,
|
|
1162
|
+
fetchFn: H
|
|
1163
|
+
};
|
|
1164
|
+
return V(u), u;
|
|
1165
|
+
})();
|
|
1166
|
+
(this.#e === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior)?.onFetch(U, this), this.#n = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== U.fetchOptions?.meta) && this.#l({
|
|
1167
|
+
type: "fetch",
|
|
1168
|
+
meta: U.fetchOptions?.meta
|
|
1169
|
+
}), this.#a = createRetryer({
|
|
1170
|
+
initialPromise: z?.initialPromise,
|
|
1171
|
+
fn: U.fetchFn,
|
|
1172
|
+
onCancel: (u) => {
|
|
1173
|
+
u instanceof CancelledError && u.revert && this.setState({
|
|
1174
|
+
...this.#n,
|
|
1175
|
+
fetchStatus: "idle"
|
|
1176
|
+
}), B.abort();
|
|
1177
|
+
},
|
|
1178
|
+
onFail: (u, z) => {
|
|
1179
|
+
this.#l({
|
|
1180
|
+
type: "failed",
|
|
1181
|
+
failureCount: u,
|
|
1182
|
+
error: z
|
|
1183
|
+
});
|
|
1184
|
+
},
|
|
1185
|
+
onPause: () => {
|
|
1186
|
+
this.#l({ type: "pause" });
|
|
1187
|
+
},
|
|
1188
|
+
onContinue: () => {
|
|
1189
|
+
this.#l({ type: "continue" });
|
|
1190
|
+
},
|
|
1191
|
+
retry: U.options.retry,
|
|
1192
|
+
retryDelay: U.options.retryDelay,
|
|
1193
|
+
networkMode: U.options.networkMode,
|
|
1194
|
+
canRun: () => !0
|
|
1195
|
+
});
|
|
1196
|
+
try {
|
|
1197
|
+
let u = await this.#a.start();
|
|
1198
|
+
if (u === void 0) throw process.env.NODE_ENV !== "production" && console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`), Error(`${this.queryHash} data is undefined`);
|
|
1199
|
+
return this.setData(u), this.#r.config.onSuccess?.(u, this), this.#r.config.onSettled?.(u, this.state.error, this), u;
|
|
1200
|
+
} catch (u) {
|
|
1201
|
+
if (u instanceof CancelledError) {
|
|
1202
|
+
if (u.silent) return this.#a.promise;
|
|
1203
|
+
if (u.revert) {
|
|
1204
|
+
if (this.state.data === void 0) throw u;
|
|
1205
|
+
return this.state.data;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
throw this.#l({
|
|
1209
|
+
type: "error",
|
|
1210
|
+
error: u
|
|
1211
|
+
}), this.#r.config.onError?.(u, this), this.#r.config.onSettled?.(this.state.data, u, this), u;
|
|
1212
|
+
} finally {
|
|
1213
|
+
this.scheduleGc();
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
#l(u) {
|
|
1217
|
+
this.state = ((z) => {
|
|
1218
|
+
switch (u.type) {
|
|
1219
|
+
case "failed": return {
|
|
1220
|
+
...z,
|
|
1221
|
+
fetchFailureCount: u.failureCount,
|
|
1222
|
+
fetchFailureReason: u.error
|
|
1223
|
+
};
|
|
1224
|
+
case "pause": return {
|
|
1225
|
+
...z,
|
|
1226
|
+
fetchStatus: "paused"
|
|
1227
|
+
};
|
|
1228
|
+
case "continue": return {
|
|
1229
|
+
...z,
|
|
1230
|
+
fetchStatus: "fetching"
|
|
1231
|
+
};
|
|
1232
|
+
case "fetch": return {
|
|
1233
|
+
...z,
|
|
1234
|
+
...fetchState(z.data, this.options),
|
|
1235
|
+
fetchMeta: u.meta ?? null
|
|
1236
|
+
};
|
|
1237
|
+
case "success":
|
|
1238
|
+
let B = {
|
|
1239
|
+
...z,
|
|
1240
|
+
...successState(u.data, u.dataUpdatedAt),
|
|
1241
|
+
dataUpdateCount: z.dataUpdateCount + 1,
|
|
1242
|
+
...!u.manual && {
|
|
1243
|
+
fetchStatus: "idle",
|
|
1244
|
+
fetchFailureCount: 0,
|
|
1245
|
+
fetchFailureReason: null
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
return this.#n = u.manual ? B : void 0, B;
|
|
1249
|
+
case "error":
|
|
1250
|
+
let V = u.error;
|
|
1251
|
+
return {
|
|
1252
|
+
...z,
|
|
1253
|
+
error: V,
|
|
1254
|
+
errorUpdateCount: z.errorUpdateCount + 1,
|
|
1255
|
+
errorUpdatedAt: Date.now(),
|
|
1256
|
+
fetchFailureCount: z.fetchFailureCount + 1,
|
|
1257
|
+
fetchFailureReason: V,
|
|
1258
|
+
fetchStatus: "idle",
|
|
1259
|
+
status: "error",
|
|
1260
|
+
isInvalidated: !0
|
|
1261
|
+
};
|
|
1262
|
+
case "invalidate": return {
|
|
1263
|
+
...z,
|
|
1264
|
+
isInvalidated: !0
|
|
1265
|
+
};
|
|
1266
|
+
case "setState": return {
|
|
1267
|
+
...z,
|
|
1268
|
+
...u.state
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
})(this.state), notifyManager.batch(() => {
|
|
1272
|
+
this.observers.forEach((u) => {
|
|
1273
|
+
u.onQueryUpdate();
|
|
1274
|
+
}), this.#r.notify({
|
|
1275
|
+
query: this,
|
|
1276
|
+
type: "updated",
|
|
1277
|
+
action: u
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
function fetchState(u, z) {
|
|
1283
|
+
return {
|
|
1284
|
+
fetchFailureCount: 0,
|
|
1285
|
+
fetchFailureReason: null,
|
|
1286
|
+
fetchStatus: canFetch(z.networkMode) ? "fetching" : "paused",
|
|
1287
|
+
...u === void 0 && {
|
|
1288
|
+
error: null,
|
|
1289
|
+
status: "pending"
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
function successState(u, z) {
|
|
1294
|
+
return {
|
|
1295
|
+
data: u,
|
|
1296
|
+
dataUpdatedAt: z ?? Date.now(),
|
|
1297
|
+
error: null,
|
|
1298
|
+
isInvalidated: !1,
|
|
1299
|
+
status: "success"
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
function getDefaultState$1(u) {
|
|
1303
|
+
let z = typeof u.initialData == "function" ? u.initialData() : u.initialData, B = z !== void 0, V = B ? typeof u.initialDataUpdatedAt == "function" ? u.initialDataUpdatedAt() : u.initialDataUpdatedAt : 0;
|
|
1304
|
+
return {
|
|
1305
|
+
data: z,
|
|
1306
|
+
dataUpdateCount: 0,
|
|
1307
|
+
dataUpdatedAt: B ? V ?? Date.now() : 0,
|
|
1308
|
+
error: null,
|
|
1309
|
+
errorUpdateCount: 0,
|
|
1310
|
+
errorUpdatedAt: 0,
|
|
1311
|
+
fetchFailureCount: 0,
|
|
1312
|
+
fetchFailureReason: null,
|
|
1313
|
+
fetchMeta: null,
|
|
1314
|
+
isInvalidated: !1,
|
|
1315
|
+
status: B ? "success" : "pending",
|
|
1316
|
+
fetchStatus: "idle"
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
var Mutation = class extends Removable {
|
|
1320
|
+
#e;
|
|
1321
|
+
#t;
|
|
1322
|
+
#n;
|
|
1323
|
+
#r;
|
|
1324
|
+
constructor(u) {
|
|
1325
|
+
super(), this.#e = u.client, this.mutationId = u.mutationId, this.#n = u.mutationCache, this.#t = [], this.state = u.state || getDefaultState(), this.setOptions(u.options), this.scheduleGc();
|
|
1326
|
+
}
|
|
1327
|
+
setOptions(u) {
|
|
1328
|
+
this.options = u, this.updateGcTime(this.options.gcTime);
|
|
1329
|
+
}
|
|
1330
|
+
get meta() {
|
|
1331
|
+
return this.options.meta;
|
|
1332
|
+
}
|
|
1333
|
+
addObserver(u) {
|
|
1334
|
+
this.#t.includes(u) || (this.#t.push(u), this.clearGcTimeout(), this.#n.notify({
|
|
1335
|
+
type: "observerAdded",
|
|
1336
|
+
mutation: this,
|
|
1337
|
+
observer: u
|
|
1338
|
+
}));
|
|
1339
|
+
}
|
|
1340
|
+
removeObserver(u) {
|
|
1341
|
+
this.#t = this.#t.filter((z) => z !== u), this.scheduleGc(), this.#n.notify({
|
|
1342
|
+
type: "observerRemoved",
|
|
1343
|
+
mutation: this,
|
|
1344
|
+
observer: u
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
optionalRemove() {
|
|
1348
|
+
this.#t.length || (this.state.status === "pending" ? this.scheduleGc() : this.#n.remove(this));
|
|
1349
|
+
}
|
|
1350
|
+
continue() {
|
|
1351
|
+
return this.#r?.continue() ?? this.execute(this.state.variables);
|
|
1352
|
+
}
|
|
1353
|
+
async execute(u) {
|
|
1354
|
+
let z = () => {
|
|
1355
|
+
this.#i({ type: "continue" });
|
|
1356
|
+
}, B = {
|
|
1357
|
+
client: this.#e,
|
|
1358
|
+
meta: this.options.meta,
|
|
1359
|
+
mutationKey: this.options.mutationKey
|
|
1360
|
+
};
|
|
1361
|
+
this.#r = createRetryer({
|
|
1362
|
+
fn: () => this.options.mutationFn ? this.options.mutationFn(u, B) : Promise.reject(/* @__PURE__ */ Error("No mutationFn found")),
|
|
1363
|
+
onFail: (u, z) => {
|
|
1364
|
+
this.#i({
|
|
1365
|
+
type: "failed",
|
|
1366
|
+
failureCount: u,
|
|
1367
|
+
error: z
|
|
1368
|
+
});
|
|
1369
|
+
},
|
|
1370
|
+
onPause: () => {
|
|
1371
|
+
this.#i({ type: "pause" });
|
|
1372
|
+
},
|
|
1373
|
+
onContinue: z,
|
|
1374
|
+
retry: this.options.retry ?? 0,
|
|
1375
|
+
retryDelay: this.options.retryDelay,
|
|
1376
|
+
networkMode: this.options.networkMode,
|
|
1377
|
+
canRun: () => this.#n.canRun(this)
|
|
1378
|
+
});
|
|
1379
|
+
let V = this.state.status === "pending", H = !this.#r.canStart();
|
|
1380
|
+
try {
|
|
1381
|
+
if (V) z();
|
|
1382
|
+
else {
|
|
1383
|
+
this.#i({
|
|
1384
|
+
type: "pending",
|
|
1385
|
+
variables: u,
|
|
1386
|
+
isPaused: H
|
|
1387
|
+
}), this.#n.config.onMutate && await this.#n.config.onMutate(u, this, B);
|
|
1388
|
+
let z = await this.options.onMutate?.(u, B);
|
|
1389
|
+
z !== this.state.context && this.#i({
|
|
1390
|
+
type: "pending",
|
|
1391
|
+
context: z,
|
|
1392
|
+
variables: u,
|
|
1393
|
+
isPaused: H
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
let U = await this.#r.start();
|
|
1397
|
+
return await this.#n.config.onSuccess?.(U, u, this.state.context, this, B), await this.options.onSuccess?.(U, u, this.state.context, B), await this.#n.config.onSettled?.(U, null, this.state.variables, this.state.context, this, B), await this.options.onSettled?.(U, null, u, this.state.context, B), this.#i({
|
|
1398
|
+
type: "success",
|
|
1399
|
+
data: U
|
|
1400
|
+
}), U;
|
|
1401
|
+
} catch (z) {
|
|
1402
|
+
try {
|
|
1403
|
+
await this.#n.config.onError?.(z, u, this.state.context, this, B);
|
|
1404
|
+
} catch (u) {
|
|
1405
|
+
Promise.reject(u);
|
|
1406
|
+
}
|
|
1407
|
+
try {
|
|
1408
|
+
await this.options.onError?.(z, u, this.state.context, B);
|
|
1409
|
+
} catch (u) {
|
|
1410
|
+
Promise.reject(u);
|
|
1411
|
+
}
|
|
1412
|
+
try {
|
|
1413
|
+
await this.#n.config.onSettled?.(void 0, z, this.state.variables, this.state.context, this, B);
|
|
1414
|
+
} catch (u) {
|
|
1415
|
+
Promise.reject(u);
|
|
1416
|
+
}
|
|
1417
|
+
try {
|
|
1418
|
+
await this.options.onSettled?.(void 0, z, u, this.state.context, B);
|
|
1419
|
+
} catch (u) {
|
|
1420
|
+
Promise.reject(u);
|
|
1421
|
+
}
|
|
1422
|
+
throw this.#i({
|
|
1423
|
+
type: "error",
|
|
1424
|
+
error: z
|
|
1425
|
+
}), z;
|
|
1426
|
+
} finally {
|
|
1427
|
+
this.#n.runNext(this);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
#i(u) {
|
|
1431
|
+
this.state = ((z) => {
|
|
1432
|
+
switch (u.type) {
|
|
1433
|
+
case "failed": return {
|
|
1434
|
+
...z,
|
|
1435
|
+
failureCount: u.failureCount,
|
|
1436
|
+
failureReason: u.error
|
|
1437
|
+
};
|
|
1438
|
+
case "pause": return {
|
|
1439
|
+
...z,
|
|
1440
|
+
isPaused: !0
|
|
1441
|
+
};
|
|
1442
|
+
case "continue": return {
|
|
1443
|
+
...z,
|
|
1444
|
+
isPaused: !1
|
|
1445
|
+
};
|
|
1446
|
+
case "pending": return {
|
|
1447
|
+
...z,
|
|
1448
|
+
context: u.context,
|
|
1449
|
+
data: void 0,
|
|
1450
|
+
failureCount: 0,
|
|
1451
|
+
failureReason: null,
|
|
1452
|
+
error: null,
|
|
1453
|
+
isPaused: u.isPaused,
|
|
1454
|
+
status: "pending",
|
|
1455
|
+
variables: u.variables,
|
|
1456
|
+
submittedAt: Date.now()
|
|
1457
|
+
};
|
|
1458
|
+
case "success": return {
|
|
1459
|
+
...z,
|
|
1460
|
+
data: u.data,
|
|
1461
|
+
failureCount: 0,
|
|
1462
|
+
failureReason: null,
|
|
1463
|
+
error: null,
|
|
1464
|
+
status: "success",
|
|
1465
|
+
isPaused: !1
|
|
1466
|
+
};
|
|
1467
|
+
case "error": return {
|
|
1468
|
+
...z,
|
|
1469
|
+
data: void 0,
|
|
1470
|
+
error: u.error,
|
|
1471
|
+
failureCount: z.failureCount + 1,
|
|
1472
|
+
failureReason: u.error,
|
|
1473
|
+
isPaused: !1,
|
|
1474
|
+
status: "error"
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
})(this.state), notifyManager.batch(() => {
|
|
1478
|
+
this.#t.forEach((z) => {
|
|
1479
|
+
z.onMutationUpdate(u);
|
|
1480
|
+
}), this.#n.notify({
|
|
1481
|
+
mutation: this,
|
|
1482
|
+
type: "updated",
|
|
1483
|
+
action: u
|
|
1484
|
+
});
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
};
|
|
1488
|
+
function getDefaultState() {
|
|
1489
|
+
return {
|
|
1490
|
+
context: void 0,
|
|
1491
|
+
data: void 0,
|
|
1492
|
+
error: null,
|
|
1493
|
+
failureCount: 0,
|
|
1494
|
+
failureReason: null,
|
|
1495
|
+
isPaused: !1,
|
|
1496
|
+
status: "idle",
|
|
1497
|
+
variables: void 0,
|
|
1498
|
+
submittedAt: 0
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
var _a$1;
|
|
1502
|
+
function $constructor(u, z, B) {
|
|
1503
|
+
function V(B, V) {
|
|
1504
|
+
if (B._zod || Object.defineProperty(B, "_zod", {
|
|
1505
|
+
value: {
|
|
1506
|
+
def: V,
|
|
1507
|
+
constr: W,
|
|
1508
|
+
traits: /* @__PURE__ */ new Set()
|
|
1509
|
+
},
|
|
1510
|
+
enumerable: !1
|
|
1511
|
+
}), B._zod.traits.has(u)) return;
|
|
1512
|
+
B._zod.traits.add(u), z(B, V);
|
|
1513
|
+
let H = W.prototype, U = Object.keys(H);
|
|
1514
|
+
for (let u = 0; u < U.length; u++) {
|
|
1515
|
+
let z = U[u];
|
|
1516
|
+
z in B || (B[z] = H[z].bind(B));
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
let H = B?.Parent ?? Object;
|
|
1520
|
+
class U extends H {}
|
|
1521
|
+
Object.defineProperty(U, "name", { value: u });
|
|
1522
|
+
function W(u) {
|
|
1523
|
+
var z;
|
|
1524
|
+
let H = B?.Parent ? new U() : this;
|
|
1525
|
+
V(H, u), (z = H._zod).deferred ?? (z.deferred = []);
|
|
1526
|
+
for (let u of H._zod.deferred) u();
|
|
1527
|
+
return H;
|
|
1528
|
+
}
|
|
1529
|
+
return Object.defineProperty(W, "init", { value: V }), Object.defineProperty(W, Symbol.hasInstance, { value: (z) => B?.Parent && z instanceof B.Parent ? !0 : z?._zod?.traits?.has(u) }), Object.defineProperty(W, "name", { value: u }), W;
|
|
1530
|
+
}
|
|
1531
|
+
var $ZodAsyncError = class extends Error {
|
|
1532
|
+
constructor() {
|
|
1533
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
1534
|
+
}
|
|
1535
|
+
}, $ZodEncodeError = class extends Error {
|
|
1536
|
+
constructor(u) {
|
|
1537
|
+
super(`Encountered unidirectional transform during encode: ${u}`), this.name = "ZodEncodeError";
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
1541
|
+
const globalConfig = globalThis.__zod_globalConfig;
|
|
1542
|
+
function config(u) {
|
|
1543
|
+
return u && Object.assign(globalConfig, u), globalConfig;
|
|
1544
|
+
}
|
|
1545
|
+
function getEnumValues(u) {
|
|
1546
|
+
let z = Object.values(u).filter((u) => typeof u == "number");
|
|
1547
|
+
return Object.entries(u).filter(([u, B]) => z.indexOf(+u) === -1).map(([u, z]) => z);
|
|
1548
|
+
}
|
|
1549
|
+
function jsonStringifyReplacer(u, z) {
|
|
1550
|
+
return typeof z == "bigint" ? z.toString() : z;
|
|
1551
|
+
}
|
|
1552
|
+
function cached(u) {
|
|
1553
|
+
return { get value() {
|
|
1554
|
+
{
|
|
1555
|
+
let z = u();
|
|
1556
|
+
return Object.defineProperty(this, "value", { value: z }), z;
|
|
1557
|
+
}
|
|
1558
|
+
throw Error("cached value already set");
|
|
1559
|
+
} };
|
|
1560
|
+
}
|
|
1561
|
+
function nullish(u) {
|
|
1562
|
+
return u == null;
|
|
1563
|
+
}
|
|
1564
|
+
function cleanRegex(u) {
|
|
1565
|
+
let z = u.startsWith("^") ? 1 : 0, B = u.endsWith("$") ? u.length - 1 : u.length;
|
|
1566
|
+
return u.slice(z, B);
|
|
1567
|
+
}
|
|
1568
|
+
var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
1569
|
+
function defineLazy(u, z, B) {
|
|
1570
|
+
let V;
|
|
1571
|
+
Object.defineProperty(u, z, {
|
|
1572
|
+
get() {
|
|
1573
|
+
if (V !== EVALUATING) return V === void 0 && (V = EVALUATING, V = B()), V;
|
|
1574
|
+
},
|
|
1575
|
+
set(B) {
|
|
1576
|
+
Object.defineProperty(u, z, { value: B });
|
|
1577
|
+
},
|
|
1578
|
+
configurable: !0
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
function assignProp(u, z, B) {
|
|
1582
|
+
Object.defineProperty(u, z, {
|
|
1583
|
+
value: B,
|
|
1584
|
+
writable: !0,
|
|
1585
|
+
enumerable: !0,
|
|
1586
|
+
configurable: !0
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
function mergeDefs(...u) {
|
|
1590
|
+
let z = {};
|
|
1591
|
+
for (let B of u) {
|
|
1592
|
+
let u = Object.getOwnPropertyDescriptors(B);
|
|
1593
|
+
Object.assign(z, u);
|
|
1594
|
+
}
|
|
1595
|
+
return Object.defineProperties({}, z);
|
|
1596
|
+
}
|
|
1597
|
+
function esc(u) {
|
|
1598
|
+
return JSON.stringify(u);
|
|
1599
|
+
}
|
|
1600
|
+
function slugify(u) {
|
|
1601
|
+
return u.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1602
|
+
}
|
|
1603
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (...u) => {};
|
|
1604
|
+
function isObject(u) {
|
|
1605
|
+
return typeof u == "object" && !!u && !Array.isArray(u);
|
|
1606
|
+
}
|
|
1607
|
+
const allowsEval = /* @__PURE__ */ cached(() => {
|
|
1608
|
+
if (globalConfig.jitless || typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare")) return !1;
|
|
1609
|
+
try {
|
|
1610
|
+
return Function(""), !0;
|
|
1611
|
+
} catch {
|
|
1612
|
+
return !1;
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
function isPlainObject(u) {
|
|
1616
|
+
if (isObject(u) === !1) return !1;
|
|
1617
|
+
let z = u.constructor;
|
|
1618
|
+
if (z === void 0 || typeof z != "function") return !0;
|
|
1619
|
+
let B = z.prototype;
|
|
1620
|
+
return !(isObject(B) === !1 || Object.prototype.hasOwnProperty.call(B, "isPrototypeOf") === !1);
|
|
1621
|
+
}
|
|
1622
|
+
function shallowClone(u) {
|
|
1623
|
+
return isPlainObject(u) ? { ...u } : Array.isArray(u) ? [...u] : u instanceof Map ? new Map(u) : u instanceof Set ? new Set(u) : u;
|
|
1624
|
+
}
|
|
1625
|
+
const propertyKeyTypes = /* @__PURE__ */ new Set([
|
|
1626
|
+
"string",
|
|
1627
|
+
"number",
|
|
1628
|
+
"symbol"
|
|
1629
|
+
]);
|
|
1630
|
+
function escapeRegex(u) {
|
|
1631
|
+
return u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1632
|
+
}
|
|
1633
|
+
function clone(u, z, B) {
|
|
1634
|
+
let V = new u._zod.constr(z ?? u._zod.def);
|
|
1635
|
+
return (!z || B?.parent) && (V._zod.parent = u), V;
|
|
1636
|
+
}
|
|
1637
|
+
function normalizeParams(u) {
|
|
1638
|
+
let z = u;
|
|
1639
|
+
if (!z) return {};
|
|
1640
|
+
if (typeof z == "string") return { error: () => z };
|
|
1641
|
+
if (z?.message !== void 0) {
|
|
1642
|
+
if (z?.error !== void 0) throw Error("Cannot specify both `message` and `error` params");
|
|
1643
|
+
z.error = z.message;
|
|
1644
|
+
}
|
|
1645
|
+
return delete z.message, typeof z.error == "string" ? {
|
|
1646
|
+
...z,
|
|
1647
|
+
error: () => z.error
|
|
1648
|
+
} : z;
|
|
1649
|
+
}
|
|
1650
|
+
function optionalKeys(u) {
|
|
1651
|
+
return Object.keys(u).filter((z) => u[z]._zod.optin === "optional" && u[z]._zod.optout === "optional");
|
|
1652
|
+
}
|
|
1653
|
+
-Number.MAX_VALUE, Number.MAX_VALUE;
|
|
1654
|
+
function pick(u, z) {
|
|
1655
|
+
let B = u._zod.def, V = B.checks;
|
|
1656
|
+
if (V && V.length > 0) throw Error(".pick() cannot be used on object schemas containing refinements");
|
|
1657
|
+
return clone(u, mergeDefs(u._zod.def, {
|
|
1658
|
+
get shape() {
|
|
1659
|
+
let u = {};
|
|
1660
|
+
for (let V in z) {
|
|
1661
|
+
if (!(V in B.shape)) throw Error(`Unrecognized key: "${V}"`);
|
|
1662
|
+
z[V] && (u[V] = B.shape[V]);
|
|
1663
|
+
}
|
|
1664
|
+
return assignProp(this, "shape", u), u;
|
|
1665
|
+
},
|
|
1666
|
+
checks: []
|
|
1667
|
+
}));
|
|
1668
|
+
}
|
|
1669
|
+
function omit(u, z) {
|
|
1670
|
+
let B = u._zod.def, V = B.checks;
|
|
1671
|
+
if (V && V.length > 0) throw Error(".omit() cannot be used on object schemas containing refinements");
|
|
1672
|
+
return clone(u, mergeDefs(u._zod.def, {
|
|
1673
|
+
get shape() {
|
|
1674
|
+
let V = { ...u._zod.def.shape };
|
|
1675
|
+
for (let u in z) {
|
|
1676
|
+
if (!(u in B.shape)) throw Error(`Unrecognized key: "${u}"`);
|
|
1677
|
+
z[u] && delete V[u];
|
|
1678
|
+
}
|
|
1679
|
+
return assignProp(this, "shape", V), V;
|
|
1680
|
+
},
|
|
1681
|
+
checks: []
|
|
1682
|
+
}));
|
|
1683
|
+
}
|
|
1684
|
+
function extend(u, z) {
|
|
1685
|
+
if (!isPlainObject(z)) throw Error("Invalid input to extend: expected a plain object");
|
|
1686
|
+
let B = u._zod.def.checks;
|
|
1687
|
+
if (B && B.length > 0) {
|
|
1688
|
+
let B = u._zod.def.shape;
|
|
1689
|
+
for (let u in z) if (Object.getOwnPropertyDescriptor(B, u) !== void 0) throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1690
|
+
}
|
|
1691
|
+
return clone(u, mergeDefs(u._zod.def, { get shape() {
|
|
1692
|
+
let B = {
|
|
1693
|
+
...u._zod.def.shape,
|
|
1694
|
+
...z
|
|
1695
|
+
};
|
|
1696
|
+
return assignProp(this, "shape", B), B;
|
|
1697
|
+
} }));
|
|
1698
|
+
}
|
|
1699
|
+
function safeExtend(u, z) {
|
|
1700
|
+
if (!isPlainObject(z)) throw Error("Invalid input to safeExtend: expected a plain object");
|
|
1701
|
+
return clone(u, mergeDefs(u._zod.def, { get shape() {
|
|
1702
|
+
let B = {
|
|
1703
|
+
...u._zod.def.shape,
|
|
1704
|
+
...z
|
|
1705
|
+
};
|
|
1706
|
+
return assignProp(this, "shape", B), B;
|
|
1707
|
+
} }));
|
|
1708
|
+
}
|
|
1709
|
+
function merge(u, z) {
|
|
1710
|
+
if (u._zod.def.checks?.length) throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
|
|
1711
|
+
return clone(u, mergeDefs(u._zod.def, {
|
|
1712
|
+
get shape() {
|
|
1713
|
+
let B = {
|
|
1714
|
+
...u._zod.def.shape,
|
|
1715
|
+
...z._zod.def.shape
|
|
1716
|
+
};
|
|
1717
|
+
return assignProp(this, "shape", B), B;
|
|
1718
|
+
},
|
|
1719
|
+
get catchall() {
|
|
1720
|
+
return z._zod.def.catchall;
|
|
1721
|
+
},
|
|
1722
|
+
checks: z._zod.def.checks ?? []
|
|
1723
|
+
}));
|
|
1724
|
+
}
|
|
1725
|
+
function partial(u, z, B) {
|
|
1726
|
+
let V = z._zod.def.checks;
|
|
1727
|
+
if (V && V.length > 0) throw Error(".partial() cannot be used on object schemas containing refinements");
|
|
1728
|
+
return clone(z, mergeDefs(z._zod.def, {
|
|
1729
|
+
get shape() {
|
|
1730
|
+
let V = z._zod.def.shape, H = { ...V };
|
|
1731
|
+
if (B) for (let z in B) {
|
|
1732
|
+
if (!(z in V)) throw Error(`Unrecognized key: "${z}"`);
|
|
1733
|
+
B[z] && (H[z] = u ? new u({
|
|
1734
|
+
type: "optional",
|
|
1735
|
+
innerType: V[z]
|
|
1736
|
+
}) : V[z]);
|
|
1737
|
+
}
|
|
1738
|
+
else for (let z in V) H[z] = u ? new u({
|
|
1739
|
+
type: "optional",
|
|
1740
|
+
innerType: V[z]
|
|
1741
|
+
}) : V[z];
|
|
1742
|
+
return assignProp(this, "shape", H), H;
|
|
1743
|
+
},
|
|
1744
|
+
checks: []
|
|
1745
|
+
}));
|
|
1746
|
+
}
|
|
1747
|
+
function required(u, z, B) {
|
|
1748
|
+
return clone(z, mergeDefs(z._zod.def, { get shape() {
|
|
1749
|
+
let V = z._zod.def.shape, H = { ...V };
|
|
1750
|
+
if (B) for (let z in B) {
|
|
1751
|
+
if (!(z in H)) throw Error(`Unrecognized key: "${z}"`);
|
|
1752
|
+
B[z] && (H[z] = new u({
|
|
1753
|
+
type: "nonoptional",
|
|
1754
|
+
innerType: V[z]
|
|
1755
|
+
}));
|
|
1756
|
+
}
|
|
1757
|
+
else for (let z in V) H[z] = new u({
|
|
1758
|
+
type: "nonoptional",
|
|
1759
|
+
innerType: V[z]
|
|
1760
|
+
});
|
|
1761
|
+
return assignProp(this, "shape", H), H;
|
|
1762
|
+
} }));
|
|
1763
|
+
}
|
|
1764
|
+
function aborted(u, z = 0) {
|
|
1765
|
+
if (u.aborted === !0) return !0;
|
|
1766
|
+
for (let B = z; B < u.issues.length; B++) if (u.issues[B]?.continue !== !0) return !0;
|
|
1767
|
+
return !1;
|
|
1768
|
+
}
|
|
1769
|
+
function explicitlyAborted(u, z = 0) {
|
|
1770
|
+
if (u.aborted === !0) return !0;
|
|
1771
|
+
for (let B = z; B < u.issues.length; B++) if (u.issues[B]?.continue === !1) return !0;
|
|
1772
|
+
return !1;
|
|
1773
|
+
}
|
|
1774
|
+
function prefixIssues(u, z) {
|
|
1775
|
+
return z.map((z) => {
|
|
1776
|
+
var B;
|
|
1777
|
+
return (B = z).path ?? (B.path = []), z.path.unshift(u), z;
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
function unwrapMessage(u) {
|
|
1781
|
+
return typeof u == "string" ? u : u?.message;
|
|
1782
|
+
}
|
|
1783
|
+
function finalizeIssue(u, z, B) {
|
|
1784
|
+
let V = u.message ? u.message : unwrapMessage(u.inst?._zod.def?.error?.(u)) ?? unwrapMessage(z?.error?.(u)) ?? unwrapMessage(B.customError?.(u)) ?? unwrapMessage(B.localeError?.(u)) ?? "Invalid input", { inst: H, continue: U, input: W,...G } = u;
|
|
1785
|
+
return G.path ??= [], G.message = V, z?.reportInput && (G.input = W), G;
|
|
1786
|
+
}
|
|
1787
|
+
function getLengthableOrigin(u) {
|
|
1788
|
+
return Array.isArray(u) ? "array" : typeof u == "string" ? "string" : "unknown";
|
|
1789
|
+
}
|
|
1790
|
+
function issue(...u) {
|
|
1791
|
+
let [z, B, V] = u;
|
|
1792
|
+
return typeof z == "string" ? {
|
|
1793
|
+
message: z,
|
|
1794
|
+
code: "custom",
|
|
1795
|
+
input: B,
|
|
1796
|
+
inst: V
|
|
1797
|
+
} : { ...z };
|
|
1798
|
+
}
|
|
1799
|
+
var initializer$1 = (u, z) => {
|
|
1800
|
+
u.name = "$ZodError", Object.defineProperty(u, "_zod", {
|
|
1801
|
+
value: u._zod,
|
|
1802
|
+
enumerable: !1
|
|
1803
|
+
}), Object.defineProperty(u, "issues", {
|
|
1804
|
+
value: z,
|
|
1805
|
+
enumerable: !1
|
|
1806
|
+
}), u.message = JSON.stringify(z, jsonStringifyReplacer, 2), Object.defineProperty(u, "toString", {
|
|
1807
|
+
value: () => u.message,
|
|
1808
|
+
enumerable: !1
|
|
1809
|
+
});
|
|
1810
|
+
};
|
|
1811
|
+
const $ZodError = $constructor("$ZodError", initializer$1), $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
1812
|
+
function flattenError(u, z = (u) => u.message) {
|
|
1813
|
+
let B = {}, V = [];
|
|
1814
|
+
for (let H of u.issues) H.path.length > 0 ? (B[H.path[0]] = B[H.path[0]] || [], B[H.path[0]].push(z(H))) : V.push(z(H));
|
|
1815
|
+
return {
|
|
1816
|
+
formErrors: V,
|
|
1817
|
+
fieldErrors: B
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
function formatError(u, z = (u) => u.message) {
|
|
1821
|
+
let B = { _errors: [] }, V = (u, H = []) => {
|
|
1822
|
+
for (let U of u.issues) if (U.code === "invalid_union" && U.errors.length) U.errors.map((u) => V({ issues: u }, [...H, ...U.path]));
|
|
1823
|
+
else if (U.code === "invalid_key") V({ issues: U.issues }, [...H, ...U.path]);
|
|
1824
|
+
else if (U.code === "invalid_element") V({ issues: U.issues }, [...H, ...U.path]);
|
|
1825
|
+
else {
|
|
1826
|
+
let u = [...H, ...U.path];
|
|
1827
|
+
if (u.length === 0) B._errors.push(z(U));
|
|
1828
|
+
else {
|
|
1829
|
+
let V = B, H = 0;
|
|
1830
|
+
for (; H < u.length;) {
|
|
1831
|
+
let B = u[H];
|
|
1832
|
+
H === u.length - 1 ? (V[B] = V[B] || { _errors: [] }, V[B]._errors.push(z(U))) : V[B] = V[B] || { _errors: [] }, V = V[B], H++;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
return V(u), B;
|
|
1838
|
+
}
|
|
1839
|
+
const _parse = (u) => (z, B, V, H) => {
|
|
1840
|
+
let U = V ? {
|
|
1841
|
+
...V,
|
|
1842
|
+
async: !1
|
|
1843
|
+
} : { async: !1 }, W = z._zod.run({
|
|
1844
|
+
value: B,
|
|
1845
|
+
issues: []
|
|
1846
|
+
}, U);
|
|
1847
|
+
if (W instanceof Promise) throw new $ZodAsyncError();
|
|
1848
|
+
if (W.issues.length) {
|
|
1849
|
+
let z = new (H?.Err ?? u)(W.issues.map((u) => finalizeIssue(u, U, config())));
|
|
1850
|
+
throw captureStackTrace(z, H?.callee), z;
|
|
1851
|
+
}
|
|
1852
|
+
return W.value;
|
|
1853
|
+
}, _parseAsync = (u) => async (z, B, V, H) => {
|
|
1854
|
+
let U = V ? {
|
|
1855
|
+
...V,
|
|
1856
|
+
async: !0
|
|
1857
|
+
} : { async: !0 }, W = z._zod.run({
|
|
1858
|
+
value: B,
|
|
1859
|
+
issues: []
|
|
1860
|
+
}, U);
|
|
1861
|
+
if (W instanceof Promise && (W = await W), W.issues.length) {
|
|
1862
|
+
let z = new (H?.Err ?? u)(W.issues.map((u) => finalizeIssue(u, U, config())));
|
|
1863
|
+
throw captureStackTrace(z, H?.callee), z;
|
|
1864
|
+
}
|
|
1865
|
+
return W.value;
|
|
1866
|
+
}, _safeParse = (u) => (z, B, V) => {
|
|
1867
|
+
let H = V ? {
|
|
1868
|
+
...V,
|
|
1869
|
+
async: !1
|
|
1870
|
+
} : { async: !1 }, U = z._zod.run({
|
|
1871
|
+
value: B,
|
|
1872
|
+
issues: []
|
|
1873
|
+
}, H);
|
|
1874
|
+
if (U instanceof Promise) throw new $ZodAsyncError();
|
|
1875
|
+
return U.issues.length ? {
|
|
1876
|
+
success: !1,
|
|
1877
|
+
error: new (u ?? $ZodError)(U.issues.map((u) => finalizeIssue(u, H, config())))
|
|
1878
|
+
} : {
|
|
1879
|
+
success: !0,
|
|
1880
|
+
data: U.value
|
|
1881
|
+
};
|
|
1882
|
+
}, safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError), _safeParseAsync = (u) => async (z, B, V) => {
|
|
1883
|
+
let H = V ? {
|
|
1884
|
+
...V,
|
|
1885
|
+
async: !0
|
|
1886
|
+
} : { async: !0 }, U = z._zod.run({
|
|
1887
|
+
value: B,
|
|
1888
|
+
issues: []
|
|
1889
|
+
}, H);
|
|
1890
|
+
return U instanceof Promise && (U = await U), U.issues.length ? {
|
|
1891
|
+
success: !1,
|
|
1892
|
+
error: new u(U.issues.map((u) => finalizeIssue(u, H, config())))
|
|
1893
|
+
} : {
|
|
1894
|
+
success: !0,
|
|
1895
|
+
data: U.value
|
|
1896
|
+
};
|
|
1897
|
+
}, safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError), _encode = (u) => (z, B, V) => {
|
|
1898
|
+
let H = V ? {
|
|
1899
|
+
...V,
|
|
1900
|
+
direction: "backward"
|
|
1901
|
+
} : { direction: "backward" };
|
|
1902
|
+
return _parse(u)(z, B, H);
|
|
1903
|
+
}, _decode = (u) => (z, B, V) => _parse(u)(z, B, V), _encodeAsync = (u) => async (z, B, V) => {
|
|
1904
|
+
let H = V ? {
|
|
1905
|
+
...V,
|
|
1906
|
+
direction: "backward"
|
|
1907
|
+
} : { direction: "backward" };
|
|
1908
|
+
return _parseAsync(u)(z, B, H);
|
|
1909
|
+
}, _decodeAsync = (u) => async (z, B, V) => _parseAsync(u)(z, B, V), _safeEncode = (u) => (z, B, V) => {
|
|
1910
|
+
let H = V ? {
|
|
1911
|
+
...V,
|
|
1912
|
+
direction: "backward"
|
|
1913
|
+
} : { direction: "backward" };
|
|
1914
|
+
return _safeParse(u)(z, B, H);
|
|
1915
|
+
}, _safeDecode = (u) => (z, B, V) => _safeParse(u)(z, B, V), _safeEncodeAsync = (u) => async (z, B, V) => {
|
|
1916
|
+
let H = V ? {
|
|
1917
|
+
...V,
|
|
1918
|
+
direction: "backward"
|
|
1919
|
+
} : { direction: "backward" };
|
|
1920
|
+
return _safeParseAsync(u)(z, B, H);
|
|
1921
|
+
}, _safeDecodeAsync = (u) => async (z, B, V) => _safeParseAsync(u)(z, B, V), cuid = /^[cC][0-9a-z]{6,}$/, cuid2 = /^[0-9a-z]+$/, ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, xid = /^[0-9a-vA-V]{20}$/, ksuid = /^[A-Za-z0-9]{27}$/, nanoid = /^[a-zA-Z0-9_-]{21}$/, duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, guid = /^([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})$/, uuid = (u) => u ? /* @__PURE__ */ RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${u}[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)$/, email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1922
|
+
var _emoji$1 = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1923
|
+
function emoji() {
|
|
1924
|
+
return new RegExp(_emoji$1, "u");
|
|
1925
|
+
}
|
|
1926
|
+
const ipv4 = /^(?:(?: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])$/, ipv6 = /^(([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}|:))$/, cidrv4 = /^((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])$/, cidrv6 = /^(([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])$/, base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, base64url = /^[A-Za-z0-9_-]*$/, httpProtocol = /^https?$/, e164 = /^\+[1-9]\d{6,14}$/;
|
|
1927
|
+
var dateSource = "(?:(?:\\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])))";
|
|
1928
|
+
const date$1 = /* @__PURE__ */ RegExp(`^${dateSource}$`);
|
|
1929
|
+
function timeSource(u) {
|
|
1930
|
+
let z = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
1931
|
+
return typeof u.precision == "number" ? u.precision === -1 ? `${z}` : u.precision === 0 ? `${z}:[0-5]\\d` : `${z}:[0-5]\\d\\.\\d{${u.precision}}` : `${z}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
1932
|
+
}
|
|
1933
|
+
function time$1(u) {
|
|
1934
|
+
return /* @__PURE__ */ RegExp(`^${timeSource(u)}$`);
|
|
1935
|
+
}
|
|
1936
|
+
function datetime$1(u) {
|
|
1937
|
+
let z = timeSource({ precision: u.precision }), B = ["Z"];
|
|
1938
|
+
u.local && B.push(""), u.offset && B.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
1939
|
+
let V = `${z}(?:${B.join("|")})`;
|
|
1940
|
+
return /* @__PURE__ */ RegExp(`^${dateSource}T(?:${V})$`);
|
|
1941
|
+
}
|
|
1942
|
+
const string$1 = (u) => {
|
|
1943
|
+
let z = u ? `[\\s\\S]{${u?.minimum ?? 0},${u?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
1944
|
+
return /* @__PURE__ */ RegExp(`^${z}$`);
|
|
1945
|
+
}, number = /^-?\d+(?:\.\d+)?$/, lowercase = /^[^A-Z]*$/, uppercase = /^[^a-z]*$/, $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (u, z) => {
|
|
1946
|
+
var B;
|
|
1947
|
+
u._zod ??= {}, u._zod.def = z, (B = u._zod).onattach ?? (B.onattach = []);
|
|
1948
|
+
}), $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (u, z) => {
|
|
1949
|
+
var B;
|
|
1950
|
+
$ZodCheck.init(u, z), (B = u._zod.def).when ?? (B.when = (u) => {
|
|
1951
|
+
let z = u.value;
|
|
1952
|
+
return !nullish(z) && z.length !== void 0;
|
|
1953
|
+
}), u._zod.onattach.push((u) => {
|
|
1954
|
+
let B = u._zod.bag.maximum ?? Infinity;
|
|
1955
|
+
z.maximum < B && (u._zod.bag.maximum = z.maximum);
|
|
1956
|
+
}), u._zod.check = (B) => {
|
|
1957
|
+
let V = B.value;
|
|
1958
|
+
if (V.length <= z.maximum) return;
|
|
1959
|
+
let H = getLengthableOrigin(V);
|
|
1960
|
+
B.issues.push({
|
|
1961
|
+
origin: H,
|
|
1962
|
+
code: "too_big",
|
|
1963
|
+
maximum: z.maximum,
|
|
1964
|
+
inclusive: !0,
|
|
1965
|
+
input: V,
|
|
1966
|
+
inst: u,
|
|
1967
|
+
continue: !z.abort
|
|
1968
|
+
});
|
|
1969
|
+
};
|
|
1970
|
+
}), $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (u, z) => {
|
|
1971
|
+
var B;
|
|
1972
|
+
$ZodCheck.init(u, z), (B = u._zod.def).when ?? (B.when = (u) => {
|
|
1973
|
+
let z = u.value;
|
|
1974
|
+
return !nullish(z) && z.length !== void 0;
|
|
1975
|
+
}), u._zod.onattach.push((u) => {
|
|
1976
|
+
let B = u._zod.bag.minimum ?? -Infinity;
|
|
1977
|
+
z.minimum > B && (u._zod.bag.minimum = z.minimum);
|
|
1978
|
+
}), u._zod.check = (B) => {
|
|
1979
|
+
let V = B.value;
|
|
1980
|
+
if (V.length >= z.minimum) return;
|
|
1981
|
+
let H = getLengthableOrigin(V);
|
|
1982
|
+
B.issues.push({
|
|
1983
|
+
origin: H,
|
|
1984
|
+
code: "too_small",
|
|
1985
|
+
minimum: z.minimum,
|
|
1986
|
+
inclusive: !0,
|
|
1987
|
+
input: V,
|
|
1988
|
+
inst: u,
|
|
1989
|
+
continue: !z.abort
|
|
1990
|
+
});
|
|
1991
|
+
};
|
|
1992
|
+
}), $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (u, z) => {
|
|
1993
|
+
var B;
|
|
1994
|
+
$ZodCheck.init(u, z), (B = u._zod.def).when ?? (B.when = (u) => {
|
|
1995
|
+
let z = u.value;
|
|
1996
|
+
return !nullish(z) && z.length !== void 0;
|
|
1997
|
+
}), u._zod.onattach.push((u) => {
|
|
1998
|
+
let B = u._zod.bag;
|
|
1999
|
+
B.minimum = z.length, B.maximum = z.length, B.length = z.length;
|
|
2000
|
+
}), u._zod.check = (B) => {
|
|
2001
|
+
let V = B.value, H = V.length;
|
|
2002
|
+
if (H === z.length) return;
|
|
2003
|
+
let U = getLengthableOrigin(V), W = H > z.length;
|
|
2004
|
+
B.issues.push({
|
|
2005
|
+
origin: U,
|
|
2006
|
+
...W ? {
|
|
2007
|
+
code: "too_big",
|
|
2008
|
+
maximum: z.length
|
|
2009
|
+
} : {
|
|
2010
|
+
code: "too_small",
|
|
2011
|
+
minimum: z.length
|
|
2012
|
+
},
|
|
2013
|
+
inclusive: !0,
|
|
2014
|
+
exact: !0,
|
|
2015
|
+
input: B.value,
|
|
2016
|
+
inst: u,
|
|
2017
|
+
continue: !z.abort
|
|
2018
|
+
});
|
|
2019
|
+
};
|
|
2020
|
+
}), $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (u, z) => {
|
|
2021
|
+
var B, V;
|
|
2022
|
+
$ZodCheck.init(u, z), u._zod.onattach.push((u) => {
|
|
2023
|
+
let B = u._zod.bag;
|
|
2024
|
+
B.format = z.format, z.pattern && (B.patterns ??= /* @__PURE__ */ new Set(), B.patterns.add(z.pattern));
|
|
2025
|
+
}), z.pattern ? (B = u._zod).check ?? (B.check = (B) => {
|
|
2026
|
+
z.pattern.lastIndex = 0, !z.pattern.test(B.value) && B.issues.push({
|
|
2027
|
+
origin: "string",
|
|
2028
|
+
code: "invalid_format",
|
|
2029
|
+
format: z.format,
|
|
2030
|
+
input: B.value,
|
|
2031
|
+
...z.pattern ? { pattern: z.pattern.toString() } : {},
|
|
2032
|
+
inst: u,
|
|
2033
|
+
continue: !z.abort
|
|
2034
|
+
});
|
|
2035
|
+
}) : (V = u._zod).check ?? (V.check = () => {});
|
|
2036
|
+
}), $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (u, z) => {
|
|
2037
|
+
$ZodCheckStringFormat.init(u, z), u._zod.check = (B) => {
|
|
2038
|
+
z.pattern.lastIndex = 0, !z.pattern.test(B.value) && B.issues.push({
|
|
2039
|
+
origin: "string",
|
|
2040
|
+
code: "invalid_format",
|
|
2041
|
+
format: "regex",
|
|
2042
|
+
input: B.value,
|
|
2043
|
+
pattern: z.pattern.toString(),
|
|
2044
|
+
inst: u,
|
|
2045
|
+
continue: !z.abort
|
|
2046
|
+
});
|
|
2047
|
+
};
|
|
2048
|
+
}), $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (u, z) => {
|
|
2049
|
+
z.pattern ??= lowercase, $ZodCheckStringFormat.init(u, z);
|
|
2050
|
+
}), $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (u, z) => {
|
|
2051
|
+
z.pattern ??= uppercase, $ZodCheckStringFormat.init(u, z);
|
|
2052
|
+
}), $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (u, z) => {
|
|
2053
|
+
$ZodCheck.init(u, z);
|
|
2054
|
+
let B = escapeRegex(z.includes), V = new RegExp(typeof z.position == "number" ? `^.{${z.position}}${B}` : B);
|
|
2055
|
+
z.pattern = V, u._zod.onattach.push((u) => {
|
|
2056
|
+
let z = u._zod.bag;
|
|
2057
|
+
z.patterns ??= /* @__PURE__ */ new Set(), z.patterns.add(V);
|
|
2058
|
+
}), u._zod.check = (B) => {
|
|
2059
|
+
B.value.includes(z.includes, z.position) || B.issues.push({
|
|
2060
|
+
origin: "string",
|
|
2061
|
+
code: "invalid_format",
|
|
2062
|
+
format: "includes",
|
|
2063
|
+
includes: z.includes,
|
|
2064
|
+
input: B.value,
|
|
2065
|
+
inst: u,
|
|
2066
|
+
continue: !z.abort
|
|
2067
|
+
});
|
|
2068
|
+
};
|
|
2069
|
+
}), $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (u, z) => {
|
|
2070
|
+
$ZodCheck.init(u, z);
|
|
2071
|
+
let B = /* @__PURE__ */ RegExp(`^${escapeRegex(z.prefix)}.*`);
|
|
2072
|
+
z.pattern ??= B, u._zod.onattach.push((u) => {
|
|
2073
|
+
let z = u._zod.bag;
|
|
2074
|
+
z.patterns ??= /* @__PURE__ */ new Set(), z.patterns.add(B);
|
|
2075
|
+
}), u._zod.check = (B) => {
|
|
2076
|
+
B.value.startsWith(z.prefix) || B.issues.push({
|
|
2077
|
+
origin: "string",
|
|
2078
|
+
code: "invalid_format",
|
|
2079
|
+
format: "starts_with",
|
|
2080
|
+
prefix: z.prefix,
|
|
2081
|
+
input: B.value,
|
|
2082
|
+
inst: u,
|
|
2083
|
+
continue: !z.abort
|
|
2084
|
+
});
|
|
2085
|
+
};
|
|
2086
|
+
}), $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (u, z) => {
|
|
2087
|
+
$ZodCheck.init(u, z);
|
|
2088
|
+
let B = /* @__PURE__ */ RegExp(`.*${escapeRegex(z.suffix)}$`);
|
|
2089
|
+
z.pattern ??= B, u._zod.onattach.push((u) => {
|
|
2090
|
+
let z = u._zod.bag;
|
|
2091
|
+
z.patterns ??= /* @__PURE__ */ new Set(), z.patterns.add(B);
|
|
2092
|
+
}), u._zod.check = (B) => {
|
|
2093
|
+
B.value.endsWith(z.suffix) || B.issues.push({
|
|
2094
|
+
origin: "string",
|
|
2095
|
+
code: "invalid_format",
|
|
2096
|
+
format: "ends_with",
|
|
2097
|
+
suffix: z.suffix,
|
|
2098
|
+
input: B.value,
|
|
2099
|
+
inst: u,
|
|
2100
|
+
continue: !z.abort
|
|
2101
|
+
});
|
|
2102
|
+
};
|
|
2103
|
+
}), $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (u, z) => {
|
|
2104
|
+
$ZodCheck.init(u, z), u._zod.check = (u) => {
|
|
2105
|
+
u.value = z.tx(u.value);
|
|
2106
|
+
};
|
|
2107
|
+
});
|
|
2108
|
+
var Doc = class {
|
|
2109
|
+
constructor(u = []) {
|
|
2110
|
+
this.content = [], this.indent = 0, this && (this.args = u);
|
|
2111
|
+
}
|
|
2112
|
+
indented(u) {
|
|
2113
|
+
this.indent += 1, u(this), --this.indent;
|
|
2114
|
+
}
|
|
2115
|
+
write(u) {
|
|
2116
|
+
if (typeof u == "function") {
|
|
2117
|
+
u(this, { execution: "sync" }), u(this, { execution: "async" });
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
let z = u.split("\n").filter((u) => u), B = Math.min(...z.map((u) => u.length - u.trimStart().length)), V = z.map((u) => u.slice(B)).map((u) => " ".repeat(this.indent * 2) + u);
|
|
2121
|
+
for (let u of V) this.content.push(u);
|
|
2122
|
+
}
|
|
2123
|
+
compile() {
|
|
2124
|
+
let u = Function, z = this?.args, B = [...(this?.content ?? [""]).map((u) => ` ${u}`)];
|
|
2125
|
+
return new u(...z, B.join("\n"));
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
const version = {
|
|
2129
|
+
major: 4,
|
|
2130
|
+
minor: 4,
|
|
2131
|
+
patch: 3
|
|
2132
|
+
}, $ZodType = /* @__PURE__ */ $constructor("$ZodType", (u, z) => {
|
|
2133
|
+
var B;
|
|
2134
|
+
u ??= {}, u._zod.def = z, u._zod.bag = u._zod.bag || {}, u._zod.version = version;
|
|
2135
|
+
let V = [...u._zod.def.checks ?? []];
|
|
2136
|
+
u._zod.traits.has("$ZodCheck") && V.unshift(u);
|
|
2137
|
+
for (let z of V) for (let B of z._zod.onattach) B(u);
|
|
2138
|
+
if (V.length === 0) (B = u._zod).deferred ?? (B.deferred = []), u._zod.deferred?.push(() => {
|
|
2139
|
+
u._zod.run = u._zod.parse;
|
|
2140
|
+
});
|
|
2141
|
+
else {
|
|
2142
|
+
let z = (u, z, B) => {
|
|
2143
|
+
let V = aborted(u), H;
|
|
2144
|
+
for (let U of z) {
|
|
2145
|
+
if (U._zod.def.when) {
|
|
2146
|
+
if (explicitlyAborted(u) || !U._zod.def.when(u)) continue;
|
|
2147
|
+
} else if (V) continue;
|
|
2148
|
+
let z = u.issues.length, W = U._zod.check(u);
|
|
2149
|
+
if (W instanceof Promise && B?.async === !1) throw new $ZodAsyncError();
|
|
2150
|
+
if (H || W instanceof Promise) H = (H ?? Promise.resolve()).then(async () => {
|
|
2151
|
+
await W, u.issues.length !== z && (V ||= aborted(u, z));
|
|
2152
|
+
});
|
|
2153
|
+
else {
|
|
2154
|
+
if (u.issues.length === z) continue;
|
|
2155
|
+
V ||= aborted(u, z);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
return H ? H.then(() => u) : u;
|
|
2159
|
+
}, B = (B, H, U) => {
|
|
2160
|
+
if (aborted(B)) return B.aborted = !0, B;
|
|
2161
|
+
let W = z(H, V, U);
|
|
2162
|
+
if (W instanceof Promise) {
|
|
2163
|
+
if (U.async === !1) throw new $ZodAsyncError();
|
|
2164
|
+
return W.then((z) => u._zod.parse(z, U));
|
|
2165
|
+
}
|
|
2166
|
+
return u._zod.parse(W, U);
|
|
2167
|
+
};
|
|
2168
|
+
u._zod.run = (H, U) => {
|
|
2169
|
+
if (U.skipChecks) return u._zod.parse(H, U);
|
|
2170
|
+
if (U.direction === "backward") {
|
|
2171
|
+
let z = u._zod.parse({
|
|
2172
|
+
value: H.value,
|
|
2173
|
+
issues: []
|
|
2174
|
+
}, {
|
|
2175
|
+
...U,
|
|
2176
|
+
skipChecks: !0
|
|
2177
|
+
});
|
|
2178
|
+
return z instanceof Promise ? z.then((u) => B(u, H, U)) : B(z, H, U);
|
|
2179
|
+
}
|
|
2180
|
+
let W = u._zod.parse(H, U);
|
|
2181
|
+
if (W instanceof Promise) {
|
|
2182
|
+
if (U.async === !1) throw new $ZodAsyncError();
|
|
2183
|
+
return W.then((u) => z(u, V, U));
|
|
2184
|
+
}
|
|
2185
|
+
return z(W, V, U);
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
defineLazy(u, "~standard", () => ({
|
|
2189
|
+
validate: (z) => {
|
|
2190
|
+
try {
|
|
2191
|
+
let B = safeParse$1(u, z);
|
|
2192
|
+
return B.success ? { value: B.data } : { issues: B.error?.issues };
|
|
2193
|
+
} catch {
|
|
2194
|
+
return safeParseAsync$1(u, z).then((u) => u.success ? { value: u.data } : { issues: u.error?.issues });
|
|
2195
|
+
}
|
|
2196
|
+
},
|
|
2197
|
+
vendor: "zod",
|
|
2198
|
+
version: 1
|
|
2199
|
+
}));
|
|
2200
|
+
}), $ZodString = /* @__PURE__ */ $constructor("$ZodString", (u, z) => {
|
|
2201
|
+
$ZodType.init(u, z), u._zod.pattern = [...u?._zod.bag?.patterns ?? []].pop() ?? string$1(u._zod.bag), u._zod.parse = (B, V) => {
|
|
2202
|
+
if (z.coerce) try {
|
|
2203
|
+
B.value = String(B.value);
|
|
2204
|
+
} catch {}
|
|
2205
|
+
return typeof B.value == "string" || B.issues.push({
|
|
2206
|
+
expected: "string",
|
|
2207
|
+
code: "invalid_type",
|
|
2208
|
+
input: B.value,
|
|
2209
|
+
inst: u
|
|
2210
|
+
}), B;
|
|
2211
|
+
};
|
|
2212
|
+
}), $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (u, z) => {
|
|
2213
|
+
$ZodCheckStringFormat.init(u, z), $ZodString.init(u, z);
|
|
2214
|
+
}), $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (u, z) => {
|
|
2215
|
+
z.pattern ??= guid, $ZodStringFormat.init(u, z);
|
|
2216
|
+
}), $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (u, z) => {
|
|
2217
|
+
if (z.version) {
|
|
2218
|
+
let u = {
|
|
2219
|
+
v1: 1,
|
|
2220
|
+
v2: 2,
|
|
2221
|
+
v3: 3,
|
|
2222
|
+
v4: 4,
|
|
2223
|
+
v5: 5,
|
|
2224
|
+
v6: 6,
|
|
2225
|
+
v7: 7,
|
|
2226
|
+
v8: 8
|
|
2227
|
+
}[z.version];
|
|
2228
|
+
if (u === void 0) throw Error(`Invalid UUID version: "${z.version}"`);
|
|
2229
|
+
z.pattern ??= uuid(u);
|
|
2230
|
+
} else z.pattern ??= uuid();
|
|
2231
|
+
$ZodStringFormat.init(u, z);
|
|
2232
|
+
}), $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (u, z) => {
|
|
2233
|
+
z.pattern ??= email, $ZodStringFormat.init(u, z);
|
|
2234
|
+
}), $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (u, z) => {
|
|
2235
|
+
$ZodStringFormat.init(u, z), u._zod.check = (B) => {
|
|
2236
|
+
try {
|
|
2237
|
+
let V = B.value.trim();
|
|
2238
|
+
if (!z.normalize && z.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(V)) {
|
|
2239
|
+
B.issues.push({
|
|
2240
|
+
code: "invalid_format",
|
|
2241
|
+
format: "url",
|
|
2242
|
+
note: "Invalid URL format",
|
|
2243
|
+
input: B.value,
|
|
2244
|
+
inst: u,
|
|
2245
|
+
continue: !z.abort
|
|
2246
|
+
});
|
|
2247
|
+
return;
|
|
2248
|
+
}
|
|
2249
|
+
let H = new URL(V);
|
|
2250
|
+
z.hostname && (z.hostname.lastIndex = 0, z.hostname.test(H.hostname) || B.issues.push({
|
|
2251
|
+
code: "invalid_format",
|
|
2252
|
+
format: "url",
|
|
2253
|
+
note: "Invalid hostname",
|
|
2254
|
+
pattern: z.hostname.source,
|
|
2255
|
+
input: B.value,
|
|
2256
|
+
inst: u,
|
|
2257
|
+
continue: !z.abort
|
|
2258
|
+
})), z.protocol && (z.protocol.lastIndex = 0, z.protocol.test(H.protocol.endsWith(":") ? H.protocol.slice(0, -1) : H.protocol) || B.issues.push({
|
|
2259
|
+
code: "invalid_format",
|
|
2260
|
+
format: "url",
|
|
2261
|
+
note: "Invalid protocol",
|
|
2262
|
+
pattern: z.protocol.source,
|
|
2263
|
+
input: B.value,
|
|
2264
|
+
inst: u,
|
|
2265
|
+
continue: !z.abort
|
|
2266
|
+
})), z.normalize ? B.value = H.href : B.value = V;
|
|
2267
|
+
return;
|
|
2268
|
+
} catch {
|
|
2269
|
+
B.issues.push({
|
|
2270
|
+
code: "invalid_format",
|
|
2271
|
+
format: "url",
|
|
2272
|
+
input: B.value,
|
|
2273
|
+
inst: u,
|
|
2274
|
+
continue: !z.abort
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
}), $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (u, z) => {
|
|
2279
|
+
z.pattern ??= emoji(), $ZodStringFormat.init(u, z);
|
|
2280
|
+
}), $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (u, z) => {
|
|
2281
|
+
z.pattern ??= nanoid, $ZodStringFormat.init(u, z);
|
|
2282
|
+
}), $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (u, z) => {
|
|
2283
|
+
z.pattern ??= cuid, $ZodStringFormat.init(u, z);
|
|
2284
|
+
}), $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (u, z) => {
|
|
2285
|
+
z.pattern ??= cuid2, $ZodStringFormat.init(u, z);
|
|
2286
|
+
}), $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (u, z) => {
|
|
2287
|
+
z.pattern ??= ulid, $ZodStringFormat.init(u, z);
|
|
2288
|
+
}), $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (u, z) => {
|
|
2289
|
+
z.pattern ??= xid, $ZodStringFormat.init(u, z);
|
|
2290
|
+
}), $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (u, z) => {
|
|
2291
|
+
z.pattern ??= ksuid, $ZodStringFormat.init(u, z);
|
|
2292
|
+
}), $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (u, z) => {
|
|
2293
|
+
z.pattern ??= datetime$1(z), $ZodStringFormat.init(u, z);
|
|
2294
|
+
}), $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (u, z) => {
|
|
2295
|
+
z.pattern ??= date$1, $ZodStringFormat.init(u, z);
|
|
2296
|
+
}), $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (u, z) => {
|
|
2297
|
+
z.pattern ??= time$1(z), $ZodStringFormat.init(u, z);
|
|
2298
|
+
}), $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (u, z) => {
|
|
2299
|
+
z.pattern ??= duration$1, $ZodStringFormat.init(u, z);
|
|
2300
|
+
}), $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (u, z) => {
|
|
2301
|
+
z.pattern ??= ipv4, $ZodStringFormat.init(u, z), u._zod.bag.format = "ipv4";
|
|
2302
|
+
}), $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (u, z) => {
|
|
2303
|
+
z.pattern ??= ipv6, $ZodStringFormat.init(u, z), u._zod.bag.format = "ipv6", u._zod.check = (B) => {
|
|
2304
|
+
try {
|
|
2305
|
+
new URL(`http://[${B.value}]`);
|
|
2306
|
+
} catch {
|
|
2307
|
+
B.issues.push({
|
|
2308
|
+
code: "invalid_format",
|
|
2309
|
+
format: "ipv6",
|
|
2310
|
+
input: B.value,
|
|
2311
|
+
inst: u,
|
|
2312
|
+
continue: !z.abort
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
}), $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (u, z) => {
|
|
2317
|
+
z.pattern ??= cidrv4, $ZodStringFormat.init(u, z);
|
|
2318
|
+
}), $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (u, z) => {
|
|
2319
|
+
z.pattern ??= cidrv6, $ZodStringFormat.init(u, z), u._zod.check = (B) => {
|
|
2320
|
+
let V = B.value.split("/");
|
|
2321
|
+
try {
|
|
2322
|
+
if (V.length !== 2) throw Error();
|
|
2323
|
+
let [u, z] = V;
|
|
2324
|
+
if (!z) throw Error();
|
|
2325
|
+
let B = Number(z);
|
|
2326
|
+
if (`${B}` !== z || B < 0 || B > 128) throw Error();
|
|
2327
|
+
new URL(`http://[${u}]`);
|
|
2328
|
+
} catch {
|
|
2329
|
+
B.issues.push({
|
|
2330
|
+
code: "invalid_format",
|
|
2331
|
+
format: "cidrv6",
|
|
2332
|
+
input: B.value,
|
|
2333
|
+
inst: u,
|
|
2334
|
+
continue: !z.abort
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
});
|
|
2339
|
+
function isValidBase64(u) {
|
|
2340
|
+
if (u === "") return !0;
|
|
2341
|
+
if (/\s/.test(u) || u.length % 4 != 0) return !1;
|
|
2342
|
+
try {
|
|
2343
|
+
return atob(u), !0;
|
|
2344
|
+
} catch {
|
|
2345
|
+
return !1;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (u, z) => {
|
|
2349
|
+
z.pattern ??= base64, $ZodStringFormat.init(u, z), u._zod.bag.contentEncoding = "base64", u._zod.check = (B) => {
|
|
2350
|
+
isValidBase64(B.value) || B.issues.push({
|
|
2351
|
+
code: "invalid_format",
|
|
2352
|
+
format: "base64",
|
|
2353
|
+
input: B.value,
|
|
2354
|
+
inst: u,
|
|
2355
|
+
continue: !z.abort
|
|
2356
|
+
});
|
|
2357
|
+
};
|
|
2358
|
+
});
|
|
2359
|
+
function isValidBase64URL(u) {
|
|
2360
|
+
if (!base64url.test(u)) return !1;
|
|
2361
|
+
let z = u.replace(/[-_]/g, (u) => u === "-" ? "+" : "/");
|
|
2362
|
+
return isValidBase64(z.padEnd(Math.ceil(z.length / 4) * 4, "="));
|
|
2363
|
+
}
|
|
2364
|
+
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (u, z) => {
|
|
2365
|
+
z.pattern ??= base64url, $ZodStringFormat.init(u, z), u._zod.bag.contentEncoding = "base64url", u._zod.check = (B) => {
|
|
2366
|
+
isValidBase64URL(B.value) || B.issues.push({
|
|
2367
|
+
code: "invalid_format",
|
|
2368
|
+
format: "base64url",
|
|
2369
|
+
input: B.value,
|
|
2370
|
+
inst: u,
|
|
2371
|
+
continue: !z.abort
|
|
2372
|
+
});
|
|
2373
|
+
};
|
|
2374
|
+
}), $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (u, z) => {
|
|
2375
|
+
z.pattern ??= e164, $ZodStringFormat.init(u, z);
|
|
2376
|
+
});
|
|
2377
|
+
function isValidJWT(u, z = null) {
|
|
2378
|
+
try {
|
|
2379
|
+
let B = u.split(".");
|
|
2380
|
+
if (B.length !== 3) return !1;
|
|
2381
|
+
let [V] = B;
|
|
2382
|
+
if (!V) return !1;
|
|
2383
|
+
let H = JSON.parse(atob(V));
|
|
2384
|
+
return !("typ" in H && H?.typ !== "JWT" || !H.alg || z && (!("alg" in H) || H.alg !== z));
|
|
2385
|
+
} catch {
|
|
2386
|
+
return !1;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (u, z) => {
|
|
2390
|
+
$ZodStringFormat.init(u, z), u._zod.check = (B) => {
|
|
2391
|
+
isValidJWT(B.value, z.alg) || B.issues.push({
|
|
2392
|
+
code: "invalid_format",
|
|
2393
|
+
format: "jwt",
|
|
2394
|
+
input: B.value,
|
|
2395
|
+
inst: u,
|
|
2396
|
+
continue: !z.abort
|
|
2397
|
+
});
|
|
2398
|
+
};
|
|
2399
|
+
}), $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (u, z) => {
|
|
2400
|
+
$ZodType.init(u, z), u._zod.parse = (u) => u;
|
|
2401
|
+
}), $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (u, z) => {
|
|
2402
|
+
$ZodType.init(u, z), u._zod.parse = (z, B) => (z.issues.push({
|
|
2403
|
+
expected: "never",
|
|
2404
|
+
code: "invalid_type",
|
|
2405
|
+
input: z.value,
|
|
2406
|
+
inst: u
|
|
2407
|
+
}), z);
|
|
2408
|
+
});
|
|
2409
|
+
function handleArrayResult(u, z, B) {
|
|
2410
|
+
u.issues.length && z.issues.push(...prefixIssues(B, u.issues)), z.value[B] = u.value;
|
|
2411
|
+
}
|
|
2412
|
+
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (u, z) => {
|
|
2413
|
+
$ZodType.init(u, z), u._zod.parse = (B, V) => {
|
|
2414
|
+
let H = B.value;
|
|
2415
|
+
if (!Array.isArray(H)) return B.issues.push({
|
|
2416
|
+
expected: "array",
|
|
2417
|
+
code: "invalid_type",
|
|
2418
|
+
input: H,
|
|
2419
|
+
inst: u
|
|
2420
|
+
}), B;
|
|
2421
|
+
B.value = Array(H.length);
|
|
2422
|
+
let U = [];
|
|
2423
|
+
for (let u = 0; u < H.length; u++) {
|
|
2424
|
+
let W = H[u], G = z.element._zod.run({
|
|
2425
|
+
value: W,
|
|
2426
|
+
issues: []
|
|
2427
|
+
}, V);
|
|
2428
|
+
G instanceof Promise ? U.push(G.then((z) => handleArrayResult(z, B, u))) : handleArrayResult(G, B, u);
|
|
2429
|
+
}
|
|
2430
|
+
return U.length ? Promise.all(U).then(() => B) : B;
|
|
2431
|
+
};
|
|
2432
|
+
});
|
|
2433
|
+
function handlePropertyResult(u, z, B, V, H, U) {
|
|
2434
|
+
let W = B in V;
|
|
2435
|
+
if (u.issues.length) {
|
|
2436
|
+
if (H && U && !W) return;
|
|
2437
|
+
z.issues.push(...prefixIssues(B, u.issues));
|
|
2438
|
+
}
|
|
2439
|
+
if (!W && !H) {
|
|
2440
|
+
u.issues.length || z.issues.push({
|
|
2441
|
+
code: "invalid_type",
|
|
2442
|
+
expected: "nonoptional",
|
|
2443
|
+
input: void 0,
|
|
2444
|
+
path: [B]
|
|
2445
|
+
});
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
u.value === void 0 ? W && (z.value[B] = void 0) : z.value[B] = u.value;
|
|
2449
|
+
}
|
|
2450
|
+
function normalizeDef(u) {
|
|
2451
|
+
let z = Object.keys(u.shape);
|
|
2452
|
+
for (let B of z) if (!u.shape?.[B]?._zod?.traits?.has("$ZodType")) throw Error(`Invalid element at key "${B}": expected a Zod schema`);
|
|
2453
|
+
let B = optionalKeys(u.shape);
|
|
2454
|
+
return {
|
|
2455
|
+
...u,
|
|
2456
|
+
keys: z,
|
|
2457
|
+
keySet: new Set(z),
|
|
2458
|
+
numKeys: z.length,
|
|
2459
|
+
optionalKeys: new Set(B)
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
function handleCatchall(u, z, B, V, H, U) {
|
|
2463
|
+
let W = [], G = H.keySet, K = H.catchall._zod, q = K.def.type, J = K.optin === "optional", Y = K.optout === "optional";
|
|
2464
|
+
for (let H in z) {
|
|
2465
|
+
if (H === "__proto__" || G.has(H)) continue;
|
|
2466
|
+
if (q === "never") {
|
|
2467
|
+
W.push(H);
|
|
2468
|
+
continue;
|
|
2469
|
+
}
|
|
2470
|
+
let U = K.run({
|
|
2471
|
+
value: z[H],
|
|
2472
|
+
issues: []
|
|
2473
|
+
}, V);
|
|
2474
|
+
U instanceof Promise ? u.push(U.then((u) => handlePropertyResult(u, B, H, z, J, Y))) : handlePropertyResult(U, B, H, z, J, Y);
|
|
2475
|
+
}
|
|
2476
|
+
return W.length && B.issues.push({
|
|
2477
|
+
code: "unrecognized_keys",
|
|
2478
|
+
keys: W,
|
|
2479
|
+
input: z,
|
|
2480
|
+
inst: U
|
|
2481
|
+
}), u.length ? Promise.all(u).then(() => B) : B;
|
|
2482
|
+
}
|
|
2483
|
+
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (u, z) => {
|
|
2484
|
+
if ($ZodType.init(u, z), !Object.getOwnPropertyDescriptor(z, "shape")?.get) {
|
|
2485
|
+
let u = z.shape;
|
|
2486
|
+
Object.defineProperty(z, "shape", { get: () => {
|
|
2487
|
+
let B = { ...u };
|
|
2488
|
+
return Object.defineProperty(z, "shape", { value: B }), B;
|
|
2489
|
+
} });
|
|
2490
|
+
}
|
|
2491
|
+
let B = cached(() => normalizeDef(z));
|
|
2492
|
+
defineLazy(u._zod, "propValues", () => {
|
|
2493
|
+
let u = z.shape, B = {};
|
|
2494
|
+
for (let z in u) {
|
|
2495
|
+
let V = u[z]._zod;
|
|
2496
|
+
if (V.values) {
|
|
2497
|
+
B[z] ?? (B[z] = /* @__PURE__ */ new Set());
|
|
2498
|
+
for (let u of V.values) B[z].add(u);
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
return B;
|
|
2502
|
+
});
|
|
2503
|
+
let V = isObject, H = z.catchall, U;
|
|
2504
|
+
u._zod.parse = (z, W) => {
|
|
2505
|
+
U ??= B.value;
|
|
2506
|
+
let G = z.value;
|
|
2507
|
+
if (!V(G)) return z.issues.push({
|
|
2508
|
+
expected: "object",
|
|
2509
|
+
code: "invalid_type",
|
|
2510
|
+
input: G,
|
|
2511
|
+
inst: u
|
|
2512
|
+
}), z;
|
|
2513
|
+
z.value = {};
|
|
2514
|
+
let K = [], q = U.shape;
|
|
2515
|
+
for (let u of U.keys) {
|
|
2516
|
+
let B = q[u], V = B._zod.optin === "optional", H = B._zod.optout === "optional", U = B._zod.run({
|
|
2517
|
+
value: G[u],
|
|
2518
|
+
issues: []
|
|
2519
|
+
}, W);
|
|
2520
|
+
U instanceof Promise ? K.push(U.then((B) => handlePropertyResult(B, z, u, G, V, H))) : handlePropertyResult(U, z, u, G, V, H);
|
|
2521
|
+
}
|
|
2522
|
+
return H ? handleCatchall(K, G, z, W, B.value, u) : K.length ? Promise.all(K).then(() => z) : z;
|
|
2523
|
+
};
|
|
2524
|
+
}), $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (u, z) => {
|
|
2525
|
+
$ZodObject.init(u, z);
|
|
2526
|
+
let B = u._zod.parse, V = cached(() => normalizeDef(z)), H = (u) => {
|
|
2527
|
+
let z = new Doc([
|
|
2528
|
+
"shape",
|
|
2529
|
+
"payload",
|
|
2530
|
+
"ctx"
|
|
2531
|
+
]), B = V.value, H = (u) => {
|
|
2532
|
+
let z = esc(u);
|
|
2533
|
+
return `shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`;
|
|
2534
|
+
};
|
|
2535
|
+
z.write("const input = payload.value;");
|
|
2536
|
+
let U = Object.create(null), W = 0;
|
|
2537
|
+
for (let u of B.keys) U[u] = `key_${W++}`;
|
|
2538
|
+
z.write("const newResult = {};");
|
|
2539
|
+
for (let V of B.keys) {
|
|
2540
|
+
let B = U[V], W = esc(V), G = u[V], K = G?._zod?.optin === "optional", q = G?._zod?.optout === "optional";
|
|
2541
|
+
z.write(`const ${B} = ${H(V)};`), K && q ? z.write(`
|
|
2542
|
+
if (${B}.issues.length) {
|
|
2543
|
+
if (${W} in input) {
|
|
2544
|
+
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
2545
|
+
...iss,
|
|
2546
|
+
path: iss.path ? [${W}, ...iss.path] : [${W}]
|
|
2547
|
+
})));
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
if (${B}.value === undefined) {
|
|
2552
|
+
if (${W} in input) {
|
|
2553
|
+
newResult[${W}] = undefined;
|
|
2554
|
+
}
|
|
2555
|
+
} else {
|
|
2556
|
+
newResult[${W}] = ${B}.value;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2559
|
+
`) : K ? z.write(`
|
|
2560
|
+
if (${B}.issues.length) {
|
|
2561
|
+
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
2562
|
+
...iss,
|
|
2563
|
+
path: iss.path ? [${W}, ...iss.path] : [${W}]
|
|
2564
|
+
})));
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
if (${B}.value === undefined) {
|
|
2568
|
+
if (${W} in input) {
|
|
2569
|
+
newResult[${W}] = undefined;
|
|
2570
|
+
}
|
|
2571
|
+
} else {
|
|
2572
|
+
newResult[${W}] = ${B}.value;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
`) : z.write(`
|
|
2576
|
+
const ${B}_present = ${W} in input;
|
|
2577
|
+
if (${B}.issues.length) {
|
|
2578
|
+
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
2579
|
+
...iss,
|
|
2580
|
+
path: iss.path ? [${W}, ...iss.path] : [${W}]
|
|
2581
|
+
})));
|
|
2582
|
+
}
|
|
2583
|
+
if (!${B}_present && !${B}.issues.length) {
|
|
2584
|
+
payload.issues.push({
|
|
2585
|
+
code: "invalid_type",
|
|
2586
|
+
expected: "nonoptional",
|
|
2587
|
+
input: undefined,
|
|
2588
|
+
path: [${W}]
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
|
|
2592
|
+
if (${B}_present) {
|
|
2593
|
+
if (${B}.value === undefined) {
|
|
2594
|
+
newResult[${W}] = undefined;
|
|
2595
|
+
} else {
|
|
2596
|
+
newResult[${W}] = ${B}.value;
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
`);
|
|
2601
|
+
}
|
|
2602
|
+
z.write("payload.value = newResult;"), z.write("return payload;");
|
|
2603
|
+
let G = z.compile();
|
|
2604
|
+
return (z, B) => G(u, z, B);
|
|
2605
|
+
}, U, W = isObject, G = !globalConfig.jitless, K = G && allowsEval.value, q = z.catchall, J;
|
|
2606
|
+
u._zod.parse = (Y, X) => {
|
|
2607
|
+
J ??= V.value;
|
|
2608
|
+
let Z = Y.value;
|
|
2609
|
+
return W(Z) ? G && K && X?.async === !1 && X.jitless !== !0 ? (U ||= H(z.shape), Y = U(Y, X), q ? handleCatchall([], Z, Y, X, J, u) : Y) : B(Y, X) : (Y.issues.push({
|
|
2610
|
+
expected: "object",
|
|
2611
|
+
code: "invalid_type",
|
|
2612
|
+
input: Z,
|
|
2613
|
+
inst: u
|
|
2614
|
+
}), Y);
|
|
2615
|
+
};
|
|
2616
|
+
});
|
|
2617
|
+
function handleUnionResults(u, z, B, V) {
|
|
2618
|
+
for (let B of u) if (B.issues.length === 0) return z.value = B.value, z;
|
|
2619
|
+
let H = u.filter((u) => !aborted(u));
|
|
2620
|
+
return H.length === 1 ? (z.value = H[0].value, H[0]) : (z.issues.push({
|
|
2621
|
+
code: "invalid_union",
|
|
2622
|
+
input: z.value,
|
|
2623
|
+
inst: B,
|
|
2624
|
+
errors: u.map((u) => u.issues.map((u) => finalizeIssue(u, V, config())))
|
|
2625
|
+
}), z);
|
|
2626
|
+
}
|
|
2627
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (u, z) => {
|
|
2628
|
+
$ZodType.init(u, z), defineLazy(u._zod, "optin", () => z.options.some((u) => u._zod.optin === "optional") ? "optional" : void 0), defineLazy(u._zod, "optout", () => z.options.some((u) => u._zod.optout === "optional") ? "optional" : void 0), defineLazy(u._zod, "values", () => {
|
|
2629
|
+
if (z.options.every((u) => u._zod.values)) return new Set(z.options.flatMap((u) => Array.from(u._zod.values)));
|
|
2630
|
+
}), defineLazy(u._zod, "pattern", () => {
|
|
2631
|
+
if (z.options.every((u) => u._zod.pattern)) {
|
|
2632
|
+
let u = z.options.map((u) => u._zod.pattern);
|
|
2633
|
+
return /* @__PURE__ */ RegExp(`^(${u.map((u) => cleanRegex(u.source)).join("|")})$`);
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
let B = z.options.length === 1 ? z.options[0]._zod.run : null;
|
|
2637
|
+
u._zod.parse = (V, H) => {
|
|
2638
|
+
if (B) return B(V, H);
|
|
2639
|
+
let U = !1, W = [];
|
|
2640
|
+
for (let u of z.options) {
|
|
2641
|
+
let z = u._zod.run({
|
|
2642
|
+
value: V.value,
|
|
2643
|
+
issues: []
|
|
2644
|
+
}, H);
|
|
2645
|
+
if (z instanceof Promise) W.push(z), U = !0;
|
|
2646
|
+
else {
|
|
2647
|
+
if (z.issues.length === 0) return z;
|
|
2648
|
+
W.push(z);
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
return U ? Promise.all(W).then((z) => handleUnionResults(z, V, u, H)) : handleUnionResults(W, V, u, H);
|
|
2652
|
+
};
|
|
2653
|
+
}), $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (u, z) => {
|
|
2654
|
+
$ZodType.init(u, z), u._zod.parse = (u, B) => {
|
|
2655
|
+
let V = u.value, H = z.left._zod.run({
|
|
2656
|
+
value: V,
|
|
2657
|
+
issues: []
|
|
2658
|
+
}, B), U = z.right._zod.run({
|
|
2659
|
+
value: V,
|
|
2660
|
+
issues: []
|
|
2661
|
+
}, B);
|
|
2662
|
+
return H instanceof Promise || U instanceof Promise ? Promise.all([H, U]).then(([z, B]) => handleIntersectionResults(u, z, B)) : handleIntersectionResults(u, H, U);
|
|
2663
|
+
};
|
|
2664
|
+
});
|
|
2665
|
+
function mergeValues(u, z) {
|
|
2666
|
+
if (u === z || u instanceof Date && z instanceof Date && +u == +z) return {
|
|
2667
|
+
valid: !0,
|
|
2668
|
+
data: u
|
|
2669
|
+
};
|
|
2670
|
+
if (isPlainObject(u) && isPlainObject(z)) {
|
|
2671
|
+
let B = Object.keys(z), V = Object.keys(u).filter((u) => B.indexOf(u) !== -1), H = {
|
|
2672
|
+
...u,
|
|
2673
|
+
...z
|
|
2674
|
+
};
|
|
2675
|
+
for (let B of V) {
|
|
2676
|
+
let V = mergeValues(u[B], z[B]);
|
|
2677
|
+
if (!V.valid) return {
|
|
2678
|
+
valid: !1,
|
|
2679
|
+
mergeErrorPath: [B, ...V.mergeErrorPath]
|
|
2680
|
+
};
|
|
2681
|
+
H[B] = V.data;
|
|
2682
|
+
}
|
|
2683
|
+
return {
|
|
2684
|
+
valid: !0,
|
|
2685
|
+
data: H
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
if (Array.isArray(u) && Array.isArray(z)) {
|
|
2689
|
+
if (u.length !== z.length) return {
|
|
2690
|
+
valid: !1,
|
|
2691
|
+
mergeErrorPath: []
|
|
2692
|
+
};
|
|
2693
|
+
let B = [];
|
|
2694
|
+
for (let V = 0; V < u.length; V++) {
|
|
2695
|
+
let H = u[V], U = z[V], W = mergeValues(H, U);
|
|
2696
|
+
if (!W.valid) return {
|
|
2697
|
+
valid: !1,
|
|
2698
|
+
mergeErrorPath: [V, ...W.mergeErrorPath]
|
|
2699
|
+
};
|
|
2700
|
+
B.push(W.data);
|
|
2701
|
+
}
|
|
2702
|
+
return {
|
|
2703
|
+
valid: !0,
|
|
2704
|
+
data: B
|
|
2705
|
+
};
|
|
2706
|
+
}
|
|
2707
|
+
return {
|
|
2708
|
+
valid: !1,
|
|
2709
|
+
mergeErrorPath: []
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
function handleIntersectionResults(u, z, B) {
|
|
2713
|
+
let V = /* @__PURE__ */ new Map(), H;
|
|
2714
|
+
for (let B of z.issues) if (B.code === "unrecognized_keys") {
|
|
2715
|
+
H ??= B;
|
|
2716
|
+
for (let u of B.keys) V.has(u) || V.set(u, {}), V.get(u).l = !0;
|
|
2717
|
+
} else u.issues.push(B);
|
|
2718
|
+
for (let z of B.issues) if (z.code === "unrecognized_keys") for (let u of z.keys) V.has(u) || V.set(u, {}), V.get(u).r = !0;
|
|
2719
|
+
else u.issues.push(z);
|
|
2720
|
+
let U = [...V].filter(([, u]) => u.l && u.r).map(([u]) => u);
|
|
2721
|
+
if (U.length && H && u.issues.push({
|
|
2722
|
+
...H,
|
|
2723
|
+
keys: U
|
|
2724
|
+
}), aborted(u)) return u;
|
|
2725
|
+
let W = mergeValues(z.value, B.value);
|
|
2726
|
+
if (!W.valid) throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);
|
|
2727
|
+
return u.value = W.data, u;
|
|
2728
|
+
}
|
|
2729
|
+
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (u, z) => {
|
|
2730
|
+
$ZodType.init(u, z), u._zod.parse = (B, V) => {
|
|
2731
|
+
let H = B.value;
|
|
2732
|
+
if (!isPlainObject(H)) return B.issues.push({
|
|
2733
|
+
expected: "record",
|
|
2734
|
+
code: "invalid_type",
|
|
2735
|
+
input: H,
|
|
2736
|
+
inst: u
|
|
2737
|
+
}), B;
|
|
2738
|
+
let U = [], W = z.keyType._zod.values;
|
|
2739
|
+
if (W) {
|
|
2740
|
+
B.value = {};
|
|
2741
|
+
let G = /* @__PURE__ */ new Set();
|
|
2742
|
+
for (let K of W) if (typeof K == "string" || typeof K == "number" || typeof K == "symbol") {
|
|
2743
|
+
G.add(typeof K == "number" ? K.toString() : K);
|
|
2744
|
+
let W = z.keyType._zod.run({
|
|
2745
|
+
value: K,
|
|
2746
|
+
issues: []
|
|
2747
|
+
}, V);
|
|
2748
|
+
if (W instanceof Promise) throw Error("Async schemas not supported in object keys currently");
|
|
2749
|
+
if (W.issues.length) {
|
|
2750
|
+
B.issues.push({
|
|
2751
|
+
code: "invalid_key",
|
|
2752
|
+
origin: "record",
|
|
2753
|
+
issues: W.issues.map((u) => finalizeIssue(u, V, config())),
|
|
2754
|
+
input: K,
|
|
2755
|
+
path: [K],
|
|
2756
|
+
inst: u
|
|
2757
|
+
});
|
|
2758
|
+
continue;
|
|
2759
|
+
}
|
|
2760
|
+
let q = W.value, J = z.valueType._zod.run({
|
|
2761
|
+
value: H[K],
|
|
2762
|
+
issues: []
|
|
2763
|
+
}, V);
|
|
2764
|
+
J instanceof Promise ? U.push(J.then((u) => {
|
|
2765
|
+
u.issues.length && B.issues.push(...prefixIssues(K, u.issues)), B.value[q] = u.value;
|
|
2766
|
+
})) : (J.issues.length && B.issues.push(...prefixIssues(K, J.issues)), B.value[q] = J.value);
|
|
2767
|
+
}
|
|
2768
|
+
let K;
|
|
2769
|
+
for (let u in H) G.has(u) || (K ??= [], K.push(u));
|
|
2770
|
+
K && K.length > 0 && B.issues.push({
|
|
2771
|
+
code: "unrecognized_keys",
|
|
2772
|
+
input: H,
|
|
2773
|
+
inst: u,
|
|
2774
|
+
keys: K
|
|
2775
|
+
});
|
|
2776
|
+
} else {
|
|
2777
|
+
B.value = {};
|
|
2778
|
+
for (let W of Reflect.ownKeys(H)) {
|
|
2779
|
+
if (W === "__proto__" || !Object.prototype.propertyIsEnumerable.call(H, W)) continue;
|
|
2780
|
+
let G = z.keyType._zod.run({
|
|
2781
|
+
value: W,
|
|
2782
|
+
issues: []
|
|
2783
|
+
}, V);
|
|
2784
|
+
if (G instanceof Promise) throw Error("Async schemas not supported in object keys currently");
|
|
2785
|
+
if (typeof W == "string" && number.test(W) && G.issues.length) {
|
|
2786
|
+
let u = z.keyType._zod.run({
|
|
2787
|
+
value: Number(W),
|
|
2788
|
+
issues: []
|
|
2789
|
+
}, V);
|
|
2790
|
+
if (u instanceof Promise) throw Error("Async schemas not supported in object keys currently");
|
|
2791
|
+
u.issues.length === 0 && (G = u);
|
|
2792
|
+
}
|
|
2793
|
+
if (G.issues.length) {
|
|
2794
|
+
z.mode === "loose" ? B.value[W] = H[W] : B.issues.push({
|
|
2795
|
+
code: "invalid_key",
|
|
2796
|
+
origin: "record",
|
|
2797
|
+
issues: G.issues.map((u) => finalizeIssue(u, V, config())),
|
|
2798
|
+
input: W,
|
|
2799
|
+
path: [W],
|
|
2800
|
+
inst: u
|
|
2801
|
+
});
|
|
2802
|
+
continue;
|
|
2803
|
+
}
|
|
2804
|
+
let K = z.valueType._zod.run({
|
|
2805
|
+
value: H[W],
|
|
2806
|
+
issues: []
|
|
2807
|
+
}, V);
|
|
2808
|
+
K instanceof Promise ? U.push(K.then((u) => {
|
|
2809
|
+
u.issues.length && B.issues.push(...prefixIssues(W, u.issues)), B.value[G.value] = u.value;
|
|
2810
|
+
})) : (K.issues.length && B.issues.push(...prefixIssues(W, K.issues)), B.value[G.value] = K.value);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
return U.length ? Promise.all(U).then(() => B) : B;
|
|
2814
|
+
};
|
|
2815
|
+
}), $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (u, z) => {
|
|
2816
|
+
$ZodType.init(u, z);
|
|
2817
|
+
let B = getEnumValues(z.entries), V = new Set(B);
|
|
2818
|
+
u._zod.values = V, u._zod.pattern = /* @__PURE__ */ RegExp(`^(${B.filter((u) => propertyKeyTypes.has(typeof u)).map((u) => typeof u == "string" ? escapeRegex(u) : u.toString()).join("|")})$`), u._zod.parse = (z, H) => {
|
|
2819
|
+
let U = z.value;
|
|
2820
|
+
return V.has(U) || z.issues.push({
|
|
2821
|
+
code: "invalid_value",
|
|
2822
|
+
values: B,
|
|
2823
|
+
input: U,
|
|
2824
|
+
inst: u
|
|
2825
|
+
}), z;
|
|
2826
|
+
};
|
|
2827
|
+
}), $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (u, z) => {
|
|
2828
|
+
$ZodType.init(u, z), u._zod.optin = "optional", u._zod.parse = (B, V) => {
|
|
2829
|
+
if (V.direction === "backward") throw new $ZodEncodeError(u.constructor.name);
|
|
2830
|
+
let H = z.transform(B.value, B);
|
|
2831
|
+
if (V.async) return (H instanceof Promise ? H : Promise.resolve(H)).then((u) => (B.value = u, B.fallback = !0, B));
|
|
2832
|
+
if (H instanceof Promise) throw new $ZodAsyncError();
|
|
2833
|
+
return B.value = H, B.fallback = !0, B;
|
|
2834
|
+
};
|
|
2835
|
+
});
|
|
2836
|
+
function handleOptionalResult(u, z) {
|
|
2837
|
+
return z === void 0 && (u.issues.length || u.fallback) ? {
|
|
2838
|
+
issues: [],
|
|
2839
|
+
value: void 0
|
|
2840
|
+
} : u;
|
|
2841
|
+
}
|
|
2842
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (u, z) => {
|
|
2843
|
+
$ZodType.init(u, z), u._zod.optin = "optional", u._zod.optout = "optional", defineLazy(u._zod, "values", () => z.innerType._zod.values ? new Set([...z.innerType._zod.values, void 0]) : void 0), defineLazy(u._zod, "pattern", () => {
|
|
2844
|
+
let u = z.innerType._zod.pattern;
|
|
2845
|
+
return u ? /* @__PURE__ */ RegExp(`^(${cleanRegex(u.source)})?$`) : void 0;
|
|
2846
|
+
}), u._zod.parse = (u, B) => {
|
|
2847
|
+
if (z.innerType._zod.optin === "optional") {
|
|
2848
|
+
let V = u.value, H = z.innerType._zod.run(u, B);
|
|
2849
|
+
return H instanceof Promise ? H.then((u) => handleOptionalResult(u, V)) : handleOptionalResult(H, V);
|
|
2850
|
+
}
|
|
2851
|
+
return u.value === void 0 ? u : z.innerType._zod.run(u, B);
|
|
2852
|
+
};
|
|
2853
|
+
}), $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (u, z) => {
|
|
2854
|
+
$ZodOptional.init(u, z), defineLazy(u._zod, "values", () => z.innerType._zod.values), defineLazy(u._zod, "pattern", () => z.innerType._zod.pattern), u._zod.parse = (u, B) => z.innerType._zod.run(u, B);
|
|
2855
|
+
}), $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (u, z) => {
|
|
2856
|
+
$ZodType.init(u, z), defineLazy(u._zod, "optin", () => z.innerType._zod.optin), defineLazy(u._zod, "optout", () => z.innerType._zod.optout), defineLazy(u._zod, "pattern", () => {
|
|
2857
|
+
let u = z.innerType._zod.pattern;
|
|
2858
|
+
return u ? /* @__PURE__ */ RegExp(`^(${cleanRegex(u.source)}|null)$`) : void 0;
|
|
2859
|
+
}), defineLazy(u._zod, "values", () => z.innerType._zod.values ? new Set([...z.innerType._zod.values, null]) : void 0), u._zod.parse = (u, B) => u.value === null ? u : z.innerType._zod.run(u, B);
|
|
2860
|
+
}), $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (u, z) => {
|
|
2861
|
+
$ZodType.init(u, z), u._zod.optin = "optional", defineLazy(u._zod, "values", () => z.innerType._zod.values), u._zod.parse = (u, B) => {
|
|
2862
|
+
if (B.direction === "backward") return z.innerType._zod.run(u, B);
|
|
2863
|
+
if (u.value === void 0) return u.value = z.defaultValue, u;
|
|
2864
|
+
let V = z.innerType._zod.run(u, B);
|
|
2865
|
+
return V instanceof Promise ? V.then((u) => handleDefaultResult(u, z)) : handleDefaultResult(V, z);
|
|
2866
|
+
};
|
|
2867
|
+
});
|
|
2868
|
+
function handleDefaultResult(u, z) {
|
|
2869
|
+
return u.value === void 0 && (u.value = z.defaultValue), u;
|
|
2870
|
+
}
|
|
2871
|
+
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (u, z) => {
|
|
2872
|
+
$ZodType.init(u, z), u._zod.optin = "optional", defineLazy(u._zod, "values", () => z.innerType._zod.values), u._zod.parse = (u, B) => (B.direction === "backward" || u.value === void 0 && (u.value = z.defaultValue), z.innerType._zod.run(u, B));
|
|
2873
|
+
}), $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (u, z) => {
|
|
2874
|
+
$ZodType.init(u, z), defineLazy(u._zod, "values", () => {
|
|
2875
|
+
let u = z.innerType._zod.values;
|
|
2876
|
+
return u ? new Set([...u].filter((u) => u !== void 0)) : void 0;
|
|
2877
|
+
}), u._zod.parse = (B, V) => {
|
|
2878
|
+
let H = z.innerType._zod.run(B, V);
|
|
2879
|
+
return H instanceof Promise ? H.then((z) => handleNonOptionalResult(z, u)) : handleNonOptionalResult(H, u);
|
|
2880
|
+
};
|
|
2881
|
+
});
|
|
2882
|
+
function handleNonOptionalResult(u, z) {
|
|
2883
|
+
return !u.issues.length && u.value === void 0 && u.issues.push({
|
|
2884
|
+
code: "invalid_type",
|
|
2885
|
+
expected: "nonoptional",
|
|
2886
|
+
input: u.value,
|
|
2887
|
+
inst: z
|
|
2888
|
+
}), u;
|
|
2889
|
+
}
|
|
2890
|
+
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (u, z) => {
|
|
2891
|
+
$ZodType.init(u, z), u._zod.optin = "optional", defineLazy(u._zod, "optout", () => z.innerType._zod.optout), defineLazy(u._zod, "values", () => z.innerType._zod.values), u._zod.parse = (u, B) => {
|
|
2892
|
+
if (B.direction === "backward") return z.innerType._zod.run(u, B);
|
|
2893
|
+
let V = z.innerType._zod.run(u, B);
|
|
2894
|
+
return V instanceof Promise ? V.then((V) => (u.value = V.value, V.issues.length && (u.value = z.catchValue({
|
|
2895
|
+
...u,
|
|
2896
|
+
error: { issues: V.issues.map((u) => finalizeIssue(u, B, config())) },
|
|
2897
|
+
input: u.value
|
|
2898
|
+
}), u.issues = [], u.fallback = !0), u)) : (u.value = V.value, V.issues.length && (u.value = z.catchValue({
|
|
2899
|
+
...u,
|
|
2900
|
+
error: { issues: V.issues.map((u) => finalizeIssue(u, B, config())) },
|
|
2901
|
+
input: u.value
|
|
2902
|
+
}), u.issues = [], u.fallback = !0), u);
|
|
2903
|
+
};
|
|
2904
|
+
}), $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (u, z) => {
|
|
2905
|
+
$ZodType.init(u, z), defineLazy(u._zod, "values", () => z.in._zod.values), defineLazy(u._zod, "optin", () => z.in._zod.optin), defineLazy(u._zod, "optout", () => z.out._zod.optout), defineLazy(u._zod, "propValues", () => z.in._zod.propValues), u._zod.parse = (u, B) => {
|
|
2906
|
+
if (B.direction === "backward") {
|
|
2907
|
+
let V = z.out._zod.run(u, B);
|
|
2908
|
+
return V instanceof Promise ? V.then((u) => handlePipeResult(u, z.in, B)) : handlePipeResult(V, z.in, B);
|
|
2909
|
+
}
|
|
2910
|
+
let V = z.in._zod.run(u, B);
|
|
2911
|
+
return V instanceof Promise ? V.then((u) => handlePipeResult(u, z.out, B)) : handlePipeResult(V, z.out, B);
|
|
2912
|
+
};
|
|
2913
|
+
});
|
|
2914
|
+
function handlePipeResult(u, z, B) {
|
|
2915
|
+
return u.issues.length ? (u.aborted = !0, u) : z._zod.run({
|
|
2916
|
+
value: u.value,
|
|
2917
|
+
issues: u.issues,
|
|
2918
|
+
fallback: u.fallback
|
|
2919
|
+
}, B);
|
|
2920
|
+
}
|
|
2921
|
+
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (u, z) => {
|
|
2922
|
+
$ZodType.init(u, z), defineLazy(u._zod, "propValues", () => z.innerType._zod.propValues), defineLazy(u._zod, "values", () => z.innerType._zod.values), defineLazy(u._zod, "optin", () => z.innerType?._zod?.optin), defineLazy(u._zod, "optout", () => z.innerType?._zod?.optout), u._zod.parse = (u, B) => {
|
|
2923
|
+
if (B.direction === "backward") return z.innerType._zod.run(u, B);
|
|
2924
|
+
let V = z.innerType._zod.run(u, B);
|
|
2925
|
+
return V instanceof Promise ? V.then(handleReadonlyResult) : handleReadonlyResult(V);
|
|
2926
|
+
};
|
|
2927
|
+
});
|
|
2928
|
+
function handleReadonlyResult(u) {
|
|
2929
|
+
return u.value = Object.freeze(u.value), u;
|
|
2930
|
+
}
|
|
2931
|
+
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (u, z) => {
|
|
2932
|
+
$ZodCheck.init(u, z), $ZodType.init(u, z), u._zod.parse = (u, z) => u, u._zod.check = (B) => {
|
|
2933
|
+
let V = B.value, H = z.fn(V);
|
|
2934
|
+
if (H instanceof Promise) return H.then((z) => handleRefineResult(z, B, V, u));
|
|
2935
|
+
handleRefineResult(H, B, V, u);
|
|
2936
|
+
};
|
|
2937
|
+
});
|
|
2938
|
+
function handleRefineResult(u, z, B, V) {
|
|
2939
|
+
if (!u) {
|
|
2940
|
+
let u = {
|
|
2941
|
+
code: "custom",
|
|
2942
|
+
input: B,
|
|
2943
|
+
inst: V,
|
|
2944
|
+
path: [...V._zod.def.path ?? []],
|
|
2945
|
+
continue: !V._zod.def.abort
|
|
2946
|
+
};
|
|
2947
|
+
V._zod.def.params && (u.params = V._zod.def.params), z.issues.push(issue(u));
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
var _a, $ZodRegistry = class {
|
|
2951
|
+
constructor() {
|
|
2952
|
+
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
2953
|
+
}
|
|
2954
|
+
add(u, ...z) {
|
|
2955
|
+
let B = z[0];
|
|
2956
|
+
return this._map.set(u, B), B && typeof B == "object" && "id" in B && this._idmap.set(B.id, u), this;
|
|
2957
|
+
}
|
|
2958
|
+
clear() {
|
|
2959
|
+
return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
2960
|
+
}
|
|
2961
|
+
remove(u) {
|
|
2962
|
+
let z = this._map.get(u);
|
|
2963
|
+
return z && typeof z == "object" && "id" in z && this._idmap.delete(z.id), this._map.delete(u), this;
|
|
2964
|
+
}
|
|
2965
|
+
get(u) {
|
|
2966
|
+
let z = u._zod.parent;
|
|
2967
|
+
if (z) {
|
|
2968
|
+
let B = { ...this.get(z) ?? {} };
|
|
2969
|
+
delete B.id;
|
|
2970
|
+
let V = {
|
|
2971
|
+
...B,
|
|
2972
|
+
...this._map.get(u)
|
|
2973
|
+
};
|
|
2974
|
+
return Object.keys(V).length ? V : void 0;
|
|
2975
|
+
}
|
|
2976
|
+
return this._map.get(u);
|
|
2977
|
+
}
|
|
2978
|
+
has(u) {
|
|
2979
|
+
return this._map.has(u);
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
function registry() {
|
|
2983
|
+
return new $ZodRegistry();
|
|
2984
|
+
}
|
|
2985
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2986
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2987
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2988
|
+
function _string(u, z) {
|
|
2989
|
+
return new u({
|
|
2990
|
+
type: "string",
|
|
2991
|
+
...normalizeParams(z)
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
2995
|
+
function _email(u, z) {
|
|
2996
|
+
return new u({
|
|
2997
|
+
type: "string",
|
|
2998
|
+
format: "email",
|
|
2999
|
+
check: "string_format",
|
|
3000
|
+
abort: !1,
|
|
3001
|
+
...normalizeParams(z)
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3005
|
+
function _guid(u, z) {
|
|
3006
|
+
return new u({
|
|
3007
|
+
type: "string",
|
|
3008
|
+
format: "guid",
|
|
3009
|
+
check: "string_format",
|
|
3010
|
+
abort: !1,
|
|
3011
|
+
...normalizeParams(z)
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3015
|
+
function _uuid(u, z) {
|
|
3016
|
+
return new u({
|
|
3017
|
+
type: "string",
|
|
3018
|
+
format: "uuid",
|
|
3019
|
+
check: "string_format",
|
|
3020
|
+
abort: !1,
|
|
3021
|
+
...normalizeParams(z)
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3025
|
+
function _uuidv4(u, z) {
|
|
3026
|
+
return new u({
|
|
3027
|
+
type: "string",
|
|
3028
|
+
format: "uuid",
|
|
3029
|
+
check: "string_format",
|
|
3030
|
+
abort: !1,
|
|
3031
|
+
version: "v4",
|
|
3032
|
+
...normalizeParams(z)
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3036
|
+
function _uuidv6(u, z) {
|
|
3037
|
+
return new u({
|
|
3038
|
+
type: "string",
|
|
3039
|
+
format: "uuid",
|
|
3040
|
+
check: "string_format",
|
|
3041
|
+
abort: !1,
|
|
3042
|
+
version: "v6",
|
|
3043
|
+
...normalizeParams(z)
|
|
3044
|
+
});
|
|
3045
|
+
}
|
|
3046
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3047
|
+
function _uuidv7(u, z) {
|
|
3048
|
+
return new u({
|
|
3049
|
+
type: "string",
|
|
3050
|
+
format: "uuid",
|
|
3051
|
+
check: "string_format",
|
|
3052
|
+
abort: !1,
|
|
3053
|
+
version: "v7",
|
|
3054
|
+
...normalizeParams(z)
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3058
|
+
function _url(u, z) {
|
|
3059
|
+
return new u({
|
|
3060
|
+
type: "string",
|
|
3061
|
+
format: "url",
|
|
3062
|
+
check: "string_format",
|
|
3063
|
+
abort: !1,
|
|
3064
|
+
...normalizeParams(z)
|
|
3065
|
+
});
|
|
3066
|
+
}
|
|
3067
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3068
|
+
function _emoji(u, z) {
|
|
3069
|
+
return new u({
|
|
3070
|
+
type: "string",
|
|
3071
|
+
format: "emoji",
|
|
3072
|
+
check: "string_format",
|
|
3073
|
+
abort: !1,
|
|
3074
|
+
...normalizeParams(z)
|
|
3075
|
+
});
|
|
3076
|
+
}
|
|
3077
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3078
|
+
function _nanoid(u, z) {
|
|
3079
|
+
return new u({
|
|
3080
|
+
type: "string",
|
|
3081
|
+
format: "nanoid",
|
|
3082
|
+
check: "string_format",
|
|
3083
|
+
abort: !1,
|
|
3084
|
+
...normalizeParams(z)
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3088
|
+
function _cuid(u, z) {
|
|
3089
|
+
return new u({
|
|
3090
|
+
type: "string",
|
|
3091
|
+
format: "cuid",
|
|
3092
|
+
check: "string_format",
|
|
3093
|
+
abort: !1,
|
|
3094
|
+
...normalizeParams(z)
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3098
|
+
function _cuid2(u, z) {
|
|
3099
|
+
return new u({
|
|
3100
|
+
type: "string",
|
|
3101
|
+
format: "cuid2",
|
|
3102
|
+
check: "string_format",
|
|
3103
|
+
abort: !1,
|
|
3104
|
+
...normalizeParams(z)
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3108
|
+
function _ulid(u, z) {
|
|
3109
|
+
return new u({
|
|
3110
|
+
type: "string",
|
|
3111
|
+
format: "ulid",
|
|
3112
|
+
check: "string_format",
|
|
3113
|
+
abort: !1,
|
|
3114
|
+
...normalizeParams(z)
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3118
|
+
function _xid(u, z) {
|
|
3119
|
+
return new u({
|
|
3120
|
+
type: "string",
|
|
3121
|
+
format: "xid",
|
|
3122
|
+
check: "string_format",
|
|
3123
|
+
abort: !1,
|
|
3124
|
+
...normalizeParams(z)
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3128
|
+
function _ksuid(u, z) {
|
|
3129
|
+
return new u({
|
|
3130
|
+
type: "string",
|
|
3131
|
+
format: "ksuid",
|
|
3132
|
+
check: "string_format",
|
|
3133
|
+
abort: !1,
|
|
3134
|
+
...normalizeParams(z)
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3138
|
+
function _ipv4(u, z) {
|
|
3139
|
+
return new u({
|
|
3140
|
+
type: "string",
|
|
3141
|
+
format: "ipv4",
|
|
3142
|
+
check: "string_format",
|
|
3143
|
+
abort: !1,
|
|
3144
|
+
...normalizeParams(z)
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3148
|
+
function _ipv6(u, z) {
|
|
3149
|
+
return new u({
|
|
3150
|
+
type: "string",
|
|
3151
|
+
format: "ipv6",
|
|
3152
|
+
check: "string_format",
|
|
3153
|
+
abort: !1,
|
|
3154
|
+
...normalizeParams(z)
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3158
|
+
function _cidrv4(u, z) {
|
|
3159
|
+
return new u({
|
|
3160
|
+
type: "string",
|
|
3161
|
+
format: "cidrv4",
|
|
3162
|
+
check: "string_format",
|
|
3163
|
+
abort: !1,
|
|
3164
|
+
...normalizeParams(z)
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3168
|
+
function _cidrv6(u, z) {
|
|
3169
|
+
return new u({
|
|
3170
|
+
type: "string",
|
|
3171
|
+
format: "cidrv6",
|
|
3172
|
+
check: "string_format",
|
|
3173
|
+
abort: !1,
|
|
3174
|
+
...normalizeParams(z)
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3178
|
+
function _base64(u, z) {
|
|
3179
|
+
return new u({
|
|
3180
|
+
type: "string",
|
|
3181
|
+
format: "base64",
|
|
3182
|
+
check: "string_format",
|
|
3183
|
+
abort: !1,
|
|
3184
|
+
...normalizeParams(z)
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3188
|
+
function _base64url(u, z) {
|
|
3189
|
+
return new u({
|
|
3190
|
+
type: "string",
|
|
3191
|
+
format: "base64url",
|
|
3192
|
+
check: "string_format",
|
|
3193
|
+
abort: !1,
|
|
3194
|
+
...normalizeParams(z)
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3198
|
+
function _e164(u, z) {
|
|
3199
|
+
return new u({
|
|
3200
|
+
type: "string",
|
|
3201
|
+
format: "e164",
|
|
3202
|
+
check: "string_format",
|
|
3203
|
+
abort: !1,
|
|
3204
|
+
...normalizeParams(z)
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3208
|
+
function _jwt(u, z) {
|
|
3209
|
+
return new u({
|
|
3210
|
+
type: "string",
|
|
3211
|
+
format: "jwt",
|
|
3212
|
+
check: "string_format",
|
|
3213
|
+
abort: !1,
|
|
3214
|
+
...normalizeParams(z)
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3218
|
+
function _isoDateTime(u, z) {
|
|
3219
|
+
return new u({
|
|
3220
|
+
type: "string",
|
|
3221
|
+
format: "datetime",
|
|
3222
|
+
check: "string_format",
|
|
3223
|
+
offset: !1,
|
|
3224
|
+
local: !1,
|
|
3225
|
+
precision: null,
|
|
3226
|
+
...normalizeParams(z)
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3230
|
+
function _isoDate(u, z) {
|
|
3231
|
+
return new u({
|
|
3232
|
+
type: "string",
|
|
3233
|
+
format: "date",
|
|
3234
|
+
check: "string_format",
|
|
3235
|
+
...normalizeParams(z)
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3239
|
+
function _isoTime(u, z) {
|
|
3240
|
+
return new u({
|
|
3241
|
+
type: "string",
|
|
3242
|
+
format: "time",
|
|
3243
|
+
check: "string_format",
|
|
3244
|
+
precision: null,
|
|
3245
|
+
...normalizeParams(z)
|
|
3246
|
+
});
|
|
3247
|
+
}
|
|
3248
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3249
|
+
function _isoDuration(u, z) {
|
|
3250
|
+
return new u({
|
|
3251
|
+
type: "string",
|
|
3252
|
+
format: "duration",
|
|
3253
|
+
check: "string_format",
|
|
3254
|
+
...normalizeParams(z)
|
|
3255
|
+
});
|
|
3256
|
+
}
|
|
3257
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3258
|
+
function _unknown(u) {
|
|
3259
|
+
return new u({ type: "unknown" });
|
|
3260
|
+
}
|
|
3261
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3262
|
+
function _never(u, z) {
|
|
3263
|
+
return new u({
|
|
3264
|
+
type: "never",
|
|
3265
|
+
...normalizeParams(z)
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3269
|
+
function _maxLength(u, z) {
|
|
3270
|
+
return new $ZodCheckMaxLength({
|
|
3271
|
+
check: "max_length",
|
|
3272
|
+
...normalizeParams(z),
|
|
3273
|
+
maximum: u
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3277
|
+
function _minLength(u, z) {
|
|
3278
|
+
return new $ZodCheckMinLength({
|
|
3279
|
+
check: "min_length",
|
|
3280
|
+
...normalizeParams(z),
|
|
3281
|
+
minimum: u
|
|
3282
|
+
});
|
|
3283
|
+
}
|
|
3284
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3285
|
+
function _length(u, z) {
|
|
3286
|
+
return new $ZodCheckLengthEquals({
|
|
3287
|
+
check: "length_equals",
|
|
3288
|
+
...normalizeParams(z),
|
|
3289
|
+
length: u
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3293
|
+
function _regex(u, z) {
|
|
3294
|
+
return new $ZodCheckRegex({
|
|
3295
|
+
check: "string_format",
|
|
3296
|
+
format: "regex",
|
|
3297
|
+
...normalizeParams(z),
|
|
3298
|
+
pattern: u
|
|
3299
|
+
});
|
|
3300
|
+
}
|
|
3301
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3302
|
+
function _lowercase(u) {
|
|
3303
|
+
return new $ZodCheckLowerCase({
|
|
3304
|
+
check: "string_format",
|
|
3305
|
+
format: "lowercase",
|
|
3306
|
+
...normalizeParams(u)
|
|
3307
|
+
});
|
|
3308
|
+
}
|
|
3309
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3310
|
+
function _uppercase(u) {
|
|
3311
|
+
return new $ZodCheckUpperCase({
|
|
3312
|
+
check: "string_format",
|
|
3313
|
+
format: "uppercase",
|
|
3314
|
+
...normalizeParams(u)
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3318
|
+
function _includes(u, z) {
|
|
3319
|
+
return new $ZodCheckIncludes({
|
|
3320
|
+
check: "string_format",
|
|
3321
|
+
format: "includes",
|
|
3322
|
+
...normalizeParams(z),
|
|
3323
|
+
includes: u
|
|
3324
|
+
});
|
|
3325
|
+
}
|
|
3326
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3327
|
+
function _startsWith(u, z) {
|
|
3328
|
+
return new $ZodCheckStartsWith({
|
|
3329
|
+
check: "string_format",
|
|
3330
|
+
format: "starts_with",
|
|
3331
|
+
...normalizeParams(z),
|
|
3332
|
+
prefix: u
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3336
|
+
function _endsWith(u, z) {
|
|
3337
|
+
return new $ZodCheckEndsWith({
|
|
3338
|
+
check: "string_format",
|
|
3339
|
+
format: "ends_with",
|
|
3340
|
+
...normalizeParams(z),
|
|
3341
|
+
suffix: u
|
|
3342
|
+
});
|
|
3343
|
+
}
|
|
3344
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3345
|
+
function _overwrite(u) {
|
|
3346
|
+
return new $ZodCheckOverwrite({
|
|
3347
|
+
check: "overwrite",
|
|
3348
|
+
tx: u
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3352
|
+
function _normalize(u) {
|
|
3353
|
+
return /* @__PURE__ */ _overwrite((z) => z.normalize(u));
|
|
3354
|
+
}
|
|
3355
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3356
|
+
function _trim() {
|
|
3357
|
+
return /* @__PURE__ */ _overwrite((u) => u.trim());
|
|
3358
|
+
}
|
|
3359
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3360
|
+
function _toLowerCase() {
|
|
3361
|
+
return /* @__PURE__ */ _overwrite((u) => u.toLowerCase());
|
|
3362
|
+
}
|
|
3363
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3364
|
+
function _toUpperCase() {
|
|
3365
|
+
return /* @__PURE__ */ _overwrite((u) => u.toUpperCase());
|
|
3366
|
+
}
|
|
3367
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3368
|
+
function _slugify() {
|
|
3369
|
+
return /* @__PURE__ */ _overwrite((u) => slugify(u));
|
|
3370
|
+
}
|
|
3371
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3372
|
+
function _array(u, z, B) {
|
|
3373
|
+
return new u({
|
|
3374
|
+
type: "array",
|
|
3375
|
+
element: z,
|
|
3376
|
+
...normalizeParams(B)
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3380
|
+
function _refine(u, z, B) {
|
|
3381
|
+
return new u({
|
|
3382
|
+
type: "custom",
|
|
3383
|
+
check: "custom",
|
|
3384
|
+
fn: z,
|
|
3385
|
+
...normalizeParams(B)
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3389
|
+
function _superRefine(u, z) {
|
|
3390
|
+
let B = /* @__PURE__ */ _check((z) => (z.addIssue = (u) => {
|
|
3391
|
+
if (typeof u == "string") z.issues.push(issue(u, z.value, B._zod.def));
|
|
3392
|
+
else {
|
|
3393
|
+
let V = u;
|
|
3394
|
+
V.fatal && (V.continue = !1), V.code ??= "custom", V.input ??= z.value, V.inst ??= B, V.continue ??= !B._zod.def.abort, z.issues.push(issue(V));
|
|
3395
|
+
}
|
|
3396
|
+
}, u(z.value, z)), z);
|
|
3397
|
+
return B;
|
|
3398
|
+
}
|
|
3399
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
3400
|
+
function _check(u, z) {
|
|
3401
|
+
let B = new $ZodCheck({
|
|
3402
|
+
check: "custom",
|
|
3403
|
+
...normalizeParams(z)
|
|
3404
|
+
});
|
|
3405
|
+
return B._zod.check = u, B;
|
|
3406
|
+
}
|
|
3407
|
+
function initializeContext(u) {
|
|
3408
|
+
let z = u?.target ?? "draft-2020-12";
|
|
3409
|
+
return z === "draft-4" && (z = "draft-04"), z === "draft-7" && (z = "draft-07"), {
|
|
3410
|
+
processors: u.processors ?? {},
|
|
3411
|
+
metadataRegistry: u?.metadata ?? globalRegistry,
|
|
3412
|
+
target: z,
|
|
3413
|
+
unrepresentable: u?.unrepresentable ?? "throw",
|
|
3414
|
+
override: u?.override ?? (() => {}),
|
|
3415
|
+
io: u?.io ?? "output",
|
|
3416
|
+
counter: 0,
|
|
3417
|
+
seen: /* @__PURE__ */ new Map(),
|
|
3418
|
+
cycles: u?.cycles ?? "ref",
|
|
3419
|
+
reused: u?.reused ?? "inline",
|
|
3420
|
+
external: u?.external ?? void 0
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
function process$1(u, z, B = {
|
|
3424
|
+
path: [],
|
|
3425
|
+
schemaPath: []
|
|
3426
|
+
}) {
|
|
3427
|
+
var V;
|
|
3428
|
+
let H = u._zod.def, U = z.seen.get(u);
|
|
3429
|
+
if (U) return U.count++, B.schemaPath.includes(u) && (U.cycle = B.path), U.schema;
|
|
3430
|
+
let W = {
|
|
3431
|
+
schema: {},
|
|
3432
|
+
count: 1,
|
|
3433
|
+
cycle: void 0,
|
|
3434
|
+
path: B.path
|
|
3435
|
+
};
|
|
3436
|
+
z.seen.set(u, W);
|
|
3437
|
+
let G = u._zod.toJSONSchema?.();
|
|
3438
|
+
if (G) W.schema = G;
|
|
3439
|
+
else {
|
|
3440
|
+
let V = {
|
|
3441
|
+
...B,
|
|
3442
|
+
schemaPath: [...B.schemaPath, u],
|
|
3443
|
+
path: B.path
|
|
3444
|
+
};
|
|
3445
|
+
if (u._zod.processJSONSchema) u._zod.processJSONSchema(z, W.schema, V);
|
|
3446
|
+
else {
|
|
3447
|
+
let B = W.schema, U = z.processors[H.type];
|
|
3448
|
+
if (!U) throw Error(`[toJSONSchema]: Non-representable type encountered: ${H.type}`);
|
|
3449
|
+
U(u, z, B, V);
|
|
3450
|
+
}
|
|
3451
|
+
let U = u._zod.parent;
|
|
3452
|
+
U && (W.ref ||= U, process$1(U, z, V), z.seen.get(U).isParent = !0);
|
|
3453
|
+
}
|
|
3454
|
+
let K = z.metadataRegistry.get(u);
|
|
3455
|
+
return K && Object.assign(W.schema, K), z.io === "input" && isTransforming(u) && (delete W.schema.examples, delete W.schema.default), z.io === "input" && "_prefault" in W.schema && ((V = W.schema).default ?? (V.default = W.schema._prefault)), delete W.schema._prefault, z.seen.get(u).schema;
|
|
3456
|
+
}
|
|
3457
|
+
function extractDefs(u, z) {
|
|
3458
|
+
let B = u.seen.get(z);
|
|
3459
|
+
if (!B) throw Error("Unprocessed schema. This is a bug in Zod.");
|
|
3460
|
+
let V = /* @__PURE__ */ new Map();
|
|
3461
|
+
for (let z of u.seen.entries()) {
|
|
3462
|
+
let B = u.metadataRegistry.get(z[0])?.id;
|
|
3463
|
+
if (B) {
|
|
3464
|
+
let u = V.get(B);
|
|
3465
|
+
if (u && u !== z[0]) throw Error(`Duplicate schema id "${B}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
3466
|
+
V.set(B, z[0]);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
let H = (z) => {
|
|
3470
|
+
let V = u.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3471
|
+
if (u.external) {
|
|
3472
|
+
let B = u.external.registry.get(z[0])?.id, H = u.external.uri ?? ((u) => u);
|
|
3473
|
+
if (B) return { ref: H(B) };
|
|
3474
|
+
let U = z[1].defId ?? z[1].schema.id ?? `schema${u.counter++}`;
|
|
3475
|
+
return z[1].defId = U, {
|
|
3476
|
+
defId: U,
|
|
3477
|
+
ref: `${H("__shared")}#/${V}/${U}`
|
|
3478
|
+
};
|
|
3479
|
+
}
|
|
3480
|
+
if (z[1] === B) return { ref: "#" };
|
|
3481
|
+
let H = `#/${V}/`, U = z[1].schema.id ?? `__schema${u.counter++}`;
|
|
3482
|
+
return {
|
|
3483
|
+
defId: U,
|
|
3484
|
+
ref: H + U
|
|
3485
|
+
};
|
|
3486
|
+
}, U = (u) => {
|
|
3487
|
+
if (u[1].schema.$ref) return;
|
|
3488
|
+
let z = u[1], { ref: B, defId: V } = H(u);
|
|
3489
|
+
z.def = { ...z.schema }, V && (z.defId = V);
|
|
3490
|
+
let U = z.schema;
|
|
3491
|
+
for (let u in U) delete U[u];
|
|
3492
|
+
U.$ref = B;
|
|
3493
|
+
};
|
|
3494
|
+
if (u.cycles === "throw") for (let z of u.seen.entries()) {
|
|
3495
|
+
let u = z[1];
|
|
3496
|
+
if (u.cycle) throw Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
|
|
3497
|
+
|
|
3498
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3499
|
+
}
|
|
3500
|
+
for (let B of u.seen.entries()) {
|
|
3501
|
+
let V = B[1];
|
|
3502
|
+
if (z === B[0]) {
|
|
3503
|
+
U(B);
|
|
3504
|
+
continue;
|
|
3505
|
+
}
|
|
3506
|
+
if (u.external) {
|
|
3507
|
+
let V = u.external.registry.get(B[0])?.id;
|
|
3508
|
+
if (z !== B[0] && V) {
|
|
3509
|
+
U(B);
|
|
3510
|
+
continue;
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
if (u.metadataRegistry.get(B[0])?.id) {
|
|
3514
|
+
U(B);
|
|
3515
|
+
continue;
|
|
3516
|
+
}
|
|
3517
|
+
if (V.cycle) {
|
|
3518
|
+
U(B);
|
|
3519
|
+
continue;
|
|
3520
|
+
}
|
|
3521
|
+
if (V.count > 1 && u.reused === "ref") {
|
|
3522
|
+
U(B);
|
|
3523
|
+
continue;
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
function finalize(u, z) {
|
|
3528
|
+
let B = u.seen.get(z);
|
|
3529
|
+
if (!B) throw Error("Unprocessed schema. This is a bug in Zod.");
|
|
3530
|
+
let V = (z) => {
|
|
3531
|
+
let B = u.seen.get(z);
|
|
3532
|
+
if (B.ref === null) return;
|
|
3533
|
+
let H = B.def ?? B.schema, U = { ...H }, W = B.ref;
|
|
3534
|
+
if (B.ref = null, W) {
|
|
3535
|
+
V(W);
|
|
3536
|
+
let B = u.seen.get(W), G = B.schema;
|
|
3537
|
+
if (G.$ref && (u.target === "draft-07" || u.target === "draft-04" || u.target === "openapi-3.0") ? (H.allOf = H.allOf ?? [], H.allOf.push(G)) : Object.assign(H, G), Object.assign(H, U), z._zod.parent === W) for (let u in H) u === "$ref" || u === "allOf" || u in U || delete H[u];
|
|
3538
|
+
if (G.$ref && B.def) for (let u in H) u === "$ref" || u === "allOf" || u in B.def && JSON.stringify(H[u]) === JSON.stringify(B.def[u]) && delete H[u];
|
|
3539
|
+
}
|
|
3540
|
+
let G = z._zod.parent;
|
|
3541
|
+
if (G && G !== W) {
|
|
3542
|
+
V(G);
|
|
3543
|
+
let z = u.seen.get(G);
|
|
3544
|
+
if (z?.schema.$ref && (H.$ref = z.schema.$ref, z.def)) for (let u in H) u === "$ref" || u === "allOf" || u in z.def && JSON.stringify(H[u]) === JSON.stringify(z.def[u]) && delete H[u];
|
|
3545
|
+
}
|
|
3546
|
+
u.override({
|
|
3547
|
+
zodSchema: z,
|
|
3548
|
+
jsonSchema: H,
|
|
3549
|
+
path: B.path ?? []
|
|
3550
|
+
});
|
|
3551
|
+
};
|
|
3552
|
+
for (let z of [...u.seen.entries()].reverse()) V(z[0]);
|
|
3553
|
+
let H = {};
|
|
3554
|
+
if (u.target === "draft-2020-12" ? H.$schema = "https://json-schema.org/draft/2020-12/schema" : u.target === "draft-07" ? H.$schema = "http://json-schema.org/draft-07/schema#" : u.target === "draft-04" ? H.$schema = "http://json-schema.org/draft-04/schema#" : u.target, u.external?.uri) {
|
|
3555
|
+
let B = u.external.registry.get(z)?.id;
|
|
3556
|
+
if (!B) throw Error("Schema is missing an `id` property");
|
|
3557
|
+
H.$id = u.external.uri(B);
|
|
3558
|
+
}
|
|
3559
|
+
Object.assign(H, B.def ?? B.schema);
|
|
3560
|
+
let U = u.metadataRegistry.get(z)?.id;
|
|
3561
|
+
U !== void 0 && H.id === U && delete H.id;
|
|
3562
|
+
let W = u.external?.defs ?? {};
|
|
3563
|
+
for (let z of u.seen.entries()) {
|
|
3564
|
+
let u = z[1];
|
|
3565
|
+
u.def && u.defId && (u.def.id === u.defId && delete u.def.id, W[u.defId] = u.def);
|
|
3566
|
+
}
|
|
3567
|
+
u.external || Object.keys(W).length > 0 && (u.target === "draft-2020-12" ? H.$defs = W : H.definitions = W);
|
|
3568
|
+
try {
|
|
3569
|
+
let B = JSON.parse(JSON.stringify(H));
|
|
3570
|
+
return Object.defineProperty(B, "~standard", {
|
|
3571
|
+
value: {
|
|
3572
|
+
...z["~standard"],
|
|
3573
|
+
jsonSchema: {
|
|
3574
|
+
input: createStandardJSONSchemaMethod(z, "input", u.processors),
|
|
3575
|
+
output: createStandardJSONSchemaMethod(z, "output", u.processors)
|
|
3576
|
+
}
|
|
3577
|
+
},
|
|
3578
|
+
enumerable: !1,
|
|
3579
|
+
writable: !1
|
|
3580
|
+
}), B;
|
|
3581
|
+
} catch {
|
|
3582
|
+
throw Error("Error converting schema to JSON.");
|
|
3583
|
+
}
|
|
3584
|
+
}
|
|
3585
|
+
function isTransforming(u, z) {
|
|
3586
|
+
let B = z ?? { seen: /* @__PURE__ */ new Set() };
|
|
3587
|
+
if (B.seen.has(u)) return !1;
|
|
3588
|
+
B.seen.add(u);
|
|
3589
|
+
let V = u._zod.def;
|
|
3590
|
+
if (V.type === "transform") return !0;
|
|
3591
|
+
if (V.type === "array") return isTransforming(V.element, B);
|
|
3592
|
+
if (V.type === "set") return isTransforming(V.valueType, B);
|
|
3593
|
+
if (V.type === "lazy") return isTransforming(V.getter(), B);
|
|
3594
|
+
if (V.type === "promise" || V.type === "optional" || V.type === "nonoptional" || V.type === "nullable" || V.type === "readonly" || V.type === "default" || V.type === "prefault") return isTransforming(V.innerType, B);
|
|
3595
|
+
if (V.type === "intersection") return isTransforming(V.left, B) || isTransforming(V.right, B);
|
|
3596
|
+
if (V.type === "record" || V.type === "map") return isTransforming(V.keyType, B) || isTransforming(V.valueType, B);
|
|
3597
|
+
if (V.type === "pipe") return u._zod.traits.has("$ZodCodec") ? !0 : isTransforming(V.in, B) || isTransforming(V.out, B);
|
|
3598
|
+
if (V.type === "object") {
|
|
3599
|
+
for (let u in V.shape) if (isTransforming(V.shape[u], B)) return !0;
|
|
3600
|
+
return !1;
|
|
3601
|
+
}
|
|
3602
|
+
if (V.type === "union") {
|
|
3603
|
+
for (let u of V.options) if (isTransforming(u, B)) return !0;
|
|
3604
|
+
return !1;
|
|
3605
|
+
}
|
|
3606
|
+
if (V.type === "tuple") {
|
|
3607
|
+
for (let u of V.items) if (isTransforming(u, B)) return !0;
|
|
3608
|
+
return !!(V.rest && isTransforming(V.rest, B));
|
|
3609
|
+
}
|
|
3610
|
+
return !1;
|
|
3611
|
+
}
|
|
3612
|
+
const createToJSONSchemaMethod = (u, z = {}) => (B) => {
|
|
3613
|
+
let V = initializeContext({
|
|
3614
|
+
...B,
|
|
3615
|
+
processors: z
|
|
3616
|
+
});
|
|
3617
|
+
return process$1(u, V), extractDefs(V, u), finalize(V, u);
|
|
3618
|
+
}, createStandardJSONSchemaMethod = (u, z, B = {}) => (V) => {
|
|
3619
|
+
let { libraryOptions: H, target: U } = V ?? {}, W = initializeContext({
|
|
3620
|
+
...H ?? {},
|
|
3621
|
+
target: U,
|
|
3622
|
+
io: z,
|
|
3623
|
+
processors: B
|
|
3624
|
+
});
|
|
3625
|
+
return process$1(u, W), extractDefs(W, u), finalize(W, u);
|
|
3626
|
+
};
|
|
3627
|
+
var formatMap = {
|
|
3628
|
+
guid: "uuid",
|
|
3629
|
+
url: "uri",
|
|
3630
|
+
datetime: "date-time",
|
|
3631
|
+
json_string: "json-string",
|
|
3632
|
+
regex: ""
|
|
3633
|
+
};
|
|
3634
|
+
const stringProcessor = (u, z, B, V) => {
|
|
3635
|
+
let H = B;
|
|
3636
|
+
H.type = "string";
|
|
3637
|
+
let { minimum: U, maximum: W, format: G, patterns: K, contentEncoding: q } = u._zod.bag;
|
|
3638
|
+
if (typeof U == "number" && (H.minLength = U), typeof W == "number" && (H.maxLength = W), G && (H.format = formatMap[G] ?? G, H.format === "" && delete H.format, G === "time" && delete H.format), q && (H.contentEncoding = q), K && K.size > 0) {
|
|
3639
|
+
let u = [...K];
|
|
3640
|
+
u.length === 1 ? H.pattern = u[0].source : u.length > 1 && (H.allOf = [...u.map((u) => ({
|
|
3641
|
+
...z.target === "draft-07" || z.target === "draft-04" || z.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3642
|
+
pattern: u.source
|
|
3643
|
+
}))]);
|
|
3644
|
+
}
|
|
3645
|
+
}, neverProcessor = (u, z, B, V) => {
|
|
3646
|
+
B.not = {};
|
|
3647
|
+
}, enumProcessor = (u, z, B, V) => {
|
|
3648
|
+
let H = u._zod.def, U = getEnumValues(H.entries);
|
|
3649
|
+
U.every((u) => typeof u == "number") && (B.type = "number"), U.every((u) => typeof u == "string") && (B.type = "string"), B.enum = U;
|
|
3650
|
+
}, customProcessor = (u, z, B, V) => {
|
|
3651
|
+
if (z.unrepresentable === "throw") throw Error("Custom types cannot be represented in JSON Schema");
|
|
3652
|
+
}, transformProcessor = (u, z, B, V) => {
|
|
3653
|
+
if (z.unrepresentable === "throw") throw Error("Transforms cannot be represented in JSON Schema");
|
|
3654
|
+
}, arrayProcessor = (u, z, B, V) => {
|
|
3655
|
+
let H = B, U = u._zod.def, { minimum: W, maximum: G } = u._zod.bag;
|
|
3656
|
+
typeof W == "number" && (H.minItems = W), typeof G == "number" && (H.maxItems = G), H.type = "array", H.items = process$1(U.element, z, {
|
|
3657
|
+
...V,
|
|
3658
|
+
path: [...V.path, "items"]
|
|
3659
|
+
});
|
|
3660
|
+
}, objectProcessor = (u, z, B, V) => {
|
|
3661
|
+
let H = B, U = u._zod.def;
|
|
3662
|
+
H.type = "object", H.properties = {};
|
|
3663
|
+
let W = U.shape;
|
|
3664
|
+
for (let u in W) H.properties[u] = process$1(W[u], z, {
|
|
3665
|
+
...V,
|
|
3666
|
+
path: [
|
|
3667
|
+
...V.path,
|
|
3668
|
+
"properties",
|
|
3669
|
+
u
|
|
3670
|
+
]
|
|
3671
|
+
});
|
|
3672
|
+
let G = new Set(Object.keys(W)), K = new Set([...G].filter((u) => {
|
|
3673
|
+
let B = U.shape[u]._zod;
|
|
3674
|
+
return z.io === "input" ? B.optin === void 0 : B.optout === void 0;
|
|
3675
|
+
}));
|
|
3676
|
+
K.size > 0 && (H.required = Array.from(K)), U.catchall?._zod.def.type === "never" ? H.additionalProperties = !1 : U.catchall ? U.catchall && (H.additionalProperties = process$1(U.catchall, z, {
|
|
3677
|
+
...V,
|
|
3678
|
+
path: [...V.path, "additionalProperties"]
|
|
3679
|
+
})) : z.io === "output" && (H.additionalProperties = !1);
|
|
3680
|
+
}, unionProcessor = (u, z, B, V) => {
|
|
3681
|
+
let H = u._zod.def, U = H.inclusive === !1, W = H.options.map((u, B) => process$1(u, z, {
|
|
3682
|
+
...V,
|
|
3683
|
+
path: [
|
|
3684
|
+
...V.path,
|
|
3685
|
+
U ? "oneOf" : "anyOf",
|
|
3686
|
+
B
|
|
3687
|
+
]
|
|
3688
|
+
}));
|
|
3689
|
+
U ? B.oneOf = W : B.anyOf = W;
|
|
3690
|
+
}, intersectionProcessor = (u, z, B, V) => {
|
|
3691
|
+
let H = u._zod.def, U = process$1(H.left, z, {
|
|
3692
|
+
...V,
|
|
3693
|
+
path: [
|
|
3694
|
+
...V.path,
|
|
3695
|
+
"allOf",
|
|
3696
|
+
0
|
|
3697
|
+
]
|
|
3698
|
+
}), W = process$1(H.right, z, {
|
|
3699
|
+
...V,
|
|
3700
|
+
path: [
|
|
3701
|
+
...V.path,
|
|
3702
|
+
"allOf",
|
|
3703
|
+
1
|
|
3704
|
+
]
|
|
3705
|
+
}), G = (u) => "allOf" in u && Object.keys(u).length === 1;
|
|
3706
|
+
B.allOf = [...G(U) ? U.allOf : [U], ...G(W) ? W.allOf : [W]];
|
|
3707
|
+
}, recordProcessor = (u, z, B, V) => {
|
|
3708
|
+
let H = B, U = u._zod.def;
|
|
3709
|
+
H.type = "object";
|
|
3710
|
+
let W = U.keyType, G = W._zod.bag?.patterns;
|
|
3711
|
+
if (U.mode === "loose" && G && G.size > 0) {
|
|
3712
|
+
let u = process$1(U.valueType, z, {
|
|
3713
|
+
...V,
|
|
3714
|
+
path: [
|
|
3715
|
+
...V.path,
|
|
3716
|
+
"patternProperties",
|
|
3717
|
+
"*"
|
|
3718
|
+
]
|
|
3719
|
+
});
|
|
3720
|
+
H.patternProperties = {};
|
|
3721
|
+
for (let z of G) H.patternProperties[z.source] = u;
|
|
3722
|
+
} else (z.target === "draft-07" || z.target === "draft-2020-12") && (H.propertyNames = process$1(U.keyType, z, {
|
|
3723
|
+
...V,
|
|
3724
|
+
path: [...V.path, "propertyNames"]
|
|
3725
|
+
})), H.additionalProperties = process$1(U.valueType, z, {
|
|
3726
|
+
...V,
|
|
3727
|
+
path: [...V.path, "additionalProperties"]
|
|
3728
|
+
});
|
|
3729
|
+
let K = W._zod.values;
|
|
3730
|
+
if (K) {
|
|
3731
|
+
let u = [...K].filter((u) => typeof u == "string" || typeof u == "number");
|
|
3732
|
+
u.length > 0 && (H.required = u);
|
|
3733
|
+
}
|
|
3734
|
+
}, nullableProcessor = (u, z, B, V) => {
|
|
3735
|
+
let H = u._zod.def, U = process$1(H.innerType, z, V), W = z.seen.get(u);
|
|
3736
|
+
z.target === "openapi-3.0" ? (W.ref = H.innerType, B.nullable = !0) : B.anyOf = [U, { type: "null" }];
|
|
3737
|
+
}, nonoptionalProcessor = (u, z, B, V) => {
|
|
3738
|
+
let H = u._zod.def;
|
|
3739
|
+
process$1(H.innerType, z, V);
|
|
3740
|
+
let U = z.seen.get(u);
|
|
3741
|
+
U.ref = H.innerType;
|
|
3742
|
+
}, defaultProcessor = (u, z, B, V) => {
|
|
3743
|
+
let H = u._zod.def;
|
|
3744
|
+
process$1(H.innerType, z, V);
|
|
3745
|
+
let U = z.seen.get(u);
|
|
3746
|
+
U.ref = H.innerType, B.default = JSON.parse(JSON.stringify(H.defaultValue));
|
|
3747
|
+
}, prefaultProcessor = (u, z, B, V) => {
|
|
3748
|
+
let H = u._zod.def;
|
|
3749
|
+
process$1(H.innerType, z, V);
|
|
3750
|
+
let U = z.seen.get(u);
|
|
3751
|
+
U.ref = H.innerType, z.io === "input" && (B._prefault = JSON.parse(JSON.stringify(H.defaultValue)));
|
|
3752
|
+
}, catchProcessor = (u, z, B, V) => {
|
|
3753
|
+
let H = u._zod.def;
|
|
3754
|
+
process$1(H.innerType, z, V);
|
|
3755
|
+
let U = z.seen.get(u);
|
|
3756
|
+
U.ref = H.innerType;
|
|
3757
|
+
let W;
|
|
3758
|
+
try {
|
|
3759
|
+
W = H.catchValue(void 0);
|
|
3760
|
+
} catch {
|
|
3761
|
+
throw Error("Dynamic catch values are not supported in JSON Schema");
|
|
3762
|
+
}
|
|
3763
|
+
B.default = W;
|
|
3764
|
+
}, pipeProcessor = (u, z, B, V) => {
|
|
3765
|
+
let H = u._zod.def, U = H.in._zod.traits.has("$ZodTransform"), W = z.io === "input" ? U ? H.out : H.in : H.out;
|
|
3766
|
+
process$1(W, z, V);
|
|
3767
|
+
let G = z.seen.get(u);
|
|
3768
|
+
G.ref = W;
|
|
3769
|
+
}, readonlyProcessor = (u, z, B, V) => {
|
|
3770
|
+
let H = u._zod.def;
|
|
3771
|
+
process$1(H.innerType, z, V);
|
|
3772
|
+
let U = z.seen.get(u);
|
|
3773
|
+
U.ref = H.innerType, B.readOnly = !0;
|
|
3774
|
+
}, optionalProcessor = (u, z, B, V) => {
|
|
3775
|
+
let H = u._zod.def;
|
|
3776
|
+
process$1(H.innerType, z, V);
|
|
3777
|
+
let U = z.seen.get(u);
|
|
3778
|
+
U.ref = H.innerType;
|
|
3779
|
+
}, ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (u, z) => {
|
|
3780
|
+
$ZodISODateTime.init(u, z), ZodStringFormat.init(u, z);
|
|
3781
|
+
});
|
|
3782
|
+
function datetime(u) {
|
|
3783
|
+
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, u);
|
|
3784
|
+
}
|
|
3785
|
+
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (u, z) => {
|
|
3786
|
+
$ZodISODate.init(u, z), ZodStringFormat.init(u, z);
|
|
3787
|
+
});
|
|
3788
|
+
function date(u) {
|
|
3789
|
+
return /* @__PURE__ */ _isoDate(ZodISODate, u);
|
|
3790
|
+
}
|
|
3791
|
+
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (u, z) => {
|
|
3792
|
+
$ZodISOTime.init(u, z), ZodStringFormat.init(u, z);
|
|
3793
|
+
});
|
|
3794
|
+
function time(u) {
|
|
3795
|
+
return /* @__PURE__ */ _isoTime(ZodISOTime, u);
|
|
3796
|
+
}
|
|
3797
|
+
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (u, z) => {
|
|
3798
|
+
$ZodISODuration.init(u, z), ZodStringFormat.init(u, z);
|
|
3799
|
+
});
|
|
3800
|
+
function duration(u) {
|
|
3801
|
+
return /* @__PURE__ */ _isoDuration(ZodISODuration, u);
|
|
3802
|
+
}
|
|
3803
|
+
const ZodRealError = /* @__PURE__ */ $constructor("ZodError", (u, z) => {
|
|
3804
|
+
$ZodError.init(u, z), u.name = "ZodError", Object.defineProperties(u, {
|
|
3805
|
+
format: { value: (z) => formatError(u, z) },
|
|
3806
|
+
flatten: { value: (z) => flattenError(u, z) },
|
|
3807
|
+
addIssue: { value: (z) => {
|
|
3808
|
+
u.issues.push(z), u.message = JSON.stringify(u.issues, jsonStringifyReplacer, 2);
|
|
3809
|
+
} },
|
|
3810
|
+
addIssues: { value: (z) => {
|
|
3811
|
+
u.issues.push(...z), u.message = JSON.stringify(u.issues, jsonStringifyReplacer, 2);
|
|
3812
|
+
} },
|
|
3813
|
+
isEmpty: { get() {
|
|
3814
|
+
return u.issues.length === 0;
|
|
3815
|
+
} }
|
|
3816
|
+
});
|
|
3817
|
+
}, { Parent: Error }), parse = /* @__PURE__ */ _parse(ZodRealError), parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError), safeParse = /* @__PURE__ */ _safeParse(ZodRealError), safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError), encode = /* @__PURE__ */ _encode(ZodRealError), decode = /* @__PURE__ */ _decode(ZodRealError), encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError), decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError), safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError), safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError), safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError), safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3818
|
+
var _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
3819
|
+
function _installLazyMethods(u, z, B) {
|
|
3820
|
+
let V = Object.getPrototypeOf(u), H = _installedGroups.get(V);
|
|
3821
|
+
if (H || (H = /* @__PURE__ */ new Set(), _installedGroups.set(V, H)), !H.has(z)) for (let u in H.add(z), B) {
|
|
3822
|
+
let z = B[u];
|
|
3823
|
+
Object.defineProperty(V, u, {
|
|
3824
|
+
configurable: !0,
|
|
3825
|
+
enumerable: !1,
|
|
3826
|
+
get() {
|
|
3827
|
+
let B = z.bind(this);
|
|
3828
|
+
return Object.defineProperty(this, u, {
|
|
3829
|
+
configurable: !0,
|
|
3830
|
+
writable: !0,
|
|
3831
|
+
enumerable: !0,
|
|
3832
|
+
value: B
|
|
3833
|
+
}), B;
|
|
3834
|
+
},
|
|
3835
|
+
set(z) {
|
|
3836
|
+
Object.defineProperty(this, u, {
|
|
3837
|
+
configurable: !0,
|
|
3838
|
+
writable: !0,
|
|
3839
|
+
enumerable: !0,
|
|
3840
|
+
value: z
|
|
3841
|
+
});
|
|
3842
|
+
}
|
|
3843
|
+
});
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
const ZodType = /* @__PURE__ */ $constructor("ZodType", (u, z) => ($ZodType.init(u, z), Object.assign(u["~standard"], { jsonSchema: {
|
|
3847
|
+
input: createStandardJSONSchemaMethod(u, "input"),
|
|
3848
|
+
output: createStandardJSONSchemaMethod(u, "output")
|
|
3849
|
+
} }), u.toJSONSchema = createToJSONSchemaMethod(u, {}), u.def = z, u.type = z.type, Object.defineProperty(u, "_def", { value: z }), u.parse = (z, B) => parse(u, z, B, { callee: u.parse }), u.safeParse = (z, B) => safeParse(u, z, B), u.parseAsync = async (z, B) => parseAsync(u, z, B, { callee: u.parseAsync }), u.safeParseAsync = async (z, B) => safeParseAsync(u, z, B), u.spa = u.safeParseAsync, u.encode = (z, B) => encode(u, z, B), u.decode = (z, B) => decode(u, z, B), u.encodeAsync = async (z, B) => encodeAsync(u, z, B), u.decodeAsync = async (z, B) => decodeAsync(u, z, B), u.safeEncode = (z, B) => safeEncode(u, z, B), u.safeDecode = (z, B) => safeDecode(u, z, B), u.safeEncodeAsync = async (z, B) => safeEncodeAsync(u, z, B), u.safeDecodeAsync = async (z, B) => safeDecodeAsync(u, z, B), _installLazyMethods(u, "ZodType", {
|
|
3850
|
+
check(...u) {
|
|
3851
|
+
let z = this.def;
|
|
3852
|
+
return this.clone(mergeDefs(z, { checks: [...z.checks ?? [], ...u.map((u) => typeof u == "function" ? { _zod: {
|
|
3853
|
+
check: u,
|
|
3854
|
+
def: { check: "custom" },
|
|
3855
|
+
onattach: []
|
|
3856
|
+
} } : u)] }), { parent: !0 });
|
|
3857
|
+
},
|
|
3858
|
+
with(...u) {
|
|
3859
|
+
return this.check(...u);
|
|
3860
|
+
},
|
|
3861
|
+
clone(u, z) {
|
|
3862
|
+
return clone(this, u, z);
|
|
3863
|
+
},
|
|
3864
|
+
brand() {
|
|
3865
|
+
return this;
|
|
3866
|
+
},
|
|
3867
|
+
register(u, z) {
|
|
3868
|
+
return u.add(this, z), this;
|
|
3869
|
+
},
|
|
3870
|
+
refine(u, z) {
|
|
3871
|
+
return this.check(refine(u, z));
|
|
3872
|
+
},
|
|
3873
|
+
superRefine(u, z) {
|
|
3874
|
+
return this.check(superRefine(u, z));
|
|
3875
|
+
},
|
|
3876
|
+
overwrite(u) {
|
|
3877
|
+
return this.check(/* @__PURE__ */ _overwrite(u));
|
|
3878
|
+
},
|
|
3879
|
+
optional() {
|
|
3880
|
+
return optional(this);
|
|
3881
|
+
},
|
|
3882
|
+
exactOptional() {
|
|
3883
|
+
return exactOptional(this);
|
|
3884
|
+
},
|
|
3885
|
+
nullable() {
|
|
3886
|
+
return nullable(this);
|
|
3887
|
+
},
|
|
3888
|
+
nullish() {
|
|
3889
|
+
return optional(nullable(this));
|
|
3890
|
+
},
|
|
3891
|
+
nonoptional(u) {
|
|
3892
|
+
return nonoptional(this, u);
|
|
3893
|
+
},
|
|
3894
|
+
array() {
|
|
3895
|
+
return array(this);
|
|
3896
|
+
},
|
|
3897
|
+
or(u) {
|
|
3898
|
+
return union([this, u]);
|
|
3899
|
+
},
|
|
3900
|
+
and(u) {
|
|
3901
|
+
return intersection(this, u);
|
|
3902
|
+
},
|
|
3903
|
+
transform(u) {
|
|
3904
|
+
return pipe(this, transform(u));
|
|
3905
|
+
},
|
|
3906
|
+
default(u) {
|
|
3907
|
+
return _default(this, u);
|
|
3908
|
+
},
|
|
3909
|
+
prefault(u) {
|
|
3910
|
+
return prefault(this, u);
|
|
3911
|
+
},
|
|
3912
|
+
catch(u) {
|
|
3913
|
+
return _catch(this, u);
|
|
3914
|
+
},
|
|
3915
|
+
pipe(u) {
|
|
3916
|
+
return pipe(this, u);
|
|
3917
|
+
},
|
|
3918
|
+
readonly() {
|
|
3919
|
+
return readonly(this);
|
|
3920
|
+
},
|
|
3921
|
+
describe(u) {
|
|
3922
|
+
let z = this.clone();
|
|
3923
|
+
return globalRegistry.add(z, { description: u }), z;
|
|
3924
|
+
},
|
|
3925
|
+
meta(...u) {
|
|
3926
|
+
if (u.length === 0) return globalRegistry.get(this);
|
|
3927
|
+
let z = this.clone();
|
|
3928
|
+
return globalRegistry.add(z, u[0]), z;
|
|
3929
|
+
},
|
|
3930
|
+
isOptional() {
|
|
3931
|
+
return this.safeParse(void 0).success;
|
|
3932
|
+
},
|
|
3933
|
+
isNullable() {
|
|
3934
|
+
return this.safeParse(null).success;
|
|
3935
|
+
},
|
|
3936
|
+
apply(u) {
|
|
3937
|
+
return u(this);
|
|
3938
|
+
}
|
|
3939
|
+
}), Object.defineProperty(u, "description", {
|
|
3940
|
+
get() {
|
|
3941
|
+
return globalRegistry.get(u)?.description;
|
|
3942
|
+
},
|
|
3943
|
+
configurable: !0
|
|
3944
|
+
}), u)), _ZodString = /* @__PURE__ */ $constructor("_ZodString", (u, z) => {
|
|
3945
|
+
$ZodString.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => stringProcessor(u, z, B, V);
|
|
3946
|
+
let B = u._zod.bag;
|
|
3947
|
+
u.format = B.format ?? null, u.minLength = B.minimum ?? null, u.maxLength = B.maximum ?? null, _installLazyMethods(u, "_ZodString", {
|
|
3948
|
+
regex(...u) {
|
|
3949
|
+
return this.check(/* @__PURE__ */ _regex(...u));
|
|
3950
|
+
},
|
|
3951
|
+
includes(...u) {
|
|
3952
|
+
return this.check(/* @__PURE__ */ _includes(...u));
|
|
3953
|
+
},
|
|
3954
|
+
startsWith(...u) {
|
|
3955
|
+
return this.check(/* @__PURE__ */ _startsWith(...u));
|
|
3956
|
+
},
|
|
3957
|
+
endsWith(...u) {
|
|
3958
|
+
return this.check(/* @__PURE__ */ _endsWith(...u));
|
|
3959
|
+
},
|
|
3960
|
+
min(...u) {
|
|
3961
|
+
return this.check(/* @__PURE__ */ _minLength(...u));
|
|
3962
|
+
},
|
|
3963
|
+
max(...u) {
|
|
3964
|
+
return this.check(/* @__PURE__ */ _maxLength(...u));
|
|
3965
|
+
},
|
|
3966
|
+
length(...u) {
|
|
3967
|
+
return this.check(/* @__PURE__ */ _length(...u));
|
|
3968
|
+
},
|
|
3969
|
+
nonempty(...u) {
|
|
3970
|
+
return this.check(/* @__PURE__ */ _minLength(1, ...u));
|
|
3971
|
+
},
|
|
3972
|
+
lowercase(u) {
|
|
3973
|
+
return this.check(/* @__PURE__ */ _lowercase(u));
|
|
3974
|
+
},
|
|
3975
|
+
uppercase(u) {
|
|
3976
|
+
return this.check(/* @__PURE__ */ _uppercase(u));
|
|
3977
|
+
},
|
|
3978
|
+
trim() {
|
|
3979
|
+
return this.check(/* @__PURE__ */ _trim());
|
|
3980
|
+
},
|
|
3981
|
+
normalize(...u) {
|
|
3982
|
+
return this.check(/* @__PURE__ */ _normalize(...u));
|
|
3983
|
+
},
|
|
3984
|
+
toLowerCase() {
|
|
3985
|
+
return this.check(/* @__PURE__ */ _toLowerCase());
|
|
3986
|
+
},
|
|
3987
|
+
toUpperCase() {
|
|
3988
|
+
return this.check(/* @__PURE__ */ _toUpperCase());
|
|
3989
|
+
},
|
|
3990
|
+
slugify() {
|
|
3991
|
+
return this.check(/* @__PURE__ */ _slugify());
|
|
3992
|
+
}
|
|
3993
|
+
});
|
|
3994
|
+
}), ZodString = /* @__PURE__ */ $constructor("ZodString", (u, z) => {
|
|
3995
|
+
$ZodString.init(u, z), _ZodString.init(u, z), u.email = (z) => u.check(/* @__PURE__ */ _email(ZodEmail, z)), u.url = (z) => u.check(/* @__PURE__ */ _url(ZodURL, z)), u.jwt = (z) => u.check(/* @__PURE__ */ _jwt(ZodJWT, z)), u.emoji = (z) => u.check(/* @__PURE__ */ _emoji(ZodEmoji, z)), u.guid = (z) => u.check(/* @__PURE__ */ _guid(ZodGUID, z)), u.uuid = (z) => u.check(/* @__PURE__ */ _uuid(ZodUUID, z)), u.uuidv4 = (z) => u.check(/* @__PURE__ */ _uuidv4(ZodUUID, z)), u.uuidv6 = (z) => u.check(/* @__PURE__ */ _uuidv6(ZodUUID, z)), u.uuidv7 = (z) => u.check(/* @__PURE__ */ _uuidv7(ZodUUID, z)), u.nanoid = (z) => u.check(/* @__PURE__ */ _nanoid(ZodNanoID, z)), u.guid = (z) => u.check(/* @__PURE__ */ _guid(ZodGUID, z)), u.cuid = (z) => u.check(/* @__PURE__ */ _cuid(ZodCUID, z)), u.cuid2 = (z) => u.check(/* @__PURE__ */ _cuid2(ZodCUID2, z)), u.ulid = (z) => u.check(/* @__PURE__ */ _ulid(ZodULID, z)), u.base64 = (z) => u.check(/* @__PURE__ */ _base64(ZodBase64, z)), u.base64url = (z) => u.check(/* @__PURE__ */ _base64url(ZodBase64URL, z)), u.xid = (z) => u.check(/* @__PURE__ */ _xid(ZodXID, z)), u.ksuid = (z) => u.check(/* @__PURE__ */ _ksuid(ZodKSUID, z)), u.ipv4 = (z) => u.check(/* @__PURE__ */ _ipv4(ZodIPv4, z)), u.ipv6 = (z) => u.check(/* @__PURE__ */ _ipv6(ZodIPv6, z)), u.cidrv4 = (z) => u.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, z)), u.cidrv6 = (z) => u.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, z)), u.e164 = (z) => u.check(/* @__PURE__ */ _e164(ZodE164, z)), u.datetime = (z) => u.check(datetime(z)), u.date = (z) => u.check(date(z)), u.time = (z) => u.check(time(z)), u.duration = (z) => u.check(duration(z));
|
|
3996
|
+
});
|
|
3997
|
+
function string(u) {
|
|
3998
|
+
return /* @__PURE__ */ _string(ZodString, u);
|
|
3999
|
+
}
|
|
4000
|
+
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (u, z) => {
|
|
4001
|
+
$ZodStringFormat.init(u, z), _ZodString.init(u, z);
|
|
4002
|
+
}), ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (u, z) => {
|
|
4003
|
+
$ZodEmail.init(u, z), ZodStringFormat.init(u, z);
|
|
4004
|
+
}), ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (u, z) => {
|
|
4005
|
+
$ZodGUID.init(u, z), ZodStringFormat.init(u, z);
|
|
4006
|
+
}), ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (u, z) => {
|
|
4007
|
+
$ZodUUID.init(u, z), ZodStringFormat.init(u, z);
|
|
4008
|
+
}), ZodURL = /* @__PURE__ */ $constructor("ZodURL", (u, z) => {
|
|
4009
|
+
$ZodURL.init(u, z), ZodStringFormat.init(u, z);
|
|
4010
|
+
}), ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (u, z) => {
|
|
4011
|
+
$ZodEmoji.init(u, z), ZodStringFormat.init(u, z);
|
|
4012
|
+
}), ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (u, z) => {
|
|
4013
|
+
$ZodNanoID.init(u, z), ZodStringFormat.init(u, z);
|
|
4014
|
+
}), ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (u, z) => {
|
|
4015
|
+
$ZodCUID.init(u, z), ZodStringFormat.init(u, z);
|
|
4016
|
+
}), ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (u, z) => {
|
|
4017
|
+
$ZodCUID2.init(u, z), ZodStringFormat.init(u, z);
|
|
4018
|
+
}), ZodULID = /* @__PURE__ */ $constructor("ZodULID", (u, z) => {
|
|
4019
|
+
$ZodULID.init(u, z), ZodStringFormat.init(u, z);
|
|
4020
|
+
}), ZodXID = /* @__PURE__ */ $constructor("ZodXID", (u, z) => {
|
|
4021
|
+
$ZodXID.init(u, z), ZodStringFormat.init(u, z);
|
|
4022
|
+
}), ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (u, z) => {
|
|
4023
|
+
$ZodKSUID.init(u, z), ZodStringFormat.init(u, z);
|
|
4024
|
+
}), ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (u, z) => {
|
|
4025
|
+
$ZodIPv4.init(u, z), ZodStringFormat.init(u, z);
|
|
4026
|
+
}), ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (u, z) => {
|
|
4027
|
+
$ZodIPv6.init(u, z), ZodStringFormat.init(u, z);
|
|
4028
|
+
}), ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (u, z) => {
|
|
4029
|
+
$ZodCIDRv4.init(u, z), ZodStringFormat.init(u, z);
|
|
4030
|
+
}), ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (u, z) => {
|
|
4031
|
+
$ZodCIDRv6.init(u, z), ZodStringFormat.init(u, z);
|
|
4032
|
+
}), ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (u, z) => {
|
|
4033
|
+
$ZodBase64.init(u, z), ZodStringFormat.init(u, z);
|
|
4034
|
+
}), ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (u, z) => {
|
|
4035
|
+
$ZodBase64URL.init(u, z), ZodStringFormat.init(u, z);
|
|
4036
|
+
}), ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (u, z) => {
|
|
4037
|
+
$ZodE164.init(u, z), ZodStringFormat.init(u, z);
|
|
4038
|
+
}), ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (u, z) => {
|
|
4039
|
+
$ZodJWT.init(u, z), ZodStringFormat.init(u, z);
|
|
4040
|
+
}), ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (u, z) => {
|
|
4041
|
+
$ZodUnknown.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (u, z, B) => void 0;
|
|
4042
|
+
});
|
|
4043
|
+
function unknown() {
|
|
4044
|
+
return /* @__PURE__ */ _unknown(ZodUnknown);
|
|
4045
|
+
}
|
|
4046
|
+
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (u, z) => {
|
|
4047
|
+
$ZodNever.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => neverProcessor(u, z, B, V);
|
|
4048
|
+
});
|
|
4049
|
+
function never(u) {
|
|
4050
|
+
return /* @__PURE__ */ _never(ZodNever, u);
|
|
4051
|
+
}
|
|
4052
|
+
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (u, z) => {
|
|
4053
|
+
$ZodArray.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => arrayProcessor(u, z, B, V), u.element = z.element, _installLazyMethods(u, "ZodArray", {
|
|
4054
|
+
min(u, z) {
|
|
4055
|
+
return this.check(/* @__PURE__ */ _minLength(u, z));
|
|
4056
|
+
},
|
|
4057
|
+
nonempty(u) {
|
|
4058
|
+
return this.check(/* @__PURE__ */ _minLength(1, u));
|
|
4059
|
+
},
|
|
4060
|
+
max(u, z) {
|
|
4061
|
+
return this.check(/* @__PURE__ */ _maxLength(u, z));
|
|
4062
|
+
},
|
|
4063
|
+
length(u, z) {
|
|
4064
|
+
return this.check(/* @__PURE__ */ _length(u, z));
|
|
4065
|
+
},
|
|
4066
|
+
unwrap() {
|
|
4067
|
+
return this.element;
|
|
4068
|
+
}
|
|
4069
|
+
});
|
|
4070
|
+
});
|
|
4071
|
+
function array(u, z) {
|
|
4072
|
+
return /* @__PURE__ */ _array(ZodArray, u, z);
|
|
4073
|
+
}
|
|
4074
|
+
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (u, z) => {
|
|
4075
|
+
$ZodObjectJIT.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => objectProcessor(u, z, B, V), defineLazy(u, "shape", () => z.shape), _installLazyMethods(u, "ZodObject", {
|
|
4076
|
+
keyof() {
|
|
4077
|
+
return _enum(Object.keys(this._zod.def.shape));
|
|
4078
|
+
},
|
|
4079
|
+
catchall(u) {
|
|
4080
|
+
return this.clone({
|
|
4081
|
+
...this._zod.def,
|
|
4082
|
+
catchall: u
|
|
4083
|
+
});
|
|
4084
|
+
},
|
|
4085
|
+
passthrough() {
|
|
4086
|
+
return this.clone({
|
|
4087
|
+
...this._zod.def,
|
|
4088
|
+
catchall: unknown()
|
|
4089
|
+
});
|
|
4090
|
+
},
|
|
4091
|
+
loose() {
|
|
4092
|
+
return this.clone({
|
|
4093
|
+
...this._zod.def,
|
|
4094
|
+
catchall: unknown()
|
|
4095
|
+
});
|
|
4096
|
+
},
|
|
4097
|
+
strict() {
|
|
4098
|
+
return this.clone({
|
|
4099
|
+
...this._zod.def,
|
|
4100
|
+
catchall: never()
|
|
4101
|
+
});
|
|
4102
|
+
},
|
|
4103
|
+
strip() {
|
|
4104
|
+
return this.clone({
|
|
4105
|
+
...this._zod.def,
|
|
4106
|
+
catchall: void 0
|
|
4107
|
+
});
|
|
4108
|
+
},
|
|
4109
|
+
extend(u) {
|
|
4110
|
+
return extend(this, u);
|
|
4111
|
+
},
|
|
4112
|
+
safeExtend(u) {
|
|
4113
|
+
return safeExtend(this, u);
|
|
4114
|
+
},
|
|
4115
|
+
merge(u) {
|
|
4116
|
+
return merge(this, u);
|
|
4117
|
+
},
|
|
4118
|
+
pick(u) {
|
|
4119
|
+
return pick(this, u);
|
|
4120
|
+
},
|
|
4121
|
+
omit(u) {
|
|
4122
|
+
return omit(this, u);
|
|
4123
|
+
},
|
|
4124
|
+
partial(...u) {
|
|
4125
|
+
return partial(ZodOptional, this, u[0]);
|
|
4126
|
+
},
|
|
4127
|
+
required(...u) {
|
|
4128
|
+
return required(ZodNonOptional, this, u[0]);
|
|
4129
|
+
}
|
|
4130
|
+
});
|
|
4131
|
+
});
|
|
4132
|
+
function object(u, z) {
|
|
4133
|
+
return new ZodObject({
|
|
4134
|
+
type: "object",
|
|
4135
|
+
shape: u ?? {},
|
|
4136
|
+
...normalizeParams(z)
|
|
4137
|
+
});
|
|
4138
|
+
}
|
|
4139
|
+
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (u, z) => {
|
|
4140
|
+
$ZodUnion.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => unionProcessor(u, z, B, V), u.options = z.options;
|
|
4141
|
+
});
|
|
4142
|
+
function union(u, z) {
|
|
4143
|
+
return new ZodUnion({
|
|
4144
|
+
type: "union",
|
|
4145
|
+
options: u,
|
|
4146
|
+
...normalizeParams(z)
|
|
4147
|
+
});
|
|
4148
|
+
}
|
|
4149
|
+
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (u, z) => {
|
|
4150
|
+
$ZodIntersection.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => intersectionProcessor(u, z, B, V);
|
|
4151
|
+
});
|
|
4152
|
+
function intersection(u, z) {
|
|
4153
|
+
return new ZodIntersection({
|
|
4154
|
+
type: "intersection",
|
|
4155
|
+
left: u,
|
|
4156
|
+
right: z
|
|
4157
|
+
});
|
|
4158
|
+
}
|
|
4159
|
+
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (u, z) => {
|
|
4160
|
+
$ZodRecord.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => recordProcessor(u, z, B, V), u.keyType = z.keyType, u.valueType = z.valueType;
|
|
4161
|
+
});
|
|
4162
|
+
function record(u, z, B) {
|
|
4163
|
+
return !z || !z._zod ? new ZodRecord({
|
|
4164
|
+
type: "record",
|
|
4165
|
+
keyType: string(),
|
|
4166
|
+
valueType: u,
|
|
4167
|
+
...normalizeParams(z)
|
|
4168
|
+
}) : new ZodRecord({
|
|
4169
|
+
type: "record",
|
|
4170
|
+
keyType: u,
|
|
4171
|
+
valueType: z,
|
|
4172
|
+
...normalizeParams(B)
|
|
4173
|
+
});
|
|
4174
|
+
}
|
|
4175
|
+
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (u, z) => {
|
|
4176
|
+
$ZodEnum.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => enumProcessor(u, z, B, V), u.enum = z.entries, u.options = Object.values(z.entries);
|
|
4177
|
+
let B = new Set(Object.keys(z.entries));
|
|
4178
|
+
u.extract = (u, V) => {
|
|
4179
|
+
let H = {};
|
|
4180
|
+
for (let V of u) if (B.has(V)) H[V] = z.entries[V];
|
|
4181
|
+
else throw Error(`Key ${V} not found in enum`);
|
|
4182
|
+
return new ZodEnum({
|
|
4183
|
+
...z,
|
|
4184
|
+
checks: [],
|
|
4185
|
+
...normalizeParams(V),
|
|
4186
|
+
entries: H
|
|
4187
|
+
});
|
|
4188
|
+
}, u.exclude = (u, V) => {
|
|
4189
|
+
let H = { ...z.entries };
|
|
4190
|
+
for (let z of u) if (B.has(z)) delete H[z];
|
|
4191
|
+
else throw Error(`Key ${z} not found in enum`);
|
|
4192
|
+
return new ZodEnum({
|
|
4193
|
+
...z,
|
|
4194
|
+
checks: [],
|
|
4195
|
+
...normalizeParams(V),
|
|
4196
|
+
entries: H
|
|
4197
|
+
});
|
|
4198
|
+
};
|
|
4199
|
+
});
|
|
4200
|
+
function _enum(u, z) {
|
|
4201
|
+
return new ZodEnum({
|
|
4202
|
+
type: "enum",
|
|
4203
|
+
entries: Array.isArray(u) ? Object.fromEntries(u.map((u) => [u, u])) : u,
|
|
4204
|
+
...normalizeParams(z)
|
|
4205
|
+
});
|
|
4206
|
+
}
|
|
4207
|
+
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (u, z) => {
|
|
4208
|
+
$ZodTransform.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => transformProcessor(u, z, B, V), u._zod.parse = (B, V) => {
|
|
4209
|
+
if (V.direction === "backward") throw new $ZodEncodeError(u.constructor.name);
|
|
4210
|
+
B.addIssue = (V) => {
|
|
4211
|
+
if (typeof V == "string") B.issues.push(issue(V, B.value, z));
|
|
4212
|
+
else {
|
|
4213
|
+
let z = V;
|
|
4214
|
+
z.fatal && (z.continue = !1), z.code ??= "custom", z.input ??= B.value, z.inst ??= u, B.issues.push(issue(z));
|
|
4215
|
+
}
|
|
4216
|
+
};
|
|
4217
|
+
let H = z.transform(B.value, B);
|
|
4218
|
+
return H instanceof Promise ? H.then((u) => (B.value = u, B.fallback = !0, B)) : (B.value = H, B.fallback = !0, B);
|
|
4219
|
+
};
|
|
4220
|
+
});
|
|
4221
|
+
function transform(u) {
|
|
4222
|
+
return new ZodTransform({
|
|
4223
|
+
type: "transform",
|
|
4224
|
+
transform: u
|
|
4225
|
+
});
|
|
4226
|
+
}
|
|
4227
|
+
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (u, z) => {
|
|
4228
|
+
$ZodOptional.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => optionalProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4229
|
+
});
|
|
4230
|
+
function optional(u) {
|
|
4231
|
+
return new ZodOptional({
|
|
4232
|
+
type: "optional",
|
|
4233
|
+
innerType: u
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (u, z) => {
|
|
4237
|
+
$ZodExactOptional.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => optionalProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4238
|
+
});
|
|
4239
|
+
function exactOptional(u) {
|
|
4240
|
+
return new ZodExactOptional({
|
|
4241
|
+
type: "optional",
|
|
4242
|
+
innerType: u
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (u, z) => {
|
|
4246
|
+
$ZodNullable.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => nullableProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4247
|
+
});
|
|
4248
|
+
function nullable(u) {
|
|
4249
|
+
return new ZodNullable({
|
|
4250
|
+
type: "nullable",
|
|
4251
|
+
innerType: u
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (u, z) => {
|
|
4255
|
+
$ZodDefault.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => defaultProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType, u.removeDefault = u.unwrap;
|
|
4256
|
+
});
|
|
4257
|
+
function _default(u, z) {
|
|
4258
|
+
return new ZodDefault({
|
|
4259
|
+
type: "default",
|
|
4260
|
+
innerType: u,
|
|
4261
|
+
get defaultValue() {
|
|
4262
|
+
return typeof z == "function" ? z() : shallowClone(z);
|
|
4263
|
+
}
|
|
4264
|
+
});
|
|
4265
|
+
}
|
|
4266
|
+
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (u, z) => {
|
|
4267
|
+
$ZodPrefault.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => prefaultProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4268
|
+
});
|
|
4269
|
+
function prefault(u, z) {
|
|
4270
|
+
return new ZodPrefault({
|
|
4271
|
+
type: "prefault",
|
|
4272
|
+
innerType: u,
|
|
4273
|
+
get defaultValue() {
|
|
4274
|
+
return typeof z == "function" ? z() : shallowClone(z);
|
|
4275
|
+
}
|
|
4276
|
+
});
|
|
4277
|
+
}
|
|
4278
|
+
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (u, z) => {
|
|
4279
|
+
$ZodNonOptional.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => nonoptionalProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4280
|
+
});
|
|
4281
|
+
function nonoptional(u, z) {
|
|
4282
|
+
return new ZodNonOptional({
|
|
4283
|
+
type: "nonoptional",
|
|
4284
|
+
innerType: u,
|
|
4285
|
+
...normalizeParams(z)
|
|
4286
|
+
});
|
|
4287
|
+
}
|
|
4288
|
+
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (u, z) => {
|
|
4289
|
+
$ZodCatch.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => catchProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType, u.removeCatch = u.unwrap;
|
|
4290
|
+
});
|
|
4291
|
+
function _catch(u, z) {
|
|
4292
|
+
return new ZodCatch({
|
|
4293
|
+
type: "catch",
|
|
4294
|
+
innerType: u,
|
|
4295
|
+
catchValue: typeof z == "function" ? z : () => z
|
|
4296
|
+
});
|
|
4297
|
+
}
|
|
4298
|
+
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (u, z) => {
|
|
4299
|
+
$ZodPipe.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => pipeProcessor(u, z, B, V), u.in = z.in, u.out = z.out;
|
|
4300
|
+
});
|
|
4301
|
+
function pipe(u, z) {
|
|
4302
|
+
return new ZodPipe({
|
|
4303
|
+
type: "pipe",
|
|
4304
|
+
in: u,
|
|
4305
|
+
out: z
|
|
4306
|
+
});
|
|
4307
|
+
}
|
|
4308
|
+
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (u, z) => {
|
|
4309
|
+
$ZodReadonly.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => readonlyProcessor(u, z, B, V), u.unwrap = () => u._zod.def.innerType;
|
|
4310
|
+
});
|
|
4311
|
+
function readonly(u) {
|
|
4312
|
+
return new ZodReadonly({
|
|
4313
|
+
type: "readonly",
|
|
4314
|
+
innerType: u
|
|
4315
|
+
});
|
|
4316
|
+
}
|
|
4317
|
+
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (u, z) => {
|
|
4318
|
+
$ZodCustom.init(u, z), ZodType.init(u, z), u._zod.processJSONSchema = (z, B, V) => customProcessor(u, z, B, V);
|
|
4319
|
+
});
|
|
4320
|
+
function refine(u, z = {}) {
|
|
4321
|
+
return /* @__PURE__ */ _refine(ZodCustom, u, z);
|
|
4322
|
+
}
|
|
4323
|
+
function superRefine(u, z) {
|
|
4324
|
+
return /* @__PURE__ */ _superRefine(u, z);
|
|
4325
|
+
}
|
|
4326
|
+
export { Subscribable as A, resolveStaleTime as C, timeUntilStale as D, skipToken as E, client as M, timeoutManager as O, resolveQueryBoolean as S, shouldThrowError as T, matchMutation as _, Mutation as a, partialMatchKey as b, fetchState as c, pendingThenable as d, environmentManager as f, isValidTimeout as g, hashQueryKeyByOptions as h, string as i, Client as j, focusManager as k, onlineManager as l, hashKey as m, object as n, getDefaultState as o, functionalUpdate as p, record as r, Query as s, _enum as t, notifyManager as u, matchQuery as v, shallowEqualObjects as w, replaceData as x, noop as y };
|