import { Toaster } from "@/components/ui/toaster";
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, Navigate } from "react-router-dom";
import { ThemeProvider } from "next-themes";
import Index from "./pages/Index";
import NotFound from "./pages/NotFound";
import Redirect from "./pages/Redirect";
import { GlobalFunctions } from "./GlobalFunctions";
import React from "react";
import IntelligenceIAApp from "./modules/intelligence-ia/App";

const queryClient = new QueryClient();

const App = () => (
  <QueryClientProvider client={queryClient}>
    <ThemeProvider
      attribute="class"
      defaultTheme="light"
      themes={["light", "dark"]}
      enableSystem={false}
      storageKey="hgtx-codex-theme"
      enableColorScheme
    >
      <TooltipProvider>
        <Toaster />
        <Sonner />
        <BrowserRouter>
          <Routes>
            <Route
              path="/redir/:gsikey"
              element={<Redirect />}
            />

            {/* Módulo Intelligence IA como subpath*/}
            <Route path="/intelligence-ia/*" element={<IntelligenceIAApp />} />

            <Route path="/*" element={<Index />} />
            
            <Route path="*" element={<NotFound />} />
            <Route path="/404" element={<NotFound />} />
          </Routes>
        </BrowserRouter>
      </TooltipProvider>
    </ThemeProvider>
  </QueryClientProvider>
);

export default App;


const HGTXLogin = () =>{

  React.useEffect(() => {
    window.location.replace(import.meta.env.VITE_BASE_URL_HGTX_CORE);
  });

  return(<></>);
}