'use client' import { CheckCircle2, Lock } from 'lucide-react' export function UsageBadge({ value }: { value: string }) { const config: Record = { allowed: { bg: 'bg-green-100 text-green-800', label: 'Erlaubt' }, restricted: { bg: 'bg-yellow-100 text-yellow-800', label: 'Eingeschraenkt' }, prohibited: { bg: 'bg-red-100 text-red-800', label: 'Verboten' }, unclear: { bg: 'bg-gray-100 text-gray-600', label: 'Unklar' }, yes: { bg: 'bg-green-100 text-green-800', label: 'Ja' }, no: { bg: 'bg-red-100 text-red-800', label: 'Nein' }, 'n/a': { bg: 'bg-gray-100 text-gray-400', label: 'k.A.' }, } const c = config[value] || config.unclear return {c.label} } export function PermBadge({ label, allowed }: { label: string; allowed: boolean }) { return (
{allowed ? : } {label}
) } export function MarkdownRenderer({ content }: { content: string }) { let html = content .replace(/&/g, '&') .replace(//g, '>') html = html.replace( /^```[\w]*\n([\s\S]*?)^```$/gm, (_m, code: string) => `
${code.trimEnd()}
` ) html = html.replace( /^(\|.+\|)\n(\|[\s:|-]+\|)\n((?:\|.+\|\n?)*)/gm, (_m, header: string, _sep: string, body: string) => { const ths = header.split('|').filter((c: string) => c.trim()).map((c: string) => `${c.trim()}` ).join('') const rows = body.trim().split('\n').map((row: string) => { const tds = row.split('|').filter((c: string) => c.trim()).map((c: string) => `${c.trim()}` ).join('') return `${tds}` }).join('') return `${ths}${rows}
` } ) html = html.replace(/^### (.+)$/gm, '

$1

') html = html.replace(/^## (.+)$/gm, '

$1

') html = html.replace(/\*\*(.+?)\*\*/g, '$1') html = html.replace(/`([^`]+)`/g, '$1') html = html.replace(/^- (.+)$/gm, '
  • $1
  • ') html = html.replace(/((?:]*>.*<\/li>\n?)+)/g, '') html = html.replace(/^(\d+)\. (.+)$/gm, '
  • $2
  • ') html = html.replace(/^(?!<[hultdp]|$)(.+)$/gm, '

    $1

    ') return
    }