import e from "../../../../d3-selection/src/select.js";
import t from "../../../../d3-selection/src/pointer.js";
import n from "../../../../d3-drag/src/drag.js";
import r from "../../../../d3-interpolate/src/value.js";
import i from "../../../../d3-interpolate/src/zoom.js";
import a, { identity as o } from "../../../../d3-zoom/src/transform.js";
import s from "../../../../d3-zoom/src/zoom.js";
import "../../../../d3-zoom/src/index.js";
//#region ../../node_modules/@xyflow/system/dist/esm/index.js
var c = {
	error001: () => "[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",
	error002: () => "It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",
	error003: (e) => `Node type "${e}" not found. Using fallback type "default".`,
	error004: () => "The React Flow parent container needs a width and a height to render the graph.",
	error005: () => "Only child nodes can use a parent extent.",
	error006: () => "Can't create edge. An edge needs a source and a target.",
	error007: (e) => `The old edge with id=${e} does not exist.`,
	error009: (e) => `Marker type "${e}" doesn't exist.`,
	error008: (e, { id: t, sourceHandle: n, targetHandle: r }) => `Couldn't create edge for ${e} handle id: "${e === "source" ? n : r}", edge id: ${t}.`,
	error010: () => "Handle: No node id found. Make sure to only use a Handle inside a custom Node.",
	error011: (e) => `Edge type "${e}" not found. Using fallback type "default".`,
	error012: (e) => `Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,
	error013: (e = "react") => `It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,
	error014: () => "useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",
	error015: () => "It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."
}, l = [[-Infinity, -Infinity], [Infinity, Infinity]], u = [
	"Enter",
	" ",
	"Escape"
], d = {
	"node.a11yDescription.default": "Press enter or space to select a node. Press delete to remove it and escape to cancel.",
	"node.a11yDescription.keyboardDisabled": "Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.",
	"node.a11yDescription.ariaLiveMessage": ({ direction: e, x: t, y: n }) => `Moved selected node ${e}. New position, x: ${t}, y: ${n}`,
	"edge.a11yDescription.default": "Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
	"controls.ariaLabel": "Control Panel",
	"controls.zoomIn.ariaLabel": "Zoom In",
	"controls.zoomOut.ariaLabel": "Zoom Out",
	"controls.fitView.ariaLabel": "Fit View",
	"controls.interactive.ariaLabel": "Toggle Interactivity",
	"minimap.ariaLabel": "Mini Map",
	"handle.ariaLabel": "Handle"
}, f;
(function(e) {
	e.Strict = "strict", e.Loose = "loose";
})(f ||= {});
var p;
(function(e) {
	e.Free = "free", e.Vertical = "vertical", e.Horizontal = "horizontal";
})(p ||= {});
var m;
(function(e) {
	e.Partial = "partial", e.Full = "full";
})(m ||= {});
var h = {
	inProgress: !1,
	isValid: null,
	from: null,
	fromHandle: null,
	fromPosition: null,
	fromNode: null,
	to: null,
	toHandle: null,
	toPosition: null,
	toNode: null,
	pointer: null
}, g;
(function(e) {
	e.Bezier = "default", e.Straight = "straight", e.Step = "step", e.SmoothStep = "smoothstep", e.SimpleBezier = "simplebezier";
})(g ||= {});
var _;
(function(e) {
	e.Arrow = "arrow", e.ArrowClosed = "arrowclosed";
})(_ ||= {});
var v;
(function(e) {
	e.Left = "left", e.Top = "top", e.Right = "right", e.Bottom = "bottom";
})(v ||= {});
var y = {
	[v.Left]: v.Right,
	[v.Right]: v.Left,
	[v.Top]: v.Bottom,
	[v.Bottom]: v.Top
};
function b(e) {
	return e === null ? null : e ? "valid" : "invalid";
}
var x = (e) => "id" in e && "source" in e && "target" in e, S = (e) => "id" in e && "position" in e && !("source" in e) && !("target" in e), C = (e) => "id" in e && "internals" in e && !("source" in e) && !("target" in e), w = (e, t = [0, 0]) => {
	let { width: n, height: r } = J(e), i = e.origin ?? t, a = n * i[0], o = r * i[1];
	return {
		x: e.position.x - a,
		y: e.position.y - o
	};
}, T = (e, t = { nodeOrigin: [0, 0] }) => (process.env.NODE_ENV === "development" && !t.nodeLookup && console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."), e.length === 0 ? {
	x: 0,
	y: 0,
	width: 0,
	height: 0
} : R(e.reduce((e, n) => {
	let r = typeof n == "string", i = !t.nodeLookup && !r ? n : void 0;
	return t.nodeLookup && (i = r ? t.nodeLookup.get(n) : C(n) ? n : t.nodeLookup.get(n.id)), te(e, i ? ne(i, t.nodeOrigin) : {
		x: 0,
		y: 0,
		x2: 0,
		y2: 0
	});
}, {
	x: Infinity,
	y: Infinity,
	x2: -Infinity,
	y2: -Infinity
}))), E = (e, t = {}) => {
	let n = {
		x: Infinity,
		y: Infinity,
		x2: -Infinity,
		y2: -Infinity
	}, r = !1;
	return e.forEach((e) => {
		(t.filter === void 0 || t.filter(e)) && (n = te(n, ne(e)), r = !0);
	}), r ? R(n) : {
		x: 0,
		y: 0,
		width: 0,
		height: 0
	};
}, D = (e, t, [n, r, i] = [
	0,
	0,
	1
], a = !1, o = !1) => {
	let s = {
		...re(t, [
			n,
			r,
			i
		]),
		width: t.width / i,
		height: t.height / i
	}, c = [];
	for (let t of e.values()) {
		let { measured: e, selectable: n = !0, hidden: r = !1 } = t;
		if (o && !n || r) continue;
		let i = e.width ?? t.width ?? t.initialWidth ?? null, l = e.height ?? t.height ?? t.initialHeight ?? null, u = V(s, z(t)), d = (i ?? 0) * (l ?? 0), f = a && u > 0;
		(!t.internals.handleBounds || f || u >= d || t.dragging) && c.push(t);
	}
	return c;
}, O = (e, t) => {
	let n = /* @__PURE__ */ new Set();
	return e.forEach((e) => {
		n.add(e.id);
	}), t.filter((e) => n.has(e.source) || n.has(e.target));
};
function k(e, t) {
	let n = /* @__PURE__ */ new Map(), r = t?.nodes ? new Set(t.nodes.map((e) => e.id)) : null;
	return e.forEach((e) => {
		e.measured.width && e.measured.height && (t?.includeHiddenNodes || !e.hidden) && (!r || r.has(e.id)) && n.set(e.id, e);
	}), n;
}
async function A({ nodes: e, width: t, height: n, panZoom: r, minZoom: i, maxZoom: a }, o) {
	if (e.size === 0) return Promise.resolve(!0);
	let s = se(E(k(e, o)), t, n, o?.minZoom ?? i, o?.maxZoom ?? a, o?.padding ?? .1);
	return await r.setViewport(s, {
		duration: o?.duration,
		ease: o?.ease,
		interpolate: o?.interpolate
	}), Promise.resolve(!0);
}
function j({ nodeId: e, nextPosition: t, nodeLookup: n, nodeOrigin: r = [0, 0], nodeExtent: i, onError: a }) {
	let o = n.get(e), s = o.parentId ? n.get(o.parentId) : void 0, { x: l, y: u } = s ? s.internals.positionAbsolute : {
		x: 0,
		y: 0
	}, d = o.origin ?? r, f = o.extent || i;
	if (o.extent === "parent" && !o.expandParent) if (!s) a?.("005", c.error005());
	else {
		let e = s.measured.width, t = s.measured.height;
		e && t && (f = [[l, u], [l + e, u + t]]);
	}
	else s && q(o.extent) && (f = [[o.extent[0][0] + l, o.extent[0][1] + u], [o.extent[1][0] + l, o.extent[1][1] + u]]);
	let p = q(f) ? P(t, f, o.measured) : t;
	return (o.measured.width === void 0 || o.measured.height === void 0) && a?.("015", c.error015()), {
		position: {
			x: p.x - l + (o.measured.width ?? 0) * d[0],
			y: p.y - u + (o.measured.height ?? 0) * d[1]
		},
		positionAbsolute: p
	};
}
async function M({ nodesToRemove: e = [], edgesToRemove: t = [], nodes: n, edges: r, onBeforeDelete: i }) {
	let a = new Set(e.map((e) => e.id)), o = [];
	for (let e of n) {
		if (e.deletable === !1) continue;
		let t = a.has(e.id), n = !t && e.parentId && o.find((t) => t.id === e.parentId);
		(t || n) && o.push(e);
	}
	let s = new Set(t.map((e) => e.id)), c = r.filter((e) => e.deletable !== !1), l = O(o, c);
	for (let e of c) s.has(e.id) && !l.find((t) => t.id === e.id) && l.push(e);
	if (!i) return {
		edges: l,
		nodes: o
	};
	let u = await i({
		nodes: o,
		edges: l
	});
	return typeof u == "boolean" ? u ? {
		edges: l,
		nodes: o
	} : {
		edges: [],
		nodes: []
	} : u;
}
var N = (e, t = 0, n = 1) => Math.min(Math.max(e, t), n), P = (e = {
	x: 0,
	y: 0
}, t, n) => ({
	x: N(e.x, t[0][0], t[1][0] - (n?.width ?? 0)),
	y: N(e.y, t[0][1], t[1][1] - (n?.height ?? 0))
});
function F(e, t, n) {
	let { width: r, height: i } = J(n), { x: a, y: o } = n.internals.positionAbsolute;
	return P(e, [[a, o], [a + r, o + i]], t);
}
var I = (e, t, n) => e < t ? N(Math.abs(e - t), 1, t) / t : e > n ? -N(Math.abs(e - n), 1, t) / t : 0, ee = (e, t, n = 15, r = 40) => [I(e.x, r, t.width - r) * n, I(e.y, r, t.height - r) * n], te = (e, t) => ({
	x: Math.min(e.x, t.x),
	y: Math.min(e.y, t.y),
	x2: Math.max(e.x2, t.x2),
	y2: Math.max(e.y2, t.y2)
}), L = ({ x: e, y: t, width: n, height: r }) => ({
	x: e,
	y: t,
	x2: e + n,
	y2: t + r
}), R = ({ x: e, y: t, x2: n, y2: r }) => ({
	x: e,
	y: t,
	width: n - e,
	height: r - t
}), z = (e, t = [0, 0]) => {
	let { x: n, y: r } = C(e) ? e.internals.positionAbsolute : w(e, t);
	return {
		x: n,
		y: r,
		width: e.measured?.width ?? e.width ?? e.initialWidth ?? 0,
		height: e.measured?.height ?? e.height ?? e.initialHeight ?? 0
	};
}, ne = (e, t = [0, 0]) => {
	let { x: n, y: r } = C(e) ? e.internals.positionAbsolute : w(e, t);
	return {
		x: n,
		y: r,
		x2: n + (e.measured?.width ?? e.width ?? e.initialWidth ?? 0),
		y2: r + (e.measured?.height ?? e.height ?? e.initialHeight ?? 0)
	};
}, B = (e, t) => R(te(L(e), L(t))), V = (e, t) => {
	let n = Math.max(0, Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x)), r = Math.max(0, Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y));
	return Math.ceil(n * r);
}, H = (e) => U(e.width) && U(e.height) && U(e.x) && U(e.y), U = (e) => !isNaN(e) && isFinite(e), W = (e, t) => {
	process.env.NODE_ENV === "development" && console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`);
}, G = (e, t = [1, 1]) => ({
	x: t[0] * Math.round(e.x / t[0]),
	y: t[1] * Math.round(e.y / t[1])
}), re = ({ x: e, y: t }, [n, r, i], a = !1, o = [1, 1]) => {
	let s = {
		x: (e - n) / i,
		y: (t - r) / i
	};
	return a ? G(s, o) : s;
}, ie = ({ x: e, y: t }, [n, r, i]) => ({
	x: e * i + n,
	y: t * i + r
});
function K(e, t) {
	if (typeof e == "number") return Math.floor((t - t / (1 + e)) * .5);
	if (typeof e == "string" && e.endsWith("px")) {
		let t = parseFloat(e);
		if (!Number.isNaN(t)) return Math.floor(t);
	}
	if (typeof e == "string" && e.endsWith("%")) {
		let n = parseFloat(e);
		if (!Number.isNaN(n)) return Math.floor(t * n * .01);
	}
	return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`), 0;
}
function ae(e, t, n) {
	if (typeof e == "string" || typeof e == "number") {
		let r = K(e, n), i = K(e, t);
		return {
			top: r,
			right: i,
			bottom: r,
			left: i,
			x: i * 2,
			y: r * 2
		};
	}
	if (typeof e == "object") {
		let r = K(e.top ?? e.y ?? 0, n), i = K(e.bottom ?? e.y ?? 0, n), a = K(e.left ?? e.x ?? 0, t), o = K(e.right ?? e.x ?? 0, t);
		return {
			top: r,
			right: o,
			bottom: i,
			left: a,
			x: a + o,
			y: r + i
		};
	}
	return {
		top: 0,
		right: 0,
		bottom: 0,
		left: 0,
		x: 0,
		y: 0
	};
}
function oe(e, t, n, r, i, a) {
	let { x: o, y: s } = ie(e, [
		t,
		n,
		r
	]), { x: c, y: l } = ie({
		x: e.x + e.width,
		y: e.y + e.height
	}, [
		t,
		n,
		r
	]), u = i - c, d = a - l;
	return {
		left: Math.floor(o),
		top: Math.floor(s),
		right: Math.floor(u),
		bottom: Math.floor(d)
	};
}
var se = (e, t, n, r, i, a) => {
	let o = ae(a, t, n), s = (t - o.x) / e.width, c = (n - o.y) / e.height, l = N(Math.min(s, c), r, i), u = e.x + e.width / 2, d = e.y + e.height / 2, f = t / 2 - u * l, p = n / 2 - d * l, m = oe(e, f, p, l, t, n), h = {
		left: Math.min(m.left - o.left, 0),
		top: Math.min(m.top - o.top, 0),
		right: Math.min(m.right - o.right, 0),
		bottom: Math.min(m.bottom - o.bottom, 0)
	};
	return {
		x: f - h.left + h.right,
		y: p - h.top + h.bottom,
		zoom: l
	};
}, ce = () => typeof navigator < "u" && navigator?.userAgent?.indexOf("Mac") >= 0;
function q(e) {
	return e != null && e !== "parent";
}
function J(e) {
	return {
		width: e.measured?.width ?? e.width ?? e.initialWidth ?? 0,
		height: e.measured?.height ?? e.height ?? e.initialHeight ?? 0
	};
}
function le(e) {
	return (e.measured?.width ?? e.width ?? e.initialWidth) !== void 0 && (e.measured?.height ?? e.height ?? e.initialHeight) !== void 0;
}
function ue(e, t = {
	width: 0,
	height: 0
}, n, r, i) {
	let a = { ...e }, o = r.get(n);
	if (o) {
		let e = o.origin || i;
		a.x += o.internals.positionAbsolute.x - (t.width ?? 0) * e[0], a.y += o.internals.positionAbsolute.y - (t.height ?? 0) * e[1];
	}
	return a;
}
function de(e, t) {
	if (e.size !== t.size) return !1;
	for (let n of e) if (!t.has(n)) return !1;
	return !0;
}
function fe() {
	let e, t;
	return {
		promise: new Promise((n, r) => {
			e = n, t = r;
		}),
		resolve: e,
		reject: t
	};
}
function pe(e) {
	return {
		...d,
		...e || {}
	};
}
function me(e, { snapGrid: t = [0, 0], snapToGrid: n = !1, transform: r, containerBounds: i }) {
	let { x: a, y: o } = Y(e), s = re({
		x: a - (i?.left ?? 0),
		y: o - (i?.top ?? 0)
	}, r), { x: c, y: l } = n ? G(s, t) : s;
	return {
		xSnapped: c,
		ySnapped: l,
		...s
	};
}
var he = (e) => ({
	width: e.offsetWidth,
	height: e.offsetHeight
}), ge = (e) => e?.getRootNode?.() || window?.document, _e = [
	"INPUT",
	"SELECT",
	"TEXTAREA"
];
function ve(e) {
	let t = e.composedPath?.()?.[0] || e.target;
	return t?.nodeType === 1 ? _e.includes(t.nodeName) || t.hasAttribute("contenteditable") || !!t.closest(".nokey") : !1;
}
var ye = (e) => "clientX" in e, Y = (e, t) => {
	let n = ye(e), r = n ? e.clientX : e.touches?.[0].clientX, i = n ? e.clientY : e.touches?.[0].clientY;
	return {
		x: r - (t?.left ?? 0),
		y: i - (t?.top ?? 0)
	};
}, be = (e, t, n, r, i) => {
	let a = t.querySelectorAll(`.${e}`);
	return !a || !a.length ? null : Array.from(a).map((t) => {
		let a = t.getBoundingClientRect();
		return {
			id: t.getAttribute("data-handleid"),
			type: e,
			nodeId: i,
			position: t.getAttribute("data-handlepos"),
			x: (a.left - n.left) / r,
			y: (a.top - n.top) / r,
			...he(t)
		};
	});
};
function xe({ sourceX: e, sourceY: t, targetX: n, targetY: r, sourceControlX: i, sourceControlY: a, targetControlX: o, targetControlY: s }) {
	let c = e * .125 + i * .375 + o * .375 + n * .125, l = t * .125 + a * .375 + s * .375 + r * .125;
	return [
		c,
		l,
		Math.abs(c - e),
		Math.abs(l - t)
	];
}
function Se(e, t) {
	return e >= 0 ? .5 * e : t * 25 * Math.sqrt(-e);
}
function Ce({ pos: e, x1: t, y1: n, x2: r, y2: i, c: a }) {
	switch (e) {
		case v.Left: return [t - Se(t - r, a), n];
		case v.Right: return [t + Se(r - t, a), n];
		case v.Top: return [t, n - Se(n - i, a)];
		case v.Bottom: return [t, n + Se(i - n, a)];
	}
}
function we({ sourceX: e, sourceY: t, sourcePosition: n = v.Bottom, targetX: r, targetY: i, targetPosition: a = v.Top, curvature: o = .25 }) {
	let [s, c] = Ce({
		pos: n,
		x1: e,
		y1: t,
		x2: r,
		y2: i,
		c: o
	}), [l, u] = Ce({
		pos: a,
		x1: r,
		y1: i,
		x2: e,
		y2: t,
		c: o
	}), [d, f, p, m] = xe({
		sourceX: e,
		sourceY: t,
		targetX: r,
		targetY: i,
		sourceControlX: s,
		sourceControlY: c,
		targetControlX: l,
		targetControlY: u
	});
	return [
		`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,
		d,
		f,
		p,
		m
	];
}
function Te({ sourceX: e, sourceY: t, targetX: n, targetY: r }) {
	let i = Math.abs(n - e) / 2, a = n < e ? n + i : n - i, o = Math.abs(r - t) / 2;
	return [
		a,
		r < t ? r + o : r - o,
		i,
		o
	];
}
function Ee({ sourceNode: e, targetNode: t, selected: n = !1, zIndex: r = 0, elevateOnSelect: i = !1, zIndexMode: a = "basic" }) {
	return a === "manual" ? r : (i && n ? r + 1e3 : r) + Math.max(e.parentId || i && e.selected ? e.internals.z : 0, t.parentId || i && t.selected ? t.internals.z : 0);
}
function De({ sourceNode: e, targetNode: t, width: n, height: r, transform: i }) {
	let a = te(ne(e), ne(t));
	return a.x === a.x2 && (a.x2 += 1), a.y === a.y2 && (a.y2 += 1), V({
		x: -i[0] / i[2],
		y: -i[1] / i[2],
		width: n / i[2],
		height: r / i[2]
	}, R(a)) > 0;
}
var Oe = ({ source: e, sourceHandle: t, target: n, targetHandle: r }) => `xy-edge__${e}${t || ""}-${n}${r || ""}`, ke = (e, t) => t.some((t) => t.source === e.source && t.target === e.target && (t.sourceHandle === e.sourceHandle || !t.sourceHandle && !e.sourceHandle) && (t.targetHandle === e.targetHandle || !t.targetHandle && !e.targetHandle)), Ae = (e, t, n = {}) => {
	if (!e.source || !e.target) return W("006", c.error006()), t;
	let r = n.getEdgeId || Oe, i;
	return i = x(e) ? { ...e } : {
		...e,
		id: r(e)
	}, ke(i, t) ? t : (i.sourceHandle === null && delete i.sourceHandle, i.targetHandle === null && delete i.targetHandle, t.concat(i));
};
function je({ sourceX: e, sourceY: t, targetX: n, targetY: r }) {
	let [i, a, o, s] = Te({
		sourceX: e,
		sourceY: t,
		targetX: n,
		targetY: r
	});
	return [
		`M ${e},${t}L ${n},${r}`,
		i,
		a,
		o,
		s
	];
}
var Me = {
	[v.Left]: {
		x: -1,
		y: 0
	},
	[v.Right]: {
		x: 1,
		y: 0
	},
	[v.Top]: {
		x: 0,
		y: -1
	},
	[v.Bottom]: {
		x: 0,
		y: 1
	}
}, Ne = ({ source: e, sourcePosition: t = v.Bottom, target: n }) => t === v.Left || t === v.Right ? e.x < n.x ? {
	x: 1,
	y: 0
} : {
	x: -1,
	y: 0
} : e.y < n.y ? {
	x: 0,
	y: 1
} : {
	x: 0,
	y: -1
}, Pe = (e, t) => Math.sqrt((t.x - e.x) ** 2 + (t.y - e.y) ** 2);
function Fe({ source: e, sourcePosition: t = v.Bottom, target: n, targetPosition: r = v.Top, center: i, offset: a, stepPosition: o }) {
	let s = Me[t], c = Me[r], l = {
		x: e.x + s.x * a,
		y: e.y + s.y * a
	}, u = {
		x: n.x + c.x * a,
		y: n.y + c.y * a
	}, d = Ne({
		source: l,
		sourcePosition: t,
		target: u
	}), f = d.x === 0 ? "y" : "x", p = d[f], m = [], h, g, _ = {
		x: 0,
		y: 0
	}, y = {
		x: 0,
		y: 0
	}, [, , b, x] = Te({
		sourceX: e.x,
		sourceY: e.y,
		targetX: n.x,
		targetY: n.y
	});
	if (s[f] * c[f] === -1) {
		f === "x" ? (h = i.x ?? l.x + (u.x - l.x) * o, g = i.y ?? (l.y + u.y) / 2) : (h = i.x ?? (l.x + u.x) / 2, g = i.y ?? l.y + (u.y - l.y) * o);
		let e = [{
			x: h,
			y: l.y
		}, {
			x: h,
			y: u.y
		}], t = [{
			x: l.x,
			y: g
		}, {
			x: u.x,
			y: g
		}];
		m = s[f] === p ? f === "x" ? e : t : f === "x" ? t : e;
	} else {
		let i = [{
			x: l.x,
			y: u.y
		}], o = [{
			x: u.x,
			y: l.y
		}];
		if (m = f === "x" ? s.x === p ? o : i : s.y === p ? i : o, t === r) {
			let t = Math.abs(e[f] - n[f]);
			if (t <= a) {
				let r = Math.min(a - 1, a - t);
				s[f] === p ? _[f] = (l[f] > e[f] ? -1 : 1) * r : y[f] = (u[f] > n[f] ? -1 : 1) * r;
			}
		}
		if (t !== r) {
			let e = f === "x" ? "y" : "x", t = s[f] === c[e], n = l[e] > u[e], r = l[e] < u[e];
			(s[f] === 1 && (!t && n || t && r) || s[f] !== 1 && (!t && r || t && n)) && (m = f === "x" ? i : o);
		}
		let d = {
			x: l.x + _.x,
			y: l.y + _.y
		}, v = {
			x: u.x + y.x,
			y: u.y + y.y
		};
		Math.max(Math.abs(d.x - m[0].x), Math.abs(v.x - m[0].x)) >= Math.max(Math.abs(d.y - m[0].y), Math.abs(v.y - m[0].y)) ? (h = (d.x + v.x) / 2, g = m[0].y) : (h = m[0].x, g = (d.y + v.y) / 2);
	}
	let S = {
		x: l.x + _.x,
		y: l.y + _.y
	}, C = {
		x: u.x + y.x,
		y: u.y + y.y
	};
	return [
		[
			e,
			...S.x !== m[0].x || S.y !== m[0].y ? [S] : [],
			...m,
			...C.x !== m[m.length - 1].x || C.y !== m[m.length - 1].y ? [C] : [],
			n
		],
		h,
		g,
		b,
		x
	];
}
function Ie(e, t, n, r) {
	let i = Math.min(Pe(e, t) / 2, Pe(t, n) / 2, r), { x: a, y: o } = t;
	if (e.x === a && a === n.x || e.y === o && o === n.y) return `L${a} ${o}`;
	if (e.y === o) {
		let t = e.x < n.x ? -1 : 1, r = e.y < n.y ? 1 : -1;
		return `L ${a + i * t},${o}Q ${a},${o} ${a},${o + i * r}`;
	}
	let s = e.x < n.x ? 1 : -1;
	return `L ${a},${o + i * (e.y < n.y ? -1 : 1)}Q ${a},${o} ${a + i * s},${o}`;
}
function Le({ sourceX: e, sourceY: t, sourcePosition: n = v.Bottom, targetX: r, targetY: i, targetPosition: a = v.Top, borderRadius: o = 5, centerX: s, centerY: c, offset: l = 20, stepPosition: u = .5 }) {
	let [d, f, p, m, h] = Fe({
		source: {
			x: e,
			y: t
		},
		sourcePosition: n,
		target: {
			x: r,
			y: i
		},
		targetPosition: a,
		center: {
			x: s,
			y: c
		},
		offset: l,
		stepPosition: u
	}), g = `M${d[0].x} ${d[0].y}`;
	for (let e = 1; e < d.length - 1; e++) g += Ie(d[e - 1], d[e], d[e + 1], o);
	return g += `L${d[d.length - 1].x} ${d[d.length - 1].y}`, [
		g,
		f,
		p,
		m,
		h
	];
}
function Re(e) {
	return e && !!(e.internals.handleBounds || e.handles?.length) && !!(e.measured.width || e.width || e.initialWidth);
}
function ze(e) {
	let { sourceNode: t, targetNode: n } = e;
	if (!Re(t) || !Re(n)) return null;
	let r = t.internals.handleBounds || Be(t.handles), i = n.internals.handleBounds || Be(n.handles), a = Ve(r?.source ?? [], e.sourceHandle), o = Ve(e.connectionMode === f.Strict ? i?.target ?? [] : (i?.target ?? []).concat(i?.source ?? []), e.targetHandle);
	if (!a || !o) return e.onError?.("008", c.error008(a ? "target" : "source", {
		id: e.id,
		sourceHandle: e.sourceHandle,
		targetHandle: e.targetHandle
	})), null;
	let s = a?.position || v.Bottom, l = o?.position || v.Top, u = X(t, a, s), d = X(n, o, l);
	return {
		sourceX: u.x,
		sourceY: u.y,
		targetX: d.x,
		targetY: d.y,
		sourcePosition: s,
		targetPosition: l
	};
}
function Be(e) {
	if (!e) return null;
	let t = [], n = [];
	for (let r of e) r.width = r.width ?? 1, r.height = r.height ?? 1, r.type === "source" ? t.push(r) : r.type === "target" && n.push(r);
	return {
		source: t,
		target: n
	};
}
function X(e, t, n = v.Left, r = !1) {
	let i = (t?.x ?? 0) + e.internals.positionAbsolute.x, a = (t?.y ?? 0) + e.internals.positionAbsolute.y, { width: o, height: s } = t ?? J(e);
	if (r) return {
		x: i + o / 2,
		y: a + s / 2
	};
	switch (t?.position ?? n) {
		case v.Top: return {
			x: i + o / 2,
			y: a
		};
		case v.Right: return {
			x: i + o,
			y: a + s / 2
		};
		case v.Bottom: return {
			x: i + o / 2,
			y: a + s
		};
		case v.Left: return {
			x: i,
			y: a + s / 2
		};
	}
}
function Ve(e, t) {
	return e && (t ? e.find((e) => e.id === t) : e[0]) || null;
}
function He(e, t) {
	return e ? typeof e == "string" ? e : `${t ? `${t}__` : ""}${Object.keys(e).sort().map((t) => `${t}=${e[t]}`).join("&")}` : "";
}
function Ue(e, { id: t, defaultColor: n, defaultMarkerStart: r, defaultMarkerEnd: i }) {
	let a = /* @__PURE__ */ new Set();
	return e.reduce((e, o) => ([o.markerStart || r, o.markerEnd || i].forEach((r) => {
		if (r && typeof r == "object") {
			let i = He(r, t);
			a.has(i) || (e.push({
				id: i,
				color: r.color || n,
				...r
			}), a.add(i));
		}
	}), e), []).sort((e, t) => e.id.localeCompare(t.id));
}
var We = 1e3, Ge = 10, Ke = {
	nodeOrigin: [0, 0],
	nodeExtent: l,
	elevateNodesOnSelect: !0,
	zIndexMode: "basic",
	defaults: {}
}, qe = {
	...Ke,
	checkEquality: !0
};
function Je(e, t) {
	let n = { ...e };
	for (let e in t) t[e] !== void 0 && (n[e] = t[e]);
	return n;
}
function Ye(e, t, n) {
	let r = Je(Ke, n);
	for (let n of e.values()) if (n.parentId) et(n, e, t, r);
	else {
		let e = P(w(n, r.nodeOrigin), q(n.extent) ? n.extent : r.nodeExtent, J(n));
		n.internals.positionAbsolute = e;
	}
}
function Xe(e, t) {
	if (!e.handles) return e.measured ? t?.internals.handleBounds : void 0;
	let n = [], r = [];
	for (let t of e.handles) {
		let i = {
			id: t.id,
			width: t.width ?? 1,
			height: t.height ?? 1,
			nodeId: e.id,
			x: t.x,
			y: t.y,
			position: t.position,
			type: t.type
		};
		t.type === "source" ? n.push(i) : t.type === "target" && r.push(i);
	}
	return {
		source: n,
		target: r
	};
}
function Ze(e) {
	return e === "manual";
}
function Qe(e, t, n, r = {}) {
	let i = Je(qe, r), a = { i: 0 }, o = new Map(t), s = i?.elevateNodesOnSelect && !Ze(i.zIndexMode) ? We : 0, c = e.length > 0, l = !1;
	t.clear(), n.clear();
	for (let u of e) {
		let e = o.get(u.id);
		if (i.checkEquality && u === e?.internals.userNode) t.set(u.id, e);
		else {
			let n = P(w(u, i.nodeOrigin), q(u.extent) ? u.extent : i.nodeExtent, J(u));
			e = {
				...i.defaults,
				...u,
				measured: {
					width: u.measured?.width,
					height: u.measured?.height
				},
				internals: {
					positionAbsolute: n,
					handleBounds: Xe(u, e),
					z: tt(u, s, i.zIndexMode),
					userNode: u
				}
			}, t.set(u.id, e);
		}
		(e.measured === void 0 || e.measured.width === void 0 || e.measured.height === void 0) && !e.hidden && (c = !1), u.parentId && et(e, t, n, r, a), l ||= u.selected ?? !1;
	}
	return {
		nodesInitialized: c,
		hasSelectedNodes: l
	};
}
function $e(e, t) {
	if (!e.parentId) return;
	let n = t.get(e.parentId);
	n ? n.set(e.id, e) : t.set(e.parentId, new Map([[e.id, e]]));
}
function et(e, t, n, r, i) {
	let { elevateNodesOnSelect: a, nodeOrigin: o, nodeExtent: s, zIndexMode: c } = Je(Ke, r), l = e.parentId, u = t.get(l);
	if (!u) {
		console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);
		return;
	}
	$e(e, n), i && !u.parentId && u.internals.rootParentIndex === void 0 && c === "auto" && (u.internals.rootParentIndex = ++i.i, u.internals.z = u.internals.z + i.i * Ge), i && u.internals.rootParentIndex !== void 0 && (i.i = u.internals.rootParentIndex);
	let { x: d, y: f, z: p } = nt(e, u, o, s, a && !Ze(c) ? We : 0, c), { positionAbsolute: m } = e.internals, h = d !== m.x || f !== m.y;
	(h || p !== e.internals.z) && t.set(e.id, {
		...e,
		internals: {
			...e.internals,
			positionAbsolute: h ? {
				x: d,
				y: f
			} : m,
			z: p
		}
	});
}
function tt(e, t, n) {
	let r = U(e.zIndex) ? e.zIndex : 0;
	return Ze(n) ? r : r + (e.selected ? t : 0);
}
function nt(e, t, n, r, i, a) {
	let { x: o, y: s } = t.internals.positionAbsolute, c = J(e), l = w(e, n), u = q(e.extent) ? P(l, e.extent, c) : l, d = P({
		x: o + u.x,
		y: s + u.y
	}, r, c);
	e.extent === "parent" && (d = F(d, c, t));
	let f = tt(e, i, a), p = t.internals.z ?? 0;
	return {
		x: d.x,
		y: d.y,
		z: p >= f ? p + 1 : f
	};
}
function rt(e, t, n, r = [0, 0]) {
	let i = [], a = /* @__PURE__ */ new Map();
	for (let n of e) {
		let e = t.get(n.parentId);
		if (!e) continue;
		let r = B(a.get(n.parentId)?.expandedRect ?? z(e), n.rect);
		a.set(n.parentId, {
			expandedRect: r,
			parent: e
		});
	}
	return a.size > 0 && a.forEach(({ expandedRect: t, parent: a }, o) => {
		let s = a.internals.positionAbsolute, c = J(a), l = a.origin ?? r, u = t.x < s.x ? Math.round(Math.abs(s.x - t.x)) : 0, d = t.y < s.y ? Math.round(Math.abs(s.y - t.y)) : 0, f = Math.max(c.width, Math.round(t.width)), p = Math.max(c.height, Math.round(t.height)), m = (f - c.width) * l[0], h = (p - c.height) * l[1];
		(u > 0 || d > 0 || m || h) && (i.push({
			id: o,
			type: "position",
			position: {
				x: a.position.x - u + m,
				y: a.position.y - d + h
			}
		}), n.get(o)?.forEach((t) => {
			e.some((e) => e.id === t.id) || i.push({
				id: t.id,
				type: "position",
				position: {
					x: t.position.x + u,
					y: t.position.y + d
				}
			});
		})), (c.width < t.width || c.height < t.height || u || d) && i.push({
			id: o,
			type: "dimensions",
			setAttributes: !0,
			dimensions: {
				width: f + (u ? l[0] * u - m : 0),
				height: p + (d ? l[1] * d - h : 0)
			}
		});
	}), i;
}
function it(e, t, n, r, i, a, o) {
	let s = r?.querySelector(".xyflow__viewport"), c = !1;
	if (!s) return {
		changes: [],
		updatedInternals: c
	};
	let l = [], u = window.getComputedStyle(s), { m22: d } = new window.DOMMatrixReadOnly(u.transform), f = [];
	for (let r of e.values()) {
		let e = t.get(r.id);
		if (!e) continue;
		if (e.hidden) {
			t.set(e.id, {
				...e,
				internals: {
					...e.internals,
					handleBounds: void 0
				}
			}), c = !0;
			continue;
		}
		let s = he(r.nodeElement), u = e.measured.width !== s.width || e.measured.height !== s.height;
		if (s.width && s.height && (u || !e.internals.handleBounds || r.force)) {
			let p = r.nodeElement.getBoundingClientRect(), m = q(e.extent) ? e.extent : a, { positionAbsolute: h } = e.internals;
			e.parentId && e.extent === "parent" ? h = F(h, s, t.get(e.parentId)) : m && (h = P(h, m, s));
			let g = {
				...e,
				measured: s,
				internals: {
					...e.internals,
					positionAbsolute: h,
					handleBounds: {
						source: be("source", r.nodeElement, p, d, e.id),
						target: be("target", r.nodeElement, p, d, e.id)
					}
				}
			};
			t.set(e.id, g), e.parentId && et(g, t, n, {
				nodeOrigin: i,
				zIndexMode: o
			}), c = !0, u && (l.push({
				id: e.id,
				type: "dimensions",
				dimensions: s
			}), e.expandParent && e.parentId && f.push({
				id: e.id,
				parentId: e.parentId,
				rect: z(g, i)
			}));
		}
	}
	if (f.length > 0) {
		let e = rt(f, t, n, i);
		l.push(...e);
	}
	return {
		changes: l,
		updatedInternals: c
	};
}
async function at({ delta: e, panZoom: t, transform: n, translateExtent: r, width: i, height: a }) {
	if (!t || !e.x && !e.y) return Promise.resolve(!1);
	let o = await t.setViewportConstrained({
		x: n[0] + e.x,
		y: n[1] + e.y,
		zoom: n[2]
	}, [[0, 0], [i, a]], r), s = !!o && (o.x !== n[0] || o.y !== n[1] || o.k !== n[2]);
	return Promise.resolve(s);
}
function ot(e, t, n, r, i, a) {
	let o = i, s = r.get(o) || /* @__PURE__ */ new Map();
	r.set(o, s.set(n, t)), o = `${i}-${e}`;
	let c = r.get(o) || /* @__PURE__ */ new Map();
	if (r.set(o, c.set(n, t)), a) {
		o = `${i}-${e}-${a}`;
		let s = r.get(o) || /* @__PURE__ */ new Map();
		r.set(o, s.set(n, t));
	}
}
function st(e, t, n) {
	e.clear(), t.clear();
	for (let r of n) {
		let { source: n, target: i, sourceHandle: a = null, targetHandle: o = null } = r, s = {
			edgeId: r.id,
			source: n,
			target: i,
			sourceHandle: a,
			targetHandle: o
		}, c = `${n}-${a}--${i}-${o}`;
		ot("source", s, `${i}-${o}--${n}-${a}`, e, n, a), ot("target", s, c, e, i, o), t.set(r.id, r);
	}
}
function ct(e, t) {
	if (!e.parentId) return !1;
	let n = t.get(e.parentId);
	return n ? n.selected ? !0 : ct(n, t) : !1;
}
function lt(e, t, n) {
	let r = e;
	do {
		if (r?.matches?.(t)) return !0;
		if (r === n) return !1;
		r = r?.parentElement;
	} while (r);
	return !1;
}
function ut(e, t, n, r) {
	let i = /* @__PURE__ */ new Map();
	for (let [a, o] of e) if ((o.selected || o.id === r) && (!o.parentId || !ct(o, e)) && (o.draggable || t && o.draggable === void 0)) {
		let t = e.get(a);
		t && i.set(a, {
			id: a,
			position: t.position || {
				x: 0,
				y: 0
			},
			distance: {
				x: n.x - t.internals.positionAbsolute.x,
				y: n.y - t.internals.positionAbsolute.y
			},
			extent: t.extent,
			parentId: t.parentId,
			origin: t.origin,
			expandParent: t.expandParent,
			internals: { positionAbsolute: t.internals.positionAbsolute || {
				x: 0,
				y: 0
			} },
			measured: {
				width: t.measured.width ?? 0,
				height: t.measured.height ?? 0
			}
		});
	}
	return i;
}
function dt({ nodeId: e, dragItems: t, nodeLookup: n, dragging: r = !0 }) {
	let i = [];
	for (let [e, a] of t) {
		let t = n.get(e)?.internals.userNode;
		t && i.push({
			...t,
			position: a.position,
			dragging: r
		});
	}
	if (!e) return [i[0], i];
	let a = n.get(e)?.internals.userNode;
	return [a ? {
		...a,
		position: t.get(e)?.position || a.position,
		dragging: r
	} : i[0], i];
}
function ft({ dragItems: e, snapGrid: t, x: n, y: r }) {
	let i = e.values().next().value;
	if (!i) return null;
	let a = {
		x: n - i.distance.x,
		y: r - i.distance.y
	}, o = G(a, t);
	return {
		x: o.x - a.x,
		y: o.y - a.y
	};
}
function pt({ onNodeMouseDown: t, getStoreItems: r, onDragStart: i, onDrag: a, onDragStop: o }) {
	let s = {
		x: null,
		y: null
	}, c = 0, l = /* @__PURE__ */ new Map(), u = !1, d = {
		x: 0,
		y: 0
	}, f = null, p = !1, m = null, h = !1, g = !1, _ = null;
	function v({ noDragClassName: v, handleSelector: y, domNode: b, isSelectable: x, nodeId: S, nodeClickDistance: C = 0 }) {
		m = e(b);
		function w({ x: e, y: t }) {
			let { nodeLookup: n, nodeExtent: i, snapGrid: o, snapToGrid: c, nodeOrigin: u, onNodeDrag: d, onSelectionDrag: f, onError: p, updateNodePositions: m } = r();
			s = {
				x: e,
				y: t
			};
			let h = !1, v = l.size > 1, y = v && i ? L(E(l)) : null, b = v && c ? ft({
				dragItems: l,
				snapGrid: o,
				x: e,
				y: t
			}) : null;
			for (let [r, a] of l) {
				if (!n.has(r)) continue;
				let s = {
					x: e - a.distance.x,
					y: t - a.distance.y
				};
				c && (s = b ? {
					x: Math.round(s.x + b.x),
					y: Math.round(s.y + b.y)
				} : G(s, o));
				let l = null;
				if (v && i && !a.extent && y) {
					let { positionAbsolute: e } = a.internals, t = e.x - y.x + i[0][0], n = e.x + a.measured.width - y.x2 + i[1][0], r = e.y - y.y + i[0][1], o = e.y + a.measured.height - y.y2 + i[1][1];
					l = [[t, r], [n, o]];
				}
				let { position: d, positionAbsolute: f } = j({
					nodeId: r,
					nextPosition: s,
					nodeLookup: n,
					nodeExtent: l || i,
					nodeOrigin: u,
					onError: p
				});
				h = h || a.position.x !== d.x || a.position.y !== d.y, a.position = d, a.internals.positionAbsolute = f;
			}
			if (g ||= h, h && (m(l, !0), _ && (a || d || !S && f))) {
				let [e, t] = dt({
					nodeId: S,
					dragItems: l,
					nodeLookup: n
				});
				a?.(_, l, e, t), d?.(_, e, t), S || f?.(_, t);
			}
		}
		async function T() {
			if (!f) return;
			let { transform: e, panBy: t, autoPanSpeed: n, autoPanOnNodeDrag: i } = r();
			if (!i) {
				u = !1, cancelAnimationFrame(c);
				return;
			}
			let [a, o] = ee(d, f, n);
			(a !== 0 || o !== 0) && (s.x = (s.x ?? 0) - a / e[2], s.y = (s.y ?? 0) - o / e[2], await t({
				x: a,
				y: o
			}) && w(s)), c = requestAnimationFrame(T);
		}
		function D(e) {
			let { nodeLookup: n, multiSelectionActive: a, nodesDraggable: o, transform: c, snapGrid: u, snapToGrid: d, selectNodesOnDrag: m, onNodeDragStart: h, onSelectionDragStart: g, unselectNodesAndEdges: _ } = r();
			p = !0, (!m || !x) && !a && S && (n.get(S)?.selected || _()), x && m && S && t?.(S);
			let v = me(e.sourceEvent, {
				transform: c,
				snapGrid: u,
				snapToGrid: d,
				containerBounds: f
			});
			if (s = v, l = ut(n, o, v, S), l.size > 0 && (i || h || !S && g)) {
				let [t, r] = dt({
					nodeId: S,
					dragItems: l,
					nodeLookup: n
				});
				i?.(e.sourceEvent, l, t, r), h?.(e.sourceEvent, t, r), S || g?.(e.sourceEvent, r);
			}
		}
		let O = n().clickDistance(C).on("start", (e) => {
			let { domNode: t, nodeDragThreshold: n, transform: i, snapGrid: a, snapToGrid: o } = r();
			f = t?.getBoundingClientRect() || null, h = !1, g = !1, _ = e.sourceEvent, n === 0 && D(e), s = me(e.sourceEvent, {
				transform: i,
				snapGrid: a,
				snapToGrid: o,
				containerBounds: f
			}), d = Y(e.sourceEvent, f);
		}).on("drag", (e) => {
			let { autoPanOnNodeDrag: t, transform: n, snapGrid: i, snapToGrid: a, nodeDragThreshold: o, nodeLookup: c } = r(), m = me(e.sourceEvent, {
				transform: n,
				snapGrid: i,
				snapToGrid: a,
				containerBounds: f
			});
			if (_ = e.sourceEvent, (e.sourceEvent.type === "touchmove" && e.sourceEvent.touches.length > 1 || S && !c.has(S)) && (h = !0), !h) {
				if (!u && t && p && (u = !0, T()), !p) {
					let t = Y(e.sourceEvent, f), n = t.x - d.x, r = t.y - d.y;
					Math.sqrt(n * n + r * r) > o && D(e);
				}
				(s.x !== m.xSnapped || s.y !== m.ySnapped) && l && p && (d = Y(e.sourceEvent, f), w(m));
			}
		}).on("end", (e) => {
			if (!(!p || h) && (u = !1, p = !1, cancelAnimationFrame(c), l.size > 0)) {
				let { nodeLookup: t, updateNodePositions: n, onNodeDragStop: i, onSelectionDragStop: a } = r();
				if (g &&= (n(l, !1), !1), o || i || !S && a) {
					let [n, r] = dt({
						nodeId: S,
						dragItems: l,
						nodeLookup: t,
						dragging: !1
					});
					o?.(e.sourceEvent, l, n, r), i?.(e.sourceEvent, n, r), S || a?.(e.sourceEvent, r);
				}
			}
		}).filter((e) => {
			let t = e.target;
			return !e.button && (!v || !lt(t, `.${v}`, b)) && (!y || lt(t, y, b));
		});
		m.call(O);
	}
	function y() {
		m?.on(".drag", null);
	}
	return {
		update: v,
		destroy: y
	};
}
function mt(e, t, n) {
	let r = [], i = {
		x: e.x - n,
		y: e.y - n,
		width: n * 2,
		height: n * 2
	};
	for (let e of t.values()) V(i, z(e)) > 0 && r.push(e);
	return r;
}
var ht = 250;
function gt(e, t, n, r) {
	let i = [], a = Infinity, o = mt(e, n, t + ht);
	for (let n of o) {
		let o = [...n.internals.handleBounds?.source ?? [], ...n.internals.handleBounds?.target ?? []];
		for (let s of o) {
			if (r.nodeId === s.nodeId && r.type === s.type && r.id === s.id) continue;
			let { x: o, y: c } = X(n, s, s.position, !0), l = Math.sqrt((o - e.x) ** 2 + (c - e.y) ** 2);
			l > t || (l < a ? (i = [{
				...s,
				x: o,
				y: c
			}], a = l) : l === a && i.push({
				...s,
				x: o,
				y: c
			}));
		}
	}
	if (!i.length) return null;
	if (i.length > 1) {
		let e = r.type === "source" ? "target" : "source";
		return i.find((t) => t.type === e) ?? i[0];
	}
	return i[0];
}
function _t(e, t, n, r, i, a = !1) {
	let o = r.get(e);
	if (!o) return null;
	let s = i === "strict" ? o.internals.handleBounds?.[t] : [...o.internals.handleBounds?.source ?? [], ...o.internals.handleBounds?.target ?? []], c = (n ? s?.find((e) => e.id === n) : s?.[0]) ?? null;
	return c && a ? {
		...c,
		...X(o, c, c.position, !0)
	} : c;
}
function vt(e, t) {
	return e || (t?.classList.contains("target") ? "target" : t?.classList.contains("source") ? "source" : null);
}
function yt(e, t) {
	let n = null;
	return t ? n = !0 : e && !t && (n = !1), n;
}
var bt = () => !0;
function xt(e, { connectionMode: t, connectionRadius: n, handleId: r, nodeId: i, edgeUpdaterType: a, isTarget: o, domNode: s, nodeLookup: c, lib: l, autoPanOnConnect: u, flowId: d, panBy: f, cancelConnection: p, onConnectStart: m, onConnect: h, onConnectEnd: g, isValidConnection: _ = bt, onReconnectEnd: b, updateConnection: x, getTransform: S, getFromHandle: C, autoPanSpeed: w, dragThreshold: T = 1, handleDomNode: E }) {
	let D = ge(e.target), O = 0, k, { x: A, y: j } = Y(e), M = vt(a, E), N = s?.getBoundingClientRect(), P = !1;
	if (!N || !M) return;
	let F = _t(i, M, r, c, t);
	if (!F) return;
	let I = Y(e, N), te = !1, L = null, R = !1, z = null;
	function ne() {
		if (!u || !N) return;
		let [e, t] = ee(I, N, w);
		f({
			x: e,
			y: t
		}), O = requestAnimationFrame(ne);
	}
	let B = {
		...F,
		nodeId: i,
		type: M,
		position: F.position
	}, V = c.get(i), H = {
		inProgress: !0,
		isValid: null,
		from: X(V, B, v.Left, !0),
		fromHandle: B,
		fromPosition: B.position,
		fromNode: V,
		to: I,
		toHandle: null,
		toPosition: y[B.position],
		toNode: null,
		pointer: I
	};
	function U() {
		P = !0, x(H), m?.(e, {
			nodeId: i,
			handleId: r,
			handleType: M
		});
	}
	T === 0 && U();
	function W(e) {
		if (!P) {
			let { x: t, y: n } = Y(e), r = t - A, i = n - j;
			if (!(r * r + i * i > T * T)) return;
			U();
		}
		if (!C() || !B) {
			G(e);
			return;
		}
		let a = S();
		I = Y(e, N), k = gt(re(I, a, !1, [1, 1]), n, c, B), te ||= (ne(), !0);
		let s = St(e, {
			handle: k,
			connectionMode: t,
			fromNodeId: i,
			fromHandleId: r,
			fromType: o ? "target" : "source",
			isValidConnection: _,
			doc: D,
			lib: l,
			flowId: d,
			nodeLookup: c
		});
		z = s.handleDomNode, L = s.connection, R = yt(!!k, s.isValid);
		let u = c.get(i), f = u ? X(u, B, v.Left, !0) : H.from, p = {
			...H,
			from: f,
			isValid: R,
			to: s.toHandle && R ? ie({
				x: s.toHandle.x,
				y: s.toHandle.y
			}, a) : I,
			toHandle: s.toHandle,
			toPosition: R && s.toHandle ? s.toHandle.position : y[B.position],
			toNode: s.toHandle ? c.get(s.toHandle.nodeId) : null,
			pointer: I
		};
		x(p), H = p;
	}
	function G(e) {
		if (!("touches" in e && e.touches.length > 0)) {
			if (P) {
				(k || z) && L && R && h?.(L);
				let { inProgress: t, ...n } = H, r = {
					...n,
					toPosition: H.toHandle ? H.toPosition : null
				};
				g?.(e, r), a && b?.(e, r);
			}
			p(), cancelAnimationFrame(O), te = !1, R = !1, L = null, z = null, D.removeEventListener("mousemove", W), D.removeEventListener("mouseup", G), D.removeEventListener("touchmove", W), D.removeEventListener("touchend", G);
		}
	}
	D.addEventListener("mousemove", W), D.addEventListener("mouseup", G), D.addEventListener("touchmove", W), D.addEventListener("touchend", G);
}
function St(e, { handle: t, connectionMode: n, fromNodeId: r, fromHandleId: i, fromType: a, doc: o, lib: s, flowId: c, isValidConnection: l = bt, nodeLookup: u }) {
	let d = a === "target", p = t ? o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`) : null, { x: m, y: h } = Y(e), g = o.elementFromPoint(m, h), _ = g?.classList.contains(`${s}-flow__handle`) ? g : p, v = {
		handleDomNode: _,
		isValid: !1,
		connection: null,
		toHandle: null
	};
	if (_) {
		let e = vt(void 0, _), t = _.getAttribute("data-nodeid"), a = _.getAttribute("data-handleid"), o = _.classList.contains("connectable"), s = _.classList.contains("connectableend");
		if (!t || !e) return v;
		let c = {
			source: d ? t : r,
			sourceHandle: d ? a : i,
			target: d ? r : t,
			targetHandle: d ? i : a
		};
		v.connection = c, v.isValid = o && s && (n === f.Strict ? d && e === "source" || !d && e === "target" : t !== r || a !== i) && l(c), v.toHandle = _t(t, e, a, u, n, !0);
	}
	return v;
}
var Ct = {
	onPointerDown: xt,
	isValid: St
};
function wt({ domNode: n, panZoom: r, getTransform: i, getViewScale: a }) {
	let o = e(n);
	function c({ translateExtent: e, width: t, height: n, zoomStep: c = 1, pannable: l = !0, zoomable: u = !0, inversePan: d = !1 }) {
		let f = (e) => {
			if (e.sourceEvent.type !== "wheel" || !r) return;
			let t = i(), n = e.sourceEvent.ctrlKey && ce() ? 10 : 1, a = -e.sourceEvent.deltaY * (e.sourceEvent.deltaMode === 1 ? .05 : e.sourceEvent.deltaMode ? 1 : .002) * c, o = t[2] * 2 ** (a * n);
			r.scaleTo(o);
		}, p = [0, 0], m = s().on("start", (e) => {
			(e.sourceEvent.type === "mousedown" || e.sourceEvent.type === "touchstart") && (p = [e.sourceEvent.clientX ?? e.sourceEvent.touches[0].clientX, e.sourceEvent.clientY ?? e.sourceEvent.touches[0].clientY]);
		}).on("zoom", l ? (o) => {
			let s = i();
			if (o.sourceEvent.type !== "mousemove" && o.sourceEvent.type !== "touchmove" || !r) return;
			let c = [o.sourceEvent.clientX ?? o.sourceEvent.touches[0].clientX, o.sourceEvent.clientY ?? o.sourceEvent.touches[0].clientY], l = [c[0] - p[0], c[1] - p[1]];
			p = c;
			let u = a() * Math.max(s[2], Math.log(s[2])) * (d ? -1 : 1), f = {
				x: s[0] - l[0] * u,
				y: s[1] - l[1] * u
			}, m = [[0, 0], [t, n]];
			r.setViewportConstrained({
				x: f.x,
				y: f.y,
				zoom: s[2]
			}, m, e);
		} : null).on("zoom.wheel", u ? f : null);
		o.call(m, {});
	}
	function l() {
		o.on("zoom", null);
	}
	return {
		update: c,
		destroy: l,
		pointer: t
	};
}
var Tt = (e) => ({
	x: e.x,
	y: e.y,
	zoom: e.k
}), Et = ({ x: e, y: t, zoom: n }) => o.translate(e, t).scale(n), Z = (e, t) => e.target.closest(`.${t}`), Dt = (e, t) => t === 2 && Array.isArray(e) && e.includes(2), Ot = (e) => ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2, kt = (e, t = 0, n = Ot, r = () => {}) => {
	let i = typeof t == "number" && t > 0;
	return i || r(), i ? e.transition().duration(t).ease(n).on("end", r) : e;
}, At = (e) => {
	let t = e.ctrlKey && ce() ? 10 : 1;
	return -e.deltaY * (e.deltaMode === 1 ? .05 : e.deltaMode ? 1 : .002) * t;
};
function jt({ zoomPanValues: e, noWheelClassName: n, d3Selection: r, d3Zoom: i, panOnScrollMode: a, panOnScrollSpeed: o, zoomOnPinch: s, onPanZoomStart: c, onPanZoom: l, onPanZoomEnd: u }) {
	return (d) => {
		if (Z(d, n)) return d.ctrlKey && d.preventDefault(), !1;
		d.preventDefault(), d.stopImmediatePropagation();
		let f = r.property("__zoom").k || 1;
		if (d.ctrlKey && s) {
			let e = t(d), n = f * 2 ** At(d);
			i.scaleTo(r, n, e, d);
			return;
		}
		let m = d.deltaMode === 1 ? 20 : 1, h = a === p.Vertical ? 0 : d.deltaX * m, g = a === p.Horizontal ? 0 : d.deltaY * m;
		!ce() && d.shiftKey && a !== p.Vertical && (h = d.deltaY * m, g = 0), i.translateBy(r, -(h / f) * o, -(g / f) * o, { internal: !0 });
		let _ = Tt(r.property("__zoom"));
		clearTimeout(e.panScrollTimeout), e.isPanScrolling ? (l?.(d, _), e.panScrollTimeout = setTimeout(() => {
			u?.(d, _), e.isPanScrolling = !1;
		}, 150)) : (e.isPanScrolling = !0, c?.(d, _));
	};
}
function Mt({ noWheelClassName: e, preventScrolling: t, d3ZoomHandler: n }) {
	return function(r, i) {
		let a = r.type === "wheel", o = !t && a && !r.ctrlKey, s = Z(r, e);
		if (r.ctrlKey && a && s && r.preventDefault(), o || s) return null;
		r.preventDefault(), n.call(this, r, i);
	};
}
function Nt({ zoomPanValues: e, onDraggingChange: t, onPanZoomStart: n }) {
	return (r) => {
		if (r.sourceEvent?.internal) return;
		let i = Tt(r.transform);
		e.mouseButton = r.sourceEvent?.button || 0, e.isZoomingOrPanning = !0, e.prevViewport = i, r.sourceEvent?.type === "mousedown" && t(!0), n && n?.(r.sourceEvent, i);
	};
}
function Pt({ zoomPanValues: e, panOnDrag: t, onPaneContextMenu: n, onTransformChange: r, onPanZoom: i }) {
	return (a) => {
		e.usedRightMouseButton = !!(n && Dt(t, e.mouseButton ?? 0)), a.sourceEvent?.sync || r([
			a.transform.x,
			a.transform.y,
			a.transform.k
		]), i && !a.sourceEvent?.internal && i?.(a.sourceEvent, Tt(a.transform));
	};
}
function Ft({ zoomPanValues: e, panOnDrag: t, panOnScroll: n, onDraggingChange: r, onPanZoomEnd: i, onPaneContextMenu: a }) {
	return (o) => {
		if (!o.sourceEvent?.internal && (e.isZoomingOrPanning = !1, a && Dt(t, e.mouseButton ?? 0) && !e.usedRightMouseButton && o.sourceEvent && a(o.sourceEvent), e.usedRightMouseButton = !1, r(!1), i)) {
			let t = Tt(o.transform);
			e.prevViewport = t, clearTimeout(e.timerId), e.timerId = setTimeout(() => {
				i?.(o.sourceEvent, t);
			}, n ? 150 : 0);
		}
	};
}
function It({ zoomActivationKeyPressed: e, zoomOnScroll: t, zoomOnPinch: n, panOnDrag: r, panOnScroll: i, zoomOnDoubleClick: a, userSelectionActive: o, noWheelClassName: s, noPanClassName: c, lib: l, connectionInProgress: u }) {
	return (d) => {
		let f = e || t, p = n && d.ctrlKey, m = d.type === "wheel";
		if (d.button === 1 && d.type === "mousedown" && (Z(d, `${l}-flow__node`) || Z(d, `${l}-flow__edge`))) return !0;
		if (!r && !f && !i && !a && !n || o || u && !m || Z(d, s) && m || Z(d, c) && (!m || i && m && !e) || !n && d.ctrlKey && m) return !1;
		if (!n && d.type === "touchstart" && d.touches?.length > 1) return d.preventDefault(), !1;
		if (!f && !i && !p && m || !r && (d.type === "mousedown" || d.type === "touchstart") || Array.isArray(r) && !r.includes(d.button) && d.type === "mousedown") return !1;
		let h = Array.isArray(r) && r.includes(d.button) || !d.button || d.button <= 1;
		return (!d.ctrlKey || m) && h;
	};
}
function Lt({ domNode: t, minZoom: n, maxZoom: o, translateExtent: c, viewport: l, onPanZoom: u, onPanZoomStart: d, onPanZoomEnd: f, onDraggingChange: p }) {
	let m = {
		isZoomingOrPanning: !1,
		usedRightMouseButton: !1,
		prevViewport: {
			x: 0,
			y: 0,
			zoom: 0
		},
		mouseButton: 0,
		timerId: void 0,
		panScrollTimeout: void 0,
		isPanScrolling: !1
	}, h = t.getBoundingClientRect(), g = s().scaleExtent([n, o]).translateExtent(c), _ = e(t).call(g);
	C({
		x: l.x,
		y: l.y,
		zoom: N(l.zoom, n, o)
	}, [[0, 0], [h.width, h.height]], c);
	let v = _.on("wheel.zoom"), y = _.on("dblclick.zoom");
	g.wheelDelta(At);
	function b(e, t) {
		return _ ? new Promise((n) => {
			g?.interpolate(t?.interpolate === "linear" ? r : i).transform(kt(_, t?.duration, t?.ease, () => n(!0)), e);
		}) : Promise.resolve(!1);
	}
	function x({ noWheelClassName: e, noPanClassName: t, onPaneContextMenu: n, userSelectionActive: r, panOnScroll: i, panOnDrag: a, panOnScrollMode: o, panOnScrollSpeed: s, preventScrolling: c, zoomOnPinch: l, zoomOnScroll: h, zoomOnDoubleClick: b, zoomActivationKeyPressed: x, lib: C, onTransformChange: w, connectionInProgress: T, paneClickDistance: E, selectionOnDrag: D }) {
		r && !m.isZoomingOrPanning && S();
		let O = i && !x && !r;
		g.clickDistance(D ? Infinity : !U(E) || E < 0 ? 0 : E);
		let k = O ? jt({
			zoomPanValues: m,
			noWheelClassName: e,
			d3Selection: _,
			d3Zoom: g,
			panOnScrollMode: o,
			panOnScrollSpeed: s,
			zoomOnPinch: l,
			onPanZoomStart: d,
			onPanZoom: u,
			onPanZoomEnd: f
		}) : Mt({
			noWheelClassName: e,
			preventScrolling: c,
			d3ZoomHandler: v
		});
		if (_.on("wheel.zoom", k, { passive: !1 }), !r) {
			let e = Nt({
				zoomPanValues: m,
				onDraggingChange: p,
				onPanZoomStart: d
			});
			g.on("start", e);
			let t = Pt({
				zoomPanValues: m,
				panOnDrag: a,
				onPaneContextMenu: !!n,
				onPanZoom: u,
				onTransformChange: w
			});
			g.on("zoom", t);
			let r = Ft({
				zoomPanValues: m,
				panOnDrag: a,
				panOnScroll: i,
				onPaneContextMenu: n,
				onPanZoomEnd: f,
				onDraggingChange: p
			});
			g.on("end", r);
		}
		let A = It({
			zoomActivationKeyPressed: x,
			panOnDrag: a,
			zoomOnScroll: h,
			panOnScroll: i,
			zoomOnDoubleClick: b,
			zoomOnPinch: l,
			userSelectionActive: r,
			noPanClassName: t,
			noWheelClassName: e,
			lib: C,
			connectionInProgress: T
		});
		g.filter(A), b ? _.on("dblclick.zoom", y) : _.on("dblclick.zoom", null);
	}
	function S() {
		g.on("zoom", null);
	}
	async function C(e, t, n) {
		let r = Et(e), i = g?.constrain()(r, t, n);
		return i && await b(i), new Promise((e) => e(i));
	}
	async function w(e, t) {
		let n = Et(e);
		return await b(n, t), new Promise((e) => e(n));
	}
	function T(e) {
		if (_) {
			let t = Et(e), n = _.property("__zoom");
			(n.k !== e.zoom || n.x !== e.x || n.y !== e.y) && g?.transform(_, t, null, { sync: !0 });
		}
	}
	function E() {
		let e = _ ? a(_.node()) : {
			x: 0,
			y: 0,
			k: 1
		};
		return {
			x: e.x,
			y: e.y,
			zoom: e.k
		};
	}
	function D(e, t) {
		return _ ? new Promise((n) => {
			g?.interpolate(t?.interpolate === "linear" ? r : i).scaleTo(kt(_, t?.duration, t?.ease, () => n(!0)), e);
		}) : Promise.resolve(!1);
	}
	function O(e, t) {
		return _ ? new Promise((n) => {
			g?.interpolate(t?.interpolate === "linear" ? r : i).scaleBy(kt(_, t?.duration, t?.ease, () => n(!0)), e);
		}) : Promise.resolve(!1);
	}
	function k(e) {
		g?.scaleExtent(e);
	}
	function A(e) {
		g?.translateExtent(e);
	}
	function j(e) {
		let t = !U(e) || e < 0 ? 0 : e;
		g?.clickDistance(t);
	}
	return {
		update: x,
		destroy: S,
		setViewport: w,
		setViewportConstrained: C,
		getViewport: E,
		scaleTo: D,
		scaleBy: O,
		setScaleExtent: k,
		setTranslateExtent: A,
		syncViewport: T,
		setClickDistance: j
	};
}
var Rt;
(function(e) {
	e.Line = "line", e.Handle = "handle";
})(Rt ||= {});
function zt({ width: e, prevWidth: t, height: n, prevHeight: r, affectsX: i, affectsY: a }) {
	let o = e - t, s = n - r, c = [o > 0 ? 1 : o < 0 ? -1 : 0, s > 0 ? 1 : s < 0 ? -1 : 0];
	return o && i && (c[0] *= -1), s && a && (c[1] *= -1), c;
}
function Bt(e) {
	return {
		isHorizontal: e.includes("right") || e.includes("left"),
		isVertical: e.includes("bottom") || e.includes("top"),
		affectsX: e.includes("left"),
		affectsY: e.includes("top")
	};
}
function Q(e, t) {
	return Math.max(0, t - e);
}
function $(e, t) {
	return Math.max(0, e - t);
}
function Vt(e, t, n) {
	return Math.max(0, t - e, e - n);
}
function Ht(e, t) {
	return e ? !t : t;
}
function Ut(e, t, n, r, i, a, o, s) {
	let { affectsX: c, affectsY: l } = t, { isHorizontal: u, isVertical: d } = t, f = u && d, { xSnapped: p, ySnapped: m } = n, { minWidth: h, maxWidth: g, minHeight: _, maxHeight: v } = r, { x: y, y: b, width: x, height: S, aspectRatio: C } = e, w = Math.floor(u ? p - e.pointerX : 0), T = Math.floor(d ? m - e.pointerY : 0), E = x + (c ? -w : w), D = S + (l ? -T : T), O = -a[0] * x, k = -a[1] * S, A = Vt(E, h, g), j = Vt(D, _, v);
	if (o) {
		let e = 0, t = 0;
		c && w < 0 ? e = Q(y + w + O, o[0][0]) : !c && w > 0 && (e = $(y + E + O, o[1][0])), l && T < 0 ? t = Q(b + T + k, o[0][1]) : !l && T > 0 && (t = $(b + D + k, o[1][1])), A = Math.max(A, e), j = Math.max(j, t);
	}
	if (s) {
		let e = 0, t = 0;
		c && w > 0 ? e = $(y + w, s[0][0]) : !c && w < 0 && (e = Q(y + E, s[1][0])), l && T > 0 ? t = $(b + T, s[0][1]) : !l && T < 0 && (t = Q(b + D, s[1][1])), A = Math.max(A, e), j = Math.max(j, t);
	}
	if (i) {
		if (u) {
			let e = Vt(E / C, _, v) * C;
			if (A = Math.max(A, e), o) {
				let e = 0;
				e = !c && !l || c && !l && f ? $(b + k + E / C, o[1][1]) * C : Q(b + k + (c ? w : -w) / C, o[0][1]) * C, A = Math.max(A, e);
			}
			if (s) {
				let e = 0;
				e = !c && !l || c && !l && f ? Q(b + E / C, s[1][1]) * C : $(b + (c ? w : -w) / C, s[0][1]) * C, A = Math.max(A, e);
			}
		}
		if (d) {
			let e = Vt(D * C, h, g) / C;
			if (j = Math.max(j, e), o) {
				let e = 0;
				e = !c && !l || l && !c && f ? $(y + D * C + O, o[1][0]) / C : Q(y + (l ? T : -T) * C + O, o[0][0]) / C, j = Math.max(j, e);
			}
			if (s) {
				let e = 0;
				e = !c && !l || l && !c && f ? Q(y + D * C, s[1][0]) / C : $(y + (l ? T : -T) * C, s[0][0]) / C, j = Math.max(j, e);
			}
		}
	}
	T += T < 0 ? j : -j, w += w < 0 ? A : -A, i && (f ? E > D * C ? T = (Ht(c, l) ? -w : w) / C : w = (Ht(c, l) ? -T : T) * C : u ? (T = w / C, l = c) : (w = T * C, c = l));
	let M = c ? y + w : y, N = l ? b + T : b;
	return {
		width: x + (c ? -w : w),
		height: S + (l ? -T : T),
		x: a[0] * w * (c ? -1 : 1) + M,
		y: a[1] * T * (l ? -1 : 1) + N
	};
}
var Wt = {
	width: 0,
	height: 0,
	x: 0,
	y: 0
}, Gt = {
	...Wt,
	pointerX: 0,
	pointerY: 0,
	aspectRatio: 1
};
function Kt(e) {
	return [[0, 0], [e.measured.width, e.measured.height]];
}
function qt(e, t, n) {
	let r = t.position.x + e.position.x, i = t.position.y + e.position.y, a = e.measured.width ?? 0, o = e.measured.height ?? 0, s = n[0] * a, c = n[1] * o;
	return [[r - s, i - c], [r + a - s, i + o - c]];
}
function Jt({ domNode: t, nodeId: r, getStoreItems: i, onChange: a, onEnd: o }) {
	let s = e(t), c = {
		controlDirection: Bt("bottom-right"),
		boundaries: {
			minWidth: 0,
			minHeight: 0,
			maxWidth: Number.MAX_VALUE,
			maxHeight: Number.MAX_VALUE
		},
		resizeDirection: void 0,
		keepAspectRatio: !1
	};
	function l({ controlPosition: e, boundaries: t, keepAspectRatio: l, resizeDirection: u, onResizeStart: d, onResize: f, onResizeEnd: p, shouldResize: m }) {
		let h = { ...Wt }, g = { ...Gt };
		c = {
			boundaries: t,
			resizeDirection: u,
			keepAspectRatio: l,
			controlDirection: Bt(e)
		};
		let _, v = null, y = [], b, x, S, C = !1, w = n().on("start", (e) => {
			let { nodeLookup: t, transform: n, snapGrid: a, snapToGrid: o, nodeOrigin: s, paneDomNode: c } = i();
			if (_ = t.get(r), !_) return;
			v = c?.getBoundingClientRect() ?? null;
			let { xSnapped: l, ySnapped: u } = me(e.sourceEvent, {
				transform: n,
				snapGrid: a,
				snapToGrid: o,
				containerBounds: v
			});
			h = {
				width: _.measured.width ?? 0,
				height: _.measured.height ?? 0,
				x: _.position.x ?? 0,
				y: _.position.y ?? 0
			}, g = {
				...h,
				pointerX: l,
				pointerY: u,
				aspectRatio: h.width / h.height
			}, b = void 0, _.parentId && (_.extent === "parent" || _.expandParent) && (b = t.get(_.parentId), x = b && _.extent === "parent" ? Kt(b) : void 0), y = [], S = void 0;
			for (let [e, n] of t) if (n.parentId === r && (y.push({
				id: e,
				position: { ...n.position },
				extent: n.extent
			}), n.extent === "parent" || n.expandParent)) {
				let e = qt(n, _, n.origin ?? s);
				S = S ? [[Math.min(e[0][0], S[0][0]), Math.min(e[0][1], S[0][1])], [Math.max(e[1][0], S[1][0]), Math.max(e[1][1], S[1][1])]] : e;
			}
			d?.(e, { ...h });
		}).on("drag", (e) => {
			let { transform: t, snapGrid: n, snapToGrid: r, nodeOrigin: o } = i(), s = me(e.sourceEvent, {
				transform: t,
				snapGrid: n,
				snapToGrid: r,
				containerBounds: v
			}), l = [];
			if (!_) return;
			let { x: u, y: d, width: p, height: w } = h, T = {}, E = _.origin ?? o, { width: D, height: O, x: k, y: A } = Ut(g, c.controlDirection, s, c.boundaries, c.keepAspectRatio, E, x, S), j = D !== p, M = O !== w, N = k !== u && j, P = A !== d && M;
			if (!N && !P && !j && !M) return;
			if ((N || P || E[0] === 1 || E[1] === 1) && (T.x = N ? k : h.x, T.y = P ? A : h.y, h.x = T.x, h.y = T.y, y.length > 0)) {
				let e = k - u, t = A - d;
				for (let n of y) n.position = {
					x: n.position.x - e + E[0] * (D - p),
					y: n.position.y - t + E[1] * (O - w)
				}, l.push(n);
			}
			if ((j || M) && (T.width = j && (!c.resizeDirection || c.resizeDirection === "horizontal") ? D : h.width, T.height = M && (!c.resizeDirection || c.resizeDirection === "vertical") ? O : h.height, h.width = T.width, h.height = T.height), b && _.expandParent) {
				let e = E[0] * (T.width ?? 0);
				T.x && T.x < e && (h.x = e, g.x -= T.x - e);
				let t = E[1] * (T.height ?? 0);
				T.y && T.y < t && (h.y = t, g.y -= T.y - t);
			}
			let F = zt({
				width: h.width,
				prevWidth: p,
				height: h.height,
				prevHeight: w,
				affectsX: c.controlDirection.affectsX,
				affectsY: c.controlDirection.affectsY
			}), I = {
				...h,
				direction: F
			};
			m?.(e, I) !== !1 && (C = !0, f?.(e, I), a(T, l));
		}).on("end", (e) => {
			C &&= (p?.(e, { ...h }), o?.({ ...h }), !1);
		});
		s.call(w);
	}
	function u() {
		s.on(".drag", null);
	}
	return {
		update: l,
		destroy: u
	};
}
//#endregion
export { g as ConnectionLineType, f as ConnectionMode, _ as MarkerType, p as PanOnScrollMode, v as Position, Rt as ResizeControlVariant, m as SelectionMode, pt as XYDrag, Ct as XYHandle, wt as XYMinimap, Lt as XYPanZoom, Jt as XYResizer, Ae as addEdge, Qe as adoptUserNodes, de as areSetsEqual, j as calculateNodePosition, Ue as createMarkerIds, d as defaultAriaLabelConfig, W as devWarn, u as elementSelectionKeys, c as errorMessages, ue as evaluateAbsolutePosition, A as fitViewport, xe as getBezierEdgeCenter, we as getBezierPath, B as getBoundsOfRects, O as getConnectedEdges, b as getConnectionStatus, he as getDimensions, Te as getEdgeCenter, ze as getEdgePosition, M as getElementsToRemove, Ee as getElevatedEdgeZIndex, Y as getEventPosition, X as getHandlePosition, ge as getHostForElement, E as getInternalNodesBounds, He as getMarkerId, J as getNodeDimensions, T as getNodesBounds, D as getNodesInside, V as getOverlappingArea, Le as getSmoothStepPath, je as getStraightPath, se as getViewportForBounds, rt as handleExpandParent, l as infiniteExtent, h as initialConnection, x as isEdgeBase, De as isEdgeVisible, ve as isInputDOMNode, ce as isMacOs, ye as isMouseEvent, S as isNodeBase, U as isNumeric, H as isRectObject, pe as mergeAriaLabelConfig, le as nodeHasDimensions, z as nodeToRect, at as panBy, re as pointToRendererPoint, ie as rendererPointToPoint, G as snapPosition, Ye as updateAbsolutePositions, st as updateConnectionLookup, it as updateNodeInternals, fe as withResolvers };
