"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                          */
;/* empty css                                                              */
;/* empty css                                                              */
;/* empty css                                                                 */
;/* empty css                                                                      */
const Vue = require("vue");
const eventBus = require("../../packages/utils/eventBus.js");
const vueDraggablePlus = require("../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.js");
const index$7 = require("../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const common = require("../../packages/utils/common.js");
const index$2 = require("../../packages/table/aside/index.js");
const index$1 = require("../../packages/form/aside/index.js");
const fieldRecycleBin = require("./fieldRecycleBin.vue.js");
const HiddenFieldDialog = require("./HiddenFieldDialog.vue.js");
const index$5 = require("../../../../node_modules/@vexip-ui/utils/dist/index.js");
const index = require("../../store/index.js");
;/* empty css            */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index$3 = require("../../../../node_modules/element-plus/es/components/container/index.js");
const index$4 = require("../../../../node_modules/element-plus/es/components/collapse/index.js");
const index$6 = require("../../../../node_modules/element-plus/es/components/icon/index.js");
const index$8 = require("../../../../node_modules/element-plus/es/components/badge/index.js");
const _hoisted_1 = { class: "dev-designer-aside" };
const _hoisted_2 = { class: "menu-components-item" };
const _hoisted_3 = { class: "components-item-label" };
const _hoisted_4 = {
  key: 0,
  class: "table-item"
};
const _hoisted_5 = { class: "widgets" };
const _hoisted_6 = { class: "field-label" };
const _hoisted_7 = { class: "aside-footer" };
const _sfc_main = {
  __name: "index",
  emits: ["onFormDragMove"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const editingAside = Vue.computed(() => {
      switch (index.default.getters.editingType) {
        case "table":
          return index$2.default;
        case "form":
          return index$1.default;
      }
      return null;
    });
    const editingType = Vue.computed(() => {
      return index.default.getters.editingType;
    });
    const activeNames = Vue.ref(["basic", "advanced"]);
    const recycleBinVisible = Vue.ref(false);
    const hiddenFieldDialogVisible = Vue.ref(false);
    const recycleBinCount = Vue.computed(() => {
      var _a;
      const editConfigData = common.getEditConfigData();
      return ((_a = editConfigData == null ? void 0 : editConfigData.deletedFields) == null ? void 0 : _a.length) || 0;
    });
    const hiddenFieldCount = Vue.computed(() => {
      var _a;
      const editConfigData = common.getEditConfigData();
      return ((_a = editConfigData == null ? void 0 : editConfigData.hiddenFields) == null ? void 0 : _a.length) || 0;
    });
    function clone(element) {
      return {
        ...common.cloneDeep(element),
        id: Date.now(),
        type: "widgets"
      };
    }
    function onDragEnd(event) {
      common.setSelectedItem(event.clonedData);
      if (index.default.getters.editingType == "form") {
        eventBus.default.emit("onFormDragEnd", event);
      }
    }
    const onMove = index$5.throttle((event) => {
      if (index.default.getters.editingType == "form") {
        emit("onFormDragMove", event);
        return true;
      }
      return true;
    }, 50);
    function onStart(event) {
      if (index.default.getters.editingType == "form") {
        eventBus.default.emit("onFormDragStart", event);
      }
    }
    function openRecycleBin() {
      recycleBinVisible.value = true;
    }
    function openHiddenFieldDialog() {
      hiddenFieldDialogVisible.value = true;
    }
    return (_ctx, _cache) => {
      const _component_el_icon = index$6.ElIcon;
      const _component_el_collapse_item = index$4.ElCollapseItem;
      const _component_el_collapse = index$4.ElCollapse;
      const _component_el_badge = index$8.ElBadge;
      const _component_el_aside = index$3.ElAside;
      return Vue.openBlock(), Vue.createBlock(_component_el_aside, { class: "root-aside" }, {
        default: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_1, [
            Vue.createVNode(_component_el_collapse, {
              modelValue: activeNames.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeNames.value = $event)
            }, {
              default: Vue.withCtx(() => [
                (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(editingAside.value, (item) => {
                  return Vue.openBlock(), Vue.createBlock(_component_el_collapse_item, {
                    key: item.name,
                    title: item.title,
                    name: item.name
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
                        modelValue: item.children,
                        "onUpdate:modelValue": ($event) => item.children = $event,
                        animation: 150,
                        ghostClass: "ghost",
                        group: { name: "dev", pull: "clone", put: false },
                        clone,
                        onEnd: onDragEnd,
                        onMove: Vue.unref(onMove),
                        onStart,
                        sort: false,
                        class: "components-list"
                      }, {
                        default: Vue.withCtx(() => [
                          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(item.children, (comp) => {
                            return Vue.openBlock(), Vue.createElementBlock("div", {
                              key: comp.fieldType,
                              class: "components-item"
                            }, [
                              Vue.createElementVNode("div", _hoisted_2, [
                                Vue.createVNode(_component_el_icon, { class: "components-item-icon" }, {
                                  default: Vue.withCtx(() => [
                                    Vue.createVNode(Vue.unref(index$7.Calendar))
                                  ]),
                                  _: 1
                                }),
                                Vue.createElementVNode("span", _hoisted_3, Vue.toDisplayString(comp.label), 1)
                              ]),
                              editingType.value == "table" ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_4, [
                                Vue.createElementVNode("div", _hoisted_5, Vue.toDisplayString(comp.label), 1),
                                Vue.createElementVNode("div", _hoisted_6, Vue.toDisplayString(comp.fieldName), 1)
                              ])) : Vue.createCommentVNode("", true)
                            ]);
                          }), 128))
                        ]),
                        _: 2
                      }, 1032, ["modelValue", "onUpdate:modelValue", "onMove"])
                    ]),
                    _: 2
                  }, 1032, ["title", "name"]);
                }), 128))
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          Vue.createElementVNode("div", _hoisted_7, [
            Vue.createElementVNode("div", {
              class: "footer-btn recycle-btn",
              onClick: openRecycleBin
            }, [
              Vue.createVNode(_component_el_icon, { class: "btn-icon" }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(Vue.unref(index$7.DeleteFilled))
                ]),
                _: 1
              }),
              _cache[3] || (_cache[3] = Vue.createElementVNode("span", { class: "btn-text" }, "字段回收站", -1)),
              recycleBinCount.value > 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_badge, {
                key: 0,
                value: recycleBinCount.value,
                max: 99,
                class: "btn-badge"
              }, null, 8, ["value"])) : Vue.createCommentVNode("", true)
            ]),
            _cache[5] || (_cache[5] = Vue.createElementVNode("div", { class: "footer-divider" }, null, -1)),
            Vue.createElementVNode("div", {
              class: "footer-btn hidden-field-btn",
              onClick: openHiddenFieldDialog
            }, [
              Vue.createVNode(_component_el_icon, { class: "btn-icon" }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(Vue.unref(index$7.Hide))
                ]),
                _: 1
              }),
              _cache[4] || (_cache[4] = Vue.createElementVNode("span", { class: "btn-text" }, "隐藏域", -1)),
              hiddenFieldCount.value > 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_badge, {
                key: 0,
                value: hiddenFieldCount.value,
                max: 99,
                class: "btn-badge"
              }, null, 8, ["value"])) : Vue.createCommentVNode("", true)
            ])
          ]),
          Vue.createVNode(fieldRecycleBin.default, {
            modelValue: recycleBinVisible.value,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => recycleBinVisible.value = $event)
          }, null, 8, ["modelValue"]),
          Vue.createVNode(HiddenFieldDialog.default, {
            modelValue: hiddenFieldDialogVisible.value,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => hiddenFieldDialogVisible.value = $event)
          }, null, 8, ["modelValue"])
        ]),
        _: 1
      });
    };
  }
};
const LayoutAside = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-b7e9472b"]]);
exports.default = LayoutAside;
