import { defineComponent, defineAsyncComponent, reactive, computed, onMounted, onUnmounted, openBlock, createElementBlock, createBlock, unref, createCommentVNode, createVNode, withCtx, Fragment, renderList, renderSlot, mergeProps } from 'vue';
import { useRoute } from 'vue-router';
import { storeToRefs } from 'pinia';
import '../../../../../stores/index.mjs';
import emitter from '../../../../../utils/mitt.mjs';
import { useRoutesList } from '../../../../../stores/routesList.mjs';
import { useThemeConfig } from '../../../../../stores/themeConfig.mjs';

const _hoisted_1 = { class: "layout-navbars-breadcrumb-index" };
var _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    const Breadcrumb = defineAsyncComponent(() => import('./breadcrumb.vue.mjs'));
    const User = defineAsyncComponent(() => import('./user.vue.mjs'));
    const Logo = defineAsyncComponent(() => import('../../logo/index.vue.mjs'));
    const Horizontal = defineAsyncComponent(() => import('../../navMenu/horizontal.vue.mjs'));
    const stores = useRoutesList();
    const storesThemeConfig = useThemeConfig();
    const { themeConfig } = storeToRefs(storesThemeConfig);
    const { routesList } = storeToRefs(stores);
    const route = useRoute();
    const state = reactive({
      menuList: []
    });
    const setIsShowLogo = computed(() => {
      let { isShowLogo, layout } = themeConfig.value;
      return isShowLogo && layout === "classic" || isShowLogo && layout === "transverse";
    });
    const isLayoutTransverse = computed(() => {
      let { layout, isClassicSplitMenu } = themeConfig.value;
      return layout === "transverse" || isClassicSplitMenu && layout === "classic";
    });
    const setFilterRoutes = () => {
      let { layout, isClassicSplitMenu } = themeConfig.value;
      if (layout === "classic" && isClassicSplitMenu) {
        state.menuList = delClassicChildren(filterRoutesFun(routesList.value));
        const resData = setSendClassicChildren(route.path);
        emitter.emit("setSendClassicChildren", resData);
      } else {
        state.menuList = filterRoutesFun(routesList.value);
      }
    };
    const delClassicChildren = (arr) => {
      arr.map((v) => {
        if (v.children) delete v.children;
      });
      return arr;
    };
    const filterRoutesFun = (arr) => {
      return arr.filter((item) => {
        var _a;
        return !((_a = item.meta) == null ? void 0 : _a.isHide);
      }).map((item) => {
        item = Object.assign({}, item);
        if (item.children) item.children = filterRoutesFun(item.children);
        return item;
      });
    };
    const setSendClassicChildren = (path) => {
      const currentPathSplit = path.split("/");
      let currentData = { children: [] };
      filterRoutesFun(routesList.value).map((v, k) => {
        if (v.path === `/${currentPathSplit[1]}`) {
          v["k"] = k;
          currentData["item"] = { ...v };
          currentData["children"] = [{ ...v }];
          if (v.children) currentData["children"] = v.children;
        }
      });
      return currentData;
    };
    onMounted(() => {
      setFilterRoutes();
      emitter.on("getBreadcrumbIndexSetFilterRoutes", () => {
        setFilterRoutes();
      });
    });
    onUnmounted(() => {
      emitter.off("getBreadcrumbIndexSetFilterRoutes", () => {
      });
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        setIsShowLogo.value ? (openBlock(), createBlock(unref(Logo), { key: 0 })) : createCommentVNode("v-if", true),
        createVNode(unref(Breadcrumb)),
        isLayoutTransverse.value ? (openBlock(), createBlock(unref(Horizontal), {
          key: 1,
          menuList: state.menuList
        }, null, 8, ["menuList"])) : createCommentVNode("v-if", true),
        !_ctx.$slots.user ? (openBlock(), createBlock(unref(User), { key: 2 }, {
          default: withCtx(() => [
            (openBlock(true), createElementBlock(
              Fragment,
              null,
              renderList(_ctx.$slots, (_, name) => {
                return renderSlot(_ctx.$slots, name, mergeProps({
                  key: name,
                  ref_for: true
                }, _ctx.$slots[name].props || {}));
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ]),
          _: 3
          /* FORWARDED */
        })) : renderSlot(_ctx.$slots, "user", { key: 3 })
      ]);
    };
  }
});

export { _sfc_main as default };
