import { audit as e } from "../internal/controllers/audit.controller.js";
import { isSimpleFocusable as t } from "../internal/utils/focus.js";
import { appendRootNodeStyle as n, clickOutsideElementBounds as r, getFlattenedFocusableItems as i } from "../internal/utils/dom.js";
import { useStyles as a } from "../internal/styles/index.js";
import { __decorate as o } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/decorate.js";
import s from "./dropdown-group.global.js";
import { LitElement as c, html as l } from "lit";
import { queryAssignedElements as u } from "lit/decorators/query-assigned-elements.js";
//#region src/dropdown-group/dropdown-group.ts
var d = class extends c {
	static {
		this.styles = a([]);
	}
	static {
		this.metadata = {
			tag: "nve-dropdown-group",
			version: "2.0.2",
			children: ["nve-dropdown"]
		};
	}
	render() {
		return l`<div internal-host><slot @slotchange="${this.#t}"></slot></div>`;
	}
	#e = (e) => this.#n(e);
	connectedCallback() {
		super.connectedCallback(), n(this, s), globalThis.document?.addEventListener("pointerup", this.#e), this.addEventListener("keydown", this.#r), this.addEventListener("open", this.#i), this.addEventListener("close", this.#a);
	}
	disconnectedCallback() {
		super.disconnectedCallback(), globalThis.document?.removeEventListener("pointerup", this.#e), this.removeEventListener("keydown", this.#r), this.removeEventListener("open", this.#i), this.removeEventListener("close", this.#a);
	}
	#t() {
		this.dropdowns.forEach((e) => {
			e.popoverType = "manual";
		});
	}
	#n(e) {
		let t = this.dropdowns.some((e) => e.matches(":popover-open")), n = this.dropdowns.every((t) => r(e, t));
		t && n && this.close();
	}
	#r(e) {
		let n = e.target;
		if (e.code === "Escape" && this.close(), e.code === "ArrowRight") {
			let e = n.getAttribute("popovertarget");
			this.dropdowns.find((t) => t.id === e)?.showPopover();
		}
		e.code === "ArrowLeft" && t(e.target) && n.closest("nve-dropdown")?.hidePopover();
	}
	#i(e) {
		let t = e.target;
		t.localName === "nve-dropdown" && this.dropdowns.find((e) => e === t) && i(t)[0]?.focus();
	}
	#a(e) {
		let t = e.target;
		t.localName === "nve-dropdown" && this.dropdowns.find((e) => e === t) && t._activeTrigger?.focus();
	}
	close() {
		this.querySelectorAll("nve-dropdown").forEach((e) => e.hidePopover());
	}
};
o([u()], d.prototype, "dropdowns", void 0), d = o([e()], d);
//#endregion
export { d as DropdownGroup };

//# sourceMappingURL=dropdown-group.js.map