import { faker } from '@faker-js/faker';

export interface ChatSession {
    id: string;
    title: string;
    date: string; // ISO string
    preview: string;
    tags: string[];
    status: 'active' | 'completed';
    messages: Array<{
        id: string;
        role: 'user' | 'assistant';
        content: string;
        timestamp: number;
    }>;
}

export const createChatSession = (overrides: Partial<ChatSession> = {}): ChatSession => {
    const timestamp = faker.date.recent().getTime();

    return {
        id: faker.string.uuid(),
        title: faker.lorem.sentence(3),
        date: new Date(timestamp).toISOString(),
        preview: faker.lorem.sentence(),
        tags: [faker.word.sample(), faker.word.sample()],
        status: 'completed',
        messages: [
            {
                id: faker.string.uuid(),
                role: 'user',
                content: faker.lorem.paragraph(),
                timestamp: timestamp - 10000,
            },
            {
                id: faker.string.uuid(),
                role: 'assistant',
                content: faker.lorem.paragraph(),
                timestamp: timestamp,
            }
        ],
        ...overrides,
    };
};

export const createChatSessions = (count: number, overrides: Partial<ChatSession> = {}): ChatSession[] => {
    return Array.from({ length: count }, () => createChatSession(overrides));
};
