import {Author} from './User';
import {ActChapter, ChapterProps} from "@/lib/models/Chapter";
import {SelectBoxProps} from "@/shared/interface";

export interface BookProps {
    bookId: string;
    type: string;
    title: string;
    author?: Author;
    serie?: number;
    subTitle?: string;
    summary?: string;
    publicationDate?: string;
    desiredWordCount?: number;
    totalWordCount?: number;
    coverImage?: string;
    chapters?: ChapterProps[];
}

export interface BookListProps {
    id: string;
    type: string;
    authorId: string;
    title: string;
    subTitle?: string;
    summary?: string;
    serieId?: number;
    desiredReleaseDate?: string;
    desiredWordCount?: number;
    wordCount?: number;
    coverImage?: string;
    bookMeta?: string;
}

export interface GuideLine {
    tone: string;
    atmosphere: string;
    writingStyle: string;
    themes: string;
    symbolism: string;
    motifs: string;
    narrativeVoice: string;
    pacing: string;
    intendedAudience: string;
    keyMessages: string;
}

export interface GuideLineAI {
    narrativeType: number;
    dialogueType: number;
    globalResume: string;
    atmosphere: string;
    verbeTense: number;
    langue: number;
    themes: string;
}

export interface PlotPoint {
    plotPointId: string;
    title: string;
    summary: string;
    linkedIncidentId: string;
    chapters?: ActChapter[];
}

export interface Incident {
    incidentId: string;
    title: string;
    summary: string;
    chapters?: ActChapter[];
}

export interface Issue {
    name: string;
    id: string;
}

export interface Act {
    id: number;
    summary: string | null;
    incidents?: Incident[];
    plotPoints?: PlotPoint[];
    chapters?: ActChapter[];
}

export interface Tag {
    label: string,
    value: string,
}

export interface BookTags {
    characters: Tag[];
    locations: Tag[];
    objects: Tag[];
    worldElements: Tag[];
}

export const bookTypes: SelectBoxProps[] = [
    {label: 'bookTypes.short', value: 'short'},
    {label: 'bookTypes.novelette', value: 'novelette'},
    {label: 'bookTypes.novella', value: 'long'},
    {label: 'bookTypes.chapbook', value: 'chapbook'},
    {label: 'bookTypes.novel', value: 'novel'},
]

export default class Book {
    constructor() {
    }

    static booksToSelectBox(books: BookProps[]): SelectBoxProps[] {
        return books.map((book: BookProps) => {
            return {
                label: book.title,
                value: book.bookId,
            }
        });
    }
    
    static getBookTypeLabel(value: string): string {
        switch (value) {
            case 'short':
                return 'bookTypes.short';
            case 'novelette':
                return 'bookTypes.novelette';
            case 'long':
                return 'bookTypes.novella';
            case 'chapbook':
                return 'bookTypes.chapbook';
            case 'novel':
                return 'bookTypes.novel';
            default:
                return 'bookTypes.novel';
        }
    }
}
