// The placeholder shown in the password box when this connection has a
// saved remember-token. The server fixes the expiry at issue time and never
// slides it, so this countdown is honest: it means what it says.
//
// `null` means "there is nothing remembered" — the caller shows an ordinary
// Password placeholder instead.
export function rememberLabel(expiresAt, now = Date.now() / 1000) {
  if (!expiresAt) return null;
  const secondsLeft = expiresAt - now;
  if (secondsLeft <= 0) return null;
  if (secondsLeft < 86400) return 'Remembered until today';
  // Round UP, not down: a token issued for exactly N days reads as "N days"
  // the moment it's issued, not "N-1" the instant a second of it has
  // elapsed. Whole-day boundaries (exactly N*86400 left) still land on N.
  const days = Math.ceil(secondsLeft / 86400);
  return `Remembered for ${days} day${days === 1 ? '' : 's'}`;
}
