import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef, useContext } from 'react';
import { Collapse } from '../Collapse';
import { DashboardSidebarButton } from '../DashboardSidebarButton';
import { DashboardSidebarContext } from '../DashboardSidebarProvider';
import { useLogic } from './useLogic';
export const DashboardMenuSidebarButton = forwardRef((props, ref) => {
    const { collapsedIn, isPopupOpen, setIsPopupOpen } = useContext(DashboardSidebarContext);
    const { handleTogglePopover, popoverAnchorRef } = useLogic({
        isPopupOpen,
        setIsPopupOpen,
        ref,
    });
    const { children, popover, ...buttonProps } = props;
    return (_jsxs(_Fragment, { children: [_jsx(DashboardSidebarButton, { ref: popoverAnchorRef, ...buttonProps, onClick: handleTogglePopover, selected: isPopupOpen, children: _jsx(Collapse, { orientation: "horizontal", in: collapsedIn, children: children }) }), popover] }));
});
