@abduljebar/text-editor 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2878 @@
1
+ import Lt, { useState as ze, useEffect as ut, useRef as Mt, useCallback as V } from "react";
2
+ import { Save as Vt, FileDown as Wt, Trash2 as Bt, Bold as Yt, Italic as Jt, Underline as Gt, Strikethrough as qt, List as Ht, ListOrdered as Xt, Heading1 as Kt, Heading2 as Qt, Type as en, AlignLeft as tn, AlignCenter as nn, AlignRight as rn, Link as on } from "lucide-react";
3
+ var K = { exports: {} }, Y = {};
4
+ /**
5
+ * @license React
6
+ * react-jsx-runtime.production.js
7
+ *
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ var Ne;
14
+ function cn() {
15
+ if (Ne) return Y;
16
+ Ne = 1;
17
+ var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
18
+ function n(r, o, i) {
19
+ var c = null;
20
+ if (i !== void 0 && (c = "" + i), o.key !== void 0 && (c = "" + o.key), "key" in o) {
21
+ i = {};
22
+ for (var a in o)
23
+ a !== "key" && (i[a] = o[a]);
24
+ } else i = o;
25
+ return o = i.ref, {
26
+ $$typeof: e,
27
+ type: r,
28
+ key: c,
29
+ ref: o !== void 0 ? o : null,
30
+ props: i
31
+ };
32
+ }
33
+ return Y.Fragment = t, Y.jsx = n, Y.jsxs = n, Y;
34
+ }
35
+ var J = {};
36
+ /**
37
+ * @license React
38
+ * react-jsx-runtime.development.js
39
+ *
40
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
41
+ *
42
+ * This source code is licensed under the MIT license found in the
43
+ * LICENSE file in the root directory of this source tree.
44
+ */
45
+ var De;
46
+ function sn() {
47
+ return De || (De = 1, process.env.NODE_ENV !== "production" && (function() {
48
+ function e(u) {
49
+ if (u == null) return null;
50
+ if (typeof u == "function")
51
+ return u.$$typeof === Dt ? null : u.displayName || u.name || null;
52
+ if (typeof u == "string") return u;
53
+ switch (u) {
54
+ case T:
55
+ return "Fragment";
56
+ case L:
57
+ return "Profiler";
58
+ case P:
59
+ return "StrictMode";
60
+ case Rt:
61
+ return "Suspense";
62
+ case Pt:
63
+ return "SuspenseList";
64
+ case Nt:
65
+ return "Activity";
66
+ }
67
+ if (typeof u == "object")
68
+ switch (typeof u.tag == "number" && console.error(
69
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
70
+ ), u.$$typeof) {
71
+ case R:
72
+ return "Portal";
73
+ case j:
74
+ return u.displayName || "Context";
75
+ case A:
76
+ return (u._context.displayName || "Context") + ".Consumer";
77
+ case C:
78
+ var _ = u.render;
79
+ return u = u.displayName, u || (u = _.displayName || _.name || "", u = u !== "" ? "ForwardRef(" + u + ")" : "ForwardRef"), u;
80
+ case Ct:
81
+ return _ = u.displayName || null, _ !== null ? _ : e(u.type) || "Memo";
82
+ case de:
83
+ _ = u._payload, u = u._init;
84
+ try {
85
+ return e(u(_));
86
+ } catch {
87
+ }
88
+ }
89
+ return null;
90
+ }
91
+ function t(u) {
92
+ return "" + u;
93
+ }
94
+ function n(u) {
95
+ try {
96
+ t(u);
97
+ var _ = !1;
98
+ } catch {
99
+ _ = !0;
100
+ }
101
+ if (_) {
102
+ _ = console;
103
+ var z = _.error, Z = typeof Symbol == "function" && Symbol.toStringTag && u[Symbol.toStringTag] || u.constructor.name || "Object";
104
+ return z.call(
105
+ _,
106
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
107
+ Z
108
+ ), t(u);
109
+ }
110
+ }
111
+ function r(u) {
112
+ if (u === T) return "<>";
113
+ if (typeof u == "object" && u !== null && u.$$typeof === de)
114
+ return "<...>";
115
+ try {
116
+ var _ = e(u);
117
+ return _ ? "<" + _ + ">" : "<...>";
118
+ } catch {
119
+ return "<...>";
120
+ }
121
+ }
122
+ function o() {
123
+ var u = fe.A;
124
+ return u === null ? null : u.getOwner();
125
+ }
126
+ function i() {
127
+ return Error("react-stack-top-frame");
128
+ }
129
+ function c(u) {
130
+ if (je.call(u, "key")) {
131
+ var _ = Object.getOwnPropertyDescriptor(u, "key").get;
132
+ if (_ && _.isReactWarning) return !1;
133
+ }
134
+ return u.key !== void 0;
135
+ }
136
+ function a(u, _) {
137
+ function z() {
138
+ Se || (Se = !0, console.error(
139
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
140
+ _
141
+ ));
142
+ }
143
+ z.isReactWarning = !0, Object.defineProperty(u, "key", {
144
+ get: z,
145
+ configurable: !0
146
+ });
147
+ }
148
+ function f() {
149
+ var u = e(this.type);
150
+ return Oe[u] || (Oe[u] = !0, console.error(
151
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
152
+ )), u = this.props.ref, u !== void 0 ? u : null;
153
+ }
154
+ function d(u, _, z, Z, X, pe) {
155
+ var E = z.ref;
156
+ return u = {
157
+ $$typeof: x,
158
+ type: u,
159
+ key: _,
160
+ props: z,
161
+ _owner: Z
162
+ }, (E !== void 0 ? E : null) !== null ? Object.defineProperty(u, "ref", {
163
+ enumerable: !1,
164
+ get: f
165
+ }) : Object.defineProperty(u, "ref", { enumerable: !1, value: null }), u._store = {}, Object.defineProperty(u._store, "validated", {
166
+ configurable: !1,
167
+ enumerable: !1,
168
+ writable: !0,
169
+ value: 0
170
+ }), Object.defineProperty(u, "_debugInfo", {
171
+ configurable: !1,
172
+ enumerable: !1,
173
+ writable: !0,
174
+ value: null
175
+ }), Object.defineProperty(u, "_debugStack", {
176
+ configurable: !1,
177
+ enumerable: !1,
178
+ writable: !0,
179
+ value: X
180
+ }), Object.defineProperty(u, "_debugTask", {
181
+ configurable: !1,
182
+ enumerable: !1,
183
+ writable: !0,
184
+ value: pe
185
+ }), Object.freeze && (Object.freeze(u.props), Object.freeze(u)), u;
186
+ }
187
+ function l(u, _, z, Z, X, pe) {
188
+ var E = _.children;
189
+ if (E !== void 0)
190
+ if (Z)
191
+ if (Ut(E)) {
192
+ for (Z = 0; Z < E.length; Z++)
193
+ g(E[Z]);
194
+ Object.freeze && Object.freeze(E);
195
+ } else
196
+ console.error(
197
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
198
+ );
199
+ else g(E);
200
+ if (je.call(_, "key")) {
201
+ E = e(u);
202
+ var M = Object.keys(_).filter(function(Ft) {
203
+ return Ft !== "key";
204
+ });
205
+ Z = 0 < M.length ? "{key: someKey, " + M.join(": ..., ") + ": ...}" : "{key: someKey}", Ce[E + Z] || (M = 0 < M.length ? "{" + M.join(": ..., ") + ": ...}" : "{}", console.error(
206
+ `A props object containing a "key" prop is being spread into JSX:
207
+ let props = %s;
208
+ <%s {...props} />
209
+ React keys must be passed directly to JSX without using spread:
210
+ let props = %s;
211
+ <%s key={someKey} {...props} />`,
212
+ Z,
213
+ E,
214
+ M,
215
+ E
216
+ ), Ce[E + Z] = !0);
217
+ }
218
+ if (E = null, z !== void 0 && (n(z), E = "" + z), c(_) && (n(_.key), E = "" + _.key), "key" in _) {
219
+ z = {};
220
+ for (var me in _)
221
+ me !== "key" && (z[me] = _[me]);
222
+ } else z = _;
223
+ return E && a(
224
+ z,
225
+ typeof u == "function" ? u.displayName || u.name || "Unknown" : u
226
+ ), d(
227
+ u,
228
+ E,
229
+ z,
230
+ o(),
231
+ X,
232
+ pe
233
+ );
234
+ }
235
+ function g(u) {
236
+ p(u) ? u._store && (u._store.validated = 1) : typeof u == "object" && u !== null && u.$$typeof === de && (u._payload.status === "fulfilled" ? p(u._payload.value) && u._payload.value._store && (u._payload.value._store.validated = 1) : u._store && (u._store.validated = 1));
237
+ }
238
+ function p(u) {
239
+ return typeof u == "object" && u !== null && u.$$typeof === x;
240
+ }
241
+ var v = Lt, x = Symbol.for("react.transitional.element"), R = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), P = Symbol.for("react.strict_mode"), L = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), j = Symbol.for("react.context"), C = Symbol.for("react.forward_ref"), Rt = Symbol.for("react.suspense"), Pt = Symbol.for("react.suspense_list"), Ct = Symbol.for("react.memo"), de = Symbol.for("react.lazy"), Nt = Symbol.for("react.activity"), Dt = Symbol.for("react.client.reference"), fe = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, je = Object.prototype.hasOwnProperty, Ut = Array.isArray, he = console.createTask ? console.createTask : function() {
242
+ return null;
243
+ };
244
+ v = {
245
+ react_stack_bottom_frame: function(u) {
246
+ return u();
247
+ }
248
+ };
249
+ var Se, Oe = {}, Re = v.react_stack_bottom_frame.bind(
250
+ v,
251
+ i
252
+ )(), Pe = he(r(i)), Ce = {};
253
+ J.Fragment = T, J.jsx = function(u, _, z) {
254
+ var Z = 1e4 > fe.recentlyCreatedOwnerStacks++;
255
+ return l(
256
+ u,
257
+ _,
258
+ z,
259
+ !1,
260
+ Z ? Error("react-stack-top-frame") : Re,
261
+ Z ? he(r(u)) : Pe
262
+ );
263
+ }, J.jsxs = function(u, _, z) {
264
+ var Z = 1e4 > fe.recentlyCreatedOwnerStacks++;
265
+ return l(
266
+ u,
267
+ _,
268
+ z,
269
+ !0,
270
+ Z ? Error("react-stack-top-frame") : Re,
271
+ Z ? he(r(u)) : Pe
272
+ );
273
+ };
274
+ })()), J;
275
+ }
276
+ var Ue;
277
+ function an() {
278
+ return Ue || (Ue = 1, process.env.NODE_ENV === "production" ? K.exports = cn() : K.exports = sn()), K.exports;
279
+ }
280
+ var m = an();
281
+ const un = ({
282
+ onCommand: e,
283
+ onSave: t,
284
+ onExport: n,
285
+ onClear: r,
286
+ hasUnsavedChanges: o
287
+ }) => {
288
+ const [i, c] = ze([]), a = () => {
289
+ const l = [
290
+ "bold",
291
+ "italic",
292
+ "underline",
293
+ "strikeThrough",
294
+ "justifyLeft",
295
+ "justifyCenter",
296
+ "justifyRight"
297
+ ], g = [];
298
+ l.forEach((p) => {
299
+ document.queryCommandState(p) && g.push(p);
300
+ }), c(g);
301
+ };
302
+ ut(() => (document.addEventListener("selectionchange", a), () => document.removeEventListener("selectionchange", a)), []);
303
+ const f = () => {
304
+ const l = prompt("Enter URL:");
305
+ l && e("createLink", l);
306
+ }, d = [
307
+ { command: "bold", icon: /* @__PURE__ */ m.jsx(Yt, { size: 18 }), title: "Bold" },
308
+ { command: "italic", icon: /* @__PURE__ */ m.jsx(Jt, { size: 18 }), title: "Italic" },
309
+ { command: "underline", icon: /* @__PURE__ */ m.jsx(Gt, { size: 18 }), title: "Underline" },
310
+ { command: "strikeThrough", icon: /* @__PURE__ */ m.jsx(qt, { size: 18 }), title: "Strikethrough" },
311
+ { separator: !0 },
312
+ { command: "insertUnorderedList", icon: /* @__PURE__ */ m.jsx(Ht, { size: 18 }), title: "Bullet List" },
313
+ { command: "insertOrderedList", icon: /* @__PURE__ */ m.jsx(Xt, { size: 18 }), title: "Numbered List" },
314
+ { separator: !0 },
315
+ { command: "formatBlock", value: "h1", icon: /* @__PURE__ */ m.jsx(Kt, { size: 18 }), title: "Heading 1" },
316
+ { command: "formatBlock", value: "h2", icon: /* @__PURE__ */ m.jsx(Qt, { size: 18 }), title: "Heading 2" },
317
+ { command: "formatBlock", value: "p", icon: /* @__PURE__ */ m.jsx(en, { size: 18 }), title: "Paragraph" },
318
+ { separator: !0 },
319
+ { command: "justifyLeft", icon: /* @__PURE__ */ m.jsx(tn, { size: 18 }), title: "Align Left" },
320
+ { command: "justifyCenter", icon: /* @__PURE__ */ m.jsx(nn, { size: 18 }), title: "Center" },
321
+ { command: "justifyRight", icon: /* @__PURE__ */ m.jsx(rn, { size: 18 }), title: "Align Right" },
322
+ { separator: !0 },
323
+ { command: "createLink", icon: /* @__PURE__ */ m.jsx(on, { size: 18 }), title: "Insert Link" }
324
+ ];
325
+ return /* @__PURE__ */ m.jsxs("div", { className: "flex flex-wrap justify-between items-center p-3 bg-gray-50 border-b border-gray-200", children: [
326
+ /* @__PURE__ */ m.jsx("div", { className: "flex flex-wrap items-center gap-1", children: d.map((l, g) => {
327
+ if ("separator" in l)
328
+ return /* @__PURE__ */ m.jsx("div", { className: "w-px h-6 bg-gray-300 mx-2" }, g);
329
+ const p = i.includes(l.command);
330
+ return /* @__PURE__ */ m.jsx(
331
+ "button",
332
+ {
333
+ onClick: () => l.command === "createLink" ? f() : e(l.command, l.value),
334
+ title: l.title,
335
+ type: "button",
336
+ className: `w-9 h-9 flex items-center justify-center rounded-md border border-gray-300 text-gray-700 hover:bg-gray-100 active:bg-gray-200 transition
337
+ ${p ? "bg-blue-100 text-blue-600 border-blue-300" : "bg-white"}`,
338
+ children: l.icon
339
+ },
340
+ g
341
+ );
342
+ }) }),
343
+ /* @__PURE__ */ m.jsxs("div", { className: "flex items-center gap-2 mt-2 sm:mt-0", children: [
344
+ /* @__PURE__ */ m.jsxs(
345
+ "button",
346
+ {
347
+ onClick: t,
348
+ disabled: !o,
349
+ title: "Save Document",
350
+ className: "flex items-center gap-1 px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 disabled:bg-blue-300 disabled:cursor-not-allowed transition",
351
+ children: [
352
+ /* @__PURE__ */ m.jsx(Vt, { size: 16 }),
353
+ " Save"
354
+ ]
355
+ }
356
+ ),
357
+ /* @__PURE__ */ m.jsxs(
358
+ "button",
359
+ {
360
+ onClick: n,
361
+ title: "Export as HTML",
362
+ className: "flex items-center gap-1 px-3 py-2 bg-green-600 text-white text-sm font-medium rounded-md hover:bg-green-700 transition",
363
+ children: [
364
+ /* @__PURE__ */ m.jsx(Wt, { size: 16 }),
365
+ " Export"
366
+ ]
367
+ }
368
+ ),
369
+ /* @__PURE__ */ m.jsxs(
370
+ "button",
371
+ {
372
+ onClick: r,
373
+ title: "Clear Editor",
374
+ className: "flex items-center gap-1 px-3 py-2 bg-red-600 text-white text-sm font-medium rounded-md hover:bg-red-700 transition",
375
+ children: [
376
+ /* @__PURE__ */ m.jsx(Bt, { size: 16 }),
377
+ " Clear"
378
+ ]
379
+ }
380
+ )
381
+ ] })
382
+ ] });
383
+ }, ln = ({
384
+ wordCount: e,
385
+ characterCount: t,
386
+ hasUnsavedChanges: n
387
+ }) => /* @__PURE__ */ m.jsx("div", { className: "flex justify-between items-center px-5 py-3 bg-gray-50 border-t border-gray-200 text-sm text-gray-600", children: /* @__PURE__ */ m.jsxs("div", { className: "flex items-center gap-6", children: [
388
+ /* @__PURE__ */ m.jsxs("div", { children: [
389
+ "Words: ",
390
+ /* @__PURE__ */ m.jsx("strong", { className: "text-gray-800", children: e })
391
+ ] }),
392
+ /* @__PURE__ */ m.jsxs("div", { children: [
393
+ "Characters: ",
394
+ /* @__PURE__ */ m.jsx("strong", { className: "text-gray-800", children: t })
395
+ ] }),
396
+ /* @__PURE__ */ m.jsxs("div", { children: [
397
+ "Status: ",
398
+ /* @__PURE__ */ m.jsx("strong", { className: n ? "text-orange-600" : "text-green-600", children: n ? "Unsaved Changes" : "Saved" })
399
+ ] })
400
+ ] }) });
401
+ function s(e, t, n) {
402
+ function r(a, f) {
403
+ var d;
404
+ Object.defineProperty(a, "_zod", {
405
+ value: a._zod ?? {},
406
+ enumerable: !1
407
+ }), (d = a._zod).traits ?? (d.traits = /* @__PURE__ */ new Set()), a._zod.traits.add(e), t(a, f);
408
+ for (const l in c.prototype)
409
+ l in a || Object.defineProperty(a, l, { value: c.prototype[l].bind(a) });
410
+ a._zod.constr = c, a._zod.def = f;
411
+ }
412
+ const o = n?.Parent ?? Object;
413
+ class i extends o {
414
+ }
415
+ Object.defineProperty(i, "name", { value: e });
416
+ function c(a) {
417
+ var f;
418
+ const d = n?.Parent ? new i() : this;
419
+ r(d, a), (f = d._zod).deferred ?? (f.deferred = []);
420
+ for (const l of d._zod.deferred)
421
+ l();
422
+ return d;
423
+ }
424
+ return Object.defineProperty(c, "init", { value: r }), Object.defineProperty(c, Symbol.hasInstance, {
425
+ value: (a) => n?.Parent && a instanceof n.Parent ? !0 : a?._zod?.traits?.has(e)
426
+ }), Object.defineProperty(c, "name", { value: e }), c;
427
+ }
428
+ class B extends Error {
429
+ constructor() {
430
+ super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
431
+ }
432
+ }
433
+ class lt extends Error {
434
+ constructor(t) {
435
+ super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
436
+ }
437
+ }
438
+ const dt = {};
439
+ function N(e) {
440
+ return dt;
441
+ }
442
+ function dn(e) {
443
+ const t = Object.values(e).filter((r) => typeof r == "number");
444
+ return Object.entries(e).filter(([r, o]) => t.indexOf(+r) === -1).map(([r, o]) => o);
445
+ }
446
+ function ve(e, t) {
447
+ return typeof t == "bigint" ? t.toString() : t;
448
+ }
449
+ function ye(e) {
450
+ return {
451
+ get value() {
452
+ {
453
+ const t = e();
454
+ return Object.defineProperty(this, "value", { value: t }), t;
455
+ }
456
+ }
457
+ };
458
+ }
459
+ function $e(e) {
460
+ return e == null;
461
+ }
462
+ function Ze(e) {
463
+ const t = e.startsWith("^") ? 1 : 0, n = e.endsWith("$") ? e.length - 1 : e.length;
464
+ return e.slice(t, n);
465
+ }
466
+ function fn(e, t) {
467
+ const n = (e.toString().split(".")[1] || "").length, r = t.toString();
468
+ let o = (r.split(".")[1] || "").length;
469
+ if (o === 0 && /\d?e-\d?/.test(r)) {
470
+ const f = r.match(/\d?e-(\d?)/);
471
+ f?.[1] && (o = Number.parseInt(f[1]));
472
+ }
473
+ const i = n > o ? n : o, c = Number.parseInt(e.toFixed(i).replace(".", "")), a = Number.parseInt(t.toFixed(i).replace(".", ""));
474
+ return c % a / 10 ** i;
475
+ }
476
+ const Fe = Symbol("evaluating");
477
+ function b(e, t, n) {
478
+ let r;
479
+ Object.defineProperty(e, t, {
480
+ get() {
481
+ if (r !== Fe)
482
+ return r === void 0 && (r = Fe, r = n()), r;
483
+ },
484
+ set(o) {
485
+ Object.defineProperty(e, t, {
486
+ value: o
487
+ // configurable: true,
488
+ });
489
+ },
490
+ configurable: !0
491
+ });
492
+ }
493
+ function U(e, t, n) {
494
+ Object.defineProperty(e, t, {
495
+ value: n,
496
+ writable: !0,
497
+ enumerable: !0,
498
+ configurable: !0
499
+ });
500
+ }
501
+ function F(...e) {
502
+ const t = {};
503
+ for (const n of e) {
504
+ const r = Object.getOwnPropertyDescriptors(n);
505
+ Object.assign(t, r);
506
+ }
507
+ return Object.defineProperties({}, t);
508
+ }
509
+ function Le(e) {
510
+ return JSON.stringify(e);
511
+ }
512
+ const ft = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
513
+ };
514
+ function oe(e) {
515
+ return typeof e == "object" && e !== null && !Array.isArray(e);
516
+ }
517
+ const hn = ye(() => {
518
+ if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
519
+ return !1;
520
+ try {
521
+ const e = Function;
522
+ return new e(""), !0;
523
+ } catch {
524
+ return !1;
525
+ }
526
+ });
527
+ function G(e) {
528
+ if (oe(e) === !1)
529
+ return !1;
530
+ const t = e.constructor;
531
+ if (t === void 0)
532
+ return !0;
533
+ const n = t.prototype;
534
+ return !(oe(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
535
+ }
536
+ function ht(e) {
537
+ return G(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
538
+ }
539
+ const pn = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
540
+ function se(e) {
541
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
542
+ }
543
+ function O(e, t, n) {
544
+ const r = new e._zod.constr(t ?? e._zod.def);
545
+ return (!t || n?.parent) && (r._zod.parent = e), r;
546
+ }
547
+ function h(e) {
548
+ const t = e;
549
+ if (!t)
550
+ return {};
551
+ if (typeof t == "string")
552
+ return { error: () => t };
553
+ if (t?.message !== void 0) {
554
+ if (t?.error !== void 0)
555
+ throw new Error("Cannot specify both `message` and `error` params");
556
+ t.error = t.message;
557
+ }
558
+ return delete t.message, typeof t.error == "string" ? { ...t, error: () => t.error } : t;
559
+ }
560
+ function mn(e) {
561
+ return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
562
+ }
563
+ const _n = {
564
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
565
+ int32: [-2147483648, 2147483647],
566
+ uint32: [0, 4294967295],
567
+ float32: [-34028234663852886e22, 34028234663852886e22],
568
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
569
+ };
570
+ function gn(e, t) {
571
+ const n = e._zod.def, r = F(e._zod.def, {
572
+ get shape() {
573
+ const o = {};
574
+ for (const i in t) {
575
+ if (!(i in n.shape))
576
+ throw new Error(`Unrecognized key: "${i}"`);
577
+ t[i] && (o[i] = n.shape[i]);
578
+ }
579
+ return U(this, "shape", o), o;
580
+ },
581
+ checks: []
582
+ });
583
+ return O(e, r);
584
+ }
585
+ function vn(e, t) {
586
+ const n = e._zod.def, r = F(e._zod.def, {
587
+ get shape() {
588
+ const o = { ...e._zod.def.shape };
589
+ for (const i in t) {
590
+ if (!(i in n.shape))
591
+ throw new Error(`Unrecognized key: "${i}"`);
592
+ t[i] && delete o[i];
593
+ }
594
+ return U(this, "shape", o), o;
595
+ },
596
+ checks: []
597
+ });
598
+ return O(e, r);
599
+ }
600
+ function bn(e, t) {
601
+ if (!G(t))
602
+ throw new Error("Invalid input to extend: expected a plain object");
603
+ const n = e._zod.def.checks;
604
+ if (n && n.length > 0)
605
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
606
+ const o = F(e._zod.def, {
607
+ get shape() {
608
+ const i = { ...e._zod.def.shape, ...t };
609
+ return U(this, "shape", i), i;
610
+ },
611
+ checks: []
612
+ });
613
+ return O(e, o);
614
+ }
615
+ function wn(e, t) {
616
+ if (!G(t))
617
+ throw new Error("Invalid input to safeExtend: expected a plain object");
618
+ const n = {
619
+ ...e._zod.def,
620
+ get shape() {
621
+ const r = { ...e._zod.def.shape, ...t };
622
+ return U(this, "shape", r), r;
623
+ },
624
+ checks: e._zod.def.checks
625
+ };
626
+ return O(e, n);
627
+ }
628
+ function kn(e, t) {
629
+ const n = F(e._zod.def, {
630
+ get shape() {
631
+ const r = { ...e._zod.def.shape, ...t._zod.def.shape };
632
+ return U(this, "shape", r), r;
633
+ },
634
+ get catchall() {
635
+ return t._zod.def.catchall;
636
+ },
637
+ checks: []
638
+ // delete existing checks
639
+ });
640
+ return O(e, n);
641
+ }
642
+ function zn(e, t, n) {
643
+ const r = F(t._zod.def, {
644
+ get shape() {
645
+ const o = t._zod.def.shape, i = { ...o };
646
+ if (n)
647
+ for (const c in n) {
648
+ if (!(c in o))
649
+ throw new Error(`Unrecognized key: "${c}"`);
650
+ n[c] && (i[c] = e ? new e({
651
+ type: "optional",
652
+ innerType: o[c]
653
+ }) : o[c]);
654
+ }
655
+ else
656
+ for (const c in o)
657
+ i[c] = e ? new e({
658
+ type: "optional",
659
+ innerType: o[c]
660
+ }) : o[c];
661
+ return U(this, "shape", i), i;
662
+ },
663
+ checks: []
664
+ });
665
+ return O(t, r);
666
+ }
667
+ function yn(e, t, n) {
668
+ const r = F(t._zod.def, {
669
+ get shape() {
670
+ const o = t._zod.def.shape, i = { ...o };
671
+ if (n)
672
+ for (const c in n) {
673
+ if (!(c in i))
674
+ throw new Error(`Unrecognized key: "${c}"`);
675
+ n[c] && (i[c] = new e({
676
+ type: "nonoptional",
677
+ innerType: o[c]
678
+ }));
679
+ }
680
+ else
681
+ for (const c in o)
682
+ i[c] = new e({
683
+ type: "nonoptional",
684
+ innerType: o[c]
685
+ });
686
+ return U(this, "shape", i), i;
687
+ },
688
+ checks: []
689
+ });
690
+ return O(t, r);
691
+ }
692
+ function W(e, t = 0) {
693
+ if (e.aborted === !0)
694
+ return !0;
695
+ for (let n = t; n < e.issues.length; n++)
696
+ if (e.issues[n]?.continue !== !0)
697
+ return !0;
698
+ return !1;
699
+ }
700
+ function pt(e, t) {
701
+ return t.map((n) => {
702
+ var r;
703
+ return (r = n).path ?? (r.path = []), n.path.unshift(e), n;
704
+ });
705
+ }
706
+ function Q(e) {
707
+ return typeof e == "string" ? e : e?.message;
708
+ }
709
+ function D(e, t, n) {
710
+ const r = { ...e, path: e.path ?? [] };
711
+ if (!e.message) {
712
+ const o = Q(e.inst?._zod.def?.error?.(e)) ?? Q(t?.error?.(e)) ?? Q(n.customError?.(e)) ?? Q(n.localeError?.(e)) ?? "Invalid input";
713
+ r.message = o;
714
+ }
715
+ return delete r.inst, delete r.continue, t?.reportInput || delete r.input, r;
716
+ }
717
+ function Ee(e) {
718
+ return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
719
+ }
720
+ function q(...e) {
721
+ const [t, n, r] = e;
722
+ return typeof t == "string" ? {
723
+ message: t,
724
+ code: "custom",
725
+ input: n,
726
+ inst: r
727
+ } : { ...t };
728
+ }
729
+ const mt = (e, t) => {
730
+ e.name = "$ZodError", Object.defineProperty(e, "_zod", {
731
+ value: e._zod,
732
+ enumerable: !1
733
+ }), Object.defineProperty(e, "issues", {
734
+ value: t,
735
+ enumerable: !1
736
+ }), e.message = JSON.stringify(t, ve, 2), Object.defineProperty(e, "toString", {
737
+ value: () => e.message,
738
+ enumerable: !1
739
+ });
740
+ }, _t = s("$ZodError", mt), gt = s("$ZodError", mt, { Parent: Error });
741
+ function $n(e, t = (n) => n.message) {
742
+ const n = {}, r = [];
743
+ for (const o of e.issues)
744
+ o.path.length > 0 ? (n[o.path[0]] = n[o.path[0]] || [], n[o.path[0]].push(t(o))) : r.push(t(o));
745
+ return { formErrors: r, fieldErrors: n };
746
+ }
747
+ function Zn(e, t) {
748
+ const n = t || function(i) {
749
+ return i.message;
750
+ }, r = { _errors: [] }, o = (i) => {
751
+ for (const c of i.issues)
752
+ if (c.code === "invalid_union" && c.errors.length)
753
+ c.errors.map((a) => o({ issues: a }));
754
+ else if (c.code === "invalid_key")
755
+ o({ issues: c.issues });
756
+ else if (c.code === "invalid_element")
757
+ o({ issues: c.issues });
758
+ else if (c.path.length === 0)
759
+ r._errors.push(n(c));
760
+ else {
761
+ let a = r, f = 0;
762
+ for (; f < c.path.length; ) {
763
+ const d = c.path[f];
764
+ f === c.path.length - 1 ? (a[d] = a[d] || { _errors: [] }, a[d]._errors.push(n(c))) : a[d] = a[d] || { _errors: [] }, a = a[d], f++;
765
+ }
766
+ }
767
+ };
768
+ return o(e), r;
769
+ }
770
+ const xe = (e) => (t, n, r, o) => {
771
+ const i = r ? Object.assign(r, { async: !1 }) : { async: !1 }, c = t._zod.run({ value: n, issues: [] }, i);
772
+ if (c instanceof Promise)
773
+ throw new B();
774
+ if (c.issues.length) {
775
+ const a = new (o?.Err ?? e)(c.issues.map((f) => D(f, i, N())));
776
+ throw ft(a, o?.callee), a;
777
+ }
778
+ return c.value;
779
+ }, Te = (e) => async (t, n, r, o) => {
780
+ const i = r ? Object.assign(r, { async: !0 }) : { async: !0 };
781
+ let c = t._zod.run({ value: n, issues: [] }, i);
782
+ if (c instanceof Promise && (c = await c), c.issues.length) {
783
+ const a = new (o?.Err ?? e)(c.issues.map((f) => D(f, i, N())));
784
+ throw ft(a, o?.callee), a;
785
+ }
786
+ return c.value;
787
+ }, ae = (e) => (t, n, r) => {
788
+ const o = r ? { ...r, async: !1 } : { async: !1 }, i = t._zod.run({ value: n, issues: [] }, o);
789
+ if (i instanceof Promise)
790
+ throw new B();
791
+ return i.issues.length ? {
792
+ success: !1,
793
+ error: new (e ?? _t)(i.issues.map((c) => D(c, o, N())))
794
+ } : { success: !0, data: i.value };
795
+ }, En = /* @__PURE__ */ ae(gt), ue = (e) => async (t, n, r) => {
796
+ const o = r ? Object.assign(r, { async: !0 }) : { async: !0 };
797
+ let i = t._zod.run({ value: n, issues: [] }, o);
798
+ return i instanceof Promise && (i = await i), i.issues.length ? {
799
+ success: !1,
800
+ error: new e(i.issues.map((c) => D(c, o, N())))
801
+ } : { success: !0, data: i.value };
802
+ }, xn = /* @__PURE__ */ ue(gt), Tn = (e) => (t, n, r) => {
803
+ const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
804
+ return xe(e)(t, n, o);
805
+ }, An = (e) => (t, n, r) => xe(e)(t, n, r), In = (e) => async (t, n, r) => {
806
+ const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
807
+ return Te(e)(t, n, o);
808
+ }, jn = (e) => async (t, n, r) => Te(e)(t, n, r), Sn = (e) => (t, n, r) => {
809
+ const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
810
+ return ae(e)(t, n, o);
811
+ }, On = (e) => (t, n, r) => ae(e)(t, n, r), Rn = (e) => async (t, n, r) => {
812
+ const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
813
+ return ue(e)(t, n, o);
814
+ }, Pn = (e) => async (t, n, r) => ue(e)(t, n, r), Cn = /^[cC][^\s-]{8,}$/, Nn = /^[0-9a-z]+$/, Dn = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Un = /^[0-9a-vA-V]{20}$/, Fn = /^[A-Za-z0-9]{27}$/, Ln = /^[a-zA-Z0-9_-]{21}$/, Mn = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Vn = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, Me = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Wn = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Bn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
815
+ function Yn() {
816
+ return new RegExp(Bn, "u");
817
+ }
818
+ const Jn = /^(?:(?: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])$/, Gn = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, qn = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, Hn = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Xn = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, vt = /^[A-Za-z0-9_-]*$/, Kn = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/, Qn = /^\+(?:[0-9]){6,14}[0-9]$/, bt = "(?:(?:\\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])))", er = /* @__PURE__ */ new RegExp(`^${bt}$`);
819
+ function wt(e) {
820
+ const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
821
+ return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
822
+ }
823
+ function tr(e) {
824
+ return new RegExp(`^${wt(e)}$`);
825
+ }
826
+ function nr(e) {
827
+ const t = wt({ precision: e.precision }), n = ["Z"];
828
+ e.local && n.push(""), e.offset && n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
829
+ const r = `${t}(?:${n.join("|")})`;
830
+ return new RegExp(`^${bt}T(?:${r})$`);
831
+ }
832
+ const rr = (e) => {
833
+ const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
834
+ return new RegExp(`^${t}$`);
835
+ }, or = /^-?\d+$/, ir = /^-?\d+(?:\.\d+)?/, cr = /^(?:true|false)$/i, sr = /^[^A-Z]*$/, ar = /^[^a-z]*$/, I = /* @__PURE__ */ s("$ZodCheck", (e, t) => {
836
+ var n;
837
+ e._zod ?? (e._zod = {}), e._zod.def = t, (n = e._zod).onattach ?? (n.onattach = []);
838
+ }), kt = {
839
+ number: "number",
840
+ bigint: "bigint",
841
+ object: "date"
842
+ }, zt = /* @__PURE__ */ s("$ZodCheckLessThan", (e, t) => {
843
+ I.init(e, t);
844
+ const n = kt[typeof t.value];
845
+ e._zod.onattach.push((r) => {
846
+ const o = r._zod.bag, i = (t.inclusive ? o.maximum : o.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
847
+ t.value < i && (t.inclusive ? o.maximum = t.value : o.exclusiveMaximum = t.value);
848
+ }), e._zod.check = (r) => {
849
+ (t.inclusive ? r.value <= t.value : r.value < t.value) || r.issues.push({
850
+ origin: n,
851
+ code: "too_big",
852
+ maximum: t.value,
853
+ input: r.value,
854
+ inclusive: t.inclusive,
855
+ inst: e,
856
+ continue: !t.abort
857
+ });
858
+ };
859
+ }), yt = /* @__PURE__ */ s("$ZodCheckGreaterThan", (e, t) => {
860
+ I.init(e, t);
861
+ const n = kt[typeof t.value];
862
+ e._zod.onattach.push((r) => {
863
+ const o = r._zod.bag, i = (t.inclusive ? o.minimum : o.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
864
+ t.value > i && (t.inclusive ? o.minimum = t.value : o.exclusiveMinimum = t.value);
865
+ }), e._zod.check = (r) => {
866
+ (t.inclusive ? r.value >= t.value : r.value > t.value) || r.issues.push({
867
+ origin: n,
868
+ code: "too_small",
869
+ minimum: t.value,
870
+ input: r.value,
871
+ inclusive: t.inclusive,
872
+ inst: e,
873
+ continue: !t.abort
874
+ });
875
+ };
876
+ }), ur = /* @__PURE__ */ s("$ZodCheckMultipleOf", (e, t) => {
877
+ I.init(e, t), e._zod.onattach.push((n) => {
878
+ var r;
879
+ (r = n._zod.bag).multipleOf ?? (r.multipleOf = t.value);
880
+ }), e._zod.check = (n) => {
881
+ if (typeof n.value != typeof t.value)
882
+ throw new Error("Cannot mix number and bigint in multiple_of check.");
883
+ (typeof n.value == "bigint" ? n.value % t.value === BigInt(0) : fn(n.value, t.value) === 0) || n.issues.push({
884
+ origin: typeof n.value,
885
+ code: "not_multiple_of",
886
+ divisor: t.value,
887
+ input: n.value,
888
+ inst: e,
889
+ continue: !t.abort
890
+ });
891
+ };
892
+ }), lr = /* @__PURE__ */ s("$ZodCheckNumberFormat", (e, t) => {
893
+ I.init(e, t), t.format = t.format || "float64";
894
+ const n = t.format?.includes("int"), r = n ? "int" : "number", [o, i] = _n[t.format];
895
+ e._zod.onattach.push((c) => {
896
+ const a = c._zod.bag;
897
+ a.format = t.format, a.minimum = o, a.maximum = i, n && (a.pattern = or);
898
+ }), e._zod.check = (c) => {
899
+ const a = c.value;
900
+ if (n) {
901
+ if (!Number.isInteger(a)) {
902
+ c.issues.push({
903
+ expected: r,
904
+ format: t.format,
905
+ code: "invalid_type",
906
+ continue: !1,
907
+ input: a,
908
+ inst: e
909
+ });
910
+ return;
911
+ }
912
+ if (!Number.isSafeInteger(a)) {
913
+ a > 0 ? c.issues.push({
914
+ input: a,
915
+ code: "too_big",
916
+ maximum: Number.MAX_SAFE_INTEGER,
917
+ note: "Integers must be within the safe integer range.",
918
+ inst: e,
919
+ origin: r,
920
+ continue: !t.abort
921
+ }) : c.issues.push({
922
+ input: a,
923
+ code: "too_small",
924
+ minimum: Number.MIN_SAFE_INTEGER,
925
+ note: "Integers must be within the safe integer range.",
926
+ inst: e,
927
+ origin: r,
928
+ continue: !t.abort
929
+ });
930
+ return;
931
+ }
932
+ }
933
+ a < o && c.issues.push({
934
+ origin: "number",
935
+ input: a,
936
+ code: "too_small",
937
+ minimum: o,
938
+ inclusive: !0,
939
+ inst: e,
940
+ continue: !t.abort
941
+ }), a > i && c.issues.push({
942
+ origin: "number",
943
+ input: a,
944
+ code: "too_big",
945
+ maximum: i,
946
+ inst: e
947
+ });
948
+ };
949
+ }), dr = /* @__PURE__ */ s("$ZodCheckMaxLength", (e, t) => {
950
+ var n;
951
+ I.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
952
+ const o = r.value;
953
+ return !$e(o) && o.length !== void 0;
954
+ }), e._zod.onattach.push((r) => {
955
+ const o = r._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
956
+ t.maximum < o && (r._zod.bag.maximum = t.maximum);
957
+ }), e._zod.check = (r) => {
958
+ const o = r.value;
959
+ if (o.length <= t.maximum)
960
+ return;
961
+ const c = Ee(o);
962
+ r.issues.push({
963
+ origin: c,
964
+ code: "too_big",
965
+ maximum: t.maximum,
966
+ inclusive: !0,
967
+ input: o,
968
+ inst: e,
969
+ continue: !t.abort
970
+ });
971
+ };
972
+ }), fr = /* @__PURE__ */ s("$ZodCheckMinLength", (e, t) => {
973
+ var n;
974
+ I.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
975
+ const o = r.value;
976
+ return !$e(o) && o.length !== void 0;
977
+ }), e._zod.onattach.push((r) => {
978
+ const o = r._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
979
+ t.minimum > o && (r._zod.bag.minimum = t.minimum);
980
+ }), e._zod.check = (r) => {
981
+ const o = r.value;
982
+ if (o.length >= t.minimum)
983
+ return;
984
+ const c = Ee(o);
985
+ r.issues.push({
986
+ origin: c,
987
+ code: "too_small",
988
+ minimum: t.minimum,
989
+ inclusive: !0,
990
+ input: o,
991
+ inst: e,
992
+ continue: !t.abort
993
+ });
994
+ };
995
+ }), hr = /* @__PURE__ */ s("$ZodCheckLengthEquals", (e, t) => {
996
+ var n;
997
+ I.init(e, t), (n = e._zod.def).when ?? (n.when = (r) => {
998
+ const o = r.value;
999
+ return !$e(o) && o.length !== void 0;
1000
+ }), e._zod.onattach.push((r) => {
1001
+ const o = r._zod.bag;
1002
+ o.minimum = t.length, o.maximum = t.length, o.length = t.length;
1003
+ }), e._zod.check = (r) => {
1004
+ const o = r.value, i = o.length;
1005
+ if (i === t.length)
1006
+ return;
1007
+ const c = Ee(o), a = i > t.length;
1008
+ r.issues.push({
1009
+ origin: c,
1010
+ ...a ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
1011
+ inclusive: !0,
1012
+ exact: !0,
1013
+ input: r.value,
1014
+ inst: e,
1015
+ continue: !t.abort
1016
+ });
1017
+ };
1018
+ }), le = /* @__PURE__ */ s("$ZodCheckStringFormat", (e, t) => {
1019
+ var n, r;
1020
+ I.init(e, t), e._zod.onattach.push((o) => {
1021
+ const i = o._zod.bag;
1022
+ i.format = t.format, t.pattern && (i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(t.pattern));
1023
+ }), t.pattern ? (n = e._zod).check ?? (n.check = (o) => {
1024
+ t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
1025
+ origin: "string",
1026
+ code: "invalid_format",
1027
+ format: t.format,
1028
+ input: o.value,
1029
+ ...t.pattern ? { pattern: t.pattern.toString() } : {},
1030
+ inst: e,
1031
+ continue: !t.abort
1032
+ });
1033
+ }) : (r = e._zod).check ?? (r.check = () => {
1034
+ });
1035
+ }), pr = /* @__PURE__ */ s("$ZodCheckRegex", (e, t) => {
1036
+ le.init(e, t), e._zod.check = (n) => {
1037
+ t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
1038
+ origin: "string",
1039
+ code: "invalid_format",
1040
+ format: "regex",
1041
+ input: n.value,
1042
+ pattern: t.pattern.toString(),
1043
+ inst: e,
1044
+ continue: !t.abort
1045
+ });
1046
+ };
1047
+ }), mr = /* @__PURE__ */ s("$ZodCheckLowerCase", (e, t) => {
1048
+ t.pattern ?? (t.pattern = sr), le.init(e, t);
1049
+ }), _r = /* @__PURE__ */ s("$ZodCheckUpperCase", (e, t) => {
1050
+ t.pattern ?? (t.pattern = ar), le.init(e, t);
1051
+ }), gr = /* @__PURE__ */ s("$ZodCheckIncludes", (e, t) => {
1052
+ I.init(e, t);
1053
+ const n = se(t.includes), r = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${n}` : n);
1054
+ t.pattern = r, e._zod.onattach.push((o) => {
1055
+ const i = o._zod.bag;
1056
+ i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(r);
1057
+ }), e._zod.check = (o) => {
1058
+ o.value.includes(t.includes, t.position) || o.issues.push({
1059
+ origin: "string",
1060
+ code: "invalid_format",
1061
+ format: "includes",
1062
+ includes: t.includes,
1063
+ input: o.value,
1064
+ inst: e,
1065
+ continue: !t.abort
1066
+ });
1067
+ };
1068
+ }), vr = /* @__PURE__ */ s("$ZodCheckStartsWith", (e, t) => {
1069
+ I.init(e, t);
1070
+ const n = new RegExp(`^${se(t.prefix)}.*`);
1071
+ t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
1072
+ const o = r._zod.bag;
1073
+ o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
1074
+ }), e._zod.check = (r) => {
1075
+ r.value.startsWith(t.prefix) || r.issues.push({
1076
+ origin: "string",
1077
+ code: "invalid_format",
1078
+ format: "starts_with",
1079
+ prefix: t.prefix,
1080
+ input: r.value,
1081
+ inst: e,
1082
+ continue: !t.abort
1083
+ });
1084
+ };
1085
+ }), br = /* @__PURE__ */ s("$ZodCheckEndsWith", (e, t) => {
1086
+ I.init(e, t);
1087
+ const n = new RegExp(`.*${se(t.suffix)}$`);
1088
+ t.pattern ?? (t.pattern = n), e._zod.onattach.push((r) => {
1089
+ const o = r._zod.bag;
1090
+ o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
1091
+ }), e._zod.check = (r) => {
1092
+ r.value.endsWith(t.suffix) || r.issues.push({
1093
+ origin: "string",
1094
+ code: "invalid_format",
1095
+ format: "ends_with",
1096
+ suffix: t.suffix,
1097
+ input: r.value,
1098
+ inst: e,
1099
+ continue: !t.abort
1100
+ });
1101
+ };
1102
+ }), wr = /* @__PURE__ */ s("$ZodCheckOverwrite", (e, t) => {
1103
+ I.init(e, t), e._zod.check = (n) => {
1104
+ n.value = t.tx(n.value);
1105
+ };
1106
+ });
1107
+ class kr {
1108
+ constructor(t = []) {
1109
+ this.content = [], this.indent = 0, this && (this.args = t);
1110
+ }
1111
+ indented(t) {
1112
+ this.indent += 1, t(this), this.indent -= 1;
1113
+ }
1114
+ write(t) {
1115
+ if (typeof t == "function") {
1116
+ t(this, { execution: "sync" }), t(this, { execution: "async" });
1117
+ return;
1118
+ }
1119
+ const r = t.split(`
1120
+ `).filter((c) => c), o = Math.min(...r.map((c) => c.length - c.trimStart().length)), i = r.map((c) => c.slice(o)).map((c) => " ".repeat(this.indent * 2) + c);
1121
+ for (const c of i)
1122
+ this.content.push(c);
1123
+ }
1124
+ compile() {
1125
+ const t = Function, n = this?.args, o = [...(this?.content ?? [""]).map((i) => ` ${i}`)];
1126
+ return new t(...n, o.join(`
1127
+ `));
1128
+ }
1129
+ }
1130
+ const zr = {
1131
+ major: 4,
1132
+ minor: 1,
1133
+ patch: 11
1134
+ }, y = /* @__PURE__ */ s("$ZodType", (e, t) => {
1135
+ var n;
1136
+ e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = zr;
1137
+ const r = [...e._zod.def.checks ?? []];
1138
+ e._zod.traits.has("$ZodCheck") && r.unshift(e);
1139
+ for (const o of r)
1140
+ for (const i of o._zod.onattach)
1141
+ i(e);
1142
+ if (r.length === 0)
1143
+ (n = e._zod).deferred ?? (n.deferred = []), e._zod.deferred?.push(() => {
1144
+ e._zod.run = e._zod.parse;
1145
+ });
1146
+ else {
1147
+ const o = (c, a, f) => {
1148
+ let d = W(c), l;
1149
+ for (const g of a) {
1150
+ if (g._zod.def.when) {
1151
+ if (!g._zod.def.when(c))
1152
+ continue;
1153
+ } else if (d)
1154
+ continue;
1155
+ const p = c.issues.length, v = g._zod.check(c);
1156
+ if (v instanceof Promise && f?.async === !1)
1157
+ throw new B();
1158
+ if (l || v instanceof Promise)
1159
+ l = (l ?? Promise.resolve()).then(async () => {
1160
+ await v, c.issues.length !== p && (d || (d = W(c, p)));
1161
+ });
1162
+ else {
1163
+ if (c.issues.length === p)
1164
+ continue;
1165
+ d || (d = W(c, p));
1166
+ }
1167
+ }
1168
+ return l ? l.then(() => c) : c;
1169
+ }, i = (c, a, f) => {
1170
+ if (W(c))
1171
+ return c.aborted = !0, c;
1172
+ const d = o(a, r, f);
1173
+ if (d instanceof Promise) {
1174
+ if (f.async === !1)
1175
+ throw new B();
1176
+ return d.then((l) => e._zod.parse(l, f));
1177
+ }
1178
+ return e._zod.parse(d, f);
1179
+ };
1180
+ e._zod.run = (c, a) => {
1181
+ if (a.skipChecks)
1182
+ return e._zod.parse(c, a);
1183
+ if (a.direction === "backward") {
1184
+ const d = e._zod.parse({ value: c.value, issues: [] }, { ...a, skipChecks: !0 });
1185
+ return d instanceof Promise ? d.then((l) => i(l, c, a)) : i(d, c, a);
1186
+ }
1187
+ const f = e._zod.parse(c, a);
1188
+ if (f instanceof Promise) {
1189
+ if (a.async === !1)
1190
+ throw new B();
1191
+ return f.then((d) => o(d, r, a));
1192
+ }
1193
+ return o(f, r, a);
1194
+ };
1195
+ }
1196
+ e["~standard"] = {
1197
+ validate: (o) => {
1198
+ try {
1199
+ const i = En(e, o);
1200
+ return i.success ? { value: i.data } : { issues: i.error?.issues };
1201
+ } catch {
1202
+ return xn(e, o).then((c) => c.success ? { value: c.data } : { issues: c.error?.issues });
1203
+ }
1204
+ },
1205
+ vendor: "zod",
1206
+ version: 1
1207
+ };
1208
+ }), Ae = /* @__PURE__ */ s("$ZodString", (e, t) => {
1209
+ y.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? rr(e._zod.bag), e._zod.parse = (n, r) => {
1210
+ if (t.coerce)
1211
+ try {
1212
+ n.value = String(n.value);
1213
+ } catch {
1214
+ }
1215
+ return typeof n.value == "string" || n.issues.push({
1216
+ expected: "string",
1217
+ code: "invalid_type",
1218
+ input: n.value,
1219
+ inst: e
1220
+ }), n;
1221
+ };
1222
+ }), w = /* @__PURE__ */ s("$ZodStringFormat", (e, t) => {
1223
+ le.init(e, t), Ae.init(e, t);
1224
+ }), yr = /* @__PURE__ */ s("$ZodGUID", (e, t) => {
1225
+ t.pattern ?? (t.pattern = Vn), w.init(e, t);
1226
+ }), $r = /* @__PURE__ */ s("$ZodUUID", (e, t) => {
1227
+ if (t.version) {
1228
+ const r = {
1229
+ v1: 1,
1230
+ v2: 2,
1231
+ v3: 3,
1232
+ v4: 4,
1233
+ v5: 5,
1234
+ v6: 6,
1235
+ v7: 7,
1236
+ v8: 8
1237
+ }[t.version];
1238
+ if (r === void 0)
1239
+ throw new Error(`Invalid UUID version: "${t.version}"`);
1240
+ t.pattern ?? (t.pattern = Me(r));
1241
+ } else
1242
+ t.pattern ?? (t.pattern = Me());
1243
+ w.init(e, t);
1244
+ }), Zr = /* @__PURE__ */ s("$ZodEmail", (e, t) => {
1245
+ t.pattern ?? (t.pattern = Wn), w.init(e, t);
1246
+ }), Er = /* @__PURE__ */ s("$ZodURL", (e, t) => {
1247
+ w.init(e, t), e._zod.check = (n) => {
1248
+ try {
1249
+ const r = n.value.trim(), o = new URL(r);
1250
+ t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(o.hostname) || n.issues.push({
1251
+ code: "invalid_format",
1252
+ format: "url",
1253
+ note: "Invalid hostname",
1254
+ pattern: Kn.source,
1255
+ input: n.value,
1256
+ inst: e,
1257
+ continue: !t.abort
1258
+ })), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(o.protocol.endsWith(":") ? o.protocol.slice(0, -1) : o.protocol) || n.issues.push({
1259
+ code: "invalid_format",
1260
+ format: "url",
1261
+ note: "Invalid protocol",
1262
+ pattern: t.protocol.source,
1263
+ input: n.value,
1264
+ inst: e,
1265
+ continue: !t.abort
1266
+ })), t.normalize ? n.value = o.href : n.value = r;
1267
+ return;
1268
+ } catch {
1269
+ n.issues.push({
1270
+ code: "invalid_format",
1271
+ format: "url",
1272
+ input: n.value,
1273
+ inst: e,
1274
+ continue: !t.abort
1275
+ });
1276
+ }
1277
+ };
1278
+ }), xr = /* @__PURE__ */ s("$ZodEmoji", (e, t) => {
1279
+ t.pattern ?? (t.pattern = Yn()), w.init(e, t);
1280
+ }), Tr = /* @__PURE__ */ s("$ZodNanoID", (e, t) => {
1281
+ t.pattern ?? (t.pattern = Ln), w.init(e, t);
1282
+ }), Ar = /* @__PURE__ */ s("$ZodCUID", (e, t) => {
1283
+ t.pattern ?? (t.pattern = Cn), w.init(e, t);
1284
+ }), Ir = /* @__PURE__ */ s("$ZodCUID2", (e, t) => {
1285
+ t.pattern ?? (t.pattern = Nn), w.init(e, t);
1286
+ }), jr = /* @__PURE__ */ s("$ZodULID", (e, t) => {
1287
+ t.pattern ?? (t.pattern = Dn), w.init(e, t);
1288
+ }), Sr = /* @__PURE__ */ s("$ZodXID", (e, t) => {
1289
+ t.pattern ?? (t.pattern = Un), w.init(e, t);
1290
+ }), Or = /* @__PURE__ */ s("$ZodKSUID", (e, t) => {
1291
+ t.pattern ?? (t.pattern = Fn), w.init(e, t);
1292
+ }), Rr = /* @__PURE__ */ s("$ZodISODateTime", (e, t) => {
1293
+ t.pattern ?? (t.pattern = nr(t)), w.init(e, t);
1294
+ }), Pr = /* @__PURE__ */ s("$ZodISODate", (e, t) => {
1295
+ t.pattern ?? (t.pattern = er), w.init(e, t);
1296
+ }), Cr = /* @__PURE__ */ s("$ZodISOTime", (e, t) => {
1297
+ t.pattern ?? (t.pattern = tr(t)), w.init(e, t);
1298
+ }), Nr = /* @__PURE__ */ s("$ZodISODuration", (e, t) => {
1299
+ t.pattern ?? (t.pattern = Mn), w.init(e, t);
1300
+ }), Dr = /* @__PURE__ */ s("$ZodIPv4", (e, t) => {
1301
+ t.pattern ?? (t.pattern = Jn), w.init(e, t), e._zod.onattach.push((n) => {
1302
+ const r = n._zod.bag;
1303
+ r.format = "ipv4";
1304
+ });
1305
+ }), Ur = /* @__PURE__ */ s("$ZodIPv6", (e, t) => {
1306
+ t.pattern ?? (t.pattern = Gn), w.init(e, t), e._zod.onattach.push((n) => {
1307
+ const r = n._zod.bag;
1308
+ r.format = "ipv6";
1309
+ }), e._zod.check = (n) => {
1310
+ try {
1311
+ new URL(`http://[${n.value}]`);
1312
+ } catch {
1313
+ n.issues.push({
1314
+ code: "invalid_format",
1315
+ format: "ipv6",
1316
+ input: n.value,
1317
+ inst: e,
1318
+ continue: !t.abort
1319
+ });
1320
+ }
1321
+ };
1322
+ }), Fr = /* @__PURE__ */ s("$ZodCIDRv4", (e, t) => {
1323
+ t.pattern ?? (t.pattern = qn), w.init(e, t);
1324
+ }), Lr = /* @__PURE__ */ s("$ZodCIDRv6", (e, t) => {
1325
+ t.pattern ?? (t.pattern = Hn), w.init(e, t), e._zod.check = (n) => {
1326
+ const r = n.value.split("/");
1327
+ try {
1328
+ if (r.length !== 2)
1329
+ throw new Error();
1330
+ const [o, i] = r;
1331
+ if (!i)
1332
+ throw new Error();
1333
+ const c = Number(i);
1334
+ if (`${c}` !== i)
1335
+ throw new Error();
1336
+ if (c < 0 || c > 128)
1337
+ throw new Error();
1338
+ new URL(`http://[${o}]`);
1339
+ } catch {
1340
+ n.issues.push({
1341
+ code: "invalid_format",
1342
+ format: "cidrv6",
1343
+ input: n.value,
1344
+ inst: e,
1345
+ continue: !t.abort
1346
+ });
1347
+ }
1348
+ };
1349
+ });
1350
+ function $t(e) {
1351
+ if (e === "")
1352
+ return !0;
1353
+ if (e.length % 4 !== 0)
1354
+ return !1;
1355
+ try {
1356
+ return atob(e), !0;
1357
+ } catch {
1358
+ return !1;
1359
+ }
1360
+ }
1361
+ const Mr = /* @__PURE__ */ s("$ZodBase64", (e, t) => {
1362
+ t.pattern ?? (t.pattern = Xn), w.init(e, t), e._zod.onattach.push((n) => {
1363
+ n._zod.bag.contentEncoding = "base64";
1364
+ }), e._zod.check = (n) => {
1365
+ $t(n.value) || n.issues.push({
1366
+ code: "invalid_format",
1367
+ format: "base64",
1368
+ input: n.value,
1369
+ inst: e,
1370
+ continue: !t.abort
1371
+ });
1372
+ };
1373
+ });
1374
+ function Vr(e) {
1375
+ if (!vt.test(e))
1376
+ return !1;
1377
+ const t = e.replace(/[-_]/g, (r) => r === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
1378
+ return $t(n);
1379
+ }
1380
+ const Wr = /* @__PURE__ */ s("$ZodBase64URL", (e, t) => {
1381
+ t.pattern ?? (t.pattern = vt), w.init(e, t), e._zod.onattach.push((n) => {
1382
+ n._zod.bag.contentEncoding = "base64url";
1383
+ }), e._zod.check = (n) => {
1384
+ Vr(n.value) || n.issues.push({
1385
+ code: "invalid_format",
1386
+ format: "base64url",
1387
+ input: n.value,
1388
+ inst: e,
1389
+ continue: !t.abort
1390
+ });
1391
+ };
1392
+ }), Br = /* @__PURE__ */ s("$ZodE164", (e, t) => {
1393
+ t.pattern ?? (t.pattern = Qn), w.init(e, t);
1394
+ });
1395
+ function Yr(e, t = null) {
1396
+ try {
1397
+ const n = e.split(".");
1398
+ if (n.length !== 3)
1399
+ return !1;
1400
+ const [r] = n;
1401
+ if (!r)
1402
+ return !1;
1403
+ const o = JSON.parse(atob(r));
1404
+ return !("typ" in o && o?.typ !== "JWT" || !o.alg || t && (!("alg" in o) || o.alg !== t));
1405
+ } catch {
1406
+ return !1;
1407
+ }
1408
+ }
1409
+ const Jr = /* @__PURE__ */ s("$ZodJWT", (e, t) => {
1410
+ w.init(e, t), e._zod.check = (n) => {
1411
+ Yr(n.value, t.alg) || n.issues.push({
1412
+ code: "invalid_format",
1413
+ format: "jwt",
1414
+ input: n.value,
1415
+ inst: e,
1416
+ continue: !t.abort
1417
+ });
1418
+ };
1419
+ }), Zt = /* @__PURE__ */ s("$ZodNumber", (e, t) => {
1420
+ y.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? ir, e._zod.parse = (n, r) => {
1421
+ if (t.coerce)
1422
+ try {
1423
+ n.value = Number(n.value);
1424
+ } catch {
1425
+ }
1426
+ const o = n.value;
1427
+ if (typeof o == "number" && !Number.isNaN(o) && Number.isFinite(o))
1428
+ return n;
1429
+ const i = typeof o == "number" ? Number.isNaN(o) ? "NaN" : Number.isFinite(o) ? void 0 : "Infinity" : void 0;
1430
+ return n.issues.push({
1431
+ expected: "number",
1432
+ code: "invalid_type",
1433
+ input: o,
1434
+ inst: e,
1435
+ ...i ? { received: i } : {}
1436
+ }), n;
1437
+ };
1438
+ }), Gr = /* @__PURE__ */ s("$ZodNumber", (e, t) => {
1439
+ lr.init(e, t), Zt.init(e, t);
1440
+ }), qr = /* @__PURE__ */ s("$ZodBoolean", (e, t) => {
1441
+ y.init(e, t), e._zod.pattern = cr, e._zod.parse = (n, r) => {
1442
+ if (t.coerce)
1443
+ try {
1444
+ n.value = !!n.value;
1445
+ } catch {
1446
+ }
1447
+ const o = n.value;
1448
+ return typeof o == "boolean" || n.issues.push({
1449
+ expected: "boolean",
1450
+ code: "invalid_type",
1451
+ input: o,
1452
+ inst: e
1453
+ }), n;
1454
+ };
1455
+ }), Hr = /* @__PURE__ */ s("$ZodUnknown", (e, t) => {
1456
+ y.init(e, t), e._zod.parse = (n) => n;
1457
+ }), Xr = /* @__PURE__ */ s("$ZodNever", (e, t) => {
1458
+ y.init(e, t), e._zod.parse = (n, r) => (n.issues.push({
1459
+ expected: "never",
1460
+ code: "invalid_type",
1461
+ input: n.value,
1462
+ inst: e
1463
+ }), n);
1464
+ });
1465
+ function Ve(e, t, n) {
1466
+ e.issues.length && t.issues.push(...pt(n, e.issues)), t.value[n] = e.value;
1467
+ }
1468
+ const Kr = /* @__PURE__ */ s("$ZodArray", (e, t) => {
1469
+ y.init(e, t), e._zod.parse = (n, r) => {
1470
+ const o = n.value;
1471
+ if (!Array.isArray(o))
1472
+ return n.issues.push({
1473
+ expected: "array",
1474
+ code: "invalid_type",
1475
+ input: o,
1476
+ inst: e
1477
+ }), n;
1478
+ n.value = Array(o.length);
1479
+ const i = [];
1480
+ for (let c = 0; c < o.length; c++) {
1481
+ const a = o[c], f = t.element._zod.run({
1482
+ value: a,
1483
+ issues: []
1484
+ }, r);
1485
+ f instanceof Promise ? i.push(f.then((d) => Ve(d, n, c))) : Ve(f, n, c);
1486
+ }
1487
+ return i.length ? Promise.all(i).then(() => n) : n;
1488
+ };
1489
+ });
1490
+ function ie(e, t, n, r) {
1491
+ e.issues.length && t.issues.push(...pt(n, e.issues)), e.value === void 0 ? n in r && (t.value[n] = void 0) : t.value[n] = e.value;
1492
+ }
1493
+ function Et(e) {
1494
+ const t = Object.keys(e.shape);
1495
+ for (const r of t)
1496
+ if (!e.shape?.[r]?._zod?.traits?.has("$ZodType"))
1497
+ throw new Error(`Invalid element at key "${r}": expected a Zod schema`);
1498
+ const n = mn(e.shape);
1499
+ return {
1500
+ ...e,
1501
+ keys: t,
1502
+ keySet: new Set(t),
1503
+ numKeys: t.length,
1504
+ optionalKeys: new Set(n)
1505
+ };
1506
+ }
1507
+ function xt(e, t, n, r, o, i) {
1508
+ const c = [], a = o.keySet, f = o.catchall._zod, d = f.def.type;
1509
+ for (const l of Object.keys(t)) {
1510
+ if (a.has(l))
1511
+ continue;
1512
+ if (d === "never") {
1513
+ c.push(l);
1514
+ continue;
1515
+ }
1516
+ const g = f.run({ value: t[l], issues: [] }, r);
1517
+ g instanceof Promise ? e.push(g.then((p) => ie(p, n, l, t))) : ie(g, n, l, t);
1518
+ }
1519
+ return c.length && n.issues.push({
1520
+ code: "unrecognized_keys",
1521
+ keys: c,
1522
+ input: t,
1523
+ inst: i
1524
+ }), e.length ? Promise.all(e).then(() => n) : n;
1525
+ }
1526
+ const Qr = /* @__PURE__ */ s("$ZodObject", (e, t) => {
1527
+ if (y.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
1528
+ const a = t.shape;
1529
+ Object.defineProperty(t, "shape", {
1530
+ get: () => {
1531
+ const f = { ...a };
1532
+ return Object.defineProperty(t, "shape", {
1533
+ value: f
1534
+ }), f;
1535
+ }
1536
+ });
1537
+ }
1538
+ const r = ye(() => Et(t));
1539
+ b(e._zod, "propValues", () => {
1540
+ const a = t.shape, f = {};
1541
+ for (const d in a) {
1542
+ const l = a[d]._zod;
1543
+ if (l.values) {
1544
+ f[d] ?? (f[d] = /* @__PURE__ */ new Set());
1545
+ for (const g of l.values)
1546
+ f[d].add(g);
1547
+ }
1548
+ }
1549
+ return f;
1550
+ });
1551
+ const o = oe, i = t.catchall;
1552
+ let c;
1553
+ e._zod.parse = (a, f) => {
1554
+ c ?? (c = r.value);
1555
+ const d = a.value;
1556
+ if (!o(d))
1557
+ return a.issues.push({
1558
+ expected: "object",
1559
+ code: "invalid_type",
1560
+ input: d,
1561
+ inst: e
1562
+ }), a;
1563
+ a.value = {};
1564
+ const l = [], g = c.shape;
1565
+ for (const p of c.keys) {
1566
+ const x = g[p]._zod.run({ value: d[p], issues: [] }, f);
1567
+ x instanceof Promise ? l.push(x.then((R) => ie(R, a, p, d))) : ie(x, a, p, d);
1568
+ }
1569
+ return i ? xt(l, d, a, f, r.value, e) : l.length ? Promise.all(l).then(() => a) : a;
1570
+ };
1571
+ }), eo = /* @__PURE__ */ s("$ZodObjectJIT", (e, t) => {
1572
+ Qr.init(e, t);
1573
+ const n = e._zod.parse, r = ye(() => Et(t)), o = (p) => {
1574
+ const v = new kr(["shape", "payload", "ctx"]), x = r.value, R = (A) => {
1575
+ const j = Le(A);
1576
+ return `shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`;
1577
+ };
1578
+ v.write("const input = payload.value;");
1579
+ const T = /* @__PURE__ */ Object.create(null);
1580
+ let P = 0;
1581
+ for (const A of x.keys)
1582
+ T[A] = `key_${P++}`;
1583
+ v.write("const newResult = {};");
1584
+ for (const A of x.keys) {
1585
+ const j = T[A], C = Le(A);
1586
+ v.write(`const ${j} = ${R(A)};`), v.write(`
1587
+ if (${j}.issues.length) {
1588
+ payload.issues = payload.issues.concat(${j}.issues.map(iss => ({
1589
+ ...iss,
1590
+ path: iss.path ? [${C}, ...iss.path] : [${C}]
1591
+ })));
1592
+ }
1593
+
1594
+
1595
+ if (${j}.value === undefined) {
1596
+ if (${C} in input) {
1597
+ newResult[${C}] = undefined;
1598
+ }
1599
+ } else {
1600
+ newResult[${C}] = ${j}.value;
1601
+ }
1602
+
1603
+ `);
1604
+ }
1605
+ v.write("payload.value = newResult;"), v.write("return payload;");
1606
+ const L = v.compile();
1607
+ return (A, j) => L(p, A, j);
1608
+ };
1609
+ let i;
1610
+ const c = oe, a = !dt.jitless, d = a && hn.value, l = t.catchall;
1611
+ let g;
1612
+ e._zod.parse = (p, v) => {
1613
+ g ?? (g = r.value);
1614
+ const x = p.value;
1615
+ return c(x) ? a && d && v?.async === !1 && v.jitless !== !0 ? (i || (i = o(t.shape)), p = i(p, v), l ? xt([], x, p, v, g, e) : p) : n(p, v) : (p.issues.push({
1616
+ expected: "object",
1617
+ code: "invalid_type",
1618
+ input: x,
1619
+ inst: e
1620
+ }), p);
1621
+ };
1622
+ });
1623
+ function We(e, t, n, r) {
1624
+ for (const i of e)
1625
+ if (i.issues.length === 0)
1626
+ return t.value = i.value, t;
1627
+ const o = e.filter((i) => !W(i));
1628
+ return o.length === 1 ? (t.value = o[0].value, o[0]) : (t.issues.push({
1629
+ code: "invalid_union",
1630
+ input: t.value,
1631
+ inst: n,
1632
+ errors: e.map((i) => i.issues.map((c) => D(c, r, N())))
1633
+ }), t);
1634
+ }
1635
+ const to = /* @__PURE__ */ s("$ZodUnion", (e, t) => {
1636
+ y.init(e, t), b(e._zod, "optin", () => t.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0), b(e._zod, "optout", () => t.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0), b(e._zod, "values", () => {
1637
+ if (t.options.every((o) => o._zod.values))
1638
+ return new Set(t.options.flatMap((o) => Array.from(o._zod.values)));
1639
+ }), b(e._zod, "pattern", () => {
1640
+ if (t.options.every((o) => o._zod.pattern)) {
1641
+ const o = t.options.map((i) => i._zod.pattern);
1642
+ return new RegExp(`^(${o.map((i) => Ze(i.source)).join("|")})$`);
1643
+ }
1644
+ });
1645
+ const n = t.options.length === 1, r = t.options[0]._zod.run;
1646
+ e._zod.parse = (o, i) => {
1647
+ if (n)
1648
+ return r(o, i);
1649
+ let c = !1;
1650
+ const a = [];
1651
+ for (const f of t.options) {
1652
+ const d = f._zod.run({
1653
+ value: o.value,
1654
+ issues: []
1655
+ }, i);
1656
+ if (d instanceof Promise)
1657
+ a.push(d), c = !0;
1658
+ else {
1659
+ if (d.issues.length === 0)
1660
+ return d;
1661
+ a.push(d);
1662
+ }
1663
+ }
1664
+ return c ? Promise.all(a).then((f) => We(f, o, e, i)) : We(a, o, e, i);
1665
+ };
1666
+ }), no = /* @__PURE__ */ s("$ZodIntersection", (e, t) => {
1667
+ y.init(e, t), e._zod.parse = (n, r) => {
1668
+ const o = n.value, i = t.left._zod.run({ value: o, issues: [] }, r), c = t.right._zod.run({ value: o, issues: [] }, r);
1669
+ return i instanceof Promise || c instanceof Promise ? Promise.all([i, c]).then(([f, d]) => Be(n, f, d)) : Be(n, i, c);
1670
+ };
1671
+ });
1672
+ function be(e, t) {
1673
+ if (e === t)
1674
+ return { valid: !0, data: e };
1675
+ if (e instanceof Date && t instanceof Date && +e == +t)
1676
+ return { valid: !0, data: e };
1677
+ if (G(e) && G(t)) {
1678
+ const n = Object.keys(t), r = Object.keys(e).filter((i) => n.indexOf(i) !== -1), o = { ...e, ...t };
1679
+ for (const i of r) {
1680
+ const c = be(e[i], t[i]);
1681
+ if (!c.valid)
1682
+ return {
1683
+ valid: !1,
1684
+ mergeErrorPath: [i, ...c.mergeErrorPath]
1685
+ };
1686
+ o[i] = c.data;
1687
+ }
1688
+ return { valid: !0, data: o };
1689
+ }
1690
+ if (Array.isArray(e) && Array.isArray(t)) {
1691
+ if (e.length !== t.length)
1692
+ return { valid: !1, mergeErrorPath: [] };
1693
+ const n = [];
1694
+ for (let r = 0; r < e.length; r++) {
1695
+ const o = e[r], i = t[r], c = be(o, i);
1696
+ if (!c.valid)
1697
+ return {
1698
+ valid: !1,
1699
+ mergeErrorPath: [r, ...c.mergeErrorPath]
1700
+ };
1701
+ n.push(c.data);
1702
+ }
1703
+ return { valid: !0, data: n };
1704
+ }
1705
+ return { valid: !1, mergeErrorPath: [] };
1706
+ }
1707
+ function Be(e, t, n) {
1708
+ if (t.issues.length && e.issues.push(...t.issues), n.issues.length && e.issues.push(...n.issues), W(e))
1709
+ return e;
1710
+ const r = be(t.value, n.value);
1711
+ if (!r.valid)
1712
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);
1713
+ return e.value = r.data, e;
1714
+ }
1715
+ const ro = /* @__PURE__ */ s("$ZodEnum", (e, t) => {
1716
+ y.init(e, t);
1717
+ const n = dn(t.entries), r = new Set(n);
1718
+ e._zod.values = r, e._zod.pattern = new RegExp(`^(${n.filter((o) => pn.has(typeof o)).map((o) => typeof o == "string" ? se(o) : o.toString()).join("|")})$`), e._zod.parse = (o, i) => {
1719
+ const c = o.value;
1720
+ return r.has(c) || o.issues.push({
1721
+ code: "invalid_value",
1722
+ values: n,
1723
+ input: c,
1724
+ inst: e
1725
+ }), o;
1726
+ };
1727
+ }), oo = /* @__PURE__ */ s("$ZodTransform", (e, t) => {
1728
+ y.init(e, t), e._zod.parse = (n, r) => {
1729
+ if (r.direction === "backward")
1730
+ throw new lt(e.constructor.name);
1731
+ const o = t.transform(n.value, n);
1732
+ if (r.async)
1733
+ return (o instanceof Promise ? o : Promise.resolve(o)).then((c) => (n.value = c, n));
1734
+ if (o instanceof Promise)
1735
+ throw new B();
1736
+ return n.value = o, n;
1737
+ };
1738
+ });
1739
+ function Ye(e, t) {
1740
+ return e.issues.length && t === void 0 ? { issues: [], value: void 0 } : e;
1741
+ }
1742
+ const io = /* @__PURE__ */ s("$ZodOptional", (e, t) => {
1743
+ y.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", b(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), b(e._zod, "pattern", () => {
1744
+ const n = t.innerType._zod.pattern;
1745
+ return n ? new RegExp(`^(${Ze(n.source)})?$`) : void 0;
1746
+ }), e._zod.parse = (n, r) => {
1747
+ if (t.innerType._zod.optin === "optional") {
1748
+ const o = t.innerType._zod.run(n, r);
1749
+ return o instanceof Promise ? o.then((i) => Ye(i, n.value)) : Ye(o, n.value);
1750
+ }
1751
+ return n.value === void 0 ? n : t.innerType._zod.run(n, r);
1752
+ };
1753
+ }), co = /* @__PURE__ */ s("$ZodNullable", (e, t) => {
1754
+ y.init(e, t), b(e._zod, "optin", () => t.innerType._zod.optin), b(e._zod, "optout", () => t.innerType._zod.optout), b(e._zod, "pattern", () => {
1755
+ const n = t.innerType._zod.pattern;
1756
+ return n ? new RegExp(`^(${Ze(n.source)}|null)$`) : void 0;
1757
+ }), b(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (n, r) => n.value === null ? n : t.innerType._zod.run(n, r);
1758
+ }), so = /* @__PURE__ */ s("$ZodDefault", (e, t) => {
1759
+ y.init(e, t), e._zod.optin = "optional", b(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
1760
+ if (r.direction === "backward")
1761
+ return t.innerType._zod.run(n, r);
1762
+ if (n.value === void 0)
1763
+ return n.value = t.defaultValue, n;
1764
+ const o = t.innerType._zod.run(n, r);
1765
+ return o instanceof Promise ? o.then((i) => Je(i, t)) : Je(o, t);
1766
+ };
1767
+ });
1768
+ function Je(e, t) {
1769
+ return e.value === void 0 && (e.value = t.defaultValue), e;
1770
+ }
1771
+ const ao = /* @__PURE__ */ s("$ZodPrefault", (e, t) => {
1772
+ y.init(e, t), e._zod.optin = "optional", b(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => (r.direction === "backward" || n.value === void 0 && (n.value = t.defaultValue), t.innerType._zod.run(n, r));
1773
+ }), uo = /* @__PURE__ */ s("$ZodNonOptional", (e, t) => {
1774
+ y.init(e, t), b(e._zod, "values", () => {
1775
+ const n = t.innerType._zod.values;
1776
+ return n ? new Set([...n].filter((r) => r !== void 0)) : void 0;
1777
+ }), e._zod.parse = (n, r) => {
1778
+ const o = t.innerType._zod.run(n, r);
1779
+ return o instanceof Promise ? o.then((i) => Ge(i, e)) : Ge(o, e);
1780
+ };
1781
+ });
1782
+ function Ge(e, t) {
1783
+ return !e.issues.length && e.value === void 0 && e.issues.push({
1784
+ code: "invalid_type",
1785
+ expected: "nonoptional",
1786
+ input: e.value,
1787
+ inst: t
1788
+ }), e;
1789
+ }
1790
+ const lo = /* @__PURE__ */ s("$ZodCatch", (e, t) => {
1791
+ y.init(e, t), b(e._zod, "optin", () => t.innerType._zod.optin), b(e._zod, "optout", () => t.innerType._zod.optout), b(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, r) => {
1792
+ if (r.direction === "backward")
1793
+ return t.innerType._zod.run(n, r);
1794
+ const o = t.innerType._zod.run(n, r);
1795
+ return o instanceof Promise ? o.then((i) => (n.value = i.value, i.issues.length && (n.value = t.catchValue({
1796
+ ...n,
1797
+ error: {
1798
+ issues: i.issues.map((c) => D(c, r, N()))
1799
+ },
1800
+ input: n.value
1801
+ }), n.issues = []), n)) : (n.value = o.value, o.issues.length && (n.value = t.catchValue({
1802
+ ...n,
1803
+ error: {
1804
+ issues: o.issues.map((i) => D(i, r, N()))
1805
+ },
1806
+ input: n.value
1807
+ }), n.issues = []), n);
1808
+ };
1809
+ }), fo = /* @__PURE__ */ s("$ZodPipe", (e, t) => {
1810
+ y.init(e, t), b(e._zod, "values", () => t.in._zod.values), b(e._zod, "optin", () => t.in._zod.optin), b(e._zod, "optout", () => t.out._zod.optout), b(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (n, r) => {
1811
+ if (r.direction === "backward") {
1812
+ const i = t.out._zod.run(n, r);
1813
+ return i instanceof Promise ? i.then((c) => ee(c, t.in, r)) : ee(i, t.in, r);
1814
+ }
1815
+ const o = t.in._zod.run(n, r);
1816
+ return o instanceof Promise ? o.then((i) => ee(i, t.out, r)) : ee(o, t.out, r);
1817
+ };
1818
+ });
1819
+ function ee(e, t, n) {
1820
+ return e.issues.length ? (e.aborted = !0, e) : t._zod.run({ value: e.value, issues: e.issues }, n);
1821
+ }
1822
+ const ho = /* @__PURE__ */ s("$ZodReadonly", (e, t) => {
1823
+ y.init(e, t), b(e._zod, "propValues", () => t.innerType._zod.propValues), b(e._zod, "values", () => t.innerType._zod.values), b(e._zod, "optin", () => t.innerType._zod.optin), b(e._zod, "optout", () => t.innerType._zod.optout), e._zod.parse = (n, r) => {
1824
+ if (r.direction === "backward")
1825
+ return t.innerType._zod.run(n, r);
1826
+ const o = t.innerType._zod.run(n, r);
1827
+ return o instanceof Promise ? o.then(qe) : qe(o);
1828
+ };
1829
+ });
1830
+ function qe(e) {
1831
+ return e.value = Object.freeze(e.value), e;
1832
+ }
1833
+ const po = /* @__PURE__ */ s("$ZodCustom", (e, t) => {
1834
+ I.init(e, t), y.init(e, t), e._zod.parse = (n, r) => n, e._zod.check = (n) => {
1835
+ const r = n.value, o = t.fn(r);
1836
+ if (o instanceof Promise)
1837
+ return o.then((i) => He(i, n, r, e));
1838
+ He(o, n, r, e);
1839
+ };
1840
+ });
1841
+ function He(e, t, n, r) {
1842
+ if (!e) {
1843
+ const o = {
1844
+ code: "custom",
1845
+ input: n,
1846
+ inst: r,
1847
+ // incorporates params.error into issue reporting
1848
+ path: [...r._zod.def.path ?? []],
1849
+ // incorporates params.error into issue reporting
1850
+ continue: !r._zod.def.abort
1851
+ // params: inst._zod.def.params,
1852
+ };
1853
+ r._zod.def.params && (o.params = r._zod.def.params), t.issues.push(q(o));
1854
+ }
1855
+ }
1856
+ class mo {
1857
+ constructor() {
1858
+ this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
1859
+ }
1860
+ add(t, ...n) {
1861
+ const r = n[0];
1862
+ if (this._map.set(t, r), r && typeof r == "object" && "id" in r) {
1863
+ if (this._idmap.has(r.id))
1864
+ throw new Error(`ID ${r.id} already exists in the registry`);
1865
+ this._idmap.set(r.id, t);
1866
+ }
1867
+ return this;
1868
+ }
1869
+ clear() {
1870
+ return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
1871
+ }
1872
+ remove(t) {
1873
+ const n = this._map.get(t);
1874
+ return n && typeof n == "object" && "id" in n && this._idmap.delete(n.id), this._map.delete(t), this;
1875
+ }
1876
+ get(t) {
1877
+ const n = t._zod.parent;
1878
+ if (n) {
1879
+ const r = { ...this.get(n) ?? {} };
1880
+ delete r.id;
1881
+ const o = { ...r, ...this._map.get(t) };
1882
+ return Object.keys(o).length ? o : void 0;
1883
+ }
1884
+ return this._map.get(t);
1885
+ }
1886
+ has(t) {
1887
+ return this._map.has(t);
1888
+ }
1889
+ }
1890
+ function _o() {
1891
+ return new mo();
1892
+ }
1893
+ const te = /* @__PURE__ */ _o();
1894
+ function go(e, t) {
1895
+ return new e({
1896
+ type: "string",
1897
+ ...h(t)
1898
+ });
1899
+ }
1900
+ function vo(e, t) {
1901
+ return new e({
1902
+ type: "string",
1903
+ format: "email",
1904
+ check: "string_format",
1905
+ abort: !1,
1906
+ ...h(t)
1907
+ });
1908
+ }
1909
+ function Xe(e, t) {
1910
+ return new e({
1911
+ type: "string",
1912
+ format: "guid",
1913
+ check: "string_format",
1914
+ abort: !1,
1915
+ ...h(t)
1916
+ });
1917
+ }
1918
+ function bo(e, t) {
1919
+ return new e({
1920
+ type: "string",
1921
+ format: "uuid",
1922
+ check: "string_format",
1923
+ abort: !1,
1924
+ ...h(t)
1925
+ });
1926
+ }
1927
+ function wo(e, t) {
1928
+ return new e({
1929
+ type: "string",
1930
+ format: "uuid",
1931
+ check: "string_format",
1932
+ abort: !1,
1933
+ version: "v4",
1934
+ ...h(t)
1935
+ });
1936
+ }
1937
+ function ko(e, t) {
1938
+ return new e({
1939
+ type: "string",
1940
+ format: "uuid",
1941
+ check: "string_format",
1942
+ abort: !1,
1943
+ version: "v6",
1944
+ ...h(t)
1945
+ });
1946
+ }
1947
+ function zo(e, t) {
1948
+ return new e({
1949
+ type: "string",
1950
+ format: "uuid",
1951
+ check: "string_format",
1952
+ abort: !1,
1953
+ version: "v7",
1954
+ ...h(t)
1955
+ });
1956
+ }
1957
+ function yo(e, t) {
1958
+ return new e({
1959
+ type: "string",
1960
+ format: "url",
1961
+ check: "string_format",
1962
+ abort: !1,
1963
+ ...h(t)
1964
+ });
1965
+ }
1966
+ function $o(e, t) {
1967
+ return new e({
1968
+ type: "string",
1969
+ format: "emoji",
1970
+ check: "string_format",
1971
+ abort: !1,
1972
+ ...h(t)
1973
+ });
1974
+ }
1975
+ function Zo(e, t) {
1976
+ return new e({
1977
+ type: "string",
1978
+ format: "nanoid",
1979
+ check: "string_format",
1980
+ abort: !1,
1981
+ ...h(t)
1982
+ });
1983
+ }
1984
+ function Eo(e, t) {
1985
+ return new e({
1986
+ type: "string",
1987
+ format: "cuid",
1988
+ check: "string_format",
1989
+ abort: !1,
1990
+ ...h(t)
1991
+ });
1992
+ }
1993
+ function xo(e, t) {
1994
+ return new e({
1995
+ type: "string",
1996
+ format: "cuid2",
1997
+ check: "string_format",
1998
+ abort: !1,
1999
+ ...h(t)
2000
+ });
2001
+ }
2002
+ function To(e, t) {
2003
+ return new e({
2004
+ type: "string",
2005
+ format: "ulid",
2006
+ check: "string_format",
2007
+ abort: !1,
2008
+ ...h(t)
2009
+ });
2010
+ }
2011
+ function Ao(e, t) {
2012
+ return new e({
2013
+ type: "string",
2014
+ format: "xid",
2015
+ check: "string_format",
2016
+ abort: !1,
2017
+ ...h(t)
2018
+ });
2019
+ }
2020
+ function Io(e, t) {
2021
+ return new e({
2022
+ type: "string",
2023
+ format: "ksuid",
2024
+ check: "string_format",
2025
+ abort: !1,
2026
+ ...h(t)
2027
+ });
2028
+ }
2029
+ function jo(e, t) {
2030
+ return new e({
2031
+ type: "string",
2032
+ format: "ipv4",
2033
+ check: "string_format",
2034
+ abort: !1,
2035
+ ...h(t)
2036
+ });
2037
+ }
2038
+ function So(e, t) {
2039
+ return new e({
2040
+ type: "string",
2041
+ format: "ipv6",
2042
+ check: "string_format",
2043
+ abort: !1,
2044
+ ...h(t)
2045
+ });
2046
+ }
2047
+ function Oo(e, t) {
2048
+ return new e({
2049
+ type: "string",
2050
+ format: "cidrv4",
2051
+ check: "string_format",
2052
+ abort: !1,
2053
+ ...h(t)
2054
+ });
2055
+ }
2056
+ function Ro(e, t) {
2057
+ return new e({
2058
+ type: "string",
2059
+ format: "cidrv6",
2060
+ check: "string_format",
2061
+ abort: !1,
2062
+ ...h(t)
2063
+ });
2064
+ }
2065
+ function Po(e, t) {
2066
+ return new e({
2067
+ type: "string",
2068
+ format: "base64",
2069
+ check: "string_format",
2070
+ abort: !1,
2071
+ ...h(t)
2072
+ });
2073
+ }
2074
+ function Co(e, t) {
2075
+ return new e({
2076
+ type: "string",
2077
+ format: "base64url",
2078
+ check: "string_format",
2079
+ abort: !1,
2080
+ ...h(t)
2081
+ });
2082
+ }
2083
+ function No(e, t) {
2084
+ return new e({
2085
+ type: "string",
2086
+ format: "e164",
2087
+ check: "string_format",
2088
+ abort: !1,
2089
+ ...h(t)
2090
+ });
2091
+ }
2092
+ function Do(e, t) {
2093
+ return new e({
2094
+ type: "string",
2095
+ format: "jwt",
2096
+ check: "string_format",
2097
+ abort: !1,
2098
+ ...h(t)
2099
+ });
2100
+ }
2101
+ function Uo(e, t) {
2102
+ return new e({
2103
+ type: "string",
2104
+ format: "datetime",
2105
+ check: "string_format",
2106
+ offset: !1,
2107
+ local: !1,
2108
+ precision: null,
2109
+ ...h(t)
2110
+ });
2111
+ }
2112
+ function Fo(e, t) {
2113
+ return new e({
2114
+ type: "string",
2115
+ format: "date",
2116
+ check: "string_format",
2117
+ ...h(t)
2118
+ });
2119
+ }
2120
+ function Lo(e, t) {
2121
+ return new e({
2122
+ type: "string",
2123
+ format: "time",
2124
+ check: "string_format",
2125
+ precision: null,
2126
+ ...h(t)
2127
+ });
2128
+ }
2129
+ function Mo(e, t) {
2130
+ return new e({
2131
+ type: "string",
2132
+ format: "duration",
2133
+ check: "string_format",
2134
+ ...h(t)
2135
+ });
2136
+ }
2137
+ function Vo(e, t) {
2138
+ return new e({
2139
+ type: "number",
2140
+ checks: [],
2141
+ ...h(t)
2142
+ });
2143
+ }
2144
+ function Wo(e, t) {
2145
+ return new e({
2146
+ type: "number",
2147
+ check: "number_format",
2148
+ abort: !1,
2149
+ format: "safeint",
2150
+ ...h(t)
2151
+ });
2152
+ }
2153
+ function Bo(e, t) {
2154
+ return new e({
2155
+ type: "boolean",
2156
+ ...h(t)
2157
+ });
2158
+ }
2159
+ function Yo(e) {
2160
+ return new e({
2161
+ type: "unknown"
2162
+ });
2163
+ }
2164
+ function Jo(e, t) {
2165
+ return new e({
2166
+ type: "never",
2167
+ ...h(t)
2168
+ });
2169
+ }
2170
+ function Ke(e, t) {
2171
+ return new zt({
2172
+ check: "less_than",
2173
+ ...h(t),
2174
+ value: e,
2175
+ inclusive: !1
2176
+ });
2177
+ }
2178
+ function _e(e, t) {
2179
+ return new zt({
2180
+ check: "less_than",
2181
+ ...h(t),
2182
+ value: e,
2183
+ inclusive: !0
2184
+ });
2185
+ }
2186
+ function Qe(e, t) {
2187
+ return new yt({
2188
+ check: "greater_than",
2189
+ ...h(t),
2190
+ value: e,
2191
+ inclusive: !1
2192
+ });
2193
+ }
2194
+ function ge(e, t) {
2195
+ return new yt({
2196
+ check: "greater_than",
2197
+ ...h(t),
2198
+ value: e,
2199
+ inclusive: !0
2200
+ });
2201
+ }
2202
+ function et(e, t) {
2203
+ return new ur({
2204
+ check: "multiple_of",
2205
+ ...h(t),
2206
+ value: e
2207
+ });
2208
+ }
2209
+ function Tt(e, t) {
2210
+ return new dr({
2211
+ check: "max_length",
2212
+ ...h(t),
2213
+ maximum: e
2214
+ });
2215
+ }
2216
+ function ce(e, t) {
2217
+ return new fr({
2218
+ check: "min_length",
2219
+ ...h(t),
2220
+ minimum: e
2221
+ });
2222
+ }
2223
+ function At(e, t) {
2224
+ return new hr({
2225
+ check: "length_equals",
2226
+ ...h(t),
2227
+ length: e
2228
+ });
2229
+ }
2230
+ function Go(e, t) {
2231
+ return new pr({
2232
+ check: "string_format",
2233
+ format: "regex",
2234
+ ...h(t),
2235
+ pattern: e
2236
+ });
2237
+ }
2238
+ function qo(e) {
2239
+ return new mr({
2240
+ check: "string_format",
2241
+ format: "lowercase",
2242
+ ...h(e)
2243
+ });
2244
+ }
2245
+ function Ho(e) {
2246
+ return new _r({
2247
+ check: "string_format",
2248
+ format: "uppercase",
2249
+ ...h(e)
2250
+ });
2251
+ }
2252
+ function Xo(e, t) {
2253
+ return new gr({
2254
+ check: "string_format",
2255
+ format: "includes",
2256
+ ...h(t),
2257
+ includes: e
2258
+ });
2259
+ }
2260
+ function Ko(e, t) {
2261
+ return new vr({
2262
+ check: "string_format",
2263
+ format: "starts_with",
2264
+ ...h(t),
2265
+ prefix: e
2266
+ });
2267
+ }
2268
+ function Qo(e, t) {
2269
+ return new br({
2270
+ check: "string_format",
2271
+ format: "ends_with",
2272
+ ...h(t),
2273
+ suffix: e
2274
+ });
2275
+ }
2276
+ function H(e) {
2277
+ return new wr({
2278
+ check: "overwrite",
2279
+ tx: e
2280
+ });
2281
+ }
2282
+ function ei(e) {
2283
+ return H((t) => t.normalize(e));
2284
+ }
2285
+ function ti() {
2286
+ return H((e) => e.trim());
2287
+ }
2288
+ function ni() {
2289
+ return H((e) => e.toLowerCase());
2290
+ }
2291
+ function ri() {
2292
+ return H((e) => e.toUpperCase());
2293
+ }
2294
+ function oi(e, t, n) {
2295
+ return new e({
2296
+ type: "array",
2297
+ element: t,
2298
+ // get element() {
2299
+ // return element;
2300
+ // },
2301
+ ...h(n)
2302
+ });
2303
+ }
2304
+ function ii(e, t, n) {
2305
+ return new e({
2306
+ type: "custom",
2307
+ check: "custom",
2308
+ fn: t,
2309
+ ...h(n)
2310
+ });
2311
+ }
2312
+ function ci(e) {
2313
+ const t = si((n) => (n.addIssue = (r) => {
2314
+ if (typeof r == "string")
2315
+ n.issues.push(q(r, n.value, t._zod.def));
2316
+ else {
2317
+ const o = r;
2318
+ o.fatal && (o.continue = !1), o.code ?? (o.code = "custom"), o.input ?? (o.input = n.value), o.inst ?? (o.inst = t), o.continue ?? (o.continue = !t._zod.def.abort), n.issues.push(q(o));
2319
+ }
2320
+ }, e(n.value, n)));
2321
+ return t;
2322
+ }
2323
+ function si(e, t) {
2324
+ const n = new I({
2325
+ check: "custom",
2326
+ ...h(t)
2327
+ });
2328
+ return n._zod.check = e, n;
2329
+ }
2330
+ const ai = /* @__PURE__ */ s("ZodISODateTime", (e, t) => {
2331
+ Rr.init(e, t), k.init(e, t);
2332
+ });
2333
+ function ui(e) {
2334
+ return Uo(ai, e);
2335
+ }
2336
+ const li = /* @__PURE__ */ s("ZodISODate", (e, t) => {
2337
+ Pr.init(e, t), k.init(e, t);
2338
+ });
2339
+ function di(e) {
2340
+ return Fo(li, e);
2341
+ }
2342
+ const fi = /* @__PURE__ */ s("ZodISOTime", (e, t) => {
2343
+ Cr.init(e, t), k.init(e, t);
2344
+ });
2345
+ function hi(e) {
2346
+ return Lo(fi, e);
2347
+ }
2348
+ const pi = /* @__PURE__ */ s("ZodISODuration", (e, t) => {
2349
+ Nr.init(e, t), k.init(e, t);
2350
+ });
2351
+ function mi(e) {
2352
+ return Mo(pi, e);
2353
+ }
2354
+ const _i = (e, t) => {
2355
+ _t.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
2356
+ format: {
2357
+ value: (n) => Zn(e, n)
2358
+ // enumerable: false,
2359
+ },
2360
+ flatten: {
2361
+ value: (n) => $n(e, n)
2362
+ // enumerable: false,
2363
+ },
2364
+ addIssue: {
2365
+ value: (n) => {
2366
+ e.issues.push(n), e.message = JSON.stringify(e.issues, ve, 2);
2367
+ }
2368
+ // enumerable: false,
2369
+ },
2370
+ addIssues: {
2371
+ value: (n) => {
2372
+ e.issues.push(...n), e.message = JSON.stringify(e.issues, ve, 2);
2373
+ }
2374
+ // enumerable: false,
2375
+ },
2376
+ isEmpty: {
2377
+ get() {
2378
+ return e.issues.length === 0;
2379
+ }
2380
+ // enumerable: false,
2381
+ }
2382
+ });
2383
+ }, S = s("ZodError", _i, {
2384
+ Parent: Error
2385
+ }), gi = /* @__PURE__ */ xe(S), vi = /* @__PURE__ */ Te(S), bi = /* @__PURE__ */ ae(S), wi = /* @__PURE__ */ ue(S), ki = /* @__PURE__ */ Tn(S), zi = /* @__PURE__ */ An(S), yi = /* @__PURE__ */ In(S), $i = /* @__PURE__ */ jn(S), Zi = /* @__PURE__ */ Sn(S), Ei = /* @__PURE__ */ On(S), xi = /* @__PURE__ */ Rn(S), Ti = /* @__PURE__ */ Pn(S), $ = /* @__PURE__ */ s("ZodType", (e, t) => (y.init(e, t), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => e.clone(F(t, {
2386
+ checks: [
2387
+ ...t.checks ?? [],
2388
+ ...n.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
2389
+ ]
2390
+ })), e.clone = (n, r) => O(e, n, r), e.brand = () => e, e.register = ((n, r) => (n.add(e, r), e)), e.parse = (n, r) => gi(e, n, r, { callee: e.parse }), e.safeParse = (n, r) => bi(e, n, r), e.parseAsync = async (n, r) => vi(e, n, r, { callee: e.parseAsync }), e.safeParseAsync = async (n, r) => wi(e, n, r), e.spa = e.safeParseAsync, e.encode = (n, r) => ki(e, n, r), e.decode = (n, r) => zi(e, n, r), e.encodeAsync = async (n, r) => yi(e, n, r), e.decodeAsync = async (n, r) => $i(e, n, r), e.safeEncode = (n, r) => Zi(e, n, r), e.safeDecode = (n, r) => Ei(e, n, r), e.safeEncodeAsync = async (n, r) => xi(e, n, r), e.safeDecodeAsync = async (n, r) => Ti(e, n, r), e.refine = (n, r) => e.check(bc(n, r)), e.superRefine = (n) => e.check(wc(n)), e.overwrite = (n) => e.check(H(n)), e.optional = () => ct(e), e.nullable = () => st(e), e.nullish = () => ct(st(e)), e.nonoptional = (n) => fc(e, n), e.array = () => Qi(e), e.or = (n) => nc([e, n]), e.and = (n) => oc(e, n), e.transform = (n) => at(e, cc(n)), e.default = (n) => uc(e, n), e.prefault = (n) => dc(e, n), e.catch = (n) => pc(e, n), e.pipe = (n) => at(e, n), e.readonly = () => gc(e), e.describe = (n) => {
2391
+ const r = e.clone();
2392
+ return te.add(r, { description: n }), r;
2393
+ }, Object.defineProperty(e, "description", {
2394
+ get() {
2395
+ return te.get(e)?.description;
2396
+ },
2397
+ configurable: !0
2398
+ }), e.meta = (...n) => {
2399
+ if (n.length === 0)
2400
+ return te.get(e);
2401
+ const r = e.clone();
2402
+ return te.add(r, n[0]), r;
2403
+ }, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e)), It = /* @__PURE__ */ s("_ZodString", (e, t) => {
2404
+ Ae.init(e, t), $.init(e, t);
2405
+ const n = e._zod.bag;
2406
+ e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, e.regex = (...r) => e.check(Go(...r)), e.includes = (...r) => e.check(Xo(...r)), e.startsWith = (...r) => e.check(Ko(...r)), e.endsWith = (...r) => e.check(Qo(...r)), e.min = (...r) => e.check(ce(...r)), e.max = (...r) => e.check(Tt(...r)), e.length = (...r) => e.check(At(...r)), e.nonempty = (...r) => e.check(ce(1, ...r)), e.lowercase = (r) => e.check(qo(r)), e.uppercase = (r) => e.check(Ho(r)), e.trim = () => e.check(ti()), e.normalize = (...r) => e.check(ei(...r)), e.toLowerCase = () => e.check(ni()), e.toUpperCase = () => e.check(ri());
2407
+ }), Ai = /* @__PURE__ */ s("ZodString", (e, t) => {
2408
+ Ae.init(e, t), It.init(e, t), e.email = (n) => e.check(vo(Ii, n)), e.url = (n) => e.check(yo(ji, n)), e.jwt = (n) => e.check(Do(Yi, n)), e.emoji = (n) => e.check($o(Si, n)), e.guid = (n) => e.check(Xe(tt, n)), e.uuid = (n) => e.check(bo(re, n)), e.uuidv4 = (n) => e.check(wo(re, n)), e.uuidv6 = (n) => e.check(ko(re, n)), e.uuidv7 = (n) => e.check(zo(re, n)), e.nanoid = (n) => e.check(Zo(Oi, n)), e.guid = (n) => e.check(Xe(tt, n)), e.cuid = (n) => e.check(Eo(Ri, n)), e.cuid2 = (n) => e.check(xo(Pi, n)), e.ulid = (n) => e.check(To(Ci, n)), e.base64 = (n) => e.check(Po(Vi, n)), e.base64url = (n) => e.check(Co(Wi, n)), e.xid = (n) => e.check(Ao(Ni, n)), e.ksuid = (n) => e.check(Io(Di, n)), e.ipv4 = (n) => e.check(jo(Ui, n)), e.ipv6 = (n) => e.check(So(Fi, n)), e.cidrv4 = (n) => e.check(Oo(Li, n)), e.cidrv6 = (n) => e.check(Ro(Mi, n)), e.e164 = (n) => e.check(No(Bi, n)), e.datetime = (n) => e.check(ui(n)), e.date = (n) => e.check(di(n)), e.time = (n) => e.check(hi(n)), e.duration = (n) => e.check(mi(n));
2409
+ });
2410
+ function ne(e) {
2411
+ return go(Ai, e);
2412
+ }
2413
+ const k = /* @__PURE__ */ s("ZodStringFormat", (e, t) => {
2414
+ w.init(e, t), It.init(e, t);
2415
+ }), Ii = /* @__PURE__ */ s("ZodEmail", (e, t) => {
2416
+ Zr.init(e, t), k.init(e, t);
2417
+ }), tt = /* @__PURE__ */ s("ZodGUID", (e, t) => {
2418
+ yr.init(e, t), k.init(e, t);
2419
+ }), re = /* @__PURE__ */ s("ZodUUID", (e, t) => {
2420
+ $r.init(e, t), k.init(e, t);
2421
+ }), ji = /* @__PURE__ */ s("ZodURL", (e, t) => {
2422
+ Er.init(e, t), k.init(e, t);
2423
+ }), Si = /* @__PURE__ */ s("ZodEmoji", (e, t) => {
2424
+ xr.init(e, t), k.init(e, t);
2425
+ }), Oi = /* @__PURE__ */ s("ZodNanoID", (e, t) => {
2426
+ Tr.init(e, t), k.init(e, t);
2427
+ }), Ri = /* @__PURE__ */ s("ZodCUID", (e, t) => {
2428
+ Ar.init(e, t), k.init(e, t);
2429
+ }), Pi = /* @__PURE__ */ s("ZodCUID2", (e, t) => {
2430
+ Ir.init(e, t), k.init(e, t);
2431
+ }), Ci = /* @__PURE__ */ s("ZodULID", (e, t) => {
2432
+ jr.init(e, t), k.init(e, t);
2433
+ }), Ni = /* @__PURE__ */ s("ZodXID", (e, t) => {
2434
+ Sr.init(e, t), k.init(e, t);
2435
+ }), Di = /* @__PURE__ */ s("ZodKSUID", (e, t) => {
2436
+ Or.init(e, t), k.init(e, t);
2437
+ }), Ui = /* @__PURE__ */ s("ZodIPv4", (e, t) => {
2438
+ Dr.init(e, t), k.init(e, t);
2439
+ }), Fi = /* @__PURE__ */ s("ZodIPv6", (e, t) => {
2440
+ Ur.init(e, t), k.init(e, t);
2441
+ }), Li = /* @__PURE__ */ s("ZodCIDRv4", (e, t) => {
2442
+ Fr.init(e, t), k.init(e, t);
2443
+ }), Mi = /* @__PURE__ */ s("ZodCIDRv6", (e, t) => {
2444
+ Lr.init(e, t), k.init(e, t);
2445
+ }), Vi = /* @__PURE__ */ s("ZodBase64", (e, t) => {
2446
+ Mr.init(e, t), k.init(e, t);
2447
+ }), Wi = /* @__PURE__ */ s("ZodBase64URL", (e, t) => {
2448
+ Wr.init(e, t), k.init(e, t);
2449
+ }), Bi = /* @__PURE__ */ s("ZodE164", (e, t) => {
2450
+ Br.init(e, t), k.init(e, t);
2451
+ }), Yi = /* @__PURE__ */ s("ZodJWT", (e, t) => {
2452
+ Jr.init(e, t), k.init(e, t);
2453
+ }), jt = /* @__PURE__ */ s("ZodNumber", (e, t) => {
2454
+ Zt.init(e, t), $.init(e, t), e.gt = (r, o) => e.check(Qe(r, o)), e.gte = (r, o) => e.check(ge(r, o)), e.min = (r, o) => e.check(ge(r, o)), e.lt = (r, o) => e.check(Ke(r, o)), e.lte = (r, o) => e.check(_e(r, o)), e.max = (r, o) => e.check(_e(r, o)), e.int = (r) => e.check(rt(r)), e.safe = (r) => e.check(rt(r)), e.positive = (r) => e.check(Qe(0, r)), e.nonnegative = (r) => e.check(ge(0, r)), e.negative = (r) => e.check(Ke(0, r)), e.nonpositive = (r) => e.check(_e(0, r)), e.multipleOf = (r, o) => e.check(et(r, o)), e.step = (r, o) => e.check(et(r, o)), e.finite = () => e;
2455
+ const n = e._zod.bag;
2456
+ e.minValue = Math.max(n.minimum ?? Number.NEGATIVE_INFINITY, n.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(n.maximum ?? Number.POSITIVE_INFINITY, n.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (n.format ?? "").includes("int") || Number.isSafeInteger(n.multipleOf ?? 0.5), e.isFinite = !0, e.format = n.format ?? null;
2457
+ });
2458
+ function nt(e) {
2459
+ return Vo(jt, e);
2460
+ }
2461
+ const Ji = /* @__PURE__ */ s("ZodNumberFormat", (e, t) => {
2462
+ Gr.init(e, t), jt.init(e, t);
2463
+ });
2464
+ function rt(e) {
2465
+ return Wo(Ji, e);
2466
+ }
2467
+ const Gi = /* @__PURE__ */ s("ZodBoolean", (e, t) => {
2468
+ qr.init(e, t), $.init(e, t);
2469
+ });
2470
+ function ot(e) {
2471
+ return Bo(Gi, e);
2472
+ }
2473
+ const qi = /* @__PURE__ */ s("ZodUnknown", (e, t) => {
2474
+ Hr.init(e, t), $.init(e, t);
2475
+ });
2476
+ function it() {
2477
+ return Yo(qi);
2478
+ }
2479
+ const Hi = /* @__PURE__ */ s("ZodNever", (e, t) => {
2480
+ Xr.init(e, t), $.init(e, t);
2481
+ });
2482
+ function Xi(e) {
2483
+ return Jo(Hi, e);
2484
+ }
2485
+ const Ki = /* @__PURE__ */ s("ZodArray", (e, t) => {
2486
+ Kr.init(e, t), $.init(e, t), e.element = t.element, e.min = (n, r) => e.check(ce(n, r)), e.nonempty = (n) => e.check(ce(1, n)), e.max = (n, r) => e.check(Tt(n, r)), e.length = (n, r) => e.check(At(n, r)), e.unwrap = () => e.element;
2487
+ });
2488
+ function Qi(e, t) {
2489
+ return oi(Ki, e, t);
2490
+ }
2491
+ const ec = /* @__PURE__ */ s("ZodObject", (e, t) => {
2492
+ eo.init(e, t), $.init(e, t), b(e, "shape", () => t.shape), e.keyof = () => Ie(Object.keys(e._zod.def.shape)), e.catchall = (n) => e.clone({ ...e._zod.def, catchall: n }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: it() }), e.loose = () => e.clone({ ...e._zod.def, catchall: it() }), e.strict = () => e.clone({ ...e._zod.def, catchall: Xi() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (n) => bn(e, n), e.safeExtend = (n) => wn(e, n), e.merge = (n) => kn(e, n), e.pick = (n) => gn(e, n), e.omit = (n) => vn(e, n), e.partial = (...n) => zn(St, e, n[0]), e.required = (...n) => yn(Ot, e, n[0]);
2493
+ });
2494
+ function we(e, t) {
2495
+ const n = {
2496
+ type: "object",
2497
+ shape: e ?? {},
2498
+ ...h(t)
2499
+ };
2500
+ return new ec(n);
2501
+ }
2502
+ const tc = /* @__PURE__ */ s("ZodUnion", (e, t) => {
2503
+ to.init(e, t), $.init(e, t), e.options = t.options;
2504
+ });
2505
+ function nc(e, t) {
2506
+ return new tc({
2507
+ type: "union",
2508
+ options: e,
2509
+ ...h(t)
2510
+ });
2511
+ }
2512
+ const rc = /* @__PURE__ */ s("ZodIntersection", (e, t) => {
2513
+ no.init(e, t), $.init(e, t);
2514
+ });
2515
+ function oc(e, t) {
2516
+ return new rc({
2517
+ type: "intersection",
2518
+ left: e,
2519
+ right: t
2520
+ });
2521
+ }
2522
+ const ke = /* @__PURE__ */ s("ZodEnum", (e, t) => {
2523
+ ro.init(e, t), $.init(e, t), e.enum = t.entries, e.options = Object.values(t.entries);
2524
+ const n = new Set(Object.keys(t.entries));
2525
+ e.extract = (r, o) => {
2526
+ const i = {};
2527
+ for (const c of r)
2528
+ if (n.has(c))
2529
+ i[c] = t.entries[c];
2530
+ else
2531
+ throw new Error(`Key ${c} not found in enum`);
2532
+ return new ke({
2533
+ ...t,
2534
+ checks: [],
2535
+ ...h(o),
2536
+ entries: i
2537
+ });
2538
+ }, e.exclude = (r, o) => {
2539
+ const i = { ...t.entries };
2540
+ for (const c of r)
2541
+ if (n.has(c))
2542
+ delete i[c];
2543
+ else
2544
+ throw new Error(`Key ${c} not found in enum`);
2545
+ return new ke({
2546
+ ...t,
2547
+ checks: [],
2548
+ ...h(o),
2549
+ entries: i
2550
+ });
2551
+ };
2552
+ });
2553
+ function Ie(e, t) {
2554
+ const n = Array.isArray(e) ? Object.fromEntries(e.map((r) => [r, r])) : e;
2555
+ return new ke({
2556
+ type: "enum",
2557
+ entries: n,
2558
+ ...h(t)
2559
+ });
2560
+ }
2561
+ const ic = /* @__PURE__ */ s("ZodTransform", (e, t) => {
2562
+ oo.init(e, t), $.init(e, t), e._zod.parse = (n, r) => {
2563
+ if (r.direction === "backward")
2564
+ throw new lt(e.constructor.name);
2565
+ n.addIssue = (i) => {
2566
+ if (typeof i == "string")
2567
+ n.issues.push(q(i, n.value, t));
2568
+ else {
2569
+ const c = i;
2570
+ c.fatal && (c.continue = !1), c.code ?? (c.code = "custom"), c.input ?? (c.input = n.value), c.inst ?? (c.inst = e), n.issues.push(q(c));
2571
+ }
2572
+ };
2573
+ const o = t.transform(n.value, n);
2574
+ return o instanceof Promise ? o.then((i) => (n.value = i, n)) : (n.value = o, n);
2575
+ };
2576
+ });
2577
+ function cc(e) {
2578
+ return new ic({
2579
+ type: "transform",
2580
+ transform: e
2581
+ });
2582
+ }
2583
+ const St = /* @__PURE__ */ s("ZodOptional", (e, t) => {
2584
+ io.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType;
2585
+ });
2586
+ function ct(e) {
2587
+ return new St({
2588
+ type: "optional",
2589
+ innerType: e
2590
+ });
2591
+ }
2592
+ const sc = /* @__PURE__ */ s("ZodNullable", (e, t) => {
2593
+ co.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType;
2594
+ });
2595
+ function st(e) {
2596
+ return new sc({
2597
+ type: "nullable",
2598
+ innerType: e
2599
+ });
2600
+ }
2601
+ const ac = /* @__PURE__ */ s("ZodDefault", (e, t) => {
2602
+ so.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
2603
+ });
2604
+ function uc(e, t) {
2605
+ return new ac({
2606
+ type: "default",
2607
+ innerType: e,
2608
+ get defaultValue() {
2609
+ return typeof t == "function" ? t() : ht(t);
2610
+ }
2611
+ });
2612
+ }
2613
+ const lc = /* @__PURE__ */ s("ZodPrefault", (e, t) => {
2614
+ ao.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType;
2615
+ });
2616
+ function dc(e, t) {
2617
+ return new lc({
2618
+ type: "prefault",
2619
+ innerType: e,
2620
+ get defaultValue() {
2621
+ return typeof t == "function" ? t() : ht(t);
2622
+ }
2623
+ });
2624
+ }
2625
+ const Ot = /* @__PURE__ */ s("ZodNonOptional", (e, t) => {
2626
+ uo.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType;
2627
+ });
2628
+ function fc(e, t) {
2629
+ return new Ot({
2630
+ type: "nonoptional",
2631
+ innerType: e,
2632
+ ...h(t)
2633
+ });
2634
+ }
2635
+ const hc = /* @__PURE__ */ s("ZodCatch", (e, t) => {
2636
+ lo.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
2637
+ });
2638
+ function pc(e, t) {
2639
+ return new hc({
2640
+ type: "catch",
2641
+ innerType: e,
2642
+ catchValue: typeof t == "function" ? t : () => t
2643
+ });
2644
+ }
2645
+ const mc = /* @__PURE__ */ s("ZodPipe", (e, t) => {
2646
+ fo.init(e, t), $.init(e, t), e.in = t.in, e.out = t.out;
2647
+ });
2648
+ function at(e, t) {
2649
+ return new mc({
2650
+ type: "pipe",
2651
+ in: e,
2652
+ out: t
2653
+ // ...util.normalizeParams(params),
2654
+ });
2655
+ }
2656
+ const _c = /* @__PURE__ */ s("ZodReadonly", (e, t) => {
2657
+ ho.init(e, t), $.init(e, t), e.unwrap = () => e._zod.def.innerType;
2658
+ });
2659
+ function gc(e) {
2660
+ return new _c({
2661
+ type: "readonly",
2662
+ innerType: e
2663
+ });
2664
+ }
2665
+ const vc = /* @__PURE__ */ s("ZodCustom", (e, t) => {
2666
+ po.init(e, t), $.init(e, t);
2667
+ });
2668
+ function bc(e, t = {}) {
2669
+ return ii(vc, e, t);
2670
+ }
2671
+ function wc(e) {
2672
+ return ci(e);
2673
+ }
2674
+ const kc = we({
2675
+ title: ne().min(1, "Title is required").max(200, "Title too long"),
2676
+ content: ne().min(1, "Content is required"),
2677
+ format: Ie(["html", "markdown"]).default("html"),
2678
+ metadata: we({
2679
+ createdAt: ne().datetime(),
2680
+ updatedAt: ne().datetime(),
2681
+ wordCount: nt().min(0),
2682
+ characterCount: nt().min(0)
2683
+ }).optional()
2684
+ });
2685
+ we({
2686
+ includeStyles: ot().default(!0),
2687
+ includeMeta: ot().default(!0),
2688
+ format: Ie(["html", "txt"]).default("html")
2689
+ });
2690
+ const zc = (e = "") => {
2691
+ const [t, n] = ze({
2692
+ content: e,
2693
+ title: "Untitled Document",
2694
+ wordCount: e.trim() ? e.trim().split(/\s+/).length : 0,
2695
+ characterCount: e.length,
2696
+ hasUnsavedChanges: !1
2697
+ }), r = Mt(null);
2698
+ ut(() => {
2699
+ r.current && e !== t.content && (r.current.innerHTML = e, n((l) => ({
2700
+ ...l,
2701
+ content: e,
2702
+ wordCount: e.trim() ? e.trim().split(/\s+/).length : 0,
2703
+ characterCount: e.length
2704
+ })));
2705
+ }, [e]);
2706
+ const o = V((l) => {
2707
+ const g = l.trim() ? l.trim().split(/\s+/).length : 0, p = l.length;
2708
+ n((v) => ({
2709
+ ...v,
2710
+ content: l,
2711
+ wordCount: g,
2712
+ characterCount: p,
2713
+ hasUnsavedChanges: !0
2714
+ }));
2715
+ }, []), i = V((l) => {
2716
+ n((g) => ({
2717
+ ...g,
2718
+ title: l,
2719
+ hasUnsavedChanges: !0
2720
+ }));
2721
+ }, []), c = V((l, g) => {
2722
+ document.execCommand(l, !1, g), r.current?.focus();
2723
+ }, []), a = V(() => {
2724
+ try {
2725
+ return { success: !0, data: kc.parse({
2726
+ title: t.title,
2727
+ content: t.content,
2728
+ metadata: {
2729
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2730
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2731
+ wordCount: t.wordCount,
2732
+ characterCount: t.characterCount
2733
+ }
2734
+ }) };
2735
+ } catch (l) {
2736
+ return { success: !1, error: l instanceof Error ? l.message : "Validation failed" };
2737
+ }
2738
+ }, [t]), f = V(
2739
+ (l = { includeStyles: !0, includeMeta: !0 }) => {
2740
+ const g = a();
2741
+ if (!g.success)
2742
+ throw new Error(g.error);
2743
+ const { data: p } = g;
2744
+ let v = `<!DOCTYPE html>
2745
+ <html>
2746
+ <head>
2747
+ <meta charset="UTF-8">
2748
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
2749
+ <title>${p?.title}</title>`;
2750
+ return l.includeStyles && (v += `
2751
+ <style>
2752
+ body {
2753
+ font-family: Arial, sans-serif;
2754
+ line-height: 1.6;
2755
+ margin: 40px;
2756
+ max-width: 800px;
2757
+ }
2758
+ .editor-content {
2759
+ border: 1px solid #ddd;
2760
+ padding: 20px;
2761
+ border-radius: 8px;
2762
+ background: white;
2763
+ }
2764
+ </style>`), v += `
2765
+ </head>
2766
+ <body>`, l.includeMeta && (v += `
2767
+ <div class="document-meta">
2768
+ <h1>${p?.title}</h1>
2769
+ <p><small>Created: ${new Date(p?.metadata.createdAt ?? "").toLocaleString()} |
2770
+ Words: ${p?.metadata.wordCount} |
2771
+ Characters: ${p?.metadata.characterCount}</small></p>
2772
+ <hr>
2773
+ </div>`), v += `
2774
+ <div class="editor-content">
2775
+ ${p?.content}
2776
+ </div>
2777
+ </body>
2778
+ </html>`, v;
2779
+ },
2780
+ [a]
2781
+ ), d = V(() => {
2782
+ n({
2783
+ content: "",
2784
+ title: "Untitled Document",
2785
+ wordCount: 0,
2786
+ characterCount: 0,
2787
+ hasUnsavedChanges: !1
2788
+ }), r.current && (r.current.innerHTML = "");
2789
+ }, []);
2790
+ return {
2791
+ editorState: t,
2792
+ editorRef: r,
2793
+ updateContent: o,
2794
+ updateTitle: i,
2795
+ executeCommand: c,
2796
+ getValidationResult: a,
2797
+ exportToHTML: f,
2798
+ clearEditor: d
2799
+ };
2800
+ }, Zc = ({
2801
+ initialContent: e = "",
2802
+ onSave: t,
2803
+ onExport: n
2804
+ }) => {
2805
+ const {
2806
+ editorState: r,
2807
+ editorRef: o,
2808
+ updateContent: i,
2809
+ updateTitle: c,
2810
+ executeCommand: a,
2811
+ getValidationResult: f,
2812
+ exportToHTML: d,
2813
+ clearEditor: l
2814
+ } = zc(e), [g, p] = ze(!1), v = () => {
2815
+ if (f().success) {
2816
+ const P = d();
2817
+ t?.(r.content, P);
2818
+ } else
2819
+ p(!0), setTimeout(() => p(!1), 3e3);
2820
+ }, x = () => {
2821
+ try {
2822
+ const T = d();
2823
+ n?.(T);
2824
+ const P = new Blob([T], { type: "text/html" }), L = URL.createObjectURL(P), A = document.createElement("a");
2825
+ A.href = L, A.download = `${r.title.replace(/\s+/g, "_")}.html`, document.body.appendChild(A), A.click(), document.body.removeChild(A), URL.revokeObjectURL(L);
2826
+ } catch (T) {
2827
+ alert("Export failed: " + (T instanceof Error ? T.message : "Unknown error"));
2828
+ }
2829
+ }, R = () => {
2830
+ confirm("Are you sure you want to clear the editor? All unsaved changes will be lost.") && l();
2831
+ };
2832
+ return /* @__PURE__ */ m.jsxs("div", { className: "w-full max-w-6xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden", children: [
2833
+ /* @__PURE__ */ m.jsxs("div", { className: "p-6 border-b border-gray-200 bg-gray-50", children: [
2834
+ /* @__PURE__ */ m.jsx(
2835
+ "input",
2836
+ {
2837
+ type: "text",
2838
+ className: "w-full bg-transparent text-2xl font-bold text-gray-800 outline-none placeholder-gray-400",
2839
+ value: r.title,
2840
+ onChange: (T) => c(T.target.value),
2841
+ placeholder: "Document Title"
2842
+ }
2843
+ ),
2844
+ g && /* @__PURE__ */ m.jsx("div", { className: "text-red-600 text-sm mt-2 animate-fadeIn", children: "Please add content before saving" })
2845
+ ] }),
2846
+ /* @__PURE__ */ m.jsx(
2847
+ un,
2848
+ {
2849
+ onCommand: a,
2850
+ onSave: v,
2851
+ onExport: x,
2852
+ onClear: R,
2853
+ hasUnsavedChanges: r.hasUnsavedChanges
2854
+ }
2855
+ ),
2856
+ /* @__PURE__ */ m.jsx(
2857
+ "div",
2858
+ {
2859
+ ref: o,
2860
+ className: "editor-content min-h-[500px] p-8 border-none outline-none resize-none text-gray-700 leading-relaxed prose max-w-none",
2861
+ contentEditable: !0,
2862
+ onInput: (T) => i(T.currentTarget.innerHTML)
2863
+ }
2864
+ ),
2865
+ /* @__PURE__ */ m.jsx(
2866
+ ln,
2867
+ {
2868
+ wordCount: r.wordCount,
2869
+ characterCount: r.characterCount,
2870
+ hasUnsavedChanges: r.hasUnsavedChanges
2871
+ }
2872
+ )
2873
+ ] });
2874
+ };
2875
+ export {
2876
+ Zc as TextEditor,
2877
+ zc as useTextEditor
2878
+ };