import "./global.css";

import { Toaster } from "@/components/ui/toaster";
import { createRoot } from "react-dom/client";
import { Toaster as Sonner } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Index from "./pages/Index";
import Dashboard from "./pages/Dashboard";
import Member from "./pages/Member";
import MemberSimple from "./pages/MemberSimple";
import MemberBuilder from "./pages/MemberBuilder";
import Prizes from "./pages/Prizes";
import Settings from "./pages/Settings";
import NotFound from "./pages/NotFound";

const queryClient = new QueryClient();

const App = () => {
  // Debug logging for about:blank issues
  console.log('🚀 App component starting...');
  console.log('📍 Current URL:', window.location.href);
  console.log('🔗 Pathname:', window.location.pathname);
  console.log('🌐 Origin:', window.location.origin);

  return (
    <QueryClientProvider client={queryClient}>
      <TooltipProvider>
        <Toaster />
        <Sonner />
        <BrowserRouter>
          <Routes>
            <Route path="/" element={<Index />} />
            <Route path="/dashboard" element={<Dashboard />} />
            <Route path="/member" element={<Member />} />
            <Route path="/member-simple" element={<MemberSimple />} />
            <Route path="/member-builder" element={<MemberBuilder />} />
            <Route path="/prizes" element={<Prizes />} />
            <Route path="/prize" element={<Prizes />} />
            <Route path="/settings" element={<Settings />} />
            {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
            <Route path="*" element={<NotFound />} />
          </Routes>
        </BrowserRouter>
      </TooltipProvider>
    </QueryClientProvider>
  );
};

createRoot(document.getElementById("root")!).render(<App />);
