import { InertiaLinkProps } from '@inertiajs/react';
import { LucideIcon } from 'lucide-react';

export interface Auth {
    user: User;
}

export interface BreadcrumbItem {
    title: string;
    href: string;
}

export interface NavGroup {
    title: string;
    items: NavItem[];
}

export interface NavItem {
    title: string;
    href: NonNullable<InertiaLinkProps['href']>;
    icon?: LucideIcon | null;
    isActive?: boolean;
}

export interface SharedData {
    name: string;
    quote: { message: string; author: string };
    auth: Auth;
    sidebarOpen: boolean;
    [key: string]: unknown;
}

export interface User {
    id: number;
    first_name: string;
    last_name: string;
    full_name: string;
    email: string;
    avatar?: string;
    email_verified_at: string | null;
    two_factor_enabled?: boolean;
    created_at: string;
    updated_at: string;
    [key: string]: unknown; // This allows for additional properties...
}

export interface Video {
    id: number;
    user_id: number;
    project_id: number;
    filename: string;
    original_name: string;
    path: string;
    thumbnail: string | null;
    thumbnail_url: string | null;
    status: 'pending' | 'processing' | 'completed' | 'failed';
    duration: number | null;
    size: number;
    mime_type: string;
    expected_language: string | null;
    video_type: string;
    error_message: string | null;
    vector_indexed_at: string | null;
    qdrant_collection: string | null;
    created_at: string;
    updated_at: string;
    transcript?: Transcript;
    summary?: Summary;
}

export interface TranscriptSegment {
    start_time: number;
    end_time: number;
    text: string;
}

export interface Transcript {
    id: number;
    video_id: number;
    text: string;
    language: string | null;
    transcribed_at: string | null;
    metadata: Record<string, any> | null;
    segments?: TranscriptSegment[];
    created_at: string;
    updated_at: string;
}

export type AudioStatus = 'generating' | 'completed' | 'failed' | null;

export interface Summary {
    id: number;
    video_id: number;
    llm_provider: string;
    summary_text: string;
    audio_path: string | null;
    audio_status: AudioStatus;
    processing_time: number | null;
    metadata: Record<string, any> | null;
    created_at: string;
    updated_at: string;
}

export interface ChatMessage {
    id: number;
    video_id: number;
    user_id: number;
    role: 'user' | 'assistant';
    message: string;
    llm_provider: string | null;
    created_at: string;
    updated_at: string;
    user?: User;
}

export interface PaginatedVideos {
    data: Video[];
    links: {
        first: string | null;
        last: string | null;
        prev: string | null;
        next: string | null;
    };
    meta: {
        current_page: number;
        from: number;
        last_page: number;
        path: string;
        per_page: number;
        to: number;
        total: number;
    };
}

export interface Note {
    id: number;
    user_id: number;
    user_name: string;
    project_id: number;
    notable_type: string;
    notable_id: number;
    content: string;
    audio_path: string | null;
    audio_status: AudioStatus;
    vector_indexed_at: string | null;
    created_at: string;
    updated_at: string;
}

export interface ProjectEmail {
    id: number;
    subject: string;
    from_email: string;
    from_name: string | null;
    summary: string | null;
    category: EmailCategory | null;
    estimated_impact: EmailImpact | null;
    status: EmailStatus;
    has_attachments: boolean;
    processing_status: EmailProcessingStatus;
    is_forwarded: boolean;
    received_at: string;
}

export interface Project {
    id: number;
    user_id: number;
    name: string;
    description: string | null;
    qdrant_collection: string | null;
    vector_indexed_at: string | null;
    created_at: string;
    updated_at: string;
    videos_count?: number;
    documents_count?: number;
    file_counts?: {
        total: number;
        indexed: number;
        videos: number;
        documents: number;
    };
    videos?: ProjectVideo[];
    documents?: ProjectDocument[];
    notes?: Note[];
    emails?: ProjectEmail[];
}

export interface ProjectDocument {
    id: number;
    original_name: string;
    type: string;
    type_label: string;
    size: number;
    status: 'pending' | 'processing' | 'completed' | 'failed';
    error_message: string | null;
    audio_path: string | null;
    audio_status: AudioStatus;
    page_count: number | null;
    word_count: number | null;
    user_name: string | null;
    created_at: string;
}

export interface ProjectVideo {
    id: number;
    original_name: string;
    thumbnail_url: string | null;
    status: 'pending' | 'processing' | 'completed' | 'failed';
    duration: number | null;
    size: number;
    video_type: string;
    user_name: string | null;
    created_at: string;
}

export interface PaginatedProjects {
    data: Project[];
    links: {
        first: string | null;
        last: string | null;
        prev: string | null;
        next: string | null;
    };
    meta: {
        current_page: number;
        from: number | null;
        last_page: number;
        path: string;
        per_page: number;
        to: number | null;
        total: number;
    };
}

export interface Widget {
    id: number;
    user_id: number;
    widget_key: string;
    name: string;
    config: {
        theme?: {
            primaryColor?: string;
            accentColor?: string;
        };
    } | null;
    total_requests: number;
    last_used_at: string | null;
    is_active: boolean;
    created_at: string;
    updated_at: string;
    faqs_count?: number;
    leads_count?: number;
}

export type EmailCategory = 'feature' | 'modification' | 'bug' | 'question' | 'info' | 'other';
export type EmailImpact = 'minor' | 'moderate' | 'major';
export type EmailStatus = 'unread' | 'read' | 'flagged' | 'archived';
export type EmailProcessingStatus = 'pending' | 'processing' | 'completed' | 'failed';

export interface Email {
    id: number;
    user_id: number;
    project_id: number | null;
    message_id: string;
    subject: string;
    from_email: string;
    from_name: string | null;
    to_email: string;
    is_forwarded: boolean;
    original_from_email: string | null;
    original_from_name: string | null;
    original_date: string | null;
    received_at: string;
    body_text: string;
    body_html: string | null;
    summary: string | null;
    category: EmailCategory | null;
    estimated_impact: EmailImpact | null;
    status: EmailStatus;
    has_attachments: boolean;
    processing_status: EmailProcessingStatus;
    error_message: string | null;
    qdrant_point_id: string | null;
    created_at: string;
    updated_at: string;
    attachments?: EmailAttachment[];
    project?: Project;
}

export interface EmailAttachment {
    id: number;
    email_id: number;
    filename: string;
    file_path: string;
    mime_type: string;
    file_size: number;
    created_at: string;
    updated_at: string;
}

export interface PaginatedEmails {
    data: Email[];
    links: {
        first: string | null;
        last: string | null;
        prev: string | null;
        next: string | null;
    };
    meta: {
        current_page: number;
        from: number | null;
        last_page: number;
        path: string;
        per_page: number;
        to: number | null;
        total: number;
    };
}
