import * as f from "react";
import { useLayoutEffect as un } from "react";
import { u as te, i as ie, P as ne, b as Z, k as fn, c as ht, d as dn, a as pn, l as mn, R as hn, S as gn, y as yn } from "./index.D1n9HtNk.js";
import { jsx as O, jsxs as vn } from "react/jsx-runtime";
import * as wn from "react-dom";
import xn from "react-dom";
function Ae() {
  return typeof window < "u";
}
function le(e) {
  return gt(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function H(e) {
  var t;
  return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function K(e) {
  var t;
  return (t = (gt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function gt(e) {
  return Ae() ? e instanceof Node || e instanceof H(e).Node : !1;
}
function V(e) {
  return Ae() ? e instanceof Element || e instanceof H(e).Element : !1;
}
function G(e) {
  return Ae() ? e instanceof HTMLElement || e instanceof H(e).HTMLElement : !1;
}
function et(e) {
  return !Ae() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof H(e).ShadowRoot;
}
const Cn = /* @__PURE__ */ new Set(["inline", "contents"]);
function pe(e) {
  const {
    overflow: t,
    overflowX: n,
    overflowY: o,
    display: r
  } = z(e);
  return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !Cn.has(r);
}
const bn = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Pn(e) {
  return bn.has(le(e));
}
const En = [":popover-open", ":modal"];
function Re(e) {
  return En.some((t) => {
    try {
      return e.matches(t);
    } catch {
      return !1;
    }
  });
}
const An = ["transform", "translate", "scale", "rotate", "perspective"], Rn = ["transform", "translate", "scale", "rotate", "perspective", "filter"], On = ["paint", "layout", "strict", "content"];
function $e(e) {
  const t = He(), n = V(e) ? z(e) : e;
  return An.some((o) => n[o] ? n[o] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !t && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !t && (n.filter ? n.filter !== "none" : !1) || Rn.some((o) => (n.willChange || "").includes(o)) || On.some((o) => (n.contain || "").includes(o));
}
function Tn(e) {
  let t = J(e);
  for (; G(t) && !se(t); ) {
    if ($e(t))
      return t;
    if (Re(t))
      return null;
    t = J(t);
  }
  return null;
}
function He() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Sn = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function se(e) {
  return Sn.has(le(e));
}
function z(e) {
  return H(e).getComputedStyle(e);
}
function Oe(e) {
  return V(e) ? {
    scrollLeft: e.scrollLeft,
    scrollTop: e.scrollTop
  } : {
    scrollLeft: e.scrollX,
    scrollTop: e.scrollY
  };
}
function J(e) {
  if (le(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.
    et(e) && e.host || // Fallback.
    K(e)
  );
  return et(t) ? t.host : t;
}
function yt(e) {
  const t = J(e);
  return se(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : G(t) && pe(t) ? t : yt(t);
}
function fe(e, t, n) {
  var o;
  t === void 0 && (t = []), n === void 0 && (n = !0);
  const r = yt(e), i = r === ((o = e.ownerDocument) == null ? void 0 : o.body), s = H(r);
  if (i) {
    const u = ke(s);
    return t.concat(s, s.visualViewport || [], pe(r) ? r : [], u && n ? fe(u) : []);
  }
  return t.concat(r, fe(r, [], n));
}
function ke(e) {
  return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
const vt = ["top", "right", "bottom", "left"], tt = ["start", "end"], nt = /* @__PURE__ */ vt.reduce((e, t) => e.concat(t, t + "-" + tt[0], t + "-" + tt[1]), []), Q = Math.min, $ = Math.max, we = Math.round, ge = Math.floor, X = (e) => ({
  x: e,
  y: e
}), Dn = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Ln = {
  start: "end",
  end: "start"
};
function _e(e, t, n) {
  return $(e, Q(t, n));
}
function q(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function U(e) {
  return e.split("-")[0];
}
function W(e) {
  return e.split("-")[1];
}
function We(e) {
  return e === "x" ? "y" : "x";
}
function Ve(e) {
  return e === "y" ? "height" : "width";
}
const Nn = /* @__PURE__ */ new Set(["top", "bottom"]);
function Y(e) {
  return Nn.has(U(e)) ? "y" : "x";
}
function ze(e) {
  return We(Y(e));
}
function wt(e, t, n) {
  n === void 0 && (n = !1);
  const o = W(e), r = ze(e), i = Ve(r);
  let s = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
  return t.reference[i] > t.floating[i] && (s = Ce(s)), [s, Ce(s)];
}
function Mn(e) {
  const t = Ce(e);
  return [xe(e), t, xe(t)];
}
function xe(e) {
  return e.replace(/start|end/g, (t) => Ln[t]);
}
const ot = ["left", "right"], rt = ["right", "left"], kn = ["top", "bottom"], _n = ["bottom", "top"];
function Bn(e, t, n) {
  switch (e) {
    case "top":
    case "bottom":
      return n ? t ? rt : ot : t ? ot : rt;
    case "left":
    case "right":
      return t ? kn : _n;
    default:
      return [];
  }
}
function Fn(e, t, n, o) {
  const r = W(e);
  let i = Bn(U(e), n === "start", o);
  return r && (i = i.map((s) => s + "-" + r), t && (i = i.concat(i.map(xe)))), i;
}
function Ce(e) {
  return e.replace(/left|right|bottom|top/g, (t) => Dn[t]);
}
function In(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function xt(e) {
  return typeof e != "number" ? In(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function be(e) {
  const {
    x: t,
    y: n,
    width: o,
    height: r
  } = e;
  return {
    width: o,
    height: r,
    top: n,
    left: t,
    right: t + o,
    bottom: n + r,
    x: t,
    y: n
  };
}
function it(e, t, n) {
  let {
    reference: o,
    floating: r
  } = e;
  const i = Y(t), s = ze(t), u = Ve(s), a = U(t), c = i === "y", l = o.x + o.width / 2 - r.width / 2, d = o.y + o.height / 2 - r.height / 2, m = o[u] / 2 - r[u] / 2;
  let p;
  switch (a) {
    case "top":
      p = {
        x: l,
        y: o.y - r.height
      };
      break;
    case "bottom":
      p = {
        x: l,
        y: o.y + o.height
      };
      break;
    case "right":
      p = {
        x: o.x + o.width,
        y: d
      };
      break;
    case "left":
      p = {
        x: o.x - r.width,
        y: d
      };
      break;
    default:
      p = {
        x: o.x,
        y: o.y
      };
  }
  switch (W(t)) {
    case "start":
      p[s] -= m * (n && c ? -1 : 1);
      break;
    case "end":
      p[s] += m * (n && c ? -1 : 1);
      break;
  }
  return p;
}
const $n = async (e, t, n) => {
  const {
    placement: o = "bottom",
    strategy: r = "absolute",
    middleware: i = [],
    platform: s
  } = n, u = i.filter(Boolean), a = await (s.isRTL == null ? void 0 : s.isRTL(t));
  let c = await s.getElementRects({
    reference: e,
    floating: t,
    strategy: r
  }), {
    x: l,
    y: d
  } = it(c, o, a), m = o, p = {}, h = 0;
  for (let g = 0; g < u.length; g++) {
    const {
      name: y,
      fn: v
    } = u[g], {
      x: w,
      y: b,
      data: x,
      reset: C
    } = await v({
      x: l,
      y: d,
      initialPlacement: o,
      placement: m,
      strategy: r,
      middlewareData: p,
      rects: c,
      platform: s,
      elements: {
        reference: e,
        floating: t
      }
    });
    l = w ?? l, d = b ?? d, p = {
      ...p,
      [y]: {
        ...p[y],
        ...x
      }
    }, C && h <= 50 && (h++, typeof C == "object" && (C.placement && (m = C.placement), C.rects && (c = C.rects === !0 ? await s.getElementRects({
      reference: e,
      floating: t,
      strategy: r
    }) : C.rects), {
      x: l,
      y: d
    } = it(c, m, a)), g = -1);
  }
  return {
    x: l,
    y: d,
    placement: m,
    strategy: r,
    middlewareData: p
  };
};
async function ae(e, t) {
  var n;
  t === void 0 && (t = {});
  const {
    x: o,
    y: r,
    platform: i,
    rects: s,
    elements: u,
    strategy: a
  } = e, {
    boundary: c = "clippingAncestors",
    rootBoundary: l = "viewport",
    elementContext: d = "floating",
    altBoundary: m = !1,
    padding: p = 0
  } = q(t, e), h = xt(p), y = u[m ? d === "floating" ? "reference" : "floating" : d], v = be(await i.getClippingRect({
    element: (n = await (i.isElement == null ? void 0 : i.isElement(y))) == null || n ? y : y.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(u.floating)),
    boundary: c,
    rootBoundary: l,
    strategy: a
  })), w = d === "floating" ? {
    x: o,
    y: r,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, b = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(u.floating)), x = 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
  }, C = be(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: u,
    rect: w,
    offsetParent: b,
    strategy: a
  }) : w);
  return {
    top: (v.top - C.top + h.top) / x.y,
    bottom: (C.bottom - v.bottom + h.bottom) / x.y,
    left: (v.left - C.left + h.left) / x.x,
    right: (C.right - v.right + h.right) / x.x
  };
}
const Hn = (e) => ({
  name: "arrow",
  options: e,
  async fn(t) {
    const {
      x: n,
      y: o,
      placement: r,
      rects: i,
      platform: s,
      elements: u,
      middlewareData: a
    } = t, {
      element: c,
      padding: l = 0
    } = q(e, t) || {};
    if (c == null)
      return {};
    const d = xt(l), m = {
      x: n,
      y: o
    }, p = ze(r), h = Ve(p), g = await s.getDimensions(c), y = p === "y", v = y ? "top" : "left", w = y ? "bottom" : "right", b = y ? "clientHeight" : "clientWidth", x = i.reference[h] + i.reference[p] - m[p] - i.floating[h], C = m[p] - i.reference[p], E = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(c));
    let P = E ? E[b] : 0;
    (!P || !await (s.isElement == null ? void 0 : s.isElement(E))) && (P = u.floating[b] || i.floating[h]);
    const T = x / 2 - C / 2, N = P / 2 - g[h] / 2 - 1, R = Q(d[v], N), S = Q(d[w], N), _ = R, D = P - g[h] - S, L = P / 2 - g[h] / 2 + T, F = _e(_, L, D), M = !a.arrow && W(r) != null && L !== F && i.reference[h] / 2 - (L < _ ? R : S) - g[h] / 2 < 0, k = M ? L < _ ? L - _ : L - D : 0;
    return {
      [p]: m[p] + k,
      data: {
        [p]: F,
        centerOffset: L - F - k,
        ...M && {
          alignmentOffset: k
        }
      },
      reset: M
    };
  }
});
function Wn(e, t, n) {
  return (e ? [...n.filter((r) => W(r) === e), ...n.filter((r) => W(r) !== e)] : n.filter((r) => U(r) === r)).filter((r) => e ? W(r) === e || (t ? xe(r) !== r : !1) : !0);
}
const Vn = function(e) {
  return e === void 0 && (e = {}), {
    name: "autoPlacement",
    options: e,
    async fn(t) {
      var n, o, r;
      const {
        rects: i,
        middlewareData: s,
        placement: u,
        platform: a,
        elements: c
      } = t, {
        crossAxis: l = !1,
        alignment: d,
        allowedPlacements: m = nt,
        autoAlignment: p = !0,
        ...h
      } = q(e, t), g = d !== void 0 || m === nt ? Wn(d || null, p, m) : m, y = await ae(t, h), v = ((n = s.autoPlacement) == null ? void 0 : n.index) || 0, w = g[v];
      if (w == null)
        return {};
      const b = wt(w, i, await (a.isRTL == null ? void 0 : a.isRTL(c.floating)));
      if (u !== w)
        return {
          reset: {
            placement: g[0]
          }
        };
      const x = [y[U(w)], y[b[0]], y[b[1]]], C = [...((o = s.autoPlacement) == null ? void 0 : o.overflows) || [], {
        placement: w,
        overflows: x
      }], E = g[v + 1];
      if (E)
        return {
          data: {
            index: v + 1,
            overflows: C
          },
          reset: {
            placement: E
          }
        };
      const P = C.map((R) => {
        const S = W(R.placement);
        return [R.placement, S && l ? (
          // Check along the mainAxis and main crossAxis side.
          R.overflows.slice(0, 2).reduce((_, D) => _ + D, 0)
        ) : (
          // Check only the mainAxis.
          R.overflows[0]
        ), R.overflows];
      }).sort((R, S) => R[1] - S[1]), N = ((r = P.filter((R) => R[2].slice(
        0,
        // Aligned placements should not check their opposite crossAxis
        // side.
        W(R[0]) ? 2 : 3
      ).every((S) => S <= 0))[0]) == null ? void 0 : r[0]) || P[0][0];
      return N !== u ? {
        data: {
          index: v + 1,
          overflows: C
        },
        reset: {
          placement: N
        }
      } : {};
    }
  };
}, zn = function(e) {
  return e === void 0 && (e = {}), {
    name: "flip",
    options: e,
    async fn(t) {
      var n, o;
      const {
        placement: r,
        middlewareData: i,
        rects: s,
        initialPlacement: u,
        platform: a,
        elements: c
      } = t, {
        mainAxis: l = !0,
        crossAxis: d = !0,
        fallbackPlacements: m,
        fallbackStrategy: p = "bestFit",
        fallbackAxisSideDirection: h = "none",
        flipAlignment: g = !0,
        ...y
      } = q(e, t);
      if ((n = i.arrow) != null && n.alignmentOffset)
        return {};
      const v = U(r), w = Y(u), b = U(u) === u, x = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), C = m || (b || !g ? [Ce(u)] : Mn(u)), E = h !== "none";
      !m && E && C.push(...Fn(u, g, h, x));
      const P = [u, ...C], T = await ae(t, y), N = [];
      let R = ((o = i.flip) == null ? void 0 : o.overflows) || [];
      if (l && N.push(T[v]), d) {
        const L = wt(r, s, x);
        N.push(T[L[0]], T[L[1]]);
      }
      if (R = [...R, {
        placement: r,
        overflows: N
      }], !N.every((L) => L <= 0)) {
        var S, _;
        const L = (((S = i.flip) == null ? void 0 : S.index) || 0) + 1, F = P[L];
        if (F && (!(d === "alignment" ? w !== Y(F) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        R.every((A) => Y(A.placement) === w ? A.overflows[0] > 0 : !0)))
          return {
            data: {
              index: L,
              overflows: R
            },
            reset: {
              placement: F
            }
          };
        let M = (_ = R.filter((k) => k.overflows[0] <= 0).sort((k, A) => k.overflows[1] - A.overflows[1])[0]) == null ? void 0 : _.placement;
        if (!M)
          switch (p) {
            case "bestFit": {
              var D;
              const k = (D = R.filter((A) => {
                if (E) {
                  const B = Y(A.placement);
                  return B === w || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  B === "y";
                }
                return !0;
              }).map((A) => [A.placement, A.overflows.filter((B) => B > 0).reduce((B, j) => B + j, 0)]).sort((A, B) => A[1] - B[1])[0]) == null ? void 0 : D[0];
              k && (M = k);
              break;
            }
            case "initialPlacement":
              M = u;
              break;
          }
        if (r !== M)
          return {
            reset: {
              placement: M
            }
          };
      }
      return {};
    }
  };
};
function st(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function at(e) {
  return vt.some((t) => e[t] >= 0);
}
const Un = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: n
      } = t, {
        strategy: o = "referenceHidden",
        ...r
      } = q(e, t);
      switch (o) {
        case "referenceHidden": {
          const i = await ae(t, {
            ...r,
            elementContext: "reference"
          }), s = st(i, n.reference);
          return {
            data: {
              referenceHiddenOffsets: s,
              referenceHidden: at(s)
            }
          };
        }
        case "escaped": {
          const i = await ae(t, {
            ...r,
            altBoundary: !0
          }), s = st(i, n.floating);
          return {
            data: {
              escapedOffsets: s,
              escaped: at(s)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, Ct = /* @__PURE__ */ new Set(["left", "top"]);
async function jn(e, t) {
  const {
    placement: n,
    platform: o,
    elements: r
  } = e, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), s = U(n), u = W(n), a = Y(n) === "y", c = Ct.has(s) ? -1 : 1, l = i && a ? -1 : 1, d = q(t, e);
  let {
    mainAxis: m,
    crossAxis: p,
    alignmentAxis: h
  } = typeof d == "number" ? {
    mainAxis: d,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: d.mainAxis || 0,
    crossAxis: d.crossAxis || 0,
    alignmentAxis: d.alignmentAxis
  };
  return u && typeof h == "number" && (p = u === "end" ? h * -1 : h), a ? {
    x: p * l,
    y: m * c
  } : {
    x: m * c,
    y: p * l
  };
}
const Yn = function(e) {
  return e === void 0 && (e = 0), {
    name: "offset",
    options: e,
    async fn(t) {
      var n, o;
      const {
        x: r,
        y: i,
        placement: s,
        middlewareData: u
      } = t, a = await jn(t, e);
      return s === ((n = u.offset) == null ? void 0 : n.placement) && (o = u.arrow) != null && o.alignmentOffset ? {} : {
        x: r + a.x,
        y: i + a.y,
        data: {
          ...a,
          placement: s
        }
      };
    }
  };
}, Xn = function(e) {
  return e === void 0 && (e = {}), {
    name: "shift",
    options: e,
    async fn(t) {
      const {
        x: n,
        y: o,
        placement: r
      } = t, {
        mainAxis: i = !0,
        crossAxis: s = !1,
        limiter: u = {
          fn: (y) => {
            let {
              x: v,
              y: w
            } = y;
            return {
              x: v,
              y: w
            };
          }
        },
        ...a
      } = q(e, t), c = {
        x: n,
        y: o
      }, l = await ae(t, a), d = Y(U(r)), m = We(d);
      let p = c[m], h = c[d];
      if (i) {
        const y = m === "y" ? "top" : "left", v = m === "y" ? "bottom" : "right", w = p + l[y], b = p - l[v];
        p = _e(w, p, b);
      }
      if (s) {
        const y = d === "y" ? "top" : "left", v = d === "y" ? "bottom" : "right", w = h + l[y], b = h - l[v];
        h = _e(w, h, b);
      }
      const g = u.fn({
        ...t,
        [m]: p,
        [d]: h
      });
      return {
        ...g,
        data: {
          x: g.x - n,
          y: g.y - o,
          enabled: {
            [m]: i,
            [d]: s
          }
        }
      };
    }
  };
}, Gn = function(e) {
  return e === void 0 && (e = {}), {
    options: e,
    fn(t) {
      const {
        x: n,
        y: o,
        placement: r,
        rects: i,
        middlewareData: s
      } = t, {
        offset: u = 0,
        mainAxis: a = !0,
        crossAxis: c = !0
      } = q(e, t), l = {
        x: n,
        y: o
      }, d = Y(r), m = We(d);
      let p = l[m], h = l[d];
      const g = q(u, t), y = typeof g == "number" ? {
        mainAxis: g,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...g
      };
      if (a) {
        const b = m === "y" ? "height" : "width", x = i.reference[m] - i.floating[b] + y.mainAxis, C = i.reference[m] + i.reference[b] - y.mainAxis;
        p < x ? p = x : p > C && (p = C);
      }
      if (c) {
        var v, w;
        const b = m === "y" ? "width" : "height", x = Ct.has(U(r)), C = i.reference[d] - i.floating[b] + (x && ((v = s.offset) == null ? void 0 : v[d]) || 0) + (x ? 0 : y.crossAxis), E = i.reference[d] + i.reference[b] + (x ? 0 : ((w = s.offset) == null ? void 0 : w[d]) || 0) - (x ? y.crossAxis : 0);
        h < C ? h = C : h > E && (h = E);
      }
      return {
        [m]: p,
        [d]: h
      };
    }
  };
}, qn = function(e) {
  return e === void 0 && (e = {}), {
    name: "size",
    options: e,
    async fn(t) {
      var n, o;
      const {
        placement: r,
        rects: i,
        platform: s,
        elements: u
      } = t, {
        apply: a = () => {
        },
        ...c
      } = q(e, t), l = await ae(t, c), d = U(r), m = W(r), p = Y(r) === "y", {
        width: h,
        height: g
      } = i.floating;
      let y, v;
      d === "top" || d === "bottom" ? (y = d, v = m === (await (s.isRTL == null ? void 0 : s.isRTL(u.floating)) ? "start" : "end") ? "left" : "right") : (v = d, y = m === "end" ? "top" : "bottom");
      const w = g - l.top - l.bottom, b = h - l.left - l.right, x = Q(g - l[y], w), C = Q(h - l[v], b), E = !t.middlewareData.shift;
      let P = x, T = C;
      if ((n = t.middlewareData.shift) != null && n.enabled.x && (T = b), (o = t.middlewareData.shift) != null && o.enabled.y && (P = w), E && !m) {
        const R = $(l.left, 0), S = $(l.right, 0), _ = $(l.top, 0), D = $(l.bottom, 0);
        p ? T = h - 2 * (R !== 0 || S !== 0 ? R + S : $(l.left, l.right)) : P = g - 2 * (_ !== 0 || D !== 0 ? _ + D : $(l.top, l.bottom));
      }
      await a({
        ...t,
        availableWidth: T,
        availableHeight: P
      });
      const N = await s.getDimensions(u.floating);
      return h !== N.width || g !== N.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function bt(e) {
  const t = z(e);
  let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
  const r = G(e), i = r ? e.offsetWidth : n, s = r ? e.offsetHeight : o, u = we(n) !== i || we(o) !== s;
  return u && (n = i, o = s), {
    width: n,
    height: o,
    $: u
  };
}
function Ue(e) {
  return V(e) ? e : e.contextElement;
}
function re(e) {
  const t = Ue(e);
  if (!G(t))
    return X(1);
  const n = t.getBoundingClientRect(), {
    width: o,
    height: r,
    $: i
  } = bt(t);
  let s = (i ? we(n.width) : n.width) / o, u = (i ? we(n.height) : n.height) / r;
  return (!s || !Number.isFinite(s)) && (s = 1), (!u || !Number.isFinite(u)) && (u = 1), {
    x: s,
    y: u
  };
}
const Kn = /* @__PURE__ */ X(0);
function Pt(e) {
  const t = H(e);
  return !He() || !t.visualViewport ? Kn : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function Zn(e, t, n) {
  return t === void 0 && (t = !1), !n || t && n !== H(e) ? !1 : t;
}
function ee(e, t, n, o) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const r = e.getBoundingClientRect(), i = Ue(e);
  let s = X(1);
  t && (o ? V(o) && (s = re(o)) : s = re(e));
  const u = Zn(i, n, o) ? Pt(i) : X(0);
  let a = (r.left + u.x) / s.x, c = (r.top + u.y) / s.y, l = r.width / s.x, d = r.height / s.y;
  if (i) {
    const m = H(i), p = o && V(o) ? H(o) : o;
    let h = m, g = ke(h);
    for (; g && o && p !== h; ) {
      const y = re(g), v = g.getBoundingClientRect(), w = z(g), b = v.left + (g.clientLeft + parseFloat(w.paddingLeft)) * y.x, x = v.top + (g.clientTop + parseFloat(w.paddingTop)) * y.y;
      a *= y.x, c *= y.y, l *= y.x, d *= y.y, a += b, c += x, h = H(g), g = ke(h);
    }
  }
  return be({
    width: l,
    height: d,
    x: a,
    y: c
  });
}
function Te(e, t) {
  const n = Oe(e).scrollLeft;
  return t ? t.left + n : ee(K(e)).left + n;
}
function Et(e, t) {
  const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - Te(e, n), r = n.top + t.scrollTop;
  return {
    x: o,
    y: r
  };
}
function Jn(e) {
  let {
    elements: t,
    rect: n,
    offsetParent: o,
    strategy: r
  } = e;
  const i = r === "fixed", s = K(o), u = t ? Re(t.floating) : !1;
  if (o === s || u && i)
    return n;
  let a = {
    scrollLeft: 0,
    scrollTop: 0
  }, c = X(1);
  const l = X(0), d = G(o);
  if ((d || !d && !i) && ((le(o) !== "body" || pe(s)) && (a = Oe(o)), G(o))) {
    const p = ee(o);
    c = re(o), l.x = p.x + o.clientLeft, l.y = p.y + o.clientTop;
  }
  const m = s && !d && !i ? Et(s, a) : X(0);
  return {
    width: n.width * c.x,
    height: n.height * c.y,
    x: n.x * c.x - a.scrollLeft * c.x + l.x + m.x,
    y: n.y * c.y - a.scrollTop * c.y + l.y + m.y
  };
}
function Qn(e) {
  return Array.from(e.getClientRects());
}
function eo(e) {
  const t = K(e), n = Oe(e), o = e.ownerDocument.body, r = $(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), i = $(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
  let s = -n.scrollLeft + Te(e);
  const u = -n.scrollTop;
  return z(o).direction === "rtl" && (s += $(t.clientWidth, o.clientWidth) - r), {
    width: r,
    height: i,
    x: s,
    y: u
  };
}
const ct = 25;
function to(e, t) {
  const n = H(e), o = K(e), r = n.visualViewport;
  let i = o.clientWidth, s = o.clientHeight, u = 0, a = 0;
  if (r) {
    i = r.width, s = r.height;
    const l = He();
    (!l || l && t === "fixed") && (u = r.offsetLeft, a = r.offsetTop);
  }
  const c = Te(o);
  if (c <= 0) {
    const l = o.ownerDocument, d = l.body, m = getComputedStyle(d), p = l.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, h = Math.abs(o.clientWidth - d.clientWidth - p);
    h <= ct && (i -= h);
  } else c <= ct && (i += c);
  return {
    width: i,
    height: s,
    x: u,
    y: a
  };
}
const no = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function oo(e, t) {
  const n = ee(e, !0, t === "fixed"), o = n.top + e.clientTop, r = n.left + e.clientLeft, i = G(e) ? re(e) : X(1), s = e.clientWidth * i.x, u = e.clientHeight * i.y, a = r * i.x, c = o * i.y;
  return {
    width: s,
    height: u,
    x: a,
    y: c
  };
}
function lt(e, t, n) {
  let o;
  if (t === "viewport")
    o = to(e, n);
  else if (t === "document")
    o = eo(K(e));
  else if (V(t))
    o = oo(t, n);
  else {
    const r = Pt(e);
    o = {
      x: t.x - r.x,
      y: t.y - r.y,
      width: t.width,
      height: t.height
    };
  }
  return be(o);
}
function At(e, t) {
  const n = J(e);
  return n === t || !V(n) || se(n) ? !1 : z(n).position === "fixed" || At(n, t);
}
function ro(e, t) {
  const n = t.get(e);
  if (n)
    return n;
  let o = fe(e, [], !1).filter((u) => V(u) && le(u) !== "body"), r = null;
  const i = z(e).position === "fixed";
  let s = i ? J(e) : e;
  for (; V(s) && !se(s); ) {
    const u = z(s), a = $e(s);
    !a && u.position === "fixed" && (r = null), (i ? !a && !r : !a && u.position === "static" && !!r && no.has(r.position) || pe(s) && !a && At(e, s)) ? o = o.filter((l) => l !== s) : r = u, s = J(s);
  }
  return t.set(e, o), o;
}
function io(e) {
  let {
    element: t,
    boundary: n,
    rootBoundary: o,
    strategy: r
  } = e;
  const s = [...n === "clippingAncestors" ? Re(t) ? [] : ro(t, this._c) : [].concat(n), o], u = s[0], a = s.reduce((c, l) => {
    const d = lt(t, l, r);
    return c.top = $(d.top, c.top), c.right = Q(d.right, c.right), c.bottom = Q(d.bottom, c.bottom), c.left = $(d.left, c.left), c;
  }, lt(t, u, r));
  return {
    width: a.right - a.left,
    height: a.bottom - a.top,
    x: a.left,
    y: a.top
  };
}
function so(e) {
  const {
    width: t,
    height: n
  } = bt(e);
  return {
    width: t,
    height: n
  };
}
function ao(e, t, n) {
  const o = G(t), r = K(t), i = n === "fixed", s = ee(e, !0, i, t);
  let u = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const a = X(0);
  function c() {
    a.x = Te(r);
  }
  if (o || !o && !i)
    if ((le(t) !== "body" || pe(r)) && (u = Oe(t)), o) {
      const p = ee(t, !0, i, t);
      a.x = p.x + t.clientLeft, a.y = p.y + t.clientTop;
    } else r && c();
  i && !o && r && c();
  const l = r && !o && !i ? Et(r, u) : X(0), d = s.left + u.scrollLeft - a.x - l.x, m = s.top + u.scrollTop - a.y - l.y;
  return {
    x: d,
    y: m,
    width: s.width,
    height: s.height
  };
}
function Ne(e) {
  return z(e).position === "static";
}
function ut(e, t) {
  if (!G(e) || z(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let n = e.offsetParent;
  return K(e) === n && (n = n.ownerDocument.body), n;
}
function Rt(e, t) {
  const n = H(e);
  if (Re(e))
    return n;
  if (!G(e)) {
    let r = J(e);
    for (; r && !se(r); ) {
      if (V(r) && !Ne(r))
        return r;
      r = J(r);
    }
    return n;
  }
  let o = ut(e, t);
  for (; o && Pn(o) && Ne(o); )
    o = ut(o, t);
  return o && se(o) && Ne(o) && !$e(o) ? n : o || Tn(e) || n;
}
const co = async function(e) {
  const t = this.getOffsetParent || Rt, n = this.getDimensions, o = await n(e.floating);
  return {
    reference: ao(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: o.width,
      height: o.height
    }
  };
};
function lo(e) {
  return z(e).direction === "rtl";
}
const uo = {
  convertOffsetParentRelativeRectToViewportRelativeRect: Jn,
  getDocumentElement: K,
  getClippingRect: io,
  getOffsetParent: Rt,
  getElementRects: co,
  getClientRects: Qn,
  getDimensions: so,
  getScale: re,
  isElement: V,
  isRTL: lo
};
function Ot(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function fo(e, t) {
  let n = null, o;
  const r = K(e);
  function i() {
    var u;
    clearTimeout(o), (u = n) == null || u.disconnect(), n = null;
  }
  function s(u, a) {
    u === void 0 && (u = !1), a === void 0 && (a = 1), i();
    const c = e.getBoundingClientRect(), {
      left: l,
      top: d,
      width: m,
      height: p
    } = c;
    if (u || t(), !m || !p)
      return;
    const h = ge(d), g = ge(r.clientWidth - (l + m)), y = ge(r.clientHeight - (d + p)), v = ge(l), b = {
      rootMargin: -h + "px " + -g + "px " + -y + "px " + -v + "px",
      threshold: $(0, Q(1, a)) || 1
    };
    let x = !0;
    function C(E) {
      const P = E[0].intersectionRatio;
      if (P !== a) {
        if (!x)
          return s();
        P ? s(!1, P) : o = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      P === 1 && !Ot(c, e.getBoundingClientRect()) && s(), x = !1;
    }
    try {
      n = new IntersectionObserver(C, {
        ...b,
        // Handle <iframe>s
        root: r.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(C, b);
    }
    n.observe(e);
  }
  return s(!0), i;
}
function po(e, t, n, o) {
  o === void 0 && (o = {});
  const {
    ancestorScroll: r = !0,
    ancestorResize: i = !0,
    elementResize: s = typeof ResizeObserver == "function",
    layoutShift: u = typeof IntersectionObserver == "function",
    animationFrame: a = !1
  } = o, c = Ue(e), l = r || i ? [...c ? fe(c) : [], ...fe(t)] : [];
  l.forEach((v) => {
    r && v.addEventListener("scroll", n, {
      passive: !0
    }), i && v.addEventListener("resize", n);
  });
  const d = c && u ? fo(c, n) : null;
  let m = -1, p = null;
  s && (p = new ResizeObserver((v) => {
    let [w] = v;
    w && w.target === c && p && (p.unobserve(t), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
      var b;
      (b = p) == null || b.observe(t);
    })), n();
  }), c && !a && p.observe(c), p.observe(t));
  let h, g = a ? ee(e) : null;
  a && y();
  function y() {
    const v = ee(e);
    g && !Ot(g, v) && n(), g = v, h = requestAnimationFrame(y);
  }
  return n(), () => {
    var v;
    l.forEach((w) => {
      r && w.removeEventListener("scroll", n), i && w.removeEventListener("resize", n);
    }), d?.(), (v = p) == null || v.disconnect(), p = null, a && cancelAnimationFrame(h);
  };
}
const mo = Yn, ho = Vn, go = Xn, yo = zn, vo = qn, wo = Un, ft = Hn, xo = Gn, Co = (e, t, n) => {
  const o = /* @__PURE__ */ new Map(), r = {
    platform: uo,
    ...n
  }, i = {
    ...r.platform,
    _c: o
  };
  return $n(e, t, {
    ...r,
    platform: i
  });
};
var bo = typeof document < "u", Po = function() {
}, ve = bo ? un : Po;
function Pe(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, o, r;
  if (e && t && typeof e == "object") {
    if (Array.isArray(e)) {
      if (n = e.length, n !== t.length) return !1;
      for (o = n; o-- !== 0; )
        if (!Pe(e[o], t[o]))
          return !1;
      return !0;
    }
    if (r = Object.keys(e), n = r.length, n !== Object.keys(t).length)
      return !1;
    for (o = n; o-- !== 0; )
      if (!{}.hasOwnProperty.call(t, r[o]))
        return !1;
    for (o = n; o-- !== 0; ) {
      const i = r[o];
      if (!(i === "_owner" && e.$$typeof) && !Pe(e[i], t[i]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function Tt(e) {
  return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function dt(e, t) {
  const n = Tt(e);
  return Math.round(t * n) / n;
}
function Me(e) {
  const t = f.useRef(e);
  return ve(() => {
    t.current = e;
  }), t;
}
function Eo(e) {
  e === void 0 && (e = {});
  const {
    placement: t = "bottom",
    strategy: n = "absolute",
    middleware: o = [],
    platform: r,
    elements: {
      reference: i,
      floating: s
    } = {},
    transform: u = !0,
    whileElementsMounted: a,
    open: c
  } = e, [l, d] = f.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: t,
    middlewareData: {},
    isPositioned: !1
  }), [m, p] = f.useState(o);
  Pe(m, o) || p(o);
  const [h, g] = f.useState(null), [y, v] = f.useState(null), w = f.useCallback((A) => {
    A !== E.current && (E.current = A, g(A));
  }, []), b = f.useCallback((A) => {
    A !== P.current && (P.current = A, v(A));
  }, []), x = i || h, C = s || y, E = f.useRef(null), P = f.useRef(null), T = f.useRef(l), N = a != null, R = Me(a), S = Me(r), _ = Me(c), D = f.useCallback(() => {
    if (!E.current || !P.current)
      return;
    const A = {
      placement: t,
      strategy: n,
      middleware: m
    };
    S.current && (A.platform = S.current), Co(E.current, P.current, A).then((B) => {
      const j = {
        ...B,
        // 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: _.current !== !1
      };
      L.current && !Pe(T.current, j) && (T.current = j, wn.flushSync(() => {
        d(j);
      }));
    });
  }, [m, t, n, S, _]);
  ve(() => {
    c === !1 && T.current.isPositioned && (T.current.isPositioned = !1, d((A) => ({
      ...A,
      isPositioned: !1
    })));
  }, [c]);
  const L = f.useRef(!1);
  ve(() => (L.current = !0, () => {
    L.current = !1;
  }), []), ve(() => {
    if (x && (E.current = x), C && (P.current = C), x && C) {
      if (R.current)
        return R.current(x, C, D);
      D();
    }
  }, [x, C, D, R, N]);
  const F = f.useMemo(() => ({
    reference: E,
    floating: P,
    setReference: w,
    setFloating: b
  }), [w, b]), M = f.useMemo(() => ({
    reference: x,
    floating: C
  }), [x, C]), k = f.useMemo(() => {
    const A = {
      position: n,
      left: 0,
      top: 0
    };
    if (!M.floating)
      return A;
    const B = dt(M.floating, l.x), j = dt(M.floating, l.y);
    return u ? {
      ...A,
      transform: "translate(" + B + "px, " + j + "px)",
      ...Tt(M.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: B,
      top: j
    };
  }, [n, u, M.floating, l.x, l.y]);
  return f.useMemo(() => ({
    ...l,
    update: D,
    refs: F,
    elements: M,
    floatingStyles: k
  }), [l, D, F, M, k]);
}
const Ao = (e) => {
  function t(n) {
    return {}.hasOwnProperty.call(n, "current");
  }
  return {
    name: "arrow",
    options: e,
    fn(n) {
      const {
        element: o,
        padding: r
      } = typeof e == "function" ? e(n) : e;
      return o && t(o) ? o.current != null ? ft({
        element: o.current,
        padding: r
      }).fn(n) : {} : o ? ft({
        element: o,
        padding: r
      }).fn(n) : {};
    }
  };
}, Ro = (e, t) => ({
  ...mo(e),
  options: [e, t]
}), Oo = (e, t) => ({
  ...go(e),
  options: [e, t]
}), To = (e, t) => ({
  ...xo(e),
  options: [e, t]
}), So = (e, t) => ({
  ...yo(e),
  options: [e, t]
}), Do = (e, t) => ({
  ...vo(e),
  options: [e, t]
}), Dr = (e, t) => ({
  ...ho(e),
  options: [e, t]
}), Lo = (e, t) => ({
  ...wo(e),
  options: [e, t]
}), No = (e, t) => ({
  ...Ao(e),
  options: [e, t]
});
function Mo(e, t) {
  return f.useReducer((n, o) => t[n][o] ?? n, e);
}
var je = (e) => {
  const { present: t, children: n } = e, o = ko(t), r = typeof n == "function" ? n({ present: o.isPresent }) : f.Children.only(n), i = te(o.ref, _o(r));
  return typeof n == "function" || o.isPresent ? f.cloneElement(r, { ref: i }) : null;
};
je.displayName = "Presence";
function ko(e) {
  const [t, n] = f.useState(), o = f.useRef(null), r = f.useRef(e), i = f.useRef("none"), s = e ? "mounted" : "unmounted", [u, a] = Mo(s, {
    mounted: {
      UNMOUNT: "unmounted",
      ANIMATION_OUT: "unmountSuspended"
    },
    unmountSuspended: {
      MOUNT: "mounted",
      ANIMATION_END: "unmounted"
    },
    unmounted: {
      MOUNT: "mounted"
    }
  });
  return f.useEffect(() => {
    const c = ye(o.current);
    i.current = u === "mounted" ? c : "none";
  }, [u]), ie(() => {
    const c = o.current, l = r.current;
    if (l !== e) {
      const m = i.current, p = ye(c);
      e ? a("MOUNT") : p === "none" || c?.display === "none" ? a("UNMOUNT") : a(l && m !== p ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
    }
  }, [e, a]), ie(() => {
    if (t) {
      let c;
      const l = t.ownerDocument.defaultView ?? window, d = (p) => {
        const g = ye(o.current).includes(CSS.escape(p.animationName));
        if (p.target === t && g && (a("ANIMATION_END"), !r.current)) {
          const y = t.style.animationFillMode;
          t.style.animationFillMode = "forwards", c = l.setTimeout(() => {
            t.style.animationFillMode === "forwards" && (t.style.animationFillMode = y);
          });
        }
      }, m = (p) => {
        p.target === t && (i.current = ye(o.current));
      };
      return t.addEventListener("animationstart", m), t.addEventListener("animationcancel", d), t.addEventListener("animationend", d), () => {
        l.clearTimeout(c), t.removeEventListener("animationstart", m), t.removeEventListener("animationcancel", d), t.removeEventListener("animationend", d);
      };
    } else
      a("ANIMATION_END");
  }, [t, a]), {
    isPresent: ["mounted", "unmountSuspended"].includes(u),
    ref: f.useCallback((c) => {
      o.current = c ? getComputedStyle(c) : null, n(c);
    }, [])
  };
}
function ye(e) {
  return e?.animationName || "none";
}
function _o(e) {
  let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
var Bo = f[" useId ".trim().toString()] || (() => {
}), Fo = 0;
function Io(e) {
  const [t, n] = f.useState(Bo());
  return ie(() => {
    n((o) => o ?? String(Fo++));
  }, [e]), t ? `radix-${t}` : "";
}
var St = f.createContext(void 0), $o = (e) => {
  const { dir: t, children: n } = e;
  return /* @__PURE__ */ O(St.Provider, { value: t, children: n });
};
function Lr(e) {
  const t = f.useContext(St);
  return e || t || "ltr";
}
var Ho = $o;
function Se(e) {
  const t = f.useRef(e);
  return f.useEffect(() => {
    t.current = e;
  }), f.useMemo(() => (...n) => t.current?.(...n), []);
}
function Wo(e, t = globalThis?.document) {
  const n = Se(e);
  f.useEffect(() => {
    const o = (r) => {
      r.key === "Escape" && n(r);
    };
    return t.addEventListener("keydown", o, { capture: !0 }), () => t.removeEventListener("keydown", o, { capture: !0 });
  }, [n, t]);
}
var Vo = "DismissableLayer", Be = "dismissableLayer.update", zo = "dismissableLayer.pointerDownOutside", Uo = "dismissableLayer.focusOutside", pt, Dt = f.createContext({
  layers: /* @__PURE__ */ new Set(),
  layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
  branches: /* @__PURE__ */ new Set()
}), Lt = f.forwardRef(
  (e, t) => {
    const {
      disableOutsidePointerEvents: n = !1,
      onEscapeKeyDown: o,
      onPointerDownOutside: r,
      onFocusOutside: i,
      onInteractOutside: s,
      onDismiss: u,
      ...a
    } = e, c = f.useContext(Dt), [l, d] = f.useState(null), m = l?.ownerDocument ?? globalThis?.document, [, p] = f.useState({}), h = te(t, (P) => d(P)), g = Array.from(c.layers), [y] = [...c.layersWithOutsidePointerEventsDisabled].slice(-1), v = g.indexOf(y), w = l ? g.indexOf(l) : -1, b = c.layersWithOutsidePointerEventsDisabled.size > 0, x = w >= v, C = Xo((P) => {
      const T = P.target, N = [...c.branches].some((R) => R.contains(T));
      !x || N || (r?.(P), s?.(P), P.defaultPrevented || u?.());
    }, m), E = Go((P) => {
      const T = P.target;
      [...c.branches].some((R) => R.contains(T)) || (i?.(P), s?.(P), P.defaultPrevented || u?.());
    }, m);
    return Wo((P) => {
      w === c.layers.size - 1 && (o?.(P), !P.defaultPrevented && u && (P.preventDefault(), u()));
    }, m), f.useEffect(() => {
      if (l)
        return n && (c.layersWithOutsidePointerEventsDisabled.size === 0 && (pt = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), c.layersWithOutsidePointerEventsDisabled.add(l)), c.layers.add(l), mt(), () => {
          n && c.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = pt);
        };
    }, [l, m, n, c]), f.useEffect(() => () => {
      l && (c.layers.delete(l), c.layersWithOutsidePointerEventsDisabled.delete(l), mt());
    }, [l, c]), f.useEffect(() => {
      const P = () => p({});
      return document.addEventListener(Be, P), () => document.removeEventListener(Be, P);
    }, []), /* @__PURE__ */ O(
      ne.div,
      {
        ...a,
        ref: h,
        style: {
          pointerEvents: b ? x ? "auto" : "none" : void 0,
          ...e.style
        },
        onFocusCapture: Z(e.onFocusCapture, E.onFocusCapture),
        onBlurCapture: Z(e.onBlurCapture, E.onBlurCapture),
        onPointerDownCapture: Z(
          e.onPointerDownCapture,
          C.onPointerDownCapture
        )
      }
    );
  }
);
Lt.displayName = Vo;
var jo = "DismissableLayerBranch", Yo = f.forwardRef((e, t) => {
  const n = f.useContext(Dt), o = f.useRef(null), r = te(t, o);
  return f.useEffect(() => {
    const i = o.current;
    if (i)
      return n.branches.add(i), () => {
        n.branches.delete(i);
      };
  }, [n.branches]), /* @__PURE__ */ O(ne.div, { ...e, ref: r });
});
Yo.displayName = jo;
function Xo(e, t = globalThis?.document) {
  const n = Se(e), o = f.useRef(!1), r = f.useRef(() => {
  });
  return f.useEffect(() => {
    const i = (u) => {
      if (u.target && !o.current) {
        let a = function() {
          Nt(
            zo,
            n,
            c,
            { discrete: !0 }
          );
        };
        const c = { originalEvent: u };
        u.pointerType === "touch" ? (t.removeEventListener("click", r.current), r.current = a, t.addEventListener("click", r.current, { once: !0 })) : a();
      } else
        t.removeEventListener("click", r.current);
      o.current = !1;
    }, s = window.setTimeout(() => {
      t.addEventListener("pointerdown", i);
    }, 0);
    return () => {
      window.clearTimeout(s), t.removeEventListener("pointerdown", i), t.removeEventListener("click", r.current);
    };
  }, [t, n]), {
    // ensures we check React component tree (not just DOM tree)
    onPointerDownCapture: () => o.current = !0
  };
}
function Go(e, t = globalThis?.document) {
  const n = Se(e), o = f.useRef(!1);
  return f.useEffect(() => {
    const r = (i) => {
      i.target && !o.current && Nt(Uo, n, { originalEvent: i }, {
        discrete: !1
      });
    };
    return t.addEventListener("focusin", r), () => t.removeEventListener("focusin", r);
  }, [t, n]), {
    onFocusCapture: () => o.current = !0,
    onBlurCapture: () => o.current = !1
  };
}
function mt() {
  const e = new CustomEvent(Be);
  document.dispatchEvent(e);
}
function Nt(e, t, n, { discrete: o }) {
  const r = n.originalEvent.target, i = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
  t && r.addEventListener(e, t, { once: !0 }), o ? fn(r, i) : r.dispatchEvent(i);
}
var qo = "Portal", Ye = f.forwardRef((e, t) => {
  const { container: n, ...o } = e, [r, i] = f.useState(!1);
  ie(() => i(!0), []);
  const s = n || r && globalThis?.document?.body;
  return s ? xn.createPortal(/* @__PURE__ */ O(ne.div, { ...o, ref: t }), s) : null;
});
Ye.displayName = qo;
var Nr = Ye, Ko = "Arrow", Mt = f.forwardRef((e, t) => {
  const { children: n, width: o = 10, height: r = 5, ...i } = e;
  return /* @__PURE__ */ O(
    ne.svg,
    {
      ...i,
      ref: t,
      width: o,
      height: r,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: e.asChild ? n : /* @__PURE__ */ O("polygon", { points: "0,0 30,0 15,10" })
    }
  );
});
Mt.displayName = Ko;
var Zo = Mt, Xe = "Popper", [kt, _t] = ht(Xe), [Jo, Bt] = kt(Xe), Ft = (e) => {
  const { __scopePopper: t, children: n } = e, [o, r] = f.useState(null);
  return /* @__PURE__ */ O(Jo, { scope: t, anchor: o, onAnchorChange: r, children: n });
};
Ft.displayName = Xe;
var It = "PopperAnchor", $t = f.forwardRef(
  (e, t) => {
    const { __scopePopper: n, virtualRef: o, ...r } = e, i = Bt(It, n), s = f.useRef(null), u = te(t, s), a = f.useRef(null);
    return f.useEffect(() => {
      const c = a.current;
      a.current = o?.current || s.current, c !== a.current && i.onAnchorChange(a.current);
    }), o ? null : /* @__PURE__ */ O(ne.div, { ...r, ref: u });
  }
);
$t.displayName = It;
var Ge = "PopperContent", [Qo, er] = kt(Ge), Ht = f.forwardRef(
  (e, t) => {
    const {
      __scopePopper: n,
      side: o = "bottom",
      sideOffset: r = 0,
      align: i = "center",
      alignOffset: s = 0,
      arrowPadding: u = 0,
      avoidCollisions: a = !0,
      collisionBoundary: c = [],
      collisionPadding: l = 0,
      sticky: d = "partial",
      hideWhenDetached: m = !1,
      updatePositionStrategy: p = "optimized",
      onPlaced: h,
      ...g
    } = e, y = Bt(Ge, n), [v, w] = f.useState(null), b = te(t, (ue) => w(ue)), [x, C] = f.useState(null), E = dn(x), P = E?.width ?? 0, T = E?.height ?? 0, N = o + (i !== "center" ? "-" + i : ""), R = typeof l == "number" ? l : { top: 0, right: 0, bottom: 0, left: 0, ...l }, S = Array.isArray(c) ? c : [c], _ = S.length > 0, D = {
      padding: R,
      boundary: S.filter(nr),
      // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
      altBoundary: _
    }, { refs: L, floatingStyles: F, placement: M, isPositioned: k, middlewareData: A } = Eo({
      // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
      strategy: "fixed",
      placement: N,
      whileElementsMounted: (...ue) => po(...ue, {
        animationFrame: p === "always"
      }),
      elements: {
        reference: y.anchor
      },
      middleware: [
        Ro({ mainAxis: r + T, alignmentAxis: s }),
        a && Oo({
          mainAxis: !0,
          crossAxis: !1,
          limiter: d === "partial" ? To() : void 0,
          ...D
        }),
        a && So({ ...D }),
        Do({
          ...D,
          apply: ({ elements: ue, rects: Qe, availableWidth: sn, availableHeight: an }) => {
            const { width: cn, height: ln } = Qe.reference, he = ue.floating.style;
            he.setProperty("--radix-popper-available-width", `${sn}px`), he.setProperty("--radix-popper-available-height", `${an}px`), he.setProperty("--radix-popper-anchor-width", `${cn}px`), he.setProperty("--radix-popper-anchor-height", `${ln}px`);
          }
        }),
        x && No({ element: x, padding: u }),
        or({ arrowWidth: P, arrowHeight: T }),
        m && Lo({ strategy: "referenceHidden", ...D })
      ]
    }), [B, j] = zt(M), Je = Se(h);
    ie(() => {
      k && Je?.();
    }, [k, Je]);
    const en = A.arrow?.x, tn = A.arrow?.y, nn = A.arrow?.centerOffset !== 0, [on, rn] = f.useState();
    return ie(() => {
      v && rn(window.getComputedStyle(v).zIndex);
    }, [v]), /* @__PURE__ */ O(
      "div",
      {
        ref: L.setFloating,
        "data-radix-popper-content-wrapper": "",
        style: {
          ...F,
          transform: k ? F.transform : "translate(0, -200%)",
          // keep off the page when measuring
          minWidth: "max-content",
          zIndex: on,
          "--radix-popper-transform-origin": [
            A.transformOrigin?.x,
            A.transformOrigin?.y
          ].join(" "),
          // hide the content if using the hide middleware and should be hidden
          // set visibility to hidden and disable pointer events so the UI behaves
          // as if the PopperContent isn't there at all
          ...A.hide?.referenceHidden && {
            visibility: "hidden",
            pointerEvents: "none"
          }
        },
        dir: e.dir,
        children: /* @__PURE__ */ O(
          Qo,
          {
            scope: n,
            placedSide: B,
            onArrowChange: C,
            arrowX: en,
            arrowY: tn,
            shouldHideArrow: nn,
            children: /* @__PURE__ */ O(
              ne.div,
              {
                "data-side": B,
                "data-align": j,
                ...g,
                ref: b,
                style: {
                  ...g.style,
                  // if the PopperContent hasn't been placed yet (not all measurements done)
                  // we prevent animations so that users's animation don't kick in too early referring wrong sides
                  animation: k ? void 0 : "none"
                }
              }
            )
          }
        )
      }
    );
  }
);
Ht.displayName = Ge;
var Wt = "PopperArrow", tr = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right"
}, Vt = f.forwardRef(function(t, n) {
  const { __scopePopper: o, ...r } = t, i = er(Wt, o), s = tr[i.placedSide];
  return (
    // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
    // doesn't report size as we'd expect on SVG elements.
    // it reports their bounding box which is effectively the largest path inside the SVG.
    /* @__PURE__ */ O(
      "span",
      {
        ref: i.onArrowChange,
        style: {
          position: "absolute",
          left: i.arrowX,
          top: i.arrowY,
          [s]: 0,
          transformOrigin: {
            top: "",
            right: "0 0",
            bottom: "center 0",
            left: "100% 0"
          }[i.placedSide],
          transform: {
            top: "translateY(100%)",
            right: "translateY(50%) rotate(90deg) translateX(-50%)",
            bottom: "rotate(180deg)",
            left: "translateY(50%) rotate(-90deg) translateX(50%)"
          }[i.placedSide],
          visibility: i.shouldHideArrow ? "hidden" : void 0
        },
        children: /* @__PURE__ */ O(
          Zo,
          {
            ...r,
            ref: n,
            style: {
              ...r.style,
              // ensures the element can be measured correctly (mostly for if SVG)
              display: "block"
            }
          }
        )
      }
    )
  );
});
Vt.displayName = Wt;
function nr(e) {
  return e !== null;
}
var or = (e) => ({
  name: "transformOrigin",
  options: e,
  fn(t) {
    const { placement: n, rects: o, middlewareData: r } = t, s = r.arrow?.centerOffset !== 0, u = s ? 0 : e.arrowWidth, a = s ? 0 : e.arrowHeight, [c, l] = zt(n), d = { start: "0%", center: "50%", end: "100%" }[l], m = (r.arrow?.x ?? 0) + u / 2, p = (r.arrow?.y ?? 0) + a / 2;
    let h = "", g = "";
    return c === "bottom" ? (h = s ? d : `${m}px`, g = `${-a}px`) : c === "top" ? (h = s ? d : `${m}px`, g = `${o.floating.height + a}px`) : c === "right" ? (h = `${-a}px`, g = s ? d : `${p}px`) : c === "left" && (h = `${o.floating.width + a}px`, g = s ? d : `${p}px`), { data: { x: h, y: g } };
  }
});
function zt(e) {
  const [t, n = "center"] = e.split("-");
  return [t, n];
}
var rr = Ft, ir = $t, sr = Ht, ar = Vt, [De] = ht("Tooltip", [
  _t
]), Le = _t(), Ut = "TooltipProvider", cr = 700, Fe = "tooltip.open", [lr, qe] = De(Ut), jt = (e) => {
  const {
    __scopeTooltip: t,
    delayDuration: n = cr,
    skipDelayDuration: o = 300,
    disableHoverableContent: r = !1,
    children: i
  } = e, s = f.useRef(!0), u = f.useRef(!1), a = f.useRef(0);
  return f.useEffect(() => {
    const c = a.current;
    return () => window.clearTimeout(c);
  }, []), /* @__PURE__ */ O(
    lr,
    {
      scope: t,
      isOpenDelayedRef: s,
      delayDuration: n,
      onOpen: f.useCallback(() => {
        window.clearTimeout(a.current), s.current = !1;
      }, []),
      onClose: f.useCallback(() => {
        window.clearTimeout(a.current), a.current = window.setTimeout(
          () => s.current = !0,
          o
        );
      }, [o]),
      isPointerInTransitRef: u,
      onPointerInTransitChange: f.useCallback((c) => {
        u.current = c;
      }, []),
      disableHoverableContent: r,
      children: i
    }
  );
};
jt.displayName = Ut;
var de = "Tooltip", [ur, me] = De(de), Yt = (e) => {
  const {
    __scopeTooltip: t,
    children: n,
    open: o,
    defaultOpen: r,
    onOpenChange: i,
    disableHoverableContent: s,
    delayDuration: u
  } = e, a = qe(de, e.__scopeTooltip), c = Le(t), [l, d] = f.useState(null), m = Io(), p = f.useRef(0), h = s ?? a.disableHoverableContent, g = u ?? a.delayDuration, y = f.useRef(!1), [v, w] = pn({
    prop: o,
    defaultProp: r ?? !1,
    onChange: (P) => {
      P ? (a.onOpen(), document.dispatchEvent(new CustomEvent(Fe))) : a.onClose(), i?.(P);
    },
    caller: de
  }), b = f.useMemo(() => v ? y.current ? "delayed-open" : "instant-open" : "closed", [v]), x = f.useCallback(() => {
    window.clearTimeout(p.current), p.current = 0, y.current = !1, w(!0);
  }, [w]), C = f.useCallback(() => {
    window.clearTimeout(p.current), p.current = 0, w(!1);
  }, [w]), E = f.useCallback(() => {
    window.clearTimeout(p.current), p.current = window.setTimeout(() => {
      y.current = !0, w(!0), p.current = 0;
    }, g);
  }, [g, w]);
  return f.useEffect(() => () => {
    p.current && (window.clearTimeout(p.current), p.current = 0);
  }, []), /* @__PURE__ */ O(rr, { ...c, children: /* @__PURE__ */ O(
    ur,
    {
      scope: t,
      contentId: m,
      open: v,
      stateAttribute: b,
      trigger: l,
      onTriggerChange: d,
      onTriggerEnter: f.useCallback(() => {
        a.isOpenDelayedRef.current ? E() : x();
      }, [a.isOpenDelayedRef, E, x]),
      onTriggerLeave: f.useCallback(() => {
        h ? C() : (window.clearTimeout(p.current), p.current = 0);
      }, [C, h]),
      onOpen: x,
      onClose: C,
      disableHoverableContent: h,
      children: n
    }
  ) });
};
Yt.displayName = de;
var Ie = "TooltipTrigger", Xt = f.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = me(Ie, n), i = qe(Ie, n), s = Le(n), u = f.useRef(null), a = te(t, u, r.onTriggerChange), c = f.useRef(!1), l = f.useRef(!1), d = f.useCallback(() => c.current = !1, []);
    return f.useEffect(() => () => document.removeEventListener("pointerup", d), [d]), /* @__PURE__ */ O(ir, { asChild: !0, ...s, children: /* @__PURE__ */ O(
      ne.button,
      {
        "aria-describedby": r.open ? r.contentId : void 0,
        "data-state": r.stateAttribute,
        ...o,
        ref: a,
        onPointerMove: Z(e.onPointerMove, (m) => {
          m.pointerType !== "touch" && !l.current && !i.isPointerInTransitRef.current && (r.onTriggerEnter(), l.current = !0);
        }),
        onPointerLeave: Z(e.onPointerLeave, () => {
          r.onTriggerLeave(), l.current = !1;
        }),
        onPointerDown: Z(e.onPointerDown, () => {
          r.open && r.onClose(), c.current = !0, document.addEventListener("pointerup", d, { once: !0 });
        }),
        onFocus: Z(e.onFocus, () => {
          c.current || r.onOpen();
        }),
        onBlur: Z(e.onBlur, r.onClose),
        onClick: Z(e.onClick, r.onClose)
      }
    ) });
  }
);
Xt.displayName = Ie;
var Ke = "TooltipPortal", [fr, dr] = De(Ke, {
  forceMount: void 0
}), Gt = (e) => {
  const { __scopeTooltip: t, forceMount: n, children: o, container: r } = e, i = me(Ke, t);
  return /* @__PURE__ */ O(fr, { scope: t, forceMount: n, children: /* @__PURE__ */ O(je, { present: n || i.open, children: /* @__PURE__ */ O(Ye, { asChild: !0, container: r, children: o }) }) });
};
Gt.displayName = Ke;
var ce = "TooltipContent", qt = f.forwardRef(
  (e, t) => {
    const n = dr(ce, e.__scopeTooltip), { forceMount: o = n.forceMount, side: r = "top", ...i } = e, s = me(ce, e.__scopeTooltip);
    return /* @__PURE__ */ O(je, { present: o || s.open, children: s.disableHoverableContent ? /* @__PURE__ */ O(Kt, { side: r, ...i, ref: t }) : /* @__PURE__ */ O(pr, { side: r, ...i, ref: t }) });
  }
), pr = f.forwardRef((e, t) => {
  const n = me(ce, e.__scopeTooltip), o = qe(ce, e.__scopeTooltip), r = f.useRef(null), i = te(t, r), [s, u] = f.useState(null), { trigger: a, onClose: c } = n, l = r.current, { onPointerInTransitChange: d } = o, m = f.useCallback(() => {
    u(null), d(!1);
  }, [d]), p = f.useCallback(
    (h, g) => {
      const y = h.currentTarget, v = { x: h.clientX, y: h.clientY }, w = yr(v, y.getBoundingClientRect()), b = vr(v, w), x = wr(g.getBoundingClientRect()), C = Cr([...b, ...x]);
      u(C), d(!0);
    },
    [d]
  );
  return f.useEffect(() => () => m(), [m]), f.useEffect(() => {
    if (a && l) {
      const h = (y) => p(y, l), g = (y) => p(y, a);
      return a.addEventListener("pointerleave", h), l.addEventListener("pointerleave", g), () => {
        a.removeEventListener("pointerleave", h), l.removeEventListener("pointerleave", g);
      };
    }
  }, [a, l, p, m]), f.useEffect(() => {
    if (s) {
      const h = (g) => {
        const y = g.target, v = { x: g.clientX, y: g.clientY }, w = a?.contains(y) || l?.contains(y), b = !xr(v, s);
        w ? m() : b && (m(), c());
      };
      return document.addEventListener("pointermove", h), () => document.removeEventListener("pointermove", h);
    }
  }, [a, l, s, c, m]), /* @__PURE__ */ O(Kt, { ...e, ref: i });
}), [mr, hr] = De(de, { isInside: !1 }), gr = mn("TooltipContent"), Kt = f.forwardRef(
  (e, t) => {
    const {
      __scopeTooltip: n,
      children: o,
      "aria-label": r,
      onEscapeKeyDown: i,
      onPointerDownOutside: s,
      ...u
    } = e, a = me(ce, n), c = Le(n), { onClose: l } = a;
    return f.useEffect(() => (document.addEventListener(Fe, l), () => document.removeEventListener(Fe, l)), [l]), f.useEffect(() => {
      if (a.trigger) {
        const d = (m) => {
          m.target?.contains(a.trigger) && l();
        };
        return window.addEventListener("scroll", d, { capture: !0 }), () => window.removeEventListener("scroll", d, { capture: !0 });
      }
    }, [a.trigger, l]), /* @__PURE__ */ O(
      Lt,
      {
        asChild: !0,
        disableOutsidePointerEvents: !1,
        onEscapeKeyDown: i,
        onPointerDownOutside: s,
        onFocusOutside: (d) => d.preventDefault(),
        onDismiss: l,
        children: /* @__PURE__ */ vn(
          sr,
          {
            "data-state": a.stateAttribute,
            ...c,
            ...u,
            ref: t,
            style: {
              ...u.style,
              "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
              "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
              "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
              "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
              "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
            },
            children: [
              /* @__PURE__ */ O(gr, { children: o }),
              /* @__PURE__ */ O(mr, { scope: n, isInside: !0, children: /* @__PURE__ */ O(hn, { id: a.contentId, role: "tooltip", children: r || o }) })
            ]
          }
        )
      }
    );
  }
);
qt.displayName = ce;
var Zt = "TooltipArrow", Jt = f.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = Le(n);
    return hr(
      Zt,
      n
    ).isInside ? null : /* @__PURE__ */ O(ar, { ...r, ...o, ref: t });
  }
);
Jt.displayName = Zt;
function yr(e, t) {
  const n = Math.abs(t.top - e.y), o = Math.abs(t.bottom - e.y), r = Math.abs(t.right - e.x), i = Math.abs(t.left - e.x);
  switch (Math.min(n, o, r, i)) {
    case i:
      return "left";
    case r:
      return "right";
    case n:
      return "top";
    case o:
      return "bottom";
    default:
      throw new Error("unreachable");
  }
}
function vr(e, t, n = 5) {
  const o = [];
  switch (t) {
    case "top":
      o.push(
        { x: e.x - n, y: e.y + n },
        { x: e.x + n, y: e.y + n }
      );
      break;
    case "bottom":
      o.push(
        { x: e.x - n, y: e.y - n },
        { x: e.x + n, y: e.y - n }
      );
      break;
    case "left":
      o.push(
        { x: e.x + n, y: e.y - n },
        { x: e.x + n, y: e.y + n }
      );
      break;
    case "right":
      o.push(
        { x: e.x - n, y: e.y - n },
        { x: e.x - n, y: e.y + n }
      );
      break;
  }
  return o;
}
function wr(e) {
  const { top: t, right: n, bottom: o, left: r } = e;
  return [
    { x: r, y: t },
    { x: n, y: t },
    { x: n, y: o },
    { x: r, y: o }
  ];
}
function xr(e, t) {
  const { x: n, y: o } = e;
  let r = !1;
  for (let i = 0, s = t.length - 1; i < t.length; s = i++) {
    const u = t[i], a = t[s], c = u.x, l = u.y, d = a.x, m = a.y;
    l > o != m > o && n < (d - c) * (o - l) / (m - l) + c && (r = !r);
  }
  return r;
}
function Cr(e) {
  const t = e.slice();
  return t.sort((n, o) => n.x < o.x ? -1 : n.x > o.x ? 1 : n.y < o.y ? -1 : n.y > o.y ? 1 : 0), br(t);
}
function br(e) {
  if (e.length <= 1) return e.slice();
  const t = [];
  for (let o = 0; o < e.length; o++) {
    const r = e[o];
    for (; t.length >= 2; ) {
      const i = t[t.length - 1], s = t[t.length - 2];
      if ((i.x - s.x) * (r.y - s.y) >= (i.y - s.y) * (r.x - s.x)) t.pop();
      else break;
    }
    t.push(r);
  }
  t.pop();
  const n = [];
  for (let o = e.length - 1; o >= 0; o--) {
    const r = e[o];
    for (; n.length >= 2; ) {
      const i = n[n.length - 1], s = n[n.length - 2];
      if ((i.x - s.x) * (r.y - s.y) >= (i.y - s.y) * (r.x - s.x)) n.pop();
      else break;
    }
    n.push(r);
  }
  return n.pop(), t.length === 1 && n.length === 1 && t[0].x === n[0].x && t[0].y === n[0].y ? t : t.concat(n);
}
var Pr = jt, Mr = Yt, kr = Xt, _r = Gt, Br = qt, Fr = Jt;
function Er(e) {
  switch (e) {
    case "tomato":
    case "red":
    case "ruby":
    case "crimson":
    case "pink":
    case "plum":
    case "purple":
    case "violet":
      return "mauve";
    case "iris":
    case "indigo":
    case "blue":
    case "sky":
    case "cyan":
      return "slate";
    case "teal":
    case "jade":
    case "mint":
    case "green":
      return "sage";
    case "grass":
    case "lime":
      return "olive";
    case "yellow":
    case "amber":
    case "orange":
    case "brown":
    case "gold":
    case "bronze":
      return "sand";
    case "gray":
      return "gray";
  }
}
const I = { hasBackground: { default: !0 }, appearance: { default: "inherit" }, accentColor: { default: "indigo" }, grayColor: { default: "auto" }, panelBackground: { default: "translucent" }, radius: { default: "medium" }, scaling: { default: "100%" } }, oe = () => {
}, Ee = f.createContext(void 0);
function Ir() {
  const e = f.useContext(Ee);
  if (e === void 0) throw new Error("`useThemeContext` must be used within a `Theme`");
  return e;
}
const Ar = f.forwardRef((e, t) => f.useContext(Ee) === void 0 ? f.createElement(Pr, { delayDuration: 200 }, f.createElement(Ho, { dir: "ltr" }, f.createElement(Qt, { ...e, ref: t }))) : f.createElement(Ze, { ...e, ref: t }));
Ar.displayName = "Theme";
const Qt = f.forwardRef((e, t) => {
  const { appearance: n = I.appearance.default, accentColor: o = I.accentColor.default, grayColor: r = I.grayColor.default, panelBackground: i = I.panelBackground.default, radius: s = I.radius.default, scaling: u = I.scaling.default, hasBackground: a = I.hasBackground.default, ...c } = e, [l, d] = f.useState(n);
  f.useEffect(() => d(n), [n]);
  const [m, p] = f.useState(o);
  f.useEffect(() => p(o), [o]);
  const [h, g] = f.useState(r);
  f.useEffect(() => g(r), [r]);
  const [y, v] = f.useState(i);
  f.useEffect(() => v(i), [i]);
  const [w, b] = f.useState(s);
  f.useEffect(() => b(s), [s]);
  const [x, C] = f.useState(u);
  return f.useEffect(() => C(u), [u]), f.createElement(Ze, { ...c, ref: t, isRoot: !0, hasBackground: a, appearance: l, accentColor: m, grayColor: h, panelBackground: y, radius: w, scaling: x, onAppearanceChange: d, onAccentColorChange: p, onGrayColorChange: g, onPanelBackgroundChange: v, onRadiusChange: b, onScalingChange: C });
});
Qt.displayName = "ThemeRoot";
const Ze = f.forwardRef((e, t) => {
  const n = f.useContext(Ee), { asChild: o, isRoot: r, hasBackground: i, appearance: s = n?.appearance ?? I.appearance.default, accentColor: u = n?.accentColor ?? I.accentColor.default, grayColor: a = n?.resolvedGrayColor ?? I.grayColor.default, panelBackground: c = n?.panelBackground ?? I.panelBackground.default, radius: l = n?.radius ?? I.radius.default, scaling: d = n?.scaling ?? I.scaling.default, onAppearanceChange: m = oe, onAccentColorChange: p = oe, onGrayColorChange: h = oe, onPanelBackgroundChange: g = oe, onRadiusChange: y = oe, onScalingChange: v = oe, ...w } = e, b = o ? gn : "div", x = a === "auto" ? Er(u) : a, C = e.appearance === "light" || e.appearance === "dark", E = i === void 0 ? r || C : i;
  return f.createElement(Ee.Provider, { value: f.useMemo(() => ({ appearance: s, accentColor: u, grayColor: a, resolvedGrayColor: x, panelBackground: c, radius: l, scaling: d, onAppearanceChange: m, onAccentColorChange: p, onGrayColorChange: h, onPanelBackgroundChange: g, onRadiusChange: y, onScalingChange: v }), [s, u, a, x, c, l, d, m, p, h, g, y, v]) }, f.createElement(b, { "data-is-root-theme": r ? "true" : "false", "data-accent-color": u, "data-gray-color": x, "data-has-background": E ? "true" : "false", "data-panel-background": c, "data-radius": l, "data-scaling": d, ref: t, ...w, className: yn("radix-themes", { light: s === "light", dark: s === "dark" }, w.className) }));
});
Ze.displayName = "ThemeImpl";
export {
  ir as A,
  sr as C,
  Lt as D,
  Ir as H,
  je as P,
  Ar as R,
  kr as T,
  rr as a,
  Ye as b,
  _t as c,
  ar as d,
  Lr as e,
  Se as f,
  po as g,
  Mr as h,
  _r as i,
  Br as j,
  Fr as k,
  et as l,
  Eo as m,
  V as n,
  Ro as o,
  Dr as p,
  Nr as q,
  Io as u
};
