import { defineComponent, resolveComponent, createElementBlock, openBlock, Fragment, renderList, createCommentVNode, createBlock, createVNode, mergeProps, createSlots, withCtx, createElementVNode, normalizeStyle, toDisplayString } from 'vue';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "RecursiveMenu" },
  __name: "recursive-menu",
  props: {
    items: {
      type: Array,
      default: () => []
    }
  },
  emits: {
    claimSelected: (item) => !!item
  },
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const getMenuItemProps = (item) => {
      const { label, subMenu, type, icon, color, ...rest } = item;
      return rest;
    };
    const getSubMenuProps = (item) => {
      const { label, subMenu, icon, color, ...rest } = item;
      return rest;
    };
    const handleClick = (item) => {
      emit("claimSelected", item);
    };
    return (_ctx, _cache) => {
      const _component_a_menu_divider = resolveComponent("a-menu-divider");
      const _component_ll_icon = resolveComponent("ll-icon");
      const _component_a_menu_item = resolveComponent("a-menu-item");
      const _component_RecursiveMenu = resolveComponent("RecursiveMenu", true);
      const _component_a_sub_menu = resolveComponent("a-sub-menu");
      return openBlock(true), createElementBlock(
        Fragment,
        null,
        renderList(props.items, (item, index) => {
          return openBlock(), createElementBlock(
            Fragment,
            {
              key: item?.key ?? index
            },
            [
              createCommentVNode(" \u5206\u9694\u7EBF "),
              item.type === "divider" ? (openBlock(), createBlock(_component_a_menu_divider, { key: 0 })) : !item.subMenu || item.subMenu.length === 0 ? (openBlock(), createElementBlock(
                Fragment,
                { key: 1 },
                [
                  createCommentVNode(" \u666E\u901A\u83DC\u5355\u9879 "),
                  createVNode(_component_a_menu_item, mergeProps({ ref_for: true }, getMenuItemProps(item), {
                    onClick: ($event) => handleClick(item)
                  }), createSlots({
                    default: withCtx(() => [
                      createElementVNode(
                        "span",
                        {
                          style: normalizeStyle({ color: item.disabled ? "" : item.color })
                        },
                        toDisplayString(item.label),
                        5
                        /* TEXT, STYLE */
                      )
                    ]),
                    _: 2
                    /* DYNAMIC */
                  }, [
                    item.icon ? {
                      name: "icon",
                      fn: withCtx(() => [
                        createVNode(_component_ll_icon, {
                          "icon-name": item.icon,
                          color: item.disabled ? "" : item.color
                        }, null, 8, ["icon-name", "color"])
                      ]),
                      key: "0"
                    } : void 0
                  ]), 1040, ["onClick"])
                ],
                2112
                /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
              )) : (openBlock(), createElementBlock(
                Fragment,
                { key: 2 },
                [
                  createCommentVNode(" \u5B50\u83DC\u5355 "),
                  createVNode(
                    _component_a_sub_menu,
                    mergeProps({ ref_for: true }, getSubMenuProps(item)),
                    createSlots({
                      title: withCtx(() => [
                        createElementVNode(
                          "span",
                          {
                            style: normalizeStyle({ color: item.disabled ? "" : item.color })
                          },
                          toDisplayString(item.label),
                          5
                          /* TEXT, STYLE */
                        )
                      ]),
                      default: withCtx(() => [
                        createVNode(_component_RecursiveMenu, {
                          items: item.subMenu,
                          onClaimSelected: handleClick
                        }, null, 8, ["items"])
                      ]),
                      _: 2
                      /* DYNAMIC */
                    }, [
                      item.icon ? {
                        name: "icon",
                        fn: withCtx(() => [
                          createVNode(_component_ll_icon, {
                            "icon-name": item.icon,
                            color: item.disabled ? "" : item.color
                          }, null, 8, ["icon-name", "color"])
                        ]),
                        key: "0"
                      } : void 0
                    ]),
                    1040
                    /* FULL_PROPS, DYNAMIC_SLOTS */
                  )
                ],
                2112
                /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
              ))
            ],
            64
            /* STABLE_FRAGMENT */
          );
        }),
        128
        /* KEYED_FRAGMENT */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=recursive-menu.vue2.mjs.map
