const prefetched = new Set<string>()

/**
 * Prefetch a lazy-loaded route chunk on hover/focus for perceived instant navigation.
 * Call with the same import function used in React.lazy().
 */
export function prefetchRoute(importFn: () => Promise<unknown>) {
  const key = importFn.toString()
  if (prefetched.has(key)) return
  prefetched.add(key)
  importFn()
}
