'use client' import { useState } from 'react' import { ChevronDown, ChevronRight, ExternalLink } from 'lucide-react' import type { KnowledgeUnit } from '@/lib/sdk/advisor/evidence' /** * A source rendered as a hierarchical Knowledge Unit (Regelwerk → Section → Paragraph → Footnote), * not a text-list line. [öffnen] resolves to the original source when available; the optional * snippet lets the user peek the cited text. */ export function KnowledgeUnitCard({ unit }: { unit: KnowledgeUnit }) { const [open, setOpen] = useState(false) const crumbs = [unit.section, unit.subsection, unit.paragraph, unit.footnoteRef].filter(Boolean) const href = unit.open?.originalUrl const canOpen = href && /^https?:\/\//i.test(href) return (
{unit.regulation.short}
{crumbs.length > 0 ? (
{crumbs.map((c, i) => ( {i > 0 && } {c} ))}
) : ( unit.label && unit.label !== unit.regulation.short && (
{unit.label}
) )}
{canOpen && ( öffnen )}
{unit.snippet && (
{open && (

{unit.snippet}

)}
)}
) }