import { BaseEdge, EdgeLabelRenderer } from "../../../../node_modules/@xyflow/react/dist/esm/index.js";
import { formatCondition } from "../../lib/flow-utils.js";
import { resolveEdgePath } from "../../lib/edge-paths.js";
import { c } from "react/compiler-runtime";
import React from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
import { Wrench } from "lucide-react";
var TransitionLabel = (e) => {
	let t = c(12), { transitionId: n, tools: r, condition: a, isExecuted: o, forceVisible: d } = e, f = `flex flex-col items-center gap-0.5 rounded-full border px-2 py-0.5 shadow-sm transition-all hover:z-50 hover:scale-105 bg-background/95 backdrop-blur-[2px] text-muted-foreground border-border/40 hover:border-border/80 ${o || d ? "opacity-100" : "opacity-60 hover:opacity-100"}`, p;
	t[0] === n ? p = t[1] : (p = /* @__PURE__ */ jsx("span", {
		className: "text-[10px] font-semibold leading-tight tracking-tight",
		children: n
	}), t[0] = n, t[1] = p);
	let m;
	t[2] !== o || t[3] !== r ? (m = r && /* @__PURE__ */ jsxs("div", {
		className: `flex items-center gap-1 rounded-full px-1.5 py-[1px] text-[9px] ${o ? "bg-primary/5 text-primary" : "bg-muted/50 text-muted-foreground"}`,
		children: [/* @__PURE__ */ jsx(Wrench, { className: "h-2.5 w-2.5 opacity-70" }), /* @__PURE__ */ jsx("span", {
			className: "max-w-[150px] truncate font-mono font-medium",
			children: r
		})]
	}), t[2] = o, t[3] = r, t[4] = m) : m = t[4];
	let h;
	t[5] === a ? h = t[6] : (h = a && /* @__PURE__ */ jsx("span", {
		className: "max-w-[150px] truncate font-mono text-[8px] tracking-tighter opacity-70",
		children: a
	}), t[5] = a, t[6] = h);
	let g;
	return t[7] !== f || t[8] !== p || t[9] !== m || t[10] !== h ? (g = /* @__PURE__ */ jsxs("div", {
		className: f,
		children: [
			p,
			m,
			h
		]
	}), t[7] = f, t[8] = p, t[9] = m, t[10] = h, t[11] = g) : g = t[11], g;
}, WorkflowTransitionEdge_default = (a) => {
	let u = c(39), { sourceX: f, sourceY: m, targetX: h, targetY: g, sourcePosition: _, targetPosition: v, style: y, markerEnd: b, data: x } = a, S;
	u[0] === y ? S = u[1] : (S = y === void 0 ? {} : y, u[0] = y, u[1] = S);
	let C = S, w, T, E, D, O, k, A, j;
	if (u[2] !== x || u[3] !== _ || u[4] !== f || u[5] !== m || u[6] !== v || u[7] !== h || u[8] !== g) {
		let { id: e, isExecuted: t, isSelfLoop: i, isBackEdge: a, forceVisible: o, call: s, condition: l } = x ?? {};
		j = e, D = t === void 0 ? !1 : t;
		let d = i === void 0 ? !1 : i, y = a === void 0 ? !1 : a;
		T = o === void 0 ? !1 : o, {path: w, labelX: O, labelY: k} = resolveEdgePath({
			sourceX: f,
			sourceY: m,
			targetX: h,
			targetY: g,
			sourcePosition: _,
			targetPosition: v
		}, {
			isSelfLoop: d,
			isBackEdge: y
		}), E = l ? formatCondition(l) : null, A = s?.map(_temp).join(", "), u[2] = x, u[3] = _, u[4] = f, u[5] = m, u[6] = v, u[7] = h, u[8] = g, u[9] = w, u[10] = T, u[11] = E, u[12] = D, u[13] = O, u[14] = k, u[15] = A, u[16] = j;
	} else w = u[9], T = u[10], E = u[11], D = u[12], O = u[13], k = u[14], A = u[15], j = u[16];
	let M = A;
	if (!(j || M || E)) {
		let t;
		return u[17] !== w || u[18] !== b || u[19] !== C ? (t = /* @__PURE__ */ jsx(BaseEdge, {
			path: w,
			markerEnd: b,
			style: C
		}), u[17] = w, u[18] = b, u[19] = C, u[20] = t) : t = u[20], t;
	}
	let N;
	u[21] !== w || u[22] !== b || u[23] !== C ? (N = /* @__PURE__ */ jsx(BaseEdge, {
		path: w,
		markerEnd: b,
		style: C
	}), u[21] = w, u[22] = b, u[23] = C, u[24] = N) : N = u[24];
	let P = `translate(-50%, -50%) translate(${O}px,${k}px)`, F;
	u[25] === P ? F = u[26] : (F = {
		position: "absolute",
		transform: P,
		pointerEvents: "all"
	}, u[25] = P, u[26] = F);
	let I = j ?? "", L;
	u[27] !== T || u[28] !== E || u[29] !== D || u[30] !== I || u[31] !== M ? (L = /* @__PURE__ */ jsx(TransitionLabel, {
		transitionId: I,
		tools: M,
		condition: E,
		isExecuted: D,
		forceVisible: T
	}), u[27] = T, u[28] = E, u[29] = D, u[30] = I, u[31] = M, u[32] = L) : L = u[32];
	let R;
	u[33] !== F || u[34] !== L ? (R = /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx("div", {
		style: F,
		className: "nodrag nopan",
		children: L
	}) }), u[33] = F, u[34] = L, u[35] = R) : R = u[35];
	let z;
	return u[36] !== N || u[37] !== R ? (z = /* @__PURE__ */ jsxs(Fragment$1, { children: [N, R] }), u[36] = N, u[37] = R, u[38] = z) : z = u[38], z;
};
function _temp(e) {
	return e.tool;
}
export { WorkflowTransitionEdge_default as default };
