@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "SENSELESS_COMPARISON", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIHelloUniAppX
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
import io.dcloud.uniapp.extapi.checkIsSoterEnrolledInDevice as uni_checkIsSoterEnrolledInDevice
import io.dcloud.uniapp.extapi.checkIsSupportSoterAuthentication as uni_checkIsSupportSoterAuthentication
import io.dcloud.uniapp.extapi.startSoterAuthentication as uni_startSoterAuthentication
open class GenPagesAPIAuthenticationAuthentication : BasePage {
    constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
        onLoad(fun(_: OnLoadOptions) {
            stat_instance.onLoad(this)
        }
        , __ins)
        onPageShow(fun() {
            stat_instance.onShow(this)
        }
        , __ins)
        onPageHide(fun() {
            stat_instance.onHide(this)
        }
        , __ins)
        onUnload(fun() {
            stat_instance.onUnload(this)
        }
        , __ins)
    }
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenPagesAPIAuthenticationAuthentication) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenPagesAPIAuthenticationAuthentication
            val _cache = __ins.renderCache
            val supportStatus = ref("未检查")
            val authResult = ref("等待认证")
            val getModeLabel = fun(mode: AuthMode): String {
                return if (mode == "fingerPrint") {
                    "指纹"
                } else {
                    "人脸"
                }
            }
            val checkSupport = fun(){
                uni_checkIsSupportSoterAuthentication(CheckIsSupportSoterAuthenticationOptions(success = fun(res){
                    supportStatus.value = if (res.supportMode.length > 0) {
                        "支持: " + res.supportMode.join(", ")
                    } else {
                        "不支持任何生物认证"
                    }
                }
                , fail = fun(err){
                    console.log("err: ", err)
                    supportStatus.value = "检查失败：[" + err.errCode + "]" + err.errMsg
                }
                ))
            }
            val checkAuth = fun(mode: AuthMode){
                uni_checkIsSoterEnrolledInDevice(CheckIsSoterEnrolledInDeviceOptions(checkAuthMode = mode, success = fun(res){
                    authResult.value = "" + getModeLabel(mode) + (if (res.isEnrolled) {
                        "已录入"
                    } else {
                        "未录入"
                    }
                    )
                }
                , fail = fun(err){
                    console.log("err: ", err)
                    authResult.value = "" + getModeLabel(mode) + "检查失败：[" + err.errCode + "]" + err.errMsg
                }
                ))
            }
            val startAuth = fun(mode: AuthMode){
                uni_startSoterAuthentication(StartSoterAuthenticationOptions(requestAuthModes = _uA(
                    mode
                ), challenge = "123456", authContent = "请用" + getModeLabel(mode) + "解锁", success = fun(res){
                    authResult.value = "" + getModeLabel(res.authMode as AuthMode) + "认证成功"
                }
                , fail = fun(err){
                    console.log("err: ", err)
                    authResult.value = "" + getModeLabel(mode) + "认证失败，[" + err.errCode + "]" + err.errMsg
                }
                ))
            }
            return fun(): Any? {
                return _cE("scroll-view", _uM("style" to _nS(_uM("flex" to "1", "padding" to "6px"))), _uA(
                    _cE("text", _uM("class" to "uni-h2"), "生物认证"),
                    _cE("text", _uM("class" to "notice"), "低版本安卓仅支持指纹，高版本 Android 指纹和人脸会弹出统一认证框。"),
                    _cE("text", _uM("class" to "uni-h3"), "设备支持情况"),
                    _cE("text", _uM("class" to "log-text"), _tD(unref(supportStatus)), 1),
                    _cE("button", _uM("class" to "margin-v", "onClick" to checkSupport), "检查支持的认证方式"),
                    _cE("text", _uM("class" to "uni-h3"), "录入状态检查"),
                    _cE("button", _uM("class" to "margin-v", "onClick" to fun(){
                        checkAuth("fingerPrint")
                    }
                    ), "检查指纹", 8, _uA(
                        "onClick"
                    )),
                    _cE("button", _uM("class" to "margin-v", "onClick" to fun(){
                        checkAuth("facial")
                    }
                    ), "检查人脸识别", 8, _uA(
                        "onClick"
                    )),
                    _cE("text", _uM("class" to "uni-h3"), "认证结果"),
                    _cE("text", _uM("class" to "log-text"), _tD(unref(authResult)), 1),
                    _cE("button", _uM("class" to "margin-v", "onClick" to fun(){
                        startAuth("fingerPrint")
                    }
                    , "type" to "primary"), "指纹认证", 8, _uA(
                        "onClick"
                    )),
                    _cE("button", _uM("class" to "margin-v", "onClick" to fun(){
                        startAuth("facial")
                    }
                    , "type" to "primary"), "人脸认证", 8, _uA(
                        "onClick"
                    ))
                ), 4)
            }
        }
        val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
            _nCS(_uA(
                styles0
            ))
        }
        val styles0: Map<String, Map<String, Map<String, Any>>>
            get() {
                return _uM("margin-v" to _pS(_uM("marginTop" to 5, "marginRight" to 0, "marginBottom" to 5, "marginLeft" to 0)), "log-text" to _pS(_uM("paddingTop" to 10, "paddingRight" to 10, "paddingBottom" to 10, "paddingLeft" to 10, "fontSize" to 14, "borderTopWidth" to 1, "borderRightWidth" to 1, "borderBottomWidth" to 1, "borderLeftWidth" to 1, "borderTopStyle" to "solid", "borderRightStyle" to "solid", "borderBottomStyle" to "solid", "borderLeftStyle" to "solid", "borderTopColor" to "#cccccc", "borderRightColor" to "#cccccc", "borderBottomColor" to "#cccccc", "borderLeftColor" to "#cccccc")), "notice" to _pS(_uM("color" to "#550000", "fontSize" to 14, "fontStyle" to "italic")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = _uM()
        var emits: Map<String, Any?> = _uM()
        var props = _nP(_uM())
        var propsNeedCastKeys: UTSArray<String> = _uA()
        var components: Map<String, CreateVueComponent> = _uM()
    }
}
