import { createRootRoute, createRoute, createRouter } from '@tanstack/react-router';
import { RootLayout } from '@/app/RootLayout';
import { CampaignsPage } from '@/features/campaigns/CampaignsPage';
import { CharactersPage } from '@/features/characters/CharactersPage';
import { CharacterSheetPage } from '@/features/characters/CharacterSheetPage';
import { CombatPage } from '@/features/combat/CombatPage';
import { DicePage } from '@/features/dice/DicePage';
import { CompendiumPage } from '@/features/compendium/CompendiumPage';

const rootRoute = createRootRoute({ component: RootLayout });

const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/', component: CampaignsPage });
const charactersRoute = createRoute({ getParentRoute: () => rootRoute, path: '/characters', component: CharactersPage });
const characterSheetRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/characters/$characterId',
  component: CharacterSheetPage,
});
const combatRoute = createRoute({ getParentRoute: () => rootRoute, path: '/combat', component: CombatPage });
const diceRoute = createRoute({ getParentRoute: () => rootRoute, path: '/dice', component: DicePage });
const compendiumRoute = createRoute({ getParentRoute: () => rootRoute, path: '/compendium', component: CompendiumPage });

const routeTree = rootRoute.addChildren([
  indexRoute,
  charactersRoute,
  characterSheetRoute,
  combatRoute,
  diceRoute,
  compendiumRoute,
]);

export const router = createRouter({ routeTree, defaultPreload: 'intent' });

declare module '@tanstack/react-router' {
  interface Register {
    router: typeof router;
  }
}
