//#region src/internal/utils/focus.ts
function e(e) {
	return e.matches([
		"a[href]",
		"area[href]",
		"input",
		"button",
		"select",
		"textarea",
		"iframe",
		"object",
		"embed",
		"*[tabindex]",
		"*[contenteditable=true]",
		"[role=button]"
	].join(",")) && e.matches(":not([disabled], [inert])") && !e.closest("[inert]") && !e.closest("[popover]")?.matches(":not(:popover-open)");
}
function t(e) {
	return e.matches([
		"a[href]",
		"button:not([disabled])",
		"input[type=checkbox]",
		"input[type=radio]",
		"object",
		"embed",
		"*[tabindex]",
		"[role=button]:not([disabled])"
	].join(","));
}
function n(e = globalThis.document) {
	return e.activeElement && e.activeElement.shadowRoot ? n(e.activeElement.shadowRoot) ?? e.activeElement : e.activeElement;
}
function r(t) {
	t && !e(t) ? (t.setAttribute("tabindex", "-1"), t.focus(), t.addEventListener("blur", () => t.removeAttribute("tabindex"), { once: !0 })) : t?.focus();
}
function i(e) {
	setTimeout(() => r(e));
}
function a(e, t) {
	e.forEach((e) => e.tabIndex = -1), t.tabIndex = 0;
}
function o(e) {
	e.forEach((e) => e.tabIndex = -1), e[0] && (e[0].tabIndex = 0);
}
function s(e, t) {
	let n = (e) => e.code === "Space" || e.code === "ArrowUp" || e.code === "ArrowDown";
	e.addEventListener("pointerdown", (e) => {
		e.preventDefault();
	}), e.addEventListener("click", (n) => {
		n.preventDefault(), e.disabled || t(n);
	}), e.addEventListener("keyup", (r) => {
		n(r) && !e.disabled && t(r);
	}), e.addEventListener("keydown", (t) => {
		n(t) && !e.disabled && t.preventDefault();
	});
}
//#endregion
export { r as focusElement, i as focusElementTimeout, n as getActiveElement, o as initializeKeyListItems, e as isFocusable, t as isSimpleFocusable, s as onListboxActivate, a as setActiveKeyListItem };

//# sourceMappingURL=focus.js.map