"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProfileBand = void 0;
var react_1 = __importStar(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var classnames_1 = __importDefault(require("classnames"));
var ramda_1 = require("ramda");
var Typography_1 = __importDefault(require("@mui/material/Typography"));
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var EntityAvatar_1 = require("../EntityAvatar");
var EntityTypeBadge_1 = require("../EntityTypeBadge");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var ProfileBand_module_css_1 = __importDefault(require("./ProfileBand.module.css"));
var ProfileBand = function (_a) {
    var _b;
    var entity = _a.entity, children = _a.children, className = _a.className, classes = _a.classes, _c = _a.renderLabel, renderLabel = _c === void 0 ? ramda_1.identity : _c;
    var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
    var showEntityId = (0, MdmModuleContext_1.useMdmShowEntityId)();
    var handleCopyEntityIdToClipboard = (0, react_1.useCallback)(function () {
        navigator.clipboard.writeText((0, mdm_sdk_1.getEntityId)(entity));
    }, [entity]);
    if ((0, ramda_1.isNil)(entity)) {
        return null;
    }
    var label = (0, mdm_sdk_1.getLabel)(entity.label);
    var secondaryLabel = entity.secondaryLabel;
    var businessCardText = (0, mdm_sdk_1.getBusinessCardAttributesText)(metadata, entity);
    var isActive = (0, mdm_sdk_1.isActiveObject)(entity);
    var entityUri = entity.uri;
    var entityId = (0, mdm_sdk_1.getEntityId)(entity);
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)(ProfileBand_module_css_1.default.profileBandWrapper, className), "data-reltio-id": "reltio-profile-band" },
        react_1.default.createElement("div", { className: (0, classnames_1.default)(ProfileBand_module_css_1.default.profileBand, classes === null || classes === void 0 ? void 0 : classes.profileBand, (_b = {},
                _b[ProfileBand_module_css_1.default.inactive] = !isActive,
                _b)), "data-entity-uri": entityUri },
            react_1.default.createElement(EntityAvatar_1.EntityAvatar, { key: entity.uri, entity: entity, avatarClassName: ProfileBand_module_css_1.default.profileIcon, imageClassName: ProfileBand_module_css_1.default.imageProfileIcon }),
            react_1.default.createElement("div", { className: ProfileBand_module_css_1.default.profileInfo },
                react_1.default.createElement("div", null,
                    react_1.default.createElement(Typography_1.default, { variant: "h6", className: ProfileBand_module_css_1.default.label }, renderLabel(label)),
                    secondaryLabel && (react_1.default.createElement(Typography_1.default, { variant: "subtitle2", className: ProfileBand_module_css_1.default.secondaryLabel }, secondaryLabel)),
                    businessCardText && (react_1.default.createElement(Typography_1.default, { variant: "subtitle1", className: ProfileBand_module_css_1.default.businessCard }, businessCardText))),
                react_1.default.createElement("div", { className: ProfileBand_module_css_1.default.specialInfo },
                    react_1.default.createElement("div", { className: ProfileBand_module_css_1.default.entityType },
                        react_1.default.createElement(EntityTypeBadge_1.EntityTypeBadge, { entity: entity, size: "medium" }),
                        !(0, mdm_sdk_1.isTempUri)(entityUri) && showEntityId && (react_1.default.createElement(Tooltip_1.default, { title: ui_i18n_1.default.text('Copy to clipboard') },
                            react_1.default.createElement(Typography_1.default, { display: "inline", variant: "body2", className: ProfileBand_module_css_1.default.entityId, onClick: handleCopyEntityIdToClipboard },
                                ui_i18n_1.default.text('Entity ID'),
                                ": ",
                                entityId)))))),
            children && react_1.default.createElement("div", null, children))));
};
exports.ProfileBand = ProfileBand;
