@foblex/flow 1.5.3 → 1.5.5

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