"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttributeTitle = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var classnames_1 = __importDefault(require("classnames"));
var ramda_1 = require("ramda");
var ArrowDropDown_1 = __importDefault(require("@mui/icons-material/ArrowDropDown"));
var ExpandedValueTooltip_1 = require("../../../ExpandedValueTooltip");
var SmallIconButton_1 = require("../../../SmallIconButton");
var AttributeTitle_module_css_1 = __importDefault(require("./AttributeTitle.module.css"));
var defaultGetLabel = (0, ramda_1.either)((0, ramda_1.prop)('title'), (0, ramda_1.prop)('fieldName'));
var AttributeTitle = function (_a) {
    var _b, _c, _d;
    var value = _a.value, _e = _a.getLabel, getLabel = _e === void 0 ? defaultGetLabel : _e, onSelectAttributeClick = _a.onSelectAttributeClick, _f = _a.disabled, disabled = _f === void 0 ? false : _f;
    var label = value && getLabel(value);
    return (react_1.default.createElement("div", { onClick: disabled ? undefined : onSelectAttributeClick, className: (0, classnames_1.default)(AttributeTitle_module_css_1.default.attribute, (_b = {},
            _b[AttributeTitle_module_css_1.default.attributeWithValue] = !!label,
            _b), (_c = {}, _c[AttributeTitle_module_css_1.default.disabled] = disabled, _c)) },
        react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: label },
            react_1.default.createElement("div", { className: (0, classnames_1.default)(AttributeTitle_module_css_1.default.name, (_d = {}, _d[AttributeTitle_module_css_1.default.disabled] = disabled, _d)) }, label || react_1.default.createElement("span", { className: AttributeTitle_module_css_1.default.noSelect }, ui_i18n_1.default.text('Select attribute')))),
        react_1.default.createElement(SmallIconButton_1.SmallIconButton, { size: 'M', icon: ArrowDropDown_1.default, disabled: disabled })));
};
exports.AttributeTitle = AttributeTitle;
