import { useQuery } from '@tanstack/react-query';
import { useMemo } from 'react';
import { apiGet } from './apiClient';
/**
 * Idiomatic TanStack Query wrapper around apiGet.
 */
export function useApiQuery(baseURL, url, config = {}, options) {
    const queryKey = useMemo(() => [baseURL, url, config], [baseURL, url, config]);
    return useQuery(Object.assign({ queryKey, queryFn: () => apiGet(baseURL, url, config) }, options));
}
/**
 * Drop-in replacement for useAxiosGet.
 * Returns the same `[{ data, loading, error }, refetch]` tuple shape.
 */
export function useApiQueryLegacy(baseURL, url, config = {}, isManual, useCache = true) {
    const queryKey = useMemo(() => [baseURL, url, config], [baseURL, url, config]);
    const result = useQuery(Object.assign({ queryKey, queryFn: () => apiGet(baseURL, url, config), enabled: !isManual }, (useCache === false ? { staleTime: 0 } : {})));
    const legacyState = useMemo(() => ({
        data: result.data,
        loading: result.isLoading,
        error: result.error,
    }), [result.data, result.isLoading, result.error]);
    const refetch = () => {
        void result.refetch();
    };
    return [legacyState, refetch];
}
//# sourceMappingURL=useApiQuery.js.map