import { HashRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { UserProvider } from './contexts/UserContext.jsx';
import AppLayout from './components/layout/AppLayout.jsx';
import ConsoleLayout from './components/layout/ConsoleLayout.jsx';
import AdminLayout from './components/layout/AdminLayout.jsx';
import DeveloperLayout from './components/layout/DeveloperLayout.jsx';
import HomePage from './pages/HomePage.jsx';
import LoginPage from './pages/LoginPage.jsx';

// Console 子页面
import ChatPage from './pages/console/ChatPage.jsx';
import SkillsPage from './pages/console/SkillsPage.jsx';
import SkillDetailPage from './pages/console/SkillDetailPage.jsx';
import ConsoleMySkillsPage from './pages/console/MySkillsPage.jsx';
import SkillConfigPage from './pages/console/SkillConfigPage.jsx';
import LogsPage from './pages/console/LogsPage.jsx';
import TasksPage from './pages/console/TasksPage.jsx';
import TaskDetailPage from './pages/console/TaskDetailPage.jsx';
import MembersPage from './pages/console/MembersPage.jsx';
import MemberConfigPage from './pages/console/MemberConfigPage.jsx';
import AddMemberPage from './pages/console/AddMemberPage.jsx';
import PermissionsPage from './pages/console/PermissionsPage.jsx';
import SkillsConfigPage from './pages/console/SkillsConfigPage.jsx';
import ConsoleReviewListPage from './pages/console/ConsoleReviewListPage.jsx';
import ConsoleReviewDetailPage from './pages/console/ConsoleReviewDetailPage.jsx';
import ProjectModelConfigsPage from './pages/console/ProjectModelConfigsPage.jsx';
import AddProjectModelConfigPage from './pages/console/AddProjectModelConfigPage.jsx';
import UserModelConfigsPage from './pages/console/UserModelConfigsPage.jsx';
import AddUserModelConfigPage from './pages/console/AddUserModelConfigPage.jsx';

// Admin 子页面
import OverviewPage from './pages/admin/OverviewPage.jsx';
import DepartmentsPage from './pages/admin/DepartmentsPage.jsx';
import AddDepartmentPage from './pages/admin/AddDepartmentPage.jsx';
import UsersPage from './pages/admin/UsersPage.jsx';
import AddUserPage from './pages/admin/AddUserPage.jsx';
import AdminProjectsPage from './pages/admin/AdminProjectsPage.jsx';
import AddProjectPage from './pages/admin/AddProjectPage.jsx';
import AdminLogsPage from './pages/admin/AdminLogsPage.jsx';
import ModelConfigsPage from './pages/admin/ModelConfigsPage.jsx';
import AddModelConfigPage from './pages/admin/AddModelConfigPage.jsx';

// Developer 子页面
import DevOverviewPage from './pages/developer/DevOverviewPage.jsx';
import DeveloperMySkillsPage from './pages/developer/MySkillsPage.jsx';
import UploadSkillPage from './pages/developer/UploadSkillPage.jsx';
import SkillEditorPage from './pages/developer/SkillEditorPage.jsx';
import UploadVersionPage from './pages/developer/UploadVersionPage.jsx';
import UpdateSkillInfoPage from './pages/developer/UpdateSkillInfoPage.jsx';
import DevDocsPage from './pages/developer/DevDocsPage.jsx';

function App() {
    return (
        <UserProvider>
            <Router>
                <Routes>
                    <Route path="/login" element={<LoginPage />} />
                    <Route element={<AppLayout />}>
                        <Route path="/" element={<HomePage />} />

                        <Route path="/console" element={<ConsoleLayout />}>
                            <Route index element={<Navigate to="chat/welcome" replace />} />
                            <Route path="chat" element={<ChatPage />} />
                            <Route path="chat/:scene" element={<ChatPage />} />
                            <Route path="skills" element={<SkillsPage />} />
                            <Route path="skills/:skillId" element={<SkillDetailPage />} />
                            <Route path="my-skills" element={<ConsoleMySkillsPage />} />
                            <Route path="my-skills/:subscriptionId/config" element={<SkillConfigPage />} />
                            <Route path="logs" element={<LogsPage />} />
                            <Route path="tasks" element={<TasksPage />} />
                            <Route path="tasks/:taskId" element={<TaskDetailPage />} />
                            <Route path="project" element={<Navigate to="members" replace />} />
                            <Route path="project/members" element={<MembersPage />} />
                            <Route path="project/members/add" element={<AddMemberPage />} />
                            <Route path="project/members/:memberId/config" element={<MemberConfigPage />} />
                            <Route path="project/permissions" element={<PermissionsPage />} />
                            <Route path="project/skills" element={<SkillsConfigPage />} />
                            <Route path="project/models" element={<ProjectModelConfigsPage />} />
                            <Route path="project/models/add" element={<AddProjectModelConfigPage />} />
                            <Route path="project/models/:id/edit" element={<AddProjectModelConfigPage />} />
                            <Route path="user-models" element={<UserModelConfigsPage />} />
                            <Route path="user-models/add" element={<AddUserModelConfigPage />} />
                            <Route path="user-models/:id/edit" element={<AddUserModelConfigPage />} />
                        </Route>

                        <Route path="/admin" element={<AdminLayout />}>
                            <Route index element={<Navigate to="overview" replace />} />
                            <Route path="overview" element={<OverviewPage />} />
                            <Route path="reviews" element={<ConsoleReviewListPage />} />
                            <Route path="reviews/:type/:reviewId" element={<ConsoleReviewDetailPage />} />
                            <Route path="departments" element={<DepartmentsPage />} />
                            <Route path="departments/add" element={<AddDepartmentPage />} />
                            <Route path="departments/:id/edit" element={<AddDepartmentPage />} />
                            <Route path="users" element={<UsersPage />} />
                            <Route path="users/add" element={<AddUserPage />} />
                            <Route path="users/:id/edit" element={<AddUserPage />} />
                            <Route path="projects" element={<AdminProjectsPage />} />
                            <Route path="projects/add" element={<AddProjectPage />} />
                            <Route path="projects/:id/edit" element={<AddProjectPage />} />
                            <Route path="logs" element={<AdminLogsPage />} />
                            <Route path="models" element={<ModelConfigsPage />} />
                            <Route path="models/add" element={<AddModelConfigPage />} />
                            <Route path="models/:id/edit" element={<AddModelConfigPage />} />
                        </Route>

                        <Route path="/developer" element={<DeveloperLayout />}>
                            <Route index element={<Navigate to="overview" replace />} />
                            <Route path="overview" element={<DevOverviewPage />} />
                            <Route path="my-skills" element={<DeveloperMySkillsPage />} />
                            <Route path="my-skills/upload" element={<UploadSkillPage />} />
                            <Route path="my-skills/:skillId/editor" element={<SkillEditorPage />} />
                            <Route path="my-skills/:skillId/new-version" element={<UploadVersionPage />} />
                            <Route path="my-skills/:skillId/update-info" element={<UpdateSkillInfoPage />} />
                            <Route path="docs" element={<DevDocsPage />} />
                        </Route>
                    </Route>
                </Routes>
            </Router>
        </UserProvider>
    );
}

export default App;
