@infinit-canvas/react 0.1.7 → 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 -863
- 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,7 +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
|
-
visibility:
|
|
1962
|
+
visibility: g ? "visible" : "hidden",
|
|
1963
1963
|
outline: "none"
|
|
1964
1964
|
},
|
|
1965
1965
|
"data-nodeid": t.id,
|
|
@@ -2000,32 +2000,32 @@ function Bn(t, e, n, r) {
|
|
|
2000
2000
|
var c, u;
|
|
2001
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;
|
|
2002
2002
|
if (t.handleBounds) {
|
|
2003
|
-
const l = t.handleBounds[e] || [],
|
|
2004
|
-
if (
|
|
2005
|
-
const
|
|
2006
|
-
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 };
|
|
2007
2007
|
}
|
|
2008
2008
|
}
|
|
2009
2009
|
if (r) {
|
|
2010
|
-
const l = `${t.id}__${n || e}`,
|
|
2011
|
-
if (
|
|
2012
|
-
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") };
|
|
2013
2013
|
}
|
|
2014
2014
|
if (t.handles && t.handles.length) {
|
|
2015
2015
|
for (const l of t.handles)
|
|
2016
2016
|
if (l.type === e && (!n || l.id === n)) {
|
|
2017
2017
|
if (l.x !== void 0 && l.y !== void 0)
|
|
2018
2018
|
return { x: i.x + l.x, y: i.y + l.y, position: l.position || (e === "source" ? "right" : "left") };
|
|
2019
|
-
const
|
|
2020
|
-
switch (
|
|
2019
|
+
const g = l.position || (e === "source" ? "right" : "left");
|
|
2020
|
+
switch (g) {
|
|
2021
2021
|
case "top":
|
|
2022
|
-
return { x: i.x + s / 2, y: i.y, position:
|
|
2022
|
+
return { x: i.x + s / 2, y: i.y, position: g };
|
|
2023
2023
|
case "bottom":
|
|
2024
|
-
return { x: i.x + s / 2, y: i.y + o, position:
|
|
2024
|
+
return { x: i.x + s / 2, y: i.y + o, position: g };
|
|
2025
2025
|
case "left":
|
|
2026
|
-
return { x: i.x, y: i.y + o / 2, position:
|
|
2026
|
+
return { x: i.x, y: i.y + o / 2, position: g };
|
|
2027
2027
|
default:
|
|
2028
|
-
return { x: i.x + s, y: i.y + o / 2, position:
|
|
2028
|
+
return { x: i.x + s, y: i.y + o / 2, position: g };
|
|
2029
2029
|
}
|
|
2030
2030
|
}
|
|
2031
2031
|
}
|
|
@@ -2053,32 +2053,32 @@ function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
|
2053
2053
|
);
|
|
2054
2054
|
}
|
|
2055
2055
|
function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
2056
|
-
var
|
|
2057
|
-
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) => {
|
|
2058
2058
|
var rt;
|
|
2059
|
-
|
|
2060
|
-
const
|
|
2061
|
-
if (!
|
|
2062
|
-
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;
|
|
2063
2063
|
(rt = s.workerRef.current) == null || rt.postMessage({
|
|
2064
2064
|
type: "connecting",
|
|
2065
|
-
data: { from: { x:
|
|
2065
|
+
data: { from: { x: T.x, y: T.y }, to: { x: T.x, y: T.y } }
|
|
2066
2066
|
});
|
|
2067
|
-
const
|
|
2067
|
+
const W = x.getBoundingClientRect(), xt = (q) => {
|
|
2068
2068
|
var ut;
|
|
2069
|
-
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;
|
|
2070
2070
|
(ut = s.workerRef.current) == null || ut.postMessage({
|
|
2071
2071
|
type: "connecting",
|
|
2072
|
-
data: { from: { x:
|
|
2072
|
+
data: { from: { x: T.x, y: T.y }, to: { x: ot, y: lt } }
|
|
2073
2073
|
});
|
|
2074
2074
|
}, K = (q) => {
|
|
2075
|
-
var mt,
|
|
2076
|
-
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;
|
|
2077
2077
|
let st = null, It = null;
|
|
2078
2078
|
const it = (mt = s.handleRegistryRef) == null ? void 0 : mt.current;
|
|
2079
2079
|
for (const ht of s.nodesRef.current) {
|
|
2080
2080
|
if (ht.hidden) continue;
|
|
2081
|
-
const Rt = ht.width || On,
|
|
2081
|
+
const Rt = ht.width || On, Lt = ht.height || Qn, gt = ht._absolutePosition || ht.position, ne = [];
|
|
2082
2082
|
if (it)
|
|
2083
2083
|
for (const [, Bt] of it)
|
|
2084
2084
|
Bt.nodeId === ht.id && ne.push(Bt);
|
|
@@ -2096,13 +2096,13 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2096
2096
|
Ot = gt.x + Rt / 2, Yt = gt.y;
|
|
2097
2097
|
break;
|
|
2098
2098
|
case "bottom":
|
|
2099
|
-
Ot = gt.x + Rt / 2, Yt = gt.y +
|
|
2099
|
+
Ot = gt.x + Rt / 2, Yt = gt.y + Lt;
|
|
2100
2100
|
break;
|
|
2101
2101
|
case "left":
|
|
2102
|
-
Ot = gt.x, Yt = gt.y +
|
|
2102
|
+
Ot = gt.x, Yt = gt.y + Lt / 2;
|
|
2103
2103
|
break;
|
|
2104
2104
|
default:
|
|
2105
|
-
Ot = gt.x + Rt, Yt = gt.y +
|
|
2105
|
+
Ot = gt.x + Rt, Yt = gt.y + Lt / 2;
|
|
2106
2106
|
break;
|
|
2107
2107
|
}
|
|
2108
2108
|
if (Math.abs(ot - Ot) < ut && Math.abs(lt - Yt) < ut) {
|
|
@@ -2113,17 +2113,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2113
2113
|
if (st) break;
|
|
2114
2114
|
}
|
|
2115
2115
|
if (st) {
|
|
2116
|
-
const ht =
|
|
2117
|
-
(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, [
|
|
2118
2118
|
{ id: t.id, type: "remove" },
|
|
2119
2119
|
{ type: "add", item: { id: t.id, ...ht } }
|
|
2120
2120
|
]);
|
|
2121
2121
|
}
|
|
2122
|
-
(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);
|
|
2123
2123
|
};
|
|
2124
|
-
|
|
2125
|
-
}, [t, s]), u = n.find((
|
|
2126
|
-
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(
|
|
2127
2127
|
"g",
|
|
2128
2128
|
{
|
|
2129
2129
|
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
@@ -2139,10 +2139,10 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2139
2139
|
target: t.target,
|
|
2140
2140
|
sourceX: z.x,
|
|
2141
2141
|
sourceY: z.y,
|
|
2142
|
-
targetX:
|
|
2143
|
-
targetY:
|
|
2142
|
+
targetX: R.x,
|
|
2143
|
+
targetY: R.y,
|
|
2144
2144
|
sourcePosition: z.position,
|
|
2145
|
-
targetPosition:
|
|
2145
|
+
targetPosition: R.position,
|
|
2146
2146
|
sourceHandleId: t.sourceHandle,
|
|
2147
2147
|
targetHandleId: t.targetHandle,
|
|
2148
2148
|
data: t.data,
|
|
@@ -2156,7 +2156,7 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2156
2156
|
routedPoints: _
|
|
2157
2157
|
}
|
|
2158
2158
|
),
|
|
2159
|
-
|
|
2159
|
+
B && (o || t.selected) && /* @__PURE__ */ $t(Le, { children: [
|
|
2160
2160
|
/* @__PURE__ */ S(
|
|
2161
2161
|
Dn,
|
|
2162
2162
|
{
|
|
@@ -2164,17 +2164,17 @@ function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
|
2164
2164
|
y: z.y,
|
|
2165
2165
|
position: z.position,
|
|
2166
2166
|
type: "source",
|
|
2167
|
-
onPointerDown: (
|
|
2167
|
+
onPointerDown: (p) => c("source", p, z, R)
|
|
2168
2168
|
}
|
|
2169
2169
|
),
|
|
2170
2170
|
/* @__PURE__ */ S(
|
|
2171
2171
|
Dn,
|
|
2172
2172
|
{
|
|
2173
|
-
x:
|
|
2174
|
-
y:
|
|
2175
|
-
position:
|
|
2173
|
+
x: R.x,
|
|
2174
|
+
y: R.y,
|
|
2175
|
+
position: R.position,
|
|
2176
2176
|
type: "target",
|
|
2177
|
-
onPointerDown: (
|
|
2177
|
+
onPointerDown: (p) => c("target", p, z, R)
|
|
2178
2178
|
}
|
|
2179
2179
|
)
|
|
2180
2180
|
] })
|
|
@@ -2187,46 +2187,46 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2187
2187
|
var $;
|
|
2188
2188
|
const n = yt(), [r, s] = Gt(null), o = tt(null);
|
|
2189
2189
|
if (ft(() => {
|
|
2190
|
-
const
|
|
2191
|
-
if (!
|
|
2192
|
-
let E = !1, _ = null,
|
|
2193
|
-
const
|
|
2194
|
-
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);
|
|
2195
2195
|
}, f = (w) => {
|
|
2196
|
-
w.key === t && (
|
|
2197
|
-
},
|
|
2198
|
-
if (!
|
|
2199
|
-
const
|
|
2200
|
-
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;
|
|
2201
2201
|
E = !0;
|
|
2202
|
-
const
|
|
2203
|
-
_ = { x: j, y:
|
|
2204
|
-
},
|
|
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) => {
|
|
2205
2205
|
if (!E || !_) return;
|
|
2206
|
-
const
|
|
2207
|
-
s({ startX: _.x, startY: _.y, endX:
|
|
2208
|
-
},
|
|
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) => {
|
|
2209
2209
|
var K, rt;
|
|
2210
2210
|
if (!E || !_) return;
|
|
2211
2211
|
E = !1;
|
|
2212
|
-
const
|
|
2213
|
-
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),
|
|
2214
2214
|
y: Math.min(_.y, j),
|
|
2215
|
-
width: Math.abs(
|
|
2215
|
+
width: Math.abs(T - _.x),
|
|
2216
2216
|
height: Math.abs(j - _.y)
|
|
2217
2217
|
}, xt = [];
|
|
2218
2218
|
for (const q of n.nodesRef.current) {
|
|
2219
2219
|
const G = q._absolutePosition || q.position, ot = q.width || 160, lt = q.height || 60;
|
|
2220
2220
|
let ut;
|
|
2221
|
-
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 });
|
|
2222
2222
|
}
|
|
2223
2223
|
xt.length && ((rt = (K = n.onNodesChangeRef).current) == null || rt.call(K, xt)), _ = null, s(null);
|
|
2224
2224
|
};
|
|
2225
|
-
return
|
|
2226
|
-
|
|
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);
|
|
2227
2227
|
};
|
|
2228
2228
|
}, [n, t, e]), !r) return null;
|
|
2229
|
-
const i = (($ = n.cameraRef) == null ? void 0 : $.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX),
|
|
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;
|
|
2230
2230
|
return /* @__PURE__ */ S(
|
|
2231
2231
|
"div",
|
|
2232
2232
|
{
|
|
@@ -2234,10 +2234,10 @@ function Kn({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
|
2234
2234
|
className: "ric-selection-box",
|
|
2235
2235
|
style: {
|
|
2236
2236
|
position: "absolute",
|
|
2237
|
-
left:
|
|
2238
|
-
top:
|
|
2237
|
+
left: v,
|
|
2238
|
+
top: N,
|
|
2239
2239
|
width: z,
|
|
2240
|
-
height:
|
|
2240
|
+
height: R,
|
|
2241
2241
|
border: "1px dashed #3b82f6",
|
|
2242
2242
|
background: "rgba(59, 130, 246, 0.08)",
|
|
2243
2243
|
pointerEvents: "none",
|
|
@@ -2288,84 +2288,84 @@ function on({
|
|
|
2288
2288
|
className: c = "",
|
|
2289
2289
|
style: u = {},
|
|
2290
2290
|
onConnect: l,
|
|
2291
|
-
...
|
|
2291
|
+
...g
|
|
2292
2292
|
}) {
|
|
2293
|
-
const
|
|
2294
|
-
|
|
2293
|
+
const v = qe(je), N = yt(), z = tt(null), R = tt(N);
|
|
2294
|
+
R.current = N;
|
|
2295
2295
|
const $ = F(() => {
|
|
2296
|
-
var w,
|
|
2297
|
-
const
|
|
2298
|
-
if (!
|
|
2299
|
-
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;
|
|
2300
2300
|
if (!f) return;
|
|
2301
|
-
const
|
|
2302
|
-
if (
|
|
2303
|
-
const
|
|
2304
|
-
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);
|
|
2305
2305
|
}
|
|
2306
|
-
}, [
|
|
2306
|
+
}, [v, n, t, e]);
|
|
2307
2307
|
kr(() => {
|
|
2308
2308
|
$();
|
|
2309
2309
|
}, [$]), ft(() => {
|
|
2310
|
-
if (!
|
|
2311
|
-
const
|
|
2312
|
-
An(
|
|
2313
|
-
const
|
|
2314
|
-
$(), 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);
|
|
2315
2315
|
});
|
|
2316
|
-
return f &&
|
|
2317
|
-
var
|
|
2318
|
-
|
|
2319
|
-
const
|
|
2320
|
-
|
|
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);
|
|
2321
2321
|
};
|
|
2322
|
-
}, [
|
|
2323
|
-
const
|
|
2324
|
-
var
|
|
2325
|
-
const
|
|
2326
|
-
if (!
|
|
2327
|
-
const f =
|
|
2328
|
-
if (
|
|
2329
|
-
return { x: f.x +
|
|
2330
|
-
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;
|
|
2331
2331
|
switch (e) {
|
|
2332
2332
|
case "top":
|
|
2333
2333
|
return { x: f.x + w / 2, y: f.y };
|
|
2334
2334
|
case "bottom":
|
|
2335
|
-
return { x: f.x + w / 2, y: f.y +
|
|
2335
|
+
return { x: f.x + w / 2, y: f.y + C };
|
|
2336
2336
|
case "left":
|
|
2337
|
-
return { x: f.x, y: f.y +
|
|
2337
|
+
return { x: f.x, y: f.y + C / 2 };
|
|
2338
2338
|
default:
|
|
2339
|
-
return { x: f.x + w, y: f.y +
|
|
2339
|
+
return { x: f.x + w, y: f.y + C / 2 };
|
|
2340
2340
|
}
|
|
2341
|
-
}, [
|
|
2341
|
+
}, [v, n, t, e]), E = F((B) => {
|
|
2342
2342
|
var j;
|
|
2343
2343
|
if (!r || !s) return;
|
|
2344
|
-
|
|
2345
|
-
const
|
|
2346
|
-
if (!
|
|
2347
|
-
const
|
|
2348
|
-
if (!
|
|
2349
|
-
const w =
|
|
2350
|
-
(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({
|
|
2351
2351
|
type: "connecting",
|
|
2352
|
-
data: { from: { x: w, y:
|
|
2353
|
-
}),
|
|
2354
|
-
const
|
|
2352
|
+
data: { from: { x: w, y: C }, to: { x: w, y: C } }
|
|
2353
|
+
}), h.setPointerCapture(B.pointerId);
|
|
2354
|
+
const x = (W) => {
|
|
2355
2355
|
var rt;
|
|
2356
|
-
const xt = (
|
|
2357
|
-
(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({
|
|
2358
2358
|
type: "connecting",
|
|
2359
|
-
data: { from: { x: w, y:
|
|
2359
|
+
data: { from: { x: w, y: C }, to: { x: xt, y: K } }
|
|
2360
2360
|
});
|
|
2361
|
-
},
|
|
2361
|
+
}, T = (W) => {
|
|
2362
2362
|
var lt, ut, st, It;
|
|
2363
|
-
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;
|
|
2364
2364
|
let q = null, G = null;
|
|
2365
|
-
const ot = (lt =
|
|
2366
|
-
for (const it of
|
|
2367
|
-
if (it.id ===
|
|
2368
|
-
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 = [];
|
|
2369
2369
|
if (ot)
|
|
2370
2370
|
for (const [, Rt] of ot)
|
|
2371
2371
|
Rt.nodeId === it.id && dt.push(Rt);
|
|
@@ -2374,25 +2374,25 @@ function on({
|
|
|
2374
2374
|
{ type: "source", position: "right" }
|
|
2375
2375
|
];
|
|
2376
2376
|
for (const Rt of ht) {
|
|
2377
|
-
let
|
|
2377
|
+
let Lt, gt;
|
|
2378
2378
|
if (Rt.x !== void 0 && Rt.y !== void 0)
|
|
2379
|
-
|
|
2379
|
+
Lt = zt.x + Rt.x, gt = zt.y + Rt.y;
|
|
2380
2380
|
else
|
|
2381
2381
|
switch (Rt.position || (Rt.type === "source" ? "right" : "left")) {
|
|
2382
2382
|
case "top":
|
|
2383
|
-
|
|
2383
|
+
Lt = zt.x + mt / 2, gt = zt.y;
|
|
2384
2384
|
break;
|
|
2385
2385
|
case "bottom":
|
|
2386
|
-
|
|
2386
|
+
Lt = zt.x + mt / 2, gt = zt.y + Nt;
|
|
2387
2387
|
break;
|
|
2388
2388
|
case "left":
|
|
2389
|
-
|
|
2389
|
+
Lt = zt.x, gt = zt.y + Nt / 2;
|
|
2390
2390
|
break;
|
|
2391
2391
|
default:
|
|
2392
|
-
|
|
2392
|
+
Lt = zt.x + mt, gt = zt.y + Nt / 2;
|
|
2393
2393
|
break;
|
|
2394
2394
|
}
|
|
2395
|
-
if (Math.abs(xt -
|
|
2395
|
+
if (Math.abs(xt - Lt) < rt && Math.abs(K - gt) < rt) {
|
|
2396
2396
|
q = it, G = Rt.id || null;
|
|
2397
2397
|
break;
|
|
2398
2398
|
}
|
|
@@ -2401,17 +2401,17 @@ function on({
|
|
|
2401
2401
|
}
|
|
2402
2402
|
if (q) {
|
|
2403
2403
|
const it = {
|
|
2404
|
-
source: t === "source" ?
|
|
2405
|
-
target: t === "source" ? q.id :
|
|
2404
|
+
source: t === "source" ? v : q.id,
|
|
2405
|
+
target: t === "source" ? q.id : v,
|
|
2406
2406
|
sourceHandle: t === "source" ? n || null : G,
|
|
2407
2407
|
targetHandle: t === "source" ? G : n || null
|
|
2408
2408
|
};
|
|
2409
|
-
(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 } }]);
|
|
2410
2410
|
}
|
|
2411
|
-
(It =
|
|
2411
|
+
(It = D.workerRef.current) == null || It.postMessage({ type: "connecting", data: null }), h.removeEventListener("pointermove", x), h.removeEventListener("pointerup", T);
|
|
2412
2412
|
};
|
|
2413
|
-
|
|
2414
|
-
}, [
|
|
2413
|
+
h.addEventListener("pointermove", x), h.addEventListener("pointerup", T);
|
|
2414
|
+
}, [v, n, t, e, r, s, k]), _ = {
|
|
2415
2415
|
top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
|
|
2416
2416
|
bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
|
|
2417
2417
|
left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
|
|
@@ -2423,7 +2423,7 @@ function on({
|
|
|
2423
2423
|
ref: z,
|
|
2424
2424
|
className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
|
|
2425
2425
|
"data-handleid": n || null,
|
|
2426
|
-
"data-nodeid":
|
|
2426
|
+
"data-nodeid": v,
|
|
2427
2427
|
"data-handlepos": e,
|
|
2428
2428
|
"data-handletype": t,
|
|
2429
2429
|
onPointerDown: E,
|
|
@@ -2440,7 +2440,7 @@ function on({
|
|
|
2440
2440
|
..._,
|
|
2441
2441
|
...u
|
|
2442
2442
|
},
|
|
2443
|
-
...
|
|
2443
|
+
...g,
|
|
2444
2444
|
children: i
|
|
2445
2445
|
}
|
|
2446
2446
|
);
|
|
@@ -2574,34 +2574,34 @@ function Vn({
|
|
|
2574
2574
|
labelBgBorderRadius: c = 2,
|
|
2575
2575
|
children: u,
|
|
2576
2576
|
className: l = "",
|
|
2577
|
-
...
|
|
2577
|
+
...g
|
|
2578
2578
|
}) {
|
|
2579
|
-
const [
|
|
2579
|
+
const [v, N] = Gt({ x: 1, y: 0, width: 0, height: 0 }), z = tt(null);
|
|
2580
2580
|
return ft(() => {
|
|
2581
2581
|
if (z.current) {
|
|
2582
|
-
const
|
|
2583
|
-
|
|
2584
|
-
x:
|
|
2585
|
-
y:
|
|
2586
|
-
width:
|
|
2587
|
-
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
|
|
2588
2588
|
});
|
|
2589
2589
|
}
|
|
2590
2590
|
}, [n]), n ? /* @__PURE__ */ $t(
|
|
2591
2591
|
"g",
|
|
2592
2592
|
{
|
|
2593
|
-
transform: `translate(${t -
|
|
2593
|
+
transform: `translate(${t - v.width / 2} ${e - v.height / 2})`,
|
|
2594
2594
|
className: `ric-edge-textwrapper ${l}`,
|
|
2595
|
-
visibility:
|
|
2596
|
-
...
|
|
2595
|
+
visibility: v.width ? "visible" : "hidden",
|
|
2596
|
+
...g,
|
|
2597
2597
|
children: [
|
|
2598
2598
|
s && /* @__PURE__ */ S(
|
|
2599
2599
|
"rect",
|
|
2600
2600
|
{
|
|
2601
|
-
width:
|
|
2601
|
+
width: v.width + 2 * i[0],
|
|
2602
2602
|
x: -i[0],
|
|
2603
2603
|
y: -i[1],
|
|
2604
|
-
height:
|
|
2604
|
+
height: v.height + 2 * i[1],
|
|
2605
2605
|
className: "ric-edge-textbg",
|
|
2606
2606
|
style: o,
|
|
2607
2607
|
rx: c,
|
|
@@ -2612,7 +2612,7 @@ function Vn({
|
|
|
2612
2612
|
"text",
|
|
2613
2613
|
{
|
|
2614
2614
|
className: "ric-edge-text",
|
|
2615
|
-
y:
|
|
2615
|
+
y: v.height / 2,
|
|
2616
2616
|
dy: "0.3em",
|
|
2617
2617
|
ref: z,
|
|
2618
2618
|
style: r,
|
|
@@ -2640,14 +2640,14 @@ function un({
|
|
|
2640
2640
|
labelBgStyle: c,
|
|
2641
2641
|
labelBgPadding: u,
|
|
2642
2642
|
labelBgBorderRadius: l,
|
|
2643
|
-
interactionWidth:
|
|
2644
|
-
style:
|
|
2645
|
-
markerEnd:
|
|
2643
|
+
interactionWidth: g = 20,
|
|
2644
|
+
style: v,
|
|
2645
|
+
markerEnd: N,
|
|
2646
2646
|
markerStart: z,
|
|
2647
|
-
className:
|
|
2647
|
+
className: R = "",
|
|
2648
2648
|
...$
|
|
2649
2649
|
}) {
|
|
2650
|
-
return /* @__PURE__ */ $t(
|
|
2650
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
2651
2651
|
/* @__PURE__ */ S(
|
|
2652
2652
|
"path",
|
|
2653
2653
|
{
|
|
@@ -2656,20 +2656,20 @@ function un({
|
|
|
2656
2656
|
fill: "none",
|
|
2657
2657
|
stroke: "#b1b1b7",
|
|
2658
2658
|
strokeWidth: 1.5,
|
|
2659
|
-
className: `ric-edge-path ${
|
|
2660
|
-
style:
|
|
2661
|
-
markerEnd:
|
|
2659
|
+
className: `ric-edge-path ${R}`,
|
|
2660
|
+
style: v,
|
|
2661
|
+
markerEnd: N,
|
|
2662
2662
|
markerStart: z,
|
|
2663
2663
|
...$
|
|
2664
2664
|
}
|
|
2665
2665
|
),
|
|
2666
|
-
|
|
2666
|
+
g ? /* @__PURE__ */ S(
|
|
2667
2667
|
"path",
|
|
2668
2668
|
{
|
|
2669
2669
|
d: e,
|
|
2670
2670
|
fill: "none",
|
|
2671
2671
|
strokeOpacity: 0,
|
|
2672
|
-
strokeWidth:
|
|
2672
|
+
strokeWidth: g,
|
|
2673
2673
|
className: "ric-edge-interaction",
|
|
2674
2674
|
style: { pointerEvents: "stroke" }
|
|
2675
2675
|
}
|
|
@@ -2714,64 +2714,64 @@ const tr = Zt(function({
|
|
|
2714
2714
|
targetPosition: c = "top",
|
|
2715
2715
|
label: u,
|
|
2716
2716
|
labelStyle: l,
|
|
2717
|
-
labelShowBg:
|
|
2718
|
-
labelBgStyle:
|
|
2719
|
-
labelBgPadding:
|
|
2717
|
+
labelShowBg: g,
|
|
2718
|
+
labelBgStyle: v,
|
|
2719
|
+
labelBgPadding: N,
|
|
2720
2720
|
labelBgBorderRadius: z,
|
|
2721
|
-
style:
|
|
2721
|
+
style: R,
|
|
2722
2722
|
markerEnd: $,
|
|
2723
|
-
markerStart:
|
|
2723
|
+
markerStart: k,
|
|
2724
2724
|
interactionWidth: E
|
|
2725
2725
|
}) {
|
|
2726
|
-
let _,
|
|
2727
|
-
const f = _n(n, r, i),
|
|
2728
|
-
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;
|
|
2729
2729
|
switch (i) {
|
|
2730
2730
|
case "left":
|
|
2731
|
-
w = f.x -
|
|
2731
|
+
w = f.x - M, C = f.y;
|
|
2732
2732
|
break;
|
|
2733
2733
|
case "top":
|
|
2734
|
-
w = f.x,
|
|
2734
|
+
w = f.x, C = f.y - M;
|
|
2735
2735
|
break;
|
|
2736
2736
|
case "bottom":
|
|
2737
|
-
w = f.x,
|
|
2737
|
+
w = f.x, C = f.y + M;
|
|
2738
2738
|
break;
|
|
2739
2739
|
default:
|
|
2740
|
-
w = f.x +
|
|
2740
|
+
w = f.x + M, C = f.y;
|
|
2741
2741
|
break;
|
|
2742
2742
|
}
|
|
2743
2743
|
switch (c) {
|
|
2744
2744
|
case "right":
|
|
2745
|
-
|
|
2745
|
+
x = h.x + M, T = h.y;
|
|
2746
2746
|
break;
|
|
2747
2747
|
case "top":
|
|
2748
|
-
|
|
2748
|
+
x = h.x, T = h.y - M;
|
|
2749
2749
|
break;
|
|
2750
2750
|
case "bottom":
|
|
2751
|
-
|
|
2751
|
+
x = h.x, T = h.y + M;
|
|
2752
2752
|
break;
|
|
2753
2753
|
default:
|
|
2754
|
-
|
|
2754
|
+
x = h.x - M, T = h.y;
|
|
2755
2755
|
break;
|
|
2756
2756
|
}
|
|
2757
|
-
_ = `M ${n},${r} L ${f.x},${f.y} C ${w},${
|
|
2758
|
-
const j = 0.5,
|
|
2759
|
-
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(
|
|
2760
2760
|
un,
|
|
2761
2761
|
{
|
|
2762
2762
|
id: e,
|
|
2763
2763
|
path: _,
|
|
2764
|
-
labelX:
|
|
2765
|
-
labelY:
|
|
2764
|
+
labelX: B,
|
|
2765
|
+
labelY: D,
|
|
2766
2766
|
label: u,
|
|
2767
2767
|
labelStyle: l,
|
|
2768
|
-
labelShowBg:
|
|
2769
|
-
labelBgStyle:
|
|
2770
|
-
labelBgPadding:
|
|
2768
|
+
labelShowBg: g,
|
|
2769
|
+
labelBgStyle: v,
|
|
2770
|
+
labelBgPadding: N,
|
|
2771
2771
|
labelBgBorderRadius: z,
|
|
2772
|
-
style:
|
|
2772
|
+
style: R,
|
|
2773
2773
|
markerEnd: $,
|
|
2774
|
-
markerStart:
|
|
2774
|
+
markerStart: k,
|
|
2775
2775
|
interactionWidth: E
|
|
2776
2776
|
}
|
|
2777
2777
|
);
|
|
@@ -2790,42 +2790,42 @@ function nr({
|
|
|
2790
2790
|
targetPosition: o = "left",
|
|
2791
2791
|
curvature: i = 0.25
|
|
2792
2792
|
}) {
|
|
2793
|
-
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u),
|
|
2794
|
-
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;
|
|
2795
2795
|
switch (s) {
|
|
2796
2796
|
case "top":
|
|
2797
|
-
|
|
2797
|
+
v = t, N = e - g;
|
|
2798
2798
|
break;
|
|
2799
2799
|
case "bottom":
|
|
2800
|
-
|
|
2800
|
+
v = t, N = e + g;
|
|
2801
2801
|
break;
|
|
2802
2802
|
case "left":
|
|
2803
|
-
|
|
2803
|
+
v = t - g, N = e;
|
|
2804
2804
|
break;
|
|
2805
2805
|
default:
|
|
2806
|
-
|
|
2806
|
+
v = t + g, N = e;
|
|
2807
2807
|
break;
|
|
2808
2808
|
}
|
|
2809
2809
|
switch (o) {
|
|
2810
2810
|
case "top":
|
|
2811
|
-
z = n,
|
|
2811
|
+
z = n, R = r - g;
|
|
2812
2812
|
break;
|
|
2813
2813
|
case "bottom":
|
|
2814
|
-
z = n,
|
|
2814
|
+
z = n, R = r + g;
|
|
2815
2815
|
break;
|
|
2816
2816
|
case "right":
|
|
2817
|
-
z = n +
|
|
2817
|
+
z = n + g, R = r;
|
|
2818
2818
|
break;
|
|
2819
2819
|
default:
|
|
2820
|
-
z = n -
|
|
2820
|
+
z = n - g, R = r;
|
|
2821
2821
|
break;
|
|
2822
2822
|
}
|
|
2823
|
-
const $ = `M ${t},${e} C ${
|
|
2824
|
-
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];
|
|
2825
2825
|
}
|
|
2826
2826
|
function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
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,
|
|
2828
|
-
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];
|
|
2829
2829
|
}
|
|
2830
2830
|
function kn({
|
|
2831
2831
|
sourceX: t,
|
|
@@ -2841,11 +2841,11 @@ function kn({
|
|
|
2841
2841
|
if (u) {
|
|
2842
2842
|
if (Math.abs(r - e) < 1)
|
|
2843
2843
|
return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
|
|
2844
|
-
const z = (t + n) / 2,
|
|
2845
|
-
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];
|
|
2846
2846
|
}
|
|
2847
|
-
const
|
|
2848
|
-
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];
|
|
2849
2849
|
}
|
|
2850
2850
|
function zo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2851
2851
|
const [, s, o] = nr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
@@ -2903,20 +2903,20 @@ function ln(t, e) {
|
|
|
2903
2903
|
}
|
|
2904
2904
|
}
|
|
2905
2905
|
function Yr(t, e, n, r, s, o, i, c) {
|
|
2906
|
-
const u = Math.min(t, n), l = Math.max(t, n),
|
|
2907
|
-
if (l <= s || u >= s + i ||
|
|
2908
|
-
const
|
|
2909
|
-
if (t > s +
|
|
2910
|
-
const z = (t + n) / 2,
|
|
2911
|
-
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;
|
|
2912
2912
|
const $ = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
|
|
2913
|
-
for (let
|
|
2914
|
-
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;
|
|
2915
2915
|
return !1;
|
|
2916
2916
|
}
|
|
2917
2917
|
function Ur(t, e, n, r, s, o, i, c) {
|
|
2918
|
-
const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s),
|
|
2919
|
-
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);
|
|
2920
2920
|
}
|
|
2921
2921
|
function zn(t, e, n, r, s) {
|
|
2922
2922
|
for (let o = 0; o < s.length; o++) {
|
|
@@ -2956,44 +2956,44 @@ function sr(t, e, n) {
|
|
|
2956
2956
|
r.add(t.x), r.add(e.x), s.add(t.y), s.add(e.y);
|
|
2957
2957
|
const o = Ue + 5;
|
|
2958
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);
|
|
2959
|
-
for (let
|
|
2960
|
-
const
|
|
2961
|
-
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);
|
|
2962
2962
|
}
|
|
2963
|
-
const i = [...r].sort((
|
|
2964
|
-
for (let
|
|
2965
|
-
for (let
|
|
2966
|
-
const
|
|
2967
|
-
if (z === void 0 ||
|
|
2968
|
-
const E =
|
|
2969
|
-
|
|
2970
|
-
const
|
|
2971
|
-
for (;
|
|
2972
|
-
let
|
|
2973
|
-
for (let q = 1; q <
|
|
2974
|
-
|
|
2975
|
-
const
|
|
2976
|
-
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 === _) {
|
|
2977
2977
|
const q = [];
|
|
2978
2978
|
let G = _;
|
|
2979
2979
|
for (; G !== -1 && G !== E; ) {
|
|
2980
|
-
const ot = G /
|
|
2980
|
+
const ot = G / g | 0, lt = G % g;
|
|
2981
2981
|
q.unshift({ x: i[lt], y: c[ot] }), G = f[G];
|
|
2982
2982
|
}
|
|
2983
2983
|
return q.unshift({ x: t.x, y: t.y }), jr(q, n);
|
|
2984
2984
|
}
|
|
2985
|
-
if (
|
|
2986
|
-
|
|
2987
|
-
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];
|
|
2988
2988
|
for (let q = 0; q < 4; q++) {
|
|
2989
|
-
const G =
|
|
2990
|
-
if (G < 0 || G >=
|
|
2991
|
-
const lt =
|
|
2992
|
-
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;
|
|
2993
2993
|
const ut = i[G], st = c[ot];
|
|
2994
2994
|
if (qr(ut, st, n) || !zn(xt, K, ut, st, n)) continue;
|
|
2995
|
-
const It = Math.abs(ut - xt) + Math.abs(st - K), it = rt >= 0 && rt !== q ? w : 0, mt =
|
|
2996
|
-
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));
|
|
2997
2997
|
}
|
|
2998
2998
|
}
|
|
2999
2999
|
return null;
|
|
@@ -3033,8 +3033,8 @@ function Gr(t) {
|
|
|
3033
3033
|
if (i.length < 2) continue;
|
|
3034
3034
|
const c = (i.length - 1) * nn / 2;
|
|
3035
3035
|
for (let u = 0; u < i.length; u++) {
|
|
3036
|
-
const l = i[u],
|
|
3037
|
-
|
|
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);
|
|
3038
3038
|
}
|
|
3039
3039
|
}
|
|
3040
3040
|
}
|
|
@@ -3045,8 +3045,8 @@ function Gr(t) {
|
|
|
3045
3045
|
if (i.length < 2) continue;
|
|
3046
3046
|
const c = (i.length - 1) * nn / 2;
|
|
3047
3047
|
for (let u = 0; u < i.length; u++) {
|
|
3048
|
-
const l = i[u],
|
|
3049
|
-
|
|
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);
|
|
3050
3050
|
}
|
|
3051
3051
|
}
|
|
3052
3052
|
}
|
|
@@ -3071,10 +3071,10 @@ function En(t, e = 6, n = !1) {
|
|
|
3071
3071
|
const r = e;
|
|
3072
3072
|
let s = `M ${t[0].x},${t[0].y}`;
|
|
3073
3073
|
for (let o = 1; o < t.length - 1; o++) {
|
|
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),
|
|
3075
|
-
if (
|
|
3076
|
-
const
|
|
3077
|
-
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}`;
|
|
3078
3078
|
} else
|
|
3079
3079
|
s += ` L ${c.x},${c.y}`;
|
|
3080
3080
|
}
|
|
@@ -3088,8 +3088,8 @@ function Zr(t) {
|
|
|
3088
3088
|
const e = 0.3;
|
|
3089
3089
|
let n = `M ${t[0].x},${t[0].y}`;
|
|
3090
3090
|
for (let r = 0; r < t.length - 1; r++) {
|
|
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,
|
|
3092
|
-
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}`;
|
|
3093
3093
|
}
|
|
3094
3094
|
return n;
|
|
3095
3095
|
}
|
|
@@ -3112,30 +3112,30 @@ function Cn(t) {
|
|
|
3112
3112
|
}
|
|
3113
3113
|
return { x: t[0].x, y: t[0].y };
|
|
3114
3114
|
}
|
|
3115
|
-
function
|
|
3115
|
+
function No(t, e) {
|
|
3116
3116
|
if (!t || !e || t.length === 0 || e.length === 0) return e;
|
|
3117
3117
|
const n = {};
|
|
3118
3118
|
for (const o of t) n[o.id] = o;
|
|
3119
3119
|
const r = or(t, null), s = e.map((o) => {
|
|
3120
|
-
var
|
|
3120
|
+
var h, p, M, w;
|
|
3121
3121
|
const i = o.type || "default";
|
|
3122
3122
|
if (i === "bezier" || i === "simplebezier" || i === "default") return o;
|
|
3123
3123
|
const c = n[o.source], u = n[o.target];
|
|
3124
3124
|
if (!c || !u || c.hidden || u.hidden) return o;
|
|
3125
|
-
const l = Wn(c, "source", o.sourceHandle),
|
|
3126
|
-
|
|
3127
|
-
const _ = u._absolutePosition || u.position,
|
|
3128
|
-
if (
|
|
3129
|
-
const f = sr(
|
|
3130
|
-
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;
|
|
3131
3131
|
});
|
|
3132
3132
|
return Gr(s);
|
|
3133
3133
|
}
|
|
3134
|
-
function
|
|
3134
|
+
function Lo(t, e, n, r, s, o, i, c) {
|
|
3135
3135
|
const u = or(i, c ? new Set(c) : null);
|
|
3136
3136
|
if (u.length === 0) return null;
|
|
3137
|
-
const l = { x: t, y: e, dir: s || "right" },
|
|
3138
|
-
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;
|
|
3139
3139
|
}
|
|
3140
3140
|
const ir = Zt(function({
|
|
3141
3141
|
id: e,
|
|
@@ -3147,37 +3147,37 @@ const ir = Zt(function({
|
|
|
3147
3147
|
labelStyle: c,
|
|
3148
3148
|
labelShowBg: u,
|
|
3149
3149
|
labelBgStyle: l,
|
|
3150
|
-
labelBgPadding:
|
|
3151
|
-
labelBgBorderRadius:
|
|
3152
|
-
style:
|
|
3150
|
+
labelBgPadding: g,
|
|
3151
|
+
labelBgBorderRadius: v,
|
|
3152
|
+
style: N,
|
|
3153
3153
|
markerEnd: z,
|
|
3154
|
-
markerStart:
|
|
3154
|
+
markerStart: R,
|
|
3155
3155
|
interactionWidth: $,
|
|
3156
|
-
routedPoints:
|
|
3156
|
+
routedPoints: k
|
|
3157
3157
|
}) {
|
|
3158
|
-
let E, _,
|
|
3159
|
-
if (
|
|
3160
|
-
E = En(
|
|
3161
|
-
const
|
|
3162
|
-
_ =
|
|
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;
|
|
3163
3163
|
} else
|
|
3164
|
-
[E, _,
|
|
3164
|
+
[E, _, B] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
|
|
3165
3165
|
return /* @__PURE__ */ S(
|
|
3166
3166
|
un,
|
|
3167
3167
|
{
|
|
3168
3168
|
id: e,
|
|
3169
3169
|
path: E,
|
|
3170
3170
|
labelX: _,
|
|
3171
|
-
labelY:
|
|
3171
|
+
labelY: B,
|
|
3172
3172
|
label: i,
|
|
3173
3173
|
labelStyle: c,
|
|
3174
3174
|
labelShowBg: u,
|
|
3175
3175
|
labelBgStyle: l,
|
|
3176
|
-
labelBgPadding:
|
|
3177
|
-
labelBgBorderRadius:
|
|
3178
|
-
style:
|
|
3176
|
+
labelBgPadding: g,
|
|
3177
|
+
labelBgBorderRadius: v,
|
|
3178
|
+
style: N,
|
|
3179
3179
|
markerEnd: z,
|
|
3180
|
-
markerStart:
|
|
3180
|
+
markerStart: R,
|
|
3181
3181
|
interactionWidth: $
|
|
3182
3182
|
}
|
|
3183
3183
|
);
|
|
@@ -3193,24 +3193,24 @@ const ar = Zt(function({
|
|
|
3193
3193
|
targetPosition: c = "top",
|
|
3194
3194
|
label: u,
|
|
3195
3195
|
labelStyle: l,
|
|
3196
|
-
labelShowBg:
|
|
3197
|
-
labelBgStyle:
|
|
3198
|
-
labelBgPadding:
|
|
3196
|
+
labelShowBg: g,
|
|
3197
|
+
labelBgStyle: v,
|
|
3198
|
+
labelBgPadding: N,
|
|
3199
3199
|
labelBgBorderRadius: z,
|
|
3200
|
-
style:
|
|
3200
|
+
style: R,
|
|
3201
3201
|
markerEnd: $,
|
|
3202
|
-
markerStart:
|
|
3202
|
+
markerStart: k,
|
|
3203
3203
|
pathOptions: E,
|
|
3204
3204
|
interactionWidth: _,
|
|
3205
|
-
routedPoints:
|
|
3205
|
+
routedPoints: B
|
|
3206
3206
|
}) {
|
|
3207
|
-
let
|
|
3208
|
-
if (
|
|
3209
|
-
|
|
3210
|
-
const
|
|
3211
|
-
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;
|
|
3212
3212
|
} else
|
|
3213
|
-
[
|
|
3213
|
+
[D, f, h] = kn({
|
|
3214
3214
|
sourceX: n,
|
|
3215
3215
|
sourceY: r,
|
|
3216
3216
|
sourcePosition: i,
|
|
@@ -3224,18 +3224,18 @@ const ar = Zt(function({
|
|
|
3224
3224
|
un,
|
|
3225
3225
|
{
|
|
3226
3226
|
id: e,
|
|
3227
|
-
path:
|
|
3227
|
+
path: D,
|
|
3228
3228
|
labelX: f,
|
|
3229
|
-
labelY:
|
|
3229
|
+
labelY: h,
|
|
3230
3230
|
label: u,
|
|
3231
3231
|
labelStyle: l,
|
|
3232
|
-
labelShowBg:
|
|
3233
|
-
labelBgStyle:
|
|
3234
|
-
labelBgPadding:
|
|
3232
|
+
labelShowBg: g,
|
|
3233
|
+
labelBgStyle: v,
|
|
3234
|
+
labelBgPadding: N,
|
|
3235
3235
|
labelBgBorderRadius: z,
|
|
3236
|
-
style:
|
|
3236
|
+
style: R,
|
|
3237
3237
|
markerEnd: $,
|
|
3238
|
-
markerStart:
|
|
3238
|
+
markerStart: k,
|
|
3239
3239
|
interactionWidth: _
|
|
3240
3240
|
}
|
|
3241
3241
|
);
|
|
@@ -3263,23 +3263,23 @@ const cr = Zt(function({
|
|
|
3263
3263
|
targetPosition: c,
|
|
3264
3264
|
label: u,
|
|
3265
3265
|
labelStyle: l,
|
|
3266
|
-
labelShowBg:
|
|
3267
|
-
labelBgStyle:
|
|
3268
|
-
labelBgPadding:
|
|
3266
|
+
labelShowBg: g,
|
|
3267
|
+
labelBgStyle: v,
|
|
3268
|
+
labelBgPadding: N,
|
|
3269
3269
|
labelBgBorderRadius: z,
|
|
3270
|
-
style:
|
|
3270
|
+
style: R,
|
|
3271
3271
|
markerEnd: $,
|
|
3272
|
-
markerStart:
|
|
3272
|
+
markerStart: k,
|
|
3273
3273
|
interactionWidth: E,
|
|
3274
3274
|
routedPoints: _
|
|
3275
3275
|
}) {
|
|
3276
|
-
let
|
|
3276
|
+
let B, D, f;
|
|
3277
3277
|
if (_ && _.length >= 2) {
|
|
3278
|
-
|
|
3279
|
-
const
|
|
3280
|
-
|
|
3278
|
+
B = En(_);
|
|
3279
|
+
const h = Cn(_);
|
|
3280
|
+
D = h.x, f = h.y;
|
|
3281
3281
|
} else
|
|
3282
|
-
[
|
|
3282
|
+
[B, D, f] = rr({
|
|
3283
3283
|
sourceX: n,
|
|
3284
3284
|
sourceY: r,
|
|
3285
3285
|
targetX: s,
|
|
@@ -3289,18 +3289,18 @@ const cr = Zt(function({
|
|
|
3289
3289
|
un,
|
|
3290
3290
|
{
|
|
3291
3291
|
id: e,
|
|
3292
|
-
path:
|
|
3293
|
-
labelX:
|
|
3292
|
+
path: B,
|
|
3293
|
+
labelX: D,
|
|
3294
3294
|
labelY: f,
|
|
3295
3295
|
label: u,
|
|
3296
3296
|
labelStyle: l,
|
|
3297
|
-
labelShowBg:
|
|
3298
|
-
labelBgStyle:
|
|
3299
|
-
labelBgPadding:
|
|
3297
|
+
labelShowBg: g,
|
|
3298
|
+
labelBgStyle: v,
|
|
3299
|
+
labelBgPadding: N,
|
|
3300
3300
|
labelBgBorderRadius: z,
|
|
3301
|
-
style:
|
|
3301
|
+
style: R,
|
|
3302
3302
|
markerEnd: $,
|
|
3303
|
-
markerStart:
|
|
3303
|
+
markerStart: k,
|
|
3304
3304
|
interactionWidth: E
|
|
3305
3305
|
}
|
|
3306
3306
|
);
|
|
@@ -3330,29 +3330,29 @@ function Io({
|
|
|
3330
3330
|
width: c = "100%",
|
|
3331
3331
|
height: u = "420px",
|
|
3332
3332
|
className: l = "",
|
|
3333
|
-
style:
|
|
3333
|
+
style: g = {},
|
|
3334
3334
|
// Zoom/Camera
|
|
3335
|
-
zoomMin:
|
|
3336
|
-
zoomMax:
|
|
3335
|
+
zoomMin: v,
|
|
3336
|
+
zoomMax: N,
|
|
3337
3337
|
initialCamera: z,
|
|
3338
|
-
fitView:
|
|
3338
|
+
fitView: R,
|
|
3339
3339
|
fitViewOptions: $,
|
|
3340
3340
|
// Node/Edge callbacks
|
|
3341
|
-
onNodesChange:
|
|
3341
|
+
onNodesChange: k,
|
|
3342
3342
|
onEdgesChange: E,
|
|
3343
3343
|
onConnect: _,
|
|
3344
|
-
onConnectStart:
|
|
3345
|
-
onConnectEnd:
|
|
3344
|
+
onConnectStart: B,
|
|
3345
|
+
onConnectEnd: D,
|
|
3346
3346
|
onNodeClick: f,
|
|
3347
|
-
onNodeDoubleClick:
|
|
3348
|
-
onNodeMouseEnter:
|
|
3349
|
-
onNodeMouseMove:
|
|
3347
|
+
onNodeDoubleClick: h,
|
|
3348
|
+
onNodeMouseEnter: p,
|
|
3349
|
+
onNodeMouseMove: M,
|
|
3350
3350
|
onNodeMouseLeave: w,
|
|
3351
|
-
onNodeContextMenu:
|
|
3352
|
-
onNodeDragStart:
|
|
3353
|
-
onNodeDrag:
|
|
3351
|
+
onNodeContextMenu: C,
|
|
3352
|
+
onNodeDragStart: x,
|
|
3353
|
+
onNodeDrag: T,
|
|
3354
3354
|
onNodeDragStop: j,
|
|
3355
|
-
onEdgeClick:
|
|
3355
|
+
onEdgeClick: W,
|
|
3356
3356
|
onEdgeDoubleClick: xt,
|
|
3357
3357
|
onEdgeMouseEnter: K,
|
|
3358
3358
|
onEdgeMouseMove: rt,
|
|
@@ -3365,12 +3365,12 @@ function Io({
|
|
|
3365
3365
|
onPaneMouseLeave: It,
|
|
3366
3366
|
onSelectionChange: it,
|
|
3367
3367
|
onInit: mt,
|
|
3368
|
-
onMoveStart:
|
|
3368
|
+
onMoveStart: Nt,
|
|
3369
3369
|
onMove: zt,
|
|
3370
3370
|
onMoveEnd: dt,
|
|
3371
3371
|
onDelete: ht,
|
|
3372
3372
|
onBeforeDelete: Rt,
|
|
3373
|
-
onError:
|
|
3373
|
+
onError: Lt,
|
|
3374
3374
|
// Drag and drop
|
|
3375
3375
|
onDragOver: gt,
|
|
3376
3376
|
onDrop: ne,
|
|
@@ -3396,7 +3396,7 @@ function Io({
|
|
|
3396
3396
|
panOnScrollMode: dn,
|
|
3397
3397
|
panOnScrollSpeed: fn,
|
|
3398
3398
|
zoomOnScroll: Qt,
|
|
3399
|
-
zoomOnDoubleClick:
|
|
3399
|
+
zoomOnDoubleClick: Nn,
|
|
3400
3400
|
zoomOnPinch: hn,
|
|
3401
3401
|
preventScrolling: fe,
|
|
3402
3402
|
translateExtent: vt,
|
|
@@ -3437,34 +3437,34 @@ function Io({
|
|
|
3437
3437
|
onPointerMove: He,
|
|
3438
3438
|
onPointerUp: _e,
|
|
3439
3439
|
store: le
|
|
3440
|
-
} =
|
|
3440
|
+
} = Lr({
|
|
3441
3441
|
cards: t,
|
|
3442
3442
|
nodes: O,
|
|
3443
3443
|
edges: bt,
|
|
3444
3444
|
dark: o,
|
|
3445
3445
|
gridSize: i,
|
|
3446
|
-
zoomMin:
|
|
3447
|
-
zoomMax:
|
|
3446
|
+
zoomMin: v,
|
|
3447
|
+
zoomMax: N,
|
|
3448
3448
|
initialCamera: z,
|
|
3449
|
-
fitView:
|
|
3449
|
+
fitView: R,
|
|
3450
3450
|
fitViewOptions: $,
|
|
3451
3451
|
onHudUpdate: Ve,
|
|
3452
3452
|
onNodesProcessed: gn,
|
|
3453
|
-
onNodesChange:
|
|
3453
|
+
onNodesChange: k,
|
|
3454
3454
|
onEdgesChange: E,
|
|
3455
3455
|
onConnect: _,
|
|
3456
|
-
onConnectStart:
|
|
3457
|
-
onConnectEnd:
|
|
3456
|
+
onConnectStart: B,
|
|
3457
|
+
onConnectEnd: D,
|
|
3458
3458
|
onNodeClick: f,
|
|
3459
|
-
onNodeDoubleClick:
|
|
3460
|
-
onNodeMouseEnter:
|
|
3461
|
-
onNodeMouseMove:
|
|
3459
|
+
onNodeDoubleClick: h,
|
|
3460
|
+
onNodeMouseEnter: p,
|
|
3461
|
+
onNodeMouseMove: M,
|
|
3462
3462
|
onNodeMouseLeave: w,
|
|
3463
|
-
onNodeContextMenu:
|
|
3464
|
-
onNodeDragStart:
|
|
3465
|
-
onNodeDrag:
|
|
3463
|
+
onNodeContextMenu: C,
|
|
3464
|
+
onNodeDragStart: x,
|
|
3465
|
+
onNodeDrag: T,
|
|
3466
3466
|
onNodeDragStop: j,
|
|
3467
|
-
onEdgeClick:
|
|
3467
|
+
onEdgeClick: W,
|
|
3468
3468
|
onEdgeDoubleClick: xt,
|
|
3469
3469
|
onEdgeMouseEnter: K,
|
|
3470
3470
|
onEdgeMouseMove: rt,
|
|
@@ -3477,12 +3477,12 @@ function Io({
|
|
|
3477
3477
|
onPaneMouseLeave: It,
|
|
3478
3478
|
onSelectionChange: it,
|
|
3479
3479
|
onInit: mt,
|
|
3480
|
-
onMoveStart:
|
|
3480
|
+
onMoveStart: Nt,
|
|
3481
3481
|
onMove: zt,
|
|
3482
3482
|
onMoveEnd: dt,
|
|
3483
3483
|
onDelete: ht,
|
|
3484
3484
|
onBeforeDelete: Rt,
|
|
3485
|
-
onError:
|
|
3485
|
+
onError: Lt,
|
|
3486
3486
|
nodesDraggable: Ot,
|
|
3487
3487
|
nodesConnectable: Yt,
|
|
3488
3488
|
elementsSelectable: me,
|
|
@@ -3502,7 +3502,7 @@ function Io({
|
|
|
3502
3502
|
panOnScrollMode: dn,
|
|
3503
3503
|
panOnScrollSpeed: fn,
|
|
3504
3504
|
zoomOnScroll: Qt,
|
|
3505
|
-
zoomOnDoubleClick:
|
|
3505
|
+
zoomOnDoubleClick: Nn,
|
|
3506
3506
|
zoomOnPinch: hn,
|
|
3507
3507
|
preventScrolling: fe,
|
|
3508
3508
|
translateExtent: vt,
|
|
@@ -3539,7 +3539,7 @@ function Io({
|
|
|
3539
3539
|
{
|
|
3540
3540
|
ref: Dt,
|
|
3541
3541
|
className: `ric-wrap ${l}`,
|
|
3542
|
-
style: { width: c, height: u, ...
|
|
3542
|
+
style: { width: c, height: u, ...g },
|
|
3543
3543
|
onPointerDown: Ae,
|
|
3544
3544
|
onPointerMove: He,
|
|
3545
3545
|
onPointerUp: _e,
|
|
@@ -3648,11 +3648,11 @@ function Io({
|
|
|
3648
3648
|
") zoom: ",
|
|
3649
3649
|
Ut.zoom,
|
|
3650
3650
|
"x",
|
|
3651
|
-
Ut.nodeCount > 0 && /* @__PURE__ */ $t(
|
|
3651
|
+
Ut.nodeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3652
3652
|
" nodes: ",
|
|
3653
3653
|
Ut.nodeCount
|
|
3654
3654
|
] }),
|
|
3655
|
-
Ut.edgeCount > 0 && /* @__PURE__ */ $t(
|
|
3655
|
+
Ut.edgeCount > 0 && /* @__PURE__ */ $t(Le, { children: [
|
|
3656
3656
|
" edges: ",
|
|
3657
3657
|
Ut.edgeCount
|
|
3658
3658
|
] })
|
|
@@ -3745,97 +3745,103 @@ function So(t) {
|
|
|
3745
3745
|
return [e, n, r];
|
|
3746
3746
|
}
|
|
3747
3747
|
function eo() {
|
|
3748
|
-
const t = yt(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((
|
|
3749
|
-
var
|
|
3750
|
-
if (typeof
|
|
3751
|
-
const
|
|
3752
|
-
(p = (
|
|
3753
|
-
...t.nodesRef.current.map((
|
|
3754
|
-
...
|
|
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 }))
|
|
3755
3755
|
]);
|
|
3756
3756
|
} else
|
|
3757
|
-
(
|
|
3758
|
-
...t.nodesRef.current.map((
|
|
3759
|
-
...
|
|
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 }))
|
|
3760
3760
|
]);
|
|
3761
|
-
}, [t]), i = F((
|
|
3762
|
-
var
|
|
3763
|
-
if (typeof
|
|
3764
|
-
const
|
|
3765
|
-
(p = (
|
|
3766
|
-
...t.edgesRef.current.map((
|
|
3767
|
-
...
|
|
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 }))
|
|
3768
3768
|
]);
|
|
3769
3769
|
} else
|
|
3770
|
-
(
|
|
3771
|
-
...t.edgesRef.current.map((
|
|
3772
|
-
...
|
|
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 }))
|
|
3773
3773
|
]);
|
|
3774
|
-
}, [t]), c = F((
|
|
3775
|
-
var p,
|
|
3776
|
-
const
|
|
3777
|
-
(
|
|
3778
|
-
}, [t]), u = F((
|
|
3779
|
-
var p,
|
|
3780
|
-
const
|
|
3781
|
-
(
|
|
3782
|
-
}, [t]), l = F(({ nodes:
|
|
3783
|
-
if (
|
|
3784
|
-
t.onNodesChangeRef.current(
|
|
3785
|
-
const p = zr(
|
|
3786
|
-
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" })));
|
|
3787
3787
|
}
|
|
3788
|
-
|
|
3789
|
-
}, [t]),
|
|
3790
|
-
const
|
|
3791
|
-
return { x:
|
|
3792
|
-
}, [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) => {
|
|
3793
3793
|
t.cameraRef.current = {
|
|
3794
|
-
x:
|
|
3795
|
-
y:
|
|
3796
|
-
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
|
|
3797
3797
|
}, t.sendCamera();
|
|
3798
|
-
}, [t]),
|
|
3799
|
-
const
|
|
3798
|
+
}, [t]), N = F(() => t.cameraRef.current.zoom, [t]), z = F((f) => {
|
|
3799
|
+
const h = t.cameraRef.current, p = t.wrapRef.current;
|
|
3800
3800
|
if (!p) return;
|
|
3801
|
-
const
|
|
3802
|
-
|
|
3803
|
-
}, [t]),
|
|
3804
|
-
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;
|
|
3805
3805
|
if (!p) return;
|
|
3806
|
-
const
|
|
3807
|
-
|
|
3808
|
-
}, [t]), $ = F((
|
|
3809
|
-
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;
|
|
3810
3810
|
if (!p) return;
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
}, [t]),
|
|
3814
|
-
const
|
|
3815
|
-
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;
|
|
3816
3816
|
const p = t.wrapRef.current;
|
|
3817
3817
|
if (!p) return;
|
|
3818
|
-
const
|
|
3819
|
-
if (!
|
|
3820
|
-
const
|
|
3821
|
-
|
|
3822
|
-
}, [t]), E = F((
|
|
3823
|
-
const
|
|
3824
|
-
if (!
|
|
3825
|
-
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;
|
|
3826
3826
|
t.cameraRef.current = {
|
|
3827
|
-
x:
|
|
3828
|
-
y:
|
|
3829
|
-
zoom:
|
|
3827
|
+
x: w.width / 2 - f * C,
|
|
3828
|
+
y: w.height / 2 - h * C,
|
|
3829
|
+
zoom: C
|
|
3830
3830
|
}, t.sendCamera();
|
|
3831
|
-
}, [t]), _ = F((
|
|
3832
|
-
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;
|
|
3833
3833
|
if (!p) return { x: 0, y: 0 };
|
|
3834
|
-
const
|
|
3834
|
+
const M = p.getBoundingClientRect();
|
|
3835
3835
|
return {
|
|
3836
|
-
x:
|
|
3837
|
-
y:
|
|
3836
|
+
x: f.x * h.zoom + h.x + M.left,
|
|
3837
|
+
y: f.y * h.zoom + h.y + M.top
|
|
3838
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 } }]);
|
|
3839
3845
|
}, [t]);
|
|
3840
3846
|
return {
|
|
3841
3847
|
getNodes: e,
|
|
@@ -3847,16 +3853,17 @@ function eo() {
|
|
|
3847
3853
|
addNodes: c,
|
|
3848
3854
|
addEdges: u,
|
|
3849
3855
|
deleteElements: l,
|
|
3850
|
-
getViewport:
|
|
3851
|
-
setViewport:
|
|
3852
|
-
getZoom:
|
|
3856
|
+
getViewport: g,
|
|
3857
|
+
setViewport: v,
|
|
3858
|
+
getZoom: N,
|
|
3853
3859
|
zoomIn: z,
|
|
3854
|
-
zoomOut:
|
|
3860
|
+
zoomOut: R,
|
|
3855
3861
|
zoomTo: $,
|
|
3856
|
-
fitView:
|
|
3862
|
+
fitView: k,
|
|
3857
3863
|
setCenter: E,
|
|
3858
3864
|
screenToFlowPosition: _,
|
|
3859
|
-
flowToScreenPosition:
|
|
3865
|
+
flowToScreenPosition: B,
|
|
3866
|
+
updateNodeData: D
|
|
3860
3867
|
};
|
|
3861
3868
|
}
|
|
3862
3869
|
function Bo() {
|
|
@@ -3967,52 +3974,52 @@ function Qo({
|
|
|
3967
3974
|
style: o = {},
|
|
3968
3975
|
className: i = ""
|
|
3969
3976
|
}) {
|
|
3970
|
-
const c = yt(), u = tt(null), l = tt(null),
|
|
3971
|
-
const
|
|
3972
|
-
if (!
|
|
3973
|
-
const
|
|
3974
|
-
|
|
3975
|
-
const
|
|
3976
|
-
if (!
|
|
3977
|
-
let $ = 1 / 0,
|
|
3978
|
-
for (const
|
|
3979
|
-
const
|
|
3980
|
-
|
|
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);
|
|
3981
3988
|
}
|
|
3982
|
-
const
|
|
3983
|
-
$ -=
|
|
3984
|
-
const
|
|
3985
|
-
for (const
|
|
3986
|
-
if (
|
|
3987
|
-
const
|
|
3988
|
-
|
|
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));
|
|
3989
3996
|
}
|
|
3990
|
-
const w = c.cameraRef.current,
|
|
3991
|
-
if (
|
|
3992
|
-
const
|
|
3993
|
-
|
|
3994
|
-
const K = (
|
|
3995
|
-
|
|
3996
|
-
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) {
|
|
3997
4004
|
if (ot.hidden) continue;
|
|
3998
|
-
const lt = ot.width || wn, ut = ot.height || bn, st = (ot.position.x - $) *
|
|
3999
|
-
|
|
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));
|
|
4000
4007
|
}
|
|
4001
|
-
|
|
4008
|
+
N.strokeStyle = "#3b82f6", N.lineWidth = 1.5, N.strokeRect(K, rt, q, G);
|
|
4002
4009
|
}
|
|
4003
4010
|
}, [c, t, e, n, r, s]);
|
|
4004
4011
|
return ft(() => {
|
|
4005
|
-
let
|
|
4006
|
-
function
|
|
4007
|
-
|
|
4012
|
+
let v = !0;
|
|
4013
|
+
function N() {
|
|
4014
|
+
v && (g(), l.current = requestAnimationFrame(N));
|
|
4008
4015
|
}
|
|
4009
4016
|
const z = setInterval(() => {
|
|
4010
|
-
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(
|
|
4017
|
+
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(N);
|
|
4011
4018
|
}, 66);
|
|
4012
|
-
return
|
|
4013
|
-
|
|
4019
|
+
return g(), () => {
|
|
4020
|
+
v = !1, clearInterval(z), cancelAnimationFrame(l.current);
|
|
4014
4021
|
};
|
|
4015
|
-
}, [
|
|
4022
|
+
}, [g]), /* @__PURE__ */ S(
|
|
4016
4023
|
"canvas",
|
|
4017
4024
|
{
|
|
4018
4025
|
ref: u,
|
|
@@ -4078,21 +4085,21 @@ function ao({
|
|
|
4078
4085
|
onInteractiveChange: c,
|
|
4079
4086
|
position: u = "bottom-left",
|
|
4080
4087
|
orientation: l = "vertical",
|
|
4081
|
-
style:
|
|
4082
|
-
className:
|
|
4083
|
-
"aria-label":
|
|
4088
|
+
style: g = {},
|
|
4089
|
+
className: v = "",
|
|
4090
|
+
"aria-label": N = "Canvas controls",
|
|
4084
4091
|
children: z
|
|
4085
4092
|
}) {
|
|
4086
|
-
const
|
|
4093
|
+
const R = yt(), { zoomIn: $, zoomOut: k, fitView: E, getZoom: _ } = eo(), [B, D] = Gt(!0), f = _() <= R.zoomMin, h = _() >= R.zoomMax, p = F(() => {
|
|
4087
4094
|
$(), s == null || s();
|
|
4088
|
-
}, [$, s]),
|
|
4089
|
-
|
|
4090
|
-
}, [
|
|
4095
|
+
}, [$, s]), M = F(() => {
|
|
4096
|
+
k(), o == null || o();
|
|
4097
|
+
}, [k, o]), w = F(() => {
|
|
4091
4098
|
E(r || { padding: 0.1 }), i == null || i();
|
|
4092
|
-
}, [E, r, i]),
|
|
4093
|
-
const
|
|
4094
|
-
|
|
4095
|
-
}, [
|
|
4099
|
+
}, [E, r, i]), C = F(() => {
|
|
4100
|
+
const T = !B;
|
|
4101
|
+
D(T), c == null || c(T);
|
|
4102
|
+
}, [B, c]), x = {
|
|
4096
4103
|
"top-left": { top: 10, left: 10 },
|
|
4097
4104
|
"top-right": { top: 10, right: 10 },
|
|
4098
4105
|
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
@@ -4103,25 +4110,25 @@ function ao({
|
|
|
4103
4110
|
return /* @__PURE__ */ $t(
|
|
4104
4111
|
"div",
|
|
4105
4112
|
{
|
|
4106
|
-
className: `ric-controls ${
|
|
4113
|
+
className: `ric-controls ${v}`,
|
|
4107
4114
|
style: {
|
|
4108
4115
|
position: "absolute",
|
|
4109
4116
|
display: "flex",
|
|
4110
4117
|
flexDirection: l === "horizontal" ? "row" : "column",
|
|
4111
4118
|
gap: 2,
|
|
4112
4119
|
zIndex: 5,
|
|
4113
|
-
...
|
|
4114
|
-
...
|
|
4120
|
+
...x,
|
|
4121
|
+
...g
|
|
4115
4122
|
},
|
|
4116
4123
|
role: "toolbar",
|
|
4117
|
-
"aria-label":
|
|
4124
|
+
"aria-label": N,
|
|
4118
4125
|
children: [
|
|
4119
|
-
t && /* @__PURE__ */ $t(
|
|
4126
|
+
t && /* @__PURE__ */ $t(Le, { children: [
|
|
4120
4127
|
/* @__PURE__ */ S(
|
|
4121
4128
|
rn,
|
|
4122
4129
|
{
|
|
4123
|
-
onClick:
|
|
4124
|
-
disabled:
|
|
4130
|
+
onClick: p,
|
|
4131
|
+
disabled: h,
|
|
4125
4132
|
title: "Zoom in",
|
|
4126
4133
|
"aria-label": "Zoom in",
|
|
4127
4134
|
className: "ric-controls-zoomin",
|
|
@@ -4131,7 +4138,7 @@ function ao({
|
|
|
4131
4138
|
/* @__PURE__ */ S(
|
|
4132
4139
|
rn,
|
|
4133
4140
|
{
|
|
4134
|
-
onClick:
|
|
4141
|
+
onClick: M,
|
|
4135
4142
|
disabled: f,
|
|
4136
4143
|
title: "Zoom out",
|
|
4137
4144
|
"aria-label": "Zoom out",
|
|
@@ -4153,11 +4160,11 @@ function ao({
|
|
|
4153
4160
|
n && /* @__PURE__ */ S(
|
|
4154
4161
|
rn,
|
|
4155
4162
|
{
|
|
4156
|
-
onClick:
|
|
4157
|
-
title:
|
|
4158
|
-
"aria-label":
|
|
4163
|
+
onClick: C,
|
|
4164
|
+
title: B ? "Lock interactivity" : "Unlock interactivity",
|
|
4165
|
+
"aria-label": B ? "Lock interactivity" : "Unlock interactivity",
|
|
4159
4166
|
className: "ric-controls-interactive",
|
|
4160
|
-
children:
|
|
4167
|
+
children: B ? /* @__PURE__ */ S(io, {}) : /* @__PURE__ */ S(so, {})
|
|
4161
4168
|
}
|
|
4162
4169
|
),
|
|
4163
4170
|
z
|
|
@@ -4235,34 +4242,34 @@ function ts({
|
|
|
4235
4242
|
color: c = "#3b82f6",
|
|
4236
4243
|
onResizeStart: u,
|
|
4237
4244
|
onResize: l,
|
|
4238
|
-
onResizeEnd:
|
|
4245
|
+
onResizeEnd: g
|
|
4239
4246
|
}) {
|
|
4240
|
-
const
|
|
4247
|
+
const v = qe(je), N = yt(), z = tt(null), R = F((E, _) => {
|
|
4241
4248
|
E.stopPropagation(), E.preventDefault();
|
|
4242
|
-
const
|
|
4243
|
-
if (!
|
|
4249
|
+
const B = N.nodesRef.current.find((h) => h.id === v);
|
|
4250
|
+
if (!B) return;
|
|
4244
4251
|
z.current = {
|
|
4245
4252
|
direction: _,
|
|
4246
4253
|
startX: E.clientX,
|
|
4247
4254
|
startY: E.clientY,
|
|
4248
|
-
width:
|
|
4249
|
-
height:
|
|
4255
|
+
width: B.width || 160,
|
|
4256
|
+
height: B.height || 60
|
|
4250
4257
|
}, u == null || u(E, { width: z.current.width, height: z.current.height });
|
|
4251
|
-
const
|
|
4252
|
-
var j,
|
|
4258
|
+
const D = (h) => {
|
|
4259
|
+
var j, W;
|
|
4253
4260
|
if (!z.current) return;
|
|
4254
|
-
const
|
|
4255
|
-
let
|
|
4256
|
-
|
|
4257
|
-
{ id:
|
|
4258
|
-
]), l == null || l(
|
|
4259
|
-
}, f = (
|
|
4260
|
-
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);
|
|
4261
4268
|
};
|
|
4262
|
-
window.addEventListener("pointermove",
|
|
4263
|
-
}, [
|
|
4269
|
+
window.addEventListener("pointermove", D), window.addEventListener("pointerup", f);
|
|
4270
|
+
}, [v, N, t, e, n, r, u, l, g]);
|
|
4264
4271
|
if (!s) return null;
|
|
4265
|
-
const $ = 8,
|
|
4272
|
+
const $ = 8, k = {
|
|
4266
4273
|
position: "absolute",
|
|
4267
4274
|
width: $,
|
|
4268
4275
|
height: $,
|
|
@@ -4272,61 +4279,61 @@ function ts({
|
|
|
4272
4279
|
zIndex: 20,
|
|
4273
4280
|
...o
|
|
4274
4281
|
};
|
|
4275
|
-
return /* @__PURE__ */ $t(
|
|
4282
|
+
return /* @__PURE__ */ $t(Le, { children: [
|
|
4276
4283
|
/* @__PURE__ */ S(
|
|
4277
4284
|
"div",
|
|
4278
4285
|
{
|
|
4279
|
-
style: { ...
|
|
4280
|
-
onPointerDown: (E) =>
|
|
4286
|
+
style: { ...k, bottom: -$ / 2, right: -$ / 2, cursor: "nwse-resize" },
|
|
4287
|
+
onPointerDown: (E) => R(E, "se")
|
|
4281
4288
|
}
|
|
4282
4289
|
),
|
|
4283
4290
|
/* @__PURE__ */ S(
|
|
4284
4291
|
"div",
|
|
4285
4292
|
{
|
|
4286
|
-
style: { ...
|
|
4287
|
-
onPointerDown: (E) =>
|
|
4293
|
+
style: { ...k, bottom: -$ / 2, left: -$ / 2, cursor: "nesw-resize" },
|
|
4294
|
+
onPointerDown: (E) => R(E, "sw")
|
|
4288
4295
|
}
|
|
4289
4296
|
),
|
|
4290
4297
|
/* @__PURE__ */ S(
|
|
4291
4298
|
"div",
|
|
4292
4299
|
{
|
|
4293
|
-
style: { ...
|
|
4294
|
-
onPointerDown: (E) =>
|
|
4300
|
+
style: { ...k, top: -$ / 2, right: -$ / 2, cursor: "nesw-resize" },
|
|
4301
|
+
onPointerDown: (E) => R(E, "ne")
|
|
4295
4302
|
}
|
|
4296
4303
|
),
|
|
4297
4304
|
/* @__PURE__ */ S(
|
|
4298
4305
|
"div",
|
|
4299
4306
|
{
|
|
4300
|
-
style: { ...
|
|
4301
|
-
onPointerDown: (E) =>
|
|
4307
|
+
style: { ...k, top: -$ / 2, left: -$ / 2, cursor: "nwse-resize" },
|
|
4308
|
+
onPointerDown: (E) => R(E, "nw")
|
|
4302
4309
|
}
|
|
4303
4310
|
),
|
|
4304
4311
|
/* @__PURE__ */ S(
|
|
4305
4312
|
"div",
|
|
4306
4313
|
{
|
|
4307
|
-
style: { ...
|
|
4308
|
-
onPointerDown: (E) =>
|
|
4314
|
+
style: { ...k, top: "50%", right: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4315
|
+
onPointerDown: (E) => R(E, "e")
|
|
4309
4316
|
}
|
|
4310
4317
|
),
|
|
4311
4318
|
/* @__PURE__ */ S(
|
|
4312
4319
|
"div",
|
|
4313
4320
|
{
|
|
4314
|
-
style: { ...
|
|
4315
|
-
onPointerDown: (E) =>
|
|
4321
|
+
style: { ...k, top: "50%", left: -$ / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4322
|
+
onPointerDown: (E) => R(E, "w")
|
|
4316
4323
|
}
|
|
4317
4324
|
),
|
|
4318
4325
|
/* @__PURE__ */ S(
|
|
4319
4326
|
"div",
|
|
4320
4327
|
{
|
|
4321
|
-
style: { ...
|
|
4322
|
-
onPointerDown: (E) =>
|
|
4328
|
+
style: { ...k, left: "50%", top: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4329
|
+
onPointerDown: (E) => R(E, "n")
|
|
4323
4330
|
}
|
|
4324
4331
|
),
|
|
4325
4332
|
/* @__PURE__ */ S(
|
|
4326
4333
|
"div",
|
|
4327
4334
|
{
|
|
4328
|
-
style: { ...
|
|
4329
|
-
onPointerDown: (E) =>
|
|
4335
|
+
style: { ...k, left: "50%", bottom: -$ / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4336
|
+
onPointerDown: (E) => R(E, "s")
|
|
4330
4337
|
}
|
|
4331
4338
|
)
|
|
4332
4339
|
] });
|
|
@@ -4340,9 +4347,9 @@ function es({
|
|
|
4340
4347
|
style: o = {},
|
|
4341
4348
|
className: i = ""
|
|
4342
4349
|
}) {
|
|
4343
|
-
const c = qe(je), l = yt().nodes.find((
|
|
4350
|
+
const c = qe(je), l = yt().nodes.find((N) => N.id === c);
|
|
4344
4351
|
if (!(t !== void 0 ? t : l == null ? void 0 : l.selected)) return null;
|
|
4345
|
-
const
|
|
4352
|
+
const v = {
|
|
4346
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 },
|
|
4347
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 },
|
|
4348
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 },
|
|
@@ -4356,10 +4363,10 @@ function es({
|
|
|
4356
4363
|
position: "absolute",
|
|
4357
4364
|
zIndex: 1e3,
|
|
4358
4365
|
pointerEvents: "all",
|
|
4359
|
-
...
|
|
4366
|
+
...v,
|
|
4360
4367
|
...o
|
|
4361
4368
|
},
|
|
4362
|
-
onPointerDown: (
|
|
4369
|
+
onPointerDown: (N) => N.stopPropagation(),
|
|
4363
4370
|
children: s
|
|
4364
4371
|
}
|
|
4365
4372
|
);
|
|
@@ -4527,7 +4534,7 @@ export {
|
|
|
4527
4534
|
vo as boxToRect,
|
|
4528
4535
|
or as buildObstacles,
|
|
4529
4536
|
Tn as clampPosition,
|
|
4530
|
-
|
|
4537
|
+
No as computeRoutedEdges,
|
|
4531
4538
|
zo as getBezierEdgeCenter,
|
|
4532
4539
|
nr as getBezierPath,
|
|
4533
4540
|
wo as getBoundsOfBoxes,
|
|
@@ -4550,14 +4557,14 @@ export {
|
|
|
4550
4557
|
Mo as nodeToRect,
|
|
4551
4558
|
Co as reconnectEdge,
|
|
4552
4559
|
mo as rectToBox,
|
|
4553
|
-
|
|
4560
|
+
Lo as routeSinglePath,
|
|
4554
4561
|
En as routedPointsToPath,
|
|
4555
4562
|
Pn as snapPosition,
|
|
4556
4563
|
Ho as useConnection,
|
|
4557
4564
|
Do as useEdges,
|
|
4558
4565
|
So as useEdgesState,
|
|
4559
4566
|
Xo as useHandleConnections,
|
|
4560
|
-
|
|
4567
|
+
Lr as useInfiniteCanvas,
|
|
4561
4568
|
Go as useInternalNode,
|
|
4562
4569
|
Uo as useKeyPress,
|
|
4563
4570
|
Wo as useNodeConnections,
|