"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilterChip = void 0;
var react_1 = __importDefault(require("react"));
var Chip_1 = __importDefault(require("@mui/material/Chip"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var ExpandedValueTooltip_1 = require("../../../../ExpandedValueTooltip");
var MdmModuleContext_1 = require("../../../../contexts/MdmModuleContext");
var styles_1 = require("./styles");
var FilterChip = function (_a) {
    var filterOption = _a.filterOption, filterValue = _a.filterValue, onDelete = _a.onDelete, dataTypeDefinition = _a.dataTypeDefinition;
    var styles = (0, styles_1.useStyles)();
    var attributesPresentation = (0, MdmModuleContext_1.useMdmAttributesPresentation)();
    var dateMask = (0, MdmModuleContext_1.useMdmDateMask)();
    var dateTimeMask = (0, MdmModuleContext_1.useMdmDateTimeMask)();
    var canFilterAcceptValues = (0, mdm_sdk_1.checkIfOptionHasValues)(filterOption.value);
    var optionLabel = filterOption.label + (canFilterAcceptValues ? ': ' : '');
    var formatValue = (0, mdm_sdk_1.formatDataTypeValue)({ attributesPresentation: attributesPresentation, dataTypeDefinition: dataTypeDefinition, dateMask: dateMask, dateTimeMask: dateTimeMask });
    var convertedValue = (0, mdm_sdk_1.mapFilterValue)(formatValue, filterValue);
    var filterLabel = canFilterAcceptValues ? (0, mdm_sdk_1.getFilterValueLabel)(filterOption.value, convertedValue) : '';
    return (react_1.default.createElement(Chip_1.default, { label: react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: optionLabel + filterLabel },
            react_1.default.createElement("div", { className: styles['filter-chip__label'] },
                react_1.default.createElement("span", { className: styles['filter-chip__option-label'] }, optionLabel),
                filterLabel)), classes: {
            root: styles['filter-chip'],
            label: styles['filter-chip__label']
        }, onDelete: onDelete }));
};
exports.FilterChip = FilterChip;
