import { QueryClient } from '@tanstack/react-query'

/**
 * Fresh client per island mount — Overview owns exactly one QueryClientProvider.
 * Defaults are conservative; collector queries opt into polling and focus refetches
 * themselves (collector-queries.ts), because the SSE bridge alone cannot be trusted
 * to keep the cache live across suspends and collector restarts.
 */
export function createOverdeckQueryClient(): QueryClient {
  return new QueryClient({
    defaultOptions: {
      queries: {
        staleTime: 30_000,
        refetchOnWindowFocus: false,
        retry: 1,
      },
    },
  })
}
