import { NetworkGraph as e } from "../../visualization/network-graph/index.js";
import { t } from "../../utils-B7XIe3qq.js";
import { useEffect as n, useRef as r } from "react";
import { jsx as i } from "react/jsx-runtime";
//#region src/react/primitives/network-graph.tsx
function a({ nodes: a, edges: o, layout: s = "force", zoomable: c = !0, pannable: l = !0, nodeRadius: u, showLabels: d = !0, onNodeClick: f, onEdgeClick: p, className: m }) {
	let h = r(null), g = r(null), _ = r(f);
	_.current = f;
	let v = r(p);
	return v.current = p, n(() => {
		let t = h.current;
		if (!t) return;
		let n = {
			container: t,
			nodes: a,
			edges: o,
			layout: s,
			zoomable: c,
			pannable: l,
			showLabels: d,
			onNodeClick: (e) => _.current?.(e),
			onEdgeClick: (e) => v.current?.(e)
		};
		return u !== void 0 && (n.nodeRadius = u), g.current = new e(n), () => {
			g.current?.destroy(), g.current = null;
		};
	}, [
		c,
		l,
		u,
		d
	]), n(() => {
		g.current && g.current.update(a, o);
	}, [a, o]), n(() => {
		g.current && g.current.setLayout(s);
	}, [s]), /* @__PURE__ */ i("div", {
		ref: h,
		"data-slot": "network-graph",
		className: t("relative h-full w-full overflow-hidden", m)
	});
}
a.displayName = "NetworkGraph";
//#endregion
export { a as NetworkGraph };

//# sourceMappingURL=network-graph.js.map