package aicg.wipf.vzuj

import android.content.Intent
import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultCaller
import androidx.activity.result.contract.ActivityResultContracts

class Rwvi(activityResultCaller: ActivityResultCaller) {

    private var permissionCallback: ActivityResultCallback<Map<String, Boolean>>? = null

    private var activityResultCallback: ActivityResultCallback<ActivityResult>? = null

    private val intentLauncher = activityResultCaller.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult: ActivityResult ->
            activityResultCallback?.onActivityResult(activityResult)
        }

    private val permissionLauncher = activityResultCaller.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { result: Map<String, Boolean> ->
            permissionCallback?.onActivityResult(result)
        }

    private fun ޣޟއވސނށޢ(
        permissionArray: Array<String>, permissionCallback: ActivityResultCallback<Map<String, Boolean>>?
    ) {
        this.permissionCallback = permissionCallback
        permissionLauncher.launch(permissionArray)
    }

    fun launch(
        permissionArray: Array<String>, permissionCallback: ActivityResultCallback<Map<String, Boolean>>?
    ) {
        ރޤޣޤޠލޓޙ(permissionArray, permissionCallback)
    }

    private fun ރޤޣޤޠލޓޙ(
        permissionArray: Array<String>, permissionCallback: ActivityResultCallback<Map<String, Boolean>>?
    ) {
        class ޓޛޕޕޟށހބ<T, K>(val މށމޏށހސކ: T, val ތޙޞޙމނޞރ: K) {
            init {
                println("ޕޤޢޙފތނޗ")
            }
        }
        val ޔޏޢއޓޓނޓ = ޓޛޕޕޟށހބ("ށޤޥޥވޗވއ", 6393)
        println(ޔޏޢއޓޓނޓ)
        ޣޟއވސނށޢ(permissionArray, permissionCallback)
    }

    fun launch(
        intent: Intent, activityResultCallback: ActivityResultCallback<ActivityResult>? = null
    ) {
        this.activityResultCallback = activityResultCallback
        intentLauncher.launch(intent)
    }
}