"use client";
import { createEventHandler } from "../../../core/utils/create-event-handler/create-event-handler.mjs";
import { useProps } from "../../../core/MantineProvider/use-props/use-props.mjs";
import { factory } from "../../../core/factory/factory.mjs";
import { Popover } from "../../Popover/Popover.mjs";
import { useMenuContext } from "../Menu.context.mjs";
import { SubMenuContext } from "../MenuSub/MenuSub.context.mjs";
import Menu_module_default from "../Menu.module.mjs";
import { useMenuTypeAhead } from "../use-menu-type-ahead.mjs";
import { use, useRef } from "react";
import { useMergedRef } from "@mantine/hooks";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Menu/MenuSubDropdown/MenuSubDropdown.tsx
const MenuSubDropdown = factory((props) => {
	const { classNames, className, style, styles, vars, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, onKeyDown, children, ref, ...others } = useProps("MenuSubDropdown", null, props);
	const wrapperRef = useRef(null);
	const ctx = useMenuContext();
	const subCtx = use(SubMenuContext);
	const typeAhead = useMenuTypeAhead({
		enabled: !ctx.hasSearch,
		opened: subCtx?.opened ?? false,
		getDropdown: () => wrapperRef.current
	});
	const handleKeyDown = createEventHandler(onKeyDown, (event) => {
		typeAhead(event);
		if (!event.ctrlKey && !event.metaKey && !event.altKey && event.key.length === 1 && event.key !== " ") event.stopPropagation();
	});
	const floatingProps = subCtx?.getFloatingProps({
		onMouseEnter,
		onMouseLeave,
		onPointerEnter,
		onPointerLeave
	});
	return /* @__PURE__ */ jsx(Popover.Dropdown, {
		...others,
		...floatingProps,
		role: "menu",
		"aria-orientation": "vertical",
		ref: useMergedRef(ref, wrapperRef, subCtx?.setFloating),
		...ctx.getStyles("dropdown", {
			className,
			style,
			styles,
			classNames,
			withStaticClass: false
		}),
		tabIndex: -1,
		"data-menu-dropdown": true,
		onKeyDown: handleKeyDown,
		children
	});
});
MenuSubDropdown.classes = Menu_module_default;
MenuSubDropdown.displayName = "@mantine/core/MenuSubDropdown";
//#endregion
export { MenuSubDropdown };

//# sourceMappingURL=MenuSubDropdown.mjs.map