import { formatDuration, formatDistance, formatPace, formatHeartRate, formatCadence } from '../../utils/format' const RUNNING_TYPES = new Set(['running', 'hiking', 'walking']) export default function LapTable({ laps, sportType, lapBests }) { const showPower = !RUNNING_TYPES.has(sportType?.toLowerCase()) const hasBests = lapBests && Object.keys(lapBests).length > 0 return (
{hasBests && } {hasBests && } {showPower && } {laps.map((lap) => { const best = hasBests ? lapBests[String(lap.lap_number)] : null const delta = best != null && lap.duration_s != null ? lap.duration_s - best : null const isBest = delta != null && delta <= 0.5 return ( {hasBests && ( )} {hasBests && ( )} {showPower && ( )} ) })}
Lap Distance TimeBestΔPace Avg HR CadencePower
{lap.lap_number} {formatDistance(lap.distance_m)} {formatDuration(lap.duration_s)}{best != null ? formatDuration(best) : '--'} {delta == null ? '--' : isBest ? '🏆' : `${delta > 0 ? '+' : '−'}${formatDuration(Math.abs(delta))}`} {formatPace(lap.avg_speed_ms, sportType)} {formatHeartRate(lap.avg_heart_rate)} {lap.avg_cadence ? formatCadence(lap.avg_cadence, sportType) : '--'} {lap.avg_power ? `${Math.round(lap.avg_power)} W` : '--'}
) }