"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Profile = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Typography_1 = require("../Typography");
const constants_1 = require("./constants");
const MenuList_1 = require("./MenuList");
const ProfileSkeleton_1 = require("./ProfileSkeleton");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const Profile = (props) => {
    const { displayName, annotation, avatar = {}, menu: Menu, menuList, exitButton, isLoading, } = props;
    const { open, anchorRef, handleOpenMenu, handleCloseMenu, hidePersonalDataClassname, } = (0, useLogic_1.useLogic)(props);
    if (isLoading) {
        return (0, jsx_runtime_1.jsx)(ProfileSkeleton_1.ProfileSkeleton, {});
    }
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(styles_1.ProfileRoot, { ref: anchorRef, variant: "text", onClick: handleOpenMenu, className: constants_1.profileClassnames.button, children: [(0, jsx_runtime_1.jsx)(styles_1.StyledAvatar, { ...avatar, className: constants_1.profileClassnames.avatar }), (0, jsx_runtime_1.jsxs)(styles_1.User, { className: constants_1.profileClassnames.user, children: [(0, jsx_runtime_1.jsxs)(styles_1.Credentials, { className: hidePersonalDataClassname, children: [(0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "body1", className: constants_1.profileClassnames.credentials, children: displayName }), (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "textSecondary", className: constants_1.profileClassnames.credentials, children: annotation })] }), (0, jsx_runtime_1.jsx)(styles_1.StyledChevron, { isActive: open })] })] }), Menu ? ((0, jsx_runtime_1.jsx)(Menu, { MenuListProps: { id: constants_1.PROFILE_POPOVER_ID }, open: open, anchorEl: anchorRef.current, onClose: handleCloseMenu, anchorOrigin: {
                    vertical: 'bottom',
                    horizontal: 'right',
                }, transformOrigin: {
                    vertical: 'top',
                    horizontal: 'right',
                }, PaperProps: {
                    style: {
                        maxWidth: 300,
                        minWidth: 200,
                    },
                } })) : ((0, jsx_runtime_1.jsx)(MenuList_1.MenuList, { open: open, anchorEl: anchorRef.current, menuList: menuList, displayName: displayName, annotation: annotation, exitButton: exitButton, onClose: handleCloseMenu, anchorOrigin: {
                    vertical: 'bottom',
                    horizontal: 'right',
                }, transformOrigin: {
                    vertical: 'top',
                    horizontal: 'right',
                } }))] }));
};
exports.Profile = Profile;
