import type { TerminalLine } from '$lib/components/tui/types';
import { sortedCards, projects } from '$lib/config';

const totalHackathons = sortedCards.length;
const totalAwards = sortedCards.filter(c => c.awards && c.awards.length > 0).length;
const featuredCount = sortedCards.filter(c => c.featured).length;

// Build the terminal lines with card grid
export const lines: TerminalLine[] = [
    { type: 'command', content: 'ls ~/projects' },
    { type: 'divider', content: 'PROJECTS' },
    ...projects.filter(p => p.featured).flatMap(project => [
        { type: 'header' as const, content: `(&bold)${project.name}(&)` },
        { type: 'output' as const, content: `(&muted)${project.description}(&)` },
        { type: 'info' as const, content: `(&info)TechStack:(&) (&magenta)${project.tech.join(', ')}(&)` },
        ...(project.github ? [{
            type: 'button' as const,
            content: 'View on GitHub',
            icon: 'mdi:github',
            style: 'accent' as const,
            href: project.github
        }] : []),
        ...(project.live ? [{
            type: 'button' as const,
            content: 'View Live Demo',
            icon: 'mdi:open-in-new',
            style: 'accent' as const,
            href: project.live
        }] : []),
        { type: 'blank' as const, content: '' }
    ]),
    ...projects.filter(p => !p.featured).flatMap(project => [
        { type: 'success' as const, content: `(&success)${project.name}(&)` },
        { type: 'output' as const, content: `(&muted)${project.description}(&)` },
        { type: 'info' as const, content: `(&info)TechStack:(&) (&magenta)${project.tech.join(', ')}(&)` },
        ...(project.github ? [{
            type: 'button' as const,
            content: 'View on GitHub',
            icon: 'mdi:github',
            style: 'accent' as const,
            href: project.github
        }] : []),
        ...(project.live ? [{
            type: 'button' as const,
            content: 'View Live',
            icon: 'mdi:open-in-new',
            style: 'accent' as const,
            href: project.live
        }] : []),
        { type: 'blank' as const, content: '' }
    ]),
    { type: 'divider', content: 'HACKATHONS' },
    { type: 'command', content: 'ls ~/hackathons --grid' },
    { type: 'blank', content: '' },
    { type: 'header', content: `Hackathon Journey` },
    { type: 'output', content: `(&muted)Total:(&) (&primary)${totalHackathons}(&) (&muted)| Awards:(&) (&yellow)${totalAwards}(&) (&muted)| Featured:(&) (&accent)${featuredCount}(&)` },
    { type: 'blank', content: '' },
    { type: 'cardgrid', content: '', cards: sortedCards },
    { type: 'blank', content: '' },
    { type: 'success', content: `(&success)Ready for the next hackathon! 🚀(&)` },
];