import { jsx as w } from "react/jsx-runtime";
import * as v from "react";
import { useLayoutEffect as nt, createContext as en, useState as tn, useContext as nn, useId as on } from "react";
import { u as rn, c as ne } from "../index-DlIFg0Eu.mjs";
import { u as he, c as sn } from "../index-DhGWNzsz.mjs";
import { c as ot } from "../index-DFZozV_h.mjs";
import { h as an, R as cn, u as ln, F as fn, D as un } from "../index-D_lWkK39.mjs";
import { a as dn, u as pn } from "../index-BRi38DTc.mjs";
import { c as z, g as Y, d as Pe, e as V, i as q, f as U, h as Ce, j as oe, k as fe, l as mn, m as rt, n as hn, o as Re, p as Oe, q as ge, r as je, s as it } from "../floating-ui.utils.dom-uiDUZc_y.mjs";
import * as gn from "react-dom";
import { P as ie } from "../index-MSR-vgWR.mjs";
import { u as Xe } from "../index-CCKe-Mpx.mjs";
import { u as vn } from "../index-C1qb0595.mjs";
import { P as xn } from "../index-DLHLIYPI.mjs";
import { P as st } from "../index-BZAtNKwE.mjs";
import { c as at, a as ct } from "../index-BmAFn37q.mjs";
import { Close as wn } from "@spark-ui/icons/Close";
import { I as yn } from "../Icon-D1RueiPY.mjs";
import { I as Pn } from "../IconButton-BY3gYXtU.mjs";
const bn = ["top", "right", "bottom", "left"], G = Math.min, I = Math.max, ue = Math.round, ce = Math.floor, B = (e) => ({
  x: e,
  y: e
}), An = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
}, Cn = {
  start: "end",
  end: "start"
};
function be(e, t, n) {
  return I(e, G(t, n));
}
function j(e, t) {
  return typeof e == "function" ? e(t) : e;
}
function X(e) {
  return e.split("-")[0];
}
function ee(e) {
  return e.split("-")[1];
}
function Se(e) {
  return e === "x" ? "y" : "x";
}
function Ee(e) {
  return e === "y" ? "height" : "width";
}
const Rn = /* @__PURE__ */ new Set(["top", "bottom"]);
function W(e) {
  return Rn.has(X(e)) ? "y" : "x";
}
function Ne(e) {
  return Se(W(e));
}
function On(e, t, n) {
  n === void 0 && (n = !1);
  const o = ee(e), r = Ne(e), i = Ee(r);
  let s = r === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
  return t.reference[i] > t.floating[i] && (s = de(s)), [s, de(s)];
}
function Sn(e) {
  const t = de(e);
  return [Ae(e), t, Ae(t)];
}
function Ae(e) {
  return e.replace(/start|end/g, (t) => Cn[t]);
}
const Ye = ["left", "right"], qe = ["right", "left"], En = ["top", "bottom"], Nn = ["bottom", "top"];
function Mn(e, t, n) {
  switch (e) {
    case "top":
    case "bottom":
      return n ? t ? qe : Ye : t ? Ye : qe;
    case "left":
    case "right":
      return t ? En : Nn;
    default:
      return [];
  }
}
function Dn(e, t, n, o) {
  const r = ee(e);
  let i = Mn(X(e), n === "start", o);
  return r && (i = i.map((s) => s + "-" + r), t && (i = i.concat(i.map(Ae)))), i;
}
function de(e) {
  return e.replace(/left|right|bottom|top/g, (t) => An[t]);
}
function Tn(e) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...e
  };
}
function lt(e) {
  return typeof e != "number" ? Tn(e) : {
    top: e,
    right: e,
    bottom: e,
    left: e
  };
}
function pe(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 Ge(e, t, n) {
  let {
    reference: o,
    floating: r
  } = e;
  const i = W(t), s = Ne(t), a = Ee(s), c = X(t), l = i === "y", f = 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: f,
        y: o.y - r.height
      };
      break;
    case "bottom":
      d = {
        x: f,
        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 (ee(t)) {
    case "start":
      d[s] -= p * (n && l ? -1 : 1);
      break;
    case "end":
      d[s] += p * (n && l ? -1 : 1);
      break;
  }
  return d;
}
const _n = 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 l = await s.getElementRects({
    reference: e,
    floating: t,
    strategy: r
  }), {
    x: f,
    y: u
  } = Ge(l, o, c), p = o, d = {}, m = 0;
  for (let h = 0; h < a.length; h++) {
    const {
      name: x,
      fn: g
    } = a[h], {
      x: y,
      y: P,
      data: b,
      reset: A
    } = await g({
      x: f,
      y: u,
      initialPlacement: o,
      placement: p,
      strategy: r,
      middlewareData: d,
      rects: l,
      platform: s,
      elements: {
        reference: e,
        floating: t
      }
    });
    f = y ?? f, u = P ?? u, d = {
      ...d,
      [x]: {
        ...d[x],
        ...b
      }
    }, A && m <= 50 && (m++, typeof A == "object" && (A.placement && (p = A.placement), A.rects && (l = A.rects === !0 ? await s.getElementRects({
      reference: e,
      floating: t,
      strategy: r
    }) : A.rects), {
      x: f,
      y: u
    } = Ge(l, p, c)), h = -1);
  }
  return {
    x: f,
    y: u,
    placement: p,
    strategy: r,
    middlewareData: d
  };
};
async function re(e, t) {
  var n;
  t === void 0 && (t = {});
  const {
    x: o,
    y: r,
    platform: i,
    rects: s,
    elements: a,
    strategy: c
  } = e, {
    boundary: l = "clippingAncestors",
    rootBoundary: f = "viewport",
    elementContext: u = "floating",
    altBoundary: p = !1,
    padding: d = 0
  } = j(t, e), m = lt(d), x = a[p ? u === "floating" ? "reference" : "floating" : u], g = pe(await i.getClippingRect({
    element: (n = await (i.isElement == null ? void 0 : i.isElement(x))) == null || n ? x : x.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(a.floating)),
    boundary: l,
    rootBoundary: f,
    strategy: c
  })), y = u === "floating" ? {
    x: o,
    y: r,
    width: s.floating.width,
    height: s.floating.height
  } : s.reference, P = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(a.floating)), b = await (i.isElement == null ? void 0 : i.isElement(P)) ? await (i.getScale == null ? void 0 : i.getScale(P)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  }, A = pe(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: a,
    rect: y,
    offsetParent: P,
    strategy: c
  }) : y);
  return {
    top: (g.top - A.top + m.top) / b.y,
    bottom: (A.bottom - g.bottom + m.bottom) / b.y,
    left: (g.left - A.left + m.left) / b.x,
    right: (A.right - g.right + m.right) / b.x
  };
}
const $n = (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: l,
      padding: f = 0
    } = j(e, t) || {};
    if (l == null)
      return {};
    const u = lt(f), p = {
      x: n,
      y: o
    }, d = Ne(r), m = Ee(d), h = await s.getDimensions(l), x = d === "y", g = x ? "top" : "left", y = x ? "bottom" : "right", P = x ? "clientHeight" : "clientWidth", b = i.reference[m] + i.reference[d] - p[d] - i.floating[m], A = p[d] - i.reference[d], O = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(l));
    let R = O ? O[P] : 0;
    (!R || !await (s.isElement == null ? void 0 : s.isElement(O))) && (R = a.floating[P] || i.floating[m]);
    const T = b / 2 - A / 2, k = R / 2 - h[m] / 2 - 1, D = G(u[g], k), $ = G(u[y], k), F = D, E = R - h[m] - $, S = R / 2 - h[m] / 2 + T, L = be(F, S, E), N = !c.arrow && ee(r) != null && S !== L && i.reference[m] / 2 - (S < F ? D : $) - h[m] / 2 < 0, M = N ? S < F ? S - F : S - E : 0;
    return {
      [d]: p[d] + M,
      data: {
        [d]: L,
        centerOffset: S - L - M,
        ...N && {
          alignmentOffset: M
        }
      },
      reset: N
    };
  }
}), Fn = 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: l
      } = t, {
        mainAxis: f = !0,
        crossAxis: u = !0,
        fallbackPlacements: p,
        fallbackStrategy: d = "bestFit",
        fallbackAxisSideDirection: m = "none",
        flipAlignment: h = !0,
        ...x
      } = j(e, t);
      if ((n = i.arrow) != null && n.alignmentOffset)
        return {};
      const g = X(r), y = W(a), P = X(a) === a, b = await (c.isRTL == null ? void 0 : c.isRTL(l.floating)), A = p || (P || !h ? [de(a)] : Sn(a)), O = m !== "none";
      !p && O && A.push(...Dn(a, h, m, b));
      const R = [a, ...A], T = await re(t, x), k = [];
      let D = ((o = i.flip) == null ? void 0 : o.overflows) || [];
      if (f && k.push(T[g]), u) {
        const S = On(r, s, b);
        k.push(T[S[0]], T[S[1]]);
      }
      if (D = [...D, {
        placement: r,
        overflows: k
      }], !k.every((S) => S <= 0)) {
        var $, F;
        const S = ((($ = i.flip) == null ? void 0 : $.index) || 0) + 1, L = R[S];
        if (L && (!(u === "alignment" ? y !== W(L) : !1) || // We leave the current main axis only if every placement on that axis
        // overflows the main axis.
        D.every((C) => W(C.placement) === y ? C.overflows[0] > 0 : !0)))
          return {
            data: {
              index: S,
              overflows: D
            },
            reset: {
              placement: L
            }
          };
        let N = (F = D.filter((M) => M.overflows[0] <= 0).sort((M, C) => M.overflows[1] - C.overflows[1])[0]) == null ? void 0 : F.placement;
        if (!N)
          switch (d) {
            case "bestFit": {
              var E;
              const M = (E = D.filter((C) => {
                if (O) {
                  const _ = W(C.placement);
                  return _ === y || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  _ === "y";
                }
                return !0;
              }).map((C) => [C.placement, C.overflows.filter((_) => _ > 0).reduce((_, H) => _ + H, 0)]).sort((C, _) => C[1] - _[1])[0]) == null ? void 0 : E[0];
              M && (N = M);
              break;
            }
            case "initialPlacement":
              N = a;
              break;
          }
        if (r !== N)
          return {
            reset: {
              placement: N
            }
          };
      }
      return {};
    }
  };
};
function Ke(e, t) {
  return {
    top: e.top - t.height,
    right: e.right - t.width,
    bottom: e.bottom - t.height,
    left: e.left - t.width
  };
}
function Ue(e) {
  return bn.some((t) => e[t] >= 0);
}
const kn = function(e) {
  return e === void 0 && (e = {}), {
    name: "hide",
    options: e,
    async fn(t) {
      const {
        rects: n
      } = t, {
        strategy: o = "referenceHidden",
        ...r
      } = j(e, t);
      switch (o) {
        case "referenceHidden": {
          const i = await re(t, {
            ...r,
            elementContext: "reference"
          }), s = Ke(i, n.reference);
          return {
            data: {
              referenceHiddenOffsets: s,
              referenceHidden: Ue(s)
            }
          };
        }
        case "escaped": {
          const i = await re(t, {
            ...r,
            altBoundary: !0
          }), s = Ke(i, n.floating);
          return {
            data: {
              escapedOffsets: s,
              escaped: Ue(s)
            }
          };
        }
        default:
          return {};
      }
    }
  };
}, ft = /* @__PURE__ */ new Set(["left", "top"]);
async function Ln(e, t) {
  const {
    placement: n,
    platform: o,
    elements: r
  } = e, i = await (o.isRTL == null ? void 0 : o.isRTL(r.floating)), s = X(n), a = ee(n), c = W(n) === "y", l = ft.has(s) ? -1 : 1, f = i && c ? -1 : 1, u = j(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 * f,
    y: p * l
  } : {
    x: p * l,
    y: d * f
  };
}
const In = 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 Ln(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: (x) => {
            let {
              x: g,
              y
            } = x;
            return {
              x: g,
              y
            };
          }
        },
        ...c
      } = j(e, t), l = {
        x: n,
        y: o
      }, f = await re(t, c), u = W(X(r)), p = Se(u);
      let d = l[p], m = l[u];
      if (i) {
        const x = p === "y" ? "top" : "left", g = p === "y" ? "bottom" : "right", y = d + f[x], P = d - f[g];
        d = be(y, d, P);
      }
      if (s) {
        const x = u === "y" ? "top" : "left", g = u === "y" ? "bottom" : "right", y = m + f[x], P = m - f[g];
        m = be(y, m, P);
      }
      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
          }
        }
      };
    }
  };
}, Wn = 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: l = !0
      } = j(e, t), f = {
        x: n,
        y: o
      }, u = W(r), p = Se(u);
      let d = f[p], m = f[u];
      const h = j(a, t), x = typeof h == "number" ? {
        mainAxis: h,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...h
      };
      if (c) {
        const P = p === "y" ? "height" : "width", b = i.reference[p] - i.floating[P] + x.mainAxis, A = i.reference[p] + i.reference[P] - x.mainAxis;
        d < b ? d = b : d > A && (d = A);
      }
      if (l) {
        var g, y;
        const P = p === "y" ? "width" : "height", b = ft.has(X(r)), A = i.reference[u] - i.floating[P] + (b && ((g = s.offset) == null ? void 0 : g[u]) || 0) + (b ? 0 : x.crossAxis), O = i.reference[u] + i.reference[P] + (b ? 0 : ((y = s.offset) == null ? void 0 : y[u]) || 0) - (b ? x.crossAxis : 0);
        m < A ? m = A : m > O && (m = O);
      }
      return {
        [p]: d,
        [u]: m
      };
    }
  };
}, Bn = 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 = () => {
        },
        ...l
      } = j(e, t), f = await re(t, l), u = X(r), p = ee(r), d = W(r) === "y", {
        width: m,
        height: h
      } = i.floating;
      let x, g;
      u === "top" || u === "bottom" ? (x = u, g = p === (await (s.isRTL == null ? void 0 : s.isRTL(a.floating)) ? "start" : "end") ? "left" : "right") : (g = u, x = p === "end" ? "top" : "bottom");
      const y = h - f.top - f.bottom, P = m - f.left - f.right, b = G(h - f[x], y), A = G(m - f[g], P), O = !t.middlewareData.shift;
      let R = b, T = A;
      if ((n = t.middlewareData.shift) != null && n.enabled.x && (T = P), (o = t.middlewareData.shift) != null && o.enabled.y && (R = y), O && !p) {
        const D = I(f.left, 0), $ = I(f.right, 0), F = I(f.top, 0), E = I(f.bottom, 0);
        d ? T = m - 2 * (D !== 0 || $ !== 0 ? D + $ : I(f.left, f.right)) : R = h - 2 * (F !== 0 || E !== 0 ? F + E : I(f.top, f.bottom));
      }
      await c({
        ...t,
        availableWidth: T,
        availableHeight: R
      });
      const k = await s.getDimensions(a.floating);
      return m !== k.width || h !== k.height ? {
        reset: {
          rects: !0
        }
      } : {};
    }
  };
};
function ut(e) {
  const t = V(e);
  let n = parseFloat(t.width) || 0, o = parseFloat(t.height) || 0;
  const r = q(e), i = r ? e.offsetWidth : n, s = r ? e.offsetHeight : o, a = ue(n) !== i || ue(o) !== s;
  return a && (n = i, o = s), {
    width: n,
    height: o,
    $: a
  };
}
function Me(e) {
  return z(e) ? e : e.contextElement;
}
function J(e) {
  const t = Me(e);
  if (!q(t))
    return B(1);
  const n = t.getBoundingClientRect(), {
    width: o,
    height: r,
    $: i
  } = ut(t);
  let s = (i ? ue(n.width) : n.width) / o, a = (i ? ue(n.height) : n.height) / r;
  return (!s || !Number.isFinite(s)) && (s = 1), (!a || !Number.isFinite(a)) && (a = 1), {
    x: s,
    y: a
  };
}
const zn = /* @__PURE__ */ B(0);
function dt(e) {
  const t = U(e);
  return !it() || !t.visualViewport ? zn : {
    x: t.visualViewport.offsetLeft,
    y: t.visualViewport.offsetTop
  };
}
function Vn(e, t, n) {
  return t === void 0 && (t = !1), !n || t && n !== U(e) ? !1 : t;
}
function Z(e, t, n, o) {
  t === void 0 && (t = !1), n === void 0 && (n = !1);
  const r = e.getBoundingClientRect(), i = Me(e);
  let s = B(1);
  t && (o ? z(o) && (s = J(o)) : s = J(e));
  const a = Vn(i, n, o) ? dt(i) : B(0);
  let c = (r.left + a.x) / s.x, l = (r.top + a.y) / s.y, f = r.width / s.x, u = r.height / s.y;
  if (i) {
    const p = U(i), d = o && z(o) ? U(o) : o;
    let m = p, h = je(m);
    for (; h && o && d !== m; ) {
      const x = J(h), g = h.getBoundingClientRect(), y = V(h), P = g.left + (h.clientLeft + parseFloat(y.paddingLeft)) * x.x, b = g.top + (h.clientTop + parseFloat(y.paddingTop)) * x.y;
      c *= x.x, l *= x.y, f *= x.x, u *= x.y, c += P, l += b, m = U(h), h = je(m);
    }
  }
  return pe({
    width: f,
    height: u,
    x: c,
    y: l
  });
}
function ve(e, t) {
  const n = ge(e).scrollLeft;
  return t ? t.left + n : Z(Y(e)).left + n;
}
function pt(e, t) {
  const n = e.getBoundingClientRect(), o = n.left + t.scrollLeft - ve(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 = Y(o), a = t ? Ce(t.floating) : !1;
  if (o === s || a && i)
    return n;
  let c = {
    scrollLeft: 0,
    scrollTop: 0
  }, l = B(1);
  const f = B(0), u = q(o);
  if ((u || !u && !i) && ((Re(o) !== "body" || Oe(s)) && (c = ge(o)), q(o))) {
    const d = Z(o);
    l = J(o), f.x = d.x + o.clientLeft, f.y = d.y + o.clientTop;
  }
  const p = s && !u && !i ? pt(s, c) : B(0);
  return {
    width: n.width * l.x,
    height: n.height * l.y,
    x: n.x * l.x - c.scrollLeft * l.x + f.x + p.x,
    y: n.y * l.y - c.scrollTop * l.y + f.y + p.y
  };
}
function Xn(e) {
  return Array.from(e.getClientRects());
}
function Yn(e) {
  const t = Y(e), n = ge(e), o = e.ownerDocument.body, r = I(t.scrollWidth, t.clientWidth, o.scrollWidth, o.clientWidth), i = I(t.scrollHeight, t.clientHeight, o.scrollHeight, o.clientHeight);
  let s = -n.scrollLeft + ve(e);
  const a = -n.scrollTop;
  return V(o).direction === "rtl" && (s += I(t.clientWidth, o.clientWidth) - r), {
    width: r,
    height: i,
    x: s,
    y: a
  };
}
const Ze = 25;
function qn(e, t) {
  const n = U(e), o = Y(e), r = n.visualViewport;
  let i = o.clientWidth, s = o.clientHeight, a = 0, c = 0;
  if (r) {
    i = r.width, s = r.height;
    const f = it();
    (!f || f && t === "fixed") && (a = r.offsetLeft, c = r.offsetTop);
  }
  const l = ve(o);
  if (l <= 0) {
    const f = o.ownerDocument, u = f.body, p = getComputedStyle(u), d = f.compatMode === "CSS1Compat" && parseFloat(p.marginLeft) + parseFloat(p.marginRight) || 0, m = Math.abs(o.clientWidth - u.clientWidth - d);
    m <= Ze && (i -= m);
  } else l <= Ze && (i += l);
  return {
    width: i,
    height: s,
    x: a,
    y: c
  };
}
const Gn = /* @__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 = q(e) ? J(e) : B(1), s = e.clientWidth * i.x, a = e.clientHeight * i.y, c = r * i.x, l = o * i.y;
  return {
    width: s,
    height: a,
    x: c,
    y: l
  };
}
function Je(e, t, n) {
  let o;
  if (t === "viewport")
    o = qn(e, n);
  else if (t === "document")
    o = Yn(Y(e));
  else if (z(t))
    o = Kn(t, n);
  else {
    const r = dt(e);
    o = {
      x: t.x - r.x,
      y: t.y - r.y,
      width: t.width,
      height: t.height
    };
  }
  return pe(o);
}
function mt(e, t) {
  const n = oe(e);
  return n === t || !z(n) || fe(n) ? !1 : V(n).position === "fixed" || mt(n, t);
}
function Un(e, t) {
  const n = t.get(e);
  if (n)
    return n;
  let o = Pe(e, [], !1).filter((a) => z(a) && Re(a) !== "body"), r = null;
  const i = V(e).position === "fixed";
  let s = i ? oe(e) : e;
  for (; z(s) && !fe(s); ) {
    const a = V(s), c = rt(s);
    !c && a.position === "fixed" && (r = null), (i ? !c && !r : !c && a.position === "static" && !!r && Gn.has(r.position) || Oe(s) && !c && mt(e, s)) ? o = o.filter((f) => f !== s) : r = a, s = oe(s);
  }
  return t.set(e, o), o;
}
function Zn(e) {
  let {
    element: t,
    boundary: n,
    rootBoundary: o,
    strategy: r
  } = e;
  const s = [...n === "clippingAncestors" ? Ce(t) ? [] : Un(t, this._c) : [].concat(n), o], a = s[0], c = s.reduce((l, f) => {
    const u = Je(t, f, r);
    return l.top = I(u.top, l.top), l.right = G(u.right, l.right), l.bottom = G(u.bottom, l.bottom), l.left = I(u.left, l.left), l;
  }, Je(t, a, r));
  return {
    width: c.right - c.left,
    height: c.bottom - c.top,
    x: c.left,
    y: c.top
  };
}
function Jn(e) {
  const {
    width: t,
    height: n
  } = ut(e);
  return {
    width: t,
    height: n
  };
}
function Qn(e, t, n) {
  const o = q(t), r = Y(t), i = n === "fixed", s = Z(e, !0, i, t);
  let a = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const c = B(0);
  function l() {
    c.x = ve(r);
  }
  if (o || !o && !i)
    if ((Re(t) !== "body" || Oe(r)) && (a = ge(t)), o) {
      const d = Z(t, !0, i, t);
      c.x = d.x + t.clientLeft, c.y = d.y + t.clientTop;
    } else r && l();
  i && !o && r && l();
  const f = r && !o && !i ? pt(r, a) : B(0), u = s.left + a.scrollLeft - c.x - f.x, p = s.top + a.scrollTop - c.y - f.y;
  return {
    x: u,
    y: p,
    width: s.width,
    height: s.height
  };
}
function we(e) {
  return V(e).position === "static";
}
function Qe(e, t) {
  if (!q(e) || V(e).position === "fixed")
    return null;
  if (t)
    return t(e);
  let n = e.offsetParent;
  return Y(e) === n && (n = n.ownerDocument.body), n;
}
function ht(e, t) {
  const n = U(e);
  if (Ce(e))
    return n;
  if (!q(e)) {
    let r = oe(e);
    for (; r && !fe(r); ) {
      if (z(r) && !we(r))
        return r;
      r = oe(r);
    }
    return n;
  }
  let o = Qe(e, t);
  for (; o && mn(o) && we(o); )
    o = Qe(o, t);
  return o && fe(o) && we(o) && !rt(o) ? n : o || hn(e) || n;
}
const eo = async function(e) {
  const t = this.getOffsetParent || ht, n = this.getDimensions, o = await n(e.floating);
  return {
    reference: Qn(e.reference, await t(e.floating), e.strategy),
    floating: {
      x: 0,
      y: 0,
      width: o.width,
      height: o.height
    }
  };
};
function to(e) {
  return V(e).direction === "rtl";
}
const no = {
  convertOffsetParentRelativeRectToViewportRelativeRect: jn,
  getDocumentElement: Y,
  getClippingRect: Zn,
  getOffsetParent: ht,
  getElementRects: eo,
  getClientRects: Xn,
  getDimensions: Jn,
  getScale: J,
  isElement: z,
  isRTL: to
};
function gt(e, t) {
  return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height;
}
function oo(e, t) {
  let n = null, o;
  const r = Y(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 l = e.getBoundingClientRect(), {
      left: f,
      top: u,
      width: p,
      height: d
    } = l;
    if (a || t(), !p || !d)
      return;
    const m = ce(u), h = ce(r.clientWidth - (f + p)), x = ce(r.clientHeight - (u + d)), g = ce(f), P = {
      rootMargin: -m + "px " + -h + "px " + -x + "px " + -g + "px",
      threshold: I(0, G(1, c)) || 1
    };
    let b = !0;
    function A(O) {
      const R = O[0].intersectionRatio;
      if (R !== c) {
        if (!b)
          return s();
        R ? s(!1, R) : o = setTimeout(() => {
          s(!1, 1e-7);
        }, 1e3);
      }
      R === 1 && !gt(l, e.getBoundingClientRect()) && s(), b = !1;
    }
    try {
      n = new IntersectionObserver(A, {
        ...P,
        // Handle <iframe>s
        root: r.ownerDocument
      });
    } catch {
      n = new IntersectionObserver(A, P);
    }
    n.observe(e);
  }
  return s(!0), i;
}
function ro(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, l = Me(e), f = r || i ? [...l ? Pe(l) : [], ...Pe(t)] : [];
  f.forEach((g) => {
    r && g.addEventListener("scroll", n, {
      passive: !0
    }), i && g.addEventListener("resize", n);
  });
  const u = l && a ? oo(l, n) : null;
  let p = -1, d = null;
  s && (d = new ResizeObserver((g) => {
    let [y] = g;
    y && y.target === l && d && (d.unobserve(t), cancelAnimationFrame(p), p = requestAnimationFrame(() => {
      var P;
      (P = d) == null || P.observe(t);
    })), n();
  }), l && !c && d.observe(l), d.observe(t));
  let m, h = c ? Z(e) : null;
  c && x();
  function x() {
    const g = Z(e);
    h && !gt(h, g) && n(), h = g, m = requestAnimationFrame(x);
  }
  return n(), () => {
    var g;
    f.forEach((y) => {
      r && y.removeEventListener("scroll", n), i && y.removeEventListener("resize", n);
    }), u?.(), (g = d) == null || g.disconnect(), d = null, c && cancelAnimationFrame(m);
  };
}
const io = In, so = Hn, ao = Fn, co = Bn, lo = kn, et = $n, fo = Wn, uo = (e, t, n) => {
  const o = /* @__PURE__ */ new Map(), r = {
    platform: no,
    ...n
  }, i = {
    ...r.platform,
    _c: o
  };
  return _n(e, t, {
    ...r,
    platform: i
  });
};
var po = typeof document < "u", mo = function() {
}, le = po ? nt : mo;
function me(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 (!me(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) && !me(e[i], t[i]))
        return !1;
    }
    return !0;
  }
  return e !== e && t !== t;
}
function vt(e) {
  return typeof window > "u" ? 1 : (e.ownerDocument.defaultView || window).devicePixelRatio || 1;
}
function tt(e, t) {
  const n = vt(e);
  return Math.round(t * n) / n;
}
function ye(e) {
  const t = v.useRef(e);
  return le(() => {
    t.current = e;
  }), t;
}
function ho(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: l
  } = e, [f, u] = v.useState({
    x: 0,
    y: 0,
    strategy: n,
    placement: t,
    middlewareData: {},
    isPositioned: !1
  }), [p, d] = v.useState(o);
  me(p, o) || d(o);
  const [m, h] = v.useState(null), [x, g] = v.useState(null), y = v.useCallback((C) => {
    C !== O.current && (O.current = C, h(C));
  }, []), P = v.useCallback((C) => {
    C !== R.current && (R.current = C, g(C));
  }, []), b = i || m, A = s || x, O = v.useRef(null), R = v.useRef(null), T = v.useRef(f), k = c != null, D = ye(c), $ = ye(r), F = ye(l), E = v.useCallback(() => {
    if (!O.current || !R.current)
      return;
    const C = {
      placement: t,
      strategy: n,
      middleware: p
    };
    $.current && (C.platform = $.current), uo(O.current, R.current, C).then((_) => {
      const H = {
        ..._,
        // 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: F.current !== !1
      };
      S.current && !me(T.current, H) && (T.current = H, gn.flushSync(() => {
        u(H);
      }));
    });
  }, [p, t, n, $, F]);
  le(() => {
    l === !1 && T.current.isPositioned && (T.current.isPositioned = !1, u((C) => ({
      ...C,
      isPositioned: !1
    })));
  }, [l]);
  const S = v.useRef(!1);
  le(() => (S.current = !0, () => {
    S.current = !1;
  }), []), le(() => {
    if (b && (O.current = b), A && (R.current = A), b && A) {
      if (D.current)
        return D.current(b, A, E);
      E();
    }
  }, [b, A, E, D, k]);
  const L = v.useMemo(() => ({
    reference: O,
    floating: R,
    setReference: y,
    setFloating: P
  }), [y, P]), N = v.useMemo(() => ({
    reference: b,
    floating: A
  }), [b, A]), M = v.useMemo(() => {
    const C = {
      position: n,
      left: 0,
      top: 0
    };
    if (!N.floating)
      return C;
    const _ = tt(N.floating, f.x), H = tt(N.floating, f.y);
    return a ? {
      ...C,
      transform: "translate(" + _ + "px, " + H + "px)",
      ...vt(N.floating) >= 1.5 && {
        willChange: "transform"
      }
    } : {
      position: n,
      left: _,
      top: H
    };
  }, [n, a, N.floating, f.x, f.y]);
  return v.useMemo(() => ({
    ...f,
    update: E,
    refs: L,
    elements: N,
    floatingStyles: M
  }), [f, E, L, N, M]);
}
const go = (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 ? et({
        element: o.current,
        padding: r
      }).fn(n) : {} : o ? et({
        element: o,
        padding: r
      }).fn(n) : {};
    }
  };
}, vo = (e, t) => ({
  ...io(e),
  options: [e, t]
}), xo = (e, t) => ({
  ...so(e),
  options: [e, t]
}), wo = (e, t) => ({
  ...fo(e),
  options: [e, t]
}), yo = (e, t) => ({
  ...ao(e),
  options: [e, t]
}), Po = (e, t) => ({
  ...co(e),
  options: [e, t]
}), bo = (e, t) => ({
  ...lo(e),
  options: [e, t]
}), Ao = (e, t) => ({
  ...go(e),
  options: [e, t]
});
var Co = "Arrow", xt = v.forwardRef((e, t) => {
  const { children: n, width: o = 10, height: r = 5, ...i } = e;
  return /* @__PURE__ */ w(
    ie.svg,
    {
      ...i,
      ref: t,
      width: o,
      height: r,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: e.asChild ? n : /* @__PURE__ */ w("polygon", { points: "0,0 30,0 15,10" })
    }
  );
});
xt.displayName = Co;
var Ro = xt, De = "Popper", [wt, yt] = ot(De), [Oo, Pt] = wt(De), bt = (e) => {
  const { __scopePopper: t, children: n } = e, [o, r] = v.useState(null);
  return /* @__PURE__ */ w(Oo, { scope: t, anchor: o, onAnchorChange: r, children: n });
};
bt.displayName = De;
var At = "PopperAnchor", Ct = v.forwardRef(
  (e, t) => {
    const { __scopePopper: n, virtualRef: o, ...r } = e, i = Pt(At, n), s = v.useRef(null), a = he(t, s), c = v.useRef(null);
    return v.useEffect(() => {
      const l = c.current;
      c.current = o?.current || s.current, l !== c.current && i.onAnchorChange(c.current);
    }), o ? null : /* @__PURE__ */ w(ie.div, { ...r, ref: a });
  }
);
Ct.displayName = At;
var Te = "PopperContent", [So, Eo] = wt(Te), Rt = v.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: l = [],
      collisionPadding: f = 0,
      sticky: u = "partial",
      hideWhenDetached: p = !1,
      updatePositionStrategy: d = "optimized",
      onPlaced: m,
      ...h
    } = e, x = Pt(Te, n), [g, y] = v.useState(null), P = he(t, (te) => y(te)), [b, A] = v.useState(null), O = vn(b), R = O?.width ?? 0, T = O?.height ?? 0, k = o + (i !== "center" ? "-" + i : ""), D = typeof f == "number" ? f : { top: 0, right: 0, bottom: 0, left: 0, ...f }, $ = Array.isArray(l) ? l : [l], F = $.length > 0, E = {
      padding: D,
      boundary: $.filter(Mo),
      // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
      altBoundary: F
    }, { refs: S, floatingStyles: L, placement: N, isPositioned: M, middlewareData: C } = ho({
      // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
      strategy: "fixed",
      placement: k,
      whileElementsMounted: (...te) => ro(...te, {
        animationFrame: d === "always"
      }),
      elements: {
        reference: x.anchor
      },
      middleware: [
        vo({ mainAxis: r + T, alignmentAxis: s }),
        c && xo({
          mainAxis: !0,
          crossAxis: !1,
          limiter: u === "partial" ? wo() : void 0,
          ...E
        }),
        c && yo({ ...E }),
        Po({
          ...E,
          apply: ({ elements: te, rects: Ve, availableWidth: Ut, availableHeight: Zt }) => {
            const { width: Jt, height: Qt } = Ve.reference, ae = te.floating.style;
            ae.setProperty("--radix-popper-available-width", `${Ut}px`), ae.setProperty("--radix-popper-available-height", `${Zt}px`), ae.setProperty("--radix-popper-anchor-width", `${Jt}px`), ae.setProperty("--radix-popper-anchor-height", `${Qt}px`);
          }
        }),
        b && Ao({ element: b, padding: a }),
        Do({ arrowWidth: R, arrowHeight: T }),
        p && bo({ strategy: "referenceHidden", ...E })
      ]
    }), [_, H] = Et(N), ze = dn(m);
    Xe(() => {
      M && ze?.();
    }, [M, ze]);
    const Xt = C.arrow?.x, Yt = C.arrow?.y, qt = C.arrow?.centerOffset !== 0, [Gt, Kt] = v.useState();
    return Xe(() => {
      g && Kt(window.getComputedStyle(g).zIndex);
    }, [g]), /* @__PURE__ */ w(
      "div",
      {
        ref: S.setFloating,
        "data-radix-popper-content-wrapper": "",
        style: {
          ...L,
          transform: M ? L.transform : "translate(0, -200%)",
          // keep off the page when measuring
          minWidth: "max-content",
          zIndex: Gt,
          "--radix-popper-transform-origin": [
            C.transformOrigin?.x,
            C.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
          ...C.hide?.referenceHidden && {
            visibility: "hidden",
            pointerEvents: "none"
          }
        },
        dir: e.dir,
        children: /* @__PURE__ */ w(
          So,
          {
            scope: n,
            placedSide: _,
            onArrowChange: A,
            arrowX: Xt,
            arrowY: Yt,
            shouldHideArrow: qt,
            children: /* @__PURE__ */ w(
              ie.div,
              {
                "data-side": _,
                "data-align": H,
                ...h,
                ref: P,
                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: M ? void 0 : "none"
                }
              }
            )
          }
        )
      }
    );
  }
);
Rt.displayName = Te;
var Ot = "PopperArrow", No = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right"
}, St = v.forwardRef(function(t, n) {
  const { __scopePopper: o, ...r } = t, i = Eo(Ot, o), s = No[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__ */ w(
      "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__ */ w(
          Ro,
          {
            ...r,
            ref: n,
            style: {
              ...r.style,
              // ensures the element can be measured correctly (mostly for if SVG)
              display: "block"
            }
          }
        )
      }
    )
  );
});
St.displayName = Ot;
function Mo(e) {
  return e !== null;
}
var Do = (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, [l, f] = Et(n), u = { start: "0%", center: "50%", end: "100%" }[f], p = (r.arrow?.x ?? 0) + a / 2, d = (r.arrow?.y ?? 0) + c / 2;
    let m = "", h = "";
    return l === "bottom" ? (m = s ? u : `${p}px`, h = `${-c}px`) : l === "top" ? (m = s ? u : `${p}px`, h = `${o.floating.height + c}px`) : l === "right" ? (m = `${-c}px`, h = s ? u : `${d}px`) : l === "left" && (m = `${o.floating.width + c}px`, h = s ? u : `${d}px`), { data: { x: m, y: h } };
  }
});
function Et(e) {
  const [t, n = "center"] = e.split("-");
  return [t, n];
}
var To = bt, Nt = Ct, _o = Rt, $o = St, xe = "Popover", [Mt] = ot(xe, [
  yt
]), se = yt(), [Fo, K] = Mt(xe), Dt = (e) => {
  const {
    __scopePopover: t,
    children: n,
    open: o,
    defaultOpen: r,
    onOpenChange: i,
    modal: s = !1
  } = e, a = se(t), c = v.useRef(null), [l, f] = v.useState(!1), [u, p] = rn({
    prop: o,
    defaultProp: r ?? !1,
    onChange: i,
    caller: xe
  });
  return /* @__PURE__ */ w(To, { ...a, children: /* @__PURE__ */ w(
    Fo,
    {
      scope: t,
      contentId: pn(),
      triggerRef: c,
      open: u,
      onOpenChange: p,
      onOpenToggle: v.useCallback(() => p((d) => !d), [p]),
      hasCustomAnchor: l,
      onCustomAnchorAdd: v.useCallback(() => f(!0), []),
      onCustomAnchorRemove: v.useCallback(() => f(!1), []),
      modal: s,
      children: n
    }
  ) });
};
Dt.displayName = xe;
var Tt = "PopoverAnchor", _t = v.forwardRef(
  (e, t) => {
    const { __scopePopover: n, ...o } = e, r = K(Tt, n), i = se(n), { onCustomAnchorAdd: s, onCustomAnchorRemove: a } = r;
    return v.useEffect(() => (s(), () => a()), [s, a]), /* @__PURE__ */ w(Nt, { ...i, ...o, ref: t });
  }
);
_t.displayName = Tt;
var $t = "PopoverTrigger", Ft = v.forwardRef(
  (e, t) => {
    const { __scopePopover: n, ...o } = e, r = K($t, n), i = se(n), s = he(t, r.triggerRef), a = /* @__PURE__ */ w(
      ie.button,
      {
        type: "button",
        "aria-haspopup": "dialog",
        "aria-expanded": r.open,
        "aria-controls": r.contentId,
        "data-state": zt(r.open),
        ...o,
        ref: s,
        onClick: ne(e.onClick, r.onOpenToggle)
      }
    );
    return r.hasCustomAnchor ? a : /* @__PURE__ */ w(Nt, { asChild: !0, ...i, children: a });
  }
);
Ft.displayName = $t;
var _e = "PopoverPortal", [ko, Lo] = Mt(_e, {
  forceMount: void 0
}), kt = (e) => {
  const { __scopePopover: t, forceMount: n, children: o, container: r } = e, i = K(_e, t);
  return /* @__PURE__ */ w(ko, { scope: t, forceMount: n, children: /* @__PURE__ */ w(st, { present: n || i.open, children: /* @__PURE__ */ w(xn, { asChild: !0, container: r, children: o }) }) });
};
kt.displayName = _e;
var Q = "PopoverContent", Lt = v.forwardRef(
  (e, t) => {
    const n = Lo(Q, e.__scopePopover), { forceMount: o = n.forceMount, ...r } = e, i = K(Q, e.__scopePopover);
    return /* @__PURE__ */ w(st, { present: o || i.open, children: i.modal ? /* @__PURE__ */ w(Ho, { ...r, ref: t }) : /* @__PURE__ */ w(Wo, { ...r, ref: t }) });
  }
);
Lt.displayName = Q;
var Io = sn("PopoverContent.RemoveScroll"), Ho = v.forwardRef(
  (e, t) => {
    const n = K(Q, e.__scopePopover), o = v.useRef(null), r = he(t, o), i = v.useRef(!1);
    return v.useEffect(() => {
      const s = o.current;
      if (s) return an(s);
    }, []), /* @__PURE__ */ w(cn, { as: Io, allowPinchZoom: !0, children: /* @__PURE__ */ w(
      It,
      {
        ...e,
        ref: r,
        trapFocus: n.open,
        disableOutsidePointerEvents: !0,
        onCloseAutoFocus: ne(e.onCloseAutoFocus, (s) => {
          s.preventDefault(), i.current || n.triggerRef.current?.focus();
        }),
        onPointerDownOutside: ne(
          e.onPointerDownOutside,
          (s) => {
            const a = s.detail.originalEvent, c = a.button === 0 && a.ctrlKey === !0, l = a.button === 2 || c;
            i.current = l;
          },
          { checkForDefaultPrevented: !1 }
        ),
        onFocusOutside: ne(
          e.onFocusOutside,
          (s) => s.preventDefault(),
          { checkForDefaultPrevented: !1 }
        )
      }
    ) });
  }
), Wo = v.forwardRef(
  (e, t) => {
    const n = K(Q, e.__scopePopover), o = v.useRef(!1), r = v.useRef(!1);
    return /* @__PURE__ */ w(
      It,
      {
        ...e,
        ref: t,
        trapFocus: !1,
        disableOutsidePointerEvents: !1,
        onCloseAutoFocus: (i) => {
          e.onCloseAutoFocus?.(i), i.defaultPrevented || (o.current || n.triggerRef.current?.focus(), i.preventDefault()), o.current = !1, r.current = !1;
        },
        onInteractOutside: (i) => {
          e.onInteractOutside?.(i), i.defaultPrevented || (o.current = !0, i.detail.originalEvent.type === "pointerdown" && (r.current = !0));
          const s = i.target;
          n.triggerRef.current?.contains(s) && i.preventDefault(), i.detail.originalEvent.type === "focusin" && r.current && i.preventDefault();
        }
      }
    );
  }
), It = v.forwardRef(
  (e, t) => {
    const {
      __scopePopover: n,
      trapFocus: o,
      onOpenAutoFocus: r,
      onCloseAutoFocus: i,
      disableOutsidePointerEvents: s,
      onEscapeKeyDown: a,
      onPointerDownOutside: c,
      onFocusOutside: l,
      onInteractOutside: f,
      ...u
    } = e, p = K(Q, n), d = se(n);
    return ln(), /* @__PURE__ */ w(
      fn,
      {
        asChild: !0,
        loop: !0,
        trapped: o,
        onMountAutoFocus: r,
        onUnmountAutoFocus: i,
        children: /* @__PURE__ */ w(
          un,
          {
            asChild: !0,
            disableOutsidePointerEvents: s,
            onInteractOutside: f,
            onEscapeKeyDown: a,
            onPointerDownOutside: c,
            onFocusOutside: l,
            onDismiss: () => p.onOpenChange(!1),
            children: /* @__PURE__ */ w(
              _o,
              {
                "data-state": zt(p.open),
                role: "dialog",
                id: p.contentId,
                ...d,
                ...u,
                ref: t,
                style: {
                  ...u.style,
                  "--radix-popover-content-transform-origin": "var(--radix-popper-transform-origin)",
                  "--radix-popover-content-available-width": "var(--radix-popper-available-width)",
                  "--radix-popover-content-available-height": "var(--radix-popper-available-height)",
                  "--radix-popover-trigger-width": "var(--radix-popper-anchor-width)",
                  "--radix-popover-trigger-height": "var(--radix-popper-anchor-height)"
                }
              }
            )
          }
        )
      }
    );
  }
), Ht = "PopoverClose", Wt = v.forwardRef(
  (e, t) => {
    const { __scopePopover: n, ...o } = e, r = K(Ht, n);
    return /* @__PURE__ */ w(
      ie.button,
      {
        type: "button",
        ...o,
        ref: t,
        onClick: ne(e.onClick, () => r.onOpenChange(!1))
      }
    );
  }
);
Wt.displayName = Ht;
var Bo = "PopoverArrow", Bt = v.forwardRef(
  (e, t) => {
    const { __scopePopover: n, ...o } = e, r = se(n);
    return /* @__PURE__ */ w($o, { ...r, ...o, ref: t });
  }
);
Bt.displayName = Bo;
function zt(e) {
  return e ? "open" : "closed";
}
var zo = Dt, Vo = _t, jo = Ft, Xo = kt, Yo = Lt, qo = Wt, Go = Bt;
const Vt = en(null), Ko = ":popover", Uo = ({
  children: e,
  intent: t
}) => {
  const [n, o] = tn(null);
  return /* @__PURE__ */ w(
    Vt.Provider,
    {
      value: {
        headerId: n,
        setHeaderId: o,
        intent: t
      },
      children: e
    }
  );
}, $e = () => {
  const e = nn(Vt);
  if (!e)
    throw Error("usePopover must be used within a Popover provider");
  return e;
}, jt = ({ children: e, intent: t = "surface", modal: n = !1, ...o }) => /* @__PURE__ */ w(Uo, { intent: t, children: /* @__PURE__ */ w(zo, { "data-spark-component": "popover", modal: n, ...o, children: e }) });
jt.displayName = "Popover";
const Fe = ({ asChild: e = !1, children: t, ref: n, ...o }) => /* @__PURE__ */ w(Vo, { "data-spark-component": "popover-anchor", ref: n, asChild: e, ...o, children: t });
Fe.displayName = "Popover.Anchor";
const ke = ({
  asChild: e = !1,
  width: t = 16,
  height: n = 8,
  className: o,
  ref: r,
  ...i
}) => {
  const { intent: s } = $e(), a = at("visible", {
    variants: {
      intent: {
        surface: "fill-surface",
        main: "fill-main-container",
        support: "fill-support-container",
        accent: "fill-accent-container",
        basic: "fill-basic-container",
        success: "fill-success-container",
        alert: "fill-alert-container",
        danger: "fill-error-container",
        info: "fill-info-container",
        neutral: "fill-neutral-container"
      }
    },
    defaultVariants: {
      intent: "surface"
    }
  });
  return /* @__PURE__ */ w(
    Go,
    {
      "data-spark-component": "popover-arrow",
      ref: r,
      className: a({ intent: s, className: o }),
      asChild: e,
      width: t,
      height: n,
      ...i
    }
  );
};
ke.displayName = "Popover.Arrow";
const Le = ({
  "aria-label": e,
  className: t,
  ref: n,
  ...o
}) => /* @__PURE__ */ w(
  qo,
  {
    "data-spark-component": "popover-close-button",
    ref: n,
    className: ct("right-lg top-md absolute", t),
    asChild: !0,
    ...o,
    children: /* @__PURE__ */ w(Pn, { size: "sm", intent: "neutral", design: "ghost", "aria-label": e, children: /* @__PURE__ */ w(yn, { children: /* @__PURE__ */ w(wn, {}) }) })
  }
);
Le.displayName = "Popover.CloseButton";
const Zo = at(
  [
    "rounded-md",
    "shadow-sm",
    "focus-visible:outline-hidden focus-visible:u-outline",
    "max-h-(--radix-popper-available-height) overflow-y-auto"
  ],
  {
    variants: {
      intent: {
        surface: "bg-surface text-on-surface",
        main: "bg-main-container text-on-main-container",
        support: "bg-support-container text-on-support-container",
        accent: "bg-accent-container text-on-accent-container",
        basic: "bg-basic-container text-on-basic-container",
        success: "bg-success-container text-on-success-container",
        alert: "bg-alert-container text-on-alert-container",
        danger: "bg-error-container text-on-error-container",
        info: "bg-info-container text-on-info-container",
        neutral: "bg-neutral-container text-on-neutral-container"
      },
      matchTriggerWidth: {
        true: "w-(--radix-popper-anchor-width)"
      },
      enforceBoundaries: {
        true: ["max-w-(--radix-popper-available-width)"]
      },
      inset: {
        true: "overflow-hidden",
        false: "p-lg"
      },
      elevation: {
        dropdown: "z-dropdown",
        popover: "z-popover"
      }
    },
    compoundVariants: [
      {
        inset: !1,
        /**
         * When there is a close button, padding to the right side must be adjusted to avoid content overlapping with it.
         */
        class: "has-data-[spark-component=popover-close-button]:pr-3xl"
      },
      {
        enforceBoundaries: !1,
        matchTriggerWidth: !1,
        class: "max-w-[min(var(--spacing-sz-384),100vw)]"
      }
    ],
    defaultVariants: {
      matchTriggerWidth: !1,
      enforceBoundaries: !1,
      inset: !1,
      intent: "surface",
      elevation: "popover"
    }
  }
), Ie = ({
  // Spark props
  className: e,
  children: t,
  matchTriggerWidth: n = !1,
  // Radix props
  align: o = "center",
  arrowPadding: r = 16,
  // In order not to overlap the arrow on the rounded corners of the popover.
  asChild: i = !1,
  avoidCollisions: s = !0,
  "aria-labelledby": a,
  collisionBoundary: c,
  collisionPadding: l = 0,
  hideWhenDetached: f = !1,
  side: u = "bottom",
  sideOffset: p = 8,
  sticky: d = "partial",
  inset: m = !1,
  elevation: h = "popover",
  ref: x,
  ...g
}) => {
  const { headerId: y, intent: P } = $e();
  return /* @__PURE__ */ w(
    Yo,
    {
      "aria-labelledby": y || a,
      className: Zo({
        enforceBoundaries: !!c,
        matchTriggerWidth: n,
        inset: m,
        elevation: h,
        intent: P,
        className: e
      }),
      "data-spark-component": "popover-content",
      ref: x,
      align: o,
      arrowPadding: r,
      asChild: i,
      avoidCollisions: s,
      collisionBoundary: c,
      collisionPadding: l,
      hideWhenDetached: f,
      side: u,
      sideOffset: p,
      sticky: d,
      ...g,
      children: t
    }
  );
};
Ie.displayName = "Popover.Content";
const He = ({ children: e, className: t, ref: n, ...o }) => {
  const r = `${Ko}-header-${on()}`, { setHeaderId: i } = $e();
  return nt(() => (i(r), () => i(null)), [r, i]), /* @__PURE__ */ w("header", { id: r, ref: n, className: ct("mb-md text-headline-2", t), ...o, children: e });
};
He.displayName = "Popover.Header";
const We = ({ children: e, ...t }) => /* @__PURE__ */ w(Xo, { ...t, children: e });
We.displayName = "Popover.Portal";
const Be = ({ asChild: e = !1, children: t, ref: n, ...o }) => /* @__PURE__ */ w(
  jo,
  {
    "data-spark-component": "popover-trigger",
    ref: n,
    asChild: e,
    ...o,
    children: t
  }
);
Be.displayName = "Popover.Trigger";
const Jo = Object.assign(jt, {
  Anchor: Fe,
  Arrow: ke,
  CloseButton: Le,
  Content: Ie,
  Header: He,
  Portal: We,
  Trigger: Be
});
Jo.displayName = "Popover";
Fe.displayName = "Popover.Anchor";
ke.displayName = "Popover.Arrow";
Le.displayName = "Popover.CloseButton";
Ie.displayName = "Popover.Content";
He.displayName = "Popover.Header";
We.displayName = "Popover.Portal";
Be.displayName = "Popover.Trigger";
export {
  Jo as Popover
};
//# sourceMappingURL=index.mjs.map
