import React, { useMemo } from 'react';
import { EditModeAttributesList } from '../EditModeAttributesList';
import { useMdmAction, useMdmModifiedEntity } from '../contexts/MdmModuleContext';
var defaultAttributeTypesSelectionStrategy = function (entityType) { return entityType && entityType.attributes; };
export 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 = useMdmAction('addAttributes');
    var removeAttribute = useMdmAction('removeAttribute');
    var modifyAttribute = useMdmAction('modifyAttribute');
    var entity = useMdmModifiedEntity(entityUri);
    var attributeTypes = useMemo(function () { return attributeTypesSelectionStrategy(entityType); }, [attributeTypesSelectionStrategy, entityType]);
    return entity ? (React.createElement(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;
};
