"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMoreAttrTypes = void 0;
var ramda_1 = require("ramda");
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var getSource = function (attrType, entity) {
    var _a = entity.attributes, attributes = _a === void 0 ? {} : _a, _b = entity.analyticsAttributes, analyticsAttributes = _b === void 0 ? {} : _b;
    return (0, ramda_1.cond)([
        [mdm_sdk_1.isSpecialAttribute, (0, ramda_1.always)(entity)],
        [(0, ramda_1.both)(mdm_sdk_1.isAnalyticAttribute, (0, ramda_1.always)(analyticsAttributes)), (0, ramda_1.always)(analyticsAttributes)],
        [ramda_1.T, (0, ramda_1.always)(attributes)]
    ])(attrType);
};
var getNameProp = function (attrType) {
    return (0, mdm_sdk_1.isSpecialAttribute)(attrType) ? 'uri' : 'name';
};
var getMoreAttrTypes = function (attrTypes, entity, showEmptyEditors, hasDeletionsMap) {
    return attrTypes.filter(function (attrType) {
        var source = getSource(attrType, entity);
        var nameProp = getNameProp(attrType);
        return !((attrType.singleValue || (0, mdm_sdk_1.isRoleAttrType)(attrType) || (0, mdm_sdk_1.isTagAttrType)(attrType)) &&
            ((0, ramda_1.has)(attrType[nameProp])(source) || (showEmptyEditors && !(hasDeletionsMap === null || hasDeletionsMap === void 0 ? void 0 : hasDeletionsMap[attrType.uri]))));
    });
};
exports.getMoreAttrTypes = getMoreAttrTypes;
