"use client";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Sheet } from "../sheet/Sheet.js";
const noop = ()=>{
// do nothing
};
/**
 * **Client Component**
 *
 * Implements a `Menu` using the `Sheet` component that probably shouldn't
 * really be used externally.
 *
 * @internal
 * @remarks
 * \@since 5.0.0
 * \@since 6.0.0 Added the `enabled` prop and does not render a custom `Menu`
 * implementation.
 */ export function MenuSheet(props) {
    const { header, footer, children, onClick = noop, overlayProps, enabled, ...remaining } = props;
    const { onRequestClose } = props;
    if (!enabled) {
        return /*#__PURE__*/ _jsx(_Fragment, {
            children: children
        });
    }
    return /*#__PURE__*/ _jsxs(Sheet, {
        ...remaining,
        onClick: (event)=>{
            onClick(event);
            // Prevent closing parent sheet/menus if an element in the header or
            // footer is clicked
            if (!(event.target instanceof HTMLElement) || event.target.closest('.rmd-menu,[role="dialog"]')?.getAttribute("role") === "dialog") {
                event.stopPropagation();
            }
        },
        overlayProps: {
            ...overlayProps,
            onClick: (event)=>{
                overlayProps?.onClick?.(event);
                // prevent closing parent menus if the overlay element is clicked.
                event.stopPropagation();
                onRequestClose();
            }
        },
        children: [
            header,
            children,
            footer
        ]
    });
}

//# sourceMappingURL=MenuSheet.js.map