@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
open class GenUniModulesUniTabBarComponentsUniTabBarUniTabBar : VueComponent {
    constructor(__ins: ComponentInternalInstance) : super(__ins) {}
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenUniModulesUniTabBarComponentsUniTabBarUniTabBar) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenUniModulesUniTabBarComponentsUniTabBarUniTabBar
            val _cache = __ins.renderCache
            val tabBarLayout = inject<Ref<UniTabBarLayout>>("uniTabBarLayout", ref(UniTabBarLayout(tabListBaseHeight = 50, windowWidth = 0, safeAreaInsetBottom = 0)))
            val changeTab = inject<(index: Number) -> Unit>("uniTabBarChangeTab", fun(index: Number){})
            val itemCount = ref<Number>(0)
            val hasMidButtonItem = ref<Boolean>(false)
            val midButtonWidth = ref<Number>(0)
            val containerWidth = ref<Number>(0)
            val tabBarRef = ref<UniElement?>(null)
            val tabBarStyle = computed(fun(): UTSJSONObject {
                return _uO("height" to (tabBarLayout.value.tabListBaseHeight + "px"), "paddingBottom" to (tabBarLayout.value.safeAreaInsetBottom + "px"))
            }
            )
            val validMidButtonLayout = computed(fun(): Boolean {
                return hasMidButtonItem.value && itemCount.value > 0 && itemCount.value % 2 == 0 && midButtonWidth.value > 0
            }
            )
            fun gen_registerItem_fn(): Number {
                val index = itemCount.value
                itemCount.value++
                return index
            }
            val registerItem = ::gen_registerItem_fn
            fun gen_getItemLayout_fn(index: Number): UniTabListItemLayout {
                if (itemCount.value <= 0 || tabBarLayout.value.windowWidth <= 0) {
                    return UniTabListItemLayout(width = 0, marginLeft = 0)
                }
                if (validMidButtonLayout.value) {
                    val itemWidth = (tabBarLayout.value.windowWidth - midButtonWidth.value) / itemCount.value
                    val middleIndex = itemCount.value / 2
                    return UniTabListItemLayout(width = itemWidth, marginLeft = if (index == middleIndex) {
                        midButtonWidth.value
                    } else {
                        0
                    }
                    )
                }
                return UniTabListItemLayout(width = tabBarLayout.value.windowWidth / itemCount.value, marginLeft = 0)
            }
            val getItemLayout = ::gen_getItemLayout_fn
            fun gen_syncContainerWidth_fn(): UTSPromise<Unit> {
                return wrapUTSPromise(suspend w1@{
                        val tabBarElement = tabBarRef.value
                        if (tabBarElement == null) {
                            return@w1
                        }
                })
            }
            val syncContainerWidth = ::gen_syncContainerWidth_fn
            fun gen_registerMidButton_fn(width: Number, height: Number): Unit {
                hasMidButtonItem.value = true
                midButtonWidth.value = width
                if (height <= 0) {
                    console.warn("uni-tab-midbutton: height 必须大于 0")
                }
            }
            val registerMidButton = ::gen_registerMidButton_fn
            fun gen_syncOccupiedHeight_fn(): Unit {
                if (hasMidButtonItem.value && validMidButtonLayout.value == false) {
                    console.warn("uni-tab-bar: mid-button 需要偶数个普通 uni-tab-item，才能保持居中均分布局")
                }
            }
            val syncOccupiedHeight = ::gen_syncOccupiedHeight_fn
            onMounted(fun(){
                syncOccupiedHeight()
            }
            )
            watch(fun(): Number {
                return itemCount.value
            }
            , fun(){
                syncOccupiedHeight()
            }
            )
            watch(fun(): Boolean {
                return hasMidButtonItem.value
            }
            , fun(){
                syncOccupiedHeight()
            }
            )
            provide("uniTabListRegisterItem", registerItem)
            provide("uniTabListGetItemLayout", getItemLayout)
            provide("uniTabListRegisterMidButton", registerMidButton)
            provide("uniTabListChangeTab", changeTab)
            return fun(): Any? {
                return _cE("view", _uM("ref_key" to "tabBarRef", "ref" to tabBarRef, "style" to _nS(unref(tabBarStyle)), "class" to "uni-tab-list-root"), _uA(
                    renderSlot(_ctx.`$slots`, "default")
                ), 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("uni-tab-list-root" to _pS(_uM("width" to "100%", "height" to 50, "position" to "absolute", "bottom" to 0, "boxSizing" to "content-box", "display" to "flex", "flexDirection" to "row", "justifyContent" to "flex-start", "alignItems" to "center", "overflow" to "visible", "borderTopWidth" to 0.5, "borderTopColor" to "rgba(0,0,0,0.33)", "borderTopStyle" to "solid")))
            }
        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()
    }
}
