import Link from 'next/link'; import { Empty, PNum, StatusDot } from '@/components/ui/primitives'; import { fmt, fmtInt, fmtMs, fmtPct } from '@/lib/format'; import { Time } from '@/lib/time'; import type { CountryTargetRow, LatencyPair, Probe, TargetRow } from '@/lib/types'; export function TargetsTable({ targets, showCategory = false }: { targets: (TargetRow | CountryTargetRow)[]; showCategory?: boolean }) { if (!targets.length) return No target anchored in this scope.; const sorted = [...targets].sort((a, b) => b.pressure - a.pressure); return (
{showCategory && } {sorted.map((t) => ( {showCategory && } ))}
TargetCategoryPressure OK 1h TTFB p50
{t.name} {t.target_id} {'category' in t ? t.category : '—'} {fmtPct(t.ok_ratio_1h, 1)} {fmtMs(t.ttfb_ms_median)}
); } export function ProbesTable({ probes, compact = false }: { probes: Probe[]; compact?: boolean }) { if (!probes.length) return No probe in this scope — pressure here is the destination view only.; return (
{!compact && ( <> )} {probes.map((p) => ( {!compact && ( <> )} ))}
Probe Status Location Provider ASNMeas./h Uptime 24h Clock Version CapabilitiesLast seen
{p.probe_id} {p.name} {p.city}, {p.country} ·{' '} {p.region} {p.provider} {p.asn} {fmtInt(p.measurements_1h)} {fmtPct(p.uptime_24h, 1)} 50 ? 'var(--warn)' : undefined }}> {p.clock_offset_ms > 0 ? '+' : ''} {p.clock_offset_ms} ms {p.version} {p.capabilities.join(' · ')}
); } export function LatencyMatrixTable({ rows, highlight }: { rows: LatencyPair[]; highlight?: string }) { if (!rows.length) return No inter-region latency pairs for this scope.; return (
{rows.map((m) => { const d = m.rtt_ms - m.rtt_ms_baseline; return ( ); })}
From To RTT Baseline Δ TTFB Loss z Pairs
{m.from} {m.to} {fmtMs(m.rtt_ms, 1)} {fmtMs(m.rtt_ms_baseline, 1)} 5 ? 'var(--p-stressed)' : d < -5 ? 'var(--p-calm)' : 'var(--ink-2)' }}> {d > 0 ? '+' : ''} {fmt(d, 1)} {fmtMs(m.ttfb_ms)} = 1 ? 'var(--p-high)' : 'var(--ink)' }}> {fmt(m.loss_pct)} % = 3 ? 'var(--p-high)' : Math.abs(m.z) >= 1.5 ? 'var(--p-elevated)' : 'var(--ink)' }}> {fmt(m.z)} {fmtInt(m.pairs)}
); } export function LinkList({ items, hrefFor, label }: { items: { key: string; name: string; pressure: number; sub?: string }[]; hrefFor: (k: string) => string; label: string }) { if (!items.length) return No {label} in this scope.; return ( ); }