@infinit-canvas/react 0.1.0
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/README.md +62 -0
- package/dist/react-infinite-canvas.cjs +830 -0
- package/dist/react-infinite-canvas.js +4555 -0
- package/dist/styles.css +117 -0
- package/package.json +54 -0
- package/src/types.d.ts +472 -0
|
@@ -0,0 +1,4555 @@
|
|
|
1
|
+
import { jsx as B, jsxs as It, Fragment as Le } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as V, useState as Gt, useMemo as St, useEffect as ut, useCallback as F, useContext as qe, createContext as Fn, memo as Zt, useLayoutEffect as kr } from "react";
|
|
3
|
+
import { createPortal as Yn } from "react-dom";
|
|
4
|
+
const Un = 160, qn = 60;
|
|
5
|
+
function ho(t) {
|
|
6
|
+
return t && typeof t == "object" && "position" in t && "data" in t;
|
|
7
|
+
}
|
|
8
|
+
function yo(t) {
|
|
9
|
+
return t && typeof t == "object" && "source" in t && "target" in t;
|
|
10
|
+
}
|
|
11
|
+
function zr(t, e) {
|
|
12
|
+
const n = typeof t == "string" ? /* @__PURE__ */ new Set([t]) : new Set(Array.isArray(t) ? t.map((r) => r.id) : [t.id]);
|
|
13
|
+
return e.filter((r) => n.has(r.source) || n.has(r.target));
|
|
14
|
+
}
|
|
15
|
+
function go(t, e, n) {
|
|
16
|
+
const r = typeof t == "string" ? t : t.id, s = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const o of n)
|
|
18
|
+
o.target === r && s.add(o.source);
|
|
19
|
+
return e.filter((o) => s.has(o.id));
|
|
20
|
+
}
|
|
21
|
+
function po(t, e, n) {
|
|
22
|
+
const r = typeof t == "string" ? t : t.id, s = /* @__PURE__ */ new Set();
|
|
23
|
+
for (const o of n)
|
|
24
|
+
o.source === r && s.add(o.target);
|
|
25
|
+
return e.filter((o) => s.has(o.id));
|
|
26
|
+
}
|
|
27
|
+
function Mn(t) {
|
|
28
|
+
if (!t.length) return { x: 0, y: 0, width: 0, height: 0 };
|
|
29
|
+
let e = 1 / 0, n = 1 / 0, r = -1 / 0, s = -1 / 0;
|
|
30
|
+
for (const o of t) {
|
|
31
|
+
const i = o.position.x, c = o.position.y, u = o.width || Un, l = o.height || qn;
|
|
32
|
+
i < e && (e = i), c < n && (n = c), i + u > r && (r = i + u), c + l > s && (s = c + l);
|
|
33
|
+
}
|
|
34
|
+
return { x: e, y: n, width: r - e, height: s - n };
|
|
35
|
+
}
|
|
36
|
+
function Rn(t, e, n, r = 0.1) {
|
|
37
|
+
const s = t.width * (1 + r * 2), o = t.height * (1 + r * 2), i = Math.min(e / s, n / o, 1), c = t.x + t.width / 2, u = t.y + t.height / 2;
|
|
38
|
+
return {
|
|
39
|
+
x: e / 2 - c * i,
|
|
40
|
+
y: n / 2 - u * i,
|
|
41
|
+
zoom: i
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function Pn(t, e) {
|
|
45
|
+
return {
|
|
46
|
+
x: e[0] * Math.round(t.x / e[0]),
|
|
47
|
+
y: e[1] * Math.round(t.y / e[1])
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function Tn(t, e) {
|
|
51
|
+
return {
|
|
52
|
+
x: Math.min(Math.max(t.x, e[0][0]), e[1][0]),
|
|
53
|
+
y: Math.min(Math.max(t.y, e[0][1]), e[1][1])
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function jn(t) {
|
|
57
|
+
var e, n;
|
|
58
|
+
return {
|
|
59
|
+
width: t.width || ((e = t.measured) == null ? void 0 : e.width) || Un,
|
|
60
|
+
height: t.height || ((n = t.measured) == null ? void 0 : n.height) || qn
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function xo(t, e, n = { x: 0, y: 0, zoom: 1 }, r = !1) {
|
|
64
|
+
const s = e.x, o = e.y, i = e.x + e.width, c = e.y + e.height;
|
|
65
|
+
return t.filter((u) => {
|
|
66
|
+
const { width: l, height: g } = jn(u), v = u.position.x, E = u.position.y, R = v + l, M = E + g;
|
|
67
|
+
return r ? v < i && R > s && E < c && M > o : v >= s && R <= i && E >= o && M <= c;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function mo(t) {
|
|
71
|
+
return { x: t.x, y: t.y, x2: t.x + t.width, y2: t.y + t.height };
|
|
72
|
+
}
|
|
73
|
+
function vo(t) {
|
|
74
|
+
return { x: t.x, y: t.y, width: t.x2 - t.x, height: t.y2 - t.y };
|
|
75
|
+
}
|
|
76
|
+
function wo(t, e) {
|
|
77
|
+
return {
|
|
78
|
+
x: Math.min(t.x, e.x),
|
|
79
|
+
y: Math.min(t.y, e.y),
|
|
80
|
+
x2: Math.max(t.x2, e.x2),
|
|
81
|
+
y2: Math.max(t.y2, e.y2)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function bo(t, e) {
|
|
85
|
+
const n = Math.max(0, Math.min(t.x + t.width, e.x + e.width) - Math.max(t.x, e.x)), r = Math.max(0, Math.min(t.y + t.height, e.y + e.height) - Math.max(t.y, e.y));
|
|
86
|
+
return n * r;
|
|
87
|
+
}
|
|
88
|
+
function Mo(t) {
|
|
89
|
+
const { width: e, height: n } = jn(t);
|
|
90
|
+
return { x: t.position.x, y: t.position.y, width: e, height: n };
|
|
91
|
+
}
|
|
92
|
+
const Gn = `var Ma = null, r = null, tr = 0, er = 0, g = { x: 0, y: 0, zoom: 1 }, O = [], B = [], P = [], G = !1, Ht = 40, Dt = !1, Br = "lines", Or = 1, lt = null, Pa = null, hr = null, E = 160, c = 60, ft = 8, ao = 5;
|
|
93
|
+
function h(a) {
|
|
94
|
+
return a._absolutePosition || a.position;
|
|
95
|
+
}
|
|
96
|
+
function Vo(a, t, e, o, v) {
|
|
97
|
+
if (a.x !== void 0 && a.y !== void 0)
|
|
98
|
+
return { x: t + a.x, y: e + a.y };
|
|
99
|
+
var f = a.position || (a.type === "source" ? "right" : "left");
|
|
100
|
+
switch (f) {
|
|
101
|
+
case "top":
|
|
102
|
+
return { x: t + o / 2, y: e };
|
|
103
|
+
case "bottom":
|
|
104
|
+
return { x: t + o / 2, y: e + v };
|
|
105
|
+
case "left":
|
|
106
|
+
return { x: t, y: e + v / 2 };
|
|
107
|
+
case "right":
|
|
108
|
+
return { x: t + o, y: e + v / 2 };
|
|
109
|
+
default:
|
|
110
|
+
return { x: t + o, y: e + v / 2 };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function ho(a) {
|
|
114
|
+
var t = a.width || E, e = a.height || c;
|
|
115
|
+
return a.handles && a.handles.length > 0 ? a.handles.map(function(o) {
|
|
116
|
+
var v = Vo(o, h(a).x, h(a).y, t, e);
|
|
117
|
+
return { id: o.id || null, type: o.type, x: v.x, y: v.y, position: o.position };
|
|
118
|
+
}) : [
|
|
119
|
+
{ id: null, type: "target", x: h(a).x, y: h(a).y + e / 2, position: "left" },
|
|
120
|
+
{ id: null, type: "source", x: h(a).x + t, y: h(a).y + e / 2, position: "right" }
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
var Ft = {}, Ka = !0;
|
|
124
|
+
function Uo(a) {
|
|
125
|
+
Ka && (Ft = {}, Ka = !1);
|
|
126
|
+
var t = Ft[a.id];
|
|
127
|
+
return t || (t = ho(a), Ft[a.id] = t, t);
|
|
128
|
+
}
|
|
129
|
+
function it(a, t, e) {
|
|
130
|
+
for (var o = Uo(a), v = 0; v < o.length; v++)
|
|
131
|
+
if (o[v].type === t)
|
|
132
|
+
if (e) {
|
|
133
|
+
if (o[v].id === e) return o[v];
|
|
134
|
+
} else
|
|
135
|
+
return o[v];
|
|
136
|
+
var f = a.width || E, l = a.height || c;
|
|
137
|
+
return t === "source" ? { x: h(a).x + f, y: h(a).y + l / 2 } : { x: h(a).x, y: h(a).y + l / 2 };
|
|
138
|
+
}
|
|
139
|
+
var z = {};
|
|
140
|
+
function Yt() {
|
|
141
|
+
z = {
|
|
142
|
+
grid: G ? "rgba(255,255,255,0.07)" : "rgba(0,0,0,0.07)",
|
|
143
|
+
origin: G ? "rgba(255,255,255,0.2)" : "rgba(0,0,0,0.15)",
|
|
144
|
+
cardBg: G ? "#2a2a28" : "#ffffff",
|
|
145
|
+
cardBorder: G ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.1)",
|
|
146
|
+
cardShadow: G ? "rgba(0,0,0,0.3)" : "rgba(0,0,0,0.06)",
|
|
147
|
+
titleText: "rgba(255,255,255,0.9)",
|
|
148
|
+
bodyText: G ? "rgba(255,255,255,0.55)" : "rgba(0,0,0,0.5)",
|
|
149
|
+
coordText: G ? "rgba(255,255,255,0.25)" : "rgba(0,0,0,0.2)",
|
|
150
|
+
nodeBg: G ? "#1e1e2e" : "#ffffff",
|
|
151
|
+
nodeBorder: G ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)",
|
|
152
|
+
nodeSelectedBorder: "#3b82f6",
|
|
153
|
+
nodeShadow: G ? "rgba(0,0,0,0.4)" : "rgba(0,0,0,0.08)",
|
|
154
|
+
nodeText: G ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.85)",
|
|
155
|
+
edgeStroke: G ? "rgba(255,255,255,0.35)" : "rgba(0,0,0,0.3)",
|
|
156
|
+
edgeSelected: "#3b82f6",
|
|
157
|
+
edgeAnimated: "#3b82f6",
|
|
158
|
+
handleFill: "#ffffff",
|
|
159
|
+
handleBorder: "#3b82f6",
|
|
160
|
+
connectionLine: "#3b82f6"
|
|
161
|
+
}, xa = !0;
|
|
162
|
+
}
|
|
163
|
+
Yt();
|
|
164
|
+
var Do = ["#534AB7", "#0F6E56", "#993C1D", "#185FA5"], Ga = 8, Fo = "500 11px system-ui, sans-serif", jo = "400 11px system-ui, sans-serif", Oo = "10px monospace", Xo = "500 13px system-ui, sans-serif", Ho = "400 11px system-ui, sans-serif", br = 400, Ia = {}, ht = !0;
|
|
165
|
+
function Yo() {
|
|
166
|
+
Ia = {};
|
|
167
|
+
for (var a = 0; a < O.length; a++)
|
|
168
|
+
for (var t = O[a], e = Math.floor(t.x / br), o = Math.floor(t.y / br), v = Math.floor((t.x + t.w) / br), f = Math.floor((t.y + t.h) / br), l = e; l <= v; l++)
|
|
169
|
+
for (var y = o; y <= f; y++) {
|
|
170
|
+
var d = l + "," + y;
|
|
171
|
+
Ia[d] || (Ia[d] = []), Ia[d].push(a);
|
|
172
|
+
}
|
|
173
|
+
ht = !1;
|
|
174
|
+
}
|
|
175
|
+
function to(a, t, e, o) {
|
|
176
|
+
ht && Yo();
|
|
177
|
+
for (var v = {}, f = [], l = Math.floor(a / br), y = Math.floor(t / br), d = Math.floor(e / br), M = Math.floor(o / br), x = l; x <= d; x++)
|
|
178
|
+
for (var i = y; i <= M; i++) {
|
|
179
|
+
var n = x + "," + i, s = Ia[n];
|
|
180
|
+
if (s)
|
|
181
|
+
for (var u = 0; u < s.length; u++) {
|
|
182
|
+
var w = s[u];
|
|
183
|
+
v[w] || (v[w] = !0, f.push(w));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return f;
|
|
187
|
+
}
|
|
188
|
+
var Nr = 500, Za = {}, Xr = !0;
|
|
189
|
+
function te() {
|
|
190
|
+
Za = {};
|
|
191
|
+
for (var a = 0; a < B.length; a++) {
|
|
192
|
+
var t = B[a];
|
|
193
|
+
if (!t.hidden)
|
|
194
|
+
for (var e = h(t), o = t.width || E, v = t.height || c, f = Math.floor(e.x / Nr), l = Math.floor(e.y / Nr), y = Math.floor((e.x + o) / Nr), d = Math.floor((e.y + v) / Nr), M = f; M <= y; M++)
|
|
195
|
+
for (var x = l; x <= d; x++) {
|
|
196
|
+
var i = M + "," + x;
|
|
197
|
+
Za[i] || (Za[i] = []), Za[i].push(a);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
Xr = !1;
|
|
201
|
+
}
|
|
202
|
+
function no(a, t, e, o) {
|
|
203
|
+
Xr && te();
|
|
204
|
+
for (var v = {}, f = [], l = Math.floor(a / Nr), y = Math.floor(t / Nr), d = Math.floor(e / Nr), M = Math.floor(o / Nr), x = l; x <= d; x++)
|
|
205
|
+
for (var i = y; i <= M; i++) {
|
|
206
|
+
var n = x + "," + i, s = Za[n];
|
|
207
|
+
if (s)
|
|
208
|
+
for (var u = 0; u < s.length; u++) {
|
|
209
|
+
var w = s[u];
|
|
210
|
+
v[w] || (v[w] = !0, f.push(w));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return f;
|
|
214
|
+
}
|
|
215
|
+
var ka = {}, ya = !0;
|
|
216
|
+
function ee() {
|
|
217
|
+
ka = {};
|
|
218
|
+
for (var a = 0; a < B.length; a++)
|
|
219
|
+
ka[B[a].id] = B[a];
|
|
220
|
+
ya = !1;
|
|
221
|
+
}
|
|
222
|
+
function eo(a) {
|
|
223
|
+
return ya && ee(), ka[a];
|
|
224
|
+
}
|
|
225
|
+
var Cr = {}, nt = !0;
|
|
226
|
+
function po() {
|
|
227
|
+
Cr = {};
|
|
228
|
+
for (var a = 0; a < P.length; a++) {
|
|
229
|
+
var t = P[a];
|
|
230
|
+
Cr[t.source] || (Cr[t.source] = []), Cr[t.source].push(a), t.source !== t.target && (Cr[t.target] || (Cr[t.target] = []), Cr[t.target].push(a));
|
|
231
|
+
}
|
|
232
|
+
nt = !1;
|
|
233
|
+
}
|
|
234
|
+
var jr = null, uo = 0, so = 0, Mo = "", xa = !0;
|
|
235
|
+
function rf(a) {
|
|
236
|
+
jr || (jr = new OffscreenCanvas(1, 1));
|
|
237
|
+
var t = Math.ceil(a), e = Math.ceil(a);
|
|
238
|
+
if (t < 2 || e < 2) return !1;
|
|
239
|
+
t > 512 && (t = 512), e > 512 && (e = 512), jr.width = t, jr.height = e, uo = t, so = a, Mo = Br, xa = !1;
|
|
240
|
+
var o = jr.getContext("2d");
|
|
241
|
+
o.clearRect(0, 0, t, e);
|
|
242
|
+
var v = lt || z.grid;
|
|
243
|
+
if (Br === "dots") {
|
|
244
|
+
o.fillStyle = v;
|
|
245
|
+
var f = Or * g.zoom;
|
|
246
|
+
o.beginPath(), o.arc(0, 0, f, 0, 6.2832), o.fill();
|
|
247
|
+
} else if (Br === "cross") {
|
|
248
|
+
o.strokeStyle = v, o.lineWidth = Or;
|
|
249
|
+
var l = 3 * g.zoom;
|
|
250
|
+
o.beginPath(), o.moveTo(-l, 0), o.lineTo(l, 0), o.moveTo(0, -l), o.lineTo(0, l), o.stroke();
|
|
251
|
+
} else
|
|
252
|
+
o.beginPath(), o.strokeStyle = v, o.lineWidth = Or * 0.5, o.moveTo(0.5, 0), o.lineTo(0.5, e), o.moveTo(0, 0.5), o.lineTo(t, 0.5), o.stroke();
|
|
253
|
+
return !0;
|
|
254
|
+
}
|
|
255
|
+
var oo = 0, jt = 0, fo = 0, vo = 0, pt = 0, Ja = !1;
|
|
256
|
+
console.log("[worker] script loaded v2 - FRESH");
|
|
257
|
+
self.postMessage({ type: "ping", data: { status: "alive" } });
|
|
258
|
+
self.onmessage = function(a) {
|
|
259
|
+
try {
|
|
260
|
+
var t = a.data.type, e = a.data.data;
|
|
261
|
+
switch (t) {
|
|
262
|
+
case "init":
|
|
263
|
+
Ma = e.canvas, r = Ma.getContext("2d"), tr = e.width, er = e.height, Ma.width = tr, Ma.height = er, g = e.camera, O = e.cards || [], B = e.nodes || [], P = e.edges || [], G = e.dark, e.gridSize && (Ht = e.gridSize), e.edgeRouting !== void 0 && (ga = !!e.edgeRouting), Yt(), ht = !0, ya = !0, Xr = !0, Ka = !0, nt = !0, Ja = P.some(function(d) {
|
|
264
|
+
return d.animated;
|
|
265
|
+
}), console.log("[worker] init done — canvas:", tr, "x", er, "| cards:", O.length, "| nodes:", B.length, "| edges:", P.length, "| routing:", ga), ut(), self.postMessage({ type: "ready" }), Ja && lo();
|
|
266
|
+
break;
|
|
267
|
+
case "resize":
|
|
268
|
+
tr = e.width, er = e.height, Ma.width = tr, Ma.height = er, xa = !0, ut();
|
|
269
|
+
break;
|
|
270
|
+
case "camera":
|
|
271
|
+
g = e.camera, xa = !0, or();
|
|
272
|
+
break;
|
|
273
|
+
case "cards":
|
|
274
|
+
O = e.cards, ht = !0, or();
|
|
275
|
+
break;
|
|
276
|
+
case "nodes":
|
|
277
|
+
B = e.nodes, ya = !0, Xr = !0, Ka = !0, or(), vt(), self.postMessage({ type: "nodesProcessed", data: { nodeCount: B.length } });
|
|
278
|
+
break;
|
|
279
|
+
case "nodePositions":
|
|
280
|
+
ya && ee();
|
|
281
|
+
for (var o = e.updates, v = 0; v < o.length; v++) {
|
|
282
|
+
var f = o[v], l = ka[f.id];
|
|
283
|
+
l && (l.position = f.position, f._absolutePosition && (l._absolutePosition = f._absolutePosition), f.width !== void 0 && (l.width = f.width), f.height !== void 0 && (l.height = f.height), l.dragging = f.dragging, l.selected = f.selected);
|
|
284
|
+
}
|
|
285
|
+
Ka = !0, Xr = !0, or(), vt();
|
|
286
|
+
break;
|
|
287
|
+
case "edges":
|
|
288
|
+
P = e.edges, nt = !0, Ja = P.some(function(d) {
|
|
289
|
+
return d.animated;
|
|
290
|
+
}), Ja && lo(), or(), vt();
|
|
291
|
+
break;
|
|
292
|
+
case "theme":
|
|
293
|
+
G = e.dark, Yt(), or();
|
|
294
|
+
break;
|
|
295
|
+
case "connecting":
|
|
296
|
+
Pa = e, or();
|
|
297
|
+
break;
|
|
298
|
+
case "selectionBox":
|
|
299
|
+
hr = e, or();
|
|
300
|
+
break;
|
|
301
|
+
case "background":
|
|
302
|
+
e.variant && (Br = e.variant), e.gap && (Ht = e.gap), e.size && (Or = e.size), lt = e.color || null, xa = !0, or();
|
|
303
|
+
break;
|
|
304
|
+
case "edgeRouting":
|
|
305
|
+
if (ga = !!e.enabled, ga)
|
|
306
|
+
vt();
|
|
307
|
+
else {
|
|
308
|
+
for (var y = 0; y < P.length; y++)
|
|
309
|
+
P[y]._routedPoints = null;
|
|
310
|
+
or();
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
} catch (d) {
|
|
315
|
+
console.error("[worker] error:", d);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
function or() {
|
|
319
|
+
Dt || (Dt = !0, requestAnimationFrame(function() {
|
|
320
|
+
Dt = !1, ut();
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
var Ot = !1;
|
|
324
|
+
function lo() {
|
|
325
|
+
if (Ot) return;
|
|
326
|
+
Ot = !0;
|
|
327
|
+
function a() {
|
|
328
|
+
if (!Ja) {
|
|
329
|
+
Ot = !1;
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
pt = (pt + 0.5) % 20, ut(), requestAnimationFrame(a);
|
|
333
|
+
}
|
|
334
|
+
requestAnimationFrame(a);
|
|
335
|
+
}
|
|
336
|
+
function io(a, t) {
|
|
337
|
+
var e = 6;
|
|
338
|
+
a.moveTo(t[0].x, t[0].y);
|
|
339
|
+
for (var o = 1; o < t.length - 1; o++) {
|
|
340
|
+
var v = t[o - 1], f = t[o], l = t[o + 1], y = Math.abs(f.x - v.x) + Math.abs(f.y - v.y), d = Math.abs(l.x - f.x) + Math.abs(l.y - f.y), M = Math.min(e, y / 2, d / 2);
|
|
341
|
+
if (M > 0.5) {
|
|
342
|
+
var x = f.x - v.x, i = f.y - v.y, n = l.x - f.x, s = l.y - f.y, u = Math.sqrt(x * x + i * i) || 1, w = Math.sqrt(n * n + s * s) || 1;
|
|
343
|
+
a.lineTo(f.x - x / u * M, f.y - i / u * M), a.quadraticCurveTo(f.x, f.y, f.x + n / w * M, f.y + s / w * M);
|
|
344
|
+
} else
|
|
345
|
+
a.lineTo(f.x, f.y);
|
|
346
|
+
}
|
|
347
|
+
a.lineTo(t[t.length - 1].x, t[t.length - 1].y);
|
|
348
|
+
}
|
|
349
|
+
function af(a) {
|
|
350
|
+
for (var t = 0, e = 1; e < a.length; e++)
|
|
351
|
+
t += Math.abs(a[e].x - a[e - 1].x) + Math.abs(a[e].y - a[e - 1].y);
|
|
352
|
+
for (var o = t / 2, v = 1; v < a.length; v++) {
|
|
353
|
+
var f = Math.abs(a[v].x - a[v - 1].x) + Math.abs(a[v].y - a[v - 1].y);
|
|
354
|
+
if (o <= f) {
|
|
355
|
+
var l = f > 0 ? o / f : 0;
|
|
356
|
+
return {
|
|
357
|
+
x: a[v - 1].x + (a[v].x - a[v - 1].x) * l,
|
|
358
|
+
y: a[v - 1].y + (a[v].y - a[v - 1].y) * l
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
o -= f;
|
|
362
|
+
}
|
|
363
|
+
return { x: a[0].x, y: a[0].y };
|
|
364
|
+
}
|
|
365
|
+
function re(a, t, e, o) {
|
|
366
|
+
var v = Math.abs(e - a), f = Math.max(50, v * 0.5), l = a + f, y = t, d = e - f, M = o;
|
|
367
|
+
return { cp1x: l, cp1y: y, cp2x: d, cp2y: M };
|
|
368
|
+
}
|
|
369
|
+
function tf(a, t, e, o) {
|
|
370
|
+
var v = re(a, t, e, o), f = 0.5, l = 1 - f, y = l * l * l * a + 3 * l * l * f * v.cp1x + 3 * l * f * f * v.cp2x + f * f * f * e, d = l * l * l * t + 3 * l * l * f * v.cp1y + 3 * l * f * f * v.cp2y + f * f * f * o;
|
|
371
|
+
return { x: y, y: d };
|
|
372
|
+
}
|
|
373
|
+
var ga = !0, ae = !1, Xt = !1;
|
|
374
|
+
function go(a, t, e, o, v) {
|
|
375
|
+
Xr && te();
|
|
376
|
+
for (var f = Math.min(a, e) - 20, l = Math.min(t, o) - 20, y = Math.max(a, e) + 20, d = Math.max(t, o) + 20, M = no(f, l, y, d), x = [], i = 0; i < M.length; i++) {
|
|
377
|
+
var n = B[M[i]];
|
|
378
|
+
n.hidden || v[n.id] || n.type !== "group" && x.push(n);
|
|
379
|
+
}
|
|
380
|
+
return x;
|
|
381
|
+
}
|
|
382
|
+
function dr(a, t, e, o) {
|
|
383
|
+
for (var v = Math.min(a, t), f = Math.max(a, t), l = 0; l < o.length; l++) {
|
|
384
|
+
var y = o[l], d = h(y), M = y.width || E, x = y.height || c;
|
|
385
|
+
if (e > d.y && e < d.y + x && f > d.x && v < d.x + M) return y;
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
function Mr(a, t, e, o) {
|
|
390
|
+
for (var v = Math.min(t, e), f = Math.max(t, e), l = 0; l < o.length; l++) {
|
|
391
|
+
var y = o[l], d = h(y), M = y.width || E, x = y.height || c;
|
|
392
|
+
if (a > d.x && a < d.x + M && f > d.y && v < d.y + x) return y;
|
|
393
|
+
}
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
function ef() {
|
|
397
|
+
if (ga && !(!ae || P.length === 0 || B.length === 0)) {
|
|
398
|
+
ae = !1, ya && ee(), Xr && te();
|
|
399
|
+
for (var a = 20, t = !1, e = 0; e < P.length; e++) {
|
|
400
|
+
var o = P[e];
|
|
401
|
+
if (!o._customRendered) {
|
|
402
|
+
var v = o.type || "default";
|
|
403
|
+
if (!(v === "bezier" || v === "simplebezier" || v === "default")) {
|
|
404
|
+
var f = ka[o.source], l = ka[o.target];
|
|
405
|
+
if (!(!f || !l || f.hidden || l.hidden)) {
|
|
406
|
+
var y = it(f, "source", o.sourceHandle), d = it(l, "target", o.targetHandle), M = y.position || "right", x = d.position || "left", i = y.x, n = y.y, s = d.x, u = d.y, w = i, Q = n, W = s, $ = u;
|
|
407
|
+
M === "right" ? w += a : M === "left" ? w -= a : M === "bottom" ? Q += a : M === "top" && (Q -= a), x === "right" ? W += a : x === "left" ? W -= a : x === "bottom" ? $ += a : x === "top" && ($ -= a);
|
|
408
|
+
var gr = h(f), qr = h(l), Sr = f.width || E, Gr = f.height || c, Pr = l.width || E, Hr = l.height || c, Ir = {};
|
|
409
|
+
Ir[o.source] = !0, Ir[o.target] = !0;
|
|
410
|
+
var X = go(
|
|
411
|
+
Math.min(i, s) - Sr,
|
|
412
|
+
Math.min(n, u) - Gr,
|
|
413
|
+
Math.max(i, s) + Pr,
|
|
414
|
+
Math.max(n, u) + Hr,
|
|
415
|
+
Ir
|
|
416
|
+
);
|
|
417
|
+
X.push(f), X.push(l);
|
|
418
|
+
var Yr = M === "left" || M === "right", Ta = x === "left" || x === "right", C = null;
|
|
419
|
+
if (Yr && Ta) {
|
|
420
|
+
var L, fr = M === "right" && w < W, st = M === "left" && w > W;
|
|
421
|
+
if (fr || st) {
|
|
422
|
+
L = (w + W) / 2;
|
|
423
|
+
var ma = Mr(L, n, u, X);
|
|
424
|
+
if (ma) {
|
|
425
|
+
var pr = h(ma), ra = ma.width || E;
|
|
426
|
+
L = L < pr.x + ra / 2 ? pr.x - a : pr.x + ra + a;
|
|
427
|
+
}
|
|
428
|
+
} else
|
|
429
|
+
M === "right" ? L = Math.max(gr.x + Sr, qr.x + Pr) + a : L = Math.min(gr.x, qr.x) - a;
|
|
430
|
+
C = [{ x: i, y: n }, { x: w, y: n }, { x: L, y: n }, { x: L, y: u }, { x: W, y: u }, { x: s, y: u }];
|
|
431
|
+
var yr = dr(L, W, u, X);
|
|
432
|
+
if (yr) {
|
|
433
|
+
var aa = h(yr), ta = yr.height || c, ea = aa.y - a, Zr = aa.y + ta + a, Jr = Math.abs(n - ea) <= Math.abs(n - Zr) ? ea : Zr;
|
|
434
|
+
C = [{ x: i, y: n }, { x: w, y: n }, { x: L, y: n }, { x: L, y: Jr }, { x: W, y: Jr }, { x: W, y: u }, { x: s, y: u }];
|
|
435
|
+
}
|
|
436
|
+
} else if (!Yr && !Ta) {
|
|
437
|
+
var N, Qa = M === "bottom" && Q < $, Ra = M === "top" && Q > $;
|
|
438
|
+
if (Qa || Ra) {
|
|
439
|
+
N = (Q + $) / 2;
|
|
440
|
+
var xr = dr(i, s, N, X);
|
|
441
|
+
if (xr) {
|
|
442
|
+
var kr = h(xr), oa = xr.height || c;
|
|
443
|
+
N = N < kr.y + oa / 2 ? kr.y - a : kr.y + oa + a;
|
|
444
|
+
}
|
|
445
|
+
} else
|
|
446
|
+
M === "bottom" ? N = Math.max(gr.y + Gr, qr.y + Hr) + a : N = Math.min(gr.y, qr.y) - a;
|
|
447
|
+
C = [{ x: i, y: n }, { x: i, y: Q }, { x: i, y: N }, { x: s, y: N }, { x: s, y: $ }, { x: s, y: u }];
|
|
448
|
+
var Kr = Mr(s, N, $, X);
|
|
449
|
+
if (Kr) {
|
|
450
|
+
var fa = h(Kr), wa = Kr.height || c, va = fa.y - a, la = fa.y + wa + a, ia = Math.abs(N - va) <= Math.abs(N - la) ? va : la;
|
|
451
|
+
C = [{ x: i, y: n }, { x: i, y: Q }, { x: i, y: N }, { x: s, y: N }, { x: s, y: ia }, { x: W, y: ia }, { x: W, y: u }, { x: s, y: u }];
|
|
452
|
+
}
|
|
453
|
+
} else if (Yr) {
|
|
454
|
+
C = [{ x: i, y: n }, { x: w, y: n }, { x: s, y: n }, { x: s, y: $ }, { x: s, y: u }];
|
|
455
|
+
var Tr = Mr(s, n, $, X);
|
|
456
|
+
if (Tr) {
|
|
457
|
+
var V = h(Tr), mr = Tr.width || E, za = Math.abs(i - V.x + a) <= Math.abs(i - V.x - mr - a) ? V.x - a : V.x + mr + a;
|
|
458
|
+
C = [{ x: i, y: n }, { x: w, y: n }, { x: za, y: n }, { x: za, y: u }, { x: s, y: u }, { x: s, y: $ }, { x: s, y: u }];
|
|
459
|
+
}
|
|
460
|
+
var Qr = dr(w, s, n, X);
|
|
461
|
+
if (Qr) {
|
|
462
|
+
var Rr = h(Qr), ha = Qr.height || c, H = Math.abs(u - Rr.y + a) <= Math.abs(u - Rr.y - ha - a) ? Rr.y - a : Rr.y + ha + a;
|
|
463
|
+
C = [{ x: i, y: n }, { x: w, y: n }, { x: w, y: H }, { x: s, y: H }, { x: s, y: $ }, { x: s, y: u }];
|
|
464
|
+
}
|
|
465
|
+
} else {
|
|
466
|
+
C = [{ x: i, y: n }, { x: i, y: Q }, { x: i, y: u }, { x: W, y: u }, { x: s, y: u }];
|
|
467
|
+
var wr = dr(i, W, u, X);
|
|
468
|
+
if (wr) {
|
|
469
|
+
var na = h(wr), U = wr.height || c, zr = Math.abs(n - na.y + a) <= Math.abs(n - na.y - U - a) ? na.y - a : na.y + U + a;
|
|
470
|
+
C = [{ x: i, y: n }, { x: i, y: Q }, { x: i, y: zr }, { x: W, y: zr }, { x: W, y: u }, { x: s, y: u }];
|
|
471
|
+
}
|
|
472
|
+
var nr = Mr(i, Q, u, X);
|
|
473
|
+
if (nr) {
|
|
474
|
+
var vr = h(nr), ca = nr.width || E, _a = Math.abs(s - vr.x + a) <= Math.abs(s - vr.x - ca - a) ? vr.x - a : vr.x + ca + a;
|
|
475
|
+
C = [{ x: i, y: n }, { x: i, y: Q }, { x: _a, y: Q }, { x: _a, y: u }, { x: W, y: u }, { x: s, y: u }];
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (C) {
|
|
479
|
+
for (var $r = [C[0]], lr = 1; lr < C.length; lr++) {
|
|
480
|
+
var $a = $r[$r.length - 1];
|
|
481
|
+
(Math.abs(C[lr].x - $a.x) > 0.1 || Math.abs(C[lr].y - $a.y) > 0.1) && $r.push(C[lr]);
|
|
482
|
+
}
|
|
483
|
+
o._routedPoints = $r, t = !0;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
t && or();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function vt() {
|
|
493
|
+
ga && (Xt || (Xt = !0, ae = !0, requestAnimationFrame(function() {
|
|
494
|
+
Xt = !1;
|
|
495
|
+
try {
|
|
496
|
+
ef();
|
|
497
|
+
} catch (a) {
|
|
498
|
+
console.error("[worker] async routing error:", a);
|
|
499
|
+
}
|
|
500
|
+
})));
|
|
501
|
+
}
|
|
502
|
+
function ut() {
|
|
503
|
+
if (r) {
|
|
504
|
+
var a = performance.now();
|
|
505
|
+
r.clearRect(0, 0, tr, er);
|
|
506
|
+
var t = Ht * g.zoom;
|
|
507
|
+
if (t > 2)
|
|
508
|
+
if (Br === "lines" && t >= 4 && t <= 512) {
|
|
509
|
+
if ((xa || so !== t || Mo !== Br) && rf(t), jr && uo > 0) {
|
|
510
|
+
var e = (g.x % t + t) % t, o = (g.y % t + t) % t;
|
|
511
|
+
r.save(), r.translate(e, o);
|
|
512
|
+
var v = r.createPattern(jr, "repeat");
|
|
513
|
+
v && (r.fillStyle = v, r.fillRect(-e, -o, tr, er)), r.restore();
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
var f = (g.x % t + t) % t, l = (g.y % t + t) % t, y = lt || z.grid;
|
|
517
|
+
if (Br === "dots") {
|
|
518
|
+
r.fillStyle = y;
|
|
519
|
+
for (var d = Or * g.zoom, M = f; M < tr; M += t)
|
|
520
|
+
for (var x = l; x < er; x += t)
|
|
521
|
+
r.beginPath(), r.arc(Math.round(M), Math.round(x), d, 0, 6.2832), r.fill();
|
|
522
|
+
} else if (Br === "cross") {
|
|
523
|
+
r.strokeStyle = y, r.lineWidth = Or;
|
|
524
|
+
var i = 3 * g.zoom;
|
|
525
|
+
r.beginPath();
|
|
526
|
+
for (var n = f; n < tr; n += t)
|
|
527
|
+
for (var s = l; s < er; s += t) {
|
|
528
|
+
var u = Math.round(n), w = Math.round(s);
|
|
529
|
+
r.moveTo(u - i, w), r.lineTo(u + i, w), r.moveTo(u, w - i), r.lineTo(u, w + i);
|
|
530
|
+
}
|
|
531
|
+
r.stroke();
|
|
532
|
+
} else {
|
|
533
|
+
var Q = lt || z.grid;
|
|
534
|
+
r.beginPath(), r.strokeStyle = Q, r.lineWidth = Or * 0.5;
|
|
535
|
+
for (var W = f; W < tr; W += t) {
|
|
536
|
+
var $ = Math.round(W) + 0.5;
|
|
537
|
+
r.moveTo($, 0), r.lineTo($, er);
|
|
538
|
+
}
|
|
539
|
+
for (var gr = l; gr < er; gr += t) {
|
|
540
|
+
var qr = Math.round(gr) + 0.5;
|
|
541
|
+
r.moveTo(0, qr), r.lineTo(tr, qr);
|
|
542
|
+
}
|
|
543
|
+
r.stroke();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
r.beginPath(), r.arc(g.x, g.y, 4 * g.zoom, 0, 6.2832), r.fillStyle = z.origin, r.fill(), r.save(), r.translate(g.x, g.y), r.scale(g.zoom, g.zoom);
|
|
547
|
+
var Sr = 100, Gr = -g.x / g.zoom, Pr = -g.y / g.zoom, Hr = Gr + tr / g.zoom, Ir = Pr + er / g.zoom, X = Gr - Sr, Yr = Pr - Sr, Ta = Hr + Sr, C = Ir + Sr;
|
|
548
|
+
if (O.length > 0) {
|
|
549
|
+
var L = to(Gr, Pr, Hr, Ir), fr = L.length, st = g.zoom > 0.15, ma = g.zoom > 0.3, pr = g.zoom > 0.08 && fr < 200;
|
|
550
|
+
if (pr) {
|
|
551
|
+
r.shadowColor = z.cardShadow, r.shadowBlur = 6, r.shadowOffsetY = 2, r.fillStyle = z.cardBg, r.beginPath();
|
|
552
|
+
for (var ra = 0; ra < fr; ra++) {
|
|
553
|
+
var yr = O[L[ra]];
|
|
554
|
+
r.roundRect(yr.x, yr.y, yr.w, yr.h, Ga);
|
|
555
|
+
}
|
|
556
|
+
r.fill(), r.shadowColor = "transparent", r.shadowBlur = 0, r.shadowOffsetY = 0;
|
|
557
|
+
}
|
|
558
|
+
if (!pr) {
|
|
559
|
+
r.fillStyle = z.cardBg, r.beginPath();
|
|
560
|
+
for (var aa = 0; aa < fr; aa++) {
|
|
561
|
+
var ta = O[L[aa]];
|
|
562
|
+
r.roundRect(ta.x, ta.y, ta.w, ta.h, Ga);
|
|
563
|
+
}
|
|
564
|
+
r.fill();
|
|
565
|
+
}
|
|
566
|
+
r.strokeStyle = z.cardBorder, r.lineWidth = 0.5, r.beginPath();
|
|
567
|
+
for (var ea = 0; ea < fr; ea++) {
|
|
568
|
+
var Zr = O[L[ea]];
|
|
569
|
+
r.roundRect(Zr.x, Zr.y, Zr.w, Zr.h, Ga);
|
|
570
|
+
}
|
|
571
|
+
r.stroke();
|
|
572
|
+
for (var Jr = [{}, {}, {}, {}], N = 0; N < fr; N++) {
|
|
573
|
+
var Qa = L[N], Ra = Qa % 4;
|
|
574
|
+
Jr[Ra].items || (Jr[Ra].items = []), Jr[Ra].items.push(O[Qa]);
|
|
575
|
+
}
|
|
576
|
+
for (var xr = 0; xr < 4; xr++) {
|
|
577
|
+
var kr = Jr[xr].items;
|
|
578
|
+
if (!(!kr || kr.length === 0)) {
|
|
579
|
+
r.fillStyle = Do[xr], r.beginPath();
|
|
580
|
+
for (var oa = 0; oa < kr.length; oa++) {
|
|
581
|
+
var Kr = kr[oa];
|
|
582
|
+
r.roundRect(Kr.x, Kr.y, Kr.w, 30, [Ga, Ga, 0, 0]);
|
|
583
|
+
}
|
|
584
|
+
r.fill();
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (st) {
|
|
588
|
+
r.fillStyle = z.titleText, r.font = Fo;
|
|
589
|
+
for (var fa = 0; fa < fr; fa++) {
|
|
590
|
+
var wa = O[L[fa]];
|
|
591
|
+
r.fillText(wa.title, wa.x + 12, wa.y + 19);
|
|
592
|
+
}
|
|
593
|
+
r.fillStyle = z.bodyText, r.font = jo;
|
|
594
|
+
for (var va = 0; va < fr; va++) {
|
|
595
|
+
var la = O[L[va]];
|
|
596
|
+
r.fillText(la.body, la.x + 12, la.y + 52);
|
|
597
|
+
}
|
|
598
|
+
if (ma) {
|
|
599
|
+
r.fillStyle = z.coordText, r.font = Oo;
|
|
600
|
+
for (var ia = 0; ia < fr; ia++) {
|
|
601
|
+
var Tr = O[L[ia]];
|
|
602
|
+
r.fillText("(" + Tr.x + ", " + Tr.y + ")", Tr.x + 12, Tr.y + 75);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
var V = [], mr = null;
|
|
608
|
+
if (B.length > 0)
|
|
609
|
+
if (mr = {}, B.length > 100)
|
|
610
|
+
for (var za = no(X, Yr, Ta, C), Qr = 0; Qr < za.length; Qr++) {
|
|
611
|
+
var Rr = B[za[Qr]];
|
|
612
|
+
mr[Rr.id] = !0, Rr._customRendered || V.push(Rr);
|
|
613
|
+
}
|
|
614
|
+
else
|
|
615
|
+
for (var ha = 0; ha < B.length; ha++) {
|
|
616
|
+
var H = B[ha];
|
|
617
|
+
if (!H.hidden) {
|
|
618
|
+
var wr = H.width || E, na = H.height || c;
|
|
619
|
+
h(H).x + wr < X || h(H).x > Ta || h(H).y + na < Yr || h(H).y > C || (mr[H.id] = !0, H._customRendered || V.push(H));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
var U = V.length;
|
|
623
|
+
if (P.length > 0 && B.length > 0) {
|
|
624
|
+
let ot = function(Lr, ro) {
|
|
625
|
+
if (Lr.length) {
|
|
626
|
+
r.fillStyle = ro, r.beginPath();
|
|
627
|
+
for (var Ut = 0; Ut < Lr.length; Ut++) {
|
|
628
|
+
var j = Lr[Ut];
|
|
629
|
+
r.moveTo(j.x, j.y), r.lineTo(j.x - j.size * Math.cos(j.angle - 0.5236), j.y - j.size * Math.sin(j.angle - 0.5236)), r.lineTo(j.x - j.size * Math.cos(j.angle + 0.5236), j.y - j.size * Math.sin(j.angle + 0.5236)), r.closePath();
|
|
630
|
+
}
|
|
631
|
+
r.fill();
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var of = ot;
|
|
635
|
+
nt && po();
|
|
636
|
+
var zr = null, nr = null, vr = null, ca = [], _a = [], $r = [], lr = [], $a = g.zoom > 0.3, yo = g.zoom > 0.05, ua;
|
|
637
|
+
if (mr && B.length > 100) {
|
|
638
|
+
var oe = {};
|
|
639
|
+
ua = [];
|
|
640
|
+
for (var xo in mr) {
|
|
641
|
+
var dt = Cr[xo];
|
|
642
|
+
if (dt)
|
|
643
|
+
for (var Mt = 0; Mt < dt.length; Mt++) {
|
|
644
|
+
var gt = dt[Mt];
|
|
645
|
+
oe[gt] || (oe[gt] = !0, ua.push(gt));
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
ua = [];
|
|
650
|
+
for (var yt = 0; yt < P.length; yt++) ua.push(yt);
|
|
651
|
+
}
|
|
652
|
+
for (var xt = 0; xt < ua.length; xt++) {
|
|
653
|
+
var D = P[ua[xt]], Vr = eo(D.source), Ur = eo(D.target);
|
|
654
|
+
if (!(!Vr || !Ur) && !(Vr.hidden || Ur.hidden) && !D._customRendered) {
|
|
655
|
+
var Va = it(Vr, "source", D.sourceHandle), Ua = it(Ur, "target", D.targetHandle), _ = Va.x, R = Va.y, T = Ua.x, m = Ua.y, ir = D.type || "default", fe = D.selected, ve = D.animated, q;
|
|
656
|
+
fe ? (nr || (nr = new Path2D()), q = nr) : ve ? (vr || (vr = new Path2D()), q = vr) : (zr || (zr = new Path2D()), q = zr);
|
|
657
|
+
var S = D._routedPoints;
|
|
658
|
+
if (S && S.length >= 2)
|
|
659
|
+
io(q, S);
|
|
660
|
+
else if (ir === "straight")
|
|
661
|
+
q.moveTo(_, R), q.lineTo(T, m);
|
|
662
|
+
else if (ir === "step" || ir === "smoothstep")
|
|
663
|
+
try {
|
|
664
|
+
var Y = Va.position || "right", sa = Ua.position || "left", k = 20, I = _, F = R, Z = T, p = m;
|
|
665
|
+
Y === "right" ? I += k : Y === "left" ? I -= k : Y === "bottom" ? F += k : Y === "top" && (F -= k), sa === "right" ? Z += k : sa === "left" ? Z -= k : sa === "bottom" ? p += k : sa === "top" && (p -= k);
|
|
666
|
+
var Da = h(Vr), Fa = h(Ur), Aa = Vr.width || E, Ea = Vr.height || c, le = Ur.width || E, ie = Ur.height || c, kt = Y === "left" || Y === "right", he = sa === "left" || sa === "right", Tt = {};
|
|
667
|
+
Tt[D.source] = !0, Tt[D.target] = !0;
|
|
668
|
+
var rr = go(
|
|
669
|
+
Math.min(_, T) - Aa,
|
|
670
|
+
Math.min(R, m) - Ea,
|
|
671
|
+
Math.max(_, T) + le,
|
|
672
|
+
Math.max(R, m) + ie,
|
|
673
|
+
Tt
|
|
674
|
+
);
|
|
675
|
+
rr.push(Vr), rr.push(Ur);
|
|
676
|
+
var b = [];
|
|
677
|
+
if (kt && he) {
|
|
678
|
+
var J, ko = Y === "right" && I < Z, To = Y === "left" && I > Z;
|
|
679
|
+
if (ko || To) {
|
|
680
|
+
J = (I + Z) / 2;
|
|
681
|
+
var mt = Mr(J, R, m, rr);
|
|
682
|
+
if (mt) {
|
|
683
|
+
var Rt = h(mt), wr = mt.width || E;
|
|
684
|
+
J < Rt.x + wr / 2 ? J = Rt.x - k : J = Rt.x + wr + k;
|
|
685
|
+
}
|
|
686
|
+
} else
|
|
687
|
+
Y === "right" ? J = Math.max(Da.x + Aa, Fa.x + le) + k : J = Math.min(Da.x, Fa.x) - k;
|
|
688
|
+
b = [{ x: I, y: R }, { x: J, y: R }, { x: J, y: m }, { x: Z, y: m }];
|
|
689
|
+
var wt = dr(J, Z, m, rr);
|
|
690
|
+
if (wt) {
|
|
691
|
+
var ne = h(wt), mo = wt.height || c, ue = ne.y - k, se = ne.y + mo + k, de = Math.abs(R - ue) <= Math.abs(R - se) ? ue : se;
|
|
692
|
+
b = [
|
|
693
|
+
{ x: I, y: R },
|
|
694
|
+
{ x: J, y: R },
|
|
695
|
+
{ x: J, y: de },
|
|
696
|
+
{ x: Z, y: de },
|
|
697
|
+
{ x: Z, y: m }
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
var zt = dr(I, J, R, rr);
|
|
701
|
+
if (zt) {
|
|
702
|
+
var Me = h(zt), Ro = zt.height || c, ge = Me.y - k, ye = Me.y + Ro + k, xe = Math.abs(m - ge) <= Math.abs(m - ye) ? ge : ye;
|
|
703
|
+
b.splice(
|
|
704
|
+
1,
|
|
705
|
+
0,
|
|
706
|
+
{ x: I, y: xe },
|
|
707
|
+
{ x: J, y: xe }
|
|
708
|
+
), b = b.filter(function(Lr, ro) {
|
|
709
|
+
return !(Math.abs(Lr.x - J) < 1 && Math.abs(Lr.y - R) < 1);
|
|
710
|
+
}), b.splice(0, 0, { x: I, y: R });
|
|
711
|
+
}
|
|
712
|
+
} else if (!kt && !he) {
|
|
713
|
+
var K, wo = Y === "bottom" && F < p, zo = Y === "top" && F > p;
|
|
714
|
+
if (wo || zo) {
|
|
715
|
+
K = (F + p) / 2;
|
|
716
|
+
var ct = dr(_, T, K, rr);
|
|
717
|
+
if (ct) {
|
|
718
|
+
var _t = h(ct), ke = ct.height || c;
|
|
719
|
+
K < _t.y + ke / 2 ? K = _t.y - k : K = _t.y + ke + k;
|
|
720
|
+
}
|
|
721
|
+
} else
|
|
722
|
+
Y === "bottom" ? K = Math.max(Da.y + Ea, Fa.y + ie) + k : K = Math.min(Da.y, Fa.y) - k;
|
|
723
|
+
b = [{ x: _, y: F }, { x: _, y: K }, { x: T, y: K }, { x: T, y: p }];
|
|
724
|
+
var At = Mr(_, F, K, rr);
|
|
725
|
+
if (At) {
|
|
726
|
+
var Te = h(At), co = At.width || E, me = Te.x - k, Re = Te.x + co + k, we = Math.abs(T - me) <= Math.abs(T - Re) ? me : Re;
|
|
727
|
+
b = [
|
|
728
|
+
{ x: _, y: F },
|
|
729
|
+
{ x: we, y: F },
|
|
730
|
+
{ x: we, y: K },
|
|
731
|
+
{ x: T, y: K },
|
|
732
|
+
{ x: T, y: p }
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
var Et = Mr(T, K, p, rr);
|
|
736
|
+
if (Et) {
|
|
737
|
+
var ze = h(Et), _o = Et.height || c, ce = ze.y - k, _e = ze.y + _o + k, Ao = Math.abs(K - ce) <= Math.abs(K - _e) ? ce : _e;
|
|
738
|
+
b.splice(
|
|
739
|
+
b.length - 1,
|
|
740
|
+
0,
|
|
741
|
+
{ x: Z, y: Ao }
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
} else if (kt) {
|
|
745
|
+
b = [{ x: I, y: R }, { x: T, y: R }, { x: T, y: p }];
|
|
746
|
+
var Wt = Mr(T, R, p, rr);
|
|
747
|
+
if (Wt) {
|
|
748
|
+
var Ae = h(Wt), Eo = Wt.width || E, Ee = Ae.x - k, We = Ae.x + Eo + k, Le = Math.abs(_ - Ee) <= Math.abs(_ - We) ? Ee : We;
|
|
749
|
+
b = [{ x: I, y: R }, { x: Le, y: R }, { x: Le, y: m }, { x: T, y: m }, { x: T, y: p }];
|
|
750
|
+
}
|
|
751
|
+
var Lt = dr(I, T, R, rr);
|
|
752
|
+
if (Lt) {
|
|
753
|
+
var Ce = h(Lt), Wo = Lt.height || c, Be = Ce.y - k, be = Ce.y + Wo + k, Ne = Math.abs(m - Be) <= Math.abs(m - be) ? Be : be;
|
|
754
|
+
b = [{ x: I, y: R }, { x: I, y: Ne }, { x: T, y: Ne }, { x: T, y: p }];
|
|
755
|
+
}
|
|
756
|
+
} else {
|
|
757
|
+
b = [{ x: _, y: F }, { x: _, y: m }, { x: Z, y: m }];
|
|
758
|
+
var Ct = dr(_, Z, m, rr);
|
|
759
|
+
if (Ct) {
|
|
760
|
+
var qe = h(Ct), Lo = Ct.height || c, Se = qe.y - k, Ge = qe.y + Lo + k, Pe = Math.abs(R - Se) <= Math.abs(R - Ge) ? Se : Ge;
|
|
761
|
+
b = [{ x: _, y: F }, { x: _, y: Pe }, { x: Z, y: Pe }, { x: Z, y: m }];
|
|
762
|
+
}
|
|
763
|
+
var Bt = Mr(_, F, m, rr);
|
|
764
|
+
if (Bt) {
|
|
765
|
+
var Ie = h(Bt), Co = Bt.width || E, Ze = Ie.x - k, Je = Ie.x + Co + k, Ke = Math.abs(T - Ze) <= Math.abs(T - Je) ? Ze : Je;
|
|
766
|
+
b = [{ x: _, y: F }, { x: Ke, y: F }, { x: Ke, y: m }, { x: Z, y: m }];
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
for (var Dr = [{ x: _, y: R }], bt = 0; bt < b.length; bt++) Dr.push(b[bt]);
|
|
770
|
+
Dr.push({ x: T, y: m });
|
|
771
|
+
for (var ar = [Dr[0]], Wa = 1; Wa < Dr.length; Wa++) {
|
|
772
|
+
var La = ar[ar.length - 1];
|
|
773
|
+
(Math.abs(Dr[Wa].x - La.x) > 0.1 || Math.abs(Dr[Wa].y - La.y) > 0.1) && ar.push(Dr[Wa]);
|
|
774
|
+
}
|
|
775
|
+
var Qe = ir === "smoothstep" ? 8 : 0;
|
|
776
|
+
q.moveTo(ar[0].x, ar[0].y);
|
|
777
|
+
for (var ur = 1; ur < ar.length; ur++)
|
|
778
|
+
if (Qe > 0 && ur > 0 && ur < ar.length - 1) {
|
|
779
|
+
var sr = ar[ur - 1], A = ar[ur], cr = ar[ur + 1];
|
|
780
|
+
if (Math.abs(sr.x - A.x) < 0.5 && Math.abs(A.x - cr.x) < 0.5 || Math.abs(sr.y - A.y) < 0.5 && Math.abs(A.y - cr.y) < 0.5)
|
|
781
|
+
q.lineTo(A.x, A.y);
|
|
782
|
+
else {
|
|
783
|
+
var ja = Math.min(Math.hypot(sr.x - A.x, sr.y - A.y) / 2, Math.hypot(A.x - cr.x, A.y - cr.y) / 2, Qe);
|
|
784
|
+
Math.abs(sr.y - A.y) < 0.5 ? (q.lineTo(A.x + (sr.x < cr.x ? -1 : 1) * ja, A.y), q.quadraticCurveTo(A.x, A.y, A.x, A.y + (sr.y < cr.y ? 1 : -1) * ja)) : (q.lineTo(A.x, A.y + (sr.y < cr.y ? -1 : 1) * ja), q.quadraticCurveTo(A.x, A.y, A.x + (sr.x < cr.x ? 1 : -1) * ja, A.y));
|
|
785
|
+
}
|
|
786
|
+
} else
|
|
787
|
+
q.lineTo(ar[ur].x, ar[ur].y);
|
|
788
|
+
} catch (Lr) {
|
|
789
|
+
console.error("[worker] smoothstep error:", Lr, "edge:", D.id);
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
var _r = Va.position || "right", Ar = Ua.position || "left", Er = 20, Ca = _, Oa = R, Ba = T, Xa = m;
|
|
793
|
+
_r === "right" ? Ca += Er : _r === "left" ? Ca -= Er : _r === "bottom" ? Oa += Er : _r === "top" && (Oa -= Er), Ar === "right" ? Ba += Er : Ar === "left" ? Ba -= Er : Ar === "bottom" ? Xa += Er : Ar === "top" && (Xa -= Er);
|
|
794
|
+
var Bo = Math.abs(Ba - Ca), Wr = Math.max(50, Bo * 0.5), bo = Ca + (_r === "left" ? -Wr : _r === "right" ? Wr : 0), No = Oa + (_r === "top" ? -Wr : _r === "bottom" ? Wr : 0), qo = Ba + (Ar === "left" ? -Wr : Ar === "right" ? Wr : 0), So = Xa + (Ar === "top" ? -Wr : Ar === "bottom" ? Wr : 0);
|
|
795
|
+
q.moveTo(_, R), q.lineTo(Ca, Oa), q.bezierCurveTo(bo, No, qo, So, Ba, Xa), q.lineTo(T, m);
|
|
796
|
+
}
|
|
797
|
+
if (yo) {
|
|
798
|
+
var Go = 8, ba;
|
|
799
|
+
if (S && S.length >= 2) {
|
|
800
|
+
var La = S[S.length - 1], $e = S[S.length - 2];
|
|
801
|
+
ba = Math.atan2(La.y - $e.y, La.x - $e.x);
|
|
802
|
+
} else if (ir === "straight")
|
|
803
|
+
ba = Math.atan2(m - R, T - _);
|
|
804
|
+
else if (ir === "step" || ir === "smoothstep")
|
|
805
|
+
ba = 0;
|
|
806
|
+
else {
|
|
807
|
+
var Ve = re(_, R, T, m);
|
|
808
|
+
ba = Math.atan2(m - Ve.cp2y, T - Ve.cp2x);
|
|
809
|
+
}
|
|
810
|
+
var Ue = S && S.length >= 2 ? S[S.length - 1] : { x: T, y: m }, Nt = { x: Ue.x, y: Ue.y, angle: ba, size: Go };
|
|
811
|
+
fe ? _a.push(Nt) : ve ? $r.push(Nt) : ca.push(Nt);
|
|
812
|
+
}
|
|
813
|
+
if ($a && D.label) {
|
|
814
|
+
var Na;
|
|
815
|
+
S && S.length >= 2 ? Na = af(S) : ir === "straight" || ir === "step" || ir === "smoothstep" ? Na = { x: (_ + T) / 2, y: (R + m) / 2 } : Na = tf(_, R, T, m), lr.push({ text: D.label, x: Na.x, y: Na.y });
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (zr && (r.strokeStyle = z.edgeStroke, r.lineWidth = 1.5, r.setLineDash([]), r.stroke(zr)), vr && (r.strokeStyle = z.edgeAnimated, r.lineWidth = 1.5, r.setLineDash([5, 5]), r.lineDashOffset = -pt, r.stroke(vr), r.setLineDash([])), nr && (r.strokeStyle = z.edgeSelected, r.lineWidth = 2.5, r.setLineDash([]), r.stroke(nr)), ot(ca, z.edgeStroke), ot($r, z.edgeAnimated), ot(_a, z.edgeSelected), lr.length > 0) {
|
|
820
|
+
r.font = Ho, r.textAlign = "center", r.textBaseline = "middle";
|
|
821
|
+
for (var qt = 0; qt < lr.length; qt++) {
|
|
822
|
+
var da = lr[qt], Po = r.measureText(da.text), De = Po.width + 12;
|
|
823
|
+
r.fillStyle = G ? "#2a2a2a" : "#ffffff", r.fillRect(da.x - De / 2, da.y - 9, De, 18), r.fillStyle = z.nodeText, r.fillText(da.text, da.x, da.y);
|
|
824
|
+
}
|
|
825
|
+
r.textAlign = "start", r.textBaseline = "alphabetic";
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
if (Pa) {
|
|
829
|
+
r.beginPath(), r.strokeStyle = z.connectionLine, r.lineWidth = 2, r.setLineDash([6, 4]);
|
|
830
|
+
var St = Pa._routedPoints;
|
|
831
|
+
if (St && St.length >= 2) {
|
|
832
|
+
var Fe = new Path2D();
|
|
833
|
+
io(Fe, St), r.stroke(Fe);
|
|
834
|
+
} else {
|
|
835
|
+
var Ha = Pa.from, Ya = Pa.to, pa = re(Ha.x, Ha.y, Ya.x, Ya.y);
|
|
836
|
+
r.moveTo(Ha.x, Ha.y), r.bezierCurveTo(pa.cp1x, pa.cp1y, pa.cp2x, pa.cp2y, Ya.x, Ya.y), r.stroke();
|
|
837
|
+
}
|
|
838
|
+
r.setLineDash([]);
|
|
839
|
+
}
|
|
840
|
+
if (hr) {
|
|
841
|
+
var je = Math.min(hr.startWorld.x, hr.endWorld.x), Oe = Math.min(hr.startWorld.y, hr.endWorld.y), Aa = Math.abs(hr.endWorld.x - hr.startWorld.x), Ea = Math.abs(hr.endWorld.y - hr.startWorld.y);
|
|
842
|
+
r.fillStyle = G ? "rgba(59,130,246,0.08)" : "rgba(59,130,246,0.06)", r.fillRect(je, Oe, Aa, Ea), r.strokeStyle = "#3b82f6", r.lineWidth = 1 / g.zoom, r.setLineDash([]), r.strokeRect(je, Oe, Aa, Ea);
|
|
843
|
+
}
|
|
844
|
+
if (U > 0) {
|
|
845
|
+
var Io = g.zoom > 0.12 && (g.zoom > 0.25 || U < 500), Xe = g.zoom > 0.08 && U < 200, Zo = g.zoom > 0.2 && U < 300;
|
|
846
|
+
if (Xe) {
|
|
847
|
+
r.shadowColor = z.nodeShadow, r.shadowBlur = 6, r.shadowOffsetY = 2, r.fillStyle = z.nodeBg, r.beginPath();
|
|
848
|
+
for (var Gt = 0; Gt < U; Gt++) {
|
|
849
|
+
var rt = V[Gt];
|
|
850
|
+
r.roundRect(h(rt).x, h(rt).y, rt.width || E, rt.height || c, ft);
|
|
851
|
+
}
|
|
852
|
+
r.fill(), r.shadowColor = "transparent", r.shadowBlur = 0, r.shadowOffsetY = 0;
|
|
853
|
+
}
|
|
854
|
+
if (!Xe) {
|
|
855
|
+
r.fillStyle = z.nodeBg, r.beginPath();
|
|
856
|
+
for (var Pt = 0; Pt < U; Pt++) {
|
|
857
|
+
var at = V[Pt];
|
|
858
|
+
r.roundRect(h(at).x, h(at).y, at.width || E, at.height || c, ft);
|
|
859
|
+
}
|
|
860
|
+
r.fill();
|
|
861
|
+
}
|
|
862
|
+
r.strokeStyle = z.nodeBorder, r.lineWidth = 1, r.beginPath();
|
|
863
|
+
for (var It = 0; It < U; It++) {
|
|
864
|
+
var qa = V[It];
|
|
865
|
+
qa.selected || r.roundRect(h(qa).x, h(qa).y, qa.width || E, qa.height || c, ft);
|
|
866
|
+
}
|
|
867
|
+
r.stroke();
|
|
868
|
+
var He = !1;
|
|
869
|
+
r.strokeStyle = z.nodeSelectedBorder, r.lineWidth = 2, r.beginPath();
|
|
870
|
+
for (var Zt = 0; Zt < U; Zt++) {
|
|
871
|
+
var Sa = V[Zt];
|
|
872
|
+
Sa.selected && (He = !0, r.roundRect(h(Sa).x, h(Sa).y, Sa.width || E, Sa.height || c, ft));
|
|
873
|
+
}
|
|
874
|
+
if (He && r.stroke(), Io) {
|
|
875
|
+
r.fillStyle = z.nodeText, r.font = Xo, r.textAlign = "center", r.textBaseline = "middle";
|
|
876
|
+
for (var Jt = 0; Jt < U; Jt++) {
|
|
877
|
+
var Fr = V[Jt];
|
|
878
|
+
if (!(!Fr.data || !Fr.data.label)) {
|
|
879
|
+
var Ye = Fr.width || E, Jo = Fr.height || c;
|
|
880
|
+
r.fillText(Fr.data.label, h(Fr).x + Ye / 2, h(Fr).y + Jo / 2, Ye - 24);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
r.textAlign = "start", r.textBaseline = "alphabetic";
|
|
884
|
+
}
|
|
885
|
+
if (Zo) {
|
|
886
|
+
for (var Kt = [], Qt = 0; Qt < U; Qt++)
|
|
887
|
+
for (var pe = ho(V[Qt]), $t = 0; $t < pe.length; $t++)
|
|
888
|
+
Kt.push(pe[$t]);
|
|
889
|
+
r.fillStyle = z.handleFill, r.beginPath();
|
|
890
|
+
for (var Vt = 0; Vt < Kt.length; Vt++) {
|
|
891
|
+
var tt = Kt[Vt];
|
|
892
|
+
r.moveTo(tt.x + ao, tt.y), r.arc(tt.x, tt.y, ao, 0, 6.2832);
|
|
893
|
+
}
|
|
894
|
+
r.fill(), r.strokeStyle = z.handleBorder, r.lineWidth = 1.5, r.stroke();
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
r.restore();
|
|
898
|
+
var Ko = (performance.now() - a).toFixed(1);
|
|
899
|
+
jt++;
|
|
900
|
+
var et = performance.now();
|
|
901
|
+
if (et - oo >= 1e3 && (fo = jt, jt = 0, oo = et), et - vo >= 100) {
|
|
902
|
+
vo = et;
|
|
903
|
+
var Qo = Math.round(-g.x / g.zoom), $o = Math.round(-g.y / g.zoom);
|
|
904
|
+
self.postMessage({
|
|
905
|
+
type: "hud",
|
|
906
|
+
data: {
|
|
907
|
+
wx: Qo,
|
|
908
|
+
wy: $o,
|
|
909
|
+
zoom: g.zoom.toFixed(2),
|
|
910
|
+
renderMs: Ko,
|
|
911
|
+
fps: fo,
|
|
912
|
+
visible: O.length > 0 ? to(Gr, Pr, Hr, Ir).length : 0,
|
|
913
|
+
nodeCount: B.length,
|
|
914
|
+
visibleNodes: U,
|
|
915
|
+
edgeCount: P.length
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
`, Sn = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Gn], { type: "text/javascript;charset=utf-8" });
|
|
922
|
+
function Er(t) {
|
|
923
|
+
let e;
|
|
924
|
+
try {
|
|
925
|
+
if (e = Sn && (self.URL || self.webkitURL).createObjectURL(Sn), !e) throw "";
|
|
926
|
+
const n = new Worker(e, {
|
|
927
|
+
type: "module",
|
|
928
|
+
name: t == null ? void 0 : t.name
|
|
929
|
+
});
|
|
930
|
+
return n.addEventListener("error", () => {
|
|
931
|
+
(self.URL || self.webkitURL).revokeObjectURL(e);
|
|
932
|
+
}), n;
|
|
933
|
+
} catch {
|
|
934
|
+
return new Worker(
|
|
935
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(Gn),
|
|
936
|
+
{
|
|
937
|
+
type: "module",
|
|
938
|
+
name: t == null ? void 0 : t.name
|
|
939
|
+
}
|
|
940
|
+
);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const mn = /* @__PURE__ */ new WeakMap();
|
|
944
|
+
function Cr(t, e) {
|
|
945
|
+
if (mn.has(t))
|
|
946
|
+
return mn.get(t);
|
|
947
|
+
const n = t.transferControlToOffscreen(), r = new Er();
|
|
948
|
+
r.onerror = (o) => console.error("[infinite-canvas] worker error:", o.message, o), r.postMessage({ type: "init", data: { ...e, canvas: n } }, [n]);
|
|
949
|
+
const s = { worker: r };
|
|
950
|
+
return mn.set(t, s), s;
|
|
951
|
+
}
|
|
952
|
+
const Vt = 160, jt = 60, Nr = 10;
|
|
953
|
+
function Lr({
|
|
954
|
+
cards: t = [],
|
|
955
|
+
nodes: e = [],
|
|
956
|
+
edges: n = [],
|
|
957
|
+
onHudUpdate: r,
|
|
958
|
+
onNodesProcessed: s,
|
|
959
|
+
onNodesChange: o,
|
|
960
|
+
onEdgesChange: i,
|
|
961
|
+
onConnect: c,
|
|
962
|
+
onNodeClick: u,
|
|
963
|
+
onNodeDragStart: l,
|
|
964
|
+
onNodeDrag: g,
|
|
965
|
+
onNodeDragStop: v,
|
|
966
|
+
onEdgeClick: E,
|
|
967
|
+
onEdgeDoubleClick: R,
|
|
968
|
+
onEdgeMouseEnter: M,
|
|
969
|
+
onEdgeMouseMove: T,
|
|
970
|
+
onEdgeMouseLeave: k,
|
|
971
|
+
onEdgeContextMenu: z,
|
|
972
|
+
onNodeDoubleClick: W,
|
|
973
|
+
onNodeMouseEnter: D,
|
|
974
|
+
onNodeMouseMove: x,
|
|
975
|
+
onNodeMouseLeave: f,
|
|
976
|
+
onNodeContextMenu: p,
|
|
977
|
+
onPaneClick: y,
|
|
978
|
+
onPaneContextMenu: N,
|
|
979
|
+
onPaneMouseEnter: C,
|
|
980
|
+
onPaneMouseMove: P,
|
|
981
|
+
onPaneMouseLeave: b,
|
|
982
|
+
onSelectionChange: L,
|
|
983
|
+
onConnectStart: Y,
|
|
984
|
+
onConnectEnd: H,
|
|
985
|
+
onInit: dt,
|
|
986
|
+
onMoveStart: yt,
|
|
987
|
+
onMove: ft,
|
|
988
|
+
onMoveEnd: G,
|
|
989
|
+
onDelete: j,
|
|
990
|
+
onBeforeDelete: rt,
|
|
991
|
+
onError: at,
|
|
992
|
+
isValidConnection: ct,
|
|
993
|
+
dark: lt,
|
|
994
|
+
gridSize: Ct = 40,
|
|
995
|
+
zoomMin: et = 0.1,
|
|
996
|
+
zoomMax: ot = 4,
|
|
997
|
+
initialCamera: Nt = { x: 0, y: 0, zoom: 1 },
|
|
998
|
+
fitView: Rt = !1,
|
|
999
|
+
fitViewOptions: vt,
|
|
1000
|
+
nodesDraggable: Lt = !0,
|
|
1001
|
+
nodesConnectable: kt = !0,
|
|
1002
|
+
elementsSelectable: $t = !0,
|
|
1003
|
+
multiSelectionKeyCode: mt = "Shift",
|
|
1004
|
+
selectionOnDrag: ne = !1,
|
|
1005
|
+
selectionMode: Ie = "partial",
|
|
1006
|
+
connectionMode: Bt = "loose",
|
|
1007
|
+
connectionRadius: Qt = 20,
|
|
1008
|
+
connectOnClick: Yt = !1,
|
|
1009
|
+
snapToGrid: me = !1,
|
|
1010
|
+
snapGrid: de = [15, 15],
|
|
1011
|
+
deleteKeyCode: ve = ["Delete", "Backspace"],
|
|
1012
|
+
panActivationKeyCode: we = " ",
|
|
1013
|
+
panOnScroll: Ge = !1,
|
|
1014
|
+
panOnScrollMode: $e = "free",
|
|
1015
|
+
panOnScrollSpeed: Ze = 0.5,
|
|
1016
|
+
zoomOnScroll: Qe = !0,
|
|
1017
|
+
zoomOnDoubleClick: Ke = !0,
|
|
1018
|
+
zoomOnPinch: Oe = !0,
|
|
1019
|
+
preventScrolling: Pe = !0,
|
|
1020
|
+
translateExtent: re,
|
|
1021
|
+
nodeExtent: oe,
|
|
1022
|
+
defaultEdgeOptions: be = {},
|
|
1023
|
+
autoPanOnNodeDrag: dn = !0,
|
|
1024
|
+
autoPanOnConnect: fn = !0,
|
|
1025
|
+
autoPanSpeed: Kt = 5,
|
|
1026
|
+
edgesReconnectable: Nn = !1,
|
|
1027
|
+
elevateNodesOnSelect: hn = !1,
|
|
1028
|
+
edgeRouting: fe = !0
|
|
1029
|
+
} = {}) {
|
|
1030
|
+
const pt = V(null), Te = V(null), zt = V(null), gt = V({ ...Nt }), se = V([...t]), Z = V([...e]), Pt = V([...n]), yn = V(/* @__PURE__ */ new Map()), Se = V(!1), te = V(null), [gn, pn] = Gt(!1), _t = V(null), Wt = V(null), Me = V(null), ie = V(null), Ut = V(!1), Re = V(null), [Be, Je] = Gt({ x: Nt.x, y: Nt.y, zoom: Nt.zoom }), [Ve, ae] = Gt(null), Ot = St(() => /* @__PURE__ */ new Set(), []), he = St(() => /* @__PURE__ */ new Set(), []), ke = V(!1), Q = V({});
|
|
1031
|
+
Q.current = {
|
|
1032
|
+
onHudUpdate: r,
|
|
1033
|
+
onNodesProcessed: s,
|
|
1034
|
+
onNodesChange: o,
|
|
1035
|
+
onEdgesChange: i,
|
|
1036
|
+
onConnect: c,
|
|
1037
|
+
onNodeClick: u,
|
|
1038
|
+
onNodeDragStart: l,
|
|
1039
|
+
onNodeDrag: g,
|
|
1040
|
+
onNodeDragStop: v,
|
|
1041
|
+
onEdgeClick: E,
|
|
1042
|
+
onEdgeDoubleClick: R,
|
|
1043
|
+
onEdgeMouseEnter: M,
|
|
1044
|
+
onEdgeMouseMove: T,
|
|
1045
|
+
onEdgeMouseLeave: k,
|
|
1046
|
+
onEdgeContextMenu: z,
|
|
1047
|
+
onNodeDoubleClick: W,
|
|
1048
|
+
onNodeMouseEnter: D,
|
|
1049
|
+
onNodeMouseMove: x,
|
|
1050
|
+
onNodeMouseLeave: f,
|
|
1051
|
+
onNodeContextMenu: p,
|
|
1052
|
+
onPaneClick: y,
|
|
1053
|
+
onPaneContextMenu: N,
|
|
1054
|
+
onPaneMouseEnter: C,
|
|
1055
|
+
onPaneMouseMove: P,
|
|
1056
|
+
onPaneMouseLeave: b,
|
|
1057
|
+
onSelectionChange: L,
|
|
1058
|
+
onConnectStart: Y,
|
|
1059
|
+
onConnectEnd: H,
|
|
1060
|
+
onInit: dt,
|
|
1061
|
+
onMoveStart: yt,
|
|
1062
|
+
onMove: ft,
|
|
1063
|
+
onMoveEnd: G,
|
|
1064
|
+
onDelete: j,
|
|
1065
|
+
onBeforeDelete: rt,
|
|
1066
|
+
onError: at,
|
|
1067
|
+
isValidConnection: ct
|
|
1068
|
+
};
|
|
1069
|
+
const wt = { get current() {
|
|
1070
|
+
return Q.current.onNodesChange;
|
|
1071
|
+
} }, Dt = { get current() {
|
|
1072
|
+
return Q.current.onEdgesChange;
|
|
1073
|
+
} }, ce = { get current() {
|
|
1074
|
+
return Q.current.onConnect;
|
|
1075
|
+
} }, De = { get current() {
|
|
1076
|
+
return Q.current.onNodeClick;
|
|
1077
|
+
} }, He = { get current() {
|
|
1078
|
+
return Q.current.onNodeDragStart;
|
|
1079
|
+
} }, Ae = { get current() {
|
|
1080
|
+
return Q.current.onNodeDrag;
|
|
1081
|
+
} }, _e = { get current() {
|
|
1082
|
+
return Q.current.onNodeDragStop;
|
|
1083
|
+
} }, le = { get current() {
|
|
1084
|
+
return Q.current.onEdgeClick;
|
|
1085
|
+
} }, We = { get current() {
|
|
1086
|
+
return Q.current.onPaneClick;
|
|
1087
|
+
} }, ye = { get current() {
|
|
1088
|
+
return Q.current.onSelectionChange;
|
|
1089
|
+
} }, ge = { get current() {
|
|
1090
|
+
return Q.current.onHudUpdate;
|
|
1091
|
+
} }, pe = { get current() {
|
|
1092
|
+
return Q.current.onNodesProcessed;
|
|
1093
|
+
} };
|
|
1094
|
+
ut(() => {
|
|
1095
|
+
const a = (d) => {
|
|
1096
|
+
d.key === mt && (Ut.current = !0), d.key === we && (ke.current = !0);
|
|
1097
|
+
}, m = (d) => {
|
|
1098
|
+
d.key === mt && (Ut.current = !1), d.key === we && (ke.current = !1);
|
|
1099
|
+
};
|
|
1100
|
+
return window.addEventListener("keydown", a), window.addEventListener("keyup", m), () => {
|
|
1101
|
+
window.removeEventListener("keydown", a), window.removeEventListener("keyup", m);
|
|
1102
|
+
};
|
|
1103
|
+
}, [mt, we]);
|
|
1104
|
+
const Jt = F(() => {
|
|
1105
|
+
var w;
|
|
1106
|
+
const a = Z.current.filter((I) => I.selected), m = Pt.current.filter((I) => I.selected), d = { nodes: a, edges: m };
|
|
1107
|
+
(w = ye.current) == null || w.call(ye, d);
|
|
1108
|
+
for (const I of he) I(d);
|
|
1109
|
+
}, [he]);
|
|
1110
|
+
ut(() => {
|
|
1111
|
+
var a;
|
|
1112
|
+
se.current = [...t], (a = zt.current) == null || a.postMessage({ type: "cards", data: { cards: [...t] } });
|
|
1113
|
+
}, [t]);
|
|
1114
|
+
const ze = F((a) => {
|
|
1115
|
+
const m = {};
|
|
1116
|
+
for (const d of a) m[d.id] = d;
|
|
1117
|
+
return a.map((d) => {
|
|
1118
|
+
if (!d.parentId) return d;
|
|
1119
|
+
const w = m[d.parentId];
|
|
1120
|
+
if (!w) return d;
|
|
1121
|
+
let I = d.position.x, $ = d.position.y, h = w;
|
|
1122
|
+
for (; h; )
|
|
1123
|
+
I += h.position.x, $ += h.position.y, h = h.parentId ? m[h.parentId] : null;
|
|
1124
|
+
return { ...d, _absolutePosition: { x: I, y: $ } };
|
|
1125
|
+
});
|
|
1126
|
+
}, []), ee = V([]), K = F((a) => {
|
|
1127
|
+
const m = yn.current;
|
|
1128
|
+
if (!m || m.size === 0) return a;
|
|
1129
|
+
const d = {};
|
|
1130
|
+
for (const [, w] of m)
|
|
1131
|
+
d[w.nodeId] || (d[w.nodeId] = []), d[w.nodeId].push({ id: w.id, type: w.type, position: w.position, x: w.x, y: w.y });
|
|
1132
|
+
return a.map((w) => {
|
|
1133
|
+
const I = d[w.id];
|
|
1134
|
+
return I && I.length > 0 ? { ...w, handles: I } : w;
|
|
1135
|
+
});
|
|
1136
|
+
}, []), Ft = F(() => {
|
|
1137
|
+
var m;
|
|
1138
|
+
if (_t.current) return;
|
|
1139
|
+
const a = K(ee.current);
|
|
1140
|
+
(m = zt.current) == null || m.postMessage({ type: "nodes", data: { nodes: a } });
|
|
1141
|
+
}, [K]);
|
|
1142
|
+
ut(() => {
|
|
1143
|
+
var d;
|
|
1144
|
+
if (_t.current) {
|
|
1145
|
+
const w = _t.current.id, I = /* @__PURE__ */ new Set([w, ..._t.current.selectedStarts.map((h) => h.id)]), $ = {};
|
|
1146
|
+
for (const h of Z.current)
|
|
1147
|
+
I.has(h.id) && ($[h.id] = { ...h.position });
|
|
1148
|
+
Z.current = [...e];
|
|
1149
|
+
for (const h of Z.current)
|
|
1150
|
+
$[h.id] && (h.position = $[h.id]);
|
|
1151
|
+
ee.current = ze(Z.current);
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
Z.current = [...e];
|
|
1155
|
+
const a = ze(e);
|
|
1156
|
+
ee.current = a;
|
|
1157
|
+
const m = K(a);
|
|
1158
|
+
(d = zt.current) == null || d.postMessage({ type: "nodes", data: { nodes: m } });
|
|
1159
|
+
}, [e, ze, K]), ut(() => {
|
|
1160
|
+
var a;
|
|
1161
|
+
Pt.current = [...n], (a = zt.current) == null || a.postMessage({ type: "edges", data: { edges: [...n] } });
|
|
1162
|
+
}, [n]);
|
|
1163
|
+
const st = F((a, m) => {
|
|
1164
|
+
const d = pt.current;
|
|
1165
|
+
if (!d) return { x: 0, y: 0 };
|
|
1166
|
+
const w = d.getBoundingClientRect(), I = gt.current;
|
|
1167
|
+
return {
|
|
1168
|
+
x: (a - w.left - I.x) / I.zoom,
|
|
1169
|
+
y: (m - w.top - I.y) / I.zoom
|
|
1170
|
+
};
|
|
1171
|
+
}, []), Tt = F((a, m) => {
|
|
1172
|
+
const d = ee.current.length > 0 ? ee.current : Z.current;
|
|
1173
|
+
let w = null;
|
|
1174
|
+
for (let I = d.length - 1; I >= 0; I--) {
|
|
1175
|
+
const $ = d[I];
|
|
1176
|
+
if ($.hidden) continue;
|
|
1177
|
+
const h = $._absolutePosition || $.position, A = $.width || Vt, S = $.height || jt;
|
|
1178
|
+
if (a >= h.x && a <= h.x + A && m >= h.y && m <= h.y + S) {
|
|
1179
|
+
if ($.type === "group") {
|
|
1180
|
+
w || (w = $);
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
return $;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return w;
|
|
1187
|
+
}, []), xe = F((a, m) => {
|
|
1188
|
+
const d = m.width || Vt, w = m.height || jt;
|
|
1189
|
+
if (a.x !== void 0 && a.y !== void 0)
|
|
1190
|
+
return { x: m.position.x + a.x, y: m.position.y + a.y };
|
|
1191
|
+
switch (a.position || (a.type === "source" ? "right" : "left")) {
|
|
1192
|
+
case "top":
|
|
1193
|
+
return { x: m.position.x + d / 2, y: m.position.y };
|
|
1194
|
+
case "bottom":
|
|
1195
|
+
return { x: m.position.x + d / 2, y: m.position.y + w };
|
|
1196
|
+
case "left":
|
|
1197
|
+
return { x: m.position.x, y: m.position.y + w / 2 };
|
|
1198
|
+
case "right":
|
|
1199
|
+
return { x: m.position.x + d, y: m.position.y + w / 2 };
|
|
1200
|
+
default:
|
|
1201
|
+
return { x: m.position.x + d, y: m.position.y + w / 2 };
|
|
1202
|
+
}
|
|
1203
|
+
}, []), Ee = F((a) => {
|
|
1204
|
+
const m = a.width || Vt, d = a.height || jt;
|
|
1205
|
+
return a.handles && a.handles.length > 0 ? a.handles.map((w) => {
|
|
1206
|
+
const I = xe(w, a);
|
|
1207
|
+
return { id: w.id || null, type: w.type, x: I.x, y: I.y };
|
|
1208
|
+
}) : [
|
|
1209
|
+
{ id: null, type: "target", x: a.position.x, y: a.position.y + d / 2 },
|
|
1210
|
+
{ id: null, type: "source", x: a.position.x + m, y: a.position.y + d / 2 }
|
|
1211
|
+
];
|
|
1212
|
+
}, [xe]), tn = F((a, m) => {
|
|
1213
|
+
const d = Z.current, w = gt.current, I = Math.max(Nr, Qt) / w.zoom;
|
|
1214
|
+
for (let $ = d.length - 1; $ >= 0; $--) {
|
|
1215
|
+
const h = d[$];
|
|
1216
|
+
if (h.hidden) continue;
|
|
1217
|
+
const A = Ee(h);
|
|
1218
|
+
for (const S of A)
|
|
1219
|
+
if (Math.abs(a - S.x) < I && Math.abs(m - S.y) < I)
|
|
1220
|
+
return { nodeId: h.id, handleId: S.id, type: S.type, x: S.x, y: S.y };
|
|
1221
|
+
}
|
|
1222
|
+
return null;
|
|
1223
|
+
}, [Ee]), ue = F((a, m) => {
|
|
1224
|
+
const w = 8 / gt.current.zoom;
|
|
1225
|
+
for (let I = Pt.current.length - 1; I >= 0; I--) {
|
|
1226
|
+
const $ = Pt.current[I], h = Z.current.find((bt) => bt.id === $.source), A = Z.current.find((bt) => bt.id === $.target);
|
|
1227
|
+
if (!h || !A) continue;
|
|
1228
|
+
const S = h.width || Vt, U = h.height || jt, _ = A.height || jt, O = h.position.x + S, it = h.position.y + U / 2, q = A.position.x, nt = A.position.y + _ / 2;
|
|
1229
|
+
if (Ir(a, m, O, it, q, nt) < w) return $;
|
|
1230
|
+
}
|
|
1231
|
+
return null;
|
|
1232
|
+
}, []);
|
|
1233
|
+
ut(() => {
|
|
1234
|
+
const a = Te.current, m = pt.current;
|
|
1235
|
+
if (!a || !m) return;
|
|
1236
|
+
const d = m.getBoundingClientRect(), w = lt !== void 0 ? lt : matchMedia("(prefers-color-scheme: dark)").matches, I = ze(Z.current);
|
|
1237
|
+
ee.current = I;
|
|
1238
|
+
const $ = K(I), { worker: h } = Cr(a, {
|
|
1239
|
+
width: d.width,
|
|
1240
|
+
height: d.height,
|
|
1241
|
+
camera: gt.current,
|
|
1242
|
+
cards: se.current,
|
|
1243
|
+
nodes: $,
|
|
1244
|
+
edges: Pt.current,
|
|
1245
|
+
dark: w,
|
|
1246
|
+
gridSize: Ct,
|
|
1247
|
+
edgeRouting: fe
|
|
1248
|
+
});
|
|
1249
|
+
h.onmessage = (_) => {
|
|
1250
|
+
var O, it;
|
|
1251
|
+
_.data.type === "hud" && ((O = ge.current) == null || O.call(ge, _.data.data)), _.data.type === "ready" && pn(!0), _.data.type === "nodesProcessed" && ((it = pe.current) == null || it.call(pe, _.data.data));
|
|
1252
|
+
}, zt.current = h;
|
|
1253
|
+
const A = new ResizeObserver((_) => {
|
|
1254
|
+
const { width: O, height: it } = _[0].contentRect;
|
|
1255
|
+
h.postMessage({ type: "resize", data: { width: O, height: it } });
|
|
1256
|
+
});
|
|
1257
|
+
A.observe(m);
|
|
1258
|
+
let S, U;
|
|
1259
|
+
return lt === void 0 && (S = matchMedia("(prefers-color-scheme: dark)"), U = (_) => h.postMessage({ type: "theme", data: { dark: _.matches } }), S.addEventListener("change", U)), () => {
|
|
1260
|
+
A.disconnect(), S && U && S.removeEventListener("change", U), zt.current = null;
|
|
1261
|
+
};
|
|
1262
|
+
}, []), ut(() => {
|
|
1263
|
+
var a;
|
|
1264
|
+
lt !== void 0 && ((a = zt.current) == null || a.postMessage({ type: "theme", data: { dark: lt } }));
|
|
1265
|
+
}, [lt]), ut(() => {
|
|
1266
|
+
var a;
|
|
1267
|
+
(a = zt.current) == null || a.postMessage({ type: "edgeRouting", data: { enabled: fe } });
|
|
1268
|
+
}, [fe]);
|
|
1269
|
+
const Ln = V(0), Et = F((a = null) => {
|
|
1270
|
+
var w, I, $;
|
|
1271
|
+
const m = gt.current;
|
|
1272
|
+
if (re) {
|
|
1273
|
+
const h = pt.current;
|
|
1274
|
+
if (h) {
|
|
1275
|
+
const A = h.getBoundingClientRect(), S = -re[1][0] * m.zoom + A.width, U = -re[1][1] * m.zoom + A.height, _ = -re[0][0] * m.zoom, O = -re[0][1] * m.zoom;
|
|
1276
|
+
m.x = Math.min(_, Math.max(S, m.x)), m.y = Math.min(O, Math.max(U, m.y));
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
(w = zt.current) == null || w.postMessage({ type: "camera", data: { camera: { ...m } } });
|
|
1280
|
+
const d = { x: m.x, y: m.y, zoom: m.zoom };
|
|
1281
|
+
($ = (I = Q.current).onMove) == null || $.call(I, a, d);
|
|
1282
|
+
for (const h of Ot) h(d);
|
|
1283
|
+
cancelAnimationFrame(Ln.current), Ln.current = requestAnimationFrame(() => {
|
|
1284
|
+
Je({ x: m.x, y: m.y, zoom: m.zoom });
|
|
1285
|
+
});
|
|
1286
|
+
}, [Ot, re]), Ce = F(() => {
|
|
1287
|
+
var d, w;
|
|
1288
|
+
const a = Wt.current, m = Me.current;
|
|
1289
|
+
a && m ? ((d = zt.current) == null || d.postMessage({ type: "connecting", data: { from: a.startPos, to: m, _routedPoints: null } }), ae({ source: a.sourceId, sourceHandle: a.sourceHandle, target: null, targetHandle: null })) : ((w = zt.current) == null || w.postMessage({ type: "connecting", data: null }), ae(null));
|
|
1290
|
+
}, []), Ne = F(() => {
|
|
1291
|
+
var m, d;
|
|
1292
|
+
const a = ie.current;
|
|
1293
|
+
a ? (m = zt.current) == null || m.postMessage({ type: "selectionBox", data: a }) : (d = zt.current) == null || d.postMessage({ type: "selectionBox", data: null });
|
|
1294
|
+
}, []), dr = F((a) => {
|
|
1295
|
+
var I, $, h, A, S, U, _, O, it, q, nt, xt, bt, Ht, Xt, At;
|
|
1296
|
+
const m = Z.current.length > 0, d = st(a.clientX, a.clientY), w = Ut.current;
|
|
1297
|
+
if (m && kt) {
|
|
1298
|
+
const X = tn(d.x, d.y);
|
|
1299
|
+
if (Yt && Re.current && X) {
|
|
1300
|
+
const J = Re.current;
|
|
1301
|
+
if (X.nodeId !== J.nodeId) {
|
|
1302
|
+
const qt = J.handleType === "target" ? { source: X.nodeId, target: J.nodeId, sourceHandle: X.handleId || null, targetHandle: J.handleId } : { source: J.nodeId, target: X.nodeId, sourceHandle: J.handleId, targetHandle: X.handleId || null };
|
|
1303
|
+
(Q.current.isValidConnection ? Q.current.isValidConnection(qt) : !0) && ((I = ce.current) == null || I.call(ce, { ...qt, ...be }));
|
|
1304
|
+
}
|
|
1305
|
+
Re.current = null;
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
if (Bt === "strict" ? X && X.type === "source" : X != null) {
|
|
1309
|
+
if (Yt) {
|
|
1310
|
+
Re.current = { nodeId: X.nodeId, handleId: X.handleId || null, handleType: X.type }, (h = ($ = Q.current).onConnectStart) == null || h.call($, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type });
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
Wt.current = {
|
|
1314
|
+
sourceId: X.nodeId,
|
|
1315
|
+
sourceHandle: X.handleId || null,
|
|
1316
|
+
sourceType: X.type,
|
|
1317
|
+
startPos: { x: X.x, y: X.y }
|
|
1318
|
+
}, Me.current = { x: d.x, y: d.y }, (A = pt.current) == null || A.setPointerCapture(a.pointerId), (U = (S = Q.current).onConnectStart) == null || U.call(S, a, { nodeId: X.nodeId, handleId: X.handleId, handleType: X.type }), Ce();
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
if (m) {
|
|
1323
|
+
const X = Tt(d.x, d.y);
|
|
1324
|
+
if (X) {
|
|
1325
|
+
if (wt.current && $t) {
|
|
1326
|
+
const Mt = [];
|
|
1327
|
+
if (w)
|
|
1328
|
+
Mt.push({ id: X.id, type: "select", selected: !X.selected });
|
|
1329
|
+
else if (!X.selected) {
|
|
1330
|
+
for (const J of Z.current)
|
|
1331
|
+
J.id === X.id ? Mt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && Mt.push({ id: J.id, type: "select", selected: !1 });
|
|
1332
|
+
if (Dt.current) {
|
|
1333
|
+
const J = Pt.current.filter((tt) => tt.selected).map((tt) => ({ id: tt.id, type: "select", selected: !1 }));
|
|
1334
|
+
J.length && Dt.current(J);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
if (Mt.length) {
|
|
1338
|
+
if (wt.current(Mt), hn && !w) {
|
|
1339
|
+
const J = Z.current.findIndex((tt) => tt.id === X.id);
|
|
1340
|
+
J >= 0 && J < Z.current.length - 1 && wt.current([
|
|
1341
|
+
{ id: X.id, type: "remove" },
|
|
1342
|
+
{ type: "add", item: { ...Z.current[J], selected: !0 } }
|
|
1343
|
+
]);
|
|
1344
|
+
}
|
|
1345
|
+
Jt();
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if ((_ = De.current) == null || _.call(De, a, X), Lt) {
|
|
1349
|
+
const Mt = w && X.selected;
|
|
1350
|
+
let J = null;
|
|
1351
|
+
if (X.parentId && X.extent === "parent") {
|
|
1352
|
+
const tt = Z.current.find((qt) => qt.id === X.parentId);
|
|
1353
|
+
if (tt) {
|
|
1354
|
+
const qt = tt.width || Vt, Xe = tt.height || jt, en = X.width || ((O = X.measured) == null ? void 0 : O.width) || Vt, Fe = X.height || ((it = X.measured) == null ? void 0 : it.height) || jt;
|
|
1355
|
+
J = { minX: 0, minY: 0, maxX: qt - en, maxY: Xe - Fe };
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
if (_t.current = {
|
|
1359
|
+
id: X.id,
|
|
1360
|
+
startPos: { ...X.position },
|
|
1361
|
+
startMouse: { x: d.x, y: d.y },
|
|
1362
|
+
parentClamp: J,
|
|
1363
|
+
parentId: X.parentId || null,
|
|
1364
|
+
selectedStarts: Mt ? Z.current.filter((tt) => tt.selected && tt.id !== X.id).map((tt) => {
|
|
1365
|
+
var Xe, en;
|
|
1366
|
+
let qt = null;
|
|
1367
|
+
if (tt.parentId && tt.extent === "parent") {
|
|
1368
|
+
const Fe = Z.current.find((xn) => xn.id === tt.parentId);
|
|
1369
|
+
if (Fe) {
|
|
1370
|
+
const xn = Fe.width || Vt, br = Fe.height || jt, Mr = tt.width || ((Xe = tt.measured) == null ? void 0 : Xe.width) || Vt, Rr = tt.height || ((en = tt.measured) == null ? void 0 : en.height) || jt;
|
|
1371
|
+
qt = { minX: 0, minY: 0, maxX: xn - Mr, maxY: br - Rr };
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return { id: tt.id, startPos: { ...tt.position }, parentClamp: qt, parentId: tt.parentId || null };
|
|
1375
|
+
}) : []
|
|
1376
|
+
}, (q = pt.current) == null || q.setPointerCapture(a.pointerId), (nt = He.current) == null || nt.call(He, a, X), wt.current) {
|
|
1377
|
+
const tt = [{ id: X.id, type: "position", dragging: !0 }];
|
|
1378
|
+
for (const qt of _t.current.selectedStarts)
|
|
1379
|
+
tt.push({ id: qt.id, type: "position", dragging: !0 });
|
|
1380
|
+
wt.current(tt);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
if (Pt.current.length > 0 && $t) {
|
|
1387
|
+
const X = ue(d.x, d.y);
|
|
1388
|
+
if (X) {
|
|
1389
|
+
if (Dt.current) {
|
|
1390
|
+
const Mt = [];
|
|
1391
|
+
if (w)
|
|
1392
|
+
Mt.push({ id: X.id, type: "select", selected: !X.selected });
|
|
1393
|
+
else {
|
|
1394
|
+
for (const J of Pt.current)
|
|
1395
|
+
J.id === X.id ? Mt.push({ id: J.id, type: "select", selected: !0 }) : J.selected && Mt.push({ id: J.id, type: "select", selected: !1 });
|
|
1396
|
+
if (wt.current) {
|
|
1397
|
+
const J = Z.current.filter((tt) => tt.selected).map((tt) => ({ id: tt.id, type: "select", selected: !1 }));
|
|
1398
|
+
J.length && wt.current(J);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
Mt.length && (Dt.current(Mt), Jt());
|
|
1402
|
+
}
|
|
1403
|
+
(xt = le.current) == null || xt.call(le, a, X);
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
if (!w) {
|
|
1408
|
+
const X = Z.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 })), Mt = Pt.current.filter((J) => J.selected).map((J) => ({ id: J.id, type: "select", selected: !1 }));
|
|
1409
|
+
X.length && wt.current && wt.current(X), Mt.length && Dt.current && Dt.current(Mt), (X.length || Mt.length) && Jt();
|
|
1410
|
+
}
|
|
1411
|
+
if ((bt = We.current) == null || bt.call(We, a), ne || w) {
|
|
1412
|
+
ie.current = { startWorld: { ...d }, endWorld: { ...d } }, (Ht = pt.current) == null || Ht.setPointerCapture(a.pointerId), Ne();
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
Se.current = !0, te.current = { x: a.clientX, y: a.clientY }, (Xt = pt.current) == null || Xt.classList.add("dragging"), (At = pt.current) == null || At.setPointerCapture(a.pointerId);
|
|
1416
|
+
}, [st, Tt, tn, ue, Lt, kt, $t, ne, Ce, Ne, Jt]), fr = F((a) => {
|
|
1417
|
+
var d, w;
|
|
1418
|
+
if (Wt.current) {
|
|
1419
|
+
if (Me.current = st(a.clientX, a.clientY), Ce(), fn) {
|
|
1420
|
+
const I = pt.current;
|
|
1421
|
+
if (I) {
|
|
1422
|
+
const $ = I.getBoundingClientRect(), h = 40, A = a.clientX - $.left, S = a.clientY - $.top;
|
|
1423
|
+
let U = 0, _ = 0;
|
|
1424
|
+
A < h ? U = Kt : A > $.width - h && (U = -Kt), S < h ? _ = Kt : S > $.height - h && (_ = -Kt), (U || _) && (gt.current.x += U, gt.current.y += _, Et(a));
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
if (ie.current) {
|
|
1430
|
+
ie.current.endWorld = st(a.clientX, a.clientY), Ne();
|
|
1431
|
+
const I = ie.current, $ = Math.min(I.startWorld.x, I.endWorld.x), h = Math.min(I.startWorld.y, I.endWorld.y), A = Math.max(I.startWorld.x, I.endWorld.x), S = Math.max(I.startWorld.y, I.endWorld.y);
|
|
1432
|
+
if (wt.current) {
|
|
1433
|
+
const U = [];
|
|
1434
|
+
for (const _ of Z.current) {
|
|
1435
|
+
if (_.hidden) continue;
|
|
1436
|
+
const O = _.width || Vt, it = _.height || jt, q = Ie === "full" ? _.position.x >= $ && _.position.x + O <= A && _.position.y >= h && _.position.y + it <= S : _.position.x + O > $ && _.position.x < A && _.position.y + it > h && _.position.y < S;
|
|
1437
|
+
q !== !!_.selected && U.push({ id: _.id, type: "select", selected: q });
|
|
1438
|
+
}
|
|
1439
|
+
U.length && wt.current(U);
|
|
1440
|
+
}
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
if (_t.current) {
|
|
1444
|
+
const I = st(a.clientX, a.clientY), $ = _t.current, h = I.x - $.startMouse.x, A = I.y - $.startMouse.y;
|
|
1445
|
+
let S = { x: $.startPos.x + h, y: $.startPos.y + A };
|
|
1446
|
+
if (me && (S = Pn(S, de)), oe && (S = Tn(S, oe)), $.parentClamp) {
|
|
1447
|
+
const q = $.parentClamp;
|
|
1448
|
+
S = { x: Math.max(q.minX, Math.min(S.x, q.maxX)), y: Math.max(q.minY, Math.min(S.y, q.maxY)) };
|
|
1449
|
+
}
|
|
1450
|
+
const U = [{ id: $.id, position: S }];
|
|
1451
|
+
for (const q of $.selectedStarts) {
|
|
1452
|
+
let nt = { x: q.startPos.x + h, y: q.startPos.y + A };
|
|
1453
|
+
if (me && (nt = Pn(nt, de)), oe && (nt = Tn(nt, oe)), q.parentClamp) {
|
|
1454
|
+
const xt = q.parentClamp;
|
|
1455
|
+
nt = { x: Math.max(xt.minX, Math.min(nt.x, xt.maxX)), y: Math.max(xt.minY, Math.min(nt.y, xt.maxY)) };
|
|
1456
|
+
}
|
|
1457
|
+
U.push({ id: q.id, position: nt });
|
|
1458
|
+
}
|
|
1459
|
+
const _ = [];
|
|
1460
|
+
for (const q of U) {
|
|
1461
|
+
const nt = Z.current.find((xt) => xt.id === q.id);
|
|
1462
|
+
if (nt) {
|
|
1463
|
+
nt.position = q.position, nt.dragging = !0;
|
|
1464
|
+
let xt = q.position;
|
|
1465
|
+
if (nt.parentId) {
|
|
1466
|
+
let bt = Z.current.find((At) => At.id === nt.parentId), Ht = q.position.x, Xt = q.position.y;
|
|
1467
|
+
for (; bt; )
|
|
1468
|
+
Ht += bt.position.x, Xt += bt.position.y, bt = bt.parentId ? Z.current.find((At) => At.id === bt.parentId) : null;
|
|
1469
|
+
xt = { x: Ht, y: Xt };
|
|
1470
|
+
}
|
|
1471
|
+
_.push({
|
|
1472
|
+
id: q.id,
|
|
1473
|
+
position: q.position,
|
|
1474
|
+
_absolutePosition: xt,
|
|
1475
|
+
width: nt.width,
|
|
1476
|
+
height: nt.height,
|
|
1477
|
+
dragging: !0,
|
|
1478
|
+
selected: nt.selected
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
const O = new Set(U.map((q) => q.id));
|
|
1483
|
+
for (const q of Z.current)
|
|
1484
|
+
if (q.parentId && O.has(q.parentId) && !O.has(q.id)) {
|
|
1485
|
+
let nt = Z.current.find((Ht) => Ht.id === q.parentId), xt = q.position.x, bt = q.position.y;
|
|
1486
|
+
for (; nt; )
|
|
1487
|
+
xt += nt.position.x, bt += nt.position.y, nt = nt.parentId ? Z.current.find((Ht) => Ht.id === nt.parentId) : null;
|
|
1488
|
+
_.push({
|
|
1489
|
+
id: q.id,
|
|
1490
|
+
position: q.position,
|
|
1491
|
+
_absolutePosition: { x: xt, y: bt },
|
|
1492
|
+
width: q.width,
|
|
1493
|
+
height: q.height,
|
|
1494
|
+
dragging: !1,
|
|
1495
|
+
selected: q.selected
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
if ((d = zt.current) == null || d.postMessage({ type: "nodePositions", data: { updates: _ } }), dn) {
|
|
1499
|
+
const q = pt.current;
|
|
1500
|
+
if (q) {
|
|
1501
|
+
const nt = q.getBoundingClientRect(), xt = 40, bt = a.clientX - nt.left, Ht = a.clientY - nt.top;
|
|
1502
|
+
let Xt = 0, At = 0;
|
|
1503
|
+
bt < xt ? Xt = Kt : bt > nt.width - xt && (Xt = -Kt), Ht < xt ? At = Kt : Ht > nt.height - xt && (At = -Kt), (Xt || At) && (gt.current.x += Xt, gt.current.y += At, Et(a));
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
const it = Z.current.find((q) => q.id === $.id);
|
|
1507
|
+
it && ((w = Ae.current) == null || w.call(Ae, a, it));
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
if (!Se.current) return;
|
|
1511
|
+
const m = gt.current;
|
|
1512
|
+
m.x += a.clientX - te.current.x, m.y += a.clientY - te.current.y, te.current = { x: a.clientX, y: a.clientY }, Et();
|
|
1513
|
+
}, [Et, st, Ce, Ne]), hr = F((a) => {
|
|
1514
|
+
var m, d, w, I, $;
|
|
1515
|
+
if (Wt.current) {
|
|
1516
|
+
const h = st(a.clientX, a.clientY), A = tn(h.x, h.y);
|
|
1517
|
+
if (A && A.nodeId !== Wt.current.sourceId && (Bt === "loose" || A.type === "target")) {
|
|
1518
|
+
const _ = Wt.current.sourceType === "target" ? {
|
|
1519
|
+
source: A.nodeId,
|
|
1520
|
+
target: Wt.current.sourceId,
|
|
1521
|
+
sourceHandle: A.handleId || null,
|
|
1522
|
+
targetHandle: Wt.current.sourceHandle
|
|
1523
|
+
} : {
|
|
1524
|
+
source: Wt.current.sourceId,
|
|
1525
|
+
target: A.nodeId,
|
|
1526
|
+
sourceHandle: Wt.current.sourceHandle,
|
|
1527
|
+
targetHandle: A.handleId || null
|
|
1528
|
+
};
|
|
1529
|
+
(Q.current.isValidConnection ? Q.current.isValidConnection(_) : !0) && ((m = ce.current) == null || m.call(ce, { ..._, ...be }));
|
|
1530
|
+
}
|
|
1531
|
+
(w = (d = Q.current).onConnectEnd) == null || w.call(d, a.nativeEvent || a), Wt.current = null, Me.current = null, Ce();
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
if (ie.current) {
|
|
1535
|
+
ie.current = null, Ne(), Jt();
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
if (_t.current) {
|
|
1539
|
+
const h = _t.current;
|
|
1540
|
+
if (wt.current) {
|
|
1541
|
+
const S = Z.current.find((_) => _.id === h.id), U = [{
|
|
1542
|
+
id: h.id,
|
|
1543
|
+
type: "position",
|
|
1544
|
+
position: S ? { ...S.position } : void 0,
|
|
1545
|
+
dragging: !1
|
|
1546
|
+
}];
|
|
1547
|
+
for (const _ of h.selectedStarts) {
|
|
1548
|
+
const O = Z.current.find((it) => it.id === _.id);
|
|
1549
|
+
U.push({
|
|
1550
|
+
id: _.id,
|
|
1551
|
+
type: "position",
|
|
1552
|
+
position: O ? { ...O.position } : void 0,
|
|
1553
|
+
dragging: !1
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
wt.current(U);
|
|
1557
|
+
}
|
|
1558
|
+
requestAnimationFrame(() => {
|
|
1559
|
+
_t.current = null;
|
|
1560
|
+
});
|
|
1561
|
+
const A = Z.current.find((S) => S.id === h.id);
|
|
1562
|
+
A && ((I = _e.current) == null || I.call(_e, a, A));
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
Se.current = !1, ($ = pt.current) == null || $.classList.remove("dragging");
|
|
1566
|
+
}, [st, tn, Ce, Ne, Jt]);
|
|
1567
|
+
ut(() => {
|
|
1568
|
+
const a = pt.current;
|
|
1569
|
+
if (!a) return;
|
|
1570
|
+
const m = (d) => {
|
|
1571
|
+
Pe && d.preventDefault();
|
|
1572
|
+
const w = gt.current;
|
|
1573
|
+
if (Ge || ke.current) {
|
|
1574
|
+
const S = Ze;
|
|
1575
|
+
$e === "horizontal" ? w.x -= d.deltaY * S : ($e === "vertical" || (w.x -= d.deltaX * S), w.y -= d.deltaY * S), Et(d);
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1578
|
+
if (!Qe) return;
|
|
1579
|
+
const I = d.deltaY > 0 ? 0.92 : 1.08, $ = a.getBoundingClientRect(), h = d.clientX - $.left, A = d.clientY - $.top;
|
|
1580
|
+
w.x = h - (h - w.x) * I, w.y = A - (A - w.y) * I, w.zoom = Math.min(ot, Math.max(et, w.zoom * I)), Et(d);
|
|
1581
|
+
};
|
|
1582
|
+
return a.addEventListener("wheel", m, { passive: !Pe }), () => a.removeEventListener("wheel", m);
|
|
1583
|
+
}, [Et, et, ot, Ge, $e, Ze, Qe, Pe]), ut(() => {
|
|
1584
|
+
if (!Oe) return;
|
|
1585
|
+
const a = pt.current;
|
|
1586
|
+
if (!a) return;
|
|
1587
|
+
let m = 0, d = null;
|
|
1588
|
+
const w = (h) => {
|
|
1589
|
+
if (h.touches.length === 2) {
|
|
1590
|
+
const A = h.touches[0].clientX - h.touches[1].clientX, S = h.touches[0].clientY - h.touches[1].clientY;
|
|
1591
|
+
m = Math.hypot(A, S);
|
|
1592
|
+
const U = a.getBoundingClientRect();
|
|
1593
|
+
d = {
|
|
1594
|
+
x: (h.touches[0].clientX + h.touches[1].clientX) / 2 - U.left,
|
|
1595
|
+
y: (h.touches[0].clientY + h.touches[1].clientY) / 2 - U.top
|
|
1596
|
+
}, h.preventDefault();
|
|
1597
|
+
}
|
|
1598
|
+
}, I = (h) => {
|
|
1599
|
+
if (h.touches.length === 2 && m > 0) {
|
|
1600
|
+
h.preventDefault();
|
|
1601
|
+
const A = h.touches[0].clientX - h.touches[1].clientX, S = h.touches[0].clientY - h.touches[1].clientY, U = Math.hypot(A, S), _ = U / m;
|
|
1602
|
+
m = U;
|
|
1603
|
+
const O = gt.current, it = d.x, q = d.y;
|
|
1604
|
+
O.x = it - (it - O.x) * _, O.y = q - (q - O.y) * _, O.zoom = Math.min(ot, Math.max(et, O.zoom * _)), Et(h);
|
|
1605
|
+
}
|
|
1606
|
+
}, $ = () => {
|
|
1607
|
+
m = 0, d = null;
|
|
1608
|
+
};
|
|
1609
|
+
return a.addEventListener("touchstart", w, { passive: !1 }), a.addEventListener("touchmove", I, { passive: !1 }), a.addEventListener("touchend", $), () => {
|
|
1610
|
+
a.removeEventListener("touchstart", w), a.removeEventListener("touchmove", I), a.removeEventListener("touchend", $);
|
|
1611
|
+
};
|
|
1612
|
+
}, [Oe, Et, et, ot]), ut(() => {
|
|
1613
|
+
if (!Ke) return;
|
|
1614
|
+
const a = pt.current;
|
|
1615
|
+
if (!a) return;
|
|
1616
|
+
const m = (d) => {
|
|
1617
|
+
var _, O, it, q;
|
|
1618
|
+
const w = st(d.clientX, d.clientY);
|
|
1619
|
+
if (Tt(w.x, w.y)) {
|
|
1620
|
+
(O = (_ = Q.current).onNodeDoubleClick) == null || O.call(_, d, Tt(w.x, w.y));
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const I = ue(w.x, w.y);
|
|
1624
|
+
if (I) {
|
|
1625
|
+
(q = (it = Q.current).onEdgeDoubleClick) == null || q.call(it, d, I);
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
const $ = 1.5, h = a.getBoundingClientRect(), A = d.clientX - h.left, S = d.clientY - h.top, U = gt.current;
|
|
1629
|
+
U.x = A - (A - U.x) * $, U.y = S - (S - U.y) * $, U.zoom = Math.min(ot, Math.max(et, U.zoom * $)), Et(d);
|
|
1630
|
+
};
|
|
1631
|
+
return a.addEventListener("dblclick", m), () => a.removeEventListener("dblclick", m);
|
|
1632
|
+
}, [Ke, Et, et, ot, st, Tt, ue]), ut(() => {
|
|
1633
|
+
const a = pt.current;
|
|
1634
|
+
if (!a) return;
|
|
1635
|
+
const m = (d) => {
|
|
1636
|
+
var h, A, S, U, _, O;
|
|
1637
|
+
const w = st(d.clientX, d.clientY), I = Tt(w.x, w.y);
|
|
1638
|
+
if (I) {
|
|
1639
|
+
(A = (h = Q.current).onNodeContextMenu) == null || A.call(h, d, I);
|
|
1640
|
+
return;
|
|
1641
|
+
}
|
|
1642
|
+
const $ = ue(w.x, w.y);
|
|
1643
|
+
if ($) {
|
|
1644
|
+
(U = (S = Q.current).onEdgeContextMenu) == null || U.call(S, d, $);
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
(O = (_ = Q.current).onPaneContextMenu) == null || O.call(_, d);
|
|
1648
|
+
};
|
|
1649
|
+
return a.addEventListener("contextmenu", m), () => a.removeEventListener("contextmenu", m);
|
|
1650
|
+
}, [st, Tt, ue]), ut(() => {
|
|
1651
|
+
const a = pt.current;
|
|
1652
|
+
if (!a) return;
|
|
1653
|
+
let m = null, d = null;
|
|
1654
|
+
const w = (h) => {
|
|
1655
|
+
var U, _, O, it, q, nt, xt, bt, Ht, Xt, At, X, Mt, J;
|
|
1656
|
+
(_ = (U = Q.current).onPaneMouseMove) == null || _.call(U, h);
|
|
1657
|
+
const A = st(h.clientX, h.clientY), S = Tt(A.x, A.y);
|
|
1658
|
+
if (S !== m && (m && ((it = (O = Q.current).onNodeMouseLeave) == null || it.call(O, h, m)), S && ((nt = (q = Q.current).onNodeMouseEnter) == null || nt.call(q, h, S)), m = S), S && ((bt = (xt = Q.current).onNodeMouseMove) == null || bt.call(xt, h, S)), !S) {
|
|
1659
|
+
const tt = ue(A.x, A.y);
|
|
1660
|
+
tt !== d && (d && ((Xt = (Ht = Q.current).onEdgeMouseLeave) == null || Xt.call(Ht, h, d)), tt && ((X = (At = Q.current).onEdgeMouseEnter) == null || X.call(At, h, tt)), d = tt), tt && ((J = (Mt = Q.current).onEdgeMouseMove) == null || J.call(Mt, h, tt));
|
|
1661
|
+
}
|
|
1662
|
+
}, I = (h) => {
|
|
1663
|
+
var A, S;
|
|
1664
|
+
return (S = (A = Q.current).onPaneMouseEnter) == null ? void 0 : S.call(A, h);
|
|
1665
|
+
}, $ = (h) => {
|
|
1666
|
+
var A, S, U, _, O, it;
|
|
1667
|
+
(S = (A = Q.current).onPaneMouseLeave) == null || S.call(A, h), m && ((_ = (U = Q.current).onNodeMouseLeave) == null || _.call(U, h, m), m = null), d && ((it = (O = Q.current).onEdgeMouseLeave) == null || it.call(O, h, d), d = null);
|
|
1668
|
+
};
|
|
1669
|
+
return a.addEventListener("mousemove", w), a.addEventListener("mouseenter", I), a.addEventListener("mouseleave", $), () => {
|
|
1670
|
+
a.removeEventListener("mousemove", w), a.removeEventListener("mouseenter", I), a.removeEventListener("mouseleave", $);
|
|
1671
|
+
};
|
|
1672
|
+
}, [st, Tt, ue]), ut(() => {
|
|
1673
|
+
const a = Array.isArray(ve) ? ve : [ve], m = async (d) => {
|
|
1674
|
+
var w, I;
|
|
1675
|
+
if (a.includes(d.key)) {
|
|
1676
|
+
if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA" || d.target.isContentEditable) return;
|
|
1677
|
+
const $ = Z.current.filter((S) => S.selected), h = Pt.current.filter((S) => S.selected);
|
|
1678
|
+
if (!$.length && !h.length || Q.current.onBeforeDelete && !await Q.current.onBeforeDelete({ nodes: $, edges: h }))
|
|
1679
|
+
return;
|
|
1680
|
+
const A = new Set($.map((S) => S.id));
|
|
1681
|
+
if ($.length && wt.current && (wt.current($.map((S) => ({ id: S.id, type: "remove" }))), Dt.current)) {
|
|
1682
|
+
const S = Pt.current.filter((U) => A.has(U.source) || A.has(U.target));
|
|
1683
|
+
S.length && Dt.current(S.map((U) => ({ id: U.id, type: "remove" })));
|
|
1684
|
+
}
|
|
1685
|
+
h.length && Dt.current && Dt.current(h.map((S) => ({ id: S.id, type: "remove" }))), (I = (w = Q.current).onDelete) == null || I.call(w, { nodes: $, edges: h });
|
|
1686
|
+
}
|
|
1687
|
+
if ((d.ctrlKey || d.metaKey) && d.key === "a") {
|
|
1688
|
+
if (d.target.tagName === "INPUT" || d.target.tagName === "TEXTAREA") return;
|
|
1689
|
+
if (d.preventDefault(), wt.current) {
|
|
1690
|
+
const $ = Z.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
1691
|
+
$.length && wt.current($);
|
|
1692
|
+
}
|
|
1693
|
+
if (Dt.current) {
|
|
1694
|
+
const $ = Pt.current.filter((h) => !h.selected).map((h) => ({ id: h.id, type: "select", selected: !0 }));
|
|
1695
|
+
$.length && Dt.current($);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
return window.addEventListener("keydown", m), () => window.removeEventListener("keydown", m);
|
|
1700
|
+
}, [ve]);
|
|
1701
|
+
const In = V(!1);
|
|
1702
|
+
ut(() => {
|
|
1703
|
+
var a, m;
|
|
1704
|
+
if (!In.current && zt.current) {
|
|
1705
|
+
if (In.current = !0, Rt && Z.current.length > 0) {
|
|
1706
|
+
const d = pt.current;
|
|
1707
|
+
if (d) {
|
|
1708
|
+
const w = d.getBoundingClientRect(), I = (vt == null ? void 0 : vt.padding) ?? 0.1, $ = Mn(Z.current), h = Rn($, w.width, w.height, I);
|
|
1709
|
+
vt != null && vt.maxZoom && (h.zoom = Math.min(h.zoom, vt.maxZoom)), vt != null && vt.minZoom && (h.zoom = Math.max(h.zoom, vt.minZoom)), gt.current = h, Et();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
(m = (a = Q.current).onInit) == null || m.call(a, {
|
|
1713
|
+
getNodes: () => [...Z.current],
|
|
1714
|
+
getEdges: () => [...Pt.current],
|
|
1715
|
+
getViewport: () => ({ ...gt.current }),
|
|
1716
|
+
fitView: (d = {}) => {
|
|
1717
|
+
const w = pt.current;
|
|
1718
|
+
if (!w || !Z.current.length) return;
|
|
1719
|
+
const I = w.getBoundingClientRect(), $ = Mn(Z.current), h = Rn($, I.width, I.height, d.padding ?? 0.1);
|
|
1720
|
+
gt.current = h, Et();
|
|
1721
|
+
}
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
const yr = F(() => {
|
|
1726
|
+
gt.current = { ...Nt }, Et();
|
|
1727
|
+
}, [Et, Nt]), gr = F((a) => {
|
|
1728
|
+
var m;
|
|
1729
|
+
if (a)
|
|
1730
|
+
se.current.push(a);
|
|
1731
|
+
else {
|
|
1732
|
+
const d = gt.current, w = pt.current;
|
|
1733
|
+
if (!w) return;
|
|
1734
|
+
const I = w.getBoundingClientRect(), $ = Math.round(-d.x / d.zoom + I.width / 2 / d.zoom), h = Math.round(-d.y / d.zoom + I.height / 2 / d.zoom);
|
|
1735
|
+
se.current.push({
|
|
1736
|
+
x: $ - 80,
|
|
1737
|
+
y: h - 45,
|
|
1738
|
+
w: 160,
|
|
1739
|
+
h: 90,
|
|
1740
|
+
title: "Note " + (se.current.length + 1),
|
|
1741
|
+
body: "Added at viewport center"
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
(m = zt.current) == null || m.postMessage({ type: "cards", data: { cards: [...se.current] } });
|
|
1745
|
+
}, []), pr = F((a) => {
|
|
1746
|
+
if (a.id || (a.id = "node-" + Date.now()), !a.position) {
|
|
1747
|
+
const m = gt.current, d = pt.current;
|
|
1748
|
+
if (!d) return;
|
|
1749
|
+
const w = d.getBoundingClientRect();
|
|
1750
|
+
a.position = {
|
|
1751
|
+
x: Math.round(-m.x / m.zoom + w.width / 2 / m.zoom) - Vt / 2,
|
|
1752
|
+
y: Math.round(-m.y / m.zoom + w.height / 2 / m.zoom) - jt / 2
|
|
1753
|
+
};
|
|
1754
|
+
}
|
|
1755
|
+
a.data || (a.data = { label: a.id }), wt.current && wt.current([{ type: "add", item: a }]);
|
|
1756
|
+
}, []), xr = F(() => ({ ...gt.current }), []), mr = F((a) => {
|
|
1757
|
+
gt.current = { ...gt.current, ...a }, Et();
|
|
1758
|
+
}, [Et]), vr = F((a) => st(a.x, a.y), [st]), $n = n, wr = St(() => ({
|
|
1759
|
+
wrapRef: pt,
|
|
1760
|
+
canvasRef: Te,
|
|
1761
|
+
workerRef: zt,
|
|
1762
|
+
cameraRef: gt,
|
|
1763
|
+
nodesRef: Z,
|
|
1764
|
+
edgesRef: Pt,
|
|
1765
|
+
handleRegistryRef: yn,
|
|
1766
|
+
syncNodesToWorker: Ft,
|
|
1767
|
+
onNodesChangeRef: wt,
|
|
1768
|
+
onEdgesChangeRef: Dt,
|
|
1769
|
+
sendCamera: Et,
|
|
1770
|
+
screenToWorld: st,
|
|
1771
|
+
viewportListeners: Ot,
|
|
1772
|
+
selectionListeners: he,
|
|
1773
|
+
zoomMin: et,
|
|
1774
|
+
zoomMax: ot,
|
|
1775
|
+
snapToGrid: me,
|
|
1776
|
+
snapGrid: de,
|
|
1777
|
+
nodeExtent: oe,
|
|
1778
|
+
defaultEdgeOptions: be,
|
|
1779
|
+
edgeRouting: fe,
|
|
1780
|
+
resolvedNodesRef: ee,
|
|
1781
|
+
get nodes() {
|
|
1782
|
+
return e;
|
|
1783
|
+
},
|
|
1784
|
+
get edges() {
|
|
1785
|
+
return n;
|
|
1786
|
+
},
|
|
1787
|
+
get routedEdges() {
|
|
1788
|
+
return $n;
|
|
1789
|
+
},
|
|
1790
|
+
get viewport() {
|
|
1791
|
+
return Be;
|
|
1792
|
+
},
|
|
1793
|
+
get connection() {
|
|
1794
|
+
return Ve;
|
|
1795
|
+
}
|
|
1796
|
+
}), [e, n, $n, Be, Ve, Et, st, Ft, Ot, he, et, ot, me, de, oe, be, fe]);
|
|
1797
|
+
return {
|
|
1798
|
+
wrapRef: pt,
|
|
1799
|
+
canvasRef: Te,
|
|
1800
|
+
canvasReady: gn,
|
|
1801
|
+
onPointerDown: dr,
|
|
1802
|
+
onPointerMove: fr,
|
|
1803
|
+
onPointerUp: hr,
|
|
1804
|
+
resetView: yr,
|
|
1805
|
+
addCard: gr,
|
|
1806
|
+
addNode: pr,
|
|
1807
|
+
getCamera: xr,
|
|
1808
|
+
setCamera: mr,
|
|
1809
|
+
screenToFlowPosition: vr,
|
|
1810
|
+
store: wr
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
function Ir(t, e, n, r, s, o) {
|
|
1814
|
+
const i = s - n, c = o - r, u = i * i + c * c;
|
|
1815
|
+
if (u === 0) return Math.hypot(t - n, e - r);
|
|
1816
|
+
let l = ((t - n) * i + (e - r) * c) / u;
|
|
1817
|
+
return l = Math.max(0, Math.min(1, l)), Math.hypot(t - (n + l * i), e - (r + l * c));
|
|
1818
|
+
}
|
|
1819
|
+
const Zn = Fn(null);
|
|
1820
|
+
function ht() {
|
|
1821
|
+
const t = qe(Zn);
|
|
1822
|
+
if (!t)
|
|
1823
|
+
throw new Error("useCanvasStore must be used within <InfiniteCanvas> or <InfiniteCanvasProvider>");
|
|
1824
|
+
return t;
|
|
1825
|
+
}
|
|
1826
|
+
const je = Fn(null);
|
|
1827
|
+
function Ro() {
|
|
1828
|
+
return qe(je);
|
|
1829
|
+
}
|
|
1830
|
+
function $r({ node: t, nodeType: e }) {
|
|
1831
|
+
var v, E, R;
|
|
1832
|
+
const n = ht(), r = V(null), s = t._absolutePosition || t.position, o = V(null);
|
|
1833
|
+
ut(() => {
|
|
1834
|
+
const M = r.current;
|
|
1835
|
+
if (!M) return;
|
|
1836
|
+
const T = new ResizeObserver((k) => {
|
|
1837
|
+
var D, x, f, p;
|
|
1838
|
+
const { width: z, height: W } = k[0].contentRect;
|
|
1839
|
+
if (z > 0 && W > 0) {
|
|
1840
|
+
const y = n.nodesRef.current.find((P) => P.id === t.id), N = (y == null ? void 0 : y.width) || ((D = y == null ? void 0 : y.measured) == null ? void 0 : D.width), C = (y == null ? void 0 : y.height) || ((x = y == null ? void 0 : y.measured) == null ? void 0 : x.height);
|
|
1841
|
+
(Math.abs((N || 0) - z) > 1 || Math.abs((C || 0) - W) > 1) && ((p = (f = n.onNodesChangeRef).current) == null || p.call(f, [
|
|
1842
|
+
{ id: t.id, type: "dimensions", dimensions: { width: z, height: W }, setAttributes: !0 }
|
|
1843
|
+
]));
|
|
1844
|
+
}
|
|
1845
|
+
});
|
|
1846
|
+
return T.observe(M), () => T.disconnect();
|
|
1847
|
+
}, [t.id, n]);
|
|
1848
|
+
const i = F((M) => {
|
|
1849
|
+
var P, b;
|
|
1850
|
+
if (M.stopPropagation(), n.onNodesChangeRef.current) {
|
|
1851
|
+
const L = [];
|
|
1852
|
+
if (M.shiftKey)
|
|
1853
|
+
L.push({ id: t.id, type: "select", selected: !t.selected });
|
|
1854
|
+
else
|
|
1855
|
+
for (const H of n.nodesRef.current)
|
|
1856
|
+
H.id === t.id && !H.selected ? L.push({ id: H.id, type: "select", selected: !0 }) : H.id !== t.id && H.selected && L.push({ id: H.id, type: "select", selected: !1 });
|
|
1857
|
+
L.length && n.onNodesChangeRef.current(L);
|
|
1858
|
+
}
|
|
1859
|
+
const T = n.cameraRef.current, k = n.wrapRef.current;
|
|
1860
|
+
if (!k) return;
|
|
1861
|
+
const z = k.getBoundingClientRect(), W = (M.clientX - z.left - T.x) / T.zoom, D = (M.clientY - z.top - T.y) / T.zoom, f = M.shiftKey && t.selected ? n.nodesRef.current.filter((L) => L.selected && L.id !== t.id).map((L) => ({ id: L.id, startPos: { ...L.position } })) : [];
|
|
1862
|
+
o.current = {
|
|
1863
|
+
startPos: { ...t.position },
|
|
1864
|
+
startMouse: { x: W, y: D },
|
|
1865
|
+
selectedStarts: f
|
|
1866
|
+
};
|
|
1867
|
+
const p = [{ id: t.id, type: "position", dragging: !0 }];
|
|
1868
|
+
for (const L of f)
|
|
1869
|
+
p.push({ id: L.id, type: "position", dragging: !0 });
|
|
1870
|
+
(b = (P = n.onNodesChangeRef).current) == null || b.call(P, p);
|
|
1871
|
+
const y = r.current;
|
|
1872
|
+
y && y.setPointerCapture(M.pointerId);
|
|
1873
|
+
const N = (L) => {
|
|
1874
|
+
var at, ct, lt, Ct;
|
|
1875
|
+
if (!o.current) return;
|
|
1876
|
+
const Y = n.cameraRef.current, H = k.getBoundingClientRect(), dt = (L.clientX - H.left - Y.x) / Y.zoom, yt = (L.clientY - H.top - Y.y) / Y.zoom, ft = dt - o.current.startMouse.x, G = yt - o.current.startMouse.y;
|
|
1877
|
+
let j = { x: o.current.startPos.x + ft, y: o.current.startPos.y + G };
|
|
1878
|
+
if (n.snapToGrid && n.snapGrid && (j = {
|
|
1879
|
+
x: n.snapGrid[0] * Math.round(j.x / n.snapGrid[0]),
|
|
1880
|
+
y: n.snapGrid[1] * Math.round(j.y / n.snapGrid[1])
|
|
1881
|
+
}), t.parentId && t.extent === "parent") {
|
|
1882
|
+
const et = n.nodesRef.current.find((ot) => ot.id === t.parentId);
|
|
1883
|
+
if (et) {
|
|
1884
|
+
const ot = et.width || 160, Nt = et.height || 60, Rt = t.width || ((at = t.measured) == null ? void 0 : at.width) || 160, vt = t.height || ((ct = t.measured) == null ? void 0 : ct.height) || 60;
|
|
1885
|
+
j = {
|
|
1886
|
+
x: Math.max(0, Math.min(j.x, ot - Rt)),
|
|
1887
|
+
y: Math.max(0, Math.min(j.y, Nt - vt))
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
const rt = [{ id: t.id, type: "position", position: j, dragging: !0 }];
|
|
1892
|
+
for (const et of o.current.selectedStarts) {
|
|
1893
|
+
let ot = { x: et.startPos.x + ft, y: et.startPos.y + G };
|
|
1894
|
+
n.snapToGrid && n.snapGrid && (ot = {
|
|
1895
|
+
x: n.snapGrid[0] * Math.round(ot.x / n.snapGrid[0]),
|
|
1896
|
+
y: n.snapGrid[1] * Math.round(ot.y / n.snapGrid[1])
|
|
1897
|
+
}), rt.push({ id: et.id, type: "position", position: ot, dragging: !0 });
|
|
1898
|
+
}
|
|
1899
|
+
(Ct = (lt = n.onNodesChangeRef).current) == null || Ct.call(lt, rt);
|
|
1900
|
+
}, C = (L) => {
|
|
1901
|
+
var H, dt;
|
|
1902
|
+
if (!o.current) return;
|
|
1903
|
+
const Y = [{ id: t.id, type: "position", dragging: !1 }];
|
|
1904
|
+
for (const yt of o.current.selectedStarts)
|
|
1905
|
+
Y.push({ id: yt.id, type: "position", dragging: !1 });
|
|
1906
|
+
(dt = (H = n.onNodesChangeRef).current) == null || dt.call(H, Y), o.current = null, y && y.releasePointerCapture(L.pointerId), y == null || y.removeEventListener("pointermove", N), y == null || y.removeEventListener("pointerup", C);
|
|
1907
|
+
};
|
|
1908
|
+
y == null || y.addEventListener("pointermove", N), y == null || y.addEventListener("pointerup", C);
|
|
1909
|
+
}, [t, n]), c = F((M) => {
|
|
1910
|
+
var x, f, p, y, N, C;
|
|
1911
|
+
if (!t.selected) return;
|
|
1912
|
+
const T = M.shiftKey ? 10 : 1;
|
|
1913
|
+
let k = 0, z = 0;
|
|
1914
|
+
switch (M.key) {
|
|
1915
|
+
case "ArrowUp":
|
|
1916
|
+
z = -T;
|
|
1917
|
+
break;
|
|
1918
|
+
case "ArrowDown":
|
|
1919
|
+
z = T;
|
|
1920
|
+
break;
|
|
1921
|
+
case "ArrowLeft":
|
|
1922
|
+
k = -T;
|
|
1923
|
+
break;
|
|
1924
|
+
case "ArrowRight":
|
|
1925
|
+
k = T;
|
|
1926
|
+
break;
|
|
1927
|
+
case "Escape":
|
|
1928
|
+
(f = (x = n.onNodesChangeRef).current) == null || f.call(x, [{ id: t.id, type: "select", selected: !1 }]);
|
|
1929
|
+
return;
|
|
1930
|
+
case "Delete":
|
|
1931
|
+
case "Backspace":
|
|
1932
|
+
t.deletable !== !1 && ((y = (p = n.onNodesChangeRef).current) == null || y.call(p, [{ id: t.id, type: "remove" }]));
|
|
1933
|
+
return;
|
|
1934
|
+
default:
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
M.preventDefault();
|
|
1938
|
+
const W = { x: t.position.x + k, y: t.position.y + z }, D = [{ id: t.id, type: "position", position: W }];
|
|
1939
|
+
for (const P of n.nodesRef.current)
|
|
1940
|
+
P.selected && P.id !== t.id && D.push({ id: P.id, type: "position", position: { x: P.position.x + k, y: P.position.y + z } });
|
|
1941
|
+
(C = (N = n.onNodesChangeRef).current) == null || C.call(N, D);
|
|
1942
|
+
}, [t, n]), u = t.width || ((v = t.measured) == null ? void 0 : v.width), l = t.height || ((E = t.measured) == null ? void 0 : E.height), g = !!(u && l);
|
|
1943
|
+
return /* @__PURE__ */ B(je.Provider, { value: t.id, children: /* @__PURE__ */ B(
|
|
1944
|
+
"div",
|
|
1945
|
+
{
|
|
1946
|
+
ref: r,
|
|
1947
|
+
className: `ric-node-wrapper ${t.selected ? "selected" : ""} ${t.dragging ? "dragging" : ""}`,
|
|
1948
|
+
style: {
|
|
1949
|
+
position: "absolute",
|
|
1950
|
+
left: s.x,
|
|
1951
|
+
top: s.y,
|
|
1952
|
+
zIndex: t.type === "group" ? 0 : t.zIndex || 1,
|
|
1953
|
+
pointerEvents: t.type === "group" ? "none" : "all",
|
|
1954
|
+
cursor: t.dragging ? "grabbing" : "grab",
|
|
1955
|
+
visibility: g ? "visible" : "hidden",
|
|
1956
|
+
userSelect: "none",
|
|
1957
|
+
outline: "none"
|
|
1958
|
+
},
|
|
1959
|
+
"data-nodeid": t.id,
|
|
1960
|
+
tabIndex: t.selectable !== !1 ? 0 : void 0,
|
|
1961
|
+
role: "button",
|
|
1962
|
+
"aria-label": `Node ${((R = t.data) == null ? void 0 : R.label) || t.id}`,
|
|
1963
|
+
"aria-selected": !!t.selected,
|
|
1964
|
+
onPointerDown: i,
|
|
1965
|
+
onKeyDown: c,
|
|
1966
|
+
children: /* @__PURE__ */ B(
|
|
1967
|
+
e,
|
|
1968
|
+
{
|
|
1969
|
+
id: t.id,
|
|
1970
|
+
data: t.data,
|
|
1971
|
+
type: t.type,
|
|
1972
|
+
selected: !!t.selected,
|
|
1973
|
+
dragging: !!t.dragging,
|
|
1974
|
+
draggable: t.draggable !== !1,
|
|
1975
|
+
selectable: t.selectable !== !1,
|
|
1976
|
+
deletable: t.deletable !== !1,
|
|
1977
|
+
isConnectable: t.connectable !== !1,
|
|
1978
|
+
zIndex: t.zIndex || 0,
|
|
1979
|
+
positionAbsoluteX: s.x,
|
|
1980
|
+
positionAbsoluteY: s.y,
|
|
1981
|
+
width: u,
|
|
1982
|
+
height: l,
|
|
1983
|
+
sourcePosition: t.sourcePosition,
|
|
1984
|
+
targetPosition: t.targetPosition,
|
|
1985
|
+
parentId: t.parentId,
|
|
1986
|
+
dragHandle: t.dragHandle
|
|
1987
|
+
}
|
|
1988
|
+
)
|
|
1989
|
+
}
|
|
1990
|
+
) });
|
|
1991
|
+
}
|
|
1992
|
+
const Pr = Zt($r), Qn = 160, Kn = 60;
|
|
1993
|
+
function Bn(t, e, n, r) {
|
|
1994
|
+
var c, u;
|
|
1995
|
+
const s = t.width || ((c = t.measured) == null ? void 0 : c.width) || Qn, o = t.height || ((u = t.measured) == null ? void 0 : u.height) || Kn, i = t._absolutePosition || t.position;
|
|
1996
|
+
if (t.handleBounds) {
|
|
1997
|
+
const l = t.handleBounds[e] || [], g = n ? l.find((v) => v.id === n) : l[0];
|
|
1998
|
+
if (g && g.x !== void 0 && g.y !== void 0) {
|
|
1999
|
+
const v = g.position || (e === "source" ? "right" : "left");
|
|
2000
|
+
return { x: i.x + g.x, y: i.y + g.y, position: v };
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
if (r) {
|
|
2004
|
+
const l = `${t.id}__${n || e}`, g = r.get(l);
|
|
2005
|
+
if (g && g.x !== void 0 && g.y !== void 0)
|
|
2006
|
+
return { x: i.x + g.x, y: i.y + g.y, position: g.position || (e === "source" ? "right" : "left") };
|
|
2007
|
+
}
|
|
2008
|
+
if (t.handles && t.handles.length) {
|
|
2009
|
+
for (const l of t.handles)
|
|
2010
|
+
if (l.type === e && (!n || l.id === n)) {
|
|
2011
|
+
if (l.x !== void 0 && l.y !== void 0)
|
|
2012
|
+
return { x: i.x + l.x, y: i.y + l.y, position: l.position || (e === "source" ? "right" : "left") };
|
|
2013
|
+
const g = l.position || (e === "source" ? "right" : "left");
|
|
2014
|
+
switch (g) {
|
|
2015
|
+
case "top":
|
|
2016
|
+
return { x: i.x + s / 2, y: i.y, position: g };
|
|
2017
|
+
case "bottom":
|
|
2018
|
+
return { x: i.x + s / 2, y: i.y + o, position: g };
|
|
2019
|
+
case "left":
|
|
2020
|
+
return { x: i.x, y: i.y + o / 2, position: g };
|
|
2021
|
+
default:
|
|
2022
|
+
return { x: i.x + s, y: i.y + o / 2, position: g };
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return e === "source" ? { x: i.x + s, y: i.y + o / 2, position: "right" } : { x: i.x, y: i.y + o / 2, position: "left" };
|
|
2027
|
+
}
|
|
2028
|
+
function Tr(t, e, n) {
|
|
2029
|
+
return n === "left" ? t - e : n === "right" ? t + e : t;
|
|
2030
|
+
}
|
|
2031
|
+
function Sr(t, e, n) {
|
|
2032
|
+
return n === "top" ? t - e : n === "bottom" ? t + e : t;
|
|
2033
|
+
}
|
|
2034
|
+
function Dn({ x: t, y: e, position: n, type: r, onPointerDown: s }) {
|
|
2035
|
+
return /* @__PURE__ */ B(
|
|
2036
|
+
"circle",
|
|
2037
|
+
{
|
|
2038
|
+
className: `ric-edge-anchor ric-edge-anchor-${r}`,
|
|
2039
|
+
cx: Tr(t, 10, n),
|
|
2040
|
+
cy: Sr(e, 10, n),
|
|
2041
|
+
r: 10,
|
|
2042
|
+
stroke: "transparent",
|
|
2043
|
+
fill: "transparent",
|
|
2044
|
+
style: { cursor: "move", pointerEvents: "stroke" },
|
|
2045
|
+
onPointerDown: s
|
|
2046
|
+
}
|
|
2047
|
+
);
|
|
2048
|
+
}
|
|
2049
|
+
function Br({ edge: t, edgeType: e, nodes: n, reconnectable: r }) {
|
|
2050
|
+
var x, f, p;
|
|
2051
|
+
const s = ht(), [o, i] = Gt(null), c = F((y, N, C, P) => {
|
|
2052
|
+
var ft;
|
|
2053
|
+
N.stopPropagation(), N.preventDefault();
|
|
2054
|
+
const b = s.wrapRef.current;
|
|
2055
|
+
if (!b) return;
|
|
2056
|
+
const L = y === "source" ? P : C, Y = y === "source" ? t.target : t.source;
|
|
2057
|
+
(ft = s.workerRef.current) == null || ft.postMessage({
|
|
2058
|
+
type: "connecting",
|
|
2059
|
+
data: { from: { x: L.x, y: L.y }, to: { x: L.x, y: L.y } }
|
|
2060
|
+
});
|
|
2061
|
+
const H = b.getBoundingClientRect(), dt = (G) => {
|
|
2062
|
+
var ct;
|
|
2063
|
+
const j = s.cameraRef.current, rt = (G.clientX - H.left - j.x) / j.zoom, at = (G.clientY - H.top - j.y) / j.zoom;
|
|
2064
|
+
(ct = s.workerRef.current) == null || ct.postMessage({
|
|
2065
|
+
type: "connecting",
|
|
2066
|
+
data: { from: { x: L.x, y: L.y }, to: { x: rt, y: at } }
|
|
2067
|
+
});
|
|
2068
|
+
}, yt = (G) => {
|
|
2069
|
+
var ot, Nt, Rt, vt;
|
|
2070
|
+
const j = s.cameraRef.current, rt = (G.clientX - H.left - j.x) / j.zoom, at = (G.clientY - H.top - j.y) / j.zoom, ct = 20 / j.zoom;
|
|
2071
|
+
let lt = null, Ct = null;
|
|
2072
|
+
const et = (ot = s.handleRegistryRef) == null ? void 0 : ot.current;
|
|
2073
|
+
for (const Lt of s.nodesRef.current) {
|
|
2074
|
+
if (Lt.hidden) continue;
|
|
2075
|
+
const kt = Lt.width || Qn, $t = Lt.height || Kn, mt = Lt._absolutePosition || Lt.position, ne = [];
|
|
2076
|
+
if (et)
|
|
2077
|
+
for (const [, Bt] of et)
|
|
2078
|
+
Bt.nodeId === Lt.id && ne.push(Bt);
|
|
2079
|
+
const Ie = ne.length > 0 ? ne : Lt.handles || [
|
|
2080
|
+
{ type: "target", position: "left" },
|
|
2081
|
+
{ type: "source", position: "right" }
|
|
2082
|
+
];
|
|
2083
|
+
for (const Bt of Ie) {
|
|
2084
|
+
let Qt, Yt;
|
|
2085
|
+
if (Bt.x !== void 0 && Bt.y !== void 0)
|
|
2086
|
+
Qt = mt.x + Bt.x, Yt = mt.y + Bt.y;
|
|
2087
|
+
else
|
|
2088
|
+
switch (Bt.position || (Bt.type === "source" ? "right" : "left")) {
|
|
2089
|
+
case "top":
|
|
2090
|
+
Qt = mt.x + kt / 2, Yt = mt.y;
|
|
2091
|
+
break;
|
|
2092
|
+
case "bottom":
|
|
2093
|
+
Qt = mt.x + kt / 2, Yt = mt.y + $t;
|
|
2094
|
+
break;
|
|
2095
|
+
case "left":
|
|
2096
|
+
Qt = mt.x, Yt = mt.y + $t / 2;
|
|
2097
|
+
break;
|
|
2098
|
+
default:
|
|
2099
|
+
Qt = mt.x + kt, Yt = mt.y + $t / 2;
|
|
2100
|
+
break;
|
|
2101
|
+
}
|
|
2102
|
+
if (Math.abs(rt - Qt) < ct && Math.abs(at - Yt) < ct) {
|
|
2103
|
+
lt = Lt, Ct = Bt.id || null;
|
|
2104
|
+
break;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
if (lt) break;
|
|
2108
|
+
}
|
|
2109
|
+
if (lt) {
|
|
2110
|
+
const Lt = y === "source" ? { source: lt.id, target: Y, sourceHandle: Ct, targetHandle: t.targetHandle } : { source: Y, target: lt.id, sourceHandle: t.sourceHandle, targetHandle: Ct };
|
|
2111
|
+
(Rt = (Nt = s.onEdgesChangeRef).current) == null || Rt.call(Nt, [
|
|
2112
|
+
{ id: t.id, type: "remove" },
|
|
2113
|
+
{ type: "add", item: { id: t.id, ...Lt } }
|
|
2114
|
+
]);
|
|
2115
|
+
}
|
|
2116
|
+
(vt = s.workerRef.current) == null || vt.postMessage({ type: "connecting", data: null }), b.removeEventListener("pointermove", dt), b.removeEventListener("pointerup", yt);
|
|
2117
|
+
};
|
|
2118
|
+
b.addEventListener("pointermove", dt), b.addEventListener("pointerup", yt);
|
|
2119
|
+
}, [t, s]), u = n.find((y) => y.id === t.source), l = n.find((y) => y.id === t.target), g = u && !!(u.width || (x = u.measured) != null && x.width), v = l && !!(l.width || (f = l.measured) != null && f.width), E = (p = s.handleRegistryRef) == null ? void 0 : p.current, R = g ? Bn(u, "source", t.sourceHandle, E) : null, M = v ? Bn(l, "target", t.targetHandle, E) : null, T = t.type === "bezier" || t.type === "simplebezier" || t.type === "default", k = s.routedEdges || s.edges, z = k == null ? void 0 : k.find((y) => y.id === t.id), W = T ? null : (z == null ? void 0 : z._routedPoints) || t._routedPoints || null, D = r !== !1 && t.reconnectable !== !1;
|
|
2120
|
+
return !R || !M ? null : /* @__PURE__ */ It(
|
|
2121
|
+
"g",
|
|
2122
|
+
{
|
|
2123
|
+
className: `ric-edge-wrapper ${t.selected ? "selected" : ""}`,
|
|
2124
|
+
"data-edgeid": t.id,
|
|
2125
|
+
onMouseEnter: () => i(!0),
|
|
2126
|
+
onMouseLeave: () => i(!1),
|
|
2127
|
+
children: [
|
|
2128
|
+
/* @__PURE__ */ B(
|
|
2129
|
+
e,
|
|
2130
|
+
{
|
|
2131
|
+
id: t.id,
|
|
2132
|
+
source: t.source,
|
|
2133
|
+
target: t.target,
|
|
2134
|
+
sourceX: R.x,
|
|
2135
|
+
sourceY: R.y,
|
|
2136
|
+
targetX: M.x,
|
|
2137
|
+
targetY: M.y,
|
|
2138
|
+
sourcePosition: R.position,
|
|
2139
|
+
targetPosition: M.position,
|
|
2140
|
+
sourceHandleId: t.sourceHandle,
|
|
2141
|
+
targetHandleId: t.targetHandle,
|
|
2142
|
+
data: t.data,
|
|
2143
|
+
type: t.type,
|
|
2144
|
+
selected: !!t.selected,
|
|
2145
|
+
animated: !!t.animated,
|
|
2146
|
+
label: t.label,
|
|
2147
|
+
style: t.style,
|
|
2148
|
+
selectable: t.selectable !== !1,
|
|
2149
|
+
deletable: t.deletable !== !1,
|
|
2150
|
+
routedPoints: W
|
|
2151
|
+
}
|
|
2152
|
+
),
|
|
2153
|
+
D && (o || t.selected) && /* @__PURE__ */ It(Le, { children: [
|
|
2154
|
+
/* @__PURE__ */ B(
|
|
2155
|
+
Dn,
|
|
2156
|
+
{
|
|
2157
|
+
x: R.x,
|
|
2158
|
+
y: R.y,
|
|
2159
|
+
position: R.position,
|
|
2160
|
+
type: "source",
|
|
2161
|
+
onPointerDown: (y) => c("source", y, R, M)
|
|
2162
|
+
}
|
|
2163
|
+
),
|
|
2164
|
+
/* @__PURE__ */ B(
|
|
2165
|
+
Dn,
|
|
2166
|
+
{
|
|
2167
|
+
x: M.x,
|
|
2168
|
+
y: M.y,
|
|
2169
|
+
position: M.position,
|
|
2170
|
+
type: "target",
|
|
2171
|
+
onPointerDown: (y) => c("target", y, R, M)
|
|
2172
|
+
}
|
|
2173
|
+
)
|
|
2174
|
+
] })
|
|
2175
|
+
]
|
|
2176
|
+
}
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
const Dr = Zt(Br);
|
|
2180
|
+
function On({ selectionKeyCode: t = "Shift", selectionMode: e = "partial" }) {
|
|
2181
|
+
var T;
|
|
2182
|
+
const n = ht(), [r, s] = Gt(null), o = V(null);
|
|
2183
|
+
if (ut(() => {
|
|
2184
|
+
const k = n.wrapRef.current;
|
|
2185
|
+
if (!k) return;
|
|
2186
|
+
let z = !1, W = null, D = !1;
|
|
2187
|
+
const x = (C) => {
|
|
2188
|
+
C.key === t && (D = !0);
|
|
2189
|
+
}, f = (C) => {
|
|
2190
|
+
C.key === t && (D = !1);
|
|
2191
|
+
}, p = (C) => {
|
|
2192
|
+
if (!D) return;
|
|
2193
|
+
const P = C.target;
|
|
2194
|
+
if (P.closest(".ric-node-wrapper") || P.closest(".ric-handle")) return;
|
|
2195
|
+
z = !0;
|
|
2196
|
+
const b = n.cameraRef.current, L = k.getBoundingClientRect(), Y = (C.clientX - L.left - b.x) / b.zoom, H = (C.clientY - L.top - b.y) / b.zoom;
|
|
2197
|
+
W = { x: Y, y: H }, s({ startX: Y, startY: H, endX: Y, endY: H }), C.stopPropagation();
|
|
2198
|
+
}, y = (C) => {
|
|
2199
|
+
if (!z || !W) return;
|
|
2200
|
+
const P = n.cameraRef.current, b = k.getBoundingClientRect(), L = (C.clientX - b.left - P.x) / P.zoom, Y = (C.clientY - b.top - P.y) / P.zoom;
|
|
2201
|
+
s({ startX: W.x, startY: W.y, endX: L, endY: Y });
|
|
2202
|
+
}, N = (C) => {
|
|
2203
|
+
var yt, ft;
|
|
2204
|
+
if (!z || !W) return;
|
|
2205
|
+
z = !1;
|
|
2206
|
+
const P = n.cameraRef.current, b = k.getBoundingClientRect(), L = (C.clientX - b.left - P.x) / P.zoom, Y = (C.clientY - b.top - P.y) / P.zoom, H = {
|
|
2207
|
+
x: Math.min(W.x, L),
|
|
2208
|
+
y: Math.min(W.y, Y),
|
|
2209
|
+
width: Math.abs(L - W.x),
|
|
2210
|
+
height: Math.abs(Y - W.y)
|
|
2211
|
+
}, dt = [];
|
|
2212
|
+
for (const G of n.nodesRef.current) {
|
|
2213
|
+
const j = G._absolutePosition || G.position, rt = G.width || 160, at = G.height || 60;
|
|
2214
|
+
let ct;
|
|
2215
|
+
e === "full" ? ct = j.x >= H.x && j.y >= H.y && j.x + rt <= H.x + H.width && j.y + at <= H.y + H.height : ct = j.x + rt > H.x && j.x < H.x + H.width && j.y + at > H.y && j.y < H.y + H.height, dt.push({ id: G.id, type: "select", selected: ct });
|
|
2216
|
+
}
|
|
2217
|
+
dt.length && ((ft = (yt = n.onNodesChangeRef).current) == null || ft.call(yt, dt)), W = null, s(null);
|
|
2218
|
+
};
|
|
2219
|
+
return k.addEventListener("pointerdown", p, !0), k.addEventListener("pointermove", y), k.addEventListener("pointerup", N), window.addEventListener("keydown", x), window.addEventListener("keyup", f), () => {
|
|
2220
|
+
k.removeEventListener("pointerdown", p, !0), k.removeEventListener("pointermove", y), k.removeEventListener("pointerup", N), window.removeEventListener("keydown", x), window.removeEventListener("keyup", f);
|
|
2221
|
+
};
|
|
2222
|
+
}, [n, t, e]), !r) return null;
|
|
2223
|
+
const i = ((T = n.cameraRef) == null ? void 0 : T.current) || { x: 0, y: 0, zoom: 1 }, c = Math.min(r.startX, r.endX), u = Math.min(r.startY, r.endY), l = Math.abs(r.endX - r.startX), g = Math.abs(r.endY - r.startY), v = c * i.zoom + i.x, E = u * i.zoom + i.y, R = l * i.zoom, M = g * i.zoom;
|
|
2224
|
+
return /* @__PURE__ */ B(
|
|
2225
|
+
"div",
|
|
2226
|
+
{
|
|
2227
|
+
ref: o,
|
|
2228
|
+
className: "ric-selection-box",
|
|
2229
|
+
style: {
|
|
2230
|
+
position: "absolute",
|
|
2231
|
+
left: v,
|
|
2232
|
+
top: E,
|
|
2233
|
+
width: R,
|
|
2234
|
+
height: M,
|
|
2235
|
+
border: "1px dashed #3b82f6",
|
|
2236
|
+
background: "rgba(59, 130, 246, 0.08)",
|
|
2237
|
+
pointerEvents: "none",
|
|
2238
|
+
zIndex: 100
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
}
|
|
2243
|
+
On.displayName = "SelectionBox";
|
|
2244
|
+
const Hr = Zt(On);
|
|
2245
|
+
function Jn(t, e) {
|
|
2246
|
+
var s, o, i, c;
|
|
2247
|
+
const n = (s = t.handleRegistryRef) == null ? void 0 : s.current;
|
|
2248
|
+
if (!n) return;
|
|
2249
|
+
const r = { source: [], target: [] };
|
|
2250
|
+
for (const [, u] of n)
|
|
2251
|
+
if (u.nodeId === e) {
|
|
2252
|
+
const l = { id: u.id, type: u.type, position: u.position, x: u.x, y: u.y, width: 8, height: 8 };
|
|
2253
|
+
u.type === "source" ? r.source.push(l) : r.target.push(l);
|
|
2254
|
+
}
|
|
2255
|
+
(i = (o = t.onNodesChangeRef).current) == null || i.call(o, [
|
|
2256
|
+
{ id: e, type: "dimensions", handleBounds: r, setAttributes: !1 }
|
|
2257
|
+
]), (c = t.syncNodesToWorker) == null || c.call(t);
|
|
2258
|
+
}
|
|
2259
|
+
const vn = /* @__PURE__ */ new Set();
|
|
2260
|
+
function Hn(t, e) {
|
|
2261
|
+
vn.has(e) || (vn.add(e), queueMicrotask(() => {
|
|
2262
|
+
vn.delete(e), Jn(t, e);
|
|
2263
|
+
}));
|
|
2264
|
+
}
|
|
2265
|
+
function Ar(t, e) {
|
|
2266
|
+
const n = t.closest(".ric-node-wrapper");
|
|
2267
|
+
if (!n) return null;
|
|
2268
|
+
const r = n.getBoundingClientRect(), s = t.getBoundingClientRect(), o = e || 1;
|
|
2269
|
+
return {
|
|
2270
|
+
x: (s.left + s.width / 2 - r.left) / o,
|
|
2271
|
+
y: (s.top + s.height / 2 - r.top) / o
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
function on({
|
|
2275
|
+
type: t = "source",
|
|
2276
|
+
position: e = t === "source" ? "right" : "left",
|
|
2277
|
+
id: n,
|
|
2278
|
+
isConnectable: r = !0,
|
|
2279
|
+
isConnectableStart: s = !0,
|
|
2280
|
+
isConnectableEnd: o = !0,
|
|
2281
|
+
children: i,
|
|
2282
|
+
className: c = "",
|
|
2283
|
+
style: u = {},
|
|
2284
|
+
onConnect: l,
|
|
2285
|
+
...g
|
|
2286
|
+
}) {
|
|
2287
|
+
const v = qe(je), E = ht(), R = V(null), M = V(E);
|
|
2288
|
+
M.current = E;
|
|
2289
|
+
const T = F(() => {
|
|
2290
|
+
var C, P, b;
|
|
2291
|
+
const D = R.current;
|
|
2292
|
+
if (!D || !v) return;
|
|
2293
|
+
const x = M.current, f = (C = x.handleRegistryRef) == null ? void 0 : C.current;
|
|
2294
|
+
if (!f) return;
|
|
2295
|
+
const p = `${v}__${n || t}`, y = (b = (P = x.cameraRef) == null ? void 0 : P.current) == null ? void 0 : b.zoom, N = Ar(D, y);
|
|
2296
|
+
if (N) {
|
|
2297
|
+
const L = { nodeId: v, id: n || null, type: t, position: e, x: N.x, y: N.y };
|
|
2298
|
+
f.set(p, L);
|
|
2299
|
+
}
|
|
2300
|
+
}, [v, n, t, e]);
|
|
2301
|
+
kr(() => {
|
|
2302
|
+
T();
|
|
2303
|
+
}, [T]), ut(() => {
|
|
2304
|
+
if (!v) return;
|
|
2305
|
+
const D = M.current;
|
|
2306
|
+
Hn(D, v);
|
|
2307
|
+
const x = R.current, f = x == null ? void 0 : x.closest(".ric-node-wrapper"), p = new ResizeObserver(() => {
|
|
2308
|
+
T(), Hn(M.current, v);
|
|
2309
|
+
});
|
|
2310
|
+
return f && p.observe(f), () => {
|
|
2311
|
+
var P;
|
|
2312
|
+
p.disconnect();
|
|
2313
|
+
const y = M.current, N = (P = y.handleRegistryRef) == null ? void 0 : P.current, C = `${v}__${n || t}`;
|
|
2314
|
+
N == null || N.delete(C), Jn(y, v);
|
|
2315
|
+
};
|
|
2316
|
+
}, [v, n, t, e, T]);
|
|
2317
|
+
const k = F(() => {
|
|
2318
|
+
var b;
|
|
2319
|
+
const D = M.current, x = D.nodesRef.current.find((L) => L.id === v);
|
|
2320
|
+
if (!x) return null;
|
|
2321
|
+
const f = x._absolutePosition || x.position, p = (b = D.handleRegistryRef) == null ? void 0 : b.current, y = `${v}__${n || t}`, N = p == null ? void 0 : p.get(y);
|
|
2322
|
+
if (N && N.x !== void 0 && N.y !== void 0)
|
|
2323
|
+
return { x: f.x + N.x, y: f.y + N.y };
|
|
2324
|
+
const C = x.width || 160, P = x.height || 60;
|
|
2325
|
+
switch (e) {
|
|
2326
|
+
case "top":
|
|
2327
|
+
return { x: f.x + C / 2, y: f.y };
|
|
2328
|
+
case "bottom":
|
|
2329
|
+
return { x: f.x + C / 2, y: f.y + P };
|
|
2330
|
+
case "left":
|
|
2331
|
+
return { x: f.x, y: f.y + P / 2 };
|
|
2332
|
+
default:
|
|
2333
|
+
return { x: f.x + C, y: f.y + P / 2 };
|
|
2334
|
+
}
|
|
2335
|
+
}, [v, n, t, e]), z = F((D) => {
|
|
2336
|
+
var Y;
|
|
2337
|
+
if (!r || !s) return;
|
|
2338
|
+
D.stopPropagation(), D.preventDefault();
|
|
2339
|
+
const x = M.current, f = x.cameraRef.current, p = x.wrapRef.current;
|
|
2340
|
+
if (!p) return;
|
|
2341
|
+
const y = p.getBoundingClientRect(), N = k();
|
|
2342
|
+
if (!N) return;
|
|
2343
|
+
const C = N.x, P = N.y;
|
|
2344
|
+
(Y = x.workerRef.current) == null || Y.postMessage({
|
|
2345
|
+
type: "connecting",
|
|
2346
|
+
data: { from: { x: C, y: P }, to: { x: C, y: P } }
|
|
2347
|
+
}), p.setPointerCapture(D.pointerId);
|
|
2348
|
+
const b = (H) => {
|
|
2349
|
+
var ft;
|
|
2350
|
+
const dt = (H.clientX - y.left - f.x) / f.zoom, yt = (H.clientY - y.top - f.y) / f.zoom;
|
|
2351
|
+
(ft = x.workerRef.current) == null || ft.postMessage({
|
|
2352
|
+
type: "connecting",
|
|
2353
|
+
data: { from: { x: C, y: P }, to: { x: dt, y: yt } }
|
|
2354
|
+
});
|
|
2355
|
+
}, L = (H) => {
|
|
2356
|
+
var at, ct, lt, Ct;
|
|
2357
|
+
const dt = (H.clientX - y.left - f.x) / f.zoom, yt = (H.clientY - y.top - f.y) / f.zoom, ft = 20 / f.zoom;
|
|
2358
|
+
let G = null, j = null;
|
|
2359
|
+
const rt = (at = x.handleRegistryRef) == null ? void 0 : at.current;
|
|
2360
|
+
for (const et of x.nodesRef.current) {
|
|
2361
|
+
if (et.id === v || et.hidden) continue;
|
|
2362
|
+
const ot = et.width || 160, Nt = et.height || 60, Rt = et._absolutePosition || et.position, vt = [];
|
|
2363
|
+
if (rt)
|
|
2364
|
+
for (const [, kt] of rt)
|
|
2365
|
+
kt.nodeId === et.id && vt.push(kt);
|
|
2366
|
+
const Lt = vt.length > 0 ? vt : et.handles || [
|
|
2367
|
+
{ type: "target", position: "left" },
|
|
2368
|
+
{ type: "source", position: "right" }
|
|
2369
|
+
];
|
|
2370
|
+
for (const kt of Lt) {
|
|
2371
|
+
let $t, mt;
|
|
2372
|
+
if (kt.x !== void 0 && kt.y !== void 0)
|
|
2373
|
+
$t = Rt.x + kt.x, mt = Rt.y + kt.y;
|
|
2374
|
+
else
|
|
2375
|
+
switch (kt.position || (kt.type === "source" ? "right" : "left")) {
|
|
2376
|
+
case "top":
|
|
2377
|
+
$t = Rt.x + ot / 2, mt = Rt.y;
|
|
2378
|
+
break;
|
|
2379
|
+
case "bottom":
|
|
2380
|
+
$t = Rt.x + ot / 2, mt = Rt.y + Nt;
|
|
2381
|
+
break;
|
|
2382
|
+
case "left":
|
|
2383
|
+
$t = Rt.x, mt = Rt.y + Nt / 2;
|
|
2384
|
+
break;
|
|
2385
|
+
default:
|
|
2386
|
+
$t = Rt.x + ot, mt = Rt.y + Nt / 2;
|
|
2387
|
+
break;
|
|
2388
|
+
}
|
|
2389
|
+
if (Math.abs(dt - $t) < ft && Math.abs(yt - mt) < ft) {
|
|
2390
|
+
G = et, j = kt.id || null;
|
|
2391
|
+
break;
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
if (G) break;
|
|
2395
|
+
}
|
|
2396
|
+
if (G) {
|
|
2397
|
+
const et = {
|
|
2398
|
+
source: t === "source" ? v : G.id,
|
|
2399
|
+
target: t === "source" ? G.id : v,
|
|
2400
|
+
sourceHandle: t === "source" ? n || null : j,
|
|
2401
|
+
targetHandle: t === "source" ? j : n || null
|
|
2402
|
+
};
|
|
2403
|
+
(lt = (ct = x.onEdgesChangeRef) == null ? void 0 : ct.current) == null || lt.call(ct, [{ type: "add", item: { id: `e-${et.source}-${et.target}`, ...et } }]);
|
|
2404
|
+
}
|
|
2405
|
+
(Ct = x.workerRef.current) == null || Ct.postMessage({ type: "connecting", data: null }), p.removeEventListener("pointermove", b), p.removeEventListener("pointerup", L);
|
|
2406
|
+
};
|
|
2407
|
+
p.addEventListener("pointermove", b), p.addEventListener("pointerup", L);
|
|
2408
|
+
}, [v, n, t, e, r, s, k]), W = {
|
|
2409
|
+
top: { top: 0, left: "50%", transform: "translate(-50%, -50%)" },
|
|
2410
|
+
bottom: { bottom: 0, left: "50%", transform: "translate(-50%, 50%)" },
|
|
2411
|
+
left: { top: "50%", left: 0, transform: "translate(-50%, -50%)" },
|
|
2412
|
+
right: { top: "50%", right: 0, transform: "translate(50%, -50%)" }
|
|
2413
|
+
}[e] || {};
|
|
2414
|
+
return /* @__PURE__ */ B(
|
|
2415
|
+
"div",
|
|
2416
|
+
{
|
|
2417
|
+
ref: R,
|
|
2418
|
+
className: `ric-handle ric-handle-${e} ric-handle-${t} ${c}`,
|
|
2419
|
+
"data-handleid": n || null,
|
|
2420
|
+
"data-nodeid": v,
|
|
2421
|
+
"data-handlepos": e,
|
|
2422
|
+
"data-handletype": t,
|
|
2423
|
+
onPointerDown: z,
|
|
2424
|
+
style: {
|
|
2425
|
+
position: "absolute",
|
|
2426
|
+
width: 8,
|
|
2427
|
+
height: 8,
|
|
2428
|
+
borderRadius: "50%",
|
|
2429
|
+
background: "#1a192b",
|
|
2430
|
+
border: "none",
|
|
2431
|
+
zIndex: 10,
|
|
2432
|
+
cursor: r ? "crosshair" : "default",
|
|
2433
|
+
boxSizing: "border-box",
|
|
2434
|
+
...W,
|
|
2435
|
+
...u
|
|
2436
|
+
},
|
|
2437
|
+
...g,
|
|
2438
|
+
children: i
|
|
2439
|
+
}
|
|
2440
|
+
);
|
|
2441
|
+
}
|
|
2442
|
+
function ko({
|
|
2443
|
+
data: t,
|
|
2444
|
+
isConnectable: e,
|
|
2445
|
+
selected: n,
|
|
2446
|
+
targetPosition: r = "left",
|
|
2447
|
+
sourcePosition: s = "right",
|
|
2448
|
+
hideSourceHandle: o = !1,
|
|
2449
|
+
hideTargetHandle: i = !1
|
|
2450
|
+
}) {
|
|
2451
|
+
return /* @__PURE__ */ It(
|
|
2452
|
+
"div",
|
|
2453
|
+
{
|
|
2454
|
+
className: `ric-default-node${n ? " selected" : ""}`,
|
|
2455
|
+
style: {
|
|
2456
|
+
background: "#fff",
|
|
2457
|
+
border: "1px solid #1a192b",
|
|
2458
|
+
borderRadius: 3,
|
|
2459
|
+
padding: "10px",
|
|
2460
|
+
minWidth: 150,
|
|
2461
|
+
fontSize: 12,
|
|
2462
|
+
fontFamily: "inherit",
|
|
2463
|
+
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2464
|
+
},
|
|
2465
|
+
children: [
|
|
2466
|
+
!i && /* @__PURE__ */ B(on, { type: "target", position: r, isConnectable: e }),
|
|
2467
|
+
/* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
|
|
2468
|
+
!o && /* @__PURE__ */ B(on, { type: "source", position: s, isConnectable: e })
|
|
2469
|
+
]
|
|
2470
|
+
}
|
|
2471
|
+
);
|
|
2472
|
+
}
|
|
2473
|
+
function _r({
|
|
2474
|
+
data: t,
|
|
2475
|
+
isConnectable: e,
|
|
2476
|
+
selected: n,
|
|
2477
|
+
sourcePosition: r = "right",
|
|
2478
|
+
hideSourceHandle: s = !1
|
|
2479
|
+
}) {
|
|
2480
|
+
return /* @__PURE__ */ It(
|
|
2481
|
+
"div",
|
|
2482
|
+
{
|
|
2483
|
+
className: `ric-input-node${n ? " selected" : ""}`,
|
|
2484
|
+
style: {
|
|
2485
|
+
background: "#fff",
|
|
2486
|
+
border: "1px solid #1a192b",
|
|
2487
|
+
borderBottom: "2px solid #0041d0",
|
|
2488
|
+
borderRadius: 3,
|
|
2489
|
+
padding: "10px",
|
|
2490
|
+
minWidth: 150,
|
|
2491
|
+
fontSize: 12,
|
|
2492
|
+
fontFamily: "inherit",
|
|
2493
|
+
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2494
|
+
},
|
|
2495
|
+
children: [
|
|
2496
|
+
/* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label }),
|
|
2497
|
+
!s && /* @__PURE__ */ B(on, { type: "source", position: r, isConnectable: e })
|
|
2498
|
+
]
|
|
2499
|
+
}
|
|
2500
|
+
);
|
|
2501
|
+
}
|
|
2502
|
+
function Wr({
|
|
2503
|
+
data: t,
|
|
2504
|
+
isConnectable: e,
|
|
2505
|
+
selected: n,
|
|
2506
|
+
targetPosition: r = "left",
|
|
2507
|
+
hideTargetHandle: s = !1
|
|
2508
|
+
}) {
|
|
2509
|
+
return /* @__PURE__ */ It(
|
|
2510
|
+
"div",
|
|
2511
|
+
{
|
|
2512
|
+
className: `ric-output-node${n ? " selected" : ""}`,
|
|
2513
|
+
style: {
|
|
2514
|
+
background: "#fff",
|
|
2515
|
+
border: "1px solid #1a192b",
|
|
2516
|
+
borderTop: "2px solid #ff0072",
|
|
2517
|
+
borderRadius: 3,
|
|
2518
|
+
padding: "10px",
|
|
2519
|
+
minWidth: 150,
|
|
2520
|
+
fontSize: 12,
|
|
2521
|
+
fontFamily: "inherit",
|
|
2522
|
+
boxShadow: n ? "0 0 0 0.5px #1a192b" : "none"
|
|
2523
|
+
},
|
|
2524
|
+
children: [
|
|
2525
|
+
!s && /* @__PURE__ */ B(on, { type: "target", position: r, isConnectable: e }),
|
|
2526
|
+
/* @__PURE__ */ B("div", { className: "ric-node-content", children: t == null ? void 0 : t.label })
|
|
2527
|
+
]
|
|
2528
|
+
}
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2531
|
+
function Xr({ data: t, selected: e, width: n, height: r }) {
|
|
2532
|
+
return /* @__PURE__ */ B(
|
|
2533
|
+
"div",
|
|
2534
|
+
{
|
|
2535
|
+
className: `ric-group-node${e ? " selected" : ""}`,
|
|
2536
|
+
style: {
|
|
2537
|
+
width: n || 300,
|
|
2538
|
+
height: r || 200,
|
|
2539
|
+
background: "rgba(240, 240, 240, 0.25)",
|
|
2540
|
+
border: e ? "2px solid #3b82f6" : "1px dashed #ccc",
|
|
2541
|
+
borderRadius: 8,
|
|
2542
|
+
padding: 8,
|
|
2543
|
+
boxSizing: "border-box"
|
|
2544
|
+
},
|
|
2545
|
+
children: (t == null ? void 0 : t.label) && /* @__PURE__ */ B(
|
|
2546
|
+
"div",
|
|
2547
|
+
{
|
|
2548
|
+
style: {
|
|
2549
|
+
fontSize: 11,
|
|
2550
|
+
fontWeight: 600,
|
|
2551
|
+
color: "#888",
|
|
2552
|
+
userSelect: "none"
|
|
2553
|
+
},
|
|
2554
|
+
children: t.label
|
|
2555
|
+
}
|
|
2556
|
+
)
|
|
2557
|
+
}
|
|
2558
|
+
);
|
|
2559
|
+
}
|
|
2560
|
+
function Vn({
|
|
2561
|
+
x: t,
|
|
2562
|
+
y: e,
|
|
2563
|
+
label: n,
|
|
2564
|
+
labelStyle: r,
|
|
2565
|
+
labelShowBg: s = !0,
|
|
2566
|
+
labelBgStyle: o,
|
|
2567
|
+
labelBgPadding: i = [2, 4],
|
|
2568
|
+
labelBgBorderRadius: c = 2,
|
|
2569
|
+
children: u,
|
|
2570
|
+
className: l = "",
|
|
2571
|
+
...g
|
|
2572
|
+
}) {
|
|
2573
|
+
const [v, E] = Gt({ x: 1, y: 0, width: 0, height: 0 }), R = V(null);
|
|
2574
|
+
return ut(() => {
|
|
2575
|
+
if (R.current) {
|
|
2576
|
+
const M = R.current.getBBox();
|
|
2577
|
+
E({
|
|
2578
|
+
x: M.x,
|
|
2579
|
+
y: M.y,
|
|
2580
|
+
width: M.width,
|
|
2581
|
+
height: M.height
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
}, [n]), n ? /* @__PURE__ */ It(
|
|
2585
|
+
"g",
|
|
2586
|
+
{
|
|
2587
|
+
transform: `translate(${t - v.width / 2} ${e - v.height / 2})`,
|
|
2588
|
+
className: `ric-edge-textwrapper ${l}`,
|
|
2589
|
+
visibility: v.width ? "visible" : "hidden",
|
|
2590
|
+
...g,
|
|
2591
|
+
children: [
|
|
2592
|
+
s && /* @__PURE__ */ B(
|
|
2593
|
+
"rect",
|
|
2594
|
+
{
|
|
2595
|
+
width: v.width + 2 * i[0],
|
|
2596
|
+
x: -i[0],
|
|
2597
|
+
y: -i[1],
|
|
2598
|
+
height: v.height + 2 * i[1],
|
|
2599
|
+
className: "ric-edge-textbg",
|
|
2600
|
+
style: o,
|
|
2601
|
+
rx: c,
|
|
2602
|
+
ry: c
|
|
2603
|
+
}
|
|
2604
|
+
),
|
|
2605
|
+
/* @__PURE__ */ B(
|
|
2606
|
+
"text",
|
|
2607
|
+
{
|
|
2608
|
+
className: "ric-edge-text",
|
|
2609
|
+
y: v.height / 2,
|
|
2610
|
+
dy: "0.3em",
|
|
2611
|
+
ref: R,
|
|
2612
|
+
style: r,
|
|
2613
|
+
children: n
|
|
2614
|
+
}
|
|
2615
|
+
),
|
|
2616
|
+
u
|
|
2617
|
+
]
|
|
2618
|
+
}
|
|
2619
|
+
) : null;
|
|
2620
|
+
}
|
|
2621
|
+
Vn.displayName = "EdgeText";
|
|
2622
|
+
const Fr = Zt(Vn);
|
|
2623
|
+
function An(t) {
|
|
2624
|
+
return t != null && t !== "" && !isNaN(Number(t));
|
|
2625
|
+
}
|
|
2626
|
+
function un({
|
|
2627
|
+
id: t,
|
|
2628
|
+
path: e,
|
|
2629
|
+
labelX: n,
|
|
2630
|
+
labelY: r,
|
|
2631
|
+
label: s,
|
|
2632
|
+
labelStyle: o,
|
|
2633
|
+
labelShowBg: i,
|
|
2634
|
+
labelBgStyle: c,
|
|
2635
|
+
labelBgPadding: u,
|
|
2636
|
+
labelBgBorderRadius: l,
|
|
2637
|
+
interactionWidth: g = 20,
|
|
2638
|
+
style: v,
|
|
2639
|
+
markerEnd: E,
|
|
2640
|
+
markerStart: R,
|
|
2641
|
+
className: M = "",
|
|
2642
|
+
...T
|
|
2643
|
+
}) {
|
|
2644
|
+
return /* @__PURE__ */ It(Le, { children: [
|
|
2645
|
+
/* @__PURE__ */ B(
|
|
2646
|
+
"path",
|
|
2647
|
+
{
|
|
2648
|
+
id: t,
|
|
2649
|
+
d: e,
|
|
2650
|
+
fill: "none",
|
|
2651
|
+
stroke: "#b1b1b7",
|
|
2652
|
+
strokeWidth: 1.5,
|
|
2653
|
+
className: `ric-edge-path ${M}`,
|
|
2654
|
+
style: v,
|
|
2655
|
+
markerEnd: E,
|
|
2656
|
+
markerStart: R,
|
|
2657
|
+
...T
|
|
2658
|
+
}
|
|
2659
|
+
),
|
|
2660
|
+
g ? /* @__PURE__ */ B(
|
|
2661
|
+
"path",
|
|
2662
|
+
{
|
|
2663
|
+
d: e,
|
|
2664
|
+
fill: "none",
|
|
2665
|
+
strokeOpacity: 0,
|
|
2666
|
+
strokeWidth: g,
|
|
2667
|
+
className: "ric-edge-interaction",
|
|
2668
|
+
style: { pointerEvents: "stroke" }
|
|
2669
|
+
}
|
|
2670
|
+
) : null,
|
|
2671
|
+
s && An(n) && An(r) ? /* @__PURE__ */ B(
|
|
2672
|
+
Fr,
|
|
2673
|
+
{
|
|
2674
|
+
x: n,
|
|
2675
|
+
y: r,
|
|
2676
|
+
label: s,
|
|
2677
|
+
labelStyle: o,
|
|
2678
|
+
labelShowBg: i,
|
|
2679
|
+
labelBgStyle: c,
|
|
2680
|
+
labelBgPadding: u,
|
|
2681
|
+
labelBgBorderRadius: l
|
|
2682
|
+
}
|
|
2683
|
+
) : null
|
|
2684
|
+
] });
|
|
2685
|
+
}
|
|
2686
|
+
const Ye = 20;
|
|
2687
|
+
function _n(t, e, n) {
|
|
2688
|
+
switch (n) {
|
|
2689
|
+
case "right":
|
|
2690
|
+
return { x: t + Ye, y: e };
|
|
2691
|
+
case "left":
|
|
2692
|
+
return { x: t - Ye, y: e };
|
|
2693
|
+
case "bottom":
|
|
2694
|
+
return { x: t, y: e + Ye };
|
|
2695
|
+
case "top":
|
|
2696
|
+
return { x: t, y: e - Ye };
|
|
2697
|
+
default:
|
|
2698
|
+
return { x: t + Ye, y: e };
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
const tr = Zt(function({
|
|
2702
|
+
id: e,
|
|
2703
|
+
sourceX: n,
|
|
2704
|
+
sourceY: r,
|
|
2705
|
+
targetX: s,
|
|
2706
|
+
targetY: o,
|
|
2707
|
+
sourcePosition: i = "bottom",
|
|
2708
|
+
targetPosition: c = "top",
|
|
2709
|
+
label: u,
|
|
2710
|
+
labelStyle: l,
|
|
2711
|
+
labelShowBg: g,
|
|
2712
|
+
labelBgStyle: v,
|
|
2713
|
+
labelBgPadding: E,
|
|
2714
|
+
labelBgBorderRadius: R,
|
|
2715
|
+
style: M,
|
|
2716
|
+
markerEnd: T,
|
|
2717
|
+
markerStart: k,
|
|
2718
|
+
interactionWidth: z
|
|
2719
|
+
}) {
|
|
2720
|
+
let W, D, x;
|
|
2721
|
+
const f = _n(n, r, i), p = _n(s, o, c), y = Math.abs(p.x - f.x), N = Math.max(50, y * 0.5);
|
|
2722
|
+
let C, P, b, L;
|
|
2723
|
+
switch (i) {
|
|
2724
|
+
case "left":
|
|
2725
|
+
C = f.x - N, P = f.y;
|
|
2726
|
+
break;
|
|
2727
|
+
case "top":
|
|
2728
|
+
C = f.x, P = f.y - N;
|
|
2729
|
+
break;
|
|
2730
|
+
case "bottom":
|
|
2731
|
+
C = f.x, P = f.y + N;
|
|
2732
|
+
break;
|
|
2733
|
+
default:
|
|
2734
|
+
C = f.x + N, P = f.y;
|
|
2735
|
+
break;
|
|
2736
|
+
}
|
|
2737
|
+
switch (c) {
|
|
2738
|
+
case "right":
|
|
2739
|
+
b = p.x + N, L = p.y;
|
|
2740
|
+
break;
|
|
2741
|
+
case "top":
|
|
2742
|
+
b = p.x, L = p.y - N;
|
|
2743
|
+
break;
|
|
2744
|
+
case "bottom":
|
|
2745
|
+
b = p.x, L = p.y + N;
|
|
2746
|
+
break;
|
|
2747
|
+
default:
|
|
2748
|
+
b = p.x - N, L = p.y;
|
|
2749
|
+
break;
|
|
2750
|
+
}
|
|
2751
|
+
W = `M ${n},${r} L ${f.x},${f.y} C ${C},${P} ${b},${L} ${p.x},${p.y} L ${s},${o}`;
|
|
2752
|
+
const Y = 0.5, H = 0.5;
|
|
2753
|
+
return D = H * H * H * f.x + 3 * H * H * Y * C + 3 * H * Y * Y * b + Y * Y * Y * p.x, x = H * H * H * f.y + 3 * H * H * Y * P + 3 * H * Y * Y * L + Y * Y * Y * p.y, /* @__PURE__ */ B(
|
|
2754
|
+
un,
|
|
2755
|
+
{
|
|
2756
|
+
id: e,
|
|
2757
|
+
path: W,
|
|
2758
|
+
labelX: D,
|
|
2759
|
+
labelY: x,
|
|
2760
|
+
label: u,
|
|
2761
|
+
labelStyle: l,
|
|
2762
|
+
labelShowBg: g,
|
|
2763
|
+
labelBgStyle: v,
|
|
2764
|
+
labelBgPadding: E,
|
|
2765
|
+
labelBgBorderRadius: R,
|
|
2766
|
+
style: M,
|
|
2767
|
+
markerEnd: T,
|
|
2768
|
+
markerStart: k,
|
|
2769
|
+
interactionWidth: z
|
|
2770
|
+
}
|
|
2771
|
+
);
|
|
2772
|
+
});
|
|
2773
|
+
tr.displayName = "BezierEdge";
|
|
2774
|
+
function er({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2775
|
+
const s = `M ${t},${e}L ${n},${r}`, o = (t + n) / 2, i = (e + r) / 2;
|
|
2776
|
+
return [s, o, i, 0, 0];
|
|
2777
|
+
}
|
|
2778
|
+
function nr({
|
|
2779
|
+
sourceX: t,
|
|
2780
|
+
sourceY: e,
|
|
2781
|
+
targetX: n,
|
|
2782
|
+
targetY: r,
|
|
2783
|
+
sourcePosition: s = "right",
|
|
2784
|
+
targetPosition: o = "left",
|
|
2785
|
+
curvature: i = 0.25
|
|
2786
|
+
}) {
|
|
2787
|
+
const c = Math.abs(n - t), u = Math.abs(r - e), l = Math.sqrt(c * c + u * u), g = Math.max(l * i, 50);
|
|
2788
|
+
let v, E, R, M;
|
|
2789
|
+
switch (s) {
|
|
2790
|
+
case "top":
|
|
2791
|
+
v = t, E = e - g;
|
|
2792
|
+
break;
|
|
2793
|
+
case "bottom":
|
|
2794
|
+
v = t, E = e + g;
|
|
2795
|
+
break;
|
|
2796
|
+
case "left":
|
|
2797
|
+
v = t - g, E = e;
|
|
2798
|
+
break;
|
|
2799
|
+
default:
|
|
2800
|
+
v = t + g, E = e;
|
|
2801
|
+
break;
|
|
2802
|
+
}
|
|
2803
|
+
switch (o) {
|
|
2804
|
+
case "top":
|
|
2805
|
+
R = n, M = r - g;
|
|
2806
|
+
break;
|
|
2807
|
+
case "bottom":
|
|
2808
|
+
R = n, M = r + g;
|
|
2809
|
+
break;
|
|
2810
|
+
case "right":
|
|
2811
|
+
R = n + g, M = r;
|
|
2812
|
+
break;
|
|
2813
|
+
default:
|
|
2814
|
+
R = n - g, M = r;
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
const T = `M ${t},${e} C ${v},${E} ${R},${M} ${n},${r}`, k = 0.5, z = 1 - k, W = z * z * z * t + 3 * z * z * k * v + 3 * z * k * k * R + k * k * k * n, D = z * z * z * e + 3 * z * z * k * E + 3 * z * k * k * M + k * k * k * r;
|
|
2818
|
+
return [T, W, D, 0, 0];
|
|
2819
|
+
}
|
|
2820
|
+
function rr({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2821
|
+
const s = Math.abs(n - t), o = Math.max(s * 0.5, 50), i = t + o, c = n - o, u = `M ${t},${e} C ${i},${e} ${c},${r} ${n},${r}`, l = 0.5, g = 0.5, v = g * g * g * t + 3 * g * g * l * i + 3 * g * l * l * c + l * l * l * n, E = g * g * g * e + 3 * g * g * l * e + 3 * g * l * l * r + l * l * l * r;
|
|
2822
|
+
return [u, v, E, 0, 0];
|
|
2823
|
+
}
|
|
2824
|
+
function kn({
|
|
2825
|
+
sourceX: t,
|
|
2826
|
+
sourceY: e,
|
|
2827
|
+
targetX: n,
|
|
2828
|
+
targetY: r,
|
|
2829
|
+
sourcePosition: s = "right",
|
|
2830
|
+
targetPosition: o = "left",
|
|
2831
|
+
borderRadius: i = 5,
|
|
2832
|
+
offset: c = 20
|
|
2833
|
+
}) {
|
|
2834
|
+
const u = s === "left" || s === "right", l = Math.min(i, Math.abs(n - t) / 2, Math.abs(r - e) / 2);
|
|
2835
|
+
if (u) {
|
|
2836
|
+
if (Math.abs(r - e) < 1)
|
|
2837
|
+
return [`M ${t},${e} L ${n},${r}`, (t + n) / 2, e, 0, 0];
|
|
2838
|
+
const R = (t + n) / 2, M = r > e ? 1 : -1;
|
|
2839
|
+
return [`M ${t},${e} L ${R - l},${e} Q ${R},${e} ${R},${e + M * l} L ${R},${r - M * l} Q ${R},${r} ${R + (n > R ? l : -l)},${r} L ${n},${r}`, R, (e + r) / 2, 0, 0];
|
|
2840
|
+
}
|
|
2841
|
+
const g = (e + r) / 2, v = n > t ? 1 : -1;
|
|
2842
|
+
return [`M ${t},${e} L ${t},${g - l} Q ${t},${g} ${t + v * l},${g} L ${n - v * l},${g} Q ${n},${g} ${n},${g + (r > g ? l : -l)} L ${n},${r}`, (t + n) / 2, g, 0, 0];
|
|
2843
|
+
}
|
|
2844
|
+
function zo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2845
|
+
const [, s, o] = nr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
2846
|
+
return [s, o, 0, 0];
|
|
2847
|
+
}
|
|
2848
|
+
function Eo({ sourceX: t, sourceY: e, targetX: n, targetY: r }) {
|
|
2849
|
+
return [(t + n) / 2, (e + r) / 2, 0, 0];
|
|
2850
|
+
}
|
|
2851
|
+
function Co(t, e, n) {
|
|
2852
|
+
const r = n.filter((o) => o.id !== t.id), s = {
|
|
2853
|
+
...t,
|
|
2854
|
+
id: t.id,
|
|
2855
|
+
source: e.source,
|
|
2856
|
+
target: e.target,
|
|
2857
|
+
sourceHandle: e.sourceHandle ?? t.sourceHandle,
|
|
2858
|
+
targetHandle: e.targetHandle ?? t.targetHandle
|
|
2859
|
+
};
|
|
2860
|
+
return r.push(s), r;
|
|
2861
|
+
}
|
|
2862
|
+
const sn = 160, an = 60, Ue = 20, nn = 12, cn = 20;
|
|
2863
|
+
function Wn(t, e, n) {
|
|
2864
|
+
var i, c;
|
|
2865
|
+
const r = t.width || ((i = t.measured) == null ? void 0 : i.width) || sn, s = t.height || ((c = t.measured) == null ? void 0 : c.height) || an, o = t._absolutePosition || t.position;
|
|
2866
|
+
if (t.handles && t.handles.length > 0) {
|
|
2867
|
+
for (const u of t.handles)
|
|
2868
|
+
if (u.type === e && (!n || u.id === n)) {
|
|
2869
|
+
if (u.x !== void 0 && u.y !== void 0)
|
|
2870
|
+
return { x: o.x + u.x, y: o.y + u.y, dir: u.position || (e === "source" ? "right" : "left") };
|
|
2871
|
+
switch (u.position || (e === "source" ? "right" : "left")) {
|
|
2872
|
+
case "top":
|
|
2873
|
+
return { x: o.x + r / 2, y: o.y, dir: "top" };
|
|
2874
|
+
case "bottom":
|
|
2875
|
+
return { x: o.x + r / 2, y: o.y + s, dir: "bottom" };
|
|
2876
|
+
case "left":
|
|
2877
|
+
return { x: o.x, y: o.y + s / 2, dir: "left" };
|
|
2878
|
+
default:
|
|
2879
|
+
return { x: o.x + r, y: o.y + s / 2, dir: "right" };
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
return e === "source" ? { x: o.x + r, y: o.y + s / 2, dir: "right" } : { x: o.x, y: o.y + s / 2, dir: "left" };
|
|
2884
|
+
}
|
|
2885
|
+
function ln(t, e) {
|
|
2886
|
+
switch (t.dir) {
|
|
2887
|
+
case "right":
|
|
2888
|
+
return { x: t.x + e, y: t.y, dir: t.dir };
|
|
2889
|
+
case "left":
|
|
2890
|
+
return { x: t.x - e, y: t.y, dir: t.dir };
|
|
2891
|
+
case "bottom":
|
|
2892
|
+
return { x: t.x, y: t.y + e, dir: t.dir };
|
|
2893
|
+
case "top":
|
|
2894
|
+
return { x: t.x, y: t.y - e, dir: t.dir };
|
|
2895
|
+
default:
|
|
2896
|
+
return { x: t.x + e, y: t.y, dir: t.dir };
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
function Yr(t, e, n, r, s, o, i, c) {
|
|
2900
|
+
const u = Math.min(t, n), l = Math.max(t, n), g = Math.min(e, r), v = Math.max(e, r);
|
|
2901
|
+
if (l <= s || u >= s + i || v <= o || g >= o + c) return !1;
|
|
2902
|
+
const E = 0.5;
|
|
2903
|
+
if (t > s + E && t < s + i - E && e > o + E && e < o + c - E || n > s + E && n < s + i - E && r > o + E && r < o + c - E) return !0;
|
|
2904
|
+
const R = (t + n) / 2, M = (e + r) / 2;
|
|
2905
|
+
if (R > s + E && R < s + i - E && M > o + E && M < o + c - E) return !0;
|
|
2906
|
+
const T = [[s, o], [s + i, o], [s + i, o + c], [s, o + c]];
|
|
2907
|
+
for (let k = 0; k < 4; k++)
|
|
2908
|
+
if (Ur(t, e, n, r, T[k][0], T[k][1], T[(k + 1) % 4][0], T[(k + 1) % 4][1])) return !0;
|
|
2909
|
+
return !1;
|
|
2910
|
+
}
|
|
2911
|
+
function Ur(t, e, n, r, s, o, i, c) {
|
|
2912
|
+
const u = (i - s) * (e - o) - (c - o) * (t - s), l = (i - s) * (r - o) - (c - o) * (n - s), g = (n - t) * (o - e) - (r - e) * (s - t), v = (n - t) * (c - e) - (r - e) * (i - t);
|
|
2913
|
+
return (u > 0 && l < 0 || u < 0 && l > 0) && (g > 0 && v < 0 || g < 0 && v > 0);
|
|
2914
|
+
}
|
|
2915
|
+
function zn(t, e, n, r, s) {
|
|
2916
|
+
for (let o = 0; o < s.length; o++) {
|
|
2917
|
+
const i = s[o];
|
|
2918
|
+
if (Yr(t, e, n, r, i.x, i.y, i.w, i.h)) return !1;
|
|
2919
|
+
}
|
|
2920
|
+
return !0;
|
|
2921
|
+
}
|
|
2922
|
+
function qr(t, e, n) {
|
|
2923
|
+
for (let r = 0; r < n.length; r++) {
|
|
2924
|
+
const s = n[r];
|
|
2925
|
+
if (t > s.x && t < s.x + s.w && e > s.y && e < s.y + s.h) return !0;
|
|
2926
|
+
}
|
|
2927
|
+
return !1;
|
|
2928
|
+
}
|
|
2929
|
+
function or(t, e) {
|
|
2930
|
+
var r, s;
|
|
2931
|
+
const n = [];
|
|
2932
|
+
for (let o = 0; o < t.length; o++) {
|
|
2933
|
+
const i = t[o];
|
|
2934
|
+
if (i.hidden || e && e.has(i.id) || i.type === "group") continue;
|
|
2935
|
+
const c = i._absolutePosition || i.position, u = i.width || ((r = i.measured) == null ? void 0 : r.width) || sn, l = i.height || ((s = i.measured) == null ? void 0 : s.height) || an;
|
|
2936
|
+
n.push({
|
|
2937
|
+
id: i.id,
|
|
2938
|
+
x: c.x - Ue,
|
|
2939
|
+
y: c.y - Ue,
|
|
2940
|
+
w: u + 2 * Ue,
|
|
2941
|
+
h: l + 2 * Ue
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2944
|
+
return n;
|
|
2945
|
+
}
|
|
2946
|
+
function sr(t, e, n) {
|
|
2947
|
+
if (zn(t.x, t.y, e.x, e.y, n))
|
|
2948
|
+
return null;
|
|
2949
|
+
const r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
2950
|
+
r.add(t.x), r.add(e.x), s.add(t.y), s.add(e.y);
|
|
2951
|
+
const o = Ue + 5;
|
|
2952
|
+
t.dir === "right" ? r.add(t.x + o) : t.dir === "left" ? r.add(t.x - o) : t.dir === "top" ? s.add(t.y - o) : t.dir === "bottom" && s.add(t.y + o), e.dir === "right" ? r.add(e.x + o) : e.dir === "left" ? r.add(e.x - o) : e.dir === "top" ? s.add(e.y - o) : e.dir === "bottom" && s.add(e.y + o);
|
|
2953
|
+
for (let b = 0; b < n.length; b++) {
|
|
2954
|
+
const L = n[b];
|
|
2955
|
+
r.add(L.x), r.add(L.x + L.w), s.add(L.y), s.add(L.y + L.h);
|
|
2956
|
+
}
|
|
2957
|
+
const i = [...r].sort((b, L) => b - L), c = [...s].sort((b, L) => b - L), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2958
|
+
for (let b = 0; b < i.length; b++) u.set(i[b], b);
|
|
2959
|
+
for (let b = 0; b < c.length; b++) l.set(c[b], b);
|
|
2960
|
+
const g = i.length, v = c.length, E = (b, L) => L * g + b, R = u.get(t.x), M = l.get(t.y), T = u.get(e.x), k = l.get(e.y);
|
|
2961
|
+
if (R === void 0 || M === void 0 || T === void 0 || k === void 0) return null;
|
|
2962
|
+
const z = E(R, M), W = E(T, k), D = new Float64Array(g * v).fill(1 / 0), x = new Float64Array(g * v).fill(1 / 0), f = new Int32Array(g * v).fill(-1), p = new Int8Array(g * v).fill(-1), y = new Uint8Array(g * v);
|
|
2963
|
+
D[z] = 0, x[z] = Math.abs(i[T] - t.x) + Math.abs(c[k] - t.y);
|
|
2964
|
+
const N = [z], C = 15, P = [[1, 0], [-1, 0], [0, 1], [0, -1]];
|
|
2965
|
+
for (; N.length > 0; ) {
|
|
2966
|
+
let b = 0;
|
|
2967
|
+
for (let G = 1; G < N.length; G++)
|
|
2968
|
+
x[N[G]] < x[N[b]] && (b = G);
|
|
2969
|
+
const L = N[b];
|
|
2970
|
+
if (N[b] = N[N.length - 1], N.pop(), L === W) {
|
|
2971
|
+
const G = [];
|
|
2972
|
+
let j = W;
|
|
2973
|
+
for (; j !== -1 && j !== z; ) {
|
|
2974
|
+
const rt = j / g | 0, at = j % g;
|
|
2975
|
+
G.unshift({ x: i[at], y: c[rt] }), j = f[j];
|
|
2976
|
+
}
|
|
2977
|
+
return G.unshift({ x: t.x, y: t.y }), jr(G, n);
|
|
2978
|
+
}
|
|
2979
|
+
if (y[L]) continue;
|
|
2980
|
+
y[L] = 1;
|
|
2981
|
+
const Y = L / g | 0, H = L % g, dt = i[H], yt = c[Y], ft = p[L];
|
|
2982
|
+
for (let G = 0; G < 4; G++) {
|
|
2983
|
+
const j = H + P[G][0], rt = Y + P[G][1];
|
|
2984
|
+
if (j < 0 || j >= g || rt < 0 || rt >= v) continue;
|
|
2985
|
+
const at = E(j, rt);
|
|
2986
|
+
if (y[at]) continue;
|
|
2987
|
+
const ct = i[j], lt = c[rt];
|
|
2988
|
+
if (qr(ct, lt, n) || !zn(dt, yt, ct, lt, n)) continue;
|
|
2989
|
+
const Ct = Math.abs(ct - dt) + Math.abs(lt - yt), et = ft >= 0 && ft !== G ? C : 0, ot = D[L] + Ct + et;
|
|
2990
|
+
ot < D[at] && (f[at] = L, p[at] = G, D[at] = ot, x[at] = ot + Math.abs(i[T] - ct) + Math.abs(c[k] - lt), N.push(at));
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
return null;
|
|
2994
|
+
}
|
|
2995
|
+
function jr(t, e) {
|
|
2996
|
+
if (!t || t.length <= 2) return t;
|
|
2997
|
+
const n = [t[0]];
|
|
2998
|
+
for (let r = 1; r < t.length - 1; r++) {
|
|
2999
|
+
const s = n[n.length - 1], o = t[r], i = t[r + 1], c = Math.abs(s.x - o.x) < 0.5 && Math.abs(o.x - i.x) < 0.5, u = Math.abs(s.y - o.y) < 0.5 && Math.abs(o.y - i.y) < 0.5;
|
|
3000
|
+
(c || u) && zn(s.x, s.y, i.x, i.y, e) || n.push(o);
|
|
3001
|
+
}
|
|
3002
|
+
return n.push(t[t.length - 1]), n;
|
|
3003
|
+
}
|
|
3004
|
+
function Gr(t) {
|
|
3005
|
+
const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
3006
|
+
for (const s of t) {
|
|
3007
|
+
const o = s._routedPoints;
|
|
3008
|
+
if (!(!o || o.length < 2))
|
|
3009
|
+
for (let i = 0; i < o.length - 1; i++) {
|
|
3010
|
+
const c = o[i], u = o[i + 1];
|
|
3011
|
+
if (Math.abs(c.y - u.y) < 0.5) {
|
|
3012
|
+
const l = Math.round(c.y * 10) / 10;
|
|
3013
|
+
e.has(l) || e.set(l, []), e.get(l).push({ edgeId: s.id, segIdx: i, x1: Math.min(c.x, u.x), x2: Math.max(c.x, u.x) });
|
|
3014
|
+
} else if (Math.abs(c.x - u.x) < 0.5) {
|
|
3015
|
+
const l = Math.round(c.x * 10) / 10;
|
|
3016
|
+
n.has(l) || n.set(l, []), n.get(l).push({ edgeId: s.id, segIdx: i, y1: Math.min(c.y, u.y), y2: Math.max(c.y, u.y) });
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
const r = /* @__PURE__ */ new Map();
|
|
3021
|
+
for (const s of t)
|
|
3022
|
+
s._routedPoints && r.set(s.id, s._routedPoints.map((o) => ({ ...o })));
|
|
3023
|
+
for (const [, s] of e) {
|
|
3024
|
+
if (s.length < 2) continue;
|
|
3025
|
+
const o = Xn(s, "x1", "x2");
|
|
3026
|
+
for (const i of o) {
|
|
3027
|
+
if (i.length < 2) continue;
|
|
3028
|
+
const c = (i.length - 1) * nn / 2;
|
|
3029
|
+
for (let u = 0; u < i.length; u++) {
|
|
3030
|
+
const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
|
|
3031
|
+
v && (v[l.segIdx].y += g, v[l.segIdx + 1].y += g);
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
for (const [, s] of n) {
|
|
3036
|
+
if (s.length < 2) continue;
|
|
3037
|
+
const o = Xn(s, "y1", "y2");
|
|
3038
|
+
for (const i of o) {
|
|
3039
|
+
if (i.length < 2) continue;
|
|
3040
|
+
const c = (i.length - 1) * nn / 2;
|
|
3041
|
+
for (let u = 0; u < i.length; u++) {
|
|
3042
|
+
const l = i[u], g = -c + u * nn, v = r.get(l.edgeId);
|
|
3043
|
+
v && (v[l.segIdx].x += g, v[l.segIdx + 1].x += g);
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
return t.map((s) => {
|
|
3048
|
+
const o = r.get(s.id);
|
|
3049
|
+
return o ? { ...s, _routedPoints: o } : s;
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
3052
|
+
function Xn(t, e, n) {
|
|
3053
|
+
if (t.length < 2) return [];
|
|
3054
|
+
const r = [...t].sort((i, c) => i[e] - c[e]), s = [];
|
|
3055
|
+
let o = [r[0]];
|
|
3056
|
+
for (let i = 1; i < r.length; i++) {
|
|
3057
|
+
const c = o[o.length - 1];
|
|
3058
|
+
r[i][e] < c[n] ? o.push(r[i]) : (o.length > 1 && s.push(o), o = [r[i]]);
|
|
3059
|
+
}
|
|
3060
|
+
return o.length > 1 && s.push(o), s;
|
|
3061
|
+
}
|
|
3062
|
+
function En(t, e = 6, n = !1) {
|
|
3063
|
+
if (!t || t.length < 2) return null;
|
|
3064
|
+
if (n) return Zr(t);
|
|
3065
|
+
const r = e;
|
|
3066
|
+
let s = `M ${t[0].x},${t[0].y}`;
|
|
3067
|
+
for (let o = 1; o < t.length - 1; o++) {
|
|
3068
|
+
const i = t[o - 1], c = t[o], u = t[o + 1], l = Math.abs(c.x - i.x) + Math.abs(c.y - i.y), g = Math.abs(u.x - c.x) + Math.abs(u.y - c.y), v = Math.min(r, l / 2, g / 2);
|
|
3069
|
+
if (v > 0.5) {
|
|
3070
|
+
const E = c.x - i.x, R = c.y - i.y, M = u.x - c.x, T = u.y - c.y, k = Math.sqrt(E * E + R * R) || 1, z = Math.sqrt(M * M + T * T) || 1;
|
|
3071
|
+
s += ` L ${c.x - E / k * v},${c.y - R / k * v}`, s += ` Q ${c.x},${c.y} ${c.x + M / z * v},${c.y + T / z * v}`;
|
|
3072
|
+
} else
|
|
3073
|
+
s += ` L ${c.x},${c.y}`;
|
|
3074
|
+
}
|
|
3075
|
+
return s += ` L ${t[t.length - 1].x},${t[t.length - 1].y}`, s;
|
|
3076
|
+
}
|
|
3077
|
+
function Zr(t) {
|
|
3078
|
+
if (t.length === 2)
|
|
3079
|
+
return `M ${t[0].x},${t[0].y} L ${t[1].x},${t[1].y}`;
|
|
3080
|
+
if (t.length === 3)
|
|
3081
|
+
return `M ${t[0].x},${t[0].y} Q ${t[1].x},${t[1].y} ${t[2].x},${t[2].y}`;
|
|
3082
|
+
const e = 0.3;
|
|
3083
|
+
let n = `M ${t[0].x},${t[0].y}`;
|
|
3084
|
+
for (let r = 0; r < t.length - 1; r++) {
|
|
3085
|
+
const s = t[r === 0 ? 0 : r - 1], o = t[r], i = t[r + 1], c = t[r + 2 < t.length ? r + 2 : t.length - 1], u = o.x + (i.x - s.x) * e, l = o.y + (i.y - s.y) * e, g = i.x - (c.x - o.x) * e, v = i.y - (c.y - o.y) * e;
|
|
3086
|
+
n += ` C ${u},${l} ${g},${v} ${i.x},${i.y}`;
|
|
3087
|
+
}
|
|
3088
|
+
return n;
|
|
3089
|
+
}
|
|
3090
|
+
function Cn(t) {
|
|
3091
|
+
if (!t || t.length < 2) return { x: 0, y: 0 };
|
|
3092
|
+
let e = 0;
|
|
3093
|
+
for (let r = 1; r < t.length; r++)
|
|
3094
|
+
e += Math.abs(t[r].x - t[r - 1].x) + Math.abs(t[r].y - t[r - 1].y);
|
|
3095
|
+
let n = e / 2;
|
|
3096
|
+
for (let r = 1; r < t.length; r++) {
|
|
3097
|
+
const s = Math.abs(t[r].x - t[r - 1].x) + Math.abs(t[r].y - t[r - 1].y);
|
|
3098
|
+
if (n <= s) {
|
|
3099
|
+
const o = s > 0 ? n / s : 0;
|
|
3100
|
+
return {
|
|
3101
|
+
x: t[r - 1].x + (t[r].x - t[r - 1].x) * o,
|
|
3102
|
+
y: t[r - 1].y + (t[r].y - t[r - 1].y) * o
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
n -= s;
|
|
3106
|
+
}
|
|
3107
|
+
return { x: t[0].x, y: t[0].y };
|
|
3108
|
+
}
|
|
3109
|
+
function No(t, e) {
|
|
3110
|
+
if (!t || !e || t.length === 0 || e.length === 0) return e;
|
|
3111
|
+
const n = {};
|
|
3112
|
+
for (const o of t) n[o.id] = o;
|
|
3113
|
+
const r = or(t, null), s = e.map((o) => {
|
|
3114
|
+
var p, y, N, C;
|
|
3115
|
+
const i = o.type || "default";
|
|
3116
|
+
if (i === "bezier" || i === "simplebezier" || i === "default") return o;
|
|
3117
|
+
const c = n[o.source], u = n[o.target];
|
|
3118
|
+
if (!c || !u || c.hidden || u.hidden) return o;
|
|
3119
|
+
const l = Wn(c, "source", o.sourceHandle), g = Wn(u, "target", o.targetHandle), v = ln(l, cn), E = ln(g, cn), R = 5, M = r.filter((P) => P.id !== o.source && P.id !== o.target), T = c._absolutePosition || c.position, k = c.width || ((p = c.measured) == null ? void 0 : p.width) || sn, z = c.height || ((y = c.measured) == null ? void 0 : y.height) || an;
|
|
3120
|
+
M.push({ id: o.source, x: T.x - R, y: T.y - R, w: k + 2 * R, h: z + 2 * R });
|
|
3121
|
+
const W = u._absolutePosition || u.position, D = u.width || ((N = u.measured) == null ? void 0 : N.width) || sn, x = u.height || ((C = u.measured) == null ? void 0 : C.height) || an;
|
|
3122
|
+
if (M.push({ id: o.target, x: W.x - R, y: W.y - R, w: D + 2 * R, h: x + 2 * R }), M.length === 0) return o;
|
|
3123
|
+
const f = sr(v, E, M);
|
|
3124
|
+
return f && f.length >= 2 ? (f.unshift({ x: l.x, y: l.y }), f.push({ x: g.x, y: g.y }), { ...o, _routedPoints: f }) : o;
|
|
3125
|
+
});
|
|
3126
|
+
return Gr(s);
|
|
3127
|
+
}
|
|
3128
|
+
function Lo(t, e, n, r, s, o, i, c) {
|
|
3129
|
+
const u = or(i, c ? new Set(c) : null);
|
|
3130
|
+
if (u.length === 0) return null;
|
|
3131
|
+
const l = { x: t, y: e, dir: s || "right" }, g = { x: n, y: r, dir: o || "left" }, v = ln(l, cn), E = ln(g, cn), R = sr(v, E, u);
|
|
3132
|
+
return R && R.length >= 2 ? (R.unshift({ x: l.x, y: l.y }), R.push({ x: g.x, y: g.y }), R) : null;
|
|
3133
|
+
}
|
|
3134
|
+
const ir = Zt(function({
|
|
3135
|
+
id: e,
|
|
3136
|
+
sourceX: n,
|
|
3137
|
+
sourceY: r,
|
|
3138
|
+
targetX: s,
|
|
3139
|
+
targetY: o,
|
|
3140
|
+
label: i,
|
|
3141
|
+
labelStyle: c,
|
|
3142
|
+
labelShowBg: u,
|
|
3143
|
+
labelBgStyle: l,
|
|
3144
|
+
labelBgPadding: g,
|
|
3145
|
+
labelBgBorderRadius: v,
|
|
3146
|
+
style: E,
|
|
3147
|
+
markerEnd: R,
|
|
3148
|
+
markerStart: M,
|
|
3149
|
+
interactionWidth: T,
|
|
3150
|
+
routedPoints: k
|
|
3151
|
+
}) {
|
|
3152
|
+
let z, W, D;
|
|
3153
|
+
if (k && k.length >= 2) {
|
|
3154
|
+
z = En(k);
|
|
3155
|
+
const x = Cn(k);
|
|
3156
|
+
W = x.x, D = x.y;
|
|
3157
|
+
} else
|
|
3158
|
+
[z, W, D] = er({ sourceX: n, sourceY: r, targetX: s, targetY: o });
|
|
3159
|
+
return /* @__PURE__ */ B(
|
|
3160
|
+
un,
|
|
3161
|
+
{
|
|
3162
|
+
id: e,
|
|
3163
|
+
path: z,
|
|
3164
|
+
labelX: W,
|
|
3165
|
+
labelY: D,
|
|
3166
|
+
label: i,
|
|
3167
|
+
labelStyle: c,
|
|
3168
|
+
labelShowBg: u,
|
|
3169
|
+
labelBgStyle: l,
|
|
3170
|
+
labelBgPadding: g,
|
|
3171
|
+
labelBgBorderRadius: v,
|
|
3172
|
+
style: E,
|
|
3173
|
+
markerEnd: R,
|
|
3174
|
+
markerStart: M,
|
|
3175
|
+
interactionWidth: T
|
|
3176
|
+
}
|
|
3177
|
+
);
|
|
3178
|
+
});
|
|
3179
|
+
ir.displayName = "StraightEdge";
|
|
3180
|
+
const ar = Zt(function({
|
|
3181
|
+
id: e,
|
|
3182
|
+
sourceX: n,
|
|
3183
|
+
sourceY: r,
|
|
3184
|
+
targetX: s,
|
|
3185
|
+
targetY: o,
|
|
3186
|
+
sourcePosition: i = "bottom",
|
|
3187
|
+
targetPosition: c = "top",
|
|
3188
|
+
label: u,
|
|
3189
|
+
labelStyle: l,
|
|
3190
|
+
labelShowBg: g,
|
|
3191
|
+
labelBgStyle: v,
|
|
3192
|
+
labelBgPadding: E,
|
|
3193
|
+
labelBgBorderRadius: R,
|
|
3194
|
+
style: M,
|
|
3195
|
+
markerEnd: T,
|
|
3196
|
+
markerStart: k,
|
|
3197
|
+
pathOptions: z,
|
|
3198
|
+
interactionWidth: W,
|
|
3199
|
+
routedPoints: D
|
|
3200
|
+
}) {
|
|
3201
|
+
let x, f, p;
|
|
3202
|
+
if (D && D.length >= 2) {
|
|
3203
|
+
x = En(D);
|
|
3204
|
+
const y = Cn(D);
|
|
3205
|
+
f = y.x, p = y.y;
|
|
3206
|
+
} else
|
|
3207
|
+
[x, f, p] = kn({
|
|
3208
|
+
sourceX: n,
|
|
3209
|
+
sourceY: r,
|
|
3210
|
+
sourcePosition: i,
|
|
3211
|
+
targetX: s,
|
|
3212
|
+
targetY: o,
|
|
3213
|
+
targetPosition: c,
|
|
3214
|
+
borderRadius: z == null ? void 0 : z.borderRadius,
|
|
3215
|
+
offset: z == null ? void 0 : z.offset
|
|
3216
|
+
});
|
|
3217
|
+
return /* @__PURE__ */ B(
|
|
3218
|
+
un,
|
|
3219
|
+
{
|
|
3220
|
+
id: e,
|
|
3221
|
+
path: x,
|
|
3222
|
+
labelX: f,
|
|
3223
|
+
labelY: p,
|
|
3224
|
+
label: u,
|
|
3225
|
+
labelStyle: l,
|
|
3226
|
+
labelShowBg: g,
|
|
3227
|
+
labelBgStyle: v,
|
|
3228
|
+
labelBgPadding: E,
|
|
3229
|
+
labelBgBorderRadius: R,
|
|
3230
|
+
style: M,
|
|
3231
|
+
markerEnd: T,
|
|
3232
|
+
markerStart: k,
|
|
3233
|
+
interactionWidth: W
|
|
3234
|
+
}
|
|
3235
|
+
);
|
|
3236
|
+
});
|
|
3237
|
+
ar.displayName = "SmoothStepEdge";
|
|
3238
|
+
const Qr = Zt(function({ id: e, ...n }) {
|
|
3239
|
+
var s;
|
|
3240
|
+
const r = St(
|
|
3241
|
+
() => {
|
|
3242
|
+
var o;
|
|
3243
|
+
return { borderRadius: 0, offset: (o = n.pathOptions) == null ? void 0 : o.offset };
|
|
3244
|
+
},
|
|
3245
|
+
[(s = n.pathOptions) == null ? void 0 : s.offset]
|
|
3246
|
+
);
|
|
3247
|
+
return /* @__PURE__ */ B(ar, { ...n, id: e, pathOptions: r });
|
|
3248
|
+
});
|
|
3249
|
+
Qr.displayName = "StepEdge";
|
|
3250
|
+
const cr = Zt(function({
|
|
3251
|
+
id: e,
|
|
3252
|
+
sourceX: n,
|
|
3253
|
+
sourceY: r,
|
|
3254
|
+
targetX: s,
|
|
3255
|
+
targetY: o,
|
|
3256
|
+
sourcePosition: i,
|
|
3257
|
+
targetPosition: c,
|
|
3258
|
+
label: u,
|
|
3259
|
+
labelStyle: l,
|
|
3260
|
+
labelShowBg: g,
|
|
3261
|
+
labelBgStyle: v,
|
|
3262
|
+
labelBgPadding: E,
|
|
3263
|
+
labelBgBorderRadius: R,
|
|
3264
|
+
style: M,
|
|
3265
|
+
markerEnd: T,
|
|
3266
|
+
markerStart: k,
|
|
3267
|
+
interactionWidth: z,
|
|
3268
|
+
routedPoints: W
|
|
3269
|
+
}) {
|
|
3270
|
+
let D, x, f;
|
|
3271
|
+
if (W && W.length >= 2) {
|
|
3272
|
+
D = En(W);
|
|
3273
|
+
const p = Cn(W);
|
|
3274
|
+
x = p.x, f = p.y;
|
|
3275
|
+
} else
|
|
3276
|
+
[D, x, f] = rr({
|
|
3277
|
+
sourceX: n,
|
|
3278
|
+
sourceY: r,
|
|
3279
|
+
targetX: s,
|
|
3280
|
+
targetY: o
|
|
3281
|
+
});
|
|
3282
|
+
return /* @__PURE__ */ B(
|
|
3283
|
+
un,
|
|
3284
|
+
{
|
|
3285
|
+
id: e,
|
|
3286
|
+
path: D,
|
|
3287
|
+
labelX: x,
|
|
3288
|
+
labelY: f,
|
|
3289
|
+
label: u,
|
|
3290
|
+
labelStyle: l,
|
|
3291
|
+
labelShowBg: g,
|
|
3292
|
+
labelBgStyle: v,
|
|
3293
|
+
labelBgPadding: E,
|
|
3294
|
+
labelBgBorderRadius: R,
|
|
3295
|
+
style: M,
|
|
3296
|
+
markerEnd: T,
|
|
3297
|
+
markerStart: k,
|
|
3298
|
+
interactionWidth: z
|
|
3299
|
+
}
|
|
3300
|
+
);
|
|
3301
|
+
});
|
|
3302
|
+
cr.displayName = "SimpleBezierEdge";
|
|
3303
|
+
const Kr = {
|
|
3304
|
+
input: _r,
|
|
3305
|
+
output: Wr,
|
|
3306
|
+
group: Xr
|
|
3307
|
+
}, Or = {
|
|
3308
|
+
// smoothstep/step are handled by the canvas worker directly (not React SVG)
|
|
3309
|
+
bezier: tr,
|
|
3310
|
+
straight: ir,
|
|
3311
|
+
simplebezier: cr
|
|
3312
|
+
};
|
|
3313
|
+
function Io({
|
|
3314
|
+
// Data
|
|
3315
|
+
cards: t,
|
|
3316
|
+
nodes: e = [],
|
|
3317
|
+
edges: n = [],
|
|
3318
|
+
// Custom types
|
|
3319
|
+
nodeTypes: r,
|
|
3320
|
+
edgeTypes: s,
|
|
3321
|
+
// Appearance
|
|
3322
|
+
dark: o,
|
|
3323
|
+
gridSize: i,
|
|
3324
|
+
width: c = "100%",
|
|
3325
|
+
height: u = "420px",
|
|
3326
|
+
className: l = "",
|
|
3327
|
+
style: g = {},
|
|
3328
|
+
// Zoom/Camera
|
|
3329
|
+
zoomMin: v,
|
|
3330
|
+
zoomMax: E,
|
|
3331
|
+
initialCamera: R,
|
|
3332
|
+
fitView: M,
|
|
3333
|
+
fitViewOptions: T,
|
|
3334
|
+
// Node/Edge callbacks
|
|
3335
|
+
onNodesChange: k,
|
|
3336
|
+
onEdgesChange: z,
|
|
3337
|
+
onConnect: W,
|
|
3338
|
+
onConnectStart: D,
|
|
3339
|
+
onConnectEnd: x,
|
|
3340
|
+
onNodeClick: f,
|
|
3341
|
+
onNodeDoubleClick: p,
|
|
3342
|
+
onNodeMouseEnter: y,
|
|
3343
|
+
onNodeMouseMove: N,
|
|
3344
|
+
onNodeMouseLeave: C,
|
|
3345
|
+
onNodeContextMenu: P,
|
|
3346
|
+
onNodeDragStart: b,
|
|
3347
|
+
onNodeDrag: L,
|
|
3348
|
+
onNodeDragStop: Y,
|
|
3349
|
+
onEdgeClick: H,
|
|
3350
|
+
onEdgeDoubleClick: dt,
|
|
3351
|
+
onEdgeMouseEnter: yt,
|
|
3352
|
+
onEdgeMouseMove: ft,
|
|
3353
|
+
onEdgeMouseLeave: G,
|
|
3354
|
+
onEdgeContextMenu: j,
|
|
3355
|
+
onPaneClick: rt,
|
|
3356
|
+
onPaneContextMenu: at,
|
|
3357
|
+
onPaneMouseEnter: ct,
|
|
3358
|
+
onPaneMouseMove: lt,
|
|
3359
|
+
onPaneMouseLeave: Ct,
|
|
3360
|
+
onSelectionChange: et,
|
|
3361
|
+
onInit: ot,
|
|
3362
|
+
onMoveStart: Nt,
|
|
3363
|
+
onMove: Rt,
|
|
3364
|
+
onMoveEnd: vt,
|
|
3365
|
+
onDelete: Lt,
|
|
3366
|
+
onBeforeDelete: kt,
|
|
3367
|
+
onError: $t,
|
|
3368
|
+
// Drag and drop
|
|
3369
|
+
onDragOver: mt,
|
|
3370
|
+
onDrop: ne,
|
|
3371
|
+
onDragEnter: Ie,
|
|
3372
|
+
onDragLeave: Bt,
|
|
3373
|
+
// Behavior
|
|
3374
|
+
nodesDraggable: Qt,
|
|
3375
|
+
nodesConnectable: Yt,
|
|
3376
|
+
elementsSelectable: me,
|
|
3377
|
+
multiSelectionKeyCode: de,
|
|
3378
|
+
selectionOnDrag: ve,
|
|
3379
|
+
selectionMode: we,
|
|
3380
|
+
connectionMode: Ge,
|
|
3381
|
+
connectionRadius: $e,
|
|
3382
|
+
connectOnClick: Ze,
|
|
3383
|
+
isValidConnection: Qe,
|
|
3384
|
+
defaultEdgeOptions: Ke,
|
|
3385
|
+
snapToGrid: Oe,
|
|
3386
|
+
snapGrid: Pe,
|
|
3387
|
+
deleteKeyCode: re,
|
|
3388
|
+
panActivationKeyCode: oe,
|
|
3389
|
+
panOnScroll: be,
|
|
3390
|
+
panOnScrollMode: dn,
|
|
3391
|
+
panOnScrollSpeed: fn,
|
|
3392
|
+
zoomOnScroll: Kt,
|
|
3393
|
+
zoomOnDoubleClick: Nn,
|
|
3394
|
+
zoomOnPinch: hn,
|
|
3395
|
+
preventScrolling: fe,
|
|
3396
|
+
translateExtent: pt,
|
|
3397
|
+
nodeExtent: Te,
|
|
3398
|
+
autoPanOnNodeDrag: zt,
|
|
3399
|
+
autoPanOnConnect: gt,
|
|
3400
|
+
autoPanSpeed: se,
|
|
3401
|
+
edgesReconnectable: Z,
|
|
3402
|
+
elevateNodesOnSelect: Pt,
|
|
3403
|
+
elevateEdgesOnSelect: yn,
|
|
3404
|
+
// Edge routing (obstacle avoidance)
|
|
3405
|
+
edgeRouting: Se = !0,
|
|
3406
|
+
// HUD
|
|
3407
|
+
onHudUpdate: te,
|
|
3408
|
+
onNodesProcessed: gn,
|
|
3409
|
+
showHud: pn = !0,
|
|
3410
|
+
showHint: _t = !0,
|
|
3411
|
+
hintText: Wt = "Drag to pan · Scroll to zoom",
|
|
3412
|
+
children: Me,
|
|
3413
|
+
...ie
|
|
3414
|
+
}) {
|
|
3415
|
+
const [Ut, Re] = Gt({ wx: 0, wy: 0, zoom: "1.00" }), Be = V(null), Je = V(null), Ve = F(
|
|
3416
|
+
(K) => {
|
|
3417
|
+
Re(K), te == null || te(K);
|
|
3418
|
+
},
|
|
3419
|
+
[te]
|
|
3420
|
+
), ae = St(() => ({ ...Kr, ...r }), [r]), Ot = St(() => ({ ...Or, ...s }), [s]), he = St(() => {
|
|
3421
|
+
const K = e.filter((Ft) => Ft.type && ae[Ft.type]);
|
|
3422
|
+
return K.sort((Ft, st) => {
|
|
3423
|
+
const Tt = Ft.type === "group" || !Ft.parentId && K.some((Ee) => Ee.parentId === Ft.id), xe = st.type === "group" || !st.parentId && K.some((Ee) => Ee.parentId === st.id);
|
|
3424
|
+
return Tt && !xe ? -1 : !Tt && xe ? 1 : 0;
|
|
3425
|
+
});
|
|
3426
|
+
}, [e, ae]), ke = St(() => n.filter((K) => K.type && Ot[K.type]), [n, Ot]), Q = St(() => e.map((K) => K.type && ae[K.type] ? { ...K, _customRendered: !0 } : K), [e, ae]), wt = St(() => n.map((K) => K.type && Ot[K.type] ? { ...K, _customRendered: !0 } : K), [n, Ot]), {
|
|
3427
|
+
wrapRef: Dt,
|
|
3428
|
+
canvasRef: ce,
|
|
3429
|
+
canvasReady: De,
|
|
3430
|
+
onPointerDown: He,
|
|
3431
|
+
onPointerMove: Ae,
|
|
3432
|
+
onPointerUp: _e,
|
|
3433
|
+
store: le
|
|
3434
|
+
} = Lr({
|
|
3435
|
+
cards: t,
|
|
3436
|
+
nodes: Q,
|
|
3437
|
+
edges: wt,
|
|
3438
|
+
dark: o,
|
|
3439
|
+
gridSize: i,
|
|
3440
|
+
zoomMin: v,
|
|
3441
|
+
zoomMax: E,
|
|
3442
|
+
initialCamera: R,
|
|
3443
|
+
fitView: M,
|
|
3444
|
+
fitViewOptions: T,
|
|
3445
|
+
onHudUpdate: Ve,
|
|
3446
|
+
onNodesProcessed: gn,
|
|
3447
|
+
onNodesChange: k,
|
|
3448
|
+
onEdgesChange: z,
|
|
3449
|
+
onConnect: W,
|
|
3450
|
+
onConnectStart: D,
|
|
3451
|
+
onConnectEnd: x,
|
|
3452
|
+
onNodeClick: f,
|
|
3453
|
+
onNodeDoubleClick: p,
|
|
3454
|
+
onNodeMouseEnter: y,
|
|
3455
|
+
onNodeMouseMove: N,
|
|
3456
|
+
onNodeMouseLeave: C,
|
|
3457
|
+
onNodeContextMenu: P,
|
|
3458
|
+
onNodeDragStart: b,
|
|
3459
|
+
onNodeDrag: L,
|
|
3460
|
+
onNodeDragStop: Y,
|
|
3461
|
+
onEdgeClick: H,
|
|
3462
|
+
onEdgeDoubleClick: dt,
|
|
3463
|
+
onEdgeMouseEnter: yt,
|
|
3464
|
+
onEdgeMouseMove: ft,
|
|
3465
|
+
onEdgeMouseLeave: G,
|
|
3466
|
+
onEdgeContextMenu: j,
|
|
3467
|
+
onPaneClick: rt,
|
|
3468
|
+
onPaneContextMenu: at,
|
|
3469
|
+
onPaneMouseEnter: ct,
|
|
3470
|
+
onPaneMouseMove: lt,
|
|
3471
|
+
onPaneMouseLeave: Ct,
|
|
3472
|
+
onSelectionChange: et,
|
|
3473
|
+
onInit: ot,
|
|
3474
|
+
onMoveStart: Nt,
|
|
3475
|
+
onMove: Rt,
|
|
3476
|
+
onMoveEnd: vt,
|
|
3477
|
+
onDelete: Lt,
|
|
3478
|
+
onBeforeDelete: kt,
|
|
3479
|
+
onError: $t,
|
|
3480
|
+
nodesDraggable: Qt,
|
|
3481
|
+
nodesConnectable: Yt,
|
|
3482
|
+
elementsSelectable: me,
|
|
3483
|
+
multiSelectionKeyCode: de,
|
|
3484
|
+
selectionOnDrag: ve,
|
|
3485
|
+
selectionMode: we,
|
|
3486
|
+
connectionMode: Ge,
|
|
3487
|
+
connectionRadius: $e,
|
|
3488
|
+
connectOnClick: Ze,
|
|
3489
|
+
isValidConnection: Qe,
|
|
3490
|
+
defaultEdgeOptions: Ke,
|
|
3491
|
+
snapToGrid: Oe,
|
|
3492
|
+
snapGrid: Pe,
|
|
3493
|
+
deleteKeyCode: re,
|
|
3494
|
+
panActivationKeyCode: oe,
|
|
3495
|
+
panOnScroll: be,
|
|
3496
|
+
panOnScrollMode: dn,
|
|
3497
|
+
panOnScrollSpeed: fn,
|
|
3498
|
+
zoomOnScroll: Kt,
|
|
3499
|
+
zoomOnDoubleClick: Nn,
|
|
3500
|
+
zoomOnPinch: hn,
|
|
3501
|
+
preventScrolling: fe,
|
|
3502
|
+
translateExtent: pt,
|
|
3503
|
+
nodeExtent: Te,
|
|
3504
|
+
autoPanOnNodeDrag: zt,
|
|
3505
|
+
autoPanOnConnect: gt,
|
|
3506
|
+
autoPanSpeed: se,
|
|
3507
|
+
edgesReconnectable: Z,
|
|
3508
|
+
elevateNodesOnSelect: Pt,
|
|
3509
|
+
edgeRouting: Se
|
|
3510
|
+
}), We = St(() => ({
|
|
3511
|
+
...le,
|
|
3512
|
+
edgeLabelContainerRef: Be,
|
|
3513
|
+
viewportPortalRef: Je,
|
|
3514
|
+
// Override nodes/edges getters to return ALL nodes (canvas + custom)
|
|
3515
|
+
get nodes() {
|
|
3516
|
+
return e;
|
|
3517
|
+
},
|
|
3518
|
+
get edges() {
|
|
3519
|
+
return n;
|
|
3520
|
+
}
|
|
3521
|
+
}), [le, e, n]), ye = V(null), ge = V(null), pe = V(null), Jt = V(null);
|
|
3522
|
+
ut(() => {
|
|
3523
|
+
let K;
|
|
3524
|
+
const Ft = () => {
|
|
3525
|
+
const st = le.cameraRef.current, Tt = `translate(${st.x}px, ${st.y}px) scale(${st.zoom})`, xe = `translate(${st.x}, ${st.y}) scale(${st.zoom})`;
|
|
3526
|
+
ye.current && (ye.current.style.transform = Tt), ge.current && ge.current.setAttribute("transform", xe), pe.current && (pe.current.style.transform = Tt), Jt.current && (Jt.current.style.transform = Tt), K = requestAnimationFrame(Ft);
|
|
3527
|
+
};
|
|
3528
|
+
return K = requestAnimationFrame(Ft), () => cancelAnimationFrame(K);
|
|
3529
|
+
}, [le]);
|
|
3530
|
+
const ze = he.length > 0, ee = ke.length > 0;
|
|
3531
|
+
return /* @__PURE__ */ B(Zn.Provider, { value: We, children: /* @__PURE__ */ It(
|
|
3532
|
+
"div",
|
|
3533
|
+
{
|
|
3534
|
+
ref: Dt,
|
|
3535
|
+
className: `ric-wrap ${l}`,
|
|
3536
|
+
style: { width: c, height: u, ...g },
|
|
3537
|
+
onPointerDown: He,
|
|
3538
|
+
onPointerMove: Ae,
|
|
3539
|
+
onPointerUp: _e,
|
|
3540
|
+
onDragOver: mt,
|
|
3541
|
+
onDrop: ne,
|
|
3542
|
+
onDragEnter: Ie,
|
|
3543
|
+
onDragLeave: Bt,
|
|
3544
|
+
tabIndex: 0,
|
|
3545
|
+
children: [
|
|
3546
|
+
/* @__PURE__ */ B("canvas", { ref: ce, className: "ric-canvas" }),
|
|
3547
|
+
!De && /* @__PURE__ */ B("div", { className: "ric-loader", children: /* @__PURE__ */ B("div", { className: "ric-spinner" }) }),
|
|
3548
|
+
ee && /* @__PURE__ */ B(
|
|
3549
|
+
"svg",
|
|
3550
|
+
{
|
|
3551
|
+
className: "ric-edges-overlay",
|
|
3552
|
+
style: {
|
|
3553
|
+
position: "absolute",
|
|
3554
|
+
top: 0,
|
|
3555
|
+
left: 0,
|
|
3556
|
+
width: "100%",
|
|
3557
|
+
height: "100%",
|
|
3558
|
+
pointerEvents: "none",
|
|
3559
|
+
overflow: "visible"
|
|
3560
|
+
},
|
|
3561
|
+
children: /* @__PURE__ */ B("g", { ref: ge, children: ke.map((K) => /* @__PURE__ */ B(
|
|
3562
|
+
Dr,
|
|
3563
|
+
{
|
|
3564
|
+
edge: K,
|
|
3565
|
+
edgeType: Ot[K.type],
|
|
3566
|
+
nodes: e,
|
|
3567
|
+
reconnectable: Z
|
|
3568
|
+
},
|
|
3569
|
+
K.id
|
|
3570
|
+
)) })
|
|
3571
|
+
}
|
|
3572
|
+
),
|
|
3573
|
+
ze && /* @__PURE__ */ B(
|
|
3574
|
+
"div",
|
|
3575
|
+
{
|
|
3576
|
+
ref: ye,
|
|
3577
|
+
className: "ric-nodes-overlay",
|
|
3578
|
+
style: {
|
|
3579
|
+
position: "absolute",
|
|
3580
|
+
top: 0,
|
|
3581
|
+
left: 0,
|
|
3582
|
+
width: 0,
|
|
3583
|
+
height: 0,
|
|
3584
|
+
transformOrigin: "0 0",
|
|
3585
|
+
pointerEvents: "none",
|
|
3586
|
+
zIndex: 10
|
|
3587
|
+
},
|
|
3588
|
+
children: he.map((K) => /* @__PURE__ */ B(
|
|
3589
|
+
Pr,
|
|
3590
|
+
{
|
|
3591
|
+
node: K,
|
|
3592
|
+
nodeType: ae[K.type]
|
|
3593
|
+
},
|
|
3594
|
+
K.id
|
|
3595
|
+
))
|
|
3596
|
+
}
|
|
3597
|
+
),
|
|
3598
|
+
/* @__PURE__ */ B(
|
|
3599
|
+
"div",
|
|
3600
|
+
{
|
|
3601
|
+
ref: (K) => {
|
|
3602
|
+
Be.current = K, pe.current = K;
|
|
3603
|
+
},
|
|
3604
|
+
className: "ric-edge-labels",
|
|
3605
|
+
style: {
|
|
3606
|
+
position: "absolute",
|
|
3607
|
+
top: 0,
|
|
3608
|
+
left: 0,
|
|
3609
|
+
width: 0,
|
|
3610
|
+
height: 0,
|
|
3611
|
+
transformOrigin: "0 0",
|
|
3612
|
+
pointerEvents: "none",
|
|
3613
|
+
zIndex: 5
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
),
|
|
3617
|
+
/* @__PURE__ */ B(
|
|
3618
|
+
"div",
|
|
3619
|
+
{
|
|
3620
|
+
ref: (K) => {
|
|
3621
|
+
Je.current = K, Jt.current = K;
|
|
3622
|
+
},
|
|
3623
|
+
className: "ric-viewport-portal",
|
|
3624
|
+
style: {
|
|
3625
|
+
position: "absolute",
|
|
3626
|
+
top: 0,
|
|
3627
|
+
left: 0,
|
|
3628
|
+
width: 0,
|
|
3629
|
+
height: 0,
|
|
3630
|
+
transformOrigin: "0 0",
|
|
3631
|
+
pointerEvents: "none",
|
|
3632
|
+
zIndex: 6
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
),
|
|
3636
|
+
_t && /* @__PURE__ */ B("div", { className: "ric-hint", children: Wt }),
|
|
3637
|
+
pn && /* @__PURE__ */ It("div", { className: "ric-info", children: [
|
|
3638
|
+
"world: (",
|
|
3639
|
+
Ut.wx,
|
|
3640
|
+
", ",
|
|
3641
|
+
Ut.wy,
|
|
3642
|
+
") zoom: ",
|
|
3643
|
+
Ut.zoom,
|
|
3644
|
+
"x",
|
|
3645
|
+
Ut.nodeCount > 0 && /* @__PURE__ */ It(Le, { children: [
|
|
3646
|
+
" nodes: ",
|
|
3647
|
+
Ut.nodeCount
|
|
3648
|
+
] }),
|
|
3649
|
+
Ut.edgeCount > 0 && /* @__PURE__ */ It(Le, { children: [
|
|
3650
|
+
" edges: ",
|
|
3651
|
+
Ut.edgeCount
|
|
3652
|
+
] })
|
|
3653
|
+
] }),
|
|
3654
|
+
/* @__PURE__ */ B(
|
|
3655
|
+
Hr,
|
|
3656
|
+
{
|
|
3657
|
+
selectionKeyCode: de || "Shift",
|
|
3658
|
+
selectionMode: we || "partial"
|
|
3659
|
+
}
|
|
3660
|
+
),
|
|
3661
|
+
Me
|
|
3662
|
+
]
|
|
3663
|
+
}
|
|
3664
|
+
) });
|
|
3665
|
+
}
|
|
3666
|
+
function $o({ children: t }) {
|
|
3667
|
+
return t;
|
|
3668
|
+
}
|
|
3669
|
+
function lr(t, e) {
|
|
3670
|
+
const n = [], r = /* @__PURE__ */ new Map(), s = [];
|
|
3671
|
+
for (const o of t)
|
|
3672
|
+
if (o.type === "add")
|
|
3673
|
+
s.push(o);
|
|
3674
|
+
else if (o.type === "remove" || o.type === "replace")
|
|
3675
|
+
r.set(o.id, [o]);
|
|
3676
|
+
else {
|
|
3677
|
+
const i = r.get(o.id);
|
|
3678
|
+
i ? i.push(o) : r.set(o.id, [o]);
|
|
3679
|
+
}
|
|
3680
|
+
for (const o of e) {
|
|
3681
|
+
const i = r.get(o.id);
|
|
3682
|
+
if (!i) {
|
|
3683
|
+
n.push(o);
|
|
3684
|
+
continue;
|
|
3685
|
+
}
|
|
3686
|
+
if (i[0].type === "remove") continue;
|
|
3687
|
+
if (i[0].type === "replace") {
|
|
3688
|
+
n.push({ ...i[0].item });
|
|
3689
|
+
continue;
|
|
3690
|
+
}
|
|
3691
|
+
const c = { ...o };
|
|
3692
|
+
for (const u of i)
|
|
3693
|
+
Jr(u, c);
|
|
3694
|
+
n.push(c);
|
|
3695
|
+
}
|
|
3696
|
+
for (const o of s)
|
|
3697
|
+
o.index !== void 0 ? n.splice(o.index, 0, { ...o.item }) : n.push({ ...o.item });
|
|
3698
|
+
return n;
|
|
3699
|
+
}
|
|
3700
|
+
function Jr(t, e) {
|
|
3701
|
+
switch (t.type) {
|
|
3702
|
+
case "select":
|
|
3703
|
+
e.selected = t.selected;
|
|
3704
|
+
break;
|
|
3705
|
+
case "position":
|
|
3706
|
+
t.position !== void 0 && (e.position = t.position), t.dragging !== void 0 && (e.dragging = t.dragging);
|
|
3707
|
+
break;
|
|
3708
|
+
case "dimensions":
|
|
3709
|
+
t.dimensions !== void 0 && (e.measured = { ...t.dimensions }, (t.setAttributes === !0 || t.setAttributes === "width") && (e.width = t.dimensions.width), (t.setAttributes === !0 || t.setAttributes === "height") && (e.height = t.dimensions.height)), t.handleBounds !== void 0 && (e.handleBounds = t.handleBounds);
|
|
3710
|
+
break;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
function Vr(t, e) {
|
|
3714
|
+
return lr(t, e);
|
|
3715
|
+
}
|
|
3716
|
+
function to(t, e) {
|
|
3717
|
+
return lr(t, e);
|
|
3718
|
+
}
|
|
3719
|
+
function Po(t, e) {
|
|
3720
|
+
return !t.source || !t.target ? (console.warn("addEdge: source and target are required"), e) : e.some(
|
|
3721
|
+
(r) => r.source === t.source && r.target === t.target && (r.sourceHandle || null) === (t.sourceHandle || null) && (r.targetHandle || null) === (t.targetHandle || null)
|
|
3722
|
+
) ? e : [...e, {
|
|
3723
|
+
id: t.id || `e-${t.source}-${t.target}`,
|
|
3724
|
+
...t
|
|
3725
|
+
}];
|
|
3726
|
+
}
|
|
3727
|
+
function To(t) {
|
|
3728
|
+
const [e, n] = Gt(t), r = F(
|
|
3729
|
+
(s) => n((o) => Vr(s, o)),
|
|
3730
|
+
[]
|
|
3731
|
+
);
|
|
3732
|
+
return [e, n, r];
|
|
3733
|
+
}
|
|
3734
|
+
function So(t) {
|
|
3735
|
+
const [e, n] = Gt(t), r = F(
|
|
3736
|
+
(s) => n((o) => to(s, o)),
|
|
3737
|
+
[]
|
|
3738
|
+
);
|
|
3739
|
+
return [e, n, r];
|
|
3740
|
+
}
|
|
3741
|
+
function eo() {
|
|
3742
|
+
const t = ht(), e = F(() => [...t.nodesRef.current], [t]), n = F(() => [...t.edgesRef.current], [t]), r = F((x) => t.nodesRef.current.find((f) => f.id === x), [t]), s = F((x) => t.edgesRef.current.find((f) => f.id === x), [t]), o = F((x) => {
|
|
3743
|
+
var f, p, y, N;
|
|
3744
|
+
if (typeof x == "function") {
|
|
3745
|
+
const C = x(t.nodesRef.current);
|
|
3746
|
+
(p = (f = t.onNodesChangeRef).current) == null || p.call(f, [
|
|
3747
|
+
...t.nodesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3748
|
+
...C.map((P) => ({ type: "add", item: P }))
|
|
3749
|
+
]);
|
|
3750
|
+
} else
|
|
3751
|
+
(N = (y = t.onNodesChangeRef).current) == null || N.call(y, [
|
|
3752
|
+
...t.nodesRef.current.map((C) => ({ id: C.id, type: "remove" })),
|
|
3753
|
+
...x.map((C) => ({ type: "add", item: C }))
|
|
3754
|
+
]);
|
|
3755
|
+
}, [t]), i = F((x) => {
|
|
3756
|
+
var f, p, y, N;
|
|
3757
|
+
if (typeof x == "function") {
|
|
3758
|
+
const C = x(t.edgesRef.current);
|
|
3759
|
+
(p = (f = t.onEdgesChangeRef).current) == null || p.call(f, [
|
|
3760
|
+
...t.edgesRef.current.map((P) => ({ id: P.id, type: "remove" })),
|
|
3761
|
+
...C.map((P) => ({ type: "add", item: P }))
|
|
3762
|
+
]);
|
|
3763
|
+
} else
|
|
3764
|
+
(N = (y = t.onEdgesChangeRef).current) == null || N.call(y, [
|
|
3765
|
+
...t.edgesRef.current.map((C) => ({ id: C.id, type: "remove" })),
|
|
3766
|
+
...x.map((C) => ({ type: "add", item: C }))
|
|
3767
|
+
]);
|
|
3768
|
+
}, [t]), c = F((x) => {
|
|
3769
|
+
var p, y;
|
|
3770
|
+
const f = Array.isArray(x) ? x : [x];
|
|
3771
|
+
(y = (p = t.onNodesChangeRef).current) == null || y.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3772
|
+
}, [t]), u = F((x) => {
|
|
3773
|
+
var p, y;
|
|
3774
|
+
const f = Array.isArray(x) ? x : [x];
|
|
3775
|
+
(y = (p = t.onEdgesChangeRef).current) == null || y.call(p, f.map((N) => ({ type: "add", item: N })));
|
|
3776
|
+
}, [t]), l = F(({ nodes: x = [], edges: f = [] }) => {
|
|
3777
|
+
if (x.length && t.onNodesChangeRef.current) {
|
|
3778
|
+
t.onNodesChangeRef.current(x.map((y) => ({ id: y.id, type: "remove" })));
|
|
3779
|
+
const p = zr(x, t.edgesRef.current);
|
|
3780
|
+
p.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(p.map((y) => ({ id: y.id, type: "remove" })));
|
|
3781
|
+
}
|
|
3782
|
+
f.length && t.onEdgesChangeRef.current && t.onEdgesChangeRef.current(f.map((p) => ({ id: p.id, type: "remove" })));
|
|
3783
|
+
}, [t]), g = F(() => {
|
|
3784
|
+
const x = t.cameraRef.current;
|
|
3785
|
+
return { x: x.x, y: x.y, zoom: x.zoom };
|
|
3786
|
+
}, [t]), v = F((x, f) => {
|
|
3787
|
+
t.cameraRef.current = {
|
|
3788
|
+
x: x.x ?? t.cameraRef.current.x,
|
|
3789
|
+
y: x.y ?? t.cameraRef.current.y,
|
|
3790
|
+
zoom: x.zoom ?? t.cameraRef.current.zoom
|
|
3791
|
+
}, t.sendCamera();
|
|
3792
|
+
}, [t]), E = F(() => t.cameraRef.current.zoom, [t]), R = F((x) => {
|
|
3793
|
+
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3794
|
+
if (!p) return;
|
|
3795
|
+
const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = 1.2;
|
|
3796
|
+
f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.min(t.zoomMax, f.zoom * P), t.sendCamera();
|
|
3797
|
+
}, [t]), M = F((x) => {
|
|
3798
|
+
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3799
|
+
if (!p) return;
|
|
3800
|
+
const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = 1 / 1.2;
|
|
3801
|
+
f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.max(t.zoomMin, f.zoom * P), t.sendCamera();
|
|
3802
|
+
}, [t]), T = F((x) => {
|
|
3803
|
+
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3804
|
+
if (!p) return;
|
|
3805
|
+
const y = p.getBoundingClientRect(), N = y.width / 2, C = y.height / 2, P = x / f.zoom;
|
|
3806
|
+
f.x = N - (N - f.x) * P, f.y = C - (C - f.y) * P, f.zoom = Math.min(t.zoomMax, Math.max(t.zoomMin, x)), t.sendCamera();
|
|
3807
|
+
}, [t]), k = F((x = {}) => {
|
|
3808
|
+
const f = t.nodesRef.current;
|
|
3809
|
+
if (!f.length) return;
|
|
3810
|
+
const p = t.wrapRef.current;
|
|
3811
|
+
if (!p) return;
|
|
3812
|
+
const y = p.getBoundingClientRect(), N = x.padding ?? 0.1, C = x.nodes ? f.filter((L) => x.nodes.some((Y) => Y.id === L.id)) : f;
|
|
3813
|
+
if (!C.length) return;
|
|
3814
|
+
const P = Mn(C), b = Rn(P, y.width, y.height, N);
|
|
3815
|
+
x.maxZoom && (b.zoom = Math.min(b.zoom, x.maxZoom)), x.minZoom && (b.zoom = Math.max(b.zoom, x.minZoom)), t.cameraRef.current = b, t.sendCamera();
|
|
3816
|
+
}, [t]), z = F((x, f, p = {}) => {
|
|
3817
|
+
const y = t.wrapRef.current;
|
|
3818
|
+
if (!y) return;
|
|
3819
|
+
const N = y.getBoundingClientRect(), C = p.zoom ?? t.cameraRef.current.zoom;
|
|
3820
|
+
t.cameraRef.current = {
|
|
3821
|
+
x: N.width / 2 - x * C,
|
|
3822
|
+
y: N.height / 2 - f * C,
|
|
3823
|
+
zoom: C
|
|
3824
|
+
}, t.sendCamera();
|
|
3825
|
+
}, [t]), W = F((x) => t.screenToWorld(x.x, x.y), [t]), D = F((x) => {
|
|
3826
|
+
const f = t.cameraRef.current, p = t.wrapRef.current;
|
|
3827
|
+
if (!p) return { x: 0, y: 0 };
|
|
3828
|
+
const y = p.getBoundingClientRect();
|
|
3829
|
+
return {
|
|
3830
|
+
x: x.x * f.zoom + f.x + y.left,
|
|
3831
|
+
y: x.y * f.zoom + f.y + y.top
|
|
3832
|
+
};
|
|
3833
|
+
}, [t]);
|
|
3834
|
+
return {
|
|
3835
|
+
getNodes: e,
|
|
3836
|
+
getEdges: n,
|
|
3837
|
+
getNode: r,
|
|
3838
|
+
getEdge: s,
|
|
3839
|
+
setNodes: o,
|
|
3840
|
+
setEdges: i,
|
|
3841
|
+
addNodes: c,
|
|
3842
|
+
addEdges: u,
|
|
3843
|
+
deleteElements: l,
|
|
3844
|
+
getViewport: g,
|
|
3845
|
+
setViewport: v,
|
|
3846
|
+
getZoom: E,
|
|
3847
|
+
zoomIn: R,
|
|
3848
|
+
zoomOut: M,
|
|
3849
|
+
zoomTo: T,
|
|
3850
|
+
fitView: k,
|
|
3851
|
+
setCenter: z,
|
|
3852
|
+
screenToFlowPosition: W,
|
|
3853
|
+
flowToScreenPosition: D
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
function Bo() {
|
|
3857
|
+
return ht().nodes;
|
|
3858
|
+
}
|
|
3859
|
+
function Do() {
|
|
3860
|
+
return ht().edges;
|
|
3861
|
+
}
|
|
3862
|
+
function Ho() {
|
|
3863
|
+
return ht().viewport;
|
|
3864
|
+
}
|
|
3865
|
+
function Ao() {
|
|
3866
|
+
return ht().connection;
|
|
3867
|
+
}
|
|
3868
|
+
function _o(t) {
|
|
3869
|
+
const e = ht(), n = Array.isArray(t) ? t : [t];
|
|
3870
|
+
return St(() => n.map((r) => {
|
|
3871
|
+
const s = e.nodes.find((o) => o.id === r);
|
|
3872
|
+
return s ? { id: s.id, type: s.type, data: s.data } : null;
|
|
3873
|
+
}).filter(Boolean), [e.nodes, ...n]);
|
|
3874
|
+
}
|
|
3875
|
+
function Wo(t) {
|
|
3876
|
+
const e = ht();
|
|
3877
|
+
return St(() => e.edges.filter((n) => n.source === t || n.target === t), [e.edges, t]);
|
|
3878
|
+
}
|
|
3879
|
+
function Xo({ nodeId: t, type: e, handleId: n }) {
|
|
3880
|
+
const r = ht();
|
|
3881
|
+
return St(() => r.edges.filter((s) => e === "source" ? s.source === t && (n ? s.sourceHandle === n : !0) : s.target === t && (n ? s.targetHandle === n : !0)), [r.edges, t, e, n]);
|
|
3882
|
+
}
|
|
3883
|
+
function Fo({ onChange: t, onStart: e, onEnd: n }) {
|
|
3884
|
+
const r = ht(), s = V(t), o = V(e), i = V(n);
|
|
3885
|
+
ut(() => {
|
|
3886
|
+
s.current = t;
|
|
3887
|
+
}, [t]), ut(() => {
|
|
3888
|
+
o.current = e;
|
|
3889
|
+
}, [e]), ut(() => {
|
|
3890
|
+
i.current = n;
|
|
3891
|
+
}, [n]), ut(() => {
|
|
3892
|
+
const c = (u) => {
|
|
3893
|
+
var l;
|
|
3894
|
+
(l = s.current) == null || l.call(s, { x: u.x, y: u.y, zoom: u.zoom });
|
|
3895
|
+
};
|
|
3896
|
+
return r.viewportListeners.add(c), () => r.viewportListeners.delete(c);
|
|
3897
|
+
}, [r]);
|
|
3898
|
+
}
|
|
3899
|
+
function Yo({ onChange: t }) {
|
|
3900
|
+
const e = ht(), n = V(t);
|
|
3901
|
+
ut(() => {
|
|
3902
|
+
n.current = t;
|
|
3903
|
+
}, [t]), ut(() => {
|
|
3904
|
+
const r = (s) => {
|
|
3905
|
+
var o;
|
|
3906
|
+
(o = n.current) == null || o.call(n, s);
|
|
3907
|
+
};
|
|
3908
|
+
return e.selectionListeners.add(r), () => e.selectionListeners.delete(r);
|
|
3909
|
+
}, [e]);
|
|
3910
|
+
}
|
|
3911
|
+
function Uo(t) {
|
|
3912
|
+
const [e, n] = Gt(!1), r = Array.isArray(t) ? t : [t];
|
|
3913
|
+
return ut(() => {
|
|
3914
|
+
const s = (i) => {
|
|
3915
|
+
r.includes(i.key) && n(!0);
|
|
3916
|
+
}, o = (i) => {
|
|
3917
|
+
r.includes(i.key) && n(!1);
|
|
3918
|
+
};
|
|
3919
|
+
return window.addEventListener("keydown", s), window.addEventListener("keyup", o), () => {
|
|
3920
|
+
window.removeEventListener("keydown", s), window.removeEventListener("keyup", o);
|
|
3921
|
+
};
|
|
3922
|
+
}, [r.join(",")]), e;
|
|
3923
|
+
}
|
|
3924
|
+
function qo() {
|
|
3925
|
+
const t = ht();
|
|
3926
|
+
return F((e) => {
|
|
3927
|
+
var n;
|
|
3928
|
+
(n = t.workerRef.current) == null || n.postMessage({
|
|
3929
|
+
type: "nodes",
|
|
3930
|
+
data: { nodes: [...t.nodesRef.current] }
|
|
3931
|
+
});
|
|
3932
|
+
}, [t]);
|
|
3933
|
+
}
|
|
3934
|
+
function jo(t = {}) {
|
|
3935
|
+
return ht().nodes.length > 0;
|
|
3936
|
+
}
|
|
3937
|
+
function Go(t) {
|
|
3938
|
+
const e = ht();
|
|
3939
|
+
return St(() => e.nodes.find((n) => n.id === t) || void 0, [e.nodes, t]);
|
|
3940
|
+
}
|
|
3941
|
+
function Zo(t) {
|
|
3942
|
+
const e = ht();
|
|
3943
|
+
return typeof t == "function" ? t(e) : e;
|
|
3944
|
+
}
|
|
3945
|
+
function Qo() {
|
|
3946
|
+
const t = ht();
|
|
3947
|
+
return St(() => ({
|
|
3948
|
+
getState: () => t,
|
|
3949
|
+
setState: () => {
|
|
3950
|
+
console.warn("[infinite-canvas] setState on storeApi is not supported. Use onNodesChange/onEdgesChange instead.");
|
|
3951
|
+
}
|
|
3952
|
+
}), [t]);
|
|
3953
|
+
}
|
|
3954
|
+
const wn = 160, bn = 60;
|
|
3955
|
+
function Ko({
|
|
3956
|
+
width: t = 200,
|
|
3957
|
+
height: e = 150,
|
|
3958
|
+
nodeColor: n = "#3b82f6",
|
|
3959
|
+
nodeStrokeColor: r = "#fff",
|
|
3960
|
+
maskColor: s = "rgba(0,0,0,0.1)",
|
|
3961
|
+
style: o = {},
|
|
3962
|
+
className: i = ""
|
|
3963
|
+
}) {
|
|
3964
|
+
const c = ht(), u = V(null), l = V(null), g = F(() => {
|
|
3965
|
+
const v = u.current;
|
|
3966
|
+
if (!v) return;
|
|
3967
|
+
const E = v.getContext("2d"), R = window.devicePixelRatio || 1;
|
|
3968
|
+
v.width = t * R, v.height = e * R, E.scale(R, R), E.clearRect(0, 0, t, e);
|
|
3969
|
+
const M = c.nodesRef.current;
|
|
3970
|
+
if (!M.length) return;
|
|
3971
|
+
let T = 1 / 0, k = 1 / 0, z = -1 / 0, W = -1 / 0;
|
|
3972
|
+
for (const b of M) {
|
|
3973
|
+
const L = b.width || wn, Y = b.height || bn;
|
|
3974
|
+
b.position.x < T && (T = b.position.x), b.position.y < k && (k = b.position.y), b.position.x + L > z && (z = b.position.x + L), b.position.y + Y > W && (W = b.position.y + Y);
|
|
3975
|
+
}
|
|
3976
|
+
const D = 40;
|
|
3977
|
+
T -= D, k -= D, z += D, W += D;
|
|
3978
|
+
const x = z - T, f = W - k, p = Math.min(t / x, e / f), y = (t - x * p) / 2, N = (e - f * p) / 2;
|
|
3979
|
+
for (const b of M) {
|
|
3980
|
+
if (b.hidden) continue;
|
|
3981
|
+
const L = b.width || wn, Y = b.height || bn, H = (b.position.x - T) * p + y, dt = (b.position.y - k) * p + N, yt = L * p, ft = Y * p;
|
|
3982
|
+
E.fillStyle = b.selected ? "#f59e0b" : typeof n == "function" ? n(b) : n, E.fillRect(H, dt, Math.max(yt, 2), Math.max(ft, 2));
|
|
3983
|
+
}
|
|
3984
|
+
const C = c.cameraRef.current, P = c.wrapRef.current;
|
|
3985
|
+
if (P) {
|
|
3986
|
+
const b = P.getBoundingClientRect(), L = -C.x / C.zoom, Y = -C.y / C.zoom, H = b.width / C.zoom, dt = b.height / C.zoom;
|
|
3987
|
+
E.fillStyle = s, E.fillRect(0, 0, t, e);
|
|
3988
|
+
const yt = (L - T) * p + y, ft = (Y - k) * p + N, G = H * p, j = dt * p;
|
|
3989
|
+
E.clearRect(yt, ft, G, j);
|
|
3990
|
+
for (const rt of M) {
|
|
3991
|
+
if (rt.hidden) continue;
|
|
3992
|
+
const at = rt.width || wn, ct = rt.height || bn, lt = (rt.position.x - T) * p + y, Ct = (rt.position.y - k) * p + N;
|
|
3993
|
+
E.fillStyle = rt.selected ? "#f59e0b" : typeof n == "function" ? n(rt) : n, E.fillRect(lt, Ct, Math.max(at * p, 2), Math.max(ct * p, 2));
|
|
3994
|
+
}
|
|
3995
|
+
E.strokeStyle = "#3b82f6", E.lineWidth = 1.5, E.strokeRect(yt, ft, G, j);
|
|
3996
|
+
}
|
|
3997
|
+
}, [c, t, e, n, r, s]);
|
|
3998
|
+
return ut(() => {
|
|
3999
|
+
let v = !0;
|
|
4000
|
+
function E() {
|
|
4001
|
+
v && (g(), l.current = requestAnimationFrame(E));
|
|
4002
|
+
}
|
|
4003
|
+
const R = setInterval(() => {
|
|
4004
|
+
cancelAnimationFrame(l.current), l.current = requestAnimationFrame(E);
|
|
4005
|
+
}, 66);
|
|
4006
|
+
return g(), () => {
|
|
4007
|
+
v = !1, clearInterval(R), cancelAnimationFrame(l.current);
|
|
4008
|
+
};
|
|
4009
|
+
}, [g]), /* @__PURE__ */ B(
|
|
4010
|
+
"canvas",
|
|
4011
|
+
{
|
|
4012
|
+
ref: u,
|
|
4013
|
+
className: `ric-minimap ${i}`,
|
|
4014
|
+
style: {
|
|
4015
|
+
position: "absolute",
|
|
4016
|
+
bottom: 30,
|
|
4017
|
+
right: 10,
|
|
4018
|
+
width: t,
|
|
4019
|
+
height: e,
|
|
4020
|
+
borderRadius: 4,
|
|
4021
|
+
border: "1px solid rgba(0,0,0,0.1)",
|
|
4022
|
+
background: "rgba(255,255,255,0.9)",
|
|
4023
|
+
pointerEvents: "none",
|
|
4024
|
+
...o
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
}
|
|
4029
|
+
function no() {
|
|
4030
|
+
return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4031
|
+
/* @__PURE__ */ B("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
|
|
4032
|
+
/* @__PURE__ */ B("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
|
|
4033
|
+
] });
|
|
4034
|
+
}
|
|
4035
|
+
function ro() {
|
|
4036
|
+
return /* @__PURE__ */ B("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ B("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
|
|
4037
|
+
}
|
|
4038
|
+
function oo() {
|
|
4039
|
+
return /* @__PURE__ */ B("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ B("path", { d: "M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7" }) });
|
|
4040
|
+
}
|
|
4041
|
+
function so() {
|
|
4042
|
+
return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4043
|
+
/* @__PURE__ */ B("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4044
|
+
/* @__PURE__ */ B("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
4045
|
+
] });
|
|
4046
|
+
}
|
|
4047
|
+
function io() {
|
|
4048
|
+
return /* @__PURE__ */ It("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
4049
|
+
/* @__PURE__ */ B("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
4050
|
+
/* @__PURE__ */ B("path", { d: "M7 11V7a5 5 0 0 1 9.9-1" })
|
|
4051
|
+
] });
|
|
4052
|
+
}
|
|
4053
|
+
function rn({ children: t, className: e = "", ...n }) {
|
|
4054
|
+
return /* @__PURE__ */ B(
|
|
4055
|
+
"button",
|
|
4056
|
+
{
|
|
4057
|
+
className: `ric-controls-button ${e}`,
|
|
4058
|
+
style: co,
|
|
4059
|
+
...n,
|
|
4060
|
+
children: t
|
|
4061
|
+
}
|
|
4062
|
+
);
|
|
4063
|
+
}
|
|
4064
|
+
function ao({
|
|
4065
|
+
showZoom: t = !0,
|
|
4066
|
+
showFitView: e = !0,
|
|
4067
|
+
showInteractive: n = !1,
|
|
4068
|
+
fitViewOptions: r,
|
|
4069
|
+
onZoomIn: s,
|
|
4070
|
+
onZoomOut: o,
|
|
4071
|
+
onFitView: i,
|
|
4072
|
+
onInteractiveChange: c,
|
|
4073
|
+
position: u = "bottom-left",
|
|
4074
|
+
orientation: l = "vertical",
|
|
4075
|
+
style: g = {},
|
|
4076
|
+
className: v = "",
|
|
4077
|
+
"aria-label": E = "Canvas controls",
|
|
4078
|
+
children: R
|
|
4079
|
+
}) {
|
|
4080
|
+
const M = ht(), { zoomIn: T, zoomOut: k, fitView: z, getZoom: W } = eo(), [D, x] = Gt(!0), f = W() <= M.zoomMin, p = W() >= M.zoomMax, y = F(() => {
|
|
4081
|
+
T(), s == null || s();
|
|
4082
|
+
}, [T, s]), N = F(() => {
|
|
4083
|
+
k(), o == null || o();
|
|
4084
|
+
}, [k, o]), C = F(() => {
|
|
4085
|
+
z(r || { padding: 0.1 }), i == null || i();
|
|
4086
|
+
}, [z, r, i]), P = F(() => {
|
|
4087
|
+
const L = !D;
|
|
4088
|
+
x(L), c == null || c(L);
|
|
4089
|
+
}, [D, c]), b = {
|
|
4090
|
+
"top-left": { top: 10, left: 10 },
|
|
4091
|
+
"top-right": { top: 10, right: 10 },
|
|
4092
|
+
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
4093
|
+
"bottom-left": { bottom: 30, left: 10 },
|
|
4094
|
+
"bottom-right": { bottom: 30, right: 10 },
|
|
4095
|
+
"bottom-center": { bottom: 30, left: "50%", transform: "translateX(-50%)" }
|
|
4096
|
+
}[u] || { bottom: 30, left: 10 };
|
|
4097
|
+
return /* @__PURE__ */ It(
|
|
4098
|
+
"div",
|
|
4099
|
+
{
|
|
4100
|
+
className: `ric-controls ${v}`,
|
|
4101
|
+
style: {
|
|
4102
|
+
position: "absolute",
|
|
4103
|
+
display: "flex",
|
|
4104
|
+
flexDirection: l === "horizontal" ? "row" : "column",
|
|
4105
|
+
gap: 2,
|
|
4106
|
+
zIndex: 5,
|
|
4107
|
+
...b,
|
|
4108
|
+
...g
|
|
4109
|
+
},
|
|
4110
|
+
role: "toolbar",
|
|
4111
|
+
"aria-label": E,
|
|
4112
|
+
children: [
|
|
4113
|
+
t && /* @__PURE__ */ It(Le, { children: [
|
|
4114
|
+
/* @__PURE__ */ B(
|
|
4115
|
+
rn,
|
|
4116
|
+
{
|
|
4117
|
+
onClick: y,
|
|
4118
|
+
disabled: p,
|
|
4119
|
+
title: "Zoom in",
|
|
4120
|
+
"aria-label": "Zoom in",
|
|
4121
|
+
className: "ric-controls-zoomin",
|
|
4122
|
+
children: /* @__PURE__ */ B(no, {})
|
|
4123
|
+
}
|
|
4124
|
+
),
|
|
4125
|
+
/* @__PURE__ */ B(
|
|
4126
|
+
rn,
|
|
4127
|
+
{
|
|
4128
|
+
onClick: N,
|
|
4129
|
+
disabled: f,
|
|
4130
|
+
title: "Zoom out",
|
|
4131
|
+
"aria-label": "Zoom out",
|
|
4132
|
+
className: "ric-controls-zoomout",
|
|
4133
|
+
children: /* @__PURE__ */ B(ro, {})
|
|
4134
|
+
}
|
|
4135
|
+
)
|
|
4136
|
+
] }),
|
|
4137
|
+
e && /* @__PURE__ */ B(
|
|
4138
|
+
rn,
|
|
4139
|
+
{
|
|
4140
|
+
onClick: C,
|
|
4141
|
+
title: "Fit view",
|
|
4142
|
+
"aria-label": "Fit view",
|
|
4143
|
+
className: "ric-controls-fitview",
|
|
4144
|
+
children: /* @__PURE__ */ B(oo, {})
|
|
4145
|
+
}
|
|
4146
|
+
),
|
|
4147
|
+
n && /* @__PURE__ */ B(
|
|
4148
|
+
rn,
|
|
4149
|
+
{
|
|
4150
|
+
onClick: P,
|
|
4151
|
+
title: D ? "Lock interactivity" : "Unlock interactivity",
|
|
4152
|
+
"aria-label": D ? "Lock interactivity" : "Unlock interactivity",
|
|
4153
|
+
className: "ric-controls-interactive",
|
|
4154
|
+
children: D ? /* @__PURE__ */ B(io, {}) : /* @__PURE__ */ B(so, {})
|
|
4155
|
+
}
|
|
4156
|
+
),
|
|
4157
|
+
R
|
|
4158
|
+
]
|
|
4159
|
+
}
|
|
4160
|
+
);
|
|
4161
|
+
}
|
|
4162
|
+
const co = {
|
|
4163
|
+
width: 28,
|
|
4164
|
+
height: 28,
|
|
4165
|
+
display: "flex",
|
|
4166
|
+
alignItems: "center",
|
|
4167
|
+
justifyContent: "center",
|
|
4168
|
+
border: "1px solid rgba(0,0,0,0.12)",
|
|
4169
|
+
borderRadius: 4,
|
|
4170
|
+
background: "#fff",
|
|
4171
|
+
cursor: "pointer",
|
|
4172
|
+
fontSize: 16,
|
|
4173
|
+
lineHeight: 1,
|
|
4174
|
+
color: "#333",
|
|
4175
|
+
padding: 0
|
|
4176
|
+
}, Oo = Zt(ao);
|
|
4177
|
+
function Jo({
|
|
4178
|
+
variant: t = "lines",
|
|
4179
|
+
gap: e = 40,
|
|
4180
|
+
size: n = 1,
|
|
4181
|
+
color: r,
|
|
4182
|
+
style: s = {},
|
|
4183
|
+
className: o = ""
|
|
4184
|
+
}) {
|
|
4185
|
+
const i = ht();
|
|
4186
|
+
return i.workerRef.current && i.workerRef.current.postMessage({
|
|
4187
|
+
type: "background",
|
|
4188
|
+
data: { variant: t, gap: e, size: n, color: r }
|
|
4189
|
+
}), null;
|
|
4190
|
+
}
|
|
4191
|
+
function Vo({
|
|
4192
|
+
position: t = "top-left",
|
|
4193
|
+
style: e = {},
|
|
4194
|
+
className: n = "",
|
|
4195
|
+
children: r
|
|
4196
|
+
}) {
|
|
4197
|
+
const s = {
|
|
4198
|
+
"top-left": { top: 10, left: 10 },
|
|
4199
|
+
"top-right": { top: 10, right: 10 },
|
|
4200
|
+
"top-center": { top: 10, left: "50%", transform: "translateX(-50%)" },
|
|
4201
|
+
"bottom-left": { bottom: 10, left: 10 },
|
|
4202
|
+
"bottom-right": { bottom: 10, right: 10 },
|
|
4203
|
+
"bottom-center": { bottom: 10, left: "50%", transform: "translateX(-50%)" }
|
|
4204
|
+
}[t] || { top: 10, left: 10 };
|
|
4205
|
+
return /* @__PURE__ */ B(
|
|
4206
|
+
"div",
|
|
4207
|
+
{
|
|
4208
|
+
className: `ric-panel ${n}`,
|
|
4209
|
+
style: {
|
|
4210
|
+
position: "absolute",
|
|
4211
|
+
zIndex: 5,
|
|
4212
|
+
pointerEvents: "all",
|
|
4213
|
+
...s,
|
|
4214
|
+
...e
|
|
4215
|
+
},
|
|
4216
|
+
onPointerDown: (o) => o.stopPropagation(),
|
|
4217
|
+
children: r
|
|
4218
|
+
}
|
|
4219
|
+
);
|
|
4220
|
+
}
|
|
4221
|
+
function ts({
|
|
4222
|
+
minWidth: t = 10,
|
|
4223
|
+
minHeight: e = 10,
|
|
4224
|
+
maxWidth: n = 1 / 0,
|
|
4225
|
+
maxHeight: r = 1 / 0,
|
|
4226
|
+
isVisible: s = !0,
|
|
4227
|
+
handleStyle: o = {},
|
|
4228
|
+
lineStyle: i = {},
|
|
4229
|
+
color: c = "#3b82f6",
|
|
4230
|
+
onResizeStart: u,
|
|
4231
|
+
onResize: l,
|
|
4232
|
+
onResizeEnd: g
|
|
4233
|
+
}) {
|
|
4234
|
+
const v = qe(je), E = ht(), R = V(null), M = F((z, W) => {
|
|
4235
|
+
z.stopPropagation(), z.preventDefault();
|
|
4236
|
+
const D = E.nodesRef.current.find((p) => p.id === v);
|
|
4237
|
+
if (!D) return;
|
|
4238
|
+
R.current = {
|
|
4239
|
+
direction: W,
|
|
4240
|
+
startX: z.clientX,
|
|
4241
|
+
startY: z.clientY,
|
|
4242
|
+
width: D.width || 160,
|
|
4243
|
+
height: D.height || 60
|
|
4244
|
+
}, u == null || u(z, { width: R.current.width, height: R.current.height });
|
|
4245
|
+
const x = (p) => {
|
|
4246
|
+
var Y, H;
|
|
4247
|
+
if (!R.current) return;
|
|
4248
|
+
const y = R.current, N = E.cameraRef.current, C = (p.clientX - y.startX) / N.zoom, P = (p.clientY - y.startY) / N.zoom;
|
|
4249
|
+
let b = y.width, L = y.height;
|
|
4250
|
+
y.direction.includes("e") && (b = Math.min(n, Math.max(t, y.width + C))), y.direction.includes("w") && (b = Math.min(n, Math.max(t, y.width - C))), y.direction.includes("s") && (L = Math.min(r, Math.max(e, y.height + P))), y.direction.includes("n") && (L = Math.min(r, Math.max(e, y.height - P))), (H = (Y = E.onNodesChangeRef).current) == null || H.call(Y, [
|
|
4251
|
+
{ id: v, type: "dimensions", dimensions: { width: b, height: L }, setAttributes: !0 }
|
|
4252
|
+
]), l == null || l(p, { width: b, height: L });
|
|
4253
|
+
}, f = (p) => {
|
|
4254
|
+
R.current = null, g == null || g(p, {}), window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", f);
|
|
4255
|
+
};
|
|
4256
|
+
window.addEventListener("pointermove", x), window.addEventListener("pointerup", f);
|
|
4257
|
+
}, [v, E, t, e, n, r, u, l, g]);
|
|
4258
|
+
if (!s) return null;
|
|
4259
|
+
const T = 8, k = {
|
|
4260
|
+
position: "absolute",
|
|
4261
|
+
width: T,
|
|
4262
|
+
height: T,
|
|
4263
|
+
background: c,
|
|
4264
|
+
border: "1px solid #fff",
|
|
4265
|
+
borderRadius: 2,
|
|
4266
|
+
zIndex: 20,
|
|
4267
|
+
...o
|
|
4268
|
+
};
|
|
4269
|
+
return /* @__PURE__ */ It(Le, { children: [
|
|
4270
|
+
/* @__PURE__ */ B(
|
|
4271
|
+
"div",
|
|
4272
|
+
{
|
|
4273
|
+
style: { ...k, bottom: -T / 2, right: -T / 2, cursor: "nwse-resize" },
|
|
4274
|
+
onPointerDown: (z) => M(z, "se")
|
|
4275
|
+
}
|
|
4276
|
+
),
|
|
4277
|
+
/* @__PURE__ */ B(
|
|
4278
|
+
"div",
|
|
4279
|
+
{
|
|
4280
|
+
style: { ...k, bottom: -T / 2, left: -T / 2, cursor: "nesw-resize" },
|
|
4281
|
+
onPointerDown: (z) => M(z, "sw")
|
|
4282
|
+
}
|
|
4283
|
+
),
|
|
4284
|
+
/* @__PURE__ */ B(
|
|
4285
|
+
"div",
|
|
4286
|
+
{
|
|
4287
|
+
style: { ...k, top: -T / 2, right: -T / 2, cursor: "nesw-resize" },
|
|
4288
|
+
onPointerDown: (z) => M(z, "ne")
|
|
4289
|
+
}
|
|
4290
|
+
),
|
|
4291
|
+
/* @__PURE__ */ B(
|
|
4292
|
+
"div",
|
|
4293
|
+
{
|
|
4294
|
+
style: { ...k, top: -T / 2, left: -T / 2, cursor: "nwse-resize" },
|
|
4295
|
+
onPointerDown: (z) => M(z, "nw")
|
|
4296
|
+
}
|
|
4297
|
+
),
|
|
4298
|
+
/* @__PURE__ */ B(
|
|
4299
|
+
"div",
|
|
4300
|
+
{
|
|
4301
|
+
style: { ...k, top: "50%", right: -T / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4302
|
+
onPointerDown: (z) => M(z, "e")
|
|
4303
|
+
}
|
|
4304
|
+
),
|
|
4305
|
+
/* @__PURE__ */ B(
|
|
4306
|
+
"div",
|
|
4307
|
+
{
|
|
4308
|
+
style: { ...k, top: "50%", left: -T / 2, cursor: "ew-resize", transform: "translateY(-50%)" },
|
|
4309
|
+
onPointerDown: (z) => M(z, "w")
|
|
4310
|
+
}
|
|
4311
|
+
),
|
|
4312
|
+
/* @__PURE__ */ B(
|
|
4313
|
+
"div",
|
|
4314
|
+
{
|
|
4315
|
+
style: { ...k, left: "50%", top: -T / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4316
|
+
onPointerDown: (z) => M(z, "n")
|
|
4317
|
+
}
|
|
4318
|
+
),
|
|
4319
|
+
/* @__PURE__ */ B(
|
|
4320
|
+
"div",
|
|
4321
|
+
{
|
|
4322
|
+
style: { ...k, left: "50%", bottom: -T / 2, cursor: "ns-resize", transform: "translateX(-50%)" },
|
|
4323
|
+
onPointerDown: (z) => M(z, "s")
|
|
4324
|
+
}
|
|
4325
|
+
)
|
|
4326
|
+
] });
|
|
4327
|
+
}
|
|
4328
|
+
function es({
|
|
4329
|
+
isVisible: t,
|
|
4330
|
+
position: e = "top",
|
|
4331
|
+
offset: n = 10,
|
|
4332
|
+
align: r = "center",
|
|
4333
|
+
children: s,
|
|
4334
|
+
style: o = {},
|
|
4335
|
+
className: i = ""
|
|
4336
|
+
}) {
|
|
4337
|
+
const c = qe(je), l = ht().nodes.find((E) => E.id === c);
|
|
4338
|
+
if (!(t !== void 0 ? t : l == null ? void 0 : l.selected)) return null;
|
|
4339
|
+
const v = {
|
|
4340
|
+
top: { bottom: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginBottom: n },
|
|
4341
|
+
bottom: { top: "100%", left: r === "start" ? 0 : r === "end" ? void 0 : "50%", right: r === "end" ? 0 : void 0, transform: r === "center" ? "translateX(-50%)" : void 0, marginTop: n },
|
|
4342
|
+
left: { right: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginRight: n },
|
|
4343
|
+
right: { left: "100%", top: r === "start" ? 0 : r === "end" ? void 0 : "50%", bottom: r === "end" ? 0 : void 0, transform: r === "center" ? "translateY(-50%)" : void 0, marginLeft: n }
|
|
4344
|
+
}[e] || {};
|
|
4345
|
+
return /* @__PURE__ */ B(
|
|
4346
|
+
"div",
|
|
4347
|
+
{
|
|
4348
|
+
className: `ric-node-toolbar ${i}`,
|
|
4349
|
+
style: {
|
|
4350
|
+
position: "absolute",
|
|
4351
|
+
zIndex: 1e3,
|
|
4352
|
+
pointerEvents: "all",
|
|
4353
|
+
...v,
|
|
4354
|
+
...o
|
|
4355
|
+
},
|
|
4356
|
+
onPointerDown: (E) => E.stopPropagation(),
|
|
4357
|
+
children: s
|
|
4358
|
+
}
|
|
4359
|
+
);
|
|
4360
|
+
}
|
|
4361
|
+
function ns({
|
|
4362
|
+
isVisible: t = !1,
|
|
4363
|
+
x: e = 0,
|
|
4364
|
+
y: n = 0,
|
|
4365
|
+
alignX: r = "center",
|
|
4366
|
+
alignY: s = "center",
|
|
4367
|
+
children: o,
|
|
4368
|
+
style: i = {},
|
|
4369
|
+
className: c = ""
|
|
4370
|
+
}) {
|
|
4371
|
+
if (!t) return null;
|
|
4372
|
+
const u = r === "center" ? "-50%" : r === "right" ? "-100%" : "0", l = s === "center" ? "-50%" : s === "bottom" ? "-100%" : "0";
|
|
4373
|
+
return /* @__PURE__ */ B(
|
|
4374
|
+
"div",
|
|
4375
|
+
{
|
|
4376
|
+
className: `ric-edge-toolbar ${c}`,
|
|
4377
|
+
style: {
|
|
4378
|
+
position: "absolute",
|
|
4379
|
+
left: e,
|
|
4380
|
+
top: n,
|
|
4381
|
+
transform: `translate(${u}, ${l})`,
|
|
4382
|
+
zIndex: 1e3,
|
|
4383
|
+
pointerEvents: "all",
|
|
4384
|
+
...i
|
|
4385
|
+
},
|
|
4386
|
+
children: o
|
|
4387
|
+
}
|
|
4388
|
+
);
|
|
4389
|
+
}
|
|
4390
|
+
function rs({ children: t }) {
|
|
4391
|
+
var r;
|
|
4392
|
+
const n = (r = ht().edgeLabelContainerRef) == null ? void 0 : r.current;
|
|
4393
|
+
return n ? Yn(t, n) : null;
|
|
4394
|
+
}
|
|
4395
|
+
function os({ children: t }) {
|
|
4396
|
+
var r;
|
|
4397
|
+
const n = (r = ht().viewportPortalRef) == null ? void 0 : r.current;
|
|
4398
|
+
return n ? Yn(t, n) : null;
|
|
4399
|
+
}
|
|
4400
|
+
function ur({
|
|
4401
|
+
fromX: t,
|
|
4402
|
+
fromY: e,
|
|
4403
|
+
toX: n,
|
|
4404
|
+
toY: r,
|
|
4405
|
+
fromPosition: s = "right",
|
|
4406
|
+
toPosition: o = "left",
|
|
4407
|
+
connectionLineType: i = "default",
|
|
4408
|
+
connectionLineStyle: c,
|
|
4409
|
+
connectionLineComponent: u
|
|
4410
|
+
}) {
|
|
4411
|
+
if (u)
|
|
4412
|
+
return /* @__PURE__ */ B(
|
|
4413
|
+
u,
|
|
4414
|
+
{
|
|
4415
|
+
fromX: t,
|
|
4416
|
+
fromY: e,
|
|
4417
|
+
toX: n,
|
|
4418
|
+
toY: r,
|
|
4419
|
+
fromPosition: s,
|
|
4420
|
+
toPosition: o
|
|
4421
|
+
}
|
|
4422
|
+
);
|
|
4423
|
+
let l;
|
|
4424
|
+
switch (i) {
|
|
4425
|
+
case "straight":
|
|
4426
|
+
[l] = er({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
4427
|
+
break;
|
|
4428
|
+
case "step":
|
|
4429
|
+
[l] = kn({
|
|
4430
|
+
sourceX: t,
|
|
4431
|
+
sourceY: e,
|
|
4432
|
+
targetX: n,
|
|
4433
|
+
targetY: r,
|
|
4434
|
+
sourcePosition: s,
|
|
4435
|
+
targetPosition: o,
|
|
4436
|
+
borderRadius: 0
|
|
4437
|
+
});
|
|
4438
|
+
break;
|
|
4439
|
+
case "smoothstep":
|
|
4440
|
+
[l] = kn({
|
|
4441
|
+
sourceX: t,
|
|
4442
|
+
sourceY: e,
|
|
4443
|
+
targetX: n,
|
|
4444
|
+
targetY: r,
|
|
4445
|
+
sourcePosition: s,
|
|
4446
|
+
targetPosition: o
|
|
4447
|
+
});
|
|
4448
|
+
break;
|
|
4449
|
+
case "simplebezier":
|
|
4450
|
+
[l] = rr({ sourceX: t, sourceY: e, targetX: n, targetY: r });
|
|
4451
|
+
break;
|
|
4452
|
+
default:
|
|
4453
|
+
[l] = nr({
|
|
4454
|
+
sourceX: t,
|
|
4455
|
+
sourceY: e,
|
|
4456
|
+
targetX: n,
|
|
4457
|
+
targetY: r,
|
|
4458
|
+
sourcePosition: s,
|
|
4459
|
+
targetPosition: o
|
|
4460
|
+
});
|
|
4461
|
+
break;
|
|
4462
|
+
}
|
|
4463
|
+
return /* @__PURE__ */ B(
|
|
4464
|
+
"path",
|
|
4465
|
+
{
|
|
4466
|
+
d: l,
|
|
4467
|
+
fill: "none",
|
|
4468
|
+
className: "ric-connection-line",
|
|
4469
|
+
stroke: "#b1b1b7",
|
|
4470
|
+
strokeWidth: 1.5,
|
|
4471
|
+
style: c
|
|
4472
|
+
}
|
|
4473
|
+
);
|
|
4474
|
+
}
|
|
4475
|
+
ur.displayName = "ConnectionLine";
|
|
4476
|
+
const ss = Zt(ur);
|
|
4477
|
+
export {
|
|
4478
|
+
Jo as Background,
|
|
4479
|
+
un as BaseEdge,
|
|
4480
|
+
tr as BezierEdge,
|
|
4481
|
+
ss as ConnectionLine,
|
|
4482
|
+
rn as ControlButton,
|
|
4483
|
+
Oo as Controls,
|
|
4484
|
+
ko as DefaultNode,
|
|
4485
|
+
rs as EdgeLabelRenderer,
|
|
4486
|
+
Fr as EdgeText,
|
|
4487
|
+
ns as EdgeToolbar,
|
|
4488
|
+
Xr as GroupNode,
|
|
4489
|
+
on as Handle,
|
|
4490
|
+
Io as InfiniteCanvas,
|
|
4491
|
+
$o as InfiniteCanvasProvider,
|
|
4492
|
+
_r as InputNode,
|
|
4493
|
+
Ko as MiniMap,
|
|
4494
|
+
ts as NodeResizer,
|
|
4495
|
+
es as NodeToolbar,
|
|
4496
|
+
Wr as OutputNode,
|
|
4497
|
+
Vo as Panel,
|
|
4498
|
+
Hr as SelectionBox,
|
|
4499
|
+
cr as SimpleBezierEdge,
|
|
4500
|
+
ar as SmoothStepEdge,
|
|
4501
|
+
Qr as StepEdge,
|
|
4502
|
+
ir as StraightEdge,
|
|
4503
|
+
os as ViewportPortal,
|
|
4504
|
+
Po as addEdge,
|
|
4505
|
+
to as applyEdgeChanges,
|
|
4506
|
+
Vr as applyNodeChanges,
|
|
4507
|
+
vo as boxToRect,
|
|
4508
|
+
or as buildObstacles,
|
|
4509
|
+
Tn as clampPosition,
|
|
4510
|
+
No as computeRoutedEdges,
|
|
4511
|
+
zo as getBezierEdgeCenter,
|
|
4512
|
+
nr as getBezierPath,
|
|
4513
|
+
wo as getBoundsOfBoxes,
|
|
4514
|
+
zr as getConnectedEdges,
|
|
4515
|
+
Eo as getEdgeCenter,
|
|
4516
|
+
go as getIncomers,
|
|
4517
|
+
jn as getNodeDimensions,
|
|
4518
|
+
Mn as getNodesBounds,
|
|
4519
|
+
xo as getNodesInside,
|
|
4520
|
+
po as getOutgoers,
|
|
4521
|
+
bo as getOverlappingArea,
|
|
4522
|
+
Cn as getRoutedLabelPosition,
|
|
4523
|
+
rr as getSimpleBezierPath,
|
|
4524
|
+
kn as getSmoothStepPath,
|
|
4525
|
+
er as getStraightPath,
|
|
4526
|
+
Rn as getViewportForBounds,
|
|
4527
|
+
yo as isEdge,
|
|
4528
|
+
ho as isNode,
|
|
4529
|
+
Mo as nodeToRect,
|
|
4530
|
+
Co as reconnectEdge,
|
|
4531
|
+
mo as rectToBox,
|
|
4532
|
+
Lo as routeSinglePath,
|
|
4533
|
+
En as routedPointsToPath,
|
|
4534
|
+
Pn as snapPosition,
|
|
4535
|
+
Ao as useConnection,
|
|
4536
|
+
Do as useEdges,
|
|
4537
|
+
So as useEdgesState,
|
|
4538
|
+
Xo as useHandleConnections,
|
|
4539
|
+
Lr as useInfiniteCanvas,
|
|
4540
|
+
Go as useInternalNode,
|
|
4541
|
+
Uo as useKeyPress,
|
|
4542
|
+
Wo as useNodeConnections,
|
|
4543
|
+
Ro as useNodeId,
|
|
4544
|
+
Bo as useNodes,
|
|
4545
|
+
_o as useNodesData,
|
|
4546
|
+
jo as useNodesInitialized,
|
|
4547
|
+
To as useNodesState,
|
|
4548
|
+
Yo as useOnSelectionChange,
|
|
4549
|
+
Fo as useOnViewportChange,
|
|
4550
|
+
eo as useReactFlow,
|
|
4551
|
+
Zo as useStore,
|
|
4552
|
+
Qo as useStoreApi,
|
|
4553
|
+
qo as useUpdateNodeInternals,
|
|
4554
|
+
Ho as useViewport
|
|
4555
|
+
};
|