import React, { useContext } from 'react';
import classnames from 'classnames';
import { InternalLink } from '../../../InternalLink';
import { getDataTenantEntityUri, getHistoryAppearanceBySpecialAttributeValue, getHistoryAttributeClassName } from '@reltio/mdm-sdk';
import { useMdmEntity, useMdmUiPath } from '../../../contexts/MdmModuleContext';
import { EntityContext } from '../../../contexts/EntityContext';
import { UrlGeneratorsContext } from '../../../contexts/UrlGeneratorsContext';
import { HistoryDiffContext } from '../../../contexts/HistoryAppearanceContext';
import { useStyles } from './styles';
export var Tag = function (_a) {
    var value = _a.value;
    var styles = useStyles();
    var ownEntity = useContext(EntityContext);
    var appearance = useContext(HistoryDiffContext).appearance;
    var generateTagUrl = useContext(UrlGeneratorsContext).generateTagUrl;
    var currentEntity = useMdmEntity();
    var uiPath = useMdmUiPath();
    var attributeAppearance = getHistoryAppearanceBySpecialAttributeValue('tags', value, appearance);
    var historyClassName = getHistoryAttributeClassName(attributeAppearance);
    var entity = ownEntity || currentEntity;
    return (React.createElement(InternalLink, { className: classnames(styles.attributeValue, styles[historyClassName]), href: generateTagUrl({
            uiPath: uiPath,
            tag: value,
            entityUri: entity.dataTenant ? getDataTenantEntityUri(entity) : entity.uri
        }) }, value));
};
