@balkangraph/familytree2.js
Version:
Build family tree app with BALKAN FamilyTree JS library. Family Tree also called a genealogy or a pedigree chart, is a chart representing family relationships in a conventional tree structure.
1 lines • 345 kB
JavaScript
/* eslint-disable */
var FlowChart=class{_;options;element;svgElement;shapeBar;colorBar;menuBar;statusBar;editor;nodes;labels;links;ports;selectedShapes;active;get useChangeListener(){return this._.useChangeListener}set useChangeListener(t){this._.useChangeListener=t}get defs(){return this.svgElement.querySelector("defs").innerHTML}set defs(t){this.svgElement.querySelector("defs").innerHTML=t}get mode(){return this.options.mode}set mode(t){this.options.mode=t,this.element.classList.remove("bfc-dark"),this.element.classList.remove("bfc-light"),this.element.classList.add("bfc-"+this.options.mode),this.svgElement.classList.remove("bfc-dark"),this.svgElement.classList.remove("bfc-light"),this.svgElement.classList.add("bfc-"+this.options.mode)}get viewBox(){return this._.getViewBox()}set viewBox(t){this._.snap(),this._.setViewBox(t),this._.changed({property:"viewBox"})}get selectedPortShape(){return this._.selectedPortShape}set selectedPortShape(t){null==t?(this._.selectedPortShape=null,null!=this.selectedPort&&(this.selectedPort=null),this._.hidePortsUI()):t!=this._.selectedPortShape&&(this._.selectedPortShape=t,this._.showPortsUI())}get selectedPort(){return this._.selectedPort}set selectedPort(t){if(this._.selectedPort!=t){var e={oldPort:this._.selectedPort,newPort:t};!1!==FlowChart.events.publish("selected-port-change",[this._.chart,e])&&(null==t?(this._.selectedPort=null,this._.hidePortShapeBarUI()):this._.selectedPort!=t&&(this.selectedPortShape!=t.shape&&(this.selectedPortShape=t.shape),this._.selectedPort=t,this._.showPortShapeBar()))}}get scale(){return this._.getScale()}set scale(t){if(this.scale!=t){var e=FlowChart.private.getViewBoxByScale(t,this.options,this.viewBox,this._.svgBCR);this.viewBox=e}}static MAGNET_MOVE_PIXELS=10;static MAGNET_RESIZE_PIXELS=7;static MAGNET_WIN_PIXELS=10;static MAGNET_PORT=20;static LINK_DITSNANCE=20;static LINK_ROUNDED_CORENERS=7;static MOVE_NODE_STEP=3;static SCALE_FACTOR=1.44;static DEFAULT_LINK_SHAPE_ID="rounded";static DEFAULT_LABEL_SHAPE_ID="label";static CHANGED_TIMEOUT=700;static PADDING=30;static SEPARATOR=":";static PORTSEPARATOR="~";static shortcuts={open_up_port:{keysPressed:["control","!shift","arrowup"],activeComponentType:"node|port-shape-bar|field",desc:"Open port above the shape"},open_down_port:{keysPressed:["control","!shift","arrowdown"],activeComponentType:"node|port-shape-bar|field",desc:"Open port below the shape"},open_left_port:{keysPressed:["control","!shift","arrowleft"],activeComponentType:"node|port-shape-bar|field",desc:"Open left port"},open_right_port:{keysPressed:["control","!shift","arrowright"],activeComponentType:"node|port-shape-bar|field",desc:"Open right port"},navigate_port_down:{keysPressed:["!control","!shift","arrowdown"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_left:{keysPressed:["!control","!shift","arrowleft"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_right:{keysPressed:["!control","!shift","arrowright"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},navigate_port_up:{keysPressed:["!control","!shift","arrowup"],activeComponentType:"port-shape-bar",desc:"Select shape from the opened port shape bar"},undo:{keysPressed:["control","keyz"],desc:"Undo"},redo:{keysPressed:["control","keyy"],desc:"Redo"},select_all_nodes:{keysPressed:["control","keya"],desc:"Selectd all nodes"},select_multiple_nodes:{keysPressed:["shift"],desc:"Selectd multiple nodes or shapes"},resize_node:{mouseActions:["resize-shape"],desc:"Resize shape"},centered_resize_shape:{keysPressed:["control"],mouseActions:["resize-shape"],desc:"Centered resize"},maintain_aspect_ratio_resize_shape:{keysPressed:["shift"],mouseActions:["resize-shape"],activeComponentType:"shape",desc:"Resize and maintain proportions"},remove_selected_shapes:{keysPressed:["delete|backspace"],activeComponentType:"shape",desc:"Remove selected shapes"},zoom:{keysPressed:["control"],mouseActions:["wheel"],desc:"Zoom In/Out"},move_selected_nodes_left:{keysPressed:["arrowleft","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_right:{keysPressed:["arrowright","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_up:{keysPressed:["arrowup","control","shift"],desc:"Move selected nodes with arrow keys"},move_selected_nodes_down:{keysPressed:["arrowdown","control","shift"],desc:"Move selected nodes with arrow keys"},select_node_left:{keysPressed:["arrowleft","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the left"},select_node_right:{keysPressed:["arrowright","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the right"},select_node_above:{keysPressed:["arrowup","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the top"},select_node_below:{keysPressed:["arrowdown","!control","!shift"],activeComponentType:"node",desc:"Select the closest node on the bottom"},select_nodes_left:{keysPressed:["arrowleft","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_right:{keysPressed:["arrowright","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_above:{keysPressed:["arrowup","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},select_nodes_below:{keysPressed:["arrowdown","!control","shift"],activeComponentType:"node",desc:"Select multiple nodes"},align_tofirst_selected_nodes_top:{keysPressed:["keyt","!shift"],activeComponentType:"node",desc:"Align top to the first selected node"},align_tofirst_selected_nodes_bottom:{keysPressed:["keyb","!shift"],activeComponentType:"node",desc:"Align bottom to the first selected node"},align_tofirst_selected_nodes_left:{keysPressed:["keyl","!shift"],activeComponentType:"node",desc:"Align left to the first selected node"},align_tofirst_selected_nodes_right:{keysPressed:["keyr","!shift"],activeComponentType:"node",desc:"Align right to the first selected node"},align_tofirst_selected_nodes_horizontally:{keysPressed:["keye","!shift"],activeComponentType:"node",desc:"Align center horizontally to the first selected node"},align_tofirst_selected_nodes_vertically:{keysPressed:["keyc","!shift"],activeComponentType:"node",desc:"Align center vertically to the first selected node"},align_tolast_selected_nodes_top:{keysPressed:["keyt","shift"],activeComponentType:"node",desc:"Align top to the last selected node"},align_tolast_selected_nodes_bottom:{keysPressed:["keyb","shift"],activeComponentType:"node",desc:"Align bottom to the last selected node"},align_tolast_selected_nodes_left:{keysPressed:["keyl","shift"],activeComponentType:"node",desc:"Align left to the last selected node"},align_tolast_selected_nodes_right:{keysPressed:["keyr","shift"],activeComponentType:"node",desc:"Align right to the last selected node"},align_tolast_selected_nodes_horizontally:{keysPressed:["keye","shift"],activeComponentType:"node",desc:"Align center horizontally to the last selected node"},align_tolast_selected_nodes_vertically:{keysPressed:["keyc","shift"],activeComponentType:"node",desc:"Align center vertically to the last selected node"},paint_node:{keysPressed:["digit1|digit2|digit3|digit4|digit5|digit6|digit7|digit8|digit9|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9"],activeComponentType:"node",desc:"Change color"},add_shape:{keysPressed:["enter"],activeComponentType:"port-shape-bar",desc:"Add node"},edit_next_field:{keysPressed:["tab"],activeComponentType:"field",desc:"Focus next field"},exit_edit_field:{keysPressed:["escape"],activeComponentType:"field",desc:"Finish editing"},close_port_shape_bar:{keysPressed:["escape"],activeComponentType:"port-shape-bar",desc:"Hide port shape bar"},deleselect_shapes:{keysPressed:["escape"],activeComponentType:"shape",desc:"Unselect shapes"},edit_shape:{keysPressed:["enter|numpadenter|space"],activeComponentType:"shape",desc:"Edit shape"},fit_to_page:{keysPressed:["keyf"],activeComponentType:"all-nodes",desc:"Fit to page"},replace_div_with_br_on_enter:{keysPressed:["enter|numpadenter"],activeComponentType:"field",desc:""}};static isNEU(t){return null==t||""===t}static isMobile=function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)};static animate=function(t,e,i,a,r,o,s){return FlowChart.private.animate(t,e,i,a,r,o,s)};constructor(t,e){("string"==typeof t||t instanceof String)&&(t=document.querySelector(t)),this.options=FlowChart.private.mergeDeep(FlowChart.private.defaultOptions(),e),this.element=t,this.svgElement=null,this.shapeBar=new FlowChart.ShapeBar(this),this.colorBar=new FlowChart.ColorBar(this),this.menuBar=new FlowChart.MenuBar(this),this.statusBar=new FlowChart.StatusBar(this),this.selectedShapes=new FlowChart.SelectedShapeCollection(this),this.editor=new FlowChart.Editor(this),this.ports=new FlowChart.PortCollection(this),this.nodes=new FlowChart.ShapeCollection(this),this.links=new FlowChart.LinkCollection(this),this.labels=new FlowChart.ShapeCollection(this),this.active=null,this._=new FlowChart.private(this),FlowChart.events.publish("init",[this])}addNodeWithLink(t,e,i){this._.addNodeWithLink(t,e,i)}load(t){this._.load(t)}json(t){return this._.json(t)}text(t){return this._.text(t)}svg(){return this._.svg()}exportSVG(){var t=new Blob([this.svg()],{type:"image/svg+xml"});FlowChart.private.downloadFile(t,"flowchart.svg",!1,"svg")}getShape(t){return this._.getShape(t)}generateId(){return this._.generateId()}undo(){this._.undo()}redo(){this._.redo()}undoStepsCount(){return this._.undoStepsCount()}redoStepsCount(){return this._.redoStepsCount()}clearRedo(){this._.clearRedo()}clearUndo(){this._.clearUndo()}alignShapes(t,e,i){this._.alignShapes(t,e,i)}reposition(t,e,i,a){this._.reposition(t,e,i,a)}rippleShape(t,e,i){FlowChart.private.rippleShape(t,e,i)}makeShapesVisible(t,e){this._.makeShapesVisible(t,e)}destroy(){if(FlowChart.events.topics={},this.element){this.element.innerHTML="";var t=this.element.cloneNode(!0);this.element.parentNode.replaceChild(t,this.element),this.element=t}}onInit(t){return this._.on("init",function(e,i){return t.call(e,i)})}onChanged(t){return this._.on("changed",function(e,i){return t.call(e,i)})}onUndoRedoChanged(t){return this._.on("undo-redo-changed",function(e,i){return t.call(e,i)})}onSelectedShapeChanging(t){return this._.on("selected-shape-changing",function(e,i){return t.call(e,i)})}onSelectedShapesChanged(t){return this._.on("selected-shapes-changed",function(e,i){return t.call(e,i)})}onSelectedPortChange(t){return this._.on("selected-port-change",function(e,i){return t.call(e,i)})}onShortcut(t){return this._.on("shortcut",function(e,i){return t.call(e,i)})}onMenuItemClick(t){return this._.on("menu-item-click",function(e,i){return t.call(e,i)})}onLinkPoints(t){return this._.on("link-points",function(e,i){return t.call(e,i)})}onLinkClick(t){return this._.on("link-click",function(e,i){return t.call(e,i)})}onShapeDoubleClick(t){return this._.on("shape-db-click",function(e,i){return t.call(e,i)})}onShapeClick(t){return this._.on("shape-click",function(e,i){return t.call(e,i)})}onSvgClick(t){return this._.on("svg-click",function(e,i){return t.call(e,i)})}onFieldChange(t){return this._.on("field-change",function(e,i){return t.call(e,i)})}};void 0===FlowChart&&(FlowChart={}),FlowChart.VERSION="1.01.82","undefined"!=typeof module&&(module.exports=FlowChart),FlowChart.private=class{chart;mouseActions;keysPressed;mouseOverShape;mouseOverShapeType;touchendEnabledDevice;uid;useChangeListener;initialized;changedTimeout;changedArgs;selectedPortShape;selectedPort;lastAddedTemplateIdFormPortShapeBar;changeFillPressedIndexes;changeFillPressedTimeout;makeShapesVisibleInterval;svgBCR;shortcuts;static defaultOptions(){return{mode:"light",startPosition:FlowChart.startPosition.center,startScale:1,interactive:!0,loadFromSession:!1,useSession:!0,statusBar:!0,colors:["#039BE5","#F57C00","#FFCA28"],scaleMax:4,scaleMin:.5,selectable:!0,editable:!0,nodeSeparation:100,zoom:{speed:120,smooth:12}}}static countFlowCharts=0;constructor(t){this.chart=t,this.shortcuts=JSON.parse(FlowChart.private.safeStringify(FlowChart.shortcuts)),this.mouseActions=[],this.keysPressed=[],this.matchedShortcuts=[],this.mouseOverShape=null,this.mouseOverShapeType=null,this.touchendEnabledDevice=!1,this.useChangeListener=!0,this.initialized=!1,this.changedTimeout=null,this.changedArgs={properties:[]},this.selectedPortShape=null,this.selectedPort=null,this.uid=window.location.pathname+"/flow-chart/"+FlowChart.private.countFlowCharts,FlowChart.private.countFlowCharts++,this.changeFillPressedIndexes=[],this.changeFillPressedTimeout=null,this.makeShapesVisibleInterval=null,this.init()}snap(){this.useChangeListener&&(this.changedTimeout||(this.putInUndoStack(),this.clearRedo()))}addNodeWithLink(t,e,i){var a=this,r={templateId:e};(r=this.chart.nodes.add(r)).element.style.opacity=0;var o=this.chart.links.getByShape(t.shape),s=[];for(var l of o)this.chart.ports.getByLink(l).fromPort==t&&(h=this.chart.nodes.get(l.to))&&s.push(h.id);var n=[];for(var h of this.chart.nodes)n.push({x:h.x,y:h.y,w:h.width,h:h.height,id:h.id});FlowChart.private.devin({nodeDiscriptors:n,neighborNodeIds:s,newNodeId:r.id,parentNodeId:t.shape.id,position:t.position,options:this.chart.options},function(e){var o=[],s=[],l=[],n=a.chart.scale;for(var h of e){var d=a.chart.nodes.get(h.id),p={x:h.x,y:h.y,opacity:1};if(r==d){var c={x:h.x,y:h.y,opacity:0};switch(t.position){case FlowChart.position.left:c.x+=8/n;break;case FlowChart.position.right:c.x-=8/n;break;case FlowChart.position.top:c.y+=8/n;break;case FlowChart.position.bottom:c.y-=8/n;break;case FlowChart.position.topLeft:c.y+=8/n,c.x+=8/n;break;case FlowChart.position.bottomLeft:c.y-=8/n,c.x+=8/n;break;case FlowChart.position.bottomRight:c.y-=8/n,c.x-=8/n;break;case FlowChart.position.topRight:c.y+=8/n,c.x-=8/n}s.push(c)}else s.push({x:d.x,y:d.y,opacity:0});l.push(p),d.x=-1e4,d.y=-1e4,o.push(d)}for(var f=0;f<o.length;f++)o[f].x=s[f].x,o[f].y=s[f].y;a.animateShapes(o,s,l,function(){i&&i.call(a.chart,r,m),a.makeShapesVisible([o],function(){var t=a.chart.editor.getFieldNames(r);t.length&&a.chart.editor.edit(r,t[0])})});var u=a.chart.ports.getByOpositeOfPosition(r.id,t.position)[0],m={from:t.shape.id,to:u.shape.id,fromPort:t.id,toPort:u.id,templateId:"rounded"};m=a.chart.links.add(m)})}changed(t){if(this.useChangeListener){var e=this;for(var i in t){var a=t[i];(i="property")&&-1==this.changedArgs.properties.indexOf(a)&&this.changedArgs.properties.push(a)}"selectedShapes"==t.property&&(FlowChart.events.publish("selected-shapes-changed",[e.chart]),this.chart.editor.clearFieldBorders()),this.changedTimeout&&(clearTimeout(this.changedTimeout),this.changedTimeout=null),this.changedTimeout=setTimeout(function(){e.changedTimeout=null;var t=e.chart.text(["shapes","links","viewBox","selectedShapes"]);if(e.chart.options.useSession)try{sessionStorage.setItem(`${e.uid}_state`,t)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}FlowChart.events.publish("changed",[e.chart,e.changedArgs]),e.changedArgs={properties:[]}},FlowChart.CHANGED_TIMEOUT)}}load(t){if(this.useChangeListener=!1,this.chart.nodes.clear(),this.chart.labels.clear(),this.chart.links.clear(),!this.initialized&&this.chart.options.loadFromSession){var e=sessionStorage.getItem(`${this.uid}_state`);e&&(t=JSON.parse(e))}if(t){if(t.nodes&&this.chart.nodes.addRange(t.nodes),t.links&&this.chart.links.addRange(t.links),t.labels&&this.chart.labels.addRange(t.labels),t.selectedShapes)for(var i of t.selectedShapes){var a=this.chart.getShape(i);a&&(a.selected=!0)}t.viewBox&&(this.setViewBox(t.viewBox),this.initialized=!0)}this.initialized||(this.chart.scale=this.chart.options.startScale,this.chart.reposition(),this.initialized=!0),this.useChangeListener=!0;var r=this.chart.text(["shapes","links","viewBox","selectedShapes"]);if(this.chart.options.useSession)try{sessionStorage.setItem(`${this.uid}_state`,r)}catch(t){t.code==t.QUOTA_EXCEEDED_ERR&&sessionStorage.clear(),console.error(t)}}alignShapes(t,e,i){if(t.length){this.chart.selectedPortShape=null,t.length;var a=t[t.length-1];i&&(t.length,a=t[0]);for(var r=0;r<t.length;r++){var o=t[r];e==FlowChart.position.top?o.y=a.y-a.height/2+o.height/2:e==FlowChart.align.bottom?o.y=a.y+a.height/2-o.height/2:e==FlowChart.align.left?o.x=a.x-a.width/2+o.width/2:e==FlowChart.align.right?o.x=a.x+a.width/2-o.width/2:e==FlowChart.align.vertically?o.x=a.x:e==FlowChart.align.horizontally&&(o.y=a.y)}}}getShape(t){var e=this.chart.nodes.get(t);return e||(e=this.chart.labels.get(t)),e}generateId(){for(var t=this.chart.nodes.length+this.chart.labels.length;;){if(!this.chart.nodes.contains(t)&&!this.chart.labels.contains(t))return t;t++}}init(){this.chart.element.classList.add("bfc-"+this.chart.mode),this.chart.element.classList.add("frame"),this.chart.element.innerHTML=` ${FlowChart.css()}\n <svg class="bfc-svg bfc-${this.chart.options.mode}"> \n <defs></defs> \n <g data-layer="-3"></g>\n <g data-layer="-2"></g>\n <g data-layer="-1"></g>\n <foreignObject class="bfc-html" x="90000" y="90000" width="10000" height="10000"><div data-test-elastic-size style="height: initial; display: inline-block;" class="bfc-flex-center"></div></foreignObject>\n </svg>\n <div data-statusbar class="bfc-statusbar">\n \n </div>\n <div data-shapebar class="bfc-shapebar" style="display: none;"></div>\n <div data-colorbar class="bfc-colorbar" style="display: none;"></div>\n <div data-menubar class="bfc-menubar bfc-horizontal-bar" style="display: none;"></div>${FlowChart.private.logo(this.chart.options.logoSvg)}`,this.chart.svgElement=this.chart.element.querySelector(".bfc-svg"),this.svgBCR=this.chart.svgElement.getBoundingClientRect();var t=[0,0,this.svgBCR.width,this.svgBCR.height];this.chart.svgElement.setAttribute("viewBox",t.join(",")),this.chart.menuBar.init(),this.chart.shapeBar.init(),this.chart.colorBar.init(),this.chart.statusBar.init(),this.addListeners()}getViewBox=function(){var t=null;return this.chart.svgElement?(t=(t="["+(t=this.chart.svgElement.getAttribute("viewBox"))+"]").replace(/\ /g,","),t=JSON.parse(t)):null};setViewBox(t){isNaN(t[2])&&console.log("not ok"),this.chart.svgElement.setAttribute("viewBox",t.toString());var e=FlowChart.private.getScale(t,this.svgBCR.width,this.svgBCR.height);this.updatePortsElement(e)}getScale(){if(this.svgBCR.width>0&&this.svgBCR.height>0){var t=FlowChart.private.getScale(this.chart.viewBox,this.svgBCR.width,this.svgBCR.height);return isNaN(t),t}return console.log(`setViewBox -> this.svgBCR.width: ${this.svgBCR.width}; this.svgBCR.height: ${this.svgBCR.height};`),0}on(t,e){return FlowChart.events.on(t,e,this.uid),this.chart}getSizeOfHTML(t){t&&(t=t.replaceAll("contenteditable"," "));var e=this.chart.svgElement.querySelector("[data-test-elastic-size]");e.innerHTML=t;var i=e.getBoundingClientRect(),a=this.chart.scale;return{width:i.width/a+6,height:i.height/a+6}}getActiveComponentTypes(){if(null!=this.chart.selectedPort)return["port-shape-bar"];if(this.chart.editor.hasActiveField())return["field"];var t=[];return this.chart.selectedShapes.nodes.length&&t.push("node"),this.chart.selectedShapes.labels.length&&t.push("label"),t.length?(t.push("shape"),this.chart.selectedShapes.nodes.length==this.chart.nodes.length&&t.push("all-nodes"),t):"canvas"}zoom(t,e,i,a){var r=this,o=this.chart.viewBox,s=o,l=o[2],n=o[3];!0===t?(o[2]=o[2]/FlowChart.SCALE_FACTOR,o[3]=o[3]/FlowChart.SCALE_FACTOR):!1===t?(o[2]=o[2]*FlowChart.SCALE_FACTOR,o[3]=o[3]*FlowChart.SCALE_FACTOR):(o[2]=o[2]/t,o[3]=o[3]/t),e||(e=[50,50]),o[0]=s[0]-(o[2]-l)/(100/e[0]),o[1]=s[1]-(o[3]-n)/(100/e[1]);var h=FlowChart.private.getScale(o,this.svgBCR.width,this.svgBCR.height);o[2]=this.svgBCR.width/h,o[3]=this.svgBCR.height/h;var d=this.chart.options;(!0===t&&h<d.scaleMax||!1===t&&h>d.scaleMin||!1!==t&&!0!==t&&h<d.scaleMax&&h>d.scaleMin)&&(i?(this._zoomTimeout&&(clearTimeout(this._zoomTimeout),this._zoomTimeout=null),this._zoomTimeout=FlowChart.animate(this.chart.svgElement,{viewBox:this.chart.viewBox},{viewBox:o},300,FlowChart.anim.outPow,function(){a&&a.call(r.chart)})):(this.chart.viewBox=o,a&&a.call(r.chart)))}updateMatchedShortcuts(t,e,i){this.matchedShortcuts=[];var a=this.getActiveComponentTypes();for(var r in this.shortcuts)if(!this.matchedShortcuts.includes(r)){var o=!0,s=!0,l=!0,n=this.shortcuts[r];if(n.keysPressed)for(var h=0;h<n.keysPressed.length;h++){var d,p=n.keysPressed[h];d=-1!=p.indexOf("|")?p.split("|"):[p];var c=!1;for(var f of d)0==f.indexOf("!")?(f=f.substring(1),this.keysPressed.includes(f)||(c=!0)):this.keysPressed.includes(f)&&(c=!0);if(!c){o=!1;break}var u=!1;if(n.activeComponentType){var m=n.activeComponentType.split("|");for(var y of m)a.includes(y)&&(u=!0)}else u=!0;if(!u){l=!1;break}}else e&&n.keyDown?n.keyDown!=e&&(o=!1):i&&n.keyUp&&n.keyUp!=i&&(o=!1);if(n.mouseActions)for(h=0;h<n.mouseActions.length;h++)if(!this.mouseActions.includes(n.mouseActions[h])){s=!1;break}if(s&&o&&l){this.matchedShortcuts.includes(r)||this.matchedShortcuts.push(r);var g=this.chart.selectedShapes,v=this.chart.selectedShapes.nodes;if("move_selected_nodes_left"==r)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.left);else if("move_selected_nodes_right"==r)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.right);else if("move_selected_nodes_up"==r)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.up);else if("move_selected_nodes_down"==r)this.chart.selectedPortShape=null,this.chart.nodes._.move(v,FlowChart.move.down);else if("align_tofirst_selected_nodes_bottom"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.bottom,!0);else if("align_tofirst_selected_nodes_top"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.top,!0);else if("align_tofirst_selected_nodes_left"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.left,!0);else if("align_tofirst_selected_nodes_right"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.right,!0);else if("align_tofirst_selected_nodes_horizontally"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.horizontally,!0);else if("align_tofirst_selected_nodes_vertically"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.vertically,!0);else if("align_tolast_selected_nodes_bottom"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.bottom,!1);else if("align_tolast_selected_nodes_top"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.top,!1);else if("align_tolast_selected_nodes_left"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.left,!1);else if("align_tolast_selected_nodes_right"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.right,!1);else if("align_tolast_selected_nodes_horizontally"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.horizontally,!1);else if("align_tolast_selected_nodes_vertically"==r)t.preventDefault(),this.chart.alignShapes(g,FlowChart.align.vertically,!1);else if("remove_selected_shapes"==r)this.chart.nodes.removeRange(this.chart.selectedShapes.nodes),this.chart.labels.removeRange(this.chart.selectedShapes.labels);else if("select_all_nodes"==r)for(var w of(t.preventDefault(),this.chart.nodes))"label"!=w.type&&this.chart.selectedShapes.add(w);else if("undo"==r)this.chart._.undo(),this.chart.menuBar._.simulateMouseClickOnKeydown("undo");else if("redo"==r)this.chart._.redo(),this.chart.menuBar._.simulateMouseClickOnKeydown("redo");else if("open_up_port"==r)this.showPortShapeBarUI(FlowChart.position.top);else if("open_down_port"==r)this.showPortShapeBarUI(FlowChart.position.bottom);else if("open_left_port"==r)this.showPortShapeBarUI(FlowChart.position.left);else if("open_right_port"==r)this.showPortShapeBarUI(FlowChart.position.right);else if("navigate_port_down"==r)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.bottom);else if("navigate_port_left"==r)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.left);else if("navigate_port_right"==r)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.right);else if("navigate_port_up"==r)t.preventDefault(),this.navigatePortShapeBarItems(FlowChart.position.top);else if("add_shape"==r)this.chart.editor.blur(),t.preventDefault(),this.chart._.createNodeFromPorsShapeBarItem();else if("edit_next_field"==r)t.preventDefault(),this.chart.editor.selectNextField();else if("exit_edit_field"==r)this.chart.editor.blur();else if("close_port_shape_bar"==r)this.chart.selectedPort=null;else if("deleselect_shapes"==r)this.chart.selectedShapes.clear();else if("edit_shape"==r){var x=this.chart.selectedShapes.last;t.preventDefault(),this.chart.editor.editFirstFieldIfAny(x)}else if("select_node_above"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeAbove(!0);else if("select_node_below"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeBelow(!0);else if("select_node_left"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeLeft(!0);else if("select_node_right"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeRight(!0);else if("select_nodes_above"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeAbove(!1);else if("select_nodes_below"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeBelow(!1);else if("select_nodes_left"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeLeft(!1);else if("select_nodes_right"==r)t.preventDefault(),this.chart.editor.blur(),this.chart.selectedShapes.selectNodeRight(!1);else if("paint_node"==r){if(null!=e){var b=parseInt(e)-1;this.changeFill(b),this.chart.colorBar._.simulateMouseClickOnKeydown(`color-${b}`)}}else if("fit_to_page"==r)this.chart.reposition(FlowChart.startPosition.fit);else if("replace_div_with_br_on_enter"==r){for(var C=t.target;C&&C.hasAttribute&&!C.hasAttribute("data-shape-id");)C=C.parentNode;if(C){var F=C.getAttribute("data-shape-id");if(this.chart.selectedShapes.contains(F)){if(13==t.keyCode){t.preventDefault();const e=window.getSelection(),i=e.getRangeAt(0);var I=document.getSelection().anchorNode.parentNode.nodeName.toUpperCase();switch(I){case"P":case"DIV":default:I="BR";break;case"SPAN":I="span";break;case"BR":I=null}const a=document.createElement(I);i.deleteContents(),i.insertNode(a),"BR"===I?(i.setStartAfter(a),i.setEndAfter(a)):(i.setStart(a,0),i.setEnd(a,0));const r=document.createTextNode("");i.insertNode(r),i.setStartBefore(r),i.setEndBefore(r),e.removeAllRanges(),e.addRange(i),t.stopPropagation()}t.target.value=t.target.innerHTML}}}FlowChart.events.publish("shortcut",[this.chart,{name:r,event:t}])}}}changeFill(t){t=parseInt(t)+1;var e=this;-1==this.changeFillPressedIndexes.indexOf(t)&&this.changeFillPressedIndexes.push(t),this.changeFillPressedTimeout&&(clearTimeout(this.changeFillPressedTimeout),this.changeFillPressedTimeout=null),this.changeFillPressedTimeout=setTimeout(function(){e.changeFillPressedIndexes=[]},500);for(var i="",a=0;a<this.changeFillPressedIndexes.length;a++)i+=this.changeFillPressedIndexes[a].toString();t=parseInt(i)-1;for(var r=this.chart.options.colors[t];!r&&i.length;)i=i.substring(1),t=parseInt(i)-1,r=this.chart.options.colors[t];if(r)for(var o of this.chart.selectedShapes)o.fill!=r&&(o.fill=r)}},void 0===FlowChart&&(FlowChart={}),FlowChart.position=Object.freeze({top:"top",bottom:"bottom",left:"left",right:"right",topLeft:"topLeft",topRight:"topRight",bottomLeft:"bottomLeft",bottomRight:"bottomRight"}),FlowChart.align=Object.freeze({top:"top",bottom:"bottom",left:"left",right:"right",horizontally:"horizontally",vertically:"vertically"}),FlowChart.move=Object.freeze({up:"up",down:"down",left:"left",right:"right"}),FlowChart.direction=Object.freeze({vertical:"vertical",horizontal:"horizontal"}),FlowChart.startPosition=Object.freeze({none:"none",fitHeight:"fitHeight",fitWidth:"fitWidth",fit:"fit",fit1:"fit1",centerShapes:"centerShapes",centerTop:"centerTop",centerBottom:"centerBottom",centerLeft:"centerLeft",centerRight:"centerRight",center:"center"}),FlowChart.private.animate=function(t,e,i,a,r,o,s){var l,n=10,h=1,d=a/n+1;return document.getElementsByTagName("g"),Array.isArray(t)||(t=[t]),Array.isArray(e)||(e=[e]),Array.isArray(i)||(i=[i]),l=setInterval(function(){for(var p=0;p<t.length;p++)for(var c in i[p]){var f=["top","left","right","bottom","width","height"].includes(c.toLowerCase())?"px":"";if("node"==t[p].type||"label"==t[p].type){var u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c];switch(c){case"x":case"y":case"width":case"height":case"opacity":t[p][c]=u;break;default:t[p].element.style[c]=u}}else switch(c){case"d":var m=r((h*n-n)/a)*(i[p][c][0]-e[p][c][0])+e[p][c][0],y=r((h*n-n)/a)*(i[p][c][1]-e[p][c][1])+e[p][c][1];t[p].setAttribute("d",t[p].getAttribute("d")+" L"+m+" "+y);break;case"r":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("r",u);break;case"x1":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("x1",u);break;case"x2":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("x2",u);break;case"y1":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("y1",u);break;case"y2":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("y2",u);break;case"rotate3d":if(i[p][c]){var g=e[p][c],v=i[p][c],w=[0,0,0,0];for(var x in g)w[x]=r((h*n-n)/a)*(v[x]-g[x])+g[x];t[p].style.transform="rotate3d("+w.toString()+"deg)"}break;case"transform":if(i[p][c]){for(var x in g=e[p][c],v=i[p][c],w=[0,0,0,0,0,0],g)w[x]=r((h*n-n)/a)*(v[x]-g[x])+g[x];t[p].hasAttribute("transform")?t[p].setAttribute("transform","matrix("+w.toString()+")"):t[p].style.transform="matrix("+w.toString()+")"}break;case"translate":if(i[p][c]){for(var x in g=e[p][c],v=i[p][c],w=[0,0],g)w[x]=r((h*n-n)/a)*(v[x]-g[x])+g[x];t[p].setAttribute("transform","translate("+w.toString()+")")}break;case"viewBox":if(i[p][c]){for(var x in g=e[p][c],v=i[p][c],w=[0,0,0,0],g)w[x]=r((h*n-n)/a)*(v[x]-g[x])+g[x];t[p].setAttribute("viewBox",w.toString())}break;case"margin":if(i[p][c]){for(var x in g=e[p][c],v=i[p][c],w=[0,0,0,0],g)w[x]=r((h*n-n)/a)*(v[x]-g[x])+g[x];var b="";for(x=0;x<w.length;x++)b+=parseInt(w[x])+"px ";t[p]&&t[p].style&&(t[p].style[c]=b)}break;case"scrollY":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].scrollTo(0,u);break;case"stdDeviation":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("stdDeviation",u);break;case"baseFrequency":u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p].setAttribute("baseFrequency",u);break;default:u=r((h*n-n)/a)*(i[p][c]-e[p][c])+e[p][c],t[p]&&t[p].style&&(t[p].style[c]=u+f)}}s&&s(),(h+=1)>d+1&&(clearInterval(l),o&&o(t))},n)},FlowChart.private.linkFromTo=function(t,e,i,a,r){var o=[];if(i.position==FlowChart.position.right&&a.position==FlowChart.position.left)if(t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE){var s=t.left+t.width+(e.left-(t.left+t.width))/2;o.push({x:i.x,y:i.y}),o.push({x:s,y:i.y}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})}else if(t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var l=t.top+t.height+(e.top-(t.top+t.height))/2;o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})}else if(t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE)l=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y});else if(i.y<=a.y&&t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE){var n=Math.min(t.top,e.top);o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})}else if(i.y>a.y&&t.left+FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE){var h=Math.max(t.top+t.height,e.top+e.height);o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})}else o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y});else if(i.position==FlowChart.position.left&&a.position==FlowChart.position.right)t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:s,y:i.y}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(l=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):i.y<=a.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(n=Math.min(t.top,e.top),o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):i.y>a.y&&t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(h=Math.max(t.top+t.height,e.top+e.height),o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y}));else if(i.position==FlowChart.position.bottom&&a.position==FlowChart.position.top)if(t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE)l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:a.x,y:l}),o.push({x:a.x,y:a.y});else if(t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE)s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y});else if(t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE)s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y});else if(i.x<=a.x&&t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var d=Math.min(t.left,e.left);o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})}else if(i.x>a.x&&t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE){var p=Math.max(t.left+t.width,e.left+e.width);o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})}else o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y});else i.position==FlowChart.position.top&&a.position==FlowChart.position.bottom?t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(l=e.top+e.height+(t.top-(e.top+e.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:a.x,y:l}),o.push({x:a.x,y:a.y})):t.left+t.width+FlowChart.LINK_DITSNANCE<e.left-FlowChart.LINK_DITSNANCE?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):t.left-FlowChart.LINK_DITSNANCE>e.left+e.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):i.x<=a.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):i.x>a.x&&t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.bottom&&a.position==FlowChart.position.left?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.y+FlowChart.LINK_DITSNANCE<a.y&&i.x<e.left-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<e.top-FlowChart.LINK_DITSNANCE?(l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE?(h=Math.max(t.top+t.height,e.top+e.height),d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.bottom&&a.position==FlowChart.position.right?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.y<a.y&&i.x>e.left+e.width+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE<=e.top-FlowChart.LINK_DITSNANCE?(l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE?(h=Math.max(t.top+t.height,e.top+e.height),p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:h+FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+t.height+FlowChart.LINK_DITSNANCE>e.top?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.top&&a.position==FlowChart.position.left?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.y>a.y&&i.x<e.left-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:a.y}),o.push({x:a.x,y:a.y})):t.top-FlowChart.LINK_DITSNANCE>=e.top+e.height+FlowChart.LINK_DITSNANCE?(l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE&&t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE?(n=Math.min(t.top,e.top),d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+FlowChart.LINK_DITSNANCE<e.top+e.height?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.top&&a.position==FlowChart.position.right?t.left+t.width+FlowChart.LINK_DITSNANCE>e.left-FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE&&t.top+t.height+FlowChart.LINK_DITSNANCE>e.top-FlowChart.LINK_DITSNANCE&&t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.y-FlowChart.LINK_DITSNANCE>a.y&&i.x>e.left+e.width+FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:a.y}),o.push({x:a.x,y:a.y})):t.top-FlowChart.LINK_DITSNANCE>e.top+e.height+FlowChart.LINK_DITSNANCE?(l=t.top+t.height+(e.top-(t.top+t.height))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:l}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top-FlowChart.LINK_DITSNANCE<e.top+e.height+FlowChart.LINK_DITSNANCE&&t.left-FlowChart.LINK_DITSNANCE<e.left+e.width+FlowChart.LINK_DITSNANCE?(n=Math.min(t.top,e.top),p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.top+FlowChart.LINK_DITSNANCE<e.top+e.height?(s=t.left+t.width+(e.left-(t.left+t.width))/2,o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.right&&a.position==FlowChart.position.right?a.x<i.x?t.top-FlowChart.LINK_DITSNANCE>a.y||t.top+t.height+FlowChart.LINK_DITSNANCE<a.y?(o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):e.left+e.width+FlowChart.LINK_DITSNANCE<t.left-FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):e.top-FlowChart.LINK_DITSNANCE>i.y||e.top+e.height+FlowChart.LINK_DITSNANCE<i.y?(p=Math.max(t.left+t.width,e.left+e.width),o.push({x:i.x,y:i.y}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:p+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):e.left+e.width-(t.left+t.width)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left+t.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left+e.width+FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.left&&a.position==FlowChart.position.left?a.x>i.x?t.top-FlowChart.LINK_DITSNANCE>a.y||t.top+t.height+FlowChart.LINK_DITSNANCE<a.y?(o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):e.left-FlowChart.LINK_DITSNANCE>t.left+t.width+FlowChart.LINK_DITSNANCE?(s=e.left+e.width+(t.left-(e.left+e.width))/2,o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:s,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):e.top-FlowChart.LINK_DITSNANCE>i.y||e.top+e.height+FlowChart.LINK_DITSNANCE<i.y?(d=Math.min(t.left,e.left),o.push({x:i.x,y:i.y}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:d-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):t.left-(e.left+e.width)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:i.y}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top+e.height+FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:a.y}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.top&&a.position==FlowChart.position.top?a.y<i.y?t.left-FlowChart.LINK_DITSNANCE>a.x||t.left+t.width+FlowChart.LINK_DITSNANCE<a.x?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:e.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):e.left-FlowChart.LINK_DITSNANCE>i.x||e.left+e.width+FlowChart.LINK_DITSNANCE<i.x?(n=Math.min(t.top,e.top),o.push({x:i.x,y:i.y}),o.push({x:i.x,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:n-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):e.top+e.height-(t.top+t.height)>FlowChart.LINK_DITSNANCE?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:t.top-FlowChart.LINK_DITSNANCE}),o.push({x:t.left-FlowChart.LINK_DITSNANCE,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:e.top-FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):(o.push({x:i.x,y:i.y}),o.push({x:a.x,y:a.y})):i.position==FlowChart.position.bottom&&a.position==FlowChart.position.bottom?a.y<i.y?t.left-FlowChart.LINK_DITSNANCE>a.x||t.left+t.width+FlowChart.LINK_DITSNANCE<a.x?(o.push({x:i.x,y:i.y}),o.push({x:i.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:t.top+t.height+FlowChart.LINK_DITSNANCE}),o.push({x:a.x,y:a.y})):e.top+e.height+FlowChart.LINK_DITSNANCE<t.top-FlowChart.LINK_DITSNANCE?(o.push(