import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/HomeView.vue'),
    meta: { title: 'Dashboard' }
  },
  {
    path: '/server/:id',
    name: 'server-detail',
    component: () => import('../views/ServerDetailView.vue'),
    meta: { title: 'Server Detail' }
  },
  {
    path: '/server/:id/peers',
    name: 'peers',
    component: () => import('../views/PeersView.vue'),
    meta: { title: 'Peer Management' }
  },
  {
    path: '/server/:id/webhooks',
    name: 'webhooks',
    component: () => import('../views/WebhooksView.vue'),
    meta: { title: 'Webhook Management' }
  },
  {
    path: '/settings',
    name: 'settings',
    component: () => import('../views/SettingsView.vue'),
    meta: { title: 'Settings' }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to) => {
  document.title = `${to.meta.title || 'WGRplane'} - WGRplane`
})

export default router
