import type { LayerExplanation } from '@/config/map-layer-definitions'; import { escapeHtml } from '@/utils/sanitize'; export function renderLayerExplanationCard(layerLabel: string, explanation: LayerExplanation): string { const list = (items: string[]): string => items.map(item => `
  • ${escapeHtml(item)}
  • `).join(''); const related = explanation.related.length > 0 ? explanation.related.map(item => `${escapeHtml(item)}`).join('') : 'Layer guide'; const evidence = explanation.evidence.length > 0 ? `
    Grounded in${explanation.evidence.map(item => `${escapeHtml(item)}`).join('')}
    ` : ''; const coverageLabel = explanation.coverage === 'curated' ? 'Curated v1' : 'Fallback'; return `
    ${escapeHtml(explanation.category)} ${escapeHtml(layerLabel)}
    ${coverageLabel}

    ${escapeHtml(explanation.purpose)}

    Source

    ${escapeHtml(explanation.source)}

    Freshness

    ${escapeHtml(explanation.freshness)}

    Confidence

    ${escapeHtml(explanation.confidence)}

    Limitations
    Related
    ${evidence}
    `; }