import EvidenceDetails from './evidence-details'; import { publicReference, publicSourceHref } from '@/lib/public-presentation'; type Source = { title?: string | null; url?: string | null; source_date?: string | null; supports?: string | null; }; export default function PublicSourceList({ sources }: { sources?: Source[] }) { const rows = new Map< string, { title: string; url?: string; date?: string | null; supports: string[]; } >(); for (const source of sources ?? []) { const url = publicSourceHref(source.url), title = publicReference(source.title) || (url ? new URL(url).hostname : null); if (!title) continue; const key = JSON.stringify([url || title, source.source_date || '']); const row = rows.get(key) ?? { title, url, date: source.source_date, supports: [], }; const support = publicReference(source.supports); if (support && !row.supports.includes(support)) row.supports.push(support); rows.set(key, row); } if (!rows.size) return null; return ( ); }