/
jit-st.min.js
1 lines (1 loc) · 82.6 KB
/
jit-st.min.js
1
(function(){window.$jit=function(v){v=v||window;for(var x in $jit){if($jit[x].$extend){v[x]=$jit[x]}}};$jit.version="2.0.1";var c=function(v){return document.getElementById(v)};c.empty=function(){};c.extend=function(x,v){for(var w in (v||{})){x[w]=v[w]}return x};c.lambda=function(v){return(typeof v=="function")?v:function(){return v}};c.time=Date.now||function(){return +new Date};c.splat=function(w){var v=c.type(w);return v?((v!="array")?[w]:w):[]};c.type=function(w){var v=c.type.s.call(w).match(/^\[object\s(.*)\]$/)[1].toLowerCase();if(v!="object"){return v}if(w&&w.$$family){return w.$$family}return(w&&w.nodeName&&w.nodeType==1)?"element":v};c.type.s=Object.prototype.toString;c.each=function(A,z){var y=c.type(A);if(y=="object"){for(var x in A){z(A[x],x)}}else{for(var w=0,v=A.length;w<v;w++){z(A[w],w)}}};c.indexOf=function(y,x){if(Array.indexOf){return y.indexOf(x)}for(var w=0,v=y.length;w<v;w++){if(y[w]===x){return w}}return -1};c.map=function(x,w){var v=[];c.each(x,function(z,y){v.push(w(z,y))});return v};c.reduce=function(z,x,w){var v=z.length;if(v==0){return w}var y=arguments.length==3?w:z[--v];while(v--){y=x(y,z[v])}return y};c.merge=function(){var z={};for(var y=0,v=arguments.length;y<v;y++){var w=arguments[y];if(c.type(w)!="object"){continue}for(var x in w){var B=w[x],A=z[x];z[x]=(A&&c.type(B)=="object"&&c.type(A)=="object")?c.merge(A,B):c.unlink(B)}}return z};c.unlink=function(x){var w;switch(c.type(x)){case"object":w={};for(var z in x){w[z]=c.unlink(x[z])}break;case"array":w=[];for(var y=0,v=x.length;y<v;y++){w[y]=c.unlink(x[y])}break;default:return x}return w};c.zip=function(){if(arguments.length===0){return[]}for(var x=0,w=[],v=arguments.length,A=arguments[0].length;x<A;x++){for(var y=0,z=[];y<v;y++){z.push(arguments[y][x])}w.push(z)}return w};c.rgbToHex=function(z,y){if(z.length<3){return null}if(z.length==4&&z[3]==0&&!y){return"transparent"}var w=[];for(var v=0;v<3;v++){var x=(z[v]-0).toString(16);w.push(x.length==1?"0"+x:x)}return y?w:"#"+w.join("")};c.hexToRgb=function(x){if(x.length!=7){x=x.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);x.shift();if(x.length!=3){return null}var v=[];for(var w=0;w<3;w++){var y=x[w];if(y.length==1){y+=y}v.push(parseInt(y,16))}return v}else{x=parseInt(x.slice(1),16);return[x>>16,x>>8&255,x&255]}};c.destroy=function(v){c.clean(v);if(v.parentNode){v.parentNode.removeChild(v)}if(v.clearAttributes){v.clearAttributes()}};c.clean=function(y){for(var x=y.childNodes,w=0,v=x.length;w<v;w++){c.destroy(x[w])}};c.addEvent=function(x,w,v){if(x.addEventListener){x.addEventListener(w,v,false)}else{x.attachEvent("on"+w,v)}};c.addEvents=function(w,x){for(var v in x){c.addEvent(w,v,x[v])}};c.hasClass=function(w,v){return(" "+w.className+" ").indexOf(" "+v+" ")>-1};c.addClass=function(w,v){if(!c.hasClass(w,v)){w.className=(w.className+" "+v)}};c.removeClass=function(w,v){w.className=w.className.replace(new RegExp("(^|\\s)"+v+"(?:\\s|$)"),"$1")};c.getPos=function(x){var A=z(x);var v=y(x);return{x:A.x-v.x,y:A.y-v.y};function z(C){var B={x:0,y:0};while(C&&!w(C)){B.x+=C.offsetLeft;B.y+=C.offsetTop;C=C.offsetParent}return B}function y(C){var B={x:0,y:0};while(C&&!w(C)){B.x+=C.scrollLeft;B.y+=C.scrollTop;C=C.parentNode}return B}function w(B){return(/^(?:body|html)$/i).test(B.tagName)}};c.event={get:function(w,v){v=v||window;return w||v.event},getWheel:function(v){return v.wheelDelta?v.wheelDelta/120:-(v.detail||0)/3},isRightClick:function(v){return(v.which==3||v.button==2)},getPos:function(y,x){x=x||window;y=y||x.event;var w=x.document;w=w.documentElement||w.body;if(y.touches&&y.touches.length){y=y.touches[0]}var v={x:y.pageX||(y.clientX+w.scrollLeft),y:y.pageY||(y.clientY+w.scrollTop)};return v},stop:function(v){if(v.stopPropagation){v.stopPropagation()}v.cancelBubble=true;if(v.preventDefault){v.preventDefault()}else{v.returnValue=false}}};$jit.util=$jit.id=c;var q=function(w){w=w||{};var v=function(){for(var z in this){if(typeof this[z]!="function"){this[z]=c.unlink(this[z])}}this.constructor=v;if(q.prototyping){return this}var y=this.initialize?this.initialize.apply(this,arguments):this;this.$$family="class";return y};for(var x in q.Mutators){if(!w[x]){continue}w=q.Mutators[x](w,w[x]);delete w[x]}c.extend(v,this);v.constructor=q;v.prototype=w;return v};q.Mutators={Implements:function(v,w){c.each(c.splat(w),function(y){q.prototyping=y;var x=(typeof y=="function")?new y:y;for(var z in x){if(!(z in v)){v[z]=x[z]}}delete q.prototyping});return v}};c.extend(q,{inherit:function(v,y){for(var x in y){var w=y[x];var A=v[x];var z=c.type(w);if(A&&z=="function"){if(w!=A){q.override(v,x,w)}}else{if(z=="object"){v[x]=c.merge(A,w)}else{v[x]=w}}}return v},override:function(w,v,z){var y=q.prototyping;if(y&&w[v]!=y[v]){y=null}var x=function(){var A=this.parent;this.parent=y?y[v]:w[v];var B=z.apply(this,arguments);this.parent=A;return B};w[v]=x}});q.prototype.implement=function(){var v=this.prototype;c.each(Array.prototype.slice.call(arguments||[]),function(w){q.inherit(v,w)});return this};$jit.Class=q;$jit.json={prune:function(w,v){this.each(w,function(y,x){if(x==v&&y.children){delete y.children;y.children=[]}})},getParent:function(v,z){if(v.id==z){return false}var y=v.children;if(y&&y.length>0){for(var x=0;x<y.length;x++){if(y[x].id==z){return v}else{var w=this.getParent(y[x],z);if(w){return w}}}}return false},getSubtree:function(v,z){if(v.id==z){return v}for(var x=0,y=v.children;y&&x<y.length;x++){var w=this.getSubtree(y[x],z);if(w!=null){return w}}return null},eachLevel:function(v,A,x,z){if(A<=x){z(v,A);if(!v.children){return}for(var w=0,y=v.children;w<y.length;w++){this.eachLevel(y[w],A+1,x,z)}}},each:function(v,w){this.eachLevel(v,0,Number.MAX_VALUE,w)}};$jit.Trans={$extend:true,linear:function(v){return v}};var i=$jit.Trans;(function(){var v=function(y,x){x=c.splat(x);return c.extend(y,{easeIn:function(z){return y(z,x)},easeOut:function(z){return 1-y(1-z,x)},easeInOut:function(z){return(z<=0.5)?y(2*z,x)/2:(2-y(2*(1-z),x))/2}})};var w={Pow:function(z,y){return Math.pow(z,y[0]||6)},Expo:function(x){return Math.pow(2,8*(x-1))},Circ:function(x){return 1-Math.sin(Math.acos(x))},Sine:function(x){return 1-Math.sin((1-x)*Math.PI/2)},Back:function(z,y){y=y[0]||1.618;return Math.pow(z,2)*((y+1)*z-y)},Bounce:function(A){var z;for(var y=0,x=1;1;y+=x,x/=2){if(A>=(7-4*y)/11){z=x*x-Math.pow((11-6*y-11*A)/4,2);break}}return z},Elastic:function(z,y){return Math.pow(2,10*--z)*Math.cos(20*z*Math.PI*(y[0]||1)/3)}};c.each(w,function(y,x){i[x]=v(y)});c.each(["Quad","Cubic","Quart","Quint"],function(y,x){i[y]=v(function(z){return Math.pow(z,[x+2])})})})();var u=new q({initialize:function(v){this.setOptions(v)},setOptions:function(v){var w={duration:2500,fps:40,transition:i.Quart.easeInOut,compute:c.empty,complete:c.empty,link:"ignore"};this.opt=c.merge(w,v||{});return this},step:function(){var w=c.time(),v=this.opt;if(w<this.time+v.duration){var x=v.transition((w-this.time)/v.duration);v.compute(x)}else{this.timer=clearInterval(this.timer);v.compute(1);v.complete()}},start:function(){if(!this.check()){return this}this.time=0;this.startTimer();return this},startTimer:function(){var v=this,w=this.opt.fps;if(this.timer){return false}this.time=c.time()-this.time;this.timer=setInterval((function(){v.step()}),Math.round(1000/w));return true},pause:function(){this.stopTimer();return this},resume:function(){this.startTimer();return this},stopTimer:function(){if(!this.timer){return false}this.time=c.time()-this.time;this.timer=clearInterval(this.timer);return true},check:function(){if(!this.timer){return true}if(this.opt.link=="cancel"){this.stopTimer();return true}return false}});var n=function(){var x=arguments;for(var z=0,v=x.length,w={};z<v;z++){var y=n[x[z]];if(y.$extend){c.extend(w,y)}else{w[x[z]]=y}}return w};n.Canvas={$extend:true,injectInto:"id",type:"2D",width:false,height:false,useCanvas:false,withLabels:true,background:false,Scene:{Lighting:{enable:false,ambient:[1,1,1],directional:{direction:{x:-100,y:-100,z:-100},color:[0.5,0.3,0.1]}}}};n.Tree={$extend:true,orientation:"left",subtreeOffset:8,siblingOffset:5,indent:10,multitree:false,align:"center"};n.Node={$extend:false,overridable:false,type:"circle",color:"#ccb",alpha:1,dim:3,height:20,width:90,autoHeight:false,autoWidth:false,lineWidth:1,transform:true,align:"center",angularWidth:1,span:1,CanvasStyles:{}};n.Edge={$extend:false,overridable:false,type:"line",color:"#ccb",lineWidth:1,dim:15,alpha:1,epsilon:7,CanvasStyles:{}};n.Fx={$extend:true,fps:40,duration:2500,transition:$jit.Trans.Quart.easeInOut,clearCanvas:true};n.Label={$extend:false,overridable:false,type:"HTML",style:" ",size:10,family:"sans-serif",textAlign:"center",textBaseline:"alphabetic",color:"#fff"};n.Tips={$extend:false,enable:false,type:"auto",offsetX:20,offsetY:20,force:false,onShow:c.empty,onHide:c.empty};n.NodeStyles={$extend:false,enable:false,type:"auto",stylesHover:false,stylesClick:false};n.Events={$extend:false,enable:false,enableForEdges:false,type:"auto",onClick:c.empty,onRightClick:c.empty,onMouseMove:c.empty,onMouseEnter:c.empty,onMouseLeave:c.empty,onDragStart:c.empty,onDragMove:c.empty,onDragCancel:c.empty,onDragEnd:c.empty,onTouchStart:c.empty,onTouchMove:c.empty,onTouchEnd:c.empty,onMouseWheel:c.empty};n.Navigation={$extend:false,enable:false,type:"auto",panning:false,zooming:false};n.Controller={$extend:true,onBeforeCompute:c.empty,onAfterCompute:c.empty,onCreateLabel:c.empty,onPlaceLabel:c.empty,onComplete:c.empty,onBeforePlotLine:c.empty,onAfterPlotLine:c.empty,onBeforePlotNode:c.empty,onAfterPlotNode:c.empty,request:false};var t={initialize:function(x,v){this.viz=v;this.canvas=v.canvas;this.config=v.config[x];this.nodeTypes=v.fx.nodeTypes;var w=this.config.type;this.dom=w=="auto"?(v.config.Label.type!="Native"):(w!="Native");this.labelContainer=this.dom&&v.labels.getLabelContainer();this.isEnabled()&&this.initializePost()},initializePost:c.empty,setAsProperty:c.lambda(false),isEnabled:function(){return this.config.enable},isLabel:function(A,z,y){A=c.event.get(A,z);var v=this.labelContainer,x=A.target||A.srcElement,w=A.relatedTarget;if(y){return w&&w==this.viz.canvas.getCtx().canvas&&!!x&&this.isDescendantOf(x,v)}else{return this.isDescendantOf(x,v)}},isDescendantOf:function(w,v){while(w&&w.parentNode){if(w.parentNode==v){return w}w=w.parentNode}return false}};var h={onMouseUp:c.empty,onMouseDown:c.empty,onMouseMove:c.empty,onMouseOver:c.empty,onMouseOut:c.empty,onMouseWheel:c.empty,onTouchStart:c.empty,onTouchMove:c.empty,onTouchEnd:c.empty,onTouchCancel:c.empty};var s=new q({initialize:function(v){this.viz=v;this.canvas=v.canvas;this.node=false;this.edge=false;this.registeredObjects=[];this.attachEvents()},attachEvents:function(){var x=this.canvas.getElement(),w=this;x.oncontextmenu=c.lambda(false);c.addEvents(x,{mouseup:function(A,z){var y=c.event.get(A,z);w.handleEvent("MouseUp",A,z,w.makeEventObject(A,z),c.event.isRightClick(y))},mousedown:function(A,z){var y=c.event.get(A,z);w.handleEvent("MouseDown",A,z,w.makeEventObject(A,z),c.event.isRightClick(y))},mousemove:function(z,y){w.handleEvent("MouseMove",z,y,w.makeEventObject(z,y))},mouseover:function(z,y){w.handleEvent("MouseOver",z,y,w.makeEventObject(z,y))},mouseout:function(z,y){w.handleEvent("MouseOut",z,y,w.makeEventObject(z,y))},touchstart:function(z,y){w.handleEvent("TouchStart",z,y,w.makeEventObject(z,y))},touchmove:function(z,y){w.handleEvent("TouchMove",z,y,w.makeEventObject(z,y))},touchend:function(z,y){w.handleEvent("TouchEnd",z,y,w.makeEventObject(z,y))}});var v=function(B,A){var z=c.event.get(B,A);var y=c.event.getWheel(z);w.handleEvent("MouseWheel",B,A,y)};if(!document.getBoxObjectFor&&window.mozInnerScreenX==null){c.addEvent(x,"mousewheel",v)}else{x.addEventListener("DOMMouseScroll",v,false)}},register:function(v){this.registeredObjects.push(v)},handleEvent:function(){var w=Array.prototype.slice.call(arguments),z=w.shift();for(var y=0,x=this.registeredObjects,v=x.length;y<v;y++){x[y]["on"+z].apply(x[y],w)}},makeEventObject:function(B,A){var y=this,z=this.viz.graph,x=this.viz.fx,w=x.nodeTypes,v=x.edgeTypes;return{pos:false,node:false,edge:false,contains:false,getNodeCalled:false,getEdgeCalled:false,getPos:function(){var E=y.viz.canvas,F=E.getSize(),G=E.getPos(),D=E.translateOffsetX,C=E.translateOffsetY,J=E.scaleOffsetX,H=E.scaleOffsetY,I=c.event.getPos(B,A);this.pos={x:(I.x-G.x-F.width/2-D)*1/J,y:(I.y-G.y-F.height/2-C)*1/H};return this.pos},getNode:function(){if(this.getNodeCalled){return this.node}this.getNodeCalled=true;for(var F in z.nodes){var E=z.nodes[F],D=E&&w[E.getData("type")],C=D&&D.contains&&D.contains.call(x,E,this.getPos());if(C){this.contains=C;return y.node=this.node=E}}return y.node=this.node=false},getEdge:function(){if(this.getEdgeCalled){return this.edge}this.getEdgeCalled=true;var E={};for(var I in z.edges){var G=z.edges[I];E[I]=true;for(var H in G){if(H in E){continue}var F=G[H],D=F&&v[F.getData("type")],C=D&&D.contains&&D.contains.call(x,F,this.getPos());if(C){this.contains=C;return y.edge=this.edge=F}}}return y.edge=this.edge=false},getContains:function(){if(this.getNodeCalled){return this.contains}this.getNode();return this.contains}}}});var o={initializeExtras:function(){var w=new s(this),v=this;c.each(["NodeStyles","Tips","Navigation","Events"],function(x){var y=new o.Classes[x](x,v);if(y.isEnabled()){w.register(y)}if(y.setAsProperty()){v[x.toLowerCase()]=y}})}};o.Classes={};o.Classes.Events=new q({Implements:[t,h],initializePost:function(){this.fx=this.viz.fx;this.ntypes=this.viz.fx.nodeTypes;this.etypes=this.viz.fx.edgeTypes;this.hovered=false;this.pressed=false;this.touched=false;this.touchMoved=false;this.moved=false},setAsProperty:c.lambda(true),onMouseUp:function(z,y,w,x){var v=c.event.get(z,y);if(!this.moved){if(x){this.config.onRightClick(this.hovered,w,v)}else{this.config.onClick(this.pressed,w,v)}}if(this.pressed){if(this.moved){this.config.onDragEnd(this.pressed,w,v)}else{this.config.onDragCancel(this.pressed,w,v)}this.pressed=this.moved=false}},onMouseOut:function(A,z,y){var w=c.event.get(A,z),x;if(this.dom&&(x=this.isLabel(A,z,true))){this.config.onMouseLeave(this.viz.graph.getNode(x.id),y,w);this.hovered=false;return}var v=w.relatedTarget,B=this.canvas.getElement();while(v&&v.parentNode){if(B==v.parentNode){return}v=v.parentNode}if(this.hovered){this.config.onMouseLeave(this.hovered,y,w);this.hovered=false}},onMouseOver:function(z,y,x){var v=c.event.get(z,y),w;if(this.dom&&(w=this.isLabel(z,y,true))){this.hovered=this.viz.graph.getNode(w.id);this.config.onMouseEnter(this.hovered,x,v)}},onMouseMove:function(B,A,z){var w,v=c.event.get(B,A);if(this.pressed){this.moved=true;this.config.onDragMove(this.pressed,z,v);return}if(this.dom){this.config.onMouseMove(this.hovered,z,v)}else{if(this.hovered){var C=this.hovered;var y=C.nodeFrom?this.etypes[C.getData("type")]:this.ntypes[C.getData("type")];var x=y&&y.contains&&y.contains.call(this.fx,C,z.getPos());if(x){this.config.onMouseMove(C,z,v);return}else{this.config.onMouseLeave(C,z,v);this.hovered=false}}if(this.hovered=(z.getNode()||(this.config.enableForEdges&&z.getEdge()))){this.config.onMouseEnter(this.hovered,z,v)}else{this.config.onMouseMove(false,z,v)}}},onMouseWheel:function(w,v,x){this.config.onMouseWheel(x,c.event.get(w,v))},onMouseDown:function(z,y,x){var v=c.event.get(z,y),w;if(this.dom){if(w=this.isLabel(z,y)){this.pressed=this.viz.graph.getNode(w.id)}}else{this.pressed=x.getNode()||(this.config.enableForEdges&&x.getEdge())}this.pressed&&this.config.onDragStart(this.pressed,x,v)},onTouchStart:function(z,y,x){var v=c.event.get(z,y),w;if(this.dom&&(w=this.isLabel(z,y))){this.touched=this.viz.graph.getNode(w.id)}else{this.touched=x.getNode()||(this.config.enableForEdges&&x.getEdge())}this.touched&&this.config.onTouchStart(this.touched,x,v)},onTouchMove:function(y,x,w){var v=c.event.get(y,x);if(this.touched){this.touchMoved=true;this.config.onTouchMove(this.touched,w,v)}},onTouchEnd:function(y,x,w){var v=c.event.get(y,x);if(this.touched){if(this.touchMoved){this.config.onTouchEnd(this.touched,w,v)}else{this.config.onTouchCancel(this.touched,w,v)}this.touched=this.touchMoved=false}}});o.Classes.Tips=new q({Implements:[t,h],initializePost:function(){if(document.body){var v=c("_tooltip")||document.createElement("div");v.id="_tooltip";v.className="tip";c.extend(v.style,{position:"absolute",display:"none",zIndex:13000});document.body.appendChild(v);this.tip=v;this.node=false}},setAsProperty:c.lambda(true),onMouseOut:function(y,x){var w=c.event.get(y,x);if(this.dom&&this.isLabel(y,x,true)){this.hide(true);return}var v=y.relatedTarget,z=this.canvas.getElement();while(v&&v.parentNode){if(z==v.parentNode){return}v=v.parentNode}this.hide(false)},onMouseOver:function(x,w){var v;if(this.dom&&(v=this.isLabel(x,w,false))){this.node=this.viz.graph.getNode(v.id);this.config.onShow(this.tip,this.node,v)}},onMouseMove:function(y,x,v){if(this.dom&&this.isLabel(y,x)){this.setTooltipPosition(c.event.getPos(y,x))}if(!this.dom){var w=v.getNode();if(!w){this.hide(true);return}if(this.config.force||!this.node||this.node.id!=w.id){this.node=w;this.config.onShow(this.tip,w,v.getContains())}this.setTooltipPosition(c.event.getPos(y,x))}},setTooltipPosition:function(E){var A=this.tip,z=A.style,w=this.config;z.display="";var C={height:document.body.clientHeight,width:document.body.clientWidth};var B={width:A.offsetWidth,height:A.offsetHeight};var v=w.offsetX,D=w.offsetY;z.top=((E.y+D+B.height>C.height)?(E.y-B.height-D):E.y+D)+"px";z.left=((E.x+B.width+v>C.width)?(E.x-B.width-v):E.x+v)+"px"},hide:function(v){this.tip.style.display="none";v&&this.config.onHide()}});o.Classes.NodeStyles=new q({Implements:[t,h],initializePost:function(){this.fx=this.viz.fx;this.types=this.viz.fx.nodeTypes;this.nStyles=this.config;this.nodeStylesOnHover=this.nStyles.stylesHover;this.nodeStylesOnClick=this.nStyles.stylesClick;this.hoveredNode=false;this.fx.nodeFxAnimation=new u();this.down=false;this.move=false},onMouseOut:function(x,w){this.down=this.move=false;if(!this.hoveredNode){return}if(this.dom&&this.isLabel(x,w,true)){this.toggleStylesOnHover(this.hoveredNode,false)}var v=x.relatedTarget,y=this.canvas.getElement();while(v&&v.parentNode){if(y==v.parentNode){return}v=v.parentNode}this.toggleStylesOnHover(this.hoveredNode,false);this.hoveredNode=false},onMouseOver:function(y,x){var v;if(this.dom&&(v=this.isLabel(y,x,true))){var w=this.viz.graph.getNode(v.id);if(w.selected){return}this.hoveredNode=w;this.toggleStylesOnHover(this.hoveredNode,true)}},onMouseDown:function(z,y,w,x){if(x){return}var v;if(this.dom&&(v=this.isLabel(z,y))){this.down=this.viz.graph.getNode(v.id)}else{if(!this.dom){this.down=w.getNode()}}this.move=false},onMouseUp:function(y,x,v,w){if(w){return}if(!this.move){this.onClick(v.getNode())}this.down=this.move=false},getRestoredStyles:function(w,v){var y={},x=this["nodeStylesOn"+v];for(var z in x){y[z]=w.styles["$"+z]}return y},toggleStylesOnHover:function(v,w){if(this.nodeStylesOnHover){this.toggleStylesOn("Hover",v,w)}},toggleStylesOnClick:function(v,w){if(this.nodeStylesOnClick){this.toggleStylesOn("Click",v,w)}},toggleStylesOn:function(z,v,B){var C=this.viz;var A=this.nStyles;if(B){var y=this;if(!v.styles){v.styles=c.merge(v.data,{})}for(var D in this["nodeStylesOn"+z]){var w="$"+D;if(!(w in v.styles)){v.styles[w]=v.getData(D)}}C.fx.nodeFx(c.extend({elements:{id:v.id,properties:y["nodeStylesOn"+z]},transition:i.Quart.easeOut,duration:300,fps:40},this.config))}else{var x=this.getRestoredStyles(v,z);C.fx.nodeFx(c.extend({elements:{id:v.id,properties:x},transition:i.Quart.easeOut,duration:300,fps:40},this.config))}},onClick:function(v){if(!v){return}var w=this.nodeStylesOnClick;if(!w){return}if(v.selected){this.toggleStylesOnClick(v,false);delete v.selected}else{this.viz.graph.eachNode(function(y){if(y.selected){for(var x in w){y.setData(x,y.styles["$"+x],"end")}delete y.selected}});this.toggleStylesOnClick(v,true);v.selected=true;delete v.hovered;this.hoveredNode=false}},onMouseMove:function(B,A,y){if(this.down){this.move=true}if(this.dom&&this.isLabel(B,A)){return}var z=this.nodeStylesOnHover;if(!z){return}if(!this.dom){if(this.hoveredNode){var w=this.types[this.hoveredNode.getData("type")];var v=w&&w.contains&&w.contains.call(this.fx,this.hoveredNode,y.getPos());if(v){return}}var x=y.getNode();if(!this.hoveredNode&&!x){return}if(x.hovered){return}if(x&&!x.selected){this.fx.nodeFxAnimation.stopTimer();this.viz.graph.eachNode(function(D){if(D.hovered&&!D.selected){for(var C in z){D.setData(C,D.styles["$"+C],"end")}delete D.hovered}});x.hovered=true;this.hoveredNode=x;this.toggleStylesOnHover(x,true)}else{if(this.hoveredNode&&!this.hoveredNode.selected){this.fx.nodeFxAnimation.stopTimer();this.toggleStylesOnHover(this.hoveredNode,false);delete this.hoveredNode.hovered;this.hoveredNode=false}}}}});o.Classes.Navigation=new q({Implements:[t,h],initializePost:function(){this.pos=false;this.pressed=false},onMouseWheel:function(y,x,v){if(!this.config.zooming){return}c.event.stop(c.event.get(y,x));var z=this.config.zooming/1000,w=1+v*z;this.canvas.scale(w,w)},onMouseDown:function(A,z,y){if(!this.config.panning){return}if(this.config.panning=="avoid nodes"&&(this.dom?this.isLabel(A,z):y.getNode())){return}this.pressed=true;c.event.stop(c.event.get(A,z));this.canvas.getElement().style.cursor="move";this.pos=y.getPos();var x=this.canvas,w=x.translateOffsetX,v=x.translateOffsetY,C=x.scaleOffsetX,B=x.scaleOffsetY;this.pos.x*=C;this.pos.x+=w;this.pos.y*=B;this.pos.y+=v},onMouseMove:function(C,B,E){if(!this.config.panning){return}if(!this.pressed){return}if(this.config.panning=="avoid nodes"&&(this.dom?this.isLabel(C,B):E.getNode())){return}var A=this.pos,D=E.getPos(),w=this.canvas,z=w.translateOffsetX,v=w.translateOffsetY,I=w.scaleOffsetX,G=w.scaleOffsetY;D.x*=I;D.y*=G;D.x+=z;D.y+=v;var H=D.x-A.x,F=D.y-A.y;this.pos=D;this.canvas.translate(H*1/I,F*1/G)},onMouseUp:function(y,x,w,v){if(!this.config.panning){return}this.pressed=false;this.canvas.getElement().style.cursor=""}});var l;(function(){var v=typeof HTMLCanvasElement,x=(v=="object"||v=="function");function w(y,z){var A=document.createElement(y);for(var B in z){if(typeof z[B]=="object"){c.extend(A[B],z[B])}else{A[B]=z[B]}}if(y=="canvas"&&!x&&G_vmlCanvasManager){A=G_vmlCanvasManager.initElement(document.body.appendChild(A))}return A}$jit.Canvas=l=new q({canvases:[],pos:false,element:false,labelContainer:false,translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(K,D){this.viz=K;this.opt=this.config=D;var A=c.type(D.injectInto)=="string"?D.injectInto:D.injectInto.id,J=D.type,B=A+"-label",y=c(A),C=D.width||y.offsetWidth,L=D.height||y.offsetHeight;this.id=A;var E={injectInto:A,width:C,height:L};this.element=w("div",{id:A+"-canvaswidget",style:{position:"relative",width:C+"px",height:L+"px"}});this.labelContainer=this.createLabelContainer(D.Label.type,B,E);this.canvases.push(new l.Base[J]({config:c.extend({idSuffix:"-canvas"},E),plot:function(M){K.fx.plot()},resize:function(){K.plot()}}));var F=D.background;if(F){var I=new l.Background[F.type](K,c.extend(F,E));this.canvases.push(new l.Base[J](I))}var H=this.canvases.length;while(H--){this.element.appendChild(this.canvases[H].canvas);if(H>0){this.canvases[H].plot()}}this.element.appendChild(this.labelContainer);y.appendChild(this.element);var z=null,G=this;c.addEvent(window,"scroll",function(){clearTimeout(z);z=setTimeout(function(){G.getPos(true)},500)})},getCtx:function(y){return this.canvases[y||0].getCtx()},getConfig:function(){return this.opt},getElement:function(){return this.element},getSize:function(y){return this.canvases[y||0].getSize()},resize:function(C,y){this.getPos(true);this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;for(var A=0,z=this.canvases.length;A<z;A++){this.canvases[A].resize(C,y)}var B=this.element.style;B.width=C+"px";B.height=y+"px";if(this.labelContainer){this.labelContainer.style.width=C+"px"}},translate:function(z,D,C){this.translateOffsetX+=z*this.scaleOffsetX;this.translateOffsetY+=D*this.scaleOffsetY;for(var B=0,A=this.canvases.length;B<A;B++){this.canvases[B].translate(z,D,C)}},scale:function(E,B,C){var F=this.scaleOffsetX*E,D=this.scaleOffsetY*B;var H=this.translateOffsetX*(E-1)/F,G=this.translateOffsetY*(B-1)/D;this.scaleOffsetX=F;this.scaleOffsetY=D;for(var A=0,z=this.canvases.length;A<z;A++){this.canvases[A].scale(E,B,true)}this.translate(H,G,false)},getPos:function(y){if(y||!this.pos){return this.pos=c.getPos(this.getElement())}return this.pos},clear:function(y){this.canvases[y||0].clear()},path:function(z,A){var y=this.canvases[0].getCtx();y.beginPath();A(y);y[z]();y.closePath()},createLabelContainer:function(A,E,D){var C="http://www.w3.org/2000/svg";if(A=="HTML"||A=="Native"){return w("div",{id:E,style:{overflow:"visible",position:"absolute",top:0,left:0,width:D.width+"px",height:0}})}else{if(A=="SVG"){var B=document.createElementNS(C,"svg:svg");B.setAttribute("width",D.width);B.setAttribute("height",D.height);var z=B.style;z.position="absolute";z.left=z.top="0px";var y=document.createElementNS(C,"svg:g");y.setAttribute("width",D.width);y.setAttribute("height",D.height);y.setAttribute("x",0);y.setAttribute("y",0);y.setAttribute("id",E);B.appendChild(y);return B}}}});l.Base={};l.Base["2D"]=new q({translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(y){this.viz=y;this.opt=y.config;this.size=false;this.createCanvas();this.translateToCenter()},createCanvas:function(){var z=this.opt,A=z.width,y=z.height;this.canvas=w("canvas",{id:z.injectInto+z.idSuffix,width:A,height:y,style:{position:"absolute",top:0,left:0,width:A+"px",height:y+"px"}})},getCtx:function(){if(!this.ctx){return this.ctx=this.canvas.getContext("2d")}return this.ctx},getSize:function(){if(this.size){return this.size}var y=this.canvas;return this.size={width:y.width,height:y.height}},translateToCenter:function(B){var z=this.getSize(),A=B?(z.width-B.width-this.translateOffsetX*2):z.width;height=B?(z.height-B.height-this.translateOffsetY*2):z.height;var y=this.getCtx();B&&y.scale(1/this.scaleOffsetX,1/this.scaleOffsetY);y.translate(A/2,height/2)},resize:function(B,y){var A=this.getSize(),z=this.canvas,C=z.style;this.size=false;z.width=B;z.height=y;C.width=B+"px";C.height=y+"px";if(!x){this.translateToCenter(A)}else{this.translateToCenter()}this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;this.clear();this.viz.resize(B,y,this)},translate:function(z,D,A){var C=this.scaleOffsetX,B=this.scaleOffsetY;this.translateOffsetX+=z*C;this.translateOffsetY+=D*B;this.getCtx().translate(z,D);!A&&this.plot()},scale:function(z,B,A){this.scaleOffsetX*=z;this.scaleOffsetY*=B;this.getCtx().scale(z,B);!A&&this.plot()},clear:function(){var A=this.getSize(),z=this.translateOffsetX,y=this.translateOffsetY,C=this.scaleOffsetX,B=this.scaleOffsetY;this.getCtx().clearRect((-A.width/2-z)*1/C,(-A.height/2-y)*1/B,A.width*1/C,A.height*1/B)},plot:function(){this.clear();this.viz.plot(this)}});l.Background={};l.Background.Circles=new q({initialize:function(y,z){this.viz=y;this.config=c.merge({idSuffix:"-bkcanvas",levelDistance:100,numberOfCircles:6,CanvasStyles:{},offset:0},z)},resize:function(z,y,A){this.plot(A)},plot:function(y){var z=y.canvas,F=y.getCtx(),C=this.config,E=C.CanvasStyles;for(var G in E){F[G]=E[G]}var A=C.numberOfCircles,D=C.levelDistance;for(var B=1;B<=A;B++){F.beginPath();F.arc(0,0,D*B,0,2*Math.PI,false);F.stroke();F.closePath()}}})})();var b=function(w,v){this.theta=w||0;this.rho=v||0};$jit.Polar=b;b.prototype={getc:function(v){return this.toComplex(v)},getp:function(){return this},set:function(w){w=w.getp();this.theta=w.theta;this.rho=w.rho},setc:function(v,w){this.rho=Math.sqrt(v*v+w*w);this.theta=Math.atan2(w,v);if(this.theta<0){this.theta+=Math.PI*2}},setp:function(w,v){this.theta=w;this.rho=v},clone:function(){return new b(this.theta,this.rho)},toComplex:function(z){var v=Math.cos(this.theta)*this.rho;var w=Math.sin(this.theta)*this.rho;if(z){return{x:v,y:w}}return new p(v,w)},add:function(v){return new b(this.theta+v.theta,this.rho+v.rho)},scale:function(v){return new b(this.theta,this.rho*v)},equals:function(v){return this.theta==v.theta&&this.rho==v.rho},$add:function(v){this.theta=this.theta+v.theta;this.rho+=v.rho;return this},$madd:function(v){this.theta=(this.theta+v.theta)%(Math.PI*2);this.rho+=v.rho;return this},$scale:function(v){this.rho*=v;return this},isZero:function(){var w=0.0001,v=Math.abs;return v(this.theta)<w&&v(this.rho)<w},interpolate:function(x,E){var y=Math.PI,B=y*2;var w=function(G){var F=(G<0)?(G%B)+B:G%B;return F};var A=this.theta,D=x.theta;var z,C=Math.abs(A-D);if(C==y){if(A>D){z=w((D+((A-B)-D)*E))}else{z=w((D-B+(A-(D))*E))}}else{if(C>=y){if(A>D){z=w((D+((A-B)-D)*E))}else{z=w((D-B+(A-(D-B))*E))}}else{z=w((D+(A-D)*E))}}var v=(this.rho-x.rho)*E+x.rho;return{theta:z,rho:v}}};var k=function(w,v){return new b(w,v)};b.KER=k(0,0);var p=function(v,w){this.x=v||0;this.y=w||0};$jit.Complex=p;p.prototype={getc:function(){return this},getp:function(v){return this.toPolar(v)},set:function(v){v=v.getc(true);this.x=v.x;this.y=v.y},setc:function(v,w){this.x=v;this.y=w},setp:function(w,v){this.x=Math.cos(w)*v;this.y=Math.sin(w)*v},clone:function(){return new p(this.x,this.y)},toPolar:function(x){var v=this.norm();var w=Math.atan2(this.y,this.x);if(w<0){w+=Math.PI*2}if(x){return{theta:w,rho:v}}return new b(w,v)},norm:function(){return Math.sqrt(this.squaredNorm())},squaredNorm:function(){return this.x*this.x+this.y*this.y},add:function(v){return new p(this.x+v.x,this.y+v.y)},prod:function(v){return new p(this.x*v.x-this.y*v.y,this.y*v.x+this.x*v.y)},conjugate:function(){return new p(this.x,-this.y)},scale:function(v){return new p(this.x*v,this.y*v)},equals:function(v){return this.x==v.x&&this.y==v.y},$add:function(v){this.x+=v.x;this.y+=v.y;return this},$prod:function(z){var v=this.x,w=this.y;this.x=v*z.x-w*z.y;this.y=w*z.x+v*z.y;return this},$conjugate:function(){this.y=-this.y;return this},$scale:function(v){this.x*=v;this.y*=v;return this},$div:function(A){var v=this.x,z=this.y;var w=A.squaredNorm();this.x=v*A.x+z*A.y;this.y=z*A.x-v*A.y;return this.$scale(1/w)},isZero:function(){var w=0.0001,v=Math.abs;return v(this.x)<w&&v(this.y)<w}};var r=function(w,v){return new p(w,v)};p.KER=r(0,0);$jit.Graph=new q({initialize:function(x,w,v,B){var z={klass:p,Node:{}};this.Node=w;this.Edge=v;this.Label=B;this.opt=c.merge(z,x||{});this.nodes={};this.edges={};var y=this;this.nodeList={};for(var A in j){y.nodeList[A]=(function(C){return function(){var D=Array.prototype.slice.call(arguments);y.eachNode(function(E){E[C].apply(E,D)})}})(A)}},getNode:function(v){if(this.hasNode(v)){return this.nodes[v]}return false},get:function(v){return this.getNode(v)},getByName:function(v){for(var x in this.nodes){var w=this.nodes[x];if(w.name==v){return w}}return false},getAdjacence:function(w,v){if(w in this.edges){return this.edges[w][v]}return false},addNode:function(w){if(!this.nodes[w.id]){var v=this.edges[w.id]={};this.nodes[w.id]=new e.Node(c.extend({id:w.id,name:w.name,data:c.merge(w.data||{},{}),adjacencies:v},this.opt.Node),this.opt.klass,this.Node,this.Edge,this.Label)}return this.nodes[w.id]},addAdjacence:function(y,x,w){if(!this.hasNode(y.id)){this.addNode(y)}if(!this.hasNode(x.id)){this.addNode(x)}y=this.nodes[y.id];x=this.nodes[x.id];if(!y.adjacentTo(x)){var z=this.edges[y.id]=this.edges[y.id]||{};var v=this.edges[x.id]=this.edges[x.id]||{};z[x.id]=v[y.id]=new e.Adjacence(y,x,w,this.Edge,this.Label);return z[x.id]}return this.edges[y.id][x.id]},removeNode:function(x){if(this.hasNode(x)){delete this.nodes[x];var w=this.edges[x];for(var v in w){delete this.edges[v][x]}delete this.edges[x]}},removeAdjacence:function(w,v){delete this.edges[w][v];delete this.edges[v][w]},hasNode:function(v){return v in this.nodes},empty:function(){this.nodes={};this.edges={}}});var e=$jit.Graph;var j;(function(){var v=function(C,E,z,B,D){var A;z=z||"current";C="$"+(C?C+"-":"");if(z=="current"){A=this.data}else{if(z=="start"){A=this.startData}else{if(z=="end"){A=this.endData}}}var y=C+E;if(B){return A[y]}if(!this.Config.overridable){return D[E]||0}return(y in A)?A[y]:((y in this.data)?this.data[y]:(D[E]||0))};var x=function(B,C,A,y){y=y||"current";B="$"+(B?B+"-":"");var z;if(y=="current"){z=this.data}else{if(y=="start"){z=this.startData}else{if(y=="end"){z=this.endData}}}z[B+C]=A};var w=function(A,y){A="$"+(A?A+"-":"");var z=this;c.each(y,function(C){var B=A+C;delete z.data[B];delete z.endData[B];delete z.startData[B]})};j={getData:function(A,y,z){return v.call(this,"",A,y,z,this.Config)},setData:function(A,z,y){x.call(this,"",A,z,y)},setDataset:function(B,C){B=c.splat(B);for(var y in C){for(var A=0,D=c.splat(C[y]),z=B.length;A<z;A++){this.setData(y,D[A],B[A])}}},removeData:function(){w.call(this,"",Array.prototype.slice.call(arguments))},getCanvasStyle:function(A,y,z){return v.call(this,"canvas",A,y,z,this.Config.CanvasStyles)},setCanvasStyle:function(A,z,y){x.call(this,"canvas",A,z,y)},setCanvasStyles:function(B,C){B=c.splat(B);for(var y in C){for(var A=0,D=c.splat(C[y]),z=B.length;A<z;A++){this.setCanvasStyle(y,D[A],B[A])}}},removeCanvasStyle:function(){w.call(this,"canvas",Array.prototype.slice.call(arguments))},getLabelData:function(A,y,z){return v.call(this,"label",A,y,z,this.Label)},setLabelData:function(A,z,y){x.call(this,"label",A,z,y)},setLabelDataset:function(B,C){B=c.splat(B);for(var y in C){for(var A=0,D=c.splat(C[y]),z=B.length;A<z;A++){this.setLabelData(y,D[A],B[A])}}},removeLabelData:function(){w.call(this,"label",Array.prototype.slice.call(arguments))}}})();e.Node=new q({initialize:function(y,v,x,w,A){var z={id:"",name:"",data:{},startData:{},endData:{},adjacencies:{},selected:false,drawn:false,exist:false,angleSpan:{begin:0,end:0},pos:new v,startPos:new v,endPos:new v};c.extend(this,c.extend(z,y));this.Config=this.Node=x;this.Edge=w;this.Label=A},adjacentTo:function(v){return v.id in this.adjacencies},getAdjacency:function(v){return this.adjacencies[v]},getPos:function(v){v=v||"current";if(v=="current"){return this.pos}else{if(v=="end"){return this.endPos}else{if(v=="start"){return this.startPos}}}},setPos:function(w,v){v=v||"current";var x;if(v=="current"){x=this.pos}else{if(v=="end"){x=this.endPos}else{if(v=="start"){x=this.startPos}}}x.set(w)}});e.Node.implement(j);e.Adjacence=new q({initialize:function(w,z,x,v,y){this.nodeFrom=w;this.nodeTo=z;this.data=x||{};this.startData={};this.endData={};this.Config=this.Edge=v;this.Label=y}});e.Adjacence.implement(j);e.Util={filter:function(w){if(!w||!(c.type(w)=="string")){return function(){return true}}var v=w.split(" ");return function(y){for(var x=0;x<v.length;x++){if(y[v[x]]){return false}}return true}},getNode:function(v,w){return v.nodes[w]},eachNode:function(z,y,v){var x=this.filter(v);for(var w in z.nodes){if(x(z.nodes[w])){y(z.nodes[w])}}},each:function(x,w,v){this.eachNode(x,w,v)},eachAdjacency:function(A,B,w){var x=A.adjacencies,z=this.filter(w);for(var C in x){var v=x[C];if(z(v)){if(v.nodeFrom!=A){var y=v.nodeFrom;v.nodeFrom=v.nodeTo;v.nodeTo=y}B(v,C)}}},computeLevels:function(B,C,y,x){y=y||0;var z=this.filter(x);this.eachNode(B,function(D){D._flag=false;D._depth=-1},x);var w=B.getNode(C);w._depth=y;var v=[w];while(v.length!=0){var A=v.pop();A._flag=true;this.eachAdjacency(A,function(D){var E=D.nodeTo;if(E._flag==false&&z(E)){if(E._depth<0){E._depth=A._depth+1+y}v.unshift(E)}},x)}},eachBFS:function(A,B,z,w){var x=this.filter(w);this.clean(A);var v=[A.getNode(B)];while(v.length!=0){var y=v.pop();y._flag=true;z(y,y._depth);this.eachAdjacency(y,function(C){var D=C.nodeTo;if(D._flag==false&&x(D)){D._flag=true;v.unshift(D)}},w)}},eachLevel:function(z,D,w,A,y){var C=z._depth,v=this.filter(y),B=this;w=w===false?Number.MAX_VALUE-C:w;(function x(G,E,F){var H=G._depth;if(H>=E&&H<=F&&v(G)){A(G,H)}if(H<F){B.eachAdjacency(G,function(I){var J=I.nodeTo;if(J._depth>H){x(J,E,F)}})}})(z,D+C,w+C)},eachSubgraph:function(w,x,v){this.eachLevel(w,0,false,x,v)},eachSubnode:function(w,x,v){this.eachLevel(w,1,1,x,v)},anySubnode:function(y,x,w){var v=false;x=x||c.lambda(true);var z=c.type(x)=="string"?function(A){return A[x]}:x;this.eachSubnode(y,function(A){if(z(A)){v=true}},w);return v},getSubnodes:function(A,B,v){var x=[],z=this;B=B||0;var y,w;if(c.type(B)=="array"){y=B[0];w=B[1]}else{y=B;w=Number.MAX_VALUE-A._depth}this.eachLevel(A,y,w,function(C){x.push(C)},v);return x},getParents:function(w){var v=[];this.eachAdjacency(w,function(x){var y=x.nodeTo;if(y._depth<w._depth){v.push(y)}});return v},isDescendantOf:function(y,z){if(y.id==z){return true}var x=this.getParents(y),v=false;for(var w=0;!v&&w<x.length;w++){v=v||this.isDescendantOf(x[w],z)}return v},clean:function(v){this.eachNode(v,function(w){w._flag=false})},getClosestNodeToOrigin:function(w,x,v){return this.getClosestNodeToPos(w,b.KER,x,v)},getClosestNodeToPos:function(x,A,z,v){var w=null;z=z||"current";A=A&&A.getc(true)||p.KER;var y=function(C,B){var E=C.x-B.x,D=C.y-B.y;return E*E+D*D};this.eachNode(x,function(B){w=(w==null||y(B.getPos(z).getc(true),A)<y(w.getPos(z).getc(true),A))?B:w},v);return w}};c.each(["get","getNode","each","eachNode","computeLevels","eachBFS","clean","getClosestNodeToPos","getClosestNodeToOrigin"],function(v){e.prototype[v]=function(){return e.Util[v].apply(e.Util,[this].concat(Array.prototype.slice.call(arguments)))}});c.each(["eachAdjacency","eachLevel","eachSubgraph","eachSubnode","anySubnode","getSubnodes","getParents","isDescendantOf"],function(v){e.Node.prototype[v]=function(){return e.Util[v].apply(e.Util,[this].concat(Array.prototype.slice.call(arguments)))}});e.Op={options:{type:"nothing",duration:2000,hideLabels:true,fps:30},initialize:function(v){this.viz=v},removeNode:function(A,y){var v=this.viz;var w=c.merge(this.options,v.controller,y);var C=c.splat(A);var x,z,B;switch(w.type){case"nothing":for(x=0;x<C.length;x++){v.graph.removeNode(C[x])}break;case"replot":this.removeNode(C,{type:"nothing"});v.labels.clearLabels();v.refresh(true);break;case"fade:seq":case"fade":z=this;for(x=0;x<C.length;x++){B=v.graph.getNode(C[x]);B.setData("alpha",0,"end")}v.fx.animate(c.merge(w,{modes:["node-property:alpha"],onComplete:function(){z.removeNode(C,{type:"nothing"});v.labels.clearLabels();v.reposition();v.fx.animate(c.merge(w,{modes:["linear"]}))}}));break;case"fade:con":z=this;for(x=0;x<C.length;x++){B=v.graph.getNode(C[x]);B.setData("alpha",0,"end");B.ignore=true}v.reposition();v.fx.animate(c.merge(w,{modes:["node-property:alpha","linear"],onComplete:function(){z.removeNode(C,{type:"nothing"});w.onComplete&&w.onComplete()}}));break;case"iter":z=this;v.fx.sequence({condition:function(){return C.length!=0},step:function(){z.removeNode(C.shift(),{type:"nothing"});v.labels.clearLabels()},onComplete:function(){w.onComplete&&w.onComplete()},duration:Math.ceil(w.duration/C.length)});break;default:this.doError()}},removeEdge:function(D,B){var w=this.viz;var z=c.merge(this.options,w.controller,B);var y=(c.type(D[0])=="string")?[D]:D;var A,C,x;switch(z.type){case"nothing":for(A=0;A<y.length;A++){w.graph.removeAdjacence(y[A][0],y[A][1])}break;case"replot":this.removeEdge(y,{type:"nothing"});w.refresh(true);break;case"fade:seq":case"fade":C=this;for(A=0;A<y.length;A++){x=w.graph.getAdjacence(y[A][0],y[A][1]);if(x){x.setData("alpha",0,"end")}}w.fx.animate(c.merge(z,{modes:["edge-property:alpha"],onComplete:function(){C.removeEdge(y,{type:"nothing"});w.reposition();w.fx.animate(c.merge(z,{modes:["linear"]}))}}));break;case"fade:con":C=this;for(A=0;A<y.length;A++){x=w.graph.getAdjacence(y[A][0],y[A][1]);if(x){x.setData("alpha",0,"end");x.ignore=true}}w.reposition();w.fx.animate(c.merge(z,{modes:["edge-property:alpha","linear"],onComplete:function(){C.removeEdge(y,{type:"nothing"});z.onComplete&&z.onComplete()}}));break;case"iter":C=this;w.fx.sequence({condition:function(){return y.length!=0},step:function(){C.removeEdge(y.shift(),{type:"nothing"});w.labels.clearLabels()},onComplete:function(){z.onComplete()},duration:Math.ceil(z.duration/y.length)});break;default:this.doError()}},sum:function(z,y){var v=this.viz;var x=c.merge(this.options,v.controller,y),w=v.root;var B;v.root=y.id||v.root;switch(x.type){case"nothing":B=v.construct(z);B.eachNode(function(D){D.eachAdjacency(function(E){v.graph.addAdjacence(E.nodeFrom,E.nodeTo,E.data)})});break;case"replot":v.refresh(true);this.sum(z,{type:"nothing"});v.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;B=v.construct(z);var C=this.preprocessSum(B);var A=!C?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];v.reposition();if(x.type!="fade:con"){v.fx.animate(c.merge(x,{modes:["linear"],onComplete:function(){v.fx.animate(c.merge(x,{modes:A,onComplete:function(){x.onComplete()}}))}}))}else{v.graph.eachNode(function(D){if(D.id!=w&&D.pos.isZero()){D.pos.set(D.endPos);D.startPos.set(D.endPos)}});v.fx.animate(c.merge(x,{modes:["linear"].concat(A)}))}break;default:this.doError()}},morph:function(D,w,y){y=y||{};var A=this.viz;var E=c.merge(this.options,A.controller,w),z=A.root;var B;A.root=w.id||A.root;switch(E.type){case"nothing":B=A.construct(D);B.eachNode(function(H){var G=A.graph.hasNode(H.id);H.eachAdjacency(function(L){var K=!!A.graph.getAdjacence(L.nodeFrom.id,L.nodeTo.id);A.graph.addAdjacence(L.nodeFrom,L.nodeTo,L.data);if(K){var J=A.graph.getAdjacence(L.nodeFrom.id,L.nodeTo.id);for(var M in (L.data||{})){J.data[M]=L.data[M]}}});if(G){var F=A.graph.getNode(H.id);for(var I in (H.data||{})){F.data[I]=H.data[I]}}});A.graph.eachNode(function(F){F.eachAdjacency(function(G){if(!B.getAdjacence(G.nodeFrom.id,G.nodeTo.id)){A.graph.removeAdjacence(G.nodeFrom.id,G.nodeTo.id)}});if(!B.hasNode(F.id)){A.graph.removeNode(F.id)}});break;case"replot":A.labels.clearLabels(true);this.morph(D,{type:"nothing"});A.refresh(true);A.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;B=A.construct(D);var C=("node-property" in y)&&c.map(c.splat(y["node-property"]),function(F){return"$"+F});A.graph.eachNode(function(G){var H=B.getNode(G.id);if(!H){G.setData("alpha",1);G.setData("alpha",1,"start");G.setData("alpha",0,"end");G.ignore=true}else{var F=H.data;for(var I in F){if(C&&(c.indexOf(C,I)>-1)){G.endData[I]=F[I]}else{G.data[I]=F[I]}}}});A.graph.eachNode(function(F){if(F.ignore){return}F.eachAdjacency(function(G){if(G.nodeFrom.ignore||G.nodeTo.ignore){return}var H=B.getNode(G.nodeFrom.id);var I=B.getNode(G.nodeTo.id);if(!H.adjacentTo(I)){var G=A.graph.getAdjacence(H.id,I.id);v=true;G.setData("alpha",1);G.setData("alpha",1,"start");G.setData("alpha",0,"end")}})});var v=this.preprocessSum(B);var x=!v?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];x[0]=x[0]+(("node-property" in y)?(":"+c.splat(y["node-property"]).join(":")):"");x[1]=(x[1]||"edge-property:alpha")+(("edge-property" in y)?(":"+c.splat(y["edge-property"]).join(":")):"");if("label-property" in y){x.push("label-property:"+c.splat(y["label-property"]).join(":"))}if(A.reposition){A.reposition()}else{A.compute("end")}A.graph.eachNode(function(F){if(F.id!=z&&F.pos.getp().equals(b.KER)){F.pos.set(F.endPos);F.startPos.set(F.endPos)}});A.fx.animate(c.merge(E,{modes:[y.position||"polar"].concat(x),onComplete:function(){A.graph.eachNode(function(F){if(F.ignore){A.graph.removeNode(F.id)}});A.graph.eachNode(function(F){F.eachAdjacency(function(G){if(G.ignore){A.graph.removeAdjacence(G.nodeFrom.id,G.nodeTo.id)}})});E.onComplete()}}));break;default:}},contract:function(x,w){var v=this.viz;if(x.collapsed||!x.anySubnode(c.lambda(true))){return}w=c.merge(this.options,v.config,w||{},{modes:["node-property:alpha:span","linear"]});x.collapsed=true;(function y(z){z.eachSubnode(function(A){A.ignore=true;A.setData("alpha",0,w.type=="animate"?"end":"current");y(A)})})(x);if(w.type=="animate"){v.compute("end");if(v.rotated){v.rotate(v.rotated,"none",{property:"end"})}(function y(z){z.eachSubnode(function(A){A.setPos(x.getPos("end"),"end");y(A)})})(x);v.fx.animate(w)}else{if(w.type=="replot"){v.refresh()}}},expand:function(x,w){if(!("collapsed" in x)){return}var v=this.viz;w=c.merge(this.options,v.config,w||{},{modes:["node-property:alpha:span","linear"]});delete x.collapsed;(function y(z){z.eachSubnode(function(A){delete A.ignore;A.setData("alpha",1,w.type=="animate"?"end":"current");y(A)})})(x);if(w.type=="animate"){v.compute("end");if(v.rotated){v.rotate(v.rotated,"none",{property:"end"})}v.fx.animate(w)}else{if(w.type=="replot"){v.refresh()}}},preprocessSum:function(w){var v=this.viz;w.eachNode(function(y){if(!v.graph.hasNode(y.id)){v.graph.addNode(y);var z=v.graph.getNode(y.id);z.setData("alpha",0);z.setData("alpha",0,"start");z.setData("alpha",1,"end")}});var x=false;w.eachNode(function(y){y.eachAdjacency(function(z){var A=v.graph.getNode(z.nodeFrom.id);var B=v.graph.getNode(z.nodeTo.id);if(!A.adjacentTo(B)){var z=v.graph.addAdjacence(A,B,z.data);if(A.startAlpha==A.endAlpha&&B.startAlpha==B.endAlpha){x=true;z.setData("alpha",0);z.setData("alpha",0,"start");z.setData("alpha",1,"end")}}})});return x}};var a={none:{render:c.empty,contains:c.lambda(false)},circle:{render:function(y,z,v,x){var w=x.getCtx();w.beginPath();w.arc(z.x,z.y,v,0,Math.PI*2,true);w.closePath();w[y]()},contains:function(A,z,v){var x=A.x-z.x,w=A.y-z.y,y=x*x+w*w;return y<=v*v}},ellipse:{render:function(B,D,v,E,w){var F=w.getCtx(),y=1,x=1,C=1,A=1,z=0;if(v>E){z=v/2;x=E/v;A=v/E}else{z=E/2;y=v/E;C=E/v}F.save();F.scale(y,x);F.beginPath();F.arc(D.x*C,D.y*A,z,0,Math.PI*2,true);F.closePath();F[B]();F.restore()},contains:function(v,C,w,E){var B=0,A=1,z=1,y=0,x=0,D=0;if(w>E){B=w/2;z=E/w}else{B=E/2;A=w/E}y=(v.x-C.x)*(1/A);x=(v.y-C.y)*(1/z);D=y*y+x*x;return D<=B*B}},square:{render:function(w,y,x,v){v.getCtx()[w+"Rect"](y.x-x,y.y-x,2*x,2*x)},contains:function(x,w,v){return Math.abs(w.x-x.x)<=v&&Math.abs(w.y-x.y)<=v}},rectangle:{render:function(y,z,x,v,w){w.getCtx()[y+"Rect"](z.x-x/2,z.y-v/2,x,v)},contains:function(y,x,w,v){return Math.abs(x.x-y.x)<=w/2&&Math.abs(x.y-y.y)<=v/2}},triangle:{render:function(B,C,y,v){var F=v.getCtx(),x=C.x,w=C.y-y,E=x-y,D=C.y+y,A=x+y,z=D;F.beginPath();F.moveTo(x,w);F.lineTo(E,D);F.lineTo(A,z);F.closePath();F[B]()},contains:function(x,w,v){return a.circle.contains(x,w,v)}},star:{render:function(z,B,A,w){var v=w.getCtx(),y=Math.PI/5;v.save();v.translate(B.x,B.y);v.beginPath();v.moveTo(A,0);for(var x=0;x<9;x++){v.rotate(y);if(x%2==0){v.lineTo((A/0.525731)*0.200811,0)}else{v.lineTo(A,0)}}v.closePath();v[z]();v.restore()},contains:function(x,w,v){return a.circle.contains(x,w,v)}}};var m={line:{render:function(y,x,w){var v=w.getCtx();v.beginPath();v.moveTo(y.x,y.y);v.lineTo(x.x,x.y);v.stroke()},contains:function(F,x,A,D){var y=Math.min,B=Math.max,w=y(F.x,x.x),E=B(F.x,x.x),v=y(F.y,x.y),C=B(F.y,x.y);if(A.x>=w&&A.x<=E&&A.y>=v&&A.y<=C){if(Math.abs(x.x-F.x)<=D){return true}var z=(x.y-F.y)/(x.x-F.x)*(A.x-F.x)+F.y;return Math.abs(z-A.y)<=D}return false}},arrow:{render:function(E,F,y,w,v){var G=v.getCtx();if(w){var x=E;E=F;F=x}var B=new p(F.x-E.x,F.y-E.y);B.$scale(y/B.norm());var z=new p(F.x-B.x,F.y-B.y),A=new p(-B.y/2,B.x/2),D=z.add(A),C=z.$add(A.$scale(-1));G.beginPath();G.moveTo(E.x,E.y);G.lineTo(F.x,F.y);G.stroke();G.beginPath();G.moveTo(D.x,D.y);G.lineTo(C.x,C.y);G.lineTo(F.x,F.y);G.closePath();G.fill()},contains:function(w,v,y,x){return m.line.contains(w,v,y,x)}},hyperline:{render:function(C,D,v,x){var E=x.getCtx();var y=z(C,D);if(y.a>1000||y.b>1000||y.ratio<0){E.beginPath();E.moveTo(C.x*v,C.y*v);E.lineTo(D.x*v,D.y*v);E.stroke()}else{var B=Math.atan2(D.y-y.y,D.x-y.x);var A=Math.atan2(C.y-y.y,C.x-y.x);var w=w(B,A);E.beginPath();E.arc(y.x*v,y.y*v,y.ratio*v,B,A,w);E.stroke()}function z(R,Q){var J=(R.x*Q.y-R.y*Q.x),F=J;var I=R.squaredNorm(),H=Q.squaredNorm();if(J==0){return{x:0,y:0,ratio:-1}}var P=(R.y*H-Q.y*I+R.y-Q.y)/J;var N=(Q.x*I-R.x*H+Q.x-R.x)/F;var O=-P/2;var M=-N/2;var L=(P*P+N*N)/4-1;if(L<0){return{x:0,y:0,ratio:-1}}var K=Math.sqrt(L);var G={x:O,y:M,ratio:K>1000?-1:K,a:P,b:N};return G}function w(F,G){return(F<G)?((F+Math.PI>G)?false:true):((G+Math.PI>F)?true:false)}},contains:c.lambda(false)}};e.Plot={initialize:function(w,v){this.viz=w;this.config=w.config;this.node=w.config.Node;this.edge=w.config.Edge;this.animation=new u;this.nodeTypes=new v.Plot.NodeTypes;this.edgeTypes=new v.Plot.EdgeTypes;this.labels=w.labels},nodeHelper:a,edgeHelper:m,Interpolator:{map:{border:"color",color:"color",width:"number",height:"number",dim:"number",alpha:"number",lineWidth:"number",angularWidth:"number",span:"number",valueArray:"array-number",dimArray:"array-number"},canvas:{globalAlpha:"number",fillStyle:"color",strokeStyle:"color",lineWidth:"number",shadowBlur:"number",shadowColor:"color",shadowOffsetX:"number",shadowOffsetY:"number",miterLimit:"number"},label:{size:"number",color:"color"},compute:function(x,w,v){return x+(w-x)*v},moebius:function(D,C,F,z){var B=z.scale(-F);if(B.norm()<1){var w=B.x,E=B.y;var A=D.startPos.getc().moebiusTransformation(B);D.pos.setc(A.x,A.y);B.x=w;B.y=E}},linear:function(w,v,z){var y=w.startPos.getc(true);var x=w.endPos.getc(true);w.pos.setc(this.compute(y.x,x.x,z),this.compute(y.y,x.y,z))},polar:function(x,w,A){var z=x.startPos.getp(true);var y=x.endPos.getp();var v=y.interpolate(z,A);x.pos.setp(v.theta,v.rho)},number:function(w,B,A,v,z){var y=w[v](B,"start");var x=w[v](B,"end");w[z](B,this.compute(y,x,A))},color:function(x,v,D,A,y){var B=c.hexToRgb(x[A](v,"start"));var C=c.hexToRgb(x[A](v,"end"));var z=this.compute;var w=c.rgbToHex([parseInt(z(B[0],C[0],D)),parseInt(z(B[1],C[1],D)),parseInt(z(B[2],C[2],D))]);x[y](v,w)},"array-number":function(y,x,I,F,A){var G=y[F](x,"start"),H=y[F](x,"end"),J=[];for(var D=0,z=G.length;D<z;D++){var w=G[D],v=H[D];if(w.length){for(var C=0,E=w.length,B=[];C<E;C++){B.push(this.compute(w[C],v[C],I))}J.push(B)}else{J.push(this.compute(w,v,I))}}y[A](x,J)},node:function(w,B,D,v,C,x){v=this[v];if(B){var A=B.length;for(var y=0;y<A;y++){var z=B[y];this[v[z]](w,z,D,C,x)}}else{for(var z in v){this[v[z]](w,z,D,C,x)}}},edge:function(x,w,C,y,v,B){var A=x.adjacencies;for(var z in A){this["node"](A[z],w,C,y,v,B)}},"node-property":function(w,v,x){this["node"](w,v,x,"map","getData","setData")},"edge-property":function(w,v,x){this["edge"](w,v,x,"map","getData","setData")},"label-property":function(w,v,x){this["node"](w,v,x,"label","getLabelData","setLabelData")},"node-style":function(w,v,x){this["node"](w,v,x,"canvas","getCanvasStyle","setCanvasStyle")},"edge-style":function(w,v,x){this["edge"](w,v,x,"canvas","getCanvasStyle","setCanvasStyle")}},sequence:function(w){var x=this;w=c.merge({condition:c.lambda(false),step:c.empty,onComplete:c.empty,duration:200},w||{});var v=setInterval(function(){if(w.condition()){w.step()}else{clearInterval(v);w.onComplete()}x.viz.refresh(true)},w.duration)},prepare:function(B){var A=this.viz.graph,y={"node-property":{getter:"getData",setter:"setData"},"edge-property":{getter:"getData",setter:"setData"},"node-style":{getter:"getCanvasStyle",setter:"setCanvasStyle"},"edge-style":{getter:"getCanvasStyle",setter:"setCanvasStyle"}};var w={};if(c.type(B)=="array"){for(var z=0,v=B.length;z<v;z++){var x=B[z].split(":");w[x.shift()]=x}}else{for(var C in B){if(C=="position"){w[B.position]=[]}else{w[C]=c.splat(B[C])}}}A.eachNode(function(D){D.startPos.set(D.pos);c.each(["node-property","node-style"],function(G){if(G in w){var H=w[G];for(var F=0,E=H.length;F<E;F++){D[y[G].setter](H[F],D[y[G].getter](H[F]),"start")}}});c.each(["edge-property","edge-style"],function(E){if(E in w){var F=w[E];D.eachAdjacency(function(H){for(var I=0,G=F.length;I<G;I++){H[y[E].setter](F[I],H[y[E].getter](F[I]),"start")}})}})});return w},animate:function(y,x){y=c.merge(this.viz.config,y||{});var z=this,w=this.viz,B=w.graph,C=this.Interpolator,A=y.type==="nodefx"?this.nodeFxAnimation:this.animation;var v=this.prepare(y.modes);if(y.hideLabels){this.labels.hideLabels(true)}A.setOptions(c.extend(y,{$animating:false,compute:function(D){B.eachNode(function(E){for(var F in v){C[F](E,v[F],D,x)}});z.plot(y,this.$animating,D);this.$animating=true},complete:function(){if(y.hideLabels){z.labels.hideLabels(false)}z.plot(y);y.onComplete()}})).start()},nodeFx:function(x){var C=this.viz,D=C.graph,A=this.nodeFxAnimation,E=c.merge(this.viz.config,{elements:{id:false,properties:{}},reposition:false});x=c.merge(E,x||{},{onBeforeCompute:c.empty,onAfterCompute:c.empty});A.stopTimer();var B=x.elements.properties;if(!x.elements.id){D.eachNode(function(G){for(var F in B){G.setData(F,B[F],"end")}})}else{var v=c.splat(x.elements.id);c.each(v,function(H){var G=D.getNode(H);if(G){for(var F in B){G.setData(F,B[F],"end")}}})}var z=[];for(var w in B){z.push(w)}var y=["node-property:"+z.join(":")];if(x.reposition){y.push("linear");C.compute("end")}this.animate(c.merge(x,{modes:y,type:"nodefx"}))},plot:function(w,F){var D=this.viz,A=D.graph,x=D.canvas,v=D.root,B=this,E=x.getCtx(),z=Math.min,w=w||this.viz.controller;w.clearCanvas&&x.clear();var C=A.getNode(v);if(!C){return}var y=!!C.visited;A.eachNode(function(H){var G=H.getData("alpha");H.eachAdjacency(function(I){var J=I.nodeTo;if(!!J.visited===y&&H.drawn&&J.drawn){!F&&w.onBeforePlotLine(I);B.plotLine(I,x,F);!F&&w.onAfterPlotLine(I)}});if(H.drawn){!F&&w.onBeforePlotNode(H);B.plotNode(H,x,F);!F&&w.onAfterPlotNode(H)}if(!B.labelsHidden&&w.withLabels){if(H.drawn&&G>=0.95){B.labels.plotLabel(x,H,w)}else{B.labels.hideLabel(H,false)}}H.visited=!y})},plotTree:function(z,w,D){var A=this,B=this.viz,x=B.canvas,y=this.config,C=x.getCtx();var v=z.getData("alpha");z.eachSubnode(function(F){if(w.plotSubtree(z,F)&&F.exist&&F.drawn){var E=z.getAdjacency(F.id);!D&&w.onBeforePlotLine(E);A.plotLine(E,x,D);!D&&w.onAfterPlotLine(E);A.plotTree(F,w,D)}});if(z.drawn){!D&&w.onBeforePlotNode(z);this.plotNode(z,x,D);!D&&w.onAfterPlotNode(z);if(!w.hideLabels&&w.withLabels&&v>=0.95){this.labels.plotLabel(x,z,w)}else{this.labels.hideLabel(z,false)}}else{this.labels.hideLabel(z,true)}},plotNode:function(x,w,E){var B=x.getData("type"),A=this.node.CanvasStyles;if(B!="none"){var v=x.getData("lineWidth"),z=x.getData("color"),y=x.getData("alpha"),C=w.getCtx();C.save();C.lineWidth=v;C.fillStyle=C.strokeStyle=z;C.globalAlpha=y;for(var D in A){C[D]=x.getCanvasStyle(D)}this.nodeTypes[B].render.call(this,x,w,E);C.restore()}},plotLine:function(B,w,F){var A=B.getData("type"),y=this.edge.CanvasStyles;if(A!="none"){var v=B.getData("lineWidth"),x=B.getData("color"),D=w.getCtx(),z=B.nodeFrom,C=B.nodeTo;D.save();D.lineWidth=v;D.fillStyle=D.strokeStyle=x;D.globalAlpha=Math.min(z.getData("alpha"),C.getData("alpha"),B.getData("alpha"));for(var E in y){D[E]=B.getCanvasStyle(E)}this.edgeTypes[A].render.call(this,B,w,F);D.restore()}}};e.Plot3D=c.merge(e.Plot,{Interpolator:{linear:function(w,v,z){var y=w.startPos.getc(true);var x=w.endPos.getc(true);w.pos.setc(this.compute(y.x,x.x,z),this.compute(y.y,x.y,z),this.compute(y.z,x.z,z))}},plotNode:function(w,v){if(w.getData("type")=="none"){return}this.plotElement(w,v,{getAlpha:function(){return w.getData("alpha")}})},plotLine:function(v,w){if(v.getData("type")=="none"){return}this.plotElement(v,w,{getAlpha:function(){return Math.min(v.nodeFrom.getData("alpha"),v.nodeTo.getData("alpha"),v.getData("alpha"))}})},plotElement:function(X,D,y){var U=D.getCtx(),E=new Matrix4,w=D.config.Scene.Lighting,Y=D.canvases[0],J=Y.program,W=Y.camera;if(!X.geometry){X.geometry=new O3D[X.getData("type")]}X.geometry.update(X);if(!X.webGLVertexBuffer){var I=[],A=[],O=[],M=0,R=X.geometry;for(var V=0,T=R.vertices,G=R.faces,F=G.length;V<F;V++){var L=G[V],C=T[L.a],B=T[L.b],z=T[L.c],x=L.d?T[L.d]:false,Q=L.normal;I.push(C.x,C.y,C.z);I.push(B.x,B.y,B.z);I.push(z.x,z.y,z.z);if(x){I.push(x.x,x.y,x.z)}O.push(Q.x,Q.y,Q.z);O.push(Q.x,Q.y,Q.z);O.push(Q.x,Q.y,Q.z);if(x){O.push(Q.x,Q.y,Q.z)}A.push(M,M+1,M+2);if(x){A.push(M,M+2,M+3);M+=4}else{M+=3}}X.webGLVertexBuffer=U.createBuffer();U.bindBuffer(U.ARRAY_BUFFER,X.webGLVertexBuffer);U.bufferData(U.ARRAY_BUFFER,new Float32Array(I),U.STATIC_DRAW);X.webGLFaceBuffer=U.createBuffer();U.bindBuffer(U.ELEMENT_ARRAY_BUFFER,X.webGLFaceBuffer);U.bufferData(U.ELEMENT_ARRAY_BUFFER,new Uint16Array(A),U.STATIC_DRAW);X.webGLFaceCount=A.length;X.webGLNormalBuffer=U.createBuffer();U.bindBuffer(U.ARRAY_BUFFER,X.webGLNormalBuffer);U.bufferData(U.ARRAY_BUFFER,new Float32Array(O),U.STATIC_DRAW)}E.multiply(W.matrix,X.geometry.matrix);U.uniformMatrix4fv(J.viewMatrix,false,E.flatten());U.uniformMatrix4fv(J.projectionMatrix,false,W.projectionMatrix.flatten());var K=Matrix4.makeInvert(E);K.$transpose();U.uniformMatrix4fv(J.normalMatrix,false,K.flatten());var S=c.hexToRgb(X.getData("color"));S.push(y.getAlpha());U.uniform4f(J.color,S[0]/255,S[1]/255,S[2]/255,S[3]);U.uniform1i(J.enableLighting,w.enable);if(w.enable){if(w.ambient){var N=w.ambient;U.uniform3f(J.ambientColor,N[0],N[1],N[2])}if(w.directional){var P=w.directional,S=P.color,H=P.direction,v=new Vector3(H.x,H.y,H.z).normalize().$scale(-1);U.uniform3f(J.lightingDirection,v.x,v.y,v.z);U.uniform3f(J.directionalColor,S[0],S[1],S[2])}}U.bindBuffer(U.ARRAY_BUFFER,X.webGLVertexBuffer);U.vertexAttribPointer(J.position,3,U.FLOAT,false,0,0);U.bindBuffer(U.ARRAY_BUFFER,X.webGLNormalBuffer);U.vertexAttribPointer(J.normal,3,U.FLOAT,false,0,0);U.bindBuffer(U.ELEMENT_ARRAY_BUFFER,X.webGLFaceBuffer);U.drawElements(U.TRIANGLES,X.webGLFaceCount,U.UNSIGNED_SHORT,0)}});e.Label={};e.Label.Native=new q({initialize:function(v){this.viz=v},plotLabel:function(x,y,w){var v=x.getCtx();var z=y.pos.getc(true);v.font=y.getLabelData("style")+" "+y.getLabelData("size")+"px "+y.getLabelData("family");v.textAlign=y.getLabelData("textAlign");v.fillStyle=v.strokeStyle=y.getLabelData("color");v.textBaseline=y.getLabelData("textBaseline");this.renderLabel(x,y,w)},renderLabel:function(x,y,w){var v=x.getCtx();var z=y.pos.getc(true);v.fillText(y.name,z.x,z.y+y.getData("height")/2)},hideLabel:c.empty,hideLabels:c.empty});e.Label.DOM=new q({labelsHidden:false,labelContainer:false,labels:{},getLabelContainer:function(){return this.labelContainer?this.labelContainer:this.labelContainer=document.getElementById(this.viz.config.labelContainer)},getLabel:function(v){return(v in this.labels&&this.labels[v]!=null)?this.labels[v]:this.labels[v]=document.getElementById(v)},hideLabels:function(w){var v=this.getLabelContainer();if(w){v.style.display="none"}else{v.style.display=""}this.labelsHidden=w},clearLabels:function(v){for(var w in this.labels){if(v||!this.viz.graph.hasNode(w)){this.disposeLabel(w);delete this.labels[w]}}},disposeLabel:function(w){var v=this.getLabel(w);if(v&&v.parentNode){v.parentNode.removeChild(v)}},hideLabel:function(z,v){z=c.splat(z);var w=v?"":"none",x,y=this;c.each(z,function(B){var A=y.getLabel(B.id);if(A){A.style.display=w}})},fitsInCanvas:function(x,v){var w=v.getSize();if(x.x>=w.width||x.x<0||x.y>=w.height||x.y<0){return false}return true}});e.Label.HTML=new q({Implements:e.Label.DOM,plotLabel:function(y,z,x){var A=z.id,v=this.getLabel(A);if(!v&&!(v=document.getElementById(A))){v=document.createElement("div");var w=this.getLabelContainer();v.id=A;v.className="node";v.style.position="absolute";x.onCreateLabel(v,z);w.appendChild(v);this.labels[z.id]=v}this.placeLabel(v,z,x)}});e.Label.SVG=new q({Implements:e.Label.DOM,plotLabel:function(y,A,x){var C=A.id,v=this.getLabel(C);if(!v&&!(v=document.getElementById(C))){var z="http://www.w3.org/2000/svg";v=document.createElementNS(z,"svg:text");var B=document.createElementNS(z,"svg:tspan");v.appendChild(B);var w=this.getLabelContainer();v.setAttribute("id",C);v.setAttribute("class","node");w.appendChild(v);x.onCreateLabel(v,A);this.labels[A.id]=v}this.placeLabel(v,A,x)}});e.Geom=new q({initialize:function(v){this.viz=v;this.config=v.config;this.node=v.config.Node;this.edge=v.config.Edge},translate:function(w,v){v=c.splat(v);this.viz.graph.eachNode(function(x){c.each(v,function(y){x.getPos(y).$add(w)})})},setRightLevelToShow:function(y,v,A){var z=this.getRightLevelToShow(y,v),x=this.viz.labels,w=c.merge({execShow:true,execHide:true,onHide:c.empty,onShow:c.empty},A||{});y.eachLevel(0,this.config.levelsToShow,function(C){var B=C._depth-y._depth;if(B>z){w.onHide(C);if(w.execHide){C.drawn=false;C.exist=false;x.hideLabel(C,false)}}else{w.onShow(C);if(w.execShow){C.exist=true}}});y.drawn=true},getRightLevelToShow:function(y,w){var v=this.config;var z=v.levelsToShow;var x=v.constrained;if(!x){return z}while(!this.treeFitsInCanvas(y,w,z)&&z>1){z--}return z}});var d={construct:function(w){var x=(c.type(w)=="array");var v=new e(this.graphOptions,this.config.Node,this.config.Edge,this.config.Label);if(!x){(function(y,A){y.addNode(A);if(A.children){for(var z=0,B=A.children;z<B.length;z++){y.addAdjacence(A,B[z]);arguments.callee(y,B[z])}}})(v,w)}else{(function(G,H){var z=function(L){for(var K=0,I=H.length;K<I;K++){if(H[K].id==L){return H[K]}}var J={id:L,name:L};return G.addNode(J)};for(var D=0,A=H.length;D<A;D++){G.addNode(H[D]);var E=H[D].adjacencies;if(E){for(var B=0,F=E.length;B<F;B++){var y=E[B],C={};if(typeof E[B]!="string"){C=c.merge(y.data,{});y=y.nodeTo}G.addAdjacence(H[D],z(y),C)}}}})(v,w)}return v},loadJSON:function(w,v){this.json=w;if(this.labels&&this.labels.clearLabels){this.labels.clearLabels(true)}this.graph=this.construct(w);if(c.type(w)!="array"){this.root=w.id}else{this.root=w[v?v:0].id}},toJSON:function(z){z=z||"tree";if(z=="tree"){var x={};var w=this.graph.getNode(this.root);var x=(function v(C){var A={};A.id=C.id;A.name=C.name;A.data=C.data;var B=[];C.eachSubnode(function(D){B.push(v(D))});A.children=B;return A})(w);return x}else{var x=[];var y=!!this.graph.getNode(this.root).visited;this.graph.eachNode(function(B){var A={};A.id=B.id;A.name=B.name;A.data=B.data;var C=[];B.eachAdjacency(function(D){var F=D.nodeTo;if(!!F.visited===y){var E={};E.nodeTo=F.id;E.data=D.data;C.push(E)}});A.adjacencies=C;x.push(A);B.visited=!y});return x}}};var g=$jit.Layouts={};var f={label:null,compute:function(y,z,w){this.initializeLabel(w);var v=this.label,x=v.style;y.eachNode(function(C){var G=C.getData("autoWidth"),H=C.getData("autoHeight");if(G||H){delete C.data.$width;delete C.data.$height;delete C.data.$dim;var A=C.getData("width"),I=C.getData("height");x.width=G?"auto":A+"px";x.height=H?"auto":I+"px";v.innerHTML=C.name;var E=v.offsetWidth,B=v.offsetHeight;var F=C.getData("type");if(c.indexOf(["circle","square","triangle","star"],F)===-1){C.setData("width",E);C.setData("height",B)}else{var D=E>B?E:B;C.setData("width",D);C.setData("height",D);C.setData("dim",D)}}})},initializeLabel:function(v){if(!this.label){this.label=document.createElement("div");document.body.appendChild(this.label)}this.setLabelStyles(v)},setLabelStyles:function(v){c.extend(this.label.style,{visibility:"hidden",position:"absolute",width:"auto",height:"auto"});this.label.className="jit-autoadjust-label"}};g.Tree=(function(){var E=Array.prototype.slice;function C(O,J,G,M,H){var L=J.Node;var I=J.multitree;if(L.overridable){var N=-1,K=-1;O.eachNode(function(R){if(R._depth==G&&(!I||("$orn" in R.data)&&R.data.$orn==M)){var P=R.getData("width",H);var Q=R.getData("height",H);N=(N<P)?P:N;K=(K<Q)?Q:K}});return{width:N<0?L.width:N,height:K<0?L.height:K}}else{return L}}function F(H,K,J,G){var I=(G=="left"||G=="right")?"y":"x";H.getPos(K)[I]+=J}function A(H,I){var G=[];c.each(H,function(J){J=E.call(J);J[0]+=I;J[1]+=I;G.push(J)});return G}function D(J,G){if(J.length==0){return G}if(G.length==0){return J}var I=J.shift(),H=G.shift();return[[I[0],H[1]]].concat(D(J,G))}function y(G,H){H=H||[];if(G.length==0){return H}var I=G.pop();return y(G,D(I,H))}function B(J,H,K,G,I){if(J.length<=I||H.length<=I){return 0}var M=J[I][1],L=H[I][0];return Math.max(B(J,H,K,G,++I)+K,M-L+G)}function z(J,H,G){function I(M,O,L){if(O.length<=L){return[]}var N=O[L],K=B(M,N,H,G,0);return[K].concat(I(D(M,A(N,K)),O,++L))}return I([],J,0)}function w(K,J,I){function G(N,P,M){if(P.length<=M){return[]}var O=P[M],L=-B(O,N,J,I,0);return[L].concat(G(D(A(O,L),N),P,++M))}K=E.call(K);var H=G([],K.reverse(),0);return H.reverse()}function v(M,K,H,N){var I=z(M,K,H),L=w(M,K,H);if(N=="left"){L=I}else{if(N=="right"){I=L}}for(var J=0,G=[];J<I.length;J++){G[J]=(I[J]+L[J])/2}return G}function x(G,Q,H,X,V){var J=X.multitree;var P=["x","y"],M=["width","height"];var I=+(V=="left"||V=="right");var N=P[I],W=P[1-I];var S=X.Node;var L=M[I],U=M[1-I];var K=X.siblingOffset;var T=X.subtreeOffset;var R=X.align;function O(aa,ae,ai){var Z=aa.getData(L,H);var ah=ae||(aa.getData(U,H));if(U=="width"&&aa.getData("align",H)=="center"){ah/=2}var al=[],aj=[],af=false;var Y=ah+X.levelDistance;aa.eachSubnode(function(an){if(an.exist&&(!J||("$orn" in an.data)&&an.data.$orn==V)){if(!af){af=C(G,X,an._depth,V,H)}var am=O(an,af[U],ai+Y);al.push(am.tree);aj.push(am.extent)}});var ad=v(aj,T,K,R);for(var ac=0,ab=[],ag=[];ac<al.length;ac++){F(al[ac],H,ad[ac],V);ag.push(A(aj[ac],ad[ac]))}var ak=[[-Z/2,Z/2]].concat(y(ag));aa.getPos(H)[N]=0;if(V=="top"||V=="left"){aa.getPos(H)[W]=ai}else{aa.getPos(H)[W]=-ai}return{tree:aa,extent:ak}}O(Q,false,0)}return new q({compute:function(I,H){var J=I||"start";var G=this.graph.getNode(this.root);c.extend(G,{drawn:true,exist:true,selected:true});f.compute(this.graph,J,this.config);if(!!H||!("_depth" in G)){this.graph.computeLevels(this.root,0,"ignore")}this.computePositions(G,J)},computePositions:function(K,G){var I=this.config;var H=I.multitree;var N=I.align;var J=N!=="center"&&I.indent;var O=I.orientation;var M=H?["top","right","bottom","left"]:[O];var L=this;c.each(M,function(P){x(L.graph,K,G,L.config,P,G);var Q=["x","y"][+(P=="left"||P=="right")];(function R(S){S.eachSubnode(function(T){if(T.exist&&(!H||("$orn" in T.data)&&T.data.$orn==P)){T.getPos(G)[Q]+=S.getPos(G)[Q];if(J){T.getPos(G)[Q]+=N=="left"?J:-J}R(T)}})})(K)})}})})();$jit.ST=(function(){var w=[];function x(C){C=C||this.clickedNode;if(!this.config.constrained){return[]}var z=this.geom;var G=this.graph;var A=this.canvas;var y=C._depth,D=[];G.eachNode(function(H){if(H.exist&&!H.selected){if(H.isDescendantOf(C.id)){if(H._depth<=y){D.push(H)}}else{D.push(H)}}});var E=z.getRightLevelToShow(C,A);C.eachLevel(E,E,function(H){if(H.exist&&!H.selected){D.push(H)}});for(var F=0;F<w.length;F++){var B=this.graph.getNode(w[F]);if(!B.isDescendantOf(C.id)){D.push(B)}}return D}function v(A){var z=[],y=this.config;A=A||this.clickedNode;this.clickedNode.eachLevel(0,y.levelsToShow,function(B){if(y.multitree&&!("$orn" in B.data)&&B.anySubnode(function(C){return C.exist&&!C.drawn})){z.push(B)}else{if(B.drawn&&!B.anySubnode("drawn")){z.push(B)}}});return z}return new q({Implements:[d,o,g.Tree],initialize:function(y){var A=$jit.ST;var z={levelsToShow:2,levelDistance:30,constrained:true,Node:{type:"rectangle"},duration:700,offsetX:0,offsetY:0};this.controller=this.config=c.merge(n("Canvas","Fx","Tree","Node","Edge","Controller","Tips","NodeStyles","Events","Navigation","Label"),z,y);var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(B.background){B.background=c.merge({type:"Circles"},B.background)}this.canvas=new l(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={klass:p};this.graph=new e(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new A.Label[B.Label.type](this);this.fx=new A.Plot(this,A);this.op=new A.Op(this);this.group=new A.Group(this);this.geom=new A.Geom(this);this.clickedNode=null;this.initializeExtras()},plot:function(){this.fx.plot(this.controller)},switchPosition:function(D,C,B){var y=this.geom,z=this.fx,A=this;if(!z.busy){z.busy=true;this.contract({onComplete:function(){y.switchOrientation(D);A.compute("end",false);z.busy=false;if(C=="animate"){A.onClick(A.clickedNode.id,B)}else{if(C=="replot"){A.select(A.clickedNode.id,B)}}}},D)}},switchAlignment:function(A,z,y){this.config.align=A;if(z=="animate"){this.select(this.clickedNode.id,y)}else{if(z=="replot"){this.onClick(this.clickedNode.id,y)}}},addNodeInPath:function(y){w.push(y);this.select((this.clickedNode&&this.clickedNode.id)||this.root)},clearNodesInPath:function(y){w.length=0;this.select((this.clickedNode&&this.clickedNode.id)||this.root)},refresh:function(){this.reposition();this.select((this.clickedNode&&this.clickedNode.id)||this.root)},reposition:function(){this.graph.computeLevels(this.root,0,"ignore");this.geom.setRightLevelToShow(this.clickedNode,this.canvas);this.graph.eachNode(function(z){if(z.exist){z.drawn=true}});this.compute("end");if(this.clickedNode){var y={x:this.canvas.translateOffsetX+this.config.offsetX||0,y:this.canvas.translateOffsetY+this.config.offsetY||0};this.geom.translate(this.clickedNode.endPos.add(y).$scale(-1),"end")}},requestNodes:function(A,B){var z=c.merge(this.controller,B),y=this.config.levelsToShow;if(z.request){var D=[],C=A._depth;A.eachLevel(0,y,function(E){if(E.drawn&&!E.anySubnode()){D.push(E);E._level=y-(E._depth-C)}});this.group.requestNodes(D,z)}else{z.onComplete()}},contract:function(C,D){var B=this.config.orientation;var y=this.geom,A=this.group;if(D){y.switchOrientation(D)}var z=x.call(this);if(D){y.switchOrientation(B)}A.contract(z,c.merge(this.controller,C))},move:function(z,A){this.compute("end",false);var y=A.Move,B={x:y.offsetX,y:y.offsetY};if(y.enable){this.geom.translate(z.endPos.add(B).$scale(-1),"end")}else{this.geom.translate(r(B.x,B.y).$scale(-1),"end")}this.fx.animate(c.merge(this.controller,{modes:["linear"]},A))},expand:function(z,A){var y=v.call(this,z);this.group.expand(y,c.merge(this.controller,A))},selectPath:function(B){var A=this;this.graph.eachNode(function(D){D.selected=false});function C(E){if(E==null||E.selected){return}E.selected=true;c.each(A.group.getSiblings([E])[E.id],function(F){F.exist=true;F.drawn=true});var D=E.getParents();D=(D.length>0)?D[0]:null;C(D)}for(var y=0,z=[B.id].concat(w);y<z.length;y++){C(this.graph.getNode(z[y]))}},setRoot:function(F,E,D){if(this.busy){return}this.busy=true;var C=this,A=this.canvas;var y=this.graph.getNode(this.root);var z=this.graph.getNode(F);function B(){if(this.config.multitree&&z.data.$orn){var H=z.data.$orn;var I={left:"right",right:"left",top:"bottom",bottom:"top"}[H];y.data.$orn=I;(function G(J){J.eachSubnode(function(K){if(K.id!=F){K.data.$orn=I;G(K)}})})(y);delete z.data.$orn}this.root=F;this.clickedNode=z;this.graph.computeLevels(this.root,0,"ignore");this.geom.setRightLevelToShow(z,A,{execHide:false,onShow:function(J){if(!J.drawn){J.drawn=true;J.setData("alpha",1,"end");J.setData("alpha",0);J.pos.setc(z.pos.x,z.pos.y)}}});this.compute("end");this.busy=true;this.fx.animate({modes:["linear","node-property:alpha"],onComplete:function(){C.busy=false;C.onClick(F,{onComplete:function(){D&&D.onComplete()}})}})}delete y.data.$orns;if(E=="animate"){B.call(this);C.selectPath(z)}else{if(E=="replot"){B.call(this);this.select(this.root)}}},addSubtree:function(y,A,z){if(A=="replot"){this.op.sum(y,c.extend({type:"replot"},z||{}))}else{if(A=="animate"){this.op.sum(y,c.extend({type:"fade:seq"},z||{}))}}},removeSubtree:function(D,z,C,B){var A=this.graph.getNode(D),y=[];A.eachLevel(+!z,false,function(E){y.push(E.id)});if(C=="replot"){this.op.removeNode(y,c.extend({type:"replot"},B||{}))}else{if(C=="animate"){this.op.removeNode(y,c.extend({type:"fade:seq"},B||{}))}}},select:function(y,B){var G=this.group,E=this.geom;var C=this.graph.getNode(y),A=this.canvas;var F=this.graph.getNode(this.root);var z=c.merge(this.controller,B);var D=this;z.onBeforeCompute(C);this.selectPath(C);this.clickedNode=C;this.requestNodes(C,{onComplete:function(){G.hide(G.prepare(x.call(D)),z);E.setRightLevelToShow(C,A);D.compute("current");D.graph.eachNode(function(J){var I=J.pos.getc(true);J.startPos.setc(I.x,I.y);J.endPos.setc(I.x,I.y);J.visited=false});var H={x:z.offsetX,y:z.offsetY};D.geom.translate(C.endPos.add(H).$scale(-1),["start","current","end"]);G.show(v.call(D));D.plot();z.onAfterCompute(D.clickedNode);z.onComplete()}})},onClick:function(z,G){var B=this.canvas,F=this,y=this.geom,C=this.config;var E={Move:{enable:true,offsetX:B.translateOffsetX+C.offsetX||0,offsetY:B.translateOffsetY+C.offsetY||0},setRightLevelToShowConfig:false,onBeforeRequest:c.empty,onBeforeContract:c.empty,onBeforeMove:c.empty,onBeforeExpand:c.empty};var A=c.merge(this.controller,E,G);if(!this.busy){this.busy=true;var D=this.graph.getNode(z);this.selectPath(D,this.clickedNode);this.clickedNode=D;A.onBeforeCompute(D);A.onBeforeRequest(D);this.requestNodes(D,{onComplete:function(){A.onBeforeContract(D);F.contract({onComplete:function(){y.setRightLevelToShow(D,B,A.setRightLevelToShowConfig);A.onBeforeMove(D);F.move(D,{Move:A.Move,onComplete:function(){A.onBeforeExpand(D);F.expand(D,{onComplete:function(){F.busy=false;A.onAfterCompute(z);A.onComplete()}})}})}})}})}}})})();$jit.ST.$extend=true;$jit.ST.Op=new q({Implements:e.Op});$jit.ST.Group=new q({initialize:function(v){this.viz=v;this.canvas=v.canvas;this.config=v.config;this.animation=new u;this.nodes=null},requestNodes:function(A,z){var y=0,w=A.length,C={};var x=function(){z.onComplete()};var v=this.viz;if(w==0){x()}for(var B=0;B<w;B++){C[A[B].id]=A[B];z.request(A[B].id,A[B]._level,{onComplete:function(E,D){if(D&&D.children){D.id=E;v.op.sum(D,{type:"nothing"})}if(++y==w){v.graph.computeLevels(v.root,0);x()}}})}},contract:function(x,w){var v=this.viz;var y=this;x=this.prepare(x);this.animation.setOptions(c.merge(w,{$animating:false,compute:function(z){if(z==1){z=0.99}y.plotStep(1-z,w,this.$animating);this.$animating="contract"},complete:function(){y.hide(x,w)}})).start()},hide:function(x,w){var v=this.viz;for(var y=0;y<x.length;y++){if(true||!w||!w.request){x[y].eachLevel(1,false,function(A){if(A.exist){c.extend(A,{drawn:false,exist:false})}})}else{var z=[];x[y].eachLevel(1,false,function(A){z.push(A.id)});v.op.removeNode(z,{type:"nothing"});v.labels.clearLabels()}}w.onComplete()},expand:function(w,v){var x=this;this.show(w);this.animation.setOptions(c.merge(v,{$animating:false,compute:function(y){x.plotStep(y,v,this.$animating);this.$animating="expand"},complete:function(){x.plotStep(undefined,v,false);v.onComplete()}})).start()},show:function(v){var w=this.config;this.prepare(v);c.each(v,function(y){if(w.multitree&&!("$orn" in y.data)){delete y.data.$orns;var x=" ";y.eachSubnode(function(z){if(("$orn" in z.data)&&x.indexOf(z.data.$orn)<0&&z.exist&&!z.drawn){x+=z.data.$orn+" "}});y.data.$orns=x}y.eachLevel(0,w.levelsToShow,function(z){if(z.exist){z.drawn=true}})})},prepare:function(v){this.nodes=this.getNodesWithChildren(v);return this.nodes},getNodesWithChildren:function(x){var w=[],z=this.config,v=this.viz.root;x.sort(function(D,C){return(D._depth<=C._depth)-(D._depth>=C._depth)});for(var A=0;A<x.length;A++){if(x[A].anySubnode("exist")){for(var y=A+1,B=false;!B&&y<x.length;y++){if(!z.multitree||"$orn" in x[y].data){B=B||x[A].isDescendantOf(x[y].id)}}if(!B){w.push(x[A])}}}return w},plotStep:function(F,B,H){var E=this.viz,y=this.config,x=E.canvas,G=x.getCtx(),v=this.nodes;var A,z;var w={};for(A=0;A<v.length;A++){z=v[A];w[z.id]=[];var D=y.multitree&&!("$orn" in z.data);var C=D&&z.data.$orns;z.eachSubgraph(function(I){if(D&&C&&C.indexOf(I.data.$orn)>0&&I.drawn){I.drawn=false;w[z.id].push(I)}else{if((!D||!C)&&I.drawn){I.drawn=false;w[z.id].push(I)}}});z.drawn=true}if(v.length>0){E.fx.plot()}for(A in w){c.each(w[A],function(I){I.drawn=true})}for(A=0;A<v.length;A++){z=v[A];G.save();E.fx.plotSubtree(z,B,F,H);G.restore()}},getSiblings:function(v){var w={};c.each(v,function(z){var y=z.getParents();if(y.length==0){w[z.id]=[z]}else{var x=[];y[0].eachSubnode(function(A){x.push(A)});w[z.id]=x}});return w}});$jit.ST.Geom=new q({Implements:e.Geom,switchOrientation:function(v){this.config.orientation=v},dispatch:function(){var w=Array.prototype.slice.call(arguments);var x=w.shift(),v=w.length;var y=function(z){return typeof z=="function"?z():z};if(v==2){return(x=="top"||x=="bottom")?y(w[0]):y(w[1])}else{if(v==4){switch(x){case"top":return y(w[0]);case"right":return y(w[1]);case"bottom":return y(w[2]);case"left":return y(w[3])}}}return undefined},getSize:function(D,C){var B=D.data,y=this.config;var x=y.siblingOffset;var A=(y.multitree&&("$orn" in B)&&B.$orn)||y.orientation;var v=D.getData("width")+x;var z=D.getData("height")+x;if(!C){return this.dispatch(A,z,v)}else{return this.dispatch(A,v,z)}},getTreeBaseSize:function(z,A,w){var x=this.getSize(z,true),v=0,y=this;if(w(A,z)){return x}if(A===0){return 0}z.eachSubnode(function(B){v+=y.getTreeBaseSize(B,A-1,w)});return(x>v?x:v)+this.config.subtreeOffset},getEdge:function(B,A,z){var x=function(D,w){return function(){return B.pos.add(new p(D,w))}};var C=B.getData("align")||this.node.align;var v=B.getData("width");var y=B.getData("height");if(A=="begin"){if(C=="center"){return this.dispatch(z,x(0,y/2),x(-v/2,0),x(0,-y/2),x(v/2,0))}else{if(C=="left"){return this.dispatch(z,x(0,y),x(0,0),x(0,0),x(v,0))}else{if(C=="right"){return this.dispatch(z,x(0,0),x(-v,0),x(0,-y),x(0,0))}else{throw"align: not implemented"}}}}else{if(A=="end"){if(C=="center"){return this.dispatch(z,x(0,-y/2),x(v/2,0),x(0,y/2),x(-v/2,0))}else{if(C=="left"){return this.dispatch(z,x(0,0),x(v,0),x(0,y),x(0,0))}else{if(C=="right"){return this.dispatch(z,x(0,-y),x(0,0),x(0,0),x(-v,0))}else{throw"align: not implemented"}}}}}},getScaledTreePosition:function(A,B){var C=A.getData("align")||this.node.align;var v=A.getData("width");var z=A.getData("height");var y=(this.config.multitree&&("$orn" in A.data)&&A.data.$orn)||this.config.orientation;var x=function(D,w){return function(){return A.pos.add(new p(D,w)).$scale(1-B)}};if(C=="left"){return this.dispatch(y,x(0,z),x(0,0),x(0,0),x(v,0))}else{if(C=="center"){return this.dispatch(y,x(0,z/2),x(-v/2,0),x(0,-z/2),x(v/2,0))}else{if(C=="right"){return this.dispatch(y,x(0,0),x(-v,0),x(0,-z),x(0,0))}else{throw"align: not implemented"}}}},treeFitsInCanvas:function(A,v,B){var x=v.getSize();var y=(this.config.multitree&&("$orn" in A.data)&&A.data.$orn)||this.config.orientation;var w=this.dispatch(y,x.width,x.height);var z=this.getTreeBaseSize(A,B,function(D,C){return D===0||!C.anySubnode()});return(z<w)}});$jit.ST.Plot=new q({Implements:e.Plot,plotSubtree:function(y,v,z,D){var B=this.viz,w=B.canvas,x=B.config;z=Math.min(Math.max(0.001,z),1);if(z>=0){y.drawn=false;var C=w.getCtx();var A=B.geom.getScaledTreePosition(y,z);C.translate(A.x,A.y);C.scale(z,z)}this.plotTree(y,c.merge(v,{withLabels:true,hideLabels:!!z,plotSubtree:function(H,F){var E=x.multitree&&!("$orn" in y.data);var G=E&&y.getData("orns");return !E||G.indexOf(y.getData("orn"))>-1}}),D);if(z>=0){y.drawn=true}},getAlignedPos:function(A,x,v,z){var y,w;if(!z){z=this.node.align}if(z=="center"){y={x:A.x-x/2,y:A.y-v/2}}else{if(z=="left"){w=this.config.orientation;if(w=="bottom"||w=="top"){y={x:A.x-x/2,y:A.y}}else{y={x:A.x,y:A.y-v/2}}}else{if(z=="right"){w=this.config.orientation;if(w=="bottom"||w=="top"){y={x:A.x-x/2,y:A.y-v}}else{y={x:A.x-x,y:A.y-v/2}}}else{throw"align: not implemented"}}}return y},getOrientation:function(v){var x=this.config;var w=x.orientation;if(x.multitree){var y=v.nodeFrom;var z=v.nodeTo;w=(("$orn" in y.data)&&y.data.$orn)||(("$orn" in z.data)&&z.data.$orn)}return w}});$jit.ST.Label={};$jit.ST.Label.Native=new q({Implements:e.Label.Native,renderLabel:function(y,A,x){var w=y.getCtx(),C=A.pos.getc(true),z=A.getData("width"),v=A.getData("height"),B=A.getData("align");pos=this.viz.fx.getAlignedPos(C,z,v,B);w.fillText(A.name,pos.x+z/2,pos.y+v/2)}});$jit.ST.Label.DOM=new q({Implements:e.Label.DOM,placeLabel:function(P,J,F){var A=J.pos.getc(true),O=this.viz.config,K=J.getData("align")||O.Node.align,v=this.viz.canvas,C=J.getData("width"),M=J.getData("height"),x=v.getSize(),G,N;var z=v.translateOffsetX,y=v.translateOffsetY,E=v.scaleOffsetX,D=v.scaleOffsetY,I=A.x*E+z,H=A.y*D+y;C=Math.round(C*E);M=Math.round(M*D);if(K=="center"){G={x:Math.round(I-C/2+x.width/2),y:Math.round(H-M/2+x.height/2)}}else{if(K=="left"){N=O.orientation;if(N=="bottom"||N=="top"){G={x:Math.round(I-C/2+x.width/2),y:Math.round(H+x.height/2)}}else{G={x:Math.round(I+x.width/2),y:Math.round(H-M/2+x.height/2)}}}else{if(K=="right"){N=O.orientation;if(N=="bottom"||N=="top"){G={x:Math.round(I-C/2+x.width/2),y:Math.round(H-M+x.height/2)}}else{G={x:Math.round(I-C+x.width/2),y:Math.round(H-M/2+x.height/2)}}}else{throw"align: not implemented"}}}var L=P.style;L.left=G.x+"px";L.top=G.y+"px";var B={x:G.x+C,y:G.y+M};L.display=this.fitsInCanvas(G,v)||this.fitsInCanvas(B,v)?"":"none";F.onPlaceLabel(P,J)}});$jit.ST.Label.SVG=new q({Implements:[$jit.ST.Label.DOM,e.Label.SVG],initialize:function(v){this.viz=v}});$jit.ST.Label.HTML=new q({Implements:[$jit.ST.Label.DOM,e.Label.HTML],initialize:function(v){this.viz=v}});$jit.ST.Plot.NodeTypes=new q({none:{render:c.empty,contains:c.lambda(false)},circle:{render:function(w,v){var y=w.getData("dim"),A=w.getData("align"),z=this.getAlignedPos(w.pos.getc(true),y,y,A),x=y/2;this.nodeHelper.circle.render("fill",{x:z.x+x,y:z.y+x},x,v)},contains:function(v,A){var x=v.getData("dim"),z=v.getData("align"),y=this.getAlignedPos(v.pos.getc(true),x,x,z),w=x/2;this.nodeHelper.circle.contains({x:y.x+w,y:y.y+w},A,w)}},square:{render:function(w,v){var y=w.getData("dim"),x=y/2,A=w.getData("align"),z=this.getAlignedPos(w.pos.getc(true),y,y,A);this.nodeHelper.square.render("fill",{x:z.x+x,y:z.y+x},x,v)},contains:function(v,A){var x=v.getData("dim"),z=v.getData("align"),y=this.getAlignedPos(v.pos.getc(true),x,x,z),w=x/2;this.nodeHelper.square.contains({x:y.x+w,y:y.y+w},A,w)}},ellipse:{render:function(y,w){var x=y.getData("width"),v=y.getData("height"),A=y.getData("align"),z=this.getAlignedPos(y.pos.getc(true),x,v,A);this.nodeHelper.ellipse.render("fill",{x:z.x+x/2,y:z.y+v/2},x,v,w)},contains:function(x,A){var w=x.getData("width"),v=x.getData("height"),z=x.getData("align"),y=this.getAlignedPos(x.pos.getc(true),w,v,z);this.nodeHelper.ellipse.contains({x:y.x+w/2,y:y.y+v/2},A,w,v)}},rectangle:{render:function(y,w){var x=y.getData("width"),v=y.getData("height"),A=y.getData("align"),z=this.getAlignedPos(y.pos.getc(true),x,v,A);this.nodeHelper.rectangle.render("fill",{x:z.x+x/2,y:z.y+v/2},x,v,w)},contains:function(x,A){var w=x.getData("width"),v=x.getData("height"),z=x.getData("align"),y=this.getAlignedPos(x.pos.getc(true),w,v,z);this.nodeHelper.rectangle.contains({x:y.x+w/2,y:y.y+v/2},A,w,v)}}});$jit.ST.Plot.EdgeTypes=new q({none:c.empty,line:{render:function(w,y){var x=this.getOrientation(w),z=w.nodeFrom,A=w.nodeTo,v=z._depth<A._depth,C=this.viz.geom.getEdge(v?z:A,"begin",x),B=this.viz.geom.getEdge(v?A:z,"end",x);this.edgeHelper.line.render(C,B,y)},contains:function(w,C){var x=this.getOrientation(w),y=w.nodeFrom,z=w.nodeTo,v=y._depth<z._depth,B=this.viz.geom.getEdge(v?y:z,"begin",x),A=this.viz.geom.getEdge(v?z:y,"end",x);return this.edgeHelper.line.contains(B,A,C,this.edge.epsilon)}},arrow:{render:function(B,w){var A=this.getOrientation(B),x=B.nodeFrom,v=B.nodeTo,z=B.getData("dim"),D=this.viz.geom.getEdge(x,"begin",A),E=this.viz.geom.getEdge(v,"end",A),C=B.data.$direction,y=(C&&C.length>1&&C[0]!=x.id);this.edgeHelper.arrow.render(D,E,z,y,w)},contains:function(w,C){var x=this.getOrientation(w),y=w.nodeFrom,z=w.nodeTo,v=y._depth<z._depth,B=this.viz.geom.getEdge(v?y:z,"begin",x),A=this.viz.geom.getEdge(v?z:y,"end",x);return this.edgeHelper.arrow.contains(B,A,C,this.edge.epsilon)}},"quadratic:begin":{render:function(B,v){var A=this.getOrientation(B);var z=B.nodeFrom,C=B.nodeTo,E=z._depth<C._depth,w=this.viz.geom.getEdge(E?z:C,"begin",A),x=this.viz.geom.getEdge(E?C:z,"end",A),y=B.getData("dim"),D=v.getCtx();D.beginPath();D.moveTo(w.x,w.y);switch(A){case"left":D.quadraticCurveTo(w.x+y,w.y,x.x,x.y);break;case"right":D.quadraticCurveTo(w.x-y,w.y,x.x,x.y);break;case"top":D.quadraticCurveTo(w.x,w.y+y,x.x,x.y);break;case"bottom":D.quadraticCurveTo(w.x,w.y-y,x.x,x.y);break}D.stroke()}},"quadratic:end":{render:function(B,v){var A=this.getOrientation(B);var z=B.nodeFrom,C=B.nodeTo,E=z._depth<C._depth,w=this.viz.geom.getEdge(E?z:C,"begin",A),x=this.viz.geom.getEdge(E?C:z,"end",A),y=B.getData("dim"),D=v.getCtx();D.beginPath();D.moveTo(w.x,w.y);switch(A){case"left":D.quadraticCurveTo(x.x-y,x.y,x.x,x.y);break;case"right":D.quadraticCurveTo(x.x+y,x.y,x.x,x.y);break;case"top":D.quadraticCurveTo(x.x,x.y-y,x.x,x.y);break;case"bottom":D.quadraticCurveTo(x.x,x.y+y,x.x,x.y);break}D.stroke()}},bezier:{render:function(B,v){var A=this.getOrientation(B),z=B.nodeFrom,C=B.nodeTo,E=z._depth<C._depth,w=this.viz.geom.getEdge(E?z:C,"begin",A),x=this.viz.geom.getEdge(E?C:z,"end",A),y=B.getData("dim"),D=v.getCtx();D.beginPath();D.moveTo(w.x,w.y);switch(A){case"left":D.bezierCurveTo(w.x+y,w.y,x.x-y,x.y,x.x,x.y);break;case"right":D.bezierCurveTo(w.x-y,w.y,x.x+y,x.y,x.x,x.y);break;case"top":D.bezierCurveTo(w.x,w.y+y,x.x,x.y-y,x.x,x.y);break;case"bottom":D.bezierCurveTo(w.x,w.y-y,x.x,x.y+y,x.x,x.y);break}D.stroke()}}})})();