import { BrowserRouter, Route, Routes } from 'react-router-dom'
import { HomePage } from '@pages/home'
import { WalletPage } from '@pages/wallet'
import { SwapPage } from '@pages/swap'
import { BridgePage } from '@pages/bridge'
import { ProfilePage } from '@pages/profile'
import { LoginPage } from '@pages/login'
import { RegisterPage } from '@pages/register'
import { ConverterPage } from '@pages/converter'
import { SeedPhrasePage } from '@pages/seed-phrase'
import { KycPage } from '@pages/kyc'
import { RestorePasswordPage } from '@pages/restore-password'
import { PublichnayaOfertaPage } from '@pages/publichnaya-oferta'
import { PolitikaPage } from '@pages/politika-personalnyh-dannyh'
import { PolitikaCookiePage } from '@pages/politika-cookie'
import { SoglasiePage } from '@pages/soglasie-personalnyh-dannyh'
import { ReestryPage } from '@pages/reestr-pd-rkn'
import { TransactionsPage } from '@pages/transactions'
import { WalletLayout } from '@widgets/wallet-layout'
import { ROUTES } from '@shared/config/routes'
import { ScrollToTop } from './ScrollToTop'
import { ProtectedRoute } from './ProtectedRoute'
import { GuestRoute } from './GuestRoute'

export function RouterProvider() {
  return (
    <BrowserRouter>
      <ScrollToTop />
      <Routes>
        <Route path={ROUTES.HOME} element={<HomePage />} />
        <Route path={ROUTES.PUBLICHNAYA_OFERTA} element={<PublichnayaOfertaPage />} />
        <Route path={ROUTES.POLITIKA_PERSONALNYH_DANNYH} element={<PolitikaPage />} />
        <Route path={ROUTES.POLITIKA_COOKIE} element={<PolitikaCookiePage />} />
        <Route path={ROUTES.SOGLASIE_PERSONALNYH_DANNYH} element={<SoglasiePage />} />
        <Route path={ROUTES.REESTR_PD_RKN} element={<ReestryPage />} />

        <Route element={<GuestRoute />}>
          <Route path={ROUTES.LOGIN} element={<LoginPage />} />
          <Route path={ROUTES.REGISTER} element={<RegisterPage />} />
          <Route path={ROUTES.RESTORE_PASSWORD} element={<RestorePasswordPage />} />
        </Route>

        <Route element={<ProtectedRoute />}>
          <Route element={<WalletLayout footer center />}>
            <Route path={ROUTES.CONVERTER} element={<ConverterPage />} />
          </Route>

          <Route element={<WalletLayout footer />}>
            <Route path={ROUTES.SWAP} element={<SwapPage />} />
            <Route path={ROUTES.BRIDGE} element={<BridgePage />} />
            <Route path={ROUTES.TRANSACTIONS} element={<TransactionsPage />} />
          </Route>

          <Route path={ROUTES.WALLET} element={<WalletPage />} />
          <Route path={ROUTES.WALLET_CHAIN} element={<WalletPage />} />
          <Route path={ROUTES.PROFILE} element={<ProfilePage />} />
          <Route path={ROUTES.SEED_PHRASE} element={<SeedPhrasePage />} />
          <Route path={ROUTES.KYC} element={<KycPage />} />
        </Route>
      </Routes>
    </BrowserRouter>
  )
}
