import "../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                          */
/* empty css                                                                */
/* empty css                                                               */
/* empty css                                                               */
import { mergeModels, useModel, ref, createBlock, openBlock, withCtx, createElementVNode, createVNode, createTextVNode } from "vue";
import _sfc_main$1 from "../eventFlow/index.vue.mjs";
import defaultProcessData from "../eventFlow/defaultProcessData.mjs";
import { cloneDeep } from "../utils/common.mjs";
/* empty css                                                              */
/* empty css                                                                */
/* empty css              */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElDialog } from "../../../../node_modules/element-plus/es/components/dialog/index.mjs";
import { ElButton } from "../../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElMessage } from "../../../../node_modules/element-plus/es/components/message/index.mjs";
const _hoisted_1 = { style: { "border": "1px solid #ebeef5", "border-radius": "4px", "height": "600px", "overflow": "auto", "background-color": "#f2f3f5" } };
const _hoisted_2 = { class: "dialog-footer" };
const _sfc_main = {
  __name: "onlyFlow",
  props: /* @__PURE__ */ mergeModels({
    eventConfig: {
      type: Object,
      default: {}
    },
    title: {
      type: String,
      default: "事件配置"
    },
    onConfirm: Function
  }, {
    "modelValue": { required: true },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const dialogVisible = useModel(__props, "modelValue");
    const props = __props;
    const createEventFlow = () => JSON.parse(JSON.stringify(defaultProcessData));
    const eventConfigData = ref(props.eventConfig || createEventFlow());
    const eventFlowRef = ref(null);
    const onConfirm = async () => {
      var _a;
      try {
        if ((_a = eventFlowRef.value) == null ? void 0 : _a.validate) {
          await eventFlowRef.value.validate();
        }
        props.onConfirm && props.onConfirm(cloneDeep(eventConfigData.value));
        dialogVisible.value = false;
      } catch (error) {
        console.error("事件流校验失败:", error);
        ElMessage.error("请完善事件配置");
      }
    };
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_dialog = ElDialog;
      return openBlock(), createBlock(_component_el_dialog, {
        modelValue: dialogVisible.value,
        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dialogVisible.value = $event),
        width: "50%",
        title: __props.title,
        draggable: "",
        overflow: "",
        "append-to-body": "",
        class: "fec-dev-designer-dialog"
      }, {
        footer: withCtx(() => [
          createElementVNode("div", _hoisted_2, [
            createVNode(_component_el_button, {
              onClick: _cache[0] || (_cache[0] = ($event) => dialogVisible.value = false)
            }, {
              default: withCtx(() => _cache[2] || (_cache[2] = [
                createTextVNode("取消")
              ])),
              _: 1
            }),
            createVNode(_component_el_button, {
              type: "primary",
              onClick: onConfirm
            }, {
              default: withCtx(() => _cache[3] || (_cache[3] = [
                createTextVNode(" 确定 ")
              ])),
              _: 1
            })
          ])
        ]),
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createVNode(_sfc_main$1, {
              ref_key: "eventFlowRef",
              ref: eventFlowRef,
              process: eventConfigData.value
            }, null, 8, ["process"])
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "title"]);
    };
  }
};
const OnlyFlowDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-497a8403"]]);
export {
  OnlyFlowDialog as default
};
