@joint/core 4.0.1 → 4.0.3

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/joint.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.1 (2024-02-02) - JavaScript diagramming library
1
+ /*! JointJS v4.0.3 (2024-05-14) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -13762,6 +13762,10 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
13762
13762
  var ry2 = ry * ry;
13763
13763
 
13764
13764
  var k = ((large_arc_flag == sweep_flag) ? -1 : 1) * sqrt(abs(((rx2 * ry2) - (rx2 * y * y) - (ry2 * x * x)) / ((rx2 * y * y) + (ry2 * x * x))));
13765
+ if (!Number.isFinite(k)) {
13766
+ // Arc is a single point
13767
+ return [x1, y1, x2, y2, x2, y2];
13768
+ }
13765
13769
 
13766
13770
  var cx = ((k * rx * y) / ry) + ((x1 + x2) / 2);
13767
13771
  var cy = ((k * -ry * x) / rx) + ((y1 + y2) / 2);
@@ -17522,12 +17526,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
17522
17526
  if (text === undefined) { text = attrs.text; }
17523
17527
  if (text !== undefined) {
17524
17528
  var breakTextFn = value.breakText || breakText;
17529
+ var computedStyles = getComputedStyle(node);
17530
+
17525
17531
  wrappedText = breakTextFn('' + text, size, {
17526
- 'font-weight': attrs['font-weight'],
17527
- 'font-size': attrs['font-size'],
17528
- 'font-family': attrs['font-family'],
17532
+ 'font-weight': computedStyles.fontWeight,
17533
+ 'font-family': computedStyles.fontFamily,
17534
+ 'text-transform': computedStyles.textTransform,
17535
+ 'font-size': computedStyles.fontSize,
17536
+ 'letter-spacing': computedStyles.letterSpacing,
17537
+ // The `line-height` attribute in SVG is JoinJS specific.
17529
17538
  'lineHeight': attrs['line-height'],
17530
- 'letter-spacing': attrs['letter-spacing']
17531
17539
  }, {
17532
17540
  // Provide an existing SVG Document here
17533
17541
  // instead of creating a temporary one over again.
@@ -20336,6 +20344,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
20336
20344
  'port-group': port.group
20337
20345
  });
20338
20346
 
20347
+ // If the port ID is a number, we need to add
20348
+ // extra information to the port element to distinguish
20349
+ // between ports with the same ID but different types.
20350
+ if (isNumber(port.id)) {
20351
+ portElement.attr('port-id-type', 'number');
20352
+ }
20353
+
20339
20354
  var labelMarkupDef = this._getPortLabelMarkup(port.label);
20340
20355
  if (Array.isArray(labelMarkupDef)) {
20341
20356
  // JSON Markup
@@ -23858,23 +23873,25 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
23858
23873
  return this;
23859
23874
  },
23860
23875
 
23861
- findAttribute: function(attributeName, node) {
23862
-
23876
+ findAttributeNode: function(attributeName, node) {
23863
23877
  var currentNode = node;
23864
-
23865
23878
  while (currentNode && currentNode.nodeType === 1) {
23866
- var attributeValue = currentNode.getAttribute(attributeName);
23867
23879
  // attribute found
23868
- if (attributeValue) { return attributeValue; }
23880
+ // (empty value does not count as attribute found)
23881
+ if (currentNode.getAttribute(attributeName)) { return currentNode; }
23869
23882
  // do not climb up the DOM
23870
23883
  if (currentNode === this.el) { return null; }
23871
23884
  // try parent node
23872
23885
  currentNode = currentNode.parentNode;
23873
23886
  }
23874
-
23875
23887
  return null;
23876
23888
  },
23877
23889
 
23890
+ findAttribute: function(attributeName, node) {
23891
+ var matchedNode = this.findAttributeNode(attributeName, node);
23892
+ return matchedNode && matchedNode.getAttribute(attributeName);
23893
+ },
23894
+
23878
23895
  // Override the mvc ViewBase `_ensureElement()` method in order to create an
23879
23896
  // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.
23880
23897
  // Expose class name setter as a separate method.
@@ -27322,8 +27339,14 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27322
27339
  var ty = target.y0;
27323
27340
 
27324
27341
  if (tx === ax && ty < sy0) { return Directions$2.BOTTOM; }
27325
- if (tx < ax && ty < smy0) { return Directions$2.RIGHT; }
27326
- if (tx > ax && ty < smy0) { return Directions$2.LEFT; }
27342
+ if (tx < ax && ty < smy0) {
27343
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27344
+ return Directions$2.RIGHT;
27345
+ }
27346
+ if (tx > ax && ty < smy0) {
27347
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27348
+ return Directions$2.LEFT;
27349
+ }
27327
27350
  if (tx < smx0 && ty >= sy0) { return Directions$2.TOP; }
27328
27351
  if (tx > smx1 && ty >= sy0) { return Directions$2.TOP; }
27329
27352
  if (tx >= smx0 && tx <= ax && ty > sy1) {
@@ -27362,8 +27385,14 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27362
27385
  var ty = target.y0;
27363
27386
 
27364
27387
  if (tx === ax && ty > sy1) { return Directions$2.TOP; }
27365
- if (tx < ax && ty > smy1) { return Directions$2.RIGHT; }
27366
- if (tx > ax && ty > smy1) { return Directions$2.LEFT; }
27388
+ if (tx < ax && ty > smy1) {
27389
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27390
+ return Directions$2.RIGHT;
27391
+ }
27392
+ if (tx > ax && ty > smy1) {
27393
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27394
+ return Directions$2.LEFT;
27395
+ }
27367
27396
  if (tx < smx0 && ty <= sy1) { return Directions$2.BOTTOM; }
27368
27397
  if (tx > smx1 && ty <= sy1) { return Directions$2.BOTTOM; }
27369
27398
  if (tx >= smx0 && tx <= ax && ty < sy0) {
@@ -27574,11 +27603,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27574
27603
  return outsidePoint;
27575
27604
  }
27576
27605
 
27577
- function routeBetweenPoints(source, target) {
27606
+ function routeBetweenPoints(source, target, opt) {
27607
+ if ( opt === void 0 ) opt = {};
27608
+
27578
27609
  var sourcePoint = source.point;
27579
27610
  var sx0 = source.x0;
27580
27611
  var sy0 = source.y0;
27581
- var sourceView = source.view;
27582
27612
  var sourceWidth = source.width;
27583
27613
  var sourceHeight = source.height;
27584
27614
  var sourceMargin = source.margin;
@@ -27588,14 +27618,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27588
27618
  var targetWidth = target.width;
27589
27619
  var targetHeight = target.height;
27590
27620
  var targetMargin = target.margin;
27621
+ var targetInSourceBBox = opt.targetInSourceBBox; if ( targetInSourceBBox === void 0 ) targetInSourceBBox = false;
27591
27622
 
27592
27623
  var tx1 = tx0 + targetWidth;
27593
27624
  var ty1 = ty0 + targetHeight;
27594
27625
  var sx1 = sx0 + sourceWidth;
27595
27626
  var sy1 = sy0 + sourceHeight;
27596
27627
 
27597
- var isSourceEl = sourceView && sourceView.model.isElement();
27598
-
27599
27628
  // Key coordinates including the margin
27600
27629
  var smx0 = sx0 - sourceMargin;
27601
27630
  var smx1 = sx1 + sourceMargin;
@@ -27625,10 +27654,15 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27625
27654
  var middleOfVerticalSides = (scx < tcx ? (sx1 + tx0) : (tx1 + sx0)) / 2;
27626
27655
  var middleOfHorizontalSides = (scy < tcy ? (sy1 + ty0) : (ty1 + sy0)) / 2;
27627
27656
 
27657
+ var sourceBBox = new Rect(sx0, sy0, sourceWidth, sourceHeight);
27658
+ var targetBBox = new Rect(tx0, ty0, targetWidth, targetHeight);
27659
+ var inflatedSourceBBox = sourceBBox.clone().inflate(sourceMargin);
27660
+ var inflatedTargetBBox = targetBBox.clone().inflate(targetMargin);
27661
+
27628
27662
  if (sourceSide === 'left' && targetSide === 'right') {
27629
27663
  if (smx0 <= tmx1) {
27630
27664
  var y = middleOfHorizontalSides;
27631
- if (sx1 <= tx0) {
27665
+ if (sox <= tmx0) {
27632
27666
  if (ty1 >= smy0 && toy < soy) {
27633
27667
  y = Math.min(tmy0, smy0);
27634
27668
  } else if (ty0 <= smy1 && toy >= soy) {
@@ -27649,7 +27683,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27649
27683
  { x: x, y: toy }
27650
27684
  ];
27651
27685
  } else if (sourceSide === 'right' && targetSide === 'left') {
27652
- if (smx1 >= tmx0) {
27686
+ if (sox >= tmx0) {
27653
27687
  var y$1 = middleOfHorizontalSides;
27654
27688
  if (sox > tx1) {
27655
27689
  if (ty1 >= smy0 && toy < soy) {
@@ -27673,16 +27707,20 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27673
27707
  { x: x$1, y: toy }
27674
27708
  ];
27675
27709
  } else if (sourceSide === 'top' && targetSide === 'bottom') {
27710
+ var isPointInsideSource = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27711
+
27676
27712
  if (soy < toy) {
27677
27713
  var x$2 = middleOfVerticalSides;
27678
27714
  var y$2 = soy;
27679
27715
 
27680
- if (soy < ty0) {
27681
- if (tx1 >= smx0 && tox < sox) {
27682
- x$2 = Math.min(tmx0, smx0);
27683
- } else if (tx0 <= smx1 && tox >= sox) {
27684
- x$2 = Math.max(tmx1, smx1);
27685
- }
27716
+ if (isPointInsideSource) {
27717
+ y$2 = Math.min(y$2, tmy0);
27718
+ }
27719
+
27720
+ if (tx1 >= smx0 && tox < sox) {
27721
+ x$2 = Math.min(tmx0, smx0);
27722
+ } else if (tx0 <= smx1 && tox >= sox) {
27723
+ x$2 = Math.max(tmx1, smx1);
27686
27724
  }
27687
27725
 
27688
27726
  return [
@@ -27698,16 +27736,20 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27698
27736
  { x: tox, y: y$3 }
27699
27737
  ];
27700
27738
  } else if (sourceSide === 'bottom' && targetSide === 'top') {
27701
- if (soy - sourceMargin > toy) {
27739
+ var isPointInsideSource$1 = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27740
+
27741
+ if (soy > toy) {
27702
27742
  var x$3 = middleOfVerticalSides;
27703
27743
  var y$4 = soy;
27704
27744
 
27705
- if (soy > ty1) {
27706
- if (tx1 >= smx0 && tox < sox) {
27707
- x$3 = Math.min(tmx0, smx0);
27708
- } else if (tx0 <= smx1 && tox >= sox) {
27709
- x$3 = Math.max(tmx1, smx1);
27710
- }
27745
+ if (isPointInsideSource$1) {
27746
+ y$4 = Math.max(y$4, tmy1);
27747
+ }
27748
+
27749
+ if (tx1 >= smx0 && tox < sox) {
27750
+ x$3 = Math.min(tmx0, smx0);
27751
+ } else if (tx0 <= smx1 && tox >= sox) {
27752
+ x$3 = Math.max(tmx1, smx1);
27711
27753
  }
27712
27754
 
27713
27755
  return [
@@ -27723,28 +27765,31 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27723
27765
  { x: tox, y: y$5 }
27724
27766
  ];
27725
27767
  } else if (sourceSide === 'top' && targetSide === 'top') {
27768
+ var useUShapeConnection =
27769
+ targetInSourceBBox ||
27770
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27771
+ (soy <= ty0 && (inflatedSourceBBox.bottomRight().x <= tox || inflatedSourceBBox.bottomLeft().x >= tox)) ||
27772
+ (soy >= ty0 && (inflatedTargetBBox.bottomRight().x <= sox || inflatedTargetBBox.bottomLeft().x >= sox));
27773
+
27774
+ if (useUShapeConnection) {
27775
+ return [
27776
+ { x: sox, y: Math.min(soy, toy) },
27777
+ { x: tox, y: Math.min(soy, toy) }
27778
+ ];
27779
+ }
27780
+
27726
27781
  var x$4;
27727
27782
  var y1 = Math.min((sy1 + ty0) / 2, toy);
27728
27783
  var y2 = Math.min((sy0 + ty1) / 2, soy);
27729
27784
 
27730
27785
  if (toy < soy) {
27731
- if (sox >= tmx1 || sox <= tmx0) {
27732
- return [
27733
- { x: sox, y: Math.min(soy, toy) },
27734
- { x: tox, y: Math.min(soy, toy) }
27735
- ];
27736
- } else if (tox > sox) {
27786
+ if (tox > sox) {
27737
27787
  x$4 = Math.min(sox, tmx0);
27738
27788
  } else {
27739
27789
  x$4 = Math.max(sox, tmx1);
27740
27790
  }
27741
27791
  } else {
27742
- if (tox >= smx1 || tox <= smx0) {
27743
- return [
27744
- { x: sox, y: Math.min(soy, toy) },
27745
- { x: tox, y: Math.min(soy, toy) }
27746
- ];
27747
- } else if (tox >= sox) {
27792
+ if (tox >= sox) {
27748
27793
  x$4 = Math.max(tox, smx1);
27749
27794
  } else {
27750
27795
  x$4 = Math.min(tox, smx0);
@@ -27758,28 +27803,31 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27758
27803
  { x: tox, y: y1 }
27759
27804
  ];
27760
27805
  } else if (sourceSide === 'bottom' && targetSide === 'bottom') {
27806
+ var useUShapeConnection$1 =
27807
+ targetInSourceBBox ||
27808
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27809
+ (soy >= toy && (inflatedSourceBBox.topRight().x <= tox || inflatedSourceBBox.topLeft().x >= tox)) ||
27810
+ (soy <= toy && (inflatedTargetBBox.topRight().x <= sox || inflatedTargetBBox.topLeft().x >= sox));
27811
+
27812
+ if (useUShapeConnection$1) {
27813
+ return [
27814
+ { x: sox, y: Math.max(soy, toy) },
27815
+ { x: tox, y: Math.max(soy, toy) }
27816
+ ];
27817
+ }
27818
+
27761
27819
  var x$5;
27762
27820
  var y1$1 = Math.max((sy0 + ty1) / 2, toy);
27763
27821
  var y2$1 = Math.max((sy1 + ty0) / 2, soy);
27764
27822
 
27765
27823
  if (toy > soy) {
27766
- if (sox >= tmx1 || sox <= tmx0) {
27767
- return [
27768
- { x: sox, y: Math.max(soy, toy) },
27769
- { x: tox, y: Math.max(soy, toy) }
27770
- ];
27771
- } else if (tox > sox) {
27824
+ if (tox > sox) {
27772
27825
  x$5 = Math.min(sox, tmx0);
27773
27826
  } else {
27774
27827
  x$5 = Math.max(sox, tmx1);
27775
27828
  }
27776
27829
  } else {
27777
- if (tox >= smx1 || tox <= smx0) {
27778
- return [
27779
- { x: sox, y: Math.max(soy, toy) },
27780
- { x: tox, y: Math.max(soy, toy) }
27781
- ];
27782
- } else if (tox >= sox) {
27830
+ if (tox >= sox) {
27783
27831
  x$5 = Math.max(tox, smx1);
27784
27832
  } else {
27785
27833
  x$5 = Math.min(tox, smx0);
@@ -27793,6 +27841,19 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27793
27841
  { x: tox, y: y1$1 }
27794
27842
  ];
27795
27843
  } else if (sourceSide === 'left' && targetSide === 'left') {
27844
+ var useUShapeConnection$2 =
27845
+ targetInSourceBBox ||
27846
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27847
+ (sox <= tox && (inflatedSourceBBox.bottomRight().y <= toy || inflatedSourceBBox.topRight().y >= toy)) ||
27848
+ (sox >= tox && (inflatedTargetBBox.bottomRight().y <= soy || inflatedTargetBBox.topRight().y >= soy));
27849
+
27850
+ if (useUShapeConnection$2) {
27851
+ return [
27852
+ { x: Math.min(sox, tox), y: soy },
27853
+ { x: Math.min(sox, tox), y: toy }
27854
+ ];
27855
+ }
27856
+
27796
27857
  var y$6;
27797
27858
  var x1 = Math.min((sx1 + tx0) / 2, tox);
27798
27859
  var x2 = Math.min((sx0 + tx1) / 2, sox);
@@ -27818,11 +27879,24 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27818
27879
  { x: x1, y: toy }
27819
27880
  ];
27820
27881
  } else if (sourceSide === 'right' && targetSide === 'right') {
27882
+ var useUShapeConnection$3 =
27883
+ targetInSourceBBox ||
27884
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27885
+ (sox >= tox && (inflatedSourceBBox.bottomLeft().y <= toy || inflatedSourceBBox.topLeft().y >= toy)) ||
27886
+ (sox <= tox && (inflatedTargetBBox.bottomLeft().y <= soy || inflatedTargetBBox.topLeft().y >= soy));
27887
+
27888
+ if (useUShapeConnection$3) {
27889
+ return [
27890
+ { x: Math.max(sox, tox), y: soy },
27891
+ { x: Math.max(sox, tox), y: toy }
27892
+ ];
27893
+ }
27894
+
27821
27895
  var y$7;
27822
27896
  var x1$1 = Math.max((sx0 + tx1) / 2, tox);
27823
27897
  var x2$1 = Math.max((sx1 + tx0) / 2, sox);
27824
27898
 
27825
- if (tox < sox) {
27899
+ if (tox <= sox) {
27826
27900
  if (toy <= soy) {
27827
27901
  y$7 = Math.min(smy0, toy);
27828
27902
  } else {
@@ -27843,16 +27917,44 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27843
27917
  { x: x1$1, y: toy }
27844
27918
  ];
27845
27919
  } else if (sourceSide === 'top' && targetSide === 'right') {
27846
- if (soy > toy) {
27920
+ var isPointInsideSource$2 = inflatedSourceBBox.containsPoint(targetPoint);
27921
+
27922
+ // The target point is inside the source element
27923
+ if (isPointInsideSource$2) {
27924
+ if (sox <= tmx1) {
27925
+ var x$6 = Math.max(sox + sourceMargin, tox);
27926
+ var y$8 = Math.min(smy0, tmy0);
27927
+
27928
+ // Target anchor is on the right side of the source anchor
27929
+ return [
27930
+ { x: sox, y: y$8 },
27931
+ { x: x$6, y: y$8 },
27932
+ { x: x$6, y: toy }
27933
+ ];
27934
+ }
27935
+
27936
+ // Target anchor is on the left side of the source anchor
27937
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
27938
+ var anchorMiddleX = (sox - sourceMargin + tox) / 2;
27939
+
27940
+ return [
27941
+ { x: sox, y: soy },
27942
+ { x: anchorMiddleX, y: soy },
27943
+ { x: anchorMiddleX, y: toy }
27944
+ ];
27945
+ }
27946
+
27947
+ if (smy0 > toy) {
27847
27948
  if (sox < tox) {
27848
- var y$8 = middleOfHorizontalSides;
27949
+ var y$9 = tmy0;
27849
27950
 
27850
- if ((y$8 > tcy || !isSourceEl) && y$8 < tmy1 && sox < tx0) {
27851
- y$8 = tmy0;
27951
+ if (tmy1 <= smy0 && tmx1 >= sox) {
27952
+ y$9 = middleOfHorizontalSides;
27852
27953
  }
27954
+
27853
27955
  return [
27854
- { x: sox, y: y$8 },
27855
- { x: tox, y: y$8 },
27956
+ { x: sox, y: y$9 },
27957
+ { x: tox, y: y$9 },
27856
27958
  { x: tox, y: toy }
27857
27959
  ];
27858
27960
  }
@@ -27860,273 +27962,523 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
27860
27962
  return [{ x: sox, y: toy }];
27861
27963
  }
27862
27964
 
27863
- var x$6 = Math.max(middleOfVerticalSides, tmx1);
27965
+ var x$7 = Math.max(middleOfVerticalSides, tmx1);
27864
27966
 
27865
- if (tox < sox && toy > sy0 && toy < sy1) {
27967
+ if (sox > tox && sy1 >= toy) {
27866
27968
  return [
27867
27969
  { x: sox, y: soy },
27868
- { x: x$6, y: soy },
27869
- { x: x$6, y: toy }
27970
+ { x: x$7, y: soy },
27971
+ { x: x$7, y: toy }
27870
27972
  ];
27871
27973
  }
27872
27974
 
27873
- if ((x$6 > smx0 && toy > sy0) || tx0 > sx1) {
27874
- var y$9 = Math.min(sy0 - sourceMargin, ty0 - targetMargin);
27875
- var x$7 = Math.max(sx1 + sourceMargin, tx1 + targetMargin);
27975
+ if (x$7 > smx0 && soy < ty1) {
27976
+ var y$10 = Math.min(smy0, tmy0);
27977
+ var x$8 = Math.max(smx1, tmx1);
27876
27978
  return [
27877
- { x: sox, y: y$9 },
27878
- { x: x$7, y: y$9 },
27879
- { x: x$7, y: toy }
27979
+ { x: sox, y: y$10 },
27980
+ { x: x$8, y: y$10 },
27981
+ { x: x$8, y: toy }
27880
27982
  ];
27881
27983
  }
27882
27984
 
27883
27985
  return [
27884
27986
  { x: sox, y: soy },
27885
- { x: Math.max(x$6, tox), y: soy },
27886
- { x: Math.max(x$6, tox), y: toy }
27987
+ { x: x$7, y: soy },
27988
+ { x: x$7, y: toy }
27887
27989
  ];
27888
27990
  } else if (sourceSide === 'top' && targetSide === 'left') {
27889
- if (soy > toy) {
27991
+ var isPointInsideSource$3 = inflatedSourceBBox.containsPoint(targetPoint);
27992
+
27993
+ // The target point is inside the source element
27994
+ if (isPointInsideSource$3) {
27995
+ if (sox >= tmx0) {
27996
+ var x$9 = Math.min(sox - sourceMargin, tox);
27997
+ var y$11 = Math.min(smy0, tmy0);
27998
+
27999
+ // Target anchor is on the left side of the source anchor
28000
+ return [
28001
+ { x: sox, y: y$11 },
28002
+ { x: x$9, y: y$11 },
28003
+ { x: x$9, y: toy }
28004
+ ];
28005
+ }
28006
+
28007
+ // Target anchor is on the right side of the source anchor
28008
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
28009
+ var anchorMiddleX$1 = (sox + sourceMargin + tox) / 2;
28010
+
28011
+ return [
28012
+ { x: sox, y: soy },
28013
+ { x: anchorMiddleX$1, y: soy },
28014
+ { x: anchorMiddleX$1, y: toy }
28015
+ ];
28016
+ }
28017
+
28018
+ if (smy0 > toy) {
27890
28019
  if (sox > tox) {
27891
- var y$10 = middleOfHorizontalSides;
28020
+ var y$12 = tmy0;
27892
28021
 
27893
- if ((y$10 > tcy || !isSourceEl) && y$10 < tmy1 && sox > tx1) {
27894
- y$10 = tmy0;
28022
+ if (tmy1 <= smy0 && tmx0 <= sox) {
28023
+ y$12 = middleOfHorizontalSides;
27895
28024
  }
28025
+
27896
28026
  return [
27897
- { x: sox, y: y$10 },
27898
- { x: tox, y: y$10 },
28027
+ { x: sox, y: y$12 },
28028
+ { x: tox, y: y$12 },
27899
28029
  { x: tox, y: toy }
27900
28030
  ];
27901
28031
  }
28032
+
27902
28033
  return [{ x: sox, y: toy }];
27903
28034
  }
27904
28035
 
27905
- var x$8 = Math.min(tmx0, middleOfVerticalSides);
28036
+ var x$10 = Math.min(tmx0, middleOfVerticalSides);
27906
28037
 
27907
28038
  if (sox < tox && sy1 >= toy) {
27908
28039
  return [
27909
28040
  { x: sox, y: soy },
27910
- { x: x$8, y: soy },
27911
- { x: x$8, y: toy }];
28041
+ { x: x$10, y: soy },
28042
+ { x: x$10, y: toy }];
27912
28043
  }
27913
28044
 
27914
- if (x$8 < smx1 && soy < ty1) {
27915
- var y$11 = Math.min(smy0, tmy0);
27916
- var x$9 = Math.min(smx0, tmx0);
28045
+ if (x$10 < smx1 && soy < ty1) {
28046
+ var y$13 = Math.min(smy0, tmy0);
28047
+ var x$11 = Math.min(smx0, tmx0);
27917
28048
  return [
27918
- { x: sox, y: y$11 },
27919
- { x: x$9, y: y$11 },
27920
- { x: x$9, y: toy }
28049
+ { x: sox, y: y$13 },
28050
+ { x: x$11, y: y$13 },
28051
+ { x: x$11, y: toy }
27921
28052
  ];
27922
28053
  }
28054
+
27923
28055
  return [
27924
28056
  { x: sox, y: soy },
27925
- { x: x$8, y: soy },
27926
- { x: x$8, y: toy }
28057
+ { x: x$10, y: soy },
28058
+ { x: x$10, y: toy }
27927
28059
  ];
27928
28060
  } else if (sourceSide === 'bottom' && targetSide === 'right') {
27929
- if (soy < toy) {
28061
+ var isPointInsideSource$4 = inflatedSourceBBox.containsPoint(targetPoint);
28062
+
28063
+ // The target point is inside the source element
28064
+ if (isPointInsideSource$4) {
28065
+ if (sox <= tmx1) {
28066
+ var x$12 = Math.max(sox + sourceMargin, tox);
28067
+ var y$14 = Math.max(smy1, tmy1);
28068
+
28069
+ // Target anchor is on the right side of the source anchor
28070
+ return [
28071
+ { x: sox, y: y$14 },
28072
+ { x: x$12, y: y$14 },
28073
+ { x: x$12, y: toy }
28074
+ ];
28075
+ }
28076
+
28077
+ // Target anchor is on the left side of the source anchor
28078
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
28079
+ var anchorMiddleX$2 = (sox - sourceMargin + tox) / 2;
28080
+
28081
+ return [
28082
+ { x: sox, y: soy },
28083
+ { x: anchorMiddleX$2, y: soy },
28084
+ { x: anchorMiddleX$2, y: toy }
28085
+ ];
28086
+ }
28087
+
28088
+ if (smy1 < toy) {
27930
28089
  if (sox < tox) {
27931
- var y$12 = middleOfHorizontalSides;
28090
+ var y$15 = tmy1;
27932
28091
 
27933
- if ((y$12 < tcy || !isSourceEl) && y$12 > tmy0 && sox < tx0) {
27934
- y$12 = tmy1;
28092
+ if (tmy0 >= smy1 && tmx1 >= sox) {
28093
+ y$15 = middleOfHorizontalSides;
27935
28094
  }
28095
+
27936
28096
  return [
27937
- { x: sox, y: y$12 },
27938
- { x: tox, y: y$12 },
28097
+ { x: sox, y: y$15 },
28098
+ { x: tox, y: y$15 },
27939
28099
  { x: tox, y: toy }
27940
28100
  ];
27941
28101
  }
28102
+
27942
28103
  return [{ x: sox, y: toy }];
27943
- } else {
27944
- if (sx0 < tox) {
27945
- var y$13 = Math.max(smy1, tmy1);
27946
- var x$10 = Math.max(smx1, tmx1);
27947
- return [
27948
- { x: sox, y: y$13 },
27949
- { x: x$10, y: y$13 },
27950
- { x: x$10, y: toy }
27951
- ];
27952
- }
27953
28104
  }
27954
28105
 
27955
- var x$11 = middleOfVerticalSides;
28106
+ var x$13 = Math.max(middleOfVerticalSides, tmx1);
28107
+
28108
+ if (sox > tox && sy0 <= toy) {
28109
+ return [
28110
+ { x: sox, y: soy },
28111
+ { x: x$13, y: soy },
28112
+ { x: x$13, y: toy }
28113
+ ];
28114
+ }
28115
+
28116
+ if (x$13 > smx0 && soy > ty0) {
28117
+ var y$16 = Math.max(smy1, tmy1);
28118
+ var x$14 = Math.max(smx1, tmx1);
28119
+ return [
28120
+ { x: sox, y: y$16 },
28121
+ { x: x$14, y: y$16 },
28122
+ { x: x$14, y: toy }
28123
+ ];
28124
+ }
27956
28125
 
27957
28126
  return [
27958
28127
  { x: sox, y: soy },
27959
- { x: x$11, y: soy },
27960
- { x: x$11, y: toy }
28128
+ { x: x$13, y: soy },
28129
+ { x: x$13, y: toy }
27961
28130
  ];
27962
28131
  } else if (sourceSide === 'bottom' && targetSide === 'left') {
27963
- if (soy < toy) {
28132
+ var isPointInsideSource$5 = inflatedSourceBBox.containsPoint(targetPoint);
28133
+
28134
+ // The target point is inside the source element
28135
+ if (isPointInsideSource$5) {
28136
+ if (sox >= tmx0) {
28137
+ var x$15 = Math.min(sox - sourceMargin, tox);
28138
+ var y$17 = Math.max(smy1, tmy1);
28139
+
28140
+ // Target anchor is on the left side of the source anchor
28141
+ return [
28142
+ { x: sox, y: y$17 },
28143
+ { x: x$15, y: y$17 },
28144
+ { x: x$15, y: toy }
28145
+ ];
28146
+ }
28147
+
28148
+ // Target anchor is on the right side of the source anchor
28149
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
28150
+ var anchorMiddleX$3 = (sox + sourceMargin + tox) / 2;
28151
+
28152
+ return [
28153
+ { x: sox, y: soy },
28154
+ { x: anchorMiddleX$3, y: soy },
28155
+ { x: anchorMiddleX$3, y: toy }
28156
+ ];
28157
+ }
28158
+
28159
+ if (smy1 < toy) {
27964
28160
  if (sox > tox) {
27965
- var y$14 = middleOfHorizontalSides;
28161
+ var y$18 = tmy1;
27966
28162
 
27967
- if ((y$14 < tcy || !isSourceEl) && y$14 > tmy0 && sox > tx1) {
27968
- y$14 = tmy1;
28163
+ if (tmy0 >= smy1 && tmx0 <= sox) {
28164
+ y$18 = middleOfHorizontalSides;
27969
28165
  }
28166
+
27970
28167
  return [
27971
- { x: sox, y: y$14 },
27972
- { x: tox, y: y$14 },
28168
+ { x: sox, y: y$18 },
28169
+ { x: tox, y: y$18 },
27973
28170
  { x: tox, y: toy }
27974
28171
  ];
27975
28172
  }
28173
+
27976
28174
  return [{ x: sox, y: toy }];
27977
- } else {
27978
- if (sx1 > tox) {
27979
- var y$15 = Math.max(smy1, tmy1);
27980
- var x$12 = Math.min(smx0, tmx0);
27981
- return [
27982
- { x: sox, y: y$15 },
27983
- { x: x$12, y: y$15 },
27984
- { x: x$12, y: toy }
27985
- ];
27986
- }
27987
28175
  }
27988
28176
 
27989
- var x$13 = middleOfVerticalSides;
28177
+ var x$16 = Math.min(tmx0, middleOfVerticalSides);
28178
+
28179
+ if (sox < tox && sy0 <= toy) {
28180
+ return [
28181
+ { x: sox, y: soy },
28182
+ { x: x$16, y: soy },
28183
+ { x: x$16, y: toy }
28184
+ ];
28185
+ }
28186
+
28187
+ if (x$16 < smx1 && soy > ty0) {
28188
+ var y$19 = Math.max(smy1, tmy1);
28189
+ var x$17 = Math.min(smx0, tmx0);
28190
+ return [
28191
+ { x: sox, y: y$19 },
28192
+ { x: x$17, y: y$19 },
28193
+ { x: x$17, y: toy }
28194
+ ];
28195
+ }
27990
28196
 
27991
28197
  return [
27992
28198
  { x: sox, y: soy },
27993
- { x: x$13, y: soy },
27994
- { x: x$13, y: toy }
28199
+ { x: x$16, y: soy },
28200
+ { x: x$16, y: toy }
27995
28201
  ];
27996
- }
27997
- else if (sourceSide === 'left' && targetSide === 'bottom') {
27998
- if (sox >= tox && soy >= tmy1) {
27999
- return [{ x: tox, y: soy }];
28000
- }
28202
+ } else if (sourceSide === 'left' && targetSide === 'bottom') {
28203
+ var isPointInsideSource$6 = inflatedSourceBBox.containsPoint(targetPoint);
28001
28204
 
28002
- if (sox >= tx1 && soy < toy) {
28003
- var x$14 = middleOfVerticalSides;
28205
+ // The target point is inside the source element
28206
+ if (isPointInsideSource$6) {
28207
+ if (soy <= tmy1) {
28208
+ var x$18 = Math.min(smx0, tmx0);
28209
+ var y$20 = Math.max(soy + sourceMargin, toy);
28210
+
28211
+ return [
28212
+ { x: x$18, y: soy },
28213
+ { x: x$18, y: y$20 },
28214
+ { x: tox, y: y$20 }
28215
+ ];
28216
+ }
28217
+
28218
+ // Target anchor is above the source anchor
28219
+ var anchorMiddleY = (soy - sourceMargin + toy) / 2;
28004
28220
 
28005
28221
  return [
28006
- { x: x$14, y: soy },
28007
- { x: x$14, y: toy },
28008
- { x: tox, y: toy }
28222
+ { x: sox, y: soy },
28223
+ { x: sox, y: anchorMiddleY },
28224
+ { x: tox, y: anchorMiddleY }
28009
28225
  ];
28010
28226
  }
28011
28227
 
28012
- if (tox < sx1 && ty1 <= sy0) {
28013
- var y$16 = middleOfHorizontalSides;
28228
+ if (smx0 > tox) {
28229
+ if (soy < toy) {
28230
+ var x$19 = tmx0;
28231
+
28232
+ if (tmx1 <= smx0 && tmy1 >= soy) {
28233
+ x$19 = middleOfVerticalSides;
28234
+ }
28235
+
28236
+ return [
28237
+ { x: x$19, y: soy },
28238
+ { x: x$19, y: toy },
28239
+ { x: tox, y: toy }
28240
+ ];
28241
+ }
28242
+
28243
+ return [{ x: tox, y: soy }];
28244
+ }
28245
+
28246
+ var y$21 = Math.max(tmy1, middleOfHorizontalSides);
28014
28247
 
28248
+ if (soy > toy && sx1 >= tox) {
28015
28249
  return [
28016
28250
  { x: sox, y: soy },
28017
- { x: sox, y: y$16 },
28018
- { x: tox, y: y$16 }
28251
+ { x: sox, y: y$21 },
28252
+ { x: tox, y: y$21 }
28019
28253
  ];
28020
28254
  }
28021
28255
 
28022
- var x$15 = Math.min(tmx0, sox);
28023
- var y$17 = Math.max(smy1, tmy1);
28256
+ if (y$21 > smy0 && sox < tx1) {
28257
+ var x$20 = Math.min(smx0, tmx0);
28258
+ var y$22 = Math.max(smy1, tmy1);
28259
+
28260
+ return [
28261
+ { x: x$20, y: soy },
28262
+ { x: x$20, y: y$22 },
28263
+ { x: tox, y: y$22 }
28264
+ ];
28265
+ }
28024
28266
 
28025
28267
  return [
28026
- { x: x$15, y: soy },
28027
- { x: x$15, y: y$17 },
28028
- { x: tox, y: y$17 }
28268
+ { x: sox, y: soy },
28269
+ { x: sox, y: y$21 },
28270
+ { x: tox, y: y$21 }
28029
28271
  ];
28030
28272
  } else if (sourceSide === 'left' && targetSide === 'top') {
28031
- if (sox > tox && soy < tmy0) {
28032
- return [{ x: tox, y: soy }];
28273
+ var isPointInsideSource$7 = inflatedSourceBBox.containsPoint(targetPoint);
28274
+
28275
+ // The target point is inside the source element
28276
+ if (isPointInsideSource$7) {
28277
+ if (soy >= tmy0) {
28278
+ var y$23 = Math.min(soy - sourceMargin, toy);
28279
+ var x$21 = Math.min(smx0, tmx0);
28280
+
28281
+ // Target anchor is on the top side of the source anchor
28282
+ return [
28283
+ { x: x$21, y: soy },
28284
+ { x: x$21, y: y$23 },
28285
+ { x: tox, y: y$23 }
28286
+ ];
28287
+ }
28288
+
28289
+ // Target anchor is below the source anchor
28290
+ // Add the `sourceMargin` since the source anchor is above the target anchor
28291
+ var anchorMiddleY$1 = (soy + sourceMargin + toy) / 2;
28292
+
28293
+ return [
28294
+ { x: sox, y: soy },
28295
+ { x: sox, y: anchorMiddleY$1 },
28296
+ { x: tox, y: anchorMiddleY$1 }
28297
+ ];
28033
28298
  }
28034
28299
 
28035
- if (sox >= tx1) {
28300
+ if (smx0 > tox) {
28036
28301
  if (soy > toy) {
28037
- var x$16 = middleOfVerticalSides;
28302
+ var x$22 = tmx0;
28303
+
28304
+ if (tmx1 <= smx0 && tmy0 <= soy) {
28305
+ x$22 = middleOfVerticalSides;
28306
+ }
28038
28307
 
28039
28308
  return [
28040
- { x: x$16, y: soy },
28041
- { x: x$16, y: toy },
28309
+ { x: x$22, y: soy },
28310
+ { x: x$22, y: toy },
28042
28311
  { x: tox, y: toy }
28043
28312
  ];
28044
28313
  }
28314
+
28315
+ return [{ x: tox, y: soy }];
28045
28316
  }
28046
28317
 
28047
- if (tox <= sx1 && toy > soy) {
28048
- var y$18 = middleOfHorizontalSides;
28318
+ var y$24 = Math.min(tmy0, middleOfHorizontalSides);
28049
28319
 
28320
+ if (soy < toy && sx1 >= tox) {
28050
28321
  return [
28051
28322
  { x: sox, y: soy },
28052
- { x: sox, y: y$18 },
28053
- { x: tox, y: y$18 } ];
28323
+ { x: sox, y: y$24 },
28324
+ { x: tox, y: y$24 }];
28054
28325
  }
28055
28326
 
28056
- var x$17 = toy < soy ? Math.min(smx0, tmx0) : smx0;
28057
- var y$19 = Math.min(smy0, tmy0);
28327
+ if (y$24 < smy1 && sox < tx1) {
28328
+ var x$23 = Math.min(smx0, tmx0);
28329
+ var y$25 = Math.min(smy0, tmy0);
28330
+ return [
28331
+ { x: x$23, y: soy },
28332
+ { x: x$23, y: y$25 },
28333
+ { x: tox, y: y$25 }
28334
+ ];
28335
+ }
28058
28336
 
28059
28337
  return [
28060
- { x: x$17, y: soy },
28061
- { x: x$17, y: y$19 },
28062
- { x: tox, y: y$19 }
28338
+ { x: sox, y: soy },
28339
+ { x: sox, y: y$24 },
28340
+ { x: tox, y: y$24 }
28063
28341
  ];
28064
-
28065
28342
  } else if (sourceSide === 'right' && targetSide === 'top') {
28066
- if (sox <= tox && soy < tmy0) {
28067
- return [{ x: tox, y: soy }];
28068
- }
28343
+ var isPointInsideSource$8 = inflatedSourceBBox.containsPoint(targetPoint);
28344
+
28345
+ // The target point is inside the source element
28346
+ if (isPointInsideSource$8) {
28347
+ if (soy >= tmy0) {
28348
+ var x$24 = Math.max(smx1, tmx1);
28349
+ var y$26 = Math.min(soy - sourceMargin, toy);
28350
+
28351
+ // Target anchor is on the top side of the source anchor
28352
+ return [
28353
+ { x: x$24, y: soy },
28354
+ { x: x$24, y: y$26 }, // Path adjustment for right side start
28355
+ { x: tox, y: y$26 }
28356
+ ];
28357
+ }
28069
28358
 
28070
- if (sx1 < tx0 && soy > toy) {
28071
- var x$18 = middleOfVerticalSides;
28359
+ // Target anchor is below the source anchor
28360
+ // Adjust sourceMargin calculation since the source anchor is now on the right
28361
+ var anchorMiddleY$2 = (soy + sourceMargin + toy) / 2;
28072
28362
 
28073
28363
  return [
28074
- { x: x$18, y: soy },
28075
- { x: x$18, y: toy },
28076
- { x: tox, y: toy }
28364
+ { x: sox, y: soy },
28365
+ { x: sox, y: anchorMiddleY$2 },
28366
+ { x: tox, y: anchorMiddleY$2 }
28077
28367
  ];
28078
28368
  }
28079
28369
 
28080
- if (tox < sox && ty0 > sy1) {
28081
- var y$20 = middleOfHorizontalSides;
28370
+ if (smx1 < tox) {
28371
+ if (soy > toy) {
28372
+ var x$25 = tmx1;
28082
28373
 
28374
+ if (tmx0 >= smx1 && tmy0 <= soy) {
28375
+ x$25 = middleOfVerticalSides;
28376
+ }
28377
+
28378
+ return [
28379
+ { x: x$25, y: soy },
28380
+ { x: x$25, y: toy },
28381
+ { x: tox, y: toy }
28382
+ ];
28383
+ }
28384
+
28385
+ return [{ x: tox, y: soy }];
28386
+ }
28387
+
28388
+ var y$27 = Math.min(tmy0, middleOfHorizontalSides);
28389
+
28390
+ if (soy < toy && sx0 <= tox) {
28083
28391
  return [
28084
28392
  { x: sox, y: soy },
28085
- { x: sox, y: y$20 },
28086
- { x: tox, y: y$20 }
28087
- ];
28393
+ { x: sox, y: y$27 },
28394
+ { x: tox, y: y$27 }];
28088
28395
  }
28089
28396
 
28090
- var x$19 = Math.max(smx1, tmx1);
28091
- var y$21 = Math.min(smy0, tmy0);
28397
+ if (y$27 < smy1 && sox > tx0) {
28398
+ var x$26 = Math.max(smx1, tmx1);
28399
+ var y$28 = Math.min(smy0, tmy0);
28400
+
28401
+ return [
28402
+ { x: x$26, y: soy },
28403
+ { x: x$26, y: y$28 },
28404
+ { x: tox, y: y$28 }
28405
+ ];
28406
+ }
28092
28407
 
28093
28408
  return [
28094
- { x: x$19, y: soy },
28095
- { x: x$19, y: y$21 },
28096
- { x: tox, y: y$21 }
28409
+ { x: sox, y: soy },
28410
+ { x: sox, y: y$27 },
28411
+ { x: tox, y: y$27 }
28097
28412
  ];
28098
28413
  } else if (sourceSide === 'right' && targetSide === 'bottom') {
28099
- if (sox <= tox && soy >= tmy1) {
28100
- return [{ x: tox, y: soy }];
28101
- }
28414
+ var isPointInsideSource$9 = inflatedSourceBBox.containsPoint(targetPoint);
28102
28415
 
28103
- if (sox <= tmx0 && soy < toy) {
28104
- var x$20 = middleOfVerticalSides;
28416
+ // The target point is inside the source element
28417
+ if (isPointInsideSource$9) {
28418
+ if (soy <= tmy1) {
28419
+ var x$27 = Math.max(smx1, tmx1);
28420
+ var y$29 = Math.max(soy + sourceMargin, toy);
28421
+
28422
+ return [
28423
+ { x: x$27, y: soy },
28424
+ { x: x$27, y: y$29 },
28425
+ { x: tox, y: y$29 }
28426
+ ];
28427
+ }
28428
+
28429
+ // Target anchor is above the source anchor
28430
+ var anchorMiddleY$3 = (soy - sourceMargin + toy) / 2;
28105
28431
 
28106
28432
  return [
28107
- { x: x$20, y: soy },
28108
- { x: x$20, y: toy },
28109
- { x: tox, y: toy }
28433
+ { x: sox, y: soy },
28434
+ { x: sox, y: anchorMiddleY$3 },
28435
+ { x: tox, y: anchorMiddleY$3 }
28110
28436
  ];
28111
28437
  }
28112
28438
 
28113
- if (tox > sx0 && ty1 < sy0) {
28114
- var y$22 = middleOfHorizontalSides;
28439
+ if (smx1 < tox) {
28440
+ if (soy < toy) {
28441
+ var x$28 = tmx1;
28442
+
28443
+ if (tmx0 >= smx1 && tmy1 >= soy) {
28444
+ x$28 = middleOfVerticalSides;
28445
+ }
28446
+
28447
+ return [
28448
+ { x: x$28, y: soy },
28449
+ { x: x$28, y: toy },
28450
+ { x: tox, y: toy }
28451
+ ];
28452
+ }
28453
+
28454
+ return [{ x: tox, y: soy }];
28455
+ }
28456
+
28457
+ var y$30 = Math.max(tmy1, middleOfHorizontalSides);
28115
28458
 
28459
+ if (soy > toy && sx0 <= tox) {
28116
28460
  return [
28117
28461
  { x: sox, y: soy },
28118
- { x: sox, y: y$22 },
28119
- { x: tox, y: y$22 }
28462
+ { x: sox, y: y$30 },
28463
+ { x: tox, y: y$30 }
28120
28464
  ];
28121
28465
  }
28122
28466
 
28123
- var x$21 = Math.max(tmx1, sox);
28124
- var y$23 = Math.max(smy1, tmy1);
28467
+ if (y$30 > smy0 && sox > tx0) {
28468
+ var x$29 = Math.max(smx1, tmx1);
28469
+ var y$31 = Math.max(smy1, tmy1);
28470
+
28471
+ return [
28472
+ { x: x$29, y: soy },
28473
+ { x: x$29, y: y$31 },
28474
+ { x: tox, y: y$31 }
28475
+ ];
28476
+ }
28125
28477
 
28126
28478
  return [
28127
- { x: x$21, y: soy },
28128
- { x: x$21, y: y$23 },
28129
- { x: tox, y: y$23 }
28479
+ { x: sox, y: soy },
28480
+ { x: sox, y: y$30 },
28481
+ { x: tox, y: y$30 }
28130
28482
  ];
28131
28483
  }
28132
28484
  }
@@ -28162,7 +28514,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
28162
28514
  dummySource.direction = fromDirection;
28163
28515
  firstVertex.direction = toDirection;
28164
28516
 
28165
- resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex).concat( [firstVertex.point] ));
28517
+ resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex, { targetInSourceBBox: true }).concat( [firstVertex.point] ));
28166
28518
  } else {
28167
28519
  // The first point responsible for the initial direction of the route
28168
28520
  var next = verticesData[1] || targetPoint;
@@ -30263,13 +30615,18 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
30263
30615
 
30264
30616
  var model = this.model;
30265
30617
  var id = model.id;
30266
- var port = this.findAttribute('port', magnet);
30618
+ // Find a node with the `port` attribute set on it.
30619
+ var portNode = this.findAttributeNode('port', magnet);
30267
30620
  // Find a unique `selector` of the element under pointer that is a magnet.
30268
30621
  var selector = magnet.getAttribute('joint-selector');
30269
30622
 
30270
30623
  var end = { id: id };
30271
30624
  if (selector != null) { end.magnet = selector; }
30272
- if (port != null) {
30625
+ if (portNode != null) {
30626
+ var port = portNode.getAttribute('port');
30627
+ if (portNode.getAttribute('port-id-type') === 'number') {
30628
+ port = parseInt(port, 10);
30629
+ }
30273
30630
  end.port = port;
30274
30631
  if (!model.hasPort(port) && !selector) {
30275
30632
  // port created via the `port` attribute (not API)
@@ -34324,6 +34681,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34324
34681
  },
34325
34682
 
34326
34683
  renderGrid: function renderGrid() {
34684
+ var this$1 = this;
34685
+
34327
34686
 
34328
34687
  var ref = this;
34329
34688
  var paper = ref.options.paper;
@@ -34343,7 +34702,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34343
34702
 
34344
34703
  gridSettings.forEach(function (gridLayerSetting, index) {
34345
34704
 
34346
- var id = 'pattern_' + index;
34705
+ var id = this$1._getPatternId(index);
34347
34706
  var options = merge({}, gridLayerSetting);
34348
34707
  var scaleFactor = options.scaleFactor; if ( scaleFactor === void 0 ) scaleFactor = 1;
34349
34708
  options.width = gridSize * scaleFactor || 1;
@@ -34371,6 +34730,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34371
34730
  },
34372
34731
 
34373
34732
  updateGrid: function updateGrid() {
34733
+ var this$1 = this;
34734
+
34374
34735
 
34375
34736
  var ref = this;
34376
34737
  var grid = ref._gridCache;
@@ -34391,12 +34752,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34391
34752
  }
34392
34753
  gridSettings.forEach(function (options, index) {
34393
34754
  if (isFunction(options.update)) {
34394
- var vPattern = patterns['pattern_' + index];
34755
+ var vPattern = patterns[this$1._getPatternId(index)];
34395
34756
  options.update(vPattern.node.firstChild, options, paper);
34396
34757
  }
34397
34758
  });
34398
34759
  },
34399
34760
 
34761
+ _getPatternId: function _getPatternId(index) {
34762
+ return ("pattern_" + (this.options.paper.cid) + "_" + index);
34763
+ },
34764
+
34400
34765
  _getGridRefs: function _getGridRefs() {
34401
34766
  var ref = this;
34402
34767
  var grid = ref._gridCache;
@@ -34826,6 +35191,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
34826
35191
  },
34827
35192
 
34828
35193
  _resetUpdates: function() {
35194
+ if (this._updates && this._updates.id) { cancelFrame(this._updates.id); }
35195
+
34829
35196
  return this._updates = {
34830
35197
  id: null,
34831
35198
  priorities: [{}, {}, {}],
@@ -38619,12 +38986,14 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
38619
38986
  evt.stopPropagation();
38620
38987
  evt.preventDefault();
38621
38988
  var relatedView = this.relatedView;
38989
+ var paper = relatedView.paper;
38622
38990
  relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
38623
38991
  relatedView.startArrowheadMove(this.arrowheadType);
38624
38992
  this.delegateDocumentEvents();
38625
- relatedView.paper.undelegateEvents();
38993
+ paper.undelegateEvents();
38626
38994
  this.focus();
38627
38995
  this.el.style.pointerEvents = 'none';
38996
+ relatedView.notifyPointerdown.apply(relatedView, paper.getPointerArgs(evt));
38628
38997
  },
38629
38998
  onPointerMove: function(evt) {
38630
38999
  var normalizedEvent = normalizeEvent(evt);
@@ -39579,7 +39948,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
39579
39948
  Control: Control
39580
39949
  });
39581
39950
 
39582
- var version = "4.0.1";
39951
+ var version = "4.0.3";
39583
39952
 
39584
39953
  var Vectorizer = V;
39585
39954
  var layout = { PortLabel: PortLabel, Port: Port };