(function(){window.$jit=function(z){z=z||window;for(var A in $jit){if($jit[A].$extend){z[A]=$jit[A]}}};$jit.version="2.0.0a";var d=function(z){return document.getElementById(z)};d.empty=function(){};d.extend=function(B,z){for(var A in (z||{})){B[A]=z[A]}return B};d.lambda=function(z){return(typeof z=="function")?z:function(){return z}};d.time=Date.now||function(){return +new Date};d.splat=function(A){var z=d.type(A);return z?((z!="array")?[A]:A):[]};d.type=function(A){var z=d.type.s.call(A).match(/^\[object\s(.*)\]$/)[1].toLowerCase();if(z!="object"){return z}if(A&&A.$$family){return A.$$family}return(A&&A.nodeName&&A.nodeType==1)?"element":z};d.type.s=Object.prototype.toString;d.each=function(E,D){var C=d.type(E);if(C=="object"){for(var B in E){D(E[B],B)}}else{for(var A=0,z=E.length;A<z;A++){D(E[A],A)}}};d.indexOf=function(C,B){if(Array.indexOf){return C.indexOf(B)}for(var A=0,z=C.length;A<z;A++){if(C[A]===B){return A}}return -1};d.map=function(B,A){var z=[];d.each(B,function(D,C){z.push(A(D,C))});return z};d.reduce=function(D,B,A){var z=D.length;if(z==0){return A}var C=arguments.length==3?A:D[--z];while(z--){C=B(C,D[z])}return C};d.merge=function(){var D={};for(var C=0,z=arguments.length;C<z;C++){var A=arguments[C];if(d.type(A)!="object"){continue}for(var B in A){var F=A[B],E=D[B];D[B]=(E&&d.type(F)=="object"&&d.type(E)=="object")?d.merge(E,F):d.unlink(F)}}return D};d.unlink=function(B){var A;switch(d.type(B)){case"object":A={};for(var D in B){A[D]=d.unlink(B[D])}break;case"array":A=[];for(var C=0,z=B.length;C<z;C++){A[C]=d.unlink(B[C])}break;default:return B}return A};d.zip=function(){if(arguments.length===0){return[]}for(var B=0,A=[],z=arguments.length,E=arguments[0].length;B<E;B++){for(var C=0,D=[];C<z;C++){D.push(arguments[C][B])}A.push(D)}return A};d.rgbToHex=function(D,C){if(D.length<3){return null}if(D.length==4&&D[3]==0&&!C){return"transparent"}var A=[];for(var z=0;z<3;z++){var B=(D[z]-0).toString(16);A.push(B.length==1?"0"+B:B)}return C?A:"#"+A.join("")};d.hexToRgb=function(B){if(B.length!=7){B=B.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);B.shift();if(B.length!=3){return null}var z=[];for(var A=0;A<3;A++){var C=B[A];if(C.length==1){C+=C}z.push(parseInt(C,16))}return z}else{B=parseInt(B.slice(1),16);return[B>>16,B>>8&255,B&255]}};d.rgbToHsl=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=(z+C)/2;if(z==C){E=D=0}else{var F=z-C;D=A>0.5?F/(2-z-C):F/(z+C);switch(z){case r:E=(g-b)/F+(g<b?6:0);break;case g:E=(b-r)/F+2;break;case b:E=(r-g)/F+4;break}E/=6}return[Math.round(E*360),Math.round(D*100),Math.round(A*100)]};d.hslToRgb=function(D){var F=D[0]/360,I=D[1]/100,E=D[2]/100;var z,G,H;if(I==0){z=G=H=E}else{function C(L,K,J){if(J<0){J+=1}if(J>1){J-=1}if(J<1/6){return L+(K-L)*6*J}if(J<1/2){return K}if(J<2/3){return L+(K-L)*(2/3-J)*6}return L}var A=E<0.5?E*(1+I):E+I-E*I;var B=2*E-A;z=C(B,A,F+1/3);G=C(B,A,F);H=C(B,A,F-1/3)}return[Math.round(z*255),Math.round(G*255),Math.round(H*255)]};d.hslToHex=function(z){return d.rgbToHex(d.hslToRgb(z))};d.rgbToHsv=function(B){r=B[0]/255,g=B[1]/255,b=B[2]/255;var z=Math.max(r,g,b),C=Math.min(r,g,b);var E,D,A=z;var F=z-C;D=z==0?0:F/z;if(z==C){E=0}else{switch(z){case r:E=(g-b)/F+(g<b?6:0);break;case g:E=(b-r)/F+2;break;case b:E=(r-g)/F+4;break}E/=6}return[Math.round(E*360),Math.round(D*100),Math.round(A*100)]};d.hsvToRgb=function(C){var E=C[0]/360,K=C[1]/100,I=C[2]/100;var z,F,H;var D=Math.floor(E*6);var G=E*6-D;var B=I*(1-K);var A=I*(1-G*K);var J=I*(1-(1-G)*K);switch(D%6){case 0:z=I,F=J,H=B;break;case 1:z=A,F=I,H=B;break;case 2:z=B,F=I,H=J;break;case 3:z=B,F=A,H=I;break;case 4:z=J,F=B,H=I;break;case 5:z=I,F=B,H=A;break}return[Math.round(z*255),Math.round(F*255),Math.round(H*255)]};d.hsvToHex=function(z){return d.rgbToHex(d.hsvToRgb(z))};d.destroy=function(z){d.clean(z);if(z.parentNode){z.parentNode.removeChild(z)}if(z.clearAttributes){z.clearAttributes()}};d.clean=function(C){for(var B=C.childNodes,A=0,z=B.length;A<z;A++){d.destroy(B[A])}};d.addEvent=function(B,A,z){if(B.addEventListener){B.addEventListener(A,z,false)}else{B.attachEvent("on"+A,z)}};d.addEvents=function(A,B){for(var z in B){d.addEvent(A,z,B[z])}};d.hasClass=function(A,z){return(" "+A.className+" ").indexOf(" "+z+" ")>-1};d.addClass=function(A,z){if(!d.hasClass(A,z)){A.className=(A.className+" "+z)}};d.removeClass=function(A,z){A.className=A.className.replace(new RegExp("(^|\\s)"+z+"(?:\\s|$)"),"$1")};d.getPos=function(B){var E=D(B);var z=C(B);return{x:E.x-z.x,y:E.y-z.y};function D(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.offsetLeft;F.y+=G.offsetTop;G=G.offsetParent}return F}function C(G){var F={x:0,y:0};while(G&&!A(G)){F.x+=G.scrollLeft;F.y+=G.scrollTop;G=G.parentNode}return F}function A(F){return(/^(?:body|html)$/i).test(F.tagName)}};d.event={get:function(A,z){z=z||window;return A||z.event},getWheel:function(z){return z.wheelDelta?z.wheelDelta/120:-(z.detail||0)/3},isRightClick:function(z){return(z.which==3||z.button==2)},getPos:function(C,B){B=B||window;C=C||B.event;var A=B.document;A=A.documentElement||A.body;if(C.touches&&C.touches.length){C=C.touches[0]}var z={x:C.pageX||(C.clientX+A.scrollLeft),y:C.pageY||(C.clientY+A.scrollTop)};return z},stop:function(z){if(z.stopPropagation){z.stopPropagation()}z.cancelBubble=true;if(z.preventDefault){z.preventDefault()}else{z.returnValue=false}}};$jit.util=$jit.id=d;var t=function(A){A=A||{};var z=function(){for(var D in this){if(typeof this[D]!="function"){this[D]=d.unlink(this[D])}}this.constructor=z;if(t.prototyping){return this}var C=this.initialize?this.initialize.apply(this,arguments):this;this.$$family="class";return C};for(var B in t.Mutators){if(!A[B]){continue}A=t.Mutators[B](A,A[B]);delete A[B]}d.extend(z,this);z.constructor=t;z.prototype=A;return z};t.Mutators={Implements:function(z,A){d.each(d.splat(A),function(C){t.prototyping=C;var B=(typeof C=="function")?new C:C;for(var D in B){if(!(D in z)){z[D]=B[D]}}delete t.prototyping});return z}};d.extend(t,{inherit:function(z,C){for(var B in C){var A=C[B];var E=z[B];var D=d.type(A);if(E&&D=="function"){if(A!=E){t.override(z,B,A)}}else{if(D=="object"){z[B]=d.merge(E,A)}else{z[B]=A}}}return z},override:function(A,z,D){var C=t.prototyping;if(C&&A[z]!=C[z]){C=null}var B=function(){var E=this.parent;this.parent=C?C[z]:A[z];var F=D.apply(this,arguments);this.parent=E;return F};A[z]=B}});t.prototype.implement=function(){var z=this.prototype;d.each(Array.prototype.slice.call(arguments||[]),function(A){t.inherit(z,A)});return this};$jit.Class=t;$jit.json={prune:function(A,z){this.each(A,function(C,B){if(B==z&&C.children){delete C.children;C.children=[]}})},getParent:function(z,D){if(z.id==D){return false}var C=z.children;if(C&&C.length>0){for(var B=0;B<C.length;B++){if(C[B].id==D){return z}else{var A=this.getParent(C[B],D);if(A){return A}}}}return false},getSubtree:function(z,D){if(z.id==D){return z}for(var B=0,C=z.children;B<C.length;B++){var A=this.getSubtree(C[B],D);if(A!=null){return A}}return null},eachLevel:function(z,E,B,D){if(E<=B){D(z,E);if(!z.children){return}for(var A=0,C=z.children;A<C.length;A++){this.eachLevel(C[A],E+1,B,D)}}},each:function(z,A){this.eachLevel(z,0,Number.MAX_VALUE,A)}};$jit.Trans={$extend:true,linear:function(z){return z}};var k=$jit.Trans;(function(){var z=function(C,B){B=d.splat(B);return d.extend(C,{easeIn:function(D){return C(D,B)},easeOut:function(D){return 1-C(1-D,B)},easeInOut:function(D){return(D<=0.5)?C(2*D,B)/2:(2-C(2*(1-D),B))/2}})};var A={Pow:function(C,B){return Math.pow(C,B[0]||6)},Expo:function(B){return Math.pow(2,8*(B-1))},Circ:function(B){return 1-Math.sin(Math.acos(B))},Sine:function(B){return 1-Math.sin((1-B)*Math.PI/2)},Back:function(C,B){B=B[0]||1.618;return Math.pow(C,2)*((B+1)*C-B)},Bounce:function(E){var D;for(var C=0,B=1;1;C+=B,B/=2){if(E>=(7-4*C)/11){D=B*B-Math.pow((11-6*C-11*E)/4,2);break}}return D},Elastic:function(C,B){return Math.pow(2,10*--C)*Math.cos(20*C*Math.PI*(B[0]||1)/3)}};d.each(A,function(C,B){k[B]=z(C)});d.each(["Quad","Cubic","Quart","Quint"],function(C,B){k[C]=z(function(D){return Math.pow(D,[B+2])})})})();var x=new t({initialize:function(z){this.setOptions(z)},setOptions:function(z){var A={duration:2500,fps:40,transition:k.Quart.easeInOut,compute:d.empty,complete:d.empty,link:"ignore"};this.opt=d.merge(A,z||{});return this},step:function(){var A=d.time(),z=this.opt;if(A<this.time+z.duration){var B=z.transition((A-this.time)/z.duration);z.compute(B)}else{this.timer=clearInterval(this.timer);z.compute(1);z.complete()}},start:function(){if(!this.check()){return this}this.time=0;this.startTimer();return this},startTimer:function(){var z=this,A=this.opt.fps;if(this.timer){return false}this.time=d.time()-this.time;this.timer=setInterval((function(){z.step()}),Math.round(1000/A));return true},pause:function(){this.stopTimer();return this},resume:function(){this.startTimer();return this},stopTimer:function(){if(!this.timer){return false}this.time=d.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 p=function(){var B=arguments;for(var D=0,z=B.length,A={};D<z;D++){var C=p[B[D]];if(C.$extend){d.extend(A,C)}else{A[B[D]]=C}}return A};p.Canvas={$extend:true,injectInto:"id",width:false,height:false,useCanvas:false,withLabels:true,background:false};p.Tree={$extend:true,orientation:"left",subtreeOffset:8,siblingOffset:5,indent:10,multitree:false,align:"center"};p.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:{}};p.Edge={$extend:false,overridable:false,type:"line",color:"#ccb",lineWidth:1,dim:15,alpha:1,epsilon:7,CanvasStyles:{}};p.Fx={$extend:true,fps:40,duration:2500,transition:$jit.Trans.Quart.easeInOut,clearCanvas:true};p.Label={$extend:false,overridable:false,type:"HTML",style:" ",size:10,family:"sans-serif",textAlign:"center",textBaseline:"alphabetic",color:"#fff"};p.Tips={$extend:false,enable:false,type:"auto",offsetX:20,offsetY:20,force:false,onShow:d.empty,onHide:d.empty};p.NodeStyles={$extend:false,enable:false,type:"auto",stylesHover:false,stylesClick:false};p.Events={$extend:false,enable:false,enableForEdges:false,type:"auto",onClick:d.empty,onRightClick:d.empty,onMouseMove:d.empty,onMouseEnter:d.empty,onMouseLeave:d.empty,onDragStart:d.empty,onDragMove:d.empty,onDragCancel:d.empty,onDragEnd:d.empty,onTouchStart:d.empty,onTouchMove:d.empty,onTouchEnd:d.empty,onMouseWheel:d.empty};p.Navigation={$extend:false,enable:false,type:"auto",panning:false,zooming:false};p.Controller={$extend:true,onBeforeCompute:d.empty,onAfterCompute:d.empty,onCreateLabel:d.empty,onPlaceLabel:d.empty,onComplete:d.empty,onBeforePlotLine:d.empty,onAfterPlotLine:d.empty,onBeforePlotNode:d.empty,onAfterPlotNode:d.empty,request:false};var w={initialize:function(B,z){this.viz=z;this.canvas=z.canvas;this.config=z.config[B];this.nodeTypes=z.fx.nodeTypes;var A=this.config.type;this.dom=A=="auto"?(z.config.Label.type!="Native"):(A!="Native");this.labelContainer=this.dom&&z.labels.getLabelContainer();this.isEnabled()&&this.initializePost()},initializePost:d.empty,setAsProperty:d.lambda(false),isEnabled:function(){return this.config.enable},isLabel:function(C,B){C=d.event.get(C,B);var z=this.labelContainer,A=C.target||C.srcElement;if(A&&A.parentNode==z){return A}return false}};var j={onMouseUp:d.empty,onMouseDown:d.empty,onMouseMove:d.empty,onMouseOver:d.empty,onMouseOut:d.empty,onMouseWheel:d.empty,onTouchStart:d.empty,onTouchMove:d.empty,onTouchEnd:d.empty,onTouchCancel:d.empty};var v=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.node=false;this.edge=false;this.registeredObjects=[];this.attachEvents()},attachEvents:function(){var B=this.canvas.getElement(),A=this;B.oncontextmenu=d.lambda(false);d.addEvents(B,{mouseup:function(E,D){var C=d.event.get(E,D);A.handleEvent("MouseUp",E,D,A.makeEventObject(E,D),d.event.isRightClick(C))},mousedown:function(E,D){var C=d.event.get(E,D);A.handleEvent("MouseDown",E,D,A.makeEventObject(E,D),d.event.isRightClick(C))},mousemove:function(D,C){A.handleEvent("MouseMove",D,C,A.makeEventObject(D,C))},mouseover:function(D,C){A.handleEvent("MouseOver",D,C,A.makeEventObject(D,C))},mouseout:function(D,C){A.handleEvent("MouseOut",D,C,A.makeEventObject(D,C))},touchstart:function(D,C){A.handleEvent("TouchStart",D,C,A.makeEventObject(D,C))},touchmove:function(D,C){A.handleEvent("TouchMove",D,C,A.makeEventObject(D,C))},touchend:function(D,C){A.handleEvent("TouchEnd",D,C,A.makeEventObject(D,C))}});var z=function(F,E){var D=d.event.get(F,E);var C=d.event.getWheel(D);A.handleEvent("MouseWheel",F,E,C)};if(!document.getBoxObjectFor&&window.mozInnerScreenX==null){d.addEvent(B,"mousewheel",z)}else{B.addEventListener("DOMMouseScroll",z,false)}},register:function(z){this.registeredObjects.push(z)},handleEvent:function(){var A=Array.prototype.slice.call(arguments),D=A.shift();for(var C=0,B=this.registeredObjects,z=B.length;C<z;C++){B[C]["on"+D].apply(B[C],A)}},makeEventObject:function(F,E){var C=this,D=this.viz.graph,B=this.viz.fx,A=B.nodeTypes,z=B.edgeTypes;return{pos:false,node:false,edge:false,contains:false,getNodeCalled:false,getEdgeCalled:false,getPos:function(){var I=C.viz.canvas,J=I.getSize(),K=I.getPos(),H=I.translateOffsetX,G=I.translateOffsetY,N=I.scaleOffsetX,L=I.scaleOffsetY,M=d.event.getPos(F,E);this.pos={x:(M.x-K.x-J.width/2-H)*1/N,y:(M.y-K.y-J.height/2-G)*1/L};return this.pos},getNode:function(){if(this.getNodeCalled){return this.node}this.getNodeCalled=true;for(var J in D.nodes){var I=D.nodes[J],H=I&&A[I.getData("type")],G=H&&H.contains&&H.contains.call(B,I,this.getPos());if(G){this.contains=G;return C.node=this.node=I}}return C.node=this.node=false},getEdge:function(){if(this.getEdgeCalled){return this.edge}this.getEdgeCalled=true;var I={};for(var M in D.edges){var K=D.edges[M];I[M]=true;for(var L in K){if(L in I){continue}var J=K[L],H=J&&z[J.getData("type")],G=H&&H.contains&&H.contains.call(B,J,this.getPos());if(G){this.contains=G;return C.edge=this.edge=J}}}return C.edge=this.edge=false},getContains:function(){if(this.getNodeCalled){return this.contains}this.getNode();return this.contains}}}});var q={initializeExtras:function(){var A=new v(this),z=this;d.each(["NodeStyles","Tips","Navigation","Events"],function(B){var C=new q.Classes[B](B,z);if(C.isEnabled()){A.register(C)}if(C.setAsProperty()){z[B.toLowerCase()]=C}})}};q.Classes={};q.Classes.Events=new t({Implements:[w,j],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:d.lambda(true),onMouseUp:function(D,C,A,B){var z=d.event.get(D,C);if(B){this.config.onRightClick(this.hovered,A,z)}else{this.config.onClick(this.pressed,A,z)}if(this.pressed){if(this.moved){this.config.onDragEnd(this.pressed,A,z)}else{this.config.onDragCancel(this.pressed,A,z)}this.pressed=this.moved=false}},onMouseOut:function(E,D,C){var A=d.event.get(E,D),B;if(this.dom&&(B=this.isLabel(E,D))){this.config.onMouseLeave(this.viz.graph.getNode(B.id),C,A);this.hovered=false;return}var z=A.relatedTarget,F=this.canvas.getElement();while(z&&z.parentNode){if(F==z.parentNode){return}z=z.parentNode}if(this.hovered){this.config.onMouseLeave(this.hovered,C,A);this.hovered=false}},onMouseOver:function(D,C,B){var z=d.event.get(D,C),A;if(this.dom&&(A=this.isLabel(D,C))){this.hovered=this.viz.graph.getNode(A.id);this.config.onMouseEnter(this.hovered,B,z)}},onMouseMove:function(F,E,D){var A,z=d.event.get(F,E);if(this.pressed){this.moved=true;this.config.onDragMove(this.pressed,D,z);return}if(this.dom){this.config.onMouseMove(this.hovered,D,z)}else{if(this.hovered){var G=this.hovered;var C=G.nodeFrom?this.etypes[G.getData("type")]:this.ntypes[G.getData("type")];var B=C&&C.contains&&C.contains.call(this.fx,G,D.getPos());if(B){this.config.onMouseMove(G,D,z);return}else{this.config.onMouseLeave(G,D,z);this.hovered=false}}if(this.hovered=(D.getNode()||(this.config.enableForEdges&&D.getEdge()))){this.config.onMouseEnter(this.hovered,D,z)}else{this.config.onMouseMove(false,D,z)}}},onMouseWheel:function(A,z,B){this.config.onMouseWheel(B,d.event.get(A,z))},onMouseDown:function(C,B,A){var z=d.event.get(C,B);this.pressed=A.getNode()||(this.config.enableForEdges&&A.getEdge());this.config.onDragStart(this.pressed,A,z)},onTouchStart:function(C,B,A){var z=d.event.get(C,B);this.touched=A.getNode()||(this.config.enableForEdges&&A.getEdge());this.config.onTouchStart(this.touched,A,z)},onTouchMove:function(C,B,A){var z=d.event.get(C,B);if(this.touched){this.touchMoved=true;this.config.onTouchMove(this.touched,A,z)}},onTouchEnd:function(C,B,A){var z=d.event.get(C,B);if(this.touched){if(this.touchMoved){this.config.onTouchEnd(this.touched,A,z)}else{this.config.onTouchCancel(this.touched,A,z)}this.touched=this.touchMoved=false}}});q.Classes.Tips=new t({Implements:[w,j],initializePost:function(){if(document.body){var z=d("_tooltip")||document.createElement("div");z.id="_tooltip";z.className="tip";d.extend(z.style,{position:"absolute",display:"none",zIndex:13000});document.body.appendChild(z);this.tip=z;this.node=false}},setAsProperty:d.lambda(true),onMouseOut:function(B,A){if(this.dom&&this.isLabel(B,A)){this.hide(true);return}var z=B.relatedTarget,C=this.canvas.getElement();while(z&&z.parentNode){if(C==z.parentNode){return}z=z.parentNode}this.hide(false)},onMouseOver:function(B,A){var z;if(this.dom&&(z=this.isLabel(B,A))){this.node=this.viz.graph.getNode(z.id);this.config.onShow(this.tip,this.node,z)}},onMouseMove:function(C,B,z){if(this.dom&&this.isLabel(C,B)){this.setTooltipPosition(d.event.getPos(C,B))}if(!this.dom){var A=z.getNode();if(!A){this.hide(true);return}if(this.config.force||!this.node||this.node.id!=A.id){this.node=A;this.config.onShow(this.tip,A,z.getContains())}this.setTooltipPosition(d.event.getPos(C,B))}},setTooltipPosition:function(G){var C=this.tip,B=C.style,A=this.config;B.display="";var E={height:document.body.clientHeight,width:document.body.clientWidth};var D={width:C.offsetWidth,height:C.offsetHeight};var z=A.offsetX,F=A.offsetY;B.top=((G.y+F+D.height>E.height)?(G.y-D.height-F):G.y+F)+"px";B.left=((G.x+D.width+z>E.width)?(G.x-D.width-z):G.x+z)+"px"},hide:function(z){this.tip.style.display="none";z&&this.config.onHide()}});q.Classes.NodeStyles=new t({Implements:[w,j],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 x();this.down=false;this.move=false},onMouseOut:function(B,A){this.down=this.move=false;if(!this.hoveredNode){return}if(this.dom&&this.isLabel(B,A)){this.toggleStylesOnHover(this.hoveredNode,false)}var z=B.relatedTarget,C=this.canvas.getElement();while(z&&z.parentNode){if(C==z.parentNode){return}z=z.parentNode}this.toggleStylesOnHover(this.hoveredNode,false);this.hoveredNode=false},onMouseOver:function(C,B){var z;if(this.dom&&(z=this.isLabel(C,B))){var A=this.viz.graph.getNode(z.id);if(A.selected){return}this.hoveredNode=A;this.toggleStylesOnHover(this.hoveredNode,true)}},onMouseDown:function(D,C,A,B){if(B){return}var z;if(this.dom&&(z=this.isLabel(D,C))){this.down=this.viz.graph.getNode(z.id)}else{if(!this.dom){this.down=A.getNode()}}this.move=false},onMouseUp:function(C,B,z,A){if(A){return}if(!this.move){this.onClick(z.getNode())}this.down=this.move=false},getRestoredStyles:function(A,z){var C={},B=this["nodeStylesOn"+z];for(var D in B){C[D]=A.styles["$"+D]}return C},toggleStylesOnHover:function(z,A){if(this.nodeStylesOnHover){this.toggleStylesOn("Hover",z,A)}},toggleStylesOnClick:function(z,A){if(this.nodeStylesOnClick){this.toggleStylesOn("Click",z,A)}},toggleStylesOn:function(D,z,F){var G=this.viz;var E=this.nStyles;if(F){var C=this;if(!z.styles){z.styles=d.merge(z.data,{})}for(var H in this["nodeStylesOn"+D]){var A="$"+H;if(!(A in z.styles)){z.styles[A]=z.getData(H)}}G.fx.nodeFx(d.extend({elements:{id:z.id,properties:C["nodeStylesOn"+D]},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}else{var B=this.getRestoredStyles(z,D);G.fx.nodeFx(d.extend({elements:{id:z.id,properties:B},transition:k.Quart.easeOut,duration:300,fps:40},this.config))}},onClick:function(z){if(!z){return}var A=this.nodeStylesOnClick;if(!A){return}if(z.selected){this.toggleStylesOnClick(z,false);delete z.selected}else{this.viz.graph.eachNode(function(C){if(C.selected){for(var B in A){C.setData(B,C.styles["$"+B],"end")}delete C.selected}});this.toggleStylesOnClick(z,true);z.selected=true;delete z.hovered;this.hoveredNode=false}},onMouseMove:function(F,E,C){if(this.down){this.move=true}if(this.dom&&this.isLabel(F,E)){return}var D=this.nodeStylesOnHover;if(!D){return}if(!this.dom){if(this.hoveredNode){var A=this.types[this.hoveredNode.getData("type")];var z=A&&A.contains&&A.contains.call(this.fx,this.hoveredNode,C.getPos());if(z){return}}var B=C.getNode();if(!this.hoveredNode&&!B){return}if(B.hovered){return}if(B&&!B.selected){this.fx.nodeFxAnimation.stopTimer();this.viz.graph.eachNode(function(H){if(H.hovered&&!H.selected){for(var G in D){H.setData(G,H.styles["$"+G],"end")}delete H.hovered}});B.hovered=true;this.hoveredNode=B;this.toggleStylesOnHover(B,true)}else{if(this.hoveredNode&&!this.hoveredNode.selected){this.fx.nodeFxAnimation.stopTimer();this.toggleStylesOnHover(this.hoveredNode,false);delete this.hoveredNode.hovered;this.hoveredNode=false}}}}});q.Classes.Navigation=new t({Implements:[w,j],initializePost:function(){this.pos=false;this.pressed=false},onMouseWheel:function(C,B,z){if(!this.config.zooming){return}d.event.stop(d.event.get(C,B));var D=this.config.zooming/1000,A=1+z*D;this.canvas.scale(A,A)},onMouseDown:function(E,D,C){if(!this.config.panning){return}if(this.config.panning=="avoid nodes"&&C.getNode()){return}this.pressed=true;this.pos=C.getPos();var B=this.canvas,A=B.translateOffsetX,z=B.translateOffsetY,G=B.scaleOffsetX,F=B.scaleOffsetY;this.pos.x*=G;this.pos.x+=A;this.pos.y*=F;this.pos.y+=z},onMouseMove:function(E,D,G){if(!this.config.panning){return}if(!this.pressed){return}if(this.config.panning=="avoid nodes"&&G.getNode()){return}var C=this.pos,F=G.getPos(),A=this.canvas,B=A.translateOffsetX,z=A.translateOffsetY,K=A.scaleOffsetX,I=A.scaleOffsetY;F.x*=K;F.y*=I;F.x+=B;F.y+=z;var J=F.x-C.x,H=F.y-C.y;this.pos=F;this.canvas.translate(J*1/K,H*1/I)},onMouseUp:function(C,B,A,z){if(!this.config.panning){return}this.pressed=false}});var n;(function(){var z=typeof HTMLCanvasElement,B=(z=="object"||z=="function");function A(C,D){var E=document.createElement(C);for(var F in D){if(typeof D[F]=="object"){d.extend(E[F],D[F])}else{E[F]=D[F]}}if(C=="canvas"&&!B&&G_vmlCanvasManager){E=G_vmlCanvasManager.initElement(document.body.appendChild(E))}return E}$jit.Canvas=n=new t({canvases:[],pos:false,element:false,labelContainer:false,translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(N,H){this.viz=N;this.opt=H;var E=d.type(H.injectInto)=="string"?H.injectInto:H.injectInto.id,F=E+"-label",C=d(E),G=H.width||C.offsetWidth,O=H.height||C.offsetHeight;this.id=E;var I={injectInto:E,width:G,height:O};this.element=A("div",{id:E+"-canvaswidget",style:{position:"relative",width:G+"px",height:O+"px"}});this.labelContainer=this.createLabelContainer(H.Label.type,F,I);this.canvases.push(new n.Base({config:d.extend({idSuffix:"-canvas"},I),plot:function(P){N.fx.plot()},resize:function(){N.refresh()}}));var J=H.background;if(J){var M=new n.Background[J.type](N,d.extend(J,I));this.canvases.push(new n.Base(M))}var L=this.canvases.length;while(L--){this.element.appendChild(this.canvases[L].canvas);if(L>0){this.canvases[L].plot()}}this.element.appendChild(this.labelContainer);C.appendChild(this.element);var D=null,K=this;d.addEvent(window,"scroll",function(){clearTimeout(D);D=setTimeout(function(){K.getPos(true)},500)})},getCtx:function(C){return this.canvases[C||0].getCtx()},getConfig:function(){return this.opt},getElement:function(){return this.element},getSize:function(C){return this.canvases[C||0].getSize()},resize:function(G,C){this.getPos(true);this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;for(var E=0,D=this.canvases.length;E<D;E++){this.canvases[E].resize(G,C)}var F=this.element.style;F.width=G+"px";F.height=C+"px";if(this.labelContainer){this.labelContainer.style.width=G+"px"}},translate:function(C,G,F){this.translateOffsetX+=C*this.scaleOffsetX;this.translateOffsetY+=G*this.scaleOffsetY;for(var E=0,D=this.canvases.length;E<D;E++){this.canvases[E].translate(C,G,F)}},scale:function(H,E,F){var I=this.scaleOffsetX*H,G=this.scaleOffsetY*E;var K=this.translateOffsetX*(H-1)/I,J=this.translateOffsetY*(E-1)/G;this.scaleOffsetX=I;this.scaleOffsetY=G;for(var D=0,C=this.canvases.length;D<C;D++){this.canvases[D].scale(H,E,true)}this.translate(K,J,false)},getPos:function(C){if(C||!this.pos){return this.pos=d.getPos(this.getElement())}return this.pos},clear:function(C){this.canvases[C||0].clear()},path:function(D,E){var C=this.canvases[0].getCtx();C.beginPath();E(C);C[D]();C.closePath()},createLabelContainer:function(E,I,H){var G="http://www.w3.org/2000/svg";if(E=="HTML"||E=="Native"){return A("div",{id:I,style:{overflow:"visible",position:"absolute",top:0,left:0,width:H.width+"px",height:0}})}else{if(E=="SVG"){var F=document.createElementNS(G,"svg:svg");F.setAttribute("width",H.width);F.setAttribute("height",H.height);var D=F.style;D.position="absolute";D.left=D.top="0px";var C=document.createElementNS(G,"svg:g");C.setAttribute("width",H.width);C.setAttribute("height",H.height);C.setAttribute("x",0);C.setAttribute("y",0);C.setAttribute("id",I);F.appendChild(C);return F}}}});n.Base=new t({translateOffsetX:0,translateOffsetY:0,scaleOffsetX:1,scaleOffsetY:1,initialize:function(C){this.viz=C;this.opt=C.config;this.size=false;this.createCanvas();this.translateToCenter()},createCanvas:function(){var D=this.opt,E=D.width,C=D.height;this.canvas=A("canvas",{id:D.injectInto+D.idSuffix,width:E,height:C,style:{position:"absolute",top:0,left:0,width:E+"px",height:C+"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 C=this.canvas;return this.size={width:C.width,height:C.height}},translateToCenter:function(F){var D=this.getSize(),E=F?(D.width-F.width-this.translateOffsetX*2):D.width;height=F?(D.height-F.height-this.translateOffsetY*2):D.height;var C=this.getCtx();F&&C.scale(1/this.scaleOffsetX,1/this.scaleOffsetY);C.translate(E/2,height/2)},resize:function(F,C){var E=this.getSize(),D=this.canvas,G=D.style;this.size=false;D.width=F;D.height=C;G.width=F+"px";G.height=C+"px";if(!B){this.translateToCenter(E)}else{this.translateToCenter()}this.translateOffsetX=this.translateOffsetY=0;this.scaleOffsetX=this.scaleOffsetY=1;this.clear();this.viz.resize(F,C,this)},translate:function(C,G,D){var F=this.scaleOffsetX,E=this.scaleOffsetY;this.translateOffsetX+=C*F;this.translateOffsetY+=G*E;this.getCtx().translate(C,G);!D&&this.plot()},scale:function(C,E,D){this.scaleOffsetX*=C;this.scaleOffsetY*=E;this.getCtx().scale(C,E);!D&&this.plot()},clear:function(){var E=this.getSize(),D=this.translateOffsetX,C=this.translateOffsetY,G=this.scaleOffsetX,F=this.scaleOffsetY;this.getCtx().clearRect((-E.width/2-D)*1/G,(-E.height/2-C)*1/F,E.width*1/G,E.height*1/F)},plot:function(){this.clear();this.viz.plot(this)}});n.Background={};n.Background.Circles=new t({initialize:function(C,D){this.viz=C;this.config=d.merge({idSuffix:"-bkcanvas",levelDistance:100,numberOfCircles:6,CanvasStyles:{},offset:0},D)},resize:function(D,C,E){this.plot(E)},plot:function(C){var D=C.canvas,J=C.getCtx(),G=this.config,I=G.CanvasStyles;for(var K in I){J[K]=I[K]}var E=G.numberOfCircles,H=G.levelDistance;for(var F=1;F<=E;F++){J.beginPath();J.arc(0,0,H*F,0,2*Math.PI,false);J.stroke();J.closePath()}}})})();var c=function(A,z){this.theta=A;this.rho=z};$jit.Polar=c;c.prototype={getc:function(z){return this.toComplex(z)},getp:function(){return this},set:function(z){z=z.getp();this.theta=z.theta;this.rho=z.rho},setc:function(z,A){this.rho=Math.sqrt(z*z+A*A);this.theta=Math.atan2(A,z);if(this.theta<0){this.theta+=Math.PI*2}},setp:function(A,z){this.theta=A;this.rho=z},clone:function(){return new c(this.theta,this.rho)},toComplex:function(B){var z=Math.cos(this.theta)*this.rho;var A=Math.sin(this.theta)*this.rho;if(B){return{x:z,y:A}}return new s(z,A)},add:function(z){return new c(this.theta+z.theta,this.rho+z.rho)},scale:function(z){return new c(this.theta,this.rho*z)},equals:function(z){return this.theta==z.theta&&this.rho==z.rho},$add:function(z){this.theta=this.theta+z.theta;this.rho+=z.rho;return this},$madd:function(z){this.theta=(this.theta+z.theta)%(Math.PI*2);this.rho+=z.rho;return this},$scale:function(z){this.rho*=z;return this},interpolate:function(B,I){var C=Math.PI,F=C*2;var A=function(K){var J=(K<0)?(K%F)+F:K%F;return J};var E=this.theta,H=B.theta;var D,G=Math.abs(E-H);if(G==C){if(E>H){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H))*I))}}else{if(G>=C){if(E>H){D=A((H+((E-F)-H)*I))}else{D=A((H-F+(E-(H-F))*I))}}else{D=A((H+(E-H)*I))}}var z=(this.rho-B.rho)*I+B.rho;return{theta:D,rho:z}}};var m=function(A,z){return new c(A,z)};c.KER=m(0,0);var s=function(z,A){this.x=z;this.y=A};$jit.Complex=s;s.prototype={getc:function(){return this},getp:function(z){return this.toPolar(z)},set:function(z){z=z.getc(true);this.x=z.x;this.y=z.y},setc:function(z,A){this.x=z;this.y=A},setp:function(A,z){this.x=Math.cos(A)*z;this.y=Math.sin(A)*z},clone:function(){return new s(this.x,this.y)},toPolar:function(B){var z=this.norm();var A=Math.atan2(this.y,this.x);if(A<0){A+=Math.PI*2}if(B){return{theta:A,rho:z}}return new c(A,z)},norm:function(){return Math.sqrt(this.squaredNorm())},squaredNorm:function(){return this.x*this.x+this.y*this.y},add:function(z){return new s(this.x+z.x,this.y+z.y)},prod:function(z){return new s(this.x*z.x-this.y*z.y,this.y*z.x+this.x*z.y)},conjugate:function(){return new s(this.x,-this.y)},scale:function(z){return new s(this.x*z,this.y*z)},equals:function(z){return this.x==z.x&&this.y==z.y},$add:function(z){this.x+=z.x;this.y+=z.y;return this},$prod:function(B){var z=this.x,A=this.y;this.x=z*B.x-A*B.y;this.y=A*B.x+z*B.y;return this},$conjugate:function(){this.y=-this.y;return this},$scale:function(z){this.x*=z;this.y*=z;return this},$div:function(C){var z=this.x,B=this.y;var A=C.squaredNorm();this.x=z*C.x+B*C.y;this.y=B*C.x-z*C.y;return this.$scale(1/A)}};var u=function(A,z){return new s(A,z)};s.KER=u(0,0);$jit.Graph=new t({initialize:function(B,A,z,F){var D={complex:false,Node:{}};this.Node=A;this.Edge=z;this.Label=F;this.opt=d.merge(D,B||{});this.nodes={};this.edges={};var C=this;this.nodeList={};for(var E in l){C.nodeList[E]=(function(G){return function(){var H=Array.prototype.slice.call(arguments);C.eachNode(function(I){I[G].apply(I,H)})}})(E)}},getNode:function(z){if(this.hasNode(z)){return this.nodes[z]}return false},getByName:function(z){for(var B in this.nodes){var A=this.nodes[B];if(A.name==z){return A}}return false},getAdjacence:function(A,z){if(A in this.edges){return this.edges[A][z]}return false},addNode:function(A){if(!this.nodes[A.id]){var z=this.edges[A.id]={};this.nodes[A.id]=new f.Node(d.extend({id:A.id,name:A.name,data:A.data||{},adjacencies:z},this.opt.Node),this.opt.complex,this.Node,this.Edge,this.Label)}return this.nodes[A.id]},addAdjacence:function(C,B,A){if(!this.hasNode(C.id)){this.addNode(C)}if(!this.hasNode(B.id)){this.addNode(B)}C=this.nodes[C.id];B=this.nodes[B.id];if(!C.adjacentTo(B)){var D=this.edges[C.id]=this.edges[C.id]||{};var z=this.edges[B.id]=this.edges[B.id]||{};D[B.id]=z[C.id]=new f.Adjacence(C,B,A,this.Edge,this.Label);return D[B.id]}return this.edges[C.id][B.id]},removeNode:function(B){if(this.hasNode(B)){delete this.nodes[B];var A=this.edges[B];for(var z in A){delete this.edges[z][B]}delete this.edges[B]}},removeAdjacence:function(A,z){delete this.edges[A][z];delete this.edges[z][A]},hasNode:function(z){return z in this.nodes},empty:function(){this.nodes={};this.edges={}}});var f=$jit.Graph;var l;(function(){var z=function(G,I,D,F,H){var E;D=D||"current";G="$"+(G?G+"-":"");if(D=="current"){E=this.data}else{if(D=="start"){E=this.startData}else{if(D=="end"){E=this.endData}}}var C=G+I;if(F){return E[C]}if(!this.Config.overridable){return H[I]||0}return(C in E)?E[C]:((C in this.data)?this.data[C]:(H[I]||0))};var B=function(F,G,E,C){C=C||"current";F="$"+(F?F+"-":"");var D;if(C=="current"){D=this.data}else{if(C=="start"){D=this.startData}else{if(C=="end"){D=this.endData}}}D[F+G]=E};var A=function(E,C){E="$"+(E?E+"-":"");var D=this;d.each(C,function(G){var F=E+G;delete D.data[F];delete D.endData[F];delete D.startData[F]})};l={getData:function(E,C,D){return z.call(this,"",E,C,D,this.Config)},setData:function(E,D,C){B.call(this,"",E,D,C)},setDataset:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setData(C,H[E],F[E])}}},removeData:function(){A.call(this,"",Array.prototype.slice.call(arguments))},getCanvasStyle:function(E,C,D){return z.call(this,"canvas",E,C,D,this.Config.CanvasStyles)},setCanvasStyle:function(E,D,C){B.call(this,"canvas",E,D,C)},setCanvasStyles:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setCanvasStyle(C,H[E],F[E])}}},removeCanvasStyle:function(){A.call(this,"canvas",Array.prototype.slice.call(arguments))},getLabelData:function(E,C,D){return z.call(this,"label",E,C,D,this.Label)},setLabelData:function(E,D,C){B.call(this,"label",E,D,C)},setLabelDataset:function(F,G){F=d.splat(F);for(var C in G){for(var E=0,H=d.splat(G[C]),D=F.length;E<D;E++){this.setLabelData(C,H[E],F[E])}}},removeLabelData:function(){A.call(this,"label",Array.prototype.slice.call(arguments))}}})();f.Node=new t({initialize:function(B,D,A,z,E){var C={id:"",name:"",data:{},startData:{},endData:{},adjacencies:{},selected:false,drawn:false,exist:false,angleSpan:{begin:0,end:0},pos:(D&&u(0,0))||m(0,0),startPos:(D&&u(0,0))||m(0,0),endPos:(D&&u(0,0))||m(0,0)};d.extend(this,d.extend(C,B));this.Config=this.Node=A;this.Edge=z;this.Label=E},adjacentTo:function(z){return z.id in this.adjacencies},getAdjacency:function(z){return this.adjacencies[z]},getPos:function(z){z=z||"current";if(z=="current"){return this.pos}else{if(z=="end"){return this.endPos}else{if(z=="start"){return this.startPos}}}},setPos:function(A,z){z=z||"current";var B;if(z=="current"){B=this.pos}else{if(z=="end"){B=this.endPos}else{if(z=="start"){B=this.startPos}}}B.set(A)}});f.Node.implement(l);f.Adjacence=new t({initialize:function(A,D,B,z,C){this.nodeFrom=A;this.nodeTo=D;this.data=B||{};this.startData={};this.endData={};this.Config=this.Edge=z;this.Label=C}});f.Adjacence.implement(l);f.Util={filter:function(A){if(!A||!(d.type(A)=="string")){return function(){return true}}var z=A.split(" ");return function(C){for(var B=0;B<z.length;B++){if(C[z[B]]){return false}}return true}},getNode:function(z,A){return z.nodes[A]},eachNode:function(D,C,z){var B=this.filter(z);for(var A in D.nodes){if(B(D.nodes[A])){C(D.nodes[A])}}},eachAdjacency:function(E,F,A){var B=E.adjacencies,D=this.filter(A);for(var G in B){var z=B[G];if(D(z)){if(z.nodeFrom!=E){var C=z.nodeFrom;z.nodeFrom=z.nodeTo;z.nodeTo=C}F(z,G)}}},computeLevels:function(F,G,C,B){C=C||0;var D=this.filter(B);this.eachNode(F,function(H){H._flag=false;H._depth=-1},B);var A=F.getNode(G);A._depth=C;var z=[A];while(z.length!=0){var E=z.pop();E._flag=true;this.eachAdjacency(E,function(H){var I=H.nodeTo;if(I._flag==false&&D(I)){if(I._depth<0){I._depth=E._depth+1+C}z.unshift(I)}},B)}},eachBFS:function(E,F,D,A){var B=this.filter(A);this.clean(E);var z=[E.getNode(F)];while(z.length!=0){var C=z.pop();C._flag=true;D(C,C._depth);this.eachAdjacency(C,function(G){var H=G.nodeTo;if(H._flag==false&&B(H)){H._flag=true;z.unshift(H)}},A)}},eachLevel:function(D,H,A,E,C){var G=D._depth,z=this.filter(C),F=this;A=A===false?Number.MAX_VALUE-G:A;(function B(K,I,J){var L=K._depth;if(L>=I&&L<=J&&z(K)){E(K,L)}if(L<J){F.eachAdjacency(K,function(M){var N=M.nodeTo;if(N._depth>L){B(N,I,J)}})}})(D,H+G,A+G)},eachSubgraph:function(A,B,z){this.eachLevel(A,0,false,B,z)},eachSubnode:function(A,B,z){this.eachLevel(A,1,1,B,z)},anySubnode:function(C,B,A){var z=false;B=B||d.lambda(true);var D=d.type(B)=="string"?function(E){return E[B]}:B;this.eachSubnode(C,function(E){if(D(E)){z=true}},A);return z},getSubnodes:function(E,F,z){var B=[],D=this;F=F||0;var C,A;if(d.type(F)=="array"){C=F[0];A=F[1]}else{C=F;A=Number.MAX_VALUE-E._depth}this.eachLevel(E,C,A,function(G){B.push(G)},z);return B},getParents:function(A){var z=[];this.eachAdjacency(A,function(B){var C=B.nodeTo;if(C._depth<A._depth){z.push(C)}});return z},isDescendantOf:function(C,D){if(C.id==D){return true}var B=this.getParents(C),z=false;for(var A=0;!z&&A<B.length;A++){z=z||this.isDescendantOf(B[A],D)}return z},clean:function(z){this.eachNode(z,function(A){A._flag=false})},getClosestNodeToOrigin:function(A,B,z){return this.getClosestNodeToPos(A,c.KER,B,z)},getClosestNodeToPos:function(B,E,D,z){var A=null;D=D||"current";E=E&&E.getc(true)||s.KER;var C=function(G,F){var I=G.x-F.x,H=G.y-F.y;return I*I+H*H};this.eachNode(B,function(F){A=(A==null||C(F.getPos(D).getc(true),E)<C(A.getPos(D).getc(true),E))?F:A},z);return A}};d.each(["getNode","eachNode","computeLevels","eachBFS","clean","getClosestNodeToPos","getClosestNodeToOrigin"],function(z){f.prototype[z]=function(){return f.Util[z].apply(f.Util,[this].concat(Array.prototype.slice.call(arguments)))}});d.each(["eachAdjacency","eachLevel","eachSubgraph","eachSubnode","anySubnode","getSubnodes","getParents","isDescendantOf"],function(z){f.Node.prototype[z]=function(){return f.Util[z].apply(f.Util,[this].concat(Array.prototype.slice.call(arguments)))}});f.Op={options:{type:"nothing",duration:2000,hideLabels:true,fps:30},removeNode:function(E,C){var z=this.viz;var A=d.merge(this.options,z.controller,C);var G=d.splat(E);var B,D,F;switch(A.type){case"nothing":for(B=0;B<G.length;B++){z.graph.removeNode(G[B])}break;case"replot":this.removeNode(G,{type:"nothing"});z.labels.clearLabels();z.refresh(true);break;case"fade:seq":case"fade":D=this;for(B=0;B<G.length;B++){F=z.graph.getNode(G[B]);F.setData("alpha",0,"end")}z.fx.animate(d.merge(A,{modes:["node-property:alpha"],onComplete:function(){D.removeNode(G,{type:"nothing"});z.labels.clearLabels();z.reposition();z.fx.animate(d.merge(A,{modes:["linear"]}))}}));break;case"fade:con":D=this;for(B=0;B<G.length;B++){F=z.graph.getNode(G[B]);F.setData("alpha",0,"end");F.ignore=true}z.reposition();z.fx.animate(d.merge(A,{modes:["node-property:alpha","linear"],onComplete:function(){D.removeNode(G,{type:"nothing"})}}));break;case"iter":D=this;z.fx.sequence({condition:function(){return G.length!=0},step:function(){D.removeNode(G.shift(),{type:"nothing"});z.labels.clearLabels()},onComplete:function(){A.onComplete()},duration:Math.ceil(A.duration/G.length)});break;default:this.doError()}},removeEdge:function(G,E){var z=this.viz;var C=d.merge(this.options,z.controller,E);var B=(d.type(G[0])=="string")?[G]:G;var D,F,A;switch(C.type){case"nothing":for(D=0;D<B.length;D++){z.graph.removeAdjacence(B[D][0],B[D][1])}break;case"replot":this.removeEdge(B,{type:"nothing"});z.refresh(true);break;case"fade:seq":case"fade":F=this;for(D=0;D<B.length;D++){A=z.graph.getAdjacence(B[D][0],B[D][1]);if(A){A.setData("alpha",0,"end")}}z.fx.animate(d.merge(C,{modes:["edge-property:alpha"],onComplete:function(){F.removeEdge(B,{type:"nothing"});z.reposition();z.fx.animate(d.merge(C,{modes:["linear"]}))}}));break;case"fade:con":F=this;for(D=0;D<B.length;D++){A=z.graph.getAdjacence(B[D][0],B[D][1]);if(A){A.setData("alpha",0,"end");A.ignore=true}}z.reposition();z.fx.animate(d.merge(C,{modes:["edge-property:alpha","linear"],onComplete:function(){F.removeEdge(B,{type:"nothing"})}}));break;case"iter":F=this;z.fx.sequence({condition:function(){return B.length!=0},step:function(){F.removeEdge(B.shift(),{type:"nothing"});z.labels.clearLabels()},onComplete:function(){C.onComplete()},duration:Math.ceil(C.duration/B.length)});break;default:this.doError()}},sum:function(D,C){var z=this.viz;var B=d.merge(this.options,z.controller,C),A=z.root;var F;z.root=C.id||z.root;switch(B.type){case"nothing":F=z.construct(D);F.eachNode(function(H){H.eachAdjacency(function(I){z.graph.addAdjacence(I.nodeFrom,I.nodeTo,I.data)})});break;case"replot":z.refresh(true);this.sum(D,{type:"nothing"});z.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;F=z.construct(D);var G=this.preprocessSum(F);var E=!G?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];z.reposition();if(B.type!="fade:con"){z.fx.animate(d.merge(B,{modes:["linear"],onComplete:function(){z.fx.animate(d.merge(B,{modes:E,onComplete:function(){B.onComplete()}}))}}))}else{z.graph.eachNode(function(H){if(H.id!=A&&H.pos.getp().equals(c.KER)){H.pos.set(H.endPos);H.startPos.set(H.endPos)}});z.fx.animate(d.merge(B,{modes:["linear"].concat(E)}))}break;default:this.doError()}},morph:function(H,A,C){var E=this.viz;var I=d.merge(this.options,E.controller,A),D=E.root;var F;E.root=A.id||E.root;switch(I.type){case"nothing":F=E.construct(H);F.eachNode(function(L){var K=E.graph.hasNode(L.id);L.eachAdjacency(function(P){var O=!!E.graph.getAdjacence(P.nodeFrom.id,P.nodeTo.id);E.graph.addAdjacence(P.nodeFrom,P.nodeTo,P.data);if(O){var N=E.graph.getAdjacence(P.nodeFrom.id,P.nodeTo.id);for(var Q in (P.data||{})){N.data[Q]=P.data[Q]}}});if(K){var J=E.graph.getNode(L.id);for(var M in (L.data||{})){J.data[M]=L.data[M]}}});E.graph.eachNode(function(J){J.eachAdjacency(function(K){if(!F.getAdjacence(K.nodeFrom.id,K.nodeTo.id)){E.graph.removeAdjacence(K.nodeFrom.id,K.nodeTo.id)}});if(!F.hasNode(J.id)){E.graph.removeNode(J.id)}});break;case"replot":E.labels.clearLabels(true);this.morph(H,{type:"nothing"});E.refresh(true);E.refresh(true);break;case"fade:seq":case"fade":case"fade:con":that=this;F=E.construct(H);var G=C&&("node-property" in C)&&d.map(d.splat(C["node-property"]),function(J){return"$"+J});E.graph.eachNode(function(K){var L=F.getNode(K.id);if(!L){K.setData("alpha",1);K.setData("alpha",1,"start");K.setData("alpha",0,"end");K.ignore=true}else{var J=L.data;for(var M in J){if(G&&(M in G)){K.endData[M]=J[M]}else{K.data[M]=J[M]}}}});E.graph.eachNode(function(J){if(J.ignore){return}J.eachAdjacency(function(K){if(K.nodeFrom.ignore||K.nodeTo.ignore){return}var L=F.getNode(K.nodeFrom.id);var M=F.getNode(K.nodeTo.id);if(!L.adjacentTo(M)){var K=E.graph.getAdjacence(L.id,M.id);z=true;K.setData("alpha",1);K.setData("alpha",1,"start");K.setData("alpha",0,"end")}})});var z=this.preprocessSum(F);var B=!z?["node-property:alpha"]:["node-property:alpha","edge-property:alpha"];B[0]=B[0]+((C&&("node-property" in C))?d.splat(C["node-property"]).join(":"):"");B[1]=(B[1]||"edge-property:alpha")+((C&&("edge-property" in C))?d.splat(C["edge-property"]).join(":"):"");if(C&&("label-property" in C)){B.push("label-property"+d.splat(C["label-property"]).join(":"))}E.reposition();E.graph.eachNode(function(J){if(J.id!=D&&J.pos.getp().equals(c.KER)){J.pos.set(J.endPos);J.startPos.set(J.endPos)}});E.fx.animate(d.merge(I,{modes:["polar"].concat(B),onComplete:function(){E.graph.eachNode(function(J){if(J.ignore){E.graph.removeNode(J.id)}});E.graph.eachNode(function(J){J.eachAdjacency(function(K){if(K.ignore){E.graph.removeAdjacence(K.nodeFrom.id,K.nodeTo.id)}})});I.onComplete()}}));break;default:}},contract:function(B,A){var z=this.viz;if(B.collapsed||!B.anySubnode(d.lambda(true))){return}A=d.merge(this.options,z.config,A||{},{modes:["node-property:alpha:span","linear"]});B.collapsed=true;(function C(D){D.eachSubnode(function(E){E.ignore=true;E.setData("alpha",0,A.type=="animate"?"end":"current");C(E)})})(B);if(A.type=="animate"){z.compute("end");if(z.rotated){z.rotate(z.rotated,"none",{property:"end"})}(function C(D){D.eachSubnode(function(E){E.setPos(B.getPos("end"),"end");C(E)})})(B);z.fx.animate(A)}else{if(A.type=="replot"){z.refresh()}}},expand:function(B,A){if(!("collapsed" in B)){return}var z=this.viz;A=d.merge(this.options,z.config,A||{},{modes:["node-property:alpha:span","linear"]});delete B.collapsed;(function C(D){D.eachSubnode(function(E){delete E.ignore;E.setData("alpha",1,A.type=="animate"?"end":"current");C(E)})})(B);if(A.type=="animate"){z.compute("end");if(z.rotated){z.rotate(z.rotated,"none",{property:"end"})}z.fx.animate(A)}else{if(A.type=="replot"){z.refresh()}}},preprocessSum:function(A){var z=this.viz;A.eachNode(function(C){if(!z.graph.hasNode(C.id)){z.graph.addNode(C);var D=z.graph.getNode(C.id);D.setData("alpha",0);D.setData("alpha",0,"start");D.setData("alpha",1,"end")}});var B=false;A.eachNode(function(C){C.eachAdjacency(function(D){var E=z.graph.getNode(D.nodeFrom.id);var F=z.graph.getNode(D.nodeTo.id);if(!E.adjacentTo(F)){var D=z.graph.addAdjacence(E,F,D.data);if(E.startAlpha==E.endAlpha&&F.startAlpha==F.endAlpha){B=true;D.setData("alpha",0);D.setData("alpha",0,"start");D.setData("alpha",1,"end")}}})});return B}};var a={none:{render:d.empty,contains:d.lambda(false)},circle:{render:function(C,D,z,B){var A=B.getCtx();A.beginPath();A.arc(D.x,D.y,z,0,Math.PI*2,true);A.closePath();A[C]()},contains:function(E,D,z){var B=E.x-D.x,A=E.y-D.y,C=B*B+A*A;return C<=z*z}},ellipse:{render:function(D,E,C,z,B){var A=B.getCtx();z/=2;C/=2;A.save();A.scale(C/z,z/C);A.beginPath();A.arc(E.x*(z/C),E.y*(C/z),z,0,Math.PI*2,true);A.closePath();A[D]();A.restore()},contains:function(G,F,C,z){C/=2;z/=2;var E=(C+z)/2,B=G.x-F.x,A=G.y-F.y,D=B*B+A*A;return D<=E*E}},square:{render:function(A,C,B,z){z.getCtx()[A+"Rect"](C.x-B,C.y-B,2*B,2*B)},contains:function(B,A,z){return Math.abs(A.x-B.x)<=z&&Math.abs(A.y-B.y)<=z}},rectangle:{render:function(C,D,B,z,A){A.getCtx()[C+"Rect"](D.x-B/2,D.y-z/2,B,z)},contains:function(C,B,A,z){return Math.abs(B.x-C.x)<=A/2&&Math.abs(B.y-C.y)<=z/2}},triangle:{render:function(F,G,C,z){var J=z.getCtx(),B=G.x,A=G.y-C,I=B-C,H=G.y+C,E=B+C,D=H;J.beginPath();J.moveTo(B,A);J.lineTo(I,H);J.lineTo(E,D);J.closePath();J[F]()},contains:function(B,A,z){return a.circle.contains(B,A,z)}},star:{render:function(D,F,E,A){var z=A.getCtx(),C=Math.PI/5;z.save();z.translate(F.x,F.y);z.beginPath();z.moveTo(E,0);for(var B=0;B<9;B++){z.rotate(C);if(B%2==0){z.lineTo((E/0.525731)*0.200811,0)}else{z.lineTo(E,0)}}z.closePath();z[D]();z.restore()},contains:function(B,A,z){return a.circle.contains(B,A,z)}}};var o={line:{render:function(C,B,A){var z=A.getCtx();z.beginPath();z.moveTo(C.x,C.y);z.lineTo(B.x,B.y);z.stroke()},contains:function(J,B,E,H){var C=Math.min,F=Math.max,A=C(J.x,B.x),I=F(J.x,B.x),z=C(J.y,B.y),G=F(J.y,B.y);if(E.x>=A&&E.x<=I&&E.y>=z&&E.y<=G){if(Math.abs(B.x-J.x)<=H){return true}var D=(B.y-J.y)/(B.x-J.x)*(E.x-J.x)+J.y;return Math.abs(D-E.y)<=H}return false}},arrow:{render:function(I,J,C,A,z){var K=z.getCtx();if(A){var B=I;I=J;J=B}var F=new s(J.x-I.x,J.y-I.y);F.$scale(C/F.norm());var D=new s(J.x-F.x,J.y-F.y),E=new s(-F.y/2,F.x/2),H=D.add(E),G=D.$add(E.$scale(-1));K.beginPath();K.moveTo(I.x,I.y);K.lineTo(J.x,J.y);K.stroke();K.beginPath();K.moveTo(H.x,H.y);K.lineTo(G.x,G.y);K.lineTo(J.x,J.y);K.closePath();K.fill()},contains:function(A,z,C,B){return o.line.contains(A,z,C,B)}},hyperline:{render:function(G,H,z,B){var I=B.getCtx();var C=D(G,H);if(C.a>1000||C.b>1000||C.ratio<0){I.beginPath();I.moveTo(G.x*z,G.y*z);I.lineTo(H.x*z,H.y*z);I.stroke()}else{var F=Math.atan2(H.y-C.y,H.x-C.x);var E=Math.atan2(G.y-C.y,G.x-C.x);var A=A(F,E);I.beginPath();I.arc(C.x*z,C.y*z,C.ratio*z,F,E,A);I.stroke()}function D(V,U){var N=(V.x*U.y-V.y*U.x),J=N;var M=V.squaredNorm(),L=U.squaredNorm();if(N==0){return{x:0,y:0,ratio:-1}}var T=(V.y*L-U.y*M+V.y-U.y)/N;var R=(U.x*M-V.x*L+U.x-V.x)/J;var S=-T/2;var Q=-R/2;var P=(T*T+R*R)/4-1;if(P<0){return{x:0,y:0,ratio:-1}}var O=Math.sqrt(P);var K={x:S,y:Q,ratio:O>1000?-1:O,a:T,b:R};return K}function A(J,K){return(J<K)?((J+Math.PI>K)?false:true):((K+Math.PI>J)?true:false)}},contains:d.lambda(false)}};f.Plot={nodeHelper:a,edgeHelper:o,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(B,A,z){return B+(A-B)*z},moebius:function(E,D,G,A){var C=A.scale(-G);if(C.norm()<1){var z=C.x,F=C.y;var B=E.startPos.getc().moebiusTransformation(C);E.pos.setc(B.x,B.y);C.x=z;C.y=F}},linear:function(A,z,D){var C=A.startPos.getc(true);var B=A.endPos.getc(true);A.pos.setc(this.compute(C.x,B.x,D),this.compute(C.y,B.y,D))},polar:function(B,A,E){var D=B.startPos.getp(true);var C=B.endPos.getp();var z=C.interpolate(D,E);B.pos.setp(z.theta,z.rho)},number:function(A,F,E,z,D){var C=A[z](F,"start");var B=A[z](F,"end");A[D](F,this.compute(C,B,E))},color:function(B,z,H,E,C){var F=d.hexToRgb(B[E](z,"start"));var G=d.hexToRgb(B[E](z,"end"));var D=this.compute;var A=d.rgbToHex([parseInt(D(F[0],G[0],H)),parseInt(D(F[1],G[1],H)),parseInt(D(F[2],G[2],H))]);B[C](z,A)},"array-number":function(C,B,M,J,E){var K=C[J](B,"start"),L=C[J](B,"end"),N=[];for(var H=0,D=K.length;H<D;H++){var A=K[H],z=L[H];if(A.length){for(var G=0,I=A.length,F=[];G<I;G++){F.push(this.compute(A[G],z[G],M))}N.push(F)}else{N.push(this.compute(A,z,M))}}C[E](B,N)},node:function(A,F,H,z,G,B){z=this[z];if(F){var E=F.length;for(var C=0;C<E;C++){var D=F[C];this[z[D]](A,D,H,G,B)}}else{for(var D in z){this[z[D]](A,D,H,G,B)}}},edge:function(B,A,G,C,z,F){var E=B.adjacencies;for(var D in E){this["node"](E[D],A,G,C,z,F)}},"node-property":function(A,z,B){this["node"](A,z,B,"map","getData","setData")},"edge-property":function(A,z,B){this["edge"](A,z,B,"map","getData","setData")},"label-property":function(A,z,B){this["node"](A,z,B,"label","getLabelData","setLabelData")},"node-style":function(A,z,B){this["node"](A,z,B,"canvas","getCanvasStyle","setCanvasStyle")},"edge-style":function(A,z,B){this["edge"](A,z,B,"canvas","getCanvasStyle","setCanvasStyle")}},sequence:function(A){var B=this;A=d.merge({condition:d.lambda(false),step:d.empty,onComplete:d.empty,duration:200},A||{});var z=setInterval(function(){if(A.condition()){A.step()}else{clearInterval(z);A.onComplete()}B.viz.refresh(true)},A.duration)},prepare:function(F){var E=this.viz.graph,C={"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 A={};if(d.type(F)=="array"){for(var D=0,z=F.length;D<z;D++){var B=F[D].split(":");A[B.shift()]=B}}else{for(var G in F){if(G=="position"){A[F.position]=[]}else{A[G]=d.splat(F[G])}}}E.eachNode(function(H){H.startPos.set(H.pos);d.each(["node-property","node-style"],function(K){if(K in A){var L=A[K];for(var J=0,I=L.length;J<I;J++){H[C[K].setter](L[J],H[C[K].getter](L[J]),"start")}}});d.each(["edge-property","edge-style"],function(I){if(I in A){var J=A[I];H.eachAdjacency(function(L){for(var M=0,K=J.length;M<K;M++){L[C[I].setter](J[M],L[C[I].getter](J[M]),"start")}})}})});return A},animate:function(C,B){C=d.merge(this.viz.config,C||{});var D=this,A=this.viz,F=A.graph,G=this.Interpolator,E=C.type==="nodefx"?this.nodeFxAnimation:this.animation;var z=this.prepare(C.modes);if(C.hideLabels){this.labels.hideLabels(true)}E.setOptions(d.merge(C,{$animating:false,compute:function(H){F.eachNode(function(I){for(var J in z){G[J](I,z[J],H,B)}});D.plot(C,this.$animating,H);this.$animating=true},complete:function(){if(C.hideLabels){D.labels.hideLabels(false)}D.plot(C);C.onComplete();C.onAfterCompute()}})).start()},nodeFx:function(B){var G=this.viz,H=G.graph,E=this.nodeFxAnimation,I=d.merge(this.viz.config,{elements:{id:false,properties:{}},reposition:false});B=d.merge(I,B||{},{onBeforeCompute:d.empty,onAfterCompute:d.empty});E.stopTimer();var F=B.elements.properties;if(!B.elements.id){H.eachNode(function(K){for(var J in F){K.setData(J,F[J],"end")}})}else{var z=d.splat(B.elements.id);d.each(z,function(L){var K=H.getNode(L);if(K){for(var J in F){K.setData(J,F[J],"end")}}})}var D=[];for(var A in F){D.push(A)}var C=["node-property:"+D.join(":")];if(B.reposition){C.push("linear");G.compute("end")}this.animate(d.merge(B,{modes:C,type:"nodefx"}))},plot:function(A,J){var H=this.viz,E=H.graph,B=H.canvas,z=H.root,F=this,I=B.getCtx(),D=Math.min,A=A||this.viz.controller;A.clearCanvas&&B.clear();var G=E.getNode(z);if(!G){return}var C=!!G.visited;E.eachNode(function(L){var K=L.getData("alpha");L.eachAdjacency(function(M){var N=M.nodeTo;if(!!N.visited===C&&L.drawn&&N.drawn){!J&&A.onBeforePlotLine(M);I.save();I.globalAlpha=D(K,N.getData("alpha"),M.getData("alpha"));F.plotLine(M,B,J);I.restore();!J&&A.onAfterPlotLine(M)}});I.save();if(L.drawn){!J&&A.onBeforePlotNode(L);F.plotNode(L,B,J);!J&&A.onAfterPlotNode(L)}if(!F.labelsHidden&&A.withLabels){if(L.drawn&&K>=0.95){F.labels.plotLabel(B,L,A)}else{F.labels.hideLabel(L,false)}}I.restore();L.visited=!C})},plotTree:function(D,A,H){var E=this,F=this.viz,B=F.canvas,C=this.config,G=B.getCtx();var z=D.getData("alpha");D.eachSubnode(function(J){if(A.plotSubtree(D,J)&&J.exist&&J.drawn){var I=D.getAdjacency(J.id);!H&&A.onBeforePlotLine(I);G.globalAlpha=Math.min(z,J.getData("alpha"));E.plotLine(I,B,H);!H&&A.onAfterPlotLine(I);E.plotTree(J,A,H)}});if(D.drawn){!H&&A.onBeforePlotNode(D);this.plotNode(D,B,H);!H&&A.onAfterPlotNode(D);if(!A.hideLabels&&A.withLabels&&z>=0.95){this.labels.plotLabel(B,D,A)}else{this.labels.hideLabel(D,false)}}else{this.labels.hideLabel(D,true)}},plotNode:function(B,A,I){var F=B.getData("type"),E=this.node.CanvasStyles;if(F!="none"){var z=B.getData("lineWidth"),D=B.getData("color"),C=B.getData("alpha"),G=A.getCtx();G.lineWidth=z;G.fillStyle=G.strokeStyle=D;G.globalAlpha=C;for(var H in E){G[H]=B.getCanvasStyle(H)}this.nodeTypes[F].render.call(this,B,A,I)}},plotLine:function(E,A,H){var D=E.getData("type"),C=this.edge.CanvasStyles;if(D!="none"){var z=E.getData("lineWidth"),B=E.getData("color"),F=A.getCtx();F.lineWidth=z;F.fillStyle=F.strokeStyle=B;for(var G in C){F[G]=E.getCanvasStyle(G)}this.edgeTypes[D].render.call(this,E,A,H)}}};f.Label={};f.Label.Native=new t({plotLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.font=C.getLabelData("style")+" "+C.getLabelData("size")+"px "+C.getLabelData("family");z.textAlign=C.getLabelData("textAlign");z.fillStyle=z.strokeStyle=C.getLabelData("color");z.textBaseline=C.getLabelData("textBaseline");this.renderLabel(B,C,A)},renderLabel:function(B,C,A){var z=B.getCtx();var D=C.pos.getc(true);z.fillText(C.name,D.x,D.y+C.getData("height")/2)},hideLabel:d.empty,hideLabels:d.empty});f.Label.DOM=new t({labelsHidden:false,labelContainer:false,labels:{},getLabelContainer:function(){return this.labelContainer?this.labelContainer:this.labelContainer=document.getElementById(this.viz.config.labelContainer)},getLabel:function(z){return(z in this.labels&&this.labels[z]!=null)?this.labels[z]:this.labels[z]=document.getElementById(z)},hideLabels:function(A){var z=this.getLabelContainer();if(A){z.style.display="none"}else{z.style.display=""}this.labelsHidden=A},clearLabels:function(z){for(var A in this.labels){if(z||!this.viz.graph.hasNode(A)){this.disposeLabel(A);delete this.labels[A]}}},disposeLabel:function(A){var z=this.getLabel(A);if(z&&z.parentNode){z.parentNode.removeChild(z)}},hideLabel:function(D,z){D=d.splat(D);var A=z?"":"none",B,C=this;d.each(D,function(F){var E=C.getLabel(F.id);if(E){E.style.display=A}})},fitsInCanvas:function(B,z){var A=z.getSize();if(B.x>=A.width||B.x<0||B.y>=A.height||B.y<0){return false}return true}});f.Label.HTML=new t({Implements:f.Label.DOM,plotLabel:function(C,D,B){var E=D.id,z=this.getLabel(E);if(!z&&!(z=document.getElementById(E))){z=document.createElement("div");var A=this.getLabelContainer();z.id=E;z.className="node";z.style.position="absolute";B.onCreateLabel(z,D);A.appendChild(z);this.labels[D.id]=z}this.placeLabel(z,D,B)}});f.Label.SVG=new t({Implements:f.Label.DOM,plotLabel:function(C,E,B){var G=E.id,z=this.getLabel(G);if(!z&&!(z=document.getElementById(G))){var D="http://www.w3.org/2000/svg";z=document.createElementNS(D,"svg:text");var F=document.createElementNS(D,"svg:tspan");z.appendChild(F);var A=this.getLabelContainer();z.setAttribute("id",G);z.setAttribute("class","node");A.appendChild(z);B.onCreateLabel(z,E);this.labels[E.id]=z}this.placeLabel(z,E,B)}});f.Geom=new t({initialize:function(z){this.viz=z;this.config=z.config;this.node=z.config.Node;this.edge=z.config.Edge},translate:function(A,z){z=d.splat(z);this.viz.graph.eachNode(function(B){d.each(z,function(C){B.getPos(C).$add(A)})})},setRightLevelToShow:function(C,z,E){var D=this.getRightLevelToShow(C,z),B=this.viz.labels,A=d.merge({execShow:true,execHide:true,onHide:d.empty,onShow:d.empty},E||{});C.eachLevel(0,this.config.levelsToShow,function(G){var F=G._depth-C._depth;if(F>D){A.onHide(G);if(A.execHide){G.drawn=false;G.exist=false;B.hideLabel(G,false)}}else{A.onShow(G);if(A.execShow){G.exist=true}}});C.drawn=true},getRightLevelToShow:function(C,A){var z=this.config;var D=z.levelsToShow;var B=z.constrained;if(!B){return D}while(!this.treeFitsInCanvas(C,A,D)&&D>1){D--}return D}});var e={construct:function(A){var B=(d.type(A)=="array");var z=new f(this.graphOptions,this.config.Node,this.config.Edge,this.config.Label);if(!B){(function(C,E){C.addNode(E);if(E.children){for(var D=0,F=E.children;D<F.length;D++){C.addAdjacence(E,F[D]);arguments.callee(C,F[D])}}})(z,A)}else{(function(K,L){var D=function(P){for(var O=0,M=L.length;O<M;O++){if(L[O].id==P){return L[O]}}var N={id:P,name:P};return K.addNode(N)};for(var H=0,E=L.length;H<E;H++){K.addNode(L[H]);var I=L[H].adjacencies;if(I){for(var F=0,J=I.length;F<J;F++){var C=I[F],G={};if(typeof I[F]!="string"){G=C.data;C=C.nodeTo}K.addAdjacence(L[H],D(C),G)}}}})(z,A)}return z},loadJSON:function(A,z){this.json=A;if(this.labels&&this.labels.clearLabels){this.labels.clearLabels(true)}this.graph=this.construct(A);if(d.type(A)!="array"){this.root=A.id}else{this.root=A[z?z:0].id}},toJSON:function(D){D=D||"tree";if(D=="tree"){var B={};var A=this.graph.getNode(this.root);var B=(function z(G){var E={};E.id=G.id;E.name=G.name;E.data=G.data;var F=[];G.eachSubnode(function(H){F.push(z(H))});E.children=F;return E})(A);return B}else{var B=[];var C=!!this.graph.getNode(this.root).visited;this.graph.eachNode(function(F){var E={};E.id=F.id;E.name=F.name;E.data=F.data;var G=[];F.eachAdjacency(function(H){var J=H.nodeTo;if(!!J.visited===C){var I={};I.nodeTo=J.id;I.data=H.data;G.push(I)}});E.adjacencies=G;B.push(E);F.visited=!C});return B}}};var i=$jit.Layouts={};var h={label:null,compute:function(C,D,A){this.initializeLabel(A);var z=this.label,B=z.style;C.eachNode(function(G){var K=G.getData("autoWidth"),L=G.getData("autoHeight");if(K||L){delete G.data.$width;delete G.data.$height;delete G.data.$dim;var E=G.getData("width"),M=G.getData("height");B.width=K?"auto":E+"px";B.height=L?"auto":M+"px";z.innerHTML=G.name;var I=z.offsetWidth,F=z.offsetHeight;var J=G.getData("type");if(d.indexOf(["circle","square","triangle","star"],J)===-1){G.setData("width",I);G.setData("height",F)}else{var H=I>F?I:F;G.setData("width",H);G.setData("height",H);G.setData("dim",H)}}})},initializeLabel:function(z){if(!this.label){this.label=document.createElement("div");document.body.appendChild(this.label)}this.setLabelStyles(z)},setLabelStyles:function(z){d.extend(this.label.style,{visibility:"hidden",position:"absolute",width:"auto",height:"auto"});this.label.className="jit-autoadjust-label"}};i.TM={};i.TM.SliceAndDice=new t({compute:function(E){var A=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(A);var C=this.canvas.getSize(),B=this.config,D=C.width,z=C.height;this.graph.computeLevels(this.root,0,"ignore");A.getPos(E).setc(-D/2,-z/2);A.setData("width",D,E);A.setData("height",z+B.titleHeight,E);this.computePositions(A,A,this.layout.orientation,E);this.controller.onAfterCompute(A)},computePositions:function(I,G,S,B){var P=0;I.eachSubnode(function(U){P+=U.getData("area",B)});var T=this.config,Q=T.offset,M=I.getData("width",B),K=I.getData("height",B)-T.titleHeight,A=I==G?1:(G.getData("area",B)/P);var L,J,O,E,D,H,F;var R=(S=="h");if(R){S="v";L=K;J=M*A;O="height";E="y";D="x";H=T.titleHeight;F=0}else{S="h";L=K*A;J=M;O="width";E="x";D="y";H=0;F=T.titleHeight}var z=G.getPos(B);G.setData("width",J,B);G.setData("height",L,B);var N=0,C=this;G.eachSubnode(function(V){var U=V.getPos(B);U[E]=N+z[E]+H;U[D]=z[D]+F;C.computePositions(G,V,S,B);N+=V.getData(O,B)})}});i.TM.Area={compute:function(z){z=z||"current";var F=this.graph.getNode(this.clickedNode&&this.clickedNode.id||this.root);this.controller.onBeforeCompute(F);var B=this.config,I=this.canvas.getSize(),A=I.width,H=I.height,G=B.offset,C=A-G,E=H-G;this.graph.computeLevels(this.root,0,"ignore");F.getPos(z).setc(-A/2,-H/2);F.setData("width",A,z);F.setData("height",H,z);var D={top:-H/2+B.titleHeight,left:-A/2,width:C,height:E-B.titleHeight};this.computePositions(F,D,z);this.controller.onAfterCompute(F)},computeDim:function(D,E,G,C,B,z){if(D.length+E.length==1){var A=(D.length==1)?D:E;this.layoutLast(A,G,C,z);return}if(D.length>=2&&E.length==0){E=[D.shift()]}if(D.length==0){if(E.length>0){this.layoutRow(E,G,C,z)}return}var F=D[0];if(B(E,G)>=B([F].concat(E),G)){this.computeDim(D.slice(1),E.concat([F]),G,C,B,z)}else{var H=this.layoutRow(E,G,C,z);this.computeDim(D,[],H.dim,H,B,z)}},worstAspectRatio:function(z,H){if(!z||z.length==0){return Number.MAX_VALUE}var A=0,I=0,D=Number.MAX_VALUE;for(var F=0,E=z.length;F<E;F++){var B=z[F]._area;A+=B;D=D<B?D:B;I=I>B?I:B}var G=H*H,C=A*A;return Math.max(G*I/C,C/(G*D))},avgAspectRatio:function(D,A){if(!D||D.length==0){return Number.MAX_VALUE}var F=0;for(var B=0,z=D.length;B<z;B++){var E=D[B]._area;var C=E/A;F+=A>C?A/C:C/A}return F/z},layoutLast:function(A,z,D,C){var B=A[0];B.getPos(C).setc(D.left,D.top);B.setData("width",D.width,C);B.setData("height",D.height,C)}};i.TM.Squarified=new t({Implements:i.TM.Area,computePositions:function(D,G,A){var C=this.config;if(!(G.width>=G.height&&this.layout.horizontal())){this.layout.change()}var z=D.getSubnodes([1,1],"ignore");if(z.length>0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;F<E;F++){var I=z[F];var J=C.offset,K=I.getData("height",A)-J-C.titleHeight,B=I.getData("width",A)-J;var H=I.getPos(A);G={width:B,height:K,top:H.y+C.titleHeight,left:H.x};this.computePositions(I,G,A)}}},processChildrenLayout:function(J,z,F,A){var D=F.width*F.height;var E,B=z.length,G=0,K=[];for(E=0;E<B;E++){K[E]=parseFloat(z[E].getData("area",A));G+=K[E]}for(E=0;E<B;E++){z[E]._area=D*K[E]/G}var C=this.layout.horizontal()?F.height:F.width;z.sort(function(M,L){var N=L._area-M._area;return N?N:(L.id==M.id?0:(L.id<M.id?1:-1))});var I=[z[0]];var H=z.slice(1);this.squarify(H,I,C,F,A)},squarify:function(A,D,z,C,B){this.computeDim(A,D,z,C,this.worstAspectRatio,B)},layoutRow:function(A,z,C,B){if(this.layout.horizontal()){return this.layoutV(A,z,C,B)}else{return this.layoutH(A,z,C,B)}},layoutV:function(z,K,G,A){var L=0,C=function(M){return M};d.each(z,function(M){L+=M._area});var B=C(L/K),H=0;for(var E=0,D=z.length;E<D;E++){var F=C(z[E]._area/B);var I=z[E];I.getPos(A).setc(G.left,G.top+H);I.setData("width",B,A);I.setData("height",F,A);H+=F}var J={height:G.height,width:G.width-B,top:G.top,left:G.left+B};J.dim=Math.min(J.width,J.height);if(J.dim!=J.height){this.layout.change()}return J},layoutH:function(z,I,E,A){var K=0;d.each(z,function(L){K+=L._area});var J=K/I,F=E.top,B=0;for(var D=0,C=z.length;D<C;D++){var G=z[D];var I=G._area/J;G.getPos(A).setc(E.left+B,F);G.setData("width",I,A);G.setData("height",J,A);B+=I}var H={height:E.height-J,width:E.width,top:E.top+J,left:E.left};H.dim=Math.min(H.width,H.height);if(H.dim!=H.width){this.layout.change()}return H}});i.TM.Strip=new t({Implements:i.TM.Area,computePositions:function(D,G,A){var z=D.getSubnodes([1,1],"ignore"),C=this.config;if(z.length>0){this.processChildrenLayout(D,z,G,A);for(var F=0,E=z.length;F<E;F++){var I=z[F];var J=C.offset,K=I.getData("height",A)-J-C.titleHeight,B=I.getData("width",A)-J;var H=I.getPos(A);G={width:B,height:K,top:H.y+C.titleHeight,left:H.x};this.computePositions(I,G,A)}}},processChildrenLayout:function(J,z,E,A){var C=E.width*E.height;var D,B=z.length,F=0,K=[];for(D=0;D<B;D++){K[D]=+z[D].getData("area",A);F+=K[D]}for(D=0;D<B;D++){z[D]._area=C*K[D]/F}var I=this.layout.horizontal()?E.width:E.height;var H=[z[0]];var G=z.slice(1);this.stripify(G,H,I,E,A)},stripify:function(A,D,z,C,B){this.computeDim(A,D,z,C,this.avgAspectRatio,B)},layoutRow:function(A,z,C,B){if(this.layout.horizontal()){return this.layoutH(A,z,C,B)}else{return this.layoutV(A,z,C,B)}},layoutV:function(z,I,F,A){var J=0;d.each(z,function(K){J+=K._area});var B=J/I,G=0;for(var D=0,C=z.length;D<C;D++){var H=z[D];var E=H._area/B;H.getPos(A).setc(F.left,F.top+(I-E-G));H.setData("width",B,A);H.setData("height",E,A);G+=E}return{height:F.height,width:F.width-B,top:F.top,left:F.left+B,dim:I}},layoutH:function(z,H,E,A){var J=0;d.each(z,function(L){J+=L._area});var I=J/H,F=E.height-I,B=0;for(var D=0,C=z.length;D<C;D++){var G=z[D];var K=G._area/I;G.getPos(A).setc(E.left+B,E.top+F);G.setData("width",K,A);G.setData("height",I,A);B+=K}return{height:E.height-I,width:E.width,top:E.top,left:E.left,dim:H}}});$jit.TM={};var y=$jit.TM;$jit.TM.$extend=true;y.Base={layout:{orientation:"h",vertical:function(){return this.orientation=="v"},horizontal:function(){return this.orientation=="h"},change:function(){this.orientation=this.vertical()?"h":"v"}},initialize:function(z){var A={orientation:"h",titleHeight:13,offset:2,levelsToShow:3,constrained:false,animate:false,Node:{type:"rectangle",overridable:true,width:3,height:3,color:"#444"},Label:{textAlign:"center",textBaseline:"top"},Edge:{type:"none"},duration:700,fps:45};this.controller=this.config=d.merge(p("Canvas","Node","Edge","Fx","Controller","Tips","NodeStyles","Events","Navigation","Label"),A,z);this.layout.orientation=this.config.orientation;var B=this.config;if(B.useCanvas){this.canvas=B.useCanvas;this.config.labelContainer=this.canvas.id+"-label"}else{if(B.background){B.background=d.merge({type:"Circles"},B.background)}this.canvas=new n(this,B);this.config.labelContainer=(typeof B.injectInto=="string"?B.injectInto:B.injectInto.id)+"-label"}this.graphOptions={complex:true,Node:{selected:false,exist:true,drawn:true}};this.graph=new f(this.graphOptions,this.config.Node,this.config.Edge);this.labels=new y.Label[B.Label.type](this);this.fx=new y.Plot(this);this.op=new y.Op(this);this.group=new y.Group(this);this.geom=new y.Geom(this);this.clickedNode=null;this.busy=false;this.initializeExtras()},refresh:function(){if(this.busy){return}this.busy=true;var A=this;if(this.config.animate){this.compute("end");this.geom.setRightLevelToShow(this.graph.getNode(this.root));this.fx.animate(d.merge(this.config,{modes:["linear","node-property:width:height"],onComplete:function(){A.busy=false}}))}else{var z=this.config.Label.type;if(z!="Native"){var A=this;this.graph.eachNode(function(B){A.labels.hideLabel(B,false)})}this.busy=false;this.compute();this.plot()}},plot:function(){this.fx.plot()},leaf:function(z){return z.getSubnodes([1,1],"ignore").length==0},enter:function(F){if(this.busy){return}this.busy=true;var B=this,A=this.config,D=this.graph,z=F,C=this.clickedNode;var E={onComplete:function(){if(A.levelsToShow>0){B.geom.setRightLevelToShow(F)}if(A.request){B.compute()}if(A.animate){D.nodeList.setData("alpha",0,"end");F.eachSubgraph(function(G){G.setData("alpha",1,"end")},"ignore");B.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){B.clickedNode=z;B.compute("end");B.clickedNode=C;B.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){B.busy=false;B.clickedNode=z}})}})}else{B.busy=false;B.clickedNode=F;B.refresh()}}};if(A.request){this.requestNodes(z,E)}else{E.onComplete()}},out:function(){if(this.busy){return}this.busy=true;this.events.hoveredNode=false;var D=this,B=this.config,F=this.graph,A=F.getNode(this.clickedNode&&this.clickedNode.id||this.root).getParents(),C=A[0],z=C,E=this.clickedNode;if(!C){this.busy=false;return}callback={onComplete:function(){D.clickedNode=C;if(B.request){D.requestNodes(C,{onComplete:function(){D.compute();D.plot();D.busy=false}})}else{D.compute();D.plot();D.busy=false}}};if(B.levelsToShow>0){this.geom.setRightLevelToShow(C)}if(B.animate){this.clickedNode=z;this.compute("end");this.clickedNode=E;this.fx.animate({modes:["linear","node-property:width:height"],duration:1000,onComplete:function(){D.clickedNode=z;F.eachNode(function(G){G.setDataset(["current","end"],{alpha:[0,1]})},"ignore");E.eachSubgraph(function(G){G.setData("alpha",1)},"ignore");D.fx.animate({duration:500,modes:["node-property:alpha"],onComplete:function(){callback.onComplete()}})}})}else{callback.onComplete()}},requestNodes:function(B,C){var A=d.merge(this.controller,C),z=this.config.levelsToShow;if(A.request){var E=[],D=B._depth;B.eachLevel(0,z,function(G){var F=z-(G._depth-D);if(G.drawn&&!G.anySubnode()&&F>0){E.push(G);G._level=F}});this.group.requestNodes(E,A)}else{A.onComplete()}}};y.Op=new t({Implements:f.Op,initialize:function(z){this.viz=z}});y.Geom=new t({Implements:f.Geom,getRightLevelToShow:function(){return this.viz.config.levelsToShow},setRightLevelToShow:function(A){var B=this.getRightLevelToShow(),z=this.viz.labels;A.eachLevel(0,B+1,function(D){var C=D._depth-A._depth;if(C>B){D.drawn=false;D.exist=false;D.ignore=true;z.hideLabel(D,false)}else{D.drawn=true;D.exist=true;delete D.ignore}});A.drawn=true;delete A.ignore}});y.Group=new t({initialize:function(z){this.viz=z;this.canvas=z.canvas;this.config=z.config},requestNodes:function(E,D){var C=0,A=E.length,G={};var B=function(){D.onComplete()};var z=this.viz;if(A==0){B()}for(var F=0;F<A;F++){G[E[F].id]=E[F];D.request(E[F].id,E[F]._level,{onComplete:function(I,H){if(H&&H.children){H.id=I;z.op.sum(H,{type:"nothing"})}if(++C==A){z.graph.computeLevels(z.root,0);B()}}})}}});y.Plot=new t({Implements:f.Plot,initialize:function(z){this.viz=z;this.config=z.config;this.node=this.config.Node;this.edge=this.config.Edge;this.animation=new x;this.nodeTypes=new y.Plot.NodeTypes;this.edgeTypes=new y.Plot.EdgeTypes;this.labels=z.labels},plot:function(B,A){var z=this.viz,C=z.graph;z.canvas.clear();this.plotTree(C.getNode(z.clickedNode&&z.clickedNode.id||z.root),d.merge(z.config,B||{},{withLabels:true,hideLabels:false,plotSubtree:function(E,D){return E.anySubnode("exist")}}),A)}});y.Label={};y.Label.Native=new t({Implements:f.Label.Native,initialize:function(z){this.config=z.config;this.leaf=z.leaf},renderLabel:function(A,B,C){if(!this.leaf(B)&&!this.config.titleHeight){return}var E=B.pos.getc(true),H=A.getCtx(),z=B.getData("width"),G=B.getData("height"),F=E.x+z/2,D=E.y;H.fillText(B.name,F,D,z)}});y.Label.SVG=new t({Implements:f.Label.SVG,initialize:function(z){this.viz=z;this.leaf=z.leaf;this.config=z.config},placeLabel:function(J,D,E){var H=D.pos.getc(true),A=this.viz.canvas,B=A.translateOffsetX,z=A.translateOffsetY,I=A.scaleOffsetX,G=A.scaleOffsetY,F=A.getSize();var C={x:Math.round(H.x*I+B+F.width/2),y:Math.round(H.y*G+z+F.height/2)};J.setAttribute("x",C.x);J.setAttribute("y",C.y);if(!this.leaf(D)&&!this.config.titleHeight){J.style.display="none"}E.onPlaceLabel(J,D)}});y.Label.HTML=new t({Implements:f.Label.HTML,initialize:function(z){this.viz=z;this.leaf=z.leaf;this.config=z.config},placeLabel:function(K,E,F){var I=E.pos.getc(true),B=this.viz.canvas,C=B.translateOffsetX,A=B.translateOffsetY,J=B.scaleOffsetX,H=B.scaleOffsetY,G=B.getSize();var D={x:Math.round(I.x*J+C+G.width/2),y:Math.round(I.y*H+A+G.height/2)};var z=K.style;z.left=D.x+"px";z.top=D.y+"px";z.width=E.getData("width")*J+"px";z.height=E.getData("height")*H+"px";z.zIndex=E._depth*100;z.display="";if(!this.leaf(E)&&!this.config.titleHeight){K.style.display="none"}F.onPlaceLabel(K,E)}});y.Plot.NodeTypes=new t({none:{render:d.empty},rectangle:{render:function(C,A,P){var G=this.viz.leaf(C),B=this.config,L=B.offset,F=B.titleHeight,K=C.pos.getc(true),z=C.getData("width"),M=C.getData("height"),E=C.getData("border"),O=A.getCtx(),J=K.x+L/2,H=K.y+L/2;if(z<=L||M<=L){return}if(G){if(B.cushion){var N=O.createRadialGradient(J+(z-L)/2,H+(M-L)/2,1,J+(z-L)/2,H+(M-L)/2,z<M?M:z);var D=C.getData("color");var I=d.rgbToHex(d.map(d.hexToRgb(D),function(Q){return Q*0.2>>0}));N.addColorStop(0,D);N.addColorStop(1,I);O.fillStyle=N}O.fillRect(J,H,z-L,M-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(J,H,z-L,M-L);O.restore()}}else{if(F>0){O.fillRect(K.x+L/2,K.y+L/2,z-L,F-L);if(E){O.save();O.strokeStyle=E;O.strokeRect(K.x+L/2,K.y+L/2,z-L,M-L);O.restore()}}}},contains:function(C,E){if(this.viz.clickedNode&&!C.isDescendantOf(this.viz.clickedNode.id)||C.ignore){return false}var D=C.pos.getc(true),B=C.getData("width"),A=this.viz.leaf(C),z=A?C.getData("height"):this.config.titleHeight;return this.nodeHelper.rectangle.contains({x:D.x+B/2,y:D.y+z/2},E,B,z)}}});y.Plot.EdgeTypes=new t({none:d.empty});y.SliceAndDice=new t({Implements:[e,q,y.Base,i.TM.SliceAndDice]});y.Squarified=new t({Implements:[e,q,y.Base,i.TM.Squarified]});y.Strip=new t({Implements:[e,q,y.Base,i.TM.Strip]})})();
