dishui 0.0.60 → 0.0.61
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.
|
@@ -5,685 +5,687 @@ import { useViewport as zn } from "./hooks/useViewport.js";
|
|
|
5
5
|
import { GridRenderer as En } from "./canvas/GridRenderer.js";
|
|
6
6
|
import { SelectionOverlay as Cn } from "./canvas/SelectionOverlay.js";
|
|
7
7
|
import { shapeDrawers as an } from "./nodes/shapes.js";
|
|
8
|
-
import { findClosestHandleWorld as
|
|
9
|
-
import { distToSegment as Le, generateId as Nn, isPointInNode as
|
|
8
|
+
import { findClosestHandleWorld as Bt, getHandlePositions as Mt, handleWorldPos as Vt } from "./nodes/NodeHandles.js";
|
|
9
|
+
import { distToSegment as Le, generateId as Nn, isPointInNode as qt, rectsOverlap as kn } from "./nodes/nodeUtils.js";
|
|
10
10
|
import { NodeRenderer as Tn } from "./nodes/NodeRenderer.js";
|
|
11
11
|
import { buildEdgePath as wn, linearizeSegments as mn, resolveEdgeEndpoints as St } from "./edges/edgePaths.js";
|
|
12
12
|
import { EdgeRenderer as Dn } from "./edges/EdgeRenderer.js";
|
|
13
13
|
import { LineRenderer as Hn } from "./lines/LineRenderer.js";
|
|
14
14
|
import { FreehandTool as Pn } from "./lines/FreehandTool.js";
|
|
15
15
|
import { GeometricLineTool as An } from "./lines/GeometricLineTool.js";
|
|
16
|
-
import { computeAlignmentSnap as
|
|
16
|
+
import { computeAlignmentSnap as me } from "./hooks/useAlignmentGuides.js";
|
|
17
17
|
import { AlignmentGuidesRenderer as Ln } from "./canvas/AlignmentGuides.js";
|
|
18
18
|
import { getDocumentSlides as Gn, nextAnimIndex as Wn } from "./nodes/animAnchors.js";
|
|
19
19
|
import { useDeleteSelection as Yn } from "./hooks/useDeleteSelection.js";
|
|
20
|
-
import { useCallback as
|
|
21
|
-
import { jsx as
|
|
22
|
-
import { Graphics as
|
|
20
|
+
import { useCallback as le, useEffect as Rt, useRef as m, useState as ln } from "react";
|
|
21
|
+
import { jsx as Zt, jsxs as ve } from "react/jsx-runtime";
|
|
22
|
+
import { Graphics as ue } from "pixi.js";
|
|
23
23
|
var Xn = {
|
|
24
24
|
nw: "nwse-resize",
|
|
25
25
|
ne: "nesw-resize",
|
|
26
26
|
se: "nwse-resize",
|
|
27
27
|
sw: "nesw-resize"
|
|
28
|
-
},
|
|
29
|
-
function
|
|
30
|
-
return Math.min(M * un /
|
|
28
|
+
}, fe = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(pointer: coarse)").matches, un = fe ? 2 : 1;
|
|
29
|
+
function Q(L, M, H) {
|
|
30
|
+
return Math.min(M * un / L, H * un);
|
|
31
31
|
}
|
|
32
32
|
var vn = 26;
|
|
33
|
-
function fn(
|
|
33
|
+
function fn(L, M) {
|
|
34
34
|
return {
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
35
|
+
x: L.position.x + L.width / 2,
|
|
36
|
+
y: L.position.y - vn / M
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return !
|
|
39
|
+
function Kt(L, M, H) {
|
|
40
|
+
return !H || !(M > 0) ? L : Math.round(L / M) * M;
|
|
41
41
|
}
|
|
42
|
-
function hn(
|
|
43
|
-
const { x: U, y:
|
|
42
|
+
function hn(L, M, H) {
|
|
43
|
+
const { x: U, y: D } = M.position, W = M.width, A = M.height, N = [
|
|
44
44
|
[
|
|
45
45
|
"nw",
|
|
46
46
|
U,
|
|
47
|
-
|
|
47
|
+
D
|
|
48
48
|
],
|
|
49
49
|
[
|
|
50
50
|
"ne",
|
|
51
|
-
U +
|
|
52
|
-
|
|
51
|
+
U + W,
|
|
52
|
+
D
|
|
53
53
|
],
|
|
54
54
|
[
|
|
55
55
|
"se",
|
|
56
|
-
U +
|
|
57
|
-
|
|
56
|
+
U + W,
|
|
57
|
+
D + A
|
|
58
58
|
],
|
|
59
59
|
[
|
|
60
60
|
"sw",
|
|
61
61
|
U,
|
|
62
|
-
|
|
62
|
+
D + A
|
|
63
63
|
]
|
|
64
64
|
];
|
|
65
|
-
let
|
|
66
|
-
for (const [j, lt,
|
|
67
|
-
const $ = Math.hypot(
|
|
68
|
-
$ < q && (q = $,
|
|
65
|
+
let E = null, q = H;
|
|
66
|
+
for (const [j, lt, et] of N) {
|
|
67
|
+
const $ = Math.hypot(L.x - lt, L.y - et);
|
|
68
|
+
$ < q && (q = $, E = j);
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return E;
|
|
71
71
|
}
|
|
72
|
-
function yn(
|
|
73
|
-
let
|
|
74
|
-
for (const
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
77
|
-
const q = Math.hypot(
|
|
78
|
-
q <
|
|
79
|
-
edgeId:
|
|
72
|
+
function yn(L, M, H, U, D) {
|
|
73
|
+
let W = null, A = D;
|
|
74
|
+
for (const N of H) {
|
|
75
|
+
const E = St(N, U);
|
|
76
|
+
if (!E) continue;
|
|
77
|
+
const q = Math.hypot(L - E.sx, M - E.sy);
|
|
78
|
+
q < A && (A = q, W = {
|
|
79
|
+
edgeId: N.id,
|
|
80
80
|
end: "source",
|
|
81
|
-
worldX:
|
|
82
|
-
worldY:
|
|
81
|
+
worldX: E.sx,
|
|
82
|
+
worldY: E.sy
|
|
83
83
|
});
|
|
84
|
-
const j = Math.hypot(
|
|
85
|
-
j <
|
|
86
|
-
edgeId:
|
|
84
|
+
const j = Math.hypot(L - E.tx, M - E.ty);
|
|
85
|
+
j < A && (A = j, W = {
|
|
86
|
+
edgeId: N.id,
|
|
87
87
|
end: "target",
|
|
88
|
-
worldX:
|
|
89
|
-
worldY:
|
|
88
|
+
worldX: E.tx,
|
|
89
|
+
worldY: E.ty
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
return
|
|
92
|
+
return W;
|
|
93
93
|
}
|
|
94
|
-
function pn(
|
|
95
|
-
let
|
|
96
|
-
for (const
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
for (let
|
|
100
|
-
const q = Math.hypot(
|
|
101
|
-
q <
|
|
102
|
-
edgeId:
|
|
103
|
-
waypointIndex:
|
|
104
|
-
wx:
|
|
105
|
-
wy:
|
|
94
|
+
function pn(L, M, H, U) {
|
|
95
|
+
let D = null, W = U;
|
|
96
|
+
for (const A of H) {
|
|
97
|
+
const N = A.data.waypoints;
|
|
98
|
+
if (N)
|
|
99
|
+
for (let E = 0; E < N.length; E++) {
|
|
100
|
+
const q = Math.hypot(L - N[E].x, M - N[E].y);
|
|
101
|
+
q < W && (W = q, D = {
|
|
102
|
+
edgeId: A.id,
|
|
103
|
+
waypointIndex: E,
|
|
104
|
+
wx: N[E].x,
|
|
105
|
+
wy: N[E].y
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
return
|
|
109
|
+
return D;
|
|
110
110
|
}
|
|
111
|
-
function xn(
|
|
112
|
-
let
|
|
113
|
-
for (const
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
117
|
-
const q =
|
|
111
|
+
function xn(L, M, H, U, D) {
|
|
112
|
+
let W = null, A = D;
|
|
113
|
+
for (const N of H) {
|
|
114
|
+
if (N.type !== "simplebezier") continue;
|
|
115
|
+
const E = St(N, U);
|
|
116
|
+
if (!E) continue;
|
|
117
|
+
const q = N.data.waypoints ?? [], j = [
|
|
118
118
|
{
|
|
119
|
-
x:
|
|
120
|
-
y:
|
|
119
|
+
x: E.sx,
|
|
120
|
+
y: E.sy
|
|
121
121
|
},
|
|
122
122
|
...q,
|
|
123
123
|
{
|
|
124
|
-
x:
|
|
125
|
-
y:
|
|
124
|
+
x: E.tx,
|
|
125
|
+
y: E.ty
|
|
126
126
|
}
|
|
127
|
-
], lt =
|
|
128
|
-
for (let $ = 0; $ <=
|
|
129
|
-
const
|
|
130
|
-
Ct <
|
|
131
|
-
edgeId:
|
|
127
|
+
], lt = N.data.bezierControls, et = j.length - 2;
|
|
128
|
+
for (let $ = 0; $ <= et; $++) {
|
|
129
|
+
const ot = j[$], st = j[$ + 1], zt = lt?.[$], Ut = Math.hypot(st.x - ot.x, st.y - ot.y), Lt = Math.max(30, Ut * 0.3), he = zt?.c1x ?? ($ === 0 ? ot.x + E.snx * Lt : ot.x + (st.x - ot.x) * 0.4), $t = zt?.c1y ?? ($ === 0 ? ot.y + E.sny * Lt : ot.y), jt = zt?.c2x ?? ($ === et ? st.x + E.tnx * Lt : st.x - (st.x - ot.x) * 0.4), Et = zt?.c2y ?? ($ === et ? st.y + E.tny * Lt : st.y), Ct = Math.hypot(L - he, M - $t);
|
|
130
|
+
Ct < A && (A = Ct, W = {
|
|
131
|
+
edgeId: N.id,
|
|
132
132
|
segmentIndex: $,
|
|
133
133
|
controlEnd: "c1",
|
|
134
|
-
wx:
|
|
135
|
-
wy:
|
|
134
|
+
wx: he,
|
|
135
|
+
wy: $t
|
|
136
136
|
});
|
|
137
|
-
const gt = Math.hypot(
|
|
138
|
-
gt <
|
|
139
|
-
edgeId:
|
|
137
|
+
const gt = Math.hypot(L - jt, M - Et);
|
|
138
|
+
gt < A && (A = gt, W = {
|
|
139
|
+
edgeId: N.id,
|
|
140
140
|
segmentIndex: $,
|
|
141
141
|
controlEnd: "c2",
|
|
142
|
-
wx:
|
|
142
|
+
wx: jt,
|
|
143
143
|
wy: Et
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
return
|
|
147
|
+
return W;
|
|
148
148
|
}
|
|
149
|
-
function _n(
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
152
|
-
const
|
|
149
|
+
function _n(L, M, H, U) {
|
|
150
|
+
const D = St(H, U);
|
|
151
|
+
if (!D) return 0;
|
|
152
|
+
const W = H.data.waypoints ?? [], A = [
|
|
153
153
|
{
|
|
154
|
-
x:
|
|
155
|
-
y:
|
|
154
|
+
x: D.sx,
|
|
155
|
+
y: D.sy
|
|
156
156
|
},
|
|
157
|
-
...
|
|
157
|
+
...W,
|
|
158
158
|
{
|
|
159
|
-
x:
|
|
160
|
-
y:
|
|
159
|
+
x: D.tx,
|
|
160
|
+
y: D.ty
|
|
161
161
|
}
|
|
162
162
|
];
|
|
163
|
-
let
|
|
164
|
-
for (let q = 0; q <
|
|
165
|
-
const j = Le(
|
|
166
|
-
j <
|
|
163
|
+
let N = 1 / 0, E = 0;
|
|
164
|
+
for (let q = 0; q < A.length - 1; q++) {
|
|
165
|
+
const j = Le(L, M, A[q].x, A[q].y, A[q + 1].x, A[q + 1].y);
|
|
166
|
+
j < N && (N = j, E = q);
|
|
167
167
|
}
|
|
168
|
-
return
|
|
168
|
+
return E;
|
|
169
169
|
}
|
|
170
|
-
function On(
|
|
171
|
-
let { x:
|
|
172
|
-
const q = M === "nw" || M === "sw", j = M === "ne" || M === "se", lt = M === "nw" || M === "ne",
|
|
173
|
-
return q && (
|
|
174
|
-
x:
|
|
175
|
-
y:
|
|
176
|
-
w:
|
|
177
|
-
h:
|
|
170
|
+
function On(L, M, H, U, D = 24) {
|
|
171
|
+
let { x: W, y: A, w: N, h: E } = { ...L };
|
|
172
|
+
const q = M === "nw" || M === "sw", j = M === "ne" || M === "se", lt = M === "nw" || M === "ne", et = M === "sw" || M === "se";
|
|
173
|
+
return q && (W += H, N -= H), j && (N += H), lt && (A += U, E -= U), et && (E += U), N < D && (q && (W = L.x + L.w - D), N = D), E < D && (lt && (A = L.y + L.h - D), E = D), {
|
|
174
|
+
x: W,
|
|
175
|
+
y: A,
|
|
176
|
+
w: N,
|
|
177
|
+
h: E
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
function Ae(
|
|
181
|
-
const
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
for (let
|
|
180
|
+
function Ae(L, M, H, U, D) {
|
|
181
|
+
const W = St(H, U);
|
|
182
|
+
if (!W) return !1;
|
|
183
|
+
const A = mn(wn(H.type, W, H.data.waypoints, H.data.bezierControls));
|
|
184
|
+
for (let N = 0; N < A.length - 1; N++) if (Le(L, M, A[N].x, A[N].y, A[N + 1].x, A[N + 1].y) < D) return !0;
|
|
185
185
|
return !1;
|
|
186
186
|
}
|
|
187
|
-
function gn(
|
|
188
|
-
const
|
|
189
|
-
for (let
|
|
187
|
+
function gn(L, M, H, U) {
|
|
188
|
+
const D = H.points;
|
|
189
|
+
for (let W = 0; W < D.length - 1; W++) if (Le(L, M, D[W].x, D[W].y, D[W + 1].x, D[W + 1].y) < U) return !0;
|
|
190
190
|
return !1;
|
|
191
191
|
}
|
|
192
|
-
function fr({ onPixiReady:
|
|
193
|
-
const M =
|
|
194
|
-
U.current = f.gridDot,
|
|
195
|
-
}, [])), { setViewportInternal:
|
|
192
|
+
function fr({ onPixiReady: L }) {
|
|
193
|
+
const M = m(null), H = m(null), U = m(13751771), { pixiRef: D, readyRef: W } = Sn(M, le((f) => {
|
|
194
|
+
U.current = f.gridDot, H.current && (H.current.dotColor = f.gridDot);
|
|
195
|
+
}, [])), { setViewportInternal: A, viewportReqRef: N, viewport: E, autoFocus: q, showGrid: j, showAnchors: lt, gridSize: et, toolMode: $, edgeType: ot, focusOnRect: st, setFocusOnRect: zt, pendingPlacement: Ut, setPendingPlacement: Lt, setContextMenu: he, beginNodeDrag: $t, endNodeDrag: jt, presentation: Et, editingNodeId: Ct, setEditingNodeId: gt, readOnly: Ge, placementSnap: We } = Rn(), { currentCanvas: Ie, selection: Ye, setSelection: pt, setDoc: tt, currentCanvasId: be, pushCanvas: In, doc: Xe } = Mn(), _e = Yn(), Oe = m(_e);
|
|
196
196
|
Oe.current = _e;
|
|
197
|
-
const Fe =
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
const Nt =
|
|
202
|
-
Nt.current =
|
|
203
|
-
const kt =
|
|
197
|
+
const Fe = m(null), Jt = m(Ge);
|
|
198
|
+
Jt.current = Ge;
|
|
199
|
+
const Qt = m(We);
|
|
200
|
+
Qt.current = We;
|
|
201
|
+
const Nt = m(et);
|
|
202
|
+
Nt.current = et;
|
|
203
|
+
const kt = m(null), ye = m(null), pe = m(null), xe = m(null), Me = m(null), Re = m(null), Tt = m(null), te = m(null), ee = m(null), ge = m(null), Gt = m([]), Wt = m(null), Yt = m(null), ut = m(null), ne = m(null), Be = m({
|
|
204
204
|
time: 0,
|
|
205
205
|
wx: 0,
|
|
206
206
|
wy: 0
|
|
207
|
-
}),
|
|
207
|
+
}), Xt = m({
|
|
208
208
|
time: 0,
|
|
209
209
|
wx: 0,
|
|
210
210
|
wy: 0
|
|
211
|
-
}), Ve =
|
|
211
|
+
}), Ve = m(0), re = m(null), qe = m({
|
|
212
212
|
x: 0,
|
|
213
213
|
y: 0
|
|
214
|
-
}), Ze = lt || Et ?
|
|
215
|
-
...
|
|
216
|
-
nodes:
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
const Z =
|
|
220
|
-
Z.current =
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
const Ke =
|
|
214
|
+
}), Ze = lt || Et ? Ie : {
|
|
215
|
+
...Ie,
|
|
216
|
+
nodes: Ie.nodes.filter((f) => f.type !== "animAnchor")
|
|
217
|
+
}, X = m(Ze);
|
|
218
|
+
X.current = Ze;
|
|
219
|
+
const Z = m(be);
|
|
220
|
+
Z.current = be;
|
|
221
|
+
const oe = m(Ye);
|
|
222
|
+
oe.current = Ye;
|
|
223
|
+
const Ke = m(Xe);
|
|
224
224
|
Ke.current = Xe;
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
const Ue =
|
|
232
|
-
Ue.current =
|
|
233
|
-
const $e =
|
|
225
|
+
const se = m($);
|
|
226
|
+
se.current = $;
|
|
227
|
+
const ie = m(q);
|
|
228
|
+
ie.current = q;
|
|
229
|
+
const ce = m(st);
|
|
230
|
+
ce.current = st;
|
|
231
|
+
const Ue = m(ot);
|
|
232
|
+
Ue.current = ot;
|
|
233
|
+
const $e = m(lt);
|
|
234
234
|
$e.current = lt;
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const Se =
|
|
240
|
-
Se.current =
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
const
|
|
235
|
+
const Dt = m(Et);
|
|
236
|
+
Dt.current = Et;
|
|
237
|
+
const de = m(Ut);
|
|
238
|
+
de.current = Ut;
|
|
239
|
+
const Se = m($t);
|
|
240
|
+
Se.current = $t;
|
|
241
|
+
const Ht = m(jt);
|
|
242
|
+
Ht.current = jt;
|
|
243
|
+
const it = m(null), nt = m(null), rt = m(null), ft = m(null), ct = m(null), wt = m(null), xt = m(null), mt = m(null), ze = m(E), Ee = m(0), { vmRef: B, screenToWorld: je } = zn(D, le((f) => {
|
|
244
244
|
ze.current = f, Ee.current || (Ee.current = requestAnimationFrame(() => {
|
|
245
|
-
Ee.current = 0,
|
|
245
|
+
Ee.current = 0, A(ze.current);
|
|
246
246
|
}));
|
|
247
|
-
}, [
|
|
248
|
-
|
|
249
|
-
const [ht, Ce] = ln(null), [Ne, ke] = ln(null), Te =
|
|
247
|
+
}, [A])), dt = m(je);
|
|
248
|
+
dt.current = je;
|
|
249
|
+
const [ht, Ce] = ln(null), [Ne, ke] = ln(null), Te = m(ht);
|
|
250
250
|
Te.current = ht;
|
|
251
|
-
const
|
|
251
|
+
const we = m(() => {
|
|
252
252
|
});
|
|
253
|
-
|
|
254
|
-
gt(f === "node" ?
|
|
253
|
+
we.current = (f, G, F) => {
|
|
254
|
+
gt(f === "node" ? G : null), Ce({
|
|
255
255
|
kind: f,
|
|
256
|
-
id:
|
|
257
|
-
value:
|
|
256
|
+
id: G,
|
|
257
|
+
value: F
|
|
258
258
|
});
|
|
259
259
|
};
|
|
260
|
-
const Je =
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
if (!K) return
|
|
260
|
+
const Je = le((f) => {
|
|
261
|
+
const G = Te.current;
|
|
262
|
+
G && (tt((F) => {
|
|
263
|
+
const Y = Z.current, K = F.canvases[Y];
|
|
264
|
+
if (!K) return F;
|
|
265
265
|
let V = K;
|
|
266
|
-
if (
|
|
266
|
+
if (G.kind === "node") V = {
|
|
267
267
|
...K,
|
|
268
|
-
nodes: K.nodes.map((
|
|
269
|
-
...
|
|
268
|
+
nodes: K.nodes.map((O) => O.id === G.id ? {
|
|
269
|
+
...O,
|
|
270
270
|
data: {
|
|
271
|
-
...
|
|
271
|
+
...O.data,
|
|
272
272
|
label: f
|
|
273
273
|
}
|
|
274
|
-
} :
|
|
274
|
+
} : O)
|
|
275
275
|
};
|
|
276
|
-
else if (
|
|
276
|
+
else if (G.kind === "edge") V = {
|
|
277
277
|
...K,
|
|
278
|
-
edges: K.edges.map((
|
|
279
|
-
...
|
|
278
|
+
edges: K.edges.map((O) => O.id === G.id ? {
|
|
279
|
+
...O,
|
|
280
280
|
data: {
|
|
281
|
-
...
|
|
281
|
+
...O.data,
|
|
282
282
|
labelText: f
|
|
283
283
|
}
|
|
284
|
-
} :
|
|
284
|
+
} : O)
|
|
285
285
|
};
|
|
286
|
-
else return
|
|
286
|
+
else return F;
|
|
287
287
|
return {
|
|
288
|
-
...
|
|
288
|
+
...F,
|
|
289
289
|
canvases: {
|
|
290
|
-
...
|
|
291
|
-
[
|
|
290
|
+
...F.canvases,
|
|
291
|
+
[Y]: V
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
294
|
}), Ce(null), gt(null), ke(null));
|
|
295
|
-
}, [
|
|
295
|
+
}, [tt, gt]), bn = le(() => {
|
|
296
296
|
Ce(null), gt(null), ke(null);
|
|
297
297
|
}, [gt]);
|
|
298
298
|
Rt(() => {
|
|
299
299
|
if (!Ct || Te.current?.id === Ct) return;
|
|
300
|
-
const f =
|
|
301
|
-
f &&
|
|
300
|
+
const f = X.current.nodes.find((G) => G.id === Ct);
|
|
301
|
+
f && we.current("node", f.id, f.data.label);
|
|
302
302
|
}, [Ct]), Rt(() => {
|
|
303
303
|
if (!ht) return;
|
|
304
|
-
const f =
|
|
304
|
+
const f = B.current;
|
|
305
305
|
if (!f) return;
|
|
306
|
-
const
|
|
307
|
-
let
|
|
306
|
+
const G = X.current;
|
|
307
|
+
let F = null;
|
|
308
308
|
if (ht.kind === "node") {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
x:
|
|
312
|
-
y:
|
|
309
|
+
const Y = G.nodes.find((K) => K.id === ht.id);
|
|
310
|
+
Y && (F = {
|
|
311
|
+
x: Y.position.x + Y.width / 2,
|
|
312
|
+
y: Y.position.y + Y.height / 2
|
|
313
313
|
});
|
|
314
314
|
} else if (ht.kind === "edge") {
|
|
315
|
-
const
|
|
316
|
-
for (const V of
|
|
317
|
-
if (
|
|
318
|
-
const V = St(
|
|
315
|
+
const Y = G.edges.find((V) => V.id === ht.id), K = /* @__PURE__ */ new Map();
|
|
316
|
+
for (const V of G.nodes) K.set(V.id, V);
|
|
317
|
+
if (Y) {
|
|
318
|
+
const V = St(Y, K);
|
|
319
319
|
if (V) {
|
|
320
|
-
const
|
|
320
|
+
const O = mn(wn(Y.type, V, Y.data.waypoints, Y.data.bezierControls)), at = O[Math.floor(O.length / 2)] ?? {
|
|
321
321
|
x: (V.sx + V.tx) / 2,
|
|
322
322
|
y: (V.sy + V.ty) / 2
|
|
323
323
|
};
|
|
324
|
-
|
|
325
|
-
x:
|
|
326
|
-
y:
|
|
324
|
+
F = {
|
|
325
|
+
x: at.x,
|
|
326
|
+
y: at.y
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
|
-
if (
|
|
332
|
-
const
|
|
331
|
+
if (F) {
|
|
332
|
+
const Y = f.worldToScreen(F.x, F.y);
|
|
333
333
|
ke({
|
|
334
|
-
x:
|
|
335
|
-
y:
|
|
334
|
+
x: Y.x,
|
|
335
|
+
y: Y.y
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
|
-
}, [ht,
|
|
339
|
-
const Qe =
|
|
338
|
+
}, [ht, B]);
|
|
339
|
+
const Qe = m(0);
|
|
340
340
|
Rt(() => {
|
|
341
|
-
|
|
341
|
+
N.current !== Qe.current && (Qe.current = N.current, ze.current = E, B.current?.setState(E));
|
|
342
342
|
}, [
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
343
|
+
E,
|
|
344
|
+
B,
|
|
345
|
+
N
|
|
346
346
|
]), Rt(() => {
|
|
347
|
-
zt((f,
|
|
348
|
-
const V =
|
|
349
|
-
if (!V || !
|
|
350
|
-
const
|
|
347
|
+
zt((f, G, F, Y, K) => {
|
|
348
|
+
const V = B.current, O = M.current;
|
|
349
|
+
if (!V || !O) return;
|
|
350
|
+
const at = O.clientWidth || 800, vt = O.clientHeight || 600, It = Math.max(0, K?.padding ?? 60), _t = Math.max(1, at - It * 2), bt = Math.max(1, vt - It * 2), Pt = K?.preserveZoom ? V.state.zoom : Math.min(_t / Math.max(F, 1), bt / Math.max(Y, 1), K?.maxZoom ?? 2), At = f + F / 2, yt = G + Y / 2, ae = at / 2 - At * Pt, He = vt / 2 - yt * Pt;
|
|
351
351
|
V.animateTo({
|
|
352
|
-
x:
|
|
352
|
+
x: ae,
|
|
353
353
|
y: He,
|
|
354
|
-
zoom:
|
|
354
|
+
zoom: Pt
|
|
355
355
|
}, K?.duration ?? 350);
|
|
356
356
|
});
|
|
357
|
-
}, [zt,
|
|
358
|
-
const tn =
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
return
|
|
362
|
-
...
|
|
357
|
+
}, [zt, B]);
|
|
358
|
+
const tn = le((f) => {
|
|
359
|
+
tt((G) => {
|
|
360
|
+
const F = G.canvases[Z.current];
|
|
361
|
+
return F ? {
|
|
362
|
+
...G,
|
|
363
363
|
canvases: {
|
|
364
|
-
...
|
|
364
|
+
...G.canvases,
|
|
365
365
|
[Z.current]: {
|
|
366
|
-
...
|
|
367
|
-
lines: [...
|
|
366
|
+
...F,
|
|
367
|
+
lines: [...F.lines, f]
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
-
} :
|
|
370
|
+
} : G;
|
|
371
371
|
});
|
|
372
|
-
}, [
|
|
372
|
+
}, [tt, be]), De = m(tn);
|
|
373
373
|
return De.current = tn, Rt(() => {
|
|
374
|
-
const f =
|
|
374
|
+
const f = D.current;
|
|
375
375
|
if (!f || f.destroyed) return;
|
|
376
|
-
let
|
|
376
|
+
let G = !1, F = null, Y = null, K = null;
|
|
377
377
|
const V = () => {
|
|
378
|
-
if (
|
|
379
|
-
if (!
|
|
378
|
+
if (G) return;
|
|
379
|
+
if (!W.current) {
|
|
380
380
|
setTimeout(V, 30);
|
|
381
381
|
return;
|
|
382
382
|
}
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
const vt = new
|
|
389
|
-
vt.label = "handle-hover", f.world.addChild(vt),
|
|
390
|
-
const It = new
|
|
391
|
-
It.label = "edge-edit-handles", f.world.addChild(It),
|
|
392
|
-
const
|
|
393
|
-
|
|
383
|
+
H.current = new En(f.app.stage, et, j), H.current.dotColor = U.current, kt.current = new Cn(f.app.stage), ye.current = new Tn(f.world), pe.current = new Dn(f.world), xe.current = new Hn(f.world);
|
|
384
|
+
const O = new ue();
|
|
385
|
+
O.label = "connect-line", O.visible = !1, f.world.addChild(O), wt.current = O;
|
|
386
|
+
const at = new ue();
|
|
387
|
+
at.label = "transform-handles", f.app.stage.addChild(at), te.current = at;
|
|
388
|
+
const vt = new ue();
|
|
389
|
+
vt.label = "handle-hover", f.world.addChild(vt), ee.current = vt;
|
|
390
|
+
const It = new ue();
|
|
391
|
+
It.label = "edge-edit-handles", f.world.addChild(It), ne.current = It;
|
|
392
|
+
const _t = new ue();
|
|
393
|
+
_t.label = "ghost-placement", _t.alpha = 0.5, f.world.addChild(_t), re.current = _t, ge.current = new Ln(f.world), Me.current = new Pn(f.app.stage, f.world, {
|
|
394
394
|
onLineComplete: (x) => De.current(x),
|
|
395
|
-
screenToWorld: (x,
|
|
396
|
-
}),
|
|
395
|
+
screenToWorld: (x, s) => dt.current(x, s)
|
|
396
|
+
}), Re.current = new An(f.app.stage, f.world, {
|
|
397
397
|
onLineComplete: (x) => De.current(x),
|
|
398
|
-
screenToWorld: (x,
|
|
399
|
-
}),
|
|
398
|
+
screenToWorld: (x, s) => dt.current(x, s)
|
|
399
|
+
}), L?.(f);
|
|
400
400
|
const bt = f.app.stage;
|
|
401
401
|
bt.on("pointerdown", (x) => {
|
|
402
|
-
if (M.current?.focus({ preventScroll: !0 }),
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
|
|
402
|
+
if (M.current?.focus({ preventScroll: !0 }), B.current?.multiTouchActive || B.current?.isPanning || B.current?.isSpaceHeld || x.button !== 0) return;
|
|
403
|
+
const s = se.current;
|
|
404
|
+
if (s === "pan") {
|
|
405
|
+
B.current?.startPan(x.global.x, x.global.y);
|
|
406
406
|
return;
|
|
407
407
|
}
|
|
408
|
-
if (
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
const
|
|
408
|
+
if (s === "freehand" || s === "line" || s === "polyline" || s === "arrow") return;
|
|
409
|
+
const c = dt.current(x.global.x, x.global.y), p = X.current.nodes, P = X.current.edges, k = X.current.lines, R = oe.current, S = x.metaKey || x.ctrlKey || x.shiftKey, T = B.current?.state.zoom ?? 1;
|
|
410
|
+
if (de.current) return;
|
|
411
|
+
const r = Date.now(), h = Be.current, l = r - h.time < 350 && Math.hypot(c.x - h.wx, c.y - h.wy) < 8 / T;
|
|
412
412
|
if (Be.current = {
|
|
413
|
-
time:
|
|
414
|
-
wx:
|
|
415
|
-
wy:
|
|
416
|
-
}, R.nodeIds.size === 1 && !S &&
|
|
417
|
-
const t =
|
|
413
|
+
time: r,
|
|
414
|
+
wx: c.x,
|
|
415
|
+
wy: c.y
|
|
416
|
+
}, R.nodeIds.size === 1 && !S && s === "select" && !Jt.current) {
|
|
417
|
+
const t = p.find((o) => o.id === [...R.nodeIds][0]);
|
|
418
418
|
if (t) {
|
|
419
|
-
const
|
|
420
|
-
if (Math.hypot(
|
|
419
|
+
const o = fn(t, T);
|
|
420
|
+
if (Math.hypot(c.x - o.x, c.y - o.y) < Q(T, 12, 24)) {
|
|
421
421
|
ft.current = {
|
|
422
422
|
active: !0,
|
|
423
423
|
nodeId: t.id,
|
|
424
424
|
cx: t.position.x + t.width / 2,
|
|
425
425
|
cy: t.position.y + t.height / 2,
|
|
426
|
-
startPointerAngle: Math.atan2(
|
|
426
|
+
startPointerAngle: Math.atan2(c.y - (t.position.y + t.height / 2), c.x - (t.position.x + t.width / 2)),
|
|
427
427
|
startRotation: t.data.rotation ?? 0
|
|
428
428
|
}, Se.current();
|
|
429
429
|
return;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
if (R.nodeIds.size === 1 && !S &&
|
|
434
|
-
const t =
|
|
433
|
+
if (R.nodeIds.size === 1 && !S && s === "select") {
|
|
434
|
+
const t = p.find((o) => o.id === [...R.nodeIds][0]);
|
|
435
435
|
if (t) {
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
for (const u of
|
|
440
|
-
u.id !== t.id && (u.parentId === t.id ?
|
|
436
|
+
const o = hn(c, t, Q(T, 10, 16));
|
|
437
|
+
if (o) {
|
|
438
|
+
const a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), n = t.type === "geometryGroup", d = n || t.type === "flowGroup" || t.data.isGroup, w = t.position.x, g = t.position.y, z = t.width, C = t.height;
|
|
439
|
+
for (const u of p)
|
|
440
|
+
u.id !== t.id && (u.parentId === t.id ? a.set(u.id, {
|
|
441
441
|
x: u.position.x,
|
|
442
442
|
y: u.position.y,
|
|
443
443
|
w: u.width,
|
|
444
444
|
h: u.height
|
|
445
|
-
}) :
|
|
445
|
+
}) : n && u.position.x >= w && u.position.y >= g && u.position.x + u.width <= w + z && u.position.y + u.height <= g + C && a.set(u.id, {
|
|
446
446
|
x: u.position.x,
|
|
447
447
|
y: u.position.y,
|
|
448
448
|
w: u.width,
|
|
449
449
|
h: u.height
|
|
450
450
|
}));
|
|
451
|
-
if (
|
|
452
|
-
for (const u of
|
|
451
|
+
if (d)
|
|
452
|
+
for (const u of X.current.lines) u.parentId === t.id ? i.set(u.id, u.points.map((b) => ({ ...b }))) : n && u.points.length > 0 && u.points.every((b) => b.x >= w && b.x <= w + z && b.y >= g && b.y <= g + C) && i.set(u.id, u.points.map((b) => ({ ...b })));
|
|
453
453
|
xt.current = {
|
|
454
454
|
active: !0,
|
|
455
455
|
nodeId: t.id,
|
|
456
|
-
handle:
|
|
457
|
-
startWorld:
|
|
456
|
+
handle: o,
|
|
457
|
+
startWorld: c,
|
|
458
458
|
startBounds: {
|
|
459
459
|
x: t.position.x,
|
|
460
460
|
y: t.position.y,
|
|
461
461
|
w: t.width,
|
|
462
462
|
h: t.height
|
|
463
463
|
},
|
|
464
|
-
childStarts:
|
|
465
|
-
childLineStarts:
|
|
464
|
+
childStarts: a,
|
|
465
|
+
childLineStarts: i.size > 0 ? i : void 0
|
|
466
466
|
};
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
let e = null;
|
|
472
|
-
for (let t =
|
|
473
|
-
e =
|
|
472
|
+
for (let t = p.length - 1; t >= 0; t--) if (qt(c.x, c.y, p[t])) {
|
|
473
|
+
e = p[t];
|
|
474
474
|
break;
|
|
475
475
|
}
|
|
476
476
|
if (e?.parentId) {
|
|
477
|
-
const t =
|
|
477
|
+
const t = p.find((o) => o.id === e.parentId);
|
|
478
478
|
t && (e = t);
|
|
479
479
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
const
|
|
487
|
-
|
|
480
|
+
fe && (Tt.current = e ? e.parentId ? p.find((t) => t.id === e.parentId)?.id ?? e.id : e.id : null, Wt.current = null, Yt.current = null);
|
|
481
|
+
let I = !1;
|
|
482
|
+
if (e && s === "select" && (I = Math.min(c.x - e.position.x, e.position.x + e.width - c.x, c.y - e.position.y, e.position.y + e.height - c.y) > Math.min(14, Math.min(e.width, e.height) * 0.3)), (s === "select" || s === "connect") && (e || fe) && !I) {
|
|
483
|
+
const t = e ? [e] : p, o = Q(T, 14, 20);
|
|
484
|
+
let a = null, i = null, n = 1 / 0;
|
|
485
|
+
for (const d of t) {
|
|
486
|
+
const w = Bt(Mt(d.width, d.height), d, c.x, c.y, o);
|
|
487
|
+
if (!w) continue;
|
|
488
|
+
const g = Vt(w, d), z = Math.hypot(c.x - g.x, c.y - g.y);
|
|
489
|
+
z < n && (n = z, a = d, i = w);
|
|
488
490
|
}
|
|
489
|
-
if (
|
|
490
|
-
|
|
491
|
+
if (a && i) {
|
|
492
|
+
rt.current = {
|
|
491
493
|
active: !0,
|
|
492
|
-
sourceNodeId:
|
|
493
|
-
sourceHandleId:
|
|
494
|
+
sourceNodeId: a.id,
|
|
495
|
+
sourceHandleId: i.id
|
|
494
496
|
};
|
|
495
497
|
return;
|
|
496
498
|
}
|
|
497
499
|
}
|
|
498
|
-
if ((
|
|
500
|
+
if ((s === "select" || s === "connect") && !S && R.edgeIds.size > 0) {
|
|
499
501
|
const t = /* @__PURE__ */ new Map();
|
|
500
|
-
for (const
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
const
|
|
502
|
+
for (const i of p) t.set(i.id, i);
|
|
503
|
+
const o = P.filter((i) => R.edgeIds.has(i.id)), a = yn(c.x, c.y, o, t, Q(T, 14, 20));
|
|
504
|
+
if (a) {
|
|
505
|
+
const i = P.find((n) => n.id === a.edgeId);
|
|
506
|
+
if (i) {
|
|
507
|
+
const n = a.end === "source" ? "target" : "source";
|
|
506
508
|
ct.current = {
|
|
507
509
|
active: !0,
|
|
508
|
-
edgeId:
|
|
509
|
-
movingEnd:
|
|
510
|
-
fixedNodeId:
|
|
511
|
-
fixedHandleId:
|
|
510
|
+
edgeId: i.id,
|
|
511
|
+
movingEnd: a.end,
|
|
512
|
+
fixedNodeId: n === "source" ? i.source : i.target,
|
|
513
|
+
fixedHandleId: n === "source" ? i.sourceHandle : i.targetHandle
|
|
512
514
|
};
|
|
513
515
|
return;
|
|
514
516
|
}
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
|
-
if (
|
|
519
|
+
if (s === "select" && R.edgeIds.size > 0 && !e) {
|
|
518
520
|
const t = /* @__PURE__ */ new Map();
|
|
519
|
-
for (const
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
521
|
+
for (const d of p) t.set(d.id, d);
|
|
522
|
+
const o = P.filter((d) => R.edgeIds.has(d.id)), a = Q(T, 10, 14), i = xn(c.x, c.y, o, t, a);
|
|
523
|
+
if (i) {
|
|
522
524
|
ut.current = {
|
|
523
525
|
active: !0,
|
|
524
|
-
edgeId:
|
|
525
|
-
type:
|
|
526
|
-
index:
|
|
526
|
+
edgeId: i.edgeId,
|
|
527
|
+
type: i.controlEnd === "c1" ? "bezierC1" : "bezierC2",
|
|
528
|
+
index: i.segmentIndex
|
|
527
529
|
};
|
|
528
530
|
return;
|
|
529
531
|
}
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
+
const n = pn(c.x, c.y, o, a);
|
|
533
|
+
if (n) {
|
|
532
534
|
if (l) {
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
return
|
|
536
|
-
...
|
|
535
|
+
tt((d) => {
|
|
536
|
+
const w = d.canvases[Z.current];
|
|
537
|
+
return w ? {
|
|
538
|
+
...d,
|
|
537
539
|
canvases: {
|
|
538
|
-
...
|
|
540
|
+
...d.canvases,
|
|
539
541
|
[Z.current]: {
|
|
540
|
-
...
|
|
541
|
-
edges:
|
|
542
|
-
if (g.id !==
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
const
|
|
542
|
+
...w,
|
|
543
|
+
edges: w.edges.map((g) => {
|
|
544
|
+
if (g.id !== n.edgeId) return g;
|
|
545
|
+
const z = [...g.data.waypoints ?? []];
|
|
546
|
+
z.splice(n.waypointIndex, 1);
|
|
547
|
+
const C = {
|
|
546
548
|
...g.data,
|
|
547
|
-
waypoints:
|
|
549
|
+
waypoints: z.length > 0 ? z : void 0
|
|
548
550
|
};
|
|
549
551
|
if (g.type === "simplebezier" && g.data.bezierControls) {
|
|
550
552
|
const u = [...g.data.bezierControls];
|
|
551
|
-
u.splice(
|
|
553
|
+
u.splice(n.waypointIndex, 2, null), C.bezierControls = u.some((b) => b !== null) ? u : void 0;
|
|
552
554
|
}
|
|
553
555
|
return {
|
|
554
556
|
...g,
|
|
555
|
-
data:
|
|
557
|
+
data: C
|
|
556
558
|
};
|
|
557
559
|
})
|
|
558
560
|
}
|
|
559
561
|
}
|
|
560
|
-
} :
|
|
562
|
+
} : d;
|
|
561
563
|
});
|
|
562
564
|
return;
|
|
563
565
|
}
|
|
564
566
|
ut.current = {
|
|
565
567
|
active: !0,
|
|
566
|
-
edgeId:
|
|
568
|
+
edgeId: n.edgeId,
|
|
567
569
|
type: "waypoint",
|
|
568
|
-
index:
|
|
570
|
+
index: n.waypointIndex
|
|
569
571
|
};
|
|
570
572
|
return;
|
|
571
573
|
}
|
|
572
574
|
if (l) {
|
|
573
|
-
for (const
|
|
574
|
-
const
|
|
575
|
-
x:
|
|
576
|
-
y:
|
|
575
|
+
for (const d of o) if (Ae(c.x, c.y, d, t, Q(T, 8, 12))) {
|
|
576
|
+
const w = _n(c.x, c.y, d, t), g = {
|
|
577
|
+
x: c.x,
|
|
578
|
+
y: c.y
|
|
577
579
|
};
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
return
|
|
581
|
-
...
|
|
580
|
+
tt((z) => {
|
|
581
|
+
const C = z.canvases[Z.current];
|
|
582
|
+
return C ? {
|
|
583
|
+
...z,
|
|
582
584
|
canvases: {
|
|
583
|
-
...
|
|
585
|
+
...z.canvases,
|
|
584
586
|
[Z.current]: {
|
|
585
|
-
...
|
|
586
|
-
edges:
|
|
587
|
-
if (u.id !==
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
const
|
|
587
|
+
...C,
|
|
588
|
+
edges: C.edges.map((u) => {
|
|
589
|
+
if (u.id !== d.id) return u;
|
|
590
|
+
const b = [...u.data.waypoints ?? []];
|
|
591
|
+
b.splice(w, 0, g);
|
|
592
|
+
const _ = {
|
|
591
593
|
...u.data,
|
|
592
|
-
waypoints:
|
|
594
|
+
waypoints: b
|
|
593
595
|
};
|
|
594
596
|
if (u.type === "simplebezier" && u.data.bezierControls) {
|
|
595
|
-
const
|
|
596
|
-
for (;
|
|
597
|
-
|
|
597
|
+
const J = [...u.data.bezierControls];
|
|
598
|
+
for (; J.length < (u.data.waypoints ?? []).length + 1; ) J.push(null);
|
|
599
|
+
J.splice(w, 1, null, null), _.bezierControls = J;
|
|
598
600
|
}
|
|
599
601
|
return {
|
|
600
602
|
...u,
|
|
601
|
-
data:
|
|
603
|
+
data: _
|
|
602
604
|
};
|
|
603
605
|
})
|
|
604
606
|
}
|
|
605
607
|
}
|
|
606
|
-
} :
|
|
608
|
+
} : z;
|
|
607
609
|
}), ut.current = {
|
|
608
610
|
active: !0,
|
|
609
|
-
edgeId:
|
|
611
|
+
edgeId: d.id,
|
|
610
612
|
type: "waypoint",
|
|
611
|
-
index:
|
|
613
|
+
index: w
|
|
612
614
|
};
|
|
613
615
|
return;
|
|
614
616
|
}
|
|
615
617
|
}
|
|
616
618
|
}
|
|
617
|
-
if (e && (
|
|
619
|
+
if (e && (s === "select" || s === "connect")) {
|
|
618
620
|
!S && !R.nodeIds.has(e.id) ? pt({
|
|
619
621
|
nodeIds: /* @__PURE__ */ new Set([e.id]),
|
|
620
622
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
621
623
|
lineIds: /* @__PURE__ */ new Set()
|
|
622
|
-
}) : S && pt((
|
|
623
|
-
const
|
|
624
|
-
return
|
|
625
|
-
nodeIds:
|
|
624
|
+
}) : S && pt((n) => {
|
|
625
|
+
const d = new Set(n.nodeIds);
|
|
626
|
+
return d.has(e.id) ? d.delete(e.id) : d.add(e.id), {
|
|
627
|
+
nodeIds: d,
|
|
626
628
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
627
629
|
lineIds: /* @__PURE__ */ new Set()
|
|
628
630
|
};
|
|
629
|
-
}),
|
|
631
|
+
}), ie.current && ce.current(e.position.x, e.position.y, e.width, e.height, {
|
|
630
632
|
padding: 80,
|
|
631
633
|
preserveZoom: !0,
|
|
632
634
|
duration: 280
|
|
633
635
|
});
|
|
634
636
|
const t = R.nodeIds.has(e.id) ? new Set(R.nodeIds) : /* @__PURE__ */ new Set([e.id]);
|
|
635
637
|
S && !R.nodeIds.has(e.id) && t.add(e.id);
|
|
636
|
-
const
|
|
637
|
-
for (const
|
|
638
|
-
const
|
|
639
|
-
if (!
|
|
640
|
-
const
|
|
641
|
-
for (const
|
|
642
|
-
if (!(t.has(
|
|
643
|
-
if (
|
|
644
|
-
t.add(
|
|
638
|
+
const o = /* @__PURE__ */ new Set();
|
|
639
|
+
for (const n of [...t]) {
|
|
640
|
+
const d = p.find((b) => b.id === n);
|
|
641
|
+
if (!d || d.type !== "flowGroup" && d.type !== "geometryGroup" && !d.data.isGroup) continue;
|
|
642
|
+
const w = d.type === "geometryGroup", g = d.position.x, z = d.position.y, C = d.width, u = d.height;
|
|
643
|
+
for (const b of p)
|
|
644
|
+
if (!(t.has(b.id) || b.id === n)) {
|
|
645
|
+
if (b.parentId === n) {
|
|
646
|
+
t.add(b.id);
|
|
645
647
|
continue;
|
|
646
648
|
}
|
|
647
|
-
|
|
649
|
+
w && b.position.x >= g && b.position.y >= z && b.position.x + b.width <= g + C && b.position.y + b.height <= z + u && t.add(b.id);
|
|
648
650
|
}
|
|
649
|
-
for (const
|
|
650
|
-
if (
|
|
651
|
-
|
|
651
|
+
for (const b of X.current.lines) b.parentId === n && o.add(b.id);
|
|
652
|
+
if (w) for (const b of X.current.lines)
|
|
653
|
+
o.has(b.id) || b.points.length > 0 && b.points.every((_) => _.x >= g && _.x <= g + C && _.y >= z && _.y <= z + u) && o.add(b.id);
|
|
652
654
|
}
|
|
653
|
-
const i = /* @__PURE__ */ new Map();
|
|
654
|
-
for (const o of y) t.has(o.id) && i.set(o.id, { ...o.position });
|
|
655
655
|
const a = /* @__PURE__ */ new Map();
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
656
|
+
for (const n of p) t.has(n.id) && a.set(n.id, { ...n.position });
|
|
657
|
+
const i = /* @__PURE__ */ new Map();
|
|
658
|
+
if (o.size > 0)
|
|
659
|
+
for (const n of X.current.lines) o.has(n.id) && i.set(n.id, n.points.map((d) => ({ ...d })));
|
|
660
|
+
it.current = {
|
|
659
661
|
active: !0,
|
|
660
662
|
nodeIds: t,
|
|
661
|
-
lineIds:
|
|
662
|
-
startWorld:
|
|
663
|
-
nodeStarts:
|
|
664
|
-
linePointStarts:
|
|
663
|
+
lineIds: o.size > 0 ? o : void 0,
|
|
664
|
+
startWorld: c,
|
|
665
|
+
nodeStarts: a,
|
|
666
|
+
linePointStarts: i.size > 0 ? i : void 0
|
|
665
667
|
}, Se.current();
|
|
666
668
|
return;
|
|
667
669
|
}
|
|
668
|
-
const
|
|
669
|
-
for (const t of
|
|
670
|
-
const
|
|
671
|
-
for (const t of
|
|
672
|
-
if (pt(S ? (
|
|
673
|
-
const
|
|
674
|
-
return
|
|
675
|
-
...
|
|
676
|
-
edgeIds:
|
|
670
|
+
const y = /* @__PURE__ */ new Map();
|
|
671
|
+
for (const t of p) y.set(t.id, t);
|
|
672
|
+
const v = Q(T, 8, 12);
|
|
673
|
+
for (const t of P) if (Ae(c.x, c.y, t, y, v)) {
|
|
674
|
+
if (pt(S ? (o) => {
|
|
675
|
+
const a = new Set(o.edgeIds);
|
|
676
|
+
return a.has(t.id) ? a.delete(t.id) : a.add(t.id), {
|
|
677
|
+
...o,
|
|
678
|
+
edgeIds: a
|
|
677
679
|
};
|
|
678
680
|
} : {
|
|
679
681
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
680
682
|
edgeIds: /* @__PURE__ */ new Set([t.id]),
|
|
681
683
|
lineIds: /* @__PURE__ */ new Set()
|
|
682
|
-
}),
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
const
|
|
686
|
-
|
|
684
|
+
}), ie.current) {
|
|
685
|
+
const o = y.get(t.source), a = y.get(t.target);
|
|
686
|
+
if (o && a) {
|
|
687
|
+
const i = Math.min(o.position.x, a.position.x), n = Math.min(o.position.y, a.position.y), d = Math.max(o.position.x + o.width, a.position.x + a.width), w = Math.max(o.position.y + o.height, a.position.y + a.height);
|
|
688
|
+
ce.current(i, n, d - i, w - n, {
|
|
687
689
|
padding: 80,
|
|
688
690
|
preserveZoom: !0,
|
|
689
691
|
duration: 280
|
|
@@ -692,33 +694,33 @@ function fr({ onPixiReady: A }) {
|
|
|
692
694
|
}
|
|
693
695
|
return;
|
|
694
696
|
}
|
|
695
|
-
for (const t of
|
|
696
|
-
const
|
|
697
|
-
if (S ? pt((
|
|
698
|
-
const
|
|
699
|
-
return
|
|
700
|
-
...
|
|
701
|
-
lineIds:
|
|
697
|
+
for (const t of k) if (gn(c.x, c.y, t, v)) {
|
|
698
|
+
const o = R.lineIds.has(t.id);
|
|
699
|
+
if (S ? pt((n) => {
|
|
700
|
+
const d = new Set(n.lineIds);
|
|
701
|
+
return d.has(t.id) ? d.delete(t.id) : d.add(t.id), {
|
|
702
|
+
...n,
|
|
703
|
+
lineIds: d
|
|
702
704
|
};
|
|
703
|
-
}) :
|
|
705
|
+
}) : o || pt({
|
|
704
706
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
705
707
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
706
708
|
lineIds: /* @__PURE__ */ new Set([t.id])
|
|
707
|
-
}),
|
|
708
|
-
const
|
|
709
|
-
|
|
709
|
+
}), ie.current && t.points.length > 0) {
|
|
710
|
+
const n = t.points.map((u) => u.x), d = t.points.map((u) => u.y), w = Math.min(...n), g = Math.min(...d), z = Math.max(...n), C = Math.max(...d);
|
|
711
|
+
ce.current(w, g, Math.max(1, z - w), Math.max(1, C - g), {
|
|
710
712
|
padding: 80,
|
|
711
713
|
preserveZoom: !0,
|
|
712
714
|
duration: 280
|
|
713
715
|
});
|
|
714
716
|
}
|
|
715
|
-
const
|
|
716
|
-
for (const
|
|
717
|
+
const a = o ? new Set(R.lineIds) : /* @__PURE__ */ new Set([t.id]), i = /* @__PURE__ */ new Map();
|
|
718
|
+
for (const n of k) a.has(n.id) && i.set(n.id, n.points.map((d) => ({ ...d })));
|
|
717
719
|
mt.current = {
|
|
718
720
|
active: !0,
|
|
719
|
-
lineIds:
|
|
720
|
-
startWorld:
|
|
721
|
-
pointStarts:
|
|
721
|
+
lineIds: a,
|
|
722
|
+
startWorld: c,
|
|
723
|
+
pointStarts: i
|
|
722
724
|
};
|
|
723
725
|
return;
|
|
724
726
|
}
|
|
@@ -726,7 +728,7 @@ function fr({ onPixiReady: A }) {
|
|
|
726
728
|
nodeIds: /* @__PURE__ */ new Set(),
|
|
727
729
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
728
730
|
lineIds: /* @__PURE__ */ new Set()
|
|
729
|
-
}),
|
|
731
|
+
}), s === "select" && (nt.current = {
|
|
730
732
|
active: !0,
|
|
731
733
|
startScreen: {
|
|
732
734
|
x: x.global.x,
|
|
@@ -734,75 +736,75 @@ function fr({ onPixiReady: A }) {
|
|
|
734
736
|
}
|
|
735
737
|
});
|
|
736
738
|
}), bt.on("globalpointermove", (x) => {
|
|
737
|
-
const
|
|
738
|
-
if (qe.current =
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
741
|
-
const
|
|
739
|
+
const s = dt.current(x.global.x, x.global.y);
|
|
740
|
+
if (qe.current = s, B.current?.multiTouchActive) return;
|
|
741
|
+
const c = se.current;
|
|
742
|
+
if (c === "freehand" || c === "line" || c === "polyline" || c === "arrow") return;
|
|
743
|
+
const p = X.current.nodes, P = X.current.edges, k = B.current?.state.zoom ?? 1, R = !it.current?.active && !rt.current?.active && !xt.current?.active && !ct.current?.active && !ut.current?.active && !mt.current?.active && !ft.current?.active;
|
|
742
744
|
let S = null;
|
|
743
|
-
for (let
|
|
744
|
-
const h =
|
|
745
|
-
S = h.parentId ?
|
|
745
|
+
for (let r = p.length - 1; r >= 0; r--) if (qt(s.x, s.y, p[r])) {
|
|
746
|
+
const h = p[r];
|
|
747
|
+
S = h.parentId ? p.find((l) => l.id === h.parentId)?.id ?? h.id : h.id;
|
|
746
748
|
break;
|
|
747
749
|
}
|
|
748
|
-
if (
|
|
749
|
-
const
|
|
750
|
-
for (const
|
|
751
|
-
const h =
|
|
752
|
-
|
|
750
|
+
if (Tt.current = S, R && (c === "select" || c === "connect")) {
|
|
751
|
+
const r = /* @__PURE__ */ new Map();
|
|
752
|
+
for (const y of p) r.set(y.id, y);
|
|
753
|
+
const h = oe.current, l = h.edgeIds.size > 0 ? P.filter((y) => h.edgeIds.has(y.id)) : [], e = l.length > 0 ? yn(s.x, s.y, l, r, Q(k, 12, 18)) : null;
|
|
754
|
+
Yt.current = e;
|
|
753
755
|
let I = null;
|
|
754
756
|
if (S) {
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
757
|
-
const
|
|
758
|
-
if (
|
|
759
|
-
const
|
|
757
|
+
const y = p.find((v) => v.id === S);
|
|
758
|
+
if (y) {
|
|
759
|
+
const v = Bt(Mt(y.width, y.height), y, s.x, s.y, Q(k, 14, 20));
|
|
760
|
+
if (v) {
|
|
761
|
+
const t = Vt(v, y);
|
|
760
762
|
I = {
|
|
761
|
-
nodeId:
|
|
762
|
-
handleId:
|
|
763
|
-
wx:
|
|
764
|
-
wy:
|
|
763
|
+
nodeId: y.id,
|
|
764
|
+
handleId: v.id,
|
|
765
|
+
wx: t.x,
|
|
766
|
+
wy: t.y
|
|
765
767
|
};
|
|
766
768
|
}
|
|
767
769
|
}
|
|
768
770
|
}
|
|
769
|
-
|
|
771
|
+
Wt.current = I;
|
|
770
772
|
}
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
const
|
|
773
|
+
const T = M.current;
|
|
774
|
+
if (T && R) {
|
|
775
|
+
const r = oe.current;
|
|
774
776
|
let h = "";
|
|
775
|
-
if (
|
|
776
|
-
else if (
|
|
777
|
-
else if (
|
|
778
|
-
const l =
|
|
779
|
-
for (const
|
|
780
|
-
const I =
|
|
781
|
-
(pn(
|
|
777
|
+
if (Yt.current) h = "crosshair";
|
|
778
|
+
else if (Wt.current) h = "crosshair";
|
|
779
|
+
else if (r.edgeIds.size > 0 && c === "select") {
|
|
780
|
+
const l = P.filter((y) => r.edgeIds.has(y.id)), e = /* @__PURE__ */ new Map();
|
|
781
|
+
for (const y of p) e.set(y.id, y);
|
|
782
|
+
const I = Q(k, 10, 14);
|
|
783
|
+
(pn(s.x, s.y, l, I) || xn(s.x, s.y, l, e, I)) && (h = "grab");
|
|
782
784
|
}
|
|
783
|
-
if (!h &&
|
|
784
|
-
const l =
|
|
785
|
+
if (!h && r.nodeIds.size === 1 && c === "select") {
|
|
786
|
+
const l = p.find((e) => e.id === [...r.nodeIds][0]);
|
|
785
787
|
if (l) {
|
|
786
|
-
const e = hn(
|
|
788
|
+
const e = hn(s, l, Q(k, 10, 16));
|
|
787
789
|
if (e) h = Xn[e];
|
|
788
|
-
else if (!
|
|
789
|
-
const I = fn(l,
|
|
790
|
-
Math.hypot(
|
|
790
|
+
else if (!Jt.current) {
|
|
791
|
+
const I = fn(l, k);
|
|
792
|
+
Math.hypot(s.x - I.x, s.y - I.y) < Q(k, 12, 24) && (h = "grab");
|
|
791
793
|
}
|
|
792
794
|
}
|
|
793
795
|
}
|
|
794
|
-
if (!h &&
|
|
795
|
-
const l =
|
|
796
|
-
for (const I of l) if (gn(
|
|
796
|
+
if (!h && c === "select") {
|
|
797
|
+
const l = X.current.lines, e = Q(k, 8, 12);
|
|
798
|
+
for (const I of l) if (gn(s.x, s.y, I, e)) {
|
|
797
799
|
h = "move";
|
|
798
800
|
break;
|
|
799
801
|
}
|
|
800
802
|
}
|
|
801
|
-
|
|
803
|
+
T.style.cursor = h;
|
|
802
804
|
}
|
|
803
805
|
if (xt.current?.active) {
|
|
804
|
-
const
|
|
805
|
-
id:
|
|
806
|
+
const r = xt.current, h = s.x - r.startWorld.x, l = s.y - r.startWorld.y, e = On(r.startBounds, r.handle, h, l), I = X.current.nodes, y = me([{
|
|
807
|
+
id: r.nodeId,
|
|
806
808
|
type: "shapeRect",
|
|
807
809
|
position: {
|
|
808
810
|
x: e.x,
|
|
@@ -812,50 +814,50 @@ function fr({ onPixiReady: A }) {
|
|
|
812
814
|
height: e.h,
|
|
813
815
|
data: {}
|
|
814
816
|
}], I);
|
|
815
|
-
if (e.x +=
|
|
817
|
+
if (e.x += y.dx, e.y += y.dy, (r.handle === "ne" || r.handle === "se") && (e.w += y.dx), (r.handle === "se" || r.handle === "sw") && (e.h += y.dy), Gt.current = y.guides, Qt.current && Nt.current > 0 && y.guides.length === 0) {
|
|
816
818
|
const n = Nt.current;
|
|
817
|
-
(
|
|
819
|
+
(r.handle === "nw" || r.handle === "sw") && (e.x = Math.round(e.x / n) * n), (r.handle === "nw" || r.handle === "ne") && (e.y = Math.round(e.y / n) * n), (r.handle === "ne" || r.handle === "se") && (e.w = Math.round((e.x + e.w) / n) * n - e.x), (r.handle === "se" || r.handle === "sw") && (e.h = Math.round((e.y + e.h) / n) * n - e.y);
|
|
818
820
|
}
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
const
|
|
822
|
-
return
|
|
821
|
+
const v = r.startBounds, t = Math.max(e.w, 24), o = Math.max(e.h, 24), a = v.w > 0 ? t / v.w : 1, i = v.h > 0 ? o / v.h : 1;
|
|
822
|
+
tt((n) => {
|
|
823
|
+
const d = n.canvases[Z.current];
|
|
824
|
+
return d ? {
|
|
823
825
|
...n,
|
|
824
826
|
canvases: {
|
|
825
827
|
...n.canvases,
|
|
826
828
|
[Z.current]: {
|
|
827
|
-
...
|
|
828
|
-
nodes:
|
|
829
|
-
if (
|
|
830
|
-
...
|
|
829
|
+
...d,
|
|
830
|
+
nodes: d.nodes.map((w) => {
|
|
831
|
+
if (w.id === r.nodeId) return {
|
|
832
|
+
...w,
|
|
831
833
|
position: {
|
|
832
834
|
x: e.x,
|
|
833
835
|
y: e.y
|
|
834
836
|
},
|
|
835
|
-
width:
|
|
836
|
-
height:
|
|
837
|
+
width: t,
|
|
838
|
+
height: o
|
|
837
839
|
};
|
|
838
|
-
const
|
|
839
|
-
return
|
|
840
|
-
...
|
|
840
|
+
const g = r.childStarts.get(w.id);
|
|
841
|
+
return g ? {
|
|
842
|
+
...w,
|
|
841
843
|
position: {
|
|
842
|
-
x: e.x + (
|
|
843
|
-
y: e.y + (
|
|
844
|
+
x: e.x + (g.x - v.x) * a,
|
|
845
|
+
y: e.y + (g.y - v.y) * i
|
|
844
846
|
},
|
|
845
|
-
width: Math.max(
|
|
846
|
-
height: Math.max(
|
|
847
|
-
} :
|
|
847
|
+
width: Math.max(g.w * a, 24),
|
|
848
|
+
height: Math.max(g.h * i, 24)
|
|
849
|
+
} : w;
|
|
848
850
|
}),
|
|
849
|
-
lines:
|
|
850
|
-
const
|
|
851
|
-
return
|
|
852
|
-
...
|
|
853
|
-
points:
|
|
854
|
-
x: e.x + (
|
|
855
|
-
y: e.y + (
|
|
851
|
+
lines: r.childLineStarts ? d.lines.map((w) => {
|
|
852
|
+
const g = r.childLineStarts.get(w.id);
|
|
853
|
+
return g ? {
|
|
854
|
+
...w,
|
|
855
|
+
points: g.map((z) => ({
|
|
856
|
+
x: e.x + (z.x - v.x) * a,
|
|
857
|
+
y: e.y + (z.y - v.y) * i
|
|
856
858
|
}))
|
|
857
|
-
} :
|
|
858
|
-
}) :
|
|
859
|
+
} : w;
|
|
860
|
+
}) : d.lines
|
|
859
861
|
}
|
|
860
862
|
}
|
|
861
863
|
} : n;
|
|
@@ -863,14 +865,14 @@ function fr({ onPixiReady: A }) {
|
|
|
863
865
|
return;
|
|
864
866
|
}
|
|
865
867
|
if (ft.current?.active) {
|
|
866
|
-
const
|
|
867
|
-
let l = ((
|
|
868
|
+
const r = ft.current, h = (Math.atan2(s.y - r.cy, s.x - r.cx) - r.startPointerAngle) * 180 / Math.PI;
|
|
869
|
+
let l = ((r.startRotation + h) % 360 + 360) % 360;
|
|
868
870
|
if (x.shiftKey) l = Math.round(l / 15) * 15 % 360;
|
|
869
871
|
else {
|
|
870
872
|
const e = Math.round(l / 45) * 45;
|
|
871
873
|
Math.abs(l - e) < 4 && (l = (e % 360 + 360) % 360);
|
|
872
874
|
}
|
|
873
|
-
|
|
875
|
+
tt((e) => {
|
|
874
876
|
const I = e.canvases[Z.current];
|
|
875
877
|
return I ? {
|
|
876
878
|
...e,
|
|
@@ -878,13 +880,13 @@ function fr({ onPixiReady: A }) {
|
|
|
878
880
|
...e.canvases,
|
|
879
881
|
[Z.current]: {
|
|
880
882
|
...I,
|
|
881
|
-
nodes: I.nodes.map((
|
|
882
|
-
...
|
|
883
|
+
nodes: I.nodes.map((y) => y.id === r.nodeId ? {
|
|
884
|
+
...y,
|
|
883
885
|
data: {
|
|
884
|
-
...
|
|
886
|
+
...y.data,
|
|
885
887
|
rotation: l
|
|
886
888
|
}
|
|
887
|
-
} :
|
|
889
|
+
} : y)
|
|
888
890
|
}
|
|
889
891
|
}
|
|
890
892
|
} : e;
|
|
@@ -892,9 +894,9 @@ function fr({ onPixiReady: A }) {
|
|
|
892
894
|
return;
|
|
893
895
|
}
|
|
894
896
|
if (ut.current?.active) {
|
|
895
|
-
const
|
|
897
|
+
const r = ut.current, h = X.current.nodes, l = /* @__PURE__ */ new Map();
|
|
896
898
|
for (const e of h) l.set(e.id, e);
|
|
897
|
-
|
|
899
|
+
tt((e) => {
|
|
898
900
|
const I = e.canvases[Z.current];
|
|
899
901
|
return I ? {
|
|
900
902
|
...e,
|
|
@@ -902,53 +904,53 @@ function fr({ onPixiReady: A }) {
|
|
|
902
904
|
...e.canvases,
|
|
903
905
|
[Z.current]: {
|
|
904
906
|
...I,
|
|
905
|
-
edges: I.edges.map((
|
|
906
|
-
if (
|
|
907
|
-
if (
|
|
908
|
-
const
|
|
909
|
-
return
|
|
910
|
-
x:
|
|
911
|
-
y:
|
|
907
|
+
edges: I.edges.map((y) => {
|
|
908
|
+
if (y.id !== r.edgeId) return y;
|
|
909
|
+
if (r.type === "waypoint") {
|
|
910
|
+
const Ft = [...y.data.waypoints ?? []];
|
|
911
|
+
return r.index < Ft.length && (Ft[r.index] = {
|
|
912
|
+
x: s.x,
|
|
913
|
+
y: s.y
|
|
912
914
|
}), {
|
|
913
|
-
...
|
|
915
|
+
...y,
|
|
914
916
|
data: {
|
|
915
|
-
...
|
|
916
|
-
waypoints:
|
|
917
|
+
...y.data,
|
|
918
|
+
waypoints: Ft
|
|
917
919
|
}
|
|
918
920
|
};
|
|
919
921
|
}
|
|
920
|
-
const
|
|
921
|
-
if (!
|
|
922
|
-
const
|
|
922
|
+
const v = St(y, l);
|
|
923
|
+
if (!v) return y;
|
|
924
|
+
const t = y.data.waypoints ?? [], o = [
|
|
923
925
|
{
|
|
924
|
-
x:
|
|
925
|
-
y:
|
|
926
|
+
x: v.sx,
|
|
927
|
+
y: v.sy
|
|
926
928
|
},
|
|
927
|
-
...
|
|
929
|
+
...t,
|
|
928
930
|
{
|
|
929
|
-
x:
|
|
930
|
-
y:
|
|
931
|
+
x: v.tx,
|
|
932
|
+
y: v.ty
|
|
931
933
|
}
|
|
932
|
-
], a =
|
|
933
|
-
for (;
|
|
934
|
-
const n =
|
|
935
|
-
if (n >= a) return
|
|
936
|
-
const
|
|
937
|
-
return
|
|
938
|
-
c1x:
|
|
939
|
-
c1y:
|
|
940
|
-
c2x:
|
|
941
|
-
c2y:
|
|
942
|
-
} :
|
|
943
|
-
c1x:
|
|
944
|
-
c1y:
|
|
945
|
-
c2x:
|
|
946
|
-
c2y:
|
|
934
|
+
], a = o.length - 1, i = [...y.data.bezierControls ?? []];
|
|
935
|
+
for (; i.length < a; ) i.push(null);
|
|
936
|
+
const n = r.index;
|
|
937
|
+
if (n >= a) return y;
|
|
938
|
+
const d = o[n], w = o[n + 1], g = i[n], z = Math.hypot(w.x - d.x, w.y - d.y), C = Math.max(30, z * 0.3), u = a - 1, b = n === 0 ? d.x + v.snx * C : d.x + (w.x - d.x) * 0.4, _ = n === 0 ? d.y + v.sny * C : d.y, J = n === u ? w.x + v.tnx * C : w.x - (w.x - d.x) * 0.4, Ot = n === u ? w.y + v.tny * C : w.y;
|
|
939
|
+
return r.type === "bezierC1" ? i[n] = {
|
|
940
|
+
c1x: s.x,
|
|
941
|
+
c1y: s.y,
|
|
942
|
+
c2x: g?.c2x ?? J,
|
|
943
|
+
c2y: g?.c2y ?? Ot
|
|
944
|
+
} : i[n] = {
|
|
945
|
+
c1x: g?.c1x ?? b,
|
|
946
|
+
c1y: g?.c1y ?? _,
|
|
947
|
+
c2x: s.x,
|
|
948
|
+
c2y: s.y
|
|
947
949
|
}, {
|
|
948
|
-
...
|
|
950
|
+
...y,
|
|
949
951
|
data: {
|
|
950
|
-
...
|
|
951
|
-
bezierControls:
|
|
952
|
+
...y.data,
|
|
953
|
+
bezierControls: i
|
|
952
954
|
}
|
|
953
955
|
};
|
|
954
956
|
})
|
|
@@ -959,8 +961,8 @@ function fr({ onPixiReady: A }) {
|
|
|
959
961
|
return;
|
|
960
962
|
}
|
|
961
963
|
if (mt.current?.active) {
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
+
const r = mt.current, h = s.x - r.startWorld.x, l = s.y - r.startWorld.y;
|
|
965
|
+
tt((e) => {
|
|
964
966
|
const I = e.canvases[Z.current];
|
|
965
967
|
return I ? {
|
|
966
968
|
...e,
|
|
@@ -968,15 +970,15 @@ function fr({ onPixiReady: A }) {
|
|
|
968
970
|
...e.canvases,
|
|
969
971
|
[Z.current]: {
|
|
970
972
|
...I,
|
|
971
|
-
lines: I.lines.map((
|
|
972
|
-
const
|
|
973
|
-
return
|
|
974
|
-
...
|
|
975
|
-
points:
|
|
976
|
-
x:
|
|
977
|
-
y:
|
|
973
|
+
lines: I.lines.map((y) => {
|
|
974
|
+
const v = r.pointStarts.get(y.id);
|
|
975
|
+
return v ? {
|
|
976
|
+
...y,
|
|
977
|
+
points: v.map((t) => ({
|
|
978
|
+
x: t.x + h,
|
|
979
|
+
y: t.y + l
|
|
978
980
|
}))
|
|
979
|
-
} :
|
|
981
|
+
} : y;
|
|
980
982
|
})
|
|
981
983
|
}
|
|
982
984
|
}
|
|
@@ -984,109 +986,109 @@ function fr({ onPixiReady: A }) {
|
|
|
984
986
|
});
|
|
985
987
|
return;
|
|
986
988
|
}
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
+
if (it.current?.active) {
|
|
990
|
+
const r = it.current, h = s.x - r.startWorld.x, l = s.y - r.startWorld.y;
|
|
989
991
|
let e = h, I = l;
|
|
990
|
-
if (
|
|
991
|
-
const
|
|
992
|
-
|
|
992
|
+
if (Qt.current && Nt.current > 0 && r.nodeIds.size > 0) {
|
|
993
|
+
const t = Nt.current, o = r.nodeStarts.values().next().value;
|
|
994
|
+
o && (e = Kt(o.x + h, t, !0) - o.x, I = Kt(o.y + l, t, !0) - o.y);
|
|
993
995
|
}
|
|
994
|
-
const
|
|
995
|
-
const
|
|
996
|
+
const y = X.current.nodes, v = me(y.filter((t) => r.nodeIds.has(t.id)).map((t) => {
|
|
997
|
+
const o = r.nodeStarts.get(t.id);
|
|
996
998
|
return {
|
|
997
|
-
...
|
|
999
|
+
...t,
|
|
998
1000
|
position: {
|
|
999
|
-
x:
|
|
1000
|
-
y:
|
|
1001
|
+
x: o.x + e,
|
|
1002
|
+
y: o.y + I
|
|
1001
1003
|
}
|
|
1002
1004
|
};
|
|
1003
|
-
}),
|
|
1004
|
-
e +=
|
|
1005
|
-
const
|
|
1006
|
-
return
|
|
1007
|
-
...
|
|
1005
|
+
}), y);
|
|
1006
|
+
e += v.dx, I += v.dy, Gt.current = v.guides, tt((t) => {
|
|
1007
|
+
const o = t.canvases[Z.current];
|
|
1008
|
+
return o ? {
|
|
1009
|
+
...t,
|
|
1008
1010
|
canvases: {
|
|
1009
|
-
...
|
|
1011
|
+
...t.canvases,
|
|
1010
1012
|
[Z.current]: {
|
|
1011
|
-
...
|
|
1012
|
-
nodes:
|
|
1013
|
-
const
|
|
1014
|
-
return
|
|
1013
|
+
...o,
|
|
1014
|
+
nodes: o.nodes.map((a) => {
|
|
1015
|
+
const i = r.nodeStarts.get(a.id);
|
|
1016
|
+
return i ? {
|
|
1015
1017
|
...a,
|
|
1016
1018
|
position: {
|
|
1017
|
-
x:
|
|
1018
|
-
y:
|
|
1019
|
+
x: i.x + e,
|
|
1020
|
+
y: i.y + I
|
|
1019
1021
|
}
|
|
1020
1022
|
} : a;
|
|
1021
1023
|
}),
|
|
1022
|
-
lines:
|
|
1023
|
-
const
|
|
1024
|
-
return
|
|
1024
|
+
lines: r.linePointStarts ? o.lines.map((a) => {
|
|
1025
|
+
const i = r.linePointStarts.get(a.id);
|
|
1026
|
+
return i ? {
|
|
1025
1027
|
...a,
|
|
1026
|
-
points:
|
|
1028
|
+
points: i.map((n) => ({
|
|
1027
1029
|
x: n.x + e,
|
|
1028
1030
|
y: n.y + I
|
|
1029
1031
|
}))
|
|
1030
1032
|
} : a;
|
|
1031
|
-
}) :
|
|
1033
|
+
}) : o.lines
|
|
1032
1034
|
}
|
|
1033
1035
|
}
|
|
1034
|
-
} :
|
|
1036
|
+
} : t;
|
|
1035
1037
|
});
|
|
1036
1038
|
return;
|
|
1037
1039
|
}
|
|
1038
|
-
if (
|
|
1039
|
-
const
|
|
1040
|
-
kt.current.showMarquee(
|
|
1040
|
+
if (nt.current?.active && kt.current) {
|
|
1041
|
+
const r = Math.min(nt.current.startScreen.x, x.global.x), h = Math.min(nt.current.startScreen.y, x.global.y), l = Math.abs(x.global.x - nt.current.startScreen.x), e = Math.abs(x.global.y - nt.current.startScreen.y);
|
|
1042
|
+
kt.current.showMarquee(r, h, l, e);
|
|
1041
1043
|
}
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
1045
|
-
const h = Mt(
|
|
1044
|
+
if (rt.current?.active && wt.current) {
|
|
1045
|
+
const r = X.current.nodes.find((h) => h.id === rt.current.sourceNodeId);
|
|
1046
|
+
if (r) {
|
|
1047
|
+
const h = Mt(r.width, r.height).find((l) => l.id === rt.current.sourceHandleId);
|
|
1046
1048
|
if (h) {
|
|
1047
|
-
const l =
|
|
1048
|
-
let
|
|
1049
|
-
const
|
|
1050
|
-
if (
|
|
1051
|
-
const a =
|
|
1049
|
+
const l = Vt(h, r), e = l.x, I = l.y;
|
|
1050
|
+
let y = s.x, v = s.y;
|
|
1051
|
+
const t = Tt.current;
|
|
1052
|
+
if (t && t !== rt.current.sourceNodeId) {
|
|
1053
|
+
const a = X.current.nodes.find((i) => i.id === t);
|
|
1052
1054
|
if (a) {
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1055
|
-
const n =
|
|
1056
|
-
|
|
1055
|
+
const i = Bt(Mt(a.width, a.height), a, s.x, s.y, 1 / 0);
|
|
1056
|
+
if (i) {
|
|
1057
|
+
const n = Vt(i, a);
|
|
1058
|
+
y = n.x, v = n.y;
|
|
1057
1059
|
}
|
|
1058
1060
|
}
|
|
1059
1061
|
}
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
+
const o = wt.current;
|
|
1063
|
+
o.clear(), o.moveTo(e, I).lineTo(y, v).stroke({
|
|
1062
1064
|
color: 3900150,
|
|
1063
1065
|
width: 2,
|
|
1064
1066
|
alpha: 0.6
|
|
1065
|
-
}),
|
|
1067
|
+
}), o.visible = !0;
|
|
1066
1068
|
}
|
|
1067
1069
|
}
|
|
1068
1070
|
}
|
|
1069
1071
|
if (ct.current?.active && wt.current && !wt.current.destroyed) {
|
|
1070
|
-
const
|
|
1072
|
+
const r = ct.current, h = X.current.nodes.find((l) => l.id === r.fixedNodeId);
|
|
1071
1073
|
if (h) {
|
|
1072
|
-
const l = Mt(h.width, h.height).find((
|
|
1074
|
+
const l = Mt(h.width, h.height).find((i) => i.id === r.fixedHandleId), e = l ? Vt(l, h) : {
|
|
1073
1075
|
x: h.position.x + h.width / 2,
|
|
1074
1076
|
y: h.position.y + h.height / 2
|
|
1075
|
-
}, I = e.x,
|
|
1076
|
-
let
|
|
1077
|
-
const
|
|
1078
|
-
if (
|
|
1079
|
-
const
|
|
1080
|
-
if (
|
|
1081
|
-
const n =
|
|
1077
|
+
}, I = e.x, y = e.y;
|
|
1078
|
+
let v = s.x, t = s.y;
|
|
1079
|
+
const o = Tt.current;
|
|
1080
|
+
if (o && o !== r.fixedNodeId) {
|
|
1081
|
+
const i = X.current.nodes.find((n) => n.id === o);
|
|
1082
|
+
if (i) {
|
|
1083
|
+
const n = Bt(Mt(i.width, i.height), i, s.x, s.y, 1 / 0);
|
|
1082
1084
|
if (n) {
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
+
const d = Vt(n, i);
|
|
1086
|
+
v = d.x, t = d.y;
|
|
1085
1087
|
}
|
|
1086
1088
|
}
|
|
1087
1089
|
}
|
|
1088
1090
|
const a = wt.current;
|
|
1089
|
-
a.clear(), a.moveTo(I,
|
|
1091
|
+
a.clear(), a.moveTo(I, y).lineTo(v, t).stroke({
|
|
1090
1092
|
color: 16347926,
|
|
1091
1093
|
width: 2,
|
|
1092
1094
|
alpha: 0.7
|
|
@@ -1094,10 +1096,10 @@ function fr({ onPixiReady: A }) {
|
|
|
1094
1096
|
}
|
|
1095
1097
|
}
|
|
1096
1098
|
});
|
|
1097
|
-
const
|
|
1098
|
-
|
|
1099
|
+
const Pt = () => {
|
|
1100
|
+
Gt.current = [];
|
|
1099
1101
|
try {
|
|
1100
|
-
|
|
1102
|
+
ge.current?.clear();
|
|
1101
1103
|
} catch {
|
|
1102
1104
|
}
|
|
1103
1105
|
try {
|
|
@@ -1108,8 +1110,8 @@ function fr({ onPixiReady: A }) {
|
|
|
1108
1110
|
M.current && (M.current.style.cursor = "");
|
|
1109
1111
|
};
|
|
1110
1112
|
bt.on("pointerup", (x) => {
|
|
1111
|
-
if (
|
|
1112
|
-
ft.current = null,
|
|
1113
|
+
if (Pt(), ft.current?.active) {
|
|
1114
|
+
ft.current = null, Ht.current();
|
|
1113
1115
|
return;
|
|
1114
1116
|
}
|
|
1115
1117
|
if (ut.current?.active) {
|
|
@@ -1124,30 +1126,30 @@ function fr({ onPixiReady: A }) {
|
|
|
1124
1126
|
mt.current = null;
|
|
1125
1127
|
return;
|
|
1126
1128
|
}
|
|
1127
|
-
if (
|
|
1128
|
-
const
|
|
1129
|
-
if (
|
|
1130
|
-
const S =
|
|
1129
|
+
if (it.current?.active && (it.current = null, Ht.current()), nt.current?.active) {
|
|
1130
|
+
const s = dt.current(nt.current.startScreen.x, nt.current.startScreen.y), c = dt.current(x.global.x, x.global.y), p = Math.min(s.x, c.x), P = Math.min(s.y, c.y), k = Math.abs(c.x - s.x), R = Math.abs(c.y - s.y);
|
|
1131
|
+
if (k > 4 && R > 4) {
|
|
1132
|
+
const S = X.current.nodes.filter((r) => kn(p, P, k, R, r.position.x, r.position.y, r.width, r.height)), T = X.current.lines.filter((r) => r.points.length === 0 ? !1 : r.points.every((h) => h.x >= p && h.x <= p + k && h.y >= P && h.y <= P + R));
|
|
1131
1133
|
pt({
|
|
1132
|
-
nodeIds: new Set(S.map((
|
|
1134
|
+
nodeIds: new Set(S.map((r) => r.id)),
|
|
1133
1135
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
1134
|
-
lineIds: new Set(
|
|
1136
|
+
lineIds: new Set(T.map((r) => r.id))
|
|
1135
1137
|
});
|
|
1136
1138
|
}
|
|
1137
|
-
|
|
1139
|
+
nt.current = null, kt.current?.hideMarquee();
|
|
1138
1140
|
}
|
|
1139
1141
|
if (ct.current?.active) {
|
|
1140
|
-
const
|
|
1142
|
+
const s = ct.current.edgeId, c = ct.current.movingEnd, p = ct.current.fixedNodeId;
|
|
1141
1143
|
ct.current = null;
|
|
1142
|
-
const
|
|
1144
|
+
const P = dt.current(x.global.x, x.global.y), k = X.current.nodes, R = fe ? Q(B.current?.state.zoom ?? 1, 12, 24) : 0;
|
|
1143
1145
|
let S = null;
|
|
1144
|
-
for (let
|
|
1145
|
-
S =
|
|
1146
|
+
for (let T = k.length - 1; T >= 0; T--) if (qt(P.x, P.y, k[T], R) && k[T].id !== p) {
|
|
1147
|
+
S = k[T];
|
|
1146
1148
|
break;
|
|
1147
1149
|
}
|
|
1148
1150
|
if (S) {
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1151
|
+
const T = S.id, r = Bt(Mt(S.width, S.height), S, P.x, P.y, 1 / 0)?.id;
|
|
1152
|
+
tt((h) => {
|
|
1151
1153
|
const l = h.canvases[Z.current];
|
|
1152
1154
|
return l ? {
|
|
1153
1155
|
...h,
|
|
@@ -1155,14 +1157,14 @@ function fr({ onPixiReady: A }) {
|
|
|
1155
1157
|
...h.canvases,
|
|
1156
1158
|
[Z.current]: {
|
|
1157
1159
|
...l,
|
|
1158
|
-
edges: l.edges.map((e) => e.id !==
|
|
1160
|
+
edges: l.edges.map((e) => e.id !== s ? e : c === "source" ? {
|
|
1159
1161
|
...e,
|
|
1160
|
-
source:
|
|
1161
|
-
sourceHandle:
|
|
1162
|
+
source: T,
|
|
1163
|
+
sourceHandle: r
|
|
1162
1164
|
} : {
|
|
1163
1165
|
...e,
|
|
1164
|
-
target:
|
|
1165
|
-
targetHandle:
|
|
1166
|
+
target: T,
|
|
1167
|
+
targetHandle: r
|
|
1166
1168
|
})
|
|
1167
1169
|
}
|
|
1168
1170
|
}
|
|
@@ -1171,31 +1173,31 @@ function fr({ onPixiReady: A }) {
|
|
|
1171
1173
|
}
|
|
1172
1174
|
return;
|
|
1173
1175
|
}
|
|
1174
|
-
if (
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
const
|
|
1176
|
+
if (rt.current?.active) {
|
|
1177
|
+
const s = rt.current.sourceNodeId, c = rt.current.sourceHandleId;
|
|
1178
|
+
rt.current = null;
|
|
1179
|
+
const p = dt.current(x.global.x, x.global.y), P = X.current.nodes, k = fe ? Q(B.current?.state.zoom ?? 1, 12, 24) : 0;
|
|
1178
1180
|
let R = null;
|
|
1179
|
-
for (let S =
|
|
1180
|
-
R =
|
|
1181
|
+
for (let S = P.length - 1; S >= 0; S--) if (qt(p.x, p.y, P[S], k) && P[S].id !== s) {
|
|
1182
|
+
R = P[S];
|
|
1181
1183
|
break;
|
|
1182
1184
|
}
|
|
1183
1185
|
if (R) {
|
|
1184
|
-
const S = R.id,
|
|
1185
|
-
|
|
1186
|
+
const S = R.id, T = Bt(Mt(R.width, R.height), R, p.x, p.y, 1 / 0)?.id, r = `edge_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 6)}`, h = Ue.current;
|
|
1187
|
+
tt((l) => {
|
|
1186
1188
|
const e = l.canvases[Z.current];
|
|
1187
|
-
return !e || e.edges.some((I) => I.source ===
|
|
1189
|
+
return !e || e.edges.some((I) => I.source === s && I.target === S && I.sourceHandle === c && I.targetHandle === T) ? l : {
|
|
1188
1190
|
...l,
|
|
1189
1191
|
canvases: {
|
|
1190
1192
|
...l.canvases,
|
|
1191
1193
|
[Z.current]: {
|
|
1192
1194
|
...e,
|
|
1193
1195
|
edges: [...e.edges, {
|
|
1194
|
-
id:
|
|
1195
|
-
source:
|
|
1196
|
+
id: r,
|
|
1197
|
+
source: s,
|
|
1196
1198
|
target: S,
|
|
1197
|
-
sourceHandle:
|
|
1198
|
-
targetHandle:
|
|
1199
|
+
sourceHandle: c,
|
|
1200
|
+
targetHandle: T,
|
|
1199
1201
|
type: h,
|
|
1200
1202
|
data: {
|
|
1201
1203
|
strokeColor: "theme:base-content",
|
|
@@ -1211,97 +1213,97 @@ function fr({ onPixiReady: A }) {
|
|
|
1211
1213
|
}
|
|
1212
1214
|
}
|
|
1213
1215
|
}), bt.on("pointerupoutside", () => {
|
|
1214
|
-
|
|
1216
|
+
Pt(), it.current?.active && Ht.current(), ft.current?.active && Ht.current(), it.current = null, ft.current = null, xt.current = null, nt.current = null, ct.current = null, rt.current = null, ut.current = null, mt.current = null, Tt.current = null, Wt.current = null, Yt.current = null, kt.current?.hideMarquee();
|
|
1215
1217
|
});
|
|
1216
|
-
const
|
|
1218
|
+
const At = M.current;
|
|
1217
1219
|
let yt = null;
|
|
1218
|
-
const
|
|
1219
|
-
const
|
|
1220
|
+
const ae = (x) => {
|
|
1221
|
+
const s = At.getBoundingClientRect(), c = x[0].clientX, p = x[0].clientY, P = x[1].clientX, k = x[1].clientY;
|
|
1220
1222
|
return {
|
|
1221
|
-
dist: Math.hypot(
|
|
1222
|
-
midX: (
|
|
1223
|
-
midY: (
|
|
1223
|
+
dist: Math.hypot(P - c, k - p),
|
|
1224
|
+
midX: (c + P) / 2 - s.left,
|
|
1225
|
+
midY: (p + k) / 2 - s.top
|
|
1224
1226
|
};
|
|
1225
1227
|
}, He = () => {
|
|
1226
|
-
|
|
1228
|
+
Pt(), it.current?.active && Ht.current(), ft.current?.active && Ht.current(), it.current = null, ft.current = null, xt.current = null, nt.current = null, ct.current = null, rt.current = null, ut.current = null, mt.current = null, Tt.current = null, Wt.current = null, Yt.current = null, kt.current?.hideMarquee(), B.current?.cancelPan();
|
|
1227
1229
|
}, en = (x) => {
|
|
1228
1230
|
if (x.touches.length < 2) return;
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
+
const s = B.current;
|
|
1232
|
+
s && (s.multiTouchActive = !0, He(), yt = ae(x.touches), x.preventDefault());
|
|
1231
1233
|
}, nn = (x) => {
|
|
1232
1234
|
if (!yt || x.touches.length < 2) return;
|
|
1233
1235
|
x.preventDefault();
|
|
1234
|
-
const
|
|
1235
|
-
if (!
|
|
1236
|
-
const
|
|
1237
|
-
Number.isFinite(
|
|
1238
|
-
x:
|
|
1239
|
-
y:
|
|
1240
|
-
}), yt =
|
|
1236
|
+
const s = B.current;
|
|
1237
|
+
if (!s) return;
|
|
1238
|
+
const c = ae(x.touches), p = c.dist / Math.max(1, yt.dist);
|
|
1239
|
+
Number.isFinite(p) && p > 0 && s.zoomAt(c.midX, c.midY, p), s.setState({
|
|
1240
|
+
x: s.state.x + (c.midX - yt.midX),
|
|
1241
|
+
y: s.state.y + (c.midY - yt.midY)
|
|
1242
|
+
}), yt = c;
|
|
1241
1243
|
}, Pe = (x) => {
|
|
1242
1244
|
if (x.touches.length >= 2) {
|
|
1243
|
-
yt =
|
|
1245
|
+
yt = ae(x.touches);
|
|
1244
1246
|
return;
|
|
1245
1247
|
}
|
|
1246
1248
|
if (yt = null, x.touches.length === 0) {
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
+
const s = B.current;
|
|
1250
|
+
s && (s.multiTouchActive = !1), Ve.current = performance.now() + 350;
|
|
1249
1251
|
}
|
|
1250
1252
|
};
|
|
1251
|
-
|
|
1252
|
-
if (x.preventDefault?.(),
|
|
1253
|
-
const
|
|
1254
|
-
let
|
|
1255
|
-
for (let S =
|
|
1256
|
-
|
|
1253
|
+
At?.addEventListener("touchstart", en, { passive: !1 }), At?.addEventListener("touchmove", nn, { passive: !1 }), At?.addEventListener("touchend", Pe), At?.addEventListener("touchcancel", Pe), F = en, Y = nn, K = Pe, bt.on("rightclick", (x) => {
|
|
1254
|
+
if (x.preventDefault?.(), B.current?.didRightPan) return;
|
|
1255
|
+
const s = dt.current(x.global.x, x.global.y), c = X.current.nodes;
|
|
1256
|
+
let p = null;
|
|
1257
|
+
for (let S = c.length - 1; S >= 0; S--) if (qt(s.x, s.y, c[S])) {
|
|
1258
|
+
p = c[S].id;
|
|
1257
1259
|
break;
|
|
1258
1260
|
}
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1261
|
-
x:
|
|
1261
|
+
const P = x.nativeEvent, k = P?.clientX ?? x.global.x, R = P?.clientY ?? x.global.y;
|
|
1262
|
+
he({
|
|
1263
|
+
x: k,
|
|
1262
1264
|
y: R,
|
|
1263
|
-
nodeId:
|
|
1265
|
+
nodeId: p
|
|
1264
1266
|
});
|
|
1265
1267
|
}), bt.on("pointertap", (x) => {
|
|
1266
|
-
if (
|
|
1267
|
-
const
|
|
1268
|
-
if (
|
|
1269
|
-
const S = Nn("node"),
|
|
1268
|
+
if (B.current?.multiTouchActive || performance.now() < Ve.current || x.button !== 0) return;
|
|
1269
|
+
const s = Date.now(), c = dt.current(x.global.x, x.global.y), p = de.current;
|
|
1270
|
+
if (p) {
|
|
1271
|
+
const S = Nn("node"), T = Nt.current, r = Qt.current, h = Kt(c.x - p.width / 2, T, r), l = Kt(c.y - p.height / 2, T, r), e = me([{
|
|
1270
1272
|
id: "__ghost__",
|
|
1271
|
-
type:
|
|
1273
|
+
type: p.type,
|
|
1272
1274
|
position: {
|
|
1273
1275
|
x: h,
|
|
1274
1276
|
y: l
|
|
1275
1277
|
},
|
|
1276
|
-
width:
|
|
1277
|
-
height:
|
|
1278
|
+
width: p.width,
|
|
1279
|
+
height: p.height,
|
|
1278
1280
|
data: {}
|
|
1279
|
-
}],
|
|
1280
|
-
|
|
1281
|
-
const
|
|
1282
|
-
if (!
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
const a = Math.max(0, ...
|
|
1281
|
+
}], X.current.nodes), I = h + e.dx, y = l + e.dy;
|
|
1282
|
+
tt((v) => {
|
|
1283
|
+
const t = v.canvases[Z.current];
|
|
1284
|
+
if (!t) return v;
|
|
1285
|
+
const o = {};
|
|
1286
|
+
p.type === "animAnchor" && (o.animIndex = Wn(v));
|
|
1287
|
+
const a = Math.max(0, ...t.nodes.map((i) => i.zIndex ?? 0), ...t.lines.map((i) => i.zIndex ?? 0));
|
|
1286
1288
|
return {
|
|
1287
|
-
...
|
|
1289
|
+
...v,
|
|
1288
1290
|
canvases: {
|
|
1289
|
-
...
|
|
1291
|
+
...v.canvases,
|
|
1290
1292
|
[Z.current]: {
|
|
1291
|
-
...
|
|
1292
|
-
nodes: [...
|
|
1293
|
+
...t,
|
|
1294
|
+
nodes: [...t.nodes, {
|
|
1293
1295
|
id: S,
|
|
1294
|
-
type:
|
|
1296
|
+
type: p.type,
|
|
1295
1297
|
position: {
|
|
1296
1298
|
x: I,
|
|
1297
|
-
y
|
|
1299
|
+
y
|
|
1298
1300
|
},
|
|
1299
|
-
width:
|
|
1300
|
-
height:
|
|
1301
|
+
width: p.width,
|
|
1302
|
+
height: p.height,
|
|
1301
1303
|
zIndex: a + 1,
|
|
1302
1304
|
data: {
|
|
1303
|
-
...
|
|
1304
|
-
...
|
|
1305
|
+
...p.data,
|
|
1306
|
+
...o
|
|
1305
1307
|
}
|
|
1306
1308
|
}]
|
|
1307
1309
|
}
|
|
@@ -1311,44 +1313,44 @@ function fr({ onPixiReady: A }) {
|
|
|
1311
1313
|
nodeIds: /* @__PURE__ */ new Set([S]),
|
|
1312
1314
|
edgeIds: /* @__PURE__ */ new Set(),
|
|
1313
1315
|
lineIds: /* @__PURE__ */ new Set()
|
|
1314
|
-
}),
|
|
1315
|
-
|
|
1316
|
+
}), ie.current && window.setTimeout(() => {
|
|
1317
|
+
ce.current(I, y, p.width, p.height, {
|
|
1316
1318
|
padding: 80,
|
|
1317
1319
|
preserveZoom: !0,
|
|
1318
1320
|
duration: 280
|
|
1319
1321
|
});
|
|
1320
|
-
}, 0),
|
|
1322
|
+
}, 0), Xt.current = {
|
|
1321
1323
|
time: 0,
|
|
1322
1324
|
wx: 0,
|
|
1323
1325
|
wy: 0
|
|
1324
1326
|
};
|
|
1325
1327
|
return;
|
|
1326
1328
|
}
|
|
1327
|
-
const
|
|
1328
|
-
if (
|
|
1329
|
-
const S =
|
|
1330
|
-
for (let l = S.length - 1; l >= 0; l--) if (
|
|
1329
|
+
const P = Xt.current, k = c.x - P.wx, R = c.y - P.wy;
|
|
1330
|
+
if (s - P.time < 400 && Math.abs(k) < 10 && Math.abs(R) < 10) {
|
|
1331
|
+
const S = X.current.nodes;
|
|
1332
|
+
for (let l = S.length - 1; l >= 0; l--) if (qt(c.x, c.y, S[l])) {
|
|
1331
1333
|
const e = S[l], I = e.data.childCanvasId;
|
|
1332
1334
|
if (I) {
|
|
1333
|
-
In(I),
|
|
1335
|
+
In(I), Xt.current = {
|
|
1334
1336
|
time: 0,
|
|
1335
1337
|
wx: 0,
|
|
1336
1338
|
wy: 0
|
|
1337
1339
|
};
|
|
1338
1340
|
return;
|
|
1339
1341
|
}
|
|
1340
|
-
|
|
1342
|
+
we.current("node", e.id, e.data.label ?? ""), Xt.current = {
|
|
1341
1343
|
time: 0,
|
|
1342
1344
|
wx: 0,
|
|
1343
1345
|
wy: 0
|
|
1344
1346
|
};
|
|
1345
1347
|
return;
|
|
1346
1348
|
}
|
|
1347
|
-
const
|
|
1348
|
-
for (const l of S)
|
|
1349
|
-
const h =
|
|
1350
|
-
for (let l =
|
|
1351
|
-
|
|
1349
|
+
const T = X.current.edges, r = /* @__PURE__ */ new Map();
|
|
1350
|
+
for (const l of S) r.set(l.id, l);
|
|
1351
|
+
const h = B.current?.state.zoom ?? 1;
|
|
1352
|
+
for (let l = T.length - 1; l >= 0; l--) if (Ae(c.x, c.y, T[l], r, Q(h, 8, 12))) {
|
|
1353
|
+
we.current("edge", T[l].id, T[l].data.labelText ?? ""), Xt.current = {
|
|
1352
1354
|
time: 0,
|
|
1353
1355
|
wx: 0,
|
|
1354
1356
|
wy: 0
|
|
@@ -1356,266 +1358,266 @@ function fr({ onPixiReady: A }) {
|
|
|
1356
1358
|
return;
|
|
1357
1359
|
}
|
|
1358
1360
|
}
|
|
1359
|
-
|
|
1360
|
-
time:
|
|
1361
|
-
wx:
|
|
1362
|
-
wy:
|
|
1361
|
+
Xt.current = {
|
|
1362
|
+
time: s,
|
|
1363
|
+
wx: c.x,
|
|
1364
|
+
wy: c.y
|
|
1363
1365
|
};
|
|
1364
1366
|
});
|
|
1365
1367
|
let rn = !1;
|
|
1366
1368
|
f.app.ticker.add((x) => {
|
|
1367
1369
|
if (f.destroyed) return;
|
|
1368
|
-
const
|
|
1370
|
+
const s = x.deltaMS, c = f.app.screen, p = B.current?.state ?? {
|
|
1369
1371
|
x: 0,
|
|
1370
1372
|
y: 0,
|
|
1371
1373
|
zoom: 1
|
|
1372
1374
|
};
|
|
1373
|
-
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
const
|
|
1377
|
-
S.forEach((
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1375
|
+
H.current?.update(p, c.width, c.height);
|
|
1376
|
+
const P = B.current?.isPanning ?? !1;
|
|
1377
|
+
P !== rn && (rn = P, M.current && (M.current.style.cursor = P ? "grabbing" : ""));
|
|
1378
|
+
const k = X.current, R = oe.current, S = Gn(Ke.current), T = /* @__PURE__ */ new Map();
|
|
1379
|
+
S.forEach((t, o) => T.set(t.node.id, o + 1)), ye.current?.advanceAnimation(s);
|
|
1380
|
+
const r = Dt.current ? S[Dt.current.current] : void 0;
|
|
1381
|
+
ye.current?.sync(k.nodes, R.nodeIds, Tt.current, T, {
|
|
1380
1382
|
showAnchors: $e.current,
|
|
1381
|
-
presentation:
|
|
1382
|
-
presentationAnchorId:
|
|
1383
|
-
presentationAnchorVisible:
|
|
1383
|
+
presentation: Dt.current !== null,
|
|
1384
|
+
presentationAnchorId: r?.node.id,
|
|
1385
|
+
presentationAnchorVisible: Dt.current?.showAnchor ?? !1
|
|
1384
1386
|
});
|
|
1385
1387
|
const h = /* @__PURE__ */ new Map();
|
|
1386
|
-
for (const
|
|
1387
|
-
|
|
1388
|
+
for (const t of k.nodes) h.set(t.id, t);
|
|
1389
|
+
pe.current?.advanceAnimation(s), pe.current?.sync(k.edges, h, R.edgeIds, null, { presentation: Dt.current !== null }), xe.current?.advanceAnimation(s), xe.current?.sync(k.lines, R.lineIds), ge.current?.update(Gt.current, c.width, c.height, p);
|
|
1388
1390
|
const l = Fe.current;
|
|
1389
1391
|
if (l) {
|
|
1390
|
-
const
|
|
1391
|
-
let
|
|
1392
|
-
if (
|
|
1393
|
-
let a = 1 / 0,
|
|
1394
|
-
const
|
|
1395
|
-
a = Math.min(a,
|
|
1392
|
+
const t = (R.nodeIds.size > 0 || R.edgeIds.size > 0 || R.lineIds.size > 0) && !Jt.current && !Dt.current && !de.current;
|
|
1393
|
+
let o = !t;
|
|
1394
|
+
if (t) {
|
|
1395
|
+
let a = 1 / 0, i = 1 / 0, n = -1 / 0, d = -1 / 0;
|
|
1396
|
+
const w = (g, z, C, u) => {
|
|
1397
|
+
a = Math.min(a, g), i = Math.min(i, z), n = Math.max(n, g + C), d = Math.max(d, z + u);
|
|
1396
1398
|
};
|
|
1397
|
-
for (const
|
|
1398
|
-
for (const
|
|
1399
|
-
if (!R.edgeIds.has(
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1399
|
+
for (const g of k.nodes) R.nodeIds.has(g.id) && w(g.position.x, g.position.y, g.width, g.height);
|
|
1400
|
+
for (const g of k.edges) {
|
|
1401
|
+
if (!R.edgeIds.has(g.id)) continue;
|
|
1402
|
+
const z = h.get(g.source), C = h.get(g.target);
|
|
1403
|
+
z && w(z.position.x, z.position.y, z.width, z.height), C && w(C.position.x, C.position.y, C.width, C.height);
|
|
1402
1404
|
}
|
|
1403
|
-
for (const
|
|
1404
|
-
if (R.lineIds.has(
|
|
1405
|
-
for (const
|
|
1406
|
-
if (a === 1 / 0)
|
|
1405
|
+
for (const g of k.lines)
|
|
1406
|
+
if (R.lineIds.has(g.id))
|
|
1407
|
+
for (const z of g.points) w(z.x, z.y, 0, 0);
|
|
1408
|
+
if (a === 1 / 0) o = !0;
|
|
1407
1409
|
else {
|
|
1408
|
-
const
|
|
1409
|
-
let
|
|
1410
|
-
|
|
1410
|
+
const g = p.zoom, z = 66, C = 30, u = 6;
|
|
1411
|
+
let b = n * g + p.x + 8, _ = i * g + p.y - C - 6;
|
|
1412
|
+
b + z > c.width - u && (b = Math.max(u, c.width - z - u)), _ < u && (_ = i * g + p.y + u), _ + C > c.height - u && (_ = Math.max(u, c.height - C - u)), l.style.display = "flex", l.style.left = `${Math.round(b)}px`, l.style.top = `${Math.round(_)}px`;
|
|
1411
1413
|
}
|
|
1412
1414
|
}
|
|
1413
|
-
|
|
1415
|
+
o && l.style.display !== "none" && (l.style.display = "none");
|
|
1414
1416
|
}
|
|
1415
|
-
const e =
|
|
1417
|
+
const e = ee.current;
|
|
1416
1418
|
if (e) {
|
|
1417
1419
|
e.clear();
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
+
const t = Wt.current;
|
|
1421
|
+
t && (e.circle(t.wx, t.wy, 10).fill({
|
|
1420
1422
|
color: 3900150,
|
|
1421
1423
|
alpha: 0.12
|
|
1422
1424
|
}).stroke({
|
|
1423
1425
|
color: 3900150,
|
|
1424
1426
|
width: 1.5,
|
|
1425
1427
|
alpha: 0.5
|
|
1426
|
-
}), e.circle(
|
|
1428
|
+
}), e.circle(t.wx, t.wy, 4).fill({
|
|
1427
1429
|
color: 3900150,
|
|
1428
1430
|
alpha: 0.9
|
|
1429
1431
|
}));
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
+
const o = Yt.current;
|
|
1433
|
+
o && !t && (e.circle(o.worldX, o.worldY, 10).fill({
|
|
1432
1434
|
color: 16347926,
|
|
1433
1435
|
alpha: 0.12
|
|
1434
1436
|
}).stroke({
|
|
1435
1437
|
color: 16347926,
|
|
1436
1438
|
width: 1.5,
|
|
1437
1439
|
alpha: 0.5
|
|
1438
|
-
}), e.circle(
|
|
1440
|
+
}), e.circle(o.worldX, o.worldY, 4).fill({
|
|
1439
1441
|
color: 16347926,
|
|
1440
1442
|
alpha: 0.9
|
|
1441
1443
|
}));
|
|
1442
1444
|
}
|
|
1443
|
-
const I =
|
|
1445
|
+
const I = re.current;
|
|
1444
1446
|
if (I) {
|
|
1445
1447
|
I.clear();
|
|
1446
|
-
const
|
|
1447
|
-
if (
|
|
1448
|
-
const
|
|
1448
|
+
const t = de.current;
|
|
1449
|
+
if (t) {
|
|
1450
|
+
const o = qe.current, a = Nt.current, i = Qt.current, n = Kt(o.x - t.width / 2, a, i), d = Kt(o.y - t.height / 2, a, i), w = me([{
|
|
1449
1451
|
id: "__ghost__",
|
|
1450
|
-
type:
|
|
1452
|
+
type: t.type,
|
|
1451
1453
|
position: {
|
|
1452
1454
|
x: n,
|
|
1453
|
-
y:
|
|
1455
|
+
y: d
|
|
1454
1456
|
},
|
|
1455
|
-
width:
|
|
1456
|
-
height:
|
|
1457
|
+
width: t.width,
|
|
1458
|
+
height: t.height,
|
|
1457
1459
|
data: {}
|
|
1458
|
-
}],
|
|
1459
|
-
|
|
1460
|
-
width:
|
|
1461
|
-
height:
|
|
1460
|
+
}], k.nodes);
|
|
1461
|
+
Gt.current = w.guides, I.position.set(n + w.dx, d + w.dy), (an[t.type] ?? an.shapeRect)(I, {
|
|
1462
|
+
width: t.width,
|
|
1463
|
+
height: t.height,
|
|
1462
1464
|
fill: "#3b82f6",
|
|
1463
1465
|
stroke: "#3b82f6",
|
|
1464
1466
|
strokeWidth: 1.5,
|
|
1465
|
-
borderStyle:
|
|
1467
|
+
borderStyle: t.data.borderStyle
|
|
1466
1468
|
});
|
|
1467
1469
|
} else
|
|
1468
|
-
I.position.set(0, 0), !
|
|
1470
|
+
I.position.set(0, 0), !it.current?.active && !xt.current?.active && (Gt.current = []);
|
|
1469
1471
|
}
|
|
1470
|
-
const
|
|
1471
|
-
if (
|
|
1472
|
-
const
|
|
1473
|
-
for (const
|
|
1474
|
-
if (!R.edgeIds.has(
|
|
1475
|
-
const a = St(
|
|
1476
|
-
a && (
|
|
1472
|
+
const y = ne.current;
|
|
1473
|
+
if (y && (y.clear(), R.edgeIds.size > 0 && se.current === "select")) {
|
|
1474
|
+
const t = 1 / p.zoom;
|
|
1475
|
+
for (const o of k.edges) {
|
|
1476
|
+
if (!R.edgeIds.has(o.id)) continue;
|
|
1477
|
+
const a = St(o, h);
|
|
1478
|
+
a && (y.circle(a.sx, a.sy, 5 * t).fill({ color: 16777215 }).stroke({
|
|
1477
1479
|
color: 16347926,
|
|
1478
|
-
width: 1.5 *
|
|
1479
|
-
}),
|
|
1480
|
+
width: 1.5 * t
|
|
1481
|
+
}), y.circle(a.tx, a.ty, 5 * t).fill({ color: 16777215 }).stroke({
|
|
1480
1482
|
color: 16347926,
|
|
1481
|
-
width: 1.5 *
|
|
1483
|
+
width: 1.5 * t
|
|
1482
1484
|
}));
|
|
1483
|
-
const
|
|
1484
|
-
if (
|
|
1485
|
+
const i = o.data.waypoints;
|
|
1486
|
+
if (i) for (const n of i) y.circle(n.x, n.y, 5 * t).fill({ color: 16777215 }).stroke({
|
|
1485
1487
|
color: 3900150,
|
|
1486
|
-
width: 1.5 *
|
|
1488
|
+
width: 1.5 * t
|
|
1487
1489
|
});
|
|
1488
|
-
if (
|
|
1489
|
-
const n = St(
|
|
1490
|
+
if (o.type === "simplebezier") {
|
|
1491
|
+
const n = St(o, h);
|
|
1490
1492
|
if (!n) continue;
|
|
1491
|
-
const
|
|
1493
|
+
const d = i ?? [], w = [
|
|
1492
1494
|
{
|
|
1493
1495
|
x: n.sx,
|
|
1494
1496
|
y: n.sy
|
|
1495
1497
|
},
|
|
1496
|
-
...
|
|
1498
|
+
...d,
|
|
1497
1499
|
{
|
|
1498
1500
|
x: n.tx,
|
|
1499
1501
|
y: n.ty
|
|
1500
1502
|
}
|
|
1501
|
-
],
|
|
1502
|
-
for (let
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1503
|
+
], g = o.data.bezierControls, z = w.length - 2;
|
|
1504
|
+
for (let C = 0; C <= z; C++) {
|
|
1505
|
+
const u = w[C], b = w[C + 1], _ = g?.[C], J = Math.hypot(b.x - u.x, b.y - u.y), Ot = Math.max(30, J * 0.3), Ft = _?.c1x ?? (C === 0 ? u.x + n.snx * Ot : u.x + (b.x - u.x) * 0.4), on = _?.c1y ?? (C === 0 ? u.y + n.sny * Ot : u.y), sn = _?.c2x ?? (C === z ? b.x + n.tnx * Ot : b.x - (b.x - u.x) * 0.4), cn = _?.c2y ?? (C === z ? b.y + n.tny * Ot : b.y);
|
|
1506
|
+
y.moveTo(u.x, u.y).lineTo(Ft, on).stroke({
|
|
1505
1507
|
color: 10265519,
|
|
1506
|
-
width: 1 *
|
|
1507
|
-
}),
|
|
1508
|
+
width: 1 * t
|
|
1509
|
+
}), y.moveTo(b.x, b.y).lineTo(sn, cn).stroke({
|
|
1508
1510
|
color: 10265519,
|
|
1509
|
-
width: 1 *
|
|
1511
|
+
width: 1 * t
|
|
1510
1512
|
});
|
|
1511
|
-
const dn = 4 *
|
|
1512
|
-
|
|
1513
|
+
const dn = 4 * t;
|
|
1514
|
+
y.circle(Ft, on, dn).fill({ color: 16777215 }).stroke({
|
|
1513
1515
|
color: 3900150,
|
|
1514
|
-
width: 1.5 *
|
|
1515
|
-
}),
|
|
1516
|
+
width: 1.5 * t
|
|
1517
|
+
}), y.circle(sn, cn, dn).fill({ color: 16777215 }).stroke({
|
|
1516
1518
|
color: 3900150,
|
|
1517
|
-
width: 1.5 *
|
|
1519
|
+
width: 1.5 * t
|
|
1518
1520
|
});
|
|
1519
1521
|
}
|
|
1520
1522
|
}
|
|
1521
1523
|
}
|
|
1522
1524
|
}
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1525
|
-
const
|
|
1526
|
-
if (
|
|
1527
|
-
const a =
|
|
1528
|
-
|
|
1525
|
+
const v = te.current;
|
|
1526
|
+
if (v && (v.clear(), R.nodeIds.size === 1 && se.current === "select")) {
|
|
1527
|
+
const t = [...R.nodeIds][0], o = k.nodes.find((a) => a.id === t);
|
|
1528
|
+
if (o) {
|
|
1529
|
+
const a = p.zoom, i = o.position.x * a + p.x, n = o.position.y * a + p.y, d = o.width * a, w = o.height * a;
|
|
1530
|
+
v.rect(i, n, d, w).stroke({
|
|
1529
1531
|
color: 3900150,
|
|
1530
1532
|
width: 1.5
|
|
1531
1533
|
});
|
|
1532
|
-
const
|
|
1533
|
-
[
|
|
1534
|
-
[
|
|
1535
|
-
[
|
|
1536
|
-
[
|
|
1534
|
+
const g = 7, z = g / 2, C = [
|
|
1535
|
+
[i, n],
|
|
1536
|
+
[i + d, n],
|
|
1537
|
+
[i + d, n + w],
|
|
1538
|
+
[i, n + w]
|
|
1537
1539
|
];
|
|
1538
|
-
for (const [
|
|
1540
|
+
for (const [_, J] of C) v.rect(_ - z, J - z, g, g).fill({ color: 16777215 }).stroke({
|
|
1539
1541
|
color: 3900150,
|
|
1540
1542
|
width: 1.5
|
|
1541
1543
|
});
|
|
1542
|
-
const
|
|
1543
|
-
[
|
|
1544
|
-
[
|
|
1545
|
-
[
|
|
1546
|
-
[
|
|
1544
|
+
const u = 4, b = [
|
|
1545
|
+
[i + d / 2, n],
|
|
1546
|
+
[i + d, n + w / 2],
|
|
1547
|
+
[i + d / 2, n + w],
|
|
1548
|
+
[i, n + w / 2]
|
|
1547
1549
|
];
|
|
1548
|
-
for (const [
|
|
1550
|
+
for (const [_, J] of b) v.circle(_, J, u).fill({
|
|
1549
1551
|
color: 3900150,
|
|
1550
1552
|
alpha: 0.9
|
|
1551
1553
|
});
|
|
1552
|
-
if (!
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1554
|
+
if (!Jt.current) {
|
|
1555
|
+
const _ = i + d / 2, J = n - vn;
|
|
1556
|
+
v.moveTo(_, n).lineTo(_, J).stroke({
|
|
1555
1557
|
color: 3900150,
|
|
1556
1558
|
width: 1.5,
|
|
1557
1559
|
alpha: 0.85
|
|
1558
|
-
}),
|
|
1560
|
+
}), v.circle(_, J, 6).fill({ color: 16777215 }).stroke({
|
|
1559
1561
|
color: 3900150,
|
|
1560
1562
|
width: 1.5
|
|
1561
|
-
}),
|
|
1563
|
+
}), v.circle(_, J, 2.5).fill({ color: 3900150 });
|
|
1562
1564
|
}
|
|
1563
1565
|
}
|
|
1564
1566
|
}
|
|
1565
1567
|
});
|
|
1566
1568
|
};
|
|
1567
1569
|
return V(), () => {
|
|
1568
|
-
if (
|
|
1570
|
+
if (G = !0, f && !f.destroyed) try {
|
|
1569
1571
|
f.app.stage.removeAllListeners();
|
|
1570
1572
|
} catch {
|
|
1571
1573
|
}
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
+
const O = M.current;
|
|
1575
|
+
F && O?.removeEventListener("touchstart", F), Y && O?.removeEventListener("touchmove", Y), K && (O?.removeEventListener("touchend", K), O?.removeEventListener("touchcancel", K)), H.current?.destroy(), kt.current?.destroy(), ye.current?.destroy(), pe.current?.destroy(), xe.current?.destroy(), Me.current?.destroy(), Re.current?.destroy(), wt.current?.destroy(), te.current && (te.current.destroy(), te.current = null), ee.current && (ee.current.destroy(), ee.current = null), ne.current && (ne.current.destroy(), ne.current = null), re.current && (re.current.destroy(), re.current = null), ge.current?.destroy();
|
|
1574
1576
|
};
|
|
1575
|
-
}, [
|
|
1576
|
-
const f =
|
|
1577
|
-
if (!(!f || !
|
|
1578
|
-
switch (f.deactivate(),
|
|
1577
|
+
}, [D.current]), Rt(() => {
|
|
1578
|
+
const f = Me.current, G = Re.current;
|
|
1579
|
+
if (!(!f || !G))
|
|
1580
|
+
switch (f.deactivate(), G.deactivate(), $) {
|
|
1579
1581
|
case "freehand":
|
|
1580
1582
|
f.activate();
|
|
1581
1583
|
break;
|
|
1582
1584
|
case "line":
|
|
1583
|
-
|
|
1585
|
+
G.activate("straight");
|
|
1584
1586
|
break;
|
|
1585
1587
|
case "polyline":
|
|
1586
|
-
|
|
1588
|
+
G.activate("polyline");
|
|
1587
1589
|
break;
|
|
1588
1590
|
case "arrow":
|
|
1589
|
-
|
|
1591
|
+
G.activate("arrow");
|
|
1590
1592
|
break;
|
|
1591
1593
|
}
|
|
1592
1594
|
}, [$]), Rt(() => {
|
|
1593
|
-
|
|
1594
|
-
}, [j,
|
|
1595
|
+
H.current && (H.current.visible = j, H.current.gridSize = et);
|
|
1596
|
+
}, [j, et]), Rt(() => {
|
|
1595
1597
|
const f = M.current;
|
|
1596
1598
|
if (!f) return;
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
const K =
|
|
1599
|
+
const G = 1e-3, F = (Y) => {
|
|
1600
|
+
Y.preventDefault();
|
|
1601
|
+
const K = B.current;
|
|
1600
1602
|
if (!K) return;
|
|
1601
|
-
const V = f.getBoundingClientRect(),
|
|
1602
|
-
K.zoomAt(
|
|
1603
|
+
const V = f.getBoundingClientRect(), O = Y.clientX - V.left, at = Y.clientY - V.top, vt = Y.ctrlKey ? 3 : 1, It = -Y.deltaY * G * vt;
|
|
1604
|
+
K.zoomAt(O, at, 1 + It);
|
|
1603
1605
|
};
|
|
1604
|
-
return f.addEventListener("wheel",
|
|
1605
|
-
}, [
|
|
1606
|
+
return f.addEventListener("wheel", F, { passive: !1 }), () => f.removeEventListener("wheel", F);
|
|
1607
|
+
}, [B]), /* @__PURE__ */ ve("div", {
|
|
1606
1608
|
style: {
|
|
1607
1609
|
position: "relative",
|
|
1608
1610
|
width: "100%",
|
|
1609
1611
|
height: "100%"
|
|
1610
1612
|
},
|
|
1611
1613
|
children: [
|
|
1612
|
-
/* @__PURE__ */
|
|
1614
|
+
/* @__PURE__ */ Zt("div", {
|
|
1613
1615
|
ref: M,
|
|
1614
1616
|
className: "flow-canvas-wrapper",
|
|
1615
1617
|
tabIndex: -1,
|
|
1616
1618
|
onContextMenu: (f) => f.preventDefault()
|
|
1617
1619
|
}),
|
|
1618
|
-
ht && Ne && /* @__PURE__ */
|
|
1620
|
+
ht && Ne && /* @__PURE__ */ Zt("input", {
|
|
1619
1621
|
className: "flow-label-editor",
|
|
1620
1622
|
autoFocus: !0,
|
|
1621
1623
|
defaultValue: ht.value,
|
|
@@ -1630,17 +1632,17 @@ function fr({ onPixiReady: A }) {
|
|
|
1630
1632
|
onBlur: (f) => Je(f.target.value),
|
|
1631
1633
|
onPointerDown: (f) => f.stopPropagation()
|
|
1632
1634
|
}),
|
|
1633
|
-
|
|
1635
|
+
Ut && !Et && /* @__PURE__ */ ve("button", {
|
|
1634
1636
|
type: "button",
|
|
1635
1637
|
className: "flow-esc-button",
|
|
1636
|
-
onClick: () =>
|
|
1638
|
+
onClick: () => Lt(null),
|
|
1637
1639
|
title: "取消连续放置 (Esc)",
|
|
1638
|
-
children: [/* @__PURE__ */
|
|
1640
|
+
children: [/* @__PURE__ */ Zt("span", {
|
|
1639
1641
|
"aria-hidden": !0,
|
|
1640
1642
|
children: "⎋"
|
|
1641
1643
|
}), " 取消放置 (ESC)"]
|
|
1642
1644
|
}),
|
|
1643
|
-
/* @__PURE__ */
|
|
1645
|
+
/* @__PURE__ */ ve("button", {
|
|
1644
1646
|
ref: Fe,
|
|
1645
1647
|
type: "button",
|
|
1646
1648
|
className: "flow-delete-button",
|
|
@@ -1648,7 +1650,7 @@ function fr({ onPixiReady: A }) {
|
|
|
1648
1650
|
onClick: () => Oe.current(),
|
|
1649
1651
|
title: "删除所选 (Delete)",
|
|
1650
1652
|
"aria-label": "删除所选",
|
|
1651
|
-
children: [/* @__PURE__ */
|
|
1653
|
+
children: [/* @__PURE__ */ ve("svg", {
|
|
1652
1654
|
width: "12",
|
|
1653
1655
|
height: "12",
|
|
1654
1656
|
viewBox: "0 0 24 24",
|
|
@@ -1659,9 +1661,9 @@ function fr({ onPixiReady: A }) {
|
|
|
1659
1661
|
strokeLinejoin: "round",
|
|
1660
1662
|
"aria-hidden": !0,
|
|
1661
1663
|
children: [
|
|
1662
|
-
/* @__PURE__ */
|
|
1663
|
-
/* @__PURE__ */
|
|
1664
|
-
/* @__PURE__ */
|
|
1664
|
+
/* @__PURE__ */ Zt("path", { d: "M3 6h18" }),
|
|
1665
|
+
/* @__PURE__ */ Zt("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
|
|
1666
|
+
/* @__PURE__ */ Zt("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
1665
1667
|
]
|
|
1666
1668
|
}), "删除"]
|
|
1667
1669
|
})
|