package eu.kanade.tachiyomi.data.database.models

import eu.kanade.tachiyomi.domain.manga.models.Manga

class MangaChapter(val manga: Manga, val chapter: Chapter) {
    companion object {
        fun mapper(
            // manga
            mangaId: Long,
            source: Long,
            mangaUrl: String,
            artist: String?,
            author: String?,
            description: String?,
            genre: String?,
            title: String,
            status: Long,
            thumbnailUrl: String?,
            favorite: Boolean,
            lastUpdate: Long?,
            initialized: Boolean,
            viewer: Long,
            hideTitle: Boolean,
            chapterFlags: Long,
            dateAdded: Long?,
            filteredScanlators: String?,
            updateStrategy: Long,
            coverLastModified: Long,
            // chapter
            chapterId: Long,
            _mangaId: Long,
            chapterUrl: String,
            name: String,
            scanlator: String?,
            read: Boolean,
            bookmark: Boolean,
            lastPageRead: Long,
            pagesLeft: Long,
            chapterNumber: Double,
            sourceOrder: Long,
            dateFetch: Long,
            dateUpload: Long,
        ) = MangaChapter(
            Manga.mapper(
                id = mangaId,
                source = source,
                url = mangaUrl,
                artist = artist,
                author = author,
                description = description,
                genre = genre,
                title = title,
                status = status,
                thumbnailUrl = thumbnailUrl,
                favorite = favorite,
                lastUpdate = lastUpdate,
                initialized = initialized,
                viewerFlags = viewer,
                hideTitle = hideTitle,
                chapterFlags = chapterFlags,
                dateAdded = dateAdded,
                filteredScanlators = filteredScanlators,
                updateStrategy = updateStrategy,
                coverLastModified = coverLastModified,
            ),
            Chapter.mapper(
                id = chapterId,
                mangaId = _mangaId,
                url = chapterUrl,
                name = name,
                scanlator = scanlator,
                read = read,
                bookmark = bookmark,
                lastPageRead = lastPageRead,
                pagesLeft = pagesLeft,
                chapterNumber = chapterNumber,
                sourceOrder = sourceOrder,
                dateFetch = dateFetch,
                dateUpload = dateUpload,
            ),
        )
    }
}
