"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMenu = void 0;
const react_1 = require("react");
function useMenu(ref = null) {
    const [open, setOpen] = (0, react_1.useState)(false);
    const anchorRef = (0, react_1.useRef)(null);
    (0, react_1.useEffect)(() => {
        if (!ref) {
            return;
        }
        if (typeof ref === 'function') {
            ref(anchorRef.current);
        }
        else {
            ref.current = anchorRef.current;
        }
    }, [ref]);
    const handleCloseMenu = () => setOpen(false);
    const handleOpenMenu = () => setOpen(true);
    return { open, anchorRef, handleCloseMenu, handleOpenMenu };
}
exports.useMenu = useMenu;
