"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                                                               */
const Vue = require("vue");
const _default = require("./default.js");
const vueDraggablePlus = require("../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.js");
const index$2 = require("../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const common = require("../utils/common.js");
;/* empty css               */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/element-plus/es/components/icon/index.js");
const index$1 = require("../../../../node_modules/element-plus/es/components/button/index.js");
const index$3 = require("../../../../node_modules/element-plus/es/components/link/index.js");
const _hoisted_1 = { class: "table-work-btns" };
const _hoisted_2 = { class: "left" };
const _hoisted_3 = {
  key: 0,
  class: "back-icon"
};
const _hoisted_4 = {
  key: 1,
  class: "template-name"
};
const _hoisted_5 = ["onMouseenter", "onClick"];
const _hoisted_6 = { class: "right" };
const _hoisted_7 = ["onMouseenter", "onClick"];
const _sfc_main = {
  __name: "tableBtn",
  setup(__props) {
    const editConfigData = Vue.computed(() => {
      return common.getEditConfigData();
    });
    const btnTypeConfig = {
      custom: { type: "primary" },
      refresh: { icon: index$2.Refresh },
      export: { icon: index$2.Download },
      personalize: { icon: index$2.Setting }
    };
    function getBtnProps(item) {
      const data = btnTypeConfig[item.btnType] || {};
      if (!item.label) {
        data.class = "system";
      } else {
        data.class = "";
      }
      return data;
    }
    function addOptBtns(state) {
      const newBtn = {
        id: Date.now(),
        ..._default.defaultCustomBtn
      };
      if (state === "right") {
        editConfigData.value.customBtns[state].unshift(newBtn);
      } else {
        editConfigData.value.customBtns[state].push(newBtn);
      }
    }
    function removeOptBtns(state, item) {
      const index2 = editConfigData.value.customBtns[state].findIndex(
        (i) => i.id === item.id
      );
      if (index2 !== -1) {
        editConfigData.value.customBtns[state].splice(index2, 1);
      }
    }
    return (_ctx, _cache) => {
      const _component_ArrowLeftBold = Vue.resolveComponent("ArrowLeftBold");
      const _component_el_icon = index.ElIcon;
      const _component_el_button = index$1.ElButton;
      const _component_el_link = index$3.ElLink;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        Vue.createElementVNode("div", _hoisted_2, [
          editConfigData.value.showReturn ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_3, [
            Vue.createVNode(_component_el_icon, null, {
              default: Vue.withCtx(() => [
                Vue.createVNode(_component_ArrowLeftBold)
              ]),
              _: 1
            })
          ])) : Vue.createCommentVNode("", true),
          editConfigData.value.showTitle ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_4, Vue.toDisplayString(editConfigData.value.templateName), 1)) : Vue.createCommentVNode("", true),
          Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
            modelValue: editConfigData.value.customBtns.left,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => editConfigData.value.customBtns.left = $event),
            animation: 150,
            group: { name: "tableBtn" },
            ghostClass: "ghost",
            class: "optBtnDraggable"
          }, {
            default: Vue.withCtx(() => [
              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(editConfigData.value.customBtns.left, (item) => {
                return Vue.openBlock(), Vue.createElementBlock("div", {
                  class: Vue.normalizeClass(["optBtn", Vue.unref(common.getCurrentClass)(item)]),
                  onMouseenter: ($event) => Vue.unref(common.setHoverItem)(item),
                  onMouseleave: _cache[0] || (_cache[0] = ($event) => Vue.unref(common.setHoverItem)()),
                  onClick: Vue.withModifiers(($event) => Vue.unref(common.setSelectedItem)(item), ["stop"])
                }, [
                  Vue.createVNode(_component_el_button, Vue.mergeProps({
                    class: "elBtn",
                    ref_for: true
                  }, getBtnProps(item)), {
                    default: Vue.withCtx(() => [
                      Vue.createTextVNode(Vue.toDisplayString(item.label), 1)
                    ]),
                    _: 2
                  }, 1040),
                  Vue.createVNode(_component_el_icon, {
                    class: "delete-icon",
                    onClick: Vue.withModifiers(($event) => removeOptBtns("left", item), ["stop"])
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(index$2.Close))
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ], 42, _hoisted_5);
              }), 256))
            ]),
            _: 1
          }, 8, ["modelValue"]),
          Vue.createVNode(_component_el_link, {
            class: "optBtn addLink",
            underline: "never",
            type: "primary",
            icon: Vue.unref(index$2.Plus),
            onClick: _cache[2] || (_cache[2] = Vue.withModifiers(($event) => addOptBtns("left"), ["stop"]))
          }, {
            default: Vue.withCtx(() => _cache[6] || (_cache[6] = [
              Vue.createTextVNode("按钮")
            ])),
            _: 1
          }, 8, ["icon"])
        ]),
        Vue.createElementVNode("div", _hoisted_6, [
          Vue.createVNode(_component_el_link, {
            class: "optBtn addLink",
            underline: "never",
            type: "primary",
            icon: Vue.unref(index$2.Plus),
            onClick: _cache[3] || (_cache[3] = Vue.withModifiers(($event) => addOptBtns("right"), ["stop"]))
          }, {
            default: Vue.withCtx(() => _cache[7] || (_cache[7] = [
              Vue.createTextVNode("按钮")
            ])),
            _: 1
          }, 8, ["icon"]),
          Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
            modelValue: editConfigData.value.customBtns.right,
            "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => editConfigData.value.customBtns.right = $event),
            animation: 150,
            group: { name: "tableBtn" },
            ghostClass: "ghost",
            class: "optBtnDraggable"
          }, {
            default: Vue.withCtx(() => [
              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(editConfigData.value.customBtns.right, (item) => {
                return Vue.openBlock(), Vue.createElementBlock("div", {
                  class: Vue.normalizeClass(["optBtn", Vue.unref(common.getCurrentClass)(item)]),
                  onMouseenter: ($event) => Vue.unref(common.setHoverItem)(item),
                  onMouseleave: _cache[4] || (_cache[4] = ($event) => Vue.unref(common.setHoverItem)()),
                  onClick: Vue.withModifiers(($event) => Vue.unref(common.setSelectedItem)(item), ["stop"])
                }, [
                  Vue.createVNode(_component_el_button, Vue.mergeProps({
                    class: "elBtn",
                    ref_for: true
                  }, getBtnProps(item)), {
                    default: Vue.withCtx(() => [
                      Vue.createTextVNode(Vue.toDisplayString(item.label), 1)
                    ]),
                    _: 2
                  }, 1040),
                  Vue.createVNode(_component_el_icon, {
                    class: "delete-icon",
                    onClick: Vue.withModifiers(($event) => removeOptBtns("right", item), ["stop"])
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(index$2.Close))
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ], 42, _hoisted_7);
              }), 256))
            ]),
            _: 1
          }, 8, ["modelValue"])
        ])
      ]);
    };
  }
};
const TableBtn = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-c16f2646"]]);
exports.default = TableBtn;
