import { createBrowserRouter } from 'react-router-dom';

import { AuthLayout } from '@/pages/Auth/AuthLayout';
import { ForgotPasswordPage } from '@/pages/Auth/ForgotPassword/ForgotPasswordPage';
import { LoginPage } from '@/pages/Auth/Login/LoginPage';
import { RegisterPage } from '@/pages/Auth/Register/RegisterPage';
import { ResetPasswordPage } from '@/pages/Auth/ResetPassword/ResetPasswordPage';
import { HomePage } from '@/pages/Home/HomePage';
import { RootLayout } from '@/pages/RootLayout';
import { IssueDetailPage } from '@/pages/Workspace/Issues/IssueDetailPage';
import { WorkspaceIssuesPage } from '@/pages/Workspace/Issues/WorkspaceIssuesPage';
import { WorkspaceMembersPage } from '@/pages/Workspace/Members/WorkspaceMembersPage';
import { RepoBlobPage } from '@/pages/Workspace/Repo/RepoBlobPage';
import { RepoBranchesPage } from '@/pages/Workspace/Repo/RepoBranchesPage';
import { RepoCodePage } from '@/pages/Workspace/Repo/RepoCodePage';
import { RepoCommitDetailPage } from '@/pages/Workspace/Repo/RepoCommitDetailPage';
import { RepoCommitsPage } from '@/pages/Workspace/Repo/RepoCommitsPage';
import { RepoCreatePrPage } from '@/pages/Workspace/Repo/RepoCreatePrPage';
import { RepoDeployKeysPage } from '@/pages/Workspace/Repo/RepoDeployKeysPage';
import { RepoForksPage } from '@/pages/Workspace/Repo/RepoForksPage';
import { RepoLayout } from '@/pages/Workspace/Repo/RepoLayout';
import { RepoMembersPage } from '@/pages/Workspace/Repo/RepoMembersPage';
import { RepoOverviewPage } from '@/pages/Workspace/Repo/RepoOverviewPage';
import { RepoPrDetailPage } from '@/pages/Workspace/Repo/RepoPrDetailPage';
import { RepoPullsPage } from '@/pages/Workspace/Repo/RepoPullsPage';
import { RepoReleasesPage } from '@/pages/Workspace/Repo/RepoReleasesPage';
import { RepoSettingsPage } from '@/pages/Workspace/Repo/RepoSettingsPage';
import { RepoStarsPage } from '@/pages/Workspace/Repo/RepoStarsPage';
import { RepoTagsPage } from '@/pages/Workspace/Repo/RepoTagsPage';
import { RepoWatchersPage } from '@/pages/Workspace/Repo/RepoWatchersPage';
import { RepoWebhooksPage } from '@/pages/Workspace/Repo/RepoWebhooksPage';
import { RepoWikiDetailPage } from '@/pages/Workspace/Repo/Wiki/RepoWikiDetailPage';
import { RepoWikiPage } from '@/pages/Workspace/Repo/Wiki/RepoWikiPage';
import { WorkspaceReposPage } from '@/pages/Workspace/Repos/WorkspaceReposPage';
import { WorkspaceSettingsPage } from '@/pages/Workspace/Settings/WorkspaceSettingsPage';
import { WorkspaceLayout } from '@/pages/Workspace/WorkspaceLayout';
import { WorkspacePage } from '@/pages/Workspace/WorkspacePage';

export const router = createBrowserRouter([
  {
    path: '/',
    Component: RootLayout,
    children: [
      { index: true, Component: HomePage },
      {
        path: '/:workspaceName',
        Component: WorkspaceLayout,
        children: [
          { index: true, Component: WorkspacePage },
          { path: 'repos', Component: WorkspaceReposPage },
          {
            path: 'repos/:repoName',
            Component: RepoLayout,
            children: [
              { index: true, Component: RepoCodePage },
              { path: 'overview', Component: RepoOverviewPage },
              { path: 'branches', Component: RepoBranchesPage },
              { path: 'tags', Component: RepoTagsPage },
              { path: 'releases', Component: RepoReleasesPage },
              { path: 'commits', Component: RepoCommitsPage },
              { path: 'commits/:commitSha', Component: RepoCommitDetailPage },
              { path: 'pulls', Component: RepoPullsPage },
              { path: 'pulls/new', Component: RepoCreatePrPage },
              { path: 'pulls/:prNumber', Component: RepoPrDetailPage },
              { path: 'members', Component: RepoMembersPage },
              { path: 'forks', Component: RepoForksPage },
              { path: 'stars', Component: RepoStarsPage },
              { path: 'watchers', Component: RepoWatchersPage },
              { path: 'deploy-keys', Component: RepoDeployKeysPage },
              { path: 'webhooks', Component: RepoWebhooksPage },
              { path: 'wiki', Component: RepoWikiPage },
              { path: 'wiki/:slug', Component: RepoWikiDetailPage },
              { path: 'settings', Component: RepoSettingsPage },
              { path: 'blob', Component: RepoBlobPage },
            ],
          },
          { path: 'issues', Component: WorkspaceIssuesPage },
          { path: 'issues/:issueNumber', Component: IssueDetailPage },
          { path: 'members', Component: WorkspaceMembersPage },
          { path: 'settings', Component: WorkspaceSettingsPage },
        ],
      },
    ],
  },
  {
    path: '/auth',
    Component: AuthLayout,
    children: [
      { path: 'login', Component: LoginPage },
      { path: 'register', Component: RegisterPage },
      { path: 'forgot-password', Component: ForgotPasswordPage },
      { path: 'reset-password', Component: ResetPasswordPage },
    ],
  },
]);
