package com.pixelized.biblib.ui.theme.color

import androidx.compose.material.Colors
import androidx.compose.material.MaterialTheme
import androidx.compose.material.darkColors
import androidx.compose.material.lightColors
import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.Color
import com.pixelized.biblib.utils.extention.bibLib
import javax.annotation.concurrent.Immutable


@Stable
@Immutable
data class BibLibColor(
    val base: Colors,
    val system: System,
    val handle: Color,
    val typography: Typography,
    val placeHolder: PlaceHolder,
) {
    @Stable
    @Immutable
    data class System(
        val status: Color,
        val navigation: Color,
    )

    @Stable
    @Immutable
    data class Typography(
        val light: Color,
        val medium: Color,
        val emphasis: Color,
    )

    @Stable
    @Immutable
    data class PlaceHolder(
        val color: Color,
        val shimmer: Color,
    )
}

fun bibLibDarkColors(
    base: Colors = darkColors(
        primary = BibLibColorPalette.Green,
        secondary = BibLibColorPalette.VeryLightGreen,
        onPrimary = Color.White,
        onSecondary = Color.White,
        error = BibLibColorPalette.Red,
        onError = Color.White,
    ),
    system: BibLibColor.System = BibLibColor.System(
        status = base.surface.copy(alpha = 0.5f),
        navigation = base.surface.copy(alpha = 0.5f),
    ),
    handle: Color = base.onSurface.copy(alpha = 0.2f),
    typography: BibLibColor.Typography = BibLibColor.Typography(
        light = base.onSurface.copy(alpha = 0.67f),
        medium = base.onSurface,
        emphasis = base.primary,
    ),
    placeHolder: BibLibColor.PlaceHolder = BibLibColor.PlaceHolder(
        color = BibLibColorPalette.DarkGrey,
        shimmer = BibLibColorPalette.Grey,
    ),
) = BibLibColor(
    base = base,
    system = system,
    handle = handle,
    typography = typography,
    placeHolder = placeHolder,
)

fun bibLibLightColors(
    base: Colors = lightColors(
        primary = BibLibColorPalette.Green,
        secondary = BibLibColorPalette.VeryLightGreen,
        onPrimary = Color.White,
        onSecondary = Color.White,
        error = BibLibColorPalette.Red,
        onError = Color.White,
        background = BibLibColorPalette.VeryLightGrey,
        onBackground = BibLibColorPalette.VeryDarkGrey,
        surface = Color.White,
        onSurface = BibLibColorPalette.VeryDarkGrey,
    ),
    system: BibLibColor.System = BibLibColor.System(
        status = base.surface,
        navigation = base.surface,
    ),
    handle: Color = base.onSurface.copy(alpha = 0.1f),
    typography: BibLibColor.Typography = BibLibColor.Typography(
        light = base.onSurface.copy(alpha = 0.67f),
        medium = base.onSurface,
        emphasis = base.primary,
    ),
    placeHolder: BibLibColor.PlaceHolder = BibLibColor.PlaceHolder(
        color = BibLibColorPalette.LightGrey,
        shimmer = BibLibColorPalette.VeryLightGrey,
    ),
) = BibLibColor(
    base = base,
    system = system,
    handle = handle,
    typography = typography,
    placeHolder = placeHolder,
)