"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StyledColumnBadgePreview = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const Tag_1 = require("../../../../../components/Tag");
const GeneralConstants_1 = require("../../../../../Utilities/Constants/GeneralConstants");
const AdaptableContext_1 = require("../../../../AdaptableContext");
const Badge_1 = require("../../../../Components/Badge");
const StyledColumnBadgePreview = ({ data }) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const badgeStyle = data.BadgeStyle;
    if (!badgeStyle || badgeStyle.Badges.length === 0) {
        return React.createElement("div", null, "No Badges Defined");
    }
    const value = adaptable.api.columnApi.getColumnDataTypeForColumnId(data.ColumnId) === 'number'
        ? GeneralConstants_1.DEFAULT_INTEGER_DISPLAY_VALUE
        : GeneralConstants_1.DEFAULT_STRING_DISPLAY_VALUE;
    return (React.createElement(rebass_1.Flex, { flexDirection: "column" }, badgeStyle.Badges.map((badge, index) => {
        let ruleString = 'No Rule';
        if (badge.Predicate) {
            ruleString = adaptable.api.predicateApi.predicateToString(badge.Predicate);
        }
        if (badge.Expression) {
            ruleString = badge.Expression.BooleanExpression;
        }
        return (React.createElement(rebass_1.Box, { mb: 1, key: index },
            React.createElement(Badge_1.Badge, { icon: badge.Icon, adaptableStyle: badge.Style, iconPosition: badge.IconPosition }, value),
            React.createElement(Tag_1.Tag, { ml: 2 }, ruleString)));
    })));
};
exports.StyledColumnBadgePreview = StyledColumnBadgePreview;
