// ─── Activity Log Helper ───────────────────────────────────────────────
// Moved from store-modules/activity-log.ts to eliminate legacy dependencies

import type { ActivityEventType, ActivityLogEntry } from '../types';

function createActivityEntry(
  eventType: string,
  message: string,
  details?: ActivityLogEntry['details']
): ActivityLogEntry {
  return {
    id: `act_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
    timestamp: Date.now(), // Use timestamp for ordering
    eventType: eventType as ActivityEventType,
    message,
    details,
  };
}

export function addActivityLogEntry(
  state: { activityLog: ActivityLogEntry[] },
  eventType: string,
  message: string,
  details?: ActivityLogEntry['details']
): ActivityLogEntry[] {
  const entry = createActivityEntry(eventType, message, details);
  // Keep last 50 entries, newest first
  return [entry, ...state.activityLog.slice(0, 49)];
}
