@infinit-canvas/react 0.1.2 → 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 B, jsxs as It, Fragment as Le } from "react/jsx-runtime";
2
- import { useRef as V, useState as Gt, useMemo as St, useEffect as ut, 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: g } = jn(u), v = u.position.x, E = u.position.y, R = v + l, M = E + g;
67
- return r ? v < i && R > s && E < c && M > o : v >= s && R <= i && E >= 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) {
@@ -961,46 +961,46 @@ function Lr({
961
961
  onConnect: c,
962
962
  onNodeClick: u,
963
963
  onNodeDragStart: l,
964
- onNodeDrag: g,
965
- onNodeDragStop: v,
966
- onEdgeClick: E,
967
- onEdgeDoubleClick: R,
964
+ onNodeDrag: y,
965
+ onNodeDragStop: m,
966
+ onEdgeClick: C,
967
+ onEdgeDoubleClick: z,
968
968
  onEdgeMouseEnter: M,
969
- onEdgeMouseMove: T,
969
+ onEdgeMouseMove: $,
970
970
  onEdgeMouseLeave: k,
971
- onEdgeContextMenu: z,
972
- onNodeDoubleClick: W,
971
+ onEdgeContextMenu: E,
972
+ onNodeDoubleClick: _,
973
973
  onNodeMouseEnter: D,
974
- onNodeMouseMove: x,
974
+ onNodeMouseMove: g,
975
975
  onNodeMouseLeave: f,
976
976
  onNodeContextMenu: p,
977
- onPaneClick: y,
977
+ onPaneClick: v,
978
978
  onPaneContextMenu: N,
979
- onPaneMouseEnter: C,
979
+ onPaneMouseEnter: w,
980
980
  onPaneMouseMove: P,
981
- onPaneMouseLeave: b,
982
- onSelectionChange: L,
983
- onConnectStart: Y,
984
- onConnectEnd: H,
985
- onInit: dt,
986
- onMoveStart: yt,
987
- onMove: ft,
981
+ onPaneMouseLeave: R,
982
+ onSelectionChange: B,
983
+ onConnectStart: q,
984
+ onConnectEnd: X,
985
+ onInit: K,
986
+ onMoveStart: at,
987
+ onMove: rt,
988
988
  onMoveEnd: G,
989
989
  onDelete: j,
990
- onBeforeDelete: rt,
991
- onError: at,
992
- isValidConnection: ct,
993
- dark: lt,
994
- gridSize: Ct = 40,
995
- zoomMin: et = 0.1,
996
- zoomMax: ot = 4,
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
997
  initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
998
- fitView: Rt = !1,
999
- fitViewOptions: vt,
1000
- nodesDraggable: Lt = !0,
1001
- nodesConnectable: kt = !0,
1002
- elementsSelectable: $t = !0,
1003
- multiSelectionKeyCode: mt = "Shift",
998
+ fitView: gt = !1,
999
+ fitViewOptions: ct,
1000
+ nodesDraggable: zt = !0,
1001
+ nodesConnectable: Rt = !0,
1002
+ elementsSelectable: Lt = !0,
1003
+ multiSelectionKeyCode: wt = "Shift",
1004
1004
  selectionOnDrag: ne = !1,
1005
1005
  selectionMode: Ie = "partial",
1006
1006
  connectionMode: Bt = "loose",
@@ -1027,7 +1027,7 @@ function Lr({
1027
1027
  elevateNodesOnSelect: hn = !1,
1028
1028
  edgeRouting: fe = !0
1029
1029
  } = {}) {
1030
- const pt = V(null), Te = V(null), zt = V(null), gt = V({ ...Nt }), 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: Nt.x, y: Nt.y, zoom: Nt.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,
@@ -1036,37 +1036,37 @@ function Lr({
1036
1036
  onConnect: c,
1037
1037
  onNodeClick: u,
1038
1038
  onNodeDragStart: l,
1039
- onNodeDrag: g,
1040
- onNodeDragStop: v,
1041
- onEdgeClick: E,
1042
- onEdgeDoubleClick: R,
1039
+ onNodeDrag: y,
1040
+ onNodeDragStop: m,
1041
+ onEdgeClick: C,
1042
+ onEdgeDoubleClick: z,
1043
1043
  onEdgeMouseEnter: M,
1044
- onEdgeMouseMove: T,
1044
+ onEdgeMouseMove: $,
1045
1045
  onEdgeMouseLeave: k,
1046
- onEdgeContextMenu: z,
1047
- onNodeDoubleClick: W,
1046
+ onEdgeContextMenu: E,
1047
+ onNodeDoubleClick: _,
1048
1048
  onNodeMouseEnter: D,
1049
- onNodeMouseMove: x,
1049
+ onNodeMouseMove: g,
1050
1050
  onNodeMouseLeave: f,
1051
1051
  onNodeContextMenu: p,
1052
- onPaneClick: y,
1052
+ onPaneClick: v,
1053
1053
  onPaneContextMenu: N,
1054
- onPaneMouseEnter: C,
1054
+ onPaneMouseEnter: w,
1055
1055
  onPaneMouseMove: P,
1056
- onPaneMouseLeave: b,
1057
- onSelectionChange: L,
1058
- onConnectStart: Y,
1059
- onConnectEnd: H,
1060
- onInit: dt,
1061
- onMoveStart: yt,
1062
- onMove: ft,
1056
+ onPaneMouseLeave: R,
1057
+ onSelectionChange: B,
1058
+ onConnectStart: q,
1059
+ onConnectEnd: X,
1060
+ onInit: K,
1061
+ onMoveStart: at,
1062
+ onMove: rt,
1063
1063
  onMoveEnd: G,
1064
1064
  onDelete: j,
1065
- onBeforeDelete: rt,
1066
- onError: at,
1067
- isValidConnection: ct
1065
+ onBeforeDelete: it,
1066
+ onError: dt,
1067
+ isValidConnection: ot
1068
1068
  };
1069
- const wt = { 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,387 +1091,387 @@ function Lr({
1091
1091
  } }, pe = { get current() {
1092
1092
  return O.current.onNodesProcessed;
1093
1093
  } };
1094
- ut(() => {
1094
+ ht(() => {
1095
1095
  const a = (d) => {
1096
- d.key === mt && (Ut.current = !0), d.key === we && (ke.current = !0);
1097
- }, m = (d) => {
1098
- d.key === mt && (Ut.current = !1), d.key === we && (ke.current = !1);
1096
+ d.key === wt && (Ut.current = !0), d.key === we && (ke.current = !0);
1097
+ }, x = (d) => {
1098
+ d.key === wt && (Ut.current = !1), d.key === we && (ke.current = !1);
1099
1099
  };
1100
- return window.addEventListener("keydown", a), window.addEventListener("keyup", m), () => {
1101
- window.removeEventListener("keydown", a), window.removeEventListener("keyup", m);
1100
+ return window.addEventListener("keydown", a), window.addEventListener("keyup", x), () => {
1101
+ window.removeEventListener("keydown", a), window.removeEventListener("keyup", x);
1102
1102
  };
1103
- }, [mt, we]);
1103
+ }, [wt, we]);
1104
1104
  const Jt = F(() => {
1105
- var w;
1106
- const a = Z.current.filter((I) => I.selected), m = Pt.current.filter((I) => I.selected), d = { nodes: a, edges: m };
1107
- (w = ye.current) == null || w.call(ye, d);
1108
- for (const I of he) I(d);
1105
+ var b;
1106
+ const a = Z.current.filter((L) => L.selected), x = Pt.current.filter((L) => L.selected), d = { nodes: a, edges: x };
1107
+ (b = ye.current) == null || b.call(ye, d);
1108
+ for (const L of he) L(d);
1109
1109
  }, [he]);
1110
- ut(() => {
1110
+ ht(() => {
1111
1111
  var a;
1112
- se.current = [...t], (a = zt.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
- const m = {};
1116
- for (const d of a) m[d.id] = d;
1115
+ const x = {};
1116
+ for (const d of a) x[d.id] = d;
1117
1117
  return a.map((d) => {
1118
1118
  if (!d.parentId) return d;
1119
- const w = m[d.parentId];
1120
- if (!w) return d;
1121
- let I = d.position.x, $ = d.position.y, h = w;
1119
+ const b = x[d.parentId];
1120
+ if (!b) return d;
1121
+ let L = d.position.x, I = d.position.y, h = b;
1122
1122
  for (; h; )
1123
- I += h.position.x, $ += h.position.y, h = h.parentId ? m[h.parentId] : null;
1124
- return { ...d, _absolutePosition: { x: I, y: $ } };
1123
+ L += h.position.x, I += h.position.y, h = h.parentId ? x[h.parentId] : null;
1124
+ return { ...d, _absolutePosition: { x: L, y: I } };
1125
1125
  });
1126
- }, []), ee = V([]), Q = F((a) => {
1127
- const m = yn.current;
1128
- if (!m || m.size === 0) return a;
1126
+ }, []), ee = tt([]), Q = F((a) => {
1127
+ const x = yn.current;
1128
+ if (!x || x.size === 0) return a;
1129
1129
  const d = {};
1130
- for (const [, w] of m)
1131
- d[w.nodeId] || (d[w.nodeId] = []), d[w.nodeId].push({ id: w.id, type: w.type, position: w.position, x: w.x, y: w.y });
1132
- return a.map((w) => {
1133
- const I = d[w.id];
1134
- return I && I.length > 0 ? { ...w, handles: I } : w;
1130
+ for (const [, b] of x)
1131
+ d[b.nodeId] || (d[b.nodeId] = []), d[b.nodeId].push({ id: b.id, type: b.type, position: b.position, x: b.x, y: b.y });
1132
+ return a.map((b) => {
1133
+ const L = d[b.id];
1134
+ return L && L.length > 0 ? { ...b, handles: L } : b;
1135
1135
  });
1136
1136
  }, []), Ft = F(() => {
1137
- var m;
1137
+ var x;
1138
1138
  if (_t.current) return;
1139
1139
  const a = Q(ee.current);
1140
- (m = zt.current) == null || m.postMessage({ type: "nodes", data: { nodes: a } });
1140
+ (x = Et.current) == null || x.postMessage({ type: "nodes", data: { nodes: a } });
1141
1141
  }, [Q]);
1142
- ut(() => {
1142
+ ht(() => {
1143
1143
  var d;
1144
1144
  if (_t.current) {
1145
- const w = _t.current.id, I = /* @__PURE__ */ new Set([w, ..._t.current.selectedStarts.map((h) => h.id)]), $ = {};
1145
+ const b = _t.current.id, L = /* @__PURE__ */ new Set([b, ..._t.current.selectedStarts.map((h) => h.id)]), I = {};
1146
1146
  for (const h of Z.current)
1147
- I.has(h.id) && ($[h.id] = { ...h.position });
1147
+ L.has(h.id) && (I[h.id] = { ...h.position });
1148
1148
  Z.current = [...e];
1149
1149
  for (const h of Z.current)
1150
- $[h.id] && (h.position = $[h.id]);
1150
+ I[h.id] && (h.position = I[h.id]);
1151
1151
  ee.current = ze(Z.current);
1152
1152
  return;
1153
1153
  }
1154
1154
  Z.current = [...e];
1155
1155
  const a = ze(e);
1156
1156
  ee.current = a;
1157
- const m = Q(a);
1158
- (d = zt.current) == null || d.postMessage({ type: "nodes", data: { nodes: m } });
1159
- }, [e, ze, Q]), ut(() => {
1157
+ const x = Q(a);
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 = zt.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 st = F((a, m) => {
1164
- const d = pt.current;
1163
+ const lt = F((a, x) => {
1164
+ const d = mt.current;
1165
1165
  if (!d) return { x: 0, y: 0 };
1166
- const w = d.getBoundingClientRect(), I = gt.current;
1166
+ const b = d.getBoundingClientRect(), L = pt.current;
1167
1167
  return {
1168
- x: (a - w.left - I.x) / I.zoom,
1169
- y: (m - w.top - I.y) / I.zoom
1168
+ x: (a - b.left - L.x) / L.zoom,
1169
+ y: (x - b.top - L.y) / L.zoom
1170
1170
  };
1171
- }, []), Tt = F((a, m) => {
1171
+ }, []), Tt = F((a, x) => {
1172
1172
  const d = ee.current.length > 0 ? ee.current : Z.current;
1173
- let w = null;
1174
- for (let I = d.length - 1; I >= 0; I--) {
1175
- const $ = d[I];
1176
- if ($.hidden) continue;
1177
- const h = $._absolutePosition || $.position, A = $.width || Vt, S = $.height || jt;
1178
- if (a >= h.x && a <= h.x + A && m >= h.y && m <= h.y + S) {
1179
- if ($.type === "group") {
1180
- w || (w = $);
1173
+ let b = null;
1174
+ for (let L = d.length - 1; L >= 0; L--) {
1175
+ const I = d[L];
1176
+ if (I.hidden) continue;
1177
+ const h = I._absolutePosition || I.position, A = I.width || Vt, T = I.height || jt;
1178
+ if (a >= h.x && a <= h.x + A && x >= h.y && x <= h.y + T) {
1179
+ if (I.type === "group") {
1180
+ b || (b = I);
1181
1181
  continue;
1182
1182
  }
1183
- return $;
1183
+ return I;
1184
1184
  }
1185
1185
  }
1186
- return w;
1187
- }, []), xe = F((a, m) => {
1188
- const d = m.width || Vt, w = m.height || jt;
1186
+ return b;
1187
+ }, []), xe = F((a, x) => {
1188
+ const d = x.width || Vt, b = x.height || jt;
1189
1189
  if (a.x !== void 0 && a.y !== void 0)
1190
- return { x: m.position.x + a.x, y: m.position.y + a.y };
1190
+ return { x: x.position.x + a.x, y: x.position.y + a.y };
1191
1191
  switch (a.position || (a.type === "source" ? "right" : "left")) {
1192
1192
  case "top":
1193
- return { x: m.position.x + d / 2, y: m.position.y };
1193
+ return { x: x.position.x + d / 2, y: x.position.y };
1194
1194
  case "bottom":
1195
- return { x: m.position.x + d / 2, y: m.position.y + w };
1195
+ return { x: x.position.x + d / 2, y: x.position.y + b };
1196
1196
  case "left":
1197
- return { x: m.position.x, y: m.position.y + w / 2 };
1197
+ return { x: x.position.x, y: x.position.y + b / 2 };
1198
1198
  case "right":
1199
- return { x: m.position.x + d, y: m.position.y + w / 2 };
1199
+ return { x: x.position.x + d, y: x.position.y + b / 2 };
1200
1200
  default:
1201
- return { x: m.position.x + d, y: m.position.y + w / 2 };
1201
+ return { x: x.position.x + d, y: x.position.y + b / 2 };
1202
1202
  }
1203
1203
  }, []), Ee = F((a) => {
1204
- const m = a.width || Vt, d = a.height || jt;
1205
- return a.handles && a.handles.length > 0 ? a.handles.map((w) => {
1206
- const I = xe(w, a);
1207
- return { id: w.id || null, type: w.type, x: I.x, y: I.y };
1204
+ const x = a.width || Vt, d = a.height || jt;
1205
+ return a.handles && a.handles.length > 0 ? a.handles.map((b) => {
1206
+ const L = xe(b, a);
1207
+ return { id: b.id || null, type: b.type, x: L.x, y: L.y };
1208
1208
  }) : [
1209
1209
  { id: null, type: "target", x: a.position.x, y: a.position.y + d / 2 },
1210
- { id: null, type: "source", x: a.position.x + m, y: a.position.y + d / 2 }
1210
+ { id: null, type: "source", x: a.position.x + x, y: a.position.y + d / 2 }
1211
1211
  ];
1212
- }, [xe]), tn = F((a, m) => {
1213
- const d = Z.current, w = gt.current, I = Math.max(Nr, Ot) / w.zoom;
1214
- for (let $ = d.length - 1; $ >= 0; $--) {
1215
- const h = d[$];
1212
+ }, [xe]), tn = F((a, x) => {
1213
+ const d = Z.current, b = pt.current, L = Math.max(Nr, Ot) / b.zoom;
1214
+ for (let I = d.length - 1; I >= 0; I--) {
1215
+ const h = d[I];
1216
1216
  if (h.hidden) continue;
1217
1217
  const A = Ee(h);
1218
- for (const S of A)
1219
- if (Math.abs(a - S.x) < I && Math.abs(m - S.y) < I)
1220
- return { nodeId: h.id, handleId: S.id, type: S.type, x: S.x, y: S.y };
1218
+ for (const T of A)
1219
+ if (Math.abs(a - T.x) < L && Math.abs(x - T.y) < L)
1220
+ return { nodeId: h.id, handleId: T.id, type: T.type, x: T.x, y: T.y };
1221
1221
  }
1222
1222
  return null;
1223
- }, [Ee]), ue = F((a, m) => {
1224
- const w = 8 / gt.current.zoom;
1225
- for (let I = Pt.current.length - 1; I >= 0; I--) {
1226
- const $ = Pt.current[I], h = Z.current.find((bt) => bt.id === $.source), A = Z.current.find((bt) => bt.id === $.target);
1223
+ }, [Ee]), ue = F((a, x) => {
1224
+ const b = 8 / pt.current.zoom;
1225
+ for (let L = Pt.current.length - 1; L >= 0; L--) {
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 S = h.width || Vt, U = h.height || jt, _ = A.height || jt, K = h.position.x + S, it = h.position.y + U / 2, q = A.position.x, nt = A.position.y + _ / 2;
1229
- if (Ir(a, m, K, it, q, nt) < w) return $;
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
- ut(() => {
1234
- const a = Te.current, m = pt.current;
1235
- if (!a || !m) return;
1236
- const d = m.getBoundingClientRect(), w = lt !== void 0 ? lt : matchMedia("(prefers-color-scheme: dark)").matches, I = ze(Z.current);
1237
- ee.current = I;
1238
- const $ = Q(I), { worker: h } = Cr(a, {
1233
+ ht(() => {
1234
+ const a = Te.current, x = mt.current;
1235
+ if (!a || !x) return;
1236
+ const d = x.getBoundingClientRect(), b = ft !== void 0 ? ft : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
1237
+ ee.current = L;
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
- nodes: $,
1243
+ nodes: I,
1244
1244
  edges: Pt.current,
1245
- dark: w,
1246
- gridSize: Ct,
1245
+ dark: b,
1246
+ gridSize: It,
1247
1247
  edgeRouting: fe
1248
1248
  });
1249
- h.onmessage = (_) => {
1250
- var K, it;
1251
- _.data.type === "hud" && ((K = ge.current) == null || K.call(ge, _.data.data)), _.data.type === "ready" && pn(!0), _.data.type === "nodesProcessed" && ((it = pe.current) == null || it.call(pe, _.data.data));
1252
- }, zt.current = h;
1253
- const A = new ResizeObserver((_) => {
1254
- const { width: K, height: it } = _[0].contentRect;
1255
- h.postMessage({ type: "resize", data: { width: K, height: it } });
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
- A.observe(m);
1258
- let S, U;
1259
- return lt === void 0 && (S = matchMedia("(prefers-color-scheme: dark)"), U = (_) => h.postMessage({ type: "theme", data: { dark: _.matches } }), S.addEventListener("change", U)), () => {
1260
- A.disconnect(), S && U && S.removeEventListener("change", U), zt.current = null;
1257
+ A.observe(x);
1258
+ let T, Y;
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
- }, []), ut(() => {
1262
+ }, []), ht(() => {
1263
1263
  var a;
1264
- lt !== void 0 && ((a = zt.current) == null || a.postMessage({ type: "theme", data: { dark: lt } }));
1265
- }, [lt]), ut(() => {
1264
+ ft !== void 0 && ((a = Et.current) == null || a.postMessage({ type: "theme", data: { dark: ft } }));
1265
+ }, [ft]), ht(() => {
1266
1266
  var a;
1267
- (a = zt.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), Et = F((a = null) => {
1270
- var w, I, $;
1271
- const m = gt.current;
1269
+ const Ln = tt(0), Ct = F((a = null) => {
1270
+ var b, L, I;
1271
+ const x = pt.current;
1272
1272
  if (re) {
1273
- const h = pt.current;
1273
+ const h = mt.current;
1274
1274
  if (h) {
1275
- const A = h.getBoundingClientRect(), S = -re[1][0] * m.zoom + A.width, U = -re[1][1] * m.zoom + A.height, _ = -re[0][0] * m.zoom, K = -re[0][1] * m.zoom;
1276
- m.x = Math.min(_, Math.max(S, m.x)), m.y = Math.min(K, Math.max(U, m.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
- (w = zt.current) == null || w.postMessage({ type: "camera", data: { camera: { ...m } } });
1280
- const d = { x: m.x, y: m.y, zoom: m.zoom };
1281
- ($ = (I = O.current).onMove) == null || $.call(I, a, d);
1279
+ (b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...x } } });
1280
+ const d = { x: x.x, y: x.y, zoom: x.zoom };
1281
+ (I = (L = O.current).onMove) == null || I.call(L, a, d);
1282
1282
  for (const h of Kt) h(d);
1283
1283
  cancelAnimationFrame(Ln.current), Ln.current = requestAnimationFrame(() => {
1284
- Je({ x: m.x, y: m.y, zoom: m.zoom });
1284
+ Je({ x: x.x, y: x.y, zoom: x.zoom });
1285
1285
  });
1286
1286
  }, [Kt, re]), Ce = F(() => {
1287
- var d, w;
1288
- const a = Wt.current, m = Me.current;
1289
- a && m ? ((d = zt.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: m, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((w = zt.current) == null || w.postMessage({ type: "connecting", data: null }), ae(null));
1287
+ var d, b;
1288
+ const a = Wt.current, x = Me.current;
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
- var m, d;
1291
+ var x, d;
1292
1292
  const a = ie.current;
1293
- a ? (m = zt.current) == null || m.postMessage({ type: "selectionBox", data: a }) : (d = zt.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 I, $, h, A, S, U, _, K, it, q, nt, xt, bt, Ht, Xt, At;
1296
- const m = Z.current.length > 0, d = st(a.clientX, a.clientY), w = Ut.current;
1297
- if (m && 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 };
1303
- (O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((I = ce.current) == null || I.call(ce, { ...qt, ...be }));
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
+ (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 = ($ = O.current).onConnectStart) == null || h.call($, 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 = pt.current) == null || A.setPointerCapture(a.pointerId), (U = (S = O.current).onConnectStart) == null || U.call(S, 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
- if (m) {
1323
- const X = Tt(d.x, d.y);
1324
- if (X) {
1325
- if (wt.current && $t) {
1326
- const Mt = [];
1327
- if (w)
1328
- Mt.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 ? Mt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && Mt.push({ id: J.id, type: "select", selected: !1 });
1322
+ if (x) {
1323
+ const W = Tt(d.x, d.y);
1324
+ if (W) {
1325
+ if (bt.current && Lt) {
1326
+ const kt = [];
1327
+ if (b)
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 (Mt.length) {
1338
- if (wt.current(Mt), hn && !w) {
1339
- const J = Z.current.findIndex((tt) => tt.id === X.id);
1340
- J >= 0 && J < Z.current.length - 1 && wt.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), Lt) {
1349
- const Mt = w && 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 || ((it = X.measured) == null ? void 0 : it.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: Mt ? 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
- }, (q = pt.current) == null || q.setPointerCapture(a.pointerId), (nt = He.current) == null || nt.call(He, a, X), wt.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
- wt.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 Mt = [];
1391
- if (w)
1392
- Mt.push({ id: X.id, type: "select", selected: !X.selected });
1390
+ const kt = [];
1391
+ if (b)
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 ? Mt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && Mt.push({ id: J.id, type: "select", selected: !1 });
1396
- if (wt.current) {
1397
- const J = Z.current.filter((tt) => tt.selected).map((tt) => ({ id: tt.id, type: "select", selected: !1 }));
1398
- J.length && wt.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
- Mt.length && (Dt.current(Mt), Jt());
1401
+ kt.length && (Dt.current(kt), Jt());
1402
1402
  }
1403
- (xt = le.current) == null || xt.call(le, a, X);
1403
+ (vt = le.current) == null || vt.call(le, a, W);
1404
1404
  return;
1405
1405
  }
1406
1406
  }
1407
- if (!w) {
1408
- const X = Z.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 })), Mt = Pt.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 }));
1409
- X.length && wt.current && wt.current(X), Mt.length && Dt.current && Dt.current(Mt), (X.length || Mt.length) && Jt();
1407
+ if (!b) {
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 ((bt = We.current) == null || bt.call(We, a), ne || w) {
1412
- ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (Ht = pt.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 = pt.current) == null || Xt.classList.add("dragging"), (At = pt.current) == null || At.setPointerCapture(a.pointerId);
1416
- }, [st, Tt, tn, ue, Lt, kt, $t, ne, Ce, Ne, Jt]), fr = F((a) => {
1417
- var d, w;
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
+ var d, b;
1418
1418
  if (Wt.current) {
1419
- if (Me.current = st(a.clientX, a.clientY), Ce(), fn) {
1420
- const I = pt.current;
1421
- if (I) {
1422
- const $ = I.getBoundingClientRect(), h = 40, A = a.clientX - $.left, S = a.clientY - $.top;
1423
- let U = 0, _ = 0;
1424
- A < h ? U = Qt : A > $.width - h && (U = -Qt), S < h ? _ = Qt : S > $.height - h && (_ = -Qt), (U || _) && (gt.current.x += U, gt.current.y += _, Et(a));
1419
+ if (Me.current = lt(a.clientX, a.clientY), Ce(), fn) {
1420
+ const L = mt.current;
1421
+ if (L) {
1422
+ const I = L.getBoundingClientRect(), h = 40, A = a.clientX - I.left, T = a.clientY - I.top;
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 = st(a.clientX, a.clientY), Ne();
1431
- const I = ie.current, $ = Math.min(I.startWorld.x, I.endWorld.x), h = Math.min(I.startWorld.y, I.endWorld.y), A = Math.max(I.startWorld.x, I.endWorld.x), S = Math.max(I.startWorld.y, I.endWorld.y);
1432
- if (wt.current) {
1433
- const U = [];
1434
- for (const _ of Z.current) {
1435
- if (_.hidden) continue;
1436
- const K = _.width || Vt, it = _.height || jt, q = Ie === "full" ? _.position.x >= $ && _.position.x + K <= A && _.position.y >= h && _.position.y + it <= S : _.position.x + K > $ && _.position.x < A && _.position.y + it > h && _.position.y < S;
1437
- q !== !!_.selected && U.push({ id: _.id, type: "select", selected: q });
1430
+ ie.current.endWorld = lt(a.clientX, a.clientY), Ne();
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 (bt.current) {
1433
+ const Y = [];
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
- U.length && wt.current(U);
1439
+ Y.length && bt.current(Y);
1440
1440
  }
1441
1441
  return;
1442
1442
  }
1443
1443
  if (_t.current) {
1444
- const I = st(a.clientX, a.clientY), $ = _t.current, h = I.x - $.startMouse.x, A = I.y - $.startMouse.y;
1445
- let S = { x: $.startPos.x + h, y: $.startPos.y + A };
1446
- if (me && (S = Pn(S, de)), oe && (S = Tn(S, oe)), $.parentClamp) {
1447
- const q = $.parentClamp;
1448
- S = { x: Math.max(q.minX, Math.min(S.x, q.maxX)), y: Math.max(q.minY, Math.min(S.y, q.maxY)) };
1444
+ const L = lt(a.clientX, a.clientY), I = _t.current, h = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
1445
+ let T = { x: I.startPos.x + h, y: I.startPos.y + A };
1446
+ if (me && (T = Pn(T, de)), oe && (T = Tn(T, oe)), I.parentClamp) {
1447
+ const U = I.parentClamp;
1448
+ T = { x: Math.max(U.minX, Math.min(T.x, U.maxX)), y: Math.max(U.minY, Math.min(T.y, U.maxY)) };
1449
1449
  }
1450
- const U = [{ id: $.id, position: S }];
1451
- for (const q of $.selectedStarts) {
1452
- let nt = { x: q.startPos.x + h, y: q.startPos.y + A };
1453
- if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), q.parentClamp) {
1454
- const xt = q.parentClamp;
1455
- nt = { x: Math.max(xt.minX, Math.min(nt.x, xt.maxX)), y: Math.max(xt.minY, Math.min(nt.y, xt.maxY)) };
1450
+ const Y = [{ id: I.id, position: T }];
1451
+ for (const U of I.selectedStarts) {
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
- U.push({ id: q.id, position: nt });
1457
+ Y.push({ id: U.id, position: nt });
1458
1458
  }
1459
- const _ = [];
1460
- for (const q of U) {
1461
- const nt = Z.current.find((xt) => xt.id === q.id);
1459
+ const H = [];
1460
+ for (const U of Y) {
1461
+ const nt = Z.current.find((vt) => vt.id === U.id);
1462
1462
  if (nt) {
1463
- nt.position = q.position, nt.dragging = !0;
1464
- let xt = q.position;
1463
+ nt.position = U.position, nt.dragging = !0;
1464
+ let vt = U.position;
1465
1465
  if (nt.parentId) {
1466
- let bt = Z.current.find((At) => At.id === nt.parentId), Ht = q.position.x, Xt = q.position.y;
1467
- for (; bt; )
1468
- Ht += bt.position.x, Xt += bt.position.y, bt = bt.parentId ? Z.current.find((At) => At.id === bt.parentId) : null;
1469
- xt = { x: Ht, y: Xt };
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({
1472
- id: q.id,
1473
- position: q.position,
1474
- _absolutePosition: xt,
1471
+ H.push({
1472
+ id: U.id,
1473
+ position: U.position,
1474
+ _absolutePosition: vt,
1475
1475
  width: nt.width,
1476
1476
  height: nt.height,
1477
1477
  dragging: !0,
@@ -1479,43 +1479,43 @@ function Lr({
1479
1479
  });
1480
1480
  }
1481
1481
  }
1482
- const K = new Set(U.map((q) => q.id));
1483
- for (const q of Z.current)
1484
- if (q.parentId && K.has(q.parentId) && !K.has(q.id)) {
1485
- let nt = Z.current.find((Ht) => Ht.id === q.parentId), xt = q.position.x, bt = q.position.y;
1482
+ const J = new Set(Y.map((U) => U.id));
1483
+ for (const U of Z.current)
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
1486
  for (; nt; )
1487
- xt += nt.position.x, bt += nt.position.y, nt = nt.parentId ? Z.current.find((Ht) => Ht.id === nt.parentId) : null;
1488
- _.push({
1489
- id: q.id,
1490
- position: q.position,
1491
- _absolutePosition: { x: xt, y: bt },
1492
- width: q.width,
1493
- height: q.height,
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
+ id: U.id,
1490
+ position: U.position,
1491
+ _absolutePosition: { x: vt, y: Mt },
1492
+ width: U.width,
1493
+ height: U.height,
1494
1494
  dragging: !1,
1495
- selected: q.selected
1495
+ selected: U.selected
1496
1496
  });
1497
1497
  }
1498
- if ((d = zt.current) == null || d.postMessage({ type: "nodePositions", data: { updates: _ } }), dn) {
1499
- const q = pt.current;
1500
- if (q) {
1501
- const nt = q.getBoundingClientRect(), xt = 40, bt = a.clientX - nt.left, Ht = a.clientY - nt.top;
1502
- let Xt = 0, At = 0;
1503
- bt < xt ? Xt = Qt : bt > nt.width - xt && (Xt = -Qt), Ht < xt ? At = Qt : Ht > nt.height - xt && (At = -Qt), (Xt || At) && (gt.current.x += Xt, gt.current.y += At, Et(a));
1498
+ if ((d = Et.current) == null || d.postMessage({ type: "nodePositions", data: { updates: H } }), dn) {
1499
+ const U = mt.current;
1500
+ if (U) {
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 it = Z.current.find((q) => q.id === $.id);
1507
- it && ((w = Ae.current) == null || w.call(Ae, a, it));
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 m = gt.current;
1512
- m.x += a.clientX - te.current.x, m.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Et();
1513
- }, [Et, st, Ce, Ne]), hr = F((a) => {
1514
- var m, d, w, I, $;
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
+ var x, d, b, L, I;
1515
1515
  if (Wt.current) {
1516
- const h = st(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,9 +1526,9 @@ function Lr({
1526
1526
  sourceHandle: Wt.current.sourceHandle,
1527
1527
  targetHandle: A.handleId || null
1528
1528
  };
1529
- (O.current.isValidConnection ? O.current.isValidConnection(_) : !0) && ((m = ce.current) == null || m.call(ce, { ..._, ...be }));
1529
+ (O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((x = ce.current) == null || x.call(ce, { ...H, ...be }));
1530
1530
  }
1531
- (w = (d = O.current).onConnectEnd) == null || w.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
1531
+ (b = (d = O.current).onConnectEnd) == null || b.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
1532
1532
  return;
1533
1533
  }
1534
1534
  if (ie.current) {
@@ -1537,203 +1537,203 @@ function Lr({
1537
1537
  }
1538
1538
  if (_t.current) {
1539
1539
  const h = _t.current;
1540
- if (wt.current) {
1541
- const S = Z.current.find((_) => _.id === h.id), U = [{
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
- position: S ? { ...S.position } : void 0,
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((it) => it.id === _.id);
1549
- U.push({
1550
- id: _.id,
1547
+ for (const H of h.selectedStarts) {
1548
+ const J = Z.current.find((ut) => ut.id === H.id);
1549
+ Y.push({
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
- wt.current(U);
1556
+ bt.current(Y);
1557
1557
  }
1558
1558
  requestAnimationFrame(() => {
1559
1559
  _t.current = null;
1560
1560
  });
1561
- const A = Z.current.find((S) => S.id === h.id);
1562
- A && ((I = _e.current) == null || I.call(_e, a, A));
1561
+ const A = Z.current.find((T) => T.id === h.id);
1562
+ A && ((L = _e.current) == null || L.call(_e, a, A));
1563
1563
  return;
1564
1564
  }
1565
- Se.current = !1, ($ = pt.current) == null || $.classList.remove("dragging");
1566
- }, [st, tn, Ce, Ne, Jt]);
1567
- ut(() => {
1568
- const a = pt.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
- const m = (d) => {
1570
+ const x = (d) => {
1571
1571
  Pe && d.preventDefault();
1572
- const w = gt.current;
1572
+ const b = pt.current;
1573
1573
  if (Ge || ke.current) {
1574
- const S = Ze;
1575
- $e === "horizontal" ? w.x -= d.deltaY * S : ($e === "vertical" || (w.x -= d.deltaX * S), w.y -= d.deltaY * S), Et(d);
1574
+ const T = Ze;
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
- const I = d.deltaY > 0 ? 0.92 : 1.08, $ = a.getBoundingClientRect(), h = d.clientX - $.left, A = d.clientY - $.top;
1580
- w.x = h - (h - w.x) * I, w.y = A - (A - w.y) * I, w.zoom = Math.min(ot, Math.max(et, w.zoom * I)), Et(d);
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(xt, Math.max(st, b.zoom * L)), Ct(d);
1581
1581
  };
1582
- return a.addEventListener("wheel", m, { passive: !Pe }), () => a.removeEventListener("wheel", m);
1583
- }, [Et, et, ot, Ge, $e, Ze, Oe, Pe]), ut(() => {
1582
+ return a.addEventListener("wheel", x, { passive: !Pe }), () => a.removeEventListener("wheel", x);
1583
+ }, [Ct, st, xt, Ge, $e, Ze, Oe, Pe]), ht(() => {
1584
1584
  if (!Ke) return;
1585
- const a = pt.current;
1585
+ const a = mt.current;
1586
1586
  if (!a) return;
1587
- let m = 0, d = null;
1588
- const w = (h) => {
1587
+ let x = 0, d = null;
1588
+ const b = (h) => {
1589
1589
  if (h.touches.length === 2) {
1590
- const A = h.touches[0].clientX - h.touches[1].clientX, S = h.touches[0].clientY - h.touches[1].clientY;
1591
- m = Math.hypot(A, S);
1592
- const U = a.getBoundingClientRect();
1590
+ const A = h.touches[0].clientX - h.touches[1].clientX, T = h.touches[0].clientY - h.touches[1].clientY;
1591
+ x = Math.hypot(A, T);
1592
+ const Y = a.getBoundingClientRect();
1593
1593
  d = {
1594
- x: (h.touches[0].clientX + h.touches[1].clientX) / 2 - U.left,
1595
- y: (h.touches[0].clientY + h.touches[1].clientY) / 2 - U.top
1594
+ x: (h.touches[0].clientX + h.touches[1].clientX) / 2 - Y.left,
1595
+ y: (h.touches[0].clientY + h.touches[1].clientY) / 2 - Y.top
1596
1596
  }, h.preventDefault();
1597
1597
  }
1598
- }, I = (h) => {
1599
- if (h.touches.length === 2 && m > 0) {
1598
+ }, L = (h) => {
1599
+ if (h.touches.length === 2 && x > 0) {
1600
1600
  h.preventDefault();
1601
- const A = h.touches[0].clientX - h.touches[1].clientX, S = h.touches[0].clientY - h.touches[1].clientY, U = Math.hypot(A, S), _ = U / m;
1602
- m = U;
1603
- const K = gt.current, it = d.x, q = d.y;
1604
- K.x = it - (it - K.x) * _, K.y = q - (q - K.y) * _, K.zoom = Math.min(ot, Math.max(et, K.zoom * _)), Et(h);
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
+ x = Y;
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
- }, $ = () => {
1607
- m = 0, d = null;
1606
+ }, I = () => {
1607
+ x = 0, d = null;
1608
1608
  };
1609
- return a.addEventListener("touchstart", w, { passive: !1 }), a.addEventListener("touchmove", I, { passive: !1 }), a.addEventListener("touchend", $), () => {
1610
- a.removeEventListener("touchstart", w), a.removeEventListener("touchmove", I), a.removeEventListener("touchend", $);
1609
+ return a.addEventListener("touchstart", b, { passive: !1 }), a.addEventListener("touchmove", L, { passive: !1 }), a.addEventListener("touchend", I), () => {
1610
+ a.removeEventListener("touchstart", b), a.removeEventListener("touchmove", L), a.removeEventListener("touchend", I);
1611
1611
  };
1612
- }, [Ke, Et, et, ot]), ut(() => {
1612
+ }, [Ke, Ct, st, xt]), ht(() => {
1613
1613
  if (!Qe) return;
1614
- const a = pt.current;
1614
+ const a = mt.current;
1615
1615
  if (!a) return;
1616
- const m = (d) => {
1617
- var _, K, it, q;
1618
- const w = st(d.clientX, d.clientY);
1619
- if (Tt(w.x, w.y)) {
1620
- (K = (_ = O.current).onNodeDoubleClick) == null || K.call(_, d, Tt(w.x, w.y));
1616
+ const x = (d) => {
1617
+ var H, J, ut, U;
1618
+ const b = lt(d.clientX, d.clientY);
1619
+ if (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
- const I = ue(w.x, w.y);
1624
- if (I) {
1625
- (q = (it = O.current).onEdgeDoubleClick) == null || q.call(it, d, I);
1623
+ const L = ue(b.x, b.y);
1624
+ if (L) {
1625
+ (U = (ut = O.current).onEdgeDoubleClick) == null || U.call(ut, d, L);
1626
1626
  return;
1627
1627
  }
1628
- const $ = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, S = d.clientY - h.top, U = gt.current;
1629
- U.x = A - (A - U.x) * $, U.y = S - (S - U.y) * $, U.zoom = Math.min(ot, Math.max(et, U.zoom * $)), Et(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
- return a.addEventListener("dblclick", m), () => a.removeEventListener("dblclick", m);
1632
- }, [Qe, Et, et, ot, st, Tt, ue]), ut(() => {
1633
- const a = pt.current;
1631
+ return a.addEventListener("dblclick", x), () => a.removeEventListener("dblclick", x);
1632
+ }, [Qe, Ct, st, xt, lt, Tt, ue]), ht(() => {
1633
+ const a = mt.current;
1634
1634
  if (!a) return;
1635
- const m = (d) => {
1636
- var h, A, S, U, _, K;
1637
- const w = st(d.clientX, d.clientY), I = Tt(w.x, w.y);
1638
- if (I) {
1639
- (A = (h = O.current).onNodeContextMenu) == null || A.call(h, d, I);
1635
+ const x = (d) => {
1636
+ var h, A, T, Y, H, J;
1637
+ const b = lt(d.clientX, d.clientY), L = Tt(b.x, b.y);
1638
+ if (L) {
1639
+ (A = (h = O.current).onNodeContextMenu) == null || A.call(h, d, L);
1640
1640
  return;
1641
1641
  }
1642
- const $ = ue(w.x, w.y);
1643
- if ($) {
1644
- (U = (S = O.current).onEdgeContextMenu) == null || U.call(S, d, $);
1642
+ const I = ue(b.x, b.y);
1643
+ if (I) {
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
- return a.addEventListener("contextmenu", m), () => a.removeEventListener("contextmenu", m);
1650
- }, [st, Tt, ue]), ut(() => {
1651
- const a = pt.current;
1649
+ return a.addEventListener("contextmenu", x), () => a.removeEventListener("contextmenu", x);
1650
+ }, [lt, Tt, ue]), ht(() => {
1651
+ const a = mt.current;
1652
1652
  if (!a) return;
1653
- let m = null, d = null;
1654
- const w = (h) => {
1655
- var U, _, K, it, q, nt, xt, bt, Ht, Xt, At, X, Mt, J;
1656
- (_ = (U = O.current).onPaneMouseMove) == null || _.call(U, h);
1657
- const A = st(h.clientX, h.clientY), S = Tt(A.x, A.y);
1658
- if (S !== m && (m && ((it = (K = O.current).onNodeMouseLeave) == null || it.call(K, h, m)), S && ((nt = (q = O.current).onNodeMouseEnter) == null || nt.call(q, h, S)), m = S), S && ((bt = (xt = O.current).onNodeMouseMove) == null || bt.call(xt, h, S)), !S) {
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 = (Mt = O.current).onEdgeMouseMove) == null || J.call(Mt, h, tt));
1653
+ let x = null, d = null;
1654
+ const b = (h) => {
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
+ }, L = (h) => {
1663
+ var A, T;
1664
+ return (T = (A = O.current).onPaneMouseEnter) == null ? void 0 : T.call(A, h);
1662
1665
  }, I = (h) => {
1663
- var A, S;
1664
- return (S = (A = O.current).onPaneMouseEnter) == null ? void 0 : S.call(A, h);
1665
- }, $ = (h) => {
1666
- var A, S, U, _, K, it;
1667
- (S = (A = O.current).onPaneMouseLeave) == null || S.call(A, h), m && ((_ = (U = O.current).onNodeMouseLeave) == null || _.call(U, h, m), m = null), d && ((it = (K = O.current).onEdgeMouseLeave) == null || it.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
- return a.addEventListener("mousemove", w), a.addEventListener("mouseenter", I), a.addEventListener("mouseleave", $), () => {
1670
- a.removeEventListener("mousemove", w), a.removeEventListener("mouseenter", I), a.removeEventListener("mouseleave", $);
1669
+ return a.addEventListener("mousemove", b), a.addEventListener("mouseenter", L), a.addEventListener("mouseleave", I), () => {
1670
+ a.removeEventListener("mousemove", b), a.removeEventListener("mouseenter", L), a.removeEventListener("mouseleave", I);
1671
1671
  };
1672
- }, [st, Tt, ue]), ut(() => {
1673
- const a = Array.isArray(ve) ? ve : [ve], m = async (d) => {
1674
- var w, I;
1672
+ }, [lt, Tt, ue]), ht(() => {
1673
+ const a = Array.isArray(ve) ? ve : [ve], x = async (d) => {
1674
+ var b, L;
1675
1675
  if (a.includes(d.key)) {
1676
1676
  if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA" || d.target.isContentEditable) return;
1677
- const $ = Z.current.filter((S) => S.selected), h = Pt.current.filter((S) => S.selected);
1678
- if (!$.length && !h.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: $, edges: h }))
1677
+ const I = Z.current.filter((T) => T.selected), h = Pt.current.filter((T) => T.selected);
1678
+ if (!I.length && !h.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: I, edges: h }))
1679
1679
  return;
1680
- const A = new Set($.map((S) => S.id));
1681
- if ($.length && wt.current && (wt.current($.map((S) => ({ id: S.id, type: "remove" }))), Dt.current)) {
1682
- const S = Pt.current.filter((U) => A.has(U.source) || A.has(U.target));
1683
- S.length && Dt.current(S.map((U) => ({ id: U.id, type: "remove" })));
1680
+ const A = new Set(I.map((T) => T.id));
1681
+ if (I.length && bt.current && (bt.current(I.map((T) => ({ id: T.id, type: "remove" }))), Dt.current)) {
1682
+ const T = Pt.current.filter((Y) => A.has(Y.source) || A.has(Y.target));
1683
+ T.length && Dt.current(T.map((Y) => ({ id: Y.id, type: "remove" })));
1684
1684
  }
1685
- h.length && Dt.current && Dt.current(h.map((S) => ({ id: S.id, type: "remove" }))), (I = (w = O.current).onDelete) == null || I.call(w, { nodes: $, edges: h });
1685
+ h.length && Dt.current && Dt.current(h.map((T) => ({ id: T.id, type: "remove" }))), (L = (b = O.current).onDelete) == null || L.call(b, { nodes: I, edges: h });
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(), wt.current) {
1690
- const $ = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
1691
- $.length && wt.current($);
1689
+ if (d.preventDefault(), bt.current) {
1690
+ const I = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
1691
+ I.length && bt.current(I);
1692
1692
  }
1693
1693
  if (Dt.current) {
1694
- const $ = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
1695
- $.length && Dt.current($);
1694
+ const I = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
1695
+ I.length && Dt.current(I);
1696
1696
  }
1697
1697
  }
1698
1698
  };
1699
- return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
1699
+ return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
1700
1700
  }, [ve]);
1701
- const In = V(!1);
1702
- ut(() => {
1703
- var a, m;
1704
- if (!In.current && zt.current) {
1705
- if (In.current = !0, Rt && Z.current.length > 0) {
1706
- const d = pt.current;
1701
+ const In = tt(!1);
1702
+ ht(() => {
1703
+ var a, x;
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 w = d.getBoundingClientRect(), I = (vt == null ? void 0 : vt.padding) ?? 0.1, $ = Mn(Z.current), h = Rn($, w.width, w.height, I);
1709
- vt != null && vt.maxZoom && (h.zoom = Math.min(h.zoom, vt.maxZoom)), vt != null && vt.minZoom && (h.zoom = Math.max(h.zoom, vt.minZoom)), gt.current = h, Et();
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
- (m = (a = O.current).onInit) == null || m.call(a, {
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 w = pt.current;
1718
- if (!w || !Z.current.length) return;
1719
- const I = w.getBoundingClientRect(), $ = Mn(Z.current), h = Rn($, I.width, I.height, d.padding ?? 0.1);
1720
- gt.current = h, Et();
1717
+ const b = mt.current;
1718
+ if (!b || !Z.current.length) return;
1719
+ const L = b.getBoundingClientRect(), I = Mn(Z.current), h = Rn(I, L.width, L.height, d.padding ?? 0.1);
1720
+ pt.current = h, Ct();
1721
1721
  }
1722
1722
  });
1723
1723
  }
1724
1724
  });
1725
1725
  const yr = F(() => {
1726
- gt.current = { ...Nt }, Et();
1727
- }, [Et, Nt]), gr = F((a) => {
1728
- var m;
1726
+ pt.current = { ...Nt }, Ct();
1727
+ }, [Ct, Nt]), gr = F((a) => {
1728
+ var x;
1729
1729
  if (a)
1730
1730
  se.current.push(a);
1731
1731
  else {
1732
- const d = gt.current, w = pt.current;
1733
- if (!w) return;
1734
- const I = w.getBoundingClientRect(), $ = Math.round(-d.x / d.zoom + I.width / 2 / d.zoom), h = Math.round(-d.y / d.zoom + I.height / 2 / d.zoom);
1732
+ const d = pt.current, b = mt.current;
1733
+ if (!b) return;
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({
1736
- x: $ - 80,
1736
+ x: I - 80,
1737
1737
  y: h - 45,
1738
1738
  w: 160,
1739
1739
  h: 90,
@@ -1741,37 +1741,37 @@ function Lr({
1741
1741
  body: "Added at viewport center"
1742
1742
  });
1743
1743
  }
1744
- (m = zt.current) == null || m.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 m = gt.current, d = pt.current;
1747
+ const x = pt.current, d = mt.current;
1748
1748
  if (!d) return;
1749
- const w = d.getBoundingClientRect();
1749
+ const b = d.getBoundingClientRect();
1750
1750
  a.position = {
1751
- x: Math.round(-m.x / m.zoom + w.width / 2 / m.zoom) - Vt / 2,
1752
- y: Math.round(-m.y / m.zoom + w.height / 2 / m.zoom) - jt / 2
1751
+ x: Math.round(-x.x / x.zoom + b.width / 2 / x.zoom) - Vt / 2,
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 }), wt.current && wt.current([{ type: "add", item: a }]);
1756
- }, []), xr = F(() => ({ ...gt.current }), []), mr = F((a) => {
1757
- gt.current = { ...gt.current, ...a }, Et();
1758
- }, [Et]), vr = F((a) => st(a.x, a.y), [st]), $n = n, wr = St(() => ({
1759
- wrapRef: pt,
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: zt,
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: wt,
1767
+ onNodesChangeRef: bt,
1768
1768
  onEdgesChangeRef: Dt,
1769
- sendCamera: Et,
1770
- screenToWorld: st,
1769
+ sendCamera: Ct,
1770
+ screenToWorld: lt,
1771
1771
  viewportListeners: Kt,
1772
1772
  selectionListeners: he,
1773
- zoomMin: et,
1774
- zoomMax: ot,
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, Et, st, Ft, Kt, he, et, ot, 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: pt,
1798
+ wrapRef: mt,
1799
1799
  canvasRef: Te,
1800
1800
  canvasReady: gn,
1801
1801
  onPointerDown: dr,
@@ -1817,7 +1817,7 @@ function Ir(t, e, n, r, s, o) {
1817
1817
  return l = Math.max(0, Math.min(1, l)), Math.hypot(t - (n + l * i), e - (r + l * c));
1818
1818
  }
1819
1819
  const Zn = Fn(null);
1820
- function ht() {
1820
+ function yt() {
1821
1821
  const t = qe(Zn);
1822
1822
  if (!t)
1823
1823
  throw new Error("useCanvasStore must be used within <InfiniteCanvas> or <InfiniteCanvasProvider>");
@@ -1828,119 +1828,127 @@ function Ro() {
1828
1828
  return qe(je);
1829
1829
  }
1830
1830
  function $r({ node: t, nodeType: e }) {
1831
- var v, E, R;
1832
- const n = ht(), r = V(null), s = t._absolutePosition || t.position, o = V(null);
1833
- ut(() => {
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 T = new ResizeObserver((k) => {
1837
- var D, x, f, p;
1838
- const { width: z, height: W } = k[0].contentRect;
1839
- if (z > 0 && W > 0) {
1840
- const y = n.nodesRef.current.find((P) => P.id === t.id), N = (y == null ? void 0 : y.width) || ((D = y == null ? void 0 : y.measured) == null ? void 0 : D.width), C = (y == null ? void 0 : y.height) || ((x = y == null ? void 0 : y.measured) == null ? void 0 : x.height);
1841
- (Math.abs((N || 0) - z) > 1 || Math.abs((C || 0) - W) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
1842
- { id: t.id, type: "dimensions", dimensions: { width: z, 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
- return T.observe(M), () => T.disconnect();
1846
+ return $.observe(M), () => $.disconnect();
1847
1847
  }, [t.id, n]);
1848
1848
  const i = F((M) => {
1849
- var P, b;
1850
- if (M.stopPropagation(), n.onNodesChangeRef.current) {
1851
- const L = [];
1849
+ var B, q, X;
1850
+ M.stopPropagation();
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;
1857
+ }
1858
+ if (n.onNodesChangeRef.current) {
1859
+ const K = [];
1852
1860
  if (M.shiftKey)
1853
- L.push({ id: t.id, type: "select", selected: !t.selected });
1861
+ K.push({ id: t.id, type: "select", selected: !t.selected });
1854
1862
  else
1855
- for (const H of n.nodesRef.current)
1856
- H.id === t.id && !H.selected ? L.push({ id: H.id, type: "select", selected: !0 }) : H.id !== t.id && H.selected && L.push({ id: H.id, type: "select", selected: !1 });
1857
- L.length && n.onNodesChangeRef.current(L);
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);
1858
1866
  }
1859
- const T = n.cameraRef.current, k = n.wrapRef.current;
1860
- if (!k) return;
1861
- const z = k.getBoundingClientRect(), W = (M.clientX - z.left - T.x) / T.zoom, D = (M.clientY - z.top - T.y) / T.zoom, f = M.shiftKey && t.selected ? n.nodesRef.current.filter((L) => L.selected && L.id !== t.id).map((L) => ({ id: L.id, startPos: { ...L.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 } })) : [];
1862
1870
  o.current = {
1863
1871
  startPos: { ...t.position },
1864
- startMouse: { x: W, y: D },
1865
- selectedStarts: f
1872
+ startMouse: { x: g, y: f },
1873
+ selectedStarts: v
1866
1874
  };
1867
- const p = [{ id: t.id, type: "position", dragging: !0 }];
1868
- for (const L of f)
1869
- p.push({ id: L.id, type: "position", dragging: !0 });
1870
- (b = (P = n.onNodesChangeRef).current) == null || b.call(P, p);
1871
- const y = r.current;
1872
- y && y.setPointerCapture(M.pointerId);
1873
- const N = (L) => {
1874
- var at, ct, lt, Ct;
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);
1879
+ const w = r.current;
1880
+ w && w.setPointerCapture(M.pointerId);
1881
+ const P = (K) => {
1882
+ var It, st, xt, Nt;
1875
1883
  if (!o.current) return;
1876
- const Y = n.cameraRef.current, H = k.getBoundingClientRect(), dt = (L.clientX - H.left - Y.x) / Y.zoom, yt = (L.clientY - H.top - Y.y) / Y.zoom, ft = dt - o.current.startMouse.x, G = yt - o.current.startMouse.y;
1877
- let j = { x: o.current.startPos.x + ft, y: o.current.startPos.y + G };
1878
- if (n.snapToGrid && n.snapGrid && (j = {
1879
- x: n.snapGrid[0] * Math.round(j.x / n.snapGrid[0]),
1880
- y: n.snapGrid[1] * Math.round(j.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])
1881
1889
  }), t.parentId && t.extent === "parent") {
1882
- const et = n.nodesRef.current.find((ot) => ot.id === t.parentId);
1883
- if (et) {
1884
- const ot = et.width || 160, Nt = et.height || 60, Rt = t.width || ((at = t.measured) == null ? void 0 : at.width) || 160, vt = t.height || ((ct = t.measured) == null ? void 0 : ct.height) || 60;
1885
- j = {
1886
- x: Math.max(0, Math.min(j.x, ot - Rt)),
1887
- y: Math.max(0, Math.min(j.y, Nt - vt))
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))
1888
1896
  };
1889
1897
  }
1890
1898
  }
1891
- const rt = [{ id: t.id, type: "position", position: j, dragging: !0 }];
1892
- for (const et of o.current.selectedStarts) {
1893
- let ot = { x: et.startPos.x + ft, y: et.startPos.y + G };
1894
- n.snapToGrid && n.snapGrid && (ot = {
1895
- x: n.snapGrid[0] * Math.round(ot.x / n.snapGrid[0]),
1896
- y: n.snapGrid[1] * Math.round(ot.y / n.snapGrid[1])
1897
- }), rt.push({ id: et.id, type: "position", position: ot, 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 });
1898
1906
  }
1899
- (Ct = (lt = n.onNodesChangeRef).current) == null || Ct.call(lt, rt);
1900
- }, C = (L) => {
1901
- var H, dt;
1907
+ (Nt = (xt = n.onNodesChangeRef).current) == null || Nt.call(xt, ft);
1908
+ }, R = (K) => {
1909
+ var rt, G;
1902
1910
  if (!o.current) return;
1903
- const Y = [{ id: t.id, type: "position", dragging: !1 }];
1904
- for (const yt of o.current.selectedStarts)
1905
- Y.push({ id: yt.id, type: "position", dragging: !1 });
1906
- (dt = (H = n.onNodesChangeRef).current) == null || dt.call(H, Y), o.current = null, y && y.releasePointerCapture(L.pointerId), y == null || y.removeEventListener("pointermove", N), y == null || y.removeEventListener("pointerup", C);
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);
1907
1915
  };
1908
- y == null || y.addEventListener("pointermove", N), y == null || y.addEventListener("pointerup", C);
1916
+ w == null || w.addEventListener("pointermove", P), w == null || w.addEventListener("pointerup", R);
1909
1917
  }, [t, n]), c = F((M) => {
1910
- var x, f, p, y, N, C;
1918
+ var g, f, p, v, N, w;
1911
1919
  if (!t.selected) return;
1912
- const T = M.shiftKey ? 10 : 1;
1913
- let k = 0, z = 0;
1920
+ const $ = M.shiftKey ? 10 : 1;
1921
+ let k = 0, E = 0;
1914
1922
  switch (M.key) {
1915
1923
  case "ArrowUp":
1916
- z = -T;
1924
+ E = -$;
1917
1925
  break;
1918
1926
  case "ArrowDown":
1919
- z = T;
1927
+ E = $;
1920
1928
  break;
1921
1929
  case "ArrowLeft":
1922
- k = -T;
1930
+ k = -$;
1923
1931
  break;
1924
1932
  case "ArrowRight":
1925
- k = T;
1933
+ k = $;
1926
1934
  break;
1927
1935
  case "Escape":
1928
- (f = (x = n.onNodesChangeRef).current) == null || f.call(x, [{ id: t.id, type: "select", selected: !1 }]);
1936
+ (f = (g = n.onNodesChangeRef).current) == null || f.call(g, [{ id: t.id, type: "select", selected: !1 }]);
1929
1937
  return;
1930
1938
  case "Delete":
1931
1939
  case "Backspace":
1932
- t.deletable !== !1 && ((y = (p = n.onNodesChangeRef).current) == null || y.call(p, [{ id: t.id, type: "remove" }]));
1940
+ t.deletable !== !1 && ((v = (p = n.onNodesChangeRef).current) == null || v.call(p, [{ id: t.id, type: "remove" }]));
1933
1941
  return;
1934
1942
  default:
1935
1943
  return;
1936
1944
  }
1937
1945
  M.preventDefault();
1938
- const W = { x: t.position.x + k, y: t.position.y + z }, D = [{ 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: _ }];
1939
1947
  for (const P of n.nodesRef.current)
1940
- P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y + z } });
1941
- (C = (N = n.onNodesChangeRef).current) == null || C.call(N, D);
1942
- }, [t, n]), u = t.width || ((v = t.measured) == null ? void 0 : v.width), l = t.height || ((E = t.measured) == null ? void 0 : E.height), g = !!(u && l);
1943
- return /* @__PURE__ */ B(je.Provider, { value: t.id, children: /* @__PURE__ */ B(
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);
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);
1951
+ return /* @__PURE__ */ S(je.Provider, { value: t.id, children: /* @__PURE__ */ S(
1944
1952
  "div",
1945
1953
  {
1946
1954
  ref: r,
@@ -1952,18 +1960,18 @@ function $r({ node: t, nodeType: e }) {
1952
1960
  zIndex: t.type === "group" ? 0 : t.zIndex || 1,
1953
1961
  pointerEvents: t.type === "group" ? "none" : "all",
1954
1962
  cursor: t.dragging ? "grabbing" : "grab",
1955
- visibility: g ? "visible" : "hidden",
1963
+ visibility: y ? "visible" : "hidden",
1956
1964
  userSelect: "none",
1957
1965
  outline: "none"
1958
1966
  },
1959
1967
  "data-nodeid": t.id,
1960
1968
  tabIndex: t.selectable !== !1 ? 0 : void 0,
1961
1969
  role: "button",
1962
- "aria-label": `Node ${((R = t.data) == null ? void 0 : R.label) || t.id}`,
1970
+ "aria-label": `Node ${((z = t.data) == null ? void 0 : z.label) || t.id}`,
1963
1971
  "aria-selected": !!t.selected,
1964
1972
  onPointerDown: i,
1965
1973
  onKeyDown: c,
1966
- children: /* @__PURE__ */ B(
1974
+ children: /* @__PURE__ */ S(
1967
1975
  e,
1968
1976
  {
1969
1977
  id: t.id,
@@ -1994,32 +2002,32 @@ function Bn(t, e, n, r) {
1994
2002
  var c, u;
1995
2003
  const s = t.width || ((c = t.measured) == null ? void 0 : c.width) || On, o = t.height || ((u = t.measured) == null ? void 0 : u.height) || Qn, i = t._absolutePosition || t.position;
1996
2004
  if (t.handleBounds) {
1997
- const l = t.handleBounds[e] || [], g = n ? l.find((v) => v.id === n) : l[0];
1998
- if (g && g.x !== void 0 && g.y !== void 0) {
1999
- const v = g.position || (e === "source" ? "right" : "left");
2000
- return { x: i.x + g.x, y: i.y + g.y, position: v };
2005
+ const l = t.handleBounds[e] || [], y = n ? l.find((m) => m.id === n) : l[0];
2006
+ if (y && y.x !== void 0 && y.y !== void 0) {
2007
+ const m = y.position || (e === "source" ? "right" : "left");
2008
+ return { x: i.x + y.x, y: i.y + y.y, position: m };
2001
2009
  }
2002
2010
  }
2003
2011
  if (r) {
2004
- const l = `${t.id}__${n || e}`, g = r.get(l);
2005
- if (g && g.x !== void 0 && g.y !== void 0)
2006
- return { x: i.x + g.x, y: i.y + g.y, position: g.position || (e === "source" ? "right" : "left") };
2012
+ const l = `${t.id}__${n || e}`, y = r.get(l);
2013
+ if (y && y.x !== void 0 && y.y !== void 0)
2014
+ return { x: i.x + y.x, y: i.y + y.y, position: y.position || (e === "source" ? "right" : "left") };
2007
2015
  }
2008
2016
  if (t.handles && t.handles.length) {
2009
2017
  for (const l of t.handles)
2010
2018
  if (l.type === e && (!n || l.id === n)) {
2011
2019
  if (l.x !== void 0 && l.y !== void 0)
2012
2020
  return { x: i.x + l.x, y: i.y + l.y, position: l.position || (e === "source" ? "right" : "left") };
2013
- const g = l.position || (e === "source" ? "right" : "left");
2014
- switch (g) {
2021
+ const y = l.position || (e === "source" ? "right" : "left");
2022
+ switch (y) {
2015
2023
  case "top":
2016
- return { x: i.x + s / 2, y: i.y, position: g };
2024
+ return { x: i.x + s / 2, y: i.y, position: y };
2017
2025
  case "bottom":
2018
- return { x: i.x + s / 2, y: i.y + o, position: g };
2026
+ return { x: i.x + s / 2, y: i.y + o, position: y };
2019
2027
  case "left":
2020
- return { x: i.x, y: i.y + o / 2, position: g };
2028
+ return { x: i.x, y: i.y + o / 2, position: y };
2021
2029
  default:
2022
- return { x: i.x + s, y: i.y + o / 2, position: g };
2030
+ return { x: i.x + s, y: i.y + o / 2, position: y };
2023
2031
  }
2024
2032
  }
2025
2033
  }
@@ -2032,7 +2040,7 @@ function Sr(t, e, n) {
2032
2040
  return n === "top" ? t - e : n === "bottom" ? t + e : t;
2033
2041
  }
2034
2042
  function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
2035
- return /* @__PURE__ */ B(
2043
+ return /* @__PURE__ */ S(
2036
2044
  "circle",
2037
2045
  {
2038
2046
  className: `ric-edge-anchor ric-edge-anchor-${r}`,
@@ -2047,77 +2055,77 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
2047
2055
  );
2048
2056
  }
2049
2057
  function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2050
- var x, f, p;
2051
- const s = ht(), [o, i] = Gt(null), c = F((y, N, C, P) => {
2052
- var ft;
2058
+ var g, f, p;
2059
+ const s = yt(), [o, i] = Gt(null), c = F((v, N, w, P) => {
2060
+ var rt;
2053
2061
  N.stopPropagation(), N.preventDefault();
2054
- const b = s.wrapRef.current;
2055
- if (!b) return;
2056
- const L = y === "source" ? P : C, Y = y === "source" ? t.target : t.source;
2057
- (ft = s.workerRef.current) == null || ft.postMessage({
2062
+ const R = s.wrapRef.current;
2063
+ if (!R) return;
2064
+ const B = v === "source" ? P : w, q = v === "source" ? t.target : t.source;
2065
+ (rt = s.workerRef.current) == null || rt.postMessage({
2058
2066
  type: "connecting",
2059
- data: { from: { x: L.x, y: L.y }, to: { x: L.x, y: L.y } }
2067
+ data: { from: { x: B.x, y: B.y }, to: { x: B.x, y: B.y } }
2060
2068
  });
2061
- const H = b.getBoundingClientRect(), dt = (G) => {
2062
- var ct;
2063
- const j = s.cameraRef.current, rt = (G.clientX - H.left - j.x) / j.zoom, at = (G.clientY - H.top - j.y) / j.zoom;
2064
- (ct = s.workerRef.current) == null || ct.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({
2065
2073
  type: "connecting",
2066
- data: { from: { x: L.x, y: L.y }, to: { x: rt, y: at } }
2074
+ data: { from: { x: B.x, y: B.y }, to: { x: it, y: dt } }
2067
2075
  });
2068
- }, yt = (G) => {
2069
- var ot, Nt, Rt, vt;
2070
- const j = s.cameraRef.current, rt = (G.clientX - H.left - j.x) / j.zoom, at = (G.clientY - H.top - j.y) / j.zoom, ct = 20 / j.zoom;
2071
- let lt = null, Ct = null;
2072
- const et = (ot = s.handleRegistryRef) == null ? void 0 : ot.current;
2073
- for (const Lt of s.nodesRef.current) {
2074
- if (Lt.hidden) continue;
2075
- const kt = Lt.width || On, $t = Lt.height || Qn, mt = Lt._absolutePosition || Lt.position, ne = [];
2076
- if (et)
2077
- for (const [, Bt] of et)
2078
- Bt.nodeId === Lt.id && ne.push(Bt);
2079
- const Ie = ne.length > 0 ? ne : Lt.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 || [
2080
2088
  { type: "target", position: "left" },
2081
2089
  { type: "source", position: "right" }
2082
2090
  ];
2083
2091
  for (const Bt of Ie) {
2084
2092
  let Ot, Yt;
2085
2093
  if (Bt.x !== void 0 && Bt.y !== void 0)
2086
- Ot = mt.x + Bt.x, Yt = mt.y + Bt.y;
2094
+ Ot = wt.x + Bt.x, Yt = wt.y + Bt.y;
2087
2095
  else
2088
2096
  switch (Bt.position || (Bt.type === "source" ? "right" : "left")) {
2089
2097
  case "top":
2090
- Ot = mt.x + kt / 2, Yt = mt.y;
2098
+ Ot = wt.x + Rt / 2, Yt = wt.y;
2091
2099
  break;
2092
2100
  case "bottom":
2093
- Ot = mt.x + kt / 2, Yt = mt.y + $t;
2101
+ Ot = wt.x + Rt / 2, Yt = wt.y + Lt;
2094
2102
  break;
2095
2103
  case "left":
2096
- Ot = mt.x, Yt = mt.y + $t / 2;
2104
+ Ot = wt.x, Yt = wt.y + Lt / 2;
2097
2105
  break;
2098
2106
  default:
2099
- Ot = mt.x + kt, Yt = mt.y + $t / 2;
2107
+ Ot = wt.x + Rt, Yt = wt.y + Lt / 2;
2100
2108
  break;
2101
2109
  }
2102
- if (Math.abs(rt - Ot) < ct && Math.abs(at - Yt) < ct) {
2103
- lt = Lt, Ct = Bt.id || null;
2110
+ if (Math.abs(it - Ot) < ot && Math.abs(dt - Yt) < ot) {
2111
+ ft = zt, It = Bt.id || null;
2104
2112
  break;
2105
2113
  }
2106
2114
  }
2107
- if (lt) break;
2115
+ if (ft) break;
2108
2116
  }
2109
- if (lt) {
2110
- const Lt = y === "source" ? { source: lt.id, target: Y, sourceHandle: Ct, targetHandle: t.targetHandle } : { source: Y, target: lt.id, sourceHandle: t.sourceHandle, targetHandle: Ct };
2111
- (Rt = (Nt = s.onEdgesChangeRef).current) == null || Rt.call(Nt, [
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, [
2112
2120
  { id: t.id, type: "remove" },
2113
- { type: "add", item: { id: t.id, ...Lt } }
2121
+ { type: "add", item: { id: t.id, ...zt } }
2114
2122
  ]);
2115
2123
  }
2116
- (vt = s.workerRef.current) == null || vt.postMessage({ type: "connecting", data: null }), b.removeEventListener("pointermove", dt), b.removeEventListener("pointerup", yt);
2124
+ (ct = s.workerRef.current) == null || ct.postMessage({ type: "connecting", data: null }), R.removeEventListener("pointermove", K), R.removeEventListener("pointerup", at);
2117
2125
  };
2118
- b.addEventListener("pointermove", dt), b.addEventListener("pointerup", yt);
2119
- }, [t, s]), u = n.find((y) => y.id === t.source), l = n.find((y) => y.id === t.target), g = u && !!(u.width || (x = u.measured) != null && x.width), v = l && !!(l.width || (f = l.measured) != null && f.width), E = (p = s.handleRegistryRef) == null ? void 0 : p.current, R = g ? Bn(u, "source", t.sourceHandle, E) : null, M = v ? Bn(l, "target", t.targetHandle, E) : null, T = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, z = k == null ? void 0 : k.find((y) => y.id === t.id), W = T ? null : (z == null ? void 0 : z._routedPoints) || t._routedPoints || null, D = r !== !1 && t.reconnectable !== !1;
2120
- return !R || !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(
2121
2129
  "g",
2122
2130
  {
2123
2131
  className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
@@ -2125,17 +2133,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2125
2133
  onMouseEnter: () => i(!0),
2126
2134
  onMouseLeave: () => i(!1),
2127
2135
  children: [
2128
- /* @__PURE__ */ B(
2136
+ /* @__PURE__ */ S(
2129
2137
  e,
2130
2138
  {
2131
2139
  id: t.id,
2132
2140
  source: t.source,
2133
2141
  target: t.target,
2134
- sourceX: R.x,
2135
- sourceY: R.y,
2142
+ sourceX: z.x,
2143
+ sourceY: z.y,
2136
2144
  targetX: M.x,
2137
2145
  targetY: M.y,
2138
- sourcePosition: R.position,
2146
+ sourcePosition: z.position,
2139
2147
  targetPosition: M.position,
2140
2148
  sourceHandleId: t.sourceHandle,
2141
2149
  targetHandleId: t.targetHandle,
@@ -2147,28 +2155,28 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2147
2155
  style: t.style,
2148
2156
  selectable: t.selectable !== !1,
2149
2157
  deletable: t.deletable !== !1,
2150
- routedPoints: W
2158
+ routedPoints: _
2151
2159
  }
2152
2160
  ),
2153
- D && (o || t.selected) && /* @__PURE__ */ It(Le, { children: [
2154
- /* @__PURE__ */ B(
2161
+ D && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
2162
+ /* @__PURE__ */ S(
2155
2163
  Dn,
2156
2164
  {
2157
- x: R.x,
2158
- y: R.y,
2159
- position: R.position,
2165
+ x: z.x,
2166
+ y: z.y,
2167
+ position: z.position,
2160
2168
  type: "source",
2161
- onPointerDown: (y) => c("source", y, R, M)
2169
+ onPointerDown: (v) => c("source", v, z, M)
2162
2170
  }
2163
2171
  ),
2164
- /* @__PURE__ */ B(
2172
+ /* @__PURE__ */ S(
2165
2173
  Dn,
2166
2174
  {
2167
2175
  x: M.x,
2168
2176
  y: M.y,
2169
2177
  position: M.position,
2170
2178
  type: "target",
2171
- onPointerDown: (y) => c("target", y, R, M)
2179
+ onPointerDown: (v) => c("target", v, z, M)
2172
2180
  }
2173
2181
  )
2174
2182
  ] })
@@ -2178,59 +2186,59 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
2178
2186
  }
2179
2187
  const Dr = Zt(Br);
2180
2188
  function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
2181
- var T;
2182
- const n = ht(), [r, s] = Gt(null), o = V(null);
2183
- if (ut(() => {
2189
+ var $;
2190
+ const n = yt(), [r, s] = Gt(null), o = tt(null);
2191
+ if (ht(() => {
2184
2192
  const k = n.wrapRef.current;
2185
2193
  if (!k) return;
2186
- let z = !1, W = null, D = !1;
2187
- const x = (C) => {
2188
- C.key === t && (D = !0);
2189
- }, f = (C) => {
2190
- C.key === t && (D = !1);
2191
- }, p = (C) => {
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) => {
2192
2200
  if (!D) return;
2193
- const P = C.target;
2201
+ const P = w.target;
2194
2202
  if (P.closest(".ric-node-wrapper") || P.closest(".ric-handle")) return;
2195
- z = !0;
2196
- const b = n.cameraRef.current, L = k.getBoundingClientRect(), Y = (C.clientX - L.left - b.x) / b.zoom, H = (C.clientY - L.top - b.y) / b.zoom;
2197
- W = { x: Y, y: H }, s({ startX: Y, startY: H, endX: Y, endY: H }), C.stopPropagation();
2198
- }, y = (C) => {
2199
- if (!z || !W) return;
2200
- const P = n.cameraRef.current, b = k.getBoundingClientRect(), L = (C.clientX - b.left - P.x) / P.zoom, Y = (C.clientY - b.top - P.y) / P.zoom;
2201
- s({ startX: W.x, startY: W.y, endX: L, endY: Y });
2202
- }, N = (C) => {
2203
- var yt, ft;
2204
- if (!z || !W) return;
2205
- z = !1;
2206
- const P = n.cameraRef.current, b = k.getBoundingClientRect(), L = (C.clientX - b.left - P.x) / P.zoom, Y = (C.clientY - b.top - P.y) / P.zoom, H = {
2207
- x: Math.min(W.x, L),
2208
- y: Math.min(W.y, Y),
2209
- width: Math.abs(L - W.x),
2210
- height: Math.abs(Y - W.y)
2211
- }, dt = [];
2203
+ E = !0;
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;
2213
+ E = !1;
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 = [];
2212
2220
  for (const G of n.nodesRef.current) {
2213
- const j = G._absolutePosition || G.position, rt = G.width || 160, at = G.height || 60;
2214
- let ct;
2215
- e === "full" ? ct = j.x >= H.x && j.y >= H.y && j.x + rt <= H.x + H.width && j.y + at <= H.y + H.height : ct = j.x + rt > H.x && j.x < H.x + H.width && j.y + at > H.y && j.y < H.y + H.height, dt.push({ id: G.id, type: "select", selected: ct });
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 });
2216
2224
  }
2217
- dt.length && ((ft = (yt = n.onNodesChangeRef).current) == null || ft.call(yt, dt)), W = null, s(null);
2225
+ K.length && ((rt = (at = n.onNodesChangeRef).current) == null || rt.call(at, K)), _ = null, s(null);
2218
2226
  };
2219
- return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove", y), k.addEventListener("pointerup", N), window.addEventListener("keydown", x), window.addEventListener("keyup", f), () => {
2220
- k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove", y), k.removeEventListener("pointerup", N), window.removeEventListener("keydown", x), 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);
2221
2229
  };
2222
2230
  }, [n, t, e]), !r) return null;
2223
- const i = ((T = n.cameraRef) == null ? void 0 : T.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), g = Math.abs(r.endY - r.startY), v = c * i.zoom + i.x, E = u * i.zoom + i.y, R = l * i.zoom, M = g * i.zoom;
2224
- return /* @__PURE__ */ B(
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;
2232
+ return /* @__PURE__ */ S(
2225
2233
  "div",
2226
2234
  {
2227
2235
  ref: o,
2228
2236
  className: "ric-selection-box",
2229
2237
  style: {
2230
2238
  position: "absolute",
2231
- left: v,
2232
- top: E,
2233
- width: R,
2239
+ left: m,
2240
+ top: C,
2241
+ width: z,
2234
2242
  height: M,
2235
2243
  border: "1px dashed #3b82f6",
2236
2244
  background: "rgba(59, 130, 246, 0.08)",
@@ -2241,7 +2249,7 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
2241
2249
  );
2242
2250
  }
2243
2251
  Kn.displayName = "SelectionBox";
2244
- const Hr = Zt(Kn);
2252
+ const Ar = Zt(Kn);
2245
2253
  function Jn(t, e) {
2246
2254
  var s, o, i, c;
2247
2255
  const n = (s = t.handleRegistryRef) == null ? void 0 : s.current;
@@ -2257,12 +2265,12 @@ function Jn(t, e) {
2257
2265
  ]), (c = t.syncNodesToWorker) == null || c.call(t);
2258
2266
  }
2259
2267
  const vn = /* @__PURE__ */ new Set();
2260
- function Hn(t, e) {
2268
+ function An(t, e) {
2261
2269
  vn.has(e) || (vn.add(e), queueMicrotask(() => {
2262
2270
  vn.delete(e), Jn(t, e);
2263
2271
  }));
2264
2272
  }
2265
- function Ar(t, e) {
2273
+ function Hr(t, e) {
2266
2274
  const n = t.closest(".ric-node-wrapper");
2267
2275
  if (!n) return null;
2268
2276
  const r = n.getBoundingClientRect(), s = t.getBoundingClientRect(), o = e || 1;
@@ -2282,145 +2290,145 @@ function on({
2282
2290
  className: c = "",
2283
2291
  style: u = {},
2284
2292
  onConnect: l,
2285
- ...g
2293
+ ...y
2286
2294
  }) {
2287
- const v = qe(je), E = ht(), R = V(null), M = V(E);
2288
- M.current = E;
2289
- const T = F(() => {
2290
- var C, P, b;
2291
- const D = R.current;
2292
- if (!D || !v) return;
2293
- const x = M.current, f = (C = x.handleRegistryRef) == null ? void 0 : C.current;
2295
+ const m = qe(je), C = yt(), z = tt(null), M = tt(C);
2296
+ M.current = C;
2297
+ const $ = F(() => {
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;
2294
2302
  if (!f) return;
2295
- const p = `${v}__${n || t}`, y = (b = (P = x.cameraRef) == null ? void 0 : P.current) == null ? void 0 : b.zoom, N = Ar(D, 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);
2296
2304
  if (N) {
2297
- const L = { nodeId: v, id: n || null, type: t, position: e, x: N.x, y: N.y };
2298
- f.set(p, L);
2305
+ const B = { nodeId: m, id: n || null, type: t, position: e, x: N.x, y: N.y };
2306
+ f.set(p, B);
2299
2307
  }
2300
- }, [v, n, t, e]);
2308
+ }, [m, n, t, e]);
2301
2309
  kr(() => {
2302
- T();
2303
- }, [T]), ut(() => {
2304
- if (!v) return;
2310
+ $();
2311
+ }, [$]), ht(() => {
2312
+ if (!m) return;
2305
2313
  const D = M.current;
2306
- Hn(D, v);
2307
- const x = R.current, f = x == null ? void 0 : x.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
2308
- T(), Hn(M.current, v);
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);
2309
2317
  });
2310
2318
  return f && p.observe(f), () => {
2311
2319
  var P;
2312
2320
  p.disconnect();
2313
- const y = M.current, N = (P = y.handleRegistryRef) == null ? void 0 : P.current, C = `${v}__${n || t}`;
2314
- N == null || N.delete(C), Jn(y, v);
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);
2315
2323
  };
2316
- }, [v, n, t, e, T]);
2324
+ }, [m, n, t, e, $]);
2317
2325
  const k = F(() => {
2318
- var b;
2319
- const D = M.current, x = D.nodesRef.current.find((L) => L.id === v);
2320
- if (!x) return null;
2321
- const f = x._absolutePosition || x.position, p = (b = D.handleRegistryRef) == null ? void 0 : b.current, y = `${v}__${n || t}`, N = p == null ? void 0 : p.get(y);
2326
+ var R;
2327
+ const D = M.current, g = D.nodesRef.current.find((B) => B.id === m);
2328
+ if (!g) return null;
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);
2322
2330
  if (N && N.x !== void 0 && N.y !== void 0)
2323
2331
  return { x: f.x + N.x, y: f.y + N.y };
2324
- const C = x.width || 160, P = x.height || 60;
2332
+ const w = g.width || 160, P = g.height || 60;
2325
2333
  switch (e) {
2326
2334
  case "top":
2327
- return { x: f.x + C / 2, y: f.y };
2335
+ return { x: f.x + w / 2, y: f.y };
2328
2336
  case "bottom":
2329
- return { x: f.x + C / 2, y: f.y + P };
2337
+ return { x: f.x + w / 2, y: f.y + P };
2330
2338
  case "left":
2331
2339
  return { x: f.x, y: f.y + P / 2 };
2332
2340
  default:
2333
- return { x: f.x + C, y: f.y + P / 2 };
2341
+ return { x: f.x + w, y: f.y + P / 2 };
2334
2342
  }
2335
- }, [v, n, t, e]), z = F((D) => {
2336
- var Y;
2343
+ }, [m, n, t, e]), E = F((D) => {
2344
+ var q;
2337
2345
  if (!r || !s) return;
2338
2346
  D.stopPropagation(), D.preventDefault();
2339
- const x = M.current, f = x.cameraRef.current, p = x.wrapRef.current;
2347
+ const g = M.current, f = g.cameraRef.current, p = g.wrapRef.current;
2340
2348
  if (!p) return;
2341
- const y = p.getBoundingClientRect(), N = k();
2349
+ const v = p.getBoundingClientRect(), N = k();
2342
2350
  if (!N) return;
2343
- const C = N.x, P = N.y;
2344
- (Y = x.workerRef.current) == null || Y.postMessage({
2351
+ const w = N.x, P = N.y;
2352
+ (q = g.workerRef.current) == null || q.postMessage({
2345
2353
  type: "connecting",
2346
- data: { from: { x: C, y: P }, to: { x: C, y: P } }
2354
+ data: { from: { x: w, y: P }, to: { x: w, y: P } }
2347
2355
  }), p.setPointerCapture(D.pointerId);
2348
- const b = (H) => {
2349
- var ft;
2350
- const dt = (H.clientX - y.left - f.x) / f.zoom, yt = (H.clientY - y.top - f.y) / f.zoom;
2351
- (ft = x.workerRef.current) == null || ft.postMessage({
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({
2352
2360
  type: "connecting",
2353
- data: { from: { x: C, y: P }, to: { x: dt, y: yt } }
2361
+ data: { from: { x: w, y: P }, to: { x: K, y: at } }
2354
2362
  });
2355
- }, L = (H) => {
2356
- var at, ct, lt, Ct;
2357
- const dt = (H.clientX - y.left - f.x) / f.zoom, yt = (H.clientY - y.top - f.y) / f.zoom, ft = 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;
2358
2366
  let G = null, j = null;
2359
- const rt = (at = x.handleRegistryRef) == null ? void 0 : at.current;
2360
- for (const et of x.nodesRef.current) {
2361
- if (et.id === v || et.hidden) continue;
2362
- const ot = et.width || 160, Nt = et.height || 60, Rt = et._absolutePosition || et.position, vt = [];
2363
- if (rt)
2364
- for (const [, kt] of rt)
2365
- kt.nodeId === et.id && vt.push(kt);
2366
- const Lt = vt.length > 0 ? vt : et.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 || [
2367
2375
  { type: "target", position: "left" },
2368
2376
  { type: "source", position: "right" }
2369
2377
  ];
2370
- for (const kt of Lt) {
2371
- let $t, mt;
2372
- if (kt.x !== void 0 && kt.y !== void 0)
2373
- $t = Rt.x + kt.x, mt = Rt.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;
2374
2382
  else
2375
- switch (kt.position || (kt.type === "source" ? "right" : "left")) {
2383
+ switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
2376
2384
  case "top":
2377
- $t = Rt.x + ot / 2, mt = Rt.y;
2385
+ Lt = gt.x + xt / 2, wt = gt.y;
2378
2386
  break;
2379
2387
  case "bottom":
2380
- $t = Rt.x + ot / 2, mt = Rt.y + Nt;
2388
+ Lt = gt.x + xt / 2, wt = gt.y + Nt;
2381
2389
  break;
2382
2390
  case "left":
2383
- $t = Rt.x, mt = Rt.y + Nt / 2;
2391
+ Lt = gt.x, wt = gt.y + Nt / 2;
2384
2392
  break;
2385
2393
  default:
2386
- $t = Rt.x + ot, mt = Rt.y + Nt / 2;
2394
+ Lt = gt.x + xt, wt = gt.y + Nt / 2;
2387
2395
  break;
2388
2396
  }
2389
- if (Math.abs(dt - $t) < ft && Math.abs(yt - mt) < ft) {
2390
- G = et, j = kt.id || null;
2397
+ if (Math.abs(K - Lt) < rt && Math.abs(at - wt) < rt) {
2398
+ G = st, j = Rt.id || null;
2391
2399
  break;
2392
2400
  }
2393
2401
  }
2394
2402
  if (G) break;
2395
2403
  }
2396
2404
  if (G) {
2397
- const et = {
2398
- source: t === "source" ? v : G.id,
2399
- target: t === "source" ? G.id : v,
2405
+ const st = {
2406
+ source: t === "source" ? m : G.id,
2407
+ target: t === "source" ? G.id : m,
2400
2408
  sourceHandle: t === "source" ? n || null : j,
2401
2409
  targetHandle: t === "source" ? j : n || null
2402
2410
  };
2403
- (lt = (ct = x.onEdgesChangeRef) == null ? void 0 : ct.current) == null || lt.call(ct, [{ type: "add", item: { id: `e-${et.source}-${et.target}`, ...et } }]);
2411
+ (ft = (ot = g.onEdgesChangeRef) == null ? void 0 : ot.current) == null || ft.call(ot, [{ type: "add", item: { id: `e-${st.source}-${st.target}`, ...st } }]);
2404
2412
  }
2405
- (Ct = x.workerRef.current) == null || Ct.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", b), p.removeEventListener("pointerup", L);
2413
+ (It = g.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", R), p.removeEventListener("pointerup", B);
2406
2414
  };
2407
- p.addEventListener("pointermove", b), p.addEventListener("pointerup", L);
2408
- }, [v, n, t, e, r, s, k]), W = {
2415
+ p.addEventListener("pointermove", R), p.addEventListener("pointerup", B);
2416
+ }, [m, n, t, e, r, s, k]), _ = {
2409
2417
  top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
2410
2418
  bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
2411
2419
  left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
2412
2420
  right: { top: "50%", right: 0, transform: "translate(50%, -50%)" }
2413
2421
  }[e] || {};
2414
- return /* @__PURE__ */ B(
2422
+ return /* @__PURE__ */ S(
2415
2423
  "div",
2416
2424
  {
2417
- ref: R,
2425
+ ref: z,
2418
2426
  className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
2419
2427
  "data-handleid": n || null,
2420
- "data-nodeid": v,
2428
+ "data-nodeid": m,
2421
2429
  "data-handlepos": e,
2422
2430
  "data-handletype": t,
2423
- onPointerDown: z,
2431
+ onPointerDown: E,
2424
2432
  style: {
2425
2433
  position: "absolute",
2426
2434
  width: 8,
@@ -2431,10 +2439,10 @@ function on({
2431
2439
  zIndex: 10,
2432
2440
  cursor: r ? "crosshair" : "default",
2433
2441
  boxSizing: "border-box",
2434
- ...W,
2442
+ ..._,
2435
2443
  ...u
2436
2444
  },
2437
- ...g,
2445
+ ...y,
2438
2446
  children: i
2439
2447
  }
2440
2448
  );
@@ -2448,7 +2456,7 @@ function ko({
2448
2456
  hideSourceHandle: o = !1,
2449
2457
  hideTargetHandle: i = !1
2450
2458
  }) {
2451
- return /* @__PURE__ */ It(
2459
+ return /* @__PURE__ */ $t(
2452
2460
  "div",
2453
2461
  {
2454
2462
  className: `ric-default-node${n ? " selected" : ""}`,
@@ -2463,9 +2471,9 @@ function ko({
2463
2471
  boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
2464
2472
  },
2465
2473
  children: [
2466
- !i && /* @__PURE__ */ B(on, { type: "target", position: r, isConnectable: e }),
2467
- /* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
2468
- !o && /* @__PURE__ */ B(on, { type: "source", position: s, isConnectable: e })
2474
+ !i && /* @__PURE__ */ S(on, { type: "target", position: r, isConnectable: e }),
2475
+ /* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
2476
+ !o && /* @__PURE__ */ S(on, { type: "source", position: s, isConnectable: e })
2469
2477
  ]
2470
2478
  }
2471
2479
  );
@@ -2477,7 +2485,7 @@ function _r({
2477
2485
  sourcePosition: r = "right",
2478
2486
  hideSourceHandle: s = !1
2479
2487
  }) {
2480
- return /* @__PURE__ */ It(
2488
+ return /* @__PURE__ */ $t(
2481
2489
  "div",
2482
2490
  {
2483
2491
  className: `ric-input-node${n ? " selected" : ""}`,
@@ -2493,8 +2501,8 @@ function _r({
2493
2501
  boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
2494
2502
  },
2495
2503
  children: [
2496
- /* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
2497
- !s && /* @__PURE__ */ B(on, { type: "source", position: r, isConnectable: e })
2504
+ /* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
2505
+ !s && /* @__PURE__ */ S(on, { type: "source", position: r, isConnectable: e })
2498
2506
  ]
2499
2507
  }
2500
2508
  );
@@ -2506,7 +2514,7 @@ function Wr({
2506
2514
  targetPosition: r = "left",
2507
2515
  hideTargetHandle: s = !1
2508
2516
  }) {
2509
- return /* @__PURE__ */ It(
2517
+ return /* @__PURE__ */ $t(
2510
2518
  "div",
2511
2519
  {
2512
2520
  className: `ric-output-node${n ? " selected" : ""}`,
@@ -2522,14 +2530,14 @@ function Wr({
2522
2530
  boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
2523
2531
  },
2524
2532
  children: [
2525
- !s && /* @__PURE__ */ B(on, { type: "target", position: r, isConnectable: e }),
2526
- /* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label })
2533
+ !s && /* @__PURE__ */ S(on, { type: "target", position: r, isConnectable: e }),
2534
+ /* @__PURE__ */ S("div", { className: "ric-node-content", children: t == null ? void 0 : t.label })
2527
2535
  ]
2528
2536
  }
2529
2537
  );
2530
2538
  }
2531
2539
  function Xr({ data: t, selected: e, width: n, height: r }) {
2532
- return /* @__PURE__ */ B(
2540
+ return /* @__PURE__ */ S(
2533
2541
  "div",
2534
2542
  {
2535
2543
  className: `ric-group-node${e ? " selected" : ""}`,
@@ -2542,7 +2550,7 @@ function Xr({ data: t, selected: e, width: n, height: r }) {
2542
2550
  padding: 8,
2543
2551
  boxSizing: "border-box"
2544
2552
  },
2545
- children: (t == null ? void 0 : t.label) && /* @__PURE__ */ B(
2553
+ children: (t == null ? void 0 : t.label) && /* @__PURE__ */ S(
2546
2554
  "div",
2547
2555
  {
2548
2556
  style: {
@@ -2568,47 +2576,47 @@ function Vn({
2568
2576
  labelBgBorderRadius: c = 2,
2569
2577
  children: u,
2570
2578
  className: l = "",
2571
- ...g
2579
+ ...y
2572
2580
  }) {
2573
- const [v, E] = Gt({ x: 1, y: 0, width: 0, height: 0 }), R = V(null);
2574
- return ut(() => {
2575
- if (R.current) {
2576
- const M = R.current.getBBox();
2577
- E({
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();
2585
+ C({
2578
2586
  x: M.x,
2579
2587
  y: M.y,
2580
2588
  width: M.width,
2581
2589
  height: M.height
2582
2590
  });
2583
2591
  }
2584
- }, [n]), n ? /* @__PURE__ */ It(
2592
+ }, [n]), n ? /* @__PURE__ */ $t(
2585
2593
  "g",
2586
2594
  {
2587
- transform: `translate(${t - v.width / 2} ${e - v.height / 2})`,
2595
+ transform: `translate(${t - m.width / 2} ${e - m.height / 2})`,
2588
2596
  className: `ric-edge-textwrapper ${l}`,
2589
- visibility: v.width ? "visible" : "hidden",
2590
- ...g,
2597
+ visibility: m.width ? "visible" : "hidden",
2598
+ ...y,
2591
2599
  children: [
2592
- s && /* @__PURE__ */ B(
2600
+ s && /* @__PURE__ */ S(
2593
2601
  "rect",
2594
2602
  {
2595
- width: v.width + 2 * i[0],
2603
+ width: m.width + 2 * i[0],
2596
2604
  x: -i[0],
2597
2605
  y: -i[1],
2598
- height: v.height + 2 * i[1],
2606
+ height: m.height + 2 * i[1],
2599
2607
  className: "ric-edge-textbg",
2600
2608
  style: o,
2601
2609
  rx: c,
2602
2610
  ry: c
2603
2611
  }
2604
2612
  ),
2605
- /* @__PURE__ */ B(
2613
+ /* @__PURE__ */ S(
2606
2614
  "text",
2607
2615
  {
2608
2616
  className: "ric-edge-text",
2609
- y: v.height / 2,
2617
+ y: m.height / 2,
2610
2618
  dy: "0.3em",
2611
- ref: R,
2619
+ ref: z,
2612
2620
  style: r,
2613
2621
  children: n
2614
2622
  }
@@ -2620,7 +2628,7 @@ function Vn({
2620
2628
  }
2621
2629
  Vn.displayName = "EdgeText";
2622
2630
  const Fr = Zt(Vn);
2623
- function An(t) {
2631
+ function Hn(t) {
2624
2632
  return t != null && t !== "" && !isNaN(Number(t));
2625
2633
  }
2626
2634
  function un({
@@ -2634,15 +2642,15 @@ function un({
2634
2642
  labelBgStyle: c,
2635
2643
  labelBgPadding: u,
2636
2644
  labelBgBorderRadius: l,
2637
- interactionWidth: g = 20,
2638
- style: v,
2639
- markerEnd: E,
2640
- markerStart: R,
2645
+ interactionWidth: y = 20,
2646
+ style: m,
2647
+ markerEnd: C,
2648
+ markerStart: z,
2641
2649
  className: M = "",
2642
- ...T
2650
+ ...$
2643
2651
  }) {
2644
- return /* @__PURE__ */ It(Le, { children: [
2645
- /* @__PURE__ */ B(
2652
+ return /* @__PURE__ */ $t(Le, { children: [
2653
+ /* @__PURE__ */ S(
2646
2654
  "path",
2647
2655
  {
2648
2656
  id: t,
@@ -2651,24 +2659,24 @@ function un({
2651
2659
  stroke: "#b1b1b7",
2652
2660
  strokeWidth: 1.5,
2653
2661
  className: `ric-edge-path ${M}`,
2654
- style: v,
2655
- markerEnd: E,
2656
- markerStart: R,
2657
- ...T
2662
+ style: m,
2663
+ markerEnd: C,
2664
+ markerStart: z,
2665
+ ...$
2658
2666
  }
2659
2667
  ),
2660
- g ? /* @__PURE__ */ B(
2668
+ y ? /* @__PURE__ */ S(
2661
2669
  "path",
2662
2670
  {
2663
2671
  d: e,
2664
2672
  fill: "none",
2665
2673
  strokeOpacity: 0,
2666
- strokeWidth: g,
2674
+ strokeWidth: y,
2667
2675
  className: "ric-edge-interaction",
2668
2676
  style: { pointerEvents: "stroke" }
2669
2677
  }
2670
2678
  ) : null,
2671
- s && An(n) && An(r) ? /* @__PURE__ */ B(
2679
+ s && Hn(n) && Hn(r) ? /* @__PURE__ */ S(
2672
2680
  Fr,
2673
2681
  {
2674
2682
  x: n,
@@ -2708,65 +2716,65 @@ const tr = Zt(function({
2708
2716
  targetPosition: c = "top",
2709
2717
  label: u,
2710
2718
  labelStyle: l,
2711
- labelShowBg: g,
2712
- labelBgStyle: v,
2713
- labelBgPadding: E,
2714
- labelBgBorderRadius: R,
2719
+ labelShowBg: y,
2720
+ labelBgStyle: m,
2721
+ labelBgPadding: C,
2722
+ labelBgBorderRadius: z,
2715
2723
  style: M,
2716
- markerEnd: T,
2724
+ markerEnd: $,
2717
2725
  markerStart: k,
2718
- interactionWidth: z
2726
+ interactionWidth: E
2719
2727
  }) {
2720
- let W, D, x;
2721
- const f = _n(n, r, i), p = _n(s, o, c), y = Math.abs(p.x - f.x), N = Math.max(50, y * 0.5);
2722
- let C, P, b, L;
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;
2723
2731
  switch (i) {
2724
2732
  case "left":
2725
- C = f.x - N, P = f.y;
2733
+ w = f.x - N, P = f.y;
2726
2734
  break;
2727
2735
  case "top":
2728
- C = f.x, P = f.y - N;
2736
+ w = f.x, P = f.y - N;
2729
2737
  break;
2730
2738
  case "bottom":
2731
- C = f.x, P = f.y + N;
2739
+ w = f.x, P = f.y + N;
2732
2740
  break;
2733
2741
  default:
2734
- C = f.x + N, P = f.y;
2742
+ w = f.x + N, P = f.y;
2735
2743
  break;
2736
2744
  }
2737
2745
  switch (c) {
2738
2746
  case "right":
2739
- b = p.x + N, L = p.y;
2747
+ R = p.x + N, B = p.y;
2740
2748
  break;
2741
2749
  case "top":
2742
- b = p.x, L = p.y - N;
2750
+ R = p.x, B = p.y - N;
2743
2751
  break;
2744
2752
  case "bottom":
2745
- b = p.x, L = p.y + N;
2753
+ R = p.x, B = p.y + N;
2746
2754
  break;
2747
2755
  default:
2748
- b = p.x - N, L = p.y;
2756
+ R = p.x - N, B = p.y;
2749
2757
  break;
2750
2758
  }
2751
- W = `M ${n},${r} L ${f.x},${f.y} C ${C},${P} ${b},${L} ${p.x},${p.y} L ${s},${o}`;
2752
- const Y = 0.5, H = 0.5;
2753
- return D = H * H * H * f.x + 3 * H * H * Y * C + 3 * H * Y * Y * b + Y * Y * Y * p.x, x = H * H * H * f.y + 3 * H * H * Y * P + 3 * H * Y * Y * L + Y * Y * Y * p.y, /* @__PURE__ */ B(
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(
2754
2762
  un,
2755
2763
  {
2756
2764
  id: e,
2757
- path: W,
2765
+ path: _,
2758
2766
  labelX: D,
2759
- labelY: x,
2767
+ labelY: g,
2760
2768
  label: u,
2761
2769
  labelStyle: l,
2762
- labelShowBg: g,
2763
- labelBgStyle: v,
2764
- labelBgPadding: E,
2765
- labelBgBorderRadius: R,
2770
+ labelShowBg: y,
2771
+ labelBgStyle: m,
2772
+ labelBgPadding: C,
2773
+ labelBgBorderRadius: z,
2766
2774
  style: M,
2767
- markerEnd: T,
2775
+ markerEnd: $,
2768
2776
  markerStart: k,
2769
- interactionWidth: z
2777
+ interactionWidth: E
2770
2778
  }
2771
2779
  );
2772
2780
  });
@@ -2784,42 +2792,42 @@ function nr({
2784
2792
  targetPosition: o = "left",
2785
2793
  curvature: i = 0.25
2786
2794
  }) {
2787
- const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), g = Math.max(l * i, 50);
2788
- let v, E, R, M;
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);
2796
+ let m, C, z, M;
2789
2797
  switch (s) {
2790
2798
  case "top":
2791
- v = t, E = e - g;
2799
+ m = t, C = e - y;
2792
2800
  break;
2793
2801
  case "bottom":
2794
- v = t, E = e + g;
2802
+ m = t, C = e + y;
2795
2803
  break;
2796
2804
  case "left":
2797
- v = t - g, E = e;
2805
+ m = t - y, C = e;
2798
2806
  break;
2799
2807
  default:
2800
- v = t + g, E = e;
2808
+ m = t + y, C = e;
2801
2809
  break;
2802
2810
  }
2803
2811
  switch (o) {
2804
2812
  case "top":
2805
- R = n, M = r - g;
2813
+ z = n, M = r - y;
2806
2814
  break;
2807
2815
  case "bottom":
2808
- R = n, M = r + g;
2816
+ z = n, M = r + y;
2809
2817
  break;
2810
2818
  case "right":
2811
- R = n + g, M = r;
2819
+ z = n + y, M = r;
2812
2820
  break;
2813
2821
  default:
2814
- R = n - g, M = r;
2822
+ z = n - y, M = r;
2815
2823
  break;
2816
2824
  }
2817
- const T = `M ${t},${e} C ${v},${E} ${R},${M} ${n},${r}`, k = 0.5, z = 1 - k, W = z * z * z * t + 3 * z * z * k * v + 3 * z * k * k * R + k * k * k * n, D = z * z * z * e + 3 * z * z * k * E + 3 * z * k * k * M + k * k * k * r;
2818
- return [T, W, D, 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];
2819
2827
  }
2820
2828
  function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
2821
- 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, g = 0.5, v = g * g * g * t + 3 * g * g * l * i + 3 * g * l * l * c + l * l * l * n, E = g * g * g * e + 3 * g * g * l * e + 3 * g * l * l * r + l * l * l * r;
2822
- return [u, v, E, 0, 0];
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;
2830
+ return [u, m, C, 0, 0];
2823
2831
  }
2824
2832
  function kn({
2825
2833
  sourceX: t,
@@ -2835,11 +2843,11 @@ function kn({
2835
2843
  if (u) {
2836
2844
  if (Math.abs(r - e) < 1)
2837
2845
  return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
2838
- const R = (t + n) / 2, M = r > e ? 1 : -1;
2839
- return [`M ${t},${e} L ${R - l},${e} Q ${R},${e} ${R},${e + M * l} L ${R},${r - M * l} Q ${R},${r} ${R + (n > R ? l : -l)},${r} L ${n},${r}`, R, (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];
2840
2848
  }
2841
- const g = (e + r) / 2, v = n > t ? 1 : -1;
2842
- return [`M ${t},${e} L ${t},${g - l} Q ${t},${g} ${t + v * l},${g} L ${n - v * l},${g} Q ${n},${g} ${n},${g + (r > g ? l : -l)} L ${n},${r}`, (t + n) / 2, g, 0, 0];
2849
+ const y = (e + r) / 2, m = n > t ? 1 : -1;
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];
2843
2851
  }
2844
2852
  function zo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
2845
2853
  const [, s, o] = nr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
@@ -2897,20 +2905,20 @@ function ln(t, e) {
2897
2905
  }
2898
2906
  }
2899
2907
  function Yr(t, e, n, r, s, o, i, c) {
2900
- const u = Math.min(t, n), l = Math.max(t, n), g = Math.min(e, r), v = Math.max(e, r);
2901
- if (l <= s || u >= s + i || v <= o || g >= o + c) return !1;
2902
- const E = 0.5;
2903
- if (t > s + E && t < s + i - E && e > o + E && e < o + c - E || n > s + E && n < s + i - E && r > o + E && r < o + c - E) return !0;
2904
- const R = (t + n) / 2, M = (e + r) / 2;
2905
- if (R > s + E && R < s + i - E && M > o + E && M < o + c - E) return !0;
2906
- const T = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
2908
+ const u = Math.min(t, n), l = Math.max(t, n), y = Math.min(e, r), m = Math.max(e, r);
2909
+ if (l <= s || u >= s + i || m <= o || y >= o + c) return !1;
2910
+ const C = 0.5;
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;
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;
2914
+ const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
2907
2915
  for (let k = 0; k < 4; k++)
2908
- if (Ur(t, e, n, r, T[k][0], T[k][1], T[(k + 1) % 4][0], T[(k + 1) % 4][1])) return !0;
2916
+ if (Ur(t, e, n, r, $[k][0], $[k][1], $[(k + 1) % 4][0], $[(k + 1) % 4][1])) return !0;
2909
2917
  return !1;
2910
2918
  }
2911
2919
  function Ur(t, e, n, r, s, o, i, c) {
2912
- const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s), g = (n - t) * (o - e) - (r - e) * (s - t), v = (n - t) * (c - e) - (r - e) * (i - t);
2913
- return (u > 0 && l < 0 || u < 0 && l > 0) && (g > 0 && v < 0 || g < 0 && v > 0);
2920
+ const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s), y = (n - t) * (o - e) - (r - e) * (s - t), m = (n - t) * (c - e) - (r - e) * (i - t);
2921
+ return (u > 0 && l < 0 || u < 0 && l > 0) && (y > 0 && m < 0 || y < 0 && m > 0);
2914
2922
  }
2915
2923
  function zn(t, e, n, r, s) {
2916
2924
  for (let o = 0; o < s.length; o++) {
@@ -2950,44 +2958,44 @@ function sr(t, e, n) {
2950
2958
  r.add(t.x), r.add(e.x), s.add(t.y), s.add(e.y);
2951
2959
  const o = Ue + 5;
2952
2960
  t.dir === "right" ? r.add(t.x + o) : t.dir === "left" ? r.add(t.x - o) : t.dir === "top" ? s.add(t.y - o) : t.dir === "bottom" && s.add(t.y + o), e.dir === "right" ? r.add(e.x + o) : e.dir === "left" ? r.add(e.x - o) : e.dir === "top" ? s.add(e.y - o) : e.dir === "bottom" && s.add(e.y + o);
2953
- for (let b = 0; b < n.length; b++) {
2954
- const L = n[b];
2955
- r.add(L.x), r.add(L.x + L.w), s.add(L.y), s.add(L.y + L.h);
2961
+ for (let R = 0; R < n.length; R++) {
2962
+ const B = n[R];
2963
+ r.add(B.x), r.add(B.x + B.w), s.add(B.y), s.add(B.y + B.h);
2956
2964
  }
2957
- const i = [...r].sort((b, L) => b - L), c = [...s].sort((b, L) => b - L), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2958
- for (let b = 0; b < i.length; b++) u.set(i[b], b);
2959
- for (let b = 0; b < c.length; b++) l.set(c[b], b);
2960
- const g = i.length, v = c.length, E = (b, L) => L * g + b, R = u.get(t.x), M = l.get(t.y), T = u.get(e.x), k = l.get(e.y);
2961
- if (R === void 0 || M === void 0 || T === void 0 || k === void 0) return null;
2962
- const z = E(R, M), W = E(T, k), D = new Float64Array(g * v).fill(1 / 0), x = new Float64Array(g * v).fill(1 / 0), f = new Int32Array(g * v).fill(-1), p = new Int8Array(g * v).fill(-1), y = new Uint8Array(g * v);
2963
- D[z] = 0, x[z] = Math.abs(i[T] - t.x) + Math.abs(c[k] - t.y);
2964
- const N = [z], C = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
2965
+ const i = [...r].sort((R, B) => R - B), c = [...s].sort((R, B) => R - B), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
2966
+ for (let R = 0; R < i.length; R++) u.set(i[R], R);
2967
+ for (let R = 0; R < c.length; R++) l.set(c[R], R);
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]];
2965
2973
  for (; N.length > 0; ) {
2966
- let b = 0;
2974
+ let R = 0;
2967
2975
  for (let G = 1; G < N.length; G++)
2968
- x[N[G]] < x[N[b]] && (b = G);
2969
- const L = N[b];
2970
- if (N[b] = N[N.length - 1], N.pop(), L === W) {
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 === _) {
2971
2979
  const G = [];
2972
- let j = W;
2973
- for (; j !== -1 && j !== z; ) {
2974
- const rt = j / g | 0, at = j % g;
2975
- G.unshift({ x: i[at], y: c[rt] }), j = f[j];
2980
+ let j = _;
2981
+ for (; j !== -1 && j !== E; ) {
2982
+ const it = j / y | 0, dt = j % y;
2983
+ G.unshift({ x: i[dt], y: c[it] }), j = f[j];
2976
2984
  }
2977
2985
  return G.unshift({ x: t.x, y: t.y }), jr(G, n);
2978
2986
  }
2979
- if (y[L]) continue;
2980
- y[L] = 1;
2981
- const Y = L / g | 0, H = L % g, dt = i[H], yt = c[Y], ft = p[L];
2987
+ if (v[B]) continue;
2988
+ v[B] = 1;
2989
+ const q = B / y | 0, X = B % y, K = i[X], at = c[q], rt = p[B];
2982
2990
  for (let G = 0; G < 4; G++) {
2983
- const j = H + P[G][0], rt = Y + P[G][1];
2984
- if (j < 0 || j >= g || rt < 0 || rt >= v) continue;
2985
- const at = E(j, rt);
2986
- if (y[at]) continue;
2987
- const ct = i[j], lt = c[rt];
2988
- if (qr(ct, lt, n) || !zn(dt, yt, ct, lt, n)) continue;
2989
- const Ct = Math.abs(ct - dt) + Math.abs(lt - yt), et = ft >= 0 && ft !== G ? C : 0, ot = D[L] + Ct + et;
2990
- ot < D[at] && (f[at] = L, p[at] = G, D[at] = ot, x[at] = ot + Math.abs(i[T] - ct) + Math.abs(c[k] - lt), N.push(at));
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));
2991
2999
  }
2992
3000
  }
2993
3001
  return null;
@@ -3027,8 +3035,8 @@ function Gr(t) {
3027
3035
  if (i.length < 2) continue;
3028
3036
  const c = (i.length - 1) * nn / 2;
3029
3037
  for (let u = 0; u < i.length; u++) {
3030
- const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
3031
- v && (v[l.segIdx].y += g, v[l.segIdx + 1].y += g);
3038
+ const l = i[u], y = -c + u * nn, m = r.get(l.edgeId);
3039
+ m && (m[l.segIdx].y += y, m[l.segIdx + 1].y += y);
3032
3040
  }
3033
3041
  }
3034
3042
  }
@@ -3039,8 +3047,8 @@ function Gr(t) {
3039
3047
  if (i.length < 2) continue;
3040
3048
  const c = (i.length - 1) * nn / 2;
3041
3049
  for (let u = 0; u < i.length; u++) {
3042
- const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
3043
- v && (v[l.segIdx].x += g, v[l.segIdx + 1].x += g);
3050
+ const l = i[u], y = -c + u * nn, m = r.get(l.edgeId);
3051
+ m && (m[l.segIdx].x += y, m[l.segIdx + 1].x += y);
3044
3052
  }
3045
3053
  }
3046
3054
  }
@@ -3065,10 +3073,10 @@ function En(t, e = 6, n = !1) {
3065
3073
  const r = e;
3066
3074
  let s = `M ${t[0].x},${t[0].y}`;
3067
3075
  for (let o = 1; o < t.length - 1; o++) {
3068
- 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), g = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), v = Math.min(r, l / 2, g / 2);
3069
- if (v > 0.5) {
3070
- const E = c.x - i.x, R = c.y - i.y, M = u.x - c.x, T = u.y - c.y, k = Math.sqrt(E * E + R * R) || 1, z = Math.sqrt(M * M + T * T) || 1;
3071
- s += ` L ${c.x - E / k * v},${c.y - R / k * v}`, s += ` Q ${c.x},${c.y} ${c.x + M / z * v},${c.y + T / z * v}`;
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);
3077
+ if (m > 0.5) {
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}`;
3072
3080
  } else
3073
3081
  s += ` L ${c.x},${c.y}`;
3074
3082
  }
@@ -3082,8 +3090,8 @@ function Zr(t) {
3082
3090
  const e = 0.3;
3083
3091
  let n = `M ${t[0].x},${t[0].y}`;
3084
3092
  for (let r = 0; r < t.length - 1; r++) {
3085
- const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e, g = i.x - (c.x - o.x) * e, v = i.y - (c.y - o.y) * e;
3086
- n += ` C ${u},${l} ${g},${v} ${i.x},${i.y}`;
3093
+ const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e, y = i.x - (c.x - o.x) * e, m = i.y - (c.y - o.y) * e;
3094
+ n += ` C ${u},${l} ${y},${m} ${i.x},${i.y}`;
3087
3095
  }
3088
3096
  return n;
3089
3097
  }
@@ -3111,25 +3119,25 @@ function No(t, e) {
3111
3119
  const n = {};
3112
3120
  for (const o of t) n[o.id] = o;
3113
3121
  const r = or(t, null), s = e.map((o) => {
3114
- var p, y, N, C;
3122
+ var p, v, N, w;
3115
3123
  const i = o.type || "default";
3116
3124
  if (i === "bezier" || i === "simplebezier" || i === "default") return o;
3117
3125
  const c = n[o.source], u = n[o.target];
3118
3126
  if (!c || !u || c.hidden || u.hidden) return o;
3119
- const l = Wn(c, "source", o.sourceHandle), g = Wn(u, "target", o.targetHandle), v = ln(l, cn), E = ln(g, cn), R = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), T = c._absolutePosition || c.position, k = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, z = c.height || ((y = c.measured) == null ? void 0 : y.height) || an;
3120
- M.push({ id: o.source, x: T.x - R, y: T.y - R, w: k + 2 * R, h: z + 2 * R });
3121
- const W = u._absolutePosition || u.position, D = u.width || ((N = u.measured) == null ? void 0 : N.width) || sn, x = u.height || ((C = u.measured) == null ? void 0 : C.height) || an;
3122
- if (M.push({ id: o.target, x: W.x - R, y: W.y - R, w: D + 2 * R, h: x + 2 * R }), M.length === 0) return o;
3123
- const f = sr(v, E, M);
3124
- return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: g.x, y: g.y }), { ...o, _routedPoints: f }) : 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;
3131
+ const f = sr(m, C, M);
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;
3125
3133
  });
3126
3134
  return Gr(s);
3127
3135
  }
3128
3136
  function Lo(t, e, n, r, s, o, i, c) {
3129
3137
  const u = or(i, c ? new Set(c) : null);
3130
3138
  if (u.length === 0) return null;
3131
- const l = { x: t, y: e, dir: s || "right" }, g = { x: n, y: r, dir: o || "left" }, v = ln(l, cn), E = ln(g, cn), R = sr(v, E, u);
3132
- return R && R.length >= 2 ? (R.unshift({ x: l.x, y: l.y }), R.push({ x: g.x, y: g.y }), R) : 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;
3133
3141
  }
3134
3142
  const ir = Zt(function({
3135
3143
  id: e,
@@ -3141,38 +3149,38 @@ const ir = Zt(function({
3141
3149
  labelStyle: c,
3142
3150
  labelShowBg: u,
3143
3151
  labelBgStyle: l,
3144
- labelBgPadding: g,
3145
- labelBgBorderRadius: v,
3146
- style: E,
3147
- markerEnd: R,
3152
+ labelBgPadding: y,
3153
+ labelBgBorderRadius: m,
3154
+ style: C,
3155
+ markerEnd: z,
3148
3156
  markerStart: M,
3149
- interactionWidth: T,
3157
+ interactionWidth: $,
3150
3158
  routedPoints: k
3151
3159
  }) {
3152
- let z, W, D;
3160
+ let E, _, D;
3153
3161
  if (k && k.length >= 2) {
3154
- z = En(k);
3155
- const x = Cn(k);
3156
- W = x.x, D = x.y;
3162
+ E = En(k);
3163
+ const g = Cn(k);
3164
+ _ = g.x, D = g.y;
3157
3165
  } else
3158
- [z, W, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
3159
- return /* @__PURE__ */ B(
3166
+ [E, _, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
3167
+ return /* @__PURE__ */ S(
3160
3168
  un,
3161
3169
  {
3162
3170
  id: e,
3163
- path: z,
3164
- labelX: W,
3171
+ path: E,
3172
+ labelX: _,
3165
3173
  labelY: D,
3166
3174
  label: i,
3167
3175
  labelStyle: c,
3168
3176
  labelShowBg: u,
3169
3177
  labelBgStyle: l,
3170
- labelBgPadding: g,
3171
- labelBgBorderRadius: v,
3172
- style: E,
3173
- markerEnd: R,
3178
+ labelBgPadding: y,
3179
+ labelBgBorderRadius: m,
3180
+ style: C,
3181
+ markerEnd: z,
3174
3182
  markerStart: M,
3175
- interactionWidth: T
3183
+ interactionWidth: $
3176
3184
  }
3177
3185
  );
3178
3186
  });
@@ -3187,50 +3195,50 @@ const ar = Zt(function({
3187
3195
  targetPosition: c = "top",
3188
3196
  label: u,
3189
3197
  labelStyle: l,
3190
- labelShowBg: g,
3191
- labelBgStyle: v,
3192
- labelBgPadding: E,
3193
- labelBgBorderRadius: R,
3198
+ labelShowBg: y,
3199
+ labelBgStyle: m,
3200
+ labelBgPadding: C,
3201
+ labelBgBorderRadius: z,
3194
3202
  style: M,
3195
- markerEnd: T,
3203
+ markerEnd: $,
3196
3204
  markerStart: k,
3197
- pathOptions: z,
3198
- interactionWidth: W,
3205
+ pathOptions: E,
3206
+ interactionWidth: _,
3199
3207
  routedPoints: D
3200
3208
  }) {
3201
- let x, f, p;
3209
+ let g, f, p;
3202
3210
  if (D && D.length >= 2) {
3203
- x = En(D);
3204
- const y = Cn(D);
3205
- f = y.x, p = y.y;
3211
+ g = En(D);
3212
+ const v = Cn(D);
3213
+ f = v.x, p = v.y;
3206
3214
  } else
3207
- [x, f, p] = kn({
3215
+ [g, f, p] = kn({
3208
3216
  sourceX: n,
3209
3217
  sourceY: r,
3210
3218
  sourcePosition: i,
3211
3219
  targetX: s,
3212
3220
  targetY: o,
3213
3221
  targetPosition: c,
3214
- borderRadius: z == null ? void 0 : z.borderRadius,
3215
- offset: z == null ? void 0 : z.offset
3222
+ borderRadius: E == null ? void 0 : E.borderRadius,
3223
+ offset: E == null ? void 0 : E.offset
3216
3224
  });
3217
- return /* @__PURE__ */ B(
3225
+ return /* @__PURE__ */ S(
3218
3226
  un,
3219
3227
  {
3220
3228
  id: e,
3221
- path: x,
3229
+ path: g,
3222
3230
  labelX: f,
3223
3231
  labelY: p,
3224
3232
  label: u,
3225
3233
  labelStyle: l,
3226
- labelShowBg: g,
3227
- labelBgStyle: v,
3228
- labelBgPadding: E,
3229
- labelBgBorderRadius: R,
3234
+ labelShowBg: y,
3235
+ labelBgStyle: m,
3236
+ labelBgPadding: C,
3237
+ labelBgBorderRadius: z,
3230
3238
  style: M,
3231
- markerEnd: T,
3239
+ markerEnd: $,
3232
3240
  markerStart: k,
3233
- interactionWidth: W
3241
+ interactionWidth: _
3234
3242
  }
3235
3243
  );
3236
3244
  });
@@ -3244,7 +3252,7 @@ const Or = Zt(function({ id: e, ...n }) {
3244
3252
  },
3245
3253
  [(s = n.pathOptions) == null ? void 0 : s.offset]
3246
3254
  );
3247
- return /* @__PURE__ */ B(ar, { ...n, id: e, pathOptions: r });
3255
+ return /* @__PURE__ */ S(ar, { ...n, id: e, pathOptions: r });
3248
3256
  });
3249
3257
  Or.displayName = "StepEdge";
3250
3258
  const cr = Zt(function({
@@ -3257,45 +3265,45 @@ const cr = Zt(function({
3257
3265
  targetPosition: c,
3258
3266
  label: u,
3259
3267
  labelStyle: l,
3260
- labelShowBg: g,
3261
- labelBgStyle: v,
3262
- labelBgPadding: E,
3263
- labelBgBorderRadius: R,
3268
+ labelShowBg: y,
3269
+ labelBgStyle: m,
3270
+ labelBgPadding: C,
3271
+ labelBgBorderRadius: z,
3264
3272
  style: M,
3265
- markerEnd: T,
3273
+ markerEnd: $,
3266
3274
  markerStart: k,
3267
- interactionWidth: z,
3268
- routedPoints: W
3275
+ interactionWidth: E,
3276
+ routedPoints: _
3269
3277
  }) {
3270
- let D, x, f;
3271
- if (W && W.length >= 2) {
3272
- D = En(W);
3273
- const p = Cn(W);
3274
- x = p.x, f = p.y;
3278
+ let D, g, f;
3279
+ if (_ && _.length >= 2) {
3280
+ D = En(_);
3281
+ const p = Cn(_);
3282
+ g = p.x, f = p.y;
3275
3283
  } else
3276
- [D, x, f] = rr({
3284
+ [D, g, f] = rr({
3277
3285
  sourceX: n,
3278
3286
  sourceY: r,
3279
3287
  targetX: s,
3280
3288
  targetY: o
3281
3289
  });
3282
- return /* @__PURE__ */ B(
3290
+ return /* @__PURE__ */ S(
3283
3291
  un,
3284
3292
  {
3285
3293
  id: e,
3286
3294
  path: D,
3287
- labelX: x,
3295
+ labelX: g,
3288
3296
  labelY: f,
3289
3297
  label: u,
3290
3298
  labelStyle: l,
3291
- labelShowBg: g,
3292
- labelBgStyle: v,
3293
- labelBgPadding: E,
3294
- labelBgBorderRadius: R,
3299
+ labelShowBg: y,
3300
+ labelBgStyle: m,
3301
+ labelBgPadding: C,
3302
+ labelBgBorderRadius: z,
3295
3303
  style: M,
3296
- markerEnd: T,
3304
+ markerEnd: $,
3297
3305
  markerStart: k,
3298
- interactionWidth: z
3306
+ interactionWidth: E
3299
3307
  }
3300
3308
  );
3301
3309
  });
@@ -3324,49 +3332,49 @@ function Io({
3324
3332
  width: c = "100%",
3325
3333
  height: u = "420px",
3326
3334
  className: l = "",
3327
- style: g = {},
3335
+ style: y = {},
3328
3336
  // Zoom/Camera
3329
- zoomMin: v,
3330
- zoomMax: E,
3331
- initialCamera: R,
3337
+ zoomMin: m,
3338
+ zoomMax: C,
3339
+ initialCamera: z,
3332
3340
  fitView: M,
3333
- fitViewOptions: T,
3341
+ fitViewOptions: $,
3334
3342
  // Node/Edge callbacks
3335
3343
  onNodesChange: k,
3336
- onEdgesChange: z,
3337
- onConnect: W,
3344
+ onEdgesChange: E,
3345
+ onConnect: _,
3338
3346
  onConnectStart: D,
3339
- onConnectEnd: x,
3347
+ onConnectEnd: g,
3340
3348
  onNodeClick: f,
3341
3349
  onNodeDoubleClick: p,
3342
- onNodeMouseEnter: y,
3350
+ onNodeMouseEnter: v,
3343
3351
  onNodeMouseMove: N,
3344
- onNodeMouseLeave: C,
3352
+ onNodeMouseLeave: w,
3345
3353
  onNodeContextMenu: P,
3346
- onNodeDragStart: b,
3347
- onNodeDrag: L,
3348
- onNodeDragStop: Y,
3349
- onEdgeClick: H,
3350
- onEdgeDoubleClick: dt,
3351
- onEdgeMouseEnter: yt,
3352
- onEdgeMouseMove: ft,
3354
+ onNodeDragStart: R,
3355
+ onNodeDrag: B,
3356
+ onNodeDragStop: q,
3357
+ onEdgeClick: X,
3358
+ onEdgeDoubleClick: K,
3359
+ onEdgeMouseEnter: at,
3360
+ onEdgeMouseMove: rt,
3353
3361
  onEdgeMouseLeave: G,
3354
3362
  onEdgeContextMenu: j,
3355
- onPaneClick: rt,
3356
- onPaneContextMenu: at,
3357
- onPaneMouseEnter: ct,
3358
- onPaneMouseMove: lt,
3359
- onPaneMouseLeave: Ct,
3360
- onSelectionChange: et,
3361
- onInit: ot,
3363
+ onPaneClick: it,
3364
+ onPaneContextMenu: dt,
3365
+ onPaneMouseEnter: ot,
3366
+ onPaneMouseMove: ft,
3367
+ onPaneMouseLeave: It,
3368
+ onSelectionChange: st,
3369
+ onInit: xt,
3362
3370
  onMoveStart: Nt,
3363
- onMove: Rt,
3364
- onMoveEnd: vt,
3365
- onDelete: Lt,
3366
- onBeforeDelete: kt,
3367
- onError: $t,
3371
+ onMove: gt,
3372
+ onMoveEnd: ct,
3373
+ onDelete: zt,
3374
+ onBeforeDelete: Rt,
3375
+ onError: Lt,
3368
3376
  // Drag and drop
3369
- onDragOver: mt,
3377
+ onDragOver: wt,
3370
3378
  onDrop: ne,
3371
3379
  onDragEnter: Ie,
3372
3380
  onDragLeave: Bt,
@@ -3393,10 +3401,10 @@ function Io({
3393
3401
  zoomOnDoubleClick: Nn,
3394
3402
  zoomOnPinch: hn,
3395
3403
  preventScrolling: fe,
3396
- translateExtent: pt,
3404
+ translateExtent: mt,
3397
3405
  nodeExtent: Te,
3398
- autoPanOnNodeDrag: zt,
3399
- autoPanOnConnect: gt,
3406
+ autoPanOnNodeDrag: Et,
3407
+ autoPanOnConnect: pt,
3400
3408
  autoPanSpeed: se,
3401
3409
  edgesReconnectable: Z,
3402
3410
  elevateNodesOnSelect: Pt,
@@ -3412,71 +3420,71 @@ function Io({
3412
3420
  children: Me,
3413
3421
  ...ie
3414
3422
  }) {
3415
- 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(
3416
3424
  (Q) => {
3417
3425
  Re(Q), te == null || te(Q);
3418
3426
  },
3419
3427
  [te]
3420
3428
  ), ae = St(() => ({ ...Qr, ...r }), [r]), Kt = St(() => ({ ...Kr, ...s }), [s]), he = St(() => {
3421
3429
  const Q = e.filter((Ft) => Ft.type && ae[Ft.type]);
3422
- return Q.sort((Ft, st) => {
3423
- const Tt = Ft.type === "group" || !Ft.parentId && Q.some((Ee) => Ee.parentId === Ft.id), xe = st.type === "group" || !st.parentId && Q.some((Ee) => Ee.parentId === st.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);
3424
3432
  return Tt && !xe ? -1 : !Tt && xe ? 1 : 0;
3425
3433
  });
3426
- }, [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]), wt = 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]), {
3427
3435
  wrapRef: Dt,
3428
3436
  canvasRef: ce,
3429
3437
  canvasReady: De,
3430
- onPointerDown: He,
3431
- onPointerMove: Ae,
3438
+ onPointerDown: Ae,
3439
+ onPointerMove: He,
3432
3440
  onPointerUp: _e,
3433
3441
  store: le
3434
3442
  } = Lr({
3435
3443
  cards: t,
3436
3444
  nodes: O,
3437
- edges: wt,
3445
+ edges: bt,
3438
3446
  dark: o,
3439
3447
  gridSize: i,
3440
- zoomMin: v,
3441
- zoomMax: E,
3442
- initialCamera: R,
3448
+ zoomMin: m,
3449
+ zoomMax: C,
3450
+ initialCamera: z,
3443
3451
  fitView: M,
3444
- fitViewOptions: T,
3452
+ fitViewOptions: $,
3445
3453
  onHudUpdate: Ve,
3446
3454
  onNodesProcessed: gn,
3447
3455
  onNodesChange: k,
3448
- onEdgesChange: z,
3449
- onConnect: W,
3456
+ onEdgesChange: E,
3457
+ onConnect: _,
3450
3458
  onConnectStart: D,
3451
- onConnectEnd: x,
3459
+ onConnectEnd: g,
3452
3460
  onNodeClick: f,
3453
3461
  onNodeDoubleClick: p,
3454
- onNodeMouseEnter: y,
3462
+ onNodeMouseEnter: v,
3455
3463
  onNodeMouseMove: N,
3456
- onNodeMouseLeave: C,
3464
+ onNodeMouseLeave: w,
3457
3465
  onNodeContextMenu: P,
3458
- onNodeDragStart: b,
3459
- onNodeDrag: L,
3460
- onNodeDragStop: Y,
3461
- onEdgeClick: H,
3462
- onEdgeDoubleClick: dt,
3463
- onEdgeMouseEnter: yt,
3464
- onEdgeMouseMove: ft,
3466
+ onNodeDragStart: R,
3467
+ onNodeDrag: B,
3468
+ onNodeDragStop: q,
3469
+ onEdgeClick: X,
3470
+ onEdgeDoubleClick: K,
3471
+ onEdgeMouseEnter: at,
3472
+ onEdgeMouseMove: rt,
3465
3473
  onEdgeMouseLeave: G,
3466
3474
  onEdgeContextMenu: j,
3467
- onPaneClick: rt,
3468
- onPaneContextMenu: at,
3469
- onPaneMouseEnter: ct,
3470
- onPaneMouseMove: lt,
3471
- onPaneMouseLeave: Ct,
3472
- onSelectionChange: et,
3473
- onInit: ot,
3475
+ onPaneClick: it,
3476
+ onPaneContextMenu: dt,
3477
+ onPaneMouseEnter: ot,
3478
+ onPaneMouseMove: ft,
3479
+ onPaneMouseLeave: It,
3480
+ onSelectionChange: st,
3481
+ onInit: xt,
3474
3482
  onMoveStart: Nt,
3475
- onMove: Rt,
3476
- onMoveEnd: vt,
3477
- onDelete: Lt,
3478
- onBeforeDelete: kt,
3479
- onError: $t,
3483
+ onMove: gt,
3484
+ onMoveEnd: ct,
3485
+ onDelete: zt,
3486
+ onBeforeDelete: Rt,
3487
+ onError: Lt,
3480
3488
  nodesDraggable: Ot,
3481
3489
  nodesConnectable: Yt,
3482
3490
  elementsSelectable: me,
@@ -3499,10 +3507,10 @@ function Io({
3499
3507
  zoomOnDoubleClick: Nn,
3500
3508
  zoomOnPinch: hn,
3501
3509
  preventScrolling: fe,
3502
- translateExtent: pt,
3510
+ translateExtent: mt,
3503
3511
  nodeExtent: Te,
3504
- autoPanOnNodeDrag: zt,
3505
- autoPanOnConnect: gt,
3512
+ autoPanOnNodeDrag: Et,
3513
+ autoPanOnConnect: pt,
3506
3514
  autoPanSpeed: se,
3507
3515
  edgesReconnectable: Z,
3508
3516
  elevateNodesOnSelect: Pt,
@@ -3518,34 +3526,34 @@ function Io({
3518
3526
  get edges() {
3519
3527
  return n;
3520
3528
  }
3521
- }), [le, e, n]), ye = V(null), ge = V(null), pe = V(null), Jt = V(null);
3522
- ut(() => {
3529
+ }), [le, e, n]), ye = tt(null), ge = tt(null), pe = tt(null), Jt = tt(null);
3530
+ ht(() => {
3523
3531
  let Q;
3524
3532
  const Ft = () => {
3525
- const st = le.cameraRef.current, Tt = `translate(${st.x}px, ${st.y}px) scale(${st.zoom})`, xe = `translate(${st.x}, ${st.y}) scale(${st.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})`;
3526
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);
3527
3535
  };
3528
3536
  return Q = requestAnimationFrame(Ft), () => cancelAnimationFrame(Q);
3529
3537
  }, [le]);
3530
3538
  const ze = he.length > 0, ee = ke.length > 0;
3531
- return /* @__PURE__ */ B(Zn.Provider, { value: We, children: /* @__PURE__ */ It(
3539
+ return /* @__PURE__ */ S(Zn.Provider, { value: We, children: /* @__PURE__ */ $t(
3532
3540
  "div",
3533
3541
  {
3534
3542
  ref: Dt,
3535
3543
  className: `ric-wrap ${l}`,
3536
- style: { width: c, height: u, ...g },
3537
- onPointerDown: He,
3538
- onPointerMove: Ae,
3544
+ style: { width: c, height: u, ...y },
3545
+ onPointerDown: Ae,
3546
+ onPointerMove: He,
3539
3547
  onPointerUp: _e,
3540
- onDragOver: mt,
3548
+ onDragOver: wt,
3541
3549
  onDrop: ne,
3542
3550
  onDragEnter: Ie,
3543
3551
  onDragLeave: Bt,
3544
3552
  tabIndex: 0,
3545
3553
  children: [
3546
- /* @__PURE__ */ B("canvas", { ref: ce, className: "ric-canvas" }),
3547
- !De && /* @__PURE__ */ B("div", { className: "ric-loader", children: /* @__PURE__ */ B("div", { className: "ric-spinner" }) }),
3548
- ee && /* @__PURE__ */ B(
3554
+ /* @__PURE__ */ S("canvas", { ref: ce, className: "ric-canvas" }),
3555
+ !De && /* @__PURE__ */ S("div", { className: "ric-loader", children: /* @__PURE__ */ S("div", { className: "ric-spinner" }) }),
3556
+ ee && /* @__PURE__ */ S(
3549
3557
  "svg",
3550
3558
  {
3551
3559
  className: "ric-edges-overlay",
@@ -3558,7 +3566,7 @@ function Io({
3558
3566
  pointerEvents: "none",
3559
3567
  overflow: "visible"
3560
3568
  },
3561
- children: /* @__PURE__ */ B("g", { ref: ge, children: ke.map((Q) => /* @__PURE__ */ B(
3569
+ children: /* @__PURE__ */ S("g", { ref: ge, children: ke.map((Q) => /* @__PURE__ */ S(
3562
3570
  Dr,
3563
3571
  {
3564
3572
  edge: Q,
@@ -3570,7 +3578,7 @@ function Io({
3570
3578
  )) })
3571
3579
  }
3572
3580
  ),
3573
- ze && /* @__PURE__ */ B(
3581
+ ze && /* @__PURE__ */ S(
3574
3582
  "div",
3575
3583
  {
3576
3584
  ref: ye,
@@ -3585,7 +3593,7 @@ function Io({
3585
3593
  pointerEvents: "none",
3586
3594
  zIndex: 10
3587
3595
  },
3588
- children: he.map((Q) => /* @__PURE__ */ B(
3596
+ children: he.map((Q) => /* @__PURE__ */ S(
3589
3597
  Pr,
3590
3598
  {
3591
3599
  node: Q,
@@ -3595,7 +3603,7 @@ function Io({
3595
3603
  ))
3596
3604
  }
3597
3605
  ),
3598
- /* @__PURE__ */ B(
3606
+ /* @__PURE__ */ S(
3599
3607
  "div",
3600
3608
  {
3601
3609
  ref: (Q) => {
@@ -3614,7 +3622,7 @@ function Io({
3614
3622
  }
3615
3623
  }
3616
3624
  ),
3617
- /* @__PURE__ */ B(
3625
+ /* @__PURE__ */ S(
3618
3626
  "div",
3619
3627
  {
3620
3628
  ref: (Q) => {
@@ -3633,8 +3641,8 @@ function Io({
3633
3641
  }
3634
3642
  }
3635
3643
  ),
3636
- _t && /* @__PURE__ */ B("div", { className: "ric-hint", children: Wt }),
3637
- pn && /* @__PURE__ */ It("div", { className: "ric-info", children: [
3644
+ _t && /* @__PURE__ */ S("div", { className: "ric-hint", children: Wt }),
3645
+ pn && /* @__PURE__ */ $t("div", { className: "ric-info", children: [
3638
3646
  "world: (",
3639
3647
  Ut.wx,
3640
3648
  ", ",
@@ -3642,17 +3650,17 @@ function Io({
3642
3650
  ")   zoom: ",
3643
3651
  Ut.zoom,
3644
3652
  "x",
3645
- Ut.nodeCount > 0 && /* @__PURE__ */ It(Le, { children: [
3653
+ Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
3646
3654
  "   nodes: ",
3647
3655
  Ut.nodeCount
3648
3656
  ] }),
3649
- Ut.edgeCount > 0 && /* @__PURE__ */ It(Le, { children: [
3657
+ Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
3650
3658
  "   edges: ",
3651
3659
  Ut.edgeCount
3652
3660
  ] })
3653
3661
  ] }),
3654
- /* @__PURE__ */ B(
3655
- Hr,
3662
+ /* @__PURE__ */ S(
3663
+ Ar,
3656
3664
  {
3657
3665
  selectionKeyCode: de || "Shift",
3658
3666
  selectionMode: we || "partial"
@@ -3739,96 +3747,96 @@ function So(t) {
3739
3747
  return [e, n, r];
3740
3748
  }
3741
3749
  function eo() {
3742
- const t = ht(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((x) => t.nodesRef.current.find((f) => f.id === x), [t]), s = F((x) => t.edgesRef.current.find((f) => f.id === x), [t]), o = F((x) => {
3743
- var f, p, y, N;
3744
- if (typeof x == "function") {
3745
- const C = x(t.nodesRef.current);
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) => {
3751
+ var f, p, v, N;
3752
+ if (typeof g == "function") {
3753
+ const w = g(t.nodesRef.current);
3746
3754
  (p = (f = t.onNodesChangeRef).current) == null || p.call(f, [
3747
3755
  ...t.nodesRef.current.map((P) => ({ id: P.id, type: "remove" })),
3748
- ...C.map((P) => ({ type: "add", item: P }))
3756
+ ...w.map((P) => ({ type: "add", item: P }))
3749
3757
  ]);
3750
3758
  } else
3751
- (N = (y = t.onNodesChangeRef).current) == null || N.call(y, [
3752
- ...t.nodesRef.current.map((C) => ({ id: C.id, type: "remove" })),
3753
- ...x.map((C) => ({ type: "add", item: C }))
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 }))
3754
3762
  ]);
3755
- }, [t]), i = F((x) => {
3756
- var f, p, y, N;
3757
- if (typeof x == "function") {
3758
- const C = x(t.edgesRef.current);
3763
+ }, [t]), i = F((g) => {
3764
+ var f, p, v, N;
3765
+ if (typeof g == "function") {
3766
+ const w = g(t.edgesRef.current);
3759
3767
  (p = (f = t.onEdgesChangeRef).current) == null || p.call(f, [
3760
3768
  ...t.edgesRef.current.map((P) => ({ id: P.id, type: "remove" })),
3761
- ...C.map((P) => ({ type: "add", item: P }))
3769
+ ...w.map((P) => ({ type: "add", item: P }))
3762
3770
  ]);
3763
3771
  } else
3764
- (N = (y = t.onEdgesChangeRef).current) == null || N.call(y, [
3765
- ...t.edgesRef.current.map((C) => ({ id: C.id, type: "remove" })),
3766
- ...x.map((C) => ({ type: "add", item: C }))
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 }))
3767
3775
  ]);
3768
- }, [t]), c = F((x) => {
3769
- var p, y;
3770
- const f = Array.isArray(x) ? x : [x];
3771
- (y = (p = t.onNodesChangeRef).current) == null || y.call(p, f.map((N) => ({ type: "add", item: N })));
3772
- }, [t]), u = F((x) => {
3773
- var p, y;
3774
- const f = Array.isArray(x) ? x : [x];
3775
- (y = (p = t.onEdgesChangeRef).current) == null || y.call(p, f.map((N) => ({ type: "add", item: N })));
3776
- }, [t]), l = F(({ nodes: x = [], edges: f = [] }) => {
3777
- if (x.length && t.onNodesChangeRef.current) {
3778
- t.onNodesChangeRef.current(x.map((y) => ({ id: y.id, type: "remove" })));
3779
- const p = zr(x, t.edgesRef.current);
3780
- p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((y) => ({ id: y.id, type: "remove" })));
3776
+ }, [t]), c = F((g) => {
3777
+ var p, v;
3778
+ const f = Array.isArray(g) ? g : [g];
3779
+ (v = (p = t.onNodesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
3780
+ }, [t]), u = F((g) => {
3781
+ var p, v;
3782
+ const f = Array.isArray(g) ? g : [g];
3783
+ (v = (p = t.onEdgesChangeRef).current) == null || v.call(p, f.map((N) => ({ type: "add", item: N })));
3784
+ }, [t]), l = F(({ nodes: g = [], edges: f = [] }) => {
3785
+ if (g.length && t.onNodesChangeRef.current) {
3786
+ t.onNodesChangeRef.current(g.map((v) => ({ id: v.id, type: "remove" })));
3787
+ const p = zr(g, t.edgesRef.current);
3788
+ p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((v) => ({ id: v.id, type: "remove" })));
3781
3789
  }
3782
3790
  f.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(f.map((p) => ({ id: p.id, type: "remove" })));
3783
- }, [t]), g = F(() => {
3784
- const x = t.cameraRef.current;
3785
- return { x: x.x, y: x.y, zoom: x.zoom };
3786
- }, [t]), v = F((x, f) => {
3791
+ }, [t]), y = F(() => {
3792
+ const g = t.cameraRef.current;
3793
+ return { x: g.x, y: g.y, zoom: g.zoom };
3794
+ }, [t]), m = F((g, f) => {
3787
3795
  t.cameraRef.current = {
3788
- x: x.x ?? t.cameraRef.current.x,
3789
- y: x.y ?? t.cameraRef.current.y,
3790
- zoom: x.zoom ?? t.cameraRef.current.zoom
3796
+ x: g.x ?? t.cameraRef.current.x,
3797
+ y: g.y ?? t.cameraRef.current.y,
3798
+ zoom: g.zoom ?? t.cameraRef.current.zoom
3791
3799
  }, t.sendCamera();
3792
- }, [t]), E = F(() => t.cameraRef.current.zoom, [t]), R = F((x) => {
3800
+ }, [t]), C = F(() => t.cameraRef.current.zoom, [t]), z = F((g) => {
3793
3801
  const f = t.cameraRef.current, p = t.wrapRef.current;
3794
3802
  if (!p) return;
3795
- const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = 1.2;
3796
- f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
3797
- }, [t]), M = F((x) => {
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();
3805
+ }, [t]), M = F((g) => {
3798
3806
  const f = t.cameraRef.current, p = t.wrapRef.current;
3799
3807
  if (!p) return;
3800
- const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = 1 / 1.2;
3801
- f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
3802
- }, [t]), T = F((x) => {
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();
3810
+ }, [t]), $ = F((g) => {
3803
3811
  const f = t.cameraRef.current, p = t.wrapRef.current;
3804
3812
  if (!p) return;
3805
- const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = x / f.zoom;
3806
- f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, x)), t.sendCamera();
3807
- }, [t]), k = F((x = {}) => {
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 = {}) => {
3808
3816
  const f = t.nodesRef.current;
3809
3817
  if (!f.length) return;
3810
3818
  const p = t.wrapRef.current;
3811
3819
  if (!p) return;
3812
- const y = p.getBoundingClientRect(), N = x.padding ?? 0.1, C = x.nodes ? f.filter((L) => x.nodes.some((Y) => Y.id === L.id)) : f;
3813
- if (!C.length) return;
3814
- const P = Mn(C), b = Rn(P, y.width, y.height, N);
3815
- x.maxZoom && (b.zoom = Math.min(b.zoom, x.maxZoom)), x.minZoom && (b.zoom = Math.max(b.zoom, x.minZoom)), t.cameraRef.current = b, t.sendCamera();
3816
- }, [t]), z = F((x, f, p = {}) => {
3817
- const y = t.wrapRef.current;
3818
- if (!y) return;
3819
- const N = y.getBoundingClientRect(), C = p.zoom ?? t.cameraRef.current.zoom;
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);
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();
3824
+ }, [t]), E = F((g, f, p = {}) => {
3825
+ const v = t.wrapRef.current;
3826
+ if (!v) return;
3827
+ const N = v.getBoundingClientRect(), w = p.zoom ?? t.cameraRef.current.zoom;
3820
3828
  t.cameraRef.current = {
3821
- x: N.width / 2 - x * C,
3822
- y: N.height / 2 - f * C,
3823
- zoom: C
3829
+ x: N.width / 2 - g * w,
3830
+ y: N.height / 2 - f * w,
3831
+ zoom: w
3824
3832
  }, t.sendCamera();
3825
- }, [t]), W = F((x) => t.screenToWorld(x.x, x.y), [t]), D = F((x) => {
3833
+ }, [t]), _ = F((g) => t.screenToWorld(g.x, g.y), [t]), D = F((g) => {
3826
3834
  const f = t.cameraRef.current, p = t.wrapRef.current;
3827
3835
  if (!p) return { x: 0, y: 0 };
3828
- const y = p.getBoundingClientRect();
3836
+ const v = p.getBoundingClientRect();
3829
3837
  return {
3830
- x: x.x * f.zoom + f.x + y.left,
3831
- y: x.y * f.zoom + f.y + y.top
3838
+ x: g.x * f.zoom + f.x + v.left,
3839
+ y: g.y * f.zoom + f.y + v.top
3832
3840
  };
3833
3841
  }, [t]);
3834
3842
  return {
@@ -3841,54 +3849,54 @@ function eo() {
3841
3849
  addNodes: c,
3842
3850
  addEdges: u,
3843
3851
  deleteElements: l,
3844
- getViewport: g,
3845
- setViewport: v,
3846
- getZoom: E,
3847
- zoomIn: R,
3852
+ getViewport: y,
3853
+ setViewport: m,
3854
+ getZoom: C,
3855
+ zoomIn: z,
3848
3856
  zoomOut: M,
3849
- zoomTo: T,
3857
+ zoomTo: $,
3850
3858
  fitView: k,
3851
- setCenter: z,
3852
- screenToFlowPosition: W,
3859
+ setCenter: E,
3860
+ screenToFlowPosition: _,
3853
3861
  flowToScreenPosition: D
3854
3862
  };
3855
3863
  }
3856
3864
  function Bo() {
3857
- return ht().nodes;
3865
+ return yt().nodes;
3858
3866
  }
3859
3867
  function Do() {
3860
- return ht().edges;
3861
- }
3862
- function Ho() {
3863
- return ht().viewport;
3868
+ return yt().edges;
3864
3869
  }
3865
3870
  function Ao() {
3866
- return ht().connection;
3871
+ return yt().viewport;
3872
+ }
3873
+ function Ho() {
3874
+ return yt().connection;
3867
3875
  }
3868
3876
  function _o(t) {
3869
- const e = ht(), n = Array.isArray(t) ? t : [t];
3877
+ const e = yt(), n = Array.isArray(t) ? t : [t];
3870
3878
  return St(() => n.map((r) => {
3871
3879
  const s = e.nodes.find((o) => o.id === r);
3872
3880
  return s ? { id: s.id, type: s.type, data: s.data } : null;
3873
3881
  }).filter(Boolean), [e.nodes, ...n]);
3874
3882
  }
3875
3883
  function Wo(t) {
3876
- const e = ht();
3884
+ const e = yt();
3877
3885
  return St(() => e.edges.filter((n) => n.source === t || n.target === t), [e.edges, t]);
3878
3886
  }
3879
3887
  function Xo({ nodeId: t, type: e, handleId: n }) {
3880
- const r = ht();
3888
+ const r = yt();
3881
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]);
3882
3890
  }
3883
3891
  function Fo({ onChange: t, onStart: e, onEnd: n }) {
3884
- const r = ht(), s = V(t), o = V(e), i = V(n);
3885
- ut(() => {
3892
+ const r = yt(), s = tt(t), o = tt(e), i = tt(n);
3893
+ ht(() => {
3886
3894
  s.current = t;
3887
- }, [t]), ut(() => {
3895
+ }, [t]), ht(() => {
3888
3896
  o.current = e;
3889
- }, [e]), ut(() => {
3897
+ }, [e]), ht(() => {
3890
3898
  i.current = n;
3891
- }, [n]), ut(() => {
3899
+ }, [n]), ht(() => {
3892
3900
  const c = (u) => {
3893
3901
  var l;
3894
3902
  (l = s.current) == null || l.call(s, { x: u.x, y: u.y, zoom: u.zoom });
@@ -3897,10 +3905,10 @@ function Fo({ onChange: t, onStart: e, onEnd: n }) {
3897
3905
  }, [r]);
3898
3906
  }
3899
3907
  function Yo({ onChange: t }) {
3900
- const e = ht(), n = V(t);
3901
- ut(() => {
3908
+ const e = yt(), n = tt(t);
3909
+ ht(() => {
3902
3910
  n.current = t;
3903
- }, [t]), ut(() => {
3911
+ }, [t]), ht(() => {
3904
3912
  const r = (s) => {
3905
3913
  var o;
3906
3914
  (o = n.current) == null || o.call(n, s);
@@ -3910,7 +3918,7 @@ function Yo({ onChange: t }) {
3910
3918
  }
3911
3919
  function Uo(t) {
3912
3920
  const [e, n] = Gt(!1), r = Array.isArray(t) ? t : [t];
3913
- return ut(() => {
3921
+ return ht(() => {
3914
3922
  const s = (i) => {
3915
3923
  r.includes(i.key) && n(!0);
3916
3924
  }, o = (i) => {
@@ -3922,7 +3930,7 @@ function Uo(t) {
3922
3930
  }, [r.join(",")]), e;
3923
3931
  }
3924
3932
  function qo() {
3925
- const t = ht();
3933
+ const t = yt();
3926
3934
  return F((e) => {
3927
3935
  var n;
3928
3936
  (n = t.workerRef.current) == null || n.postMessage({
@@ -3932,18 +3940,18 @@ function qo() {
3932
3940
  }, [t]);
3933
3941
  }
3934
3942
  function jo(t = {}) {
3935
- return ht().nodes.length > 0;
3943
+ return yt().nodes.length > 0;
3936
3944
  }
3937
3945
  function Go(t) {
3938
- const e = ht();
3946
+ const e = yt();
3939
3947
  return St(() => e.nodes.find((n) => n.id === t) || void 0, [e.nodes, t]);
3940
3948
  }
3941
3949
  function Zo(t) {
3942
- const e = ht();
3950
+ const e = yt();
3943
3951
  return typeof t == "function" ? t(e) : e;
3944
3952
  }
3945
3953
  function Oo() {
3946
- const t = ht();
3954
+ const t = yt();
3947
3955
  return St(() => ({
3948
3956
  getState: () => t,
3949
3957
  setState: () => {
@@ -3961,52 +3969,52 @@ function Qo({
3961
3969
  style: o = {},
3962
3970
  className: i = ""
3963
3971
  }) {
3964
- const c = ht(), u = V(null), l = V(null), g = F(() => {
3965
- const v = u.current;
3966
- if (!v) return;
3967
- const E = v.getContext("2d"), R = window.devicePixelRatio || 1;
3968
- v.width = t * R, v.height = e * R, E.scale(R, R), E.clearRect(0, 0, t, e);
3972
+ const c = yt(), u = tt(null), l = tt(null), y = F(() => {
3973
+ const m = u.current;
3974
+ if (!m) return;
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);
3969
3977
  const M = c.nodesRef.current;
3970
3978
  if (!M.length) return;
3971
- let T = 1 / 0, k = 1 / 0, z = -1 / 0, W = -1 / 0;
3972
- for (const b of M) {
3973
- const L = b.width || wn, Y = b.height || bn;
3974
- b.position.x < T && (T = b.position.x), b.position.y < k && (k = b.position.y), b.position.x + L > z && (z = b.position.x + L), b.position.y + Y > W && (W = b.position.y + Y);
3979
+ let $ = 1 / 0, k = 1 / 0, E = -1 / 0, _ = -1 / 0;
3980
+ for (const R of M) {
3981
+ const B = R.width || wn, q = R.height || bn;
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);
3975
3983
  }
3976
3984
  const D = 40;
3977
- T -= D, k -= D, z += D, W += D;
3978
- const x = z - T, f = W - k, p = Math.min(t / x, e / f), y = (t - x * p) / 2, N = (e - f * p) / 2;
3979
- for (const b of M) {
3980
- if (b.hidden) continue;
3981
- const L = b.width || wn, Y = b.height || bn, H = (b.position.x - T) * p + y, dt = (b.position.y - k) * p + N, yt = L * p, ft = Y * p;
3982
- E.fillStyle = b.selected ? "#f59e0b" : typeof n == "function" ? n(b) : n, E.fillRect(H, dt, Math.max(yt, 2), Math.max(ft, 2));
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;
3987
+ for (const R of M) {
3988
+ if (R.hidden) continue;
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));
3983
3991
  }
3984
- const C = c.cameraRef.current, P = c.wrapRef.current;
3992
+ const w = c.cameraRef.current, P = c.wrapRef.current;
3985
3993
  if (P) {
3986
- const b = P.getBoundingClientRect(), L = -C.x / C.zoom, Y = -C.y / C.zoom, H = b.width / C.zoom, dt = b.height / C.zoom;
3987
- E.fillStyle = s, E.fillRect(0, 0, t, e);
3988
- const yt = (L - T) * p + y, ft = (Y - k) * p + N, G = H * p, j = dt * p;
3989
- E.clearRect(yt, ft, G, j);
3990
- for (const rt of M) {
3991
- if (rt.hidden) continue;
3992
- const at = rt.width || wn, ct = rt.height || bn, lt = (rt.position.x - T) * p + y, Ct = (rt.position.y - k) * p + N;
3993
- E.fillStyle = rt.selected ? "#f59e0b" : typeof n == "function" ? n(rt) : n, E.fillRect(lt, Ct, Math.max(at * p, 2), Math.max(ct * p, 2));
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;
3995
+ C.fillStyle = s, C.fillRect(0, 0, t, e);
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));
3994
4002
  }
3995
- E.strokeStyle = "#3b82f6", E.lineWidth = 1.5, E.strokeRect(yt, ft, G, j);
4003
+ C.strokeStyle = "#3b82f6", C.lineWidth = 1.5, C.strokeRect(at, rt, G, j);
3996
4004
  }
3997
4005
  }, [c, t, e, n, r, s]);
3998
- return ut(() => {
3999
- let v = !0;
4000
- function E() {
4001
- v && (g(), l.current = requestAnimationFrame(E));
4006
+ return ht(() => {
4007
+ let m = !0;
4008
+ function C() {
4009
+ m && (y(), l.current = requestAnimationFrame(C));
4002
4010
  }
4003
- const R = setInterval(() => {
4004
- cancelAnimationFrame(l.current), l.current = requestAnimationFrame(E);
4011
+ const z = setInterval(() => {
4012
+ cancelAnimationFrame(l.current), l.current = requestAnimationFrame(C);
4005
4013
  }, 66);
4006
- return g(), () => {
4007
- v = !1, clearInterval(R), cancelAnimationFrame(l.current);
4014
+ return y(), () => {
4015
+ m = !1, clearInterval(z), cancelAnimationFrame(l.current);
4008
4016
  };
4009
- }, [g]), /* @__PURE__ */ B(
4017
+ }, [y]), /* @__PURE__ */ S(
4010
4018
  "canvas",
4011
4019
  {
4012
4020
  ref: u,
@@ -4027,31 +4035,31 @@ function Qo({
4027
4035
  );
4028
4036
  }
4029
4037
  function no() {
4030
- 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: [
4031
- /* @__PURE__ */ B("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
4032
- /* @__PURE__ */ B("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
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: [
4039
+ /* @__PURE__ */ S("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
4040
+ /* @__PURE__ */ S("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
4033
4041
  ] });
4034
4042
  }
4035
4043
  function ro() {
4036
- return /* @__PURE__ */ B("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__ */ B("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
4044
+ 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("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
4037
4045
  }
4038
4046
  function oo() {
4039
- return /* @__PURE__ */ B("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__ */ B("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
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" }) });
4040
4048
  }
4041
4049
  function so() {
4042
- 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: [
4043
- /* @__PURE__ */ B("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4044
- /* @__PURE__ */ B("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
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: [
4051
+ /* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4052
+ /* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
4045
4053
  ] });
4046
4054
  }
4047
4055
  function io() {
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: [
4049
- /* @__PURE__ */ B("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4050
- /* @__PURE__ */ B("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
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: [
4057
+ /* @__PURE__ */ S("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
4058
+ /* @__PURE__ */ S("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
4051
4059
  ] });
4052
4060
  }
4053
4061
  function rn({ children: t, className: e = "", ...n }) {
4054
- return /* @__PURE__ */ B(
4062
+ return /* @__PURE__ */ S(
4055
4063
  "button",
4056
4064
  {
4057
4065
  className: `ric-controls-button ${e}`,
@@ -4072,21 +4080,21 @@ function ao({
4072
4080
  onInteractiveChange: c,
4073
4081
  position: u = "bottom-left",
4074
4082
  orientation: l = "vertical",
4075
- style: g = {},
4076
- className: v = "",
4077
- "aria-label": E = "Canvas controls",
4078
- children: R
4083
+ style: y = {},
4084
+ className: m = "",
4085
+ "aria-label": C = "Canvas controls",
4086
+ children: z
4079
4087
  }) {
4080
- const M = ht(), { zoomIn: T, zoomOut: k, fitView: z, getZoom: W } = eo(), [D, x] = Gt(!0), f = W() <= M.zoomMin, p = W() >= M.zoomMax, y = F(() => {
4081
- T(), s == null || s();
4082
- }, [T, s]), N = F(() => {
4088
+ const M = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [D, g] = Gt(!0), f = _() <= M.zoomMin, p = _() >= M.zoomMax, v = F(() => {
4089
+ $(), s == null || s();
4090
+ }, [$, s]), N = F(() => {
4083
4091
  k(), o == null || o();
4084
- }, [k, o]), C = F(() => {
4085
- z(r || { padding: 0.1 }), i == null || i();
4086
- }, [z, r, i]), P = F(() => {
4087
- const L = !D;
4088
- x(L), c == null || c(L);
4089
- }, [D, c]), b = {
4092
+ }, [k, o]), w = F(() => {
4093
+ E(r || { padding: 0.1 }), i == null || i();
4094
+ }, [E, r, i]), P = F(() => {
4095
+ const B = !D;
4096
+ g(B), c == null || c(B);
4097
+ }, [D, c]), R = {
4090
4098
  "top-left": { top: 10, left: 10 },
4091
4099
  "top-right": { top: 10, right: 10 },
4092
4100
  "top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
@@ -4094,35 +4102,35 @@ function ao({
4094
4102
  "bottom-right": { bottom: 30, right: 10 },
4095
4103
  "bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
4096
4104
  }[u] || { bottom: 30, left: 10 };
4097
- return /* @__PURE__ */ It(
4105
+ return /* @__PURE__ */ $t(
4098
4106
  "div",
4099
4107
  {
4100
- className: `ric-controls ${v}`,
4108
+ className: `ric-controls ${m}`,
4101
4109
  style: {
4102
4110
  position: "absolute",
4103
4111
  display: "flex",
4104
4112
  flexDirection: l === "horizontal" ? "row" : "column",
4105
4113
  gap: 2,
4106
4114
  zIndex: 5,
4107
- ...b,
4108
- ...g
4115
+ ...R,
4116
+ ...y
4109
4117
  },
4110
4118
  role: "toolbar",
4111
- "aria-label": E,
4119
+ "aria-label": C,
4112
4120
  children: [
4113
- t && /* @__PURE__ */ It(Le, { children: [
4114
- /* @__PURE__ */ B(
4121
+ t && /* @__PURE__ */ $t(Le, { children: [
4122
+ /* @__PURE__ */ S(
4115
4123
  rn,
4116
4124
  {
4117
- onClick: y,
4125
+ onClick: v,
4118
4126
  disabled: p,
4119
4127
  title: "Zoom in",
4120
4128
  "aria-label": "Zoom in",
4121
4129
  className: "ric-controls-zoomin",
4122
- children: /* @__PURE__ */ B(no, {})
4130
+ children: /* @__PURE__ */ S(no, {})
4123
4131
  }
4124
4132
  ),
4125
- /* @__PURE__ */ B(
4133
+ /* @__PURE__ */ S(
4126
4134
  rn,
4127
4135
  {
4128
4136
  onClick: N,
@@ -4130,31 +4138,31 @@ function ao({
4130
4138
  title: "Zoom out",
4131
4139
  "aria-label": "Zoom out",
4132
4140
  className: "ric-controls-zoomout",
4133
- children: /* @__PURE__ */ B(ro, {})
4141
+ children: /* @__PURE__ */ S(ro, {})
4134
4142
  }
4135
4143
  )
4136
4144
  ] }),
4137
- e && /* @__PURE__ */ B(
4145
+ e && /* @__PURE__ */ S(
4138
4146
  rn,
4139
4147
  {
4140
- onClick: C,
4148
+ onClick: w,
4141
4149
  title: "Fit view",
4142
4150
  "aria-label": "Fit view",
4143
4151
  className: "ric-controls-fitview",
4144
- children: /* @__PURE__ */ B(oo, {})
4152
+ children: /* @__PURE__ */ S(oo, {})
4145
4153
  }
4146
4154
  ),
4147
- n && /* @__PURE__ */ B(
4155
+ n && /* @__PURE__ */ S(
4148
4156
  rn,
4149
4157
  {
4150
4158
  onClick: P,
4151
4159
  title: D ? "Lock interactivity" : "Unlock interactivity",
4152
4160
  "aria-label": D ? "Lock interactivity" : "Unlock interactivity",
4153
4161
  className: "ric-controls-interactive",
4154
- children: D ? /* @__PURE__ */ B(io, {}) : /* @__PURE__ */ B(so, {})
4162
+ children: D ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
4155
4163
  }
4156
4164
  ),
4157
- R
4165
+ z
4158
4166
  ]
4159
4167
  }
4160
4168
  );
@@ -4182,7 +4190,7 @@ function Jo({
4182
4190
  style: s = {},
4183
4191
  className: o = ""
4184
4192
  }) {
4185
- const i = ht();
4193
+ const i = yt();
4186
4194
  return i.workerRef.current && i.workerRef.current.postMessage({
4187
4195
  type: "background",
4188
4196
  data: { variant: t, gap: e, size: n, color: r }
@@ -4202,7 +4210,7 @@ function Vo({
4202
4210
  "bottom-right": { bottom: 10, right: 10 },
4203
4211
  "bottom-center": { bottom: 10, left: "50%", transform: "translateX(-50%)" }
4204
4212
  }[t] || { top: 10, left: 10 };
4205
- return /* @__PURE__ */ B(
4213
+ return /* @__PURE__ */ S(
4206
4214
  "div",
4207
4215
  {
4208
4216
  className: `ric-panel ${n}`,
@@ -4229,98 +4237,98 @@ function ts({
4229
4237
  color: c = "#3b82f6",
4230
4238
  onResizeStart: u,
4231
4239
  onResize: l,
4232
- onResizeEnd: g
4240
+ onResizeEnd: y
4233
4241
  }) {
4234
- const v = qe(je), E = ht(), R = V(null), M = F((z, W) => {
4235
- z.stopPropagation(), z.preventDefault();
4236
- const D = E.nodesRef.current.find((p) => p.id === v);
4242
+ const m = qe(je), C = yt(), z = tt(null), M = F((E, _) => {
4243
+ E.stopPropagation(), E.preventDefault();
4244
+ const D = C.nodesRef.current.find((p) => p.id === m);
4237
4245
  if (!D) return;
4238
- R.current = {
4239
- direction: W,
4240
- startX: z.clientX,
4241
- startY: z.clientY,
4246
+ z.current = {
4247
+ direction: _,
4248
+ startX: E.clientX,
4249
+ startY: E.clientY,
4242
4250
  width: D.width || 160,
4243
4251
  height: D.height || 60
4244
- }, u == null || u(z, { width: R.current.width, height: R.current.height });
4245
- const x = (p) => {
4246
- var Y, H;
4247
- if (!R.current) return;
4248
- const y = R.current, N = E.cameraRef.current, C = (p.clientX - y.startX) / N.zoom, P = (p.clientY - y.startY) / N.zoom;
4249
- let b = y.width, L = y.height;
4250
- y.direction.includes("e") && (b = Math.min(n, Math.max(t, y.width + C))), y.direction.includes("w") && (b = Math.min(n, Math.max(t, y.width - C))), y.direction.includes("s") && (L = Math.min(r, Math.max(e, y.height + P))), y.direction.includes("n") && (L = Math.min(r, Math.max(e, y.height - P))), (H = (Y = E.onNodesChangeRef).current) == null || H.call(Y, [
4251
- { id: v, type: "dimensions", dimensions: { width: b, height: L }, setAttributes: !0 }
4252
- ]), l == null || l(p, { width: b, height: L });
4252
+ }, u == null || u(E, { width: z.current.width, height: z.current.height });
4253
+ const g = (p) => {
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;
4257
+ let R = v.width, B = v.height;
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, [
4259
+ { id: m, type: "dimensions", dimensions: { width: R, height: B }, setAttributes: !0 }
4260
+ ]), l == null || l(p, { width: R, height: B });
4253
4261
  }, f = (p) => {
4254
- R.current = null, g == null || g(p, {}), window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", f);
4262
+ z.current = null, y == null || y(p, {}), window.removeEventListener("pointermove", g), window.removeEventListener("pointerup", f);
4255
4263
  };
4256
- window.addEventListener("pointermove", x), window.addEventListener("pointerup", f);
4257
- }, [v, E, t, e, n, r, u, l, g]);
4264
+ window.addEventListener("pointermove", g), window.addEventListener("pointerup", f);
4265
+ }, [m, C, t, e, n, r, u, l, y]);
4258
4266
  if (!s) return null;
4259
- const T = 8, k = {
4267
+ const $ = 8, k = {
4260
4268
  position: "absolute",
4261
- width: T,
4262
- height: T,
4269
+ width: $,
4270
+ height: $,
4263
4271
  background: c,
4264
4272
  border: "1px solid #fff",
4265
4273
  borderRadius: 2,
4266
4274
  zIndex: 20,
4267
4275
  ...o
4268
4276
  };
4269
- return /* @__PURE__ */ It(Le, { children: [
4270
- /* @__PURE__ */ B(
4277
+ return /* @__PURE__ */ $t(Le, { children: [
4278
+ /* @__PURE__ */ S(
4271
4279
  "div",
4272
4280
  {
4273
- style: { ...k, bottom: -T / 2, right: -T / 2, cursor: "nwse-resize" },
4274
- onPointerDown: (z) => M(z, "se")
4281
+ style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
4282
+ onPointerDown: (E) => M(E, "se")
4275
4283
  }
4276
4284
  ),
4277
- /* @__PURE__ */ B(
4285
+ /* @__PURE__ */ S(
4278
4286
  "div",
4279
4287
  {
4280
- style: { ...k, bottom: -T / 2, left: -T / 2, cursor: "nesw-resize" },
4281
- onPointerDown: (z) => M(z, "sw")
4288
+ style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
4289
+ onPointerDown: (E) => M(E, "sw")
4282
4290
  }
4283
4291
  ),
4284
- /* @__PURE__ */ B(
4292
+ /* @__PURE__ */ S(
4285
4293
  "div",
4286
4294
  {
4287
- style: { ...k, top: -T / 2, right: -T / 2, cursor: "nesw-resize" },
4288
- onPointerDown: (z) => M(z, "ne")
4295
+ style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
4296
+ onPointerDown: (E) => M(E, "ne")
4289
4297
  }
4290
4298
  ),
4291
- /* @__PURE__ */ B(
4299
+ /* @__PURE__ */ S(
4292
4300
  "div",
4293
4301
  {
4294
- style: { ...k, top: -T / 2, left: -T / 2, cursor: "nwse-resize" },
4295
- onPointerDown: (z) => M(z, "nw")
4302
+ style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
4303
+ onPointerDown: (E) => M(E, "nw")
4296
4304
  }
4297
4305
  ),
4298
- /* @__PURE__ */ B(
4306
+ /* @__PURE__ */ S(
4299
4307
  "div",
4300
4308
  {
4301
- style: { ...k, top: "50%", right: -T / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4302
- onPointerDown: (z) => M(z, "e")
4309
+ style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4310
+ onPointerDown: (E) => M(E, "e")
4303
4311
  }
4304
4312
  ),
4305
- /* @__PURE__ */ B(
4313
+ /* @__PURE__ */ S(
4306
4314
  "div",
4307
4315
  {
4308
- style: { ...k, top: "50%", left: -T / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4309
- onPointerDown: (z) => M(z, "w")
4316
+ style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
4317
+ onPointerDown: (E) => M(E, "w")
4310
4318
  }
4311
4319
  ),
4312
- /* @__PURE__ */ B(
4320
+ /* @__PURE__ */ S(
4313
4321
  "div",
4314
4322
  {
4315
- style: { ...k, left: "50%", top: -T / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4316
- onPointerDown: (z) => M(z, "n")
4323
+ style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4324
+ onPointerDown: (E) => M(E, "n")
4317
4325
  }
4318
4326
  ),
4319
- /* @__PURE__ */ B(
4327
+ /* @__PURE__ */ S(
4320
4328
  "div",
4321
4329
  {
4322
- style: { ...k, left: "50%", bottom: -T / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4323
- onPointerDown: (z) => M(z, "s")
4330
+ style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
4331
+ onPointerDown: (E) => M(E, "s")
4324
4332
  }
4325
4333
  )
4326
4334
  ] });
@@ -4334,15 +4342,15 @@ function es({
4334
4342
  style: o = {},
4335
4343
  className: i = ""
4336
4344
  }) {
4337
- const c = qe(je), l = ht().nodes.find((E) => E.id === c);
4345
+ const c = qe(je), l = yt().nodes.find((C) => C.id === c);
4338
4346
  if (!(t !== void 0 ? t : l == null ? void 0 : l.selected)) return null;
4339
- const v = {
4347
+ const m = {
4340
4348
  top: { bottom: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginBottom: n },
4341
4349
  bottom: { top: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginTop: n },
4342
4350
  left: { right: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginRight: n },
4343
4351
  right: { left: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginLeft: n }
4344
4352
  }[e] || {};
4345
- return /* @__PURE__ */ B(
4353
+ return /* @__PURE__ */ S(
4346
4354
  "div",
4347
4355
  {
4348
4356
  className: `ric-node-toolbar ${i}`,
@@ -4350,10 +4358,10 @@ function es({
4350
4358
  position: "absolute",
4351
4359
  zIndex: 1e3,
4352
4360
  pointerEvents: "all",
4353
- ...v,
4361
+ ...m,
4354
4362
  ...o
4355
4363
  },
4356
- onPointerDown: (E) => E.stopPropagation(),
4364
+ onPointerDown: (C) => C.stopPropagation(),
4357
4365
  children: s
4358
4366
  }
4359
4367
  );
@@ -4370,7 +4378,7 @@ function ns({
4370
4378
  }) {
4371
4379
  if (!t) return null;
4372
4380
  const u = r === "center" ? "-50%" : r === "right" ? "-100%" : "0", l = s === "center" ? "-50%" : s === "bottom" ? "-100%" : "0";
4373
- return /* @__PURE__ */ B(
4381
+ return /* @__PURE__ */ S(
4374
4382
  "div",
4375
4383
  {
4376
4384
  className: `ric-edge-toolbar ${c}`,
@@ -4389,12 +4397,12 @@ function ns({
4389
4397
  }
4390
4398
  function rs({ children: t }) {
4391
4399
  var r;
4392
- const n = (r = ht().edgeLabelContainerRef) == null ? void 0 : r.current;
4400
+ const n = (r = yt().edgeLabelContainerRef) == null ? void 0 : r.current;
4393
4401
  return n ? Yn(t, n) : null;
4394
4402
  }
4395
4403
  function os({ children: t }) {
4396
4404
  var r;
4397
- const n = (r = ht().viewportPortalRef) == null ? void 0 : r.current;
4405
+ const n = (r = yt().viewportPortalRef) == null ? void 0 : r.current;
4398
4406
  return n ? Yn(t, n) : null;
4399
4407
  }
4400
4408
  function ur({
@@ -4409,7 +4417,7 @@ function ur({
4409
4417
  connectionLineComponent: u
4410
4418
  }) {
4411
4419
  if (u)
4412
- return /* @__PURE__ */ B(
4420
+ return /* @__PURE__ */ S(
4413
4421
  u,
4414
4422
  {
4415
4423
  fromX: t,
@@ -4460,7 +4468,7 @@ function ur({
4460
4468
  });
4461
4469
  break;
4462
4470
  }
4463
- return /* @__PURE__ */ B(
4471
+ return /* @__PURE__ */ S(
4464
4472
  "path",
4465
4473
  {
4466
4474
  d: l,
@@ -4509,7 +4517,7 @@ export {
4509
4517
  Wr as OutputNode,
4510
4518
  Vo as Panel,
4511
4519
  is as Position,
4512
- Hr as SelectionBox,
4520
+ Ar as SelectionBox,
4513
4521
  cr as SimpleBezierEdge,
4514
4522
  ar as SmoothStepEdge,
4515
4523
  Or as StepEdge,
@@ -4547,7 +4555,7 @@ export {
4547
4555
  Lo as routeSinglePath,
4548
4556
  En as routedPointsToPath,
4549
4557
  Pn as snapPosition,
4550
- Ao as useConnection,
4558
+ Ho as useConnection,
4551
4559
  Do as useEdges,
4552
4560
  So as useEdgesState,
4553
4561
  Xo as useHandleConnections,
@@ -4566,5 +4574,5 @@ export {
4566
4574
  Zo as useStore,
4567
4575
  Oo as useStoreApi,
4568
4576
  qo as useUpdateNodeInternals,
4569
- Ho as useViewport
4577
+ Ao as useViewport
4570
4578
  };