import { ExternalLinkIcon, PlayIcon } from 'lucide-react' import Link from 'next/link' import type { ReactNode } from 'react' import { SpeechExcerpt } from '@/components/campaign/speech/SpeechExcerpt' import { SpeechNestedCuts } from '@/components/campaign/speech/SpeechNestedCuts' import { SpeechResultChips, type SpeechChipGroup, } from '@/components/campaign/speech/SpeechResultChips' import { SpeechResultThumbnail } from '@/components/campaign/speech/SpeechResultThumbnail' import { SpeechLiteralMatchBadge, SpeechSemanticBadges, SpeechSemanticProvenance, } from '@/components/campaign/speech/SpeechSemanticEvidence' import { Button } from '@/components/ui/button' import type { SpeechListItemViewModel } from '@/utilities/speech/speechViewModels' /** * The LLM classifies many topics per speech; the card shows the leading few so * the excerpt keeps the scan path (the detail lists all of them). */ const MAX_TOPIC_CHIPS = 3 const MAX_SCOPE_CHIPS = 2 const MAX_KEYWORD_CHIPS = 3 const MetaSeparator = () => const ActionLink = ({ href, children, variant, fullWidthOnMobile = false, }: { href: string children: ReactNode variant: 'default' | 'outline' | 'ghost' fullWidthOnMobile?: boolean }) => ( ) const SpeechMetaLine = ({ speech, originLabel = false, }: { speech: SpeechListItemViewModel originLabel?: boolean }) => { const items: string[] = [] if (originLabel) items.push('Fala de origem') items.push(speech.speechAtLabel) if (speech.type) items.push(speech.type) if (speech.durationLabel) items.push(speech.durationLabel) if (speech.presidingOfficer) items.push(`Presidiu: ${speech.presidingOfficer}`) return (
{items.map((item, index) => ( {index > 0 ? : null} {item} ))}
) } /** * The primary CTA of every result card: a link to the speech (or its trecho) * whose variant/width the caller owns (C229 adds the theme appearance). */ const SpeechWatchButton = ({ speech, watchLabel, variant, className, }: { speech: SpeechListItemViewModel watchLabel: string variant: 'default' | 'outline' className: string }) => ( ) const SpeechActions = ({ speech, className, fullWidthOnMobile = false, }: { speech: SpeechListItemViewModel className: string fullWidthOnMobile?: boolean }) => (
{speech.officialTextUrl ? ( ) : null}
) export const SpeechResultCard = ({ speech, query, }: { speech: SpeechListItemViewModel /** C174 — the search term, highlighted on the nested cuts. */ query?: string }) => { // C174 (option B): a speech that surfaced only because a cut matched the term // shows the origin note instead of an excerpt the speech does not contain, and // the actions sit at the top right (approved scene 05). C229 — a semantic // result outranks this branch: the evidence lives in the speech itself. if (!speech.matchedTextSearch && !speech.semanticMatch) { return (
{speech.literalFallback ? (
) : null}

A fala não contém o termo exato; ela aparece porque um corte vinculado corresponde à busca.

{speech.cuts.length ? ( ) : null}
) } const chipGroups: SpeechChipGroup[] = [ { key: 'topics', items: speech.topics, max: MAX_TOPIC_CHIPS }, { key: 'scopes', items: speech.scopes, max: MAX_SCOPE_CHIPS }, { key: 'keywords', items: speech.keywords.map((keyword) => ({ value: keyword, label: keyword })), max: MAX_KEYWORD_CHIPS, variant: 'outline', className: 'font-normal text-muted-foreground', }, ] const isTheme = speech.semanticMatch // C229 — a semantic card only offers the trecho seek when the speech really // contains the literal query (a stopword-only segment hit must not claim it). const watchLabel = speech.matchKind === 'segment' && speech.matchedTextSearch ? 'Assistir no trecho' : 'Ver fala' // C229 — the semantic card replaces the common excerpt with the evidence // block; the two never coexist (design gate). const bodyNode = isTheme ? ( ) : ( ) const chips = const hasChips = Boolean(speech.topics.length || speech.scopes.length || speech.keywords.length) return (
{isTheme ? (
) : (
{speech.literalFallback ? (
) : null}
)}
{speech.thumbnailUrl ? (
{bodyNode}
) : ( bodyNode )}
{isTheme ? (
{hasChips ?
{chips}
: }
{speech.officialTextUrl ? ( ) : null}
) : ( <> {hasChips ?
{chips}
: null}
{speech.officialTextUrl ? ( ) : null}
)} {speech.cuts.length ? : null}
) }