import { t as e } from "./floating-ui.utils.dom-5U5b4xPf.js";
import "./constants-VB9bsA8p.js";
import { o as t } from "./event-DWcDp5kt.js";
//#region ../../node_modules/.bun/@floating-ui+utils@0.2.11/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
var n = [
	"top",
	"right",
	"bottom",
	"left"
], r = Math.min, i = Math.max, a = Math.round, o = Math.floor, s = (e) => ({
	x: e,
	y: e
}), c = {
	left: "right",
	right: "left",
	bottom: "top",
	top: "bottom"
};
function l(e, t, n) {
	return i(e, r(t, n));
}
function u(e, t) {
	return typeof e == "function" ? e(t) : e;
}
function d(e) {
	return e.split("-")[0];
}
function f(e) {
	return e.split("-")[1];
}
function p(e) {
	return e === "x" ? "y" : "x";
}
function m(e) {
	return e === "y" ? "height" : "width";
}
function h(e) {
	let t = e[0];
	return t === "t" || t === "b" ? "y" : "x";
}
function g(e) {
	return p(h(e));
}
function _(e, t, n) {
	n === void 0 && (n = !1);
	let r = f(e), i = g(e), a = m(i), o = i === "x" ? r === (n ? "end" : "start") ? "right" : "left" : r === "start" ? "bottom" : "top";
	return t.reference[a] > t.floating[a] && (o = E(o)), [o, E(o)];
}
function v(e) {
	let t = E(e);
	return [
		y(e),
		t,
		y(t)
	];
}
function y(e) {
	return e.includes("start") ? e.replace("start", "end") : e.replace("end", "start");
}
var b = ["left", "right"], x = ["right", "left"], S = ["top", "bottom"], C = ["bottom", "top"];
function w(e, t, n) {
	switch (e) {
		case "top":
		case "bottom": return n ? t ? x : b : t ? b : x;
		case "left":
		case "right": return t ? S : C;
		default: return [];
	}
}
function T(e, t, n, r) {
	let i = f(e), a = w(d(e), n === "start", r);
	return i && (a = a.map((e) => e + "-" + i), t && (a = a.concat(a.map(y)))), a;
}
function E(e) {
	let t = d(e);
	return c[t] + e.slice(t.length);
}
function D(e) {
	return {
		top: 0,
		right: 0,
		bottom: 0,
		left: 0,
		...e
	};
}
function O(e) {
	return typeof e == "number" ? {
		top: e,
		right: e,
		bottom: e,
		left: e
	} : D(e);
}
function k(e) {
	let { x: t, y: n, width: r, height: i } = e;
	return {
		width: r,
		height: i,
		top: n,
		left: t,
		right: t + r,
		bottom: n + i,
		x: t,
		y: n
	};
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js
function A(e, t, n) {
	return Math.floor(e / t) !== n;
}
function j(e, t) {
	return t < 0 || t >= e.length;
}
function M(e, t) {
	return P(e.current, { disabledIndices: t });
}
function N(e, t) {
	return P(e.current, {
		decrement: !0,
		startingIndex: e.current.length,
		disabledIndices: t
	});
}
function P(e, { startingIndex: t = -1, decrement: n = !1, disabledIndices: r, amount: i = 1 } = {}) {
	let a = t;
	do
		a += n ? -i : i;
	while (a >= 0 && a <= e.length - 1 && z(e, a, r));
	return a;
}
function F(e, { event: n, orientation: r, loopFocus: i, onLoop: a, rtl: s, cols: c, disabledIndices: l, minIndex: u, maxIndex: d, prevIndex: f, stopEvent: p = !1 }) {
	let m = f, h;
	if (n.key === "ArrowUp" ? h = "up" : n.key === "ArrowDown" && (h = "down"), h) {
		let r = [], s = [], g = !1, _ = 0;
		{
			let t = null, n = -1;
			e.forEach((e, i) => {
				if (e == null) return;
				_ += 1;
				let a = e.closest("[role=\"row\"]");
				a && (g = !0), (a !== t || n === -1) && (t = a, n += 1, r[n] = []), r[n].push(i), s[i] = n;
			});
		}
		let v = !1, y = 0;
		if (g) for (let e of r) {
			let t = e.length;
			t > y && (y = t), t !== c && (v = !0);
		}
		let b = v && _ < e.length, x = y || c, S = (t) => {
			if (!v || f === -1) return;
			let o = s[f];
			if (o == null) return;
			let c = r[o].indexOf(f), u = t === "up" ? -1 : 1;
			for (let t = o + u, d = 0; d < r.length; d += 1, t += u) {
				if (t < 0 || t >= r.length) {
					if (!i || b) return;
					if (t = t < 0 ? r.length - 1 : 0, a) {
						let e = Math.min(c, r[t].length - 1);
						t = s[a(n, f, r[t][e] ?? r[t][0])] ?? t;
					}
				}
				let o = r[t];
				for (let t = Math.min(c, o.length - 1); t >= 0; --t) {
					let n = o[t];
					if (!z(e, n, l)) return n;
				}
			}
		}, C = (t) => {
			if (!b || f === -1) return;
			let n = f % x, r = t === "up" ? -x : x, a = d - d % x, s = o(d / x) + 1;
			for (let t = f - n + r, o = 0; o < s; o += 1, t += r) {
				if (t < 0 || t > d) {
					if (!i) return;
					t = t < 0 ? a : 0;
				}
				let r = Math.min(t + x - 1, d);
				for (let i = Math.min(t + n, r); i >= t; --i) if (!z(e, i, l)) return i;
			}
		};
		p && t(n);
		let w = S(h) ?? C(h);
		if (w !== void 0) m = w;
		else if (f === -1) m = h === "up" ? d : u;
		else if (m = P(e, {
			startingIndex: f,
			amount: x,
			decrement: h === "up",
			disabledIndices: l
		}), i) {
			if (h === "up" && (f - x < u || m < 0)) {
				let e = f % x, t = d % x, r = d - (t - e);
				m = t === e ? d : t > e ? r : r - x, a && (m = a(n, f, m));
			}
			h === "down" && f + x > d && (m = P(e, {
				startingIndex: f % x - x,
				amount: x,
				disabledIndices: l
			}), a && (m = a(n, f, m)));
		}
		j(e, m) && (m = f);
	}
	if (r === "both") {
		let r = o(f / c);
		n.key === (s ? "ArrowLeft" : "ArrowRight") && (p && t(n), f % c === c - 1 ? i && (m = P(e, {
			startingIndex: f - f % c - 1,
			disabledIndices: l
		}), a && (m = a(n, f, m))) : (m = P(e, {
			startingIndex: f,
			disabledIndices: l
		}), i && A(m, c, r) && (m = P(e, {
			startingIndex: f - f % c - 1,
			disabledIndices: l
		}), a && (m = a(n, f, m)))), A(m, c, r) && (m = f)), n.key === (s ? "ArrowRight" : "ArrowLeft") && (p && t(n), f % c === 0 ? i && (m = P(e, {
			startingIndex: f + (c - f % c),
			decrement: !0,
			disabledIndices: l
		}), a && (m = a(n, f, m))) : (m = P(e, {
			startingIndex: f,
			decrement: !0,
			disabledIndices: l
		}), i && A(m, c, r) && (m = P(e, {
			startingIndex: f + (c - f % c),
			decrement: !0,
			disabledIndices: l
		}), a && (m = a(n, f, m)))), A(m, c, r) && (m = f));
		let u = o(d / c) === r;
		j(e, m) && (i && u ? (m = n.key === (s ? "ArrowRight" : "ArrowLeft") ? d : P(e, {
			startingIndex: f - f % c - 1,
			disabledIndices: l
		}), a && (m = a(n, f, m))) : m = f);
	}
	return m;
}
function I(e, t, n) {
	let r = [], i = 0;
	return e.forEach(({ width: e, height: a }, o) => {
		if (e > t && process.env.NODE_ENV !== "production") throw Error(`[Floating UI]: Invalid grid - item width at index ${o} is greater than grid columns`);
		let s = !1;
		for (n && (i = 0); !s;) {
			let n = [];
			for (let r = 0; r < e; r += 1) for (let e = 0; e < a; e += 1) n.push(i + r + e * t);
			i % t + e <= t && n.every((e) => r[e] == null) ? (n.forEach((e) => {
				r[e] = o;
			}), s = !0) : i += 1;
		}
	}), [...r];
}
function L(e, t, n, r, i) {
	if (e === -1) return -1;
	let a = n.indexOf(e), o = t[e];
	switch (i) {
		case "tl": return a;
		case "tr": return o ? a + o.width - 1 : a;
		case "bl": return o ? a + (o.height - 1) * r : a;
		case "br": return n.lastIndexOf(e);
		default: return -1;
	}
}
function R(e, t) {
	return t.flatMap((t, n) => e.includes(t) ? [n] : []);
}
function z(e, t, n) {
	if (typeof n == "function" ? n(t) : n?.includes(t) ?? !1) return !0;
	let r = e[t];
	return r ? V(r) ? !n && (r.hasAttribute("disabled") || r.getAttribute("aria-disabled") === "true") : !0 : !1;
}
function B(e) {
	return e.visibility === "hidden" || e.visibility === "collapse";
}
function V(t, n = t ? e(t) : null) {
	return !t || !t.isConnected || !n || B(n) ? !1 : typeof t.checkVisibility == "function" ? t.checkVisibility() : n.display !== "none" && n.display !== "contents";
}
//#endregion
export { n as A, O as C, r as D, i as E, k as O, E as S, h as T, _, F as a, p as b, V as c, l as d, s as f, g, f as h, R as i, a as k, j as l, o as m, P as n, N as o, u as p, L as r, M as s, I as t, z as u, m as v, d as w, T as x, v as y };
