// Miles are the primary distance unit across the site. Km appears
// parenthetically so metric readers aren't lost. Keep this in sync
// with Microwaveprop.Format.distance_km/1 on the server side.
export function formatDistanceKm(km: number | null | undefined): string {
  if (km == null) return "—"
  const mi = km / 1.609344
  if (mi < 10) {
    return `${mi.toFixed(1)} mi (${km.toFixed(1)} km)`
  }
  return `${Math.round(mi)} mi (${Math.round(km)} km)`
}
