import { lazy, Suspense } from 'react'
import { Routes, Route } from 'react-router'
import { Layout } from './components/Layout'
import { Dashboard } from './pages/Dashboard'
import { KnowledgeBase } from './pages/KnowledgeBase'
import { Assistant } from './pages/Assistant'
import { Downloads } from './pages/Downloads'
import { Maps } from './pages/Maps'
import { About } from './pages/About'

// Peržiūra įkelia žemėlapių variklį (MapLibre) — užkraunama tik pareikalavus,
// kad pagrindinis paketas liktų lengvas.
const Preview = lazy(() =>
  import('./pages/Preview').then((m) => ({ default: m.Preview }))
)

export default function App() {
  return (
    <Routes>
      <Route element={<Layout />}>
        <Route path="/" element={<Dashboard />} />
        <Route path="/knowledge" element={<KnowledgeBase />} />
        <Route path="/assistant" element={<Assistant />} />
        <Route path="/downloads" element={<Downloads />} />
        <Route
          path="/preview/:id"
          element={
            <Suspense fallback={<p className="text-arka-muted">…</p>}>
              <Preview />
            </Suspense>
          }
        />
        <Route path="/maps" element={<Maps />} />
        <Route path="/about" element={<About />} />
      </Route>
    </Routes>
  )
}
