import { useParams } from 'react-router';
import { lazy, Suspense } from 'react';
import { PageLoader } from '../../components/PageLoader';

const AgentHealth = lazy(() => import('../AgentHealth/AgentHealth'));
const AgentInstance = lazy(() => import('../AgentInstance/AgentInstance'));

export default function RuntimePage() {
  const { instanceId } = useParams<{ appId?: string; instanceId?: string }>();

  if (instanceId) {
    return <Suspense fallback={<PageLoader />}><AgentInstance /></Suspense>;
  }
  return <Suspense fallback={<PageLoader />}><AgentHealth /></Suspense>;
}
