@blueking/flow-canvas 0.0.1-beta.1 → 0.0.1-beta.2

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,6 +1,6 @@
1
- import { ref as B, computed as z, onScopeDispose as ze, defineComponent as ie, onBeforeUnmount as Ne, createElementBlock as M, openBlock as C, normalizeStyle as we, createElementVNode as $, createVNode as Oe, createCommentVNode as O, normalizeClass as Q, Transition as je, withCtx as De, withModifiers as qe, createTextVNode as Ae, renderSlot as ce, onMounted as Ge, watch as de, createBlock as be, Fragment as se, renderList as ge, toDisplayString as ue, unref as le, resolveDynamicComponent as Ve, inject as We } from "vue";
2
- import { Graph as Qe } from "@antv/x6";
3
- import { register as Xe } from "@antv/x6-vue-shape";
1
+ import { ref as z, computed as j, onScopeDispose as Le, defineComponent as re, onBeforeUnmount as Se, createElementBlock as S, openBlock as k, normalizeStyle as me, createElementVNode as A, createVNode as Be, createCommentVNode as H, normalizeClass as W, Transition as ze, withCtx as Ne, withModifiers as He, createTextVNode as De, renderSlot as fe, onMounted as Fe, watch as le, createBlock as ve, Fragment as ie, renderList as ye, toDisplayString as de, unref as Ue, resolveDynamicComponent as qe, inject as Ge } from "vue";
2
+ import { Graph as Ve } from "@antv/x6";
3
+ import { register as We } from "@antv/x6-vue-shape";
4
4
  function io() {
5
5
  return {
6
6
  version: "1.0",
@@ -13,12 +13,12 @@ class K extends Error {
13
13
  super(e), this.name = "CanvasConstraintError";
14
14
  }
15
15
  }
16
- class Ye extends Error {
16
+ class Qe extends Error {
17
17
  constructor(e) {
18
18
  super(e), this.name = "CanvasSchemaError";
19
19
  }
20
20
  }
21
- function xe(s, e, t) {
21
+ function be(s, e, t) {
22
22
  if (e.length === 0) {
23
23
  if (t === void 0) return;
24
24
  if (typeof t != "object" || t === null || Array.isArray(t))
@@ -28,99 +28,99 @@ function xe(s, e, t) {
28
28
  const o = s ? { ...s } : {};
29
29
  let n = o;
30
30
  for (let r = 0; r < e.length - 1; r++) {
31
- const a = e[r], l = n[a];
32
- l && typeof l == "object" && !Array.isArray(l) ? n[a] = { ...l } : n[a] = {}, n = n[a];
31
+ const l = e[r], a = n[l];
32
+ a && typeof a == "object" && !Array.isArray(a) ? n[l] = { ...a } : n[l] = {}, n = n[l];
33
33
  }
34
34
  const i = e[e.length - 1];
35
35
  return t === void 0 ? delete n[i] : n[i] = t, o;
36
36
  }
37
- function Se(s, e) {
37
+ function Me(s, e) {
38
38
  switch (e.type) {
39
39
  case "node.add":
40
- return Ke(s, e.node);
40
+ return Xe(s, e.node);
41
41
  case "node.move":
42
- return Ze(s, e.nodeId, e.position);
42
+ return Ke(s, e.nodeId, e.position);
43
43
  case "node.remove":
44
- return Je(s, e.nodeId);
44
+ return Ye(s, e.nodeId);
45
45
  case "node.update":
46
- return et(s, e.nodeId, e.patch);
46
+ return Ze(s, e.nodeId, e.patch);
47
47
  case "node.set-payload":
48
- return tt(s, e.nodeId, e.path, e.value);
48
+ return Je(s, e.nodeId, e.path, e.value);
49
49
  case "node.set-extensions":
50
- return ot(s, e.nodeId, e.path, e.value);
50
+ return et(s, e.nodeId, e.path, e.value);
51
51
  case "edge.add":
52
- return nt(s, e.edge);
52
+ return tt(s, e.edge);
53
53
  case "edge.remove":
54
- return st(s, e.edgeId);
54
+ return ot(s, e.edgeId);
55
55
  case "edge.reconnect":
56
- return it(s, e.edgeId, e.source, e.target);
56
+ return nt(s, e.edgeId, e.source, e.target);
57
57
  case "edge.update":
58
- return rt(s, e.edgeId, e.patch);
58
+ return st(s, e.edgeId, e.patch);
59
59
  case "edge.set-payload":
60
- return at(s, e.edgeId, e.path, e.value);
60
+ return it(s, e.edgeId, e.path, e.value);
61
61
  case "edge.label.update":
62
- return lt(s, e.edgeId, e.labelId, e.patch);
62
+ return rt(s, e.edgeId, e.labelId, e.patch);
63
63
  case "model.set-meta":
64
- return dt(s, e.path, e.value);
64
+ return at(s, e.path, e.value);
65
65
  default:
66
66
  throw new K(`Unknown command type: ${e.type}`);
67
67
  }
68
68
  }
69
- function he(s, e) {
69
+ function pe(s, e) {
70
70
  const t = s.nodes[e];
71
71
  if (!t) throw new K(`Node "${e}" does not exist`);
72
72
  return t;
73
73
  }
74
- function ve(s, e) {
74
+ function ge(s, e) {
75
75
  const t = s.edges[e];
76
76
  if (!t) throw new K(`Edge "${e}" does not exist`);
77
77
  return t;
78
78
  }
79
- function fe(s, e, t) {
79
+ function ce(s, e, t) {
80
80
  const o = s.nodes[e.nodeId];
81
81
  if (!o)
82
82
  throw new K(`${t} node "${e.nodeId}" does not exist`);
83
83
  if (e.portId && o.ports && !o.ports.some((i) => i.id === e.portId))
84
84
  throw new K(`${t} port "${e.portId}" not found on node "${e.nodeId}"`);
85
85
  }
86
- function ke(s, e, t) {
86
+ function we(s, e, t) {
87
87
  return { ...s, nodes: { ...s.nodes, [e]: t } };
88
88
  }
89
- function Ce(s, e, t) {
89
+ function xe(s, e, t) {
90
90
  return { ...s, edges: { ...s.edges, [e]: t } };
91
91
  }
92
- function Ke(s, e) {
92
+ function Xe(s, e) {
93
93
  if (s.nodes[e.id])
94
94
  throw new K(`Node id "${e.id}" already exists`);
95
95
  return { ...s, nodes: { ...s.nodes, [e.id]: e } };
96
96
  }
97
- function Ze(s, e, t) {
98
- const o = he(s, e);
99
- return ke(s, e, { ...o, position: t });
97
+ function Ke(s, e, t) {
98
+ const o = pe(s, e);
99
+ return we(s, e, { ...o, position: t });
100
100
  }
101
- function Je(s, e) {
102
- he(s, e);
101
+ function Ye(s, e) {
102
+ pe(s, e);
103
103
  const { [e]: t, ...o } = s.nodes, n = {};
104
104
  for (const [i, r] of Object.entries(s.edges))
105
105
  r.source.nodeId !== e && r.target.nodeId !== e && (n[i] = r);
106
106
  return { ...s, nodes: o, edges: n };
107
107
  }
108
- function et(s, e, t) {
109
- const o = he(s, e);
110
- return ke(s, e, { ...o, ...t, id: o.id });
108
+ function Ze(s, e, t) {
109
+ const o = pe(s, e);
110
+ return we(s, e, { ...o, ...t, id: o.id });
111
111
  }
112
- function tt(s, e, t, o) {
113
- const n = he(s, e), i = xe(n.payload, t, o);
114
- return ke(s, e, { ...n, payload: i });
112
+ function Je(s, e, t, o) {
113
+ const n = pe(s, e), i = be(n.payload, t, o);
114
+ return we(s, e, { ...n, payload: i });
115
115
  }
116
- function ot(s, e, t, o) {
117
- const n = he(s, e), i = xe(n.extensions, t, o);
118
- return ke(s, e, { ...n, extensions: i });
116
+ function et(s, e, t, o) {
117
+ const n = pe(s, e), i = be(n.extensions, t, o);
118
+ return we(s, e, { ...n, extensions: i });
119
119
  }
120
- function nt(s, e) {
120
+ function tt(s, e) {
121
121
  if (s.edges[e.id])
122
122
  throw new K(`Edge id "${e.id}" already exists`);
123
- if (fe(s, e.source, "Source"), fe(s, e.target, "Target"), e.labels) {
123
+ if (ce(s, e.source, "Source"), ce(s, e.target, "Target"), e.labels) {
124
124
  const t = /* @__PURE__ */ new Set();
125
125
  for (const o of e.labels) {
126
126
  if (t.has(o.id))
@@ -130,93 +130,93 @@ function nt(s, e) {
130
130
  }
131
131
  return { ...s, edges: { ...s.edges, [e.id]: e } };
132
132
  }
133
- function st(s, e) {
134
- ve(s, e);
133
+ function ot(s, e) {
134
+ ge(s, e);
135
135
  const { [e]: t, ...o } = s.edges;
136
136
  return { ...s, edges: o };
137
137
  }
138
- function it(s, e, t, o) {
139
- const n = ve(s, e), i = t ?? n.source, r = o ?? n.target;
140
- return fe(s, i, "Source"), fe(s, r, "Target"), Ce(s, e, { ...n, source: i, target: r });
138
+ function nt(s, e, t, o) {
139
+ const n = ge(s, e), i = t ?? n.source, r = o ?? n.target;
140
+ return ce(s, i, "Source"), ce(s, r, "Target"), xe(s, e, { ...n, source: i, target: r });
141
141
  }
142
- function rt(s, e, t) {
143
- const o = ve(s, e), n = { ...o, ...t, id: o.id };
144
- return t.source && fe(s, n.source, "Source"), t.target && fe(s, n.target, "Target"), Ce(s, e, n);
142
+ function st(s, e, t) {
143
+ const o = ge(s, e), n = { ...o, ...t, id: o.id };
144
+ return t.source && ce(s, n.source, "Source"), t.target && ce(s, n.target, "Target"), xe(s, e, n);
145
145
  }
146
- function at(s, e, t, o) {
147
- const n = ve(s, e), i = xe(n.payload, t, o);
148
- return Ce(s, e, { ...n, payload: i });
146
+ function it(s, e, t, o) {
147
+ const n = ge(s, e), i = be(n.payload, t, o);
148
+ return xe(s, e, { ...n, payload: i });
149
149
  }
150
- function lt(s, e, t, o) {
151
- const n = ve(s, e);
150
+ function rt(s, e, t, o) {
151
+ const n = ge(s, e);
152
152
  if (!n.labels)
153
153
  throw new K(`Edge "${e}" has no labels`);
154
- const i = n.labels.findIndex((a) => a.id === t);
154
+ const i = n.labels.findIndex((l) => l.id === t);
155
155
  if (i === -1)
156
156
  throw new K(`Label "${t}" not found in edge "${e}"`);
157
157
  const r = [...n.labels];
158
- return r[i] = { ...r[i], ...o, id: t }, Ce(s, e, { ...n, labels: r });
158
+ return r[i] = { ...r[i], ...o, id: t }, xe(s, e, { ...n, labels: r });
159
159
  }
160
- function dt(s, e, t) {
161
- const o = xe(s.meta, e, t);
160
+ function at(s, e, t) {
161
+ const o = be(s.meta, e, t);
162
162
  return { ...s, meta: o };
163
163
  }
164
- function ct(s, e) {
165
- const t = e?.maxHistorySize ?? 100, o = B(s), n = [], i = [], r = B(!1), a = B(!1);
166
- function l() {
167
- r.value = n.length > 0, a.value = i.length > 0;
164
+ function lt(s, e) {
165
+ const t = e?.maxHistorySize ?? 100, o = z(s), n = [], i = [], r = z(!1), l = z(!1);
166
+ function a() {
167
+ r.value = n.length > 0, l.value = i.length > 0;
168
168
  }
169
169
  function c(b) {
170
- const m = o.value;
171
- let p = m;
172
- for (const P of b.commands)
173
- p = Se(p, P);
174
- return n.push({ snapshot: m, envelope: b }), n.length > t && n.shift(), i.length = 0, o.value = p, l(), p;
170
+ const y = o.value;
171
+ let m = y;
172
+ for (const R of b.commands)
173
+ m = Me(m, R);
174
+ return n.push({ snapshot: y, envelope: b }), n.length > t && n.shift(), i.length = 0, o.value = m, a(), m;
175
175
  }
176
- function u() {
176
+ function d() {
177
177
  const b = n.pop();
178
- return b ? (i.push({ snapshot: o.value, envelope: b.envelope }), o.value = b.snapshot, l(), b.snapshot) : null;
178
+ return b ? (i.push({ snapshot: o.value, envelope: b.envelope }), o.value = b.snapshot, a(), b.snapshot) : null;
179
179
  }
180
- function d() {
180
+ function g() {
181
181
  const b = i.pop();
182
182
  if (!b) return null;
183
183
  n.push({ snapshot: o.value, envelope: b.envelope });
184
- let m = o.value;
185
- for (const p of b.envelope.commands)
186
- m = Se(m, p);
187
- return o.value = m, l(), m;
184
+ let y = o.value;
185
+ for (const m of b.envelope.commands)
186
+ y = Me(y, m);
187
+ return o.value = y, a(), y;
188
188
  }
189
- function w() {
190
- n.length = 0, i.length = 0, l();
189
+ function p() {
190
+ n.length = 0, i.length = 0, a();
191
191
  }
192
- function f() {
192
+ function u() {
193
193
  return o.value;
194
194
  }
195
- function E(b) {
196
- o.value = b, w();
195
+ function N(b) {
196
+ o.value = b, p();
197
197
  }
198
198
  return {
199
199
  currentFlowModel: o,
200
200
  execute: c,
201
- undo: u,
202
- redo: d,
201
+ undo: d,
202
+ redo: g,
203
203
  canUndo: r,
204
- canRedo: a,
204
+ canRedo: l,
205
205
  get undoStack() {
206
206
  return n.map((b) => b.envelope);
207
207
  },
208
208
  get redoStack() {
209
209
  return i.map((b) => b.envelope);
210
210
  },
211
- clear: w,
212
- createSnapshot: f,
213
- replaceFlowModel: E
211
+ clear: p,
212
+ createSnapshot: u,
213
+ replaceFlowModel: N
214
214
  };
215
215
  }
216
- function ut(s) {
216
+ function dt(s) {
217
217
  return s !== null && typeof s == "object" && s.rejected === !0;
218
218
  }
219
- class ft {
219
+ class ct {
220
220
  plugins = [];
221
221
  editorContext = null;
222
222
  runtimeCtx = null;
@@ -251,12 +251,12 @@ class ft {
251
251
  */
252
252
  createSafeRuntimeContext(e, t) {
253
253
  const o = this, n = new Proxy(e.graph, {
254
- get(i, r, a) {
255
- const l = Reflect.get(i, r, a);
256
- return r === "use" && typeof l == "function" ? function(...u) {
254
+ get(i, r, l) {
255
+ const a = Reflect.get(i, r, l);
256
+ return r === "use" && typeof a == "function" ? function(...d) {
257
257
  if (o.runtimeVersion === t)
258
- return l.apply(i, u);
259
- } : l;
258
+ return a.apply(i, d);
259
+ } : a;
260
260
  }
261
261
  });
262
262
  return { ...e, graph: n };
@@ -281,7 +281,7 @@ class ft {
281
281
  source: o.name
282
282
  }
283
283
  };
284
- if (ut(i))
284
+ if (dt(i))
285
285
  return {
286
286
  rejected: !0,
287
287
  error: {
@@ -374,42 +374,42 @@ class ft {
374
374
  const n = o ?? e.commands;
375
375
  let i = t.flowModel.value;
376
376
  for (const r of n)
377
- i = Se(i, r);
377
+ i = Me(i, r);
378
378
  return i;
379
379
  }
380
380
  };
381
381
  }
382
382
  }
383
383
  function ro(s) {
384
- const { initialFlowModel: e, schema: t, plugins: o = [], historyOptions: n } = s, i = ct(e, n), r = B(s.mode ?? "edit"), a = B(!1), l = B(null), c = B([]), u = {}, d = new ft();
385
- function w(m, p, P, g = "user:toolbar") {
384
+ const { schema: e, plugins: t = [], historyOptions: o } = s, n = { version: "1.0", ...s.initialFlowModel }, i = lt(n, o), r = z(s.mode ?? "edit"), l = z(!1), a = z(null), c = z([]), d = {}, g = new ct();
385
+ function p(y, m, R, h = "user:toolbar") {
386
386
  const v = {
387
387
  id: `history-${Date.now()}`,
388
- source: g,
389
- label: m,
388
+ source: h,
389
+ label: y,
390
390
  timestamp: Date.now(),
391
391
  commands: []
392
392
  };
393
- d.afterCommand(v, p, P), c.value = d.collectToolbarItems(), s.onCommandResult?.({
393
+ g.afterCommand(v, m, R), c.value = g.collectToolbarItems(), s.onCommandResult?.({
394
394
  status: "applied",
395
395
  envelope: v,
396
- flowModel: P
396
+ flowModel: R
397
397
  }), s.onFlowModelChange?.({
398
- flowModel: P,
399
- prevFlowModel: p,
398
+ flowModel: R,
399
+ prevFlowModel: m,
400
400
  envelope: v,
401
- source: g
401
+ source: h
402
402
  });
403
403
  }
404
- const f = {
404
+ const u = {
405
405
  execute: i.execute,
406
406
  undo() {
407
- const m = i.currentFlowModel.value, p = i.undo();
408
- return p && w("撤销", m, p), p;
407
+ const y = i.currentFlowModel.value, m = i.undo();
408
+ return m && p("撤销", y, m), m;
409
409
  },
410
410
  redo() {
411
- const m = i.currentFlowModel.value, p = i.redo();
412
- return p && w("重做", m, p), p;
411
+ const y = i.currentFlowModel.value, m = i.redo();
412
+ return m && p("重做", y, m), m;
413
413
  },
414
414
  get canUndo() {
415
415
  return i.canUndo;
@@ -425,82 +425,82 @@ function ro(s) {
425
425
  },
426
426
  clear: i.clear,
427
427
  createSnapshot: i.createSnapshot,
428
- replaceFlowModel(m) {
429
- const p = i.currentFlowModel.value;
430
- i.replaceFlowModel(m), w("替换 FlowModel", p, m, "system:replace");
431
- }
432
- }, E = {
433
- flowModel: z(() => i.currentFlowModel.value),
434
- history: f,
435
- schema: t,
428
+ replaceFlowModel(y) {
429
+ const m = i.currentFlowModel.value;
430
+ i.replaceFlowModel(y), p("替换 FlowModel", m, y, "system:replace");
431
+ }
432
+ }, N = {
433
+ flowModel: j(() => i.currentFlowModel.value),
434
+ history: u,
435
+ schema: e,
436
436
  mode: r,
437
437
  executeCommand: b,
438
- replaceFlowModel(m) {
439
- f.replaceFlowModel(m);
438
+ replaceFlowModel(y) {
439
+ u.replaceFlowModel(y);
440
440
  },
441
- setMode(m) {
442
- r.value = m;
441
+ setMode(y) {
442
+ r.value = y;
443
443
  },
444
- selectionMode: a,
445
- setSelectionMode(m) {
446
- a.value = m;
444
+ selectionMode: l,
445
+ setSelectionMode(y) {
446
+ l.value = y;
447
447
  },
448
- api: l,
448
+ api: a,
449
449
  toolbarItems: c,
450
- extendedApi: u,
451
- _pluginManager: d
450
+ extendedApi: d,
451
+ _pluginManager: g
452
452
  };
453
- d.install(o, {
454
- flowModel: E.flowModel,
455
- history: f,
456
- schema: t,
453
+ g.install(t, {
454
+ flowModel: N.flowModel,
455
+ history: u,
456
+ schema: e,
457
457
  mode: r,
458
458
  executeCommand: b
459
- }), c.value = d.collectToolbarItems(), ze(() => {
460
- d.dispose();
459
+ }), c.value = g.collectToolbarItems(), Le(() => {
460
+ g.dispose();
461
461
  });
462
- function b(m) {
463
- const p = d.transformCommand(m);
464
- if ("rejected" in p) {
462
+ function b(y) {
463
+ const m = g.transformCommand(y);
464
+ if ("rejected" in m) {
465
465
  const v = {
466
466
  status: "rejected",
467
- envelope: m,
468
- error: p.error
467
+ envelope: y,
468
+ error: m.error
469
469
  };
470
470
  return s.onCommandResult?.(v), v;
471
471
  }
472
- const P = p.envelope, g = i.currentFlowModel.value;
472
+ const R = m.envelope, h = i.currentFlowModel.value;
473
473
  try {
474
- const v = i.execute(P), N = {
474
+ const v = i.execute(R), I = {
475
475
  status: "applied",
476
- envelope: P,
476
+ envelope: R,
477
477
  flowModel: v
478
478
  };
479
- return d.afterCommand(P, g, v), c.value = d.collectToolbarItems(), s.onCommandResult?.(N), s.onFlowModelChange?.({
479
+ return g.afterCommand(R, h, v), c.value = g.collectToolbarItems(), s.onCommandResult?.(I), s.onFlowModelChange?.({
480
480
  flowModel: v,
481
- prevFlowModel: g,
482
- envelope: P,
483
- source: P.source
484
- }), N;
481
+ prevFlowModel: h,
482
+ envelope: R,
483
+ source: R.source
484
+ }), I;
485
485
  } catch (v) {
486
486
  if (v instanceof K) {
487
- const N = {
487
+ const I = {
488
488
  status: "invalid",
489
- envelope: P,
489
+ envelope: R,
490
490
  error: {
491
491
  code: "constraint_violated",
492
492
  reason: v.message,
493
493
  source: "engine"
494
494
  }
495
495
  };
496
- return s.onCommandResult?.(N), N;
496
+ return s.onCommandResult?.(I), I;
497
497
  }
498
498
  throw v;
499
499
  }
500
500
  }
501
- return E;
501
+ return N;
502
502
  }
503
- class pt {
503
+ class ut {
504
504
  graph;
505
505
  schema;
506
506
  shapeRegistry;
@@ -586,11 +586,11 @@ class pt {
586
586
  for (const [o, n] of Object.entries(e.nodes)) {
587
587
  const i = this.schema.nodeTypes[n.type];
588
588
  if (!i)
589
- throw new Ye(
589
+ throw new Qe(
590
590
  `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.`
591
591
  );
592
- const r = this.shapeRegistry.registerNodeType(n.type, i.component), a = i.getSize(n), l = i.getPorts?.(n) ?? n.ports ?? [];
593
- t.set(o, { model: n, definition: i, shapeName: r, size: a, ports: l });
592
+ const r = this.shapeRegistry.registerNodeType(n.type, i.component), l = i.getSize(n), a = i.getPorts?.(n) ?? n.ports ?? [];
593
+ t.set(o, { model: n, definition: i, shapeName: r, size: l, ports: a });
594
594
  }
595
595
  return t;
596
596
  }
@@ -615,10 +615,10 @@ class pt {
615
615
  }
616
616
  }
617
617
  updateExistingNode(e, t) {
618
- const { model: o, size: n, ports: i, definition: r } = t, a = e.getPosition();
619
- (a.x !== o.position.x || a.y !== o.position.y) && e.setPosition(o.position.x, o.position.y);
620
- const l = e.getSize();
621
- (l.width !== n.width || l.height !== n.height) && e.setSize(n.width, n.height, { silent: !0 }), this.syncNodePorts(e, i), e.setData({ ...o }, { silent: !0 }), this.applyNodeBehavior(e, o, r), this.applyNodeHighlightAndDecoration(e, o);
618
+ const { model: o, size: n, ports: i, definition: r } = t, l = e.getPosition();
619
+ (l.x !== o.position.x || l.y !== o.position.y) && e.setPosition(o.position.x, o.position.y);
620
+ const a = e.getSize();
621
+ (a.width !== n.width || a.height !== n.height) && e.setSize(n.width, n.height, { silent: !0 }), this.syncNodePorts(e, i), e.setData({ ...o }), this.applyNodeBehavior(e, o, r), this.applyNodeHighlightAndDecoration(e, o);
622
622
  }
623
623
  syncNodePorts(e, t) {
624
624
  const o = e.getPorts(), n = new Set(t.map((r) => r.id)), i = new Set(o.map((r) => r.id));
@@ -628,7 +628,7 @@ class pt {
628
628
  i.has(r.id) || e.addPort({ id: r.id, group: r.group, ...r.x6PortConfig });
629
629
  }
630
630
  addNewNode(e, t) {
631
- const { model: o, shapeName: n, size: i, ports: r, definition: a } = t, l = {
631
+ const { model: o, shapeName: n, size: i, ports: r, definition: l } = t, a = {
632
632
  id: o.id,
633
633
  shape: n,
634
634
  x: o.position.x,
@@ -663,13 +663,13 @@ class pt {
663
663
  }
664
664
  }
665
665
  },
666
- items: r.map((u) => ({ id: u.id, group: u.group, ...u.x6PortConfig }))
666
+ items: r.map((d) => ({ id: d.id, group: d.group, ...d.x6PortConfig }))
667
667
  },
668
- ...a.x6CellConfig
668
+ ...l.x6CellConfig
669
669
  };
670
- this.graph.addNode(l), this.knownNodeIds.add(e), this.saveNodeDefaultAttrs(e, a);
670
+ this.graph.addNode(a), this.knownNodeIds.add(e), this.saveNodeDefaultAttrs(e, l);
671
671
  const c = this.graph.getCellById(e);
672
- c && (this.applyNodeBehavior(c, o, a), this.applyNodeHighlightAndDecoration(c, o));
672
+ c && (this.applyNodeBehavior(c, o, l), this.applyNodeHighlightAndDecoration(c, o));
673
673
  }
674
674
  /**
675
675
  * 将 schema 定义的 getBehavior 映射到 X6 节点属性。
@@ -686,14 +686,14 @@ class pt {
686
686
  if (!n) return;
687
687
  const i = o.getBehavior(t, n);
688
688
  if (i.draggable !== void 0 && e.setProp("draggable", i.draggable, { silent: !0 }), i.connectable !== void 0) {
689
- const a = i.connectable;
690
- for (const l of e.getPorts())
691
- e.setPortProp(l.id, "attrs/circle/magnet", a, { silent: !0 });
689
+ const l = i.connectable;
690
+ for (const a of e.getPorts())
691
+ e.setPortProp(a.id, "attrs/circle/magnet", l, { silent: !0 });
692
692
  }
693
693
  if (i.showPorts !== void 0) {
694
- const a = i.showPorts;
695
- for (const l of e.getPorts())
696
- e.setPortProp(l.id, "attrs/circle/style/visibility", a ? "visible" : "hidden", { silent: !0 });
694
+ const l = i.showPorts;
695
+ for (const a of e.getPorts())
696
+ e.setPortProp(a.id, "attrs/circle/style/visibility", l ? "visible" : "hidden", { silent: !0 });
697
697
  }
698
698
  const r = e.getData() ?? {};
699
699
  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 });
@@ -706,8 +706,8 @@ class pt {
706
706
  i && this.graph.removeCell(i), this.knownEdgeIds.delete(n), this.defaultHighlightedEdgeIds.delete(n), this.prevEdgeDecorationClasses.delete(n), this.prevEdgeDecorationColors.delete(n), this.prevEdgeStyleIds.delete(n), this.edgeDefaultAttrs.delete(n);
707
707
  }
708
708
  for (const [n, i] of e) {
709
- const r = this.graph.getCellById(n), { model: a, definition: l } = i;
710
- r ? (this.updateExistingEdge(r, a, l, t), this.knownEdgeIds.has(n) || (this.knownEdgeIds.add(n), this.saveEdgeDefaultAttrs(n, l))) : this.addNewEdge(n, a, l);
709
+ const r = this.graph.getCellById(n), { model: l, definition: a } = i;
710
+ r ? (this.updateExistingEdge(r, l, a, t), this.knownEdgeIds.has(n) || (this.knownEdgeIds.add(n), this.saveEdgeDefaultAttrs(n, a))) : this.addNewEdge(n, l, a);
711
711
  }
712
712
  }
713
713
  /**
@@ -718,12 +718,12 @@ class pt {
718
718
  updateExistingEdge(e, t, o, n) {
719
719
  const i = e.getSource(), r = e.getTarget();
720
720
  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 }), o?.router) {
721
- const a = typeof o.router == "string" ? { name: o.router } : o.router;
722
- e.setRouter(a);
721
+ const l = typeof o.router == "string" ? { name: o.router } : o.router;
722
+ e.setRouter(l);
723
723
  }
724
724
  if (o?.connector) {
725
- const a = typeof o.connector == "string" ? { name: o.connector } : o.connector;
726
- e.setConnector(a);
725
+ const l = typeof o.connector == "string" ? { name: o.connector } : o.connector;
726
+ e.setConnector(l);
727
727
  }
728
728
  this.syncEdgeMarker(e, o, "sourceMarker"), this.syncEdgeMarker(e, o, "targetMarker"), this.syncEdgeLabels(e, t), e.setData({ ...t }, { silent: !0 }), this.applyEdgeStyleAndDecoration(e, t, o);
729
729
  }
@@ -793,8 +793,8 @@ class pt {
793
793
  applyNodeHighlightAndDecoration(e, t) {
794
794
  const o = this.highlightedNodeIds.has(e.id), n = this.resolveNodeDecoration?.(t), i = this.prevNodeDecorationClasses.get(e.id);
795
795
  i && (this.graph.findViewByCell(e)?.container?.classList.remove(i), this.prevNodeDecorationClasses.delete(e.id)), n?.className && (this.graph.findViewByCell(e)?.container?.classList.add(n.className), this.prevNodeDecorationClasses.set(e.id, n.className));
796
- const r = n?.borderColor, l = r ?? (o ? "#3a84ff" : void 0), c = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
797
- l ? (e.setAttrByPath("body/stroke", l), e.setAttrByPath("body/strokeWidth", 2)) : c && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !r ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
796
+ const r = n?.borderColor, a = r ?? (o ? "#3a84ff" : void 0), c = this.prevNodeDecorationColors.has(e.id) || this.defaultHighlightedNodeIds.has(e.id);
797
+ a ? (e.setAttrByPath("body/stroke", a), e.setAttrByPath("body/strokeWidth", 2)) : c && (this.restoreNodeAttr(e, "body/stroke", "stroke"), this.restoreNodeAttr(e, "body/strokeWidth", "strokeWidth")), r ? this.prevNodeDecorationColors.add(e.id) : this.prevNodeDecorationColors.delete(e.id), o && !r ? this.defaultHighlightedNodeIds.add(e.id) : this.defaultHighlightedNodeIds.delete(e.id);
798
798
  }
799
799
  setHoveredEdge(e) {
800
800
  this.hoveredEdgeId = e;
@@ -819,22 +819,22 @@ class pt {
819
819
  applyEdgeStyleAndDecoration(e, t, o) {
820
820
  const n = this.highlightedEdgeIds.has(e.id), i = this.resolveEdgeDecoration?.(t), r = this.prevEdgeDecorationClasses.get(e.id);
821
821
  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));
822
- let a, l, c;
822
+ let l, a, c;
823
823
  if (o?.style) {
824
- const E = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, m = o.style(t, { selected: E, highlighted: n, hovered: b });
825
- a = m.stroke, l = m.strokeWidth, c = m.strokeDasharray;
824
+ const N = this.graph.isSelected?.(e) ?? !1, b = this.hoveredEdgeId === e.id, y = o.style(t, { selected: N, highlighted: n, hovered: b });
825
+ l = y.stroke, a = y.strokeWidth, c = y.strokeDasharray;
826
826
  }
827
- const u = !o?.style && n ? "#3a84ff" : void 0, d = i?.strokeColor, w = d ?? a ?? u, f = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
828
- w ? e.setAttrByPath("line/stroke", w) : f && this.restoreEdgeAttr(e, "line/stroke", "stroke"), o?.style ? (this.prevEdgeStyleIds.add(e.id), l ? e.setAttrByPath("line/strokeWidth", l) : this.restoreEdgeAttr(e, "line/strokeWidth", "strokeWidth"), c ? e.setAttrByPath("line/strokeDasharray", c) : 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)), d ? this.prevEdgeDecorationColors.add(e.id) : this.prevEdgeDecorationColors.delete(e.id), u ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
827
+ const d = !o?.style && n ? "#3a84ff" : void 0, g = i?.strokeColor, p = g ?? l ?? d, u = !!o?.style || this.prevEdgeDecorationColors.has(e.id) || this.defaultHighlightedEdgeIds.has(e.id) || this.prevEdgeStyleIds.has(e.id);
828
+ p ? e.setAttrByPath("line/stroke", p) : u && 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"), c ? e.setAttrByPath("line/strokeDasharray", c) : 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), d ? this.defaultHighlightedEdgeIds.add(e.id) : this.defaultHighlightedEdgeIds.delete(e.id);
829
829
  }
830
830
  }
831
- let gt = 0;
832
- function L() {
831
+ let ft = 0;
832
+ function T() {
833
833
  const s = Date.now().toString(36), e = Math.random().toString(36).substring(2, 8);
834
- return `${s}-${e}-${++gt}`;
834
+ return `${s}-${e}-${++ft}`;
835
835
  }
836
- class ht {
837
- instanceId = L();
836
+ class pt {
837
+ instanceId = T();
838
838
  registeredShapes = /* @__PURE__ */ new Map();
839
839
  getShapeName(e) {
840
840
  let t = this.registeredShapes.get(e);
@@ -842,7 +842,7 @@ class ht {
842
842
  }
843
843
  registerNodeType(e, t) {
844
844
  const o = this.getShapeName(e);
845
- return Xe({
845
+ return We({
846
846
  shape: o,
847
847
  component: t,
848
848
  width: 100,
@@ -853,7 +853,7 @@ class ht {
853
853
  this.registeredShapes.clear();
854
854
  }
855
855
  }
856
- class vt {
856
+ class gt {
857
857
  graph;
858
858
  onUiEvent;
859
859
  onCommand;
@@ -880,11 +880,11 @@ class vt {
880
880
  }), this.on("edge:click", ({ edge: e, e: t }) => {
881
881
  const n = t.target?.closest?.(".x6-edge-label");
882
882
  if (n) {
883
- const r = e.getData?.()?.labels ?? [], a = n.parentElement?.querySelectorAll(".x6-edge-label"), l = a ? Array.from(a).indexOf(n) : 0, c = r[Math.max(0, l)];
883
+ const r = e.getData?.()?.labels ?? [], l = n.parentElement?.querySelectorAll(".x6-edge-label"), a = l ? Array.from(l).indexOf(n) : 0, c = r[Math.max(0, a)];
884
884
  this.onUiEvent({
885
885
  type: "edge.label.click",
886
886
  edgeId: e.id,
887
- labelId: c?.id ?? `label-${l}`
887
+ labelId: c?.id ?? `label-${a}`
888
888
  });
889
889
  return;
890
890
  }
@@ -900,7 +900,7 @@ class vt {
900
900
  }), this.on("node:moved", ({ node: e }) => {
901
901
  const t = e.getPosition();
902
902
  this.onCommand({
903
- id: L(),
903
+ id: T(),
904
904
  source: "user:drag",
905
905
  label: "移动节点",
906
906
  timestamp: Date.now(),
@@ -909,9 +909,9 @@ class vt {
909
909
  }), this.on("edge:connected", ({ edge: e, isNew: t }) => {
910
910
  const o = e.getSourceCell(), n = e.getTargetCell();
911
911
  if (!o || !n) return;
912
- const i = e.getSourcePortId(), r = e.getTargetPortId(), a = e.id in this.flowModelRef.value.edges;
913
- t && !a ? this.onCommand({
914
- id: L(),
912
+ const i = e.getSourcePortId(), r = e.getTargetPortId(), l = e.id in this.flowModelRef.value.edges;
913
+ t && !l ? this.onCommand({
914
+ id: T(),
915
915
  source: "user:drag",
916
916
  label: "连线",
917
917
  timestamp: Date.now(),
@@ -926,7 +926,7 @@ class vt {
926
926
  }
927
927
  ]
928
928
  }) : this.onCommand({
929
- id: L(),
929
+ id: T(),
930
930
  source: "user:drag",
931
931
  label: "重连",
932
932
  timestamp: Date.now(),
@@ -944,18 +944,18 @@ class vt {
944
944
  if (!n.length || !t?.length) return;
945
945
  const i = [];
946
946
  for (let r = 0; r < Math.min(n.length, t.length); r++) {
947
- const a = t[r], l = n[r];
948
- if (!l?.id) continue;
949
- const c = typeof a.position == "object" ? a.position?.distance : a.position;
947
+ const l = t[r], a = n[r];
948
+ if (!a?.id) continue;
949
+ const c = typeof l.position == "object" ? l.position?.distance : l.position;
950
950
  c != null && i.push({
951
951
  type: "edge.label.update",
952
952
  edgeId: e.id,
953
- labelId: l.id,
953
+ labelId: a.id,
954
954
  patch: { position: c }
955
955
  });
956
956
  }
957
957
  i.length && this.onCommand({
958
- id: L(),
958
+ id: T(),
959
959
  source: "user:drag",
960
960
  label: "拖动标签",
961
961
  timestamp: Date.now(),
@@ -967,31 +967,19 @@ class vt {
967
967
  this.graph.on(e, t), this.disposers.push(() => this.graph.off(e, t));
968
968
  }
969
969
  }
970
- function yt(s, e) {
971
- const t = B(null);
972
- function o(i) {
973
- const r = s.getCellById(i);
974
- if (!r || !r.isNode()) return null;
975
- const a = r, l = a.getPosition(), c = a.getSize(), u = { x: l.x, y: l.y, width: c.width, height: c.height }, d = s.localToGraph(u);
976
- return new DOMRect(d.x, d.y, d.width, d.height);
977
- }
978
- function n(i, r) {
979
- const a = s.getCellById(i);
980
- if (!a || !a.isNode()) return null;
981
- const l = a, c = l.getData() ?? {}, u = c.type, f = ((u ? e.nodeTypes[u] : void 0)?.getOverlayAnchors?.(c) ?? {})[r], E = f && typeof f == "object" && "x" in f ? f : void 0, b = l.getPosition(), m = b.x + (E?.x ?? 0), p = b.y + (E?.y ?? 0), P = s.localToGraph({ x: m, y: p });
982
- return {
983
- x: P.x,
984
- y: P.y
985
- };
970
+ function ht(s) {
971
+ function e(t) {
972
+ const o = s.getCellById(t);
973
+ if (!o || !o.isNode()) return null;
974
+ const n = o, i = n.getPosition(), r = n.getSize(), l = { x: i.x, y: i.y, width: r.width, height: r.height }, a = s.localToGraph(l);
975
+ return new DOMRect(a.x, a.y, a.width, a.height);
986
976
  }
987
977
  return {
988
- overlayContainer: t,
989
- getNodeScreenRect: o,
990
- getAnchorScreenPosition: n
978
+ getNodeScreenRect: e
991
979
  };
992
980
  }
993
- const mt = 100;
994
- function bt({
981
+ const vt = 100;
982
+ function yt({
995
983
  graph: s,
996
984
  overlayManager: e,
997
985
  executeCommand: t,
@@ -999,66 +987,66 @@ function bt({
999
987
  flowModel: n,
1000
988
  defaultInsertGap: i,
1001
989
  getContextMenuItems: r,
1002
- onHighlightChange: a,
1003
- resolveNodeShape: l
990
+ onHighlightChange: l,
991
+ resolveNodeShape: a
1004
992
  }) {
1005
- let c = [], u = [], d = null, w = !1, f = null, E = !1;
993
+ let c = [], d = [], g = null, p = !1, u = null, N = !1;
1006
994
  async function b() {
1007
- if (w) return d;
1008
- w = !0;
995
+ if (p) return g;
996
+ p = !0;
1009
997
  try {
1010
- const g = await import("./index-BAAMFT_J.js"), v = g.Dnd ?? g.default;
1011
- return v ? (d = new v({
998
+ const h = await import("./index-BAAMFT_J.js"), v = h.Dnd ?? h.default;
999
+ return v ? (g = new v({
1012
1000
  target: s,
1013
1001
  scaled: !0,
1014
1002
  animation: !0,
1015
- getDragNode: (N) => N.clone(),
1016
- getDropNode: (N) => N.clone()
1017
- }), d) : null;
1003
+ getDragNode: (I) => I.clone(),
1004
+ getDropNode: (I) => I.clone()
1005
+ }), g) : null;
1018
1006
  } catch {
1019
1007
  return console.warn("[flow-canvas] @antv/x6-plugin-dnd not available, add it to your dependencies"), null;
1020
1008
  }
1021
1009
  }
1022
- async function m() {
1023
- if (!E) {
1024
- E = !0;
1010
+ async function y() {
1011
+ if (!N) {
1012
+ N = !0;
1025
1013
  try {
1026
- const g = await import("./index-siYsjzl4.js"), v = g.Export ?? g.default;
1014
+ const h = await import("./index-siYsjzl4.js"), v = h.Export ?? h.default;
1027
1015
  v && s.use(new v());
1028
1016
  } catch {
1029
1017
  console.warn("[flow-canvas] @antv/x6-plugin-export not available, add it to your dependencies");
1030
1018
  }
1031
1019
  }
1032
1020
  }
1033
- const p = ({ node: g }) => {
1034
- const v = g.getData?.();
1035
- if (!v?._dndSessionId || v._dndSessionId !== f) return;
1036
- f = null;
1037
- const N = g.getPosition();
1038
- s.removeNode(g.id);
1039
- const { _dndSessionId: U, ...S } = v, I = S.id || L();
1021
+ const m = ({ node: h }) => {
1022
+ const v = h.getData?.();
1023
+ if (!v?._dndSessionId || v._dndSessionId !== u) return;
1024
+ u = null;
1025
+ const I = h.getPosition();
1026
+ s.removeNode(h.id);
1027
+ const { _dndSessionId: L, ...D } = v, C = D.id || T();
1040
1028
  t({
1041
- id: L(),
1029
+ id: T(),
1042
1030
  source: "user:drag",
1043
1031
  label: "拖入节点",
1044
1032
  timestamp: Date.now(),
1045
1033
  commands: [
1046
1034
  {
1047
1035
  type: "node.add",
1048
- node: { ...S, id: I, position: { x: N.x, y: N.y } }
1036
+ node: { ...D, id: C, position: { x: I.x, y: I.y } }
1049
1037
  }
1050
1038
  ]
1051
1039
  });
1052
1040
  };
1053
- return s.on("node:added", p), {
1041
+ return s.on("node:added", m), {
1054
1042
  zoomIn() {
1055
1043
  s.zoom(0.1);
1056
1044
  },
1057
1045
  zoomOut() {
1058
1046
  s.zoom(-0.1);
1059
1047
  },
1060
- zoomTo(g) {
1061
- s.zoomTo(g);
1048
+ zoomTo(h) {
1049
+ s.zoomTo(h);
1062
1050
  },
1063
1051
  zoomToFit() {
1064
1052
  s.zoomToFit({ padding: 40, maxScale: 1.5 });
@@ -1072,218 +1060,224 @@ function bt({
1072
1060
  scrollToOrigin() {
1073
1061
  s.translate(0, 0);
1074
1062
  },
1075
- scrollToNode(g) {
1076
- const v = s.getCellById(g);
1063
+ scrollToNode(h) {
1064
+ const v = s.getCellById(h);
1077
1065
  v && s.centerCell(v);
1078
1066
  },
1079
1067
  getSelection() {
1080
- const g = s.getSelectedCells?.() ?? [];
1068
+ const h = s.getSelectedCells?.() ?? [];
1081
1069
  return {
1082
- nodeIds: g.filter((v) => v.isNode()).map((v) => v.id),
1083
- edgeIds: g.filter((v) => v.isEdge()).map((v) => v.id)
1070
+ nodeIds: h.filter((v) => v.isNode()).map((v) => v.id),
1071
+ edgeIds: h.filter((v) => v.isEdge()).map((v) => v.id)
1084
1072
  };
1085
1073
  },
1086
- selectNodes(g) {
1087
- const v = g.map((N) => s.getCellById(N)).filter(Boolean);
1074
+ selectNodes(h) {
1075
+ const v = h.map((I) => s.getCellById(I)).filter(Boolean);
1088
1076
  s.select?.(v);
1089
1077
  },
1090
- selectEdges(g) {
1091
- const v = g.map((N) => s.getCellById(N)).filter(Boolean);
1078
+ selectEdges(h) {
1079
+ const v = h.map((I) => s.getCellById(I)).filter(Boolean);
1092
1080
  s.select?.(v);
1093
1081
  },
1094
1082
  clearSelection() {
1095
- const g = s.getSelectedCells?.();
1096
- g?.length && s.unselect?.(g);
1083
+ const h = s.getSelectedCells?.();
1084
+ h?.length && s.unselect?.(h);
1097
1085
  },
1098
- registerDndSource(g, v) {
1099
- const N = async (U) => {
1100
- const S = await b();
1101
- if (!S) return;
1102
- const I = L();
1103
- f = I;
1104
- const j = v(), q = l?.(j.type), Y = s.createNode({
1105
- width: q?.width ?? 154,
1106
- height: q?.height ?? 54,
1107
- shape: q?.shapeName ?? "rect",
1108
- data: { ...j, _dndSessionId: I }
1086
+ registerDndSource(h, v) {
1087
+ const I = async (L) => {
1088
+ const D = await b();
1089
+ if (!D) return;
1090
+ const C = T();
1091
+ u = C;
1092
+ const F = v(), Y = a?.(F.type), q = s.createNode({
1093
+ width: Y?.width ?? 154,
1094
+ height: Y?.height ?? 54,
1095
+ shape: Y?.shapeName ?? "rect",
1096
+ data: { ...F, _dndSessionId: C }
1109
1097
  });
1110
- S.start(Y, U);
1098
+ D.start(q, L);
1111
1099
  };
1112
- return g.addEventListener("mousedown", N), () => {
1113
- g.removeEventListener("mousedown", N);
1100
+ return h.addEventListener("mousedown", I), () => {
1101
+ h.removeEventListener("mousedown", I);
1114
1102
  };
1115
1103
  },
1116
1104
  /**
1117
1105
  * 通过编程方式发起连线:直接命中真实 port 元素,
1118
1106
  * 复用 X6 原生的连线拖拽流程与 connecting.createEdge 配置。
1119
1107
  */
1120
- startConnection(g, v) {
1121
- const N = s.getCellById(g);
1122
- if (!N?.isNode()) return;
1123
- const U = N, S = s.findViewByCell(U);
1124
- if (!S) return;
1125
- const I = S.findPortElem(v, "circle") ?? S.findPortElem(v);
1126
- if (!I) return;
1127
- const q = (I.matches?.("[magnet]") ? I : I.querySelector?.("[magnet]")) ?? I, Y = q.getBoundingClientRect(), oe = Y.left + Y.width / 2, Z = Y.top + Y.height / 2, X = new MouseEvent("mousedown", {
1128
- clientX: oe,
1129
- clientY: Z,
1108
+ startConnection(h, v) {
1109
+ const I = s.getCellById(h);
1110
+ if (!I?.isNode()) return;
1111
+ const L = I, D = s.findViewByCell(L);
1112
+ if (!D) return;
1113
+ const C = D.findPortElem(v, "circle") ?? D.findPortElem(v);
1114
+ if (!C) return;
1115
+ const Y = (C.matches?.("[magnet]") ? C : C.querySelector?.("[magnet]")) ?? C, q = Y.getBoundingClientRect(), Q = q.left + q.width / 2, X = q.top + q.height / 2, G = new MouseEvent("mousedown", {
1116
+ clientX: Q,
1117
+ clientY: X,
1130
1118
  button: 0,
1131
1119
  buttons: 1,
1132
1120
  bubbles: !0,
1133
1121
  cancelable: !0
1134
1122
  });
1135
- q.dispatchEvent(X);
1123
+ Y.dispatchEvent(G);
1136
1124
  },
1137
- async exportAsImage(g) {
1138
- await m();
1125
+ async exportAsImage(h) {
1126
+ await y();
1139
1127
  const v = s;
1140
- return typeof v.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((N) => {
1128
+ return typeof v.toPNG != "function" ? (console.warn("[flow-canvas] exportAsImage requires @antv/x6-plugin-export, add it to your dependencies"), new Blob()) : new Promise((I) => {
1141
1129
  v.toPNG(
1142
- (U) => {
1143
- fetch(U).then((S) => S.blob()).then(N).catch(() => N(new Blob()));
1130
+ (L) => {
1131
+ fetch(L).then((D) => D.blob()).then(I).catch(() => I(new Blob()));
1144
1132
  },
1145
1133
  {
1146
- backgroundColor: g?.backgroundColor ?? "#ffffff",
1147
- padding: g?.padding ?? 20,
1148
- quality: g?.quality,
1134
+ backgroundColor: h?.backgroundColor ?? "#ffffff",
1135
+ padding: h?.padding ?? 20,
1136
+ quality: h?.quality,
1149
1137
  copyStyles: !0
1150
1138
  }
1151
1139
  );
1152
1140
  });
1153
1141
  },
1154
1142
  async exportAsSVG() {
1155
- await m();
1156
- const g = s;
1157
- return typeof g.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((v) => {
1158
- g.toSVG((N) => v(N));
1143
+ await y();
1144
+ const h = s;
1145
+ return typeof h.toSVG != "function" ? (console.warn("[flow-canvas] exportAsSVG requires @antv/x6-plugin-export, add it to your dependencies"), "") : new Promise((v) => {
1146
+ h.toSVG((I) => v(I));
1159
1147
  });
1160
1148
  },
1161
- highlightNodes(g) {
1162
- c = g, a?.(c, u);
1149
+ highlightNodes(h) {
1150
+ c = h, l?.(c, d);
1163
1151
  },
1164
- highlightEdges(g) {
1165
- u = g, a?.(c, u);
1152
+ highlightEdges(h) {
1153
+ d = h, l?.(c, d);
1166
1154
  },
1167
1155
  clearHighlight() {
1168
- c = [], u = [], a?.([], []);
1156
+ c = [], d = [], l?.([], []);
1169
1157
  },
1170
1158
  overlay: e,
1171
- getContextMenuItems(g) {
1172
- return r?.(g) ?? [];
1159
+ getContextMenuItems(h) {
1160
+ return r?.(h) ?? [];
1173
1161
  },
1174
- insertNodeToRight(g, v, N) {
1175
- const U = n.value, S = U.nodes[g];
1176
- if (!S)
1162
+ insertNodeToRight(h, v, I) {
1163
+ const L = n.value, D = L.nodes[h];
1164
+ if (!D)
1177
1165
  return {
1178
1166
  status: "invalid",
1179
1167
  envelope: { id: "", source: "user:toolbar", timestamp: Date.now(), commands: [] },
1180
- error: { code: "constraint_violated", reason: `Source node "${g}" not found`, source: "api" }
1168
+ error: { code: "constraint_violated", reason: `Source node "${h}" not found`, source: "api" }
1181
1169
  };
1182
- const I = N?.gap ?? i ?? mt, j = o.nodeTypes[S.type], q = o.nodeTypes[v.type], Y = j?.getSize(S) ?? { width: 154, height: 54 }, oe = q?.getSize({ ...v, position: { x: 0, y: 0 } }) ?? {
1170
+ const C = I?.gap ?? i ?? vt, F = o.nodeTypes[D.type], Y = o.nodeTypes[v.type], q = F?.getSize(D) ?? { width: 154, height: 54 }, Q = Y?.getSize({ ...v, position: { x: 0, y: 0 } }) ?? {
1183
1171
  width: 154,
1184
1172
  height: 54
1185
- }, Z = {
1186
- x: S.position.x + Y.width + I,
1187
- y: S.position.y + (Y.height - oe.height) / 2
1188
- }, X = v.id || L(), ee = { ...v, id: X, position: Z }, V = [{ type: "node.add", node: ee }], pe = oe.width + I, ne = { x: Z.x, y: Z.y, width: oe.width, height: oe.height };
1189
- for (const [J, G] of Object.entries(U.nodes)) {
1190
- if (J === g || J === X) continue;
1191
- const te = o.nodeTypes[G.type]?.getSize(G) ?? { width: 154, height: 54 }, H = ne.x < G.position.x + te.width && ne.x + ne.width > G.position.x, Ie = ne.y < G.position.y + te.height && ne.y + ne.height > G.position.y;
1192
- H && Ie && V.push({
1173
+ }, X = {
1174
+ x: D.position.x + q.width + C,
1175
+ y: D.position.y + (q.height - Q.height) / 2
1176
+ }, G = v.id || T(), se = { ...v, id: G, position: X }, ee = [{ type: "node.add", node: se }], ke = Q.width + C, te = { x: X.x, y: X.y, width: Q.width, height: Q.height };
1177
+ for (const [Z, V] of Object.entries(L.nodes)) {
1178
+ if (Z === h || Z === G) continue;
1179
+ const oe = o.nodeTypes[V.type]?.getSize(V) ?? { width: 154, height: 54 }, U = te.x < V.position.x + oe.width && te.x + te.width > V.position.x, x = te.y < V.position.y + oe.height && te.y + te.height > V.position.y;
1180
+ U && x && ee.push({
1193
1181
  type: "node.move",
1194
- nodeId: J,
1195
- position: { x: G.position.x + pe, y: G.position.y }
1182
+ nodeId: Z,
1183
+ position: { x: V.position.x + ke, y: V.position.y }
1196
1184
  });
1197
1185
  }
1198
- if (N?.autoWireEdges) {
1199
- const J = S.ports?.find((H) => H.group === "right"), G = ee.ports?.find((H) => H.group === "left"), ye = ee.ports?.find((H) => H.group === "right"), te = J ? Object.values(U.edges).find(
1200
- (H) => H.source.nodeId === g && H.source.portId === J.id
1201
- ) : Object.values(U.edges).find((H) => H.source.nodeId === g);
1202
- if (te) {
1203
- const H = te.target;
1204
- V.push({ type: "edge.remove", edgeId: te.id }), V.push({
1186
+ if (I?.autoWireEdges) {
1187
+ const Z = D.ports?.find((U) => U.group === "right"), V = se.ports?.find((U) => U.group === "left"), ue = se.ports?.find((U) => U.group === "right"), oe = Z ? Object.values(L.edges).find(
1188
+ (U) => U.source.nodeId === h && U.source.portId === Z.id
1189
+ ) : Object.values(L.edges).find((U) => U.source.nodeId === h);
1190
+ if (oe) {
1191
+ const U = oe.target;
1192
+ ee.push({ type: "edge.remove", edgeId: oe.id }), ee.push({
1205
1193
  type: "edge.add",
1206
1194
  edge: {
1207
- id: L(),
1208
- source: { nodeId: g, portId: J?.id },
1209
- target: { nodeId: X, portId: G?.id }
1195
+ id: T(),
1196
+ source: { nodeId: h, portId: Z?.id },
1197
+ target: { nodeId: G, portId: V?.id }
1210
1198
  }
1211
- }), V.push({
1199
+ }), ee.push({
1212
1200
  type: "edge.add",
1213
1201
  edge: {
1214
- id: L(),
1215
- source: { nodeId: X, portId: ye?.id },
1216
- target: H
1202
+ id: T(),
1203
+ source: { nodeId: G, portId: ue?.id },
1204
+ target: U
1217
1205
  }
1218
1206
  });
1219
1207
  } else
1220
- V.push({
1208
+ ee.push({
1221
1209
  type: "edge.add",
1222
1210
  edge: {
1223
- id: L(),
1224
- source: { nodeId: g, portId: J?.id },
1225
- target: { nodeId: X, portId: G?.id }
1211
+ id: T(),
1212
+ source: { nodeId: h, portId: Z?.id },
1213
+ target: { nodeId: G, portId: V?.id }
1226
1214
  }
1227
1215
  });
1228
1216
  }
1229
- const Ee = {
1230
- id: L(),
1231
- source: N?.source ?? "user:toolbar",
1232
- label: N?.label ?? "插入节点",
1217
+ const he = {
1218
+ id: T(),
1219
+ source: I?.source ?? "user:toolbar",
1220
+ label: I?.label ?? "插入节点",
1233
1221
  timestamp: Date.now(),
1234
- commands: V
1222
+ commands: ee
1235
1223
  };
1236
- return t(Ee);
1224
+ return t(he);
1237
1225
  },
1238
- onGraphEvent(g, v) {
1239
- return s.on(g, v), () => s.off(g, v);
1226
+ onGraphEvent(h, v) {
1227
+ return s.on(h, v), () => s.off(h, v);
1240
1228
  },
1241
1229
  unsafeGetGraph() {
1242
1230
  return s;
1243
1231
  }
1244
1232
  };
1245
1233
  }
1246
- function wt() {
1247
- const s = B(null), e = B(!1);
1248
- let t = null;
1249
- function o(a) {
1250
- t && (clearTimeout(t), t = null), s.value = a;
1251
- }
1252
- function n() {
1253
- t = setTimeout(() => {
1234
+ function mt() {
1235
+ const s = z(null), e = z(!1);
1236
+ let t = null, o = !1;
1237
+ function n(d) {
1238
+ t && (clearTimeout(t), t = null), s.value = d;
1239
+ }
1240
+ function i(d = 100) {
1241
+ o || (t && clearTimeout(t), t = setTimeout(() => {
1254
1242
  s.value = null, t = null;
1255
- }, 100);
1243
+ }, d));
1256
1244
  }
1257
- function i() {
1245
+ function r() {
1246
+ o = !0, t && (clearTimeout(t), t = null);
1247
+ }
1248
+ function l(d = 100) {
1249
+ o = !1, i(d);
1250
+ }
1251
+ function a() {
1258
1252
  t && (clearTimeout(t), t = null);
1259
1253
  }
1260
- function r() {
1254
+ function c() {
1261
1255
  t && clearTimeout(t);
1262
1256
  }
1263
- return { hoveredNodeId: s, isDraggingNode: e, enter: o, leave: n, cancelLeave: i, cleanup: r };
1257
+ return { hoveredNodeId: s, isDraggingNode: e, enter: n, leave: i, enterOverlay: r, leaveOverlay: l, cancelLeave: a, cleanup: c };
1264
1258
  }
1265
- const Pe = 10;
1266
- function Te(s, e) {
1259
+ const _e = 10;
1260
+ function Pe(s, e) {
1267
1261
  const t = s.getTotalLength();
1268
1262
  if (t === 0) return { ...e, length: 0, totalLength: 0 };
1269
1263
  let o = s.getPointAtLength(0), n = 1 / 0;
1270
1264
  const i = 50, r = t / i;
1271
- let a = 0;
1272
- for (let d = 0; d <= i; d++) {
1273
- const w = d * r, f = s.getPointAtLength(w), E = (f.x - e.x) ** 2 + (f.y - e.y) ** 2;
1274
- E < n && (n = E, o = f, a = w);
1265
+ let l = 0;
1266
+ for (let g = 0; g <= i; g++) {
1267
+ const p = g * r, u = s.getPointAtLength(p), N = (u.x - e.x) ** 2 + (u.y - e.y) ** 2;
1268
+ N < n && (n = N, o = u, l = p);
1275
1269
  }
1276
- const l = Math.max(0, a - r), c = Math.min(t, a + r), u = (c - l) / 20;
1277
- for (let d = l; d <= c; d += u) {
1278
- const w = s.getPointAtLength(d), f = (w.x - e.x) ** 2 + (w.y - e.y) ** 2;
1279
- f < n && (n = f, o = w, a = d);
1270
+ const a = Math.max(0, l - r), c = Math.min(t, l + r), d = (c - a) / 20;
1271
+ for (let g = a; g <= c; g += d) {
1272
+ const p = s.getPointAtLength(g), u = (p.x - e.x) ** 2 + (p.y - e.y) ** 2;
1273
+ u < n && (n = u, o = p, l = g);
1280
1274
  }
1281
- return { x: o.x, y: o.y, length: a, totalLength: t };
1275
+ return { x: o.x, y: o.y, length: l, totalLength: t };
1282
1276
  }
1283
- function Re(s, e) {
1284
- return s < Pe || s > e - Pe;
1277
+ function Ae(s, e) {
1278
+ return s < _e || s > e - _e;
1285
1279
  }
1286
- function $e() {
1280
+ function Te() {
1287
1281
  const s = "http://www.w3.org/2000/svg", e = document.createElementNS(s, "g");
1288
1282
  e.setAttribute("class", "flow-canvas-edge-delete-tool"), e.style.cursor = "pointer";
1289
1283
  const t = document.createElementNS(s, "rect");
@@ -1291,73 +1285,73 @@ function $e() {
1291
1285
  const o = document.createElementNS(s, "text");
1292
1286
  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;
1293
1287
  }
1294
- function xt(s) {
1288
+ function bt(s) {
1295
1289
  let e = null, t = null;
1296
- function o(a, l) {
1297
- i(), t = a;
1298
- const c = s.getCellById(a);
1290
+ function o(l, a) {
1291
+ i(), t = l;
1292
+ const c = s.getCellById(l);
1299
1293
  if (!c?.isEdge()) return;
1300
- const u = s.findViewByCell(c);
1301
- if (!u) return;
1302
- const d = u.container.querySelector("path");
1294
+ const d = s.findViewByCell(c);
1303
1295
  if (!d) return;
1304
- const w = s.clientToLocal(l.clientX, l.clientY), f = Te(d, w);
1305
- if (Re(f.length, f.totalLength)) return;
1306
- const E = $e();
1307
- E.setAttribute("transform", `translate(${f.x}, ${f.y})`), u.container.appendChild(E), e = E;
1308
- }
1309
- function n(a) {
1296
+ const g = d.container.querySelector("path");
1297
+ if (!g) return;
1298
+ const p = s.clientToLocal(a.clientX, a.clientY), u = Pe(g, p);
1299
+ if (Ae(u.length, u.totalLength)) return;
1300
+ const N = Te();
1301
+ N.setAttribute("transform", `translate(${u.x}, ${u.y})`), d.container.appendChild(N), e = N;
1302
+ }
1303
+ function n(l) {
1310
1304
  if (!t) return;
1311
- const l = s.getCellById(t);
1312
- if (!l?.isEdge()) return;
1313
- const c = s.findViewByCell(l);
1305
+ const a = s.getCellById(t);
1306
+ if (!a?.isEdge()) return;
1307
+ const c = s.findViewByCell(a);
1314
1308
  if (!c) return;
1315
- const u = c.container.querySelector("path");
1316
- if (!u) return;
1317
- const d = s.clientToLocal(a.clientX, a.clientY), w = Te(u, d);
1318
- if (Re(w.length, w.totalLength))
1309
+ const d = c.container.querySelector("path");
1310
+ if (!d) return;
1311
+ const g = s.clientToLocal(l.clientX, l.clientY), p = Pe(d, g);
1312
+ if (Ae(p.length, p.totalLength))
1319
1313
  e && e.setAttribute("display", "none");
1320
1314
  else if (e)
1321
- e.removeAttribute("display"), e.setAttribute("transform", `translate(${w.x}, ${w.y})`);
1315
+ e.removeAttribute("display"), e.setAttribute("transform", `translate(${p.x}, ${p.y})`);
1322
1316
  else {
1323
- const f = $e();
1324
- f.setAttribute("transform", `translate(${w.x}, ${w.y})`), c.container.appendChild(f), e = f;
1317
+ const u = Te();
1318
+ u.setAttribute("transform", `translate(${p.x}, ${p.y})`), c.container.appendChild(u), e = u;
1325
1319
  }
1326
1320
  }
1327
1321
  function i() {
1328
1322
  e && (e.remove(), e = null), t = null;
1329
1323
  }
1330
- function r(a) {
1331
- a === t && (e = null, t = null);
1324
+ function r(l) {
1325
+ l === t && (e = null, t = null);
1332
1326
  }
1333
1327
  return { show: o, move: n, remove: i, handleEdgeRemoved: r };
1334
1328
  }
1335
- function kt(s) {
1329
+ function wt(s) {
1336
1330
  let e = null, t = 0;
1337
- function o(u) {
1338
- const d = u ? "visible" : "hidden";
1339
- for (const w of s.getNodes())
1340
- for (const f of w.getPorts())
1341
- w.setPortProp(f.id, "attrs/circle/visibility", d);
1331
+ function o(d) {
1332
+ const g = d ? "visible" : "hidden";
1333
+ for (const p of s.getNodes())
1334
+ for (const u of p.getPorts())
1335
+ p.setPortProp(u.id, "attrs/circle/visibility", g);
1342
1336
  }
1343
- function n(u) {
1337
+ function n(d) {
1344
1338
  if (!e)
1345
- for (const d of u.getPorts())
1346
- u.setPortProp(d.id, "attrs/circle/visibility", "visible");
1339
+ for (const g of d.getPorts())
1340
+ d.setPortProp(g.id, "attrs/circle/visibility", "visible");
1347
1341
  }
1348
- function i(u) {
1342
+ function i(d) {
1349
1343
  if (!e)
1350
- for (const d of u.getPorts())
1351
- u.setPortProp(d.id, "attrs/circle/visibility", "hidden");
1344
+ for (const g of d.getPorts())
1345
+ d.setPortProp(g.id, "attrs/circle/visibility", "hidden");
1352
1346
  }
1353
- function r(u) {
1354
- u.getTargetCell() || (e = u.id, o(!0));
1347
+ function r(d) {
1348
+ d.getTargetCell() || (e = d.id, o(!0));
1355
1349
  }
1356
- function a() {
1350
+ function l() {
1357
1351
  e = null, o(!1), t = Date.now() + 300;
1358
1352
  }
1359
- function l(u) {
1360
- u === e && (e = null, o(!1));
1353
+ function a(d) {
1354
+ d === e && (e = null, o(!1));
1361
1355
  }
1362
1356
  function c() {
1363
1357
  return !e && Date.now() >= t;
@@ -1366,22 +1360,30 @@ function kt(s) {
1366
1360
  showNodePorts: n,
1367
1361
  hideNodePorts: i,
1368
1362
  handleEdgeAdded: r,
1369
- handleEdgeConnected: a,
1370
- handleEdgeRemoved: l,
1363
+ handleEdgeConnected: l,
1364
+ handleEdgeRemoved: a,
1371
1365
  canShowEdgeTool: c
1372
1366
  };
1373
1367
  }
1374
- const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1368
+ const xt = { class: "flow-canvas-node-actions__bar" }, kt = /* @__PURE__ */ re({
1375
1369
  __name: "node-actions-toolbar",
1376
1370
  props: {
1377
1371
  node: {},
1378
1372
  position: {},
1379
1373
  config: {},
1380
- behavior: {}
1374
+ behavior: {},
1375
+ actionsOffset: {}
1381
1376
  },
1382
1377
  emits: ["action"],
1383
1378
  setup(s, { emit: e }) {
1384
- const t = s, o = e, n = z(() => ({
1379
+ const t = s, o = j(() => {
1380
+ const g = t.actionsOffset?.x ?? 0, p = t.actionsOffset?.y ?? 0, u = g !== 0 || p !== 0;
1381
+ return {
1382
+ left: `${t.position.x}px`,
1383
+ top: `${t.position.y}px`,
1384
+ transform: u ? `translate(${g}px, ${p}px)` : "translateX(-100%)"
1385
+ };
1386
+ }), n = e, i = j(() => ({
1385
1387
  debug: {
1386
1388
  visible: t.config.showDebug && t.behavior.debuggable !== !1,
1387
1389
  disabled: t.behavior.debugDisabled === !0
@@ -1402,89 +1404,89 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1402
1404
  visible: t.config.showDisconnect && t.behavior.disconnectable !== !1,
1403
1405
  disabled: t.behavior.disconnectDisabled === !0
1404
1406
  }
1405
- })), i = z(() => n.value.copy.visible || n.value.copyInsert.visible || n.value.disconnect.visible), r = B(!1);
1407
+ })), r = j(() => i.value.copy.visible || i.value.copyInsert.visible || i.value.disconnect.visible), l = z(!1);
1406
1408
  let a = null;
1407
- function l() {
1408
- a && (clearTimeout(a), a = null), r.value = !0;
1409
- }
1410
1409
  function c() {
1410
+ a && (clearTimeout(a), a = null), l.value = !0;
1411
+ }
1412
+ function d() {
1411
1413
  a = setTimeout(() => {
1412
- r.value = !1, a = null;
1414
+ l.value = !1, a = null;
1413
1415
  }, 100);
1414
1416
  }
1415
- return Ne(() => {
1417
+ return Se(() => {
1416
1418
  a && clearTimeout(a);
1417
- }), (u, d) => (C(), M("div", {
1419
+ }), (g, p) => (k(), S("div", {
1418
1420
  class: "flow-canvas-node-actions",
1419
- style: we({ left: `${s.position.x}px`, top: `${s.position.y}px` })
1421
+ style: me(o.value)
1420
1422
  }, [
1421
- $("div", Ct, [
1422
- n.value.debug.visible ? (C(), M("i", {
1423
+ A("div", xt, [
1424
+ i.value.debug.visible ? (k(), S("i", {
1423
1425
  key: 0,
1424
- class: Q(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": n.value.debug.disabled }]),
1425
- onClick: d[0] || (d[0] = (w) => !n.value.debug.disabled && o("action", "debug", s.node.id))
1426
- }, null, 2)) : O("", !0),
1427
- n.value.delete.visible ? (C(), M("i", {
1426
+ class: W(["flow-canvas-icon canvas-debug flow-canvas-node-actions__icon", { "is-disabled": i.value.debug.disabled }]),
1427
+ onClick: p[0] || (p[0] = (u) => !i.value.debug.disabled && n("action", "debug", s.node.id))
1428
+ }, null, 2)) : H("", !0),
1429
+ i.value.delete.visible ? (k(), S("i", {
1428
1430
  key: 1,
1429
- class: Q(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": n.value.delete.disabled }]),
1430
- onClick: d[1] || (d[1] = (w) => !n.value.delete.disabled && o("action", "delete", s.node.id))
1431
- }, null, 2)) : O("", !0),
1432
- i.value ? (C(), M("div", {
1431
+ class: W(["flow-canvas-icon canvas-shanchu flow-canvas-node-actions__icon", { "is-disabled": i.value.delete.disabled }]),
1432
+ onClick: p[1] || (p[1] = (u) => !i.value.delete.disabled && n("action", "delete", s.node.id))
1433
+ }, null, 2)) : H("", !0),
1434
+ r.value ? (k(), S("div", {
1433
1435
  key: 2,
1434
1436
  class: "flow-canvas-node-actions__more-wrapper",
1435
- onMouseenter: l,
1436
- onMouseleave: c
1437
- }, [...d[5] || (d[5] = [
1438
- $("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1439
- ])], 32)) : O("", !0)
1437
+ onMouseenter: c,
1438
+ onMouseleave: d
1439
+ }, [...p[5] || (p[5] = [
1440
+ A("i", { class: "flow-canvas-icon canvas-gengduo flow-canvas-node-actions__icon" }, null, -1)
1441
+ ])], 32)) : H("", !0)
1440
1442
  ]),
1441
- Oe(je, { name: "flow-canvas-fade" }, {
1442
- default: De(() => [
1443
- r.value && i.value ? (C(), M("div", {
1443
+ Be(ze, { name: "flow-canvas-fade" }, {
1444
+ default: Ne(() => [
1445
+ l.value && r.value ? (k(), S("div", {
1444
1446
  key: 0,
1445
1447
  class: "flow-canvas-node-actions__dropdown",
1446
- onMouseenter: l,
1447
- onMouseleave: c
1448
+ onMouseenter: c,
1449
+ onMouseleave: d
1448
1450
  }, [
1449
- n.value.copy.visible ? (C(), M("div", {
1451
+ i.value.copy.visible ? (k(), S("div", {
1450
1452
  key: 0,
1451
- class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": n.value.copy.disabled }]),
1452
- onClick: d[2] || (d[2] = (w) => !n.value.copy.disabled && o("action", "copy", s.node.id))
1453
- }, [...d[6] || (d[6] = [
1454
- $("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1455
- $("span", null, "复制", -1)
1456
- ])], 2)) : O("", !0),
1457
- n.value.copyInsert.visible ? (C(), M("div", {
1453
+ class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copy.disabled }]),
1454
+ onClick: p[2] || (p[2] = (u) => !i.value.copy.disabled && n("action", "copy", s.node.id))
1455
+ }, [...p[6] || (p[6] = [
1456
+ A("i", { class: "flow-canvas-icon canvas-copy-fuzhi-2" }, null, -1),
1457
+ A("span", null, "复制", -1)
1458
+ ])], 2)) : H("", !0),
1459
+ i.value.copyInsert.visible ? (k(), S("div", {
1458
1460
  key: 1,
1459
- class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": n.value.copyInsert.disabled }]),
1460
- onClick: d[3] || (d[3] = (w) => !n.value.copyInsert.disabled && o("action", "copy-insert", s.node.id))
1461
- }, [...d[7] || (d[7] = [
1462
- $("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1463
- $("span", null, "复制并插入", -1)
1464
- ])], 2)) : O("", !0),
1465
- n.value.disconnect.visible ? (C(), M("div", {
1461
+ class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.copyInsert.disabled }]),
1462
+ onClick: p[3] || (p[3] = (u) => !i.value.copyInsert.disabled && n("action", "copy-insert", s.node.id))
1463
+ }, [...p[7] || (p[7] = [
1464
+ A("i", { class: "flow-canvas-icon canvas-fuzhibingcharu" }, null, -1),
1465
+ A("span", null, "复制并插入", -1)
1466
+ ])], 2)) : H("", !0),
1467
+ i.value.disconnect.visible ? (k(), S("div", {
1466
1468
  key: 2,
1467
- class: Q(["flow-canvas-node-actions__dropdown-item", { "is-disabled": n.value.disconnect.disabled }]),
1468
- onClick: d[4] || (d[4] = (w) => !n.value.disconnect.disabled && o("action", "disconnect", s.node.id))
1469
- }, [...d[8] || (d[8] = [
1470
- $("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1471
- $("span", null, "断开连线", -1)
1472
- ])], 2)) : O("", !0)
1473
- ], 32)) : O("", !0)
1469
+ class: W(["flow-canvas-node-actions__dropdown-item", { "is-disabled": i.value.disconnect.disabled }]),
1470
+ onClick: p[4] || (p[4] = (u) => !i.value.disconnect.disabled && n("action", "disconnect", s.node.id))
1471
+ }, [...p[8] || (p[8] = [
1472
+ A("i", { class: "flow-canvas-icon canvas-unlock-jiebang" }, null, -1),
1473
+ A("span", null, "断开连线", -1)
1474
+ ])], 2)) : H("", !0)
1475
+ ], 32)) : H("", !0)
1474
1476
  ]),
1475
1477
  _: 1
1476
1478
  })
1477
1479
  ], 4));
1478
1480
  }
1479
- }), re = (s, e) => {
1481
+ }), ae = (s, e) => {
1480
1482
  const t = s.__vccOpts || s;
1481
1483
  for (const [o, n] of e)
1482
1484
  t[o] = n;
1483
1485
  return t;
1484
- }, It = /* @__PURE__ */ re(Et, [["__scopeId", "data-v-14d6590b"]]), Mt = {
1486
+ }, Ct = /* @__PURE__ */ ae(kt, [["__scopeId", "data-v-3b39dab5"]]), Et = {
1485
1487
  key: 0,
1486
1488
  class: "flow-canvas-quick-add__tooltip"
1487
- }, St = 5, Nt = /* @__PURE__ */ ie({
1489
+ }, It = 5, Mt = /* @__PURE__ */ re({
1488
1490
  __name: "node-quick-add-popover",
1489
1491
  props: {
1490
1492
  node: {},
@@ -1493,98 +1495,98 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1493
1495
  },
1494
1496
  emits: ["open", "close", "start-drag", "mouseenter", "mouseleave"],
1495
1497
  setup(s, { expose: e, emit: t }) {
1496
- const o = s, n = t, i = B(), r = B(), a = B(!1), l = B(!1);
1497
- let c = null, u = !1, d = null;
1498
- function w(S) {
1499
- S.preventDefault(), S.stopPropagation(), c = { x: S.clientX, y: S.clientY }, u = !1, document.addEventListener("mousemove", f), document.addEventListener("mouseup", E);
1498
+ const o = s, n = t, i = z(), r = z(), l = z(!1), a = z(!1);
1499
+ let c = null, d = !1, g = null;
1500
+ function p(D) {
1501
+ D.preventDefault(), D.stopPropagation(), c = { x: D.clientX, y: D.clientY }, d = !1, document.addEventListener("mousemove", u), document.addEventListener("mouseup", N);
1500
1502
  }
1501
- function f(S) {
1503
+ function u(D) {
1502
1504
  if (!c) return;
1503
- const I = S.clientX - c.x, j = S.clientY - c.y;
1504
- Math.sqrt(I * I + j * j) >= St && (u = !0, b(), n("start-drag", o.node.id));
1505
+ const C = D.clientX - c.x, F = D.clientY - c.y;
1506
+ Math.sqrt(C * C + F * F) >= It && (d = !0, b(), n("start-drag", o.node.id));
1505
1507
  }
1506
- function E() {
1507
- b(), u || m(), c = null, u = !1;
1508
+ function N() {
1509
+ b(), d || y(), c = null, d = !1;
1508
1510
  }
1509
1511
  function b() {
1510
- document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", E);
1512
+ document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", N);
1511
1513
  }
1512
- function m() {
1513
- l.value ? P() : p();
1514
+ function y() {
1515
+ a.value ? R() : m();
1514
1516
  }
1515
- function p() {
1516
- l.value = !0, n("open", o.node.id), requestAnimationFrame(() => {
1517
- document.addEventListener("mousedown", g);
1517
+ function m() {
1518
+ a.value = !0, n("open", o.node.id), requestAnimationFrame(() => {
1519
+ document.addEventListener("mousedown", h);
1518
1520
  });
1519
1521
  }
1520
- function P() {
1521
- l.value = !1, n("close"), document.removeEventListener("mousedown", g);
1522
+ function R() {
1523
+ a.value = !1, n("close"), document.removeEventListener("mousedown", h);
1522
1524
  }
1523
- function g(S) {
1524
- const I = S.target;
1525
- i.value?.contains(I) || r.value?.contains(I) || P();
1525
+ function h(D) {
1526
+ const C = D.target;
1527
+ i.value?.contains(C) || r.value?.contains(C) || R();
1526
1528
  }
1527
1529
  function v() {
1528
- l.value || n("mouseleave");
1530
+ a.value || n("mouseleave");
1529
1531
  }
1530
- function N() {
1531
- d && (clearTimeout(d), d = null), n("mouseenter");
1532
+ function I() {
1533
+ g && (clearTimeout(g), g = null), n("mouseenter");
1532
1534
  }
1533
- function U() {
1534
- d = setTimeout(() => {
1535
- P(), n("mouseleave"), d = null;
1535
+ function L() {
1536
+ g = setTimeout(() => {
1537
+ R(), n("mouseleave"), g = null;
1536
1538
  }, 150);
1537
1539
  }
1538
- return Ne(() => {
1539
- b(), d && clearTimeout(d), document.removeEventListener("mousedown", g);
1540
- }), e({ closePopover: P }), (S, I) => (C(), M("div", {
1540
+ return Se(() => {
1541
+ b(), g && clearTimeout(g), document.removeEventListener("mousedown", h);
1542
+ }), e({ closePopover: R }), (D, C) => (k(), S("div", {
1541
1543
  class: "flow-canvas-quick-add",
1542
- style: we({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
1543
- onMouseenter: I[2] || (I[2] = (j) => n("mouseenter")),
1544
+ style: me({ left: `${s.portPosition.x}px`, top: `${s.portPosition.y}px` }),
1545
+ onMouseenter: C[2] || (C[2] = (F) => n("mouseenter")),
1544
1546
  onMouseleave: v,
1545
- onClick: I[3] || (I[3] = qe(() => {
1547
+ onClick: C[3] || (C[3] = He(() => {
1546
1548
  }, ["stop"]))
1547
1549
  }, [
1548
- $("div", {
1550
+ A("div", {
1549
1551
  ref_key: "btnRef",
1550
1552
  ref: i,
1551
- class: Q(["flow-canvas-quick-add__btn", { "is-hovered": a.value, "is-active": l.value }]),
1552
- onMouseenter: I[0] || (I[0] = (j) => a.value = !0),
1553
- onMouseleave: I[1] || (I[1] = (j) => a.value = !1),
1554
- onMousedown: w
1555
- }, [...I[4] || (I[4] = [
1556
- $("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
1553
+ class: W(["flow-canvas-quick-add__btn", { "is-hovered": l.value, "is-active": a.value }]),
1554
+ onMouseenter: C[0] || (C[0] = (F) => l.value = !0),
1555
+ onMouseleave: C[1] || (C[1] = (F) => l.value = !1),
1556
+ onMousedown: p
1557
+ }, [...C[4] || (C[4] = [
1558
+ A("i", { class: "flow-canvas-icon canvas-zoom-add" }, null, -1)
1557
1559
  ])], 34),
1558
- a.value && !l.value ? (C(), M("div", Mt, [...I[5] || (I[5] = [
1559
- $("div", null, [
1560
- $("b", null, "点击"),
1561
- Ae(" 添加节点")
1560
+ l.value && !a.value ? (k(), S("div", Et, [...C[5] || (C[5] = [
1561
+ A("div", null, [
1562
+ A("b", null, "点击"),
1563
+ De(" 添加节点")
1562
1564
  ], -1),
1563
- $("div", null, [
1564
- $("b", null, "拖拽"),
1565
- Ae(" 连接节点")
1565
+ A("div", null, [
1566
+ A("b", null, "拖拽"),
1567
+ De(" 连接节点")
1566
1568
  ], -1)
1567
- ])])) : O("", !0),
1568
- Oe(je, { name: "flow-canvas-fade" }, {
1569
- default: De(() => [
1570
- l.value ? (C(), M("div", {
1569
+ ])])) : H("", !0),
1570
+ Be(ze, { name: "flow-canvas-fade" }, {
1571
+ default: Ne(() => [
1572
+ a.value ? (k(), S("div", {
1571
1573
  key: 0,
1572
1574
  ref_key: "popoverRef",
1573
1575
  ref: r,
1574
1576
  class: "flow-canvas-quick-add__popover",
1575
- onMouseenter: N,
1576
- onMouseleave: U
1577
+ onMouseenter: I,
1578
+ onMouseleave: L
1577
1579
  }, [
1578
- ce(S.$slots, "default", {}, () => [
1579
- I[6] || (I[6] = $("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
1580
+ fe(D.$slots, "default", {}, () => [
1581
+ C[6] || (C[6] = A("div", { class: "flow-canvas-quick-add__default-content" }, "节点快捷操作面板", -1))
1580
1582
  ], !0)
1581
- ], 544)) : O("", !0)
1583
+ ], 544)) : H("", !0)
1582
1584
  ]),
1583
1585
  _: 3
1584
1586
  })
1585
1587
  ], 36));
1586
1588
  }
1587
- }), Dt = /* @__PURE__ */ re(Nt, [["__scopeId", "data-v-deb5af25"]]), _t = /* @__PURE__ */ ie({
1589
+ }), St = /* @__PURE__ */ ae(Mt, [["__scopeId", "data-v-deb5af25"]]), Nt = { class: "flow-canvas-runtime-core__overlay" }, Dt = /* @__PURE__ */ re({
1588
1590
  __name: "canvas-runtime-core",
1589
1591
  props: {
1590
1592
  editor: {},
@@ -1594,60 +1596,46 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1594
1596
  },
1595
1597
  emits: ["ui-event"],
1596
1598
  setup(s, { emit: e }) {
1597
- const t = s, o = e, n = B(), i = B(), r = B();
1598
- let a, l, c, u;
1599
- const d = wt(), { hoveredNodeId: w, isDraggingNode: f } = d, E = d.cancelLeave, b = d.leave, m = B(null);
1600
- let p = null;
1601
- function P(x) {
1602
- return v(), te(x) ? (m.value = x, !0) : (m.value = null, !1);
1603
- }
1604
- function g() {
1605
- p && clearTimeout(p), p = setTimeout(() => {
1606
- m.value = null, p = null;
1599
+ const t = s, o = e, n = z(), i = z();
1600
+ let r, l, a, c;
1601
+ const d = mt(), { hoveredNodeId: g, isDraggingNode: p } = d, u = d.enterOverlay, N = () => d.leaveOverlay(), b = z(null);
1602
+ let y = null;
1603
+ function m(x) {
1604
+ return h(), V(x) ? (b.value = x, !0) : (b.value = null, !1);
1605
+ }
1606
+ function R() {
1607
+ y && clearTimeout(y), y = setTimeout(() => {
1608
+ b.value = null, y = null;
1607
1609
  }, 150);
1608
1610
  }
1609
- function v() {
1610
- p && (clearTimeout(p), p = null);
1611
+ function h() {
1612
+ y && (clearTimeout(y), y = null);
1611
1613
  }
1612
- function N() {
1613
- v(), d.cancelLeave();
1614
+ function v() {
1615
+ h(), d.enterOverlay();
1614
1616
  }
1615
- function U() {
1616
- g(), d.leave();
1617
+ function I() {
1618
+ R(), d.leaveOverlay();
1617
1619
  }
1618
- let S = null, I = null, j = null;
1619
- const q = B(0), Y = z(
1620
+ let L = null, D = null, C = null;
1621
+ const F = z(0), Y = j(
1620
1622
  () => {
1621
- if (q.value, !t.editor.api.value) return [];
1622
- const x = t.editor.flowModel.value, k = t.editor.api.value.overlay, y = [];
1623
- for (const [D, T] of Object.entries(x.nodes)) {
1624
- const A = t.editor._pluginManager.collectNodeDecorations(T);
1625
- if (!A?.badge) continue;
1626
- const R = k.getNodeScreenRect(D);
1627
- R && y.push({
1628
- nodeId: D,
1629
- x: R.x + R.width - 4,
1630
- y: R.y - 8,
1631
- badge: A.badge
1623
+ if (F.value, !t.editor.api.value) return [];
1624
+ const x = t.editor.flowModel.value, E = t.editor.api.value.overlay, w = [];
1625
+ for (const [_, B] of Object.entries(x.nodes)) {
1626
+ const P = t.editor._pluginManager.collectNodeDecorations(B);
1627
+ if (!P?.badge) continue;
1628
+ const O = E.getNodeScreenRect(_);
1629
+ O && w.push({
1630
+ nodeId: _,
1631
+ x: O.x + O.width - 4,
1632
+ y: O.y - 8,
1633
+ badge: P.badge
1632
1634
  });
1633
1635
  }
1634
- return y;
1636
+ return w;
1635
1637
  }
1636
- ), oe = z(() => {
1637
- q.value;
1638
- const x = w.value;
1639
- if (!x || !t.editor.api.value) return [];
1640
- const y = t.editor.flowModel.value.nodes[x];
1641
- if (!y) return [];
1642
- const D = t.editor.schema.nodeTypes[y.type];
1643
- if (!D?.getOverlayAnchors) return [];
1644
- const T = D.getOverlayAnchors(y), A = t.editor.api.value.overlay, R = {};
1645
- for (const W of Object.keys(T)) {
1646
- const ae = A.getAnchorScreenPosition(x, W);
1647
- ae && (R[W] = ae);
1648
- }
1649
- return [{ node: y, screenAnchors: R }];
1650
- }), Z = z(() => ({
1638
+ ), q = j(() => ({
1651
1639
  showDebug: !1,
1652
1640
  showDelete: !0,
1653
1641
  showCopy: !0,
@@ -1655,75 +1643,75 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1655
1643
  showDisconnect: !0,
1656
1644
  insertGap: 100,
1657
1645
  ...t.nodeActions
1658
- })), X = z(() => {
1659
- q.value;
1660
- const x = w.value;
1661
- if (!x || f.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1662
- const k = t.editor.flowModel.value, y = k.nodes[x];
1663
- if (!y) return null;
1664
- const D = t.editor.api.value.overlay.getNodeScreenRect(x);
1665
- if (!D) return null;
1666
- const A = t.editor.schema.nodeTypes[y.type]?.getBehavior?.(y, {
1646
+ })), Q = j(() => {
1647
+ F.value;
1648
+ const x = g.value;
1649
+ if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1650
+ const E = t.editor.flowModel.value, w = E.nodes[x];
1651
+ if (!w) return null;
1652
+ const _ = t.editor.api.value.overlay.getNodeScreenRect(x);
1653
+ if (!_) return null;
1654
+ const P = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1667
1655
  api: t.editor.api.value,
1668
- flowModel: k,
1656
+ flowModel: E,
1669
1657
  history: t.editor.history,
1670
1658
  mode: t.editor.mode.value
1671
1659
  }) ?? {};
1672
- return A.showActions === !1 ? null : {
1673
- node: y,
1674
- position: { x: D.x + D.width, y: D.y + D.height + 4 },
1675
- behavior: A
1660
+ return P.showActions === !1 ? null : {
1661
+ node: w,
1662
+ position: { x: _.x + _.width, y: _.y + _.height + 4 },
1663
+ behavior: P
1676
1664
  };
1677
- }), ee = z(() => ({
1665
+ }), X = j(() => ({
1678
1666
  enabled: !0,
1679
1667
  tooltipText: "",
1680
1668
  ...t.quickAdd
1681
- })), V = z(() => {
1682
- if (q.value, !ee.value.enabled) return null;
1683
- const x = m.value;
1684
- if (!x || f.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1685
- const k = t.editor.flowModel.value, y = k.nodes[x];
1686
- if (!y) return null;
1687
- const T = t.editor.schema.nodeTypes[y.type]?.getBehavior?.(y, {
1669
+ })), G = j(() => {
1670
+ if (F.value, !X.value.enabled) return null;
1671
+ const x = b.value;
1672
+ if (!x || p.value || !t.editor.api.value || t.editor.mode.value !== "edit") return null;
1673
+ const E = t.editor.flowModel.value, w = E.nodes[x];
1674
+ if (!w) return null;
1675
+ const B = t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1688
1676
  api: t.editor.api.value,
1689
- flowModel: k,
1677
+ flowModel: E,
1690
1678
  history: t.editor.history,
1691
1679
  mode: t.editor.mode.value
1692
1680
  }) ?? {};
1693
- if (T.quickAddEnabled === !1) return null;
1694
- const A = t.editor.api.value.overlay.getNodeScreenRect(x);
1695
- return A ? {
1696
- node: y,
1697
- portPosition: { x: A.x + A.width, y: A.y + A.height / 2 },
1698
- behavior: T
1681
+ if (B.quickAddEnabled === !1) return null;
1682
+ const P = t.editor.api.value.overlay.getNodeScreenRect(x);
1683
+ return P ? {
1684
+ node: w,
1685
+ portPosition: { x: P.x + P.width, y: P.y + P.height / 2 },
1686
+ behavior: B
1699
1687
  } : null;
1700
- }), pe = B();
1701
- function ne(x) {
1702
- const k = V.value;
1703
- k && o("ui-event", {
1688
+ }), se = z();
1689
+ function ee(x) {
1690
+ const E = G.value;
1691
+ E && o("ui-event", {
1704
1692
  type: "node.quick-add",
1705
1693
  nodeId: x,
1706
- position: k.portPosition
1694
+ position: E.portPosition
1707
1695
  });
1708
1696
  }
1709
- function Ee(x) {
1710
- const k = t.editor.api.value;
1711
- k && k.startConnection(x, "right");
1697
+ function ke(x) {
1698
+ const E = t.editor.api.value;
1699
+ E && E.startConnection(x, "right");
1712
1700
  }
1713
- function J(x, k) {
1714
- const y = t.editor.api.value;
1715
- if (!y) return;
1716
- const D = k.id || L(), T = { ...k, id: D };
1717
- y.insertNodeToRight(x, T, {
1701
+ function te(x, E) {
1702
+ const w = t.editor.api.value;
1703
+ if (!w) return;
1704
+ const _ = E.id || T(), B = { ...E, id: _ };
1705
+ w.insertNodeToRight(x, B, {
1718
1706
  autoWireEdges: !0,
1719
- gap: Z.value.insertGap,
1707
+ gap: q.value.insertGap,
1720
1708
  source: "user:quick-add",
1721
1709
  label: "快捷插入节点"
1722
- }).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: x, newNodeId: D }), pe.value?.closePopover();
1710
+ }).status === "applied" && o("ui-event", { type: "node.action.quick-insert", sourceNodeId: x, newNodeId: _ }), se.value?.closePopover();
1723
1711
  }
1724
- function G(x) {
1712
+ function he(x) {
1725
1713
  return {
1726
- id: L(),
1714
+ id: T(),
1727
1715
  type: x.type,
1728
1716
  label: x.label,
1729
1717
  ports: x.ports ? JSON.parse(JSON.stringify(x.ports)) : void 0,
@@ -1731,79 +1719,79 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1731
1719
  extensions: x.extensions ? JSON.parse(JSON.stringify(x.extensions)) : void 0
1732
1720
  };
1733
1721
  }
1734
- function ye(x, k) {
1735
- const y = t.editor, D = y.api.value;
1722
+ function Z(x, E) {
1723
+ const w = t.editor, _ = w.api.value;
1736
1724
  switch (x) {
1737
1725
  case "delete": {
1738
- y.executeCommand({
1739
- id: L(),
1726
+ w.executeCommand({
1727
+ id: T(),
1740
1728
  source: "user:toolbar",
1741
1729
  label: "删除节点",
1742
1730
  timestamp: Date.now(),
1743
- commands: [{ type: "node.remove", nodeId: k }]
1744
- }), o("ui-event", { type: "node.action.delete", nodeId: k }), w.value = null;
1731
+ commands: [{ type: "node.remove", nodeId: E }]
1732
+ }), o("ui-event", { type: "node.action.delete", nodeId: E }), g.value = null;
1745
1733
  break;
1746
1734
  }
1747
1735
  case "copy": {
1748
- if (!D) break;
1749
- const T = y.flowModel.value.nodes[k];
1750
- if (!T) break;
1751
- const A = G(T);
1752
- D.insertNodeToRight(k, A, {
1736
+ if (!_) break;
1737
+ const B = w.flowModel.value.nodes[E];
1738
+ if (!B) break;
1739
+ const P = he(B);
1740
+ _.insertNodeToRight(E, P, {
1753
1741
  autoWireEdges: !1,
1754
- gap: Z.value.insertGap,
1742
+ gap: q.value.insertGap,
1755
1743
  label: "复制节点"
1756
- }), o("ui-event", { type: "node.action.copy", sourceNodeId: k, newNodeId: A.id });
1744
+ }), o("ui-event", { type: "node.action.copy", sourceNodeId: E, newNodeId: P.id });
1757
1745
  break;
1758
1746
  }
1759
1747
  case "copy-insert": {
1760
- if (!D) break;
1761
- const T = y.flowModel.value.nodes[k];
1762
- if (!T) break;
1763
- const A = G(T);
1764
- D.insertNodeToRight(k, A, {
1748
+ if (!_) break;
1749
+ const B = w.flowModel.value.nodes[E];
1750
+ if (!B) break;
1751
+ const P = he(B);
1752
+ _.insertNodeToRight(E, P, {
1765
1753
  autoWireEdges: !0,
1766
- gap: Z.value.insertGap,
1754
+ gap: q.value.insertGap,
1767
1755
  label: "复制并插入节点"
1768
- }), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: k, newNodeId: A.id });
1756
+ }), o("ui-event", { type: "node.action.copy-insert", sourceNodeId: E, newNodeId: P.id });
1769
1757
  break;
1770
1758
  }
1771
1759
  case "disconnect": {
1772
- const T = y.flowModel.value, A = Object.entries(T.edges).filter(([, R]) => {
1773
- const W = R;
1774
- return W.source.nodeId === k || W.target.nodeId === k;
1775
- }).map(([R]) => R);
1776
- if (A.length === 0) break;
1777
- y.executeCommand({
1778
- id: L(),
1760
+ const B = w.flowModel.value, P = Object.entries(B.edges).filter(([, O]) => {
1761
+ const J = O;
1762
+ return J.source.nodeId === E || J.target.nodeId === E;
1763
+ }).map(([O]) => O);
1764
+ if (P.length === 0) break;
1765
+ w.executeCommand({
1766
+ id: T(),
1779
1767
  source: "user:toolbar",
1780
1768
  label: "断开连线",
1781
1769
  timestamp: Date.now(),
1782
- commands: A.map((R) => ({ type: "edge.remove", edgeId: R }))
1783
- }), o("ui-event", { type: "node.action.disconnect", nodeId: k, edgeIds: A });
1770
+ commands: P.map((O) => ({ type: "edge.remove", edgeId: O }))
1771
+ }), o("ui-event", { type: "node.action.disconnect", nodeId: E, edgeIds: P });
1784
1772
  break;
1785
1773
  }
1786
1774
  case "debug": {
1787
- o("ui-event", { type: "node.action.debug", nodeId: k });
1775
+ o("ui-event", { type: "node.action.debug", nodeId: E });
1788
1776
  break;
1789
1777
  }
1790
1778
  }
1791
1779
  }
1792
- function te(x) {
1793
- if (!ee.value.enabled || t.editor.mode.value !== "edit") return !1;
1794
- const k = t.editor.flowModel.value, y = k.nodes[x];
1795
- return y ? (t.editor.schema.nodeTypes[y.type]?.getBehavior?.(y, {
1780
+ function V(x) {
1781
+ if (!X.value.enabled || t.editor.mode.value !== "edit") return !1;
1782
+ const E = t.editor.flowModel.value, w = E.nodes[x];
1783
+ return w ? (t.editor.schema.nodeTypes[w.type]?.getBehavior?.(w, {
1796
1784
  api: t.editor.api.value,
1797
- flowModel: k,
1785
+ flowModel: E,
1798
1786
  history: t.editor.history,
1799
1787
  mode: t.editor.mode.value
1800
1788
  }) ?? {}).quickAddEnabled !== !1 : !1;
1801
1789
  }
1802
- function H(x) {
1790
+ function ue(x) {
1803
1791
  if (t.editor.mode.value !== "edit") return;
1804
1792
  t.editor._pluginManager.dispatchKeyboardShortcut(x) && (x.preventDefault(), x.stopPropagation());
1805
1793
  }
1806
- function Ie() {
1794
+ function oe() {
1807
1795
  return {
1808
1796
  refX: 0,
1809
1797
  children: [
@@ -1824,8 +1812,8 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1824
1812
  ]
1825
1813
  };
1826
1814
  }
1827
- function He(x) {
1828
- const k = t.editor.schema.defaultEdgeType ?? "default", y = t.editor.schema.edgeTypes?.[k], D = {
1815
+ function U(x) {
1816
+ const E = t.editor.schema.defaultEdgeType ?? "default", w = t.editor.schema.edgeTypes?.[E], _ = {
1829
1817
  zIndex: -1,
1830
1818
  attrs: {
1831
1819
  line: {
@@ -1835,34 +1823,39 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1835
1823
  }
1836
1824
  }
1837
1825
  };
1838
- y?.router && (D.router = typeof y.router == "string" ? { name: y.router } : y.router), y?.connector && (D.connector = typeof y.connector == "string" ? { name: y.connector } : y.connector), y?.x6EdgeConfig && Object.assign(D, y.x6EdgeConfig);
1839
- const T = D.attrs ?? {}, A = T.line ?? {};
1840
- return D.attrs = {
1841
- ...T,
1826
+ w?.router && (_.router = typeof w.router == "string" ? { name: w.router } : w.router), w?.connector && (_.connector = typeof w.connector == "string" ? { name: w.connector } : w.connector), w?.x6EdgeConfig && Object.assign(_, w.x6EdgeConfig);
1827
+ const B = _.attrs ?? {}, P = B.line ?? {};
1828
+ return _.attrs = {
1829
+ ...B,
1842
1830
  line: {
1843
- ...A,
1844
- targetMarker: Ie()
1831
+ ...P,
1832
+ targetMarker: oe()
1845
1833
  }
1846
- }, x.createEdge(D);
1834
+ }, x.createEdge(_);
1847
1835
  }
1848
- return Ge(() => {
1836
+ return Fe(() => {
1849
1837
  if (!i.value) return;
1850
- const x = /* @__PURE__ */ new Set(["model", "container"]), k = {};
1838
+ const x = /* @__PURE__ */ new Set(["model", "container"]), E = {};
1851
1839
  if (t.graphOptions)
1852
- for (const [h, _] of Object.entries(t.graphOptions)) {
1853
- if (x.has(h)) {
1854
- console.warn(`[flow-canvas] graphOptions.${h} is managed by the engine and will be ignored`);
1840
+ for (const [f, M] of Object.entries(t.graphOptions)) {
1841
+ if (x.has(f)) {
1842
+ console.warn(`[flow-canvas] graphOptions.${f} is managed by the engine and will be ignored`);
1855
1843
  continue;
1856
1844
  }
1857
- k[h] = _;
1845
+ E[f] = M;
1858
1846
  }
1859
- a = new Qe({
1847
+ r = new Ve({
1860
1848
  container: i.value,
1861
1849
  autoResize: !0,
1862
1850
  background: { color: "#edf2fc" },
1863
1851
  grid: { visible: !0, size: 20, type: "dot" },
1864
1852
  panning: { enabled: !0 },
1865
1853
  mousewheel: { enabled: !0, modifiers: ["ctrl", "meta"] },
1854
+ interacting: {
1855
+ nodeMovable(f) {
1856
+ return f.cell.getProp("draggable") !== !1;
1857
+ }
1858
+ },
1866
1859
  connecting: {
1867
1860
  allowBlank: !1,
1868
1861
  allowMulti: !0,
@@ -1874,16 +1867,16 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1874
1867
  connectionPoint: "anchor",
1875
1868
  snap: { radius: 30 },
1876
1869
  createEdge() {
1877
- return He(this);
1870
+ return U(this);
1878
1871
  }
1879
1872
  },
1880
- ...k
1881
- }), c = new ht(), l = new pt(
1882
- a,
1873
+ ...E
1874
+ }), a = new pt(), l = new ut(
1875
+ r,
1883
1876
  t.editor.schema,
1884
- c,
1885
- (h) => t.editor._pluginManager.collectNodeDecorations(h),
1886
- (h) => t.editor._pluginManager.collectEdgeDecorations(h),
1877
+ a,
1878
+ (f) => t.editor._pluginManager.collectNodeDecorations(f),
1879
+ (f) => t.editor._pluginManager.collectEdgeDecorations(f),
1887
1880
  () => t.editor.api.value ? {
1888
1881
  api: t.editor.api.value,
1889
1882
  flowModel: t.editor.flowModel.value,
@@ -1891,266 +1884,261 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
1891
1884
  mode: t.editor.mode.value
1892
1885
  } : null
1893
1886
  );
1894
- const y = yt(a, t.editor.schema);
1895
- r.value && (y.overlayContainer.value = r.value);
1896
- const D = bt({
1897
- graph: a,
1898
- overlayManager: y,
1899
- executeCommand: (h) => t.editor.executeCommand(h),
1887
+ const w = ht(r), _ = yt({
1888
+ graph: r,
1889
+ overlayManager: w,
1890
+ executeCommand: (f) => t.editor.executeCommand(f),
1900
1891
  schema: t.editor.schema,
1901
1892
  flowModel: t.editor.flowModel,
1902
1893
  defaultInsertGap: t.nodeActions?.insertGap,
1903
- getContextMenuItems: (h) => t.editor._pluginManager.collectContextMenuItems(h),
1904
- onHighlightChange: (h, _) => {
1905
- l.setHighlightedNodes(h), l.setHighlightedEdges(_), l.refreshNodeHighlights(), l.refreshEdgeStyles();
1894
+ getContextMenuItems: (f) => t.editor._pluginManager.collectContextMenuItems(f),
1895
+ onHighlightChange: (f, M) => {
1896
+ l.setHighlightedNodes(f), l.setHighlightedEdges(M), l.refreshNodeHighlights(), l.refreshEdgeStyles();
1906
1897
  },
1907
- resolveNodeShape: (h) => {
1908
- const _ = t.editor.schema.nodeTypes[h];
1909
- if (!_) return null;
1910
- const F = c.registerNodeType(h, _.component), me = _.getSize({ id: "", type: h, position: { x: 0, y: 0 } });
1911
- return { shapeName: F, width: me.width, height: me.height };
1898
+ resolveNodeShape: (f) => {
1899
+ const M = t.editor.schema.nodeTypes[f];
1900
+ if (!M) return null;
1901
+ const $ = a.registerNodeType(f, M.component), ne = M.getSize({ id: "", type: f, position: { x: 0, y: 0 } });
1902
+ return { shapeName: $, width: ne.width, height: ne.height };
1912
1903
  }
1913
1904
  });
1914
- t.editor.api.value = D;
1915
- const T = {
1905
+ t.editor.api.value = _;
1906
+ const B = {
1916
1907
  flowModel: t.editor.flowModel,
1917
1908
  history: t.editor.history,
1918
1909
  schema: t.editor.schema,
1919
1910
  mode: t.editor.mode,
1920
1911
  executeCommand: t.editor.executeCommand,
1921
- api: D,
1922
- overlay: y,
1923
- graph: a
1912
+ api: _,
1913
+ overlay: w,
1914
+ graph: r
1924
1915
  };
1925
- t.editor._pluginManager.attachRuntime(T);
1926
- const A = t.editor._pluginManager.collectExtendedApi();
1927
- Object.assign(t.editor.extendedApi, A), u = new vt(
1928
- a,
1929
- (h) => {
1930
- (h.type === "node.click" || h.type === "node.dblclick" || h.type === "node.contextmenu") && d.enter(h.nodeId), t.editor._pluginManager.dispatchUiEvent(h), o("ui-event", h);
1916
+ t.editor._pluginManager.attachRuntime(B);
1917
+ const P = t.editor._pluginManager.collectExtendedApi();
1918
+ Object.assign(t.editor.extendedApi, P), c = new gt(
1919
+ r,
1920
+ (f) => {
1921
+ (f.type === "node.click" || f.type === "node.dblclick" || f.type === "node.contextmenu") && d.enter(f.nodeId), t.editor._pluginManager.dispatchUiEvent(f), o("ui-event", f);
1931
1922
  },
1932
- (h) => {
1933
- l.isSyncing || t.editor.executeCommand(h);
1923
+ (f) => {
1924
+ if (l.isSyncing) return;
1925
+ if (t.editor.executeCommand(f).status !== "applied") {
1926
+ for (const $ of f.commands)
1927
+ if ($.type === "edge.add") {
1928
+ const ne = r.getCellById($.edge.id);
1929
+ ne && r.removeCell(ne);
1930
+ }
1931
+ }
1934
1932
  },
1935
1933
  t.editor.flowModel
1936
- ), S = xt(a);
1937
- const R = kt(a), W = a, ae = (h) => {
1938
- const _ = W.isRubberbandEnabled?.() ?? !1;
1939
- _ && W.disableRubberband?.(), h ? a.enablePanning() : a.disablePanning(), _ && W.enableRubberband?.();
1940
- }, Me = () => {
1941
- q.value++;
1934
+ ), L = bt(r);
1935
+ const O = wt(r), J = r, Ce = (f) => {
1936
+ const M = J.isRubberbandEnabled?.() ?? !1;
1937
+ M && J.disableRubberband?.(), f ? r.enablePanning() : r.disablePanning(), M && J.enableRubberband?.();
1938
+ }, Ee = () => {
1939
+ F.value++;
1942
1940
  };
1943
- a.on("translate", Me), a.on("scale", Me), a.on("resize", Me), a.on("node:move", () => {
1944
- f.value = !0;
1945
- }), a.on("node:moved", () => {
1946
- f.value = !1;
1947
- }), a.on("node:mouseenter", ({ node: h }) => {
1948
- d.enter(h.id), ee.value.enabled && P(h.id) || R.showNodePorts(h);
1949
- }), a.on("node:mouseleave", ({ node: h }) => {
1950
- d.leave(), ee.value.enabled && m.value === h.id ? g() : R.hideNodePorts(h);
1941
+ r.on("translate", Ee), r.on("scale", Ee), r.on("resize", Ee), r.on("node:move", () => {
1942
+ p.value = !0;
1943
+ }), r.on("node:moved", () => {
1944
+ p.value = !1;
1945
+ }), r.on("node:mouseenter", ({ node: f }) => {
1946
+ d.enter(f.id), X.value.enabled && m(f.id) || O.showNodePorts(f);
1947
+ }), r.on("node:mouseleave", ({ node: f }) => {
1948
+ const M = t.editor.flowModel.value.nodes[f.id];
1949
+ let $ = 100;
1950
+ M && t.editor.api.value && t.editor.schema.nodeTypes[M.type]?.getBehavior?.(M, {
1951
+ api: t.editor.api.value,
1952
+ flowModel: t.editor.flowModel.value,
1953
+ history: t.editor.history,
1954
+ mode: t.editor.mode.value
1955
+ })?.actionsOffset && ($ = 300), d.leave($), X.value.enabled && b.value === f.id ? R() : O.hideNodePorts(f);
1951
1956
  });
1952
- function Fe(h) {
1953
- const _ = a.getCellById(h);
1954
- if (!_?.isNode()) return;
1955
- const F = _, me = !f.value && te(h);
1956
- for (const _e of F.getPorts()) {
1957
- const Ue = me && _e.group === "right" ? "hidden" : "visible";
1958
- F.setPortProp(_e.id, "attrs/circle/visibility", Ue);
1957
+ function Oe(f) {
1958
+ const M = r.getCellById(f);
1959
+ if (!M?.isNode()) return;
1960
+ const $ = M, ne = !p.value && V(f);
1961
+ for (const Ie of $.getPorts()) {
1962
+ const je = ne && Ie.group === "right" ? "hidden" : "visible";
1963
+ $.setPortProp(Ie.id, "attrs/circle/visibility", je);
1959
1964
  }
1960
1965
  }
1961
- de(
1962
- [m, f],
1963
- ([h], [_]) => {
1964
- if (_ && _ !== h) {
1965
- const F = a.getCellById(_);
1966
- F?.isNode() && R.hideNodePorts(F);
1966
+ le(
1967
+ [b, p],
1968
+ ([f], [M]) => {
1969
+ if (M && M !== f) {
1970
+ const $ = r.getCellById(M);
1971
+ $?.isNode() && O.hideNodePorts($);
1967
1972
  }
1968
- h && Fe(h);
1973
+ f && Oe(f);
1969
1974
  },
1970
1975
  { flush: "sync" }
1971
- ), a.on("edge:added", ({ edge: h }) => {
1972
- R.handleEdgeAdded(h);
1973
- }), a.on("edge:connected", () => {
1974
- R.handleEdgeConnected();
1975
- }), a.on("edge:removed", ({ edge: h }) => {
1976
- R.handleEdgeRemoved(h.id), S.handleEdgeRemoved(h.id);
1977
- }), a.on("selection:changed", () => {
1978
- const h = a.getSelectedCells?.() ?? [], _ = {
1979
- nodeIds: h.filter((F) => F.isNode()).map((F) => F.id),
1980
- edgeIds: h.filter((F) => F.isEdge()).map((F) => F.id)
1976
+ ), r.on("edge:added", ({ edge: f }) => {
1977
+ O.handleEdgeAdded(f);
1978
+ }), r.on("edge:connected", () => {
1979
+ O.handleEdgeConnected();
1980
+ }), r.on("edge:removed", ({ edge: f }) => {
1981
+ O.handleEdgeRemoved(f.id), L.handleEdgeRemoved(f.id);
1982
+ }), r.on("selection:changed", () => {
1983
+ const f = r.getSelectedCells?.() ?? [], M = {
1984
+ nodeIds: f.filter(($) => $.isNode()).map(($) => $.id),
1985
+ edgeIds: f.filter(($) => $.isEdge()).map(($) => $.id)
1981
1986
  };
1982
- t.editor._pluginManager.dispatchSelectionChange(_), o("ui-event", {
1987
+ t.editor._pluginManager.dispatchSelectionChange(M), o("ui-event", {
1983
1988
  type: "selection.change",
1984
- nodeIds: _.nodeIds,
1985
- edgeIds: _.edgeIds
1989
+ nodeIds: M.nodeIds,
1990
+ edgeIds: M.edgeIds
1986
1991
  }), l.refreshEdgeStyles();
1987
- }), a.on("edge:mouseenter", ({ edge: h, e: _ }) => {
1988
- l.setHoveredEdge(h.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && R.canShowEdgeTool() && S.show(h.id, _);
1989
- }), I = (h) => S.move(h), a.container.addEventListener("mousemove", I), a.on("edge:mouseleave", () => {
1990
- l.setHoveredEdge(null), l.refreshEdgeStyles(), S.remove();
1991
- }), a.on("edge:click", ({ edge: h, e: _ }) => {
1992
- _.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (S.remove(), t.editor.executeCommand({
1993
- id: L(),
1992
+ }), r.on("edge:mouseenter", ({ edge: f, e: M }) => {
1993
+ l.setHoveredEdge(f.id), l.refreshEdgeStyles(), t.editor.mode.value === "edit" && O.canShowEdgeTool() && L.show(f.id, M);
1994
+ }), D = (f) => L.move(f), r.container.addEventListener("mousemove", D), r.on("edge:mouseleave", () => {
1995
+ l.setHoveredEdge(null), l.refreshEdgeStyles(), L.remove();
1996
+ }), r.on("edge:click", ({ edge: f, e: M }) => {
1997
+ M.target?.closest?.(".flow-canvas-edge-delete-tool") && t.editor.mode.value === "edit" && (L.remove(), t.editor.executeCommand({
1998
+ id: T(),
1994
1999
  source: "user:toolbar",
1995
2000
  label: "删除连线",
1996
2001
  timestamp: Date.now(),
1997
- commands: [{ type: "edge.remove", edgeId: h.id }]
2002
+ commands: [{ type: "edge.remove", edgeId: f.id }]
1998
2003
  }));
1999
- }), n.value?.addEventListener("keydown", H), l.syncFlowModel(t.editor.flowModel.value), de(
2004
+ }), n.value?.addEventListener("keydown", ue), l.syncFlowModel(t.editor.flowModel.value), le(
2000
2005
  () => t.editor.flowModel.value,
2001
- (h) => l.syncFlowModel(h)
2002
- ), de(
2006
+ (f) => l.syncFlowModel(f)
2007
+ ), le(
2003
2008
  () => t.editor.selectionMode.value,
2004
- (h) => {
2005
- if (j?.(), j = null, h) {
2006
- ae(!1), W.enableRubberband?.();
2007
- const _ = () => {
2008
- a.container.removeEventListener("mouseup", _), j = null, setTimeout(() => {
2009
+ (f) => {
2010
+ if (C?.(), C = null, f) {
2011
+ Ce(!1), J.enableRubberband?.();
2012
+ const M = () => {
2013
+ r.container.removeEventListener("mouseup", M), C = null, setTimeout(() => {
2009
2014
  t.editor.selectionMode.value && t.editor.setSelectionMode(!1);
2010
2015
  }, 50);
2011
2016
  };
2012
- a.container.addEventListener("mouseup", _), j = () => a.container.removeEventListener("mouseup", _);
2017
+ r.container.addEventListener("mouseup", M), C = () => r.container.removeEventListener("mouseup", M);
2013
2018
  } else
2014
- W.disableRubberband?.(), ae(!0);
2019
+ J.disableRubberband?.(), Ce(!0);
2015
2020
  }
2016
- ), de(
2021
+ ), le(
2017
2022
  () => t.editor.mode.value,
2018
- (h) => {
2019
- const _ = h === "edit";
2020
- ae(!0), _ ? W.enableSelection?.() : W.disableSelection?.();
2023
+ (f) => {
2024
+ const M = f === "edit";
2025
+ Ce(!0), M ? J.enableSelection?.() : J.disableSelection?.();
2021
2026
  }
2022
2027
  );
2023
- }), Ne(() => {
2024
- d.cleanup(), p && clearTimeout(p), S?.remove(), j?.(), I && a?.container?.removeEventListener("mousemove", I), n.value?.removeEventListener("keydown", H), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2028
+ }), Se(() => {
2029
+ d.cleanup(), y && clearTimeout(y), L?.remove(), C?.(), D && r?.container?.removeEventListener("mousemove", D), n.value?.removeEventListener("keydown", ue), t.editor._pluginManager.detachRuntime(), t.editor.api.value = null;
2025
2030
  for (const x of Object.keys(t.editor.extendedApi))
2026
2031
  delete t.editor.extendedApi[x];
2027
- u?.dispose(), l?.dispose(), c?.dispose(), a?.dispose();
2028
- }), (x, k) => (C(), M("div", {
2032
+ c?.dispose(), l?.dispose(), a?.dispose(), r?.dispose();
2033
+ }), (x, E) => (k(), S("div", {
2029
2034
  ref_key: "rootRef",
2030
2035
  ref: n,
2031
2036
  class: "flow-canvas-runtime-core",
2032
2037
  tabindex: "0"
2033
2038
  }, [
2034
- $("div", {
2039
+ A("div", {
2035
2040
  ref_key: "containerRef",
2036
2041
  ref: i,
2037
2042
  class: "flow-canvas-runtime-core__graph"
2038
2043
  }, null, 512),
2039
- $("div", {
2040
- ref_key: "overlayContainerRef",
2041
- ref: r,
2042
- class: "flow-canvas-runtime-core__overlay"
2043
- }, [
2044
- (C(!0), M(se, null, ge(Y.value, (y) => (C(), M("div", {
2045
- key: `badge-${y.nodeId}`,
2044
+ A("div", Nt, [
2045
+ (k(!0), S(ie, null, ye(Y.value, (w) => (k(), S("div", {
2046
+ key: `badge-${w.nodeId}`,
2046
2047
  class: "flow-canvas-runtime-core__badge",
2047
- style: we({ left: `${y.x}px`, top: `${y.y}px`, backgroundColor: y.badge.color })
2048
- }, ue(y.badge.text), 5))), 128)),
2049
- V.value ? (C(), be(Dt, {
2048
+ style: me({ left: `${w.x}px`, top: `${w.y}px`, backgroundColor: w.badge.color })
2049
+ }, de(w.badge.text), 5))), 128)),
2050
+ G.value ? (k(), ve(St, {
2050
2051
  key: 0,
2051
2052
  ref_key: "quickAddPopoverRef",
2052
- ref: pe,
2053
- node: V.value.node,
2054
- "port-position": V.value.portPosition,
2055
- "tooltip-text": ee.value.tooltipText,
2056
- onOpen: ne,
2057
- onStartDrag: Ee,
2058
- onMouseenter: N,
2059
- onMouseleave: U
2053
+ ref: se,
2054
+ node: G.value.node,
2055
+ "port-position": G.value.portPosition,
2056
+ "tooltip-text": X.value.tooltipText,
2057
+ onOpen: ee,
2058
+ onStartDrag: ke,
2059
+ onMouseenter: v,
2060
+ onMouseleave: I
2060
2061
  }, {
2061
- default: De(() => [
2062
- ce(x.$slots, "quick-add-panel", {
2063
- node: V.value.node,
2062
+ default: Ne(() => [
2063
+ fe(x.$slots, "quick-add-panel", {
2064
+ node: G.value.node,
2064
2065
  api: s.editor.api.value,
2065
- insertNodeToRight: (y) => J(V.value.node.id, y),
2066
- closePopover: () => pe.value?.closePopover()
2066
+ insertNodeToRight: (w) => te(G.value.node.id, w),
2067
+ closePopover: () => se.value?.closePopover()
2067
2068
  }, void 0, !0)
2068
2069
  ]),
2069
2070
  _: 3
2070
- }, 8, ["node", "port-position", "tooltip-text"])) : O("", !0),
2071
- X.value ? (C(), be(It, {
2071
+ }, 8, ["node", "port-position", "tooltip-text"])) : H("", !0),
2072
+ Q.value ? (k(), ve(Ct, {
2072
2073
  key: 1,
2073
- node: X.value.node,
2074
- position: X.value.position,
2075
- config: Z.value,
2076
- behavior: X.value.behavior,
2077
- onAction: ye,
2078
- onMouseenter: le(E),
2079
- onMouseleave: le(b)
2080
- }, null, 8, ["node", "position", "config", "behavior", "onMouseenter", "onMouseleave"])) : O("", !0),
2081
- (C(!0), M(se, null, ge(oe.value, (y) => (C(), M("div", {
2082
- key: y.node.id,
2083
- class: "flow-canvas-runtime-core__node-overlay",
2084
- onMouseenter: k[0] || (k[0] = //@ts-ignore
2085
- (...D) => le(E) && le(E)(...D)),
2086
- onMouseleave: k[1] || (k[1] = //@ts-ignore
2087
- (...D) => le(b) && le(b)(...D))
2088
- }, [
2089
- ce(x.$slots, "node-overlay", {
2090
- node: y.node,
2091
- screenAnchors: y.screenAnchors,
2092
- api: s.editor.api.value
2093
- }, void 0, !0)
2094
- ], 32))), 128))
2095
- ], 512)
2074
+ node: Q.value.node,
2075
+ position: Q.value.position,
2076
+ config: q.value,
2077
+ behavior: Q.value.behavior,
2078
+ "actions-offset": Q.value.behavior.actionsOffset,
2079
+ onAction: Z,
2080
+ onMouseenter: Ue(u),
2081
+ onMouseleave: N
2082
+ }, null, 8, ["node", "position", "config", "behavior", "actions-offset", "onMouseenter"])) : H("", !0)
2083
+ ])
2096
2084
  ], 512));
2097
2085
  }
2098
- }), ao = /* @__PURE__ */ re(_t, [["__scopeId", "data-v-bba2427b"]]), At = { class: "flow-canvas-node-palette" }, Pt = ["data-node-type"], Tt = { class: "flow-canvas-node-palette__item-label" }, Rt = /* @__PURE__ */ ie({
2086
+ }), ao = /* @__PURE__ */ ae(Dt, [["__scopeId", "data-v-96013976"]]), _t = { class: "flow-canvas-node-palette" }, Pt = ["data-node-type"], At = { class: "flow-canvas-node-palette__item-label" }, Tt = /* @__PURE__ */ re({
2099
2087
  __name: "canvas-node-palette",
2100
2088
  props: {
2101
2089
  editor: {},
2102
2090
  items: {}
2103
2091
  },
2104
2092
  setup(s) {
2105
- const e = s, t = B(), o = z(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
2093
+ const e = s, t = z(), o = j(() => e.items ? e.items : Object.keys(e.editor.schema.nodeTypes).map((n) => ({
2106
2094
  type: n,
2107
2095
  label: n.charAt(0).toUpperCase() + n.slice(1)
2108
2096
  })));
2109
- return de(
2097
+ return le(
2110
2098
  [() => e.editor.api.value, o, t],
2111
- ([n, i, r], a, l) => {
2099
+ ([n, i, r], l, a) => {
2112
2100
  if (!n || !r) return;
2113
2101
  const c = [];
2114
- for (const u of i) {
2115
- const d = r.querySelector(`[data-node-type="${u.type}"]`);
2116
- if (!d) continue;
2117
- const w = n.registerDndSource(d, () => ({
2118
- id: L(),
2119
- type: u.type,
2120
- label: u.label,
2102
+ for (const d of i) {
2103
+ const g = r.querySelector(`[data-node-type="${d.type}"]`);
2104
+ if (!g) continue;
2105
+ const p = n.registerDndSource(g, () => ({
2106
+ id: T(),
2107
+ type: d.type,
2108
+ label: d.label,
2121
2109
  position: { x: 0, y: 0 }
2122
2110
  }));
2123
- c.push(w);
2111
+ c.push(p);
2124
2112
  }
2125
- l(() => {
2126
- for (const u of c) u();
2113
+ a(() => {
2114
+ for (const d of c) d();
2127
2115
  });
2128
2116
  },
2129
2117
  { flush: "post" }
2130
- ), (n, i) => (C(), M("div", At, [
2131
- $("div", {
2118
+ ), (n, i) => (k(), S("div", _t, [
2119
+ A("div", {
2132
2120
  ref_key: "listRef",
2133
2121
  ref: t,
2134
2122
  class: "flow-canvas-node-palette__list"
2135
2123
  }, [
2136
- (C(!0), M(se, null, ge(o.value, (r) => (C(), M("div", {
2124
+ (k(!0), S(ie, null, ye(o.value, (r) => (k(), S("div", {
2137
2125
  key: r.type,
2138
2126
  class: "flow-canvas-node-palette__item",
2139
2127
  "data-node-type": r.type
2140
2128
  }, [
2141
- r.icon ? (C(), M("i", {
2129
+ r.icon ? (k(), S("i", {
2142
2130
  key: 0,
2143
- class: Q([r.icon, "flow-canvas-node-palette__item-icon"])
2144
- }, null, 2)) : O("", !0),
2145
- $("span", Tt, ue(r.label), 1)
2131
+ class: W([r.icon, "flow-canvas-node-palette__item-icon"])
2132
+ }, null, 2)) : H("", !0),
2133
+ A("span", At, de(r.label), 1)
2146
2134
  ], 8, Pt))), 128))
2147
2135
  ], 512)
2148
2136
  ]));
2149
2137
  }
2150
- }), $t = /* @__PURE__ */ re(Rt, [["__scopeId", "data-v-300314b7"]]), Lt = { class: "flow-canvas-layout" }, Bt = { class: "flow-canvas-layout__main" }, zt = { class: "flow-canvas-layout__content" }, Ot = {
2138
+ }), Rt = /* @__PURE__ */ ae(Tt, [["__scopeId", "data-v-300314b7"]]), $t = { class: "flow-canvas-layout" }, Lt = { class: "flow-canvas-layout__main" }, Bt = { class: "flow-canvas-layout__content" }, zt = {
2151
2139
  key: 0,
2152
2140
  class: "flow-canvas-layout__footer"
2153
- }, jt = /* @__PURE__ */ ie({
2141
+ }, Ot = /* @__PURE__ */ re({
2154
2142
  __name: "canvas-layout",
2155
2143
  props: {
2156
2144
  sidebarCollapsed: { type: Boolean, default: !1 },
@@ -2162,33 +2150,36 @@ const Ct = { class: "flow-canvas-node-actions__bar" }, Et = /* @__PURE__ */ ie({
2162
2150
  },
2163
2151
  emits: ["update:sidebarCollapsed"],
2164
2152
  setup(s) {
2165
- return (e, t) => (C(), M("div", Lt, [
2166
- !s.hideSidebar && (e.$slots.sidebar || s.editor) ? (C(), M("aside", {
2153
+ return (e, t) => (k(), S("div", $t, [
2154
+ !s.hideSidebar && (e.$slots.sidebar || s.editor) ? (k(), S("aside", {
2167
2155
  key: 0,
2168
- class: Q(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
2169
- style: we({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
2156
+ class: W(["flow-canvas-layout__sidebar", { "is-collapsed": s.sidebarCollapsed }]),
2157
+ style: me({ width: s.sidebarCollapsed ? "0px" : `${s.sidebarWidth}px` })
2170
2158
  }, [
2171
- ce(e.$slots, "sidebar", {}, () => [
2172
- s.editor ? (C(), be($t, {
2159
+ fe(e.$slots, "sidebar", {}, () => [
2160
+ s.editor ? (k(), ve(Rt, {
2173
2161
  key: 0,
2174
2162
  editor: s.editor,
2175
2163
  items: s.paletteItems
2176
- }, null, 8, ["editor", "items"])) : O("", !0)
2164
+ }, null, 8, ["editor", "items"])) : H("", !0)
2177
2165
  ], !0)
2178
- ], 6)) : O("", !0),
2179
- $("div", Bt, [
2180
- $("div", zt, [
2181
- ce(e.$slots, "default", {}, void 0, !0)
2166
+ ], 6)) : H("", !0),
2167
+ A("div", Lt, [
2168
+ A("div", Bt, [
2169
+ fe(e.$slots, "default", {}, void 0, !0)
2182
2170
  ]),
2183
- !s.hideFooter && e.$slots.footer ? (C(), M("div", Ot, [
2184
- ce(e.$slots, "footer", {}, void 0, !0)
2185
- ])) : O("", !0)
2171
+ !s.hideFooter && e.$slots.footer ? (k(), S("div", zt, [
2172
+ fe(e.$slots, "footer", {}, void 0, !0)
2173
+ ])) : H("", !0)
2186
2174
  ])
2187
2175
  ]));
2188
2176
  }
2189
- }), lo = /* @__PURE__ */ re(jt, [["__scopeId", "data-v-26f35b6b"]]);
2177
+ }), lo = /* @__PURE__ */ ae(Ot, [["__scopeId", "data-v-26f35b6b"]]), jt = ["undo", "redo"];
2190
2178
  function Ht(s) {
2191
- const e = new Set(s?.exclude), t = [
2179
+ const e = new Set(s?.include), t = /* @__PURE__ */ new Set([
2180
+ ...jt.filter((a) => !e.has(a)),
2181
+ ...s?.exclude ?? []
2182
+ ]), o = [
2192
2183
  {
2193
2184
  id: "undo",
2194
2185
  type: "undo",
@@ -2205,7 +2196,7 @@ function Ht(s) {
2205
2196
  description: "重做",
2206
2197
  order: 11
2207
2198
  }
2208
- ], o = [
2199
+ ], n = [
2209
2200
  {
2210
2201
  id: "select",
2211
2202
  type: "select",
@@ -2246,7 +2237,7 @@ function Ht(s) {
2246
2237
  description: "导出为图片",
2247
2238
  order: 24
2248
2239
  }
2249
- ], n = [
2240
+ ], i = [
2250
2241
  {
2251
2242
  id: "zoom-out",
2252
2243
  type: "zoom-out",
@@ -2264,7 +2255,7 @@ function Ht(s) {
2264
2255
  description: "放大画布",
2265
2256
  order: 32
2266
2257
  }
2267
- ], i = [
2258
+ ], r = [
2268
2259
  {
2269
2260
  id: "reset",
2270
2261
  type: "reset",
@@ -2274,9 +2265,9 @@ function Ht(s) {
2274
2265
  order: 40
2275
2266
  }
2276
2267
  ];
2277
- return [...[...t, ...o].filter(
2278
- (a) => !e.has(a.type)
2279
- ), ...n, ...i];
2268
+ return [...[...o, ...n].filter(
2269
+ (a) => !t.has(a.type)
2270
+ ), ...i, ...r];
2280
2271
  }
2281
2272
  const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2282
2273
  key: 0,
@@ -2284,7 +2275,7 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2284
2275
  }, qt = { class: "flow-canvas-toolbar__group" }, Gt = {
2285
2276
  key: 0,
2286
2277
  class: "flow-canvas-toolbar__zoom-display"
2287
- }, Vt = ["data-description", "disabled", "onClick"], Wt = ["textContent"], Qt = /* @__PURE__ */ ie({
2278
+ }, Vt = ["data-description", "disabled", "onClick"], Wt = ["textContent"], Qt = /* @__PURE__ */ re({
2288
2279
  __name: "canvas-toolbar",
2289
2280
  props: {
2290
2281
  items: {},
@@ -2292,42 +2283,42 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2292
2283
  editor: {}
2293
2284
  },
2294
2285
  setup(s) {
2295
- const e = s, t = z(() => e.items ? e.items : Ht({ exclude: e.exclude })), o = B(1);
2286
+ const e = s, t = j(() => e.items ? e.items : Ht({ exclude: e.exclude })), o = z(1);
2296
2287
  let n = null;
2297
- de(
2288
+ le(
2298
2289
  () => e.editor.api.value,
2299
- (f) => {
2300
- n?.(), n = null, f && (o.value = f.getZoom(), n = f.onGraphEvent("scale", () => {
2301
- o.value = f.getZoom();
2290
+ (u) => {
2291
+ n?.(), n = null, u && (o.value = u.getZoom(), n = u.onGraphEvent("scale", () => {
2292
+ o.value = u.getZoom();
2302
2293
  }));
2303
2294
  },
2304
2295
  { immediate: !0 }
2305
- ), ze(() => {
2296
+ ), Le(() => {
2306
2297
  n?.();
2307
2298
  });
2308
- const i = z(() => `${Math.round(o.value * 100)}%`), r = z(() => e.editor.api.value ? {
2299
+ const i = j(() => `${Math.round(o.value * 100)}%`), r = j(() => e.editor.api.value ? {
2309
2300
  api: e.editor.api.value,
2310
2301
  flowModel: e.editor.flowModel.value,
2311
2302
  history: e.editor.history,
2312
2303
  mode: e.editor.mode.value
2313
2304
  } : null);
2314
- function a(f) {
2315
- return f.visible === !1 ? !1 : typeof f.visible == "function" ? r.value ? f.visible(r.value) : !1 : !0;
2305
+ function l(u) {
2306
+ return u.visible === !1 ? !1 : typeof u.visible == "function" ? r.value ? u.visible(r.value) : !1 : !0;
2316
2307
  }
2317
- function l(f) {
2318
- return f.type === "select" ? e.editor.selectionMode.value : !1;
2308
+ function a(u) {
2309
+ return u.type === "select" ? e.editor.selectionMode.value : !1;
2319
2310
  }
2320
- function c(f) {
2321
- return !r.value || f.disabled === !0 ? !0 : typeof f.disabled == "function" ? f.disabled(r.value) : f.type === "undo" ? !e.editor.history.canUndo.value : f.type === "redo" ? !e.editor.history.canRedo.value : !1;
2311
+ function c(u) {
2312
+ return !r.value || u.disabled === !0 ? !0 : typeof u.disabled == "function" ? u.disabled(r.value) : u.type === "undo" ? !e.editor.history.canUndo.value : u.type === "redo" ? !e.editor.history.canRedo.value : !1;
2322
2313
  }
2323
- function u(f) {
2324
- if (!r.value || c(f)) return;
2325
- if (f.onClick) {
2326
- f.onClick(r.value);
2314
+ function d(u) {
2315
+ if (!r.value || c(u)) return;
2316
+ if (u.onClick) {
2317
+ u.onClick(r.value);
2327
2318
  return;
2328
2319
  }
2329
- const { api: E } = r.value;
2330
- switch (f.type) {
2320
+ const { api: N } = r.value;
2321
+ switch (u.type) {
2331
2322
  case "undo":
2332
2323
  e.editor.history.undo();
2333
2324
  break;
@@ -2335,21 +2326,21 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2335
2326
  e.editor.history.redo();
2336
2327
  break;
2337
2328
  case "zoom-in":
2338
- E.zoomIn(), o.value = E.getZoom();
2329
+ N.zoomIn(), o.value = N.getZoom();
2339
2330
  break;
2340
2331
  case "zoom-out":
2341
- E.zoomOut(), o.value = E.getZoom();
2332
+ N.zoomOut(), o.value = N.getZoom();
2342
2333
  break;
2343
2334
  case "fit":
2344
- E.zoomToFit();
2335
+ N.zoomToFit();
2345
2336
  break;
2346
2337
  case "reset":
2347
- E.zoomTo(1), E.scrollToOrigin(), o.value = 1;
2338
+ N.zoomTo(1), N.scrollToOrigin(), o.value = 1;
2348
2339
  break;
2349
2340
  case "export":
2350
- E.exportAsImage().then((b) => {
2351
- const m = URL.createObjectURL(b), p = document.createElement("a");
2352
- p.href = m, p.download = "canvas-export.png", p.click(), URL.revokeObjectURL(m);
2341
+ N.exportAsImage().then((b) => {
2342
+ const y = URL.createObjectURL(b), m = document.createElement("a");
2343
+ m.href = y, m.download = "canvas-export.png", m.click(), URL.revokeObjectURL(y);
2353
2344
  }).catch((b) => {
2354
2345
  console.warn("[flow-canvas] Export failed:", b);
2355
2346
  });
@@ -2360,44 +2351,44 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2360
2351
  case "search":
2361
2352
  case "auto-layout":
2362
2353
  case "minimap":
2363
- console.warn(`[flow-canvas] "${f.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2354
+ console.warn(`[flow-canvas] "${u.type}" toolbar item has no built-in handler. Provide an onClick callback.`);
2364
2355
  break;
2365
2356
  default:
2366
- f.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${f.type}". Provide an onClick handler.`);
2357
+ u.type !== "custom" && console.warn(`[flow-canvas] No default handler for toolbar type "${u.type}". Provide an onClick handler.`);
2367
2358
  break;
2368
2359
  }
2369
2360
  }
2370
- const d = z(() => t.value.filter(a)), w = z(() => {
2371
- const f = /* @__PURE__ */ new Map(), E = [];
2372
- for (const b of d.value) {
2373
- const m = b.group ?? "default";
2374
- f.has(m) || (f.set(m, []), E.push(m)), f.get(m).push(b);
2361
+ const g = j(() => t.value.filter(l)), p = j(() => {
2362
+ const u = /* @__PURE__ */ new Map(), N = [];
2363
+ for (const b of g.value) {
2364
+ const y = b.group ?? "default";
2365
+ u.has(y) || (u.set(y, []), N.push(y)), u.get(y).push(b);
2375
2366
  }
2376
- return E.map((b) => ({ name: b, items: f.get(b) })).filter((b) => b.items.length > 0);
2367
+ return N.map((b) => ({ name: b, items: u.get(b) })).filter((b) => b.items.length > 0);
2377
2368
  });
2378
- return (f, E) => (C(), M("div", Ft, [
2379
- (C(!0), M(se, null, ge(w.value, (b, m) => (C(), M(se, {
2369
+ return (u, N) => (k(), S("div", Ft, [
2370
+ (k(!0), S(ie, null, ye(p.value, (b, y) => (k(), S(ie, {
2380
2371
  key: b.name
2381
2372
  }, [
2382
- m > 0 ? (C(), M("div", Ut)) : O("", !0),
2383
- $("div", qt, [
2384
- (C(!0), M(se, null, ge(b.items, (p) => (C(), M(se, {
2385
- key: p.id
2373
+ y > 0 ? (k(), S("div", Ut)) : H("", !0),
2374
+ A("div", qt, [
2375
+ (k(!0), S(ie, null, ye(b.items, (m) => (k(), S(ie, {
2376
+ key: m.id
2386
2377
  }, [
2387
- p.type === "zoom-display" ? (C(), M("span", Gt, ue(i.value), 1)) : (C(), M("button", {
2378
+ m.type === "zoom-display" ? (k(), S("span", Gt, de(i.value), 1)) : (k(), S("button", {
2388
2379
  key: 1,
2389
- class: Q(["flow-canvas-toolbar__btn", { "is-disabled": c(p), "is-active": l(p) }]),
2390
- "data-description": p.description,
2391
- disabled: c(p),
2392
- onClick: (P) => u(p)
2380
+ class: W(["flow-canvas-toolbar__btn", { "is-disabled": c(m), "is-active": a(m) }]),
2381
+ "data-description": m.description,
2382
+ disabled: c(m),
2383
+ onClick: (R) => d(m)
2393
2384
  }, [
2394
- p.component ? (C(), be(Ve(p.component), { key: 0 })) : p.icon ? (C(), M("i", {
2385
+ m.component ? (k(), ve(qe(m.component), { key: 0 })) : m.icon ? (k(), S("i", {
2395
2386
  key: 1,
2396
- class: Q(p.icon)
2397
- }, null, 2)) : (C(), M("span", {
2387
+ class: W(m.icon)
2388
+ }, null, 2)) : (k(), S("span", {
2398
2389
  key: 2,
2399
2390
  class: "flow-canvas-toolbar__text",
2400
- textContent: ue(p.text ?? p.description ?? p.id)
2391
+ textContent: de(m.text ?? m.description ?? m.id)
2401
2392
  }, null, 8, Wt))
2402
2393
  ], 10, Vt))
2403
2394
  ], 64))), 128))
@@ -2405,49 +2396,49 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2405
2396
  ], 64))), 128))
2406
2397
  ]));
2407
2398
  }
2408
- }), co = /* @__PURE__ */ re(Qt, [["__scopeId", "data-v-ca50cd45"]]), Xt = { class: "flow-canvas-default-node__ep-label" }, Yt = {
2399
+ }), co = /* @__PURE__ */ ae(Qt, [["__scopeId", "data-v-ca50cd45"]]), Xt = { class: "flow-canvas-default-node__ep-label" }, Kt = {
2409
2400
  key: 1,
2410
2401
  class: "flow-canvas-default-node__diamond"
2411
- }, Kt = {
2402
+ }, Yt = {
2412
2403
  key: 2,
2413
2404
  class: "flow-canvas-default-node__task-label"
2414
- }, Zt = /* @__PURE__ */ ie({
2405
+ }, Zt = /* @__PURE__ */ re({
2415
2406
  __name: "default-node",
2416
2407
  setup(s) {
2417
- const t = We("getNode")?.(), o = z(() => t?.getData?.() ?? null), n = z(() => o.value?.label || o.value?.type || ""), i = {
2408
+ const t = Ge("getNode")?.(), o = j(() => t?.getData?.() ?? null), n = j(() => o.value?.label || o.value?.type || ""), i = {
2418
2409
  start: "canvas-kaishi",
2419
2410
  end: "canvas-stop",
2420
2411
  "parallel-gateway": "canvas-bingxingwangguan",
2421
2412
  "branch-gateway": "canvas-fenzhiwangguan",
2422
2413
  "converge-gateway": "canvas-huijuwangguan",
2423
2414
  "conditional-parallel-gateway": "canvas-tiaojianbingxingwangguan"
2424
- }, r = /* @__PURE__ */ new Set(["start", "end"]), a = /* @__PURE__ */ new Set([
2415
+ }, r = /* @__PURE__ */ new Set(["start", "end"]), l = /* @__PURE__ */ new Set([
2425
2416
  "parallel-gateway",
2426
2417
  "branch-gateway",
2427
2418
  "converge-gateway",
2428
2419
  "conditional-parallel-gateway"
2429
- ]), l = z(() => {
2430
- const u = o.value?.type ?? "";
2431
- return r.has(u) ? "endpoint" : a.has(u) ? "gateway" : "task";
2432
- }), c = z(() => i[o.value?.type ?? ""] ?? "");
2433
- return (u, d) => (C(), M("div", {
2434
- class: Q(["flow-canvas-default-node", `is-${l.value}`])
2420
+ ]), a = j(() => {
2421
+ const d = o.value?.type ?? "";
2422
+ return r.has(d) ? "endpoint" : l.has(d) ? "gateway" : "task";
2423
+ }), c = j(() => i[o.value?.type ?? ""] ?? "");
2424
+ return (d, g) => (k(), S("div", {
2425
+ class: W(["flow-canvas-default-node", `is-${a.value}`])
2435
2426
  }, [
2436
- l.value === "endpoint" ? (C(), M(se, { key: 0 }, [
2437
- c.value ? (C(), M("i", {
2427
+ a.value === "endpoint" ? (k(), S(ie, { key: 0 }, [
2428
+ c.value ? (k(), S("i", {
2438
2429
  key: 0,
2439
- class: Q([["flow-canvas-icon", c.value], "flow-canvas-default-node__ep-icon"])
2440
- }, null, 2)) : O("", !0),
2441
- $("span", Xt, ue(n.value), 1)
2442
- ], 64)) : l.value === "gateway" ? (C(), M("div", Yt, [
2443
- c.value ? (C(), M("i", {
2430
+ class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__ep-icon"])
2431
+ }, null, 2)) : H("", !0),
2432
+ A("span", Xt, de(n.value), 1)
2433
+ ], 64)) : a.value === "gateway" ? (k(), S("div", Kt, [
2434
+ c.value ? (k(), S("i", {
2444
2435
  key: 0,
2445
- class: Q([["flow-canvas-icon", c.value], "flow-canvas-default-node__gw-icon"])
2446
- }, null, 2)) : O("", !0)
2447
- ])) : (C(), M("span", Kt, ue(n.value), 1))
2436
+ class: W([["flow-canvas-icon", c.value], "flow-canvas-default-node__gw-icon"])
2437
+ }, null, 2)) : H("", !0)
2438
+ ])) : (k(), S("span", Yt, de(n.value), 1))
2448
2439
  ], 2));
2449
2440
  }
2450
- }), Jt = /* @__PURE__ */ re(Zt, [["__scopeId", "data-v-c88cdae7"]]), eo = {
2441
+ }), Jt = /* @__PURE__ */ ae(Zt, [["__scopeId", "data-v-c88cdae7"]]), eo = {
2451
2442
  start: { label: "开始", icon: "flow-canvas-icon canvas-kaishi", width: 88, height: 40 },
2452
2443
  end: { label: "结束", icon: "flow-canvas-icon canvas-stop", width: 88, height: 40 },
2453
2444
  empty: { label: "空节点", icon: "flow-canvas-icon canvas-jiedi", width: 240, height: 48 },
@@ -2460,10 +2451,10 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2460
2451
  width: 64,
2461
2452
  height: 64
2462
2453
  }
2463
- }, Le = (s, e) => ({
2454
+ }, Re = (s, e) => ({
2464
2455
  stroke: e.hovered ? "#3a84ff" : "#abb5cc",
2465
2456
  strokeWidth: 2
2466
- }), Be = {
2457
+ }), $e = {
2467
2458
  attrs: {
2468
2459
  line: {
2469
2460
  stroke: "#abb5cc",
@@ -2475,22 +2466,22 @@ const Ft = { class: "flow-canvas-toolbar" }, Ut = {
2475
2466
  manhattan: {
2476
2467
  router: { name: "manhattan", args: { padding: 10, maxDirectionChange: 90 } },
2477
2468
  connector: { name: "rounded", args: { radius: 8 } },
2478
- style: Le,
2479
- x6EdgeConfig: Be
2469
+ style: Re,
2470
+ x6EdgeConfig: $e
2480
2471
  },
2481
2472
  bezier: {
2482
2473
  connector: { name: "smooth" },
2483
- style: Le,
2484
- x6EdgeConfig: Be
2474
+ style: Re,
2475
+ x6EdgeConfig: $e
2485
2476
  }
2486
2477
  };
2487
2478
  function uo(s) {
2488
2479
  const e = s?.nodeTypes ?? eo, t = {}, o = [];
2489
- for (const [r, a] of Object.entries(e)) {
2490
- const l = a.width ?? 150, c = a.height ?? 50;
2480
+ for (const [r, l] of Object.entries(e)) {
2481
+ const a = l.width ?? 150, c = l.height ?? 50;
2491
2482
  t[r] = {
2492
2483
  component: Jt,
2493
- getSize: () => ({ width: l, height: c }),
2484
+ getSize: () => ({ width: a, height: c }),
2494
2485
  getPorts: () => [
2495
2486
  { id: "top", group: "top" },
2496
2487
  { id: "right", group: "right" },
@@ -2499,8 +2490,8 @@ function uo(s) {
2499
2490
  ]
2500
2491
  }, o.push({
2501
2492
  type: r,
2502
- label: a.label ?? r,
2503
- icon: a.icon
2493
+ label: l.label ?? r,
2494
+ icon: l.icon
2504
2495
  });
2505
2496
  }
2506
2497
  const n = {
@@ -2519,22 +2510,22 @@ function fo(s) {
2519
2510
  transformCommand(e, t, o) {
2520
2511
  for (const n of e.commands) {
2521
2512
  if (n.type !== "edge.add" && n.type !== "edge.reconnect") continue;
2522
- const i = o.flowModel.value, r = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId, a = n.type === "edge.add" ? n.edge.target.nodeId : n.target?.nodeId;
2523
- if (!r || !a) continue;
2524
- const l = i.nodes[r], c = i.nodes[a];
2525
- if (!l || !c) continue;
2526
- const u = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, d = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, w = u ? l.ports?.find((p) => p.id === u) : void 0, f = d ? c.ports?.find((p) => p.id === d) : void 0, E = n.type === "edge.reconnect" ? n.edgeId : void 0, b = Object.values(i.edges).filter((p) => p.id !== E), m = s({
2513
+ const i = o.flowModel.value, r = n.type === "edge.add" ? n.edge.source.nodeId : n.source?.nodeId, l = n.type === "edge.add" ? n.edge.target.nodeId : n.target?.nodeId;
2514
+ if (!r || !l) continue;
2515
+ const a = i.nodes[r], c = i.nodes[l];
2516
+ if (!a || !c) continue;
2517
+ const d = n.type === "edge.add" ? n.edge.source.portId : n.source?.portId, g = n.type === "edge.add" ? n.edge.target.portId : n.target?.portId, p = d ? a.ports?.find((m) => m.id === d) : void 0, u = g ? c.ports?.find((m) => m.id === g) : void 0, N = n.type === "edge.reconnect" ? n.edgeId : void 0, b = Object.values(i.edges).filter((m) => m.id !== N), y = s({
2527
2518
  flowModel: i,
2528
- sourceNode: l,
2519
+ sourceNode: a,
2529
2520
  targetNode: c,
2530
- sourcePort: w,
2531
- targetPort: f,
2521
+ sourcePort: p,
2522
+ targetPort: u,
2532
2523
  existingEdges: b
2533
2524
  });
2534
- if (!m.valid)
2525
+ if (!y.valid)
2535
2526
  return {
2536
2527
  rejected: !0,
2537
- reason: m.reason ?? "Connection validation failed",
2528
+ reason: y.reason ?? "Connection validation failed",
2538
2529
  code: "validation_failed"
2539
2530
  };
2540
2531
  }
@@ -2552,7 +2543,7 @@ function po(s) {
2552
2543
  n.graph.use(
2553
2544
  new i({
2554
2545
  enabled: !0,
2555
- rubberband: !1,
2546
+ rubberband: e,
2556
2547
  multiple: t,
2557
2548
  movable: o,
2558
2549
  showNodeSelectionBox: !0,
@@ -2631,53 +2622,53 @@ function vo() {
2631
2622
  if (n && t.key === "c") {
2632
2623
  const i = o.graph.getSelectedCells?.() ?? [];
2633
2624
  if (!i.length) return !1;
2634
- const r = o.flowModel.value, a = new Set(i.filter((u) => u.isNode()).map((u) => u.id)), l = [...a].map((u) => r.nodes[u]).filter(Boolean);
2635
- if (!l.length) return !1;
2625
+ const r = o.flowModel.value, l = new Set(i.filter((d) => d.isNode()).map((d) => d.id)), a = [...l].map((d) => r.nodes[d]).filter(Boolean);
2626
+ if (!a.length) return !1;
2636
2627
  const c = Object.values(r.edges).filter(
2637
- (u) => a.has(u.source.nodeId) && a.has(u.target.nodeId)
2628
+ (d) => l.has(d.source.nodeId) && l.has(d.target.nodeId)
2638
2629
  );
2639
- return s = { nodes: l, edges: c }, e = 0, !0;
2630
+ return s = { nodes: a, edges: c }, e = 0, !0;
2640
2631
  }
2641
2632
  if (n && t.key === "v") {
2642
2633
  if (!s?.nodes.length) return !1;
2643
2634
  e++;
2644
- const i = e * 30, r = /* @__PURE__ */ new Map(), a = [];
2645
- for (const l of s.nodes) {
2646
- const c = `${l.id}_cp${L().slice(0, 6)}`;
2647
- r.set(l.id, c), a.push({
2635
+ const i = e * 30, r = /* @__PURE__ */ new Map(), l = [];
2636
+ for (const a of s.nodes) {
2637
+ const c = `${a.id}_cp${T().slice(0, 6)}`;
2638
+ r.set(a.id, c), l.push({
2648
2639
  type: "node.add",
2649
2640
  node: {
2650
- ...l,
2641
+ ...a,
2651
2642
  id: c,
2652
2643
  position: {
2653
- x: l.position.x + i,
2654
- y: l.position.y + i
2644
+ x: a.position.x + i,
2645
+ y: a.position.y + i
2655
2646
  },
2656
- payload: l.payload ? { ...l.payload } : {},
2657
- extensions: l.extensions ? { ...l.extensions } : void 0
2647
+ payload: a.payload ? { ...a.payload } : {},
2648
+ extensions: a.extensions ? { ...a.extensions } : void 0
2658
2649
  }
2659
2650
  });
2660
2651
  }
2661
- for (const l of s.edges) {
2662
- const c = r.get(l.source.nodeId), u = r.get(l.target.nodeId);
2663
- !c || !u || a.push({
2652
+ for (const a of s.edges) {
2653
+ const c = r.get(a.source.nodeId), d = r.get(a.target.nodeId);
2654
+ !c || !d || l.push({
2664
2655
  type: "edge.add",
2665
2656
  edge: {
2666
- ...l,
2667
- id: `${l.id}_cp${L().slice(0, 6)}`,
2668
- source: { ...l.source, nodeId: c },
2669
- target: { ...l.target, nodeId: u },
2670
- labels: l.labels?.map((d) => ({ ...d, id: `${d.id}_cp${L().slice(0, 6)}` })),
2671
- payload: l.payload ? { ...l.payload } : {}
2657
+ ...a,
2658
+ id: `${a.id}_cp${T().slice(0, 6)}`,
2659
+ source: { ...a.source, nodeId: c },
2660
+ target: { ...a.target, nodeId: d },
2661
+ labels: a.labels?.map((g) => ({ ...g, id: `${g.id}_cp${T().slice(0, 6)}` })),
2662
+ payload: a.payload ? { ...a.payload } : {}
2672
2663
  }
2673
2664
  });
2674
2665
  }
2675
- return a.length && o.executeCommand({
2676
- id: L(),
2666
+ return l.length && o.executeCommand({
2667
+ id: T(),
2677
2668
  source: "user:keyboard",
2678
2669
  label: "粘贴",
2679
2670
  timestamp: Date.now(),
2680
- commands: a
2671
+ commands: l
2681
2672
  }), !0;
2682
2673
  }
2683
2674
  return !1;
@@ -2687,21 +2678,21 @@ function vo() {
2687
2678
  export {
2688
2679
  K as CanvasConstraintError,
2689
2680
  lo as CanvasLayout,
2690
- $t as CanvasNodePalette,
2681
+ Rt as CanvasNodePalette,
2691
2682
  ao as CanvasRuntime,
2692
- Ye as CanvasSchemaError,
2683
+ Qe as CanvasSchemaError,
2693
2684
  co as CanvasToolbar,
2694
2685
  Jt as DefaultNode,
2695
- It as NodeActionsToolbar,
2696
- Dt as NodeQuickAddPopover,
2697
- Se as applyCanvasCommand,
2686
+ Ct as NodeActionsToolbar,
2687
+ St as NodeQuickAddPopover,
2688
+ Me as applyCanvasCommand,
2698
2689
  vo as clipboardPlugin,
2699
2690
  fo as connectionValidatorPlugin,
2700
- ct as createCanvasHistory,
2691
+ lt as createCanvasHistory,
2701
2692
  uo as createDefaultSchema,
2702
2693
  Ht as createDefaultToolbarItems,
2703
2694
  io as createEmptyFlowModel,
2704
- L as generateId,
2695
+ T as generateId,
2705
2696
  ho as minimapPlugin,
2706
2697
  po as selectionPlugin,
2707
2698
  go as snaplinePlugin,