@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
1,574 lines • 58.4 kB
JavaScript
import p, { useCallback as Xr } from "react";
import { p as et } from "./query-BszLGcZK.mjs";
import { jsx as oe, jsxs as ze } from "react/jsx-runtime";
import { E as rt } from "./Error-BTeTwGKx.mjs";
import { a as tt, L as st } from "./Label-DwiiPc06.mjs";
import { I as nt } from "./InfoButton-B-iIr4px.mjs";
import { T as it } from "./Tooltip-Rs8aEg_1.mjs";
import { e as ot, b as at } from "./misc-CHmrAmhc.mjs";
import { E as ut } from "./ErrorState-CVgGRS0u.mjs";
import { S as ct } from "./StateContainer-D7lYvK4y.mjs";
import { c as lt } from "./index-2NvaPZWc.mjs";
import { i as ft } from "./isString-CmHDXlmA.mjs";
var _e = (e) => e.type === "checkbox", ae = (e) => e instanceof Date, H = (e) => e == null;
const xr = (e) => typeof e == "object";
var R = (e) => !H(e) && !Array.isArray(e) && xr(e) && !ae(e), Sr = (e) => R(e) && e.target ? _e(e.target) ? e.target.checked : e.target.value : e, dt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Or = (e, t) => e.has(dt(t)), yt = (e) => {
const t = e.constructor && e.constructor.prototype;
return R(t) && t.hasOwnProperty("isPrototypeOf");
}, Me = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
function T(e) {
if (e instanceof Date)
return new Date(e);
const t = typeof FileList < "u" && e instanceof FileList;
if (Me && (e instanceof Blob || t))
return e;
const r = Array.isArray(e);
if (!r && !(R(e) && yt(e)))
return e;
const s = r ? [] : Object.create(Object.getPrototypeOf(e));
for (const o in e)
Object.prototype.hasOwnProperty.call(e, o) && (s[o] = T(e[o]));
return s;
}
var ke = (e) => /^\w*$/.test(e), C = (e) => e === void 0, Ne = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Be = (e) => Ne(e.replace(/["|']|\]/g, "").split(/\.|\[/)), y = (e, t, r) => {
if (!t || !R(e))
return r;
const s = (ke(t) ? [t] : Be(t)).reduce((o, i) => H(o) ? o : o[i], e);
return C(s) || s === e ? C(e[t]) ? r : e[t] : s;
}, K = (e) => typeof e == "boolean", W = (e) => typeof e == "function", O = (e, t, r) => {
let s = -1;
const o = ke(t) ? [t] : Be(t), i = o.length, a = i - 1;
for (; ++s < i; ) {
const c = o[s];
let g = r;
if (s !== a) {
const m = e[c];
g = R(m) || Array.isArray(m) ? m : isNaN(+o[s + 1]) ? {} : [];
}
if (c === "__proto__" || c === "constructor" || c === "prototype")
return;
e[c] = g, e = e[c];
}
};
const we = {
BLUR: "blur",
FOCUS_OUT: "focusout",
CHANGE: "change"
}, Q = {
onBlur: "onBlur",
onChange: "onChange",
onSubmit: "onSubmit",
onTouched: "onTouched",
all: "all"
}, se = {
max: "max",
min: "min",
maxLength: "maxLength",
minLength: "minLength",
pattern: "pattern",
required: "required",
validate: "validate"
}, Dr = p.createContext(null);
Dr.displayName = "HookFormControlContext";
const $e = () => p.useContext(Dr);
var Cr = (e, t, r, s = !0) => {
const o = {
defaultValues: t._defaultValues
};
for (const i in e)
Object.defineProperty(o, i, {
get: () => {
const a = i;
return t._proxyFormState[a] !== Q.all && (t._proxyFormState[a] = !s || Q.all), r && (r[a] = !0), e[a];
}
});
return o;
};
const We = typeof window < "u" ? p.useLayoutEffect : p.useEffect;
function ht(e) {
const t = $e(), { control: r = t, disabled: s, name: o, exact: i } = e || {}, [a, c] = p.useState(r._formState), g = p.useRef({
isDirty: !1,
isLoading: !1,
dirtyFields: !1,
touchedFields: !1,
validatingFields: !1,
isValidating: !1,
isValid: !1,
errors: !1
});
return We(() => r._subscribe({
name: o,
formState: g.current,
exact: i,
callback: (m) => {
!s && c({
...r._formState,
...m
});
}
}), [o, s, i]), p.useEffect(() => {
g.current.isValid && r._setValid(!0);
}, [r]), p.useMemo(() => Cr(a, r, g.current, !1), [a, r]);
}
var G = (e) => typeof e == "string", Re = (e, t, r, s, o) => G(e) ? (s && t.watch.add(e), y(r, e, o)) : Array.isArray(e) ? e.map((i) => (s && t.watch.add(i), y(r, i))) : (s && (t.watchAll = !0), r), Ue = (e) => H(e) || !xr(e);
function X(e, t, r = /* @__PURE__ */ new WeakSet()) {
if (Ue(e) || Ue(t))
return Object.is(e, t);
if (ae(e) && ae(t))
return Object.is(e.getTime(), t.getTime());
const s = Object.keys(e), o = Object.keys(t);
if (s.length !== o.length)
return !1;
if (r.has(e) || r.has(t))
return !0;
r.add(e), r.add(t);
for (const i of s) {
const a = e[i];
if (!o.includes(i))
return !1;
if (i !== "ref") {
const c = t[i];
if (ae(a) && ae(c) || R(a) && R(c) || Array.isArray(a) && Array.isArray(c) ? !X(a, c, r) : !Object.is(a, c))
return !1;
}
}
return !0;
}
function gt(e) {
const t = $e(), { control: r = t, name: s, defaultValue: o, disabled: i, exact: a, compute: c } = e || {}, g = p.useRef(o), m = p.useRef(c), D = p.useRef(void 0), v = p.useRef(r), V = p.useRef(s);
m.current = c;
const [_, P] = p.useState(() => {
const E = r._getWatch(s, g.current);
return m.current ? m.current(E) : E;
}), j = p.useCallback((E) => {
const k = Re(s, r._names, E || r._formValues, !1, g.current);
return m.current ? m.current(k) : k;
}, [r._formValues, r._names, s]), I = p.useCallback((E) => {
if (!i) {
const k = Re(s, r._names, E || r._formValues, !1, g.current);
if (m.current) {
const q = m.current(k);
X(q, D.current) || (P(q), D.current = q);
} else
P(k);
}
}, [r._formValues, r._names, i, s]);
We(() => ((v.current !== r || !X(V.current, s)) && (v.current = r, V.current = s, I()), r._subscribe({
name: s,
formState: {
values: !0
},
exact: a,
callback: (E) => {
I(E.values);
}
})), [r, a, s, I]), p.useEffect(() => r._removeUnmounted());
const U = v.current !== r, w = V.current, N = p.useMemo(() => {
if (i)
return null;
const E = !U && !X(w, s);
return U || E ? j() : null;
}, [i, U, s, w, j]);
return N !== null ? N : _;
}
function mt(e) {
const t = $e(), { name: r, disabled: s, control: o = t, shouldUnregister: i, defaultValue: a, exact: c = !0 } = e, g = Or(o._names.array, r), m = p.useMemo(() => y(o._formValues, r, y(o._defaultValues, r, a)), [o, r, a]), D = gt({
control: o,
name: r,
defaultValue: m,
exact: c
}), v = ht({
control: o,
name: r,
exact: c
}), V = p.useRef(e), _ = p.useRef(void 0), P = p.useRef(o.register(r, {
...e.rules,
value: D,
...K(e.disabled) ? { disabled: e.disabled } : {}
}));
V.current = e;
const j = p.useMemo(() => Object.defineProperties({}, {
invalid: {
enumerable: !0,
get: () => !!y(v.errors, r)
},
isDirty: {
enumerable: !0,
get: () => !!y(v.dirtyFields, r)
},
isTouched: {
enumerable: !0,
get: () => !!y(v.touchedFields, r)
},
isValidating: {
enumerable: !0,
get: () => !!y(v.validatingFields, r)
},
error: {
enumerable: !0,
get: () => y(v.errors, r)
}
}), [v, r]), I = p.useCallback((E) => P.current.onChange({
target: {
value: Sr(E),
name: r
},
type: we.CHANGE
}), [r]), U = p.useCallback(() => P.current.onBlur({
target: {
value: y(o._formValues, r),
name: r
},
type: we.BLUR
}), [r, o._formValues]), w = p.useCallback((E) => {
const k = y(o._fields, r);
k && k._f && E && (k._f.ref = {
focus: () => W(E.focus) && E.focus(),
select: () => W(E.select) && E.select(),
setCustomValidity: (q) => W(E.setCustomValidity) && E.setCustomValidity(q),
reportValidity: () => W(E.reportValidity) && E.reportValidity()
});
}, [o._fields, r]), N = p.useMemo(() => ({
name: r,
value: D,
...K(s) || v.disabled ? { disabled: v.disabled || s } : {},
onChange: I,
onBlur: U,
ref: w
}), [r, s, v.disabled, I, U, w, D]);
return p.useEffect(() => {
const E = o._options.shouldUnregister || i, k = _.current;
k && k !== r && !g && o.unregister(k), o.register(r, {
...V.current.rules,
...K(V.current.disabled) ? { disabled: V.current.disabled } : {}
});
const q = (re, te) => {
const ee = y(o._fields, re);
ee && ee._f && (ee._f.mount = te);
};
if (q(r, !0), E) {
const re = T(y(o._options.defaultValues, r, V.current.defaultValue));
O(o._defaultValues, r, re), C(y(o._formValues, r)) && O(o._formValues, r, re);
}
return !g && o.register(r), _.current = r, () => {
(g ? E && !o._state.action : E) ? o.unregister(r) : q(r, !1);
};
}, [r, o, g, i]), p.useEffect(() => {
o._setDisabledField({
disabled: s,
name: r
});
}, [s, r, o]), p.useMemo(() => ({
field: N,
formState: v,
fieldState: j
}), [N, v, j]);
}
const bt = (e) => e.render(mt(e)), vt = p.createContext(null);
vt.displayName = "HookFormContext";
var qe = (e, t, r, s, o) => t ? {
...r[e],
types: {
...r[e] && r[e].types ? r[e].types : {},
[s]: o || !0
}
} : {}, be = (e) => Array.isArray(e) ? e : [e], lr = () => {
let e = [];
return {
get observers() {
return e;
},
next: (o) => {
for (const i of e)
i.next && i.next(o);
},
subscribe: (o) => (e.push(o), {
unsubscribe: () => {
e = e.filter((i) => i !== o);
}
}),
unsubscribe: () => {
e = [];
}
};
};
function Pr(e, t) {
const r = {};
for (const s in e)
if (e.hasOwnProperty(s)) {
const o = e[s], i = t[s];
if (o && R(o) && i) {
const a = Pr(o, i);
R(a) && (r[s] = a);
} else e[s] && (r[s] = i);
}
return r;
}
var $ = (e) => R(e) && !Object.keys(e).length, He = (e) => e.type === "file", Ee = (e) => {
if (!Me)
return !1;
const t = e ? e.ownerDocument : 0;
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
}, jr = (e) => e.type === "select-multiple", Ze = (e) => e.type === "radio", _t = (e) => Ze(e) || _e(e), Te = (e) => Ee(e) && e.isConnected;
function pt(e, t) {
const r = t.slice(0, -1).length;
let s = 0;
for (; s < r; )
e = C(e) ? s++ : e[t[s++]];
return e;
}
function Vt(e) {
for (const t in e)
if (e.hasOwnProperty(t) && !C(e[t]))
return !1;
return !0;
}
function z(e, t) {
const r = Array.isArray(t) ? t : ke(t) ? [t] : Be(t), s = r.length === 1 ? e : pt(e, r), o = r.length - 1, i = r[o];
return s && delete s[i], o !== 0 && (R(s) && $(s) || Array.isArray(s) && Vt(s)) && z(e, r.slice(0, -1)), e;
}
var wt = (e) => {
for (const t in e)
if (W(e[t]))
return !0;
return !1;
};
function Tr(e) {
return Array.isArray(e) || R(e) && !wt(e);
}
function Le(e, t = {}) {
for (const r in e) {
const s = e[r];
Tr(s) ? (t[r] = Array.isArray(s) ? [] : {}, Le(s, t[r])) : C(s) || (t[r] = !0);
}
return t;
}
function de(e, t, r) {
r || (r = Le(t));
for (const s in e) {
const o = e[s];
if (Tr(o))
C(t) || Ue(r[s]) ? r[s] = Le(o, Array.isArray(o) ? [] : {}) : de(o, H(t) ? {} : t[s], r[s]);
else {
const i = t[s];
r[s] = !X(o, i);
}
}
return r;
}
const fr = {
value: !1,
isValid: !1
}, dr = { value: !0, isValid: !0 };
var zr = (e) => {
if (Array.isArray(e)) {
if (e.length > 1) {
const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
return { value: t, isValid: !!t.length };
}
return e[0].checked && !e[0].disabled ? (
// @ts-expect-error expected to work in the browser
e[0].attributes && !C(e[0].attributes.value) ? C(e[0].value) || e[0].value === "" ? dr : { value: e[0].value, isValid: !0 } : dr
) : fr;
}
return fr;
}, Rr = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => C(e) ? e : t ? e === "" ? NaN : e && +e : r && G(e) ? new Date(e) : s ? s(e) : e;
const yr = {
isValid: !1,
value: null
};
var Ur = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
isValid: !0,
value: r.value
} : t, yr) : yr;
function hr(e) {
const t = e.ref;
return He(t) ? t.files : Ze(t) ? Ur(e.refs).value : jr(t) ? [...t.selectedOptions].map(({ value: r }) => r) : _e(t) ? zr(e.refs).value : Rr(C(t.value) ? e.ref.value : t.value, e);
}
var Et = (e, t, r, s) => {
const o = {};
for (const i of e) {
const a = y(t, i);
a && O(o, i, a._f);
}
return {
criteriaMode: r,
names: [...e],
fields: o,
shouldUseNativeValidation: s
};
}, Fe = (e) => e instanceof RegExp, me = (e) => C(e) ? e : Fe(e) ? e.source : R(e) ? Fe(e.value) ? e.value.source : e.value : e, gr = (e) => ({
isOnSubmit: !e || e === Q.onSubmit,
isOnBlur: e === Q.onBlur,
isOnChange: e === Q.onChange,
isOnAll: e === Q.all,
isOnTouch: e === Q.onTouched
});
const mr = "AsyncFunction";
var Ft = (e) => !!e && !!e.validate && !!(W(e.validate) && e.validate.constructor.name === mr || R(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === mr)), kt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), br = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
const ve = (e, t, r, s) => {
for (const o of r || Object.keys(e)) {
const i = y(e, o);
if (i) {
const { _f: a, ...c } = i;
if (a) {
if (a.refs && a.refs[0] && t(a.refs[0], o) && !s)
return !0;
if (a.ref && t(a.ref, a.name) && !s)
return !0;
if (ve(c, t))
break;
} else if (R(c) && ve(c, t))
break;
}
}
};
function vr(e, t, r) {
const s = y(e, r);
if (s || ke(r))
return {
error: s,
name: r
};
const o = r.split(".");
for (; o.length; ) {
const i = o.join("."), a = y(t, i), c = y(e, i);
if (a && !Array.isArray(a) && r !== i)
return { name: r };
if (c && c.type)
return {
name: i,
error: c
};
if (c && c.root && c.root.type)
return {
name: `${i}.root`,
error: c.root
};
o.pop();
}
return {
name: r
};
}
var At = (e, t, r, s) => {
r(e);
const { name: o, ...i } = e;
return $(i) || Object.keys(i).length >= Object.keys(t).length || Object.keys(i).find((a) => t[a] === (!s || Q.all));
}, xt = (e, t, r) => !e || !t || e === t || be(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), St = (e, t, r, s, o) => o.isOnAll ? !1 : !r && o.isOnTouch ? !(t || e) : (r ? s.isOnBlur : o.isOnBlur) ? !e : (r ? s.isOnChange : o.isOnChange) ? e : !0, Ot = (e, t) => !Ne(y(e, t)).length && z(e, t), Dt = (e, t, r) => {
const s = be(y(e, r));
return O(s, "root", t[r]), O(e, r, s), e;
};
function _r(e, t, r = "validate") {
if (G(e) || Array.isArray(e) && e.every(G) || K(e) && !e)
return {
type: r,
message: G(e) ? e : "",
ref: t
};
}
var fe = (e) => R(e) && !Fe(e) ? e : {
value: e,
message: ""
}, pr = async (e, t, r, s, o, i) => {
const { ref: a, refs: c, required: g, maxLength: m, minLength: D, min: v, max: V, pattern: _, validate: P, name: j, valueAsNumber: I, mount: U } = e._f, w = y(r, j);
if (!U || t.has(j))
return {};
const N = c ? c[0] : a, E = (F) => {
o && N.reportValidity && (N.setCustomValidity(K(F) ? "" : F || ""), N.reportValidity());
}, k = {}, q = Ze(a), re = _e(a), te = q || re, ee = (I || He(a)) && C(a.value) && C(w) || Ee(a) && a.value === "" || w === "" || Array.isArray(w) && !w.length, J = qe.bind(null, j, s, k), pe = (F, A, L, M = se.maxLength, Y = se.minLength) => {
const Z = F ? A : L;
k[j] = {
type: F ? M : Y,
message: Z,
ref: a,
...J(F ? M : Y, Z)
};
};
if (i ? !Array.isArray(w) || !w.length : g && (!te && (ee || H(w)) || K(w) && !w || re && !zr(c).isValid || q && !Ur(c).isValid)) {
const { value: F, message: A } = G(g) ? { value: !!g, message: g } : fe(g);
if (F && (k[j] = {
type: se.required,
message: A,
ref: N,
...J(se.required, A)
}, !s))
return E(A), k;
}
if (!ee && (!H(v) || !H(V))) {
let F, A;
const L = fe(V), M = fe(v);
if (!H(w) && !isNaN(w)) {
const Y = a.valueAsNumber || w && +w;
H(L.value) || (F = Y > L.value), H(M.value) || (A = Y < M.value);
} else {
const Y = a.valueAsDate || new Date(w), Z = (ge) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ge), ye = a.type == "time", he = a.type == "week";
G(L.value) && w && (F = ye ? Z(w) > Z(L.value) : he ? w > L.value : Y > new Date(L.value)), G(M.value) && w && (A = ye ? Z(w) < Z(M.value) : he ? w < M.value : Y < new Date(M.value));
}
if ((F || A) && (pe(!!F, L.message, M.message, se.max, se.min), !s))
return E(k[j].message), k;
}
if ((m || D) && !ee && (G(w) || i && Array.isArray(w))) {
const F = fe(m), A = fe(D), L = !H(F.value) && w.length > +F.value, M = !H(A.value) && w.length < +A.value;
if ((L || M) && (pe(L, F.message, A.message), !s))
return E(k[j].message), k;
}
if (_ && !ee && G(w)) {
const { value: F, message: A } = fe(_);
if (Fe(F) && !w.match(F) && (k[j] = {
type: se.pattern,
message: A,
ref: a,
...J(se.pattern, A)
}, !s))
return E(A), k;
}
if (P) {
if (W(P)) {
const F = await P(w, r), A = _r(F, N);
if (A && (k[j] = {
...A,
...J(se.validate, A.message)
}, !s))
return E(A.message), k;
} else if (R(P)) {
let F = {};
for (const A in P) {
if (!$(F) && !s)
break;
const L = _r(await P[A](w, r), N, A);
L && (F = {
...L,
...J(A, L.message)
}, E(L.message), s && (k[j] = F));
}
if (!$(F) && (k[j] = {
ref: N,
...F
}, !s))
return k;
}
}
return E(!0), k;
};
const Ct = {
mode: Q.onSubmit,
reValidateMode: Q.onChange,
shouldFocusError: !0
};
function Pt(e = {}) {
let t = {
...Ct,
...e
}, r = {
submitCount: 0,
isDirty: !1,
isReady: !1,
isLoading: W(t.defaultValues),
isValidating: !1,
isSubmitted: !1,
isSubmitting: !1,
isSubmitSuccessful: !1,
isValid: !1,
touchedFields: {},
dirtyFields: {},
validatingFields: {},
errors: t.errors || {},
disabled: t.disabled || !1
}, s = {}, o = R(t.defaultValues) || R(t.values) ? T(t.defaultValues || t.values) || {} : {}, i = t.shouldUnregister ? {} : T(o), a = {
action: !1,
mount: !1,
watch: !1,
keepIsValid: !1
}, c = {
mount: /* @__PURE__ */ new Set(),
disabled: /* @__PURE__ */ new Set(),
unMount: /* @__PURE__ */ new Set(),
array: /* @__PURE__ */ new Set(),
watch: /* @__PURE__ */ new Set()
}, g, m = 0;
const D = {
isDirty: !1,
dirtyFields: !1,
validatingFields: !1,
touchedFields: !1,
isValidating: !1,
isValid: !1,
errors: !1
}, v = {
...D
};
let V = {
...v
};
const _ = {
array: lr(),
state: lr()
}, P = t.criteriaMode === Q.all, j = (n) => (u) => {
clearTimeout(m), m = setTimeout(n, u);
}, I = async (n) => {
if (!a.keepIsValid && !t.disabled && (v.isValid || V.isValid || n)) {
let u;
t.resolver ? (u = $((await te()).errors), U()) : u = await J(s, !0), u !== r.isValid && _.state.next({
isValid: u
});
}
}, U = (n, u) => {
!t.disabled && (v.isValidating || v.validatingFields || V.isValidating || V.validatingFields) && ((n || Array.from(c.mount)).forEach((l) => {
l && (u ? O(r.validatingFields, l, u) : z(r.validatingFields, l));
}), _.state.next({
validatingFields: r.validatingFields,
isValidating: !$(r.validatingFields)
}));
}, w = (n, u = [], l, h, d = !0, f = !0) => {
if (h && l && !t.disabled) {
if (a.action = !0, f && Array.isArray(y(s, n))) {
const b = l(y(s, n), h.argA, h.argB);
d && O(s, n, b);
}
if (f && Array.isArray(y(r.errors, n))) {
const b = l(y(r.errors, n), h.argA, h.argB);
d && O(r.errors, n, b), Ot(r.errors, n);
}
if ((v.touchedFields || V.touchedFields) && f && Array.isArray(y(r.touchedFields, n))) {
const b = l(y(r.touchedFields, n), h.argA, h.argB);
d && O(r.touchedFields, n, b);
}
(v.dirtyFields || V.dirtyFields) && (r.dirtyFields = de(o, i)), _.state.next({
name: n,
isDirty: F(n, u),
dirtyFields: r.dirtyFields,
errors: r.errors,
isValid: r.isValid
});
} else
O(i, n, u);
}, N = (n, u) => {
O(r.errors, n, u), _.state.next({
errors: r.errors
});
}, E = (n) => {
r.errors = n, _.state.next({
errors: r.errors,
isValid: !1
});
}, k = (n, u, l, h) => {
const d = y(s, n);
if (d) {
const f = y(i, n, C(l) ? y(o, n) : l);
C(f) || h && h.defaultChecked || u ? O(i, n, u ? f : hr(d._f)) : M(n, f), a.mount && !a.action && I();
}
}, q = (n, u, l, h, d) => {
let f = !1, b = !1;
const x = {
name: n
};
if (!t.disabled) {
if (!l || h) {
(v.isDirty || V.isDirty) && (b = r.isDirty, r.isDirty = x.isDirty = F(), f = b !== x.isDirty);
const S = X(y(o, n), u);
b = !!y(r.dirtyFields, n), S ? z(r.dirtyFields, n) : O(r.dirtyFields, n, !0), x.dirtyFields = r.dirtyFields, f = f || (v.dirtyFields || V.dirtyFields) && b !== !S;
}
if (l) {
const S = y(r.touchedFields, n);
S || (O(r.touchedFields, n, l), x.touchedFields = r.touchedFields, f = f || (v.touchedFields || V.touchedFields) && S !== l);
}
f && d && _.state.next(x);
}
return f ? x : {};
}, re = (n, u, l, h) => {
const d = y(r.errors, n), f = (v.isValid || V.isValid) && K(u) && r.isValid !== u;
if (t.delayError && l ? (g = j(() => N(n, l)), g(t.delayError)) : (clearTimeout(m), g = null, l ? O(r.errors, n, l) : z(r.errors, n)), (l ? !X(d, l) : d) || !$(h) || f) {
const b = {
...h,
...f && K(u) ? { isValid: u } : {},
errors: r.errors,
name: n
};
r = {
...r,
...b
}, _.state.next(b);
}
}, te = async (n) => (U(n, !0), await t.resolver(i, t.context, Et(n || c.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), ee = async (n) => {
const { errors: u } = await te(n);
if (U(n), n)
for (const l of n) {
const h = y(u, l);
h ? O(r.errors, l, h) : z(r.errors, l);
}
else
r.errors = u;
return u;
}, J = async (n, u, l = {
valid: !0
}) => {
for (const h in n) {
const d = n[h];
if (d) {
const { _f: f, ...b } = d;
if (f) {
const x = c.array.has(f.name), S = d._f && Ft(d._f);
S && v.validatingFields && U([f.name], !0);
const B = await pr(d, c.disabled, i, P, t.shouldUseNativeValidation && !u, x);
if (S && v.validatingFields && U([f.name]), B[f.name] && (l.valid = !1, u || e.shouldUseNativeValidation))
break;
!u && (y(B, f.name) ? x ? Dt(r.errors, B, f.name) : O(r.errors, f.name, B[f.name]) : z(r.errors, f.name));
}
!$(b) && await J(b, u, l);
}
}
return l.valid;
}, pe = () => {
for (const n of c.unMount) {
const u = y(s, n);
u && (u._f.refs ? u._f.refs.every((l) => !Te(l)) : !Te(u._f.ref)) && Oe(n);
}
c.unMount = /* @__PURE__ */ new Set();
}, F = (n, u) => !t.disabled && (n && u && O(i, n, u), !X(Xe(), o)), A = (n, u, l) => Re(n, c, {
...a.mount ? i : C(u) ? o : G(n) ? { [n]: u } : u
}, l, u), L = (n) => Ne(y(a.mount ? i : o, n, t.shouldUnregister ? y(o, n, []) : [])), M = (n, u, l = {}) => {
const h = y(s, n);
let d = u;
if (h) {
const f = h._f;
f && (!f.disabled && O(i, n, Rr(u, f)), d = Ee(f.ref) && H(u) ? "" : u, jr(f.ref) ? [...f.ref.options].forEach((b) => b.selected = d.includes(b.value)) : f.refs ? _e(f.ref) ? f.refs.forEach((b) => {
(!b.defaultChecked || !b.disabled) && (Array.isArray(d) ? b.checked = !!d.find((x) => x === b.value) : b.checked = d === b.value || !!d);
}) : f.refs.forEach((b) => b.checked = b.value === d) : He(f.ref) ? f.ref.value = "" : (f.ref.value = d, f.ref.type || _.state.next({
name: n,
values: T(i)
})));
}
(l.shouldDirty || l.shouldTouch) && q(n, d, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && ge(n);
}, Y = (n, u, l) => {
for (const h in u) {
if (!u.hasOwnProperty(h))
return;
const d = u[h], f = n + "." + h, b = y(s, f);
(c.array.has(n) || R(d) || b && !b._f) && !ae(d) ? Y(f, d, l) : M(f, d, l);
}
}, Z = (n, u, l = {}) => {
const h = y(s, n), d = c.array.has(n), f = T(u);
O(i, n, f), d ? (_.array.next({
name: n,
values: T(i)
}), (v.isDirty || v.dirtyFields || V.isDirty || V.dirtyFields) && l.shouldDirty && _.state.next({
name: n,
dirtyFields: de(o, i),
isDirty: F(n, f)
})) : h && !h._f && !H(f) ? Y(n, f, l) : M(n, f, l), br(n, c) ? _.state.next({
...r,
name: n,
values: T(i)
}) : _.state.next({
name: a.mount ? n : void 0,
values: T(i)
});
}, ye = async (n) => {
a.mount = !0;
const u = n.target;
let l = u.name, h = !0;
const d = y(s, l), f = (S) => {
h = Number.isNaN(S) || ae(S) && isNaN(S.getTime()) || X(S, y(i, l, S));
}, b = gr(t.mode), x = gr(t.reValidateMode);
if (d) {
let S, B;
const ie = u.type ? hr(d._f) : Sr(n), ne = n.type === we.BLUR || n.type === we.FOCUS_OUT, Jr = !kt(d._f) && !t.resolver && !y(r.errors, l) && !d._f.deps || St(ne, y(r.touchedFields, l), r.isSubmitted, x, b), Pe = br(l, c, ne);
O(i, l, ie), ne ? (!u || !u.readOnly) && (d._f.onBlur && d._f.onBlur(n), g && g(0)) : d._f.onChange && d._f.onChange(n);
const je = q(l, ie, ne), Yr = !$(je) || Pe;
if (!ne && _.state.next({
name: l,
type: n.type,
values: T(i)
}), Jr)
return (v.isValid || V.isValid) && (t.mode === "onBlur" ? ne && I() : ne || I()), Yr && _.state.next({ name: l, ...Pe ? {} : je });
if (!ne && Pe && _.state.next({ ...r }), t.resolver) {
const { errors: ur } = await te([l]);
if (U([l]), f(ie), h) {
const Qr = vr(r.errors, s, l), cr = vr(ur, s, Qr.name || l);
S = cr.error, l = cr.name, B = $(ur);
}
} else
U([l], !0), S = (await pr(d, c.disabled, i, P, t.shouldUseNativeValidation))[l], U([l]), f(ie), h && (S ? B = !1 : (v.isValid || V.isValid) && (B = await J(s, !0)));
h && (d._f.deps && (!Array.isArray(d._f.deps) || d._f.deps.length > 0) && ge(d._f.deps), re(l, B, S, je));
}
}, he = (n, u) => {
if (y(r.errors, u) && n.focus)
return n.focus(), 1;
}, ge = async (n, u = {}) => {
let l, h;
const d = be(n);
if (t.resolver) {
const f = await ee(C(n) ? n : d);
l = $(f), h = n ? !d.some((b) => y(f, b)) : l;
} else n ? (h = (await Promise.all(d.map(async (f) => {
const b = y(s, f);
return await J(b && b._f ? { [f]: b } : b);
}))).every(Boolean), !(!h && !r.isValid) && I()) : h = l = await J(s);
return _.state.next({
...!G(n) || (v.isValid || V.isValid) && l !== r.isValid ? {} : { name: n },
...t.resolver || !n ? { isValid: l } : {},
errors: r.errors
}), u.shouldFocus && !h && ve(s, he, n ? d : c.mount), h;
}, Xe = (n, u) => {
let l = {
...a.mount ? i : o
};
return u && (l = Pr(u.dirtyFields ? r.dirtyFields : r.touchedFields, l)), C(n) ? l : G(n) ? y(l, n) : n.map((h) => y(l, h));
}, er = (n, u) => ({
invalid: !!y((u || r).errors, n),
isDirty: !!y((u || r).dirtyFields, n),
error: y((u || r).errors, n),
isValidating: !!y(r.validatingFields, n),
isTouched: !!y((u || r).touchedFields, n)
}), $r = (n) => {
const u = n ? be(n) : void 0;
u?.forEach((l) => z(r.errors, l)), u ? u.forEach((l) => {
_.state.next({
name: l,
errors: r.errors
});
}) : _.state.next({
errors: {}
});
}, rr = (n, u, l) => {
const h = (y(s, n, { _f: {} })._f || {}).ref, d = y(r.errors, n) || {}, { ref: f, message: b, type: x, ...S } = d;
O(r.errors, n, {
...S,
...u,
ref: h
}), _.state.next({
name: n,
errors: r.errors,
isValid: !1
}), l && l.shouldFocus && h && h.focus && h.focus();
}, Wr = (n, u) => W(n) ? _.state.subscribe({
next: (l) => "values" in l && n(A(void 0, u), l)
}) : A(n, u, !0), tr = (n) => _.state.subscribe({
next: (u) => {
xt(n.name, u.name, n.exact) && At(u, n.formState || v, Gr, n.reRenderRoot) && n.callback({
values: { ...i },
...r,
...u,
defaultValues: o
});
}
}).unsubscribe, qr = (n) => (a.mount = !0, V = {
...V,
...n.formState
}, tr({
...n,
formState: {
...D,
...n.formState
}
})), Oe = (n, u = {}) => {
for (const l of n ? be(n) : c.mount)
c.mount.delete(l), c.array.delete(l), u.keepValue || (z(s, l), z(i, l)), !u.keepError && z(r.errors, l), !u.keepDirty && z(r.dirtyFields, l), !u.keepTouched && z(r.touchedFields, l), !u.keepIsValidating && z(r.validatingFields, l), !t.shouldUnregister && !u.keepDefaultValue && z(o, l);
_.state.next({
values: T(i)
}), _.state.next({
...r,
...u.keepDirty ? { isDirty: F() } : {}
}), !u.keepIsValid && I();
}, sr = ({ disabled: n, name: u }) => {
if (K(n) && a.mount || n || c.disabled.has(u)) {
const d = c.disabled.has(u) !== !!n;
n ? c.disabled.add(u) : c.disabled.delete(u), d && a.mount && !a.action && I();
}
}, De = (n, u = {}) => {
let l = y(s, n);
const h = K(u.disabled) || K(t.disabled);
return O(s, n, {
...l || {},
_f: {
...l && l._f ? l._f : { ref: { name: n } },
name: n,
mount: !0,
...u
}
}), c.mount.add(n), l ? sr({
disabled: K(u.disabled) ? u.disabled : t.disabled,
name: n
}) : k(n, !0, u.value), {
...h ? { disabled: u.disabled || t.disabled } : {},
...t.progressive ? {
required: !!u.required,
min: me(u.min),
max: me(u.max),
minLength: me(u.minLength),
maxLength: me(u.maxLength),
pattern: me(u.pattern)
} : {},
name: n,
onChange: ye,
onBlur: ye,
ref: (d) => {
if (d) {
De(n, u), l = y(s, n);
const f = C(d.value) && d.querySelectorAll && d.querySelectorAll("input,select,textarea")[0] || d, b = _t(f), x = l._f.refs || [];
if (b ? x.find((S) => S === f) : f === l._f.ref)
return;
O(s, n, {
_f: {
...l._f,
...b ? {
refs: [
...x.filter(Te),
f,
...Array.isArray(y(o, n)) ? [{}] : []
],
ref: { type: f.type, name: n }
} : { ref: f }
}
}), k(n, !1, void 0, f);
} else
l = y(s, n, {}), l._f && (l._f.mount = !1), (t.shouldUnregister || u.shouldUnregister) && !(Or(c.array, n) && a.action) && c.unMount.add(n);
}
};
}, Ce = () => t.shouldFocusError && ve(s, he, c.mount), Hr = (n) => {
K(n) && (_.state.next({ disabled: n }), ve(s, (u, l) => {
const h = y(s, l);
h && (u.disabled = h._f.disabled || n, Array.isArray(h._f.refs) && h._f.refs.forEach((d) => {
d.disabled = h._f.disabled || n;
}));
}, 0, !1));
}, nr = (n, u) => async (l) => {
let h;
l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
let d = T(i);
if (_.state.next({
isSubmitting: !0
}), t.resolver) {
const { errors: f, values: b } = await te();
U(), r.errors = f, d = T(b);
} else
await J(s);
if (c.disabled.size)
for (const f of c.disabled)
z(d, f);
if (z(r.errors, "root"), $(r.errors)) {
_.state.next({
errors: {}
});
try {
await n(d, l);
} catch (f) {
h = f;
}
} else
u && await u({ ...r.errors }, l), Ce(), setTimeout(Ce);
if (_.state.next({
isSubmitted: !0,
isSubmitting: !1,
isSubmitSuccessful: $(r.errors) && !h,
submitCount: r.submitCount + 1,
errors: r.errors
}), h)
throw h;
}, Zr = (n, u = {}) => {
y(s, n) && (C(u.defaultValue) ? Z(n, T(y(o, n))) : (Z(n, u.defaultValue), O(o, n, T(u.defaultValue))), u.keepTouched || z(r.touchedFields, n), u.keepDirty || (z(r.dirtyFields, n), r.isDirty = u.defaultValue ? F(n, T(y(o, n))) : F()), u.keepError || (z(r.errors, n), v.isValid && I()), _.state.next({ ...r }));
}, ir = (n, u = {}) => {
const l = n ? T(n) : o, h = T(l), d = $(n), f = d ? o : h;
if (u.keepDefaultValues || (o = l), !u.keepValues) {
if (u.keepDirtyValues) {
const b = /* @__PURE__ */ new Set([
...c.mount,
...Object.keys(de(o, i))
]);
for (const x of Array.from(b)) {
const S = y(r.dirtyFields, x), B = y(i, x), ie = y(f, x);
S && !C(B) ? O(f, x, B) : !S && !C(ie) && Z(x, ie);
}
} else {
if (Me && C(n))
for (const b of c.mount) {
const x = y(s, b);
if (x && x._f) {
const S = Array.isArray(x._f.refs) ? x._f.refs[0] : x._f.ref;
if (Ee(S)) {
const B = S.closest("form");
if (B) {
B.reset();
break;
}
}
}
}
if (u.keepFieldsRef)
for (const b of c.mount)
Z(b, y(f, b));
else
s = {};
}
i = t.shouldUnregister ? u.keepDefaultValues ? T(o) : {} : T(f), _.array.next({
values: { ...f }
}), _.state.next({
values: { ...f }
});
}
c = {
mount: u.keepDirtyValues ? c.mount : /* @__PURE__ */ new Set(),
unMount: /* @__PURE__ */ new Set(),
array: /* @__PURE__ */ new Set(),
disabled: /* @__PURE__ */ new Set(),
watch: /* @__PURE__ */ new Set(),
watchAll: !1,
focus: ""
}, a.mount = !v.isValid || !!u.keepIsValid || !!u.keepDirtyValues || !t.shouldUnregister && !$(f), a.watch = !!t.shouldUnregister, a.keepIsValid = !!u.keepIsValid, a.action = !1, u.keepErrors || (r.errors = {}), _.state.next({
submitCount: u.keepSubmitCount ? r.submitCount : 0,
isDirty: d ? !1 : u.keepDirty ? r.isDirty : !!(u.keepDefaultValues && !X(n, o)),
isSubmitted: u.keepIsSubmitted ? r.isSubmitted : !1,
dirtyFields: d ? {} : u.keepDirtyValues ? u.keepDefaultValues && i ? de(o, i) : r.dirtyFields : u.keepDefaultValues && n ? de(o, n) : u.keepDirty ? r.dirtyFields : {},
touchedFields: u.keepTouched ? r.touchedFields : {},
errors: u.keepErrors ? r.errors : {},
isSubmitSuccessful: u.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
isSubmitting: !1,
defaultValues: o
});
}, or = (n, u) => ir(W(n) ? n(i) : n, { ...t.resetOptions, ...u }), Kr = (n, u = {}) => {
const l = y(s, n), h = l && l._f;
if (h) {
const d = h.refs ? h.refs[0] : h.ref;
d.focus && setTimeout(() => {
d.focus(), u.shouldSelect && W(d.select) && d.select();
});
}
}, Gr = (n) => {
r = {
...r,
...n
};
}, ar = {
control: {
register: De,
unregister: Oe,
getFieldState: er,
handleSubmit: nr,
setError: rr,
_subscribe: tr,
_runSchema: te,
_updateIsValidating: U,
_focusError: Ce,
_getWatch: A,
_getDirty: F,
_setValid: I,
_setFieldArray: w,
_setDisabledField: sr,
_setErrors: E,
_getFieldArray: L,
_reset: ir,
_resetDefaultValues: () => W(t.defaultValues) && t.defaultValues().then((n) => {
or(n, t.resetOptions), _.state.next({
isLoading: !1
});
}),
_removeUnmounted: pe,
_disableForm: Hr,
_subjects: _,
_proxyFormState: v,
get _fields() {
return s;
},
get _formValues() {
return i;
},
get _state() {
return a;
},
set _state(n) {
a = n;
},
get _defaultValues() {
return o;
},
get _names() {
return c;
},
set _names(n) {
c = n;
},
get _formState() {
return r;
},
get _options() {
return t;
},
set _options(n) {
t = {
...t,
...n
};
}
},
subscribe: qr,
trigger: ge,
register: De,
handleSubmit: nr,
watch: Wr,
setValue: Z,
getValues: Xe,
reset: or,
resetField: Zr,
clearErrors: $r,
unregister: Oe,
setError: rr,
setFocus: Kr,
getFieldState: er
};
return {
...ar,
formControl: ar
};
}
function jt(e = {}) {
const t = p.useRef(void 0), r = p.useRef(void 0), [s, o] = p.useState({
isDirty: !1,
isValidating: !1,
isLoading: W(e.defaultValues),
isSubmitted: !1,
isSubmitting: !1,
isSubmitSuccessful: !1,
isValid: !1,
submitCount: 0,
dirtyFields: {},
touchedFields: {},
validatingFields: {},
errors: e.errors || {},
disabled: e.disabled || !1,
isReady: !1,
defaultValues: W(e.defaultValues) ? void 0 : e.defaultValues
});
if (!t.current)
if (e.formControl)
t.current = {
...e.formControl,
formState: s
}, e.defaultValues && !W(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
else {
const { formControl: a, ...c } = Pt(e);
t.current = {
...c,
formState: s
};
}
const i = t.current.control;
return i._options = e, We(() => {
const a = i._subscribe({
formState: i._proxyFormState,
callback: () => o({ ...i._formState }),
reRenderRoot: !0
});
return o((c) => ({
...c,
isReady: !0
})), i._formState.isReady = !0, a;
}, [i]), p.useEffect(() => i._disableForm(e.disabled), [i, e.disabled]), p.useEffect(() => {
e.mode && (i._options.mode = e.mode), e.reValidateMode && (i._options.reValidateMode = e.reValidateMode);
}, [i, e.mode, e.reValidateMode]), p.useEffect(() => {
e.errors && (i._setErrors(e.errors), i._focusError());
}, [i, e.errors]), p.useEffect(() => {
e.shouldUnregister && i._subjects.state.next({
values: i._getWatch()
});
}, [i, e.shouldUnregister]), p.useEffect(() => {
if (i._proxyFormState.isDirty) {
const a = i._getDirty();
a !== s.isDirty && i._subjects.state.next({
isDirty: a
});
}
}, [i, s.isDirty]), p.useEffect(() => {
var a;
e.values && !X(e.values, r.current) ? (i._reset(e.values, {
keepFieldsRef: !0,
...i._options.resetOptions
}), !((a = i._options.resetOptions) === null || a === void 0) && a.keepIsValid || i._setValid(), r.current = e.values, o((c) => ({ ...c }))) : i._resetDefaultValues();
}, [i, e.values]), p.useEffect(() => {
i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
}), t.current.formState = p.useMemo(() => Cr(s, i), [i, s]), t.current;
}
const Vr = (e, t, r) => {
if (e && "reportValidity" in e) {
const s = y(r, t);
e.setCustomValidity(s && s.message || ""), e.reportValidity();
}
}, Ie = (e, t) => {
for (const r in t.fields) {
const s = t.fields[r];
s && s.ref && "reportValidity" in s.ref ? Vr(s.ref, r, e) : s && s.refs && s.refs.forEach((o) => Vr(o, r, e));
}
}, wr = (e, t) => {
t.shouldUseNativeValidation && Ie(e, t);
const r = {};
for (const s in e) {
const o = y(t.fields, s), i = Object.assign(e[s] || {}, { ref: o && o.ref });
if (Tt(t.names || Object.keys(e), s)) {
const a = Object.assign({}, y(r, s));
O(a, "root", i), O(r, s, a);
} else O(r, s, i);
}
return r;
}, Tt = (e, t) => {
const r = Er(t);
return e.some((s) => Er(s).match(`^${r}\\.\\d+`));
};
function Er(e) {
return e.replace(/\]|\[/g, "");
}
function Lr(e, t, r) {
function s(c, g) {
if (c._zod || Object.defineProperty(c, "_zod", {
value: {
def: g,
constr: a,
traits: /* @__PURE__ */ new Set()
},
enumerable: !1
}), c._zod.traits.has(e))
return;
c._zod.traits.add(e), t(c, g);
const m = a.prototype, D = Object.keys(m);
for (let v = 0; v < D.length; v++) {
const V = D[v];
V in c || (c[V] = m[V].bind(c));
}
}
const o = r?.Parent ?? Object;
class i extends o {
}
Object.defineProperty(i, "name", { value: e });
function a(c) {
var g;
const m = r?.Parent ? new i() : this;
s(m, c), (g = m._zod).deferred ?? (g.deferred = []);
for (const D of m._zod.deferred)
D();
return m;
}
return Object.defineProperty(a, "init", { value: s }), Object.defineProperty(a, Symbol.hasInstance, {
value: (c) => r?.Parent && c instanceof r.Parent ? !0 : c?._zod?.traits?.has(e)
}), Object.defineProperty(a, "name", { value: e }), a;
}
class Ir extends Error {
constructor() {
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
}
}
class ns extends Error {
constructor(t) {
super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
}
}
const zt = {};
function Ae(e) {
return zt;
}
function is(e) {
const t = Object.values(e).filter((s) => typeof s == "number");
return Object.entries(e).filter(([s, o]) => t.indexOf(+s) === -1).map(([s, o]) => o);
}
function Rt(e, t) {
return typeof t == "bigint" ? t.toString() : t;
}
function Ut(e) {
return {
get value() {
{
const t = e();
return Object.defineProperty(this, "value", { value: t }), t;
}
}
};
}
function os(e) {
return e == null;
}
function as(e) {
const t = e.startsWith("^") ? 1 : 0, r = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, r);
}
const Fr = /* @__PURE__ */ Symbol("evaluating");
function us(e, t, r) {
let s;
Object.defineProperty(e, t, {
get() {
if (s !== Fr)
return s === void 0 && (s = Fr, s = r()), s;
},
set(o) {
Object.defineProperty(e, t, {
value: o
// configurable: true,
});
},
configurable: !0
});
}
function ue(e, t, r) {
Object.defineProperty(e, t, {
value: r,
writable: !0,
enumerable: !0,
configurable: !0
});
}
function ce(...e) {
const t = {};
for (const r of e) {
const s = Object.getOwnPropertyDescriptors(r);
Object.assign(t, s);
}
return Object.defineProperties({}, t);
}
function cs(e) {
return JSON.stringify(e);
}
function ls(e) {
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const Mr = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
};
function kr(e) {
return typeof e == "object" && e !== null && !Array.isArray(e);
}
const fs = Ut(() => {
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
return !1;
try {
const e = Function;
return new e(""), !0;
} catch {
return !1;
}
});
function Ke(e) {
if (kr(e) === !1)
return !1;
const t = e.constructor;
if (t === void 0 || typeof t != "function")
return !0;
const r = t.prototype;
return !(kr(r) === !1 || Object.prototype.hasOwnProperty.call(r, "isPrototypeOf") === !1);
}
function ds(e) {
return Ke(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
}
const ys = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
function hs(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function le(e, t, r) {
const s = new e._zod.constr(t ?? e._zod.def);
return (!t || r?.parent) && (s._zod.parent = e), s;
}
function gs(e) {
const t = e;
if (!t)
return {};
if (typeof t == "string")
return { error: () => t };
if (t?.message !== void 0) {
if (t?.error !== void 0)
throw new Error("Cannot specify both `message` and `error` params");
t.error = t.message;
}
return delete t.message, typeof t.error == "string" ? { ...t, error: () => t.error } : t;
}
function ms(e) {
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
}
function bs(e, t) {
const r = e._zod.def, s = r.checks;
if (s && s.length > 0)
throw new Error(".pick() cannot be used on object schemas containing refinements");
const i = ce(e._zod.def, {
get shape() {
const a = {};
for (const c in t) {
if (!(c in r.shape))
throw new Error(`Unrecognized key: "${c}"`);
t[c] && (a[c] = r.shape[c]);
}
return ue(this, "shape", a), a;
},
checks: []
});
return le(e, i);
}
function vs(e, t) {
const r = e._zod.def, s = r.checks;
if (s && s.length > 0)
throw new Error(".omit() cannot be used on object schemas containing refinements");
const i = ce(e._zod.def, {
get shape() {
const a = { ...e._zod.def.shape };
for (const c in t) {
if (!(c in r.shape))
throw new Error(`Unrecognized key: "${c}"`);
t[c] && delete a[c];
}
return ue(this, "shape", a), a;
},
checks: []
});
return le(e, i);
}
function _s(e, t) {
if (!Ke(t))
throw new Error("Invalid input to extend: expected a plain object");
const r = e._zod.def.checks;
if (r && r.length > 0) {
const i = e._zod.def.shape;
for (const a in t)
if (Object.getOwnPropertyDescriptor(i, a) !== void 0)
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
}
const o = ce(e._zod.def, {
get shape() {
const i = { ...e._zod.def.shape, ...t };
return ue(this, "shape", i), i;
}
});
return le(e, o);
}
function ps(e, t) {
if (!Ke(t))
throw new Error("Invalid input to safeExtend: expected a plain object");
const r = ce(e._zod.def, {
get shape() {
const s = { ...e._zod.def.shape, ...t };
return ue(this, "shape", s), s;
}
});
return le(e, r);
}
function Vs(e, t) {
const r = ce(e._zod.def, {
get shape() {
const s = { ...e._zod.def.shape, ...t._zod.def.shape };
return ue(this, "shape", s), s;
},
get catchall() {
return t._zod.def.catchall;
},
checks: []
// delete existing checks
});
return le(e, r);
}
function ws(e, t, r) {
const o = t._zod.def.checks;
if (o && o.length > 0)
throw new Error(".partial() cannot be used on object schemas containing refinements");
const a = ce(t._zod.def, {
get shape() {
const c = t._zod.def.shape, g = { ...c };
if (r)
for (const m in r) {
if (!(m in c))
throw new Error(`Unrecognized key: "${m}"`);
r[m] && (g[m] = e ? new e({
type: "optional",
innerType: c[m]
}) : c[m]);
}
else
for (const m in c)
g[m] = e ? new e({
type: "optional",
innerType: c[m]
}) : c[m];
return ue(this, "shape", g), g;
},
checks: []
});
return le(t, a);
}
function Es(e, t, r) {
const s = ce(t._zod.def, {
get shape() {
const o = t._zod.def.shape, i = { ...o };
if (r)
for (const a in r) {
if (!(a in i))
throw new Error(`Unrecognized key: "${a}"`);
r[a] && (i[a] = new e({
type: "nonoptional",
innerType: o[a]
}));
}
else
for (const a in o)
i[a] = new e({
type: "nonoptional",
innerType: o[a]
});
return ue(this, "shape", i), i;
}
});
return le(t, s);
}
function Fs(e, t = 0) {
if (e.aborted === !0)
return !0;
for (let r = t; r < e.issues.length; r++)
if (e.issues[r]?.continue !== !0)
return !0;
return !1;
}
function ks(e, t) {
return t.map((r) => {
var s;
return (s = r).path ?? (s.path = []), r.path.unshift(e), r;
});
}
function Ve(e) {
return typeof e == "string" ? e : e?.message;
}
function xe(e, t, r) {
const s = { ...e, path: e.path ?? [] };
if (!e.message) {
const o = Ve(e.inst?._zod.def?.error?.(e)) ?? Ve(t?.error?.(e)) ?? Ve(r.customError?.(e)) ?? Ve(r.localeError?.(e)) ?? "Invalid input";
s.message = o;
}
return delete s.inst, delete s.continue, t?.reportInput || delete s.input, s;
}
function As(e) {
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
}
function xs(...e) {
const [t, r, s] = e;
return typeof t == "string" ? {
message: t,
code: "custom",
input: r,
inst: s
} : { ...t };
}
const Nr = (e, t) => {
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
value: e._zod,
enumerable: !1
}), Object.defineProperty(e, "issues", {
value: t,
enumerable: !1
}), e.message = JSON.stringify(t, Rt, 2), Object.defineProperty(e, "toString", {
value: () => e.message,
enumerable: !1
});
}, Br = Lr("$ZodError", Nr), Se = Lr("$ZodError", Nr, { Parent: Error });
function Ss(e, t = (r) => r.message) {
const r = {}, s = [];
for (const o of e.issues)
o.path.length > 0 ? (r[o.path[0]] = r[o.path[0]] || [], r[o.path[0]].push(t(o))) : s.push(t(o));
return { formErrors: s, fieldErrors: r };
}
function Os(e, t = (r) => r.message) {
const r = { _errors: [] }, s = (o) => {
for (const i of o.issues)
if (i.code === "invalid_union" && i.errors.length)
i.errors.map((a) => s({ issues: a }));
else if (i.code === "invalid_key")
s({ issues: i.issues });
else if (i.code === "invali