"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.")}
{t("Add material to begin")}
{t("Preparing {{title}}", { title: material.title })}
{t("Extracting structure and grounded passages…")} {material.progress}%
{t("This material could not be prepared")}
{readingFailureMessage(material, t) || t("Try importing this material again.")}
{retryError && ({retryError}
)}