"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLargeMoverChartData = 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 useLargeMoverChartData = ({ ids, counterCurrency, range, }) => {
    const chartQueries = (0, react_query_1.useQueries)({
        queries: ids.map(id => ({
            queryKey: [queryKeys_1.QUERY_KEY.CurrencyChartData, id, counterCurrency, range],
            queryFn: () => (0, api_1.fetchCurrencyChartData)({ id, counterCurrency, range }),
            refetchInterval: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
            staleTime: timers_1.REFETCH_TIME_ONE_MINUTE * timers_1.BASIC_REFETCH,
        })),
    });
    const loadingChart = chartQueries.some(query => query.isLoading);
    const errorChart = chartQueries.every(query => query.isError);
    const chartDataArray = ids.map((id, index) => ({
        idChartData: id,
        chartData: chartQueries[index]?.data,
        isLoading: chartQueries[index]?.isLoading || false,
        isError: chartQueries[index]?.isError || false,
    }));
    return { chartDataArray, loadingChart, errorChart };
};
exports.useLargeMoverChartData = useLargeMoverChartData;
//# sourceMappingURL=useLargeMoverChartData.js.map