"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.EntityCreator = void 0;
var react_1 = __importStar(require("react"));
var EditModeAttributesList_1 = require("../EditModeAttributesList");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var defaultAttributeTypesSelectionStrategy = function (entityType) { return entityType && entityType.attributes; };
var EntityCreator = function (_a) {
    var entityUri = _a.entityUri, entityType = _a.entityType, mode = _a.mode, _b = _a.attributeTypesSelectionStrategy, attributeTypesSelectionStrategy = _b === void 0 ? defaultAttributeTypesSelectionStrategy : _b;
    var addAttributes = (0, MdmModuleContext_1.useMdmAction)('addAttributes');
    var removeAttribute = (0, MdmModuleContext_1.useMdmAction)('removeAttribute');
    var modifyAttribute = (0, MdmModuleContext_1.useMdmAction)('modifyAttribute');
    var entity = (0, MdmModuleContext_1.useMdmModifiedEntity)(entityUri);
    var attributeTypes = (0, react_1.useMemo)(function () { return attributeTypesSelectionStrategy(entityType); }, [attributeTypesSelectionStrategy, entityType]);
    return entity ? (react_1.default.createElement(EditModeAttributesList_1.EditModeAttributesList, { key: entity.uri, attrTypes: attributeTypes, entity: entity, showEmptyEditors: true, drawLines: true, parentUri: entity.uri, mode: mode, crosswalks: entity.crosswalks, onAddAttributes: addAttributes, onChangeAttribute: modifyAttribute, onDeleteAttribute: removeAttribute })) : null;
};
exports.EntityCreator = EntityCreator;
