import { defineComponent, getCurrentInstance, ref, resolveComponent, openBlock, createElementBlock, Fragment, createCommentVNode, createElementVNode, createBlock, unref, toDisplayString, createVNode, Transition, withCtx, withDirectives, renderList, vShow } from 'vue';
import { ElSubMenu, ElMenuItem } from 'element-plus';
import { MeDot } from '../../dot/index.mjs';
import { MeSvgIcon } from '../../svg-icon/index.mjs';
import './components/badge.vue.mjs';
import script$1 from './components/badge.vue2.mjs';

"use strict";
const _hoisted_1 = {
  key: 0,
  class: "group"
};
const _hoisted_2 = { key: 0 };
const _hoisted_3 = { class: "menuIcon" };
const _hoisted_4 = { class: "menuTitle" };
const _hoisted_5 = {
  key: 0,
  class: "menuDot"
};
const _hoisted_6 = { key: 1 };
const _hoisted_7 = { class: "menuIcon" };
const _hoisted_8 = { class: "menuTitle" };
const _hoisted_9 = {
  key: 0,
  class: "menuDot"
};
const _hoisted_10 = { class: "menuIcon" };
const _hoisted_11 = { class: "menuTitle" };
const _hoisted_12 = {
  key: 0,
  class: "menuDot"
};
var script = /* @__PURE__ */ defineComponent({
  __name: "column-menu-tree",
  props: {
    showGroup: { type: Boolean, required: false },
    item: { type: Object, required: true },
    show: { type: [Boolean, Function], required: false },
    router: { type: Boolean, required: false, default: false }
  },
  emits: ["menuItemClick"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const instance = getCurrentInstance();
    const router = instance.appContext.config.globalProperties.$router;
    const showGroupContent = ref(props.showGroup);
    const groupContentRef = ref();
    let showLogic = (item) => {
      if (typeof props.show == "function") {
        return props.show(item);
      } else {
        return props.show;
      }
    };
    const handleGroupClick = () => {
      showGroupContent.value = !showGroupContent.value;
    };
    const menuClickHandler = (item) => {
      if (props.router && router) {
        if (item.meta.linkURL) {
          window.open(item.meta.linkURL);
          return;
        }
        if (item.meta.activeMenu != "") {
          item = item.children?.find((child) => child.id == item.meta.activeMenu) || item;
        }
        router.push(item.meta.path);
      }
      emits("menuItemClick", item);
    };
    const onEnter = (el, done) => {
      el.style.height = "0";
      el.offsetHeight;
      const contentHeight = groupContentRef.value.scrollHeight + "px";
      el.style.height = contentHeight;
    };
    const onAfterEnter = (el) => {
      el.style.height = "auto";
    };
    const onLeave = (el, done) => {
      const contentHeight = groupContentRef.value.scrollHeight + "px";
      el.style.height = contentHeight;
      el.offsetHeight;
      el.style.height = "0";
    };
    const onAfterLeave = (el) => {
      el.style.height = "";
    };
    return (_ctx, _cache) => {
      const _component_column_menu_tree = resolveComponent("column-menu-tree", true);
      return openBlock(), createElementBlock(
        Fragment,
        null,
        [
          createCommentVNode(" \u5206\u7EC4\u83DC\u5355\u9879 "),
          __props.item.meta?.type === "group" && !__props.item.hideFlag ? (openBlock(), createElementBlock("div", _hoisted_1, [
            createElementVNode("div", {
              class: "title",
              onClick: handleGroupClick
            }, [
              !showGroupContent.value ? (openBlock(), createBlock(unref(MeSvgIcon), {
                key: 0,
                name: __props.item.icon || "ri-arrow-right-s-fill"
              }, null, 8, ["name"])) : (openBlock(), createBlock(unref(MeSvgIcon), {
                key: 1,
                name: "ri-arrow-down-s-fill"
              })),
              createElementVNode(
                "span",
                null,
                toDisplayString(__props.item.title),
                1
                /* TEXT */
              )
            ]),
            createVNode(Transition, {
              css: false,
              onEnter,
              onAfterEnter,
              onLeave,
              onAfterLeave
            }, {
              default: withCtx(() => [
                __props.item.children?.length ? withDirectives((openBlock(), createElementBlock(
                  "div",
                  {
                    key: 0,
                    ref_key: "groupContentRef",
                    ref: groupContentRef,
                    class: "group-content"
                  },
                  [
                    (openBlock(true), createElementBlock(
                      Fragment,
                      null,
                      renderList(__props.item.children, (children) => {
                        return openBlock(), createBlock(_component_column_menu_tree, {
                          onMenuItemClick: menuClickHandler,
                          show: unref(showLogic)(__props.item),
                          key: __props.item.id,
                          item: children
                        }, null, 8, ["show", "item"]);
                      }),
                      128
                      /* KEYED_FRAGMENT */
                    ))
                  ],
                  512
                  /* NEED_PATCH */
                )), [
                  [vShow, showGroupContent.value]
                ]) : createCommentVNode("v-if", true)
              ]),
              _: 1
              /* STABLE */
            })
          ])) : !__props.item.hideFlag && unref(showLogic)(__props.item) ? (openBlock(), createElementBlock(
            Fragment,
            { key: 1 },
            [
              createCommentVNode(" \u5E38\u89C4\u83DC\u5355\u9879  "),
              createCommentVNode(" \u591A\u83DC\u5355-\u6709\u5B50\u680F\u76EE "),
              __props.item.children?.length && __props.item.hideFlag == false && !__props.item.meta.hideChildrenMenu ? (openBlock(), createElementBlock("div", _hoisted_2, [
                (openBlock(), createBlock(unref(ElSubMenu), {
                  style: { "padding-top": "6px" },
                  index: __props.item.id,
                  key: __props.item.id
                }, {
                  title: withCtx(() => [
                    createCommentVNode(" Icon "),
                    createElementVNode("span", _hoisted_3, [
                      createVNode(unref(MeSvgIcon), {
                        name: __props.item.icon
                      }, null, 8, ["name"])
                    ]),
                    createCommentVNode(" Title "),
                    createElementVNode(
                      "span",
                      _hoisted_4,
                      toDisplayString(__props.item.title),
                      1
                      /* TEXT */
                    ),
                    createCommentVNode("\u5FBD\u7AE0 "),
                    createVNode(script$1, {
                      meta: __props.item.meta,
                      type: __props.item.meta.badgeType,
                      color: __props.item.meta.badgeColor,
                      text: __props.item.meta.badge
                    }, null, 8, ["meta", "type", "color", "text"]),
                    createCommentVNode("\u5706\u70B9\u53D1\u5149 "),
                    __props.item.meta.dot ? (openBlock(), createElementBlock("span", _hoisted_5, [
                      createVNode(unref(MeDot))
                    ])) : createCommentVNode("v-if", true)
                  ]),
                  default: withCtx(() => [
                    (openBlock(true), createElementBlock(
                      Fragment,
                      null,
                      renderList(__props.item.children, (children) => {
                        return openBlock(), createBlock(_component_column_menu_tree, {
                          onMenuItemClick: menuClickHandler,
                          show: unref(showLogic)(__props.item),
                          key: __props.item.id,
                          item: children
                        }, null, 8, ["show", "item"]);
                      }),
                      128
                      /* KEYED_FRAGMENT */
                    ))
                  ]),
                  _: 1
                  /* STABLE */
                }, 8, ["index"]))
              ])) : createCommentVNode("v-if", true),
              createCommentVNode(" \u591A\u83DC\u5355-\u8BBE\u7F6E\u4E86\u9690\u85CF\u5B50\u83DC\u5355 "),
              __props.item.children?.length && __props.item.hideFlag == false && __props.item.meta.hideChildrenMenu ? (openBlock(), createElementBlock("div", _hoisted_6, [
                (openBlock(), createBlock(unref(ElMenuItem), {
                  index: `${__props.item.id}`,
                  key: __props.item.id,
                  onClick: _cache[0] || (_cache[0] = ($event) => menuClickHandler(__props.item))
                }, {
                  default: withCtx(() => [
                    createCommentVNode(" Icon "),
                    createElementVNode("span", _hoisted_7, [
                      createVNode(unref(MeSvgIcon), {
                        name: __props.item.icon
                      }, null, 8, ["name"])
                    ]),
                    createCommentVNode(" Title "),
                    createElementVNode(
                      "span",
                      _hoisted_8,
                      toDisplayString(__props.item.title),
                      1
                      /* TEXT */
                    ),
                    createCommentVNode("\u5FBD\u7AE0 "),
                    createVNode(script$1, {
                      meta: __props.item.meta,
                      type: __props.item.meta.badgeType,
                      color: __props.item.meta.badgeColor,
                      text: __props.item.meta.badge
                    }, null, 8, ["meta", "type", "color", "text"]),
                    createCommentVNode("\u5706\u70B9\u53D1\u5149 "),
                    __props.item.meta.dot ? (openBlock(), createElementBlock("span", _hoisted_9, [
                      createVNode(unref(MeDot))
                    ])) : createCommentVNode("v-if", true)
                  ]),
                  _: 1
                  /* STABLE */
                }, 8, ["index"]))
              ])) : createCommentVNode("v-if", true),
              createCommentVNode(" \u5355\u83DC\u5355 "),
              !__props.item.children?.length && __props.item.hideFlag == false ? (openBlock(), createElementBlock("div", {
                key: __props.item.id
              }, [
                (openBlock(), createBlock(unref(ElMenuItem), {
                  index: `${__props.item.id}`,
                  key: __props.item.id,
                  onClick: _cache[1] || (_cache[1] = ($event) => menuClickHandler(__props.item))
                }, {
                  default: withCtx(() => [
                    createCommentVNode(" Icon "),
                    createElementVNode("span", _hoisted_10, [
                      createVNode(unref(MeSvgIcon), {
                        name: __props.item.icon
                      }, null, 8, ["name"])
                    ]),
                    createCommentVNode(" Title "),
                    createElementVNode(
                      "span",
                      _hoisted_11,
                      toDisplayString(__props.item.title),
                      1
                      /* TEXT */
                    ),
                    createCommentVNode("\u5FBD\u7AE0 "),
                    createVNode(script$1, {
                      meta: __props.item.meta,
                      type: __props.item.meta.badgeType,
                      text: __props.item.meta.badge,
                      color: __props.item.meta.badgeColor
                    }, null, 8, ["meta", "type", "text", "color"]),
                    createCommentVNode("\u5706\u70B9\u53D1\u5149 "),
                    __props.item.meta.dot ? (openBlock(), createElementBlock("span", _hoisted_12, [
                      createVNode(unref(MeDot))
                    ])) : createCommentVNode("v-if", true)
                  ]),
                  _: 1
                  /* STABLE */
                }, 8, ["index"]))
              ])) : createCommentVNode("v-if", true)
            ],
            64
            /* STABLE_FRAGMENT */
          )) : createCommentVNode("v-if", true)
        ],
        2112
        /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
      );
    };
  }
});

export { script as default };
//# sourceMappingURL=column-menu-tree.vue2.mjs.map
