import { inject, ref, resolveComponent, createElementBlock, openBlock, Fragment, createElementVNode, createVNode, renderSlot, unref, renderList, createCommentVNode, mergeProps, withCtx, withDirectives, withModifiers, vShow } from "vue";
import _sfc_main$1 from "./TreeNode.vue.mjs";
import Add from "./Add.vue2.mjs";
/* empty css                 */
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
const _hoisted_1 = { class: "gateway-node" };
const _hoisted_2 = { class: "add-branch" };
const _hoisted_3 = ["onClick"];
const _hoisted_4 = ["onClick"];
const _sfc_main = {
  __name: "GatewayNode",
  props: {
    node: Object
  },
  emits: ["addNode"],
  setup(__props, { emit: __emit }) {
    const $emits = __emit;
    const props = __props;
    const { readOnly } = inject("flowDesign", { readOnly: ref(false) });
    const addNode = (type, node) => {
      $emits("addNode", type, node || props.node);
    };
    const moveRight = (index) => {
      const node = props.node.branches[index];
      props.node.branches.splice(index, 1);
      props.node.branches.splice(index + 1, 0, node);
    };
    const moveLeft = (index) => {
      const node = props.node.branches[index];
      props.node.branches.splice(index, 1);
      props.node.branches.splice(index - 1, 0, node);
    };
    return (_ctx, _cache) => {
      const _component_svg_icon = resolveComponent("svg-icon");
      return openBlock(), createElementBlock(Fragment, null, [
        createElementVNode("div", _hoisted_1, [
          createElementVNode("div", _hoisted_2, [
            renderSlot(_ctx.$slots, "default", {
              addNode,
              readOnly: unref(readOnly)
            }, void 0, true)
          ]),
          (openBlock(true), createElementBlock(Fragment, null, renderList(__props.node.branches, (item, index) => {
            return openBlock(), createElementBlock("div", {
              key: item.id,
              class: "col-box"
            }, [
              index === 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                _cache[0] || (_cache[0] = createElementVNode("div", { class: "top-left-border" }, null, -1)),
                _cache[1] || (_cache[1] = createElementVNode("div", { class: "bottom-left-border" }, null, -1))
              ], 64)) : __props.node.branches.length === index + 1 ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                _cache[2] || (_cache[2] = createElementVNode("div", { class: "top-right-border" }, null, -1)),
                _cache[3] || (_cache[3] = createElementVNode("div", { class: "bottom-right-border" }, null, -1))
              ], 64)) : createCommentVNode("", true),
              createVNode(_sfc_main$1, mergeProps({
                node: item,
                ref_for: true
              }, _ctx.$attrs, {
                onAddNode: addNode,
                class: "col-node"
              }), {
                append: withCtx(() => [
                  withDirectives(createElementVNode("div", {
                    class: "move-left",
                    onClick: withModifiers(($event) => moveLeft(index), ["stop"])
                  }, [
                    createVNode(_component_svg_icon, { name: "el:ArrowLeft" })
                  ], 8, _hoisted_3), [
                    [vShow, index !== 0 && __props.node.branches.length !== index + 1 && !unref(readOnly)]
                  ]),
                  withDirectives(createElementVNode("div", {
                    class: "move-right",
                    onClick: withModifiers(($event) => moveRight(index), ["stop"])
                  }, [
                    createVNode(_component_svg_icon, { name: "el:ArrowRight" })
                  ], 8, _hoisted_4), [
                    [vShow, ![index + 1, index + 2].includes(__props.node.branches.length) && !unref(readOnly)]
                  ])
                ]),
                _: 2
              }, 1040, ["node"])
            ]);
          }), 128))
        ]),
        createVNode(Add, {
          onAddNode: addNode,
          class: "branch-but"
        })
      ], 64);
    };
  }
};
const GatewayNode = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3050b6e4"]]);
export {
  GatewayNode as default
};
