'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var vueRouter = require('vue-router');
var pinia = require('pinia');
require('../../../../../stores/index.js');
var mitt = require('../../../../../utils/mitt.js');
var routesList = require('../../../../../stores/routesList.js');
var themeConfig = require('../../../../../stores/themeConfig.js');

const _hoisted_1 = { class: "layout-navbars-breadcrumb-index" };
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const Breadcrumb = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('./breadcrumb.vue.js'); }));
    const User = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('./user.vue.js'); }));
    const Logo = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('../../logo/index.vue.js'); }));
    const Horizontal = vue.defineAsyncComponent(() => Promise.resolve().then(function () { return require('../../navMenu/horizontal.vue.js'); }));
    const stores = routesList.useRoutesList();
    const storesThemeConfig = themeConfig.useThemeConfig();
    const { themeConfig: themeConfig$1 } = pinia.storeToRefs(storesThemeConfig);
    const { routesList: routesList$1 } = pinia.storeToRefs(stores);
    const route = vueRouter.useRoute();
    const state = vue.reactive({
      menuList: []
    });
    const setIsShowLogo = vue.computed(() => {
      let { isShowLogo, layout } = themeConfig$1.value;
      return isShowLogo && layout === "classic" || isShowLogo && layout === "transverse";
    });
    const isLayoutTransverse = vue.computed(() => {
      let { layout, isClassicSplitMenu } = themeConfig$1.value;
      return layout === "transverse" || isClassicSplitMenu && layout === "classic";
    });
    const setFilterRoutes = () => {
      let { layout, isClassicSplitMenu } = themeConfig$1.value;
      if (layout === "classic" && isClassicSplitMenu) {
        state.menuList = delClassicChildren(filterRoutesFun(routesList$1.value));
        const resData = setSendClassicChildren(route.path);
        mitt.default.emit("setSendClassicChildren", resData);
      } else {
        state.menuList = filterRoutesFun(routesList$1.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$1.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;
    };
    vue.onMounted(() => {
      setFilterRoutes();
      mitt.default.on("getBreadcrumbIndexSetFilterRoutes", () => {
        setFilterRoutes();
      });
    });
    vue.onUnmounted(() => {
      mitt.default.off("getBreadcrumbIndexSetFilterRoutes", () => {
      });
    });
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        setIsShowLogo.value ? (vue.openBlock(), vue.createBlock(vue.unref(Logo), { key: 0 })) : vue.createCommentVNode("v-if", true),
        vue.createVNode(vue.unref(Breadcrumb)),
        isLayoutTransverse.value ? (vue.openBlock(), vue.createBlock(vue.unref(Horizontal), {
          key: 1,
          menuList: state.menuList
        }, null, 8, ["menuList"])) : vue.createCommentVNode("v-if", true),
        !_ctx.$slots.user ? (vue.openBlock(), vue.createBlock(vue.unref(User), { key: 2 }, {
          default: vue.withCtx(() => [
            (vue.openBlock(true), vue.createElementBlock(
              vue.Fragment,
              null,
              vue.renderList(_ctx.$slots, (_, name) => {
                return vue.renderSlot(_ctx.$slots, name, vue.mergeProps({
                  key: name,
                  ref_for: true
                }, _ctx.$slots[name].props || {}));
              }),
              128
              /* KEYED_FRAGMENT */
            ))
          ]),
          _: 3
          /* FORWARDED */
        })) : vue.renderSlot(_ctx.$slots, "user", { key: 3 })
      ]);
    };
  }
});

exports.default = _sfc_main;
