import { subtitleLanguages } from '../../../shared/subtitle-languages'; import { useEffect, useRef, useState } from 'react'; import type { TranscriptDocument } from '../../../shared/transcript'; import { transcriptWorkflowPrompt } from '../../../shared/transcript-workflow'; import { defaultPlatformExportTarget, platformExportTargets, type PlatformExportTarget } from '../../../shared/platform-export'; import { useI18n } from '../i18n/I18n'; import { useStudioShellContext } from '../contexts/StudioContext'; import { Button } from 'open-design-ui/button'; import { RemixIcon } from '../icons/RemixIcons'; import { useIntegrationInfo } from './useIntegrationInfo'; import { SettingsError, SettingsLoading } from './settingsPrimitives'; export function TranscriptWorkflowBrief({ projectId, sourcePaths, transcript }: { projectId: string; sourcePaths: string[]; transcript: TranscriptDocument | null }) { const { t, locale } = useI18n(), shell = useStudioShellContext(); const { info, failed, retry } = useIntegrationInfo(); const [platforms, setPlatforms] = useState(() => [defaultPlatformExportTarget(locale)]); const [languages, setLanguages] = useState([]); const [links, setLinks] = useState(''), [otherPlatforms, setOtherPlatforms] = useState(''), [otherLanguages, setOtherLanguages] = useState(''), [notes, setNotes] = useState(''); const [goal, setGoal] = useState<'highlights' | 'adapt'>('highlights'), [busy, setBusy] = useState(false), [manual, setManual] = useState(''); const [more, setMore] = useState(false); const alive = useRef(true), lock = useRef(false); const sourceIdentity = JSON.stringify(sourcePaths); useEffect(() => { alive.current = true; return () => { alive.current = false; }; }, []); useEffect(() => setManual(''), [links, platforms, languages, otherPlatforms, otherLanguages, notes, goal, transcript, sourceIdentity, projectId]); const sourceLanguage = languages.length === 0 && !otherLanguages.trim(); const selectedPlatforms = platformExportTargets.filter(target => platforms.includes(target.id)); const targets = [...selectedPlatforms.map(target => `${target.label} (${target.aspect}, ${target.width}×${target.height})`), otherPlatforms.trim()].filter(Boolean).join(', '); const requestedLanguages = [...subtitleLanguages.filter(language => languages.includes(language.id)).map(language => language.name), otherLanguages.trim()].filter(Boolean).join(', '); const platformSummary = [...selectedPlatforms.map(target => t(target.label)), otherPlatforms.trim()].filter(Boolean).join(' · '); const languageSummary = sourceLanguage ? t('Source language') : [...subtitleLanguages.filter(language => languages.includes(language.id)).map(language => language.label), otherLanguages.trim()].filter(Boolean).join(' · '); const field = (label: string, value: string, change: (v: string) => void, multiline = false) =>