@html-graph/html-graph 0.0.58 → 0.0.59

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/main.js CHANGED
@@ -161,12 +161,6 @@ class ee {
161
161
  constructor(e) {
162
162
  this.graphStore = e;
163
163
  }
164
- getAllNodeIds() {
165
- return this.graphStore.getAllNodeIds();
166
- }
167
- getAllPortIds() {
168
- return this.graphStore.getAllPortIds();
169
- }
170
164
  getNode(e) {
171
165
  const t = this.graphStore.getNode(e);
172
166
  return t === void 0 ? null : {
@@ -177,8 +171,8 @@ class ee {
177
171
  priority: t.priority
178
172
  };
179
173
  }
180
- getNodePortIds(e) {
181
- return this.graphStore.getNodePortIds(e);
174
+ getAllNodeIds() {
175
+ return this.graphStore.getAllNodeIds();
182
176
  }
183
177
  getPort(e) {
184
178
  const t = this.graphStore.getPort(e);
@@ -188,6 +182,12 @@ class ee {
188
182
  direction: t.direction
189
183
  };
190
184
  }
185
+ getAllPortIds() {
186
+ return this.graphStore.getAllPortIds();
187
+ }
188
+ getNodePortIds(e) {
189
+ return this.graphStore.getNodePortIds(e);
190
+ }
191
191
  getPortNodeId(e) {
192
192
  return this.graphStore.getPortNodeId(e) ?? null;
193
193
  }
@@ -198,12 +198,6 @@ class ee {
198
198
  const t = this.graphStore.getEdge(e);
199
199
  return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
200
200
  }
201
- getPortAdjacentEdgeIds(e) {
202
- return this.graphStore.getPortAdjacentEdgeIds(e);
203
- }
204
- getNodeAdjacentEdgeIds(e) {
205
- return this.graphStore.getNodeAdjacentEdgeIds(e);
206
- }
207
201
  getPortIncomingEdgeIds(e) {
208
202
  return this.graphStore.getPortIncomingEdgeIds(e);
209
203
  }
@@ -213,6 +207,9 @@ class ee {
213
207
  getPortCycleEdgeIds(e) {
214
208
  return this.graphStore.getPortCycleEdgeIds(e);
215
209
  }
210
+ getPortAdjacentEdgeIds(e) {
211
+ return this.graphStore.getPortAdjacentEdgeIds(e);
212
+ }
216
213
  getNodeIncomingEdgeIds(e) {
217
214
  return this.graphStore.getNodeIncomingEdgeIds(e);
218
215
  }
@@ -222,6 +219,9 @@ class ee {
222
219
  getNodeCycleEdgeIds(e) {
223
220
  return this.graphStore.getNodeCycleEdgeIds(e);
224
221
  }
222
+ getNodeAdjacentEdgeIds(e) {
223
+ return this.graphStore.getNodeAdjacentEdgeIds(e);
224
+ }
225
225
  }
226
226
  const l = {
227
227
  x: 0,
@@ -229,59 +229,59 @@ const l = {
229
229
  }, p = (r, e, t) => ({
230
230
  x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
231
231
  y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
232
- }), x = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), E = (r, e, t, s) => {
232
+ }), f = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), x = (r, e, t, s) => {
233
233
  const i = [
234
234
  l,
235
235
  { x: t, y: s },
236
236
  { x: t, y: -s }
237
237
  ].map((d) => p(d, r, l)).map((d) => ({ x: d.x + e.x, y: d.y + e.y })), n = `M ${i[0].x} ${i[0].y}`, h = `L ${i[1].x} ${i[1].y}`, c = `L ${i[2].x} ${i[2].y}`;
238
238
  return `${n} ${h} ${c}`;
239
- }, F = (r, e) => {
239
+ }, D = (r, e) => {
240
240
  const t = [];
241
241
  if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
242
242
  const s = r.length - 1;
243
243
  let o = 0, i = 0, n = 0;
244
244
  r.forEach((h, c) => {
245
- let d = 0, u = 0, w = 0;
245
+ let d = 0, g = 0, w = 0;
246
246
  const m = c > 0, y = c < s, v = m && y;
247
- if (m && (d = -o, u = -i, w = n), y) {
247
+ if (m && (d = -o, g = -i, w = n), y) {
248
248
  const j = r[c + 1];
249
249
  o = j.x - h.x, i = j.y - h.y, n = Math.sqrt(o * o + i * i);
250
250
  }
251
- const S = Math.min((v ? e : 0) / n, c < s - 1 ? 0.5 : 1), N = v ? { x: h.x + o * S, y: h.y + i * S } : h, M = Math.min((v ? e : 0) / w, c > 1 ? 0.5 : 1), b = v ? { x: h.x + d * M, y: h.y + u * M } : h;
252
- c > 0 && t.push(`L ${b.x} ${b.y}`), v && t.push(
253
- `C ${h.x} ${h.y} ${h.x} ${h.y} ${N.x} ${N.y}`
251
+ const P = Math.min((v ? e : 0) / n, c < s - 1 ? 0.5 : 1), M = v ? { x: h.x + o * P, y: h.y + i * P } : h, T = Math.min((v ? e : 0) / w, c > 1 ? 0.5 : 1), W = v ? { x: h.x + d * T, y: h.y + g * T } : h;
252
+ c > 0 && t.push(`L ${W.x} ${W.y}`), v && t.push(
253
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${M.x} ${M.y}`
254
254
  );
255
255
  });
256
256
  }
257
257
  return t.join(" ");
258
- }, T = () => {
258
+ }, N = () => {
259
259
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
260
260
  return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
261
261
  }, $ = () => {
262
262
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
263
263
  return r.style.transformOrigin = "50% 50%", r;
264
- }, D = (r, e) => {
264
+ }, L = (r, e) => {
265
265
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
266
266
  return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
267
- }, C = (r) => {
267
+ }, E = (r) => {
268
268
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
269
269
  return e.setAttribute("fill", r), e;
270
270
  };
271
271
  class te {
272
272
  constructor(e, t, s, o, i, n, h) {
273
- a(this, "svg", T());
273
+ a(this, "svg", N());
274
274
  a(this, "group", $());
275
275
  a(this, "line");
276
276
  a(this, "sourceArrow", null);
277
277
  a(this, "targetArrow", null);
278
- this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
278
+ this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
279
279
  }
280
280
  update(e, t, s, o, i) {
281
281
  this.group.style.transform = `scale(${t}, ${s})`;
282
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h);
282
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
283
283
  if (this.line.setAttribute("d", c), this.sourceArrow) {
284
- const d = E(
284
+ const d = x(
285
285
  n,
286
286
  l,
287
287
  this.arrowLength,
@@ -290,7 +290,7 @@ class te {
290
290
  this.sourceArrow.setAttribute("d", d);
291
291
  }
292
292
  if (this.targetArrow) {
293
- const d = E(
293
+ const d = x(
294
294
  h,
295
295
  e,
296
296
  -this.arrowLength,
@@ -314,24 +314,24 @@ class te {
314
314
  }, h = {
315
315
  x: i.x - s.x * this.curvature,
316
316
  y: i.y - s.y * this.curvature
317
- }, c = `M ${o.x} ${o.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${o.x} ${o.y} `, u = this.targetArrow ? "" : ` M ${i.x} ${i.y} L ${e.x} ${e.y}`;
318
- return `${d}${c}${u}`;
317
+ }, c = `M ${o.x} ${o.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${o.x} ${o.y} `, g = this.targetArrow ? "" : ` M ${i.x} ${i.y} L ${e.x} ${e.y}`;
318
+ return `${d}${c}${g}`;
319
319
  }
320
320
  }
321
321
  class re {
322
322
  constructor(e, t, s, o, i, n, h, c) {
323
- a(this, "svg", T());
323
+ a(this, "svg", N());
324
324
  a(this, "group", $());
325
325
  a(this, "line");
326
326
  a(this, "sourceArrow", null);
327
327
  a(this, "targetArrow", null);
328
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
328
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
329
329
  }
330
330
  update(e, t, s, o, i) {
331
331
  this.group.style.transform = `scale(${t}, ${s})`;
332
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h);
332
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h);
333
333
  if (this.line.setAttribute("d", c), this.sourceArrow) {
334
- const d = E(
334
+ const d = x(
335
335
  n,
336
336
  l,
337
337
  this.arrowLength,
@@ -340,7 +340,7 @@ class re {
340
340
  this.sourceArrow.setAttribute("d", d);
341
341
  }
342
342
  if (this.targetArrow) {
343
- const d = E(
343
+ const d = x(
344
344
  h,
345
345
  e,
346
346
  -this.arrowLength,
@@ -351,23 +351,23 @@ class re {
351
351
  }
352
352
  createLinePath(e, t, s) {
353
353
  const o = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, n = this.arrowLength + this.arrowOffset, h = p({ x: n, y: l.y }, t, l), c = p({ x: e.x - n, y: e.y }, s, e);
354
- return F([o, h, c, i], this.roundness);
354
+ return D([o, h, c, i], this.roundness);
355
355
  }
356
356
  }
357
357
  class se {
358
358
  constructor(e, t, s, o, i, n, h, c) {
359
- a(this, "svg", T());
359
+ a(this, "svg", N());
360
360
  a(this, "group", $());
361
361
  a(this, "line");
362
362
  a(this, "sourceArrow", null);
363
363
  a(this, "targetArrow", null);
364
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
364
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
365
365
  }
366
366
  update(e, t, s, o, i) {
367
367
  this.group.style.transform = `scale(${t}, ${s})`;
368
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t);
368
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t);
369
369
  if (this.line.setAttribute("d", c), this.sourceArrow) {
370
- const d = E(
370
+ const d = x(
371
371
  n,
372
372
  l,
373
373
  this.arrowLength,
@@ -376,7 +376,7 @@ class se {
376
376
  this.sourceArrow.setAttribute("d", d);
377
377
  }
378
378
  if (this.targetArrow) {
379
- const d = E(
379
+ const d = x(
380
380
  h,
381
381
  e,
382
382
  -this.arrowLength,
@@ -386,27 +386,27 @@ class se {
386
386
  }
387
387
  }
388
388
  createLinePath(e, t, s, o) {
389
- const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), u = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.x + u.x) / 2, h), m = e.y / 2, y = { x: o > 0 ? w : -h, y: d.y }, v = { x: y.x, y: m }, A = { x: o > 0 ? e.x - w : e.x + h, y: u.y }, S = { x: A.x, y: m };
390
- return F(
391
- [i, d, y, v, S, A, u, n],
389
+ const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), g = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.x + g.x) / 2, h), m = e.y / 2, y = { x: o > 0 ? w : -h, y: d.y }, v = { x: y.x, y: m }, S = { x: o > 0 ? e.x - w : e.x + h, y: g.y }, P = { x: S.x, y: m };
390
+ return D(
391
+ [i, d, y, v, P, S, g, n],
392
392
  this.roundness
393
393
  );
394
394
  }
395
395
  }
396
396
  class oe {
397
397
  constructor(e, t, s, o, i, n, h, c) {
398
- a(this, "svg", T());
398
+ a(this, "svg", N());
399
399
  a(this, "group", $());
400
400
  a(this, "line");
401
401
  a(this, "sourceArrow", null);
402
402
  a(this, "targetArrow", null);
403
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
403
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
404
404
  }
405
405
  update(e, t, s, o, i) {
406
406
  this.group.style.transform = `scale(${t}, ${s})`;
407
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, s);
407
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, s);
408
408
  if (this.line.setAttribute("d", c), this.sourceArrow) {
409
- const d = E(
409
+ const d = x(
410
410
  n,
411
411
  l,
412
412
  this.arrowLength,
@@ -415,7 +415,7 @@ class oe {
415
415
  this.sourceArrow.setAttribute("d", d);
416
416
  }
417
417
  if (this.targetArrow) {
418
- const d = E(
418
+ const d = x(
419
419
  h,
420
420
  e,
421
421
  -this.arrowLength,
@@ -425,28 +425,27 @@ class oe {
425
425
  }
426
426
  }
427
427
  createLinePath(e, t, s, o) {
428
- const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), u = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.y + u.y) / 2, h), m = e.x / 2, y = { x: d.x, y: o > 0 ? w : -h }, v = { x: m, y: y.y }, A = {
429
- x: u.x,
428
+ const i = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, n = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, c = h - this.roundness, d = p({ x: c, y: l.y }, t, l), g = p({ x: e.x - c, y: e.y }, s, e), w = Math.max((d.y + g.y) / 2, h), m = e.x / 2, y = { x: d.x, y: o > 0 ? w : -h }, v = { x: m, y: y.y }, S = {
429
+ x: g.x,
430
430
  y: o > 0 ? e.y - w : e.y + h
431
- }, S = { x: m, y: A.y };
432
- return F(
433
- [i, d, y, v, S, A, u, n],
431
+ }, P = { x: m, y: S.y };
432
+ return D(
433
+ [i, d, y, v, P, S, g, n],
434
434
  this.roundness
435
435
  );
436
436
  }
437
437
  }
438
438
  class ie {
439
439
  constructor(e, t, s, o, i, n, h) {
440
- a(this, "svg", T());
441
- a(this, "group", $());
440
+ a(this, "svg", N());
442
441
  a(this, "line");
443
442
  a(this, "arrow", null);
444
- this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), i && (this.arrow = C(e), this.group.appendChild(this.arrow));
443
+ this.arrowLength = s, this.arrowWidth = o, this.radius = n, this.smallRadius = h, this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
445
444
  }
446
445
  update(e, t, s, o) {
447
- const i = x(o, t, s), n = this.createLinePath(i);
446
+ const i = f(o, t, s), n = this.createLinePath(i);
448
447
  if (this.line.setAttribute("d", n), this.arrow) {
449
- const h = E(
448
+ const h = x(
450
449
  i,
451
450
  l,
452
451
  this.arrowLength,
@@ -460,25 +459,24 @@ class ie {
460
459
  { x: this.arrowLength, y: l.y },
461
460
  { x: n, y: h },
462
461
  { x: n, y: -h }
463
- ].map((m) => p(m, e, l)), u = [
462
+ ].map((m) => p(m, e, l)), g = [
464
463
  `M ${d[0].x} ${d[0].y}`,
465
464
  `A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
466
465
  `A ${s} ${s} 0 1 0 ${d[2].x} ${d[2].y}`,
467
466
  `A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
468
467
  ].join(" "), w = `M 0 0 L ${d[0].x} ${d[0].y} `;
469
- return `${this.arrow !== null ? "" : w}${u}`;
468
+ return `${this.arrow !== null ? "" : w}${g}`;
470
469
  }
471
470
  }
472
471
  class B {
473
472
  constructor(e, t, s, o, i, n, h, c) {
474
- a(this, "svg", T());
475
- a(this, "group", $());
473
+ a(this, "svg", N());
476
474
  a(this, "line");
477
475
  a(this, "arrow", null);
478
476
  a(this, "roundness");
479
477
  a(this, "linePoints");
480
- this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = h, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), i && (this.arrow = C(e), this.group.appendChild(this.arrow));
481
- const d = this.minPortOffset, u = this.side, w = this.arrowLength + d, m = w + 2 * u;
478
+ this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = h, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.line = L(e, t), this.svg.appendChild(this.line), i && (this.arrow = E(e), this.svg.appendChild(this.arrow));
479
+ const d = this.minPortOffset, g = this.side, w = this.arrowLength + d, m = w + 2 * g;
482
480
  this.linePoints = [
483
481
  { x: this.arrowLength, y: l.y },
484
482
  { x: w, y: l.y },
@@ -491,9 +489,9 @@ class B {
491
489
  ];
492
490
  }
493
491
  update(e, t, s, o) {
494
- const i = x(o, t, s), n = this.createLinePath(i);
492
+ const i = f(o, t, s), n = this.createLinePath(i);
495
493
  if (this.line.setAttribute("d", n), this.arrow) {
496
- const h = E(
494
+ const h = x(
497
495
  i,
498
496
  l,
499
497
  this.arrowLength,
@@ -506,25 +504,25 @@ class B {
506
504
  const t = this.linePoints.map(
507
505
  (o) => p(o, e, l)
508
506
  ), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
509
- return `${this.arrow ? "" : s}${F(t, this.roundness)}`;
507
+ return `${this.arrow ? "" : s}${D(t, this.roundness)}`;
510
508
  }
511
509
  }
512
- class G {
513
- constructor(e, t, s, o, i, n, h, c, d, u) {
514
- a(this, "svg", T());
510
+ class ne {
511
+ constructor(e, t, s, o, i, n, h, c, d) {
512
+ a(this, "svg", N());
515
513
  a(this, "group", $());
516
514
  a(this, "line");
517
515
  a(this, "sourceArrow", null);
518
516
  a(this, "targetArrow", null);
519
517
  a(this, "detourX");
520
518
  a(this, "detourY");
521
- this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.detourX = Math.cos(u) * d, this.detourY = Math.sin(u) * d, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
519
+ this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) * c, this.detourY = Math.sin(d) * c, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
522
520
  }
523
521
  update(e, t, s, o, i) {
524
522
  this.group.style.transform = `scale(${t}, ${s})`;
525
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t, s);
523
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
526
524
  if (this.line.setAttribute("d", c), this.sourceArrow) {
527
- const d = E(
525
+ const d = x(
528
526
  n,
529
527
  l,
530
528
  this.arrowLength,
@@ -533,7 +531,7 @@ class G {
533
531
  this.sourceArrow.setAttribute("d", d);
534
532
  }
535
533
  if (this.targetArrow) {
536
- const d = E(
534
+ const d = x(
537
535
  h,
538
536
  e,
539
537
  -this.arrowLength,
@@ -543,38 +541,58 @@ class G {
543
541
  }
544
542
  }
545
543
  createLinePath(e, t, s, o, i) {
546
- const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength + this.arrowOffset, d = p(
544
+ const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength, d = this.detourX * o, g = this.detourY * i, w = p(
547
545
  { x: c, y: l.y },
548
546
  t,
549
547
  l
550
- ), u = this.detourX * o, w = this.detourY * i, m = { x: d.x + u, y: d.y + w }, y = p(
548
+ ), m = {
549
+ x: w.x + d,
550
+ y: w.y + g
551
+ }, y = p(
551
552
  { x: e.x - c, y: e.y },
552
553
  s,
553
554
  e
554
- ), v = { x: y.x + u, y: y.y + w };
555
- return F(
556
- [n, d, m, v, y, h],
557
- this.roundness
558
- );
555
+ ), v = {
556
+ x: y.x + d,
557
+ y: y.y + g
558
+ }, S = { x: (m.x + v.x) / 2, y: (m.y + v.y) / 2 }, P = {
559
+ x: w.x + this.curvature * t.x,
560
+ y: w.y + this.curvature * t.y
561
+ }, M = {
562
+ x: y.x - this.curvature * s.x,
563
+ y: y.y - this.curvature * s.y
564
+ }, b = {
565
+ x: w.x + d,
566
+ y: w.y + g
567
+ }, T = {
568
+ x: y.x + d,
569
+ y: y.y + g
570
+ };
571
+ return [
572
+ `M ${n.x} ${n.y}`,
573
+ `L ${w.x} ${w.y}`,
574
+ `C ${P.x} ${P.y} ${b.x} ${b.y} ${S.x} ${S.y}`,
575
+ `C ${T.x} ${T.y} ${M.x} ${M.y} ${y.x} ${y.y}`,
576
+ `L ${h.x} ${h.y}`
577
+ ].join(" ");
559
578
  }
560
579
  }
561
- var P = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(P || {});
562
- class ne {
563
- constructor(e, t, s, o, i, n, h, c, d) {
564
- a(this, "svg", T());
580
+ class G {
581
+ constructor(e, t, s, o, i, n, h, c, d, g) {
582
+ a(this, "svg", N());
565
583
  a(this, "group", $());
566
584
  a(this, "line");
567
585
  a(this, "sourceArrow", null);
568
586
  a(this, "targetArrow", null);
569
587
  a(this, "detourX");
570
588
  a(this, "detourY");
571
- this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(d) * c, this.detourY = Math.sin(d) * c, this.svg.appendChild(this.group), this.line = D(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = C(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = C(e), this.group.appendChild(this.targetArrow));
589
+ this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.detourX = Math.cos(g) * d, this.detourY = Math.sin(g) * d, this.svg.appendChild(this.group), this.line = L(e, t), this.group.appendChild(this.line), n && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
572
590
  }
573
591
  update(e, t, s, o, i) {
574
592
  this.group.style.transform = `scale(${t}, ${s})`;
575
- const n = x(o, t, s), h = x(i, t, s), c = this.createLinePath(e, n, h, t, s);
593
+ const n = f(o, t, s), h = f(i, t, s), c = this.createLinePath(e, n, h, t, s);
576
594
  if (this.line.setAttribute("d", c), this.sourceArrow) {
577
- const d = E(
595
+ const d = x(
578
596
  n,
579
597
  l,
580
598
  this.arrowLength,
@@ -583,7 +601,7 @@ class ne {
583
601
  this.sourceArrow.setAttribute("d", d);
584
602
  }
585
603
  if (this.targetArrow) {
586
- const d = E(
604
+ const d = x(
587
605
  h,
588
606
  e,
589
607
  -this.arrowLength,
@@ -593,43 +611,23 @@ class ne {
593
611
  }
594
612
  }
595
613
  createLinePath(e, t, s, o, i) {
596
- const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength, d = this.detourX * o, u = this.detourY * i, w = p(
614
+ const n = this.sourceArrow ? p({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? p({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, c = this.arrowLength + this.arrowOffset, d = p(
597
615
  { x: c, y: l.y },
598
616
  t,
599
617
  l
600
- ), m = {
601
- x: w.x + d,
602
- y: w.y + u
603
- }, y = p(
618
+ ), g = this.detourX * o, w = this.detourY * i, m = { x: d.x + g, y: d.y + w }, y = p(
604
619
  { x: e.x - c, y: e.y },
605
620
  s,
606
621
  e
607
- ), v = {
608
- x: y.x + d,
609
- y: y.y + u
610
- }, A = { x: (m.x + v.x) / 2, y: (m.y + v.y) / 2 }, S = {
611
- x: w.x + this.curvature * t.x,
612
- y: w.y + this.curvature * t.y
613
- }, N = {
614
- x: y.x - this.curvature * s.x,
615
- y: y.y - this.curvature * s.y
616
- }, L = {
617
- x: w.x + d,
618
- y: w.y + u
619
- }, M = {
620
- x: y.x + d,
621
- y: y.y + u
622
- };
623
- return [
624
- `M ${n.x} ${n.y}`,
625
- `L ${w.x} ${w.y}`,
626
- `C ${S.x} ${S.y} ${L.x} ${L.y} ${A.x} ${A.y}`,
627
- `C ${M.x} ${M.y} ${N.x} ${N.y} ${y.x} ${y.y}`,
628
- `L ${h.x} ${h.y}`
629
- ].join(" ");
622
+ ), v = { x: y.x + g, y: y.y + w };
623
+ return D(
624
+ [n, d, m, v, y, h],
625
+ this.roundness
626
+ );
630
627
  }
631
628
  }
632
- const ae = (r) => (e) => e === P.PortCycle ? new ie(
629
+ var A = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(A || {});
630
+ const ae = (r) => (e) => e === A.PortCycle ? new ie(
633
631
  r.color,
634
632
  r.width,
635
633
  r.arrowLength,
@@ -637,7 +635,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
637
635
  r.hasSourceArrow || r.hasTargetArrow,
638
636
  r.cycleRadius,
639
637
  r.smallCycleRadius
640
- ) : e === P.NodeCycle ? new ne(
638
+ ) : e === A.NodeCycle ? new ne(
641
639
  r.color,
642
640
  r.width,
643
641
  r.curvature,
@@ -655,7 +653,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
655
653
  r.arrowWidth,
656
654
  r.hasSourceArrow,
657
655
  r.hasTargetArrow
658
- ), he = (r) => (e) => e === P.PortCycle ? new B(
656
+ ), he = (r) => (e) => e === A.PortCycle ? new B(
659
657
  r.color,
660
658
  r.width,
661
659
  r.arrowLength,
@@ -664,7 +662,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
664
662
  r.cycleSquareSide,
665
663
  r.arrowOffset,
666
664
  r.roundness
667
- ) : e === P.NodeCycle ? new G(
665
+ ) : e === A.NodeCycle ? new G(
668
666
  r.color,
669
667
  r.width,
670
668
  r.arrowLength,
@@ -684,7 +682,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
684
682
  r.hasSourceArrow,
685
683
  r.hasTargetArrow,
686
684
  r.roundness
687
- ), ce = (r) => (e) => e === P.PortCycle ? new B(
685
+ ), ce = (r) => (e) => e === A.PortCycle ? new B(
688
686
  r.color,
689
687
  r.width,
690
688
  r.arrowLength,
@@ -693,7 +691,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
693
691
  r.cycleSquareSide,
694
692
  r.arrowOffset,
695
693
  r.roundness
696
- ) : e === P.NodeCycle ? new G(
694
+ ) : e === A.NodeCycle ? new G(
697
695
  r.color,
698
696
  r.width,
699
697
  r.arrowLength,
@@ -704,7 +702,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
704
702
  r.roundness,
705
703
  r.detourDistance,
706
704
  r.detourDirection
707
- ) : new se(
705
+ ) : new oe(
708
706
  r.color,
709
707
  r.width,
710
708
  r.arrowLength,
@@ -713,7 +711,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
713
711
  r.hasSourceArrow,
714
712
  r.hasTargetArrow,
715
713
  r.roundness
716
- ), de = (r) => (e) => e === P.PortCycle ? new B(
714
+ ), de = (r) => (e) => e === A.PortCycle ? new B(
717
715
  r.color,
718
716
  r.width,
719
717
  r.arrowLength,
@@ -722,7 +720,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
722
720
  r.cycleSquareSide,
723
721
  r.arrowOffset,
724
722
  r.roundness
725
- ) : e === P.NodeCycle ? new G(
723
+ ) : e === A.NodeCycle ? new G(
726
724
  r.color,
727
725
  r.width,
728
726
  r.arrowLength,
@@ -733,7 +731,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
733
731
  r.roundness,
734
732
  r.detourDistance,
735
733
  r.detourDirection
736
- ) : new oe(
734
+ ) : new se(
737
735
  r.color,
738
736
  r.width,
739
737
  r.arrowLength,
@@ -743,7 +741,7 @@ const ae = (r) => (e) => e === P.PortCycle ? new ie(
743
741
  r.hasTargetArrow,
744
742
  r.roundness
745
743
  );
746
- class W {
744
+ class F {
747
745
  constructor(e) {
748
746
  a(this, "counter", 0);
749
747
  this.checkExists = e;
@@ -759,7 +757,7 @@ class W {
759
757
  this.counter = 0;
760
758
  }
761
759
  }
762
- class f extends Error {
760
+ class C extends Error {
763
761
  constructor() {
764
762
  super(...arguments);
765
763
  a(this, "name", "HtmlGraphError");
@@ -767,20 +765,20 @@ class f extends Error {
767
765
  }
768
766
  class le {
769
767
  constructor(e, t, s, o, i, n, h, c) {
770
- a(this, "nodeIdGenerator", new W(
768
+ a(this, "nodeIdGenerator", new F(
771
769
  (e) => this.graphStore.getNode(e) !== void 0
772
770
  ));
773
- a(this, "portIdGenerator", new W(
771
+ a(this, "portIdGenerator", new F(
774
772
  (e) => this.graphStore.getPort(e) !== void 0
775
773
  ));
776
- a(this, "edgeIdGenerator", new W(
774
+ a(this, "edgeIdGenerator", new F(
777
775
  (e) => this.graphStore.getEdge(e) !== void 0
778
776
  ));
779
777
  this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = o, this.defaultPortsCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
780
778
  }
781
779
  addNode(e, t, s, o, i, n, h) {
782
780
  if (e = this.nodeIdGenerator.create(e), this.graphStore.getNode(e) !== void 0)
783
- throw new f("failed to add node with existing id");
781
+ throw new C("failed to add node with existing id");
784
782
  this.graphStore.addNode(
785
783
  e,
786
784
  t,
@@ -801,21 +799,21 @@ class le {
801
799
  updateNode(e, t, s, o, i) {
802
800
  const n = this.graphStore.getNode(e);
803
801
  if (n === void 0)
804
- throw new f("failed to update nonexisting node");
802
+ throw new C("failed to update nonexisting node");
805
803
  n.x = t ?? n.x, n.y = s ?? n.y, n.centerFn = i ?? n.centerFn, this.htmlController.updateNodeCoordinates(e), o !== void 0 && (n.priority = o, this.htmlController.updateNodePriority(e));
806
804
  }
807
805
  removeNode(e) {
808
806
  if (this.graphStore.getNode(e) === void 0)
809
- throw new f("failed to remove nonexisting node");
807
+ throw new C("failed to remove nonexisting node");
810
808
  (this.graphStore.getNodePortIds(e) ?? []).forEach((t) => {
811
809
  this.unmarkPort(t);
812
810
  }), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
813
811
  }
814
812
  markPort(e, t, s, o, i) {
815
813
  if (e = this.portIdGenerator.create(e), this.graphStore.getNode(s) === void 0)
816
- throw new f("failed to set port on nonexisting node");
814
+ throw new C("failed to set port on nonexisting node");
817
815
  if (this.graphStore.getPort(e) !== void 0)
818
- throw new f("failed to add port with existing id");
816
+ throw new C("failed to add port with existing id");
819
817
  this.graphStore.addPort(
820
818
  e,
821
819
  t,
@@ -827,23 +825,23 @@ class le {
827
825
  updatePort(e, t, s) {
828
826
  const o = this.graphStore.getPort(e);
829
827
  if (o === void 0)
830
- throw new f("failed to unset nonexisting port");
828
+ throw new C("failed to unset nonexisting port");
831
829
  o.direction = t ?? o.direction, o.centerFn = s ?? o.centerFn, this.htmlController.updatePortEdges(e);
832
830
  }
833
831
  unmarkPort(e) {
834
832
  if (this.graphStore.getPort(e) === void 0)
835
- throw new f("failed to unset nonexisting port");
833
+ throw new C("failed to unset nonexisting port");
836
834
  this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
837
835
  this.removeEdge(t);
838
836
  }), this.graphStore.removePort(e);
839
837
  }
840
838
  addEdge(e, t, s, o, i) {
841
839
  if (e = this.edgeIdGenerator.create(e), this.graphStore.getPort(t) === void 0)
842
- throw new f("failed to add edge from nonexisting port");
840
+ throw new C("failed to add edge from nonexisting port");
843
841
  if (this.graphStore.getPort(s) === void 0)
844
- throw new f("failed to add edge to nonexisting port");
842
+ throw new C("failed to add edge to nonexisting port");
845
843
  if (this.graphStore.getEdge(e) !== void 0)
846
- throw new f("failed to add edge with existing id");
844
+ throw new C("failed to add edge with existing id");
847
845
  const n = this.resolveEdgeType(t, s);
848
846
  this.graphStore.addEdge(
849
847
  e,
@@ -856,7 +854,7 @@ class le {
856
854
  updateEdge(e, t, s) {
857
855
  const o = this.graphStore.getEdge(e);
858
856
  if (o === void 0)
859
- throw new f("failed to update nonexisting edge");
857
+ throw new C("failed to update nonexisting edge");
860
858
  if (t !== void 0) {
861
859
  const i = this.resolveEdgeType(o.from, o.to);
862
860
  o.shape = t(i), this.htmlController.updateEdgeShape(e);
@@ -865,7 +863,7 @@ class le {
865
863
  }
866
864
  removeEdge(e) {
867
865
  if (this.graphStore.getEdge(e) === void 0)
868
- throw new f("failed to remove nonexisting edge");
866
+ throw new C("failed to remove nonexisting edge");
869
867
  this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
870
868
  }
871
869
  patchViewportMatrix(e, t, s) {
@@ -888,25 +886,22 @@ class le {
888
886
  }
889
887
  resolveEdgeType(e, t) {
890
888
  if (e === t)
891
- return P.PortCycle;
889
+ return A.PortCycle;
892
890
  const s = this.graphStore.getPortNodeId(e), o = this.graphStore.getPortNodeId(t);
893
- return s === o ? P.NodeCycle : P.Regular;
891
+ return s === o ? A.NodeCycle : A.Regular;
894
892
  }
895
893
  }
896
894
  const ue = () => {
897
895
  const r = document.createElement("div");
898
896
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
899
897
  }, ge = () => {
900
- const r = document.createElement("canvas");
901
- return r.style.position = "absolute", r.style.inset = "0", r;
902
- }, we = () => {
903
898
  const r = document.createElement("div");
904
899
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
905
- }, ye = () => {
900
+ }, we = () => {
906
901
  const r = document.createElement("div");
907
902
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
908
903
  };
909
- class me {
904
+ class ye {
910
905
  constructor() {
911
906
  a(this, "keyMap", /* @__PURE__ */ new Map());
912
907
  a(this, "valueMap", /* @__PURE__ */ new Map());
@@ -937,48 +932,30 @@ class me {
937
932
  this.keyMap.clear(), this.valueMap.clear();
938
933
  }
939
934
  }
940
- class pe {
941
- constructor(e, t, s, o) {
935
+ class me {
936
+ constructor(e, t) {
942
937
  a(this, "canvasWrapper", null);
943
938
  a(this, "host", ue());
944
- a(this, "canvas", ge());
945
- a(this, "container", we());
946
- a(this, "canvasCtx");
947
- a(this, "canvasResizeObserver");
939
+ a(this, "container", ge());
948
940
  a(this, "nodesResizeObserver");
949
941
  a(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
950
- a(this, "nodeIdToWrapperElementMap", new me());
942
+ a(this, "nodeIdToWrapperElementMap", new ye());
951
943
  a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
952
- this.graphStore = e, this.viewportTransformer = t, this.publicViewportTransformer = s, this.backgroundDrawingFn = o;
953
- const i = this.canvas.getContext("2d");
954
- if (i === null)
955
- throw new f("unable to get canvas context");
956
- this.canvasCtx = i, this.host.appendChild(this.canvas), this.host.appendChild(this.container), this.canvasResizeObserver = this.createHostResizeObserver(), this.nodesResizeObserver = this.createNodesResizeObserver();
957
- }
958
- clear() {
959
- this.edgeIdToElementMap.forEach((e, t) => {
960
- this.detachEdge(t);
961
- }), this.nodeIdToWrapperElementMap.forEach((e, t) => {
962
- this.detachNode(t);
963
- });
944
+ this.graphStore = e, this.viewportTransformer = t, this.host.appendChild(this.container), this.nodesResizeObserver = this.createNodesResizeObserver();
964
945
  }
965
946
  attach(e) {
966
- this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host), this.canvasResizeObserver.observe(this.canvasWrapper);
947
+ this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
967
948
  }
968
949
  detach() {
969
- this.canvasWrapper !== null && (this.canvasResizeObserver.unobserve(this.canvasWrapper), this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
970
- }
971
- destroy() {
972
- this.canvasResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.container), this.clear(), this.detach();
950
+ this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
973
951
  }
974
952
  applyTransform() {
975
- this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
976
953
  const e = this.viewportTransformer.getContentMatrix();
977
954
  this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
978
955
  }
979
956
  attachNode(e) {
980
- const t = this.graphStore.getNode(e), s = ye();
981
- s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoords(e), this.updateNodePriority(e), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
957
+ const t = this.graphStore.getNode(e), s = we();
958
+ s.appendChild(t.element), this.container.appendChild(s), this.nodeElementToIdMap.set(t.element, e), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoordinatesInternal(e), this.updateNodePriority(e), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
982
959
  }
983
960
  detachNode(e) {
984
961
  const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.getByKey(e);
@@ -986,16 +963,26 @@ class pe {
986
963
  }
987
964
  attachEdge(e) {
988
965
  const t = this.graphStore.getEdge(e);
989
- this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdgeCoords(e), this.updateEdgePriority(e);
966
+ this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
990
967
  }
991
968
  detachEdge(e) {
992
969
  const t = this.graphStore.getEdge(e);
993
970
  this.container.removeChild(t.shape.svg), this.edgeIdToElementMap.delete(e);
994
971
  }
972
+ clear() {
973
+ this.edgeIdToElementMap.forEach((e, t) => {
974
+ this.detachEdge(t);
975
+ }), this.nodeIdToWrapperElementMap.forEach((e, t) => {
976
+ this.detachNode(t);
977
+ });
978
+ }
979
+ destroy() {
980
+ this.nodesResizeObserver.disconnect(), this.host.removeChild(this.container), this.clear(), this.detach();
981
+ }
995
982
  updateNodeCoordinates(e) {
996
983
  const t = this.graphStore.getNodeAdjacentEdgeIds(e);
997
- this.updateNodeCoords(e), t.forEach((s) => {
998
- this.updateEdgeCoords(s);
984
+ this.updateNodeCoordinatesInternal(e), t.forEach((s) => {
985
+ this.updateEdgeCoordinates(s);
999
986
  });
1000
987
  }
1001
988
  updateNodePriority(e) {
@@ -1006,7 +993,7 @@ class pe {
1006
993
  const t = this.edgeIdToElementMap.get(e);
1007
994
  this.container.removeChild(t);
1008
995
  const s = this.graphStore.getEdge(e);
1009
- this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoords(e), this.updateEdgePriority(e);
996
+ this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg), this.updateEdgeCoordinates(e), this.updateEdgePriority(e);
1010
997
  }
1011
998
  updateEdgePriority(e) {
1012
999
  const t = this.graphStore.getEdge(e);
@@ -1014,37 +1001,28 @@ class pe {
1014
1001
  }
1015
1002
  updatePortEdges(e) {
1016
1003
  this.graphStore.getPortAdjacentEdgeIds(e).forEach((s) => {
1017
- this.updateEdgeCoords(s);
1018
- });
1019
- }
1020
- createHostResizeObserver() {
1021
- return new ResizeObserver(() => {
1022
- this.updateCanvasDimensions(), this.applyTransform();
1004
+ this.updateEdgeCoordinates(s);
1023
1005
  });
1024
1006
  }
1025
1007
  createNodesResizeObserver() {
1026
1008
  return new ResizeObserver((e) => {
1027
1009
  e.forEach((t) => {
1028
1010
  const s = t.target, o = this.nodeIdToWrapperElementMap.getByValue(s);
1029
- this.updateNodeCoords(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
1030
- this.updateEdgeCoords(n);
1011
+ this.updateNodeCoordinatesInternal(o), this.graphStore.getNodeAdjacentEdgeIds(o).forEach((n) => {
1012
+ this.updateEdgeCoordinates(n);
1031
1013
  });
1032
1014
  });
1033
1015
  });
1034
1016
  }
1035
- updateCanvasDimensions() {
1036
- const { width: e, height: t } = this.host.getBoundingClientRect();
1037
- this.canvas.width = e, this.canvas.height = t;
1038
- }
1039
- updateNodeCoords(e) {
1040
- const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = t.getBoundingClientRect(), i = this.viewportTransformer.getViewportMatrix().scale, n = this.graphStore.getNode(e), { x: h, y: c } = n.centerFn(s, o), d = n.x - i * h, u = n.y - i * c;
1041
- t.style.transform = `matrix(1, 0, 0, 1, ${d}, ${u})`;
1017
+ updateNodeCoordinatesInternal(e) {
1018
+ const t = this.nodeIdToWrapperElementMap.getByKey(e), { width: s, height: o } = t.getBoundingClientRect(), i = this.viewportTransformer.getViewportMatrix().scale, n = this.graphStore.getNode(e), { x: h, y: c } = n.centerFn(s, o), d = n.x - i * h, g = n.y - i * c;
1019
+ t.style.transform = `matrix(1, 0, 0, 1, ${d}, ${g})`;
1042
1020
  }
1043
- updateEdgeCoords(e) {
1021
+ updateEdgeCoordinates(e) {
1044
1022
  const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), o = this.graphStore.getPort(t.to), i = s.element.getBoundingClientRect(), n = o.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), d = {
1045
1023
  x: c.scale * (i.left - h.left) + c.dx,
1046
1024
  y: c.scale * (i.top - h.top) + c.dy
1047
- }, u = {
1025
+ }, g = {
1048
1026
  x: c.scale * (n.left - h.left) + c.dx,
1049
1027
  y: c.scale * (n.top - h.top) + c.dy
1050
1028
  }, w = s.centerFn(
@@ -1057,87 +1035,46 @@ class pe {
1057
1035
  x: d.x + w.x,
1058
1036
  y: d.y + w.y
1059
1037
  }, v = {
1060
- x: u.x + m.x,
1061
- y: u.y + m.y
1062
- }, A = Math.min(y.x, v.x), S = Math.min(y.y, v.y), N = Math.abs(v.x - y.x), L = Math.abs(v.y - y.y);
1063
- t.shape.svg.style.width = `${N}px`, t.shape.svg.style.height = `${L}px`, t.shape.svg.style.transform = `translate(${A}px, ${S}px)`;
1064
- const M = y.x <= v.x ? 1 : -1, b = y.y <= v.y ? 1 : -1;
1038
+ x: g.x + m.x,
1039
+ y: g.y + m.y
1040
+ }, S = Math.min(y.x, v.x), P = Math.min(y.y, v.y), M = Math.abs(v.x - y.x), b = Math.abs(v.y - y.y);
1041
+ t.shape.svg.style.width = `${M}px`, t.shape.svg.style.height = `${b}px`, t.shape.svg.style.transform = `translate(${S}px, ${P}px)`;
1042
+ const T = y.x <= v.x ? 1 : -1, W = y.y <= v.y ? 1 : -1;
1065
1043
  t.shape.update(
1066
- { x: N, y: L },
1067
- M,
1068
- b,
1044
+ { x: M, y: b },
1045
+ T,
1046
+ W,
1069
1047
  s.direction,
1070
1048
  o.direction
1071
1049
  );
1072
1050
  }
1073
1051
  }
1074
- class ve {
1075
- constructor(e, t, s, o, i, n) {
1052
+ class pe {
1053
+ constructor(e, t, s, o, i) {
1076
1054
  a(this, "publicViewportTransformer");
1077
1055
  a(this, "publicGraphStore");
1078
1056
  a(this, "canvasController");
1079
- const h = new Q(), c = new q();
1080
- this.publicGraphStore = new ee(c), this.publicViewportTransformer = new Z(
1081
- h
1082
- );
1083
- const d = new pe(
1084
- c,
1085
- h,
1086
- this.publicViewportTransformer,
1087
- e
1057
+ const n = new Q(), h = new q();
1058
+ this.publicGraphStore = new ee(h), this.publicViewportTransformer = new Z(
1059
+ n
1088
1060
  );
1061
+ const c = new me(h, n);
1089
1062
  this.canvasController = new le(
1090
- c,
1091
- d,
1092
1063
  h,
1064
+ c,
1065
+ n,
1066
+ e,
1093
1067
  t,
1094
1068
  s,
1095
1069
  o,
1096
- i,
1097
- n
1070
+ i
1098
1071
  );
1099
1072
  }
1100
1073
  }
1101
1074
  const H = (r, e) => ({
1102
1075
  x: r / 2,
1103
1076
  y: e / 2
1104
- }), fe = () => () => {
1105
- }, xe = (r, e, t, s, o, i, n) => {
1106
- r.clearRect(0, 0, r.canvas.width, r.canvas.height), r.fillStyle = i, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
1107
- const h = e.getContentMatrix(), c = s * h.scale, d = r.canvas.width / c, u = r.canvas.height / c;
1108
- if (d * u > n)
1109
- return;
1110
- const w = h.dx - Math.floor(h.dx / c) * c, m = h.dy - Math.floor(h.dy / c) * c, y = o * h.scale, v = 2 * Math.PI, A = w - c, S = m - c, N = r.canvas.width + w, L = r.canvas.height + m;
1111
- r.fillStyle = t;
1112
- for (let M = A; M <= N; M += c)
1113
- for (let b = S; b <= L; b += c)
1114
- r.beginPath(), r.arc(M, b, y, 0, v), r.closePath(), r.fill();
1115
- }, Ee = (r, e, t, s, o) => (i, n) => {
1116
- xe(
1117
- i,
1118
- n,
1119
- r,
1120
- e,
1121
- t,
1122
- s,
1123
- o
1124
- );
1125
- }, Ce = (r) => {
1126
- switch (r == null ? void 0 : r.type) {
1127
- case "custom":
1128
- return r.drawingFn;
1129
- case "dots":
1130
- return Ee(
1131
- r.dotColor ?? "#d8d8d8",
1132
- r.dotGap ?? 25,
1133
- r.dotRadius ?? 1.5,
1134
- r.color ?? "#ffffff",
1135
- r.limit ?? 1e4
1136
- );
1137
- default:
1138
- return fe();
1139
- }
1140
- }, g = {
1077
+ }), u = {
1141
1078
  edgeColor: "#5c5c5c",
1142
1079
  edgeWidth: 1,
1143
1080
  edgeArrowLength: 15,
@@ -1151,90 +1088,85 @@ const H = (r, e) => ({
1151
1088
  detourDirection: -Math.PI / 2,
1152
1089
  smallCycleSize: 15,
1153
1090
  curvature: 90
1154
- }, z = (r) => {
1091
+ }, R = (r) => {
1155
1092
  switch (r == null ? void 0 : r.type) {
1156
1093
  case "custom":
1157
1094
  return r.factory;
1158
1095
  case "straight":
1159
1096
  return he({
1160
- color: r.color ?? g.edgeColor,
1161
- width: r.width ?? g.edgeWidth,
1162
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
1163
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
1164
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
1165
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
1166
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
1167
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
1168
- roundness: r.roundness ?? g.roundness,
1169
- detourDistance: r.detourDistance ?? g.detourDistance,
1170
- detourDirection: r.detourDirection ?? g.detourDirection
1097
+ color: r.color ?? u.edgeColor,
1098
+ width: r.width ?? u.edgeWidth,
1099
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1100
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1101
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1102
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1103
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1104
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1105
+ roundness: r.roundness ?? u.roundness,
1106
+ detourDistance: r.detourDistance ?? u.detourDistance,
1107
+ detourDirection: r.detourDirection ?? u.detourDirection
1171
1108
  });
1172
1109
  case "horizontal":
1173
- return ce({
1174
- color: r.color ?? g.edgeColor,
1175
- width: r.width ?? g.edgeWidth,
1176
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
1177
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
1178
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
1179
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
1180
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
1181
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
1182
- roundness: r.roundness ?? g.roundness,
1183
- detourDistance: r.detourDistance ?? g.detourDistance,
1184
- detourDirection: r.detourDirection ?? g.detourDirection
1110
+ return de({
1111
+ color: r.color ?? u.edgeColor,
1112
+ width: r.width ?? u.edgeWidth,
1113
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1114
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1115
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1116
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1117
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1118
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1119
+ roundness: r.roundness ?? u.roundness,
1120
+ detourDistance: r.detourDistance ?? u.detourDistance,
1121
+ detourDirection: r.detourDirection ?? u.detourDirection
1185
1122
  });
1186
1123
  case "vertical":
1187
- return de({
1188
- color: r.color ?? g.edgeColor,
1189
- width: r.width ?? g.edgeWidth,
1190
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
1191
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
1192
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
1193
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
1194
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
1195
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
1196
- roundness: r.roundness ?? g.roundness,
1197
- detourDistance: r.detourDistance ?? g.detourDistance,
1198
- detourDirection: r.detourDirection ?? g.detourDirection
1124
+ return ce({
1125
+ color: r.color ?? u.edgeColor,
1126
+ width: r.width ?? u.edgeWidth,
1127
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1128
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1129
+ arrowOffset: r.arrowOffset ?? u.edgeArrowOffset,
1130
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1131
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1132
+ cycleSquareSide: r.cycleSquareSide ?? u.cycleSize,
1133
+ roundness: r.roundness ?? u.roundness,
1134
+ detourDistance: r.detourDistance ?? u.detourDistance,
1135
+ detourDirection: r.detourDirection ?? u.detourDirection
1199
1136
  });
1200
1137
  default:
1201
1138
  return ae({
1202
- color: r.color ?? g.edgeColor,
1203
- width: r.width ?? g.edgeWidth,
1204
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
1205
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
1206
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
1207
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
1208
- cycleRadius: r.cycleRadius ?? g.cycleSize,
1209
- detourDistance: r.detourDistance ?? g.detourDistance,
1210
- detourDirection: r.detourDirection ?? g.detourDirection,
1211
- smallCycleRadius: r.smallCycleRadius ?? g.smallCycleSize,
1212
- curvature: r.curvature ?? g.curvature
1139
+ color: r.color ?? u.edgeColor,
1140
+ width: r.width ?? u.edgeWidth,
1141
+ arrowLength: r.arrowLength ?? u.edgeArrowLength,
1142
+ arrowWidth: r.arrowWidth ?? u.edgeArrowWidth,
1143
+ hasSourceArrow: r.hasSourceArrow ?? u.hasSourceArrow,
1144
+ hasTargetArrow: r.hasTargetArrow ?? u.hasTargetArrow,
1145
+ cycleRadius: r.cycleRadius ?? u.cycleSize,
1146
+ detourDistance: r.detourDistance ?? u.detourDistance,
1147
+ detourDirection: r.detourDirection ?? u.detourDirection,
1148
+ smallCycleRadius: r.smallCycleRadius ?? u.smallCycleSize,
1149
+ curvature: r.curvature ?? u.curvature
1213
1150
  });
1214
1151
  }
1215
- }, I = (r) => () => r, U = I(0), k = () => {
1152
+ }, z = (r) => () => r, U = z(0), k = () => {
1216
1153
  let r = 0;
1217
1154
  return () => r++;
1218
- }, Ae = (r, e) => {
1155
+ }, ve = (r, e) => {
1219
1156
  const t = [
1220
1157
  U,
1221
1158
  U
1222
1159
  ];
1223
1160
  r === "incremental" && (t[0] = k()), e === "incremental" && (t[1] = k());
1224
1161
  const s = k();
1225
- return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] = I(r)), typeof e == "number" && (t[1] = I(e)), typeof r == "function" && (t[0] = r), typeof e == "function" && (t[1] = e), t;
1226
- }, Se = (r) => {
1162
+ return r === "shared-incremental" && (t[0] = s), e === "shared-incremental" && (t[1] = s), typeof r == "number" && (t[0] = z(r)), typeof e == "number" && (t[1] = z(e)), typeof r == "function" && (t[0] = r), typeof e == "function" && (t[1] = e), t;
1163
+ }, fe = (r) => {
1227
1164
  var s, o, i, n, h, c;
1228
- const [e, t] = Ae(
1165
+ const [e, t] = ve(
1229
1166
  (s = r.nodes) == null ? void 0 : s.priority,
1230
1167
  (o = r.edges) == null ? void 0 : o.priority
1231
1168
  );
1232
1169
  return {
1233
- background: {
1234
- drawingFn: Ce(
1235
- r.background ?? { type: "none" }
1236
- )
1237
- },
1238
1170
  nodes: {
1239
1171
  centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? H,
1240
1172
  priorityFn: e
@@ -1244,21 +1176,20 @@ const H = (r, e) => ({
1244
1176
  direction: ((h = r.ports) == null ? void 0 : h.direction) ?? 0
1245
1177
  },
1246
1178
  edges: {
1247
- shapeFactory: z(((c = r.edges) == null ? void 0 : c.shape) ?? {}),
1179
+ shapeFactory: R(((c = r.edges) == null ? void 0 : c.shape) ?? {}),
1248
1180
  priorityFn: t
1249
1181
  }
1250
1182
  };
1251
1183
  };
1252
- class Pe {
1184
+ class xe {
1253
1185
  constructor(e) {
1254
1186
  a(this, "transformation");
1255
1187
  a(this, "model");
1256
1188
  a(this, "di");
1257
1189
  a(this, "edgeShapeFactory");
1258
1190
  this.apiOptions = e;
1259
- const t = Se(this.apiOptions ?? {});
1260
- this.di = new ve(
1261
- t.background.drawingFn,
1191
+ const t = fe(this.apiOptions ?? {});
1192
+ this.di = new pe(
1262
1193
  t.nodes.centerFn,
1263
1194
  t.ports.centerFn,
1264
1195
  t.ports.direction,
@@ -1309,7 +1240,7 @@ class Pe {
1309
1240
  return this.di.canvasController.unmarkPort(e), this;
1310
1241
  }
1311
1242
  addEdge(e) {
1312
- const t = e.shape !== void 0 ? z(e.shape) : this.edgeShapeFactory;
1243
+ const t = e.shape !== void 0 ? R(e.shape) : this.edgeShapeFactory;
1313
1244
  return this.di.canvasController.addEdge(
1314
1245
  e.id,
1315
1246
  e.from,
@@ -1319,7 +1250,7 @@ class Pe {
1319
1250
  ), this;
1320
1251
  }
1321
1252
  updateEdge(e, t) {
1322
- const s = t.shape !== void 0 ? z(t.shape) : void 0;
1253
+ const s = t.shape !== void 0 ? R(t.shape) : void 0;
1323
1254
  return this.di.canvasController.updateEdge(e, s, t.priority), this;
1324
1255
  }
1325
1256
  removeEdge(e) {
@@ -1352,13 +1283,13 @@ class Pe {
1352
1283
  this.di.canvasController.destroy();
1353
1284
  }
1354
1285
  }
1355
- const O = (r, e, t) => {
1286
+ const V = (r, e, t) => {
1356
1287
  const { x: s, y: o, width: i, height: n } = r.getBoundingClientRect();
1357
1288
  return e >= s && e < s + i && t >= o && t <= o + n;
1358
- }, V = (r, e, t) => e >= 0 && e < r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e) => {
1289
+ }, O = (r, e, t) => e >= 0 && e < r.innerWidth && t >= 0 && t <= r.innerHeight, I = (r, e) => {
1359
1290
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
1360
1291
  };
1361
- class Me {
1292
+ class Ee {
1362
1293
  constructor(e, t) {
1363
1294
  a(this, "model");
1364
1295
  a(this, "transformation");
@@ -1367,7 +1298,7 @@ class Me {
1367
1298
  a(this, "grabbedNodeId", null);
1368
1299
  a(this, "onNodeDrag");
1369
1300
  a(this, "onBeforeNodeDrag");
1370
- a(this, "nodeIdGenerator", new W(
1301
+ a(this, "nodeIdGenerator", new F(
1371
1302
  (e) => this.nodes.has(e)
1372
1303
  ));
1373
1304
  a(this, "element", null);
@@ -1375,7 +1306,7 @@ class Me {
1375
1306
  this.cancelMouseDrag();
1376
1307
  });
1377
1308
  a(this, "onCanvasMouseMove", (e) => {
1378
- if (this.element !== null && (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY))) {
1309
+ if (this.element !== null && (!V(this.element, e.clientX, e.clientY) || !O(this.window, e.clientX, e.clientY))) {
1379
1310
  this.cancelMouseDrag();
1380
1311
  return;
1381
1312
  }
@@ -1390,7 +1321,7 @@ class Me {
1390
1321
  a(this, "onCanvasTouchMove", (e) => {
1391
1322
  if (e.touches.length === 1) {
1392
1323
  const t = e.touches[0];
1393
- if (this.element !== null && (!O(this.element, t.clientX, t.clientY) || !V(this.window, t.clientX, t.clientY))) {
1324
+ if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !O(this.window, t.clientX, t.clientY))) {
1394
1325
  this.cancelTouchDrag();
1395
1326
  return;
1396
1327
  }
@@ -1434,7 +1365,7 @@ class Me {
1434
1365
  element: e.element,
1435
1366
  x: n.x,
1436
1367
  y: n.y
1437
- }) && (i.stopImmediatePropagation(), this.grabbedNodeId = t, R(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
1368
+ }) && (i.stopImmediatePropagation(), this.grabbedNodeId = t, I(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
1438
1369
  }, o = (i) => {
1439
1370
  const n = this.model.getNode(t);
1440
1371
  this.onBeforeNodeDrag({
@@ -1500,8 +1431,8 @@ class Me {
1500
1431
  dragNode(e, t, s) {
1501
1432
  const o = this.model.getNode(e);
1502
1433
  if (o === null)
1503
- throw new f("failed to drag nonexisting node");
1504
- const i = this.canvas.transformation.getContentMatrix(), n = i.scale * o.x + i.dx, h = i.scale * o.y + i.dy, c = n + t, d = h + s, u = this.canvas.transformation.getViewportMatrix(), w = u.scale * c + u.dx, m = u.scale * d + u.dy;
1434
+ throw new C("failed to drag nonexisting node");
1435
+ const i = this.canvas.transformation.getContentMatrix(), n = i.scale * o.x + i.dx, h = i.scale * o.y + i.dy, c = n + t, d = h + s, g = this.canvas.transformation.getViewportMatrix(), w = g.scale * c + g.dx, m = g.scale * d + g.dy;
1505
1436
  this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
1506
1437
  nodeId: e,
1507
1438
  element: o.element,
@@ -1523,7 +1454,7 @@ class Me {
1523
1454
  });
1524
1455
  }
1525
1456
  cancelMouseDrag() {
1526
- this.grabbedNodeId = null, this.element !== null && R(this.element, null), this.removeMouseDragListeners();
1457
+ this.grabbedNodeId = null, this.element !== null && I(this.element, null), this.removeMouseDragListeners();
1527
1458
  }
1528
1459
  removeMouseDragListeners() {
1529
1460
  this.window.removeEventListener("mouseup", this.onCanvasMouseUp), this.window.removeEventListener("mousemove", this.onCanvasMouseMove);
@@ -1535,26 +1466,26 @@ class Me {
1535
1466
  this.window.removeEventListener("touchmove", this.onCanvasTouchMove), this.window.removeEventListener("touchend", this.onCanvasTouchEnd), this.window.removeEventListener("touchcancel", this.onCanvasTouchEnd);
1536
1467
  }
1537
1468
  }
1538
- const Ne = () => {
1539
- }, Le = (r, e) => e, be = (r, e) => {
1469
+ const Ce = () => {
1470
+ }, Ae = (r, e) => e, Se = (r, e) => {
1540
1471
  const t = e !== null ? 1 / e : null, s = r !== null ? 1 / r : null;
1541
1472
  return (o, i) => s !== null && i.scale > s && i.scale > o.scale || t !== null && i.scale < t && i.scale < o.scale ? o : i;
1542
- }, Te = (r, e, t, s) => (o, i, n, h) => {
1473
+ }, Pe = (r, e, t, s) => (o, i, n, h) => {
1543
1474
  let c = i.dx, d = i.dy;
1544
1475
  r !== null && c < r && c < o.dx && (c = o.dx);
1545
- const u = n * o.scale;
1546
- e !== null && c > e - u && c > o.dx && (c = o.dx), t !== null && d < t && d < o.dy && (d = o.dy);
1476
+ const g = n * o.scale;
1477
+ e !== null && c > e - g && c > o.dx && (c = o.dx), t !== null && d < t && d < o.dy && (d = o.dy);
1547
1478
  const w = h * o.scale;
1548
1479
  return s !== null && d > s - w && d > o.dy && (d = o.dy), { scale: i.scale, dx: c, dy: d };
1549
1480
  }, K = (r) => {
1550
1481
  switch (r.type) {
1551
1482
  case "scale-limit":
1552
- return be(
1483
+ return Se(
1553
1484
  r.minContentScale ?? null,
1554
1485
  r.maxContentScale ?? null
1555
1486
  );
1556
1487
  case "shift-limit":
1557
- return Te(
1488
+ return Pe(
1558
1489
  r.minX ?? null,
1559
1490
  r.maxX ?? null,
1560
1491
  r.minY ?? null,
@@ -1563,11 +1494,11 @@ const Ne = () => {
1563
1494
  default:
1564
1495
  return r.preprocessorFn;
1565
1496
  }
1566
- }, $e = (r) => (e, t, s, o) => r.reduce(
1497
+ }, Me = (r) => (e, t, s, o) => r.reduce(
1567
1498
  (i, n) => n(e, i, s, o),
1568
1499
  t
1569
1500
  );
1570
- class De {
1501
+ class Ne {
1571
1502
  constructor(e, t) {
1572
1503
  a(this, "model");
1573
1504
  a(this, "transformation");
@@ -1580,12 +1511,12 @@ class De {
1580
1511
  a(this, "wheelSensitivity");
1581
1512
  a(this, "window", window);
1582
1513
  a(this, "onMouseDown", () => {
1583
- this.element !== null && (R(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
1514
+ this.element !== null && (I(this.element, this.shiftCursor), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
1584
1515
  });
1585
1516
  a(this, "onMouseMove", (e) => {
1586
1517
  if (!this.isShiftable || this.element === null)
1587
1518
  return;
1588
- if (!O(this.element, e.clientX, e.clientY) || !V(this.window, e.clientX, e.clientY)) {
1519
+ if (!V(this.element, e.clientX, e.clientY) || !O(this.window, e.clientX, e.clientY)) {
1589
1520
  this.stopMouseDrag();
1590
1521
  return;
1591
1522
  }
@@ -1610,7 +1541,7 @@ class De {
1610
1541
  return;
1611
1542
  const t = this.getAverageTouch(e);
1612
1543
  if (!t.touches.every(
1613
- (o) => O(this.element, o[0], o[1]) && V(this.window, o[0], o[1])
1544
+ (o) => V(this.element, o[0], o[1]) && O(this.window, o[0], o[1])
1614
1545
  )) {
1615
1546
  this.stopTouchDrag();
1616
1547
  return;
@@ -1635,20 +1566,20 @@ class De {
1635
1566
  t,
1636
1567
  s
1637
1568
  );
1638
- this.canvas.patchViewportMatrix(o), this.onTransformFinished(o);
1569
+ this.canvas.patchViewportMatrix(o), this.onTransformFinished();
1639
1570
  }
1640
1571
  }));
1641
1572
  a(this, "shiftCursor");
1642
- var i, n, h, c, d, u, w, m;
1573
+ var i, n, h, c, d, g, w, m;
1643
1574
  this.canvas = e, this.options = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.isScalable = ((n = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : n.enabled) !== !1, this.isShiftable = ((c = (h = this.options) == null ? void 0 : h.shift) == null ? void 0 : c.enabled) !== !1;
1644
- const s = (u = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : u.wheelSensitivity;
1645
- this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((w = t == null ? void 0 : t.events) == null ? void 0 : w.onTransformFinished) ?? Ne;
1575
+ const s = (g = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : g.wheelSensitivity;
1576
+ this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((w = t == null ? void 0 : t.events) == null ? void 0 : w.onTransformFinished) ?? Ce;
1646
1577
  const o = t == null ? void 0 : t.transformPreprocessor;
1647
- o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = $e(
1578
+ o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = Me(
1648
1579
  o.map(
1649
1580
  (y) => K(y)
1650
1581
  )
1651
- ) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Le, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
1582
+ ) : this.transformPreprocessor = K(o) : this.transformPreprocessor = Ae, this.shiftCursor = ((m = t == null ? void 0 : t.shift) == null ? void 0 : m.cursor) !== void 0 ? t.shift.cursor : "grab";
1652
1583
  }
1653
1584
  addNode(e) {
1654
1585
  return this.canvas.addNode(e), this;
@@ -1727,7 +1658,7 @@ class De {
1727
1658
  i,
1728
1659
  n
1729
1660
  );
1730
- this.canvas.patchViewportMatrix(h), this.onTransformFinished(h);
1661
+ this.canvas.patchViewportMatrix(h), this.onTransformFinished();
1731
1662
  }
1732
1663
  }
1733
1664
  scaleViewport(e, t, s) {
@@ -1743,10 +1674,10 @@ class De {
1743
1674
  n,
1744
1675
  h
1745
1676
  );
1746
- this.canvas.patchViewportMatrix(c), this.onTransformFinished(c);
1677
+ this.canvas.patchViewportMatrix(c), this.onTransformFinished();
1747
1678
  }
1748
1679
  stopMouseDrag() {
1749
- this.element !== null && R(this.element, null), this.removeMouseDragListeners();
1680
+ this.element !== null && I(this.element, null), this.removeMouseDragListeners();
1750
1681
  }
1751
1682
  removeMouseDragListeners() {
1752
1683
  this.window.removeEventListener("mousemove", this.onMouseMove), this.window.removeEventListener("mouseup", this.onMouseUp);
@@ -1758,7 +1689,7 @@ class De {
1758
1689
  this.window.removeEventListener("touchmove", this.onTouchMove), this.window.removeEventListener("touchend", this.onTouchEnd), this.window.removeEventListener("touchcancel", this.onTouchEnd);
1759
1690
  }
1760
1691
  }
1761
- class We {
1692
+ class Te {
1762
1693
  constructor() {
1763
1694
  a(this, "coreOptions");
1764
1695
  a(this, "dragOptions");
@@ -1776,26 +1707,27 @@ class We {
1776
1707
  return this.isTransformable = !0, this.transformOptions = e, this;
1777
1708
  }
1778
1709
  build() {
1779
- let e = new Pe(this.coreOptions);
1780
- return this.isDraggable && (e = new Me(e, this.dragOptions)), this.isTransformable && (e = new De(e, this.transformOptions)), e;
1710
+ let e = new xe(this.coreOptions);
1711
+ return this.isDraggable && (e = new Ee(e, this.dragOptions)), this.isTransformable && (e = new Ne(e, this.transformOptions)), e;
1781
1712
  }
1782
1713
  }
1783
1714
  export {
1784
1715
  te as BezierEdgeShape,
1785
- Pe as CanvasCore,
1716
+ xe as CanvasCore,
1786
1717
  ie as CycleCircleEdgeShape,
1787
1718
  B as CycleSquareEdgeShape,
1719
+ ne as DetourBezierEdgeShape,
1788
1720
  G as DetourStraightEdgeShape,
1789
- P as EdgeType,
1721
+ A as EdgeType,
1790
1722
  se as HorizontalEdgeShape,
1791
- We as HtmlGraphBuilder,
1792
- f as HtmlGraphError,
1723
+ Te as HtmlGraphBuilder,
1724
+ C as HtmlGraphError,
1793
1725
  re as StraightEdgeShape,
1794
- Me as UserDraggableNodesCanvas,
1795
- De as UserTransformableCanvas,
1726
+ Ee as UserDraggableNodesCanvas,
1727
+ Ne as UserTransformableCanvas,
1796
1728
  oe as VerticalEdgeShape,
1797
1729
  ae as createBezierEdgeShapeFactory,
1798
- ce as createHorizontalEdgeShapeFactory,
1730
+ de as createHorizontalEdgeShapeFactory,
1799
1731
  he as createStraightEdgeShareFactory,
1800
- de as createVerticalEdgeShapeFactory
1732
+ ce as createVerticalEdgeShapeFactory
1801
1733
  };