UNPKG

@lunalytics/ui

Version:

React based component library created to be used in Lunalytics

3,466 lines 108 kB
var wr = Object.defineProperty;
var Rr = (e, t, n) => t in e ? wr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var ue = (e, t, n) => Rr(e, typeof t != "symbol" ? t + "" : t, n);
import * as h from "react";
import Pn, { useLayoutEffect as xr } from "react";
import { d as Dn, k as Er, c as Le, b as Q, a as z, T as _n } from "./useTimeout-BZrhyGBQ.js";
import { jsx as Ae, jsxs as Or } from "react/jsx-runtime";
function Ii({
  controlled: e,
  default: t,
  name: n,
  state: r = "value"
}) {
  const {
    current: o
  } = h.useRef(e !== void 0), [i, s] = h.useState(t), l = o ? e : i;
  if (process.env.NODE_ENV !== "production") {
    h.useEffect(() => {
      o !== (e !== void 0) && console.error([`Base UI: A component is changing the ${o ? "" : "un"}controlled ${r} state of ${n} to be ${o ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join(`
`));
    }, [r, n, e]);
    const {
      current: c
    } = h.useRef(t);
    h.useEffect(() => {
      !o && !Object.is(c, t) && console.error([`Base UI: A component is changing the default ${r} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
`));
    }, [JSON.stringify(t)]);
  }
  const u = h.useCallback((c) => {
    o || s(c);
  }, []);
  return [l, u];
}
function et() {
  return typeof window < "u";
}
function _e(e) {
  return Ln(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function J(e) {
  var t;
  return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function de(e) {
  var t;
  return (t = (Ln(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function Ln(e) {
  return et() ? e instanceof Node || e instanceof J(e).Node : !1;
}
function W(e) {
  return et() ? e instanceof Element || e instanceof J(e).Element : !1;
}
function ee(e) {
  return et() ? e instanceof HTMLElement || e instanceof J(e).HTMLElement : !1;
}
function bt(e) {
  return !et() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof J(e).ShadowRoot;
}
const Sr = /* @__PURE__ */ new Set(["inline", "contents"]);
function Ne(e) {
  const {
    overflow: t,
    overflowX: n,
    overflowY: r,
    display: o
  } = re(e);
  return /auto|scroll|overlay|hidden|clip/.test(t + r + n) && !Sr.has(o);
}
const Tr = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Ar(e) {
  return Tr.has(_e(e));
}
const Cr = [":popover-open", ":modal"];
function tt(e) {
  return Cr.some((t) => {
    try {
      return e.matches(t);
    } catch {
      return !1;
    }
  });
}
const Pr = ["transform", "translate", "scale", "rotate", "perspective"], Dr = ["transform", "translate", "scale", "rotate", "perspective", "filter"], _r = ["paint", "layout", "strict", "content"];
function Dt(e) {
  const t = nt(), n = W(e) ? re(e) : e;
  return Pr.some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Dr.some((r) => (n.willChange || "").includes(r)) || _r.some((r) => (n.contain || "").includes(r));
}
function Lr(e) {
  let t = pe(e);
  for (; ee(t) && !me(t); ) {
    if (Dt(t))
      return t;
    if (tt(t))
      return null;
    t = pe(t);
  }
  return null;
}
function nt() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Mr = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function me(e) {
  return Mr.has(_e(e));
}
function re(e) {
  return J(e).getComputedStyle(e);
}
function rt(e) {
  return W(e) ? {
    scrollLeft: e.scrollLeft,
    scrollTop: e.scrollTop
  } : {
    scrollLeft: e.scrollX,
    scrollTop: e.scrollY
  };
}
function pe(e) {
  if (_e(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.
    bt(e) && e.host || // Fallback.
    de(e)
  );
  return bt(t) ? t.host : t;
}
function Mn(e) {
  const t = pe(e);
  return me(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : ee(t) && Ne(t) ? t : Mn(t);
}
function we(e, t, n) {
  var r;
  t === void 0 && (t = []), n === void 0 && (n = !0);
  const o = Mn(e), i = o === ((r = e.ownerDocument) == null ? void 0 : r.body), s = J(o);
  if (i) {
    const l = wt(s);
    return t.concat(s, s.visualViewport || [], Ne(o) ? o : [], l && n ? we(l) : []);
  }
  return t.concat(o, we(o, [], n));
}
function wt(e) {
  return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
const Ie = typeof navigator < "u", ut = Ir(), Nn = Fr(), In = kr(), ki = typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter:none"), Fi = (
  // iPads can claim to be MacIntel
  ut.platform === "MacIntel" && ut.maxTouchPoints > 1 ? !0 : /iP(hone|ad|od)|iOS/.test(ut.platform)
), kn = Ie && /apple/i.test(navigator.vendor), Rt = Ie && /android/i.test(Nn) || /android/i.test(In), Nr = Ie && Nn.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints, Fn = In.includes("jsdom/");
function Ir() {
  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 kr() {
  if (!Ie)
    return "";
  const e = navigator.userAgentData;
  return e && Array.isArray(e.brands) ? e.brands.map(({
    brand: t,
    version: n
  }) => `${t}/${n}`).join(" ") : navigator.userAgent;
}
function Fr() {
  if (!Ie)
    return "";
  const e = navigator.userAgentData;
  return e != null && e.platform ? e.platform : navigator.platform;
}
const xt = "data-base-ui-focusable", $n = "active", Hn = "selected", $r = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])", $i = "ArrowLeft", Hi = "ArrowRight", Bi = "ArrowUp", Vi = "ArrowDown";
function Et(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 he(e, t) {
  var r;
  if (!e || !t)
    return !1;
  const n = (r = t.getRootNode) == null ? void 0 : r.call(t);
  if (e.contains(t))
    return !0;
  if (n && bt(n)) {
    let o = t;
    for (; o; ) {
      if (e === o)
        return !0;
      o = o.parentNode || o.host;
    }
  }
  return !1;
}
function Ee(e) {
  return "composedPath" in e ? e.composedPath()[0] : e.target;
}
function ft(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 Hr(e) {
  return e.matches("html,body");
}
function se(e) {
  return (e == null ? void 0 : e.ownerDocument) || document;
}
function Bn(e) {
  return ee(e) && e.matches($r);
}
function Wi(e) {
  return e ? e.getAttribute("role") === "combobox" && Bn(e) : !1;
}
function Br(e) {
  if (!e || Fn)
    return !0;
  try {
    return e.matches(":focus-visible");
  } catch {
    return !0;
  }
}
function ji(e) {
  return e ? e.hasAttribute(xt) ? e : e.querySelector(`[${xt}]`) || e : null;
}
function Ce(e, t, n = !0) {
  return e.filter((o) => {
    var i;
    return o.parentId === t && (!n || ((i = o.context) == null ? void 0 : i.open));
  }).flatMap((o) => [o, ...Ce(e, o.id, n)]);
}
function Ui(e, t) {
  let n, r = -1;
  function o(i, s) {
    s > r && (n = i, r = s), Ce(e, i).forEach((u) => {
      o(u.id, s + 1);
    });
  }
  return o(t, 0), e.find((i) => i.id === n);
}
function qi(e, t) {
  var o;
  let n = [], r = (o = e.find((i) => i.id === t)) == null ? void 0 : o.parentId;
  for (; r; ) {
    const i = e.find((s) => s.id === r);
    r = i == null ? void 0 : i.parentId, i && (n = n.concat(i));
  }
  return n;
}
function Yi(e) {
  e.preventDefault(), e.stopPropagation();
}
function Vr(e) {
  return "nativeEvent" in e;
}
function Ki(e) {
  return e.mozInputSource === 0 && e.isTrusted ? !0 : Rt && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function Gi(e) {
  return Fn ? !1 : !Rt && e.width === 0 && e.height === 0 || Rt && 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 Ot(e, t) {
  const n = ["mouse", "pen"];
  return t || n.push("", void 0), n.includes(e);
}
const Wr = ["top", "right", "bottom", "left"], Re = Math.min, Z = Math.max, Ye = Math.round, Ve = Math.floor, fe = (e) => ({
  x: e,
  y: e
}), jr = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Ur = {
  start: "end",
  end: "start"
};
function St(e, t, n) {
  return Z(e, Re(t, n));
}
function ye(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function oe(e) {
  return e.split("-")[0];
}
function xe(e) {
  return e.split("-")[1];
}
function _t(e) {
  return e === "x" ? "y" : "x";
}
function Lt(e) {
  return e === "y" ? "height" : "width";
}
const qr = /* @__PURE__ */ new Set(["top", "bottom"]);
function ce(e) {
  return qr.has(oe(e)) ? "y" : "x";
}
function Mt(e) {
  return _t(ce(e));
}
function Yr(e, t, n) {
  n === void 0 && (n = !1);
  const r = xe(e), o = Mt(e), i = Lt(o);
  let s = o === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
  return t.reference[i] > t.floating[i] && (s = Ke(s)), [s, Ke(s)];
}
function Kr(e) {
  const t = Ke(e);
  return [Tt(e), t, Tt(t)];
}
function Tt(e) {
  return e.replace(/start|end/g, (t) => Ur[t]);
}
const rn = ["left", "right"], on = ["right", "left"], Gr = ["top", "bottom"], Xr = ["bottom", "top"];
function zr(e, t, n) {
  switch (e) {
    case "top":
    case "bottom":
      return n ? t ? on : rn : t ? rn : on;
    case "left":
    case "right":
      return t ? Gr : Xr;
    default:
      return [];
  }
}
function Jr(e, t, n, r) {
  const o = xe(e);
  let i = zr(oe(e), n === "start", r);
  return o && (i = i.map((s) => s + "-" + o), t && (i = i.concat(i.map(Tt)))), i;
}
function Ke(e) {
  return e.replace(/left|right|bottom|top/g, (t) => jr[t]);
}
function Zr(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function Vn(e) {
  return typeof e != "number" ? Zr(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function Ge(e) {
  const {
    x: t,
    y: n,
    width: r,
    height: o
  } = e;
  return {
    width: r,
    height: o,
    top: n,
    left: t,
    right: t + r,
    bottom: n + o,
    x: t,
    y: n
  };
}
/*!
* tabbable 6.2.0
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
*/
var Qr = ["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])"], Xe = /* @__PURE__ */ Qr.join(","), Wn = typeof Element > "u", De = Wn ? function() {
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, ze = !Wn && 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;
}, Je = function e(t, n) {
  var r;
  n === void 0 && (n = !0);
  var o = t == null || (r = t.getAttribute) === null || r === void 0 ? void 0 : r.call(t, "inert"), i = o === "" || o === "true", s = i || n && t && e(t.parentNode);
  return s;
}, eo = function(t) {
  var n, r = t == null || (n = t.getAttribute) === null || n === void 0 ? void 0 : n.call(t, "contenteditable");
  return r === "" || r === "true";
}, jn = function(t, n, r) {
  if (Je(t))
    return [];
  var o = Array.prototype.slice.apply(t.querySelectorAll(Xe));
  return n && De.call(t, Xe) && o.unshift(t), o = o.filter(r), o;
}, Un = function e(t, n, r) {
  for (var o = [], i = Array.from(t); i.length; ) {
    var s = i.shift();
    if (!Je(s, !1))
      if (s.tagName === "SLOT") {
        var l = s.assignedElements(), u = l.length ? l : s.children, c = e(u, !0, r);
        r.flatten ? o.push.apply(o, c) : o.push({
          scopeParent: s,
          candidates: c
        });
      } else {
        var g = De.call(s, Xe);
        g && r.filter(s) && (n || !t.includes(s)) && o.push(s);
        var f = s.shadowRoot || // check for an undisclosed shadow
        typeof r.getShadowRoot == "function" && r.getShadowRoot(s), a = !Je(f, !1) && (!r.shadowRootFilter || r.shadowRootFilter(s));
        if (f && a) {
          var d = e(f === !0 ? s.children : f.children, !0, r);
          r.flatten ? o.push.apply(o, d) : o.push({
            scopeParent: s,
            candidates: d
          });
        } else
          i.unshift.apply(i, s.children);
      }
  }
  return o;
}, qn = function(t) {
  return !isNaN(parseInt(t.getAttribute("tabindex"), 10));
}, Yn = function(t) {
  if (!t)
    throw new Error("No node provided");
  return t.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName) || eo(t)) && !qn(t) ? 0 : t.tabIndex;
}, to = function(t, n) {
  var r = Yn(t);
  return r < 0 && n && !qn(t) ? 0 : r;
}, no = function(t, n) {
  return t.tabIndex === n.tabIndex ? t.documentOrder - n.documentOrder : t.tabIndex - n.tabIndex;
}, Kn = function(t) {
  return t.tagName === "INPUT";
}, ro = function(t) {
  return Kn(t) && t.type === "hidden";
}, oo = function(t) {
  var n = t.tagName === "DETAILS" && Array.prototype.slice.apply(t.children).some(function(r) {
    return r.tagName === "SUMMARY";
  });
  return n;
}, io = function(t, n) {
  for (var r = 0; r < t.length; r++)
    if (t[r].checked && t[r].form === n)
      return t[r];
}, so = function(t) {
  if (!t.name)
    return !0;
  var n = t.form || ze(t), r = function(l) {
    return n.querySelectorAll('input[type="radio"][name="' + l + '"]');
  }, o;
  if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
    o = r(window.CSS.escape(t.name));
  else
    try {
      o = r(t.name);
    } catch (s) {
      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", s.message), !1;
    }
  var i = io(o, t.form);
  return !i || i === t;
}, co = function(t) {
  return Kn(t) && t.type === "radio";
}, ao = function(t) {
  return co(t) && !so(t);
}, lo = function(t) {
  var n, r = t && ze(t), o = (n = r) === null || n === void 0 ? void 0 : n.host, i = !1;
  if (r && r !== t) {
    var s, l, u;
    for (i = !!((s = o) !== null && s !== void 0 && (l = s.ownerDocument) !== null && l !== void 0 && l.contains(o) || t != null && (u = t.ownerDocument) !== null && u !== void 0 && u.contains(t)); !i && o; ) {
      var c, g, f;
      r = ze(o), o = (c = r) === null || c === void 0 ? void 0 : c.host, i = !!((g = o) !== null && g !== void 0 && (f = g.ownerDocument) !== null && f !== void 0 && f.contains(o));
    }
  }
  return i;
}, sn = function(t) {
  var n = t.getBoundingClientRect(), r = n.width, o = n.height;
  return r === 0 && o === 0;
}, uo = function(t, n) {
  var r = n.displayCheck, o = n.getShadowRoot;
  if (getComputedStyle(t).visibility === "hidden")
    return !0;
  var i = De.call(t, "details>summary:first-of-type"), s = i ? t.parentElement : t;
  if (De.call(s, "details:not([open]) *"))
    return !0;
  if (!r || r === "full" || r === "legacy-full") {
    if (typeof o == "function") {
      for (var l = t; t; ) {
        var u = t.parentElement, c = ze(t);
        if (u && !u.shadowRoot && o(u) === !0)
          return sn(t);
        t.assignedSlot ? t = t.assignedSlot : !u && c !== t.ownerDocument ? t = c.host : t = u;
      }
      t = l;
    }
    if (lo(t))
      return !t.getClientRects().length;
    if (r !== "legacy-full")
      return !0;
  } else if (r === "non-zero-area")
    return sn(t);
  return !1;
}, fo = function(t) {
  if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))
    for (var n = t.parentElement; n; ) {
      if (n.tagName === "FIELDSET" && n.disabled) {
        for (var r = 0; r < n.children.length; r++) {
          var o = n.children.item(r);
          if (o.tagName === "LEGEND")
            return De.call(n, "fieldset[disabled] *") ? !0 : !o.contains(t);
        }
        return !0;
      }
      n = n.parentElement;
    }
  return !1;
}, At = 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`)
  Je(n) || ro(n) || uo(n, t) || // For a details element with a summary, the summary element gets the focus
  oo(n) || fo(n));
}, Ct = function(t, n) {
  return !(ao(n) || Yn(n) < 0 || !At(t, n));
}, go = function(t) {
  var n = parseInt(t.getAttribute("tabindex"), 10);
  return !!(isNaN(n) || n >= 0);
}, mo = function e(t) {
  var n = [], r = [];
  return t.forEach(function(o, i) {
    var s = !!o.scopeParent, l = s ? o.scopeParent : o, u = to(l, s), c = s ? e(o.candidates) : l;
    u === 0 ? s ? n.push.apply(n, c) : n.push(l) : r.push({
      documentOrder: i,
      tabIndex: u,
      item: o,
      isScope: s,
      content: c
    });
  }), r.sort(no).reduce(function(o, i) {
    return i.isScope ? o.push.apply(o, i.content) : o.push(i.content), o;
  }, []).concat(n);
}, Gn = function(t, n) {
  n = n || {};
  var r;
  return n.getShadowRoot ? r = Un([t], n.includeContainer, {
    filter: Ct.bind(null, n),
    flatten: !1,
    getShadowRoot: n.getShadowRoot,
    shadowRootFilter: go
  }) : r = jn(t, n.includeContainer, Ct.bind(null, n)), mo(r);
}, Xi = function(t, n) {
  n = n || {};
  var r;
  return n.getShadowRoot ? r = Un([t], n.includeContainer, {
    filter: At.bind(null, n),
    flatten: !0,
    getShadowRoot: n.getShadowRoot
  }) : r = jn(t, n.includeContainer, At.bind(null, n)), r;
}, zi = function(t, n) {
  if (n = n || {}, !t)
    throw new Error("No node provided");
  return De.call(t, Xe) === !1 ? !1 : Ct(n, t);
};
const Xn = () => ({
  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 zn(e, t) {
  const n = Gn(e, Xn()), r = n.length;
  if (r === 0)
    return;
  const o = Et(se(e)), i = n.indexOf(o), s = i === -1 ? t === 1 ? 0 : r - 1 : i + t;
  return n[s];
}
function ho(e) {
  return zn(se(e).body, 1) || e;
}
function po(e) {
  return zn(se(e).body, -1) || e;
}
function dt(e, t) {
  const n = t || e.currentTarget, r = e.relatedTarget;
  return !r || !he(n, r);
}
function yo(e) {
  Gn(e, Xn()).forEach((n) => {
    n.dataset.tabindex = n.getAttribute("tabindex") || "", n.setAttribute("tabindex", "-1");
  });
}
function cn(e) {
  e.querySelectorAll("[data-tabindex]").forEach((n) => {
    const r = n.dataset.tabindex;
    delete n.dataset.tabindex, r ? n.setAttribute("tabindex", r) : n.removeAttribute("tabindex");
  });
}
const Jn = /* @__PURE__ */ h.createContext(void 0);
process.env.NODE_ENV !== "production" && (Jn.displayName = "DirectionContext");
function vo(e = !0) {
  const t = h.useContext(Jn);
  if (t === void 0 && !e)
    throw new Error("Base UI: DirectionContext is missing.");
  return (t == null ? void 0 : t.direction) ?? "ltr";
}
const bo = {
  ...h
};
let an = 0;
function wo(e, t = "mui") {
  const [n, r] = h.useState(e), o = e || n;
  return h.useEffect(() => {
    n == null && (an += 1, r(`${t}-${an}`));
  }, [n, t]), o;
}
const ln = bo.useId;
function Nt(e, t) {
  if (ln !== void 0) {
    const n = ln();
    return e ?? (t ? `${t}-${n}` : n);
  }
  return wo(e, t);
}
var We = { exports: {} }, K = {};
/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var un;
function Ro() {
  if (un) return K;
  un = 1;
  var e = Pn;
  function t(u) {
    var c = "https://react.dev/errors/" + u;
    if (1 < arguments.length) {
      c += "?args[]=" + encodeURIComponent(arguments[1]);
      for (var g = 2; g < arguments.length; g++)
        c += "&args[]=" + encodeURIComponent(arguments[g]);
    }
    return "Minified React error #" + u + "; visit " + c + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
  }
  function n() {
  }
  var r = {
    d: {
      f: n,
      r: function() {
        throw Error(t(522));
      },
      D: n,
      C: n,
      L: n,
      m: n,
      X: n,
      S: n,
      M: n
    },
    p: 0,
    findDOMNode: null
  }, o = Symbol.for("react.portal");
  function i(u, c, g) {
    var f = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
    return {
      $$typeof: o,
      key: f == null ? null : "" + f,
      children: u,
      containerInfo: c,
      implementation: g
    };
  }
  var s = e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
  function l(u, c) {
    if (u === "font") return "";
    if (typeof c == "string")
      return c === "use-credentials" ? c : "";
  }
  return K.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = r, K.createPortal = function(u, c) {
    var g = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
    if (!c || c.nodeType !== 1 && c.nodeType !== 9 && c.nodeType !== 11)
      throw Error(t(299));
    return i(u, c, null, g);
  }, K.flushSync = function(u) {
    var c = s.T, g = r.p;
    try {
      if (s.T = null, r.p = 2, u) return u();
    } finally {
      s.T = c, r.p = g, r.d.f();
    }
  }, K.preconnect = function(u, c) {
    typeof u == "string" && (c ? (c = c.crossOrigin, c = typeof c == "string" ? c === "use-credentials" ? c : "" : void 0) : c = null, r.d.C(u, c));
  }, K.prefetchDNS = function(u) {
    typeof u == "string" && r.d.D(u);
  }, K.preinit = function(u, c) {
    if (typeof u == "string" && c && typeof c.as == "string") {
      var g = c.as, f = l(g, c.crossOrigin), a = typeof c.integrity == "string" ? c.integrity : void 0, d = typeof c.fetchPriority == "string" ? c.fetchPriority : void 0;
      g === "style" ? r.d.S(
        u,
        typeof c.precedence == "string" ? c.precedence : void 0,
        {
          crossOrigin: f,
          integrity: a,
          fetchPriority: d
        }
      ) : g === "script" && r.d.X(u, {
        crossOrigin: f,
        integrity: a,
        fetchPriority: d,
        nonce: typeof c.nonce == "string" ? c.nonce : void 0
      });
    }
  }, K.preinitModule = function(u, c) {
    if (typeof u == "string")
      if (typeof c == "object" && c !== null) {
        if (c.as == null || c.as === "script") {
          var g = l(
            c.as,
            c.crossOrigin
          );
          r.d.M(u, {
            crossOrigin: g,
            integrity: typeof c.integrity == "string" ? c.integrity : void 0,
            nonce: typeof c.nonce == "string" ? c.nonce : void 0
          });
        }
      } else c == null && r.d.M(u);
  }, K.preload = function(u, c) {
    if (typeof u == "string" && typeof c == "object" && c !== null && typeof c.as == "string") {
      var g = c.as, f = l(g, c.crossOrigin);
      r.d.L(u, g, {
        crossOrigin: f,
        integrity: typeof c.integrity == "string" ? c.integrity : void 0,
        nonce: typeof c.nonce == "string" ? c.nonce : void 0,
        type: typeof c.type == "string" ? c.type : void 0,
        fetchPriority: typeof c.fetchPriority == "string" ? c.fetchPriority : void 0,
        referrerPolicy: typeof c.referrerPolicy == "string" ? c.referrerPolicy : void 0,
        imageSrcSet: typeof c.imageSrcSet == "string" ? c.imageSrcSet : void 0,
        imageSizes: typeof c.imageSizes == "string" ? c.imageSizes : void 0,
        media: typeof c.media == "string" ? c.media : void 0
      });
    }
  }, K.preloadModule = function(u, c) {
    if (typeof u == "string")
      if (c) {
        var g = l(c.as, c.crossOrigin);
        r.d.m(u, {
          as: typeof c.as == "string" && c.as !== "script" ? c.as : void 0,
          crossOrigin: g,
          integrity: typeof c.integrity == "string" ? c.integrity : void 0
        });
      } else r.d.m(u);
  }, K.requestFormReset = function(u) {
    r.d.r(u);
  }, K.unstable_batchedUpdates = function(u, c) {
    return u(c);
  }, K.useFormState = function(u, c, g) {
    return s.H.useFormState(u, c, g);
  }, K.useFormStatus = function() {
    return s.H.useHostTransitionStatus();
  }, K.version = "19.1.0", K;
}
var G = {};
/**
 * @license React
 * react-dom.development.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
var fn;
function xo() {
  return fn || (fn = 1, process.env.NODE_ENV !== "production" && function() {
    function e() {
    }
    function t(f) {
      return "" + f;
    }
    function n(f, a, d) {
      var m = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
      try {
        t(m);
        var p = !1;
      } catch {
        p = !0;
      }
      return p && (console.error(
        "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
        typeof Symbol == "function" && Symbol.toStringTag && m[Symbol.toStringTag] || m.constructor.name || "Object"
      ), t(m)), {
        $$typeof: c,
        key: m == null ? null : "" + m,
        children: f,
        containerInfo: a,
        implementation: d
      };
    }
    function r(f, a) {
      if (f === "font") return "";
      if (typeof a == "string")
        return a === "use-credentials" ? a : "";
    }
    function o(f) {
      return f === null ? "`null`" : f === void 0 ? "`undefined`" : f === "" ? "an empty string" : 'something with type "' + typeof f + '"';
    }
    function i(f) {
      return f === null ? "`null`" : f === void 0 ? "`undefined`" : f === "" ? "an empty string" : typeof f == "string" ? JSON.stringify(f) : typeof f == "number" ? "`" + f + "`" : 'something with type "' + typeof f + '"';
    }
    function s() {
      var f = g.H;
      return f === null && console.error(
        `Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`
      ), f;
    }
    typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
    var l = Pn, u = {
      d: {
        f: e,
        r: function() {
          throw Error(
            "Invalid form element. requestFormReset must be passed a form that was rendered by React."
          );
        },
        D: e,
        C: e,
        L: e,
        m: e,
        X: e,
        S: e,
        M: e
      },
      p: 0,
      findDOMNode: null
    }, c = Symbol.for("react.portal"), g = l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
    typeof Map == "function" && Map.prototype != null && typeof Map.prototype.forEach == "function" && typeof Set == "function" && Set.prototype != null && typeof Set.prototype.clear == "function" && typeof Set.prototype.forEach == "function" || console.error(
      "React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"
    ), G.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = u, G.createPortal = function(f, a) {
      var d = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
      if (!a || a.nodeType !== 1 && a.nodeType !== 9 && a.nodeType !== 11)
        throw Error("Target container is not a DOM element.");
      return n(f, a, null, d);
    }, G.flushSync = function(f) {
      var a = g.T, d = u.p;
      try {
        if (g.T = null, u.p = 2, f)
          return f();
      } finally {
        g.T = a, u.p = d, u.d.f() && console.error(
          "flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."
        );
      }
    }, G.preconnect = function(f, a) {
      typeof f == "string" && f ? a != null && typeof a != "object" ? console.error(
        "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",
        i(a)
      ) : a != null && typeof a.crossOrigin != "string" && console.error(
        "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",
        o(a.crossOrigin)
      ) : console.error(
        "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
        o(f)
      ), typeof f == "string" && (a ? (a = a.crossOrigin, a = typeof a == "string" ? a === "use-credentials" ? a : "" : void 0) : a = null, u.d.C(f, a));
    }, G.prefetchDNS = function(f) {
      if (typeof f != "string" || !f)
        console.error(
          "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
          o(f)
        );
      else if (1 < arguments.length) {
        var a = arguments[1];
        typeof a == "object" && a.hasOwnProperty("crossOrigin") ? console.error(
          "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
          i(a)
        ) : console.error(
          "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
          i(a)
        );
      }
      typeof f == "string" && u.d.D(f);
    }, G.preinit = function(f, a) {
      if (typeof f == "string" && f ? a == null || typeof a != "object" ? console.error(
        "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",
        i(a)
      ) : a.as !== "style" && a.as !== "script" && console.error(
        'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
        i(a.as)
      ) : console.error(
        "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
        o(f)
      ), typeof f == "string" && a && typeof a.as == "string") {
        var d = a.as, m = r(d, a.crossOrigin), p = typeof a.integrity == "string" ? a.integrity : void 0, v = typeof a.fetchPriority == "string" ? a.fetchPriority : void 0;
        d === "style" ? u.d.S(
          f,
          typeof a.precedence == "string" ? a.precedence : void 0,
          {
            crossOrigin: m,
            integrity: p,
            fetchPriority: v
          }
        ) : d === "script" && u.d.X(f, {
          crossOrigin: m,
          integrity: p,
          fetchPriority: v,
          nonce: typeof a.nonce == "string" ? a.nonce : void 0
        });
      }
    }, G.preinitModule = function(f, a) {
      var d = "";
      if (typeof f == "string" && f || (d += " The `href` argument encountered was " + o(f) + "."), a !== void 0 && typeof a != "object" ? d += " The `options` argument encountered was " + o(a) + "." : a && "as" in a && a.as !== "script" && (d += " The `as` option encountered was " + i(a.as) + "."), d)
        console.error(
          "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",
          d
        );
      else
        switch (d = a && typeof a.as == "string" ? a.as : "script", d) {
          case "script":
            break;
          default:
            d = i(d), console.error(
              'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',
              d,
              f
            );
        }
      typeof f == "string" && (typeof a == "object" && a !== null ? (a.as == null || a.as === "script") && (d = r(
        a.as,
        a.crossOrigin
      ), u.d.M(f, {
        crossOrigin: d,
        integrity: typeof a.integrity == "string" ? a.integrity : void 0,
        nonce: typeof a.nonce == "string" ? a.nonce : void 0
      })) : a == null && u.d.M(f));
    }, G.preload = function(f, a) {
      var d = "";
      if (typeof f == "string" && f || (d += " The `href` argument encountered was " + o(f) + "."), a == null || typeof a != "object" ? d += " The `options` argument encountered was " + o(a) + "." : typeof a.as == "string" && a.as || (d += " The `as` option encountered was " + o(a.as) + "."), d && console.error(
        'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',
        d
      ), typeof f == "string" && typeof a == "object" && a !== null && typeof a.as == "string") {
        d = a.as;
        var m = r(
          d,
          a.crossOrigin
        );
        u.d.L(f, d, {
          crossOrigin: m,
          integrity: typeof a.integrity == "string" ? a.integrity : void 0,
          nonce: typeof a.nonce == "string" ? a.nonce : void 0,
          type: typeof a.type == "string" ? a.type : void 0,
          fetchPriority: typeof a.fetchPriority == "string" ? a.fetchPriority : void 0,
          referrerPolicy: typeof a.referrerPolicy == "string" ? a.referrerPolicy : void 0,
          imageSrcSet: typeof a.imageSrcSet == "string" ? a.imageSrcSet : void 0,
          imageSizes: typeof a.imageSizes == "string" ? a.imageSizes : void 0,
          media: typeof a.media == "string" ? a.media : void 0
        });
      }
    }, G.preloadModule = function(f, a) {
      var d = "";
      typeof f == "string" && f || (d += " The `href` argument encountered was " + o(f) + "."), a !== void 0 && typeof a != "object" ? d += " The `options` argument encountered was " + o(a) + "." : a && "as" in a && typeof a.as != "string" && (d += " The `as` option encountered was " + o(a.as) + "."), d && console.error(
        'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',
        d
      ), typeof f == "string" && (a ? (d = r(
        a.as,
        a.crossOrigin
      ), u.d.m(f, {
        as: typeof a.as == "string" && a.as !== "script" ? a.as : void 0,
        crossOrigin: d,
        integrity: typeof a.integrity == "string" ? a.integrity : void 0
      })) : u.d.m(f));
    }, G.requestFormReset = function(f) {
      u.d.r(f);
    }, G.unstable_batchedUpdates = function(f, a) {
      return f(a);
    }, G.useFormState = function(f, a, d) {
      return s().useFormState(f, a, d);
    }, G.useFormStatus = function() {
      return s().useHostTransitionStatus();
    }, G.version = "19.1.0", typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
  }()), G;
}
var dn;
function Eo() {
  if (dn) return We.exports;
  dn = 1;
  function e() {
    if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ > "u" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function")) {
      if (process.env.NODE_ENV !== "production")
        throw new Error("^_^");
      try {
        __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e);
      } catch (t) {
        console.error(t);
      }
    }
  }
  return process.env.NODE_ENV === "production" ? (e(), We.exports = Ro()) : We.exports = xo(), We.exports;
}
var ot = Eo();
const je = null;
let gn = globalThis.requestAnimationFrame;
class Oo {
  constructor() {
    /* This implementation uses an array as a backing data-structure for frame callbacks.
     * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
     * never calls the native `cancelAnimationFrame` if there are no frames left. This can
     * be much more efficient if there is a call pattern that alterns as
     * "request-cancel-request-cancel-…".
     * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
     * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
    ue(this, "callbacks", []);
    ue(this, "callbacksCount", 0);
    ue(this, "nextId", 1);
    ue(this, "startId", 1);
    ue(this, "isScheduled", !1);
    ue(this, "tick", (t) => {
      var o;
      this.isScheduled = !1;
      const n = this.callbacks, r = this.callbacksCount;
      if (this.callbacks = [], this.callbacksCount = 0, this.startId = this.nextId, r > 0)
        for (let i = 0; i < n.length; i += 1)
          (o = n[i]) == null || o.call(n, t);
    });
  }
  request(t) {
    const n = this.nextId;
    this.nextId += 1, this.callbacks.push(t), this.callbacksCount += 1;
    const r = process.env.NODE_ENV === "test" && gn !== requestAnimationFrame && (gn = requestAnimationFrame, !0);
    return (!this.isScheduled || r) && (requestAnimationFrame(this.tick), this.isScheduled = !0), n;
  }
  cancel(t) {
    const n = t - this.startId;
    n < 0 || n >= this.callbacks.length || (this.callbacks[n] = null, this.callbacksCount -= 1);
  }
}
const Ue = new Oo();
class ge {
  constructor() {
    ue(this, "currentId", je);
    ue(this, "cancel", () => {
      this.currentId !== je && (Ue.cancel(this.currentId), this.currentId = je);
    });
    ue(this, "disposeEffect", () => this.cancel);
  }
  static create() {
    return new ge();
  }
  static request(t) {
    return Ue.request(t);
  }
  static cancel(t) {
    return Ue.cancel(t);
  }
  /**
   * Executes `fn` after `delay`, clearing any previously scheduled call.
   */
  request(t) {
    this.cancel(), this.currentId = Ue.request(() => {
      this.currentId = je, t();
    });
  }
}
function So() {
  const e = Dn(ge.create).current;
  return Er(e.disposeEffect), e;
}
function To(e, t = !1) {
  const n = So(), r = Le();
  return Q((o, i = null) => {
    n.cancel(), r.clear();
    const s = e.current;
    s && (typeof s.getAnimations != "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED ? o() : n.request(() => {
      function l() {
        s && Promise.allSettled(s.getAnimations().map((u) => u.finished)).then(() => {
          i != null && i.aborted || ot.flushSync(o);
        });
      }
      t ? r.start(0, l) : l();
    }));
  });
}
function Ji(e, t = !1, n = !1) {
  const [r, o] = h.useState(e && t ? "idle" : void 0), [i, s] = h.useState(e);
  return e && !i && (s(!0), o("starting")), !e && i && r !== "ending" && !n && o("ending"), !e && !i && r === "ending" && o(void 0), z(() => {
    if (!e && i && r !== "ending" && n) {
      const l = ge.request(() => {
        o("ending");
      });
      return () => {
        ge.cancel(l);
      };
    }
  }, [e, i, r, n]), z(() => {
    if (!e || t)
      return;
    const l = ge.request(() => {
      ot.flushSync(() => {
        o(void 0);
      });
    });
    return () => {
      ge.cancel(l);
    };
  }, [t, e]), z(() => {
    if (!e || !t)
      return;
    e && i && r !== "idle" && o("starting");
    const l = ge.request(() => {
      o("idle");
    });
    return () => {
      ge.cancel(l);
    };
  }, [t, e, i, o, r]), h.useMemo(() => ({
    mounted: i,
    setMounted: s,
    transitionStatus: r
  }), [i, r]);
}
let Ze = /* @__PURE__ */ function(e) {
  return e.startingStyle = "data-starting-style", e.endingStyle = "data-ending-style", e;
}({});
const Ao = {
  [Ze.startingStyle]: ""
}, Co = {
  [Ze.endingStyle]: ""
}, Zi = {
  transitionStatus(e) {
    return e === "starting" ? Ao : e === "ending" ? Co : null;
  }
};
function be(e) {
  const t = Dn(Po, e).current;
  return t.next = e, z(t.effect), t;
}
function Po(e) {
  const t = {
    current: e,
    next: e,
    effect: () => {
      t.current = t.next;
    }
  };
  return t;
}
function Qi(e) {
  const {
    enabled: t = !0,
    open: n,
    ref: r,
    onComplete: o
  } = e, i = be(n), s = Q(o), l = To(r, n);
  h.useEffect(() => {
    t && l(() => {
      n === i.current && s();
    });
  }, [t, n, s, l, i]);
}
let It = function(e) {
  return e.open = "data-open", e.closed = "data-closed", e[e.startingStyle = Ze.startingStyle] = "startingStyle", e[e.endingStyle = Ze.endingStyle] = "endingStyle", e.anchorHidden = "data-anchor-hidden", e;
}({}), Do = /* @__PURE__ */ function(e) {
  return e.popupOpen = "data-popup-open", e.pressed = "data-pressed", e;
}({});
const _o = {
  [Do.popupOpen]: ""
}, Lo = {
  [It.open]: ""
}, Mo = {
  [It.closed]: ""
}, No = {
  [It.anchorHidden]: ""
}, es = {
  open(e) {
    return e ? _o : null;
  }
}, ts = {
  open(e) {
    return e ? Lo : Mo;
  },
  anchorHidden(e) {
    return e ? No : null;
  }
};
function Zn() {
  const e = /* @__PURE__ */ new Map();
  return {
    emit(t, n) {
      var r;
      (r = e.get(t)) == null || r.forEach((o) => o(n));
    },
    on(t, n) {
      e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n);
    },
    off(t, n) {
      var r;
      (r = e.get(t)) == null || r.delete(n);
    }
  };
}
const kt = /* @__PURE__ */ h.createContext(null);
process.env.NODE_ENV !== "production" && (kt.displayName = "FloatingNodeContext");
const Ft = /* @__PURE__ */ h.createContext(null);
process.env.NODE_ENV !== "production" && (Ft.displayName = "FloatingTreeContext");
const it = () => {
  var e;
  return ((e = h.useContext(kt)) == null ? void 0 : e.id) || null;
}, st = () => h.useContext(Ft);
function ns(e) {
  const t = Nt(), n = st(), o = it();
  return z(() => {
    if (!t)
      return;
    const i = {
      id: t,
      parentId: o
    };
    return n == null || n.addNode(i), () => {
      n == null || n.removeNode(i);
    };
  }, [n, t, o]), t;
}
function rs(e) {
  const {
    children: t,
    id: n
  } = e, r = it();
  return /* @__PURE__ */ Ae(kt.Provider, {
    value: h.useMemo(() => ({
      id: n,
      parentId: r
    }), [n, r]),
    children: t
  });
}
function os(e) {
  const {
    children: t
  } = e, n = h.useRef([]), r = h.useCallback((s) => {
    n.current = [...n.current, s];
  }, []), o = h.useCallback((s) => {
    n.current = n.current.filter((l) => l !== s);
  }, []), [i] = h.useState(() => Zn());
  return /* @__PURE__ */ Ae(Ft.Provider, {
    value: h.useMemo(() => ({
      nodesRef: n,
      addNode: r,
      removeNode: o,
      events: i
    }), [r, o, i]),
    children: t
  });
}
function ct(e) {
  return `data-base-ui-${e}`;
}
const mn = ct("safe-polygon");
function gt(e, t, n) {
  if (n && !Ot(n))
    return 0;
  if (typeof e == "number")
    return e;
  if (typeof e == "function") {
    const r = e();
    return typeof r == "number" ? r : r == null ? void 0 : r[t];
  }
  return e == null ? void 0 : e[t];
}
function mt(e) {
  return typeof e == "function" ? e() : e;
}
function is(e, t = {}) {
  const {
    open: n,
    onOpenChange: r,
    dataRef: o,
    events: i,
    elements: s
  } = e, {
    enabled: l = !0,
    delay: u = 0,
    handleClose: c = null,
    mouseOnly: g = !1,
    restMs: f = 0,
    move: a = !0
  } = t, d = st(), m = it(), p = be(c), v = be(u), R = be(n), x = be(f), b = h.useRef(void 0), E = Le(), A = h.useRef(void 0), _ = Le(), I = h.useRef(!0), j = h.useRef(!1), k = h.useRef(() => {
  }), V = h.useRef(!1), $ = Q(() => {
    var y;
    const S = (y = o.current.openEvent) == null ? void 0 : y.type;
    return (S == null ? void 0 : S.includes("mouse")) && S !== "mousedown";
  });
  h.useEffect(() => {
    if (!l)
      return;
    function S({
      open: y
    }) {
      y || (E.clear(), _.clear(), I.current = !0, V.current = !1);
    }
    return i.on("openchange", S), () => {
      i.off("openchange", S);
    };
  }, [l, i, E, _]), h.useEffect(() => {
    if (!l || !p.current || !n)
      return;
    function S(T) {
      $() && r(!1, T, "hover");
    }
    const y = se(s.floating).documentElement;
    return y.addEventListener("mouseleave", S), () => {
      y.removeEventListener("mouseleave", S);
    };
  }, [s.floating, n, r, l, p, $]);
  const C = h.useCallback((S, y = !0, T = "hover") => {
    const D = gt(v.current, "close", b.current);
    D && !A.current ? E.start(D, () => r(!1, S, T)) : y && (E.clear(), r(!1, S, T));
  }, [v, r, E]), w = Q(() => {
    k.current(), A.current = void 0;
  }), L = Q(() => {
    if (j.current) {
      const S = se(s.floating).body;
      S.style.pointerEvents = "", S.removeAttribute(mn), j.current = !1;
    }
  }), O = Q(() => o.current.openEvent ? ["click", "mousedown"].includes(o.current.openEvent.type) : !1);
  h.useEffect(() => {
    if (!l)
      return;
    function S(M) {
      if (E.clear(), I.current = !1, g && !Ot(b.current) || mt(x.current) > 0 && !gt(v.current, "open"))
        return;
      const B = gt(v.current, "open", b.current);
      B ? E.start(B, () => {
        R.current || r(!0, M, "hover");
      }) : n || r(!0, M, "hover");
    }
    function y(M) {
      if (O()) {
        L();
        return;
      }
      k.current();
      const B = se(s.floating);
      if (_.clear(), V.current = !1, p.current && o.current.floatingContext) {
        n || E.clear(), A.current = p.current({
          ...o.current.floatingContext,
          tree: d,
          x: M.clientX,
          y: M.clientY,
          onClose() {
            L(), w(), O() || C(M, !0, "safe-polygon");
          }
        });
        const te = A.current;
        B.addEventListener("mousemove", te), k.current = () => {
          B.removeEventListener("mousemove", te);
        };
        return;
      }
      (b.current === "touch" ? !he(s.floating, M.relatedTarget) : !0) && C(M);
    }
    function T(M) {
      var B;
      O() || o.current.floatingContext && ((B = p.current) == null || B.call(p, {
        ...o.current.floatingContext,
        tree: d,
        x: M.clientX,
        y: M.clientY,
        onClose() {
          L(), w(), O() || C(M);
        }
      })(M));
    }
    function D() {
      E.clear();
    }
    function H(M) {
      O() || C(M, !1);
    }
    if (W(s.domReference)) {
      const M = s.domReference, B = s.floating;
      return n && M.addEventListener("mouseleave", T), a && M.addEventListener("mousemove", S, {
        once: !0
      }), M.addEventListener("mouseenter", S), M.addEventListener("mouseleave", y), B && (B.addEventListener("mouseleave", T), B.addEventListener("mouseenter", D), B.addEventListener("mouseleave", H)), () => {
        n && M.removeEventListener("mouseleave", T), a && M.removeEventListener("mousemove", S), M.removeEventListener("mouseenter", S), M.removeEventListener("mouseleave", y), B && (B.removeEventListener("mouseleave", T), B.removeEventListener("mouseenter", D), B.removeEventListener("mouseleave", H));
      };
    }
  }, [s, l, e, g, a, C, w, L, r, n, R, d, v, p, o, O, x, E, _]), z(() => {
    var S, y, T, D;
    if (l && n && (y = (S = p.current) == null ? void 0 : S.__options) != null && y.blockPointerEvents && $()) {
      j.current = !0;
      const H = s.floating;
      if (W(s.domReference) && H) {
        const M = se(s.floating).body;
        M.setAttribute(mn, "");
        const B = s.domReference, X = (D = (T = d == null ? void 0 : d.nodesRef.current.find((te) => te.id === m)) == null ? void 0 : T.context) == null ? void 0 : D.elements.floating;
        return X && (X.style.pointerEvents = ""), M.style.pointerEvents = "none", B.style.pointerEvents = "auto", H.style.pointerEvents = "auto", () => {
          M.style.pointerEvents = "", B.style.pointerEvents = "", H.style.pointerEvents = "";
        };
      }
    }
  }, [l, n, m, s, d, p, $]), z(() => {
    n || (b.current = void 0, V.current = !1, w(), L());
  }, [n, w, L]), h.useEffect(() => () => {
    w(), E.clear(), _.clear(), L();
  }, [l, s.domReference, w, L, E, _]);
  const P = h.useMemo(() => {
    function S(y) {
      b.current = y.pointerType;
    }
    return {
      onPointerDown: S,
      onPointerEnter: S,
      onMouseMove(y) {
        const {
          nativeEvent: T
        } = y;
        function D() {
          !I.current && !R.current && r(!0, T, "hover");
        }
        g && !Ot(b.current) || n || mt(x.current) === 0 || V.current && y.movementX ** 2 + y.movementY ** 2 < 2 || (_.clear(), b.current === "touch" ? D() : (V.current = !0, _.start(mt(x.current), D)));
      }
    };
  }, [g, r, n, R, x, _]);
  return h.useMemo(() => l ? {
    reference: P
  } : {}, [l, P]);
}
const Qn = {
  clip: "rect(0 0 0 0)",
  overflow: "hidden",
  whiteSpace: "nowrap",
  position: "fixed",
  top: 0,
  left: 0,
  border: 0,
  padding: 0,
  width: 1,
  height: 1,
  margin: -1
}, Pt = /* @__PURE__ */ h.forwardRef(function(t, n) {
  const [r, o] = h.useState();
  return z(() => {
    kn && o("button");
  }, []), /* @__PURE__ */ Ae("span", {
    ...t,
    ...{
      ref: n,
      tabIndex: 0,
      // Role is only for VoiceOver
      role: r,
      "aria-hidden": r ? void 0 : !0,
      style: Qn
    },
    "data-base-ui-focus-guard": ""
  });
});
process.env.NODE_ENV !== "production" && (Pt.displayName = "FocusGuard");
const $t = /* @__PURE__ */ h.createContext(null);
process.env.NODE_ENV !== "production" && ($t.displayName = "PortalContext");
const Io = () => h.useContext($t), hn = ct("portal");
function ko(e = {}) {
  const {
    id: t,
    root: n
  } = e, r = Nt(), o = Io(), [i, s] = h.useState(null), l = h.useRef(null);
  return z(() => () => {
    i == null || i.remove(), queueMicrotask(() => {
      l.current = null;
    });
  }, [i]), z(() => {
    if (!r || l.current)
      return;
    const u = t ? document.getElementById(t) : null;
    if (!u)
      return;
    const c = document.createElement("div");
    c.id = r, c.setAttribute(hn, ""), u.appendChild(c), l.current = c, s(c);
  }, [t, r]), z(() => {
    if (n === null || !r || l.current)
      return;
    let u = n || (o == null ? void 0 : o.portalNode);
    u && !W(u) && (u = u.current), u = u || document.body;
    let c = null;
    t && (c = document.createElement("div"), c.id = t, u.appendChild(c));
    const g = document.createElement("div");
    g.id = r, g.setAttribute(hn, ""), u = c || u, u.appendChild(g), l.current = g, s(g);
  }, [t, n, r, o]), i;
}
function ss(e) {
  const {
    children: t,
    id: n,
    root: r,
    preserveTabOrder: o = !0
  } = e, i = ko({
    id: n,
    root: r
  }), [s, l] = h.useState(null), u = h.useRef(null), c = h.useRef(null), g = h.useRef(null), f = h.useRef(null), a = s == null ? void 0 : s.modal, d = s == null ? void 0 : s.open, m = (
    // The FocusManager and therefore floating element are currently open/
    // rendered.
    !!s && // Guards are only for non-modal focus management.
    !s.modal && // Don't render if unmount is transitioning.
    s.open && o && !!(r || i)
  );
  return h.useEffect(() => {
    if (!i || !o || a)
      return;
    function p(v) {
      i && dt(v) && (v.type === "focusin" ? cn : yo)(i);
    }
    return i.addEventListener("focusin", p, !0), i.addEventListener("focusout", p, !0), () => {
      i.removeEventListener("focusin", p, !0), i.removeEventListener("focusout", p, !0);
    };
  }, [i, o, a]), h.useEffect(() => {
    i && (d || cn(i));
  }, [d, i]), /* @__PURE__ */ Or($t.Provider, {
    value: h.useMemo(() => ({
      preserveTabOrder: o,
      beforeOutsideRef: u,
      afterOutsideRef: c,
      beforeInsideRef: g,
      afterInsideRef: f,
      portalNode: i,
      setFocusManagerState: l
    }), [o, i]),
    children: [m && i && /* @__PURE__ */ Ae(Pt, {
      "data-type": "outside",
      ref: u,
      onFocus: (p) => {
        var v;
        if (dt(p, i))
          (v = g.current) == null || v.focus();
        else {
          const R = s ? s.domReference : null, x = po(R);
          x == null || x.focus();
        }
      }
    }), m && i && /* @__PURE__ */ Ae("span", {
      "aria-owns": i.id,
      style: Qn
    }), i && /* @__PURE__ */ ot.createPortal(t, i), m && i && /* @__PURE__ */ Ae(Pt, {
      "data-type": "outside",
      ref: c,
      onFocus: (p) => {
        var v;
        if (dt(p, i))
          (v = f.current) == null || v.focus();
        else {
          const R = s ? s.domReference : null, x = ho(R);
          x == null || x.focus(), s != null && s.closeOnFocusOut && (s == null || s.onOpenChange(!1, p.nativeEvent, "focus-out"));
        }
      }
    })]
  });
}
function pn(e, t, n) {
  let {
    reference: r,
    floating: o
  } = e;
  const i = ce(t), s = Mt(t), l = Lt(s), u = oe(t), c = i === "y", g = r.x + r.width / 2 - o.width / 2, f = r.y + r.height / 2 - o.height / 2, a = r[l] / 2 - o[l] / 2;
  let d;
  switch (u) {
    case "top":
      d = {
        x: g,
        y: r.y - o.height
      };
      break;
    case "bottom":
      d = {
        x: g,
        y: r.y + r.height
      };
      break;
    case "right":
      d = {
        x: r.x + r.width,
        y: f
      };
      break;
    case "left":
      d = {
        x: r.x - o.width,
        y: f
      };
      break;
    default:
      d = {
        x: r.x,
        y: r.y
      };
  }
  switch (xe(t)) {
    case "start":
      d[s] -= a * (n && c ? -1 : 1);
      break;
    case "end":
      d[s] += a * (n && c ? -1 : 1);
      break;
  }
  return d;
}
const Fo = async (e, t, n) => {
  const {
    placement: r = "bottom",
    strategy: o = "absolute",
    middleware: i = [],
    platform: s
  } = n, l = i.filter(Boolean), u = await (s.isRTL == null ? void 0 : s.isRTL(t));
  let c = await s.getElementRects({
    reference: e,
    floating: t,
    strategy: o
  }), {
    x: g,
    y: f
  } = pn(c, r, u), a = r, d = {}, m = 0;
  for (let p = 0; p < l.length; p++) {
    const {
      name: v,
      fn: R
    } = l[p], {
      x,
      y: b,
      data: E,
      reset: A
    } = await R({
      x: g,
      y: f,
      initialPlacement: r,
      placement: a,
      strategy: o,
      middlewareData: d,
      rects: c,
      platform: s,
      elements: {
        reference: e,
        floating: t
      }
    });
    g = x ?? g, f = b ?? f, d = {
      ...d,
      [v]: {
        ...d[v],
        ...E
      }
    }, A && m <= 50 && (m++, typeof A == "object" && (A.placement && (a = A.placement), A.rects && (c = A.rects === !0 ? await s.getElementRects({
      reference: e,
      floating: t,
      strategy: o
    }) : A.rects), {
      x: g,
      y: f
    } = pn(c, a, u)), p = -1);
  }
  return {
    x: g,
    y: f,
    placement: a,
    strategy: o,
    middlewareData: d
  };
};
async function Me(e, t) {
  var n;
  t === void 0 && (t = {});
  const {
    x: r,
    y: o,
    platform: i,
    rects: s,
    elements: l,
    strategy: u
  } = e, {
    boundary: c = "clippingAncestors",
    rootBoundary: g = "viewport",
    elementContext: f = "floating",
    altBoundary: a = !1,
    padding: d = 0
  } = ye(t, e), m = Vn(d), v = l[a ? f === "floating" ? "reference" : "floating" : f], R = Ge(await i.getClippingRect({
    element: (n = await (i.isElement == null ? void 0 : i.isElement(v))) == null || n ? v : v.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(l.floating)),
    boundary: c,
    rootBoundary: g,
    strategy: u
  })), x = f === "floating" ? {
    x: r,
    y: o,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, b = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(l.floating)), E = await (i.isElement == null ? void 0 : i.isElement(b)) ? await (i.getScale == null ? void 0 : i.getScale(b)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, A = Ge(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: l,
    rect: x,
    offsetParent: b,
    strategy: u
  }) : x);
  return {
    top: (R.top - A.top + m.top) / E.y,
    bottom: (A.bottom - R.bottom + m.bottom) / E.y,
    left: (R.left - A.left + m.left) / E.x,
    right: (A.right - R.right + m.right) / E.x
  };
}
const $o = (e) => ({
  name: "arrow",
  options: e,
  async fn(t) {
    const {
      x: n,
      y: r,
      placement: o,
      rects: i,
      platform: s,
      elements: l,
      middlewareData: u
    } = t, {
      element: c,
      padding: g = 0
    } = ye(e, t) || {};
    if (c == null)
      return {};
    const f = Vn(g), a = {
      x: n,
      y: r
    }, d = Mt(o), m = Lt(d), p = await s.getDimensions(c), v = d === "y", R = v ? "top" : "left", x = v ? "bottom" : "right", b = v ? "clientHeight" : "clientWidth", E = i.reference[m] + i.reference[d] - a[d] - i.floating[m], A = a[d] - i.reference[d], _ = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c));
    let I = _ ? _[b] : 0;
    (!I || !await (s.isElement == null ? void 0 : s.isElement(_))) && (I = l.floating[b] || i.floating[m]);
    const j = E / 2 - A / 2, k = I / 2 - p[m] / 2 - 1, V = Re(f[R], k), $ = Re(f[x], k), C = V, w = I - p[m] - $, L = I / 2 - p[m] / 2 + j, O = St(C, L, w), P = !u.arrow && xe(o) != null && L !== O && i.reference[m] / 2 - (L < C ? V : $) - p[m] / 2 < 0, S = P ? L < C ? L - C : L - w : 0;
    return {
      [d]: a[d] + S,
      data: {
        [d]: O,
        centerOffset: L - O - S,
        ...P && {
          alignmentOffset: S
        }
      },
      reset: P
    };
  }
}), Ho = function(e) {
  return e === void 0 && (e = {}), {
    name: "flip",
    options: e,
    async fn(t) {
      var n, r;
      const {
        placement: o,
        middlewareData: i,
        rects: s,
        initialPlacement: l,
        platform: u,
        elements: c
      } = t, {
        mainAxis: g = !0,
        crossAxis: f = !0,
        fallbackPlacements: a,
        fallbackStrategy: d = "bestFit",
        fallbackAxisSideDirection: m = "none",
        flipAlignment: p = !0,
        ...v
      } = ye(e, t);
      if ((n = i.arrow) != null && n.alignmentOffset)
        return {};
      const R = oe(o), x = ce(l), b = oe(l) === l, E = await (u.isRTL == null ? void 0 : u.isRTL(c.floating)), A = a || (b || !p ? [Ke(l)] : Kr(l)), _ = m !== "none";
      !a && _ && A.push(...Jr(l, p, m, E));
      const I = [l, ...A], j = await Me(t, v), k = [];
      let V = ((r = i.flip) == null ? void 0 : r.overflows) || [];
      if (g && k.push(j[R]), f) {
        const L = Yr(o, s, E);
        k.push(j[L[0]], j[L[1]]);
      }
      if (V = [...V, {
        placement: o,
        overflows: k
      }], !k.every((L) => L <= 0)) {
        var $, C;
        const L = ((($ = i.flip) == null ? void 0 : $.index) || 0) + 1, O = I[L];
        if (O && (!(f === "alignment" ? x !== ce(O) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        V.every((y) => y.overflows[0] > 0 && ce(y.placement) === x)))
          return {
            data: {
              index: L,
              overflows: V
            },
            reset: {
              placement: O
            }
          };
        let P = (C = V.filter((S) => S.overflows[0] <= 0).sort((S, y) => S.overflows[1] - y.overflows[1])[0]) == null ? void 0 : C.placement;
        if (!P)
          switch (d) {
            case "bestFit": {
              var w;
              const S = (w = V.filter((y) => {
                if (_) {
                  const T = ce(y.placement);
                  return T === x || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  T === "y";
                }
                return !0;
              }).map((y) => [y.placement, y.overflows.filter((T) => T > 0).reduce((T, D) => T + D, 0)]).sort((y, T) => y[1] - T[1])[0]) == null ? void 0 : w[0];
              S && (P = S);
              break;
            }
            case "initialPlacement":
              P = l;
              break;
          }
        if (o !== P)
          return {
            reset: {
              placement: P
            }
          };
      }
      return {};
    }
  };
};
function yn(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function vn(e) {
  return Wr.some((t) => e[t] >= 0);
}
const Bo = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: n
      } = t, {
        strategy: r = "referenceHidden",
        ...o
      } = ye(e, t);
      switch (r) {
        case "referenceHidden": {
          const i = await Me(t, {
            ...o,
            elementContext: "reference"
          }), s = yn(i, n.reference);
          return {
            data: {
              referenceHiddenOffsets: s,
              referenceHidden: vn(s)
            }
          };
        }
        case "escaped": {
          const i = await Me(t, {
            ...o,
            altBoundary: !0
          }), s = yn(i, n.floating);
          return {
            data: {
              escapedOffsets: s,
              escaped: vn(s)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, er = /* @__PURE__ */ new Set(["left", "top"]);
async function Vo(e, t) {
  const {
    placement: n,
    platform: r,
    elements: o
  } = e, i = await (r.isRTL == null ? void 0 : r.isRTL(o.floating)), s = oe(n), l = xe(n), u = ce(n) === "y", c = er.has(s) ? -1 : 1, g = i && u ? -1 : 1, f = ye(t, e);
  let {
    mainAxis: a,
    crossAxis: d,
    alignmentAxis: m
  } = typeof f == "number" ? {
    mainAxis: f,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: f.mainAxis || 0,
    crossAxis: f.crossAxis || 0,
    alignmentAxis: f.alignmentAxis
  };
  return l && typeof m == "number" && (d = l === "end" ? m * -1 : m), u ? {
    x: d * g,
    y: a * c
  } : {
    x: a * c,
    y: d * g
  };
}
const Wo = function(e) {
  return e === void 0 && (e = 0), {
    name: "offset",
    options: e,
    async fn(t) {
      var n, r;
      const {
        x: o,
        y: i,
        placement: s,
        middlewareData: l
      } = t, u = await Vo(t, e);
      return s === ((n = l.offset) == null ? void 0 : n.placement) && (r = l.arrow) != null && r.alignmentOffset ? {} : {
        x: o + u.x,
        y: i + u.y,
        data: {
          ...u,
          placement: s
        }
      };
    }
  };
}, jo = function(e) {
  return e === void 0 && (e = {}), {
    name: "shift",
    options: e,
    async fn(t) {
      const {
        x: n,
        y: r,
        placement: o
      } = t, {
        mainAxis: i = !0,
        crossAxis: s = !1,
        limiter: l = {
          fn: (v) => {
            let {
              x: R,
              y: x
            } = v;
            return {
              x: R,
              y: x
            };
          }
        },
        ...u
      } = ye(e, t), c = {
        x: n,
        y: r
      }, g = await Me(t, u), f = ce(oe(o)), a = _t(f);
      let d = c[a], m = c[f];
      if (i) {
        const v = a === "y" ? "top" : "left", R = a === "y" ? "bottom" : "right", x = d + g[v], b = d - g[R];
        d = St(x, d, b);
      }
      if (s) {
        const v = f === "y" ? "top" : "left", R = f === "y" ? "bottom" : "right", x = m + g[v], b = m - g[R];
        m = St(x, m, b);
      }
      const p = l.fn({
        ...t,
        [a]: d,
        [f]: m
      });
      return {
        ...p,
        data: {
          x: p.x - n,
          y: p.y - r,
          enabled: {
            [a]: i,
            [f]: s
          }
        }
      };
    }
  };
}, Uo = function(e) {
  return e === void 0 && (e = {}), {
    options: e,
    fn(t) {
      const {
        x: n,
        y: r,
        placement: o,
        rects: i,
        middlewareData: s
      } = t, {
        offset: l = 0,
        mainAxis: u = !0,
        crossAxis: c = !0
      } = ye(e, t), g = {
        x: n,
        y: r
      }, f = ce(o), a = _t(f);
      let d = g[a], m = g[f];
      const p = ye(l, t), v = typeof p == "number" ? {
        mainAxis: p,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...p
      };
      if (u) {
        const b = a === "y" ? "height" : "width", E = i.reference[a] - i.floating[b] + v.mainAxis, A = i.reference[a] + i.reference[b] - v.mainAxis;
        d < E ? d = E : d > A && (d = A);
      }
      if (c) {
        var R, x;
        const b = a === "y" ? "width" : "height", E = er.has(oe(o)), A = i.reference[f] - i.floating[b] + (E && ((R = s.offset) == null ? void 0 : R[f]) || 0) + (E ? 0 : v.crossAxis), _ = i.reference[f] + i.reference[b] + (E ? 0 : ((x = s.offset) == null ? void 0 : x[f]) || 0) - (E ? v.crossAxis : 0);
        m < A ? m = A : m > _ && (m = _);
      }
      return {
        [a]: d,
        [f]: m
      };
    }
  };
}, qo = function(e) {
  return e === void 0 && (e = {}), {
    name: "size",
    options: e,
    async fn(t) {
      var n, r;
      const {
        placement: o,
        rects: i,
        platform: s,
        elements: l
      } = t, {
        apply: u = () => {
        },
        ...c
      } = ye(e, t), g = await Me(t, c), f = oe(o), a = xe(o), d = ce(o) === "y", {
        width: m,
        height: p
      } = i.floating;
      let v, R;
      f === "top" || f === "bottom" ? (v = f, R = a === (await (s.isRTL == null ? void 0 : s.isRTL(l.floating)) ? "start" : "end") ? "left" : "right") : (R = f, v = a === "end" ? "top" : "bottom");
      const x = p - g.top - g.bottom, b = m - g.left - g.right, E = Re(p - g[v], x), A = Re(m - g[R], b), _ = !t.middlewareData.shift;
      let I = E, j = A;
      if ((n = t.middlewareData.shift) != null && n.enabled.x && (j = b), (r = t.middlewareData.shift) != null && r.enabled.y && (I = x), _ && !a) {
        const V = Z(g.left, 0), $ = Z(g.right, 0), C = Z(g.top, 0), w = Z(g.bottom, 0);
        d ? j = m - 2 * (V !== 0 || $ !== 0 ? V + $ : Z(g.left, g.right)) : I = p - 2 * (C !== 0 || w !== 0 ? C + w : Z(g.top, g.bottom));
      }
      await u({
        ...t,
        availableWidth: j,
        availableHeight: I
      });
      const k = await s.getDimensions(l.floating);
      return m !== k.width || p !== k.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function tr(e) {
  const t = re(e);
  let n = parseFloat(t.width) || 0, r = parseFloat(t.height) || 0;
  const o = ee(e), i = o ? e.offsetWidth : n, s = o ? e.offsetHeight : r, l = Ye(n) !== i || Ye(r) !== s;
  return l && (n = i, r = s), {
    width: n,
    height: r,
    $: l
  };
}
function Ht(e) {
  return W(e) ? e : e.contextElement;
}
function Pe(e) {
  const t = Ht(e);
  if (!ee(t))
    return fe(1);
  const n = t.getBoundingClientRect(), {
    width: r,
    height: o,
    $: i
  } = tr(t);
  let s = (i ? Ye(n.width) : n.width) / r, l = (i ? Ye(n.height) : n.height) / o;
  return (!s || !Number.isFinite(s)) && (s = 1), (!l || !Number.isFinite(l)) && (l = 1), {
    x: s,
    y: l
  };
}
const Yo = /* @__PURE__ */ fe(0);
function nr(e) {
  const t = J(e);
  return !nt() || !t.visualViewport ? Yo : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function Ko(e, t, n) {
  return t === void 0 && (t = !1), !n || t && n !== J(e) ? !1 : t;
}
function Oe(e, t, n, r) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const o = e.getBoundingClientRect(), i = Ht(e);
  let s = fe(1);
  t && (r ? W(r) && (s = Pe(r)) : s = Pe(e));
  const l = Ko(i, n, r) ? nr(i) : fe(0);
  let u = (o.left + l.x) / s.x, c = (o.top + l.y) / s.y, g = o.width / s.x, f = o.height / s.y;
  if (i) {
    const a = J(i), d = r && W(r) ? J(r) : r;
    let m = a, p = wt(m);
    for (; p && r && d !== m; ) {
      const v = Pe(p), R = p.getBoundingClientRect(), x = re(p), b = R.left + (p.clientLeft + parseFloat(x.paddingLeft)) * v.x, E = R.top + (p.clientTop + parseFloat(x.paddingTop)) * v.y;
      u *= v.x, c *= v.y, g *= v.x, f *= v.y, u += b, c += E, m = J(p), p = wt(m);
    }
  }
  return Ge({
    width: g,
    height: f,
    x: u,
    y: c
  });
}
function Bt(e, t) {
  const n = rt(e).scrollLeft;
  return t ? t.left + n : Oe(de(e)).left + n;
}
function rr(e, t, n) {
  n === void 0 && (n = !1);
  const r = e.getBoundingClientRect(), o = r.left + t.scrollLeft - (n ? 0 : (
    // RTL <body> scrollbar.
    Bt(e, r)
  )), i = r.top + t.scrollTop;
  return {
    x: o,
    y: i
  };
}
function Go(e) {
  let {
    elements: t,
    rect: n,
    offsetParent: r,
    strategy: o
  } = e;
  const i = o === "fixed", s = de(r), l = t ? tt(t.floating) : !1;
  if (r === s || l && i)
    return n;
  let u = {
    scrollLeft: 0,
    scrollTop: 0
  }, c = fe(1);
  const g = fe(0), f = ee(r);
  if ((f || !f && !i) && ((_e(r) !== "body" || Ne(s)) && (u = rt(r)), ee(r))) {
    const d = Oe(r);
    c = Pe(r), g.x = d.x + r.clientLeft, g.y = d.y + r.clientTop;
  }
  const a = s && !f && !i ? rr(s, u, !0) : fe(0);
  return {
    width: n.width * c.x,
    height: n.height * c.y,
    x: n.x * c.x - u.scrollLeft * c.x + g.x + a.x,
    y: n.y * c.y - u.scrollTop * c.y + g.y + a.y
  };
}
function Xo(e) {
  return Array.from(e.getClientRects());
}
function zo(e) {
  const t = de(e), n = rt(e), r = e.ownerDocument.body, o = Z(t.scrollWidth, t.clientWidth, r.scrollWidth, r.clientWidth), i = Z(t.scrollHeight, t.clientHeight, r.scrollHeight, r.clientHeight);
  let s = -n.scrollLeft + Bt(e);
  const l = -n.scrollTop;
  return re(r).direction === "rtl" && (s += Z(t.clientWidth, r.clientWidth) - o), {
    width: o,
    height: i,
    x: s,
    y: l
  };
}
function Jo(e, t) {
  const n = J(e), r = de(e), o = n.visualViewport;
  let i = r.clientWidth, s = r.clientHeight, l = 0, u = 0;
  if (o) {
    i = o.width, s = o.height;
    const c = nt();
    (!c || c && t === "fixed") && (l = o.offsetLeft, u = o.offsetTop);
  }
  return {
    width: i,
    height: s,
    x: l,
    y: u
  };
}
const Zo = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Qo(e, t) {
  const n = Oe(e, !0, t === "fixed"), r = n.top + e.clientTop, o = n.left + e.clientLeft, i = ee(e) ? Pe(e) : fe(1), s = e.clientWidth * i.x, l = e.clientHeight * i.y, u = o * i.x, c = r * i.y;
  return {
    width: s,
    height: l,
    x: u,
    y: c
  };
}
function bn(e, t, n) {
  let r;
  if (t === "viewport")
    r = Jo(e, n);
  else if (t === "document")
    r = zo(de(e));
  else if (W(t))
    r = Qo(t, n);
  else {
    const o = nr(e);
    r = {
      x: t.x - o.x,
      y: t.y - o.y,
      width: t.width,
      height: t.height
    };
  }
  return Ge(r);
}
function or(e, t) {
  const n = pe(e);
  return n === t || !W(n) || me(n) ? !1 : re(n).position === "fixed" || or(n, t);
}
function ei(e, t) {
  const n = t.get(e);
  if (n)
    return n;
  let r = we(e, [], !1).filter((l) => W(l) && _e(l) !== "body"), o = null;
  const i = re(e).position === "fixed";
  let s = i ? pe(e) : e;
  for (; W(s) && !me(s); ) {
    const l = re(s), u = Dt(s);
    !u && l.position === "fixed" && (o = null), (i ? !u && !o : !u && l.position === "static" && !!o && Zo.has(o.position) || Ne(s) && !u && or(e, s)) ? r = r.filter((g) => g !== s) : o = l, s = pe(s);
  }
  return t.set(e, r), r;
}
function ti(e) {
  let {
    element: t,
    boundary: n,
    rootBoundary: r,
    strategy: o
  } = e;
  const s = [...n === "clippingAncestors" ? tt(t) ? [] : ei(t, this._c) : [].concat(n), r], l = s[0], u = s.reduce((c, g) => {
    const f = bn(t, g, o);
    return c.top = Z(f.top, c.top), c.right = Re(f.right, c.right), c.bottom = Re(f.bottom, c.bottom), c.left = Z(f.left, c.left), c;
  }, bn(t, l, o));
  return {
    width: u.right - u.left,
    height: u.bottom - u.top,
    x: u.left,
    y: u.top
  };
}
function ni(e) {
  const {
    width: t,
    height: n
  } = tr(e);
  return {
    width: t,
    height: n
  };
}
function ri(e, t, n) {
  const r = ee(t), o = de(t), i = n === "fixed", s = Oe(e, !0, i, t);
  let l = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const u = fe(0);
  function c() {
    u.x = Bt(o);
  }
  if (r || !r && !i)
    if ((_e(t) !== "body" || Ne(o)) && (l = rt(t)), r) {
      const d = Oe(t, !0, i, t);
      u.x = d.x + t.clientLeft, u.y = d.y + t.clientTop;
    } else o && c();
  i && !r && o && c();
  const g = o && !r && !i ? rr(o, l) : fe(0), f = s.left + l.scrollLeft - u.x - g.x, a = s.top + l.scrollTop - u.y - g.y;
  return {
    x: f,
    y: a,
    width: s.width,
    height: s.height
  };
}
function ht(e) {
  return re(e).position === "static";
}
function wn(e, t) {
  if (!ee(e) || re(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let n = e.offsetParent;
  return de(e) === n && (n = n.ownerDocument.body), n;
}
function ir(e, t) {
  const n = J(e);
  if (tt(e))
    return n;
  if (!ee(e)) {
    let o = pe(e);
    for (; o && !me(o); ) {
      if (W(o) && !ht(o))
        return o;
      o = pe(o);
    }
    return n;
  }
  let r = wn(e, t);
  for (; r && Ar(r) && ht(r); )
    r = wn(r, t);
  return r && me(r) && ht(r) && !Dt(r) ? n : r || Lr(e) || n;
}
const oi = async function(e) {
  const t = this.getOffsetParent || ir, n = this.getDimensions, r = await n(e.floating);
  return {
    reference: ri(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: r.width,
      height: r.height
    }
  };
};
function ii(e) {
  return re(e).direction === "rtl";
}
const si = {
  convertOffsetParentRelativeRectToViewportRelativeRect: Go,
  getDocumentElement: de,
  getClippingRect: ti,
  getOffsetParent: ir,
  getElementRects: oi,
  getClientRects: Xo,
  getDimensions: ni,
  getScale: Pe,
  isElement: W,
  isRTL: ii
};
function sr(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function ci(e, t) {
  let n = null, r;
  const o = de(e);
  function i() {
    var l;
    clearTimeout(r), (l = n) == null || l.disconnect(), n = null;
  }
  function s(l, u) {
    l === void 0 && (l = !1), u === void 0 && (u = 1), i();
    const c = e.getBoundingClientRect(), {
      left: g,
      top: f,
      width: a,
      height: d
    } = c;
    if (l || t(), !a || !d)
      return;
    const m = Ve(f), p = Ve(o.clientWidth - (g + a)), v = Ve(o.clientHeight - (f + d)), R = Ve(g), b = {
      rootMargin: -m + "px " + -p + "px " + -v + "px " + -R + "px",
      threshold: Z(0, Re(1, u)) || 1
    };
    let E = !0;
    function A(_) {
      const I = _[0].intersectionRatio;
      if (I !== u) {
        if (!E)
          return s();
        I ? s(!1, I) : r = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      I === 1 && !sr(c, e.getBoundingClientRect()) && s(), E = !1;
    }
    try {
      n = new IntersectionObserver(A, {
        ...b,
        // Handle <iframe>s
        root: o.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(A, b);
    }
    n.observe(e);
  }
  return s(!0), i;
}
function Rn(e, t, n, r) {
  r === void 0 && (r = {});
  const {
    ancestorScroll: o = !0,
    ancestorResize: i = !0,
    elementResize: s = typeof ResizeObserver == "function",
    layoutShift: l = typeof IntersectionObserver == "function",
    animationFrame: u = !1
  } = r, c = Ht(e), g = o || i ? [...c ? we(c) : [], ...we(t)] : [];
  g.forEach((R) => {
    o && R.addEventListener("scroll", n, {
      passive: !0
    }), i && R.addEventListener("resize", n);
  });
  const f = c && l ? ci(c, n) : null;
  let a = -1, d = null;
  s && (d = new ResizeObserver((R) => {
    let [x] = R;
    x && x.target === c && d && (d.unobserve(t), cancelAnimationFrame(a), a = requestAnimationFrame(() => {
      var b;
      (b = d) == null || b.observe(t);
    })), n();
  }), c && !u && d.observe(c), d.observe(t));
  let m, p = u ? Oe(e) : null;
  u && v();
  function v() {
    const R = Oe(e);
    p && !sr(p, R) && n(), p = R, m = requestAnimationFrame(v);
  }
  return n(), () => {
    var R;
    g.forEach((x) => {
      o && x.removeEventListener("scroll", n), i && x.removeEventListener("resize", n);
    }), f == null || f(), (R = d) == null || R.disconnect(), d = null, u && cancelAnimationFrame(m);
  };
}
const ai = Wo, li = jo, ui = Ho, fi = qo, di = Bo, xn = $o, gi = Uo, mi = (e, t, n) => {
  const r = /* @__PURE__ */ new Map(), o = {
    platform: si,
    ...n
  }, i = {
    ...o.platform,
    _c: r
  };
  return Fo(e, t, {
    ...o,
    platform: i
  });
};
var hi = typeof document < "u", pi = function() {
}, qe = hi ? xr : pi;
function Qe(e, t) {
  if (e === t)
    return !0;
  if (typeof e != typeof t)
    return !1;
  if (typeof e == "function" && e.toString() === t.toString())
    return !0;
  let n, r, o;
  if (e && t && typeof e == "object") {
    if (Array.isArray(e)) {
      if (n = e.length, n !== t.length) return !1;
      for (r = n; r-- !== 0; )
        if (!Qe(e[r], t[r]))
          return !1;
      return !0;
    }
    if (o = Object.keys(e), n = o.length, n !== Object.keys(t).length)
      return !1;
    for (r = n; r-- !== 0; )
      if (!{}.hasOwnProperty.call(t, o[r]))
        return !1;
    for (r = n; r-- !== 0; ) {
      const i = o[r];
      if (!(i === "_owner" && e.$$typeof) && !Qe(e[i], t[i]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function cr(e) {
  return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function En(e, t) {
  const n = cr(e);
  return Math.round(t * n) / n;
}
function pt(e) {
  const t = h.useRef(e);
  return qe(() => {
    t.current = e;
  }), t;
}
function yi(e) {
  e === void 0 && (e = {});
  const {
    placement: t = "bottom",
    strategy: n = "absolute",
    middleware: r = [],
    platform: o,
    elements: {
      reference: i,
      floating: s
    } = {},
    transform: l = !0,
    whileElementsMounted: u,
    open: c
  } = e, [g, f] = h.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: t,
    middlewareData: {},
    isPositioned: !1
  }), [a, d] = h.useState(r);
  Qe(a, r) || d(r);
  const [m, p] = h.useState(null), [v, R] = h.useState(null), x = h.useCallback((y) => {
    y !== _.current && (_.current = y, p(y));
  }, []), b = h.useCallback((y) => {
    y !== I.current && (I.current = y, R(y));
  }, []), E = i || m, A = s || v, _ = h.useRef(null), I = h.useRef(null), j = h.useRef(g), k = u != null, V = pt(u), $ = pt(o), C = pt(c), w = h.useCallback(() => {
    if (!_.current || !I.current)
      return;
    const y = {
      placement: t,
      strategy: n,
      middleware: a
    };
    $.current && (y.platform = $.current), mi(_.current, I.current, y).then((T) => {
      const D = {
        ...T,
        // The floating element's position may be recomputed while it's closed
        // but still mounted (such as when transitioning out). To ensure
        // `isPositioned` will be `false` initially on the next open, avoid
        // setting it to `true` when `open === false` (must be specified).
        isPositioned: C.current !== !1
      };
      L.current && !Qe(j.current, D) && (j.current = D, ot.flushSync(() => {
        f(D);
      }));
    });
  }, [a, t, n, $, C]);
  qe(() => {
    c === !1 && j.current.isPositioned && (j.current.isPositioned = !1, f((y) => ({
      ...y,
      isPositioned: !1
    })));
  }, [c]);
  const L = h.useRef(!1);
  qe(() => (L.current = !0, () => {
    L.current = !1;
  }), []), qe(() => {
    if (E && (_.current = E), A && (I.current = A), E && A) {
      if (V.current)
        return V.current(E, A, w);
      w();
    }
  }, [E, A, w, V, k]);
  const O = h.useMemo(() => ({
    reference: _,
    floating: I,
    setReference: x,
    setFloating: b
  }), [x, b]), P = h.useMemo(() => ({
    reference: E,
    floating: A
  }), [E, A]), S = h.useMemo(() => {
    const y = {
      position: n,
      left: 0,
      top: 0
    };
    if (!P.floating)
      return y;
    const T = En(P.floating, g.x), D = En(P.floating, g.y);
    return l ? {
      ...y,
      transform: "translate(" + T + "px, " + D + "px)",
      ...cr(P.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: T,
      top: D
    };
  }, [n, l, P.floating, g.x, g.y]);
  return h.useMemo(() => ({
    ...g,
    update: w,
    refs: O,
    elements: P,
    floatingStyles: S
  }), [g, w, O, P, S]);
}
const vi = (e) => {
  function t(n) {
    return {}.hasOwnProperty.call(n, "current");
  }
  return {
    name: "arrow",
    options: e,
    fn(n) {
      const {
        element: r,
        padding: o
      } = typeof e == "function" ? e(n) : e;
      return r && t(r) ? r.current != null ? xn({
        element: r.current,
        padding: o
      }).fn(n) : {} : r ? xn({
        element: r,
        padding: o
      }).fn(n) : {};
    }
  };
}, bi = (e, t) => ({
  ...ai(e),
  options: [e, t]
}), wi = (e, t) => ({
  ...li(e),
  options: [e, t]
}), Ri = (e, t) => ({
  ...gi(e),
  options: [e, t]
}), xi = (e, t) => ({
  ...ui(e),
  options: [e, t]
}), Ei = (e, t) => ({
  ...fi(e),
  options: [e, t]
}), Oi = (e, t) => ({
  ...di(e),
  options: [e, t]
}), Si = (e, t) => ({
  ...vi(e),
  options: [e, t]
}), Ti = {
  pointerdown: "onPointerDown",
  mousedown: "onMouseDown",
  click: "onClick"
}, Ai = {
  pointerdown: "onPointerDownCapture",
  mousedown: "onMouseDownCapture",
  click: "onClickCapture"
}, On = (e) => ({
  escapeKey: typeof e == "boolean" ? e : (e == null ? void 0 : e.escapeKey) ?? !1,
  outsidePress: typeof e == "boolean" ? e : (e == null ? void 0 : e.outsidePress) ?? !0
});
function cs(e, t = {}) {
  const {
    open: n,
    onOpenChange: r,
    elements: o,
    dataRef: i
  } = e, {
    enabled: s = !0,
    escapeKey: l = !0,
    outsidePress: u = !0,
    outsidePressEvent: c = "pointerdown",
    referencePress: g = !1,
    referencePressEvent: f = "pointerdown",
    ancestorScroll: a = !1,
    bubbles: d,
    capture: m
  } = t, p = st(), v = Q(typeof u == "function" ? u : () => !1), R = typeof u == "function" ? v : u, x = h.useRef(!1), {
    escapeKey: b,
    outsidePress: E
  } = On(d), {
    escapeKey: A,
    outsidePress: _
  } = On(m), I = h.useRef(!1), j = Le(), k = Q((O) => {
    var y;
    if (!n || !s || !l || O.key !== "Escape" || I.current)
      return;
    const P = (y = i.current.floatingContext) == null ? void 0 : y.nodeId, S = p ? Ce(p.nodesRef.current, P) : [];
    if (!b && (O.stopPropagation(), S.length > 0)) {
      let T = !0;
      if (S.forEach((D) => {
        var H;
        (H = D.context) != null && H.open && !D.context.dataRef.current.__escapeKeyBubbles && (T = !1);
      }), !T)
        return;
    }
    r(!1, Vr(O) ? O.nativeEvent : O, "escape-key");
  }), V = Q((O) => {
    var S;
    const P = () => {
      var y;
      k(O), (y = Ee(O)) == null || y.removeEventListener("keydown", P);
    };
    (S = Ee(O)) == null || S.addEventListener("keydown", P);
  }), $ = Q((O) => {
    var te;
    const P = i.current.insideReactTree;
    i.current.insideReactTree = !1;
    const S = x.current;
    if (x.current = !1, c === "click" && S || P || typeof R == "function" && !R(O))
      return;
    const y = Ee(O), T = `[${ct("inert")}]`, D = se(o.floating).querySelectorAll(T);
    let H = W(y) ? y : null;
    for (; H && !me(H); ) {
      const N = pe(H);
      if (me(N) || !W(N))
        break;
      H = N;
    }
    if (D.length && W(y) && !Hr(y) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
    !he(y, o.floating) && // If the target root element contains none of the markers, then the
    // element was injected after the floating element rendered.
    Array.from(D).every((N) => !he(H, N)))
      return;
    if (ee(y)) {
      const N = me(y), F = re(y), q = /auto|scroll/, ne = N || q.test(F.overflowX), ie = N || q.test(F.overflowY), ve = ne && y.clientWidth > 0 && y.scrollWidth > y.clientWidth, Se = ie && y.clientHeight > 0 && y.scrollHeight > y.clientHeight, ke = F.direction === "rtl", Fe = Se && (ke ? O.offsetX <= y.offsetWidth - y.clientWidth : O.offsetX > y.clientWidth), $e = ve && O.offsetY > y.clientHeight;
      if (Fe || $e)
        return;
    }
    const M = (te = i.current.floatingContext) == null ? void 0 : te.nodeId, B = p && Ce(p.nodesRef.current, M).some((N) => {
      var F;
      return ft(O, (F = N.context) == null ? void 0 : F.elements.floating);
    });
    if (ft(O, o.floating) || ft(O, o.domReference) || B)
      return;
    const X = p ? Ce(p.nodesRef.current, M) : [];
    if (X.length > 0) {
      let N = !0;
      if (X.forEach((F) => {
        var q;
        (q = F.context) != null && q.open && !F.context.dataRef.current.__outsidePressBubbles && (N = !1);
      }), !N)
        return;
    }
    r(!1, O, "outside-press");
  }), C = Q((O) => {
    var S;
    const P = () => {
      var y;
      $(O), (y = Ee(O)) == null || y.removeEventListener(c, P);
    };
    (S = Ee(O)) == null || S.addEventListener(c, P);
  });
  h.useEffect(() => {
    if (!n || !s)
      return;
    i.current.__escapeKeyBubbles = b, i.current.__outsidePressBubbles = E;
    const O = new _n();
    function P(H) {
      r(!1, H, "ancestor-scroll");
    }
    function S() {
      O.clear(), I.current = !0;
    }
    function y() {
      O.start(
        // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
        // Only apply to WebKit for the test to remain 0ms.
        nt() ? 5 : 0,
        () => {
          I.current = !1;
        }
      );
    }
    const T = se(o.floating);
    l && (T.addEventListener("keydown", A ? V : k, A), T.addEventListener("compositionstart", S), T.addEventListener("compositionend", y)), R && T.addEventListener(c, _ ? C : $, _);
    let D = [];
    return a && (W(o.domReference) && (D = we(o.domReference)), W(o.floating) && (D = D.concat(we(o.floating))), !W(o.reference) && o.reference && o.reference.contextElement && (D = D.concat(we(o.reference.contextElement)))), D = D.filter((H) => {
      var M;
      return H !== ((M = T.defaultView) == null ? void 0 : M.visualViewport);
    }), D.forEach((H) => {
      H.addEventListener("scroll", P, {
        passive: !0
      });
    }), () => {
      l && (T.removeEventListener("keydown", A ? V : k, A), T.removeEventListener("compositionstart", S), T.removeEventListener("compositionend", y)), R && T.removeEventListener(c, _ ? C : $, _), D.forEach((H) => {
        H.removeEventListener("scroll", P);
      }), O.clear();
    };
  }, [i, o, l, R, c, n, r, a, s, b, E, k, A, V, $, _, C]), h.useEffect(() => {
    i.current.insideReactTree = !1;
  }, [i, R, c]);
  const w = h.useMemo(() => ({
    onKeyDown: k,
    ...g && {
      [Ti[f]]: (O) => {
        r(!1, O.nativeEvent, "reference-press");
      },
      ...f !== "click" && {
        onClick(O) {
          r(!1, O.nativeEvent, "reference-press");
        }
      }
    }
  }), [k, r, g, f]), L = h.useMemo(() => ({
    onKeyDown: k,
    onMouseDown() {
      x.current = !0;
    },
    onMouseUp() {
      x.current = !0;
    },
    [Ai[c]]: () => {
      i.current.insideReactTree = !0;
    },
    onBlurCapture() {
      p || (i.current.insideReactTree = !0, j.start(0, () => {
        i.current.insideReactTree = !1;
      }));
    }
  }), [k, c, i, p, j]);
  return h.useMemo(() => s ? {
    reference: w,
    floating: L
  } : {}, [s, w, L]);
}
function Ci(e) {
  const {
    open: t = !1,
    onOpenChange: n,
    elements: r
  } = e, o = Nt(), i = h.useRef({}), [s] = h.useState(() => Zn()), l = it() != null;
  if (process.env.NODE_ENV !== "production") {
    const d = r.reference;
    d && !W(d) && console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `refs.setPositionReference()`", "instead.");
  }
  const [u, c] = h.useState(r.reference), g = Q((d, m, p) => {
    i.current.openEvent = d ? m : void 0, s.emit("openchange", {
      open: d,
      event: m,
      reason: p,
      nested: l
    }), n == null || n(d, m, p);
  }), f = h.useMemo(() => ({
    setPositionReference: c
  }), []), a = h.useMemo(() => ({
    reference: u || r.reference || null,
    floating: r.floating || null,
    domReference: r.reference
  }), [u, r.reference, r.floating]);
  return h.useMemo(() => ({
    dataRef: i,
    open: t,
    onOpenChange: g,
    elements: a,
    events: s,
    floatingId: o,
    refs: f
  }), [t, g, a, s, o, f]);
}
function Pi(e = {}) {
  const {
    nodeId: t
  } = e, n = Ci({
    ...e,
    elements: {
      reference: null,
      floating: null,
      ...e.elements
    }
  }), r = e.rootContext || n, o = r.elements, [i, s] = h.useState(null), [l, u] = h.useState(null), g = (o == null ? void 0 : o.domReference) || i, f = h.useRef(null), a = st();
  z(() => {
    g && (f.current = g);
  }, [g]);
  const d = yi({
    ...e,
    elements: {
      ...o,
      ...l && {
        reference: l
      }
    }
  }), m = h.useCallback((b) => {
    const E = W(b) ? {
      getBoundingClientRect: () => b.getBoundingClientRect(),
      getClientRects: () => b.getClientRects(),
      contextElement: b
    } : b;
    u(E), d.refs.setReference(E);
  }, [d.refs]), p = h.useCallback((b) => {
    (W(b) || b === null) && (f.current = b, s(b)), (W(d.refs.reference.current) || d.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
    // `null` to support `positionReference` + an unstable `reference`
    // callback ref.
    b !== null && !W(b)) && d.refs.setReference(b);
  }, [d.refs]), v = h.useMemo(() => ({
    ...d.refs,
    setReference: p,
    setPositionReference: m,
    domReference: f
  }), [d.refs, p, m]), R = h.useMemo(() => ({
    ...d.elements,
    domReference: g
  }), [d.elements, g]), x = h.useMemo(() => ({
    ...d,
    ...r,
    refs: v,
    elements: R,
    nodeId: t
  }), [d, v, R, t, r]);
  return z(() => {
    r.dataRef.current.floatingContext = x;
    const b = a == null ? void 0 : a.nodesRef.current.find((E) => E.id === t);
    b && (b.context = x);
  }), h.useMemo(() => ({
    ...d,
    context: x,
    refs: v,
    elements: R
  }), [d, v, R, x]);
}
const yt = Nr && kn;
function as(e, t = {}) {
  const {
    open: n,
    onOpenChange: r,
    events: o,
    dataRef: i,
    elements: s
  } = e, {
    enabled: l = !0,
    visibleOnly: u = !0
  } = t, c = h.useRef(!1), g = Le(), f = h.useRef(!0);
  h.useEffect(() => {
    if (!l)
      return;
    const d = J(s.domReference);
    function m() {
      !n && ee(s.domReference) && s.domReference === Et(se(s.domReference)) && (c.current = !0);
    }
    function p() {
      f.current = !0;
    }
    function v() {
      f.current = !1;
    }
    return d.addEventListener("blur", m), yt && (d.addEventListener("keydown", p, !0), d.addEventListener("pointerdown", v, !0)), () => {
      d.removeEventListener("blur", m), yt && (d.removeEventListener("keydown", p, !0), d.removeEventListener("pointerdown", v, !0));
    };
  }, [s.domReference, n, l]), h.useEffect(() => {
    if (!l)
      return;
    function d({
      reason: m
    }) {
      (m === "reference-press" || m === "escape-key") && (c.current = !0);
    }
    return o.on("openchange", d), () => {
      o.off("openchange", d);
    };
  }, [o, l]);
  const a = h.useMemo(() => ({
    onMouseLeave() {
      c.current = !1;
    },
    onFocus(d) {
      if (c.current)
        return;
      const m = Ee(d.nativeEvent);
      if (u && W(m)) {
        if (yt && !d.relatedTarget) {
          if (!f.current && !Bn(m))
            return;
        } else if (!Br(m))
          return;
      }
      r(!0, d.nativeEvent, "focus");
    },
    onBlur(d) {
      c.current = !1;
      const m = d.relatedTarget, p = d.nativeEvent, v = W(m) && m.hasAttribute(ct("focus-guard")) && m.getAttribute("data-type") === "outside";
      g.start(0, () => {
        var x;
        const R = Et(s.domReference ? s.domReference.ownerDocument : document);
        !m && R === s.domReference || he((x = i.current.floatingContext) == null ? void 0 : x.refs.floating.current, R) || he(s.domReference, R) || v || r(!1, p, "focus");
      });
    }
  }), [i, s.domReference, r, u, g]);
  return h.useMemo(() => l ? {
    reference: a
  } : {}, [l, a]);
}
function ls(e = []) {
  const t = e.map((l) => l == null ? void 0 : l.reference), n = e.map((l) => l == null ? void 0 : l.floating), r = e.map((l) => l == null ? void 0 : l.item), o = h.useCallback(
    (l) => vt(l, e, "reference"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    t
  ), i = h.useCallback(
    (l) => vt(l, e, "floating"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    n
  ), s = h.useCallback(
    (l) => vt(l, e, "item"),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    r
  );
  return h.useMemo(() => ({
    getReferenceProps: o,
    getFloatingProps: i,
    getItemProps: s
  }), [o, i, s]);
}
function vt(e, t, n) {
  var s;
  const r = /* @__PURE__ */ new Map(), o = n === "item", i = {};
  n === "floating" && (i.tabIndex = -1, i[xt] = "");
  for (const l in e)
    o && e && (l === $n || l === Hn) || (i[l] = e[l]);
  for (let l = 0; l < t.length; l += 1) {
    let u;
    const c = (s = t[l]) == null ? void 0 : s[n];
    typeof c == "function" ? u = e ? c(e) : null : u = c, u && Sn(i, u, o, r);
  }
  return Sn(i, e, o, r), i;
}
function Sn(e, t, n, r) {
  var o;
  for (const i in t) {
    const s = t[i];
    n && (i === $n || i === Hn) || (i.startsWith("on") ? (r.has(i) || r.set(i, []), typeof s == "function" && ((o = r.get(i)) == null || o.push(s), e[i] = (...l) => {
      var u;
      return (u = r.get(i)) == null ? void 0 : u.map((c) => c(...l)).find((c) => c !== void 0);
    })) : e[i] = s);
  }
}
function Tn(e, t) {
  const [n, r] = e;
  let o = !1;
  const i = t.length;
  for (let s = 0, l = i - 1; s < i; l = s++) {
    const [u, c] = t[s] || [0, 0], [g, f] = t[l] || [0, 0];
    c >= r != f >= r && n <= (g - u) * (r - c) / (f - c) + u && (o = !o);
  }
  return o;
}
function Di(e, t) {
  return e[0] >= t.x && e[0] <= t.x + t.width && e[1] >= t.y && e[1] <= t.y + t.height;
}
function us(e = {}) {
  const {
    buffer: t = 0.5,
    blockPointerEvents: n = !1,
    requireIntent: r = !0
  } = e, o = new _n();
  let i = !1, s = null, l = null, u = performance.now();
  function c(f, a) {
    const d = performance.now(), m = d - u;
    if (s === null || l === null || m === 0)
      return s = f, l = a, u = d, null;
    const p = f - s, v = a - l, x = Math.sqrt(p * p + v * v) / m;
    return s = f, l = a, u = d, x;
  }
  const g = ({
    x: f,
    y: a,
    placement: d,
    elements: m,
    onClose: p,
    nodeId: v,
    tree: R
  }) => function(b) {
    function E() {
      o.clear(), p();
    }
    if (o.clear(), !m.domReference || !m.floating || d == null || f == null || a == null)
      return;
    const {
      clientX: A,
      clientY: _
    } = b, I = [A, _], j = Ee(b), k = b.type === "mouseleave", V = he(m.floating, j), $ = he(m.domReference, j), C = m.domReference.getBoundingClientRect(), w = m.floating.getBoundingClientRect(), L = d.split("-")[0], O = f > w.right - w.width / 2, P = a > w.bottom - w.height / 2, S = Di(I, C), y = w.width > C.width, T = w.height > C.height, D = (y ? C : w).left, H = (y ? C : w).right, M = (T ? C : w).top, B = (T ? C : w).bottom;
    if (V && (i = !0, !k))
      return;
    if ($ && (i = !1), $ && !k) {
      i = !0;
      return;
    }
    if (k && W(b.relatedTarget) && he(m.floating, b.relatedTarget) || R && Ce(R.nodesRef.current, v).some(({
      context: N
    }) => N == null ? void 0 : N.open))
      return;
    if (L === "top" && a >= C.bottom - 1 || L === "bottom" && a <= C.top + 1 || L === "left" && f >= C.right - 1 || L === "right" && f <= C.left + 1)
      return E();
    let X = [];
    switch (L) {
      case "top":
        X = [[D, C.top + 1], [D, w.bottom - 1], [H, w.bottom - 1], [H, C.top + 1]];
        break;
      case "bottom":
        X = [[D, w.top + 1], [D, C.bottom - 1], [H, C.bottom - 1], [H, w.top + 1]];
        break;
      case "left":
        X = [[w.right - 1, B], [w.right - 1, M], [C.left + 1, M], [C.left + 1, B]];
        break;
      case "right":
        X = [[C.right - 1, B], [C.right - 1, M], [w.left + 1, M], [w.left + 1, B]];
        break;
    }
    function te([N, F]) {
      switch (L) {
        case "top": {
          const q = [y ? N + t / 2 : O ? N + t * 4 : N - t * 4, F + t + 1], ne = [y ? N - t / 2 : O ? N + t * 4 : N - t * 4, F + t + 1], ie = [[w.left, O || y ? w.bottom - t : w.top], [w.right, O ? y ? w.bottom - t : w.top : w.bottom - t]];
          return [q, ne, ...ie];
        }
        case "bottom": {
          const q = [y ? N + t / 2 : O ? N + t * 4 : N - t * 4, F - t], ne = [y ? N - t / 2 : O ? N + t * 4 : N - t * 4, F - t], ie = [[w.left, O || y ? w.top + t : w.bottom], [w.right, O ? y ? w.top + t : w.bottom : w.top + t]];
          return [q, ne, ...ie];
        }
        case "left": {
          const q = [N + t + 1, T ? F + t / 2 : P ? F + t * 4 : F - t * 4], ne = [N + t + 1, T ? F - t / 2 : P ? F + t * 4 : F - t * 4];
          return [...[[P || T ? w.right - t : w.left, w.top], [P ? T ? w.right - t : w.left : w.right - t, w.bottom]], q, ne];
        }
        case "right": {
          const q = [N - t, T ? F + t / 2 : P ? F + t * 4 : F - t * 4], ne = [N - t, T ? F - t / 2 : P ? F + t * 4 : F - t * 4], ie = [[P || T ? w.left + t : w.right, w.top], [P ? T ? w.left + t : w.right : w.left + t, w.bottom]];
          return [q, ne, ...ie];
        }
        default:
          return [];
      }
    }
    if (!Tn([A, _], X)) {
      if (i && !S)
        return E();
      if (!k && r) {
        const N = c(b.clientX, b.clientY);
        if (N !== null && N < 0.1)
          return E();
      }
      Tn([A, _], te([f, a])) ? !i && r && o.start(40, E) : E();
    }
  };
  return g.__options = {
    blockPointerEvents: n
  }, g;
}
function fs(e) {
  if (e)
    return {
      // Identical mappings
      "focus-out": "focus-out",
      "escape-key": "escape-key",
      "outside-press": "outside-press",
      "list-navigation": "list-navigation",
      // New mappings
      click: "trigger-press",
      hover: "trigger-hover",
      focus: "trigger-focus",
      "reference-press": "trigger-press",
      "safe-polygon": "trigger-hover",
      "ancestor-scroll": void 0
      // Not supported
    }[e];
}
function ar(e, t, n) {
  const r = e === "inline-start" || e === "inline-end";
  return {
    top: "top",
    right: r ? n ? "inline-start" : "inline-end" : "right",
    bottom: "bottom",
    left: r ? n ? "inline-end" : "inline-start" : "left"
  }[t];
}
function An(e, t, n) {
  const {
    rects: r,
    placement: o
  } = e;
  return {
    side: ar(t, oe(o), n),
    align: xe(o) || "center",
    anchor: {
      width: r.reference.width,
      height: r.reference.height
    },
    positioner: {
      width: r.floating.width,
      height: r.floating.height
    }
  };
}
function ds(e) {
  var zt, Jt;
  const {
    // Public parameters
    anchor: t,
    positionMethod: n = "absolute",
    side: r = "bottom",
    sideOffset: o = 0,
    align: i = "center",
    alignOffset: s = 0,
    collisionBoundary: l,
    collisionPadding: u = 5,
    sticky: c = !1,
    arrowPadding: g = 5,
    trackAnchor: f = !0,
    // Private parameters
    keepMounted: a = !1,
    floatingRootContext: d,
    mounted: m,
    collisionAvoidance: p,
    shiftCrossAxis: v = !1,
    nodeId: R,
    adaptiveOrigin: x
  } = e, b = p.side || "flip", E = p.align || "flip", A = p.fallbackAxisSide || "end", _ = typeof t == "function" ? t : void 0, I = Q(_), j = _ ? I : t, k = be(t), $ = vo() === "rtl", C = {
    top: "top",
    right: "right",
    bottom: "bottom",
    left: "left",
    "inline-end": $ ? "left" : "right",
    "inline-start": $ ? "right" : "left"
  }[r], w = i === "center" ? C : `${C}-${i}`, L = {
    boundary: l === "clipping-ancestors" ? "clippingAncestors" : l,
    padding: u
  }, O = h.useRef(null), P = be(o), S = be(s), D = [bi((U) => {
    const Y = An(U, r, $), ae = typeof P.current == "function" ? P.current(Y) : P.current, le = typeof S.current == "function" ? S.current(Y) : S.current;
    return {
      mainAxis: ae,
      crossAxis: le,
      alignmentAxis: le
    };
  }, [typeof o != "function" ? o : 0, typeof s != "function" ? s : 0, $, r])], H = E === "none" && b !== "shift", M = !H && (c || v || b === "shift"), B = b === "none" ? null : xi({
    ...L,
    mainAxis: !v && b === "flip",
    crossAxis: E === "flip" ? "alignment" : !1,
    fallbackAxisSideDirection: A
  }), X = H ? null : wi((U) => {
    const Y = se(U.elements.floating).documentElement;
    return {
      ...L,
      // Use the Layout Viewport to avoid shifting around when pinch-zooming
      // for context menus.
      rootBoundary: v ? {
        x: 0,
        y: 0,
        width: Y.clientWidth,
        height: Y.clientHeight
      } : void 0,
      mainAxis: E !== "none",
      crossAxis: M,
      limiter: c || v ? void 0 : Ri(() => {
        if (!O.current)
          return {};
        const {
          height: ae
        } = O.current.getBoundingClientRect();
        return {
          offset: ae / 2 + (typeof u == "number" ? u : 0)
        };
      })
    };
  }, [L, c, v, u, E]);
  b === "shift" || E === "shift" || i === "center" ? D.push(X, B) : D.push(B, X), D.push(Ei({
    ...L,
    apply({
      elements: {
        floating: U
      },
      rects: {
        reference: Y
      },
      availableWidth: ae,
      availableHeight: le
    }) {
      Object.entries({
        "--available-width": `${ae}px`,
        "--available-height": `${le}px`,
        "--anchor-width": `${Y.width}px`,
        "--anchor-height": `${Y.height}px`
      }).forEach(([Be, at]) => {
        U.style.setProperty(Be, at);
      });
    }
  }), Si(() => ({
    // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
    // we'll create a fake element.
    element: O.current || document.createElement("div"),
    padding: g
  }), [g]), Oi(), {
    name: "transformOrigin",
    fn(U) {
      var en, tn, nn;
      const {
        elements: Y,
        middlewareData: ae,
        placement: le,
        rects: Be,
        y: at
      } = U, Zt = oe(le), ur = ce(Zt), Te = O.current, fr = ((en = ae.arrow) == null ? void 0 : en.x) || 0, dr = ((tn = ae.arrow) == null ? void 0 : tn.y) || 0, gr = (Te == null ? void 0 : Te.clientWidth) || 0, mr = (Te == null ? void 0 : Te.clientHeight) || 0, lt = fr + gr / 2, Qt = dr + mr / 2, hr = Math.abs(((nn = ae.shift) == null ? void 0 : nn.y) || 0), pr = Be.reference.height / 2, yr = hr > (typeof o == "function" ? o(An(U, r, $)) : o), vr = {
        top: `${lt}px calc(100% + ${o}px)`,
        bottom: `${lt}px ${-o}px`,
        left: `calc(100% + ${o}px) ${Qt}px`,
        right: `${-o}px ${Qt}px`
      }[Zt], br = `${lt}px ${Be.reference.y + pr - at}px`;
      return Y.floating.style.setProperty("--transform-origin", M && ur === "y" && yr ? br : vr), {};
    }
  }, x);
  let te = d;
  !m && d && (te = {
    ...d,
    elements: {
      reference: null,
      floating: null,
      domReference: null
    }
  });
  const N = h.useMemo(() => ({
    elementResize: f && typeof ResizeObserver < "u",
    layoutShift: f && typeof IntersectionObserver < "u"
  }), [f]), {
    refs: F,
    elements: q,
    x: ne,
    y: ie,
    middlewareData: ve,
    update: Se,
    placement: ke,
    context: Fe,
    isPositioned: $e,
    floatingStyles: Vt
  } = Pi({
    rootContext: te,
    placement: w,
    middleware: D,
    strategy: n,
    whileElementsMounted: a ? void 0 : (...U) => Rn(...U, N),
    nodeId: R
  }), {
    sideX: Wt,
    sideY: jt
  } = ve.adaptiveOrigin || {}, Ut = h.useMemo(() => x ? {
    position: n,
    [Wt]: `${ne}px`,
    [jt]: `${ie}px`
  } : Vt, [x, Wt, jt, n, ne, ie, Vt]), He = h.useRef(null);
  z(() => {
    if (!m)
      return;
    const U = k.current, Y = typeof U == "function" ? U() : U, le = (Cn(Y) ? Y.current : Y) || null || null;
    le !== He.current && (F.setPositionReference(le), He.current = le);
  }, [m, F, j, k]), h.useEffect(() => {
    if (!m)
      return;
    const U = k.current;
    typeof U != "function" && Cn(U) && U.current !== He.current && (F.setPositionReference(U.current), He.current = U.current);
  }, [m, F, j, k]), h.useEffect(() => {
    if (a && m && q.domReference && q.floating)
      return Rn(q.domReference, q.floating, Se, N);
  }, [a, m, q, Se, N]);
  const lr = oe(ke), qt = ar(r, lr, $), Yt = xe(ke) || "center", Kt = !!((zt = ve.hide) != null && zt.referenceHidden), Gt = h.useMemo(() => {
    var U, Y;
    return {
      position: "absolute",
      top: (U = ve.arrow) == null ? void 0 : U.y,
      left: (Y = ve.arrow) == null ? void 0 : Y.x
    };
  }, [ve.arrow]), Xt = ((Jt = ve.arrow) == null ? void 0 : Jt.centerOffset) !== 0;
  return h.useMemo(() => ({
    positionerStyles: Ut,
    arrowStyles: Gt,
    arrowRef: O,
    arrowUncentered: Xt,
    side: qt,
    align: Yt,
    anchorHidden: Kt,
    refs: F,
    context: Fe,
    isPositioned: $e,
    update: Se
  }), [Ut, Gt, O, Xt, qt, Yt, Kt, F, Fe, $e, Se]);
}
function Cn(e) {
  return e != null && "current" in e;
}
export {
  Ui as $,
  Bi as A,
  Nt as B,
  se as C,
  _e as D,
  Wi as E,
  be as F,
  st as G,
  Io as H,
  ji as I,
  Gn as J,
  Xn as K,
  ee as L,
  ct as M,
  qi as N,
  Et as O,
  Qn as P,
  Ce as Q,
  Ki as R,
  Gi as S,
  Pt as T,
  dt as U,
  ho as V,
  po as W,
  zi as X,
  Xi as Y,
  So as Z,
  it as _,
  J as a,
  ki as a0,
  Fi as a1,
  ge as a2,
  ss as a3,
  ns as a4,
  rs as a5,
  vo as a6,
  os as a7,
  Ee as b,
  he as c,
  Ii as d,
  Ji as e,
  Qi as f,
  gt as g,
  Ci as h,
  Ot as i,
  is as j,
  as as k,
  cs as l,
  ls as m,
  es as n,
  ds as o,
  ts as p,
  Zi as q,
  ot as r,
  us as s,
  fs as t,
  ko as u,
  Yi as v,
  Vi as w,
  $i as x,
  Hi as y,
  Ve as z
};