"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NewPopover = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const BottomDrawer_1 = require("../BottomDrawer");
const classNames_1 = require("../utils/classNames");
const cva_1 = require("../utils/cva");
const constants_1 = require("./constants");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const animatedWrapperCva = (0, cva_1.cva)(constants_1.popoverClassnames.animatedWrapper, {
    variants: {
        isOpen: {
            true: constants_1.popoverClassnames.animatedWrapperOpen,
        },
    },
});
const NewPopover = ({ children, onClose, isOpen, title, className, style, placement = 'bottom', anchorEl, disablePortal, disableAutoFocus, }) => {
    const { isMobile, isOpened, shouldRender, handleAnimationEnd, handleClose, setContainerRef, } = (0, useLogic_1.useLogic)({ isOpen, anchorEl, onClose, disableAutoFocus });
    if (isMobile) {
        return ((0, jsx_runtime_1.jsx)(BottomDrawer_1.BottomDrawer, { title: title, onClose: handleClose, open: isOpened, className: className, style: style, ModalProps: {
                disableAutoFocus,
            }, children: children }));
    }
    return ((0, jsx_runtime_1.jsx)(styles_1.StyledMuiPopper, { className: constants_1.popoverClassnames.root, open: shouldRender, placement: placement, anchorEl: anchorEl, disablePortal: disablePortal, children: (0, jsx_runtime_1.jsx)(styles_1.AnimatedWrapper, { className: (0, classNames_1.classNames)(className, animatedWrapperCva({ isOpen: isOpened })), style: style, onAnimationEnd: handleAnimationEnd, children: (0, jsx_runtime_1.jsx)(styles_1.InnerContainer, { ref: setContainerRef, tabIndex: -1, className: constants_1.popoverClassnames.innerContainer, children: children }) }) }));
};
exports.NewPopover = NewPopover;
