import { TestcasePanel } from "@/features/problems/testcase/panel";
import { BotPanel } from "@/features/problems/bot/components/panel";
import { CodePanel } from "@/features/problems/code/components/panel";
import { DetailPanel } from "@/features/problems/detail/components/panel";
import { DetailTabSync } from "@/features/problems/detail/components/tab-sync";
import { SolutionPanel } from "@/features/problems/solution/components/panel";
import { SubmissionPanel } from "@/features/problems/submission/components/panel";
import { DescriptionPanel } from "@/features/problems/description/components/panel";
import { ProblemFlexLayout } from "@/features/problems/components/problem-flexlayout";
import { SubmissionRealtimeListener } from "@/features/problems/submission/components/realtime-listener";

interface ProblemViewProps {
  problemId: string;
  submissionId: string | undefined;
}

export const ProblemView = ({ problemId, submissionId }: ProblemViewProps) => {
  const components: Record<string, React.ReactNode> = {
    description: <DescriptionPanel problemId={problemId} />,
    solution: <SolutionPanel problemId={problemId} />,
    submission: <SubmissionPanel problemId={problemId} />,
    detail: <DetailPanel submissionId={submissionId} />,
    code: <CodePanel problemId={problemId} />,
    testcase: <TestcasePanel problemId={problemId} />,
    bot: <BotPanel problemId={problemId} submissionId={submissionId} />,
  };

  return (
    <div className="relative flex h-full w-full">
      <DetailTabSync submissionId={submissionId} />
      <SubmissionRealtimeListener problemId={problemId} />
      <ProblemFlexLayout components={components} />
    </div>
  );
};
