@foblex/flow 1.5.4 → 1.5.6

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.
Files changed (127) hide show
  1. package/domain/clear-selection/clear-selection.handler.d.ts +11 -0
  2. package/domain/clear-selection/clear-selection.request.d.ts +2 -0
  3. package/domain/clear-selection/index.d.ts +2 -0
  4. package/domain/get-connection-vector/get-connection-vector.handler.d.ts +1 -1
  5. package/domain/get-element-rect-in-flow/get-element-rect-in-flow-request.d.ts +4 -0
  6. package/domain/{get-element-rect-in-flow.handler.d.ts → get-element-rect-in-flow/get-element-rect-in-flow.handler.d.ts} +4 -3
  7. package/domain/get-element-rect-in-flow/index.d.ts +2 -0
  8. package/domain/get-input-rect-in-flow/get-input-rect-in-flow-request.d.ts +4 -0
  9. package/domain/get-input-rect-in-flow/get-input-rect-in-flow-response.d.ts +7 -0
  10. package/domain/get-input-rect-in-flow/get-input-rect-in-flow.handler.d.ts +14 -0
  11. package/domain/get-input-rect-in-flow/index.d.ts +3 -0
  12. package/domain/get-nodes-rect/get-nodes-rect.handler.d.ts +11 -0
  13. package/domain/get-nodes-rect/get-nodes-rect.request.d.ts +2 -0
  14. package/domain/get-nodes-rect/index.d.ts +2 -0
  15. package/domain/get-output-rect-in-flow/get-output-rect-in-flow.handler.d.ts +3 -3
  16. package/domain/get-selection/get-selection.handler.d.ts +11 -0
  17. package/domain/get-selection/get-selection.request.d.ts +2 -0
  18. package/domain/get-selection/index.d.ts +2 -0
  19. package/domain/index.d.ts +6 -5
  20. package/domain/providers.d.ts +7 -5
  21. package/domain/redraw-connections/redraw-connections.handler.d.ts +1 -3
  22. package/domain/select-all/index.d.ts +2 -0
  23. package/domain/{select-all.handler.d.ts → select-all/select-all.handler.d.ts} +5 -4
  24. package/domain/select-all/select-all.request.d.ts +2 -0
  25. package/errors/conflict-error.d.ts +6 -0
  26. package/errors/create-error-class.d.ts +1 -0
  27. package/errors/errors.d.ts +3 -0
  28. package/errors/index.d.ts +4 -0
  29. package/errors/not-found-error.d.ts +6 -0
  30. package/esm2022/domain/clear-selection/clear-selection.handler.mjs +28 -0
  31. package/esm2022/domain/clear-selection/clear-selection.request.mjs +3 -0
  32. package/esm2022/domain/clear-selection/index.mjs +3 -0
  33. package/esm2022/domain/get-connection-vector/get-connection-vector.handler.mjs +3 -3
  34. package/esm2022/domain/get-element-rect-in-flow/get-element-rect-in-flow-request.mjs +6 -0
  35. package/esm2022/domain/get-element-rect-in-flow/get-element-rect-in-flow.handler.mjs +35 -0
  36. package/esm2022/domain/get-element-rect-in-flow/index.mjs +3 -0
  37. package/esm2022/domain/get-input-rect-in-flow/get-input-rect-in-flow-request.mjs +6 -0
  38. package/esm2022/domain/get-input-rect-in-flow/get-input-rect-in-flow-response.mjs +7 -0
  39. package/esm2022/domain/get-input-rect-in-flow/get-input-rect-in-flow.handler.mjs +34 -0
  40. package/esm2022/domain/get-input-rect-in-flow/index.mjs +4 -0
  41. package/esm2022/domain/get-nodes-rect/get-nodes-rect.handler.mjs +30 -0
  42. package/esm2022/domain/get-nodes-rect/get-nodes-rect.request.mjs +3 -0
  43. package/esm2022/domain/get-nodes-rect/index.mjs +3 -0
  44. package/esm2022/domain/get-output-rect-in-flow/get-output-rect-in-flow.handler.mjs +9 -8
  45. package/esm2022/domain/get-selection/get-selection.handler.mjs +35 -0
  46. package/esm2022/domain/get-selection/get-selection.request.mjs +3 -0
  47. package/esm2022/domain/get-selection/index.mjs +3 -0
  48. package/esm2022/domain/index.mjs +7 -6
  49. package/esm2022/domain/providers.mjs +12 -8
  50. package/esm2022/domain/redraw-connections/redraw-connections.handler.mjs +8 -9
  51. package/esm2022/domain/select-all/index.mjs +3 -0
  52. package/esm2022/domain/select-all/select-all.handler.mjs +38 -0
  53. package/esm2022/domain/select-all/select-all.request.mjs +3 -0
  54. package/esm2022/errors/conflict-error.mjs +7 -0
  55. package/esm2022/errors/create-error-class.mjs +11 -0
  56. package/esm2022/errors/errors.mjs +12 -0
  57. package/esm2022/errors/index.mjs +5 -0
  58. package/esm2022/errors/not-found-error.mjs +7 -0
  59. package/esm2022/f-canvas/f-canvas.component.mjs +15 -12
  60. package/esm2022/f-connection/common/e-f-connection-behavior.mjs +2 -1
  61. package/esm2022/f-connectors/f-connector-base.mjs +2 -1
  62. package/esm2022/f-connectors/f-node-output/f-node-output-base.mjs +2 -2
  63. package/esm2022/f-connectors/f-node-output/f-node-output.directive.mjs +9 -2
  64. package/esm2022/f-draggable/connections/create-connection/create-connection.on-pointer-up.mjs +3 -3
  65. package/esm2022/f-draggable/connections/create-connection/create-connection.prepare-drag-sequence.mjs +9 -10
  66. package/esm2022/f-draggable/connections/find-inputs-under-pointer/find-inputs-under-pointer.handler.mjs +3 -3
  67. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.drag-handler.mjs +5 -6
  68. package/esm2022/f-draggable/connections/reassign-connection/reassign-connection.prepare-drag-sequence.mjs +2 -2
  69. package/esm2022/f-draggable/external-item/external-item.drag-handler.mjs +1 -4
  70. package/esm2022/f-draggable/external-item/external-item.on-pointer-up.mjs +9 -8
  71. package/esm2022/f-draggable/external-item/external-item.prepare-drag-sequence.mjs +4 -1
  72. package/esm2022/f-draggable/f-draggable-base.mjs +148 -7
  73. package/esm2022/f-draggable/f-draggable.directive.mjs +19 -24
  74. package/esm2022/f-draggable/f-selection-change-event.mjs +7 -0
  75. package/esm2022/f-draggable/index.mjs +2 -2
  76. package/esm2022/f-draggable/node/connection-source.drag-handler.mjs +4 -5
  77. package/esm2022/f-draggable/node/connection-target.drag-handler.mjs +4 -5
  78. package/esm2022/f-draggable/node/connection.drag-handler.mjs +4 -5
  79. package/esm2022/f-draggable/node/domain/is-connection-under-node/is-connection-under-node.handler.mjs +10 -7
  80. package/esm2022/f-draggable/node/node.prepare-drag-sequence.mjs +8 -9
  81. package/esm2022/f-draggable/selection-area/get-can-be-selected-items/get-can-be-selected-items.handler.mjs +9 -8
  82. package/esm2022/f-draggable/single-select/index.mjs +1 -2
  83. package/esm2022/f-draggable/single-select/single-select.on-pointer-down.mjs +2 -2
  84. package/esm2022/f-external-item/f-external-item-base.mjs +1 -1
  85. package/esm2022/f-external-item/f-external-item.directive.mjs +10 -6
  86. package/esm2022/f-flow/f-flow.component.mjs +24 -12
  87. package/esm2022/f-line-alignment/f-line-alignment.component.mjs +9 -8
  88. package/f-canvas/f-canvas.component.d.ts +3 -5
  89. package/f-connection/common/e-f-connection-behavior.d.ts +1 -0
  90. package/f-connectors/f-connector-base.d.ts +1 -0
  91. package/f-connectors/f-node-output/f-node-output-base.d.ts +1 -0
  92. package/f-connectors/f-node-output/f-node-output.directive.d.ts +3 -1
  93. package/f-draggable/connections/create-connection/create-connection.prepare-drag-sequence.d.ts +1 -3
  94. package/f-draggable/connections/providers.d.ts +1 -1
  95. package/f-draggable/connections/reassign-connection/reassign-connection.drag-handler.d.ts +1 -3
  96. package/f-draggable/external-item/external-item.drag-handler.d.ts +1 -2
  97. package/f-draggable/external-item/external-item.on-pointer-up.d.ts +3 -3
  98. package/f-draggable/f-draggable-base.d.ts +38 -8
  99. package/f-draggable/f-draggable.directive.d.ts +6 -4
  100. package/f-draggable/index.d.ts +1 -1
  101. package/f-draggable/node/connection-source.drag-handler.d.ts +1 -3
  102. package/f-draggable/node/connection-target.drag-handler.d.ts +1 -3
  103. package/f-draggable/node/connection.drag-handler.d.ts +1 -3
  104. package/f-draggable/node/domain/is-connection-under-node/is-connection-under-node.handler.d.ts +4 -3
  105. package/f-draggable/node/node.prepare-drag-sequence.d.ts +2 -3
  106. package/f-draggable/node/providers.d.ts +1 -1
  107. package/f-draggable/selection-area/get-can-be-selected-items/get-can-be-selected-items.handler.d.ts +3 -3
  108. package/f-draggable/single-select/index.d.ts +0 -1
  109. package/f-external-item/f-external-item-base.d.ts +7 -6
  110. package/f-external-item/f-external-item.directive.d.ts +6 -5
  111. package/f-flow/f-flow.component.d.ts +7 -4
  112. package/f-line-alignment/f-line-alignment.component.d.ts +3 -3
  113. package/fesm2022/foblex-flow.mjs +1735 -1609
  114. package/fesm2022/foblex-flow.mjs.map +1 -1
  115. package/package.json +1 -1
  116. package/domain/errors.d.ts +0 -3
  117. package/domain/get-all-nodes-rect.handler.d.ts +0 -10
  118. package/domain/get-input-rect-in-flow.handler.d.ts +0 -19
  119. package/esm2022/domain/errors.mjs +0 -10
  120. package/esm2022/domain/get-all-nodes-rect.handler.mjs +0 -23
  121. package/esm2022/domain/get-element-rect-in-flow.handler.mjs +0 -28
  122. package/esm2022/domain/get-input-rect-in-flow.handler.mjs +0 -25
  123. package/esm2022/domain/select-all.handler.mjs +0 -31
  124. package/esm2022/f-draggable/i-drag-and-drop-base.mjs +0 -147
  125. package/esm2022/f-draggable/single-select/f-selection-change-event.mjs +0 -7
  126. package/f-draggable/i-drag-and-drop-base.d.ts +0 -34
  127. /package/f-draggable/{single-select/f-selection-change-event.d.ts → f-selection-change-event.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Component, ChangeDetectionStrategy, Input, Directive, Injectable, ContentChild, Inject, ViewChild, ContentChildren, Optional, SkipSelf, EventEmitter, Output, NgModule } from '@angular/core';
3
- import { TransformModelExtensions, DomElementExtensions, PointExtensions, RectExtensions, BooleanExtensions, sanitizeElementId, Point, GuidExtensions, VectorExtensions, EventExtensions, mixinChangePosition, mixinFitToParent, mixinOneToOneCentering, mixinChangeZoom, SizeExtensions, MouseEventExtensions, IMouseEvent, ITouchDownEvent, ITouchMoveEvent, ITouchUpEvent } from '@foblex/core';
3
+ import { TransformModelExtensions, DomElementExtensions, PointExtensions, RectExtensions, BooleanExtensions, sanitizeElementId, Point, GuidExtensions, VectorExtensions, EventExtensions, mixinChangePosition, mixinFitToParent, mixinOneToOneCentering, mixinChangeZoom, MouseEventExtensions, IMouseEvent, ITouchDownEvent, ITouchMoveEvent, ITouchUpEvent, SizeExtensions } from '@foblex/core';
4
4
  import { Subject, Observable, Subscription, startWith, debounceTime } from 'rxjs';
5
5
  import * as i2 from '@angular/common';
6
6
  import { DOCUMENT, CommonModule } from '@angular/common';
@@ -346,6 +346,7 @@ class CalculateConnectorConnectableSideRequest {
346
346
  class FConnectorBase {
347
347
  constructor() {
348
348
  this.stateChanges = new Subject();
349
+ this.isSelfConnectable = true;
349
350
  this.fConnectableSide = EFConnectableSide.AUTO;
350
351
  this._fConnectableSide = EFConnectableSide.AUTO;
351
352
  }
@@ -546,7 +547,7 @@ class FNodeOutputBase extends FConnectorBase {
546
547
  this.isConnected = false;
547
548
  }
548
549
  get canBeConnected() {
549
- return !this.disabled && !this.isConnected;
550
+ return !this.disabled && (this.multiple ? true : !this.isConnected);
550
551
  }
551
552
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FNodeOutputBase, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
552
553
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FNodeOutputBase, usesInheritance: true, ngImport: i0 }); }
@@ -580,9 +581,11 @@ class FNodeOutputDirective extends FNodeOutputBase {
580
581
  this.fNode = fNode;
581
582
  this.fComponentsStore = fComponentsStore;
582
583
  this.id = `f-node-output-${uniqueId$5++}`;
584
+ this.multiple = false;
583
585
  this.isDisabled = false;
584
586
  this._fConnectableSide = EFConnectableSide.AUTO;
585
587
  this.isConnected = false;
588
+ this.isSelfConnectable = true;
586
589
  }
587
590
  ngOnInit() {
588
591
  if (!this.fNode) {
@@ -600,7 +603,7 @@ class FNodeOutputDirective extends FNodeOutputBase {
600
603
  this.fComponentsStore.removeOutput(this);
601
604
  }
602
605
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FNodeOutputDirective, deps: [{ token: i0.ElementRef }, { token: F_NODE }, { token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Directive }); }
603
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FNodeOutputDirective, selector: "[fNodeOutput]", inputs: { id: ["fOutputId", "id"], disabled: ["fOutputDisabled", "disabled"], _fConnectableSide: ["fOutputConnectableSide", "_fConnectableSide"] }, host: { properties: { "attr.data-f-output-id": "id", "class.f-node-output-disabled": "disabled" }, classAttribute: "f-component f-node-output" }, providers: [{ provide: F_NODE_OUTPUT, useExisting: FNodeOutputDirective }], exportAs: ["fNodeOutput"], usesInheritance: true, ngImport: i0 }); }
606
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FNodeOutputDirective, selector: "[fNodeOutput]", inputs: { id: ["fOutputId", "id"], multiple: ["fOutputMultiple", "multiple"], disabled: ["fOutputDisabled", "disabled"], _fConnectableSide: ["fOutputConnectableSide", "_fConnectableSide"], isSelfConnectable: "isSelfConnectable" }, host: { properties: { "attr.data-f-output-id": "id", "class.f-node-output-disabled": "disabled" }, classAttribute: "f-component f-node-output" }, providers: [{ provide: F_NODE_OUTPUT, useExisting: FNodeOutputDirective }], exportAs: ["fNodeOutput"], usesInheritance: true, ngImport: i0 }); }
604
607
  }
605
608
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FNodeOutputDirective, decorators: [{
606
609
  type: Directive,
@@ -620,12 +623,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
620
623
  }] }, { type: FComponentsStore }], propDecorators: { id: [{
621
624
  type: Input,
622
625
  args: ['fOutputId']
626
+ }], multiple: [{
627
+ type: Input,
628
+ args: ['fOutputMultiple']
623
629
  }], disabled: [{
624
630
  type: Input,
625
631
  args: ['fOutputDisabled']
626
632
  }], _fConnectableSide: [{
627
633
  type: Input,
628
634
  args: ['fOutputConnectableSide']
635
+ }], isSelfConnectable: [{
636
+ type: Input
629
637
  }] } });
630
638
 
631
639
  class FBezierPathBuilder extends FPathBuilderBase {
@@ -1311,6 +1319,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
1311
1319
  var EFConnectionBehavior;
1312
1320
  (function (EFConnectionBehavior) {
1313
1321
  EFConnectionBehavior["FIXED"] = "fixed";
1322
+ EFConnectionBehavior["FIXED_CENTER"] = "fixed_center";
1314
1323
  EFConnectionBehavior["FLOATING"] = "floating";
1315
1324
  })(EFConnectionBehavior || (EFConnectionBehavior = {}));
1316
1325
 
@@ -1902,14 +1911,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
1902
1911
  type: Directive
1903
1912
  }], ctorParameters: () => [] });
1904
1913
 
1905
- class GetConnectionVectorRequest {
1906
- constructor(outputRect, inputRect, behavior, outputSide, inputSide) {
1907
- this.outputRect = outputRect;
1908
- this.inputRect = inputRect;
1909
- this.behavior = behavior;
1910
- this.outputSide = outputSide;
1911
- this.inputSide = inputSide;
1912
- }
1914
+ class ClearSelectionRequest {
1913
1915
  }
1914
1916
 
1915
1917
  class FFlowMediator {
@@ -1940,1981 +1942,2092 @@ function FHandlerRegister(requestType) {
1940
1942
  };
1941
1943
  }
1942
1944
 
1943
- let GetConnectionVectorHandler = class GetConnectionVectorHandler {
1944
- constructor() {
1945
- this.behaviorHandlers = {
1946
- [EFConnectionBehavior.FLOATING.toString()]: this.floatingBehavior,
1947
- // [EFConnectionBehavior.FIXED.toString()]: this.fixedBehavior,
1948
- [EFConnectionBehavior.FIXED.toString()]: this.fixedOutboundBehaviour,
1949
- };
1945
+ var EFDraggableType;
1946
+ (function (EFDraggableType) {
1947
+ EFDraggableType["NODE"] = "node";
1948
+ EFDraggableType["REASSIGN_CONNECTION"] = "reassign-connection";
1949
+ EFDraggableType["CREATE_CONNECTION"] = "create-connection";
1950
+ EFDraggableType["CONNECTION"] = "connection";
1951
+ EFDraggableType["CANVAS"] = "canvas";
1952
+ EFDraggableType["PALETTE_ITEM"] = "palette-item";
1953
+ EFDraggableType["SELECTION"] = "selection";
1954
+ })(EFDraggableType || (EFDraggableType = {}));
1955
+
1956
+ class CanvasDragHandler {
1957
+ constructor(fComponentsStore) {
1958
+ this.fComponentsStore = fComponentsStore;
1959
+ this.type = EFDraggableType.CANVAS;
1960
+ this.onPointerDownPosition = PointExtensions.initialize();
1950
1961
  }
1951
- handle(payload) {
1952
- const result = this.behaviorHandlers[payload.behavior](payload);
1953
- return result;
1962
+ initialize() {
1963
+ this.onPointerDownPosition = this.fComponentsStore.fCanvas.transform.position;
1954
1964
  }
1955
- floatingBehavior(payload) {
1956
- const fromResult = RectExtensions.intersectionWithVector(payload.outputRect, payload.outputRect.gravityCenter, payload.inputRect.gravityCenter);
1957
- const toResult = RectExtensions.intersectionWithVector(payload.inputRect, payload.outputRect.gravityCenter, payload.inputRect.gravityCenter);
1958
- return {
1959
- point1: fromResult ? fromResult[1] : payload.outputRect.gravityCenter,
1960
- point2: toResult ? toResult[0] : payload.inputRect.gravityCenter,
1961
- };
1965
+ move(difference) {
1966
+ this.fComponentsStore.fCanvas.setPosition(Point.fromPoint(this.onPointerDownPosition).add(difference));
1967
+ this.fComponentsStore.fCanvas.redraw();
1962
1968
  }
1963
- fixedBehavior(payload) {
1964
- return {
1965
- point1: payload.outputRect.gravityCenter,
1966
- point2: payload.inputRect.gravityCenter,
1967
- };
1969
+ complete() {
1970
+ this.fComponentsStore.fCanvas.completeDrag();
1968
1971
  }
1969
- fixedOutboundBehaviour(payload) {
1970
- const point1 = positionFixedOutbound[payload.outputSide === EFConnectableSide.AUTO ? EFConnectableSide.BOTTOM : payload.outputSide](payload.outputRect);
1971
- const point2 = positionFixedOutbound[payload.inputSide === EFConnectableSide.AUTO ? EFConnectableSide.TOP : payload.inputSide](payload.inputRect);
1972
- return {
1973
- point1: point1,
1974
- point2: point2,
1975
- };
1972
+ }
1973
+
1974
+ class FDraggableDataContext {
1975
+ constructor() {
1976
+ this.selectedItems = [];
1977
+ this.isSelectedChanged = false;
1978
+ this.onPointerDownScale = 1;
1979
+ this.onPointerDownPosition = new Point(0, 0);
1980
+ this.draggableItems = [];
1976
1981
  }
1977
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1978
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler }); }
1979
- };
1980
- GetConnectionVectorHandler = __decorate([
1981
- FHandlerRegister(GetConnectionVectorRequest)
1982
- ], GetConnectionVectorHandler);
1983
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, decorators: [{
1982
+ reset() {
1983
+ this.draggableItems = [];
1984
+ this.onPointerDownScale = 1;
1985
+ this.onPointerDownPosition = new Point(0, 0);
1986
+ this.isSelectedChanged = false;
1987
+ }
1988
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1989
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext }); }
1990
+ }
1991
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext, decorators: [{
1984
1992
  type: Injectable
1985
1993
  }] });
1986
- const positionFixedOutbound = {
1987
- [EFConnectableSide.TOP]: (rect) => {
1988
- const result = new Point();
1989
- result.y = rect.y;
1990
- result.x = rect.x + rect.width / 2;
1991
- return result;
1992
- },
1993
- [EFConnectableSide.BOTTOM]: (rect) => {
1994
- const result = new Point();
1995
- result.y = rect.y + rect.height;
1996
- result.x = rect.x + rect.width / 2;
1997
- return result;
1998
- },
1999
- [EFConnectableSide.LEFT]: (rect) => {
2000
- const result = new Point();
2001
- result.x = rect.x;
2002
- result.y = rect.y + rect.height / 2;
2003
- return result;
2004
- },
2005
- [EFConnectableSide.RIGHT]: (rect) => {
2006
- const result = new Point();
2007
- result.x = rect.x + rect.width;
2008
- result.y = rect.y + rect.height / 2;
2009
- return result;
2010
- },
2011
- };
2012
1994
 
2013
- class GetOutputRectInFlowRequest {
2014
- constructor(fOutputId) {
2015
- this.fOutputId = fOutputId;
1995
+ class CanvasOnPointerUp {
1996
+ constructor(fDraggableDataContext) {
1997
+ this.fDraggableDataContext = fDraggableDataContext;
2016
1998
  }
1999
+ handle(event) {
2000
+ const isDragCanvas = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CANVAS);
2001
+ if (isDragCanvas) {
2002
+ this.fDraggableDataContext.draggableItems.forEach((x) => {
2003
+ x.complete?.();
2004
+ });
2005
+ }
2006
+ }
2007
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
2008
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp }); }
2017
2009
  }
2010
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp, decorators: [{
2011
+ type: Injectable
2012
+ }], ctorParameters: () => [{ type: FDraggableDataContext }] });
2018
2013
 
2019
- function OutputNotFound(outputId) {
2020
- return new Error(`Output with id ${outputId} not found`);
2021
- }
2022
- function InputNotFound(inputId) {
2023
- return new Error(`Input with id ${inputId} not found`);
2024
- }
2025
- function requiredOutput() {
2026
- return new Error(`The node must contain at least one fOutput if there is an fOutlet`);
2027
- }
2028
-
2029
- class GetOutputRectInFlowResponse {
2030
- constructor(rect, fConnectableSide) {
2031
- this.rect = rect;
2032
- this.fConnectableSide = fConnectableSide;
2014
+ class CanvasPrepareDragSequence {
2015
+ get flowHost() {
2016
+ return this.fComponentsStore.fFlow.hostElement;
2017
+ }
2018
+ constructor(fComponentsStore, fDraggableDataContext) {
2019
+ this.fComponentsStore = fComponentsStore;
2020
+ this.fDraggableDataContext = fDraggableDataContext;
2021
+ }
2022
+ handle(event) {
2023
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2024
+ const isBackgroundElement = this.fComponentsStore.fBackground?.isBackgroundElement(event.targetElement);
2025
+ const isFlowHost = this.flowHost.contains(event.targetElement);
2026
+ let node = this.fComponentsStore.findNode(event.targetElement);
2027
+ if (node && node.disabled) {
2028
+ node = undefined;
2029
+ }
2030
+ if ((isBackgroundElement || (isFlowHost && !node)) && !this.fDraggableDataContext.draggableItems.length) {
2031
+ this.fDraggableDataContext.onPointerDownScale = 1;
2032
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
2033
+ this.fDraggableDataContext.draggableItems = [
2034
+ new CanvasDragHandler(this.fComponentsStore)
2035
+ ];
2036
+ }
2033
2037
  }
2038
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
2039
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence }); }
2034
2040
  }
2041
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence, decorators: [{
2042
+ type: Injectable
2043
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }] });
2035
2044
 
2036
- class GetElementRectInFlowHandler {
2037
- get transform() {
2038
- return this.fComponentsStore.transform;
2045
+ const CANVAS_PROVIDERS = [
2046
+ CanvasOnPointerUp,
2047
+ CanvasPrepareDragSequence
2048
+ ];
2049
+
2050
+ class FindFirstCanBeConnectedOutputByOutletHandler {
2051
+ get fNodes() {
2052
+ return this.fComponentsStore.fNodes;
2039
2053
  }
2040
- get flowHost() {
2041
- return this.fComponentsStore.flowHost;
2054
+ get fOutputs() {
2055
+ return this.fComponentsStore.fOutputs;
2042
2056
  }
2043
2057
  constructor(fComponentsStore) {
2044
2058
  this.fComponentsStore = fComponentsStore;
2045
2059
  }
2046
- handle(element) {
2047
- const systemRect = RectExtensions.fromElement(element);
2048
- const position = Point.fromPoint(systemRect).elementTransform(this.flowHost).sub(this.transform.scaledPosition).sub(this.transform.position).div(this.transform.scale);
2049
- const size = SizeExtensions.initialize(systemRect.width / this.transform.scale, systemRect.height / this.transform.scale);
2050
- const result = RectExtensions.initialize(position.x, position.y, size.width, size.height);
2060
+ handle(outlet) {
2061
+ let result;
2062
+ const node = this.fNodes.find((x) => x.isContains(outlet.hostElement));
2063
+ if (!node) {
2064
+ throw new Error('Node not found');
2065
+ }
2066
+ const outputsOfNode = this.fOutputs.filter((x) => {
2067
+ return node.isContains(x.hostElement) && x.canBeConnected;
2068
+ });
2069
+ if (outputsOfNode.length > 0) {
2070
+ result = outputsOfNode[0];
2071
+ }
2051
2072
  return result;
2052
2073
  }
2053
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2054
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler }); }
2074
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2075
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler }); }
2055
2076
  }
2056
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, decorators: [{
2077
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, decorators: [{
2057
2078
  type: Injectable
2058
2079
  }], ctorParameters: () => [{ type: FComponentsStore }] });
2059
2080
 
2060
- let GetOutputRectInFlowHandler = class GetOutputRectInFlowHandler {
2061
- constructor(fComponentsStore, getElementRectInFlowHandler) {
2062
- this.fComponentsStore = fComponentsStore;
2063
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2081
+ class CreateConnectionDragHandler {
2082
+ constructor(fMediator, connection, mouseDownPoint) {
2083
+ this.fMediator = fMediator;
2084
+ this.connection = connection;
2085
+ this.mouseDownPoint = mouseDownPoint;
2086
+ this.type = EFDraggableType.CREATE_CONNECTION;
2087
+ this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2088
+ this.onPointerDownToConnectorRect = RectExtensions.initialize();
2089
+ this.outputSide = EFConnectableSide.BOTTOM;
2064
2090
  }
2065
- handle(request) {
2066
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === request.fOutputId);
2067
- if (!output) {
2068
- throw OutputNotFound(request.fOutputId);
2069
- }
2070
- const result = this.getElementRectInFlowHandler.handle(output.hostElement);
2071
- return new GetOutputRectInFlowResponse(result, output.fConnectableSide);
2091
+ initialize() {
2092
+ const outputRect = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2093
+ this.outputSide = outputRect.fConnectableSide;
2094
+ this.onPointerDownFromConnectorRect = outputRect.rect;
2095
+ this.onPointerDownToConnectorRect = RectExtensions.initialize(this.mouseDownPoint.x, this.mouseDownPoint.y, 0, 0);
2096
+ this.connection.show();
2097
+ this.move(new Point(0, 0));
2072
2098
  }
2073
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2074
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler }); }
2075
- };
2076
- GetOutputRectInFlowHandler = __decorate([
2077
- FHandlerRegister(GetOutputRectInFlowRequest)
2078
- ], GetOutputRectInFlowHandler);
2079
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, decorators: [{
2080
- type: Injectable
2081
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }] });
2082
-
2083
- class RedrawConnectionsRequest {
2084
- constructor() {
2099
+ move(difference) {
2100
+ const toPoint = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2101
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toPoint, this.connection.fBehavior, this.outputSide, EFConnectableSide.TOP));
2102
+ this.connection.setVector(vector.point1, this.outputSide, vector.point2, EFConnectableSide.TOP);
2103
+ this.connection.redraw();
2104
+ }
2105
+ complete() {
2106
+ this.connection.redraw();
2107
+ this.connection.hide();
2085
2108
  }
2086
2109
  }
2087
2110
 
2088
- let RedrawConnectionsHandler = class RedrawConnectionsHandler {
2089
- constructor(fComponentsStore, getElementRectInFlowHandler, fMediator) {
2090
- this.fComponentsStore = fComponentsStore;
2091
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2092
- this.fMediator = fMediator;
2111
+ class FCreateConnectionEvent {
2112
+ constructor(fOutputId, fInputId) {
2113
+ this.fOutputId = fOutputId;
2114
+ this.fInputId = fInputId;
2093
2115
  }
2094
- handle(request) {
2095
- this.resetConnectors();
2096
- this.fComponentsStore.fTempConnection?.setMarkers();
2097
- this.fComponentsStore.fConnections.forEach((connection) => {
2098
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === connection.fOutputId);
2099
- const input = this.fComponentsStore.fInputs.find((x) => x.id === connection.fInputId);
2100
- if (output && input) {
2101
- this.setupConnection(output, input, connection);
2102
- }
2103
- });
2104
- }
2105
- resetConnectors() {
2106
- this.fComponentsStore.fOutputs.forEach((output) => output.setConnected(false));
2107
- this.fComponentsStore.fInputs.forEach((input) => input.setConnected(false));
2108
- }
2109
- setupConnection(output, input, connection) {
2110
- output.setConnected(true);
2111
- input.setConnected(true);
2112
- const vector = this.getVector(output, input, connection);
2113
- connection.setVector(vector.point1, output.fConnectableSide, vector.point2, input.fConnectableSide);
2114
- connection.setMarkers();
2115
- connection.initialize();
2116
+ }
2117
+
2118
+ class FirstNotConnectedInputOfNodeUnderPointerHandler {
2119
+ get fNodes() {
2120
+ return this.fComponentsStore.fNodes;
2116
2121
  }
2117
- getVector(output, input, connection) {
2118
- const outputRect = this.getElementRectInFlowHandler.handle(output.hostElement);
2119
- const inputRect = this.getElementRectInFlowHandler.handle(input.hostElement);
2120
- return this.fMediator.send(new GetConnectionVectorRequest(outputRect, inputRect, connection.fBehavior, output.fConnectableSide, input.fConnectableSide));
2122
+ get fInputs() {
2123
+ return this.fComponentsStore.fInputs;
2121
2124
  }
2122
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2123
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler }); }
2124
- };
2125
- RedrawConnectionsHandler = __decorate([
2126
- FHandlerRegister(RedrawConnectionsRequest)
2127
- ], RedrawConnectionsHandler);
2128
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, decorators: [{
2129
- type: Injectable
2130
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }, { type: FFlowMediator }] });
2131
-
2132
- class GetAllNodesRectHandler {
2133
2125
  constructor(fComponentsStore) {
2134
2126
  this.fComponentsStore = fComponentsStore;
2135
2127
  }
2136
- handle() {
2137
- const fNodes = this.fComponentsStore.fNodes;
2138
- const rects = fNodes.map((x) => {
2139
- return RectExtensions.fromElement(x.hostElement);
2128
+ handle(event) {
2129
+ const position = event.getPosition();
2130
+ const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2131
+ const nodes = elementsFromPoint.map((element) => {
2132
+ return this.fNodes.find((x) => x.isContains(element));
2133
+ }).filter((x) => !!x);
2134
+ const inputs = nodes.map((x) => {
2135
+ return this.fInputs.filter((i) => x.isContains(i.hostElement)).find((i) => {
2136
+ return !i.isConnected && i.canBeConnected;
2137
+ });
2140
2138
  });
2141
- const result = RectExtensions.union(rects);
2139
+ const result = inputs.find((x) => !!x);
2142
2140
  return result;
2143
2141
  }
2144
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetAllNodesRectHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2145
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetAllNodesRectHandler }); }
2142
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2143
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler }); }
2146
2144
  }
2147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetAllNodesRectHandler, decorators: [{
2145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, decorators: [{
2148
2146
  type: Injectable
2149
2147
  }], ctorParameters: () => [{ type: FComponentsStore }] });
2150
2148
 
2151
- class GetConnectionHandler {
2152
- get fConnections() {
2153
- return this.fComponentsStore.fConnections;
2149
+ class InputsUnderPointerHandler {
2150
+ get fInputs() {
2151
+ return this.fComponentsStore.fInputs;
2154
2152
  }
2155
2153
  constructor(fComponentsStore) {
2156
2154
  this.fComponentsStore = fComponentsStore;
2157
2155
  }
2158
- handle(element) {
2159
- const result = this.fConnections.find(c => c.isContains(element));
2160
- return result;
2156
+ handle(event) {
2157
+ const position = event.getPosition();
2158
+ const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2159
+ return elementsFromPoint.filter((x) => isNodeInput(x)).map((element) => {
2160
+ return this.fInputs.find((x) => x.isContains(element));
2161
+ }).filter((x) => !!x);
2161
2162
  }
2162
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2163
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler }); }
2163
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2164
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler }); }
2164
2165
  }
2165
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler, decorators: [{
2166
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, decorators: [{
2166
2167
  type: Injectable
2167
2168
  }], ctorParameters: () => [{ type: FComponentsStore }] });
2168
2169
 
2169
- class GetIncomingConnectionsHandler {
2170
- get fConnections() {
2171
- return this.fComponentsStore.fConnections;
2172
- }
2173
- constructor(fComponentsStore) {
2174
- this.fComponentsStore = fComponentsStore;
2175
- }
2176
- handle(inputs) {
2177
- const inputsIds = inputs.map((x) => x.id);
2178
- return this.fConnections.filter((x) => {
2179
- return inputsIds.includes(x.fInputId);
2180
- });
2170
+ class FindInputsUnderPointerRequest {
2171
+ constructor(event, dragHandler) {
2172
+ this.event = event;
2173
+ this.dragHandler = dragHandler;
2181
2174
  }
2182
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2183
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler }); }
2184
2175
  }
2185
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler, decorators: [{
2186
- type: Injectable
2187
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2188
2176
 
2189
- class GetOutgoingConnectionsHandler {
2190
- get fConnections() {
2191
- return this.fComponentsStore.fConnections;
2177
+ function createErrorClass(impl) {
2178
+ const _super = (instance) => {
2179
+ Error.call(instance);
2180
+ instance.stack = new Error().stack;
2181
+ };
2182
+ const constructor = impl(_super);
2183
+ constructor.prototype = Object.create(Error.prototype);
2184
+ constructor.prototype.constructor = constructor;
2185
+ return constructor;
2186
+ }
2187
+
2188
+ const NotFoundError = createErrorClass((_super) => function error(message) {
2189
+ _super(this);
2190
+ this.message = message || 'The requested resource was not found.';
2191
+ this.code = 404;
2192
+ });
2193
+
2194
+ const ConflictError = createErrorClass((_super) => function error(message) {
2195
+ _super(this);
2196
+ this.message = message || 'Conflict error occurred.';
2197
+ this.code = 409;
2198
+ });
2199
+
2200
+ function OutputNotFound(id) {
2201
+ return new NotFoundError(`Output with fOutputId ${id} not found. Check out the issues section on Github or create a new issue.`);
2202
+ }
2203
+ function InputNotFound(id) {
2204
+ return new NotFoundError(`Input with fInputId ${id} not found. Check out the issues section on Github or create a new issue.`);
2205
+ }
2206
+ function RequiredOutput() {
2207
+ return new ConflictError(`The fNode must contain at least one fOutput if there is an fOutlet`);
2208
+ }
2209
+
2210
+ class FindInputsUnderPointerHandler {
2211
+ get fNodes() {
2212
+ return this.fComponentsStore.fNodes;
2192
2213
  }
2193
- constructor(fComponentsStore) {
2214
+ constructor(fComponentsStore, inputsUnderPointerHandler, firstNotConnectedInputOfNodeUnderPointerHandler) {
2194
2215
  this.fComponentsStore = fComponentsStore;
2216
+ this.inputsUnderPointerHandler = inputsUnderPointerHandler;
2217
+ this.firstNotConnectedInputOfNodeUnderPointerHandler = firstNotConnectedInputOfNodeUnderPointerHandler;
2195
2218
  }
2196
- handle(outputs) {
2197
- const outputsIds = outputs.map((x) => x.id);
2198
- return this.fConnections.filter((x) => {
2199
- return outputsIds.includes(x.fOutputId);
2219
+ handle(payload) {
2220
+ const inputsUnderPointer = this.getInputsUnderPointer(payload);
2221
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === payload.dragHandler.connection.fOutputId);
2222
+ if (!output) {
2223
+ throw OutputNotFound(payload.dragHandler.connection.fOutputId);
2224
+ }
2225
+ return output.isSelfConnectable ? inputsUnderPointer : inputsUnderPointer.filter((x) => {
2226
+ const targetNode = this.fNodes.find((y) => y.isContains(x.hostElement));
2227
+ const sourceNode = this.fNodes.find((y) => y.isContains(output.hostElement));
2228
+ return sourceNode?.hostElement !== targetNode?.hostElement;
2200
2229
  });
2201
2230
  }
2202
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2203
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler }); }
2204
- }
2205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler, decorators: [{
2206
- type: Injectable
2207
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2208
-
2209
- class GetInputRectInFlowHandler {
2210
- constructor(fComponentsStore, getElementRectInFlowHandler) {
2211
- this.fComponentsStore = fComponentsStore;
2212
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2213
- }
2214
- handle(inputId) {
2215
- const input = this.fComponentsStore.fInputs.find((x) => x.id === inputId);
2216
- if (!input) {
2217
- throw InputNotFound(inputId);
2231
+ getInputsUnderPointer(payload) {
2232
+ let inputs = this.inputsUnderPointerHandler.handle(payload.event);
2233
+ const input = this.firstNotConnectedInputOfNodeUnderPointerHandler.handle(payload.event);
2234
+ if (input) {
2235
+ inputs.push(input);
2218
2236
  }
2219
- const result = this.getElementRectInFlowHandler.handle(input.hostElement);
2220
- return { rect: result, fConnectableSide: input.fConnectableSide };
2237
+ inputs = inputs.filter((x) => x.canBeConnected);
2238
+ return inputs;
2221
2239
  }
2222
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2223
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler }); }
2240
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, deps: [{ token: FComponentsStore }, { token: InputsUnderPointerHandler }, { token: FirstNotConnectedInputOfNodeUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2241
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler }); }
2224
2242
  }
2225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler, decorators: [{
2243
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, decorators: [{
2226
2244
  type: Injectable
2227
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: GetElementRectInFlowHandler }] });
2245
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: InputsUnderPointerHandler }, { type: FirstNotConnectedInputOfNodeUnderPointerHandler }] });
2228
2246
 
2229
- class UpdateNodeLayerHandler {
2230
- get fNodesContainer() {
2231
- return this.fComponentsStore.fCanvas?.fNodesContainer?.nativeElement;
2232
- }
2233
- constructor(fComponentsStore) {
2247
+ class CreateConnectionOnPointerUp {
2248
+ constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler, findFirstCanBeConnectedOutputByOutletHandler) {
2234
2249
  this.fComponentsStore = fComponentsStore;
2250
+ this.fDraggableDataContext = fDraggableDataContext;
2251
+ this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2252
+ this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2235
2253
  }
2236
- handle(node) {
2237
- const elements = Array.from(this.fNodesContainer.children);
2238
- const elementsCount = elements.length;
2239
- const targetIndex = elements.findIndex((x) => x === node.hostElement);
2240
- if (targetIndex !== elementsCount - 1) {
2241
- const afterElements = elements.splice(targetIndex + 1);
2242
- afterElements.forEach((x) => {
2243
- this.fNodesContainer.removeChild(x);
2244
- this.fNodesContainer.insertBefore(x, node.hostElement);
2245
- });
2254
+ handle(event) {
2255
+ const isCreateConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CREATE_CONNECTION);
2256
+ if (isCreateConnection) {
2257
+ const handler = this.fDraggableDataContext.draggableItems[0];
2258
+ const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2259
+ if (inputsUnderPointer.length > 0) {
2260
+ let output = this.fComponentsStore.fOutputs.find((x) => x.id === handler.connection.fOutputId);
2261
+ if (!output) {
2262
+ output = this.fComponentsStore.fOutlets.find((x) => x.id === handler.connection.fOutputId);
2263
+ }
2264
+ if (!output) {
2265
+ throw OutputNotFound(handler.connection.fOutputId);
2266
+ }
2267
+ const isOutlet = isNodeOutlet(output.hostElement);
2268
+ if (isOutlet) {
2269
+ output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(output);
2270
+ if (!output) {
2271
+ throw RequiredOutput();
2272
+ }
2273
+ }
2274
+ this.fComponentsStore.fDraggable?.fCreateConnection.emit(new FCreateConnectionEvent(output.id, inputsUnderPointer[0]?.id));
2275
+ }
2276
+ handler.complete();
2246
2277
  }
2247
2278
  }
2248
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2249
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler }); }
2279
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2280
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp }); }
2250
2281
  }
2251
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler, decorators: [{
2282
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, decorators: [{
2252
2283
  type: Injectable
2253
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2284
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2254
2285
 
2255
- class FDraggableDataContext {
2256
- constructor() {
2257
- this.selectedItems = [];
2258
- this.isSelectedChanged = false;
2259
- this.onPointerDownScale = 1;
2260
- this.onPointerDownPosition = new Point(0, 0);
2261
- this.draggableItems = [];
2286
+ class CreateConnectionPrepareDragSequence {
2287
+ get transform() {
2288
+ return this.fComponentsStore.fCanvas.transform;
2262
2289
  }
2263
- reset() {
2264
- this.draggableItems = [];
2265
- this.onPointerDownScale = 1;
2266
- this.onPointerDownPosition = new Point(0, 0);
2267
- this.isSelectedChanged = false;
2290
+ get flowHost() {
2291
+ return this.fComponentsStore.fFlow.hostElement;
2268
2292
  }
2269
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2270
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext }); }
2271
- }
2272
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDataContext, decorators: [{
2273
- type: Injectable
2274
- }] });
2275
-
2276
- class SelectAllHandler {
2277
- constructor(fDataContext, fDraggableDataContext) {
2278
- this.fDataContext = fDataContext;
2293
+ constructor(fComponentsStore, fDraggableDataContext, fMediator, findFirstCanBeConnectedOutputByOutletHandler) {
2294
+ this.fComponentsStore = fComponentsStore;
2279
2295
  this.fDraggableDataContext = fDraggableDataContext;
2296
+ this.fMediator = fMediator;
2297
+ this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2280
2298
  }
2281
- handle() {
2282
- this.fDraggableDataContext.selectedItems.forEach((x) => {
2283
- x.deselect();
2284
- });
2285
- this.fDraggableDataContext.selectedItems = [];
2286
- this.fDataContext.fNodes.forEach((x) => {
2287
- x.select();
2288
- this.fDraggableDataContext.selectedItems.push(x);
2289
- });
2290
- this.fDataContext.fConnections.forEach((x) => {
2291
- x.select();
2292
- this.fDraggableDataContext.selectedItems.push(x);
2293
- });
2294
- this.fDraggableDataContext.isSelectedChanged = true;
2295
- }
2296
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
2297
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler }); }
2298
- }
2299
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler, decorators: [{
2300
- type: Injectable
2301
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }] });
2302
-
2303
- class UpdateConnectionLayerHandler {
2304
- get fConnectionsContainer() {
2305
- return this.fComponentsStore.fCanvas?.fConnectionsContainer?.nativeElement;
2306
- }
2307
- constructor(fComponentsStore) {
2308
- this.fComponentsStore = fComponentsStore;
2309
- }
2310
- handle(connection) {
2311
- const elements = Array.from(this.fConnectionsContainer.children);
2312
- const elementsCount = elements.length;
2313
- const targetIndex = elements.findIndex((x) => x === connection.hostElement);
2314
- if (targetIndex !== elementsCount - 1) {
2315
- const afterElements = elements.splice(targetIndex + 1);
2316
- afterElements.forEach((x) => {
2317
- this.fConnectionsContainer.removeChild(x);
2318
- this.fConnectionsContainer.insertBefore(x, connection.hostElement);
2319
- });
2320
- }
2321
- }
2322
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2323
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler }); }
2324
- }
2325
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler, decorators: [{
2326
- type: Injectable
2327
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2328
-
2329
- const COMMON_PROVIDERS = [
2330
- GetConnectionVectorHandler,
2331
- GetOutputRectInFlowHandler,
2332
- RedrawConnectionsHandler,
2333
- GetAllNodesRectHandler,
2334
- GetConnectionHandler,
2335
- GetElementRectInFlowHandler,
2336
- GetInputRectInFlowHandler,
2337
- GetIncomingConnectionsHandler,
2338
- GetOutgoingConnectionsHandler,
2339
- SelectAllHandler,
2340
- UpdateConnectionLayerHandler,
2341
- UpdateNodeLayerHandler,
2342
- ];
2343
-
2344
- class FCanvasComponent extends FCanvasBase {
2345
- set position(value) {
2346
- if (!value) {
2299
+ handle(event) {
2300
+ const node = this.fComponentsStore.findNode(event.targetElement);
2301
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2302
+ if (!node || this.fDraggableDataContext.draggableItems.length || !this.fComponentsStore.fTempConnection) {
2347
2303
  return;
2348
2304
  }
2349
- const position = PointExtensions.sum(this.transform.position, this.transform.scaledPosition);
2350
- if (!PointExtensions.isEqual(position, value)) {
2351
- this.transform.position = value;
2352
- this.transform.scaledPosition = PointExtensions.initialize();
2353
- this.redraw();
2305
+ if (isNodeOutlet(event.targetElement)) {
2306
+ const outlet = this.fComponentsStore.fOutlets.find((x) => {
2307
+ return x.hostElement.contains(event.targetElement);
2308
+ });
2309
+ if (!outlet) {
2310
+ throw new Error('Outlet not found');
2311
+ }
2312
+ const nodeOutputs = this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
2313
+ outlet.setOutputs(nodeOutputs);
2314
+ if (outlet.canBeConnected) {
2315
+ const outletCenter = this.fMediator.send(new GetElementRectInFlowRequest(outlet.hostElement)).gravityCenter;
2316
+ if (outlet.isConnectionFromOutlet) {
2317
+ this.createConnectionHandler(pointerPositionInFlow, outlet, outletCenter);
2318
+ }
2319
+ else {
2320
+ const output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(outlet);
2321
+ if (!output) {
2322
+ throw new Error('Output not found');
2323
+ }
2324
+ this.createConnectionHandler(pointerPositionInFlow, output, outletCenter);
2325
+ }
2326
+ }
2354
2327
  }
2355
- }
2356
- set scale(value) {
2357
- if (!value) {
2358
- return;
2328
+ else if (this.isNodeOutput(event.targetElement, node)) {
2329
+ const output = this.fComponentsStore.fOutputs.find((x) => {
2330
+ return x.hostElement.contains(event.targetElement);
2331
+ });
2332
+ if (!output) {
2333
+ throw new Error('Output not found');
2334
+ }
2335
+ if (output.canBeConnected) {
2336
+ const outputCenter = this.fMediator.send(new GetElementRectInFlowRequest(output.hostElement)).gravityCenter;
2337
+ this.createConnectionHandler(pointerPositionInFlow, output, outputCenter);
2338
+ }
2359
2339
  }
2360
- this.transform.scale = value;
2361
- this.redraw();
2362
- }
2363
- get fNodes() {
2364
- return this.fComponentsStore.fNodes;
2365
- }
2366
- get hostElement() {
2367
- return this.elementReference.nativeElement;
2368
- }
2369
- constructor(getAllNodesRectHandler, selectAllHandler, elementReference, fComponentsStore) {
2370
- super();
2371
- this.getAllNodesRectHandler = getAllNodesRectHandler;
2372
- this.selectAllHandler = selectAllHandler;
2373
- this.elementReference = elementReference;
2374
- this.fComponentsStore = fComponentsStore;
2375
- this.fCanvasChange = new EventEmitter();
2376
- }
2377
- ngOnInit() {
2378
- this.fComponentsStore.fCanvas = this;
2379
- }
2380
- redraw() {
2381
- this.fComponentsStore.fBackground?.setTransform(this.transform);
2382
- this.hostElement.setAttribute("style", `transform: ${TransformModelExtensions.toString(this.transform)}`);
2383
- }
2384
- redrawWithAnimation() {
2385
- this.fComponentsStore.fBackground?.setTransform(this.transform);
2386
- this.hostElement.setAttribute("style", `transition: transform 0.15s ease-in-out; transform: ${TransformModelExtensions.toString(this.transform)}`);
2387
- setTimeout(() => {
2388
- this.redraw();
2389
- }, 150);
2390
- }
2391
- fitToScreen(toCenter = PointExtensions.initialize(), animated = true) {
2392
- const fNodesRect = this.getAllNodesRectHandler.handle();
2393
- const rect = RectExtensions.addPointToSize(fNodesRect, Point.fromPoint(toCenter).mult(2));
2394
- this.fitToParent(rect, RectExtensions.fromElement(this.fComponentsStore.fFlow.hostElement), this.fNodes.map((x) => {
2395
- return Point.fromPoint(x.position).sub(toCenter);
2396
- }));
2397
- animated ? this.redrawWithAnimation() : this.redraw();
2398
- this.completeDrag();
2399
2340
  }
2400
- oneToOne() {
2401
- const fNodesRect = this.getAllNodesRectHandler.handle();
2402
- this.oneToOneCentering(fNodesRect, RectExtensions.fromElement(this.fComponentsStore.fFlow.hostElement), this.fNodes.map((x) => {
2403
- return Point.fromPoint(x.position).sub(new Point(0, 0));
2404
- }));
2405
- this.redrawWithAnimation();
2406
- this.completeDrag();
2341
+ createConnectionHandler(pointerPositionInCanvas, output, outputCenter) {
2342
+ this.fComponentsStore.fTempConnection.fOutputId = output.id;
2343
+ this.fComponentsStore.fTempConnection.initialize();
2344
+ this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2345
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInCanvas.div(this.transform.scale);
2346
+ this.fDraggableDataContext.draggableItems = [
2347
+ new CreateConnectionDragHandler(this.fMediator, this.fComponentsStore.fTempConnection, outputCenter)
2348
+ ];
2407
2349
  }
2408
- selectAll() {
2409
- this.selectAllHandler.handle();
2350
+ isNodeOutput(targetElement, node) {
2351
+ const outlets = this.fComponentsStore.fOutlets.filter((x) => node.isContains(x.hostElement));
2352
+ return isNodeOutput(targetElement) && !outlets.length;
2410
2353
  }
2411
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FCanvasComponent, deps: [{ token: GetAllNodesRectHandler }, { token: SelectAllHandler }, { token: i0.ElementRef }, { token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Component }); }
2412
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FCanvasComponent, selector: "f-canvas", inputs: { position: "position", scale: "scale" }, outputs: { fCanvasChange: "fCanvasChange" }, host: { classAttribute: "f-component f-canvas" }, providers: [{ provide: F_CANVAS, useExisting: FCanvasComponent }], viewQueries: [{ propertyName: "fNodesContainer", first: true, predicate: ["fNodesContainer"], descendants: true, static: true }, { propertyName: "fConnectionsContainer", first: true, predicate: ["fConnectionsContainer"], descendants: true, static: true }], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "<ng-container>\n <div #fConnectionsContainer>\n <ng-content select=\"f-connection\"></ng-content>\n <ng-content select=\"f-connection-for-create\"></ng-content>\n </div>\n <div #fNodesContainer>\n <ng-content select=\"[fNode]\"></ng-content>\n </div>\n</ng-container>\n", styles: [":host{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2354
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FFlowMediator }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2355
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence }); }
2413
2356
  }
2414
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FCanvasComponent, decorators: [{
2415
- type: Component,
2416
- args: [{ selector: 'f-canvas', exportAs: 'fComponent', host: {
2417
- 'class': 'f-component f-canvas',
2418
- }, providers: [{ provide: F_CANVAS, useExisting: FCanvasComponent }], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container>\n <div #fConnectionsContainer>\n <ng-content select=\"f-connection\"></ng-content>\n <ng-content select=\"f-connection-for-create\"></ng-content>\n </div>\n <div #fNodesContainer>\n <ng-content select=\"[fNode]\"></ng-content>\n </div>\n</ng-container>\n", styles: [":host{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}\n"] }]
2419
- }], ctorParameters: () => [{ type: GetAllNodesRectHandler }, { type: SelectAllHandler }, { type: i0.ElementRef }, { type: FComponentsStore }], propDecorators: { fCanvasChange: [{
2420
- type: Output
2421
- }], position: [{
2422
- type: Input
2423
- }], scale: [{
2424
- type: Input
2425
- }], fNodesContainer: [{
2426
- type: ViewChild,
2427
- args: ['fNodesContainer', { static: true }]
2428
- }], fConnectionsContainer: [{
2429
- type: ViewChild,
2430
- args: ['fConnectionsContainer', { static: true }]
2431
- }] } });
2432
-
2433
- var EFDraggableType;
2434
- (function (EFDraggableType) {
2435
- EFDraggableType["NODE"] = "node";
2436
- EFDraggableType["REASSIGN_CONNECTION"] = "reassign-connection";
2437
- EFDraggableType["CREATE_CONNECTION"] = "create-connection";
2438
- EFDraggableType["CONNECTION"] = "connection";
2439
- EFDraggableType["CANVAS"] = "canvas";
2440
- EFDraggableType["PALETTE_ITEM"] = "palette-item";
2441
- EFDraggableType["SELECTION"] = "selection";
2442
- })(EFDraggableType || (EFDraggableType = {}));
2357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, decorators: [{
2358
+ type: Injectable
2359
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FFlowMediator }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2443
2360
 
2444
- class CanvasDragHandler {
2445
- constructor(fComponentsStore) {
2446
- this.fComponentsStore = fComponentsStore;
2447
- this.type = EFDraggableType.CANVAS;
2448
- this.onPointerDownPosition = PointExtensions.initialize();
2361
+ class ReassignConnectionDragHandler {
2362
+ constructor(fMediator, connection) {
2363
+ this.fMediator = fMediator;
2364
+ this.connection = connection;
2365
+ this.type = EFDraggableType.REASSIGN_CONNECTION;
2366
+ this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2367
+ this.onPointerDownToConnectorRect = RectExtensions.initialize();
2368
+ this.outputSide = EFConnectableSide.BOTTOM;
2369
+ this.inputSide = EFConnectableSide.TOP;
2449
2370
  }
2450
2371
  initialize() {
2451
- this.onPointerDownPosition = this.fComponentsStore.fCanvas.transform.position;
2372
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2373
+ this.inputSide = this.fMediator.send(new GetInputRectInFlowRequest(this.connection.fInputId)).fConnectableSide;
2374
+ this.outputSide = fromConnector.fConnectableSide;
2375
+ this.onPointerDownFromConnectorRect = fromConnector.rect;
2376
+ this.onPointerDownToConnectorRect = RectExtensions.initialize(this.connection.vector.point2.x, this.connection.vector.point2.y, 0, 0);
2452
2377
  }
2453
2378
  move(difference) {
2454
- this.fComponentsStore.fCanvas.setPosition(Point.fromPoint(this.onPointerDownPosition).add(difference));
2455
- this.fComponentsStore.fCanvas.redraw();
2379
+ const toRect = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2380
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toRect, this.connection.fBehavior, this.outputSide, this.inputSide));
2381
+ this.connection.setVector(vector.point1, this.outputSide, vector.point2, this.inputSide);
2382
+ this.connection.redraw();
2456
2383
  }
2457
2384
  complete() {
2458
- this.fComponentsStore.fCanvas.completeDrag();
2385
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2386
+ const toConnector = this.fMediator.send(new GetInputRectInFlowRequest(this.connection.fInputId));
2387
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
2388
+ this.connection.setVector(vector.point1, fromConnector.fConnectableSide, vector.point2, toConnector.fConnectableSide);
2389
+ this.connection.redraw();
2459
2390
  }
2460
2391
  }
2461
2392
 
2462
- class CanvasOnPointerUp {
2463
- constructor(fDraggableDataContext) {
2393
+ class FReassignConnectionEvent {
2394
+ constructor(connectionId, fOutputId, oldFInputId, newFInputId) {
2395
+ this.connectionId = connectionId;
2396
+ this.fOutputId = fOutputId;
2397
+ this.oldFInputId = oldFInputId;
2398
+ this.newFInputId = newFInputId;
2399
+ }
2400
+ }
2401
+
2402
+ class ReassignConnectionOnPointerUp {
2403
+ get fDraggable() {
2404
+ return this.fComponentsStore.fDraggable;
2405
+ }
2406
+ constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler) {
2407
+ this.fComponentsStore = fComponentsStore;
2464
2408
  this.fDraggableDataContext = fDraggableDataContext;
2409
+ this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2465
2410
  }
2466
2411
  handle(event) {
2467
- const isDragCanvas = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CANVAS);
2468
- if (isDragCanvas) {
2469
- this.fDraggableDataContext.draggableItems.forEach((x) => {
2470
- x.complete?.();
2471
- });
2412
+ const isReassignConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.REASSIGN_CONNECTION);
2413
+ if (isReassignConnection) {
2414
+ const handler = this.fDraggableDataContext.draggableItems[0];
2415
+ const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2416
+ if (inputsUnderPointer.length > 0) {
2417
+ if (handler.connection.fInputId !== inputsUnderPointer[0]?.id) {
2418
+ this.fDraggable.fReassignConnection.emit(new FReassignConnectionEvent(handler.connection.fConnectionId, handler.connection.fOutputId, handler.connection.fInputId, inputsUnderPointer[0]?.id));
2419
+ }
2420
+ }
2421
+ handler.complete();
2472
2422
  }
2473
2423
  }
2474
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
2475
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp }); }
2424
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2425
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp }); }
2476
2426
  }
2477
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasOnPointerUp, decorators: [{
2427
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, decorators: [{
2478
2428
  type: Injectable
2479
- }], ctorParameters: () => [{ type: FDraggableDataContext }] });
2429
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }] });
2480
2430
 
2481
- class CanvasPrepareDragSequence {
2431
+ class ReassignConnectionPrepareDragSequence {
2432
+ get transform() {
2433
+ return this.fComponentsStore.fCanvas.transform;
2434
+ }
2482
2435
  get flowHost() {
2483
2436
  return this.fComponentsStore.fFlow.hostElement;
2484
2437
  }
2485
- constructor(fComponentsStore, fDraggableDataContext) {
2438
+ constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, getInputRectInFlowHandler, fMediator, updateConnectionLayerHandler) {
2486
2439
  this.fComponentsStore = fComponentsStore;
2487
2440
  this.fDraggableDataContext = fDraggableDataContext;
2441
+ this.getConnectionHandler = getConnectionHandler;
2442
+ this.getInputRectInFlowHandler = getInputRectInFlowHandler;
2443
+ this.fMediator = fMediator;
2444
+ this.updateConnectionLayerHandler = updateConnectionLayerHandler;
2488
2445
  }
2489
2446
  handle(event) {
2490
2447
  const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2491
- const isBackgroundElement = this.fComponentsStore.fBackground?.isBackgroundElement(event.targetElement);
2492
- const isFlowHost = this.flowHost.contains(event.targetElement);
2493
- let node = this.fComponentsStore.findNode(event.targetElement);
2494
- if (node && node.disabled) {
2495
- node = undefined;
2448
+ const position = event.getPosition();
2449
+ const allElements = document.elementsFromPoint(position.x, position.y);
2450
+ const dragHandlesOfConnections = allElements.filter((x) => {
2451
+ return !!this.getConnectionHandler.handle(x) && x.classList.contains(F_CONNECTION_DRAG_HANDLE_CLASS);
2452
+ });
2453
+ let connectionToReassign;
2454
+ if (dragHandlesOfConnections.length) {
2455
+ const connections = dragHandlesOfConnections.map((x) => this.getConnectionHandler.handle(x)).filter((x) => !x?.disabled);
2456
+ if (connections.length) {
2457
+ connectionToReassign = this.getConnectionHandler.handle(dragHandlesOfConnections[0]);
2458
+ }
2496
2459
  }
2497
- if ((isBackgroundElement || (isFlowHost && !node)) && !this.fDraggableDataContext.draggableItems.length) {
2498
- this.fDraggableDataContext.onPointerDownScale = 1;
2499
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
2460
+ if (connectionToReassign && !this.fDraggableDataContext.draggableItems.length) {
2461
+ this.updateConnectionLayerHandler.handle(connectionToReassign);
2462
+ this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2463
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
2500
2464
  this.fDraggableDataContext.draggableItems = [
2501
- new CanvasDragHandler(this.fComponentsStore)
2465
+ new ReassignConnectionDragHandler(this.fMediator, connectionToReassign)
2502
2466
  ];
2503
2467
  }
2504
2468
  }
2505
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
2506
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence }); }
2469
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: GetInputRectInFlowHandler }, { token: FFlowMediator }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2470
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence }); }
2507
2471
  }
2508
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CanvasPrepareDragSequence, decorators: [{
2472
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, decorators: [{
2509
2473
  type: Injectable
2510
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }] });
2474
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: GetInputRectInFlowHandler }, { type: FFlowMediator }, { type: UpdateConnectionLayerHandler }] });
2511
2475
 
2512
- const CANVAS_PROVIDERS = [
2513
- CanvasOnPointerUp,
2514
- CanvasPrepareDragSequence
2476
+ const CONNECTIONS_PROVIDERS = [
2477
+ FindFirstCanBeConnectedOutputByOutletHandler,
2478
+ CreateConnectionOnPointerUp,
2479
+ CreateConnectionPrepareDragSequence,
2480
+ FirstNotConnectedInputOfNodeUnderPointerHandler,
2481
+ InputsUnderPointerHandler,
2482
+ FindInputsUnderPointerHandler,
2483
+ ReassignConnectionOnPointerUp,
2484
+ ReassignConnectionPrepareDragSequence
2515
2485
  ];
2516
2486
 
2517
- class FindFirstCanBeConnectedOutputByOutletHandler {
2518
- get fNodes() {
2519
- return this.fComponentsStore.fNodes;
2520
- }
2521
- get fOutputs() {
2522
- return this.fComponentsStore.fOutputs;
2523
- }
2524
- constructor(fComponentsStore) {
2525
- this.fComponentsStore = fComponentsStore;
2526
- }
2527
- handle(outlet) {
2528
- let result;
2529
- const node = this.fNodes.find((x) => x.isContains(outlet.hostElement));
2530
- if (!node) {
2531
- throw new Error('Node not found');
2532
- }
2533
- const outputsOfNode = this.fOutputs.filter((x) => {
2534
- return node.isContains(x.hostElement) && x.canBeConnected;
2535
- });
2536
- if (outputsOfNode.length > 0) {
2537
- result = outputsOfNode[0];
2538
- }
2539
- return result;
2487
+ class FCreateNodeEvent {
2488
+ constructor(rect, data) {
2489
+ this.rect = rect;
2490
+ this.data = data;
2540
2491
  }
2541
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2542
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler }); }
2543
2492
  }
2544
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindFirstCanBeConnectedOutputByOutletHandler, decorators: [{
2545
- type: Injectable
2546
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2547
2493
 
2548
- class CreateConnectionDragHandler {
2549
- constructor(fMediator, connection, mouseDownPoint) {
2550
- this.fMediator = fMediator;
2551
- this.connection = connection;
2552
- this.mouseDownPoint = mouseDownPoint;
2553
- this.type = EFDraggableType.CREATE_CONNECTION;
2554
- this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2555
- this.onPointerDownToConnectorRect = RectExtensions.initialize();
2556
- this.outputSide = EFConnectableSide.BOTTOM;
2494
+ class ExternalItemDragHandler {
2495
+ constructor(externalItem) {
2496
+ this.externalItem = externalItem;
2497
+ this.type = EFDraggableType.PALETTE_ITEM;
2498
+ this.onPointerDownRect = RectExtensions.initialize();
2499
+ this.difference = PointExtensions.initialize();
2500
+ }
2501
+ getStyle(position) {
2502
+ return `position: absolute; left: 0; top: 0; transform: translate(${position.x}px, ${position.y}px)`;
2557
2503
  }
2558
2504
  initialize() {
2559
- const outputRect = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2560
- this.outputSide = outputRect.fConnectableSide;
2561
- this.onPointerDownFromConnectorRect = outputRect.rect;
2562
- this.onPointerDownToConnectorRect = RectExtensions.initialize(this.mouseDownPoint.x, this.mouseDownPoint.y, 0, 0);
2563
- this.connection.show();
2564
- this.move(new Point(0, 0));
2505
+ this.onPointerDownRect = this.getExternalItemRect();
2506
+ this.placeholder = DomElementExtensions.deepCloneNode(this.externalItem.hostElement);
2507
+ document.body.appendChild(this.placeholder);
2508
+ }
2509
+ getExternalItemRect() {
2510
+ const rect = this.externalItem.hostElement.getBoundingClientRect();
2511
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
2512
+ const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
2513
+ const offsetTop = rect.top + scrollTop;
2514
+ const offsetLeft = rect.left + scrollLeft;
2515
+ return RectExtensions.initialize(offsetLeft, offsetTop, rect.width, rect.height);
2565
2516
  }
2566
2517
  move(difference) {
2567
- const toPoint = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2568
- const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toPoint, this.connection.fBehavior, this.outputSide, EFConnectableSide.TOP));
2569
- this.connection.setVector(vector.point1, this.outputSide, vector.point2, EFConnectableSide.TOP);
2570
- this.connection.redraw();
2518
+ this.difference = difference;
2519
+ const position = Point.fromPoint(this.onPointerDownRect).add(this.difference);
2520
+ this.placeholder.setAttribute('style', this.getStyle(position));
2571
2521
  }
2572
2522
  complete() {
2573
- this.connection.redraw();
2574
- this.connection.hide();
2523
+ document.body.removeChild(this.placeholder);
2575
2524
  }
2576
2525
  }
2577
2526
 
2578
- class FCreateConnectionEvent {
2579
- constructor(fOutputId, fInputId) {
2580
- this.fOutputId = fOutputId;
2581
- this.fInputId = fInputId;
2582
- }
2527
+ const F_EXTERNAL_ITEM = new InjectionToken('F_EXTERNAL_ITEM');
2528
+ class FExternalItemBase {
2529
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2530
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemBase, ngImport: i0 }); }
2531
+ }
2532
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, decorators: [{
2533
+ type: Directive
2534
+ }] });
2535
+
2536
+ function isExternalItem(element) {
2537
+ return !!element.closest('[fExternalItem]');
2538
+ }
2539
+ function getExternalItem(element) {
2540
+ return element.closest('[fExternalItem]');
2583
2541
  }
2584
2542
 
2585
- class FirstNotConnectedInputOfNodeUnderPointerHandler {
2586
- get fNodes() {
2587
- return this.fComponentsStore.fNodes;
2543
+ class FExternalItemService {
2544
+ constructor() {
2545
+ this.items = [];
2588
2546
  }
2589
- get fInputs() {
2590
- return this.fComponentsStore.fInputs;
2547
+ registerItem(item) {
2548
+ this.items.push(item);
2591
2549
  }
2592
- constructor(fComponentsStore) {
2593
- this.fComponentsStore = fComponentsStore;
2550
+ getItem(element) {
2551
+ return this.items.find(item => item.hostElement === element);
2594
2552
  }
2595
- handle(event) {
2596
- const position = event.getPosition();
2597
- const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2598
- const nodes = elementsFromPoint.map((element) => {
2599
- return this.fNodes.find((x) => x.isContains(element));
2600
- }).filter((x) => !!x);
2601
- const inputs = nodes.map((x) => {
2602
- return this.fInputs.filter((i) => x.isContains(i.hostElement)).find((i) => {
2603
- return !i.isConnected && i.canBeConnected;
2604
- });
2605
- });
2606
- const result = inputs.find((x) => !!x);
2607
- return result;
2553
+ removeItem(item) {
2554
+ const index = this.items.indexOf(item);
2555
+ if (index !== -1) {
2556
+ this.items.splice(index, 1);
2557
+ }
2608
2558
  }
2609
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2610
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler }); }
2559
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2560
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, providedIn: 'root' }); }
2611
2561
  }
2612
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FirstNotConnectedInputOfNodeUnderPointerHandler, decorators: [{
2613
- type: Injectable
2614
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2562
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, decorators: [{
2563
+ type: Injectable,
2564
+ args: [{
2565
+ providedIn: 'root'
2566
+ }]
2567
+ }] });
2615
2568
 
2616
- class InputsUnderPointerHandler {
2617
- get fInputs() {
2618
- return this.fComponentsStore.fInputs;
2569
+ let uniqueId$1 = 0;
2570
+ class FExternalItemDirective extends FExternalItemBase {
2571
+ get hostElement() {
2572
+ return this.elementReference.nativeElement;
2619
2573
  }
2620
- constructor(fComponentsStore) {
2621
- this.fComponentsStore = fComponentsStore;
2574
+ constructor(elementReference, fExternalItemService) {
2575
+ super();
2576
+ this.elementReference = elementReference;
2577
+ this.fExternalItemService = fExternalItemService;
2578
+ this.fExternalItemId = `f-external-item-${uniqueId$1++}`;
2579
+ this.fDisabled = false;
2622
2580
  }
2623
- handle(event) {
2624
- const position = event.getPosition();
2625
- const elementsFromPoint = document.elementsFromPoint(position.x, position.y);
2626
- return elementsFromPoint.filter((x) => isNodeInput(x)).map((element) => {
2627
- return this.fInputs.find((x) => x.isContains(element));
2628
- }).filter((x) => !!x);
2581
+ ngOnInit() {
2582
+ this.fExternalItemService.registerItem(this);
2629
2583
  }
2630
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
2631
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler }); }
2632
- }
2633
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: InputsUnderPointerHandler, decorators: [{
2634
- type: Injectable
2635
- }], ctorParameters: () => [{ type: FComponentsStore }] });
2636
-
2637
- class FindInputsUnderPointerRequest {
2638
- constructor(event, dragHandler) {
2639
- this.event = event;
2640
- this.dragHandler = dragHandler;
2584
+ ngOnDestroy() {
2585
+ this.fExternalItemService.removeItem(this);
2641
2586
  }
2587
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, deps: [{ token: i0.ElementRef }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Directive }); }
2588
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemDirective, selector: "[fExternalItem]", inputs: { fExternalItemId: "fExternalItemId", fData: "fData", fDisabled: "fDisabled" }, host: { properties: { "attr.id": "fExternalItemId", "class.f-external-item-disabled": "fDisabled" }, classAttribute: "f-component f-external-item" }, providers: [
2589
+ { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
2590
+ ], usesInheritance: true, ngImport: i0 }); }
2642
2591
  }
2592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, decorators: [{
2593
+ type: Directive,
2594
+ args: [{
2595
+ selector: "[fExternalItem]",
2596
+ host: {
2597
+ '[attr.id]': 'fExternalItemId',
2598
+ class: "f-component f-external-item",
2599
+ '[class.f-external-item-disabled]': 'fDisabled',
2600
+ },
2601
+ providers: [
2602
+ { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
2603
+ ],
2604
+ }]
2605
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FExternalItemService }], propDecorators: { fExternalItemId: [{
2606
+ type: Input
2607
+ }], fData: [{
2608
+ type: Input
2609
+ }], fDisabled: [{
2610
+ type: Input
2611
+ }] } });
2643
2612
 
2644
- class FindInputsUnderPointerHandler {
2645
- get fNodes() {
2646
- return this.fComponentsStore.fNodes;
2613
+ class ExternalItemPrepareDragSequence {
2614
+ get transform() {
2615
+ return this.fComponentsStore.fCanvas.transform;
2647
2616
  }
2648
- constructor(fComponentsStore, inputsUnderPointerHandler, firstNotConnectedInputOfNodeUnderPointerHandler) {
2617
+ get flowHost() {
2618
+ return this.fComponentsStore.fFlow.hostElement;
2619
+ }
2620
+ constructor(fComponentsStore, fDraggableDataContext, fExternalItemService) {
2649
2621
  this.fComponentsStore = fComponentsStore;
2650
- this.inputsUnderPointerHandler = inputsUnderPointerHandler;
2651
- this.firstNotConnectedInputOfNodeUnderPointerHandler = firstNotConnectedInputOfNodeUnderPointerHandler;
2622
+ this.fDraggableDataContext = fDraggableDataContext;
2623
+ this.fExternalItemService = fExternalItemService;
2652
2624
  }
2653
- handle(payload) {
2654
- const inputsUnderPointer = this.getInputsUnderPointer(payload);
2655
- const output = this.fComponentsStore.fOutputs.find((x) => x.id === payload.dragHandler.connection.fOutputId);
2656
- if (!output) {
2657
- throw OutputNotFound(payload.dragHandler.connection.fOutputId);
2658
- }
2659
- return inputsUnderPointer.filter((x) => {
2660
- const targetNode = this.fNodes.find((y) => y.isContains(x.hostElement));
2661
- const sourceNode = this.fNodes.find((y) => y.isContains(output.hostElement));
2662
- return sourceNode?.hostElement !== targetNode?.hostElement;
2663
- });
2664
- }
2665
- getInputsUnderPointer(payload) {
2666
- let inputs = this.inputsUnderPointerHandler.handle(payload.event);
2667
- const input = this.firstNotConnectedInputOfNodeUnderPointerHandler.handle(payload.event);
2668
- if (input) {
2669
- inputs.push(input);
2625
+ handle(event) {
2626
+ if (isExternalItem(event.targetElement)) {
2627
+ const item = this.fExternalItemService.getItem(getExternalItem(event.targetElement));
2628
+ if (!item) {
2629
+ throw new Error('External item not found');
2630
+ }
2631
+ if (item.fDisabled) {
2632
+ return;
2633
+ }
2634
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2635
+ this.fDraggableDataContext.onPointerDownScale = 1;
2636
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
2637
+ this.fDraggableDataContext.draggableItems = [
2638
+ new ExternalItemDragHandler(item)
2639
+ ];
2670
2640
  }
2671
- inputs = inputs.filter((x) => x.canBeConnected);
2672
- return inputs;
2673
2641
  }
2674
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, deps: [{ token: FComponentsStore }, { token: InputsUnderPointerHandler }, { token: FirstNotConnectedInputOfNodeUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2675
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler }); }
2642
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2643
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence }); }
2676
2644
  }
2677
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FindInputsUnderPointerHandler, decorators: [{
2645
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, decorators: [{
2678
2646
  type: Injectable
2679
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: InputsUnderPointerHandler }, { type: FirstNotConnectedInputOfNodeUnderPointerHandler }] });
2647
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FExternalItemService }] });
2680
2648
 
2681
- class CreateConnectionOnPointerUp {
2682
- constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler, findFirstCanBeConnectedOutputByOutletHandler) {
2649
+ class ExternalItemOnPointerUp {
2650
+ get flowHost() {
2651
+ return this.fComponentsStore.fFlow.hostElement;
2652
+ }
2653
+ get fCreateNode() {
2654
+ return this.fComponentsStore.fDraggable.fCreateNode;
2655
+ }
2656
+ constructor(fComponentsStore, fDraggableDataContext, fMediator) {
2683
2657
  this.fComponentsStore = fComponentsStore;
2684
2658
  this.fDraggableDataContext = fDraggableDataContext;
2685
- this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2686
- this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2659
+ this.fMediator = fMediator;
2687
2660
  }
2688
2661
  handle(event) {
2689
- const isCreateConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.CREATE_CONNECTION);
2690
- if (isCreateConnection) {
2691
- const handler = this.fDraggableDataContext.draggableItems[0];
2692
- const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2693
- if (inputsUnderPointer.length > 0) {
2694
- let output = this.fComponentsStore.fOutputs.find((x) => x.id === handler.connection.fOutputId);
2695
- if (!output) {
2696
- output = this.fComponentsStore.fOutlets.find((x) => x.id === handler.connection.fOutputId);
2697
- }
2698
- if (!output) {
2699
- throw OutputNotFound(handler.connection.fOutputId);
2700
- }
2701
- const isOutlet = isNodeOutlet(output.hostElement);
2702
- if (isOutlet) {
2703
- output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(output);
2704
- if (!output) {
2705
- throw requiredOutput();
2706
- }
2707
- }
2708
- this.fComponentsStore.fDraggable?.fCreateConnection.emit(new FCreateConnectionEvent(output.id, inputsUnderPointer[0]?.id));
2662
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2663
+ let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
2664
+ const isDragPaletteItem = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.PALETTE_ITEM);
2665
+ if (isDragPaletteItem) {
2666
+ const dragHandler = this.fDraggableDataContext.draggableItems[0];
2667
+ dragHandler.move(difference);
2668
+ const isPointerInCanvasRect = document.elementsFromPoint(event.getPosition().x, event.getPosition().y).some((x) => x === this.flowHost);
2669
+ if (isPointerInCanvasRect) {
2670
+ const rectInCanvas = this.fMediator.send(new GetElementRectInFlowRequest(dragHandler.placeholder));
2671
+ this.fCreateNode.emit(new FCreateNodeEvent(rectInCanvas, dragHandler.externalItem.fData));
2709
2672
  }
2710
- handler.complete();
2673
+ dragHandler.complete();
2711
2674
  }
2712
2675
  }
2713
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2714
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp }); }
2676
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2677
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp }); }
2715
2678
  }
2716
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionOnPointerUp, decorators: [{
2679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, decorators: [{
2717
2680
  type: Injectable
2718
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2681
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FFlowMediator }] });
2719
2682
 
2720
- class CreateConnectionPrepareDragSequence {
2683
+ const EXTERNAL_ITEM_PROVIDERS = [
2684
+ ExternalItemOnPointerUp,
2685
+ ExternalItemPrepareDragSequence
2686
+ ];
2687
+
2688
+ class IsConnectionUnderNodeHandler {
2721
2689
  get transform() {
2722
2690
  return this.fComponentsStore.fCanvas.transform;
2723
2691
  }
2724
2692
  get flowHost() {
2725
2693
  return this.fComponentsStore.fFlow.hostElement;
2726
2694
  }
2727
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, fMediator, findFirstCanBeConnectedOutputByOutletHandler) {
2695
+ constructor(fComponentsStore, fDraggableDataContext, fMediator, getOutgoingConnectionsHandler, getIncomingConnectionsHandler) {
2728
2696
  this.fComponentsStore = fComponentsStore;
2729
2697
  this.fDraggableDataContext = fDraggableDataContext;
2730
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
2731
2698
  this.fMediator = fMediator;
2732
- this.findFirstCanBeConnectedOutputByOutletHandler = findFirstCanBeConnectedOutputByOutletHandler;
2699
+ this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
2700
+ this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
2733
2701
  }
2734
- handle(event) {
2735
- const node = this.fComponentsStore.findNode(event.targetElement);
2736
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2737
- if (!node || this.fDraggableDataContext.draggableItems.length || !this.fComponentsStore.fTempConnection) {
2702
+ handle() {
2703
+ const isValid = this.isValidRequest();
2704
+ if (!isValid) {
2738
2705
  return;
2739
2706
  }
2740
- if (isNodeOutlet(event.targetElement)) {
2741
- const outlet = this.fComponentsStore.fOutlets.find((x) => {
2742
- return x.hostElement.contains(event.targetElement);
2743
- });
2744
- if (!outlet) {
2745
- throw new Error('Outlet not found');
2746
- }
2747
- const nodeOutputs = this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
2748
- outlet.setOutputs(nodeOutputs);
2749
- if (outlet.canBeConnected) {
2750
- const outletCenter = this.getElementRectInFlowHandler.handle(outlet.hostElement).gravityCenter;
2751
- if (outlet.isConnectionFromOutlet) {
2752
- this.createConnectionHandler(pointerPositionInFlow, outlet, outletCenter);
2753
- }
2754
- else {
2755
- const output = this.findFirstCanBeConnectedOutputByOutletHandler.handle(outlet);
2756
- if (!output) {
2757
- throw new Error('Output not found');
2758
- }
2759
- this.createConnectionHandler(pointerPositionInFlow, output, outletCenter);
2707
+ const fNode = this.fDraggableDataContext.draggableItems[0].fNode;
2708
+ const outputsOfNode = this.getOutputsForNode(fNode);
2709
+ const inputsOfNode = this.getInputsForNode(fNode);
2710
+ const isCantBeConnectedByOutput = outputsOfNode.some((x) => !x.canBeConnected);
2711
+ const isCantBeConnectedByInput = this.fComponentsStore.fConnections.some((x) => {
2712
+ return inputsOfNode.find((input) => input.id === x.fInputId);
2713
+ });
2714
+ if (!isCantBeConnectedByInput && outputsOfNode.length && !isCantBeConnectedByOutput && inputsOfNode.length) {
2715
+ const output = outputsOfNode[0];
2716
+ const input = inputsOfNode[0];
2717
+ const outgoingConnections = this.getOutgoingConnectionsHandler.handle([output]);
2718
+ const incomingConnections = this.getIncomingConnectionsHandler.handle([input]);
2719
+ if (outgoingConnections.length === 0 && incomingConnections.length === 0) {
2720
+ const connections = this.findConnectionsUnderNode(fNode);
2721
+ if (connections.length) {
2722
+ //TODO: need to implement
2760
2723
  }
2761
2724
  }
2762
2725
  }
2763
- else if (this.isNodeOutput(event.targetElement, node)) {
2764
- const output = this.fComponentsStore.fOutputs.find((x) => {
2765
- return x.hostElement.contains(event.targetElement);
2766
- });
2767
- if (!output) {
2768
- throw new Error('Output not found');
2769
- }
2770
- if (output.canBeConnected) {
2771
- const outputCenter = this.getElementRectInFlowHandler.handle(output.hostElement).gravityCenter;
2772
- this.createConnectionHandler(pointerPositionInFlow, output, outputCenter);
2773
- }
2774
- }
2775
2726
  }
2776
- createConnectionHandler(pointerPositionInCanvas, output, outputCenter) {
2777
- this.fComponentsStore.fTempConnection.fOutputId = output.id;
2778
- this.fComponentsStore.fTempConnection.initialize();
2779
- this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2780
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInCanvas.div(this.transform.scale);
2781
- this.fDraggableDataContext.draggableItems = [
2782
- new CreateConnectionDragHandler(this.fMediator, this.fComponentsStore.fTempConnection, outputCenter)
2783
- ];
2727
+ isValidRequest() {
2728
+ const result = this.fDraggableDataContext.draggableItems.length === 1 &&
2729
+ this.fDraggableDataContext.draggableItems[0].type === EFDraggableType.NODE;
2730
+ return result;
2784
2731
  }
2785
- isNodeOutput(targetElement, node) {
2786
- const outlets = this.fComponentsStore.fOutlets.filter((x) => node.isContains(x.hostElement));
2787
- return isNodeOutput(targetElement) && !outlets.length;
2732
+ getOutputsForNode(node) {
2733
+ return this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
2788
2734
  }
2789
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }, { token: FFlowMediator }, { token: FindFirstCanBeConnectedOutputByOutletHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2790
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence }); }
2735
+ getInputsForNode(node) {
2736
+ return this.fComponentsStore.fInputs.filter((x) => node.isContains(x.hostElement));
2737
+ }
2738
+ findConnectionsUnderNode(node) {
2739
+ const nodeRect = this.fMediator.send(new GetElementRectInFlowRequest(node.hostElement));
2740
+ return this.fComponentsStore.fConnections.filter((x) => {
2741
+ const intersection = RectExtensions.intersectionWithVector(nodeRect, x.vector.point1, x.vector.point2);
2742
+ return (intersection || []).length > 0;
2743
+ });
2744
+ }
2745
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FFlowMediator }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2746
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler }); }
2791
2747
  }
2792
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: CreateConnectionPrepareDragSequence, decorators: [{
2748
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler, decorators: [{
2793
2749
  type: Injectable
2794
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }, { type: FFlowMediator }, { type: FindFirstCanBeConnectedOutputByOutletHandler }] });
2750
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FFlowMediator }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }] });
2795
2751
 
2796
- class ReassignConnectionDragHandler {
2797
- constructor(getInputRectInFlowHandler, fMediator, connection) {
2798
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
2752
+ class ConnectionDragHandler {
2753
+ constructor(fMediator, connection) {
2799
2754
  this.fMediator = fMediator;
2800
2755
  this.connection = connection;
2801
- this.type = EFDraggableType.REASSIGN_CONNECTION;
2802
- this.onPointerDownFromConnectorRect = RectExtensions.initialize();
2803
- this.onPointerDownToConnectorRect = RectExtensions.initialize();
2804
- this.outputSide = EFConnectableSide.BOTTOM;
2805
- this.inputSide = EFConnectableSide.TOP;
2756
+ this.type = EFDraggableType.CONNECTION;
2757
+ this.onPointerDownVector = VectorExtensions.initialize();
2758
+ this.fromConnectorSide = EFConnectableSide.BOTTOM;
2759
+ this.toConnectorSide = EFConnectableSide.TOP;
2806
2760
  }
2807
2761
  initialize() {
2808
2762
  const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2809
- this.inputSide = this.getInputRectInFlowHandler.handle(this.connection.fInputId).fConnectableSide;
2810
- this.outputSide = fromConnector.fConnectableSide;
2811
- this.onPointerDownFromConnectorRect = fromConnector.rect;
2812
- this.onPointerDownToConnectorRect = RectExtensions.initialize(this.connection.vector.point2.x, this.connection.vector.point2.y, 0, 0);
2763
+ this.fromConnectorSide = fromConnector.fConnectableSide;
2764
+ const toConnector = this.fMediator.send(new GetInputRectInFlowRequest(this.connection.fInputId));
2765
+ this.toConnectorSide = toConnector.fConnectableSide;
2766
+ this.onPointerDownVector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
2813
2767
  }
2814
2768
  move(difference) {
2815
- const toRect = RectExtensions.addPoint(this.onPointerDownToConnectorRect, difference);
2816
- const vector = this.fMediator.send(new GetConnectionVectorRequest(this.onPointerDownFromConnectorRect, toRect, this.connection.fBehavior, this.outputSide, this.inputSide));
2817
- this.connection.setVector(vector.point1, this.outputSide, vector.point2, this.inputSide);
2769
+ const fromPoint = Point.fromPoint(this.onPointerDownVector.point1).add(difference);
2770
+ const toPoint = Point.fromPoint(this.onPointerDownVector.point2).add(difference);
2771
+ this.connection.setVector(fromPoint, this.fromConnectorSide, toPoint, this.toConnectorSide);
2818
2772
  this.connection.redraw();
2819
2773
  }
2820
- complete() {
2774
+ }
2775
+
2776
+ class ConnectionSourceDragHandler {
2777
+ constructor(fMediator, connection) {
2778
+ this.fMediator = fMediator;
2779
+ this.connection = connection;
2780
+ this.type = EFDraggableType.CONNECTION;
2781
+ this.fromConnectorRect = RectExtensions.initialize();
2782
+ this.fromConnectorSide = EFConnectableSide.BOTTOM;
2783
+ this.toConnectorRect = RectExtensions.initialize();
2784
+ this.toConnectorSide = EFConnectableSide.TOP;
2785
+ }
2786
+ initialize() {
2821
2787
  const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2822
- const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
2823
- const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
2824
- this.connection.setVector(vector.point1, fromConnector.fConnectableSide, vector.point2, toConnector.fConnectableSide);
2788
+ this.fromConnectorRect = fromConnector.rect;
2789
+ this.fromConnectorSide = fromConnector.fConnectableSide;
2790
+ const toConnector = this.fMediator.send(new GetInputRectInFlowRequest(this.connection.fInputId));
2791
+ this.toConnectorRect = toConnector.rect;
2792
+ this.toConnectorSide = toConnector.fConnectableSide;
2793
+ }
2794
+ move(difference) {
2795
+ const fromConnectorRect = RectExtensions.addPoint(this.fromConnectorRect, difference);
2796
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnectorRect, this.toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
2797
+ this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
2825
2798
  this.connection.redraw();
2826
2799
  }
2827
2800
  }
2828
2801
 
2829
- class FReassignConnectionEvent {
2830
- constructor(connectionId, fOutputId, oldFInputId, newFInputId) {
2831
- this.connectionId = connectionId;
2832
- this.fOutputId = fOutputId;
2833
- this.oldFInputId = oldFInputId;
2834
- this.newFInputId = newFInputId;
2802
+ class ConnectionTargetDragHandler {
2803
+ constructor(fMediator, connection) {
2804
+ this.fMediator = fMediator;
2805
+ this.connection = connection;
2806
+ this.type = EFDraggableType.CONNECTION;
2807
+ this.fromConnectorRect = RectExtensions.initialize();
2808
+ this.fromConnectorSide = EFConnectableSide.BOTTOM;
2809
+ this.toConnectorRect = RectExtensions.initialize();
2810
+ this.toConnectorSide = EFConnectableSide.TOP;
2811
+ }
2812
+ initialize() {
2813
+ const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
2814
+ this.fromConnectorRect = fromConnector.rect;
2815
+ this.fromConnectorSide = fromConnector.fConnectableSide;
2816
+ const toConnector = this.fMediator.send(new GetInputRectInFlowRequest(this.connection.fInputId));
2817
+ this.toConnectorRect = toConnector.rect;
2818
+ this.toConnectorSide = toConnector.fConnectableSide;
2819
+ }
2820
+ move(difference) {
2821
+ const toConnectorRect = RectExtensions.addPoint(this.toConnectorRect, difference);
2822
+ const vector = this.fMediator.send(new GetConnectionVectorRequest(this.fromConnectorRect, toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
2823
+ this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
2824
+ this.connection.redraw();
2835
2825
  }
2836
2826
  }
2837
2827
 
2838
- class ReassignConnectionOnPointerUp {
2839
- get fDraggable() {
2840
- return this.fComponentsStore.fDraggable;
2841
- }
2842
- constructor(fComponentsStore, fDraggableDataContext, findInputsUnderPointerHandler) {
2843
- this.fComponentsStore = fComponentsStore;
2828
+ class NodeDragHandler {
2829
+ constructor(fDraggableDataContext, fNode) {
2844
2830
  this.fDraggableDataContext = fDraggableDataContext;
2845
- this.findInputsUnderPointerHandler = findInputsUnderPointerHandler;
2846
- }
2831
+ this.fNode = fNode;
2832
+ this.type = EFDraggableType.NODE;
2833
+ this.onPointerDownPosition = PointExtensions.initialize();
2834
+ this.onPointerDownPosition = this.fNode.position;
2835
+ }
2836
+ move(difference) {
2837
+ const position = Point.fromPoint(this.onPointerDownPosition).add(difference);
2838
+ this.fNode.updatePosition(position);
2839
+ this.fNode.redraw();
2840
+ this.fDraggableDataContext.fLineAlignment?.handle(difference);
2841
+ }
2842
+ complete() {
2843
+ this.fNode.completeDrag();
2844
+ }
2845
+ }
2846
+
2847
+ class NodeOnPointerUp {
2848
+ get transform() {
2849
+ return this.fComponentsStore.fCanvas.transform;
2850
+ }
2851
+ get flowHost() {
2852
+ return this.fComponentsStore.fFlow.hostElement;
2853
+ }
2854
+ constructor(fComponentsStore, fDraggableDataContext, isConnectionUnderNodeHandler) {
2855
+ this.fComponentsStore = fComponentsStore;
2856
+ this.fDraggableDataContext = fDraggableDataContext;
2857
+ this.isConnectionUnderNodeHandler = isConnectionUnderNodeHandler;
2858
+ }
2847
2859
  handle(event) {
2848
- const isReassignConnection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.REASSIGN_CONNECTION);
2849
- if (isReassignConnection) {
2850
- const handler = this.fDraggableDataContext.draggableItems[0];
2851
- const inputsUnderPointer = this.findInputsUnderPointerHandler.handle(new FindInputsUnderPointerRequest(event, handler));
2852
- if (inputsUnderPointer.length > 0) {
2853
- if (handler.connection.fInputId !== inputsUnderPointer[0]?.id) {
2854
- this.fDraggable.fReassignConnection.emit(new FReassignConnectionEvent(handler.connection.fConnectionId, handler.connection.fOutputId, handler.connection.fInputId, inputsUnderPointer[0]?.id));
2855
- }
2860
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2861
+ let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
2862
+ const isDragNodes = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.NODE);
2863
+ if (isDragNodes) {
2864
+ const nearestIntersection = this.fDraggableDataContext.fLineAlignment?.findNearestCoordinate(difference);
2865
+ if (nearestIntersection) {
2866
+ difference.x = nearestIntersection.xResult.value ? (difference.x - nearestIntersection.xResult.distance) : difference.x;
2867
+ difference.y = nearestIntersection.yResult.value ? (difference.y - nearestIntersection.yResult.distance) : difference.y;
2856
2868
  }
2857
- handler.complete();
2869
+ this.fDraggableDataContext.draggableItems.forEach((x) => {
2870
+ x.move(difference);
2871
+ x.complete?.();
2872
+ });
2873
+ this.isConnectionUnderNodeHandler.handle();
2874
+ this.fDraggableDataContext.fLineAlignment?.complete();
2858
2875
  }
2859
2876
  }
2860
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FindInputsUnderPointerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2861
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp }); }
2877
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: IsConnectionUnderNodeHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2878
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp }); }
2862
2879
  }
2863
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionOnPointerUp, decorators: [{
2880
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp, decorators: [{
2864
2881
  type: Injectable
2865
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FindInputsUnderPointerHandler }] });
2882
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: IsConnectionUnderNodeHandler }] });
2866
2883
 
2867
- class ReassignConnectionPrepareDragSequence {
2884
+ class NodePrepareDragSequence {
2868
2885
  get transform() {
2869
2886
  return this.fComponentsStore.fCanvas.transform;
2870
2887
  }
2871
2888
  get flowHost() {
2872
2889
  return this.fComponentsStore.fFlow.hostElement;
2873
2890
  }
2874
- constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, getInputRectInFlowHandler, fMediator, updateConnectionLayerHandler) {
2891
+ constructor(fComponentsStore, fDraggableDataContext, updateNodeLayerHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler, fMediator) {
2875
2892
  this.fComponentsStore = fComponentsStore;
2876
2893
  this.fDraggableDataContext = fDraggableDataContext;
2877
- this.getConnectionHandler = getConnectionHandler;
2878
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
2894
+ this.updateNodeLayerHandler = updateNodeLayerHandler;
2895
+ this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
2896
+ this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
2879
2897
  this.fMediator = fMediator;
2880
- this.updateConnectionLayerHandler = updateConnectionLayerHandler;
2881
2898
  }
2882
2899
  handle(event) {
2900
+ const node = this.fComponentsStore.findNode(event.targetElement);
2883
2901
  const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
2884
- const position = event.getPosition();
2885
- const allElements = document.elementsFromPoint(position.x, position.y);
2886
- const dragHandlesOfConnections = allElements.filter((x) => {
2887
- return !!this.getConnectionHandler.handle(x) && x.classList.contains(F_CONNECTION_DRAG_HANDLE_CLASS);
2888
- });
2889
- let connectionToReassign;
2890
- if (dragHandlesOfConnections.length) {
2891
- const connections = dragHandlesOfConnections.map((x) => this.getConnectionHandler.handle(x)).filter((x) => !x?.disabled);
2892
- if (connections.length) {
2893
- connectionToReassign = this.getConnectionHandler.handle(dragHandlesOfConnections[0]);
2902
+ if (node && !node.disabled && !this.fDraggableDataContext.draggableItems.length) {
2903
+ if (isNodeDragHandle(event.targetElement)) {
2904
+ if (!this.fDraggableDataContext.selectedItems.includes(node)) {
2905
+ this.fDraggableDataContext.selectedItems.push(node);
2906
+ node.select();
2907
+ this.fDraggableDataContext.isSelectedChanged = true;
2908
+ }
2909
+ this.updateNodeLayerHandler.handle(node);
2910
+ const itemsToDrag = this.calculateDraggableConnectionsAndNodes();
2911
+ const draggedNodes = itemsToDrag.filter((x) => {
2912
+ return x.type === EFDraggableType.NODE;
2913
+ }).map((x) => x.fNode);
2914
+ this.fDraggableDataContext.fLineAlignment?.initialize(this.fComponentsStore.fNodes, draggedNodes);
2915
+ this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2916
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
2917
+ this.fDraggableDataContext.draggableItems = itemsToDrag;
2894
2918
  }
2895
2919
  }
2896
- if (connectionToReassign && !this.fDraggableDataContext.draggableItems.length) {
2897
- this.updateConnectionLayerHandler.handle(connectionToReassign);
2898
- this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
2899
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
2900
- this.fDraggableDataContext.draggableItems = [
2901
- new ReassignConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, connectionToReassign)
2902
- ];
2903
- }
2904
2920
  }
2905
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: GetInputRectInFlowHandler }, { token: FFlowMediator }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
2906
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence }); }
2921
+ calculateDraggableConnectionsAndNodes() {
2922
+ let itemsToDrag = [];
2923
+ const selectedNodes = this.fDraggableDataContext.selectedItems.map((x) => {
2924
+ return this.fComponentsStore.findNode(x.hostElement);
2925
+ }).filter((x) => !!x);
2926
+ const nodeDragHandlers = selectedNodes.map((x) => new NodeDragHandler(this.fDraggableDataContext, x));
2927
+ itemsToDrag = nodeDragHandlers;
2928
+ const allOutputIds = selectedNodes.reduce((result, x) => {
2929
+ return result.concat(this.getOutputsForNode(x));
2930
+ }, []).map((x) => x.id);
2931
+ const allInputIds = selectedNodes.reduce((result, x) => {
2932
+ return result.concat(this.getInputsForNode(x));
2933
+ }, []).map((x) => x.id);
2934
+ nodeDragHandlers.forEach((nodeHandler) => {
2935
+ const outputConnections = this.getOutgoingConnectionsHandler.handle(this.getOutputsForNode(nodeHandler.fNode));
2936
+ outputConnections.forEach((c) => {
2937
+ if (allInputIds.includes(c.fInputId)) {
2938
+ itemsToDrag.push(new ConnectionDragHandler(this.fMediator, c));
2939
+ }
2940
+ else {
2941
+ itemsToDrag.push(new ConnectionSourceDragHandler(this.fMediator, c));
2942
+ }
2943
+ });
2944
+ const inputConnections = this.getIncomingConnectionsHandler.handle(this.getInputsForNode(nodeHandler.fNode));
2945
+ inputConnections.forEach((c) => {
2946
+ if (allOutputIds.includes(c.fOutputId)) {
2947
+ const index = itemsToDrag.findIndex((x) => x.type === EFDraggableType.CONNECTION && x.connection.fConnectionId === c.fConnectionId);
2948
+ if (index !== -1) {
2949
+ itemsToDrag.push(new ConnectionDragHandler(this.fMediator, c));
2950
+ }
2951
+ }
2952
+ else {
2953
+ itemsToDrag.push(new ConnectionTargetDragHandler(this.fMediator, c));
2954
+ }
2955
+ });
2956
+ });
2957
+ return itemsToDrag;
2958
+ }
2959
+ getInputsForNode(node) {
2960
+ return this.fComponentsStore.fInputs.filter((x) => node.isContains(x.hostElement));
2961
+ }
2962
+ getOutputsForNode(node) {
2963
+ return this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
2964
+ }
2965
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: UpdateNodeLayerHandler }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
2966
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence }); }
2907
2967
  }
2908
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ReassignConnectionPrepareDragSequence, decorators: [{
2968
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, decorators: [{
2909
2969
  type: Injectable
2910
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: GetInputRectInFlowHandler }, { type: FFlowMediator }, { type: UpdateConnectionLayerHandler }] });
2970
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: UpdateNodeLayerHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }, { type: FFlowMediator }] });
2911
2971
 
2912
- const CONNECTIONS_PROVIDERS = [
2913
- FindFirstCanBeConnectedOutputByOutletHandler,
2914
- CreateConnectionOnPointerUp,
2915
- CreateConnectionPrepareDragSequence,
2916
- FirstNotConnectedInputOfNodeUnderPointerHandler,
2917
- InputsUnderPointerHandler,
2918
- FindInputsUnderPointerHandler,
2919
- ReassignConnectionOnPointerUp,
2920
- ReassignConnectionPrepareDragSequence
2972
+ const NODE_PROVIDERS = [
2973
+ NodeOnPointerUp,
2974
+ NodePrepareDragSequence,
2975
+ IsConnectionUnderNodeHandler
2921
2976
  ];
2922
2977
 
2923
- class FCreateNodeEvent {
2924
- constructor(rect, data) {
2925
- this.rect = rect;
2926
- this.data = data;
2927
- }
2928
- }
2929
-
2930
- class ExternalItemDragHandler {
2931
- constructor(externalItem) {
2932
- this.externalItem = externalItem;
2933
- this.type = EFDraggableType.PALETTE_ITEM;
2934
- this.onPointerDownRect = RectExtensions.initialize();
2935
- this.difference = PointExtensions.initialize();
2978
+ class GetCanBeSelectedItemsHandler {
2979
+ get fNodes() {
2980
+ return this.fComponentsStore.fNodes;
2936
2981
  }
2937
- getStyle(position) {
2938
- return `position: absolute; left: 0; top: 0; transform: translate(${position.x}px, ${position.y}px)`;
2982
+ get fConnections() {
2983
+ return this.fComponentsStore.fConnections;
2939
2984
  }
2940
- initialize() {
2941
- this.onPointerDownRect = this.getExternalItemRect();
2942
- this.placeholder = DomElementExtensions.deepCloneNode(this.externalItem.hostElement);
2943
- document.body.appendChild(this.placeholder);
2985
+ get transform() {
2986
+ return this.fComponentsStore.fCanvas.transform;
2944
2987
  }
2945
- getExternalItemRect() {
2946
- const rect = this.externalItem.hostElement.getBoundingClientRect();
2947
- const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
2948
- const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
2949
- const offsetTop = rect.top + scrollTop;
2950
- const offsetLeft = rect.left + scrollLeft;
2951
- return RectExtensions.initialize(offsetLeft, offsetTop, rect.width, rect.height);
2988
+ constructor(fComponentsStore, fDraggableDataContext, fMediator) {
2989
+ this.fComponentsStore = fComponentsStore;
2990
+ this.fDraggableDataContext = fDraggableDataContext;
2991
+ this.fMediator = fMediator;
2952
2992
  }
2953
- move(difference) {
2954
- this.difference = difference;
2955
- const position = Point.fromPoint(this.onPointerDownRect).add(this.difference);
2956
- this.placeholder.setAttribute('style', this.getStyle(position));
2993
+ handle() {
2994
+ const nodeRects = this.getNodesWithRects();
2995
+ const lineRects = this.getConnectionsWithRects();
2996
+ const result = [...nodeRects, ...lineRects].filter((x) => {
2997
+ return !this.fDraggableDataContext.selectedItems.includes(x.element);
2998
+ });
2999
+ return result;
2957
3000
  }
2958
- getPlaceholderRect() {
2959
- return RectExtensions.fromElement(this.placeholder);
3001
+ getNodesWithRects() {
3002
+ return this.fNodes.map((x) => {
3003
+ const rect = this.fMediator.send(new GetElementRectInFlowRequest(x.hostElement));
3004
+ return {
3005
+ element: x,
3006
+ rect: RectExtensions.mult(rect, this.transform.scale)
3007
+ };
3008
+ });
2960
3009
  }
2961
- complete() {
2962
- document.body.removeChild(this.placeholder);
3010
+ getConnectionsWithRects() {
3011
+ return this.fConnections.map((x) => {
3012
+ const rect = this.fMediator.send(new GetElementRectInFlowRequest(x.boundingElement));
3013
+ return {
3014
+ element: x,
3015
+ rect: RectExtensions.mult(rect, this.transform.scale)
3016
+ };
3017
+ });
2963
3018
  }
3019
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3020
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler }); }
2964
3021
  }
3022
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler, decorators: [{
3023
+ type: Injectable
3024
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FFlowMediator }] });
2965
3025
 
2966
- const F_EXTERNAL_ITEM = new InjectionToken('F_EXTERNAL_ITEM');
2967
- class FExternalItemBase {
2968
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
2969
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemBase, ngImport: i0 }); }
2970
- }
2971
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemBase, decorators: [{
2972
- type: Directive
2973
- }] });
2974
-
2975
- function isExternalItem(element) {
2976
- return !!element.closest('[fExternalItem]');
2977
- }
2978
- function getExternalItem(element) {
2979
- return element.closest('[fExternalItem]');
2980
- }
2981
-
2982
- class FExternalItemService {
2983
- constructor() {
2984
- this.items = [];
2985
- }
2986
- registerItem(item) {
2987
- this.items.push(item);
2988
- }
2989
- getItem(element) {
2990
- return this.items.find(item => item.hostElement === element);
3026
+ class SelectionAreaDragHandle {
3027
+ get canvasPosition() {
3028
+ return Point.fromPoint(this.fComponentsStore.fCanvas.transform.position).add(this.fComponentsStore.fCanvas.transform.scaledPosition);
2991
3029
  }
2992
- removeItem(item) {
2993
- const index = this.items.indexOf(item);
2994
- if (index !== -1) {
2995
- this.items.splice(index, 1);
2996
- }
2997
- }
2998
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2999
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, providedIn: 'root' }); }
3000
- }
3001
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemService, decorators: [{
3002
- type: Injectable,
3003
- args: [{
3004
- providedIn: 'root'
3005
- }]
3006
- }] });
3007
-
3008
- let uniqueId$1 = 0;
3009
- class FExternalItemDirective extends FExternalItemBase {
3010
- get hostElement() {
3011
- return this.elementReference.nativeElement;
3030
+ constructor(fComponentsStore, fDraggableDataContext, injector) {
3031
+ this.fComponentsStore = fComponentsStore;
3032
+ this.fDraggableDataContext = fDraggableDataContext;
3033
+ this.injector = injector;
3034
+ this.type = EFDraggableType.SELECTION;
3035
+ this.canBeSelected = [];
3036
+ this.selectedByMove = [];
3012
3037
  }
3013
- constructor(elementReference, fExternalItemService) {
3014
- super();
3015
- this.elementReference = elementReference;
3016
- this.fExternalItemService = fExternalItemService;
3017
- this.id = `f-external-item-${uniqueId$1++}`;
3038
+ initialize() {
3039
+ this.canBeSelected = this.injector.get(GetCanBeSelectedItemsHandler).handle();
3040
+ this.fDraggableDataContext.fSelectionArea?.show();
3041
+ this.fDraggableDataContext.fSelectionArea?.draw({
3042
+ left: this.fDraggableDataContext.onPointerDownPosition.x,
3043
+ top: this.fDraggableDataContext.onPointerDownPosition.y,
3044
+ width: 0,
3045
+ height: 0
3046
+ });
3018
3047
  }
3019
- ngOnInit() {
3020
- this.fExternalItemService.registerItem(this);
3048
+ move(difference) {
3049
+ const currentPoint = Point.fromPoint(difference).add(this.fDraggableDataContext.onPointerDownPosition);
3050
+ const x = Math.min(this.fDraggableDataContext.onPointerDownPosition.x, currentPoint.x);
3051
+ const y = Math.min(this.fDraggableDataContext.onPointerDownPosition.y, currentPoint.y);
3052
+ const width = Math.abs(difference.x);
3053
+ const height = Math.abs(difference.y);
3054
+ this.fDraggableDataContext.fSelectionArea?.draw({ left: x, top: y, width, height });
3055
+ this.selectedByMove = [];
3056
+ this.canBeSelected.forEach((item) => {
3057
+ item.element.deselect();
3058
+ const itemRect = RectExtensions.addPoint(item.rect, this.canvasPosition);
3059
+ const isIntersect = RectExtensions.intersectionWithRect(itemRect, RectExtensions.initialize(x, y, width, height));
3060
+ if (isIntersect) {
3061
+ item.element.select();
3062
+ this.selectedByMove.push(item.element);
3063
+ }
3064
+ });
3021
3065
  }
3022
- ngOnDestroy() {
3023
- this.fExternalItemService.removeItem(this);
3066
+ complete() {
3067
+ this.fDraggableDataContext.fSelectionArea?.hide();
3068
+ this.fDraggableDataContext.selectedItems.push(...this.selectedByMove);
3069
+ if (this.selectedByMove.length > 0) {
3070
+ this.fDraggableDataContext.isSelectedChanged = true;
3071
+ }
3024
3072
  }
3025
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, deps: [{ token: i0.ElementRef }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Directive }); }
3026
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FExternalItemDirective, selector: "[fExternalItem]", inputs: { id: "id", data: "data" }, host: { properties: { "attr.id": "id" }, classAttribute: "f-component f-external-item" }, providers: [
3027
- { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
3028
- ], usesInheritance: true, ngImport: i0 }); }
3029
3073
  }
3030
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FExternalItemDirective, decorators: [{
3031
- type: Directive,
3032
- args: [{
3033
- selector: "[fExternalItem]",
3034
- host: {
3035
- '[attr.id]': 'id',
3036
- class: "f-component f-external-item",
3037
- },
3038
- providers: [
3039
- { provide: F_EXTERNAL_ITEM, useExisting: FExternalItemDirective }
3040
- ],
3041
- }]
3042
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FExternalItemService }], propDecorators: { id: [{
3043
- type: Input
3044
- }], data: [{
3045
- type: Input
3046
- }] } });
3047
3074
 
3048
- class ExternalItemPrepareDragSequence {
3049
- get transform() {
3050
- return this.fComponentsStore.fCanvas.transform;
3051
- }
3052
- get flowHost() {
3053
- return this.fComponentsStore.fFlow.hostElement;
3075
+ class SelectionAreaPrepareDragSequence {
3076
+ get fFlow() {
3077
+ return this.fComponentsStore.fFlow;
3054
3078
  }
3055
- constructor(fComponentsStore, fDraggableDataContext, fExternalItemService) {
3079
+ constructor(fComponentsStore, fDraggableDataContext, injector) {
3056
3080
  this.fComponentsStore = fComponentsStore;
3057
3081
  this.fDraggableDataContext = fDraggableDataContext;
3058
- this.fExternalItemService = fExternalItemService;
3082
+ this.injector = injector;
3059
3083
  }
3060
3084
  handle(event) {
3061
- if (isExternalItem(event.targetElement)) {
3062
- const item = this.fExternalItemService.getItem(getExternalItem(event.targetElement));
3063
- if (!item) {
3064
- throw new Error('External item not found');
3065
- }
3066
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3067
- this.fDraggableDataContext.onPointerDownScale = 1;
3068
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
3085
+ const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.fFlow.hostElement);
3086
+ if (MouseEventExtensions.isShiftPressed(event.originalEvent) && this.fDraggableDataContext.fSelectionArea) {
3069
3087
  this.fDraggableDataContext.draggableItems = [
3070
- new ExternalItemDragHandler(item)
3088
+ new SelectionAreaDragHandle(this.fComponentsStore, this.fDraggableDataContext, this.injector)
3071
3089
  ];
3090
+ this.fDraggableDataContext.onPointerDownScale = 1;
3091
+ this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
3072
3092
  }
3073
3093
  }
3074
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: FExternalItemService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3075
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence }); }
3094
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
3095
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence }); }
3076
3096
  }
3077
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemPrepareDragSequence, decorators: [{
3097
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence, decorators: [{
3078
3098
  type: Injectable
3079
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: FExternalItemService }] });
3099
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: i0.Injector }] });
3080
3100
 
3081
- class ExternalItemOnPointerUp {
3082
- get flowHost() {
3083
- return this.fComponentsStore.fFlow.hostElement;
3084
- }
3085
- get fCreateNode() {
3086
- return this.fComponentsStore.fDraggable.fCreateNode;
3087
- }
3088
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
3089
- this.fComponentsStore = fComponentsStore;
3101
+ class SelectionAreaOnPointerUp {
3102
+ constructor(fDraggableDataContext) {
3090
3103
  this.fDraggableDataContext = fDraggableDataContext;
3091
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3092
3104
  }
3093
3105
  handle(event) {
3094
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3095
- let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3096
- const isDragPaletteItem = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.PALETTE_ITEM);
3097
- if (isDragPaletteItem) {
3098
- const dragHandler = this.fDraggableDataContext.draggableItems[0];
3099
- dragHandler.move(difference);
3100
- const isPointerInCanvasRect = document.elementsFromPoint(event.getPosition().x, event.getPosition().y).some((x) => x === this.flowHost);
3101
- if (isPointerInCanvasRect) {
3102
- const rectInCanvas = this.getElementRectInFlowHandler.handle(dragHandler.placeholder);
3103
- this.fCreateNode.emit(new FCreateNodeEvent(rectInCanvas, dragHandler.externalItem.data));
3104
- }
3105
- dragHandler.complete();
3106
+ const isSelection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.SELECTION);
3107
+ if (isSelection) {
3108
+ this.fDraggableDataContext.draggableItems.forEach((x) => {
3109
+ x.complete?.();
3110
+ });
3106
3111
  }
3107
3112
  }
3108
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3109
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp }); }
3113
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
3114
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp }); }
3110
3115
  }
3111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ExternalItemOnPointerUp, decorators: [{
3116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp, decorators: [{
3112
3117
  type: Injectable
3113
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
3118
+ }], ctorParameters: () => [{ type: FDraggableDataContext }] });
3114
3119
 
3115
- const EXTERNAL_ITEM_PROVIDERS = [
3116
- ExternalItemOnPointerUp,
3117
- ExternalItemPrepareDragSequence
3120
+ const SELECTION_AREA_PROVIDERS = [
3121
+ GetCanBeSelectedItemsHandler,
3122
+ SelectionAreaPrepareDragSequence,
3123
+ SelectionAreaOnPointerUp,
3118
3124
  ];
3119
3125
 
3120
- class IsConnectionUnderNodeHandler {
3121
- get transform() {
3122
- return this.fComponentsStore.fCanvas.transform;
3123
- }
3124
- get flowHost() {
3125
- return this.fComponentsStore.fFlow.hostElement;
3126
- }
3127
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler) {
3126
+ class SingleSelectOnPointerDown {
3127
+ constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, updateConnectionLayerHandler) {
3128
3128
  this.fComponentsStore = fComponentsStore;
3129
3129
  this.fDraggableDataContext = fDraggableDataContext;
3130
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3131
- this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
3132
- this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
3130
+ this.getConnectionHandler = getConnectionHandler;
3131
+ this.updateConnectionLayerHandler = updateConnectionLayerHandler;
3133
3132
  }
3134
- handle() {
3135
- const isValid = this.isValidRequest();
3136
- if (!isValid) {
3133
+ handle(event) {
3134
+ if (!this.fComponentsStore.fFlow?.hostElement.contains(event.targetElement)) {
3137
3135
  return;
3138
3136
  }
3139
- const fNode = this.fDraggableDataContext.draggableItems[0].fNode;
3140
- const outputsOfNode = this.getOutputsForNode(fNode);
3141
- const inputsOfNode = this.getInputsForNode(fNode);
3142
- const isCantBeConnectedByOutput = outputsOfNode.some((x) => !x.canBeConnected);
3143
- const isCantBeConnectedByInput = this.fComponentsStore.fConnections.some((x) => {
3144
- return inputsOfNode.find((input) => input.id === x.fInputId);
3145
- });
3146
- if (!isCantBeConnectedByInput && outputsOfNode.length && !isCantBeConnectedByOutput && inputsOfNode.length) {
3147
- const output = outputsOfNode[0];
3148
- const input = inputsOfNode[0];
3149
- const outgoingConnections = this.getOutgoingConnectionsHandler.handle([output]);
3150
- const incomingConnections = this.getIncomingConnectionsHandler.handle([input]);
3151
- if (outgoingConnections.length === 0 && incomingConnections.length === 0) {
3152
- const connections = this.findConnectionsUnderNode(fNode);
3153
- if (connections.length) {
3137
+ const node = this.fComponentsStore.findNode(event.targetElement);
3138
+ const connection = this.getConnectionHandler.handle(event.targetElement);
3139
+ this.deselectAll(node, event);
3140
+ let element;
3141
+ if (this.fDraggableDataContext.selectedItems.length) {
3142
+ element = this.fDraggableDataContext.selectedItems[0];
3143
+ }
3144
+ this.resetSelectionIfNotMultiselect(event);
3145
+ if (node) {
3146
+ if (!this.fDraggableDataContext.selectedItems.includes(node)) {
3147
+ this.fDraggableDataContext.selectedItems.push(node);
3148
+ if (element?.hostElement.dataset['fNodeId'] !== node.hostElement.dataset['fNodeId']) {
3149
+ this.fDraggableDataContext.isSelectedChanged = true;
3154
3150
  }
3155
3151
  }
3152
+ else {
3153
+ this.fDraggableDataContext.selectedItems.splice(this.fDraggableDataContext.selectedItems.indexOf(node), 1);
3154
+ }
3156
3155
  }
3156
+ else if (connection) {
3157
+ this.updateConnectionLayerHandler.handle(connection);
3158
+ if (!this.fDraggableDataContext.selectedItems.includes(connection)) {
3159
+ this.fDraggableDataContext.selectedItems.push(connection);
3160
+ if (element?.hostElement.id !== connection.hostElement.id) {
3161
+ this.fDraggableDataContext.isSelectedChanged = true;
3162
+ }
3163
+ }
3164
+ else {
3165
+ this.fDraggableDataContext.selectedItems.splice(this.fDraggableDataContext.selectedItems.indexOf(connection), 1);
3166
+ }
3167
+ }
3168
+ this.selectIfNotSelected();
3157
3169
  }
3158
- isValidRequest() {
3159
- const result = this.fDraggableDataContext.draggableItems.length === 1 &&
3160
- this.fDraggableDataContext.draggableItems[0].type === EFDraggableType.NODE;
3161
- return result;
3162
- }
3163
- getOutputsForNode(node) {
3164
- return this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
3170
+ deselectAll(node, event) {
3171
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3172
+ if (x !== node || (!isNodeOutlet(event.targetElement) && !isNodeOutput(event.targetElement))) {
3173
+ x.deselect();
3174
+ }
3175
+ });
3165
3176
  }
3166
- getInputsForNode(node) {
3167
- return this.fComponentsStore.fInputs.filter((x) => node.isContains(x.hostElement));
3177
+ resetSelectionIfNotMultiselect(event) {
3178
+ const isMultiselect = MouseEventExtensions.isCommandButton(event.originalEvent) ||
3179
+ MouseEventExtensions.isShiftPressed(event.originalEvent);
3180
+ if (!isMultiselect) {
3181
+ this.fDraggableDataContext.selectedItems = [];
3182
+ }
3168
3183
  }
3169
- findConnectionsUnderNode(node) {
3170
- const nodeRect = this.getElementRectInFlowHandler.handle(node.hostElement);
3171
- return this.fComponentsStore.fConnections.filter((x) => {
3172
- const intersection = RectExtensions.intersectionWithVector(nodeRect, x.vector.point1, x.vector.point2);
3173
- return (intersection || []).length > 0;
3184
+ selectIfNotSelected() {
3185
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3186
+ if (!x.isSelected()) {
3187
+ x.select();
3188
+ }
3174
3189
  });
3175
3190
  }
3176
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3177
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler }); }
3191
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3192
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown }); }
3178
3193
  }
3179
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: IsConnectionUnderNodeHandler, decorators: [{
3194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown, decorators: [{
3180
3195
  type: Injectable
3181
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }] });
3196
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: UpdateConnectionLayerHandler }] });
3182
3197
 
3183
- class ConnectionDragHandler {
3184
- constructor(getInputRectInFlowHandler, fMediator, connection) {
3185
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3186
- this.fMediator = fMediator;
3187
- this.connection = connection;
3188
- this.type = EFDraggableType.CONNECTION;
3189
- this.onPointerDownVector = VectorExtensions.initialize();
3190
- this.fromConnectorSide = EFConnectableSide.BOTTOM;
3191
- this.toConnectorSide = EFConnectableSide.TOP;
3198
+ const SINGLE_SELECT_PROVIDERS = [
3199
+ SingleSelectOnPointerDown
3200
+ ];
3201
+
3202
+ const F_DRAGGABLE = new InjectionToken('F_DRAGGABLE');
3203
+ const MOUSE_EVENT_IGNORE_TIME = 800;
3204
+ class FDraggableBase {
3205
+ isSyntheticEvent(event) {
3206
+ const isSyntheticEvent = !!this.lastTouchEventTime &&
3207
+ (this.lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now());
3208
+ return isSyntheticEvent;
3192
3209
  }
3193
- initialize() {
3194
- const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3195
- this.fromConnectorSide = fromConnector.fConnectableSide;
3196
- const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
3197
- this.toConnectorSide = toConnector.fConnectableSide;
3198
- this.onPointerDownVector = this.fMediator.send(new GetConnectionVectorRequest(fromConnector.rect, toConnector.rect, this.connection.fBehavior, fromConnector.fConnectableSide, toConnector.fConnectableSide));
3210
+ constructor(ngZone) {
3211
+ this.ngZone = ngZone;
3212
+ this.mouseListeners = EventExtensions.emptyListener();
3213
+ this.touchListeners = EventExtensions.emptyListener();
3214
+ this.startListeners = EventExtensions.emptyListener();
3215
+ this.lastTouchEventTime = 0;
3216
+ this.isDragStarted = false;
3217
+ this.dragStartThreshold = 5;
3218
+ this.dragStartDelay = 0;
3219
+ this.dragStartTime = 0;
3220
+ this.dragStartPosition = PointExtensions.initialize();
3221
+ this.moveHandler = this.checkDragSequenceToStart;
3222
+ this.onMouseDown = (event) => {
3223
+ const isSyntheticEvent = this.isSyntheticEvent(event);
3224
+ const isFakeEvent = isFakeMousedownFromScreenReader(event);
3225
+ const mouseEvent = new IMouseEvent(event);
3226
+ if (isSyntheticEvent || isFakeEvent || this.disabled) {
3227
+ return;
3228
+ }
3229
+ let result = this.onPointerDown(mouseEvent);
3230
+ if (result) {
3231
+ this.dragStartTime = Date.now();
3232
+ this.dragStartPosition = mouseEvent.getPosition();
3233
+ this.ngZone.runOutsideAngular(() => {
3234
+ this.document?.addEventListener('mousemove', this.onMouseMove);
3235
+ this.document?.addEventListener('mouseup', this.onMouseUp);
3236
+ });
3237
+ this.mouseListeners = () => {
3238
+ this.document?.removeEventListener('mousemove', this.onMouseMove);
3239
+ this.document?.removeEventListener('mouseup', this.onMouseUp);
3240
+ };
3241
+ }
3242
+ };
3243
+ this.onTouchDown = (event) => {
3244
+ const isFakeEvent = isFakeTouchstartFromScreenReader(event);
3245
+ const touchEvent = new ITouchDownEvent(event);
3246
+ if (isFakeEvent || this.disabled) {
3247
+ return;
3248
+ }
3249
+ let result = this.onPointerDown(new ITouchDownEvent(event));
3250
+ if (result) {
3251
+ this.dragStartTime = Date.now();
3252
+ this.dragStartPosition = touchEvent.getPosition();
3253
+ this.ngZone.runOutsideAngular(() => {
3254
+ this.document?.addEventListener('touchmove', this.onTouchMove);
3255
+ this.document?.addEventListener('touchend', this.onTouchUp);
3256
+ });
3257
+ this.touchListeners = () => {
3258
+ this.document?.removeEventListener('touchmove', this.onTouchMove);
3259
+ this.document?.removeEventListener('touchend', this.onTouchUp);
3260
+ };
3261
+ }
3262
+ };
3263
+ this.onMouseMove = (event) => {
3264
+ this.moveHandler(new IMouseEvent(event));
3265
+ };
3266
+ this.onTouchMove = (event) => {
3267
+ this.moveHandler(new ITouchMoveEvent(event));
3268
+ };
3269
+ this.onMouseUp = (event) => {
3270
+ if (this.isDragStarted) {
3271
+ this.onPointerUp(new IMouseEvent(event));
3272
+ }
3273
+ this.endDragSequence();
3274
+ };
3275
+ this.onTouchUp = (event) => {
3276
+ if (this.isDragStarted) {
3277
+ this.onPointerUp(new ITouchUpEvent(event));
3278
+ }
3279
+ this.endDragSequence();
3280
+ };
3199
3281
  }
3200
- move(difference) {
3201
- const fromPoint = Point.fromPoint(this.onPointerDownVector.point1).add(difference);
3202
- const toPoint = Point.fromPoint(this.onPointerDownVector.point2).add(difference);
3203
- this.connection.setVector(fromPoint, this.fromConnectorSide, toPoint, this.toConnectorSide);
3204
- this.connection.redraw();
3282
+ checkDragSequenceToStart(event) {
3283
+ const pointerPosition = event.getPosition();
3284
+ if (!this.isDragStarted) {
3285
+ const distanceX = Math.abs(pointerPosition.x - this.dragStartPosition.x);
3286
+ const distanceY = Math.abs(pointerPosition.y - this.dragStartPosition.y);
3287
+ const isOverThreshold = distanceX + distanceY >= this.dragStartThreshold;
3288
+ if (isOverThreshold) {
3289
+ const isDelayElapsed = Date.now() >= this.dragStartTime + this.dragStartDelay;
3290
+ if (!isDelayElapsed) {
3291
+ this.endDragSequence();
3292
+ return;
3293
+ }
3294
+ event.preventDefault();
3295
+ this.prepareDragSequence(event);
3296
+ this.isDragStarted = true;
3297
+ this.moveHandler = this.onPointerMove;
3298
+ if (isTouchEvent(event.originalEvent)) {
3299
+ this.lastTouchEventTime = Date.now();
3300
+ }
3301
+ }
3302
+ }
3205
3303
  }
3304
+ endDragSequence() {
3305
+ this.isDragStarted = false;
3306
+ this.moveHandler = this.checkDragSequenceToStart;
3307
+ this.mouseListeners();
3308
+ this.mouseListeners = EventExtensions.emptyListener();
3309
+ this.touchListeners();
3310
+ this.touchListeners = EventExtensions.emptyListener();
3311
+ this.finalizeDragSequence();
3312
+ }
3313
+ subscribe(document) {
3314
+ if (this.document) {
3315
+ this.unsubscribe();
3316
+ }
3317
+ this.document = document;
3318
+ this.ngZone.runOutsideAngular(() => {
3319
+ document.addEventListener('mousedown', this.onMouseDown, EventExtensions.activeListener());
3320
+ document.addEventListener('touchstart', this.onTouchDown, EventExtensions.passiveListener());
3321
+ });
3322
+ this.startListeners = () => {
3323
+ document.removeEventListener('mousedown', this.onMouseDown, EventExtensions.activeListener());
3324
+ document.removeEventListener('touchstart', this.onTouchDown, EventExtensions.passiveListener());
3325
+ };
3326
+ }
3327
+ unsubscribe() {
3328
+ this.startListeners();
3329
+ this.startListeners = EventExtensions.emptyListener();
3330
+ this.touchListeners();
3331
+ this.touchListeners = EventExtensions.emptyListener();
3332
+ this.mouseListeners();
3333
+ this.mouseListeners = EventExtensions.emptyListener();
3334
+ }
3335
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
3336
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableBase, ngImport: i0 }); }
3337
+ }
3338
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, decorators: [{
3339
+ type: Directive
3340
+ }], ctorParameters: () => [{ type: undefined }] });
3341
+ function isTouchEvent(event) {
3342
+ return event.type[0] === 't';
3343
+ }
3344
+ function isFakeMousedownFromScreenReader(event) {
3345
+ return event.buttons === 0 || (event.offsetX === 0 && event.offsetY === 0);
3346
+ }
3347
+ function isFakeTouchstartFromScreenReader(event) {
3348
+ const touch = (event.touches && event.touches[0]) || (event.changedTouches && event.changedTouches[0]);
3349
+ return (!!touch &&
3350
+ touch.identifier === -1 &&
3351
+ (touch.radiusX == null || touch.radiusX === 1) &&
3352
+ (touch.radiusY == null || touch.radiusY === 1));
3206
3353
  }
3207
3354
 
3208
- class ConnectionSourceDragHandler {
3209
- constructor(getInputRectInFlowHandler, fMediator, connection) {
3210
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3355
+ class FDraggableDirective extends FDraggableBase {
3356
+ get hostElement() {
3357
+ return this.elementReference.nativeElement;
3358
+ }
3359
+ constructor(elementReference, fDraggableDataContext, ngZone, injector, fComponentsStore, fMediator, doc) {
3360
+ super(ngZone);
3361
+ this.elementReference = elementReference;
3362
+ this.fDraggableDataContext = fDraggableDataContext;
3363
+ this.injector = injector;
3364
+ this.fComponentsStore = fComponentsStore;
3211
3365
  this.fMediator = fMediator;
3212
- this.connection = connection;
3213
- this.type = EFDraggableType.CONNECTION;
3214
- this.fromConnectorRect = RectExtensions.initialize();
3215
- this.fromConnectorSide = EFConnectableSide.BOTTOM;
3216
- this.toConnectorRect = RectExtensions.initialize();
3217
- this.toConnectorSide = EFConnectableSide.TOP;
3366
+ this.doc = doc;
3367
+ this.subscriptions$ = new Subscription();
3368
+ this.disabled = false;
3369
+ this.fSelectionChange = new EventEmitter();
3370
+ // @Output()
3371
+ // public override fConnectionIntersectNode: EventEmitter<ConnectionIntersectNodeEvent> = new EventEmitter<ConnectionIntersectNodeEvent>();
3372
+ this.fCreateNode = new EventEmitter();
3373
+ this.fReassignConnection = new EventEmitter();
3374
+ this.fCreateConnection = new EventEmitter();
3218
3375
  }
3219
- initialize() {
3220
- const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3221
- this.fromConnectorRect = fromConnector.rect;
3222
- this.fromConnectorSide = fromConnector.fConnectableSide;
3223
- const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
3224
- this.toConnectorRect = toConnector.rect;
3225
- this.toConnectorSide = toConnector.fConnectableSide;
3376
+ ngOnInit() {
3377
+ this.fComponentsStore.fDraggable = this;
3226
3378
  }
3227
- move(difference) {
3228
- const fromConnectorRect = RectExtensions.addPoint(this.fromConnectorRect, difference);
3229
- const vector = this.fMediator.send(new GetConnectionVectorRequest(fromConnectorRect, this.toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3230
- this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
3231
- this.connection.redraw();
3379
+ ngAfterViewInit() {
3380
+ super.subscribe(this.doc);
3232
3381
  }
3382
+ onPointerDown(event) {
3383
+ this.fDraggableDataContext.reset();
3384
+ let result = event.isMouseLeftButton();
3385
+ this.injector.get(SingleSelectOnPointerDown).handle(event);
3386
+ this.injector.get(ReassignConnectionPrepareDragSequence).handle(event);
3387
+ this.injector.get(CreateConnectionPrepareDragSequence).handle(event);
3388
+ if (!result) {
3389
+ this.finalizeDragSequence();
3390
+ }
3391
+ return result;
3392
+ }
3393
+ prepareDragSequence(event) {
3394
+ this.injector.get(SelectionAreaPrepareDragSequence).handle(event);
3395
+ this.injector.get(NodePrepareDragSequence).handle(event);
3396
+ this.injector.get(CanvasPrepareDragSequence).handle(event);
3397
+ this.injector.get(ExternalItemPrepareDragSequence).handle(event);
3398
+ this.fDraggableDataContext.draggableItems.forEach((item) => {
3399
+ item.initialize?.();
3400
+ });
3401
+ if (this.fDraggableDataContext.draggableItems.length > 0) {
3402
+ this.hostElement.classList.add('f-dragging');
3403
+ }
3404
+ }
3405
+ onPointerMove(event) {
3406
+ const pointerPositionInCanvas = Point.fromPoint(event.getPosition()).elementTransform(this.hostElement);
3407
+ const difference = pointerPositionInCanvas.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3408
+ this.fDraggableDataContext.draggableItems.forEach((item) => {
3409
+ item.move(difference);
3410
+ });
3411
+ }
3412
+ onPointerUp(event) {
3413
+ this.injector.get(ReassignConnectionOnPointerUp).handle(event);
3414
+ this.injector.get(CreateConnectionOnPointerUp).handle(event);
3415
+ this.injector.get(SelectionAreaOnPointerUp).handle(event);
3416
+ this.injector.get(NodeOnPointerUp).handle(event);
3417
+ this.injector.get(CanvasOnPointerUp).handle(event);
3418
+ this.injector.get(ExternalItemOnPointerUp).handle(event);
3419
+ this.hostElement.classList.remove('f-dragging');
3420
+ this.fDraggableDataContext.reset();
3421
+ }
3422
+ finalizeDragSequence() {
3423
+ this.emitSelectionChangeEvent();
3424
+ }
3425
+ emitSelectionChangeEvent() {
3426
+ if (!this.fDraggableDataContext.isSelectedChanged) {
3427
+ return;
3428
+ }
3429
+ const result = this.fMediator.send(new GetSelectionRequest());
3430
+ this.fSelectionChange.emit(result);
3431
+ }
3432
+ ngOnDestroy() {
3433
+ super.unsubscribe();
3434
+ this.subscriptions$.unsubscribe();
3435
+ }
3436
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }, { token: i0.NgZone }, { token: i0.Injector }, { token: FComponentsStore }, { token: FFlowMediator }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive }); }
3437
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableDirective, selector: "f-flow[fDraggable]", inputs: { disabled: ["fDraggableDisabled", "disabled"] }, outputs: { fSelectionChange: "fSelectionChange", fCreateNode: "fCreateNode", fReassignConnection: "fReassignConnection", fCreateConnection: "fCreateConnection" }, providers: [
3438
+ { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3439
+ ], exportAs: ["fDraggable"], usesInheritance: true, ngImport: i0 }); }
3233
3440
  }
3441
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, decorators: [{
3442
+ type: Directive,
3443
+ args: [{
3444
+ selector: "f-flow[fDraggable]",
3445
+ exportAs: 'fDraggable',
3446
+ providers: [
3447
+ { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3448
+ ]
3449
+ }]
3450
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }, { type: i0.NgZone }, { type: i0.Injector }, { type: FComponentsStore }, { type: FFlowMediator }, { type: Document, decorators: [{
3451
+ type: Inject,
3452
+ args: [DOCUMENT]
3453
+ }] }], propDecorators: { disabled: [{
3454
+ type: Input,
3455
+ args: ['fDraggableDisabled']
3456
+ }], fSelectionChange: [{
3457
+ type: Output
3458
+ }], fCreateNode: [{
3459
+ type: Output
3460
+ }], fReassignConnection: [{
3461
+ type: Output
3462
+ }], fCreateConnection: [{
3463
+ type: Output
3464
+ }] } });
3234
3465
 
3235
- class ConnectionTargetDragHandler {
3236
- constructor(getInputRectInFlowHandler, fMediator, connection) {
3237
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3238
- this.fMediator = fMediator;
3239
- this.connection = connection;
3240
- this.type = EFDraggableType.CONNECTION;
3241
- this.fromConnectorRect = RectExtensions.initialize();
3242
- this.fromConnectorSide = EFConnectableSide.BOTTOM;
3243
- this.toConnectorRect = RectExtensions.initialize();
3244
- this.toConnectorSide = EFConnectableSide.TOP;
3466
+ class FSelectionChangeEvent {
3467
+ constructor(nodes, connections) {
3468
+ this.nodes = nodes;
3469
+ this.connections = connections;
3245
3470
  }
3246
- initialize() {
3247
- const fromConnector = this.fMediator.send(new GetOutputRectInFlowRequest(this.connection.fOutputId));
3248
- this.fromConnectorRect = fromConnector.rect;
3249
- this.fromConnectorSide = fromConnector.fConnectableSide;
3250
- const toConnector = this.getInputRectInFlowHandler.handle(this.connection.fInputId);
3251
- this.toConnectorRect = toConnector.rect;
3252
- this.toConnectorSide = toConnector.fConnectableSide;
3471
+ }
3472
+
3473
+ let ClearSelectionHandler = class ClearSelectionHandler {
3474
+ constructor(fDraggableDataContext) {
3475
+ this.fDraggableDataContext = fDraggableDataContext;
3253
3476
  }
3254
- move(difference) {
3255
- const toConnectorRect = RectExtensions.addPoint(this.toConnectorRect, difference);
3256
- const vector = this.fMediator.send(new GetConnectionVectorRequest(this.fromConnectorRect, toConnectorRect, this.connection.fBehavior, this.fromConnectorSide, this.toConnectorSide));
3257
- this.connection.setVector(vector.point1, this.fromConnectorSide, vector.point2, this.toConnectorSide);
3258
- this.connection.redraw();
3477
+ handle(request) {
3478
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3479
+ x.deselect();
3480
+ });
3481
+ this.fDraggableDataContext.selectedItems = [];
3482
+ this.fDraggableDataContext.isSelectedChanged = true;
3483
+ }
3484
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ClearSelectionHandler, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
3485
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ClearSelectionHandler }); }
3486
+ };
3487
+ ClearSelectionHandler = __decorate([
3488
+ FHandlerRegister(ClearSelectionRequest)
3489
+ ], ClearSelectionHandler);
3490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: ClearSelectionHandler, decorators: [{
3491
+ type: Injectable
3492
+ }], ctorParameters: () => [{ type: FDraggableDataContext }] });
3493
+
3494
+ class GetConnectionVectorRequest {
3495
+ constructor(outputRect, inputRect, behavior, outputSide, inputSide) {
3496
+ this.outputRect = outputRect;
3497
+ this.inputRect = inputRect;
3498
+ this.behavior = behavior;
3499
+ this.outputSide = outputSide;
3500
+ this.inputSide = inputSide;
3259
3501
  }
3260
3502
  }
3261
3503
 
3262
- class NodeDragHandler {
3263
- constructor(fDraggableDataContext, fNode) {
3264
- this.fDraggableDataContext = fDraggableDataContext;
3265
- this.fNode = fNode;
3266
- this.type = EFDraggableType.NODE;
3267
- this.onPointerDownPosition = PointExtensions.initialize();
3268
- this.onPointerDownPosition = this.fNode.position;
3504
+ let GetConnectionVectorHandler = class GetConnectionVectorHandler {
3505
+ constructor() {
3506
+ this.behaviorHandlers = {
3507
+ [EFConnectionBehavior.FLOATING.toString()]: this.floatingBehavior,
3508
+ [EFConnectionBehavior.FIXED_CENTER.toString()]: this.fixedCenterBehavior,
3509
+ [EFConnectionBehavior.FIXED.toString()]: this.fixedOutboundBehaviour,
3510
+ };
3269
3511
  }
3270
- move(difference) {
3271
- const position = Point.fromPoint(this.onPointerDownPosition).add(difference);
3272
- this.fNode.updatePosition(position);
3273
- this.fNode.redraw();
3274
- this.fDraggableDataContext.fLineAlignment?.handle(difference);
3512
+ handle(payload) {
3513
+ const result = this.behaviorHandlers[payload.behavior](payload);
3514
+ return result;
3275
3515
  }
3276
- complete() {
3277
- this.fNode.completeDrag();
3516
+ floatingBehavior(payload) {
3517
+ const fromResult = RectExtensions.intersectionWithVector(payload.outputRect, payload.outputRect.gravityCenter, payload.inputRect.gravityCenter);
3518
+ const toResult = RectExtensions.intersectionWithVector(payload.inputRect, payload.outputRect.gravityCenter, payload.inputRect.gravityCenter);
3519
+ return {
3520
+ point1: fromResult ? fromResult[1] : payload.outputRect.gravityCenter,
3521
+ point2: toResult ? toResult[0] : payload.inputRect.gravityCenter,
3522
+ };
3523
+ }
3524
+ fixedCenterBehavior(payload) {
3525
+ return {
3526
+ point1: payload.outputRect.gravityCenter,
3527
+ point2: payload.inputRect.gravityCenter,
3528
+ };
3529
+ }
3530
+ fixedOutboundBehaviour(payload) {
3531
+ const point1 = positionFixedOutbound[payload.outputSide === EFConnectableSide.AUTO ? EFConnectableSide.BOTTOM : payload.outputSide](payload.outputRect);
3532
+ const point2 = positionFixedOutbound[payload.inputSide === EFConnectableSide.AUTO ? EFConnectableSide.TOP : payload.inputSide](payload.inputRect);
3533
+ return {
3534
+ point1: point1,
3535
+ point2: point2,
3536
+ };
3537
+ }
3538
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3539
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler }); }
3540
+ };
3541
+ GetConnectionVectorHandler = __decorate([
3542
+ FHandlerRegister(GetConnectionVectorRequest)
3543
+ ], GetConnectionVectorHandler);
3544
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionVectorHandler, decorators: [{
3545
+ type: Injectable
3546
+ }] });
3547
+ const positionFixedOutbound = {
3548
+ [EFConnectableSide.TOP]: (rect) => {
3549
+ const result = new Point();
3550
+ result.y = rect.y;
3551
+ result.x = rect.x + rect.width / 2;
3552
+ return result;
3553
+ },
3554
+ [EFConnectableSide.BOTTOM]: (rect) => {
3555
+ const result = new Point();
3556
+ result.y = rect.y + rect.height;
3557
+ result.x = rect.x + rect.width / 2;
3558
+ return result;
3559
+ },
3560
+ [EFConnectableSide.LEFT]: (rect) => {
3561
+ const result = new Point();
3562
+ result.x = rect.x;
3563
+ result.y = rect.y + rect.height / 2;
3564
+ return result;
3565
+ },
3566
+ [EFConnectableSide.RIGHT]: (rect) => {
3567
+ const result = new Point();
3568
+ result.x = rect.x + rect.width;
3569
+ result.y = rect.y + rect.height / 2;
3570
+ return result;
3571
+ },
3572
+ };
3573
+
3574
+ class GetElementRectInFlowRequest {
3575
+ constructor(element) {
3576
+ this.element = element;
3278
3577
  }
3279
3578
  }
3280
3579
 
3281
- class NodeOnPointerUp {
3580
+ let GetElementRectInFlowHandler = class GetElementRectInFlowHandler {
3282
3581
  get transform() {
3283
- return this.fComponentsStore.fCanvas.transform;
3582
+ return this.fComponentsStore.transform;
3284
3583
  }
3285
3584
  get flowHost() {
3286
- return this.fComponentsStore.fFlow.hostElement;
3585
+ return this.fComponentsStore.flowHost;
3287
3586
  }
3288
- constructor(fComponentsStore, fDraggableDataContext, isConnectionUnderNodeHandler) {
3587
+ constructor(fComponentsStore) {
3289
3588
  this.fComponentsStore = fComponentsStore;
3290
- this.fDraggableDataContext = fDraggableDataContext;
3291
- this.isConnectionUnderNodeHandler = isConnectionUnderNodeHandler;
3292
3589
  }
3293
- handle(event) {
3294
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3295
- let difference = pointerPositionInFlow.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3296
- const isDragNodes = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.NODE);
3297
- if (isDragNodes) {
3298
- const nearestIntersection = this.fDraggableDataContext.fLineAlignment?.findNearestCoordinate(difference);
3299
- if (nearestIntersection) {
3300
- difference.x = nearestIntersection.xResult.value ? (difference.x - nearestIntersection.xResult.distance) : difference.x;
3301
- difference.y = nearestIntersection.yResult.value ? (difference.y - nearestIntersection.yResult.distance) : difference.y;
3302
- }
3303
- this.fDraggableDataContext.draggableItems.forEach((x) => {
3304
- x.move(difference);
3305
- x.complete?.();
3306
- });
3307
- this.isConnectionUnderNodeHandler.handle();
3308
- this.fDraggableDataContext.fLineAlignment?.complete();
3309
- }
3590
+ handle(request) {
3591
+ const systemRect = RectExtensions.fromElement(request.element);
3592
+ const position = Point.fromPoint(systemRect).elementTransform(this.flowHost).sub(this.transform.scaledPosition).sub(this.transform.position).div(this.transform.scale);
3593
+ const size = SizeExtensions.initialize(systemRect.width / this.transform.scale, systemRect.height / this.transform.scale);
3594
+ const result = RectExtensions.initialize(position.x, position.y, size.width, size.height);
3595
+ return result;
3310
3596
  }
3311
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: IsConnectionUnderNodeHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3312
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp }); }
3313
- }
3314
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodeOnPointerUp, decorators: [{
3597
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3598
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler }); }
3599
+ };
3600
+ GetElementRectInFlowHandler = __decorate([
3601
+ FHandlerRegister(GetElementRectInFlowRequest)
3602
+ ], GetElementRectInFlowHandler);
3603
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetElementRectInFlowHandler, decorators: [{
3315
3604
  type: Injectable
3316
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: IsConnectionUnderNodeHandler }] });
3605
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3317
3606
 
3318
- class NodePrepareDragSequence {
3319
- get transform() {
3320
- return this.fComponentsStore.fCanvas.transform;
3607
+ class GetInputRectInFlowRequest {
3608
+ constructor(fInputId) {
3609
+ this.fInputId = fInputId;
3321
3610
  }
3322
- get flowHost() {
3323
- return this.fComponentsStore.fFlow.hostElement;
3611
+ }
3612
+
3613
+ class GetInputRectInFlowResponse {
3614
+ constructor(rect, fConnectableSide) {
3615
+ this.rect = rect;
3616
+ this.fConnectableSide = fConnectableSide;
3324
3617
  }
3325
- constructor(fComponentsStore, fDraggableDataContext, updateNodeLayerHandler, getInputRectInFlowHandler, getOutgoingConnectionsHandler, getIncomingConnectionsHandler, fMediator) {
3618
+ }
3619
+
3620
+ let GetInputRectInFlowHandler = class GetInputRectInFlowHandler {
3621
+ constructor(fComponentsStore, fMediator) {
3326
3622
  this.fComponentsStore = fComponentsStore;
3327
- this.fDraggableDataContext = fDraggableDataContext;
3328
- this.updateNodeLayerHandler = updateNodeLayerHandler;
3329
- this.getInputRectInFlowHandler = getInputRectInFlowHandler;
3330
- this.getOutgoingConnectionsHandler = getOutgoingConnectionsHandler;
3331
- this.getIncomingConnectionsHandler = getIncomingConnectionsHandler;
3332
3623
  this.fMediator = fMediator;
3333
3624
  }
3334
- handle(event) {
3335
- const node = this.fComponentsStore.findNode(event.targetElement);
3336
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.flowHost);
3337
- if (node && !node.disabled && !this.fDraggableDataContext.draggableItems.length) {
3338
- if (isNodeDragHandle(event.targetElement)) {
3339
- if (!this.fDraggableDataContext.selectedItems.includes(node)) {
3340
- this.fDraggableDataContext.selectedItems.push(node);
3341
- node.select();
3342
- this.fDraggableDataContext.isSelectedChanged = true;
3343
- }
3344
- this.updateNodeLayerHandler.handle(node);
3345
- const itemsToDrag = this.calculateDraggableConnectionsAndNodes();
3346
- const draggedNodes = itemsToDrag.filter((x) => {
3347
- return x.type === EFDraggableType.NODE;
3348
- }).map((x) => x.fNode);
3349
- this.fDraggableDataContext.fLineAlignment?.initialize(this.fComponentsStore.fNodes, draggedNodes);
3350
- this.fDraggableDataContext.onPointerDownScale = this.transform.scale;
3351
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(this.transform.scale);
3352
- this.fDraggableDataContext.draggableItems = itemsToDrag;
3353
- }
3625
+ handle(request) {
3626
+ const input = this.fComponentsStore.fInputs.find((x) => x.id === request.fInputId);
3627
+ if (!input) {
3628
+ throw InputNotFound(request.fInputId);
3354
3629
  }
3630
+ const result = this.fMediator.send(new GetElementRectInFlowRequest(input.hostElement));
3631
+ return new GetInputRectInFlowResponse(result, input.fConnectableSide);
3355
3632
  }
3356
- calculateDraggableConnectionsAndNodes() {
3357
- let itemsToDrag = [];
3358
- const selectedNodes = this.fDraggableDataContext.selectedItems.map((x) => {
3359
- return this.fComponentsStore.findNode(x.hostElement);
3360
- }).filter((x) => !!x);
3361
- const nodeDragHandlers = selectedNodes.map((x) => new NodeDragHandler(this.fDraggableDataContext, x));
3362
- itemsToDrag = nodeDragHandlers;
3363
- const allOutputIds = selectedNodes.reduce((result, x) => {
3364
- return result.concat(this.getOutputsForNode(x));
3365
- }, []).map((x) => x.id);
3366
- const allInputIds = selectedNodes.reduce((result, x) => {
3367
- return result.concat(this.getInputsForNode(x));
3368
- }, []).map((x) => x.id);
3369
- nodeDragHandlers.forEach((nodeHandler) => {
3370
- const outputConnections = this.getOutgoingConnectionsHandler.handle(this.getOutputsForNode(nodeHandler.fNode));
3371
- outputConnections.forEach((c) => {
3372
- if (allInputIds.includes(c.fInputId)) {
3373
- itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3374
- }
3375
- else {
3376
- itemsToDrag.push(new ConnectionSourceDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3377
- }
3378
- });
3379
- const inputConnections = this.getIncomingConnectionsHandler.handle(this.getInputsForNode(nodeHandler.fNode));
3380
- inputConnections.forEach((c) => {
3381
- if (allOutputIds.includes(c.fOutputId)) {
3382
- const index = itemsToDrag.findIndex((x) => x.type === EFDraggableType.CONNECTION && x.connection.fConnectionId === c.fConnectionId);
3383
- if (index !== -1) {
3384
- itemsToDrag.push(new ConnectionDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3385
- }
3386
- }
3387
- else {
3388
- itemsToDrag.push(new ConnectionTargetDragHandler(this.getInputRectInFlowHandler, this.fMediator, c));
3389
- }
3390
- });
3633
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3634
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler }); }
3635
+ };
3636
+ GetInputRectInFlowHandler = __decorate([
3637
+ FHandlerRegister(GetInputRectInFlowRequest)
3638
+ ], GetInputRectInFlowHandler);
3639
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetInputRectInFlowHandler, decorators: [{
3640
+ type: Injectable
3641
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FFlowMediator }] });
3642
+
3643
+ class GetNodesRectRequest {
3644
+ }
3645
+
3646
+ let GetNodesRectHandler = class GetNodesRectHandler {
3647
+ constructor(fComponentsStore) {
3648
+ this.fComponentsStore = fComponentsStore;
3649
+ }
3650
+ handle(request) {
3651
+ const fNodes = this.fComponentsStore.fNodes;
3652
+ const rects = fNodes.map((x) => {
3653
+ return RectExtensions.fromElement(x.hostElement);
3391
3654
  });
3392
- return itemsToDrag;
3655
+ const result = RectExtensions.union(rects);
3656
+ return result;
3393
3657
  }
3394
- getInputsForNode(node) {
3395
- return this.fComponentsStore.fInputs.filter((x) => node.isContains(x.hostElement));
3658
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetNodesRectHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3659
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetNodesRectHandler }); }
3660
+ };
3661
+ GetNodesRectHandler = __decorate([
3662
+ FHandlerRegister(GetNodesRectRequest)
3663
+ ], GetNodesRectHandler);
3664
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetNodesRectHandler, decorators: [{
3665
+ type: Injectable
3666
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3667
+
3668
+ class GetOutputRectInFlowRequest {
3669
+ constructor(fOutputId) {
3670
+ this.fOutputId = fOutputId;
3396
3671
  }
3397
- getOutputsForNode(node) {
3398
- return this.fComponentsStore.fOutputs.filter((x) => node.isContains(x.hostElement));
3672
+ }
3673
+
3674
+ class GetOutputRectInFlowResponse {
3675
+ constructor(rect, fConnectableSide) {
3676
+ this.rect = rect;
3677
+ this.fConnectableSide = fConnectableSide;
3399
3678
  }
3400
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: UpdateNodeLayerHandler }, { token: GetInputRectInFlowHandler }, { token: GetOutgoingConnectionsHandler }, { token: GetIncomingConnectionsHandler }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3401
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence }); }
3402
3679
  }
3403
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: NodePrepareDragSequence, decorators: [{
3680
+
3681
+ let GetOutputRectInFlowHandler = class GetOutputRectInFlowHandler {
3682
+ constructor(fComponentsStore, fMediator) {
3683
+ this.fComponentsStore = fComponentsStore;
3684
+ this.fMediator = fMediator;
3685
+ }
3686
+ handle(request) {
3687
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === request.fOutputId);
3688
+ if (!output) {
3689
+ throw OutputNotFound(request.fOutputId);
3690
+ }
3691
+ const result = this.fMediator.send(new GetElementRectInFlowRequest(output.hostElement));
3692
+ return new GetOutputRectInFlowResponse(result, output.fConnectableSide);
3693
+ }
3694
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, deps: [{ token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3695
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler }); }
3696
+ };
3697
+ GetOutputRectInFlowHandler = __decorate([
3698
+ FHandlerRegister(GetOutputRectInFlowRequest)
3699
+ ], GetOutputRectInFlowHandler);
3700
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutputRectInFlowHandler, decorators: [{
3404
3701
  type: Injectable
3405
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: UpdateNodeLayerHandler }, { type: GetInputRectInFlowHandler }, { type: GetOutgoingConnectionsHandler }, { type: GetIncomingConnectionsHandler }, { type: FFlowMediator }] });
3702
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FFlowMediator }] });
3406
3703
 
3407
- const NODE_PROVIDERS = [
3408
- NodeOnPointerUp,
3409
- NodePrepareDragSequence,
3410
- IsConnectionUnderNodeHandler
3411
- ];
3704
+ class GetSelectionRequest {
3705
+ }
3412
3706
 
3413
- class GetCanBeSelectedItemsHandler {
3414
- get fNodes() {
3415
- return this.fComponentsStore.fNodes;
3707
+ let GetSelectionHandler = class GetSelectionHandler {
3708
+ constructor(fDraggableDataContext) {
3709
+ this.fDraggableDataContext = fDraggableDataContext;
3416
3710
  }
3417
- get fConnections() {
3418
- return this.fComponentsStore.fConnections;
3711
+ handle() {
3712
+ let selectedNodes = [];
3713
+ let selectedConnections = [];
3714
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3715
+ if (x.hostElement.classList.contains('f-node')) {
3716
+ selectedNodes.push(x.hostElement.dataset['fNodeId']);
3717
+ }
3718
+ else {
3719
+ selectedConnections.push(x.hostElement.id);
3720
+ }
3721
+ });
3722
+ return new FSelectionChangeEvent(selectedNodes, selectedConnections);
3419
3723
  }
3420
- get transform() {
3421
- return this.fComponentsStore.fCanvas.transform;
3724
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetSelectionHandler, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
3725
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetSelectionHandler }); }
3726
+ };
3727
+ GetSelectionHandler = __decorate([
3728
+ FHandlerRegister(GetSelectionRequest)
3729
+ ], GetSelectionHandler);
3730
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetSelectionHandler, decorators: [{
3731
+ type: Injectable
3732
+ }], ctorParameters: () => [{ type: FDraggableDataContext }] });
3733
+
3734
+ class RedrawConnectionsRequest {
3735
+ constructor() {
3422
3736
  }
3423
- constructor(fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
3737
+ }
3738
+
3739
+ let RedrawConnectionsHandler = class RedrawConnectionsHandler {
3740
+ constructor(fComponentsStore, fMediator) {
3424
3741
  this.fComponentsStore = fComponentsStore;
3425
- this.fDraggableDataContext = fDraggableDataContext;
3426
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
3742
+ this.fMediator = fMediator;
3427
3743
  }
3428
- handle() {
3429
- const nodeRects = this.getNodesWithRects();
3430
- const lineRects = this.getConnectionsWithRects();
3431
- const result = [...nodeRects, ...lineRects].filter((x) => {
3432
- return !this.fDraggableDataContext.selectedItems.includes(x.element);
3744
+ handle(request) {
3745
+ this.resetConnectors();
3746
+ this.fComponentsStore.fTempConnection?.setMarkers();
3747
+ this.fComponentsStore.fConnections.forEach((connection) => {
3748
+ const output = this.fComponentsStore.fOutputs.find((x) => x.id === connection.fOutputId);
3749
+ const input = this.fComponentsStore.fInputs.find((x) => x.id === connection.fInputId);
3750
+ if (output && input) {
3751
+ this.setupConnection(output, input, connection);
3752
+ }
3433
3753
  });
3434
- return result;
3435
3754
  }
3436
- getNodesWithRects() {
3437
- return this.fNodes.map((x) => {
3438
- const rect = this.getElementRectInFlowHandler.handle(x.hostElement);
3439
- return {
3440
- element: x,
3441
- rect: RectExtensions.mult(rect, this.transform.scale)
3442
- };
3443
- });
3755
+ resetConnectors() {
3756
+ this.fComponentsStore.fOutputs.forEach((output) => output.setConnected(false));
3757
+ this.fComponentsStore.fInputs.forEach((input) => input.setConnected(false));
3444
3758
  }
3445
- getConnectionsWithRects() {
3446
- return this.fConnections.map((x) => {
3447
- const rect = this.getElementRectInFlowHandler.handle(x.boundingElement);
3448
- return {
3449
- element: x,
3450
- rect: RectExtensions.mult(rect, this.transform.scale)
3451
- };
3452
- });
3759
+ setupConnection(output, input, connection) {
3760
+ output.setConnected(true);
3761
+ input.setConnected(true);
3762
+ const vector = this.getVector(output, input, connection);
3763
+ connection.setVector(vector.point1, output.fConnectableSide, vector.point2, input.fConnectableSide);
3764
+ connection.setMarkers();
3765
+ connection.initialize();
3453
3766
  }
3454
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3455
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler }); }
3456
- }
3457
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetCanBeSelectedItemsHandler, decorators: [{
3767
+ getVector(output, input, connection) {
3768
+ const outputRect = this.fMediator.send(new GetElementRectInFlowRequest(output.hostElement));
3769
+ const inputRect = this.fMediator.send(new GetElementRectInFlowRequest(input.hostElement));
3770
+ return this.fMediator.send(new GetConnectionVectorRequest(outputRect, inputRect, connection.fBehavior, output.fConnectableSide, input.fConnectableSide));
3771
+ }
3772
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, deps: [{ token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Injectable }); }
3773
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler }); }
3774
+ };
3775
+ RedrawConnectionsHandler = __decorate([
3776
+ FHandlerRegister(RedrawConnectionsRequest)
3777
+ ], RedrawConnectionsHandler);
3778
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: RedrawConnectionsHandler, decorators: [{
3458
3779
  type: Injectable
3459
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
3780
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FFlowMediator }] });
3460
3781
 
3461
- class SelectionAreaDragHandle {
3462
- get canvasPosition() {
3463
- return Point.fromPoint(this.fComponentsStore.fCanvas.transform.position).add(this.fComponentsStore.fCanvas.transform.scaledPosition);
3464
- }
3465
- constructor(fComponentsStore, fDraggableDataContext, injector) {
3466
- this.fComponentsStore = fComponentsStore;
3782
+ class SelectAllRequest {
3783
+ }
3784
+
3785
+ let SelectAllHandler = class SelectAllHandler {
3786
+ constructor(fDataContext, fDraggableDataContext) {
3787
+ this.fDataContext = fDataContext;
3467
3788
  this.fDraggableDataContext = fDraggableDataContext;
3468
- this.injector = injector;
3469
- this.type = EFDraggableType.SELECTION;
3470
- this.canBeSelected = [];
3471
- this.selectedByMove = [];
3472
3789
  }
3473
- initialize() {
3474
- this.canBeSelected = this.injector.get(GetCanBeSelectedItemsHandler).handle();
3475
- this.fDraggableDataContext.fSelectionArea?.show();
3476
- this.fDraggableDataContext.fSelectionArea?.draw({
3477
- left: this.fDraggableDataContext.onPointerDownPosition.x,
3478
- top: this.fDraggableDataContext.onPointerDownPosition.y,
3479
- width: 0,
3480
- height: 0
3790
+ handle(request) {
3791
+ this.fDraggableDataContext.selectedItems.forEach((x) => {
3792
+ x.deselect();
3481
3793
  });
3482
- }
3483
- move(difference) {
3484
- const currentPoint = Point.fromPoint(difference).add(this.fDraggableDataContext.onPointerDownPosition);
3485
- const x = Math.min(this.fDraggableDataContext.onPointerDownPosition.x, currentPoint.x);
3486
- const y = Math.min(this.fDraggableDataContext.onPointerDownPosition.y, currentPoint.y);
3487
- const width = Math.abs(difference.x);
3488
- const height = Math.abs(difference.y);
3489
- this.fDraggableDataContext.fSelectionArea?.draw({ left: x, top: y, width, height });
3490
- this.selectedByMove = [];
3491
- this.canBeSelected.forEach((item) => {
3492
- item.element.deselect();
3493
- const itemRect = RectExtensions.addPoint(item.rect, this.canvasPosition);
3494
- const isIntersect = RectExtensions.intersectionWithRect(itemRect, RectExtensions.initialize(x, y, width, height));
3495
- if (isIntersect) {
3496
- item.element.select();
3497
- this.selectedByMove.push(item.element);
3498
- }
3794
+ this.fDraggableDataContext.selectedItems = [];
3795
+ this.fDataContext.fNodes.forEach((x) => {
3796
+ x.select();
3797
+ this.fDraggableDataContext.selectedItems.push(x);
3499
3798
  });
3799
+ this.fDataContext.fConnections.forEach((x) => {
3800
+ x.select();
3801
+ this.fDraggableDataContext.selectedItems.push(x);
3802
+ });
3803
+ this.fDraggableDataContext.isSelectedChanged = true;
3500
3804
  }
3501
- complete() {
3502
- this.fDraggableDataContext.fSelectionArea?.hide();
3503
- this.fDraggableDataContext.selectedItems.push(...this.selectedByMove);
3504
- if (this.selectedByMove.length > 0) {
3505
- this.fDraggableDataContext.isSelectedChanged = true;
3506
- }
3507
- }
3508
- }
3805
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
3806
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler }); }
3807
+ };
3808
+ SelectAllHandler = __decorate([
3809
+ FHandlerRegister(SelectAllRequest)
3810
+ ], SelectAllHandler);
3811
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectAllHandler, decorators: [{
3812
+ type: Injectable
3813
+ }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }] });
3509
3814
 
3510
- class SelectionAreaPrepareDragSequence {
3511
- get fFlow() {
3512
- return this.fComponentsStore.fFlow;
3815
+ class GetConnectionHandler {
3816
+ get fConnections() {
3817
+ return this.fComponentsStore.fConnections;
3513
3818
  }
3514
- constructor(fComponentsStore, fDraggableDataContext, injector) {
3819
+ constructor(fComponentsStore) {
3515
3820
  this.fComponentsStore = fComponentsStore;
3516
- this.fDraggableDataContext = fDraggableDataContext;
3517
- this.injector = injector;
3518
3821
  }
3519
- handle(event) {
3520
- const pointerPositionInFlow = Point.fromPoint(event.getPosition()).elementTransform(this.fFlow.hostElement);
3521
- if (MouseEventExtensions.isShiftPressed(event.originalEvent) && this.fDraggableDataContext.fSelectionArea) {
3522
- this.fDraggableDataContext.draggableItems = [
3523
- new SelectionAreaDragHandle(this.fComponentsStore, this.fDraggableDataContext, this.injector)
3524
- ];
3525
- this.fDraggableDataContext.onPointerDownScale = 1;
3526
- this.fDraggableDataContext.onPointerDownPosition = pointerPositionInFlow.div(1);
3527
- }
3822
+ handle(element) {
3823
+ const result = this.fConnections.find(c => c.isContains(element));
3824
+ return result;
3528
3825
  }
3529
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
3530
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence }); }
3826
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3827
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler }); }
3531
3828
  }
3532
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaPrepareDragSequence, decorators: [{
3829
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetConnectionHandler, decorators: [{
3533
3830
  type: Injectable
3534
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: i0.Injector }] });
3831
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3535
3832
 
3536
- class SelectionAreaOnPointerUp {
3537
- constructor(fDraggableDataContext) {
3538
- this.fDraggableDataContext = fDraggableDataContext;
3833
+ class GetIncomingConnectionsHandler {
3834
+ get fConnections() {
3835
+ return this.fComponentsStore.fConnections;
3539
3836
  }
3540
- handle(event) {
3541
- const isSelection = this.fDraggableDataContext.draggableItems.some((x) => x.type === EFDraggableType.SELECTION);
3542
- if (isSelection) {
3543
- this.fDraggableDataContext.draggableItems.forEach((x) => {
3544
- x.complete?.();
3545
- });
3546
- }
3837
+ constructor(fComponentsStore) {
3838
+ this.fComponentsStore = fComponentsStore;
3547
3839
  }
3548
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp, deps: [{ token: FDraggableDataContext }], target: i0.ɵɵFactoryTarget.Injectable }); }
3549
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp }); }
3840
+ handle(inputs) {
3841
+ const inputsIds = inputs.map((x) => x.id);
3842
+ return this.fConnections.filter((x) => {
3843
+ return inputsIds.includes(x.fInputId);
3844
+ });
3845
+ }
3846
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3847
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler }); }
3550
3848
  }
3551
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SelectionAreaOnPointerUp, decorators: [{
3849
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetIncomingConnectionsHandler, decorators: [{
3552
3850
  type: Injectable
3553
- }], ctorParameters: () => [{ type: FDraggableDataContext }] });
3554
-
3555
- const SELECTION_AREA_PROVIDERS = [
3556
- GetCanBeSelectedItemsHandler,
3557
- SelectionAreaPrepareDragSequence,
3558
- SelectionAreaOnPointerUp,
3559
- ];
3851
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3560
3852
 
3561
- class SingleSelectOnPointerDown {
3562
- constructor(fComponentsStore, fDraggableDataContext, getConnectionHandler, updateConnectionLayerHandler) {
3563
- this.fComponentsStore = fComponentsStore;
3564
- this.fDraggableDataContext = fDraggableDataContext;
3565
- this.getConnectionHandler = getConnectionHandler;
3566
- this.updateConnectionLayerHandler = updateConnectionLayerHandler;
3567
- }
3568
- handle(event) {
3569
- if (!this.fComponentsStore.fFlow?.hostElement.contains(event.targetElement)) {
3570
- return;
3571
- }
3572
- const node = this.fComponentsStore.findNode(event.targetElement);
3573
- const connection = this.getConnectionHandler.handle(event.targetElement);
3574
- this.deselectAll(node, event);
3575
- let element;
3576
- if (this.fDraggableDataContext.selectedItems.length) {
3577
- element = this.fDraggableDataContext.selectedItems[0];
3578
- }
3579
- this.resetSelectionIfNotMultiselect(event);
3580
- if (node) {
3581
- if (!this.fDraggableDataContext.selectedItems.includes(node)) {
3582
- this.fDraggableDataContext.selectedItems.push(node);
3583
- if (element?.hostElement.id !== node.hostElement.id) {
3584
- this.fDraggableDataContext.isSelectedChanged = true;
3585
- }
3586
- }
3587
- else {
3588
- this.fDraggableDataContext.selectedItems.splice(this.fDraggableDataContext.selectedItems.indexOf(node), 1);
3589
- }
3590
- }
3591
- else if (connection) {
3592
- this.updateConnectionLayerHandler.handle(connection);
3593
- if (!this.fDraggableDataContext.selectedItems.includes(connection)) {
3594
- this.fDraggableDataContext.selectedItems.push(connection);
3595
- if (element?.hostElement.id !== connection.hostElement.id) {
3596
- this.fDraggableDataContext.isSelectedChanged = true;
3597
- }
3598
- }
3599
- else {
3600
- this.fDraggableDataContext.selectedItems.splice(this.fDraggableDataContext.selectedItems.indexOf(connection), 1);
3601
- }
3602
- }
3603
- this.selectIfNotSelected();
3604
- }
3605
- deselectAll(node, event) {
3606
- this.fDraggableDataContext.selectedItems.forEach((x) => {
3607
- if (x !== node || (!isNodeOutlet(event.targetElement) && !isNodeOutput(event.targetElement))) {
3608
- x.deselect();
3609
- }
3610
- });
3853
+ class GetOutgoingConnectionsHandler {
3854
+ get fConnections() {
3855
+ return this.fComponentsStore.fConnections;
3611
3856
  }
3612
- resetSelectionIfNotMultiselect(event) {
3613
- const isMultiselect = MouseEventExtensions.isCommandButton(event.originalEvent) ||
3614
- MouseEventExtensions.isShiftPressed(event.originalEvent);
3615
- if (!isMultiselect) {
3616
- this.fDraggableDataContext.selectedItems = [];
3617
- }
3857
+ constructor(fComponentsStore) {
3858
+ this.fComponentsStore = fComponentsStore;
3618
3859
  }
3619
- selectIfNotSelected() {
3620
- this.fDraggableDataContext.selectedItems.forEach((x) => {
3621
- if (!x.isSelected()) {
3622
- x.select();
3623
- }
3860
+ handle(outputs) {
3861
+ const outputsIds = outputs.map((x) => x.id);
3862
+ return this.fConnections.filter((x) => {
3863
+ return outputsIds.includes(x.fOutputId);
3624
3864
  });
3625
3865
  }
3626
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown, deps: [{ token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetConnectionHandler }, { token: UpdateConnectionLayerHandler }], target: i0.ɵɵFactoryTarget.Injectable }); }
3627
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown }); }
3866
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3867
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler }); }
3628
3868
  }
3629
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: SingleSelectOnPointerDown, decorators: [{
3869
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: GetOutgoingConnectionsHandler, decorators: [{
3630
3870
  type: Injectable
3631
- }], ctorParameters: () => [{ type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetConnectionHandler }, { type: UpdateConnectionLayerHandler }] });
3632
-
3633
- const SINGLE_SELECT_PROVIDERS = [
3634
- SingleSelectOnPointerDown
3635
- ];
3636
-
3637
- class FSelectionChangeEvent {
3638
- constructor(nodes, connections) {
3639
- this.nodes = nodes;
3640
- this.connections = connections;
3641
- }
3642
- }
3871
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3643
3872
 
3644
- const MOUSE_EVENT_IGNORE_TIME = 800;
3645
- class IDragAndDropBase {
3646
- isSyntheticEvent(event) {
3647
- const isSyntheticEvent = !!this.lastTouchEventTime &&
3648
- (this.lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now());
3649
- return isSyntheticEvent;
3650
- }
3651
- constructor(ngZone) {
3652
- this.ngZone = ngZone;
3653
- this.mouseListeners = EventExtensions.emptyListener();
3654
- this.touchListeners = EventExtensions.emptyListener();
3655
- this.startListeners = EventExtensions.emptyListener();
3656
- this.lastTouchEventTime = 0;
3657
- this.isDragStarted = false;
3658
- this.dragStartThreshold = 5;
3659
- this.dragStartDelay = 0;
3660
- this.dragStartTime = 0;
3661
- this.dragStartPosition = PointExtensions.initialize();
3662
- this.moveHandler = this.checkDragSequenceToStart;
3663
- this.onMouseDown = (event) => {
3664
- const isSyntheticEvent = this.isSyntheticEvent(event);
3665
- const isFakeEvent = isFakeMousedownFromScreenReader(event);
3666
- const mouseEvent = new IMouseEvent(event);
3667
- if (isSyntheticEvent || isFakeEvent || this.disabled) {
3668
- return;
3669
- }
3670
- let result = this.onPointerDown(mouseEvent);
3671
- if (result) {
3672
- this.dragStartTime = Date.now();
3673
- this.dragStartPosition = mouseEvent.getPosition();
3674
- this.ngZone.runOutsideAngular(() => {
3675
- this.element.addEventListener('mousemove', this.onMouseMove);
3676
- this.element.addEventListener('mouseup', this.onMouseUp);
3677
- });
3678
- this.mouseListeners = () => {
3679
- this.element.removeEventListener('mousemove', this.onMouseMove);
3680
- this.element.removeEventListener('mouseup', this.onMouseUp);
3681
- };
3682
- }
3683
- };
3684
- this.onTouchDown = (event) => {
3685
- const isFakeEvent = isFakeTouchstartFromScreenReader(event);
3686
- const touchEvent = new ITouchDownEvent(event);
3687
- if (isFakeEvent || this.disabled) {
3688
- return;
3689
- }
3690
- let result = this.onPointerDown(new ITouchDownEvent(event));
3691
- if (result) {
3692
- this.dragStartTime = Date.now();
3693
- this.dragStartPosition = touchEvent.getPosition();
3694
- this.ngZone.runOutsideAngular(() => {
3695
- this.element.addEventListener('touchmove', this.onTouchMove);
3696
- this.element.addEventListener('touchend', this.onTouchUp);
3697
- });
3698
- this.touchListeners = () => {
3699
- this.element.removeEventListener('touchmove', this.onTouchMove);
3700
- this.element.removeEventListener('touchend', this.onTouchUp);
3701
- };
3702
- }
3703
- };
3704
- this.onMouseMove = (event) => {
3705
- this.moveHandler(new IMouseEvent(event));
3706
- };
3707
- this.onTouchMove = (event) => {
3708
- this.moveHandler(new ITouchMoveEvent(event));
3709
- };
3710
- this.onMouseUp = (event) => {
3711
- if (this.isDragStarted) {
3712
- this.onPointerUp(new IMouseEvent(event));
3713
- }
3714
- this.endDragSequence();
3715
- };
3716
- this.onTouchUp = (event) => {
3717
- if (this.isDragStarted) {
3718
- this.onPointerUp(new ITouchUpEvent(event));
3719
- }
3720
- this.endDragSequence();
3721
- };
3722
- }
3723
- checkDragSequenceToStart(event) {
3724
- const pointerPosition = event.getPosition();
3725
- if (!this.isDragStarted) {
3726
- const distanceX = Math.abs(pointerPosition.x - this.dragStartPosition.x);
3727
- const distanceY = Math.abs(pointerPosition.y - this.dragStartPosition.y);
3728
- const isOverThreshold = distanceX + distanceY >= this.dragStartThreshold;
3729
- if (isOverThreshold) {
3730
- const isDelayElapsed = Date.now() >= this.dragStartTime + this.dragStartDelay;
3731
- if (!isDelayElapsed) {
3732
- this.endDragSequence();
3733
- return;
3734
- }
3735
- event.preventDefault();
3736
- this.prepareDragSequence(event);
3737
- this.isDragStarted = true;
3738
- this.moveHandler = this.onPointerMove;
3739
- if (isTouchEvent(event.originalEvent)) {
3740
- this.lastTouchEventTime = Date.now();
3741
- }
3742
- }
3743
- }
3873
+ class UpdateNodeLayerHandler {
3874
+ get fNodesContainer() {
3875
+ return this.fComponentsStore.fCanvas?.fNodesContainer?.nativeElement;
3744
3876
  }
3745
- endDragSequence() {
3746
- this.isDragStarted = false;
3747
- this.moveHandler = this.checkDragSequenceToStart;
3748
- this.mouseListeners();
3749
- this.mouseListeners = EventExtensions.emptyListener();
3750
- this.touchListeners();
3751
- this.touchListeners = EventExtensions.emptyListener();
3877
+ constructor(fComponentsStore) {
3878
+ this.fComponentsStore = fComponentsStore;
3752
3879
  }
3753
- subscribe(elementToSubscribe) {
3754
- if (this.element) {
3755
- this.unsubscribe();
3880
+ handle(node) {
3881
+ const elements = Array.from(this.fNodesContainer.children);
3882
+ const elementsCount = elements.length;
3883
+ const targetIndex = elements.findIndex((x) => x === node.hostElement);
3884
+ if (targetIndex !== elementsCount - 1) {
3885
+ const afterElements = elements.splice(targetIndex + 1);
3886
+ afterElements.forEach((x) => {
3887
+ this.fNodesContainer.removeChild(x);
3888
+ this.fNodesContainer.insertBefore(x, node.hostElement);
3889
+ });
3756
3890
  }
3757
- this.element = elementToSubscribe;
3758
- this.ngZone.runOutsideAngular(() => {
3759
- this.element.addEventListener('mousedown', this.onMouseDown, EventExtensions.activeListener());
3760
- this.element.addEventListener('touchstart', this.onTouchDown, EventExtensions.passiveListener());
3761
- });
3762
- this.startListeners = () => {
3763
- this.element.removeEventListener('mousedown', this.onMouseDown, EventExtensions.activeListener());
3764
- this.element.removeEventListener('touchstart', this.onTouchDown, EventExtensions.passiveListener());
3765
- };
3766
- }
3767
- unsubscribe() {
3768
- this.startListeners();
3769
- this.startListeners = EventExtensions.emptyListener();
3770
- this.touchListeners();
3771
- this.touchListeners = EventExtensions.emptyListener();
3772
- this.mouseListeners();
3773
- this.mouseListeners = EventExtensions.emptyListener();
3774
3891
  }
3892
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3893
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler }); }
3775
3894
  }
3776
- function isTouchEvent(event) {
3777
- return event.type[0] === 't';
3778
- }
3779
- function isFakeMousedownFromScreenReader(event) {
3780
- return event.buttons === 0 || (event.offsetX === 0 && event.offsetY === 0);
3781
- }
3782
- function isFakeTouchstartFromScreenReader(event) {
3783
- const touch = (event.touches && event.touches[0]) || (event.changedTouches && event.changedTouches[0]);
3784
- return (!!touch &&
3785
- touch.identifier === -1 &&
3786
- (touch.radiusX == null || touch.radiusX === 1) &&
3787
- (touch.radiusY == null || touch.radiusY === 1));
3788
- }
3895
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateNodeLayerHandler, decorators: [{
3896
+ type: Injectable
3897
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3789
3898
 
3790
- const F_DRAGGABLE = new InjectionToken('F_DRAGGABLE');
3791
- class FDraggableBase extends IDragAndDropBase {
3792
- constructor(ngZone) {
3793
- super(ngZone);
3899
+ class UpdateConnectionLayerHandler {
3900
+ get fConnectionsContainer() {
3901
+ return this.fComponentsStore.fCanvas?.fConnectionsContainer?.nativeElement;
3902
+ }
3903
+ constructor(fComponentsStore) {
3904
+ this.fComponentsStore = fComponentsStore;
3905
+ }
3906
+ handle(connection) {
3907
+ const elements = Array.from(this.fConnectionsContainer.children);
3908
+ const elementsCount = elements.length;
3909
+ const targetIndex = elements.findIndex((x) => x === connection.hostElement);
3910
+ if (targetIndex !== elementsCount - 1) {
3911
+ const afterElements = elements.splice(targetIndex + 1);
3912
+ afterElements.forEach((x) => {
3913
+ this.fConnectionsContainer.removeChild(x);
3914
+ this.fConnectionsContainer.insertBefore(x, connection.hostElement);
3915
+ });
3916
+ }
3794
3917
  }
3795
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
3796
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableBase, usesInheritance: true, ngImport: i0 }); }
3918
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler, deps: [{ token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
3919
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler }); }
3797
3920
  }
3798
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableBase, decorators: [{
3799
- type: Directive
3800
- }], ctorParameters: () => [{ type: i0.NgZone }] });
3921
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: UpdateConnectionLayerHandler, decorators: [{
3922
+ type: Injectable
3923
+ }], ctorParameters: () => [{ type: FComponentsStore }] });
3801
3924
 
3802
- class FDraggableDirective extends FDraggableBase {
3925
+ const COMMON_PROVIDERS = [
3926
+ ClearSelectionHandler,
3927
+ GetConnectionVectorHandler,
3928
+ GetElementRectInFlowHandler,
3929
+ GetNodesRectHandler,
3930
+ GetOutputRectInFlowHandler,
3931
+ GetSelectionHandler,
3932
+ RedrawConnectionsHandler,
3933
+ SelectAllHandler,
3934
+ GetConnectionHandler,
3935
+ GetInputRectInFlowHandler,
3936
+ GetIncomingConnectionsHandler,
3937
+ GetOutgoingConnectionsHandler,
3938
+ UpdateConnectionLayerHandler,
3939
+ UpdateNodeLayerHandler,
3940
+ ];
3941
+
3942
+ class FCanvasComponent extends FCanvasBase {
3943
+ set position(value) {
3944
+ if (!value) {
3945
+ return;
3946
+ }
3947
+ const position = PointExtensions.sum(this.transform.position, this.transform.scaledPosition);
3948
+ if (!PointExtensions.isEqual(position, value)) {
3949
+ this.transform.position = value;
3950
+ this.transform.scaledPosition = PointExtensions.initialize();
3951
+ this.redraw();
3952
+ }
3953
+ }
3954
+ set scale(value) {
3955
+ if (!value) {
3956
+ return;
3957
+ }
3958
+ this.transform.scale = value;
3959
+ this.redraw();
3960
+ }
3961
+ get fNodes() {
3962
+ return this.fComponentsStore.fNodes;
3963
+ }
3803
3964
  get hostElement() {
3804
3965
  return this.elementReference.nativeElement;
3805
3966
  }
3806
- constructor(elementReference, fDraggableDataContext, ngZone, injector, fComponentsStore, document) {
3807
- super(ngZone);
3967
+ constructor(elementReference, fMediator, fComponentsStore) {
3968
+ super();
3808
3969
  this.elementReference = elementReference;
3809
- this.fDraggableDataContext = fDraggableDataContext;
3810
- this.injector = injector;
3970
+ this.fMediator = fMediator;
3811
3971
  this.fComponentsStore = fComponentsStore;
3812
- this.subscriptions$ = new Subscription();
3813
- this.disabled = false;
3814
- this.fSelectionChange = new EventEmitter();
3815
- // @Output()
3816
- // public override fConnectionIntersectNode: EventEmitter<ConnectionIntersectNodeEvent> = new EventEmitter<ConnectionIntersectNodeEvent>();
3817
- this.fCreateNode = new EventEmitter();
3818
- this.fReassignConnection = new EventEmitter();
3819
- this.fCreateConnection = new EventEmitter();
3820
- this.selectedItemsOnPointerDown = 0;
3821
- this.document = document;
3972
+ this.fCanvasChange = new EventEmitter();
3822
3973
  }
3823
3974
  ngOnInit() {
3824
- this.fComponentsStore.fDraggable = this;
3975
+ this.fComponentsStore.fCanvas = this;
3825
3976
  }
3826
- ngAfterViewInit() {
3827
- super.subscribe(this.document);
3977
+ redraw() {
3978
+ this.fComponentsStore.fBackground?.setTransform(this.transform);
3979
+ this.hostElement.setAttribute("style", `transform: ${TransformModelExtensions.toString(this.transform)}`);
3828
3980
  }
3829
- onPointerDown(event) {
3830
- this.fDraggableDataContext.reset();
3831
- let result = event.isMouseLeftButton();
3832
- this.selectedItemsOnPointerDown = this.fDraggableDataContext.selectedItems.length;
3833
- this.injector.get(SingleSelectOnPointerDown).handle(event);
3834
- this.injector.get(ReassignConnectionPrepareDragSequence).handle(event);
3835
- this.injector.get(CreateConnectionPrepareDragSequence).handle(event);
3836
- this.emitSelectionChangeEvent();
3837
- return result;
3981
+ redrawWithAnimation() {
3982
+ this.fComponentsStore.fBackground?.setTransform(this.transform);
3983
+ this.hostElement.setAttribute("style", `transition: transform 0.15s ease-in-out; transform: ${TransformModelExtensions.toString(this.transform)}`);
3984
+ setTimeout(() => {
3985
+ this.redraw();
3986
+ }, 150);
3838
3987
  }
3839
- prepareDragSequence(event) {
3840
- this.injector.get(SelectionAreaPrepareDragSequence).handle(event);
3841
- this.injector.get(NodePrepareDragSequence).handle(event);
3842
- this.injector.get(CanvasPrepareDragSequence).handle(event);
3843
- this.injector.get(ExternalItemPrepareDragSequence).handle(event);
3844
- this.fDraggableDataContext.draggableItems.forEach((item) => {
3845
- item.initialize?.();
3846
- });
3847
- if (this.fDraggableDataContext.draggableItems.length > 0) {
3848
- this.hostElement.classList.add('f-dragging');
3988
+ fitToScreen(toCenter = PointExtensions.initialize(), animated = true) {
3989
+ const fNodesRect = this.fMediator.send(new GetNodesRectRequest());
3990
+ if (fNodesRect.width === 0 || fNodesRect.height === 0) {
3991
+ return;
3849
3992
  }
3993
+ const rect = RectExtensions.addPointToSize(fNodesRect, Point.fromPoint(toCenter).mult(2));
3994
+ this.fitToParent(rect, RectExtensions.fromElement(this.fComponentsStore.fFlow.hostElement), this.fNodes.map((x) => {
3995
+ return Point.fromPoint(x.position).sub(toCenter);
3996
+ }));
3997
+ animated ? this.redrawWithAnimation() : this.redraw();
3998
+ this.completeDrag();
3850
3999
  }
3851
- onPointerMove(event) {
3852
- const pointerPositionInCanvas = Point.fromPoint(event.getPosition()).elementTransform(this.hostElement);
3853
- const difference = pointerPositionInCanvas.div(this.fDraggableDataContext.onPointerDownScale).sub(this.fDraggableDataContext.onPointerDownPosition);
3854
- this.fDraggableDataContext.draggableItems.forEach((item) => {
3855
- item.move(difference);
3856
- });
3857
- }
3858
- onPointerUp(event) {
3859
- this.injector.get(ReassignConnectionOnPointerUp).handle(event);
3860
- this.injector.get(CreateConnectionOnPointerUp).handle(event);
3861
- this.injector.get(SelectionAreaOnPointerUp).handle(event);
3862
- this.injector.get(NodeOnPointerUp).handle(event);
3863
- this.injector.get(CanvasOnPointerUp).handle(event);
3864
- this.injector.get(ExternalItemOnPointerUp).handle(event);
3865
- this.hostElement.classList.remove('f-dragging');
3866
- this.emitSelectionChangeEvent();
3867
- this.fDraggableDataContext.reset();
3868
- }
3869
- emitSelectionChangeEvent() {
3870
- if (!this.fDraggableDataContext.isSelectedChanged
3871
- && this.selectedItemsOnPointerDown === this.fDraggableDataContext.selectedItems.length) {
4000
+ oneToOne() {
4001
+ const fNodesRect = this.fMediator.send(new GetNodesRectRequest());
4002
+ if (fNodesRect.width === 0 || fNodesRect.height === 0) {
3872
4003
  return;
3873
4004
  }
3874
- let selectedNodes = [];
3875
- let selectedConnections = [];
3876
- this.fDraggableDataContext.selectedItems.forEach((x) => {
3877
- if (x.hostElement.classList.contains('f-node')) {
3878
- selectedNodes.push(x.hostElement.id);
3879
- }
3880
- else {
3881
- selectedConnections.push(x.hostElement.id);
3882
- }
3883
- });
3884
- this.fSelectionChange.emit(new FSelectionChangeEvent(selectedNodes, selectedConnections));
3885
- }
3886
- ngOnDestroy() {
3887
- super.unsubscribe();
3888
- this.subscriptions$.unsubscribe();
4005
+ this.oneToOneCentering(fNodesRect, RectExtensions.fromElement(this.fComponentsStore.fFlow.hostElement), this.fNodes.map((x) => {
4006
+ return Point.fromPoint(x.position).sub(new Point(0, 0));
4007
+ }));
4008
+ this.redrawWithAnimation();
4009
+ this.completeDrag();
3889
4010
  }
3890
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, deps: [{ token: i0.ElementRef }, { token: FDraggableDataContext }, { token: i0.NgZone }, { token: i0.Injector }, { token: FComponentsStore }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive }); }
3891
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.2.1", type: FDraggableDirective, selector: "f-flow[fDraggable]", inputs: { disabled: ["fDraggableDisabled", "disabled"] }, outputs: { fSelectionChange: "fSelectionChange", fCreateNode: "fCreateNode", fReassignConnection: "fReassignConnection", fCreateConnection: "fCreateConnection" }, providers: [
3892
- { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3893
- ], exportAs: ["fDraggable"], usesInheritance: true, ngImport: i0 }); }
4011
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FCanvasComponent, deps: [{ token: i0.ElementRef }, { token: FFlowMediator }, { token: FComponentsStore }], target: i0.ɵɵFactoryTarget.Component }); }
4012
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FCanvasComponent, selector: "f-canvas", inputs: { position: "position", scale: "scale" }, outputs: { fCanvasChange: "fCanvasChange" }, host: { classAttribute: "f-component f-canvas" }, providers: [{ provide: F_CANVAS, useExisting: FCanvasComponent }], viewQueries: [{ propertyName: "fNodesContainer", first: true, predicate: ["fNodesContainer"], descendants: true, static: true }, { propertyName: "fConnectionsContainer", first: true, predicate: ["fConnectionsContainer"], descendants: true, static: true }], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "<ng-container>\n <div #fConnectionsContainer>\n <ng-content select=\"f-connection\"></ng-content>\n <ng-content select=\"f-connection-for-create\"></ng-content>\n </div>\n <div #fNodesContainer>\n <ng-content select=\"[fNode]\"></ng-content>\n </div>\n</ng-container>\n", styles: [":host{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3894
4013
  }
3895
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FDraggableDirective, decorators: [{
3896
- type: Directive,
3897
- args: [{
3898
- selector: "f-flow[fDraggable]",
3899
- exportAs: 'fDraggable',
3900
- providers: [
3901
- { provide: F_DRAGGABLE, useExisting: FDraggableDirective }
3902
- ]
3903
- }]
3904
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FDraggableDataContext }, { type: i0.NgZone }, { type: i0.Injector }, { type: FComponentsStore }, { type: undefined, decorators: [{
3905
- type: Inject,
3906
- args: [DOCUMENT]
3907
- }] }], propDecorators: { disabled: [{
3908
- type: Input,
3909
- args: ['fDraggableDisabled']
3910
- }], fSelectionChange: [{
3911
- type: Output
3912
- }], fCreateNode: [{
3913
- type: Output
3914
- }], fReassignConnection: [{
3915
- type: Output
3916
- }], fCreateConnection: [{
4014
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FCanvasComponent, decorators: [{
4015
+ type: Component,
4016
+ args: [{ selector: 'f-canvas', exportAs: 'fComponent', host: {
4017
+ 'class': 'f-component f-canvas',
4018
+ }, providers: [{ provide: F_CANVAS, useExisting: FCanvasComponent }], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container>\n <div #fConnectionsContainer>\n <ng-content select=\"f-connection\"></ng-content>\n <ng-content select=\"f-connection-for-create\"></ng-content>\n </div>\n <div #fNodesContainer>\n <ng-content select=\"[fNode]\"></ng-content>\n </div>\n</ng-container>\n", styles: [":host{position:absolute;overflow:visible;width:100%;height:100%;left:0;top:0;transform-origin:0 0;pointer-events:none}\n"] }]
4019
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FFlowMediator }, { type: FComponentsStore }], propDecorators: { fCanvasChange: [{
3917
4020
  type: Output
4021
+ }], position: [{
4022
+ type: Input
4023
+ }], scale: [{
4024
+ type: Input
4025
+ }], fNodesContainer: [{
4026
+ type: ViewChild,
4027
+ args: ['fNodesContainer', { static: true }]
4028
+ }], fConnectionsContainer: [{
4029
+ type: ViewChild,
4030
+ args: ['fConnectionsContainer', { static: true }]
3918
4031
  }] } });
3919
4032
 
3920
4033
  class LineElement {
@@ -4090,12 +4203,12 @@ class FLineAlignmentComponent extends FLineAlignmentBase {
4090
4203
  get flowHost() {
4091
4204
  return this.fComponentsStore.fFlow.hostElement;
4092
4205
  }
4093
- constructor(elementReference, fComponentsStore, fDraggableDataContext, getElementRectInFlowHandler) {
4206
+ constructor(elementReference, fComponentsStore, fDraggableDataContext, fMediator) {
4094
4207
  super();
4095
4208
  this.elementReference = elementReference;
4096
4209
  this.fComponentsStore = fComponentsStore;
4097
4210
  this.fDraggableDataContext = fDraggableDataContext;
4098
- this.getElementRectInFlowHandler = getElementRectInFlowHandler;
4211
+ this.fMediator = fMediator;
4099
4212
  this.size = SizeExtensions.initialize();
4100
4213
  this.draggedNodeRect = RectExtensions.initialize();
4101
4214
  this.rects = [];
@@ -4108,14 +4221,14 @@ class FLineAlignmentComponent extends FLineAlignmentBase {
4108
4221
  this.size = this.flowHost.getBoundingClientRect();
4109
4222
  this.rects = [];
4110
4223
  const draggedNodeRects = currentNodes.map((x) => {
4111
- return this.getElementRectInFlowHandler.handle(x.hostElement);
4224
+ return this.fMediator.send(new GetElementRectInFlowRequest(x.hostElement));
4112
4225
  });
4113
4226
  this.draggedNodeRect = RectExtensions.union(draggedNodeRects);
4114
4227
  const allNodesExcludeCurrents = allNodes.filter((x) => {
4115
4228
  return !currentNodes.includes(x);
4116
4229
  });
4117
4230
  this.rects = allNodesExcludeCurrents.map((x) => {
4118
- return this.getElementRectInFlowHandler.handle(x.hostElement);
4231
+ return this.fMediator.send(new GetElementRectInFlowRequest(x.hostElement));
4119
4232
  });
4120
4233
  }
4121
4234
  handle(difference) {
@@ -4148,7 +4261,7 @@ class FLineAlignmentComponent extends FLineAlignmentBase {
4148
4261
  this.lineService.hideVerticalLine();
4149
4262
  this.lineService.hideHorizontalLine();
4150
4263
  }
4151
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }, { token: FDraggableDataContext }, { token: GetElementRectInFlowHandler }], target: i0.ɵɵFactoryTarget.Component }); }
4264
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FLineAlignmentComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }, { token: FDraggableDataContext }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Component }); }
4152
4265
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FLineAlignmentComponent, selector: "f-line-alignment", host: { classAttribute: "f-line-alignment f-component" }, providers: [
4153
4266
  { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
4154
4267
  ], exportAs: ["fComponent"], usesInheritance: true, ngImport: i0, template: "", isInline: true, styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }); }
@@ -4160,7 +4273,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4160
4273
  }, providers: [
4161
4274
  { provide: F_LINE_ALIGNMENT, useExisting: FLineAlignmentComponent }
4162
4275
  ], styles: [":host{display:block;position:absolute;left:0;top:0;width:100%;height:100%;overflow:hidden;pointer-events:none;-webkit-user-select:none;user-select:none}\n"] }]
4163
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }, { type: FDraggableDataContext }, { type: GetElementRectInFlowHandler }] });
4276
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }, { type: FDraggableDataContext }, { type: FFlowMediator }] });
4164
4277
 
4165
4278
  const F_SELECTION_AREA = new InjectionToken('F_SELECTION_AREA');
4166
4279
  class FSelectionAreaBase {
@@ -4220,10 +4333,9 @@ class FFlowComponent extends FFlowBase {
4220
4333
  get hostElement() {
4221
4334
  return this.elementReference.nativeElement;
4222
4335
  }
4223
- constructor(elementReference, getAllNodesRectHandler, fComponentsStore, fMediator) {
4336
+ constructor(elementReference, fComponentsStore, fMediator) {
4224
4337
  super();
4225
4338
  this.elementReference = elementReference;
4226
- this.getAllNodesRectHandler = getAllNodesRectHandler;
4227
4339
  this.fComponentsStore = fComponentsStore;
4228
4340
  this.fMediator = fMediator;
4229
4341
  this.subscription$ = new Subscription();
@@ -4247,13 +4359,27 @@ class FFlowComponent extends FFlowBase {
4247
4359
  }
4248
4360
  });
4249
4361
  }
4362
+ reset() {
4363
+ this.isLoaded = false;
4364
+ }
4250
4365
  getNodesRect() {
4251
- return this.getAllNodesRectHandler.handle();
4366
+ const result = this.fMediator.send(new GetNodesRectRequest());
4367
+ return result;
4368
+ }
4369
+ getSelection() {
4370
+ const result = this.fMediator.send(new GetSelectionRequest());
4371
+ return result;
4372
+ }
4373
+ selectAll() {
4374
+ this.fMediator.send(new SelectAllRequest());
4375
+ }
4376
+ clearSelection() {
4377
+ this.fMediator.send(new ClearSelectionRequest());
4252
4378
  }
4253
4379
  ngOnDestroy() {
4254
4380
  this.subscription$.unsubscribe();
4255
4381
  }
4256
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowComponent, deps: [{ token: i0.ElementRef }, { token: GetAllNodesRectHandler }, { token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Component }); }
4382
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowComponent, deps: [{ token: i0.ElementRef }, { token: FComponentsStore }, { token: FFlowMediator }], target: i0.ɵɵFactoryTarget.Component }); }
4257
4383
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.1", type: FFlowComponent, selector: "f-flow", inputs: { fFlowId: "fFlowId" }, outputs: { fLoaded: "fLoaded" }, host: { properties: { "attr.id": "fFlowId" }, classAttribute: "f-component f-flow" }, providers: [
4258
4384
  FFlowMediator,
4259
4385
  FComponentsStore,
@@ -4266,7 +4392,7 @@ class FFlowComponent extends FFlowBase {
4266
4392
  ...CONNECTIONS_PROVIDERS,
4267
4393
  ...COMMON_PROVIDERS,
4268
4394
  { provide: F_FLOW, useExisting: FFlowComponent },
4269
- ], usesInheritance: true, ngImport: i0, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4395
+ ], usesInheritance: true, ngImport: i0, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n\n <ng-content select=\"f-mini-map\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4270
4396
  }
4271
4397
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImport: i0, type: FFlowComponent, decorators: [{
4272
4398
  type: Component,
@@ -4285,8 +4411,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4285
4411
  ...CONNECTIONS_PROVIDERS,
4286
4412
  ...COMMON_PROVIDERS,
4287
4413
  { provide: F_FLOW, useExisting: FFlowComponent },
4288
- ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"] }]
4289
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: GetAllNodesRectHandler }, { type: FComponentsStore }, { type: FFlowMediator }], propDecorators: { fFlowId: [{
4414
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container>\n <ng-content select=\"[fDefinitions]\"></ng-content>\n\n <ng-content select=\"f-background\"></ng-content>\n\n <ng-content select=\"f-line-alignment\"></ng-content>\n\n <ng-content select=\"f-canvas\"></ng-content>\n\n <ng-content select=\"f-selection-area\"></ng-content>\n\n <ng-content select=\"f-mini-map\"></ng-content>\n</ng-container>\n", styles: [":host{display:block;position:relative;width:100%;height:100%;overflow:hidden;pointer-events:all;-webkit-user-select:none;user-select:none;touch-action:none}\n"] }]
4415
+ }], ctorParameters: () => [{ type: i0.ElementRef }, { type: FComponentsStore }, { type: FFlowMediator }], propDecorators: { fFlowId: [{
4290
4416
  type: Input
4291
4417
  }], fLoaded: [{
4292
4418
  type: Output
@@ -4385,5 +4511,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.1", ngImpor
4385
4511
  * Generated bundle index. Do not edit.
4386
4512
  */
4387
4513
 
4388
- export { CANVAS_PROVIDERS, COMMON_PROVIDERS, CONNECTIONS_PROVIDERS, CONNECTION_GRADIENT, CONNECTION_PATH, CONNECTION_TEXT, CalculateCenterBetweenPointsHandler, CalculateCenterBetweenPointsRequest, CalculateConnectionCenterHandler, CalculateConnectionCenterRequest, CalculateConnectorConnectableSideHandler, CalculateConnectorConnectableSideRequest, CanvasDragHandler, CanvasOnPointerUp, CanvasPrepareDragSequence, ConnectionDragHandler, ConnectionSourceDragHandler, ConnectionTargetDragHandler, CreateConnectionDragHandler, CreateConnectionOnPointerUp, CreateConnectionPrepareDragSequence, EFConnectableSide, EFConnectionBehavior, EFConnectionType, EFDraggableType, EFMarkerType, EXTERNAL_ITEM_PROVIDERS, ExternalItemDragHandler, ExternalItemOnPointerUp, ExternalItemPrepareDragSequence, FBackgroundBase, FBackgroundComponent, FBezierPathBuilder, FCanvasBase, FCanvasChangeEvent, FCanvasComponent, FCellPatternComponent, FComponentsStore, FConnectionBase, FConnectionCenterDirective, FConnectionComponent, FConnectionDragHandleComponent, FConnectionForCreateComponent, FConnectionGradientComponent, FConnectionPathComponent, FConnectionSelectionComponent, FConnectionTextComponent, FConnectionTextPathDirective, FConnectorBase, FCreateConnectionEvent, FCreateNodeEvent, FDragHandleDirective, FDraggableBase, FDraggableDataContext, FDraggableDirective, FExternalItemBase, FExternalItemDirective, FExternalItemService, FFlowBase, FFlowComponent, FFlowMediator, FFlowModule, FHandlerRegister, FLOW, FLineAlignmentBase, FLineAlignmentComponent, FMarkerBase, FMarkerDirective, FNodeBase, FNodeDirective, FNodeInputBase, FNodeInputDirective, FNodeOutletBase, FNodeOutletDirective, FNodeOutputBase, FNodeOutputDirective, FPathBuilderBase, FPathBuilderSelector, FReassignConnectionEvent, FResizeObserver, FSegmentPathBuilder, FSelectionAreaBase, FSelectionAreaComponent, FSelectionChangeEvent, FStraightPathBuilder, FZoomBase, FZoomDirective, F_BACKGROUND, F_BACKGROUND_PATTERN, F_CANVAS, F_CONNECTION_DRAG_HANDLE_CLASS, F_CONNECTION_IDENTIFIERS, F_DRAGGABLE, F_DRAG_HANDLE, F_EXTERNAL_ITEM, F_FLOW, F_LINE_ALIGNMENT, F_MARKER, F_NODE, F_NODE_INPUT, F_NODE_OUTLET, F_NODE_OUTPUT, F_SELECTED_CLASS, F_SELECTION_AREA, F_ZOOM, FindFirstCanBeConnectedOutputByOutletHandler, FindInputsUnderPointerHandler, FindInputsUnderPointerRequest, FirstNotConnectedInputOfNodeUnderPointerHandler, GetAllNodesRectHandler, GetCanBeSelectedItemsHandler, GetConnectionHandler, GetConnectionVectorHandler, GetConnectionVectorRequest, GetElementRectInFlowHandler, GetIncomingConnectionsHandler, GetInputRectInFlowHandler, GetOutgoingConnectionsHandler, GetOutputRectInFlowHandler, GetOutputRectInFlowRequest, GetOutputRectInFlowResponse, IDragAndDropBase, InputNotFound, InputsUnderPointerHandler, IsConnectionUnderNodeHandler, LineElement, LineService, MOUSE_EVENT_IGNORE_TIME, NODE_PROVIDERS, NearestCoordinateFinder, NodeDragHandler, NodeOnPointerUp, NodePrepareDragSequence, OutputNotFound, ReassignConnectionDragHandler, ReassignConnectionOnPointerUp, ReassignConnectionPrepareDragSequence, RedrawConnectionsHandler, RedrawConnectionsRequest, SELECTION_AREA_PROVIDERS, SINGLE_SELECT_PROVIDERS, SelectAllHandler, SelectionAreaDragHandle, SelectionAreaOnPointerUp, SelectionAreaPrepareDragSequence, SingleSelectOnPointerDown, UpdateConnectionLayerHandler, UpdateNodeLayerHandler, castToConnectionBehavior, castToConnectionType, getExternalItem, getFlowUid, isExternalItem, isNode, isNodeDragHandle, isNodeInput, isNodeOutlet, isNodeOutput, mixinChangeConnectionSelection, mixinChangeConnectionVisibility, requiredOutput };
4514
+ export { CANVAS_PROVIDERS, COMMON_PROVIDERS, CONNECTIONS_PROVIDERS, CONNECTION_GRADIENT, CONNECTION_PATH, CONNECTION_TEXT, CalculateCenterBetweenPointsHandler, CalculateCenterBetweenPointsRequest, CalculateConnectionCenterHandler, CalculateConnectionCenterRequest, CalculateConnectorConnectableSideHandler, CalculateConnectorConnectableSideRequest, CanvasDragHandler, CanvasOnPointerUp, CanvasPrepareDragSequence, ClearSelectionHandler, ClearSelectionRequest, ConnectionDragHandler, ConnectionSourceDragHandler, ConnectionTargetDragHandler, CreateConnectionDragHandler, CreateConnectionOnPointerUp, CreateConnectionPrepareDragSequence, EFConnectableSide, EFConnectionBehavior, EFConnectionType, EFDraggableType, EFMarkerType, EXTERNAL_ITEM_PROVIDERS, ExternalItemDragHandler, ExternalItemOnPointerUp, ExternalItemPrepareDragSequence, FBackgroundBase, FBackgroundComponent, FBezierPathBuilder, FCanvasBase, FCanvasChangeEvent, FCanvasComponent, FCellPatternComponent, FComponentsStore, FConnectionBase, FConnectionCenterDirective, FConnectionComponent, FConnectionDragHandleComponent, FConnectionForCreateComponent, FConnectionGradientComponent, FConnectionPathComponent, FConnectionSelectionComponent, FConnectionTextComponent, FConnectionTextPathDirective, FConnectorBase, FCreateConnectionEvent, FCreateNodeEvent, FDragHandleDirective, FDraggableBase, FDraggableDataContext, FDraggableDirective, FExternalItemBase, FExternalItemDirective, FExternalItemService, FFlowBase, FFlowComponent, FFlowMediator, FFlowModule, FHandlerRegister, FLOW, FLineAlignmentBase, FLineAlignmentComponent, FMarkerBase, FMarkerDirective, FNodeBase, FNodeDirective, FNodeInputBase, FNodeInputDirective, FNodeOutletBase, FNodeOutletDirective, FNodeOutputBase, FNodeOutputDirective, FPathBuilderBase, FPathBuilderSelector, FReassignConnectionEvent, FResizeObserver, FSegmentPathBuilder, FSelectionAreaBase, FSelectionAreaComponent, FSelectionChangeEvent, FStraightPathBuilder, FZoomBase, FZoomDirective, F_BACKGROUND, F_BACKGROUND_PATTERN, F_CANVAS, F_CONNECTION_DRAG_HANDLE_CLASS, F_CONNECTION_IDENTIFIERS, F_DRAGGABLE, F_DRAG_HANDLE, F_EXTERNAL_ITEM, F_FLOW, F_LINE_ALIGNMENT, F_MARKER, F_NODE, F_NODE_INPUT, F_NODE_OUTLET, F_NODE_OUTPUT, F_SELECTED_CLASS, F_SELECTION_AREA, F_ZOOM, FindFirstCanBeConnectedOutputByOutletHandler, FindInputsUnderPointerHandler, FindInputsUnderPointerRequest, FirstNotConnectedInputOfNodeUnderPointerHandler, GetCanBeSelectedItemsHandler, GetConnectionHandler, GetConnectionVectorHandler, GetConnectionVectorRequest, GetElementRectInFlowHandler, GetElementRectInFlowRequest, GetIncomingConnectionsHandler, GetInputRectInFlowHandler, GetInputRectInFlowRequest, GetInputRectInFlowResponse, GetNodesRectHandler, GetNodesRectRequest, GetOutgoingConnectionsHandler, GetOutputRectInFlowHandler, GetOutputRectInFlowRequest, GetOutputRectInFlowResponse, GetSelectionHandler, GetSelectionRequest, InputsUnderPointerHandler, IsConnectionUnderNodeHandler, LineElement, LineService, MOUSE_EVENT_IGNORE_TIME, NODE_PROVIDERS, NearestCoordinateFinder, NodeDragHandler, NodeOnPointerUp, NodePrepareDragSequence, ReassignConnectionDragHandler, ReassignConnectionOnPointerUp, ReassignConnectionPrepareDragSequence, RedrawConnectionsHandler, RedrawConnectionsRequest, SELECTION_AREA_PROVIDERS, SINGLE_SELECT_PROVIDERS, SelectAllHandler, SelectAllRequest, SelectionAreaDragHandle, SelectionAreaOnPointerUp, SelectionAreaPrepareDragSequence, SingleSelectOnPointerDown, UpdateConnectionLayerHandler, UpdateNodeLayerHandler, castToConnectionBehavior, castToConnectionType, getExternalItem, getFlowUid, isExternalItem, isNode, isNodeDragHandle, isNodeInput, isNodeOutlet, isNodeOutput, mixinChangeConnectionSelection, mixinChangeConnectionVisibility };
4389
4515
  //# sourceMappingURL=foblex-flow.mjs.map