@lunalytics/ui
Version:
React based component library created to be used in Lunalytics
1,729 lines • 228 kB
JavaScript
import './assets/index.css';var Vi = Object.defineProperty;
var Bi = (e, t, n) => t in e ? Vi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var Me = (e, t, n) => Bi(e, typeof t != "symbol" ? t + "" : t, n);
import { jsx as x, jsxs as re, Fragment as Yr } from "react/jsx-runtime";
import * as u from "react";
import vt, { createContext as _i, useState as zr, useEffect as qr, useContext as Hi, useRef as Ui, useLayoutEffect as $i } from "react";
import * as nt from "react-dom";
const Gr = _i({
selected: [],
setSelected: () => {
},
showMultiple: !1,
dark: !1
}), Wi = ({
children: e,
defaultExpandedKeys: t = [],
handleChange: n,
showMultiple: o = !1,
dark: s = !1,
...r
}) => {
const [i, c] = zr(t);
return qr(() => {
n == null || n(i);
}, [i, n]), /* @__PURE__ */ x("div", { className: "luna-accordion-list", ...r, children: /* @__PURE__ */ x(
Gr.Provider,
{
value: { selected: i, setSelected: c, showMultiple: o, dark: s },
children: e
}
) });
};
Wi.displayName = "Accordion";
function ji(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var Wn = { exports: {} };
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
var tr;
function Ki() {
return tr || (tr = 1, function(e) {
(function() {
var t = {}.hasOwnProperty;
function n() {
for (var r = "", i = 0; i < arguments.length; i++) {
var c = arguments[i];
c && (r = s(r, o(c)));
}
return r;
}
function o(r) {
if (typeof r == "string" || typeof r == "number")
return r;
if (typeof r != "object")
return "";
if (Array.isArray(r))
return n.apply(null, r);
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
return r.toString();
var i = "";
for (var c in r)
t.call(r, c) && r[c] && (i = s(i, c));
return i;
}
function s(r, i) {
return i ? r ? r + " " + i : r + i : r;
}
e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
})();
}(Wn)), Wn.exports;
}
var Yi = Ki();
const Be = /* @__PURE__ */ ji(Yi);
var Xr = {
color: void 0,
size: void 0,
className: void 0,
style: void 0,
attr: void 0
}, nr = vt.createContext && /* @__PURE__ */ vt.createContext(Xr), zi = ["attr", "size", "title"];
function qi(e, t) {
if (e == null) return {};
var n = Gi(e, t), o, s;
if (Object.getOwnPropertySymbols) {
var r = Object.getOwnPropertySymbols(e);
for (s = 0; s < r.length; s++)
o = r[s], !(t.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(e, o) && (n[o] = e[o]);
}
return n;
}
function Gi(e, t) {
if (e == null) return {};
var n = {};
for (var o in e)
if (Object.prototype.hasOwnProperty.call(e, o)) {
if (t.indexOf(o) >= 0) continue;
n[o] = e[o];
}
return n;
}
function ln() {
return ln = Object.assign ? Object.assign.bind() : function(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t];
for (var o in n)
Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
}
return e;
}, ln.apply(this, arguments);
}
function or(e, t) {
var n = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
t && (o = o.filter(function(s) {
return Object.getOwnPropertyDescriptor(e, s).enumerable;
})), n.push.apply(n, o);
}
return n;
}
function an(e) {
for (var t = 1; t < arguments.length; t++) {
var n = arguments[t] != null ? arguments[t] : {};
t % 2 ? or(Object(n), !0).forEach(function(o) {
Xi(e, o, n[o]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : or(Object(n)).forEach(function(o) {
Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(n, o));
});
}
return e;
}
function Xi(e, t, n) {
return t = Zi(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
}
function Zi(e) {
var t = Ji(e, "string");
return typeof t == "symbol" ? t : t + "";
}
function Ji(e, t) {
if (typeof e != "object" || !e) return e;
var n = e[Symbol.toPrimitive];
if (n !== void 0) {
var o = n.call(e, t);
if (typeof o != "object") return o;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (t === "string" ? String : Number)(e);
}
function Zr(e) {
return e && e.map((t, n) => /* @__PURE__ */ vt.createElement(t.tag, an({
key: n
}, t.attr), Zr(t.child)));
}
function wn(e) {
return (t) => /* @__PURE__ */ vt.createElement(Qi, ln({
attr: an({}, e.attr)
}, t), Zr(e.child));
}
function Qi(e) {
var t = (n) => {
var {
attr: o,
size: s,
title: r
} = e, i = qi(e, zi), c = s || n.size || "1em", a;
return n.className && (a = n.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ vt.createElement("svg", ln({
stroke: "currentColor",
fill: "currentColor",
strokeWidth: "0"
}, n.attr, o, i, {
className: a,
style: an(an({
color: e.color || n.color
}, n.style), e.style),
height: c,
width: c,
xmlns: "http://www.w3.org/2000/svg"
}), r && /* @__PURE__ */ vt.createElement("title", null, r), e.children);
};
return nr !== void 0 ? /* @__PURE__ */ vt.createElement(nr.Consumer, null, (n) => t(n)) : t(Xr);
}
function ec(e) {
return wn({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z" }, child: [] }] })(e);
}
const tc = ({
children: e,
id: t,
title: n,
subtitle: o,
tag: s,
tagColor: r,
...i
}) => {
var h;
const { selected: c, setSelected: a, showMultiple: l, dark: f } = Hi(Gr), d = c.includes(t), g = Ui(null), p = Be("luna-accordion-list-item", {
"luna-accordion-list-item-dark": f
}), m = Be("luna-accordion-list-item-tag", r);
return /* @__PURE__ */ re("div", { ...i, id: t, className: p, children: [
/* @__PURE__ */ re("header", { role: "button", onClick: () => {
a(
l ? d ? c.filter((v) => v !== t) : [...c, t] : d ? [] : [t]
);
}, children: [
/* @__PURE__ */ re("div", { style: { flex: 1 }, children: [
/* @__PURE__ */ x("div", { className: "luna-accordion-list-item-title", children: n }),
o && /* @__PURE__ */ x("div", { className: "luna-accordion-list-item-subtitle", children: o })
] }),
s && /* @__PURE__ */ x("div", { className: m, children: s }),
/* @__PURE__ */ x(
ec,
{
size: 16,
style: {
transition: "transform 0.3s ease-in-out",
transform: d ? "rotate(0deg)" : "rotate(90deg)"
}
}
)
] }),
/* @__PURE__ */ x(
"div",
{
style: {
height: d ? (h = g.current) == null ? void 0 : h.offsetHeight : 0,
overflowY: "hidden",
transition: "all 0.3s ease-in-out"
},
children: /* @__PURE__ */ x("div", { className: "luna-accordion-list-item-text", ref: g, children: e })
}
)
] });
};
tc.displayName = "AccordionItem";
function Xt(e) {
return wn({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0V0z" }, child: [] }, { tag: "path", attr: { d: "M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z" }, child: [] }] })(e);
}
const nc = {
info: "blue",
success: "green",
warning: "yellow",
error: "red"
}, rr = {
info: () => /* @__PURE__ */ x(Xt, {}),
success: () => /* @__PURE__ */ x(Xt, {}),
warning: () => /* @__PURE__ */ x(Xt, {}),
error: () => /* @__PURE__ */ x(Xt, {})
}, oc = ({
title: e = "info",
hideIcon: t = !1,
description: n,
color: o,
variant: s = "border",
status: r = "info",
...i
}) => {
const c = o || nc[r], a = r ? rr[r] : rr.info, l = Be("luna-alert", {
[c]: c,
[s]: s
});
return /* @__PURE__ */ re("div", { className: l, ...i, children: [
!t && /* @__PURE__ */ x("div", { className: "luna-alert-icon", children: /* @__PURE__ */ x(a, {}) }),
/* @__PURE__ */ re("div", { children: [
/* @__PURE__ */ x("div", { className: "luna-alert-title", children: e }),
n && /* @__PURE__ */ x("div", { children: n })
] })
] });
};
oc.displayName = "Alert";
function rc(e, t) {
const n = {};
for (const o in e) {
const s = e[o];
if (t != null && t.hasOwnProperty(o)) {
const r = t[o](s);
r != null && Object.assign(n, r);
continue;
}
s === !0 ? n[`data-${o.toLowerCase()}`] = "" : s && (n[`data-${o.toLowerCase()}`] = s.toString());
}
return n;
}
const sr = {};
function ut(e, t) {
const n = u.useRef(sr);
return n.current === sr && (n.current = e(t)), n;
}
function lt(e, t, n, o) {
const s = ut(Jr).current;
return ic(s, e, t, n, o) && Qr(s, [e, t, n, o]), s.callback;
}
function sc(e) {
const t = ut(Jr).current;
return cc(t, e) && Qr(t, e), t.callback;
}
function Jr() {
return {
callback: null,
cleanup: null,
refs: []
};
}
function ic(e, t, n, o, s) {
return e.refs[0] !== t || e.refs[1] !== n || e.refs[2] !== o || e.refs[3] !== s;
}
function cc(e, t) {
return e.refs.length !== t.length || e.refs.some((n, o) => n !== t[o]);
}
function Qr(e, t) {
if (e.refs = t, t.every((n) => n == null)) {
e.callback = null;
return;
}
e.callback = (n) => {
if (e.cleanup && (e.cleanup(), e.cleanup = null), n != null) {
const o = Array(t.length).fill(null);
for (let s = 0; s < t.length; s += 1) {
const r = t[s];
if (r != null)
switch (typeof r) {
case "function": {
const i = r(n);
typeof i == "function" && (o[s] = i);
break;
}
case "object": {
r.current = n;
break;
}
}
}
e.cleanup = () => {
for (let s = 0; s < t.length; s += 1) {
const r = t[s];
if (r != null)
switch (typeof r) {
case "function": {
const i = o[s];
typeof i == "function" ? i() : r(null);
break;
}
case "object": {
r.current = null;
break;
}
}
}
};
}
};
}
function uc(e, t) {
return typeof e == "function" ? e(t) : e;
}
const lc = parseInt(u.version, 10);
function es(e) {
return lc >= e;
}
function ts(e, t) {
if (e && !t)
return e;
if (!e && t)
return t;
if (e || t)
return {
...e,
...t
};
}
const Dt = {};
function kt(e, t, n, o, s) {
let r = {
...to(e, Dt)
};
return t && (r = rn(r, t)), n && (r = rn(r, n)), o && (r = rn(r, o)), r;
}
function ac(e) {
if (e.length === 0)
return Dt;
if (e.length === 1)
return to(e[0], Dt);
let t = {
...to(e[0], Dt)
};
for (let n = 1; n < e.length; n += 1)
t = rn(t, e[n]);
return t;
}
function rn(e, t) {
return ns(t) ? t(e) : fc(e, t);
}
function fc(e, t) {
if (!t)
return e;
for (const n in t) {
const o = t[n];
switch (n) {
case "style": {
e[n] = ts(e.style, o);
break;
}
case "className": {
e[n] = os(e.className, o);
break;
}
default:
dc(n, o) ? e[n] = pc(e[n], o) : e[n] = o;
}
}
return e;
}
function dc(e, t) {
const n = e.charCodeAt(0), o = e.charCodeAt(1), s = e.charCodeAt(2);
return n === 111 && o === 110 && s >= 65 && s <= 90 && (typeof t == "function" || typeof t > "u");
}
function ns(e) {
return typeof e == "function";
}
function to(e, t) {
return ns(e) ? e(t) : e ?? Dt;
}
function pc(e, t) {
return t ? e ? (n) => {
if (mc(n)) {
const s = n;
no(s);
const r = t(s);
return s.baseUIHandlerPrevented || e == null || e(s), r;
}
const o = t(n);
return e == null || e(n), o;
} : t : e;
}
function no(e) {
return e.preventBaseUIHandler = () => {
e.baseUIHandlerPrevented = !0;
}, e;
}
function os(e, t) {
return t ? e ? t + " " + e : t : e;
}
function mc(e) {
return e != null && typeof e == "object" && "nativeEvent" in e;
}
const gc = 500, rs = 500, Rn = {
style: {
transition: "none"
}
}, _e = {}, hc = {
fallbackAxisSide: "none"
}, mo = {
fallbackAxisSide: "end"
};
function xe(e, t, n = {}) {
const o = t.render, s = yc(t, n);
if (n.enabled === !1)
return null;
const r = n.state ?? _e;
return bc(e, o, s, r);
}
function yc(e, t = {}) {
const {
className: n,
render: o
} = e, {
state: s = _e,
ref: r,
props: i,
disableStyleHooks: c,
customStyleHookMapping: a,
enabled: l = !0
} = t, f = l ? uc(n, s) : void 0;
let d;
c !== !0 && (d = u.useMemo(() => l ? rc(s, a) : _e, [s, a, l]));
const g = l ? ts(d, Array.isArray(i) ? ac(i) : i) ?? _e : _e;
return typeof document < "u" && (l ? Array.isArray(r) ? g.ref = sc([g.ref, ir(o), ...r]) : g.ref = lt(g.ref, ir(o), r) : lt(null, null)), l ? (f !== void 0 && (g.className = os(g.className, f)), g) : _e;
}
function bc(e, t, n, o) {
if (t) {
if (typeof t == "function")
return t(n, o);
const s = kt(n, t.props);
return s.ref = n.ref, /* @__PURE__ */ u.cloneElement(t, s);
}
if (e && typeof e == "string")
return vc(e, n);
throw new Error("Base UI: Render element or function are not defined.");
}
function vc(e, t) {
return e === "button" ? /* @__PURE__ */ x("button", {
type: "button",
...t
}) : e === "img" ? /* @__PURE__ */ x("img", {
alt: "",
...t
}) : /* @__PURE__ */ u.createElement(e, t);
}
function ir(e) {
return e && typeof e != "function" ? es(19) ? e.props.ref : e.ref : null;
}
const go = /* @__PURE__ */ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (go.displayName = "AvatarRootContext");
function ss() {
const e = u.useContext(go);
if (e === void 0)
throw new Error("Base UI: AvatarRootContext is missing. Avatar parts must be placed within <Avatar.Root>.");
return e;
}
const ho = {
imageLoadingStatus: () => null
}, is = /* @__PURE__ */ u.forwardRef(function(t, n) {
const {
className: o,
render: s,
...r
} = t, [i, c] = u.useState("idle"), a = u.useMemo(() => ({
imageLoadingStatus: i
}), [i]), l = u.useMemo(() => ({
imageLoadingStatus: i,
setImageLoadingStatus: c
}), [i, c]), f = xe("span", t, {
state: a,
ref: n,
props: r,
customStyleHookMapping: ho
});
return /* @__PURE__ */ x(go.Provider, {
value: l,
children: f
});
});
process.env.NODE_ENV !== "production" && (is.displayName = "AvatarRoot");
const jn = u[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)], wc = (
// React 17 doesn't have useInsertionEffect.
jn && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
jn !== u.useLayoutEffect ? jn : (e) => e()
);
function J(e) {
const t = ut(Rc).current;
return t.next = e, wc(t.effect), t.trampoline;
}
function Rc() {
const e = {
next: void 0,
callback: xc,
trampoline: (...t) => {
var n;
return (n = e.callback) == null ? void 0 : n.call(e, ...t);
},
effect: () => {
e.callback = e.next;
}
};
return e;
}
function xc() {
if (process.env.NODE_ENV !== "production")
throw new Error("Base UI: Cannot call an event handler while rendering.");
}
const Ec = () => {
}, ee = typeof document < "u" ? u.useLayoutEffect : Ec, cs = () => {
};
function Cc(e, {
referrerPolicy: t,
crossOrigin: n
}) {
const [o, s] = u.useState("idle");
return ee(() => {
if (!e)
return s("error"), cs;
let r = !0;
const i = new window.Image(), c = (a) => () => {
r && s(a);
};
return s("loading"), i.onload = c("loaded"), i.onerror = c("error"), t && (i.referrerPolicy = t), i.crossOrigin = n ?? null, i.src = e, () => {
r = !1;
};
}, [e, n, t]), o;
}
const us = /* @__PURE__ */ u.forwardRef(function(t, n) {
const {
className: o,
render: s,
onLoadingStatusChange: r,
referrerPolicy: i,
crossOrigin: c,
...a
} = t, l = ss(), f = Cc(t.src, {
referrerPolicy: i,
crossOrigin: c
}), d = J((m) => {
r == null || r(m), l.setImageLoadingStatus(m);
});
ee(() => {
f !== "idle" && d(f);
}, [f, d]);
const g = u.useMemo(() => ({
imageLoadingStatus: f
}), [f]);
return xe("img", t, {
state: g,
ref: n,
props: a,
customStyleHookMapping: ho,
enabled: f === "loaded"
});
});
process.env.NODE_ENV !== "production" && (us.displayName = "AvatarImage");
const Pc = [];
function ls(e) {
u.useEffect(e, Pc);
}
const At = 0;
class at {
constructor() {
Me(this, "currentId", At);
Me(this, "clear", () => {
this.currentId !== At && (clearTimeout(this.currentId), this.currentId = At);
});
Me(this, "disposeEffect", () => this.clear);
}
static create() {
return new at();
}
/**
* Executes `fn` after `delay`, clearing any previously scheduled call.
*/
start(t, n) {
this.clear(), this.currentId = setTimeout(() => {
this.currentId = At, n();
}, t);
}
isStarted() {
return this.currentId !== At;
}
}
function Le() {
const e = ut(at.create).current;
return ls(e.disposeEffect), e;
}
const as = /* @__PURE__ */ u.forwardRef(function(t, n) {
const {
className: o,
render: s,
delay: r,
...i
} = t, {
imageLoadingStatus: c
} = ss(), [a, l] = u.useState(r === void 0), f = Le();
u.useEffect(() => (r !== void 0 && f.start(r, () => l(!0)), f.clear), [f, r]);
const d = u.useMemo(() => ({
imageLoadingStatus: c
}), [c]);
return xe("span", t, {
state: d,
ref: n,
props: i,
customStyleHookMapping: ho,
enabled: c !== "loaded" && a
});
});
process.env.NODE_ENV !== "production" && (as.displayName = "AvatarFallback");
const Mc = ({ avatar: e, name: t, showName: n = !0, ...o }) => {
var s;
return /* @__PURE__ */ re("div", { className: "luna-avatar-container", ...o, children: [
/* @__PURE__ */ re(is, { children: [
/* @__PURE__ */ x(us, { src: e, className: "luna-avatar" }),
/* @__PURE__ */ x(as, { className: "luna-avatar-default", children: (s = t == null ? void 0 : t.charAt(0)) == null ? void 0 : s.toUpperCase() })
] }),
n && /* @__PURE__ */ x("div", { className: "luna-avatar-username", children: t })
] });
};
Mc.displayName = "Avatar";
const Sc = ({
children: e,
iconLeft: t,
iconRight: n,
color: o = "primary",
variant: s = "solid",
fullWidth: r,
theme: i,
tabIndex: c = 0,
as: a = "div",
...l
}) => {
const f = Be("luna-button", {
[`theme-${i}`]: i,
[o]: o,
[s]: s,
"luna-button-fixed-width": !r
});
return /* @__PURE__ */ re(a, { className: f, tabIndex: c, ...l, children: [
t,
e && /* @__PURE__ */ x("div", { className: "luna-button-content", children: e }),
n
] });
};
Sc.displayName = "Button";
const yo = /* @__PURE__ */ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (yo.displayName = "MenuPositionerContext");
function Oc() {
const e = u.useContext(yo);
if (e === void 0)
throw new Error("Base UI: MenuPositionerContext is missing. MenuPositioner parts must be placed within <Menu.Positioner>.");
return e;
}
const xn = /* @__PURE__ */ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (xn.displayName = "MenuRootContext");
function Rt(e) {
const t = u.useContext(xn);
if (t === void 0 && !e)
throw new Error("Base UI: MenuRootContext is missing. Menu parts must be placed within <Menu.Root>.");
return t;
}
let fn = /* @__PURE__ */ function(e) {
return e.startingStyle = "data-starting-style", e.endingStyle = "data-ending-style", e;
}({});
const Nc = {
[fn.startingStyle]: ""
}, Tc = {
[fn.endingStyle]: ""
}, En = {
transitionStatus(e) {
return e === "starting" ? Nc : e === "ending" ? Tc : null;
}
};
let bo = function(e) {
return e.open = "data-open", e.closed = "data-closed", e[e.startingStyle = fn.startingStyle] = "startingStyle", e[e.endingStyle = fn.endingStyle] = "endingStyle", e.anchorHidden = "data-anchor-hidden", e;
}({}), oo = /* @__PURE__ */ function(e) {
return e.popupOpen = "data-popup-open", e.pressed = "data-pressed", e;
}({});
const Ic = {
[oo.popupOpen]: ""
}, kc = {
[oo.popupOpen]: "",
[oo.pressed]: ""
}, Ac = {
[bo.open]: ""
}, Dc = {
[bo.closed]: ""
}, Lc = {
[bo.anchorHidden]: ""
}, Cn = {
open(e) {
return e ? Ic : null;
}
}, fs = {
open(e) {
return e ? kc : null;
}
}, Xe = {
open(e) {
return e ? Ac : Dc;
},
anchorHidden(e) {
return e ? Lc : null;
}
}, vo = /* @__PURE__ */ u.createContext(void 0);
process.env.NODE_ENV !== "production" && (vo.displayName = "ContextMenuRootContext");
function wo(e = !0) {
const t = u.useContext(vo);
if (t === void 0 && !e)
throw new Error("Base UI: ContextMenuRootContext is missing. ContextMenu parts must be placed within <ContextMenu.Root>.");
return t;
}
function Pn() {
return typeof window < "u";
}
function dt(e) {
return ds(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function Se(e) {
var t;
return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function Ze(e) {
var t;
return (t = (ds(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function ds(e) {
return Pn() ? e instanceof Node || e instanceof Se(e).Node : !1;
}
function ge(e) {
return Pn() ? e instanceof Element || e instanceof Se(e).Element : !1;
}
function Ee(e) {
return Pn() ? e instanceof HTMLElement || e instanceof Se(e).HTMLElement : !1;
}
function ro(e) {
return !Pn() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof Se(e).ShadowRoot;
}
const Fc = /* @__PURE__ */ new Set(["inline", "contents"]);
function _t(e) {
const {
overflow: t,
overflowX: n,
overflowY: o,
display: s
} = Ue(e);
return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Fc.has(s);
}
const Vc = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Bc(e) {
return Vc.has(dt(e));
}
const _c = [":popover-open", ":modal"];
function Mn(e) {
return _c.some((t) => {
try {
return e.matches(t);
} catch {
return !1;
}
});
}
const Hc = ["transform", "translate", "scale", "rotate", "perspective"], Uc = ["transform", "translate", "scale", "rotate", "perspective", "filter"], $c = ["paint", "layout", "strict", "content"];
function Ro(e) {
const t = Sn(), n = ge(e) ? Ue(e) : e;
return Hc.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Uc.some((o) => (n.willChange || "").includes(o)) || $c.some((o) => (n.contain || "").includes(o));
}
function Wc(e) {
let t = Ge(e);
for (; Ee(t) && !ze(t); ) {
if (Ro(t))
return t;
if (Mn(t))
return null;
t = Ge(t);
}
return null;
}
function Sn() {
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const jc = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function ze(e) {
return jc.has(dt(e));
}
function Ue(e) {
return Se(e).getComputedStyle(e);
}
function On(e) {
return ge(e) ? {
scrollLeft: e.scrollLeft,
scrollTop: e.scrollTop
} : {
scrollLeft: e.scrollX,
scrollTop: e.scrollY
};
}
function Ge(e) {
if (dt(e) === "html")
return e;
const t = (
// Step into the shadow DOM of the parent of a slotted node.
e.assignedSlot || // DOM Element detected.
e.parentNode || // ShadowRoot detected.
ro(e) && e.host || // Fallback.
Ze(e)
);
return ro(t) ? t.host : t;
}
function ps(e) {
const t = Ge(e);
return ze(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Ee(t) && _t(t) ? t : ps(t);
}
function rt(e, t, n) {
var o;
t === void 0 && (t = []), n === void 0 && (n = !0);
const s = ps(e), r = s === ((o = e.ownerDocument) == null ? void 0 : o.body), i = Se(s);
if (r) {
const c = so(i);
return t.concat(i, i.visualViewport || [], _t(s) ? s : [], c && n ? rt(c) : []);
}
return t.concat(s, rt(s, [], n));
}
function so(e) {
return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function Te(e) {
const t = ut(Kc, e).current;
return t.next = e, ee(t.effect), t;
}
function Kc(e) {
const t = {
current: e,
next: e,
effect: () => {
t.current = t.next;
}
};
return t;
}
const Ht = typeof navigator < "u", Kn = qc(), ms = Xc(), gs = Gc(), hs = typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter:none"), Yc = (
// iPads can claim to be MacIntel
Kn.platform === "MacIntel" && Kn.maxTouchPoints > 1 ? !0 : /iP(hone|ad|od)|iOS/.test(Kn.platform)
), ys = Ht && /apple/i.test(navigator.vendor), io = Ht && /android/i.test(ms) || /android/i.test(gs), zc = Ht && ms.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints, bs = gs.includes("jsdom/");
function qc() {
if (typeof navigator > "u")
return {
platform: "",
maxTouchPoints: -1
};
const e = navigator.userAgentData;
return e != null && e.platform ? {
platform: e.platform,
maxTouchPoints: navigator.maxTouchPoints
} : {
platform: navigator.platform,
maxTouchPoints: navigator.maxTouchPoints
};
}
function Gc() {
if (!Ht)
return "";
const e = navigator.userAgentData;
return e && Array.isArray(e.brands) ? e.brands.map(({
brand: t,
version: n
}) => `${t}/${n}`).join(" ") : navigator.userAgent;
}
function Xc() {
if (!Ht)
return "";
const e = navigator.userAgentData;
return e != null && e.platform ? e.platform : navigator.platform;
}
const co = "data-base-ui-focusable", vs = "active", ws = "selected", Zc = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])", st = "ArrowLeft", it = "ArrowRight", xo = "ArrowUp", Ut = "ArrowDown";
function He(e) {
var n;
let t = e.activeElement;
for (; ((n = t == null ? void 0 : t.shadowRoot) == null ? void 0 : n.activeElement) != null; )
t = t.shadowRoot.activeElement;
return t;
}
function de(e, t) {
var o;
if (!e || !t)
return !1;
const n = (o = t.getRootNode) == null ? void 0 : o.call(t);
if (e.contains(t))
return !0;
if (n && ro(n)) {
let s = t;
for (; s; ) {
if (e === s)
return !0;
s = s.parentNode || s.host;
}
}
return !1;
}
function Ve(e) {
return "composedPath" in e ? e.composedPath()[0] : e.target;
}
function Yn(e, t) {
if (t == null)
return !1;
if ("composedPath" in e)
return e.composedPath().includes(t);
const n = e;
return n.target != null && t.contains(n.target);
}
function Jc(e) {
return e.matches("html,body");
}
function ae(e) {
return (e == null ? void 0 : e.ownerDocument) || document;
}
function Rs(e) {
return Ee(e) && e.matches(Zc);
}
function uo(e) {
return e ? e.getAttribute("role") === "combobox" && Rs(e) : !1;
}
function Qc(e) {
if (!e || bs)
return !0;
try {
return e.matches(":focus-visible");
} catch {
return !0;
}
}
function dn(e) {
return e ? e.hasAttribute(co) ? e : e.querySelector(`[${co}]`) || e : null;
}
function ct(e, t, n = !0) {
return e.filter((s) => {
var r;
return s.parentId === t && (!n || ((r = s.context) == null ? void 0 : r.open));
}).flatMap((s) => [s, ...ct(e, s.id, n)]);
}
function eu(e, t) {
let n, o = -1;
function s(r, i) {
i > o && (n = r, o = i), ct(e, r).forEach((a) => {
s(a.id, i + 1);
});
}
return s(t, 0), e.find((r) => r.id === n);
}
function cr(e, t) {
var s;
let n = [], o = (s = e.find((r) => r.id === t)) == null ? void 0 : s.parentId;
for (; o; ) {
const r = e.find((i) => i.id === o);
o = r == null ? void 0 : r.parentId, r && (n = n.concat(r));
}
return n;
}
function Ne(e) {
e.preventDefault(), e.stopPropagation();
}
function tu(e) {
return "nativeEvent" in e;
}
function xs(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : io && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function Es(e) {
return bs ? !1 : !io && e.width === 0 && e.height === 0 || io && e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse" || // iOS VoiceOver returns 0.333• for width/height.
e.width < 1 && e.height < 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "touch";
}
function Nt(e, t) {
const n = ["mouse", "pen"];
return t || n.push("", void 0), n.includes(e);
}
const nu = ["top", "right", "bottom", "left"], ft = Math.min, Fe = Math.max, pn = Math.round, Mt = Math.floor, qe = (e) => ({
x: e,
y: e
}), ou = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
}, ru = {
start: "end",
end: "start"
};
function lo(e, t, n) {
return Fe(e, ft(t, n));
}
function tt(e, t) {
return typeof e == "function" ? e(t) : e;
}
function $e(e) {
return e.split("-")[0];
}
function pt(e) {
return e.split("-")[1];
}
function Eo(e) {
return e === "x" ? "y" : "x";
}
function Co(e) {
return e === "y" ? "height" : "width";
}
const su = /* @__PURE__ */ new Set(["top", "bottom"]);
function je(e) {
return su.has($e(e)) ? "y" : "x";
}
function Po(e) {
return Eo(je(e));
}
function iu(e, t, n) {
n === void 0 && (n = !1);
const o = pt(e), s = Po(e), r = Co(s);
let i = s === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
return t.reference[r] > t.floating[r] && (i = mn(i)), [i, mn(i)];
}
function cu(e) {
const t = mn(e);
return [ao(e), t, ao(t)];
}
function ao(e) {
return e.replace(/start|end/g, (t) => ru[t]);
}
const ur = ["left", "right"], lr = ["right", "left"], uu = ["top", "bottom"], lu = ["bottom", "top"];
function au(e, t, n) {
switch (e) {
case "top":
case "bottom":
return n ? t ? lr : ur : t ? ur : lr;
case "left":
case "right":
return t ? uu : lu;
default:
return [];
}
}
function fu(e, t, n, o) {
const s = pt(e);
let r = au($e(e), n === "start", o);
return s && (r = r.map((i) => i + "-" + s), t && (r = r.concat(r.map(ao)))), r;
}
function mn(e) {
return e.replace(/left|right|bottom|top/g, (t) => ou[t]);
}
function du(e) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...e
};
}
function Cs(e) {
return typeof e != "number" ? du(e) : {
top: e,
right: e,
bottom: e,
left: e
};
}
function gn(e) {
const {
x: t,
y: n,
width: o,
height: s
} = e;
return {
width: o,
height: s,
top: n,
left: t,
right: t + o,
bottom: n + s,
x: t,
y: n
};
}
function Zt(e, t, n) {
return Math.floor(e / t) !== n;
}
function Lt(e, t) {
return t < 0 || t >= e.current.length;
}
function zn(e, t) {
return De(e, {
disabledIndices: t
});
}
function ar(e, t) {
return De(e, {
decrement: !0,
startingIndex: e.current.length,
disabledIndices: t
});
}
function De(e, {
startingIndex: t = -1,
decrement: n = !1,
disabledIndices: o,
amount: s = 1
} = {}) {
let r = t;
do
r += n ? -s : s;
while (r >= 0 && r <= e.current.length - 1 && sn(e, r, o));
return r;
}
function pu(e, {
event: t,
orientation: n,
loop: o,
rtl: s,
cols: r,
disabledIndices: i,
minIndex: c,
maxIndex: a,
prevIndex: l,
stopEvent: f = !1
}) {
let d = l;
if (t.key === xo) {
if (f && Ne(t), l === -1)
d = a;
else if (d = De(e, {
startingIndex: d,
amount: r,
decrement: !0,
disabledIndices: i
}), o && (l - r < c || d < 0)) {
const g = l % r, p = a % r, m = a - (p - g);
p === g ? d = a : d = p > g ? m : m - r;
}
Lt(e, d) && (d = l);
}
if (t.key === Ut && (f && Ne(t), l === -1 ? d = c : (d = De(e, {
startingIndex: l,
amount: r,
disabledIndices: i
}), o && l + r > a && (d = De(e, {
startingIndex: l % r - r,
amount: r,
disabledIndices: i
}))), Lt(e, d) && (d = l)), n === "both") {
const g = Mt(l / r);
t.key === (s ? st : it) && (f && Ne(t), l % r !== r - 1 ? (d = De(e, {
startingIndex: l,
disabledIndices: i
}), o && Zt(d, r, g) && (d = De(e, {
startingIndex: l - l % r - 1,
disabledIndices: i
}))) : o && (d = De(e, {
startingIndex: l - l % r - 1,
disabledIndices: i
})), Zt(d, r, g) && (d = l)), t.key === (s ? it : st) && (f && Ne(t), l % r !== 0 ? (d = De(e, {
startingIndex: l,
decrement: !0,
disabledIndices: i
}), o && Zt(d, r, g) && (d = De(e, {
startingIndex: l + (r - l % r),
decrement: !0,
disabledIndices: i
}))) : o && (d = De(e, {
startingIndex: l + (r - l % r),
decrement: !0,
disabledIndices: i
})), Zt(d, r, g) && (d = l));
const p = Mt(a / r) === g;
Lt(e, d) && (o && p ? d = t.key === (s ? it : st) ? a : De(e, {
startingIndex: l - l % r - 1,
disabledIndices: i
}) : d = l);
}
return d;
}
function mu(e, t, n) {
const o = [];
let s = 0;
return e.forEach(({
width: r,
height: i
}, c) => {
if (r > t && process.env.NODE_ENV !== "production")
throw new Error(`[Floating UI]: Invalid grid - item width at index ${c} is greater than grid columns`);
let a = !1;
for (n && (s = 0); !a; ) {
const l = [];
for (let f = 0; f < r; f += 1)
for (let d = 0; d < i; d += 1)
l.push(s + f + d * t);
s % t + r <= t && l.every((f) => o[f] == null) ? (l.forEach((f) => {
o[f] = c;
}), a = !0) : s += 1;
}
}), [...o];
}
function gu(e, t, n, o, s) {
if (e === -1)
return -1;
const r = n.indexOf(e), i = t[e];
switch (s) {
case "tl":
return r;
case "tr":
return i ? r + i.width - 1 : r;
case "bl":
return i ? r + (i.height - 1) * o : r;
case "br":
return n.lastIndexOf(e);
default:
return -1;
}
}
function hu(e, t) {
return t.flatMap((n, o) => e.includes(n) ? [o] : []);
}
function sn(e, t, n) {
if (typeof n == "function")
return n(t);
if (n)
return n.includes(t);
const o = e.current[t];
return o == null || o.hasAttribute("disabled") || o.getAttribute("aria-disabled") === "true";
}
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var yu = ["input:not([inert])", "select:not([inert])", "textarea:not([inert])", "a[href]:not([inert])", "button:not([inert])", "[tabindex]:not(slot):not([inert])", "audio[controls]:not([inert])", "video[controls]:not([inert])", '[contenteditable]:not([contenteditable="false"]):not([inert])', "details>summary:first-of-type:not([inert])", "details:not([inert])"], hn = /* @__PURE__ */ yu.join(","), Ps = typeof Element > "u", Tt = Ps ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, yn = !Ps && Element.prototype.getRootNode ? function(e) {
var t;
return e == null || (t = e.getRootNode) === null || t === void 0 ? void 0 : t.call(e);
} : function(e) {
return e == null ? void 0 : e.ownerDocument;
}, bn = function e(t, n) {
var o;
n === void 0 && (n = !0);
var s = t == null || (o = t.getAttribute) === null || o === void 0 ? void 0 : o.call(t, "inert"), r = s === "" || s === "true", i = r || n && t && e(t.parentNode);
return i;
}, bu = function(t) {
var n, o = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
return o === "" || o === "true";
}, Ms = function(t, n, o) {
if (bn(t))
return [];
var s = Array.prototype.slice.apply(t.querySelectorAll(hn));
return n && Tt.call(t, hn) && s.unshift(t), s = s.filter(o), s;
}, Ss = function e(t, n, o) {
for (var s = [], r = Array.from(t); r.length; ) {
var i = r.shift();
if (!bn(i, !1))
if (i.tagName === "SLOT") {
var c = i.assignedElements(), a = c.length ? c : i.children, l = e(a, !0, o);
o.flatten ? s.push.apply(s, l) : s.push({
scopeParent: i,
candidates: l
});
} else {
var f = Tt.call(i, hn);
f && o.filter(i) && (n || !t.includes(i)) && s.push(i);
var d = i.shadowRoot || // check for an undisclosed shadow
typeof o.getShadowRoot == "function" && o.getShadowRoot(i), g = !bn(d, !1) && (!o.shadowRootFilter || o.shadowRootFilter(i));
if (d && g) {
var p = e(d === !0 ? i.children : d.children, !0, o);
o.flatten ? s.push.apply(s, p) : s.push({
scopeParent: i,
candidates: p
});
} else
r.unshift.apply(r, i.children);
}
}
return s;
}, Os = function(t) {
return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, Ns = function(t) {
if (!t)
throw new Error("No node provided");
return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || bu(t)) && !Os(t) ? 0 : t.tabIndex;
}, vu = function(t, n) {
var o = Ns(t);
return o < 0 && n && !Os(t) ? 0 : o;
}, wu = function(t, n) {
return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, Ts = function(t) {
return t.tagName === "INPUT";
}, Ru = function(t) {
return Ts(t) && t.type === "hidden";
}, xu = function(t) {
var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(o) {
return o.tagName === "SUMMARY";
});
return n;
}, Eu = function(t, n) {
for (var o = 0; o < t.length; o++)
if (t[o].checked && t[o].form === n)
return t[o];
}, Cu = function(t) {
if (!t.name)
return !0;
var n = t.form || yn(t), o = function(c) {
return n.querySelectorAll('input[type="radio"][name="' + c + '"]');
}, s;
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
s = o(window.CSS.escape(t.name));
else
try {
s = o(t.name);
} catch (i) {
return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", i.message), !1;
}
var r = Eu(s, t.form);
return !r || r === t;
}, Pu = function(t) {
return Ts(t) && t.type === "radio";
}, Mu = function(t) {
return Pu(t) && !Cu(t);
}, Su = function(t) {
var n, o = t && yn(t), s = (n = o) === null || n === void 0 ? void 0 : n.host, r = !1;
if (o && o !== t) {
var i, c, a;
for (r = !!((i = s) !== null && i !== void 0 && (c = i.ownerDocument) !== null && c !== void 0 && c.contains(s) || t != null && (a = t.ownerDocument) !== null && a !== void 0 && a.contains(t)); !r && s; ) {
var l, f, d;
o = yn(s), s = (l = o) === null || l === void 0 ? void 0 : l.host, r = !!((f = s) !== null && f !== void 0 && (d = f.ownerDocument) !== null && d !== void 0 && d.contains(s));
}
}
return r;
}, fr = function(t) {
var n = t.getBoundingClientRect(), o = n.width, s = n.height;
return o === 0 && s === 0;
}, Ou = function(t, n) {
var o = n.displayCheck, s = n.getShadowRoot;
if (getComputedStyle(t).visibility === "hidden")
return !0;
var r = Tt.call(t, "details>summary:first-of-type"), i = r ? t.parentElement : t;
if (Tt.call(i, "details:not([open]) *"))
return !0;
if (!o || o === "full" || o === "legacy-full") {
if (typeof s == "function") {
for (var c = t; t; ) {
var a = t.parentElement, l = yn(t);
if (a && !a.shadowRoot && s(a) === !0)
return fr(t);
t.assignedSlot ? t = t.assignedSlot : !a && l !== t.ownerDocument ? t = l.host : t = a;
}
t = c;
}
if (Su(t))
return !t.getClientRects().length;
if (o !== "legacy-full")
return !0;
} else if (o === "non-zero-area")
return fr(t);
return !1;
}, Nu = function(t) {
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
for (var n = t.parentElement; n; ) {
if (n.tagName === "FIELDSET" && n.disabled) {
for (var o = 0; o < n.children.length; o++) {
var s = n.children.item(o);
if (s.tagName === "LEGEND")
return Tt.call(n, "fieldset[disabled] *") ? !0 : !s.contains(t);
}
return !0;
}
n = n.parentElement;
}
return !1;
}, fo = function(t, n) {
return !(n.disabled || // we must do an inert look up to filter out any elements inside an inert ancestor
// because we're limited in the type of selectors we can use in JSDom (see related
// note related to `candidateSelectors`)
bn(n) || Ru(n) || Ou(n, t) || // For a details element with a summary, the summary element gets the focus
xu(n) || Nu(n));
}, po = function(t, n) {
return !(Mu(n) || Ns(n) < 0 || !fo(t, n));
}, Tu = function(t) {
var n = parseInt(t.getAttribute("tabindex"), 10);
return !!(isNaN(n) || n >= 0);
}, Iu = function e(t) {
var n = [], o = [];
return t.forEach(function(s, r) {
var i = !!s.scopeParent, c = i ? s.scopeParent : s, a = vu(c, i), l = i ? e(s.candidates) : c;
a === 0 ? i ? n.push.apply(n, l) : n.push(c) : o.push({
documentOrder: r,
tabIndex: a,
item: s,
isScope: i,
content: l
});
}), o.sort(wu).reduce(function(s, r) {
return r.isScope ? s.push.apply(s, r.content) : s.push(r.content), s;
}, []).concat(n);
}, Nn = function(t, n) {
n = n || {};
var o;
return n.getShadowRoot ? o = Ss([t], n.includeContainer, {
filter: po.bind(null, n),
flatten: !1,
getShadowRoot: n.getShadowRoot,
shadowRootFilter: Tu
}) : o = Ms(t, n.includeContainer, po.bind(null, n)), Iu(o);
}, ku = function(t, n) {
n = n || {};
var o;
return n.getShadowRoot ? o = Ss([t], n.includeContainer, {
filter: fo.bind(null, n),
flatten: !0,
getShadowRoot: n.getShadowRoot
}) : o = Ms(t, n.includeContainer, fo.bind(null, n)), o;
}, Is = function(t, n) {
if (n = n || {}, !t)
throw new Error("No node provided");
return Tt.call(t, hn) === !1 ? !1 : po(n, t);
};
const $t = () => ({
getShadowRoot: !0,
displayCheck: (
// JSDOM does not support the `tabbable` library. To solve this we can
// check if `ResizeObserver` is a real function (not polyfilled), which
// determines if the current environment is JSDOM-like.
typeof ResizeObserver == "function" && ResizeObserver.toString().includes("[native code]") ? "full" : "none"
)
});
function ks(e, t) {
const n = Nn(e, $t()), o = n.length;
if (o === 0)
return;
const s = He(ae(e)), r = n.indexOf(s), i = r === -1 ? t === 1 ? 0 : o - 1 : r + t;
return n[i];
}
function As(e) {
return ks(ae(e).body, 1) || e;
}
function Ds(e) {
return ks(ae(e).body, -1) || e;
}
function Ft(e, t) {
const n = t || e.currentTarget, o = e.relatedTarget;
return !o || !de(n, o);
}
function Au(e) {
Nn(e, $t()).forEach((n) => {
n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
});
}
function dr(e) {
e.querySelectorAll("[data-tabindex]").forEach((n) => {
const o = n.dataset.tabindex;
delete n.dataset.tabindex, o ? n.setAttribute("tabindex", o) : n.removeAttribute("tabindex");
});
}
const Du = {
...u
};
let pr = 0;
function Lu(e, t = "mui") {
const [n, o] = u.useState(e), s = e || n;
return u.useEffect(() => {
n == null && (pr += 1, o(`${t}-${pr}`));
}, [n, t]), s;
}
const mr = Du.useId;
function xt(e, t) {
if (mr !== void 0) {
const n = mr();
return e ?? (t ? `${t}-${n}` : n);
}
return Lu(e, t);
}
function Ls() {
const e = /* @__PURE__ */ new Map();
return {
emit(t, n) {
var o;
(o = e.get(t)) == null || o.forEach((s) => s(n));
},
on(t, n) {
e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
},
off(t, n) {
var o;
(o = e.get(t)) == null || o.delete(n);
}
};
}
const Mo = /* @__PURE__ */ u.createContext(null);
process.env.NODE_ENV !== "production" && (Mo.displayName = "FloatingNodeContext");
const So = /* @__PURE__ */ u.createContext(null);
process.env.NODE_ENV !== "production" && (So.displayName = "FloatingTreeContext");
const Et = () => {
var e;
return ((e = u.useContext(Mo)) == null ? void 0 : e.id) || null;
}, Ke = () => u.useContext(So);
function Fs(e) {
const t = xt(), n = Ke(), s = Et();
return ee(() => {
if (!t)
return;
const r = {
id: t,
parentId: s
};
return n == null || n.addNode(r), () => {
n == null || n.removeNode(r);
};
}, [n, t, s]), t;
}
function Vs(e) {
const {
children: t,
id: n
} = e, o = Et();
return /* @__PURE__ */ x(Mo.Provider, {
value: u.useMemo(() => ({
id: n,
parentId: o
}), [n, o]),
children: t
});
}
function Bs(e) {
const {
children: t
} = e, n = u.useRef([]), o = u.useCallback((i) => {
n.current = [...n.current, i];
}, []), s = u.useCallback((i) => {
n.current = n.current.filter((c) => c !== i);
}, []), [r] = u.useState(() => Ls());
return /* @__PURE__ */ x(So.Provider, {
value: u.useMemo(() => ({
nodesRef: n,
addNode: o,
removeNode: s,
events: r
}), [o, s, r]),
children: t
});
}
function It(e) {
return `data-base-ui-${e}`;
}
const gr = It("safe-polygon");
function cn(e, t, n) {
if (n && !Nt(n))
return 0;
if (typeof e == "number")
return e;
if (typeof e == "function") {
const o = e();
return typeof o == "number" ? o : o == null ? void 0 : o[t];
}
return e == null ? void 0 : e[t];
}
function qn(e) {
return typeof e == "function" ? e() : e;
}
function Tn(e, t = {}) {
const {
open: n,
onOpenChange: o,
dataRef: s,
events: r,
elements: i
} = e, {
enabled: c = !0,
delay: a = 0,
handleClose: l = null,
mouseOnly: f = !1,
restMs: d = 0,
move: g = !0
} = t, p = Ke(), m = Et(), y = Te(l), h = Te(a), v = Te(n), b = Te(d), w = u.useRef(void 0), R = Le(), A = u.useRef(void 0), k = Le(), M = u.useRef(!0), D = u.useRef(!1), O = u.useRef(() => {
}), H = u.useRef(!1), T = J(() => {
var P;
const N = (P = s.current.openEvent) == null ? void 0 : P.type;
return (N == null ? void 0 : N.includes("mouse")) && N !== "mousedown";
});
u.useEffect(() => {
if (!c)
return;
function N({
open: P
}) {
P || (R.clear(), k.clear(), M.current = !0, H.current = !1);
}
return r.on("openchange", N), () => {
r.off("openchange", N);
};
}, [c, r, R, k]), u.useEffect(() => {
if (!c || !y.current || !n)
return;
function N(B) {
T() && o(!1, B, "hover");
}
const P = ae(i.floating).documentElement;
return P.addEventListener("mouseleave", N), () => {
P.removeEventListener("mouseleave", N);
};
}, [i.floating, n, o, c, y, T]);
const L = u.useCallback((N, P = !0, B = "hover") => {
const F = cn(h.current, "close", w.current);
F && !A.current ? R.start(F, () => o(!1, N, B)) : P && (R.clear(), o(!1, N, B));
}, [h, o, R]), S = J(() => {
O.current(), A.current = void 0;
}), I = J(() => {
if (D.current) {
const N = ae(i.floating).body;
N.style.pointerEvents = "", N.removeAttribute(gr), D.current = !1;
}
}), C = J(() => s.current.openEvent ? ["click", "mousedown"].includes(s.current.openEvent.type) : !1);
u.useEffect(() => {
if (!c)
return;
function N(E) {
if (R.clear(), M.current = !1, f && !Nt(w.current) || qn(b.current) > 0 && !cn(h.current, "open"))
return;
const W = cn(h.current, "open", w.current);
W ? R.start(W, () => {
v.current || o(!0, E, "hover");
}) : n || o(!0, E, "hover");
}
function P(E) {
if (C()) {
I();
return;
}
O.current();
const W = ae(i.floating);
if (k.clear(), H.current = !1, y.current && s.current.floatingContext) {
n || R.clear(), A.current = y.current({
...s.current.floatingContext,
tree: p,
x: E.clientX,
y: E.clientY,
onClose() {
I(), S(), C() || L(E, !0, "safe-polygon");
}
});
const z = A.current;
W.addEventListener("mousemove", z), O.current = () => {
W.removeEventListener("mousemove", z);
};
return;
}
(w.current === "touch" ? !de(i.floating, E.relatedTarget) : !0) && L(E);
}
function B(E) {
var W;
C() || s.current.floatingContext && ((W = y.current) == null || W.call(y, {
...s.current.floatingContext,
tree: p,
x: E.clientX,
y: E.clientY,
onClose() {
I(), S(), C() || L(E);
}
})(E));
}
function F() {
R.clear();
}
function G(E) {
C() || L(E, !1);
}
if (ge(i.domReference)) {
const E = i.domReference, W = i.floating;
return n && E.addEventListener("mouseleave", B), g && E.addEventListener("mousemove", N, {
once: !0
}), E.addEventListener("mouseenter", N), E.addEventListener("mouseleave", P), W && (W.addEventListener("mouseleave", B), W.addEventListener("mouseenter", F), W.addEventListener("mouseleave", G)), () => {
n && E.removeEventListener("mouseleave", B), g && E.removeEventListener("mousemove", N), E.removeEventListener("mouseenter", N), E.removeEventListener("mouseleave", P),