import { Routes, Route, Navigate } from 'react-router-dom';
import Layout from './components/Layout';
import ErrorBoundary from './components/ErrorBoundary';
import Landing from './pages/Landing';
import Dashboard from './pages/Dashboard';
import CharacterList from './pages/CharacterList';
import CharacterCreate from './pages/CharacterCreate';
import CharacterDetail from './pages/CharacterDetail';
import Templates from './pages/Templates';
import Analytics from './pages/Analytics';
import Settings from './pages/Settings';
import SettingsAPI from './pages/SettingsAPI';
import SettingsPersona from './pages/SettingsPersona';
import GettingStarted from './pages/GettingStarted';
import Messages from './pages/telegram/Messages';
import StarsRevenue from './pages/telegram/StarsRevenue';
import TelegramManagement from './pages/telegram/TelegramManagement';
import ConversationDetail from './pages/telegram/ConversationDetail';
import Channels from './pages/telegram/Channels';
import Webhooks from './pages/telegram/Webhooks';
import ImageGenerate from './pages/ImageGenerate';

const App: React.FC = () => {
  return (
    <ErrorBoundary>
      <Routes>
        <Route path="/" element={<Landing />} />
        <Route element={<Layout />}>
          <Route path="/dashboard" element={<Dashboard />} />
          <Route path="/characters" element={<CharacterList />} />
          <Route path="/characters/new" element={<CharacterCreate />} />
          <Route path="/characters/:id" element={<ErrorBoundary><CharacterDetail /></ErrorBoundary>} />
          <Route path="/characters/:id/telegram" element={<TelegramManagement />} />
          <Route path="/characters/:characterId/conversations/:userId" element={<ConversationDetail />} />
          <Route path="/templates" element={<Templates />} />
          <Route path="/image-generate" element={<ImageGenerate />} />
          <Route path="/analytics" element={<Analytics />} />
          <Route path="/settings" element={<Settings />} />
          <Route path="/settings/api" element={<SettingsAPI />} />
          <Route path="/settings/persona" element={<SettingsPersona />} />
          <Route path="/guide" element={<GettingStarted />} />
          <Route path="/conversations" element={<Messages />} />
          <Route path="/telegram/messages" element={<Messages />} />
          <Route path="/telegram/stars" element={<StarsRevenue />} />
          <Route path="/telegram/channels" element={<Channels />} />
          <Route path="/telegram/webhooks" element={<Webhooks />} />
          <Route path="/telegram/bot-tokens" element={<Navigate to="/settings" replace />} />
          <Route path="/telegram/bots" element={<Navigate to="/settings" replace />} />
        </Route>
      </Routes>
    </ErrorBoundary>
  );
};

export default App;