/** * Bucket a week's event count into a 0–4 intensity level for the * sync-coverage heatmap, relative to the busiest week (`maxCount`). * * Pure view-model helper shared by the desktop and hub `SyncHeatmap` * components so the intensity thresholds have a single source of truth * (OPL-2525). The per-app colour treatment (cyan-glow on the hub, * GitHub-style on desktop) stays local — only the bucketing is shared. * * Kept in its own dependency-free module (exported at * `@scribe.cool/core/sync/activity-level`) so `"use client"` components can * import it without pulling the server-only sync engine (`node:zlib`) from * the `./sync` barrel into the client bundle. * * @returns 0 when there is no activity, otherwise 1–4 by quartile. */ export function getActivityLevel(count: number, maxCount: number): number { if (count === 0) return 0; const normalized = count / maxCount; if (normalized < 0.25) return 1; if (normalized < 0.5) return 2; if (normalized < 0.75) return 3; return 4; }