package app.voltplan.cable.data.model

/** Battery chemistry. Raw values match the iOS SwiftData strings exactly. */
enum class Chemistry(val rawValue: String) {
    AGM("AGM"),
    GEL("Gel"),
    FLOODED_LEAD_ACID("Flooded Lead Acid"),
    LIFEPO4("LiFePO4"),
    LITHIUM_ION("Lithium Ion");

    /** Display name shown in pickers — the raw value, as on iOS. */
    val displayName: String get() = rawValue

    /** Fraction of nominal capacity that is usable for this chemistry. */
    val usableCapacityFraction: Double
        get() = when (this) {
            FLOODED_LEAD_ACID -> 0.5
            AGM -> 0.5
            GEL -> 0.6
            LIFEPO4 -> 0.9
            LITHIUM_ION -> 0.85
        }

    companion object {
        fun fromRaw(raw: String?): Chemistry = entries.firstOrNull { it.rawValue == raw } ?: LIFEPO4
    }
}

/** Charger power source. Raw values match the iOS SwiftData strings exactly. */
enum class PowerSourceType(val rawValue: String) {
    SHORE("shore"),
    SOLAR("solar"),
    WIND("wind"),
    GENERATOR("generator"),
    ALTERNATOR("alternator");

    /** SF Symbol name used for this source (translated to a Material icon at render time). */
    val iconName: String
        get() = when (this) {
            SHORE -> "powerplug"
            SOLAR -> "sun.max.fill"
            WIND -> "wind"
            GENERATOR -> "engine.combustion.fill"
            ALTERNATOR -> "bolt.car.fill"
        }

    companion object {
        fun fromRaw(raw: String?): PowerSourceType = entries.firstOrNull { it.rawValue == raw } ?: SHORE
    }
}
