"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
;/* empty css                                               */
;/* empty css                                                 */
;/* empty css                                                */
;/* empty css                                               */
;/* empty css                                                */
;/* empty css                                                     */
;/* empty css                                              */
const Vue = require("vue");
const common = require("../../../utils/common.js");
const page = require("../../../page.vue.js");
;/* empty css           */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/vant/es/tabs/index.js");
const index$1 = require("../../../../node_modules/vant/es/tab/index.js");
const _hoisted_1 = { class: "fec-tab-content" };
const _sfc_main = {
  __name: "Tabs",
  props: {
    params: {
      type: Object,
      default: {}
    },
    modelValue: {
      type: String,
      default: ""
    },
    options: {
      type: Array,
      default: []
    },
    autoHeight: {
      //高度自适应
      type: Boolean,
      default: true
    },
    height: {
      //高度
      type: String,
      default: "300"
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const pageList = Vue.inject("pageList");
    const activeName = Vue.computed({
      get: () => {
        return props.modelValue;
      },
      set: (val) => {
        emit("update:modelValue", val);
      }
    });
    const compHeight = Vue.computed(() => {
      if (props.autoHeight) {
        return "100%";
      } else {
        return props.height + "px";
      }
    });
    const pageCache = Vue.computed(() => {
      const cache = {};
      props.options.forEach((item) => {
        if (item.pageId) {
          cache[item.pageId] = common.findPageById(pageList.value, item.pageId);
        }
      });
      console.log("🚀 ~ cache:", cache);
      return cache;
    });
    const getPage = (pageId) => {
      return pageCache.value[pageId] || null;
    };
    return (_ctx, _cache) => {
      const _component_van_tab = index$1.Tab;
      const _component_van_tabs = index.Tabs;
      return Vue.openBlock(), Vue.createElementBlock("div", {
        class: "fec-tabs-container",
        style: Vue.normalizeStyle("height:" + Vue.unref(compHeight))
      }, [
        Vue.createVNode(_component_van_tabs, {
          sticky: "",
          class: "fec-tabs",
          active: Vue.unref(activeName),
          "onUpdate:active": _cache[0] || (_cache[0] = ($event) => Vue.isRef(activeName) ? activeName.value = $event : null),
          "lazy-render": ""
        }, {
          default: Vue.withCtx(() => [
            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(__props.options, (item) => {
              return Vue.openBlock(), Vue.createBlock(_component_van_tab, Vue.mergeProps({ ref_for: true }, item, {
                name: item.id,
                replace: "",
                "show-zero-badge": false
              }), {
                default: Vue.withCtx(() => [
                  Vue.createElementVNode("div", _hoisted_1, [
                    item.pageId && getPage(item.pageId) ? (Vue.openBlock(), Vue.createBlock(page.default, {
                      key: 0,
                      parentPage: getPage(item.pageId),
                      params: __props.params
                    }, null, 8, ["parentPage", "params"])) : Vue.createCommentVNode("", true)
                  ])
                ]),
                _: 2
              }, 1040, ["name"]);
            }), 256))
          ]),
          _: 1
        }, 8, ["active"])
      ], 4);
    };
  }
};
const _Tabs = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-3ac885e8"]]);
exports.default = _Tabs;
