@jixo/cli 0.24.1 → 0.25.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/assets/bundle/google-aistudio.browser.js +3180 -27
- package/bundle/index.js +44 -45
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const obj_assign_props = /* @__NO_SIDE_EFFECTS__ */ (a, b) => {
|
|
2
|
-
const b_props = Object.getOwnPropertyDescriptors(b);
|
|
3
|
-
Object.defineProperties(a, b_props);
|
|
4
|
-
return a;
|
|
1
|
+
const obj_assign_props = /* @__NO_SIDE_EFFECTS__ */ (a$1, b$1) => {
|
|
2
|
+
const b_props = Object.getOwnPropertyDescriptors(b$1);
|
|
3
|
+
Object.defineProperties(a$1, b_props);
|
|
4
|
+
return a$1;
|
|
5
5
|
};
|
|
6
6
|
const isPromiseLike = (value) => value !== null && typeof value?.then === "function";
|
|
7
7
|
const func_remember = /* @__NO_SIDE_EFFECTS__ */ (func, key) => {
|
|
@@ -218,17 +218,17 @@ const prepareDirHandle = async () => {
|
|
|
218
218
|
rootDirHandle = await window.showDirectoryPicker({ mode: "readwrite" });
|
|
219
219
|
console.log(`%c✅ 根文件夹已选择: %c${rootDirHandle.name}`, styles.success, styles.code);
|
|
220
220
|
return rootDirHandle;
|
|
221
|
-
} catch (e) {
|
|
221
|
+
} catch (e$1) {
|
|
222
222
|
clearTimeout(ti);
|
|
223
|
-
if (e instanceof Error) {
|
|
224
|
-
if (e.name === "SecurityError" || e.name === "NotAllowedError") {
|
|
223
|
+
if (e$1 instanceof Error) {
|
|
224
|
+
if (e$1.name === "SecurityError" || e$1.name === "NotAllowedError") {
|
|
225
225
|
console.log("%c请将鼠标聚焦到窗口视图中", styles.info);
|
|
226
226
|
await delay(1e3);
|
|
227
227
|
return prepareDirHandle();
|
|
228
228
|
}
|
|
229
|
-
if (e.name === "AbortError") throw new DOMException("用户取消了文件夹选择", "AbortError");
|
|
229
|
+
if (e$1.name === "AbortError") throw new DOMException("用户取消了文件夹选择", "AbortError");
|
|
230
230
|
}
|
|
231
|
-
throw e;
|
|
231
|
+
throw e$1;
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
234
|
const getEasyFs = /* @__PURE__ */ func_remember(async () => {
|
|
@@ -241,7 +241,7 @@ const getEasyFs = /* @__PURE__ */ func_remember(async () => {
|
|
|
241
241
|
let curr = dirHandle;
|
|
242
242
|
const parts = path.split("/").filter(Boolean);
|
|
243
243
|
const last = parts.at(-1);
|
|
244
|
-
for (let i = 0; i < parts.length - 1; i++) curr = await curr.getDirectoryHandle(parts[i], { create });
|
|
244
|
+
for (let i$1 = 0; i$1 < parts.length - 1; i$1++) curr = await curr.getDirectoryHandle(parts[i$1], { create });
|
|
245
245
|
return {
|
|
246
246
|
parent: curr,
|
|
247
247
|
name: last,
|
|
@@ -258,10 +258,10 @@ const getEasyFs = /* @__PURE__ */ func_remember(async () => {
|
|
|
258
258
|
const writeFile = async (filePath, data, opts) => {
|
|
259
259
|
const { getFile } = await getHandle(filePath, { create: true });
|
|
260
260
|
const handle = await getFile();
|
|
261
|
-
const w = await handle.createWritable();
|
|
262
|
-
if (!opts?.append) await w.truncate(0);
|
|
263
|
-
await w.write(data);
|
|
264
|
-
await w.close();
|
|
261
|
+
const w$1 = await handle.createWritable();
|
|
262
|
+
if (!opts?.append) await w$1.truncate(0);
|
|
263
|
+
await w$1.write(data);
|
|
264
|
+
await w$1.close();
|
|
265
265
|
};
|
|
266
266
|
const createWriteStream = async (filePath) => {
|
|
267
267
|
const { getFile } = await getHandle(filePath, { create: true });
|
|
@@ -307,12 +307,12 @@ const getEasyFs = /* @__PURE__ */ func_remember(async () => {
|
|
|
307
307
|
const stat = async (path) => {
|
|
308
308
|
const { getFile, getDir } = await getHandle(path);
|
|
309
309
|
try {
|
|
310
|
-
const h = await getFile();
|
|
311
|
-
const f = await h.getFile();
|
|
310
|
+
const h$1 = await getFile();
|
|
311
|
+
const f$1 = await h$1.getFile();
|
|
312
312
|
return {
|
|
313
313
|
isFile: true,
|
|
314
|
-
size: f.size,
|
|
315
|
-
lastModified: f.lastModified
|
|
314
|
+
size: f$1.size,
|
|
315
|
+
lastModified: f$1.lastModified
|
|
316
316
|
};
|
|
317
317
|
} catch {
|
|
318
318
|
await getDir();
|
|
@@ -410,17 +410,3170 @@ const syncInput = async (fps = 3) => {
|
|
|
410
410
|
}
|
|
411
411
|
})();
|
|
412
412
|
};
|
|
413
|
+
const t = Symbol.for("@ts-pattern/matcher"), e = Symbol.for("@ts-pattern/isVariadic"), n = "@ts-pattern/anonymous-select-key", r = (t$1) => Boolean(t$1 && "object" == typeof t$1), i = (e$1) => e$1 && !!e$1[t], o = (n$1, s$1, c$1) => {
|
|
414
|
+
if (i(n$1)) {
|
|
415
|
+
const e$1 = n$1[t](), { matched: r$1, selections: i$1 } = e$1.match(s$1);
|
|
416
|
+
return r$1 && i$1 && Object.keys(i$1).forEach((t$1) => c$1(t$1, i$1[t$1])), r$1;
|
|
417
|
+
}
|
|
418
|
+
if (r(n$1)) {
|
|
419
|
+
if (!r(s$1)) return !1;
|
|
420
|
+
if (Array.isArray(n$1)) {
|
|
421
|
+
if (!Array.isArray(s$1)) return !1;
|
|
422
|
+
let t$1 = [], r$1 = [], a$1 = [];
|
|
423
|
+
for (const o$1 of n$1.keys()) {
|
|
424
|
+
const s$2 = n$1[o$1];
|
|
425
|
+
i(s$2) && s$2[e] ? a$1.push(s$2) : a$1.length ? r$1.push(s$2) : t$1.push(s$2);
|
|
426
|
+
}
|
|
427
|
+
if (a$1.length) {
|
|
428
|
+
if (a$1.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
429
|
+
if (s$1.length < t$1.length + r$1.length) return !1;
|
|
430
|
+
const e$1 = s$1.slice(0, t$1.length), n$2 = 0 === r$1.length ? [] : s$1.slice(-r$1.length), i$1 = s$1.slice(t$1.length, 0 === r$1.length ? Infinity : -r$1.length);
|
|
431
|
+
return t$1.every((t$2, n$3) => o(t$2, e$1[n$3], c$1)) && r$1.every((t$2, e$2) => o(t$2, n$2[e$2], c$1)) && (0 === a$1.length || o(a$1[0], i$1, c$1));
|
|
432
|
+
}
|
|
433
|
+
return n$1.length === s$1.length && n$1.every((t$2, e$1) => o(t$2, s$1[e$1], c$1));
|
|
434
|
+
}
|
|
435
|
+
return Reflect.ownKeys(n$1).every((e$1) => {
|
|
436
|
+
const r$1 = n$1[e$1];
|
|
437
|
+
return (e$1 in s$1 || i(a$1 = r$1) && "optional" === a$1[t]().matcherType) && o(r$1, s$1[e$1], c$1);
|
|
438
|
+
var a$1;
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return Object.is(s$1, n$1);
|
|
442
|
+
}, s = (e$1) => {
|
|
443
|
+
var n$1, o$1, a$1;
|
|
444
|
+
return r(e$1) ? i(e$1) ? null != (n$1 = null == (o$1 = (a$1 = e$1[t]()).getSelectionKeys) ? void 0 : o$1.call(a$1)) ? n$1 : [] : Array.isArray(e$1) ? c(e$1, s) : c(Object.values(e$1), s) : [];
|
|
445
|
+
}, c = (t$1, e$1) => t$1.reduce((t$2, n$1) => t$2.concat(e$1(n$1)), []);
|
|
446
|
+
function a(...t$1) {
|
|
447
|
+
if (1 === t$1.length) {
|
|
448
|
+
const [e$1] = t$1;
|
|
449
|
+
return (t$2) => o(e$1, t$2, () => {});
|
|
450
|
+
}
|
|
451
|
+
if (2 === t$1.length) {
|
|
452
|
+
const [e$1, n$1] = t$1;
|
|
453
|
+
return o(e$1, n$1, () => {});
|
|
454
|
+
}
|
|
455
|
+
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t$1.length}.`);
|
|
456
|
+
}
|
|
457
|
+
function u(t$1) {
|
|
458
|
+
return Object.assign(t$1, {
|
|
459
|
+
optional: () => h(t$1),
|
|
460
|
+
and: (e$1) => m(t$1, e$1),
|
|
461
|
+
or: (e$1) => d(t$1, e$1),
|
|
462
|
+
select: (e$1) => void 0 === e$1 ? y(t$1) : y(e$1, t$1)
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function l(t$1) {
|
|
466
|
+
return Object.assign(((t$2) => Object.assign(t$2, { [Symbol.iterator]() {
|
|
467
|
+
let n$1 = 0;
|
|
468
|
+
const r$1 = [{
|
|
469
|
+
value: Object.assign(t$2, { [e]: !0 }),
|
|
470
|
+
done: !1
|
|
471
|
+
}, {
|
|
472
|
+
done: !0,
|
|
473
|
+
value: void 0
|
|
474
|
+
}];
|
|
475
|
+
return { next: () => {
|
|
476
|
+
var t$3;
|
|
477
|
+
return null != (t$3 = r$1[n$1++]) ? t$3 : r$1.at(-1);
|
|
478
|
+
} };
|
|
479
|
+
} }))(t$1), {
|
|
480
|
+
optional: () => l(h(t$1)),
|
|
481
|
+
select: (e$1) => l(void 0 === e$1 ? y(t$1) : y(e$1, t$1))
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
function h(e$1) {
|
|
485
|
+
return u({ [t]: () => ({
|
|
486
|
+
match: (t$1) => {
|
|
487
|
+
let n$1 = {};
|
|
488
|
+
const r$1 = (t$2, e$2) => {
|
|
489
|
+
n$1[t$2] = e$2;
|
|
490
|
+
};
|
|
491
|
+
return void 0 === t$1 ? (s(e$1).forEach((t$2) => r$1(t$2, void 0)), {
|
|
492
|
+
matched: !0,
|
|
493
|
+
selections: n$1
|
|
494
|
+
}) : {
|
|
495
|
+
matched: o(e$1, t$1, r$1),
|
|
496
|
+
selections: n$1
|
|
497
|
+
};
|
|
498
|
+
},
|
|
499
|
+
getSelectionKeys: () => s(e$1),
|
|
500
|
+
matcherType: "optional"
|
|
501
|
+
}) });
|
|
502
|
+
}
|
|
503
|
+
const f = (t$1, e$1) => {
|
|
504
|
+
for (const n$1 of t$1) if (!e$1(n$1)) return !1;
|
|
505
|
+
return !0;
|
|
506
|
+
}, g = (t$1, e$1) => {
|
|
507
|
+
for (const [n$1, r$1] of t$1.entries()) if (!e$1(r$1, n$1)) return !1;
|
|
508
|
+
return !0;
|
|
509
|
+
};
|
|
510
|
+
function m(...e$1) {
|
|
511
|
+
return u({ [t]: () => ({
|
|
512
|
+
match: (t$1) => {
|
|
513
|
+
let n$1 = {};
|
|
514
|
+
const r$1 = (t$2, e$2) => {
|
|
515
|
+
n$1[t$2] = e$2;
|
|
516
|
+
};
|
|
517
|
+
return {
|
|
518
|
+
matched: e$1.every((e$2) => o(e$2, t$1, r$1)),
|
|
519
|
+
selections: n$1
|
|
520
|
+
};
|
|
521
|
+
},
|
|
522
|
+
getSelectionKeys: () => c(e$1, s),
|
|
523
|
+
matcherType: "and"
|
|
524
|
+
}) });
|
|
525
|
+
}
|
|
526
|
+
function d(...e$1) {
|
|
527
|
+
return u({ [t]: () => ({
|
|
528
|
+
match: (t$1) => {
|
|
529
|
+
let n$1 = {};
|
|
530
|
+
const r$1 = (t$2, e$2) => {
|
|
531
|
+
n$1[t$2] = e$2;
|
|
532
|
+
};
|
|
533
|
+
return c(e$1, s).forEach((t$2) => r$1(t$2, void 0)), {
|
|
534
|
+
matched: e$1.some((e$2) => o(e$2, t$1, r$1)),
|
|
535
|
+
selections: n$1
|
|
536
|
+
};
|
|
537
|
+
},
|
|
538
|
+
getSelectionKeys: () => c(e$1, s),
|
|
539
|
+
matcherType: "or"
|
|
540
|
+
}) });
|
|
541
|
+
}
|
|
542
|
+
function p(e$1) {
|
|
543
|
+
return { [t]: () => ({ match: (t$1) => ({ matched: Boolean(e$1(t$1)) }) }) };
|
|
544
|
+
}
|
|
545
|
+
function y(...e$1) {
|
|
546
|
+
const r$1 = "string" == typeof e$1[0] ? e$1[0] : void 0, i$1 = 2 === e$1.length ? e$1[1] : "string" == typeof e$1[0] ? void 0 : e$1[0];
|
|
547
|
+
return u({ [t]: () => ({
|
|
548
|
+
match: (t$1) => {
|
|
549
|
+
let e$2 = { [null != r$1 ? r$1 : n]: t$1 };
|
|
550
|
+
return {
|
|
551
|
+
matched: void 0 === i$1 || o(i$1, t$1, (t$2, n$1) => {
|
|
552
|
+
e$2[t$2] = n$1;
|
|
553
|
+
}),
|
|
554
|
+
selections: e$2
|
|
555
|
+
};
|
|
556
|
+
},
|
|
557
|
+
getSelectionKeys: () => [null != r$1 ? r$1 : n].concat(void 0 === i$1 ? [] : s(i$1))
|
|
558
|
+
}) });
|
|
559
|
+
}
|
|
560
|
+
function v(t$1) {
|
|
561
|
+
return "number" == typeof t$1;
|
|
562
|
+
}
|
|
563
|
+
function b(t$1) {
|
|
564
|
+
return "string" == typeof t$1;
|
|
565
|
+
}
|
|
566
|
+
function w(t$1) {
|
|
567
|
+
return "bigint" == typeof t$1;
|
|
568
|
+
}
|
|
569
|
+
const S = u(p(function(t$1) {
|
|
570
|
+
return !0;
|
|
571
|
+
})), O = S, j = (t$1) => Object.assign(u(t$1), {
|
|
572
|
+
startsWith: (e$1) => {
|
|
573
|
+
return j(m(t$1, (n$1 = e$1, p((t$2) => b(t$2) && t$2.startsWith(n$1)))));
|
|
574
|
+
var n$1;
|
|
575
|
+
},
|
|
576
|
+
endsWith: (e$1) => {
|
|
577
|
+
return j(m(t$1, (n$1 = e$1, p((t$2) => b(t$2) && t$2.endsWith(n$1)))));
|
|
578
|
+
var n$1;
|
|
579
|
+
},
|
|
580
|
+
minLength: (e$1) => j(m(t$1, ((t$2) => p((e$2) => b(e$2) && e$2.length >= t$2))(e$1))),
|
|
581
|
+
length: (e$1) => j(m(t$1, ((t$2) => p((e$2) => b(e$2) && e$2.length === t$2))(e$1))),
|
|
582
|
+
maxLength: (e$1) => j(m(t$1, ((t$2) => p((e$2) => b(e$2) && e$2.length <= t$2))(e$1))),
|
|
583
|
+
includes: (e$1) => {
|
|
584
|
+
return j(m(t$1, (n$1 = e$1, p((t$2) => b(t$2) && t$2.includes(n$1)))));
|
|
585
|
+
var n$1;
|
|
586
|
+
},
|
|
587
|
+
regex: (e$1) => {
|
|
588
|
+
return j(m(t$1, (n$1 = e$1, p((t$2) => b(t$2) && Boolean(t$2.match(n$1))))));
|
|
589
|
+
var n$1;
|
|
590
|
+
}
|
|
591
|
+
}), K = j(p(b)), x = (t$1) => Object.assign(u(t$1), {
|
|
592
|
+
between: (e$1, n$1) => x(m(t$1, ((t$2, e$2) => p((n$2) => v(n$2) && t$2 <= n$2 && e$2 >= n$2))(e$1, n$1))),
|
|
593
|
+
lt: (e$1) => x(m(t$1, ((t$2) => p((e$2) => v(e$2) && e$2 < t$2))(e$1))),
|
|
594
|
+
gt: (e$1) => x(m(t$1, ((t$2) => p((e$2) => v(e$2) && e$2 > t$2))(e$1))),
|
|
595
|
+
lte: (e$1) => x(m(t$1, ((t$2) => p((e$2) => v(e$2) && e$2 <= t$2))(e$1))),
|
|
596
|
+
gte: (e$1) => x(m(t$1, ((t$2) => p((e$2) => v(e$2) && e$2 >= t$2))(e$1))),
|
|
597
|
+
int: () => x(m(t$1, p((t$2) => v(t$2) && Number.isInteger(t$2)))),
|
|
598
|
+
finite: () => x(m(t$1, p((t$2) => v(t$2) && Number.isFinite(t$2)))),
|
|
599
|
+
positive: () => x(m(t$1, p((t$2) => v(t$2) && t$2 > 0))),
|
|
600
|
+
negative: () => x(m(t$1, p((t$2) => v(t$2) && t$2 < 0)))
|
|
601
|
+
}), E = x(p(v)), A = (t$1) => Object.assign(u(t$1), {
|
|
602
|
+
between: (e$1, n$1) => A(m(t$1, ((t$2, e$2) => p((n$2) => w(n$2) && t$2 <= n$2 && e$2 >= n$2))(e$1, n$1))),
|
|
603
|
+
lt: (e$1) => A(m(t$1, ((t$2) => p((e$2) => w(e$2) && e$2 < t$2))(e$1))),
|
|
604
|
+
gt: (e$1) => A(m(t$1, ((t$2) => p((e$2) => w(e$2) && e$2 > t$2))(e$1))),
|
|
605
|
+
lte: (e$1) => A(m(t$1, ((t$2) => p((e$2) => w(e$2) && e$2 <= t$2))(e$1))),
|
|
606
|
+
gte: (e$1) => A(m(t$1, ((t$2) => p((e$2) => w(e$2) && e$2 >= t$2))(e$1))),
|
|
607
|
+
positive: () => A(m(t$1, p((t$2) => w(t$2) && t$2 > 0))),
|
|
608
|
+
negative: () => A(m(t$1, p((t$2) => w(t$2) && t$2 < 0)))
|
|
609
|
+
}), P = A(p(w)), T = u(p(function(t$1) {
|
|
610
|
+
return "boolean" == typeof t$1;
|
|
611
|
+
})), B = u(p(function(t$1) {
|
|
612
|
+
return "symbol" == typeof t$1;
|
|
613
|
+
})), _ = u(p(function(t$1) {
|
|
614
|
+
return null == t$1;
|
|
615
|
+
})), k = u(p(function(t$1) {
|
|
616
|
+
return null != t$1;
|
|
617
|
+
}));
|
|
618
|
+
var N = {
|
|
619
|
+
__proto__: null,
|
|
620
|
+
matcher: t,
|
|
621
|
+
optional: h,
|
|
622
|
+
array: function(...e$1) {
|
|
623
|
+
return l({ [t]: () => ({
|
|
624
|
+
match: (t$1) => {
|
|
625
|
+
if (!Array.isArray(t$1)) return { matched: !1 };
|
|
626
|
+
if (0 === e$1.length) return { matched: !0 };
|
|
627
|
+
const n$1 = e$1[0];
|
|
628
|
+
let r$1 = {};
|
|
629
|
+
if (0 === t$1.length) return s(n$1).forEach((t$2) => {
|
|
630
|
+
r$1[t$2] = [];
|
|
631
|
+
}), {
|
|
632
|
+
matched: !0,
|
|
633
|
+
selections: r$1
|
|
634
|
+
};
|
|
635
|
+
const i$1 = (t$2, e$2) => {
|
|
636
|
+
r$1[t$2] = (r$1[t$2] || []).concat([e$2]);
|
|
637
|
+
};
|
|
638
|
+
return {
|
|
639
|
+
matched: t$1.every((t$2) => o(n$1, t$2, i$1)),
|
|
640
|
+
selections: r$1
|
|
641
|
+
};
|
|
642
|
+
},
|
|
643
|
+
getSelectionKeys: () => 0 === e$1.length ? [] : s(e$1[0])
|
|
644
|
+
}) });
|
|
645
|
+
},
|
|
646
|
+
set: function(...e$1) {
|
|
647
|
+
return u({ [t]: () => ({
|
|
648
|
+
match: (t$1) => {
|
|
649
|
+
if (!(t$1 instanceof Set)) return { matched: !1 };
|
|
650
|
+
let n$1 = {};
|
|
651
|
+
if (0 === t$1.size) return {
|
|
652
|
+
matched: !0,
|
|
653
|
+
selections: n$1
|
|
654
|
+
};
|
|
655
|
+
if (0 === e$1.length) return { matched: !0 };
|
|
656
|
+
const r$1 = (t$2, e$2) => {
|
|
657
|
+
n$1[t$2] = (n$1[t$2] || []).concat([e$2]);
|
|
658
|
+
}, i$1 = e$1[0];
|
|
659
|
+
return {
|
|
660
|
+
matched: f(t$1, (t$2) => o(i$1, t$2, r$1)),
|
|
661
|
+
selections: n$1
|
|
662
|
+
};
|
|
663
|
+
},
|
|
664
|
+
getSelectionKeys: () => 0 === e$1.length ? [] : s(e$1[0])
|
|
665
|
+
}) });
|
|
666
|
+
},
|
|
667
|
+
map: function(...e$1) {
|
|
668
|
+
return u({ [t]: () => ({
|
|
669
|
+
match: (t$1) => {
|
|
670
|
+
if (!(t$1 instanceof Map)) return { matched: !1 };
|
|
671
|
+
let n$1 = {};
|
|
672
|
+
if (0 === t$1.size) return {
|
|
673
|
+
matched: !0,
|
|
674
|
+
selections: n$1
|
|
675
|
+
};
|
|
676
|
+
const r$1 = (t$2, e$2) => {
|
|
677
|
+
n$1[t$2] = (n$1[t$2] || []).concat([e$2]);
|
|
678
|
+
};
|
|
679
|
+
if (0 === e$1.length) return { matched: !0 };
|
|
680
|
+
var i$1;
|
|
681
|
+
if (1 === e$1.length) throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null == (i$1 = e$1[0]) ? void 0 : i$1.toString()}`);
|
|
682
|
+
const [s$1, c$1] = e$1;
|
|
683
|
+
return {
|
|
684
|
+
matched: g(t$1, (t$2, e$2) => {
|
|
685
|
+
const n$2 = o(s$1, e$2, r$1), i$2 = o(c$1, t$2, r$1);
|
|
686
|
+
return n$2 && i$2;
|
|
687
|
+
}),
|
|
688
|
+
selections: n$1
|
|
689
|
+
};
|
|
690
|
+
},
|
|
691
|
+
getSelectionKeys: () => 0 === e$1.length ? [] : [...s(e$1[0]), ...s(e$1[1])]
|
|
692
|
+
}) });
|
|
693
|
+
},
|
|
694
|
+
intersection: m,
|
|
695
|
+
union: d,
|
|
696
|
+
not: function(e$1) {
|
|
697
|
+
return u({ [t]: () => ({
|
|
698
|
+
match: (t$1) => ({ matched: !o(e$1, t$1, () => {}) }),
|
|
699
|
+
getSelectionKeys: () => [],
|
|
700
|
+
matcherType: "not"
|
|
701
|
+
}) });
|
|
702
|
+
},
|
|
703
|
+
when: p,
|
|
704
|
+
select: y,
|
|
705
|
+
any: S,
|
|
706
|
+
_: O,
|
|
707
|
+
string: K,
|
|
708
|
+
number: E,
|
|
709
|
+
bigint: P,
|
|
710
|
+
boolean: T,
|
|
711
|
+
symbol: B,
|
|
712
|
+
nullish: _,
|
|
713
|
+
nonNullable: k,
|
|
714
|
+
instanceOf: function(t$1) {
|
|
715
|
+
return u(p(function(t$2) {
|
|
716
|
+
return (e$1) => e$1 instanceof t$2;
|
|
717
|
+
}(t$1)));
|
|
718
|
+
},
|
|
719
|
+
shape: function(t$1) {
|
|
720
|
+
return u(p(a(t$1)));
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
var W = class extends Error {
|
|
724
|
+
constructor(t$1) {
|
|
725
|
+
let e$1;
|
|
726
|
+
try {
|
|
727
|
+
e$1 = JSON.stringify(t$1);
|
|
728
|
+
} catch (n$1) {
|
|
729
|
+
e$1 = t$1;
|
|
730
|
+
}
|
|
731
|
+
super(`Pattern matching error: no pattern matches value ${e$1}`), this.input = void 0, this.input = t$1;
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
const $$1 = {
|
|
735
|
+
matched: !1,
|
|
736
|
+
value: void 0
|
|
737
|
+
};
|
|
738
|
+
function z(t$1) {
|
|
739
|
+
return new I(t$1, $$1);
|
|
740
|
+
}
|
|
741
|
+
var I = class I {
|
|
742
|
+
constructor(t$1, e$1) {
|
|
743
|
+
this.input = void 0, this.state = void 0, this.input = t$1, this.state = e$1;
|
|
744
|
+
}
|
|
745
|
+
with(...t$1) {
|
|
746
|
+
if (this.state.matched) return this;
|
|
747
|
+
const e$1 = t$1[t$1.length - 1], r$1 = [t$1[0]];
|
|
748
|
+
let i$1;
|
|
749
|
+
3 === t$1.length && "function" == typeof t$1[1] ? i$1 = t$1[1] : t$1.length > 2 && r$1.push(...t$1.slice(1, t$1.length - 1));
|
|
750
|
+
let s$1 = !1, c$1 = {};
|
|
751
|
+
const a$1 = (t$2, e$2) => {
|
|
752
|
+
s$1 = !0, c$1[t$2] = e$2;
|
|
753
|
+
}, u$1 = !r$1.some((t$2) => o(t$2, this.input, a$1)) || i$1 && !Boolean(i$1(this.input)) ? $$1 : {
|
|
754
|
+
matched: !0,
|
|
755
|
+
value: e$1(s$1 ? n in c$1 ? c$1[n] : c$1 : this.input, this.input)
|
|
756
|
+
};
|
|
757
|
+
return new I(this.input, u$1);
|
|
758
|
+
}
|
|
759
|
+
when(t$1, e$1) {
|
|
760
|
+
if (this.state.matched) return this;
|
|
761
|
+
const n$1 = Boolean(t$1(this.input));
|
|
762
|
+
return new I(this.input, n$1 ? {
|
|
763
|
+
matched: !0,
|
|
764
|
+
value: e$1(this.input, this.input)
|
|
765
|
+
} : $$1);
|
|
766
|
+
}
|
|
767
|
+
otherwise(t$1) {
|
|
768
|
+
return this.state.matched ? this.state.value : t$1(this.input);
|
|
769
|
+
}
|
|
770
|
+
exhaustive(t$1 = L) {
|
|
771
|
+
return this.state.matched ? this.state.value : t$1(this.input);
|
|
772
|
+
}
|
|
773
|
+
run() {
|
|
774
|
+
return this.exhaustive();
|
|
775
|
+
}
|
|
776
|
+
returnType() {
|
|
777
|
+
return this;
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
function L(t$1) {
|
|
781
|
+
throw new W(t$1);
|
|
782
|
+
}
|
|
783
|
+
const NEVER = Object.freeze({ status: "aborted" });
|
|
784
|
+
function $constructor(name, initializer$2, params) {
|
|
785
|
+
function init(inst, def) {
|
|
786
|
+
var _a;
|
|
787
|
+
Object.defineProperty(inst, "_zod", {
|
|
788
|
+
value: inst._zod ?? {},
|
|
789
|
+
enumerable: false
|
|
790
|
+
});
|
|
791
|
+
(_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
|
|
792
|
+
inst._zod.traits.add(name);
|
|
793
|
+
initializer$2(inst, def);
|
|
794
|
+
for (const k$1 in _$1.prototype) if (!(k$1 in inst)) Object.defineProperty(inst, k$1, { value: _$1.prototype[k$1].bind(inst) });
|
|
795
|
+
inst._zod.constr = _$1;
|
|
796
|
+
inst._zod.def = def;
|
|
797
|
+
}
|
|
798
|
+
const Parent = params?.Parent ?? Object;
|
|
799
|
+
class Definition extends Parent {}
|
|
800
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
801
|
+
function _$1(def) {
|
|
802
|
+
var _a;
|
|
803
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
804
|
+
init(inst, def);
|
|
805
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
806
|
+
for (const fn of inst._zod.deferred) fn();
|
|
807
|
+
return inst;
|
|
808
|
+
}
|
|
809
|
+
Object.defineProperty(_$1, "init", { value: init });
|
|
810
|
+
Object.defineProperty(_$1, Symbol.hasInstance, { value: (inst) => {
|
|
811
|
+
if (params?.Parent && inst instanceof params.Parent) return true;
|
|
812
|
+
return inst?._zod?.traits?.has(name);
|
|
813
|
+
} });
|
|
814
|
+
Object.defineProperty(_$1, "name", { value: name });
|
|
815
|
+
return _$1;
|
|
816
|
+
}
|
|
817
|
+
const $brand = Symbol("zod_brand");
|
|
818
|
+
var $ZodAsyncError = class extends Error {
|
|
819
|
+
constructor() {
|
|
820
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
const globalConfig = {};
|
|
824
|
+
function config(newConfig) {
|
|
825
|
+
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
826
|
+
return globalConfig;
|
|
827
|
+
}
|
|
828
|
+
function getEnumValues(entries) {
|
|
829
|
+
const numericValues = Object.values(entries).filter((v$1) => typeof v$1 === "number");
|
|
830
|
+
const values = Object.entries(entries).filter(([k$1, _$1]) => numericValues.indexOf(+k$1) === -1).map(([_$1, v$1]) => v$1);
|
|
831
|
+
return values;
|
|
832
|
+
}
|
|
833
|
+
function jsonStringifyReplacer(_$1, value) {
|
|
834
|
+
if (typeof value === "bigint") return value.toString();
|
|
835
|
+
return value;
|
|
836
|
+
}
|
|
837
|
+
function cached(getter) {
|
|
838
|
+
const set = false;
|
|
839
|
+
return { get value() {
|
|
840
|
+
{
|
|
841
|
+
const value = getter();
|
|
842
|
+
Object.defineProperty(this, "value", { value });
|
|
843
|
+
return value;
|
|
844
|
+
}
|
|
845
|
+
} };
|
|
846
|
+
}
|
|
847
|
+
function nullish(input) {
|
|
848
|
+
return input === null || input === void 0;
|
|
849
|
+
}
|
|
850
|
+
function cleanRegex(source) {
|
|
851
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
852
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
853
|
+
return source.slice(start, end);
|
|
854
|
+
}
|
|
855
|
+
function defineLazy(object$1, key, getter) {
|
|
856
|
+
const set = false;
|
|
857
|
+
Object.defineProperty(object$1, key, {
|
|
858
|
+
get() {
|
|
859
|
+
{
|
|
860
|
+
const value = getter();
|
|
861
|
+
object$1[key] = value;
|
|
862
|
+
return value;
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
set(v$1) {
|
|
866
|
+
Object.defineProperty(object$1, key, { value: v$1 });
|
|
867
|
+
},
|
|
868
|
+
configurable: true
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
function assignProp(target, prop, value) {
|
|
872
|
+
Object.defineProperty(target, prop, {
|
|
873
|
+
value,
|
|
874
|
+
writable: true,
|
|
875
|
+
enumerable: true,
|
|
876
|
+
configurable: true
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
function mergeDefs(...defs) {
|
|
880
|
+
const mergedDescriptors = {};
|
|
881
|
+
for (const def of defs) {
|
|
882
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
883
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
884
|
+
}
|
|
885
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
886
|
+
}
|
|
887
|
+
function esc(str) {
|
|
888
|
+
return JSON.stringify(str);
|
|
889
|
+
}
|
|
890
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
891
|
+
function isObject(data) {
|
|
892
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
893
|
+
}
|
|
894
|
+
const allowsEval = cached(() => {
|
|
895
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
|
|
896
|
+
try {
|
|
897
|
+
const F = Function;
|
|
898
|
+
new F("");
|
|
899
|
+
return true;
|
|
900
|
+
} catch (_$1) {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
function isPlainObject(o$1) {
|
|
905
|
+
if (isObject(o$1) === false) return false;
|
|
906
|
+
const ctor = o$1.constructor;
|
|
907
|
+
if (ctor === void 0) return true;
|
|
908
|
+
const prot = ctor.prototype;
|
|
909
|
+
if (isObject(prot) === false) return false;
|
|
910
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
911
|
+
return true;
|
|
912
|
+
}
|
|
913
|
+
const propertyKeyTypes = new Set([
|
|
914
|
+
"string",
|
|
915
|
+
"number",
|
|
916
|
+
"symbol"
|
|
917
|
+
]);
|
|
918
|
+
function escapeRegex(str) {
|
|
919
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
920
|
+
}
|
|
921
|
+
function clone(inst, def, params) {
|
|
922
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
923
|
+
if (!def || params?.parent) cl._zod.parent = inst;
|
|
924
|
+
return cl;
|
|
925
|
+
}
|
|
926
|
+
function normalizeParams(_params) {
|
|
927
|
+
const params = _params;
|
|
928
|
+
if (!params) return {};
|
|
929
|
+
if (typeof params === "string") return { error: () => params };
|
|
930
|
+
if (params?.message !== void 0) {
|
|
931
|
+
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
|
|
932
|
+
params.error = params.message;
|
|
933
|
+
}
|
|
934
|
+
delete params.message;
|
|
935
|
+
if (typeof params.error === "string") return {
|
|
936
|
+
...params,
|
|
937
|
+
error: () => params.error
|
|
938
|
+
};
|
|
939
|
+
return params;
|
|
940
|
+
}
|
|
941
|
+
function optionalKeys(shape) {
|
|
942
|
+
return Object.keys(shape).filter((k$1) => {
|
|
943
|
+
return shape[k$1]._zod.optin === "optional" && shape[k$1]._zod.optout === "optional";
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
const NUMBER_FORMAT_RANGES = {
|
|
947
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
948
|
+
int32: [-2147483648, 2147483647],
|
|
949
|
+
uint32: [0, 4294967295],
|
|
950
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
951
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
952
|
+
};
|
|
953
|
+
function pick(schema, mask) {
|
|
954
|
+
const currDef = schema._zod.def;
|
|
955
|
+
const def = mergeDefs(schema._zod.def, {
|
|
956
|
+
get shape() {
|
|
957
|
+
const newShape = {};
|
|
958
|
+
for (const key in mask) {
|
|
959
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
960
|
+
if (!mask[key]) continue;
|
|
961
|
+
newShape[key] = currDef.shape[key];
|
|
962
|
+
}
|
|
963
|
+
assignProp(this, "shape", newShape);
|
|
964
|
+
return newShape;
|
|
965
|
+
},
|
|
966
|
+
checks: []
|
|
967
|
+
});
|
|
968
|
+
return clone(schema, def);
|
|
969
|
+
}
|
|
970
|
+
function omit(schema, mask) {
|
|
971
|
+
const currDef = schema._zod.def;
|
|
972
|
+
const def = mergeDefs(schema._zod.def, {
|
|
973
|
+
get shape() {
|
|
974
|
+
const newShape = { ...schema._zod.def.shape };
|
|
975
|
+
for (const key in mask) {
|
|
976
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
977
|
+
if (!mask[key]) continue;
|
|
978
|
+
delete newShape[key];
|
|
979
|
+
}
|
|
980
|
+
assignProp(this, "shape", newShape);
|
|
981
|
+
return newShape;
|
|
982
|
+
},
|
|
983
|
+
checks: []
|
|
984
|
+
});
|
|
985
|
+
return clone(schema, def);
|
|
986
|
+
}
|
|
987
|
+
function extend(schema, shape) {
|
|
988
|
+
if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
989
|
+
const def = mergeDefs(schema._zod.def, {
|
|
990
|
+
get shape() {
|
|
991
|
+
const _shape = {
|
|
992
|
+
...schema._zod.def.shape,
|
|
993
|
+
...shape
|
|
994
|
+
};
|
|
995
|
+
assignProp(this, "shape", _shape);
|
|
996
|
+
return _shape;
|
|
997
|
+
},
|
|
998
|
+
checks: []
|
|
999
|
+
});
|
|
1000
|
+
return clone(schema, def);
|
|
1001
|
+
}
|
|
1002
|
+
function merge(a$1, b$1) {
|
|
1003
|
+
const def = mergeDefs(a$1._zod.def, {
|
|
1004
|
+
get shape() {
|
|
1005
|
+
const _shape = {
|
|
1006
|
+
...a$1._zod.def.shape,
|
|
1007
|
+
...b$1._zod.def.shape
|
|
1008
|
+
};
|
|
1009
|
+
assignProp(this, "shape", _shape);
|
|
1010
|
+
return _shape;
|
|
1011
|
+
},
|
|
1012
|
+
get catchall() {
|
|
1013
|
+
return b$1._zod.def.catchall;
|
|
1014
|
+
},
|
|
1015
|
+
checks: []
|
|
1016
|
+
});
|
|
1017
|
+
return clone(a$1, def);
|
|
1018
|
+
}
|
|
1019
|
+
function partial(Class, schema, mask) {
|
|
1020
|
+
const def = mergeDefs(schema._zod.def, {
|
|
1021
|
+
get shape() {
|
|
1022
|
+
const oldShape = schema._zod.def.shape;
|
|
1023
|
+
const shape = { ...oldShape };
|
|
1024
|
+
if (mask) for (const key in mask) {
|
|
1025
|
+
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1026
|
+
if (!mask[key]) continue;
|
|
1027
|
+
shape[key] = Class ? new Class({
|
|
1028
|
+
type: "optional",
|
|
1029
|
+
innerType: oldShape[key]
|
|
1030
|
+
}) : oldShape[key];
|
|
1031
|
+
}
|
|
1032
|
+
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
1033
|
+
type: "optional",
|
|
1034
|
+
innerType: oldShape[key]
|
|
1035
|
+
}) : oldShape[key];
|
|
1036
|
+
assignProp(this, "shape", shape);
|
|
1037
|
+
return shape;
|
|
1038
|
+
},
|
|
1039
|
+
checks: []
|
|
1040
|
+
});
|
|
1041
|
+
return clone(schema, def);
|
|
1042
|
+
}
|
|
1043
|
+
function required(Class, schema, mask) {
|
|
1044
|
+
const def = mergeDefs(schema._zod.def, {
|
|
1045
|
+
get shape() {
|
|
1046
|
+
const oldShape = schema._zod.def.shape;
|
|
1047
|
+
const shape = { ...oldShape };
|
|
1048
|
+
if (mask) for (const key in mask) {
|
|
1049
|
+
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
1050
|
+
if (!mask[key]) continue;
|
|
1051
|
+
shape[key] = new Class({
|
|
1052
|
+
type: "nonoptional",
|
|
1053
|
+
innerType: oldShape[key]
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
else for (const key in oldShape) shape[key] = new Class({
|
|
1057
|
+
type: "nonoptional",
|
|
1058
|
+
innerType: oldShape[key]
|
|
1059
|
+
});
|
|
1060
|
+
assignProp(this, "shape", shape);
|
|
1061
|
+
return shape;
|
|
1062
|
+
},
|
|
1063
|
+
checks: []
|
|
1064
|
+
});
|
|
1065
|
+
return clone(schema, def);
|
|
1066
|
+
}
|
|
1067
|
+
function aborted(x$1, startIndex = 0) {
|
|
1068
|
+
for (let i$1 = startIndex; i$1 < x$1.issues.length; i$1++) if (x$1.issues[i$1]?.continue !== true) return true;
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
function prefixIssues(path, issues) {
|
|
1072
|
+
return issues.map((iss) => {
|
|
1073
|
+
var _a;
|
|
1074
|
+
(_a = iss).path ?? (_a.path = []);
|
|
1075
|
+
iss.path.unshift(path);
|
|
1076
|
+
return iss;
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
function unwrapMessage(message) {
|
|
1080
|
+
return typeof message === "string" ? message : message?.message;
|
|
1081
|
+
}
|
|
1082
|
+
function finalizeIssue(iss, ctx, config$1) {
|
|
1083
|
+
const full = {
|
|
1084
|
+
...iss,
|
|
1085
|
+
path: iss.path ?? []
|
|
1086
|
+
};
|
|
1087
|
+
if (!iss.message) {
|
|
1088
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config$1.customError?.(iss)) ?? unwrapMessage(config$1.localeError?.(iss)) ?? "Invalid input";
|
|
1089
|
+
full.message = message;
|
|
1090
|
+
}
|
|
1091
|
+
delete full.inst;
|
|
1092
|
+
delete full.continue;
|
|
1093
|
+
if (!ctx?.reportInput) delete full.input;
|
|
1094
|
+
return full;
|
|
1095
|
+
}
|
|
1096
|
+
function getLengthableOrigin(input) {
|
|
1097
|
+
if (Array.isArray(input)) return "array";
|
|
1098
|
+
if (typeof input === "string") return "string";
|
|
1099
|
+
return "unknown";
|
|
1100
|
+
}
|
|
1101
|
+
function issue(...args) {
|
|
1102
|
+
const [iss, input, inst] = args;
|
|
1103
|
+
if (typeof iss === "string") return {
|
|
1104
|
+
message: iss,
|
|
1105
|
+
code: "custom",
|
|
1106
|
+
input,
|
|
1107
|
+
inst
|
|
1108
|
+
};
|
|
1109
|
+
return { ...iss };
|
|
1110
|
+
}
|
|
1111
|
+
const initializer$1 = (inst, def) => {
|
|
1112
|
+
inst.name = "$ZodError";
|
|
1113
|
+
Object.defineProperty(inst, "_zod", {
|
|
1114
|
+
value: inst._zod,
|
|
1115
|
+
enumerable: false
|
|
1116
|
+
});
|
|
1117
|
+
Object.defineProperty(inst, "issues", {
|
|
1118
|
+
value: def,
|
|
1119
|
+
enumerable: false
|
|
1120
|
+
});
|
|
1121
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
1122
|
+
Object.defineProperty(inst, "toString", {
|
|
1123
|
+
value: () => inst.message,
|
|
1124
|
+
enumerable: false
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
1127
|
+
const $ZodError = $constructor("$ZodError", initializer$1);
|
|
1128
|
+
const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
|
|
1129
|
+
function flattenError(error, mapper = (issue$1) => issue$1.message) {
|
|
1130
|
+
const fieldErrors = {};
|
|
1131
|
+
const formErrors = [];
|
|
1132
|
+
for (const sub of error.issues) if (sub.path.length > 0) {
|
|
1133
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
1134
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
1135
|
+
} else formErrors.push(mapper(sub));
|
|
1136
|
+
return {
|
|
1137
|
+
formErrors,
|
|
1138
|
+
fieldErrors
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
function formatError(error, _mapper) {
|
|
1142
|
+
const mapper = _mapper || function(issue$1) {
|
|
1143
|
+
return issue$1.message;
|
|
1144
|
+
};
|
|
1145
|
+
const fieldErrors = { _errors: [] };
|
|
1146
|
+
const processError = (error$1) => {
|
|
1147
|
+
for (const issue$1 of error$1.issues) if (issue$1.code === "invalid_union" && issue$1.errors.length) issue$1.errors.map((issues) => processError({ issues }));
|
|
1148
|
+
else if (issue$1.code === "invalid_key") processError({ issues: issue$1.issues });
|
|
1149
|
+
else if (issue$1.code === "invalid_element") processError({ issues: issue$1.issues });
|
|
1150
|
+
else if (issue$1.path.length === 0) fieldErrors._errors.push(mapper(issue$1));
|
|
1151
|
+
else {
|
|
1152
|
+
let curr = fieldErrors;
|
|
1153
|
+
let i$1 = 0;
|
|
1154
|
+
while (i$1 < issue$1.path.length) {
|
|
1155
|
+
const el = issue$1.path[i$1];
|
|
1156
|
+
const terminal = i$1 === issue$1.path.length - 1;
|
|
1157
|
+
if (!terminal) curr[el] = curr[el] || { _errors: [] };
|
|
1158
|
+
else {
|
|
1159
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
1160
|
+
curr[el]._errors.push(mapper(issue$1));
|
|
1161
|
+
}
|
|
1162
|
+
curr = curr[el];
|
|
1163
|
+
i$1++;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
processError(error);
|
|
1168
|
+
return fieldErrors;
|
|
1169
|
+
}
|
|
1170
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
1171
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
1172
|
+
const result = schema._zod.run({
|
|
1173
|
+
value,
|
|
1174
|
+
issues: []
|
|
1175
|
+
}, ctx);
|
|
1176
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1177
|
+
if (result.issues.length) {
|
|
1178
|
+
const e$1 = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1179
|
+
captureStackTrace(e$1, _params?.callee);
|
|
1180
|
+
throw e$1;
|
|
1181
|
+
}
|
|
1182
|
+
return result.value;
|
|
1183
|
+
};
|
|
1184
|
+
const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
|
|
1185
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
1186
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1187
|
+
let result = schema._zod.run({
|
|
1188
|
+
value,
|
|
1189
|
+
issues: []
|
|
1190
|
+
}, ctx);
|
|
1191
|
+
if (result instanceof Promise) result = await result;
|
|
1192
|
+
if (result.issues.length) {
|
|
1193
|
+
const e$1 = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
1194
|
+
captureStackTrace(e$1, params?.callee);
|
|
1195
|
+
throw e$1;
|
|
1196
|
+
}
|
|
1197
|
+
return result.value;
|
|
1198
|
+
};
|
|
1199
|
+
const parseAsync$1 = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
1200
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
1201
|
+
const ctx = _ctx ? {
|
|
1202
|
+
..._ctx,
|
|
1203
|
+
async: false
|
|
1204
|
+
} : { async: false };
|
|
1205
|
+
const result = schema._zod.run({
|
|
1206
|
+
value,
|
|
1207
|
+
issues: []
|
|
1208
|
+
}, ctx);
|
|
1209
|
+
if (result instanceof Promise) throw new $ZodAsyncError();
|
|
1210
|
+
return result.issues.length ? {
|
|
1211
|
+
success: false,
|
|
1212
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1213
|
+
} : {
|
|
1214
|
+
success: true,
|
|
1215
|
+
data: result.value
|
|
1216
|
+
};
|
|
1217
|
+
};
|
|
1218
|
+
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
1219
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
1220
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1221
|
+
let result = schema._zod.run({
|
|
1222
|
+
value,
|
|
1223
|
+
issues: []
|
|
1224
|
+
}, ctx);
|
|
1225
|
+
if (result instanceof Promise) result = await result;
|
|
1226
|
+
return result.issues.length ? {
|
|
1227
|
+
success: false,
|
|
1228
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
1229
|
+
} : {
|
|
1230
|
+
success: true,
|
|
1231
|
+
data: result.value
|
|
1232
|
+
};
|
|
1233
|
+
};
|
|
1234
|
+
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
1235
|
+
const cuid = /^[cC][^\s-]{8,}$/;
|
|
1236
|
+
const cuid2 = /^[0-9a-z]+$/;
|
|
1237
|
+
const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
|
|
1238
|
+
const xid = /^[0-9a-vA-V]{20}$/;
|
|
1239
|
+
const ksuid = /^[A-Za-z0-9]{27}$/;
|
|
1240
|
+
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
1241
|
+
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
1242
|
+
const 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})$/;
|
|
1243
|
+
const uuid = (version$1) => {
|
|
1244
|
+
if (!version$1) return /^([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)$/;
|
|
1245
|
+
return /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$1}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
1246
|
+
};
|
|
1247
|
+
const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
|
|
1248
|
+
const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
1249
|
+
function emoji() {
|
|
1250
|
+
return new RegExp(_emoji$1, "u");
|
|
1251
|
+
}
|
|
1252
|
+
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])$/;
|
|
1253
|
+
const ipv6 = /^(([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})$/;
|
|
1254
|
+
const 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])$/;
|
|
1255
|
+
const 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])$/;
|
|
1256
|
+
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
1257
|
+
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
1258
|
+
const hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
|
|
1259
|
+
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
1260
|
+
const 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])))`;
|
|
1261
|
+
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
1262
|
+
function timeSource(args) {
|
|
1263
|
+
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
1264
|
+
const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
1265
|
+
return regex;
|
|
1266
|
+
}
|
|
1267
|
+
function time$1(args) {
|
|
1268
|
+
return /* @__PURE__ */ new RegExp(`^${timeSource(args)}$`);
|
|
1269
|
+
}
|
|
1270
|
+
function datetime$1(args) {
|
|
1271
|
+
const time$2 = timeSource({ precision: args.precision });
|
|
1272
|
+
const opts = ["Z"];
|
|
1273
|
+
if (args.local) opts.push("");
|
|
1274
|
+
if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
|
|
1275
|
+
const timeRegex = `${time$2}(?:${opts.join("|")})`;
|
|
1276
|
+
return /* @__PURE__ */ new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1277
|
+
}
|
|
1278
|
+
const string$1 = (params) => {
|
|
1279
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
1280
|
+
return /* @__PURE__ */ new RegExp(`^${regex}$`);
|
|
1281
|
+
};
|
|
1282
|
+
const lowercase = /^[^A-Z]*$/;
|
|
1283
|
+
const uppercase = /^[^a-z]*$/;
|
|
1284
|
+
const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
|
|
1285
|
+
var _a;
|
|
1286
|
+
inst._zod ?? (inst._zod = {});
|
|
1287
|
+
inst._zod.def = def;
|
|
1288
|
+
(_a = inst._zod).onattach ?? (_a.onattach = []);
|
|
1289
|
+
});
|
|
1290
|
+
const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
|
|
1291
|
+
var _a;
|
|
1292
|
+
$ZodCheck.init(inst, def);
|
|
1293
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1294
|
+
const val = payload.value;
|
|
1295
|
+
return !nullish(val) && val.length !== void 0;
|
|
1296
|
+
});
|
|
1297
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1298
|
+
const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
1299
|
+
if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
|
|
1300
|
+
});
|
|
1301
|
+
inst._zod.check = (payload) => {
|
|
1302
|
+
const input = payload.value;
|
|
1303
|
+
const length = input.length;
|
|
1304
|
+
if (length <= def.maximum) return;
|
|
1305
|
+
const origin = getLengthableOrigin(input);
|
|
1306
|
+
payload.issues.push({
|
|
1307
|
+
origin,
|
|
1308
|
+
code: "too_big",
|
|
1309
|
+
maximum: def.maximum,
|
|
1310
|
+
inclusive: true,
|
|
1311
|
+
input,
|
|
1312
|
+
inst,
|
|
1313
|
+
continue: !def.abort
|
|
1314
|
+
});
|
|
1315
|
+
};
|
|
1316
|
+
});
|
|
1317
|
+
const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
|
|
1318
|
+
var _a;
|
|
1319
|
+
$ZodCheck.init(inst, def);
|
|
1320
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1321
|
+
const val = payload.value;
|
|
1322
|
+
return !nullish(val) && val.length !== void 0;
|
|
1323
|
+
});
|
|
1324
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1325
|
+
const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
1326
|
+
if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
|
|
1327
|
+
});
|
|
1328
|
+
inst._zod.check = (payload) => {
|
|
1329
|
+
const input = payload.value;
|
|
1330
|
+
const length = input.length;
|
|
1331
|
+
if (length >= def.minimum) return;
|
|
1332
|
+
const origin = getLengthableOrigin(input);
|
|
1333
|
+
payload.issues.push({
|
|
1334
|
+
origin,
|
|
1335
|
+
code: "too_small",
|
|
1336
|
+
minimum: def.minimum,
|
|
1337
|
+
inclusive: true,
|
|
1338
|
+
input,
|
|
1339
|
+
inst,
|
|
1340
|
+
continue: !def.abort
|
|
1341
|
+
});
|
|
1342
|
+
};
|
|
1343
|
+
});
|
|
1344
|
+
const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
|
|
1345
|
+
var _a;
|
|
1346
|
+
$ZodCheck.init(inst, def);
|
|
1347
|
+
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
|
|
1348
|
+
const val = payload.value;
|
|
1349
|
+
return !nullish(val) && val.length !== void 0;
|
|
1350
|
+
});
|
|
1351
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1352
|
+
const bag = inst$1._zod.bag;
|
|
1353
|
+
bag.minimum = def.length;
|
|
1354
|
+
bag.maximum = def.length;
|
|
1355
|
+
bag.length = def.length;
|
|
1356
|
+
});
|
|
1357
|
+
inst._zod.check = (payload) => {
|
|
1358
|
+
const input = payload.value;
|
|
1359
|
+
const length = input.length;
|
|
1360
|
+
if (length === def.length) return;
|
|
1361
|
+
const origin = getLengthableOrigin(input);
|
|
1362
|
+
const tooBig = length > def.length;
|
|
1363
|
+
payload.issues.push({
|
|
1364
|
+
origin,
|
|
1365
|
+
...tooBig ? {
|
|
1366
|
+
code: "too_big",
|
|
1367
|
+
maximum: def.length
|
|
1368
|
+
} : {
|
|
1369
|
+
code: "too_small",
|
|
1370
|
+
minimum: def.length
|
|
1371
|
+
},
|
|
1372
|
+
inclusive: true,
|
|
1373
|
+
exact: true,
|
|
1374
|
+
input: payload.value,
|
|
1375
|
+
inst,
|
|
1376
|
+
continue: !def.abort
|
|
1377
|
+
});
|
|
1378
|
+
};
|
|
1379
|
+
});
|
|
1380
|
+
const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
|
|
1381
|
+
var _a, _b;
|
|
1382
|
+
$ZodCheck.init(inst, def);
|
|
1383
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1384
|
+
const bag = inst$1._zod.bag;
|
|
1385
|
+
bag.format = def.format;
|
|
1386
|
+
if (def.pattern) {
|
|
1387
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1388
|
+
bag.patterns.add(def.pattern);
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1391
|
+
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
|
|
1392
|
+
def.pattern.lastIndex = 0;
|
|
1393
|
+
if (def.pattern.test(payload.value)) return;
|
|
1394
|
+
payload.issues.push({
|
|
1395
|
+
origin: "string",
|
|
1396
|
+
code: "invalid_format",
|
|
1397
|
+
format: def.format,
|
|
1398
|
+
input: payload.value,
|
|
1399
|
+
...def.pattern ? { pattern: def.pattern.toString() } : {},
|
|
1400
|
+
inst,
|
|
1401
|
+
continue: !def.abort
|
|
1402
|
+
});
|
|
1403
|
+
});
|
|
1404
|
+
else (_b = inst._zod).check ?? (_b.check = () => {});
|
|
1405
|
+
});
|
|
1406
|
+
const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
|
|
1407
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1408
|
+
inst._zod.check = (payload) => {
|
|
1409
|
+
def.pattern.lastIndex = 0;
|
|
1410
|
+
if (def.pattern.test(payload.value)) return;
|
|
1411
|
+
payload.issues.push({
|
|
1412
|
+
origin: "string",
|
|
1413
|
+
code: "invalid_format",
|
|
1414
|
+
format: "regex",
|
|
1415
|
+
input: payload.value,
|
|
1416
|
+
pattern: def.pattern.toString(),
|
|
1417
|
+
inst,
|
|
1418
|
+
continue: !def.abort
|
|
1419
|
+
});
|
|
1420
|
+
};
|
|
1421
|
+
});
|
|
1422
|
+
const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
|
|
1423
|
+
def.pattern ?? (def.pattern = lowercase);
|
|
1424
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1425
|
+
});
|
|
1426
|
+
const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
|
|
1427
|
+
def.pattern ?? (def.pattern = uppercase);
|
|
1428
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1429
|
+
});
|
|
1430
|
+
const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
|
|
1431
|
+
$ZodCheck.init(inst, def);
|
|
1432
|
+
const escapedRegex = escapeRegex(def.includes);
|
|
1433
|
+
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
|
|
1434
|
+
def.pattern = pattern;
|
|
1435
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1436
|
+
const bag = inst$1._zod.bag;
|
|
1437
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1438
|
+
bag.patterns.add(pattern);
|
|
1439
|
+
});
|
|
1440
|
+
inst._zod.check = (payload) => {
|
|
1441
|
+
if (payload.value.includes(def.includes, def.position)) return;
|
|
1442
|
+
payload.issues.push({
|
|
1443
|
+
origin: "string",
|
|
1444
|
+
code: "invalid_format",
|
|
1445
|
+
format: "includes",
|
|
1446
|
+
includes: def.includes,
|
|
1447
|
+
input: payload.value,
|
|
1448
|
+
inst,
|
|
1449
|
+
continue: !def.abort
|
|
1450
|
+
});
|
|
1451
|
+
};
|
|
1452
|
+
});
|
|
1453
|
+
const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
|
|
1454
|
+
$ZodCheck.init(inst, def);
|
|
1455
|
+
const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex(def.prefix)}.*`);
|
|
1456
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1457
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1458
|
+
const bag = inst$1._zod.bag;
|
|
1459
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1460
|
+
bag.patterns.add(pattern);
|
|
1461
|
+
});
|
|
1462
|
+
inst._zod.check = (payload) => {
|
|
1463
|
+
if (payload.value.startsWith(def.prefix)) return;
|
|
1464
|
+
payload.issues.push({
|
|
1465
|
+
origin: "string",
|
|
1466
|
+
code: "invalid_format",
|
|
1467
|
+
format: "starts_with",
|
|
1468
|
+
prefix: def.prefix,
|
|
1469
|
+
input: payload.value,
|
|
1470
|
+
inst,
|
|
1471
|
+
continue: !def.abort
|
|
1472
|
+
});
|
|
1473
|
+
};
|
|
1474
|
+
});
|
|
1475
|
+
const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
|
|
1476
|
+
$ZodCheck.init(inst, def);
|
|
1477
|
+
const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex(def.suffix)}$`);
|
|
1478
|
+
def.pattern ?? (def.pattern = pattern);
|
|
1479
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1480
|
+
const bag = inst$1._zod.bag;
|
|
1481
|
+
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
|
|
1482
|
+
bag.patterns.add(pattern);
|
|
1483
|
+
});
|
|
1484
|
+
inst._zod.check = (payload) => {
|
|
1485
|
+
if (payload.value.endsWith(def.suffix)) return;
|
|
1486
|
+
payload.issues.push({
|
|
1487
|
+
origin: "string",
|
|
1488
|
+
code: "invalid_format",
|
|
1489
|
+
format: "ends_with",
|
|
1490
|
+
suffix: def.suffix,
|
|
1491
|
+
input: payload.value,
|
|
1492
|
+
inst,
|
|
1493
|
+
continue: !def.abort
|
|
1494
|
+
});
|
|
1495
|
+
};
|
|
1496
|
+
});
|
|
1497
|
+
const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
|
|
1498
|
+
$ZodCheck.init(inst, def);
|
|
1499
|
+
inst._zod.check = (payload) => {
|
|
1500
|
+
payload.value = def.tx(payload.value);
|
|
1501
|
+
};
|
|
1502
|
+
});
|
|
1503
|
+
var Doc = class {
|
|
1504
|
+
constructor(args = []) {
|
|
1505
|
+
this.content = [];
|
|
1506
|
+
this.indent = 0;
|
|
1507
|
+
if (this) this.args = args;
|
|
1508
|
+
}
|
|
1509
|
+
indented(fn) {
|
|
1510
|
+
this.indent += 1;
|
|
1511
|
+
fn(this);
|
|
1512
|
+
this.indent -= 1;
|
|
1513
|
+
}
|
|
1514
|
+
write(arg) {
|
|
1515
|
+
if (typeof arg === "function") {
|
|
1516
|
+
arg(this, { execution: "sync" });
|
|
1517
|
+
arg(this, { execution: "async" });
|
|
1518
|
+
return;
|
|
1519
|
+
}
|
|
1520
|
+
const content = arg;
|
|
1521
|
+
const lines = content.split("\n").filter((x$1) => x$1);
|
|
1522
|
+
const minIndent = Math.min(...lines.map((x$1) => x$1.length - x$1.trimStart().length));
|
|
1523
|
+
const dedented = lines.map((x$1) => x$1.slice(minIndent)).map((x$1) => " ".repeat(this.indent * 2) + x$1);
|
|
1524
|
+
for (const line of dedented) this.content.push(line);
|
|
1525
|
+
}
|
|
1526
|
+
compile() {
|
|
1527
|
+
const F = Function;
|
|
1528
|
+
const args = this?.args;
|
|
1529
|
+
const content = this?.content ?? [``];
|
|
1530
|
+
const lines = [...content.map((x$1) => ` ${x$1}`)];
|
|
1531
|
+
return new F(...args, lines.join("\n"));
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
const version = {
|
|
1535
|
+
major: 4,
|
|
1536
|
+
minor: 0,
|
|
1537
|
+
patch: 10
|
|
1538
|
+
};
|
|
1539
|
+
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
1540
|
+
var _a;
|
|
1541
|
+
inst ?? (inst = {});
|
|
1542
|
+
inst._zod.def = def;
|
|
1543
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
1544
|
+
inst._zod.version = version;
|
|
1545
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
1546
|
+
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
|
|
1547
|
+
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
|
|
1548
|
+
if (checks.length === 0) {
|
|
1549
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
1550
|
+
inst._zod.deferred?.push(() => {
|
|
1551
|
+
inst._zod.run = inst._zod.parse;
|
|
1552
|
+
});
|
|
1553
|
+
} else {
|
|
1554
|
+
const runChecks = (payload, checks$1, ctx) => {
|
|
1555
|
+
let isAborted = aborted(payload);
|
|
1556
|
+
let asyncResult;
|
|
1557
|
+
for (const ch of checks$1) {
|
|
1558
|
+
if (ch._zod.def.when) {
|
|
1559
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
1560
|
+
if (!shouldRun) continue;
|
|
1561
|
+
} else if (isAborted) continue;
|
|
1562
|
+
const currLen = payload.issues.length;
|
|
1563
|
+
const _$1 = ch._zod.check(payload);
|
|
1564
|
+
if (_$1 instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
|
|
1565
|
+
if (asyncResult || _$1 instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
1566
|
+
await _$1;
|
|
1567
|
+
const nextLen = payload.issues.length;
|
|
1568
|
+
if (nextLen === currLen) return;
|
|
1569
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1570
|
+
});
|
|
1571
|
+
else {
|
|
1572
|
+
const nextLen = payload.issues.length;
|
|
1573
|
+
if (nextLen === currLen) continue;
|
|
1574
|
+
if (!isAborted) isAborted = aborted(payload, currLen);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (asyncResult) return asyncResult.then(() => {
|
|
1578
|
+
return payload;
|
|
1579
|
+
});
|
|
1580
|
+
return payload;
|
|
1581
|
+
};
|
|
1582
|
+
inst._zod.run = (payload, ctx) => {
|
|
1583
|
+
const result = inst._zod.parse(payload, ctx);
|
|
1584
|
+
if (result instanceof Promise) {
|
|
1585
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
1586
|
+
return result.then((result$1) => runChecks(result$1, checks, ctx));
|
|
1587
|
+
}
|
|
1588
|
+
return runChecks(result, checks, ctx);
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
inst["~standard"] = {
|
|
1592
|
+
validate: (value) => {
|
|
1593
|
+
try {
|
|
1594
|
+
const r$1 = safeParse$1(inst, value);
|
|
1595
|
+
return r$1.success ? { value: r$1.data } : { issues: r$1.error?.issues };
|
|
1596
|
+
} catch (_$1) {
|
|
1597
|
+
return safeParseAsync$1(inst, value).then((r$1) => r$1.success ? { value: r$1.data } : { issues: r$1.error?.issues });
|
|
1598
|
+
}
|
|
1599
|
+
},
|
|
1600
|
+
vendor: "zod",
|
|
1601
|
+
version: 1
|
|
1602
|
+
};
|
|
1603
|
+
});
|
|
1604
|
+
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
1605
|
+
$ZodType.init(inst, def);
|
|
1606
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
1607
|
+
inst._zod.parse = (payload, _$1) => {
|
|
1608
|
+
if (def.coerce) try {
|
|
1609
|
+
payload.value = String(payload.value);
|
|
1610
|
+
} catch (_$2) {}
|
|
1611
|
+
if (typeof payload.value === "string") return payload;
|
|
1612
|
+
payload.issues.push({
|
|
1613
|
+
expected: "string",
|
|
1614
|
+
code: "invalid_type",
|
|
1615
|
+
input: payload.value,
|
|
1616
|
+
inst
|
|
1617
|
+
});
|
|
1618
|
+
return payload;
|
|
1619
|
+
};
|
|
1620
|
+
});
|
|
1621
|
+
const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
|
|
1622
|
+
$ZodCheckStringFormat.init(inst, def);
|
|
1623
|
+
$ZodString.init(inst, def);
|
|
1624
|
+
});
|
|
1625
|
+
const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
|
|
1626
|
+
def.pattern ?? (def.pattern = guid);
|
|
1627
|
+
$ZodStringFormat.init(inst, def);
|
|
1628
|
+
});
|
|
1629
|
+
const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
|
|
1630
|
+
if (def.version) {
|
|
1631
|
+
const versionMap = {
|
|
1632
|
+
v1: 1,
|
|
1633
|
+
v2: 2,
|
|
1634
|
+
v3: 3,
|
|
1635
|
+
v4: 4,
|
|
1636
|
+
v5: 5,
|
|
1637
|
+
v6: 6,
|
|
1638
|
+
v7: 7,
|
|
1639
|
+
v8: 8
|
|
1640
|
+
};
|
|
1641
|
+
const v$1 = versionMap[def.version];
|
|
1642
|
+
if (v$1 === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
1643
|
+
def.pattern ?? (def.pattern = uuid(v$1));
|
|
1644
|
+
} else def.pattern ?? (def.pattern = uuid());
|
|
1645
|
+
$ZodStringFormat.init(inst, def);
|
|
1646
|
+
});
|
|
1647
|
+
const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
1648
|
+
def.pattern ?? (def.pattern = email);
|
|
1649
|
+
$ZodStringFormat.init(inst, def);
|
|
1650
|
+
});
|
|
1651
|
+
const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
1652
|
+
$ZodStringFormat.init(inst, def);
|
|
1653
|
+
inst._zod.check = (payload) => {
|
|
1654
|
+
try {
|
|
1655
|
+
const trimmed = payload.value.trim();
|
|
1656
|
+
const url = new URL(trimmed);
|
|
1657
|
+
if (def.hostname) {
|
|
1658
|
+
def.hostname.lastIndex = 0;
|
|
1659
|
+
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
1660
|
+
code: "invalid_format",
|
|
1661
|
+
format: "url",
|
|
1662
|
+
note: "Invalid hostname",
|
|
1663
|
+
pattern: hostname.source,
|
|
1664
|
+
input: payload.value,
|
|
1665
|
+
inst,
|
|
1666
|
+
continue: !def.abort
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
if (def.protocol) {
|
|
1670
|
+
def.protocol.lastIndex = 0;
|
|
1671
|
+
if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
|
|
1672
|
+
code: "invalid_format",
|
|
1673
|
+
format: "url",
|
|
1674
|
+
note: "Invalid protocol",
|
|
1675
|
+
pattern: def.protocol.source,
|
|
1676
|
+
input: payload.value,
|
|
1677
|
+
inst,
|
|
1678
|
+
continue: !def.abort
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
if (def.normalize) payload.value = url.href;
|
|
1682
|
+
else payload.value = trimmed;
|
|
1683
|
+
return;
|
|
1684
|
+
} catch (_$1) {
|
|
1685
|
+
payload.issues.push({
|
|
1686
|
+
code: "invalid_format",
|
|
1687
|
+
format: "url",
|
|
1688
|
+
input: payload.value,
|
|
1689
|
+
inst,
|
|
1690
|
+
continue: !def.abort
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
});
|
|
1695
|
+
const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
|
|
1696
|
+
def.pattern ?? (def.pattern = emoji());
|
|
1697
|
+
$ZodStringFormat.init(inst, def);
|
|
1698
|
+
});
|
|
1699
|
+
const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
|
|
1700
|
+
def.pattern ?? (def.pattern = nanoid);
|
|
1701
|
+
$ZodStringFormat.init(inst, def);
|
|
1702
|
+
});
|
|
1703
|
+
const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
|
|
1704
|
+
def.pattern ?? (def.pattern = cuid);
|
|
1705
|
+
$ZodStringFormat.init(inst, def);
|
|
1706
|
+
});
|
|
1707
|
+
const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
|
|
1708
|
+
def.pattern ?? (def.pattern = cuid2);
|
|
1709
|
+
$ZodStringFormat.init(inst, def);
|
|
1710
|
+
});
|
|
1711
|
+
const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
|
|
1712
|
+
def.pattern ?? (def.pattern = ulid);
|
|
1713
|
+
$ZodStringFormat.init(inst, def);
|
|
1714
|
+
});
|
|
1715
|
+
const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
|
|
1716
|
+
def.pattern ?? (def.pattern = xid);
|
|
1717
|
+
$ZodStringFormat.init(inst, def);
|
|
1718
|
+
});
|
|
1719
|
+
const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
1720
|
+
def.pattern ?? (def.pattern = ksuid);
|
|
1721
|
+
$ZodStringFormat.init(inst, def);
|
|
1722
|
+
});
|
|
1723
|
+
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
1724
|
+
def.pattern ?? (def.pattern = datetime$1(def));
|
|
1725
|
+
$ZodStringFormat.init(inst, def);
|
|
1726
|
+
});
|
|
1727
|
+
const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
|
|
1728
|
+
def.pattern ?? (def.pattern = date$1);
|
|
1729
|
+
$ZodStringFormat.init(inst, def);
|
|
1730
|
+
});
|
|
1731
|
+
const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
|
|
1732
|
+
def.pattern ?? (def.pattern = time$1(def));
|
|
1733
|
+
$ZodStringFormat.init(inst, def);
|
|
1734
|
+
});
|
|
1735
|
+
const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
|
|
1736
|
+
def.pattern ?? (def.pattern = duration$1);
|
|
1737
|
+
$ZodStringFormat.init(inst, def);
|
|
1738
|
+
});
|
|
1739
|
+
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
1740
|
+
def.pattern ?? (def.pattern = ipv4);
|
|
1741
|
+
$ZodStringFormat.init(inst, def);
|
|
1742
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1743
|
+
const bag = inst$1._zod.bag;
|
|
1744
|
+
bag.format = `ipv4`;
|
|
1745
|
+
});
|
|
1746
|
+
});
|
|
1747
|
+
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
1748
|
+
def.pattern ?? (def.pattern = ipv6);
|
|
1749
|
+
$ZodStringFormat.init(inst, def);
|
|
1750
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1751
|
+
const bag = inst$1._zod.bag;
|
|
1752
|
+
bag.format = `ipv6`;
|
|
1753
|
+
});
|
|
1754
|
+
inst._zod.check = (payload) => {
|
|
1755
|
+
try {
|
|
1756
|
+
new URL(`http://[${payload.value}]`);
|
|
1757
|
+
} catch {
|
|
1758
|
+
payload.issues.push({
|
|
1759
|
+
code: "invalid_format",
|
|
1760
|
+
format: "ipv6",
|
|
1761
|
+
input: payload.value,
|
|
1762
|
+
inst,
|
|
1763
|
+
continue: !def.abort
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
});
|
|
1768
|
+
const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
|
|
1769
|
+
def.pattern ?? (def.pattern = cidrv4);
|
|
1770
|
+
$ZodStringFormat.init(inst, def);
|
|
1771
|
+
});
|
|
1772
|
+
const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
1773
|
+
def.pattern ?? (def.pattern = cidrv6);
|
|
1774
|
+
$ZodStringFormat.init(inst, def);
|
|
1775
|
+
inst._zod.check = (payload) => {
|
|
1776
|
+
const [address, prefix] = payload.value.split("/");
|
|
1777
|
+
try {
|
|
1778
|
+
if (!prefix) throw new Error();
|
|
1779
|
+
const prefixNum = Number(prefix);
|
|
1780
|
+
if (`${prefixNum}` !== prefix) throw new Error();
|
|
1781
|
+
if (prefixNum < 0 || prefixNum > 128) throw new Error();
|
|
1782
|
+
new URL(`http://[${address}]`);
|
|
1783
|
+
} catch {
|
|
1784
|
+
payload.issues.push({
|
|
1785
|
+
code: "invalid_format",
|
|
1786
|
+
format: "cidrv6",
|
|
1787
|
+
input: payload.value,
|
|
1788
|
+
inst,
|
|
1789
|
+
continue: !def.abort
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
});
|
|
1794
|
+
function isValidBase64(data) {
|
|
1795
|
+
if (data === "") return true;
|
|
1796
|
+
if (data.length % 4 !== 0) return false;
|
|
1797
|
+
try {
|
|
1798
|
+
atob(data);
|
|
1799
|
+
return true;
|
|
1800
|
+
} catch {
|
|
1801
|
+
return false;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
1805
|
+
def.pattern ?? (def.pattern = base64);
|
|
1806
|
+
$ZodStringFormat.init(inst, def);
|
|
1807
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1808
|
+
inst$1._zod.bag.contentEncoding = "base64";
|
|
1809
|
+
});
|
|
1810
|
+
inst._zod.check = (payload) => {
|
|
1811
|
+
if (isValidBase64(payload.value)) return;
|
|
1812
|
+
payload.issues.push({
|
|
1813
|
+
code: "invalid_format",
|
|
1814
|
+
format: "base64",
|
|
1815
|
+
input: payload.value,
|
|
1816
|
+
inst,
|
|
1817
|
+
continue: !def.abort
|
|
1818
|
+
});
|
|
1819
|
+
};
|
|
1820
|
+
});
|
|
1821
|
+
function isValidBase64URL(data) {
|
|
1822
|
+
if (!base64url.test(data)) return false;
|
|
1823
|
+
const base64$1 = data.replace(/[-_]/g, (c$1) => c$1 === "-" ? "+" : "/");
|
|
1824
|
+
const padded = base64$1.padEnd(Math.ceil(base64$1.length / 4) * 4, "=");
|
|
1825
|
+
return isValidBase64(padded);
|
|
1826
|
+
}
|
|
1827
|
+
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
1828
|
+
def.pattern ?? (def.pattern = base64url);
|
|
1829
|
+
$ZodStringFormat.init(inst, def);
|
|
1830
|
+
inst._zod.onattach.push((inst$1) => {
|
|
1831
|
+
inst$1._zod.bag.contentEncoding = "base64url";
|
|
1832
|
+
});
|
|
1833
|
+
inst._zod.check = (payload) => {
|
|
1834
|
+
if (isValidBase64URL(payload.value)) return;
|
|
1835
|
+
payload.issues.push({
|
|
1836
|
+
code: "invalid_format",
|
|
1837
|
+
format: "base64url",
|
|
1838
|
+
input: payload.value,
|
|
1839
|
+
inst,
|
|
1840
|
+
continue: !def.abort
|
|
1841
|
+
});
|
|
1842
|
+
};
|
|
1843
|
+
});
|
|
1844
|
+
const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
|
|
1845
|
+
def.pattern ?? (def.pattern = e164);
|
|
1846
|
+
$ZodStringFormat.init(inst, def);
|
|
1847
|
+
});
|
|
1848
|
+
function isValidJWT(token, algorithm = null) {
|
|
1849
|
+
try {
|
|
1850
|
+
const tokensParts = token.split(".");
|
|
1851
|
+
if (tokensParts.length !== 3) return false;
|
|
1852
|
+
const [header] = tokensParts;
|
|
1853
|
+
if (!header) return false;
|
|
1854
|
+
const parsedHeader = JSON.parse(atob(header));
|
|
1855
|
+
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
|
|
1856
|
+
if (!parsedHeader.alg) return false;
|
|
1857
|
+
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
|
|
1858
|
+
return true;
|
|
1859
|
+
} catch {
|
|
1860
|
+
return false;
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
|
|
1864
|
+
$ZodStringFormat.init(inst, def);
|
|
1865
|
+
inst._zod.check = (payload) => {
|
|
1866
|
+
if (isValidJWT(payload.value, def.alg)) return;
|
|
1867
|
+
payload.issues.push({
|
|
1868
|
+
code: "invalid_format",
|
|
1869
|
+
format: "jwt",
|
|
1870
|
+
input: payload.value,
|
|
1871
|
+
inst,
|
|
1872
|
+
continue: !def.abort
|
|
1873
|
+
});
|
|
1874
|
+
};
|
|
1875
|
+
});
|
|
1876
|
+
const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
|
|
1877
|
+
$ZodType.init(inst, def);
|
|
1878
|
+
inst._zod.parse = (payload) => payload;
|
|
1879
|
+
});
|
|
1880
|
+
const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
|
|
1881
|
+
$ZodType.init(inst, def);
|
|
1882
|
+
inst._zod.parse = (payload) => payload;
|
|
1883
|
+
});
|
|
1884
|
+
const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
|
|
1885
|
+
$ZodType.init(inst, def);
|
|
1886
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
1887
|
+
payload.issues.push({
|
|
1888
|
+
expected: "never",
|
|
1889
|
+
code: "invalid_type",
|
|
1890
|
+
input: payload.value,
|
|
1891
|
+
inst
|
|
1892
|
+
});
|
|
1893
|
+
return payload;
|
|
1894
|
+
};
|
|
1895
|
+
});
|
|
1896
|
+
function handleArrayResult(result, final, index) {
|
|
1897
|
+
if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
|
|
1898
|
+
final.value[index] = result.value;
|
|
1899
|
+
}
|
|
1900
|
+
const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
1901
|
+
$ZodType.init(inst, def);
|
|
1902
|
+
inst._zod.parse = (payload, ctx) => {
|
|
1903
|
+
const input = payload.value;
|
|
1904
|
+
if (!Array.isArray(input)) {
|
|
1905
|
+
payload.issues.push({
|
|
1906
|
+
expected: "array",
|
|
1907
|
+
code: "invalid_type",
|
|
1908
|
+
input,
|
|
1909
|
+
inst
|
|
1910
|
+
});
|
|
1911
|
+
return payload;
|
|
1912
|
+
}
|
|
1913
|
+
payload.value = Array(input.length);
|
|
1914
|
+
const proms = [];
|
|
1915
|
+
for (let i$1 = 0; i$1 < input.length; i$1++) {
|
|
1916
|
+
const item = input[i$1];
|
|
1917
|
+
const result = def.element._zod.run({
|
|
1918
|
+
value: item,
|
|
1919
|
+
issues: []
|
|
1920
|
+
}, ctx);
|
|
1921
|
+
if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult(result$1, payload, i$1)));
|
|
1922
|
+
else handleArrayResult(result, payload, i$1);
|
|
1923
|
+
}
|
|
1924
|
+
if (proms.length) return Promise.all(proms).then(() => payload);
|
|
1925
|
+
return payload;
|
|
1926
|
+
};
|
|
1927
|
+
});
|
|
1928
|
+
function handlePropertyResult(result, final, key, input) {
|
|
1929
|
+
if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
|
|
1930
|
+
if (result.value === void 0) {
|
|
1931
|
+
if (key in input) final.value[key] = void 0;
|
|
1932
|
+
} else final.value[key] = result.value;
|
|
1933
|
+
}
|
|
1934
|
+
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
1935
|
+
$ZodType.init(inst, def);
|
|
1936
|
+
const _normalized = cached(() => {
|
|
1937
|
+
const keys = Object.keys(def.shape);
|
|
1938
|
+
for (const k$1 of keys) if (!(def.shape[k$1] instanceof $ZodType)) throw new Error(`Invalid element at key "${k$1}": expected a Zod schema`);
|
|
1939
|
+
const okeys = optionalKeys(def.shape);
|
|
1940
|
+
return {
|
|
1941
|
+
shape: def.shape,
|
|
1942
|
+
keys,
|
|
1943
|
+
keySet: new Set(keys),
|
|
1944
|
+
numKeys: keys.length,
|
|
1945
|
+
optionalKeys: new Set(okeys)
|
|
1946
|
+
};
|
|
1947
|
+
});
|
|
1948
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
1949
|
+
const shape = def.shape;
|
|
1950
|
+
const propValues = {};
|
|
1951
|
+
for (const key in shape) {
|
|
1952
|
+
const field = shape[key]._zod;
|
|
1953
|
+
if (field.values) {
|
|
1954
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
1955
|
+
for (const v$1 of field.values) propValues[key].add(v$1);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
return propValues;
|
|
1959
|
+
});
|
|
1960
|
+
const generateFastpass = (shape) => {
|
|
1961
|
+
const doc = new Doc([
|
|
1962
|
+
"shape",
|
|
1963
|
+
"payload",
|
|
1964
|
+
"ctx"
|
|
1965
|
+
]);
|
|
1966
|
+
const normalized = _normalized.value;
|
|
1967
|
+
const parseStr = (key) => {
|
|
1968
|
+
const k$1 = esc(key);
|
|
1969
|
+
return `shape[${k$1}]._zod.run({ value: input[${k$1}], issues: [] }, ctx)`;
|
|
1970
|
+
};
|
|
1971
|
+
doc.write(`const input = payload.value;`);
|
|
1972
|
+
const ids = Object.create(null);
|
|
1973
|
+
let counter = 0;
|
|
1974
|
+
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
1975
|
+
doc.write(`const newResult = {}`);
|
|
1976
|
+
for (const key of normalized.keys) {
|
|
1977
|
+
const id = ids[key];
|
|
1978
|
+
const k$1 = esc(key);
|
|
1979
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
1980
|
+
doc.write(`
|
|
1981
|
+
if (${id}.issues.length) {
|
|
1982
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
1983
|
+
...iss,
|
|
1984
|
+
path: iss.path ? [${k$1}, ...iss.path] : [${k$1}]
|
|
1985
|
+
})));
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
if (${id}.value === undefined) {
|
|
1989
|
+
if (${k$1} in input) {
|
|
1990
|
+
newResult[${k$1}] = undefined;
|
|
1991
|
+
}
|
|
1992
|
+
} else {
|
|
1993
|
+
newResult[${k$1}] = ${id}.value;
|
|
1994
|
+
}
|
|
1995
|
+
`);
|
|
1996
|
+
}
|
|
1997
|
+
doc.write(`payload.value = newResult;`);
|
|
1998
|
+
doc.write(`return payload;`);
|
|
1999
|
+
const fn = doc.compile();
|
|
2000
|
+
return (payload, ctx) => fn(shape, payload, ctx);
|
|
2001
|
+
};
|
|
2002
|
+
let fastpass;
|
|
2003
|
+
const isObject$1 = isObject;
|
|
2004
|
+
const jit = !globalConfig.jitless;
|
|
2005
|
+
const allowsEval$1 = allowsEval;
|
|
2006
|
+
const fastEnabled = jit && allowsEval$1.value;
|
|
2007
|
+
const catchall = def.catchall;
|
|
2008
|
+
let value;
|
|
2009
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2010
|
+
value ?? (value = _normalized.value);
|
|
2011
|
+
const input = payload.value;
|
|
2012
|
+
if (!isObject$1(input)) {
|
|
2013
|
+
payload.issues.push({
|
|
2014
|
+
expected: "object",
|
|
2015
|
+
code: "invalid_type",
|
|
2016
|
+
input,
|
|
2017
|
+
inst
|
|
2018
|
+
});
|
|
2019
|
+
return payload;
|
|
2020
|
+
}
|
|
2021
|
+
const proms = [];
|
|
2022
|
+
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
2023
|
+
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
2024
|
+
payload = fastpass(payload, ctx);
|
|
2025
|
+
} else {
|
|
2026
|
+
payload.value = {};
|
|
2027
|
+
const shape = value.shape;
|
|
2028
|
+
for (const key of value.keys) {
|
|
2029
|
+
const el = shape[key];
|
|
2030
|
+
const r$1 = el._zod.run({
|
|
2031
|
+
value: input[key],
|
|
2032
|
+
issues: []
|
|
2033
|
+
}, ctx);
|
|
2034
|
+
if (r$1 instanceof Promise) proms.push(r$1.then((r$2) => handlePropertyResult(r$2, payload, key, input)));
|
|
2035
|
+
else handlePropertyResult(r$1, payload, key, input);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
2039
|
+
const unrecognized = [];
|
|
2040
|
+
const keySet = value.keySet;
|
|
2041
|
+
const _catchall = catchall._zod;
|
|
2042
|
+
const t$1 = _catchall.def.type;
|
|
2043
|
+
for (const key of Object.keys(input)) {
|
|
2044
|
+
if (keySet.has(key)) continue;
|
|
2045
|
+
if (t$1 === "never") {
|
|
2046
|
+
unrecognized.push(key);
|
|
2047
|
+
continue;
|
|
2048
|
+
}
|
|
2049
|
+
const r$1 = _catchall.run({
|
|
2050
|
+
value: input[key],
|
|
2051
|
+
issues: []
|
|
2052
|
+
}, ctx);
|
|
2053
|
+
if (r$1 instanceof Promise) proms.push(r$1.then((r$2) => handlePropertyResult(r$2, payload, key, input)));
|
|
2054
|
+
else handlePropertyResult(r$1, payload, key, input);
|
|
2055
|
+
}
|
|
2056
|
+
if (unrecognized.length) payload.issues.push({
|
|
2057
|
+
code: "unrecognized_keys",
|
|
2058
|
+
keys: unrecognized,
|
|
2059
|
+
input,
|
|
2060
|
+
inst
|
|
2061
|
+
});
|
|
2062
|
+
if (!proms.length) return payload;
|
|
2063
|
+
return Promise.all(proms).then(() => {
|
|
2064
|
+
return payload;
|
|
2065
|
+
});
|
|
2066
|
+
};
|
|
2067
|
+
});
|
|
2068
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
2069
|
+
for (const result of results) if (result.issues.length === 0) {
|
|
2070
|
+
final.value = result.value;
|
|
2071
|
+
return final;
|
|
2072
|
+
}
|
|
2073
|
+
const nonaborted = results.filter((r$1) => !aborted(r$1));
|
|
2074
|
+
if (nonaborted.length === 1) {
|
|
2075
|
+
final.value = nonaborted[0].value;
|
|
2076
|
+
return nonaborted[0];
|
|
2077
|
+
}
|
|
2078
|
+
final.issues.push({
|
|
2079
|
+
code: "invalid_union",
|
|
2080
|
+
input: final.value,
|
|
2081
|
+
inst,
|
|
2082
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
2083
|
+
});
|
|
2084
|
+
return final;
|
|
2085
|
+
}
|
|
2086
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
2087
|
+
$ZodType.init(inst, def);
|
|
2088
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o$1) => o$1._zod.optin === "optional") ? "optional" : void 0);
|
|
2089
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o$1) => o$1._zod.optout === "optional") ? "optional" : void 0);
|
|
2090
|
+
defineLazy(inst._zod, "values", () => {
|
|
2091
|
+
if (def.options.every((o$1) => o$1._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
2092
|
+
return void 0;
|
|
2093
|
+
});
|
|
2094
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2095
|
+
if (def.options.every((o$1) => o$1._zod.pattern)) {
|
|
2096
|
+
const patterns = def.options.map((o$1) => o$1._zod.pattern);
|
|
2097
|
+
return /* @__PURE__ */ new RegExp(`^(${patterns.map((p$1) => cleanRegex(p$1.source)).join("|")})$`);
|
|
2098
|
+
}
|
|
2099
|
+
return void 0;
|
|
2100
|
+
});
|
|
2101
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2102
|
+
let async = false;
|
|
2103
|
+
const results = [];
|
|
2104
|
+
for (const option of def.options) {
|
|
2105
|
+
const result = option._zod.run({
|
|
2106
|
+
value: payload.value,
|
|
2107
|
+
issues: []
|
|
2108
|
+
}, ctx);
|
|
2109
|
+
if (result instanceof Promise) {
|
|
2110
|
+
results.push(result);
|
|
2111
|
+
async = true;
|
|
2112
|
+
} else {
|
|
2113
|
+
if (result.issues.length === 0) return result;
|
|
2114
|
+
results.push(result);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
if (!async) return handleUnionResults(results, payload, inst, ctx);
|
|
2118
|
+
return Promise.all(results).then((results$1) => {
|
|
2119
|
+
return handleUnionResults(results$1, payload, inst, ctx);
|
|
2120
|
+
});
|
|
2121
|
+
};
|
|
2122
|
+
});
|
|
2123
|
+
const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
|
|
2124
|
+
$ZodType.init(inst, def);
|
|
2125
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2126
|
+
const input = payload.value;
|
|
2127
|
+
const left = def.left._zod.run({
|
|
2128
|
+
value: input,
|
|
2129
|
+
issues: []
|
|
2130
|
+
}, ctx);
|
|
2131
|
+
const right = def.right._zod.run({
|
|
2132
|
+
value: input,
|
|
2133
|
+
issues: []
|
|
2134
|
+
}, ctx);
|
|
2135
|
+
const async = left instanceof Promise || right instanceof Promise;
|
|
2136
|
+
if (async) return Promise.all([left, right]).then(([left$1, right$1]) => {
|
|
2137
|
+
return handleIntersectionResults(payload, left$1, right$1);
|
|
2138
|
+
});
|
|
2139
|
+
return handleIntersectionResults(payload, left, right);
|
|
2140
|
+
};
|
|
2141
|
+
});
|
|
2142
|
+
function mergeValues(a$1, b$1) {
|
|
2143
|
+
if (a$1 === b$1) return {
|
|
2144
|
+
valid: true,
|
|
2145
|
+
data: a$1
|
|
2146
|
+
};
|
|
2147
|
+
if (a$1 instanceof Date && b$1 instanceof Date && +a$1 === +b$1) return {
|
|
2148
|
+
valid: true,
|
|
2149
|
+
data: a$1
|
|
2150
|
+
};
|
|
2151
|
+
if (isPlainObject(a$1) && isPlainObject(b$1)) {
|
|
2152
|
+
const bKeys = Object.keys(b$1);
|
|
2153
|
+
const sharedKeys = Object.keys(a$1).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2154
|
+
const newObj = {
|
|
2155
|
+
...a$1,
|
|
2156
|
+
...b$1
|
|
2157
|
+
};
|
|
2158
|
+
for (const key of sharedKeys) {
|
|
2159
|
+
const sharedValue = mergeValues(a$1[key], b$1[key]);
|
|
2160
|
+
if (!sharedValue.valid) return {
|
|
2161
|
+
valid: false,
|
|
2162
|
+
mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
|
|
2163
|
+
};
|
|
2164
|
+
newObj[key] = sharedValue.data;
|
|
2165
|
+
}
|
|
2166
|
+
return {
|
|
2167
|
+
valid: true,
|
|
2168
|
+
data: newObj
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
if (Array.isArray(a$1) && Array.isArray(b$1)) {
|
|
2172
|
+
if (a$1.length !== b$1.length) return {
|
|
2173
|
+
valid: false,
|
|
2174
|
+
mergeErrorPath: []
|
|
2175
|
+
};
|
|
2176
|
+
const newArray = [];
|
|
2177
|
+
for (let index = 0; index < a$1.length; index++) {
|
|
2178
|
+
const itemA = a$1[index];
|
|
2179
|
+
const itemB = b$1[index];
|
|
2180
|
+
const sharedValue = mergeValues(itemA, itemB);
|
|
2181
|
+
if (!sharedValue.valid) return {
|
|
2182
|
+
valid: false,
|
|
2183
|
+
mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
|
|
2184
|
+
};
|
|
2185
|
+
newArray.push(sharedValue.data);
|
|
2186
|
+
}
|
|
2187
|
+
return {
|
|
2188
|
+
valid: true,
|
|
2189
|
+
data: newArray
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
return {
|
|
2193
|
+
valid: false,
|
|
2194
|
+
mergeErrorPath: []
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
function handleIntersectionResults(result, left, right) {
|
|
2198
|
+
if (left.issues.length) result.issues.push(...left.issues);
|
|
2199
|
+
if (right.issues.length) result.issues.push(...right.issues);
|
|
2200
|
+
if (aborted(result)) return result;
|
|
2201
|
+
const merged = mergeValues(left.value, right.value);
|
|
2202
|
+
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
2203
|
+
result.value = merged.data;
|
|
2204
|
+
return result;
|
|
2205
|
+
}
|
|
2206
|
+
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
2207
|
+
$ZodType.init(inst, def);
|
|
2208
|
+
const values = getEnumValues(def.entries);
|
|
2209
|
+
const valuesSet = new Set(values);
|
|
2210
|
+
inst._zod.values = valuesSet;
|
|
2211
|
+
inst._zod.pattern = /* @__PURE__ */ new RegExp(`^(${values.filter((k$1) => propertyKeyTypes.has(typeof k$1)).map((o$1) => typeof o$1 === "string" ? escapeRegex(o$1) : o$1.toString()).join("|")})$`);
|
|
2212
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2213
|
+
const input = payload.value;
|
|
2214
|
+
if (valuesSet.has(input)) return payload;
|
|
2215
|
+
payload.issues.push({
|
|
2216
|
+
code: "invalid_value",
|
|
2217
|
+
values,
|
|
2218
|
+
input,
|
|
2219
|
+
inst
|
|
2220
|
+
});
|
|
2221
|
+
return payload;
|
|
2222
|
+
};
|
|
2223
|
+
});
|
|
2224
|
+
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
2225
|
+
$ZodType.init(inst, def);
|
|
2226
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
2227
|
+
const _out = def.transform(payload.value, payload);
|
|
2228
|
+
if (_ctx.async) {
|
|
2229
|
+
const output = _out instanceof Promise ? _out : Promise.resolve(_out);
|
|
2230
|
+
return output.then((output$1) => {
|
|
2231
|
+
payload.value = output$1;
|
|
2232
|
+
return payload;
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
if (_out instanceof Promise) throw new $ZodAsyncError();
|
|
2236
|
+
payload.value = _out;
|
|
2237
|
+
return payload;
|
|
2238
|
+
};
|
|
2239
|
+
});
|
|
2240
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
2241
|
+
$ZodType.init(inst, def);
|
|
2242
|
+
inst._zod.optin = "optional";
|
|
2243
|
+
inst._zod.optout = "optional";
|
|
2244
|
+
defineLazy(inst._zod, "values", () => {
|
|
2245
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
2246
|
+
});
|
|
2247
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2248
|
+
const pattern = def.innerType._zod.pattern;
|
|
2249
|
+
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
2250
|
+
});
|
|
2251
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2252
|
+
if (def.innerType._zod.optin === "optional") return def.innerType._zod.run(payload, ctx);
|
|
2253
|
+
if (payload.value === void 0) return payload;
|
|
2254
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2255
|
+
};
|
|
2256
|
+
});
|
|
2257
|
+
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
2258
|
+
$ZodType.init(inst, def);
|
|
2259
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2260
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2261
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
2262
|
+
const pattern = def.innerType._zod.pattern;
|
|
2263
|
+
return pattern ? /* @__PURE__ */ new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
2264
|
+
});
|
|
2265
|
+
defineLazy(inst._zod, "values", () => {
|
|
2266
|
+
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
2267
|
+
});
|
|
2268
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2269
|
+
if (payload.value === null) return payload;
|
|
2270
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2271
|
+
};
|
|
2272
|
+
});
|
|
2273
|
+
const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
2274
|
+
$ZodType.init(inst, def);
|
|
2275
|
+
inst._zod.optin = "optional";
|
|
2276
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2277
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2278
|
+
if (payload.value === void 0) {
|
|
2279
|
+
payload.value = def.defaultValue;
|
|
2280
|
+
return payload;
|
|
2281
|
+
}
|
|
2282
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2283
|
+
if (result instanceof Promise) return result.then((result$1) => handleDefaultResult(result$1, def));
|
|
2284
|
+
return handleDefaultResult(result, def);
|
|
2285
|
+
};
|
|
2286
|
+
});
|
|
2287
|
+
function handleDefaultResult(payload, def) {
|
|
2288
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2289
|
+
return payload;
|
|
2290
|
+
}
|
|
2291
|
+
const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
|
|
2292
|
+
$ZodType.init(inst, def);
|
|
2293
|
+
inst._zod.optin = "optional";
|
|
2294
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2295
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2296
|
+
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
2297
|
+
return def.innerType._zod.run(payload, ctx);
|
|
2298
|
+
};
|
|
2299
|
+
});
|
|
2300
|
+
const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
|
|
2301
|
+
$ZodType.init(inst, def);
|
|
2302
|
+
defineLazy(inst._zod, "values", () => {
|
|
2303
|
+
const v$1 = def.innerType._zod.values;
|
|
2304
|
+
return v$1 ? new Set([...v$1].filter((x$1) => x$1 !== void 0)) : void 0;
|
|
2305
|
+
});
|
|
2306
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2307
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2308
|
+
if (result instanceof Promise) return result.then((result$1) => handleNonOptionalResult(result$1, inst));
|
|
2309
|
+
return handleNonOptionalResult(result, inst);
|
|
2310
|
+
};
|
|
2311
|
+
});
|
|
2312
|
+
function handleNonOptionalResult(payload, inst) {
|
|
2313
|
+
if (!payload.issues.length && payload.value === void 0) payload.issues.push({
|
|
2314
|
+
code: "invalid_type",
|
|
2315
|
+
expected: "nonoptional",
|
|
2316
|
+
input: payload.value,
|
|
2317
|
+
inst
|
|
2318
|
+
});
|
|
2319
|
+
return payload;
|
|
2320
|
+
}
|
|
2321
|
+
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
2322
|
+
$ZodType.init(inst, def);
|
|
2323
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2324
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2325
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2326
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2327
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2328
|
+
if (result instanceof Promise) return result.then((result$1) => {
|
|
2329
|
+
payload.value = result$1.value;
|
|
2330
|
+
if (result$1.issues.length) {
|
|
2331
|
+
payload.value = def.catchValue({
|
|
2332
|
+
...payload,
|
|
2333
|
+
error: { issues: result$1.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2334
|
+
input: payload.value
|
|
2335
|
+
});
|
|
2336
|
+
payload.issues = [];
|
|
2337
|
+
}
|
|
2338
|
+
return payload;
|
|
2339
|
+
});
|
|
2340
|
+
payload.value = result.value;
|
|
2341
|
+
if (result.issues.length) {
|
|
2342
|
+
payload.value = def.catchValue({
|
|
2343
|
+
...payload,
|
|
2344
|
+
error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
|
|
2345
|
+
input: payload.value
|
|
2346
|
+
});
|
|
2347
|
+
payload.issues = [];
|
|
2348
|
+
}
|
|
2349
|
+
return payload;
|
|
2350
|
+
};
|
|
2351
|
+
});
|
|
2352
|
+
const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
2353
|
+
$ZodType.init(inst, def);
|
|
2354
|
+
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
2355
|
+
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
2356
|
+
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
2357
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
2358
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2359
|
+
const left = def.in._zod.run(payload, ctx);
|
|
2360
|
+
if (left instanceof Promise) return left.then((left$1) => handlePipeResult(left$1, def, ctx));
|
|
2361
|
+
return handlePipeResult(left, def, ctx);
|
|
2362
|
+
};
|
|
2363
|
+
});
|
|
2364
|
+
function handlePipeResult(left, def, ctx) {
|
|
2365
|
+
if (left.issues.length) return left;
|
|
2366
|
+
return def.out._zod.run({
|
|
2367
|
+
value: left.value,
|
|
2368
|
+
issues: left.issues
|
|
2369
|
+
}, ctx);
|
|
2370
|
+
}
|
|
2371
|
+
const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
|
|
2372
|
+
$ZodType.init(inst, def);
|
|
2373
|
+
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
2374
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
2375
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
2376
|
+
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
2377
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2378
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
2379
|
+
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
2380
|
+
return handleReadonlyResult(result);
|
|
2381
|
+
};
|
|
2382
|
+
});
|
|
2383
|
+
function handleReadonlyResult(payload) {
|
|
2384
|
+
payload.value = Object.freeze(payload.value);
|
|
2385
|
+
return payload;
|
|
2386
|
+
}
|
|
2387
|
+
const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
|
|
2388
|
+
$ZodCheck.init(inst, def);
|
|
2389
|
+
$ZodType.init(inst, def);
|
|
2390
|
+
inst._zod.parse = (payload, _$1) => {
|
|
2391
|
+
return payload;
|
|
2392
|
+
};
|
|
2393
|
+
inst._zod.check = (payload) => {
|
|
2394
|
+
const input = payload.value;
|
|
2395
|
+
const r$1 = def.fn(input);
|
|
2396
|
+
if (r$1 instanceof Promise) return r$1.then((r$2) => handleRefineResult(r$2, payload, input, inst));
|
|
2397
|
+
handleRefineResult(r$1, payload, input, inst);
|
|
2398
|
+
return;
|
|
2399
|
+
};
|
|
2400
|
+
});
|
|
2401
|
+
function handleRefineResult(result, payload, input, inst) {
|
|
2402
|
+
if (!result) {
|
|
2403
|
+
const _iss = {
|
|
2404
|
+
code: "custom",
|
|
2405
|
+
input,
|
|
2406
|
+
inst,
|
|
2407
|
+
path: [...inst._zod.def.path ?? []],
|
|
2408
|
+
continue: !inst._zod.def.abort
|
|
2409
|
+
};
|
|
2410
|
+
if (inst._zod.def.params) _iss.params = inst._zod.def.params;
|
|
2411
|
+
payload.issues.push(issue(_iss));
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
const $output = Symbol("ZodOutput");
|
|
2415
|
+
const $input = Symbol("ZodInput");
|
|
2416
|
+
var $ZodRegistry = class {
|
|
2417
|
+
constructor() {
|
|
2418
|
+
this._map = /* @__PURE__ */ new Map();
|
|
2419
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
2420
|
+
}
|
|
2421
|
+
add(schema, ..._meta) {
|
|
2422
|
+
const meta = _meta[0];
|
|
2423
|
+
this._map.set(schema, meta);
|
|
2424
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
2425
|
+
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
2426
|
+
this._idmap.set(meta.id, schema);
|
|
2427
|
+
}
|
|
2428
|
+
return this;
|
|
2429
|
+
}
|
|
2430
|
+
clear() {
|
|
2431
|
+
this._map = /* @__PURE__ */ new Map();
|
|
2432
|
+
this._idmap = /* @__PURE__ */ new Map();
|
|
2433
|
+
return this;
|
|
2434
|
+
}
|
|
2435
|
+
remove(schema) {
|
|
2436
|
+
const meta = this._map.get(schema);
|
|
2437
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
2438
|
+
this._map.delete(schema);
|
|
2439
|
+
return this;
|
|
2440
|
+
}
|
|
2441
|
+
get(schema) {
|
|
2442
|
+
const p$1 = schema._zod.parent;
|
|
2443
|
+
if (p$1) {
|
|
2444
|
+
const pm = { ...this.get(p$1) ?? {} };
|
|
2445
|
+
delete pm.id;
|
|
2446
|
+
const f$1 = {
|
|
2447
|
+
...pm,
|
|
2448
|
+
...this._map.get(schema)
|
|
2449
|
+
};
|
|
2450
|
+
return Object.keys(f$1).length ? f$1 : void 0;
|
|
2451
|
+
}
|
|
2452
|
+
return this._map.get(schema);
|
|
2453
|
+
}
|
|
2454
|
+
has(schema) {
|
|
2455
|
+
return this._map.has(schema);
|
|
2456
|
+
}
|
|
2457
|
+
};
|
|
2458
|
+
function registry() {
|
|
2459
|
+
return new $ZodRegistry();
|
|
2460
|
+
}
|
|
2461
|
+
const globalRegistry = /* @__PURE__ */ registry();
|
|
2462
|
+
function _string(Class, params) {
|
|
2463
|
+
return new Class({
|
|
2464
|
+
type: "string",
|
|
2465
|
+
...normalizeParams(params)
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
function _email(Class, params) {
|
|
2469
|
+
return new Class({
|
|
2470
|
+
type: "string",
|
|
2471
|
+
format: "email",
|
|
2472
|
+
check: "string_format",
|
|
2473
|
+
abort: false,
|
|
2474
|
+
...normalizeParams(params)
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
function _guid(Class, params) {
|
|
2478
|
+
return new Class({
|
|
2479
|
+
type: "string",
|
|
2480
|
+
format: "guid",
|
|
2481
|
+
check: "string_format",
|
|
2482
|
+
abort: false,
|
|
2483
|
+
...normalizeParams(params)
|
|
2484
|
+
});
|
|
2485
|
+
}
|
|
2486
|
+
function _uuid(Class, params) {
|
|
2487
|
+
return new Class({
|
|
2488
|
+
type: "string",
|
|
2489
|
+
format: "uuid",
|
|
2490
|
+
check: "string_format",
|
|
2491
|
+
abort: false,
|
|
2492
|
+
...normalizeParams(params)
|
|
2493
|
+
});
|
|
2494
|
+
}
|
|
2495
|
+
function _uuidv4(Class, params) {
|
|
2496
|
+
return new Class({
|
|
2497
|
+
type: "string",
|
|
2498
|
+
format: "uuid",
|
|
2499
|
+
check: "string_format",
|
|
2500
|
+
abort: false,
|
|
2501
|
+
version: "v4",
|
|
2502
|
+
...normalizeParams(params)
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
function _uuidv6(Class, params) {
|
|
2506
|
+
return new Class({
|
|
2507
|
+
type: "string",
|
|
2508
|
+
format: "uuid",
|
|
2509
|
+
check: "string_format",
|
|
2510
|
+
abort: false,
|
|
2511
|
+
version: "v6",
|
|
2512
|
+
...normalizeParams(params)
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
function _uuidv7(Class, params) {
|
|
2516
|
+
return new Class({
|
|
2517
|
+
type: "string",
|
|
2518
|
+
format: "uuid",
|
|
2519
|
+
check: "string_format",
|
|
2520
|
+
abort: false,
|
|
2521
|
+
version: "v7",
|
|
2522
|
+
...normalizeParams(params)
|
|
2523
|
+
});
|
|
2524
|
+
}
|
|
2525
|
+
function _url(Class, params) {
|
|
2526
|
+
return new Class({
|
|
2527
|
+
type: "string",
|
|
2528
|
+
format: "url",
|
|
2529
|
+
check: "string_format",
|
|
2530
|
+
abort: false,
|
|
2531
|
+
...normalizeParams(params)
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
function _emoji(Class, params) {
|
|
2535
|
+
return new Class({
|
|
2536
|
+
type: "string",
|
|
2537
|
+
format: "emoji",
|
|
2538
|
+
check: "string_format",
|
|
2539
|
+
abort: false,
|
|
2540
|
+
...normalizeParams(params)
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
function _nanoid(Class, params) {
|
|
2544
|
+
return new Class({
|
|
2545
|
+
type: "string",
|
|
2546
|
+
format: "nanoid",
|
|
2547
|
+
check: "string_format",
|
|
2548
|
+
abort: false,
|
|
2549
|
+
...normalizeParams(params)
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
function _cuid(Class, params) {
|
|
2553
|
+
return new Class({
|
|
2554
|
+
type: "string",
|
|
2555
|
+
format: "cuid",
|
|
2556
|
+
check: "string_format",
|
|
2557
|
+
abort: false,
|
|
2558
|
+
...normalizeParams(params)
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
function _cuid2(Class, params) {
|
|
2562
|
+
return new Class({
|
|
2563
|
+
type: "string",
|
|
2564
|
+
format: "cuid2",
|
|
2565
|
+
check: "string_format",
|
|
2566
|
+
abort: false,
|
|
2567
|
+
...normalizeParams(params)
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
function _ulid(Class, params) {
|
|
2571
|
+
return new Class({
|
|
2572
|
+
type: "string",
|
|
2573
|
+
format: "ulid",
|
|
2574
|
+
check: "string_format",
|
|
2575
|
+
abort: false,
|
|
2576
|
+
...normalizeParams(params)
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
function _xid(Class, params) {
|
|
2580
|
+
return new Class({
|
|
2581
|
+
type: "string",
|
|
2582
|
+
format: "xid",
|
|
2583
|
+
check: "string_format",
|
|
2584
|
+
abort: false,
|
|
2585
|
+
...normalizeParams(params)
|
|
2586
|
+
});
|
|
2587
|
+
}
|
|
2588
|
+
function _ksuid(Class, params) {
|
|
2589
|
+
return new Class({
|
|
2590
|
+
type: "string",
|
|
2591
|
+
format: "ksuid",
|
|
2592
|
+
check: "string_format",
|
|
2593
|
+
abort: false,
|
|
2594
|
+
...normalizeParams(params)
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
function _ipv4(Class, params) {
|
|
2598
|
+
return new Class({
|
|
2599
|
+
type: "string",
|
|
2600
|
+
format: "ipv4",
|
|
2601
|
+
check: "string_format",
|
|
2602
|
+
abort: false,
|
|
2603
|
+
...normalizeParams(params)
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
function _ipv6(Class, params) {
|
|
2607
|
+
return new Class({
|
|
2608
|
+
type: "string",
|
|
2609
|
+
format: "ipv6",
|
|
2610
|
+
check: "string_format",
|
|
2611
|
+
abort: false,
|
|
2612
|
+
...normalizeParams(params)
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
function _cidrv4(Class, params) {
|
|
2616
|
+
return new Class({
|
|
2617
|
+
type: "string",
|
|
2618
|
+
format: "cidrv4",
|
|
2619
|
+
check: "string_format",
|
|
2620
|
+
abort: false,
|
|
2621
|
+
...normalizeParams(params)
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
function _cidrv6(Class, params) {
|
|
2625
|
+
return new Class({
|
|
2626
|
+
type: "string",
|
|
2627
|
+
format: "cidrv6",
|
|
2628
|
+
check: "string_format",
|
|
2629
|
+
abort: false,
|
|
2630
|
+
...normalizeParams(params)
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
function _base64(Class, params) {
|
|
2634
|
+
return new Class({
|
|
2635
|
+
type: "string",
|
|
2636
|
+
format: "base64",
|
|
2637
|
+
check: "string_format",
|
|
2638
|
+
abort: false,
|
|
2639
|
+
...normalizeParams(params)
|
|
2640
|
+
});
|
|
2641
|
+
}
|
|
2642
|
+
function _base64url(Class, params) {
|
|
2643
|
+
return new Class({
|
|
2644
|
+
type: "string",
|
|
2645
|
+
format: "base64url",
|
|
2646
|
+
check: "string_format",
|
|
2647
|
+
abort: false,
|
|
2648
|
+
...normalizeParams(params)
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
function _e164(Class, params) {
|
|
2652
|
+
return new Class({
|
|
2653
|
+
type: "string",
|
|
2654
|
+
format: "e164",
|
|
2655
|
+
check: "string_format",
|
|
2656
|
+
abort: false,
|
|
2657
|
+
...normalizeParams(params)
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2660
|
+
function _jwt(Class, params) {
|
|
2661
|
+
return new Class({
|
|
2662
|
+
type: "string",
|
|
2663
|
+
format: "jwt",
|
|
2664
|
+
check: "string_format",
|
|
2665
|
+
abort: false,
|
|
2666
|
+
...normalizeParams(params)
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
function _isoDateTime(Class, params) {
|
|
2670
|
+
return new Class({
|
|
2671
|
+
type: "string",
|
|
2672
|
+
format: "datetime",
|
|
2673
|
+
check: "string_format",
|
|
2674
|
+
offset: false,
|
|
2675
|
+
local: false,
|
|
2676
|
+
precision: null,
|
|
2677
|
+
...normalizeParams(params)
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
function _isoDate(Class, params) {
|
|
2681
|
+
return new Class({
|
|
2682
|
+
type: "string",
|
|
2683
|
+
format: "date",
|
|
2684
|
+
check: "string_format",
|
|
2685
|
+
...normalizeParams(params)
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
function _isoTime(Class, params) {
|
|
2689
|
+
return new Class({
|
|
2690
|
+
type: "string",
|
|
2691
|
+
format: "time",
|
|
2692
|
+
check: "string_format",
|
|
2693
|
+
precision: null,
|
|
2694
|
+
...normalizeParams(params)
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
function _isoDuration(Class, params) {
|
|
2698
|
+
return new Class({
|
|
2699
|
+
type: "string",
|
|
2700
|
+
format: "duration",
|
|
2701
|
+
check: "string_format",
|
|
2702
|
+
...normalizeParams(params)
|
|
2703
|
+
});
|
|
2704
|
+
}
|
|
2705
|
+
function _any(Class) {
|
|
2706
|
+
return new Class({ type: "any" });
|
|
2707
|
+
}
|
|
2708
|
+
function _unknown(Class) {
|
|
2709
|
+
return new Class({ type: "unknown" });
|
|
2710
|
+
}
|
|
2711
|
+
function _never(Class, params) {
|
|
2712
|
+
return new Class({
|
|
2713
|
+
type: "never",
|
|
2714
|
+
...normalizeParams(params)
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
2717
|
+
function _maxLength(maximum, params) {
|
|
2718
|
+
const ch = new $ZodCheckMaxLength({
|
|
2719
|
+
check: "max_length",
|
|
2720
|
+
...normalizeParams(params),
|
|
2721
|
+
maximum
|
|
2722
|
+
});
|
|
2723
|
+
return ch;
|
|
2724
|
+
}
|
|
2725
|
+
function _minLength(minimum, params) {
|
|
2726
|
+
return new $ZodCheckMinLength({
|
|
2727
|
+
check: "min_length",
|
|
2728
|
+
...normalizeParams(params),
|
|
2729
|
+
minimum
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
function _length(length, params) {
|
|
2733
|
+
return new $ZodCheckLengthEquals({
|
|
2734
|
+
check: "length_equals",
|
|
2735
|
+
...normalizeParams(params),
|
|
2736
|
+
length
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
function _regex(pattern, params) {
|
|
2740
|
+
return new $ZodCheckRegex({
|
|
2741
|
+
check: "string_format",
|
|
2742
|
+
format: "regex",
|
|
2743
|
+
...normalizeParams(params),
|
|
2744
|
+
pattern
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
function _lowercase(params) {
|
|
2748
|
+
return new $ZodCheckLowerCase({
|
|
2749
|
+
check: "string_format",
|
|
2750
|
+
format: "lowercase",
|
|
2751
|
+
...normalizeParams(params)
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
function _uppercase(params) {
|
|
2755
|
+
return new $ZodCheckUpperCase({
|
|
2756
|
+
check: "string_format",
|
|
2757
|
+
format: "uppercase",
|
|
2758
|
+
...normalizeParams(params)
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
function _includes(includes, params) {
|
|
2762
|
+
return new $ZodCheckIncludes({
|
|
2763
|
+
check: "string_format",
|
|
2764
|
+
format: "includes",
|
|
2765
|
+
...normalizeParams(params),
|
|
2766
|
+
includes
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
function _startsWith(prefix, params) {
|
|
2770
|
+
return new $ZodCheckStartsWith({
|
|
2771
|
+
check: "string_format",
|
|
2772
|
+
format: "starts_with",
|
|
2773
|
+
...normalizeParams(params),
|
|
2774
|
+
prefix
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
function _endsWith(suffix, params) {
|
|
2778
|
+
return new $ZodCheckEndsWith({
|
|
2779
|
+
check: "string_format",
|
|
2780
|
+
format: "ends_with",
|
|
2781
|
+
...normalizeParams(params),
|
|
2782
|
+
suffix
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2785
|
+
function _overwrite(tx) {
|
|
2786
|
+
return new $ZodCheckOverwrite({
|
|
2787
|
+
check: "overwrite",
|
|
2788
|
+
tx
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
function _normalize(form) {
|
|
2792
|
+
return _overwrite((input) => input.normalize(form));
|
|
2793
|
+
}
|
|
2794
|
+
function _trim() {
|
|
2795
|
+
return _overwrite((input) => input.trim());
|
|
2796
|
+
}
|
|
2797
|
+
function _toLowerCase() {
|
|
2798
|
+
return _overwrite((input) => input.toLowerCase());
|
|
2799
|
+
}
|
|
2800
|
+
function _toUpperCase() {
|
|
2801
|
+
return _overwrite((input) => input.toUpperCase());
|
|
2802
|
+
}
|
|
2803
|
+
function _array(Class, element, params) {
|
|
2804
|
+
return new Class({
|
|
2805
|
+
type: "array",
|
|
2806
|
+
element,
|
|
2807
|
+
...normalizeParams(params)
|
|
2808
|
+
});
|
|
2809
|
+
}
|
|
2810
|
+
function _refine(Class, fn, _params) {
|
|
2811
|
+
const schema = new Class({
|
|
2812
|
+
type: "custom",
|
|
2813
|
+
check: "custom",
|
|
2814
|
+
fn,
|
|
2815
|
+
...normalizeParams(_params)
|
|
2816
|
+
});
|
|
2817
|
+
return schema;
|
|
2818
|
+
}
|
|
2819
|
+
const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
|
|
2820
|
+
$ZodISODateTime.init(inst, def);
|
|
2821
|
+
ZodStringFormat.init(inst, def);
|
|
2822
|
+
});
|
|
2823
|
+
function datetime(params) {
|
|
2824
|
+
return _isoDateTime(ZodISODateTime, params);
|
|
2825
|
+
}
|
|
2826
|
+
const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
|
|
2827
|
+
$ZodISODate.init(inst, def);
|
|
2828
|
+
ZodStringFormat.init(inst, def);
|
|
2829
|
+
});
|
|
2830
|
+
function date(params) {
|
|
2831
|
+
return _isoDate(ZodISODate, params);
|
|
2832
|
+
}
|
|
2833
|
+
const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
|
|
2834
|
+
$ZodISOTime.init(inst, def);
|
|
2835
|
+
ZodStringFormat.init(inst, def);
|
|
2836
|
+
});
|
|
2837
|
+
function time(params) {
|
|
2838
|
+
return _isoTime(ZodISOTime, params);
|
|
2839
|
+
}
|
|
2840
|
+
const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
|
|
2841
|
+
$ZodISODuration.init(inst, def);
|
|
2842
|
+
ZodStringFormat.init(inst, def);
|
|
2843
|
+
});
|
|
2844
|
+
function duration(params) {
|
|
2845
|
+
return _isoDuration(ZodISODuration, params);
|
|
2846
|
+
}
|
|
2847
|
+
const initializer = (inst, issues) => {
|
|
2848
|
+
$ZodError.init(inst, issues);
|
|
2849
|
+
inst.name = "ZodError";
|
|
2850
|
+
Object.defineProperties(inst, {
|
|
2851
|
+
format: { value: (mapper) => formatError(inst, mapper) },
|
|
2852
|
+
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
2853
|
+
addIssue: { value: (issue$1) => {
|
|
2854
|
+
inst.issues.push(issue$1);
|
|
2855
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2856
|
+
} },
|
|
2857
|
+
addIssues: { value: (issues$1) => {
|
|
2858
|
+
inst.issues.push(...issues$1);
|
|
2859
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
2860
|
+
} },
|
|
2861
|
+
isEmpty: { get() {
|
|
2862
|
+
return inst.issues.length === 0;
|
|
2863
|
+
} }
|
|
2864
|
+
});
|
|
2865
|
+
};
|
|
2866
|
+
const ZodError = $constructor("ZodError", initializer);
|
|
2867
|
+
const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
|
|
2868
|
+
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
2869
|
+
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
2870
|
+
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
2871
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
2872
|
+
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
2873
|
+
$ZodType.init(inst, def);
|
|
2874
|
+
inst.def = def;
|
|
2875
|
+
Object.defineProperty(inst, "_def", { value: def });
|
|
2876
|
+
inst.check = (...checks) => {
|
|
2877
|
+
return inst.clone({
|
|
2878
|
+
...def,
|
|
2879
|
+
checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
2880
|
+
check: ch,
|
|
2881
|
+
def: { check: "custom" },
|
|
2882
|
+
onattach: []
|
|
2883
|
+
} } : ch)]
|
|
2884
|
+
});
|
|
2885
|
+
};
|
|
2886
|
+
inst.clone = (def$1, params) => clone(inst, def$1, params);
|
|
2887
|
+
inst.brand = () => inst;
|
|
2888
|
+
inst.register = ((reg, meta) => {
|
|
2889
|
+
reg.add(inst, meta);
|
|
2890
|
+
return inst;
|
|
2891
|
+
});
|
|
2892
|
+
inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
|
|
2893
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
2894
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
2895
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
2896
|
+
inst.spa = inst.safeParseAsync;
|
|
2897
|
+
inst.refine = (check$1, params) => inst.check(refine(check$1, params));
|
|
2898
|
+
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
2899
|
+
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
2900
|
+
inst.optional = () => optional(inst);
|
|
2901
|
+
inst.nullable = () => nullable(inst);
|
|
2902
|
+
inst.nullish = () => optional(nullable(inst));
|
|
2903
|
+
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
2904
|
+
inst.array = () => array(inst);
|
|
2905
|
+
inst.or = (arg) => union([inst, arg]);
|
|
2906
|
+
inst.and = (arg) => intersection(inst, arg);
|
|
2907
|
+
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
2908
|
+
inst.default = (def$1) => _default(inst, def$1);
|
|
2909
|
+
inst.prefault = (def$1) => prefault(inst, def$1);
|
|
2910
|
+
inst.catch = (params) => _catch(inst, params);
|
|
2911
|
+
inst.pipe = (target) => pipe(inst, target);
|
|
2912
|
+
inst.readonly = () => readonly(inst);
|
|
2913
|
+
inst.describe = (description) => {
|
|
2914
|
+
const cl = inst.clone();
|
|
2915
|
+
globalRegistry.add(cl, { description });
|
|
2916
|
+
return cl;
|
|
2917
|
+
};
|
|
2918
|
+
Object.defineProperty(inst, "description", {
|
|
2919
|
+
get() {
|
|
2920
|
+
return globalRegistry.get(inst)?.description;
|
|
2921
|
+
},
|
|
2922
|
+
configurable: true
|
|
2923
|
+
});
|
|
2924
|
+
inst.meta = (...args) => {
|
|
2925
|
+
if (args.length === 0) return globalRegistry.get(inst);
|
|
2926
|
+
const cl = inst.clone();
|
|
2927
|
+
globalRegistry.add(cl, args[0]);
|
|
2928
|
+
return cl;
|
|
2929
|
+
};
|
|
2930
|
+
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
2931
|
+
inst.isNullable = () => inst.safeParse(null).success;
|
|
2932
|
+
return inst;
|
|
2933
|
+
});
|
|
2934
|
+
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
2935
|
+
$ZodString.init(inst, def);
|
|
2936
|
+
ZodType.init(inst, def);
|
|
2937
|
+
const bag = inst._zod.bag;
|
|
2938
|
+
inst.format = bag.format ?? null;
|
|
2939
|
+
inst.minLength = bag.minimum ?? null;
|
|
2940
|
+
inst.maxLength = bag.maximum ?? null;
|
|
2941
|
+
inst.regex = (...args) => inst.check(_regex(...args));
|
|
2942
|
+
inst.includes = (...args) => inst.check(_includes(...args));
|
|
2943
|
+
inst.startsWith = (...args) => inst.check(_startsWith(...args));
|
|
2944
|
+
inst.endsWith = (...args) => inst.check(_endsWith(...args));
|
|
2945
|
+
inst.min = (...args) => inst.check(_minLength(...args));
|
|
2946
|
+
inst.max = (...args) => inst.check(_maxLength(...args));
|
|
2947
|
+
inst.length = (...args) => inst.check(_length(...args));
|
|
2948
|
+
inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
|
|
2949
|
+
inst.lowercase = (params) => inst.check(_lowercase(params));
|
|
2950
|
+
inst.uppercase = (params) => inst.check(_uppercase(params));
|
|
2951
|
+
inst.trim = () => inst.check(_trim());
|
|
2952
|
+
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
2953
|
+
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
2954
|
+
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
2955
|
+
});
|
|
2956
|
+
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
2957
|
+
$ZodString.init(inst, def);
|
|
2958
|
+
_ZodString.init(inst, def);
|
|
2959
|
+
inst.email = (params) => inst.check(_email(ZodEmail, params));
|
|
2960
|
+
inst.url = (params) => inst.check(_url(ZodURL, params));
|
|
2961
|
+
inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
|
|
2962
|
+
inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
|
|
2963
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2964
|
+
inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
|
|
2965
|
+
inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
|
|
2966
|
+
inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
|
|
2967
|
+
inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
|
|
2968
|
+
inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
|
|
2969
|
+
inst.guid = (params) => inst.check(_guid(ZodGUID, params));
|
|
2970
|
+
inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
|
|
2971
|
+
inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
|
|
2972
|
+
inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
|
|
2973
|
+
inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
|
|
2974
|
+
inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
|
|
2975
|
+
inst.xid = (params) => inst.check(_xid(ZodXID, params));
|
|
2976
|
+
inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
|
|
2977
|
+
inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
|
|
2978
|
+
inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
|
|
2979
|
+
inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
|
|
2980
|
+
inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
|
|
2981
|
+
inst.e164 = (params) => inst.check(_e164(ZodE164, params));
|
|
2982
|
+
inst.datetime = (params) => inst.check(datetime(params));
|
|
2983
|
+
inst.date = (params) => inst.check(date(params));
|
|
2984
|
+
inst.time = (params) => inst.check(time(params));
|
|
2985
|
+
inst.duration = (params) => inst.check(duration(params));
|
|
2986
|
+
});
|
|
2987
|
+
function string(params) {
|
|
2988
|
+
return _string(ZodString, params);
|
|
2989
|
+
}
|
|
2990
|
+
const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
|
|
2991
|
+
$ZodStringFormat.init(inst, def);
|
|
2992
|
+
_ZodString.init(inst, def);
|
|
2993
|
+
});
|
|
2994
|
+
const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
|
|
2995
|
+
$ZodEmail.init(inst, def);
|
|
2996
|
+
ZodStringFormat.init(inst, def);
|
|
2997
|
+
});
|
|
2998
|
+
const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
|
|
2999
|
+
$ZodGUID.init(inst, def);
|
|
3000
|
+
ZodStringFormat.init(inst, def);
|
|
3001
|
+
});
|
|
3002
|
+
const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
|
|
3003
|
+
$ZodUUID.init(inst, def);
|
|
3004
|
+
ZodStringFormat.init(inst, def);
|
|
3005
|
+
});
|
|
3006
|
+
const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
|
|
3007
|
+
$ZodURL.init(inst, def);
|
|
3008
|
+
ZodStringFormat.init(inst, def);
|
|
3009
|
+
});
|
|
3010
|
+
const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
|
|
3011
|
+
$ZodEmoji.init(inst, def);
|
|
3012
|
+
ZodStringFormat.init(inst, def);
|
|
3013
|
+
});
|
|
3014
|
+
const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
|
|
3015
|
+
$ZodNanoID.init(inst, def);
|
|
3016
|
+
ZodStringFormat.init(inst, def);
|
|
3017
|
+
});
|
|
3018
|
+
const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
|
|
3019
|
+
$ZodCUID.init(inst, def);
|
|
3020
|
+
ZodStringFormat.init(inst, def);
|
|
3021
|
+
});
|
|
3022
|
+
const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
|
|
3023
|
+
$ZodCUID2.init(inst, def);
|
|
3024
|
+
ZodStringFormat.init(inst, def);
|
|
3025
|
+
});
|
|
3026
|
+
const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
|
|
3027
|
+
$ZodULID.init(inst, def);
|
|
3028
|
+
ZodStringFormat.init(inst, def);
|
|
3029
|
+
});
|
|
3030
|
+
const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
|
|
3031
|
+
$ZodXID.init(inst, def);
|
|
3032
|
+
ZodStringFormat.init(inst, def);
|
|
3033
|
+
});
|
|
3034
|
+
const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
|
|
3035
|
+
$ZodKSUID.init(inst, def);
|
|
3036
|
+
ZodStringFormat.init(inst, def);
|
|
3037
|
+
});
|
|
3038
|
+
const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
|
|
3039
|
+
$ZodIPv4.init(inst, def);
|
|
3040
|
+
ZodStringFormat.init(inst, def);
|
|
3041
|
+
});
|
|
3042
|
+
const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
|
|
3043
|
+
$ZodIPv6.init(inst, def);
|
|
3044
|
+
ZodStringFormat.init(inst, def);
|
|
3045
|
+
});
|
|
3046
|
+
const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
|
|
3047
|
+
$ZodCIDRv4.init(inst, def);
|
|
3048
|
+
ZodStringFormat.init(inst, def);
|
|
3049
|
+
});
|
|
3050
|
+
const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
|
|
3051
|
+
$ZodCIDRv6.init(inst, def);
|
|
3052
|
+
ZodStringFormat.init(inst, def);
|
|
3053
|
+
});
|
|
3054
|
+
const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
|
|
3055
|
+
$ZodBase64.init(inst, def);
|
|
3056
|
+
ZodStringFormat.init(inst, def);
|
|
3057
|
+
});
|
|
3058
|
+
const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
|
|
3059
|
+
$ZodBase64URL.init(inst, def);
|
|
3060
|
+
ZodStringFormat.init(inst, def);
|
|
3061
|
+
});
|
|
3062
|
+
const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
|
|
3063
|
+
$ZodE164.init(inst, def);
|
|
3064
|
+
ZodStringFormat.init(inst, def);
|
|
3065
|
+
});
|
|
3066
|
+
const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
3067
|
+
$ZodJWT.init(inst, def);
|
|
3068
|
+
ZodStringFormat.init(inst, def);
|
|
3069
|
+
});
|
|
3070
|
+
const ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
3071
|
+
$ZodAny.init(inst, def);
|
|
3072
|
+
ZodType.init(inst, def);
|
|
3073
|
+
});
|
|
3074
|
+
function any() {
|
|
3075
|
+
return _any(ZodAny);
|
|
3076
|
+
}
|
|
3077
|
+
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
3078
|
+
$ZodUnknown.init(inst, def);
|
|
3079
|
+
ZodType.init(inst, def);
|
|
3080
|
+
});
|
|
3081
|
+
function unknown() {
|
|
3082
|
+
return _unknown(ZodUnknown);
|
|
3083
|
+
}
|
|
3084
|
+
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
3085
|
+
$ZodNever.init(inst, def);
|
|
3086
|
+
ZodType.init(inst, def);
|
|
3087
|
+
});
|
|
3088
|
+
function never(params) {
|
|
3089
|
+
return _never(ZodNever, params);
|
|
3090
|
+
}
|
|
3091
|
+
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
3092
|
+
$ZodArray.init(inst, def);
|
|
3093
|
+
ZodType.init(inst, def);
|
|
3094
|
+
inst.element = def.element;
|
|
3095
|
+
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
3096
|
+
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
3097
|
+
inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
|
|
3098
|
+
inst.length = (len, params) => inst.check(_length(len, params));
|
|
3099
|
+
inst.unwrap = () => inst.element;
|
|
3100
|
+
});
|
|
3101
|
+
function array(element, params) {
|
|
3102
|
+
return _array(ZodArray, element, params);
|
|
3103
|
+
}
|
|
3104
|
+
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
3105
|
+
$ZodObject.init(inst, def);
|
|
3106
|
+
ZodType.init(inst, def);
|
|
3107
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
3108
|
+
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
3109
|
+
inst.catchall = (catchall) => inst.clone({
|
|
3110
|
+
...inst._zod.def,
|
|
3111
|
+
catchall
|
|
3112
|
+
});
|
|
3113
|
+
inst.passthrough = () => inst.clone({
|
|
3114
|
+
...inst._zod.def,
|
|
3115
|
+
catchall: unknown()
|
|
3116
|
+
});
|
|
3117
|
+
inst.loose = () => inst.clone({
|
|
3118
|
+
...inst._zod.def,
|
|
3119
|
+
catchall: unknown()
|
|
3120
|
+
});
|
|
3121
|
+
inst.strict = () => inst.clone({
|
|
3122
|
+
...inst._zod.def,
|
|
3123
|
+
catchall: never()
|
|
3124
|
+
});
|
|
3125
|
+
inst.strip = () => inst.clone({
|
|
3126
|
+
...inst._zod.def,
|
|
3127
|
+
catchall: void 0
|
|
3128
|
+
});
|
|
3129
|
+
inst.extend = (incoming) => {
|
|
3130
|
+
return extend(inst, incoming);
|
|
3131
|
+
};
|
|
3132
|
+
inst.merge = (other) => merge(inst, other);
|
|
3133
|
+
inst.pick = (mask) => pick(inst, mask);
|
|
3134
|
+
inst.omit = (mask) => omit(inst, mask);
|
|
3135
|
+
inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
|
|
3136
|
+
inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
|
|
3137
|
+
});
|
|
3138
|
+
function object(shape, params) {
|
|
3139
|
+
const def = {
|
|
3140
|
+
type: "object",
|
|
3141
|
+
get shape() {
|
|
3142
|
+
assignProp(this, "shape", { ...shape });
|
|
3143
|
+
return this.shape;
|
|
3144
|
+
},
|
|
3145
|
+
...normalizeParams(params)
|
|
3146
|
+
};
|
|
3147
|
+
return new ZodObject(def);
|
|
3148
|
+
}
|
|
3149
|
+
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
3150
|
+
$ZodUnion.init(inst, def);
|
|
3151
|
+
ZodType.init(inst, def);
|
|
3152
|
+
inst.options = def.options;
|
|
3153
|
+
});
|
|
3154
|
+
function union(options, params) {
|
|
3155
|
+
return new ZodUnion({
|
|
3156
|
+
type: "union",
|
|
3157
|
+
options,
|
|
3158
|
+
...normalizeParams(params)
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3161
|
+
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
3162
|
+
$ZodIntersection.init(inst, def);
|
|
3163
|
+
ZodType.init(inst, def);
|
|
3164
|
+
});
|
|
3165
|
+
function intersection(left, right) {
|
|
3166
|
+
return new ZodIntersection({
|
|
3167
|
+
type: "intersection",
|
|
3168
|
+
left,
|
|
3169
|
+
right
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
3173
|
+
$ZodEnum.init(inst, def);
|
|
3174
|
+
ZodType.init(inst, def);
|
|
3175
|
+
inst.enum = def.entries;
|
|
3176
|
+
inst.options = Object.values(def.entries);
|
|
3177
|
+
const keys = new Set(Object.keys(def.entries));
|
|
3178
|
+
inst.extract = (values, params) => {
|
|
3179
|
+
const newEntries = {};
|
|
3180
|
+
for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
|
|
3181
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3182
|
+
return new ZodEnum({
|
|
3183
|
+
...def,
|
|
3184
|
+
checks: [],
|
|
3185
|
+
...normalizeParams(params),
|
|
3186
|
+
entries: newEntries
|
|
3187
|
+
});
|
|
3188
|
+
};
|
|
3189
|
+
inst.exclude = (values, params) => {
|
|
3190
|
+
const newEntries = { ...def.entries };
|
|
3191
|
+
for (const value of values) if (keys.has(value)) delete newEntries[value];
|
|
3192
|
+
else throw new Error(`Key ${value} not found in enum`);
|
|
3193
|
+
return new ZodEnum({
|
|
3194
|
+
...def,
|
|
3195
|
+
checks: [],
|
|
3196
|
+
...normalizeParams(params),
|
|
3197
|
+
entries: newEntries
|
|
3198
|
+
});
|
|
3199
|
+
};
|
|
3200
|
+
});
|
|
3201
|
+
function _enum(values, params) {
|
|
3202
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v$1) => [v$1, v$1])) : values;
|
|
3203
|
+
return new ZodEnum({
|
|
3204
|
+
type: "enum",
|
|
3205
|
+
entries,
|
|
3206
|
+
...normalizeParams(params)
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
3210
|
+
$ZodTransform.init(inst, def);
|
|
3211
|
+
ZodType.init(inst, def);
|
|
3212
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
3213
|
+
payload.addIssue = (issue$1) => {
|
|
3214
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
3215
|
+
else {
|
|
3216
|
+
const _issue = issue$1;
|
|
3217
|
+
if (_issue.fatal) _issue.continue = false;
|
|
3218
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3219
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
3220
|
+
_issue.inst ?? (_issue.inst = inst);
|
|
3221
|
+
payload.issues.push(issue(_issue));
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
const output = def.transform(payload.value, payload);
|
|
3225
|
+
if (output instanceof Promise) return output.then((output$1) => {
|
|
3226
|
+
payload.value = output$1;
|
|
3227
|
+
return payload;
|
|
3228
|
+
});
|
|
3229
|
+
payload.value = output;
|
|
3230
|
+
return payload;
|
|
3231
|
+
};
|
|
3232
|
+
});
|
|
3233
|
+
function transform(fn) {
|
|
3234
|
+
return new ZodTransform({
|
|
3235
|
+
type: "transform",
|
|
3236
|
+
transform: fn
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
3240
|
+
$ZodOptional.init(inst, def);
|
|
3241
|
+
ZodType.init(inst, def);
|
|
3242
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3243
|
+
});
|
|
3244
|
+
function optional(innerType) {
|
|
3245
|
+
return new ZodOptional({
|
|
3246
|
+
type: "optional",
|
|
3247
|
+
innerType
|
|
3248
|
+
});
|
|
3249
|
+
}
|
|
3250
|
+
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
3251
|
+
$ZodNullable.init(inst, def);
|
|
3252
|
+
ZodType.init(inst, def);
|
|
3253
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3254
|
+
});
|
|
3255
|
+
function nullable(innerType) {
|
|
3256
|
+
return new ZodNullable({
|
|
3257
|
+
type: "nullable",
|
|
3258
|
+
innerType
|
|
3259
|
+
});
|
|
3260
|
+
}
|
|
3261
|
+
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
3262
|
+
$ZodDefault.init(inst, def);
|
|
3263
|
+
ZodType.init(inst, def);
|
|
3264
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3265
|
+
inst.removeDefault = inst.unwrap;
|
|
3266
|
+
});
|
|
3267
|
+
function _default(innerType, defaultValue) {
|
|
3268
|
+
return new ZodDefault({
|
|
3269
|
+
type: "default",
|
|
3270
|
+
innerType,
|
|
3271
|
+
get defaultValue() {
|
|
3272
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
3277
|
+
$ZodPrefault.init(inst, def);
|
|
3278
|
+
ZodType.init(inst, def);
|
|
3279
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3280
|
+
});
|
|
3281
|
+
function prefault(innerType, defaultValue) {
|
|
3282
|
+
return new ZodPrefault({
|
|
3283
|
+
type: "prefault",
|
|
3284
|
+
innerType,
|
|
3285
|
+
get defaultValue() {
|
|
3286
|
+
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
3291
|
+
$ZodNonOptional.init(inst, def);
|
|
3292
|
+
ZodType.init(inst, def);
|
|
3293
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3294
|
+
});
|
|
3295
|
+
function nonoptional(innerType, params) {
|
|
3296
|
+
return new ZodNonOptional({
|
|
3297
|
+
type: "nonoptional",
|
|
3298
|
+
innerType,
|
|
3299
|
+
...normalizeParams(params)
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3302
|
+
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
3303
|
+
$ZodCatch.init(inst, def);
|
|
3304
|
+
ZodType.init(inst, def);
|
|
3305
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3306
|
+
inst.removeCatch = inst.unwrap;
|
|
3307
|
+
});
|
|
3308
|
+
function _catch(innerType, catchValue) {
|
|
3309
|
+
return new ZodCatch({
|
|
3310
|
+
type: "catch",
|
|
3311
|
+
innerType,
|
|
3312
|
+
catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
|
|
3313
|
+
});
|
|
3314
|
+
}
|
|
3315
|
+
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
3316
|
+
$ZodPipe.init(inst, def);
|
|
3317
|
+
ZodType.init(inst, def);
|
|
3318
|
+
inst.in = def.in;
|
|
3319
|
+
inst.out = def.out;
|
|
3320
|
+
});
|
|
3321
|
+
function pipe(in_, out) {
|
|
3322
|
+
return new ZodPipe({
|
|
3323
|
+
type: "pipe",
|
|
3324
|
+
in: in_,
|
|
3325
|
+
out
|
|
3326
|
+
});
|
|
3327
|
+
}
|
|
3328
|
+
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
3329
|
+
$ZodReadonly.init(inst, def);
|
|
3330
|
+
ZodType.init(inst, def);
|
|
3331
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
3332
|
+
});
|
|
3333
|
+
function readonly(innerType) {
|
|
3334
|
+
return new ZodReadonly({
|
|
3335
|
+
type: "readonly",
|
|
3336
|
+
innerType
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
3340
|
+
$ZodCustom.init(inst, def);
|
|
3341
|
+
ZodType.init(inst, def);
|
|
3342
|
+
});
|
|
3343
|
+
function check(fn) {
|
|
3344
|
+
const ch = new $ZodCheck({ check: "custom" });
|
|
3345
|
+
ch._zod.check = fn;
|
|
3346
|
+
return ch;
|
|
3347
|
+
}
|
|
3348
|
+
function refine(fn, _params = {}) {
|
|
3349
|
+
return _refine(ZodCustom, fn, _params);
|
|
3350
|
+
}
|
|
3351
|
+
function superRefine(fn) {
|
|
3352
|
+
const ch = check((payload) => {
|
|
3353
|
+
payload.addIssue = (issue$1) => {
|
|
3354
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
3355
|
+
else {
|
|
3356
|
+
const _issue = issue$1;
|
|
3357
|
+
if (_issue.fatal) _issue.continue = false;
|
|
3358
|
+
_issue.code ?? (_issue.code = "custom");
|
|
3359
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
3360
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
3361
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
3362
|
+
payload.issues.push(issue(_issue));
|
|
3363
|
+
}
|
|
3364
|
+
};
|
|
3365
|
+
return fn(payload.value, payload);
|
|
3366
|
+
});
|
|
3367
|
+
return ch;
|
|
3368
|
+
}
|
|
3369
|
+
const TargetPartSchema = union([
|
|
3370
|
+
object({ text: string() }),
|
|
3371
|
+
object({ inlineData: object({
|
|
3372
|
+
mimeType: string(),
|
|
3373
|
+
data: string()
|
|
3374
|
+
}) }),
|
|
3375
|
+
object({ function_call: object({
|
|
3376
|
+
name: string(),
|
|
3377
|
+
args: any()
|
|
3378
|
+
}) }),
|
|
3379
|
+
object({ function_response: object({
|
|
3380
|
+
name: string(),
|
|
3381
|
+
response: any()
|
|
3382
|
+
}) })
|
|
3383
|
+
]);
|
|
3384
|
+
const TargetMessageSchema = object({
|
|
3385
|
+
role: string(),
|
|
3386
|
+
parts: array(TargetPartSchema)
|
|
3387
|
+
});
|
|
3388
|
+
const FinalOutputSchema = array(TargetMessageSchema);
|
|
3389
|
+
const blobUrlToBase64 = (blobUrl) => {
|
|
3390
|
+
return new Promise(async (resolve, reject) => {
|
|
3391
|
+
try {
|
|
3392
|
+
const response = await fetch(blobUrl);
|
|
3393
|
+
if (!response.ok) throw new Error(`Failed to fetch blob: ${response.statusText}`);
|
|
3394
|
+
const blob = await response.blob();
|
|
3395
|
+
const reader = new FileReader();
|
|
3396
|
+
reader.onloadend = () => {
|
|
3397
|
+
const base64Data = reader.result.split(",")[1];
|
|
3398
|
+
resolve(base64Data);
|
|
3399
|
+
};
|
|
3400
|
+
reader.onerror = (error) => {
|
|
3401
|
+
reject(error);
|
|
3402
|
+
};
|
|
3403
|
+
reader.readAsDataURL(blob);
|
|
3404
|
+
} catch (error) {
|
|
3405
|
+
reject(error);
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
};
|
|
3409
|
+
let normalizeNcMapToCanonicalArray;
|
|
3410
|
+
const normalizeNcValue = (ncWrapper) => {
|
|
3411
|
+
const ncArray = ncWrapper.Nc;
|
|
3412
|
+
return z(ncArray).with([
|
|
3413
|
+
N.any,
|
|
3414
|
+
N.any,
|
|
3415
|
+
N.any,
|
|
3416
|
+
N.any,
|
|
3417
|
+
{ Nc: [N.select(N.instanceOf(Map))] }
|
|
3418
|
+
], (innerMap) => {
|
|
3419
|
+
const processedMapArray = normalizeNcMapToCanonicalArray(innerMap);
|
|
3420
|
+
return [
|
|
3421
|
+
null,
|
|
3422
|
+
null,
|
|
3423
|
+
null,
|
|
3424
|
+
null,
|
|
3425
|
+
[processedMapArray]
|
|
3426
|
+
];
|
|
3427
|
+
}).otherwise(() => ncArray);
|
|
3428
|
+
};
|
|
3429
|
+
normalizeNcMapToCanonicalArray = (map) => {
|
|
3430
|
+
return Array.from(map.entries()).map(([key, valueWrapper]) => {
|
|
3431
|
+
const canonicalValueArray = normalizeNcValue(valueWrapper);
|
|
3432
|
+
return [key, canonicalValueArray];
|
|
3433
|
+
});
|
|
3434
|
+
};
|
|
3435
|
+
const getCanonicalFunctionCall = (msg) => {
|
|
3436
|
+
return z(msg.parts[0]).with(N.array(), (part) => ({
|
|
3437
|
+
name: part[10][0],
|
|
3438
|
+
argsArray: part[10][1][0]
|
|
3439
|
+
})).with({ Nc: N.array() }, (part) => {
|
|
3440
|
+
const functionCallData = part.Nc[10].Nc;
|
|
3441
|
+
const name = functionCallData[0];
|
|
3442
|
+
const argsMap = functionCallData[1].Nc[0];
|
|
3443
|
+
return {
|
|
3444
|
+
name,
|
|
3445
|
+
argsArray: normalizeNcMapToCanonicalArray(argsMap)
|
|
3446
|
+
};
|
|
3447
|
+
}).otherwise(() => {
|
|
3448
|
+
throw new Error("Unknown function_call structure encountered.");
|
|
3449
|
+
});
|
|
3450
|
+
};
|
|
3451
|
+
const parseArgValue = (arg) => {
|
|
3452
|
+
if (!Array.isArray(arg)) return arg;
|
|
3453
|
+
return z(arg).with([
|
|
3454
|
+
N.any,
|
|
3455
|
+
N.any,
|
|
3456
|
+
N.any,
|
|
3457
|
+
N.any,
|
|
3458
|
+
N.select(N.array())
|
|
3459
|
+
], (nestedPairs) => parseFunctionArgs(nestedPairs[0])).with([
|
|
3460
|
+
N.any,
|
|
3461
|
+
N.any,
|
|
3462
|
+
N.any,
|
|
3463
|
+
1
|
|
3464
|
+
], () => true).with([
|
|
3465
|
+
N.any,
|
|
3466
|
+
N.any,
|
|
3467
|
+
N.any,
|
|
3468
|
+
0
|
|
3469
|
+
], () => false).with([
|
|
3470
|
+
N.any,
|
|
3471
|
+
N.any,
|
|
3472
|
+
N.select(N.string)
|
|
3473
|
+
], (val) => val).with([N.any, N.select(N.number)], (val) => val).otherwise(() => null);
|
|
3474
|
+
};
|
|
3475
|
+
const parseFunctionArgs = (argList) => {
|
|
3476
|
+
if (!Array.isArray(argList)) return {};
|
|
3477
|
+
return Object.fromEntries(argList.map(([key, value]) => [key, parseArgValue(value)]));
|
|
3478
|
+
};
|
|
3479
|
+
const convertMessages = async (sourceMessages) => {
|
|
3480
|
+
const groupedMessages = sourceMessages.reduce((acc, msg) => {
|
|
3481
|
+
const lastGroup = acc[acc.length - 1];
|
|
3482
|
+
const prevMessage = lastGroup?.items[lastGroup.items.length - 1];
|
|
3483
|
+
if (lastGroup && lastGroup.role === msg.role && prevMessage?.Ua !== "function_call") lastGroup.items.push(msg);
|
|
3484
|
+
else acc.push({
|
|
3485
|
+
role: msg.role,
|
|
3486
|
+
items: [msg]
|
|
3487
|
+
});
|
|
3488
|
+
return acc;
|
|
3489
|
+
}, []);
|
|
3490
|
+
const finalMessages = [];
|
|
3491
|
+
for (const group of groupedMessages) {
|
|
3492
|
+
let functionResponseData = null;
|
|
3493
|
+
const partsPromises = group.items.map(async (item) => {
|
|
3494
|
+
return z(item).with({
|
|
3495
|
+
Ua: "text",
|
|
3496
|
+
text: N.string
|
|
3497
|
+
}, (msg) => {
|
|
3498
|
+
return msg.text.length > 0 ? { text: msg.text } : null;
|
|
3499
|
+
}).with({
|
|
3500
|
+
Ua: "image",
|
|
3501
|
+
Wd: N.not(void 0).select()
|
|
3502
|
+
}, (wd) => {
|
|
3503
|
+
return { inlineData: {
|
|
3504
|
+
mimeType: wd.mimeType,
|
|
3505
|
+
data: wd.Dc
|
|
3506
|
+
} };
|
|
3507
|
+
}).with({
|
|
3508
|
+
Ua: "image",
|
|
3509
|
+
Ta: N.not(void 0).select("ta"),
|
|
3510
|
+
zd: N.not(void 0).select("zd")
|
|
3511
|
+
}, async ({ ta, zd }) => {
|
|
3512
|
+
try {
|
|
3513
|
+
const data = await blobUrlToBase64(zd);
|
|
3514
|
+
return { inlineData: {
|
|
3515
|
+
mimeType: ta.mimeType,
|
|
3516
|
+
data
|
|
3517
|
+
} };
|
|
3518
|
+
} catch (error) {
|
|
3519
|
+
console.error(`Failed to process blob URL ${zd}:`, error);
|
|
3520
|
+
return null;
|
|
3521
|
+
}
|
|
3522
|
+
}).with({ Ua: "function_call" }, (msg) => {
|
|
3523
|
+
try {
|
|
3524
|
+
const { name, argsArray } = getCanonicalFunctionCall(msg);
|
|
3525
|
+
const args = parseFunctionArgs(argsArray);
|
|
3526
|
+
if (msg.Qg?.response) functionResponseData = {
|
|
3527
|
+
name,
|
|
3528
|
+
response: msg.Qg.response
|
|
3529
|
+
};
|
|
3530
|
+
return { function_call: {
|
|
3531
|
+
name,
|
|
3532
|
+
args
|
|
3533
|
+
} };
|
|
3534
|
+
} catch (error) {
|
|
3535
|
+
console.error("Failed to parse function call:", error, item);
|
|
3536
|
+
return null;
|
|
3537
|
+
}
|
|
3538
|
+
}).otherwise(() => null);
|
|
3539
|
+
});
|
|
3540
|
+
const parts = (await Promise.all(partsPromises)).filter((p$1) => p$1 !== null);
|
|
3541
|
+
if (parts.length > 0) finalMessages.push({
|
|
3542
|
+
role: group.role,
|
|
3543
|
+
parts
|
|
3544
|
+
});
|
|
3545
|
+
if (functionResponseData) finalMessages.push({
|
|
3546
|
+
role: "user",
|
|
3547
|
+
parts: [{ function_response: {
|
|
3548
|
+
name: functionResponseData.name,
|
|
3549
|
+
response: { output: functionResponseData.response }
|
|
3550
|
+
} }]
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
finalMessages.push({
|
|
3554
|
+
role: "user",
|
|
3555
|
+
parts: [{ text: "INSERT_INPUT_HERE" }]
|
|
3556
|
+
});
|
|
3557
|
+
return finalMessages;
|
|
3558
|
+
};
|
|
413
3559
|
const syncOutput = async () => {
|
|
414
|
-
const onChange = func_throttle(
|
|
3560
|
+
const onChange = func_throttle(async (raw) => {
|
|
3561
|
+
await runFileCreation(await convertMessages(raw));
|
|
3562
|
+
}, 200, {
|
|
415
3563
|
before: true,
|
|
416
3564
|
waitPromise: true
|
|
417
3565
|
});
|
|
418
3566
|
const arr_push = Array.prototype[Symbol.for("arr_push")] || Array.prototype.push;
|
|
419
3567
|
Array.prototype[Symbol.for("arr_push")] = arr_push;
|
|
420
3568
|
Array.prototype.push = function push(...args) {
|
|
421
|
-
const a = args[0];
|
|
422
|
-
|
|
423
|
-
|
|
3569
|
+
const a$1 = args[0];
|
|
3570
|
+
let isMatched = false;
|
|
3571
|
+
if (this.length > 1 && a$1 && Object.getPrototypeOf(a$1) === Object.prototype && a$1.role && a$1.id && typeof a$1.text === "string") isMatched = true;
|
|
3572
|
+
const res = arr_push.apply(this, args);
|
|
3573
|
+
if (isMatched) try {
|
|
3574
|
+
onChange(structuredClone(this));
|
|
3575
|
+
} catch {}
|
|
3576
|
+
return res;
|
|
424
3577
|
};
|
|
425
3578
|
const findInput = () => $(`textarea[aria-label="Start typing a prompt"]`);
|
|
426
3579
|
while (!started) {
|
|
@@ -434,7 +3587,7 @@ const syncOutput = async () => {
|
|
|
434
3587
|
};
|
|
435
3588
|
let started = false;
|
|
436
3589
|
let writting = false;
|
|
437
|
-
async function runFileCreation(b, targetFilename = getTargetNamespace() + ".contents.json") {
|
|
3590
|
+
async function runFileCreation(b$1, targetFilename = getTargetNamespace() + ".contents.json") {
|
|
438
3591
|
started = true;
|
|
439
3592
|
if (writting) return;
|
|
440
3593
|
writting = true;
|
|
@@ -444,7 +3597,7 @@ async function runFileCreation(b, targetFilename = getTargetNamespace() + ".cont
|
|
|
444
3597
|
const fileHandle = await rootDirHandle$1.getFileHandle(targetFilename, { create: true });
|
|
445
3598
|
const writable = await fileHandle.createWritable();
|
|
446
3599
|
console.log("%c - 创建可写流成功。", styles.info);
|
|
447
|
-
await writable.write(JSON.stringify(b));
|
|
3600
|
+
await writable.write(JSON.stringify(b$1));
|
|
448
3601
|
console.log("%c - 数据写入中...", styles.info);
|
|
449
3602
|
await writable.close();
|
|
450
3603
|
console.log(`%c - ✅ 文件写入并关闭成功: %c${targetFilename}`, styles.success, styles.code);
|
|
@@ -456,10 +3609,10 @@ async function runFileCreation(b, targetFilename = getTargetNamespace() + ".cont
|
|
|
456
3609
|
}
|
|
457
3610
|
}
|
|
458
3611
|
(async () => {
|
|
459
|
-
const aborted = await prepareDirHandle().then(() => false, (e) => {
|
|
460
|
-
if (e instanceof Error && e.name === "AbortError") return true;
|
|
3612
|
+
const aborted$1 = await prepareDirHandle().then(() => false, (e$1) => {
|
|
3613
|
+
if (e$1 instanceof Error && e$1.name === "AbortError") return true;
|
|
461
3614
|
});
|
|
462
|
-
if (aborted) {
|
|
3615
|
+
if (aborted$1) {
|
|
463
3616
|
console.warn("用户取消了脚本运行");
|
|
464
3617
|
return;
|
|
465
3618
|
}
|