"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SourceIcon = void 0;
var react_1 = __importDefault(require("react"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var AvatarWithFallback_1 = require("../AvatarWithFallback");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var SOURCE_URL = 'https://s3.amazonaws.com/reltio.images/api';
var SourceIcon = function (_a) {
    var sourceType = _a.sourceType, className = _a.className, classes = _a.classes;
    var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
    var _b = (0, mdm_sdk_1.findSourceSystemByUri)(metadata, sourceType) || {}, uri = _b.uri, icon = _b.icon;
    var avatarText = uri ? (0, mdm_sdk_1.getSourceSystemLabel)(metadata, uri)[0] : '';
    var sourceIcon = icon ? (0, mdm_sdk_1.getAbsoluteImageUrl)(SOURCE_URL, icon) : null;
    return (react_1.default.createElement(AvatarWithFallback_1.AvatarWithFallback, { className: className, avatarText: avatarText, icon: sourceIcon, variant: "square", rootClasses: classes }));
};
exports.SourceIcon = SourceIcon;
