@infinit-canvas/react 0.1.6 → 0.1.8
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 +870 -865
- package/dist/styles.css +25 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as S, jsxs as $t, Fragment as
|
|
1
|
+
import { jsx as S, jsxs as $t, Fragment as Le } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as tt, 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;
|
|
@@ -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: g } = jn(u), v = u.position.x, N = u.position.y, z = v + l, R = N + g;
|
|
67
|
+
return r ? v < i && z > s && N < c && R > o : v >= s && z <= i && N >= o && R <= c;
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
function mo(t) {
|
|
@@ -949,8 +949,8 @@ function Cr(t, e) {
|
|
|
949
949
|
const s = { worker: r };
|
|
950
950
|
return mn.set(t, s), s;
|
|
951
951
|
}
|
|
952
|
-
const Vt = 160, jt = 60,
|
|
953
|
-
function
|
|
952
|
+
const Vt = 160, jt = 60, Nr = 10;
|
|
953
|
+
function Lr({
|
|
954
954
|
cards: t = [],
|
|
955
955
|
nodes: e = [],
|
|
956
956
|
edges: n = [],
|
|
@@ -961,27 +961,27 @@ function Nr({
|
|
|
961
961
|
onConnect: c,
|
|
962
962
|
onNodeClick: u,
|
|
963
963
|
onNodeDragStart: l,
|
|
964
|
-
onNodeDrag:
|
|
965
|
-
onNodeDragStop:
|
|
966
|
-
onEdgeClick:
|
|
964
|
+
onNodeDrag: g,
|
|
965
|
+
onNodeDragStop: v,
|
|
966
|
+
onEdgeClick: N,
|
|
967
967
|
onEdgeDoubleClick: z,
|
|
968
|
-
onEdgeMouseEnter:
|
|
968
|
+
onEdgeMouseEnter: R,
|
|
969
969
|
onEdgeMouseMove: $,
|
|
970
|
-
onEdgeMouseLeave:
|
|
970
|
+
onEdgeMouseLeave: k,
|
|
971
971
|
onEdgeContextMenu: E,
|
|
972
972
|
onNodeDoubleClick: _,
|
|
973
|
-
onNodeMouseEnter:
|
|
974
|
-
onNodeMouseMove:
|
|
973
|
+
onNodeMouseEnter: B,
|
|
974
|
+
onNodeMouseMove: D,
|
|
975
975
|
onNodeMouseLeave: f,
|
|
976
|
-
onNodeContextMenu:
|
|
977
|
-
onPaneClick:
|
|
978
|
-
onPaneContextMenu:
|
|
976
|
+
onNodeContextMenu: h,
|
|
977
|
+
onPaneClick: p,
|
|
978
|
+
onPaneContextMenu: M,
|
|
979
979
|
onPaneMouseEnter: w,
|
|
980
|
-
onPaneMouseMove:
|
|
981
|
-
onPaneMouseLeave:
|
|
982
|
-
onSelectionChange:
|
|
980
|
+
onPaneMouseMove: C,
|
|
981
|
+
onPaneMouseLeave: x,
|
|
982
|
+
onSelectionChange: T,
|
|
983
983
|
onConnectStart: j,
|
|
984
|
-
onConnectEnd:
|
|
984
|
+
onConnectEnd: W,
|
|
985
985
|
onInit: xt,
|
|
986
986
|
onMoveStart: K,
|
|
987
987
|
onMove: rt,
|
|
@@ -994,12 +994,12 @@ function Nr({
|
|
|
994
994
|
gridSize: It = 40,
|
|
995
995
|
zoomMin: it = 0.1,
|
|
996
996
|
zoomMax: mt = 4,
|
|
997
|
-
initialCamera:
|
|
997
|
+
initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
|
|
998
998
|
fitView: zt = !1,
|
|
999
999
|
fitViewOptions: dt,
|
|
1000
1000
|
nodesDraggable: ht = !0,
|
|
1001
1001
|
nodesConnectable: Rt = !0,
|
|
1002
|
-
elementsSelectable:
|
|
1002
|
+
elementsSelectable: Lt = !0,
|
|
1003
1003
|
multiSelectionKeyCode: gt = "Shift",
|
|
1004
1004
|
selectionOnDrag: ne = !1,
|
|
1005
1005
|
selectionMode: Ie = "partial",
|
|
@@ -1023,11 +1023,11 @@ function Nr({
|
|
|
1023
1023
|
autoPanOnNodeDrag: dn = !0,
|
|
1024
1024
|
autoPanOnConnect: fn = !0,
|
|
1025
1025
|
autoPanSpeed: Qt = 5,
|
|
1026
|
-
edgesReconnectable:
|
|
1026
|
+
edgesReconnectable: Nn = !1,
|
|
1027
1027
|
elevateNodesOnSelect: hn = !1,
|
|
1028
1028
|
edgeRouting: fe = !0
|
|
1029
1029
|
} = {}) {
|
|
1030
|
-
const vt = tt(null), Te = tt(null), Et = tt(null), pt = tt({ ...
|
|
1030
|
+
const vt = tt(null), Te = tt(null), Et = tt(null), pt = tt({ ...Nt }), se = tt([...t]), Z = tt([...e]), Pt = tt([...n]), yn = tt(/* @__PURE__ */ new Map()), Se = tt(!1), te = tt(null), [gn, pn] = Gt(!1), _t = tt(null), Wt = tt(null), Me = tt(null), ie = tt(null), Ut = tt(!1), Re = tt(null), [Be, Je] = Gt({ x: Nt.x, y: Nt.y, zoom: Nt.zoom }), [Ve, ae] = Gt(null), Kt = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = tt(!1), O = tt({});
|
|
1031
1031
|
O.current = {
|
|
1032
1032
|
onHudUpdate: r,
|
|
1033
1033
|
onNodesProcessed: s,
|
|
@@ -1036,27 +1036,27 @@ function Nr({
|
|
|
1036
1036
|
onConnect: c,
|
|
1037
1037
|
onNodeClick: u,
|
|
1038
1038
|
onNodeDragStart: l,
|
|
1039
|
-
onNodeDrag:
|
|
1040
|
-
onNodeDragStop:
|
|
1041
|
-
onEdgeClick:
|
|
1039
|
+
onNodeDrag: g,
|
|
1040
|
+
onNodeDragStop: v,
|
|
1041
|
+
onEdgeClick: N,
|
|
1042
1042
|
onEdgeDoubleClick: z,
|
|
1043
|
-
onEdgeMouseEnter:
|
|
1043
|
+
onEdgeMouseEnter: R,
|
|
1044
1044
|
onEdgeMouseMove: $,
|
|
1045
|
-
onEdgeMouseLeave:
|
|
1045
|
+
onEdgeMouseLeave: k,
|
|
1046
1046
|
onEdgeContextMenu: E,
|
|
1047
1047
|
onNodeDoubleClick: _,
|
|
1048
|
-
onNodeMouseEnter:
|
|
1049
|
-
onNodeMouseMove:
|
|
1048
|
+
onNodeMouseEnter: B,
|
|
1049
|
+
onNodeMouseMove: D,
|
|
1050
1050
|
onNodeMouseLeave: f,
|
|
1051
|
-
onNodeContextMenu:
|
|
1052
|
-
onPaneClick:
|
|
1053
|
-
onPaneContextMenu:
|
|
1051
|
+
onNodeContextMenu: h,
|
|
1052
|
+
onPaneClick: p,
|
|
1053
|
+
onPaneContextMenu: M,
|
|
1054
1054
|
onPaneMouseEnter: w,
|
|
1055
|
-
onPaneMouseMove:
|
|
1056
|
-
onPaneMouseLeave:
|
|
1057
|
-
onSelectionChange:
|
|
1055
|
+
onPaneMouseMove: C,
|
|
1056
|
+
onPaneMouseLeave: x,
|
|
1057
|
+
onSelectionChange: T,
|
|
1058
1058
|
onConnectStart: j,
|
|
1059
|
-
onConnectEnd:
|
|
1059
|
+
onConnectEnd: W,
|
|
1060
1060
|
onInit: xt,
|
|
1061
1061
|
onMoveStart: K,
|
|
1062
1062
|
onMove: rt,
|
|
@@ -1094,88 +1094,88 @@ function Nr({
|
|
|
1094
1094
|
ft(() => {
|
|
1095
1095
|
const a = (d) => {
|
|
1096
1096
|
d.key === gt && (Ut.current = !0), d.key === we && (ke.current = !0);
|
|
1097
|
-
},
|
|
1097
|
+
}, m = (d) => {
|
|
1098
1098
|
d.key === gt && (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", m), () => {
|
|
1101
|
+
window.removeEventListener("keydown", a), window.removeEventListener("keyup", m);
|
|
1102
1102
|
};
|
|
1103
1103
|
}, [gt, we]);
|
|
1104
1104
|
const Jt = F(() => {
|
|
1105
1105
|
var b;
|
|
1106
|
-
const a = Z.current.filter((
|
|
1106
|
+
const a = Z.current.filter((L) => L.selected), m = Pt.current.filter((L) => L.selected), d = { nodes: a, edges: m };
|
|
1107
1107
|
(b = ye.current) == null || b.call(ye, d);
|
|
1108
|
-
for (const
|
|
1108
|
+
for (const L of he) L(d);
|
|
1109
1109
|
}, [he]);
|
|
1110
1110
|
ft(() => {
|
|
1111
1111
|
var a;
|
|
1112
1112
|
se.current = [...t], (a = Et.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
|
|
1113
1113
|
}, [t]);
|
|
1114
1114
|
const ze = F((a) => {
|
|
1115
|
-
const
|
|
1116
|
-
for (const d of a)
|
|
1115
|
+
const m = {};
|
|
1116
|
+
for (const d of a) m[d.id] = d;
|
|
1117
1117
|
return a.map((d) => {
|
|
1118
1118
|
if (!d.parentId) return d;
|
|
1119
|
-
const b =
|
|
1119
|
+
const b = m[d.parentId];
|
|
1120
1120
|
if (!b) return d;
|
|
1121
|
-
let
|
|
1122
|
-
for (;
|
|
1123
|
-
|
|
1124
|
-
return { ...d, _absolutePosition: { x:
|
|
1121
|
+
let L = d.position.x, I = d.position.y, y = b;
|
|
1122
|
+
for (; y; )
|
|
1123
|
+
L += y.position.x, I += y.position.y, y = y.parentId ? m[y.parentId] : null;
|
|
1124
|
+
return { ...d, _absolutePosition: { x: L, y: I } };
|
|
1125
1125
|
});
|
|
1126
1126
|
}, []), ee = tt([]), Q = F((a) => {
|
|
1127
|
-
const
|
|
1128
|
-
if (!
|
|
1127
|
+
const m = yn.current;
|
|
1128
|
+
if (!m || m.size === 0) return a;
|
|
1129
1129
|
const d = {};
|
|
1130
|
-
for (const [, b] of
|
|
1130
|
+
for (const [, b] of m)
|
|
1131
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
1132
|
return a.map((b) => {
|
|
1133
|
-
const
|
|
1134
|
-
return
|
|
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 m;
|
|
1138
1138
|
if (_t.current) return;
|
|
1139
1139
|
const a = Q(ee.current);
|
|
1140
|
-
(
|
|
1140
|
+
(m = Et.current) == null || m.postMessage({ type: "nodes", data: { nodes: a } });
|
|
1141
1141
|
}, [Q]);
|
|
1142
1142
|
ft(() => {
|
|
1143
1143
|
var d;
|
|
1144
1144
|
if (_t.current) {
|
|
1145
|
-
const b = _t.current.id,
|
|
1146
|
-
for (const
|
|
1147
|
-
|
|
1145
|
+
const b = _t.current.id, L = /* @__PURE__ */ new Set([b, ..._t.current.selectedStarts.map((y) => y.id)]), I = {};
|
|
1146
|
+
for (const y of Z.current)
|
|
1147
|
+
L.has(y.id) && (I[y.id] = { ...y.position });
|
|
1148
1148
|
Z.current = [...e];
|
|
1149
|
-
for (const
|
|
1150
|
-
I[
|
|
1149
|
+
for (const y of Z.current)
|
|
1150
|
+
I[y.id] && (y.position = I[y.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 = Et.current) == null || d.postMessage({ type: "nodes", data: { nodes:
|
|
1157
|
+
const m = Q(a);
|
|
1158
|
+
(d = Et.current) == null || d.postMessage({ type: "nodes", data: { nodes: m } });
|
|
1159
1159
|
}, [e, ze, Q]), ft(() => {
|
|
1160
1160
|
var a;
|
|
1161
1161
|
Pt.current = [...n], (a = Et.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
|
|
1162
1162
|
}, [n]);
|
|
1163
|
-
const at = F((a,
|
|
1163
|
+
const at = F((a, m) => {
|
|
1164
1164
|
const d = vt.current;
|
|
1165
1165
|
if (!d) return { x: 0, y: 0 };
|
|
1166
|
-
const b = d.getBoundingClientRect(),
|
|
1166
|
+
const b = d.getBoundingClientRect(), L = pt.current;
|
|
1167
1167
|
return {
|
|
1168
|
-
x: (a - b.left -
|
|
1169
|
-
y: (
|
|
1168
|
+
x: (a - b.left - L.x) / L.zoom,
|
|
1169
|
+
y: (m - b.top - L.y) / L.zoom
|
|
1170
1170
|
};
|
|
1171
|
-
}, []), Tt = F((a,
|
|
1171
|
+
}, []), Tt = F((a, m) => {
|
|
1172
1172
|
const d = ee.current.length > 0 ? ee.current : Z.current;
|
|
1173
1173
|
let b = null;
|
|
1174
|
-
for (let
|
|
1175
|
-
const I = d[
|
|
1174
|
+
for (let L = d.length - 1; L >= 0; L--) {
|
|
1175
|
+
const I = d[L];
|
|
1176
1176
|
if (I.hidden) continue;
|
|
1177
|
-
const
|
|
1178
|
-
if (a >=
|
|
1177
|
+
const y = I._absolutePosition || I.position, A = I.width || Vt, P = I.height || jt;
|
|
1178
|
+
if (a >= y.x && a <= y.x + A && m >= y.y && m <= y.y + P) {
|
|
1179
1179
|
if (I.type === "group") {
|
|
1180
1180
|
b || (b = I);
|
|
1181
1181
|
continue;
|
|
@@ -1184,58 +1184,58 @@ function Nr({
|
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
1186
|
return b;
|
|
1187
|
-
}, []), xe = F((a,
|
|
1188
|
-
const d =
|
|
1187
|
+
}, []), xe = F((a, m) => {
|
|
1188
|
+
const d = m.width || Vt, b = m.height || jt;
|
|
1189
1189
|
if (a.x !== void 0 && a.y !== void 0)
|
|
1190
|
-
return { x:
|
|
1190
|
+
return { x: m.position.x + a.x, y: m.position.y + a.y };
|
|
1191
1191
|
switch (a.position || (a.type === "source" ? "right" : "left")) {
|
|
1192
1192
|
case "top":
|
|
1193
|
-
return { x:
|
|
1193
|
+
return { x: m.position.x + d / 2, y: m.position.y };
|
|
1194
1194
|
case "bottom":
|
|
1195
|
-
return { x:
|
|
1195
|
+
return { x: m.position.x + d / 2, y: m.position.y + b };
|
|
1196
1196
|
case "left":
|
|
1197
|
-
return { x:
|
|
1197
|
+
return { x: m.position.x, y: m.position.y + b / 2 };
|
|
1198
1198
|
case "right":
|
|
1199
|
-
return { x:
|
|
1199
|
+
return { x: m.position.x + d, y: m.position.y + b / 2 };
|
|
1200
1200
|
default:
|
|
1201
|
-
return { x:
|
|
1201
|
+
return { x: m.position.x + d, y: m.position.y + b / 2 };
|
|
1202
1202
|
}
|
|
1203
1203
|
}, []), Ee = F((a) => {
|
|
1204
|
-
const
|
|
1204
|
+
const m = a.width || Vt, d = a.height || jt;
|
|
1205
1205
|
return a.handles && a.handles.length > 0 ? a.handles.map((b) => {
|
|
1206
|
-
const
|
|
1207
|
-
return { id: b.id || null, type: b.type, x:
|
|
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 + m, y: a.position.y + d / 2 }
|
|
1211
1211
|
];
|
|
1212
|
-
}, [xe]), tn = F((a,
|
|
1213
|
-
const d = Z.current, b = pt.current,
|
|
1212
|
+
}, [xe]), tn = F((a, m) => {
|
|
1213
|
+
const d = Z.current, b = pt.current, L = Math.max(Nr, Ot) / b.zoom;
|
|
1214
1214
|
for (let I = d.length - 1; I >= 0; I--) {
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1217
|
-
const A = Ee(
|
|
1218
|
-
for (const
|
|
1219
|
-
if (Math.abs(a -
|
|
1220
|
-
return { nodeId:
|
|
1215
|
+
const y = d[I];
|
|
1216
|
+
if (y.hidden) continue;
|
|
1217
|
+
const A = Ee(y);
|
|
1218
|
+
for (const P of A)
|
|
1219
|
+
if (Math.abs(a - P.x) < L && Math.abs(m - P.y) < L)
|
|
1220
|
+
return { nodeId: y.id, handleId: P.id, type: P.type, x: P.x, y: P.y };
|
|
1221
1221
|
}
|
|
1222
1222
|
return null;
|
|
1223
|
-
}, [Ee]), ue = F((a,
|
|
1223
|
+
}, [Ee]), ue = F((a, m) => {
|
|
1224
1224
|
const b = 8 / pt.current.zoom;
|
|
1225
|
-
for (let
|
|
1226
|
-
const I = Pt.current[
|
|
1227
|
-
if (!
|
|
1228
|
-
const
|
|
1229
|
-
if (Ir(a,
|
|
1225
|
+
for (let L = Pt.current.length - 1; L >= 0; L--) {
|
|
1226
|
+
const I = Pt.current[L], y = Z.current.find((Mt) => Mt.id === I.source), A = Z.current.find((Mt) => Mt.id === I.target);
|
|
1227
|
+
if (!y || !A) continue;
|
|
1228
|
+
const P = y.width || Vt, Y = y.height || jt, H = A.height || jt, J = y.position.x + P, ct = y.position.y + Y / 2, U = A.position.x, nt = A.position.y + H / 2;
|
|
1229
|
+
if (Ir(a, m, J, ct, U, nt) < b) return I;
|
|
1230
1230
|
}
|
|
1231
1231
|
return null;
|
|
1232
1232
|
}, []);
|
|
1233
1233
|
ft(() => {
|
|
1234
|
-
const a = Te.current,
|
|
1235
|
-
if (!a || !
|
|
1236
|
-
const d =
|
|
1237
|
-
ee.current =
|
|
1238
|
-
const I = Q(
|
|
1234
|
+
const a = Te.current, m = vt.current;
|
|
1235
|
+
if (!a || !m) return;
|
|
1236
|
+
const d = m.getBoundingClientRect(), b = st !== void 0 ? st : matchMedia("(prefers-color-scheme: dark)").matches, L = ze(Z.current);
|
|
1237
|
+
ee.current = L;
|
|
1238
|
+
const I = Q(L), { worker: y } = Cr(a, {
|
|
1239
1239
|
width: d.width,
|
|
1240
1240
|
height: d.height,
|
|
1241
1241
|
camera: pt.current,
|
|
@@ -1246,18 +1246,18 @@ function Nr({
|
|
|
1246
1246
|
gridSize: It,
|
|
1247
1247
|
edgeRouting: fe
|
|
1248
1248
|
});
|
|
1249
|
-
|
|
1249
|
+
y.onmessage = (H) => {
|
|
1250
1250
|
var J, ct;
|
|
1251
1251
|
H.data.type === "hud" && ((J = ge.current) == null || J.call(ge, H.data.data)), H.data.type === "ready" && pn(!0), H.data.type === "nodesProcessed" && ((ct = pe.current) == null || ct.call(pe, H.data.data));
|
|
1252
|
-
}, Et.current =
|
|
1252
|
+
}, Et.current = y;
|
|
1253
1253
|
const A = new ResizeObserver((H) => {
|
|
1254
1254
|
const { width: J, height: ct } = H[0].contentRect;
|
|
1255
|
-
|
|
1255
|
+
y.postMessage({ type: "resize", data: { width: J, height: ct } });
|
|
1256
1256
|
});
|
|
1257
|
-
A.observe(
|
|
1258
|
-
let
|
|
1259
|
-
return st === void 0 && (
|
|
1260
|
-
A.disconnect(),
|
|
1257
|
+
A.observe(m);
|
|
1258
|
+
let P, Y;
|
|
1259
|
+
return st === void 0 && (P = matchMedia("(prefers-color-scheme: dark)"), Y = (H) => y.postMessage({ type: "theme", data: { dark: H.matches } }), P.addEventListener("change", Y)), () => {
|
|
1260
|
+
A.disconnect(), P && Y && P.removeEventListener("change", Y), Et.current = null;
|
|
1261
1261
|
};
|
|
1262
1262
|
}, []), ft(() => {
|
|
1263
1263
|
var a;
|
|
@@ -1266,69 +1266,69 @@ function Nr({
|
|
|
1266
1266
|
var a;
|
|
1267
1267
|
(a = Et.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
|
|
1268
1268
|
}, [fe]);
|
|
1269
|
-
const
|
|
1270
|
-
var b,
|
|
1271
|
-
const
|
|
1269
|
+
const Ln = tt(0), Ct = F((a = null) => {
|
|
1270
|
+
var b, L, I;
|
|
1271
|
+
const m = pt.current;
|
|
1272
1272
|
if (re) {
|
|
1273
|
-
const
|
|
1274
|
-
if (
|
|
1275
|
-
const A =
|
|
1276
|
-
|
|
1273
|
+
const y = vt.current;
|
|
1274
|
+
if (y) {
|
|
1275
|
+
const A = y.getBoundingClientRect(), P = -re[1][0] * m.zoom + A.width, Y = -re[1][1] * m.zoom + A.height, H = -re[0][0] * m.zoom, J = -re[0][1] * m.zoom;
|
|
1276
|
+
m.x = Math.min(H, Math.max(P, m.x)), m.y = Math.min(J, Math.max(Y, m.y));
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
|
-
(b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...
|
|
1280
|
-
const d = { x:
|
|
1281
|
-
(I = (
|
|
1282
|
-
for (const
|
|
1283
|
-
cancelAnimationFrame(
|
|
1284
|
-
Je({ x:
|
|
1279
|
+
(b = Et.current) == null || b.postMessage({ type: "camera", data: { camera: { ...m } } });
|
|
1280
|
+
const d = { x: m.x, y: m.y, zoom: m.zoom };
|
|
1281
|
+
(I = (L = O.current).onMove) == null || I.call(L, a, d);
|
|
1282
|
+
for (const y of Kt) y(d);
|
|
1283
|
+
cancelAnimationFrame(Ln.current), Ln.current = requestAnimationFrame(() => {
|
|
1284
|
+
Je({ x: m.x, y: m.y, zoom: m.zoom });
|
|
1285
1285
|
});
|
|
1286
1286
|
}, [Kt, re]), Ce = F(() => {
|
|
1287
1287
|
var d, b;
|
|
1288
|
-
const a = Wt.current,
|
|
1289
|
-
a &&
|
|
1290
|
-
}, []),
|
|
1291
|
-
var
|
|
1288
|
+
const a = Wt.current, m = Me.current;
|
|
1289
|
+
a && m ? ((d = Et.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: m, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((b = Et.current) == null || b.postMessage({ type: "connecting", data: null }), ae(null));
|
|
1290
|
+
}, []), Ne = F(() => {
|
|
1291
|
+
var m, d;
|
|
1292
1292
|
const a = ie.current;
|
|
1293
|
-
a ? (
|
|
1293
|
+
a ? (m = Et.current) == null || m.postMessage({ type: "selectionBox", data: a }) : (d = Et.current) == null || d.postMessage({ type: "selectionBox", data: null });
|
|
1294
1294
|
}, []), dr = F((a) => {
|
|
1295
|
-
var
|
|
1296
|
-
const
|
|
1297
|
-
if (
|
|
1298
|
-
const
|
|
1299
|
-
if (Yt && Re.current &&
|
|
1295
|
+
var L, I, y, A, P, Y, H, J, ct, U, nt, wt, Mt, At, Xt, Ht;
|
|
1296
|
+
const m = Z.current.length > 0, d = at(a.clientX, a.clientY), b = Ut.current;
|
|
1297
|
+
if (m && Rt) {
|
|
1298
|
+
const X = tn(d.x, d.y);
|
|
1299
|
+
if (Yt && Re.current && X) {
|
|
1300
1300
|
const V = Re.current;
|
|
1301
|
-
if (
|
|
1302
|
-
const qt = V.handleType === "target" ? { source:
|
|
1303
|
-
(O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((
|
|
1301
|
+
if (X.nodeId !== V.nodeId) {
|
|
1302
|
+
const qt = V.handleType === "target" ? { source: X.nodeId, target: V.nodeId, sourceHandle: X.handleId || null, targetHandle: V.handleId } : { source: V.nodeId, target: X.nodeId, sourceHandle: V.handleId, targetHandle: X.handleId || null };
|
|
1303
|
+
(O.current.isValidConnection ? O.current.isValidConnection(qt) : !0) && ((L = ce.current) == null || L.call(ce, { ...qt, ...be }));
|
|
1304
1304
|
}
|
|
1305
1305
|
Re.current = null;
|
|
1306
1306
|
return;
|
|
1307
1307
|
}
|
|
1308
|
-
if (Bt === "strict" ?
|
|
1308
|
+
if (Bt === "strict" ? X && X.type === "source" : X != null) {
|
|
1309
1309
|
if (Yt) {
|
|
1310
|
-
Re.current = { nodeId:
|
|
1310
|
+
Re.current = { nodeId: X.nodeId, handleId: X.handleId || null, handleType: X.type }, (y = (I = O.current).onConnectStart) == null || y.call(I, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type });
|
|
1311
1311
|
return;
|
|
1312
1312
|
}
|
|
1313
1313
|
Wt.current = {
|
|
1314
|
-
sourceId:
|
|
1315
|
-
sourceHandle:
|
|
1316
|
-
sourceType:
|
|
1317
|
-
startPos: { x:
|
|
1318
|
-
}, Me.current = { x: d.x, y: d.y }, (A = vt.current) == null || A.setPointerCapture(a.pointerId), (Y = (
|
|
1314
|
+
sourceId: X.nodeId,
|
|
1315
|
+
sourceHandle: X.handleId || null,
|
|
1316
|
+
sourceType: X.type,
|
|
1317
|
+
startPos: { x: X.x, y: X.y }
|
|
1318
|
+
}, Me.current = { x: d.x, y: d.y }, (A = vt.current) == null || A.setPointerCapture(a.pointerId), (Y = (P = O.current).onConnectStart) == null || Y.call(P, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type }), Ce();
|
|
1319
1319
|
return;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
if (
|
|
1323
|
-
const
|
|
1324
|
-
if (
|
|
1325
|
-
if (bt.current &&
|
|
1322
|
+
if (m) {
|
|
1323
|
+
const X = Tt(d.x, d.y);
|
|
1324
|
+
if (X) {
|
|
1325
|
+
if (bt.current && Lt) {
|
|
1326
1326
|
const kt = [];
|
|
1327
1327
|
if (b)
|
|
1328
|
-
kt.push({ id:
|
|
1329
|
-
else if (!
|
|
1328
|
+
kt.push({ id: X.id, type: "select", selected: !X.selected });
|
|
1329
|
+
else if (!X.selected) {
|
|
1330
1330
|
for (const V of Z.current)
|
|
1331
|
-
V.id ===
|
|
1331
|
+
V.id === X.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1332
1332
|
if (Dt.current) {
|
|
1333
1333
|
const V = Pt.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1334
1334
|
V.length && Dt.current(V);
|
|
@@ -1336,32 +1336,32 @@ function Nr({
|
|
|
1336
1336
|
}
|
|
1337
1337
|
if (kt.length) {
|
|
1338
1338
|
if (bt.current(kt), hn && !b) {
|
|
1339
|
-
const V = Z.current.findIndex((et) => et.id ===
|
|
1339
|
+
const V = Z.current.findIndex((et) => et.id === X.id);
|
|
1340
1340
|
V >= 0 && V < Z.current.length - 1 && bt.current([
|
|
1341
|
-
{ id:
|
|
1341
|
+
{ id: X.id, type: "remove" },
|
|
1342
1342
|
{ type: "add", item: { ...Z.current[V], selected: !0 } }
|
|
1343
1343
|
]);
|
|
1344
1344
|
}
|
|
1345
1345
|
Jt();
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
if ((H = De.current) == null || H.call(De, a,
|
|
1349
|
-
const kt = b &&
|
|
1348
|
+
if ((H = De.current) == null || H.call(De, a, X), ht) {
|
|
1349
|
+
const kt = b && X.selected;
|
|
1350
1350
|
let V = null;
|
|
1351
|
-
if (
|
|
1352
|
-
const et = Z.current.find((qt) => qt.id ===
|
|
1351
|
+
if (X.parentId && X.extent === "parent") {
|
|
1352
|
+
const et = Z.current.find((qt) => qt.id === X.parentId);
|
|
1353
1353
|
if (et) {
|
|
1354
|
-
const qt = et.width || Vt, Xe = et.height || jt, en =
|
|
1354
|
+
const qt = et.width || Vt, Xe = et.height || jt, en = X.width || ((J = X.measured) == null ? void 0 : J.width) || Vt, Fe = X.height || ((ct = X.measured) == null ? void 0 : ct.height) || jt;
|
|
1355
1355
|
V = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
1358
1358
|
if (_t.current = {
|
|
1359
|
-
id:
|
|
1360
|
-
startPos: { ...
|
|
1359
|
+
id: X.id,
|
|
1360
|
+
startPos: { ...X.position },
|
|
1361
1361
|
startMouse: { x: d.x, y: d.y },
|
|
1362
1362
|
parentClamp: V,
|
|
1363
|
-
parentId:
|
|
1364
|
-
selectedStarts: kt ? Z.current.filter((et) => et.selected && et.id !==
|
|
1363
|
+
parentId: X.parentId || null,
|
|
1364
|
+
selectedStarts: kt ? Z.current.filter((et) => et.selected && et.id !== X.id).map((et) => {
|
|
1365
1365
|
var Xe, en;
|
|
1366
1366
|
let qt = null;
|
|
1367
1367
|
if (et.parentId && et.extent === "parent") {
|
|
@@ -1373,8 +1373,8 @@ function Nr({
|
|
|
1373
1373
|
}
|
|
1374
1374
|
return { id: et.id, startPos: { ...et.position }, parentClamp: qt, parentId: et.parentId || null };
|
|
1375
1375
|
}) : []
|
|
1376
|
-
}, (U = vt.current) == null || U.setPointerCapture(a.pointerId), (nt = Ae.current) == null || nt.call(Ae, a,
|
|
1377
|
-
const et = [{ id:
|
|
1376
|
+
}, (U = vt.current) == null || U.setPointerCapture(a.pointerId), (nt = Ae.current) == null || nt.call(Ae, a, X), bt.current) {
|
|
1377
|
+
const et = [{ id: X.id, type: "position", dragging: !0 }];
|
|
1378
1378
|
for (const qt of _t.current.selectedStarts)
|
|
1379
1379
|
et.push({ id: qt.id, type: "position", dragging: !0 });
|
|
1380
1380
|
bt.current(et);
|
|
@@ -1383,16 +1383,16 @@ function Nr({
|
|
|
1383
1383
|
return;
|
|
1384
1384
|
}
|
|
1385
1385
|
}
|
|
1386
|
-
if (Pt.current.length > 0 &&
|
|
1387
|
-
const
|
|
1388
|
-
if (
|
|
1386
|
+
if (Pt.current.length > 0 && Lt) {
|
|
1387
|
+
const X = ue(d.x, d.y);
|
|
1388
|
+
if (X) {
|
|
1389
1389
|
if (Dt.current) {
|
|
1390
1390
|
const kt = [];
|
|
1391
1391
|
if (b)
|
|
1392
|
-
kt.push({ id:
|
|
1392
|
+
kt.push({ id: X.id, type: "select", selected: !X.selected });
|
|
1393
1393
|
else {
|
|
1394
1394
|
for (const V of Pt.current)
|
|
1395
|
-
V.id ===
|
|
1395
|
+
V.id === X.id ? kt.push({ id: V.id, type: "select", selected: !0 }) : V.selected && kt.push({ id: V.id, type: "select", selected: !1 });
|
|
1396
1396
|
if (bt.current) {
|
|
1397
1397
|
const V = Z.current.filter((et) => et.selected).map((et) => ({ id: et.id, type: "select", selected: !1 }));
|
|
1398
1398
|
V.length && bt.current(V);
|
|
@@ -1400,40 +1400,40 @@ function Nr({
|
|
|
1400
1400
|
}
|
|
1401
1401
|
kt.length && (Dt.current(kt), Jt());
|
|
1402
1402
|
}
|
|
1403
|
-
(wt = le.current) == null || wt.call(le, a,
|
|
1403
|
+
(wt = le.current) == null || wt.call(le, a, X);
|
|
1404
1404
|
return;
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
1407
|
if (!b) {
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1408
|
+
const X = Z.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 })), kt = Pt.current.filter((V) => V.selected).map((V) => ({ id: V.id, type: "select", selected: !1 }));
|
|
1409
|
+
X.length && bt.current && bt.current(X), kt.length && Dt.current && Dt.current(kt), (X.length || kt.length) && Jt();
|
|
1410
1410
|
}
|
|
1411
1411
|
if ((Mt = We.current) == null || Mt.call(We, a), ne || b) {
|
|
1412
|
-
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (At = vt.current) == null || At.setPointerCapture(a.pointerId),
|
|
1412
|
+
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (At = vt.current) == null || At.setPointerCapture(a.pointerId), Ne();
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = vt.current) == null || Xt.classList.add("dragging"), (Ht = vt.current) == null || Ht.setPointerCapture(a.pointerId);
|
|
1416
|
-
}, [at, Tt, tn, ue, ht, Rt,
|
|
1416
|
+
}, [at, Tt, tn, ue, ht, Rt, Lt, ne, Ce, Ne, Jt]), fr = F((a) => {
|
|
1417
1417
|
var d, b;
|
|
1418
1418
|
if (Wt.current) {
|
|
1419
1419
|
if (Me.current = at(a.clientX, a.clientY), Ce(), fn) {
|
|
1420
|
-
const
|
|
1421
|
-
if (
|
|
1422
|
-
const I =
|
|
1420
|
+
const L = vt.current;
|
|
1421
|
+
if (L) {
|
|
1422
|
+
const I = L.getBoundingClientRect(), y = 40, A = a.clientX - I.left, P = a.clientY - I.top;
|
|
1423
1423
|
let Y = 0, H = 0;
|
|
1424
|
-
A <
|
|
1424
|
+
A < y ? Y = Qt : A > I.width - y && (Y = -Qt), P < y ? H = Qt : P > I.height - y && (H = -Qt), (Y || H) && (pt.current.x += Y, pt.current.y += H, Ct(a));
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
return;
|
|
1428
1428
|
}
|
|
1429
1429
|
if (ie.current) {
|
|
1430
|
-
ie.current.endWorld = at(a.clientX, a.clientY),
|
|
1431
|
-
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), y = Math.min(L.startWorld.y, L.endWorld.y), A = Math.max(L.startWorld.x, L.endWorld.x), P = Math.max(L.startWorld.y, L.endWorld.y);
|
|
1432
1432
|
if (bt.current) {
|
|
1433
1433
|
const Y = [];
|
|
1434
1434
|
for (const H of Z.current) {
|
|
1435
1435
|
if (H.hidden) continue;
|
|
1436
|
-
const J = H.width || Vt, ct = H.height || jt, U = Ie === "full" ? H.position.x >= I && H.position.x + J <= A && H.position.y >=
|
|
1436
|
+
const J = H.width || Vt, ct = H.height || jt, U = Ie === "full" ? H.position.x >= I && H.position.x + J <= A && H.position.y >= y && H.position.y + ct <= P : H.position.x + J > I && H.position.x < A && H.position.y + ct > y && H.position.y < P;
|
|
1437
1437
|
U !== !!H.selected && Y.push({ id: H.id, type: "select", selected: U });
|
|
1438
1438
|
}
|
|
1439
1439
|
Y.length && bt.current(Y);
|
|
@@ -1441,15 +1441,15 @@ function Nr({
|
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
1443
1443
|
if (_t.current) {
|
|
1444
|
-
const
|
|
1445
|
-
let
|
|
1446
|
-
if (me && (
|
|
1444
|
+
const L = at(a.clientX, a.clientY), I = _t.current, y = L.x - I.startMouse.x, A = L.y - I.startMouse.y;
|
|
1445
|
+
let P = { x: I.startPos.x + y, y: I.startPos.y + A };
|
|
1446
|
+
if (me && (P = Pn(P, de)), oe && (P = Tn(P, oe)), I.parentClamp) {
|
|
1447
1447
|
const U = I.parentClamp;
|
|
1448
|
-
|
|
1448
|
+
P = { x: Math.max(U.minX, Math.min(P.x, U.maxX)), y: Math.max(U.minY, Math.min(P.y, U.maxY)) };
|
|
1449
1449
|
}
|
|
1450
|
-
const Y = [{ id: I.id, position:
|
|
1450
|
+
const Y = [{ id: I.id, position: P }];
|
|
1451
1451
|
for (const U of I.selectedStarts) {
|
|
1452
|
-
let nt = { x: U.startPos.x +
|
|
1452
|
+
let nt = { x: U.startPos.x + y, y: U.startPos.y + A };
|
|
1453
1453
|
if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), U.parentClamp) {
|
|
1454
1454
|
const wt = U.parentClamp;
|
|
1455
1455
|
nt = { x: Math.max(wt.minX, Math.min(nt.x, wt.maxX)), y: Math.max(wt.minY, Math.min(nt.y, wt.maxY)) };
|
|
@@ -1508,12 +1508,12 @@ function Nr({
|
|
|
1508
1508
|
return;
|
|
1509
1509
|
}
|
|
1510
1510
|
if (!Se.current) return;
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
}, [Ct, at, Ce,
|
|
1514
|
-
var
|
|
1511
|
+
const m = pt.current;
|
|
1512
|
+
m.x += a.clientX - te.current.x, m.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Ct();
|
|
1513
|
+
}, [Ct, at, Ce, Ne]), hr = F((a) => {
|
|
1514
|
+
var m, d, b, L, I;
|
|
1515
1515
|
if (Wt.current) {
|
|
1516
|
-
const
|
|
1516
|
+
const y = at(a.clientX, a.clientY), A = tn(y.x, y.y);
|
|
1517
1517
|
if (A && A.nodeId !== Wt.current.sourceId && (Bt === "loose" || A.type === "target")) {
|
|
1518
1518
|
const H = Wt.current.sourceType === "target" ? {
|
|
1519
1519
|
source: A.nodeId,
|
|
@@ -1526,25 +1526,25 @@ function Nr({
|
|
|
1526
1526
|
sourceHandle: Wt.current.sourceHandle,
|
|
1527
1527
|
targetHandle: A.handleId || null
|
|
1528
1528
|
};
|
|
1529
|
-
(O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((
|
|
1529
|
+
(O.current.isValidConnection ? O.current.isValidConnection(H) : !0) && ((m = ce.current) == null || m.call(ce, { ...H, ...be }));
|
|
1530
1530
|
}
|
|
1531
1531
|
(b = (d = O.current).onConnectEnd) == null || b.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
|
|
1532
1532
|
return;
|
|
1533
1533
|
}
|
|
1534
1534
|
if (ie.current) {
|
|
1535
|
-
ie.current = null,
|
|
1535
|
+
ie.current = null, Ne(), Jt();
|
|
1536
1536
|
return;
|
|
1537
1537
|
}
|
|
1538
1538
|
if (_t.current) {
|
|
1539
|
-
const
|
|
1539
|
+
const y = _t.current;
|
|
1540
1540
|
if (bt.current) {
|
|
1541
|
-
const
|
|
1542
|
-
id:
|
|
1541
|
+
const P = Z.current.find((H) => H.id === y.id), Y = [{
|
|
1542
|
+
id: y.id,
|
|
1543
1543
|
type: "position",
|
|
1544
|
-
position:
|
|
1544
|
+
position: P ? { ...P.position } : void 0,
|
|
1545
1545
|
dragging: !1
|
|
1546
1546
|
}];
|
|
1547
|
-
for (const H of
|
|
1547
|
+
for (const H of y.selectedStarts) {
|
|
1548
1548
|
const J = Z.current.find((ct) => ct.id === H.id);
|
|
1549
1549
|
Y.push({
|
|
1550
1550
|
id: H.id,
|
|
@@ -1558,198 +1558,198 @@ function Nr({
|
|
|
1558
1558
|
requestAnimationFrame(() => {
|
|
1559
1559
|
_t.current = null;
|
|
1560
1560
|
});
|
|
1561
|
-
const A = Z.current.find((
|
|
1562
|
-
A && ((
|
|
1561
|
+
const A = Z.current.find((P) => P.id === y.id);
|
|
1562
|
+
A && ((L = _e.current) == null || L.call(_e, a, A));
|
|
1563
1563
|
return;
|
|
1564
1564
|
}
|
|
1565
1565
|
Se.current = !1, (I = vt.current) == null || I.classList.remove("dragging");
|
|
1566
|
-
}, [at, tn, Ce,
|
|
1566
|
+
}, [at, tn, Ce, Ne, Jt]);
|
|
1567
1567
|
ft(() => {
|
|
1568
1568
|
const a = vt.current;
|
|
1569
1569
|
if (!a) return;
|
|
1570
|
-
const
|
|
1570
|
+
const m = (d) => {
|
|
1571
1571
|
Pe && d.preventDefault();
|
|
1572
1572
|
const b = pt.current;
|
|
1573
1573
|
if (Ge || ke.current) {
|
|
1574
|
-
const
|
|
1575
|
-
$e === "horizontal" ? b.x -= d.deltaY *
|
|
1574
|
+
const P = Ze;
|
|
1575
|
+
$e === "horizontal" ? b.x -= d.deltaY * P : ($e === "vertical" || (b.x -= d.deltaX * P), b.y -= d.deltaY * P), Ct(d);
|
|
1576
1576
|
return;
|
|
1577
1577
|
}
|
|
1578
1578
|
if (!Oe) return;
|
|
1579
|
-
const
|
|
1580
|
-
b.x =
|
|
1579
|
+
const L = d.deltaY > 0 ? 0.92 : 1.08, I = a.getBoundingClientRect(), y = d.clientX - I.left, A = d.clientY - I.top;
|
|
1580
|
+
b.x = y - (y - b.x) * L, b.y = A - (A - b.y) * L, b.zoom = Math.min(mt, Math.max(it, b.zoom * L)), Ct(d);
|
|
1581
1581
|
};
|
|
1582
|
-
return a.addEventListener("wheel",
|
|
1582
|
+
return a.addEventListener("wheel", m, { passive: !Pe }), () => a.removeEventListener("wheel", m);
|
|
1583
1583
|
}, [Ct, it, mt, Ge, $e, Ze, Oe, Pe]), ft(() => {
|
|
1584
1584
|
if (!Ke) return;
|
|
1585
1585
|
const a = vt.current;
|
|
1586
1586
|
if (!a) return;
|
|
1587
|
-
let
|
|
1588
|
-
const b = (
|
|
1589
|
-
if (
|
|
1590
|
-
const A =
|
|
1591
|
-
|
|
1587
|
+
let m = 0, d = null;
|
|
1588
|
+
const b = (y) => {
|
|
1589
|
+
if (y.touches.length === 2) {
|
|
1590
|
+
const A = y.touches[0].clientX - y.touches[1].clientX, P = y.touches[0].clientY - y.touches[1].clientY;
|
|
1591
|
+
m = Math.hypot(A, P);
|
|
1592
1592
|
const Y = a.getBoundingClientRect();
|
|
1593
1593
|
d = {
|
|
1594
|
-
x: (
|
|
1595
|
-
y: (
|
|
1596
|
-
},
|
|
1594
|
+
x: (y.touches[0].clientX + y.touches[1].clientX) / 2 - Y.left,
|
|
1595
|
+
y: (y.touches[0].clientY + y.touches[1].clientY) / 2 - Y.top
|
|
1596
|
+
}, y.preventDefault();
|
|
1597
1597
|
}
|
|
1598
|
-
},
|
|
1599
|
-
if (
|
|
1600
|
-
|
|
1601
|
-
const A =
|
|
1602
|
-
|
|
1598
|
+
}, L = (y) => {
|
|
1599
|
+
if (y.touches.length === 2 && m > 0) {
|
|
1600
|
+
y.preventDefault();
|
|
1601
|
+
const A = y.touches[0].clientX - y.touches[1].clientX, P = y.touches[0].clientY - y.touches[1].clientY, Y = Math.hypot(A, P), H = Y / m;
|
|
1602
|
+
m = Y;
|
|
1603
1603
|
const J = pt.current, ct = d.x, U = d.y;
|
|
1604
|
-
J.x = ct - (ct - J.x) * H, J.y = U - (U - J.y) * H, J.zoom = Math.min(mt, Math.max(it, J.zoom * H)), Ct(
|
|
1604
|
+
J.x = ct - (ct - J.x) * H, J.y = U - (U - J.y) * H, J.zoom = Math.min(mt, Math.max(it, J.zoom * H)), Ct(y);
|
|
1605
1605
|
}
|
|
1606
1606
|
}, I = () => {
|
|
1607
|
-
|
|
1607
|
+
m = 0, d = null;
|
|
1608
1608
|
};
|
|
1609
|
-
return a.addEventListener("touchstart", b, { passive: !1 }), a.addEventListener("touchmove",
|
|
1610
|
-
a.removeEventListener("touchstart", b), a.removeEventListener("touchmove",
|
|
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
1612
|
}, [Ke, Ct, it, mt]), ft(() => {
|
|
1613
1613
|
if (!Qe) return;
|
|
1614
1614
|
const a = vt.current;
|
|
1615
1615
|
if (!a) return;
|
|
1616
|
-
const
|
|
1616
|
+
const m = (d) => {
|
|
1617
1617
|
var H, J, ct, U;
|
|
1618
1618
|
const b = at(d.clientX, d.clientY);
|
|
1619
1619
|
if (Tt(b.x, b.y)) {
|
|
1620
1620
|
(J = (H = O.current).onNodeDoubleClick) == null || J.call(H, d, Tt(b.x, b.y));
|
|
1621
1621
|
return;
|
|
1622
1622
|
}
|
|
1623
|
-
const
|
|
1624
|
-
if (
|
|
1625
|
-
(U = (ct = O.current).onEdgeDoubleClick) == null || U.call(ct, d,
|
|
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 I = 1.5,
|
|
1629
|
-
Y.x = A - (A - Y.x) * I, Y.y =
|
|
1628
|
+
const I = 1.5, y = a.getBoundingClientRect(), A = d.clientX - y.left, P = d.clientY - y.top, Y = pt.current;
|
|
1629
|
+
Y.x = A - (A - Y.x) * I, Y.y = P - (P - Y.y) * I, Y.zoom = Math.min(mt, Math.max(it, Y.zoom * I)), Ct(d);
|
|
1630
1630
|
};
|
|
1631
|
-
return a.addEventListener("dblclick",
|
|
1631
|
+
return a.addEventListener("dblclick", m), () => a.removeEventListener("dblclick", m);
|
|
1632
1632
|
}, [Qe, Ct, it, mt, at, Tt, ue]), ft(() => {
|
|
1633
1633
|
const a = vt.current;
|
|
1634
1634
|
if (!a) return;
|
|
1635
|
-
const
|
|
1636
|
-
var
|
|
1637
|
-
const b = at(d.clientX, d.clientY),
|
|
1638
|
-
if (
|
|
1639
|
-
(A = (
|
|
1635
|
+
const m = (d) => {
|
|
1636
|
+
var y, A, P, Y, H, J;
|
|
1637
|
+
const b = at(d.clientX, d.clientY), L = Tt(b.x, b.y);
|
|
1638
|
+
if (L) {
|
|
1639
|
+
(A = (y = O.current).onNodeContextMenu) == null || A.call(y, d, L);
|
|
1640
1640
|
return;
|
|
1641
1641
|
}
|
|
1642
1642
|
const I = ue(b.x, b.y);
|
|
1643
1643
|
if (I) {
|
|
1644
|
-
(Y = (
|
|
1644
|
+
(Y = (P = O.current).onEdgeContextMenu) == null || Y.call(P, d, I);
|
|
1645
1645
|
return;
|
|
1646
1646
|
}
|
|
1647
1647
|
(J = (H = O.current).onPaneContextMenu) == null || J.call(H, d);
|
|
1648
1648
|
};
|
|
1649
|
-
return a.addEventListener("contextmenu",
|
|
1649
|
+
return a.addEventListener("contextmenu", m), () => a.removeEventListener("contextmenu", m);
|
|
1650
1650
|
}, [at, Tt, ue]), ft(() => {
|
|
1651
1651
|
const a = vt.current;
|
|
1652
1652
|
if (!a) return;
|
|
1653
|
-
let
|
|
1654
|
-
const b = (
|
|
1655
|
-
var Y, H, J, ct, U, nt, wt, Mt, At, Xt, Ht,
|
|
1656
|
-
(H = (Y = O.current).onPaneMouseMove) == null || H.call(Y,
|
|
1657
|
-
const A = at(
|
|
1658
|
-
if (
|
|
1653
|
+
let m = null, d = null;
|
|
1654
|
+
const b = (y) => {
|
|
1655
|
+
var Y, H, J, ct, U, nt, wt, Mt, At, Xt, Ht, X, kt, V;
|
|
1656
|
+
(H = (Y = O.current).onPaneMouseMove) == null || H.call(Y, y);
|
|
1657
|
+
const A = at(y.clientX, y.clientY), P = Tt(A.x, A.y);
|
|
1658
|
+
if (P !== m && (m && ((ct = (J = O.current).onNodeMouseLeave) == null || ct.call(J, y, m)), P && ((nt = (U = O.current).onNodeMouseEnter) == null || nt.call(U, y, P)), m = P), P && ((Mt = (wt = O.current).onNodeMouseMove) == null || Mt.call(wt, y, P)), !P) {
|
|
1659
1659
|
const et = ue(A.x, A.y);
|
|
1660
|
-
et !== d && (d && ((Xt = (At = O.current).onEdgeMouseLeave) == null || Xt.call(At,
|
|
1660
|
+
et !== d && (d && ((Xt = (At = O.current).onEdgeMouseLeave) == null || Xt.call(At, y, d)), et && ((X = (Ht = O.current).onEdgeMouseEnter) == null || X.call(Ht, y, et)), d = et), et && ((V = (kt = O.current).onEdgeMouseMove) == null || V.call(kt, y, et));
|
|
1661
1661
|
}
|
|
1662
|
-
},
|
|
1663
|
-
var A,
|
|
1664
|
-
return (
|
|
1665
|
-
}, I = (
|
|
1666
|
-
var A,
|
|
1667
|
-
(
|
|
1662
|
+
}, L = (y) => {
|
|
1663
|
+
var A, P;
|
|
1664
|
+
return (P = (A = O.current).onPaneMouseEnter) == null ? void 0 : P.call(A, y);
|
|
1665
|
+
}, I = (y) => {
|
|
1666
|
+
var A, P, Y, H, J, ct;
|
|
1667
|
+
(P = (A = O.current).onPaneMouseLeave) == null || P.call(A, y), m && ((H = (Y = O.current).onNodeMouseLeave) == null || H.call(Y, y, m), m = null), d && ((ct = (J = O.current).onEdgeMouseLeave) == null || ct.call(J, y, d), d = null);
|
|
1668
1668
|
};
|
|
1669
|
-
return a.addEventListener("mousemove", b), a.addEventListener("mouseenter",
|
|
1670
|
-
a.removeEventListener("mousemove", b), a.removeEventListener("mouseenter",
|
|
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
1672
|
}, [at, Tt, ue]), ft(() => {
|
|
1673
|
-
const a = Array.isArray(ve) ? ve : [ve],
|
|
1674
|
-
var b,
|
|
1673
|
+
const a = Array.isArray(ve) ? ve : [ve], m = 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 I = Z.current.filter((
|
|
1678
|
-
if (!I.length && !
|
|
1677
|
+
const I = Z.current.filter((P) => P.selected), y = Pt.current.filter((P) => P.selected);
|
|
1678
|
+
if (!I.length && !y.length || O.current.onBeforeDelete && !await O.current.onBeforeDelete({ nodes: I, edges: y }))
|
|
1679
1679
|
return;
|
|
1680
|
-
const A = new Set(I.map((
|
|
1681
|
-
if (I.length && bt.current && (bt.current(I.map((
|
|
1682
|
-
const
|
|
1683
|
-
|
|
1680
|
+
const A = new Set(I.map((P) => P.id));
|
|
1681
|
+
if (I.length && bt.current && (bt.current(I.map((P) => ({ id: P.id, type: "remove" }))), Dt.current)) {
|
|
1682
|
+
const P = Pt.current.filter((Y) => A.has(Y.source) || A.has(Y.target));
|
|
1683
|
+
P.length && Dt.current(P.map((Y) => ({ id: Y.id, type: "remove" })));
|
|
1684
1684
|
}
|
|
1685
|
-
|
|
1685
|
+
y.length && Dt.current && Dt.current(y.map((P) => ({ id: P.id, type: "remove" }))), (L = (b = O.current).onDelete) == null || L.call(b, { nodes: I, edges: y });
|
|
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
1689
|
if (d.preventDefault(), bt.current) {
|
|
1690
|
-
const I = Z.current.filter((
|
|
1690
|
+
const I = Z.current.filter((y) => !y.selected).map((y) => ({ id: y.id, type: "select", selected: !0 }));
|
|
1691
1691
|
I.length && bt.current(I);
|
|
1692
1692
|
}
|
|
1693
1693
|
if (Dt.current) {
|
|
1694
|
-
const I = Pt.current.filter((
|
|
1694
|
+
const I = Pt.current.filter((y) => !y.selected).map((y) => ({ id: y.id, type: "select", selected: !0 }));
|
|
1695
1695
|
I.length && Dt.current(I);
|
|
1696
1696
|
}
|
|
1697
1697
|
}
|
|
1698
1698
|
};
|
|
1699
|
-
return window.addEventListener("keydown",
|
|
1699
|
+
return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
|
|
1700
1700
|
}, [ve]);
|
|
1701
1701
|
const In = tt(!1);
|
|
1702
1702
|
ft(() => {
|
|
1703
|
-
var a,
|
|
1703
|
+
var a, m;
|
|
1704
1704
|
if (!In.current && Et.current) {
|
|
1705
1705
|
if (In.current = !0, zt && Z.current.length > 0) {
|
|
1706
1706
|
const d = vt.current;
|
|
1707
1707
|
if (d) {
|
|
1708
|
-
const b = d.getBoundingClientRect(),
|
|
1709
|
-
dt != null && dt.maxZoom && (
|
|
1708
|
+
const b = d.getBoundingClientRect(), L = (dt == null ? void 0 : dt.padding) ?? 0.1, I = Mn(Z.current), y = Rn(I, b.width, b.height, L);
|
|
1709
|
+
dt != null && dt.maxZoom && (y.zoom = Math.min(y.zoom, dt.maxZoom)), dt != null && dt.minZoom && (y.zoom = Math.max(y.zoom, dt.minZoom)), pt.current = y, Ct();
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
|
-
(
|
|
1712
|
+
(m = (a = O.current).onInit) == null || m.call(a, {
|
|
1713
1713
|
getNodes: () => [...Z.current],
|
|
1714
1714
|
getEdges: () => [...Pt.current],
|
|
1715
1715
|
getViewport: () => ({ ...pt.current }),
|
|
1716
1716
|
fitView: (d = {}) => {
|
|
1717
1717
|
const b = vt.current;
|
|
1718
1718
|
if (!b || !Z.current.length) return;
|
|
1719
|
-
const
|
|
1720
|
-
pt.current =
|
|
1719
|
+
const L = b.getBoundingClientRect(), I = Mn(Z.current), y = Rn(I, L.width, L.height, d.padding ?? 0.1);
|
|
1720
|
+
pt.current = y, Ct();
|
|
1721
1721
|
}
|
|
1722
1722
|
});
|
|
1723
1723
|
}
|
|
1724
1724
|
});
|
|
1725
1725
|
const yr = F(() => {
|
|
1726
|
-
pt.current = { ...
|
|
1727
|
-
}, [Ct,
|
|
1728
|
-
var
|
|
1726
|
+
pt.current = { ...Nt }, Ct();
|
|
1727
|
+
}, [Ct, Nt]), gr = F((a) => {
|
|
1728
|
+
var m;
|
|
1729
1729
|
if (a)
|
|
1730
1730
|
se.current.push(a);
|
|
1731
1731
|
else {
|
|
1732
1732
|
const d = pt.current, b = vt.current;
|
|
1733
1733
|
if (!b) return;
|
|
1734
|
-
const
|
|
1734
|
+
const L = b.getBoundingClientRect(), I = Math.round(-d.x / d.zoom + L.width / 2 / d.zoom), y = Math.round(-d.y / d.zoom + L.height / 2 / d.zoom);
|
|
1735
1735
|
se.current.push({
|
|
1736
1736
|
x: I - 80,
|
|
1737
|
-
y:
|
|
1737
|
+
y: y - 45,
|
|
1738
1738
|
w: 160,
|
|
1739
1739
|
h: 90,
|
|
1740
1740
|
title: "Note " + (se.current.length + 1),
|
|
1741
1741
|
body: "Added at viewport center"
|
|
1742
1742
|
});
|
|
1743
1743
|
}
|
|
1744
|
-
(
|
|
1744
|
+
(m = Et.current) == null || m.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 m = pt.current, d = vt.current;
|
|
1748
1748
|
if (!d) return;
|
|
1749
1749
|
const b = d.getBoundingClientRect();
|
|
1750
1750
|
a.position = {
|
|
1751
|
-
x: Math.round(-
|
|
1752
|
-
y: Math.round(-
|
|
1751
|
+
x: Math.round(-m.x / m.zoom + b.width / 2 / m.zoom) - Vt / 2,
|
|
1752
|
+
y: Math.round(-m.y / m.zoom + b.height / 2 / m.zoom) - jt / 2
|
|
1753
1753
|
};
|
|
1754
1754
|
}
|
|
1755
1755
|
a.data || (a.data = { label: a.id }), bt.current && bt.current([{ type: "add", item: a }]);
|
|
@@ -1828,36 +1828,36 @@ function Ro() {
|
|
|
1828
1828
|
return qe(je);
|
|
1829
1829
|
}
|
|
1830
1830
|
function $r({ node: t, nodeType: e }) {
|
|
1831
|
-
var
|
|
1831
|
+
var v, N, z;
|
|
1832
1832
|
const n = yt(), r = tt(null), s = t._absolutePosition || t.position, o = tt(null);
|
|
1833
1833
|
ft(() => {
|
|
1834
|
-
const
|
|
1835
|
-
if (!
|
|
1836
|
-
const $ = new ResizeObserver((
|
|
1837
|
-
var
|
|
1838
|
-
const { width: E, height: _ } =
|
|
1834
|
+
const R = r.current;
|
|
1835
|
+
if (!R) return;
|
|
1836
|
+
const $ = new ResizeObserver((k) => {
|
|
1837
|
+
var B, D, f, h;
|
|
1838
|
+
const { width: E, height: _ } = k[0].contentRect;
|
|
1839
1839
|
if (E > 0 && _ > 0) {
|
|
1840
|
-
const
|
|
1841
|
-
(Math.abs((
|
|
1840
|
+
const p = n.nodesRef.current.find((C) => C.id === t.id), M = (p == null ? void 0 : p.width) || ((B = p == null ? void 0 : p.measured) == null ? void 0 : B.width), w = (p == null ? void 0 : p.height) || ((D = p == null ? void 0 : p.measured) == null ? void 0 : D.height);
|
|
1841
|
+
(Math.abs((M || 0) - E) > 1 || Math.abs((w || 0) - _) > 1) && ((h = (f = n.onNodesChangeRef).current) == null || h.call(f, [
|
|
1842
1842
|
{ id: t.id, type: "dimensions", dimensions: { width: E, height: _ }, setAttributes: !0 }
|
|
1843
1843
|
]));
|
|
1844
1844
|
}
|
|
1845
1845
|
});
|
|
1846
|
-
return $.observe(
|
|
1846
|
+
return $.observe(R), () => $.disconnect();
|
|
1847
1847
|
}, [t.id, n]);
|
|
1848
|
-
const i = F((
|
|
1849
|
-
var
|
|
1850
|
-
|
|
1851
|
-
const $ =
|
|
1852
|
-
if ($ === "INPUT" || $ === "TEXTAREA" || $ === "SELECT" || $ === "BUTTON" || $ === "A" || $ === "LABEL" ||
|
|
1853
|
-
let
|
|
1854
|
-
for (;
|
|
1855
|
-
if ((
|
|
1856
|
-
|
|
1848
|
+
const i = F((R) => {
|
|
1849
|
+
var T, j, W, xt;
|
|
1850
|
+
R.stopPropagation();
|
|
1851
|
+
const $ = R.target.tagName;
|
|
1852
|
+
if ($ === "INPUT" || $ === "TEXTAREA" || $ === "SELECT" || $ === "BUTTON" || $ === "A" || $ === "LABEL" || R.target.isContentEditable) return;
|
|
1853
|
+
let k = R.target;
|
|
1854
|
+
for (; k && k !== r.current; ) {
|
|
1855
|
+
if ((T = k.classList) != null && T.contains("nodrag") || (j = k.classList) != null && j.contains("nopan")) return;
|
|
1856
|
+
k = k.parentElement;
|
|
1857
1857
|
}
|
|
1858
1858
|
if (n.onNodesChangeRef.current) {
|
|
1859
1859
|
const K = [];
|
|
1860
|
-
if (
|
|
1860
|
+
if (R.shiftKey)
|
|
1861
1861
|
K.push({ id: t.id, type: "select", selected: !t.selected });
|
|
1862
1862
|
else
|
|
1863
1863
|
for (const q of n.nodesRef.current)
|
|
@@ -1866,20 +1866,20 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1866
1866
|
}
|
|
1867
1867
|
const E = n.cameraRef.current, _ = n.wrapRef.current;
|
|
1868
1868
|
if (!_) return;
|
|
1869
|
-
const
|
|
1869
|
+
const B = _.getBoundingClientRect(), D = (R.clientX - B.left - E.x) / E.zoom, f = (R.clientY - B.top - E.y) / E.zoom, p = R.shiftKey && t.selected ? n.nodesRef.current.filter((K) => K.selected && K.id !== t.id).map((K) => ({ id: K.id, startPos: { ...K.position } })) : [];
|
|
1870
1870
|
o.current = {
|
|
1871
1871
|
startPos: { ...t.position },
|
|
1872
|
-
startMouse: { x:
|
|
1873
|
-
selectedStarts:
|
|
1872
|
+
startMouse: { x: D, y: f },
|
|
1873
|
+
selectedStarts: p
|
|
1874
1874
|
};
|
|
1875
|
-
const
|
|
1876
|
-
for (const K of
|
|
1877
|
-
|
|
1878
|
-
(xt = (
|
|
1875
|
+
const M = [{ id: t.id, type: "position", dragging: !0 }];
|
|
1876
|
+
for (const K of p)
|
|
1877
|
+
M.push({ id: K.id, type: "position", dragging: !0 });
|
|
1878
|
+
(xt = (W = n.onNodesChangeRef).current) == null || xt.call(W, M);
|
|
1879
1879
|
const w = r.current;
|
|
1880
|
-
w && w.setPointerCapture(
|
|
1881
|
-
const
|
|
1882
|
-
var it, mt,
|
|
1880
|
+
w && w.setPointerCapture(R.pointerId);
|
|
1881
|
+
const C = (K) => {
|
|
1882
|
+
var it, mt, Nt, zt;
|
|
1883
1883
|
if (!o.current) return;
|
|
1884
1884
|
const rt = n.cameraRef.current, q = _.getBoundingClientRect(), G = (K.clientX - q.left - rt.x) / rt.zoom, ot = (K.clientY - q.top - rt.y) / rt.zoom, lt = G - o.current.startMouse.x, ut = ot - o.current.startMouse.y;
|
|
1885
1885
|
let st = { x: o.current.startPos.x + lt, y: o.current.startPos.y + ut };
|
|
@@ -1889,9 +1889,9 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1889
1889
|
}), t.parentId && t.extent === "parent") {
|
|
1890
1890
|
const dt = n.nodesRef.current.find((ht) => ht.id === t.parentId);
|
|
1891
1891
|
if (dt) {
|
|
1892
|
-
const ht = dt.width || 160, Rt = dt.height || 60,
|
|
1892
|
+
const ht = dt.width || 160, Rt = dt.height || 60, Lt = t.width || ((it = t.measured) == null ? void 0 : it.width) || 160, gt = t.height || ((mt = t.measured) == null ? void 0 : mt.height) || 60;
|
|
1893
1893
|
st = {
|
|
1894
|
-
x: Math.max(0, Math.min(st.x, ht -
|
|
1894
|
+
x: Math.max(0, Math.min(st.x, ht - Lt)),
|
|
1895
1895
|
y: Math.max(0, Math.min(st.y, Rt - gt))
|
|
1896
1896
|
};
|
|
1897
1897
|
}
|
|
@@ -1904,22 +1904,22 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1904
1904
|
y: n.snapGrid[1] * Math.round(ht.y / n.snapGrid[1])
|
|
1905
1905
|
}), It.push({ id: dt.id, type: "position", position: ht, dragging: !0 });
|
|
1906
1906
|
}
|
|
1907
|
-
(zt = (
|
|
1908
|
-
},
|
|
1907
|
+
(zt = (Nt = n.onNodesChangeRef).current) == null || zt.call(Nt, It);
|
|
1908
|
+
}, x = (K) => {
|
|
1909
1909
|
var q, G;
|
|
1910
1910
|
if (!o.current) return;
|
|
1911
1911
|
const rt = [{ id: t.id, type: "position", dragging: !1 }];
|
|
1912
1912
|
for (const ot of o.current.selectedStarts)
|
|
1913
1913
|
rt.push({ id: ot.id, type: "position", dragging: !1 });
|
|
1914
|
-
(G = (q = n.onNodesChangeRef).current) == null || G.call(q, rt), o.current = null, w && w.releasePointerCapture(K.pointerId), w == null || w.removeEventListener("pointermove",
|
|
1914
|
+
(G = (q = n.onNodesChangeRef).current) == null || G.call(q, rt), o.current = null, w && w.releasePointerCapture(K.pointerId), w == null || w.removeEventListener("pointermove", C), w == null || w.removeEventListener("pointerup", x);
|
|
1915
1915
|
};
|
|
1916
|
-
w == null || w.addEventListener("pointermove",
|
|
1917
|
-
}, [t, n]), c = F((
|
|
1918
|
-
var
|
|
1916
|
+
w == null || w.addEventListener("pointermove", C), w == null || w.addEventListener("pointerup", x);
|
|
1917
|
+
}, [t, n]), c = F((R) => {
|
|
1918
|
+
var D, f, h, p, M, w;
|
|
1919
1919
|
if (!t.selected) return;
|
|
1920
|
-
const $ =
|
|
1921
|
-
let
|
|
1922
|
-
switch (
|
|
1920
|
+
const $ = R.shiftKey ? 10 : 1;
|
|
1921
|
+
let k = 0, E = 0;
|
|
1922
|
+
switch (R.key) {
|
|
1923
1923
|
case "ArrowUp":
|
|
1924
1924
|
E = -$;
|
|
1925
1925
|
break;
|
|
@@ -1927,27 +1927,27 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1927
1927
|
E = $;
|
|
1928
1928
|
break;
|
|
1929
1929
|
case "ArrowLeft":
|
|
1930
|
-
|
|
1930
|
+
k = -$;
|
|
1931
1931
|
break;
|
|
1932
1932
|
case "ArrowRight":
|
|
1933
|
-
|
|
1933
|
+
k = $;
|
|
1934
1934
|
break;
|
|
1935
1935
|
case "Escape":
|
|
1936
|
-
(f = (
|
|
1936
|
+
(f = (D = n.onNodesChangeRef).current) == null || f.call(D, [{ id: t.id, type: "select", selected: !1 }]);
|
|
1937
1937
|
return;
|
|
1938
1938
|
case "Delete":
|
|
1939
1939
|
case "Backspace":
|
|
1940
|
-
t.deletable !== !1 && ((
|
|
1940
|
+
t.deletable !== !1 && ((p = (h = n.onNodesChangeRef).current) == null || p.call(h, [{ id: t.id, type: "remove" }]));
|
|
1941
1941
|
return;
|
|
1942
1942
|
default:
|
|
1943
1943
|
return;
|
|
1944
1944
|
}
|
|
1945
|
-
|
|
1946
|
-
const _ = { x: t.position.x +
|
|
1947
|
-
for (const
|
|
1948
|
-
|
|
1949
|
-
(w = (
|
|
1950
|
-
}, [t, n]), u = t.width || ((
|
|
1945
|
+
R.preventDefault();
|
|
1946
|
+
const _ = { x: t.position.x + k, y: t.position.y + E }, B = [{ id: t.id, type: "position", position: _ }];
|
|
1947
|
+
for (const C of n.nodesRef.current)
|
|
1948
|
+
C.selected && C.id !== t.id && B.push({ id: C.id, type: "position", position: { x: C.position.x + k, y: C.position.y + E } });
|
|
1949
|
+
(w = (M = n.onNodesChangeRef).current) == null || w.call(M, B);
|
|
1950
|
+
}, [t, n]), u = t.width || ((v = t.measured) == null ? void 0 : v.width), l = t.height || ((N = t.measured) == null ? void 0 : N.height), g = !!(u && l);
|
|
1951
1951
|
return /* @__PURE__ */ S(je.Provider, { value: t.id, children: /* @__PURE__ */ S(
|
|
1952
1952
|
"div",
|
|
1953
1953
|
{
|
|
@@ -1959,9 +1959,7 @@ function $r({ node: t, nodeType: e }) {
|
|
|
1959
1959
|
top: s.y,
|
|
1960
1960
|
zIndex: t.type === "group" ? 0 : t.zIndex || 1,
|
|
1961
1961
|
pointerEvents: t.type === "group" ? "none" : "all",
|
|
1962
|
-
|
|
1963
|
-
visibility: y ? "visible" : "hidden",
|
|
1964
|
-
userSelect: "none",
|
|
1962
|
+
visibility: g ? "visible" : "hidden",
|
|
1965
1963
|
outline: "none"
|
|
1966
1964
|
},
|
|
1967
1965
|
"data-nodeid": t.id,
|
|
@@ -2002,32 +2000,32 @@ function Bn(t, e, n, r) {
|
|
|
2002
2000
|
var c, u;
|
|
2003
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;
|
|
2004
2002
|
if (t.handleBounds) {
|
|
2005
|
-
const l = t.handleBounds[e] || [],
|
|
2006
|
-
if (
|
|
2007
|
-
const
|
|
2008
|
-
return { x: i.x +
|
|
2003
|
+
const l = t.handleBounds[e] || [], g = n ? l.find((v) => v.id === n) : l[0];
|
|
2004
|
+
if (g && g.x !== void 0 && g.y !== void 0) {
|
|
2005
|
+
const v = g.position || (e === "source" ? "right" : "left");
|
|
2006
|
+
return { x: i.x + g.x, y: i.y + g.y, position: v };
|
|
2009
2007
|
}
|
|
2010
2008
|
}
|
|
2011
2009
|
if (r) {
|
|
2012
|
-
const l = `${t.id}__${n || e}`,
|
|
2013
|
-
if (
|
|
2014
|
-
return { x: i.x +
|
|
2010
|
+
const l = `${t.id}__${n || e}`, g = r.get(l);
|
|
2011
|
+
if (g && g.x !== void 0 && g.y !== void 0)
|
|
2012
|
+
return { x: i.x + g.x, y: i.y + g.y, position: g.position || (e === "source" ? "right" : "left") };
|
|
2015
2013
|
}
|
|
2016
2014
|
if (t.handles && t.handles.length) {
|
|
2017
2015
|
for (const l of t.handles)
|
|
2018
2016
|
if (l.type === e && (!n || l.id === n)) {
|
|
2019
2017
|
if (l.x !== void 0 && l.y !== void 0)
|
|
2020
2018
|
return { x: i.x + l.x, y: i.y + l.y, position: l.position || (e === "source" ? "right" : "left") };
|
|
2021
|
-
const
|
|
2022
|
-
switch (
|
|
2019
|
+
const g = l.position || (e === "source" ? "right" : "left");
|
|
2020
|
+
switch (g) {
|
|
2023
2021
|
case "top":
|
|
2024
|
-
return { x: i.x + s / 2, y: i.y, position:
|
|
2022
|
+
return { x: i.x + s / 2, y: i.y, position: g };
|
|
2025
2023
|
case "bottom":
|
|
2026
|
-
return { x: i.x + s / 2, y: i.y + o, position:
|
|
2024
|
+
return { x: i.x + s / 2, y: i.y + o, position: g };
|
|
2027
2025
|
case "left":
|
|
2028
|
-
return { x: i.x, y: i.y + o / 2, position:
|
|
2026
|
+
return { x: i.x, y: i.y + o / 2, position: g };
|
|
2029
2027
|
default:
|
|
2030
|
-
return { x: i.x + s, y: i.y + o / 2, position:
|
|
2028
|
+
return { x: i.x + s, y: i.y + o / 2, position: g };
|
|
2031
2029
|
}
|
|
2032
2030
|
}
|
|
2033
2031
|
}
|
|
@@ -2055,32 +2053,32 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
|
2055
2053
|
);
|
|
2056
2054
|
}
|
|
2057
2055
|
function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
2058
|
-
var
|
|
2059
|
-
const s = yt(), [o, i] = Gt(null), c = F((
|
|
2056
|
+
var D, f, h;
|
|
2057
|
+
const s = yt(), [o, i] = Gt(null), c = F((p, M, w, C) => {
|
|
2060
2058
|
var rt;
|
|
2061
|
-
|
|
2062
|
-
const
|
|
2063
|
-
if (!
|
|
2064
|
-
const
|
|
2059
|
+
M.stopPropagation(), M.preventDefault();
|
|
2060
|
+
const x = s.wrapRef.current;
|
|
2061
|
+
if (!x) return;
|
|
2062
|
+
const T = p === "source" ? C : w, j = p === "source" ? t.target : t.source;
|
|
2065
2063
|
(rt = s.workerRef.current) == null || rt.postMessage({
|
|
2066
2064
|
type: "connecting",
|
|
2067
|
-
data: { from: { x:
|
|
2065
|
+
data: { from: { x: T.x, y: T.y }, to: { x: T.x, y: T.y } }
|
|
2068
2066
|
});
|
|
2069
|
-
const
|
|
2067
|
+
const W = x.getBoundingClientRect(), xt = (q) => {
|
|
2070
2068
|
var ut;
|
|
2071
|
-
const G = s.cameraRef.current, ot = (q.clientX -
|
|
2069
|
+
const G = s.cameraRef.current, ot = (q.clientX - W.left - G.x) / G.zoom, lt = (q.clientY - W.top - G.y) / G.zoom;
|
|
2072
2070
|
(ut = s.workerRef.current) == null || ut.postMessage({
|
|
2073
2071
|
type: "connecting",
|
|
2074
|
-
data: { from: { x:
|
|
2072
|
+
data: { from: { x: T.x, y: T.y }, to: { x: ot, y: lt } }
|
|
2075
2073
|
});
|
|
2076
2074
|
}, K = (q) => {
|
|
2077
|
-
var mt,
|
|
2078
|
-
const G = s.cameraRef.current, ot = (q.clientX -
|
|
2075
|
+
var mt, Nt, zt, dt;
|
|
2076
|
+
const G = s.cameraRef.current, ot = (q.clientX - W.left - G.x) / G.zoom, lt = (q.clientY - W.top - G.y) / G.zoom, ut = 20 / G.zoom;
|
|
2079
2077
|
let st = null, It = null;
|
|
2080
2078
|
const it = (mt = s.handleRegistryRef) == null ? void 0 : mt.current;
|
|
2081
2079
|
for (const ht of s.nodesRef.current) {
|
|
2082
2080
|
if (ht.hidden) continue;
|
|
2083
|
-
const Rt = ht.width || On,
|
|
2081
|
+
const Rt = ht.width || On, Lt = ht.height || Qn, gt = ht._absolutePosition || ht.position, ne = [];
|
|
2084
2082
|
if (it)
|
|
2085
2083
|
for (const [, Bt] of it)
|
|
2086
2084
|
Bt.nodeId === ht.id && ne.push(Bt);
|
|
@@ -2098,13 +2096,13 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2098
2096
|
Ot = gt.x + Rt / 2, Yt = gt.y;
|
|
2099
2097
|
break;
|
|
2100
2098
|
case "bottom":
|
|
2101
|
-
Ot = gt.x + Rt / 2, Yt = gt.y +
|
|
2099
|
+
Ot = gt.x + Rt / 2, Yt = gt.y + Lt;
|
|
2102
2100
|
break;
|
|
2103
2101
|
case "left":
|
|
2104
|
-
Ot = gt.x, Yt = gt.y +
|
|
2102
|
+
Ot = gt.x, Yt = gt.y + Lt / 2;
|
|
2105
2103
|
break;
|
|
2106
2104
|
default:
|
|
2107
|
-
Ot = gt.x + Rt, Yt = gt.y +
|
|
2105
|
+
Ot = gt.x + Rt, Yt = gt.y + Lt / 2;
|
|
2108
2106
|
break;
|
|
2109
2107
|
}
|
|
2110
2108
|
if (Math.abs(ot - Ot) < ut && Math.abs(lt - Yt) < ut) {
|
|
@@ -2115,17 +2113,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2115
2113
|
if (st) break;
|
|
2116
2114
|
}
|
|
2117
2115
|
if (st) {
|
|
2118
|
-
const ht =
|
|
2119
|
-
(zt = (
|
|
2116
|
+
const ht = p === "source" ? { source: st.id, target: j, sourceHandle: It, targetHandle: t.targetHandle } : { source: j, target: st.id, sourceHandle: t.sourceHandle, targetHandle: It };
|
|
2117
|
+
(zt = (Nt = s.onEdgesChangeRef).current) == null || zt.call(Nt, [
|
|
2120
2118
|
{ id: t.id, type: "remove" },
|
|
2121
2119
|
{ type: "add", item: { id: t.id, ...ht } }
|
|
2122
2120
|
]);
|
|
2123
2121
|
}
|
|
2124
|
-
(dt = s.workerRef.current) == null || dt.postMessage({ type: "connecting", data: null }),
|
|
2122
|
+
(dt = s.workerRef.current) == null || dt.postMessage({ type: "connecting", data: null }), x.removeEventListener("pointermove", xt), x.removeEventListener("pointerup", K);
|
|
2125
2123
|
};
|
|
2126
|
-
|
|
2127
|
-
}, [t, s]), u = n.find((
|
|
2128
|
-
return !z || !
|
|
2124
|
+
x.addEventListener("pointermove", xt), x.addEventListener("pointerup", K);
|
|
2125
|
+
}, [t, s]), u = n.find((p) => p.id === t.source), l = n.find((p) => p.id === t.target), g = u && !!(u.width || (D = u.measured) != null && D.width), v = l && !!(l.width || (f = l.measured) != null && f.width), N = (h = s.handleRegistryRef) == null ? void 0 : h.current, z = g ? Bn(u, "source", t.sourceHandle, N) : null, R = v ? Bn(l, "target", t.targetHandle, N) : null, $ = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, E = k == null ? void 0 : k.find((p) => p.id === t.id), _ = $ ? null : (E == null ? void 0 : E._routedPoints) || t._routedPoints || null, B = r !== !1 && t.reconnectable !== !1;
|
|
2126
|
+
return !z || !R ? null : /* @__PURE__ */ $t(
|
|
2129
2127
|
"g",
|
|
2130
2128
|
{
|
|
2131
2129
|
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
@@ -2141,10 +2139,10 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2141
2139
|
target: t.target,
|
|
2142
2140
|
sourceX: z.x,
|
|
2143
2141
|
sourceY: z.y,
|
|
2144
|
-
targetX:
|
|
2145
|
-
targetY:
|
|
2142
|
+
targetX: R.x,
|
|
2143
|
+
targetY: R.y,
|
|
2146
2144
|
sourcePosition: z.position,
|
|
2147
|
-
targetPosition:
|
|
2145
|
+
targetPosition: R.position,
|
|
2148
2146
|
sourceHandleId: t.sourceHandle,
|
|
2149
2147
|
targetHandleId: t.targetHandle,
|
|
2150
2148
|
data: t.data,
|
|
@@ -2158,7 +2156,7 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2158
2156
|
routedPoints: _
|
|
2159
2157
|
}
|
|
2160
2158
|
),
|
|
2161
|
-
|
|
2159
|
+
B && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
|
|
2162
2160
|
/* @__PURE__ */ S(
|
|
2163
2161
|
Dn,
|
|
2164
2162
|
{
|
|
@@ -2166,17 +2164,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2166
2164
|
y: z.y,
|
|
2167
2165
|
position: z.position,
|
|
2168
2166
|
type: "source",
|
|
2169
|
-
onPointerDown: (
|
|
2167
|
+
onPointerDown: (p) => c("source", p, z, R)
|
|
2170
2168
|
}
|
|
2171
2169
|
),
|
|
2172
2170
|
/* @__PURE__ */ S(
|
|
2173
2171
|
Dn,
|
|
2174
2172
|
{
|
|
2175
|
-
x:
|
|
2176
|
-
y:
|
|
2177
|
-
position:
|
|
2173
|
+
x: R.x,
|
|
2174
|
+
y: R.y,
|
|
2175
|
+
position: R.position,
|
|
2178
2176
|
type: "target",
|
|
2179
|
-
onPointerDown: (
|
|
2177
|
+
onPointerDown: (p) => c("target", p, z, R)
|
|
2180
2178
|
}
|
|
2181
2179
|
)
|
|
2182
2180
|
] })
|
|
@@ -2189,46 +2187,46 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2189
2187
|
var $;
|
|
2190
2188
|
const n = yt(), [r, s] = Gt(null), o = tt(null);
|
|
2191
2189
|
if (ft(() => {
|
|
2192
|
-
const
|
|
2193
|
-
if (!
|
|
2194
|
-
let E = !1, _ = null,
|
|
2195
|
-
const
|
|
2196
|
-
w.key === t && (
|
|
2190
|
+
const k = n.wrapRef.current;
|
|
2191
|
+
if (!k) return;
|
|
2192
|
+
let E = !1, _ = null, B = !1;
|
|
2193
|
+
const D = (w) => {
|
|
2194
|
+
w.key === t && (B = !0);
|
|
2197
2195
|
}, f = (w) => {
|
|
2198
|
-
w.key === t && (
|
|
2199
|
-
},
|
|
2200
|
-
if (!
|
|
2201
|
-
const
|
|
2202
|
-
if (
|
|
2196
|
+
w.key === t && (B = !1);
|
|
2197
|
+
}, h = (w) => {
|
|
2198
|
+
if (!B) return;
|
|
2199
|
+
const C = w.target;
|
|
2200
|
+
if (C.closest(".ric-node-wrapper") || C.closest(".ric-handle")) return;
|
|
2203
2201
|
E = !0;
|
|
2204
|
-
const
|
|
2205
|
-
_ = { x: j, y:
|
|
2206
|
-
},
|
|
2202
|
+
const x = n.cameraRef.current, T = k.getBoundingClientRect(), j = (w.clientX - T.left - x.x) / x.zoom, W = (w.clientY - T.top - x.y) / x.zoom;
|
|
2203
|
+
_ = { x: j, y: W }, s({ startX: j, startY: W, endX: j, endY: W }), w.stopPropagation();
|
|
2204
|
+
}, p = (w) => {
|
|
2207
2205
|
if (!E || !_) return;
|
|
2208
|
-
const
|
|
2209
|
-
s({ startX: _.x, startY: _.y, endX:
|
|
2210
|
-
},
|
|
2206
|
+
const C = n.cameraRef.current, x = k.getBoundingClientRect(), T = (w.clientX - x.left - C.x) / C.zoom, j = (w.clientY - x.top - C.y) / C.zoom;
|
|
2207
|
+
s({ startX: _.x, startY: _.y, endX: T, endY: j });
|
|
2208
|
+
}, M = (w) => {
|
|
2211
2209
|
var K, rt;
|
|
2212
2210
|
if (!E || !_) return;
|
|
2213
2211
|
E = !1;
|
|
2214
|
-
const
|
|
2215
|
-
x: Math.min(_.x,
|
|
2212
|
+
const C = n.cameraRef.current, x = k.getBoundingClientRect(), T = (w.clientX - x.left - C.x) / C.zoom, j = (w.clientY - x.top - C.y) / C.zoom, W = {
|
|
2213
|
+
x: Math.min(_.x, T),
|
|
2216
2214
|
y: Math.min(_.y, j),
|
|
2217
|
-
width: Math.abs(
|
|
2215
|
+
width: Math.abs(T - _.x),
|
|
2218
2216
|
height: Math.abs(j - _.y)
|
|
2219
2217
|
}, xt = [];
|
|
2220
2218
|
for (const q of n.nodesRef.current) {
|
|
2221
2219
|
const G = q._absolutePosition || q.position, ot = q.width || 160, lt = q.height || 60;
|
|
2222
2220
|
let ut;
|
|
2223
|
-
e === "full" ? ut = G.x >=
|
|
2221
|
+
e === "full" ? ut = G.x >= W.x && G.y >= W.y && G.x + ot <= W.x + W.width && G.y + lt <= W.y + W.height : ut = G.x + ot > W.x && G.x < W.x + W.width && G.y + lt > W.y && G.y < W.y + W.height, xt.push({ id: q.id, type: "select", selected: ut });
|
|
2224
2222
|
}
|
|
2225
2223
|
xt.length && ((rt = (K = n.onNodesChangeRef).current) == null || rt.call(K, xt)), _ = null, s(null);
|
|
2226
2224
|
};
|
|
2227
|
-
return
|
|
2228
|
-
|
|
2225
|
+
return k.addEventListener("pointerdown", h, !0), k.addEventListener("pointermove", p), k.addEventListener("pointerup", M), window.addEventListener("keydown", D), window.addEventListener("keyup", f), () => {
|
|
2226
|
+
k.removeEventListener("pointerdown", h, !0), k.removeEventListener("pointermove", p), k.removeEventListener("pointerup", M), window.removeEventListener("keydown", D), window.removeEventListener("keyup", f);
|
|
2229
2227
|
};
|
|
2230
2228
|
}, [n, t, e]), !r) return null;
|
|
2231
|
-
const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX),
|
|
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), g = Math.abs(r.endY - r.startY), v = c * i.zoom + i.x, N = u * i.zoom + i.y, z = l * i.zoom, R = g * i.zoom;
|
|
2232
2230
|
return /* @__PURE__ */ S(
|
|
2233
2231
|
"div",
|
|
2234
2232
|
{
|
|
@@ -2236,10 +2234,10 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2236
2234
|
className: "ric-selection-box",
|
|
2237
2235
|
style: {
|
|
2238
2236
|
position: "absolute",
|
|
2239
|
-
left:
|
|
2240
|
-
top:
|
|
2237
|
+
left: v,
|
|
2238
|
+
top: N,
|
|
2241
2239
|
width: z,
|
|
2242
|
-
height:
|
|
2240
|
+
height: R,
|
|
2243
2241
|
border: "1px dashed #3b82f6",
|
|
2244
2242
|
background: "rgba(59, 130, 246, 0.08)",
|
|
2245
2243
|
pointerEvents: "none",
|
|
@@ -2290,84 +2288,84 @@ function on({
|
|
|
2290
2288
|
className: c = "",
|
|
2291
2289
|
style: u = {},
|
|
2292
2290
|
onConnect: l,
|
|
2293
|
-
...
|
|
2291
|
+
...g
|
|
2294
2292
|
}) {
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2293
|
+
const v = qe(je), N = yt(), z = tt(null), R = tt(N);
|
|
2294
|
+
R.current = N;
|
|
2297
2295
|
const $ = F(() => {
|
|
2298
|
-
var w,
|
|
2299
|
-
const
|
|
2300
|
-
if (!
|
|
2301
|
-
const
|
|
2296
|
+
var w, C, x;
|
|
2297
|
+
const B = z.current;
|
|
2298
|
+
if (!B || !v) return;
|
|
2299
|
+
const D = R.current, f = (w = D.handleRegistryRef) == null ? void 0 : w.current;
|
|
2302
2300
|
if (!f) return;
|
|
2303
|
-
const
|
|
2304
|
-
if (
|
|
2305
|
-
const
|
|
2306
|
-
f.set(
|
|
2301
|
+
const h = `${v}__${n || t}`, p = (x = (C = D.cameraRef) == null ? void 0 : C.current) == null ? void 0 : x.zoom, M = Hr(B, p);
|
|
2302
|
+
if (M) {
|
|
2303
|
+
const T = { nodeId: v, id: n || null, type: t, position: e, x: M.x, y: M.y };
|
|
2304
|
+
f.set(h, T);
|
|
2307
2305
|
}
|
|
2308
|
-
}, [
|
|
2306
|
+
}, [v, n, t, e]);
|
|
2309
2307
|
kr(() => {
|
|
2310
2308
|
$();
|
|
2311
2309
|
}, [$]), ft(() => {
|
|
2312
|
-
if (!
|
|
2313
|
-
const
|
|
2314
|
-
An(
|
|
2315
|
-
const
|
|
2316
|
-
$(), An(
|
|
2310
|
+
if (!v) return;
|
|
2311
|
+
const B = R.current;
|
|
2312
|
+
An(B, v);
|
|
2313
|
+
const D = z.current, f = D == null ? void 0 : D.closest(".ric-node-wrapper"), h = new ResizeObserver(() => {
|
|
2314
|
+
$(), An(R.current, v);
|
|
2317
2315
|
});
|
|
2318
|
-
return f &&
|
|
2319
|
-
var
|
|
2320
|
-
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2316
|
+
return f && h.observe(f), () => {
|
|
2317
|
+
var C;
|
|
2318
|
+
h.disconnect();
|
|
2319
|
+
const p = R.current, M = (C = p.handleRegistryRef) == null ? void 0 : C.current, w = `${v}__${n || t}`;
|
|
2320
|
+
M == null || M.delete(w), Jn(p, v);
|
|
2323
2321
|
};
|
|
2324
|
-
}, [
|
|
2325
|
-
const
|
|
2326
|
-
var
|
|
2327
|
-
const
|
|
2328
|
-
if (!
|
|
2329
|
-
const f =
|
|
2330
|
-
if (
|
|
2331
|
-
return { x: f.x +
|
|
2332
|
-
const w =
|
|
2322
|
+
}, [v, n, t, e, $]);
|
|
2323
|
+
const k = F(() => {
|
|
2324
|
+
var x;
|
|
2325
|
+
const B = R.current, D = B.nodesRef.current.find((T) => T.id === v);
|
|
2326
|
+
if (!D) return null;
|
|
2327
|
+
const f = D._absolutePosition || D.position, h = (x = B.handleRegistryRef) == null ? void 0 : x.current, p = `${v}__${n || t}`, M = h == null ? void 0 : h.get(p);
|
|
2328
|
+
if (M && M.x !== void 0 && M.y !== void 0)
|
|
2329
|
+
return { x: f.x + M.x, y: f.y + M.y };
|
|
2330
|
+
const w = D.width || 160, C = D.height || 60;
|
|
2333
2331
|
switch (e) {
|
|
2334
2332
|
case "top":
|
|
2335
2333
|
return { x: f.x + w / 2, y: f.y };
|
|
2336
2334
|
case "bottom":
|
|
2337
|
-
return { x: f.x + w / 2, y: f.y +
|
|
2335
|
+
return { x: f.x + w / 2, y: f.y + C };
|
|
2338
2336
|
case "left":
|
|
2339
|
-
return { x: f.x, y: f.y +
|
|
2337
|
+
return { x: f.x, y: f.y + C / 2 };
|
|
2340
2338
|
default:
|
|
2341
|
-
return { x: f.x + w, y: f.y +
|
|
2339
|
+
return { x: f.x + w, y: f.y + C / 2 };
|
|
2342
2340
|
}
|
|
2343
|
-
}, [
|
|
2341
|
+
}, [v, n, t, e]), E = F((B) => {
|
|
2344
2342
|
var j;
|
|
2345
2343
|
if (!r || !s) return;
|
|
2346
|
-
|
|
2347
|
-
const
|
|
2348
|
-
if (!
|
|
2349
|
-
const
|
|
2350
|
-
if (!
|
|
2351
|
-
const w =
|
|
2352
|
-
(j =
|
|
2344
|
+
B.stopPropagation(), B.preventDefault();
|
|
2345
|
+
const D = R.current, f = D.cameraRef.current, h = D.wrapRef.current;
|
|
2346
|
+
if (!h) return;
|
|
2347
|
+
const p = h.getBoundingClientRect(), M = k();
|
|
2348
|
+
if (!M) return;
|
|
2349
|
+
const w = M.x, C = M.y;
|
|
2350
|
+
(j = D.workerRef.current) == null || j.postMessage({
|
|
2353
2351
|
type: "connecting",
|
|
2354
|
-
data: { from: { x: w, y:
|
|
2355
|
-
}),
|
|
2356
|
-
const
|
|
2352
|
+
data: { from: { x: w, y: C }, to: { x: w, y: C } }
|
|
2353
|
+
}), h.setPointerCapture(B.pointerId);
|
|
2354
|
+
const x = (W) => {
|
|
2357
2355
|
var rt;
|
|
2358
|
-
const xt = (
|
|
2359
|
-
(rt =
|
|
2356
|
+
const xt = (W.clientX - p.left - f.x) / f.zoom, K = (W.clientY - p.top - f.y) / f.zoom;
|
|
2357
|
+
(rt = D.workerRef.current) == null || rt.postMessage({
|
|
2360
2358
|
type: "connecting",
|
|
2361
|
-
data: { from: { x: w, y:
|
|
2359
|
+
data: { from: { x: w, y: C }, to: { x: xt, y: K } }
|
|
2362
2360
|
});
|
|
2363
|
-
},
|
|
2361
|
+
}, T = (W) => {
|
|
2364
2362
|
var lt, ut, st, It;
|
|
2365
|
-
const xt = (
|
|
2363
|
+
const xt = (W.clientX - p.left - f.x) / f.zoom, K = (W.clientY - p.top - f.y) / f.zoom, rt = 20 / f.zoom;
|
|
2366
2364
|
let q = null, G = null;
|
|
2367
|
-
const ot = (lt =
|
|
2368
|
-
for (const it of
|
|
2369
|
-
if (it.id ===
|
|
2370
|
-
const mt = it.width || 160,
|
|
2365
|
+
const ot = (lt = D.handleRegistryRef) == null ? void 0 : lt.current;
|
|
2366
|
+
for (const it of D.nodesRef.current) {
|
|
2367
|
+
if (it.id === v || it.hidden) continue;
|
|
2368
|
+
const mt = it.width || 160, Nt = it.height || 60, zt = it._absolutePosition || it.position, dt = [];
|
|
2371
2369
|
if (ot)
|
|
2372
2370
|
for (const [, Rt] of ot)
|
|
2373
2371
|
Rt.nodeId === it.id && dt.push(Rt);
|
|
@@ -2376,25 +2374,25 @@ function on({
|
|
|
2376
2374
|
{ type: "source", position: "right" }
|
|
2377
2375
|
];
|
|
2378
2376
|
for (const Rt of ht) {
|
|
2379
|
-
let
|
|
2377
|
+
let Lt, gt;
|
|
2380
2378
|
if (Rt.x !== void 0 && Rt.y !== void 0)
|
|
2381
|
-
|
|
2379
|
+
Lt = zt.x + Rt.x, gt = zt.y + Rt.y;
|
|
2382
2380
|
else
|
|
2383
2381
|
switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
|
|
2384
2382
|
case "top":
|
|
2385
|
-
|
|
2383
|
+
Lt = zt.x + mt / 2, gt = zt.y;
|
|
2386
2384
|
break;
|
|
2387
2385
|
case "bottom":
|
|
2388
|
-
|
|
2386
|
+
Lt = zt.x + mt / 2, gt = zt.y + Nt;
|
|
2389
2387
|
break;
|
|
2390
2388
|
case "left":
|
|
2391
|
-
|
|
2389
|
+
Lt = zt.x, gt = zt.y + Nt / 2;
|
|
2392
2390
|
break;
|
|
2393
2391
|
default:
|
|
2394
|
-
|
|
2392
|
+
Lt = zt.x + mt, gt = zt.y + Nt / 2;
|
|
2395
2393
|
break;
|
|
2396
2394
|
}
|
|
2397
|
-
if (Math.abs(xt -
|
|
2395
|
+
if (Math.abs(xt - Lt) < rt && Math.abs(K - gt) < rt) {
|
|
2398
2396
|
q = it, G = Rt.id || null;
|
|
2399
2397
|
break;
|
|
2400
2398
|
}
|
|
@@ -2403,17 +2401,17 @@ function on({
|
|
|
2403
2401
|
}
|
|
2404
2402
|
if (q) {
|
|
2405
2403
|
const it = {
|
|
2406
|
-
source: t === "source" ?
|
|
2407
|
-
target: t === "source" ? q.id :
|
|
2404
|
+
source: t === "source" ? v : q.id,
|
|
2405
|
+
target: t === "source" ? q.id : v,
|
|
2408
2406
|
sourceHandle: t === "source" ? n || null : G,
|
|
2409
2407
|
targetHandle: t === "source" ? G : n || null
|
|
2410
2408
|
};
|
|
2411
|
-
(st = (ut =
|
|
2409
|
+
(st = (ut = D.onEdgesChangeRef) == null ? void 0 : ut.current) == null || st.call(ut, [{ type: "add", item: { id: `e-${it.source}-${it.target}`, ...it } }]);
|
|
2412
2410
|
}
|
|
2413
|
-
(It =
|
|
2411
|
+
(It = D.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), h.removeEventListener("pointermove", x), h.removeEventListener("pointerup", T);
|
|
2414
2412
|
};
|
|
2415
|
-
|
|
2416
|
-
}, [
|
|
2413
|
+
h.addEventListener("pointermove", x), h.addEventListener("pointerup", T);
|
|
2414
|
+
}, [v, n, t, e, r, s, k]), _ = {
|
|
2417
2415
|
top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
|
|
2418
2416
|
bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
|
|
2419
2417
|
left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
|
|
@@ -2425,7 +2423,7 @@ function on({
|
|
|
2425
2423
|
ref: z,
|
|
2426
2424
|
className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
|
|
2427
2425
|
"data-handleid": n || null,
|
|
2428
|
-
"data-nodeid":
|
|
2426
|
+
"data-nodeid": v,
|
|
2429
2427
|
"data-handlepos": e,
|
|
2430
2428
|
"data-handletype": t,
|
|
2431
2429
|
onPointerDown: E,
|
|
@@ -2442,7 +2440,7 @@ function on({
|
|
|
2442
2440
|
..._,
|
|
2443
2441
|
...u
|
|
2444
2442
|
},
|
|
2445
|
-
...
|
|
2443
|
+
...g,
|
|
2446
2444
|
children: i
|
|
2447
2445
|
}
|
|
2448
2446
|
);
|
|
@@ -2576,34 +2574,34 @@ function Vn({
|
|
|
2576
2574
|
labelBgBorderRadius: c = 2,
|
|
2577
2575
|
children: u,
|
|
2578
2576
|
className: l = "",
|
|
2579
|
-
...
|
|
2577
|
+
...g
|
|
2580
2578
|
}) {
|
|
2581
|
-
const [
|
|
2579
|
+
const [v, N] = Gt({ x: 1, y: 0, width: 0, height: 0 }), z = tt(null);
|
|
2582
2580
|
return ft(() => {
|
|
2583
2581
|
if (z.current) {
|
|
2584
|
-
const
|
|
2585
|
-
|
|
2586
|
-
x:
|
|
2587
|
-
y:
|
|
2588
|
-
width:
|
|
2589
|
-
height:
|
|
2582
|
+
const R = z.current.getBBox();
|
|
2583
|
+
N({
|
|
2584
|
+
x: R.x,
|
|
2585
|
+
y: R.y,
|
|
2586
|
+
width: R.width,
|
|
2587
|
+
height: R.height
|
|
2590
2588
|
});
|
|
2591
2589
|
}
|
|
2592
2590
|
}, [n]), n ? /* @__PURE__ */ $t(
|
|
2593
2591
|
"g",
|
|
2594
2592
|
{
|
|
2595
|
-
transform: `translate(${t -
|
|
2593
|
+
transform: `translate(${t - v.width / 2} ${e - v.height / 2})`,
|
|
2596
2594
|
className: `ric-edge-textwrapper ${l}`,
|
|
2597
|
-
visibility:
|
|
2598
|
-
...
|
|
2595
|
+
visibility: v.width ? "visible" : "hidden",
|
|
2596
|
+
...g,
|
|
2599
2597
|
children: [
|
|
2600
2598
|
s && /* @__PURE__ */ S(
|
|
2601
2599
|
"rect",
|
|
2602
2600
|
{
|
|
2603
|
-
width:
|
|
2601
|
+
width: v.width + 2 * i[0],
|
|
2604
2602
|
x: -i[0],
|
|
2605
2603
|
y: -i[1],
|
|
2606
|
-
height:
|
|
2604
|
+
height: v.height + 2 * i[1],
|
|
2607
2605
|
className: "ric-edge-textbg",
|
|
2608
2606
|
style: o,
|
|
2609
2607
|
rx: c,
|
|
@@ -2614,7 +2612,7 @@ function Vn({
|
|
|
2614
2612
|
"text",
|
|
2615
2613
|
{
|
|
2616
2614
|
className: "ric-edge-text",
|
|
2617
|
-
y:
|
|
2615
|
+
y: v.height / 2,
|
|
2618
2616
|
dy: "0.3em",
|
|
2619
2617
|
ref: z,
|
|
2620
2618
|
style: r,
|
|
@@ -2642,14 +2640,14 @@ function un({
|
|
|
2642
2640
|
labelBgStyle: c,
|
|
2643
2641
|
labelBgPadding: u,
|
|
2644
2642
|
labelBgBorderRadius: l,
|
|
2645
|
-
interactionWidth:
|
|
2646
|
-
style:
|
|
2647
|
-
markerEnd:
|
|
2643
|
+
interactionWidth: g = 20,
|
|
2644
|
+
style: v,
|
|
2645
|
+
markerEnd: N,
|
|
2648
2646
|
markerStart: z,
|
|
2649
|
-
className:
|
|
2647
|
+
className: R = "",
|
|
2650
2648
|
...$
|
|
2651
2649
|
}) {
|
|
2652
|
-
return /* @__PURE__ */ $t(
|
|
2650
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
2653
2651
|
/* @__PURE__ */ S(
|
|
2654
2652
|
"path",
|
|
2655
2653
|
{
|
|
@@ -2658,20 +2656,20 @@ function un({
|
|
|
2658
2656
|
fill: "none",
|
|
2659
2657
|
stroke: "#b1b1b7",
|
|
2660
2658
|
strokeWidth: 1.5,
|
|
2661
|
-
className: `ric-edge-path ${
|
|
2662
|
-
style:
|
|
2663
|
-
markerEnd:
|
|
2659
|
+
className: `ric-edge-path ${R}`,
|
|
2660
|
+
style: v,
|
|
2661
|
+
markerEnd: N,
|
|
2664
2662
|
markerStart: z,
|
|
2665
2663
|
...$
|
|
2666
2664
|
}
|
|
2667
2665
|
),
|
|
2668
|
-
|
|
2666
|
+
g ? /* @__PURE__ */ S(
|
|
2669
2667
|
"path",
|
|
2670
2668
|
{
|
|
2671
2669
|
d: e,
|
|
2672
2670
|
fill: "none",
|
|
2673
2671
|
strokeOpacity: 0,
|
|
2674
|
-
strokeWidth:
|
|
2672
|
+
strokeWidth: g,
|
|
2675
2673
|
className: "ric-edge-interaction",
|
|
2676
2674
|
style: { pointerEvents: "stroke" }
|
|
2677
2675
|
}
|
|
@@ -2716,64 +2714,64 @@ const tr = Zt(function({
|
|
|
2716
2714
|
targetPosition: c = "top",
|
|
2717
2715
|
label: u,
|
|
2718
2716
|
labelStyle: l,
|
|
2719
|
-
labelShowBg:
|
|
2720
|
-
labelBgStyle:
|
|
2721
|
-
labelBgPadding:
|
|
2717
|
+
labelShowBg: g,
|
|
2718
|
+
labelBgStyle: v,
|
|
2719
|
+
labelBgPadding: N,
|
|
2722
2720
|
labelBgBorderRadius: z,
|
|
2723
|
-
style:
|
|
2721
|
+
style: R,
|
|
2724
2722
|
markerEnd: $,
|
|
2725
|
-
markerStart:
|
|
2723
|
+
markerStart: k,
|
|
2726
2724
|
interactionWidth: E
|
|
2727
2725
|
}) {
|
|
2728
|
-
let _,
|
|
2729
|
-
const f = _n(n, r, i),
|
|
2730
|
-
let w,
|
|
2726
|
+
let _, B, D;
|
|
2727
|
+
const f = _n(n, r, i), h = _n(s, o, c), p = Math.abs(h.x - f.x), M = Math.max(50, p * 0.5);
|
|
2728
|
+
let w, C, x, T;
|
|
2731
2729
|
switch (i) {
|
|
2732
2730
|
case "left":
|
|
2733
|
-
w = f.x -
|
|
2731
|
+
w = f.x - M, C = f.y;
|
|
2734
2732
|
break;
|
|
2735
2733
|
case "top":
|
|
2736
|
-
w = f.x,
|
|
2734
|
+
w = f.x, C = f.y - M;
|
|
2737
2735
|
break;
|
|
2738
2736
|
case "bottom":
|
|
2739
|
-
w = f.x,
|
|
2737
|
+
w = f.x, C = f.y + M;
|
|
2740
2738
|
break;
|
|
2741
2739
|
default:
|
|
2742
|
-
w = f.x +
|
|
2740
|
+
w = f.x + M, C = f.y;
|
|
2743
2741
|
break;
|
|
2744
2742
|
}
|
|
2745
2743
|
switch (c) {
|
|
2746
2744
|
case "right":
|
|
2747
|
-
|
|
2745
|
+
x = h.x + M, T = h.y;
|
|
2748
2746
|
break;
|
|
2749
2747
|
case "top":
|
|
2750
|
-
|
|
2748
|
+
x = h.x, T = h.y - M;
|
|
2751
2749
|
break;
|
|
2752
2750
|
case "bottom":
|
|
2753
|
-
|
|
2751
|
+
x = h.x, T = h.y + M;
|
|
2754
2752
|
break;
|
|
2755
2753
|
default:
|
|
2756
|
-
|
|
2754
|
+
x = h.x - M, T = h.y;
|
|
2757
2755
|
break;
|
|
2758
2756
|
}
|
|
2759
|
-
_ = `M ${n},${r} L ${f.x},${f.y} C ${w},${
|
|
2760
|
-
const j = 0.5,
|
|
2761
|
-
return
|
|
2757
|
+
_ = `M ${n},${r} L ${f.x},${f.y} C ${w},${C} ${x},${T} ${h.x},${h.y} L ${s},${o}`;
|
|
2758
|
+
const j = 0.5, W = 0.5;
|
|
2759
|
+
return B = W * W * W * f.x + 3 * W * W * j * w + 3 * W * j * j * x + j * j * j * h.x, D = W * W * W * f.y + 3 * W * W * j * C + 3 * W * j * j * T + j * j * j * h.y, /* @__PURE__ */ S(
|
|
2762
2760
|
un,
|
|
2763
2761
|
{
|
|
2764
2762
|
id: e,
|
|
2765
2763
|
path: _,
|
|
2766
|
-
labelX:
|
|
2767
|
-
labelY:
|
|
2764
|
+
labelX: B,
|
|
2765
|
+
labelY: D,
|
|
2768
2766
|
label: u,
|
|
2769
2767
|
labelStyle: l,
|
|
2770
|
-
labelShowBg:
|
|
2771
|
-
labelBgStyle:
|
|
2772
|
-
labelBgPadding:
|
|
2768
|
+
labelShowBg: g,
|
|
2769
|
+
labelBgStyle: v,
|
|
2770
|
+
labelBgPadding: N,
|
|
2773
2771
|
labelBgBorderRadius: z,
|
|
2774
|
-
style:
|
|
2772
|
+
style: R,
|
|
2775
2773
|
markerEnd: $,
|
|
2776
|
-
markerStart:
|
|
2774
|
+
markerStart: k,
|
|
2777
2775
|
interactionWidth: E
|
|
2778
2776
|
}
|
|
2779
2777
|
);
|
|
@@ -2792,42 +2790,42 @@ function nr({
|
|
|
2792
2790
|
targetPosition: o = "left",
|
|
2793
2791
|
curvature: i = 0.25
|
|
2794
2792
|
}) {
|
|
2795
|
-
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u),
|
|
2796
|
-
let
|
|
2793
|
+
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), g = Math.max(l * i, 50);
|
|
2794
|
+
let v, N, z, R;
|
|
2797
2795
|
switch (s) {
|
|
2798
2796
|
case "top":
|
|
2799
|
-
|
|
2797
|
+
v = t, N = e - g;
|
|
2800
2798
|
break;
|
|
2801
2799
|
case "bottom":
|
|
2802
|
-
|
|
2800
|
+
v = t, N = e + g;
|
|
2803
2801
|
break;
|
|
2804
2802
|
case "left":
|
|
2805
|
-
|
|
2803
|
+
v = t - g, N = e;
|
|
2806
2804
|
break;
|
|
2807
2805
|
default:
|
|
2808
|
-
|
|
2806
|
+
v = t + g, N = e;
|
|
2809
2807
|
break;
|
|
2810
2808
|
}
|
|
2811
2809
|
switch (o) {
|
|
2812
2810
|
case "top":
|
|
2813
|
-
z = n,
|
|
2811
|
+
z = n, R = r - g;
|
|
2814
2812
|
break;
|
|
2815
2813
|
case "bottom":
|
|
2816
|
-
z = n,
|
|
2814
|
+
z = n, R = r + g;
|
|
2817
2815
|
break;
|
|
2818
2816
|
case "right":
|
|
2819
|
-
z = n +
|
|
2817
|
+
z = n + g, R = r;
|
|
2820
2818
|
break;
|
|
2821
2819
|
default:
|
|
2822
|
-
z = n -
|
|
2820
|
+
z = n - g, R = r;
|
|
2823
2821
|
break;
|
|
2824
2822
|
}
|
|
2825
|
-
const $ = `M ${t},${e} C ${
|
|
2826
|
-
return [$, _,
|
|
2823
|
+
const $ = `M ${t},${e} C ${v},${N} ${z},${R} ${n},${r}`, k = 0.5, E = 1 - k, _ = E * E * E * t + 3 * E * E * k * v + 3 * E * k * k * z + k * k * k * n, B = E * E * E * e + 3 * E * E * k * N + 3 * E * k * k * R + k * k * k * r;
|
|
2824
|
+
return [$, _, B, 0, 0];
|
|
2827
2825
|
}
|
|
2828
2826
|
function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2829
|
-
const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5,
|
|
2830
|
-
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, g = 0.5, v = g * g * g * t + 3 * g * g * l * i + 3 * g * l * l * c + l * l * l * n, N = g * g * g * e + 3 * g * g * l * e + 3 * g * l * l * r + l * l * l * r;
|
|
2828
|
+
return [u, v, N, 0, 0];
|
|
2831
2829
|
}
|
|
2832
2830
|
function kn({
|
|
2833
2831
|
sourceX: t,
|
|
@@ -2843,11 +2841,11 @@ function kn({
|
|
|
2843
2841
|
if (u) {
|
|
2844
2842
|
if (Math.abs(r - e) < 1)
|
|
2845
2843
|
return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
|
|
2846
|
-
const z = (t + n) / 2,
|
|
2847
|
-
return [`M ${t},${e} L ${z - l},${e} Q ${z},${e} ${z},${e +
|
|
2844
|
+
const z = (t + n) / 2, R = r > e ? 1 : -1;
|
|
2845
|
+
return [`M ${t},${e} L ${z - l},${e} Q ${z},${e} ${z},${e + R * l} L ${z},${r - R * l} Q ${z},${r} ${z + (n > z ? l : -l)},${r} L ${n},${r}`, z, (e + r) / 2, 0, 0];
|
|
2848
2846
|
}
|
|
2849
|
-
const
|
|
2850
|
-
return [`M ${t},${e} L ${t},${
|
|
2847
|
+
const g = (e + r) / 2, v = n > t ? 1 : -1;
|
|
2848
|
+
return [`M ${t},${e} L ${t},${g - l} Q ${t},${g} ${t + v * l},${g} L ${n - v * l},${g} Q ${n},${g} ${n},${g + (r > g ? l : -l)} L ${n},${r}`, (t + n) / 2, g, 0, 0];
|
|
2851
2849
|
}
|
|
2852
2850
|
function zo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2853
2851
|
const [, s, o] = nr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
@@ -2905,20 +2903,20 @@ function ln(t, e) {
|
|
|
2905
2903
|
}
|
|
2906
2904
|
}
|
|
2907
2905
|
function Yr(t, e, n, r, s, o, i, c) {
|
|
2908
|
-
const u = Math.min(t, n), l = Math.max(t, n),
|
|
2909
|
-
if (l <= s || u >= s + i ||
|
|
2910
|
-
const
|
|
2911
|
-
if (t > s +
|
|
2912
|
-
const z = (t + n) / 2,
|
|
2913
|
-
if (z > s +
|
|
2906
|
+
const u = Math.min(t, n), l = Math.max(t, n), g = Math.min(e, r), v = Math.max(e, r);
|
|
2907
|
+
if (l <= s || u >= s + i || v <= o || g >= o + c) return !1;
|
|
2908
|
+
const N = 0.5;
|
|
2909
|
+
if (t > s + N && t < s + i - N && e > o + N && e < o + c - N || n > s + N && n < s + i - N && r > o + N && r < o + c - N) return !0;
|
|
2910
|
+
const z = (t + n) / 2, R = (e + r) / 2;
|
|
2911
|
+
if (z > s + N && z < s + i - N && R > o + N && R < o + c - N) return !0;
|
|
2914
2912
|
const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
|
|
2915
|
-
for (let
|
|
2916
|
-
if (Ur(t, e, n, r, $[
|
|
2913
|
+
for (let k = 0; k < 4; k++)
|
|
2914
|
+
if (Ur(t, e, n, r, $[k][0], $[k][1], $[(k + 1) % 4][0], $[(k + 1) % 4][1])) return !0;
|
|
2917
2915
|
return !1;
|
|
2918
2916
|
}
|
|
2919
2917
|
function Ur(t, e, n, r, s, o, i, c) {
|
|
2920
|
-
const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s),
|
|
2921
|
-
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), g = (n - t) * (o - e) - (r - e) * (s - t), v = (n - t) * (c - e) - (r - e) * (i - t);
|
|
2919
|
+
return (u > 0 && l < 0 || u < 0 && l > 0) && (g > 0 && v < 0 || g < 0 && v > 0);
|
|
2922
2920
|
}
|
|
2923
2921
|
function zn(t, e, n, r, s) {
|
|
2924
2922
|
for (let o = 0; o < s.length; o++) {
|
|
@@ -2958,44 +2956,44 @@ function sr(t, e, n) {
|
|
|
2958
2956
|
r.add(t.x), r.add(e.x), s.add(t.y), s.add(e.y);
|
|
2959
2957
|
const o = Ue + 5;
|
|
2960
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);
|
|
2961
|
-
for (let
|
|
2962
|
-
const
|
|
2963
|
-
r.add(
|
|
2959
|
+
for (let x = 0; x < n.length; x++) {
|
|
2960
|
+
const T = n[x];
|
|
2961
|
+
r.add(T.x), r.add(T.x + T.w), s.add(T.y), s.add(T.y + T.h);
|
|
2964
2962
|
}
|
|
2965
|
-
const i = [...r].sort((
|
|
2966
|
-
for (let
|
|
2967
|
-
for (let
|
|
2968
|
-
const
|
|
2969
|
-
if (z === void 0 ||
|
|
2970
|
-
const E =
|
|
2971
|
-
|
|
2972
|
-
const
|
|
2973
|
-
for (;
|
|
2974
|
-
let
|
|
2975
|
-
for (let q = 1; q <
|
|
2976
|
-
|
|
2977
|
-
const
|
|
2978
|
-
if (
|
|
2963
|
+
const i = [...r].sort((x, T) => x - T), c = [...s].sort((x, T) => x - T), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2964
|
+
for (let x = 0; x < i.length; x++) u.set(i[x], x);
|
|
2965
|
+
for (let x = 0; x < c.length; x++) l.set(c[x], x);
|
|
2966
|
+
const g = i.length, v = c.length, N = (x, T) => T * g + x, z = u.get(t.x), R = l.get(t.y), $ = u.get(e.x), k = l.get(e.y);
|
|
2967
|
+
if (z === void 0 || R === void 0 || $ === void 0 || k === void 0) return null;
|
|
2968
|
+
const E = N(z, R), _ = N($, k), B = new Float64Array(g * v).fill(1 / 0), D = new Float64Array(g * v).fill(1 / 0), f = new Int32Array(g * v).fill(-1), h = new Int8Array(g * v).fill(-1), p = new Uint8Array(g * v);
|
|
2969
|
+
B[E] = 0, D[E] = Math.abs(i[$] - t.x) + Math.abs(c[k] - t.y);
|
|
2970
|
+
const M = [E], w = 15, C = [[1, 0], [-1, 0], [0, 1], [0, -1]];
|
|
2971
|
+
for (; M.length > 0; ) {
|
|
2972
|
+
let x = 0;
|
|
2973
|
+
for (let q = 1; q < M.length; q++)
|
|
2974
|
+
D[M[q]] < D[M[x]] && (x = q);
|
|
2975
|
+
const T = M[x];
|
|
2976
|
+
if (M[x] = M[M.length - 1], M.pop(), T === _) {
|
|
2979
2977
|
const q = [];
|
|
2980
2978
|
let G = _;
|
|
2981
2979
|
for (; G !== -1 && G !== E; ) {
|
|
2982
|
-
const ot = G /
|
|
2980
|
+
const ot = G / g | 0, lt = G % g;
|
|
2983
2981
|
q.unshift({ x: i[lt], y: c[ot] }), G = f[G];
|
|
2984
2982
|
}
|
|
2985
2983
|
return q.unshift({ x: t.x, y: t.y }), jr(q, n);
|
|
2986
2984
|
}
|
|
2987
|
-
if (
|
|
2988
|
-
|
|
2989
|
-
const j =
|
|
2985
|
+
if (p[T]) continue;
|
|
2986
|
+
p[T] = 1;
|
|
2987
|
+
const j = T / g | 0, W = T % g, xt = i[W], K = c[j], rt = h[T];
|
|
2990
2988
|
for (let q = 0; q < 4; q++) {
|
|
2991
|
-
const G =
|
|
2992
|
-
if (G < 0 || G >=
|
|
2993
|
-
const lt =
|
|
2994
|
-
if (
|
|
2989
|
+
const G = W + C[q][0], ot = j + C[q][1];
|
|
2990
|
+
if (G < 0 || G >= g || ot < 0 || ot >= v) continue;
|
|
2991
|
+
const lt = N(G, ot);
|
|
2992
|
+
if (p[lt]) continue;
|
|
2995
2993
|
const ut = i[G], st = c[ot];
|
|
2996
2994
|
if (qr(ut, st, n) || !zn(xt, K, ut, st, n)) continue;
|
|
2997
|
-
const It = Math.abs(ut - xt) + Math.abs(st - K), it = rt >= 0 && rt !== q ? w : 0, mt =
|
|
2998
|
-
mt <
|
|
2995
|
+
const It = Math.abs(ut - xt) + Math.abs(st - K), it = rt >= 0 && rt !== q ? w : 0, mt = B[T] + It + it;
|
|
2996
|
+
mt < B[lt] && (f[lt] = T, h[lt] = q, B[lt] = mt, D[lt] = mt + Math.abs(i[$] - ut) + Math.abs(c[k] - st), M.push(lt));
|
|
2999
2997
|
}
|
|
3000
2998
|
}
|
|
3001
2999
|
return null;
|
|
@@ -3035,8 +3033,8 @@ function Gr(t) {
|
|
|
3035
3033
|
if (i.length < 2) continue;
|
|
3036
3034
|
const c = (i.length - 1) * nn / 2;
|
|
3037
3035
|
for (let u = 0; u < i.length; u++) {
|
|
3038
|
-
const l = i[u],
|
|
3039
|
-
|
|
3036
|
+
const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
|
|
3037
|
+
v && (v[l.segIdx].y += g, v[l.segIdx + 1].y += g);
|
|
3040
3038
|
}
|
|
3041
3039
|
}
|
|
3042
3040
|
}
|
|
@@ -3047,8 +3045,8 @@ function Gr(t) {
|
|
|
3047
3045
|
if (i.length < 2) continue;
|
|
3048
3046
|
const c = (i.length - 1) * nn / 2;
|
|
3049
3047
|
for (let u = 0; u < i.length; u++) {
|
|
3050
|
-
const l = i[u],
|
|
3051
|
-
|
|
3048
|
+
const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
|
|
3049
|
+
v && (v[l.segIdx].x += g, v[l.segIdx + 1].x += g);
|
|
3052
3050
|
}
|
|
3053
3051
|
}
|
|
3054
3052
|
}
|
|
@@ -3073,10 +3071,10 @@ function En(t, e = 6, n = !1) {
|
|
|
3073
3071
|
const r = e;
|
|
3074
3072
|
let s = `M ${t[0].x},${t[0].y}`;
|
|
3075
3073
|
for (let o = 1; o < t.length - 1; o++) {
|
|
3076
|
-
const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y),
|
|
3077
|
-
if (
|
|
3078
|
-
const
|
|
3079
|
-
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), g = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), v = Math.min(r, l / 2, g / 2);
|
|
3075
|
+
if (v > 0.5) {
|
|
3076
|
+
const N = c.x - i.x, z = c.y - i.y, R = u.x - c.x, $ = u.y - c.y, k = Math.sqrt(N * N + z * z) || 1, E = Math.sqrt(R * R + $ * $) || 1;
|
|
3077
|
+
s += ` L ${c.x - N / k * v},${c.y - z / k * v}`, s += ` Q ${c.x},${c.y} ${c.x + R / E * v},${c.y + $ / E * v}`;
|
|
3080
3078
|
} else
|
|
3081
3079
|
s += ` L ${c.x},${c.y}`;
|
|
3082
3080
|
}
|
|
@@ -3090,8 +3088,8 @@ function Zr(t) {
|
|
|
3090
3088
|
const e = 0.3;
|
|
3091
3089
|
let n = `M ${t[0].x},${t[0].y}`;
|
|
3092
3090
|
for (let r = 0; r < t.length - 1; r++) {
|
|
3093
|
-
const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e,
|
|
3094
|
-
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, g = i.x - (c.x - o.x) * e, v = i.y - (c.y - o.y) * e;
|
|
3092
|
+
n += ` C ${u},${l} ${g},${v} ${i.x},${i.y}`;
|
|
3095
3093
|
}
|
|
3096
3094
|
return n;
|
|
3097
3095
|
}
|
|
@@ -3114,30 +3112,30 @@ function Cn(t) {
|
|
|
3114
3112
|
}
|
|
3115
3113
|
return { x: t[0].x, y: t[0].y };
|
|
3116
3114
|
}
|
|
3117
|
-
function
|
|
3115
|
+
function No(t, e) {
|
|
3118
3116
|
if (!t || !e || t.length === 0 || e.length === 0) return e;
|
|
3119
3117
|
const n = {};
|
|
3120
3118
|
for (const o of t) n[o.id] = o;
|
|
3121
3119
|
const r = or(t, null), s = e.map((o) => {
|
|
3122
|
-
var
|
|
3120
|
+
var h, p, M, w;
|
|
3123
3121
|
const i = o.type || "default";
|
|
3124
3122
|
if (i === "bezier" || i === "simplebezier" || i === "default") return o;
|
|
3125
3123
|
const c = n[o.source], u = n[o.target];
|
|
3126
3124
|
if (!c || !u || c.hidden || u.hidden) return o;
|
|
3127
|
-
const l = Wn(c, "source", o.sourceHandle),
|
|
3128
|
-
|
|
3129
|
-
const _ = u._absolutePosition || u.position,
|
|
3130
|
-
if (
|
|
3131
|
-
const f = sr(
|
|
3132
|
-
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x:
|
|
3125
|
+
const l = Wn(c, "source", o.sourceHandle), g = Wn(u, "target", o.targetHandle), v = ln(l, cn), N = ln(g, cn), z = 5, R = r.filter((C) => C.id !== o.source && C.id !== o.target), $ = c._absolutePosition || c.position, k = c.width || ((h = c.measured) == null ? void 0 : h.width) || sn, E = c.height || ((p = c.measured) == null ? void 0 : p.height) || an;
|
|
3126
|
+
R.push({ id: o.source, x: $.x - z, y: $.y - z, w: k + 2 * z, h: E + 2 * z });
|
|
3127
|
+
const _ = u._absolutePosition || u.position, B = u.width || ((M = u.measured) == null ? void 0 : M.width) || sn, D = u.height || ((w = u.measured) == null ? void 0 : w.height) || an;
|
|
3128
|
+
if (R.push({ id: o.target, x: _.x - z, y: _.y - z, w: B + 2 * z, h: D + 2 * z }), R.length === 0) return o;
|
|
3129
|
+
const f = sr(v, N, R);
|
|
3130
|
+
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: g.x, y: g.y }), { ...o, _routedPoints: f }) : o;
|
|
3133
3131
|
});
|
|
3134
3132
|
return Gr(s);
|
|
3135
3133
|
}
|
|
3136
|
-
function
|
|
3134
|
+
function Lo(t, e, n, r, s, o, i, c) {
|
|
3137
3135
|
const u = or(i, c ? new Set(c) : null);
|
|
3138
3136
|
if (u.length === 0) return null;
|
|
3139
|
-
const l = { x: t, y: e, dir: s || "right" },
|
|
3140
|
-
return z && z.length >= 2 ? (z.unshift({ x: l.x, y: l.y }), z.push({ x:
|
|
3137
|
+
const l = { x: t, y: e, dir: s || "right" }, g = { x: n, y: r, dir: o || "left" }, v = ln(l, cn), N = ln(g, cn), z = sr(v, N, u);
|
|
3138
|
+
return z && z.length >= 2 ? (z.unshift({ x: l.x, y: l.y }), z.push({ x: g.x, y: g.y }), z) : null;
|
|
3141
3139
|
}
|
|
3142
3140
|
const ir = Zt(function({
|
|
3143
3141
|
id: e,
|
|
@@ -3149,37 +3147,37 @@ const ir = Zt(function({
|
|
|
3149
3147
|
labelStyle: c,
|
|
3150
3148
|
labelShowBg: u,
|
|
3151
3149
|
labelBgStyle: l,
|
|
3152
|
-
labelBgPadding:
|
|
3153
|
-
labelBgBorderRadius:
|
|
3154
|
-
style:
|
|
3150
|
+
labelBgPadding: g,
|
|
3151
|
+
labelBgBorderRadius: v,
|
|
3152
|
+
style: N,
|
|
3155
3153
|
markerEnd: z,
|
|
3156
|
-
markerStart:
|
|
3154
|
+
markerStart: R,
|
|
3157
3155
|
interactionWidth: $,
|
|
3158
|
-
routedPoints:
|
|
3156
|
+
routedPoints: k
|
|
3159
3157
|
}) {
|
|
3160
|
-
let E, _,
|
|
3161
|
-
if (
|
|
3162
|
-
E = En(
|
|
3163
|
-
const
|
|
3164
|
-
_ =
|
|
3158
|
+
let E, _, B;
|
|
3159
|
+
if (k && k.length >= 2) {
|
|
3160
|
+
E = En(k);
|
|
3161
|
+
const D = Cn(k);
|
|
3162
|
+
_ = D.x, B = D.y;
|
|
3165
3163
|
} else
|
|
3166
|
-
[E, _,
|
|
3164
|
+
[E, _, B] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
|
|
3167
3165
|
return /* @__PURE__ */ S(
|
|
3168
3166
|
un,
|
|
3169
3167
|
{
|
|
3170
3168
|
id: e,
|
|
3171
3169
|
path: E,
|
|
3172
3170
|
labelX: _,
|
|
3173
|
-
labelY:
|
|
3171
|
+
labelY: B,
|
|
3174
3172
|
label: i,
|
|
3175
3173
|
labelStyle: c,
|
|
3176
3174
|
labelShowBg: u,
|
|
3177
3175
|
labelBgStyle: l,
|
|
3178
|
-
labelBgPadding:
|
|
3179
|
-
labelBgBorderRadius:
|
|
3180
|
-
style:
|
|
3176
|
+
labelBgPadding: g,
|
|
3177
|
+
labelBgBorderRadius: v,
|
|
3178
|
+
style: N,
|
|
3181
3179
|
markerEnd: z,
|
|
3182
|
-
markerStart:
|
|
3180
|
+
markerStart: R,
|
|
3183
3181
|
interactionWidth: $
|
|
3184
3182
|
}
|
|
3185
3183
|
);
|
|
@@ -3195,24 +3193,24 @@ const ar = Zt(function({
|
|
|
3195
3193
|
targetPosition: c = "top",
|
|
3196
3194
|
label: u,
|
|
3197
3195
|
labelStyle: l,
|
|
3198
|
-
labelShowBg:
|
|
3199
|
-
labelBgStyle:
|
|
3200
|
-
labelBgPadding:
|
|
3196
|
+
labelShowBg: g,
|
|
3197
|
+
labelBgStyle: v,
|
|
3198
|
+
labelBgPadding: N,
|
|
3201
3199
|
labelBgBorderRadius: z,
|
|
3202
|
-
style:
|
|
3200
|
+
style: R,
|
|
3203
3201
|
markerEnd: $,
|
|
3204
|
-
markerStart:
|
|
3202
|
+
markerStart: k,
|
|
3205
3203
|
pathOptions: E,
|
|
3206
3204
|
interactionWidth: _,
|
|
3207
|
-
routedPoints:
|
|
3205
|
+
routedPoints: B
|
|
3208
3206
|
}) {
|
|
3209
|
-
let
|
|
3210
|
-
if (
|
|
3211
|
-
|
|
3212
|
-
const
|
|
3213
|
-
f =
|
|
3207
|
+
let D, f, h;
|
|
3208
|
+
if (B && B.length >= 2) {
|
|
3209
|
+
D = En(B);
|
|
3210
|
+
const p = Cn(B);
|
|
3211
|
+
f = p.x, h = p.y;
|
|
3214
3212
|
} else
|
|
3215
|
-
[
|
|
3213
|
+
[D, f, h] = kn({
|
|
3216
3214
|
sourceX: n,
|
|
3217
3215
|
sourceY: r,
|
|
3218
3216
|
sourcePosition: i,
|
|
@@ -3226,18 +3224,18 @@ const ar = Zt(function({
|
|
|
3226
3224
|
un,
|
|
3227
3225
|
{
|
|
3228
3226
|
id: e,
|
|
3229
|
-
path:
|
|
3227
|
+
path: D,
|
|
3230
3228
|
labelX: f,
|
|
3231
|
-
labelY:
|
|
3229
|
+
labelY: h,
|
|
3232
3230
|
label: u,
|
|
3233
3231
|
labelStyle: l,
|
|
3234
|
-
labelShowBg:
|
|
3235
|
-
labelBgStyle:
|
|
3236
|
-
labelBgPadding:
|
|
3232
|
+
labelShowBg: g,
|
|
3233
|
+
labelBgStyle: v,
|
|
3234
|
+
labelBgPadding: N,
|
|
3237
3235
|
labelBgBorderRadius: z,
|
|
3238
|
-
style:
|
|
3236
|
+
style: R,
|
|
3239
3237
|
markerEnd: $,
|
|
3240
|
-
markerStart:
|
|
3238
|
+
markerStart: k,
|
|
3241
3239
|
interactionWidth: _
|
|
3242
3240
|
}
|
|
3243
3241
|
);
|
|
@@ -3265,23 +3263,23 @@ const cr = Zt(function({
|
|
|
3265
3263
|
targetPosition: c,
|
|
3266
3264
|
label: u,
|
|
3267
3265
|
labelStyle: l,
|
|
3268
|
-
labelShowBg:
|
|
3269
|
-
labelBgStyle:
|
|
3270
|
-
labelBgPadding:
|
|
3266
|
+
labelShowBg: g,
|
|
3267
|
+
labelBgStyle: v,
|
|
3268
|
+
labelBgPadding: N,
|
|
3271
3269
|
labelBgBorderRadius: z,
|
|
3272
|
-
style:
|
|
3270
|
+
style: R,
|
|
3273
3271
|
markerEnd: $,
|
|
3274
|
-
markerStart:
|
|
3272
|
+
markerStart: k,
|
|
3275
3273
|
interactionWidth: E,
|
|
3276
3274
|
routedPoints: _
|
|
3277
3275
|
}) {
|
|
3278
|
-
let
|
|
3276
|
+
let B, D, f;
|
|
3279
3277
|
if (_ && _.length >= 2) {
|
|
3280
|
-
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3278
|
+
B = En(_);
|
|
3279
|
+
const h = Cn(_);
|
|
3280
|
+
D = h.x, f = h.y;
|
|
3283
3281
|
} else
|
|
3284
|
-
[
|
|
3282
|
+
[B, D, f] = rr({
|
|
3285
3283
|
sourceX: n,
|
|
3286
3284
|
sourceY: r,
|
|
3287
3285
|
targetX: s,
|
|
@@ -3291,18 +3289,18 @@ const cr = Zt(function({
|
|
|
3291
3289
|
un,
|
|
3292
3290
|
{
|
|
3293
3291
|
id: e,
|
|
3294
|
-
path:
|
|
3295
|
-
labelX:
|
|
3292
|
+
path: B,
|
|
3293
|
+
labelX: D,
|
|
3296
3294
|
labelY: f,
|
|
3297
3295
|
label: u,
|
|
3298
3296
|
labelStyle: l,
|
|
3299
|
-
labelShowBg:
|
|
3300
|
-
labelBgStyle:
|
|
3301
|
-
labelBgPadding:
|
|
3297
|
+
labelShowBg: g,
|
|
3298
|
+
labelBgStyle: v,
|
|
3299
|
+
labelBgPadding: N,
|
|
3302
3300
|
labelBgBorderRadius: z,
|
|
3303
|
-
style:
|
|
3301
|
+
style: R,
|
|
3304
3302
|
markerEnd: $,
|
|
3305
|
-
markerStart:
|
|
3303
|
+
markerStart: k,
|
|
3306
3304
|
interactionWidth: E
|
|
3307
3305
|
}
|
|
3308
3306
|
);
|
|
@@ -3332,29 +3330,29 @@ function Io({
|
|
|
3332
3330
|
width: c = "100%",
|
|
3333
3331
|
height: u = "420px",
|
|
3334
3332
|
className: l = "",
|
|
3335
|
-
style:
|
|
3333
|
+
style: g = {},
|
|
3336
3334
|
// Zoom/Camera
|
|
3337
|
-
zoomMin:
|
|
3338
|
-
zoomMax:
|
|
3335
|
+
zoomMin: v,
|
|
3336
|
+
zoomMax: N,
|
|
3339
3337
|
initialCamera: z,
|
|
3340
|
-
fitView:
|
|
3338
|
+
fitView: R,
|
|
3341
3339
|
fitViewOptions: $,
|
|
3342
3340
|
// Node/Edge callbacks
|
|
3343
|
-
onNodesChange:
|
|
3341
|
+
onNodesChange: k,
|
|
3344
3342
|
onEdgesChange: E,
|
|
3345
3343
|
onConnect: _,
|
|
3346
|
-
onConnectStart:
|
|
3347
|
-
onConnectEnd:
|
|
3344
|
+
onConnectStart: B,
|
|
3345
|
+
onConnectEnd: D,
|
|
3348
3346
|
onNodeClick: f,
|
|
3349
|
-
onNodeDoubleClick:
|
|
3350
|
-
onNodeMouseEnter:
|
|
3351
|
-
onNodeMouseMove:
|
|
3347
|
+
onNodeDoubleClick: h,
|
|
3348
|
+
onNodeMouseEnter: p,
|
|
3349
|
+
onNodeMouseMove: M,
|
|
3352
3350
|
onNodeMouseLeave: w,
|
|
3353
|
-
onNodeContextMenu:
|
|
3354
|
-
onNodeDragStart:
|
|
3355
|
-
onNodeDrag:
|
|
3351
|
+
onNodeContextMenu: C,
|
|
3352
|
+
onNodeDragStart: x,
|
|
3353
|
+
onNodeDrag: T,
|
|
3356
3354
|
onNodeDragStop: j,
|
|
3357
|
-
onEdgeClick:
|
|
3355
|
+
onEdgeClick: W,
|
|
3358
3356
|
onEdgeDoubleClick: xt,
|
|
3359
3357
|
onEdgeMouseEnter: K,
|
|
3360
3358
|
onEdgeMouseMove: rt,
|
|
@@ -3367,12 +3365,12 @@ function Io({
|
|
|
3367
3365
|
onPaneMouseLeave: It,
|
|
3368
3366
|
onSelectionChange: it,
|
|
3369
3367
|
onInit: mt,
|
|
3370
|
-
onMoveStart:
|
|
3368
|
+
onMoveStart: Nt,
|
|
3371
3369
|
onMove: zt,
|
|
3372
3370
|
onMoveEnd: dt,
|
|
3373
3371
|
onDelete: ht,
|
|
3374
3372
|
onBeforeDelete: Rt,
|
|
3375
|
-
onError:
|
|
3373
|
+
onError: Lt,
|
|
3376
3374
|
// Drag and drop
|
|
3377
3375
|
onDragOver: gt,
|
|
3378
3376
|
onDrop: ne,
|
|
@@ -3398,7 +3396,7 @@ function Io({
|
|
|
3398
3396
|
panOnScrollMode: dn,
|
|
3399
3397
|
panOnScrollSpeed: fn,
|
|
3400
3398
|
zoomOnScroll: Qt,
|
|
3401
|
-
zoomOnDoubleClick:
|
|
3399
|
+
zoomOnDoubleClick: Nn,
|
|
3402
3400
|
zoomOnPinch: hn,
|
|
3403
3401
|
preventScrolling: fe,
|
|
3404
3402
|
translateExtent: vt,
|
|
@@ -3439,34 +3437,34 @@ function Io({
|
|
|
3439
3437
|
onPointerMove: He,
|
|
3440
3438
|
onPointerUp: _e,
|
|
3441
3439
|
store: le
|
|
3442
|
-
} =
|
|
3440
|
+
} = Lr({
|
|
3443
3441
|
cards: t,
|
|
3444
3442
|
nodes: O,
|
|
3445
3443
|
edges: bt,
|
|
3446
3444
|
dark: o,
|
|
3447
3445
|
gridSize: i,
|
|
3448
|
-
zoomMin:
|
|
3449
|
-
zoomMax:
|
|
3446
|
+
zoomMin: v,
|
|
3447
|
+
zoomMax: N,
|
|
3450
3448
|
initialCamera: z,
|
|
3451
|
-
fitView:
|
|
3449
|
+
fitView: R,
|
|
3452
3450
|
fitViewOptions: $,
|
|
3453
3451
|
onHudUpdate: Ve,
|
|
3454
3452
|
onNodesProcessed: gn,
|
|
3455
|
-
onNodesChange:
|
|
3453
|
+
onNodesChange: k,
|
|
3456
3454
|
onEdgesChange: E,
|
|
3457
3455
|
onConnect: _,
|
|
3458
|
-
onConnectStart:
|
|
3459
|
-
onConnectEnd:
|
|
3456
|
+
onConnectStart: B,
|
|
3457
|
+
onConnectEnd: D,
|
|
3460
3458
|
onNodeClick: f,
|
|
3461
|
-
onNodeDoubleClick:
|
|
3462
|
-
onNodeMouseEnter:
|
|
3463
|
-
onNodeMouseMove:
|
|
3459
|
+
onNodeDoubleClick: h,
|
|
3460
|
+
onNodeMouseEnter: p,
|
|
3461
|
+
onNodeMouseMove: M,
|
|
3464
3462
|
onNodeMouseLeave: w,
|
|
3465
|
-
onNodeContextMenu:
|
|
3466
|
-
onNodeDragStart:
|
|
3467
|
-
onNodeDrag:
|
|
3463
|
+
onNodeContextMenu: C,
|
|
3464
|
+
onNodeDragStart: x,
|
|
3465
|
+
onNodeDrag: T,
|
|
3468
3466
|
onNodeDragStop: j,
|
|
3469
|
-
onEdgeClick:
|
|
3467
|
+
onEdgeClick: W,
|
|
3470
3468
|
onEdgeDoubleClick: xt,
|
|
3471
3469
|
onEdgeMouseEnter: K,
|
|
3472
3470
|
onEdgeMouseMove: rt,
|
|
@@ -3479,12 +3477,12 @@ function Io({
|
|
|
3479
3477
|
onPaneMouseLeave: It,
|
|
3480
3478
|
onSelectionChange: it,
|
|
3481
3479
|
onInit: mt,
|
|
3482
|
-
onMoveStart:
|
|
3480
|
+
onMoveStart: Nt,
|
|
3483
3481
|
onMove: zt,
|
|
3484
3482
|
onMoveEnd: dt,
|
|
3485
3483
|
onDelete: ht,
|
|
3486
3484
|
onBeforeDelete: Rt,
|
|
3487
|
-
onError:
|
|
3485
|
+
onError: Lt,
|
|
3488
3486
|
nodesDraggable: Ot,
|
|
3489
3487
|
nodesConnectable: Yt,
|
|
3490
3488
|
elementsSelectable: me,
|
|
@@ -3504,7 +3502,7 @@ function Io({
|
|
|
3504
3502
|
panOnScrollMode: dn,
|
|
3505
3503
|
panOnScrollSpeed: fn,
|
|
3506
3504
|
zoomOnScroll: Qt,
|
|
3507
|
-
zoomOnDoubleClick:
|
|
3505
|
+
zoomOnDoubleClick: Nn,
|
|
3508
3506
|
zoomOnPinch: hn,
|
|
3509
3507
|
preventScrolling: fe,
|
|
3510
3508
|
translateExtent: vt,
|
|
@@ -3541,7 +3539,7 @@ function Io({
|
|
|
3541
3539
|
{
|
|
3542
3540
|
ref: Dt,
|
|
3543
3541
|
className: `ric-wrap ${l}`,
|
|
3544
|
-
style: { width: c, height: u, ...
|
|
3542
|
+
style: { width: c, height: u, ...g },
|
|
3545
3543
|
onPointerDown: Ae,
|
|
3546
3544
|
onPointerMove: He,
|
|
3547
3545
|
onPointerUp: _e,
|
|
@@ -3650,11 +3648,11 @@ function Io({
|
|
|
3650
3648
|
") zoom: ",
|
|
3651
3649
|
Ut.zoom,
|
|
3652
3650
|
"x",
|
|
3653
|
-
Ut.nodeCount > 0 && /* @__PURE__ */ $t(
|
|
3651
|
+
Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3654
3652
|
" nodes: ",
|
|
3655
3653
|
Ut.nodeCount
|
|
3656
3654
|
] }),
|
|
3657
|
-
Ut.edgeCount > 0 && /* @__PURE__ */ $t(
|
|
3655
|
+
Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3658
3656
|
" edges: ",
|
|
3659
3657
|
Ut.edgeCount
|
|
3660
3658
|
] })
|
|
@@ -3747,97 +3745,103 @@ function So(t) {
|
|
|
3747
3745
|
return [e, n, r];
|
|
3748
3746
|
}
|
|
3749
3747
|
function eo() {
|
|
3750
|
-
const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((
|
|
3751
|
-
var
|
|
3752
|
-
if (typeof
|
|
3753
|
-
const
|
|
3754
|
-
(p = (
|
|
3755
|
-
...t.nodesRef.current.map((
|
|
3756
|
-
...
|
|
3748
|
+
const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((f) => t.nodesRef.current.find((h) => h.id === f), [t]), s = F((f) => t.edgesRef.current.find((h) => h.id === f), [t]), o = F((f) => {
|
|
3749
|
+
var h, p, M, w;
|
|
3750
|
+
if (typeof f == "function") {
|
|
3751
|
+
const C = f(t.nodesRef.current);
|
|
3752
|
+
(p = (h = t.onNodesChangeRef).current) == null || p.call(h, [
|
|
3753
|
+
...t.nodesRef.current.map((x) => ({ id: x.id, type: "remove" })),
|
|
3754
|
+
...C.map((x) => ({ type: "add", item: x }))
|
|
3757
3755
|
]);
|
|
3758
3756
|
} else
|
|
3759
|
-
(
|
|
3760
|
-
...t.nodesRef.current.map((
|
|
3761
|
-
...
|
|
3757
|
+
(w = (M = t.onNodesChangeRef).current) == null || w.call(M, [
|
|
3758
|
+
...t.nodesRef.current.map((C) => ({ id: C.id, type: "remove" })),
|
|
3759
|
+
...f.map((C) => ({ type: "add", item: C }))
|
|
3762
3760
|
]);
|
|
3763
|
-
}, [t]), i = F((
|
|
3764
|
-
var
|
|
3765
|
-
if (typeof
|
|
3766
|
-
const
|
|
3767
|
-
(p = (
|
|
3768
|
-
...t.edgesRef.current.map((
|
|
3769
|
-
...
|
|
3761
|
+
}, [t]), i = F((f) => {
|
|
3762
|
+
var h, p, M, w;
|
|
3763
|
+
if (typeof f == "function") {
|
|
3764
|
+
const C = f(t.edgesRef.current);
|
|
3765
|
+
(p = (h = t.onEdgesChangeRef).current) == null || p.call(h, [
|
|
3766
|
+
...t.edgesRef.current.map((x) => ({ id: x.id, type: "remove" })),
|
|
3767
|
+
...C.map((x) => ({ type: "add", item: x }))
|
|
3770
3768
|
]);
|
|
3771
3769
|
} else
|
|
3772
|
-
(
|
|
3773
|
-
...t.edgesRef.current.map((
|
|
3774
|
-
...
|
|
3770
|
+
(w = (M = t.onEdgesChangeRef).current) == null || w.call(M, [
|
|
3771
|
+
...t.edgesRef.current.map((C) => ({ id: C.id, type: "remove" })),
|
|
3772
|
+
...f.map((C) => ({ type: "add", item: C }))
|
|
3775
3773
|
]);
|
|
3776
|
-
}, [t]), c = F((
|
|
3777
|
-
var p,
|
|
3778
|
-
const
|
|
3779
|
-
(
|
|
3780
|
-
}, [t]), u = F((
|
|
3781
|
-
var p,
|
|
3782
|
-
const
|
|
3783
|
-
(
|
|
3784
|
-
}, [t]), l = F(({ nodes:
|
|
3785
|
-
if (
|
|
3786
|
-
t.onNodesChangeRef.current(
|
|
3787
|
-
const p = zr(
|
|
3788
|
-
p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((
|
|
3774
|
+
}, [t]), c = F((f) => {
|
|
3775
|
+
var p, M;
|
|
3776
|
+
const h = Array.isArray(f) ? f : [f];
|
|
3777
|
+
(M = (p = t.onNodesChangeRef).current) == null || M.call(p, h.map((w) => ({ type: "add", item: w })));
|
|
3778
|
+
}, [t]), u = F((f) => {
|
|
3779
|
+
var p, M;
|
|
3780
|
+
const h = Array.isArray(f) ? f : [f];
|
|
3781
|
+
(M = (p = t.onEdgesChangeRef).current) == null || M.call(p, h.map((w) => ({ type: "add", item: w })));
|
|
3782
|
+
}, [t]), l = F(({ nodes: f = [], edges: h = [] }) => {
|
|
3783
|
+
if (f.length && t.onNodesChangeRef.current) {
|
|
3784
|
+
t.onNodesChangeRef.current(f.map((M) => ({ id: M.id, type: "remove" })));
|
|
3785
|
+
const p = zr(f, t.edgesRef.current);
|
|
3786
|
+
p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((M) => ({ id: M.id, type: "remove" })));
|
|
3789
3787
|
}
|
|
3790
|
-
|
|
3791
|
-
}, [t]),
|
|
3792
|
-
const
|
|
3793
|
-
return { x:
|
|
3794
|
-
}, [t]),
|
|
3788
|
+
h.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(h.map((p) => ({ id: p.id, type: "remove" })));
|
|
3789
|
+
}, [t]), g = F(() => {
|
|
3790
|
+
const f = t.cameraRef.current;
|
|
3791
|
+
return { x: f.x, y: f.y, zoom: f.zoom };
|
|
3792
|
+
}, [t]), v = F((f, h) => {
|
|
3795
3793
|
t.cameraRef.current = {
|
|
3796
|
-
x:
|
|
3797
|
-
y:
|
|
3798
|
-
zoom:
|
|
3794
|
+
x: f.x ?? t.cameraRef.current.x,
|
|
3795
|
+
y: f.y ?? t.cameraRef.current.y,
|
|
3796
|
+
zoom: f.zoom ?? t.cameraRef.current.zoom
|
|
3799
3797
|
}, t.sendCamera();
|
|
3800
|
-
}, [t]),
|
|
3801
|
-
const
|
|
3798
|
+
}, [t]), N = F(() => t.cameraRef.current.zoom, [t]), z = F((f) => {
|
|
3799
|
+
const h = t.cameraRef.current, p = t.wrapRef.current;
|
|
3802
3800
|
if (!p) return;
|
|
3803
|
-
const
|
|
3804
|
-
|
|
3805
|
-
}, [t]),
|
|
3806
|
-
const
|
|
3801
|
+
const M = p.getBoundingClientRect(), w = M.width / 2, C = M.height / 2, x = 1.2;
|
|
3802
|
+
h.x = w - (w - h.x) * x, h.y = C - (C - h.y) * x, h.zoom = Math.min(t.zoomMax, h.zoom * x), t.sendCamera();
|
|
3803
|
+
}, [t]), R = F((f) => {
|
|
3804
|
+
const h = t.cameraRef.current, p = t.wrapRef.current;
|
|
3807
3805
|
if (!p) return;
|
|
3808
|
-
const
|
|
3809
|
-
|
|
3810
|
-
}, [t]), $ = F((
|
|
3811
|
-
const
|
|
3806
|
+
const M = p.getBoundingClientRect(), w = M.width / 2, C = M.height / 2, x = 1 / 1.2;
|
|
3807
|
+
h.x = w - (w - h.x) * x, h.y = C - (C - h.y) * x, h.zoom = Math.max(t.zoomMin, h.zoom * x), t.sendCamera();
|
|
3808
|
+
}, [t]), $ = F((f) => {
|
|
3809
|
+
const h = t.cameraRef.current, p = t.wrapRef.current;
|
|
3812
3810
|
if (!p) return;
|
|
3813
|
-
const
|
|
3814
|
-
|
|
3815
|
-
}, [t]),
|
|
3816
|
-
const
|
|
3817
|
-
if (!
|
|
3811
|
+
const M = p.getBoundingClientRect(), w = M.width / 2, C = M.height / 2, x = f / h.zoom;
|
|
3812
|
+
h.x = w - (w - h.x) * x, h.y = C - (C - h.y) * x, h.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, f)), t.sendCamera();
|
|
3813
|
+
}, [t]), k = F((f = {}) => {
|
|
3814
|
+
const h = t.nodesRef.current;
|
|
3815
|
+
if (!h.length) return;
|
|
3818
3816
|
const p = t.wrapRef.current;
|
|
3819
3817
|
if (!p) return;
|
|
3820
|
-
const
|
|
3821
|
-
if (!
|
|
3822
|
-
const
|
|
3823
|
-
|
|
3824
|
-
}, [t]), E = F((
|
|
3825
|
-
const
|
|
3826
|
-
if (!
|
|
3827
|
-
const
|
|
3818
|
+
const M = p.getBoundingClientRect(), w = f.padding ?? 0.1, C = f.nodes ? h.filter((j) => f.nodes.some((W) => W.id === j.id)) : h;
|
|
3819
|
+
if (!C.length) return;
|
|
3820
|
+
const x = Mn(C), T = Rn(x, M.width, M.height, w);
|
|
3821
|
+
f.maxZoom && (T.zoom = Math.min(T.zoom, f.maxZoom)), f.minZoom && (T.zoom = Math.max(T.zoom, f.minZoom)), t.cameraRef.current = T, t.sendCamera();
|
|
3822
|
+
}, [t]), E = F((f, h, p = {}) => {
|
|
3823
|
+
const M = t.wrapRef.current;
|
|
3824
|
+
if (!M) return;
|
|
3825
|
+
const w = M.getBoundingClientRect(), C = p.zoom ?? t.cameraRef.current.zoom;
|
|
3828
3826
|
t.cameraRef.current = {
|
|
3829
|
-
x:
|
|
3830
|
-
y:
|
|
3831
|
-
zoom:
|
|
3827
|
+
x: w.width / 2 - f * C,
|
|
3828
|
+
y: w.height / 2 - h * C,
|
|
3829
|
+
zoom: C
|
|
3832
3830
|
}, t.sendCamera();
|
|
3833
|
-
}, [t]), _ = F((
|
|
3834
|
-
const
|
|
3831
|
+
}, [t]), _ = F((f) => t.screenToWorld(f.x, f.y), [t]), B = F((f) => {
|
|
3832
|
+
const h = t.cameraRef.current, p = t.wrapRef.current;
|
|
3835
3833
|
if (!p) return { x: 0, y: 0 };
|
|
3836
|
-
const
|
|
3834
|
+
const M = p.getBoundingClientRect();
|
|
3837
3835
|
return {
|
|
3838
|
-
x:
|
|
3839
|
-
y:
|
|
3836
|
+
x: f.x * h.zoom + h.x + M.left,
|
|
3837
|
+
y: f.y * h.zoom + h.y + M.top
|
|
3840
3838
|
};
|
|
3839
|
+
}, [t]), D = F((f, h) => {
|
|
3840
|
+
var w, C;
|
|
3841
|
+
const p = t.nodesRef.current.find((x) => x.id === f);
|
|
3842
|
+
if (!p) return;
|
|
3843
|
+
const M = typeof h == "function" ? h(p.data) : { ...p.data, ...h };
|
|
3844
|
+
(C = (w = t.onNodesChangeRef).current) == null || C.call(w, [{ id: f, type: "replace", item: { ...p, data: M } }]);
|
|
3841
3845
|
}, [t]);
|
|
3842
3846
|
return {
|
|
3843
3847
|
getNodes: e,
|
|
@@ -3849,16 +3853,17 @@ function eo() {
|
|
|
3849
3853
|
addNodes: c,
|
|
3850
3854
|
addEdges: u,
|
|
3851
3855
|
deleteElements: l,
|
|
3852
|
-
getViewport:
|
|
3853
|
-
setViewport:
|
|
3854
|
-
getZoom:
|
|
3856
|
+
getViewport: g,
|
|
3857
|
+
setViewport: v,
|
|
3858
|
+
getZoom: N,
|
|
3855
3859
|
zoomIn: z,
|
|
3856
|
-
zoomOut:
|
|
3860
|
+
zoomOut: R,
|
|
3857
3861
|
zoomTo: $,
|
|
3858
|
-
fitView:
|
|
3862
|
+
fitView: k,
|
|
3859
3863
|
setCenter: E,
|
|
3860
3864
|
screenToFlowPosition: _,
|
|
3861
|
-
flowToScreenPosition:
|
|
3865
|
+
flowToScreenPosition: B,
|
|
3866
|
+
updateNodeData: D
|
|
3862
3867
|
};
|
|
3863
3868
|
}
|
|
3864
3869
|
function Bo() {
|
|
@@ -3969,52 +3974,52 @@ function Qo({
|
|
|
3969
3974
|
style: o = {},
|
|
3970
3975
|
className: i = ""
|
|
3971
3976
|
}) {
|
|
3972
|
-
const c = yt(), u = tt(null), l = tt(null),
|
|
3973
|
-
const
|
|
3974
|
-
if (!
|
|
3975
|
-
const
|
|
3976
|
-
|
|
3977
|
-
const
|
|
3978
|
-
if (!
|
|
3979
|
-
let $ = 1 / 0,
|
|
3980
|
-
for (const
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3977
|
+
const c = yt(), u = tt(null), l = tt(null), g = F(() => {
|
|
3978
|
+
const v = u.current;
|
|
3979
|
+
if (!v) return;
|
|
3980
|
+
const N = v.getContext("2d"), z = window.devicePixelRatio || 1;
|
|
3981
|
+
v.width = t * z, v.height = e * z, N.scale(z, z), N.clearRect(0, 0, t, e);
|
|
3982
|
+
const R = c.nodesRef.current;
|
|
3983
|
+
if (!R.length) return;
|
|
3984
|
+
let $ = 1 / 0, k = 1 / 0, E = -1 / 0, _ = -1 / 0;
|
|
3985
|
+
for (const x of R) {
|
|
3986
|
+
const T = x.width || wn, j = x.height || bn;
|
|
3987
|
+
x.position.x < $ && ($ = x.position.x), x.position.y < k && (k = x.position.y), x.position.x + T > E && (E = x.position.x + T), x.position.y + j > _ && (_ = x.position.y + j);
|
|
3983
3988
|
}
|
|
3984
|
-
const
|
|
3985
|
-
$ -=
|
|
3986
|
-
const
|
|
3987
|
-
for (const
|
|
3988
|
-
if (
|
|
3989
|
-
const
|
|
3990
|
-
|
|
3989
|
+
const B = 40;
|
|
3990
|
+
$ -= B, k -= B, E += B, _ += B;
|
|
3991
|
+
const D = E - $, f = _ - k, h = Math.min(t / D, e / f), p = (t - D * h) / 2, M = (e - f * h) / 2;
|
|
3992
|
+
for (const x of R) {
|
|
3993
|
+
if (x.hidden) continue;
|
|
3994
|
+
const T = x.width || wn, j = x.height || bn, W = (x.position.x - $) * h + p, xt = (x.position.y - k) * h + M, K = T * h, rt = j * h;
|
|
3995
|
+
N.fillStyle = x.selected ? "#f59e0b" : typeof n == "function" ? n(x) : n, N.fillRect(W, xt, Math.max(K, 2), Math.max(rt, 2));
|
|
3991
3996
|
}
|
|
3992
|
-
const w = c.cameraRef.current,
|
|
3993
|
-
if (
|
|
3994
|
-
const
|
|
3995
|
-
|
|
3996
|
-
const K = (
|
|
3997
|
-
|
|
3998
|
-
for (const ot of
|
|
3997
|
+
const w = c.cameraRef.current, C = c.wrapRef.current;
|
|
3998
|
+
if (C) {
|
|
3999
|
+
const x = C.getBoundingClientRect(), T = -w.x / w.zoom, j = -w.y / w.zoom, W = x.width / w.zoom, xt = x.height / w.zoom;
|
|
4000
|
+
N.fillStyle = s, N.fillRect(0, 0, t, e);
|
|
4001
|
+
const K = (T - $) * h + p, rt = (j - k) * h + M, q = W * h, G = xt * h;
|
|
4002
|
+
N.clearRect(K, rt, q, G);
|
|
4003
|
+
for (const ot of R) {
|
|
3999
4004
|
if (ot.hidden) continue;
|
|
4000
|
-
const lt = ot.width || wn, ut = ot.height || bn, st = (ot.position.x - $) *
|
|
4001
|
-
|
|
4005
|
+
const lt = ot.width || wn, ut = ot.height || bn, st = (ot.position.x - $) * h + p, It = (ot.position.y - k) * h + M;
|
|
4006
|
+
N.fillStyle = ot.selected ? "#f59e0b" : typeof n == "function" ? n(ot) : n, N.fillRect(st, It, Math.max(lt * h, 2), Math.max(ut * h, 2));
|
|
4002
4007
|
}
|
|
4003
|
-
|
|
4008
|
+
N.strokeStyle = "#3b82f6", N.lineWidth = 1.5, N.strokeRect(K, rt, q, G);
|
|
4004
4009
|
}
|
|
4005
4010
|
}, [c, t, e, n, r, s]);
|
|
4006
4011
|
return ft(() => {
|
|
4007
|
-
let
|
|
4008
|
-
function
|
|
4009
|
-
|
|
4012
|
+
let v = !0;
|
|
4013
|
+
function N() {
|
|
4014
|
+
v && (g(), l.current = requestAnimationFrame(N));
|
|
4010
4015
|
}
|
|
4011
4016
|
const z = setInterval(() => {
|
|
4012
|
-
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(
|
|
4017
|
+
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(N);
|
|
4013
4018
|
}, 66);
|
|
4014
|
-
return
|
|
4015
|
-
|
|
4019
|
+
return g(), () => {
|
|
4020
|
+
v = !1, clearInterval(z), cancelAnimationFrame(l.current);
|
|
4016
4021
|
};
|
|
4017
|
-
}, [
|
|
4022
|
+
}, [g]), /* @__PURE__ */ S(
|
|
4018
4023
|
"canvas",
|
|
4019
4024
|
{
|
|
4020
4025
|
ref: u,
|
|
@@ -4080,21 +4085,21 @@ function ao({
|
|
|
4080
4085
|
onInteractiveChange: c,
|
|
4081
4086
|
position: u = "bottom-left",
|
|
4082
4087
|
orientation: l = "vertical",
|
|
4083
|
-
style:
|
|
4084
|
-
className:
|
|
4085
|
-
"aria-label":
|
|
4088
|
+
style: g = {},
|
|
4089
|
+
className: v = "",
|
|
4090
|
+
"aria-label": N = "Canvas controls",
|
|
4086
4091
|
children: z
|
|
4087
4092
|
}) {
|
|
4088
|
-
const
|
|
4093
|
+
const R = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [B, D] = Gt(!0), f = _() <= R.zoomMin, h = _() >= R.zoomMax, p = F(() => {
|
|
4089
4094
|
$(), s == null || s();
|
|
4090
|
-
}, [$, s]),
|
|
4091
|
-
|
|
4092
|
-
}, [
|
|
4095
|
+
}, [$, s]), M = F(() => {
|
|
4096
|
+
k(), o == null || o();
|
|
4097
|
+
}, [k, o]), w = F(() => {
|
|
4093
4098
|
E(r || { padding: 0.1 }), i == null || i();
|
|
4094
|
-
}, [E, r, i]),
|
|
4095
|
-
const
|
|
4096
|
-
|
|
4097
|
-
}, [
|
|
4099
|
+
}, [E, r, i]), C = F(() => {
|
|
4100
|
+
const T = !B;
|
|
4101
|
+
D(T), c == null || c(T);
|
|
4102
|
+
}, [B, c]), x = {
|
|
4098
4103
|
"top-left": { top: 10, left: 10 },
|
|
4099
4104
|
"top-right": { top: 10, right: 10 },
|
|
4100
4105
|
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -4105,25 +4110,25 @@ function ao({
|
|
|
4105
4110
|
return /* @__PURE__ */ $t(
|
|
4106
4111
|
"div",
|
|
4107
4112
|
{
|
|
4108
|
-
className: `ric-controls ${
|
|
4113
|
+
className: `ric-controls ${v}`,
|
|
4109
4114
|
style: {
|
|
4110
4115
|
position: "absolute",
|
|
4111
4116
|
display: "flex",
|
|
4112
4117
|
flexDirection: l === "horizontal" ? "row" : "column",
|
|
4113
4118
|
gap: 2,
|
|
4114
4119
|
zIndex: 5,
|
|
4115
|
-
...
|
|
4116
|
-
...
|
|
4120
|
+
...x,
|
|
4121
|
+
...g
|
|
4117
4122
|
},
|
|
4118
4123
|
role: "toolbar",
|
|
4119
|
-
"aria-label":
|
|
4124
|
+
"aria-label": N,
|
|
4120
4125
|
children: [
|
|
4121
|
-
t && /* @__PURE__ */ $t(
|
|
4126
|
+
t && /* @__PURE__ */ $t(Le, { children: [
|
|
4122
4127
|
/* @__PURE__ */ S(
|
|
4123
4128
|
rn,
|
|
4124
4129
|
{
|
|
4125
|
-
onClick:
|
|
4126
|
-
disabled:
|
|
4130
|
+
onClick: p,
|
|
4131
|
+
disabled: h,
|
|
4127
4132
|
title: "Zoom in",
|
|
4128
4133
|
"aria-label": "Zoom in",
|
|
4129
4134
|
className: "ric-controls-zoomin",
|
|
@@ -4133,7 +4138,7 @@ function ao({
|
|
|
4133
4138
|
/* @__PURE__ */ S(
|
|
4134
4139
|
rn,
|
|
4135
4140
|
{
|
|
4136
|
-
onClick:
|
|
4141
|
+
onClick: M,
|
|
4137
4142
|
disabled: f,
|
|
4138
4143
|
title: "Zoom out",
|
|
4139
4144
|
"aria-label": "Zoom out",
|
|
@@ -4155,11 +4160,11 @@ function ao({
|
|
|
4155
4160
|
n && /* @__PURE__ */ S(
|
|
4156
4161
|
rn,
|
|
4157
4162
|
{
|
|
4158
|
-
onClick:
|
|
4159
|
-
title:
|
|
4160
|
-
"aria-label":
|
|
4163
|
+
onClick: C,
|
|
4164
|
+
title: B ? "Lock interactivity" : "Unlock interactivity",
|
|
4165
|
+
"aria-label": B ? "Lock interactivity" : "Unlock interactivity",
|
|
4161
4166
|
className: "ric-controls-interactive",
|
|
4162
|
-
children:
|
|
4167
|
+
children: B ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
|
|
4163
4168
|
}
|
|
4164
4169
|
),
|
|
4165
4170
|
z
|
|
@@ -4237,34 +4242,34 @@ function ts({
|
|
|
4237
4242
|
color: c = "#3b82f6",
|
|
4238
4243
|
onResizeStart: u,
|
|
4239
4244
|
onResize: l,
|
|
4240
|
-
onResizeEnd:
|
|
4245
|
+
onResizeEnd: g
|
|
4241
4246
|
}) {
|
|
4242
|
-
const
|
|
4247
|
+
const v = qe(je), N = yt(), z = tt(null), R = F((E, _) => {
|
|
4243
4248
|
E.stopPropagation(), E.preventDefault();
|
|
4244
|
-
const
|
|
4245
|
-
if (!
|
|
4249
|
+
const B = N.nodesRef.current.find((h) => h.id === v);
|
|
4250
|
+
if (!B) return;
|
|
4246
4251
|
z.current = {
|
|
4247
4252
|
direction: _,
|
|
4248
4253
|
startX: E.clientX,
|
|
4249
4254
|
startY: E.clientY,
|
|
4250
|
-
width:
|
|
4251
|
-
height:
|
|
4255
|
+
width: B.width || 160,
|
|
4256
|
+
height: B.height || 60
|
|
4252
4257
|
}, u == null || u(E, { width: z.current.width, height: z.current.height });
|
|
4253
|
-
const
|
|
4254
|
-
var j,
|
|
4258
|
+
const D = (h) => {
|
|
4259
|
+
var j, W;
|
|
4255
4260
|
if (!z.current) return;
|
|
4256
|
-
const
|
|
4257
|
-
let
|
|
4258
|
-
|
|
4259
|
-
{ id:
|
|
4260
|
-
]), l == null || l(
|
|
4261
|
-
}, f = (
|
|
4262
|
-
z.current = null,
|
|
4261
|
+
const p = z.current, M = N.cameraRef.current, w = (h.clientX - p.startX) / M.zoom, C = (h.clientY - p.startY) / M.zoom;
|
|
4262
|
+
let x = p.width, T = p.height;
|
|
4263
|
+
p.direction.includes("e") && (x = Math.min(n, Math.max(t, p.width + w))), p.direction.includes("w") && (x = Math.min(n, Math.max(t, p.width - w))), p.direction.includes("s") && (T = Math.min(r, Math.max(e, p.height + C))), p.direction.includes("n") && (T = Math.min(r, Math.max(e, p.height - C))), (W = (j = N.onNodesChangeRef).current) == null || W.call(j, [
|
|
4264
|
+
{ id: v, type: "dimensions", dimensions: { width: x, height: T }, setAttributes: !0 }
|
|
4265
|
+
]), l == null || l(h, { width: x, height: T });
|
|
4266
|
+
}, f = (h) => {
|
|
4267
|
+
z.current = null, g == null || g(h, {}), window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", f);
|
|
4263
4268
|
};
|
|
4264
|
-
window.addEventListener("pointermove",
|
|
4265
|
-
}, [
|
|
4269
|
+
window.addEventListener("pointermove", D), window.addEventListener("pointerup", f);
|
|
4270
|
+
}, [v, N, t, e, n, r, u, l, g]);
|
|
4266
4271
|
if (!s) return null;
|
|
4267
|
-
const $ = 8,
|
|
4272
|
+
const $ = 8, k = {
|
|
4268
4273
|
position: "absolute",
|
|
4269
4274
|
width: $,
|
|
4270
4275
|
height: $,
|
|
@@ -4274,61 +4279,61 @@ function ts({
|
|
|
4274
4279
|
zIndex: 20,
|
|
4275
4280
|
...o
|
|
4276
4281
|
};
|
|
4277
|
-
return /* @__PURE__ */ $t(
|
|
4282
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
4278
4283
|
/* @__PURE__ */ S(
|
|
4279
4284
|
"div",
|
|
4280
4285
|
{
|
|
4281
|
-
style: { ...
|
|
4282
|
-
onPointerDown: (E) =>
|
|
4286
|
+
style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
|
|
4287
|
+
onPointerDown: (E) => R(E, "se")
|
|
4283
4288
|
}
|
|
4284
4289
|
),
|
|
4285
4290
|
/* @__PURE__ */ S(
|
|
4286
4291
|
"div",
|
|
4287
4292
|
{
|
|
4288
|
-
style: { ...
|
|
4289
|
-
onPointerDown: (E) =>
|
|
4293
|
+
style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
|
|
4294
|
+
onPointerDown: (E) => R(E, "sw")
|
|
4290
4295
|
}
|
|
4291
4296
|
),
|
|
4292
4297
|
/* @__PURE__ */ S(
|
|
4293
4298
|
"div",
|
|
4294
4299
|
{
|
|
4295
|
-
style: { ...
|
|
4296
|
-
onPointerDown: (E) =>
|
|
4300
|
+
style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
|
|
4301
|
+
onPointerDown: (E) => R(E, "ne")
|
|
4297
4302
|
}
|
|
4298
4303
|
),
|
|
4299
4304
|
/* @__PURE__ */ S(
|
|
4300
4305
|
"div",
|
|
4301
4306
|
{
|
|
4302
|
-
style: { ...
|
|
4303
|
-
onPointerDown: (E) =>
|
|
4307
|
+
style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
|
|
4308
|
+
onPointerDown: (E) => R(E, "nw")
|
|
4304
4309
|
}
|
|
4305
4310
|
),
|
|
4306
4311
|
/* @__PURE__ */ S(
|
|
4307
4312
|
"div",
|
|
4308
4313
|
{
|
|
4309
|
-
style: { ...
|
|
4310
|
-
onPointerDown: (E) =>
|
|
4314
|
+
style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4315
|
+
onPointerDown: (E) => R(E, "e")
|
|
4311
4316
|
}
|
|
4312
4317
|
),
|
|
4313
4318
|
/* @__PURE__ */ S(
|
|
4314
4319
|
"div",
|
|
4315
4320
|
{
|
|
4316
|
-
style: { ...
|
|
4317
|
-
onPointerDown: (E) =>
|
|
4321
|
+
style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4322
|
+
onPointerDown: (E) => R(E, "w")
|
|
4318
4323
|
}
|
|
4319
4324
|
),
|
|
4320
4325
|
/* @__PURE__ */ S(
|
|
4321
4326
|
"div",
|
|
4322
4327
|
{
|
|
4323
|
-
style: { ...
|
|
4324
|
-
onPointerDown: (E) =>
|
|
4328
|
+
style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4329
|
+
onPointerDown: (E) => R(E, "n")
|
|
4325
4330
|
}
|
|
4326
4331
|
),
|
|
4327
4332
|
/* @__PURE__ */ S(
|
|
4328
4333
|
"div",
|
|
4329
4334
|
{
|
|
4330
|
-
style: { ...
|
|
4331
|
-
onPointerDown: (E) =>
|
|
4335
|
+
style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4336
|
+
onPointerDown: (E) => R(E, "s")
|
|
4332
4337
|
}
|
|
4333
4338
|
)
|
|
4334
4339
|
] });
|
|
@@ -4342,9 +4347,9 @@ function es({
|
|
|
4342
4347
|
style: o = {},
|
|
4343
4348
|
className: i = ""
|
|
4344
4349
|
}) {
|
|
4345
|
-
const c = qe(je), l = yt().nodes.find((
|
|
4350
|
+
const c = qe(je), l = yt().nodes.find((N) => N.id === c);
|
|
4346
4351
|
if (!(t !== void 0 ? t : l == null ? void 0 : l.selected)) return null;
|
|
4347
|
-
const
|
|
4352
|
+
const v = {
|
|
4348
4353
|
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 },
|
|
4349
4354
|
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 },
|
|
4350
4355
|
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 },
|
|
@@ -4358,10 +4363,10 @@ function es({
|
|
|
4358
4363
|
position: "absolute",
|
|
4359
4364
|
zIndex: 1e3,
|
|
4360
4365
|
pointerEvents: "all",
|
|
4361
|
-
...
|
|
4366
|
+
...v,
|
|
4362
4367
|
...o
|
|
4363
4368
|
},
|
|
4364
|
-
onPointerDown: (
|
|
4369
|
+
onPointerDown: (N) => N.stopPropagation(),
|
|
4365
4370
|
children: s
|
|
4366
4371
|
}
|
|
4367
4372
|
);
|
|
@@ -4529,7 +4534,7 @@ export {
|
|
|
4529
4534
|
vo as boxToRect,
|
|
4530
4535
|
or as buildObstacles,
|
|
4531
4536
|
Tn as clampPosition,
|
|
4532
|
-
|
|
4537
|
+
No as computeRoutedEdges,
|
|
4533
4538
|
zo as getBezierEdgeCenter,
|
|
4534
4539
|
nr as getBezierPath,
|
|
4535
4540
|
wo as getBoundsOfBoxes,
|
|
@@ -4552,14 +4557,14 @@ export {
|
|
|
4552
4557
|
Mo as nodeToRect,
|
|
4553
4558
|
Co as reconnectEdge,
|
|
4554
4559
|
mo as rectToBox,
|
|
4555
|
-
|
|
4560
|
+
Lo as routeSinglePath,
|
|
4556
4561
|
En as routedPointsToPath,
|
|
4557
4562
|
Pn as snapPosition,
|
|
4558
4563
|
Ho as useConnection,
|
|
4559
4564
|
Do as useEdges,
|
|
4560
4565
|
So as useEdgesState,
|
|
4561
4566
|
Xo as useHandleConnections,
|
|
4562
|
-
|
|
4567
|
+
Lr as useInfiniteCanvas,
|
|
4563
4568
|
Go as useInternalNode,
|
|
4564
4569
|
Uo as useKeyPress,
|
|
4565
4570
|
Wo as useNodeConnections,
|