"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../node_modules/element-plus/es/index.js");
;/* empty css                                                       */
;/* empty css                                                            */
const Vue = require("vue");
const index$1 = require("../../../node_modules/@element-plus/icons-vue/dist/index.js");
const useAdvancedFilterDialog = require("../packages/advancedFilter/useAdvancedFilterDialog.js");
;/* empty css                           */
const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../node_modules/element-plus/es/components/button/index.js");
const index$2 = require("../../../node_modules/element-plus/es/components/icon/index.js");
const _hoisted_1 = { class: "condition-config-wrapper" };
const _hoisted_2 = {
  key: 0,
  class: "condition-desc"
};
const _sfc_main = {
  __name: "ConditionConfigButton",
  props: {
    condition: {
      type: Object,
      default: null
    },
    title: {
      type: String,
      default: "条件配置"
    },
    description: {
      type: String,
      default: ""
    },
    width: {
      type: String,
      default: "100%"
    },
    onConfirm: Function
  },
  setup(__props) {
    const props = __props;
    const filterConfig = Vue.computed(() => {
      return props.condition;
    });
    const {
      advancedFilterDialogVisible,
      openAdvancedFilterDialog,
      AdvancedFilterDialog
    } = useAdvancedFilterDialog.useAdvancedFilterDialog();
    const isConfigured = Vue.computed(() => {
      var _a, _b;
      if (!props.condition) return false;
      const conditionsLength = ((_a = props.condition.conditions) == null ? void 0 : _a.length) || 0;
      const groupsLength = ((_b = props.condition.groups) == null ? void 0 : _b.length) || 0;
      return conditionsLength + groupsLength > 0;
    });
    const buttonText = Vue.computed(() => {
      var _a, _b;
      if (!props.condition) return "点击配置条件";
      const conditionsLength = ((_a = props.condition.conditions) == null ? void 0 : _a.length) || 0;
      const groupsLength = ((_b = props.condition.groups) == null ? void 0 : _b.length) || 0;
      const totalCount = conditionsLength + groupsLength;
      return totalCount > 0 ? `已设置(${totalCount})个条件` : "点击配置条件";
    });
    function advancedConfirm(data) {
      props.onConfirm && props.onConfirm(data);
    }
    return (_ctx, _cache) => {
      const _component_Edit = Vue.resolveComponent("Edit");
      const _component_el_icon = index$2.ElIcon;
      const _component_el_button = index.ElButton;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.createVNode(_component_el_button, {
            style: Vue.normalizeStyle({ width: __props.width }),
            icon: Vue.unref(index$1.Setting),
            class: Vue.normalizeClass(["setting-btn", { "is-configured": Vue.unref(isConfigured) }]),
            onClick: Vue.unref(openAdvancedFilterDialog)
          }, {
            default: Vue.withCtx(() => [
              Vue.createTextVNode(Vue.toDisplayString(Vue.unref(buttonText)) + " ", 1),
              Vue.createVNode(_component_el_icon, { class: "edit-btn" }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_Edit)
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["style", "icon", "class", "onClick"]),
          __props.description ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, Vue.toDisplayString(__props.description), 1)) : Vue.createCommentVNode("", true)
        ]),
        Vue.createVNode(Vue.unref(AdvancedFilterDialog), {
          modelValue: Vue.unref(advancedFilterDialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(advancedFilterDialogVisible) ? advancedFilterDialogVisible.value = $event : null),
          filterConfig: Vue.unref(filterConfig),
          onConfirm: advancedConfirm,
          title: __props.title
        }, null, 8, ["modelValue", "filterConfig", "title"])
      ], 64);
    };
  }
};
const ConditionConfigButton = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-24627e56"]]);
exports.default = ConditionConfigButton;
