"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createUseRightBalanceNetwork = void 0;
const getBalanceAndFiatValueByAssets_1 = require("../utils/getBalanceAndFiatValueByAssets");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }) {
    return function useRightBalanceNetwork({ networks }) {
        const { flattenedAccounts, state, counterValueCurrency } = useBalanceDeps();
        const networkBalanceData = (0, getBalanceAndFiatValueByAssets_1.getBalanceAndFiatValueByAssets)(flattenedAccounts, networks, state, counterValueCurrency);
        const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
        return networks.map(network => {
            const currency = network.type === "TokenCurrency" ? network.parentCurrency : network;
            const balanceData = balanceMap.get(network.id) || {
                currency,
                balance: new bignumber_js_1.default(0),
                fiatValue: 0,
            };
            return {
                rightElement: balanceItem(balanceData),
                balanceData,
            };
        });
    };
}
exports.createUseRightBalanceNetwork = createUseRightBalanceNetwork;
//# sourceMappingURL=useRightBalanceNetwork.js.map