"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLargeMoverCurrencies = void 0;
const react_query_1 = require("@tanstack/react-query");
const api_1 = require("../api");
const queryKeys_1 = require("../utils/queryKeys");
const timers_1 = require("../utils/timers");
const currencyFormatter_1 = require("../utils/currencyFormatter");
const useLargeMoverCurrencies = ({ ids, counterCurrency, }) => {
    const currencyQueries = (0, react_query_1.useQueries)({
        queries: ids.map(id => ({
            queryKey: [queryKeys_1.QUERY_KEY.CurrencyDataRaw, id, counterCurrency],
            queryFn: () => (0, api_1.fetchCurrency)({ id, counterCurrency }),
            refetchInterval: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
            staleTime: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
            select: (data) => (0, currencyFormatter_1.format)(data),
        })),
    });
    return ids.map((id, index) => ({
        id,
        data: currencyQueries[index]?.data,
        isLoading: currencyQueries[index]?.isLoading || false,
        isError: currencyQueries[index]?.isError || false,
    }));
};
exports.useLargeMoverCurrencies = useLargeMoverCurrencies;
//# sourceMappingURL=useLargeMoverCurrencies.js.map