import "../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                             */
/* empty css                                                                */
import { inject, ref, watchEffect, createElementBlock, openBlock, createVNode, mergeProps, withCtx, renderSlot, createTextVNode, toDisplayString, unref } from "vue";
import Node from "./Node.vue2.mjs";
/* empty css                   */
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElText } from "../../../../../node_modules/element-plus/es/components/text/index.mjs";
const _hoisted_1 = { class: "branch-node" };
const _sfc_main = {
  __name: "ConditionNode",
  props: {
    node: Object
  },
  setup(__props) {
    const { nodesError } = inject("flowDesign", { nodesError: ref({}) });
    const props = __props;
    const content = ref("");
    watchEffect(() => {
      var _a, _b;
      const errors = [];
      const { id, name, def, conditions, next } = props.node;
      if (def) {
        content.value = "不满足其他条件时执行";
      } else if (conditions.conditions.length > 0 || (((_a = conditions.groups) == null ? void 0 : _a.length) || 0) > 0) {
        const count = conditions.conditions.length + (((_b = conditions.groups) == null ? void 0 : _b.length) || 0);
        content.value = `已设置（${count}）个条件`;
        if (!next) {
          errors.push({ id, name, message: "分支下没有下一步动作" });
        }
      } else {
        errors.push({ id, name, message: "未设置条件" });
        content.value = "点击配置条件";
      }
      if (errors.length > 0) {
        nodesError.value[id] = errors;
      } else {
        delete nodesError.value[id];
      }
    });
    return (_ctx, _cache) => {
      const _component_el_text = ElText;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(Node, mergeProps(_ctx.$attrs, {
          icon: "el:Share",
          node: __props.node,
          readOnly: __props.node.def,
          color: "linear-gradient(89.96deg, #79db88 .05%, #4bb44b 79.83%)"
        }), {
          default: withCtx(() => [
            createVNode(_component_el_text, null, {
              default: withCtx(() => [
                createTextVNode(toDisplayString(unref(content)), 1)
              ]),
              _: 1
            }),
            renderSlot(_ctx.$slots, "append", {}, void 0, true)
          ]),
          _: 3
        }, 16, ["node", "readOnly"])
      ]);
    };
  }
};
const Condition = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6370e05c"]]);
export {
  Condition as default
};
