@infinit-canvas/react 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { jsx as S, jsxs as It, Fragment as Le } from "react/jsx-runtime";
2
- import { useRef as V, useState as Gt, useMemo as St, useEffect as ft, useCallback as F, useContext as qe, createContext as Fn, memo as Zt, useLayoutEffect as kr } from "react";
1
+ import { jsx as S, jsxs as $t, Fragment as Le } from "react/jsx-runtime";
2
+ import { useRef as tt, useState as Gt, useMemo as St, useEffect as ht, useCallback as F, useContext as qe, createContext as Fn, memo as Zt, useLayoutEffect as kr } from "react";
3
3
  import { createPortal as Yn } from "react-dom";
4
4
  const Un = 160, qn = 60;
5
5
  function ho(t) {
@@ -63,8 +63,8 @@ function jn(t) {
63
63
  function xo(t, e, n = { x: 0, y: 0, zoom: 1 }, r = !1) {
64
64
  const s = e.x, o = e.y, i = e.x + e.width, c = e.y + e.height;
65
65
  return t.filter((u) => {
66
- const { width: l, height: y } = jn(u), m = u.position.x, C = u.position.y, k = m + l, M = C + y;
67
- return r ? m < i && k > s && C < c && M > o : m >= s && k <= i && C >= o && M <= c;
66
+ const { width: l, height: y } = jn(u), m = u.position.x, C = u.position.y, z = m + l, M = C + y;
67
+ return r ? m < i && z > s && C < c && M > o : m >= s && z <= i && C >= o && M <= c;
68
68
  });
69
69
  }
70
70
  function mo(t) {
@@ -964,42 +964,42 @@ function Lr({
964
964
  onNodeDrag: y,
965
965
  onNodeDragStop: m,
966
966
  onEdgeClick: C,
967
- onEdgeDoubleClick: k,
967
+ onEdgeDoubleClick: z,
968
968
  onEdgeMouseEnter: M,
969
969
  onEdgeMouseMove: $,
970
- onEdgeMouseLeave: z,
970
+ onEdgeMouseLeave: k,
971
971
  onEdgeContextMenu: E,
972
- onNodeDoubleClick: W,
973
- onNodeMouseEnter: H,
972
+ onNodeDoubleClick: _,
973
+ onNodeMouseEnter: D,
974
974
  onNodeMouseMove: g,
975
975
  onNodeMouseLeave: f,
976
976
  onNodeContextMenu: p,
977
977
  onPaneClick: v,
978
- onPaneContextMenu: w,
979
- onPaneMouseEnter: N,
978
+ onPaneContextMenu: N,
979
+ onPaneMouseEnter: w,
980
980
  onPaneMouseMove: P,
981
981
  onPaneMouseLeave: R,
982
982
  onSelectionChange: B,
983
983
  onConnectStart: q,
984
- onConnectEnd: D,
985
- onInit: it,
986
- onMoveStart: nt,
987
- onMove: lt,
984
+ onConnectEnd: X,
985
+ onInit: K,
986
+ onMoveStart: at,
987
+ onMove: rt,
988
988
  onMoveEnd: G,
989
989
  onDelete: j,
990
- onBeforeDelete: st,
991
- onError: rt,
992
- isValidConnection: ut,
993
- dark: dt,
994
- gridSize: Lt = 40,
995
- zoomMin: ot = 0.1,
996
- zoomMax: pt = 4,
997
- initialCamera: vt = { x: 0, y: 0, zoom: 1 },
998
- fitView: ht = !1,
999
- fitViewOptions: bt,
1000
- nodesDraggable: Et = !0,
1001
- nodesConnectable: kt = !0,
1002
- elementsSelectable: $t = !0,
990
+ onBeforeDelete: it,
991
+ onError: dt,
992
+ isValidConnection: ot,
993
+ dark: ft,
994
+ gridSize: It = 40,
995
+ zoomMin: st = 0.1,
996
+ zoomMax: xt = 4,
997
+ initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
998
+ fitView: gt = !1,
999
+ fitViewOptions: ct,
1000
+ nodesDraggable: zt = !0,
1001
+ nodesConnectable: Rt = !0,
1002
+ elementsSelectable: Lt = !0,
1003
1003
  multiSelectionKeyCode: wt = "Shift",
1004
1004
  selectionOnDrag: ne = !1,
1005
1005
  selectionMode: Ie = "partial",
@@ -1027,7 +1027,7 @@ function Lr({
1027
1027
  elevateNodesOnSelect: hn = !1,
1028
1028
  edgeRouting: fe = !0
1029
1029
  } = {}) {
1030
- const xt = V(null), Te = V(null), Ct = V(null), gt = V({ ...vt }), se = V([...t]), Z = V([...e]), Pt = V([...n]), yn = V(/* @__PURE__ */ new Map()), Se = V(!1), te = V(null), [gn, pn] = Gt(!1), _t = V(null), Wt = V(null), Me = V(null), ie = V(null), Ut = V(!1), Re = V(null), [Be, Je] = Gt({ x: vt.x, y: vt.y, zoom: vt.zoom }), [Ve, ae] = Gt(null), Kt = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = V(!1), O = V({});
1030
+ const mt = tt(null), Te = tt(null), Et = tt(null), pt = tt({ ...Nt }), se = tt([...t]), Z = tt([...e]), Pt = tt([...n]), yn = tt(/* @__PURE__ */ new Map()), Se = tt(!1), te = tt(null), [gn, pn] = Gt(!1), _t = tt(null), Wt = tt(null), Me = tt(null), ie = tt(null), Ut = tt(!1), Re = tt(null), [Be, Je] = Gt({ x: Nt.x, y: Nt.y, zoom: Nt.zoom }), [Ve, ae] = Gt(null), Kt = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = tt(!1), O = tt({});
1031
1031
  O.current = {
1032
1032
  onHudUpdate: r,
1033
1033
  onNodesProcessed: s,
@@ -1039,34 +1039,34 @@ function Lr({
1039
1039
  onNodeDrag: y,
1040
1040
  onNodeDragStop: m,
1041
1041
  onEdgeClick: C,
1042
- onEdgeDoubleClick: k,
1042
+ onEdgeDoubleClick: z,
1043
1043
  onEdgeMouseEnter: M,
1044
1044
  onEdgeMouseMove: $,
1045
- onEdgeMouseLeave: z,
1045
+ onEdgeMouseLeave: k,
1046
1046
  onEdgeContextMenu: E,
1047
- onNodeDoubleClick: W,
1048
- onNodeMouseEnter: H,
1047
+ onNodeDoubleClick: _,
1048
+ onNodeMouseEnter: D,
1049
1049
  onNodeMouseMove: g,
1050
1050
  onNodeMouseLeave: f,
1051
1051
  onNodeContextMenu: p,
1052
1052
  onPaneClick: v,
1053
- onPaneContextMenu: w,
1054
- onPaneMouseEnter: N,
1053
+ onPaneContextMenu: N,
1054
+ onPaneMouseEnter: w,
1055
1055
  onPaneMouseMove: P,
1056
1056
  onPaneMouseLeave: R,
1057
1057
  onSelectionChange: B,
1058
1058
  onConnectStart: q,
1059
- onConnectEnd: D,
1060
- onInit: it,
1061
- onMoveStart: nt,
1062
- onMove: lt,
1059
+ onConnectEnd: X,
1060
+ onInit: K,
1061
+ onMoveStart: at,
1062
+ onMove: rt,
1063
1063
  onMoveEnd: G,
1064
1064
  onDelete: j,
1065
- onBeforeDelete: st,
1066
- onError: rt,
1067
- isValidConnection: ut
1065
+ onBeforeDelete: it,
1066
+ onError: dt,
1067
+ isValidConnection: ot
1068
1068
  };
1069
- const Mt = { get current() {
1069
+ const bt = { get current() {
1070
1070
  return O.current.onNodesChange;
1071
1071
  } }, Dt = { get current() {
1072
1072
  return O.current.onEdgesChange;
@@ -1074,9 +1074,9 @@ function Lr({
1074
1074
  return O.current.onConnect;
1075
1075
  } }, De = { get current() {
1076
1076
  return O.current.onNodeClick;
1077
- } }, He = { get current() {
1078
- return O.current.onNodeDragStart;
1079
1077
  } }, Ae = { get current() {
1078
+ return O.current.onNodeDragStart;
1079
+ } }, He = { get current() {
1080
1080
  return O.current.onNodeDrag;
1081
1081
  } }, _e = { get current() {
1082
1082
  return O.current.onNodeDragStop;
@@ -1091,7 +1091,7 @@ function Lr({
1091
1091
  } }, pe = { get current() {
1092
1092
  return O.current.onNodesProcessed;
1093
1093
  } };
1094
- ft(() => {
1094
+ ht(() => {
1095
1095
  const a = (d) => {
1096
1096
  d.key === wt && (Ut.current = !0), d.key === we && (ke.current = !0);
1097
1097
  }, x = (d) => {
@@ -1107,9 +1107,9 @@ function Lr({
1107
1107
  (b = ye.current) == null || b.call(ye, d);
1108
1108
  for (const L of he) L(d);
1109
1109
  }, [he]);
1110
- ft(() => {
1110
+ ht(() => {
1111
1111
  var a;
1112
- se.current = [...t], (a = Ct.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
1112
+ se.current = [...t], (a = Et.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
1113
1113
  }, [t]);
1114
1114
  const ze = F((a) => {
1115
1115
  const x = {};
@@ -1123,7 +1123,7 @@ function Lr({
1123
1123
  L += h.position.x, I += h.position.y, h = h.parentId ? x[h.parentId] : null;
1124
1124
  return { ...d, _absolutePosition: { x: L, y: I } };
1125
1125
  });
1126
- }, []), ee = V([]), Q = F((a) => {
1126
+ }, []), ee = tt([]), Q = F((a) => {
1127
1127
  const x = yn.current;
1128
1128
  if (!x || x.size === 0) return a;
1129
1129
  const d = {};
@@ -1137,9 +1137,9 @@ function Lr({
1137
1137
  var x;
1138
1138
  if (_t.current) return;
1139
1139
  const a = Q(ee.current);
1140
- (x = Ct.current) == null || x.postMessage({ type: "nodes", data: { nodes: a } });
1140
+ (x = Et.current) == null || x.postMessage({ type: "nodes", data: { nodes: a } });
1141
1141
  }, [Q]);
1142
- ft(() => {
1142
+ ht(() => {
1143
1143
  var d;
1144
1144
  if (_t.current) {
1145
1145
  const b = _t.current.id, L = /* @__PURE__ */ new Set([b, ..._t.current.selectedStarts.map((h) => h.id)]), I = {};
@@ -1155,15 +1155,15 @@ function Lr({
1155
1155
  const a = ze(e);
1156
1156
  ee.current = a;
1157
1157
  const x = Q(a);
1158
- (d = Ct.current) == null || d.postMessage({ type: "nodes", data: { nodes: x } });
1159
- }, [e, ze, Q]), ft(() => {
1158
+ (d = Et.current) == null || d.postMessage({ type: "nodes", data: { nodes: x } });
1159
+ }, [e, ze, Q]), ht(() => {
1160
1160
  var a;
1161
- Pt.current = [...n], (a = Ct.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
1161
+ Pt.current = [...n], (a = Et.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
1162
1162
  }, [n]);
1163
- const at = F((a, x) => {
1164
- const d = xt.current;
1163
+ const lt = F((a, x) => {
1164
+ const d = mt.current;
1165
1165
  if (!d) return { x: 0, y: 0 };
1166
- const b = d.getBoundingClientRect(), L = gt.current;
1166
+ const b = d.getBoundingClientRect(), L = pt.current;
1167
1167
  return {
1168
1168
  x: (a - b.left - L.x) / L.zoom,
1169
1169
  y: (x - b.top - L.y) / L.zoom
@@ -1210,7 +1210,7 @@ function Lr({
1210
1210
  { id: null, type: "source", x: a.position.x + x, y: a.position.y + d / 2 }
1211
1211
  ];
1212
1212
  }, [xe]), tn = F((a, x) => {
1213
- const d = Z.current, b = gt.current, L = Math.max(Nr, Ot) / b.zoom;
1213
+ const d = Z.current, b = pt.current, L = Math.max(Nr, Ot) / b.zoom;
1214
1214
  for (let I = d.length - 1; I >= 0; I--) {
1215
1215
  const h = d[I];
1216
1216
  if (h.hidden) continue;
@@ -1221,62 +1221,62 @@ function Lr({
1221
1221
  }
1222
1222
  return null;
1223
1223
  }, [Ee]), ue = F((a, x) => {
1224
- const b = 8 / gt.current.zoom;
1224
+ const b = 8 / pt.current.zoom;
1225
1225
  for (let L = Pt.current.length - 1; L >= 0; L--) {
1226
- const I = Pt.current[L], h = Z.current.find((Rt) => Rt.id === I.source), A = Z.current.find((Rt) => Rt.id === I.target);
1226
+ const I = Pt.current[L], h = Z.current.find((Mt) => Mt.id === I.source), A = Z.current.find((Mt) => Mt.id === I.target);
1227
1227
  if (!h || !A) continue;
1228
- const T = h.width || Vt, Y = h.height || jt, _ = A.height || jt, K = h.position.x + T, ct = h.position.y + Y / 2, U = A.position.x, et = A.position.y + _ / 2;
1229
- if (Ir(a, x, K, ct, U, et) < b) return I;
1228
+ const T = h.width || Vt, Y = h.height || jt, H = A.height || jt, J = h.position.x + T, ut = h.position.y + Y / 2, U = A.position.x, nt = A.position.y + H / 2;
1229
+ if (Ir(a, x, J, ut, U, nt) < b) return I;
1230
1230
  }
1231
1231
  return null;
1232
1232
  }, []);
1233
- ft(() => {
1234
- const a = Te.current, x = xt.current;
1233
+ ht(() => {
1234
+ const a = Te.current, x = mt.current;
1235
1235
  if (!a || !x) return;
1236
- const d = x.getBoundingClientRect(), b = dt !== void 0 ? dt : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
1236
+ const d = x.getBoundingClientRect(), b = ft !== void 0 ? ft : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
1237
1237
  ee.current = L;
1238
1238
  const I = Q(L), { worker: h } = Cr(a, {
1239
1239
  width: d.width,
1240
1240
  height: d.height,
1241
- camera: gt.current,
1241
+ camera: pt.current,
1242
1242
  cards: se.current,
1243
1243
  nodes: I,
1244
1244
  edges: Pt.current,
1245
1245
  dark: b,
1246
- gridSize: Lt,
1246
+ gridSize: It,
1247
1247
  edgeRouting: fe
1248
1248
  });
1249
- h.onmessage = (_) => {
1250
- var K, ct;
1251
- _.data.type === "hud" && ((K = ge.current) == null || K.call(ge, _.data.data)), _.data.type === "ready" && pn(!0), _.data.type === "nodesProcessed" && ((ct = pe.current) == null || ct.call(pe, _.data.data));
1252
- }, Ct.current = h;
1253
- const A = new ResizeObserver((_) => {
1254
- const { width: K, height: ct } = _[0].contentRect;
1255
- h.postMessage({ type: "resize", data: { width: K, height: ct } });
1249
+ h.onmessage = (H) => {
1250
+ var J, ut;
1251
+ H.data.type === "hud" && ((J = ge.current) == null || J.call(ge, H.data.data)), H.data.type === "ready" && pn(!0), H.data.type === "nodesProcessed" && ((ut = pe.current) == null || ut.call(pe, H.data.data));
1252
+ }, Et.current = h;
1253
+ const A = new ResizeObserver((H) => {
1254
+ const { width: J, height: ut } = H[0].contentRect;
1255
+ h.postMessage({ type: "resize", data: { width: J, height: ut } });
1256
1256
  });
1257
1257
  A.observe(x);
1258
1258
  let T, Y;
1259
- return dt === void 0 && (T = matchMedia("(prefers-color-scheme: dark)"), Y = (_) => h.postMessage({ type: "theme", data: { dark: _.matches } }), T.addEventListener("change", Y)), () => {
1260
- A.disconnect(), T && Y && T.removeEventListener("change", Y), Ct.current = null;
1259
+ return ft === void 0 && (T = matchMedia("(prefers-color-scheme: dark)"), Y = (H) => h.postMessage({ type: "theme", data: { dark: H.matches } }), T.addEventListener("change", Y)), () => {
1260
+ A.disconnect(), T && Y && T.removeEventListener("change", Y), Et.current = null;
1261
1261
  };
1262
- }, []), ft(() => {
1262
+ }, []), ht(() => {
1263
1263
  var a;
1264
- dt !== void 0 && ((a = Ct.current) == null || a.postMessage({ type: "theme", data: { dark: dt } }));
1265
- }, [dt]), ft(() => {
1264
+ ft !== void 0 && ((a = Et.current) == null || a.postMessage({ type: "theme", data: { dark: ft } }));
1265
+ }, [ft]), ht(() => {
1266
1266
  var a;
1267
- (a = Ct.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
1267
+ (a = Et.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
1268
1268
  }, [fe]);
1269
- const Ln = V(0), Nt = F((a = null) => {
1269
+ const Ln = tt(0), Ct = F((a = null) => {
1270
1270
  var b, L, I;
1271
- const x = gt.current;
1271
+ const x = pt.current;
1272
1272
  if (re) {
1273
- const h = xt.current;
1273
+ const h = mt.current;
1274
1274
  if (h) {
1275
- const A = h.getBoundingClientRect(), T = -re[1][0] * x.zoom + A.width, Y = -re[1][1] * x.zoom + A.height, _ = -re[0][0] * x.zoom, K = -re[0][1] * x.zoom;
1276
- x.x = Math.min(_, Math.max(T, x.x)), x.y = Math.min(K, Math.max(Y, x.y));
1275
+ const A = h.getBoundingClientRect(), T = -re[1][0] * x.zoom + A.width, Y = -re[1][1] * x.zoom + A.height, H = -re[0][0] * x.zoom, J = -re[0][1] * x.zoom;
1276
+ x.x = Math.min(H, Math.max(T, x.x)), x.y = Math.min(J, Math.max(Y, x.y));
1277
1277
  }
1278
1278
  }
1279
- (b = Ct.current) == null || b.postMessage({ type: "camera", data: { camera: { ...x } } });
1279
+ (b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...x } } });
1280
1280
  const d = { x: x.x, y: x.y, zoom: x.zoom };
1281
1281
  (I = (L = O.current).onMove) == null || I.call(L, a, d);
1282
1282
  for (const h of Kt) h(d);
@@ -1286,162 +1286,162 @@ function Lr({
1286
1286
  }, [Kt, re]), Ce = F(() => {
1287
1287
  var d, b;
1288
1288
  const a = Wt.current, x = Me.current;
1289
- a && x ? ((d = Ct.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: x, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((b = Ct.current) == null || b.postMessage({ type: "connecting", data: null }), ae(null));
1289
+ a && x ? ((d = Et.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: x, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((b = Et.current) == null || b.postMessage({ type: "connecting", data: null }), ae(null));
1290
1290
  }, []), Ne = F(() => {
1291
1291
  var x, d;
1292
1292
  const a = ie.current;
1293
- a ? (x = Ct.current) == null || x.postMessage({ type: "selectionBox", data: a }) : (d = Ct.current) == null || d.postMessage({ type: "selectionBox", data: null });
1293
+ a ? (x = Et.current) == null || x.postMessage({ type: "selectionBox", data: a }) : (d = Et.current) == null || d.postMessage({ type: "selectionBox", data: null });
1294
1294
  }, []), dr = F((a) => {
1295
- var L, I, h, A, T, Y, _, K, ct, U, et, mt, Rt, Ht, Xt, At;
1296
- const x = Z.current.length > 0, d = at(a.clientX, a.clientY), b = Ut.current;
1297
- if (x && kt) {
1298
- const X = tn(d.x, d.y);
1299
- if (Yt && Re.current && X) {
1300
- const J = Re.current;
1301
- if (X.nodeId !== J.nodeId) {
1302
- const qt = J.handleType === "target" ? { source: X.nodeId, target: J.nodeId, sourceHandle: X.handleId || null, targetHandle: J.handleId } : { source: J.nodeId, target: X.nodeId, sourceHandle: J.handleId, targetHandle: X.handleId || null };
1295
+ var L, I, h, A, T, Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht;
1296
+ const x = Z.current.length > 0, d = lt(a.clientX, a.clientY), b = Ut.current;
1297
+ if (x && Rt) {
1298
+ const W = tn(d.x, d.y);
1299
+ if (Yt && Re.current && W) {
1300
+ const V = Re.current;
1301
+ if (W.nodeId !== V.nodeId) {
1302
+ const qt = V.handleType === "target" ? { source: W.nodeId, target: V.nodeId, sourceHandle: W.handleId || null, targetHandle: V.handleId } : { source: V.nodeId, target: W.nodeId, sourceHandle: V.handleId, targetHandle: W.handleId || null };
1303
1303
  (O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((L = ce.current) == null || L.call(ce, { ...qt, ...be }));
1304
1304
  }
1305
1305
  Re.current = null;
1306
1306
  return;
1307
1307
  }
1308
- if (Bt === "strict" ? X && X.type === "source" : X != null) {
1308
+ if (Bt === "strict" ? W && W.type === "source" : W != null) {
1309
1309
  if (Yt) {
1310
- Re.current = { nodeId: X.nodeId, handleId: X.handleId || null, handleType: X.type }, (h = (I = O.current).onConnectStart) == null || h.call(I, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type });
1310
+ Re.current = { nodeId: W.nodeId, handleId: W.handleId || null, handleType: W.type }, (h = (I = O.current).onConnectStart) == null || h.call(I, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type });
1311
1311
  return;
1312
1312
  }
1313
1313
  Wt.current = {
1314
- sourceId: X.nodeId,
1315
- sourceHandle: X.handleId || null,
1316
- sourceType: X.type,
1317
- startPos: { x: X.x, y: X.y }
1318
- }, Me.current = { x: d.x, y: d.y }, (A = xt.current) == null || A.setPointerCapture(a.pointerId), (Y = (T = O.current).onConnectStart) == null || Y.call(T, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type }), Ce();
1314
+ sourceId: W.nodeId,
1315
+ sourceHandle: W.handleId || null,
1316
+ sourceType: W.type,
1317
+ startPos: { x: W.x, y: W.y }
1318
+ }, Me.current = { x: d.x, y: d.y }, (A = mt.current) == null || A.setPointerCapture(a.pointerId), (Y = (T = O.current).onConnectStart) == null || Y.call(T, a, { nodeId: W.nodeId, handleId: W.handleId, handleType: W.type }), Ce();
1319
1319
  return;
1320
1320
  }
1321
1321
  }
1322
1322
  if (x) {
1323
- const X = Tt(d.x, d.y);
1324
- if (X) {
1325
- if (Mt.current && $t) {
1326
- const zt = [];
1323
+ const W = Tt(d.x, d.y);
1324
+ if (W) {
1325
+ if (bt.current && Lt) {
1326
+ const kt = [];
1327
1327
  if (b)
1328
- zt.push({ id: X.id, type: "select", selected: !X.selected });
1329
- else if (!X.selected) {
1330
- for (const J of Z.current)
1331
- J.id === X.id ? zt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && zt.push({ id: J.id, type: "select", selected: !1 });
1328
+ kt.push({ id: W.id, type: "select", selected: !W.selected });
1329
+ else if (!W.selected) {
1330
+ for (const V of Z.current)
1331
+ V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
1332
1332
  if (Dt.current) {
1333
- const J = Pt.current.filter((tt) => tt.selected).map((tt) => ({ id: tt.id, type: "select", selected: !1 }));
1334
- J.length && Dt.current(J);
1333
+ const V = Pt.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
1334
+ V.length && Dt.current(V);
1335
1335
  }
1336
1336
  }
1337
- if (zt.length) {
1338
- if (Mt.current(zt), hn && !b) {
1339
- const J = Z.current.findIndex((tt) => tt.id === X.id);
1340
- J >= 0 && J < Z.current.length - 1 && Mt.current([
1341
- { id: X.id, type: "remove" },
1342
- { type: "add", item: { ...Z.current[J], selected: !0 } }
1337
+ if (kt.length) {
1338
+ if (bt.current(kt), hn && !b) {
1339
+ const V = Z.current.findIndex((et) => et.id === W.id);
1340
+ V >= 0 && V < Z.current.length - 1 && bt.current([
1341
+ { id: W.id, type: "remove" },
1342
+ { type: "add", item: { ...Z.current[V], selected: !0 } }
1343
1343
  ]);
1344
1344
  }
1345
1345
  Jt();
1346
1346
  }
1347
1347
  }
1348
- if ((_ = De.current) == null || _.call(De, a, X), Et) {
1349
- const zt = b && X.selected;
1350
- let J = null;
1351
- if (X.parentId && X.extent === "parent") {
1352
- const tt = Z.current.find((qt) => qt.id === X.parentId);
1353
- if (tt) {
1354
- const qt = tt.width || Vt, Xe = tt.height || jt, en = X.width || ((K = X.measured) == null ? void 0 : K.width) || Vt, Fe = X.height || ((ct = X.measured) == null ? void 0 : ct.height) || jt;
1355
- J = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
1348
+ if ((H = De.current) == null || H.call(De, a, W), zt) {
1349
+ const kt = b && W.selected;
1350
+ let V = null;
1351
+ if (W.parentId && W.extent === "parent") {
1352
+ const et = Z.current.find((qt) => qt.id === W.parentId);
1353
+ if (et) {
1354
+ const qt = et.width || Vt, Xe = et.height || jt, en = W.width || ((J = W.measured) == null ? void 0 : J.width) || Vt, Fe = W.height || ((ut = W.measured) == null ? void 0 : ut.height) || jt;
1355
+ V = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
1356
1356
  }
1357
1357
  }
1358
1358
  if (_t.current = {
1359
- id: X.id,
1360
- startPos: { ...X.position },
1359
+ id: W.id,
1360
+ startPos: { ...W.position },
1361
1361
  startMouse: { x: d.x, y: d.y },
1362
- parentClamp: J,
1363
- parentId: X.parentId || null,
1364
- selectedStarts: zt ? Z.current.filter((tt) => tt.selected && tt.id !== X.id).map((tt) => {
1362
+ parentClamp: V,
1363
+ parentId: W.parentId || null,
1364
+ selectedStarts: kt ? Z.current.filter((et) => et.selected && et.id !== W.id).map((et) => {
1365
1365
  var Xe, en;
1366
1366
  let qt = null;
1367
- if (tt.parentId && tt.extent === "parent") {
1368
- const Fe = Z.current.find((xn) => xn.id === tt.parentId);
1367
+ if (et.parentId && et.extent === "parent") {
1368
+ const Fe = Z.current.find((xn) => xn.id === et.parentId);
1369
1369
  if (Fe) {
1370
- const xn = Fe.width || Vt, br = Fe.height || jt, Mr = tt.width || ((Xe = tt.measured) == null ? void 0 : Xe.width) || Vt, Rr = tt.height || ((en = tt.measured) == null ? void 0 : en.height) || jt;
1370
+ const xn = Fe.width || Vt, br = Fe.height || jt, Mr = et.width || ((Xe = et.measured) == null ? void 0 : Xe.width) || Vt, Rr = et.height || ((en = et.measured) == null ? void 0 : en.height) || jt;
1371
1371
  qt = { minX: 0, minY: 0, maxX: xn - Mr, maxY: br - Rr };
1372
1372
  }
1373
1373
  }
1374
- return { id: tt.id, startPos: { ...tt.position }, parentClamp: qt, parentId: tt.parentId || null };
1374
+ return { id: et.id, startPos: { ...et.position }, parentClamp: qt, parentId: et.parentId || null };
1375
1375
  }) : []
1376
- }, (U = xt.current) == null || U.setPointerCapture(a.pointerId), (et = He.current) == null || et.call(He, a, X), Mt.current) {
1377
- const tt = [{ id: X.id, type: "position", dragging: !0 }];
1376
+ }, (U = mt.current) == null || U.setPointerCapture(a.pointerId), (nt = Ae.current) == null || nt.call(Ae, a, W), bt.current) {
1377
+ const et = [{ id: W.id, type: "position", dragging: !0 }];
1378
1378
  for (const qt of _t.current.selectedStarts)
1379
- tt.push({ id: qt.id, type: "position", dragging: !0 });
1380
- Mt.current(tt);
1379
+ et.push({ id: qt.id, type: "position", dragging: !0 });
1380
+ bt.current(et);
1381
1381
  }
1382
1382
  }
1383
1383
  return;
1384
1384
  }
1385
1385
  }
1386
- if (Pt.current.length > 0 && $t) {
1387
- const X = ue(d.x, d.y);
1388
- if (X) {
1386
+ if (Pt.current.length > 0 && Lt) {
1387
+ const W = ue(d.x, d.y);
1388
+ if (W) {
1389
1389
  if (Dt.current) {
1390
- const zt = [];
1390
+ const kt = [];
1391
1391
  if (b)
1392
- zt.push({ id: X.id, type: "select", selected: !X.selected });
1392
+ kt.push({ id: W.id, type: "select", selected: !W.selected });
1393
1393
  else {
1394
- for (const J of Pt.current)
1395
- J.id === X.id ? zt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && zt.push({ id: J.id, type: "select", selected: !1 });
1396
- if (Mt.current) {
1397
- const J = Z.current.filter((tt) => tt.selected).map((tt) => ({ id: tt.id, type: "select", selected: !1 }));
1398
- J.length && Mt.current(J);
1394
+ for (const V of Pt.current)
1395
+ V.id === W.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
1396
+ if (bt.current) {
1397
+ const V = Z.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
1398
+ V.length && bt.current(V);
1399
1399
  }
1400
1400
  }
1401
- zt.length && (Dt.current(zt), Jt());
1401
+ kt.length && (Dt.current(kt), Jt());
1402
1402
  }
1403
- (mt = le.current) == null || mt.call(le, a, X);
1403
+ (vt = le.current) == null || vt.call(le, a, W);
1404
1404
  return;
1405
1405
  }
1406
1406
  }
1407
1407
  if (!b) {
1408
- const X = Z.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 })), zt = Pt.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 }));
1409
- X.length && Mt.current && Mt.current(X), zt.length && Dt.current && Dt.current(zt), (X.length || zt.length) && Jt();
1408
+ const W = Z.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 })), kt = Pt.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 }));
1409
+ W.length && bt.current && bt.current(W), kt.length && Dt.current && Dt.current(kt), (W.length || kt.length) && Jt();
1410
1410
  }
1411
- if ((Rt = We.current) == null || Rt.call(We, a), ne || b) {
1412
- ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (Ht = xt.current) == null || Ht.setPointerCapture(a.pointerId), Ne();
1411
+ if ((Mt = We.current) == null || Mt.call(We, a), ne || b) {
1412
+ ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (At = mt.current) == null || At.setPointerCapture(a.pointerId), Ne();
1413
1413
  return;
1414
1414
  }
1415
- Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = xt.current) == null || Xt.classList.add("dragging"), (At = xt.current) == null || At.setPointerCapture(a.pointerId);
1416
- }, [at, Tt, tn, ue, Et, kt, $t, ne, Ce, Ne, Jt]), fr = F((a) => {
1415
+ Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = mt.current) == null || Xt.classList.add("dragging"), (Ht = mt.current) == null || Ht.setPointerCapture(a.pointerId);
1416
+ }, [lt, Tt, tn, ue, zt, Rt, Lt, ne, Ce, Ne, Jt]), fr = F((a) => {
1417
1417
  var d, b;
1418
1418
  if (Wt.current) {
1419
- if (Me.current = at(a.clientX, a.clientY), Ce(), fn) {
1420
- const L = xt.current;
1419
+ if (Me.current = lt(a.clientX, a.clientY), Ce(), fn) {
1420
+ const L = mt.current;
1421
1421
  if (L) {
1422
1422
  const I = L.getBoundingClientRect(), h = 40, A = a.clientX - I.left, T = a.clientY - I.top;
1423
- let Y = 0, _ = 0;
1424
- A < h ? Y = Qt : A > I.width - h && (Y = -Qt), T < h ? _ = Qt : T > I.height - h && (_ = -Qt), (Y || _) && (gt.current.x += Y, gt.current.y += _, Nt(a));
1423
+ let Y = 0, H = 0;
1424
+ A < h ? Y = Qt : A > I.width - h && (Y = -Qt), T < h ? H = Qt : T > I.height - h && (H = -Qt), (Y || H) && (pt.current.x += Y, pt.current.y += H, Ct(a));
1425
1425
  }
1426
1426
  }
1427
1427
  return;
1428
1428
  }
1429
1429
  if (ie.current) {
1430
- ie.current.endWorld = at(a.clientX, a.clientY), Ne();
1430
+ ie.current.endWorld = lt(a.clientX, a.clientY), Ne();
1431
1431
  const L = ie.current, I = Math.min(L.startWorld.x, L.endWorld.x), h = Math.min(L.startWorld.y, L.endWorld.y), A = Math.max(L.startWorld.x, L.endWorld.x), T = Math.max(L.startWorld.y, L.endWorld.y);
1432
- if (Mt.current) {
1432
+ if (bt.current) {
1433
1433
  const Y = [];
1434
- for (const _ of Z.current) {
1435
- if (_.hidden) continue;
1436
- const K = _.width || Vt, ct = _.height || jt, U = Ie === "full" ? _.position.x >= I && _.position.x + K <= A && _.position.y >= h && _.position.y + ct <= T : _.position.x + K > I && _.position.x < A && _.position.y + ct > h && _.position.y < T;
1437
- U !== !!_.selected && Y.push({ id: _.id, type: "select", selected: U });
1434
+ for (const H of Z.current) {
1435
+ if (H.hidden) continue;
1436
+ const J = H.width || Vt, ut = H.height || jt, U = Ie === "full" ? H.position.x >= I && H.position.x + J <= A && H.position.y >= h && H.position.y + ut <= T : H.position.x + J > I && H.position.x < A && H.position.y + ut > h && H.position.y < T;
1437
+ U !== !!H.selected && Y.push({ id: H.id, type: "select", selected: U });
1438
1438
  }
1439
- Y.length && Mt.current(Y);
1439
+ Y.length && bt.current(Y);
1440
1440
  }
1441
1441
  return;
1442
1442
  }
1443
1443
  if (_t.current) {
1444
- const L = at(a.clientX, a.clientY), I = _t.current, h = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
1444
+ const L = lt(a.clientX, a.clientY), I = _t.current, h = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
1445
1445
  let T = { x: I.startPos.x + h, y: I.startPos.y + A };
1446
1446
  if (me && (T = Pn(T, de)), oe && (T = Tn(T, oe)), I.parentClamp) {
1447
1447
  const U = I.parentClamp;
@@ -1449,73 +1449,73 @@ function Lr({
1449
1449
  }
1450
1450
  const Y = [{ id: I.id, position: T }];
1451
1451
  for (const U of I.selectedStarts) {
1452
- let et = { x: U.startPos.x + h, y: U.startPos.y + A };
1453
- if (me && (et = Pn(et, de)), oe && (et = Tn(et, oe)), U.parentClamp) {
1454
- const mt = U.parentClamp;
1455
- et = { x: Math.max(mt.minX, Math.min(et.x, mt.maxX)), y: Math.max(mt.minY, Math.min(et.y, mt.maxY)) };
1452
+ let nt = { x: U.startPos.x + h, y: U.startPos.y + A };
1453
+ if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), U.parentClamp) {
1454
+ const vt = U.parentClamp;
1455
+ nt = { x: Math.max(vt.minX, Math.min(nt.x, vt.maxX)), y: Math.max(vt.minY, Math.min(nt.y, vt.maxY)) };
1456
1456
  }
1457
- Y.push({ id: U.id, position: et });
1457
+ Y.push({ id: U.id, position: nt });
1458
1458
  }
1459
- const _ = [];
1459
+ const H = [];
1460
1460
  for (const U of Y) {
1461
- const et = Z.current.find((mt) => mt.id === U.id);
1462
- if (et) {
1463
- et.position = U.position, et.dragging = !0;
1464
- let mt = U.position;
1465
- if (et.parentId) {
1466
- let Rt = Z.current.find((At) => At.id === et.parentId), Ht = U.position.x, Xt = U.position.y;
1467
- for (; Rt; )
1468
- Ht += Rt.position.x, Xt += Rt.position.y, Rt = Rt.parentId ? Z.current.find((At) => At.id === Rt.parentId) : null;
1469
- mt = { x: Ht, y: Xt };
1461
+ const nt = Z.current.find((vt) => vt.id === U.id);
1462
+ if (nt) {
1463
+ nt.position = U.position, nt.dragging = !0;
1464
+ let vt = U.position;
1465
+ if (nt.parentId) {
1466
+ let Mt = Z.current.find((Ht) => Ht.id === nt.parentId), At = U.position.x, Xt = U.position.y;
1467
+ for (; Mt; )
1468
+ At += Mt.position.x, Xt += Mt.position.y, Mt = Mt.parentId ? Z.current.find((Ht) => Ht.id === Mt.parentId) : null;
1469
+ vt = { x: At, y: Xt };
1470
1470
  }
1471
- _.push({
1471
+ H.push({
1472
1472
  id: U.id,
1473
1473
  position: U.position,
1474
- _absolutePosition: mt,
1475
- width: et.width,
1476
- height: et.height,
1474
+ _absolutePosition: vt,
1475
+ width: nt.width,
1476
+ height: nt.height,
1477
1477
  dragging: !0,
1478
- selected: et.selected
1478
+ selected: nt.selected
1479
1479
  });
1480
1480
  }
1481
1481
  }
1482
- const K = new Set(Y.map((U) => U.id));
1482
+ const J = new Set(Y.map((U) => U.id));
1483
1483
  for (const U of Z.current)
1484
- if (U.parentId && K.has(U.parentId) && !K.has(U.id)) {
1485
- let et = Z.current.find((Ht) => Ht.id === U.parentId), mt = U.position.x, Rt = U.position.y;
1486
- for (; et; )
1487
- mt += et.position.x, Rt += et.position.y, et = et.parentId ? Z.current.find((Ht) => Ht.id === et.parentId) : null;
1488
- _.push({
1484
+ if (U.parentId && J.has(U.parentId) && !J.has(U.id)) {
1485
+ let nt = Z.current.find((At) => At.id === U.parentId), vt = U.position.x, Mt = U.position.y;
1486
+ for (; nt; )
1487
+ vt += nt.position.x, Mt += nt.position.y, nt = nt.parentId ? Z.current.find((At) => At.id === nt.parentId) : null;
1488
+ H.push({
1489
1489
  id: U.id,
1490
1490
  position: U.position,
1491
- _absolutePosition: { x: mt, y: Rt },
1491
+ _absolutePosition: { x: vt, y: Mt },
1492
1492
  width: U.width,
1493
1493
  height: U.height,
1494
1494
  dragging: !1,
1495
1495
  selected: U.selected
1496
1496
  });
1497
1497
  }
1498
- if ((d = Ct.current) == null || d.postMessage({ type: "nodePositions", data: { updates: _ } }), dn) {
1499
- const U = xt.current;
1498
+ if ((d = Et.current) == null || d.postMessage({ type: "nodePositions", data: { updates: H } }), dn) {
1499
+ const U = mt.current;
1500
1500
  if (U) {
1501
- const et = U.getBoundingClientRect(), mt = 40, Rt = a.clientX - et.left, Ht = a.clientY - et.top;
1502
- let Xt = 0, At = 0;
1503
- Rt < mt ? Xt = Qt : Rt > et.width - mt && (Xt = -Qt), Ht < mt ? At = Qt : Ht > et.height - mt && (At = -Qt), (Xt || At) && (gt.current.x += Xt, gt.current.y += At, Nt(a));
1501
+ const nt = U.getBoundingClientRect(), vt = 40, Mt = a.clientX - nt.left, At = a.clientY - nt.top;
1502
+ let Xt = 0, Ht = 0;
1503
+ Mt < vt ? Xt = Qt : Mt > nt.width - vt && (Xt = -Qt), At < vt ? Ht = Qt : At > nt.height - vt && (Ht = -Qt), (Xt || Ht) && (pt.current.x += Xt, pt.current.y += Ht, Ct(a));
1504
1504
  }
1505
1505
  }
1506
- const ct = Z.current.find((U) => U.id === I.id);
1507
- ct && ((b = Ae.current) == null || b.call(Ae, a, ct));
1506
+ const ut = Z.current.find((U) => U.id === I.id);
1507
+ ut && ((b = He.current) == null || b.call(He, a, ut));
1508
1508
  return;
1509
1509
  }
1510
1510
  if (!Se.current) return;
1511
- const x = gt.current;
1512
- x.x += a.clientX - te.current.x, x.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Nt();
1513
- }, [Nt, at, Ce, Ne]), hr = F((a) => {
1511
+ const x = pt.current;
1512
+ x.x += a.clientX - te.current.x, x.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Ct();
1513
+ }, [Ct, lt, Ce, Ne]), hr = F((a) => {
1514
1514
  var x, d, b, L, I;
1515
1515
  if (Wt.current) {
1516
- const h = at(a.clientX, a.clientY), A = tn(h.x, h.y);
1516
+ const h = lt(a.clientX, a.clientY), A = tn(h.x, h.y);
1517
1517
  if (A && A.nodeId !== Wt.current.sourceId && (Bt === "loose" || A.type === "target")) {
1518
- const _ = Wt.current.sourceType === "target" ? {
1518
+ const H = Wt.current.sourceType === "target" ? {
1519
1519
  source: A.nodeId,
1520
1520
  target: Wt.current.sourceId,
1521
1521
  sourceHandle: A.handleId || null,
@@ -1526,7 +1526,7 @@ function Lr({
1526
1526
  sourceHandle: Wt.current.sourceHandle,
1527
1527
  targetHandle: A.handleId || null
1528
1528
  };
1529
- (O.current.isValidConnection ? O.current.isValidConnection(_) : !0) && ((x = ce.current) == null || x.call(ce, { ..._, ...be }));
1529
+ (O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((x = ce.current) == null || x.call(ce, { ...H, ...be }));
1530
1530
  }
1531
1531
  (b = (d = O.current).onConnectEnd) == null || b.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
1532
1532
  return;
@@ -1537,23 +1537,23 @@ function Lr({
1537
1537
  }
1538
1538
  if (_t.current) {
1539
1539
  const h = _t.current;
1540
- if (Mt.current) {
1541
- const T = Z.current.find((_) => _.id === h.id), Y = [{
1540
+ if (bt.current) {
1541
+ const T = Z.current.find((H) => H.id === h.id), Y = [{
1542
1542
  id: h.id,
1543
1543
  type: "position",
1544
1544
  position: T ? { ...T.position } : void 0,
1545
1545
  dragging: !1
1546
1546
  }];
1547
- for (const _ of h.selectedStarts) {
1548
- const K = Z.current.find((ct) => ct.id === _.id);
1547
+ for (const H of h.selectedStarts) {
1548
+ const J = Z.current.find((ut) => ut.id === H.id);
1549
1549
  Y.push({
1550
- id: _.id,
1550
+ id: H.id,
1551
1551
  type: "position",
1552
- position: K ? { ...K.position } : void 0,
1552
+ position: J ? { ...J.position } : void 0,
1553
1553
  dragging: !1
1554
1554
  });
1555
1555
  }
1556
- Mt.current(Y);
1556
+ bt.current(Y);
1557
1557
  }
1558
1558
  requestAnimationFrame(() => {
1559
1559
  _t.current = null;
@@ -1562,27 +1562,27 @@ function Lr({
1562
1562
  A && ((L = _e.current) == null || L.call(_e, a, A));
1563
1563
  return;
1564
1564
  }
1565
- Se.current = !1, (I = xt.current) == null || I.classList.remove("dragging");
1566
- }, [at, tn, Ce, Ne, Jt]);
1567
- ft(() => {
1568
- const a = xt.current;
1565
+ Se.current = !1, (I = mt.current) == null || I.classList.remove("dragging");
1566
+ }, [lt, tn, Ce, Ne, Jt]);
1567
+ ht(() => {
1568
+ const a = mt.current;
1569
1569
  if (!a) return;
1570
1570
  const x = (d) => {
1571
1571
  Pe && d.preventDefault();
1572
- const b = gt.current;
1572
+ const b = pt.current;
1573
1573
  if (Ge || ke.current) {
1574
1574
  const T = Ze;
1575
- $e === "horizontal" ? b.x -= d.deltaY * T : ($e === "vertical" || (b.x -= d.deltaX * T), b.y -= d.deltaY * T), Nt(d);
1575
+ $e === "horizontal" ? b.x -= d.deltaY * T : ($e === "vertical" || (b.x -= d.deltaX * T), b.y -= d.deltaY * T), Ct(d);
1576
1576
  return;
1577
1577
  }
1578
1578
  if (!Oe) return;
1579
1579
  const L = d.deltaY > 0 ? 0.92 : 1.08, I = a.getBoundingClientRect(), h = d.clientX - I.left, A = d.clientY - I.top;
1580
- b.x = h - (h - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(pt, Math.max(ot, b.zoom * L)), Nt(d);
1580
+ b.x = h - (h - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(xt, Math.max(st, b.zoom * L)), Ct(d);
1581
1581
  };
1582
1582
  return a.addEventListener("wheel", x, { passive: !Pe }), () => a.removeEventListener("wheel", x);
1583
- }, [Nt, ot, pt, Ge, $e, Ze, Oe, Pe]), ft(() => {
1583
+ }, [Ct, st, xt, Ge, $e, Ze, Oe, Pe]), ht(() => {
1584
1584
  if (!Ke) return;
1585
- const a = xt.current;
1585
+ const a = mt.current;
1586
1586
  if (!a) return;
1587
1587
  let x = 0, d = null;
1588
1588
  const b = (h) => {
@@ -1598,10 +1598,10 @@ function Lr({
1598
1598
  }, L = (h) => {
1599
1599
  if (h.touches.length === 2 && x > 0) {
1600
1600
  h.preventDefault();
1601
- const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY, Y = Math.hypot(A, T), _ = Y / x;
1601
+ const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY, Y = Math.hypot(A, T), H = Y / x;
1602
1602
  x = Y;
1603
- const K = gt.current, ct = d.x, U = d.y;
1604
- K.x = ct - (ct - K.x) * _, K.y = U - (U - K.y) * _, K.zoom = Math.min(pt, Math.max(ot, K.zoom * _)), Nt(h);
1603
+ const J = pt.current, ut = d.x, U = d.y;
1604
+ J.x = ut - (ut - J.x) * H, J.y = U - (U - J.y) * H, J.zoom = Math.min(xt, Math.max(st, J.zoom * H)), Ct(h);
1605
1605
  }
1606
1606
  }, I = () => {
1607
1607
  x = 0, d = null;
@@ -1609,32 +1609,32 @@ function Lr({
1609
1609
  return a.addEventListener("touchstart", b, { passive: !1 }), a.addEventListener("touchmove", L, { passive: !1 }), a.addEventListener("touchend", I), () => {
1610
1610
  a.removeEventListener("touchstart", b), a.removeEventListener("touchmove", L), a.removeEventListener("touchend", I);
1611
1611
  };
1612
- }, [Ke, Nt, ot, pt]), ft(() => {
1612
+ }, [Ke, Ct, st, xt]), ht(() => {
1613
1613
  if (!Qe) return;
1614
- const a = xt.current;
1614
+ const a = mt.current;
1615
1615
  if (!a) return;
1616
1616
  const x = (d) => {
1617
- var _, K, ct, U;
1618
- const b = at(d.clientX, d.clientY);
1617
+ var H, J, ut, U;
1618
+ const b = lt(d.clientX, d.clientY);
1619
1619
  if (Tt(b.x, b.y)) {
1620
- (K = (_ = O.current).onNodeDoubleClick) == null || K.call(_, d, Tt(b.x, b.y));
1620
+ (J = (H = O.current).onNodeDoubleClick) == null || J.call(H, d, Tt(b.x, b.y));
1621
1621
  return;
1622
1622
  }
1623
1623
  const L = ue(b.x, b.y);
1624
1624
  if (L) {
1625
- (U = (ct = O.current).onEdgeDoubleClick) == null || U.call(ct, d, L);
1625
+ (U = (ut = O.current).onEdgeDoubleClick) == null || U.call(ut, d, L);
1626
1626
  return;
1627
1627
  }
1628
- const I = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, T = d.clientY - h.top, Y = gt.current;
1629
- Y.x = A - (A - Y.x) * I, Y.y = T - (T - Y.y) * I, Y.zoom = Math.min(pt, Math.max(ot, Y.zoom * I)), Nt(d);
1628
+ const I = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, T = d.clientY - h.top, Y = pt.current;
1629
+ Y.x = A - (A - Y.x) * I, Y.y = T - (T - Y.y) * I, Y.zoom = Math.min(xt, Math.max(st, Y.zoom * I)), Ct(d);
1630
1630
  };
1631
1631
  return a.addEventListener("dblclick", x), () => a.removeEventListener("dblclick", x);
1632
- }, [Qe, Nt, ot, pt, at, Tt, ue]), ft(() => {
1633
- const a = xt.current;
1632
+ }, [Qe, Ct, st, xt, lt, Tt, ue]), ht(() => {
1633
+ const a = mt.current;
1634
1634
  if (!a) return;
1635
1635
  const x = (d) => {
1636
- var h, A, T, Y, _, K;
1637
- const b = at(d.clientX, d.clientY), L = Tt(b.x, b.y);
1636
+ var h, A, T, Y, H, J;
1637
+ const b = lt(d.clientX, d.clientY), L = Tt(b.x, b.y);
1638
1638
  if (L) {
1639
1639
  (A = (h = O.current).onNodeContextMenu) == null || A.call(h, d, L);
1640
1640
  return;
@@ -1644,32 +1644,32 @@ function Lr({
1644
1644
  (Y = (T = O.current).onEdgeContextMenu) == null || Y.call(T, d, I);
1645
1645
  return;
1646
1646
  }
1647
- (K = (_ = O.current).onPaneContextMenu) == null || K.call(_, d);
1647
+ (J = (H = O.current).onPaneContextMenu) == null || J.call(H, d);
1648
1648
  };
1649
1649
  return a.addEventListener("contextmenu", x), () => a.removeEventListener("contextmenu", x);
1650
- }, [at, Tt, ue]), ft(() => {
1651
- const a = xt.current;
1650
+ }, [lt, Tt, ue]), ht(() => {
1651
+ const a = mt.current;
1652
1652
  if (!a) return;
1653
1653
  let x = null, d = null;
1654
1654
  const b = (h) => {
1655
- var Y, _, K, ct, U, et, mt, Rt, Ht, Xt, At, X, zt, J;
1656
- (_ = (Y = O.current).onPaneMouseMove) == null || _.call(Y, h);
1657
- const A = at(h.clientX, h.clientY), T = Tt(A.x, A.y);
1658
- if (T !== x && (x && ((ct = (K = O.current).onNodeMouseLeave) == null || ct.call(K, h, x)), T && ((et = (U = O.current).onNodeMouseEnter) == null || et.call(U, h, T)), x = T), T && ((Rt = (mt = O.current).onNodeMouseMove) == null || Rt.call(mt, h, T)), !T) {
1659
- const tt = ue(A.x, A.y);
1660
- tt !== d && (d && ((Xt = (Ht = O.current).onEdgeMouseLeave) == null || Xt.call(Ht, h, d)), tt && ((X = (At = O.current).onEdgeMouseEnter) == null || X.call(At, h, tt)), d = tt), tt && ((J = (zt = O.current).onEdgeMouseMove) == null || J.call(zt, h, tt));
1655
+ var Y, H, J, ut, U, nt, vt, Mt, At, Xt, Ht, W, kt, V;
1656
+ (H = (Y = O.current).onPaneMouseMove) == null || H.call(Y, h);
1657
+ const A = lt(h.clientX, h.clientY), T = Tt(A.x, A.y);
1658
+ if (T !== x && (x && ((ut = (J = O.current).onNodeMouseLeave) == null || ut.call(J, h, x)), T && ((nt = (U = O.current).onNodeMouseEnter) == null || nt.call(U, h, T)), x = T), T && ((Mt = (vt = O.current).onNodeMouseMove) == null || Mt.call(vt, h, T)), !T) {
1659
+ const et = ue(A.x, A.y);
1660
+ et !== d && (d && ((Xt = (At = O.current).onEdgeMouseLeave) == null || Xt.call(At, h, d)), et && ((W = (Ht = O.current).onEdgeMouseEnter) == null || W.call(Ht, h, et)), d = et), et && ((V = (kt = O.current).onEdgeMouseMove) == null || V.call(kt, h, et));
1661
1661
  }
1662
1662
  }, L = (h) => {
1663
1663
  var A, T;
1664
1664
  return (T = (A = O.current).onPaneMouseEnter) == null ? void 0 : T.call(A, h);
1665
1665
  }, I = (h) => {
1666
- var A, T, Y, _, K, ct;
1667
- (T = (A = O.current).onPaneMouseLeave) == null || T.call(A, h), x && ((_ = (Y = O.current).onNodeMouseLeave) == null || _.call(Y, h, x), x = null), d && ((ct = (K = O.current).onEdgeMouseLeave) == null || ct.call(K, h, d), d = null);
1666
+ var A, T, Y, H, J, ut;
1667
+ (T = (A = O.current).onPaneMouseLeave) == null || T.call(A, h), x && ((H = (Y = O.current).onNodeMouseLeave) == null || H.call(Y, h, x), x = null), d && ((ut = (J = O.current).onEdgeMouseLeave) == null || ut.call(J, h, d), d = null);
1668
1668
  };
1669
1669
  return a.addEventListener("mousemove", b), a.addEventListener("mouseenter", L), a.addEventListener("mouseleave", I), () => {
1670
1670
  a.removeEventListener("mousemove", b), a.removeEventListener("mouseenter", L), a.removeEventListener("mouseleave", I);
1671
1671
  };
1672
- }, [at, Tt, ue]), ft(() => {
1672
+ }, [lt, Tt, ue]), ht(() => {
1673
1673
  const a = Array.isArray(ve) ? ve : [ve], x = async (d) => {
1674
1674
  var b, L;
1675
1675
  if (a.includes(d.key)) {
@@ -1678,7 +1678,7 @@ function Lr({
1678
1678
  if (!I.length && !h.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: I, edges: h }))
1679
1679
  return;
1680
1680
  const A = new Set(I.map((T) => T.id));
1681
- if (I.length && Mt.current && (Mt.current(I.map((T) => ({ id: T.id, type: "remove" }))), Dt.current)) {
1681
+ if (I.length && bt.current && (bt.current(I.map((T) => ({ id: T.id, type: "remove" }))), Dt.current)) {
1682
1682
  const T = Pt.current.filter((Y) => A.has(Y.source) || A.has(Y.target));
1683
1683
  T.length && Dt.current(T.map((Y) => ({ id: Y.id, type: "remove" })));
1684
1684
  }
@@ -1686,9 +1686,9 @@ function Lr({
1686
1686
  }
1687
1687
  if ((d.ctrlKey || d.metaKey) && d.key === "a") {
1688
1688
  if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA") return;
1689
- if (d.preventDefault(), Mt.current) {
1689
+ if (d.preventDefault(), bt.current) {
1690
1690
  const I = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
1691
- I.length && Mt.current(I);
1691
+ I.length && bt.current(I);
1692
1692
  }
1693
1693
  if (Dt.current) {
1694
1694
  const I = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
@@ -1698,38 +1698,38 @@ function Lr({
1698
1698
  };
1699
1699
  return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
1700
1700
  }, [ve]);
1701
- const In = V(!1);
1702
- ft(() => {
1701
+ const In = tt(!1);
1702
+ ht(() => {
1703
1703
  var a, x;
1704
- if (!In.current && Ct.current) {
1705
- if (In.current = !0, ht && Z.current.length > 0) {
1706
- const d = xt.current;
1704
+ if (!In.current && Et.current) {
1705
+ if (In.current = !0, gt && Z.current.length > 0) {
1706
+ const d = mt.current;
1707
1707
  if (d) {
1708
- const b = d.getBoundingClientRect(), L = (bt == null ? void 0 : bt.padding) ?? 0.1, I = Mn(Z.current), h = Rn(I, b.width, b.height, L);
1709
- bt != null && bt.maxZoom && (h.zoom = Math.min(h.zoom, bt.maxZoom)), bt != null && bt.minZoom && (h.zoom = Math.max(h.zoom, bt.minZoom)), gt.current = h, Nt();
1708
+ const b = d.getBoundingClientRect(), L = (ct == null ? void 0 : ct.padding) ?? 0.1, I = Mn(Z.current), h = Rn(I, b.width, b.height, L);
1709
+ ct != null && ct.maxZoom && (h.zoom = Math.min(h.zoom, ct.maxZoom)), ct != null && ct.minZoom && (h.zoom = Math.max(h.zoom, ct.minZoom)), pt.current = h, Ct();
1710
1710
  }
1711
1711
  }
1712
1712
  (x = (a = O.current).onInit) == null || x.call(a, {
1713
1713
  getNodes: () => [...Z.current],
1714
1714
  getEdges: () => [...Pt.current],
1715
- getViewport: () => ({ ...gt.current }),
1715
+ getViewport: () => ({ ...pt.current }),
1716
1716
  fitView: (d = {}) => {
1717
- const b = xt.current;
1717
+ const b = mt.current;
1718
1718
  if (!b || !Z.current.length) return;
1719
1719
  const L = b.getBoundingClientRect(), I = Mn(Z.current), h = Rn(I, L.width, L.height, d.padding ?? 0.1);
1720
- gt.current = h, Nt();
1720
+ pt.current = h, Ct();
1721
1721
  }
1722
1722
  });
1723
1723
  }
1724
1724
  });
1725
1725
  const yr = F(() => {
1726
- gt.current = { ...vt }, Nt();
1727
- }, [Nt, vt]), gr = F((a) => {
1726
+ pt.current = { ...Nt }, Ct();
1727
+ }, [Ct, Nt]), gr = F((a) => {
1728
1728
  var x;
1729
1729
  if (a)
1730
1730
  se.current.push(a);
1731
1731
  else {
1732
- const d = gt.current, b = xt.current;
1732
+ const d = pt.current, b = mt.current;
1733
1733
  if (!b) return;
1734
1734
  const L = b.getBoundingClientRect(), I = Math.round(-d.x / d.zoom + L.width / 2 / d.zoom), h = Math.round(-d.y / d.zoom + L.height / 2 / d.zoom);
1735
1735
  se.current.push({
@@ -1741,10 +1741,10 @@ function Lr({
1741
1741
  body: "Added at viewport center"
1742
1742
  });
1743
1743
  }
1744
- (x = Ct.current) == null || x.postMessage({ type: "cards", data: { cards: [...se.current] } });
1744
+ (x = Et.current) == null || x.postMessage({ type: "cards", data: { cards: [...se.current] } });
1745
1745
  }, []), pr = F((a) => {
1746
1746
  if (a.id || (a.id = "node-" + Date.now()), !a.position) {
1747
- const x = gt.current, d = xt.current;
1747
+ const x = pt.current, d = mt.current;
1748
1748
  if (!d) return;
1749
1749
  const b = d.getBoundingClientRect();
1750
1750
  a.position = {
@@ -1752,26 +1752,26 @@ function Lr({
1752
1752
  y: Math.round(-x.y / x.zoom + b.height / 2 / x.zoom) - jt / 2
1753
1753
  };
1754
1754
  }
1755
- a.data || (a.data = { label: a.id }), Mt.current && Mt.current([{ type: "add", item: a }]);
1756
- }, []), xr = F(() => ({ ...gt.current }), []), mr = F((a) => {
1757
- gt.current = { ...gt.current, ...a }, Nt();
1758
- }, [Nt]), vr = F((a) => at(a.x, a.y), [at]), $n = n, wr = St(() => ({
1759
- wrapRef: xt,
1755
+ a.data || (a.data = { label: a.id }), bt.current && bt.current([{ type: "add", item: a }]);
1756
+ }, []), xr = F(() => ({ ...pt.current }), []), mr = F((a) => {
1757
+ pt.current = { ...pt.current, ...a }, Ct();
1758
+ }, [Ct]), vr = F((a) => lt(a.x, a.y), [lt]), $n = n, wr = St(() => ({
1759
+ wrapRef: mt,
1760
1760
  canvasRef: Te,
1761
- workerRef: Ct,
1762
- cameraRef: gt,
1761
+ workerRef: Et,
1762
+ cameraRef: pt,
1763
1763
  nodesRef: Z,
1764
1764
  edgesRef: Pt,
1765
1765
  handleRegistryRef: yn,
1766
1766
  syncNodesToWorker: Ft,
1767
- onNodesChangeRef: Mt,
1767
+ onNodesChangeRef: bt,
1768
1768
  onEdgesChangeRef: Dt,
1769
- sendCamera: Nt,
1770
- screenToWorld: at,
1769
+ sendCamera: Ct,
1770
+ screenToWorld: lt,
1771
1771
  viewportListeners: Kt,
1772
1772
  selectionListeners: he,
1773
- zoomMin: ot,
1774
- zoomMax: pt,
1773
+ zoomMin: st,
1774
+ zoomMax: xt,
1775
1775
  snapToGrid: me,
1776
1776
  snapGrid: de,
1777
1777
  nodeExtent: oe,
@@ -1793,9 +1793,9 @@ function Lr({
1793
1793
  get connection() {
1794
1794
  return Ve;
1795
1795
  }
1796
- }), [e, n, $n, Be, Ve, Nt, at, Ft, Kt, he, ot, pt, me, de, oe, be, fe]);
1796
+ }), [e, n, $n, Be, Ve, Ct, lt, Ft, Kt, he, st, xt, me, de, oe, be, fe]);
1797
1797
  return {
1798
- wrapRef: xt,
1798
+ wrapRef: mt,
1799
1799
  canvasRef: Te,
1800
1800
  canvasReady: gn,
1801
1801
  onPointerDown: dr,
@@ -1828,95 +1828,97 @@ function Ro() {
1828
1828
  return qe(je);
1829
1829
  }
1830
1830
  function $r({ node: t, nodeType: e }) {
1831
- var m, C, k;
1832
- const n = yt(), r = V(null), s = t._absolutePosition || t.position, o = V(null);
1833
- ft(() => {
1831
+ var m, C, z;
1832
+ const n = yt(), r = tt(null), s = t._absolutePosition || t.position, o = tt(null);
1833
+ ht(() => {
1834
1834
  const M = r.current;
1835
1835
  if (!M) return;
1836
- const $ = new ResizeObserver((z) => {
1837
- var H, g, f, p;
1838
- const { width: E, height: W } = z[0].contentRect;
1839
- if (E > 0 && W > 0) {
1840
- const v = n.nodesRef.current.find((P) => P.id === t.id), w = (v == null ? void 0 : v.width) || ((H = v == null ? void 0 : v.measured) == null ? void 0 : H.width), N = (v == null ? void 0 : v.height) || ((g = v == null ? void 0 : v.measured) == null ? void 0 : g.height);
1841
- (Math.abs((w || 0) - E) > 1 || Math.abs((N || 0) - W) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
1842
- { id: t.id, type: "dimensions", dimensions: { width: E, height: W }, setAttributes: !0 }
1836
+ const $ = new ResizeObserver((k) => {
1837
+ var D, g, f, p;
1838
+ const { width: E, height: _ } = k[0].contentRect;
1839
+ if (E > 0 && _ > 0) {
1840
+ const v = n.nodesRef.current.find((P) => P.id === t.id), N = (v == null ? void 0 : v.width) || ((D = v == null ? void 0 : v.measured) == null ? void 0 : D.width), w = (v == null ? void 0 : v.height) || ((g = v == null ? void 0 : v.measured) == null ? void 0 : g.height);
1841
+ (Math.abs((N || 0) - E) > 1 || Math.abs((w || 0) - _) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
1842
+ { id: t.id, type: "dimensions", dimensions: { width: E, height: _ }, setAttributes: !0 }
1843
1843
  ]));
1844
1844
  }
1845
1845
  });
1846
1846
  return $.observe(M), () => $.disconnect();
1847
1847
  }, [t.id, n]);
1848
1848
  const i = F((M) => {
1849
- var R, B, q;
1849
+ var B, q, X;
1850
1850
  M.stopPropagation();
1851
- let $ = M.target;
1852
- for (; $ && $ !== r.current; ) {
1853
- if ((R = $.classList) != null && R.contains("nodrag")) return;
1854
- $ = $.parentElement;
1851
+ const $ = M.target.tagName;
1852
+ if ($ === "INPUT" || $ === "TEXTAREA" || $ === "SELECT" || $ === "BUTTON" || $ === "A" || M.target.isContentEditable) return;
1853
+ let k = M.target;
1854
+ for (; k && k !== r.current; ) {
1855
+ if ((B = k.classList) != null && B.contains("nodrag")) return;
1856
+ k = k.parentElement;
1855
1857
  }
1856
1858
  if (n.onNodesChangeRef.current) {
1857
- const D = [];
1859
+ const K = [];
1858
1860
  if (M.shiftKey)
1859
- D.push({ id: t.id, type: "select", selected: !t.selected });
1861
+ K.push({ id: t.id, type: "select", selected: !t.selected });
1860
1862
  else
1861
- for (const nt of n.nodesRef.current)
1862
- nt.id === t.id && !nt.selected ? D.push({ id: nt.id, type: "select", selected: !0 }) : nt.id !== t.id && nt.selected && D.push({ id: nt.id, type: "select", selected: !1 });
1863
- D.length && n.onNodesChangeRef.current(D);
1863
+ for (const rt of n.nodesRef.current)
1864
+ rt.id === t.id && !rt.selected ? K.push({ id: rt.id, type: "select", selected: !0 }) : rt.id !== t.id && rt.selected && K.push({ id: rt.id, type: "select", selected: !1 });
1865
+ K.length && n.onNodesChangeRef.current(K);
1864
1866
  }
1865
- const z = n.cameraRef.current, E = n.wrapRef.current;
1866
- if (!E) return;
1867
- const W = E.getBoundingClientRect(), H = (M.clientX - W.left - z.x) / z.zoom, g = (M.clientY - W.top - z.y) / z.zoom, p = M.shiftKey && t.selected ? n.nodesRef.current.filter((D) => D.selected && D.id !== t.id).map((D) => ({ id: D.id, startPos: { ...D.position } })) : [];
1867
+ const E = n.cameraRef.current, _ = n.wrapRef.current;
1868
+ if (!_) return;
1869
+ const D = _.getBoundingClientRect(), g = (M.clientX - D.left - E.x) / E.zoom, f = (M.clientY - D.top - E.y) / E.zoom, v = M.shiftKey && t.selected ? n.nodesRef.current.filter((K) => K.selected && K.id !== t.id).map((K) => ({ id: K.id, startPos: { ...K.position } })) : [];
1868
1870
  o.current = {
1869
1871
  startPos: { ...t.position },
1870
- startMouse: { x: H, y: g },
1871
- selectedStarts: p
1872
+ startMouse: { x: g, y: f },
1873
+ selectedStarts: v
1872
1874
  };
1873
- const v = [{ id: t.id, type: "position", dragging: !0 }];
1874
- for (const D of p)
1875
- v.push({ id: D.id, type: "position", dragging: !0 });
1876
- (q = (B = n.onNodesChangeRef).current) == null || q.call(B, v);
1875
+ const N = [{ id: t.id, type: "position", dragging: !0 }];
1876
+ for (const K of v)
1877
+ N.push({ id: K.id, type: "position", dragging: !0 });
1878
+ (X = (q = n.onNodesChangeRef).current) == null || X.call(q, N);
1877
1879
  const w = r.current;
1878
1880
  w && w.setPointerCapture(M.pointerId);
1879
- const N = (D) => {
1880
- var dt, Lt, ot, pt;
1881
+ const P = (K) => {
1882
+ var It, st, xt, Nt;
1881
1883
  if (!o.current) return;
1882
- const it = n.cameraRef.current, nt = E.getBoundingClientRect(), lt = (D.clientX - nt.left - it.x) / it.zoom, G = (D.clientY - nt.top - it.y) / it.zoom, j = lt - o.current.startMouse.x, st = G - o.current.startMouse.y;
1883
- let rt = { x: o.current.startPos.x + j, y: o.current.startPos.y + st };
1884
- if (n.snapToGrid && n.snapGrid && (rt = {
1885
- x: n.snapGrid[0] * Math.round(rt.x / n.snapGrid[0]),
1886
- y: n.snapGrid[1] * Math.round(rt.y / n.snapGrid[1])
1884
+ const at = n.cameraRef.current, rt = _.getBoundingClientRect(), G = (K.clientX - rt.left - at.x) / at.zoom, j = (K.clientY - rt.top - at.y) / at.zoom, it = G - o.current.startMouse.x, dt = j - o.current.startMouse.y;
1885
+ let ot = { x: o.current.startPos.x + it, y: o.current.startPos.y + dt };
1886
+ if (n.snapToGrid && n.snapGrid && (ot = {
1887
+ x: n.snapGrid[0] * Math.round(ot.x / n.snapGrid[0]),
1888
+ y: n.snapGrid[1] * Math.round(ot.y / n.snapGrid[1])
1887
1889
  }), t.parentId && t.extent === "parent") {
1888
- const vt = n.nodesRef.current.find((ht) => ht.id === t.parentId);
1889
- if (vt) {
1890
- const ht = vt.width || 160, bt = vt.height || 60, Et = t.width || ((dt = t.measured) == null ? void 0 : dt.width) || 160, kt = t.height || ((Lt = t.measured) == null ? void 0 : Lt.height) || 60;
1891
- rt = {
1892
- x: Math.max(0, Math.min(rt.x, ht - Et)),
1893
- y: Math.max(0, Math.min(rt.y, bt - kt))
1890
+ const gt = n.nodesRef.current.find((ct) => ct.id === t.parentId);
1891
+ if (gt) {
1892
+ const ct = gt.width || 160, zt = gt.height || 60, Rt = t.width || ((It = t.measured) == null ? void 0 : It.width) || 160, Lt = t.height || ((st = t.measured) == null ? void 0 : st.height) || 60;
1893
+ ot = {
1894
+ x: Math.max(0, Math.min(ot.x, ct - Rt)),
1895
+ y: Math.max(0, Math.min(ot.y, zt - Lt))
1894
1896
  };
1895
1897
  }
1896
1898
  }
1897
- const ut = [{ id: t.id, type: "position", position: rt, dragging: !0 }];
1898
- for (const vt of o.current.selectedStarts) {
1899
- let ht = { x: vt.startPos.x + j, y: vt.startPos.y + st };
1900
- n.snapToGrid && n.snapGrid && (ht = {
1901
- x: n.snapGrid[0] * Math.round(ht.x / n.snapGrid[0]),
1902
- y: n.snapGrid[1] * Math.round(ht.y / n.snapGrid[1])
1903
- }), ut.push({ id: vt.id, type: "position", position: ht, dragging: !0 });
1899
+ const ft = [{ id: t.id, type: "position", position: ot, dragging: !0 }];
1900
+ for (const gt of o.current.selectedStarts) {
1901
+ let ct = { x: gt.startPos.x + it, y: gt.startPos.y + dt };
1902
+ n.snapToGrid && n.snapGrid && (ct = {
1903
+ x: n.snapGrid[0] * Math.round(ct.x / n.snapGrid[0]),
1904
+ y: n.snapGrid[1] * Math.round(ct.y / n.snapGrid[1])
1905
+ }), ft.push({ id: gt.id, type: "position", position: ct, dragging: !0 });
1904
1906
  }
1905
- (pt = (ot = n.onNodesChangeRef).current) == null || pt.call(ot, ut);
1906
- }, P = (D) => {
1907
- var nt, lt;
1907
+ (Nt = (xt = n.onNodesChangeRef).current) == null || Nt.call(xt, ft);
1908
+ }, R = (K) => {
1909
+ var rt, G;
1908
1910
  if (!o.current) return;
1909
- const it = [{ id: t.id, type: "position", dragging: !1 }];
1910
- for (const G of o.current.selectedStarts)
1911
- it.push({ id: G.id, type: "position", dragging: !1 });
1912
- (lt = (nt = n.onNodesChangeRef).current) == null || lt.call(nt, it), o.current = null, w && w.releasePointerCapture(D.pointerId), w == null || w.removeEventListener("pointermove", N), w == null || w.removeEventListener("pointerup", P);
1911
+ const at = [{ id: t.id, type: "position", dragging: !1 }];
1912
+ for (const j of o.current.selectedStarts)
1913
+ at.push({ id: j.id, type: "position", dragging: !1 });
1914
+ (G = (rt = n.onNodesChangeRef).current) == null || G.call(rt, at), o.current = null, w && w.releasePointerCapture(K.pointerId), w == null || w.removeEventListener("pointermove", P), w == null || w.removeEventListener("pointerup", R);
1913
1915
  };
1914
- w == null || w.addEventListener("pointermove", N), w == null || w.addEventListener("pointerup", P);
1916
+ w == null || w.addEventListener("pointermove", P), w == null || w.addEventListener("pointerup", R);
1915
1917
  }, [t, n]), c = F((M) => {
1916
- var g, f, p, v, w, N;
1918
+ var g, f, p, v, N, w;
1917
1919
  if (!t.selected) return;
1918
1920
  const $ = M.shiftKey ? 10 : 1;
1919
- let z = 0, E = 0;
1921
+ let k = 0, E = 0;
1920
1922
  switch (M.key) {
1921
1923
  case "ArrowUp":
1922
1924
  E = -$;
@@ -1925,10 +1927,10 @@ function $r({ node: t, nodeType: e }) {
1925
1927
  E = $;
1926
1928
  break;
1927
1929
  case "ArrowLeft":
1928
- z = -$;
1930
+ k = -$;
1929
1931
  break;
1930
1932
  case "ArrowRight":
1931
- z = $;
1933
+ k = $;
1932
1934
  break;
1933
1935
  case "Escape":
1934
1936
  (f = (g = n.onNodesChangeRef).current) == null || f.call(g, [{ id: t.id, type: "select", selected: !1 }]);
@@ -1941,10 +1943,10 @@ function $r({ node: t, nodeType: e }) {
1941
1943
  return;
1942
1944
  }
1943
1945
  M.preventDefault();
1944
- const W = { x: t.position.x + z, y: t.position.y + E }, H = [{ id: t.id, type: "position", position: W }];
1946
+ const _ = { x: t.position.x + k, y: t.position.y + E }, D = [{ id: t.id, type: "position", position: _ }];
1945
1947
  for (const P of n.nodesRef.current)
1946
- P.selected && P.id !== t.id && H.push({ id: P.id, type: "position", position: { x: P.position.x + z, y: P.position.y + E } });
1947
- (N = (w = n.onNodesChangeRef).current) == null || N.call(w, H);
1948
+ P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y + E } });
1949
+ (w = (N = n.onNodesChangeRef).current) == null || w.call(N, D);
1948
1950
  }, [t, n]), u = t.width || ((m = t.measured) == null ? void 0 : m.width), l = t.height || ((C = t.measured) == null ? void 0 : C.height), y = !!(u && l);
1949
1951
  return /* @__PURE__ */ S(je.Provider, { value: t.id, children: /* @__PURE__ */ S(
1950
1952
  "div",
@@ -1965,7 +1967,7 @@ function $r({ node: t, nodeType: e }) {
1965
1967
  "data-nodeid": t.id,
1966
1968
  tabIndex: t.selectable !== !1 ? 0 : void 0,
1967
1969
  role: "button",
1968
- "aria-label": `Node ${((k = t.data) == null ? void 0 : k.label) || t.id}`,
1970
+ "aria-label": `Node ${((z = t.data) == null ? void 0 : z.label) || t.id}`,
1969
1971
  "aria-selected": !!t.selected,
1970
1972
  onPointerDown: i,
1971
1973
  onKeyDown: c,
@@ -2054,35 +2056,35 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
2054
2056
  }
2055
2057
  function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2056
2058
  var g, f, p;
2057
- const s = yt(), [o, i] = Gt(null), c = F((v, w, N, P) => {
2058
- var lt;
2059
- w.stopPropagation(), w.preventDefault();
2059
+ const s = yt(), [o, i] = Gt(null), c = F((v, N, w, P) => {
2060
+ var rt;
2061
+ N.stopPropagation(), N.preventDefault();
2060
2062
  const R = s.wrapRef.current;
2061
2063
  if (!R) return;
2062
- const B = v === "source" ? P : N, q = v === "source" ? t.target : t.source;
2063
- (lt = s.workerRef.current) == null || lt.postMessage({
2064
+ const B = v === "source" ? P : w, q = v === "source" ? t.target : t.source;
2065
+ (rt = s.workerRef.current) == null || rt.postMessage({
2064
2066
  type: "connecting",
2065
2067
  data: { from: { x: B.x, y: B.y }, to: { x: B.x, y: B.y } }
2066
2068
  });
2067
- const D = R.getBoundingClientRect(), it = (G) => {
2068
- var ut;
2069
- const j = s.cameraRef.current, st = (G.clientX - D.left - j.x) / j.zoom, rt = (G.clientY - D.top - j.y) / j.zoom;
2070
- (ut = s.workerRef.current) == null || ut.postMessage({
2069
+ const X = R.getBoundingClientRect(), K = (G) => {
2070
+ var ot;
2071
+ const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom;
2072
+ (ot = s.workerRef.current) == null || ot.postMessage({
2071
2073
  type: "connecting",
2072
- data: { from: { x: B.x, y: B.y }, to: { x: st, y: rt } }
2074
+ data: { from: { x: B.x, y: B.y }, to: { x: it, y: dt } }
2073
2075
  });
2074
- }, nt = (G) => {
2075
- var pt, vt, ht, bt;
2076
- const j = s.cameraRef.current, st = (G.clientX - D.left - j.x) / j.zoom, rt = (G.clientY - D.top - j.y) / j.zoom, ut = 20 / j.zoom;
2077
- let dt = null, Lt = null;
2078
- const ot = (pt = s.handleRegistryRef) == null ? void 0 : pt.current;
2079
- for (const Et of s.nodesRef.current) {
2080
- if (Et.hidden) continue;
2081
- const kt = Et.width || On, $t = Et.height || Qn, wt = Et._absolutePosition || Et.position, ne = [];
2082
- if (ot)
2083
- for (const [, Bt] of ot)
2084
- Bt.nodeId === Et.id && ne.push(Bt);
2085
- const Ie = ne.length > 0 ? ne : Et.handles || [
2076
+ }, at = (G) => {
2077
+ var xt, Nt, gt, ct;
2078
+ const j = s.cameraRef.current, it = (G.clientX - X.left - j.x) / j.zoom, dt = (G.clientY - X.top - j.y) / j.zoom, ot = 20 / j.zoom;
2079
+ let ft = null, It = null;
2080
+ const st = (xt = s.handleRegistryRef) == null ? void 0 : xt.current;
2081
+ for (const zt of s.nodesRef.current) {
2082
+ if (zt.hidden) continue;
2083
+ const Rt = zt.width || On, Lt = zt.height || Qn, wt = zt._absolutePosition || zt.position, ne = [];
2084
+ if (st)
2085
+ for (const [, Bt] of st)
2086
+ Bt.nodeId === zt.id && ne.push(Bt);
2087
+ const Ie = ne.length > 0 ? ne : zt.handles || [
2086
2088
  { type: "target", position: "left" },
2087
2089
  { type: "source", position: "right" }
2088
2090
  ];
@@ -2093,37 +2095,37 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2093
2095
  else
2094
2096
  switch (Bt.position || (Bt.type === "source" ? "right" : "left")) {
2095
2097
  case "top":
2096
- Ot = wt.x + kt / 2, Yt = wt.y;
2098
+ Ot = wt.x + Rt / 2, Yt = wt.y;
2097
2099
  break;
2098
2100
  case "bottom":
2099
- Ot = wt.x + kt / 2, Yt = wt.y + $t;
2101
+ Ot = wt.x + Rt / 2, Yt = wt.y + Lt;
2100
2102
  break;
2101
2103
  case "left":
2102
- Ot = wt.x, Yt = wt.y + $t / 2;
2104
+ Ot = wt.x, Yt = wt.y + Lt / 2;
2103
2105
  break;
2104
2106
  default:
2105
- Ot = wt.x + kt, Yt = wt.y + $t / 2;
2107
+ Ot = wt.x + Rt, Yt = wt.y + Lt / 2;
2106
2108
  break;
2107
2109
  }
2108
- if (Math.abs(st - Ot) < ut && Math.abs(rt - Yt) < ut) {
2109
- dt = Et, Lt = Bt.id || null;
2110
+ if (Math.abs(it - Ot) < ot && Math.abs(dt - Yt) < ot) {
2111
+ ft = zt, It = Bt.id || null;
2110
2112
  break;
2111
2113
  }
2112
2114
  }
2113
- if (dt) break;
2115
+ if (ft) break;
2114
2116
  }
2115
- if (dt) {
2116
- const Et = v === "source" ? { source: dt.id, target: q, sourceHandle: Lt, targetHandle: t.targetHandle } : { source: q, target: dt.id, sourceHandle: t.sourceHandle, targetHandle: Lt };
2117
- (ht = (vt = s.onEdgesChangeRef).current) == null || ht.call(vt, [
2117
+ if (ft) {
2118
+ const zt = v === "source" ? { source: ft.id, target: q, sourceHandle: It, targetHandle: t.targetHandle } : { source: q, target: ft.id, sourceHandle: t.sourceHandle, targetHandle: It };
2119
+ (gt = (Nt = s.onEdgesChangeRef).current) == null || gt.call(Nt, [
2118
2120
  { id: t.id, type: "remove" },
2119
- { type: "add", item: { id: t.id, ...Et } }
2121
+ { type: "add", item: { id: t.id, ...zt } }
2120
2122
  ]);
2121
2123
  }
2122
- (bt = s.workerRef.current) == null || bt.postMessage({ type: "connecting", data: null }), R.removeEventListener("pointermove", it), R.removeEventListener("pointerup", nt);
2124
+ (ct = s.workerRef.current) == null || ct.postMessage({ type: "connecting", data: null }), R.removeEventListener("pointermove", K), R.removeEventListener("pointerup", at);
2123
2125
  };
2124
- R.addEventListener("pointermove", it), R.addEventListener("pointerup", nt);
2125
- }, [t, s]), u = n.find((v) => v.id === t.source), l = n.find((v) => v.id === t.target), y = u && !!(u.width || (g = u.measured) != null && g.width), m = l && !!(l.width || (f = l.measured) != null && f.width), C = (p = s.handleRegistryRef) == null ? void 0 : p.current, k = y ? Bn(u, "source", t.sourceHandle, C) : null, M = m ? Bn(l, "target", t.targetHandle, C) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", z = s.routedEdges || s.edges, E = z == null ? void 0 : z.find((v) => v.id === t.id), W = $ ? null : (E == null ? void 0 : E._routedPoints) || t._routedPoints || null, H = r !== !1 && t.reconnectable !== !1;
2126
- return !k || !M ? null : /* @__PURE__ */ It(
2126
+ R.addEventListener("pointermove", K), R.addEventListener("pointerup", at);
2127
+ }, [t, s]), u = n.find((v) => v.id === t.source), l = n.find((v) => v.id === t.target), y = u && !!(u.width || (g = u.measured) != null && g.width), m = l && !!(l.width || (f = l.measured) != null && f.width), C = (p = s.handleRegistryRef) == null ? void 0 : p.current, z = y ? Bn(u, "source", t.sourceHandle, C) : null, M = m ? Bn(l, "target", t.targetHandle, C) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, E = k == null ? void 0 : k.find((v) => v.id === t.id), _ = $ ? null : (E == null ? void 0 : E._routedPoints) || t._routedPoints || null, D = r !== !1 && t.reconnectable !== !1;
2128
+ return !z || !M ? null : /* @__PURE__ */ $t(
2127
2129
  "g",
2128
2130
  {
2129
2131
  className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
@@ -2137,11 +2139,11 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2137
2139
  id: t.id,
2138
2140
  source: t.source,
2139
2141
  target: t.target,
2140
- sourceX: k.x,
2141
- sourceY: k.y,
2142
+ sourceX: z.x,
2143
+ sourceY: z.y,
2142
2144
  targetX: M.x,
2143
2145
  targetY: M.y,
2144
- sourcePosition: k.position,
2146
+ sourcePosition: z.position,
2145
2147
  targetPosition: M.position,
2146
2148
  sourceHandleId: t.sourceHandle,
2147
2149
  targetHandleId: t.targetHandle,
@@ -2153,18 +2155,18 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2153
2155
  style: t.style,
2154
2156
  selectable: t.selectable !== !1,
2155
2157
  deletable: t.deletable !== !1,
2156
- routedPoints: W
2158
+ routedPoints: _
2157
2159
  }
2158
2160
  ),
2159
- H && (o || t.selected) && /* @__PURE__ */ It(Le, { children: [
2161
+ D && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
2160
2162
  /* @__PURE__ */ S(
2161
2163
  Dn,
2162
2164
  {
2163
- x: k.x,
2164
- y: k.y,
2165
- position: k.position,
2165
+ x: z.x,
2166
+ y: z.y,
2167
+ position: z.position,
2166
2168
  type: "source",
2167
- onPointerDown: (v) => c("source", v, k, M)
2169
+ onPointerDown: (v) => c("source", v, z, M)
2168
2170
  }
2169
2171
  ),
2170
2172
  /* @__PURE__ */ S(
@@ -2174,7 +2176,7 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2174
2176
  y: M.y,
2175
2177
  position: M.position,
2176
2178
  type: "target",
2177
- onPointerDown: (v) => c("target", v, k, M)
2179
+ onPointerDown: (v) => c("target", v, z, M)
2178
2180
  }
2179
2181
  )
2180
2182
  ] })
@@ -2185,48 +2187,48 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2185
2187
  const Dr = Zt(Br);
2186
2188
  function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
2187
2189
  var $;
2188
- const n = yt(), [r, s] = Gt(null), o = V(null);
2189
- if (ft(() => {
2190
- const z = n.wrapRef.current;
2191
- if (!z) return;
2192
- let E = !1, W = null, H = !1;
2193
- const g = (N) => {
2194
- N.key === t && (H = !0);
2195
- }, f = (N) => {
2196
- N.key === t && (H = !1);
2197
- }, p = (N) => {
2198
- if (!H) return;
2199
- const P = N.target;
2190
+ const n = yt(), [r, s] = Gt(null), o = tt(null);
2191
+ if (ht(() => {
2192
+ const k = n.wrapRef.current;
2193
+ if (!k) return;
2194
+ let E = !1, _ = null, D = !1;
2195
+ const g = (w) => {
2196
+ w.key === t && (D = !0);
2197
+ }, f = (w) => {
2198
+ w.key === t && (D = !1);
2199
+ }, p = (w) => {
2200
+ if (!D) return;
2201
+ const P = w.target;
2200
2202
  if (P.closest(".ric-node-wrapper") || P.closest(".ric-handle")) return;
2201
2203
  E = !0;
2202
- const R = n.cameraRef.current, B = z.getBoundingClientRect(), q = (N.clientX - B.left - R.x) / R.zoom, D = (N.clientY - B.top - R.y) / R.zoom;
2203
- W = { x: q, y: D }, s({ startX: q, startY: D, endX: q, endY: D }), N.stopPropagation();
2204
- }, v = (N) => {
2205
- if (!E || !W) return;
2206
- const P = n.cameraRef.current, R = z.getBoundingClientRect(), B = (N.clientX - R.left - P.x) / P.zoom, q = (N.clientY - R.top - P.y) / P.zoom;
2207
- s({ startX: W.x, startY: W.y, endX: B, endY: q });
2208
- }, w = (N) => {
2209
- var nt, lt;
2210
- if (!E || !W) return;
2204
+ const R = n.cameraRef.current, B = k.getBoundingClientRect(), q = (w.clientX - B.left - R.x) / R.zoom, X = (w.clientY - B.top - R.y) / R.zoom;
2205
+ _ = { x: q, y: X }, s({ startX: q, startY: X, endX: q, endY: X }), w.stopPropagation();
2206
+ }, v = (w) => {
2207
+ if (!E || !_) return;
2208
+ const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom;
2209
+ s({ startX: _.x, startY: _.y, endX: B, endY: q });
2210
+ }, N = (w) => {
2211
+ var at, rt;
2212
+ if (!E || !_) return;
2211
2213
  E = !1;
2212
- const P = n.cameraRef.current, R = z.getBoundingClientRect(), B = (N.clientX - R.left - P.x) / P.zoom, q = (N.clientY - R.top - P.y) / P.zoom, D = {
2213
- x: Math.min(W.x, B),
2214
- y: Math.min(W.y, q),
2215
- width: Math.abs(B - W.x),
2216
- height: Math.abs(q - W.y)
2217
- }, it = [];
2214
+ const P = n.cameraRef.current, R = k.getBoundingClientRect(), B = (w.clientX - R.left - P.x) / P.zoom, q = (w.clientY - R.top - P.y) / P.zoom, X = {
2215
+ x: Math.min(_.x, B),
2216
+ y: Math.min(_.y, q),
2217
+ width: Math.abs(B - _.x),
2218
+ height: Math.abs(q - _.y)
2219
+ }, K = [];
2218
2220
  for (const G of n.nodesRef.current) {
2219
- const j = G._absolutePosition || G.position, st = G.width || 160, rt = G.height || 60;
2220
- let ut;
2221
- e === "full" ? ut = j.x >= D.x && j.y >= D.y && j.x + st <= D.x + D.width && j.y + rt <= D.y + D.height : ut = j.x + st > D.x && j.x < D.x + D.width && j.y + rt > D.y && j.y < D.y + D.height, it.push({ id: G.id, type: "select", selected: ut });
2221
+ const j = G._absolutePosition || G.position, it = G.width || 160, dt = G.height || 60;
2222
+ let ot;
2223
+ e === "full" ? ot = j.x >= X.x && j.y >= X.y && j.x + it <= X.x + X.width && j.y + dt <= X.y + X.height : ot = j.x + it > X.x && j.x < X.x + X.width && j.y + dt > X.y && j.y < X.y + X.height, K.push({ id: G.id, type: "select", selected: ot });
2222
2224
  }
2223
- it.length && ((lt = (nt = n.onNodesChangeRef).current) == null || lt.call(nt, it)), W = null, s(null);
2225
+ K.length && ((rt = (at = n.onNodesChangeRef).current) == null || rt.call(at, K)), _ = null, s(null);
2224
2226
  };
2225
- return z.addEventListener("pointerdown", p, !0), z.addEventListener("pointermove", v), z.addEventListener("pointerup", w), window.addEventListener("keydown", g), window.addEventListener("keyup", f), () => {
2226
- z.removeEventListener("pointerdown", p, !0), z.removeEventListener("pointermove", v), z.removeEventListener("pointerup", w), window.removeEventListener("keydown", g), window.removeEventListener("keyup", f);
2227
+ return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove", v), k.addEventListener("pointerup", N), window.addEventListener("keydown", g), window.addEventListener("keyup", f), () => {
2228
+ k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove", v), k.removeEventListener("pointerup", N), window.removeEventListener("keydown", g), window.removeEventListener("keyup", f);
2227
2229
  };
2228
2230
  }, [n, t, e]), !r) return null;
2229
- const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), y = Math.abs(r.endY - r.startY), m = c * i.zoom + i.x, C = u * i.zoom + i.y, k = l * i.zoom, M = y * i.zoom;
2231
+ const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), y = Math.abs(r.endY - r.startY), m = c * i.zoom + i.x, C = u * i.zoom + i.y, z = l * i.zoom, M = y * i.zoom;
2230
2232
  return /* @__PURE__ */ S(
2231
2233
  "div",
2232
2234
  {
@@ -2236,7 +2238,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
2236
2238
  position: "absolute",
2237
2239
  left: m,
2238
2240
  top: C,
2239
- width: k,
2241
+ width: z,
2240
2242
  height: M,
2241
2243
  border: "1px dashed #3b82f6",
2242
2244
  background: "rgba(59, 130, 246, 0.08)",
@@ -2247,7 +2249,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
2247
2249
  );
2248
2250
  }
2249
2251
  Kn.displayName = "SelectionBox";
2250
- const Hr = Zt(Kn);
2252
+ const Ar = Zt(Kn);
2251
2253
  function Jn(t, e) {
2252
2254
  var s, o, i, c;
2253
2255
  const n = (s = t.handleRegistryRef) == null ? void 0 : s.current;
@@ -2263,12 +2265,12 @@ function Jn(t, e) {
2263
2265
  ]), (c = t.syncNodesToWorker) == null || c.call(t);
2264
2266
  }
2265
2267
  const vn = /* @__PURE__ */ new Set();
2266
- function Hn(t, e) {
2268
+ function An(t, e) {
2267
2269
  vn.has(e) || (vn.add(e), queueMicrotask(() => {
2268
2270
  vn.delete(e), Jn(t, e);
2269
2271
  }));
2270
2272
  }
2271
- function Ar(t, e) {
2273
+ function Hr(t, e) {
2272
2274
  const n = t.closest(".ric-node-wrapper");
2273
2275
  if (!n) return null;
2274
2276
  const r = n.getBoundingClientRect(), s = t.getBoundingClientRect(), o = e || 1;
@@ -2290,128 +2292,128 @@ function on({
2290
2292
  onConnect: l,
2291
2293
  ...y
2292
2294
  }) {
2293
- const m = qe(je), C = yt(), k = V(null), M = V(C);
2295
+ const m = qe(je), C = yt(), z = tt(null), M = tt(C);
2294
2296
  M.current = C;
2295
2297
  const $ = F(() => {
2296
- var N, P, R;
2297
- const H = k.current;
2298
- if (!H || !m) return;
2299
- const g = M.current, f = (N = g.handleRegistryRef) == null ? void 0 : N.current;
2298
+ var w, P, R;
2299
+ const D = z.current;
2300
+ if (!D || !m) return;
2301
+ const g = M.current, f = (w = g.handleRegistryRef) == null ? void 0 : w.current;
2300
2302
  if (!f) return;
2301
- const p = `${m}__${n || t}`, v = (R = (P = g.cameraRef) == null ? void 0 : P.current) == null ? void 0 : R.zoom, w = Ar(H, v);
2302
- if (w) {
2303
- const B = { nodeId: m, id: n || null, type: t, position: e, x: w.x, y: w.y };
2303
+ const p = `${m}__${n || t}`, v = (R = (P = g.cameraRef) == null ? void 0 : P.current) == null ? void 0 : R.zoom, N = Hr(D, v);
2304
+ if (N) {
2305
+ const B = { nodeId: m, id: n || null, type: t, position: e, x: N.x, y: N.y };
2304
2306
  f.set(p, B);
2305
2307
  }
2306
2308
  }, [m, n, t, e]);
2307
2309
  kr(() => {
2308
2310
  $();
2309
- }, [$]), ft(() => {
2311
+ }, [$]), ht(() => {
2310
2312
  if (!m) return;
2311
- const H = M.current;
2312
- Hn(H, m);
2313
- const g = k.current, f = g == null ? void 0 : g.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
2314
- $(), Hn(M.current, m);
2313
+ const D = M.current;
2314
+ An(D, m);
2315
+ const g = z.current, f = g == null ? void 0 : g.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
2316
+ $(), An(M.current, m);
2315
2317
  });
2316
2318
  return f && p.observe(f), () => {
2317
2319
  var P;
2318
2320
  p.disconnect();
2319
- const v = M.current, w = (P = v.handleRegistryRef) == null ? void 0 : P.current, N = `${m}__${n || t}`;
2320
- w == null || w.delete(N), Jn(v, m);
2321
+ const v = M.current, N = (P = v.handleRegistryRef) == null ? void 0 : P.current, w = `${m}__${n || t}`;
2322
+ N == null || N.delete(w), Jn(v, m);
2321
2323
  };
2322
2324
  }, [m, n, t, e, $]);
2323
- const z = F(() => {
2325
+ const k = F(() => {
2324
2326
  var R;
2325
- const H = M.current, g = H.nodesRef.current.find((B) => B.id === m);
2327
+ const D = M.current, g = D.nodesRef.current.find((B) => B.id === m);
2326
2328
  if (!g) return null;
2327
- const f = g._absolutePosition || g.position, p = (R = H.handleRegistryRef) == null ? void 0 : R.current, v = `${m}__${n || t}`, w = p == null ? void 0 : p.get(v);
2328
- if (w && w.x !== void 0 && w.y !== void 0)
2329
- return { x: f.x + w.x, y: f.y + w.y };
2330
- const N = g.width || 160, P = g.height || 60;
2329
+ const f = g._absolutePosition || g.position, p = (R = D.handleRegistryRef) == null ? void 0 : R.current, v = `${m}__${n || t}`, N = p == null ? void 0 : p.get(v);
2330
+ if (N && N.x !== void 0 && N.y !== void 0)
2331
+ return { x: f.x + N.x, y: f.y + N.y };
2332
+ const w = g.width || 160, P = g.height || 60;
2331
2333
  switch (e) {
2332
2334
  case "top":
2333
- return { x: f.x + N / 2, y: f.y };
2335
+ return { x: f.x + w / 2, y: f.y };
2334
2336
  case "bottom":
2335
- return { x: f.x + N / 2, y: f.y + P };
2337
+ return { x: f.x + w / 2, y: f.y + P };
2336
2338
  case "left":
2337
2339
  return { x: f.x, y: f.y + P / 2 };
2338
2340
  default:
2339
- return { x: f.x + N, y: f.y + P / 2 };
2341
+ return { x: f.x + w, y: f.y + P / 2 };
2340
2342
  }
2341
- }, [m, n, t, e]), E = F((H) => {
2343
+ }, [m, n, t, e]), E = F((D) => {
2342
2344
  var q;
2343
2345
  if (!r || !s) return;
2344
- H.stopPropagation(), H.preventDefault();
2346
+ D.stopPropagation(), D.preventDefault();
2345
2347
  const g = M.current, f = g.cameraRef.current, p = g.wrapRef.current;
2346
2348
  if (!p) return;
2347
- const v = p.getBoundingClientRect(), w = z();
2348
- if (!w) return;
2349
- const N = w.x, P = w.y;
2349
+ const v = p.getBoundingClientRect(), N = k();
2350
+ if (!N) return;
2351
+ const w = N.x, P = N.y;
2350
2352
  (q = g.workerRef.current) == null || q.postMessage({
2351
2353
  type: "connecting",
2352
- data: { from: { x: N, y: P }, to: { x: N, y: P } }
2353
- }), p.setPointerCapture(H.pointerId);
2354
- const R = (D) => {
2355
- var lt;
2356
- const it = (D.clientX - v.left - f.x) / f.zoom, nt = (D.clientY - v.top - f.y) / f.zoom;
2357
- (lt = g.workerRef.current) == null || lt.postMessage({
2354
+ data: { from: { x: w, y: P }, to: { x: w, y: P } }
2355
+ }), p.setPointerCapture(D.pointerId);
2356
+ const R = (X) => {
2357
+ var rt;
2358
+ const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom;
2359
+ (rt = g.workerRef.current) == null || rt.postMessage({
2358
2360
  type: "connecting",
2359
- data: { from: { x: N, y: P }, to: { x: it, y: nt } }
2361
+ data: { from: { x: w, y: P }, to: { x: K, y: at } }
2360
2362
  });
2361
- }, B = (D) => {
2362
- var rt, ut, dt, Lt;
2363
- const it = (D.clientX - v.left - f.x) / f.zoom, nt = (D.clientY - v.top - f.y) / f.zoom, lt = 20 / f.zoom;
2363
+ }, B = (X) => {
2364
+ var dt, ot, ft, It;
2365
+ const K = (X.clientX - v.left - f.x) / f.zoom, at = (X.clientY - v.top - f.y) / f.zoom, rt = 20 / f.zoom;
2364
2366
  let G = null, j = null;
2365
- const st = (rt = g.handleRegistryRef) == null ? void 0 : rt.current;
2366
- for (const ot of g.nodesRef.current) {
2367
- if (ot.id === m || ot.hidden) continue;
2368
- const pt = ot.width || 160, vt = ot.height || 60, ht = ot._absolutePosition || ot.position, bt = [];
2369
- if (st)
2370
- for (const [, kt] of st)
2371
- kt.nodeId === ot.id && bt.push(kt);
2372
- const Et = bt.length > 0 ? bt : ot.handles || [
2367
+ const it = (dt = g.handleRegistryRef) == null ? void 0 : dt.current;
2368
+ for (const st of g.nodesRef.current) {
2369
+ if (st.id === m || st.hidden) continue;
2370
+ const xt = st.width || 160, Nt = st.height || 60, gt = st._absolutePosition || st.position, ct = [];
2371
+ if (it)
2372
+ for (const [, Rt] of it)
2373
+ Rt.nodeId === st.id && ct.push(Rt);
2374
+ const zt = ct.length > 0 ? ct : st.handles || [
2373
2375
  { type: "target", position: "left" },
2374
2376
  { type: "source", position: "right" }
2375
2377
  ];
2376
- for (const kt of Et) {
2377
- let $t, wt;
2378
- if (kt.x !== void 0 && kt.y !== void 0)
2379
- $t = ht.x + kt.x, wt = ht.y + kt.y;
2378
+ for (const Rt of zt) {
2379
+ let Lt, wt;
2380
+ if (Rt.x !== void 0 && Rt.y !== void 0)
2381
+ Lt = gt.x + Rt.x, wt = gt.y + Rt.y;
2380
2382
  else
2381
- switch (kt.position || (kt.type === "source" ? "right" : "left")) {
2383
+ switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
2382
2384
  case "top":
2383
- $t = ht.x + pt / 2, wt = ht.y;
2385
+ Lt = gt.x + xt / 2, wt = gt.y;
2384
2386
  break;
2385
2387
  case "bottom":
2386
- $t = ht.x + pt / 2, wt = ht.y + vt;
2388
+ Lt = gt.x + xt / 2, wt = gt.y + Nt;
2387
2389
  break;
2388
2390
  case "left":
2389
- $t = ht.x, wt = ht.y + vt / 2;
2391
+ Lt = gt.x, wt = gt.y + Nt / 2;
2390
2392
  break;
2391
2393
  default:
2392
- $t = ht.x + pt, wt = ht.y + vt / 2;
2394
+ Lt = gt.x + xt, wt = gt.y + Nt / 2;
2393
2395
  break;
2394
2396
  }
2395
- if (Math.abs(it - $t) < lt && Math.abs(nt - wt) < lt) {
2396
- G = ot, j = kt.id || null;
2397
+ if (Math.abs(K - Lt) < rt && Math.abs(at - wt) < rt) {
2398
+ G = st, j = Rt.id || null;
2397
2399
  break;
2398
2400
  }
2399
2401
  }
2400
2402
  if (G) break;
2401
2403
  }
2402
2404
  if (G) {
2403
- const ot = {
2405
+ const st = {
2404
2406
  source: t === "source" ? m : G.id,
2405
2407
  target: t === "source" ? G.id : m,
2406
2408
  sourceHandle: t === "source" ? n || null : j,
2407
2409
  targetHandle: t === "source" ? j : n || null
2408
2410
  };
2409
- (dt = (ut = g.onEdgesChangeRef) == null ? void 0 : ut.current) == null || dt.call(ut, [{ type: "add", item: { id: `e-${ot.source}-${ot.target}`, ...ot } }]);
2411
+ (ft = (ot = g.onEdgesChangeRef) == null ? void 0 : ot.current) == null || ft.call(ot, [{ type: "add", item: { id: `e-${st.source}-${st.target}`, ...st } }]);
2410
2412
  }
2411
- (Lt = g.workerRef.current) == null || Lt.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", R), p.removeEventListener("pointerup", B);
2413
+ (It = g.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", R), p.removeEventListener("pointerup", B);
2412
2414
  };
2413
2415
  p.addEventListener("pointermove", R), p.addEventListener("pointerup", B);
2414
- }, [m, n, t, e, r, s, z]), W = {
2416
+ }, [m, n, t, e, r, s, k]), _ = {
2415
2417
  top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
2416
2418
  bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
2417
2419
  left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
@@ -2420,7 +2422,7 @@ function on({
2420
2422
  return /* @__PURE__ */ S(
2421
2423
  "div",
2422
2424
  {
2423
- ref: k,
2425
+ ref: z,
2424
2426
  className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
2425
2427
  "data-handleid": n || null,
2426
2428
  "data-nodeid": m,
@@ -2437,7 +2439,7 @@ function on({
2437
2439
  zIndex: 10,
2438
2440
  cursor: r ? "crosshair" : "default",
2439
2441
  boxSizing: "border-box",
2440
- ...W,
2442
+ ..._,
2441
2443
  ...u
2442
2444
  },
2443
2445
  ...y,
@@ -2454,7 +2456,7 @@ function ko({
2454
2456
  hideSourceHandle: o = !1,
2455
2457
  hideTargetHandle: i = !1
2456
2458
  }) {
2457
- return /* @__PURE__ */ It(
2459
+ return /* @__PURE__ */ $t(
2458
2460
  "div",
2459
2461
  {
2460
2462
  className: `ric-default-node${n ? " selected" : ""}`,
@@ -2483,7 +2485,7 @@ function _r({
2483
2485
  sourcePosition: r = "right",
2484
2486
  hideSourceHandle: s = !1
2485
2487
  }) {
2486
- return /* @__PURE__ */ It(
2488
+ return /* @__PURE__ */ $t(
2487
2489
  "div",
2488
2490
  {
2489
2491
  className: `ric-input-node${n ? " selected" : ""}`,
@@ -2512,7 +2514,7 @@ function Wr({
2512
2514
  targetPosition: r = "left",
2513
2515
  hideTargetHandle: s = !1
2514
2516
  }) {
2515
- return /* @__PURE__ */ It(
2517
+ return /* @__PURE__ */ $t(
2516
2518
  "div",
2517
2519
  {
2518
2520
  className: `ric-output-node${n ? " selected" : ""}`,
@@ -2576,10 +2578,10 @@ function Vn({
2576
2578
  className: l = "",
2577
2579
  ...y
2578
2580
  }) {
2579
- const [m, C] = Gt({ x: 1, y: 0, width: 0, height: 0 }), k = V(null);
2580
- return ft(() => {
2581
- if (k.current) {
2582
- const M = k.current.getBBox();
2581
+ const [m, C] = Gt({ x: 1, y: 0, width: 0, height: 0 }), z = tt(null);
2582
+ return ht(() => {
2583
+ if (z.current) {
2584
+ const M = z.current.getBBox();
2583
2585
  C({
2584
2586
  x: M.x,
2585
2587
  y: M.y,
@@ -2587,7 +2589,7 @@ function Vn({
2587
2589
  height: M.height
2588
2590
  });
2589
2591
  }
2590
- }, [n]), n ? /* @__PURE__ */ It(
2592
+ }, [n]), n ? /* @__PURE__ */ $t(
2591
2593
  "g",
2592
2594
  {
2593
2595
  transform: `translate(${t - m.width / 2} ${e - m.height / 2})`,
@@ -2614,7 +2616,7 @@ function Vn({
2614
2616
  className: "ric-edge-text",
2615
2617
  y: m.height / 2,
2616
2618
  dy: "0.3em",
2617
- ref: k,
2619
+ ref: z,
2618
2620
  style: r,
2619
2621
  children: n
2620
2622
  }
@@ -2626,7 +2628,7 @@ function Vn({
2626
2628
  }
2627
2629
  Vn.displayName = "EdgeText";
2628
2630
  const Fr = Zt(Vn);
2629
- function An(t) {
2631
+ function Hn(t) {
2630
2632
  return t != null && t !== "" && !isNaN(Number(t));
2631
2633
  }
2632
2634
  function un({
@@ -2643,11 +2645,11 @@ function un({
2643
2645
  interactionWidth: y = 20,
2644
2646
  style: m,
2645
2647
  markerEnd: C,
2646
- markerStart: k,
2648
+ markerStart: z,
2647
2649
  className: M = "",
2648
2650
  ...$
2649
2651
  }) {
2650
- return /* @__PURE__ */ It(Le, { children: [
2652
+ return /* @__PURE__ */ $t(Le, { children: [
2651
2653
  /* @__PURE__ */ S(
2652
2654
  "path",
2653
2655
  {
@@ -2659,7 +2661,7 @@ function un({
2659
2661
  className: `ric-edge-path ${M}`,
2660
2662
  style: m,
2661
2663
  markerEnd: C,
2662
- markerStart: k,
2664
+ markerStart: z,
2663
2665
  ...$
2664
2666
  }
2665
2667
  ),
@@ -2674,7 +2676,7 @@ function un({
2674
2676
  style: { pointerEvents: "stroke" }
2675
2677
  }
2676
2678
  ) : null,
2677
- s && An(n) && An(r) ? /* @__PURE__ */ S(
2679
+ s && Hn(n) && Hn(r) ? /* @__PURE__ */ S(
2678
2680
  Fr,
2679
2681
  {
2680
2682
  x: n,
@@ -2717,61 +2719,61 @@ const tr = Zt(function({
2717
2719
  labelShowBg: y,
2718
2720
  labelBgStyle: m,
2719
2721
  labelBgPadding: C,
2720
- labelBgBorderRadius: k,
2722
+ labelBgBorderRadius: z,
2721
2723
  style: M,
2722
2724
  markerEnd: $,
2723
- markerStart: z,
2725
+ markerStart: k,
2724
2726
  interactionWidth: E
2725
2727
  }) {
2726
- let W, H, g;
2727
- const f = _n(n, r, i), p = _n(s, o, c), v = Math.abs(p.x - f.x), w = Math.max(50, v * 0.5);
2728
- let N, P, R, B;
2728
+ let _, D, g;
2729
+ const f = _n(n, r, i), p = _n(s, o, c), v = Math.abs(p.x - f.x), N = Math.max(50, v * 0.5);
2730
+ let w, P, R, B;
2729
2731
  switch (i) {
2730
2732
  case "left":
2731
- N = f.x - w, P = f.y;
2733
+ w = f.x - N, P = f.y;
2732
2734
  break;
2733
2735
  case "top":
2734
- N = f.x, P = f.y - w;
2736
+ w = f.x, P = f.y - N;
2735
2737
  break;
2736
2738
  case "bottom":
2737
- N = f.x, P = f.y + w;
2739
+ w = f.x, P = f.y + N;
2738
2740
  break;
2739
2741
  default:
2740
- N = f.x + w, P = f.y;
2742
+ w = f.x + N, P = f.y;
2741
2743
  break;
2742
2744
  }
2743
2745
  switch (c) {
2744
2746
  case "right":
2745
- R = p.x + w, B = p.y;
2747
+ R = p.x + N, B = p.y;
2746
2748
  break;
2747
2749
  case "top":
2748
- R = p.x, B = p.y - w;
2750
+ R = p.x, B = p.y - N;
2749
2751
  break;
2750
2752
  case "bottom":
2751
- R = p.x, B = p.y + w;
2753
+ R = p.x, B = p.y + N;
2752
2754
  break;
2753
2755
  default:
2754
- R = p.x - w, B = p.y;
2756
+ R = p.x - N, B = p.y;
2755
2757
  break;
2756
2758
  }
2757
- W = `M ${n},${r} L ${f.x},${f.y} C ${N},${P} ${R},${B} ${p.x},${p.y} L ${s},${o}`;
2758
- const q = 0.5, D = 0.5;
2759
- return H = D * D * D * f.x + 3 * D * D * q * N + 3 * D * q * q * R + q * q * q * p.x, g = D * D * D * f.y + 3 * D * D * q * P + 3 * D * q * q * B + q * q * q * p.y, /* @__PURE__ */ S(
2759
+ _ = `M ${n},${r} L ${f.x},${f.y} C ${w},${P} ${R},${B} ${p.x},${p.y} L ${s},${o}`;
2760
+ const q = 0.5, X = 0.5;
2761
+ return D = X * X * X * f.x + 3 * X * X * q * w + 3 * X * q * q * R + q * q * q * p.x, g = X * X * X * f.y + 3 * X * X * q * P + 3 * X * q * q * B + q * q * q * p.y, /* @__PURE__ */ S(
2760
2762
  un,
2761
2763
  {
2762
2764
  id: e,
2763
- path: W,
2764
- labelX: H,
2765
+ path: _,
2766
+ labelX: D,
2765
2767
  labelY: g,
2766
2768
  label: u,
2767
2769
  labelStyle: l,
2768
2770
  labelShowBg: y,
2769
2771
  labelBgStyle: m,
2770
2772
  labelBgPadding: C,
2771
- labelBgBorderRadius: k,
2773
+ labelBgBorderRadius: z,
2772
2774
  style: M,
2773
2775
  markerEnd: $,
2774
- markerStart: z,
2776
+ markerStart: k,
2775
2777
  interactionWidth: E
2776
2778
  }
2777
2779
  );
@@ -2791,7 +2793,7 @@ function nr({
2791
2793
  curvature: i = 0.25
2792
2794
  }) {
2793
2795
  const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), y = Math.max(l * i, 50);
2794
- let m, C, k, M;
2796
+ let m, C, z, M;
2795
2797
  switch (s) {
2796
2798
  case "top":
2797
2799
  m = t, C = e - y;
@@ -2808,20 +2810,20 @@ function nr({
2808
2810
  }
2809
2811
  switch (o) {
2810
2812
  case "top":
2811
- k = n, M = r - y;
2813
+ z = n, M = r - y;
2812
2814
  break;
2813
2815
  case "bottom":
2814
- k = n, M = r + y;
2816
+ z = n, M = r + y;
2815
2817
  break;
2816
2818
  case "right":
2817
- k = n + y, M = r;
2819
+ z = n + y, M = r;
2818
2820
  break;
2819
2821
  default:
2820
- k = n - y, M = r;
2822
+ z = n - y, M = r;
2821
2823
  break;
2822
2824
  }
2823
- const $ = `M ${t},${e} C ${m},${C} ${k},${M} ${n},${r}`, z = 0.5, E = 1 - z, W = E * E * E * t + 3 * E * E * z * m + 3 * E * z * z * k + z * z * z * n, H = E * E * E * e + 3 * E * E * z * C + 3 * E * z * z * M + z * z * z * r;
2824
- return [$, W, H, 0, 0];
2825
+ const $ = `M ${t},${e} C ${m},${C} ${z},${M} ${n},${r}`, k = 0.5, E = 1 - k, _ = E * E * E * t + 3 * E * E * k * m + 3 * E * k * k * z + k * k * k * n, D = E * E * E * e + 3 * E * E * k * C + 3 * E * k * k * M + k * k * k * r;
2826
+ return [$, _, D, 0, 0];
2825
2827
  }
2826
2828
  function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
2827
2829
  const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5, y = 0.5, m = y * y * y * t + 3 * y * y * l * i + 3 * y * l * l * c + l * l * l * n, C = y * y * y * e + 3 * y * y * l * e + 3 * y * l * l * r + l * l * l * r;
@@ -2841,8 +2843,8 @@ function kn({
2841
2843
  if (u) {
2842
2844
  if (Math.abs(r - e) < 1)
2843
2845
  return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
2844
- const k = (t + n) / 2, M = r > e ? 1 : -1;
2845
- return [`M ${t},${e} L ${k - l},${e} Q ${k},${e} ${k},${e + M * l} L ${k},${r - M * l} Q ${k},${r} ${k + (n > k ? l : -l)},${r} L ${n},${r}`, k, (e + r) / 2, 0, 0];
2846
+ const z = (t + n) / 2, M = r > e ? 1 : -1;
2847
+ return [`M ${t},${e} L ${z - l},${e} Q ${z},${e} ${z},${e + M * l} L ${z},${r - M * l} Q ${z},${r} ${z + (n > z ? l : -l)},${r} L ${n},${r}`, z, (e + r) / 2, 0, 0];
2846
2848
  }
2847
2849
  const y = (e + r) / 2, m = n > t ? 1 : -1;
2848
2850
  return [`M ${t},${e} L ${t},${y - l} Q ${t},${y} ${t + m * l},${y} L ${n - m * l},${y} Q ${n},${y} ${n},${y + (r > y ? l : -l)} L ${n},${r}`, (t + n) / 2, y, 0, 0];
@@ -2907,11 +2909,11 @@ function Yr(t, e, n, r, s, o, i, c) {
2907
2909
  if (l <= s || u >= s + i || m <= o || y >= o + c) return !1;
2908
2910
  const C = 0.5;
2909
2911
  if (t > s + C && t < s + i - C && e > o + C && e < o + c - C || n > s + C && n < s + i - C && r > o + C && r < o + c - C) return !0;
2910
- const k = (t + n) / 2, M = (e + r) / 2;
2911
- if (k > s + C && k < s + i - C && M > o + C && M < o + c - C) return !0;
2912
+ const z = (t + n) / 2, M = (e + r) / 2;
2913
+ if (z > s + C && z < s + i - C && M > o + C && M < o + c - C) return !0;
2912
2914
  const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
2913
- for (let z = 0; z < 4; z++)
2914
- if (Ur(t, e, n, r, $[z][0], $[z][1], $[(z + 1) % 4][0], $[(z + 1) % 4][1])) return !0;
2915
+ for (let k = 0; k < 4; k++)
2916
+ if (Ur(t, e, n, r, $[k][0], $[k][1], $[(k + 1) % 4][0], $[(k + 1) % 4][1])) return !0;
2915
2917
  return !1;
2916
2918
  }
2917
2919
  function Ur(t, e, n, r, s, o, i, c) {
@@ -2963,37 +2965,37 @@ function sr(t, e, n) {
2963
2965
  const i = [...r].sort((R, B) => R - B), c = [...s].sort((R, B) => R - B), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2964
2966
  for (let R = 0; R < i.length; R++) u.set(i[R], R);
2965
2967
  for (let R = 0; R < c.length; R++) l.set(c[R], R);
2966
- const y = i.length, m = c.length, C = (R, B) => B * y + R, k = u.get(t.x), M = l.get(t.y), $ = u.get(e.x), z = l.get(e.y);
2967
- if (k === void 0 || M === void 0 || $ === void 0 || z === void 0) return null;
2968
- const E = C(k, M), W = C($, z), H = new Float64Array(y * m).fill(1 / 0), g = new Float64Array(y * m).fill(1 / 0), f = new Int32Array(y * m).fill(-1), p = new Int8Array(y * m).fill(-1), v = new Uint8Array(y * m);
2969
- H[E] = 0, g[E] = Math.abs(i[$] - t.x) + Math.abs(c[z] - t.y);
2970
- const w = [E], N = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
2971
- for (; w.length > 0; ) {
2968
+ const y = i.length, m = c.length, C = (R, B) => B * y + R, z = u.get(t.x), M = l.get(t.y), $ = u.get(e.x), k = l.get(e.y);
2969
+ if (z === void 0 || M === void 0 || $ === void 0 || k === void 0) return null;
2970
+ const E = C(z, M), _ = C($, k), D = new Float64Array(y * m).fill(1 / 0), g = new Float64Array(y * m).fill(1 / 0), f = new Int32Array(y * m).fill(-1), p = new Int8Array(y * m).fill(-1), v = new Uint8Array(y * m);
2971
+ D[E] = 0, g[E] = Math.abs(i[$] - t.x) + Math.abs(c[k] - t.y);
2972
+ const N = [E], w = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
2973
+ for (; N.length > 0; ) {
2972
2974
  let R = 0;
2973
- for (let G = 1; G < w.length; G++)
2974
- g[w[G]] < g[w[R]] && (R = G);
2975
- const B = w[R];
2976
- if (w[R] = w[w.length - 1], w.pop(), B === W) {
2975
+ for (let G = 1; G < N.length; G++)
2976
+ g[N[G]] < g[N[R]] && (R = G);
2977
+ const B = N[R];
2978
+ if (N[R] = N[N.length - 1], N.pop(), B === _) {
2977
2979
  const G = [];
2978
- let j = W;
2980
+ let j = _;
2979
2981
  for (; j !== -1 && j !== E; ) {
2980
- const st = j / y | 0, rt = j % y;
2981
- G.unshift({ x: i[rt], y: c[st] }), j = f[j];
2982
+ const it = j / y | 0, dt = j % y;
2983
+ G.unshift({ x: i[dt], y: c[it] }), j = f[j];
2982
2984
  }
2983
2985
  return G.unshift({ x: t.x, y: t.y }), jr(G, n);
2984
2986
  }
2985
2987
  if (v[B]) continue;
2986
2988
  v[B] = 1;
2987
- const q = B / y | 0, D = B % y, it = i[D], nt = c[q], lt = p[B];
2989
+ const q = B / y | 0, X = B % y, K = i[X], at = c[q], rt = p[B];
2988
2990
  for (let G = 0; G < 4; G++) {
2989
- const j = D + P[G][0], st = q + P[G][1];
2990
- if (j < 0 || j >= y || st < 0 || st >= m) continue;
2991
- const rt = C(j, st);
2992
- if (v[rt]) continue;
2993
- const ut = i[j], dt = c[st];
2994
- if (qr(ut, dt, n) || !zn(it, nt, ut, dt, n)) continue;
2995
- const Lt = Math.abs(ut - it) + Math.abs(dt - nt), ot = lt >= 0 && lt !== G ? N : 0, pt = H[B] + Lt + ot;
2996
- pt < H[rt] && (f[rt] = B, p[rt] = G, H[rt] = pt, g[rt] = pt + Math.abs(i[$] - ut) + Math.abs(c[z] - dt), w.push(rt));
2991
+ const j = X + P[G][0], it = q + P[G][1];
2992
+ if (j < 0 || j >= y || it < 0 || it >= m) continue;
2993
+ const dt = C(j, it);
2994
+ if (v[dt]) continue;
2995
+ const ot = i[j], ft = c[it];
2996
+ if (qr(ot, ft, n) || !zn(K, at, ot, ft, n)) continue;
2997
+ const It = Math.abs(ot - K) + Math.abs(ft - at), st = rt >= 0 && rt !== G ? w : 0, xt = D[B] + It + st;
2998
+ xt < D[dt] && (f[dt] = B, p[dt] = G, D[dt] = xt, g[dt] = xt + Math.abs(i[$] - ot) + Math.abs(c[k] - ft), N.push(dt));
2997
2999
  }
2998
3000
  }
2999
3001
  return null;
@@ -3073,8 +3075,8 @@ function En(t, e = 6, n = !1) {
3073
3075
  for (let o = 1; o < t.length - 1; o++) {
3074
3076
  const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y), y = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), m = Math.min(r, l / 2, y / 2);
3075
3077
  if (m > 0.5) {
3076
- const C = c.x - i.x, k = c.y - i.y, M = u.x - c.x, $ = u.y - c.y, z = Math.sqrt(C * C + k * k) || 1, E = Math.sqrt(M * M + $ * $) || 1;
3077
- s += ` L ${c.x - C / z * m},${c.y - k / z * m}`, s += ` Q ${c.x},${c.y} ${c.x + M / E * m},${c.y + $ / E * m}`;
3078
+ const C = c.x - i.x, z = c.y - i.y, M = u.x - c.x, $ = u.y - c.y, k = Math.sqrt(C * C + z * z) || 1, E = Math.sqrt(M * M + $ * $) || 1;
3079
+ s += ` L ${c.x - C / k * m},${c.y - z / k * m}`, s += ` Q ${c.x},${c.y} ${c.x + M / E * m},${c.y + $ / E * m}`;
3078
3080
  } else
3079
3081
  s += ` L ${c.x},${c.y}`;
3080
3082
  }
@@ -3117,15 +3119,15 @@ function No(t, e) {
3117
3119
  const n = {};
3118
3120
  for (const o of t) n[o.id] = o;
3119
3121
  const r = or(t, null), s = e.map((o) => {
3120
- var p, v, w, N;
3122
+ var p, v, N, w;
3121
3123
  const i = o.type || "default";
3122
3124
  if (i === "bezier" || i === "simplebezier" || i === "default") return o;
3123
3125
  const c = n[o.source], u = n[o.target];
3124
3126
  if (!c || !u || c.hidden || u.hidden) return o;
3125
- const l = Wn(c, "source", o.sourceHandle), y = Wn(u, "target", o.targetHandle), m = ln(l, cn), C = ln(y, cn), k = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), $ = c._absolutePosition || c.position, z = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, E = c.height || ((v = c.measured) == null ? void 0 : v.height) || an;
3126
- M.push({ id: o.source, x: $.x - k, y: $.y - k, w: z + 2 * k, h: E + 2 * k });
3127
- const W = u._absolutePosition || u.position, H = u.width || ((w = u.measured) == null ? void 0 : w.width) || sn, g = u.height || ((N = u.measured) == null ? void 0 : N.height) || an;
3128
- if (M.push({ id: o.target, x: W.x - k, y: W.y - k, w: H + 2 * k, h: g + 2 * k }), M.length === 0) return o;
3127
+ const l = Wn(c, "source", o.sourceHandle), y = Wn(u, "target", o.targetHandle), m = ln(l, cn), C = ln(y, cn), z = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), $ = c._absolutePosition || c.position, k = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, E = c.height || ((v = c.measured) == null ? void 0 : v.height) || an;
3128
+ M.push({ id: o.source, x: $.x - z, y: $.y - z, w: k + 2 * z, h: E + 2 * z });
3129
+ const _ = u._absolutePosition || u.position, D = u.width || ((N = u.measured) == null ? void 0 : N.width) || sn, g = u.height || ((w = u.measured) == null ? void 0 : w.height) || an;
3130
+ if (M.push({ id: o.target, x: _.x - z, y: _.y - z, w: D + 2 * z, h: g + 2 * z }), M.length === 0) return o;
3129
3131
  const f = sr(m, C, M);
3130
3132
  return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: y.x, y: y.y }), { ...o, _routedPoints: f }) : o;
3131
3133
  });
@@ -3134,8 +3136,8 @@ function No(t, e) {
3134
3136
  function Lo(t, e, n, r, s, o, i, c) {
3135
3137
  const u = or(i, c ? new Set(c) : null);
3136
3138
  if (u.length === 0) return null;
3137
- const l = { x: t, y: e, dir: s || "right" }, y = { x: n, y: r, dir: o || "left" }, m = ln(l, cn), C = ln(y, cn), k = sr(m, C, u);
3138
- return k && k.length >= 2 ? (k.unshift({ x: l.x, y: l.y }), k.push({ x: y.x, y: y.y }), k) : null;
3139
+ const l = { x: t, y: e, dir: s || "right" }, y = { x: n, y: r, dir: o || "left" }, m = ln(l, cn), C = ln(y, cn), z = sr(m, C, u);
3140
+ return z && z.length >= 2 ? (z.unshift({ x: l.x, y: l.y }), z.push({ x: y.x, y: y.y }), z) : null;
3139
3141
  }
3140
3142
  const ir = Zt(function({
3141
3143
  id: e,
@@ -3150,25 +3152,25 @@ const ir = Zt(function({
3150
3152
  labelBgPadding: y,
3151
3153
  labelBgBorderRadius: m,
3152
3154
  style: C,
3153
- markerEnd: k,
3155
+ markerEnd: z,
3154
3156
  markerStart: M,
3155
3157
  interactionWidth: $,
3156
- routedPoints: z
3158
+ routedPoints: k
3157
3159
  }) {
3158
- let E, W, H;
3159
- if (z && z.length >= 2) {
3160
- E = En(z);
3161
- const g = Cn(z);
3162
- W = g.x, H = g.y;
3160
+ let E, _, D;
3161
+ if (k && k.length >= 2) {
3162
+ E = En(k);
3163
+ const g = Cn(k);
3164
+ _ = g.x, D = g.y;
3163
3165
  } else
3164
- [E, W, H] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
3166
+ [E, _, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
3165
3167
  return /* @__PURE__ */ S(
3166
3168
  un,
3167
3169
  {
3168
3170
  id: e,
3169
3171
  path: E,
3170
- labelX: W,
3171
- labelY: H,
3172
+ labelX: _,
3173
+ labelY: D,
3172
3174
  label: i,
3173
3175
  labelStyle: c,
3174
3176
  labelShowBg: u,
@@ -3176,7 +3178,7 @@ const ir = Zt(function({
3176
3178
  labelBgPadding: y,
3177
3179
  labelBgBorderRadius: m,
3178
3180
  style: C,
3179
- markerEnd: k,
3181
+ markerEnd: z,
3180
3182
  markerStart: M,
3181
3183
  interactionWidth: $
3182
3184
  }
@@ -3196,18 +3198,18 @@ const ar = Zt(function({
3196
3198
  labelShowBg: y,
3197
3199
  labelBgStyle: m,
3198
3200
  labelBgPadding: C,
3199
- labelBgBorderRadius: k,
3201
+ labelBgBorderRadius: z,
3200
3202
  style: M,
3201
3203
  markerEnd: $,
3202
- markerStart: z,
3204
+ markerStart: k,
3203
3205
  pathOptions: E,
3204
- interactionWidth: W,
3205
- routedPoints: H
3206
+ interactionWidth: _,
3207
+ routedPoints: D
3206
3208
  }) {
3207
3209
  let g, f, p;
3208
- if (H && H.length >= 2) {
3209
- g = En(H);
3210
- const v = Cn(H);
3210
+ if (D && D.length >= 2) {
3211
+ g = En(D);
3212
+ const v = Cn(D);
3211
3213
  f = v.x, p = v.y;
3212
3214
  } else
3213
3215
  [g, f, p] = kn({
@@ -3232,11 +3234,11 @@ const ar = Zt(function({
3232
3234
  labelShowBg: y,
3233
3235
  labelBgStyle: m,
3234
3236
  labelBgPadding: C,
3235
- labelBgBorderRadius: k,
3237
+ labelBgBorderRadius: z,
3236
3238
  style: M,
3237
3239
  markerEnd: $,
3238
- markerStart: z,
3239
- interactionWidth: W
3240
+ markerStart: k,
3241
+ interactionWidth: _
3240
3242
  }
3241
3243
  );
3242
3244
  });
@@ -3266,20 +3268,20 @@ const cr = Zt(function({
3266
3268
  labelShowBg: y,
3267
3269
  labelBgStyle: m,
3268
3270
  labelBgPadding: C,
3269
- labelBgBorderRadius: k,
3271
+ labelBgBorderRadius: z,
3270
3272
  style: M,
3271
3273
  markerEnd: $,
3272
- markerStart: z,
3274
+ markerStart: k,
3273
3275
  interactionWidth: E,
3274
- routedPoints: W
3276
+ routedPoints: _
3275
3277
  }) {
3276
- let H, g, f;
3277
- if (W && W.length >= 2) {
3278
- H = En(W);
3279
- const p = Cn(W);
3278
+ let D, g, f;
3279
+ if (_ && _.length >= 2) {
3280
+ D = En(_);
3281
+ const p = Cn(_);
3280
3282
  g = p.x, f = p.y;
3281
3283
  } else
3282
- [H, g, f] = rr({
3284
+ [D, g, f] = rr({
3283
3285
  sourceX: n,
3284
3286
  sourceY: r,
3285
3287
  targetX: s,
@@ -3289,7 +3291,7 @@ const cr = Zt(function({
3289
3291
  un,
3290
3292
  {
3291
3293
  id: e,
3292
- path: H,
3294
+ path: D,
3293
3295
  labelX: g,
3294
3296
  labelY: f,
3295
3297
  label: u,
@@ -3297,10 +3299,10 @@ const cr = Zt(function({
3297
3299
  labelShowBg: y,
3298
3300
  labelBgStyle: m,
3299
3301
  labelBgPadding: C,
3300
- labelBgBorderRadius: k,
3302
+ labelBgBorderRadius: z,
3301
3303
  style: M,
3302
3304
  markerEnd: $,
3303
- markerStart: z,
3305
+ markerStart: k,
3304
3306
  interactionWidth: E
3305
3307
  }
3306
3308
  );
@@ -3334,43 +3336,43 @@ function Io({
3334
3336
  // Zoom/Camera
3335
3337
  zoomMin: m,
3336
3338
  zoomMax: C,
3337
- initialCamera: k,
3339
+ initialCamera: z,
3338
3340
  fitView: M,
3339
3341
  fitViewOptions: $,
3340
3342
  // Node/Edge callbacks
3341
- onNodesChange: z,
3343
+ onNodesChange: k,
3342
3344
  onEdgesChange: E,
3343
- onConnect: W,
3344
- onConnectStart: H,
3345
+ onConnect: _,
3346
+ onConnectStart: D,
3345
3347
  onConnectEnd: g,
3346
3348
  onNodeClick: f,
3347
3349
  onNodeDoubleClick: p,
3348
3350
  onNodeMouseEnter: v,
3349
- onNodeMouseMove: w,
3350
- onNodeMouseLeave: N,
3351
+ onNodeMouseMove: N,
3352
+ onNodeMouseLeave: w,
3351
3353
  onNodeContextMenu: P,
3352
3354
  onNodeDragStart: R,
3353
3355
  onNodeDrag: B,
3354
3356
  onNodeDragStop: q,
3355
- onEdgeClick: D,
3356
- onEdgeDoubleClick: it,
3357
- onEdgeMouseEnter: nt,
3358
- onEdgeMouseMove: lt,
3357
+ onEdgeClick: X,
3358
+ onEdgeDoubleClick: K,
3359
+ onEdgeMouseEnter: at,
3360
+ onEdgeMouseMove: rt,
3359
3361
  onEdgeMouseLeave: G,
3360
3362
  onEdgeContextMenu: j,
3361
- onPaneClick: st,
3362
- onPaneContextMenu: rt,
3363
- onPaneMouseEnter: ut,
3364
- onPaneMouseMove: dt,
3365
- onPaneMouseLeave: Lt,
3366
- onSelectionChange: ot,
3367
- onInit: pt,
3368
- onMoveStart: vt,
3369
- onMove: ht,
3370
- onMoveEnd: bt,
3371
- onDelete: Et,
3372
- onBeforeDelete: kt,
3373
- onError: $t,
3363
+ onPaneClick: it,
3364
+ onPaneContextMenu: dt,
3365
+ onPaneMouseEnter: ot,
3366
+ onPaneMouseMove: ft,
3367
+ onPaneMouseLeave: It,
3368
+ onSelectionChange: st,
3369
+ onInit: xt,
3370
+ onMoveStart: Nt,
3371
+ onMove: gt,
3372
+ onMoveEnd: ct,
3373
+ onDelete: zt,
3374
+ onBeforeDelete: Rt,
3375
+ onError: Lt,
3374
3376
  // Drag and drop
3375
3377
  onDragOver: wt,
3376
3378
  onDrop: ne,
@@ -3399,10 +3401,10 @@ function Io({
3399
3401
  zoomOnDoubleClick: Nn,
3400
3402
  zoomOnPinch: hn,
3401
3403
  preventScrolling: fe,
3402
- translateExtent: xt,
3404
+ translateExtent: mt,
3403
3405
  nodeExtent: Te,
3404
- autoPanOnNodeDrag: Ct,
3405
- autoPanOnConnect: gt,
3406
+ autoPanOnNodeDrag: Et,
3407
+ autoPanOnConnect: pt,
3406
3408
  autoPanSpeed: se,
3407
3409
  edgesReconnectable: Z,
3408
3410
  elevateNodesOnSelect: Pt,
@@ -3418,71 +3420,71 @@ function Io({
3418
3420
  children: Me,
3419
3421
  ...ie
3420
3422
  }) {
3421
- const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be = V(null), Je = V(null), Ve = F(
3423
+ const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be = tt(null), Je = tt(null), Ve = F(
3422
3424
  (Q) => {
3423
3425
  Re(Q), te == null || te(Q);
3424
3426
  },
3425
3427
  [te]
3426
3428
  ), ae = St(() => ({ ...Qr, ...r }), [r]), Kt = St(() => ({ ...Kr, ...s }), [s]), he = St(() => {
3427
3429
  const Q = e.filter((Ft) => Ft.type && ae[Ft.type]);
3428
- return Q.sort((Ft, at) => {
3429
- const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe = at.type === "group" || !at.parentId && Q.some((Ee) => Ee.parentId === at.id);
3430
+ return Q.sort((Ft, lt) => {
3431
+ const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe = lt.type === "group" || !lt.parentId && Q.some((Ee) => Ee.parentId === lt.id);
3430
3432
  return Tt && !xe ? -1 : !Tt && xe ? 1 : 0;
3431
3433
  });
3432
- }, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]), Mt = St(() => n.map((Q) => Q.type && Kt[Q.type] ? { ...Q, _customRendered: !0 } : Q), [n, Kt]), {
3434
+ }, [e, ae]), ke = St(() => n.filter((Q) => Q.type && Kt[Q.type]), [n, Kt]), O = St(() => e.map((Q) => Q.type && ae[Q.type] ? { ...Q, _customRendered: !0 } : Q), [e, ae]), bt = St(() => n.map((Q) => Q.type && Kt[Q.type] ? { ...Q, _customRendered: !0 } : Q), [n, Kt]), {
3433
3435
  wrapRef: Dt,
3434
3436
  canvasRef: ce,
3435
3437
  canvasReady: De,
3436
- onPointerDown: He,
3437
- onPointerMove: Ae,
3438
+ onPointerDown: Ae,
3439
+ onPointerMove: He,
3438
3440
  onPointerUp: _e,
3439
3441
  store: le
3440
3442
  } = Lr({
3441
3443
  cards: t,
3442
3444
  nodes: O,
3443
- edges: Mt,
3445
+ edges: bt,
3444
3446
  dark: o,
3445
3447
  gridSize: i,
3446
3448
  zoomMin: m,
3447
3449
  zoomMax: C,
3448
- initialCamera: k,
3450
+ initialCamera: z,
3449
3451
  fitView: M,
3450
3452
  fitViewOptions: $,
3451
3453
  onHudUpdate: Ve,
3452
3454
  onNodesProcessed: gn,
3453
- onNodesChange: z,
3455
+ onNodesChange: k,
3454
3456
  onEdgesChange: E,
3455
- onConnect: W,
3456
- onConnectStart: H,
3457
+ onConnect: _,
3458
+ onConnectStart: D,
3457
3459
  onConnectEnd: g,
3458
3460
  onNodeClick: f,
3459
3461
  onNodeDoubleClick: p,
3460
3462
  onNodeMouseEnter: v,
3461
- onNodeMouseMove: w,
3462
- onNodeMouseLeave: N,
3463
+ onNodeMouseMove: N,
3464
+ onNodeMouseLeave: w,
3463
3465
  onNodeContextMenu: P,
3464
3466
  onNodeDragStart: R,
3465
3467
  onNodeDrag: B,
3466
3468
  onNodeDragStop: q,
3467
- onEdgeClick: D,
3468
- onEdgeDoubleClick: it,
3469
- onEdgeMouseEnter: nt,
3470
- onEdgeMouseMove: lt,
3469
+ onEdgeClick: X,
3470
+ onEdgeDoubleClick: K,
3471
+ onEdgeMouseEnter: at,
3472
+ onEdgeMouseMove: rt,
3471
3473
  onEdgeMouseLeave: G,
3472
3474
  onEdgeContextMenu: j,
3473
- onPaneClick: st,
3474
- onPaneContextMenu: rt,
3475
- onPaneMouseEnter: ut,
3476
- onPaneMouseMove: dt,
3477
- onPaneMouseLeave: Lt,
3478
- onSelectionChange: ot,
3479
- onInit: pt,
3480
- onMoveStart: vt,
3481
- onMove: ht,
3482
- onMoveEnd: bt,
3483
- onDelete: Et,
3484
- onBeforeDelete: kt,
3485
- onError: $t,
3475
+ onPaneClick: it,
3476
+ onPaneContextMenu: dt,
3477
+ onPaneMouseEnter: ot,
3478
+ onPaneMouseMove: ft,
3479
+ onPaneMouseLeave: It,
3480
+ onSelectionChange: st,
3481
+ onInit: xt,
3482
+ onMoveStart: Nt,
3483
+ onMove: gt,
3484
+ onMoveEnd: ct,
3485
+ onDelete: zt,
3486
+ onBeforeDelete: Rt,
3487
+ onError: Lt,
3486
3488
  nodesDraggable: Ot,
3487
3489
  nodesConnectable: Yt,
3488
3490
  elementsSelectable: me,
@@ -3505,10 +3507,10 @@ function Io({
3505
3507
  zoomOnDoubleClick: Nn,
3506
3508
  zoomOnPinch: hn,
3507
3509
  preventScrolling: fe,
3508
- translateExtent: xt,
3510
+ translateExtent: mt,
3509
3511
  nodeExtent: Te,
3510
- autoPanOnNodeDrag: Ct,
3511
- autoPanOnConnect: gt,
3512
+ autoPanOnNodeDrag: Et,
3513
+ autoPanOnConnect: pt,
3512
3514
  autoPanSpeed: se,
3513
3515
  edgesReconnectable: Z,
3514
3516
  elevateNodesOnSelect: Pt,
@@ -3524,24 +3526,24 @@ function Io({
3524
3526
  get edges() {
3525
3527
  return n;
3526
3528
  }
3527
- }), [le, e, n]), ye = V(null), ge = V(null), pe = V(null), Jt = V(null);
3528
- ft(() => {
3529
+ }), [le, e, n]), ye = tt(null), ge = tt(null), pe = tt(null), Jt = tt(null);
3530
+ ht(() => {
3529
3531
  let Q;
3530
3532
  const Ft = () => {
3531
- const at = le.cameraRef.current, Tt = `translate(${at.x}px, ${at.y}px) scale(${at.zoom})`, xe = `translate(${at.x}, ${at.y}) scale(${at.zoom})`;
3533
+ const lt = le.cameraRef.current, Tt = `translate(${lt.x}px, ${lt.y}px) scale(${lt.zoom})`, xe = `translate(${lt.x}, ${lt.y}) scale(${lt.zoom})`;
3532
3534
  ye.current && (ye.current.style.transform = Tt), ge.current && ge.current.setAttribute("transform", xe), pe.current && (pe.current.style.transform = Tt), Jt.current && (Jt.current.style.transform = Tt), Q = requestAnimationFrame(Ft);
3533
3535
  };
3534
3536
  return Q = requestAnimationFrame(Ft), () => cancelAnimationFrame(Q);
3535
3537
  }, [le]);
3536
3538
  const ze = he.length > 0, ee = ke.length > 0;
3537
- return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */ It(
3539
+ return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */ $t(
3538
3540
  "div",
3539
3541
  {
3540
3542
  ref: Dt,
3541
3543
  className: `ric-wrap ${l}`,
3542
3544
  style: { width: c, height: u, ...y },
3543
- onPointerDown: He,
3544
- onPointerMove: Ae,
3545
+ onPointerDown: Ae,
3546
+ onPointerMove: He,
3545
3547
  onPointerUp: _e,
3546
3548
  onDragOver: wt,
3547
3549
  onDrop: ne,
@@ -3640,7 +3642,7 @@ function Io({
3640
3642
  }
3641
3643
  ),
3642
3644
  _t && /* @__PURE__ */ S("div", { className: "ric-hint", children: Wt }),
3643
- pn && /* @__PURE__ */ It("div", { className: "ric-info", children: [
3645
+ pn && /* @__PURE__ */ $t("div", { className: "ric-info", children: [
3644
3646
  "world: (",
3645
3647
  Ut.wx,
3646
3648
  ", ",
@@ -3648,17 +3650,17 @@ function Io({
3648
3650
  ")   zoom: ",
3649
3651
  Ut.zoom,
3650
3652
  "x",
3651
- Ut.nodeCount > 0 && /* @__PURE__ */ It(Le, { children: [
3653
+ Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
3652
3654
  "   nodes: ",
3653
3655
  Ut.nodeCount
3654
3656
  ] }),
3655
- Ut.edgeCount > 0 && /* @__PURE__ */ It(Le, { children: [
3657
+ Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
3656
3658
  "   edges: ",
3657
3659
  Ut.edgeCount
3658
3660
  ] })
3659
3661
  ] }),
3660
3662
  /* @__PURE__ */ S(
3661
- Hr,
3663
+ Ar,
3662
3664
  {
3663
3665
  selectionKeyCode: de || "Shift",
3664
3666
  selectionMode: we || "partial"
@@ -3746,39 +3748,39 @@ function So(t) {
3746
3748
  }
3747
3749
  function eo() {
3748
3750
  const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((g) => t.nodesRef.current.find((f) => f.id === g), [t]), s = F((g) => t.edgesRef.current.find((f) => f.id === g), [t]), o = F((g) => {
3749
- var f, p, v, w;
3751
+ var f, p, v, N;
3750
3752
  if (typeof g == "function") {
3751
- const N = g(t.nodesRef.current);
3753
+ const w = g(t.nodesRef.current);
3752
3754
  (p = (f = t.onNodesChangeRef).current) == null || p.call(f, [
3753
3755
  ...t.nodesRef.current.map((P) => ({ id: P.id, type: "remove" })),
3754
- ...N.map((P) => ({ type: "add", item: P }))
3756
+ ...w.map((P) => ({ type: "add", item: P }))
3755
3757
  ]);
3756
3758
  } else
3757
- (w = (v = t.onNodesChangeRef).current) == null || w.call(v, [
3758
- ...t.nodesRef.current.map((N) => ({ id: N.id, type: "remove" })),
3759
- ...g.map((N) => ({ type: "add", item: N }))
3759
+ (N = (v = t.onNodesChangeRef).current) == null || N.call(v, [
3760
+ ...t.nodesRef.current.map((w) => ({ id: w.id, type: "remove" })),
3761
+ ...g.map((w) => ({ type: "add", item: w }))
3760
3762
  ]);
3761
3763
  }, [t]), i = F((g) => {
3762
- var f, p, v, w;
3764
+ var f, p, v, N;
3763
3765
  if (typeof g == "function") {
3764
- const N = g(t.edgesRef.current);
3766
+ const w = g(t.edgesRef.current);
3765
3767
  (p = (f = t.onEdgesChangeRef).current) == null || p.call(f, [
3766
3768
  ...t.edgesRef.current.map((P) => ({ id: P.id, type: "remove" })),
3767
- ...N.map((P) => ({ type: "add", item: P }))
3769
+ ...w.map((P) => ({ type: "add", item: P }))
3768
3770
  ]);
3769
3771
  } else
3770
- (w = (v = t.onEdgesChangeRef).current) == null || w.call(v, [
3771
- ...t.edgesRef.current.map((N) => ({ id: N.id, type: "remove" })),
3772
- ...g.map((N) => ({ type: "add", item: N }))
3772
+ (N = (v = t.onEdgesChangeRef).current) == null || N.call(v, [
3773
+ ...t.edgesRef.current.map((w) => ({ id: w.id, type: "remove" })),
3774
+ ...g.map((w) => ({ type: "add", item: w }))
3773
3775
  ]);
3774
3776
  }, [t]), c = F((g) => {
3775
3777
  var p, v;
3776
3778
  const f = Array.isArray(g) ? g : [g];
3777
- (v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((w) => ({ type: "add", item: w })));
3779
+ (v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
3778
3780
  }, [t]), u = F((g) => {
3779
3781
  var p, v;
3780
3782
  const f = Array.isArray(g) ? g : [g];
3781
- (v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((w) => ({ type: "add", item: w })));
3783
+ (v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
3782
3784
  }, [t]), l = F(({ nodes: g = [], edges: f = [] }) => {
3783
3785
  if (g.length && t.onNodesChangeRef.current) {
3784
3786
  t.onNodesChangeRef.current(g.map((v) => ({ id: v.id, type: "remove" })));
@@ -3795,40 +3797,40 @@ function eo() {
3795
3797
  y: g.y ?? t.cameraRef.current.y,
3796
3798
  zoom: g.zoom ?? t.cameraRef.current.zoom
3797
3799
  }, t.sendCamera();
3798
- }, [t]), C = F(() => t.cameraRef.current.zoom, [t]), k = F((g) => {
3800
+ }, [t]), C = F(() => t.cameraRef.current.zoom, [t]), z = F((g) => {
3799
3801
  const f = t.cameraRef.current, p = t.wrapRef.current;
3800
3802
  if (!p) return;
3801
- const v = p.getBoundingClientRect(), w = v.width / 2, N = v.height / 2, P = 1.2;
3802
- f.x = w - (w - f.x) * P, f.y = N - (N - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
3803
+ const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1.2;
3804
+ f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
3803
3805
  }, [t]), M = F((g) => {
3804
3806
  const f = t.cameraRef.current, p = t.wrapRef.current;
3805
3807
  if (!p) return;
3806
- const v = p.getBoundingClientRect(), w = v.width / 2, N = v.height / 2, P = 1 / 1.2;
3807
- f.x = w - (w - f.x) * P, f.y = N - (N - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
3808
+ const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = 1 / 1.2;
3809
+ f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
3808
3810
  }, [t]), $ = F((g) => {
3809
3811
  const f = t.cameraRef.current, p = t.wrapRef.current;
3810
3812
  if (!p) return;
3811
- const v = p.getBoundingClientRect(), w = v.width / 2, N = v.height / 2, P = g / f.zoom;
3812
- f.x = w - (w - f.x) * P, f.y = N - (N - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, g)), t.sendCamera();
3813
- }, [t]), z = F((g = {}) => {
3813
+ const v = p.getBoundingClientRect(), N = v.width / 2, w = v.height / 2, P = g / f.zoom;
3814
+ f.x = N - (N - f.x) * P, f.y = w - (w - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, g)), t.sendCamera();
3815
+ }, [t]), k = F((g = {}) => {
3814
3816
  const f = t.nodesRef.current;
3815
3817
  if (!f.length) return;
3816
3818
  const p = t.wrapRef.current;
3817
3819
  if (!p) return;
3818
- const v = p.getBoundingClientRect(), w = g.padding ?? 0.1, N = g.nodes ? f.filter((B) => g.nodes.some((q) => q.id === B.id)) : f;
3819
- if (!N.length) return;
3820
- const P = Mn(N), R = Rn(P, v.width, v.height, w);
3820
+ const v = p.getBoundingClientRect(), N = g.padding ?? 0.1, w = g.nodes ? f.filter((B) => g.nodes.some((q) => q.id === B.id)) : f;
3821
+ if (!w.length) return;
3822
+ const P = Mn(w), R = Rn(P, v.width, v.height, N);
3821
3823
  g.maxZoom && (R.zoom = Math.min(R.zoom, g.maxZoom)), g.minZoom && (R.zoom = Math.max(R.zoom, g.minZoom)), t.cameraRef.current = R, t.sendCamera();
3822
3824
  }, [t]), E = F((g, f, p = {}) => {
3823
3825
  const v = t.wrapRef.current;
3824
3826
  if (!v) return;
3825
- const w = v.getBoundingClientRect(), N = p.zoom ?? t.cameraRef.current.zoom;
3827
+ const N = v.getBoundingClientRect(), w = p.zoom ?? t.cameraRef.current.zoom;
3826
3828
  t.cameraRef.current = {
3827
- x: w.width / 2 - g * N,
3828
- y: w.height / 2 - f * N,
3829
- zoom: N
3829
+ x: N.width / 2 - g * w,
3830
+ y: N.height / 2 - f * w,
3831
+ zoom: w
3830
3832
  }, t.sendCamera();
3831
- }, [t]), W = F((g) => t.screenToWorld(g.x, g.y), [t]), H = F((g) => {
3833
+ }, [t]), _ = F((g) => t.screenToWorld(g.x, g.y), [t]), D = F((g) => {
3832
3834
  const f = t.cameraRef.current, p = t.wrapRef.current;
3833
3835
  if (!p) return { x: 0, y: 0 };
3834
3836
  const v = p.getBoundingClientRect();
@@ -3850,13 +3852,13 @@ function eo() {
3850
3852
  getViewport: y,
3851
3853
  setViewport: m,
3852
3854
  getZoom: C,
3853
- zoomIn: k,
3855
+ zoomIn: z,
3854
3856
  zoomOut: M,
3855
3857
  zoomTo: $,
3856
- fitView: z,
3858
+ fitView: k,
3857
3859
  setCenter: E,
3858
- screenToFlowPosition: W,
3859
- flowToScreenPosition: H
3860
+ screenToFlowPosition: _,
3861
+ flowToScreenPosition: D
3860
3862
  };
3861
3863
  }
3862
3864
  function Bo() {
@@ -3865,10 +3867,10 @@ function Bo() {
3865
3867
  function Do() {
3866
3868
  return yt().edges;
3867
3869
  }
3868
- function Ho() {
3870
+ function Ao() {
3869
3871
  return yt().viewport;
3870
3872
  }
3871
- function Ao() {
3873
+ function Ho() {
3872
3874
  return yt().connection;
3873
3875
  }
3874
3876
  function _o(t) {
@@ -3887,14 +3889,14 @@ function Xo({ nodeId: t, type: e, handleId: n }) {
3887
3889
  return St(() => r.edges.filter((s) => e === "source" ? s.source === t && (n ? s.sourceHandle === n : !0) : s.target === t && (n ? s.targetHandle === n : !0)), [r.edges, t, e, n]);
3888
3890
  }
3889
3891
  function Fo({ onChange: t, onStart: e, onEnd: n }) {
3890
- const r = yt(), s = V(t), o = V(e), i = V(n);
3891
- ft(() => {
3892
+ const r = yt(), s = tt(t), o = tt(e), i = tt(n);
3893
+ ht(() => {
3892
3894
  s.current = t;
3893
- }, [t]), ft(() => {
3895
+ }, [t]), ht(() => {
3894
3896
  o.current = e;
3895
- }, [e]), ft(() => {
3897
+ }, [e]), ht(() => {
3896
3898
  i.current = n;
3897
- }, [n]), ft(() => {
3899
+ }, [n]), ht(() => {
3898
3900
  const c = (u) => {
3899
3901
  var l;
3900
3902
  (l = s.current) == null || l.call(s, { x: u.x, y: u.y, zoom: u.zoom });
@@ -3903,10 +3905,10 @@ function Fo({ onChange: t, onStart: e, onEnd: n }) {
3903
3905
  }, [r]);
3904
3906
  }
3905
3907
  function Yo({ onChange: t }) {
3906
- const e = yt(), n = V(t);
3907
- ft(() => {
3908
+ const e = yt(), n = tt(t);
3909
+ ht(() => {
3908
3910
  n.current = t;
3909
- }, [t]), ft(() => {
3911
+ }, [t]), ht(() => {
3910
3912
  const r = (s) => {
3911
3913
  var o;
3912
3914
  (o = n.current) == null || o.call(n, s);
@@ -3916,7 +3918,7 @@ function Yo({ onChange: t }) {
3916
3918
  }
3917
3919
  function Uo(t) {
3918
3920
  const [e, n] = Gt(!1), r = Array.isArray(t) ? t : [t];
3919
- return ft(() => {
3921
+ return ht(() => {
3920
3922
  const s = (i) => {
3921
3923
  r.includes(i.key) && n(!0);
3922
3924
  }, o = (i) => {
@@ -3967,50 +3969,50 @@ function Qo({
3967
3969
  style: o = {},
3968
3970
  className: i = ""
3969
3971
  }) {
3970
- const c = yt(), u = V(null), l = V(null), y = F(() => {
3972
+ const c = yt(), u = tt(null), l = tt(null), y = F(() => {
3971
3973
  const m = u.current;
3972
3974
  if (!m) return;
3973
- const C = m.getContext("2d"), k = window.devicePixelRatio || 1;
3974
- m.width = t * k, m.height = e * k, C.scale(k, k), C.clearRect(0, 0, t, e);
3975
+ const C = m.getContext("2d"), z = window.devicePixelRatio || 1;
3976
+ m.width = t * z, m.height = e * z, C.scale(z, z), C.clearRect(0, 0, t, e);
3975
3977
  const M = c.nodesRef.current;
3976
3978
  if (!M.length) return;
3977
- let $ = 1 / 0, z = 1 / 0, E = -1 / 0, W = -1 / 0;
3979
+ let $ = 1 / 0, k = 1 / 0, E = -1 / 0, _ = -1 / 0;
3978
3980
  for (const R of M) {
3979
3981
  const B = R.width || wn, q = R.height || bn;
3980
- R.position.x < $ && ($ = R.position.x), R.position.y < z && (z = R.position.y), R.position.x + B > E && (E = R.position.x + B), R.position.y + q > W && (W = R.position.y + q);
3982
+ R.position.x < $ && ($ = R.position.x), R.position.y < k && (k = R.position.y), R.position.x + B > E && (E = R.position.x + B), R.position.y + q > _ && (_ = R.position.y + q);
3981
3983
  }
3982
- const H = 40;
3983
- $ -= H, z -= H, E += H, W += H;
3984
- const g = E - $, f = W - z, p = Math.min(t / g, e / f), v = (t - g * p) / 2, w = (e - f * p) / 2;
3984
+ const D = 40;
3985
+ $ -= D, k -= D, E += D, _ += D;
3986
+ const g = E - $, f = _ - k, p = Math.min(t / g, e / f), v = (t - g * p) / 2, N = (e - f * p) / 2;
3985
3987
  for (const R of M) {
3986
3988
  if (R.hidden) continue;
3987
- const B = R.width || wn, q = R.height || bn, D = (R.position.x - $) * p + v, it = (R.position.y - z) * p + w, nt = B * p, lt = q * p;
3988
- C.fillStyle = R.selected ? "#f59e0b" : typeof n == "function" ? n(R) : n, C.fillRect(D, it, Math.max(nt, 2), Math.max(lt, 2));
3989
+ const B = R.width || wn, q = R.height || bn, X = (R.position.x - $) * p + v, K = (R.position.y - k) * p + N, at = B * p, rt = q * p;
3990
+ C.fillStyle = R.selected ? "#f59e0b" : typeof n == "function" ? n(R) : n, C.fillRect(X, K, Math.max(at, 2), Math.max(rt, 2));
3989
3991
  }
3990
- const N = c.cameraRef.current, P = c.wrapRef.current;
3992
+ const w = c.cameraRef.current, P = c.wrapRef.current;
3991
3993
  if (P) {
3992
- const R = P.getBoundingClientRect(), B = -N.x / N.zoom, q = -N.y / N.zoom, D = R.width / N.zoom, it = R.height / N.zoom;
3994
+ const R = P.getBoundingClientRect(), B = -w.x / w.zoom, q = -w.y / w.zoom, X = R.width / w.zoom, K = R.height / w.zoom;
3993
3995
  C.fillStyle = s, C.fillRect(0, 0, t, e);
3994
- const nt = (B - $) * p + v, lt = (q - z) * p + w, G = D * p, j = it * p;
3995
- C.clearRect(nt, lt, G, j);
3996
- for (const st of M) {
3997
- if (st.hidden) continue;
3998
- const rt = st.width || wn, ut = st.height || bn, dt = (st.position.x - $) * p + v, Lt = (st.position.y - z) * p + w;
3999
- C.fillStyle = st.selected ? "#f59e0b" : typeof n == "function" ? n(st) : n, C.fillRect(dt, Lt, Math.max(rt * p, 2), Math.max(ut * p, 2));
3996
+ const at = (B - $) * p + v, rt = (q - k) * p + N, G = X * p, j = K * p;
3997
+ C.clearRect(at, rt, G, j);
3998
+ for (const it of M) {
3999
+ if (it.hidden) continue;
4000
+ const dt = it.width || wn, ot = it.height || bn, ft = (it.position.x - $) * p + v, It = (it.position.y - k) * p + N;
4001
+ C.fillStyle = it.selected ? "#f59e0b" : typeof n == "function" ? n(it) : n, C.fillRect(ft, It, Math.max(dt * p, 2), Math.max(ot * p, 2));
4000
4002
  }
4001
- C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(nt, lt, G, j);
4003
+ C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(at, rt, G, j);
4002
4004
  }
4003
4005
  }, [c, t, e, n, r, s]);
4004
- return ft(() => {
4006
+ return ht(() => {
4005
4007
  let m = !0;
4006
4008
  function C() {
4007
4009
  m && (y(), l.current = requestAnimationFrame(C));
4008
4010
  }
4009
- const k = setInterval(() => {
4011
+ const z = setInterval(() => {
4010
4012
  cancelAnimationFrame(l.current), l.current = requestAnimationFrame(C);
4011
4013
  }, 66);
4012
4014
  return y(), () => {
4013
- m = !1, clearInterval(k), cancelAnimationFrame(l.current);
4015
+ m = !1, clearInterval(z), cancelAnimationFrame(l.current);
4014
4016
  };
4015
4017
  }, [y]), /* @__PURE__ */ S(
4016
4018
  "canvas",
@@ -4033,7 +4035,7 @@ function Qo({
4033
4035
  );
4034
4036
  }
4035
4037
  function no() {
4036
- return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4038
+ return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4037
4039
  /* @__PURE__ */ S("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
4038
4040
  /* @__PURE__ */ S("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
4039
4041
  ] });
@@ -4045,13 +4047,13 @@ function oo() {
4045
4047
  return /* @__PURE__ */ S("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ S("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
4046
4048
  }
4047
4049
  function so() {
4048
- return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4050
+ return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4049
4051
  /* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4050
4052
  /* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
4051
4053
  ] });
4052
4054
  }
4053
4055
  function io() {
4054
- return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4056
+ return /* @__PURE__ */ $t("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
4055
4057
  /* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4056
4058
  /* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
4057
4059
  ] });
@@ -4081,18 +4083,18 @@ function ao({
4081
4083
  style: y = {},
4082
4084
  className: m = "",
4083
4085
  "aria-label": C = "Canvas controls",
4084
- children: k
4086
+ children: z
4085
4087
  }) {
4086
- const M = yt(), { zoomIn: $, zoomOut: z, fitView: E, getZoom: W } = eo(), [H, g] = Gt(!0), f = W() <= M.zoomMin, p = W() >= M.zoomMax, v = F(() => {
4088
+ const M = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [D, g] = Gt(!0), f = _() <= M.zoomMin, p = _() >= M.zoomMax, v = F(() => {
4087
4089
  $(), s == null || s();
4088
- }, [$, s]), w = F(() => {
4089
- z(), o == null || o();
4090
- }, [z, o]), N = F(() => {
4090
+ }, [$, s]), N = F(() => {
4091
+ k(), o == null || o();
4092
+ }, [k, o]), w = F(() => {
4091
4093
  E(r || { padding: 0.1 }), i == null || i();
4092
4094
  }, [E, r, i]), P = F(() => {
4093
- const B = !H;
4095
+ const B = !D;
4094
4096
  g(B), c == null || c(B);
4095
- }, [H, c]), R = {
4097
+ }, [D, c]), R = {
4096
4098
  "top-left": { top: 10, left: 10 },
4097
4099
  "top-right": { top: 10, right: 10 },
4098
4100
  "top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
@@ -4100,7 +4102,7 @@ function ao({
4100
4102
  "bottom-right": { bottom: 30, right: 10 },
4101
4103
  "bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
4102
4104
  }[u] || { bottom: 30, left: 10 };
4103
- return /* @__PURE__ */ It(
4105
+ return /* @__PURE__ */ $t(
4104
4106
  "div",
4105
4107
  {
4106
4108
  className: `ric-controls ${m}`,
@@ -4116,7 +4118,7 @@ function ao({
4116
4118
  role: "toolbar",
4117
4119
  "aria-label": C,
4118
4120
  children: [
4119
- t && /* @__PURE__ */ It(Le, { children: [
4121
+ t && /* @__PURE__ */ $t(Le, { children: [
4120
4122
  /* @__PURE__ */ S(
4121
4123
  rn,
4122
4124
  {
@@ -4131,7 +4133,7 @@ function ao({
4131
4133
  /* @__PURE__ */ S(
4132
4134
  rn,
4133
4135
  {
4134
- onClick: w,
4136
+ onClick: N,
4135
4137
  disabled: f,
4136
4138
  title: "Zoom out",
4137
4139
  "aria-label": "Zoom out",
@@ -4143,7 +4145,7 @@ function ao({
4143
4145
  e && /* @__PURE__ */ S(
4144
4146
  rn,
4145
4147
  {
4146
- onClick: N,
4148
+ onClick: w,
4147
4149
  title: "Fit view",
4148
4150
  "aria-label": "Fit view",
4149
4151
  className: "ric-controls-fitview",
@@ -4154,13 +4156,13 @@ function ao({
4154
4156
  rn,
4155
4157
  {
4156
4158
  onClick: P,
4157
- title: H ? "Lock interactivity" : "Unlock interactivity",
4158
- "aria-label": H ? "Lock interactivity" : "Unlock interactivity",
4159
+ title: D ? "Lock interactivity" : "Unlock interactivity",
4160
+ "aria-label": D ? "Lock interactivity" : "Unlock interactivity",
4159
4161
  className: "ric-controls-interactive",
4160
- children: H ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
4162
+ children: D ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
4161
4163
  }
4162
4164
  ),
4163
- k
4165
+ z
4164
4166
  ]
4165
4167
  }
4166
4168
  );
@@ -4237,32 +4239,32 @@ function ts({
4237
4239
  onResize: l,
4238
4240
  onResizeEnd: y
4239
4241
  }) {
4240
- const m = qe(je), C = yt(), k = V(null), M = F((E, W) => {
4242
+ const m = qe(je), C = yt(), z = tt(null), M = F((E, _) => {
4241
4243
  E.stopPropagation(), E.preventDefault();
4242
- const H = C.nodesRef.current.find((p) => p.id === m);
4243
- if (!H) return;
4244
- k.current = {
4245
- direction: W,
4244
+ const D = C.nodesRef.current.find((p) => p.id === m);
4245
+ if (!D) return;
4246
+ z.current = {
4247
+ direction: _,
4246
4248
  startX: E.clientX,
4247
4249
  startY: E.clientY,
4248
- width: H.width || 160,
4249
- height: H.height || 60
4250
- }, u == null || u(E, { width: k.current.width, height: k.current.height });
4250
+ width: D.width || 160,
4251
+ height: D.height || 60
4252
+ }, u == null || u(E, { width: z.current.width, height: z.current.height });
4251
4253
  const g = (p) => {
4252
- var q, D;
4253
- if (!k.current) return;
4254
- const v = k.current, w = C.cameraRef.current, N = (p.clientX - v.startX) / w.zoom, P = (p.clientY - v.startY) / w.zoom;
4254
+ var q, X;
4255
+ if (!z.current) return;
4256
+ const v = z.current, N = C.cameraRef.current, w = (p.clientX - v.startX) / N.zoom, P = (p.clientY - v.startY) / N.zoom;
4255
4257
  let R = v.width, B = v.height;
4256
- v.direction.includes("e") && (R = Math.min(n, Math.max(t, v.width + N))), v.direction.includes("w") && (R = Math.min(n, Math.max(t, v.width - N))), v.direction.includes("s") && (B = Math.min(r, Math.max(e, v.height + P))), v.direction.includes("n") && (B = Math.min(r, Math.max(e, v.height - P))), (D = (q = C.onNodesChangeRef).current) == null || D.call(q, [
4258
+ v.direction.includes("e") && (R = Math.min(n, Math.max(t, v.width + w))), v.direction.includes("w") && (R = Math.min(n, Math.max(t, v.width - w))), v.direction.includes("s") && (B = Math.min(r, Math.max(e, v.height + P))), v.direction.includes("n") && (B = Math.min(r, Math.max(e, v.height - P))), (X = (q = C.onNodesChangeRef).current) == null || X.call(q, [
4257
4259
  { id: m, type: "dimensions", dimensions: { width: R, height: B }, setAttributes: !0 }
4258
4260
  ]), l == null || l(p, { width: R, height: B });
4259
4261
  }, f = (p) => {
4260
- k.current = null, y == null || y(p, {}), window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", f);
4262
+ z.current = null, y == null || y(p, {}), window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", f);
4261
4263
  };
4262
4264
  window.addEventListener("pointermove", g), window.addEventListener("pointerup", f);
4263
4265
  }, [m, C, t, e, n, r, u, l, y]);
4264
4266
  if (!s) return null;
4265
- const $ = 8, z = {
4267
+ const $ = 8, k = {
4266
4268
  position: "absolute",
4267
4269
  width: $,
4268
4270
  height: $,
@@ -4272,60 +4274,60 @@ function ts({
4272
4274
  zIndex: 20,
4273
4275
  ...o
4274
4276
  };
4275
- return /* @__PURE__ */ It(Le, { children: [
4277
+ return /* @__PURE__ */ $t(Le, { children: [
4276
4278
  /* @__PURE__ */ S(
4277
4279
  "div",
4278
4280
  {
4279
- style: { ...z, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
4281
+ style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
4280
4282
  onPointerDown: (E) => M(E, "se")
4281
4283
  }
4282
4284
  ),
4283
4285
  /* @__PURE__ */ S(
4284
4286
  "div",
4285
4287
  {
4286
- style: { ...z, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
4288
+ style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
4287
4289
  onPointerDown: (E) => M(E, "sw")
4288
4290
  }
4289
4291
  ),
4290
4292
  /* @__PURE__ */ S(
4291
4293
  "div",
4292
4294
  {
4293
- style: { ...z, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
4295
+ style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
4294
4296
  onPointerDown: (E) => M(E, "ne")
4295
4297
  }
4296
4298
  ),
4297
4299
  /* @__PURE__ */ S(
4298
4300
  "div",
4299
4301
  {
4300
- style: { ...z, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
4302
+ style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
4301
4303
  onPointerDown: (E) => M(E, "nw")
4302
4304
  }
4303
4305
  ),
4304
4306
  /* @__PURE__ */ S(
4305
4307
  "div",
4306
4308
  {
4307
- style: { ...z, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4309
+ style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4308
4310
  onPointerDown: (E) => M(E, "e")
4309
4311
  }
4310
4312
  ),
4311
4313
  /* @__PURE__ */ S(
4312
4314
  "div",
4313
4315
  {
4314
- style: { ...z, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4316
+ style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4315
4317
  onPointerDown: (E) => M(E, "w")
4316
4318
  }
4317
4319
  ),
4318
4320
  /* @__PURE__ */ S(
4319
4321
  "div",
4320
4322
  {
4321
- style: { ...z, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4323
+ style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4322
4324
  onPointerDown: (E) => M(E, "n")
4323
4325
  }
4324
4326
  ),
4325
4327
  /* @__PURE__ */ S(
4326
4328
  "div",
4327
4329
  {
4328
- style: { ...z, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4330
+ style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4329
4331
  onPointerDown: (E) => M(E, "s")
4330
4332
  }
4331
4333
  )
@@ -4515,7 +4517,7 @@ export {
4515
4517
  Wr as OutputNode,
4516
4518
  Vo as Panel,
4517
4519
  is as Position,
4518
- Hr as SelectionBox,
4520
+ Ar as SelectionBox,
4519
4521
  cr as SimpleBezierEdge,
4520
4522
  ar as SmoothStepEdge,
4521
4523
  Or as StepEdge,
@@ -4553,7 +4555,7 @@ export {
4553
4555
  Lo as routeSinglePath,
4554
4556
  En as routedPointsToPath,
4555
4557
  Pn as snapPosition,
4556
- Ao as useConnection,
4558
+ Ho as useConnection,
4557
4559
  Do as useEdges,
4558
4560
  So as useEdgesState,
4559
4561
  Xo as useHandleConnections,
@@ -4572,5 +4574,5 @@ export {
4572
4574
  Zo as useStore,
4573
4575
  Oo as useStoreApi,
4574
4576
  qo as useUpdateNodeInternals,
4575
- Ho as useViewport
4577
+ Ao as useViewport
4576
4578
  };