import { Navigate, Route, Routes } from 'react-router-dom';
import { OpsLayout } from './components/OpsLayout';
import { RequireOps } from './components/RequireOps';
import { RequireAdmin } from './components/RequireAdmin';
import { AdminLayout } from './components/AdminLayout';
import { AnalyticsPage } from './pages/AnalyticsPage';
import { CreatorsPage } from './pages/CreatorsPage';
import { FeaturedPage } from './pages/FeaturedPage';
import { ReportsPage } from './pages/ReportsPage';
import { ReviewPage } from './pages/ReviewPage';
import { SummaryPage } from './pages/admin/SummaryPage';
import { UsersPage } from './pages/admin/UsersPage';
import { BillingPage } from './pages/admin/BillingPage';
import { AgentCodeRunPage } from './pages/admin/AgentCodeRunPage';
import { WechatPage } from './pages/admin/WechatPage';
import { SystemPolicyPage } from './pages/admin/SystemPolicyPage';
import { OrchestratorPage } from './pages/admin/OrchestratorPage';
import { LlmProvidersPage } from './pages/admin/LlmProvidersPage';
import { GoalRunPage } from './pages/admin/GoalRunPage';
import { MemoryV2Page } from './pages/admin/MemoryV2Page';

export function App() {
  return (
    <Routes>
      {/* Plaza ops console */}
      <Route
        element={
          <RequireOps>
            <OpsLayout />
          </RequireOps>
        }
      >
        <Route index element={<ReviewPage />} />
        <Route path="reports" element={<ReportsPage />} />
        <Route path="featured" element={<FeaturedPage />} />
        <Route path="creators" element={<CreatorsPage />} />
        <Route path="analytics" element={<AnalyticsPage />} />
      </Route>

      {/* Super-admin console */}
      <Route
        path="admin"
        element={
          <RequireAdmin>
            <AdminLayout />
          </RequireAdmin>
        }
      >
        <Route index element={<SummaryPage />} />
        <Route path="users" element={<UsersPage />} />
        <Route path="billing" element={<BillingPage />} />
        <Route path="agent-code-run" element={<AgentCodeRunPage />} />
        <Route path="wechat" element={<WechatPage />} />
        <Route path="policy" element={<SystemPolicyPage />} />
        <Route path="orchestrator" element={<OrchestratorPage />} />
        <Route path="llm" element={<LlmProvidersPage />} />
        <Route path="goal-runs" element={<GoalRunPage />} />
        <Route path="memory-v2" element={<MemoryV2Page />} />
        <Route path="*" element={<Navigate to="/admin" replace />} />
      </Route>

      <Route path="*" element={<Navigate to="/" replace />} />
    </Routes>
  );
}
