// ============================================================
// 路由定义
// ============================================================

import { createBrowserRouter } from 'react-router-dom'
import { AuthGuard } from './AuthGuard'
import AdminLayout from '@/layouts/AdminLayout'

export const router = createBrowserRouter([
  {
    path: '/login',
    lazy: () => import('@/pages/Login').then((m) => ({ Component: m.default })),
  },
  {
    path: '/',
    element: (
      <AuthGuard>
        <AdminLayout />
      </AuthGuard>
    ),
    children: [
      { index: true, lazy: () => import('@/pages/Dashboard').then((m) => ({ Component: m.default })) },
      { path: 'accounts', lazy: () => import('@/pages/Accounts').then((m) => ({ Component: m.default })) },
      { path: 'providers', lazy: () => import('@/pages/Providers').then((m) => ({ Component: m.default })) },
      { path: 'models', lazy: () => import('@/pages/Models').then((m) => ({ Component: m.default })) },
      { path: 'agent-templates', lazy: () => import('@/pages/AgentTemplates').then((m) => ({ Component: m.default })) },
      { path: 'api-keys', lazy: () => import('@/pages/ApiKeys').then((m) => ({ Component: m.default })) },
      { path: 'usage', lazy: () => import('@/pages/Usage').then((m) => ({ Component: m.default })) },
      { path: 'relay', lazy: () => import('@/pages/Relay').then((m) => ({ Component: m.default })) },
      { path: 'config', lazy: () => import('@/pages/Config').then((m) => ({ Component: m.default })) },
      { path: 'prompts', lazy: () => import('@/pages/Prompts').then((m) => ({ Component: m.default })) },
      { path: 'logs', lazy: () => import('@/pages/Logs').then((m) => ({ Component: m.default })) },
    ],
  },
])
