import { useTranslation } from "react-i18next" import { RefreshCw, Check, Trash2 } from "lucide-react" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" interface SettingsDialogProps { open: boolean onClose: () => void // Language currentLang: string onToggleLang: () => void // Ollama + OpenAI models models: string[] ollamaUp: boolean | null refreshing: boolean onRefresh: () => void openaiModels: { llm: string[]; vlm: string[]; embed: string[] } // LLM model currentModel: string onModelChange: (e: React.ChangeEvent) => void // OCR model currentOcrModel: string onOcrModelChange: (e: React.ChangeEvent) => void // VLM model currentVlmModel: string onVlmModelChange: (e: React.ChangeEvent) => void // Embedding model openaiKeyConfigured: boolean currentEmbedModel: string onEmbedModelChange: (e: React.ChangeEvent) => void // OpenAI key showKeyInput: boolean setShowKeyInput: (v: boolean) => void keyDraft: string setKeyDraft: (v: string) => void savingKey: boolean keyError: string onSaveKey: (e: React.FormEvent) => void onDeleteKey: () => void } const OCR_MODELS = ["easyocr", "vlm", "paddleocr", "trocr"] export default function SettingsDialog({ open, onClose, models, ollamaUp, refreshing, onRefresh, openaiModels, currentModel, onModelChange, currentOcrModel, onOcrModelChange, currentVlmModel, onVlmModelChange, openaiKeyConfigured, currentEmbedModel, onEmbedModelChange, showKeyInput, setShowKeyInput, keyDraft, setKeyDraft, savingKey, keyError, onSaveKey, onDeleteKey, currentLang, onToggleLang, }: SettingsDialogProps) { const { t } = useTranslation() return ( { if (!v) onClose() }}>
{t("nav.settings")}
{/* LLM model */}
{ollamaUp === false && openaiModels.llm.length === 0 ? (

{t("config.model_offline")}

) : models.length === 0 && openaiModels.llm.length === 0 ? (

{t("config.model_loading")}

) : ( )}
{/* OCR model */}
{/* VLM model */}
{models.length === 0 && openaiModels.vlm.length === 0 ? (

{t("config.model_loading")}

) : ( )}
{/* Embedding model (only when OpenAI key configured) */} {openaiKeyConfigured && (
)} {/* OpenAI API key */}
{openaiKeyConfigured && !showKeyInput ? (
{t("config.openai_key_ok")}
) : !showKeyInput ? (

{t("config.openai_key_missing")}

) : null} {showKeyInput && (
{ setKeyDraft(e.target.value) }} placeholder="sk-…" className="flex-1 min-w-0 rounded border bg-background px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-ring" />
)} {keyError &&

{keyError}

}
{/* Language */}
) }