import { n as e } from "./chunk-TYymryXo.mjs";
import { t } from "./_plugin-vue_export-helper-C_T2la-V.mjs";
import { n, t as r } from "./selectedInfo-CT8ehCR8.mjs";
import { t as i } from "./flowProperties-vIGdsvta.mjs";
import { computed as a, createElementBlock as o, createElementVNode as s, defineComponent as c, inject as l, nextTick as u, normalizeStyle as d, openBlock as f, reactive as p, ref as m, vShow as h, withDirectives as g } from "vue";
import './nextNodePanel.css';//#region src/pages/flow-create/flow-model/createComponents/flow/components/nextNodePanel.vue?vue&type=script&setup=true&lang.ts
var _ = {
	flex: "",
	"flex-col": "",
	bg: "#fff"
}, v = /* @__PURE__ */ c({
	name: "NextNodePanel",
	__name: "nextNodePanel",
	setup(e, { expose: t }) {
		let c = l("lf"), v = n(), y = r(), b = m(""), x = a(() => c.value.graphModel), S = a(() => c.value.getNodeModelById(b.value)), C = m(!1), w = 0;
		function T(e) {
			let t = `node-${Date.now()}`, n = S.value.x + 300, r = [];
			try {
				r = x.value.nodes || [];
			} catch {
				r = [];
			}
			let a = S.value.width || S.value.w || 200, o = S.value.height || S.value.h || 40;
			function s(e) {
				let t = e.width || e.w || a, n = e.height || e.h || o;
				return {
					left: e.x - t / 2,
					right: e.x + t / 2,
					top: e.y - n / 2,
					bottom: e.y + n / 2
				};
			}
			function l(e, t) {
				return !(e.right + 20 <= t.left || e.left - 20 >= t.right || e.bottom + 20 <= t.top || e.top - 20 >= t.bottom);
			}
			let u = r.filter((e) => e.id !== S.value.id && e.id !== t).map(s), d = S.value.y, f = d + 100 * w++, p = o + 20, m = !1;
			for (let e = 0; e < 20; e++) {
				let t = d + Math.floor((e + 1) / 2) * p, r = {
					left: n - a / 2,
					right: n + a / 2,
					top: t - o / 2,
					bottom: t + o / 2
				}, i = !1;
				for (let e of u) if (l(r, e)) {
					i = !0;
					break;
				}
				if (!i) {
					f = t, m = !0;
					break;
				}
			}
			m || (f = d + 100 * w++), x.value.addNode({
				type: e,
				id: t,
				x: n,
				y: f,
				properties: i[e]
			});
			let h = {
				id: t,
				type: e,
				title: i[e].title || ""
			};
			(h.type === "user-task-node" || h.type === "normal-task-node") && (h.approveMethod = i[e].approveMethod, h.customConfiguration = i[e].customConfiguration), v.updateElement(t, h);
			let g = {
				type: "custom-bezier-edge",
				sourceNodeId: b.value,
				targetNodeId: t
			};
			x.value.addEdge(g), setTimeout(() => {
				C.value = !1, y.setSelectId(t), y.setSelectType(e), x.value.edges.forEach((e) => {
					c.value.setProperties(e.id, { selected: !1 });
				});
			}, 100);
		}
		let E = p({
			left: "0px",
			top: "0px"
		});
		async function D(e, t, n) {
			if (b.value = n, !e || !t) return;
			let r = e.getBoundingClientRect(), i = t.getBoundingClientRect(), a = t.parentElement, o = a ? a.getBoundingClientRect() : i, s = r.right - o.left + 8, c = r.top - o.top - 4;
			C.value = !0, await u();
			let l = a?.querySelector(".next-node-panel") || document.querySelector(".next-node-panel"), d = l ? l.offsetWidth : 220, f = l ? l.offsetHeight : 180, p = i.left - o.left, m = i.width, h = i.height;
			s + d > p + m && (s = r.left - o.left - d - 8), s < p && (s = p), c + f > h + i.top - o.top && (c = Math.max(i.top - o.top, i.top - o.top + h - f - 8)), c < i.top - o.top && (c = i.top - o.top), E.left = `${s}px`, E.top = `${c}px`;
		}
		function O() {
			C.value = !1;
		}
		return t({
			openByAnchor: D,
			close: O
		}), (e, t) => g((f(), o("div", {
			class: "next-node-panel",
			style: d({
				position: "absolute",
				left: E.left,
				top: E.top,
				zIndex: 1e3
			})
		}, [s("div", _, [
			s("div", {
				class: "node-item",
				onClick: t[0] ||= (e) => T("user-task-node")
			}, " 用户任务 "),
			s("div", {
				class: "node-item",
				onClick: t[1] ||= (e) => T("normal-task-node")
			}, " 任务 "),
			s("div", {
				class: "node-item",
				onClick: t[2] ||= (e) => T("exclusive-gateway-node")
			}, " 互斥网关 "),
			s("div", {
				class: "node-item",
				onClick: t[3] ||= (e) => T("parallel-gateway-node")
			}, " 并行网关 "),
			s("div", {
				class: "node-item",
				onClick: t[4] ||= (e) => T("end-node")
			}, " 结束 ")
		])], 4)), [[h, C.value]]);
	}
}), y = /* @__PURE__ */ e({ default: () => b }), b = /* @__PURE__ */ t(v, [["__scopeId", "data-v-05145dd5"]]);
//#endregion
export { y as n, b as t };
