import {
  CheckSquareOutlined,
  CloudOutlined,
  ClusterOutlined,
  CompressOutlined,
  DatabaseOutlined,
  InfoCircleOutlined,
  OpenAIOutlined,
  QuestionOutlined,
  SunOutlined,
  SyncOutlined,
  TableOutlined,
  ToolOutlined,
} from '@ant-design/icons'
import {Navigate, type RouteObject} from 'react-router'
import Conversation from './pages/ai/Conversation.tsx'
import Inspection from './pages/ai/Inspection.tsx'
import DataDetail from './pages/ai/knowledge/DataDetail.tsx'
import DataImport from './pages/ai/knowledge/DataImport.tsx'
import DataSegment from './pages/ai/knowledge/DataSegment.tsx'
import Knowledge from './pages/ai/knowledge/Knowledge.tsx'
import App from './pages/App.tsx'
import Cloud from './pages/overview/Cloud.tsx'
import Overview from './pages/overview/Overview.tsx'
import Queue from './pages/overview/Queue.tsx'
import Table from './pages/overview/Table.tsx'
import Task from './pages/overview/Task.tsx'
import Tool from './pages/overview/Tool.tsx'
import Version from './pages/overview/Version.tsx'
import Yarn from './pages/overview/Yarn.tsx'
import YarnCluster from './pages/overview/YarnCluster.tsx'
import {commonInfo} from './util/amis.tsx'

export const routes: RouteObject[] = [
  {
    path: '/',
    Component: App,
    children: [
      {
        index: true,
        element: <Navigate to="/overview" replace/>,
      },
      {
        path: 'overview',
        Component: Overview,
      },
      {
        path: 'table',
        Component: Table,
      },
      {
        path: 'queue',
        Component: Queue,
      },
      {
        path: 'version',
        Component: Version,
      },
      {
        path: 'yarn/:clusters/:queue/:search?',
        Component: Yarn,
      },
      {
        path: 'cloud',
        Component: Cloud,
      },
      {
        path: 'yarn_cluster',
        Component: YarnCluster,
      },
      {
        path: 'tool',
        Component: Tool,
      },
      {
        path: 'task',
        Component: Task,
      },
      {
        path: 'ai',
        children: [
          {
            index: true,
            element: <Navigate to="/ai/conversation" replace/>,
          },
          {
            path: 'inspection',
            Component: Inspection,
          },
          {
            path: 'conversation',
            Component: Conversation,
          },
          {
            path: 'knowledge',
            Component: Knowledge,
          },
          {
            path: 'knowledge/import/:knowledge_id',
            Component: DataImport,
          },
          {
            path: 'knowledge/detail/:knowledge_id',
            Component: DataDetail,
          },
          {
            path: 'knowledge/detail/:knowledge_id/segment/:group_id',
            Component: DataSegment,
          },
        ],
      },
    ],
  },
]

export const menus = {
  routes: [
    {
      path: '/',
      name: '概览',
      icon: <InfoCircleOutlined/>,
      routes: [
        {
          path: '/overview',
          name: '概览',
          icon: <InfoCircleOutlined/>,
        },
        {
          path: '/table',
          name: '表任务',
          icon: <TableOutlined/>,
        },
        {
          path: '/queue',
          name: '压缩队列',
          icon: <CompressOutlined/>,
        },
        {
          path: '/version',
          name: '跨天',
          icon: <SunOutlined/>,
        },
        {
          path: `/yarn/${commonInfo.clusters.sync_names()}/root/Sync`,
          name: '同步集群',
          icon: <SyncOutlined/>,
        },
        {
          path: `/yarn/${commonInfo.clusters.compaction_names()}/default/Compaction`,
          name: '压缩集群',
          icon: <SyncOutlined/>,
        },
        {
          path: '/cloud',
          name: '服务',
          icon: <CloudOutlined/>,
        },
        {
          path: 'a86f7c51-ae60-4ca4-8c4d-40b86b445a04',
          name: '集群',
          icon: <ClusterOutlined/>,
          routes: [
            {
              path: '/yarn_cluster',
              name: '概览',
              icon: <InfoCircleOutlined/>,
            },
            ...Object.keys(commonInfo.clusters.compaction).map(name => ({
              // @ts-ignore
              path: `/yarn/${name}/${commonInfo.clusters.compaction[name]}`,
              name: `${name} 集群`,
              icon: <ClusterOutlined/>,
            })),
          ],
        },
        {
          path: '/tool',
          name: '工具',
          icon: <ToolOutlined/>,
        },
        {
          path: '/task',
          name: '任务',
          icon: <CheckSquareOutlined/>,
        },
      ],
    },
    {
      path: '/ai',
      name: 'AI',
      icon: <OpenAIOutlined/>,
      routes: [
        {
          path: '/ai/conversation',
          name: '智慧问答',
          icon: <QuestionOutlined/>,
        },
        {
          path: '/ai/inspection',
          name: '智能巡检',
          icon: <CheckSquareOutlined/>,
        },
        {
          path: '/ai/knowledge',
          name: '知识库',
          icon: <DatabaseOutlined/>,
        },
      ],
    },
  ],
}
