import type { LeadActivity } from '@/types/entities';
import { daysAgo } from './factories';
import { mockLeads } from './leads';

// Use stable lead IDs for activities
const lead1 = mockLeads[0].id;    // new lead
const lead2 = mockLeads[1].id;    // new lead
const contacted1 = mockLeads[20].id; // first contacted lead
const contacted2 = mockLeads[21].id;
const qualified1 = mockLeads[30].id; // first qualified lead
const appt1 = mockLeads[35].id;      // first appointment lead
const converted1 = mockLeads[40].id; // first converted lead
const spam1 = mockLeads[45].id;      // first spam lead

export const mockLeadActivities: LeadActivity[] = [
    {
        id: 'activity-1',
        createdAt: daysAgo(2),
        activityType: 'STATUS_CHANGE',
        summary: 'Lead status changed from NEW to CONTACTED',
        occurredAt: daysAgo(2),
        performedBy: 'Rekha S.',
        previousValue: 'NEW',
        newValue: 'CONTACTED',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: contacted1,
    },
    {
        id: 'activity-2',
        createdAt: daysAgo(1.8),
        activityType: 'WHATSAPP_SENT',
        summary: 'WhatsApp message sent — Women\'s Day Checkup template',
        occurredAt: daysAgo(1.8),
        performedBy: 'Rekha S.',
        previousValue: null,
        newValue: null,
        channel: 'WHATSAPP',
        durationSeconds: null,
        outcome: 'INFORMATION_SENT',
        leadId: contacted1,
    },
    {
        id: 'activity-3',
        createdAt: daysAgo(3),
        activityType: 'ASSIGNED',
        summary: 'Lead assigned to Suresh P.',
        occurredAt: daysAgo(3),
        performedBy: 'System',
        previousValue: null,
        newValue: 'Suresh P.',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: contacted2,
    },
    {
        id: 'activity-4',
        createdAt: daysAgo(2.5),
        activityType: 'CALL_MADE',
        summary: 'Outbound call — patient confirmed interest in IVF consultation',
        occurredAt: daysAgo(2.5),
        performedBy: 'Suresh P.',
        previousValue: null,
        newValue: null,
        channel: 'PHONE',
        durationSeconds: 342,
        outcome: 'SUCCESSFUL',
        leadId: contacted2,
    },
    {
        id: 'activity-5',
        createdAt: daysAgo(4),
        activityType: 'STATUS_CHANGE',
        summary: 'Lead status changed from CONTACTED to QUALIFIED',
        occurredAt: daysAgo(4),
        performedBy: 'Suresh P.',
        previousValue: 'CONTACTED',
        newValue: 'QUALIFIED',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: qualified1,
    },
    {
        id: 'activity-6',
        createdAt: daysAgo(3.5),
        activityType: 'NOTE_ADDED',
        summary: 'Patient is 32 years old, trying for 3 years, interested in IVF with donor eggs. Has been evaluated at another clinic — bring reports.',
        occurredAt: daysAgo(3.5),
        performedBy: 'Suresh P.',
        previousValue: null,
        newValue: null,
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: qualified1,
    },
    {
        id: 'activity-7',
        createdAt: daysAgo(5),
        activityType: 'STATUS_CHANGE',
        summary: 'Lead status changed from QUALIFIED to APPOINTMENT_SET',
        occurredAt: daysAgo(5),
        performedBy: 'Rekha S.',
        previousValue: 'QUALIFIED',
        newValue: 'APPOINTMENT_SET',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: appt1,
    },
    {
        id: 'activity-8',
        createdAt: daysAgo(4.8),
        activityType: 'WHATSAPP_SENT',
        summary: 'Appointment confirmation sent via WhatsApp — IVF Free Consultation template',
        occurredAt: daysAgo(4.8),
        performedBy: 'System',
        previousValue: null,
        newValue: null,
        channel: 'WHATSAPP',
        durationSeconds: null,
        outcome: 'INFORMATION_SENT',
        leadId: appt1,
    },
    {
        id: 'activity-9',
        createdAt: daysAgo(7),
        activityType: 'CONVERTED',
        summary: 'Lead successfully converted — Patient record created (ID: patient-mock-1045)',
        occurredAt: daysAgo(7),
        performedBy: 'Meena K.',
        previousValue: 'APPOINTMENT_SET',
        newValue: 'CONVERTED',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: 'SUCCESSFUL',
        leadId: converted1,
    },
    {
        id: 'activity-10',
        createdAt: daysAgo(0.2),
        activityType: 'MARKED_SPAM',
        summary: 'Lead flagged as spam — spam score 87, invalid phone number pattern',
        occurredAt: daysAgo(0.2),
        performedBy: 'System',
        previousValue: 'false',
        newValue: 'true',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: spam1,
    },
    {
        id: 'activity-11',
        createdAt: daysAgo(0.5),
        activityType: 'DUPLICATE_DETECTED',
        summary: 'Duplicate lead detected — same phone number as lead-new-1',
        occurredAt: daysAgo(0.5),
        performedBy: 'System',
        previousValue: null,
        newValue: lead1,
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: mockLeads[47].id, // lead-dup-1
    },
    {
        id: 'activity-12',
        createdAt: daysAgo(0.1),
        activityType: 'ASSIGNED',
        summary: 'Lead auto-assigned to Rekha S. based on availability',
        occurredAt: daysAgo(0.1),
        performedBy: 'System',
        previousValue: null,
        newValue: 'Rekha S.',
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: lead2,
    },
    {
        id: 'activity-13',
        createdAt: daysAgo(1.2),
        activityType: 'CALL_MADE',
        summary: 'Outbound call — no answer, will retry tomorrow',
        occurredAt: daysAgo(1.2),
        performedBy: 'Rekha S.',
        previousValue: null,
        newValue: null,
        channel: 'PHONE',
        durationSeconds: 15,
        outcome: 'NO_ANSWER',
        leadId: contacted1,
    },
    {
        id: 'activity-14',
        createdAt: daysAgo(6),
        activityType: 'FOLLOW_UP_CREATED',
        summary: 'Follow-up scheduled for callback — patient requested call after office hours',
        occurredAt: daysAgo(6),
        performedBy: 'Suresh P.',
        previousValue: null,
        newValue: null,
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: 'CALLBACK_REQUESTED',
        leadId: qualified1,
    },
    {
        id: 'activity-15',
        createdAt: daysAgo(8),
        activityType: 'NOTE_ADDED',
        summary: 'Senior Health Package — patient is 68 years old, diabetic, requested cardiac screening add-on. Budget sensitive — offered 10% senior discount.',
        occurredAt: daysAgo(8),
        performedBy: 'Meena K.',
        previousValue: null,
        newValue: null,
        channel: 'SYSTEM',
        durationSeconds: null,
        outcome: null,
        leadId: converted1,
    },
];
