UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

1,874 lines 53.5 kB
import * as g from "react";
import { useLayoutEffect as Bt } from "react";
import { P as le, c as tt, u as ze, a as Vt, b as J } from "./index-DKfEnhKr.js";
import { u as we } from "./index-DLcqcWxM.js";
import { D as zt } from "./index-BlSRBdPy.js";
import { u as jt } from "./index-Dy59FQl5.js";
import * as Yt from "react-dom";
import { jsx as T, Fragment as Xt, jsxs as Gt } from "react/jsx-runtime";
import { u as qt } from "./index-0ioNhtNM.js";
import { u as Ut } from "./index-DtEcCIrM.js";
import { P as Kt } from "./index-AV6ZtGhy.js";
const Zt = ["top", "right", "bottom", "left"], U = Math.min, F = Math.max, pe = Math.round, ue = Math.floor, j = (e) => ({
  x: e,
  y: e
}), Jt = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Qt = {
  start: "end",
  end: "start"
};
function Oe(e, t, n) {
  return F(e, U(t, n));
}
function G(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function q(e) {
  return e.split("-")[0];
}
function ne(e) {
  return e.split("-")[1];
}
function Me(e) {
  return e === "x" ? "y" : "x";
}
function _e(e) {
  return e === "y" ? "height" : "width";
}
const en = /* @__PURE__ */ new Set(["top", "bottom"]);
function z(e) {
  return en.has(q(e)) ? "y" : "x";
}
function ke(e) {
  return Me(z(e));
}
function tn(e, t, n) {
  n === void 0 && (n = !1);
  const o = ne(e), r = ke(e), i = _e(r);
  let s = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
  return t.reference[i] > t.floating[i] && (s = me(s)), [s, me(s)];
}
function nn(e) {
  const t = me(e);
  return [Ee(e), t, Ee(t)];
}
function Ee(e) {
  return e.replace(/start|end/g, (t) => Qt[t]);
}
const je = ["left", "right"], Ye = ["right", "left"], on = ["top", "bottom"], rn = ["bottom", "top"];
function sn(e, t, n) {
  switch (e) {
    case "top":
    case "bottom":
      return n ? t ? Ye : je : t ? je : Ye;
    case "left":
    case "right":
      return t ? on : rn;
    default:
      return [];
  }
}
function cn(e, t, n, o) {
  const r = ne(e);
  let i = sn(q(e), n === "start", o);
  return r && (i = i.map((s) => s + "-" + r), t && (i = i.concat(i.map(Ee)))), i;
}
function me(e) {
  return e.replace(/left|right|bottom|top/g, (t) => Jt[t]);
}
function ln(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function nt(e) {
  return typeof e != "number" ? ln(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function he(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 Xe(e, t, n) {
  let {
    reference: o,
    floating: r
  } = e;
  const i = z(t), s = ke(t), a = _e(s), c = q(t), f = i === "y", l = o.x + o.width / 2 - r.width / 2, u = o.y + o.height / 2 - r.height / 2, p = o[a] / 2 - r[a] / 2;
  let d;
  switch (c) {
    case "top":
      d = {
        x: l,
        y: o.y - r.height
      };
      break;
    case "bottom":
      d = {
        x: l,
        y: o.y + o.height
      };
      break;
    case "right":
      d = {
        x: o.x + o.width,
        y: u
      };
      break;
    case "left":
      d = {
        x: o.x - r.width,
        y: u
      };
      break;
    default:
      d = {
        x: o.x,
        y: o.y
      };
  }
  switch (ne(t)) {
    case "start":
      d[s] -= p * (n && f ? -1 : 1);
      break;
    case "end":
      d[s] += p * (n && f ? -1 : 1);
      break;
  }
  return d;
}
const an = async (e, t, n) => {
  const {
    placement: o = "bottom",
    strategy: r = "absolute",
    middleware: i = [],
    platform: s
  } = n, a = i.filter(Boolean), c = await (s.isRTL == null ? void 0 : s.isRTL(t));
  let f = await s.getElementRects({
    reference: e,
    floating: t,
    strategy: r
  }), {
    x: l,
    y: u
  } = Xe(f, o, c), p = o, d = {}, m = 0;
  for (let h = 0; h < a.length; h++) {
    const {
      name: w,
      fn: y
    } = a[h], {
      x,
      y: C,
      data: v,
      reset: b
    } = await y({
      x: l,
      y: u,
      initialPlacement: o,
      placement: p,
      strategy: r,
      middlewareData: d,
      rects: f,
      platform: s,
      elements: {
        reference: e,
        floating: t
      }
    });
    l = x ?? l, u = C ?? u, d = {
      ...d,
      [w]: {
        ...d[w],
        ...v
      }
    }, b && m <= 50 && (m++, typeof b == "object" && (b.placement && (p = b.placement), b.rects && (f = b.rects === !0 ? await s.getElementRects({
      reference: e,
      floating: t,
      strategy: r
    }) : b.rects), {
      x: l,
      y: u
    } = Xe(f, p, c)), h = -1);
  }
  return {
    x: l,
    y: u,
    placement: p,
    strategy: r,
    middlewareData: d
  };
};
async function ie(e, t) {
  var n;
  t === void 0 && (t = {});
  const {
    x: o,
    y: r,
    platform: i,
    rects: s,
    elements: a,
    strategy: c
  } = e, {
    boundary: f = "clippingAncestors",
    rootBoundary: l = "viewport",
    elementContext: u = "floating",
    altBoundary: p = !1,
    padding: d = 0
  } = G(t, e), m = nt(d), w = a[p ? u === "floating" ? "reference" : "floating" : u], y = he(await i.getClippingRect({
    element: (n = await (i.isElement == null ? void 0 : i.isElement(w))) == null || n ? w : w.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(a.floating)),
    boundary: f,
    rootBoundary: l,
    strategy: c
  })), x = u === "floating" ? {
    x: o,
    y: r,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, C = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(a.floating)), v = await (i.isElement == null ? void 0 : i.isElement(C)) ? await (i.getScale == null ? void 0 : i.getScale(C)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, b = he(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: a,
    rect: x,
    offsetParent: C,
    strategy: c
  }) : x);
  return {
    top: (y.top - b.top + m.top) / v.y,
    bottom: (b.bottom - y.bottom + m.bottom) / v.y,
    left: (y.left - b.left + m.left) / v.x,
    right: (b.right - y.right + m.right) / v.x
  };
}
const fn = (e) => ({
  name: "arrow",
  options: e,
  async fn(t) {
    const {
      x: n,
      y: o,
      placement: r,
      rects: i,
      platform: s,
      elements: a,
      middlewareData: c
    } = t, {
      element: f,
      padding: l = 0
    } = G(e, t) || {};
    if (f == null)
      return {};
    const u = nt(l), p = {
      x: n,
      y: o
    }, d = ke(r), m = _e(d), h = await s.getDimensions(f), w = d === "y", y = w ? "top" : "left", x = w ? "bottom" : "right", C = w ? "clientHeight" : "clientWidth", v = i.reference[m] + i.reference[d] - p[d] - i.floating[m], b = p[d] - i.reference[d], P = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(f));
    let R = P ? P[C] : 0;
    (!R || !await (s.isElement == null ? void 0 : s.isElement(P))) && (R = a.floating[C] || i.floating[m]);
    const M = v / 2 - b / 2, H = R / 2 - h[m] / 2 - 1, D = U(u[y], H), k = U(u[x], H), N = D, E = R - h[m] - k, O = R / 2 - h[m] / 2 + M, $ = Oe(N, O, E), S = !c.arrow && ne(r) != null && O !== $ && i.reference[m] / 2 - (O < N ? D : k) - h[m] / 2 < 0, L = S ? O < N ? O - N : O - E : 0;
    return {
      [d]: p[d] + L,
      data: {
        [d]: $,
        centerOffset: O - $ - L,
        ...S && {
          alignmentOffset: L
        }
      },
      reset: S
    };
  }
}), un = 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: a,
        platform: c,
        elements: f
      } = t, {
        mainAxis: l = !0,
        crossAxis: u = !0,
        fallbackPlacements: p,
        fallbackStrategy: d = "bestFit",
        fallbackAxisSideDirection: m = "none",
        flipAlignment: h = !0,
        ...w
      } = G(e, t);
      if ((n = i.arrow) != null && n.alignmentOffset)
        return {};
      const y = q(r), x = z(a), C = q(a) === a, v = await (c.isRTL == null ? void 0 : c.isRTL(f.floating)), b = p || (C || !h ? [me(a)] : nn(a)), P = m !== "none";
      !p && P && b.push(...cn(a, h, m, v));
      const R = [a, ...b], M = await ie(t, w), H = [];
      let D = ((o = i.flip) == null ? void 0 : o.overflows) || [];
      if (l && H.push(M[y]), u) {
        const O = tn(r, s, v);
        H.push(M[O[0]], M[O[1]]);
      }
      if (D = [...D, {
        placement: r,
        overflows: H
      }], !H.every((O) => O <= 0)) {
        var k, N;
        const O = (((k = i.flip) == null ? void 0 : k.index) || 0) + 1, $ = R[O];
        if ($ && (!(u === "alignment" ? x !== z($) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        D.every((A) => z(A.placement) === x ? A.overflows[0] > 0 : !0)))
          return {
            data: {
              index: O,
              overflows: D
            },
            reset: {
              placement: $
            }
          };
        let S = (N = D.filter((L) => L.overflows[0] <= 0).sort((L, A) => L.overflows[1] - A.overflows[1])[0]) == null ? void 0 : N.placement;
        if (!S)
          switch (d) {
            case "bestFit": {
              var E;
              const L = (E = D.filter((A) => {
                if (P) {
                  const _ = z(A.placement);
                  return _ === x || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  _ === "y";
                }
                return !0;
              }).map((A) => [A.placement, A.overflows.filter((_) => _ > 0).reduce((_, V) => _ + V, 0)]).sort((A, _) => A[1] - _[1])[0]) == null ? void 0 : E[0];
              L && (S = L);
              break;
            }
            case "initialPlacement":
              S = a;
              break;
          }
        if (r !== S)
          return {
            reset: {
              placement: S
            }
          };
      }
      return {};
    }
  };
};
function Ge(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function qe(e) {
  return Zt.some((t) => e[t] >= 0);
}
const dn = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: n
      } = t, {
        strategy: o = "referenceHidden",
        ...r
      } = G(e, t);
      switch (o) {
        case "referenceHidden": {
          const i = await ie(t, {
            ...r,
            elementContext: "reference"
          }), s = Ge(i, n.reference);
          return {
            data: {
              referenceHiddenOffsets: s,
              referenceHidden: qe(s)
            }
          };
        }
        case "escaped": {
          const i = await ie(t, {
            ...r,
            altBoundary: !0
          }), s = Ge(i, n.floating);
          return {
            data: {
              escapedOffsets: s,
              escaped: qe(s)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, ot = /* @__PURE__ */ new Set(["left", "top"]);
async function pn(e, t) {
  const {
    placement: n,
    platform: o,
    elements: r
  } = e, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), s = q(n), a = ne(n), c = z(n) === "y", f = ot.has(s) ? -1 : 1, l = i && c ? -1 : 1, u = G(t, e);
  let {
    mainAxis: p,
    crossAxis: d,
    alignmentAxis: m
  } = typeof u == "number" ? {
    mainAxis: u,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: u.mainAxis || 0,
    crossAxis: u.crossAxis || 0,
    alignmentAxis: u.alignmentAxis
  };
  return a && typeof m == "number" && (d = a === "end" ? m * -1 : m), c ? {
    x: d * l,
    y: p * f
  } : {
    x: p * f,
    y: d * l
  };
}
const mn = 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: a
      } = t, c = await pn(t, e);
      return s === ((n = a.offset) == null ? void 0 : n.placement) && (o = a.arrow) != null && o.alignmentOffset ? {} : {
        x: r + c.x,
        y: i + c.y,
        data: {
          ...c,
          placement: s
        }
      };
    }
  };
}, hn = 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: a = {
          fn: (w) => {
            let {
              x: y,
              y: x
            } = w;
            return {
              x: y,
              y: x
            };
          }
        },
        ...c
      } = G(e, t), f = {
        x: n,
        y: o
      }, l = await ie(t, c), u = z(q(r)), p = Me(u);
      let d = f[p], m = f[u];
      if (i) {
        const w = p === "y" ? "top" : "left", y = p === "y" ? "bottom" : "right", x = d + l[w], C = d - l[y];
        d = Oe(x, d, C);
      }
      if (s) {
        const w = u === "y" ? "top" : "left", y = u === "y" ? "bottom" : "right", x = m + l[w], C = m - l[y];
        m = Oe(x, m, C);
      }
      const h = a.fn({
        ...t,
        [p]: d,
        [u]: m
      });
      return {
        ...h,
        data: {
          x: h.x - n,
          y: h.y - o,
          enabled: {
            [p]: i,
            [u]: 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: a = 0,
        mainAxis: c = !0,
        crossAxis: f = !0
      } = G(e, t), l = {
        x: n,
        y: o
      }, u = z(r), p = Me(u);
      let d = l[p], m = l[u];
      const h = G(a, t), w = typeof h == "number" ? {
        mainAxis: h,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...h
      };
      if (c) {
        const C = p === "y" ? "height" : "width", v = i.reference[p] - i.floating[C] + w.mainAxis, b = i.reference[p] + i.reference[C] - w.mainAxis;
        d < v ? d = v : d > b && (d = b);
      }
      if (f) {
        var y, x;
        const C = p === "y" ? "width" : "height", v = ot.has(q(r)), b = i.reference[u] - i.floating[C] + (v && ((y = s.offset) == null ? void 0 : y[u]) || 0) + (v ? 0 : w.crossAxis), P = i.reference[u] + i.reference[C] + (v ? 0 : ((x = s.offset) == null ? void 0 : x[u]) || 0) - (v ? w.crossAxis : 0);
        m < b ? m = b : m > P && (m = P);
      }
      return {
        [p]: d,
        [u]: m
      };
    }
  };
}, wn = 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: a
      } = t, {
        apply: c = () => {
        },
        ...f
      } = G(e, t), l = await ie(t, f), u = q(r), p = ne(r), d = z(r) === "y", {
        width: m,
        height: h
      } = i.floating;
      let w, y;
      u === "top" || u === "bottom" ? (w = u, y = p === (await (s.isRTL == null ? void 0 : s.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (y = u, w = p === "end" ? "top" : "bottom");
      const x = h - l.top - l.bottom, C = m - l.left - l.right, v = U(h - l[w], x), b = U(m - l[y], C), P = !t.middlewareData.shift;
      let R = v, M = b;
      if ((n = t.middlewareData.shift) != null && n.enabled.x && (M = C), (o = t.middlewareData.shift) != null && o.enabled.y && (R = x), P && !p) {
        const D = F(l.left, 0), k = F(l.right, 0), N = F(l.top, 0), E = F(l.bottom, 0);
        d ? M = m - 2 * (D !== 0 || k !== 0 ? D + k : F(l.left, l.right)) : R = h - 2 * (N !== 0 || E !== 0 ? N + E : F(l.top, l.bottom));
      }
      await c({
        ...t,
        availableWidth: M,
        availableHeight: R
      });
      const H = await s.getDimensions(a.floating);
      return m !== H.width || h !== H.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function ye() {
  return typeof window < "u";
}
function oe(e) {
  return rt(e) ? (e.nodeName || "").toLowerCase() : "#document";
}
function I(e) {
  var t;
  return (e == null || (t = e.ownerDocument) == null ? void 0 : t.defaultView) || window;
}
function X(e) {
  var t;
  return (t = (rt(e) ? e.ownerDocument : e.document) || window.document) == null ? void 0 : t.documentElement;
}
function rt(e) {
  return ye() ? e instanceof Node || e instanceof I(e).Node : !1;
}
function W(e) {
  return ye() ? e instanceof Element || e instanceof I(e).Element : !1;
}
function Y(e) {
  return ye() ? e instanceof HTMLElement || e instanceof I(e).HTMLElement : !1;
}
function Ue(e) {
  return !ye() || typeof ShadowRoot > "u" ? !1 : e instanceof ShadowRoot || e instanceof I(e).ShadowRoot;
}
const yn = /* @__PURE__ */ new Set(["inline", "contents"]);
function ae(e) {
  const {
    overflow: t,
    overflowX: n,
    overflowY: o,
    display: r
  } = B(e);
  return /auto|scroll|overlay|hidden|clip/.test(t + o + n) && !yn.has(r);
}
const xn = /* @__PURE__ */ new Set(["table", "td", "th"]);
function vn(e) {
  return xn.has(oe(e));
}
const bn = [":popover-open", ":modal"];
function xe(e) {
  return bn.some((t) => {
    try {
      return e.matches(t);
    } catch {
      return !1;
    }
  });
}
const Cn = ["transform", "translate", "scale", "rotate", "perspective"], An = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Rn = ["paint", "layout", "strict", "content"];
function Ne(e) {
  const t = He(), n = W(e) ? B(e) : e;
  return Cn.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) || An.some((o) => (n.willChange || "").includes(o)) || Rn.some((o) => (n.contain || "").includes(o));
}
function Pn(e) {
  let t = K(e);
  for (; Y(t) && !ee(t); ) {
    if (Ne(t))
      return t;
    if (xe(t))
      return null;
    t = K(t);
  }
  return null;
}
function He() {
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Tn = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function ee(e) {
  return Tn.has(oe(e));
}
function B(e) {
  return I(e).getComputedStyle(e);
}
function ve(e) {
  return W(e) ? {
    scrollLeft: e.scrollLeft,
    scrollTop: e.scrollTop
  } : {
    scrollLeft: e.scrollX,
    scrollTop: e.scrollY
  };
}
function K(e) {
  if (oe(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.
    Ue(e) && e.host || // Fallback.
    X(e)
  );
  return Ue(t) ? t.host : t;
}
function it(e) {
  const t = K(e);
  return ee(t) ? e.ownerDocument ? e.ownerDocument.body : e.body : Y(t) && ae(t) ? t : it(t);
}
function se(e, t, n) {
  var o;
  t === void 0 && (t = []), n === void 0 && (n = !0);
  const r = it(e), i = r === ((o = e.ownerDocument) == null ? void 0 : o.body), s = I(r);
  if (i) {
    const a = Se(s);
    return t.concat(s, s.visualViewport || [], ae(r) ? r : [], a && n ? se(a) : []);
  }
  return t.concat(r, se(r, [], n));
}
function Se(e) {
  return e.parent && Object.getPrototypeOf(e.parent) ? e.frameElement : null;
}
function st(e) {
  const t = B(e);
  let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
  const r = Y(e), i = r ? e.offsetWidth : n, s = r ? e.offsetHeight : o, a = pe(n) !== i || pe(o) !== s;
  return a && (n = i, o = s), {
    width: n,
    height: o,
    $: a
  };
}
function $e(e) {
  return W(e) ? e : e.contextElement;
}
function Q(e) {
  const t = $e(e);
  if (!Y(t))
    return j(1);
  const n = t.getBoundingClientRect(), {
    width: o,
    height: r,
    $: i
  } = st(t);
  let s = (i ? pe(n.width) : n.width) / o, a = (i ? pe(n.height) : n.height) / r;
  return (!s || !Number.isFinite(s)) && (s = 1), (!a || !Number.isFinite(a)) && (a = 1), {
    x: s,
    y: a
  };
}
const On = /* @__PURE__ */ j(0);
function ct(e) {
  const t = I(e);
  return !He() || !t.visualViewport ? On : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function En(e, t, n) {
  return t === void 0 && (t = !1), !n || t && n !== I(e) ? !1 : t;
}
function Z(e, t, n, o) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const r = e.getBoundingClientRect(), i = $e(e);
  let s = j(1);
  t && (o ? W(o) && (s = Q(o)) : s = Q(e));
  const a = En(i, n, o) ? ct(i) : j(0);
  let c = (r.left + a.x) / s.x, f = (r.top + a.y) / s.y, l = r.width / s.x, u = r.height / s.y;
  if (i) {
    const p = I(i), d = o && W(o) ? I(o) : o;
    let m = p, h = Se(m);
    for (; h && o && d !== m; ) {
      const w = Q(h), y = h.getBoundingClientRect(), x = B(h), C = y.left + (h.clientLeft + parseFloat(x.paddingLeft)) * w.x, v = y.top + (h.clientTop + parseFloat(x.paddingTop)) * w.y;
      c *= w.x, f *= w.y, l *= w.x, u *= w.y, c += C, f += v, m = I(h), h = Se(m);
    }
  }
  return he({
    width: l,
    height: u,
    x: c,
    y: f
  });
}
function be(e, t) {
  const n = ve(e).scrollLeft;
  return t ? t.left + n : Z(X(e)).left + n;
}
function lt(e, t) {
  const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - be(e, n), r = n.top + t.scrollTop;
  return {
    x: o,
    y: r
  };
}
function Sn(e) {
  let {
    elements: t,
    rect: n,
    offsetParent: o,
    strategy: r
  } = e;
  const i = r === "fixed", s = X(o), a = t ? xe(t.floating) : !1;
  if (o === s || a && i)
    return n;
  let c = {
    scrollLeft: 0,
    scrollTop: 0
  }, f = j(1);
  const l = j(0), u = Y(o);
  if ((u || !u && !i) && ((oe(o) !== "body" || ae(s)) && (c = ve(o)), Y(o))) {
    const d = Z(o);
    f = Q(o), l.x = d.x + o.clientLeft, l.y = d.y + o.clientTop;
  }
  const p = s && !u && !i ? lt(s, c) : j(0);
  return {
    width: n.width * f.x,
    height: n.height * f.y,
    x: n.x * f.x - c.scrollLeft * f.x + l.x + p.x,
    y: n.y * f.y - c.scrollTop * f.y + l.y + p.y
  };
}
function Ln(e) {
  return Array.from(e.getClientRects());
}
function Dn(e) {
  const t = X(e), n = ve(e), o = e.ownerDocument.body, r = F(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), i = F(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
  let s = -n.scrollLeft + be(e);
  const a = -n.scrollTop;
  return B(o).direction === "rtl" && (s += F(t.clientWidth, o.clientWidth) - r), {
    width: r,
    height: i,
    x: s,
    y: a
  };
}
const Ke = 25;
function Mn(e, t) {
  const n = I(e), o = X(e), r = n.visualViewport;
  let i = o.clientWidth, s = o.clientHeight, a = 0, c = 0;
  if (r) {
    i = r.width, s = r.height;
    const l = He();
    (!l || l && t === "fixed") && (a = r.offsetLeft, c = r.offsetTop);
  }
  const f = be(o);
  if (f <= 0) {
    const l = o.ownerDocument, u = l.body, p = getComputedStyle(u), d = l.compatMode === "CSS1Compat" && parseFloat(p.marginLeft) + parseFloat(p.marginRight) || 0, m = Math.abs(o.clientWidth - u.clientWidth - d);
    m <= Ke && (i -= m);
  } else f <= Ke && (i += f);
  return {
    width: i,
    height: s,
    x: a,
    y: c
  };
}
const _n = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function kn(e, t) {
  const n = Z(e, !0, t === "fixed"), o = n.top + e.clientTop, r = n.left + e.clientLeft, i = Y(e) ? Q(e) : j(1), s = e.clientWidth * i.x, a = e.clientHeight * i.y, c = r * i.x, f = o * i.y;
  return {
    width: s,
    height: a,
    x: c,
    y: f
  };
}
function Ze(e, t, n) {
  let o;
  if (t === "viewport")
    o = Mn(e, n);
  else if (t === "document")
    o = Dn(X(e));
  else if (W(t))
    o = kn(t, n);
  else {
    const r = ct(e);
    o = {
      x: t.x - r.x,
      y: t.y - r.y,
      width: t.width,
      height: t.height
    };
  }
  return he(o);
}
function at(e, t) {
  const n = K(e);
  return n === t || !W(n) || ee(n) ? !1 : B(n).position === "fixed" || at(n, t);
}
function Nn(e, t) {
  const n = t.get(e);
  if (n)
    return n;
  let o = se(e, [], !1).filter((a) => W(a) && oe(a) !== "body"), r = null;
  const i = B(e).position === "fixed";
  let s = i ? K(e) : e;
  for (; W(s) && !ee(s); ) {
    const a = B(s), c = Ne(s);
    !c && a.position === "fixed" && (r = null), (i ? !c && !r : !c && a.position === "static" && !!r && _n.has(r.position) || ae(s) && !c && at(e, s)) ? o = o.filter((l) => l !== s) : r = a, s = K(s);
  }
  return t.set(e, o), o;
}
function Hn(e) {
  let {
    element: t,
    boundary: n,
    rootBoundary: o,
    strategy: r
  } = e;
  const s = [...n === "clippingAncestors" ? xe(t) ? [] : Nn(t, this._c) : [].concat(n), o], a = s[0], c = s.reduce((f, l) => {
    const u = Ze(t, l, r);
    return f.top = F(u.top, f.top), f.right = U(u.right, f.right), f.bottom = U(u.bottom, f.bottom), f.left = F(u.left, f.left), f;
  }, Ze(t, a, r));
  return {
    width: c.right - c.left,
    height: c.bottom - c.top,
    x: c.left,
    y: c.top
  };
}
function $n(e) {
  const {
    width: t,
    height: n
  } = st(e);
  return {
    width: t,
    height: n
  };
}
function Fn(e, t, n) {
  const o = Y(t), r = X(t), i = n === "fixed", s = Z(e, !0, i, t);
  let a = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const c = j(0);
  function f() {
    c.x = be(r);
  }
  if (o || !o && !i)
    if ((oe(t) !== "body" || ae(r)) && (a = ve(t)), o) {
      const d = Z(t, !0, i, t);
      c.x = d.x + t.clientLeft, c.y = d.y + t.clientTop;
    } else r && f();
  i && !o && r && f();
  const l = r && !o && !i ? lt(r, a) : j(0), u = s.left + a.scrollLeft - c.x - l.x, p = s.top + a.scrollTop - c.y - l.y;
  return {
    x: u,
    y: p,
    width: s.width,
    height: s.height
  };
}
function Pe(e) {
  return B(e).position === "static";
}
function Je(e, t) {
  if (!Y(e) || B(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let n = e.offsetParent;
  return X(e) === n && (n = n.ownerDocument.body), n;
}
function ft(e, t) {
  const n = I(e);
  if (xe(e))
    return n;
  if (!Y(e)) {
    let r = K(e);
    for (; r && !ee(r); ) {
      if (W(r) && !Pe(r))
        return r;
      r = K(r);
    }
    return n;
  }
  let o = Je(e, t);
  for (; o && vn(o) && Pe(o); )
    o = Je(o, t);
  return o && ee(o) && Pe(o) && !Ne(o) ? n : o || Pn(e) || n;
}
const In = async function(e) {
  const t = this.getOffsetParent || ft, n = this.getDimensions, o = await n(e.floating);
  return {
    reference: Fn(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: o.width,
      height: o.height
    }
  };
};
function Wn(e) {
  return B(e).direction === "rtl";
}
const Bn = {
  convertOffsetParentRelativeRectToViewportRelativeRect: Sn,
  getDocumentElement: X,
  getClippingRect: Hn,
  getOffsetParent: ft,
  getElementRects: In,
  getClientRects: Ln,
  getDimensions: $n,
  getScale: Q,
  isElement: W,
  isRTL: Wn
};
function ut(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function Vn(e, t) {
  let n = null, o;
  const r = X(e);
  function i() {
    var a;
    clearTimeout(o), (a = n) == null || a.disconnect(), n = null;
  }
  function s(a, c) {
    a === void 0 && (a = !1), c === void 0 && (c = 1), i();
    const f = e.getBoundingClientRect(), {
      left: l,
      top: u,
      width: p,
      height: d
    } = f;
    if (a || t(), !p || !d)
      return;
    const m = ue(u), h = ue(r.clientWidth - (l + p)), w = ue(r.clientHeight - (u + d)), y = ue(l), C = {
      rootMargin: -m + "px " + -h + "px " + -w + "px " + -y + "px",
      threshold: F(0, U(1, c)) || 1
    };
    let v = !0;
    function b(P) {
      const R = P[0].intersectionRatio;
      if (R !== c) {
        if (!v)
          return s();
        R ? s(!1, R) : o = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      R === 1 && !ut(f, e.getBoundingClientRect()) && s(), v = !1;
    }
    try {
      n = new IntersectionObserver(b, {
        ...C,
        // Handle <iframe>s
        root: r.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(b, C);
    }
    n.observe(e);
  }
  return s(!0), i;
}
function zn(e, t, n, o) {
  o === void 0 && (o = {});
  const {
    ancestorScroll: r = !0,
    ancestorResize: i = !0,
    elementResize: s = typeof ResizeObserver == "function",
    layoutShift: a = typeof IntersectionObserver == "function",
    animationFrame: c = !1
  } = o, f = $e(e), l = r || i ? [...f ? se(f) : [], ...se(t)] : [];
  l.forEach((y) => {
    r && y.addEventListener("scroll", n, {
      passive: !0
    }), i && y.addEventListener("resize", n);
  });
  const u = f && a ? Vn(f, n) : null;
  let p = -1, d = null;
  s && (d = new ResizeObserver((y) => {
    let [x] = y;
    x && x.target === f && d && (d.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
      var C;
      (C = d) == null || C.observe(t);
    })), n();
  }), f && !c && d.observe(f), d.observe(t));
  let m, h = c ? Z(e) : null;
  c && w();
  function w() {
    const y = Z(e);
    h && !ut(h, y) && n(), h = y, m = requestAnimationFrame(w);
  }
  return n(), () => {
    var y;
    l.forEach((x) => {
      r && x.removeEventListener("scroll", n), i && x.removeEventListener("resize", n);
    }), u?.(), (y = d) == null || y.disconnect(), d = null, c && cancelAnimationFrame(m);
  };
}
const jn = mn, Yn = hn, Xn = un, Gn = wn, qn = dn, Qe = fn, Un = gn, Kn = (e, t, n) => {
  const o = /* @__PURE__ */ new Map(), r = {
    platform: Bn,
    ...n
  }, i = {
    ...r.platform,
    _c: o
  };
  return an(e, t, {
    ...r,
    platform: i
  });
};
var Zn = typeof document < "u", Jn = function() {
}, de = Zn ? Bt : Jn;
function ge(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 (!ge(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) && !ge(e[i], t[i]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function dt(e) {
  return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function et(e, t) {
  const n = dt(e);
  return Math.round(t * n) / n;
}
function Te(e) {
  const t = g.useRef(e);
  return de(() => {
    t.current = e;
  }), t;
}
function Qn(e) {
  e === void 0 && (e = {});
  const {
    placement: t = "bottom",
    strategy: n = "absolute",
    middleware: o = [],
    platform: r,
    elements: {
      reference: i,
      floating: s
    } = {},
    transform: a = !0,
    whileElementsMounted: c,
    open: f
  } = e, [l, u] = g.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: t,
    middlewareData: {},
    isPositioned: !1
  }), [p, d] = g.useState(o);
  ge(p, o) || d(o);
  const [m, h] = g.useState(null), [w, y] = g.useState(null), x = g.useCallback((A) => {
    A !== P.current && (P.current = A, h(A));
  }, []), C = g.useCallback((A) => {
    A !== R.current && (R.current = A, y(A));
  }, []), v = i || m, b = s || w, P = g.useRef(null), R = g.useRef(null), M = g.useRef(l), H = c != null, D = Te(c), k = Te(r), N = Te(f), E = g.useCallback(() => {
    if (!P.current || !R.current)
      return;
    const A = {
      placement: t,
      strategy: n,
      middleware: p
    };
    k.current && (A.platform = k.current), Kn(P.current, R.current, A).then((_) => {
      const V = {
        ..._,
        // 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: N.current !== !1
      };
      O.current && !ge(M.current, V) && (M.current = V, Yt.flushSync(() => {
        u(V);
      }));
    });
  }, [p, t, n, k, N]);
  de(() => {
    f === !1 && M.current.isPositioned && (M.current.isPositioned = !1, u((A) => ({
      ...A,
      isPositioned: !1
    })));
  }, [f]);
  const O = g.useRef(!1);
  de(() => (O.current = !0, () => {
    O.current = !1;
  }), []), de(() => {
    if (v && (P.current = v), b && (R.current = b), v && b) {
      if (D.current)
        return D.current(v, b, E);
      E();
    }
  }, [v, b, E, D, H]);
  const $ = g.useMemo(() => ({
    reference: P,
    floating: R,
    setReference: x,
    setFloating: C
  }), [x, C]), S = g.useMemo(() => ({
    reference: v,
    floating: b
  }), [v, b]), L = g.useMemo(() => {
    const A = {
      position: n,
      left: 0,
      top: 0
    };
    if (!S.floating)
      return A;
    const _ = et(S.floating, l.x), V = et(S.floating, l.y);
    return a ? {
      ...A,
      transform: "translate(" + _ + "px, " + V + "px)",
      ...dt(S.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: _,
      top: V
    };
  }, [n, a, S.floating, l.x, l.y]);
  return g.useMemo(() => ({
    ...l,
    update: E,
    refs: $,
    elements: S,
    floatingStyles: L
  }), [l, E, $, S, L]);
}
const eo = (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 ? Qe({
        element: o.current,
        padding: r
      }).fn(n) : {} : o ? Qe({
        element: o,
        padding: r
      }).fn(n) : {};
    }
  };
}, to = (e, t) => ({
  ...jn(e),
  options: [e, t]
}), no = (e, t) => ({
  ...Yn(e),
  options: [e, t]
}), oo = (e, t) => ({
  ...Un(e),
  options: [e, t]
}), ro = (e, t) => ({
  ...Xn(e),
  options: [e, t]
}), io = (e, t) => ({
  ...Gn(e),
  options: [e, t]
}), so = (e, t) => ({
  ...qn(e),
  options: [e, t]
}), co = (e, t) => ({
  ...eo(e),
  options: [e, t]
});
var lo = "Arrow", pt = g.forwardRef((e, t) => {
  const { children: n, width: o = 10, height: r = 5, ...i } = e;
  return /* @__PURE__ */ T(
    le.svg,
    {
      ...i,
      ref: t,
      width: o,
      height: r,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: e.asChild ? n : /* @__PURE__ */ T("polygon", { points: "0,0 30,0 15,10" })
    }
  );
});
pt.displayName = lo;
var ao = pt, Fe = "Popper", [mt, ht] = tt(Fe), [fo, gt] = mt(Fe), wt = (e) => {
  const { __scopePopper: t, children: n } = e, [o, r] = g.useState(null);
  return /* @__PURE__ */ T(fo, { scope: t, anchor: o, onAnchorChange: r, children: n });
};
wt.displayName = Fe;
var yt = "PopperAnchor", xt = g.forwardRef(
  (e, t) => {
    const { __scopePopper: n, virtualRef: o, ...r } = e, i = gt(yt, n), s = g.useRef(null), a = we(t, s), c = g.useRef(null);
    return g.useEffect(() => {
      const f = c.current;
      c.current = o?.current || s.current, f !== c.current && i.onAnchorChange(c.current);
    }), o ? null : /* @__PURE__ */ T(le.div, { ...r, ref: a });
  }
);
xt.displayName = yt;
var Ie = "PopperContent", [uo, po] = mt(Ie), vt = g.forwardRef(
  (e, t) => {
    const {
      __scopePopper: n,
      side: o = "bottom",
      sideOffset: r = 0,
      align: i = "center",
      alignOffset: s = 0,
      arrowPadding: a = 0,
      avoidCollisions: c = !0,
      collisionBoundary: f = [],
      collisionPadding: l = 0,
      sticky: u = "partial",
      hideWhenDetached: p = !1,
      updatePositionStrategy: d = "optimized",
      onPlaced: m,
      ...h
    } = e, w = gt(Ie, n), [y, x] = g.useState(null), C = we(t, (re) => x(re)), [v, b] = g.useState(null), P = Ut(v), R = P?.width ?? 0, M = P?.height ?? 0, H = o + (i !== "center" ? "-" + i : ""), D = typeof l == "number" ? l : { top: 0, right: 0, bottom: 0, left: 0, ...l }, k = Array.isArray(f) ? f : [f], N = k.length > 0, E = {
      padding: D,
      boundary: k.filter(ho),
      // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
      altBoundary: N
    }, { refs: O, floatingStyles: $, placement: S, isPositioned: L, middlewareData: A } = Qn({
      // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
      strategy: "fixed",
      placement: H,
      whileElementsMounted: (...re) => zn(...re, {
        animationFrame: d === "always"
      }),
      elements: {
        reference: w.anchor
      },
      middleware: [
        to({ mainAxis: r + M, alignmentAxis: s }),
        c && no({
          mainAxis: !0,
          crossAxis: !1,
          limiter: u === "partial" ? oo() : void 0,
          ...E
        }),
        c && ro({ ...E }),
        io({
          ...E,
          apply: ({ elements: re, rects: Ve, availableWidth: $t, availableHeight: Ft }) => {
            const { width: It, height: Wt } = Ve.reference, fe = re.floating.style;
            fe.setProperty("--radix-popper-available-width", `${$t}px`), fe.setProperty("--radix-popper-available-height", `${Ft}px`), fe.setProperty("--radix-popper-anchor-width", `${It}px`), fe.setProperty("--radix-popper-anchor-height", `${Wt}px`);
          }
        }),
        v && co({ element: v, padding: a }),
        go({ arrowWidth: R, arrowHeight: M }),
        p && so({ strategy: "referenceHidden", ...E })
      ]
    }), [_, V] = At(S), Be = qt(m);
    ze(() => {
      L && Be?.();
    }, [L, Be]);
    const Mt = A.arrow?.x, _t = A.arrow?.y, kt = A.arrow?.centerOffset !== 0, [Nt, Ht] = g.useState();
    return ze(() => {
      y && Ht(window.getComputedStyle(y).zIndex);
    }, [y]), /* @__PURE__ */ T(
      "div",
      {
        ref: O.setFloating,
        "data-radix-popper-content-wrapper": "",
        style: {
          ...$,
          transform: L ? $.transform : "translate(0, -200%)",
          // keep off the page when measuring
          minWidth: "max-content",
          zIndex: Nt,
          "--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__ */ T(
          uo,
          {
            scope: n,
            placedSide: _,
            onArrowChange: b,
            arrowX: Mt,
            arrowY: _t,
            shouldHideArrow: kt,
            children: /* @__PURE__ */ T(
              le.div,
              {
                "data-side": _,
                "data-align": V,
                ...h,
                ref: C,
                style: {
                  ...h.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: L ? void 0 : "none"
                }
              }
            )
          }
        )
      }
    );
  }
);
vt.displayName = Ie;
var bt = "PopperArrow", mo = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right"
}, Ct = g.forwardRef(function(t, n) {
  const { __scopePopper: o, ...r } = t, i = po(bt, o), s = mo[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__ */ T(
      "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__ */ T(
          ao,
          {
            ...r,
            ref: n,
            style: {
              ...r.style,
              // ensures the element can be measured correctly (mostly for if SVG)
              display: "block"
            }
          }
        )
      }
    )
  );
});
Ct.displayName = bt;
function ho(e) {
  return e !== null;
}
var go = (e) => ({
  name: "transformOrigin",
  options: e,
  fn(t) {
    const { placement: n, rects: o, middlewareData: r } = t, s = r.arrow?.centerOffset !== 0, a = s ? 0 : e.arrowWidth, c = s ? 0 : e.arrowHeight, [f, l] = At(n), u = { start: "0%", center: "50%", end: "100%" }[l], p = (r.arrow?.x ?? 0) + a / 2, d = (r.arrow?.y ?? 0) + c / 2;
    let m = "", h = "";
    return f === "bottom" ? (m = s ? u : `${p}px`, h = `${-c}px`) : f === "top" ? (m = s ? u : `${p}px`, h = `${o.floating.height + c}px`) : f === "right" ? (m = `${-c}px`, h = s ? u : `${d}px`) : f === "left" && (m = `${o.floating.width + c}px`, h = s ? u : `${d}px`), { data: { x: m, y: h } };
  }
});
function At(e) {
  const [t, n = "center"] = e.split("-");
  return [t, n];
}
var wo = wt, yo = xt, xo = vt, vo = Ct, bo = /* @__PURE__ */ Symbol("radix.slottable");
// @__NO_SIDE_EFFECTS__
function Co(e) {
  const t = ({ children: n }) => /* @__PURE__ */ T(Xt, { children: n });
  return t.displayName = `${e}.Slottable`, t.__radixId = bo, t;
}
var Ao = Object.freeze({
  // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
  position: "absolute",
  border: 0,
  width: 1,
  height: 1,
  padding: 0,
  margin: -1,
  overflow: "hidden",
  clip: "rect(0, 0, 0, 0)",
  whiteSpace: "nowrap",
  wordWrap: "normal"
}), Ro = "VisuallyHidden", Rt = g.forwardRef(
  (e, t) => /* @__PURE__ */ T(
    le.span,
    {
      ...e,
      ref: t,
      style: { ...Ao, ...e.style }
    }
  )
);
Rt.displayName = Ro;
var Po = Rt, [Ce, Zo] = tt("Tooltip", [
  ht
]), Ae = ht(), Pt = "TooltipProvider", To = 700, Le = "tooltip.open", [Oo, We] = Ce(Pt), Tt = (e) => {
  const {
    __scopeTooltip: t,
    delayDuration: n = To,
    skipDelayDuration: o = 300,
    disableHoverableContent: r = !1,
    children: i
  } = e, s = g.useRef(!0), a = g.useRef(!1), c = g.useRef(0);
  return g.useEffect(() => {
    const f = c.current;
    return () => window.clearTimeout(f);
  }, []), /* @__PURE__ */ T(
    Oo,
    {
      scope: t,
      isOpenDelayedRef: s,
      delayDuration: n,
      onOpen: g.useCallback(() => {
        window.clearTimeout(c.current), s.current = !1;
      }, []),
      onClose: g.useCallback(() => {
        window.clearTimeout(c.current), c.current = window.setTimeout(
          () => s.current = !0,
          o
        );
      }, [o]),
      isPointerInTransitRef: a,
      onPointerInTransitChange: g.useCallback((f) => {
        a.current = f;
      }, []),
      disableHoverableContent: r,
      children: i
    }
  );
};
Tt.displayName = Pt;
var ce = "Tooltip", [Eo, Re] = Ce(ce), Ot = (e) => {
  const {
    __scopeTooltip: t,
    children: n,
    open: o,
    defaultOpen: r,
    onOpenChange: i,
    disableHoverableContent: s,
    delayDuration: a
  } = e, c = We(ce, e.__scopeTooltip), f = Ae(t), [l, u] = g.useState(null), p = jt(), d = g.useRef(0), m = s ?? c.disableHoverableContent, h = a ?? c.delayDuration, w = g.useRef(!1), [y, x] = Vt({
    prop: o,
    defaultProp: r ?? !1,
    onChange: (R) => {
      R ? (c.onOpen(), document.dispatchEvent(new CustomEvent(Le))) : c.onClose(), i?.(R);
    },
    caller: ce
  }), C = g.useMemo(() => y ? w.current ? "delayed-open" : "instant-open" : "closed", [y]), v = g.useCallback(() => {
    window.clearTimeout(d.current), d.current = 0, w.current = !1, x(!0);
  }, [x]), b = g.useCallback(() => {
    window.clearTimeout(d.current), d.current = 0, x(!1);
  }, [x]), P = g.useCallback(() => {
    window.clearTimeout(d.current), d.current = window.setTimeout(() => {
      w.current = !0, x(!0), d.current = 0;
    }, h);
  }, [h, x]);
  return g.useEffect(() => () => {
    d.current && (window.clearTimeout(d.current), d.current = 0);
  }, []), /* @__PURE__ */ T(wo, { ...f, children: /* @__PURE__ */ T(
    Eo,
    {
      scope: t,
      contentId: p,
      open: y,
      stateAttribute: C,
      trigger: l,
      onTriggerChange: u,
      onTriggerEnter: g.useCallback(() => {
        c.isOpenDelayedRef.current ? P() : v();
      }, [c.isOpenDelayedRef, P, v]),
      onTriggerLeave: g.useCallback(() => {
        m ? b() : (window.clearTimeout(d.current), d.current = 0);
      }, [b, m]),
      onOpen: v,
      onClose: b,
      disableHoverableContent: m,
      children: n
    }
  ) });
};
Ot.displayName = ce;
var De = "TooltipTrigger", Et = g.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = Re(De, n), i = We(De, n), s = Ae(n), a = g.useRef(null), c = we(t, a, r.onTriggerChange), f = g.useRef(!1), l = g.useRef(!1), u = g.useCallback(() => f.current = !1, []);
    return g.useEffect(() => () => document.removeEventListener("pointerup", u), [u]), /* @__PURE__ */ T(yo, { asChild: !0, ...s, children: /* @__PURE__ */ T(
      le.button,
      {
        "aria-describedby": r.open ? r.contentId : void 0,
        "data-state": r.stateAttribute,
        ...o,
        ref: c,
        onPointerMove: J(e.onPointerMove, (p) => {
          p.pointerType !== "touch" && !l.current && !i.isPointerInTransitRef.current && (r.onTriggerEnter(), l.current = !0);
        }),
        onPointerLeave: J(e.onPointerLeave, () => {
          r.onTriggerLeave(), l.current = !1;
        }),
        onPointerDown: J(e.onPointerDown, () => {
          r.open && r.onClose(), f.current = !0, document.addEventListener("pointerup", u, { once: !0 });
        }),
        onFocus: J(e.onFocus, () => {
          f.current || r.onOpen();
        }),
        onBlur: J(e.onBlur, r.onClose),
        onClick: J(e.onClick, r.onClose)
      }
    ) });
  }
);
Et.displayName = De;
var So = "TooltipPortal", [Jo, Lo] = Ce(So, {
  forceMount: void 0
}), te = "TooltipContent", St = g.forwardRef(
  (e, t) => {
    const n = Lo(te, e.__scopeTooltip), { forceMount: o = n.forceMount, side: r = "top", ...i } = e, s = Re(te, e.__scopeTooltip);
    return /* @__PURE__ */ T(Kt, { present: o || s.open, children: s.disableHoverableContent ? /* @__PURE__ */ T(Lt, { side: r, ...i, ref: t }) : /* @__PURE__ */ T(Do, { side: r, ...i, ref: t }) });
  }
), Do = g.forwardRef((e, t) => {
  const n = Re(te, e.__scopeTooltip), o = We(te, e.__scopeTooltip), r = g.useRef(null), i = we(t, r), [s, a] = g.useState(null), { trigger: c, onClose: f } = n, l = r.current, { onPointerInTransitChange: u } = o, p = g.useCallback(() => {
    a(null), u(!1);
  }, [u]), d = g.useCallback(
    (m, h) => {
      const w = m.currentTarget, y = { x: m.clientX, y: m.clientY }, x = Ho(y, w.getBoundingClientRect()), C = $o(y, x), v = Fo(h.getBoundingClientRect()), b = Wo([...C, ...v]);
      a(b), u(!0);
    },
    [u]
  );
  return g.useEffect(() => () => p(), [p]), g.useEffect(() => {
    if (c && l) {
      const m = (w) => d(w, l), h = (w) => d(w, c);
      return c.addEventListener("pointerleave", m), l.addEventListener("pointerleave", h), () => {
        c.removeEventListener("pointerleave", m), l.removeEventListener("pointerleave", h);
      };
    }
  }, [c, l, d, p]), g.useEffect(() => {
    if (s) {
      const m = (h) => {
        const w = h.target, y = { x: h.clientX, y: h.clientY }, x = c?.contains(w) || l?.contains(w), C = !Io(y, s);
        x ? p() : C && (p(), f());
      };
      return document.addEventListener("pointermove", m), () => document.removeEventListener("pointermove", m);
    }
  }, [c, l, s, f, p]), /* @__PURE__ */ T(Lt, { ...e, ref: i });
}), [Mo, _o] = Ce(ce, { isInside: !1 }), ko = /* @__PURE__ */ Co("TooltipContent"), Lt = g.forwardRef(
  (e, t) => {
    const {
      __scopeTooltip: n,
      children: o,
      "aria-label": r,
      onEscapeKeyDown: i,
      onPointerDownOutside: s,
      ...a
    } = e, c = Re(te, n), f = Ae(n), { onClose: l } = c;
    return g.useEffect(() => (document.addEventListener(Le, l), () => document.removeEventListener(Le, l)), [l]), g.useEffect(() => {
      if (c.trigger) {
        const u = (p) => {
          p.target?.contains(c.trigger) && l();
        };
        return window.addEventListener("scroll", u, { capture: !0 }), () => window.removeEventListener("scroll", u, { capture: !0 });
      }
    }, [c.trigger, l]), /* @__PURE__ */ T(
      zt,
      {
        asChild: !0,
        disableOutsidePointerEvents: !1,
        onEscapeKeyDown: i,
        onPointerDownOutside: s,
        onFocusOutside: (u) => u.preventDefault(),
        onDismiss: l,
        children: /* @__PURE__ */ Gt(
          xo,
          {
            "data-state": c.stateAttribute,
            ...f,
            ...a,
            ref: t,
            style: {
              ...a.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__ */ T(ko, { children: o }),
              /* @__PURE__ */ T(Mo, { scope: n, isInside: !0, children: /* @__PURE__ */ T(Po, { id: c.contentId, role: "tooltip", children: r || o }) })
            ]
          }
        )
      }
    );
  }
);
St.displayName = te;
var Dt = "TooltipArrow", No = g.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = Ae(n);
    return _o(
      Dt,
      n
    ).isInside ? null : /* @__PURE__ */ T(vo, { ...r, ...o, ref: t });
  }
);
No.displayName = Dt;
function Ho(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 $o(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 Fo(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 Io(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 a = t[i], c = t[s], f = a.x, l = a.y, u = c.x, p = c.y;
    l > o != p > o && n < (u - f) * (o - l) / (p - l) + f && (r = !r);
  }
  return r;
}
function Wo(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), Bo(t);
}
function Bo(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 Qo = Tt, er = Ot, tr = Et, nr = St;
export {
  nr as C,
  Qo as P,
  er as R,
  tr as T
};