"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityChangedSelectors = void 0;
var react_1 = __importDefault(require("react"));
var ramda_1 = require("ramda");
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var AttributeSelector_1 = require("../../../../../AttributeSelector");
var EntityTypesSelector_1 = require("../EntityTypesSelector");
var SourceSelector_1 = require("../SourceSelector");
var MdmModuleContext_1 = require("../../../../../contexts/MdmModuleContext");
var styles_1 = require("../../styles");
var EntityChangedSelectors = function (_a) {
    var filter = _a.filter, entityType = _a.entityType, onPropChange = _a.onPropChange;
    var styles = (0, styles_1.useStyles)();
    var _b = filter || {}, _c = _b.attributes, attributes = _c === void 0 ? [] : _c, _d = _b.sources, sources = _d === void 0 ? [] : _d, _e = _b.entityTypes, entityTypes = _e === void 0 ? [] : _e;
    var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
    var closestEntityTypeAncestor = (0, mdm_sdk_1.findClosestCommonAncestor)(metadata, (0, ramda_1.map)((0, ramda_1.prop)('uri'), entityTypes));
    var attributesEntityType = entityType || (0, mdm_sdk_1.getEntityType)(metadata, closestEntityTypeAncestor);
    return (react_1.default.createElement("div", { className: styles.selectorsGroup },
        !entityType && (react_1.default.createElement(EntityTypesSelector_1.EntityTypesSelector, { entityTypes: metadata.entityTypes, selectedEntityTypes: entityTypes, onChange: onPropChange('entityTypes') })),
        react_1.default.createElement(AttributeSelector_1.AttributeSelector, { selectedAttributes: attributes, entityType: attributesEntityType, onChange: onPropChange('attributes'), className: styles.selectorWrapper, disableUnderline: true }),
        react_1.default.createElement(SourceSelector_1.SourceSelector, { selectedSources: sources, onChange: onPropChange('sources') })));
};
exports.EntityChangedSelectors = EntityChangedSelectors;
