package de.krisenvorrat.app.domain.model

/**
 * Type-safe Settings-Key-Definition.
 * Jeder Key hat einen festen DB-Schlüssel, einen Default-Wert und einen Typ.
 * Compile-Time-Fehler bei ungültigen Keys sind garantiert.
 */
internal sealed class SettingsKey<T>(val key: String, val defaultValue: T) {

    sealed class StringKey(key: String, defaultValue: String = "") : SettingsKey<String>(key, defaultValue) {
        data object HouseholdSize : StringKey("household_size")
        data object DailyKcalPerPerson : StringKey("daily_kcal_per_person")
        data object AgeGroups : StringKey("age_groups")
        data object ServerUrl : StringKey("server_url")
        data object AuthAccessToken : StringKey("auth_access_token")
        data object AuthRefreshToken : StringKey("auth_refresh_token")
        data object AuthUsername : StringKey("auth_username")
        data object AuthUserId : StringKey("auth_user_id")
        data object SyncLastTimestamp : StringKey("sync_last_timestamp")
        data object OpenAiApiKey : StringKey("openai_api_key")
        data object ActiveInventoryId : StringKey("active_inventory_id")
        data object ActiveInventoryName : StringKey("active_inventory_name")
    }

    companion object {
        val SENSITIVE_KEYS: Set<StringKey> = setOf(
            StringKey.AuthAccessToken,
            StringKey.AuthRefreshToken,
            StringKey.AuthUsername,
            StringKey.AuthUserId,
            StringKey.OpenAiApiKey
        )

        val SENSITIVE_KEY_STRINGS: Set<String> = SENSITIVE_KEYS.map { it.key }.toSet()
    }
}
