import React from "react"; import { Toaster } from "@/components/ui/toaster"; import { Toaster as Sonner } from "@/components/ui/sonner"; import { TooltipProvider } from "@/components/ui/tooltip"; import { QueryClientProvider } from "@tanstack/react-query"; import { queryClient } from "@/lib/queryClient"; import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom"; import { AuthProvider, useAuth } from "@/hooks/useAuth"; import { OrganizationProvider } from "@/contexts/OrganizationContext"; import { LogProvider } from "@/contexts/LogContext"; import { MediaRefreshProvider } from "@/contexts/MediaRefreshContext"; import { ProfilesProvider } from "@/contexts/ProfilesContext"; import { WebSocketProvider } from "@/contexts/WS_Socket"; import { registerAllWidgets } from "@/lib/registerWidgets"; import TopNavigation from "@/components/TopNavigation"; import Footer from "@/components/Footer"; import { DragDropProvider } from "@/contexts/DragDropContext"; import { useAppStore } from "@/store/appStore"; const GlobalDragDrop = React.lazy(() => import("@/components/GlobalDragDrop")); // Register all widgets on app boot registerAllWidgets(); import Index from "./pages/Index"; import Auth from "./pages/Auth"; const UpdatePassword = React.lazy(() => import("./pages/UpdatePassword")); import Profile from "./pages/Profile"; const Post = React.lazy(() => import("./modules/posts/PostPage")); import UserProfile from "./pages/UserProfile"; import TagPage from "./pages/TagPage"; import SearchResults from "./pages/SearchResults"; const LogsPage = React.lazy(() => import("./components/logging/LogsPage")); const Wizard = React.lazy(() => import("./pages/Wizard")); const ProviderSettings = React.lazy(() => import("./pages/ProviderSettings")); const NotFound = React.lazy(() => import("./pages/NotFound")); const AdminPage = React.lazy(() => import("./pages/AdminPage")); const enablePlaygrounds = import.meta.env.VITE_ENABLE_PLAYGROUNDS === 'true'; let PlaygroundEditor: any; let PlaygroundEditorLLM: any; let VideoPlayerPlayground: any; let VideoFeedPlayground: any; let VideoPlayerPlaygroundIntern: any; let PlaygroundImages: any; let PlaygroundImageEditor: any; let VideoGenPlayground: any; let PlaygroundCanvas: any; let TypesPlayground: any; let VariablePlayground: any; let I18nPlayground: any; let PlaygroundChat: any; let GridSearch: any; let PlacesModule: any; let LocationDetail: any; let Tetris: any; let FileBrowser: any; let SupportChat: any; GridSearch = React.lazy(() => import("./modules/places/gridsearch/GridSearch")); LocationDetail = React.lazy(() => import("./modules/places/LocationDetail")); TypesPlayground = React.lazy(() => import("@/modules/types/TypesPlayground")); if (enablePlaygrounds) { PlaygroundEditor = React.lazy(() => import("./pages/PlaygroundEditor")); PlaygroundEditorLLM = React.lazy(() => import("./pages/PlaygroundEditorLLM")); VideoPlayerPlayground = React.lazy(() => import("./pages/VideoPlayerPlayground")); VideoFeedPlayground = React.lazy(() => import("./pages/VideoFeedPlayground")); VideoPlayerPlaygroundIntern = React.lazy(() => import("./pages/VideoPlayerPlaygroundIntern")); PlaygroundImages = React.lazy(() => import("./pages/PlaygroundImages")); PlaygroundImageEditor = React.lazy(() => import("./pages/PlaygroundImageEditor")); VideoGenPlayground = React.lazy(() => import("./pages/VideoGenPlayground")); PlaygroundCanvas = React.lazy(() => import("./modules/layout/PlaygroundCanvas")); VariablePlayground = React.lazy(() => import("./components/variables/VariablesEditor").then(module => ({ default: module.VariablesEditor }))); I18nPlayground = React.lazy(() => import("./components/playground/I18nPlayground")); PlaygroundChat = React.lazy(() => import("./pages/PlaygroundChat")); SupportChat = React.lazy(() => import("./pages/SupportChat")); } Tetris = React.lazy(() => import("./apps/tetris/Tetris")); FileBrowser = React.lazy(() => import("./apps/filebrowser/FileBrowser")); const VersionMap = React.lazy(() => import("./pages/VersionMap")); const UserCollections = React.lazy(() => import("./pages/UserCollections")); const Collections = React.lazy(() => import("./pages/Collections")); const NewCollection = React.lazy(() => import("./pages/NewCollection")); const UserPage = React.lazy(() => import("./modules/pages/UserPage")); const NewPage = React.lazy(() => import("./modules/pages/NewPage")); const NewPost = React.lazy(() => import("./modules/posts/NewPost")); const EditPost = React.lazy(() => import("./modules/posts/EditPost")); // import { EcommerceBundleWrapper } from "./bundles/ecommerce"; // Create a single tracker instance outside the component to avoid re-creation on re-renders /* const tracker = new Tracker({ projectKey: import.meta.env.VITE_OPENREPLAY_KEY || 'wiN7QPfX48YLyozADQmW', respectDoNotTrack: false, __DISABLE_SECURE_MODE: true, }); tracker.use(trackerAssist()); */ const AppWrapper = () => { const location = useLocation(); const searchParams = new URLSearchParams(location.search); const isPageEditor = location.pathname.includes('/pages/') && searchParams.get('edit') === 'true'; const isFullScreenPage = location.pathname.startsWith('/video-feed') || isPageEditor; const containerClassName = isFullScreenPage ? "flex flex-col min-h-svh transition-colors duration-200 h-full" : "mx-auto max-w-[1400px] flex flex-col min-h-svh transition-colors duration-200 h-full"; const { showGlobalFooter } = useAppStore(); const ecommerce = import.meta.env.VITE_ENABLE_ECOMMERCE === 'true'; return (
{!isFullScreenPage && }
{/* Top-level routes (no organization context) */} } /> } /> Loading...
}>} /> } /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> } /> } /> } /> } /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> } /> } /> } /> } /> } /> } /> } /> } /> Loading...}>} /> Loading...}>} /> Loading map...}> } /> Loading...}>} /> {enablePlaygrounds && ( <> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> )} {/* Admin Routes */} Loading...}>} /> Loading...}>} /> Loading...}>} /> {enablePlaygrounds && Loading...}>} />} Loading...}>} /> {/* Playground Routes */} {enablePlaygrounds && ( <> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> Loading...}>} /> )} {enablePlaygrounds && Loading...}>} />} {/* Logs */} Loading...}>} /> {/* Apps */} Loading...}>} /> Loading...}>} /> {enablePlaygrounds && Loading...}>} />} {/* Ecommerce Routes */} {(ecommerce) && ( <> } /> } /> } /> } /> } /> } /> } /> } /> )} {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */} Loading...}>} /> {!isFullScreenPage && showGlobalFooter &&