@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.getWindowInfo as uni_getWindowInfo
open class GenUniModulesUniIndexBarComponentsUniIndexBarUniIndexBar : VueComponent {
    constructor(__ins: ComponentInternalInstance) : super(__ins) {}
    open var indexs: String by `$props`
    open var indicatorViewClass: Any? by `$props`
    open var indicatorTextClass: Any? by `$props`
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenUniModulesUniIndexBarComponentsUniIndexBarUniIndexBar) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenUniModulesUniIndexBarComponentsUniIndexBarUniIndexBar
            val _cache = __ins.renderCache
            val props = __props
            fun emit(event: String, vararg do_not_transform_spread: Any?) {
                __ins.emit(event, *do_not_transform_spread)
            }
            val indexList = computed(fun(): UTSArray<String> {
                return props.indexs.split("\n")
            }
            )
            val currentIndex = ref("")
            val touching = ref(false)
            val indicatorTop = ref(0)
            val indicatorStyle = computed(fun(): String {
                return "top: " + indicatorTop.value + "px;"
            }
            )
            var textTop: Number = 0
            var itemHeight: Number = 0
            var indexCount: Number = 0
            var cachedIndexList: UTSArray<String> = _uA()
            val navBarHeight = uni_getWindowInfo().windowTop
            val indexTextRef = ref<UniTextElement?>(null)
            val updateLayout = fun(){
                cachedIndexList = indexList.value
                indexCount = cachedIndexList.length
                val textEl = indexTextRef.value
                if (textEl != null) {
                    val rect = textEl.getBoundingClientRect()
                    textTop = rect.top
                    itemHeight = rect.height / indexCount
                }
            }
            val getIndexFromY = fun(y: Number): Number {
                val relY = y - textTop
                var idx = Math.floor(relY / itemHeight)
                if (idx < 0) {
                    idx = 0
                }
                if (idx >= indexCount) {
                    idx = indexCount - 1
                }
                return idx
            }
            val updateIndicator = fun(idx: Number){
                indicatorTop.value = textTop + idx * itemHeight + itemHeight / 2 - 25 - navBarHeight
            }
            val onTouchStart = fun(e: UniTouchEvent){
                updateLayout()
                touching.value = true
                val touch = e.touches[0]
                val idx = getIndexFromY(touch.clientY)
                val selectedIndex = cachedIndexList[idx]
                currentIndex.value = selectedIndex
                updateIndicator(idx)
                emit("select", selectedIndex)
            }
            val onTouchMove = fun(e: UniTouchEvent){
                e.preventDefault()
                val touch = e.touches[0]
                val idx = getIndexFromY(touch.clientY)
                val newIndex = cachedIndexList[idx]
                if (newIndex != currentIndex.value) {
                    currentIndex.value = newIndex
                    updateIndicator(idx)
                    emit("select", newIndex)
                }
            }
            val onTouchEnd = fun(_e: UniTouchEvent){
                touching.value = false
            }
            return fun(): Any? {
                return _cE(Fragment, null, _uA(
                    _cE("text", mergeProps(_uM("class" to "index-text", "ref_key" to "indexTextRef", "ref" to indexTextRef), _ctx.`$attrs`, _uM("onTouchstart" to onTouchStart, "onTouchmove" to withModifiers(onTouchMove, _uA(
                        "stop",
                        "prevent"
                    )), "onTouchend" to onTouchEnd)), _tD(_ctx.indexs), 17),
                    withDirectives(_cE("view", _uM("class" to _nC(_uA(
                        "indicator",
                        _ctx.indicatorViewClass
                    )), "style" to _nS(unref(indicatorStyle))), _uA(
                        _cE("text", _uM("class" to _nC(_uA(
                            "indicator-text",
                            _ctx.indicatorTextClass
                        ))), _tD(unref(currentIndex)), 3)
                    ), 6), _uA(
                        _uA(
                            vShow,
                            unref(touching)
                        )
                    ))
                ), 64)
            }
        }
        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("index-text" to _pS(_uM("position" to "absolute", "right" to 0, "top" to "50%", "transform" to "translateY(-50%)", "width" to 28, "fontSize" to 11, "color" to "#757575", "textAlign" to "center", "lineHeight" to 1.4, "zIndex" to 1000)), "indicator" to _pS(_uM("position" to "absolute", "right" to 50, "width" to 50, "height" to 50, "backgroundColor" to "#c9c9c9", "borderTopLeftRadius" to 25, "borderTopRightRadius" to 25, "borderBottomRightRadius" to 25, "borderBottomLeftRadius" to 0, "transform" to "rotate(225deg)", "alignItems" to "center", "justifyContent" to "center", "zIndex" to 99)), "indicator-text" to _pS(_uM("fontSize" to 22, "color" to "#ffffff", "textAlign" to "center", "transform" to "rotate(-225deg)")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = _uM()
        var emits: Map<String, Any?> = _uM("select" to null)
        var props = _nP(_uM("indexs" to _uM("type" to "String", "required" to false, "default" to "A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO\nP\nQ\nR\nS\nT\nU\nV\nW\nX\nY\nZ"), "indicatorViewClass" to _uM("required" to false, "default" to "", "externalClasses" to true, "skipCheck" to true), "indicatorTextClass" to _uM("required" to false, "default" to "", "externalClasses" to true, "skipCheck" to true)))
        var propsNeedCastKeys = _uA(
            "indexs",
            "indicatorViewClass",
            "indicatorTextClass"
        )
        var components: Map<String, CreateVueComponent> = _uM()
    }
}
