import { jsx as _jsx } from "react/jsx-runtime";
import { BottomDrawer } from '../../BottomDrawer';
import { ClickAwayListener } from '../../ClickAwayListener';
import { usePopoverAnimation } from '../../usePopoverAnimation';
import { useViewportType } from '../../useViewportType';
import { datePickerClassnames } from '../constants';
import { AnimatedWrapper, InnerContainer, StyledPopper } from './styles';
export const DatePickerPopover = ({ children, onMouseEnter, onMouseLeave, onClose, anchorEl, title, open, ...props }) => {
    const { isMobile } = useViewportType();
    const { shouldRender, handleAnimationEnd } = usePopoverAnimation(open);
    if (isMobile) {
        return (_jsx(BottomDrawer, { className: datePickerClassnames.popover, title: title, open: open, onClose: onClose, 
            // Отключает простановку фокуса в инпут при закрытии Drawer
            disableRestoreFocus: true, children: children }));
    }
    return (_jsx(StyledPopper, { className: datePickerClassnames.popover, open: shouldRender, anchorEl: anchorEl, ...props, children: _jsx(AnimatedWrapper, { "$isOpen": open, onAnimationEnd: handleAnimationEnd, children: _jsx(ClickAwayListener, { onClickAway: onClose, children: _jsx(InnerContainer, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: datePickerClassnames.popoverContainer, children: children }) }) }) }));
};
