'use client' import { useState } from 'react' import { ChevronDown, ChevronRight, ExternalLink } from 'lucide-react' import type { KnowledgeUnit } from '@/lib/sdk/advisor/evidence' import { resolveRegulation } from '@/lib/sdk/advisor/regulation-display' /** * A single evidence unit. Standalone: friendly regulation name + hierarchy. Compact (inside a * document group): chapter/section only (the group already names the regulation). [öffnen] opens * the original source; the optional snippet lets the user peek the cited text. */ export function KnowledgeUnitCard({ unit, compact }: { unit: KnowledgeUnit; compact?: boolean }) { const [open, setOpen] = useState(false) const d = resolveRegulation(unit.regulation) const crumbs = [unit.section, unit.subsection, unit.paragraph, unit.footnoteRef].filter( (x): x is string => Boolean(x), ) const href = unit.open?.originalUrl const canOpen = !!href && /^https?:\/\//i.test(href) let header: string let sub: string[] if (!compact) { header = d.familyLabel sub = crumbs } else if (d.chapter) { header = `Kapitel ${d.chapter}` sub = crumbs } else { header = crumbs[0] || unit.label || d.familyLabel sub = crumbs.slice(1) } return (
{unit.snippet}
)}