import { lazy } from 'react'; import { Routes, Route, Navigate } from 'react-router'; import { AppShell } from '../components/layout/AppShell'; import { ProtectedRoute } from './ProtectedRoute'; // Public (outside the shell) import { ConnectPage } from '../features/connect/ConnectPage'; import { LoginPage } from '../features/auth/LoginPage'; // Core screens (eager — first paint inside the shell) import { LibraryPage } from '../features/library/LibraryPage'; import { AlbumDetailPage } from '../features/album-detail/AlbumDetailPage'; import { ArtistDetailPage } from '../features/artist-detail/ArtistDetailPage'; import { PlaylistsPage } from '../features/playlists/PlaylistsPage'; import { PlaylistDetailPage } from '../features/playlist-detail/PlaylistDetailPage'; // Settings / Admin layouts + panels (small, eager) import { SettingsPage } from '../features/settings/SettingsPage'; import { ProfileSettings, PlaybackSettings, ScrobblingSettings, InstanceSettings, } from '../features/settings/panels'; import { AdminPage } from '../features/admin/AdminPage'; import { AdminUsers, AdminUserDetail, AdminSources, AdminInstance, } from '../features/admin/panels'; import { NotFoundPage } from '../features/not-found/NotFoundPage'; // Secondary screens — lazily loaded (Suspense boundary lives in AppShell) const SearchDownloadPage = lazy(() => import('../features/search-download/SearchDownloadPage').then((m) => ({ default: m.SearchDownloadPage, })), ); const DownloadsManagerPage = lazy(() => import('../features/downloads-manager/DownloadsManagerPage').then((m) => ({ default: m.DownloadsManagerPage, })), ); const UploadPage = lazy(() => import('../features/upload/UploadPage').then((m) => ({ default: m.UploadPage })), ); const MetadataEditorPage = lazy(() => import('../features/metadata-editor/MetadataEditorPage').then((m) => ({ default: m.MetadataEditorPage, })), ); const StoragePage = lazy(() => import('../features/storage/StoragePage').then((m) => ({ default: m.StoragePage, })), ); const StorageMaintenancePage = lazy(() => import('../features/storage/StorageMaintenancePage').then((m) => ({ default: m.StorageMaintenancePage, })), ); const QueuePage = lazy(() => import('../features/queue/QueuePage').then((m) => ({ default: m.QueuePage })), ); export function AppRoutes() { return ( {/* Public */} } /> } /> {/* Authenticated shell */} } > } /> {/* Library */} } /> } /> } /> {/* Playlists */} } /> } /> {/* Discover & downloads (permission-gated) */} } /> } /> {/* Upload & metadata */} } /> } /> } /> {/* Storage */} } /> } /> {/* Queue (narrow viewports) */} } /> {/* Settings */} }> } /> } /> } /> } /> } /> {/* Admin (admin-gated) */} } > } /> } /> } /> } /> } /> {/* 404 */} } /> ); }