import React from 'react';
import { findSourceSystemByUri, getAbsoluteImageUrl, getSourceSystemLabel } from '@reltio/mdm-sdk';
import { AvatarWithFallback } from '../AvatarWithFallback';
import { useMdmMetadata } from '../contexts/MdmModuleContext';
var SOURCE_URL = 'https://s3.amazonaws.com/reltio.images/api';
export var SourceIcon = function (_a) {
    var sourceType = _a.sourceType, className = _a.className, classes = _a.classes;
    var metadata = useMdmMetadata();
    var _b = findSourceSystemByUri(metadata, sourceType) || {}, uri = _b.uri, icon = _b.icon;
    var avatarText = uri ? getSourceSystemLabel(metadata, uri)[0] : '';
    var sourceIcon = icon ? getAbsoluteImageUrl(SOURCE_URL, icon) : null;
    return (React.createElement(AvatarWithFallback, { className: className, avatarText: avatarText, icon: sourceIcon, variant: "square", rootClasses: classes }));
};
