import {Route, Routes} from 'react-router-dom';
import {LoginPage} from '@/app/auth/login-page';
import {RegisterPage} from '@/app/auth/register-page';
import {VerifyEmailPage} from '@/app/auth/verify-email-page';
import {PasswordResetPage} from '@/app/auth/password-reset-page';
import {ConfirmPasswordResetPage} from '@/app/auth/confirm-password-reset-page';
import {InitProject} from '@/app/init/project';
import {InitRepository} from '@/app/init/repository';
import {UserProfile} from '@/app/user/user';
import {ProjectLayout} from '@/app/project/layout';
import {ProjectOverview} from '@/app/project/overview';
import {ProjectActivity} from '@/app/project/activity';
import {ProjectRepositories} from '@/app/project/repositories';
import {ProjectIssues} from '@/app/project/issues';
import {ProjectBoards} from '@/app/project/boards';
import {ProjectBoardDetail} from '@/app/project/boards/[boardId]';
import {IssueNew} from '@/app/project/issue-new';
import {IssueDetail} from '@/app/project/issue-detail';
import {IssueEdit} from '@/app/project/issue-edit';
import {ProjectMembers} from '@/app/project/member';
import {ProjectRoom} from '@/app/project/room';
import {ProjectArticles} from '@/app/project/articles';
import {ProjectResources} from '@/app/project/resources';
import {ProjectSettings} from '@/app/project/settings';
import {RepoLayout} from '@/app/repository/layout';
import {RepoOverview} from '@/app/repository/overview';
import {RepoBranches} from '@/app/repository/branches';
import {RepoCommits} from '@/app/repository/commits';
import {RepoContributors} from '@/app/repository/contributors';
import {RepoFiles} from '@/app/repository/files';
import {RepoTags} from '@/app/repository/tags';
import {RepoPullRequests} from '@/app/repository/pull-requests';
import {RepoPullRequestNew} from '@/app/repository/pull-request-new';
import {RepoPullRequestDetail} from '@/app/repository/pull-request-detail';
import {RepoSettingsLayout} from '@/app/repository/settings/layout';
import {RepoSettingsGeneral} from '@/app/repository/settings/general';
import {RepoSettingsTags} from '@/app/repository/settings/tags';
import {RepoSettingsBranches} from '@/app/repository/settings/branches';
import {RepoSettingsArchive} from '@/app/repository/settings/archive';
import {RepoSettingsMembers} from '@/app/repository/settings/members';
import {RepoSettingsWebhooks} from '@/app/repository/settings/webhooks';
import {RepoCommitDetail} from '@/app/repository/commit-diff';
import {SettingsGeneral} from '@/app/project/settings/general';
import {SettingsLabels} from '@/app/project/settings/labels';
import {SettingsSkills} from '@/app/project/settings/skills';
import {SkillsInit} from '@/app/project/skills-init';
import {SettingsBilling} from '@/app/project/settings/billing';
import {SettingsMembers} from '@/app/project/settings/members';
import {SettingsOAuth} from '@/app/project/settings/oauth';
import {SettingsWebhook} from '@/app/project/settings/webhook';
import {SettingsLayout} from '@/app/settings/layout';
import {SettingsProfile} from '@/app/settings/profile';
import {SettingsAccount} from '@/app/settings/account';
import {SettingsSecurity} from '@/app/settings/security';
import {SettingsTokens} from '@/app/settings/tokens';
import {SettingsSshKeys} from '@/app/settings/ssh-keys';
import {SettingsPreferences} from '@/app/settings/preferences';
import {SettingsActivity} from '@/app/settings/activity';
import NotifyLayout from '@/app/notify/layout';
import NotifyPage from '@/app/notify/page';
import InvitationsLayout from '@/app/invitations/layout';
import InvitationsPage from '@/app/invitations/page';
import LandingPage from '@/app/page';
import SearchPage from '@/app/search/page';
import PricingPage from '@/app/pricing/page';
import SkillsPage from '@/app/skills/page';
import SolutionsPage from '@/app/solutions/page';
import NetworkPage from '@/app/network/page';
import AboutPage from '@/app/about/page';
import DocsPage from '@/app/docs/page';
import SolutionsRoomsPage from '@/app/solutions/rooms/page';
import SolutionsMemoryPage from '@/app/solutions/memory/page';
import SolutionsGovernancePage from '@/app/solutions/governance/page';
import SkillsPublishPage from '@/app/skills/publish/page';
import SkillsDocsPage from '@/app/skills/docs/page';
import NetworkRoomsPage from '@/app/network/rooms/page';
import NetworkApiPage from '@/app/network/api/page';
import PricingEnterprisePage from '@/app/pricing/enterprise/page';
import PricingFaqPage from '@/app/pricing/faq/page';
import {ProtectedRoute} from '@/components/auth/protected-route';
import {WorkspaceLayout} from '@/app/workspace/layout';
import {WorkspaceOverview} from '@/app/workspace/overview';
import {WorkspaceProjects} from '@/app/workspace/projects';
import {WorkspaceMembers} from '@/app/workspace/members';
import {WorkspaceSettings} from '@/app/workspace/settings';
import {WorkspaceBilling} from '@/app/workspace/billing';
import {AcceptWorkspaceInvitePage} from '@/app/auth/accept-workspace-invite-page';
import {WorkspaceRedirect} from '@/app/workspace/redirect';
import {InitWorkspace} from '@/app/init/workspace';
import HomePage from '@/app/homepage/page';

function App() {
    return (
        <Routes>
            <Route index element={<LandingPage/>}/>
            <Route path="/auth">
                <Route path="login" element={<LoginPage/>}/>
                <Route path="register" element={<RegisterPage/>}/>
                <Route path="password/reset" element={<PasswordResetPage/>}/>
                <Route path="reset-password" element={<ConfirmPasswordResetPage/>}/>
                <Route path="verify-email" element={<VerifyEmailPage/>}/>
                <Route path="accept-workspace-invite" element={<AcceptWorkspaceInvitePage/>}/>
            </Route>
            <Route path="/user/:user">
                <Route index element={<UserProfile/>}/>
            </Route>

            <Route path="/pricing" element={<PricingPage/>}/>
            <Route path="/pricing/enterprise" element={<PricingEnterprisePage/>}/>
            <Route path="/pricing/faq" element={<PricingFaqPage/>}/>
            <Route path="/skills" element={<SkillsPage/>}/>
            <Route path="/skills/publish" element={<SkillsPublishPage/>}/>
            <Route path="/skills/docs" element={<SkillsDocsPage/>}/>
            <Route path="/solutions" element={<SolutionsPage/>}/>
            <Route path="/solutions/rooms" element={<SolutionsRoomsPage/>}/>
            <Route path="/solutions/memory" element={<SolutionsMemoryPage/>}/>
            <Route path="/solutions/governance" element={<SolutionsGovernancePage/>}/>
            <Route path="/network" element={<NetworkPage/>}/>
            <Route path="/network/rooms" element={<NetworkRoomsPage/>}/>
            <Route path="/network/api" element={<NetworkApiPage/>}/>
            <Route path="/about" element={<AboutPage/>}/>
            <Route path="/docs" element={<DocsPage/>}/>

            <Route element={<ProtectedRoute/>}>
                <Route path="/homepage" element={<HomePage/>}/>
                <Route path="/search" element={<SearchPage/>}/>

                <Route path="/init">
                    <Route path="project" element={<InitProject/>}/>
                    <Route path="repository" element={<InitRepository/>}/>
                    <Route path="workspace" element={<InitWorkspace/>}/>
                </Route>

                <Route path="/settings" element={<SettingsLayout/>}>
                    <Route index element={<SettingsProfile/>}/>
                    <Route path="profile" element={<SettingsProfile/>}/>
                    <Route path="account" element={<SettingsAccount/>}/>
                    <Route path="security" element={<SettingsSecurity/>}/>
                    <Route path="tokens" element={<SettingsTokens/>}/>
                    <Route path="ssh-keys" element={<SettingsSshKeys/>}/>
                    <Route path="preferences" element={<SettingsPreferences/>}/>
                    <Route path="activity" element={<SettingsActivity/>}/>
                </Route>

                <Route path="/notify" element={<NotifyLayout/>}>
                    <Route index element={<NotifyPage/>}/>
                </Route>

                <Route path="/invitations" element={<InvitationsLayout/>}>
                    <Route index element={<InvitationsPage/>}/>
                </Route>

                <Route path="/repository/:namespace/:repoName" element={<RepoLayout/>}>
                    <Route index element={<RepoOverview/>}/>
                    <Route path="branches" element={<RepoBranches/>}/>
                    <Route path="commits" element={<RepoCommits/>}/>
                    <Route path="commit/:oid" element={<RepoCommitDetail/>}/>
                    <Route path="contributors" element={<RepoContributors/>}/>
                    <Route path="files" element={<RepoFiles/>}/>
                    <Route path="tags" element={<RepoTags/>}/>
                    <Route path="pull-requests" element={<RepoPullRequests/>}/>
                    <Route path="pull-requests/new" element={<RepoPullRequestNew/>}/>
                    <Route path="pull-requests/:prNumber" element={<RepoPullRequestDetail/>}/>
                    <Route path="settings" element={<RepoSettingsLayout/>}>
                        <Route index element={<RepoSettingsGeneral/>}/>
                        <Route path="general" element={<RepoSettingsGeneral/>}/>
                        <Route path="tags" element={<RepoSettingsTags/>}/>
                        <Route path="branches" element={<RepoSettingsBranches/>}/>
                        <Route path="archive" element={<RepoSettingsArchive/>}/>
                        <Route path="members" element={<RepoSettingsMembers/>}/>
                        <Route path="webhooks" element={<RepoSettingsWebhooks/>}/>
                    </Route>
                </Route>

                <Route path="/project/:project_name" element={<ProjectLayout/>}>
                    <Route index element={<ProjectOverview/>}/>
                    <Route path="activity" element={<ProjectActivity/>}/>
                    <Route path="repositories" element={<ProjectRepositories/>}/>
                    <Route path="issues" element={<ProjectIssues/>}/>
                    <Route path="issues/new" element={<IssueNew/>}/>
                    <Route path="issues/:issueNumber" element={<IssueDetail/>}/>
                    <Route path="issues/:issueNumber/edit" element={<IssueEdit/>}/>
                    <Route path="boards" element={<ProjectBoards/>}/>
                    <Route path="boards/:boardId" element={<ProjectBoardDetail/>}/>
                    <Route path="members" element={<ProjectMembers/>}/>
                    <Route path="skills" element={<SettingsSkills/>}/>
                    <Route path="skills-init" element={<SkillsInit/>}/>
                    <Route path="room" element={<ProjectRoom/>}/>
                    <Route path="room/:roomId" element={<ProjectRoom/>}/>
                    <Route path="articles" element={<ProjectArticles/>}/>
                    <Route path="resources" element={<ProjectResources/>}/>
                    <Route path="settings" element={<ProjectSettings/>}>
                        <Route index element={<SettingsGeneral/>}/>
                        <Route path="general" element={<SettingsGeneral/>}/>
                        <Route path="labels" element={<SettingsLabels/>}/>
                        <Route path="billing" element={<SettingsBilling/>}/>
                        <Route path="members" element={<SettingsMembers/>}/>
                        <Route path="oauth" element={<SettingsOAuth/>}/>
                        <Route path="webhook" element={<SettingsWebhook/>}/>
                    </Route>
                </Route>

                <Route path="/w/me" element={<WorkspaceRedirect/>}/>

                <Route path="/w/:workspace_slug" element={<WorkspaceLayout/>}>
                    <Route index element={<WorkspaceOverview/>}/>
                    <Route path="projects" element={<WorkspaceProjects/>}/>
                    <Route path="billing" element={<WorkspaceBilling/>}/>
                    <Route path="members" element={<WorkspaceMembers/>}/>
                    <Route path="settings" element={<WorkspaceSettings/>}/>
                </Route>
            </Route>
        </Routes>
    );
}

export default App;
