"use client"; import { Check, CircleAlert, FileAudio, FileText, Film, Library, Loader2, StickyNote, Youtube, } from "lucide-react"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { type ReadingLibraryMaterial } from "@/lib/reading-workspace-api"; import { readingFailureMessage } from "@/lib/reading-failure"; export function iconForMaterial(material: ReadingLibraryMaterial) { if (material.source_kind === "youtube") return Youtube; if (material.source_kind === "bilibili") return Film; if (material.render_mode === "video") return Film; if (material.render_mode === "audio") return FileAudio; return FileText; } export function MenuItem({ icon: Icon, label, onClick, disabled, hint, active, spinning, mobileOnly = false, }: { icon: typeof StickyNote; label: string; onClick: () => void; disabled?: boolean; /** A second line under the label — why it is disabled, or what it acts on. */ hint?: string; /** A setting that is on. Toggles report it; plain actions leave it unset. */ active?: boolean; spinning?: boolean; /** Below `md` only: a desktop control the converged mobile header moved here. */ mobileOnly?: boolean; }) { return ( ); } export function CompanionWelcome({ hasMaterial }: { hasMaterial: boolean }) { const { t } = useTranslation(); return (

{t("Read and ask as you go")}

{hasMaterial ? t( "Select any passage to ask about it, explain it or translate it — or just ask below. Answers point back to the page they come from.", ) : t("Add material to begin a reading conversation.")}

); } /** * A page with one line picked out — the gesture the panel is waiting for, * drawn instead of an icon that stands for "AI". Theme tokens only, so it * follows light and dark without a second drawing. */ function SelectPassageMark() { const line = "fill-[color-mix(in_srgb,var(--muted-foreground)_22%,transparent)]"; return ( ); } export function EmptyWorkspace({ onAdd }: { onAdd: () => void }) { const { t } = useTranslation(); return (

{t("Add material to begin")}

); } export function MaterialProcessing({ material, }: { material: ReadingLibraryMaterial; }) { const { t } = useTranslation(); return (

{t("Preparing {{title}}", { title: material.title })}

{t("Extracting structure and grounded passages…")} {material.progress}%

); } export function MaterialFailure({ material, onRetry, }: { material: ReadingLibraryMaterial; onRetry: () => Promise; }) { const { t } = useTranslation(); const [retrying, setRetrying] = useState(false); const [retryError, setRetryError] = useState(""); const retry = async () => { setRetrying(true); setRetryError(""); try { await onRetry(); } catch (caught) { setRetryError( caught instanceof Error ? caught.message : t("Try importing this material again."), ); } finally { setRetrying(false); } }; return (

{t("This material could not be prepared")}

{readingFailureMessage(material, t) || t("Try importing this material again.")}

{retryError && (

{retryError}

)}
); }