import { useMemo } from 'react';
import { flatten } from 'ramda';
import i18n from 'ui-i18n';
import { mergeChanges } from '../helpers/merge';
import { useMdmMetadata } from '../../../contexts/MdmModuleContext';
export var useChangesList = function (_a) {
    var changes = _a.changes, entityInfo = _a.entityInfo, relationsInfo = _a.relationsInfo;
    var metadata = useMdmMetadata();
    var _b = useMemo(function () { return mergeChanges(metadata, changes, entityInfo, relationsInfo); }, [metadata, changes, entityInfo, relationsInfo]), mergedEntityChanges = _b[0], mergedRelationsChanges = _b[1];
    var changesList = useMemo(function () {
        var relationshipTitle = { label: i18n.text('Relationships') };
        return mergedRelationsChanges.length > 0
            ? flatten([mergedEntityChanges, relationshipTitle, mergedRelationsChanges])
            : mergedEntityChanges;
    }, [mergedEntityChanges, mergedRelationsChanges]);
    return changesList;
};
