package com.remax.bill.ads.bidding

/**
 * 比价平台控制器
 * 用于控制各广告类型参与比价的平台
 * 
 * 当前策略：
 * - 插页广告：AdMob、Pangle、TopOn 都参与比价
 * - Banner广告：AdMob、TopOn 参与比价
 * - 开屏广告：AdMob、TopOn 参与比价
 * - 原生广告：AdMob、TopOn 参与比价
 * - 全屏原生广告：AdMob、TopOn 参与比价
 */
object BiddingPlatformController {

    /**
     * 广告类型
     */
    enum class AdType {
        INTERSTITIAL,       // 插页广告
        BANNER,             // Banner广告
        APP_OPEN,           // 开屏广告
        NATIVE,             // 原生广告
        FULL_SCREEN_NATIVE  // 全屏原生广告
    }

    /**
     * 广告平台
     */
    enum class Platform {
        ADMOB,
        PANGLE,
        TOPON
    }

    // ==================== 平台配置（写死） ====================
    
    // 插页广告：AdMob + Pangle + TopOn
    private const val INTERSTITIAL_ADMOB = true
    private const val INTERSTITIAL_PANGLE = true
    private const val INTERSTITIAL_TOPON = true

    // Banner广告：AdMob + TopOn
    private const val BANNER_ADMOB = true
    private const val BANNER_PANGLE = false
    private const val BANNER_TOPON = true

    // 开屏广告：AdMob + TopOn
    private const val APP_OPEN_ADMOB = true
    private const val APP_OPEN_PANGLE = false
    private const val APP_OPEN_TOPON = true

    // 原生广告：AdMob + TopOn
    private const val NATIVE_ADMOB = true
    private const val NATIVE_PANGLE = false
    private const val NATIVE_TOPON = true

    // 全屏原生广告：AdMob + TopOn
    private const val FULL_SCREEN_NATIVE_ADMOB = true
    private const val FULL_SCREEN_NATIVE_PANGLE = false
    private const val FULL_SCREEN_NATIVE_TOPON = true

    /**
     * 检查指定广告类型的平台是否启用
     */
    fun isPlatformEnabled(adType: AdType, platform: Platform): Boolean {
        return when (adType) {
            AdType.INTERSTITIAL -> when (platform) {
                Platform.ADMOB -> INTERSTITIAL_ADMOB
                Platform.PANGLE -> INTERSTITIAL_PANGLE
                Platform.TOPON -> INTERSTITIAL_TOPON
            }
            AdType.BANNER -> when (platform) {
                Platform.ADMOB -> BANNER_ADMOB
                Platform.PANGLE -> BANNER_PANGLE
                Platform.TOPON -> BANNER_TOPON
            }
            AdType.APP_OPEN -> when (platform) {
                Platform.ADMOB -> APP_OPEN_ADMOB
                Platform.PANGLE -> APP_OPEN_PANGLE
                Platform.TOPON -> APP_OPEN_TOPON
            }
            AdType.NATIVE -> when (platform) {
                Platform.ADMOB -> NATIVE_ADMOB
                Platform.PANGLE -> NATIVE_PANGLE
                Platform.TOPON -> NATIVE_TOPON
            }
            AdType.FULL_SCREEN_NATIVE -> when (platform) {
                Platform.ADMOB -> FULL_SCREEN_NATIVE_ADMOB
                Platform.PANGLE -> FULL_SCREEN_NATIVE_PANGLE
                Platform.TOPON -> FULL_SCREEN_NATIVE_TOPON
            }
        }
    }

    /**
     * 获取指定广告类型启用的平台列表
     */
    fun getEnabledPlatforms(adType: AdType): List<Platform> {
        return Platform.values().filter { isPlatformEnabled(adType, it) }
    }

    // ==================== 便捷方法 ====================

    fun isAdmobEnabled(adType: AdType): Boolean = isPlatformEnabled(adType, Platform.ADMOB)
    fun isPangleEnabled(adType: AdType): Boolean = isPlatformEnabled(adType, Platform.PANGLE)
    fun isToponEnabled(adType: AdType): Boolean = isPlatformEnabled(adType, Platform.TOPON)
}
