import "../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                             */
/* empty css                                                                   */
/* empty css                                                                  */
/* empty css                                                                  */
/* empty css                                                                */
/* empty css                                                                 */
import { mergeModels, useModel, ref, watch, createBlock, openBlock, withCtx, resolveDynamicComponent, unref, createElementVNode, createVNode, createTextVNode, withModifiers, withDirectives, vShow, toDisplayString } from "vue";
import Action from "./action/index.vue2.mjs";
import Execution from "./execution/index.vue2.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 { ElInput } from "../../../../../node_modules/element-plus/es/components/input/index.mjs";
import ClickOutside from "../../../../../node_modules/element-plus/es/directives/click-outside/index.mjs";
import { ElLink } from "../../../../../node_modules/element-plus/es/components/link/index.mjs";
const _hoisted_1 = { class: "dialog-footer" };
const _sfc_main = {
  __name: "index",
  props: /* @__PURE__ */ mergeModels({
    activeData: Object
  }, {
    "modelValue": { required: true },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const dialogVisible = useModel(__props, "modelValue");
    const props = __props;
    const dialog = {
      approval: Action,
      condition: Execution
    };
    const showInput = ref(false);
    const localData = ref({});
    watch(
      () => dialogVisible.value,
      (newVal) => {
        if (newVal && props.activeData) {
          localData.value = JSON.parse(JSON.stringify(props.activeData));
        }
      }
    );
    const onClickOutside = () => {
      if (showInput.value) {
        showInput.value = false;
      }
    };
    const onConfirm = () => {
      Object.assign(props.activeData, localData.value);
      dialogVisible.value = false;
    };
    const onCancel = () => {
      dialogVisible.value = false;
    };
    return (_ctx, _cache) => {
      const _component_el_input = ElInput;
      const _component_el_link = ElLink;
      const _component_el_button = ElButton;
      const _component_el_dialog = ElDialog;
      return openBlock(), createBlock(_component_el_dialog, {
        modelValue: dialogVisible.value,
        "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => dialogVisible.value = $event),
        width: "800",
        draggable: "",
        overflow: "",
        class: "fec-dev-designer-dialog"
      }, {
        header: withCtx(() => [
          createElementVNode("span", {
            class: "fec-edit-title",
            onMousedown: _cache[2] || (_cache[2] = withModifiers(() => {
            }, ["stop"]))
          }, [
            withDirectives(createVNode(_component_el_input, {
              onBlur: onClickOutside,
              maxlength: "30",
              modelValue: unref(localData).name,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(localData).name = $event)
            }, null, 8, ["modelValue"]), [
              [unref(ClickOutside), onClickOutside],
              [vShow, unref(showInput)]
            ]),
            withDirectives(createVNode(_component_el_link, {
              icon: "EditPen",
              onClick: _cache[1] || (_cache[1] = ($event) => showInput.value = true)
            }, {
              default: withCtx(() => {
                var _a;
                return [
                  createTextVNode(toDisplayString(((_a = unref(localData)) == null ? void 0 : _a.name) || "动作"), 1)
                ];
              }),
              _: 1
            }, 512), [
              [vShow, !unref(showInput)]
            ])
          ], 32)
        ]),
        footer: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createVNode(_component_el_button, { onClick: onCancel }, {
              default: withCtx(() => _cache[4] || (_cache[4] = [
                createTextVNode("取消")
              ])),
              _: 1
            }),
            createVNode(_component_el_button, {
              type: "primary",
              onClick: onConfirm
            }, {
              default: withCtx(() => _cache[5] || (_cache[5] = [
                createTextVNode(" 确定 ")
              ])),
              _: 1
            })
          ])
        ]),
        default: withCtx(() => [
          (openBlock(), createBlock(resolveDynamicComponent(dialog[unref(localData).type]), { activeData: unref(localData) }, null, 8, ["activeData"]))
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
export {
  _sfc_main as default
};
