"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatePickerPopover = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const BottomDrawer_1 = require("../../BottomDrawer");
const ClickAwayListener_1 = require("../../ClickAwayListener");
const usePopoverAnimation_1 = require("../../usePopoverAnimation");
const useViewportType_1 = require("../../useViewportType");
const constants_1 = require("../constants");
const styles_1 = require("./styles");
const DatePickerPopover = ({ children, onMouseEnter, onMouseLeave, onClose, anchorEl, title, open, ...props }) => {
    const { isMobile } = (0, useViewportType_1.useViewportType)();
    const { shouldRender, handleAnimationEnd } = (0, usePopoverAnimation_1.usePopoverAnimation)(open);
    if (isMobile) {
        return ((0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { className: constants_1.datePickerClassnames.popover, title: title, open: open, onClose: onClose, 
            // Отключает простановку фокуса в инпут при закрытии Drawer
            disableRestoreFocus: true, children: children }));
    }
    return ((0, jsx_runtime_1.jsx)(styles_1.StyledPopper, { className: constants_1.datePickerClassnames.popover, open: shouldRender, anchorEl: anchorEl, ...props, children: (0, jsx_runtime_1.jsx)(styles_1.AnimatedWrapper, { "$isOpen": open, onAnimationEnd: handleAnimationEnd, children: (0, jsx_runtime_1.jsx)(ClickAwayListener_1.ClickAwayListener, { onClickAway: onClose, children: (0, jsx_runtime_1.jsx)(styles_1.InnerContainer, { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: constants_1.datePickerClassnames.popoverContainer, children: children }) }) }) }));
};
exports.DatePickerPopover = DatePickerPopover;
