@marimo-team/islands 0.14.11-dev2 → 0.14.11-dev21
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/dist/{ConnectedDataExplorerComponent-Dl7Gx8nj.js → ConnectedDataExplorerComponent-B98UAJGl.js} +4 -4
- package/dist/{ImageComparisonComponent-IsA0pccG.js → ImageComparisonComponent-3rx-X1eA.js} +1 -1
- package/dist/{VegaLite-C3jfIIJl.js → VegaLite-bssctYsi.js} +6961 -7180
- package/dist/{_baseUniq-DXGCzwrs.js → _baseUniq-n5nuGCm-.js} +36 -36
- package/dist/{any-language-editor-BbtP_crK.js → any-language-editor-CTuUQiXP.js} +1 -1
- package/dist/{architectureDiagram-IEHRJDOE-B5UTatfK.js → architectureDiagram-NQ2NVSRB-Ghs-gTjF.js} +897 -894
- package/dist/assets/{worker-BcyuOSTi.js → save-worker-fI5ofStJ.js} +1076 -1649
- package/dist/assets/{save-worker-BIDtxCd1.js → worker-Bfk1FrzG.js} +1627 -1747
- package/dist/assets/worker-BldghCZh.js +3752 -0
- package/dist/{blockDiagram-JOT3LUYC-BsdaPVqe.js → blockDiagram-PHRCVELO-BJrdpvE8.js} +534 -522
- package/dist/{c4Diagram-VJAJSXHY-mAt84R4z.js → c4Diagram-6F6E4RAY-C3mvzJPu.js} +4 -4
- package/dist/{channel-BQIWHLpc.js → channel-Dv_KwBSx.js} +1 -1
- package/dist/{chunk-4BMEZGHF-CKIxJWxP.js → chunk-353BL4L5-DE1uUKLI.js} +1 -1
- package/dist/{chunk-D6G4REZN-CgGV16Ao.js → chunk-67H74DCK-BSe-uUSS.js} +1 -1
- package/dist/chunk-6OLS64BW-lmSfyWue.js +1383 -0
- package/dist/{chunk-XZIHB7SX-Bwue5JjE.js → chunk-AACKK3MU-DAmuROVD.js} +1 -1
- package/dist/chunk-BFAMUDN2-D9C6R9UM.js +8 -0
- package/dist/chunk-E2GYISFI-BzFDmP6o.js +19 -0
- package/dist/{chunk-A2AXSNBT-wMvlVMnZ.js → chunk-QEP2MXWD-BILXx23p.js} +30 -27
- package/dist/chunk-SKB7J2MH-CxMkQppY.js +20 -0
- package/dist/{classDiagram-GIVACNV2-DOmcKRwM.js → classDiagram-BGRH5UQR-BbYr5aD9.js} +2 -2
- package/dist/{classDiagram-v2-COTLJTTW-DOmcKRwM.js → classDiagram-v2-O24JOBDK-BbYr5aD9.js} +2 -2
- package/dist/{clone-PHSHUhb-.js → clone-DuBujAk0.js} +1 -1
- package/dist/{dagre-OKDRZEBW-D5HNBllU.js → dagre-FFZHY6LT-DO5nLpLx.js} +8 -8
- package/dist/{data-editor-Coz_zrsX.js → data-editor-C8yM5wyh.js} +213 -201
- package/dist/diagram-3EMPZRKU-B1rYMJMS.js +313 -0
- package/dist/diagram-5UYTHUR4-BUu8PsmE.js +137 -0
- package/dist/{diagram-SSKATNLV-BsO89QJN.js → diagram-ZTM2IBQH-lz_uZrYh.js} +3 -3
- package/dist/{erDiagram-Q7BY3M3F-DWIMKTfS.js → erDiagram-R3QVA2FD-D_A2jrJV.js} +6 -5
- package/dist/{flowDiagram-4HSFHLVR-CnO0wmaL.js → flowDiagram-PKI6S5ZS-Bv6D_bIf.js} +283 -278
- package/dist/{ganttDiagram-APWFNJXF-otclLFL4.js → ganttDiagram-EK5VF46D-CbkaARm4.js} +453 -439
- package/dist/{gitGraphDiagram-7IBYFJ6S-C7F3RAja.js → gitGraphDiagram-GW3U2K7C-B8ZGoOT-.js} +35 -35
- package/dist/{graph-Btsdly6D.js → graph-txVVq_De.js} +3 -3
- package/dist/{index-BreCkhLm.js → index-BI6tloBb.js} +3 -3
- package/dist/{index-CcRF-HlA.js → index-CFJazcU-.js} +4 -4
- package/dist/{index-BGmzdYRo.js → index-OiR0LgXX.js} +6 -3
- package/dist/{index-z8OyYHEh.js → index-fJDj-gSp.js} +1 -1
- package/dist/index-pBmAzQJl.js +235 -0
- package/dist/{infoDiagram-PH2N3AL5-BwcXDzwE.js → infoDiagram-RLU2ROGC-DJw6nWp0.js} +5 -3
- package/dist/journeyDiagram-EWQZEKCU-1oCDdLcB.js +836 -0
- package/dist/{kanban-definition-NDS4AKOZ-3NJYjnpz.js → kanban-definition-ILFWEQ3N-nKJ02Ox0.js} +41 -39
- package/dist/{layout-qfivsCI_.js → layout-CbUwX9d6.js} +49 -49
- package/dist/{linear-D_Kojy5s.js → linear-sn9_bxtB.js} +22 -22
- package/dist/{main-DLuap1gp.js → main-D9-48wlP.js} +45053 -45130
- package/dist/main.js +1 -1
- package/dist/{mermaid-DCIbF0Rd.js → mermaid-CRRCnedu.js} +4925 -4853
- package/dist/min-CYaGuxZ4.js +80 -0
- package/dist/{mindmap-definition-ALO5MXBD-BtSBR7-c.js → mindmap-definition-CZNETY7S-CV62GMPJ.js} +3 -3
- package/dist/{pieDiagram-IB7DONF6-TiB_3g9z.js → pieDiagram-NIOCPIFQ-Bcs4p6kX.js} +3 -3
- package/dist/{quadrantDiagram-7GDLP6J5-B0DPjp7Z.js → quadrantDiagram-2OG54O6I-BlY5yea6.js} +2 -2
- package/dist/{react-plotly-BXWB3UQ5.js → react-plotly-B1SKP2B-.js} +1 -1
- package/dist/{requirementDiagram-KVF5MWMF-D_IlbRr_.js → requirementDiagram-SO3GGRV7-rmiJc5mh.js} +5 -4
- package/dist/{sankeyDiagram-QLVOVGJD-BHm9uvp_.js → sankeyDiagram-4UZDY2LN-TVzOLFCA.js} +11 -11
- package/dist/{sequenceDiagram-X6HHIX6F-3wcWWNtl.js → sequenceDiagram-ZIKVLSP4-POBNIgPB.js} +151 -149
- package/dist/{slides-component-JEGZbKgL.js → slides-component-5Y9DQzeV.js} +969 -962
- package/dist/stateDiagram-XX37X6EN-lR-7TG5f.js +264 -0
- package/dist/{stateDiagram-v2-YXO3MK2T-DTdt4vFc.js → stateDiagram-v2-GD6S3NHB-CYV2YCSY.js} +2 -2
- package/dist/style.css +1 -1
- package/dist/{time-DyZM4tB4.js → time-BytuUgXk.js} +2 -2
- package/dist/{timeline-definition-BDJGKUSR-Of4cvbYH.js → timeline-definition-RI47OAVP-DOrNrVHk.js} +99 -102
- package/dist/{radar-MK3ICKWK-BMSp8zaN.js → treemap-FKARHQ26-BOli4yXg.js} +2469 -2330
- package/dist/{vega-component-Dwc_9OTG.js → vega-component-KZ-3GH6H.js} +21 -21
- package/dist/{xychartDiagram-VJFVF3MP-5Jc993Va.js → xychartDiagram-H2YORKM3-CUOFDcIy.js} +409 -375
- package/package.json +37 -37
- package/dist/assets/worker-Dz6PPEGc.js +0 -4115
- package/dist/chunk-AEK57VVT-BAi7QtEw.js +0 -1416
- package/dist/chunk-RZ5BOZE2-D7Ag0UF8.js +0 -24
- package/dist/diagram-VNBRO52H-CA8VTm7L.js +0 -126
- package/dist/journeyDiagram-U35MCT3I-Co4hTdu9.js +0 -809
- package/dist/min-CQBZldos.js +0 -80
- package/dist/stateDiagram-DGXRK772-DbH3Rdz4.js +0 -271
|
@@ -1,4115 +0,0 @@
|
|
|
1
|
-
var _r = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
|
|
2
|
-
var ps = _r((ys, ht) => {
|
|
3
|
-
const br = 1e10, wr = 1e3;
|
|
4
|
-
function Le(t, e) {
|
|
5
|
-
const r = t.map((n) => `"${n}"`).join(", ");
|
|
6
|
-
return new Error(`This RPC instance cannot ${e} because the transport did not provide one or more of these methods: ${r}`);
|
|
7
|
-
}
|
|
8
|
-
function kr(t = {}) {
|
|
9
|
-
let e = {};
|
|
10
|
-
function r(v) {
|
|
11
|
-
e = v;
|
|
12
|
-
}
|
|
13
|
-
let n = {};
|
|
14
|
-
function s(v) {
|
|
15
|
-
n.unregisterHandler && n.unregisterHandler(), n = v, n.registerHandler?.(vr);
|
|
16
|
-
}
|
|
17
|
-
let a;
|
|
18
|
-
function i(v) {
|
|
19
|
-
if (typeof v == "function") {
|
|
20
|
-
a = v;
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
a = (T, O) => {
|
|
24
|
-
const R = v[T];
|
|
25
|
-
if (R)
|
|
26
|
-
return R(O);
|
|
27
|
-
const M = v._;
|
|
28
|
-
if (!M)
|
|
29
|
-
throw new Error(`The requested method has no handler: ${T}`);
|
|
30
|
-
return M(T, O);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const { maxRequestTime: o = wr } = t;
|
|
34
|
-
t.transport && s(t.transport), t.requestHandler && i(t.requestHandler), t._debugHooks && r(t._debugHooks);
|
|
35
|
-
let d = 0;
|
|
36
|
-
function c() {
|
|
37
|
-
return d <= br ? ++d : d = 0;
|
|
38
|
-
}
|
|
39
|
-
const l = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
|
|
40
|
-
function S(v, ...T) {
|
|
41
|
-
const O = T[0];
|
|
42
|
-
return new Promise((R, M) => {
|
|
43
|
-
if (!n.send)
|
|
44
|
-
throw Le(["send"], "make requests");
|
|
45
|
-
const B = c(), wt = {
|
|
46
|
-
type: "request",
|
|
47
|
-
id: B,
|
|
48
|
-
method: v,
|
|
49
|
-
params: O
|
|
50
|
-
};
|
|
51
|
-
l.set(B, { resolve: R, reject: M }), o !== 1 / 0 && w.set(B, setTimeout(() => {
|
|
52
|
-
w.delete(B), M(new Error("RPC request timed out."));
|
|
53
|
-
}, o)), e.onSend?.(wt), n.send(wt);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const C = new Proxy(S, {
|
|
57
|
-
get: (v, T, O) => T in v ? Reflect.get(v, T, O) : (R) => S(T, R)
|
|
58
|
-
}), z = C;
|
|
59
|
-
function De(v, ...T) {
|
|
60
|
-
const O = T[0];
|
|
61
|
-
if (!n.send)
|
|
62
|
-
throw Le(["send"], "send messages");
|
|
63
|
-
const R = {
|
|
64
|
-
type: "message",
|
|
65
|
-
id: v,
|
|
66
|
-
payload: O
|
|
67
|
-
};
|
|
68
|
-
e.onSend?.(R), n.send(R);
|
|
69
|
-
}
|
|
70
|
-
const _t = new Proxy(De, {
|
|
71
|
-
get: (v, T, O) => T in v ? Reflect.get(v, T, O) : (R) => De(T, R)
|
|
72
|
-
}), bt = _t, Q = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Set();
|
|
73
|
-
function yr(v, T) {
|
|
74
|
-
if (!n.registerHandler)
|
|
75
|
-
throw Le(["registerHandler"], "register message listeners");
|
|
76
|
-
if (v === "*") {
|
|
77
|
-
rt.add(T);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
Q.has(v) || Q.set(v, /* @__PURE__ */ new Set()), Q.get(v)?.add(T);
|
|
81
|
-
}
|
|
82
|
-
function gr(v, T) {
|
|
83
|
-
if (v === "*") {
|
|
84
|
-
rt.delete(T);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
Q.get(v)?.delete(T), Q.get(v)?.size === 0 && Q.delete(v);
|
|
88
|
-
}
|
|
89
|
-
async function vr(v) {
|
|
90
|
-
if (e.onReceive?.(v), !("type" in v))
|
|
91
|
-
throw new Error("Message does not contain a type.");
|
|
92
|
-
if (v.type === "request") {
|
|
93
|
-
if (!n.send || !a)
|
|
94
|
-
throw Le(["send", "requestHandler"], "handle requests");
|
|
95
|
-
const { id: T, method: O, params: R } = v;
|
|
96
|
-
let M;
|
|
97
|
-
try {
|
|
98
|
-
M = {
|
|
99
|
-
type: "response",
|
|
100
|
-
id: T,
|
|
101
|
-
success: !0,
|
|
102
|
-
payload: await a(O, R)
|
|
103
|
-
};
|
|
104
|
-
} catch (B) {
|
|
105
|
-
if (!(B instanceof Error))
|
|
106
|
-
throw B;
|
|
107
|
-
M = {
|
|
108
|
-
type: "response",
|
|
109
|
-
id: T,
|
|
110
|
-
success: !1,
|
|
111
|
-
error: B.message
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
e.onSend?.(M), n.send(M);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (v.type === "response") {
|
|
118
|
-
const T = w.get(v.id);
|
|
119
|
-
T != null && clearTimeout(T);
|
|
120
|
-
const { resolve: O, reject: R } = l.get(v.id) ?? {};
|
|
121
|
-
v.success ? O?.(v.payload) : R?.(new Error(v.error));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (v.type === "message") {
|
|
125
|
-
for (const O of rt)
|
|
126
|
-
O(v.id, v.payload);
|
|
127
|
-
const T = Q.get(v.id);
|
|
128
|
-
if (!T)
|
|
129
|
-
return;
|
|
130
|
-
for (const O of T)
|
|
131
|
-
O(v.payload);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
throw new Error(`Unexpected RPC message type: ${v.type}`);
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
setTransport: s,
|
|
138
|
-
setRequestHandler: i,
|
|
139
|
-
request: C,
|
|
140
|
-
requestProxy: z,
|
|
141
|
-
send: _t,
|
|
142
|
-
sendProxy: bt,
|
|
143
|
-
addMessageListener: yr,
|
|
144
|
-
removeMessageListener: gr,
|
|
145
|
-
proxy: { send: bt, request: z },
|
|
146
|
-
_setDebugHooks: r
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
function xr(t) {
|
|
150
|
-
return kr(t);
|
|
151
|
-
}
|
|
152
|
-
const Rt = "[transport-id]";
|
|
153
|
-
function Sr(t, e) {
|
|
154
|
-
const { transportId: r } = e;
|
|
155
|
-
return r != null ? { [Rt]: r, data: t } : t;
|
|
156
|
-
}
|
|
157
|
-
function Tr(t, e) {
|
|
158
|
-
const { transportId: r, filter: n } = e, s = n?.();
|
|
159
|
-
if (r != null && s != null)
|
|
160
|
-
throw new Error("Cannot use both `transportId` and `filter` at the same time");
|
|
161
|
-
let a = t;
|
|
162
|
-
if (r) {
|
|
163
|
-
if (t[Rt] !== r)
|
|
164
|
-
return [!0];
|
|
165
|
-
a = t.data;
|
|
166
|
-
}
|
|
167
|
-
return s === !1 ? [!0] : [!1, a];
|
|
168
|
-
}
|
|
169
|
-
function Er(t, e = {}) {
|
|
170
|
-
const { transportId: r, filter: n, remotePort: s } = e, a = t, i = s ?? t;
|
|
171
|
-
let o;
|
|
172
|
-
return {
|
|
173
|
-
send(d) {
|
|
174
|
-
i.postMessage(Sr(d, { transportId: r }));
|
|
175
|
-
},
|
|
176
|
-
registerHandler(d) {
|
|
177
|
-
o = (c) => {
|
|
178
|
-
const l = c.data, [w, S] = Tr(l, {
|
|
179
|
-
transportId: r,
|
|
180
|
-
filter: () => n?.(c)
|
|
181
|
-
});
|
|
182
|
-
w || d(S);
|
|
183
|
-
}, a.addEventListener("message", o);
|
|
184
|
-
},
|
|
185
|
-
unregisterHandler() {
|
|
186
|
-
o && a.removeEventListener("message", o);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
function Or(t) {
|
|
191
|
-
return Er(self, t);
|
|
192
|
-
}
|
|
193
|
-
const Nr = "marimo-transport";
|
|
194
|
-
var Rr = Object.defineProperty, x = (t, e) => Rr(t, "name", { value: e, configurable: !0 }), At = ((t) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(t, { get: (e, r) => (typeof require < "u" ? require : e)[r] }) : t)(function(t) {
|
|
195
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
196
|
-
throw new Error('Dynamic require of "' + t + '" is not supported');
|
|
197
|
-
});
|
|
198
|
-
function Ct(t) {
|
|
199
|
-
return !isNaN(parseFloat(t)) && isFinite(t);
|
|
200
|
-
}
|
|
201
|
-
x(Ct, "_isNumber");
|
|
202
|
-
function J(t) {
|
|
203
|
-
return t.charAt(0).toUpperCase() + t.substring(1);
|
|
204
|
-
}
|
|
205
|
-
x(J, "_capitalize");
|
|
206
|
-
function et(t) {
|
|
207
|
-
return function() {
|
|
208
|
-
return this[t];
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
x(et, "_getter");
|
|
212
|
-
var de = ["isConstructor", "isEval", "isNative", "isToplevel"], ce = ["columnNumber", "lineNumber"], ue = ["fileName", "functionName", "source"], Ar = ["args"], Cr = ["evalOrigin"], Ve = de.concat(ce, ue, Ar, Cr);
|
|
213
|
-
function I(t) {
|
|
214
|
-
if (t) for (var e = 0; e < Ve.length; e++) t[Ve[e]] !== void 0 && this["set" + J(Ve[e])](t[Ve[e]]);
|
|
215
|
-
}
|
|
216
|
-
x(I, "StackFrame");
|
|
217
|
-
I.prototype = { getArgs: function() {
|
|
218
|
-
return this.args;
|
|
219
|
-
}, setArgs: function(t) {
|
|
220
|
-
if (Object.prototype.toString.call(t) !== "[object Array]") throw new TypeError("Args must be an Array");
|
|
221
|
-
this.args = t;
|
|
222
|
-
}, getEvalOrigin: function() {
|
|
223
|
-
return this.evalOrigin;
|
|
224
|
-
}, setEvalOrigin: function(t) {
|
|
225
|
-
if (t instanceof I) this.evalOrigin = t;
|
|
226
|
-
else if (t instanceof Object) this.evalOrigin = new I(t);
|
|
227
|
-
else throw new TypeError("Eval Origin must be an Object or StackFrame");
|
|
228
|
-
}, toString: function() {
|
|
229
|
-
var t = this.getFileName() || "", e = this.getLineNumber() || "", r = this.getColumnNumber() || "", n = this.getFunctionName() || "";
|
|
230
|
-
return this.getIsEval() ? t ? "[eval] (" + t + ":" + e + ":" + r + ")" : "[eval]:" + e + ":" + r : n ? n + " (" + t + ":" + e + ":" + r + ")" : t + ":" + e + ":" + r;
|
|
231
|
-
} };
|
|
232
|
-
I.fromString = x(function(t) {
|
|
233
|
-
var e = t.indexOf("("), r = t.lastIndexOf(")"), n = t.substring(0, e), s = t.substring(e + 1, r).split(","), a = t.substring(r + 1);
|
|
234
|
-
if (a.indexOf("@") === 0) var i = /@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(a, ""), o = i[1], d = i[2], c = i[3];
|
|
235
|
-
return new I({ functionName: n, args: s || void 0, fileName: o, lineNumber: d || void 0, columnNumber: c || void 0 });
|
|
236
|
-
}, "StackFrame$$fromString");
|
|
237
|
-
for (ee = 0; ee < de.length; ee++) I.prototype["get" + J(de[ee])] = et(de[ee]), I.prototype["set" + J(de[ee])] = /* @__PURE__ */ function(t) {
|
|
238
|
-
return function(e) {
|
|
239
|
-
this[t] = !!e;
|
|
240
|
-
};
|
|
241
|
-
}(de[ee]);
|
|
242
|
-
var ee;
|
|
243
|
-
for (te = 0; te < ce.length; te++) I.prototype["get" + J(ce[te])] = et(ce[te]), I.prototype["set" + J(ce[te])] = /* @__PURE__ */ function(t) {
|
|
244
|
-
return function(e) {
|
|
245
|
-
if (!Ct(e)) throw new TypeError(t + " must be a Number");
|
|
246
|
-
this[t] = Number(e);
|
|
247
|
-
};
|
|
248
|
-
}(ce[te]);
|
|
249
|
-
var te;
|
|
250
|
-
for (re = 0; re < ue.length; re++) I.prototype["get" + J(ue[re])] = et(ue[re]), I.prototype["set" + J(ue[re])] = /* @__PURE__ */ function(t) {
|
|
251
|
-
return function(e) {
|
|
252
|
-
this[t] = String(e);
|
|
253
|
-
};
|
|
254
|
-
}(ue[re]);
|
|
255
|
-
var re, nt = I;
|
|
256
|
-
function It() {
|
|
257
|
-
var t = /^\s*at .*(\S+:\d+|\(native\))/m, e = /^(eval@)?(\[native code])?$/;
|
|
258
|
-
return { parse: x(function(r) {
|
|
259
|
-
if (r.stack && r.stack.match(t)) return this.parseV8OrIE(r);
|
|
260
|
-
if (r.stack) return this.parseFFOrSafari(r);
|
|
261
|
-
throw new Error("Cannot parse given Error object");
|
|
262
|
-
}, "ErrorStackParser$$parse"), extractLocation: x(function(r) {
|
|
263
|
-
if (r.indexOf(":") === -1) return [r];
|
|
264
|
-
var n = /(.+?)(?::(\d+))?(?::(\d+))?$/, s = n.exec(r.replace(/[()]/g, ""));
|
|
265
|
-
return [s[1], s[2] || void 0, s[3] || void 0];
|
|
266
|
-
}, "ErrorStackParser$$extractLocation"), parseV8OrIE: x(function(r) {
|
|
267
|
-
var n = r.stack.split(`
|
|
268
|
-
`).filter(function(s) {
|
|
269
|
-
return !!s.match(t);
|
|
270
|
-
}, this);
|
|
271
|
-
return n.map(function(s) {
|
|
272
|
-
s.indexOf("(eval ") > -1 && (s = s.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
|
|
273
|
-
var a = s.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), i = a.match(/ (\(.+\)$)/);
|
|
274
|
-
a = i ? a.replace(i[0], "") : a;
|
|
275
|
-
var o = this.extractLocation(i ? i[1] : a), d = i && a || void 0, c = ["eval", "<anonymous>"].indexOf(o[0]) > -1 ? void 0 : o[0];
|
|
276
|
-
return new nt({ functionName: d, fileName: c, lineNumber: o[1], columnNumber: o[2], source: s });
|
|
277
|
-
}, this);
|
|
278
|
-
}, "ErrorStackParser$$parseV8OrIE"), parseFFOrSafari: x(function(r) {
|
|
279
|
-
var n = r.stack.split(`
|
|
280
|
-
`).filter(function(s) {
|
|
281
|
-
return !s.match(e);
|
|
282
|
-
}, this);
|
|
283
|
-
return n.map(function(s) {
|
|
284
|
-
if (s.indexOf(" > eval") > -1 && (s = s.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), s.indexOf("@") === -1 && s.indexOf(":") === -1) return new nt({ functionName: s });
|
|
285
|
-
var a = /((.*".+"[^@]*)?[^@]*)(?:@)/, i = s.match(a), o = i && i[1] ? i[1] : void 0, d = this.extractLocation(s.replace(a, ""));
|
|
286
|
-
return new nt({ functionName: o, fileName: d[0], lineNumber: d[1], columnNumber: d[2], source: s });
|
|
287
|
-
}, this);
|
|
288
|
-
}, "ErrorStackParser$$parseFFOrSafari") };
|
|
289
|
-
}
|
|
290
|
-
x(It, "ErrorStackParser");
|
|
291
|
-
var Ir = new It(), Pr = Ir, V = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && !process.browser, Pt = V && typeof ht < "u" && typeof ht.exports < "u" && typeof At < "u" && typeof __dirname < "u", jr = V && !Pt, Zr = typeof Deno < "u", jt = !V && !Zr, $r = jt && typeof window == "object" && typeof document == "object" && typeof document.createElement == "function" && "sessionStorage" in window && typeof importScripts != "function", Mr = jt && typeof importScripts == "function" && typeof self == "object";
|
|
292
|
-
typeof navigator == "object" && typeof navigator.userAgent == "string" && navigator.userAgent.indexOf("Chrome") == -1 && navigator.userAgent.indexOf("Safari") > -1;
|
|
293
|
-
var Zt, at, $t, kt, mt;
|
|
294
|
-
async function yt() {
|
|
295
|
-
if (!V || (Zt = (await import("./__vite-browser-external-CPvbk0mb.js")).default, kt = await import("./__vite-browser-external-CPvbk0mb.js"), mt = await import("./__vite-browser-external-CPvbk0mb.js"), $t = (await import("./__vite-browser-external-CPvbk0mb.js")).default, at = await import("./__vite-browser-external-CPvbk0mb.js"), gt = at.sep, typeof At < "u")) return;
|
|
296
|
-
let t = kt, e = await import("./__vite-browser-external-CPvbk0mb.js"), r = await import("./__vite-browser-external-CPvbk0mb.js"), n = await import("./__vite-browser-external-CPvbk0mb.js"), s = { fs: t, crypto: e, ws: r, child_process: n };
|
|
297
|
-
globalThis.require = function(a) {
|
|
298
|
-
return s[a];
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
x(yt, "initNodeModules");
|
|
302
|
-
function Mt(t, e) {
|
|
303
|
-
return at.resolve(e || ".", t);
|
|
304
|
-
}
|
|
305
|
-
x(Mt, "node_resolvePath");
|
|
306
|
-
function Ft(t, e) {
|
|
307
|
-
return e === void 0 && (e = location), new URL(t, e).toString();
|
|
308
|
-
}
|
|
309
|
-
x(Ft, "browser_resolvePath");
|
|
310
|
-
var it;
|
|
311
|
-
V ? it = Mt : it = Ft;
|
|
312
|
-
var gt;
|
|
313
|
-
V || (gt = "/");
|
|
314
|
-
function Dt(t, e) {
|
|
315
|
-
return t.startsWith("file://") && (t = t.slice(7)), t.includes("://") ? { response: fetch(t) } : { binary: mt.readFile(t).then((r) => new Uint8Array(r.buffer, r.byteOffset, r.byteLength)) };
|
|
316
|
-
}
|
|
317
|
-
x(Dt, "node_getBinaryResponse");
|
|
318
|
-
function Lt(t, e) {
|
|
319
|
-
let r = new URL(t, location);
|
|
320
|
-
return { response: fetch(r, e ? { integrity: e } : {}) };
|
|
321
|
-
}
|
|
322
|
-
x(Lt, "browser_getBinaryResponse");
|
|
323
|
-
var Ue;
|
|
324
|
-
V ? Ue = Dt : Ue = Lt;
|
|
325
|
-
async function Vt(t, e) {
|
|
326
|
-
let { response: r, binary: n } = Ue(t, e);
|
|
327
|
-
if (n) return n;
|
|
328
|
-
let s = await r;
|
|
329
|
-
if (!s.ok) throw new Error(`Failed to load '${t}': request failed.`);
|
|
330
|
-
return new Uint8Array(await s.arrayBuffer());
|
|
331
|
-
}
|
|
332
|
-
x(Vt, "loadBinaryFile");
|
|
333
|
-
var ze;
|
|
334
|
-
if ($r) ze = x(async (t) => await import(t), "loadScript");
|
|
335
|
-
else if (Mr) ze = x(async (t) => {
|
|
336
|
-
try {
|
|
337
|
-
globalThis.importScripts(t);
|
|
338
|
-
} catch (e) {
|
|
339
|
-
if (e instanceof TypeError) await import(t);
|
|
340
|
-
else throw e;
|
|
341
|
-
}
|
|
342
|
-
}, "loadScript");
|
|
343
|
-
else if (V) ze = zt;
|
|
344
|
-
else throw new Error("Cannot determine runtime environment");
|
|
345
|
-
async function zt(t) {
|
|
346
|
-
t.startsWith("file://") && (t = t.slice(7)), t.includes("://") ? $t.runInThisContext(await (await fetch(t)).text()) : await import(Zt.pathToFileURL(t).href);
|
|
347
|
-
}
|
|
348
|
-
x(zt, "nodeLoadScript");
|
|
349
|
-
async function qt(t) {
|
|
350
|
-
if (V) {
|
|
351
|
-
await yt();
|
|
352
|
-
let e = await mt.readFile(t, { encoding: "utf8" });
|
|
353
|
-
return JSON.parse(e);
|
|
354
|
-
} else return await (await fetch(t)).json();
|
|
355
|
-
}
|
|
356
|
-
x(qt, "loadLockFile");
|
|
357
|
-
async function Ut() {
|
|
358
|
-
if (Pt) return __dirname;
|
|
359
|
-
let t;
|
|
360
|
-
try {
|
|
361
|
-
throw new Error();
|
|
362
|
-
} catch (n) {
|
|
363
|
-
t = n;
|
|
364
|
-
}
|
|
365
|
-
let e = Pr.parse(t)[0].fileName;
|
|
366
|
-
if (V && !e.startsWith("file://") && (e = `file://${e}`), jr) {
|
|
367
|
-
let n = await import("./__vite-browser-external-CPvbk0mb.js");
|
|
368
|
-
return (await import("./__vite-browser-external-CPvbk0mb.js")).fileURLToPath(n.dirname(e));
|
|
369
|
-
}
|
|
370
|
-
let r = e.lastIndexOf(gt);
|
|
371
|
-
if (r === -1) throw new Error("Could not extract indexURL path from pyodide module location");
|
|
372
|
-
return e.slice(0, r);
|
|
373
|
-
}
|
|
374
|
-
x(Ut, "calculateDirname");
|
|
375
|
-
function Ht(t) {
|
|
376
|
-
let e = t.FS, r = t.FS.filesystems.MEMFS, n = t.PATH, s = { DIR_MODE: 16895, FILE_MODE: 33279, mount: function(a) {
|
|
377
|
-
if (!a.opts.fileSystemHandle) throw new Error("opts.fileSystemHandle is required");
|
|
378
|
-
return r.mount.apply(null, arguments);
|
|
379
|
-
}, syncfs: async (a, i, o) => {
|
|
380
|
-
try {
|
|
381
|
-
let d = s.getLocalSet(a), c = await s.getRemoteSet(a), l = i ? c : d, w = i ? d : c;
|
|
382
|
-
await s.reconcile(a, l, w), o(null);
|
|
383
|
-
} catch (d) {
|
|
384
|
-
o(d);
|
|
385
|
-
}
|
|
386
|
-
}, getLocalSet: (a) => {
|
|
387
|
-
let i = /* @__PURE__ */ Object.create(null);
|
|
388
|
-
function o(l) {
|
|
389
|
-
return l !== "." && l !== "..";
|
|
390
|
-
}
|
|
391
|
-
x(o, "isRealDir");
|
|
392
|
-
function d(l) {
|
|
393
|
-
return (w) => n.join2(l, w);
|
|
394
|
-
}
|
|
395
|
-
x(d, "toAbsolute");
|
|
396
|
-
let c = e.readdir(a.mountpoint).filter(o).map(d(a.mountpoint));
|
|
397
|
-
for (; c.length; ) {
|
|
398
|
-
let l = c.pop(), w = e.stat(l);
|
|
399
|
-
e.isDir(w.mode) && c.push.apply(c, e.readdir(l).filter(o).map(d(l))), i[l] = { timestamp: w.mtime, mode: w.mode };
|
|
400
|
-
}
|
|
401
|
-
return { type: "local", entries: i };
|
|
402
|
-
}, getRemoteSet: async (a) => {
|
|
403
|
-
let i = /* @__PURE__ */ Object.create(null), o = await Fr(a.opts.fileSystemHandle);
|
|
404
|
-
for (let [d, c] of o) d !== "." && (i[n.join2(a.mountpoint, d)] = { timestamp: c.kind === "file" ? new Date((await c.getFile()).lastModified) : /* @__PURE__ */ new Date(), mode: c.kind === "file" ? s.FILE_MODE : s.DIR_MODE });
|
|
405
|
-
return { type: "remote", entries: i, handles: o };
|
|
406
|
-
}, loadLocalEntry: (a) => {
|
|
407
|
-
let i = e.lookupPath(a).node, o = e.stat(a);
|
|
408
|
-
if (e.isDir(o.mode)) return { timestamp: o.mtime, mode: o.mode };
|
|
409
|
-
if (e.isFile(o.mode)) return i.contents = r.getFileDataAsTypedArray(i), { timestamp: o.mtime, mode: o.mode, contents: i.contents };
|
|
410
|
-
throw new Error("node type not supported");
|
|
411
|
-
}, storeLocalEntry: (a, i) => {
|
|
412
|
-
if (e.isDir(i.mode)) e.mkdirTree(a, i.mode);
|
|
413
|
-
else if (e.isFile(i.mode)) e.writeFile(a, i.contents, { canOwn: !0 });
|
|
414
|
-
else throw new Error("node type not supported");
|
|
415
|
-
e.chmod(a, i.mode), e.utime(a, i.timestamp, i.timestamp);
|
|
416
|
-
}, removeLocalEntry: (a) => {
|
|
417
|
-
var i = e.stat(a);
|
|
418
|
-
e.isDir(i.mode) ? e.rmdir(a) : e.isFile(i.mode) && e.unlink(a);
|
|
419
|
-
}, loadRemoteEntry: async (a) => {
|
|
420
|
-
if (a.kind === "file") {
|
|
421
|
-
let i = await a.getFile();
|
|
422
|
-
return { contents: new Uint8Array(await i.arrayBuffer()), mode: s.FILE_MODE, timestamp: new Date(i.lastModified) };
|
|
423
|
-
} else {
|
|
424
|
-
if (a.kind === "directory") return { mode: s.DIR_MODE, timestamp: /* @__PURE__ */ new Date() };
|
|
425
|
-
throw new Error("unknown kind: " + a.kind);
|
|
426
|
-
}
|
|
427
|
-
}, storeRemoteEntry: async (a, i, o) => {
|
|
428
|
-
let d = a.get(n.dirname(i)), c = e.isFile(o.mode) ? await d.getFileHandle(n.basename(i), { create: !0 }) : await d.getDirectoryHandle(n.basename(i), { create: !0 });
|
|
429
|
-
if (c.kind === "file") {
|
|
430
|
-
let l = await c.createWritable();
|
|
431
|
-
await l.write(o.contents), await l.close();
|
|
432
|
-
}
|
|
433
|
-
a.set(i, c);
|
|
434
|
-
}, removeRemoteEntry: async (a, i) => {
|
|
435
|
-
await a.get(n.dirname(i)).removeEntry(n.basename(i)), a.delete(i);
|
|
436
|
-
}, reconcile: async (a, i, o) => {
|
|
437
|
-
let d = 0, c = [];
|
|
438
|
-
Object.keys(i.entries).forEach(function(S) {
|
|
439
|
-
let C = i.entries[S], z = o.entries[S];
|
|
440
|
-
(!z || e.isFile(C.mode) && C.timestamp.getTime() > z.timestamp.getTime()) && (c.push(S), d++);
|
|
441
|
-
}), c.sort();
|
|
442
|
-
let l = [];
|
|
443
|
-
if (Object.keys(o.entries).forEach(function(S) {
|
|
444
|
-
i.entries[S] || (l.push(S), d++);
|
|
445
|
-
}), l.sort().reverse(), !d) return;
|
|
446
|
-
let w = i.type === "remote" ? i.handles : o.handles;
|
|
447
|
-
for (let S of c) {
|
|
448
|
-
let C = n.normalize(S.replace(a.mountpoint, "/")).substring(1);
|
|
449
|
-
if (o.type === "local") {
|
|
450
|
-
let z = w.get(C), De = await s.loadRemoteEntry(z);
|
|
451
|
-
s.storeLocalEntry(S, De);
|
|
452
|
-
} else {
|
|
453
|
-
let z = s.loadLocalEntry(S);
|
|
454
|
-
await s.storeRemoteEntry(w, C, z);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
for (let S of l) if (o.type === "local") s.removeLocalEntry(S);
|
|
458
|
-
else {
|
|
459
|
-
let C = n.normalize(S.replace(a.mountpoint, "/")).substring(1);
|
|
460
|
-
await s.removeRemoteEntry(w, C);
|
|
461
|
-
}
|
|
462
|
-
} };
|
|
463
|
-
t.FS.filesystems.NATIVEFS_ASYNC = s;
|
|
464
|
-
}
|
|
465
|
-
x(Ht, "initializeNativeFS");
|
|
466
|
-
var Fr = x(async (t) => {
|
|
467
|
-
let e = [];
|
|
468
|
-
async function r(s) {
|
|
469
|
-
for await (let a of s.values()) e.push(a), a.kind === "directory" && await r(a);
|
|
470
|
-
}
|
|
471
|
-
x(r, "collect"), await r(t);
|
|
472
|
-
let n = /* @__PURE__ */ new Map();
|
|
473
|
-
n.set(".", t);
|
|
474
|
-
for (let s of e) {
|
|
475
|
-
let a = (await t.resolve(s)).join("/");
|
|
476
|
-
n.set(a, s);
|
|
477
|
-
}
|
|
478
|
-
return n;
|
|
479
|
-
}, "getFsHandles");
|
|
480
|
-
function Bt(t) {
|
|
481
|
-
let e = { noImageDecoding: !0, noAudioDecoding: !0, noWasmDecoding: !1, preRun: Kt(t), quit(r, n) {
|
|
482
|
-
throw e.exited = { status: r, toThrow: n }, n;
|
|
483
|
-
}, print: t.stdout, printErr: t.stderr, thisProgram: t._sysExecutable, arguments: t.args, API: { config: t }, locateFile: (r) => t.indexURL + r, instantiateWasm: Xt(t.indexURL) };
|
|
484
|
-
return e;
|
|
485
|
-
}
|
|
486
|
-
x(Bt, "createSettings");
|
|
487
|
-
function Wt(t) {
|
|
488
|
-
return function(e) {
|
|
489
|
-
let r = "/";
|
|
490
|
-
try {
|
|
491
|
-
e.FS.mkdirTree(t);
|
|
492
|
-
} catch (n) {
|
|
493
|
-
console.error(`Error occurred while making a home directory '${t}':`), console.error(n), console.error(`Using '${r}' for a home directory instead`), t = r;
|
|
494
|
-
}
|
|
495
|
-
e.FS.chdir(t);
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
x(Wt, "createHomeDirectory");
|
|
499
|
-
function Jt(t) {
|
|
500
|
-
return function(e) {
|
|
501
|
-
Object.assign(e.ENV, t);
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
x(Jt, "setEnvironment");
|
|
505
|
-
function Yt(t) {
|
|
506
|
-
return t ? [async (e) => {
|
|
507
|
-
e.addRunDependency("fsInitHook");
|
|
508
|
-
try {
|
|
509
|
-
await t(e.FS, { sitePackages: e.API.sitePackages });
|
|
510
|
-
} finally {
|
|
511
|
-
e.removeRunDependency("fsInitHook");
|
|
512
|
-
}
|
|
513
|
-
}] : [];
|
|
514
|
-
}
|
|
515
|
-
x(Yt, "callFsInitHook");
|
|
516
|
-
function Gt(t) {
|
|
517
|
-
let e = Vt(t);
|
|
518
|
-
return async (r) => {
|
|
519
|
-
let n = r._py_version_major(), s = r._py_version_minor();
|
|
520
|
-
r.FS.mkdirTree("/lib"), r.API.sitePackages = `/lib/python${n}.${s}/site-packages`, r.FS.mkdirTree(r.API.sitePackages), r.addRunDependency("install-stdlib");
|
|
521
|
-
try {
|
|
522
|
-
let a = await e;
|
|
523
|
-
r.FS.writeFile(`/lib/python${n}${s}.zip`, a);
|
|
524
|
-
} catch (a) {
|
|
525
|
-
console.error("Error occurred while installing the standard library:"), console.error(a);
|
|
526
|
-
} finally {
|
|
527
|
-
r.removeRunDependency("install-stdlib");
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
x(Gt, "installStdlib");
|
|
532
|
-
function Kt(t) {
|
|
533
|
-
let e;
|
|
534
|
-
return t.stdLibURL != null ? e = t.stdLibURL : e = t.indexURL + "python_stdlib.zip", [...Yt(t.fsInit), Gt(e), Wt(t.env.HOME), Jt(t.env), Ht];
|
|
535
|
-
}
|
|
536
|
-
x(Kt, "getFileSystemInitializationFuncs");
|
|
537
|
-
function Xt(t) {
|
|
538
|
-
if (typeof WasmOffsetConverter < "u") return;
|
|
539
|
-
let { binary: e, response: r } = Ue(t + "pyodide.asm.wasm");
|
|
540
|
-
return function(n, s) {
|
|
541
|
-
return async function() {
|
|
542
|
-
try {
|
|
543
|
-
let a;
|
|
544
|
-
r ? a = await WebAssembly.instantiateStreaming(r, n) : a = await WebAssembly.instantiate(await e, n);
|
|
545
|
-
let { instance: i, module: o } = a;
|
|
546
|
-
s(i, o);
|
|
547
|
-
} catch (a) {
|
|
548
|
-
console.warn("wasm instantiation failed!"), console.warn(a);
|
|
549
|
-
}
|
|
550
|
-
}(), {};
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
x(Xt, "getInstantiateWasmFunc");
|
|
554
|
-
var ot = "0.27.5";
|
|
555
|
-
async function dt(t = {}) {
|
|
556
|
-
var e, r;
|
|
557
|
-
await yt();
|
|
558
|
-
let n = t.indexURL || await Ut();
|
|
559
|
-
n = it(n), n.endsWith("/") || (n += "/"), t.indexURL = n;
|
|
560
|
-
let s = { fullStdLib: !1, jsglobals: globalThis, stdin: globalThis.prompt ? globalThis.prompt : void 0, lockFileURL: n + "pyodide-lock.json", args: [], env: {}, packageCacheDir: n, packages: [], enableRunUntilComplete: !1, checkAPIVersion: !0, BUILD_ID: "bd0388b62e760f8ba04185eb443fec955f25434f49c7b951efe5b1f792dbe5d4" }, a = Object.assign(s, t);
|
|
561
|
-
(e = a.env).HOME ?? (e.HOME = "/home/pyodide"), (r = a.env).PYTHONINSPECT ?? (r.PYTHONINSPECT = "1");
|
|
562
|
-
let i = Bt(a), o = i.API;
|
|
563
|
-
if (o.lockFilePromise = qt(a.lockFileURL), typeof _createPyodideModule != "function") {
|
|
564
|
-
let S = `${a.indexURL}pyodide.asm.js`;
|
|
565
|
-
await ze(S);
|
|
566
|
-
}
|
|
567
|
-
let d;
|
|
568
|
-
if (t._loadSnapshot) {
|
|
569
|
-
let S = await t._loadSnapshot;
|
|
570
|
-
ArrayBuffer.isView(S) ? d = S : d = new Uint8Array(S), i.noInitialRun = !0, i.INITIAL_MEMORY = d.length;
|
|
571
|
-
}
|
|
572
|
-
let c = await _createPyodideModule(i);
|
|
573
|
-
if (i.exited) throw i.exited.toThrow;
|
|
574
|
-
if (t.pyproxyToStringRepr && o.setPyProxyToStringMethod(!0), o.version !== ot && a.checkAPIVersion) throw new Error(`Pyodide version does not match: '${ot}' <==> '${o.version}'. If you updated the Pyodide version, make sure you also updated the 'indexURL' parameter passed to loadPyodide.`);
|
|
575
|
-
c.locateFile = (S) => {
|
|
576
|
-
throw new Error("Didn't expect to load any more file_packager files!");
|
|
577
|
-
};
|
|
578
|
-
let l;
|
|
579
|
-
d && (l = o.restoreSnapshot(d));
|
|
580
|
-
let w = o.finalizeBootstrap(l, t._snapshotDeserializer);
|
|
581
|
-
return o.sys.path.insert(0, o.config.env.HOME), w.version.includes("dev") || o.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${w.version}/full/`), o._pyodide.set_excepthook(), await o.packageIndexReady, o.initializeStreams(a.stdin, a.stdout, a.stderr), w;
|
|
582
|
-
}
|
|
583
|
-
x(dt, "loadPyodide");
|
|
584
|
-
const Dr = !1;
|
|
585
|
-
function Lr(t) {
|
|
586
|
-
return t.includes("dev") && Dr ? "dev" : `v${ot}`;
|
|
587
|
-
}
|
|
588
|
-
class Vr {
|
|
589
|
-
constructor(e) {
|
|
590
|
-
this.onMessage = e, this.buffer = [];
|
|
591
|
-
}
|
|
592
|
-
buffer;
|
|
593
|
-
started = !1;
|
|
594
|
-
push = (e) => {
|
|
595
|
-
this.started ? this.onMessage(e) : this.buffer.push(e);
|
|
596
|
-
};
|
|
597
|
-
/**
|
|
598
|
-
* Start processing messages
|
|
599
|
-
*/
|
|
600
|
-
start = () => {
|
|
601
|
-
this.started = !0, this.buffer.forEach((e) => this.onMessage(e)), this.buffer = [];
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
const _e = {
|
|
605
|
-
NOOP: () => {
|
|
606
|
-
}
|
|
607
|
-
}, Qt = (t, e) => {
|
|
608
|
-
const r = `[${t}]`;
|
|
609
|
-
return {
|
|
610
|
-
debug: (...n) => e.debug(r, ...n),
|
|
611
|
-
log: (...n) => e.log(r, ...n),
|
|
612
|
-
warn: (...n) => e.warn(r, ...n),
|
|
613
|
-
error: (...n) => e.error(r, ...n),
|
|
614
|
-
trace: (...n) => e.trace(r, ...n),
|
|
615
|
-
get: (n) => Qt(`${t}.${n}`, e),
|
|
616
|
-
disabled: (n = !0) => n ? Be : e
|
|
617
|
-
};
|
|
618
|
-
}, He = {
|
|
619
|
-
debug: (...t) => {
|
|
620
|
-
console.debug(...t);
|
|
621
|
-
},
|
|
622
|
-
log: (...t) => {
|
|
623
|
-
console.log(...t);
|
|
624
|
-
},
|
|
625
|
-
warn: (...t) => {
|
|
626
|
-
console.warn(...t);
|
|
627
|
-
},
|
|
628
|
-
error: (...t) => {
|
|
629
|
-
console.error(...t);
|
|
630
|
-
},
|
|
631
|
-
trace: (...t) => {
|
|
632
|
-
console.trace(...t);
|
|
633
|
-
},
|
|
634
|
-
get: (t) => Qt(t, He),
|
|
635
|
-
disabled: (t = !0) => t ? Be : He
|
|
636
|
-
}, Be = {
|
|
637
|
-
debug: () => _e.NOOP,
|
|
638
|
-
log: () => _e.NOOP,
|
|
639
|
-
warn: () => _e.NOOP,
|
|
640
|
-
error: () => _e.NOOP,
|
|
641
|
-
trace: () => _e.NOOP,
|
|
642
|
-
get: () => Be,
|
|
643
|
-
disabled: () => Be
|
|
644
|
-
};
|
|
645
|
-
function zr() {
|
|
646
|
-
return typeof window < "u" && window.Logger || He;
|
|
647
|
-
}
|
|
648
|
-
const W = zr();
|
|
649
|
-
class qr {
|
|
650
|
-
promise;
|
|
651
|
-
resolve;
|
|
652
|
-
reject;
|
|
653
|
-
status = "pending";
|
|
654
|
-
constructor() {
|
|
655
|
-
this.promise = new Promise((e, r) => {
|
|
656
|
-
this.reject = (n) => {
|
|
657
|
-
this.status = "rejected", r(n);
|
|
658
|
-
}, this.resolve = (n) => {
|
|
659
|
-
this.status = "resolved", e(n);
|
|
660
|
-
};
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
var k;
|
|
665
|
-
(function(t) {
|
|
666
|
-
t.assertEqual = (s) => s;
|
|
667
|
-
function e(s) {
|
|
668
|
-
}
|
|
669
|
-
t.assertIs = e;
|
|
670
|
-
function r(s) {
|
|
671
|
-
throw new Error();
|
|
672
|
-
}
|
|
673
|
-
t.assertNever = r, t.arrayToEnum = (s) => {
|
|
674
|
-
const a = {};
|
|
675
|
-
for (const i of s)
|
|
676
|
-
a[i] = i;
|
|
677
|
-
return a;
|
|
678
|
-
}, t.getValidEnumValues = (s) => {
|
|
679
|
-
const a = t.objectKeys(s).filter((o) => typeof s[s[o]] != "number"), i = {};
|
|
680
|
-
for (const o of a)
|
|
681
|
-
i[o] = s[o];
|
|
682
|
-
return t.objectValues(i);
|
|
683
|
-
}, t.objectValues = (s) => t.objectKeys(s).map(function(a) {
|
|
684
|
-
return s[a];
|
|
685
|
-
}), t.objectKeys = typeof Object.keys == "function" ? (s) => Object.keys(s) : (s) => {
|
|
686
|
-
const a = [];
|
|
687
|
-
for (const i in s)
|
|
688
|
-
Object.prototype.hasOwnProperty.call(s, i) && a.push(i);
|
|
689
|
-
return a;
|
|
690
|
-
}, t.find = (s, a) => {
|
|
691
|
-
for (const i of s)
|
|
692
|
-
if (a(i))
|
|
693
|
-
return i;
|
|
694
|
-
}, t.isInteger = typeof Number.isInteger == "function" ? (s) => Number.isInteger(s) : (s) => typeof s == "number" && isFinite(s) && Math.floor(s) === s;
|
|
695
|
-
function n(s, a = " | ") {
|
|
696
|
-
return s.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
697
|
-
}
|
|
698
|
-
t.joinValues = n, t.jsonStringifyReplacer = (s, a) => typeof a == "bigint" ? a.toString() : a;
|
|
699
|
-
})(k || (k = {}));
|
|
700
|
-
var ct;
|
|
701
|
-
(function(t) {
|
|
702
|
-
t.mergeShapes = (e, r) => ({
|
|
703
|
-
...e,
|
|
704
|
-
...r
|
|
705
|
-
// second overwrites first
|
|
706
|
-
});
|
|
707
|
-
})(ct || (ct = {}));
|
|
708
|
-
const p = k.arrayToEnum([
|
|
709
|
-
"string",
|
|
710
|
-
"nan",
|
|
711
|
-
"number",
|
|
712
|
-
"integer",
|
|
713
|
-
"float",
|
|
714
|
-
"boolean",
|
|
715
|
-
"date",
|
|
716
|
-
"bigint",
|
|
717
|
-
"symbol",
|
|
718
|
-
"function",
|
|
719
|
-
"undefined",
|
|
720
|
-
"null",
|
|
721
|
-
"array",
|
|
722
|
-
"object",
|
|
723
|
-
"unknown",
|
|
724
|
-
"promise",
|
|
725
|
-
"void",
|
|
726
|
-
"never",
|
|
727
|
-
"map",
|
|
728
|
-
"set"
|
|
729
|
-
]), U = (t) => {
|
|
730
|
-
switch (typeof t) {
|
|
731
|
-
case "undefined":
|
|
732
|
-
return p.undefined;
|
|
733
|
-
case "string":
|
|
734
|
-
return p.string;
|
|
735
|
-
case "number":
|
|
736
|
-
return isNaN(t) ? p.nan : p.number;
|
|
737
|
-
case "boolean":
|
|
738
|
-
return p.boolean;
|
|
739
|
-
case "function":
|
|
740
|
-
return p.function;
|
|
741
|
-
case "bigint":
|
|
742
|
-
return p.bigint;
|
|
743
|
-
case "symbol":
|
|
744
|
-
return p.symbol;
|
|
745
|
-
case "object":
|
|
746
|
-
return Array.isArray(t) ? p.array : t === null ? p.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? p.promise : typeof Map < "u" && t instanceof Map ? p.map : typeof Set < "u" && t instanceof Set ? p.set : typeof Date < "u" && t instanceof Date ? p.date : p.object;
|
|
747
|
-
default:
|
|
748
|
-
return p.unknown;
|
|
749
|
-
}
|
|
750
|
-
}, u = k.arrayToEnum([
|
|
751
|
-
"invalid_type",
|
|
752
|
-
"invalid_literal",
|
|
753
|
-
"custom",
|
|
754
|
-
"invalid_union",
|
|
755
|
-
"invalid_union_discriminator",
|
|
756
|
-
"invalid_enum_value",
|
|
757
|
-
"unrecognized_keys",
|
|
758
|
-
"invalid_arguments",
|
|
759
|
-
"invalid_return_type",
|
|
760
|
-
"invalid_date",
|
|
761
|
-
"invalid_string",
|
|
762
|
-
"too_small",
|
|
763
|
-
"too_big",
|
|
764
|
-
"invalid_intersection_types",
|
|
765
|
-
"not_multiple_of",
|
|
766
|
-
"not_finite"
|
|
767
|
-
]), Ur = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
768
|
-
class P extends Error {
|
|
769
|
-
get errors() {
|
|
770
|
-
return this.issues;
|
|
771
|
-
}
|
|
772
|
-
constructor(e) {
|
|
773
|
-
super(), this.issues = [], this.addIssue = (n) => {
|
|
774
|
-
this.issues = [...this.issues, n];
|
|
775
|
-
}, this.addIssues = (n = []) => {
|
|
776
|
-
this.issues = [...this.issues, ...n];
|
|
777
|
-
};
|
|
778
|
-
const r = new.target.prototype;
|
|
779
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
|
|
780
|
-
}
|
|
781
|
-
format(e) {
|
|
782
|
-
const r = e || function(a) {
|
|
783
|
-
return a.message;
|
|
784
|
-
}, n = { _errors: [] }, s = (a) => {
|
|
785
|
-
for (const i of a.issues)
|
|
786
|
-
if (i.code === "invalid_union")
|
|
787
|
-
i.unionErrors.map(s);
|
|
788
|
-
else if (i.code === "invalid_return_type")
|
|
789
|
-
s(i.returnTypeError);
|
|
790
|
-
else if (i.code === "invalid_arguments")
|
|
791
|
-
s(i.argumentsError);
|
|
792
|
-
else if (i.path.length === 0)
|
|
793
|
-
n._errors.push(r(i));
|
|
794
|
-
else {
|
|
795
|
-
let o = n, d = 0;
|
|
796
|
-
for (; d < i.path.length; ) {
|
|
797
|
-
const c = i.path[d];
|
|
798
|
-
d === i.path.length - 1 ? (o[c] = o[c] || { _errors: [] }, o[c]._errors.push(r(i))) : o[c] = o[c] || { _errors: [] }, o = o[c], d++;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
return s(this), n;
|
|
803
|
-
}
|
|
804
|
-
static assert(e) {
|
|
805
|
-
if (!(e instanceof P))
|
|
806
|
-
throw new Error(`Not a ZodError: ${e}`);
|
|
807
|
-
}
|
|
808
|
-
toString() {
|
|
809
|
-
return this.message;
|
|
810
|
-
}
|
|
811
|
-
get message() {
|
|
812
|
-
return JSON.stringify(this.issues, k.jsonStringifyReplacer, 2);
|
|
813
|
-
}
|
|
814
|
-
get isEmpty() {
|
|
815
|
-
return this.issues.length === 0;
|
|
816
|
-
}
|
|
817
|
-
flatten(e = (r) => r.message) {
|
|
818
|
-
const r = {}, n = [];
|
|
819
|
-
for (const s of this.issues)
|
|
820
|
-
s.path.length > 0 ? (r[s.path[0]] = r[s.path[0]] || [], r[s.path[0]].push(e(s))) : n.push(e(s));
|
|
821
|
-
return { formErrors: n, fieldErrors: r };
|
|
822
|
-
}
|
|
823
|
-
get formErrors() {
|
|
824
|
-
return this.flatten();
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
P.create = (t) => new P(t);
|
|
828
|
-
const me = (t, e) => {
|
|
829
|
-
let r;
|
|
830
|
-
switch (t.code) {
|
|
831
|
-
case u.invalid_type:
|
|
832
|
-
t.received === p.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
|
|
833
|
-
break;
|
|
834
|
-
case u.invalid_literal:
|
|
835
|
-
r = `Invalid literal value, expected ${JSON.stringify(t.expected, k.jsonStringifyReplacer)}`;
|
|
836
|
-
break;
|
|
837
|
-
case u.unrecognized_keys:
|
|
838
|
-
r = `Unrecognized key(s) in object: ${k.joinValues(t.keys, ", ")}`;
|
|
839
|
-
break;
|
|
840
|
-
case u.invalid_union:
|
|
841
|
-
r = "Invalid input";
|
|
842
|
-
break;
|
|
843
|
-
case u.invalid_union_discriminator:
|
|
844
|
-
r = `Invalid discriminator value. Expected ${k.joinValues(t.options)}`;
|
|
845
|
-
break;
|
|
846
|
-
case u.invalid_enum_value:
|
|
847
|
-
r = `Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;
|
|
848
|
-
break;
|
|
849
|
-
case u.invalid_arguments:
|
|
850
|
-
r = "Invalid function arguments";
|
|
851
|
-
break;
|
|
852
|
-
case u.invalid_return_type:
|
|
853
|
-
r = "Invalid function return type";
|
|
854
|
-
break;
|
|
855
|
-
case u.invalid_date:
|
|
856
|
-
r = "Invalid date";
|
|
857
|
-
break;
|
|
858
|
-
case u.invalid_string:
|
|
859
|
-
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : k.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
|
|
860
|
-
break;
|
|
861
|
-
case u.too_small:
|
|
862
|
-
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
|
|
863
|
-
break;
|
|
864
|
-
case u.too_big:
|
|
865
|
-
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
|
|
866
|
-
break;
|
|
867
|
-
case u.custom:
|
|
868
|
-
r = "Invalid input";
|
|
869
|
-
break;
|
|
870
|
-
case u.invalid_intersection_types:
|
|
871
|
-
r = "Intersection results could not be merged";
|
|
872
|
-
break;
|
|
873
|
-
case u.not_multiple_of:
|
|
874
|
-
r = `Number must be a multiple of ${t.multipleOf}`;
|
|
875
|
-
break;
|
|
876
|
-
case u.not_finite:
|
|
877
|
-
r = "Number must be finite";
|
|
878
|
-
break;
|
|
879
|
-
default:
|
|
880
|
-
r = e.defaultError, k.assertNever(t);
|
|
881
|
-
}
|
|
882
|
-
return { message: r };
|
|
883
|
-
};
|
|
884
|
-
let er = me;
|
|
885
|
-
function Hr(t) {
|
|
886
|
-
er = t;
|
|
887
|
-
}
|
|
888
|
-
function We() {
|
|
889
|
-
return er;
|
|
890
|
-
}
|
|
891
|
-
const Je = (t) => {
|
|
892
|
-
const { data: e, path: r, errorMaps: n, issueData: s } = t, a = [...r, ...s.path || []], i = {
|
|
893
|
-
...s,
|
|
894
|
-
path: a
|
|
895
|
-
};
|
|
896
|
-
if (s.message !== void 0)
|
|
897
|
-
return {
|
|
898
|
-
...s,
|
|
899
|
-
path: a,
|
|
900
|
-
message: s.message
|
|
901
|
-
};
|
|
902
|
-
let o = "";
|
|
903
|
-
const d = n.filter((c) => !!c).slice().reverse();
|
|
904
|
-
for (const c of d)
|
|
905
|
-
o = c(i, { data: e, defaultError: o }).message;
|
|
906
|
-
return {
|
|
907
|
-
...s,
|
|
908
|
-
path: a,
|
|
909
|
-
message: o
|
|
910
|
-
};
|
|
911
|
-
}, Br = [];
|
|
912
|
-
function f(t, e) {
|
|
913
|
-
const r = We(), n = Je({
|
|
914
|
-
issueData: e,
|
|
915
|
-
data: t.data,
|
|
916
|
-
path: t.path,
|
|
917
|
-
errorMaps: [
|
|
918
|
-
t.common.contextualErrorMap,
|
|
919
|
-
// contextual error map is first priority
|
|
920
|
-
t.schemaErrorMap,
|
|
921
|
-
// then schema-bound map if available
|
|
922
|
-
r,
|
|
923
|
-
// then global override map
|
|
924
|
-
r === me ? void 0 : me
|
|
925
|
-
// then global default map
|
|
926
|
-
].filter((s) => !!s)
|
|
927
|
-
});
|
|
928
|
-
t.common.issues.push(n);
|
|
929
|
-
}
|
|
930
|
-
class N {
|
|
931
|
-
constructor() {
|
|
932
|
-
this.value = "valid";
|
|
933
|
-
}
|
|
934
|
-
dirty() {
|
|
935
|
-
this.value === "valid" && (this.value = "dirty");
|
|
936
|
-
}
|
|
937
|
-
abort() {
|
|
938
|
-
this.value !== "aborted" && (this.value = "aborted");
|
|
939
|
-
}
|
|
940
|
-
static mergeArray(e, r) {
|
|
941
|
-
const n = [];
|
|
942
|
-
for (const s of r) {
|
|
943
|
-
if (s.status === "aborted")
|
|
944
|
-
return g;
|
|
945
|
-
s.status === "dirty" && e.dirty(), n.push(s.value);
|
|
946
|
-
}
|
|
947
|
-
return { status: e.value, value: n };
|
|
948
|
-
}
|
|
949
|
-
static async mergeObjectAsync(e, r) {
|
|
950
|
-
const n = [];
|
|
951
|
-
for (const s of r) {
|
|
952
|
-
const a = await s.key, i = await s.value;
|
|
953
|
-
n.push({
|
|
954
|
-
key: a,
|
|
955
|
-
value: i
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
return N.mergeObjectSync(e, n);
|
|
959
|
-
}
|
|
960
|
-
static mergeObjectSync(e, r) {
|
|
961
|
-
const n = {};
|
|
962
|
-
for (const s of r) {
|
|
963
|
-
const { key: a, value: i } = s;
|
|
964
|
-
if (a.status === "aborted" || i.status === "aborted")
|
|
965
|
-
return g;
|
|
966
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || s.alwaysSet) && (n[a.value] = i.value);
|
|
967
|
-
}
|
|
968
|
-
return { status: e.value, value: n };
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
const g = Object.freeze({
|
|
972
|
-
status: "aborted"
|
|
973
|
-
}), pe = (t) => ({ status: "dirty", value: t }), A = (t) => ({ status: "valid", value: t }), ut = (t) => t.status === "aborted", lt = (t) => t.status === "dirty", ae = (t) => t.status === "valid", Te = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
974
|
-
function Ye(t, e, r, n) {
|
|
975
|
-
if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
976
|
-
return e.get(t);
|
|
977
|
-
}
|
|
978
|
-
function tr(t, e, r, n, s) {
|
|
979
|
-
if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
980
|
-
return e.set(t, r), r;
|
|
981
|
-
}
|
|
982
|
-
var m;
|
|
983
|
-
(function(t) {
|
|
984
|
-
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
985
|
-
})(m || (m = {}));
|
|
986
|
-
var ke, xe;
|
|
987
|
-
class D {
|
|
988
|
-
constructor(e, r, n, s) {
|
|
989
|
-
this._cachedPath = [], this.parent = e, this.data = r, this._path = n, this._key = s;
|
|
990
|
-
}
|
|
991
|
-
get path() {
|
|
992
|
-
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
const xt = (t, e) => {
|
|
996
|
-
if (ae(e))
|
|
997
|
-
return { success: !0, data: e.value };
|
|
998
|
-
if (!t.common.issues.length)
|
|
999
|
-
throw new Error("Validation failed but no issues detected.");
|
|
1000
|
-
return {
|
|
1001
|
-
success: !1,
|
|
1002
|
-
get error() {
|
|
1003
|
-
if (this._error)
|
|
1004
|
-
return this._error;
|
|
1005
|
-
const r = new P(t.common.issues);
|
|
1006
|
-
return this._error = r, this._error;
|
|
1007
|
-
}
|
|
1008
|
-
};
|
|
1009
|
-
};
|
|
1010
|
-
function _(t) {
|
|
1011
|
-
if (!t)
|
|
1012
|
-
return {};
|
|
1013
|
-
const { errorMap: e, invalid_type_error: r, required_error: n, description: s } = t;
|
|
1014
|
-
if (e && (r || n))
|
|
1015
|
-
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1016
|
-
return e ? { errorMap: e, description: s } : { errorMap: (i, o) => {
|
|
1017
|
-
var d, c;
|
|
1018
|
-
const { message: l } = t;
|
|
1019
|
-
return i.code === "invalid_enum_value" ? { message: l ?? o.defaultError } : typeof o.data > "u" ? { message: (d = l ?? n) !== null && d !== void 0 ? d : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (c = l ?? r) !== null && c !== void 0 ? c : o.defaultError };
|
|
1020
|
-
}, description: s };
|
|
1021
|
-
}
|
|
1022
|
-
class b {
|
|
1023
|
-
get description() {
|
|
1024
|
-
return this._def.description;
|
|
1025
|
-
}
|
|
1026
|
-
_getType(e) {
|
|
1027
|
-
return U(e.data);
|
|
1028
|
-
}
|
|
1029
|
-
_getOrReturnCtx(e, r) {
|
|
1030
|
-
return r || {
|
|
1031
|
-
common: e.parent.common,
|
|
1032
|
-
data: e.data,
|
|
1033
|
-
parsedType: U(e.data),
|
|
1034
|
-
schemaErrorMap: this._def.errorMap,
|
|
1035
|
-
path: e.path,
|
|
1036
|
-
parent: e.parent
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
_processInputParams(e) {
|
|
1040
|
-
return {
|
|
1041
|
-
status: new N(),
|
|
1042
|
-
ctx: {
|
|
1043
|
-
common: e.parent.common,
|
|
1044
|
-
data: e.data,
|
|
1045
|
-
parsedType: U(e.data),
|
|
1046
|
-
schemaErrorMap: this._def.errorMap,
|
|
1047
|
-
path: e.path,
|
|
1048
|
-
parent: e.parent
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
_parseSync(e) {
|
|
1053
|
-
const r = this._parse(e);
|
|
1054
|
-
if (Te(r))
|
|
1055
|
-
throw new Error("Synchronous parse encountered promise.");
|
|
1056
|
-
return r;
|
|
1057
|
-
}
|
|
1058
|
-
_parseAsync(e) {
|
|
1059
|
-
const r = this._parse(e);
|
|
1060
|
-
return Promise.resolve(r);
|
|
1061
|
-
}
|
|
1062
|
-
parse(e, r) {
|
|
1063
|
-
const n = this.safeParse(e, r);
|
|
1064
|
-
if (n.success)
|
|
1065
|
-
return n.data;
|
|
1066
|
-
throw n.error;
|
|
1067
|
-
}
|
|
1068
|
-
safeParse(e, r) {
|
|
1069
|
-
var n;
|
|
1070
|
-
const s = {
|
|
1071
|
-
common: {
|
|
1072
|
-
issues: [],
|
|
1073
|
-
async: (n = r?.async) !== null && n !== void 0 ? n : !1,
|
|
1074
|
-
contextualErrorMap: r?.errorMap
|
|
1075
|
-
},
|
|
1076
|
-
path: r?.path || [],
|
|
1077
|
-
schemaErrorMap: this._def.errorMap,
|
|
1078
|
-
parent: null,
|
|
1079
|
-
data: e,
|
|
1080
|
-
parsedType: U(e)
|
|
1081
|
-
}, a = this._parseSync({ data: e, path: s.path, parent: s });
|
|
1082
|
-
return xt(s, a);
|
|
1083
|
-
}
|
|
1084
|
-
"~validate"(e) {
|
|
1085
|
-
var r, n;
|
|
1086
|
-
const s = {
|
|
1087
|
-
common: {
|
|
1088
|
-
issues: [],
|
|
1089
|
-
async: !!this["~standard"].async
|
|
1090
|
-
},
|
|
1091
|
-
path: [],
|
|
1092
|
-
schemaErrorMap: this._def.errorMap,
|
|
1093
|
-
parent: null,
|
|
1094
|
-
data: e,
|
|
1095
|
-
parsedType: U(e)
|
|
1096
|
-
};
|
|
1097
|
-
if (!this["~standard"].async)
|
|
1098
|
-
try {
|
|
1099
|
-
const a = this._parseSync({ data: e, path: [], parent: s });
|
|
1100
|
-
return ae(a) ? {
|
|
1101
|
-
value: a.value
|
|
1102
|
-
} : {
|
|
1103
|
-
issues: s.common.issues
|
|
1104
|
-
};
|
|
1105
|
-
} catch (a) {
|
|
1106
|
-
!((n = (r = a?.message) === null || r === void 0 ? void 0 : r.toLowerCase()) === null || n === void 0) && n.includes("encountered") && (this["~standard"].async = !0), s.common = {
|
|
1107
|
-
issues: [],
|
|
1108
|
-
async: !0
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
return this._parseAsync({ data: e, path: [], parent: s }).then((a) => ae(a) ? {
|
|
1112
|
-
value: a.value
|
|
1113
|
-
} : {
|
|
1114
|
-
issues: s.common.issues
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
async parseAsync(e, r) {
|
|
1118
|
-
const n = await this.safeParseAsync(e, r);
|
|
1119
|
-
if (n.success)
|
|
1120
|
-
return n.data;
|
|
1121
|
-
throw n.error;
|
|
1122
|
-
}
|
|
1123
|
-
async safeParseAsync(e, r) {
|
|
1124
|
-
const n = {
|
|
1125
|
-
common: {
|
|
1126
|
-
issues: [],
|
|
1127
|
-
contextualErrorMap: r?.errorMap,
|
|
1128
|
-
async: !0
|
|
1129
|
-
},
|
|
1130
|
-
path: r?.path || [],
|
|
1131
|
-
schemaErrorMap: this._def.errorMap,
|
|
1132
|
-
parent: null,
|
|
1133
|
-
data: e,
|
|
1134
|
-
parsedType: U(e)
|
|
1135
|
-
}, s = this._parse({ data: e, path: n.path, parent: n }), a = await (Te(s) ? s : Promise.resolve(s));
|
|
1136
|
-
return xt(n, a);
|
|
1137
|
-
}
|
|
1138
|
-
refine(e, r) {
|
|
1139
|
-
const n = (s) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(s) : r;
|
|
1140
|
-
return this._refinement((s, a) => {
|
|
1141
|
-
const i = e(s), o = () => a.addIssue({
|
|
1142
|
-
code: u.custom,
|
|
1143
|
-
...n(s)
|
|
1144
|
-
});
|
|
1145
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((d) => d ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
refinement(e, r) {
|
|
1149
|
-
return this._refinement((n, s) => e(n) ? !0 : (s.addIssue(typeof r == "function" ? r(n, s) : r), !1));
|
|
1150
|
-
}
|
|
1151
|
-
_refinement(e) {
|
|
1152
|
-
return new $({
|
|
1153
|
-
schema: this,
|
|
1154
|
-
typeName: y.ZodEffects,
|
|
1155
|
-
effect: { type: "refinement", refinement: e }
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
superRefine(e) {
|
|
1159
|
-
return this._refinement(e);
|
|
1160
|
-
}
|
|
1161
|
-
constructor(e) {
|
|
1162
|
-
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
1163
|
-
version: 1,
|
|
1164
|
-
vendor: "zod",
|
|
1165
|
-
validate: (r) => this["~validate"](r)
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
optional() {
|
|
1169
|
-
return F.create(this, this._def);
|
|
1170
|
-
}
|
|
1171
|
-
nullable() {
|
|
1172
|
-
return X.create(this, this._def);
|
|
1173
|
-
}
|
|
1174
|
-
nullish() {
|
|
1175
|
-
return this.nullable().optional();
|
|
1176
|
-
}
|
|
1177
|
-
array() {
|
|
1178
|
-
return Z.create(this);
|
|
1179
|
-
}
|
|
1180
|
-
promise() {
|
|
1181
|
-
return ge.create(this, this._def);
|
|
1182
|
-
}
|
|
1183
|
-
or(e) {
|
|
1184
|
-
return Re.create([this, e], this._def);
|
|
1185
|
-
}
|
|
1186
|
-
and(e) {
|
|
1187
|
-
return Ae.create(this, e, this._def);
|
|
1188
|
-
}
|
|
1189
|
-
transform(e) {
|
|
1190
|
-
return new $({
|
|
1191
|
-
..._(this._def),
|
|
1192
|
-
schema: this,
|
|
1193
|
-
typeName: y.ZodEffects,
|
|
1194
|
-
effect: { type: "transform", transform: e }
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
default(e) {
|
|
1198
|
-
const r = typeof e == "function" ? e : () => e;
|
|
1199
|
-
return new Ze({
|
|
1200
|
-
..._(this._def),
|
|
1201
|
-
innerType: this,
|
|
1202
|
-
defaultValue: r,
|
|
1203
|
-
typeName: y.ZodDefault
|
|
1204
|
-
});
|
|
1205
|
-
}
|
|
1206
|
-
brand() {
|
|
1207
|
-
return new vt({
|
|
1208
|
-
typeName: y.ZodBranded,
|
|
1209
|
-
type: this,
|
|
1210
|
-
..._(this._def)
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
catch(e) {
|
|
1214
|
-
const r = typeof e == "function" ? e : () => e;
|
|
1215
|
-
return new $e({
|
|
1216
|
-
..._(this._def),
|
|
1217
|
-
innerType: this,
|
|
1218
|
-
catchValue: r,
|
|
1219
|
-
typeName: y.ZodCatch
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
describe(e) {
|
|
1223
|
-
const r = this.constructor;
|
|
1224
|
-
return new r({
|
|
1225
|
-
...this._def,
|
|
1226
|
-
description: e
|
|
1227
|
-
});
|
|
1228
|
-
}
|
|
1229
|
-
pipe(e) {
|
|
1230
|
-
return Fe.create(this, e);
|
|
1231
|
-
}
|
|
1232
|
-
readonly() {
|
|
1233
|
-
return Me.create(this);
|
|
1234
|
-
}
|
|
1235
|
-
isOptional() {
|
|
1236
|
-
return this.safeParse(void 0).success;
|
|
1237
|
-
}
|
|
1238
|
-
isNullable() {
|
|
1239
|
-
return this.safeParse(null).success;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
const Wr = /^c[^\s-]{8,}$/i, Jr = /^[0-9a-z]+$/, Yr = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Gr = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Kr = /^[a-z0-9_-]{21}$/i, Xr = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Qr = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, en = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, tn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1243
|
-
let st;
|
|
1244
|
-
const rn = /^(?:(?: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])$/, nn = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, sn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, an = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, on = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, dn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, rr = "((\\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])))", cn = new RegExp(`^${rr}$`);
|
|
1245
|
-
function nr(t) {
|
|
1246
|
-
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
1247
|
-
return t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
1248
|
-
}
|
|
1249
|
-
function un(t) {
|
|
1250
|
-
return new RegExp(`^${nr(t)}$`);
|
|
1251
|
-
}
|
|
1252
|
-
function sr(t) {
|
|
1253
|
-
let e = `${rr}T${nr(t)}`;
|
|
1254
|
-
const r = [];
|
|
1255
|
-
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
|
|
1256
|
-
}
|
|
1257
|
-
function ln(t, e) {
|
|
1258
|
-
return !!((e === "v4" || !e) && rn.test(t) || (e === "v6" || !e) && sn.test(t));
|
|
1259
|
-
}
|
|
1260
|
-
function fn(t, e) {
|
|
1261
|
-
if (!Xr.test(t))
|
|
1262
|
-
return !1;
|
|
1263
|
-
try {
|
|
1264
|
-
const [r] = t.split("."), n = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), s = JSON.parse(atob(n));
|
|
1265
|
-
return !(typeof s != "object" || s === null || !s.typ || !s.alg || e && s.alg !== e);
|
|
1266
|
-
} catch {
|
|
1267
|
-
return !1;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
function pn(t, e) {
|
|
1271
|
-
return !!((e === "v4" || !e) && nn.test(t) || (e === "v6" || !e) && an.test(t));
|
|
1272
|
-
}
|
|
1273
|
-
class j extends b {
|
|
1274
|
-
_parse(e) {
|
|
1275
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
|
|
1276
|
-
const a = this._getOrReturnCtx(e);
|
|
1277
|
-
return f(a, {
|
|
1278
|
-
code: u.invalid_type,
|
|
1279
|
-
expected: p.string,
|
|
1280
|
-
received: a.parsedType
|
|
1281
|
-
}), g;
|
|
1282
|
-
}
|
|
1283
|
-
const n = new N();
|
|
1284
|
-
let s;
|
|
1285
|
-
for (const a of this._def.checks)
|
|
1286
|
-
if (a.kind === "min")
|
|
1287
|
-
e.data.length < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1288
|
-
code: u.too_small,
|
|
1289
|
-
minimum: a.value,
|
|
1290
|
-
type: "string",
|
|
1291
|
-
inclusive: !0,
|
|
1292
|
-
exact: !1,
|
|
1293
|
-
message: a.message
|
|
1294
|
-
}), n.dirty());
|
|
1295
|
-
else if (a.kind === "max")
|
|
1296
|
-
e.data.length > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1297
|
-
code: u.too_big,
|
|
1298
|
-
maximum: a.value,
|
|
1299
|
-
type: "string",
|
|
1300
|
-
inclusive: !0,
|
|
1301
|
-
exact: !1,
|
|
1302
|
-
message: a.message
|
|
1303
|
-
}), n.dirty());
|
|
1304
|
-
else if (a.kind === "length") {
|
|
1305
|
-
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
1306
|
-
(i || o) && (s = this._getOrReturnCtx(e, s), i ? f(s, {
|
|
1307
|
-
code: u.too_big,
|
|
1308
|
-
maximum: a.value,
|
|
1309
|
-
type: "string",
|
|
1310
|
-
inclusive: !0,
|
|
1311
|
-
exact: !0,
|
|
1312
|
-
message: a.message
|
|
1313
|
-
}) : o && f(s, {
|
|
1314
|
-
code: u.too_small,
|
|
1315
|
-
minimum: a.value,
|
|
1316
|
-
type: "string",
|
|
1317
|
-
inclusive: !0,
|
|
1318
|
-
exact: !0,
|
|
1319
|
-
message: a.message
|
|
1320
|
-
}), n.dirty());
|
|
1321
|
-
} else if (a.kind === "email")
|
|
1322
|
-
en.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1323
|
-
validation: "email",
|
|
1324
|
-
code: u.invalid_string,
|
|
1325
|
-
message: a.message
|
|
1326
|
-
}), n.dirty());
|
|
1327
|
-
else if (a.kind === "emoji")
|
|
1328
|
-
st || (st = new RegExp(tn, "u")), st.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1329
|
-
validation: "emoji",
|
|
1330
|
-
code: u.invalid_string,
|
|
1331
|
-
message: a.message
|
|
1332
|
-
}), n.dirty());
|
|
1333
|
-
else if (a.kind === "uuid")
|
|
1334
|
-
Gr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1335
|
-
validation: "uuid",
|
|
1336
|
-
code: u.invalid_string,
|
|
1337
|
-
message: a.message
|
|
1338
|
-
}), n.dirty());
|
|
1339
|
-
else if (a.kind === "nanoid")
|
|
1340
|
-
Kr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1341
|
-
validation: "nanoid",
|
|
1342
|
-
code: u.invalid_string,
|
|
1343
|
-
message: a.message
|
|
1344
|
-
}), n.dirty());
|
|
1345
|
-
else if (a.kind === "cuid")
|
|
1346
|
-
Wr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1347
|
-
validation: "cuid",
|
|
1348
|
-
code: u.invalid_string,
|
|
1349
|
-
message: a.message
|
|
1350
|
-
}), n.dirty());
|
|
1351
|
-
else if (a.kind === "cuid2")
|
|
1352
|
-
Jr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1353
|
-
validation: "cuid2",
|
|
1354
|
-
code: u.invalid_string,
|
|
1355
|
-
message: a.message
|
|
1356
|
-
}), n.dirty());
|
|
1357
|
-
else if (a.kind === "ulid")
|
|
1358
|
-
Yr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1359
|
-
validation: "ulid",
|
|
1360
|
-
code: u.invalid_string,
|
|
1361
|
-
message: a.message
|
|
1362
|
-
}), n.dirty());
|
|
1363
|
-
else if (a.kind === "url")
|
|
1364
|
-
try {
|
|
1365
|
-
new URL(e.data);
|
|
1366
|
-
} catch {
|
|
1367
|
-
s = this._getOrReturnCtx(e, s), f(s, {
|
|
1368
|
-
validation: "url",
|
|
1369
|
-
code: u.invalid_string,
|
|
1370
|
-
message: a.message
|
|
1371
|
-
}), n.dirty();
|
|
1372
|
-
}
|
|
1373
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1374
|
-
validation: "regex",
|
|
1375
|
-
code: u.invalid_string,
|
|
1376
|
-
message: a.message
|
|
1377
|
-
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1378
|
-
code: u.invalid_string,
|
|
1379
|
-
validation: { includes: a.value, position: a.position },
|
|
1380
|
-
message: a.message
|
|
1381
|
-
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1382
|
-
code: u.invalid_string,
|
|
1383
|
-
validation: { startsWith: a.value },
|
|
1384
|
-
message: a.message
|
|
1385
|
-
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1386
|
-
code: u.invalid_string,
|
|
1387
|
-
validation: { endsWith: a.value },
|
|
1388
|
-
message: a.message
|
|
1389
|
-
}), n.dirty()) : a.kind === "datetime" ? sr(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1390
|
-
code: u.invalid_string,
|
|
1391
|
-
validation: "datetime",
|
|
1392
|
-
message: a.message
|
|
1393
|
-
}), n.dirty()) : a.kind === "date" ? cn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1394
|
-
code: u.invalid_string,
|
|
1395
|
-
validation: "date",
|
|
1396
|
-
message: a.message
|
|
1397
|
-
}), n.dirty()) : a.kind === "time" ? un(a).test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1398
|
-
code: u.invalid_string,
|
|
1399
|
-
validation: "time",
|
|
1400
|
-
message: a.message
|
|
1401
|
-
}), n.dirty()) : a.kind === "duration" ? Qr.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1402
|
-
validation: "duration",
|
|
1403
|
-
code: u.invalid_string,
|
|
1404
|
-
message: a.message
|
|
1405
|
-
}), n.dirty()) : a.kind === "ip" ? ln(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1406
|
-
validation: "ip",
|
|
1407
|
-
code: u.invalid_string,
|
|
1408
|
-
message: a.message
|
|
1409
|
-
}), n.dirty()) : a.kind === "jwt" ? fn(e.data, a.alg) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1410
|
-
validation: "jwt",
|
|
1411
|
-
code: u.invalid_string,
|
|
1412
|
-
message: a.message
|
|
1413
|
-
}), n.dirty()) : a.kind === "cidr" ? pn(e.data, a.version) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1414
|
-
validation: "cidr",
|
|
1415
|
-
code: u.invalid_string,
|
|
1416
|
-
message: a.message
|
|
1417
|
-
}), n.dirty()) : a.kind === "base64" ? on.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1418
|
-
validation: "base64",
|
|
1419
|
-
code: u.invalid_string,
|
|
1420
|
-
message: a.message
|
|
1421
|
-
}), n.dirty()) : a.kind === "base64url" ? dn.test(e.data) || (s = this._getOrReturnCtx(e, s), f(s, {
|
|
1422
|
-
validation: "base64url",
|
|
1423
|
-
code: u.invalid_string,
|
|
1424
|
-
message: a.message
|
|
1425
|
-
}), n.dirty()) : k.assertNever(a);
|
|
1426
|
-
return { status: n.value, value: e.data };
|
|
1427
|
-
}
|
|
1428
|
-
_regex(e, r, n) {
|
|
1429
|
-
return this.refinement((s) => e.test(s), {
|
|
1430
|
-
validation: r,
|
|
1431
|
-
code: u.invalid_string,
|
|
1432
|
-
...m.errToObj(n)
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
_addCheck(e) {
|
|
1436
|
-
return new j({
|
|
1437
|
-
...this._def,
|
|
1438
|
-
checks: [...this._def.checks, e]
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
email(e) {
|
|
1442
|
-
return this._addCheck({ kind: "email", ...m.errToObj(e) });
|
|
1443
|
-
}
|
|
1444
|
-
url(e) {
|
|
1445
|
-
return this._addCheck({ kind: "url", ...m.errToObj(e) });
|
|
1446
|
-
}
|
|
1447
|
-
emoji(e) {
|
|
1448
|
-
return this._addCheck({ kind: "emoji", ...m.errToObj(e) });
|
|
1449
|
-
}
|
|
1450
|
-
uuid(e) {
|
|
1451
|
-
return this._addCheck({ kind: "uuid", ...m.errToObj(e) });
|
|
1452
|
-
}
|
|
1453
|
-
nanoid(e) {
|
|
1454
|
-
return this._addCheck({ kind: "nanoid", ...m.errToObj(e) });
|
|
1455
|
-
}
|
|
1456
|
-
cuid(e) {
|
|
1457
|
-
return this._addCheck({ kind: "cuid", ...m.errToObj(e) });
|
|
1458
|
-
}
|
|
1459
|
-
cuid2(e) {
|
|
1460
|
-
return this._addCheck({ kind: "cuid2", ...m.errToObj(e) });
|
|
1461
|
-
}
|
|
1462
|
-
ulid(e) {
|
|
1463
|
-
return this._addCheck({ kind: "ulid", ...m.errToObj(e) });
|
|
1464
|
-
}
|
|
1465
|
-
base64(e) {
|
|
1466
|
-
return this._addCheck({ kind: "base64", ...m.errToObj(e) });
|
|
1467
|
-
}
|
|
1468
|
-
base64url(e) {
|
|
1469
|
-
return this._addCheck({
|
|
1470
|
-
kind: "base64url",
|
|
1471
|
-
...m.errToObj(e)
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
jwt(e) {
|
|
1475
|
-
return this._addCheck({ kind: "jwt", ...m.errToObj(e) });
|
|
1476
|
-
}
|
|
1477
|
-
ip(e) {
|
|
1478
|
-
return this._addCheck({ kind: "ip", ...m.errToObj(e) });
|
|
1479
|
-
}
|
|
1480
|
-
cidr(e) {
|
|
1481
|
-
return this._addCheck({ kind: "cidr", ...m.errToObj(e) });
|
|
1482
|
-
}
|
|
1483
|
-
datetime(e) {
|
|
1484
|
-
var r, n;
|
|
1485
|
-
return typeof e == "string" ? this._addCheck({
|
|
1486
|
-
kind: "datetime",
|
|
1487
|
-
precision: null,
|
|
1488
|
-
offset: !1,
|
|
1489
|
-
local: !1,
|
|
1490
|
-
message: e
|
|
1491
|
-
}) : this._addCheck({
|
|
1492
|
-
kind: "datetime",
|
|
1493
|
-
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1494
|
-
offset: (r = e?.offset) !== null && r !== void 0 ? r : !1,
|
|
1495
|
-
local: (n = e?.local) !== null && n !== void 0 ? n : !1,
|
|
1496
|
-
...m.errToObj(e?.message)
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
date(e) {
|
|
1500
|
-
return this._addCheck({ kind: "date", message: e });
|
|
1501
|
-
}
|
|
1502
|
-
time(e) {
|
|
1503
|
-
return typeof e == "string" ? this._addCheck({
|
|
1504
|
-
kind: "time",
|
|
1505
|
-
precision: null,
|
|
1506
|
-
message: e
|
|
1507
|
-
}) : this._addCheck({
|
|
1508
|
-
kind: "time",
|
|
1509
|
-
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1510
|
-
...m.errToObj(e?.message)
|
|
1511
|
-
});
|
|
1512
|
-
}
|
|
1513
|
-
duration(e) {
|
|
1514
|
-
return this._addCheck({ kind: "duration", ...m.errToObj(e) });
|
|
1515
|
-
}
|
|
1516
|
-
regex(e, r) {
|
|
1517
|
-
return this._addCheck({
|
|
1518
|
-
kind: "regex",
|
|
1519
|
-
regex: e,
|
|
1520
|
-
...m.errToObj(r)
|
|
1521
|
-
});
|
|
1522
|
-
}
|
|
1523
|
-
includes(e, r) {
|
|
1524
|
-
return this._addCheck({
|
|
1525
|
-
kind: "includes",
|
|
1526
|
-
value: e,
|
|
1527
|
-
position: r?.position,
|
|
1528
|
-
...m.errToObj(r?.message)
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
startsWith(e, r) {
|
|
1532
|
-
return this._addCheck({
|
|
1533
|
-
kind: "startsWith",
|
|
1534
|
-
value: e,
|
|
1535
|
-
...m.errToObj(r)
|
|
1536
|
-
});
|
|
1537
|
-
}
|
|
1538
|
-
endsWith(e, r) {
|
|
1539
|
-
return this._addCheck({
|
|
1540
|
-
kind: "endsWith",
|
|
1541
|
-
value: e,
|
|
1542
|
-
...m.errToObj(r)
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
min(e, r) {
|
|
1546
|
-
return this._addCheck({
|
|
1547
|
-
kind: "min",
|
|
1548
|
-
value: e,
|
|
1549
|
-
...m.errToObj(r)
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
max(e, r) {
|
|
1553
|
-
return this._addCheck({
|
|
1554
|
-
kind: "max",
|
|
1555
|
-
value: e,
|
|
1556
|
-
...m.errToObj(r)
|
|
1557
|
-
});
|
|
1558
|
-
}
|
|
1559
|
-
length(e, r) {
|
|
1560
|
-
return this._addCheck({
|
|
1561
|
-
kind: "length",
|
|
1562
|
-
value: e,
|
|
1563
|
-
...m.errToObj(r)
|
|
1564
|
-
});
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Equivalent to `.min(1)`
|
|
1568
|
-
*/
|
|
1569
|
-
nonempty(e) {
|
|
1570
|
-
return this.min(1, m.errToObj(e));
|
|
1571
|
-
}
|
|
1572
|
-
trim() {
|
|
1573
|
-
return new j({
|
|
1574
|
-
...this._def,
|
|
1575
|
-
checks: [...this._def.checks, { kind: "trim" }]
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1578
|
-
toLowerCase() {
|
|
1579
|
-
return new j({
|
|
1580
|
-
...this._def,
|
|
1581
|
-
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
toUpperCase() {
|
|
1585
|
-
return new j({
|
|
1586
|
-
...this._def,
|
|
1587
|
-
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1588
|
-
});
|
|
1589
|
-
}
|
|
1590
|
-
get isDatetime() {
|
|
1591
|
-
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1592
|
-
}
|
|
1593
|
-
get isDate() {
|
|
1594
|
-
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1595
|
-
}
|
|
1596
|
-
get isTime() {
|
|
1597
|
-
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1598
|
-
}
|
|
1599
|
-
get isDuration() {
|
|
1600
|
-
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1601
|
-
}
|
|
1602
|
-
get isEmail() {
|
|
1603
|
-
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1604
|
-
}
|
|
1605
|
-
get isURL() {
|
|
1606
|
-
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1607
|
-
}
|
|
1608
|
-
get isEmoji() {
|
|
1609
|
-
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1610
|
-
}
|
|
1611
|
-
get isUUID() {
|
|
1612
|
-
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1613
|
-
}
|
|
1614
|
-
get isNANOID() {
|
|
1615
|
-
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1616
|
-
}
|
|
1617
|
-
get isCUID() {
|
|
1618
|
-
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1619
|
-
}
|
|
1620
|
-
get isCUID2() {
|
|
1621
|
-
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1622
|
-
}
|
|
1623
|
-
get isULID() {
|
|
1624
|
-
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1625
|
-
}
|
|
1626
|
-
get isIP() {
|
|
1627
|
-
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1628
|
-
}
|
|
1629
|
-
get isCIDR() {
|
|
1630
|
-
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1631
|
-
}
|
|
1632
|
-
get isBase64() {
|
|
1633
|
-
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1634
|
-
}
|
|
1635
|
-
get isBase64url() {
|
|
1636
|
-
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1637
|
-
}
|
|
1638
|
-
get minLength() {
|
|
1639
|
-
let e = null;
|
|
1640
|
-
for (const r of this._def.checks)
|
|
1641
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1642
|
-
return e;
|
|
1643
|
-
}
|
|
1644
|
-
get maxLength() {
|
|
1645
|
-
let e = null;
|
|
1646
|
-
for (const r of this._def.checks)
|
|
1647
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1648
|
-
return e;
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
j.create = (t) => {
|
|
1652
|
-
var e;
|
|
1653
|
-
return new j({
|
|
1654
|
-
checks: [],
|
|
1655
|
-
typeName: y.ZodString,
|
|
1656
|
-
coerce: (e = t?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1657
|
-
..._(t)
|
|
1658
|
-
});
|
|
1659
|
-
};
|
|
1660
|
-
function hn(t, e) {
|
|
1661
|
-
const r = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, s = r > n ? r : n, a = parseInt(t.toFixed(s).replace(".", "")), i = parseInt(e.toFixed(s).replace(".", ""));
|
|
1662
|
-
return a % i / Math.pow(10, s);
|
|
1663
|
-
}
|
|
1664
|
-
class Y extends b {
|
|
1665
|
-
constructor() {
|
|
1666
|
-
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1667
|
-
}
|
|
1668
|
-
_parse(e) {
|
|
1669
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
|
|
1670
|
-
const a = this._getOrReturnCtx(e);
|
|
1671
|
-
return f(a, {
|
|
1672
|
-
code: u.invalid_type,
|
|
1673
|
-
expected: p.number,
|
|
1674
|
-
received: a.parsedType
|
|
1675
|
-
}), g;
|
|
1676
|
-
}
|
|
1677
|
-
let n;
|
|
1678
|
-
const s = new N();
|
|
1679
|
-
for (const a of this._def.checks)
|
|
1680
|
-
a.kind === "int" ? k.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1681
|
-
code: u.invalid_type,
|
|
1682
|
-
expected: "integer",
|
|
1683
|
-
received: "float",
|
|
1684
|
-
message: a.message
|
|
1685
|
-
}), s.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1686
|
-
code: u.too_small,
|
|
1687
|
-
minimum: a.value,
|
|
1688
|
-
type: "number",
|
|
1689
|
-
inclusive: a.inclusive,
|
|
1690
|
-
exact: !1,
|
|
1691
|
-
message: a.message
|
|
1692
|
-
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1693
|
-
code: u.too_big,
|
|
1694
|
-
maximum: a.value,
|
|
1695
|
-
type: "number",
|
|
1696
|
-
inclusive: a.inclusive,
|
|
1697
|
-
exact: !1,
|
|
1698
|
-
message: a.message
|
|
1699
|
-
}), s.dirty()) : a.kind === "multipleOf" ? hn(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1700
|
-
code: u.not_multiple_of,
|
|
1701
|
-
multipleOf: a.value,
|
|
1702
|
-
message: a.message
|
|
1703
|
-
}), s.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1704
|
-
code: u.not_finite,
|
|
1705
|
-
message: a.message
|
|
1706
|
-
}), s.dirty()) : k.assertNever(a);
|
|
1707
|
-
return { status: s.value, value: e.data };
|
|
1708
|
-
}
|
|
1709
|
-
gte(e, r) {
|
|
1710
|
-
return this.setLimit("min", e, !0, m.toString(r));
|
|
1711
|
-
}
|
|
1712
|
-
gt(e, r) {
|
|
1713
|
-
return this.setLimit("min", e, !1, m.toString(r));
|
|
1714
|
-
}
|
|
1715
|
-
lte(e, r) {
|
|
1716
|
-
return this.setLimit("max", e, !0, m.toString(r));
|
|
1717
|
-
}
|
|
1718
|
-
lt(e, r) {
|
|
1719
|
-
return this.setLimit("max", e, !1, m.toString(r));
|
|
1720
|
-
}
|
|
1721
|
-
setLimit(e, r, n, s) {
|
|
1722
|
-
return new Y({
|
|
1723
|
-
...this._def,
|
|
1724
|
-
checks: [
|
|
1725
|
-
...this._def.checks,
|
|
1726
|
-
{
|
|
1727
|
-
kind: e,
|
|
1728
|
-
value: r,
|
|
1729
|
-
inclusive: n,
|
|
1730
|
-
message: m.toString(s)
|
|
1731
|
-
}
|
|
1732
|
-
]
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
_addCheck(e) {
|
|
1736
|
-
return new Y({
|
|
1737
|
-
...this._def,
|
|
1738
|
-
checks: [...this._def.checks, e]
|
|
1739
|
-
});
|
|
1740
|
-
}
|
|
1741
|
-
int(e) {
|
|
1742
|
-
return this._addCheck({
|
|
1743
|
-
kind: "int",
|
|
1744
|
-
message: m.toString(e)
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
positive(e) {
|
|
1748
|
-
return this._addCheck({
|
|
1749
|
-
kind: "min",
|
|
1750
|
-
value: 0,
|
|
1751
|
-
inclusive: !1,
|
|
1752
|
-
message: m.toString(e)
|
|
1753
|
-
});
|
|
1754
|
-
}
|
|
1755
|
-
negative(e) {
|
|
1756
|
-
return this._addCheck({
|
|
1757
|
-
kind: "max",
|
|
1758
|
-
value: 0,
|
|
1759
|
-
inclusive: !1,
|
|
1760
|
-
message: m.toString(e)
|
|
1761
|
-
});
|
|
1762
|
-
}
|
|
1763
|
-
nonpositive(e) {
|
|
1764
|
-
return this._addCheck({
|
|
1765
|
-
kind: "max",
|
|
1766
|
-
value: 0,
|
|
1767
|
-
inclusive: !0,
|
|
1768
|
-
message: m.toString(e)
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
nonnegative(e) {
|
|
1772
|
-
return this._addCheck({
|
|
1773
|
-
kind: "min",
|
|
1774
|
-
value: 0,
|
|
1775
|
-
inclusive: !0,
|
|
1776
|
-
message: m.toString(e)
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1779
|
-
multipleOf(e, r) {
|
|
1780
|
-
return this._addCheck({
|
|
1781
|
-
kind: "multipleOf",
|
|
1782
|
-
value: e,
|
|
1783
|
-
message: m.toString(r)
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
finite(e) {
|
|
1787
|
-
return this._addCheck({
|
|
1788
|
-
kind: "finite",
|
|
1789
|
-
message: m.toString(e)
|
|
1790
|
-
});
|
|
1791
|
-
}
|
|
1792
|
-
safe(e) {
|
|
1793
|
-
return this._addCheck({
|
|
1794
|
-
kind: "min",
|
|
1795
|
-
inclusive: !0,
|
|
1796
|
-
value: Number.MIN_SAFE_INTEGER,
|
|
1797
|
-
message: m.toString(e)
|
|
1798
|
-
})._addCheck({
|
|
1799
|
-
kind: "max",
|
|
1800
|
-
inclusive: !0,
|
|
1801
|
-
value: Number.MAX_SAFE_INTEGER,
|
|
1802
|
-
message: m.toString(e)
|
|
1803
|
-
});
|
|
1804
|
-
}
|
|
1805
|
-
get minValue() {
|
|
1806
|
-
let e = null;
|
|
1807
|
-
for (const r of this._def.checks)
|
|
1808
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1809
|
-
return e;
|
|
1810
|
-
}
|
|
1811
|
-
get maxValue() {
|
|
1812
|
-
let e = null;
|
|
1813
|
-
for (const r of this._def.checks)
|
|
1814
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1815
|
-
return e;
|
|
1816
|
-
}
|
|
1817
|
-
get isInt() {
|
|
1818
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && k.isInteger(e.value));
|
|
1819
|
-
}
|
|
1820
|
-
get isFinite() {
|
|
1821
|
-
let e = null, r = null;
|
|
1822
|
-
for (const n of this._def.checks) {
|
|
1823
|
-
if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
|
|
1824
|
-
return !0;
|
|
1825
|
-
n.kind === "min" ? (r === null || n.value > r) && (r = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1826
|
-
}
|
|
1827
|
-
return Number.isFinite(r) && Number.isFinite(e);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
Y.create = (t) => new Y({
|
|
1831
|
-
checks: [],
|
|
1832
|
-
typeName: y.ZodNumber,
|
|
1833
|
-
coerce: t?.coerce || !1,
|
|
1834
|
-
..._(t)
|
|
1835
|
-
});
|
|
1836
|
-
class G extends b {
|
|
1837
|
-
constructor() {
|
|
1838
|
-
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1839
|
-
}
|
|
1840
|
-
_parse(e) {
|
|
1841
|
-
if (this._def.coerce)
|
|
1842
|
-
try {
|
|
1843
|
-
e.data = BigInt(e.data);
|
|
1844
|
-
} catch {
|
|
1845
|
-
return this._getInvalidInput(e);
|
|
1846
|
-
}
|
|
1847
|
-
if (this._getType(e) !== p.bigint)
|
|
1848
|
-
return this._getInvalidInput(e);
|
|
1849
|
-
let n;
|
|
1850
|
-
const s = new N();
|
|
1851
|
-
for (const a of this._def.checks)
|
|
1852
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1853
|
-
code: u.too_small,
|
|
1854
|
-
type: "bigint",
|
|
1855
|
-
minimum: a.value,
|
|
1856
|
-
inclusive: a.inclusive,
|
|
1857
|
-
message: a.message
|
|
1858
|
-
}), s.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1859
|
-
code: u.too_big,
|
|
1860
|
-
type: "bigint",
|
|
1861
|
-
maximum: a.value,
|
|
1862
|
-
inclusive: a.inclusive,
|
|
1863
|
-
message: a.message
|
|
1864
|
-
}), s.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1865
|
-
code: u.not_multiple_of,
|
|
1866
|
-
multipleOf: a.value,
|
|
1867
|
-
message: a.message
|
|
1868
|
-
}), s.dirty()) : k.assertNever(a);
|
|
1869
|
-
return { status: s.value, value: e.data };
|
|
1870
|
-
}
|
|
1871
|
-
_getInvalidInput(e) {
|
|
1872
|
-
const r = this._getOrReturnCtx(e);
|
|
1873
|
-
return f(r, {
|
|
1874
|
-
code: u.invalid_type,
|
|
1875
|
-
expected: p.bigint,
|
|
1876
|
-
received: r.parsedType
|
|
1877
|
-
}), g;
|
|
1878
|
-
}
|
|
1879
|
-
gte(e, r) {
|
|
1880
|
-
return this.setLimit("min", e, !0, m.toString(r));
|
|
1881
|
-
}
|
|
1882
|
-
gt(e, r) {
|
|
1883
|
-
return this.setLimit("min", e, !1, m.toString(r));
|
|
1884
|
-
}
|
|
1885
|
-
lte(e, r) {
|
|
1886
|
-
return this.setLimit("max", e, !0, m.toString(r));
|
|
1887
|
-
}
|
|
1888
|
-
lt(e, r) {
|
|
1889
|
-
return this.setLimit("max", e, !1, m.toString(r));
|
|
1890
|
-
}
|
|
1891
|
-
setLimit(e, r, n, s) {
|
|
1892
|
-
return new G({
|
|
1893
|
-
...this._def,
|
|
1894
|
-
checks: [
|
|
1895
|
-
...this._def.checks,
|
|
1896
|
-
{
|
|
1897
|
-
kind: e,
|
|
1898
|
-
value: r,
|
|
1899
|
-
inclusive: n,
|
|
1900
|
-
message: m.toString(s)
|
|
1901
|
-
}
|
|
1902
|
-
]
|
|
1903
|
-
});
|
|
1904
|
-
}
|
|
1905
|
-
_addCheck(e) {
|
|
1906
|
-
return new G({
|
|
1907
|
-
...this._def,
|
|
1908
|
-
checks: [...this._def.checks, e]
|
|
1909
|
-
});
|
|
1910
|
-
}
|
|
1911
|
-
positive(e) {
|
|
1912
|
-
return this._addCheck({
|
|
1913
|
-
kind: "min",
|
|
1914
|
-
value: BigInt(0),
|
|
1915
|
-
inclusive: !1,
|
|
1916
|
-
message: m.toString(e)
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
negative(e) {
|
|
1920
|
-
return this._addCheck({
|
|
1921
|
-
kind: "max",
|
|
1922
|
-
value: BigInt(0),
|
|
1923
|
-
inclusive: !1,
|
|
1924
|
-
message: m.toString(e)
|
|
1925
|
-
});
|
|
1926
|
-
}
|
|
1927
|
-
nonpositive(e) {
|
|
1928
|
-
return this._addCheck({
|
|
1929
|
-
kind: "max",
|
|
1930
|
-
value: BigInt(0),
|
|
1931
|
-
inclusive: !0,
|
|
1932
|
-
message: m.toString(e)
|
|
1933
|
-
});
|
|
1934
|
-
}
|
|
1935
|
-
nonnegative(e) {
|
|
1936
|
-
return this._addCheck({
|
|
1937
|
-
kind: "min",
|
|
1938
|
-
value: BigInt(0),
|
|
1939
|
-
inclusive: !0,
|
|
1940
|
-
message: m.toString(e)
|
|
1941
|
-
});
|
|
1942
|
-
}
|
|
1943
|
-
multipleOf(e, r) {
|
|
1944
|
-
return this._addCheck({
|
|
1945
|
-
kind: "multipleOf",
|
|
1946
|
-
value: e,
|
|
1947
|
-
message: m.toString(r)
|
|
1948
|
-
});
|
|
1949
|
-
}
|
|
1950
|
-
get minValue() {
|
|
1951
|
-
let e = null;
|
|
1952
|
-
for (const r of this._def.checks)
|
|
1953
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1954
|
-
return e;
|
|
1955
|
-
}
|
|
1956
|
-
get maxValue() {
|
|
1957
|
-
let e = null;
|
|
1958
|
-
for (const r of this._def.checks)
|
|
1959
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1960
|
-
return e;
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
G.create = (t) => {
|
|
1964
|
-
var e;
|
|
1965
|
-
return new G({
|
|
1966
|
-
checks: [],
|
|
1967
|
-
typeName: y.ZodBigInt,
|
|
1968
|
-
coerce: (e = t?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1969
|
-
..._(t)
|
|
1970
|
-
});
|
|
1971
|
-
};
|
|
1972
|
-
class Ee extends b {
|
|
1973
|
-
_parse(e) {
|
|
1974
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
1975
|
-
const n = this._getOrReturnCtx(e);
|
|
1976
|
-
return f(n, {
|
|
1977
|
-
code: u.invalid_type,
|
|
1978
|
-
expected: p.boolean,
|
|
1979
|
-
received: n.parsedType
|
|
1980
|
-
}), g;
|
|
1981
|
-
}
|
|
1982
|
-
return A(e.data);
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
Ee.create = (t) => new Ee({
|
|
1986
|
-
typeName: y.ZodBoolean,
|
|
1987
|
-
coerce: t?.coerce || !1,
|
|
1988
|
-
..._(t)
|
|
1989
|
-
});
|
|
1990
|
-
class ie extends b {
|
|
1991
|
-
_parse(e) {
|
|
1992
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1993
|
-
const a = this._getOrReturnCtx(e);
|
|
1994
|
-
return f(a, {
|
|
1995
|
-
code: u.invalid_type,
|
|
1996
|
-
expected: p.date,
|
|
1997
|
-
received: a.parsedType
|
|
1998
|
-
}), g;
|
|
1999
|
-
}
|
|
2000
|
-
if (isNaN(e.data.getTime())) {
|
|
2001
|
-
const a = this._getOrReturnCtx(e);
|
|
2002
|
-
return f(a, {
|
|
2003
|
-
code: u.invalid_date
|
|
2004
|
-
}), g;
|
|
2005
|
-
}
|
|
2006
|
-
const n = new N();
|
|
2007
|
-
let s;
|
|
2008
|
-
for (const a of this._def.checks)
|
|
2009
|
-
a.kind === "min" ? e.data.getTime() < a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
2010
|
-
code: u.too_small,
|
|
2011
|
-
message: a.message,
|
|
2012
|
-
inclusive: !0,
|
|
2013
|
-
exact: !1,
|
|
2014
|
-
minimum: a.value,
|
|
2015
|
-
type: "date"
|
|
2016
|
-
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (s = this._getOrReturnCtx(e, s), f(s, {
|
|
2017
|
-
code: u.too_big,
|
|
2018
|
-
message: a.message,
|
|
2019
|
-
inclusive: !0,
|
|
2020
|
-
exact: !1,
|
|
2021
|
-
maximum: a.value,
|
|
2022
|
-
type: "date"
|
|
2023
|
-
}), n.dirty()) : k.assertNever(a);
|
|
2024
|
-
return {
|
|
2025
|
-
status: n.value,
|
|
2026
|
-
value: new Date(e.data.getTime())
|
|
2027
|
-
};
|
|
2028
|
-
}
|
|
2029
|
-
_addCheck(e) {
|
|
2030
|
-
return new ie({
|
|
2031
|
-
...this._def,
|
|
2032
|
-
checks: [...this._def.checks, e]
|
|
2033
|
-
});
|
|
2034
|
-
}
|
|
2035
|
-
min(e, r) {
|
|
2036
|
-
return this._addCheck({
|
|
2037
|
-
kind: "min",
|
|
2038
|
-
value: e.getTime(),
|
|
2039
|
-
message: m.toString(r)
|
|
2040
|
-
});
|
|
2041
|
-
}
|
|
2042
|
-
max(e, r) {
|
|
2043
|
-
return this._addCheck({
|
|
2044
|
-
kind: "max",
|
|
2045
|
-
value: e.getTime(),
|
|
2046
|
-
message: m.toString(r)
|
|
2047
|
-
});
|
|
2048
|
-
}
|
|
2049
|
-
get minDate() {
|
|
2050
|
-
let e = null;
|
|
2051
|
-
for (const r of this._def.checks)
|
|
2052
|
-
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2053
|
-
return e != null ? new Date(e) : null;
|
|
2054
|
-
}
|
|
2055
|
-
get maxDate() {
|
|
2056
|
-
let e = null;
|
|
2057
|
-
for (const r of this._def.checks)
|
|
2058
|
-
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2059
|
-
return e != null ? new Date(e) : null;
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
ie.create = (t) => new ie({
|
|
2063
|
-
checks: [],
|
|
2064
|
-
coerce: t?.coerce || !1,
|
|
2065
|
-
typeName: y.ZodDate,
|
|
2066
|
-
..._(t)
|
|
2067
|
-
});
|
|
2068
|
-
class Ge extends b {
|
|
2069
|
-
_parse(e) {
|
|
2070
|
-
if (this._getType(e) !== p.symbol) {
|
|
2071
|
-
const n = this._getOrReturnCtx(e);
|
|
2072
|
-
return f(n, {
|
|
2073
|
-
code: u.invalid_type,
|
|
2074
|
-
expected: p.symbol,
|
|
2075
|
-
received: n.parsedType
|
|
2076
|
-
}), g;
|
|
2077
|
-
}
|
|
2078
|
-
return A(e.data);
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
Ge.create = (t) => new Ge({
|
|
2082
|
-
typeName: y.ZodSymbol,
|
|
2083
|
-
..._(t)
|
|
2084
|
-
});
|
|
2085
|
-
class Oe extends b {
|
|
2086
|
-
_parse(e) {
|
|
2087
|
-
if (this._getType(e) !== p.undefined) {
|
|
2088
|
-
const n = this._getOrReturnCtx(e);
|
|
2089
|
-
return f(n, {
|
|
2090
|
-
code: u.invalid_type,
|
|
2091
|
-
expected: p.undefined,
|
|
2092
|
-
received: n.parsedType
|
|
2093
|
-
}), g;
|
|
2094
|
-
}
|
|
2095
|
-
return A(e.data);
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
Oe.create = (t) => new Oe({
|
|
2099
|
-
typeName: y.ZodUndefined,
|
|
2100
|
-
..._(t)
|
|
2101
|
-
});
|
|
2102
|
-
class Ne extends b {
|
|
2103
|
-
_parse(e) {
|
|
2104
|
-
if (this._getType(e) !== p.null) {
|
|
2105
|
-
const n = this._getOrReturnCtx(e);
|
|
2106
|
-
return f(n, {
|
|
2107
|
-
code: u.invalid_type,
|
|
2108
|
-
expected: p.null,
|
|
2109
|
-
received: n.parsedType
|
|
2110
|
-
}), g;
|
|
2111
|
-
}
|
|
2112
|
-
return A(e.data);
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
Ne.create = (t) => new Ne({
|
|
2116
|
-
typeName: y.ZodNull,
|
|
2117
|
-
..._(t)
|
|
2118
|
-
});
|
|
2119
|
-
class ye extends b {
|
|
2120
|
-
constructor() {
|
|
2121
|
-
super(...arguments), this._any = !0;
|
|
2122
|
-
}
|
|
2123
|
-
_parse(e) {
|
|
2124
|
-
return A(e.data);
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
ye.create = (t) => new ye({
|
|
2128
|
-
typeName: y.ZodAny,
|
|
2129
|
-
..._(t)
|
|
2130
|
-
});
|
|
2131
|
-
class se extends b {
|
|
2132
|
-
constructor() {
|
|
2133
|
-
super(...arguments), this._unknown = !0;
|
|
2134
|
-
}
|
|
2135
|
-
_parse(e) {
|
|
2136
|
-
return A(e.data);
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
se.create = (t) => new se({
|
|
2140
|
-
typeName: y.ZodUnknown,
|
|
2141
|
-
..._(t)
|
|
2142
|
-
});
|
|
2143
|
-
class H extends b {
|
|
2144
|
-
_parse(e) {
|
|
2145
|
-
const r = this._getOrReturnCtx(e);
|
|
2146
|
-
return f(r, {
|
|
2147
|
-
code: u.invalid_type,
|
|
2148
|
-
expected: p.never,
|
|
2149
|
-
received: r.parsedType
|
|
2150
|
-
}), g;
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
H.create = (t) => new H({
|
|
2154
|
-
typeName: y.ZodNever,
|
|
2155
|
-
..._(t)
|
|
2156
|
-
});
|
|
2157
|
-
class Ke extends b {
|
|
2158
|
-
_parse(e) {
|
|
2159
|
-
if (this._getType(e) !== p.undefined) {
|
|
2160
|
-
const n = this._getOrReturnCtx(e);
|
|
2161
|
-
return f(n, {
|
|
2162
|
-
code: u.invalid_type,
|
|
2163
|
-
expected: p.void,
|
|
2164
|
-
received: n.parsedType
|
|
2165
|
-
}), g;
|
|
2166
|
-
}
|
|
2167
|
-
return A(e.data);
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
Ke.create = (t) => new Ke({
|
|
2171
|
-
typeName: y.ZodVoid,
|
|
2172
|
-
..._(t)
|
|
2173
|
-
});
|
|
2174
|
-
class Z extends b {
|
|
2175
|
-
_parse(e) {
|
|
2176
|
-
const { ctx: r, status: n } = this._processInputParams(e), s = this._def;
|
|
2177
|
-
if (r.parsedType !== p.array)
|
|
2178
|
-
return f(r, {
|
|
2179
|
-
code: u.invalid_type,
|
|
2180
|
-
expected: p.array,
|
|
2181
|
-
received: r.parsedType
|
|
2182
|
-
}), g;
|
|
2183
|
-
if (s.exactLength !== null) {
|
|
2184
|
-
const i = r.data.length > s.exactLength.value, o = r.data.length < s.exactLength.value;
|
|
2185
|
-
(i || o) && (f(r, {
|
|
2186
|
-
code: i ? u.too_big : u.too_small,
|
|
2187
|
-
minimum: o ? s.exactLength.value : void 0,
|
|
2188
|
-
maximum: i ? s.exactLength.value : void 0,
|
|
2189
|
-
type: "array",
|
|
2190
|
-
inclusive: !0,
|
|
2191
|
-
exact: !0,
|
|
2192
|
-
message: s.exactLength.message
|
|
2193
|
-
}), n.dirty());
|
|
2194
|
-
}
|
|
2195
|
-
if (s.minLength !== null && r.data.length < s.minLength.value && (f(r, {
|
|
2196
|
-
code: u.too_small,
|
|
2197
|
-
minimum: s.minLength.value,
|
|
2198
|
-
type: "array",
|
|
2199
|
-
inclusive: !0,
|
|
2200
|
-
exact: !1,
|
|
2201
|
-
message: s.minLength.message
|
|
2202
|
-
}), n.dirty()), s.maxLength !== null && r.data.length > s.maxLength.value && (f(r, {
|
|
2203
|
-
code: u.too_big,
|
|
2204
|
-
maximum: s.maxLength.value,
|
|
2205
|
-
type: "array",
|
|
2206
|
-
inclusive: !0,
|
|
2207
|
-
exact: !1,
|
|
2208
|
-
message: s.maxLength.message
|
|
2209
|
-
}), n.dirty()), r.common.async)
|
|
2210
|
-
return Promise.all([...r.data].map((i, o) => s.type._parseAsync(new D(r, i, r.path, o)))).then((i) => N.mergeArray(n, i));
|
|
2211
|
-
const a = [...r.data].map((i, o) => s.type._parseSync(new D(r, i, r.path, o)));
|
|
2212
|
-
return N.mergeArray(n, a);
|
|
2213
|
-
}
|
|
2214
|
-
get element() {
|
|
2215
|
-
return this._def.type;
|
|
2216
|
-
}
|
|
2217
|
-
min(e, r) {
|
|
2218
|
-
return new Z({
|
|
2219
|
-
...this._def,
|
|
2220
|
-
minLength: { value: e, message: m.toString(r) }
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
max(e, r) {
|
|
2224
|
-
return new Z({
|
|
2225
|
-
...this._def,
|
|
2226
|
-
maxLength: { value: e, message: m.toString(r) }
|
|
2227
|
-
});
|
|
2228
|
-
}
|
|
2229
|
-
length(e, r) {
|
|
2230
|
-
return new Z({
|
|
2231
|
-
...this._def,
|
|
2232
|
-
exactLength: { value: e, message: m.toString(r) }
|
|
2233
|
-
});
|
|
2234
|
-
}
|
|
2235
|
-
nonempty(e) {
|
|
2236
|
-
return this.min(1, e);
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
Z.create = (t, e) => new Z({
|
|
2240
|
-
type: t,
|
|
2241
|
-
minLength: null,
|
|
2242
|
-
maxLength: null,
|
|
2243
|
-
exactLength: null,
|
|
2244
|
-
typeName: y.ZodArray,
|
|
2245
|
-
..._(e)
|
|
2246
|
-
});
|
|
2247
|
-
function le(t) {
|
|
2248
|
-
if (t instanceof E) {
|
|
2249
|
-
const e = {};
|
|
2250
|
-
for (const r in t.shape) {
|
|
2251
|
-
const n = t.shape[r];
|
|
2252
|
-
e[r] = F.create(le(n));
|
|
2253
|
-
}
|
|
2254
|
-
return new E({
|
|
2255
|
-
...t._def,
|
|
2256
|
-
shape: () => e
|
|
2257
|
-
});
|
|
2258
|
-
} else return t instanceof Z ? new Z({
|
|
2259
|
-
...t._def,
|
|
2260
|
-
type: le(t.element)
|
|
2261
|
-
}) : t instanceof F ? F.create(le(t.unwrap())) : t instanceof X ? X.create(le(t.unwrap())) : t instanceof L ? L.create(t.items.map((e) => le(e))) : t;
|
|
2262
|
-
}
|
|
2263
|
-
class E extends b {
|
|
2264
|
-
constructor() {
|
|
2265
|
-
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
2266
|
-
}
|
|
2267
|
-
_getCached() {
|
|
2268
|
-
if (this._cached !== null)
|
|
2269
|
-
return this._cached;
|
|
2270
|
-
const e = this._def.shape(), r = k.objectKeys(e);
|
|
2271
|
-
return this._cached = { shape: e, keys: r };
|
|
2272
|
-
}
|
|
2273
|
-
_parse(e) {
|
|
2274
|
-
if (this._getType(e) !== p.object) {
|
|
2275
|
-
const c = this._getOrReturnCtx(e);
|
|
2276
|
-
return f(c, {
|
|
2277
|
-
code: u.invalid_type,
|
|
2278
|
-
expected: p.object,
|
|
2279
|
-
received: c.parsedType
|
|
2280
|
-
}), g;
|
|
2281
|
-
}
|
|
2282
|
-
const { status: n, ctx: s } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
2283
|
-
if (!(this._def.catchall instanceof H && this._def.unknownKeys === "strip"))
|
|
2284
|
-
for (const c in s.data)
|
|
2285
|
-
i.includes(c) || o.push(c);
|
|
2286
|
-
const d = [];
|
|
2287
|
-
for (const c of i) {
|
|
2288
|
-
const l = a[c], w = s.data[c];
|
|
2289
|
-
d.push({
|
|
2290
|
-
key: { status: "valid", value: c },
|
|
2291
|
-
value: l._parse(new D(s, w, s.path, c)),
|
|
2292
|
-
alwaysSet: c in s.data
|
|
2293
|
-
});
|
|
2294
|
-
}
|
|
2295
|
-
if (this._def.catchall instanceof H) {
|
|
2296
|
-
const c = this._def.unknownKeys;
|
|
2297
|
-
if (c === "passthrough")
|
|
2298
|
-
for (const l of o)
|
|
2299
|
-
d.push({
|
|
2300
|
-
key: { status: "valid", value: l },
|
|
2301
|
-
value: { status: "valid", value: s.data[l] }
|
|
2302
|
-
});
|
|
2303
|
-
else if (c === "strict")
|
|
2304
|
-
o.length > 0 && (f(s, {
|
|
2305
|
-
code: u.unrecognized_keys,
|
|
2306
|
-
keys: o
|
|
2307
|
-
}), n.dirty());
|
|
2308
|
-
else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
2309
|
-
} else {
|
|
2310
|
-
const c = this._def.catchall;
|
|
2311
|
-
for (const l of o) {
|
|
2312
|
-
const w = s.data[l];
|
|
2313
|
-
d.push({
|
|
2314
|
-
key: { status: "valid", value: l },
|
|
2315
|
-
value: c._parse(
|
|
2316
|
-
new D(s, w, s.path, l)
|
|
2317
|
-
//, ctx.child(key), value, getParsedType(value)
|
|
2318
|
-
),
|
|
2319
|
-
alwaysSet: l in s.data
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
return s.common.async ? Promise.resolve().then(async () => {
|
|
2324
|
-
const c = [];
|
|
2325
|
-
for (const l of d) {
|
|
2326
|
-
const w = await l.key, S = await l.value;
|
|
2327
|
-
c.push({
|
|
2328
|
-
key: w,
|
|
2329
|
-
value: S,
|
|
2330
|
-
alwaysSet: l.alwaysSet
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
return c;
|
|
2334
|
-
}).then((c) => N.mergeObjectSync(n, c)) : N.mergeObjectSync(n, d);
|
|
2335
|
-
}
|
|
2336
|
-
get shape() {
|
|
2337
|
-
return this._def.shape();
|
|
2338
|
-
}
|
|
2339
|
-
strict(e) {
|
|
2340
|
-
return m.errToObj, new E({
|
|
2341
|
-
...this._def,
|
|
2342
|
-
unknownKeys: "strict",
|
|
2343
|
-
...e !== void 0 ? {
|
|
2344
|
-
errorMap: (r, n) => {
|
|
2345
|
-
var s, a, i, o;
|
|
2346
|
-
const d = (i = (a = (s = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(s, r, n).message) !== null && i !== void 0 ? i : n.defaultError;
|
|
2347
|
-
return r.code === "unrecognized_keys" ? {
|
|
2348
|
-
message: (o = m.errToObj(e).message) !== null && o !== void 0 ? o : d
|
|
2349
|
-
} : {
|
|
2350
|
-
message: d
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
} : {}
|
|
2354
|
-
});
|
|
2355
|
-
}
|
|
2356
|
-
strip() {
|
|
2357
|
-
return new E({
|
|
2358
|
-
...this._def,
|
|
2359
|
-
unknownKeys: "strip"
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
passthrough() {
|
|
2363
|
-
return new E({
|
|
2364
|
-
...this._def,
|
|
2365
|
-
unknownKeys: "passthrough"
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
// const AugmentFactory =
|
|
2369
|
-
// <Def extends ZodObjectDef>(def: Def) =>
|
|
2370
|
-
// <Augmentation extends ZodRawShape>(
|
|
2371
|
-
// augmentation: Augmentation
|
|
2372
|
-
// ): ZodObject<
|
|
2373
|
-
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
2374
|
-
// Def["unknownKeys"],
|
|
2375
|
-
// Def["catchall"]
|
|
2376
|
-
// > => {
|
|
2377
|
-
// return new ZodObject({
|
|
2378
|
-
// ...def,
|
|
2379
|
-
// shape: () => ({
|
|
2380
|
-
// ...def.shape(),
|
|
2381
|
-
// ...augmentation,
|
|
2382
|
-
// }),
|
|
2383
|
-
// }) as any;
|
|
2384
|
-
// };
|
|
2385
|
-
extend(e) {
|
|
2386
|
-
return new E({
|
|
2387
|
-
...this._def,
|
|
2388
|
-
shape: () => ({
|
|
2389
|
-
...this._def.shape(),
|
|
2390
|
-
...e
|
|
2391
|
-
})
|
|
2392
|
-
});
|
|
2393
|
-
}
|
|
2394
|
-
/**
|
|
2395
|
-
* Prior to zod@1.0.12 there was a bug in the
|
|
2396
|
-
* inferred type of merged objects. Please
|
|
2397
|
-
* upgrade if you are experiencing issues.
|
|
2398
|
-
*/
|
|
2399
|
-
merge(e) {
|
|
2400
|
-
return new E({
|
|
2401
|
-
unknownKeys: e._def.unknownKeys,
|
|
2402
|
-
catchall: e._def.catchall,
|
|
2403
|
-
shape: () => ({
|
|
2404
|
-
...this._def.shape(),
|
|
2405
|
-
...e._def.shape()
|
|
2406
|
-
}),
|
|
2407
|
-
typeName: y.ZodObject
|
|
2408
|
-
});
|
|
2409
|
-
}
|
|
2410
|
-
// merge<
|
|
2411
|
-
// Incoming extends AnyZodObject,
|
|
2412
|
-
// Augmentation extends Incoming["shape"],
|
|
2413
|
-
// NewOutput extends {
|
|
2414
|
-
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
2415
|
-
// ? Augmentation[k]["_output"]
|
|
2416
|
-
// : k extends keyof Output
|
|
2417
|
-
// ? Output[k]
|
|
2418
|
-
// : never;
|
|
2419
|
-
// },
|
|
2420
|
-
// NewInput extends {
|
|
2421
|
-
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2422
|
-
// ? Augmentation[k]["_input"]
|
|
2423
|
-
// : k extends keyof Input
|
|
2424
|
-
// ? Input[k]
|
|
2425
|
-
// : never;
|
|
2426
|
-
// }
|
|
2427
|
-
// >(
|
|
2428
|
-
// merging: Incoming
|
|
2429
|
-
// ): ZodObject<
|
|
2430
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2431
|
-
// Incoming["_def"]["unknownKeys"],
|
|
2432
|
-
// Incoming["_def"]["catchall"],
|
|
2433
|
-
// NewOutput,
|
|
2434
|
-
// NewInput
|
|
2435
|
-
// > {
|
|
2436
|
-
// const merged: any = new ZodObject({
|
|
2437
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
2438
|
-
// catchall: merging._def.catchall,
|
|
2439
|
-
// shape: () =>
|
|
2440
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2441
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2442
|
-
// }) as any;
|
|
2443
|
-
// return merged;
|
|
2444
|
-
// }
|
|
2445
|
-
setKey(e, r) {
|
|
2446
|
-
return this.augment({ [e]: r });
|
|
2447
|
-
}
|
|
2448
|
-
// merge<Incoming extends AnyZodObject>(
|
|
2449
|
-
// merging: Incoming
|
|
2450
|
-
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
2451
|
-
// ZodObject<
|
|
2452
|
-
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2453
|
-
// Incoming["_def"]["unknownKeys"],
|
|
2454
|
-
// Incoming["_def"]["catchall"]
|
|
2455
|
-
// > {
|
|
2456
|
-
// // const mergedShape = objectUtil.mergeShapes(
|
|
2457
|
-
// // this._def.shape(),
|
|
2458
|
-
// // merging._def.shape()
|
|
2459
|
-
// // );
|
|
2460
|
-
// const merged: any = new ZodObject({
|
|
2461
|
-
// unknownKeys: merging._def.unknownKeys,
|
|
2462
|
-
// catchall: merging._def.catchall,
|
|
2463
|
-
// shape: () =>
|
|
2464
|
-
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2465
|
-
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2466
|
-
// }) as any;
|
|
2467
|
-
// return merged;
|
|
2468
|
-
// }
|
|
2469
|
-
catchall(e) {
|
|
2470
|
-
return new E({
|
|
2471
|
-
...this._def,
|
|
2472
|
-
catchall: e
|
|
2473
|
-
});
|
|
2474
|
-
}
|
|
2475
|
-
pick(e) {
|
|
2476
|
-
const r = {};
|
|
2477
|
-
return k.objectKeys(e).forEach((n) => {
|
|
2478
|
-
e[n] && this.shape[n] && (r[n] = this.shape[n]);
|
|
2479
|
-
}), new E({
|
|
2480
|
-
...this._def,
|
|
2481
|
-
shape: () => r
|
|
2482
|
-
});
|
|
2483
|
-
}
|
|
2484
|
-
omit(e) {
|
|
2485
|
-
const r = {};
|
|
2486
|
-
return k.objectKeys(this.shape).forEach((n) => {
|
|
2487
|
-
e[n] || (r[n] = this.shape[n]);
|
|
2488
|
-
}), new E({
|
|
2489
|
-
...this._def,
|
|
2490
|
-
shape: () => r
|
|
2491
|
-
});
|
|
2492
|
-
}
|
|
2493
|
-
/**
|
|
2494
|
-
* @deprecated
|
|
2495
|
-
*/
|
|
2496
|
-
deepPartial() {
|
|
2497
|
-
return le(this);
|
|
2498
|
-
}
|
|
2499
|
-
partial(e) {
|
|
2500
|
-
const r = {};
|
|
2501
|
-
return k.objectKeys(this.shape).forEach((n) => {
|
|
2502
|
-
const s = this.shape[n];
|
|
2503
|
-
e && !e[n] ? r[n] = s : r[n] = s.optional();
|
|
2504
|
-
}), new E({
|
|
2505
|
-
...this._def,
|
|
2506
|
-
shape: () => r
|
|
2507
|
-
});
|
|
2508
|
-
}
|
|
2509
|
-
required(e) {
|
|
2510
|
-
const r = {};
|
|
2511
|
-
return k.objectKeys(this.shape).forEach((n) => {
|
|
2512
|
-
if (e && !e[n])
|
|
2513
|
-
r[n] = this.shape[n];
|
|
2514
|
-
else {
|
|
2515
|
-
let a = this.shape[n];
|
|
2516
|
-
for (; a instanceof F; )
|
|
2517
|
-
a = a._def.innerType;
|
|
2518
|
-
r[n] = a;
|
|
2519
|
-
}
|
|
2520
|
-
}), new E({
|
|
2521
|
-
...this._def,
|
|
2522
|
-
shape: () => r
|
|
2523
|
-
});
|
|
2524
|
-
}
|
|
2525
|
-
keyof() {
|
|
2526
|
-
return ar(k.objectKeys(this.shape));
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
E.create = (t, e) => new E({
|
|
2530
|
-
shape: () => t,
|
|
2531
|
-
unknownKeys: "strip",
|
|
2532
|
-
catchall: H.create(),
|
|
2533
|
-
typeName: y.ZodObject,
|
|
2534
|
-
..._(e)
|
|
2535
|
-
});
|
|
2536
|
-
E.strictCreate = (t, e) => new E({
|
|
2537
|
-
shape: () => t,
|
|
2538
|
-
unknownKeys: "strict",
|
|
2539
|
-
catchall: H.create(),
|
|
2540
|
-
typeName: y.ZodObject,
|
|
2541
|
-
..._(e)
|
|
2542
|
-
});
|
|
2543
|
-
E.lazycreate = (t, e) => new E({
|
|
2544
|
-
shape: t,
|
|
2545
|
-
unknownKeys: "strip",
|
|
2546
|
-
catchall: H.create(),
|
|
2547
|
-
typeName: y.ZodObject,
|
|
2548
|
-
..._(e)
|
|
2549
|
-
});
|
|
2550
|
-
class Re extends b {
|
|
2551
|
-
_parse(e) {
|
|
2552
|
-
const { ctx: r } = this._processInputParams(e), n = this._def.options;
|
|
2553
|
-
function s(a) {
|
|
2554
|
-
for (const o of a)
|
|
2555
|
-
if (o.result.status === "valid")
|
|
2556
|
-
return o.result;
|
|
2557
|
-
for (const o of a)
|
|
2558
|
-
if (o.result.status === "dirty")
|
|
2559
|
-
return r.common.issues.push(...o.ctx.common.issues), o.result;
|
|
2560
|
-
const i = a.map((o) => new P(o.ctx.common.issues));
|
|
2561
|
-
return f(r, {
|
|
2562
|
-
code: u.invalid_union,
|
|
2563
|
-
unionErrors: i
|
|
2564
|
-
}), g;
|
|
2565
|
-
}
|
|
2566
|
-
if (r.common.async)
|
|
2567
|
-
return Promise.all(n.map(async (a) => {
|
|
2568
|
-
const i = {
|
|
2569
|
-
...r,
|
|
2570
|
-
common: {
|
|
2571
|
-
...r.common,
|
|
2572
|
-
issues: []
|
|
2573
|
-
},
|
|
2574
|
-
parent: null
|
|
2575
|
-
};
|
|
2576
|
-
return {
|
|
2577
|
-
result: await a._parseAsync({
|
|
2578
|
-
data: r.data,
|
|
2579
|
-
path: r.path,
|
|
2580
|
-
parent: i
|
|
2581
|
-
}),
|
|
2582
|
-
ctx: i
|
|
2583
|
-
};
|
|
2584
|
-
})).then(s);
|
|
2585
|
-
{
|
|
2586
|
-
let a;
|
|
2587
|
-
const i = [];
|
|
2588
|
-
for (const d of n) {
|
|
2589
|
-
const c = {
|
|
2590
|
-
...r,
|
|
2591
|
-
common: {
|
|
2592
|
-
...r.common,
|
|
2593
|
-
issues: []
|
|
2594
|
-
},
|
|
2595
|
-
parent: null
|
|
2596
|
-
}, l = d._parseSync({
|
|
2597
|
-
data: r.data,
|
|
2598
|
-
path: r.path,
|
|
2599
|
-
parent: c
|
|
2600
|
-
});
|
|
2601
|
-
if (l.status === "valid")
|
|
2602
|
-
return l;
|
|
2603
|
-
l.status === "dirty" && !a && (a = { result: l, ctx: c }), c.common.issues.length && i.push(c.common.issues);
|
|
2604
|
-
}
|
|
2605
|
-
if (a)
|
|
2606
|
-
return r.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2607
|
-
const o = i.map((d) => new P(d));
|
|
2608
|
-
return f(r, {
|
|
2609
|
-
code: u.invalid_union,
|
|
2610
|
-
unionErrors: o
|
|
2611
|
-
}), g;
|
|
2612
|
-
}
|
|
2613
|
-
}
|
|
2614
|
-
get options() {
|
|
2615
|
-
return this._def.options;
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
Re.create = (t, e) => new Re({
|
|
2619
|
-
options: t,
|
|
2620
|
-
typeName: y.ZodUnion,
|
|
2621
|
-
..._(e)
|
|
2622
|
-
});
|
|
2623
|
-
const q = (t) => t instanceof Ie ? q(t.schema) : t instanceof $ ? q(t.innerType()) : t instanceof Pe ? [t.value] : t instanceof K ? t.options : t instanceof je ? k.objectValues(t.enum) : t instanceof Ze ? q(t._def.innerType) : t instanceof Oe ? [void 0] : t instanceof Ne ? [null] : t instanceof F ? [void 0, ...q(t.unwrap())] : t instanceof X ? [null, ...q(t.unwrap())] : t instanceof vt || t instanceof Me ? q(t.unwrap()) : t instanceof $e ? q(t._def.innerType) : [];
|
|
2624
|
-
class tt extends b {
|
|
2625
|
-
_parse(e) {
|
|
2626
|
-
const { ctx: r } = this._processInputParams(e);
|
|
2627
|
-
if (r.parsedType !== p.object)
|
|
2628
|
-
return f(r, {
|
|
2629
|
-
code: u.invalid_type,
|
|
2630
|
-
expected: p.object,
|
|
2631
|
-
received: r.parsedType
|
|
2632
|
-
}), g;
|
|
2633
|
-
const n = this.discriminator, s = r.data[n], a = this.optionsMap.get(s);
|
|
2634
|
-
return a ? r.common.async ? a._parseAsync({
|
|
2635
|
-
data: r.data,
|
|
2636
|
-
path: r.path,
|
|
2637
|
-
parent: r
|
|
2638
|
-
}) : a._parseSync({
|
|
2639
|
-
data: r.data,
|
|
2640
|
-
path: r.path,
|
|
2641
|
-
parent: r
|
|
2642
|
-
}) : (f(r, {
|
|
2643
|
-
code: u.invalid_union_discriminator,
|
|
2644
|
-
options: Array.from(this.optionsMap.keys()),
|
|
2645
|
-
path: [n]
|
|
2646
|
-
}), g);
|
|
2647
|
-
}
|
|
2648
|
-
get discriminator() {
|
|
2649
|
-
return this._def.discriminator;
|
|
2650
|
-
}
|
|
2651
|
-
get options() {
|
|
2652
|
-
return this._def.options;
|
|
2653
|
-
}
|
|
2654
|
-
get optionsMap() {
|
|
2655
|
-
return this._def.optionsMap;
|
|
2656
|
-
}
|
|
2657
|
-
/**
|
|
2658
|
-
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
2659
|
-
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
2660
|
-
* have a different value for each object in the union.
|
|
2661
|
-
* @param discriminator the name of the discriminator property
|
|
2662
|
-
* @param types an array of object schemas
|
|
2663
|
-
* @param params
|
|
2664
|
-
*/
|
|
2665
|
-
static create(e, r, n) {
|
|
2666
|
-
const s = /* @__PURE__ */ new Map();
|
|
2667
|
-
for (const a of r) {
|
|
2668
|
-
const i = q(a.shape[e]);
|
|
2669
|
-
if (!i.length)
|
|
2670
|
-
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2671
|
-
for (const o of i) {
|
|
2672
|
-
if (s.has(o))
|
|
2673
|
-
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2674
|
-
s.set(o, a);
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
return new tt({
|
|
2678
|
-
typeName: y.ZodDiscriminatedUnion,
|
|
2679
|
-
discriminator: e,
|
|
2680
|
-
options: r,
|
|
2681
|
-
optionsMap: s,
|
|
2682
|
-
..._(n)
|
|
2683
|
-
});
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
function ft(t, e) {
|
|
2687
|
-
const r = U(t), n = U(e);
|
|
2688
|
-
if (t === e)
|
|
2689
|
-
return { valid: !0, data: t };
|
|
2690
|
-
if (r === p.object && n === p.object) {
|
|
2691
|
-
const s = k.objectKeys(e), a = k.objectKeys(t).filter((o) => s.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2692
|
-
for (const o of a) {
|
|
2693
|
-
const d = ft(t[o], e[o]);
|
|
2694
|
-
if (!d.valid)
|
|
2695
|
-
return { valid: !1 };
|
|
2696
|
-
i[o] = d.data;
|
|
2697
|
-
}
|
|
2698
|
-
return { valid: !0, data: i };
|
|
2699
|
-
} else if (r === p.array && n === p.array) {
|
|
2700
|
-
if (t.length !== e.length)
|
|
2701
|
-
return { valid: !1 };
|
|
2702
|
-
const s = [];
|
|
2703
|
-
for (let a = 0; a < t.length; a++) {
|
|
2704
|
-
const i = t[a], o = e[a], d = ft(i, o);
|
|
2705
|
-
if (!d.valid)
|
|
2706
|
-
return { valid: !1 };
|
|
2707
|
-
s.push(d.data);
|
|
2708
|
-
}
|
|
2709
|
-
return { valid: !0, data: s };
|
|
2710
|
-
} else return r === p.date && n === p.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2711
|
-
}
|
|
2712
|
-
class Ae extends b {
|
|
2713
|
-
_parse(e) {
|
|
2714
|
-
const { status: r, ctx: n } = this._processInputParams(e), s = (a, i) => {
|
|
2715
|
-
if (ut(a) || ut(i))
|
|
2716
|
-
return g;
|
|
2717
|
-
const o = ft(a.value, i.value);
|
|
2718
|
-
return o.valid ? ((lt(a) || lt(i)) && r.dirty(), { status: r.value, value: o.data }) : (f(n, {
|
|
2719
|
-
code: u.invalid_intersection_types
|
|
2720
|
-
}), g);
|
|
2721
|
-
};
|
|
2722
|
-
return n.common.async ? Promise.all([
|
|
2723
|
-
this._def.left._parseAsync({
|
|
2724
|
-
data: n.data,
|
|
2725
|
-
path: n.path,
|
|
2726
|
-
parent: n
|
|
2727
|
-
}),
|
|
2728
|
-
this._def.right._parseAsync({
|
|
2729
|
-
data: n.data,
|
|
2730
|
-
path: n.path,
|
|
2731
|
-
parent: n
|
|
2732
|
-
})
|
|
2733
|
-
]).then(([a, i]) => s(a, i)) : s(this._def.left._parseSync({
|
|
2734
|
-
data: n.data,
|
|
2735
|
-
path: n.path,
|
|
2736
|
-
parent: n
|
|
2737
|
-
}), this._def.right._parseSync({
|
|
2738
|
-
data: n.data,
|
|
2739
|
-
path: n.path,
|
|
2740
|
-
parent: n
|
|
2741
|
-
}));
|
|
2742
|
-
}
|
|
2743
|
-
}
|
|
2744
|
-
Ae.create = (t, e, r) => new Ae({
|
|
2745
|
-
left: t,
|
|
2746
|
-
right: e,
|
|
2747
|
-
typeName: y.ZodIntersection,
|
|
2748
|
-
..._(r)
|
|
2749
|
-
});
|
|
2750
|
-
class L extends b {
|
|
2751
|
-
_parse(e) {
|
|
2752
|
-
const { status: r, ctx: n } = this._processInputParams(e);
|
|
2753
|
-
if (n.parsedType !== p.array)
|
|
2754
|
-
return f(n, {
|
|
2755
|
-
code: u.invalid_type,
|
|
2756
|
-
expected: p.array,
|
|
2757
|
-
received: n.parsedType
|
|
2758
|
-
}), g;
|
|
2759
|
-
if (n.data.length < this._def.items.length)
|
|
2760
|
-
return f(n, {
|
|
2761
|
-
code: u.too_small,
|
|
2762
|
-
minimum: this._def.items.length,
|
|
2763
|
-
inclusive: !0,
|
|
2764
|
-
exact: !1,
|
|
2765
|
-
type: "array"
|
|
2766
|
-
}), g;
|
|
2767
|
-
!this._def.rest && n.data.length > this._def.items.length && (f(n, {
|
|
2768
|
-
code: u.too_big,
|
|
2769
|
-
maximum: this._def.items.length,
|
|
2770
|
-
inclusive: !0,
|
|
2771
|
-
exact: !1,
|
|
2772
|
-
type: "array"
|
|
2773
|
-
}), r.dirty());
|
|
2774
|
-
const a = [...n.data].map((i, o) => {
|
|
2775
|
-
const d = this._def.items[o] || this._def.rest;
|
|
2776
|
-
return d ? d._parse(new D(n, i, n.path, o)) : null;
|
|
2777
|
-
}).filter((i) => !!i);
|
|
2778
|
-
return n.common.async ? Promise.all(a).then((i) => N.mergeArray(r, i)) : N.mergeArray(r, a);
|
|
2779
|
-
}
|
|
2780
|
-
get items() {
|
|
2781
|
-
return this._def.items;
|
|
2782
|
-
}
|
|
2783
|
-
rest(e) {
|
|
2784
|
-
return new L({
|
|
2785
|
-
...this._def,
|
|
2786
|
-
rest: e
|
|
2787
|
-
});
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
L.create = (t, e) => {
|
|
2791
|
-
if (!Array.isArray(t))
|
|
2792
|
-
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2793
|
-
return new L({
|
|
2794
|
-
items: t,
|
|
2795
|
-
typeName: y.ZodTuple,
|
|
2796
|
-
rest: null,
|
|
2797
|
-
..._(e)
|
|
2798
|
-
});
|
|
2799
|
-
};
|
|
2800
|
-
class Ce extends b {
|
|
2801
|
-
get keySchema() {
|
|
2802
|
-
return this._def.keyType;
|
|
2803
|
-
}
|
|
2804
|
-
get valueSchema() {
|
|
2805
|
-
return this._def.valueType;
|
|
2806
|
-
}
|
|
2807
|
-
_parse(e) {
|
|
2808
|
-
const { status: r, ctx: n } = this._processInputParams(e);
|
|
2809
|
-
if (n.parsedType !== p.object)
|
|
2810
|
-
return f(n, {
|
|
2811
|
-
code: u.invalid_type,
|
|
2812
|
-
expected: p.object,
|
|
2813
|
-
received: n.parsedType
|
|
2814
|
-
}), g;
|
|
2815
|
-
const s = [], a = this._def.keyType, i = this._def.valueType;
|
|
2816
|
-
for (const o in n.data)
|
|
2817
|
-
s.push({
|
|
2818
|
-
key: a._parse(new D(n, o, n.path, o)),
|
|
2819
|
-
value: i._parse(new D(n, n.data[o], n.path, o)),
|
|
2820
|
-
alwaysSet: o in n.data
|
|
2821
|
-
});
|
|
2822
|
-
return n.common.async ? N.mergeObjectAsync(r, s) : N.mergeObjectSync(r, s);
|
|
2823
|
-
}
|
|
2824
|
-
get element() {
|
|
2825
|
-
return this._def.valueType;
|
|
2826
|
-
}
|
|
2827
|
-
static create(e, r, n) {
|
|
2828
|
-
return r instanceof b ? new Ce({
|
|
2829
|
-
keyType: e,
|
|
2830
|
-
valueType: r,
|
|
2831
|
-
typeName: y.ZodRecord,
|
|
2832
|
-
..._(n)
|
|
2833
|
-
}) : new Ce({
|
|
2834
|
-
keyType: j.create(),
|
|
2835
|
-
valueType: e,
|
|
2836
|
-
typeName: y.ZodRecord,
|
|
2837
|
-
..._(r)
|
|
2838
|
-
});
|
|
2839
|
-
}
|
|
2840
|
-
}
|
|
2841
|
-
class Xe extends b {
|
|
2842
|
-
get keySchema() {
|
|
2843
|
-
return this._def.keyType;
|
|
2844
|
-
}
|
|
2845
|
-
get valueSchema() {
|
|
2846
|
-
return this._def.valueType;
|
|
2847
|
-
}
|
|
2848
|
-
_parse(e) {
|
|
2849
|
-
const { status: r, ctx: n } = this._processInputParams(e);
|
|
2850
|
-
if (n.parsedType !== p.map)
|
|
2851
|
-
return f(n, {
|
|
2852
|
-
code: u.invalid_type,
|
|
2853
|
-
expected: p.map,
|
|
2854
|
-
received: n.parsedType
|
|
2855
|
-
}), g;
|
|
2856
|
-
const s = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, d], c) => ({
|
|
2857
|
-
key: s._parse(new D(n, o, n.path, [c, "key"])),
|
|
2858
|
-
value: a._parse(new D(n, d, n.path, [c, "value"]))
|
|
2859
|
-
}));
|
|
2860
|
-
if (n.common.async) {
|
|
2861
|
-
const o = /* @__PURE__ */ new Map();
|
|
2862
|
-
return Promise.resolve().then(async () => {
|
|
2863
|
-
for (const d of i) {
|
|
2864
|
-
const c = await d.key, l = await d.value;
|
|
2865
|
-
if (c.status === "aborted" || l.status === "aborted")
|
|
2866
|
-
return g;
|
|
2867
|
-
(c.status === "dirty" || l.status === "dirty") && r.dirty(), o.set(c.value, l.value);
|
|
2868
|
-
}
|
|
2869
|
-
return { status: r.value, value: o };
|
|
2870
|
-
});
|
|
2871
|
-
} else {
|
|
2872
|
-
const o = /* @__PURE__ */ new Map();
|
|
2873
|
-
for (const d of i) {
|
|
2874
|
-
const c = d.key, l = d.value;
|
|
2875
|
-
if (c.status === "aborted" || l.status === "aborted")
|
|
2876
|
-
return g;
|
|
2877
|
-
(c.status === "dirty" || l.status === "dirty") && r.dirty(), o.set(c.value, l.value);
|
|
2878
|
-
}
|
|
2879
|
-
return { status: r.value, value: o };
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
}
|
|
2883
|
-
Xe.create = (t, e, r) => new Xe({
|
|
2884
|
-
valueType: e,
|
|
2885
|
-
keyType: t,
|
|
2886
|
-
typeName: y.ZodMap,
|
|
2887
|
-
..._(r)
|
|
2888
|
-
});
|
|
2889
|
-
class oe extends b {
|
|
2890
|
-
_parse(e) {
|
|
2891
|
-
const { status: r, ctx: n } = this._processInputParams(e);
|
|
2892
|
-
if (n.parsedType !== p.set)
|
|
2893
|
-
return f(n, {
|
|
2894
|
-
code: u.invalid_type,
|
|
2895
|
-
expected: p.set,
|
|
2896
|
-
received: n.parsedType
|
|
2897
|
-
}), g;
|
|
2898
|
-
const s = this._def;
|
|
2899
|
-
s.minSize !== null && n.data.size < s.minSize.value && (f(n, {
|
|
2900
|
-
code: u.too_small,
|
|
2901
|
-
minimum: s.minSize.value,
|
|
2902
|
-
type: "set",
|
|
2903
|
-
inclusive: !0,
|
|
2904
|
-
exact: !1,
|
|
2905
|
-
message: s.minSize.message
|
|
2906
|
-
}), r.dirty()), s.maxSize !== null && n.data.size > s.maxSize.value && (f(n, {
|
|
2907
|
-
code: u.too_big,
|
|
2908
|
-
maximum: s.maxSize.value,
|
|
2909
|
-
type: "set",
|
|
2910
|
-
inclusive: !0,
|
|
2911
|
-
exact: !1,
|
|
2912
|
-
message: s.maxSize.message
|
|
2913
|
-
}), r.dirty());
|
|
2914
|
-
const a = this._def.valueType;
|
|
2915
|
-
function i(d) {
|
|
2916
|
-
const c = /* @__PURE__ */ new Set();
|
|
2917
|
-
for (const l of d) {
|
|
2918
|
-
if (l.status === "aborted")
|
|
2919
|
-
return g;
|
|
2920
|
-
l.status === "dirty" && r.dirty(), c.add(l.value);
|
|
2921
|
-
}
|
|
2922
|
-
return { status: r.value, value: c };
|
|
2923
|
-
}
|
|
2924
|
-
const o = [...n.data.values()].map((d, c) => a._parse(new D(n, d, n.path, c)));
|
|
2925
|
-
return n.common.async ? Promise.all(o).then((d) => i(d)) : i(o);
|
|
2926
|
-
}
|
|
2927
|
-
min(e, r) {
|
|
2928
|
-
return new oe({
|
|
2929
|
-
...this._def,
|
|
2930
|
-
minSize: { value: e, message: m.toString(r) }
|
|
2931
|
-
});
|
|
2932
|
-
}
|
|
2933
|
-
max(e, r) {
|
|
2934
|
-
return new oe({
|
|
2935
|
-
...this._def,
|
|
2936
|
-
maxSize: { value: e, message: m.toString(r) }
|
|
2937
|
-
});
|
|
2938
|
-
}
|
|
2939
|
-
size(e, r) {
|
|
2940
|
-
return this.min(e, r).max(e, r);
|
|
2941
|
-
}
|
|
2942
|
-
nonempty(e) {
|
|
2943
|
-
return this.min(1, e);
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
oe.create = (t, e) => new oe({
|
|
2947
|
-
valueType: t,
|
|
2948
|
-
minSize: null,
|
|
2949
|
-
maxSize: null,
|
|
2950
|
-
typeName: y.ZodSet,
|
|
2951
|
-
..._(e)
|
|
2952
|
-
});
|
|
2953
|
-
class he extends b {
|
|
2954
|
-
constructor() {
|
|
2955
|
-
super(...arguments), this.validate = this.implement;
|
|
2956
|
-
}
|
|
2957
|
-
_parse(e) {
|
|
2958
|
-
const { ctx: r } = this._processInputParams(e);
|
|
2959
|
-
if (r.parsedType !== p.function)
|
|
2960
|
-
return f(r, {
|
|
2961
|
-
code: u.invalid_type,
|
|
2962
|
-
expected: p.function,
|
|
2963
|
-
received: r.parsedType
|
|
2964
|
-
}), g;
|
|
2965
|
-
function n(o, d) {
|
|
2966
|
-
return Je({
|
|
2967
|
-
data: o,
|
|
2968
|
-
path: r.path,
|
|
2969
|
-
errorMaps: [
|
|
2970
|
-
r.common.contextualErrorMap,
|
|
2971
|
-
r.schemaErrorMap,
|
|
2972
|
-
We(),
|
|
2973
|
-
me
|
|
2974
|
-
].filter((c) => !!c),
|
|
2975
|
-
issueData: {
|
|
2976
|
-
code: u.invalid_arguments,
|
|
2977
|
-
argumentsError: d
|
|
2978
|
-
}
|
|
2979
|
-
});
|
|
2980
|
-
}
|
|
2981
|
-
function s(o, d) {
|
|
2982
|
-
return Je({
|
|
2983
|
-
data: o,
|
|
2984
|
-
path: r.path,
|
|
2985
|
-
errorMaps: [
|
|
2986
|
-
r.common.contextualErrorMap,
|
|
2987
|
-
r.schemaErrorMap,
|
|
2988
|
-
We(),
|
|
2989
|
-
me
|
|
2990
|
-
].filter((c) => !!c),
|
|
2991
|
-
issueData: {
|
|
2992
|
-
code: u.invalid_return_type,
|
|
2993
|
-
returnTypeError: d
|
|
2994
|
-
}
|
|
2995
|
-
});
|
|
2996
|
-
}
|
|
2997
|
-
const a = { errorMap: r.common.contextualErrorMap }, i = r.data;
|
|
2998
|
-
if (this._def.returns instanceof ge) {
|
|
2999
|
-
const o = this;
|
|
3000
|
-
return A(async function(...d) {
|
|
3001
|
-
const c = new P([]), l = await o._def.args.parseAsync(d, a).catch((C) => {
|
|
3002
|
-
throw c.addIssue(n(d, C)), c;
|
|
3003
|
-
}), w = await Reflect.apply(i, this, l);
|
|
3004
|
-
return await o._def.returns._def.type.parseAsync(w, a).catch((C) => {
|
|
3005
|
-
throw c.addIssue(s(w, C)), c;
|
|
3006
|
-
});
|
|
3007
|
-
});
|
|
3008
|
-
} else {
|
|
3009
|
-
const o = this;
|
|
3010
|
-
return A(function(...d) {
|
|
3011
|
-
const c = o._def.args.safeParse(d, a);
|
|
3012
|
-
if (!c.success)
|
|
3013
|
-
throw new P([n(d, c.error)]);
|
|
3014
|
-
const l = Reflect.apply(i, this, c.data), w = o._def.returns.safeParse(l, a);
|
|
3015
|
-
if (!w.success)
|
|
3016
|
-
throw new P([s(l, w.error)]);
|
|
3017
|
-
return w.data;
|
|
3018
|
-
});
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
parameters() {
|
|
3022
|
-
return this._def.args;
|
|
3023
|
-
}
|
|
3024
|
-
returnType() {
|
|
3025
|
-
return this._def.returns;
|
|
3026
|
-
}
|
|
3027
|
-
args(...e) {
|
|
3028
|
-
return new he({
|
|
3029
|
-
...this._def,
|
|
3030
|
-
args: L.create(e).rest(se.create())
|
|
3031
|
-
});
|
|
3032
|
-
}
|
|
3033
|
-
returns(e) {
|
|
3034
|
-
return new he({
|
|
3035
|
-
...this._def,
|
|
3036
|
-
returns: e
|
|
3037
|
-
});
|
|
3038
|
-
}
|
|
3039
|
-
implement(e) {
|
|
3040
|
-
return this.parse(e);
|
|
3041
|
-
}
|
|
3042
|
-
strictImplement(e) {
|
|
3043
|
-
return this.parse(e);
|
|
3044
|
-
}
|
|
3045
|
-
static create(e, r, n) {
|
|
3046
|
-
return new he({
|
|
3047
|
-
args: e || L.create([]).rest(se.create()),
|
|
3048
|
-
returns: r || se.create(),
|
|
3049
|
-
typeName: y.ZodFunction,
|
|
3050
|
-
..._(n)
|
|
3051
|
-
});
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
class Ie extends b {
|
|
3055
|
-
get schema() {
|
|
3056
|
-
return this._def.getter();
|
|
3057
|
-
}
|
|
3058
|
-
_parse(e) {
|
|
3059
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3060
|
-
return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
|
|
3061
|
-
}
|
|
3062
|
-
}
|
|
3063
|
-
Ie.create = (t, e) => new Ie({
|
|
3064
|
-
getter: t,
|
|
3065
|
-
typeName: y.ZodLazy,
|
|
3066
|
-
..._(e)
|
|
3067
|
-
});
|
|
3068
|
-
class Pe extends b {
|
|
3069
|
-
_parse(e) {
|
|
3070
|
-
if (e.data !== this._def.value) {
|
|
3071
|
-
const r = this._getOrReturnCtx(e);
|
|
3072
|
-
return f(r, {
|
|
3073
|
-
received: r.data,
|
|
3074
|
-
code: u.invalid_literal,
|
|
3075
|
-
expected: this._def.value
|
|
3076
|
-
}), g;
|
|
3077
|
-
}
|
|
3078
|
-
return { status: "valid", value: e.data };
|
|
3079
|
-
}
|
|
3080
|
-
get value() {
|
|
3081
|
-
return this._def.value;
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
Pe.create = (t, e) => new Pe({
|
|
3085
|
-
value: t,
|
|
3086
|
-
typeName: y.ZodLiteral,
|
|
3087
|
-
..._(e)
|
|
3088
|
-
});
|
|
3089
|
-
function ar(t, e) {
|
|
3090
|
-
return new K({
|
|
3091
|
-
values: t,
|
|
3092
|
-
typeName: y.ZodEnum,
|
|
3093
|
-
..._(e)
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
|
-
class K extends b {
|
|
3097
|
-
constructor() {
|
|
3098
|
-
super(...arguments), ke.set(this, void 0);
|
|
3099
|
-
}
|
|
3100
|
-
_parse(e) {
|
|
3101
|
-
if (typeof e.data != "string") {
|
|
3102
|
-
const r = this._getOrReturnCtx(e), n = this._def.values;
|
|
3103
|
-
return f(r, {
|
|
3104
|
-
expected: k.joinValues(n),
|
|
3105
|
-
received: r.parsedType,
|
|
3106
|
-
code: u.invalid_type
|
|
3107
|
-
}), g;
|
|
3108
|
-
}
|
|
3109
|
-
if (Ye(this, ke) || tr(this, ke, new Set(this._def.values)), !Ye(this, ke).has(e.data)) {
|
|
3110
|
-
const r = this._getOrReturnCtx(e), n = this._def.values;
|
|
3111
|
-
return f(r, {
|
|
3112
|
-
received: r.data,
|
|
3113
|
-
code: u.invalid_enum_value,
|
|
3114
|
-
options: n
|
|
3115
|
-
}), g;
|
|
3116
|
-
}
|
|
3117
|
-
return A(e.data);
|
|
3118
|
-
}
|
|
3119
|
-
get options() {
|
|
3120
|
-
return this._def.values;
|
|
3121
|
-
}
|
|
3122
|
-
get enum() {
|
|
3123
|
-
const e = {};
|
|
3124
|
-
for (const r of this._def.values)
|
|
3125
|
-
e[r] = r;
|
|
3126
|
-
return e;
|
|
3127
|
-
}
|
|
3128
|
-
get Values() {
|
|
3129
|
-
const e = {};
|
|
3130
|
-
for (const r of this._def.values)
|
|
3131
|
-
e[r] = r;
|
|
3132
|
-
return e;
|
|
3133
|
-
}
|
|
3134
|
-
get Enum() {
|
|
3135
|
-
const e = {};
|
|
3136
|
-
for (const r of this._def.values)
|
|
3137
|
-
e[r] = r;
|
|
3138
|
-
return e;
|
|
3139
|
-
}
|
|
3140
|
-
extract(e, r = this._def) {
|
|
3141
|
-
return K.create(e, {
|
|
3142
|
-
...this._def,
|
|
3143
|
-
...r
|
|
3144
|
-
});
|
|
3145
|
-
}
|
|
3146
|
-
exclude(e, r = this._def) {
|
|
3147
|
-
return K.create(this.options.filter((n) => !e.includes(n)), {
|
|
3148
|
-
...this._def,
|
|
3149
|
-
...r
|
|
3150
|
-
});
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
ke = /* @__PURE__ */ new WeakMap();
|
|
3154
|
-
K.create = ar;
|
|
3155
|
-
class je extends b {
|
|
3156
|
-
constructor() {
|
|
3157
|
-
super(...arguments), xe.set(this, void 0);
|
|
3158
|
-
}
|
|
3159
|
-
_parse(e) {
|
|
3160
|
-
const r = k.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
3161
|
-
if (n.parsedType !== p.string && n.parsedType !== p.number) {
|
|
3162
|
-
const s = k.objectValues(r);
|
|
3163
|
-
return f(n, {
|
|
3164
|
-
expected: k.joinValues(s),
|
|
3165
|
-
received: n.parsedType,
|
|
3166
|
-
code: u.invalid_type
|
|
3167
|
-
}), g;
|
|
3168
|
-
}
|
|
3169
|
-
if (Ye(this, xe) || tr(this, xe, new Set(k.getValidEnumValues(this._def.values))), !Ye(this, xe).has(e.data)) {
|
|
3170
|
-
const s = k.objectValues(r);
|
|
3171
|
-
return f(n, {
|
|
3172
|
-
received: n.data,
|
|
3173
|
-
code: u.invalid_enum_value,
|
|
3174
|
-
options: s
|
|
3175
|
-
}), g;
|
|
3176
|
-
}
|
|
3177
|
-
return A(e.data);
|
|
3178
|
-
}
|
|
3179
|
-
get enum() {
|
|
3180
|
-
return this._def.values;
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
xe = /* @__PURE__ */ new WeakMap();
|
|
3184
|
-
je.create = (t, e) => new je({
|
|
3185
|
-
values: t,
|
|
3186
|
-
typeName: y.ZodNativeEnum,
|
|
3187
|
-
..._(e)
|
|
3188
|
-
});
|
|
3189
|
-
class ge extends b {
|
|
3190
|
-
unwrap() {
|
|
3191
|
-
return this._def.type;
|
|
3192
|
-
}
|
|
3193
|
-
_parse(e) {
|
|
3194
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3195
|
-
if (r.parsedType !== p.promise && r.common.async === !1)
|
|
3196
|
-
return f(r, {
|
|
3197
|
-
code: u.invalid_type,
|
|
3198
|
-
expected: p.promise,
|
|
3199
|
-
received: r.parsedType
|
|
3200
|
-
}), g;
|
|
3201
|
-
const n = r.parsedType === p.promise ? r.data : Promise.resolve(r.data);
|
|
3202
|
-
return A(n.then((s) => this._def.type.parseAsync(s, {
|
|
3203
|
-
path: r.path,
|
|
3204
|
-
errorMap: r.common.contextualErrorMap
|
|
3205
|
-
})));
|
|
3206
|
-
}
|
|
3207
|
-
}
|
|
3208
|
-
ge.create = (t, e) => new ge({
|
|
3209
|
-
type: t,
|
|
3210
|
-
typeName: y.ZodPromise,
|
|
3211
|
-
..._(e)
|
|
3212
|
-
});
|
|
3213
|
-
class $ extends b {
|
|
3214
|
-
innerType() {
|
|
3215
|
-
return this._def.schema;
|
|
3216
|
-
}
|
|
3217
|
-
sourceType() {
|
|
3218
|
-
return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3219
|
-
}
|
|
3220
|
-
_parse(e) {
|
|
3221
|
-
const { status: r, ctx: n } = this._processInputParams(e), s = this._def.effect || null, a = {
|
|
3222
|
-
addIssue: (i) => {
|
|
3223
|
-
f(n, i), i.fatal ? r.abort() : r.dirty();
|
|
3224
|
-
},
|
|
3225
|
-
get path() {
|
|
3226
|
-
return n.path;
|
|
3227
|
-
}
|
|
3228
|
-
};
|
|
3229
|
-
if (a.addIssue = a.addIssue.bind(a), s.type === "preprocess") {
|
|
3230
|
-
const i = s.transform(n.data, a);
|
|
3231
|
-
if (n.common.async)
|
|
3232
|
-
return Promise.resolve(i).then(async (o) => {
|
|
3233
|
-
if (r.value === "aborted")
|
|
3234
|
-
return g;
|
|
3235
|
-
const d = await this._def.schema._parseAsync({
|
|
3236
|
-
data: o,
|
|
3237
|
-
path: n.path,
|
|
3238
|
-
parent: n
|
|
3239
|
-
});
|
|
3240
|
-
return d.status === "aborted" ? g : d.status === "dirty" || r.value === "dirty" ? pe(d.value) : d;
|
|
3241
|
-
});
|
|
3242
|
-
{
|
|
3243
|
-
if (r.value === "aborted")
|
|
3244
|
-
return g;
|
|
3245
|
-
const o = this._def.schema._parseSync({
|
|
3246
|
-
data: i,
|
|
3247
|
-
path: n.path,
|
|
3248
|
-
parent: n
|
|
3249
|
-
});
|
|
3250
|
-
return o.status === "aborted" ? g : o.status === "dirty" || r.value === "dirty" ? pe(o.value) : o;
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
if (s.type === "refinement") {
|
|
3254
|
-
const i = (o) => {
|
|
3255
|
-
const d = s.refinement(o, a);
|
|
3256
|
-
if (n.common.async)
|
|
3257
|
-
return Promise.resolve(d);
|
|
3258
|
-
if (d instanceof Promise)
|
|
3259
|
-
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3260
|
-
return o;
|
|
3261
|
-
};
|
|
3262
|
-
if (n.common.async === !1) {
|
|
3263
|
-
const o = this._def.schema._parseSync({
|
|
3264
|
-
data: n.data,
|
|
3265
|
-
path: n.path,
|
|
3266
|
-
parent: n
|
|
3267
|
-
});
|
|
3268
|
-
return o.status === "aborted" ? g : (o.status === "dirty" && r.dirty(), i(o.value), { status: r.value, value: o.value });
|
|
3269
|
-
} else
|
|
3270
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? g : (o.status === "dirty" && r.dirty(), i(o.value).then(() => ({ status: r.value, value: o.value }))));
|
|
3271
|
-
}
|
|
3272
|
-
if (s.type === "transform")
|
|
3273
|
-
if (n.common.async === !1) {
|
|
3274
|
-
const i = this._def.schema._parseSync({
|
|
3275
|
-
data: n.data,
|
|
3276
|
-
path: n.path,
|
|
3277
|
-
parent: n
|
|
3278
|
-
});
|
|
3279
|
-
if (!ae(i))
|
|
3280
|
-
return i;
|
|
3281
|
-
const o = s.transform(i.value, a);
|
|
3282
|
-
if (o instanceof Promise)
|
|
3283
|
-
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3284
|
-
return { status: r.value, value: o };
|
|
3285
|
-
} else
|
|
3286
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => ae(i) ? Promise.resolve(s.transform(i.value, a)).then((o) => ({ status: r.value, value: o })) : i);
|
|
3287
|
-
k.assertNever(s);
|
|
3288
|
-
}
|
|
3289
|
-
}
|
|
3290
|
-
$.create = (t, e, r) => new $({
|
|
3291
|
-
schema: t,
|
|
3292
|
-
typeName: y.ZodEffects,
|
|
3293
|
-
effect: e,
|
|
3294
|
-
..._(r)
|
|
3295
|
-
});
|
|
3296
|
-
$.createWithPreprocess = (t, e, r) => new $({
|
|
3297
|
-
schema: e,
|
|
3298
|
-
effect: { type: "preprocess", transform: t },
|
|
3299
|
-
typeName: y.ZodEffects,
|
|
3300
|
-
..._(r)
|
|
3301
|
-
});
|
|
3302
|
-
class F extends b {
|
|
3303
|
-
_parse(e) {
|
|
3304
|
-
return this._getType(e) === p.undefined ? A(void 0) : this._def.innerType._parse(e);
|
|
3305
|
-
}
|
|
3306
|
-
unwrap() {
|
|
3307
|
-
return this._def.innerType;
|
|
3308
|
-
}
|
|
3309
|
-
}
|
|
3310
|
-
F.create = (t, e) => new F({
|
|
3311
|
-
innerType: t,
|
|
3312
|
-
typeName: y.ZodOptional,
|
|
3313
|
-
..._(e)
|
|
3314
|
-
});
|
|
3315
|
-
class X extends b {
|
|
3316
|
-
_parse(e) {
|
|
3317
|
-
return this._getType(e) === p.null ? A(null) : this._def.innerType._parse(e);
|
|
3318
|
-
}
|
|
3319
|
-
unwrap() {
|
|
3320
|
-
return this._def.innerType;
|
|
3321
|
-
}
|
|
3322
|
-
}
|
|
3323
|
-
X.create = (t, e) => new X({
|
|
3324
|
-
innerType: t,
|
|
3325
|
-
typeName: y.ZodNullable,
|
|
3326
|
-
..._(e)
|
|
3327
|
-
});
|
|
3328
|
-
class Ze extends b {
|
|
3329
|
-
_parse(e) {
|
|
3330
|
-
const { ctx: r } = this._processInputParams(e);
|
|
3331
|
-
let n = r.data;
|
|
3332
|
-
return r.parsedType === p.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
3333
|
-
data: n,
|
|
3334
|
-
path: r.path,
|
|
3335
|
-
parent: r
|
|
3336
|
-
});
|
|
3337
|
-
}
|
|
3338
|
-
removeDefault() {
|
|
3339
|
-
return this._def.innerType;
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
Ze.create = (t, e) => new Ze({
|
|
3343
|
-
innerType: t,
|
|
3344
|
-
typeName: y.ZodDefault,
|
|
3345
|
-
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3346
|
-
..._(e)
|
|
3347
|
-
});
|
|
3348
|
-
class $e extends b {
|
|
3349
|
-
_parse(e) {
|
|
3350
|
-
const { ctx: r } = this._processInputParams(e), n = {
|
|
3351
|
-
...r,
|
|
3352
|
-
common: {
|
|
3353
|
-
...r.common,
|
|
3354
|
-
issues: []
|
|
3355
|
-
}
|
|
3356
|
-
}, s = this._def.innerType._parse({
|
|
3357
|
-
data: n.data,
|
|
3358
|
-
path: n.path,
|
|
3359
|
-
parent: {
|
|
3360
|
-
...n
|
|
3361
|
-
}
|
|
3362
|
-
});
|
|
3363
|
-
return Te(s) ? s.then((a) => ({
|
|
3364
|
-
status: "valid",
|
|
3365
|
-
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
3366
|
-
get error() {
|
|
3367
|
-
return new P(n.common.issues);
|
|
3368
|
-
},
|
|
3369
|
-
input: n.data
|
|
3370
|
-
})
|
|
3371
|
-
})) : {
|
|
3372
|
-
status: "valid",
|
|
3373
|
-
value: s.status === "valid" ? s.value : this._def.catchValue({
|
|
3374
|
-
get error() {
|
|
3375
|
-
return new P(n.common.issues);
|
|
3376
|
-
},
|
|
3377
|
-
input: n.data
|
|
3378
|
-
})
|
|
3379
|
-
};
|
|
3380
|
-
}
|
|
3381
|
-
removeCatch() {
|
|
3382
|
-
return this._def.innerType;
|
|
3383
|
-
}
|
|
3384
|
-
}
|
|
3385
|
-
$e.create = (t, e) => new $e({
|
|
3386
|
-
innerType: t,
|
|
3387
|
-
typeName: y.ZodCatch,
|
|
3388
|
-
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3389
|
-
..._(e)
|
|
3390
|
-
});
|
|
3391
|
-
class Qe extends b {
|
|
3392
|
-
_parse(e) {
|
|
3393
|
-
if (this._getType(e) !== p.nan) {
|
|
3394
|
-
const n = this._getOrReturnCtx(e);
|
|
3395
|
-
return f(n, {
|
|
3396
|
-
code: u.invalid_type,
|
|
3397
|
-
expected: p.nan,
|
|
3398
|
-
received: n.parsedType
|
|
3399
|
-
}), g;
|
|
3400
|
-
}
|
|
3401
|
-
return { status: "valid", value: e.data };
|
|
3402
|
-
}
|
|
3403
|
-
}
|
|
3404
|
-
Qe.create = (t) => new Qe({
|
|
3405
|
-
typeName: y.ZodNaN,
|
|
3406
|
-
..._(t)
|
|
3407
|
-
});
|
|
3408
|
-
const mn = Symbol("zod_brand");
|
|
3409
|
-
class vt extends b {
|
|
3410
|
-
_parse(e) {
|
|
3411
|
-
const { ctx: r } = this._processInputParams(e), n = r.data;
|
|
3412
|
-
return this._def.type._parse({
|
|
3413
|
-
data: n,
|
|
3414
|
-
path: r.path,
|
|
3415
|
-
parent: r
|
|
3416
|
-
});
|
|
3417
|
-
}
|
|
3418
|
-
unwrap() {
|
|
3419
|
-
return this._def.type;
|
|
3420
|
-
}
|
|
3421
|
-
}
|
|
3422
|
-
class Fe extends b {
|
|
3423
|
-
_parse(e) {
|
|
3424
|
-
const { status: r, ctx: n } = this._processInputParams(e);
|
|
3425
|
-
if (n.common.async)
|
|
3426
|
-
return (async () => {
|
|
3427
|
-
const a = await this._def.in._parseAsync({
|
|
3428
|
-
data: n.data,
|
|
3429
|
-
path: n.path,
|
|
3430
|
-
parent: n
|
|
3431
|
-
});
|
|
3432
|
-
return a.status === "aborted" ? g : a.status === "dirty" ? (r.dirty(), pe(a.value)) : this._def.out._parseAsync({
|
|
3433
|
-
data: a.value,
|
|
3434
|
-
path: n.path,
|
|
3435
|
-
parent: n
|
|
3436
|
-
});
|
|
3437
|
-
})();
|
|
3438
|
-
{
|
|
3439
|
-
const s = this._def.in._parseSync({
|
|
3440
|
-
data: n.data,
|
|
3441
|
-
path: n.path,
|
|
3442
|
-
parent: n
|
|
3443
|
-
});
|
|
3444
|
-
return s.status === "aborted" ? g : s.status === "dirty" ? (r.dirty(), {
|
|
3445
|
-
status: "dirty",
|
|
3446
|
-
value: s.value
|
|
3447
|
-
}) : this._def.out._parseSync({
|
|
3448
|
-
data: s.value,
|
|
3449
|
-
path: n.path,
|
|
3450
|
-
parent: n
|
|
3451
|
-
});
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
static create(e, r) {
|
|
3455
|
-
return new Fe({
|
|
3456
|
-
in: e,
|
|
3457
|
-
out: r,
|
|
3458
|
-
typeName: y.ZodPipeline
|
|
3459
|
-
});
|
|
3460
|
-
}
|
|
3461
|
-
}
|
|
3462
|
-
class Me extends b {
|
|
3463
|
-
_parse(e) {
|
|
3464
|
-
const r = this._def.innerType._parse(e), n = (s) => (ae(s) && (s.value = Object.freeze(s.value)), s);
|
|
3465
|
-
return Te(r) ? r.then((s) => n(s)) : n(r);
|
|
3466
|
-
}
|
|
3467
|
-
unwrap() {
|
|
3468
|
-
return this._def.innerType;
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
Me.create = (t, e) => new Me({
|
|
3472
|
-
innerType: t,
|
|
3473
|
-
typeName: y.ZodReadonly,
|
|
3474
|
-
..._(e)
|
|
3475
|
-
});
|
|
3476
|
-
function St(t, e) {
|
|
3477
|
-
const r = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
|
|
3478
|
-
return typeof r == "string" ? { message: r } : r;
|
|
3479
|
-
}
|
|
3480
|
-
function ir(t, e = {}, r) {
|
|
3481
|
-
return t ? ye.create().superRefine((n, s) => {
|
|
3482
|
-
var a, i;
|
|
3483
|
-
const o = t(n);
|
|
3484
|
-
if (o instanceof Promise)
|
|
3485
|
-
return o.then((d) => {
|
|
3486
|
-
var c, l;
|
|
3487
|
-
if (!d) {
|
|
3488
|
-
const w = St(e, n), S = (l = (c = w.fatal) !== null && c !== void 0 ? c : r) !== null && l !== void 0 ? l : !0;
|
|
3489
|
-
s.addIssue({ code: "custom", ...w, fatal: S });
|
|
3490
|
-
}
|
|
3491
|
-
});
|
|
3492
|
-
if (!o) {
|
|
3493
|
-
const d = St(e, n), c = (i = (a = d.fatal) !== null && a !== void 0 ? a : r) !== null && i !== void 0 ? i : !0;
|
|
3494
|
-
s.addIssue({ code: "custom", ...d, fatal: c });
|
|
3495
|
-
}
|
|
3496
|
-
}) : ye.create();
|
|
3497
|
-
}
|
|
3498
|
-
const yn = {
|
|
3499
|
-
object: E.lazycreate
|
|
3500
|
-
};
|
|
3501
|
-
var y;
|
|
3502
|
-
(function(t) {
|
|
3503
|
-
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
3504
|
-
})(y || (y = {}));
|
|
3505
|
-
const gn = (t, e = {
|
|
3506
|
-
message: `Input not instance of ${t.name}`
|
|
3507
|
-
}) => ir((r) => r instanceof t, e), or = j.create, dr = Y.create, vn = Qe.create, _n = G.create, cr = Ee.create, bn = ie.create, wn = Ge.create, kn = Oe.create, xn = Ne.create, Sn = ye.create, Tn = se.create, En = H.create, On = Ke.create, Nn = Z.create, Rn = E.create, An = E.strictCreate, Cn = Re.create, In = tt.create, Pn = Ae.create, jn = L.create, Zn = Ce.create, $n = Xe.create, Mn = oe.create, Fn = he.create, Dn = Ie.create, Ln = Pe.create, Vn = K.create, zn = je.create, qn = ge.create, Tt = $.create, Un = F.create, Hn = X.create, Bn = $.createWithPreprocess, Wn = Fe.create, Jn = () => or().optional(), Yn = () => dr().optional(), Gn = () => cr().optional(), Kn = {
|
|
3508
|
-
string: (t) => j.create({ ...t, coerce: !0 }),
|
|
3509
|
-
number: (t) => Y.create({ ...t, coerce: !0 }),
|
|
3510
|
-
boolean: (t) => Ee.create({
|
|
3511
|
-
...t,
|
|
3512
|
-
coerce: !0
|
|
3513
|
-
}),
|
|
3514
|
-
bigint: (t) => G.create({ ...t, coerce: !0 }),
|
|
3515
|
-
date: (t) => ie.create({ ...t, coerce: !0 })
|
|
3516
|
-
}, Xn = g;
|
|
3517
|
-
var h = /* @__PURE__ */ Object.freeze({
|
|
3518
|
-
__proto__: null,
|
|
3519
|
-
defaultErrorMap: me,
|
|
3520
|
-
setErrorMap: Hr,
|
|
3521
|
-
getErrorMap: We,
|
|
3522
|
-
makeIssue: Je,
|
|
3523
|
-
EMPTY_PATH: Br,
|
|
3524
|
-
addIssueToContext: f,
|
|
3525
|
-
ParseStatus: N,
|
|
3526
|
-
INVALID: g,
|
|
3527
|
-
DIRTY: pe,
|
|
3528
|
-
OK: A,
|
|
3529
|
-
isAborted: ut,
|
|
3530
|
-
isDirty: lt,
|
|
3531
|
-
isValid: ae,
|
|
3532
|
-
isAsync: Te,
|
|
3533
|
-
get util() {
|
|
3534
|
-
return k;
|
|
3535
|
-
},
|
|
3536
|
-
get objectUtil() {
|
|
3537
|
-
return ct;
|
|
3538
|
-
},
|
|
3539
|
-
ZodParsedType: p,
|
|
3540
|
-
getParsedType: U,
|
|
3541
|
-
ZodType: b,
|
|
3542
|
-
datetimeRegex: sr,
|
|
3543
|
-
ZodString: j,
|
|
3544
|
-
ZodNumber: Y,
|
|
3545
|
-
ZodBigInt: G,
|
|
3546
|
-
ZodBoolean: Ee,
|
|
3547
|
-
ZodDate: ie,
|
|
3548
|
-
ZodSymbol: Ge,
|
|
3549
|
-
ZodUndefined: Oe,
|
|
3550
|
-
ZodNull: Ne,
|
|
3551
|
-
ZodAny: ye,
|
|
3552
|
-
ZodUnknown: se,
|
|
3553
|
-
ZodNever: H,
|
|
3554
|
-
ZodVoid: Ke,
|
|
3555
|
-
ZodArray: Z,
|
|
3556
|
-
ZodObject: E,
|
|
3557
|
-
ZodUnion: Re,
|
|
3558
|
-
ZodDiscriminatedUnion: tt,
|
|
3559
|
-
ZodIntersection: Ae,
|
|
3560
|
-
ZodTuple: L,
|
|
3561
|
-
ZodRecord: Ce,
|
|
3562
|
-
ZodMap: Xe,
|
|
3563
|
-
ZodSet: oe,
|
|
3564
|
-
ZodFunction: he,
|
|
3565
|
-
ZodLazy: Ie,
|
|
3566
|
-
ZodLiteral: Pe,
|
|
3567
|
-
ZodEnum: K,
|
|
3568
|
-
ZodNativeEnum: je,
|
|
3569
|
-
ZodPromise: ge,
|
|
3570
|
-
ZodEffects: $,
|
|
3571
|
-
ZodTransformer: $,
|
|
3572
|
-
ZodOptional: F,
|
|
3573
|
-
ZodNullable: X,
|
|
3574
|
-
ZodDefault: Ze,
|
|
3575
|
-
ZodCatch: $e,
|
|
3576
|
-
ZodNaN: Qe,
|
|
3577
|
-
BRAND: mn,
|
|
3578
|
-
ZodBranded: vt,
|
|
3579
|
-
ZodPipeline: Fe,
|
|
3580
|
-
ZodReadonly: Me,
|
|
3581
|
-
custom: ir,
|
|
3582
|
-
Schema: b,
|
|
3583
|
-
ZodSchema: b,
|
|
3584
|
-
late: yn,
|
|
3585
|
-
get ZodFirstPartyTypeKind() {
|
|
3586
|
-
return y;
|
|
3587
|
-
},
|
|
3588
|
-
coerce: Kn,
|
|
3589
|
-
any: Sn,
|
|
3590
|
-
array: Nn,
|
|
3591
|
-
bigint: _n,
|
|
3592
|
-
boolean: cr,
|
|
3593
|
-
date: bn,
|
|
3594
|
-
discriminatedUnion: In,
|
|
3595
|
-
effect: Tt,
|
|
3596
|
-
enum: Vn,
|
|
3597
|
-
function: Fn,
|
|
3598
|
-
instanceof: gn,
|
|
3599
|
-
intersection: Pn,
|
|
3600
|
-
lazy: Dn,
|
|
3601
|
-
literal: Ln,
|
|
3602
|
-
map: $n,
|
|
3603
|
-
nan: vn,
|
|
3604
|
-
nativeEnum: zn,
|
|
3605
|
-
never: En,
|
|
3606
|
-
null: xn,
|
|
3607
|
-
nullable: Hn,
|
|
3608
|
-
number: dr,
|
|
3609
|
-
object: Rn,
|
|
3610
|
-
oboolean: Gn,
|
|
3611
|
-
onumber: Yn,
|
|
3612
|
-
optional: Un,
|
|
3613
|
-
ostring: Jn,
|
|
3614
|
-
pipeline: Wn,
|
|
3615
|
-
preprocess: Bn,
|
|
3616
|
-
promise: qn,
|
|
3617
|
-
record: Zn,
|
|
3618
|
-
set: Mn,
|
|
3619
|
-
strictObject: An,
|
|
3620
|
-
string: or,
|
|
3621
|
-
symbol: wn,
|
|
3622
|
-
transformer: Tt,
|
|
3623
|
-
tuple: jn,
|
|
3624
|
-
undefined: kn,
|
|
3625
|
-
union: Cn,
|
|
3626
|
-
unknown: Tn,
|
|
3627
|
-
void: On,
|
|
3628
|
-
NEVER: Xn,
|
|
3629
|
-
ZodIssueCode: u,
|
|
3630
|
-
quotelessJson: Ur,
|
|
3631
|
-
ZodError: P
|
|
3632
|
-
});
|
|
3633
|
-
const pt = h.object({
|
|
3634
|
-
detail: h.string()
|
|
3635
|
-
}), ur = h.object({
|
|
3636
|
-
error: h.string()
|
|
3637
|
-
});
|
|
3638
|
-
function lr(t) {
|
|
3639
|
-
if (!t)
|
|
3640
|
-
return "Unknown error";
|
|
3641
|
-
if (t instanceof Error) {
|
|
3642
|
-
const e = pt.safeParse(t.cause);
|
|
3643
|
-
return e.success ? e.data.detail : Qn(t.message);
|
|
3644
|
-
}
|
|
3645
|
-
if (typeof t == "object") {
|
|
3646
|
-
const e = pt.safeParse(t);
|
|
3647
|
-
if (e.success)
|
|
3648
|
-
return e.data.detail;
|
|
3649
|
-
const r = ur.safeParse(t);
|
|
3650
|
-
if (r.success)
|
|
3651
|
-
return r.data.error;
|
|
3652
|
-
}
|
|
3653
|
-
try {
|
|
3654
|
-
return JSON.stringify(t);
|
|
3655
|
-
} catch {
|
|
3656
|
-
return String(t);
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
|
-
function Qn(t) {
|
|
3660
|
-
const e = es(t);
|
|
3661
|
-
if (!e)
|
|
3662
|
-
return t;
|
|
3663
|
-
const r = pt.safeParse(e);
|
|
3664
|
-
if (r.success)
|
|
3665
|
-
return r.data.detail;
|
|
3666
|
-
const n = ur.safeParse(e);
|
|
3667
|
-
return n.success ? n.data.error : t;
|
|
3668
|
-
}
|
|
3669
|
-
function es(t) {
|
|
3670
|
-
try {
|
|
3671
|
-
return JSON.parse(t);
|
|
3672
|
-
} catch {
|
|
3673
|
-
return t;
|
|
3674
|
-
}
|
|
3675
|
-
}
|
|
3676
|
-
function fr(t, e) {
|
|
3677
|
-
if (!t)
|
|
3678
|
-
throw new Error(e);
|
|
3679
|
-
}
|
|
3680
|
-
const ts = [
|
|
3681
|
-
"pip",
|
|
3682
|
-
"uv",
|
|
3683
|
-
"rye",
|
|
3684
|
-
"poetry",
|
|
3685
|
-
"pixi"
|
|
3686
|
-
], pr = [
|
|
3687
|
-
"normal",
|
|
3688
|
-
"compact",
|
|
3689
|
-
"medium",
|
|
3690
|
-
"full",
|
|
3691
|
-
"columns"
|
|
3692
|
-
], hr = [
|
|
3693
|
-
"auto",
|
|
3694
|
-
"native",
|
|
3695
|
-
"polars",
|
|
3696
|
-
"lazy-polars",
|
|
3697
|
-
"pandas"
|
|
3698
|
-
], rs = h.object({
|
|
3699
|
-
completion: h.object({
|
|
3700
|
-
activate_on_typing: h.boolean().default(!0),
|
|
3701
|
-
copilot: h.union([h.boolean(), h.enum(["github", "codeium", "custom"])]).default(!1).transform((t) => t === !0 ? "github" : t),
|
|
3702
|
-
codeium_api_key: h.string().nullish()
|
|
3703
|
-
}).passthrough().default({}),
|
|
3704
|
-
save: h.object({
|
|
3705
|
-
autosave: h.enum(["off", "after_delay"]).default("after_delay"),
|
|
3706
|
-
autosave_delay: h.number().nonnegative().transform((t) => Math.max(t, 1e3)).default(1e3),
|
|
3707
|
-
format_on_save: h.boolean().default(!1)
|
|
3708
|
-
}).passthrough().default({}),
|
|
3709
|
-
formatting: h.object({
|
|
3710
|
-
line_length: h.number().nonnegative().default(79).transform((t) => Math.min(t, 1e3))
|
|
3711
|
-
}).passthrough().default({}),
|
|
3712
|
-
keymap: h.object({
|
|
3713
|
-
preset: h.enum(["default", "vim"]).default("default"),
|
|
3714
|
-
overrides: h.record(h.string()).default({})
|
|
3715
|
-
}).passthrough().default({}),
|
|
3716
|
-
runtime: h.object({
|
|
3717
|
-
auto_instantiate: h.boolean().default(!0),
|
|
3718
|
-
on_cell_change: h.enum(["lazy", "autorun"]).default("autorun"),
|
|
3719
|
-
auto_reload: h.enum(["off", "lazy", "autorun"]).default("off"),
|
|
3720
|
-
watcher_on_save: h.enum(["lazy", "autorun"]).default("lazy"),
|
|
3721
|
-
default_sql_output: h.enum(hr).default("auto")
|
|
3722
|
-
}).passthrough().default({}),
|
|
3723
|
-
display: h.object({
|
|
3724
|
-
theme: h.enum(["light", "dark", "system"]).default("light"),
|
|
3725
|
-
code_editor_font_size: h.number().nonnegative().default(14),
|
|
3726
|
-
cell_output: h.enum(["above", "below"]).default("above"),
|
|
3727
|
-
dataframes: h.enum(["rich", "plain"]).default("rich"),
|
|
3728
|
-
default_table_page_size: h.number().default(10),
|
|
3729
|
-
default_width: h.enum(pr).default("medium").transform((t) => t === "normal" ? "compact" : t),
|
|
3730
|
-
reference_highlighting: h.boolean().default(!1)
|
|
3731
|
-
}).passthrough().default({}),
|
|
3732
|
-
package_management: h.object({
|
|
3733
|
-
manager: h.enum(ts).default("pip")
|
|
3734
|
-
}).passthrough().default({ manager: "pip" }),
|
|
3735
|
-
ai: h.object({
|
|
3736
|
-
rules: h.string().default(""),
|
|
3737
|
-
mode: h.enum(["manual", "ask"]).default("manual"),
|
|
3738
|
-
open_ai: h.object({
|
|
3739
|
-
api_key: h.string().optional(),
|
|
3740
|
-
base_url: h.string().optional(),
|
|
3741
|
-
model: h.string().optional()
|
|
3742
|
-
}).optional(),
|
|
3743
|
-
anthropic: h.object({
|
|
3744
|
-
api_key: h.string().optional()
|
|
3745
|
-
}).optional(),
|
|
3746
|
-
google: h.object({
|
|
3747
|
-
api_key: h.string().optional()
|
|
3748
|
-
}).optional(),
|
|
3749
|
-
bedrock: h.object({
|
|
3750
|
-
region_name: h.string().optional(),
|
|
3751
|
-
profile_name: h.string().optional(),
|
|
3752
|
-
aws_access_key_id: h.string().optional(),
|
|
3753
|
-
aws_secret_access_key: h.string().optional()
|
|
3754
|
-
}).optional()
|
|
3755
|
-
}).passthrough().default({}),
|
|
3756
|
-
experimental: h.object({
|
|
3757
|
-
markdown: h.boolean().optional(),
|
|
3758
|
-
rtc: h.boolean().optional()
|
|
3759
|
-
// Add new experimental features here
|
|
3760
|
-
}).passthrough().default({}),
|
|
3761
|
-
server: h.object({}).passthrough().default({}),
|
|
3762
|
-
sharing: h.object({
|
|
3763
|
-
html: h.boolean().optional(),
|
|
3764
|
-
wasm: h.boolean().optional()
|
|
3765
|
-
}).passthrough().optional()
|
|
3766
|
-
}).passthrough().default({
|
|
3767
|
-
completion: {},
|
|
3768
|
-
save: {},
|
|
3769
|
-
formatting: {},
|
|
3770
|
-
keymap: {},
|
|
3771
|
-
runtime: {},
|
|
3772
|
-
display: {},
|
|
3773
|
-
experimental: {},
|
|
3774
|
-
server: {},
|
|
3775
|
-
ai: {
|
|
3776
|
-
rules: "",
|
|
3777
|
-
mode: "manual",
|
|
3778
|
-
open_ai: {}
|
|
3779
|
-
}
|
|
3780
|
-
}), ns = h.string(), ss = h.enum(hr).default("auto");
|
|
3781
|
-
h.object({
|
|
3782
|
-
width: h.enum(pr).default("medium").transform((t) => t === "normal" ? "compact" : t),
|
|
3783
|
-
app_title: ns.nullish(),
|
|
3784
|
-
css_file: h.string().nullish(),
|
|
3785
|
-
html_head_file: h.string().nullish(),
|
|
3786
|
-
auto_download: h.array(h.enum(["html", "markdown", "ipynb"])).default([]),
|
|
3787
|
-
sql_output: ss
|
|
3788
|
-
}).default({ width: "medium", auto_download: [] });
|
|
3789
|
-
function as() {
|
|
3790
|
-
return rs.parse({});
|
|
3791
|
-
}
|
|
3792
|
-
const Et = (t) => new TextDecoder().decode(t);
|
|
3793
|
-
function Se(t) {
|
|
3794
|
-
return t.FS;
|
|
3795
|
-
}
|
|
3796
|
-
const be = "notebook.py", we = "/marimo", ne = {
|
|
3797
|
-
NOTEBOOK_FILENAME: be,
|
|
3798
|
-
HOME_DIR: we,
|
|
3799
|
-
createHomeDir: (t) => {
|
|
3800
|
-
const e = Se(t);
|
|
3801
|
-
try {
|
|
3802
|
-
e.mkdirTree(we);
|
|
3803
|
-
} catch {
|
|
3804
|
-
}
|
|
3805
|
-
e.chdir(we);
|
|
3806
|
-
},
|
|
3807
|
-
mountFS: (t) => {
|
|
3808
|
-
Se(t).mount(t.FS.filesystems.IDBFS, { root: "." }, we);
|
|
3809
|
-
},
|
|
3810
|
-
populateFilesToMemory: async (t) => {
|
|
3811
|
-
await Ot(t, !0);
|
|
3812
|
-
},
|
|
3813
|
-
persistFilesToRemote: async (t) => {
|
|
3814
|
-
await Ot(t, !1);
|
|
3815
|
-
},
|
|
3816
|
-
readNotebook: (t) => {
|
|
3817
|
-
const e = Se(t), r = `${we}/${be}`;
|
|
3818
|
-
return Et(e.readFile(r));
|
|
3819
|
-
},
|
|
3820
|
-
initNotebookCode: (t) => {
|
|
3821
|
-
const { pyodide: e, filename: r, code: n } = t, s = Se(e), a = (i) => {
|
|
3822
|
-
try {
|
|
3823
|
-
return Et(s.readFile(i));
|
|
3824
|
-
} catch {
|
|
3825
|
-
return null;
|
|
3826
|
-
}
|
|
3827
|
-
};
|
|
3828
|
-
if (r && r !== be) {
|
|
3829
|
-
const i = a(r);
|
|
3830
|
-
if (i)
|
|
3831
|
-
return {
|
|
3832
|
-
code: i,
|
|
3833
|
-
filename: r
|
|
3834
|
-
};
|
|
3835
|
-
}
|
|
3836
|
-
return s.writeFile(be, n), {
|
|
3837
|
-
code: n,
|
|
3838
|
-
filename: be
|
|
3839
|
-
};
|
|
3840
|
-
}
|
|
3841
|
-
};
|
|
3842
|
-
function Ot(t, e) {
|
|
3843
|
-
return new Promise((r, n) => {
|
|
3844
|
-
Se(t).syncfs(e, (s) => {
|
|
3845
|
-
if (s instanceof Error) {
|
|
3846
|
-
n(s);
|
|
3847
|
-
return;
|
|
3848
|
-
}
|
|
3849
|
-
r();
|
|
3850
|
-
});
|
|
3851
|
-
});
|
|
3852
|
-
}
|
|
3853
|
-
class is {
|
|
3854
|
-
spans = [];
|
|
3855
|
-
startSpan(e, r = {}) {
|
|
3856
|
-
const n = {
|
|
3857
|
-
name: e,
|
|
3858
|
-
startTime: Date.now(),
|
|
3859
|
-
attributes: r,
|
|
3860
|
-
end: (s = "ok") => this.endSpan(n, s)
|
|
3861
|
-
};
|
|
3862
|
-
return this.spans.push(n), n;
|
|
3863
|
-
}
|
|
3864
|
-
endSpan(e, r = "ok") {
|
|
3865
|
-
e.endTime = Date.now(), e.status = r;
|
|
3866
|
-
}
|
|
3867
|
-
getSpans() {
|
|
3868
|
-
return this.spans;
|
|
3869
|
-
}
|
|
3870
|
-
wrap(e, r, n = {}) {
|
|
3871
|
-
const s = this.startSpan(r || e.name, n);
|
|
3872
|
-
try {
|
|
3873
|
-
const a = e();
|
|
3874
|
-
return this.endSpan(s), a;
|
|
3875
|
-
} catch (a) {
|
|
3876
|
-
throw this.endSpan(s, "error"), a;
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
wrapAsync(e, r, n = {}) {
|
|
3880
|
-
return async (...s) => {
|
|
3881
|
-
const a = this.startSpan(r || e.name, n);
|
|
3882
|
-
try {
|
|
3883
|
-
const i = await e(...s);
|
|
3884
|
-
return this.endSpan(a), i;
|
|
3885
|
-
} catch (i) {
|
|
3886
|
-
throw this.endSpan(a, "error"), i;
|
|
3887
|
-
}
|
|
3888
|
-
};
|
|
3889
|
-
}
|
|
3890
|
-
logSpans() {
|
|
3891
|
-
}
|
|
3892
|
-
}
|
|
3893
|
-
const fe = new is();
|
|
3894
|
-
globalThis.t = fe;
|
|
3895
|
-
const os = !1;
|
|
3896
|
-
class ds {
|
|
3897
|
-
pyodide = null;
|
|
3898
|
-
get requirePyodide() {
|
|
3899
|
-
return fr(this.pyodide, "Pyodide not loaded"), this.pyodide;
|
|
3900
|
-
}
|
|
3901
|
-
async bootstrap(e) {
|
|
3902
|
-
return await this.loadPyodideAndPackages(e);
|
|
3903
|
-
}
|
|
3904
|
-
async loadPyodideAndPackages(e) {
|
|
3905
|
-
if (!dt)
|
|
3906
|
-
throw new Error("loadPyodide is not defined");
|
|
3907
|
-
const r = fe.startSpan("loadPyodide");
|
|
3908
|
-
try {
|
|
3909
|
-
const n = await dt({
|
|
3910
|
-
// Perf: These get loaded while pyodide is being bootstrapped
|
|
3911
|
-
packages: [
|
|
3912
|
-
"micropip",
|
|
3913
|
-
"marimo-base",
|
|
3914
|
-
"Markdown",
|
|
3915
|
-
"pymdown-extensions",
|
|
3916
|
-
"narwhals",
|
|
3917
|
-
"packaging"
|
|
3918
|
-
],
|
|
3919
|
-
_makeSnapshot: os,
|
|
3920
|
-
lockFileURL: `https://wasm.marimo.app/pyodide-lock.json?v=${e.version}&pyodide=${e.pyodideVersion}`,
|
|
3921
|
-
// Without this, this fails in Firefox with
|
|
3922
|
-
// `Could not extract indexURL path from pyodide module`
|
|
3923
|
-
// This fixes for Firefox and does not break Chrome/others
|
|
3924
|
-
indexURL: `https://cdn.jsdelivr.net/pyodide/${e.pyodideVersion}/full/`
|
|
3925
|
-
});
|
|
3926
|
-
return this.pyodide = n, r.end("ok"), n;
|
|
3927
|
-
} catch (n) {
|
|
3928
|
-
throw W.error("Failed to load Pyodide", n), n;
|
|
3929
|
-
}
|
|
3930
|
-
}
|
|
3931
|
-
async mountFilesystem(e) {
|
|
3932
|
-
const r = fe.startSpan("mountFilesystem");
|
|
3933
|
-
return ne.createHomeDir(this.requirePyodide), ne.mountFS(this.requirePyodide), await ne.populateFilesToMemory(this.requirePyodide), r.end("ok"), ne.initNotebookCode({
|
|
3934
|
-
pyodide: this.requirePyodide,
|
|
3935
|
-
code: e.code,
|
|
3936
|
-
filename: e.filename
|
|
3937
|
-
});
|
|
3938
|
-
}
|
|
3939
|
-
async startSession(e) {
|
|
3940
|
-
const { code: r, filename: n, onMessage: s, queryParameters: a, userConfig: i } = e;
|
|
3941
|
-
self.messenger = {
|
|
3942
|
-
callback: s
|
|
3943
|
-
}, self.query_params = a, self.user_config = i;
|
|
3944
|
-
const o = fe.startSpan("startSession.runPython"), d = n || ne.NOTEBOOK_FILENAME, [c, l, w] = this.requirePyodide.runPython(
|
|
3945
|
-
`
|
|
3946
|
-
print("[py] Starting marimo...")
|
|
3947
|
-
import asyncio
|
|
3948
|
-
import js
|
|
3949
|
-
from marimo._pyodide.bootstrap import create_session, instantiate
|
|
3950
|
-
|
|
3951
|
-
assert js.messenger, "messenger is not defined"
|
|
3952
|
-
assert js.query_params, "query_params is not defined"
|
|
3953
|
-
|
|
3954
|
-
session, bridge = create_session(
|
|
3955
|
-
filename="${d}",
|
|
3956
|
-
query_params=js.query_params.to_py(),
|
|
3957
|
-
message_callback=js.messenger.callback,
|
|
3958
|
-
user_config=js.user_config.to_py(),
|
|
3959
|
-
)
|
|
3960
|
-
|
|
3961
|
-
def init(auto_instantiate=True):
|
|
3962
|
-
instantiate(session, auto_instantiate)
|
|
3963
|
-
asyncio.create_task(session.start())
|
|
3964
|
-
|
|
3965
|
-
# Find the packages to install
|
|
3966
|
-
with open("${d}", "r") as f:
|
|
3967
|
-
packages = session.find_packages(f.read())
|
|
3968
|
-
|
|
3969
|
-
bridge, init, packages`
|
|
3970
|
-
);
|
|
3971
|
-
o.end();
|
|
3972
|
-
const S = new Set(w.toJs());
|
|
3973
|
-
return this.loadNotebookDeps(r, S).then(() => l(i.runtime.auto_instantiate)), c;
|
|
3974
|
-
}
|
|
3975
|
-
async loadNotebookDeps(e, r) {
|
|
3976
|
-
const n = this.requirePyodide;
|
|
3977
|
-
e.includes("mo.sql") && (e = `import pandas
|
|
3978
|
-
${e}`, e = `import duckdb
|
|
3979
|
-
${e}`, e = `import sqlglot
|
|
3980
|
-
${e}`, e.includes("polars") && (e = `import pyarrow
|
|
3981
|
-
${e}`)), e = `import docutils
|
|
3982
|
-
${e}`, e = `import pygments
|
|
3983
|
-
${e}`, e = `import jedi
|
|
3984
|
-
${e}`, e = `import pyodide_http
|
|
3985
|
-
${e}`;
|
|
3986
|
-
const s = [...r];
|
|
3987
|
-
let a = fe.startSpan("pyodide.loadPackage");
|
|
3988
|
-
await n.loadPackagesFromImports(e, {
|
|
3989
|
-
errorCallback: W.error,
|
|
3990
|
-
messageCallback: W.log
|
|
3991
|
-
}), a.end(), a = fe.startSpan("micropip.install");
|
|
3992
|
-
const i = s.filter(
|
|
3993
|
-
(o) => !n.loadedPackages[o]
|
|
3994
|
-
);
|
|
3995
|
-
i.length > 0 && await n.runPythonAsync(`
|
|
3996
|
-
import micropip
|
|
3997
|
-
import sys
|
|
3998
|
-
# Filter out builtins
|
|
3999
|
-
missing = [p for p in ${JSON.stringify(i)} if p not in sys.modules]
|
|
4000
|
-
if len(missing) > 0:
|
|
4001
|
-
print("Loading from micropip:", missing)
|
|
4002
|
-
await micropip.install(missing)
|
|
4003
|
-
`).catch((o) => {
|
|
4004
|
-
W.error("Failed to load packages from micropip", o);
|
|
4005
|
-
}), a.end();
|
|
4006
|
-
}
|
|
4007
|
-
}
|
|
4008
|
-
class cs extends ds {
|
|
4009
|
-
async bootstrap(e) {
|
|
4010
|
-
return await super.bootstrap(e);
|
|
4011
|
-
}
|
|
4012
|
-
async mountFilesystem(e) {
|
|
4013
|
-
const { code: r, filename: n } = e;
|
|
4014
|
-
try {
|
|
4015
|
-
return ne.createHomeDir(this.requirePyodide), ne.initNotebookCode({
|
|
4016
|
-
pyodide: this.requirePyodide,
|
|
4017
|
-
code: r,
|
|
4018
|
-
filename: n
|
|
4019
|
-
});
|
|
4020
|
-
} catch (s) {
|
|
4021
|
-
W.error(s);
|
|
4022
|
-
}
|
|
4023
|
-
return { code: r, filename: n };
|
|
4024
|
-
}
|
|
4025
|
-
async startSession(e) {
|
|
4026
|
-
return super.startSession({
|
|
4027
|
-
queryParameters: {},
|
|
4028
|
-
code: e.code,
|
|
4029
|
-
filename: e.filename,
|
|
4030
|
-
onMessage: e.onMessage,
|
|
4031
|
-
userConfig: as()
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4034
|
-
}
|
|
4035
|
-
async function us() {
|
|
4036
|
-
const t = fs(), e = Lr(t);
|
|
4037
|
-
try {
|
|
4038
|
-
self.controller = new cs(), self.pyodide = await self.controller.bootstrap({
|
|
4039
|
-
version: t,
|
|
4040
|
-
pyodideVersion: e
|
|
4041
|
-
});
|
|
4042
|
-
} catch (r) {
|
|
4043
|
-
W.error("Error bootstrapping", r), ve.send.initializedError({
|
|
4044
|
-
error: lr(r)
|
|
4045
|
-
});
|
|
4046
|
-
}
|
|
4047
|
-
}
|
|
4048
|
-
const qe = us(), mr = new Vr(
|
|
4049
|
-
(t) => {
|
|
4050
|
-
ve.send.kernelMessage({ message: t });
|
|
4051
|
-
}
|
|
4052
|
-
), Nt = new qr(), ls = {
|
|
4053
|
-
/**
|
|
4054
|
-
* Start the session
|
|
4055
|
-
*/
|
|
4056
|
-
startSession: async (t) => {
|
|
4057
|
-
await qe;
|
|
4058
|
-
try {
|
|
4059
|
-
fr(self.controller, "Controller not loaded");
|
|
4060
|
-
const e = await self.controller.mountFilesystem({
|
|
4061
|
-
code: t.code,
|
|
4062
|
-
filename: `app-${t.appId}.py`
|
|
4063
|
-
}), r = await self.controller.startSession({
|
|
4064
|
-
...e,
|
|
4065
|
-
onMessage: mr.push
|
|
4066
|
-
});
|
|
4067
|
-
Nt.resolve(r), ve.send.initialized({});
|
|
4068
|
-
} catch (e) {
|
|
4069
|
-
ve.send.initializedError({
|
|
4070
|
-
error: lr(e)
|
|
4071
|
-
});
|
|
4072
|
-
}
|
|
4073
|
-
},
|
|
4074
|
-
/**
|
|
4075
|
-
* Load packages
|
|
4076
|
-
*/
|
|
4077
|
-
loadPackages: async (t) => {
|
|
4078
|
-
await qe, t.includes("mo.sql") && (t = `import pandas
|
|
4079
|
-
${t}`, t = `import duckdb
|
|
4080
|
-
${t}`, t = `import sqlglot
|
|
4081
|
-
${t}`, t.includes("polars") && (t = `import pyarrow
|
|
4082
|
-
${t}`)), await self.pyodide.loadPackagesFromImports(t, {
|
|
4083
|
-
messageCallback: W.log,
|
|
4084
|
-
errorCallback: W.error
|
|
4085
|
-
});
|
|
4086
|
-
},
|
|
4087
|
-
/**
|
|
4088
|
-
* Call a function on the bridge
|
|
4089
|
-
*/
|
|
4090
|
-
bridge: async (t) => {
|
|
4091
|
-
await qe;
|
|
4092
|
-
const { functionName: e, payload: r } = t, n = await Nt.promise, s = r == null ? null : typeof r == "string" ? r : JSON.stringify(r), a = s == null ? (
|
|
4093
|
-
// @ts-expect-error ehh TypeScript
|
|
4094
|
-
await n[e]()
|
|
4095
|
-
) : (
|
|
4096
|
-
// @ts-expect-error ehh TypeScript
|
|
4097
|
-
await n[e](s)
|
|
4098
|
-
);
|
|
4099
|
-
return typeof a == "string" ? JSON.parse(a) : a;
|
|
4100
|
-
}
|
|
4101
|
-
}, ve = xr({
|
|
4102
|
-
transport: Or({
|
|
4103
|
-
transportId: Nr
|
|
4104
|
-
}),
|
|
4105
|
-
requestHandler: ls
|
|
4106
|
-
});
|
|
4107
|
-
ve.send("ready", {});
|
|
4108
|
-
ve.addMessageListener("consumerReady", async () => {
|
|
4109
|
-
await qe, mr.start();
|
|
4110
|
-
});
|
|
4111
|
-
function fs() {
|
|
4112
|
-
return self.name;
|
|
4113
|
-
}
|
|
4114
|
-
});
|
|
4115
|
-
export default ps();
|