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