"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PivotingTooltipContent = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var EntityAvatar_1 = require("../../../EntityAvatar");
var EntityUriLink_1 = require("../../../EntityUriLink");
var PivotingUriLink_1 = require("../../../PivotingUriLink");
var usePivotingDataLoader_1 = require("../../../hooks/usePivotingDataLoader");
var styles_1 = require("./styles");
var PivotingTooltipContent = function (_a) {
    var attributeType = _a.attributeType, label = _a.label, entities = _a.entities, generatedValue = _a.generatedValue, onSeeAllClick = _a.onSeeAllClick, total = _a.total;
    var styles = (0, styles_1.useStyles)();
    var shouldShowSeeAllButton = total > usePivotingDataLoader_1.MAX_ENTITIES_PIVOTING_TOOLTIP;
    var hasEntityTypeLabel = Boolean(label);
    return (react_1.default.createElement("div", { className: styles.container },
        react_1.default.createElement("div", { className: styles.header },
            react_1.default.createElement("div", { className: styles.title }, ui_i18n_1.default.text('Pivot profiles')),
            react_1.default.createElement("div", { className: styles.divider }),
            react_1.default.createElement("div", { className: styles.headerCount }, ui_i18n_1.default.number(total, '0,0') + ' ' + (total === 1 ? ui_i18n_1.default.text('item') : ui_i18n_1.default.text('items')))),
        hasEntityTypeLabel && react_1.default.createElement("div", { className: styles.entityTypeLabel }, label),
        react_1.default.createElement("div", { className: styles.body }, entities.map(function (visibleEntity) { return (react_1.default.createElement("div", { key: visibleEntity.uri, className: styles.entityContainer },
            react_1.default.createElement(EntityAvatar_1.EntityAvatar, { entity: visibleEntity, avatarClassName: styles.profileIcon }),
            react_1.default.createElement(EntityUriLink_1.EntityUriLink, { className: styles.entityLabel, value: (0, mdm_sdk_1.getEntityUriForLink)(visibleEntity) }, (0, mdm_sdk_1.getLabel)(visibleEntity.label)))); })),
        shouldShowSeeAllButton && (react_1.default.createElement("div", { className: styles.footer },
            react_1.default.createElement(PivotingUriLink_1.PivotingUriLink, { value: generatedValue, attributeType: attributeType, className: styles.seeAllButton, onClick: onSeeAllClick }, ui_i18n_1.default.text('See all'))))));
};
exports.PivotingTooltipContent = PivotingTooltipContent;
