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 { RepoBranchesPage } from '@/pages/Workspace/Repo/RepoBranchesPage';
import { RepoLayout } from '@/pages/Workspace/Repo/RepoLayout';
import { RepoOverviewPage } from '@/pages/Workspace/Repo/RepoOverviewPage';
import { RepoPrDetailPage } from '@/pages/Workspace/Repo/RepoPrDetailPage';
import { RepoPullsPage } from '@/pages/Workspace/Repo/RepoPullsPage';
import { RepoSettingsPage } from '@/pages/Workspace/Repo/RepoSettingsPage';
import { RepoTagsPage } from '@/pages/Workspace/Repo/RepoTagsPage';
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: RepoOverviewPage },
              { path: 'branches', Component: RepoBranchesPage },
              { path: 'tags', Component: RepoTagsPage },
              { path: 'pulls', Component: RepoPullsPage },
              { path: 'pulls/:prNumber', Component: RepoPrDetailPage },
              { path: 'webhooks', Component: RepoWebhooksPage },
              { path: 'wiki', Component: RepoWikiPage },
              { path: 'wiki/:slug', Component: RepoWikiDetailPage },
              { path: 'settings', Component: RepoSettingsPage },
            ],
          },
          { 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 },
    ],
  },
]);
