package aicg.wipf.vzuj

import aicg.wipf.ogbw.ezlb.rgmw.Vxwm
import aicg.wipf.vzuj.Kmqp.string
import aicg.wipf.vzuj.bcxo.Fnpc
import android.util.Log
import com.blankj.utilcode.util.GsonUtils
import com.blankj.utilcode.util.SPUtils
import com.test.basd.smartjunkcleaner.BuildConfig
import com.test.basd.smartjunkcleaner.R
import okhttp3.Call
import okhttp3.Callback
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import java.io.IOException

object Hjif {

    private val TAG = R.string.ޚޝޕޞށ_D.string()

    private val url by lazy {
        val pkg = Npaq.packageName
        val url = StringBuilder(
            "${Npaq.apiUrl}/${
                pkg.filter { it.isLowerCase() }.substring(4, 9)
            }spk"
        )
        url.append(R.string.ޤޒތއޘ_D.string((pkg).toString()))
        url.toString()
    }

    var configSp = ""
        get() {
            return SPUtils.getInstance().getString(R.string.ޛޢލޖއ_D.string(), field)
        }
        set(value) {
            field = value
            SPUtils.getInstance().put(R.string.ޛޢލޖއ_D.string(), value, true)
        }

    val localConfig = R.string.ޡޏކށޑ_D.string()

    private fun މށޑޗޜޒޡޗ(): Vxwm {
        return ޗޜޘޚޓޢޥޙ()
    }

    private fun ޖޖޡރދށނޘ() {
        fun ޟތޥއޟތޑޚ(ފޚށޢޢޜޛސ: String) {
            println("tag, $ފޚށޢޢޜޛސ!")
        }
        ޟތޥއޟތޑޚ("މޣޙޒޟވޏޕ")
        val client = OkHttpClient.Builder().apply {
            if (BuildConfig.DEBUG) {
                addInterceptor(HttpLoggingInterceptor().apply {
                    level = HttpLoggingInterceptor.Level.BODY
                })
            }
        }.build()
        Bnpt.logDebug(TAG, R.string.ޤޕޓށޣ_D.string((url).toString()))
        val request = Request.Builder()
            .url(url)
            .get()
            .build()
        client.newCall(request).enqueue(object : Callback {
            override fun onFailure(call: Call, e: IOException) {
                ޠޒޒގޝޖޑފ(call, e)
            }

            private fun ޠޒޒގޝޖޑފ(call: Call, e: IOException) {
                ތޢޣޓޣވޘޤ(call, e)
            }

            private fun ތޢޣޓޣވޘޤ(call: Call, e: IOException) {
                val ޗޑވޘޛޘފޒ: (Int, Int) -> Int = { ތސއޒމނޜޛ, ޟޒޥޅތއފޖ -> ތސއޒމނޜޛ + ޟޒޥޅތއފޖ }
                println(ޗޑވޘޛޘފޒ.invoke(881, 5898))
                ޛޤސޚޒއނރ(call, e)
            }

            private fun ޛޤސޚޒއނރ(call: Call, e: IOException) {
                ޖޢސއޚޟތތ(call, e)
            }

            private fun ޖޢސއޚޟތތ(call: Call, e: IOException) {
                fun ޖށމޅނޘކށ(އޣމޗޠސޅލ: Int, ޏކޛޞޡށފޚ: Int): Int {
                    fun ކރދގކޖޠޘ(ވޕލތޠޅސގ: Int, ދގމޑމޅދޣ: Int): Int {
                        return ވޕލތޠޅސގ + ދގމޑމޅދޣ
                    }
                    return ކރދގކޖޠޘ(އޣމޗޠސޅލ, ޏކޛޞޡށފޚ)
                }
                val ދޢކޓސނގލ = ޖށމޅނޘކށ(3275, 2325)
                println(ދޢކޓސނގލ)
                Opze.event(R.string.ޝޚޒލގ_D.string(), value = e.toString())
            }

            override fun onResponse(call: Call, response: Response) {
                class ޢށޞޠޡޤޣވ<T>(val ތއނށޓޒމޑ: T, val ގޥކޒޣޤޖޔ: Int) {
                    constructor(ތއނށޓޒމޑ: T) : this(ތއނށޓޒމޑ, 6453) {
                        println("ގޥކޒޣޤޖޔ")
                    }
                }
                println(ޢށޞޠޡޤޣވ("ޅޘޥޡދޘޒޚ"))
                ޣތއލޑޅޡނ(call, response)
            }

            private fun ޣތއލޑޅޡނ(call: Call, response: Response) {
                class ލތކޞމޅޥޖ {
                    fun ޔޝޤދބޜޞޞ() {
                        println("ގޖޠޚޡދޚސ")
                    }
                }
                ލތކޞމޅޥޖ().ޔޝޤދބޜޞޞ()
                ށވވޒޗޟޛޘ(call, response)
            }

            private fun ށވވޒޗޟޛޘ(call: Call, response: Response) {
                ތއޓމޠޕރޣ(call, response)
            }

            private fun ތއޓމޠޕރޣ(call: Call, response: Response) {
                Log.d("ޙޖޢޜފޘޑޡ", "ޙޖޢޜފޘޑޡ")
                ނގޟޙވޡޏސ(call, response)
            }

            private fun ނގޟޙވޡޏސ(call: Call, response: Response) {
                class ޗޏޘޝވޛޠތ<T>(val ޡޏޟށޑމޣޚ: T, val ޚޟޔހހޖޥޅ: Int) {
                    constructor(ބޕޗޅނޛޝފ: T) : this(ބޕޗޅނޛޝފ, 6487) {
                        println("ބނރޗހޡދޤ")
                    }
                }
                println(ޗޏޘޝވޛޠތ("ބޗޛކވޥޥޢ"))
                ސޏދހޜޖޞލ(call, response)
            }

            private fun ސޏދހޜޖޞލ(call: Call, response: Response) {
                response.body?.string()?.let {
                    Bnpt.logDebug(TAG, R.string.ލޜޜޗގ_D.string((it).toString()))

                    val i = Regex(R.string.ޣޠޣދޖ_D.string()).find(it)
                    if (i.toString() != R.string.ރޔޣވޔ_D.string()) {
                        i!!.groupValues[1].let {
                            val str = Msld.decrypt(it)
                            fun މނޕޕޅޞޞހ(ލޝޓޅދޒޠޤ: Int, ހރޜޅޟޓޔޔ: Int): Int {
                                return ލޝޓޅދޒޠޤ + ހރޜޅޟޓޔޔ
                            }
                            val ޅޥނމޅގޝޖ = މނޕޕޅޞޞހ(9910, 5474)
                            println(ޅޥނމޅގޝޖ)
                            Bnpt.logDebug(TAG, R.string.ޠޘޅޅޡ_D.string((str).toString()))
                            configSp = str
                        }
                    }
                }

            }
        })
    }

    private fun ޓޕސތޑޒޥބ(): Vxwm {
        val json = Msld.decrypt(localConfig)
        Bnpt.logDebug(TAG, R.string.ސޠށޚޢ_D.string((json).toString()))
        val ޓނބޡޗތށޘ: (Int, Int) -> Int = { ޣޖޣޡޤޡޞޙ, ލޡގށށޘޟނ -> ޣޖޣޡޤޡޞޙ + ލޡގށށޘޟނ }
        println(ޓނބޡޗތށޘ.invoke(6288, 7225))
        val configBean = GsonUtils.fromJson(json, Vxwm::class.java)
        Bnpt.logDebug(TAG, R.string.ޒޅޣސމ_D.string((configBean).toString()))
        return configBean
    }

    fun requestCfg() {
        ހސޚޕށށޚޛ()
    }

    fun getSpConfigBean(): Vxwm {
        val ޒޑސޖޏޓގޗ = 3789..3789 + 10
        println(ޒޑސޖޏޓގޗ.random())
        return ގދމޅޡތބޝ()
    }

    private fun ޜޣޓނޣޏޙޕ(): Vxwm {
        return ނގޛފބޓގތ()
    }

    private fun ހސޚޕށށޚޛ() {
        ޖޢޕމބވގޠ()
    }

    fun getLocalConfigBean(): Vxwm {
        return ވޔޕށފށފގ()
    }

    private fun ނގޛފބޓގތ(): Vxwm {
        return ދމޝދޘޝމޔ()
    }

    private fun ދމޝދޘޝމޔ(): Vxwm {
        return ޓޕސތޑޒޥބ()
    }

    private fun ވޔޕށފށފގ(): Vxwm {
        return ޜޣޓނޣޏޙޕ()
    }

    private fun ށޠޡޖޔޠޏޘ(): Vxwm {
        var configBean: Vxwm? = null
        class ކޘށޡކޅމފ(val ޞޘޠފސޑށސ: String, val ލދޏޅއޠބމ: Int)
        println(ކޘށޡކޅމފ("ޤޗބޘށޜޘއ", 6494))
        try {
            configBean = GsonUtils.fromJson(configSp, Vxwm::class.java)
        } catch (e: Exception) {
            e.printStackTrace()
        } finally {
            if (configBean == null) {
                Bnpt.logDebug(TAG, R.string.ޒޤޖލޓ_D.string((configBean).toString()))
                configBean = getLocalConfigBean()
            }
        }
        Fnpc.adShowCount = configBean.inter_show_limit
        val ޘހށޟޝވފޞ = { ޣޣޖގދޕޕށ: String -> println(ޣޣޖގދޕޕށ) }
        ޘހށޟޝވފޞ("ޙބޟބވޗޏޥ!")
        Fnpc.nativeAdShowCount = configBean.native_show_limit
        Fnpc.isNowPlayAd = configBean.isNowPlayAd
        SPUtils.getInstance().put(R.string.ޝގޅޠޢ_D.string(), configBean.open_time_out)
        abstract class ނޠޝބދޓޕސ {
            abstract fun ޜއޅޟޅޕޔޏ()
        }
        class ޟލޞޓޒޅށޟ : ނޠޝބދޓޕސ() {
            override fun ޜއޅޟޅޕޔޏ() {
                println("ޚޅހޒހލޒއ")
            }
        }
        val ޗޔޖޝތދޡޔ = ޟލޞޓޒޅށޟ()
        ޗޔޖޝތދޡޔ.ޜއޅޟޅޕޔޏ()
        Bnpt.logDebug(TAG, R.string.ޒޤޖލޓ_D.string((configBean).toString()))
        fun ވޖދޗއލދޕ(ނޣޝޏޝޤޕޏ: String) {
            println("tag, $ނޣޝޏޝޤޕޏ!")
        }
        ވޖދޗއލދޕ("މދޙތޔޖޟސ")
        return configBean
    }

    private fun ޗޜޘޚޓޢޥޙ(): Vxwm {
        class ޔވނޤޕޜވސ {
            fun ޚކޚޡޠރޙޛ() {
                println("ޡޤށޑޠޔޟޜ")
            }
        }
        ޔވނޤޕޜވސ().ޚކޚޡޠރޙޛ()
        return ށޠޡޖޔޠޏޘ()
    }

    private fun ޖޢޕމބވގޠ() {
        ޖޖޡރދށނޘ()
    }

    private fun ގދމޅޡތބޝ(): Vxwm {
        if (System.currentTimeMillis() < 1649) {
            println(System.currentTimeMillis())
        }
        return މށޑޗޜޒޡޗ()
    }
}

