"use client";
import type { ElementType } from "react";
import {
CheckCircle2,
ClipboardList,
FileQuestion,
FileText,
GraduationCap,
Layers3,
Moon,
Video,
} from "lucide-react";
import type { StudentDashboard } from "@/lib/api/dashboard";
import type { ApiDocument, VideoRenderJob } from "@/lib/api/types";
import type { StudyIntent } from "@/lib/study-intents";
import type { ChatMessage } from "./types";
import { cardDisplayTitle, contextLabel, documentKindLabel, documentStatusLabel, formatDate } from "./utils";
import { PanelBlock, ToolCard } from "./WorkspacePanelPrimitives";
export function RecentOutputs({
messages,
dashboard,
videoJobs,
}: {
messages: ChatMessage[];
dashboard: StudentDashboard | null;
videoJobs: VideoRenderJob[];
}) {
const generatedOutputs = messages
.filter((message) => message.card && message.card.kind !== "loading" && message.card.kind !== "error")
.slice(-4)
.reverse();
const dashboardOutputs = dashboard?.recent_results.slice(0, 3) ?? [];
return (
{generatedOutputs.length === 0 && dashboardOutputs.length === 0 && videoJobs.length === 0 ? (
Recent notes, quizzes, flashcards, video plans, and render jobs will appear here.
) : null}
{generatedOutputs.map((message) => (
{message.card ? cardDisplayTitle(message.card) : message.text}
{message.text}
))}
{dashboardOutputs.map((result) => (
{result.label}
{result.source_title} - {formatDate(result.created_at)}
))}
{videoJobs.slice(0, 3).map((job) => (
))}
);
}
export function RightWorkspacePanel({
documents,
selectedDocuments,
messages,
dashboard,
videoJobs,
onAction,
onUpload,
}: {
documents: ApiDocument[];
selectedDocuments: ApiDocument[];
messages: ChatMessage[];
dashboard: StudentDashboard | null;
videoJobs: VideoRenderJob[];
onAction: (intent: StudyIntent, prompt: string) => void;
onUpload: () => void;
}) {
const sourceContext = selectedDocuments.length ? contextLabel(selectedDocuments, documents) : "your selected source";
const readyCount = documents.filter((document) => document.status === "ready").length;
const paperCount = documents.filter((document) => document.material_type === "question_paper" || /pyq|question paper|previous/i.test(document.title)).length;
const tools: Array<{ label: string; description: string; intent: StudyIntent; prompt: string; icon: ElementType }> = [
{ label: "Notes", description: "Exam-ready scoring notes", intent: "generate_notes", prompt: `Make exam-ready notes from ${sourceContext}.`, icon: FileText },
{ label: "Quiz", description: "Active recall with traps", intent: "generate_quiz", prompt: `Create a quiz from ${sourceContext} with answers and explanations.`, icon: FileQuestion },
{ label: "Flashcards", description: "Fast memory cards", intent: "generate_flashcards", prompt: `Make flashcards from ${sourceContext}.`, icon: Layers3 },
{ label: "Study Video", description: "Scene plan plus builder handoff", intent: "create_video_plan", prompt: `Create a study video plan from ${sourceContext}.`, icon: Video },
{ label: "PYQ Analysis", description: paperCount ? "Use uploaded papers" : "Material-only until papers exist", intent: "analyze_pyq", prompt: `Analyze PYQ patterns from ${sourceContext}. Be explicit about available evidence.`, icon: GraduationCap },
{ label: "Study Plan", description: "Rank what scores first", intent: "continue_learning", prompt: `Build a study plan from ${sourceContext}.`, icon: ClipboardList },
{ label: "Last Night Revision", description: "Tonight-only priorities", intent: "create_revision_plan", prompt: `Make a last-night revision plan from ${sourceContext}.`, icon: Moon },
{ label: "Exam Mode", description: "Board-style answers", intent: "generate_exam_answer", prompt: `Create exam-mode answers from ${sourceContext}.`, icon: CheckCircle2 },
];
return (
);
}