import { fmt } from '@/lib/format'; import type { ServiceDetail, TargetRow } from '@/lib/types'; /** z → colour: |z|<1.5 neutral, <3 elevated, <5 high, ≥5 severe; failing cell = severe outline. */ function zColor(z: number, ok: boolean): string { if (!ok) return 'var(--p-severe)'; const a = Math.abs(z); if (a < 1) return 'var(--panel-2)'; if (a < 1.5) return 'rgba(76,201,240,0.25)'; if (a < 3) return 'rgba(233,196,106,0.45)'; if (a < 5) return 'rgba(231,111,81,0.6)'; return 'rgba(214,40,40,0.75)'; } export function ProbeTargetMatrix({ matrix, targets }: { matrix: ServiceDetail['matrix']; targets: TargetRow[] }) { if (!matrix.length || !targets.length) return

No matrix available.

; const cols = targets.map((t) => t.target_id); return (
{targets.map((t) => ( ))} {matrix.map((row) => { const byId = new Map(row.targets.map((c) => [c.target_id, c])); return ( {cols.map((id) => { const c = byId.get(id); return ( ); })} ); })}
probe \ target {t.name.replace(/^.*· /, '')}
{row.probe_id} {row.probe_region} = 3 || !c.ok) ? '#fff' : 'var(--ink-2)', outline: c && !c.ok ? '1px solid var(--p-severe)' : undefined }} title={c ? `${row.probe_id} → ${id}\nTTFB ${fmt(c.ttfb_ms, 0)} ms · z ${fmt(c.z)} · ${c.ok ? 'ok' : 'FAILING'}` : 'not measured'}> {c ? (c.ok ? fmt(c.z, 1) : '×') : '·'}
); }