package dev.kaizen.app.net

/**
 * Response speed — the user-facing framing of the backend's reasoning/throughput
 * knobs (`ChatOptions.reasoningEffort` + `preferThroughput`). [Normal] sends no
 * override (provider default); [Instant] is the web "instant" preset (no reasoning
 * + `:nitro` throughput routing); [Max] asks for high reasoning effort.
 */
enum class ChatSpeed(val reasoningEffort: String?, val preferThroughput: Boolean) {
    Instant(reasoningEffort = "none", preferThroughput = true),
    Normal(reasoningEffort = null, preferThroughput = false),
    Max(reasoningEffort = "high", preferThroughput = false),
}

/**
 * The app is deployment-agnostic: one binary that points at EITHER the official
 * server OR any self-hosted instance, via one uniform `Authorization: Bearer`
 * contract. SaaS vs self-host is only "whose base URL".
 *
 * @param baseUrl normalized origin (no trailing slash), e.g. "https://ask.kryptomrx.de"
 * @param token   the `kzn_...` personal access token (stored encrypted, never logged)
 * @param model   composite model id sent to /api/v1/chat, e.g. "vertex:gemini-2.5-flash"
 * @param email   the signed-in email (for display in the sidebar/settings)
 * @param speed   response-speed preset sent with each chat request
 */
data class ServerConfig(
    val baseUrl: String,
    val token: String,
    val model: String,
    val email: String,
    val speed: ChatSpeed = ChatSpeed.Normal,
)

/** Default origin pre-filled on the login screen (editable — self-host points it elsewhere). */
const val DEFAULT_BASE_URL = "https://ask.kryptomrx.de"

/** Fallback model when the server reports no user default (GET /api/v1/me → defaultModel null). */
const val DEFAULT_MODEL = "vertex:gemini-2.5-flash"

/** The v1 API version this app build expects from the server. */
const val EXPECTED_API_VERSION = 1

/** Strips a trailing slash so "$baseUrl/api/v1/..." never double-slashes. */
fun normalizeBaseUrl(input: String): String = input.trim().trimEnd('/')
