enum Format:byte { Manga, Novel, OneShot }
enum Status:byte { Finished, Releasing, Hiatus, NotYetReleased, Cancelled }
enum PublicationDemographic:byte { Shounen, Shoujou, Seinen, Josei }
enum Source:byte { Original, Manga, LightNovel, VisualNovel, VideoGame, Other, Novel, Doujinshi, Anime, WebNovel, LiveAction, Game, Comic, MultimediaProject, PictureBook }
enum ContentRating:byte { Safe, Suggestive, Erotica, Pornographic }

enum TagType:byte { Format, Genre, Theme, Content }

table Tag {
    type:TagType;
    value:string;
}

struct MetaValue {
    main:uint;
    bonus:uint;
}

struct Date {
    year:ushort;
    month:ubyte;
    day:ubyte;
}

struct Size {
    width:uint;
    height:uint;
}

table ImageMetadata {
    double_page:bool;
    filename:string (required);
    first_page:uint;
    size:Size (required);
}

table ChapterMetadata {
    chapter:MetaValue (required);
    name:string;
    images:[ImageMetadata];
}

table VolumeMetadata {
    volume:MetaValue (required);
    title:string;
    archive:string (required);
    chapters:[ChapterMetadata];
}

table Metadata {
    title:string (required);
    format:Format;
    original_language:string;
    country_of_origin:string;
    publication_demographic:PublicationDemographic;
    status:Status;
    content_rating:ContentRating;
    source:Source;
    start_release_date:Date;
    end_release_date:Date;
    tags:[Tag];
    description:string;
    volumes:[VolumeMetadata];
}

root_type Metadata;
