@blueking/flow-canvas 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,14 +1,16 @@
1
- import { ref as O, computed as F, onScopeDispose as et, defineComponent as ge, onBeforeUnmount as ze, createElementBlock as S, openBlock as M, normalizeStyle as _e, createElementVNode as B, createVNode as tt, createCommentVNode as U, normalizeClass as ee, Transition as ot, withCtx as je, withModifiers as rt, createTextVNode as Ve, renderSlot as ke, onMounted as at, watch as fe, createBlock as De, Fragment as pe, renderList as Pe, toDisplayString as me, unref as lt, resolveDynamicComponent as dt, inject as ct } from "vue";
2
- import { Graph as ut } from "@antv/x6";
3
- import { register as ft } from "@antv/x6-vue-shape";
4
- function Mo() {
1
+ import { ref as O, computed as j, onScopeDispose as Ye, defineComponent as le, h as Ae, watch as fe, onBeforeUnmount as Se, createElementBlock as A, openBlock as N, normalizeStyle as ve, createElementVNode as G, createVNode as Ze, createCommentVNode as V, normalizeClass as te, Transition as Qe, withCtx as $e, withModifiers as nt, createTextVNode as Pe, renderSlot as we, onMounted as Je, createBlock as ye, Fragment as he, renderList as xe, toDisplayString as ce, unref as re, reactive as st, resolveDynamicComponent as it, Teleport as rt, nextTick as Te, inject as at, createApp as lt } from "vue";
2
+ import { Graph as dt } from "@antv/x6";
3
+ import { register as ct } from "@antv/x6-vue-shape";
4
+ import { Selection as ut } from "@antv/x6-plugin-selection";
5
+ import { MiniMap as ft } from "@antv/x6-plugin-minimap";
6
+ function rn() {
5
7
  return {
6
8
  version: "1.0",
7
9
  nodes: {},
8
10
  edges: {}
9
11
  };
10
12
  }
11
- class ne extends Error {
13
+ class ae extends Error {
12
14
  constructor(e) {
13
15
  super(e), this.name = "CanvasConstraintError";
14
16
  }
@@ -18,214 +20,214 @@ class pt extends Error {
18
20
  super(e), this.name = "CanvasSchemaError";
19
21
  }
20
22
  }
21
- function Ae(s, e, t) {
23
+ function _e(n, e, t) {
22
24
  if (e.length === 0) {
23
25
  if (t === void 0) return;
24
26
  if (typeof t != "object" || t === null || Array.isArray(t))
25
27
  throw new Error("Root value of payload/extensions/meta must be an object or undefined");
26
28
  return t;
27
29
  }
28
- const o = s ? { ...s } : {};
29
- let n = o;
30
- for (let i = 0; i < e.length - 1; i++) {
31
- const l = e[i], a = n[l];
32
- a && typeof a == "object" && !Array.isArray(a) ? n[l] = { ...a } : n[l] = {}, n = n[l];
30
+ const s = n ? { ...n } : {};
31
+ let o = s;
32
+ for (let r = 0; r < e.length - 1; r++) {
33
+ const l = e[r], a = o[l];
34
+ a && typeof a == "object" && !Array.isArray(a) ? o[l] = { ...a } : o[l] = {}, o = o[l];
33
35
  }
34
- const r = e[e.length - 1];
35
- return t === void 0 ? delete n[r] : n[r] = t, o;
36
+ const i = e[e.length - 1];
37
+ return t === void 0 ? delete o[i] : o[i] = t, s;
36
38
  }
37
- function Ge(s, e) {
39
+ function Re(n, e) {
38
40
  switch (e.type) {
39
41
  case "node.add":
40
- return gt(s, e.node);
42
+ return gt(n, e.node);
41
43
  case "node.move":
42
- return ht(s, e.nodeId, e.position);
44
+ return ht(n, e.nodeId, e.position);
43
45
  case "node.remove":
44
- return vt(s, e.nodeId);
46
+ return vt(n, e.nodeId);
45
47
  case "node.update":
46
- return yt(s, e.nodeId, e.patch);
48
+ return yt(n, e.nodeId, e.patch);
47
49
  case "node.set-payload":
48
- return mt(s, e.nodeId, e.path, e.value);
50
+ return mt(n, e.nodeId, e.path, e.value);
49
51
  case "node.set-extensions":
50
- return bt(s, e.nodeId, e.path, e.value);
52
+ return bt(n, e.nodeId, e.path, e.value);
51
53
  case "edge.add":
52
- return wt(s, e.edge);
54
+ return wt(n, e.edge);
53
55
  case "edge.remove":
54
- return xt(s, e.edgeId);
56
+ return xt(n, e.edgeId);
55
57
  case "edge.reconnect":
56
- return kt(s, e.edgeId, e.source, e.target);
58
+ return Ct(n, e.edgeId, e.source, e.target);
57
59
  case "edge.update":
58
- return Ct(s, e.edgeId, e.patch);
60
+ return Et(n, e.edgeId, e.patch);
59
61
  case "edge.set-payload":
60
- return Et(s, e.edgeId, e.path, e.value);
62
+ return kt(n, e.edgeId, e.path, e.value);
61
63
  case "edge.label.update":
62
- return It(s, e.edgeId, e.labelId, e.patch);
64
+ return It(n, e.edgeId, e.labelId, e.patch);
63
65
  case "model.set-meta":
64
- return Mt(s, e.path, e.value);
66
+ return St(n, e.path, e.value);
65
67
  default:
66
- throw new ne(`Unknown command type: ${e.type}`);
68
+ throw new ae(`Unknown command type: ${e.type}`);
67
69
  }
68
70
  }
69
- function Ce(s, e) {
70
- const t = s.nodes[e];
71
- if (!t) throw new ne(`Node "${e}" does not exist`);
71
+ function Ce(n, e) {
72
+ const t = n.nodes[e];
73
+ if (!t) throw new ae(`Node "${e}" does not exist`);
72
74
  return t;
73
75
  }
74
- function Ee(s, e) {
75
- const t = s.edges[e];
76
- if (!t) throw new ne(`Edge "${e}" does not exist`);
76
+ function Ee(n, e) {
77
+ const t = n.edges[e];
78
+ if (!t) throw new ae(`Edge "${e}" does not exist`);
77
79
  return t;
78
80
  }
79
- function be(s, e, t) {
80
- const o = s.nodes[e.nodeId];
81
- if (!o)
82
- throw new ne(`${t} node "${e.nodeId}" does not exist`);
83
- if (e.portId && o.ports && !o.ports.some((r) => r.id === e.portId))
84
- throw new ne(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
85
- }
86
- function Te(s, e, t) {
87
- return { ...s, nodes: { ...s.nodes, [e]: t } };
88
- }
89
- function Re(s, e, t) {
90
- return { ...s, edges: { ...s.edges, [e]: t } };
91
- }
92
- function gt(s, e) {
93
- if (s.nodes[e.id])
94
- throw new ne(`Node id "${e.id}" already exists`);
95
- return { ...s, nodes: { ...s.nodes, [e.id]: e } };
96
- }
97
- function ht(s, e, t) {
98
- const o = Ce(s, e);
99
- return Te(s, e, { ...o, position: t });
100
- }
101
- function vt(s, e) {
102
- Ce(s, e);
103
- const { [e]: t, ...o } = s.nodes, n = {};
104
- for (const [r, i] of Object.entries(s.edges))
105
- i.source.nodeId !== e && i.target.nodeId !== e && (n[r] = i);
106
- return { ...s, nodes: o, edges: n };
107
- }
108
- function yt(s, e, t) {
109
- const o = Ce(s, e);
110
- return Te(s, e, { ...o, ...t, id: o.id });
111
- }
112
- function mt(s, e, t, o) {
113
- const n = Ce(s, e), r = Ae(n.payload, t, o);
114
- return Te(s, e, { ...n, payload: r });
115
- }
116
- function bt(s, e, t, o) {
117
- const n = Ce(s, e), r = Ae(n.extensions, t, o);
118
- return Te(s, e, { ...n, extensions: r });
119
- }
120
- function wt(s, e) {
121
- if (s.edges[e.id])
122
- throw new ne(`Edge id "${e.id}" already exists`);
123
- if (be(s, e.source, "Source"), be(s, e.target, "Target"), e.labels) {
81
+ function me(n, e, t) {
82
+ const s = n.nodes[e.nodeId];
83
+ if (!s)
84
+ throw new ae(`${t} node "${e.nodeId}" does not exist`);
85
+ if (e.portId && s.ports && !s.ports.some((i) => i.id === e.portId))
86
+ throw new ae(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
87
+ }
88
+ function Ne(n, e, t) {
89
+ return { ...n, nodes: { ...n.nodes, [e]: t } };
90
+ }
91
+ function Me(n, e, t) {
92
+ return { ...n, edges: { ...n.edges, [e]: t } };
93
+ }
94
+ function gt(n, e) {
95
+ if (n.nodes[e.id])
96
+ throw new ae(`Node id "${e.id}" already exists`);
97
+ return { ...n, nodes: { ...n.nodes, [e.id]: e } };
98
+ }
99
+ function ht(n, e, t) {
100
+ const s = Ce(n, e);
101
+ return Ne(n, e, { ...s, position: t });
102
+ }
103
+ function vt(n, e) {
104
+ Ce(n, e);
105
+ const { [e]: t, ...s } = n.nodes, o = {};
106
+ for (const [i, r] of Object.entries(n.edges))
107
+ r.source.nodeId !== e && r.target.nodeId !== e && (o[i] = r);
108
+ return { ...n, nodes: s, edges: o };
109
+ }
110
+ function yt(n, e, t) {
111
+ const s = Ce(n, e);
112
+ return Ne(n, e, { ...s, ...t, id: s.id });
113
+ }
114
+ function mt(n, e, t, s) {
115
+ const o = Ce(n, e), i = _e(o.payload, t, s);
116
+ return Ne(n, e, { ...o, payload: i });
117
+ }
118
+ function bt(n, e, t, s) {
119
+ const o = Ce(n, e), i = _e(o.extensions, t, s);
120
+ return Ne(n, e, { ...o, extensions: i });
121
+ }
122
+ function wt(n, e) {
123
+ if (n.edges[e.id])
124
+ throw new ae(`Edge id "${e.id}" already exists`);
125
+ if (me(n, e.source, "Source"), me(n, e.target, "Target"), e.labels) {
124
126
  const t = /* @__PURE__ */ new Set();
125
- for (const o of e.labels) {
126
- if (t.has(o.id))
127
- throw new ne(`Duplicate label id "${o.id}" in edge "${e.id}"`);
128
- t.add(o.id);
129
- }
130
- }
131
- return { ...s, edges: { ...s.edges, [e.id]: e } };
132
- }
133
- function xt(s, e) {
134
- Ee(s, e);
135
- const { [e]: t, ...o } = s.edges;
136
- return { ...s, edges: o };
137
- }
138
- function kt(s, e, t, o) {
139
- const n = Ee(s, e), r = t ?? n.source, i = o ?? n.target;
140
- return be(s, r, "Source"), be(s, i, "Target"), Re(s, e, { ...n, source: r, target: i });
141
- }
142
- function Ct(s, e, t) {
143
- const o = Ee(s, e), n = { ...o, ...t, id: o.id };
144
- return t.source && be(s, n.source, "Source"), t.target && be(s, n.target, "Target"), Re(s, e, n);
145
- }
146
- function Et(s, e, t, o) {
147
- const n = Ee(s, e), r = Ae(n.payload, t, o);
148
- return Re(s, e, { ...n, payload: r });
149
- }
150
- function It(s, e, t, o) {
151
- const n = Ee(s, e);
152
- if (!n.labels)
153
- throw new ne(`Edge "${e}" has no labels`);
154
- const r = n.labels.findIndex((l) => l.id === t);
155
- if (r === -1)
156
- throw new ne(`Label "${t}" not found in edge "${e}"`);
157
- const i = [...n.labels];
158
- return i[r] = { ...i[r], ...o, id: t }, Re(s, e, { ...n, labels: i });
159
- }
160
- function Mt(s, e, t) {
161
- const o = Ae(s.meta, e, t);
162
- return { ...s, meta: o };
163
- }
164
- function Nt(s, e) {
165
- const t = e?.maxHistorySize ?? 100, o = O(s), n = [], r = [], i = O(!1), l = O(!1);
127
+ for (const s of e.labels) {
128
+ if (t.has(s.id))
129
+ throw new ae(`Duplicate label id "${s.id}" in edge "${e.id}"`);
130
+ t.add(s.id);
131
+ }
132
+ }
133
+ return { ...n, edges: { ...n.edges, [e.id]: e } };
134
+ }
135
+ function xt(n, e) {
136
+ Ee(n, e);
137
+ const { [e]: t, ...s } = n.edges;
138
+ return { ...n, edges: s };
139
+ }
140
+ function Ct(n, e, t, s) {
141
+ const o = Ee(n, e), i = t ?? o.source, r = s ?? o.target;
142
+ return me(n, i, "Source"), me(n, r, "Target"), Me(n, e, { ...o, source: i, target: r });
143
+ }
144
+ function Et(n, e, t) {
145
+ const s = Ee(n, e), o = { ...s, ...t, id: s.id };
146
+ return t.source && me(n, o.source, "Source"), t.target && me(n, o.target, "Target"), Me(n, e, o);
147
+ }
148
+ function kt(n, e, t, s) {
149
+ const o = Ee(n, e), i = _e(o.payload, t, s);
150
+ return Me(n, e, { ...o, payload: i });
151
+ }
152
+ function It(n, e, t, s) {
153
+ const o = Ee(n, e);
154
+ if (!o.labels)
155
+ throw new ae(`Edge "${e}" has no labels`);
156
+ const i = o.labels.findIndex((l) => l.id === t);
157
+ if (i === -1)
158
+ throw new ae(`Label "${t}" not found in edge "${e}"`);
159
+ const r = [...o.labels];
160
+ return r[i] = { ...r[i], ...s, id: t }, Me(n, e, { ...o, labels: r });
161
+ }
162
+ function St(n, e, t) {
163
+ const s = _e(n.meta, e, t);
164
+ return { ...n, meta: s };
165
+ }
166
+ function _t(n, e) {
167
+ const t = e?.maxHistorySize ?? 100, s = O(n), o = [], i = [], r = O(!1), l = O(!1);
166
168
  function a() {
167
- i.value = n.length > 0, l.value = r.length > 0;
169
+ r.value = o.length > 0, l.value = i.length > 0;
168
170
  }
169
- function g(w) {
170
- const N = o.value;
171
- let m = N;
172
- for (const D of w.commands)
173
- m = Ge(m, D);
174
- return n.push({ snapshot: N, envelope: w }), n.length > t && n.shift(), r.length = 0, o.value = m, a(), m;
171
+ function p(C) {
172
+ const M = s.value;
173
+ let D = M;
174
+ for (const L of C.commands)
175
+ D = Re(D, L);
176
+ return o.push({ snapshot: M, envelope: C }), o.length > t && o.shift(), i.length = 0, s.value = D, a(), D;
175
177
  }
176
- function d() {
177
- const w = n.pop();
178
- return w ? (r.push({ snapshot: o.value, envelope: w.envelope }), o.value = w.snapshot, a(), w.snapshot) : null;
178
+ function c() {
179
+ const C = o.pop();
180
+ return C ? (i.push({ snapshot: s.value, envelope: C.envelope }), s.value = C.snapshot, a(), C.snapshot) : null;
179
181
  }
180
- function v() {
181
- const w = r.pop();
182
- if (!w) return null;
183
- n.push({ snapshot: o.value, envelope: w.envelope });
184
- let N = o.value;
185
- for (const m of w.envelope.commands)
186
- N = Ge(N, m);
187
- return o.value = N, a(), N;
182
+ function g() {
183
+ const C = i.pop();
184
+ if (!C) return null;
185
+ o.push({ snapshot: s.value, envelope: C.envelope });
186
+ let M = s.value;
187
+ for (const D of C.envelope.commands)
188
+ M = Re(M, D);
189
+ return s.value = M, a(), M;
188
190
  }
189
- function f() {
190
- n.length = 0, r.length = 0, a();
191
+ function u() {
192
+ o.length = 0, i.length = 0, a();
191
193
  }
192
- function p() {
193
- return o.value;
194
+ function y() {
195
+ return s.value;
194
196
  }
195
- function E(w) {
196
- o.value = w, f();
197
+ function v(C) {
198
+ s.value = C, u();
197
199
  }
198
200
  return {
199
- currentFlowModel: o,
200
- execute: g,
201
- undo: d,
202
- redo: v,
203
- canUndo: i,
201
+ currentFlowModel: s,
202
+ execute: p,
203
+ undo: c,
204
+ redo: g,
205
+ canUndo: r,
204
206
  canRedo: l,
205
207
  get undoStack() {
206
- return n.map((w) => w.envelope);
208
+ return o.map((C) => C.envelope);
207
209
  },
208
210
  get redoStack() {
209
- return r.map((w) => w.envelope);
211
+ return i.map((C) => C.envelope);
210
212
  },
211
- clear: f,
212
- createSnapshot: p,
213
- replaceFlowModel: E
213
+ clear: u,
214
+ createSnapshot: y,
215
+ replaceFlowModel: v
214
216
  };
215
217
  }
216
- function St(s) {
217
- return s !== null && typeof s == "object" && s.rejected === !0;
218
+ function Nt(n) {
219
+ return n !== null && typeof n == "object" && n.rejected === !0;
218
220
  }
219
- class Dt {
221
+ class Mt {
220
222
  plugins = [];
221
223
  editorContext = null;
222
224
  runtimeCtx = null;
223
225
  /** 每次 attachRuntime 递增,detachRuntime 时旧 generation 的异步调用自动作废 */
224
226
  runtimeVersion = 0;
225
227
  install(e, t) {
226
- this.plugins = [...e].sort((o, n) => (o.priority ?? 100) - (n.priority ?? 100)), this.editorContext = t;
227
- for (const o of this.plugins)
228
- o.install?.(t);
228
+ this.plugins = [...e].sort((s, o) => (s.priority ?? 100) - (o.priority ?? 100)), this.editorContext = t;
229
+ for (const s of this.plugins)
230
+ s.install?.(t);
229
231
  }
230
232
  /**
231
233
  * 挂载运行时上下文并调用各插件的 attachRuntime。
@@ -235,9 +237,9 @@ class Dt {
235
237
  attachRuntime(e) {
236
238
  const t = ++this.runtimeVersion;
237
239
  this.runtimeCtx = e;
238
- const o = this.createSafeRuntimeContext(e, t);
239
- for (const n of this.plugins)
240
- n.attachRuntime?.(o);
240
+ const s = this.createSafeRuntimeContext(e, t);
241
+ for (const o of this.plugins)
242
+ o.attachRuntime?.(s);
241
243
  }
242
244
  /** 按安装的逆序 detach,保证后安装的插件先释放运行时资源 */
243
245
  detachRuntime() {
@@ -250,16 +252,16 @@ class Dt {
250
252
  * 如果在 await 期间 detachRuntime 已执行,代理会将 graph 操作变为 no-op。
251
253
  */
252
254
  createSafeRuntimeContext(e, t) {
253
- const o = this, n = new Proxy(e.graph, {
254
- get(r, i, l) {
255
- const a = Reflect.get(r, i, l);
256
- return i === "use" && typeof a == "function" ? function(...d) {
257
- if (o.runtimeVersion === t)
258
- return a.apply(r, d);
255
+ const s = this, o = new Proxy(e.graph, {
256
+ get(i, r, l) {
257
+ const a = Reflect.get(i, r, l);
258
+ return r === "use" && typeof a == "function" ? function(...c) {
259
+ if (s.runtimeVersion === t)
260
+ return a.apply(i, c);
259
261
  } : a;
260
262
  }
261
263
  });
262
- return { ...e, graph: n };
264
+ return { ...e, graph: o };
263
265
  }
264
266
  dispose() {
265
267
  for (const e of [...this.plugins].reverse())
@@ -269,35 +271,35 @@ class Dt {
269
271
  transformCommand(e) {
270
272
  if (!this.editorContext) return { envelope: e };
271
273
  let t = e;
272
- for (const o of this.plugins) {
273
- if (!o.transformCommand) continue;
274
- const n = this.createPreview(t), r = o.transformCommand(t, n, this.editorContext);
275
- if (r === null)
274
+ for (const s of this.plugins) {
275
+ if (!s.transformCommand) continue;
276
+ const o = this.createPreview(t), i = s.transformCommand(t, o, this.editorContext);
277
+ if (i === null)
276
278
  return {
277
279
  rejected: !0,
278
280
  error: {
279
281
  code: "plugin_rejected",
280
282
  reason: "",
281
- source: o.name
283
+ source: s.name
282
284
  }
283
285
  };
284
- if (St(r))
286
+ if (Nt(i))
285
287
  return {
286
288
  rejected: !0,
287
289
  error: {
288
- code: r.code ?? "plugin_rejected",
289
- reason: r.reason,
290
- source: o.name
290
+ code: i.code ?? "plugin_rejected",
291
+ reason: i.reason,
292
+ source: s.name
291
293
  }
292
294
  };
293
- t = r;
295
+ t = i;
294
296
  }
295
297
  return { envelope: t };
296
298
  }
297
- afterCommand(e, t, o) {
299
+ afterCommand(e, t, s) {
298
300
  if (this.editorContext)
299
- for (const n of this.plugins)
300
- n.afterCommand?.(e, t, o, this.editorContext);
301
+ for (const o of this.plugins)
302
+ o.afterCommand?.(e, t, s, this.editorContext);
301
303
  }
302
304
  dispatchUiEvent(e) {
303
305
  if (this.runtimeCtx)
@@ -319,9 +321,9 @@ class Dt {
319
321
  collectContextMenuItems(e) {
320
322
  if (!this.runtimeCtx) return [];
321
323
  const t = [];
322
- for (const o of this.plugins) {
323
- const n = o.onBlankContextMenu?.(e, this.runtimeCtx);
324
- n && t.push(...n);
324
+ for (const s of this.plugins) {
325
+ const o = s.onBlankContextMenu?.(e, this.runtimeCtx);
326
+ o && t.push(...o);
325
327
  }
326
328
  return t;
327
329
  }
@@ -330,20 +332,20 @@ class Dt {
330
332
  if (!this.editorContext) return [];
331
333
  const e = /* @__PURE__ */ new Map();
332
334
  for (const t of this.plugins) {
333
- const o = t.provideToolbarItems?.(this.editorContext);
334
- if (o)
335
- for (const n of o)
336
- e.set(n.id, n);
335
+ const s = t.provideToolbarItems?.(this.editorContext);
336
+ if (s)
337
+ for (const o of s)
338
+ e.set(o.id, o);
337
339
  }
338
- return [...e.values()].sort((t, o) => (t.order ?? 0) - (o.order ?? 0));
340
+ return [...e.values()].sort((t, s) => (t.order ?? 0) - (s.order ?? 0));
339
341
  }
340
342
  /** 合并所有插件对某节点的装饰(className / borderColor / badge),后注册覆盖先注册 */
341
343
  collectNodeDecorations(e) {
342
344
  if (!this.editorContext) return;
343
345
  let t;
344
- for (const o of this.plugins) {
345
- const n = o.decorateNode?.(e, this.editorContext);
346
- n && (t = t ? { ...t, ...n } : n);
346
+ for (const s of this.plugins) {
347
+ const o = s.decorateNode?.(e, this.editorContext);
348
+ o && (t = t ? { ...t, ...o } : o);
347
349
  }
348
350
  return t;
349
351
  }
@@ -351,9 +353,9 @@ class Dt {
351
353
  collectEdgeDecorations(e) {
352
354
  if (!this.editorContext) return;
353
355
  let t;
354
- for (const o of this.plugins) {
355
- const n = o.decorateEdge?.(e, this.editorContext);
356
- n && (t = t ? { ...t, ...n } : n);
356
+ for (const s of this.plugins) {
357
+ const o = s.decorateEdge?.(e, this.editorContext);
358
+ o && (t = t ? { ...t, ...o } : o);
357
359
  }
358
360
  return t;
359
361
  }
@@ -361,8 +363,8 @@ class Dt {
361
363
  if (!this.runtimeCtx) return {};
362
364
  const e = {};
363
365
  for (const t of this.plugins) {
364
- const o = t.extendApi?.(this.runtimeCtx.api, this.runtimeCtx);
365
- o && Object.assign(e, o);
366
+ const s = t.extendApi?.(this.runtimeCtx.api, this.runtimeCtx);
367
+ s && Object.assign(e, s);
366
368
  }
367
369
  return e;
368
370
  }
@@ -370,152 +372,156 @@ class Dt {
370
372
  createPreview(e) {
371
373
  const t = this.editorContext;
372
374
  return {
373
- previewFlowModel(o) {
374
- const n = o ?? e.commands;
375
- let r = t.flowModel.value;
376
- for (const i of n)
377
- r = Ge(r, i);
378
- return r;
375
+ previewFlowModel(s) {
376
+ const o = s ?? e.commands;
377
+ let i = t.flowModel.value;
378
+ for (const r of o)
379
+ i = Re(i, r);
380
+ return i;
379
381
  }
380
382
  };
381
383
  }
382
384
  }
383
- let Pt = 0;
384
- function W() {
385
- const s = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
386
- return `${s}-${e}-${++Pt}`;
385
+ let Dt = 0;
386
+ function Z() {
387
+ const n = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
388
+ return `${n}-${e}-${++Dt}`;
387
389
  }
388
- const He = () => W();
389
- function No(s) {
390
- const { schema: e, plugins: t = [], historyOptions: o } = s, n = s.idGenerator ?? He, r = { version: "1.0", ...s.initialFlowModel }, i = Nt(r, o), l = O(s.mode ?? "edit"), a = O(!1), g = O(null), d = O([]), v = {}, f = new Dt();
391
- function p(m, D, z, X = "user:toolbar") {
392
- const j = {
390
+ const Oe = () => Z();
391
+ function an(n) {
392
+ const { schema: e, plugins: t = [], historyOptions: s } = n, o = n.idGenerator ?? Oe, i = { version: "1.0", ...n.initialFlowModel }, r = _t(i, s), l = O(n.mode ?? "edit"), a = O(!1), p = O(null), c = O([]), g = {}, u = new Mt();
393
+ function y(D, L, H, K = "user:toolbar") {
394
+ const $ = {
393
395
  id: `history-${Date.now()}`,
394
- source: X,
395
- label: m,
396
+ source: K,
397
+ label: D,
396
398
  timestamp: Date.now(),
397
399
  commands: []
398
400
  };
399
- f.afterCommand(j, D, z), d.value = f.collectToolbarItems(), s.onCommandResult?.({
401
+ u.afterCommand($, L, H), c.value = u.collectToolbarItems(), n.onCommandResult?.({
400
402
  status: "applied",
401
- envelope: j,
402
- flowModel: z
403
- }), s.onFlowModelChange?.({
404
- flowModel: z,
405
- prevFlowModel: D,
406
- envelope: j,
407
- source: X
403
+ envelope: $,
404
+ flowModel: H
405
+ }), n.onFlowModelChange?.({
406
+ flowModel: H,
407
+ prevFlowModel: L,
408
+ envelope: $,
409
+ source: K
408
410
  });
409
411
  }
410
- const E = {
411
- execute: i.execute,
412
+ const v = {
413
+ execute: r.execute,
412
414
  undo() {
413
- const m = i.currentFlowModel.value, D = i.undo();
414
- return D && p("撤销", m, D), D;
415
+ const D = r.currentFlowModel.value, L = r.undo();
416
+ return L && y("撤销", D, L), L;
415
417
  },
416
418
  redo() {
417
- const m = i.currentFlowModel.value, D = i.redo();
418
- return D && p("重做", m, D), D;
419
+ const D = r.currentFlowModel.value, L = r.redo();
420
+ return L && y("重做", D, L), L;
419
421
  },
420
422
  get canUndo() {
421
- return i.canUndo;
423
+ return r.canUndo;
422
424
  },
423
425
  get canRedo() {
424
- return i.canRedo;
426
+ return r.canRedo;
425
427
  },
426
428
  get undoStack() {
427
- return i.undoStack;
429
+ return r.undoStack;
428
430
  },
429
431
  get redoStack() {
430
- return i.redoStack;
432
+ return r.redoStack;
431
433
  },
432
- clear: i.clear,
433
- createSnapshot: i.createSnapshot,
434
- replaceFlowModel(m) {
435
- const D = i.currentFlowModel.value;
436
- i.replaceFlowModel(m), p("替换 FlowModel", D, m, "system:replace");
437
- }
438
- }, w = {
439
- flowModel: F(() => i.currentFlowModel.value),
440
- history: E,
434
+ clear: r.clear,
435
+ createSnapshot: r.createSnapshot,
436
+ replaceFlowModel(D) {
437
+ const L = r.currentFlowModel.value;
438
+ r.replaceFlowModel(D), y("替换 FlowModel", L, D, "system:replace");
439
+ }
440
+ }, C = {
441
+ flowModel: j(() => r.currentFlowModel.value),
442
+ history: v,
441
443
  schema: e,
442
444
  mode: l,
443
- idGenerator: n,
444
- executeCommand: N,
445
- replaceFlowModel(m) {
446
- E.replaceFlowModel(m);
445
+ idGenerator: o,
446
+ executeCommand: M,
447
+ replaceFlowModel(D) {
448
+ v.replaceFlowModel(D);
447
449
  },
448
- setMode(m) {
449
- l.value = m;
450
+ setMode(D) {
451
+ l.value = D;
450
452
  },
451
453
  selectionMode: a,
452
- setSelectionMode(m) {
453
- a.value = m;
454
+ setSelectionMode(D) {
455
+ a.value = D;
454
456
  },
455
- api: g,
456
- toolbarItems: d,
457
- extendedApi: v,
458
- _pluginManager: f
457
+ api: p,
458
+ toolbarItems: c,
459
+ extendedApi: g,
460
+ _pluginManager: u,
461
+ _emitUiEvent: (D) => {
462
+ u.dispatchUiEvent(D);
463
+ }
459
464
  };
460
- f.install(t, {
461
- flowModel: w.flowModel,
462
- history: E,
465
+ u.install(t, {
466
+ flowModel: C.flowModel,
467
+ history: v,
463
468
  schema: e,
464
469
  mode: l,
465
- idGenerator: n,
466
- executeCommand: N
467
- }), d.value = f.collectToolbarItems(), et(() => {
468
- f.dispose();
470
+ idGenerator: o,
471
+ executeCommand: M
472
+ }), c.value = u.collectToolbarItems(), Ye(() => {
473
+ u.dispose();
469
474
  });
470
- function N(m) {
471
- const D = f.transformCommand(m);
472
- if ("rejected" in D) {
473
- const j = {
475
+ function M(D) {
476
+ const L = u.transformCommand(D);
477
+ if ("rejected" in L) {
478
+ const $ = {
474
479
  status: "rejected",
475
- envelope: m,
476
- error: D.error
480
+ envelope: D,
481
+ error: L.error
477
482
  };
478
- return s.onCommandResult?.(j), j;
483
+ return n.onCommandResult?.($), $;
479
484
  }
480
- const z = D.envelope, X = i.currentFlowModel.value;
485
+ const H = L.envelope, K = r.currentFlowModel.value;
481
486
  try {
482
- const j = i.execute(z), oe = {
487
+ const $ = r.execute(H), W = {
483
488
  status: "applied",
484
- envelope: z,
485
- flowModel: j
489
+ envelope: H,
490
+ flowModel: $
486
491
  };
487
- return f.afterCommand(z, X, j), d.value = f.collectToolbarItems(), s.onCommandResult?.(oe), s.onFlowModelChange?.({
488
- flowModel: j,
489
- prevFlowModel: X,
490
- envelope: z,
491
- source: z.source
492
- }), oe;
493
- } catch (j) {
494
- if (j instanceof ne) {
495
- const oe = {
492
+ return u.afterCommand(H, K, $), c.value = u.collectToolbarItems(), n.onCommandResult?.(W), n.onFlowModelChange?.({
493
+ flowModel: $,
494
+ prevFlowModel: K,
495
+ envelope: H,
496
+ source: H.source
497
+ }), W;
498
+ } catch ($) {
499
+ if ($ instanceof ae) {
500
+ const W = {
496
501
  status: "invalid",
497
- envelope: z,
502
+ envelope: H,
498
503
  error: {
499
504
  code: "constraint_violated",
500
- reason: j.message,
505
+ reason: $.message,
501
506
  source: "engine"
502
507
  }
503
508
  };
504
- return s.onCommandResult?.(oe), oe;
509
+ return n.onCommandResult?.(W), W;
505
510
  }
506
- throw j;
511
+ throw $;
507
512
  }
508
513
  }
509
- return w;
514
+ return C;
510
515
  }
511
- const _t = ["top", "right", "bottom", "left"];
512
- function nt() {
513
- return _t.map((s) => ({ id: s, group: s }));
516
+ const At = ["top", "right", "bottom", "left"];
517
+ function et() {
518
+ return At.map((n) => ({ id: n, group: n }));
514
519
  }
515
- function Fe(s, e) {
516
- return e?.(s) ?? s.ports ?? nt();
520
+ function Be(n, e) {
521
+ return e?.(n) ?? n.ports ?? et();
517
522
  }
518
- class At {
523
+ const De = -1, Pt = "flow-canvas-node-ring-target", He = "flow-canvas-node-ring-target--decorated", Ge = "flow-canvas-node-ring-target--pulse", Tt = "linear-gradient(135deg, #cadcfa 0%, #cee0ff 100%)";
524
+ class Rt {
519
525
  graph;
520
526
  schema;
521
527
  shapeRegistry;
@@ -540,15 +546,15 @@ class At {
540
546
  /** x6EdgeConfig 中 attrs.line 的基线值,清理时恢复而非删除 */
541
547
  edgeDefaultAttrs = /* @__PURE__ */ new Map();
542
548
  lastModel = null;
543
- constructor(e, t, o, n, r, i) {
544
- this.graph = e, this.schema = t, this.shapeRegistry = o, this.resolveNodeDecoration = n, this.resolveEdgeDecoration = r, this.resolveCanvasContext = i;
549
+ constructor(e, t, s, o, i, r) {
550
+ this.graph = e, this.schema = t, this.shapeRegistry = s, this.resolveNodeDecoration = o, this.resolveEdgeDecoration = i, this.resolveCanvasContext = r;
545
551
  }
546
552
  syncFlowModel(e) {
547
553
  if (!this.syncing) {
548
554
  this.syncing = !0, this.lastModel = e;
549
555
  try {
550
- const t = this.resolveNodes(e), o = this.resolveEdges(e);
551
- this.syncNodes(t), this.syncEdges(o, e);
556
+ const t = this.resolveNodes(e), s = this.resolveEdges(e);
557
+ this.syncNodes(t), this.syncEdges(s, e);
552
558
  } finally {
553
559
  this.syncing = !1;
554
560
  }
@@ -562,100 +568,113 @@ class At {
562
568
  * 仅在节点首次创建时调用一次。
563
569
  */
564
570
  saveNodeDefaultAttrs(e, t) {
565
- const n = t.x6CellConfig?.attrs?.body;
566
- if (!n) return;
567
- const r = {};
568
- let i = !1;
569
- n.stroke !== void 0 && (r.stroke = n.stroke, i = !0), n.strokeWidth !== void 0 && (r.strokeWidth = n.strokeWidth, i = !0), i && this.nodeDefaultAttrs.set(e, r);
571
+ const o = t.x6CellConfig?.attrs?.body;
572
+ if (!o) return;
573
+ const i = {};
574
+ let r = !1;
575
+ o.stroke !== void 0 && (i.stroke = o.stroke, r = !0), o.strokeWidth !== void 0 && (i.strokeWidth = o.strokeWidth, r = !0), r && this.nodeDefaultAttrs.set(e, i);
570
576
  }
571
577
  /**
572
578
  * 从 x6EdgeConfig.attrs.line 中提取基线描边,用于管理层清理时恢复。
573
579
  */
574
580
  saveEdgeDefaultAttrs(e, t) {
575
- const n = t?.x6EdgeConfig?.attrs?.line;
576
- if (!n) return;
577
- const r = {};
578
- let i = !1;
579
- n.stroke !== void 0 && (r.stroke = n.stroke, i = !0), n.strokeWidth !== void 0 && (r.strokeWidth = n.strokeWidth, i = !0), n.strokeDasharray !== void 0 && (r.strokeDasharray = n.strokeDasharray, i = !0), i && this.edgeDefaultAttrs.set(e, r);
581
+ const o = t?.x6EdgeConfig?.attrs?.line;
582
+ if (!o) return;
583
+ const i = {};
584
+ let r = !1;
585
+ o.stroke !== void 0 && (i.stroke = o.stroke, r = !0), o.strokeWidth !== void 0 && (i.strokeWidth = o.strokeWidth, r = !0), o.strokeDasharray !== void 0 && (i.strokeDasharray = o.strokeDasharray, r = !0), r && this.edgeDefaultAttrs.set(e, i);
580
586
  }
581
- /** 恢复节点 attr 到基线值;无基线时移除。 */
582
- restoreNodeAttr(e, t, o) {
583
- const n = this.nodeDefaultAttrs.get(e.id)?.[o];
584
- n !== void 0 ? e.setAttrByPath(t, n) : e.removeAttrByPath(t);
587
+ /**
588
+ * 恢复节点 attr 到基线值;无基线时设为安全默认值。
589
+ * 不使用 removeAttrByPath,因为对 Vue Shape 节点执行 remove 会触发 X6
590
+ * 完整的 cell view 重渲染,可能导致 foreignObject 尺寸被瞬间重置,
591
+ * 使得内部 Vue 组件 (width/height: 100%) 折叠后无法恢复。
592
+ */
593
+ restoreNodeAttr(e, t, s) {
594
+ const o = this.nodeDefaultAttrs.get(e.id)?.[s];
595
+ if (o !== void 0)
596
+ e.setAttrByPath(t, o);
597
+ else {
598
+ const i = s === "stroke" ? "none" : 0;
599
+ e.setAttrByPath(t, i);
600
+ }
585
601
  }
586
602
  /** 恢复边 attr 到基线值;无基线时移除。 */
587
- restoreEdgeAttr(e, t, o) {
588
- const n = this.edgeDefaultAttrs.get(e.id)?.[o];
589
- n !== void 0 ? e.setAttrByPath(t, n) : e.removeAttrByPath(t);
603
+ restoreEdgeAttr(e, t, s) {
604
+ const o = this.edgeDefaultAttrs.get(e.id)?.[s];
605
+ o !== void 0 ? e.setAttrByPath(t, o) : e.removeAttrByPath(t);
606
+ }
607
+ getNodeRingTarget(e) {
608
+ return e ? e.querySelector(".flow-canvas-highlight-target") ?? e.querySelector(".flow-canvas-node-surface > :first-child") : null;
590
609
  }
591
610
  /** 让正式边接管交互式预览边时,恢复 schema 定义的端点 marker。 */
592
- syncEdgeMarker(e, t, o) {
593
- const r = t?.x6EdgeConfig?.attrs?.line?.[o], i = `line/${o}`;
594
- e.removeAttrByPath(i), r !== void 0 && e.setAttrByPath(i, r);
611
+ syncEdgeMarker(e, t, s) {
612
+ const i = t?.x6EdgeConfig?.attrs?.line?.[s], r = `line/${s}`;
613
+ e.removeAttrByPath(r), i !== void 0 && e.setAttrByPath(r, i);
595
614
  }
596
615
  dispose() {
597
616
  this.knownNodeIds.clear(), this.knownEdgeIds.clear();
598
617
  }
599
618
  resolveNodes(e) {
600
619
  const t = /* @__PURE__ */ new Map();
601
- for (const [o, n] of Object.entries(e.nodes)) {
602
- const r = this.schema.nodeTypes[n.type];
603
- if (!r)
620
+ for (const [s, o] of Object.entries(e.nodes)) {
621
+ const i = this.schema.nodeTypes[o.type];
622
+ if (!i)
604
623
  throw new pt(
605
- `Unknown node type "${n.type}" for node "${o}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`
624
+ `Unknown node type "${o.type}" for node "${s}". Registered types: [${Object.keys(this.schema.nodeTypes).join(", ")}]. Register the type in CanvasSchema.nodeTypes before using it in a FlowModel.`
606
625
  );
607
- const i = this.shapeRegistry.registerNodeType(n.type, r.component), l = r.getSize(n), a = Fe(n, r.getPorts);
608
- t.set(o, { model: n, definition: r, shapeName: i, size: l, ports: a });
626
+ const r = this.shapeRegistry.registerNodeType(o.type, i.component), l = i.getSize(o), a = Be(o, i.getPorts);
627
+ t.set(s, { model: o, definition: i, shapeName: r, size: l, ports: a });
609
628
  }
610
629
  return t;
611
630
  }
612
631
  resolveEdges(e) {
613
632
  const t = /* @__PURE__ */ new Map();
614
- for (const [o, n] of Object.entries(e.edges)) {
615
- const r = n.type ?? this.schema.defaultEdgeType ?? "default", i = this.schema.edgeTypes?.[r];
616
- t.set(o, { model: n, definition: i });
633
+ for (const [s, o] of Object.entries(e.edges)) {
634
+ const i = o.type ?? this.schema.defaultEdgeType ?? "default", r = this.schema.edgeTypes?.[i];
635
+ t.set(s, { model: o, definition: r });
617
636
  }
618
637
  return t;
619
638
  }
620
639
  syncNodes(e) {
621
640
  const t = new Set(e.keys());
622
- for (const o of this.knownNodeIds)
623
- if (!t.has(o)) {
624
- const n = this.graph.getCellById(o);
625
- n && this.graph.removeCell(n), this.knownNodeIds.delete(o), this.defaultHighlightedNodeIds.delete(o), this.prevNodeDecorationClasses.delete(o), this.prevNodeDecorationColors.delete(o), this.nodeDefaultAttrs.delete(o);
641
+ for (const s of this.knownNodeIds)
642
+ if (!t.has(s)) {
643
+ const o = this.graph.getCellById(s);
644
+ o && this.graph.removeCell(o), this.knownNodeIds.delete(s), this.defaultHighlightedNodeIds.delete(s), this.prevNodeDecorationClasses.delete(s), this.prevNodeDecorationColors.delete(s), this.nodeDefaultAttrs.delete(s);
626
645
  }
627
- for (const [o, n] of e) {
628
- const r = this.graph.getCellById(o);
629
- r ? this.updateExistingNode(r, n) : this.addNewNode(o, n);
646
+ for (const [s, o] of e) {
647
+ const i = this.graph.getCellById(s);
648
+ i ? this.updateExistingNode(i, o) : this.addNewNode(s, o);
630
649
  }
631
650
  }
632
651
  updateExistingNode(e, t) {
633
- const { model: o, size: n, ports: r, definition: i } = t;
634
- if (e.getData()?.type !== o.type) {
652
+ const { model: s, size: o, ports: i, definition: r } = t;
653
+ if (e.getData()?.type !== s.type) {
635
654
  this.graph.removeCell(e), this.addNewNode(e.id, t);
636
655
  return;
637
656
  }
638
657
  const a = e.getPosition();
639
- (a.x !== o.position.x || a.y !== o.position.y) && e.setPosition(o.position.x, o.position.y);
640
- const g = e.getSize();
641
- (g.width !== n.width || g.height !== n.height) && e.setSize(n.width, n.height, { silent: !0 }), this.syncNodePorts(e, r), e.setData({ ...o }), this.applyNodeBehavior(e, o, i), this.applyNodeHighlightAndDecoration(e, o);
658
+ (a.x !== s.position.x || a.y !== s.position.y) && e.setPosition(s.position.x, s.position.y);
659
+ const p = e.getSize();
660
+ (p.width !== o.width || p.height !== o.height) && e.setSize(o.width, o.height, { silent: !0 }), this.syncNodePorts(e, i), e.setData({ ...s }), this.applyNodeBehavior(e, s, r), this.applyNodeHighlightAndDecoration(e, s);
642
661
  }
643
662
  syncNodePorts(e, t) {
644
- const o = e.getPorts(), n = new Set(t.map((i) => i.id)), r = new Set(o.map((i) => i.id));
645
- for (const i of o)
646
- i.id && !n.has(i.id) && e.removePort(i.id);
647
- for (const i of t)
648
- r.has(i.id) || e.addPort({ id: i.id, group: i.group, ...i.x6PortConfig });
663
+ const s = e.getPorts(), o = new Set(t.map((r) => r.id)), i = new Set(s.map((r) => r.id));
664
+ for (const r of s)
665
+ r.id && !o.has(r.id) && e.removePort(r.id);
666
+ for (const r of t)
667
+ i.has(r.id) || e.addPort({ id: r.id, group: r.group, ...r.x6PortConfig });
649
668
  }
650
669
  addNewNode(e, t) {
651
- const { model: o, shapeName: n, size: r, ports: i, definition: l } = t, a = {
652
- id: o.id,
653
- shape: n,
654
- x: o.position.x,
655
- y: o.position.y,
656
- width: r.width,
657
- height: r.height,
658
- data: { ...o },
670
+ const { model: s, shapeName: o, size: i, ports: r, definition: l } = t, a = {
671
+ id: s.id,
672
+ shape: o,
673
+ x: s.position.x,
674
+ y: s.position.y,
675
+ width: i.width,
676
+ height: i.height,
677
+ data: { ...s },
659
678
  ports: {
660
679
  groups: {
661
680
  top: {
@@ -683,51 +702,54 @@ class At {
683
702
  }
684
703
  }
685
704
  },
686
- items: i.map((d) => ({ id: d.id, group: d.group, ...d.x6PortConfig }))
705
+ items: r.map((c) => ({ id: c.id, group: c.group, ...c.x6PortConfig }))
687
706
  },
688
707
  ...l.x6CellConfig
689
708
  };
690
709
  this.graph.addNode(a), this.knownNodeIds.add(e), this.saveNodeDefaultAttrs(e, l);
691
- const g = this.graph.getCellById(e);
692
- g && (this.applyNodeBehavior(g, o, l), this.applyNodeHighlightAndDecoration(g, o));
710
+ const p = this.graph.getCellById(e);
711
+ p && (this.applyNodeBehavior(p, s, l), this.applyNodeHighlightAndDecoration(p, s));
693
712
  }
694
713
  /**
695
714
  * 将 schema 定义的 getBehavior 映射到 X6 节点属性。
696
715
  * NodeBehaviorConfig 的每个字段都映射到 X6 Cell 对应能力:
697
716
  * - draggable → 是否可拖拽移动
698
717
  * - selectable → 是否可被选中(注意:X6 Selection 插件也有全局控制)
699
- * - connectable → ports 的 magnet 属性,控制是否可从该节点发起连线
718
+ * - connectable / targetable → ports 的 magnet 属性
719
+ * true → 可发起,也可作为目标
720
+ * 'passive' → 不可发起,但仍可作为目标(如结束节点)
721
+ * false → 不可发起,也不可作为目标
700
722
  * - showPorts → ports 的可见性
701
723
  * - deletable → 存入 cell data,由删除操作(插件/快捷键)自行读取判断
702
724
  */
703
- applyNodeBehavior(e, t, o) {
704
- if (!o.getBehavior) return;
705
- const n = this.resolveCanvasContext?.();
706
- if (!n) return;
707
- const r = o.getBehavior(t, n);
708
- if (r.draggable !== void 0 && e.setProp("draggable", r.draggable, { silent: !0 }), r.connectable !== void 0) {
709
- const l = r.connectable;
725
+ applyNodeBehavior(e, t, s) {
726
+ if (!s.getBehavior) return;
727
+ const o = this.resolveCanvasContext?.();
728
+ if (!o) return;
729
+ const i = s.getBehavior(t, o);
730
+ if (i.draggable !== void 0 && e.setProp("draggable", i.draggable, { silent: !0 }), i.connectable !== void 0) {
731
+ const l = i.connectable ? !0 : i.targetable === !1 ? !1 : "passive";
710
732
  for (const a of e.getPorts())
711
733
  e.setPortProp(a.id, "attrs/circle/magnet", l, { silent: !0 });
712
734
  }
713
- if (r.showPorts !== void 0) {
714
- const l = r.showPorts;
735
+ if (i.showPorts !== void 0) {
736
+ const l = i.showPorts;
715
737
  for (const a of e.getPorts())
716
738
  e.setPortProp(a.id, "attrs/circle/visibility", l ? "visible" : "hidden", { silent: !0 });
717
739
  }
718
- const i = e.getData() ?? {};
719
- r.deletable !== void 0 && i._deletable !== r.deletable && e.setData({ ...i, _deletable: r.deletable }, { silent: !0 }), r.selectable !== void 0 && i._selectable !== r.selectable && e.setData({ ...e.getData(), _selectable: r.selectable }, { silent: !0 });
740
+ const r = e.getData() ?? {};
741
+ i.deletable !== void 0 && r._deletable !== i.deletable && e.setData({ ...r, _deletable: i.deletable }, { silent: !0 }), i.selectable !== void 0 && r._selectable !== i.selectable && e.setData({ ...e.getData(), _selectable: i.selectable }, { silent: !0 });
720
742
  }
721
743
  syncEdges(e, t) {
722
- const o = new Set(e.keys());
723
- for (const n of this.knownEdgeIds)
724
- if (!o.has(n)) {
725
- const r = this.graph.getCellById(n);
726
- r && this.graph.removeCell(r), this.knownEdgeIds.delete(n), this.defaultHighlightedEdgeIds.delete(n), this.prevEdgeDecorationClasses.delete(n), this.prevEdgeDecorationColors.delete(n), this.prevEdgeStyleIds.delete(n), this.edgeDefaultAttrs.delete(n);
744
+ const s = new Set(e.keys());
745
+ for (const o of this.knownEdgeIds)
746
+ if (!s.has(o)) {
747
+ const i = this.graph.getCellById(o);
748
+ i && this.graph.removeCell(i), this.knownEdgeIds.delete(o), this.defaultHighlightedEdgeIds.delete(o), this.prevEdgeDecorationClasses.delete(o), this.prevEdgeDecorationColors.delete(o), this.prevEdgeStyleIds.delete(o), this.edgeDefaultAttrs.delete(o);
727
749
  }
728
- for (const [n, r] of e) {
729
- const i = this.graph.getCellById(n), { model: l, definition: a } = r;
730
- i ? (this.updateExistingEdge(i, l, a, t), this.knownEdgeIds.has(n) || (this.knownEdgeIds.add(n), this.saveEdgeDefaultAttrs(n, a))) : this.addNewEdge(n, l, a);
750
+ for (const [o, i] of e) {
751
+ const r = this.graph.getCellById(o), { model: l, definition: a } = i;
752
+ r ? (this.updateExistingEdge(r, l, a, t), this.knownEdgeIds.has(o) || (this.knownEdgeIds.add(o), this.saveEdgeDefaultAttrs(o, a))) : this.addNewEdge(o, l, a);
731
753
  }
732
754
  }
733
755
  /**
@@ -735,45 +757,45 @@ class At {
735
757
  * X6 Edge.getSource() 返回 { cell, port } 格式,与 FlowEdgeModel 的 { nodeId, portId } 不同,
736
758
  * 需要用 (currentSource as any).cell 来比较。
737
759
  */
738
- updateExistingEdge(e, t, o, n) {
739
- const r = e.getSource(), i = e.getTarget();
740
- if ((r.cell !== t.source.nodeId || r.port !== t.source.portId) && e.setSource({ cell: t.source.nodeId, port: t.source.portId }), (i.cell !== t.target.nodeId || i.port !== t.target.portId) && e.setTarget({ cell: t.target.nodeId, port: t.target.portId }), o?.router) {
741
- const l = typeof o.router == "string" ? { name: o.router } : o.router;
760
+ updateExistingEdge(e, t, s, o) {
761
+ const i = e.getSource(), r = e.getTarget();
762
+ if ((i.cell !== t.source.nodeId || i.port !== t.source.portId) && e.setSource({ cell: t.source.nodeId, port: t.source.portId }), (r.cell !== t.target.nodeId || r.port !== t.target.portId) && e.setTarget({ cell: t.target.nodeId, port: t.target.portId }), s?.router) {
763
+ const l = typeof s.router == "string" ? { name: s.router } : s.router;
742
764
  e.setRouter(l);
743
765
  }
744
- if (o?.connector) {
745
- const l = typeof o.connector == "string" ? { name: o.connector } : o.connector;
766
+ if (s?.connector) {
767
+ const l = typeof s.connector == "string" ? { name: s.connector } : s.connector;
746
768
  e.setConnector(l);
747
769
  }
748
- this.syncEdgeMarker(e, o, "sourceMarker"), this.syncEdgeMarker(e, o, "targetMarker"), this.syncEdgeLabels(e, t), e.setData({ ...t }, { silent: !0 }), this.applyEdgeStyleAndDecoration(e, t, o);
770
+ this.syncEdgeMarker(e, s, "sourceMarker"), this.syncEdgeMarker(e, s, "targetMarker"), this.syncEdgeLabels(e, t), e.getZIndex() !== De && e.setZIndex(De), e.setData({ ...t }, { silent: !0 }), this.applyEdgeStyleAndDecoration(e, t, s);
749
771
  }
750
772
  syncEdgeLabels(e, t) {
751
773
  if (!t.labels?.length) {
752
774
  e.getLabels().length > 0 && e.setLabels([]);
753
775
  return;
754
776
  }
755
- const o = t.labels.map((n) => ({
777
+ const s = t.labels.map((o) => ({
756
778
  attrs: {
757
- label: { text: n.text ?? "" }
779
+ label: { text: o.text ?? "" }
758
780
  },
759
- position: n.position != null ? { distance: n.position } : void 0
781
+ position: o.position != null ? { distance: o.position } : void 0
760
782
  }));
761
- e.setLabels(o);
783
+ e.setLabels(s);
762
784
  }
763
- addNewEdge(e, t, o) {
764
- const n = {
785
+ addNewEdge(e, t, s) {
786
+ const o = {
765
787
  id: t.id,
766
788
  source: { cell: t.source.nodeId, port: t.source.portId },
767
789
  target: { cell: t.target.nodeId, port: t.target.portId },
768
790
  data: { ...t },
769
- zIndex: -1
791
+ zIndex: De
770
792
  };
771
- o?.router && (n.router = typeof o.router == "string" ? { name: o.router } : o.router), o?.connector && (n.connector = typeof o.connector == "string" ? { name: o.connector } : o.connector), o?.x6EdgeConfig && Object.assign(n, o.x6EdgeConfig), t.labels?.length && (n.labels = t.labels.map((i) => ({
772
- attrs: { label: { text: i.text ?? "" } },
773
- position: i.position != null ? { distance: i.position } : void 0
774
- }))), this.graph.addEdge(n), this.knownEdgeIds.add(e), this.saveEdgeDefaultAttrs(e, o);
775
- const r = this.graph.getCellById(e);
776
- r && this.applyEdgeStyleAndDecoration(r, t, o);
793
+ s?.router && (o.router = typeof s.router == "string" ? { name: s.router } : s.router), s?.connector && (o.connector = typeof s.connector == "string" ? { name: s.connector } : s.connector), s?.x6EdgeConfig && Object.assign(o, s.x6EdgeConfig), t.labels?.length && (o.labels = t.labels.map((r) => ({
794
+ attrs: { label: { text: r.text ?? "" } },
795
+ position: r.position != null ? { distance: r.position } : void 0
796
+ }))), this.graph.addEdge(o), this.knownEdgeIds.add(e), this.saveEdgeDefaultAttrs(e, s);
797
+ const i = this.graph.getCellById(e);
798
+ i && this.applyEdgeStyleAndDecoration(i, t, s);
777
799
  }
778
800
  /**
779
801
  * 外部通知选区、高亮或 hover 变化时,重算所有边的视觉样式。
@@ -783,10 +805,10 @@ class At {
783
805
  refreshEdgeStyles() {
784
806
  if (this.lastModel)
785
807
  for (const [e, t] of Object.entries(this.lastModel.edges)) {
786
- const o = this.graph.getCellById(e);
787
- if (!o?.isEdge()) continue;
788
- const n = t.type ?? this.schema.defaultEdgeType ?? "default", r = this.schema.edgeTypes?.[n];
789
- this.applyEdgeStyleAndDecoration(o, t, r);
808
+ const s = this.graph.getCellById(e);
809
+ if (!s?.isEdge()) continue;
810
+ const o = t.type ?? this.schema.defaultEdgeType ?? "default", i = this.schema.edgeTypes?.[o];
811
+ this.applyEdgeStyleAndDecoration(s, t, i);
790
812
  }
791
813
  }
792
814
  /**
@@ -795,26 +817,30 @@ class At {
795
817
  refreshNodeHighlights() {
796
818
  if (this.lastModel)
797
819
  for (const [e, t] of Object.entries(this.lastModel.nodes)) {
798
- const o = this.graph.getCellById(e);
799
- o?.isNode() && this.applyNodeHighlightAndDecoration(o, t);
820
+ const s = this.graph.getCellById(e);
821
+ s?.isNode() && this.applyNodeHighlightAndDecoration(s, t);
800
822
  }
801
823
  }
802
824
  /**
803
825
  * 单节点的高亮 + 装饰统一管道。
804
826
  * 所有路径(FlowModel 同步更新/新增节点/显式刷新高亮)必须走此方法。
805
827
  *
806
- * body/stroke 的分层优先级(低 → 高):
828
+ * 可见高亮的分层优先级(低 → 高):
807
829
  * 1. 默认高亮 (#3a84ff) — 节点在 highlightedNodeIds 中时兜底
808
830
  * 2. 插件装饰 (decorateNode().borderColor) — 始终覆盖高亮
809
831
  *
810
832
  * 最终值 = decorationColor ?? highlightColor ?? (清除)。
811
- * 只在"曾经设过 现在无值"时执行 removeAttrByPath,避免误删 X6 原始样式。
833
+ * Vue Shape 节点,真正可见的 ring 通过节点高亮目标元素的独立装饰态 / 脉冲态 / 选中态 class 呈现;
834
+ * body/stroke 仅作为普通 SVG shape 的兜底同步。
812
835
  */
813
836
  applyNodeHighlightAndDecoration(e, t) {
814
- const o = this.highlightedNodeIds.has(e.id), n = this.resolveNodeDecoration?.(t), r = this.prevNodeDecorationClasses.get(e.id);
815
- r && (this.graph.findViewByCell(e)?.container?.classList.remove(r), this.prevNodeDecorationClasses.delete(e.id)), n?.className && (this.graph.findViewByCell(e)?.container?.classList.add(n.className), this.prevNodeDecorationClasses.set(e.id, n.className));
816
- const i = n?.borderColor, a = i ?? (o ? "#3a84ff" : void 0), g = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
817
- a ? (e.setAttrByPath("body/stroke", a), e.setAttrByPath("body/strokeWidth", 2)) : g && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), i ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !i ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
837
+ const s = this.highlightedNodeIds.has(e.id), o = this.resolveNodeDecoration?.(t), i = this.graph.findViewByCell(e)?.container, r = this.getNodeRingTarget(i), l = this.prevNodeDecorationClasses.get(e.id);
838
+ l && (i?.classList.remove(l), this.prevNodeDecorationClasses.delete(e.id)), o?.className && (i?.classList.add(o.className), this.prevNodeDecorationClasses.set(e.id, o.className));
839
+ const a = o?.borderColor, c = a ?? (s ? "#3a84ff" : void 0), g = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
840
+ c ? (e.setAttrByPath("body/stroke", c), e.setAttrByPath("body/strokeWidth", 2)) : g && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r && (r.classList.add(Pt), a ? (r.classList.add(He), r.style.setProperty("--flow-canvas-node-decoration-ring-background", a), r.style.setProperty("--flow-canvas-node-decoration-ring-opacity", "0.95")) : (r.classList.remove(He), r.style.removeProperty("--flow-canvas-node-decoration-ring-background"), r.style.removeProperty("--flow-canvas-node-decoration-ring-opacity")), s ? (r.classList.add(Ge), r.style.setProperty(
841
+ "--flow-canvas-node-pulse-ring-background",
842
+ a ?? Tt
843
+ ), r.style.setProperty("--flow-canvas-node-pulse-ring-opacity", "0.95")) : (r.classList.remove(Ge), r.style.removeProperty("--flow-canvas-node-pulse-ring-background"), r.style.removeProperty("--flow-canvas-node-pulse-ring-opacity"))), a ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), s && !a ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
818
844
  }
819
845
  setHoveredEdge(e) {
820
846
  this.hoveredEdgeId = e;
@@ -836,47 +862,54 @@ class At {
836
862
  * strokeWidth / strokeDasharray 仅由 schema style() 控制,不受装饰影响。
837
863
  * 最终值 = decorationStroke ?? styleStroke ?? defaultHighlightStroke ?? (清除)。
838
864
  */
839
- applyEdgeStyleAndDecoration(e, t, o) {
840
- const n = this.highlightedEdgeIds.has(e.id), r = this.resolveEdgeDecoration?.(t), i = this.prevEdgeDecorationClasses.get(e.id);
841
- i && (this.graph.findViewByCell(e)?.container?.classList.remove(i), this.prevEdgeDecorationClasses.delete(e.id)), r?.className && (this.graph.findViewByCell(e)?.container?.classList.add(r.className), this.prevEdgeDecorationClasses.set(e.id, r.className));
842
- let l, a, g;
843
- if (o?.style) {
844
- const E = this.graph.isSelected?.(e) ?? !1, w = this.hoveredEdgeId === e.id, N = o.style(t, { selected: E, highlighted: n, hovered: w });
845
- l = N.stroke, a = N.strokeWidth, g = N.strokeDasharray;
865
+ applyEdgeStyleAndDecoration(e, t, s) {
866
+ const o = this.highlightedEdgeIds.has(e.id), i = this.resolveEdgeDecoration?.(t), r = this.prevEdgeDecorationClasses.get(e.id);
867
+ r && (this.graph.findViewByCell(e)?.container?.classList.remove(r), this.prevEdgeDecorationClasses.delete(e.id)), i?.className && (this.graph.findViewByCell(e)?.container?.classList.add(i.className), this.prevEdgeDecorationClasses.set(e.id, i.className));
868
+ let l, a, p;
869
+ if (s?.style) {
870
+ const v = this.graph.isSelected?.(e) ?? !1, C = this.hoveredEdgeId === e.id, M = s.style(t, { selected: v, highlighted: o, hovered: C });
871
+ l = M.stroke, a = M.strokeWidth, p = M.strokeDasharray;
846
872
  }
847
- const d = !o?.style && n ? "#3a84ff" : void 0, v = r?.strokeColor, f = v ?? l ?? d, p = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
848
- f ? e.setAttrByPath("line/stroke", f) : p && this.restoreEdgeAttr(e, "line/stroke", "stroke"), o?.style ? (this.prevEdgeStyleIds.add(e.id), a ? e.setAttrByPath("line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), g ? e.setAttrByPath("line/strokeDasharray", g) : this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray")) : this.prevEdgeStyleIds.has(e.id) && (this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray"), this.prevEdgeStyleIds.delete(e.id)), v ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), d ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
873
+ const c = !s?.style && o ? "#3a84ff" : void 0, g = i?.strokeColor, u = g ?? l ?? c, y = !!s?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
874
+ u ? e.setAttrByPath("line/stroke", u) : y && this.restoreEdgeAttr(e, "line/stroke", "stroke"), s?.style ? (this.prevEdgeStyleIds.add(e.id), a ? e.setAttrByPath("line/strokeWidth", a) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), p ? e.setAttrByPath("line/strokeDasharray", p) : this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray")) : this.prevEdgeStyleIds.has(e.id) && (this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), this.restoreEdgeAttr(e, "line/strokeDasharray", "strokeDasharray"), this.prevEdgeStyleIds.delete(e.id)), g ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), c ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
849
875
  }
850
876
  }
851
- class Tt {
852
- instanceId = W();
877
+ class Lt {
878
+ instanceId = Z();
853
879
  registeredShapes = /* @__PURE__ */ new Map();
880
+ wrappedComponents = /* @__PURE__ */ new Map();
854
881
  getShapeName(e) {
855
882
  let t = this.registeredShapes.get(e);
856
883
  return t || (t = `flow-node-${this.instanceId}-${e}`, this.registeredShapes.set(e, t)), t;
857
884
  }
858
885
  registerNodeType(e, t) {
859
- const o = this.getShapeName(e);
860
- return ft({
861
- shape: o,
862
- component: t,
886
+ const s = this.getShapeName(e);
887
+ let o = this.wrappedComponents.get(e);
888
+ return o || (o = le({
889
+ name: `FlowCanvasNodeShape${e.replace(/(^|[-_])(\w)/g, (i, r, l) => l.toUpperCase())}`,
890
+ setup() {
891
+ return () => Ae("div", { class: "flow-canvas-node-surface" }, [Ae(t)]);
892
+ }
893
+ }), this.wrappedComponents.set(e, o)), ct({
894
+ shape: s,
895
+ component: o,
863
896
  width: 100,
864
897
  height: 40
865
- }), o;
898
+ }), s;
866
899
  }
867
900
  dispose() {
868
- this.registeredShapes.clear();
901
+ this.registeredShapes.clear(), this.wrappedComponents.clear();
869
902
  }
870
903
  }
871
- class Rt {
904
+ class $t {
872
905
  graph;
873
906
  onUiEvent;
874
907
  onCommand;
875
908
  flowModelRef;
876
909
  idGenerator;
877
910
  disposers = [];
878
- constructor(e, t, o, n, r) {
879
- this.graph = e, this.onUiEvent = t, this.onCommand = o, this.flowModelRef = n, this.idGenerator = r ?? He, this.bindEvents();
911
+ constructor(e, t, s, o, i) {
912
+ this.graph = e, this.onUiEvent = t, this.onCommand = s, this.flowModelRef = o, this.idGenerator = i ?? Oe, this.bindEvents();
880
913
  }
881
914
  dispose() {
882
915
  for (const e of this.disposers) e();
@@ -894,13 +927,13 @@ class Rt {
894
927
  position: { x: t.clientX, y: t.clientY }
895
928
  });
896
929
  }), this.on("edge:click", ({ edge: e, e: t }) => {
897
- const n = t.target?.closest?.(".x6-edge-label");
898
- if (n) {
899
- const i = e.getData?.()?.labels ?? [], l = n.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(n) : 0, g = i[Math.max(0, a)];
930
+ const o = t.target?.closest?.(".x6-edge-label");
931
+ if (o) {
932
+ const r = e.getData?.()?.labels ?? [], l = o.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(o) : 0, p = r[Math.max(0, a)];
900
933
  this.onUiEvent({
901
934
  type: "edge.label.click",
902
935
  edgeId: e.id,
903
- labelId: g?.id ?? `label-${a}`
936
+ labelId: p?.id ?? `label-${a}`
904
937
  });
905
938
  return;
906
939
  }
@@ -916,18 +949,18 @@ class Rt {
916
949
  }), this.on("node:moved", ({ node: e }) => {
917
950
  const t = e.getPosition();
918
951
  this.onCommand({
919
- id: W(),
952
+ id: Z(),
920
953
  source: "user:drag",
921
954
  label: "移动节点",
922
955
  timestamp: Date.now(),
923
956
  commands: [{ type: "node.move", nodeId: e.id, position: { x: t.x, y: t.y } }]
924
957
  });
925
958
  }), this.on("edge:connected", ({ edge: e, isNew: t }) => {
926
- const o = e.getSourceCell(), n = e.getTargetCell();
927
- if (!o || !n) return;
928
- const r = e.getSourcePortId(), i = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
959
+ const s = e.getSourceCell(), o = e.getTargetCell();
960
+ if (!s || !o) return;
961
+ const i = e.getSourcePortId(), r = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
929
962
  t && !l ? (this.graph.removeCell(e), this.onCommand({
930
- id: W(),
963
+ id: Z(),
931
964
  source: "user:drag",
932
965
  label: "连线",
933
966
  timestamp: Date.now(),
@@ -936,13 +969,13 @@ class Rt {
936
969
  type: "edge.add",
937
970
  edge: {
938
971
  id: this.idGenerator("edge"),
939
- source: { nodeId: o.id, portId: r ?? void 0 },
940
- target: { nodeId: n.id, portId: i ?? void 0 }
972
+ source: { nodeId: s.id, portId: i ?? void 0 },
973
+ target: { nodeId: o.id, portId: r ?? void 0 }
941
974
  }
942
975
  }
943
976
  ]
944
977
  })) : this.onCommand({
945
- id: W(),
978
+ id: Z(),
946
979
  source: "user:drag",
947
980
  label: "重连",
948
981
  timestamp: Date.now(),
@@ -950,32 +983,32 @@ class Rt {
950
983
  {
951
984
  type: "edge.reconnect",
952
985
  edgeId: e.id,
953
- source: { nodeId: o.id, portId: r ?? void 0 },
954
- target: { nodeId: n.id, portId: i ?? void 0 }
986
+ source: { nodeId: s.id, portId: i ?? void 0 },
987
+ target: { nodeId: o.id, portId: r ?? void 0 }
955
988
  }
956
989
  ]
957
990
  });
958
991
  }), this.on("edge:change:labels", ({ edge: e, current: t }) => {
959
- const n = e.getData?.()?.labels ?? [];
960
- if (!n.length || !t?.length) return;
961
- const r = [];
962
- for (let i = 0; i < Math.min(n.length, t.length); i++) {
963
- const l = t[i], a = n[i];
992
+ const o = e.getData?.()?.labels ?? [];
993
+ if (!o.length || !t?.length) return;
994
+ const i = [];
995
+ for (let r = 0; r < Math.min(o.length, t.length); r++) {
996
+ const l = t[r], a = o[r];
964
997
  if (!a?.id) continue;
965
- const g = typeof l.position == "object" ? l.position?.distance : l.position;
966
- g != null && r.push({
998
+ const p = typeof l.position == "object" ? l.position?.distance : l.position;
999
+ p != null && i.push({
967
1000
  type: "edge.label.update",
968
1001
  edgeId: e.id,
969
1002
  labelId: a.id,
970
- patch: { position: g }
1003
+ patch: { position: p }
971
1004
  });
972
1005
  }
973
- r.length && this.onCommand({
974
- id: W(),
1006
+ i.length && this.onCommand({
1007
+ id: Z(),
975
1008
  source: "user:drag",
976
1009
  label: "拖动标签",
977
1010
  timestamp: Date.now(),
978
- commands: r
1011
+ commands: i
979
1012
  });
980
1013
  });
981
1014
  }
@@ -983,121 +1016,154 @@ class Rt {
983
1016
  this.graph.on(e, t), this.disposers.push(() => this.graph.off(e, t));
984
1017
  }
985
1018
  }
986
- function $t(s) {
1019
+ function Ot(n) {
987
1020
  function e(t) {
988
- const o = s.getCellById(t);
989
- if (!o || !o.isNode()) return null;
990
- const n = o, r = n.getPosition(), i = n.getSize(), l = { x: r.x, y: r.y, width: i.width, height: i.height }, a = s.localToGraph(l);
1021
+ const s = n.getCellById(t);
1022
+ if (!s || !s.isNode()) return null;
1023
+ const o = s, i = o.getPosition(), r = o.getSize(), l = { x: i.x, y: i.y, width: r.width, height: r.height }, a = n.localToGraph(l);
991
1024
  return new DOMRect(a.x, a.y, a.width, a.height);
992
1025
  }
993
1026
  return {
994
1027
  getNodeScreenRect: e
995
1028
  };
996
1029
  }
997
- const Lt = 100;
998
- function Bt({
999
- graph: s,
1030
+ function tt(n) {
1031
+ return {
1032
+ nodeIds: n.filter((e) => e.isNode()).map((e) => e.id),
1033
+ edgeIds: n.filter((e) => e.isEdge()).map((e) => e.id)
1034
+ };
1035
+ }
1036
+ function Bt(n, e) {
1037
+ const t = [
1038
+ ...e.nodeIds.map((i) => n.getCellById(i)),
1039
+ ...e.edgeIds.map((i) => n.getCellById(i))
1040
+ ].filter((i) => !!i);
1041
+ if (t.length === 0) return null;
1042
+ const s = n.getCellsBBox(t);
1043
+ if (!s) return null;
1044
+ const o = n.localToGraph(s);
1045
+ return new DOMRect(o.x, o.y, o.width, o.height);
1046
+ }
1047
+ function ot(n, e, t) {
1048
+ const s = n.nodeIds.filter((r) => {
1049
+ const l = e.nodes[r];
1050
+ if (!l) return !1;
1051
+ const a = t(l);
1052
+ return a.deletable !== !1 && a.deleteDisabled !== !0;
1053
+ }), o = new Set(s), i = n.edgeIds.filter((r) => {
1054
+ const l = e.edges[r];
1055
+ return l ? !o.has(l.source.nodeId) && !o.has(l.target.nodeId) : !1;
1056
+ });
1057
+ return { nodeIds: s, edgeIds: i };
1058
+ }
1059
+ function Ht(n) {
1060
+ return [
1061
+ ...n.edgeIds.map((e) => ({ type: "edge.remove", edgeId: e })),
1062
+ ...n.nodeIds.map((e) => ({ type: "node.remove", nodeId: e }))
1063
+ ];
1064
+ }
1065
+ const Gt = 100;
1066
+ function qt({
1067
+ graph: n,
1000
1068
  overlayManager: e,
1001
1069
  executeCommand: t,
1002
- schema: o,
1003
- flowModel: n,
1070
+ schema: s,
1071
+ flowModel: o,
1072
+ getNodeBehavior: i,
1004
1073
  idGenerator: r,
1005
- defaultInsertGap: i,
1006
- getContextMenuItems: l,
1007
- onHighlightChange: a,
1008
- resolveNodeShape: g
1074
+ defaultInsertGap: l,
1075
+ getContextMenuItems: a,
1076
+ onHighlightChange: p,
1077
+ resolveNodeShape: c
1009
1078
  }) {
1010
- const d = r ?? He;
1011
- let v = [], f = [], p = null, E = !1, w = null, N = !1;
1012
- async function m() {
1013
- if (E) return p;
1014
- E = !0;
1079
+ const g = r ?? Oe;
1080
+ let u = [], y = [], v = null, C = !1, M = null;
1081
+ async function D() {
1082
+ if (C) return v;
1083
+ C = !0;
1015
1084
  try {
1016
- const h = await import("@antv/x6-plugin-dnd"), b = h.Dnd ?? h.default;
1017
- return b ? (p = new b({
1018
- target: s,
1085
+ const h = await import("@antv/x6-plugin-dnd"), d = h.Dnd ?? h.default;
1086
+ return d ? (v = new d({
1087
+ target: n,
1019
1088
  scaled: !0,
1020
1089
  animation: !0,
1021
- getDragNode: (C) => C.clone(),
1022
- getDropNode: (C) => C.clone()
1023
- }), p) : null;
1090
+ getDragNode: (f) => f.clone(),
1091
+ getDropNode: (f) => f.clone()
1092
+ }), v) : null;
1024
1093
  } catch {
1025
1094
  return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"), null;
1026
1095
  }
1027
1096
  }
1028
- async function D() {
1029
- if (!N) {
1030
- N = !0;
1031
- try {
1032
- const h = await import("@antv/x6-plugin-export"), b = h.Export ?? h.default;
1033
- b && s.use(new b());
1034
- } catch {
1035
- console.warn("[flow-canvas] @antv/x6-plugin-export not available, add it to your dependencies");
1036
- }
1037
- }
1097
+ function L() {
1098
+ return new Promise((h) => {
1099
+ requestAnimationFrame(() => requestAnimationFrame(() => h()));
1100
+ });
1038
1101
  }
1039
- const z = ({ node: h }) => {
1040
- const b = h.getData?.();
1041
- if (!b?._dndSessionId || b._dndSessionId !== w) return;
1042
- w = null;
1043
- const C = h.getPosition();
1044
- s.removeNode(h.id);
1045
- const { _dndSessionId: L, ...R } = b, q = R.id || d("node");
1102
+ const H = ({ node: h }) => {
1103
+ const d = h.getData?.();
1104
+ if (!d?._dndSessionId || d._dndSessionId !== M) return;
1105
+ M = null;
1106
+ const f = h.getPosition();
1107
+ n.removeNode(h.id);
1108
+ const { _dndSessionId: I, ...S } = d, w = S.id || g("node");
1046
1109
  t({
1047
- id: W(),
1110
+ id: Z(),
1048
1111
  source: "user:drag",
1049
1112
  label: "拖入节点",
1050
1113
  timestamp: Date.now(),
1051
1114
  commands: [
1052
1115
  {
1053
1116
  type: "node.add",
1054
- node: { ...R, id: q, position: { x: C.x, y: C.y } }
1117
+ node: { ...S, id: w, position: { x: f.x, y: f.y } }
1055
1118
  }
1056
1119
  ]
1057
1120
  });
1058
1121
  };
1059
- s.on("node:added", z);
1060
- function X(h) {
1061
- const b = o.nodeTypes[h.type];
1062
- return Fe(h, b?.getPorts);
1122
+ n.on("node:added", H);
1123
+ function K(h) {
1124
+ const d = s.nodeTypes[h.type];
1125
+ return Be(h, d?.getPorts);
1126
+ }
1127
+ function $(h) {
1128
+ return h ?? tt(n.getSelectedCells?.() ?? []);
1063
1129
  }
1064
- function j(h, b, C, L, R) {
1130
+ function W(h, d, f, I, S) {
1065
1131
  switch (h) {
1066
1132
  case "left":
1067
1133
  return {
1068
- x: b.position.x - R - L.width,
1069
- y: b.position.y + (C.height - L.height) / 2
1134
+ x: d.position.x - S - I.width,
1135
+ y: d.position.y + (f.height - I.height) / 2
1070
1136
  };
1071
1137
  case "top":
1072
1138
  return {
1073
- x: b.position.x + (C.width - L.width) / 2,
1074
- y: b.position.y - R - L.height
1139
+ x: d.position.x + (f.width - I.width) / 2,
1140
+ y: d.position.y - S - I.height
1075
1141
  };
1076
1142
  case "bottom":
1077
1143
  return {
1078
- x: b.position.x + (C.width - L.width) / 2,
1079
- y: b.position.y + C.height + R
1144
+ x: d.position.x + (f.width - I.width) / 2,
1145
+ y: d.position.y + f.height + S
1080
1146
  };
1081
1147
  default:
1082
1148
  return {
1083
- x: b.position.x + C.width + R,
1084
- y: b.position.y + (C.height - L.height) / 2
1149
+ x: d.position.x + f.width + S,
1150
+ y: d.position.y + (f.height - I.height) / 2
1085
1151
  };
1086
1152
  }
1087
1153
  }
1088
- function oe(h, b, C) {
1154
+ function F(h, d, f) {
1089
1155
  switch (h) {
1090
1156
  case "left":
1091
- return { x: -(b.width + C), y: 0 };
1157
+ return { x: -(d.width + f), y: 0 };
1092
1158
  case "top":
1093
- return { x: 0, y: -(b.height + C) };
1159
+ return { x: 0, y: -(d.height + f) };
1094
1160
  case "bottom":
1095
- return { x: 0, y: b.height + C };
1161
+ return { x: 0, y: d.height + f };
1096
1162
  default:
1097
- return { x: b.width + C, y: 0 };
1163
+ return { x: d.width + f, y: 0 };
1098
1164
  }
1099
1165
  }
1100
- function G(h) {
1166
+ function k(h) {
1101
1167
  switch (h) {
1102
1168
  case "left":
1103
1169
  return "right";
@@ -1109,355 +1175,675 @@ function Bt({
1109
1175
  return "left";
1110
1176
  }
1111
1177
  }
1112
- return {
1178
+ const B = {
1113
1179
  zoomIn() {
1114
- s.zoom(0.1);
1180
+ n.zoom(0.1);
1115
1181
  },
1116
1182
  zoomOut() {
1117
- s.zoom(-0.1);
1183
+ n.zoom(-0.1);
1118
1184
  },
1119
1185
  zoomTo(h) {
1120
- s.zoomTo(h);
1186
+ n.zoomTo(h);
1121
1187
  },
1122
1188
  zoomToFit() {
1123
- s.zoomToFit({ padding: 40, maxScale: 1.5 });
1189
+ n.zoomToFit({ padding: 40, maxScale: 1.5 });
1124
1190
  },
1125
1191
  getZoom() {
1126
- return s.zoom();
1192
+ return n.zoom();
1127
1193
  },
1128
1194
  centerContent() {
1129
- s.centerContent();
1195
+ n.centerContent();
1130
1196
  },
1131
1197
  scrollToOrigin() {
1132
- s.translate(0, 0);
1198
+ n.translate(0, 0);
1133
1199
  },
1134
1200
  scrollToNode(h) {
1135
- const b = s.getCellById(h);
1136
- b && s.centerCell(b);
1201
+ const d = n.getCellById(h);
1202
+ d && n.centerCell(d);
1137
1203
  },
1138
1204
  getSelection() {
1139
- const h = s.getSelectedCells?.() ?? [];
1140
- return {
1141
- nodeIds: h.filter((b) => b.isNode()).map((b) => b.id),
1142
- edgeIds: h.filter((b) => b.isEdge()).map((b) => b.id)
1143
- };
1205
+ return $();
1206
+ },
1207
+ getSelectionBounds(h) {
1208
+ return Bt(n, $(h));
1144
1209
  },
1145
1210
  selectNodes(h) {
1146
- const b = h.map((C) => s.getCellById(C)).filter(Boolean);
1147
- s.select?.(b);
1211
+ const d = h.map((f) => n.getCellById(f)).filter(Boolean);
1212
+ n.select?.(d);
1148
1213
  },
1149
1214
  selectEdges(h) {
1150
- const b = h.map((C) => s.getCellById(C)).filter(Boolean);
1151
- s.select?.(b);
1215
+ const d = h.map((f) => n.getCellById(f)).filter(Boolean);
1216
+ n.select?.(d);
1152
1217
  },
1153
1218
  clearSelection() {
1154
- const h = s.getSelectedCells?.();
1155
- h?.length && s.unselect?.(h);
1219
+ const h = n.getSelectedCells?.();
1220
+ h?.length && n.unselect?.(h);
1221
+ },
1222
+ deleteSelection(h) {
1223
+ const d = $(h?.selection), f = ot(d, o.value, i ?? (() => ({}))), I = Ht(f);
1224
+ if (I.length === 0) return null;
1225
+ const S = t({
1226
+ id: Z(),
1227
+ source: h?.source ?? "user:toolbar",
1228
+ label: h?.label ?? "删除选中",
1229
+ timestamp: Date.now(),
1230
+ commands: I
1231
+ });
1232
+ return S.status === "applied" && h?.clearSelectionAfterApply !== !1 && B.clearSelection(), S;
1156
1233
  },
1157
- registerDndSource(h, b) {
1158
- const C = async (L) => {
1159
- const R = await m();
1160
- if (!R) return;
1161
- const q = W();
1162
- w = q;
1163
- const Y = b(), H = g?.(Y.type), Q = s.createNode({
1164
- width: H?.width ?? 154,
1165
- height: H?.height ?? 54,
1166
- shape: H?.shapeName ?? "rect",
1167
- data: { ...Y, _dndSessionId: q }
1234
+ registerDndSource(h, d) {
1235
+ const f = async (I) => {
1236
+ const S = await D();
1237
+ if (!S) return;
1238
+ const w = Z();
1239
+ M = w;
1240
+ const U = d(), oe = c?.(U.type), E = n.createNode({
1241
+ width: oe?.width ?? 154,
1242
+ height: oe?.height ?? 54,
1243
+ shape: oe?.shapeName ?? "rect",
1244
+ data: { ...U, _dndSessionId: w }
1168
1245
  });
1169
- R.start(Q, L);
1246
+ S.start(E, I);
1170
1247
  };
1171
- return h.addEventListener("mousedown", C), () => {
1172
- h.removeEventListener("mousedown", C);
1248
+ return h.addEventListener("mousedown", f), () => {
1249
+ h.removeEventListener("mousedown", f);
1173
1250
  };
1174
1251
  },
1175
1252
  /**
1176
1253
  * 通过编程方式发起连线:直接命中真实 port 元素,
1177
1254
  * 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
1178
1255
  */
1179
- startConnection(h, b) {
1180
- const C = s.getCellById(h);
1181
- if (!C?.isNode()) return;
1182
- const L = C, R = s.findViewByCell(L);
1183
- if (!R) return;
1184
- const q = R.findPortElem(b, "circle") ?? R.findPortElem(b);
1185
- if (!q) return;
1186
- const H = (q.matches?.("[magnet]") ? q : q.querySelector?.("[magnet]")) ?? q, Q = H.getBoundingClientRect(), de = Q.left + Q.width / 2, re = Q.top + Q.height / 2, ce = new MouseEvent("mousedown", {
1187
- clientX: de,
1188
- clientY: re,
1256
+ startConnection(h, d) {
1257
+ const f = n.getCellById(h);
1258
+ if (!f?.isNode()) return;
1259
+ const I = f, S = n.findViewByCell(I);
1260
+ if (!S) return;
1261
+ const w = S.findPortElem(d, "circle") ?? S.findPortElem(d);
1262
+ if (!w) return;
1263
+ const oe = (w.matches?.("[magnet]") ? w : w.querySelector?.("[magnet]")) ?? w, E = oe.getBoundingClientRect(), T = E.left + E.width / 2, m = E.top + E.height / 2, P = new MouseEvent("mousedown", {
1264
+ clientX: T,
1265
+ clientY: m,
1189
1266
  button: 0,
1190
1267
  buttons: 1,
1191
1268
  bubbles: !0,
1192
1269
  cancelable: !0
1193
1270
  });
1194
- H.dispatchEvent(ce);
1271
+ oe.dispatchEvent(P);
1195
1272
  },
1196
1273
  async exportAsImage(h) {
1197
- await D();
1198
- const b = s;
1199
- return typeof b.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((C) => {
1200
- b.toPNG(
1201
- (L) => {
1202
- fetch(L).then((R) => R.blob()).then(C).catch(() => C(new Blob()));
1203
- },
1204
- {
1205
- backgroundColor: h?.backgroundColor ?? "#ffffff",
1206
- padding: h?.padding ?? 20,
1207
- quality: h?.quality,
1208
- copyStyles: !0
1274
+ const { domToBlob: d } = await import("modern-screenshot"), f = h?.padding ?? 20, I = h?.backgroundColor ?? n.options.background?.color ?? "#ffffff", S = n.zoom(), w = n.translate(), U = n.getContentBBox(), oe = U.width / S, E = U.height / S;
1275
+ if (oe === 0 || E === 0)
1276
+ return new Blob();
1277
+ const T = (U.x - w.tx) / S, m = (U.y - w.ty) / S, P = Math.ceil(oe + f * 2), z = Math.ceil(E + f * 2), Y = document.createElement("div");
1278
+ Y.style.cssText = "position:fixed;left:-99999px;top:0;pointer-events:none;";
1279
+ const X = n.container.cloneNode(!0);
1280
+ X.style.width = `${P}px`, X.style.height = `${z}px`, X.style.overflow = "visible";
1281
+ const ne = X.querySelector("svg");
1282
+ ne && (ne.setAttribute("width", String(P)), ne.setAttribute("height", String(z)), ne.style.width = `${P}px`, ne.style.height = `${z}px`), X.querySelector(".x6-graph-svg-viewport")?.setAttribute("transform", `matrix(1,0,0,1,${-T + f},${-m + f})`), Y.appendChild(X), document.body.appendChild(Y);
1283
+ try {
1284
+ return await L(), await d(X, {
1285
+ width: P,
1286
+ height: z,
1287
+ backgroundColor: I,
1288
+ scale: h?.scale ?? window.devicePixelRatio,
1289
+ filter: (de) => {
1290
+ if (de instanceof Element) {
1291
+ const se = de.getAttribute("class") ?? "";
1292
+ if (se.includes("x6-widget-selection") || se.includes("x6-widget-transform") || se.includes("x6-graph-grid") || se.includes("x6-graph-background"))
1293
+ return !1;
1294
+ }
1295
+ return !0;
1209
1296
  }
1210
- );
1211
- });
1212
- },
1213
- async exportAsSVG() {
1214
- await D();
1215
- const h = s;
1216
- return typeof h.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((b) => {
1217
- h.toSVG((C) => b(C));
1218
- });
1297
+ });
1298
+ } catch (de) {
1299
+ return console.warn("[flow-canvas] Export failed:", de), new Blob();
1300
+ } finally {
1301
+ Y.remove();
1302
+ }
1219
1303
  },
1220
1304
  highlightNodes(h) {
1221
- v = h, a?.(v, f);
1305
+ u = h, p?.(u, y);
1222
1306
  },
1223
1307
  highlightEdges(h) {
1224
- f = h, a?.(v, f);
1308
+ y = h, p?.(u, y);
1225
1309
  },
1226
1310
  clearHighlight() {
1227
- v = [], f = [], a?.([], []);
1311
+ u = [], y = [], p?.([], []);
1228
1312
  },
1229
1313
  overlay: e,
1230
1314
  getContextMenuItems(h) {
1231
- return l?.(h) ?? [];
1315
+ return a?.(h) ?? [];
1232
1316
  },
1233
- insertNodeToRight(h, b, C) {
1234
- const L = n.value, R = L.nodes[h];
1235
- if (!R)
1317
+ insertNodeToRight(h, d, f) {
1318
+ const I = o.value, S = I.nodes[h];
1319
+ if (!S)
1236
1320
  return {
1237
1321
  status: "invalid",
1238
1322
  envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
1239
1323
  error: { code: "constraint_violated", reason: `Source node "${h}" not found`, source: "api" }
1240
1324
  };
1241
- const q = C?.gap ?? i ?? Lt, Y = C?.direction ?? "right", H = o.nodeTypes[R.type], Q = o.nodeTypes[b.type], de = H?.getSize(R) ?? { width: 154, height: 54 }, re = Q?.getSize({ ...b, position: { x: 0, y: 0 } }) ?? {
1325
+ const w = f?.gap ?? l ?? Gt, U = f?.direction ?? "right", oe = s.nodeTypes[S.type], E = s.nodeTypes[d.type], T = oe?.getSize(S) ?? { width: 154, height: 54 }, m = E?.getSize({ ...d, position: { x: 0, y: 0 } }) ?? {
1242
1326
  width: 154,
1243
1327
  height: 54
1244
- }, ce = j(Y, R, de, re, q), ue = b.id || d("node"), Ie = { ...b, id: ue, position: ce }, se = [{ type: "node.add", node: Ie }], Me = oe(Y, re, q), ie = { x: ce.x, y: ce.y, width: re.width, height: re.height };
1245
- for (const [ae, Z] of Object.entries(L.nodes)) {
1246
- if (ae === h || ae === ue) continue;
1247
- const ve = o.nodeTypes[Z.type]?.getSize(Z) ?? { width: 154, height: 54 }, te = ie.x < Z.position.x + ve.width && ie.x + ie.width > Z.position.x, ye = ie.y < Z.position.y + ve.height && ie.y + ie.height > Z.position.y;
1248
- te && ye && se.push({
1328
+ }, P = W(U, S, T, m, w), z = d.id || g("node"), Y = { ...d, id: z, position: P }, X = [{ type: "node.add", node: Y }], ne = F(U, m, w), Q = { x: P.x, y: P.y, width: m.width, height: m.height };
1329
+ for (const [se, x] of Object.entries(I.nodes)) {
1330
+ if (se === h || se === z) continue;
1331
+ const _ = s.nodeTypes[x.type]?.getSize(x) ?? { width: 154, height: 54 }, q = Q.x < x.position.x + _.width && Q.x + Q.width > x.position.x, J = Q.y < x.position.y + _.height && Q.y + Q.height > x.position.y;
1332
+ q && J && X.push({
1249
1333
  type: "node.move",
1250
- nodeId: ae,
1251
- position: { x: Z.position.x + Me.x, y: Z.position.y + Me.y }
1334
+ nodeId: se,
1335
+ position: { x: x.position.x + ne.x, y: x.position.y + ne.y }
1252
1336
  });
1253
1337
  }
1254
- if (C?.autoWireEdges) {
1255
- const ae = X(R), Z = X(Ie), we = Y, ve = G(Y), te = ae.find((K) => K.group === we), ye = Z.find((K) => K.group === ve), Ne = Z.find((K) => K.group === we), xe = te ? Object.values(L.edges).find(
1256
- (K) => K.source.nodeId === h && K.source.portId === te.id
1257
- ) : Object.values(L.edges).find((K) => K.source.nodeId === h);
1258
- if (xe) {
1259
- const K = xe.target;
1260
- se.push({ type: "edge.remove", edgeId: xe.id }), se.push({
1338
+ if (f?.autoWireEdges) {
1339
+ const se = K(S), x = K(Y), b = U, _ = k(U), q = se.find((ee) => ee.group === b), J = x.find((ee) => ee.group === _), ue = x.find((ee) => ee.group === b), ie = q ? Object.values(I.edges).find(
1340
+ (ee) => ee.source.nodeId === h && ee.source.portId === q.id
1341
+ ) : Object.values(I.edges).find((ee) => ee.source.nodeId === h);
1342
+ if (ie) {
1343
+ const ee = ie.target;
1344
+ X.push({ type: "edge.remove", edgeId: ie.id }), X.push({
1261
1345
  type: "edge.add",
1262
1346
  edge: {
1263
- id: d("edge"),
1264
- source: { nodeId: h, portId: te?.id },
1265
- target: { nodeId: ue, portId: ye?.id }
1347
+ id: g("edge"),
1348
+ source: { nodeId: h, portId: q?.id },
1349
+ target: { nodeId: z, portId: J?.id }
1266
1350
  }
1267
- }), se.push({
1351
+ }), X.push({
1268
1352
  type: "edge.add",
1269
1353
  edge: {
1270
- id: d("edge"),
1271
- source: { nodeId: ue, portId: Ne?.id },
1272
- target: K
1354
+ id: g("edge"),
1355
+ source: { nodeId: z, portId: ue?.id },
1356
+ target: ee
1273
1357
  }
1274
1358
  });
1275
1359
  } else
1276
- se.push({
1360
+ X.push({
1277
1361
  type: "edge.add",
1278
1362
  edge: {
1279
- id: d("edge"),
1280
- source: { nodeId: h, portId: te?.id },
1281
- target: { nodeId: ue, portId: ye?.id }
1363
+ id: g("edge"),
1364
+ source: { nodeId: h, portId: q?.id },
1365
+ target: { nodeId: z, portId: J?.id }
1282
1366
  }
1283
1367
  });
1284
1368
  }
1285
- const $e = {
1286
- id: W(),
1287
- source: C?.source ?? "user:toolbar",
1288
- label: C?.label ?? "插入节点",
1369
+ const de = {
1370
+ id: Z(),
1371
+ source: f?.source ?? "user:toolbar",
1372
+ label: f?.label ?? "插入节点",
1289
1373
  timestamp: Date.now(),
1290
- commands: se
1374
+ commands: X
1291
1375
  };
1292
- return t($e);
1376
+ return t(de);
1293
1377
  },
1294
- onGraphEvent(h, b) {
1295
- return s.on(h, b), () => s.off(h, b);
1378
+ onGraphEvent(h, d) {
1379
+ return n.on(h, d), () => n.off(h, d);
1296
1380
  },
1297
1381
  unsafeGetGraph() {
1298
- return s;
1382
+ return n;
1299
1383
  }
1300
1384
  };
1385
+ return B;
1301
1386
  }
1302
- function Ot() {
1303
- const s = O(null), e = O(!1);
1304
- let t = null, o = !1;
1305
- function n(v) {
1306
- t && (clearTimeout(t), t = null), s.value = v;
1387
+ function Ut() {
1388
+ const n = O(null), e = O(!1);
1389
+ let t = null, s = !1;
1390
+ function o(g) {
1391
+ t && (clearTimeout(t), t = null), n.value = g;
1307
1392
  }
1308
- function r(v = 100) {
1309
- o || (t && clearTimeout(t), t = setTimeout(() => {
1310
- s.value = null, t = null;
1311
- }, v));
1393
+ function i(g = 100) {
1394
+ s || (t && clearTimeout(t), t = setTimeout(() => {
1395
+ n.value = null, t = null;
1396
+ }, g));
1312
1397
  }
1313
- function i() {
1314
- o = !0, t && (clearTimeout(t), t = null);
1398
+ function r() {
1399
+ s = !0, t && (clearTimeout(t), t = null);
1315
1400
  }
1316
- function l(v = 100) {
1317
- o = !1, r(v);
1401
+ function l(g = 100) {
1402
+ s = !1, i(g);
1318
1403
  }
1319
1404
  function a() {
1320
1405
  t && (clearTimeout(t), t = null);
1321
1406
  }
1322
- function g() {
1323
- a(), o = !1, s.value = null;
1407
+ function p() {
1408
+ a(), s = !1, n.value = null;
1324
1409
  }
1325
- function d() {
1410
+ function c() {
1326
1411
  t && clearTimeout(t);
1327
1412
  }
1328
- return { hoveredNodeId: s, isDraggingNode: e, enter: n, leave: r, enterOverlay: i, leaveOverlay: l, cancelLeave: a, reset: g, cleanup: d };
1413
+ return { hoveredNodeId: n, isDraggingNode: e, enter: o, leave: i, enterOverlay: r, leaveOverlay: l, cancelLeave: a, reset: p, cleanup: c };
1329
1414
  }
1330
- const We = 10, Se = 12;
1331
- function Qe(s, e) {
1332
- const t = s.getTotalLength();
1415
+ const qe = 10, Ie = 12;
1416
+ function Ue(n, e) {
1417
+ const t = n.getTotalLength();
1333
1418
  if (t === 0) return { ...e, length: 0, totalLength: 0 };
1334
- let o = s.getPointAtLength(0), n = 1 / 0;
1335
- const r = 50, i = t / r;
1419
+ let s = n.getPointAtLength(0), o = 1 / 0;
1420
+ const i = 50, r = t / i;
1336
1421
  let l = 0;
1337
- for (let v = 0; v <= r; v++) {
1338
- const f = v * i, p = s.getPointAtLength(f), E = (p.x - e.x) ** 2 + (p.y - e.y) ** 2;
1339
- E < n && (n = E, o = p, l = f);
1422
+ for (let g = 0; g <= i; g++) {
1423
+ const u = g * r, y = n.getPointAtLength(u), v = (y.x - e.x) ** 2 + (y.y - e.y) ** 2;
1424
+ v < o && (o = v, s = y, l = u);
1340
1425
  }
1341
- const a = Math.max(0, l - i), g = Math.min(t, l + i), d = (g - a) / 20;
1342
- for (let v = a; v <= g; v += d) {
1343
- const f = s.getPointAtLength(v), p = (f.x - e.x) ** 2 + (f.y - e.y) ** 2;
1344
- p < n && (n = p, o = f, l = v);
1426
+ const a = Math.max(0, l - r), p = Math.min(t, l + r), c = (p - a) / 20;
1427
+ for (let g = a; g <= p; g += c) {
1428
+ const u = n.getPointAtLength(g), y = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
1429
+ y < o && (o = y, s = u, l = g);
1345
1430
  }
1346
- return { x: o.x, y: o.y, length: l, totalLength: t };
1431
+ return { x: s.x, y: s.y, length: l, totalLength: t };
1347
1432
  }
1348
- function Xe(s, e) {
1349
- return s < We || s > e - We;
1433
+ function ze(n, e) {
1434
+ return n < qe || n > e - qe;
1350
1435
  }
1351
- function Ye(s, e, t) {
1352
- const o = s.querySelectorAll(".x6-edge-label");
1353
- for (const n of o) {
1354
- const r = n.getBoundingClientRect();
1355
- if (e >= r.left - Se && e <= r.right + Se && t >= r.top - Se && t <= r.bottom + Se)
1436
+ function Fe(n, e, t) {
1437
+ const s = n.querySelectorAll(".x6-edge-label");
1438
+ for (const o of s) {
1439
+ const i = o.getBoundingClientRect();
1440
+ if (e >= i.left - Ie && e <= i.right + Ie && t >= i.top - Ie && t <= i.bottom + Ie)
1356
1441
  return !0;
1357
1442
  }
1358
1443
  return !1;
1359
1444
  }
1360
- function Ke() {
1361
- const s = "http://www.w3.org/2000/svg", e = document.createElementNS(s, "g");
1445
+ function je() {
1446
+ const n = "http://www.w3.org/2000/svg", e = document.createElementNS(n, "g");
1362
1447
  e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
1363
- const t = document.createElementNS(s, "rect");
1448
+ const t = document.createElementNS(n, "rect");
1364
1449
  t.setAttribute("width", "20"), t.setAttribute("height", "20"), t.setAttribute("x", "-10"), t.setAttribute("y", "-10"), t.setAttribute("rx", "4"), t.setAttribute("ry", "4"), t.setAttribute("fill", "#3a84ff"), e.appendChild(t);
1365
- const o = document.createElementNS(s, "text");
1366
- return o.setAttribute("font-family", "flow-canvas"), o.setAttribute("font-size", "16"), o.setAttribute("fill", "#ffffff"), o.setAttribute("text-anchor", "middle"), o.setAttribute("dominant-baseline", "central"), o.textContent = "", e.appendChild(o), e;
1450
+ const s = document.createElementNS(n, "text");
1451
+ return s.setAttribute("font-family", "flow-canvas"), s.setAttribute("font-size", "16"), s.setAttribute("fill", "#ffffff"), s.setAttribute("text-anchor", "middle"), s.setAttribute("dominant-baseline", "central"), s.textContent = "", e.appendChild(s), e;
1367
1452
  }
1368
- function Gt(s) {
1453
+ function zt(n) {
1369
1454
  let e = null, t = null;
1370
- function o(l, a) {
1371
- if (r(), t = l, a.target?.closest?.(".x6-edge-label")) return;
1372
- const d = s.getCellById(l);
1373
- if (!d?.isEdge()) return;
1374
- const v = s.findViewByCell(d);
1375
- if (!v) return;
1376
- const f = v.container.querySelector("path");
1377
- if (!f) return;
1378
- const p = s.clientToLocal(a.clientX, a.clientY), E = Qe(f, p);
1379
- if (Xe(E.length, E.totalLength) || Ye(v.container, a.clientX, a.clientY)) return;
1380
- const w = Ke();
1381
- w.setAttribute("transform", `translate(${E.x}, ${E.y})`), v.container.appendChild(w), e = w;
1382
- }
1383
- function n(l) {
1455
+ function s(l, a) {
1456
+ if (i(), t = l, a.target?.closest?.(".x6-edge-label")) return;
1457
+ const c = n.getCellById(l);
1458
+ if (!c?.isEdge()) return;
1459
+ const g = n.findViewByCell(c);
1460
+ if (!g) return;
1461
+ const u = g.container.querySelector("path");
1462
+ if (!u) return;
1463
+ const y = n.clientToLocal(a.clientX, a.clientY), v = Ue(u, y);
1464
+ if (ze(v.length, v.totalLength) || Fe(g.container, a.clientX, a.clientY)) return;
1465
+ const C = je();
1466
+ C.setAttribute("transform", `translate(${v.x}, ${v.y})`), g.container.appendChild(C), e = C;
1467
+ }
1468
+ function o(l) {
1384
1469
  if (!t) return;
1385
1470
  if (l.target?.closest?.(".x6-edge-label")) {
1386
1471
  e && e.setAttribute("display", "none");
1387
1472
  return;
1388
1473
  }
1389
- const g = s.getCellById(t);
1390
- if (!g?.isEdge()) return;
1391
- const d = s.findViewByCell(g);
1392
- if (!d) return;
1393
- const v = d.container.querySelector("path");
1394
- if (!v) return;
1395
- const f = s.clientToLocal(l.clientX, l.clientY), p = Qe(v, f);
1396
- if (Xe(p.length, p.totalLength) || Ye(d.container, l.clientX, l.clientY))
1474
+ const p = n.getCellById(t);
1475
+ if (!p?.isEdge()) return;
1476
+ const c = n.findViewByCell(p);
1477
+ if (!c) return;
1478
+ const g = c.container.querySelector("path");
1479
+ if (!g) return;
1480
+ const u = n.clientToLocal(l.clientX, l.clientY), y = Ue(g, u);
1481
+ if (ze(y.length, y.totalLength) || Fe(c.container, l.clientX, l.clientY))
1397
1482
  e && e.setAttribute("display", "none");
1398
1483
  else if (e)
1399
- e.removeAttribute("display"), e.setAttribute("transform", `translate(${p.x}, ${p.y})`);
1484
+ e.removeAttribute("display"), e.setAttribute("transform", `translate(${y.x}, ${y.y})`);
1400
1485
  else {
1401
- const E = Ke();
1402
- E.setAttribute("transform", `translate(${p.x}, ${p.y})`), d.container.appendChild(E), e = E;
1486
+ const v = je();
1487
+ v.setAttribute("transform", `translate(${y.x}, ${y.y})`), c.container.appendChild(v), e = v;
1403
1488
  }
1404
1489
  }
1405
- function r() {
1490
+ function i() {
1406
1491
  e && (e.remove(), e = null), t = null;
1407
1492
  }
1408
- function i(l) {
1493
+ function r(l) {
1409
1494
  l === t && (e = null, t = null);
1410
1495
  }
1411
- return { show: o, move: n, remove: r, handleEdgeRemoved: i };
1496
+ return { show: s, move: o, remove: i, handleEdgeRemoved: r };
1412
1497
  }
1413
- function zt(s) {
1498
+ function Ft(n) {
1414
1499
  let e = null, t = 0;
1415
- function o(d) {
1416
- const v = d ? "visible" : "hidden";
1417
- for (const f of s.getNodes())
1418
- for (const p of f.getPorts())
1419
- f.setPortProp(p.id, "attrs/circle/visibility", v);
1500
+ function s(c) {
1501
+ const g = c ? "visible" : "hidden";
1502
+ for (const u of n.getNodes())
1503
+ for (const y of u.getPorts())
1504
+ u.setPortProp(y.id, "attrs/circle/visibility", g);
1420
1505
  }
1421
- function n(d) {
1506
+ function o(c) {
1422
1507
  if (!e)
1423
- for (const v of d.getPorts())
1424
- d.setPortProp(v.id, "attrs/circle/visibility", "visible");
1508
+ for (const g of c.getPorts())
1509
+ c.setPortProp(g.id, "attrs/circle/visibility", "visible");
1425
1510
  }
1426
- function r(d) {
1511
+ function i(c) {
1427
1512
  if (!e)
1428
- for (const v of d.getPorts())
1429
- d.setPortProp(v.id, "attrs/circle/visibility", "hidden");
1430
- }
1431
- function i(d, v) {
1432
- if (!d.getTargetCell())
1433
- if (e = d.id, v?.size)
1434
- for (const f of s.getNodes()) {
1435
- const p = v.has(f.id) ? "hidden" : "visible";
1436
- for (const E of f.getPorts())
1437
- f.setPortProp(E.id, "attrs/circle/visibility", p);
1513
+ for (const g of c.getPorts())
1514
+ c.setPortProp(g.id, "attrs/circle/visibility", "hidden");
1515
+ }
1516
+ function r(c, g) {
1517
+ if (!c.getTargetCell())
1518
+ if (e = c.id, g?.size)
1519
+ for (const u of n.getNodes()) {
1520
+ const y = g.has(u.id) ? "hidden" : "visible";
1521
+ for (const v of u.getPorts())
1522
+ u.setPortProp(v.id, "attrs/circle/visibility", y);
1438
1523
  }
1439
1524
  else
1440
- o(!0);
1525
+ s(!0);
1441
1526
  }
1442
1527
  function l() {
1443
- e = null, o(!1), t = Date.now() + 300;
1528
+ e = null, s(!1), t = Date.now() + 300;
1444
1529
  }
1445
- function a(d) {
1446
- d === e && (e = null, o(!1));
1530
+ function a(c) {
1531
+ c === e && (e = null, s(!1));
1447
1532
  }
1448
- function g() {
1533
+ function p() {
1449
1534
  return !e && Date.now() >= t;
1450
1535
  }
1451
1536
  return {
1452
- showNodePorts: n,
1453
- hideNodePorts: r,
1454
- handleEdgeAdded: i,
1537
+ showNodePorts: o,
1538
+ hideNodePorts: i,
1539
+ handleEdgeAdded: r,
1455
1540
  handleEdgeConnected: l,
1456
1541
  handleEdgeRemoved: a,
1457
- canShowEdgeTool: g
1542
+ canShowEdgeTool: p
1543
+ };
1544
+ }
1545
+ function We(n) {
1546
+ return n === "top" || n === "right" || n === "bottom" || n === "left";
1547
+ }
1548
+ function jt(n) {
1549
+ const { editor: e, nodeHover: t, isSelectionModeActive: s, viewportVersion: o, getNodeBehavior: i, getInsertGap: r } = n, { isDraggingNode: l } = n, a = O(null), p = O(!1);
1550
+ let c = null, g = null, u = null;
1551
+ const y = j(() => ({
1552
+ enabled: !0,
1553
+ portGroup: "right",
1554
+ ...n.quickAddProp.value
1555
+ }));
1556
+ function v() {
1557
+ c && (clearTimeout(c), c = null);
1558
+ }
1559
+ function C() {
1560
+ c && clearTimeout(c), c = setTimeout(() => {
1561
+ a.value = null, c = null;
1562
+ }, 150);
1563
+ }
1564
+ function M(E) {
1565
+ return p.value ? !0 : (v(), B(E) ? (a.value = E, !0) : (a.value = null, !1));
1566
+ }
1567
+ function D() {
1568
+ v(), t.enterOverlay();
1569
+ }
1570
+ function L() {
1571
+ C(), t.leaveOverlay();
1572
+ }
1573
+ function H(E) {
1574
+ const T = e.schema.nodeTypes[E.type];
1575
+ return Be(E, T?.getPorts);
1576
+ }
1577
+ function K(E, T) {
1578
+ const m = y.value.getPort?.(E, T);
1579
+ if (!m) return null;
1580
+ const P = typeof m == "string" ? m : m.id;
1581
+ return T.find((z) => z.id === P) ?? null;
1582
+ }
1583
+ function $(E, T) {
1584
+ const m = e.api.value?.overlay.getNodeScreenRect(E);
1585
+ if (!m) return null;
1586
+ switch (T) {
1587
+ case "top":
1588
+ return { x: m.x + m.width / 2, y: m.y };
1589
+ case "bottom":
1590
+ return { x: m.x + m.width / 2, y: m.y + m.height };
1591
+ case "left":
1592
+ return { x: m.x, y: m.y + m.height / 2 };
1593
+ case "right":
1594
+ return { x: m.x + m.width, y: m.y + m.height / 2 };
1595
+ default:
1596
+ return null;
1597
+ }
1598
+ }
1599
+ function W(E, T, m) {
1600
+ if (!g) return $(E, m);
1601
+ const P = g.getCellById(E);
1602
+ if (P?.isNode()) {
1603
+ const z = P, Y = g.findViewByCell(z), X = Y?.findPortElem(T, "circle") ?? Y?.findPortElem(T);
1604
+ if (X) {
1605
+ const ne = g.container.getBoundingClientRect(), Q = X.getBoundingClientRect();
1606
+ return {
1607
+ x: Q.left - ne.left + Q.width / 2,
1608
+ y: Q.top - ne.top + Q.height / 2
1609
+ };
1610
+ }
1611
+ }
1612
+ return $(E, m);
1613
+ }
1614
+ function F(E) {
1615
+ const T = H(E), m = K(E, T) ?? T.find((z) => z.group === y.value.portGroup) ?? null;
1616
+ if (!m) return null;
1617
+ const P = W(E.id, m.id, m.group);
1618
+ return P ? { portId: m.id, portGroup: m.group, portPosition: P } : null;
1619
+ }
1620
+ function k(E) {
1621
+ const T = F(E), m = y.value.insertDirection;
1622
+ if (typeof m == "function") {
1623
+ const P = m(E, T ? { id: T.portId, group: T.portGroup } : null);
1624
+ if (P) return P;
1625
+ } else if (m)
1626
+ return m;
1627
+ return T && We(T.portGroup) ? T.portGroup : We(y.value.portGroup) ? y.value.portGroup : "right";
1628
+ }
1629
+ function B(E) {
1630
+ if (!y.value.enabled || e.mode.value !== "edit") return !1;
1631
+ const m = e.flowModel.value.nodes[E];
1632
+ return !m || i(m).quickAddEnabled === !1 ? !1 : !!F(m);
1633
+ }
1634
+ const h = j(() => {
1635
+ if (o.value, !y.value.enabled) return null;
1636
+ const E = a.value;
1637
+ if (!E || l.value || !e.api.value || e.mode.value !== "edit" || s.value)
1638
+ return null;
1639
+ const m = e.flowModel.value.nodes[E];
1640
+ if (!m) return null;
1641
+ const P = i(m);
1642
+ if (P.quickAddEnabled === !1) return null;
1643
+ const z = F(m);
1644
+ return z ? { node: m, ...z, behavior: P } : null;
1645
+ });
1646
+ function d(E) {
1647
+ p.value = !0, h.value && e._emitUiEvent({ type: "node.quick-add", nodeId: E, position: h.value.portPosition });
1648
+ }
1649
+ function f() {
1650
+ p.value = !1;
1651
+ }
1652
+ function I(E) {
1653
+ const T = e.api.value;
1654
+ if (!T) return;
1655
+ const m = e.flowModel.value.nodes[E];
1656
+ if (!m) return;
1657
+ const P = F(m);
1658
+ P && T.startConnection(E, P.portId);
1659
+ }
1660
+ function S(E, T) {
1661
+ const m = e.api.value;
1662
+ if (!m) return;
1663
+ const P = T.id || e.idGenerator("node"), z = { ...T, id: P }, Y = e.flowModel.value.nodes[E];
1664
+ if (!Y) return;
1665
+ m.insertNodeToRight(E, z, {
1666
+ autoWireEdges: !0,
1667
+ direction: k(Y),
1668
+ gap: r(),
1669
+ source: "user:quick-add",
1670
+ label: "快捷插入节点"
1671
+ }).status === "applied" && e._emitUiEvent({ type: "node.action.quick-insert", sourceNodeId: E, newNodeId: P }), n.closePopover();
1672
+ }
1673
+ function w(E) {
1674
+ if (!g) return;
1675
+ const T = g.getCellById(E);
1676
+ if (!T?.isNode()) return;
1677
+ const m = T, P = e.flowModel.value.nodes[E];
1678
+ if (!P) return;
1679
+ const z = F(P);
1680
+ let Y = !0;
1681
+ i(P).hidePortForQuickAdd === !1 && (Y = !1);
1682
+ const ne = Y && !l.value && !!z && B(E);
1683
+ for (const Q of m.getPorts()) {
1684
+ const de = ne && Q.id === z?.portId ? "hidden" : "visible";
1685
+ m.setPortProp(Q.id, "attrs/circle/visibility", de);
1686
+ }
1687
+ }
1688
+ function U(E, T) {
1689
+ u?.(), g = E, u = fe(
1690
+ [a, l],
1691
+ ([m], [P]) => {
1692
+ if (P && P !== m) {
1693
+ const z = E.getCellById(P);
1694
+ z?.isNode() && T(z);
1695
+ }
1696
+ m && w(m);
1697
+ },
1698
+ { flush: "sync" }
1699
+ );
1700
+ }
1701
+ fe(h, (E) => {
1702
+ E || (p.value = !1);
1703
+ });
1704
+ function oe() {
1705
+ c && clearTimeout(c), u?.(), u = null, g = null;
1706
+ }
1707
+ return {
1708
+ quickAddNodeId: a,
1709
+ quickAddPopoverOpen: p,
1710
+ mergedConfig: y,
1711
+ data: h,
1712
+ enter: M,
1713
+ leave: C,
1714
+ cancelLeave: v,
1715
+ handleOverlayEnter: D,
1716
+ handleOverlayLeave: L,
1717
+ handleOpen: d,
1718
+ handleClose: f,
1719
+ handleStartDrag: I,
1720
+ handleInsert: S,
1721
+ isActiveForNode: B,
1722
+ syncNodePorts: w,
1723
+ attachRuntime: U,
1724
+ cleanup: oe
1458
1725
  };
1459
1726
  }
1460
- const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
1727
+ function Wt(n) {
1728
+ function e(o) {
1729
+ return {
1730
+ id: n.idGenerator("node"),
1731
+ type: o.type,
1732
+ label: o.label,
1733
+ ports: o.ports ? JSON.parse(JSON.stringify(o.ports)) : void 0,
1734
+ payload: o.payload ? JSON.parse(JSON.stringify(o.payload)) : void 0,
1735
+ extensions: o.extensions ? JSON.parse(JSON.stringify(o.extensions)) : void 0
1736
+ };
1737
+ }
1738
+ function t(o, i, r) {
1739
+ const l = n.api.value;
1740
+ switch (o) {
1741
+ case "delete":
1742
+ return n.executeCommand({
1743
+ id: Z(),
1744
+ source: "user:toolbar",
1745
+ label: "删除节点",
1746
+ timestamp: Date.now(),
1747
+ commands: [{ type: "node.remove", nodeId: i }]
1748
+ }), n._emitUiEvent({ type: "node.action.delete", nodeId: i }), !0;
1749
+ case "copy": {
1750
+ if (!l) break;
1751
+ const a = n.flowModel.value.nodes[i];
1752
+ if (!a) break;
1753
+ const p = e(a);
1754
+ l.insertNodeToRight(i, p, {
1755
+ autoWireEdges: !1,
1756
+ gap: r,
1757
+ label: "复制节点"
1758
+ }), n._emitUiEvent({ type: "node.action.copy", sourceNodeId: i, newNodeId: p.id });
1759
+ break;
1760
+ }
1761
+ case "copy-insert": {
1762
+ if (!l) break;
1763
+ const a = n.flowModel.value.nodes[i];
1764
+ if (!a) break;
1765
+ const p = e(a);
1766
+ l.insertNodeToRight(i, p, {
1767
+ autoWireEdges: !0,
1768
+ gap: r,
1769
+ label: "复制并插入节点"
1770
+ }), n._emitUiEvent({ type: "node.action.copy-insert", sourceNodeId: i, newNodeId: p.id });
1771
+ break;
1772
+ }
1773
+ case "disconnect": {
1774
+ const a = n.flowModel.value, p = Object.entries(a.edges).filter(([, c]) => {
1775
+ const g = c;
1776
+ return g.source.nodeId === i || g.target.nodeId === i;
1777
+ }).map(([c]) => c);
1778
+ if (p.length === 0) break;
1779
+ n.executeCommand({
1780
+ id: Z(),
1781
+ source: "user:toolbar",
1782
+ label: "断开连线",
1783
+ timestamp: Date.now(),
1784
+ commands: p.map((c) => ({ type: "edge.remove", edgeId: c }))
1785
+ }), n._emitUiEvent({ type: "node.action.disconnect", nodeId: i, edgeIds: p });
1786
+ break;
1787
+ }
1788
+ case "debug": {
1789
+ n._emitUiEvent({ type: "node.action.debug", nodeId: i });
1790
+ break;
1791
+ }
1792
+ }
1793
+ return !1;
1794
+ }
1795
+ function s(o) {
1796
+ n.api.value?.deleteSelection({
1797
+ selection: o,
1798
+ source: "user:toolbar",
1799
+ label: "批量删除选中"
1800
+ });
1801
+ }
1802
+ return { handleNodeAction: t, deleteSelection: s };
1803
+ }
1804
+ function Vt() {
1805
+ return {
1806
+ refX: 0,
1807
+ children: [
1808
+ {
1809
+ tagName: "path",
1810
+ d: "M -16 -5 L -8 0 L -16 5 Z",
1811
+ transform: "rotate(0)"
1812
+ },
1813
+ {
1814
+ tagName: "circle",
1815
+ cx: 0,
1816
+ cy: 0,
1817
+ r: 8,
1818
+ fill: "#3a84ff",
1819
+ stroke: "#3a84ff",
1820
+ transform: "rotate(0)"
1821
+ }
1822
+ ]
1823
+ };
1824
+ }
1825
+ function Xt(n, e) {
1826
+ const t = e.defaultEdgeType ?? "default", s = e.edgeTypes?.[t], o = {
1827
+ zIndex: -1,
1828
+ attrs: {
1829
+ line: {
1830
+ stroke: "#abb5cc",
1831
+ strokeWidth: 2,
1832
+ targetMarker: { name: "block", width: 8, height: 8 }
1833
+ }
1834
+ }
1835
+ };
1836
+ s?.router && (o.router = typeof s.router == "string" ? { name: s.router } : s.router), s?.connector && (o.connector = typeof s.connector == "string" ? { name: s.connector } : s.connector), s?.x6EdgeConfig && Object.assign(o, s.x6EdgeConfig);
1837
+ const i = o.attrs ?? {}, r = i.line ?? {};
1838
+ return o.attrs = {
1839
+ ...i,
1840
+ line: {
1841
+ ...r,
1842
+ targetMarker: Vt()
1843
+ }
1844
+ }, n.createEdge(o);
1845
+ }
1846
+ const Kt = { class: "flow-canvas-node-actions__bar" }, Yt = /* @__PURE__ */ le({
1461
1847
  __name: "node-actions-toolbar",
1462
1848
  props: {
1463
1849
  node: {},
@@ -1467,15 +1853,15 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
1467
1853
  actionsOffset: {}
1468
1854
  },
1469
1855
  emits: ["action"],
1470
- setup(s, { emit: e }) {
1471
- const t = s, o = F(() => {
1472
- const v = t.actionsOffset?.x ?? 0, f = t.actionsOffset?.y ?? 0, p = v !== 0 || f !== 0;
1856
+ setup(n, { emit: e }) {
1857
+ const t = n, s = j(() => {
1858
+ const g = t.actionsOffset?.x ?? 0, u = t.actionsOffset?.y ?? 0, y = g !== 0 || u !== 0;
1473
1859
  return {
1474
1860
  left: `${t.position.x}px`,
1475
1861
  top: `${t.position.y}px`,
1476
- transform: p ? `translate(${v}px, ${f}px)` : "translateX(-100%)"
1862
+ transform: y ? `translate(${g}px, ${u}px)` : "translateX(-100%)"
1477
1863
  };
1478
- }), n = e, r = F(() => ({
1864
+ }), o = e, i = j(() => ({
1479
1865
  debug: {
1480
1866
  visible: t.config.showDebug && t.behavior.debuggable !== !1,
1481
1867
  disabled: t.behavior.debugDisabled === !0
@@ -1496,189 +1882,213 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
1496
1882
  visible: t.config.showDisconnect && t.behavior.disconnectable !== !1,
1497
1883
  disabled: t.behavior.disconnectDisabled === !0
1498
1884
  }
1499
- })), i = F(() => r.value.copy.visible || r.value.copyInsert.visible || r.value.disconnect.visible), l = O(!1);
1885
+ })), r = j(() => i.value.copy.visible || i.value.copyInsert.visible || i.value.disconnect.visible), l = O(!1);
1500
1886
  let a = null;
1501
- function g() {
1887
+ function p() {
1502
1888
  a && (clearTimeout(a), a = null), l.value = !0;
1503
1889
  }
1504
- function d() {
1890
+ function c() {
1505
1891
  a = setTimeout(() => {
1506
1892
  l.value = !1, a = null;
1507
1893
  }, 100);
1508
1894
  }
1509
- return ze(() => {
1895
+ return Se(() => {
1510
1896
  a && clearTimeout(a);
1511
- }), (v, f) => (M(), S("div", {
1897
+ }), (g, u) => (N(), A("div", {
1512
1898
  class: "flow-canvas-node-actions",
1513
- style: _e(o.value)
1899
+ style: ve(s.value)
1514
1900
  }, [
1515
- B("div", jt, [
1516
- r.value.debug.visible ? (M(), S("i", {
1901
+ G("div", Kt, [
1902
+ i.value.debug.visible ? (N(), A("i", {
1517
1903
  key: 0,
1518
- class: ee(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": r.value.debug.disabled }]),
1519
- onClick: f[0] || (f[0] = (p) => !r.value.debug.disabled && n("action", "debug", s.node.id))
1520
- }, null, 2)) : U("", !0),
1521
- r.value.delete.visible ? (M(), S("i", {
1904
+ class: te(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": i.value.debug.disabled }]),
1905
+ onClick: u[0] || (u[0] = (y) => !i.value.debug.disabled && o("action", "debug", n.node.id))
1906
+ }, null, 2)) : V("", !0),
1907
+ i.value.delete.visible ? (N(), A("i", {
1522
1908
  key: 1,
1523
- class: ee(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": r.value.delete.disabled }]),
1524
- onClick: f[1] || (f[1] = (p) => !r.value.delete.disabled && n("action", "delete", s.node.id))
1525
- }, null, 2)) : U("", !0),
1526
- i.value ? (M(), S("div", {
1909
+ class: te(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": i.value.delete.disabled }]),
1910
+ onClick: u[1] || (u[1] = (y) => !i.value.delete.disabled && o("action", "delete", n.node.id))
1911
+ }, null, 2)) : V("", !0),
1912
+ r.value ? (N(), A("div", {
1527
1913
  key: 2,
1528
1914
  class: "flow-canvas-node-actions__more-wrapper",
1529
- onMouseenter: g,
1530
- onMouseleave: d
1531
- }, [...f[5] || (f[5] = [
1532
- B("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1533
- ])], 32)) : U("", !0)
1915
+ onMouseenter: p,
1916
+ onMouseleave: c
1917
+ }, [...u[5] || (u[5] = [
1918
+ G("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1919
+ ])], 32)) : V("", !0)
1534
1920
  ]),
1535
- tt(ot, { name: "flow-canvas-fade" }, {
1536
- default: je(() => [
1537
- l.value && i.value ? (M(), S("div", {
1921
+ Ze(Qe, { name: "flow-canvas-fade" }, {
1922
+ default: $e(() => [
1923
+ l.value && r.value ? (N(), A("div", {
1538
1924
  key: 0,
1539
1925
  class: "flow-canvas-node-actions__dropdown",
1540
- onMouseenter: g,
1541
- onMouseleave: d
1926
+ onMouseenter: p,
1927
+ onMouseleave: c
1542
1928
  }, [
1543
- r.value.copy.visible ? (M(), S("div", {
1929
+ i.value.copy.visible ? (N(), A("div", {
1544
1930
  key: 0,
1545
- class: ee(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copy.disabled }]),
1546
- onClick: f[2] || (f[2] = (p) => !r.value.copy.disabled && n("action", "copy", s.node.id))
1547
- }, [...f[6] || (f[6] = [
1548
- B("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1549
- B("span", null, "复制", -1)
1550
- ])], 2)) : U("", !0),
1551
- r.value.copyInsert.visible ? (M(), S("div", {
1931
+ class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copy.disabled }]),
1932
+ onClick: u[2] || (u[2] = (y) => !i.value.copy.disabled && o("action", "copy", n.node.id))
1933
+ }, [...u[6] || (u[6] = [
1934
+ G("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1935
+ G("span", null, "复制", -1)
1936
+ ])], 2)) : V("", !0),
1937
+ i.value.copyInsert.visible ? (N(), A("div", {
1552
1938
  key: 1,
1553
- class: ee(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.copyInsert.disabled }]),
1554
- onClick: f[3] || (f[3] = (p) => !r.value.copyInsert.disabled && n("action", "copy-insert", s.node.id))
1555
- }, [...f[7] || (f[7] = [
1556
- B("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1557
- B("span", null, "复制并插入", -1)
1558
- ])], 2)) : U("", !0),
1559
- r.value.disconnect.visible ? (M(), S("div", {
1939
+ class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copyInsert.disabled }]),
1940
+ onClick: u[3] || (u[3] = (y) => !i.value.copyInsert.disabled && o("action", "copy-insert", n.node.id))
1941
+ }, [...u[7] || (u[7] = [
1942
+ G("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1943
+ G("span", null, "复制并插入", -1)
1944
+ ])], 2)) : V("", !0),
1945
+ i.value.disconnect.visible ? (N(), A("div", {
1560
1946
  key: 2,
1561
- class: ee(["flow-canvas-node-actions__dropdown-item", { "is-disabled": r.value.disconnect.disabled }]),
1562
- onClick: f[4] || (f[4] = (p) => !r.value.disconnect.disabled && n("action", "disconnect", s.node.id))
1563
- }, [...f[8] || (f[8] = [
1564
- B("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1565
- B("span", null, "断开连线", -1)
1566
- ])], 2)) : U("", !0)
1567
- ], 32)) : U("", !0)
1947
+ class: te(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.disconnect.disabled }]),
1948
+ onClick: u[4] || (u[4] = (y) => !i.value.disconnect.disabled && o("action", "disconnect", n.node.id))
1949
+ }, [...u[8] || (u[8] = [
1950
+ G("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1951
+ G("span", null, "断开连线", -1)
1952
+ ])], 2)) : V("", !0)
1953
+ ], 32)) : V("", !0)
1568
1954
  ]),
1569
1955
  _: 1
1570
1956
  })
1571
1957
  ], 4));
1572
1958
  }
1573
- }), he = (s, e) => {
1574
- const t = s.__vccOpts || s;
1575
- for (const [o, n] of e)
1576
- t[o] = n;
1959
+ }), pe = (n, e) => {
1960
+ const t = n.__vccOpts || n;
1961
+ for (const [s, o] of e)
1962
+ t[s] = o;
1577
1963
  return t;
1578
- }, Ft = /* @__PURE__ */ he(Ht, [["__scopeId", "data-v-3b39dab5"]]), qt = {
1964
+ }, Zt = /* @__PURE__ */ pe(Yt, [["__scopeId", "data-v-3b39dab5"]]), Qt = {
1579
1965
  key: 0,
1580
1966
  class: "flow-canvas-quick-add__tooltip"
1581
- }, Ut = 5, Vt = /* @__PURE__ */ ge({
1967
+ }, Jt = 5, eo = /* @__PURE__ */ le({
1582
1968
  __name: "node-quick-add-popover",
1583
1969
  props: {
1584
1970
  node: {},
1585
- portPosition: {},
1586
- tooltipText: {}
1971
+ portPosition: {}
1587
1972
  },
1588
1973
  emits: ["open", "close", "start-drag", "mouseenter", "mouseleave"],
1589
- setup(s, { expose: e, emit: t }) {
1590
- const o = s, n = t, r = O(), i = O(), l = O(!1), a = O(!1);
1591
- let g = null, d = !1, v = null;
1592
- function f(G) {
1593
- G.preventDefault(), G.stopPropagation(), g = { x: G.clientX, y: G.clientY }, d = !1, document.addEventListener("mousemove", p), document.addEventListener("mouseup", E);
1974
+ setup(n, { expose: e, emit: t }) {
1975
+ const s = n, o = t, i = O(), r = O(), l = O(!1), a = O(!1);
1976
+ let p = null, c = !1, g = null;
1977
+ function u(F) {
1978
+ F.preventDefault(), F.stopPropagation(), p = { x: F.clientX, y: F.clientY }, c = !1, document.addEventListener("mousemove", y), document.addEventListener("mouseup", v);
1594
1979
  }
1595
- function p(G) {
1596
- if (!g) return;
1597
- const T = G.clientX - g.x, h = G.clientY - g.y;
1598
- Math.sqrt(T * T + h * h) >= Ut && (d = !0, w(), n("start-drag", o.node.id));
1980
+ function y(F) {
1981
+ if (!p) return;
1982
+ const k = F.clientX - p.x, B = F.clientY - p.y;
1983
+ Math.sqrt(k * k + B * B) >= Jt && (c = !0, C(), o("start-drag", s.node.id));
1599
1984
  }
1600
- function E() {
1601
- w(), d || N(), g = null, d = !1;
1985
+ function v() {
1986
+ C(), c || M(), p = null, c = !1;
1602
1987
  }
1603
- function w() {
1604
- document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", E);
1988
+ function C() {
1989
+ document.removeEventListener("mousemove", y), document.removeEventListener("mouseup", v);
1605
1990
  }
1606
- function N() {
1607
- a.value ? D() : m();
1991
+ function M() {
1992
+ a.value ? L() : D();
1608
1993
  }
1609
- function m() {
1610
- a.value = !0, n("open", o.node.id), requestAnimationFrame(() => {
1611
- document.addEventListener("mousedown", z);
1994
+ function D() {
1995
+ a.value = !0, o("open", s.node.id), requestAnimationFrame(() => {
1996
+ document.addEventListener("mousedown", H);
1612
1997
  });
1613
1998
  }
1614
- function D() {
1615
- a.value = !1, n("close"), document.removeEventListener("mousedown", z);
1999
+ function L() {
2000
+ a.value = !1, o("close"), document.removeEventListener("mousedown", H);
1616
2001
  }
1617
- function z(G) {
1618
- const T = G.target;
1619
- r.value?.contains(T) || i.value?.contains(T) || D();
2002
+ function H(F) {
2003
+ const k = F.target;
2004
+ i.value?.contains(k) || r.value?.contains(k) || L();
1620
2005
  }
1621
- function X() {
1622
- a.value || n("mouseleave");
2006
+ function K() {
2007
+ a.value || o("mouseleave");
1623
2008
  }
1624
- function j() {
1625
- v && (clearTimeout(v), v = null), n("mouseenter");
2009
+ function $() {
2010
+ g && (clearTimeout(g), g = null), o("mouseenter");
1626
2011
  }
1627
- function oe() {
1628
- v = setTimeout(() => {
1629
- D(), n("mouseleave"), v = null;
2012
+ function W() {
2013
+ g = setTimeout(() => {
2014
+ L(), o("mouseleave"), g = null;
1630
2015
  }, 150);
1631
2016
  }
1632
- return ze(() => {
1633
- w(), v && clearTimeout(v), document.removeEventListener("mousedown", z);
1634
- }), e({ closePopover: D }), (G, T) => (M(), S("div", {
2017
+ return Se(() => {
2018
+ C(), g && clearTimeout(g), document.removeEventListener("mousedown", H);
2019
+ }), e({ closePopover: L }), (F, k) => (N(), A("div", {
1635
2020
  class: "flow-canvas-quick-add",
1636
- style: _e({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
1637
- onMouseenter: T[2] || (T[2] = (h) => n("mouseenter")),
1638
- onMouseleave: X,
1639
- onClick: T[3] || (T[3] = rt(() => {
2021
+ style: ve({ left: `${n.portPosition.x}px`, top: `${n.portPosition.y}px` }),
2022
+ onMouseenter: k[2] || (k[2] = (B) => o("mouseenter")),
2023
+ onMouseleave: K,
2024
+ onClick: k[3] || (k[3] = nt(() => {
1640
2025
  }, ["stop"]))
1641
2026
  }, [
1642
- B("div", {
2027
+ G("div", {
1643
2028
  ref_key: "btnRef",
1644
- ref: r,
1645
- class: ee(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
1646
- onMouseenter: T[0] || (T[0] = (h) => l.value = !0),
1647
- onMouseleave: T[1] || (T[1] = (h) => l.value = !1),
1648
- onMousedown: f
1649
- }, [...T[4] || (T[4] = [
1650
- B("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
2029
+ ref: i,
2030
+ class: te(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
2031
+ onMouseenter: k[0] || (k[0] = (B) => l.value = !0),
2032
+ onMouseleave: k[1] || (k[1] = (B) => l.value = !1),
2033
+ onMousedown: u
2034
+ }, [...k[4] || (k[4] = [
2035
+ G("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
1651
2036
  ])], 34),
1652
- l.value && !a.value ? (M(), S("div", qt, [...T[5] || (T[5] = [
1653
- B("div", null, [
1654
- B("b", null, "点击"),
1655
- Ve(" 添加节点")
2037
+ l.value && !a.value ? (N(), A("div", Qt, [...k[5] || (k[5] = [
2038
+ G("div", null, [
2039
+ G("b", null, "点击"),
2040
+ Pe(" 添加节点")
1656
2041
  ], -1),
1657
- B("div", null, [
1658
- B("b", null, "拖拽"),
1659
- Ve(" 连接节点")
2042
+ G("div", null, [
2043
+ G("b", null, "拖拽"),
2044
+ Pe(" 连接节点")
1660
2045
  ], -1)
1661
- ])])) : U("", !0),
1662
- tt(ot, { name: "flow-canvas-fade" }, {
1663
- default: je(() => [
1664
- a.value ? (M(), S("div", {
2046
+ ])])) : V("", !0),
2047
+ Ze(Qe, { name: "flow-canvas-fade" }, {
2048
+ default: $e(() => [
2049
+ a.value ? (N(), A("div", {
1665
2050
  key: 0,
1666
2051
  ref_key: "popoverRef",
1667
- ref: i,
2052
+ ref: r,
1668
2053
  class: "flow-canvas-quick-add__popover",
1669
- onMouseenter: j,
1670
- onMouseleave: oe
2054
+ onMouseenter: $,
2055
+ onMouseleave: W
1671
2056
  }, [
1672
- ke(G.$slots, "default", {}, () => [
1673
- T[6] || (T[6] = B("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
2057
+ we(F.$slots, "default", {}, () => [
2058
+ k[6] || (k[6] = G("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
1674
2059
  ], !0)
1675
- ], 544)) : U("", !0)
2060
+ ], 544)) : V("", !0)
1676
2061
  ]),
1677
2062
  _: 3
1678
2063
  })
1679
2064
  ], 36));
1680
2065
  }
1681
- }), Wt = /* @__PURE__ */ he(Vt, [["__scopeId", "data-v-b98695cf"]]), Qt = { class: "flow-canvas-runtime-core__overlay" }, Xt = /* @__PURE__ */ ge({
2066
+ }), to = /* @__PURE__ */ pe(eo, [["__scopeId", "data-v-336cc3b4"]]), oo = { class: "flow-canvas-selection-actions__bar" }, no = /* @__PURE__ */ le({
2067
+ __name: "selection-actions-toolbar",
2068
+ props: {
2069
+ position: {},
2070
+ canDelete: { type: Boolean }
2071
+ },
2072
+ emits: ["action"],
2073
+ setup(n, { emit: e }) {
2074
+ const t = n, s = e, o = j(() => ({
2075
+ left: `${t.position.x}px`,
2076
+ top: `${t.position.y}px`,
2077
+ transform: "translateX(-100%)"
2078
+ }));
2079
+ return (i, r) => (N(), A("div", {
2080
+ class: "flow-canvas-selection-actions",
2081
+ style: ve(o.value)
2082
+ }, [
2083
+ G("div", oo, [
2084
+ G("i", {
2085
+ class: te(["flow-canvas-icon canvas-shanchu flow-canvas-selection-actions__icon", { "is-disabled": !n.canDelete }]),
2086
+ onClick: r[0] || (r[0] = (l) => n.canDelete && s("action", "delete"))
2087
+ }, null, 2)
2088
+ ])
2089
+ ], 4));
2090
+ }
2091
+ }), so = /* @__PURE__ */ pe(no, [["__scopeId", "data-v-25eb8b79"]]), io = { class: "flow-canvas-runtime-core__overlay" }, ro = /* @__PURE__ */ le({
1682
2092
  __name: "canvas-runtime-core",
1683
2093
  props: {
1684
2094
  editor: {},
@@ -1688,47 +2098,20 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
1688
2098
  getConnectionExcludedNodeIds: { type: Function }
1689
2099
  },
1690
2100
  emits: ["ui-event"],
1691
- setup(s, { emit: e }) {
1692
- const t = s, o = e, n = O(), r = O();
1693
- let i, l, a, g;
1694
- const d = Ot(), { hoveredNodeId: v, isDraggingNode: f } = d, p = d.enterOverlay, E = () => d.leaveOverlay(), w = O(null), N = O(!1);
1695
- let m = null;
1696
- function D(y) {
1697
- return N.value ? !0 : (X(), ie(y) ? (w.value = y, !0) : (w.value = null, !1));
1698
- }
1699
- function z() {
1700
- m && clearTimeout(m), m = setTimeout(() => {
1701
- w.value = null, m = null;
1702
- }, 150);
1703
- }
1704
- function X() {
1705
- m && (clearTimeout(m), m = null);
1706
- }
1707
- function j() {
1708
- X(), d.enterOverlay();
1709
- }
1710
- function oe() {
1711
- z(), d.leaveOverlay();
2101
+ setup(n, { emit: e }) {
2102
+ const t = n, s = e, o = O(), i = O();
2103
+ let r, l, a, p, c = null, g = null, u = null, y = null;
2104
+ const v = Ut(), { hoveredNodeId: C, isDraggingNode: M } = v, D = v.enterOverlay, L = () => v.leaveOverlay(), H = O(0), K = O({ nodeIds: [], edgeIds: [] });
2105
+ function $(x) {
2106
+ const b = t.editor.api.value;
2107
+ return b ? t.editor.schema.nodeTypes[x.type]?.getBehavior?.(x, {
2108
+ api: b,
2109
+ flowModel: t.editor.flowModel.value,
2110
+ history: t.editor.history,
2111
+ mode: t.editor.mode.value
2112
+ }) ?? {} : {};
1712
2113
  }
1713
- let G = null, T = null, h = null, b = null, C = null;
1714
- const L = O(0), R = F(
1715
- () => {
1716
- if (L.value, !t.editor.api.value) return [];
1717
- const y = t.editor.flowModel.value, x = t.editor.api.value.overlay, c = [];
1718
- for (const [I, P] of Object.entries(y.nodes)) {
1719
- const _ = t.editor._pluginManager.collectNodeDecorations(P);
1720
- if (!_?.badge) continue;
1721
- const $ = x.getNodeScreenRect(I);
1722
- $ && c.push({
1723
- nodeId: I,
1724
- x: $.x + $.width - 4,
1725
- y: $.y - 8,
1726
- badge: _.badge
1727
- });
1728
- }
1729
- return c;
1730
- }
1731
- ), q = F(() => ({
2114
+ const W = j(() => t.editor.mode.value === "edit" && t.editor.selectionMode.value), F = j(() => ({
1732
2115
  showDebug: !1,
1733
2116
  showDelete: !0,
1734
2117
  showCopy: !0,
@@ -1736,301 +2119,188 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
1736
2119
  showDisconnect: !0,
1737
2120
  insertGap: 100,
1738
2121
  ...t.nodeActions
1739
- })), Y = F(() => {
1740
- L.value;
1741
- const y = v.value;
1742
- if (!y || f.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1743
- const x = t.editor.flowModel.value, c = x.nodes[y];
1744
- if (!c) return null;
1745
- const I = t.editor.api.value.overlay.getNodeScreenRect(y);
1746
- if (!I) return null;
1747
- const _ = t.editor.schema.nodeTypes[c.type]?.getBehavior?.(c, {
1748
- api: t.editor.api.value,
1749
- flowModel: x,
1750
- history: t.editor.history,
1751
- mode: t.editor.mode.value
1752
- }) ?? {};
1753
- return _.showActions === !1 ? null : {
1754
- node: c,
1755
- position: { x: I.x + I.width, y: I.y + I.height + 4 },
1756
- behavior: _
2122
+ })), k = j(
2123
+ () => {
2124
+ if (H.value, !t.editor.api.value) return [];
2125
+ const x = t.editor.flowModel.value, b = t.editor.api.value.overlay, _ = [];
2126
+ for (const [q, J] of Object.entries(x.nodes)) {
2127
+ const ue = t.editor._pluginManager.collectNodeDecorations(J);
2128
+ if (!ue?.badge) continue;
2129
+ const ie = b.getNodeScreenRect(q);
2130
+ ie && _.push({
2131
+ nodeId: q,
2132
+ x: ie.x + ie.width - 4,
2133
+ y: ie.y - 8,
2134
+ badge: ue.badge
2135
+ });
2136
+ }
2137
+ return _;
2138
+ }
2139
+ ), B = j(() => {
2140
+ H.value;
2141
+ const x = C.value;
2142
+ if (!x || M.value || !t.editor.api.value || t.editor.mode.value !== "edit" || W.value)
2143
+ return null;
2144
+ const _ = t.editor.flowModel.value.nodes[x];
2145
+ if (!_) return null;
2146
+ const q = t.editor.api.value.overlay.getNodeScreenRect(x);
2147
+ if (!q) return null;
2148
+ const J = $(_);
2149
+ return J.showActions === !1 ? null : {
2150
+ node: _,
2151
+ position: { x: q.x + q.width, y: q.y + q.height + 4 },
2152
+ behavior: J
1757
2153
  };
1758
- }), H = F(
1759
- () => ({
1760
- enabled: !0,
1761
- tooltipText: "",
1762
- portGroup: "right",
1763
- ...t.quickAdd
1764
- })
1765
- ), Q = F(() => {
1766
- if (L.value, !H.value.enabled) return null;
1767
- const y = w.value;
1768
- if (!y || f.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1769
- const x = t.editor.flowModel.value, c = x.nodes[y];
1770
- if (!c) return null;
1771
- const P = t.editor.schema.nodeTypes[c.type]?.getBehavior?.(c, {
1772
- api: t.editor.api.value,
1773
- flowModel: x,
1774
- history: t.editor.history,
1775
- mode: t.editor.mode.value
1776
- }) ?? {};
1777
- if (P.quickAddEnabled === !1) return null;
1778
- const _ = te(c);
1779
- return _ ? {
1780
- node: c,
1781
- portId: _.portId,
1782
- portGroup: _.portGroup,
1783
- portPosition: _.portPosition,
1784
- behavior: P
1785
- } : null;
1786
- }), de = O();
1787
- function re(y) {
1788
- N.value = !0;
1789
- const x = Q.value;
1790
- x && o("ui-event", {
1791
- type: "node.quick-add",
1792
- nodeId: y,
1793
- position: x.portPosition
1794
- });
1795
- }
1796
- function ce() {
1797
- N.value = !1;
1798
- }
1799
- function ue(y) {
1800
- const x = t.editor.api.value;
1801
- if (!x) return;
1802
- const I = t.editor.flowModel.value.nodes[y];
1803
- if (!I) return;
1804
- const P = te(I);
1805
- P && x.startConnection(y, P.portId);
1806
- }
1807
- function Ie(y, x) {
1808
- const c = t.editor.api.value;
1809
- if (!c) return;
1810
- const I = x.id || t.editor.idGenerator("node"), P = { ...x, id: I }, _ = t.editor.flowModel.value.nodes[y];
1811
- if (!_) return;
1812
- c.insertNodeToRight(y, P, {
1813
- autoWireEdges: !0,
1814
- direction: ye(_),
1815
- gap: q.value.insertGap,
1816
- source: "user:quick-add",
1817
- label: "快捷插入节点"
1818
- }).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: y, newNodeId: I }), de.value?.closePopover();
1819
- }
1820
- function se(y) {
2154
+ }), h = j(() => {
2155
+ if (H.value, !t.editor.api.value || t.editor.mode.value !== "edit") return null;
2156
+ const x = K.value;
2157
+ if (x.nodeIds.length + x.edgeIds.length <= 1) return null;
2158
+ const b = t.editor.api.value.getSelectionBounds(x);
2159
+ if (!b) return null;
2160
+ const _ = ot(x, t.editor.flowModel.value, $);
1821
2161
  return {
1822
- id: t.editor.idGenerator("node"),
1823
- type: y.type,
1824
- label: y.label,
1825
- ports: y.ports ? JSON.parse(JSON.stringify(y.ports)) : void 0,
1826
- payload: y.payload ? JSON.parse(JSON.stringify(y.payload)) : void 0,
1827
- extensions: y.extensions ? JSON.parse(JSON.stringify(y.extensions)) : void 0
2162
+ position: { x: b.x + b.width, y: b.y + b.height + 4 },
2163
+ canDelete: _.nodeIds.length > 0 || _.edgeIds.length > 0
1828
2164
  };
2165
+ }), d = O(), f = jt({
2166
+ editor: t.editor,
2167
+ quickAddProp: j(() => t.quickAdd),
2168
+ isDraggingNode: M,
2169
+ nodeHover: v,
2170
+ isSelectionModeActive: W,
2171
+ viewportVersion: H,
2172
+ getNodeBehavior: $,
2173
+ getInsertGap: () => F.value.insertGap,
2174
+ closePopover: () => d.value?.closePopover()
2175
+ }), I = f.data, S = f.handleOpen, w = f.handleClose, U = f.handleStartDrag, oe = f.handleOverlayEnter, E = f.handleOverlayLeave, T = f.handleInsert, m = Wt(t.editor);
2176
+ function P(x, b) {
2177
+ m.handleNodeAction(
2178
+ x,
2179
+ b,
2180
+ F.value.insertGap
2181
+ ) && (C.value = null);
2182
+ }
2183
+ function z(x) {
2184
+ x === "delete" && m.deleteSelection(K.value);
2185
+ }
2186
+ function Y(x) {
2187
+ if (t.editor.mode.value !== "edit") return;
2188
+ t.editor._pluginManager.dispatchKeyboardShortcut(x) && (x.preventDefault(), x.stopPropagation());
1829
2189
  }
1830
- function Me(y, x) {
1831
- const c = t.editor, I = c.api.value;
1832
- switch (y) {
1833
- case "delete": {
1834
- c.executeCommand({
1835
- id: W(),
1836
- source: "user:toolbar",
1837
- label: "删除节点",
1838
- timestamp: Date.now(),
1839
- commands: [{ type: "node.remove", nodeId: x }]
1840
- }), o("ui-event", { type: "node.action.delete", nodeId: x }), v.value = null;
1841
- break;
1842
- }
1843
- case "copy": {
1844
- if (!I) break;
1845
- const P = c.flowModel.value.nodes[x];
1846
- if (!P) break;
1847
- const _ = se(P);
1848
- I.insertNodeToRight(x, _, {
1849
- autoWireEdges: !1,
1850
- gap: q.value.insertGap,
1851
- label: "复制节点"
1852
- }), o("ui-event", { type: "node.action.copy", sourceNodeId: x, newNodeId: _.id });
1853
- break;
1854
- }
1855
- case "copy-insert": {
1856
- if (!I) break;
1857
- const P = c.flowModel.value.nodes[x];
1858
- if (!P) break;
1859
- const _ = se(P);
1860
- I.insertNodeToRight(x, _, {
1861
- autoWireEdges: !0,
1862
- gap: q.value.insertGap,
1863
- label: "复制并插入节点"
1864
- }), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: x, newNodeId: _.id });
1865
- break;
1866
- }
1867
- case "disconnect": {
1868
- const P = c.flowModel.value, _ = Object.entries(P.edges).filter(([, $]) => {
1869
- const J = $;
1870
- return J.source.nodeId === x || J.target.nodeId === x;
1871
- }).map(([$]) => $);
1872
- if (_.length === 0) break;
1873
- c.executeCommand({
1874
- id: W(),
1875
- source: "user:toolbar",
1876
- label: "断开连线",
1877
- timestamp: Date.now(),
1878
- commands: _.map(($) => ({ type: "edge.remove", edgeId: $ }))
1879
- }), o("ui-event", { type: "node.action.disconnect", nodeId: x, edgeIds: _ });
1880
- break;
2190
+ function X(x, b) {
2191
+ const _ = r, q = (J) => {
2192
+ const ue = _.isRubberbandEnabled?.() ?? !1;
2193
+ ue && _.disableRubberband?.(), J ? r.enablePanning() : r.disablePanning(), ue && _.enableRubberband?.();
2194
+ };
2195
+ x ? (_.enableSelection?.(), b ? (v.reset(), f.quickAddNodeId.value = null, f.quickAddPopoverOpen.value = !1, c?.remove(), q(!1), _.enableRubberband?.()) : (_.disableRubberband?.(), q(!0))) : (_.disableRubberband?.(), q(!0), _.disableSelection?.());
2196
+ }
2197
+ function ne(x) {
2198
+ r.on("node:move", ({ node: b }) => {
2199
+ M.value = !0;
2200
+ const _ = t.editor.flowModel.value.nodes[b.id];
2201
+ _ && $(_).bringToFrontOnDrag === !1 || b.toFront?.();
2202
+ }), r.on("node:moved", () => {
2203
+ M.value = !1;
2204
+ }), r.on("node:mouseenter", ({ node: b }) => {
2205
+ if (W.value) {
2206
+ C.value = null, f.quickAddNodeId.value = null, x.hideNodePorts(b);
2207
+ return;
1881
2208
  }
1882
- case "debug": {
1883
- o("ui-event", { type: "node.action.debug", nodeId: x });
1884
- break;
2209
+ v.enter(b.id);
2210
+ const _ = t.editor.flowModel.value.nodes[b.id];
2211
+ if (_ && $(_).showPorts === !1) {
2212
+ f.mergedConfig.value.enabled && f.enter(b.id);
2213
+ return;
1885
2214
  }
1886
- }
1887
- }
1888
- function ie(y) {
1889
- if (!H.value.enabled || t.editor.mode.value !== "edit") return !1;
1890
- const x = t.editor.flowModel.value, c = x.nodes[y];
1891
- return !c || (t.editor.schema.nodeTypes[c.type]?.getBehavior?.(c, {
1892
- api: t.editor.api.value,
1893
- flowModel: x,
1894
- history: t.editor.history,
1895
- mode: t.editor.mode.value
1896
- }) ?? {}).quickAddEnabled === !1 ? !1 : !!te(c);
1897
- }
1898
- function $e(y) {
1899
- const x = t.editor.schema.nodeTypes[y.type];
1900
- return Fe(y, x?.getPorts);
1901
- }
1902
- function ae(y) {
1903
- return y === "top" || y === "right" || y === "bottom" || y === "left";
1904
- }
1905
- function Z(y, x) {
1906
- const c = H.value.getPort?.(y, x);
1907
- if (!c) return null;
1908
- const I = typeof c == "string" ? c : c.id;
1909
- return x.find((P) => P.id === I) ?? null;
1910
- }
1911
- function we(y, x) {
1912
- const c = t.editor.api.value?.overlay.getNodeScreenRect(y);
1913
- if (!c) return null;
1914
- switch (x) {
1915
- case "top":
1916
- return { x: c.x + c.width / 2, y: c.y };
1917
- case "bottom":
1918
- return { x: c.x + c.width / 2, y: c.y + c.height };
1919
- case "left":
1920
- return { x: c.x, y: c.y + c.height / 2 };
1921
- case "right":
1922
- return { x: c.x + c.width, y: c.y + c.height / 2 };
1923
- default:
1924
- return null;
1925
- }
1926
- }
1927
- function ve(y, x, c) {
1928
- const I = i.getCellById(y);
1929
- if (I?.isNode()) {
1930
- const P = I, _ = i.findViewByCell(P), $ = _?.findPortElem(x, "circle") ?? _?.findPortElem(x);
1931
- if ($) {
1932
- const J = i.container.getBoundingClientRect(), le = $.getBoundingClientRect();
1933
- return {
1934
- x: le.left - J.left + le.width / 2,
1935
- y: le.top - J.top + le.height / 2
1936
- };
2215
+ f.mergedConfig.value.enabled && f.enter(b.id) || x.showNodePorts(b);
2216
+ }), r.on("node:mouseleave", ({ node: b }) => {
2217
+ if (W.value) {
2218
+ x.hideNodePorts(b);
2219
+ return;
1937
2220
  }
1938
- }
1939
- return we(y, c);
1940
- }
1941
- function te(y) {
1942
- const x = $e(y), c = Z(y, x) ?? x.find((P) => P.group === H.value.portGroup) ?? null;
1943
- if (!c) return null;
1944
- const I = ve(y.id, c.id, c.group);
1945
- return I ? {
1946
- portId: c.id,
1947
- portGroup: c.group,
1948
- portPosition: I
1949
- } : null;
1950
- }
1951
- function ye(y) {
1952
- const x = te(y), c = H.value.insertDirection;
1953
- if (typeof c == "function") {
1954
- const I = c(
1955
- y,
1956
- x ? { id: x.portId, group: x.portGroup } : null
1957
- );
1958
- if (I) return I;
1959
- } else if (c)
1960
- return c;
1961
- return x && ae(x.portGroup) ? x.portGroup : ae(H.value.portGroup) ? H.value.portGroup : "right";
1962
- }
1963
- function Ne(y) {
1964
- if (t.editor.mode.value !== "edit") return;
1965
- t.editor._pluginManager.dispatchKeyboardShortcut(y) && (y.preventDefault(), y.stopPropagation());
1966
- }
1967
- function xe() {
1968
- return {
1969
- refX: 0,
1970
- children: [
1971
- {
1972
- tagName: "path",
1973
- d: "M -16 -5 L -8 0 L -16 5 Z",
1974
- transform: "rotate(0)"
1975
- },
1976
- {
1977
- tagName: "circle",
1978
- cx: 0,
1979
- cy: 0,
1980
- r: 8,
1981
- fill: "#3a84ff",
1982
- stroke: "#3a84ff",
1983
- transform: "rotate(0)"
1984
- }
1985
- ]
1986
- };
2221
+ const _ = t.editor.flowModel.value.nodes[b.id];
2222
+ let q = 100;
2223
+ _ && $(_).actionsOffset && (q = 300), v.leave(q), f.mergedConfig.value.enabled ? f.quickAddNodeId.value === b.id && !f.quickAddPopoverOpen.value ? f.leave() : f.quickAddNodeId.value !== b.id && x.hideNodePorts(b) : x.hideNodePorts(b);
2224
+ });
1987
2225
  }
1988
- function K(y) {
1989
- const x = t.editor.schema.defaultEdgeType ?? "default", c = t.editor.schema.edgeTypes?.[x], I = {
1990
- zIndex: -1,
1991
- attrs: {
1992
- line: {
1993
- stroke: "#abb5cc",
1994
- strokeWidth: 2,
1995
- targetMarker: { name: "block", width: 8, height: 8 }
2226
+ function Q(x) {
2227
+ r.on("edge:added", ({ edge: b }) => {
2228
+ let _;
2229
+ if (t.getConnectionExcludedNodeIds && !b.getTargetCell()) {
2230
+ const q = b.getSourceCell();
2231
+ if (q) {
2232
+ const J = t.getConnectionExcludedNodeIds(q.id);
2233
+ _ = J instanceof Set ? J : new Set(J);
1996
2234
  }
1997
2235
  }
1998
- };
1999
- c?.router && (I.router = typeof c.router == "string" ? { name: c.router } : c.router), c?.connector && (I.connector = typeof c.connector == "string" ? { name: c.connector } : c.connector), c?.x6EdgeConfig && Object.assign(I, c.x6EdgeConfig);
2000
- const P = I.attrs ?? {}, _ = P.line ?? {};
2001
- return I.attrs = {
2002
- ...P,
2003
- line: {
2004
- ..._,
2005
- targetMarker: xe()
2236
+ x.handleEdgeAdded(b, _);
2237
+ }), r.on("edge:connected", () => {
2238
+ x.handleEdgeConnected();
2239
+ }), r.on("edge:removed", ({ edge: b }) => {
2240
+ x.handleEdgeRemoved(b.id), c.handleEdgeRemoved(b.id);
2241
+ }), r.on("edge:mouseenter", ({ edge: b, e: _ }) => {
2242
+ l.setHoveredEdge(b.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && !W.value && x.canShowEdgeTool() && c.show(b.id, _);
2243
+ }), r.on("edge:mouseleave", () => {
2244
+ l.setHoveredEdge(null), l.refreshEdgeStyles(), c.remove();
2245
+ }), r.on("edge:click", ({ edge: b, e: _ }) => {
2246
+ _.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (c.remove(), t.editor.executeCommand({
2247
+ id: Z(),
2248
+ source: "user:toolbar",
2249
+ label: "删除连线",
2250
+ timestamp: Date.now(),
2251
+ commands: [{ type: "edge.remove", edgeId: b.id }]
2252
+ }));
2253
+ }), g = (b) => c.move(b), r.container.addEventListener("mousemove", g);
2254
+ }
2255
+ function de() {
2256
+ u = (x) => {
2257
+ if (!C.value && !f.quickAddNodeId.value) return;
2258
+ const b = x.target;
2259
+ if (b?.closest?.(".x6-node") || b?.closest?.(".flow-canvas-node-actions") || b?.closest?.(".flow-canvas-quick-add")) {
2260
+ v.cancelLeave(), f.cancelLeave();
2261
+ return;
2006
2262
  }
2007
- }, y.createEdge(I);
2263
+ v.leave(180), f.quickAddPopoverOpen.value || f.leave();
2264
+ }, o.value?.addEventListener("mousemove", u), y = () => {
2265
+ v.reset(), f.quickAddPopoverOpen.value || (f.quickAddNodeId.value = null);
2266
+ }, o.value?.addEventListener("mouseleave", y), o.value?.addEventListener("keydown", Y);
2008
2267
  }
2009
- return at(() => {
2010
- if (!r.value) return;
2011
- const y = /* @__PURE__ */ new Set(["model", "container"]), x = {};
2268
+ function se() {
2269
+ fe(
2270
+ () => t.editor.flowModel.value,
2271
+ (x) => l.syncFlowModel(x)
2272
+ ), fe(
2273
+ [() => t.editor.mode.value, () => t.editor.selectionMode.value],
2274
+ ([x, b]) => {
2275
+ X(x === "edit", b);
2276
+ },
2277
+ { immediate: !0 }
2278
+ );
2279
+ }
2280
+ return Je(() => {
2281
+ if (!i.value) return;
2282
+ const x = /* @__PURE__ */ new Set(["model", "container"]), b = {};
2012
2283
  if (t.graphOptions)
2013
- for (const [u, k] of Object.entries(t.graphOptions)) {
2014
- if (y.has(u)) {
2015
- console.warn(`[flow-canvas] graphOptions.${u} is managed by the engine and will be ignored`);
2284
+ for (const [R, ge] of Object.entries(t.graphOptions)) {
2285
+ if (x.has(R)) {
2286
+ console.warn(`[flow-canvas] graphOptions.${R} is managed by the engine and will be ignored`);
2016
2287
  continue;
2017
2288
  }
2018
- x[u] = k;
2289
+ b[R] = ge;
2019
2290
  }
2020
- i = new ut({
2021
- container: r.value,
2291
+ r = new dt({
2292
+ container: i.value,
2022
2293
  autoResize: !0,
2023
2294
  background: { color: "#edf2fc" },
2024
2295
  grid: { visible: !0, size: 20, type: "dot" },
2025
2296
  highlighting: {
2026
- // 连接吸附到 port 时不再叠加 X6 默认橙色高亮,由业务层自行控制端口视觉。
2027
2297
  magnetAdsorbed: { name: "className", args: { className: "flow-canvas-magnet-adsorbed" } }
2028
2298
  },
2029
2299
  panning: { enabled: !0 },
2030
2300
  mousewheel: { enabled: !0, modifiers: ["ctrl", "meta"] },
2031
2301
  interacting: {
2032
- nodeMovable(u) {
2033
- return u.cell.getProp("draggable") !== !1;
2302
+ nodeMovable(R) {
2303
+ return R.cell.getProp("draggable") !== !1;
2034
2304
  }
2035
2305
  },
2036
2306
  connecting: {
@@ -2044,16 +2314,16 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
2044
2314
  connectionPoint: "anchor",
2045
2315
  snap: { radius: 30 },
2046
2316
  createEdge() {
2047
- return K(this);
2317
+ return Xt(this, t.editor.schema);
2048
2318
  }
2049
2319
  },
2050
- ...x
2051
- }), a = new Tt(), l = new At(
2052
- i,
2320
+ ...b
2321
+ }), a = new Lt(), l = new Rt(
2322
+ r,
2053
2323
  t.editor.schema,
2054
2324
  a,
2055
- (u) => t.editor._pluginManager.collectNodeDecorations(u),
2056
- (u) => t.editor._pluginManager.collectEdgeDecorations(u),
2325
+ (R) => t.editor._pluginManager.collectNodeDecorations(R),
2326
+ (R) => t.editor._pluginManager.collectEdgeDecorations(R),
2057
2327
  () => t.editor.api.value ? {
2058
2328
  api: t.editor.api.value,
2059
2329
  flowModel: t.editor.flowModel.value,
@@ -2061,313 +2331,194 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
2061
2331
  mode: t.editor.mode.value
2062
2332
  } : null
2063
2333
  );
2064
- const c = $t(i), I = Bt({
2065
- graph: i,
2066
- overlayManager: c,
2067
- executeCommand: (u) => t.editor.executeCommand(u),
2334
+ const _ = Ot(r), q = qt({
2335
+ graph: r,
2336
+ overlayManager: _,
2337
+ executeCommand: (R) => t.editor.executeCommand(R),
2068
2338
  schema: t.editor.schema,
2069
2339
  flowModel: t.editor.flowModel,
2340
+ getNodeBehavior: $,
2070
2341
  idGenerator: t.editor.idGenerator,
2071
2342
  defaultInsertGap: t.nodeActions?.insertGap,
2072
- getContextMenuItems: (u) => t.editor._pluginManager.collectContextMenuItems(u),
2073
- onHighlightChange: (u, k) => {
2074
- l.setHighlightedNodes(u), l.setHighlightedEdges(k), l.refreshNodeHighlights(), l.refreshEdgeStyles();
2343
+ getContextMenuItems: (R) => t.editor._pluginManager.collectContextMenuItems(R),
2344
+ onHighlightChange: (R, ge) => {
2345
+ l.setHighlightedNodes(R), l.setHighlightedEdges(ge), l.refreshNodeHighlights(), l.refreshEdgeStyles();
2075
2346
  },
2076
- resolveNodeShape: (u) => {
2077
- const k = t.editor.schema.nodeTypes[u];
2078
- if (!k) return null;
2079
- const A = a.registerNodeType(u, k.component), V = k.getSize({ id: "", type: u, position: { x: 0, y: 0 } });
2080
- return { shapeName: A, width: V.width, height: V.height };
2347
+ resolveNodeShape: (R) => {
2348
+ const ge = t.editor.schema.nodeTypes[R];
2349
+ if (!ge) return null;
2350
+ const ke = a.registerNodeType(R, ge.component), be = ge.getSize({ id: "", type: R, position: { x: 0, y: 0 } });
2351
+ return { shapeName: ke, width: be.width, height: be.height };
2081
2352
  }
2082
2353
  });
2083
- t.editor.api.value = I;
2084
- const P = {
2354
+ t.editor.api.value = q;
2355
+ const J = {
2085
2356
  flowModel: t.editor.flowModel,
2086
2357
  history: t.editor.history,
2087
2358
  schema: t.editor.schema,
2088
2359
  mode: t.editor.mode,
2089
2360
  idGenerator: t.editor.idGenerator,
2090
2361
  executeCommand: t.editor.executeCommand,
2091
- api: I,
2092
- overlay: c,
2093
- graph: i
2362
+ selectionMode: t.editor.selectionMode,
2363
+ api: q,
2364
+ overlay: _,
2365
+ graph: r
2094
2366
  };
2095
- t.editor._pluginManager.attachRuntime(P);
2096
- const _ = t.editor._pluginManager.collectExtendedApi();
2097
- Object.assign(t.editor.extendedApi, _), g = new Rt(
2098
- i,
2099
- (u) => {
2100
- (u.type === "node.click" || u.type === "node.dblclick" || u.type === "node.contextmenu") && d.enter(u.nodeId), t.editor._pluginManager.dispatchUiEvent(u), o("ui-event", u);
2367
+ t.editor._pluginManager.attachRuntime(J);
2368
+ const ue = t.editor._pluginManager.collectExtendedApi();
2369
+ Object.assign(t.editor.extendedApi, ue), t.editor._emitUiEvent = (R) => {
2370
+ t.editor._pluginManager.dispatchUiEvent(R), s("ui-event", R);
2371
+ }, p = new $t(
2372
+ r,
2373
+ (R) => {
2374
+ (R.type === "node.click" || R.type === "node.dblclick" || R.type === "node.contextmenu") && v.enter(R.nodeId), t.editor._emitUiEvent(R);
2101
2375
  },
2102
- (u) => {
2376
+ (R) => {
2103
2377
  if (l.isSyncing) return;
2104
- if (t.editor.executeCommand(u).status !== "applied") {
2105
- for (const A of u.commands)
2106
- if (A.type === "edge.add") {
2107
- const V = i.getCellById(A.edge.id);
2108
- V && i.removeCell(V);
2378
+ if (t.editor.executeCommand(R).status !== "applied") {
2379
+ for (const ke of R.commands)
2380
+ if (ke.type === "edge.add") {
2381
+ const be = r.getCellById(ke.edge.id);
2382
+ be && r.removeCell(be);
2109
2383
  }
2110
2384
  }
2111
2385
  },
2112
2386
  t.editor.flowModel,
2113
2387
  t.editor.idGenerator
2114
- ), G = Gt(i);
2115
- const $ = zt(i), J = i, le = (u) => {
2116
- const k = J.isRubberbandEnabled?.() ?? !1;
2117
- k && J.disableRubberband?.(), u ? i.enablePanning() : i.disablePanning(), k && J.enableRubberband?.();
2118
- }, Le = () => {
2119
- L.value++;
2120
- };
2121
- i.on("translate", Le), i.on("scale", Le), i.on("resize", Le), i.on("node:move", ({ node: u }) => {
2122
- f.value = !0;
2123
- const k = t.editor.flowModel.value.nodes[u.id];
2124
- k && t.editor.api.value && t.editor.schema.nodeTypes[k.type]?.getBehavior?.(k, {
2125
- api: t.editor.api.value,
2126
- flowModel: t.editor.flowModel.value,
2127
- history: t.editor.history,
2128
- mode: t.editor.mode.value
2129
- })?.bringToFrontOnDrag === !1 || u.toFront?.();
2130
- }), i.on("node:moved", () => {
2131
- f.value = !1;
2132
- }), i.on("node:mouseenter", ({ node: u }) => {
2133
- d.enter(u.id);
2134
- const k = t.editor.flowModel.value.nodes[u.id];
2135
- if (k && t.editor.api.value && t.editor.schema.nodeTypes[k.type]?.getBehavior?.(k, {
2136
- api: t.editor.api.value,
2137
- flowModel: t.editor.flowModel.value,
2138
- history: t.editor.history,
2139
- mode: t.editor.mode.value
2140
- })?.showPorts === !1) {
2141
- H.value.enabled && D(u.id);
2142
- return;
2143
- }
2144
- H.value.enabled && D(u.id) || $.showNodePorts(u);
2145
- }), i.on("node:mouseleave", ({ node: u }) => {
2146
- const k = t.editor.flowModel.value.nodes[u.id];
2147
- let A = 100;
2148
- k && t.editor.api.value && t.editor.schema.nodeTypes[k.type]?.getBehavior?.(k, {
2149
- api: t.editor.api.value,
2150
- flowModel: t.editor.flowModel.value,
2151
- history: t.editor.history,
2152
- mode: t.editor.mode.value
2153
- })?.actionsOffset && (A = 300), d.leave(A), H.value.enabled ? w.value === u.id && !N.value ? z() : w.value !== u.id && $.hideNodePorts(u) : $.hideNodePorts(u);
2154
- });
2155
- function st(u) {
2156
- const k = i.getCellById(u);
2157
- if (!k?.isNode()) return;
2158
- const A = k, V = t.editor.flowModel.value.nodes[u];
2159
- if (!V) return;
2160
- const Be = te(V);
2161
- let qe = !0;
2162
- t.editor.api.value && t.editor.schema.nodeTypes[V.type]?.getBehavior?.(V, {
2163
- api: t.editor.api.value,
2164
- flowModel: t.editor.flowModel.value,
2165
- history: t.editor.history,
2166
- mode: t.editor.mode.value
2167
- })?.hidePortForQuickAdd === !1 && (qe = !1);
2168
- const it = qe && !f.value && !!Be && ie(u);
2169
- for (const Oe of A.getPorts()) {
2170
- const Ue = it && Oe.id === Be?.portId ? "hidden" : "visible";
2171
- A.setPortProp(Oe.id, "attrs/circle/visibility", Ue);
2172
- }
2173
- }
2174
- fe(
2175
- [w, f],
2176
- ([u], [k]) => {
2177
- if (k && k !== u) {
2178
- const A = i.getCellById(k);
2179
- A?.isNode() && $.hideNodePorts(A);
2180
- }
2181
- u && st(u);
2182
- },
2183
- { flush: "sync" }
2184
- ), fe(Q, (u) => {
2185
- u || (N.value = !1);
2186
- }), i.on("edge:added", ({ edge: u }) => {
2187
- let k;
2188
- if (t.getConnectionExcludedNodeIds && !u.getTargetCell()) {
2189
- const A = u.getSourceCell();
2190
- if (A) {
2191
- const V = t.getConnectionExcludedNodeIds(A.id);
2192
- k = V instanceof Set ? V : new Set(V);
2193
- }
2194
- }
2195
- $.handleEdgeAdded(u, k);
2196
- }), i.on("edge:connected", () => {
2197
- $.handleEdgeConnected();
2198
- }), i.on("edge:removed", ({ edge: u }) => {
2199
- $.handleEdgeRemoved(u.id), G.handleEdgeRemoved(u.id);
2200
- }), i.on("selection:changed", () => {
2201
- const u = i.getSelectedCells?.() ?? [], k = {
2202
- nodeIds: u.filter((A) => A.isNode()).map((A) => A.id),
2203
- edgeIds: u.filter((A) => A.isEdge()).map((A) => A.id)
2204
- };
2205
- t.editor._pluginManager.dispatchSelectionChange(k), o("ui-event", {
2388
+ ), c = zt(r);
2389
+ const ie = Ft(r);
2390
+ f.attachRuntime(r, (R) => ie.hideNodePorts(R)), ne(ie), Q(ie), r.on("selection:changed", () => {
2391
+ const R = tt(r.getSelectedCells?.() ?? []);
2392
+ K.value = R, t.editor._pluginManager.dispatchSelectionChange(R), s("ui-event", {
2206
2393
  type: "selection.change",
2207
- nodeIds: k.nodeIds,
2208
- edgeIds: k.edgeIds
2209
- }), l.refreshEdgeStyles();
2210
- }), i.on("edge:mouseenter", ({ edge: u, e: k }) => {
2211
- l.setHoveredEdge(u.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && $.canShowEdgeTool() && G.show(u.id, k);
2212
- }), T = (u) => G.move(u), i.container.addEventListener("mousemove", T), h = (u) => {
2213
- if (!v.value && !w.value) return;
2214
- const k = u.target;
2215
- if (k?.closest?.(".x6-node") || k?.closest?.(".flow-canvas-node-actions") || k?.closest?.(".flow-canvas-quick-add")) {
2216
- d.cancelLeave(), X();
2217
- return;
2218
- }
2219
- d.leave(180), N.value || z();
2220
- }, n.value?.addEventListener("mousemove", h), b = () => {
2221
- d.reset(), N.value || (w.value = null);
2222
- }, n.value?.addEventListener("mouseleave", b), i.on("edge:mouseleave", () => {
2223
- l.setHoveredEdge(null), l.refreshEdgeStyles(), G.remove();
2224
- }), i.on("edge:click", ({ edge: u, e: k }) => {
2225
- k.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (G.remove(), t.editor.executeCommand({
2226
- id: W(),
2227
- source: "user:toolbar",
2228
- label: "删除连线",
2229
- timestamp: Date.now(),
2230
- commands: [{ type: "edge.remove", edgeId: u.id }]
2231
- }));
2232
- }), n.value?.addEventListener("keydown", Ne), l.syncFlowModel(t.editor.flowModel.value), fe(
2233
- () => t.editor.flowModel.value,
2234
- (u) => l.syncFlowModel(u)
2235
- ), fe(
2236
- () => t.editor.selectionMode.value,
2237
- (u) => {
2238
- if (C?.(), C = null, u) {
2239
- le(!1), J.enableRubberband?.();
2240
- const k = () => {
2241
- i.container.removeEventListener("mouseup", k), C = null, setTimeout(() => {
2242
- t.editor.selectionMode.value && t.editor.setSelectionMode(!1);
2243
- }, 50);
2244
- };
2245
- i.container.addEventListener("mouseup", k), C = () => i.container.removeEventListener("mouseup", k);
2246
- } else
2247
- J.disableRubberband?.(), le(!0);
2248
- }
2249
- ), fe(
2250
- () => t.editor.mode.value,
2251
- (u) => {
2252
- const k = u === "edit";
2253
- le(!0), k ? J.enableSelection?.() : J.disableSelection?.();
2254
- }
2255
- );
2256
- }), ze(() => {
2257
- d.cleanup(), m && clearTimeout(m), G?.remove(), C?.(), T && i?.container?.removeEventListener("mousemove", T), h && n.value?.removeEventListener("mousemove", h), b && n.value?.removeEventListener("mouseleave", b), n.value?.removeEventListener("keydown", Ne), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2258
- for (const y of Object.keys(t.editor.extendedApi))
2259
- delete t.editor.extendedApi[y];
2260
- g?.dispose(), l?.dispose(), a?.dispose(), i?.dispose();
2261
- }), (y, x) => (M(), S("div", {
2394
+ nodeIds: R.nodeIds,
2395
+ edgeIds: R.edgeIds
2396
+ }), l.refreshNodeHighlights(), l.refreshEdgeStyles();
2397
+ });
2398
+ const ee = () => {
2399
+ H.value++;
2400
+ };
2401
+ r.on("translate", ee), r.on("scale", ee), r.on("resize", ee), de(), l.syncFlowModel(t.editor.flowModel.value), se();
2402
+ }), Se(() => {
2403
+ v.cleanup(), f.cleanup(), c?.remove(), g && r?.container?.removeEventListener("mousemove", g), u && o.value?.removeEventListener("mousemove", u), y && o.value?.removeEventListener("mouseleave", y), o.value?.removeEventListener("keydown", Y), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2404
+ for (const x of Object.keys(t.editor.extendedApi))
2405
+ delete t.editor.extendedApi[x];
2406
+ p?.dispose(), l?.dispose(), a?.dispose(), r?.dispose();
2407
+ }), (x, b) => (N(), A("div", {
2262
2408
  ref_key: "rootRef",
2263
- ref: n,
2264
- class: "flow-canvas-runtime-core",
2409
+ ref: o,
2410
+ class: te(["flow-canvas-runtime-core", { "flow-canvas-runtime-core--selection-mode": W.value }]),
2265
2411
  tabindex: "0"
2266
2412
  }, [
2267
- B("div", {
2413
+ G("div", {
2268
2414
  ref_key: "containerRef",
2269
- ref: r,
2415
+ ref: i,
2270
2416
  class: "flow-canvas-runtime-core__graph"
2271
2417
  }, null, 512),
2272
- B("div", Qt, [
2273
- (M(!0), S(pe, null, Pe(R.value, (c) => (M(), S("div", {
2274
- key: `badge-${c.nodeId}`,
2418
+ G("div", io, [
2419
+ (N(!0), A(he, null, xe(k.value, (_) => (N(), A("div", {
2420
+ key: `badge-${_.nodeId}`,
2275
2421
  class: "flow-canvas-runtime-core__badge",
2276
- style: _e({ left: `${c.x}px`, top: `${c.y}px`, backgroundColor: c.badge.color })
2277
- }, me(c.badge.text), 5))), 128)),
2278
- Q.value ? (M(), De(Wt, {
2422
+ style: ve({ left: `${_.x}px`, top: `${_.y}px`, backgroundColor: _.badge.color })
2423
+ }, ce(_.badge.text), 5))), 128)),
2424
+ re(I) ? (N(), ye(to, {
2279
2425
  key: 0,
2280
2426
  ref_key: "quickAddPopoverRef",
2281
- ref: de,
2282
- node: Q.value.node,
2283
- "port-position": Q.value.portPosition,
2284
- "tooltip-text": H.value.tooltipText,
2285
- onOpen: re,
2286
- onClose: ce,
2287
- onStartDrag: ue,
2288
- onMouseenter: j,
2289
- onMouseleave: oe
2427
+ ref: d,
2428
+ node: re(I).node,
2429
+ "port-position": re(I).portPosition,
2430
+ onOpen: re(S),
2431
+ onClose: re(w),
2432
+ onStartDrag: re(U),
2433
+ onMouseenter: re(oe),
2434
+ onMouseleave: re(E)
2290
2435
  }, {
2291
- default: je(() => [
2292
- ke(y.$slots, "quick-add-panel", {
2293
- node: Q.value.node,
2294
- api: s.editor.api.value,
2295
- insertNodeToRight: (c) => Ie(Q.value.node.id, c),
2296
- closePopover: () => de.value?.closePopover()
2436
+ default: $e(() => [
2437
+ we(x.$slots, "quick-add-panel", {
2438
+ node: re(I).node,
2439
+ api: n.editor.api.value,
2440
+ insertNodeToRight: (_) => re(T)(re(I).node.id, _),
2441
+ closePopover: () => d.value?.closePopover()
2297
2442
  }, void 0, !0)
2298
2443
  ]),
2299
2444
  _: 3
2300
- }, 8, ["node", "port-position", "tooltip-text"])) : U("", !0),
2301
- Y.value ? (M(), De(Ft, {
2445
+ }, 8, ["node", "port-position", "onOpen", "onClose", "onStartDrag", "onMouseenter", "onMouseleave"])) : V("", !0),
2446
+ B.value ? (N(), ye(Zt, {
2302
2447
  key: 1,
2303
- node: Y.value.node,
2304
- position: Y.value.position,
2305
- config: q.value,
2306
- behavior: Y.value.behavior,
2307
- "actions-offset": Y.value.behavior.actionsOffset,
2308
- onAction: Me,
2309
- onMouseenter: lt(p),
2310
- onMouseleave: E
2311
- }, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : U("", !0)
2448
+ node: B.value.node,
2449
+ position: B.value.position,
2450
+ config: F.value,
2451
+ behavior: B.value.behavior,
2452
+ "actions-offset": B.value.behavior.actionsOffset,
2453
+ onAction: P,
2454
+ onMouseenter: re(D),
2455
+ onMouseleave: L
2456
+ }, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : V("", !0),
2457
+ h.value ? (N(), ye(so, {
2458
+ key: 2,
2459
+ position: h.value.position,
2460
+ "can-delete": h.value.canDelete,
2461
+ onAction: z
2462
+ }, null, 8, ["position", "can-delete"])) : V("", !0)
2312
2463
  ])
2313
- ], 512));
2464
+ ], 2));
2314
2465
  }
2315
- }), So = /* @__PURE__ */ he(Xt, [["__scopeId", "data-v-b37732f8"]]), Yt = { class: "flow-canvas-node-palette" }, Kt = ["data-node-type"], Zt = { class: "flow-canvas-node-palette__item-label" }, Jt = /* @__PURE__ */ ge({
2466
+ }), ln = /* @__PURE__ */ pe(ro, [["__scopeId", "data-v-84f96992"]]), ao = { class: "flow-canvas-node-palette" }, lo = ["data-node-type"], co = { class: "flow-canvas-node-palette__item-label" }, uo = /* @__PURE__ */ le({
2316
2467
  __name: "canvas-node-palette",
2317
2468
  props: {
2318
2469
  editor: {},
2319
2470
  items: {}
2320
2471
  },
2321
- setup(s) {
2322
- const e = s, t = O(), o = F(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
2323
- type: n,
2324
- label: n.charAt(0).toUpperCase() + n.slice(1)
2472
+ setup(n) {
2473
+ const e = n, t = O(), s = j(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((o) => ({
2474
+ type: o,
2475
+ label: o.charAt(0).toUpperCase() + o.slice(1)
2325
2476
  })));
2326
2477
  return fe(
2327
- [() => e.editor.api.value, o, t],
2328
- ([n, r, i], l, a) => {
2329
- if (!n || !i) return;
2330
- const g = [];
2331
- for (const d of r) {
2332
- const v = i.querySelector(`[data-node-type="${d.type}"]`);
2333
- if (!v) continue;
2334
- const f = n.registerDndSource(v, () => ({
2335
- id: W(),
2336
- type: d.type,
2337
- label: d.label,
2478
+ [() => e.editor.api.value, s, t],
2479
+ ([o, i, r], l, a) => {
2480
+ if (!o || !r) return;
2481
+ const p = [];
2482
+ for (const c of i) {
2483
+ const g = r.querySelector(`[data-node-type="${c.type}"]`);
2484
+ if (!g) continue;
2485
+ const u = o.registerDndSource(g, () => ({
2486
+ id: Z(),
2487
+ type: c.type,
2488
+ label: c.label,
2338
2489
  position: { x: 0, y: 0 }
2339
2490
  }));
2340
- g.push(f);
2491
+ p.push(u);
2341
2492
  }
2342
2493
  a(() => {
2343
- for (const d of g) d();
2494
+ for (const c of p) c();
2344
2495
  });
2345
2496
  },
2346
2497
  { flush: "post" }
2347
- ), (n, r) => (M(), S("div", Yt, [
2348
- B("div", {
2498
+ ), (o, i) => (N(), A("div", ao, [
2499
+ G("div", {
2349
2500
  ref_key: "listRef",
2350
2501
  ref: t,
2351
2502
  class: "flow-canvas-node-palette__list"
2352
2503
  }, [
2353
- (M(!0), S(pe, null, Pe(o.value, (i) => (M(), S("div", {
2354
- key: i.type,
2504
+ (N(!0), A(he, null, xe(s.value, (r) => (N(), A("div", {
2505
+ key: r.type,
2355
2506
  class: "flow-canvas-node-palette__item",
2356
- "data-node-type": i.type
2507
+ "data-node-type": r.type
2357
2508
  }, [
2358
- i.icon ? (M(), S("i", {
2509
+ r.icon ? (N(), A("i", {
2359
2510
  key: 0,
2360
- class: ee([i.icon, "flow-canvas-node-palette__item-icon"])
2361
- }, null, 2)) : U("", !0),
2362
- B("span", Zt, me(i.label), 1)
2363
- ], 8, Kt))), 128))
2511
+ class: te([r.icon, "flow-canvas-node-palette__item-icon"])
2512
+ }, null, 2)) : V("", !0),
2513
+ G("span", co, ce(r.label), 1)
2514
+ ], 8, lo))), 128))
2364
2515
  ], 512)
2365
2516
  ]));
2366
2517
  }
2367
- }), eo = /* @__PURE__ */ he(Jt, [["__scopeId", "data-v-300314b7"]]), to = { class: "flow-canvas-layout" }, oo = { class: "flow-canvas-layout__main" }, no = { class: "flow-canvas-layout__content" }, so = {
2518
+ }), fo = /* @__PURE__ */ pe(uo, [["__scopeId", "data-v-300314b7"]]), po = { class: "flow-canvas-layout" }, go = { class: "flow-canvas-layout__main" }, ho = { class: "flow-canvas-layout__content" }, vo = {
2368
2519
  key: 0,
2369
2520
  class: "flow-canvas-layout__footer"
2370
- }, io = /* @__PURE__ */ ge({
2521
+ }, yo = /* @__PURE__ */ le({
2371
2522
  __name: "canvas-layout",
2372
2523
  props: {
2373
2524
  sidebarCollapsed: { type: Boolean, default: !1 },
@@ -2378,34 +2529,34 @@ const jt = { class: "flow-canvas-node-actions__bar" }, Ht = /* @__PURE__ */ ge({
2378
2529
  paletteItems: { default: void 0 }
2379
2530
  },
2380
2531
  emits: ["update:sidebarCollapsed"],
2381
- setup(s) {
2382
- return (e, t) => (M(), S("div", to, [
2383
- !s.hideSidebar && (e.$slots.sidebar || s.editor) ? (M(), S("aside", {
2532
+ setup(n) {
2533
+ return (e, t) => (N(), A("div", po, [
2534
+ !n.hideSidebar && (e.$slots.sidebar || n.editor) ? (N(), A("aside", {
2384
2535
  key: 0,
2385
- class: ee(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
2386
- style: _e({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
2536
+ class: te(["flow-canvas-layout__sidebar", { "is-collapsed": n.sidebarCollapsed }]),
2537
+ style: ve({ width: n.sidebarCollapsed ? "0px" : `${n.sidebarWidth}px` })
2387
2538
  }, [
2388
- ke(e.$slots, "sidebar", {}, () => [
2389
- s.editor ? (M(), De(eo, {
2539
+ we(e.$slots, "sidebar", {}, () => [
2540
+ n.editor ? (N(), ye(fo, {
2390
2541
  key: 0,
2391
- editor: s.editor,
2392
- items: s.paletteItems
2393
- }, null, 8, ["editor", "items"])) : U("", !0)
2542
+ editor: n.editor,
2543
+ items: n.paletteItems
2544
+ }, null, 8, ["editor", "items"])) : V("", !0)
2394
2545
  ], !0)
2395
- ], 6)) : U("", !0),
2396
- B("div", oo, [
2397
- B("div", no, [
2398
- ke(e.$slots, "default", {}, void 0, !0)
2546
+ ], 6)) : V("", !0),
2547
+ G("div", go, [
2548
+ G("div", ho, [
2549
+ we(e.$slots, "default", {}, void 0, !0)
2399
2550
  ]),
2400
- !s.hideFooter && e.$slots.footer ? (M(), S("div", so, [
2401
- ke(e.$slots, "footer", {}, void 0, !0)
2402
- ])) : U("", !0)
2551
+ !n.hideFooter && e.$slots.footer ? (N(), A("div", vo, [
2552
+ we(e.$slots, "footer", {}, void 0, !0)
2553
+ ])) : V("", !0)
2403
2554
  ])
2404
2555
  ]));
2405
2556
  }
2406
- }), Do = /* @__PURE__ */ he(io, [["__scopeId", "data-v-26f35b6b"]]), ro = ["undo", "redo"];
2407
- function ao(s) {
2408
- const e = new Set(s?.include), t = /* @__PURE__ */ new Set([...ro.filter((a) => !e.has(a)), ...s?.exclude ?? []]), o = [
2557
+ }), dn = /* @__PURE__ */ pe(yo, [["__scopeId", "data-v-26f35b6b"]]), mo = ["undo", "redo"];
2558
+ function bo(n) {
2559
+ const e = new Set(n?.include), t = new Set(mo.filter((a) => !e.has(a))), s = [
2409
2560
  {
2410
2561
  id: "undo",
2411
2562
  type: "undo",
@@ -2422,7 +2573,7 @@ function ao(s) {
2422
2573
  description: "重做",
2423
2574
  order: 11
2424
2575
  }
2425
- ], n = [
2576
+ ], o = [
2426
2577
  {
2427
2578
  id: "select",
2428
2579
  type: "select",
@@ -2439,22 +2590,6 @@ function ao(s) {
2439
2590
  description: "自动排版",
2440
2591
  order: 21
2441
2592
  },
2442
- {
2443
- id: "search",
2444
- type: "search",
2445
- group: "tools",
2446
- icon: "flow-canvas-icon canvas-search",
2447
- description: "搜索节点",
2448
- order: 22
2449
- },
2450
- {
2451
- id: "minimap",
2452
- type: "minimap",
2453
- group: "tools",
2454
- icon: "flow-canvas-icon canvas-map",
2455
- description: "缩略图",
2456
- order: 23
2457
- },
2458
2593
  {
2459
2594
  id: "export",
2460
2595
  type: "export",
@@ -2463,7 +2598,7 @@ function ao(s) {
2463
2598
  description: "导出为图片",
2464
2599
  order: 24
2465
2600
  }
2466
- ], r = [
2601
+ ], i = [
2467
2602
  {
2468
2603
  id: "zoom-out",
2469
2604
  type: "zoom-out",
@@ -2481,7 +2616,7 @@ function ao(s) {
2481
2616
  description: "放大画布",
2482
2617
  order: 32
2483
2618
  }
2484
- ], i = [
2619
+ ], r = [
2485
2620
  {
2486
2621
  id: "reset",
2487
2622
  type: "reset",
@@ -2491,180 +2626,268 @@ function ao(s) {
2491
2626
  order: 40
2492
2627
  }
2493
2628
  ];
2494
- return [...[...o, ...n].filter(
2629
+ return [...[...s, ...o].filter(
2495
2630
  (a) => !t.has(a.type)
2496
- ), ...r, ...i];
2631
+ ), ...i, ...r];
2497
2632
  }
2498
- const lo = { class: "flow-canvas-toolbar" }, co = {
2633
+ const wo = { class: "flow-canvas-toolbar" }, xo = {
2499
2634
  key: 0,
2500
2635
  class: "flow-canvas-toolbar__separator"
2501
- }, uo = { class: "flow-canvas-toolbar__group" }, fo = {
2636
+ }, Co = { class: "flow-canvas-toolbar__group" }, Eo = {
2502
2637
  key: 0,
2503
2638
  class: "flow-canvas-toolbar__zoom-display"
2504
- }, po = ["data-description", "disabled", "onClick"], go = ["textContent"], ho = /* @__PURE__ */ ge({
2639
+ }, ko = ["data-toolbar-id", "data-toolbar-type", "disabled", "onClick", "onMouseenter"], Io = ["textContent"], So = /* @__PURE__ */ le({
2505
2640
  __name: "canvas-toolbar",
2506
2641
  props: {
2507
2642
  items: {},
2508
2643
  exclude: {},
2509
2644
  editor: {}
2510
2645
  },
2511
- setup(s) {
2512
- const e = s, t = F(() => e.items ? e.items : ao({ exclude: e.exclude })), o = O(1);
2513
- let n = null;
2646
+ setup(n) {
2647
+ const e = /* @__PURE__ */ new Set([
2648
+ "undo",
2649
+ "redo",
2650
+ "select",
2651
+ "auto-layout",
2652
+ "search",
2653
+ "minimap",
2654
+ "export"
2655
+ ]), t = /* @__PURE__ */ new Set(["select", "search", "minimap"]);
2656
+ function s(d) {
2657
+ return d.id.startsWith("plugin:") || d.type === "custom";
2658
+ }
2659
+ function o(d) {
2660
+ return d !== "custom" && t.has(d);
2661
+ }
2662
+ const i = n, r = j(() => {
2663
+ if (i.items) return i.items;
2664
+ const d = bo(), f = i.editor.toolbarItems.value, I = new Set(i.exclude ?? []), S = /* @__PURE__ */ new Map();
2665
+ for (const w of d)
2666
+ S.set(w.id, w);
2667
+ for (const w of f) {
2668
+ const U = S.get(w.id);
2669
+ U ? S.set(w.id, { ...U, ...w, order: U.order, group: U.group }) : s(w) && S.set(w.id, w);
2670
+ }
2671
+ return [...S.values()].filter((w) => w.type === "custom" || !e.has(w.type) ? !0 : !I.has(w.type)).sort((w, U) => (w.order ?? 0) - (U.order ?? 0));
2672
+ }), l = O(1), a = O(null), p = O(null), c = O(!1);
2673
+ let g = null;
2514
2674
  fe(
2515
- () => e.editor.api.value,
2516
- (p) => {
2517
- n?.(), n = null, p && (o.value = p.getZoom(), n = p.onGraphEvent("scale", () => {
2518
- o.value = p.getZoom();
2675
+ () => i.editor.api.value,
2676
+ (d) => {
2677
+ g?.(), g = null, d && (l.value = d.getZoom(), g = d.onGraphEvent("scale", () => {
2678
+ l.value = d.getZoom();
2519
2679
  }));
2520
2680
  },
2521
2681
  { immediate: !0 }
2522
- ), et(() => {
2523
- n?.();
2682
+ );
2683
+ const u = st({ visible: !1, text: "", x: 0, y: 0 });
2684
+ function y(d, f) {
2685
+ if (!f.description) return;
2686
+ const S = d.currentTarget.getBoundingClientRect();
2687
+ u.text = f.description, u.visible = !0, Te(() => {
2688
+ const w = a.value?.offsetWidth ?? 0, U = a.value?.offsetHeight ?? 0;
2689
+ u.x = S.left + S.width / 2 - w / 2, u.y = S.top - U - 6;
2690
+ });
2691
+ }
2692
+ function v() {
2693
+ u.visible = !1, a.value = null;
2694
+ }
2695
+ Ye(() => {
2696
+ g?.();
2524
2697
  });
2525
- const r = F(() => `${Math.round(o.value * 100)}%`), i = F(() => e.editor.api.value ? {
2526
- api: e.editor.api.value,
2527
- flowModel: e.editor.flowModel.value,
2528
- history: e.editor.history,
2529
- mode: e.editor.mode.value
2698
+ const C = j(() => `${Math.round(l.value * 100)}%`), M = j(() => i.editor.api.value ? {
2699
+ api: i.editor.api.value,
2700
+ flowModel: i.editor.flowModel.value,
2701
+ history: i.editor.history,
2702
+ mode: i.editor.mode.value
2530
2703
  } : null);
2531
- function l(p) {
2532
- return p.visible === !1 ? !1 : typeof p.visible == "function" ? i.value ? p.visible(i.value) : !1 : !0;
2704
+ function D(d) {
2705
+ return d.visible === !1 ? !1 : typeof d.visible == "function" ? M.value ? d.visible(M.value) : !1 : !0;
2533
2706
  }
2534
- function a(p) {
2535
- return p.type === "select" ? e.editor.selectionMode.value : !1;
2707
+ function L(d) {
2708
+ return typeof d.active == "function" ? M.value ? d.active(M.value) : !1 : d.active !== void 0 ? d.active : d.type === "select" ? i.editor.selectionMode.value : !1;
2536
2709
  }
2537
- function g(p) {
2538
- return !i.value || p.disabled === !0 ? !0 : typeof p.disabled == "function" ? p.disabled(i.value) : p.type === "undo" ? !e.editor.history.canUndo.value : p.type === "redo" ? !e.editor.history.canRedo.value : !1;
2710
+ const H = j(() => {
2711
+ const d = B.value.filter(
2712
+ (I) => o(I.type) && L(I)
2713
+ );
2714
+ if (d.length === 0) return null;
2715
+ const f = p.value;
2716
+ return f && d.some((I) => I.type === f) ? f : d[0]?.type ?? null;
2717
+ });
2718
+ function K(d) {
2719
+ return o(d.type) ? H.value === d.type : L(d);
2720
+ }
2721
+ function $(d) {
2722
+ return !M.value || d.disabled === !0 ? !0 : typeof d.disabled == "function" ? d.disabled(M.value) : d.type === "undo" ? !i.editor.history.canUndo.value : d.type === "redo" ? !i.editor.history.canRedo.value : d.type === "export" ? c.value : !1;
2723
+ }
2724
+ function W(d) {
2725
+ if (!(!M.value || !o(d.type) || !L(d))) {
2726
+ if (d.type === "select") {
2727
+ i.editor.setSelectionMode(!1);
2728
+ return;
2729
+ }
2730
+ d.onClick?.(M.value);
2731
+ }
2539
2732
  }
2540
- function d(p) {
2541
- if (!i.value || g(p)) return;
2542
- if (p.onClick) {
2543
- p.onClick(i.value);
2733
+ function F(d) {
2734
+ if (o(d.type))
2735
+ for (const f of B.value)
2736
+ !o(f.type) || f.id === d.id || W(f);
2737
+ }
2738
+ function k(d) {
2739
+ if (!M.value || $(d)) return;
2740
+ if (o(d.type) && (p.value = d.type, F(d)), d.onClick) {
2741
+ d.onClick(M.value);
2544
2742
  return;
2545
2743
  }
2546
- const { api: E } = i.value;
2547
- switch (p.type) {
2744
+ const { api: f } = M.value;
2745
+ switch (d.type) {
2548
2746
  case "undo":
2549
- e.editor.history.undo();
2747
+ i.editor.history.undo();
2550
2748
  break;
2551
2749
  case "redo":
2552
- e.editor.history.redo();
2750
+ i.editor.history.redo();
2553
2751
  break;
2554
2752
  case "zoom-in":
2555
- E.zoomIn(), o.value = E.getZoom();
2753
+ f.zoomIn(), l.value = f.getZoom();
2556
2754
  break;
2557
2755
  case "zoom-out":
2558
- E.zoomOut(), o.value = E.getZoom();
2756
+ f.zoomOut(), l.value = f.getZoom();
2559
2757
  break;
2560
2758
  case "fit":
2561
- E.zoomToFit();
2759
+ f.zoomToFit();
2562
2760
  break;
2563
2761
  case "reset":
2564
- E.zoomTo(1), E.scrollToOrigin(), o.value = 1;
2762
+ f.zoomTo(1), f.scrollToOrigin(), l.value = 1;
2565
2763
  break;
2566
2764
  case "export":
2567
- E.exportAsImage().then((w) => {
2568
- const N = URL.createObjectURL(w), m = document.createElement("a");
2569
- m.href = N, m.download = "canvas-export.png", m.click(), URL.revokeObjectURL(N);
2570
- }).catch((w) => {
2571
- console.warn("[flow-canvas] Export failed:", w);
2765
+ if (c.value) break;
2766
+ c.value = !0, f.exportAsImage().then((I) => {
2767
+ const S = URL.createObjectURL(I), w = document.createElement("a");
2768
+ w.href = S, w.download = "canvas-export.png", w.click(), URL.revokeObjectURL(S);
2769
+ }).catch((I) => {
2770
+ console.warn("[flow-canvas] Export failed:", I);
2771
+ }).finally(() => {
2772
+ c.value = !1;
2572
2773
  });
2573
2774
  break;
2574
2775
  case "select":
2575
- e.editor.setSelectionMode(!e.editor.selectionMode.value);
2776
+ i.editor.setSelectionMode(!i.editor.selectionMode.value);
2576
2777
  break;
2577
- case "search":
2578
2778
  case "auto-layout":
2779
+ i.editor._emitUiEvent({ type: "toolbar.auto-layout" });
2780
+ break;
2781
+ case "search":
2579
2782
  case "minimap":
2580
- console.warn(`[flow-canvas] "${p.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2783
+ console.warn(`[flow-canvas] "${d.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2581
2784
  break;
2582
2785
  default:
2583
- p.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${p.type}". Provide an onClick handler.`);
2786
+ d.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${d.type}". Provide an onClick handler.`);
2584
2787
  break;
2585
2788
  }
2586
2789
  }
2587
- const v = F(() => t.value.filter(l)), f = F(() => {
2588
- const p = /* @__PURE__ */ new Map(), E = [];
2589
- for (const w of v.value) {
2590
- const N = w.group ?? "default";
2591
- p.has(N) || (p.set(N, []), E.push(N)), p.get(N).push(w);
2790
+ const B = j(() => r.value.filter(D)), h = j(() => {
2791
+ const d = /* @__PURE__ */ new Map(), f = [];
2792
+ for (const I of B.value) {
2793
+ const S = I.group ?? "default";
2794
+ d.has(S) || (d.set(S, []), f.push(S)), d.get(S).push(I);
2592
2795
  }
2593
- return E.map((w) => ({ name: w, items: p.get(w) })).filter((w) => w.items.length > 0);
2796
+ return f.map((I) => ({ name: I, items: d.get(I) })).filter((I) => I.items.length > 0);
2594
2797
  });
2595
- return (p, E) => (M(), S("div", lo, [
2596
- (M(!0), S(pe, null, Pe(f.value, (w, N) => (M(), S(pe, {
2597
- key: w.name
2798
+ return (d, f) => (N(), A("div", wo, [
2799
+ (N(!0), A(he, null, xe(h.value, (I, S) => (N(), A(he, {
2800
+ key: I.name
2598
2801
  }, [
2599
- N > 0 ? (M(), S("div", co)) : U("", !0),
2600
- B("div", uo, [
2601
- (M(!0), S(pe, null, Pe(w.items, (m) => (M(), S(pe, {
2602
- key: m.id
2802
+ S > 0 ? (N(), A("div", xo)) : V("", !0),
2803
+ G("div", Co, [
2804
+ (N(!0), A(he, null, xe(I.items, (w) => (N(), A(he, {
2805
+ key: w.id
2603
2806
  }, [
2604
- m.type === "zoom-display" ? (M(), S("span", fo, me(r.value), 1)) : (M(), S("button", {
2807
+ w.type === "zoom-display" ? (N(), A("span", Eo, ce(C.value), 1)) : (N(), A("button", {
2605
2808
  key: 1,
2606
- class: ee(["flow-canvas-toolbar__btn", { "is-disabled": g(m), "is-active": a(m) }]),
2607
- "data-description": m.description,
2608
- disabled: g(m),
2609
- onClick: (D) => d(m)
2809
+ type: "button",
2810
+ class: te(["flow-canvas-toolbar__btn", {
2811
+ "is-disabled": $(w),
2812
+ "is-active": K(w),
2813
+ "is-exporting": w.type === "export" && c.value
2814
+ }]),
2815
+ "data-toolbar-id": w.id,
2816
+ "data-toolbar-type": w.type,
2817
+ disabled: $(w),
2818
+ onClick: (U) => k(w),
2819
+ onMouseenter: (U) => y(U, w),
2820
+ onMouseleave: v
2610
2821
  }, [
2611
- m.component ? (M(), De(dt(m.component), { key: 0 })) : m.icon ? (M(), S("i", {
2822
+ w.component ? (N(), ye(it(w.component), { key: 0 })) : w.icon ? (N(), A("i", {
2612
2823
  key: 1,
2613
- class: ee(m.icon)
2614
- }, null, 2)) : (M(), S("span", {
2824
+ class: te(w.icon)
2825
+ }, null, 2)) : (N(), A("span", {
2615
2826
  key: 2,
2616
2827
  class: "flow-canvas-toolbar__text",
2617
- textContent: me(m.text ?? m.description ?? m.id)
2618
- }, null, 8, go))
2619
- ], 10, po))
2828
+ textContent: ce(w.text ?? w.description ?? w.id)
2829
+ }, null, 8, Io))
2830
+ ], 42, ko))
2620
2831
  ], 64))), 128))
2621
2832
  ])
2622
- ], 64))), 128))
2833
+ ], 64))), 128)),
2834
+ (N(), ye(rt, { to: "body" }, [
2835
+ u.visible ? (N(), A("div", {
2836
+ key: 0,
2837
+ ref_key: "tooltipRef",
2838
+ ref: a,
2839
+ class: "flow-canvas-toolbar-tooltip",
2840
+ style: ve({ left: `${u.x}px`, top: `${u.y}px` })
2841
+ }, [
2842
+ Pe(ce(u.text) + " ", 1),
2843
+ f[0] || (f[0] = G("div", { class: "flow-canvas-toolbar-tooltip__arrow" }, null, -1))
2844
+ ], 4)) : V("", !0)
2845
+ ]))
2623
2846
  ]));
2624
2847
  }
2625
- }), Po = /* @__PURE__ */ he(ho, [["__scopeId", "data-v-51b5c98a"]]), vo = { class: "flow-canvas-default-node__ep-label" }, yo = {
2848
+ }), cn = /* @__PURE__ */ pe(So, [["__scopeId", "data-v-77d4afbb"]]), _o = { class: "flow-canvas-default-node__ep-label" }, No = {
2626
2849
  key: 1,
2627
- class: "flow-canvas-default-node__diamond"
2628
- }, mo = {
2850
+ class: "flow-canvas-default-node__diamond flow-canvas-highlight-target"
2851
+ }, Mo = {
2629
2852
  key: 2,
2630
2853
  class: "flow-canvas-default-node__task-label"
2631
- }, bo = /* @__PURE__ */ ge({
2854
+ }, Do = /* @__PURE__ */ le({
2632
2855
  __name: "default-node",
2633
- setup(s) {
2634
- const t = ct("getNode")?.(), o = F(() => t?.getData?.() ?? null), n = F(() => o.value?.label || o.value?.type || ""), r = {
2856
+ setup(n) {
2857
+ const t = at("getNode")?.(), s = j(() => t?.getData?.() ?? null), o = j(() => s.value?.label || s.value?.type || ""), i = {
2635
2858
  start: "canvas-kaishi",
2636
2859
  end: "canvas-stop",
2637
2860
  "parallel-gateway": "canvas-bingxingwangguan",
2638
2861
  "branch-gateway": "canvas-fenzhiwangguan",
2639
2862
  "converge-gateway": "canvas-huijuwangguan",
2640
2863
  "conditional-parallel-gateway": "canvas-tiaojianbingxingwangguan"
2641
- }, i = /* @__PURE__ */ new Set(["start", "end"]), l = /* @__PURE__ */ new Set([
2864
+ }, r = /* @__PURE__ */ new Set(["start", "end"]), l = /* @__PURE__ */ new Set([
2642
2865
  "parallel-gateway",
2643
2866
  "branch-gateway",
2644
2867
  "converge-gateway",
2645
2868
  "conditional-parallel-gateway"
2646
- ]), a = F(() => {
2647
- const d = o.value?.type ?? "";
2648
- return i.has(d) ? "endpoint" : l.has(d) ? "gateway" : "task";
2649
- }), g = F(() => r[o.value?.type ?? ""] ?? "");
2650
- return (d, v) => (M(), S("div", {
2651
- class: ee(["flow-canvas-default-node", `is-${a.value}`])
2869
+ ]), a = j(() => {
2870
+ const c = s.value?.type ?? "";
2871
+ return r.has(c) ? "endpoint" : l.has(c) ? "gateway" : "task";
2872
+ }), p = j(() => i[s.value?.type ?? ""] ?? "");
2873
+ return (c, g) => (N(), A("div", {
2874
+ class: te(["flow-canvas-default-node", [`is-${a.value}`, { "flow-canvas-highlight-target": a.value !== "gateway" }]])
2652
2875
  }, [
2653
- a.value === "endpoint" ? (M(), S(pe, { key: 0 }, [
2654
- g.value ? (M(), S("i", {
2876
+ a.value === "endpoint" ? (N(), A(he, { key: 0 }, [
2877
+ p.value ? (N(), A("i", {
2655
2878
  key: 0,
2656
- class: ee([["flow-canvas-icon", g.value], "flow-canvas-default-node__ep-icon"])
2657
- }, null, 2)) : U("", !0),
2658
- B("span", vo, me(n.value), 1)
2659
- ], 64)) : a.value === "gateway" ? (M(), S("div", yo, [
2660
- g.value ? (M(), S("i", {
2879
+ class: te([["flow-canvas-icon", p.value], "flow-canvas-default-node__ep-icon"])
2880
+ }, null, 2)) : V("", !0),
2881
+ G("span", _o, ce(o.value), 1)
2882
+ ], 64)) : a.value === "gateway" ? (N(), A("div", No, [
2883
+ p.value ? (N(), A("i", {
2661
2884
  key: 0,
2662
- class: ee([["flow-canvas-icon", g.value], "flow-canvas-default-node__gw-icon"])
2663
- }, null, 2)) : U("", !0)
2664
- ])) : (M(), S("span", mo, me(n.value), 1))
2885
+ class: te([["flow-canvas-icon", p.value], "flow-canvas-default-node__gw-icon"])
2886
+ }, null, 2)) : V("", !0)
2887
+ ])) : (N(), A("span", Mo, ce(o.value), 1))
2665
2888
  ], 2));
2666
2889
  }
2667
- }), wo = /* @__PURE__ */ he(bo, [["__scopeId", "data-v-c88cdae7"]]), xo = {
2890
+ }), Ao = /* @__PURE__ */ pe(Do, [["__scopeId", "data-v-f0e24a9f"]]), Po = {
2668
2891
  start: { label: "开始", icon: "flow-canvas-icon canvas-kaishi", width: 88, height: 40 },
2669
2892
  end: { label: "结束", icon: "flow-canvas-icon canvas-stop", width: 88, height: 40 },
2670
2893
  empty: { label: "空节点", icon: "flow-canvas-icon canvas-jiedi", width: 240, height: 48 },
@@ -2677,11 +2900,11 @@ const lo = { class: "flow-canvas-toolbar" }, co = {
2677
2900
  width: 64,
2678
2901
  height: 64
2679
2902
  }
2680
- }, Ze = (s, e) => ({
2903
+ }, Ve = (n, e) => ({
2681
2904
  stroke: e.hovered ? "#3a84ff" : "#abb5cc",
2682
2905
  strokeWidth: 2
2683
2906
  });
2684
- function Je() {
2907
+ function Xe() {
2685
2908
  return {
2686
2909
  attrs: {
2687
2910
  line: {
@@ -2692,67 +2915,67 @@ function Je() {
2692
2915
  }
2693
2916
  };
2694
2917
  }
2695
- function ko() {
2918
+ function To() {
2696
2919
  return {
2697
2920
  manhattan: {
2698
2921
  router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
2699
2922
  connector: { name: "rounded", args: { radius: 8 } },
2700
- style: Ze,
2701
- x6EdgeConfig: Je()
2923
+ style: Ve,
2924
+ x6EdgeConfig: Xe()
2702
2925
  },
2703
2926
  bezier: {
2704
2927
  connector: { name: "smooth" },
2705
- style: Ze,
2706
- x6EdgeConfig: Je()
2928
+ style: Ve,
2929
+ x6EdgeConfig: Xe()
2707
2930
  }
2708
2931
  };
2709
2932
  }
2710
- function _o(s) {
2711
- const e = s?.nodeTypes ?? xo, t = {}, o = [];
2712
- for (const [i, l] of Object.entries(e)) {
2713
- const a = l.width ?? 150, g = l.height ?? 50;
2714
- t[i] = {
2715
- component: wo,
2716
- getSize: () => ({ width: a, height: g }),
2717
- getPorts: () => nt()
2718
- }, o.push({
2719
- type: i,
2720
- label: l.label ?? i,
2933
+ function un(n) {
2934
+ const e = n?.nodeTypes ?? Po, t = {}, s = [];
2935
+ for (const [r, l] of Object.entries(e)) {
2936
+ const a = l.width ?? 150, p = l.height ?? 50;
2937
+ t[r] = {
2938
+ component: Ao,
2939
+ getSize: () => ({ width: a, height: p }),
2940
+ getPorts: () => et()
2941
+ }, s.push({
2942
+ type: r,
2943
+ label: l.label ?? r,
2721
2944
  icon: l.icon
2722
2945
  });
2723
2946
  }
2724
- const n = {
2725
- ...ko(),
2726
- ...s?.edgeTypes
2727
- }, r = s?.defaultEdgeType ?? "manhattan";
2947
+ const o = {
2948
+ ...To(),
2949
+ ...n?.edgeTypes
2950
+ }, i = n?.defaultEdgeType ?? "manhattan";
2728
2951
  return {
2729
- schema: { nodeTypes: t, defaultEdgeType: r, edgeTypes: n },
2730
- paletteItems: o
2952
+ schema: { nodeTypes: t, defaultEdgeType: i, edgeTypes: o },
2953
+ paletteItems: s
2731
2954
  };
2732
2955
  }
2733
- function Ao(s) {
2956
+ function fn(n) {
2734
2957
  return {
2735
2958
  name: "connection-validator",
2736
2959
  priority: 10,
2737
- transformCommand(e, t, o) {
2738
- for (const n of e.commands) {
2739
- if (n.type !== "edge.add" && n.type !== "edge.reconnect") continue;
2740
- const r = o.flowModel.value, i = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId, l = n.type === "edge.add" ? n.edge.target.nodeId : n.target?.nodeId;
2741
- if (!i || !l) continue;
2742
- const a = r.nodes[i], g = r.nodes[l];
2743
- if (!a || !g) continue;
2744
- const d = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, v = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, f = d ? a.ports?.find((m) => m.id === d) : void 0, p = v ? g.ports?.find((m) => m.id === v) : void 0, E = n.type === "edge.reconnect" ? n.edgeId : void 0, w = Object.values(r.edges).filter((m) => m.id !== E), N = s({
2745
- flowModel: r,
2960
+ transformCommand(e, t, s) {
2961
+ for (const o of e.commands) {
2962
+ if (o.type !== "edge.add" && o.type !== "edge.reconnect") continue;
2963
+ const i = s.flowModel.value, r = o.type === "edge.add" ? o.edge.source.nodeId : o.source?.nodeId, l = o.type === "edge.add" ? o.edge.target.nodeId : o.target?.nodeId;
2964
+ if (!r || !l) continue;
2965
+ const a = i.nodes[r], p = i.nodes[l];
2966
+ if (!a || !p) continue;
2967
+ const c = o.type === "edge.add" ? o.edge.source.portId : o.source?.portId, g = o.type === "edge.add" ? o.edge.target.portId : o.target?.portId, u = c ? a.ports?.find((D) => D.id === c) : void 0, y = g ? p.ports?.find((D) => D.id === g) : void 0, v = o.type === "edge.reconnect" ? o.edgeId : void 0, C = Object.values(i.edges).filter((D) => D.id !== v), M = n({
2968
+ flowModel: i,
2746
2969
  sourceNode: a,
2747
- targetNode: g,
2748
- sourcePort: f,
2749
- targetPort: p,
2750
- existingEdges: w
2970
+ targetNode: p,
2971
+ sourcePort: u,
2972
+ targetPort: y,
2973
+ existingEdges: C
2751
2974
  });
2752
- if (!N.valid)
2975
+ if (!M.valid)
2753
2976
  return {
2754
2977
  rejected: !0,
2755
- reason: N.reason ?? "Connection validation failed",
2978
+ reason: M.reason ?? "Connection validation failed",
2756
2979
  code: "validation_failed"
2757
2980
  };
2758
2981
  }
@@ -2760,138 +2983,458 @@ function Ao(s) {
2760
2983
  }
2761
2984
  };
2762
2985
  }
2763
- function To(s) {
2764
- const { rubberband: e = !0, multiple: t = !0, movable: o = !0 } = s ?? {};
2986
+ function pn(n) {
2987
+ const { rubberband: e = !0, multiple: t = !0, movable: s = !0 } = n ?? {};
2765
2988
  return {
2766
2989
  name: "selection",
2767
2990
  priority: 90,
2768
- async attachRuntime(n) {
2769
- const { Selection: r } = await import("@antv/x6-plugin-selection");
2770
- n.graph.use(
2771
- new r({
2991
+ attachRuntime(o) {
2992
+ o.graph.use(
2993
+ new ut({
2772
2994
  enabled: !0,
2773
2995
  rubberband: e,
2774
2996
  multiple: t,
2775
- movable: o,
2997
+ movable: s,
2998
+ pointerEvents: "none",
2776
2999
  showNodeSelectionBox: !0,
2777
- filter: (i) => !(i.isNode() && (!n.graph.isRubberbandEnabled?.() || (i.getData?.() ?? {})._selectable === !1))
3000
+ filter: (i) => !(i.isNode() && (i.getData?.() ?? {})._selectable === !1)
2778
3001
  })
2779
3002
  );
2780
3003
  }
2781
3004
  };
2782
3005
  }
2783
- function Ro(s) {
2784
- const { tolerance: e = 10, color: t = "#3a84ff" } = s ?? {};
2785
- let o = null;
3006
+ function gn(n) {
3007
+ const { tolerance: e = 10, color: t = "#3a84ff" } = n ?? {};
3008
+ let s = null;
2786
3009
  return {
2787
3010
  name: "snapline",
2788
3011
  priority: 90,
2789
- async attachRuntime(n) {
2790
- const { Snapline: r } = await import("@antv/x6-plugin-snapline");
2791
- n.graph.use(
2792
- new r({
3012
+ async attachRuntime(o) {
3013
+ const { Snapline: i } = await import("@antv/x6-plugin-snapline");
3014
+ o.graph.use(
3015
+ new i({
2793
3016
  enabled: !0,
2794
3017
  tolerance: e,
2795
3018
  className: "flow-canvas-snapline"
2796
3019
  })
2797
- ), o = document.createElement("style"), o.textContent = `.flow-canvas-snapline line { stroke: ${t} !important; }`, document.head.appendChild(o);
3020
+ ), s = document.createElement("style"), s.textContent = `.flow-canvas-snapline line { stroke: ${t} !important; }`, document.head.appendChild(s);
2798
3021
  },
2799
3022
  detachRuntime() {
2800
- o?.remove(), o = null;
3023
+ s?.remove(), s = null;
2801
3024
  }
2802
3025
  };
2803
3026
  }
2804
- function $o(s) {
3027
+ const Ro = { class: "flow-canvas-search-popover__input" }, Lo = ["value", "placeholder"], $o = ["onMouseenter", "onClick"], Oo = { class: "flow-canvas-search-popover__item-label" }, Bo = {
3028
+ key: 0,
3029
+ class: "flow-canvas-search-popover__item-subtitle"
3030
+ }, Ho = {
3031
+ key: 1,
3032
+ class: "flow-canvas-search-popover__empty"
3033
+ }, Go = /* @__PURE__ */ le({
3034
+ __name: "search-popover",
3035
+ props: {
3036
+ open: { type: Boolean },
3037
+ position: {},
3038
+ query: {},
3039
+ results: {},
3040
+ placeholder: { default: "搜索节点名称" },
3041
+ emptyText: { default: "暂无匹配节点" },
3042
+ isAnchorTarget: { type: Function, default: void 0 }
3043
+ },
3044
+ emits: ["update:query", "select", "close"],
3045
+ setup(n, { emit: e }) {
3046
+ const t = n, s = e, o = O(null), i = O(null), r = O(-1);
3047
+ fe(
3048
+ () => t.open,
3049
+ (v) => {
3050
+ v && (r.value = -1, Te(() => {
3051
+ o.value?.focus(), o.value?.select();
3052
+ }));
3053
+ }
3054
+ ), fe(
3055
+ () => t.query,
3056
+ () => {
3057
+ r.value = -1;
3058
+ }
3059
+ ), fe(
3060
+ () => t.results.length,
3061
+ (v) => {
3062
+ if (!v) {
3063
+ r.value = -1;
3064
+ return;
3065
+ }
3066
+ r.value >= v && (r.value = -1);
3067
+ }
3068
+ );
3069
+ function l(v) {
3070
+ s("update:query", v.target.value);
3071
+ }
3072
+ function a(v) {
3073
+ r.value = v;
3074
+ }
3075
+ function p() {
3076
+ r.value = -1;
3077
+ }
3078
+ function c() {
3079
+ s("update:query", ""), Te(() => {
3080
+ o.value?.focus();
3081
+ });
3082
+ }
3083
+ function g() {
3084
+ const v = t.results[r.value] ?? t.results[0];
3085
+ v && s("select", v.id);
3086
+ }
3087
+ function u(v) {
3088
+ if (v.key === "Escape") {
3089
+ v.preventDefault(), s("close");
3090
+ return;
3091
+ }
3092
+ if (v.key === "ArrowDown") {
3093
+ if (v.preventDefault(), !t.results.length) return;
3094
+ r.value = r.value < t.results.length - 1 ? r.value + 1 : 0;
3095
+ return;
3096
+ }
3097
+ if (v.key === "ArrowUp") {
3098
+ if (v.preventDefault(), !t.results.length) return;
3099
+ r.value = r.value > 0 ? r.value - 1 : t.results.length - 1;
3100
+ return;
3101
+ }
3102
+ v.key === "Enter" && (v.preventDefault(), g());
3103
+ }
3104
+ function y(v) {
3105
+ if (!t.open) return;
3106
+ const C = v.target;
3107
+ C && i.value?.contains(C) || t.isAnchorTarget?.(v.target) || s("close");
3108
+ }
3109
+ return Je(() => {
3110
+ document.addEventListener("mousedown", y);
3111
+ }), Se(() => {
3112
+ document.removeEventListener("mousedown", y);
3113
+ }), (v, C) => n.open ? (N(), A("div", {
3114
+ key: 0,
3115
+ ref_key: "panelRef",
3116
+ ref: i,
3117
+ class: "flow-canvas-search-popover",
3118
+ style: ve({ left: `${n.position.x}px`, top: `${n.position.y}px`, width: `${n.position.width}px` })
3119
+ }, [
3120
+ G("div", Ro, [
3121
+ C[1] || (C[1] = G("i", { class: "flow-canvas-icon canvas-search" }, null, -1)),
3122
+ G("input", {
3123
+ ref_key: "inputRef",
3124
+ ref: o,
3125
+ value: n.query,
3126
+ placeholder: n.placeholder,
3127
+ onInput: l,
3128
+ onKeydown: u
3129
+ }, null, 40, Lo),
3130
+ n.query ? (N(), A("button", {
3131
+ key: 0,
3132
+ type: "button",
3133
+ class: "flow-canvas-search-popover__clear",
3134
+ "aria-label": "清空搜索",
3135
+ onClick: c
3136
+ }, [...C[0] || (C[0] = [
3137
+ G("i", { class: "flow-canvas-icon canvas-close-circle-shape" }, null, -1)
3138
+ ])])) : V("", !0)
3139
+ ]),
3140
+ n.results.length ? (N(), A("div", {
3141
+ key: 0,
3142
+ class: "flow-canvas-search-popover__list",
3143
+ onMouseleave: p
3144
+ }, [
3145
+ (N(!0), A(he, null, xe(n.results, (M, D) => (N(), A("button", {
3146
+ key: M.id,
3147
+ type: "button",
3148
+ class: te(["flow-canvas-search-popover__item", { "is-active": D === r.value }]),
3149
+ onMouseenter: (L) => a(D),
3150
+ onClick: (L) => s("select", M.id)
3151
+ }, [
3152
+ G("span", Oo, ce(M.label), 1),
3153
+ M.subtitle ? (N(), A("span", Bo, ce(M.subtitle), 1)) : V("", !0)
3154
+ ], 42, $o))), 128))
3155
+ ], 32)) : (N(), A("div", Ho, ce(n.emptyText), 1))
3156
+ ], 4)) : V("", !0);
3157
+ }
3158
+ }), qo = /* @__PURE__ */ pe(Go, [["__scopeId", "data-v-c80f6b26"]]), Ke = 282, Uo = 4, zo = 300, Fo = 360, Le = 100, jo = Fo * 4 - Le;
3159
+ function Wo(n) {
3160
+ return n !== null;
3161
+ }
3162
+ function Vo(n) {
3163
+ const e = /* @__PURE__ */ new Set();
3164
+ return n.map((t) => t?.trim()).filter((t) => !!t).filter((t) => {
3165
+ const s = t.toLowerCase();
3166
+ return e.has(s) ? !1 : (e.add(s), !0);
3167
+ });
3168
+ }
3169
+ function Xo(n, e) {
3170
+ const t = Math.max(8, window.innerWidth - e - 8);
3171
+ return Math.min(Math.max(8, n), t);
3172
+ }
3173
+ function Ko(n, e) {
3174
+ const t = e?.getNodeMeta?.(n);
3175
+ if (t === null) return null;
3176
+ const s = t?.label?.trim() || n.label?.trim() || n.id, o = t?.subtitle?.trim() || void 0, i = Vo(t?.keywords ?? [n.label, o]);
3177
+ return i.length ? {
3178
+ id: n.id,
3179
+ label: s,
3180
+ subtitle: o,
3181
+ keywords: i
3182
+ } : null;
3183
+ }
3184
+ function hn(n) {
3185
+ let e = null, t = null, s = null, o = null, i = null, r = [];
3186
+ const l = O(!1), a = O(""), p = O({ x: 0, y: 0, width: Ke }), c = j(() => e ? Object.values(e.flowModel.value.nodes).map((k) => Ko(k, n)).filter(Wo) : []), g = j(() => {
3187
+ const k = a.value.trim().toLowerCase(), B = Math.max(1, n?.maxResults ?? zo);
3188
+ return k ? c.value.filter((h) => h.keywords.some((d) => d.toLowerCase().includes(k))).slice(0, B) : c.value.slice(0, B);
3189
+ });
3190
+ function u() {
3191
+ return s?.querySelector('.flow-canvas-toolbar__btn[data-toolbar-type="search"]');
3192
+ }
3193
+ function y() {
3194
+ return u()?.closest(".flow-canvas-toolbar");
3195
+ }
3196
+ function v() {
3197
+ const k = y(), B = s?.getBoundingClientRect(), h = k?.getBoundingClientRect() ?? B;
3198
+ if (!h) return;
3199
+ const d = Math.max(Ke, Math.round(h.width));
3200
+ p.value = {
3201
+ x: Xo(h.left, d),
3202
+ y: h.bottom + Uo,
3203
+ width: d
3204
+ };
3205
+ }
3206
+ function C() {
3207
+ r.forEach((k) => clearTimeout(k)), r = [], t?.api.clearHighlight();
3208
+ }
3209
+ function M(k) {
3210
+ C();
3211
+ const B = setTimeout(() => {
3212
+ t?.api.highlightNodes([k]);
3213
+ }, Le), h = setTimeout(() => {
3214
+ t?.api.clearHighlight(), r = [];
3215
+ }, Le + jo);
3216
+ r.push(B, h);
3217
+ }
3218
+ function D(k) {
3219
+ t && (t.api.scrollToNode(k), M(k));
3220
+ }
3221
+ function L() {
3222
+ t && (l.value = !0, v(), requestAnimationFrame(() => v()));
3223
+ }
3224
+ function H() {
3225
+ l.value = !1, a.value = "";
3226
+ }
3227
+ function K() {
3228
+ if (l.value) {
3229
+ H();
3230
+ return;
3231
+ }
3232
+ L();
3233
+ }
3234
+ function $(k) {
3235
+ const B = u();
3236
+ return !!(B && k instanceof Node && B.contains(k));
3237
+ }
3238
+ function W() {
3239
+ l.value && v();
3240
+ }
3241
+ const F = le({
3242
+ name: "FlowCanvasSearchHost",
3243
+ setup() {
3244
+ return () => Ae(qo, {
3245
+ open: l.value,
3246
+ position: p.value,
3247
+ query: a.value,
3248
+ results: g.value,
3249
+ placeholder: n?.placeholder ?? "搜索节点名称",
3250
+ emptyText: n?.emptyText ?? "暂无匹配节点",
3251
+ isAnchorTarget: $,
3252
+ "onUpdate:query": (k) => {
3253
+ a.value = k;
3254
+ },
3255
+ onSelect: D,
3256
+ onClose: H
3257
+ });
3258
+ }
3259
+ });
3260
+ return {
3261
+ name: "search",
3262
+ priority: 90,
3263
+ install(k) {
3264
+ e = k;
3265
+ },
3266
+ attachRuntime(k) {
3267
+ t = k, s = k.graph.container.closest(".flow-canvas-layout__content") ?? k.graph.container.parentElement, o = document.createElement("div"), o.className = "flow-canvas-search-host", document.body.append(o), i = lt(F), i.mount(o), window.addEventListener("resize", W), window.addEventListener("scroll", W, !0);
3268
+ },
3269
+ detachRuntime() {
3270
+ H(), C(), window.removeEventListener("resize", W), window.removeEventListener("scroll", W, !0), i?.unmount(), i = null, o?.remove(), o = null, s = null, t = null;
3271
+ },
3272
+ dispose() {
3273
+ H(), C(), e = null;
3274
+ },
3275
+ provideToolbarItems() {
3276
+ return [
3277
+ {
3278
+ id: "plugin:search",
3279
+ type: "search",
3280
+ icon: "flow-canvas-icon canvas-search",
3281
+ description: "搜索节点",
3282
+ group: "tools",
3283
+ order: 22,
3284
+ active: () => l.value,
3285
+ onClick: K
3286
+ }
3287
+ ];
3288
+ }
3289
+ };
3290
+ }
3291
+ const Yo = 52, Zo = 16, Qo = 40;
3292
+ function Jo(n) {
3293
+ const e = document.createElement("div");
3294
+ e.className = "flow-canvas-minimap", n.floating !== !1 && e.classList.add("flow-canvas-minimap--floating");
3295
+ const t = document.createElement("div");
3296
+ t.className = "flow-canvas-minimap__host", e.append(t), Object.assign(e.style, {
3297
+ width: `${n.width}px`,
3298
+ height: `${n.height}px`
3299
+ }), n.floating !== !1 && Object.assign(e.style, {
3300
+ top: `${Yo}px`,
3301
+ left: `${Zo}px`
3302
+ });
3303
+ let s = null, o = n.defaultOpen ?? !1, i = null;
3304
+ function r() {
3305
+ !n.onClickOutside || i || (i = (u) => {
3306
+ const y = u.target;
3307
+ y && e.contains(y) || u.target?.closest('[data-toolbar-type="minimap"]') || n.onClickOutside();
3308
+ }, document.addEventListener("mousedown", i));
3309
+ }
3310
+ function l() {
3311
+ i && (document.removeEventListener("mousedown", i), i = null);
3312
+ }
3313
+ function a() {
3314
+ s || (s = new ft({
3315
+ container: t,
3316
+ width: n.width,
3317
+ height: n.height,
3318
+ padding: n.contentPadding ?? Qo,
3319
+ scalable: !1
3320
+ }), n.sourceGraph.use(s));
3321
+ }
3322
+ function p(u) {
3323
+ o = u, e.style.display = o ? "" : "none", o ? (a(), r()) : l();
3324
+ }
3325
+ function c() {
3326
+ p(o), n.mountTarget.appendChild(e);
3327
+ }
3328
+ function g() {
3329
+ l(), s?.dispose(), s = null, e.remove();
3330
+ }
3331
+ return c(), {
3332
+ element: e,
3333
+ isOpen: () => o,
3334
+ setOpen: p,
3335
+ toggle() {
3336
+ const u = !o;
3337
+ return p(u), u;
3338
+ },
3339
+ destroy: g
3340
+ };
3341
+ }
3342
+ function vn(n) {
2805
3343
  let e = null;
3344
+ const t = O(!1);
3345
+ function s(i) {
3346
+ e?.setOpen(i), t.value = i;
3347
+ }
3348
+ function o() {
3349
+ e && (t.value = e.toggle());
3350
+ }
2806
3351
  return {
2807
3352
  name: "minimap",
2808
3353
  priority: 90,
2809
- async attachRuntime(t) {
2810
- if (!s?.container) return;
2811
- e = s.container;
2812
- const { MiniMap: o } = await import("@antv/x6-plugin-minimap");
2813
- t.graph.use(
2814
- new o({
2815
- container: s.container,
2816
- width: s.width ?? 200,
2817
- height: s.height ?? 160
2818
- })
2819
- );
3354
+ attachRuntime(i) {
3355
+ const r = n?.width ?? 334, l = n?.height ?? 180, a = n?.container ?? i.graph.container.closest(".flow-canvas-layout__content") ?? i.graph.container.parentElement;
3356
+ a && (e = Jo({
3357
+ sourceGraph: i.graph,
3358
+ mountTarget: a,
3359
+ width: r,
3360
+ height: l,
3361
+ floating: !n?.container,
3362
+ defaultOpen: !1,
3363
+ onClickOutside: () => s(!1)
3364
+ }), s(!1));
2820
3365
  },
2821
3366
  detachRuntime() {
2822
- e = null;
3367
+ e?.destroy(), e = null, t.value = !1;
2823
3368
  },
2824
3369
  provideToolbarItems() {
2825
3370
  return [
2826
3371
  {
2827
- id: "minimap",
3372
+ id: "plugin:minimap",
2828
3373
  type: "minimap",
2829
- tooltip: "小地图",
2830
- order: 100,
2831
- visible: !!s?.container,
2832
- onClick() {
2833
- if (!e) return;
2834
- const t = e.style.display === "none";
2835
- e.style.display = t ? "" : "none";
2836
- }
3374
+ icon: "flow-canvas-icon canvas-map",
3375
+ description: "缩略图",
3376
+ group: "tools",
3377
+ order: 23,
3378
+ active: () => t.value,
3379
+ onClick: o
2837
3380
  }
2838
3381
  ];
2839
3382
  }
2840
3383
  };
2841
3384
  }
2842
- function Lo() {
2843
- let s = null, e = 0;
3385
+ function yn() {
3386
+ let n = null, e = 0;
2844
3387
  return {
2845
3388
  name: "clipboard",
2846
3389
  priority: 90,
2847
- onKeyboardShortcut(t, o) {
2848
- const n = t.metaKey || t.ctrlKey;
2849
- if (n && t.key === "c") {
2850
- const r = o.graph.getSelectedCells?.() ?? [];
2851
- if (!r.length) return !1;
2852
- const i = o.flowModel.value, l = new Set(r.filter((d) => d.isNode()).map((d) => d.id)), a = [...l].map((d) => i.nodes[d]).filter(Boolean);
3390
+ onKeyboardShortcut(t, s) {
3391
+ const o = t.metaKey || t.ctrlKey;
3392
+ if (o && t.key === "c") {
3393
+ const i = s.graph.getSelectedCells?.() ?? [];
3394
+ if (!i.length) return !1;
3395
+ const r = s.flowModel.value, l = new Set(i.filter((c) => c.isNode()).map((c) => c.id)), a = [...l].map((c) => r.nodes[c]).filter(Boolean);
2853
3396
  if (!a.length) return !1;
2854
- const g = Object.values(i.edges).filter(
2855
- (d) => l.has(d.source.nodeId) && l.has(d.target.nodeId)
3397
+ const p = Object.values(r.edges).filter(
3398
+ (c) => l.has(c.source.nodeId) && l.has(c.target.nodeId)
2856
3399
  );
2857
- return s = { nodes: a, edges: g }, e = 0, !0;
3400
+ return n = { nodes: a, edges: p }, e = 0, !0;
2858
3401
  }
2859
- if (n && t.key === "v") {
2860
- if (!s?.nodes.length) return !1;
3402
+ if (o && t.key === "v") {
3403
+ if (!n?.nodes.length) return !1;
2861
3404
  e++;
2862
- const r = e * 30, i = /* @__PURE__ */ new Map(), l = [];
2863
- for (const a of s.nodes) {
2864
- const g = `${a.id}_cp${W().slice(0, 6)}`;
2865
- i.set(a.id, g), l.push({
3405
+ const i = e * 30, r = /* @__PURE__ */ new Map(), l = [];
3406
+ for (const a of n.nodes) {
3407
+ const p = `${a.id}_cp${Z().slice(0, 6)}`;
3408
+ r.set(a.id, p), l.push({
2866
3409
  type: "node.add",
2867
3410
  node: {
2868
3411
  ...a,
2869
- id: g,
3412
+ id: p,
2870
3413
  position: {
2871
- x: a.position.x + r,
2872
- y: a.position.y + r
3414
+ x: a.position.x + i,
3415
+ y: a.position.y + i
2873
3416
  },
2874
3417
  payload: a.payload ? { ...a.payload } : {},
2875
3418
  extensions: a.extensions ? { ...a.extensions } : void 0
2876
3419
  }
2877
3420
  });
2878
3421
  }
2879
- for (const a of s.edges) {
2880
- const g = i.get(a.source.nodeId), d = i.get(a.target.nodeId);
2881
- !g || !d || l.push({
3422
+ for (const a of n.edges) {
3423
+ const p = r.get(a.source.nodeId), c = r.get(a.target.nodeId);
3424
+ !p || !c || l.push({
2882
3425
  type: "edge.add",
2883
3426
  edge: {
2884
3427
  ...a,
2885
- id: `${a.id}_cp${W().slice(0, 6)}`,
2886
- source: { ...a.source, nodeId: g },
2887
- target: { ...a.target, nodeId: d },
2888
- labels: a.labels?.map((v) => ({ ...v, id: `${v.id}_cp${W().slice(0, 6)}` })),
3428
+ id: `${a.id}_cp${Z().slice(0, 6)}`,
3429
+ source: { ...a.source, nodeId: p },
3430
+ target: { ...a.target, nodeId: c },
3431
+ labels: a.labels?.map((g) => ({ ...g, id: `${g.id}_cp${Z().slice(0, 6)}` })),
2889
3432
  payload: a.payload ? { ...a.payload } : {}
2890
3433
  }
2891
3434
  });
2892
3435
  }
2893
- return l.length && o.executeCommand({
2894
- id: W(),
3436
+ return l.length && s.executeCommand({
3437
+ id: Z(),
2895
3438
  source: "user:keyboard",
2896
3439
  label: "粘贴",
2897
3440
  timestamp: Date.now(),
@@ -2903,26 +3446,27 @@ function Lo() {
2903
3446
  };
2904
3447
  }
2905
3448
  export {
2906
- ne as CanvasConstraintError,
2907
- Do as CanvasLayout,
2908
- eo as CanvasNodePalette,
2909
- So as CanvasRuntime,
3449
+ ae as CanvasConstraintError,
3450
+ dn as CanvasLayout,
3451
+ fo as CanvasNodePalette,
3452
+ ln as CanvasRuntime,
2910
3453
  pt as CanvasSchemaError,
2911
- Po as CanvasToolbar,
2912
- wo as DefaultNode,
2913
- Ft as NodeActionsToolbar,
2914
- Wt as NodeQuickAddPopover,
2915
- Ge as applyCanvasCommand,
2916
- Lo as clipboardPlugin,
2917
- Ao as connectionValidatorPlugin,
2918
- ko as createBuiltinEdgeTypes,
2919
- Nt as createCanvasHistory,
2920
- _o as createDefaultSchema,
2921
- ao as createDefaultToolbarItems,
2922
- Mo as createEmptyFlowModel,
2923
- W as generateId,
2924
- $o as minimapPlugin,
2925
- To as selectionPlugin,
2926
- Ro as snaplinePlugin,
2927
- No as useCanvasEditor
3454
+ cn as CanvasToolbar,
3455
+ Ao as DefaultNode,
3456
+ Zt as NodeActionsToolbar,
3457
+ to as NodeQuickAddPopover,
3458
+ Re as applyCanvasCommand,
3459
+ yn as clipboardPlugin,
3460
+ fn as connectionValidatorPlugin,
3461
+ To as createBuiltinEdgeTypes,
3462
+ _t as createCanvasHistory,
3463
+ un as createDefaultSchema,
3464
+ bo as createDefaultToolbarItems,
3465
+ rn as createEmptyFlowModel,
3466
+ Z as generateId,
3467
+ vn as minimapPlugin,
3468
+ hn as searchPlugin,
3469
+ pn as selectionPlugin,
3470
+ gn as snaplinePlugin,
3471
+ an as useCanvasEditor
2928
3472
  };