package dev.kaizen.app.chat

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import dev.kaizen.app.R
import dev.kaizen.app.net.Attachment
import dev.kaizen.app.net.SearchSource
import dev.kaizen.app.net.ToolEvent
import dev.kaizen.app.ui.icon.KaizenIcons

enum class Role { User, Assistant }

enum class ReasoningPreset(val label: Int, val effort: String?, val throughput: Boolean) {
    Instant(R.string.reasoning_instant, "none", true),
    None(R.string.reasoning_none, "none", false),
    Minimal(R.string.reasoning_minimal, "minimal", false),
    Low(R.string.reasoning_low, "low", false),
    Standard(R.string.reasoning_standard, null, false),
    Medium(R.string.reasoning_medium, "medium", false),
    High(R.string.reasoning_high, "high", false),
    XHigh(R.string.reasoning_xhigh, "xhigh", false),
}

data class SamplingParam(val enabled: Boolean, val value: Float)

data class SamplingPrefs(
    val temperature: SamplingParam = SamplingParam(false, 1f),
    val topP: SamplingParam = SamplingParam(false, 1f),
    val topK: SamplingParam = SamplingParam(false, 40f),
)

data class Message(
    val id: Long,
    val role: Role,
    val content: String,
    val streaming: Boolean = false,
    val thinking: Boolean = false,
    val wireId: String = java.util.UUID.randomUUID().toString(),
    val attachments: List<Attachment> = emptyList(),
    val reasoning: String = "",
    val tools: List<ToolEvent> = emptyList(),
    val query: String = "",
    val sources: List<SearchSource> = emptyList(),
    val branchInfo: BranchInfo? = null,
)

data class Suggestion(val labelRes: Int, val promptRes: Int, val icon: ImageVector)

val suggestions = listOf(
    Suggestion(R.string.suggest_brainstorm, R.string.suggest_brainstorm_prompt, KaizenIcons.Sparkles),
    Suggestion(R.string.suggest_image, R.string.suggest_image_prompt, KaizenIcons.Image),
    Suggestion(R.string.suggest_video, R.string.suggest_video_prompt, KaizenIcons.Video),
    Suggestion(R.string.suggest_web, R.string.suggest_web_prompt, KaizenIcons.Globe),
)

data class ChatMode(val labelRes: Int, val icon: ImageVector)

val chatModes = listOf(
    ChatMode(R.string.mode_standard, KaizenIcons.CircleDot),
    ChatMode(R.string.mode_sampling, KaizenIcons.SlidersHorizontal),
    ChatMode(R.string.mode_image, KaizenIcons.Image),
    ChatMode(R.string.mode_search, KaizenIcons.Globe),
    ChatMode(R.string.mode_video, KaizenIcons.Video),
    ChatMode(R.string.mode_audio, KaizenIcons.Music),
)

@Composable
fun greeting(hour: Int): String = when (hour) {
    in 5..11 -> stringResource(R.string.greeting_morning)
    in 12..17 -> stringResource(R.string.greeting_day)
    in 18..22 -> stringResource(R.string.greeting_evening)
    else -> stringResource(R.string.greeting_night)
}
