import { jsx as p, Fragment as Qe, jsxs as Y } from "react/jsx-runtime";
import * as i from "react";
import { forwardRef as et, useState as tt, Children as nt } from "react";
import { c as rt, B as ot } from "./button-DBX_tvfJ.mjs";
import { r as st } from "./info.es-u0pS2u7W.mjs";
import { a as it, P as at } from "./paragraph-DNtj7OLr.mjs";
import { d as ct } from "./variables-BUfnQw6H.mjs";
import * as lt from "react-dom";
import ut from "react-dom";
import { u as dt, o as pt, s as ft, l as ht, m as mt, n as vt, p as yt, q as gt, k as wt } from "./floating-ui.react-dom-0ol4sFzt.mjs";
import { c as Pt } from "./bind-CU-R61T-.mjs";
function T(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
  return function(r) {
    if (e?.(r), n === !1 || !r.defaultPrevented)
      return t?.(r);
  };
}
function ce(e, t) {
  if (typeof e == "function")
    return e(t);
  e != null && (e.current = t);
}
function de(...e) {
  return (t) => {
    let n = !1;
    const o = e.map((r) => {
      const s = ce(r, t);
      return !n && typeof s == "function" && (n = !0), s;
    });
    if (n)
      return () => {
        for (let r = 0; r < o.length; r++) {
          const s = o[r];
          typeof s == "function" ? s() : ce(e[r], null);
        }
      };
  };
}
function N(...e) {
  return i.useCallback(de(...e), e);
}
function pe(e, t = []) {
  let n = [];
  function o(s, a) {
    const u = i.createContext(a), c = n.length;
    n = [...n, a];
    const l = (f) => {
      const { scope: m, children: h, ...v } = f, y = m?.[e]?.[c] || u, w = i.useMemo(() => v, Object.values(v));
      return /* @__PURE__ */ p(y.Provider, { value: w, children: h });
    };
    l.displayName = s + "Provider";
    function d(f, m) {
      const h = m?.[e]?.[c] || u, v = i.useContext(h);
      if (v) return v;
      if (a !== void 0) return a;
      throw new Error(`\`${f}\` must be used within \`${s}\``);
    }
    return [l, d];
  }
  const r = () => {
    const s = n.map((a) => i.createContext(a));
    return function(u) {
      const c = u?.[e] || s;
      return i.useMemo(
        () => ({ [`__scope${e}`]: { ...u, [e]: c } }),
        [u, c]
      );
    };
  };
  return r.scopeName = e, [o, Et(r, ...t)];
}
function Et(...e) {
  const t = e[0];
  if (e.length === 1) return t;
  const n = () => {
    const o = e.map((r) => ({
      useScope: r(),
      scopeName: r.scopeName
    }));
    return function(s) {
      const a = o.reduce((u, { useScope: c, scopeName: l }) => {
        const f = c(s)[`__scope${l}`];
        return { ...u, ...f };
      }, {});
      return i.useMemo(() => ({ [`__scope${t.scopeName}`]: a }), [a]);
    };
  };
  return n.scopeName = t.scopeName, n;
}
var fe = i.forwardRef((e, t) => {
  const { children: n, ...o } = e, r = i.Children.toArray(n), s = r.find(Ct);
  if (s) {
    const a = s.props.children, u = r.map((c) => c === s ? i.Children.count(a) > 1 ? i.Children.only(null) : i.isValidElement(a) ? a.props.children : null : c);
    return /* @__PURE__ */ p(X, { ...o, ref: t, children: i.isValidElement(a) ? i.cloneElement(a, void 0, u) : null });
  }
  return /* @__PURE__ */ p(X, { ...o, ref: t, children: n });
});
fe.displayName = "Slot";
var X = i.forwardRef((e, t) => {
  const { children: n, ...o } = e;
  if (i.isValidElement(n)) {
    const r = xt(n), s = bt(o, n.props);
    return n.type !== i.Fragment && (s.ref = t ? de(t, r) : r), i.cloneElement(n, s);
  }
  return i.Children.count(n) > 1 ? i.Children.only(null) : null;
});
X.displayName = "SlotClone";
var he = ({ children: e }) => /* @__PURE__ */ p(Qe, { children: e });
function Ct(e) {
  return i.isValidElement(e) && e.type === he;
}
function bt(e, t) {
  const n = { ...t };
  for (const o in t) {
    const r = e[o], s = t[o];
    /^on[A-Z]/.test(o) ? r && s ? n[o] = (...u) => {
      s(...u), r(...u);
    } : r && (n[o] = r) : o === "style" ? n[o] = { ...r, ...s } : o === "className" && (n[o] = [r, s].filter(Boolean).join(" "));
  }
  return { ...e, ...n };
}
function xt(e) {
  let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
var Tt = [
  "a",
  "button",
  "div",
  "form",
  "h2",
  "h3",
  "img",
  "input",
  "label",
  "li",
  "nav",
  "ol",
  "p",
  "span",
  "svg",
  "ul"
], A = Tt.reduce((e, t) => {
  const n = i.forwardRef((o, r) => {
    const { asChild: s, ...a } = o, u = s ? fe : t;
    return typeof window < "u" && (window[/* @__PURE__ */ Symbol.for("radix-ui")] = !0), /* @__PURE__ */ p(u, { ...a, ref: r });
  });
  return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
}, {});
function _t(e, t) {
  e && lt.flushSync(() => e.dispatchEvent(t));
}
function k(e) {
  const t = i.useRef(e);
  return i.useEffect(() => {
    t.current = e;
  }), i.useMemo(() => (...n) => t.current?.(...n), []);
}
function At(e, t = globalThis?.document) {
  const n = k(e);
  i.useEffect(() => {
    const o = (r) => {
      r.key === "Escape" && n(r);
    };
    return t.addEventListener("keydown", o, { capture: !0 }), () => t.removeEventListener("keydown", o, { capture: !0 });
  }, [n, t]);
}
var Ot = "DismissableLayer", K = "dismissableLayer.update", Rt = "dismissableLayer.pointerDownOutside", Nt = "dismissableLayer.focusOutside", le, me = i.createContext({
  layers: /* @__PURE__ */ new Set(),
  layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
  branches: /* @__PURE__ */ new Set()
}), ve = i.forwardRef(
  (e, t) => {
    const {
      disableOutsidePointerEvents: n = !1,
      onEscapeKeyDown: o,
      onPointerDownOutside: r,
      onFocusOutside: s,
      onInteractOutside: a,
      onDismiss: u,
      ...c
    } = e, l = i.useContext(me), [d, f] = i.useState(null), m = d?.ownerDocument ?? globalThis?.document, [, h] = i.useState({}), v = N(t, (g) => f(g)), y = Array.from(l.layers), [w] = [...l.layersWithOutsidePointerEventsDisabled].slice(-1), E = y.indexOf(w), P = d ? y.indexOf(d) : -1, b = l.layersWithOutsidePointerEventsDisabled.size > 0, C = P >= E, x = Lt((g) => {
      const O = g.target, $ = [...l.branches].some((I) => I.contains(O));
      !C || $ || (r?.(g), a?.(g), g.defaultPrevented || u?.());
    }, m), _ = kt((g) => {
      const O = g.target;
      [...l.branches].some((I) => I.contains(O)) || (s?.(g), a?.(g), g.defaultPrevented || u?.());
    }, m);
    return At((g) => {
      P === l.layers.size - 1 && (o?.(g), !g.defaultPrevented && u && (g.preventDefault(), u()));
    }, m), i.useEffect(() => {
      if (d)
        return n && (l.layersWithOutsidePointerEventsDisabled.size === 0 && (le = m.body.style.pointerEvents, m.body.style.pointerEvents = "none"), l.layersWithOutsidePointerEventsDisabled.add(d)), l.layers.add(d), ue(), () => {
          n && l.layersWithOutsidePointerEventsDisabled.size === 1 && (m.body.style.pointerEvents = le);
        };
    }, [d, m, n, l]), i.useEffect(() => () => {
      d && (l.layers.delete(d), l.layersWithOutsidePointerEventsDisabled.delete(d), ue());
    }, [d, l]), i.useEffect(() => {
      const g = () => h({});
      return document.addEventListener(K, g), () => document.removeEventListener(K, g);
    }, []), /* @__PURE__ */ p(
      A.div,
      {
        ...c,
        ref: v,
        style: {
          pointerEvents: b ? C ? "auto" : "none" : void 0,
          ...e.style
        },
        onFocusCapture: T(e.onFocusCapture, _.onFocusCapture),
        onBlurCapture: T(e.onBlurCapture, _.onBlurCapture),
        onPointerDownCapture: T(
          e.onPointerDownCapture,
          x.onPointerDownCapture
        )
      }
    );
  }
);
ve.displayName = Ot;
var St = "DismissableLayerBranch", Dt = i.forwardRef((e, t) => {
  const n = i.useContext(me), o = i.useRef(null), r = N(t, o);
  return i.useEffect(() => {
    const s = o.current;
    if (s)
      return n.branches.add(s), () => {
        n.branches.delete(s);
      };
  }, [n.branches]), /* @__PURE__ */ p(A.div, { ...e, ref: r });
});
Dt.displayName = St;
function Lt(e, t = globalThis?.document) {
  const n = k(e), o = i.useRef(!1), r = i.useRef(() => {
  });
  return i.useEffect(() => {
    const s = (u) => {
      if (u.target && !o.current) {
        let c = function() {
          ye(
            Rt,
            n,
            l,
            { discrete: !0 }
          );
        };
        const l = { originalEvent: u };
        u.pointerType === "touch" ? (t.removeEventListener("click", r.current), r.current = c, t.addEventListener("click", r.current, { once: !0 })) : c();
      } else
        t.removeEventListener("click", r.current);
      o.current = !1;
    }, a = window.setTimeout(() => {
      t.addEventListener("pointerdown", s);
    }, 0);
    return () => {
      window.clearTimeout(a), t.removeEventListener("pointerdown", s), t.removeEventListener("click", r.current);
    };
  }, [t, n]), {
    // ensures we check React component tree (not just DOM tree)
    onPointerDownCapture: () => o.current = !0
  };
}
function kt(e, t = globalThis?.document) {
  const n = k(e), o = i.useRef(!1);
  return i.useEffect(() => {
    const r = (s) => {
      s.target && !o.current && ye(Nt, n, { originalEvent: s }, {
        discrete: !1
      });
    };
    return t.addEventListener("focusin", r), () => t.removeEventListener("focusin", r);
  }, [t, n]), {
    onFocusCapture: () => o.current = !0,
    onBlurCapture: () => o.current = !1
  };
}
function ue() {
  const e = new CustomEvent(K);
  document.dispatchEvent(e);
}
function ye(e, t, n, { discrete: o }) {
  const r = n.originalEvent.target, s = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
  t && r.addEventListener(e, t, { once: !0 }), o ? _t(r, s) : r.dispatchEvent(s);
}
var R = globalThis?.document ? i.useLayoutEffect : () => {
}, It = i.useId || (() => {
}), Mt = 0;
function Ft(e) {
  const [t, n] = i.useState(It());
  return R(() => {
    n((o) => o ?? String(Mt++));
  }, [e]), t ? `radix-${t}` : "";
}
var $t = "Arrow", ge = i.forwardRef((e, t) => {
  const { children: n, width: o = 10, height: r = 5, ...s } = e;
  return /* @__PURE__ */ p(
    A.svg,
    {
      ...s,
      ref: t,
      width: o,
      height: r,
      viewBox: "0 0 30 10",
      preserveAspectRatio: "none",
      children: e.asChild ? n : /* @__PURE__ */ p("polygon", { points: "0,0 30,0 15,10" })
    }
  );
});
ge.displayName = $t;
var Ht = ge;
function Wt(e) {
  const [t, n] = i.useState(void 0);
  return R(() => {
    if (e) {
      n({ width: e.offsetWidth, height: e.offsetHeight });
      const o = new ResizeObserver((r) => {
        if (!Array.isArray(r) || !r.length)
          return;
        const s = r[0];
        let a, u;
        if ("borderBoxSize" in s) {
          const c = s.borderBoxSize, l = Array.isArray(c) ? c[0] : c;
          a = l.inlineSize, u = l.blockSize;
        } else
          a = e.offsetWidth, u = e.offsetHeight;
        n({ width: a, height: u });
      });
      return o.observe(e, { box: "border-box" }), () => o.unobserve(e);
    } else
      n(void 0);
  }, [e]), t;
}
var J = "Popper", [we, Pe] = pe(J), [Bt, Ee] = we(J), Ce = (e) => {
  const { __scopePopper: t, children: n } = e, [o, r] = i.useState(null);
  return /* @__PURE__ */ p(Bt, { scope: t, anchor: o, onAnchorChange: r, children: n });
};
Ce.displayName = J;
var be = "PopperAnchor", xe = i.forwardRef(
  (e, t) => {
    const { __scopePopper: n, virtualRef: o, ...r } = e, s = Ee(be, n), a = i.useRef(null), u = N(t, a);
    return i.useEffect(() => {
      s.onAnchorChange(o?.current || a.current);
    }), o ? null : /* @__PURE__ */ p(A.div, { ...r, ref: u });
  }
);
xe.displayName = be;
var Q = "PopperContent", [Ut, zt] = we(Q), Te = i.forwardRef(
  (e, t) => {
    const {
      __scopePopper: n,
      side: o = "bottom",
      sideOffset: r = 0,
      align: s = "center",
      alignOffset: a = 0,
      arrowPadding: u = 0,
      avoidCollisions: c = !0,
      collisionBoundary: l = [],
      collisionPadding: d = 0,
      sticky: f = "partial",
      hideWhenDetached: m = !1,
      updatePositionStrategy: h = "optimized",
      onPlaced: v,
      ...y
    } = e, w = Ee(Q, n), [E, P] = i.useState(null), b = N(t, (M) => P(M)), [C, x] = i.useState(null), _ = Wt(C), g = _?.width ?? 0, O = _?.height ?? 0, $ = o + (s !== "center" ? "-" + s : ""), I = typeof d == "number" ? d : { top: 0, right: 0, bottom: 0, left: 0, ...d }, re = Array.isArray(l) ? l : [l], We = re.length > 0, H = {
      padding: I,
      boundary: re.filter(jt),
      // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
      altBoundary: We
    }, { refs: Be, floatingStyles: oe, placement: Ue, isPositioned: W, middlewareData: S } = dt({
      // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
      strategy: "fixed",
      placement: $,
      whileElementsMounted: (...M) => wt(...M, {
        animationFrame: h === "always"
      }),
      elements: {
        reference: w.anchor
      },
      middleware: [
        pt({ mainAxis: r + O, alignmentAxis: a }),
        c && ft({
          mainAxis: !0,
          crossAxis: !1,
          limiter: f === "partial" ? gt() : void 0,
          ...H
        }),
        c && ht({ ...H }),
        mt({
          ...H,
          apply: ({ elements: M, rects: ae, availableWidth: Ke, availableHeight: qe }) => {
            const { width: Ze, height: Je } = ae.reference, B = M.floating.style;
            B.setProperty("--radix-popper-available-width", `${Ke}px`), B.setProperty("--radix-popper-available-height", `${qe}px`), B.setProperty("--radix-popper-anchor-width", `${Ze}px`), B.setProperty("--radix-popper-anchor-height", `${Je}px`);
          }
        }),
        C && vt({ element: C, padding: u }),
        Gt({ arrowWidth: g, arrowHeight: O }),
        m && yt({ strategy: "referenceHidden", ...H })
      ]
    }), [se, ze] = Oe(Ue), ie = k(v);
    R(() => {
      W && ie?.();
    }, [W, ie]);
    const Ve = S.arrow?.x, je = S.arrow?.y, Ge = S.arrow?.centerOffset !== 0, [Ye, Xe] = i.useState();
    return R(() => {
      E && Xe(window.getComputedStyle(E).zIndex);
    }, [E]), /* @__PURE__ */ p(
      "div",
      {
        ref: Be.setFloating,
        "data-radix-popper-content-wrapper": "",
        style: {
          ...oe,
          transform: W ? oe.transform : "translate(0, -200%)",
          // keep off the page when measuring
          minWidth: "max-content",
          zIndex: Ye,
          "--radix-popper-transform-origin": [
            S.transformOrigin?.x,
            S.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
          ...S.hide?.referenceHidden && {
            visibility: "hidden",
            pointerEvents: "none"
          }
        },
        dir: e.dir,
        children: /* @__PURE__ */ p(
          Ut,
          {
            scope: n,
            placedSide: se,
            onArrowChange: x,
            arrowX: Ve,
            arrowY: je,
            shouldHideArrow: Ge,
            children: /* @__PURE__ */ p(
              A.div,
              {
                "data-side": se,
                "data-align": ze,
                ...y,
                ref: b,
                style: {
                  ...y.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: W ? void 0 : "none"
                }
              }
            )
          }
        )
      }
    );
  }
);
Te.displayName = Q;
var _e = "PopperArrow", Vt = {
  top: "bottom",
  right: "left",
  bottom: "top",
  left: "right"
}, Ae = i.forwardRef(function(t, n) {
  const { __scopePopper: o, ...r } = t, s = zt(_e, o), a = Vt[s.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__ */ p(
      "span",
      {
        ref: s.onArrowChange,
        style: {
          position: "absolute",
          left: s.arrowX,
          top: s.arrowY,
          [a]: 0,
          transformOrigin: {
            top: "",
            right: "0 0",
            bottom: "center 0",
            left: "100% 0"
          }[s.placedSide],
          transform: {
            top: "translateY(100%)",
            right: "translateY(50%) rotate(90deg) translateX(-50%)",
            bottom: "rotate(180deg)",
            left: "translateY(50%) rotate(-90deg) translateX(50%)"
          }[s.placedSide],
          visibility: s.shouldHideArrow ? "hidden" : void 0
        },
        children: /* @__PURE__ */ p(
          Ht,
          {
            ...r,
            ref: n,
            style: {
              ...r.style,
              // ensures the element can be measured correctly (mostly for if SVG)
              display: "block"
            }
          }
        )
      }
    )
  );
});
Ae.displayName = _e;
function jt(e) {
  return e !== null;
}
var Gt = (e) => ({
  name: "transformOrigin",
  options: e,
  fn(t) {
    const { placement: n, rects: o, middlewareData: r } = t, a = r.arrow?.centerOffset !== 0, u = a ? 0 : e.arrowWidth, c = a ? 0 : e.arrowHeight, [l, d] = Oe(n), f = { start: "0%", center: "50%", end: "100%" }[d], m = (r.arrow?.x ?? 0) + u / 2, h = (r.arrow?.y ?? 0) + c / 2;
    let v = "", y = "";
    return l === "bottom" ? (v = a ? f : `${m}px`, y = `${-c}px`) : l === "top" ? (v = a ? f : `${m}px`, y = `${o.floating.height + c}px`) : l === "right" ? (v = `${-c}px`, y = a ? f : `${h}px`) : l === "left" && (v = `${o.floating.width + c}px`, y = a ? f : `${h}px`), { data: { x: v, y } };
  }
});
function Oe(e) {
  const [t, n = "center"] = e.split("-");
  return [t, n];
}
var Yt = Ce, Xt = xe, Kt = Te, qt = Ae, Zt = "Portal", Re = i.forwardRef((e, t) => {
  const { container: n, ...o } = e, [r, s] = i.useState(!1);
  R(() => s(!0), []);
  const a = n || r && globalThis?.document?.body;
  return a ? ut.createPortal(/* @__PURE__ */ p(A.div, { ...o, ref: t }), a) : null;
});
Re.displayName = Zt;
function Jt(e, t) {
  return i.useReducer((n, o) => t[n][o] ?? n, e);
}
var ee = (e) => {
  const { present: t, children: n } = e, o = Qt(t), r = typeof n == "function" ? n({ present: o.isPresent }) : i.Children.only(n), s = N(o.ref, en(r));
  return typeof n == "function" || o.isPresent ? i.cloneElement(r, { ref: s }) : null;
};
ee.displayName = "Presence";
function Qt(e) {
  const [t, n] = i.useState(), o = i.useRef({}), r = i.useRef(e), s = i.useRef("none"), a = e ? "mounted" : "unmounted", [u, c] = Jt(a, {
    mounted: {
      UNMOUNT: "unmounted",
      ANIMATION_OUT: "unmountSuspended"
    },
    unmountSuspended: {
      MOUNT: "mounted",
      ANIMATION_END: "unmounted"
    },
    unmounted: {
      MOUNT: "mounted"
    }
  });
  return i.useEffect(() => {
    const l = U(o.current);
    s.current = u === "mounted" ? l : "none";
  }, [u]), R(() => {
    const l = o.current, d = r.current;
    if (d !== e) {
      const m = s.current, h = U(l);
      e ? c("MOUNT") : h === "none" || l?.display === "none" ? c("UNMOUNT") : c(d && m !== h ? "ANIMATION_OUT" : "UNMOUNT"), r.current = e;
    }
  }, [e, c]), R(() => {
    if (t) {
      let l;
      const d = t.ownerDocument.defaultView ?? window, f = (h) => {
        const y = U(o.current).includes(h.animationName);
        if (h.target === t && y && (c("ANIMATION_END"), !r.current)) {
          const w = t.style.animationFillMode;
          t.style.animationFillMode = "forwards", l = d.setTimeout(() => {
            t.style.animationFillMode === "forwards" && (t.style.animationFillMode = w);
          });
        }
      }, m = (h) => {
        h.target === t && (s.current = U(o.current));
      };
      return t.addEventListener("animationstart", m), t.addEventListener("animationcancel", f), t.addEventListener("animationend", f), () => {
        d.clearTimeout(l), t.removeEventListener("animationstart", m), t.removeEventListener("animationcancel", f), t.removeEventListener("animationend", f);
      };
    } else
      c("ANIMATION_END");
  }, [t, c]), {
    isPresent: ["mounted", "unmountSuspended"].includes(u),
    ref: i.useCallback((l) => {
      l && (o.current = getComputedStyle(l)), n(l);
    }, [])
  };
}
function U(e) {
  return e?.animationName || "none";
}
function en(e) {
  let t = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning;
  return n ? e.ref : (t = Object.getOwnPropertyDescriptor(e, "ref")?.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
}
function tn({
  prop: e,
  defaultProp: t,
  onChange: n = () => {
  }
}) {
  const [o, r] = nn({ defaultProp: t, onChange: n }), s = e !== void 0, a = s ? e : o, u = k(n), c = i.useCallback(
    (l) => {
      if (s) {
        const f = typeof l == "function" ? l(e) : l;
        f !== e && u(f);
      } else
        r(l);
    },
    [s, e, r, u]
  );
  return [a, c];
}
function nn({
  defaultProp: e,
  onChange: t
}) {
  const n = i.useState(e), [o] = n, r = i.useRef(o), s = k(t);
  return i.useEffect(() => {
    r.current !== o && (s(o), r.current = o);
  }, [o, r, s]), n;
}
var rn = "VisuallyHidden", Ne = i.forwardRef(
  (e, t) => /* @__PURE__ */ p(
    A.span,
    {
      ...e,
      ref: t,
      style: {
        // 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",
        ...e.style
      }
    }
  )
);
Ne.displayName = rn;
var on = Ne, [z] = pe("Tooltip", [
  Pe
]), V = Pe(), Se = "TooltipProvider", sn = 700, q = "tooltip.open", [an, te] = z(Se), De = (e) => {
  const {
    __scopeTooltip: t,
    delayDuration: n = sn,
    skipDelayDuration: o = 300,
    disableHoverableContent: r = !1,
    children: s
  } = e, [a, u] = i.useState(!0), c = i.useRef(!1), l = i.useRef(0);
  return i.useEffect(() => {
    const d = l.current;
    return () => window.clearTimeout(d);
  }, []), /* @__PURE__ */ p(
    an,
    {
      scope: t,
      isOpenDelayed: a,
      delayDuration: n,
      onOpen: i.useCallback(() => {
        window.clearTimeout(l.current), u(!1);
      }, []),
      onClose: i.useCallback(() => {
        window.clearTimeout(l.current), l.current = window.setTimeout(
          () => u(!0),
          o
        );
      }, [o]),
      isPointerInTransitRef: c,
      onPointerInTransitChange: i.useCallback((d) => {
        c.current = d;
      }, []),
      disableHoverableContent: r,
      children: s
    }
  );
};
De.displayName = Se;
var j = "Tooltip", [cn, F] = z(j), Le = (e) => {
  const {
    __scopeTooltip: t,
    children: n,
    open: o,
    defaultOpen: r = !1,
    onOpenChange: s,
    disableHoverableContent: a,
    delayDuration: u
  } = e, c = te(j, e.__scopeTooltip), l = V(t), [d, f] = i.useState(null), m = Ft(), h = i.useRef(0), v = a ?? c.disableHoverableContent, y = u ?? c.delayDuration, w = i.useRef(!1), [E = !1, P] = tn({
    prop: o,
    defaultProp: r,
    onChange: (g) => {
      g ? (c.onOpen(), document.dispatchEvent(new CustomEvent(q))) : c.onClose(), s?.(g);
    }
  }), b = i.useMemo(() => E ? w.current ? "delayed-open" : "instant-open" : "closed", [E]), C = i.useCallback(() => {
    window.clearTimeout(h.current), h.current = 0, w.current = !1, P(!0);
  }, [P]), x = i.useCallback(() => {
    window.clearTimeout(h.current), h.current = 0, P(!1);
  }, [P]), _ = i.useCallback(() => {
    window.clearTimeout(h.current), h.current = window.setTimeout(() => {
      w.current = !0, P(!0), h.current = 0;
    }, y);
  }, [y, P]);
  return i.useEffect(() => () => {
    h.current && (window.clearTimeout(h.current), h.current = 0);
  }, []), /* @__PURE__ */ p(Yt, { ...l, children: /* @__PURE__ */ p(
    cn,
    {
      scope: t,
      contentId: m,
      open: E,
      stateAttribute: b,
      trigger: d,
      onTriggerChange: f,
      onTriggerEnter: i.useCallback(() => {
        c.isOpenDelayed ? _() : C();
      }, [c.isOpenDelayed, _, C]),
      onTriggerLeave: i.useCallback(() => {
        v ? x() : (window.clearTimeout(h.current), h.current = 0);
      }, [x, v]),
      onOpen: C,
      onClose: x,
      disableHoverableContent: v,
      children: n
    }
  ) });
};
Le.displayName = j;
var Z = "TooltipTrigger", ke = i.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = F(Z, n), s = te(Z, n), a = V(n), u = i.useRef(null), c = N(t, u, r.onTriggerChange), l = i.useRef(!1), d = i.useRef(!1), f = i.useCallback(() => l.current = !1, []);
    return i.useEffect(() => () => document.removeEventListener("pointerup", f), [f]), /* @__PURE__ */ p(Xt, { asChild: !0, ...a, children: /* @__PURE__ */ p(
      A.button,
      {
        "aria-describedby": r.open ? r.contentId : void 0,
        "data-state": r.stateAttribute,
        ...o,
        ref: c,
        onPointerMove: T(e.onPointerMove, (m) => {
          m.pointerType !== "touch" && !d.current && !s.isPointerInTransitRef.current && (r.onTriggerEnter(), d.current = !0);
        }),
        onPointerLeave: T(e.onPointerLeave, () => {
          r.onTriggerLeave(), d.current = !1;
        }),
        onPointerDown: T(e.onPointerDown, () => {
          l.current = !0, document.addEventListener("pointerup", f, { once: !0 });
        }),
        onFocus: T(e.onFocus, () => {
          l.current || r.onOpen();
        }),
        onBlur: T(e.onBlur, r.onClose),
        onClick: T(e.onClick, r.onClose)
      }
    ) });
  }
);
ke.displayName = Z;
var ne = "TooltipPortal", [ln, un] = z(ne, {
  forceMount: void 0
}), Ie = (e) => {
  const { __scopeTooltip: t, forceMount: n, children: o, container: r } = e, s = F(ne, t);
  return /* @__PURE__ */ p(ln, { scope: t, forceMount: n, children: /* @__PURE__ */ p(ee, { present: n || s.open, children: /* @__PURE__ */ p(Re, { asChild: !0, container: r, children: o }) }) });
};
Ie.displayName = ne;
var L = "TooltipContent", Me = i.forwardRef(
  (e, t) => {
    const n = un(L, e.__scopeTooltip), { forceMount: o = n.forceMount, side: r = "top", ...s } = e, a = F(L, e.__scopeTooltip);
    return /* @__PURE__ */ p(ee, { present: o || a.open, children: a.disableHoverableContent ? /* @__PURE__ */ p(Fe, { side: r, ...s, ref: t }) : /* @__PURE__ */ p(dn, { side: r, ...s, ref: t }) });
  }
), dn = i.forwardRef((e, t) => {
  const n = F(L, e.__scopeTooltip), o = te(L, e.__scopeTooltip), r = i.useRef(null), s = N(t, r), [a, u] = i.useState(null), { trigger: c, onClose: l } = n, d = r.current, { onPointerInTransitChange: f } = o, m = i.useCallback(() => {
    u(null), f(!1);
  }, [f]), h = i.useCallback(
    (v, y) => {
      const w = v.currentTarget, E = { x: v.clientX, y: v.clientY }, P = hn(E, w.getBoundingClientRect()), b = mn(E, P), C = vn(y.getBoundingClientRect()), x = gn([...b, ...C]);
      u(x), f(!0);
    },
    [f]
  );
  return i.useEffect(() => () => m(), [m]), i.useEffect(() => {
    if (c && d) {
      const v = (w) => h(w, d), y = (w) => h(w, c);
      return c.addEventListener("pointerleave", v), d.addEventListener("pointerleave", y), () => {
        c.removeEventListener("pointerleave", v), d.removeEventListener("pointerleave", y);
      };
    }
  }, [c, d, h, m]), i.useEffect(() => {
    if (a) {
      const v = (y) => {
        const w = y.target, E = { x: y.clientX, y: y.clientY }, P = c?.contains(w) || d?.contains(w), b = !yn(E, a);
        P ? m() : b && (m(), l());
      };
      return document.addEventListener("pointermove", v), () => document.removeEventListener("pointermove", v);
    }
  }, [c, d, a, l, m]), /* @__PURE__ */ p(Fe, { ...e, ref: s });
}), [pn, fn] = z(j, { isInside: !1 }), Fe = i.forwardRef(
  (e, t) => {
    const {
      __scopeTooltip: n,
      children: o,
      "aria-label": r,
      onEscapeKeyDown: s,
      onPointerDownOutside: a,
      ...u
    } = e, c = F(L, n), l = V(n), { onClose: d } = c;
    return i.useEffect(() => (document.addEventListener(q, d), () => document.removeEventListener(q, d)), [d]), i.useEffect(() => {
      if (c.trigger) {
        const f = (m) => {
          m.target?.contains(c.trigger) && d();
        };
        return window.addEventListener("scroll", f, { capture: !0 }), () => window.removeEventListener("scroll", f, { capture: !0 });
      }
    }, [c.trigger, d]), /* @__PURE__ */ p(
      ve,
      {
        asChild: !0,
        disableOutsidePointerEvents: !1,
        onEscapeKeyDown: s,
        onPointerDownOutside: a,
        onFocusOutside: (f) => f.preventDefault(),
        onDismiss: d,
        children: /* @__PURE__ */ Y(
          Kt,
          {
            "data-state": c.stateAttribute,
            ...l,
            ...u,
            ref: t,
            style: {
              ...u.style,
              "--radix-tooltip-content-transform-origin": "var(--radix-popper-transform-origin)",
              "--radix-tooltip-content-available-width": "var(--radix-popper-available-width)",
              "--radix-tooltip-content-available-height": "var(--radix-popper-available-height)",
              "--radix-tooltip-trigger-width": "var(--radix-popper-anchor-width)",
              "--radix-tooltip-trigger-height": "var(--radix-popper-anchor-height)"
            },
            children: [
              /* @__PURE__ */ p(he, { children: o }),
              /* @__PURE__ */ p(pn, { scope: n, isInside: !0, children: /* @__PURE__ */ p(on, { id: c.contentId, role: "tooltip", children: r || o }) })
            ]
          }
        )
      }
    );
  }
);
Me.displayName = L;
var $e = "TooltipArrow", He = i.forwardRef(
  (e, t) => {
    const { __scopeTooltip: n, ...o } = e, r = V(n);
    return fn(
      $e,
      n
    ).isInside ? null : /* @__PURE__ */ p(qt, { ...r, ...o, ref: t });
  }
);
He.displayName = $e;
function hn(e, t) {
  const n = Math.abs(t.top - e.y), o = Math.abs(t.bottom - e.y), r = Math.abs(t.right - e.x), s = Math.abs(t.left - e.x);
  switch (Math.min(n, o, r, s)) {
    case s:
      return "left";
    case r:
      return "right";
    case n:
      return "top";
    case o:
      return "bottom";
    default:
      throw new Error("unreachable");
  }
}
function mn(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 vn(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 yn(e, t) {
  const { x: n, y: o } = e;
  let r = !1;
  for (let s = 0, a = t.length - 1; s < t.length; a = s++) {
    const u = t[s].x, c = t[s].y, l = t[a].x, d = t[a].y;
    c > o != d > o && n < (l - u) * (o - c) / (d - c) + u && (r = !r);
  }
  return r;
}
function gn(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), wn(t);
}
function wn(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 s = t[t.length - 1], a = t[t.length - 2];
      if ((s.x - a.x) * (r.y - a.y) >= (s.y - a.y) * (r.x - a.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 s = n[n.length - 1], a = n[n.length - 2];
      if ((s.x - a.x) * (r.y - a.y) >= (s.y - a.y) * (r.x - a.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 Pn = De, En = Le, Cn = ke, bn = Ie, xn = Me, Tn = He;
const _n = "_slideDownAndFade_fkagk_1", An = "_slideLeftAndFade_fkagk_1", On = "_slideUpAndFade_fkagk_1", Rn = "_slideRightAndFade_fkagk_1", Nn = {
  "purpur-tooltip": "_purpur-tooltip_fkagk_1",
  "purpur-tooltip__content": "_purpur-tooltip__content_fkagk_4",
  "purpur-tooltip__content--primary": "_purpur-tooltip__content--primary_fkagk_14",
  "purpur-tooltip__content--primary-negative": "_purpur-tooltip__content--primary-negative_fkagk_17",
  slideDownAndFade: _n,
  slideLeftAndFade: An,
  slideUpAndFade: On,
  slideRightAndFade: Rn,
  "purpur-tooltip__arrow--primary": "_purpur-tooltip__arrow--primary_fkagk_32",
  "purpur-tooltip__arrow--primary-negative": "_purpur-tooltip__arrow--primary-negative_fkagk_35"
}, G = Pt.bind(Nn), Sn = {
  TOP: "top",
  BOTTOM: "bottom",
  LEFT: "left",
  RIGHT: "right"
}, Dn = {
  START: "start",
  CENTER: "center",
  END: "end"
}, D = "purpur-tooltip", Ln = et(
  ({
    ["data-testid"]: e,
    buttonSize: t = "md",
    children: n,
    className: o,
    contentClassName: r,
    negative: s = !1,
    position: a = Sn.TOP,
    align: u = Dn.CENTER,
    triggerAriaLabel: c,
    triggerElement: l,
    ...d
  }, f) => {
    const [m, h] = tt(!1), v = G(
      o,
      D,
      `${D}--primary${s ? "-negative" : ""}`
    ), y = /* @__PURE__ */ p(
      rt,
      {
        ref: f,
        "aria-label": c,
        "aria-expanded": m,
        variant: ot.TERTIARY_PURPLE,
        negative: s,
        iconOnly: !0,
        "data-testid": `${e}-trigger-button`,
        size: t,
        children: /* @__PURE__ */ p(st, { size: "md" })
      }
    );
    return /* @__PURE__ */ p("div", { "data-testid": e, className: v, children: /* @__PURE__ */ p(Pn, { delayDuration: parseInt(ct), children: /* @__PURE__ */ Y(En, { open: m, onOpenChange: h, ...d, children: [
      /* @__PURE__ */ p(
        Cn,
        {
          asChild: !0,
          onClick: (w) => {
            w.preventDefault(), h(!0);
          },
          children: nt.count(l) === 0 ? y : l
        }
      ),
      /* @__PURE__ */ p(bn, { children: /* @__PURE__ */ Y(
        xn,
        {
          side: a,
          align: u,
          className: G(
            r,
            `${D}__content`,
            `${D}__content--primary${s ? "-negative" : ""}`
          ),
          sideOffset: -5,
          "data-testid": `${e}-content`,
          children: [
            typeof n == "string" ? /* @__PURE__ */ p(
              it,
              {
                variant: at.PARAGRAPH100,
                negative: !s,
                "data-testid": `${e}-paragraph`,
                children: n
              }
            ) : n,
            /* @__PURE__ */ p(
              Tn,
              {
                className: G(
                  `${D}__arrow`,
                  `${D}__arrow--primary${s ? "-negative" : ""}`
                )
              }
            )
          ]
        }
      ) })
    ] }) }) });
  }
);
Ln.displayName = "Tooltip";
export {
  Sn as T,
  Dn as a,
  Ln as b
};
//# sourceMappingURL=tooltip-DXi7ikUT.mjs.map
