@venkat91/ark-ui-components
Version:
React component library built on Ark UI with TypeScript and Panda CSS
1,536 lines • 183 kB
JavaScript
import { jsx as w, jsxs as J, Fragment as _t } from "react/jsx-runtime";
import { useMemo as Jo, useRef as H, useLayoutEffect as Qo, useEffect as Vt, useState as be, createContext as ti, useContext as ei, memo as ni, forwardRef as F, createElement as ri, Children as ur, isValidElement as oi, cloneElement as ii, useCallback as si, useId as Pe, useSyncExternalStore as ai } from "react";
import { flushSync as sn, createPortal as ci } from "react-dom";
const li = {
primary: "custom-button--primary",
secondary: "custom-button--secondary",
danger: "custom-button--danger"
}, ui = {
sm: "custom-button--sm",
md: "custom-button--md",
lg: "custom-button--lg"
}, Ru = ({
children: t,
variant: e = "primary",
size: n = "md",
loading: r = !1,
leftIcon: o,
rightIcon: i,
className: s = "",
disabled: a,
...l
}) => /* @__PURE__ */ w(
"button",
{
className: [
"custom-button",
li[e],
ui[n],
s
].join(" "),
disabled: a || r,
...l,
children: r ? /* @__PURE__ */ w("span", { className: "custom-button__spinner", "aria-label": "Loading" }) : /* @__PURE__ */ J(_t, { children: [
o && /* @__PURE__ */ w("span", { className: "custom-button__icon custom-button__icon--left", children: o }),
t,
i && /* @__PURE__ */ w("span", { className: "custom-button__icon custom-button__icon--right", children: i })
] })
}
);
function di(t) {
return t ? Array.isArray(t) ? t : [t] : [];
}
var dr = (t) => t[0], fr = (t) => t[t.length - 1], Nn = (t) => (t == null ? void 0 : t.constructor.name) === "Array", fi = (t, e) => {
if (t.length !== e.length) return !1;
for (let n = 0; n < t.length; n++)
if (!an(t[n], e[n])) return !1;
return !0;
}, an = (t, e) => {
if (Object.is(t, e)) return !0;
if (t == null && e != null || t != null && e == null) return !1;
if (typeof (t == null ? void 0 : t.isEqual) == "function" && typeof (e == null ? void 0 : e.isEqual) == "function")
return t.isEqual(e);
if (typeof t == "function" && typeof e == "function")
return t.toString() === e.toString();
if (Nn(t) && Nn(e))
return fi(Array.from(t), Array.from(e));
if (typeof t != "object" || typeof e != "object") return !1;
const n = Object.keys(e ?? /* @__PURE__ */ Object.create(null)), r = n.length;
for (let o = 0; o < r; o++)
if (!Reflect.has(t, n[o])) return !1;
for (let o = 0; o < r; o++) {
const i = n[o];
if (!an(t[i], e[i])) return !1;
}
return !0;
}, pe = (t) => typeof t == "string", Ft = (t) => typeof t == "function", gi = (t) => t == null, pi = Function.prototype.toString;
pi.call(Object);
var mi = (t, ...e) => (typeof t == "function" ? t(...e) : t) ?? void 0, hi = (t) => t(), bi = () => {
}, $e = (...t) => (...e) => {
t.forEach(function(n) {
n == null || n(...e);
});
}, { floor: An, abs: ve, round: gr, min: vi, max: yi, pow: xi, sign: wi } = Math, Xt = (t) => Number.isNaN(t), Zt = (t) => Xt(t) ? 0 : t, Ei = (t, e, n) => t === 0 ? n : e[t - 1], Ti = (t, e, n) => t === e.length - 1 ? n : e[t + 1], Pi = (t, e, n) => Zt(t) >= e && Zt(t) <= n, Oi = (t, e, n) => gr((Zt(t) - e) / n) * n + e, ee = (t, e, n) => vi(yi(Zt(t), e), n), cn = (t, e, n) => (Zt(t) - e) / (n - e), pr = (t, e, n, r) => ee(Oi(t * (n - e) + e, e, r), e, n), ce = (t, e) => {
let n = t, r = e.toString(), o = r.indexOf("."), i = o >= 0 ? r.length - o : 0;
if (i > 0) {
let s = xi(10, i);
n = gr(n * s) / s;
}
return n;
}, ln = (t, e, n, r) => {
e = Number(e), n = Number(n);
let o = (t - (Xt(e) ? 0 : e)) % r, i = ce(
ve(o) * 2 >= r ? t + wi(o) * (r - ve(o)) : t - o,
r
);
return Xt(e) ? !Xt(n) && i > n && (i = e + An(ce((n - e) / r, r)) * r) : i < e ? i = e : !Xt(n) && i > n && (i = e + An(ce((n - e) / r, r)) * r), ce(i, r);
}, Yt = (t, e, n) => t[e] === n ? t : [...t.slice(0, e), n, ...t.slice(e + 1)];
function mr(t, e) {
const n = Ei(t, e.values, e.min), r = Ti(t, e.values, e.max);
let o = e.values.slice();
return function(s) {
let a = ln(s, n, r, e.step);
return o = Yt(o, t, s), o[t] = a, o;
};
}
function Ci(t, e) {
const n = e.values[t] + e.step;
return mr(t, e)(n);
}
function Si(t, e) {
const n = e.values[t] - e.step;
return mr(t, e)(n);
}
var Ni = (t, e) => {
let n = t.findIndex((i) => e - i < 0);
if (n === 0) return n;
if (n === -1) return t.length - 1;
let r = t[n - 1], o = t[n];
return ve(r - e) < ve(o - e) ? n - 1 : n;
}, hr = (t, e, n, r) => t.map((o, i) => ({
min: i === 0 ? e : t[i - 1] + r,
max: i === t.length - 1 ? n : t[i + 1] - r,
value: o
})), We = (t, e) => {
const [n, r] = t, [o, i] = e;
return (s) => n === r || o === i ? o : o + (i - o) / (r - n) * (s - n);
}, kn = (t) => t != null ? `${t}px` : void 0;
function un(t) {
if (!Ai(t) || t === void 0) return t;
const e = Reflect.ownKeys(t).filter((r) => typeof r == "string"), n = {};
for (const r of e) {
const o = t[r];
o !== void 0 && (n[r] = un(o));
}
return n;
}
var Ai = (t) => t && typeof t == "object" && t.constructor === Object;
function ki(t, e) {
const n = {};
for (const r of e) {
const o = t[r];
o !== void 0 && (n[r] = o);
}
return n;
}
function Ue(...t) {
const e = t.length === 1 ? t[0] : t[1];
(t.length === 2 ? t[0] : !0) && process.env.NODE_ENV !== "production" && console.warn(e);
}
function Ri(t, e) {
if (t == null) throw new Error(e());
}
var Rn = (t) => Math.max(0, Math.min(1, t)), br = () => {
}, Oe = (t) => typeof t == "object" && t !== null, A = (t) => t ? "" : void 0, Ii = (t) => t ? "true" : void 0, Fi = 1, Di = 9, Li = 11, $ = (t) => Oe(t) && t.nodeType === Fi && typeof t.nodeName == "string", dn = (t) => Oe(t) && t.nodeType === Di, _i = (t) => Oe(t) && t === t.window, vr = (t) => $(t) ? t.localName || "" : "#document";
function Vi(t) {
return ["html", "body", "#document"].includes(vr(t));
}
var Bi = (t) => Oe(t) && t.nodeType !== void 0, Bt = (t) => Bi(t) && t.nodeType === Li && "host" in t, Mi = (t) => $(t) && t.localName === "input", $i = (t) => !!(t != null && t.matches("a[href]")), Wi = (t) => $(t) ? t.offsetWidth > 0 || t.offsetHeight > 0 || t.getClientRects().length > 0 : !1, Ui = /(textarea|select)/;
function Hi(t) {
if (t == null || !$(t)) return !1;
try {
return Mi(t) && t.selectionStart != null || Ui.test(t.localName) || t.isContentEditable || t.getAttribute("contenteditable") === "true" || t.getAttribute("contenteditable") === "";
} catch {
return !1;
}
}
function Jt(t, e) {
var r;
if (!t || !e || !$(t) || !$(e)) return !1;
const n = (r = e.getRootNode) == null ? void 0 : r.call(e);
if (t === e || t.contains(e)) return !0;
if (n && Bt(n)) {
let o = e;
for (; o; ) {
if (t === o) return !0;
o = o.parentNode || o.host;
}
}
return !1;
}
function dt(t) {
return dn(t) ? t : _i(t) ? t.document : (t == null ? void 0 : t.ownerDocument) ?? document;
}
function zi(t) {
return dt(t).documentElement;
}
function ft(t) {
var e;
return Bt(t) ? ft(t.host) : dn(t) ? t.defaultView ?? window : $(t) ? ((e = t.ownerDocument) == null ? void 0 : e.defaultView) ?? window : window;
}
function yr(t) {
let e = t.activeElement;
for (; e != null && e.shadowRoot; ) {
const n = e.shadowRoot.activeElement;
if (n === e) break;
e = n;
}
return e;
}
function ji(t) {
if (vr(t) === "html") return t;
const e = t.assignedSlot || t.parentNode || Bt(t) && t.host || zi(t);
return Bt(e) ? e.host : e;
}
var De = /* @__PURE__ */ new WeakMap();
function fn(t) {
return De.has(t) || De.set(t, ft(t).getComputedStyle(t)), De.get(t);
}
var Ce = () => typeof document < "u";
function Gi() {
const t = navigator.userAgentData;
return (t == null ? void 0 : t.platform) ?? navigator.platform;
}
function Ki() {
const t = navigator.userAgentData;
return t && Array.isArray(t.brands) ? t.brands.map(({ brand: e, version: n }) => `${e}/${n}`).join(" ") : navigator.userAgent;
}
var gn = (t) => Ce() && t.test(Gi()), Xi = (t) => Ce() && t.test(Ki()), Yi = (t) => Ce() && t.test(navigator.vendor), In = () => Ce() && !!navigator.maxTouchPoints, qi = () => gn(/^iPhone/i), Zi = () => gn(/^iPad/i) || pn() && navigator.maxTouchPoints > 1, Se = () => qi() || Zi(), Ji = () => pn() || Se(), pn = () => gn(/^Mac/i), xr = () => Ji() && Yi(/apple/i), Qi = () => Xi(/Firefox/i);
function ts(t) {
var e, n, r;
return ((e = t.composedPath) == null ? void 0 : e.call(t)) ?? ((r = (n = t.nativeEvent) == null ? void 0 : n.composedPath) == null ? void 0 : r.call(n));
}
function rt(t) {
const e = ts(t);
return (e == null ? void 0 : e[0]) ?? t.target;
}
var es = (t) => Jt(t.currentTarget, rt(t));
function ns(t) {
return cs(t).isComposing || t.keyCode === 229;
}
var rs = (t) => t.button === 0, os = (t) => t.button === 2 || pn() && t.ctrlKey && t.button === 0, is = (t) => t.ctrlKey || t.altKey || t.metaKey, ss = (t) => "touches" in t && t.touches.length > 0, as = {
Up: "ArrowUp",
Down: "ArrowDown",
Esc: "Escape",
" ": "Space",
",": "Comma",
Left: "ArrowLeft",
Right: "ArrowRight"
}, Fn = {
ArrowLeft: "ArrowRight",
ArrowRight: "ArrowLeft"
};
function wr(t, e = {}) {
const { dir: n = "ltr", orientation: r = "horizontal" } = e;
let o = t.key;
return o = as[o] ?? o, n === "rtl" && r === "horizontal" && o in Fn && (o = Fn[o]), o;
}
function cs(t) {
return t.nativeEvent ?? t;
}
var ls = /* @__PURE__ */ new Set(["PageUp", "PageDown"]), us = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
function ds(t) {
return t.ctrlKey || t.metaKey ? 0.1 : ls.has(t.key) || t.shiftKey && us.has(t.key) ? 10 : 1;
}
function Er(t, e = "client") {
const n = ss(t) ? t.touches[0] || t.changedTouches[0] : t;
return { x: n[`${e}X`], y: n[`${e}Y`] };
}
var z = (t, e, n, r) => {
const o = typeof t == "function" ? t() : t;
return o == null || o.addEventListener(e, n, r), () => {
o == null || o.removeEventListener(e, n, r);
};
};
function fs(t, e) {
const { type: n = "HTMLInputElement", property: r = "value" } = e, o = ft(t)[n].prototype;
return Object.getOwnPropertyDescriptor(o, r) ?? {};
}
function gs(t) {
if (t.localName === "input") return "HTMLInputElement";
if (t.localName === "textarea") return "HTMLTextAreaElement";
if (t.localName === "select") return "HTMLSelectElement";
}
function Tr(t, e, n = "value") {
var o;
if (!t) return;
const r = gs(t);
r && ((o = fs(t, { type: r, property: n }).set) == null || o.call(t, e)), t.setAttribute(n, e);
}
function ps(t, e) {
const { value: n, bubbles: r = !0 } = e;
if (!t) return;
const o = ft(t);
t instanceof o.HTMLInputElement && (Tr(t, `${n}`), t.dispatchEvent(new o.Event("input", { bubbles: r })));
}
function ms(t) {
return hs(t) ? t.form : t.closest("form");
}
function hs(t) {
return t.matches("textarea, input, select, button");
}
function bs(t, e) {
if (!t) return;
const n = ms(t), r = (o) => {
o.defaultPrevented || e();
};
return n == null || n.addEventListener("reset", r, { passive: !0 }), () => n == null ? void 0 : n.removeEventListener("reset", r);
}
function vs(t, e) {
const n = t == null ? void 0 : t.closest("fieldset");
if (!n) return;
e(n.disabled);
const r = ft(n), o = new r.MutationObserver(() => e(n.disabled));
return o.observe(n, {
attributes: !0,
attributeFilter: ["disabled"]
}), () => o.disconnect();
}
function ys(t, e) {
if (!t) return;
const { onFieldsetDisabledChange: n, onFormReset: r } = e, o = [bs(t, r), vs(t, n)];
return () => o.forEach((i) => i == null ? void 0 : i());
}
var Pr = (t) => $(t) && t.tagName === "IFRAME", xs = (t) => !Number.isNaN(parseInt(t.getAttribute("tabindex") || "0", 10)), ws = (t) => parseInt(t.getAttribute("tabindex") || "0", 10) < 0, mn = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type", hn = (t, e = !1) => {
if (!t) return [];
const n = Array.from(t.querySelectorAll(mn));
(e == !0 || e == "if-empty" && n.length === 0) && $(t) && mt(t) && n.unshift(t);
const o = n.filter(mt);
return o.forEach((i, s) => {
if (Pr(i) && i.contentDocument) {
const a = i.contentDocument.body;
o.splice(s, 1, ...hn(a));
}
}), o;
};
function mt(t) {
return !t || t.closest("[inert]") ? !1 : t.matches(mn) && Wi(t);
}
function ne(t, e) {
if (!t) return [];
const n = Array.from(t.querySelectorAll(mn)), r = n.filter(pt);
return e && pt(t) && r.unshift(t), r.forEach((o, i) => {
if (Pr(o) && o.contentDocument) {
const s = o.contentDocument.body, a = ne(s);
r.splice(i, 1, ...a);
}
}), !r.length && e ? n : r;
}
function pt(t) {
return t != null && t.tabIndex > 0 ? !0 : mt(t) && !ws(t);
}
function Es(t, e) {
const n = ne(t, e), r = n[0] || null, o = n[n.length - 1] || null;
return [r, o];
}
function Ts(t, e) {
const n = ne(t), r = (t == null ? void 0 : t.ownerDocument) || document, o = e ?? r.activeElement;
if (!o) return null;
const i = n.indexOf(o);
return n[i + 1] || null;
}
function Ht(t) {
return t.tabIndex < 0 && (/^(audio|video|details)$/.test(t.localName) || Hi(t)) && !xs(t) ? 0 : t.tabIndex;
}
function Dn(t) {
const { root: e, getInitialEl: n, filter: r, enabled: o = !0 } = t;
if (!o) return;
let i = null;
if (i || (i = typeof n == "function" ? n() : n), i || (i = e == null ? void 0 : e.querySelector("[data-autofocus],[autofocus]")), !i) {
const s = ne(e);
i = r ? s.filter(r)[0] : s[0];
}
return i || e || void 0;
}
function bn(t) {
const e = /* @__PURE__ */ new Set();
function n(r) {
const o = globalThis.requestAnimationFrame(r);
e.add(() => globalThis.cancelAnimationFrame(o));
}
return n(() => n(t)), function() {
e.forEach((o) => o());
};
}
function _(t) {
let e;
const n = globalThis.requestAnimationFrame(() => {
e = t();
});
return () => {
globalThis.cancelAnimationFrame(n), e == null || e();
};
}
function Ps(t, e, n) {
const r = _(() => {
t.removeEventListener(e, o, !0), n();
}), o = () => {
r(), n();
};
return t.addEventListener(e, o, { once: !0, capture: !0 }), r;
}
function Os(t) {
const e = () => t.click();
Qi() ? Ps(t, "keyup", e) : queueMicrotask(e);
}
function He(t) {
const e = ji(t);
return Vi(e) ? dt(e).body : $(e) && Ss(e) ? e : He(e);
}
var Cs = /auto|scroll|overlay|hidden|clip/;
function Ss(t) {
const e = ft(t), { overflow: n, overflowX: r, overflowY: o, display: i } = e.getComputedStyle(t);
return Cs.test(n + o + r) && !["inline", "contents"].includes(i);
}
function Ns(t, e) {
const { left: n, top: r, width: o, height: i } = e.getBoundingClientRect(), s = { x: t.x - n, y: t.y - r }, a = { x: Rn(s.x / o), y: Rn(s.y / i) };
function l(c = {}) {
const { dir: d = "ltr", orientation: g = "horizontal", inverted: f } = c, u = typeof f == "object" ? f.x : f, p = typeof f == "object" ? f.y : f;
return g === "horizontal" ? d === "rtl" || u ? 1 - a.x : a.x : p ? 1 - a.y : a.y;
}
return { offset: s, percent: a, getPercentValue: l };
}
var Dt = "default", ze = "", me = /* @__PURE__ */ new WeakMap();
function As(t = {}) {
const { target: e, doc: n } = t, r = n ?? document, o = r.documentElement;
return Se() ? (Dt === "default" && (ze = o.style.webkitUserSelect, o.style.webkitUserSelect = "none"), Dt = "disabled") : e && (me.set(e, e.style.userSelect), e.style.userSelect = "none"), () => ks({ target: e, doc: r });
}
function ks(t = {}) {
const { target: e, doc: n } = t, o = (n ?? document).documentElement;
if (Se()) {
if (Dt !== "disabled") return;
Dt = "restoring", setTimeout(() => {
bn(() => {
Dt === "restoring" && (o.style.webkitUserSelect === "none" && (o.style.webkitUserSelect = ze || ""), ze = "", Dt = "default");
});
}, 300);
} else if (e && me.has(e)) {
const i = me.get(e);
e.style.userSelect === "none" && (e.style.userSelect = i ?? ""), e.getAttribute("style") === "" && e.removeAttribute("style"), me.delete(e);
}
}
function Rs(t = {}) {
const { defer: e, target: n, ...r } = t, o = e ? _ : (s) => s(), i = [];
return i.push(
o(() => {
const s = typeof n == "function" ? n() : n;
i.push(As({ ...r, target: s }));
})
), () => {
i.forEach((s) => s == null ? void 0 : s());
};
}
function Is(t, e) {
const { onPointerMove: n, onPointerUp: r } = e, i = [
z(t, "pointermove", (s) => {
const a = Er(s), l = Math.sqrt(a.x ** 2 + a.y ** 2), c = s.pointerType === "touch" ? 10 : 5;
if (!(l < c)) {
if (s.pointerType === "mouse" && s.button === 0) {
r();
return;
}
n({ point: a, event: s });
}
}, !1),
z(t, "pointerup", r, !1),
z(t, "pointercancel", r, !1),
z(t, "contextmenu", r, !1),
Rs({ doc: t })
];
return () => {
i.forEach((s) => s());
};
}
function Fs(t, e = {}) {
const { triggerElement: n, onFocus: r, onFocusEnter: o } = e, i = (t == null ? void 0 : t.ownerDocument) || document, s = i.body;
function a(l) {
if (l.key !== "Tab") return;
let c = null;
const [d, g] = Es(t, !0), f = Ts(s, n), u = !d && !g;
l.shiftKey && f === i.activeElement ? (o == null || o(), c = g) : l.shiftKey && (i.activeElement === d || u) ? c = n : !l.shiftKey && i.activeElement === n ? (o == null || o(), c = d) : !l.shiftKey && (i.activeElement === g || u) && (c = f), c && (l.preventDefault(), typeof r == "function" ? r(c) : c.focus());
}
return z(i, "keydown", a, !0);
}
function Ds(t, e) {
const { defer: n, triggerElement: r, ...o } = e, i = n ? _ : (a) => a(), s = [];
return s.push(
i(() => {
const a = typeof t == "function" ? t() : t, l = typeof r == "function" ? r() : r;
s.push(Fs(a, { triggerElement: l, ...o }));
})
), () => {
s.forEach((a) => a == null ? void 0 : a());
};
}
function Or(t, e) {
return Array.from((t == null ? void 0 : t.querySelectorAll(e)) ?? []);
}
var Cr = (t) => t.id;
function Sr(t, e, n = Cr) {
return t.find((r) => n(r) === e);
}
function Nr(t, e, n = Cr) {
const r = Sr(t, e, n);
return r ? t.indexOf(r) : -1;
}
function Ls(t, e, n = !0) {
let r = Nr(t, e);
return r = n ? (r + 1) % t.length : Math.min(r + 1, t.length - 1), t[r];
}
function _s(t, e, n = !0) {
let r = Nr(t, e);
return r === -1 ? n ? t[t.length - 1] : null : (r = n ? (r - 1 + t.length) % t.length : Math.max(0, r - 1), t[r]);
}
function Ar(t, e) {
const { onEntry: n, measure: r, box: o = "border-box" } = e, i = (Array.isArray(t) ? t : [t]).filter($), s = ft(i[0]), a = (c) => {
const d = i.map((g) => r(g));
n({ rects: d, entries: c });
};
a([]);
const l = new s.ResizeObserver(a);
return i.forEach((c) => l.observe(c, { box: o })), () => l.disconnect();
}
function ye(t, e) {
if (!t) return br;
const n = Object.keys(e).reduce((r, o) => (r[o] = t.style.getPropertyValue(o), r), {});
return Object.assign(t.style, e), () => {
Object.assign(t.style, n), t.style.length === 0 && t.removeAttribute("style");
};
}
function Vs(t, e, n) {
if (!t) return br;
const r = t.style.getPropertyValue(e);
return t.style.setProperty(e, n), () => {
t.style.setProperty(e, r), t.style.length === 0 && t.removeAttribute("style");
};
}
var Bs = 1e3 / 60;
function Ms(t, e) {
const n = t();
if ($(n) && n.isConnected)
return e(n), () => {
};
{
const r = setInterval(() => {
const o = t();
$(o) && o.isConnected && (e(o), clearInterval(r));
}, Bs);
return () => clearInterval(r);
}
}
function $s(t, e) {
const n = [];
return t == null || t.forEach((r) => {
const o = Ms(r, e);
n.push(o);
}), () => {
n.forEach((r) => r());
};
}
var Ws = (...t) => t.map((e) => {
var n;
return (n = e == null ? void 0 : e.trim) == null ? void 0 : n.call(e);
}).filter(Boolean).join(" "), Us = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g, Ln = (t) => {
const e = {};
let n;
for (; n = Us.exec(t); )
e[n[1]] = n[2];
return e;
}, Hs = (t, e) => {
if (pe(t)) {
if (pe(e)) return `${t};${e}`;
t = Ln(t);
} else pe(e) && (e = Ln(e));
return Object.assign({}, t ?? {}, e ?? {});
};
function k(...t) {
let e = {};
for (let n of t) {
for (let r in e) {
if (r.startsWith("on") && typeof e[r] == "function" && typeof n[r] == "function") {
e[r] = $e(n[r], e[r]);
continue;
}
if (r === "className" || r === "class") {
e[r] = Ws(e[r], n[r]);
continue;
}
if (r === "style") {
e[r] = Hs(e[r], n[r]);
continue;
}
e[r] = n[r] !== void 0 ? n[r] : e[r];
}
for (let r in n)
e[r] === void 0 && (e[r] = n[r]);
}
return e;
}
function zs() {
return {
and: (...t) => function(n) {
return t.every((r) => n.guard(r));
},
or: (...t) => function(n) {
return t.some((r) => n.guard(r));
},
not: (t) => function(n) {
return !n.guard(t);
}
};
}
var It = /* @__PURE__ */ ((t) => (t.NotStarted = "Not Started", t.Started = "Started", t.Stopped = "Stopped", t))(It || {}), Le = "__init__";
function js(t) {
const e = () => {
var a;
return ((a = t.getRootNode) == null ? void 0 : a.call(t)) ?? document;
}, n = () => dt(e()), r = () => n().defaultView ?? window, o = () => yr(e());
return {
...t,
getRootNode: e,
getDoc: n,
getWin: r,
getActiveElement: o,
isActiveElement: (a) => a === o(),
getById: (a) => e().getElementById(a)
};
}
function Gs(t) {
return new Proxy({}, {
get(e, n) {
return n === "style" ? (r) => t({ style: r }).style : t;
}
});
}
var yt = () => (t) => Array.from(new Set(t)), kr = typeof globalThis.document < "u" ? Qo : Vt;
function xe(t) {
const e = t().value ?? t().defaultValue, n = t().isEqual ?? Object.is, [r] = be(e), [o, i] = be(r), s = t().value !== void 0, a = H(o);
a.current = s ? t().value : o;
const l = H(a.current);
kr(() => {
l.current = a.current;
}, [o, t().value]);
const c = (g) => {
var p, m;
const f = l.current, u = Ft(g) ? g(f) : g;
t().debug && console.log(`[bindable > ${t().debug}] setValue`, { next: u, prev: f }), s || i(u), n(u, f) || (m = (p = t()).onChange) == null || m.call(p, u, f);
};
function d() {
return s ? t().value : o;
}
return {
initial: r,
ref: a,
get: d,
set(g) {
(t().sync ? sn : hi)(() => c(g));
},
invoke(g, f) {
var u, p;
(p = (u = t()).onChange) == null || p.call(u, g, f);
},
hash(g) {
var f, u;
return ((u = (f = t()).hash) == null ? void 0 : u.call(f, g)) ?? String(g);
}
};
}
xe.cleanup = (t) => {
Vt(() => t, []);
};
xe.ref = (t) => {
const e = H(t);
return {
get: () => e.current,
set: (n) => {
e.current = n;
}
};
};
function Ks(t) {
const e = H(t);
return {
get(n) {
return e.current[n];
},
set(n, r) {
e.current[n] = r;
}
};
}
var Xs = (t, e) => {
const n = H(!1), r = H(!1);
Vt(() => {
if (n.current && r.current) return e();
r.current = !0;
}, [...(t ?? []).map((o) => typeof o == "function" ? o() : o)]), Vt(() => (n.current = !0, () => {
n.current = !1;
}), []);
};
function re(t, e = {}) {
var G, U, j, I;
const n = Jo(() => {
const { id: E, ids: T, getRootNode: C } = e;
return js({ id: E, ids: T, getRootNode: C });
}, [e]), r = (...E) => {
t.debug && console.log(...E);
}, o = ((G = t.props) == null ? void 0 : G.call(t, { props: un(e), scope: n })) ?? e, i = Ys(o), s = (U = t.context) == null ? void 0 : U.call(t, {
prop: i,
bindable: xe,
scope: n,
flush: _n,
getContext() {
return l;
},
getComputed() {
return b;
},
getRefs() {
return m;
}
}), a = Rr(s), l = {
get(E) {
var T;
return (T = a.current) == null ? void 0 : T[E].ref.current;
},
set(E, T) {
var C;
(C = a.current) == null || C[E].set(T);
},
initial(E) {
var T;
return (T = a.current) == null ? void 0 : T[E].initial;
},
hash(E) {
var C, S;
const T = (C = a.current) == null ? void 0 : C[E].get();
return (S = a.current) == null ? void 0 : S[E].hash(T);
}
}, c = H(/* @__PURE__ */ new Map()), d = H(null), g = H(null), f = H({ type: "" }), u = () => ({
...f.current,
current() {
return f.current;
},
previous() {
return g.current;
}
}), p = () => ({
...y,
matches(...E) {
return E.includes(y.ref.current);
},
hasTag(E) {
var T, C;
return !!((C = (T = t.states[y.ref.current]) == null ? void 0 : T.tags) != null && C.includes(E));
}
}), m = Ks(((j = t.refs) == null ? void 0 : j.call(t, { prop: i, context: l })) ?? {}), h = () => ({
state: p(),
context: l,
event: u(),
prop: i,
send: M,
action: v,
guard: x,
track: Xs,
refs: m,
computed: b,
flush: _n,
scope: n,
choose: O
}), v = (E) => {
const T = Ft(E) ? E(h()) : E;
if (!T) return;
const C = T.map((S) => {
var W, q;
const R = (q = (W = t.implementations) == null ? void 0 : W.actions) == null ? void 0 : q[S];
return R || Ue(`[zag-js] No implementation found for action "${JSON.stringify(S)}"`), R;
});
for (const S of C)
S == null || S(h());
}, x = (E) => {
var T, C;
return Ft(E) ? E(h()) : (C = (T = t.implementations) == null ? void 0 : T.guards) == null ? void 0 : C[E](h());
}, P = (E) => {
const T = Ft(E) ? E(h()) : E;
if (!T) return;
const C = T.map((R) => {
var q, Y;
const W = (Y = (q = t.implementations) == null ? void 0 : q.effects) == null ? void 0 : Y[R];
return W || Ue(`[zag-js] No implementation found for effect "${JSON.stringify(R)}"`), W;
}), S = [];
for (const R of C) {
const W = R == null ? void 0 : R(h());
W && S.push(W);
}
return () => S.forEach((R) => R == null ? void 0 : R());
}, O = (E) => di(E).find((T) => {
let C = !T.guard;
return pe(T.guard) ? C = !!x(T.guard) : Ft(T.guard) && (C = T.guard(h())), C;
}), b = (E) => {
Ri(t.computed, () => "[zag-js] No computed object found on machine");
const T = t.computed[E];
return T({
context: l,
event: u(),
prop: i,
refs: m,
scope: n,
computed: b
});
}, y = xe(() => ({
defaultValue: t.initialState({ prop: i }),
onChange(E, T) {
var S, R, W, q;
if (T) {
const Y = c.current.get(T);
Y == null || Y(), c.current.delete(T);
}
T && v((S = t.states[T]) == null ? void 0 : S.exit), v((R = d.current) == null ? void 0 : R.actions);
const C = P((W = t.states[E]) == null ? void 0 : W.effects);
if (C && c.current.set(E, C), T === Le) {
v(t.entry);
const Y = P(t.effects);
Y && c.current.set(Le, Y);
}
v((q = t.states[E]) == null ? void 0 : q.entry);
}
})), N = H(void 0), V = H(It.NotStarted);
kr(() => {
queueMicrotask(() => {
const C = V.current === It.Started;
V.current = It.Started, r(C ? "rehydrating..." : "initializing...");
const S = N.current ?? y.initial;
y.invoke(S, C ? y.get() : Le);
});
const E = c.current, T = y.ref.current;
return () => {
r("unmounting..."), N.current = T, V.current = It.Stopped, E.forEach((C) => C == null ? void 0 : C()), c.current = /* @__PURE__ */ new Map(), d.current = null, queueMicrotask(() => {
v(t.exit);
});
};
}, []);
const B = () => "ref" in y ? y.ref.current : y.get(), M = (E) => {
queueMicrotask(() => {
var q, Y;
if (V.current !== It.Started) return;
g.current = f.current, f.current = E, r("send", E);
let T = B();
const C = (
// @ts-ignore
((q = t.states[T].on) == null ? void 0 : q[E.type]) ?? // @ts-ignore
((Y = t.on) == null ? void 0 : Y[E.type])
), S = O(C);
if (!S) return;
d.current = S;
const R = S.target ?? T;
r("transition", S);
const W = R !== T;
W ? sn(() => y.set(R)) : S.reenter && !W ? y.invoke(T, T) : v(S.actions ?? []);
});
};
return (I = t.watch) == null || I.call(t, h()), {
state: p(),
send: M,
context: l,
prop: i,
scope: n,
refs: m,
computed: b,
event: u(),
getStatus: () => V.current
};
}
function Rr(t) {
const e = H(t);
return e.current = t, e;
}
function Ys(t) {
const e = Rr(t);
return function(r) {
return e.current[r];
};
}
function _n(t) {
queueMicrotask(() => {
sn(() => t());
});
}
var Ne = Gs((t) => t);
function oe(...t) {
return (e) => {
const n = [];
for (const r of t)
if (typeof r == "function") {
const o = r(e);
typeof o == "function" && n.push(o);
} else r && (r.current = e);
if (n.length)
return () => {
for (const r of n)
r();
};
};
}
function qs(t, e) {
return `${t} returned \`undefined\`. Seems you forgot to wrap component within ${e}`;
}
function gt(t = {}) {
const {
name: e,
strict: n = !0,
hookName: r = "useContext",
providerName: o = "Provider",
errorMessage: i,
defaultValue: s
} = t, a = ti(s);
a.displayName = e;
function l() {
var d;
const c = ei(a);
if (!c && n) {
const g = new Error(i ?? qs(r, o));
throw g.name = "ContextError", (d = Error.captureStackTrace) == null || d.call(Error, g, l), g;
}
return c;
}
return [a.Provider, l, a];
}
const Pt = () => (t, e) => e.reduce(
(n, r) => {
const [o, i] = n, s = r;
return i[s] !== void 0 && (o[s] = i[s]), delete i[s], [o, i];
},
[{}, { ...t }]
), [Ir, Fr] = gt({
name: "RenderStrategyContext",
hookName: "useRenderStrategyContext",
providerName: "<RenderStrategyPropsProvider />"
}), Dr = (t) => Pt()(t, ["lazyMount", "unmountOnExit"]);
function Zs(t) {
var r, o;
let e = (r = Object.getOwnPropertyDescriptor(t.props, "ref")) == null ? void 0 : r.get, n = e && "isReactWarning" in e && e.isReactWarning;
return n ? t.ref : (e = (o = Object.getOwnPropertyDescriptor(t, "ref")) == null ? void 0 : o.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? t.props.ref : t.props.ref || t.ref);
}
const _e = (t) => {
const e = ni(
F((n, r) => {
const { asChild: o, children: i, ...s } = n;
if (!o)
return ri(t, { ...s, ref: r }, i);
const a = ur.only(i);
if (!oi(a))
return null;
const l = Zs(a);
return ii(a, {
...k(s, a.props),
ref: r ? oe(r, l) : l
});
})
);
return e.displayName = t.displayName || t.name, e;
}, Js = () => {
const t = /* @__PURE__ */ new Map();
return new Proxy(_e, {
apply(e, n, r) {
return _e(r[0]);
},
get(e, n) {
const r = n;
return t.has(r) || t.set(r, _e(r)), t.get(r);
}
});
}, D = Js();
function Qs(t, e) {
const { state: n, send: r, context: o } = t, i = n.matches("mounted", "unmountSuspended");
return {
skip: !o.get("initial"),
present: i,
setNode(s) {
s && r({ type: "NODE.SET", node: s });
},
unmount() {
r({ type: "UNMOUNT" });
}
};
}
var ta = {
props({ props: t }) {
return { ...t, present: !!t.present };
},
initialState({ prop: t }) {
return t("present") ? "mounted" : "unmounted";
},
refs() {
return {
node: null,
styles: null
};
},
context({ bindable: t }) {
return {
unmountAnimationName: t(() => ({ defaultValue: null })),
prevAnimationName: t(() => ({ defaultValue: null })),
present: t(() => ({ defaultValue: !1 })),
initial: t(() => ({
sync: !0,
defaultValue: !1
}))
};
},
exit: ["clearInitial", "cleanupNode"],
watch({ track: t, action: e, prop: n }) {
t([() => n("present")], () => {
e(["setInitial", "syncPresence"]);
});
},
on: {
"NODE.SET": {
actions: ["setNode", "setStyles"]
}
},
states: {
mounted: {
on: {
UNMOUNT: {
target: "unmounted",
actions: ["clearPrevAnimationName", "invokeOnExitComplete"]
},
"UNMOUNT.SUSPEND": {
target: "unmountSuspended"
}
}
},
unmountSuspended: {
effects: ["trackAnimationEvents"],
on: {
MOUNT: {
target: "mounted",
actions: ["setPrevAnimationName"]
},
UNMOUNT: {
target: "unmounted",
actions: ["clearPrevAnimationName", "invokeOnExitComplete"]
}
}
},
unmounted: {
on: {
MOUNT: {
target: "mounted",
actions: ["setPrevAnimationName"]
}
}
}
},
implementations: {
actions: {
setInitial: ({ context: t }) => {
t.get("initial") || queueMicrotask(() => {
t.set("initial", !0);
});
},
clearInitial: ({ context: t }) => {
t.set("initial", !1);
},
cleanupNode: ({ refs: t }) => {
t.set("node", null), t.set("styles", null);
},
invokeOnExitComplete: ({ prop: t }) => {
var e;
(e = t("onExitComplete")) == null || e();
},
setNode: ({ refs: t, event: e }) => {
t.set("node", e.node);
},
setStyles: ({ refs: t, event: e }) => {
t.set("styles", fn(e.node));
},
syncPresence: ({ context: t, refs: e, send: n, prop: r }) => {
const o = r("present");
if (o)
return n({ type: "MOUNT", src: "presence.changed" });
const i = e.get("node");
if (!o && (i == null ? void 0 : i.ownerDocument.visibilityState) === "hidden")
return n({ type: "UNMOUNT", src: "visibilitychange" });
_(() => {
var a, l;
const s = le(e.get("styles"));
t.set("unmountAnimationName", s), s === "none" || s === t.get("prevAnimationName") || ((a = e.get("styles")) == null ? void 0 : a.display) === "none" || ((l = e.get("styles")) == null ? void 0 : l.animationDuration) === "0s" ? n({ type: "UNMOUNT", src: "presence.changed" }) : n({ type: "UNMOUNT.SUSPEND" });
});
},
setPrevAnimationName: ({ context: t, refs: e }) => {
_(() => {
t.set("prevAnimationName", le(e.get("styles")));
});
},
clearPrevAnimationName: ({ context: t }) => {
t.set("prevAnimationName", null);
}
},
effects: {
trackAnimationEvents: ({ context: t, refs: e, send: n }) => {
const r = e.get("node");
if (!r) return;
const o = (a) => {
var c, d;
(((d = (c = a.composedPath) == null ? void 0 : c.call(a)) == null ? void 0 : d[0]) ?? a.target) === r && t.set("prevAnimationName", le(e.get("styles")));
}, i = (a) => {
const l = le(e.get("styles"));
rt(a) === r && l === t.get("unmountAnimationName") && n({ type: "UNMOUNT", src: "animationend" });
};
r.addEventListener("animationstart", o), r.addEventListener("animationcancel", i), r.addEventListener("animationend", i);
const s = ye(r, { animationFillMode: "forwards" });
return () => {
r.removeEventListener("animationstart", o), r.removeEventListener("animationcancel", i), r.removeEventListener("animationend", i), bn(() => s());
};
}
}
}
};
function le(t) {
return (t == null ? void 0 : t.animationName) || "none";
}
yt()(["onExitComplete", "present", "immediate"]);
function ea(t, e = {}) {
const { sync: n = !1 } = e, r = na(t);
return si(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(...o) => {
var i;
return n ? queueMicrotask(() => {
var s;
return (s = r.current) == null ? void 0 : s.call(r, ...o);
}) : (i = r.current) == null ? void 0 : i.call(r, ...o);
},
[n, r]
);
}
function na(t) {
const e = H(t);
return e.current = t, e;
}
const Ae = (t = {}) => {
const { lazyMount: e, unmountOnExit: n, present: r, skipAnimationOnMount: o = !1, ...i } = t, s = H(!1), a = {
...i,
present: r,
onExitComplete: ea(t.onExitComplete)
}, l = re(ta, a), c = Qs(l);
c.present && (s.current = !0);
const d = !c.present && !s.current && e || n && !c.present && s.current, g = () => ({
"data-state": c.skip && o ? void 0 : r ? "open" : "closed",
hidden: !c.present
});
return {
ref: c.setNode,
getPresenceProps: g,
present: c.present,
unmounted: d
};
}, [ra, Ot] = gt({
name: "DialogContext",
hookName: "useDialogContext",
providerName: "<DialogProvider />"
}), Lr = F((t, e) => {
const n = Ot(), r = Fr(), o = Ae({ ...r, present: n.open }), i = k(n.getBackdropProps(), o.getPresenceProps(), t);
return o.unmounted ? null : /* @__PURE__ */ w(D.div, { ...i, ref: oe(o.ref, e) });
});
Lr.displayName = "DialogBackdrop";
const je = F((t, e) => {
const n = Ot(), r = k(n.getCloseTriggerProps(), t);
return /* @__PURE__ */ w(D.button, { ...r, ref: e });
});
je.displayName = "DialogCloseTrigger";
const [vn, $t] = gt({
name: "PresenceContext",
hookName: "usePresenceContext",
providerName: "<PresenceProvider />"
}), _r = F((t, e) => {
const n = Ot(), r = $t(), o = k(n.getContentProps(), r.getPresenceProps(), t);
return r.unmounted ? null : /* @__PURE__ */ w(D.div, { ...o, ref: oe(r.ref, e) });
});
_r.displayName = "DialogContent";
const Vr = F((t, e) => {
const n = Ot(), r = k(n.getDescriptionProps(), t);
return /* @__PURE__ */ w(D.div, { ...r, ref: e });
});
Vr.displayName = "DialogDescription";
const Br = F((t, e) => {
const n = Ot(), r = k(n.getPositionerProps(), t);
return $t().unmounted ? null : /* @__PURE__ */ w(D.div, { ...r, ref: e });
});
Br.displayName = "DialogPositioner";
const Mr = (t) => Pt()(t, [
"immediate",
"lazyMount",
"onExitComplete",
"present",
"skipAnimationOnMount",
"unmountOnExit"
]);
var wt = (t, e = []) => ({
parts: (...n) => {
if (oa(e))
return wt(t, n);
throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?");
},
extendWith: (...n) => wt(t, [...e, ...n]),
rename: (n) => wt(n, e),
keys: () => e,
build: () => [...new Set(e)].reduce(
(n, r) => Object.assign(n, {
[r]: {
selector: [
`&[data-scope="${Nt(t)}"][data-part="${Nt(r)}"]`,
`& [data-scope="${Nt(t)}"][data-part="${Nt(r)}"]`
].join(", "),
attrs: { "data-scope": Nt(t), "data-part": Nt(r) }
}
}),
{}
)
}), Nt = (t) => t.replace(/([A-Z])([A-Z])/g, "$1-$2").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase(), oa = (t) => t.length === 0, At = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), de = {}, Ve = 0, $r = (t) => t && (t.host || $r(t.parentNode)), ia = (t, e) => e.map((n) => {
if (t.contains(n)) return n;
const r = $r(n);
return r && t.contains(r) ? r : (console.error("[zag-js > ariaHidden] target", n, "in not contained inside", t, ". Doing nothing"), null);
}).filter((n) => !!n), sa = (t) => t.localName === "next-route-announcer" || t.localName === "script" || t.hasAttribute("aria-live") ? !0 : t.matches("[data-live-announcer]"), aa = (t, e) => {
const { parentNode: n, markerName: r, controlAttribute: o } = e, i = ia(n, Array.isArray(t) ? t : [t]);
de[r] || (de[r] = /* @__PURE__ */ new WeakMap());
const s = de[r], a = [], l = /* @__PURE__ */ new Set(), c = new Set(i), d = (f) => {
!f || l.has(f) || (l.add(f), d(f.parentNode));
};
i.forEach(d);
const g = (f) => {
!f || c.has(f) || Array.prototype.forEach.call(f.children, (u) => {
if (l.has(u))
g(u);
else
try {
if (sa(u)) return;
const m = u.getAttribute(o) === "true", h = (At.get(u) || 0) + 1, v = (s.get(u) || 0) + 1;
At.set(u, h), s.set(u, v), a.push(u), h === 1 && m && ue.set(u, !0), v === 1 && u.setAttribute(r, ""), m || u.setAttribute(o, "true");
} catch (p) {
console.error("[zag-js > ariaHidden] cannot operate on ", u, p);
}
});
};
return g(n), l.clear(), Ve++, () => {
a.forEach((f) => {
const u = At.get(f) - 1, p = s.get(f) - 1;
At.set(f, u), s.set(f, p), u || (ue.has(f) || f.removeAttribute(o), ue.delete(f)), p || f.removeAttribute(r);
}), Ve--, Ve || (At = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), de = {});
};
}, ca = (t) => (Array.isArray(t) ? t[0] : t).ownerDocument.body, la = (t, e = ca(t), n = "data-aria-hidden") => {
if (e)
return aa(t, {
parentNode: e,
markerName: n,
controlAttribute: "aria-hidden"
});
}, ua = (t) => {
const e = requestAnimationFrame(() => t());
return () => cancelAnimationFrame(e);
};
function Wr(t, e = {}) {
const { defer: n = !0 } = e, r = n ? ua : (i) => i(), o = [];
return o.push(
r(() => {
const s = (typeof t == "function" ? t() : t).filter(Boolean);
s.length !== 0 && o.push(la(s));
})
), () => {
o.forEach((i) => i == null ? void 0 : i());
};
}
function da(t) {
const e = {
each(n) {
var r;
for (let o = 0; o < ((r = t.frames) == null ? void 0 : r.length); o += 1) {
const i = t.frames[o];
i && n(i);
}
},
addEventListener(n, r, o) {
return e.each((i) => {
try {
i.document.addEventListener(n, r, o);
} catch {
}
}), () => {
try {
e.removeEventListener(n, r, o);
} catch {
}
};
},
removeEventListener(n, r, o) {
e.each((i) => {
try {
i.document.removeEventListener(n, r, o);
} catch {
}
});
}
};
return e;
}
function fa(t) {
const e = t.frameElement != null ? t.parent : null;
return {
addEventListener: (n, r, o) => {
try {
e == null || e.addEventListener(n, r, o);
} catch {
}
return () => {
try {
e == null || e.removeEventListener(n, r, o);
} catch {
}
};
},
removeEventListener: (n, r, o) => {
try {
e == null || e.removeEventListener(n, r, o);
} catch {
}
}
};
}
var Vn = "pointerdown.outside", Bn = "focus.outside";
function ga(t) {
for (const e of t)
if ($(e) && mt(e)) return !0;
return !1;
}
var Ur = (t) => "clientY" in t;
function pa(t, e) {
if (!Ur(e) || !t) return !1;
const n = t.getBoundingClientRect();
return n.width === 0 || n.height === 0 ? !1 : n.top <= e.clientY && e.clientY <= n.top + n.height && n.left <= e.clientX && e.clientX <= n.left + n.width;
}
function ma(t, e) {
return t.y <= e.y && e.y <= t.y + t.height && t.x <= e.x && e.x <= t.x + t.width;
}
function Mn(t, e) {
if (!e || !Ur(t)) return !1;
const n = e.scrollHeight > e.clientHeight, r = n && t.clientX > e.offsetLeft + e.clientWidth, o = e.scrollWidth > e.clientWidth, i = o && t.clientY > e.offsetTop + e.clientHeight, s = {
x: e.offsetLeft,
y: e.offsetTop,
width: e.clientWidth + (n ? 16 : 0),
height: e.clientHeight + (o ? 16 : 0)
}, a = {
x: t.clientX,
y: t.clientY
};
return ma(s, a) ? r || i : !1;
}
function ha(t, e) {
const { exclude: n, onFocusOutside: r, onPointerDownOutside: o, onInteractOutside: i, defer: s } = e;
if (!t) return;
const a = dt(t), l = ft(t), c = da(l), d = fa(l);
function g(x, P) {
if (!$(P) || !P.isConnected || Jt(t, P) || pa(t, x)) return !1;
const O = a.querySelector(`[aria-controls="${t.id}"]`);
if (O) {
const y = He(O);
if (Mn(x, y)) return !1;
}
const b = He(t);
return Mn(x, b) ? !1 : !(n != null && n(P));
}
const f = /* @__PURE__ */ new Set(), u = Bt(t == null ? void 0 : t.getRootNode());
function p(x) {
function P(O) {
var V;
const b = s && !In() ? _ : (B) => B(), y = O ?? x, N = ((V = y == null ? void 0 : y.composedPath) == null ? void 0 : V.call(y)) ?? [y == null ? void 0 : y.target];
b(() => {
const B = u ? N[0] : rt(x);
if (!(!t || !g(x, B))) {
if (o || i) {
const M = $e(o, i);
t.addEventListener(Vn, M, { once: !0 });
}
$n(t, Vn, {
bubbles: !1,
cancelable: !0,
detail: {
originalEvent: y,
contextmenu: os(y),
focusable: ga(N),
target: B
}
});
}
});
}
x.pointerType === "touch" ? (f.forEach((O) => O()), f.add(z(a, "click", P, { once: !0 })), f.add(d.addEventListener("click", P, { once: !0 })), f.add(c.addEventListener("click", P, { once: !0 }))) : P();
}
const m = /* @__PURE__ */ new Set(), h = setTimeout(() => {
m.add(z(a, "pointerdown", p, !0)), m.add(d.addEventListener("pointerdown", p, !0)), m.add(c.addEventListener("pointerdown", p, !0));
}, 0);
function v(x) {
(s ? _ : (O) => O())(() => {
const O = rt(x);
if (!(!t || !g(x, O))) {
if (r || i) {
const b = $e(r, i);
t.addEventListener(Bn, b, { once: !0 });
}
$n(t, Bn, {
bubbles: !1,
cancelable: !0,
detail: {
originalEvent: x,
contextmenu: !1,
focusable: mt(O),
target: O
}
});
}
});
}
return In() || (m.add(z(a, "focusin", v, !0)), m.add(d.addEventListener("focusin", v, !0)), m.add(c.addEventListener("focusin", v, !0))), () => {
clearTimeout(h), f.forEach((x) => x()), m.forEach((x) => x());
};
}
function ba(t, e) {
const { defer: n } = e, r = n ? _ : (i) => i(), o = [];
return o.push(
r(() => {
const i = typeof t == "function" ? t() : t;
o.push(ha(i, e));
})
), () => {
o.forEach((i) => i == null ? void 0 : i());
};
}
function $n(t, e, n) {
const r = t.ownerDocument.defaultView || window, o = new r.CustomEvent(e, n);
return t.dispatchEvent(o);
}
function va(t, e) {
const n = (r) => {
r.key === "Escape" && (r.isComposing || e == null || e(r));
};
return z(dt(t), "keydown", n, { capture: !0 });
}
var Z = {
layers: [],
branches: [],
count() {
return this.layers.length;
},
pointerBlockingLayers() {
return this.layers.filter((t) => t.pointerBlocking);
},
topMostPointerBlockingLayer() {
return [...this.pointerBlockingLayers()].slice(-1)[0];
},
hasPointerBlockingLayer() {
return this.pointerBlockingLayers().length > 0;
},
isBelowPointerBlockingLayer(t) {
var r;
const e = this.indexOf(t), n = this.topMostPointerBlockingLayer() ? this.indexOf((r = this.topMostPointerBlockingLayer()) == null ? void 0 : r.node) : -1;
return e < n;
},
isTopMost(t) {
const e = this.layers[this.count() - 1];
return (e == null ? void 0 : e.node) === t;
},
getNestedLayers(t) {
return Array.from(this.layers).slice(this.indexOf(t) + 1);
},
isInNestedLayer(t, e) {
return this.getNestedLayers(t).some((n) => Jt(n.node, e));
},
isInBranch(t) {
return Array.from(this.branches).some((e) => Jt(e, t));
},
add(t) {
const e = this.layers.push(t);
t.node.style.setProperty("--layer-index", `${e}`);
},
addBranch(t) {
this.branches.push(t);
},
remove(t) {
const e = this.indexOf(t);
e < 0 || (e < this.count() - 1 && this.getNestedLayers(t).forEach((r) => r.dismiss()), this.layers.splice(e, 1), t.style.removeProperty("--layer-index"));
},
removeBranch(t) {
const e = this.branches.indexOf(t);
e >= 0 && this.branches.splice(e, 1);
},
indexOf(t) {
return this.layers.findIndex((e) => e.node === t);
},
dismiss(t) {
var e;
(e = this.layers[this.indexOf(t)]) == null || e.dismiss();
},
clear() {
this.remove(this.layers[0].node);
}
}, Wn;
function Un() {
Z.layers.forEach(({ node: t }) => {
t.style.pointerEvents = Z.isBelowPointerBlockingLayer(t) ? "none" : "auto";
});
}
function ya(t) {
t.style.pointerEvents = "";
}
function xa(t, e) {
const n = dt(t), r = [];
if (Z.hasPointerBlockingLayer() && !n.body.hasAttribute("data-inert") && (Wn = document.body.style.pointerEvents, queueMicrotask(() => {
n.body.style.pointerEvents = "none", n.body.setAttribute("data-inert", "");
})), e) {
const o = $s(e, (i) => {
r.push(ye(i, { pointerEvents: "auto" }));
});
r.push(o);
}
return () => {
Z.hasPointerBlockingLayer() || (queueMicrotask(() => {
n.body.style.pointerEvents = Wn, n.body.removeAttribute("data-inert"), n.body.style.length === 0 && n.body.removeAttribute("style");
}), r.forEach((o) => o()));
};
}
function wa(t, e) {
const { warnOnMissingNode: n = !0 } = e;
if (n && !t) {
Ue("[@zag-js/dismissable] node is `null` or `undefined`");
return;
}
if (!t)
return;
const { onDismiss: r, pointerBlocking: o, exclude: i, debug: s } = e, a = { dismiss: r, node: t, pointerBlocking: o };
Z.add(a), Un();
function l(u) {
var m, h;
const p = rt(u.detail.originalEvent);
Z.isBelowPointerBlockingLayer(t) || Z.isInBranch(p) || ((m = e.onPointerDownOutside) == null || m.call(e, u), (h = e.onInteractOutside) == null || h.call(e, u), !u.defaultPrevented && (s && console.log("onPointerDownOutside:", u.detail.originalEvent), r == null || r()));
}
function c(u) {
var m, h;
const p = rt(u.detail.originalEvent);
Z.isInBranch(p) || ((m = e.onFocusOutside) == null || m.call(e, u), (h = e.onInteractOutside) == null || h.call(e, u), !u.defaultPrevented && (s && console.log("onFocusOutside:", u.detail.originalEvent), r == null || r()));
}
function d(u) {
var p;
Z.isTopMost(t) && ((p = e.onEscapeKeyDown) == null || p.call(e, u), !u.defaultPrevented && r && (u.preventDefault(), r()));
}
function g(u) {
var v;