import { RouterProvider } from "@tanstack/react-router";
import { router } from "@/router";
import { SseProvider } from "@/lib/sse-context";
import { useAuth } from "@/lib/auth-context";

function App() {
  const auth = useAuth();

  if (auth.isPending) {
    return (
      <div className="flex min-h-screen items-center justify-center">
        <div className="size-8 animate-spin rounded-full border-4 border-muted border-t-primary" />
      </div>
    );
  }

  return (
    <SseProvider>
      <RouterProvider router={router} context={{ auth }} />
    </SseProvider>
  );
}

export default App;
