import { ScanViewLayout } from "./components/ScanViewLayout";
import { DiagnosticsView } from "./components/DiagnosticsView";
import { useScanViewController } from "./hooks/useScanViewController";
import type { ScanViewProps } from "./types";

interface ScanViewExtraProps {
  /** "workspace" shows the clean scan surface; "diagnose" shows all dev info. */
  mode?: "workspace" | "diagnose";
  onDemoScan?: () => void;
  canDemoScan?: boolean;
}

export function ScanView({ mode = "workspace", onDemoScan, canDemoScan, ...props }: ScanViewProps & ScanViewExtraProps) {
  const controller = useScanViewController(props);

  if (mode === "diagnose") {
    return (
      <DiagnosticsView
        controller={controller}
        latestCapture={props.latestCapture}
        captureStatus={props.captureStatus}
        onDemoScan={onDemoScan}
        canDemoScan={canDemoScan}
      />
    );
  }

  return <ScanViewLayout {...props} controller={controller} />;
}
