var cola;!function(a){function b(a,b,c,e,f){function g(a){function b(a){var b=Number.MAX_VALUE,c=Number.MAX_VALUE,d=0,f=0;a.array.forEach(function(a){var g="undefined"!=typeof a.width?a.width:e,h="undefined"!=typeof a.height?a.height:e;g/=2,h/=2,d=Math.max(a.x+g,d),b=Math.min(a.x-g,b),f=Math.max(a.y+h,f),c=Math.min(a.y-h,c)}),a.width=d-b,a.height=f-c}a.forEach(function(a){b(a)})}function h(a){a.forEach(function(a){var b={x:0,y:0};a.array.forEach(function(a){b.x+=a.x,b.y+=a.y}),b.x/=a.array.length,b.y/=a.array.length;var c={x:b.x-a.width/2,y:b.y-a.height/2},d={x:a.x-c.x+p/2-r/2,y:a.y-c.y+q/2-s/2};a.array.forEach(function(a){a.x+=d.x,a.y+=d.y})})}function i(a,b){var c=Number.POSITIVE_INFINITY,e=0;a.sort(function(a,b){return b.height-a.height}),t=a.reduce(function(a,b){return a.widtht||o>d.FLOAT_EPSILON;){if(1!=m)var p=g-(g-f)/d.GOLDEN_SECTION,i=j(a,p);if(0!=m)var q=f+(g-f)/d.GOLDEN_SECTION,k=j(a,q);if(n=Math.abs(p-q),o=Math.abs(i-k),c>i&&(c=i,e=p),c>k&&(c=k,e=q),i>k?(f=p,p=q,i=k,m=1):(g=q,q=p,k=i,m=0),h++>100)break}j(a,e)}function j(a,b){v=[],r=0,s=0,u=o;for(var c=0;c=a.height&&v[e].x+v[e].width+a.width+d.PADDING-b<=d.FLOAT_EPSILON){c=v[e];break}v.push(a),void 0!==c?(a.x=c.x+c.width+d.PADDING,a.y=c.bottom,a.space_left=a.height,a.bottom=a.y,c.space_left-=a.height+d.PADDING,c.bottom+=a.height+d.PADDING):(a.y=u,u+=a.height+d.PADDING,a.x=n,a.bottom=a.y,a.space_left=a.height),a.y+a.height-s>-d.FLOAT_EPSILON&&(s=a.y+a.height-o),a.x+a.width-r>-d.FLOAT_EPSILON&&(r=a.x+a.width-n)}function l(a){var b=0;return a.forEach(function(a){return b+=a.width+d.PADDING}),b}function m(){return r/s}void 0===f&&(f=1);var n=0,o=0,p=b,q=c,f="undefined"!=typeof f?f:1,e="undefined"!=typeof e?e:0,r=0,s=0,t=0,u=0,v=[];0!=a.length&&(g(a),i(a,f),h(a))}function c(a,b){function c(a,b){if(void 0===d[a.index]){b&&(g++,f.push({array:[]})),d[a.index]=g,f[g-1].array.push(a);var h=e[a.index];if(h)for(var i=0;ia;++a)this.ps.addVariable(this.vars[a]);this.posn=this.ps.getPosn()},a.prototype.compute_lm=function(a,b,c){var d=this,e=a.dfdv();return a.visitNeighbours(b,function(b,f){var g=d.compute_lm(f,a,c);f===b.right?(e+=g*b.left.scale,b.lm=g):(e+=g*b.right.scale,b.lm=-g),c(b)}),e/a.scale},a.prototype.populateSplitBlock=function(a,b){var c=this;a.visitNeighbours(b,function(b,d){d.offset=a.offset+(d===b.right?b.gap:-b.gap),c.addVariable(d),c.populateSplitBlock(d,a)})},a.prototype.traverse=function(a,b,c,d){var e=this;void 0===c&&(c=this.vars[0]),void 0===d&&(d=null),c.visitNeighbours(d,function(d,f){b.push(a(d)),e.traverse(a,b,f,c)})},a.prototype.findMinLM=function(){var a=null;return this.compute_lm(this.vars[0],null,function(b){!b.equality&&(null===a||b.lmd;++d){var f=a.vars[d];f.offset+=c,this.addVariable(f)}this.posn=this.ps.getPosn()},a.prototype.cost=function(){for(var a=0,b=this.vars.length;b--;){var c=this.vars[b],d=c.position()-c.desiredPosition;a+=d*d*c.weight}return a},a}();a.Block=e;var f=function(){function a(a){this.vs=a;var b=a.length;for(this.list=new Array(b);b--;){var c=new e(a[b]);this.list[b]=c,c.blockInd=b}}return a.prototype.cost=function(){for(var a=0,b=this.list.length;b--;)a+=this.list[b].cost();return a},a.prototype.insert=function(a){a.blockInd=this.list.length,this.list.push(a)},a.prototype.remove=function(a){var b=this.list.length-1,c=this.list[b];this.list.length=b,a!==c&&(this.list[a.blockInd]=c,c.blockInd=a.blockInd)},a.prototype.merge=function(a){var b=a.left.block,c=a.right.block,d=a.right.offset-a.left.offset-a.gap;b.vars.lengthg;++g){var h=d[g];if(!h.unsatisfiable){var i=h.slack();if((h.equality||b>i)&&(b=i,c=h,f=g,h.equality))break}}return f!==e&&(b=0?this.inactive.push(b):this.bs.merge(b)}}},a.prototype.solve=function(){this.satisfy();for(var a=Number.MAX_VALUE,b=this.bs.cost();Math.abs(a-b)>1e-4;)this.satisfy(),a=b,b=this.bs.cost();return b},a.LAGRANGIAN_TOLERANCE=-1e-4,a.ZERO_UPPERBOUND=-1e-10,a}();a.Solver=g}(b=a.vpsc||(a.vpsc={}))}(cola||(cola={}));var __extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},cola;!function(a){var b;!function(a){var b=function(){function a(){this.findIter=function(a){for(var b=this._root,c=this.iterator();null!==b;){var d=this._comparator(a,b.data);if(0===d)return c._cursor=b,c;c._ancestors.push(b),b=b.get_child(d>0)}return null}}return a.prototype.clear=function(){this._root=null,this.size=0},a.prototype.find=function(a){for(var b=this._root;null!==b;){var c=this._comparator(a,b.data);if(0===c)return b.data;b=b.get_child(c>0)}return null},a.prototype.lowerBound=function(a){return this._bound(a,this._comparator)},a.prototype.upperBound=function(a){function b(a,b){return c(b,a)}var c=this._comparator;return this._bound(a,b)},a.prototype.min=function(){var a=this._root;if(null===a)return null;for(;null!==a.left;)a=a.left;return a.data},a.prototype.max=function(){var a=this._root;if(null===a)return null;for(;null!==a.right;)a=a.right;return a.data},a.prototype.iterator=function(){return new c(this)},a.prototype.each=function(a){for(var b,c=this.iterator();null!==(b=c.next());)a(b)},a.prototype.reach=function(a){for(var b,c=this.iterator();null!==(b=c.prev());)a(b)},a.prototype._bound=function(a,b){for(var c=this._root,d=this.iterator();null!==c;){var e=this._comparator(a,c.data);if(0===e)return d._cursor=c,d;d._ancestors.push(c),c=c.get_child(e>0)}for(var f=d._ancestors.length-1;f>=0;--f)if(c=d._ancestors[f],b(a,c.data)>0)return d._cursor=c,d._ancestors.length=f,d;return d._ancestors.length=0,d},a}();a.TreeBase=b;var c=function(){function a(a){this._tree=a,this._ancestors=[],this._cursor=null}return a.prototype.data=function(){return null!==this._cursor?this._cursor.data:null},a.prototype.next=function(){if(null===this._cursor){var a=this._tree._root;null!==a&&this._minNode(a)}else if(null===this._cursor.right){var b;do{if(b=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.right===b)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return null!==this._cursor?this._cursor.data:null},a.prototype.prev=function(){if(null===this._cursor){var a=this._tree._root;null!==a&&this._maxNode(a)}else if(null===this._cursor.left){var b;do{if(b=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.left===b)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return null!==this._cursor?this._cursor.data:null},a.prototype._minNode=function(a){for(;null!==a.left;)this._ancestors.push(a),a=a.left;this._cursor=a},a.prototype._maxNode=function(a){for(;null!==a.right;)this._ancestors.push(a),a=a.right;this._cursor=a},a}();a.Iterator=c;var d=function(){function a(a){this.data=a,this.left=null,this.right=null,this.red=!0}return a.prototype.get_child=function(a){return a?this.right:this.left},a.prototype.set_child=function(a,b){a?this.right=b:this.left=b},a}(),e=function(a){function b(b){a.call(this),this._root=null,this._comparator=b,this.size=0}return __extends(b,a),b.prototype.insert=function(a){var c=!1;if(null===this._root)this._root=new d(a),c=!0,this.size++;else{var e=new d(void 0),f=!1,g=!1,h=null,i=e,j=null,k=this._root;for(i.right=this._root;;){if(null===k?(k=new d(a),j.set_child(f,k),c=!0,this.size++):b.is_red(k.left)&&b.is_red(k.right)&&(k.red=!0,k.left.red=!1,k.right.red=!1),b.is_red(k)&&b.is_red(j)){var l=i.right===h;k===j.get_child(g)?i.set_child(l,b.single_rotate(h,!g)):i.set_child(l,b.double_rotate(h,!g))}var m=this._comparator(k.data,a);if(0===m)break;g=f,f=0>m,null!==h&&(i=h),h=j,j=k,k=k.get_child(f)}this._root=e.right}return this._root.red=!1,c},b.prototype.remove=function(a){if(null===this._root)return!1;var c=new d(void 0),e=c;e.right=this._root;for(var f=null,g=null,h=null,i=!0;null!==e.get_child(i);){var j=i;g=f,f=e,e=e.get_child(i);var k=this._comparator(a,e.data);if(i=k>0,0===k&&(h=e),!b.is_red(e)&&!b.is_red(e.get_child(i)))if(b.is_red(e.get_child(!i))){var l=b.single_rotate(e,i);f.set_child(j,l),f=l}else if(!b.is_red(e.get_child(!i))){var m=f.get_child(!j);if(null!==m)if(b.is_red(m.get_child(!j))||b.is_red(m.get_child(j))){var n=g.right===f;b.is_red(m.get_child(j))?g.set_child(n,b.double_rotate(f,j)):b.is_red(m.get_child(!j))&&g.set_child(n,b.single_rotate(f,j));var o=g.get_child(n);o.red=!0,e.red=!0,o.left.red=!1,o.right.red=!1}else f.red=!1,m.red=!0,e.red=!0}}return null!==h&&(h.data=e.data,f.set_child(f.right===e,e.get_child(null===e.left)),this.size--),this._root=c.right,null!==this._root&&(this._root.red=!1),null!==h},b.is_red=function(a){return null!==a&&a.red},b.single_rotate=function(a,b){var c=a.get_child(!b);return a.set_child(!b,c.get_child(b)),c.set_child(b,a),a.red=!0,c.red=!1,c},b.double_rotate=function(a,c){return a.set_child(!c,b.single_rotate(a.get_child(!c),!c)),b.single_rotate(a,c)},b}(b);a.RBTree=e}(b=a.vpsc||(a.vpsc={}))}(cola||(cola={}));var cola;!function(a){var b;!function(a){function b(a){return a.bounds="undefined"!=typeof a.leaves?a.leaves.reduce(function(a,b){return b.bounds.union(a)},p.empty()):p.empty(),"undefined"!=typeof a.groups&&(a.bounds=a.groups.reduce(function(a,c){return b(c).union(a)},a.bounds)),a.bounds=a.bounds.inflate(a.padding),a.bounds}function c(a,b,c){var d=a.rayIntersection(b.cx(),b.cy())||{x:a.cx(),y:a.cy()},e=b.rayIntersection(a.cx(),a.cy())||{x:b.cx(),y:b.cy()},f=e.x-d.x,g=e.y-d.y,h=Math.sqrt(f*f+g*g),i=h-c;return{sourceIntersection:d,targetIntersection:e,arrowStart:{x:d.x+i*f/h,y:d.y+i*g/h}}}function d(a,b,c){var d=b.rayIntersection(a.x,a.y);d||(d={x:b.cx(),y:b.cy()});var e=d.x-a.x,f=d.y-a.y,g=Math.sqrt(e*e+f*f);return{x:d.x-c*e/g,y:d.y-c*f/g}}function e(a,b){return a.pos>b.pos?1:a.pos=i);var k=new Array(j);for(h=0;i>h;++h){var l=b[h],m=new q(c[h],l,d.getCentre(l));k[h]=new r(!0,m,d.getOpen(l)),k[h+i]=new r(!1,m,d.getClose(l))}k.sort(e);var n=new Array,o=f();for(h=0;j>h;++h){var p=k[h],m=p.v;if(p.isOpen)o.insert(m),d.findNeighbours(m,o);else{o.remove(m);var s=function(b,c){var e=(d.getSize(b.r)+d.getSize(c.r))/2+g;n.push(new a.Constraint(b.v,c.v,e))},t=function(a,b,c){for(var d,e=m[a].iterator();null!==(d=e[a]());)c(d,m),d[b].remove(m)};t("prev","next",function(a,b){return s(a,b)}),t("next","prev",function(a,b){return s(b,a)})}}return console.assert(0===o.size),n}function i(a,b){var c=function(c,d){for(var e,f=b.findIter(a);null!==(e=f[c]());){var g=e.r.overlapX(a.r);if((0>=g||g<=e.r.overlapY(a.r))&&(a[c].insert(e),e[d].insert(a)),0>=g)break}};c("next","prev"),c("prev","next")}function j(a,b){var c=function(c,d){var e=b.findIter(a)[c]();null!==e&&e.r.overlapX(a.r)>0&&(a[c].insert(e),e[d].insert(a))};c("next","prev"),c("prev","next")}function k(a,b){return h(a,b,s,1e-6)}function l(a,b){return h(a,b,t,1e-6)}function m(a){return g(a,s,1e-6)}function n(a){return g(a,t,1e-6)}function o(b){var c=b.map(function(b){return new a.Variable(b.cx())}),d=a.generateXConstraints(b,c),e=new a.Solver(c,d);e.solve(),c.forEach(function(a,c){return b[c].setXCentre(a.position())}),c=b.map(function(b){return new a.Variable(b.cy())}),d=a.generateYConstraints(b,c),e=new a.Solver(c,d),e.solve(),c.forEach(function(a,c){return b[c].setYCentre(a.position())})}a.computeGroupBounds=b;var p=function(){function a(a,b,c,d){this.x=a,this.X=b,this.y=c,this.Y=d}return a.empty=function(){return new a(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},a.prototype.cx=function(){return(this.x+this.X)/2},a.prototype.cy=function(){return(this.y+this.Y)/2},a.prototype.overlapX=function(a){var b=this.cx(),c=a.cx();return c>=b&&a.x=c&&this.x=b&&a.y=c&&this.yh;++h){var i=a.lineIntersection(b,c,d,e,f[h][0],f[h][1],f[h][2],f[h][3]);null!==i&&g.push({x:i.x,y:i.y})}return g},a.prototype.rayIntersection=function(a,b){var c=this.lineIntersections(this.cx(),this.cy(),a,b);return c.length>0?c[0]:null},a.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y},{x:this.x,y:this.y}]},a.lineIntersection=function(a,b,c,d,e,f,g,h){var i=c-a,j=g-e,k=d-b,l=h-f,m=l*i-j*k;if(0==m)return null;var n=a-e,o=b-f,p=j*o-l*n,q=p/m,r=i*o-k*n,s=r/m;return q>=0&&1>=q&&s>=0&&1>=s?{x:a+q*i,y:b+q*k}:null},a.prototype.inflate=function(b){return new a(this.x-b,this.X+b,this.y-b,this.Y+b)},a}();a.Rectangle=p,a.makeEdgeBetween=c,a.makeEdgeTo=d;var q=function(){function a(a,b,c){this.v=a,this.r=b,this.pos=c,this.prev=f(),this.next=f()}return a}(),r=function(){function a(a,b,c){this.isOpen=a,this.v=b,this.pos=c}return a}(),s={getCentre:function(a){return a.cx()},getOpen:function(a){return a.y},getClose:function(a){return a.Y},getSize:function(a){return a.width()},makeRect:function(a,b,c,d){return new p(c-d/2,c+d/2,a,b)},findNeighbours:i},t={getCentre:function(a){return a.cy()},getOpen:function(a){return a.x},getClose:function(a){return a.X},getSize:function(a){return a.height()},makeRect:function(a,b,c,d){return new p(a,b,c-d/2,c+d/2)},findNeighbours:j};a.generateXConstraints=k,a.generateYConstraints=l,a.generateXGroupConstraints=m,a.generateYGroupConstraints=n,a.removeOverlaps=o;var u=function(a){function b(b,c){a.call(this,0,c),this.index=b}return __extends(b,a),b}(a.Variable);a.IndexedVariable=u;var v=function(){function c(c,d,e,f,g){var h=this;if(void 0===e&&(e=null),void 0===f&&(f=null),void 0===g&&(g=!1),this.nodes=c,this.groups=d,this.rootGroup=e,this.avoidOverlaps=g,this.variables=c.map(function(a,b){return a.variable=new u(b,1)}),f&&this.createConstraints(f),g&&e&&"undefined"!=typeof e.groups){c.forEach(function(b){if(!b.width||!b.height)return void(b.bounds=new a.Rectangle(b.x,b.x,b.y,b.y));var c=b.width/2,d=b.height/2;b.bounds=new a.Rectangle(b.x-c,b.x+c,b.y-d,b.y+d)}),b(e);var i=c.length;d.forEach(function(a){h.variables[i]=a.minVar=new u(i++,"undefined"!=typeof a.stiffness?a.stiffness:.01),h.variables[i]=a.maxVar=new u(i++,"undefined"!=typeof a.stiffness?a.stiffness:.01)})}}return c.prototype.createSeparation=function(b){return new a.Constraint(this.nodes[b.left].variable,this.nodes[b.right].variable,b.gap,"undefined"!=typeof b.equality?b.equality:!1)},c.prototype.makeFeasible=function(a){var b=this;if(this.avoidOverlaps){var c="x",d="width";"x"===a.axis&&(c="y",d="height");var e=a.offsets.map(function(a){return b.nodes[a.node]}).sort(function(a,b){return a[c]-b[c]}),f=null;e.forEach(function(a){f&&(a[c]=f[c]+f[d]+1),f=a})}},c.prototype.createAlignment=function(b){var c=this,d=this.nodes[b.offsets[0].node].variable;this.makeFeasible(b);var e="x"===b.axis?this.xConstraints:this.yConstraints;b.offsets.slice(1).forEach(function(b){var f=c.nodes[b.node].variable;e.push(new a.Constraint(d,f,b.offset,!0))})},c.prototype.createConstraints=function(a){var b=this,c=function(a){return"undefined"==typeof a.type||"separation"===a.type};this.xConstraints=a.filter(function(a){return"x"===a.axis&&c(a)}).map(function(a){return b.createSeparation(a)}),this.yConstraints=a.filter(function(a){return"y"===a.axis&&c(a)}).map(function(a){return b.createSeparation(a)}),a.filter(function(a){return"alignment"===a.type}).forEach(function(a){return b.createAlignment(a)})},c.prototype.setupVariablesAndBounds=function(a,b,c,d){this.nodes.forEach(function(e,f){e.fixed?(e.variable.weight=e.fixedWeight?e.fixedWeight:1e3,c[f]=d(e)):e.variable.weight=1;var g=(e.width||0)/2,h=(e.height||0)/2,i=a[f],j=b[f];e.bounds=new p(i-g,i+g,j-h,j+h)})},c.prototype.xProject=function(a,b,c){(this.rootGroup||this.avoidOverlaps||this.xConstraints)&&this.project(a,b,a,c,function(a){return a.px},this.xConstraints,m,function(a){return a.bounds.setXCentre(c[a.variable.index]=a.variable.position())},function(a){var b=c[a.minVar.index]=a.minVar.position(),d=c[a.maxVar.index]=a.maxVar.position(),e=a.padding/2;a.bounds.x=b-e,a.bounds.X=d+e})},c.prototype.yProject=function(a,b,c){(this.rootGroup||this.yConstraints)&&this.project(a,b,b,c,function(a){return a.py},this.yConstraints,n,function(a){return a.bounds.setYCentre(c[a.variable.index]=a.variable.position())},function(a){var b=c[a.minVar.index]=a.minVar.position(),d=c[a.maxVar.index]=a.maxVar.position(),e=a.padding/2;a.bounds.y=b-e,a.bounds.Y=d+e})},c.prototype.projectFunctions=function(){var a=this;return[function(b,c,d){return a.xProject(b,c,d)},function(b,c,d){return a.yProject(b,c,d)}]},c.prototype.project=function(a,c,d,e,f,g,h,i,j){this.setupVariablesAndBounds(a,c,e,f),this.rootGroup&&this.avoidOverlaps&&(b(this.rootGroup),g=g.concat(h(this.rootGroup))),this.solve(this.variables,g,d,e),this.nodes.forEach(i),this.rootGroup&&this.avoidOverlaps&&(this.groups.forEach(j),b(this.rootGroup))},c.prototype.solve=function(b,c,d,e){var f=new a.Solver(b,c);f.setStartingPositions(d),f.setDesiredPositions(e),f.solve()},c}();a.Projection=v}(b=a.vpsc||(a.vpsc={}))}(cola||(cola={}));var cola;!function(a){var b;!function(b){function c(a,b,c){return(b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y)}function d(a,b,d){return c(a,b,d)>0}function e(a,b,d){return c(a,b,d)<0}function f(a){var b,d=a.slice(0).sort(function(a,b){return a.x!==b.x?b.x-a.x:b.y-a.y}),e=a.length,f=0,g=d[0].x;for(b=1;e>b&&d[b].x===g;++b);var h=b-1,i=[];if(i.push(d[f]),h===e-1)d[h].y!==d[f].y&&i.push(d[h]);else{var j,k=e-1,l=d[e-1].x;for(b=e-2;b>=0&&d[b].x===l;b--);for(j=b+1,b=h;++b<=j;)if(!(c(d[f],d[j],d[b])>=0&&j>b)){for(;i.length>1&&!(c(i[i.length-2],i[i.length-1],d[b])>0);)i.length-=1;b!=f&&i.push(d[b])}k!=j&&i.push(d[k]);var m=i.length;for(b=j;--b>=h;)if(!(c(d[k],d[h],d[b])>=0&&b>h)){for(;i.length>m&&!(c(i[i.length-2],i[i.length-1],d[b])>0);)i.length-=1;b!=f&&i.push(d[b])}}return i}function g(a,b,c){b.slice(0).sort(function(b,c){return Math.atan2(b.y-a.y,b.x-a.x)-Math.atan2(c.y-a.y,c.x-a.x)}).forEach(c)}function h(a,b){return{rtan:i(a,b),ltan:j(a,b)}}function i(a,b){var c,f,g,h,i,j=b.length-1;if(e(a,b[1],b[0])&&!d(a,b[j-1],b[0]))return 0;for(c=0,f=j;;){if(f-c===1)return d(a,b[c],b[f])?c:f;if(g=Math.floor((c+f)/2),i=e(a,b[g+1],b[g]),i&&!d(a,b[g-1],b[g]))return g;h=d(a,b[c+1],b[c]),h?i?f=g:d(a,b[c],b[g])?f=g:c=g:i&&e(a,b[c],b[g])?f=g:c=g}}function j(a,b){var c,f,g,h,i,j=b.length-1;if(d(a,b[j-1],b[0])&&!e(a,b[1],b[0]))return 0;for(c=0,f=j;;){if(f-c===1)return e(a,b[c],b[f])?c:f;if(g=Math.floor((c+f)/2),i=e(a,b[g+1],b[g]),d(a,b[g-1],b[g])&&!i)return g;h=e(a,b[c+1],b[c]),h?i?e(a,b[c],b[g])?f=g:c=g:f=g:i?c=g:d(a,b[c],b[g])?f=g:c=g}}function k(a,b,c,d,e,f){var g,h;g=c(b[0],a),h=d(a[g],b);for(var i=!1;!i;){for(i=!0;;){if(g===a.length-1&&(g=0),e(b[h],a[g],a[g+1]))break;++g}for(;;){if(0===h&&(h=b.length-1),f(a[g],b[h],b[h-1]))break;--h,i=!1}}return{t1:g,t2:h}}function l(a,b){var c=m(b,a);return{t1:c.t2,t2:c.t1}}function m(a,b){return k(a,b,i,j,d,e)}function n(a,b){return k(a,b,j,j,e,e)}function o(a,b){return k(a,b,i,i,d,d)}function p(b,c){for(var d=[],e=1,f=c.length;f>e;++e){var g=a.vpsc.Rectangle.lineIntersection(b.x1,b.y1,b.x2,b.y2,c[e-1].x,c[e-1].y,c[e].x,c[e].y);g&&d.push(g)}return d}function q(a,b){for(var d=a.length-1,e=b.length-1,f=new y,g=0;d>g;++g)for(var h=0;e>h;++h){var i=a[0==g?d-1:g-1],j=a[g],k=a[g+1],l=b[0==h?e-1:h-1],m=b[h],n=b[h+1],o=c(i,j,m),p=c(j,l,m),q=c(j,m,n),r=c(l,m,j),s=c(m,i,j),t=c(m,j,k);o>=0&&p>=0&&0>q&&r>=0&&s>=0&&0>t?f.ll=new x(g,h):0>=o&&0>=p&&q>0&&0>=r&&0>=s&&t>0?f.rr=new x(g,h):0>=o&&p>0&&0>=q&&r>=0&&0>s&&t>=0?f.rl=new x(g,h):o>=0&&0>p&&q>=0&&0>=r&&s>0&&0>=t&&(f.lr=new x(g,h))}return f}function r(a,b){for(var c=1,d=b.length;d>c;++c)if(e(b[c-1],b[c],a))return!1;return!0}function s(a,b){return!a.every(function(a){return!r(a,b)})}function t(a,b){if(s(a,b))return!0;if(s(b,a))return!0;for(var c=1,d=a.length;d>c;++c){var e=a[c],f=a[c-1];if(p(new v(f.x,f.y,e.x,e.y),b).length>0)return!0}return!1}var u=function(){function a(){}return a}();b.Point=u;var v=function(){function a(a,b,c,d){this.x1=a,this.y1=b,this.x2=c,this.y2=d}return a}();b.LineSegment=v;var w=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b}(u);b.PolyPoint=w,b.isLeft=c,b.ConvexHull=f,b.clockwiseRadialSweep=g,b.tangent_PolyPolyC=k,b.LRtangent_PolyPolyC=l,b.RLtangent_PolyPolyC=m,b.LLtangent_PolyPolyC=n,b.RRtangent_PolyPolyC=o;var x=function(){function a(a,b){this.t1=a,this.t2=b}return a}();b.BiTangent=x;var y=function(){function a(){}return a}();b.BiTangents=y;var z=function(a){function b(){a.apply(this,arguments)}return __extends(b,a),b}(u);b.TVGPoint=z;var A=function(){function a(a,b,c,d){this.id=a,this.polyid=b,this.polyvertid=c,this.p=d,d.vv=this}return a}();b.VisibilityVertex=A;var B=function(){function a(a,b){this.source=a,this.target=b}return a.prototype.length=function(){var a=this.source.p.x-this.target.p.x,b=this.source.p.y-this.target.p.y;return Math.sqrt(a*a+b*b)},a}();b.VisibilityEdge=B;var C=function(){function a(a,c){if(this.P=a,this.V=[],this.E=[],c)this.V=c.V.slice(0),this.E=c.E.slice(0);else{for(var d=a.length,e=0;d>e;e++)for(var f=a[e],g=0;g0&&this.E.push(new B(f[g-1].vv,i))}for(var e=0;d-1>e;e++)for(var j=a[e],g=e+1;d>g;g++){var k=a[g],l=b.tangents(j,k);for(var m in l){var n=l[m],o=j[n.t1],p=k[n.t2];this.addEdgeIfVisible(o,p,e,g)}}}}return a.prototype.addEdgeIfVisible=function(a,b,c,d){this.intersectsPolys(new v(a.x,a.y,b.x,b.y),c,d)||this.E.push(new B(a.vv,b.vv))},a.prototype.addPoint=function(a,b){var c=this.P.length;this.V.push(new A(this.V.length,c,0,a));for(var d=0;c>d;++d)if(d!==b){var e=this.P[d],f=h(a,e);this.addEdgeIfVisible(a,e[f.ltan],b,d),this.addEdgeIfVisible(a,e[f.rtan],b,d)}return a.vv},a.prototype.intersectsPolys=function(a,b,c){for(var d=0,e=this.P.length;e>d;++d)if(d!=b&&d!=c&&p(a,this.P[d]).length>0)return!0;return!1},a}();b.TangentVisibilityGraph=C,b.tangents=q,b.polysOverlap=t}(b=a.geom||(a.geom={}))}(cola||(cola={}));var cola;!function(a){var b=function(){function a(){this.locks={}}return a.prototype.add=function(a,b){this.locks[a]=b},a.prototype.clear=function(){this.locks={}},a.prototype.isEmpty=function(){for(var a in this.locks)return!1;return!0},a.prototype.apply=function(a){for(var b in this.locks)a(b,this.locks[b])},a}();a.Locks=b;var c=function(){function a(a,c,e){void 0===e&&(e=null),this.D=c,this.G=e,this.threshold=1e-4,this.numGridSnapNodes=0,this.snapGridSize=100,this.snapStrength=1e3,this.scaleSnapByMaxH=!1,this.random=new d,this.project=null,this.x=a,this.k=a.length;var f=this.n=a[0].length;this.H=new Array(this.k),this.g=new Array(this.k),this.Hd=new Array(this.k),this.a=new Array(this.k),this.b=new Array(this.k),this.c=new Array(this.k),this.d=new Array(this.k),this.e=new Array(this.k),this.ia=new Array(this.k),this.ib=new Array(this.k),this.xtmp=new Array(this.k),this.locks=new b,this.minD=Number.MAX_VALUE;for(var g,h=f;h--;)for(g=f;--g>h;){var i=c[h][g];i>0&&id;++d){c[d]=new Array(a);for(var e=0;a>e;++e)c[d][e]=b(d,e)}return c},a.prototype.offsetDir=function(){for(var a=this,b=new Array(this.k),c=0,d=0;dc)){for(var d,e=new Array(this.k),f=new Array(this.k),g=new Array(this.k),h=0,i=0;c>i;++i){for(d=0;dj;++j)if(i!==j){for(var k=c;k--;){var l=0;for(d=0;d1e-9)break;var n=this.offsetDir();for(d=0;d1&&o>p||!isFinite(p))for(d=0;d1&&(q=1);var r=p*p,s=2*q*(o-p)/(r*o),t=o*o*o,u=2*-q/(r*t);for(isFinite(s)||console.log(s),d=0;di;++i)for(d=0;d=E?A-D*w:A>0?A-(D+1)*w:A-(D-1)*w;m>-v&&v>=m&&(this.scaleSnapByMaxH?(this.g[d][i]+=h*y*m,this.H[d][i][i]+=h*y):(this.g[d][i]+=y*m,this.H[d][i][i]+=y))}this.locks.isEmpty()||this.locks.apply(function(c,e){for(d=0;de;++e)for(var f=0;d>f;++f)b[e][f]=a[e][f]},a.prototype.stepAndProject=function(b,c,d,e){a.copy(b,c),this.takeDescentStep(c[0],d[0],e),this.project&&this.project[0](b[0],b[1],c[0]),this.takeDescentStep(c[1],d[1],e),this.project&&this.project[1](c[0],b[1],c[1]);for(var f=2;f0;)for(var e=b;e-- >0;)c(d,e)},a.prototype.matrixApply=function(b){a.mApply(this.k,this.n,b)},a.prototype.computeNextPosition=function(a,b){var c=this;this.computeDerivatives(a);var d=this.computeStepSize(this.g);if(this.stepAndProject(a,b,this.g,d),this.project){this.matrixApply(function(d,e){return c.e[d][e]=a[d][e]-b[d][e]});var e=this.computeStepSize(this.e);e=Math.max(.2,Math.min(e,1)),this.stepAndProject(a,b,this.e,e)}},a.prototype.run=function(a){for(var b=Number.MAX_VALUE,c=!1;!c&&a-- >0;){var d=this.rungeKutta();c=Math.abs(b/d-1)b;++b)for(var d=b+1,e=this.n;e>d;++d){for(var f=0,g=0;g>16)/this.range},a.prototype.getNextBetween=function(a,b){return a+this.getNext()*(b-a)},a}();a.PseudoRandom=d}(cola||(cola={}));var cola;!function(a){var b;!function(a){function b(a,c,d){a.forAll(function(a){if(a.isLeaf())c.leaves||(c.leaves=[]),c.leaves.push(a.id);else{var e=c;if(a.gid=d.length,!a.isIsland()||a.isPredefined()){if(e={id:a.gid},a.isPredefined())for(var f in a.definition)e[f]=a.definition[f];c.groups||(c.groups=[]),c.groups.push(a.gid),d.push(e)}b(a.children,e,d)}})}function c(a,b){var c={};for(var d in a)d in b&&(c[d]=a[d]);return c}function d(b,c,d,e){for(var f=b.length,g=new a.Configuration(f,c,d,e);g.greedyMerge(););var h=[],i=g.getGroupHierarchy(h);return h.forEach(function(a){var c=function(c){var d=a[c];"number"==typeof d&&(a[c]=b[d])};c("source"),c("target")}),{groups:i,powerEdges:h}}var e=function(){function a(a,b,c){this.source=a,this.target=b,this.type=c}return a}();a.PowerEdge=e;var f=function(){function a(a,b,c,d){var e=this;if(this.linkAccessor=c,this.modules=new Array(a),this.roots=[],d)this.initModulesFromGroup(d);else{this.roots.push(new h);for(var f=0;a>f;++f)this.roots[0].add(this.modules[f]=new g(f))}this.R=b.length,b.forEach(function(a){var b=e.modules[c.getSourceIndex(a)],d=e.modules[c.getTargetIndex(a)],f=c.getType(a);b.outgoing.add(f,d),d.incoming.add(f,b)})}return a.prototype.initModulesFromGroup=function(a){var b=new h;this.roots.push(b);for(var c=0;cf;++f)for(var h=f+1;c>h;++h){var i=b[f],j=b[h];d[e]={id:e,nEdges:this.nEdges(i,j),a:i,b:j},e++}return d},a.prototype.greedyMerge=function(){for(var a=0;a=this.R))return this.merge(c.a,c.b,a),!0}},a.prototype.nEdges=function(a,b){var c=a.incoming.intersection(b.incoming),d=a.outgoing.intersection(b.outgoing);return this.R-c.count()-d.count()},a.prototype.getGroupHierarchy=function(a){var c=this,d=[],f={};b(this.roots[0],f,d);var g=this.allEdges();return g.forEach(function(b){var f=c.modules[b.source],g=c.modules[b.target];a.push(new e("undefined"==typeof f.gid?b.source:d[f.gid],"undefined"==typeof g.gid?b.target:d[g.gid],b.type))}),d},a.prototype.allEdges=function(){var b=[];return a.getEdges(this.roots[0],b),b},a.getEdges=function(b,c){b.forAll(function(b){b.getEdges(c),a.getEdges(b.children,c)})},a}();a.Configuration=f;var g=function(){function a(a,b,c,d,e){void 0===b&&(b=new i),void 0===c&&(c=new i),void 0===d&&(d=new h),this.id=a,this.outgoing=b,this.incoming=c,this.children=d,this.definition=e}return a.prototype.getEdges=function(a){var b=this;this.outgoing.forAll(function(c,d){c.forAll(function(c){a.push(new e(b.id,c.id,d))})})},a.prototype.isLeaf=function(){return 0===this.children.count()},a.prototype.isIsland=function(){return 0===this.outgoing.count()&&0===this.incoming.count()},a.prototype.isPredefined=function(){return"undefined"!=typeof this.definition},a}();a.Module=g;var h=function(){function a(){this.table={}}return a.prototype.count=function(){return Object.keys(this.table).length},a.prototype.intersection=function(b){var d=new a;return d.table=c(this.table,b.table),d},a.prototype.intersectionCount=function(a){return this.intersection(a).count()},a.prototype.contains=function(a){return a in this.table},a.prototype.add=function(a){this.table[a.id]=a},a.prototype.remove=function(a){delete this.table[a.id]},a.prototype.forAll=function(a){for(var b in this.table)a(this.table[b])},a.prototype.modules=function(){var a=[];return this.forAll(function(b){b.isPredefined()||a.push(b)}),a},a}();a.ModuleSet=h;var i=function(){function a(){this.sets={},this.n=0}return a.prototype.count=function(){return this.n},a.prototype.contains=function(a){var b=!1;return this.forAllModules(function(c){b||c.id!=a||(b=!0)}),b},a.prototype.add=function(a,b){var c=a in this.sets?this.sets[a]:this.sets[a]=new h;c.add(b),++this.n},a.prototype.remove=function(a,b){var c=this.sets[a];c.remove(b),0===c.count()&&delete this.sets[a],--this.n},a.prototype.forAll=function(a){for(var b in this.sets)a(this.sets[b],b)},a.prototype.forAllModules=function(a){this.forAll(function(b,c){return b.forAll(a)})},a.prototype.intersection=function(b){var c=new a;return this.forAll(function(a,d){if(d in b.sets){var e=a.intersection(b.sets[d]),f=e.count();f>0&&(c.sets[d]=e,c.n+=f)}}),c},a}();a.LinkSets=i,a.getGroups=d}(b=a.powergraph||(a.powergraph={}))}(cola||(cola={}));var cola;!function(a){function b(a,b){var c={};for(var d in a)c[d]={};for(var d in b)c[d]={};return Object.keys(c).length}function c(a,b){var c=0;for(var d in a)"undefined"!=typeof b[d]&&++c;return c}function d(a,b){var c={},d=function(a,b){"undefined"==typeof c[a]&&(c[a]={}),c[a][b]={}};return a.forEach(function(a){var c=b.getSourceIndex(a),e=b.getTargetIndex(a);d(c,e),d(e,c)}),c}function e(a,b,c,e){var f=d(a,e);a.forEach(function(a){var d=f[e.getSourceIndex(a)],g=f[e.getTargetIndex(a)];e.setLength(a,1+b*c(d,g))})}function f(a,d,f){void 0===f&&(f=1),e(a,f,function(a,d){return Math.sqrt(b(a,d)-c(a,d))},d)}function g(a,d,f){void 0===f&&(f=1),e(a,f,function(a,d){return Math.min(Object.keys(a).length,Object.keys(d).length)<1.1?0:c(a,d)/b(a,d)},d)}function h(a,b,c,d){var e=i(a,b,d),f={};e.forEach(function(a,b){return a.forEach(function(a){return f[a]=b})});var g=[];return b.forEach(function(a){var b=d.getSourceIndex(a),e=d.getTargetIndex(a),h=f[b],i=f[e];h!==i&&g.push({axis:c,left:b,right:e,gap:d.getMinSeparation(a)})}),g}function i(a,b,c){function d(a){a.index=a.lowlink=f++,g.push(a),a.onStack=!0;for(var b=0,c=a.out;bi;i++)e.push({id:i,out:[]});for(var j=0;jk&&(i.d=k,i.prev=g,c.reduceKey(i.q,i,function(a,b){return a.q=b}))}}return e},a}();a.Calculator=e}(b=a.shortestpaths||(a.shortestpaths={}))}(cola||(cola={}));var cola;!function(a){function b(a){return"undefined"!=typeof a.leaves||"undefined"!=typeof a.groups}!function(a){a[a.start=0]="start",a[a.tick=1]="tick",a[a.end=2]="end"}(a.EventType||(a.EventType={}));var c=a.EventType,d=function(){function d(){var a=this;this._canvasSize=[1,1],this._linkDistance=20,this._defaultNodeSize=10,this._linkLengthCalculator=null,this._linkType=null,this._avoidOverlaps=!1,this._handleDisconnected=!0,this._running=!1,this._nodes=[],this._groups=[],this._rootGroup=null,this._links=[],this._constraints=[],this._distanceMatrix=null,this._descent=null,this._directedLinkConstraints=null,this._threshold=.01,this._visibilityGraph=null,this._groupCompactness=1e-6,this.event=null,this.linkAccessor={getSourceIndex:d.getSourceIndex,getTargetIndex:d.getTargetIndex,setLength:d.setLinkLength,getType:function(b){return"function"==typeof a._linkType?a._linkType(b):0}}}return d.prototype.on=function(a,b){return this.event||(this.event={}),"string"==typeof a?this.event[c[a]]=b:this.event[a]=b,this},d.prototype.trigger=function(a){this.event&&"undefined"!=typeof this.event[a.type]&&this.event[a.type](a)},d.prototype.kick=function(){for(;!this.tick(););},d.prototype.tick=function(){if(this._alphab;++b)if(a=this._nodes[b],a.fixed){("undefined"==typeof a.px||"undefined"==typeof a.py)&&(a.px=a.x,a.py=a.y);var e=[a.px,a.py];this._descent.locks.add(b,e)}var f=this._descent.rungeKutta();return 0===f?this._alpha=0:"undefined"!=typeof this._lastStress&&(this._alpha=f),this._lastStress=f,this.updateNodePositions(),this.trigger({type:c.tick,alpha:this._alpha,stress:this._lastStress}),!1},d.prototype.updateNodePositions=function(){for(var a,b=this._descent.x[0],c=this._descent.x[1],d=this._nodes.length;d--;)a=this._nodes[d],a.x=b[d],a.y=c[d]},d.prototype.nodes=function(a){if(!a){if(0===this._nodes.length&&this._links.length>0){var b=0;this._links.forEach(function(a){b=Math.max(b,a.source,a.target)}),this._nodes=new Array(++b);for(var c=0;b>c;++c)this._nodes[c]={}}return this._nodes}return this._nodes=a,this},d.prototype.groups=function(a){var b=this;return a?(this._groups=a,this._rootGroup={},this._groups.forEach(function(a){"undefined"==typeof a.padding&&(a.padding=1),"undefined"!=typeof a.leaves&&a.leaves.forEach(function(c,d){(a.leaves[d]=b._nodes[c]).parent=a}),"undefined"!=typeof a.groups&&a.groups.forEach(function(c,d){(a.groups[d]=b._groups[c]).parent=a})}),this._rootGroup.leaves=this._nodes.filter(function(a){return"undefined"==typeof a.parent}),this._rootGroup.groups=this._groups.filter(function(a){return"undefined"==typeof a.parent}),this):this._groups},d.prototype.powerGraphGroups=function(b){var c=a.powergraph.getGroups(this._nodes,this._links,this.linkAccessor,this._rootGroup);return this.groups(c.groups),b(c),this},d.prototype.avoidOverlaps=function(a){return arguments.length?(this._avoidOverlaps=a,this):this._avoidOverlaps},d.prototype.handleDisconnected=function(a){return arguments.length?(this._handleDisconnected=a,this):this._handleDisconnected},d.prototype.flowLayout=function(a,b){return arguments.length||(a="y"),this._directedLinkConstraints={axis:a,getMinSeparation:"number"==typeof b?function(){return b}:b},this},d.prototype.links=function(a){return arguments.length?(this._links=a,this):this._links},d.prototype.constraints=function(a){return arguments.length?(this._constraints=a,this):this._constraints},d.prototype.distanceMatrix=function(a){return arguments.length?(this._distanceMatrix=a,this):this._distanceMatrix},d.prototype.size=function(a){return a?(this._canvasSize=a,this):this._canvasSize},d.prototype.defaultNodeSize=function(a){return a?(this._defaultNodeSize=a,this):this._defaultNodeSize},d.prototype.groupCompactness=function(a){return a?(this._groupCompactness=a,this):this._groupCompactness},d.prototype.linkDistance=function(a){return a?(this._linkDistance="function"==typeof a?a:+a,this._linkLengthCalculator=null,this):this._linkDistance},d.prototype.linkType=function(a){return this._linkType=a,this},d.prototype.convergenceThreshold=function(a){return a?(this._threshold="function"==typeof a?a:+a,this):this._threshold},d.prototype.alpha=function(a){return arguments.length?(a=+a,this._alpha?a>0?this._alpha=a:this._alpha=0:a>0&&(this._running||(this._running=!0,this.trigger({type:c.start,alpha:this._alpha=a}),this.kick())),this):this._alpha},d.prototype.getLinkLength=function(a){return"function"==typeof this._linkDistance?+this._linkDistance(a):this._linkDistance},d.setLinkLength=function(a,b){a.length=b},d.prototype.getLinkType=function(a){return"function"==typeof this._linkType?this._linkType(a):0},d.prototype.symmetricDiffLinkLengths=function(b,c){var d=this;return void 0===c&&(c=1),this.linkDistance(function(a){return b*a.length}),this._linkLengthCalculator=function(){return a.symmetricDiffLinkLengths(d._links,d.linkAccessor,c)},this},d.prototype.jaccardLinkLengths=function(b,c){var d=this;return void 0===c&&(c=1),this.linkDistance(function(a){return b*a.length}),this._linkLengthCalculator=function(){return a.jaccardLinkLengths(d._links,d.linkAccessor,c)},this},d.prototype.start=function(b,c,e,f,g){var h=this;void 0===b&&(b=0),void 0===c&&(c=0),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=!0);var i,j=this.nodes().length,k=j+2*this._groups.length,l=(this._links.length,this._canvasSize[0]),m=this._canvasSize[1];this._linkLengthCalculator&&this._linkLengthCalculator();var n=new Array(k),o=new Array(k),p=null,q=this._avoidOverlaps;this._nodes.forEach(function(a,b){a.index=b,"undefined"==typeof a.x&&(a.x=l/2,a.y=m/2),n[b]=a.x,o[b]=a.y});var r;this._distanceMatrix?r=this._distanceMatrix:(r=new a.shortestpaths.Calculator(k,this._links,d.getSourceIndex,d.getTargetIndex,function(a){return h.getLinkLength(a)}).DistanceMatrix(),p=a.Descent.createSquareMatrix(k,function(){return 2}),this._links.forEach(function(a){"number"==typeof a.source&&(a.source=h._nodes[a.source]),"number"==typeof a.target&&(a.target=h._nodes[a.target])}),this._links.forEach(function(a){var b=d.getSourceIndex(a),c=d.getTargetIndex(a);p[b][c]=p[c][b]=a.weight||1}));var s=a.Descent.createSquareMatrix(k,function(a,b){return r[a][b]});if(this._rootGroup&&"undefined"!=typeof this._rootGroup.groups){var i=j,t=function(a,b,c,d){p[a][b]=p[b][a]=c,s[a][b]=s[b][a]=d};this._groups.forEach(function(a){t(i,i+1,h._groupCompactness,.1),n[i]=0,o[i++]=0,n[i]=0,o[i++]=0})}else this._rootGroup={leaves:this._nodes,groups:[]};var u=this._constraints||[];this._directedLinkConstraints&&(this.linkAccessor.getMinSeparation=this._directedLinkConstraints.getMinSeparation,u=u.concat(a.generateDirectedEdgeConstraints(j,this._links,this._directedLinkConstraints.axis,this.linkAccessor))),this.avoidOverlaps(!1),this._descent=new a.Descent([n,o],s),this._descent.locks.clear();for(var i=0;j>i;++i){var v=this._nodes[i];if(v.fixed){v.px=v.x,v.py=v.y;var w=[v.x,v.y];this._descent.locks.add(i,w)}}if(this._descent.threshold=this._threshold,this.initialLayout(b,n,o),u.length>0&&(this._descent.project=new a.vpsc.Projection(this._nodes,this._groups,this._rootGroup,u).projectFunctions()),this._descent.run(c),this.separateOverlappingComponents(l,m),this.avoidOverlaps(q),q&&(this._nodes.forEach(function(a,b){a.x=n[b],a.y=o[b]}),this._descent.project=new a.vpsc.Projection(this._nodes,this._groups,this._rootGroup,u,!0).projectFunctions(),this._nodes.forEach(function(a,b){n[b]=a.x,o[b]=a.y})),this._descent.G=p,this._descent.run(e),f){this._descent.snapStrength=1e3,this._descent.snapGridSize=this._nodes[0].width,this._descent.numGridSnapNodes=j,this._descent.scaleSnapByMaxH=j!=k;var x=a.Descent.createSquareMatrix(k,function(a,b){return a>=j||b>=j?p[a][b]:0});this._descent.G=x,this._descent.run(f)}return this.updateNodePositions(),this.separateOverlappingComponents(l,m),g?this.resume():this},d.prototype.initialLayout=function(b,c,d){if(this._groups.length>0&&b>0){var e=this._nodes.length,f=this._links.map(function(a){return{source:a.source.index,target:a.target.index}}),g=this._nodes.map(function(a){return{index:a.index}});this._groups.forEach(function(a,b){g.push({index:a.index=e+b})}),this._groups.forEach(function(a,b){"undefined"!=typeof a.leaves&&a.leaves.forEach(function(b){return f.push({source:a.index,target:b.index})}),"undefined"!=typeof a.groups&&a.groups.forEach(function(b){return f.push({source:a.index,target:b.index})})}),(new a.Layout).size(this.size()).nodes(g).links(f).avoidOverlaps(!1).linkDistance(this.linkDistance()).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(b,0,0,0,!1),this._nodes.forEach(function(a){c[a.index]=g[a.index].x,d[a.index]=g[a.index].y})}else this._descent.run(b)},d.prototype.separateOverlappingComponents=function(b,c){var d=this;if(!this._distanceMatrix&&this._handleDisconnected){var e=this._descent.x[0],f=this._descent.x[1];this._nodes.forEach(function(a,b){a.x=e[b],a.y=f[b]});var g=a.separateGraphs(this._nodes,this._links);a.applyPacking(g,b,c,this._defaultNodeSize),this._nodes.forEach(function(a,b){d._descent.x[0][b]=a.x,d._descent.x[1][b]=a.y,a.bounds&&(a.bounds.setXCentre(a.x),a.bounds.setYCentre(a.y))})}},d.prototype.resume=function(){return this.alpha(.1)},d.prototype.stop=function(){return this.alpha(0)},d.prototype.prepareEdgeRouting=function(b){void 0===b&&(b=0),this._visibilityGraph=new a.geom.TangentVisibilityGraph(this._nodes.map(function(a){return a.bounds.inflate(-b).vertices()}))},d.prototype.routeEdge=function(b,c){var d=[],e=new a.geom.TangentVisibilityGraph(this._visibilityGraph.P,{V:this._visibilityGraph.V,E:this._visibilityGraph.E}),f={x:b.source.x,y:b.source.y},g={x:b.target.x,y:b.target.y},h=e.addPoint(f,b.source.index),i=e.addPoint(g,b.target.index);e.addEdgeIfVisible(f,g,b.source.index,b.target.index),"undefined"!=typeof c&&c(e);var j=function(a){return a.source.id},k=function(a){return a.target.id},l=function(a){return a.length()},m=new a.shortestpaths.Calculator(e.V.length,e.E,j,k,l),n=m.PathFromNodeToNode(h.id,i.id);if(1===n.length||n.length===e.V.length){var o=a.vpsc.makeEdgeBetween(b.source.innerBounds,b.target.innerBounds,5);d=[o.sourceIntersection,o.arrowStart]}else{for(var p=n.length-2,q=e.V[n[p]].p,r=e.V[n[0]].p,d=[b.source.innerBounds.rayIntersection(q.x,q.y)],s=p;s>=0;--s)d.push(e.V[n[s]].p);d.push(a.vpsc.makeEdgeTo(r,b.target.innerBounds,5))}return d},d.getSourceIndex=function(a){return"number"==typeof a.source?a.source:a.source.index},d.getTargetIndex=function(a){return"number"==typeof a.target?a.target:a.target.index},d.linkId=function(a){return d.getSourceIndex(a)+"-"+d.getTargetIndex(a)},d.dragStart=function(a){b(a)?d.storeOffset(a,d.dragOrigin(a)):(d.stopNode(a),a.fixed|=2)},d.stopNode=function(a){a.px=a.x,a.py=a.y},d.storeOffset=function(a,b){"undefined"!=typeof a.leaves&&a.leaves.forEach(function(a){a.fixed|=2,d.stopNode(a),a._dragGroupOffsetX=a.x-b.x,a._dragGroupOffsetY=a.y-b.y}),"undefined"!=typeof a.groups&&a.groups.forEach(function(a){return d.storeOffset(a,b)})},d.dragOrigin=function(a){return b(a)?{x:a.bounds.cx(),y:a.bounds.cy()}:a},d.drag=function(a,c){b(a)?("undefined"!=typeof a.leaves&&a.leaves.forEach(function(b){a.bounds.setXCentre(c.x),a.bounds.setYCentre(c.y),b.px=b._dragGroupOffsetX+c.x,b.py=b._dragGroupOffsetY+c.y}),"undefined"!=typeof a.groups&&a.groups.forEach(function(a){return d.drag(a,c)})):(a.px=c.x,a.py=c.y)},d.dragEnd=function(a){b(a)?("undefined"!=typeof a.leaves&&a.leaves.forEach(function(a){d.dragEnd(a),delete a._dragGroupOffsetX,delete a._dragGroupOffsetY}),"undefined"!=typeof a.groups&&a.groups.forEach(d.dragEnd)):a.fixed&=-7},d.mouseOver=function(a){a.fixed|=4,a.px=a.x,a.py=a.y},d.mouseOut=function(a){a.fixed&=-5},d}();a.Layout=d}(cola||(cola={}));var cola;!function(a){function b(a){return new c(a)}var c=function(b){function c(c){b.call(this);var d=c;d.trigger&&(this.trigger=d.trigger),d.kick&&(this.kick=d.kick),d.drag&&(this.drag=d.drag),d.on&&(this.on=d.on),this.dragstart=this.dragStart=a.Layout.dragStart,this.dragend=this.dragEnd=a.Layout.dragEnd}return __extends(c,b),c.prototype.trigger=function(a){},c.prototype.kick=function(){},c.prototype.drag=function(){},c.prototype.on=function(a,b){return this},c}(a.Layout);a.LayoutAdaptor=c,a.adaptor=b}(cola||(cola={}));var cola;!function(a){function b(a,b,d,e){a.cola.start(0,0,0,10,!1);var f=c(a.cola.nodes(),a.cola.groups(),d,e);return f.routeEdges(a.powerGraph.powerEdges,b,function(a){return a.source.routerNode.id},function(a){return a.target.routerNode.id})}function c(b,c,d,e){b.forEach(function(a){a.routerNode={name:a.name,bounds:a.bounds.inflate(-d)}}),c.forEach(function(a){a.routerNode={bounds:a.bounds.inflate(-e),children:("undefined"!=typeof a.groups?a.groups.map(function(a){return b.length+a.id}):[]).concat("undefined"!=typeof a.leaves?a.leaves.map(function(a){return a.index}):[])}});var f=b.concat(c).map(function(a,b){return a.routerNode.id=b,a.routerNode});return new a.GridRouter(f,{getChildren:function(a){return a.children},getBounds:function(a){return a.bounds}},d-e)}function d(b,c,d,e,f){var g;b.nodes.forEach(function(a,b){return a.index=b}),(new a.Layout).avoidOverlaps(!1).nodes(b.nodes).links(b.links).powerGraphGroups(function(a){g=a,g.groups.forEach(function(a){return a.padding=d})});var h=b.nodes.length,i=[],j=b.nodes.slice(0);return j.forEach(function(a,b){return a.index=b}),g.groups.forEach(function(a){var b=a.index=a.id+h;j.push(a),"undefined"!=typeof a.leaves&&a.leaves.forEach(function(a){return i.push({source:b,target:a.index})}),"undefined"!=typeof a.groups&&a.groups.forEach(function(a){return i.push({source:b,target:a.id+h})})}),g.powerEdges.forEach(function(a){i.push({source:a.source.index,target:a.target.index})}),(new a.Layout).size(c).nodes(j).links(i).avoidOverlaps(!1).linkDistance(30).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(100,0,0,0,!1),{cola:(new a.Layout).convergenceThreshold(.001).size(c).avoidOverlaps(!0).nodes(b.nodes).links(b.links).groupCompactness(1e-4).linkDistance(30).symmetricDiffLinkLengths(5).powerGraphGroups(function(a){g=a,g.groups.forEach(function(a){a.padding=d})}).start(50,0,100,0,!1),powerGraph:g}}a.gridify=b,a.powerGraphGridLayout=d}(cola||(cola={}));var cola;!function(a){function b(){return new c}var c=function(b){function c(){b.call(this),this.event=d3.dispatch(a.EventType[a.EventType.start],a.EventType[a.EventType.tick],a.EventType[a.EventType.end]);var c=this;this.drag=function(){if(!b)var b=d3.behavior.drag().origin(a.Layout.dragOrigin).on("dragstart.d3adaptor",a.Layout.dragStart).on("drag.d3adaptor",function(b){a.Layout.drag(b,d3.event),c.resume()}).on("dragend.d3adaptor",a.Layout.dragEnd);return arguments.length?void this.call(b):b}}return __extends(c,b),c.prototype.trigger=function(b){var c={type:a.EventType[b.type],alpha:b.alpha,stress:b.stress};this.event[c.type](c)},c.prototype.kick=function(){var a=this;d3.timer(function(){return b.prototype.tick.call(a)})},c.prototype.on=function(b,c){return"string"==typeof b?this.event.on(b,c):this.event.on(a.EventType[b],c),this},c}(a.Layout);a.D3StyleLayoutAdaptor=c,a.d3adaptor=b}(cola||(cola={}));var cola;!function(a){var b=function(){function a(a,b,c){this.id=a,this.rect=b,this.children=c,this.leaf="undefined"==typeof c||0===c.length}return a}();a.NodeWrapper=b;var c=function(){function a(a,b,c,d,e){void 0===d&&(d=null),void 0===e&&(e=null),this.id=a,this.x=b,this.y=c,this.node=d,this.line=e}return a}();a.Vert=c;var d=function(){function a(b,c){this.s=b,this.t=c;var d=a.findMatch(b,c),e=c.slice(0).reverse(),f=a.findMatch(b,e);d.length>=f.length?(this.length=d.length,this.si=d.si,this.ti=d.ti,this.reversed=!1):(this.length=f.length,this.si=f.si,this.ti=c.length-f.ti-f.length,this.reversed=!0)}return a.findMatch=function(a,b){for(var c=a.length,d=b.length,e={length:0,si:-1,ti:-1},f=new Array(c),g=0;c>g;g++){f[g]=new Array(d);for(var h=0;d>h;h++)if(a[g]===b[h]){var i=f[g][h]=0===g||0===h?1:f[g-1][h-1]+1;i>e.length&&(e.length=i,e.si=g-i+1,e.ti=h-i+1)}else f[g][h]=0}return e},a.prototype.getSequence=function(){return this.length>=0?this.s.slice(this.si,this.si+this.length):[]},a}();a.LongestCommonSubsequence=d;var e=function(){function d(d,e,f){var g=this;void 0===f&&(f=12),this.originalnodes=d,this.groupPadding=f,this.leaves=null,this.nodes=d.map(function(a,c){return new b(c,e.getBounds(a),e.getChildren(a))}),this.leaves=this.nodes.filter(function(a){return a.leaf}),this.groups=this.nodes.filter(function(a){return!a.leaf}),this.cols=this.getGridLines("x"),this.rows=this.getGridLines("y"),this.groups.forEach(function(a){return a.children.forEach(function(b){return g.nodes[b].parent=a})}),this.root={children:[]},this.nodes.forEach(function(a){"undefined"==typeof a.parent&&(a.parent=g.root,g.root.children.push(a.id)),a.ports=[]}),this.backToFront=this.nodes.slice(0),this.backToFront.sort(function(a,b){return g.getDepth(a)-g.getDepth(b)});var h=this.backToFront.slice(0).reverse().filter(function(a){return!a.leaf});h.forEach(function(b){var c=a.vpsc.Rectangle.empty();b.children.forEach(function(a){return c=c.union(g.nodes[a].rect)}),b.rect=c.inflate(g.groupPadding)});var i=this.midPoints(this.cols.map(function(a){return a.pos})),j=this.midPoints(this.rows.map(function(a){return a.pos})),k=i[0],l=i[i.length-1],m=j[0],n=j[j.length-1],o=this.rows.map(function(a){return{x1:k,x2:l,y1:a.pos,y2:a.pos}}).concat(j.map(function(a){return{x1:k,x2:l,y1:a,y2:a}})),p=this.cols.map(function(a){return{x1:a.pos,x2:a.pos,y1:m,y2:n}}).concat(i.map(function(a){return{x1:a,x2:a,y1:m,y2:n}})),q=o.concat(p);q.forEach(function(a){return a.verts=[]}),this.verts=[],this.edges=[],o.forEach(function(a){return p.forEach(function(b){var d=new c(g.verts.length,b.x1,a.y1);a.verts.push(d),b.verts.push(d),g.verts.push(d);for(var e=g.backToFront.length;e-- >0;){ var f=g.backToFront[e],h=f.rect,i=Math.abs(d.x-h.cx()),j=Math.abs(d.y-h.cy());if(i0;){var d=c.filter(function(b){return b.rect["overlap"+a.toUpperCase()](c[0].rect)}),e={nodes:d,pos:this.avg(d.map(function(b){return b.rect["c"+a]()}))};b.push(e),e.nodes.forEach(function(a){return c.splice(c.indexOf(a),1)})}return b.sort(function(a,b){return a.pos-b.pos}),b},d.prototype.getDepth=function(a){for(var b=0;a.parent!==this.root;)b++,a=a.parent;return b},d.prototype.midPoints=function(a){for(var b=a[1]-a[0],c=[a[0]-b/2],d=1;d.1)&&(k={pos:h[0][b],segments:[]},j.push(k)),k.segments.push(h)}return j},d.nudgeSegs=function(b,c,d,e,f,g){var h=e.length;if(!(1>=h)){for(var i=e.map(function(c){return new a.vpsc.Variable(c[0][b])}),j=[],k=0;h>k;k++)for(var l=0;h>l;l++)if(k!==l){var m=e[k],n=e[l],o=m.edgeid,p=n.edgeid,q=-1,r=-1;"x"==b?f(o,p)&&(m[0][c]=0&&j.push(new a.vpsc.Constraint(i[q],i[r],g))}var s=new a.vpsc.Solver(i,j);s.solve(),i.forEach(function(a,c){var f=e[c],g=a.position();f[0][b]=f[1][b]=g;var h=d[f.edgeid];f.i>0&&(h[f.i-1][1][b]=g),f.iMath.PI||e<-Math.PI)&&(e=d-c),e},d.isLeft=function(a,b,c){return(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x)<=0},d.getOrder=function(a){for(var b={},c=0;c=j.length||l.ti+l.length>=k.length)?c.push({l:e,r:f}):(l.si+l.length>=j.length||l.ti+l.length>=k.length?(g=j[l.si+1],i=j[l.si-1],h=k[l.ti-1]):(g=j[l.si+l.length-2],h=j[l.si+l.length],i=k[l.ti+l.length]),d.isLeft(g,h,i)?c.push({l:f,r:e}):c.push({l:e,r:f})))}return a.GridRouter.getOrder(c)},d.makeSegments=function(a){function b(a){return{x:a.x,y:a.y}}for(var c=function(a,b,c){return Math.abs((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))<.001},d=[],e=b(a[0]),f=1;f1&&k>1?1e3:0},p=n.PathFromNodeToNodeWithPrevCost(e.ports[0].id,f.ports[0].id,o),q=p.reverse().map(function(a){return d.verts[a]});return q.push(this.nodes[f.id].ports[0]),q.filter(function(a,b){return!(b0&&a.node===f&&q[b-1].node===f)})},d.getRoutePath=function(a,b,c,e){var f={routepath:"M "+a[0][0].x+" "+a[0][0].y+" ",arrowpath:""};if(a.length>1)for(var g=0;g0?i-=k/Math.abs(k)*b:j-=l/Math.abs(l)*b,f.routepath+="L "+i+" "+j+" ";var m=a[g+1],n=m[0].x,o=m[0].y,p=m[1].x,q=m[1].y;k=p-n,l=q-o;var r,s,t=d.angleBetween2Lines(h,m)<0?1:0;Math.abs(k)>0?(r=n+k/Math.abs(k)*b,s=o):(r=n,s=o+l/Math.abs(l)*b);var u=Math.abs(r-i),v=Math.abs(s-j);f.routepath+="A "+u+" "+v+" 0 0 "+t+" "+r+" "+s+" "}else{var w,x,y=[i,j];Math.abs(k)>0?(i-=k/Math.abs(k)*e,w=[i,j+c],x=[i,j-c]):(j-=l/Math.abs(l)*e,w=[i+c,j],x=[i-c,j]),f.routepath+="L "+i+" "+j+" ",e>0&&(f.arrowpath="M "+y[0]+" "+y[1]+" L "+w[0]+" "+w[1]+" L "+x[0]+" "+x[1])}}else{var w,x,h=a[0],i=h[1].x,j=h[1].y,k=i-h[0].x,l=j-h[0].y,y=[i,j];Math.abs(k)>0?(i-=k/Math.abs(k)*e,w=[i,j+c],x=[i,j-c]):(j-=l/Math.abs(l)*e,w=[i+c,j],x=[i-c,j]),f.routepath+="L "+i+" "+j+" ",e>0&&(f.arrowpath="M "+y[0]+" "+y[1]+" L "+w[0]+" "+w[1]+" L "+x[0]+" "+x[1])}return f},d}();a.GridRouter=e}(cola||(cola={}));var cola;!function(a){var b=function(){function a(a,b){this.source=a,this.target=b}return a.prototype.actualLength=function(a){var b=this;return Math.sqrt(a.reduce(function(a,c){var d=c[b.target]-c[b.source];return a+d*d},0))},a}();a.Link3D=b;var c=function(){function a(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this.x=a,this.y=b,this.z=c}return a}();a.Node3D=c;var d=function(){function b(a,c,d){var e=this;void 0===d&&(d=1),this.nodes=a,this.links=c,this.idealLinkLength=d,this.constraints=null,this.useJaccardLinkLengths=!0,this.result=new Array(b.k);for(var f=0;f