"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityTypeBadge = void 0;
var react_1 = __importDefault(require("react"));
var classnames_1 = __importDefault(require("classnames"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var Typography_1 = __importDefault(require("@mui/material/Typography"));
var ExpandedValueTooltip_1 = require("../ExpandedValueTooltip");
var constants_1 = require("../constants");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var styles_1 = require("./styles");
var EntityTypeBadge = function (_a) {
    var entity = _a.entity, className = _a.className, _b = _a.size, size = _b === void 0 ? 'small' : _b;
    var styles = (0, styles_1.useStyles)();
    var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
    var entityType = (0, mdm_sdk_1.getEntityType)(metadata, entity.type);
    var color = entityType ? (0, mdm_sdk_1.getPropWithInheritance)(metadata, entityType, 'typeColor') : null;
    var entityTypeColor = color || constants_1.theme.palette.primary.main;
    var entityTypeLabel = (0, mdm_sdk_1.getEntityTypeLabel)(metadata, entity);
    return (react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: entityTypeLabel, placement: "top" },
        react_1.default.createElement(Typography_1.default, { style: {
                backgroundColor: entityTypeColor,
                color: mdm_sdk_1.utils.Colors.getColor(entityTypeColor) ? '#FFFFFF' : '#212121'
            }, className: (0, classnames_1.default)(styles["entityType-".concat(size)], styles['entityType-overflow'], className), component: "div" }, entityTypeLabel)));
};
exports.EntityTypeBadge = EntityTypeBadge;
