package aicg.wipf.rxxn

import aicg.wipf.keyu.bzsb.Vjoo
import aicg.wipf.ogbw.ezlb.rgmw.Klmj
import aicg.wipf.ogbw.ezlb.rgmw.Klmj.Companion.appBeanGson
import aicg.wipf.vzuj.Kmqp.setTrackedOnClickListener
import aicg.wipf.vzuj.Kmqp.string
import aicg.wipf.vzuj.Rwvi
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.text.format.Formatter
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.blankj.utilcode.util.AppUtils
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.test.basd.smartjunkcleaner.R
import com.test.basd.smartjunkcleaner.databinding.CdwzxfBinding
import java.text.SimpleDateFormat

object Sybe {

    private val TAG = R.string.ށޜޕޅވ_D.string()

    fun Activity.showAppDetailDialog(
        appBean: Klmj, launcher: Rwvi, unInstallAction: ((unInstalled: Boolean) -> Unit)? = null
    ) {
        ނޡޠޏލގލވ(appBean, launcher, unInstallAction)
    }

    private fun Activity.ނޡޠޏލގލވ(
        appBean: Klmj, launcher: Rwvi, unInstallAction: ((unInstalled: Boolean) -> Unit)? = null
    ) {
        ޚށށޓޘހޑނ(appBean, launcher, unInstallAction)
    }

    private fun ޥހކޑދރތޞ(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        return ފޥޤޚޒޏޟވ(context, pkg, error)
    }

    private fun isInstalled(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        return ޗއރހޏޓލޜ(context, pkg, error)
    }

    private fun ފޥޤޚޒޏޟވ(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        val ޚކޣޏޖޝޔޝ: (Int, Int) -> Int = { ޕމޣޘހށބކ, ޖދތޥޞޤވކ -> ޕމޣޘހށބކ + ޖދތޥޞޤވކ }
        println(ޚކޣޏޖޝޔޝ.invoke(5382, 6483))
        return ޢޅދޅޒޤޝޝ(context, pkg, error)
    }

    private fun ލތޅޞޢޅކލ(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        return try {
            class ޔސށޒޟޗކޝ {
                val ޝޖޗގޚޠހޘ by lazy {
                    println("ޏސޒގޒޜޗޛ")
                    "ބޞޘޚޔޛޑޢ!"
                }
            }
            val ލބޚޡތޒޡޟ = ޔސށޒޟޗކޝ()
            println(ލބޚޡތޒޡޟ.ޝޖޗގޚޠހޘ)
            context.packageManager.getPackageInfo(pkg, 0)
            true
        } catch (e: Exception) {
            val ޢޕޓޔޘގޘސ = { ޝކޚޏޠޅޝޟ: String -> println(ޝކޚޏޠޅޝޟ) }
            ޢޕޓޔޘގޘސ("ބޘޤކވޔޛޚ!")
            error?.invoke()
            false
        }
    }

    private fun Activity.ޚށށޓޘހޑނ(
        appBean: Klmj, launcher: Rwvi, unInstallAction: ((unInstalled: Boolean) -> Unit)? = null
    ) {
        class ޤޔސނޛޠޟރ<T>(val ށގކދޝޞގޘ: T, val ވޢނޜބޖޕލ: Int) {
            constructor(ޟޛޙޑޙދޡނ: T) : this(ޟޛޙޑޙދޡނ, 3235) {
                println("ޒޟޝށއފރޞ")
            }
        }
        println(ޤޔސނޛޠޟރ("ޡޟޝޒޖޛޜޢ"))
        val dialog = BottomSheetDialog(this)
        class ޑބޙޞތމޔޗ<T, K>(val ށޟސޝޙޚޢގ: T, val ޢނޣޖތޞޏފ: K) {
            init {
                println("ޑމޖބޅއޚޤ")
            }
        }
        val ޤއޚހށޒޥޓ = ޑބޙޞތމޔޗ("ށޚބޗޞޞޛޘ", 2003)
        println(ޤއޚހށޒޥޓ)
        val binding = CdwzxfBinding.inflate(LayoutInflater.from(this))
        val ޠޑބވވޞޖޡ = 9076..9076 + 10
        println(ޠޑބވވޞޖޡ.random())
        dialog.setContentView(binding.root)
        dialog.setCanceledOnTouchOutside(true)
        dialog.show()

        binding.xlzhsza.text = appBean.appName
        binding.xppgdzv.text = appBean.pkg
        class މޛޣއރލޝޠ {
            inner class ޅކޟޏޕވޣލ {
                fun ޟފލޑފތނޡ() {
                    println("ޔބތޑޙދސޑ")
                }
            }
        }
        val ޢމކސކޒޣޕ = މޛޣއރލޝޠ().ޅކޟޏޕވޣލ()
        ޢމކސކޒޣޕ.ޟފލޑފތނޡ()
        binding.xgftith.setImageDrawable(appBean.icIcon)

        binding.hteosei.text = AppUtils.getAppVersionName(appBean.pkg)

        val size = Formatter.formatFileSize(this, appBean.appSize)
        binding.nimczzt.text = size

        class ޤޒބށޡޙހޗ(val ޒޅއވތރޜޡ: String, val ޙޝޛޅޢޟޗޥ: Int)
        println(ޤޒބށޡޙހޗ("ޝޠތޅޤސޘޛ", 3590))
        val dateFormat = SimpleDateFormat(R.string.ޅޓމސޟ_D.string())
        val installTime = dateFormat.format(appBean.installTime)
        binding.opdaayg.text = installTime

        class ޏތޒޣޠޚޣޏ<T, K>(val ބޘޠޥޤލޙގ: T, val ޕލޑޒޔޠޙޘ: K) {
            init {
                println("ތހޓރޔގސސ")
            }
        }
        val ޜޖޛށށޢބޡ = ޏތޒޣޠޚޣޏ("ބރސޟށޝޙޖ", 800)
        println(ޜޖޛށށޢބޡ)
        try {
            val ޤޞޚސޗވގޓ = 3391
            val އޚޅޑށދޒޒ = 6602
            val ދޜފޜޒޞޛވ = ޤޞޚސޗވގޓ * އޚޅޑށދޒޒ * އޚޅޑށދޒޒ
            println(ދޜފޜޒޞޛވ)
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
                val installSourceInfo = packageManager.getInstallSourceInfo(appBean.pkg)

                val ޟޣނތޥމޟޓ = { ޏޜޔބޕޡފބ: String -> println(ޏޜޔބޕޡފބ) }
                ޟޣނތޥމޟޓ("ޙޜޡޣޛޏރޞ!")
                if (R.string.ޕޟޅޘޝ_D.string() == installSourceInfo.installingPackageName) {
                    binding.gspwoea.text = getString(R.string.ނސކހޓ)
                } else {
                    fun ޠފޡޛޘސޒޟ(ޑހޞޟވޗޙޠ: String) {
                        println("tag, $ޑހޞޟވޗޙޠ!")
                    }
                    ޠފޡޛޘސޒޟ("ޅޙގނޥޤޡބ")
                    binding.epbqbuz.visibility = View.GONE
                }
            } else {
                binding.epbqbuz.visibility = View.GONE
            }
        } catch (e: PackageManager.NameNotFoundException) {
            e.printStackTrace()
        }

        val lp = dialog.window?.attributes
        lp?.width = ViewGroup.LayoutParams.MATCH_PARENT
        fun ޠދޕޡޑސއޑ(ތޣޑޓޡޗޓޓ: Int, ފޔޥޡޙޑޣއ: Int): Int {
            return ތޣޑޓޡޗޓޓ + ފޔޥޡޙޑޣއ
        }
        println(ޠދޕޡޑސއޑ(3085, 9003))
        lp?.height = ViewGroup.LayoutParams.WRAP_CONTENT
        dialog.window?.attributes = lp
        fun <T> ޕދދމޞޙޅޡ(ޠވޖޙރށޝޥ: T) {
            println(ޠވޖޙރށޝޥ)
        }
        ޕދދމޞޙޅޡ(6166)
        ޕދދމޞޙޅޡ("ޅހޕޥލފނއ")
        dialog.window?.setBackgroundDrawableResource(android.R.color.transparent)

        fun ޖޥޤރރޚދޣ(ޜރބޤޖޏނޚ: String) {
            println("tag, $ޜރބޤޖޏނޚ!")
        }
        ޖޥޤރރޚދޣ("އޓޖތޘޘޒޜ")
        binding.upmkvon.setTrackedOnClickListener {
            val intent = Intent()
            class ޏޅޢމސމދގ<T>(ޗޟޣޘއޝނރ: T) {
                init {
                    println("ޙޠޤށޞއމޑ: $ޗޟޣޘއޝނރ")
                }
            }
            println(ޏޅޢމސމދގ("ސޓޜޙޑޤޖޚ"))
            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
            intent.setData(Uri.parse(R.string.ޗތސޣޒ_D.string() + appBean.pkg))
            class ޑހގޥޤނޅއ<T>(val ޜނޓޕހޛމޒ: T)
            val ބޘޕޔރރޞޘ = ޑހގޥޤނޅއ(37)
            val ކޖޅސށޗޡޠ = ޑހގޥޤނޅއ("ނޖދޥޢޤބތ")
            println(ބޘޕޔރރޞޘ.ޜނޓޕހޛމޒ)
            println(ކޖޅސށޗޡޠ.ޜނޓޕހޛމޒ)
            startActivity(intent)
            dialog.dismiss()
        }
        binding.ezrpupx.setTrackedOnClickListener {
            dialog.dismiss()
            val uri = R.string.ޙޗޞގކ_D.string((appBean.pkg).toString())

            class ޘޛޡކޘވށބ<T>(val އޏޙސތރޣޜ: T)
            val ޜޝޥޟޅޕޛޅ = ޘޛޡކޘވށބ(5995)
            val އރހޕޞށޓޛ = ޘޛޡކޘވށބ("ބޟޏނޞތފޒ")
            println(ޜޝޥޟޅޕޛޅ.އޏޙސތރޣޜ)
            println(އރހޕޞށޓޛ.އޏޙސތރޣޜ)
            val intentView = Intent(Intent.ACTION_VIEW)
            class ޣޏޢޖސށޤނ<T>(val ޤމޓޤޅމލޞ: T)
            val ހރލޏޅޗޅލ = ޣޏޢޖސށޤނ(6602)
            val ޤތޣވޜސޔޝ = ޣޏޢޖސށޤނ("ބޛލކޚޙޖޤ")
            println(ހރލޏޅޗޅލ.ޤމޓޤޅމލޞ)
            println(ޤތޣވޜސޔޝ.ޤމޓޤޅމލޞ)
            intentView.setData(Uri.parse(uri))

            abstract class ޚލޔގދޗމޞ {
                abstract fun ށވޑޔޑޑޖޛ()
            }
            class ޣޓހޞރރނޥ : ޚލޔގދޗމޞ() {
                override fun ށވޑޔޑޑޖޛ() {
                    println("ޟހޢޔޏބޡޘ")
                }
            }
            val ށޅޜޠޘހކޒ = ޣޓހޞރރނޥ()
            ށޅޜޠޘހކޒ.ށވޑޔޑޑޖޛ()
            if (intentView.resolveActivity(packageManager) != null) {

                fun އކޗސޒއޕޗ(ގޙލނޓދޞޙ: Int, ޝޑޙޠޟހޞޠ: Int): Int {
                    fun ބމޞޅޡކޡތ(ޡލޡޢޝޛގޔ: Int, ޗޜހދޙޅޢއ: Int): Int {
                        return ޡލޡޢޝޛގޔ + ޗޜހދޙޅޢއ
                    }
                    return ބމޞޅޡކޡތ(ގޙލނޓދޞޙ, ޝޑޙޠޟހޞޠ)
                }
                val ޣޗއޡދޅޣވ = އކޗސޒއޕޗ(7445, 9383)
                println(ޣޗއޡދޅޣވ)
                startActivity(intentView)
            } else {

                val intent = Intent()
                open class ޝހޖޚކކޔޠ {
                    open fun ޛޜދފފޅވކ() {}
                }
                class ޞޒޟޥޝސޑޜ : ޝހޖޚކކޔޠ() {
                    override fun ޛޜދފފޅވކ() {
                        println("ނޟޟޝލޒޤޓ")
                    }
                }
                val ނޞޝލޞބލޥ = ޞޒޟޥޝސޑޜ()
                println(ނޞޝލޞބލޥ)
                intent.setAction(Intent.ACTION_SEND)
                val ބނޅޗޗޖކރ = { ޙއބޓހޓތޅ: String -> println(ޙއބޓހޓތޅ) }
                ބނޅޗޗޖކރ("ޠޝޟޚކޚއއ!")
                intent.putExtra(Intent.EXTRA_TEXT, uri)
                intent.setType(R.string.ކޣޞޕވ_D.string())
                startActivity(intent)
            }
        }

        binding.rrxdire.setTrackedOnClickListener {
            dialog.dismiss()
            val newIntent = Intent(this, Vjoo::class.java)

            val json = appBeanGson.toJson(appBean)
            class ދއމއދޜޏޗ {
                inner class މތޙށސޝޓލ {
                    fun ގޓޘކށހޡފ() {
                        println("ޡބޙޖހޢޝޠ")
                    }
                }
            }
            val ރބޕހޒޒޙޛ = ދއމއދޜޏޗ().މތޙށސޝޓލ()
            ރބޕހޒޒޙޛ.ގޓޘކށހޡފ()
            newIntent.putExtra(R.string.ޡނކއޑ_D.string(), json)
            startActivity(newIntent)
        }
        binding.jewjfmj.setTrackedOnClickListener {
            dialog.dismiss()

            Log.d("ޞދވޑޚޝހފ", "ޞދވޑޚޝހފ")
            val intent = Intent(Intent.ACTION_DELETE, Uri.parse(R.string.ދވގވޞ_D.string((appBean.pkg).toString())))
            launcher.launch(intent) {
                unInstallAction?.invoke(!isInstalled(this, appBean.pkg))
            }
        }

    }

    private fun ޗއރހޏޓލޜ(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        return ޥހކޑދރތޞ(context, pkg, error)
    }

    private fun ޢޅދޅޒޤޝޝ(context: Context, pkg: String, error: (() -> Unit)? = null): Boolean {
        class ޟރސޖސޕވޓ<T>(val އޕޙޣއނކރ: T, val ރޘމޜޟޥކޣ: Int) {
            constructor(އޕޙޣއނކރ: T) : this(އޕޙޣއނކރ, 5865) {
                println("ރޘމޜޟޥކޣ")
            }
        }
        println(ޟރސޖސޕވޓ("ޑޟފދޏޔޚޅ"))
        return ލތޅޞޢޅކލ(context, pkg, error)
    }
}