import { a as e, r as t, t as n } from "./dist-DCjaNViz.js";
import { i as r, o as i, t as a } from "./dist-D-6_qntS.js";
import { t as o } from "./dist-BSqU5QJM.js";
import { t as s } from "./dist-BN9-Ksur.js";
import { t as c } from "./utils-CHlhTiFC.js";
import { r as l, t as u } from "./dist-CniKe8MM.js";
import { a as d, i as f, n as p, r as m, t as h } from "./dist-CCgkh91X.js";
import { t as g } from "./dist-Dw21-wvw.js";
import * as _ from "react";
import v from "react";
import { jsx as y, jsxs as b } from "react/jsx-runtime";
//#region node_modules/@radix-ui/react-tooltip/dist/index.mjs
var [x, S] = e("Tooltip", [d]), C = d(), w = "TooltipProvider", T = 700, E = "tooltip.open", [D, O] = x(w), k = (e) => {
	let { __scopeTooltip: t, delayDuration: n = T, skipDelayDuration: r = 300, disableHoverableContent: i = !1, children: a } = e, o = _.useRef(!0), s = _.useRef(!1), c = _.useRef(0);
	return _.useEffect(() => {
		let e = c.current;
		return () => window.clearTimeout(e);
	}, []), /* @__PURE__ */ y(D, {
		scope: t,
		isOpenDelayedRef: o,
		delayDuration: n,
		onOpen: _.useCallback(() => {
			window.clearTimeout(c.current), o.current = !1;
		}, []),
		onClose: _.useCallback(() => {
			window.clearTimeout(c.current), c.current = window.setTimeout(() => o.current = !0, r);
		}, [r]),
		isPointerInTransitRef: s,
		onPointerInTransitChange: _.useCallback((e) => {
			s.current = e;
		}, []),
		disableHoverableContent: i,
		children: a
	});
};
k.displayName = w;
var A = "Tooltip", [j, M] = x(A), N = (e) => {
	let { __scopeTooltip: t, children: r, open: i, defaultOpen: a, onOpenChange: o, disableHoverableContent: c, delayDuration: l } = e, u = O(A, e.__scopeTooltip), d = C(t), [p, m] = _.useState(null), h = s(), g = _.useRef(0), v = c ?? u.disableHoverableContent, b = l ?? u.delayDuration, x = _.useRef(!1), [S, w] = n({
		prop: i,
		defaultProp: a ?? !1,
		onChange: (e) => {
			e ? (u.onOpen(), document.dispatchEvent(new CustomEvent(E))) : u.onClose(), o?.(e);
		},
		caller: A
	}), T = _.useMemo(() => S ? x.current ? "delayed-open" : "instant-open" : "closed", [S]), D = _.useCallback(() => {
		window.clearTimeout(g.current), g.current = 0, x.current = !1, w(!0);
	}, [w]), k = _.useCallback(() => {
		window.clearTimeout(g.current), g.current = 0, w(!1);
	}, [w]), M = _.useCallback(() => {
		window.clearTimeout(g.current), g.current = window.setTimeout(() => {
			x.current = !0, w(!0), g.current = 0;
		}, b);
	}, [b, w]);
	return _.useEffect(() => () => {
		g.current &&= (window.clearTimeout(g.current), 0);
	}, []), /* @__PURE__ */ y(f, {
		...d,
		children: /* @__PURE__ */ y(j, {
			scope: t,
			contentId: h,
			open: S,
			stateAttribute: T,
			trigger: p,
			onTriggerChange: m,
			onTriggerEnter: _.useCallback(() => {
				u.isOpenDelayedRef.current ? M() : D();
			}, [
				u.isOpenDelayedRef,
				M,
				D
			]),
			onTriggerLeave: _.useCallback(() => {
				v ? k() : (window.clearTimeout(g.current), g.current = 0);
			}, [k, v]),
			onOpen: D,
			onClose: k,
			disableHoverableContent: v,
			children: r
		})
	});
};
N.displayName = A;
var P = "TooltipTrigger", F = _.forwardRef((e, n) => {
	let { __scopeTooltip: r, ...o } = e, s = M(P, r), c = O(P, r), l = C(r), u = i(n, _.useRef(null), s.onTriggerChange), d = _.useRef(!1), f = _.useRef(!1), p = _.useCallback(() => d.current = !1, []);
	return _.useEffect(() => () => document.removeEventListener("pointerup", p), [p]), /* @__PURE__ */ y(h, {
		asChild: !0,
		...l,
		children: /* @__PURE__ */ y(a.button, {
			"aria-describedby": s.open ? s.contentId : void 0,
			"data-state": s.stateAttribute,
			...o,
			ref: u,
			onPointerMove: t(e.onPointerMove, (e) => {
				e.pointerType !== "touch" && !f.current && !c.isPointerInTransitRef.current && (s.onTriggerEnter(), f.current = !0);
			}),
			onPointerLeave: t(e.onPointerLeave, () => {
				s.onTriggerLeave(), f.current = !1;
			}),
			onPointerDown: t(e.onPointerDown, () => {
				s.open && s.onClose(), d.current = !0, document.addEventListener("pointerup", p, { once: !0 });
			}),
			onFocus: t(e.onFocus, () => {
				d.current || s.onOpen();
			}),
			onBlur: t(e.onBlur, s.onClose),
			onClick: t(e.onClick, s.onClose)
		})
	});
});
F.displayName = P;
var I = "TooltipPortal", [L, ee] = x(I, { forceMount: void 0 }), R = (e) => {
	let { __scopeTooltip: t, forceMount: n, children: r, container: i } = e, a = M(I, t);
	return /* @__PURE__ */ y(L, {
		scope: t,
		forceMount: n,
		children: /* @__PURE__ */ y(o, {
			present: n || a.open,
			children: /* @__PURE__ */ y(u, {
				asChild: !0,
				container: i,
				children: r
			})
		})
	});
};
R.displayName = I;
var z = "TooltipContent", B = _.forwardRef((e, t) => {
	let n = ee(z, e.__scopeTooltip), { forceMount: r = n.forceMount, side: i = "top", ...a } = e, s = M(z, e.__scopeTooltip);
	return /* @__PURE__ */ y(o, {
		present: r || s.open,
		children: s.disableHoverableContent ? /* @__PURE__ */ y(U, {
			side: i,
			...a,
			ref: t
		}) : /* @__PURE__ */ y(te, {
			side: i,
			...a,
			ref: t
		})
	});
}), te = _.forwardRef((e, t) => {
	let n = M(z, e.__scopeTooltip), r = O(z, e.__scopeTooltip), a = _.useRef(null), o = i(t, a), [s, c] = _.useState(null), { trigger: l, onClose: u } = n, d = a.current, { onPointerInTransitChange: f } = r, p = _.useCallback(() => {
		c(null), f(!1);
	}, [f]), m = _.useCallback((e, t) => {
		let n = e.currentTarget, r = {
			x: e.clientX,
			y: e.clientY
		}, i = q(r, K(r, n.getBoundingClientRect())), a = J(t.getBoundingClientRect());
		c(X([...i, ...a])), f(!0);
	}, [f]);
	return _.useEffect(() => () => p(), [p]), _.useEffect(() => {
		if (l && d) {
			let e = (e) => m(e, d), t = (e) => m(e, l);
			return l.addEventListener("pointerleave", e), d.addEventListener("pointerleave", t), () => {
				l.removeEventListener("pointerleave", e), d.removeEventListener("pointerleave", t);
			};
		}
	}, [
		l,
		d,
		m,
		p
	]), _.useEffect(() => {
		if (s) {
			let e = (e) => {
				let t = e.target, n = {
					x: e.clientX,
					y: e.clientY
				}, r = l?.contains(t) || d?.contains(t), i = !Y(n, s);
				r ? p() : i && (p(), u());
			};
			return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
		}
	}, [
		l,
		d,
		s,
		u,
		p
	]), /* @__PURE__ */ y(U, {
		...e,
		ref: o
	});
}), [ne, V] = x(A, { isInside: !1 }), H = r("TooltipContent"), U = _.forwardRef((e, t) => {
	let { __scopeTooltip: n, children: r, "aria-label": i, onEscapeKeyDown: a, onPointerDownOutside: o, ...s } = e, c = M(z, n), u = C(n), { onClose: d } = c;
	return _.useEffect(() => (document.addEventListener(E, d), () => document.removeEventListener(E, d)), [d]), _.useEffect(() => {
		if (c.trigger) {
			let e = (e) => {
				e.target?.contains(c.trigger) && d();
			};
			return window.addEventListener("scroll", e, { capture: !0 }), () => window.removeEventListener("scroll", e, { capture: !0 });
		}
	}, [c.trigger, d]), /* @__PURE__ */ y(l, {
		asChild: !0,
		disableOutsidePointerEvents: !1,
		onEscapeKeyDown: a,
		onPointerDownOutside: o,
		onFocusOutside: (e) => e.preventDefault(),
		onDismiss: d,
		children: /* @__PURE__ */ b(m, {
			"data-state": c.stateAttribute,
			...u,
			...s,
			ref: t,
			style: {
				...s.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__ */ y(H, { children: r }), /* @__PURE__ */ y(ne, {
				scope: n,
				isInside: !0,
				children: /* @__PURE__ */ y(g, {
					id: c.contentId,
					role: "tooltip",
					children: i || r
				})
			})]
		})
	});
});
B.displayName = z;
var W = "TooltipArrow", G = _.forwardRef((e, t) => {
	let { __scopeTooltip: n, ...r } = e, i = C(n);
	return V(W, n).isInside ? null : /* @__PURE__ */ y(p, {
		...i,
		...r,
		ref: t
	});
});
G.displayName = W;
function K(e, t) {
	let n = Math.abs(t.top - e.y), r = Math.abs(t.bottom - e.y), i = Math.abs(t.right - e.x), a = Math.abs(t.left - e.x);
	switch (Math.min(n, r, i, a)) {
		case a: return "left";
		case i: return "right";
		case n: return "top";
		case r: return "bottom";
		default: throw Error("unreachable");
	}
}
function q(e, t, n = 5) {
	let r = [];
	switch (t) {
		case "top":
			r.push({
				x: e.x - n,
				y: e.y + n
			}, {
				x: e.x + n,
				y: e.y + n
			});
			break;
		case "bottom":
			r.push({
				x: e.x - n,
				y: e.y - n
			}, {
				x: e.x + n,
				y: e.y - n
			});
			break;
		case "left":
			r.push({
				x: e.x + n,
				y: e.y - n
			}, {
				x: e.x + n,
				y: e.y + n
			});
			break;
		case "right":
			r.push({
				x: e.x - n,
				y: e.y - n
			}, {
				x: e.x - n,
				y: e.y + n
			});
			break;
	}
	return r;
}
function J(e) {
	let { top: t, right: n, bottom: r, left: i } = e;
	return [
		{
			x: i,
			y: t
		},
		{
			x: n,
			y: t
		},
		{
			x: n,
			y: r
		},
		{
			x: i,
			y: r
		}
	];
}
function Y(e, t) {
	let { x: n, y: r } = e, i = !1;
	for (let e = 0, a = t.length - 1; e < t.length; a = e++) {
		let o = t[e], s = t[a], c = o.x, l = o.y, u = s.x, d = s.y;
		l > r != d > r && n < (u - c) * (r - l) / (d - l) + c && (i = !i);
	}
	return i;
}
function X(e) {
	let t = e.slice();
	return t.sort((e, t) => e.x < t.x ? -1 : e.x > t.x ? 1 : e.y < t.y ? -1 : +(e.y > t.y)), re(t);
}
function re(e) {
	if (e.length <= 1) return e.slice();
	let t = [];
	for (let n = 0; n < e.length; n++) {
		let r = e[n];
		for (; t.length >= 2;) {
			let e = t[t.length - 1], n = t[t.length - 2];
			if ((e.x - n.x) * (r.y - n.y) >= (e.y - n.y) * (r.x - n.x)) t.pop();
			else break;
		}
		t.push(r);
	}
	t.pop();
	let n = [];
	for (let t = e.length - 1; t >= 0; t--) {
		let r = e[t];
		for (; n.length >= 2;) {
			let e = n[n.length - 1], t = n[n.length - 2];
			if ((e.x - t.x) * (r.y - t.y) >= (e.y - t.y) * (r.x - t.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 ie = k, Z = N, ae = F, oe = R, Q = B, se = ie, ce = Z, le = ae, $ = v.forwardRef(({ className: e, inPortal: t = !1, sideOffset: n = 4, ...r }, i) => {
	let a = /* @__PURE__ */ y(Q, {
		...r,
		ref: i,
		sideOffset: n,
		className: c("z-50 overflow-hidden border border-primary-gray-300 dark:border-primary-gray-550 text-sm! bg-primary-gray-300 dark:bg-primary-gray-550 p-2 text-primary-black dark:text-primary-white animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", e)
	});
	return t ? /* @__PURE__ */ y(oe, { children: a }) : a;
});
$.displayName = Q.displayName;
//#endregion
export { le as i, $ as n, se as r, ce as t };

//# sourceMappingURL=tooltip-CcVg0YMs.js.map