"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSelectableCurrencies = void 0;
const react_1 = require("react");
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
const state_1 = require("@ledgerhq/cryptoassets/state");
const useSelectableCurrencies = ({ allCurrencies, }) => {
    const [currencies, setCurrencies] = (0, react_1.useState)([]);
    (0, react_1.useEffect)(() => {
        const loadCurrencies = async () => {
            const results = await Promise.all(allCurrencies.map(async (id) => {
                // Try token first, then crypto currency
                const token = await (0, state_1.getCryptoAssetsStore)().findTokenById(id);
                if (token)
                    return token;
                const crypto = (0, cryptoassets_1.findCryptoCurrencyById)(id);
                return crypto;
            }));
            const validCurrencies = results.filter(Boolean);
            setCurrencies(validCurrencies);
        };
        loadCurrencies();
    }, [allCurrencies]);
    return currencies;
};
exports.useSelectableCurrencies = useSelectableCurrencies;
//# sourceMappingURL=useSelectableCurrencies.js.map