ngx-diagrams
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.2.0.
16 lines • 52.5 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("lodash"),require("@angular/common"),require("dagre")):"function"==typeof define&&define.amd?define("ngx-diagrams",["exports","@angular/core","rxjs","rxjs/operators","lodash","@angular/common","dagre"],e):e((t=t||self)["ngx-diagrams"]={},t.ng.core,t.rxjs,t.rxjs.operators,t._,t.ng.common,t.dagre)}(this,(function(t,e,n,o,r,i,s){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function l(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var c=function(){return(c=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function u(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function d(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(d(arguments[e]));return t}var h={LOG:0,ERROR:1};function f(){return t.__DEV__}function g(e,n){void 0===n&&(n=h.LOG);for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];f()&&t.__LOG__===n&&(t.__LOG__===h.ERROR&&console.error.apply(console,p([e],o)),console.log.apply(console,p([e],o)))}function y(t,e){void 0===e&&(e=h.LOG);for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return(function(r){return f()?r.pipe(o.tap((function(o){return g.apply(void 0,p([t,e,o],n))}))):r})}function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}function m(t){return null==t}function b(t){var e=[];for(var n in t)m(t[n])||e.push(t[n]);return e}function x(t,e,n){void 0===n&&(n=0);var o=Math.abs(t.x-e.x)>Math.abs(t.y-e.y),r=o?n:0,i=o?0:n;return"M"+t.x+","+t.y+" C "+(t.x+r)+","+(t.y+i)+"\n "+(e.x-r)+","+(e.y-i)+" "+e.x+","+e.y}h[h.LOG]="LOG",h[h.ERROR]="ERROR",t.__DEV__=!0,t.__LOG__=h.ERROR;var P=function(t){var e=this;this.id=v(),this.entity=t,this.entityId=t.id,this.firing=!0,this.stopPropagation=function(){return e.firing=!1}};var k=function(t){function e(e,n){void 0===n&&(n=!1);var o=t.call(this,e)||this;return o.locked=n,o}return l(e,t),e}(P);var L=function(t){function e(e,n){var o=t.call(this,e)||this;return o.parent=n,o}return l(e,t),e}(P);var w=function(t){function e(e,n){var o=t.call(this,e)||this;return o.isSelected=n,o}return l(e,t),e}(P);var M=function(t){function e(e,n){void 0===n&&(n=!1);var o=t.call(this,e)||this;return o.isPainted=n,o}return l(e,t),e}(P);var C=function(){function t(t,e){void 0===e&&(e=""),this._destroyed=new n.Subject,this._destroyed$=this._destroyed.asObservable(),this._locked=new n.BehaviorSubject(!1),this._locked$=this._locked.asObservable(),this._id=t||v(),this._logPrefix=""+e}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},set:function(t){this._id=t},enumerable:!0,configurable:!0}),t.prototype.log=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];g.apply(void 0,p([this._logPrefix+" "+t+": ",h.LOG],e))},t.prototype.withLog=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return y.apply(void 0,p([this._logPrefix+" "+t+": ",h.LOG],e))},t.prototype.getLocked=function(){return this._locked.getValue()},t.prototype.setLocked=function(t){void 0===t&&(t=!0),this._locked.next(t)},t.prototype.doClone=function(t,e){void 0===t&&(t={})},t.prototype.clone=function(t){if(void 0===t&&(t={}),t[this.id])return t[this.id];var e=c({},this);return e.id=v(),t[this.id]=e,this.doClone(t,e),e},t.prototype.lockChanges=function(){var t=this;return this._locked$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(e){return new k(t,e)})),this.withLog("lockChanges"))},t.prototype.destroy=function(t){var e=c({emit:!0,propagate:!0},t);this.log("entity destroyed"),this._destroyed.next(e),this._destroyed.complete()},t.prototype.onEntityDestroy=function(){return this._destroyed$.pipe(o.filter((function(t){return t.emit})),o.mapTo(new P(this)))},t}();var $=function(t){function e(e,o,r){void 0===r&&(r="[Base]");var i=t.call(this,o,r)||this;return i._parent=new n.BehaviorSubject(null),i._parent$=i._parent.asObservable(),i._selected=new n.BehaviorSubject(!1),i._selected$=i._selected.asObservable(),i._painted=new n.BehaviorSubject(!1),i._painted$=i._painted.asObservable(),i._type=e,i}return l(e,t),e.prototype.getParent=function(){return this._parent.getValue()},e.prototype.setParent=function(t){this._parent.next(t)},e.prototype.parentChanges=function(){var t=this;return this._parent$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(e){return new L(t,e)})))},e.prototype.getPainted=function(){return this._painted.getValue()},e.prototype.setPainted=function(t){void 0===t&&(t=!0),this._painted.next(t)},e.prototype.paintChanges=function(){var t=this;return this._painted$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(e){return new M(t,e)})))},e.prototype.getType=function(){return this._type},e.prototype.getSelected=function(){return this._selected.getValue()},e.prototype.selectSelected=function(){return this._selected.asObservable()},e.prototype.setSelected=function(t){void 0===t&&(t=!0),this._selected.next(t)},e.prototype.selectionChanges=function(){var t=this;return this._selected$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(e){return new w(t,e)})),this.withLog("selectionChanges"))},e.prototype.getSelectedEntities=function(){return this._selected.value?[this]:[]},e}(C);var E=function(t){function e(e,o,r,i,s,a,l,c){void 0===e&&(e="default"),void 0===r&&(r={}),void 0===i&&(i=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===l&&(l=0),void 0===c&&(c="[Node]");var u=t.call(this,e,o,c)||this;return u._extras=new n.BehaviorSubject(r),u._ports=new n.BehaviorSubject({}),u._dimensions=new n.BehaviorSubject({width:a,height:l}),u._coords=new n.BehaviorSubject({x:i,y:s}),u.extras$=u._extras.asObservable(),u.ports$=u._ports.asObservable(),u.coords$=u._coords.asObservable(),u.dimensions$=u._dimensions.asObservable(),u}return l(e,t),e.prototype.getCoords=function(){return this._coords.getValue()},e.prototype.setCoords=function(t){var e=t.x,n=t.y,o=this.getCoords(),r=o.x,i=o.y;Object.values(this._ports.getValue()).forEach((function(t){Object.values(t.getLinks()).forEach((function(o){var s=o.getPointForPort(t),a=s.getCoords(),l=a.x,c=a.y;s.setCoords({x:l+e-r,y:c+n-i})}))})),this._coords.next({x:e,y:n})},e.prototype.transitionToCoords=function(t){t.x,t.y},e.prototype.getSelectedEntities=function(){var e=t.prototype.getSelectedEntities.call(this);return this.getSelected()&&Object.values(this._ports.getValue()).forEach((function(t){var n=Object.values(t.getLinks());e=e.concat(n.map((function(e){return e.getPointForPort(t)})))})),this.log("selectedEntities",e),e},e.prototype.coordsChanges=function(){return this.coords$.pipe(o.takeUntil(this.onEntityDestroy()))},e.prototype.selectCoords=function(){return this.coords$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged())},e.prototype.selectX=function(){return this.selectCoords().pipe(o.map((function(t){return t.x})),this.withLog("selectX"),o.distinctUntilChanged())},e.prototype.selectY=function(){return this.selectCoords().pipe(o.map((function(t){return t.y})),this.withLog("selectY"),o.distinctUntilChanged())},e.prototype.addPort=function(t){var e;return t.setParent(this),this._ports.next(c({},this._ports.value,((e={})[t.id]=t,e))),t},e.prototype.getPort=function(t){return this._ports.value[t]},e.prototype.selectPorts=function(t){return this.ports$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged(),o.map((function(t){return b(t)})),this.withLog("selectPorts"))},e.prototype.getPorts=function(t){return this._ports.getValue()},e.prototype.setDimensions=function(t){var e=t.width,n=t.height;this._dimensions.next({width:e,height:n})},e.prototype.getDimensions=function(){return this._dimensions.getValue()},e.prototype.dimensionChanges=function(){return this.dimensions$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged(),this.withLog("DimensionChanges"))},e.prototype.getHeight=function(){return this._dimensions.getValue().height},e.prototype.getWidth=function(){return this._dimensions.getValue().width},e.prototype.selectWidth=function(){return this.dimensions$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(t){return t.width})),o.distinctUntilChanged(),this.withLog("selectWidth"))},e.prototype.selectHeight=function(){return this.dimensions$.pipe(o.takeUntil(this.onEntityDestroy()),o.map((function(t){return t.width})),o.distinctUntilChanged(),this.withLog("selectHeight"))},e.prototype.setExtras=function(t){this._extras.next(t)},e.prototype.getExtras=function(){return this._extras.getValue()},e.prototype.selectExtras=function(t){return this.extras$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged())},e}($);var _=function(t){function e(e,o){var r=o.x,i=o.y,s=t.call(this)||this;return s._coords=new n.BehaviorSubject({x:r,y:i}),s.coords$=s._coords.asObservable(),s.setParent(e),s}return l(e,t),e.prototype.isConnectedToPort=function(){return null!==this.getParent().getPortForPoint(this)},e.prototype.getLink=function(){return this.getParent()},e.prototype.destroy=function(e){this.getParent&&this.getParent().removePoint(this),t.prototype.destroy.call(this,e)},e.prototype.setCoords=function(t){this._coords.next(c({},this._coords.getValue(),t))},e.prototype.selectCoords=function(){return this.coords$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged())},e.prototype.getCoords=function(){return this._coords.getValue()},e.prototype.selectX=function(){return this.selectCoords().pipe(o.map((function(t){return t.x})),o.distinctUntilChanged())},e.prototype.selectY=function(){return this.selectCoords().pipe(o.map((function(t){return t.y})),o.distinctUntilChanged())},e}($);var S=function(t){function e(e,o){void 0===e&&(e="default");var r=t.call(this,e,o)||this;return r.label=new n.BehaviorSubject(null),r.points=[new _(r,{x:0,y:0}),new _(r,{x:0,y:0})],r.extras={},r.sourcePort=null,r.targetPort=null,r}return l(e,t),e.prototype.setName=function(t){this.name=t},e.prototype.getName=function(){return this.name},e.prototype.getExtras=function(){return this.extras},e.prototype.setExtras=function(t){this.extras=t},e.prototype.destroy=function(e){this.sourcePort&&this.sourcePort.removeLink(this),this.targetPort&&this.targetPort.removeLink(this),t.prototype.destroy.call(this,e)},e.prototype.doClone=function(t,e){void 0===t&&(t={}),e.setPoints(this.getPoints().map((function(e){return e.clone(t)}))),this.sourcePort&&e.setSourcePort(this.sourcePort.clone(t)),this.targetPort&&e.setTargetPort(this.targetPort.clone(t))},e.prototype.isLastPoint=function(t){return this.getPointIndex(t)===this.points.length-1},e.prototype.getPointIndex=function(t){return this.points.indexOf(t)},e.prototype.getPointModel=function(t){var e,n;try{for(var o=u(this.points),r=o.next();!r.done;r=o.next()){var i=r.value;if(i.id===t)return i}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return null},e.prototype.getPortForPoint=function(t){return null!==this.sourcePort&&this.getFirstPoint().id===t.id?this.sourcePort:null!==this.targetPort&&this.getLastPoint().id===t.id?this.targetPort:null},e.prototype.getPointForPort=function(t){return null!==this.sourcePort&&this.sourcePort.id===t.id?this.getFirstPoint():null!==this.targetPort&&this.targetPort.id===t.id?this.getLastPoint():null},e.prototype.getFirstPoint=function(){return this.points[0]},e.prototype.getLastPoint=function(){return this.points[this.points.length-1]},e.prototype.setSourcePort=function(t){null!==t&&t.addLink(this),null!==this.sourcePort&&this.sourcePort.removeLink(this),this.sourcePort=t},e.prototype.getSourcePort=function(){return this.sourcePort},e.prototype.getTargetPort=function(){return this.targetPort},e.prototype.setTargetPort=function(t){null!==t&&t.addLink(this),null!==this.targetPort&&this.targetPort.removeLink(this),this.targetPort=t},e.prototype.point=function(t){var e=t.x,n=t.y;return this.addPoint(this.generatePoint({x:e,y:n}))},e.prototype.getPoints=function(){return this.points},e.prototype.setPoints=function(t){var e=this;t.forEach((function(t){t.setParent(e)})),this.points=t},e.prototype.setLabel=function(t){t.setParent(this),this.label.next(t),t.setPainted()},e.prototype.selectLabel=function(){return this.label.asObservable()},e.prototype.getLabel=function(){return this.label.getValue()},e.prototype.resetLabel=function(){var t=this.label.getValue();t&&(t.setParent(null),t.setPainted(!1)),this.label.next(null)},e.prototype.removePoint=function(t){this.points.splice(this.getPointIndex(t),1)},e.prototype.removePointsBefore=function(t){this.points.splice(0,this.getPointIndex(t))},e.prototype.removePointsAfter=function(t){this.points.splice(this.getPointIndex(t)+1)},e.prototype.removeMiddlePoints=function(){this.points.length>2&&this.points.splice(0,this.points.length-2)},e.prototype.addPoint=function(t,e){return void 0===e&&(e=1),t.setParent(this),this.points.splice(e,0,t),t},e.prototype.generatePoint=function(t){var e=t.x,n=void 0===e?0:e,o=t.y;return new _(this,{x:n,y:void 0===o?0:o})},e}($);var O=function(t){function e(e,o,r,i,s){var a=t.call(this,o,r)||this;return a.name=e,a.links$=new n.BehaviorSubject({}),a.maximumLinks=i,a.x$=new n.BehaviorSubject(0),a.y$=new n.BehaviorSubject(0),a.height$=new n.BehaviorSubject(0),a.width$=new n.BehaviorSubject(0),a.linkType=s,a}return l(e,t),e.prototype.getNode=function(){return this.getParent()},e.prototype.getName=function(){return this.name},e.prototype.selectX=function(){return this.x$.asObservable()},e.prototype.selectY=function(){return this.y$.asObservable()},e.prototype.getY=function(){return this.y$.getValue()},e.prototype.getX=function(){return this.x$.getValue()},e.prototype.getHeight=function(){return this.height$.getValue()},e.prototype.getWidth=function(){return this.width$.getValue()},e.prototype.getMaximumLinks=function(){return this.maximumLinks},e.prototype.setMaximumLinks=function(t){this.maximumLinks=t},e.prototype.getLinkType=function(){return this.linkType},e.prototype.setLinkType=function(t){this.linkType=t},e.prototype.removeLink=function(t){var e=this.links$.getValue();delete e[t.id],this.links$.next(c({},e))},e.prototype.addLink=function(t){var e;this.links$.next(c({},this.links$.value,((e={})[t.id]=t,e)))},e.prototype.getLinks=function(){return this.links$.getValue()},e.prototype.selectLinks=function(){return this.links$.asObservable()},e.prototype.updateCoords=function(t){var e=t.x,n=t.y,o=t.width,r=t.height;this.x$.next(e),this.y$.next(n),this.width$.next(o),this.height$.next(r)},e.prototype.canLinkToPort=function(t){return!0},e.prototype.isLocked=function(){return t.prototype.getLocked.call(this)},e.prototype.createLinkModel=function(){var t=Object.keys(this.links$.getValue()).length;return 1===this.maximumLinks&&t>=1?(Object.values(this.links$.getValue())[0].destroy(),null):t>=this.maximumLinks?(Object.values(this.links$.getValue())[0].destroy(),null):null},e}($);var F=function(t){function e(e,o){var r=t.call(this,o)||this;return r.diagramEngine=e,r.nodes$=new n.BehaviorSubject({}),r.links$=new n.BehaviorSubject({}),r.zoom$=new n.BehaviorSubject(100),r.offsetX$=new n.BehaviorSubject(0),r.offsetY$=new n.BehaviorSubject(0),r.gridSize$=new n.BehaviorSubject(0),r}return l(e,t),e.prototype.getNodes=function(){return this.nodes$.getValue()},e.prototype.getNode=function(t){return this.nodes$.getValue()[t]},e.prototype.getLink=function(t){return this.links$.getValue()[t]},e.prototype.getLinks=function(){return this.links$.getValue()},e.prototype.addNode=function(t){var e;return this.nodes$.next(c({},this.nodes$.value,((e={})[t.id]=t,e))),t},e.prototype.deleteNode=function(t){var e="string"==typeof t?t:t.id,n=c({},this.nodes$.value);delete n[e],this.nodes$.next(n)},e.prototype.selectNodes=function(){return this.nodes$.asObservable()},e.prototype.addLink=function(t){var e;return this.links$.next(c({},this.links$.value,((e={})[t.id]=t,e))),t},e.prototype.deleteLink=function(t){var e="string"==typeof t?t:t.id,n=c({},this.links$.value);delete n[e],this.links$.next(n)},e.prototype.selectLinks=function(){return this.links$.asObservable()},e.prototype.setOffset=function(t,e){this.offsetX$.next(t),this.offsetY$.next(e)},e.prototype.setOffsetX=function(t){this.offsetX$.next(t)},e.prototype.getOffsetX=function(){return this.offsetX$.getValue()},e.prototype.selectOffsetX=function(){return this.offsetX$.asObservable()},e.prototype.setOffsetY=function(t){this.offsetY$.next(t)},e.prototype.getOffsetY=function(){return this.offsetY$.getValue()},e.prototype.selectOffsetY=function(){return this.offsetY$.asObservable()},e.prototype.setZoomLevel=function(t){this.zoom$.next(t)},e.prototype.getZoomLevel=function(){return this.zoom$.getValue()},e.prototype.selectZoomLevel=function(){return this.zoom$.asObservable()},e.prototype.getDiagramEngine=function(){return this.diagramEngine},e.prototype.clearSelection=function(t){void 0===t&&(t=null),this.getSelectedItems().forEach((function(e){t&&t.id===e.id||e.setSelected(!1)}))},e.prototype.getGridPosition=function(t){var e=t.x,n=t.y,o=this.gridSize$.getValue();return 0===o?{x:e,y:n}:{x:o*Math.floor((e+o/2)/o),y:o*Math.floor((n+o/2)/o)}},e.prototype.getSelectedItems=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];Array.isArray(t)||(t=[t]);var n=[];return n=(n=(n=n.concat(r.flatMap(this.nodes$.getValue(),(function(t){return t.getSelectedEntities()})))).concat(r.flatMap(this.links$.getValue(),(function(t){return t.getSelectedEntities()})))).concat(r.flatMap(this.links$.getValue(),(function(t){return r.flatMap(t.getPoints(),(function(t){return t.getSelectedEntities()}))}))),n=r.uniq(n),t.length>0&&(n=r.uniq(n).filter((function(e){return!!(t.includes("node")&&e instanceof E)||(!!(t.includes("link")&&e instanceof S)||(!!(t.includes("port")&&e instanceof O)||!!(t.includes("point")&&e instanceof _)))}))),n},e.prototype.addAll=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.forEach((function(e){e instanceof S?t.addLink(e):e instanceof E&&t.addNode(e)})),e},e}(C);var D=function(t,e){this.mouseX=t,this.mouseY=e,this.ms=(new Date).getTime()};var j=function(t){function e(e,n,o){var r=t.call(this,e,n)||this;return r.initialOffsetX=o.getOffsetX(),r.initialOffsetY=o.getOffsetY(),r}return l(e,t),e}(D);var R=function(t){function e(e,n){var o=t.call(this,e,n)||this;return o.mouseX2=e,o.mouseY2=n,o}return l(e,t),e.prototype.getBoxDimensions=function(){return this.dimensions={left:this.mouseX2>this.mouseX?this.mouseX:this.mouseX2,top:this.mouseY2>this.mouseY?this.mouseY:this.mouseY2,width:Math.abs(this.mouseX2-this.mouseX),height:Math.abs(this.mouseY2-this.mouseY),right:this.mouseX2<this.mouseX?this.mouseX:this.mouseX2,bottom:this.mouseY2<this.mouseY?this.mouseY:this.mouseY2},this.dimensions},e.prototype.containsElement=function(t,e){var n=t.x,o=t.y,r=e.getZoomLevel()/100,i=this.getBoxDimensions();return n*r+e.getOffsetX()>i.left&&n*r+e.getOffsetX()<i.right&&o*r+e.getOffsetY()>i.top&&o*r+e.getOffsetY()<i.bottom},e}(D);var N=function(t){function e(e,n,o){var r=t.call(this,e,n)||this;r.moved=!1;var i=o.getDiagramModel().getSelectedItems();return i=i.filter((function(t){return!(o.isModelLocked(t)||t instanceof S)})),r.selectionModels=i.map((function(t){var e=t.getCoords();return{model:t,initialX:e.x,initialY:e.y}})),r}return l(e,t),e}(D);var T=function(t){function e(e,n,o){var r=t.call(this,e,n)||this;return r.sourcePort=o.getSourcePort(),r.targetPort=o.getTargetPort(),r.link=o,r}return l(e,t),e.prototype.getOutPortNode=function(){return this.sourcePort.getParent()},e.prototype.getInPortNode=function(){return this.targetPort.getParent()},e}(D);var V=function(){function t(t,o){var i=this;this.renderer=t,this.cdRef=o,this.allowCanvasZoon=!0,this.allowCanvasTranslation=!0,this.inverseZoom=!0,this.allowLooseLinks=!0,this.actionStartedFiring=new e.EventEmitter,this.actionStillFiring=new e.EventEmitter,this.actionStoppedFiring=new e.EventEmitter,this.action$=new n.BehaviorSubject(null),this.destroyed$=new n.ReplaySubject(1),this.mouseUpListener=function(){},this.mouseMoveListener=function(){},this.onMouseUp=function(t){var e=i.diagramModel.getDiagramEngine(),n=i.action$.getValue();if(n instanceof N){var o=i.getMouseElement(t);n.selectionModels.forEach((function(n){if(n.model instanceof _&&o&&o.model instanceof O&&!e.isModelLocked(o.model)){var r=n.model.getLink();if(null!==r.getTargetPort())if(r.getTargetPort()!==o.model&&r.getSourcePort()!==o.model){var s=r.getTargetPort(),a=r.clone({});a.setSourcePort(o.model),a.setTargetPort(s),r.setTargetPort(o.model),s.removeLink(r),a.removePointsBefore(a.getPoints()[r.getPointIndex(n.model)]),r.removePointsAfter(n.model),e.getDiagramModel().addLink(a)}else r.getTargetPort()===o.model?r.removePointsAfter(n.model):r.getSourcePort()===o.model&&r.removePointsBefore(n.model);else{r.setTargetPort(o.model);s=r.getTargetPort();var l=r.getSourcePort();s.id!==l.id&&i.startFiringAction(new T(t.clientX,t.clientY,r))}}})),i.allowLooseLinks||n.selectionModels.forEach((function(t){if(t.model instanceof _){var e=t.model.getLink();null!==e.getSourcePort()&&null!==e.getTargetPort()||e.destroy()}})),n.selectionModels.forEach((function(t){if(t.model instanceof _){var e=t.model.getLink(),n=e.getSourcePort(),o=e.getTargetPort();null!==n&&null!==o&&(n.canLinkToPort(o)?r.some(Object.values(o.getLinks()),(function(t){return t!==e&&(t.getSourcePort()===n||t.getTargetPort()===n)}))&&e.destroy():e.destroy())}})),i.stopFiringAction()}else i.stopFiringAction();i.mouseUpListener(),i.mouseMoveListener(),i.action$.next(null)},this.onMouseMove=function(t){var e=i.action$.getValue();if(null!=e){if(e instanceof R){var n=i.diagramModel.getDiagramEngine().getRelativePoint(t.clientX,t.clientY);return Object.values(i.diagramModel.getNodes()).forEach((function(t){e.containsElement(t.getCoords(),i.diagramModel)?t.setSelected():t.setSelected(!1)})),Object.values(i.diagramModel.getLinks()).forEach((function(t){var n=!0;t.getPoints().forEach((function(t){e.containsElement(t.getCoords(),i.diagramModel)?t.setSelected():(t.setSelected(!1),n=!1)})),n&&t.setSelected()})),e.mouseX2=n.x,e.mouseY2=n.y,i.fireAction(),void i.action$.next(e)}if(e instanceof N){var o={x:t.clientX-e.mouseX,y:t.clientY-e.mouseY},r=i.diagramModel.getZoomLevel()/100;e.selectionModels.forEach((function(t){if(t.model instanceof E||t.model instanceof _&&!t.model.isConnectedToPort()){var e={x:t.initialX+o.x/r,y:t.initialY+o.y/r};t.model.setCoords(i.diagramModel.getGridPosition(e)),t.model instanceof E&&Object.values(t.model.getPorts()).forEach((function(t){var e=i.diagramModel.getDiagramEngine().getPortCoords(t);t.updateCoords(e)}))}else if(t.model instanceof _){e=i.diagramModel.getGridPosition({x:o.x/r,y:o.y/r});t.model.setCoords({x:t.initialX+e.x,y:t.initialY+e.y})}})),i.fireAction()}else e instanceof j&&i.allowCanvasTranslation&&(i.diagramModel.setOffset(e.initialOffsetX+(t.clientX-e.mouseX),e.initialOffsetY+(t.clientY-e.mouseY)),i.fireAction())}}}return t.prototype.ngOnInit=function(){var t=this;this.diagramModel&&(this.diagramModel.getDiagramEngine().setCanvas(this.canvas.nativeElement),this.nodes$=this.diagramModel.selectNodes(),this.links$=this.diagramModel.selectLinks(),this.nodesRendered$=new n.BehaviorSubject(!1),this.nodes$.pipe(o.takeUntil(this.destroyed$)).subscribe((function(e){t.nodesRendered$.next(!1),Object.values(e).forEach((function(e){e.getPainted()||(t.diagramModel.getDiagramEngine().generateWidgetForNode(e,t.nodesLayer),e.setPainted(),t.cdRef.detectChanges())})),t.nodesRendered$.next(!0)})))},t.prototype.ngOnDestroy=function(){this.destroyed$.next(!0),this.destroyed$.complete()},t.prototype.ngAfterViewInit=function(){var t=this;n.combineLatest([this.nodesRendered$,this.links$]).pipe(o.takeUntil(this.destroyed$),o.filter((function(t){var e=d(t,2),n=e[0];e[1];return!!n}))).subscribe((function(e){var n=d(e,2),o=(n[0],n[1]);Object.values(o).forEach((function(e){if(!e.getPainted()){if(null!==e.getSourcePort()){var n=t.diagramModel.getDiagramEngine().getPortCenter(e.getSourcePort());e.getPoints()[0].setCoords(n);var o=t.diagramModel.getDiagramEngine().getPortCoords(e.getSourcePort());e.getSourcePort().updateCoords(o)}if(null!==e.getTargetPort()){n=t.diagramModel.getDiagramEngine().getPortCenter(e.getTargetPort());e.getPoints()[e.getPoints().length-1].setCoords(n);o=t.diagramModel.getDiagramEngine().getPortCoords(e.getTargetPort());e.getTargetPort().updateCoords(o)}t.diagramModel.getDiagramEngine().generateWidgetForLink(e,t.linksLayer),e.setPainted(),t.cdRef.detectChanges()}}))}))},t.prototype.fireAction=function(){this.action$.value&&this.actionStillFiring.emit(this.action$.value)},t.prototype.stopFiringAction=function(t){t||this.actionStoppedFiring.emit(this.action$.value),this.action$.next(null)},t.prototype.startFiringAction=function(t){this.action$.next(t),this.actionStartedFiring.emit(t)},t.prototype.selectAction=function(){return this.action$},t.prototype.shouldDrawSelectionBox=function(){var t=this.action$.getValue();return t instanceof R&&(t.getBoxDimensions(),!0)},t.prototype.getMouseElement=function(t){var e=t.target,n=e.closest("[data-portid]");if(n){var o=e.closest("[data-nodeid]");return{model:this.diagramModel.getNode(o.getAttribute("data-nodeid")).getPort(n.getAttribute("data-portid")),element:n}}return(n=e.closest("[data-pointid]"))?{model:this.diagramModel.getLink(n.getAttribute("data-linkid")).getPointModel(n.getAttribute("data-pointid")),element:n}:(n=e.closest("[data-linkid]"))?{model:this.diagramModel.getLink(n.getAttribute("data-linkid")),element:n}:(n=e.closest("[data-nodeid]"))?{model:this.diagramModel.getNode(n.getAttribute("data-nodeid")),element:n}:null},t.prototype.onMouseDown=function(t){if(3!==t.button){var e=this.getMouseElement(t);if(null===e)if(t.shiftKey){var n=this.diagramModel.getDiagramEngine().getRelativePoint(t.clientX,t.clientY);this.startFiringAction(new R(n.x,n.y))}else this.diagramModel.clearSelection(),this.startFiringAction(new j(t.clientX,t.clientY,this.diagramModel));else if(e.model instanceof O)if(this.diagramModel.getDiagramEngine().isModelLocked(e.model))this.diagramModel.clearSelection();else{n=this.diagramModel.getDiagramEngine().getRelativeMousePoint(t);var o=e.model,r=o.createLinkModel();r.setSourcePort(o),r&&(r.removeMiddlePoints(),r.getSourcePort()!==o&&r.setSourcePort(o),r.setTargetPort(null),r.getFirstPoint().setCoords(n),r.getLastPoint().setCoords(n),this.diagramModel.clearSelection(),r.getLastPoint().setSelected(),this.diagramModel.addLink(r),this.startFiringAction(new N(t.clientX,t.clientY,this.diagramModel.getDiagramEngine())))}else t.shiftKey||e.model.getSelected()||this.diagramModel.clearSelection(),e.model.setSelected(),this.startFiringAction(new N(t.clientX,t.clientY,this.diagramModel.getDiagramEngine()));this.mouseMoveListener=this.renderer.listen(document,"mousemove",this.onMouseMove),this.mouseUpListener=this.renderer.listen(document,"mouseup",this.onMouseUp)}},t.prototype.onMouseWheel=function(t){if(this.allowCanvasZoon){t.preventDefault(),t.stopPropagation();var e=this.diagramModel.getZoomLevel(),n=e/100,o=this.inverseZoom?-t.deltaY:t.deltaY;t.ctrlKey&&o%1!=0?o/=3:o/=60,e+o>10&&this.diagramModel.setZoomLevel(e+o);var r=this.diagramModel.getZoomLevel()/100,i=t.currentTarget.getBoundingClientRect(),s=i.width,a=i.height,l=s*r-s*n,c=a*r-a*n,u=t.clientX-i.left,d=t.clientY-i.top,p=(u-this.diagramModel.getOffsetX())/n/s,h=(d-this.diagramModel.getOffsetY())/n/a;this.diagramModel.setOffset(this.diagramModel.getOffsetX()-l*p,this.diagramModel.getOffsetY()-c*h)}},t.decorators=[{type:e.Component,args:[{selector:"ngdx-diagram",template:"<div class=\"ngdx-diagram\" #canvas (mousedown)=\"onMouseDown($event)\" (wheel)=\"onMouseWheel($event)\">\n\t\x3c!-- Nodes Layer --\x3e\n\t<div\n\t\tclass=\"ngdx-nodes-layer\"\n\t\t[ngStyle]=\"{\n\t\t\ttransform:\n\t\t\t\t'translate(' +\n\t\t\t\t(diagramModel.selectOffsetX() | async) +\n\t\t\t\t'px, ' +\n\t\t\t\t(diagramModel.selectOffsetY() | async) +\n\t\t\t\t'px) scale(' +\n\t\t\t\t(diagramModel.selectZoomLevel() | async) / 100.0 +\n\t\t\t\t')'\n\t\t}\"\n\t>\n\t\t<ng-template #nodesLayer></ng-template>\n\t</div>\n\n\t\x3c!-- Links Layer --\x3e\n\t<div\n\t\tclass=\"ngdx-links-layer\"\n\t\t[ngStyle]=\"{\n\t\t\ttransform:\n\t\t\t\t'translate(' +\n\t\t\t\t(diagramModel.selectOffsetX() | async) +\n\t\t\t\t'px, ' +\n\t\t\t\t(diagramModel.selectOffsetY() | async) +\n\t\t\t\t'px) scale(' +\n\t\t\t\t(diagramModel.selectZoomLevel() | async) / 100.0 +\n\t\t\t\t')'\n\t\t}\"\n\t>\n\t\t<ng-template #linksLayer></ng-template>\n\t</div>\n\n\t\x3c!-- Selection Box --\x3e\n\t<div\n\t\t*ngIf=\"shouldDrawSelectionBox() && selectAction() | async as action\"\n\t\tclass=\"selector\"\n\t\t[ngStyle]=\"{\n\t\t\ttop: action.dimensions.top + 'px',\n\t\t\tleft: action.dimensions.left + 'px',\n\t\t\twidth: action.dimensions.width + 'px',\n\t\t\theight: action.dimensions.height + 'px'\n\t\t}\"\n\t></div>\n</div>\n",changeDetection:e.ChangeDetectionStrategy.OnPush,styles:[".ngdx-diagram{position:relative;flex-grow:1;display:flex;cursor:move;overflow:hidden}.ngdx-diagram .selector{position:absolute;background-color:rgba(0,192,255,.2);border:2px solid #00c0ff}.ngdx-diagram .ngdx-nodes-layer{position:absolute;height:100%;width:100%;transform-origin:0 0;overflow:visible!important;pointer-events:none;z-index:150;top:0;bottom:0;left:0;right:0}.ngdx-diagram .ngdx-links-layer{position:absolute;height:100%;width:100%;transform-origin:0 0;overflow:visible!important;pointer-events:none;z-index:100;top:0;bottom:0;left:0;right:0}"]}]}],t.ctorParameters=function(){return[{type:e.Renderer2},{type:e.ChangeDetectorRef}]},t.propDecorators={diagramModel:[{type:e.Input,args:["model"]}],allowCanvasZoon:[{type:e.Input}],allowCanvasTranslation:[{type:e.Input}],inverseZoom:[{type:e.Input}],allowLooseLinks:[{type:e.Input}],actionStartedFiring:[{type:e.Output}],actionStillFiring:[{type:e.Output}],actionStoppedFiring:[{type:e.Output}],nodesLayer:[{type:e.ViewChild,args:["nodesLayer",{read:e.ViewContainerRef,static:!0}]}],linksLayer:[{type:e.ViewChild,args:["linksLayer",{read:e.ViewContainerRef,static:!0}]}],canvas:[{type:e.ViewChild,args:["canvas",{read:e.ElementRef,static:!0}]}]},t}();var Y=function(t){function e(e){void 0===e&&(e="default");var n=t.call(this,e)||this;return n.color="rgba(255,255,255,0.5)",n.width=3,n.curvyness=50,n}return l(e,t),e.prototype.setWidth=function(t){this.width=t},e.prototype.setColor=function(t){this.color=t},e}(S);var A=function(t){function e(e){var n=void 0===e?{}:e,o=n.isInput,r=void 0===o||o,i=n.name,s=void 0===i?"port":i,a=n.type,l=void 0===a?"default":a,c=n.id,u=void 0===c?null:c,d=n.label,p=void 0===d?null:d,h=n.linkType,f=void 0===h?"default":h,g=t.call(this,s,l,u,null,f)||this;return g.in=r,g.label=p||s,g}return l(e,t),e.prototype.link=function(t){var e=this.createLinkModel();return e.setSourcePort(this),e.setTargetPort(t),e},e.prototype.canLinkToPort=function(t){return!(t instanceof e)||this.in!==t.in},e.prototype.createLinkModel=function(){return t.prototype.createLinkModel.call(this)||new Y(this.getLinkType())},e}(O);var X=function(t){function e(e,n,o,r){void 0===e&&(e="Untitled"),void 0===n&&(n="default"),void 0===r&&(r="rgb(0, 192, 255)");var i=t.call(this,n,o)||this;return i.name=e,i.color=r,i.height$=i.selectHeight(),i.width$=i.selectWidth(),i}return l(e,t),e.prototype.addInPort=function(t){var e=t.name,n=t.type,o=void 0===n?"default":n,r=t.id,i=t.linkType,s=new A({isInput:!0,name:e,type:o,id:r,label:null,linkType:void 0===i?"default":i});return this.addPort(s),s},e.prototype.addOutPort=function(t){var e=t.name,n=t.type,o=void 0===n?"default":n,r=t.id,i=t.linkType,s=new A({isInput:!1,name:e,type:o,id:r,label:null,linkType:void 0===i?"default":i});return this.addPort(s),s},e}(E);var B=function(t){function n(){return t.call(this,"ngdx-default-node")||this}return l(n,t),n.prototype.ngOnInit=function(){var t=this;this.selectPorts().subscribe((function(e){e.forEach((function(e){e.getPainted()||(t.generatePort(e),e.setPainted())}))}))},n.prototype.generatePort=function(t){this.diagramEngine.generateWidgetForPort(t,this.portsLayer)},n.decorators=[{type:e.Component,args:[{selector:"ngdx-default-node",template:"<div\n\tclass=\"default-node\"\n\t[ngStyle]=\"{\n\t\t'height.px': height$ | async,\n\t\t'width.px': width$ | async,\n\t\t'background-color': color\n\t}\"\n>\n\t<div class=\"ports\">\n\t\t<ng-template #portsLayer></ng-template>\n\t</div>\n</div>\n",styles:[":host.selected .default-node{background-color:#fff!important;border-color:#00f}:host .default-node{pointer-events:all;width:100%;border-radius:10px;transition:.3s ease-in-out;cursor:auto}:host .default-node .title{padding:10px;text-align:center;border-bottom:1px solid #00f}"]}]}],n.ctorParameters=function(){return[]},n.propDecorators={portsLayer:[{type:e.ViewChild,args:["portsLayer",{read:e.ViewContainerRef,static:!0}]}]},n}(X);var I=function(){function t(t){this._type=t}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),t}();var U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e}(I);var W=function(t){function e(e,n){var o=t.call(this,"default")||this;return o.resolver=e,o.renderer=n,o}return l(e,t),e.prototype.generateWidget=function(t,e,n){var o=this,r=n.createComponent(this.getRecipe()),i=r.location.nativeElement;return this.renderer.setStyle(i,"position","absolute"),this.renderer.setStyle(i,"display","block"),this.renderer.setAttribute(i,"data-nodeid",e.id),e.selectCoords().subscribe((function(t){var e=t.x,n=t.y;o.renderer.setStyle(i,"left",e+"px"),o.renderer.setStyle(i,"top",n+"px")})),e.selectionChanges().subscribe((function(t){t.isSelected?o.renderer.addClass(i,"selected"):o.renderer.removeClass(i,"selected")})),e.onEntityDestroy().subscribe((function(){r.destroy()})),Object.entries(e).forEach((function(t){var e=d(t,2),n=e[0],o=e[1];r.instance[n]=o})),r.instance.diagramEngine=t,r},e.prototype.getRecipe=function(){return this.resolver.resolveComponentFactory(B)},e.prototype.getNewInstance=function(t){return new(X.bind.apply(X,p([void 0,"default"],t)))},e}(U);var Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e}(I);var G=function(t){function n(){return t.call(this)||this}return l(n,t),n.decorators=[{type:e.Component,args:[{selector:"ngdx-default-port",template:"<div [ngClass]=\"in ? 'in' : 'out'\"></div>\n",styles:[":host{position:absolute;width:10px;height:10px;border-radius:60px;border:1px solid violet;background-color:#d3d3d3;margin:10px 0}:host:hover{background-color:green}:host.out{right:-5px}:host.in{left:-5px}"]}]}],n.ctorParameters=function(){return[]},n}(A),q=function(t){function e(e,n){var o=t.call(this,"default")||this;return o.resolver=e,o.renderer=n,o}return l(e,t),e.prototype.generateWidget=function(t,e){var n=e.createComponent(this.getRecipe()),o=n.location.nativeElement;return this.renderer.setAttribute(o,"data-portid",t.id),this.renderer.setAttribute(o,"data-name",t.getName()),t.in?this.renderer.addClass(o,"in"):this.renderer.addClass(o,"out"),Object.entries(t).forEach((function(t){var e=d(t,2),o=e[0],r=e[1];n.instance[o]=r})),t.onEntityDestroy().subscribe((function(){n.destroy()})),n},e.prototype.getRecipe=function(){return this.resolver.resolveComponentFactory(G)},e.prototype.getNewInstance=function(t){return new A(c({isInput:!0,name:"unknown"},t))},e}(Z);var z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e}(I);var H=function(t){function r(e){var o=t.call(this,"ngdx-default-link")||this;return o.cdRef=e,o._path$=new n.BehaviorSubject(null),o.path$=o._path$.asObservable(),o.points$=new n.BehaviorSubject([]),o}return l(r,t),r.prototype.ngAfterViewInit=function(){var t=this,e=this.getFirstPoint().selectCoords(),r=this.getLastPoint().selectCoords();n.combineLatest([e,r]).pipe(o.takeUntil(this.onEntityDestroy())).subscribe((function(e){var n=d(e,2),o=n[0],r=n[1],i=[o,r],s=Math.abs(o.x-r.x)>Math.abs(o.y-r.y)?"x":"y",a=!1;Math.abs(i[0][s]-i[1][s])<50&&(a=!0);var l=x(o,r,a?0:t.curvyness);if(t._path$.next(l),!t.getTargetPort()){var c=t.generatePoint(r);t.points$.next([c])}var u=t.getLabel();u&&u.setCoords(t.calcCenterOfPath(o,r)),t.cdRef.detectChanges()})),this.selectLabel().pipe(o.filter(Boolean)).subscribe((function(e){t.diagramEngine.generateWidgetForLabel(e,t.labelLayer),t.cdRef.detectChanges()}))},r.prototype.calcLabelIncline=function(t,e){var n=e.y-t.y,o=e.x-t.x;if(0===o)return 0;var r=180*Math.atan(n/o)/Math.PI;return r<0&&(r+=180),r},r.prototype.calcCenterOfPath=function(t,e){return{x:(t.x+e.x)/2+20,y:(t.y+e.y)/2+20}},r.decorators=[{type:e.Component,args:[{selector:"ngdx-default-link",template:'\x3c!-- Label Host --\x3e\n<ng-template #labelLayer></ng-template>\n\n\x3c!-- Link --\x3e\n<svg class="default-link">\n\t<g>\n\t\t<path [attr.stroke-width]="width" [attr.stroke]="color" [attr.d]="path$ | async"></path>\n\t\t<path\n\t\t\t(mouseleave)="setSelected(false)"\n\t\t\t(mouseenter)="setSelected()"\n\t\t\t[attr.stroke-width]="20"\n\t\t\t[attr.stroke]="color"\n\t\t\t[attr.stroke-linecap]="\'round\'"\n\t\t\t[attr.data-linkid]="id"\n\t\t\t[attr.stroke-opacity]="(selectSelected() | async) ? \'0.1\' : \'0\'"\n\t\t\t[attr.d]="path$ | async"\n\t\t></path>\n\t</g>\n\t<g *ngFor="let point of points$ | async">\n\t\t<circle [attr.cx]="point.selectX() | async" [attr.cy]="point.selectY() | async" r="5" class="default-point" />\n\n\t\t<circle\n\t\t\t(mouseleave)="setSelected(false)"\n\t\t\t(mouseenter)="setSelected()"\n\t\t\t[attr.data-id]="point.id"\n\t\t\t[attr.data-linkid]="id"\n\t\t\t[attr.cx]="point.selectX() | async"\n\t\t\t[attr.cy]="point.selectY() | async"\n\t\t\tr="15"\n\t\t\t[attr.opacity]="0"\n\t\t\tclass="default-point"\n\t\t\t[ngClass]="{ \'default-point\': true, selected: point.selectSelected() | async }"\n\t\t/>\n\t\t{{ point.selectSelected() | async }}\n\t</g>\n</svg>\n',styles:[".default-link{fill:none;overflow:visible}.default-link .default-point{fill:rgba(255,255,255,.5)}.default-link .default-point.selected{fill:rgba(0,0,255,.5)}@-webkit-keyframes dash{from{stroke-dashoffset:24}to{stroke-dashoffset:0}}@keyframes dash{from{stroke-dashoffset:24}to{stroke-dashoffset:0}}.default-link path{fill:none;pointer-events:all}.default-link.path-selected{stroke:#00c0ff!important;stroke-dasharray:10,2;-webkit-animation:1s linear infinite dash;animation:1s linear infinite dash}"]}]}],r.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},r.propDecorators={labelLayer:[{type:e.ViewChild,args:["labelLayer",{read:e.ViewContainerRef,static:!0}]}]},r}(Y);var K=function(t){function e(e,n){var o=t.call(this,"default")||this;return o.resolver=e,o.renderer=n,o}return l(e,t),e.prototype.generateWidget=function(t,e,n){var o=n.createComponent(this.getRecipe()),r=o.location.nativeElement;return this.renderer.setStyle(r,"position","absolute"),this.renderer.addClass(r,"label"),this.renderer.setAttribute(r,"data-linkid",e.id),e.onEntityDestroy().subscribe((function(){o.destroy()})),Object.entries(e).forEach((function(t){var e=d(t,2),n=e[0],r=e[1];o.instance[n]=r})),o.instance.diagramEngine=t,o},e.prototype.getRecipe=function(){return this.resolver.resolveComponentFactory(H)},e.prototype.getNewInstance=function(){return new Y},e}(z);var J=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[V],imports:[i.CommonModule],providers:[],exports:[V],entryComponents:[]}]}],t}(),Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return l(e,t),e}(I);var tt=function(t){function e(e,o){var r=t.call(this,e,o)||this;return r._coords=new n.BehaviorSubject({x:0,y:0}),r.coords$=r._coords.asObservable(),r._rotation=new n.BehaviorSubject(0),r.rotation$=r._rotation.asObservable(),r}return l(e,t),e.prototype.destroy=function(e){t.prototype.destroy.call(this,e)},e.prototype.setRotation=function(t){this._rotation.next(t)},e.prototype.selectRotation=function(){return this.rotation$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged())},e.prototype.setCoords=function(t){this._coords.next(c({},this._coords.getValue(),t))},e.prototype.selectCoords=function(){return this.coords$.pipe(o.takeUntil(this.onEntityDestroy()),o.distinctUntilChanged())},e}($);var et=function(t){function e(e,o){void 0===e&&(e="NO LABEL"),void 0===o&&(o="default");var r=t.call(this,o)||this;return r._label=new n.BehaviorSubject(""),r.label$=r._label.asObservable(),r.setLabel(e),r}return l(e,t),e.prototype.setLabel=function(t){this._label.next(t)},e.prototype.getLabel=function(){return this._label.getValue()},e.prototype.selectLabel=function(){return this.label$},e}(tt);var nt=function(t){function n(){return t.call(this,"ngdx-default-label")||this}return l(n,t),n.decorators=[{type:e.Component,args:[{selector:"ngdx-default-label",template:"<div\n\tclass=\"default-label\"\n\t[ngStyle]=\"{\n\t\ttransform:\n\t\t\t'translate(' +\n\t\t\t(selectCoords() | async).x +\n\t\t\t'px, ' +\n\t\t\t(selectCoords() | async).y +\n\t\t\t'px)' +\n\t\t\t'rotate(' +\n\t\t\t(selectRotation() | async) +\n\t\t\t'deg)'\n\t}\"\n>\n\t{{ label$ | async }}\n</div>\n",styles:[".default-label{color:#fff;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}"]}]}],n.ctorParameters=function(){return[]},n}(et),ot=function(t){function e(e,n){var o=t.call(this,"default")||this;return o.resolver=e,o.renderer=n,o}return l(e,t),e.prototype.generateWidget=function(t,e){var n=e.createComponent(this.getRecipe()),o=n.location.nativeElement;return this.renderer.setStyle(o,"position","absolute"),this.renderer.setAttribute(o,"data-labelid",t.id),t.onEntityDestroy().subscribe((function(){n.destroy()})),Object.entries(t).forEach((function(t){var e=d(t,2),o=e[0],r=e[1];n.instance[o]=r})),n},e.prototype.getRecipe=function(){return this.resolver.resolveComponentFactory(nt)},e.prototype.getNewInstance=function(){return new et},e}(Q);var rt=function(){function t(t,e){this.resolver=t,this.rendererFactory=e,this._renderer=this.rendererFactory.createRenderer(null,null),this.nodeFactories={},this.linkFactories={},this.portFactories={},this.labelFactories={},this.canvas$=new n.BehaviorSubject(null)}return t.prototype.createDiagram=function(){return this.diagramModel=new F(this),this.diagramModel},t.prototype.registerDefaultFactories=function(){this.registerNodeFactory(new W(this.resolver,this._renderer)),this.registerPortFactory(new q(this.resolver,this._renderer)),this.registerLinkFactory(new K(this.resolver,this._renderer)),this.registerLabelFactory(new ot(this.resolver,this._renderer))},t.prototype.registerLabelFactory=function(t){this.labelFactories[t.type]=t},t.prototype.getLabelFactories=function(){return this.labelFactories},t.prototype.getLabelFactory=function(t){if(this.labelFactories[t])return this.labelFactories[t];throw new Error("cannot find factory for node of type: ["+t+"]")},t.prototype.getFactoryForLabel=function(t){return this.getLabelFactory(t.getType())},t.prototype.generateWidgetForLabel=function(t,e){var n=this.getFactoryForLabel(t);if(!n)throw new Error("Cannot find widget factory for node: "+t.getType());return n.generateWidget(t,e)},t.prototype.registerNodeFactory=function(t){this.nodeFactories[t.type]=t},t.prototype.getNodeFactories=function(){return this.nodeFactories},t.prototype.getNodeFactory=function(t){if(this.nodeFactories[t])return this.nodeFactories[t];throw new Error("cannot find factory for node of type: ["+t+"]")},t.prototype.getFactoryForNode=function(t){return this.getNodeFactory(t.getType())},t.prototype.generateWidgetForNode=function(t,e){var n=this.getFactoryForNode(t);if(!n)throw new Error("Cannot find widget factory for node: "+t.getType());return n.generateWidget(this,t,e)},t.prototype.registerPortFactory=function(t){this.portFactories[t.type]=t},t.prototype.getPortFactories=function(){return this.portFactories},t.prototype.getPortFactory=function(t){if(this.portFactories[t])return this.portFactories[t];throw new Error("cannot find factory for port of type: ["+t+"]")},t.prototype.getFactoryForPort=function(t){return this.getPortFactory(t.getType())},t.prototype.generateWidgetForPort=function(t,e){var n=this.getFactoryForPort(t);if(!n)throw new Error("Cannot find widget factory for port: "+t.getType());return n.generateWidget(t,e)},t.prototype.getLinkFactories=function(){return this.linkFactories},t.prototype.registerLinkFactory=function(t){this.linkFactories[t.type]=t},t.prototype.getLinkFactory=function(t){if(this.linkFactories[t])return this.linkFactories[t];throw new Error("cannot find factory for link of type: ["+t+"]")},t.prototype.getFactoryForLink=function(t){return this.getLinkFactory(t.getType())},t.prototype.generateWidgetForLink=function(t,e){var n=this.getFactoryForLink(t);if(!n)throw new Error("Cannot find link factory for link: "+t.getType());return n.generateWidget(this,t,e)},t.prototype.getNodeElement=function(t){var e=this.canvas$.getValue().querySelector('[data-nodeid="'+t.id+'"]');if(null===e)throw new Error("Cannot find Node element with node id: ["+t.id+"]");return(e)},t.prototype.getNodePortElement=function(t){var e=this.canvas$.getValue().querySelector('[data-nodeid="'+t.getParent().id+'"] [data-portid="'+t.id+'"]');if(null===e)throw new Error("Cannot find Node Port element with node id: ["+t.getParent().id+"] and port id: ["+t.id+"]");return(e)},t.prototype.getPortCenter=function(t){var e=this.getNodePortElement(t),n=e.getBoundingClientRect(),o=this.getRelativePoint(n.left,n.top);return{x:e.offsetWidth/2+(o.x-this.diagramModel.getOffsetX())/(this.diagramModel.getZoomLevel()/100),y:e.offsetHeight/2+(o.y-this.diagramModel.getOffsetY())/(this.diagramModel.getZoomLevel()/100)}},t.prototype.getPortCoords=function(t){var e=this.getNodePortElement(t).getBoundingClientRect(),n=this.canvas$.getValue().getBoundingClientRect();return{x:(e.x-this.diagramModel.getOffsetX())/(this.diagramModel.getZoomLevel()/100)-n.left,y:(e.y-this.diagramModel.getOffsetY())/(this.diagramModel.getZoomLevel()/100)-n.top,width:e.width,height:e.height}},t.prototype.getNodeDimensions=function(t){if(!this.canvas$.getValue())return{width:0,height:0};var e=this.getNodeElement(t).getBoundingClientRect();return{width:e.width,height:e.height}},t.prototype.setCanvas=function(t){this.canvas$.next(t)},t.prototype.getRelativeMousePoint=function(t){var e=this.getRelativePoint(t.clientX,t.clientY);return{x:(e.x-this.diagramModel.getOffsetX())/(this.diagramModel.getZoomLevel()/100),y:(e.y-this.diagramModel.getOffsetY())/(this.diagramModel.getZoomLevel()/100)}},t.prototype.getRelativePoint=function(t,e){var n=this.canvas$.getValue().getBoundingClientRect();return{x:t-n.left,y:e-n.top}},t.prototype.getDiagramModel=function(){return this.diagramModel},t.prototype.isModelLocked=function(t){return!!this.diagramModel.getLocked()||t.getLocked()},t.prototype.autoArrange=function(){},t.prototype.zoomToFit=function(t){var e=this;void 0===t&&(t=.005),this.canvas$.pipe(o.filter(Boolean),o.take(1),o.delay(0)).subscribe((function(n){var o=n.clientWidth/n.scrollWidth,r=n.clientHeight/n.scrollHeight,i=o<r?o:r;e.diagramModel.setZoomLevel(e.diagramModel.getZoomLevel()*(i-t)),e.diagramModel.setOffset(0,0)}))},t.decorators=[{type:e.Injectable,args:[{providedIn:J}]}],t.ctorParameters=function(){return[{type:e.ComponentFactoryResolver},{type:e.RendererFactory2}]},t.ngInjectableDef=e.ɵɵdefineInjectable({factory:function(){return new t(e.ɵɵinject(e.ComponentFactoryResolver),e.ɵɵinject(e.RendererFactory2))},token:t,providedIn:J}),t}();var it=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[H],imports:[i.CommonModule],providers:[],exports:[H],entryComponents:[H]}]}],t}(),st=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[B],imports:[i.CommonModule],providers:[],exports:[B],entryComponents:[B]}]}],t}(),at=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[G],imports:[i.CommonModule],providers:[],exports:[G],entryComponents:[G]}]}],t}(),lt=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{declarations:[nt],imports:[i.CommonModule],providers:[],exports:[nt],entryComponents:[nt]}]}],t}();var ct=function(){};var ut=function(){function t(){}return t.prototype.redistribute=function(t,e){void 0===e&&(e={});var n=new s.graphlib.Graph({multigraph:!0});n.setGraph(e.graph||{}),n.setDefaultEdgeLabel((function(){return{}}));var o={};Object.values(t.getNodes()).forEach((function(t){n.setNode(t.id,{width:t.getWidth(),height:t.getHeight()})})),Object.values(t.getLinks()).forEach((function(t){t.getSourcePort()&&t.getTargetPort()&&(o[t.id]=!0,n.setEdge({v:t.getSourcePort().getNode().id,w:t.getTargetPort().getNode().id,name:t.id}))})),s.layout(n,e.layout),n.nodes().forEach((function(e){var o=n.node(e),r=o.x,i=o.y;t.getNode(e).setCoords({x:r,y:i})})),e.includeLinks&&n.edges().forEach((function(e){for(var o=n.edge(e),r=t.getLink(e.name),i=[r.getFirstPoint()],s=1;s<o.points.length-2;s++)i.push(new _(r,{x:o.points[s].x,y:o.points[s].y}));r.setPoints(i.concat(r.getLastPoint()))}))},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[]},t}();t.AbstractFactory=I,t.AbstractLabelFactory=Q,t.AbstractLinkFactory=z,t.AbstractNodeFactory=U,t.AbstractPortFactory=Z,t.BaseAction=D,t.BaseEvent=P,t.BaseModel=$,t.DagreEngine=ut,t.DefaultLabelFactory=ot,t.DefaultLabelModel=et,t.DefaultLabelModule=lt,t.DefaultLinkFactory=K,t.DefaultLinkModel=Y,t.DefaultLinkModule=it,t.DefaultNodeFactory=W,t.DefaultNodeModel=X,t.DefaultNodeModule=st,t.DefaultPortFactory=q,t.DefaultPortModel=A,t.DefaultPortModule=at,t.DiagramEngine=rt,t.DiagramModel=F,t.LOG_LEVEL=h,t.LabelModel=tt,t.LinkCreatedAction=T,t.LinkModel=S,t.LockEvent=k,t.MoveCanvasAction=j,t.MoveItemsAction=N,t.NgxDiagramComponent=V,t.NgxDiagramsModule=J,t.NodeModel=E,t.PaintedEvent=M,t.ParentChangeEvent=L,t.PathFinding=ct,t.PointModel=_,t.PortModel=O,t.ROUTING_SCALING_FACTOR=5,t.SelectingAction=R,t.SelectionEvent=w,t.UID=v,t.arrayToMap=function(t){var e,n,o={};try{for(var r=u(t),i=r.next();!i.done;i=r.next()){var s=i.value;m(s)||(o[s.id]=s)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return o},t.coerceArray=function(t){return m(t)?[]:Array.isArray(t)?t:[t]},t.enableDiagramProdMode=function(){t.__DEV__=!1},t.generateCurvePath=x,t.generateLinePath=function(t,e){return"M"+t.x$+","+t.y+" L "+e.x$+","+e.y},t.isArray=function(t){return Array.isArray(t)},t.isDev=f,t.isFunction=function(t){return"function"==typeof t},t.isNil=m,t.isString=function(t){return"string"==typeof t},t.log=g,t.mapToArray=b,t.setLogLevel=function(e){t.__LOG__=e},t.withLog=y,t.ɵa=H,t.ɵb=Y,t.ɵc=S,t.ɵd=$,t.ɵe=C,t.ɵg=B,t.ɵh=X,t.ɵi=E,t.ɵj=G,t.ɵk=A,t.ɵl=O,t.ɵm=nt,t.ɵn=et,t.ɵo=tt,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ngx-diagrams.umd.min.js.map