"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var styled_components_1 = require("styled-components");
var isPlainObject = require("lodash/isPlainObject");
var keys = require("lodash/keys");
var values = require("lodash/values");
var DeleteButton_1 = require("../DeleteButton");
var Grid_1 = require("../Grid");
var PineTypes_1 = require("../PineTypes");
var ButtonWrapper = styled_components_1.default.button(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  font-size: 13px;\n  min-height: 22px;\n  border: 0;\n  border-radius: 3px;\n  background-color: #e9e9e9;\n  padding: 3px 8px;\n"], ["\n  font-size: 13px;\n  min-height: 22px;\n  border: 0;\n  border-radius: 3px;\n  background-color: #e9e9e9;\n  padding: 3px 8px;\n"])));
var getOperatorText = function (operator, type, schemaEntry) {
    var operatorItem = PineTypes_1.default[type].rules[operator];
    if (isPlainObject(operatorItem) && schemaEntry) {
        var label = operatorItem.getLabel(schemaEntry);
        return label || operator;
    }
    return operator;
};
var kvpFormat = function (object, schema) {
    if (keys(object).length > 1) {
        return object[schema.key] + " : " + object[schema.value];
    }
    return values(object).pop();
};
var FilterDescription = function (props) { return (React.createElement("div", null,
    React.createElement(ButtonWrapper, { onClick: !!props.edit && props.edit },
        React.createElement(Grid_1.Flex, null,
            React.createElement(Grid_1.Box, { mr: 7 },
                props.rule.label || props.rule.name,
                " "),
            props.rule.operator && (React.createElement(Grid_1.Box, { mr: 7 },
                React.createElement("strong", null, getOperatorText(props.rule.operator, props.rule.type, props.schema)))),
            props.rule.type === 'Key Value Pair' ? (React.createElement("em", null, kvpFormat(props.rule.value, props.schema))) : (React.createElement("em", null, props.rule.value)))),
    !!props.delete && (React.createElement(DeleteButton_1.default, { color: props.dark && '#fff', onClick: props.delete })))); };
exports.default = FilterDescription;
var templateObject_1;
