import React from "react";
import * as icons from "@ledgerhq/crypto-icons-ui/react";
import { inferCryptoCurrencyIcon } from "./currencies/cryptoIcons";
const polyfillMappingCache = new WeakMap();
/**
 * thin wrapper from the crypto-icons lib to the format expected by ledger-live-common
 * @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
 */
function polyfillIconComponent(IconComponent) {
    if (!IconComponent)
        return IconComponent;
    if (polyfillMappingCache.has(IconComponent))
        return polyfillMappingCache.get(IconComponent);
    const PolyfillIconComponent = (props) => props.color === undefined ? (
    // in the previous behavior, we were fallbacking on "currentColor"
    // if you need this behavior, it will be preferrable to explicit set it. as we will drop this polyfill implementation.
    React.createElement(IconComponent, { ...props, color: "currentColor" })) : (React.createElement(IconComponent, { ...props }));
    polyfillMappingCache.set(IconComponent, PolyfillIconComponent);
    return PolyfillIconComponent;
}
/**
 * @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
 */
export function getCryptoCurrencyIcon(currency) {
    return polyfillIconComponent(inferCryptoCurrencyIcon(icons, currency));
}
/**
 * @deprecated prefer using @ledgerhq/crypto-icons-ui directly + mapping provided by @ledgerhq/live-common/currencies/cryptoIcons
 */
export function getTokenCurrencyIcon(token) {
    return polyfillIconComponent(inferCryptoCurrencyIcon(icons, token));
}
//# sourceMappingURL=react.js.map