@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.navigateTo as uni_navigateTo
import io.dcloud.uniapp.extapi.reLaunch as uni_reLaunch
import io.dcloud.uniapp.extapi.showToast as uni_showToast
open class GenPagesTabBarUniUi : 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: GenPagesTabBarUniUi) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenPagesTabBarUniUi
            val _cache = __ins.renderCache
            val instance = getCurrentInstance()?.proxy
            val list = ref<UTSArray<ListItem__1>>(_uA<ListItem__1>(ListItem__1(id = "badge", name = "uni-badge-view 数字角标", open = false, url = "/pages/uni-ui/badge-view/badge-view", pages = _uA<Page__2>()), ListItem__1(id = "collapse", name = "uni-collapse 折叠面板", open = false, url = "/pages/uni-ui/collapse/collapse", pages = _uA<Page__2>()), ListItem__1(id = "drag-cell", name = "uni-drag-cell 拖拽排序", open = false, url = "/pages/uni-ui/drag-cell/drag-cell", pages = _uA<Page__2>()), ListItem__1(id = "fab-button", name = "uni-fab-button 悬浮按钮", open = false, url = "/pages/uni-ui/fab-button/fab-button", pages = _uA<Page__2>()), ListItem__1(id = "index-bar", name = "uni-index-bar 索引栏", open = false, url = "/pages/uni-ui/index-bar/index-bar", pages = _uA<Page__2>()), ListItem__1(id = "link", name = "uni-link 链接", open = false, url = "/pages/uni-ui/link/link", pages = _uA<Page__2>()), ListItem__1(id = "nav-bar", name = "uni-nav-bar 导航栏", open = false, url = "/pages/uni-ui/nav-bar/nav-bar", pages = _uA<Page__2>()), ListItem__1(id = "number-box", name = "uni-number-box 数字输入框", open = false, url = "/pages/uni-ui/number-box/number-box", pages = _uA<Page__2>()), ListItem__1(id = "rate", name = "uni-rate 评分组件", open = false, url = "/pages/uni-ui/rate/rate", pages = _uA<Page__2>()), ListItem__1(id = "refresh-box", name = "uni-refresh-box 下拉刷新组件", open = false, url = "/pages/uni-ui/refresh-box/refresh-box", pages = _uA<Page__2>()), ListItem__1(id = "tab-bar", name = "uni-tab-bar 底部选项卡", open = false, pages = _uA<Page__2>(Page__2(name = "默认样式", url = "/pages/uni-ui/tab-bar/tab-bar"), Page__2(name = "暗色风格", url = "/pages/uni-ui/tab-bar/tab-bar-dark"), Page__2(name = "自定义样式", url = "/pages/uni-ui/tab-bar/tab-bar-custom"), Page__2(name = "中间按钮", url = "/pages/uni-ui/tab-bar/tab-bar-midbutton"), Page__2(name = "中间按钮镂空", url = "/pages/uni-ui/tab-bar/tab-bar-midbutton-notch"))), ListItem__1(id = "time-format", name = "uni-time-format 时间格式化", open = false, url = "/pages/uni-ui/time-format/time-format", pages = _uA<Page__2>())))
            val hasLeftWin = computed(fun(): Boolean {
                return !state.noMatchLeftWindow
            }
            )
            val leftWinActive = computed(fun(): String {
                val parts = state.leftWinActive.split("/").filter(fun(item): Boolean {
                    return item.length > 0
                }
                )
                return if (parts.length > 0) {
                    parts[parts.length - 1]
                } else {
                    ""
                }
            }
            )
            val isDarkMode = computed(fun(): Boolean {
                return state.isDarkMode
            }
            )
            fun gen_getPageKey_fn(url: String): String {
                val parts = url.split("/").filter(fun(item): Boolean {
                    return item.length > 0
                }
                )
                return if (parts.length > 0) {
                    parts[parts.length - 1]
                } else {
                    url
                }
            }
            val getPageKey = ::gen_getPageKey_fn
            fun gen_goDetailPage_fn(page: Page__2) {
                if (page.enable == false) {
                    uni_showToast(ShowToastOptions(icon = "none", title = "暂不支持"))
                    return
                }
                if (hasLeftWin.value) {
                    uni_reLaunch(ReLaunchOptions(url = page.url))
                } else {
                    uni_navigateTo(NavigateToOptions(url = page.url, fail = fun(_) {
                        console.log("页面跳转失败：" + page.url)
                    }
                    ))
                }
            }
            val goDetailPage = ::gen_goDetailPage_fn
            fun gen_triggerCollapse_fn(index: Number, item: ListItem__1) {
                if (item.pages.length == 0) {
                    val page = Page__2(name = item.name, enable = item.enable, url = item.url!!)
                    goDetailPage(page)
                    return
                }
                run {
                    var i: Number = 0
                    while(i < list.value.length){
                        list.value[i].open = if (index == i) {
                            !list.value[i].open
                        } else {
                            false
                        }
                        i++
                    }
                }
            }
            val triggerCollapse = ::gen_triggerCollapse_fn
            fun gen_syncCollapseState_fn(index: Number, open: Boolean) {
                run {
                    var i: Number = 0
                    while(i < list.value.length){
                        list.value[i].open = open && index == i
                        i++
                    }
                }
            }
            val syncCollapseState = ::gen_syncCollapseState_fn
            fun gen_syncActiveGroup_fn(path: String) {
                val matchedIndex = list.value.findIndex(fun(item): Boolean {
                    for(page in resolveUTSValueIterator(item.pages)){
                        if (getPageKey(page.url) == path) {
                            return true
                        }
                    }
                    if (item.url != null && getPageKey(item.url!!) == path) {
                        return true
                    }
                    return false
                }
                )
                if (matchedIndex == -1) {
                    return
                }
                run {
                    var i: Number = 0
                    while(i < list.value.length){
                        list.value[i].open = matchedIndex == i && list.value[i].pages.length > 0
                        i++
                    }
                }
            }
            val syncActiveGroup = ::gen_syncActiveGroup_fn
            watch(fun(): String {
                return leftWinActive.value
            }
            , fun(path: String){
                syncActiveGroup(path)
            }
            , WatchOptions(immediate = true))
            return fun(): Any? {
                val _component_uni_link = resolveEasyComponent("uni-link", GenUniModulesUniLinkComponentsUniLinkUniLinkClass)
                val _component_uni_collapse_item = resolveEasyComponent("uni-collapse-item", GenUniModulesUniCollapseComponentsUniCollapseItemUniCollapseItemClass)
                val _component_uni_collapse = resolveEasyComponent("uni-collapse", GenUniModulesUniCollapseComponentsUniCollapseUniCollapseClass)
                return _cE("scroll-view", _uM("style" to _nS(_uM("flex" to "1")), "enable-back-to-top" to "true"), _uA(
                    _cE("view", _uM("class" to _nC(_uA(
                        "uni-container",
                        if (unref(isDarkMode)) {
                            "theme-dark"
                        } else {
                            "theme-light"
                        }
                    ))), _uA(
                        if (isTrue(!unref(hasLeftWin))) {
                            _cE("view", _uM("key" to 0, "class" to "uni-header-logo"), _uA(
                                _cE("image", _uM("class" to "uni-header-image", "src" to "/static/extuiIndex.png"))
                            ))
                        } else {
                            _cC("v-if", true)
                        }
                        ,
                        if (isTrue(!unref(hasLeftWin))) {
                            _cE("view", _uM("key" to 1, "class" to "uni-text-box"), _uA(
                                _cE("text", _uM("class" to "hello-text"), "uni-ui x 扩展组件示例，文档详见："),
                                _cV(_component_uni_link, _uM("class" to "hello-text", "href" to "https://doc.dcloud.net.cn/uni-app-x/component/uni-ui-x", "target" to "_blank"), _uM("default" to withSlotCtx(fun(): UTSArray<Any> {
                                    return _uA(
                                        " https://doc.dcloud.net.cn/uni-app-x/component/uni-ui-x "
                                    )
                                }), "_" to 1))
                            ))
                        } else {
                            _cC("v-if", true)
                        }
                        ,
                        _cV(_component_uni_collapse, null, _uM("default" to withSlotCtx(fun(): UTSArray<Any> {
                            return _uA(
                                _cE(Fragment, null, RenderHelpers.renderList(unref(list), fun(item, index, __index, _cached): Any {
                                    return _cE(Fragment, _uM("key" to item.id), _uA(
                                        if (item.pages.length > 0) {
                                            _cV(_component_uni_collapse_item, _uM("key" to 0, "class" to "uni-panel pl-4 pr-4", "open" to item.open, "title" to item.name, "onChange" to fun(`$event`: Any){
                                                syncCollapseState(index, `$event` as Boolean)
                                            }), _uM("default" to withSlotCtx(fun(): UTSArray<Any> {
                                                return _uA(
                                                    _cE(Fragment, null, RenderHelpers.renderList(item.pages, fun(page, key, __index, _cached): Any {
                                                        return _cE("view", _uM("style" to _nS(_uM("padding-left" to "18px")), "class" to "uni-navigate-item", "hover-class" to if (page.enable == false) {
                                                            ""
                                                        } else {
                                                            "is--active"
                                                        }, "key" to key, "onClick" to fun(){
                                                            goDetailPage(page)
                                                        }), _uA(
                                                            _cE("text", _uM("class" to _nC(_uA(
                                                                "uni-navigate-text",
                                                                _uM("left-win-active" to (unref(leftWinActive) === getPageKey(page.url) && unref(hasLeftWin)), "text-disabled" to (page.enable == false))
                                                            ))), _tD(page.name), 3),
                                                            _cE("view", _uM("class" to "right_arrow"))
                                                        ), 12, _uA(
                                                            "hover-class",
                                                            "onClick"
                                                        ))
                                                    }), 128)
                                                )
                                            }), "_" to 2), 1032, _uA(
                                                "open",
                                                "title",
                                                "onChange"
                                            ))
                                        } else {
                                            _cE("view", _uM("key" to 1, "class" to "uni-panel"), _uA(
                                                _cE("view", _uM("hover-class" to "is--active", "class" to "uni-panel-h", "onClick" to fun(){
                                                    triggerCollapse(index, item)
                                                }
                                                ), _uA(
                                                    _cE("text", _uM("class" to _nC(_uA(
                                                        "uni-panel-text",
                                                        _uM("text-disabled" to (item.enable == false || item.open == true), "left-win-active" to (getPageKey(item.url!!) == unref(leftWinActive) && unref(hasLeftWin)))
                                                    ))), _tD(item.name), 3),
                                                    _cE("view", _uM("class" to "right_arrow"))
                                                ), 8, _uA(
                                                    "onClick"
                                                ))
                                            ))
                                        }
                                    ), 64)
                                }
                                ), 128)
                            )
                        }
                        ), "_" to 1))
                    ), 2)
                ), 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-panel-h" to _pS(_uM("flexDirection" to "row", "alignItems" to "center", "paddingTop" to 12, "paddingRight" to 18, "paddingBottom" to 12, "paddingLeft" to 18)), "uni-ui-navigate-item" to _pS(_uM("borderTopStyle" to "none")), "right_arrow" to _pS(_uM("width" to 8, "height" to 8, "marginLeft" to 12, "transform" to "rotate(-45deg)", "borderRightWidth" to 1, "borderRightStyle" to "solid", "borderRightColor" to "var(--arrow-color, #999999)", "borderBottomWidth" to 1, "borderBottomStyle" to "solid", "borderBottomColor" to "var(--arrow-color, #999999)")))
            }
        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()
    }
}
