import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                    */
/* empty css                                                                        */
/* empty css                                                                     */
/* empty css                                                                     */
/* empty css                                                                   */
/* empty css                                                                   */
/* empty css                                                                        */
/* empty css                                                                     */
import "../../../../../../node_modules/element-plus/theme-chalk/el-tooltip.css.mjs";
/* empty css                                                                   */
import "../../../../../../node_modules/element-plus/theme-chalk/el-sub-menu.css.mjs";
import "../../../../../../node_modules/element-plus/theme-chalk/el-menu-item.css.mjs";
import { ref, watch, resolveComponent, createBlock, openBlock, withCtx, createVNode, createElementVNode, unref, createElementBlock, Fragment, renderList, toDisplayString, createCommentVNode, resolveDynamicComponent } from "vue";
import menuData from "./config.mjs";
import _sfc_main$1 from "./Advanced.vue.mjs";
import { cloneDeep } from "../../../utils/common.mjs";
/* empty css           */
import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElContainer, ElAside, ElMain, ElHeader } from "../../../../../../node_modules/element-plus/es/components/container/index.mjs";
import { ElIcon } from "../../../../../../node_modules/element-plus/es/components/icon/index.mjs";
import { ElScrollbar } from "../../../../../../node_modules/element-plus/es/components/scrollbar/index.mjs";
import { ElMenu, ElSubMenu, ElMenuItem } from "../../../../../../node_modules/element-plus/es/components/menu/index.mjs";
import { ElForm } from "../../../../../../node_modules/element-plus/es/components/form/index.mjs";
const _hoisted_1 = { class: "menu-header" };
const _hoisted_2 = { class: "category-title" };
const _hoisted_3 = { class: "menu-item-text" };
const _hoisted_4 = { class: "action-desc" };
const _sfc_main = {
  __name: "index",
  props: {
    activeData: Object
  },
  setup(__props) {
    const props = __props;
    const selectedMenu = ref("");
    const selectedComponent = ref();
    const activeIndex = ref("");
    const handleMenuSelect = (index) => {
      activeIndex.value = index;
      props.activeData.actionType = index;
      const findItem = (index2) => {
        for (const category of menuData) {
          const item = category.items.find((i) => i.index === index2);
          if (item) return item;
        }
        return null;
      };
      const menuItem = findItem(index);
      selectedComponent.value = menuItem == null ? void 0 : menuItem.component;
      props.activeData.actionName = menuItem == null ? void 0 : menuItem.label;
      props.activeData.basic = {
        ...cloneDeep(menuItem.default),
        ...props.activeData.basic
      };
      selectedMenu.value = menuItem;
    };
    watch(
      () => props.activeData.actionType,
      (newActionType) => {
        if (newActionType) {
          handleMenuSelect(newActionType);
        } else if (menuData.length > 0 && menuData[0].items.length > 0) {
          const firstItem = menuData[0].items[0];
          activeIndex.value = firstItem.index;
          handleMenuSelect(firstItem.index);
        }
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      const _component_setting = resolveComponent("setting");
      const _component_el_icon = ElIcon;
      const _component_el_menu_item = ElMenuItem;
      const _component_el_sub_menu = ElSubMenu;
      const _component_el_menu = ElMenu;
      const _component_el_scrollbar = ElScrollbar;
      const _component_el_aside = ElAside;
      const _component_el_header = ElHeader;
      const _component_el_form = ElForm;
      const _component_el_main = ElMain;
      const _component_el_container = ElContainer;
      return openBlock(), createBlock(_component_el_container, {
        class: "action-dialog",
        style: { "height": "500px" }
      }, {
        default: withCtx(() => [
          createVNode(_component_el_aside, {
            width: "220px",
            style: { "border-right": "1px solid #ebeef5" }
          }, {
            default: withCtx(() => [
              createElementVNode("div", _hoisted_1, [
                createVNode(_component_el_icon, { class: "header-icon" }, {
                  default: withCtx(() => [
                    createVNode(_component_setting)
                  ]),
                  _: 1
                }),
                _cache[0] || (_cache[0] = createElementVNode("span", { class: "dev-header-title" }, "执行动作", -1))
              ]),
              createVNode(_component_el_scrollbar, { class: "menu-scrollbar" }, {
                default: withCtx(() => [
                  createVNode(_component_el_menu, {
                    "default-openeds": ["page"],
                    "default-active": unref(activeIndex),
                    onSelect: handleMenuSelect,
                    "background-color": "transparent",
                    "text-color": "#606266",
                    "active-text-color": "#409eff"
                  }, {
                    default: withCtx(() => [
                      (openBlock(true), createElementBlock(Fragment, null, renderList(unref(menuData), (category) => {
                        return openBlock(), createBlock(_component_el_sub_menu, {
                          key: category.index,
                          index: category.index,
                          class: "menu-category"
                        }, {
                          title: withCtx(() => [
                            createElementVNode("div", _hoisted_2, [
                              createVNode(_component_el_icon, { class: "category-icon" }, {
                                default: withCtx(() => [
                                  createVNode(_component_setting)
                                ]),
                                _: 1
                              }),
                              createElementVNode("span", null, toDisplayString(category.label), 1)
                            ])
                          ]),
                          default: withCtx(() => [
                            (openBlock(true), createElementBlock(Fragment, null, renderList(category.items, (item) => {
                              return openBlock(), createBlock(_component_el_menu_item, {
                                key: item.index,
                                index: item.index,
                                class: "menu-item"
                              }, {
                                default: withCtx(() => [
                                  createElementVNode("span", _hoisted_3, toDisplayString(item.label), 1)
                                ]),
                                _: 2
                              }, 1032, ["index"]);
                            }), 128))
                          ]),
                          _: 2
                        }, 1032, ["index"]);
                      }), 128))
                    ]),
                    _: 1
                  }, 8, ["default-active"])
                ]),
                _: 1
              })
            ]),
            _: 1
          }),
          createVNode(_component_el_main, { style: { "padding": "0" } }, {
            default: withCtx(() => [
              createVNode(_component_el_container, { style: { "height": "100%" } }, {
                default: withCtx(() => [
                  createVNode(_component_el_header, { height: "40px" }, {
                    default: withCtx(() => [
                      _cache[1] || (_cache[1] = createElementVNode("div", null, "动作说明", -1)),
                      createElementVNode("div", _hoisted_4, toDisplayString(unref(selectedMenu).desc), 1)
                    ]),
                    _: 1
                  }),
                  createVNode(_component_el_main, { style: { "padding": "12px 20px 0 20px" } }, {
                    default: withCtx(() => [
                      createVNode(_component_el_scrollbar, null, {
                        default: withCtx(() => [
                          unref(selectedComponent) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                            _cache[2] || (_cache[2] = createElementVNode("div", { class: "event-behavior-title" }, "基础配置", -1)),
                            createVNode(_component_el_form, {
                              model: __props.activeData.basic,
                              "label-width": "100px",
                              size: "small",
                              style: { "padding-right": "20px" }
                            }, {
                              default: withCtx(() => [
                                (openBlock(), createBlock(resolveDynamicComponent(unref(selectedComponent)), {
                                  formData: __props.activeData.basic,
                                  type: unref(selectedMenu).index
                                }, null, 8, ["formData", "type"]))
                              ]),
                              _: 1
                            }, 8, ["model"])
                          ], 64)) : createCommentVNode("", true),
                          _cache[3] || (_cache[3] = createElementVNode("div", { class: "event-behavior-title" }, "高级配置", -1)),
                          createVNode(_component_el_form, {
                            model: __props.activeData.advanced,
                            "label-width": "100px",
                            size: "small"
                          }, {
                            default: withCtx(() => [
                              createVNode(_sfc_main$1, {
                                formData: __props.activeData.advanced
                              }, null, 8, ["formData"])
                            ]),
                            _: 1
                          }, 8, ["model"])
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      });
    };
  }
};
const Action = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d155ddb6"]]);
export {
  Action as default
};
